mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
refactor: remove redundant session patch conversions
This commit is contained in:
@@ -112,7 +112,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
return invalid("spawnedBy cannot be cleared once set");
|
||||
}
|
||||
} else if (raw !== undefined) {
|
||||
const trimmed = normalizeOptionalString(String(raw)) ?? "";
|
||||
const trimmed = normalizeOptionalString(raw) ?? "";
|
||||
if (!trimmed) {
|
||||
return invalid("invalid spawnedBy: empty");
|
||||
}
|
||||
@@ -136,7 +136,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (!supportsSpawnLineage(storeKey)) {
|
||||
return invalid("spawnedWorkspaceDir is only supported for subagent:* or acp:* sessions");
|
||||
}
|
||||
const trimmed = normalizeOptionalString(String(raw)) ?? "";
|
||||
const trimmed = normalizeOptionalString(raw) ?? "";
|
||||
if (!trimmed) {
|
||||
return invalid("invalid spawnedWorkspaceDir: empty");
|
||||
}
|
||||
@@ -157,7 +157,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (!supportsSpawnLineage(storeKey)) {
|
||||
return invalid("spawnDepth is only supported for subagent:* or acp:* sessions");
|
||||
}
|
||||
const numeric = Number(raw);
|
||||
const numeric = raw;
|
||||
if (!Number.isInteger(numeric) || numeric < 0) {
|
||||
return invalid("invalid spawnDepth (use an integer >= 0)");
|
||||
}
|
||||
@@ -179,7 +179,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (!supportsSpawnLineage(storeKey)) {
|
||||
return invalid("subagentRole is only supported for subagent:* or acp:* sessions");
|
||||
}
|
||||
const normalized = normalizeSubagentRole(String(raw));
|
||||
const normalized = normalizeSubagentRole(raw);
|
||||
if (!normalized) {
|
||||
return invalid('invalid subagentRole (use "orchestrator" or "leaf")');
|
||||
}
|
||||
@@ -200,7 +200,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (!supportsSpawnLineage(storeKey)) {
|
||||
return invalid("subagentControlScope is only supported for subagent:* or acp:* sessions");
|
||||
}
|
||||
const normalized = normalizeSubagentControlScope(String(raw));
|
||||
const normalized = normalizeSubagentControlScope(raw);
|
||||
if (!normalized) {
|
||||
return invalid('invalid subagentControlScope (use "children" or "none")');
|
||||
}
|
||||
@@ -238,7 +238,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
// Clear the override and fall back to model default
|
||||
delete next.thinkingLevel;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeThinkLevel(String(raw));
|
||||
const normalized = normalizeThinkLevel(raw);
|
||||
if (!normalized) {
|
||||
const hintProvider =
|
||||
normalizeOptionalString(existing?.providerOverride) || resolvedDefault.provider;
|
||||
@@ -278,7 +278,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (raw === null) {
|
||||
delete next.reasoningLevel;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeReasoningLevel(String(raw));
|
||||
const normalized = normalizeReasoningLevel(raw);
|
||||
if (!normalized) {
|
||||
return invalid('invalid reasoningLevel (use "on"|"off"|"stream")');
|
||||
}
|
||||
@@ -293,7 +293,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (raw === null) {
|
||||
delete next.responseUsage;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeUsageDisplay(String(raw));
|
||||
const normalized = normalizeUsageDisplay(raw);
|
||||
if (!normalized) {
|
||||
return invalid('invalid responseUsage (use "off"|"tokens"|"full")');
|
||||
}
|
||||
@@ -310,7 +310,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (raw === null) {
|
||||
delete next.elevatedLevel;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeElevatedLevel(String(raw));
|
||||
const normalized = normalizeElevatedLevel(raw);
|
||||
if (!normalized) {
|
||||
return invalid('invalid elevatedLevel (use "on"|"off"|"ask"|"full")');
|
||||
}
|
||||
@@ -324,7 +324,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (raw === null) {
|
||||
delete next.execHost;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeExecTarget(String(raw)) ?? undefined;
|
||||
const normalized = normalizeExecTarget(raw) ?? undefined;
|
||||
if (!normalized) {
|
||||
return invalid('invalid execHost (use "auto"|"sandbox"|"gateway"|"node")');
|
||||
}
|
||||
@@ -337,7 +337,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (raw === null) {
|
||||
delete next.execSecurity;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeExecSecurity(String(raw));
|
||||
const normalized = normalizeExecSecurity(raw);
|
||||
if (!normalized) {
|
||||
return invalid('invalid execSecurity (use "deny"|"allowlist"|"full")');
|
||||
}
|
||||
@@ -350,7 +350,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (raw === null) {
|
||||
delete next.execAsk;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeExecAsk(String(raw));
|
||||
const normalized = normalizeExecAsk(raw);
|
||||
if (!normalized) {
|
||||
return invalid('invalid execAsk (use "off"|"on-miss"|"always")');
|
||||
}
|
||||
@@ -363,7 +363,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (raw === null) {
|
||||
delete next.execNode;
|
||||
} else if (raw !== undefined) {
|
||||
const trimmed = normalizeOptionalString(String(raw)) ?? "";
|
||||
const trimmed = normalizeOptionalString(raw) ?? "";
|
||||
if (!trimmed) {
|
||||
return invalid("invalid execNode: empty");
|
||||
}
|
||||
@@ -384,7 +384,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
markLiveSwitchPending: true,
|
||||
});
|
||||
} else if (raw !== undefined) {
|
||||
const trimmed = normalizeOptionalString(String(raw)) ?? "";
|
||||
const trimmed = normalizeOptionalString(raw) ?? "";
|
||||
if (!trimmed) {
|
||||
return invalid("invalid model: empty");
|
||||
}
|
||||
@@ -436,7 +436,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (raw === null) {
|
||||
delete next.sendPolicy;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeSendPolicy(String(raw));
|
||||
const normalized = normalizeSendPolicy(raw);
|
||||
if (!normalized) {
|
||||
return invalid('invalid sendPolicy (use "allow"|"deny")');
|
||||
}
|
||||
@@ -449,7 +449,7 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (raw === null) {
|
||||
delete next.groupActivation;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeGroupActivation(String(raw));
|
||||
const normalized = normalizeGroupActivation(raw);
|
||||
if (!normalized) {
|
||||
return invalid('invalid groupActivation (use "mention"|"always")');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user