惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
T
Tailwind CSS Blog
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
H
Help Net Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
腾讯CDC
GbyAI
GbyAI
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Last Week in AI
Last Week in AI
A
About on SuperTechFans
L
LangChain Blog
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
G
Google Developers Blog
The Cloudflare Blog
云风的 BLOG
云风的 BLOG
D
Docker
博客园 - 聂微东
博客园 - 司徒正美
Recent Announcements
Recent Announcements
MyScale Blog
MyScale Blog
U
Unit 42

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(config): sanitize plugin session hydration · openclaw...
vincentkoc · 2026-05-16 · via Recent Commits to openclaw:main

@@ -1,5 +1,7 @@

11

import fs from "node:fs";

22

import { createSubsystemLogger } from "../../logging/subsystem.js";

3+

import { isPluginJsonValue, type PluginJsonValue } from "../../plugins/host-hook-json.js";

4+

import { normalizeSessionEntrySlotKey } from "../../plugins/session-entry-slot-keys.js";

35

import {

46

normalizeDeliveryContext,

57

normalizeSessionDeliveryFields,

@@ -59,6 +61,11 @@ function normalizeOptionalStringOrNull(value: unknown): string | null | undefine

5961

return undefined;

6062

}

616364+

function normalizeRecordKey(value: string): string | undefined {

65+

const key = value.trim();

66+

return key.length > 0 ? key : undefined;

67+

}

68+6269

function normalizeOptionalDeliveryContext(

6370

value: unknown,

6471

): SessionEntry["pendingFinalDeliveryContext"] {

@@ -138,6 +145,111 @@ function normalizePendingFinalDeliveryFields(entry: SessionEntry): SessionEntry

138145

return next;

139146

}

140147148+

function normalizePluginExtensions(entry: SessionEntry): SessionEntry {

149+

if (entry.pluginExtensions === undefined) {

150+

return entry;

151+

}

152+

if (!isRecord(entry.pluginExtensions)) {

153+

const next = { ...entry };

154+

delete next.pluginExtensions;

155+

return next;

156+

}

157+158+

let changed = false;

159+

const normalizedExtensions: Record<string, Record<string, PluginJsonValue>> = {};

160+

for (const [rawPluginId, rawPluginState] of Object.entries(entry.pluginExtensions)) {

161+

const pluginId = normalizeRecordKey(rawPluginId);

162+

if (!pluginId || !isRecord(rawPluginState)) {

163+

changed = true;

164+

continue;

165+

}

166+

if (pluginId !== rawPluginId) {

167+

changed = true;

168+

}

169+

const normalizedPluginState: Record<string, PluginJsonValue> = {};

170+

for (const [rawNamespace, rawValue] of Object.entries(rawPluginState)) {

171+

const namespace = normalizeRecordKey(rawNamespace);

172+

if (!namespace || !isPluginJsonValue(rawValue)) {

173+

changed = true;

174+

continue;

175+

}

176+

if (namespace !== rawNamespace) {

177+

changed = true;

178+

}

179+

normalizedPluginState[namespace] = rawValue;

180+

}

181+

if (Object.keys(normalizedPluginState).length === 0) {

182+

changed = true;

183+

continue;

184+

}

185+

normalizedExtensions[pluginId] = normalizedPluginState;

186+

}

187+188+

if (!changed) {

189+

return entry;

190+

}

191+

const next = { ...entry };

192+

if (Object.keys(normalizedExtensions).length > 0) {

193+

next.pluginExtensions = normalizedExtensions;

194+

} else {

195+

delete next.pluginExtensions;

196+

}

197+

return next;

198+

}

199+200+

function normalizePluginExtensionSlotKeys(entry: SessionEntry): SessionEntry {

201+

if (entry.pluginExtensionSlotKeys === undefined) {

202+

return entry;

203+

}

204+

if (!isRecord(entry.pluginExtensionSlotKeys)) {

205+

const next = { ...entry };

206+

delete next.pluginExtensionSlotKeys;

207+

return next;

208+

}

209+210+

let changed = false;

211+

const normalizedSlotKeys: Record<string, Record<string, string>> = {};

212+

for (const [rawPluginId, rawPluginSlots] of Object.entries(entry.pluginExtensionSlotKeys)) {

213+

const pluginId = normalizeRecordKey(rawPluginId);

214+

if (!pluginId || !isRecord(rawPluginSlots)) {

215+

changed = true;

216+

continue;

217+

}

218+

if (pluginId !== rawPluginId) {

219+

changed = true;

220+

}

221+

const normalizedPluginSlots: Record<string, string> = {};

222+

for (const [rawNamespace, rawSlotKey] of Object.entries(rawPluginSlots)) {

223+

const namespace = normalizeRecordKey(rawNamespace);

224+

const slotKey = normalizeSessionEntrySlotKey(rawSlotKey);

225+

if (!namespace || !slotKey.ok) {

226+

changed = true;

227+

continue;

228+

}

229+

if (namespace !== rawNamespace || slotKey.key !== rawSlotKey) {

230+

changed = true;

231+

}

232+

normalizedPluginSlots[namespace] = slotKey.key;

233+

}

234+

if (Object.keys(normalizedPluginSlots).length === 0) {

235+

changed = true;

236+

continue;

237+

}

238+

normalizedSlotKeys[pluginId] = normalizedPluginSlots;

239+

}

240+241+

if (!changed) {

242+

return entry;

243+

}

244+

const next = { ...entry };

245+

if (Object.keys(normalizedSlotKeys).length > 0) {

246+

next.pluginExtensionSlotKeys = normalizedSlotKeys;

247+

} else {

248+

delete next.pluginExtensionSlotKeys;

249+

}

250+

return next;

251+

}

252+141253

function normalizeSessionEntryDelivery(entry: SessionEntry): SessionEntry {

142254

const normalized = normalizeSessionDeliveryFields({

143255

channel: entry.channel,

@@ -195,8 +307,12 @@ export function normalizeSessionStore(store: Record<string, SessionEntry>): bool

195307

continue;

196308

}

197309

const normalized = stripPersistedSkillsCache(

198-

normalizePendingFinalDeliveryFields(

199-

normalizeSessionEntryDelivery(normalizeSessionRuntimeModelFields(entry)),

310+

normalizePluginExtensionSlotKeys(

311+

normalizePluginExtensions(

312+

normalizePendingFinalDeliveryFields(

313+

normalizeSessionEntryDelivery(normalizeSessionRuntimeModelFields(entry)),

314+

),

315+

),

200316

),

201317

);

202318

if (normalized !== entry) {