From 30098b04d7298407a9eb8b2896f33e891b74d542 Mon Sep 17 00:00:00 2001 From: Vignesh Natarajan Date: Mon, 2 Feb 2026 21:15:43 -0800 Subject: [PATCH] chore: fix lint warnings --- src/agents/system-prompt.ts | 46 ++++++++++++++++++++++++--------- src/agents/tools/memory-tool.ts | 27 ++++++++++++++----- src/commands/status.scan.ts | 18 +++++++++---- src/config/zod-schema.ts | 16 +++++++++--- src/memory/search-manager.ts | 2 +- 5 files changed, 80 insertions(+), 29 deletions(-) diff --git a/src/agents/system-prompt.ts b/src/agents/system-prompt.ts index e8345cdb9..589f29ca2 100644 --- a/src/agents/system-prompt.ts +++ b/src/agents/system-prompt.ts @@ -18,9 +18,13 @@ function buildSkillsSection(params: { isMinimal: boolean; readToolName: string; }) { - if (params.isMinimal) return []; + if (params.isMinimal) { + return []; + } const trimmed = params.skillsPrompt?.trim(); - if (!trimmed) return []; + if (!trimmed) { + return []; + } return [ "## Skills (mandatory)", "Before replying: scan entries.", @@ -38,7 +42,9 @@ function buildMemorySection(params: { availableTools: Set; citationsMode?: MemoryCitationsMode; }) { - if (params.isMinimal) return []; + if (params.isMinimal) { + return []; + } if (!params.availableTools.has("memory_search") && !params.availableTools.has("memory_get")) { return []; } @@ -60,17 +66,23 @@ function buildMemorySection(params: { } function buildUserIdentitySection(ownerLine: string | undefined, isMinimal: boolean) { - if (!ownerLine || isMinimal) return []; + if (!ownerLine || isMinimal) { + return []; + } return ["## User Identity", ownerLine, ""]; } function buildTimeSection(params: { userTimezone?: string }) { - if (!params.userTimezone) return []; + if (!params.userTimezone) { + return []; + } return ["## Current Date & Time", `Time zone: ${params.userTimezone}`, ""]; } function buildReplyTagsSection(isMinimal: boolean) { - if (isMinimal) return []; + if (isMinimal) { + return []; + } return [ "## Reply Tags", "To request a native reply/quote on supported surfaces, include one tag in your reply:", @@ -90,7 +102,9 @@ function buildMessagingSection(params: { runtimeChannel?: string; messageToolHints?: string[]; }) { - if (params.isMinimal) return []; + if (params.isMinimal) { + return []; + } return [ "## Messaging", "- Reply in current session → automatically routes to the source channel (Signal, Telegram, etc.)", @@ -119,15 +133,21 @@ function buildMessagingSection(params: { } function buildVoiceSection(params: { isMinimal: boolean; ttsHint?: string }) { - if (params.isMinimal) return []; + if (params.isMinimal) { + return []; + } const hint = params.ttsHint?.trim(); - if (!hint) return []; + if (!hint) { + return []; + } return ["## Voice (TTS)", hint, ""]; } function buildDocsSection(params: { docsPath?: string; isMinimal: boolean; readToolName: string }) { const docsPath = params.docsPath?.trim(); - if (!docsPath || params.isMinimal) return []; + if (!docsPath || params.isMinimal) { + return []; + } return [ "## Documentation", `OpenClaw docs: ${docsPath}`, @@ -268,7 +288,9 @@ export function buildAgentSystemPrompt(params: { const externalToolSummaries = new Map(); for (const [key, value] of Object.entries(params.toolSummaries ?? {})) { const normalized = key.trim().toLowerCase(); - if (!normalized || !value?.trim()) continue; + if (!normalized || !value?.trim()) { + continue; + } externalToolSummaries.set(normalized, value.trim()); } const extraTools = Array.from( @@ -280,7 +302,7 @@ export function buildAgentSystemPrompt(params: { const name = resolveToolName(tool); return summary ? `- ${name}: ${summary}` : `- ${name}`; }); - for (const tool of extraTools.sort()) { + for (const tool of extraTools.toSorted()) { const summary = coreToolSummaries[tool] ?? externalToolSummaries.get(tool); const name = resolveToolName(tool); toolLines.push(summary ? `- ${name}: ${summary}` : `- ${name}`); diff --git a/src/agents/tools/memory-tool.ts b/src/agents/tools/memory-tool.ts index 3f793e364..270ebdb2d 100644 --- a/src/agents/tools/memory-tool.ts +++ b/src/agents/tools/memory-tool.ts @@ -27,12 +27,16 @@ export function createMemorySearchTool(options: { agentSessionKey?: string; }): AnyAgentTool | null { const cfg = options.config; - if (!cfg) return null; + if (!cfg) { + return null; + } const agentId = resolveSessionAgentId({ sessionKey: options.agentSessionKey, config: cfg, }); - if (!resolveMemorySearchConfig(cfg, agentId)) return null; + if (!resolveMemorySearchConfig(cfg, agentId)) { + return null; + } return { label: "Memory Search", name: "memory_search", @@ -88,12 +92,16 @@ export function createMemoryGetTool(options: { agentSessionKey?: string; }): AnyAgentTool | null { const cfg = options.config; - if (!cfg) return null; + if (!cfg) { + return null; + } const agentId = resolveSessionAgentId({ sessionKey: options.agentSessionKey, config: cfg, }); - if (!resolveMemorySearchConfig(cfg, agentId)) return null; + if (!resolveMemorySearchConfig(cfg, agentId)) { + return null; + } return { label: "Memory Get", name: "memory_get", @@ -199,11 +207,16 @@ function deriveChatTypeFromSessionKey(sessionKey?: string): "direct" | "group" | if (!parsed?.rest) { return "direct"; } - const tokens = parsed.rest.toLowerCase().split(":").filter(Boolean); - if (tokens.includes("channel")) { + const tokens = new Set( + parsed.rest + .toLowerCase() + .split(":") + .filter(Boolean), + ); + if (tokens.has("channel")) { return "channel"; } - if (tokens.includes("group")) { + if (tokens.has("group")) { return "group"; } return "direct"; diff --git a/src/commands/status.scan.ts b/src/commands/status.scan.ts index bcfd9be1d..64570253a 100644 --- a/src/commands/status.scan.ts +++ b/src/commands/status.scan.ts @@ -28,7 +28,9 @@ type MemoryPluginStatus = { function resolveMemoryPluginStatus(cfg: ReturnType): MemoryPluginStatus { const pluginsEnabled = cfg.plugins?.enabled !== false; - if (!pluginsEnabled) return { enabled: false, slot: null, reason: "plugins disabled" }; + if (!pluginsEnabled) { + return { enabled: false, slot: null, reason: "plugins disabled" }; + } const raw = typeof cfg.plugins?.slots?.memory === "string" ? cfg.plugins.slots.memory.trim() : ""; if (raw && raw.toLowerCase() === "none") { return { enabled: false, slot: null, reason: 'plugins.slots.memory="none"' }; @@ -126,7 +128,7 @@ export async function scanStatus( progress.setLabel("Querying channel status…"); const channelsStatus = gatewayReachable - ? await callGateway>({ + ? await callGateway({ method: "channels.status", params: { probe: false, @@ -149,11 +151,17 @@ export async function scanStatus( progress.setLabel("Checking memory…"); const memoryPlugin = resolveMemoryPluginStatus(cfg); const memory = await (async (): Promise => { - if (!memoryPlugin.enabled) return null; - if (memoryPlugin.slot !== "memory-core") return null; + if (!memoryPlugin.enabled) { + return null; + } + if (memoryPlugin.slot !== "memory-core") { + return null; + } const agentId = agentStatus.defaultId ?? "main"; const { manager } = await getMemorySearchManager({ cfg, agentId }); - if (!manager) return null; + if (!manager) { + return null; + } try { await manager.probeVectorAvailability(); } catch {} diff --git a/src/config/zod-schema.ts b/src/config/zod-schema.ts index 81626cf2d..7a71cc8ac 100644 --- a/src/config/zod-schema.ts +++ b/src/config/zod-schema.ts @@ -592,15 +592,23 @@ export const OpenClawSchema = z .strict() .superRefine((cfg, ctx) => { const agents = cfg.agents?.list ?? []; - if (agents.length === 0) return; + if (agents.length === 0) { + return; + } const agentIds = new Set(agents.map((agent) => agent.id)); const broadcast = cfg.broadcast; - if (!broadcast) return; + if (!broadcast) { + return; + } for (const [peerId, ids] of Object.entries(broadcast)) { - if (peerId === "strategy") continue; - if (!Array.isArray(ids)) continue; + if (peerId === "strategy") { + continue; + } + if (!Array.isArray(ids)) { + continue; + } for (let idx = 0; idx < ids.length; idx += 1) { const agentId = ids[idx]; if (!agentIds.has(agentId)) { diff --git a/src/memory/search-manager.ts b/src/memory/search-manager.ts index 5eca68501..0efe71ee3 100644 --- a/src/memory/search-manager.ts +++ b/src/memory/search-manager.ts @@ -204,7 +204,7 @@ function sortValue(value: unknown): unknown { } if (value && typeof value === "object") { const sortedEntries = Object.keys(value as Record) - .sort((a, b) => a.localeCompare(b)) + .toSorted((a, b) => a.localeCompare(b)) .map((key) => [key, sortValue((value as Record)[key])]); return Object.fromEntries(sortedEntries); }