mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 18:40:21 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -76,10 +76,14 @@ export async function applySessionsPatchToStore(params: {
|
||||
if ("spawnedBy" in patch) {
|
||||
const raw = patch.spawnedBy;
|
||||
if (raw === null) {
|
||||
if (existing?.spawnedBy) return invalid("spawnedBy cannot be cleared once set");
|
||||
if (existing?.spawnedBy) {
|
||||
return invalid("spawnedBy cannot be cleared once set");
|
||||
}
|
||||
} else if (raw !== undefined) {
|
||||
const trimmed = String(raw).trim();
|
||||
if (!trimmed) return invalid("invalid spawnedBy: empty");
|
||||
if (!trimmed) {
|
||||
return invalid("invalid spawnedBy: empty");
|
||||
}
|
||||
if (!isSubagentSessionKey(storeKey)) {
|
||||
return invalid("spawnedBy is only supported for subagent:* sessions");
|
||||
}
|
||||
@@ -96,9 +100,13 @@ export async function applySessionsPatchToStore(params: {
|
||||
delete next.label;
|
||||
} else if (raw !== undefined) {
|
||||
const parsed = parseSessionLabel(raw);
|
||||
if (!parsed.ok) return invalid(parsed.error);
|
||||
if (!parsed.ok) {
|
||||
return invalid(parsed.error);
|
||||
}
|
||||
for (const [key, entry] of Object.entries(store)) {
|
||||
if (key === storeKey) continue;
|
||||
if (key === storeKey) {
|
||||
continue;
|
||||
}
|
||||
if (entry?.label === parsed.label) {
|
||||
return invalid(`label already in use: ${parsed.label}`);
|
||||
}
|
||||
@@ -125,15 +133,20 @@ export async function applySessionsPatchToStore(params: {
|
||||
`invalid thinkingLevel (use ${formatThinkingLevels(hintProvider, hintModel, "|")})`,
|
||||
);
|
||||
}
|
||||
if (normalized === "off") delete next.thinkingLevel;
|
||||
else next.thinkingLevel = normalized;
|
||||
if (normalized === "off") {
|
||||
delete next.thinkingLevel;
|
||||
} else {
|
||||
next.thinkingLevel = normalized;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ("verboseLevel" in patch) {
|
||||
const raw = patch.verboseLevel;
|
||||
const parsed = parseVerboseOverride(raw);
|
||||
if (!parsed.ok) return invalid(parsed.error);
|
||||
if (!parsed.ok) {
|
||||
return invalid(parsed.error);
|
||||
}
|
||||
applyVerboseOverride(next, parsed.value);
|
||||
}
|
||||
|
||||
@@ -146,8 +159,11 @@ export async function applySessionsPatchToStore(params: {
|
||||
if (!normalized) {
|
||||
return invalid('invalid reasoningLevel (use "on"|"off"|"stream")');
|
||||
}
|
||||
if (normalized === "off") delete next.reasoningLevel;
|
||||
else next.reasoningLevel = normalized;
|
||||
if (normalized === "off") {
|
||||
delete next.reasoningLevel;
|
||||
} else {
|
||||
next.reasoningLevel = normalized;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,9 +173,14 @@ export async function applySessionsPatchToStore(params: {
|
||||
delete next.responseUsage;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeUsageDisplay(String(raw));
|
||||
if (!normalized) return invalid('invalid responseUsage (use "off"|"tokens"|"full")');
|
||||
if (normalized === "off") delete next.responseUsage;
|
||||
else next.responseUsage = normalized;
|
||||
if (!normalized) {
|
||||
return invalid('invalid responseUsage (use "off"|"tokens"|"full")');
|
||||
}
|
||||
if (normalized === "off") {
|
||||
delete next.responseUsage;
|
||||
} else {
|
||||
next.responseUsage = normalized;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +190,9 @@ export async function applySessionsPatchToStore(params: {
|
||||
delete next.elevatedLevel;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeElevatedLevel(String(raw));
|
||||
if (!normalized) return invalid('invalid elevatedLevel (use "on"|"off"|"ask"|"full")');
|
||||
if (!normalized) {
|
||||
return invalid('invalid elevatedLevel (use "on"|"off"|"ask"|"full")');
|
||||
}
|
||||
// Persist "off" explicitly so patches can override defaults.
|
||||
next.elevatedLevel = normalized;
|
||||
}
|
||||
@@ -181,7 +204,9 @@ export async function applySessionsPatchToStore(params: {
|
||||
delete next.execHost;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeExecHost(String(raw));
|
||||
if (!normalized) return invalid('invalid execHost (use "sandbox"|"gateway"|"node")');
|
||||
if (!normalized) {
|
||||
return invalid('invalid execHost (use "sandbox"|"gateway"|"node")');
|
||||
}
|
||||
next.execHost = normalized;
|
||||
}
|
||||
}
|
||||
@@ -192,7 +217,9 @@ export async function applySessionsPatchToStore(params: {
|
||||
delete next.execSecurity;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeExecSecurity(String(raw));
|
||||
if (!normalized) return invalid('invalid execSecurity (use "deny"|"allowlist"|"full")');
|
||||
if (!normalized) {
|
||||
return invalid('invalid execSecurity (use "deny"|"allowlist"|"full")');
|
||||
}
|
||||
next.execSecurity = normalized;
|
||||
}
|
||||
}
|
||||
@@ -203,7 +230,9 @@ export async function applySessionsPatchToStore(params: {
|
||||
delete next.execAsk;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeExecAsk(String(raw));
|
||||
if (!normalized) return invalid('invalid execAsk (use "off"|"on-miss"|"always")');
|
||||
if (!normalized) {
|
||||
return invalid('invalid execAsk (use "off"|"on-miss"|"always")');
|
||||
}
|
||||
next.execAsk = normalized;
|
||||
}
|
||||
}
|
||||
@@ -214,7 +243,9 @@ export async function applySessionsPatchToStore(params: {
|
||||
delete next.execNode;
|
||||
} else if (raw !== undefined) {
|
||||
const trimmed = String(raw).trim();
|
||||
if (!trimmed) return invalid("invalid execNode: empty");
|
||||
if (!trimmed) {
|
||||
return invalid("invalid execNode: empty");
|
||||
}
|
||||
next.execNode = trimmed;
|
||||
}
|
||||
}
|
||||
@@ -237,7 +268,9 @@ export async function applySessionsPatchToStore(params: {
|
||||
});
|
||||
} else if (raw !== undefined) {
|
||||
const trimmed = String(raw).trim();
|
||||
if (!trimmed) return invalid("invalid model: empty");
|
||||
if (!trimmed) {
|
||||
return invalid("invalid model: empty");
|
||||
}
|
||||
if (!params.loadGatewayModelCatalog) {
|
||||
return {
|
||||
ok: false,
|
||||
@@ -291,7 +324,9 @@ export async function applySessionsPatchToStore(params: {
|
||||
delete next.sendPolicy;
|
||||
} else if (raw !== undefined) {
|
||||
const normalized = normalizeSendPolicy(String(raw));
|
||||
if (!normalized) return invalid('invalid sendPolicy (use "allow"|"deny")');
|
||||
if (!normalized) {
|
||||
return invalid('invalid sendPolicy (use "allow"|"deny")');
|
||||
}
|
||||
next.sendPolicy = normalized;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user