
























@@ -7,7 +7,10 @@ import {
77resolveIntegerOption,
88resolveNonNegativeIntegerOption,
99} from "@openclaw/normalization-core/number-coercion";
10-import { normalizeOptionalLowercaseString } from "@openclaw/normalization-core/string-coerce";
10+import {
11+normalizeOptionalLowercaseString,
12+normalizeOptionalString,
13+} from "@openclaw/normalization-core/string-coerce";
1114import { DEFAULT_SUBAGENT_MAX_SPAWN_DEPTH } from "../config/agent-limits.js";
1215import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
1316import type { OpenClawConfig } from "../config/types.openclaw.js";
@@ -21,7 +24,6 @@ import {
2124normalizeInheritedToolDenylist,
2225} from "./inherited-tool-deny.js";
2326import { getSubagentDepthFromSessionStore } from "./subagent-depth.js";
24-import { normalizeSubagentSessionKey } from "./subagent-session-key.js";
25272628/** Resolved role for a main session, orchestrating subagent, or leaf subagent. */
2729export type SubagentSessionRole = "main" | "orchestrator" | "leaf";
@@ -96,14 +98,14 @@ function findEntryBySessionId(
9698store: SessionCapabilityStore,
9799sessionId: string,
98100): SessionCapabilityEntry | undefined {
99-const normalizedSessionId = normalizeSubagentSessionKey(sessionId);
101+const normalizedSessionId = normalizeOptionalString(sessionId);
100102if (!normalizedSessionId) {
101103return undefined;
102104}
103105for (const entry of Object.values(store)) {
104106// Older callers may know the session id but not the exact store key, so
105107// persisted entries are searchable by their normalized embedded sessionId.
106-const candidateSessionId = normalizeSubagentSessionKey(entry?.sessionId);
108+const candidateSessionId = normalizeOptionalString(entry?.sessionId);
107109if (candidateSessionId === normalizedSessionId) {
108110return entry;
109111}
@@ -139,7 +141,7 @@ export function resolveSubagentCapabilityStore(
139141store?: SessionCapabilityStore;
140142},
141143): SessionCapabilityStore | undefined {
142-const normalizedSessionKey = normalizeSubagentSessionKey(sessionKey);
144+const normalizedSessionKey = normalizeOptionalString(sessionKey);
143145if (!normalizedSessionKey) {
144146return opts?.store;
145147}
@@ -201,7 +203,7 @@ function isStoredSubagentEnvelopeSession(
201203},
202204visited = new Set<string>(),
203205): boolean {
204-const normalizedSessionKey = normalizeSubagentSessionKey(params.sessionKey);
206+const normalizedSessionKey = normalizeOptionalString(params.sessionKey);
205207if (!normalizedSessionKey || visited.has(normalizedSessionKey)) {
206208return false;
207209}
@@ -228,7 +230,7 @@ function isStoredSubagentEnvelopeSession(
228230return true;
229231}
230232231-const spawnedBy = normalizeSubagentSessionKey(entry?.spawnedBy);
233+const spawnedBy = normalizeOptionalString(entry?.spawnedBy);
232234if (!spawnedBy) {
233235return false;
234236}
@@ -256,7 +258,7 @@ export function isSubagentEnvelopeSession(
256258entry?: SessionCapabilityEntry;
257259},
258260): boolean {
259-const normalizedSessionKey = normalizeSubagentSessionKey(sessionKey);
261+const normalizedSessionKey = normalizeOptionalString(sessionKey);
260262if (!normalizedSessionKey) {
261263return false;
262264}
@@ -286,7 +288,7 @@ export function resolveStoredSubagentCapabilities(
286288store?: SessionCapabilityStore;
287289},
288290) {
289-const normalizedSessionKey = normalizeSubagentSessionKey(sessionKey);
291+const normalizedSessionKey = normalizeOptionalString(sessionKey);
290292const maxSpawnDepth =
291293opts?.cfg?.agents?.defaults?.subagents?.maxSpawnDepth ?? DEFAULT_SUBAGENT_MAX_SPAWN_DEPTH;
292294if (!normalizedSessionKey) {
@@ -339,7 +341,7 @@ export function resolveStoredSubagentInheritedToolDenylist(
339341store?: SessionCapabilityStore;
340342},
341343): string[] {
342-const normalizedSessionKey = normalizeSubagentSessionKey(sessionKey);
344+const normalizedSessionKey = normalizeOptionalString(sessionKey);
343345if (!normalizedSessionKey || !shouldInspectStoredSubagentEnvelope(normalizedSessionKey)) {
344346return [];
345347}
@@ -360,7 +362,7 @@ export function resolveStoredSubagentInheritedToolAllowlist(
360362store?: SessionCapabilityStore;
361363},
362364): string[] {
363-const normalizedSessionKey = normalizeSubagentSessionKey(sessionKey);
365+const normalizedSessionKey = normalizeOptionalString(sessionKey);
364366if (!normalizedSessionKey || !shouldInspectStoredSubagentEnvelope(normalizedSessionKey)) {
365367return [];
366368}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。