mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 01:41:36 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -12,7 +12,9 @@ export function resolveMainSessionKey(cfg?: {
|
||||
session?: { scope?: SessionScope; mainKey?: string };
|
||||
agents?: { list?: Array<{ id?: string; default?: boolean }> };
|
||||
}): string {
|
||||
if (cfg?.session?.scope === "global") return "global";
|
||||
if (cfg?.session?.scope === "global") {
|
||||
return "global";
|
||||
}
|
||||
const agents = cfg?.agents?.list ?? [];
|
||||
const defaultAgentId =
|
||||
agents.find((agent) => agent?.default)?.id ?? agents[0]?.id ?? DEFAULT_AGENT_ID;
|
||||
@@ -40,7 +42,9 @@ export function resolveExplicitAgentSessionKey(params: {
|
||||
agentId?: string | null;
|
||||
}): string | undefined {
|
||||
const agentId = params.agentId?.trim();
|
||||
if (!agentId) return undefined;
|
||||
if (!agentId) {
|
||||
return undefined;
|
||||
}
|
||||
return resolveAgentMainSessionKey({ cfg: params.cfg, agentId });
|
||||
}
|
||||
|
||||
@@ -50,7 +54,9 @@ export function canonicalizeMainSessionAlias(params: {
|
||||
sessionKey: string;
|
||||
}): string {
|
||||
const raw = params.sessionKey.trim();
|
||||
if (!raw) return raw;
|
||||
if (!raw) {
|
||||
return raw;
|
||||
}
|
||||
|
||||
const agentId = normalizeAgentId(params.agentId);
|
||||
const mainKey = normalizeMainKey(params.cfg?.session?.mainKey);
|
||||
@@ -63,7 +69,11 @@ export function canonicalizeMainSessionAlias(params: {
|
||||
const isMainAlias =
|
||||
raw === "main" || raw === mainKey || raw === agentMainSessionKey || raw === agentMainAliasKey;
|
||||
|
||||
if (params.cfg?.session?.scope === "global" && isMainAlias) return "global";
|
||||
if (isMainAlias) return agentMainSessionKey;
|
||||
if (params.cfg?.session?.scope === "global" && isMainAlias) {
|
||||
return "global";
|
||||
}
|
||||
if (isMainAlias) {
|
||||
return agentMainSessionKey;
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user