From 24aa3e3311224cab31f7330b64c04d4df8d34885 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 4 Jan 2026 04:16:38 +0100 Subject: [PATCH] test: stabilize gateway tests --- src/agents/clawdis-tools.sessions.test.ts | 34 +++++++----- src/agents/clawdis-tools.ts | 65 ++++++++++++----------- src/gateway/server-methods.ts | 6 +-- src/gateway/server-methods/agent-job.ts | 8 ++- src/gateway/server-methods/agent.ts | 25 +++++---- src/gateway/server-methods/chat.ts | 31 ++++++++--- src/gateway/server-methods/cron.ts | 7 ++- src/gateway/server-methods/health.ts | 4 +- src/gateway/server-methods/models.ts | 6 ++- src/gateway/server-methods/nodes.ts | 10 +++- src/gateway/server-methods/providers.ts | 23 +++++--- src/gateway/server-methods/send.ts | 2 +- src/gateway/server-methods/sessions.ts | 25 ++++++--- src/gateway/server-methods/skills.ts | 12 +++-- src/gateway/server-methods/system.ts | 3 +- src/gateway/server-methods/talk.ts | 6 ++- src/gateway/server-methods/types.ts | 8 ++- src/gateway/server-methods/voicewake.ts | 5 +- src/gateway/server-methods/wizard.ts | 6 +-- src/gateway/server.cron.test.ts | 8 +-- src/gateway/test-helpers.ts | 2 +- 21 files changed, 192 insertions(+), 104 deletions(-) diff --git a/src/agents/clawdis-tools.sessions.test.ts b/src/agents/clawdis-tools.sessions.test.ts index 4d0a4aeef..94376b95d 100644 --- a/src/agents/clawdis-tools.sessions.test.ts +++ b/src/agents/clawdis-tools.sessions.test.ts @@ -129,7 +129,7 @@ describe("sessions tools", () => { callGatewayMock.mockReset(); const calls: Array<{ method?: string; params?: unknown }> = []; let agentCallCount = 0; - let historyCallCount = 0; + let _historyCallCount = 0; let sendCallCount = 0; let lastWaitedRunId: string | undefined; const replyByRunId = new Map(); @@ -165,7 +165,7 @@ describe("sessions tools", () => { return { runId: params?.runId ?? "run-1", status: "ok" }; } if (request.method === "chat.history") { - historyCallCount += 1; + _historyCallCount += 1; const text = (lastWaitedRunId && replyByRunId.get(lastWaitedRunId)) ?? ""; return { @@ -193,9 +193,7 @@ describe("sessions tools", () => { const tool = createClawdisTools({ agentSessionKey: requesterKey, agentSurface: "discord", - }).find( - (candidate) => candidate.name === "sessions_send", - ); + }).find((candidate) => candidate.name === "sessions_send"); expect(tool).toBeDefined(); if (!tool) throw new Error("missing sessions_send tool"); @@ -236,8 +234,9 @@ describe("sessions tools", () => { (call) => typeof (call.params as { extraSystemPrompt?: string }) ?.extraSystemPrompt === "string" && - (call.params as { extraSystemPrompt?: string }) - ?.extraSystemPrompt?.includes("Agent-to-agent message context"), + ( + call.params as { extraSystemPrompt?: string } + )?.extraSystemPrompt?.includes("Agent-to-agent message context"), ), ).toBe(true); expect( @@ -245,8 +244,9 @@ describe("sessions tools", () => { (call) => typeof (call.params as { extraSystemPrompt?: string }) ?.extraSystemPrompt === "string" && - (call.params as { extraSystemPrompt?: string }) - ?.extraSystemPrompt?.includes("Agent-to-agent reply step"), + ( + call.params as { extraSystemPrompt?: string } + )?.extraSystemPrompt?.includes("Agent-to-agent reply step"), ), ).toBe(true); expect( @@ -254,8 +254,9 @@ describe("sessions tools", () => { (call) => typeof (call.params as { extraSystemPrompt?: string }) ?.extraSystemPrompt === "string" && - (call.params as { extraSystemPrompt?: string }) - ?.extraSystemPrompt?.includes("Agent-to-agent announce step"), + ( + call.params as { extraSystemPrompt?: string } + )?.extraSystemPrompt?.includes("Agent-to-agent announce step"), ), ).toBe(true); expect(waitCalls).toHaveLength(8); @@ -285,7 +286,11 @@ describe("sessions tools", () => { agentCallCount += 1; const runId = `run-${agentCallCount}`; const params = request.params as - | { message?: string; sessionKey?: string; extraSystemPrompt?: string } + | { + message?: string; + sessionKey?: string; + extraSystemPrompt?: string; + } | undefined; let reply = "initial"; if (params?.extraSystemPrompt?.includes("Agent-to-agent reply step")) { @@ -359,8 +364,9 @@ describe("sessions tools", () => { call.method === "agent" && typeof (call.params as { extraSystemPrompt?: string }) ?.extraSystemPrompt === "string" && - (call.params as { extraSystemPrompt?: string }) - ?.extraSystemPrompt?.includes("Agent-to-agent reply step"), + ( + call.params as { extraSystemPrompt?: string } + )?.extraSystemPrompt?.includes("Agent-to-agent reply step"), ); expect(replySteps).toHaveLength(2); expect(sendParams).toMatchObject({ diff --git a/src/agents/clawdis-tools.ts b/src/agents/clawdis-tools.ts index 062272a25..7dd46e644 100644 --- a/src/agents/clawdis-tools.ts +++ b/src/agents/clawdis-tools.ts @@ -2784,7 +2784,9 @@ function buildAgentToAgentReplyContext(params: { ? `Agent 1 (requester) surface: ${params.requesterSurface}.` : undefined, `Agent 2 (target) session: ${params.targetSessionKey}.`, - params.targetChannel ? `Agent 2 (target) surface: ${params.targetChannel}.` : undefined, + params.targetChannel + ? `Agent 2 (target) surface: ${params.targetChannel}.` + : undefined, `If you want to stop the ping-pong, reply exactly "${REPLY_SKIP_TOKEN}".`, ].filter(Boolean); return lines.join("\n"); @@ -2808,7 +2810,9 @@ function buildAgentToAgentAnnounceContext(params: { ? `Agent 1 (requester) surface: ${params.requesterSurface}.` : undefined, `Agent 2 (target) session: ${params.targetSessionKey}.`, - params.targetChannel ? `Agent 2 (target) surface: ${params.targetChannel}.` : undefined, + params.targetChannel + ? `Agent 2 (target) surface: ${params.targetChannel}.` + : undefined, `Original request: ${params.originalMessage}`, params.roundOneReply ? `Round 1 reply: ${params.roundOneReply}` @@ -2892,34 +2896,35 @@ function createSessionsSendTool(opts?: { const requesterSurface = opts?.agentSurface; const maxPingPongTurns = resolvePingPongTurns(cfg); - const resolveAnnounceTarget = async (): Promise => { - const parsed = resolveAnnounceTargetFromKey(resolvedKey); - if (parsed) return parsed; - try { - const list = (await callGateway({ - method: "sessions.list", - params: { - includeGlobal: true, - includeUnknown: true, - limit: 200, - }, - })) as { sessions?: Array> }; - const sessions = Array.isArray(list?.sessions) ? list.sessions : []; - const match = - sessions.find((entry) => entry?.key === resolvedKey) ?? - sessions.find((entry) => entry?.key === displayKey); - const channel = - typeof match?.lastChannel === "string" - ? match.lastChannel - : undefined; - const to = - typeof match?.lastTo === "string" ? match.lastTo : undefined; - if (channel && to) return { channel, to }; - } catch { - // ignore; fall through to null - } - return null; - }; + const resolveAnnounceTarget = + async (): Promise => { + const parsed = resolveAnnounceTargetFromKey(resolvedKey); + if (parsed) return parsed; + try { + const list = (await callGateway({ + method: "sessions.list", + params: { + includeGlobal: true, + includeUnknown: true, + limit: 200, + }, + })) as { sessions?: Array> }; + const sessions = Array.isArray(list?.sessions) ? list.sessions : []; + const match = + sessions.find((entry) => entry?.key === resolvedKey) ?? + sessions.find((entry) => entry?.key === displayKey); + const channel = + typeof match?.lastChannel === "string" + ? match.lastChannel + : undefined; + const to = + typeof match?.lastTo === "string" ? match.lastTo : undefined; + if (channel && to) return { channel, to }; + } catch { + // ignore; fall through to null + } + return null; + }; const readLatestAssistantReply = async ( sessionKeyToRead: string, diff --git a/src/gateway/server-methods.ts b/src/gateway/server-methods.ts index 600a94d52..16b9fe364 100644 --- a/src/gateway/server-methods.ts +++ b/src/gateway/server-methods.ts @@ -13,13 +13,13 @@ import { sessionsHandlers } from "./server-methods/sessions.js"; import { skillsHandlers } from "./server-methods/skills.js"; import { systemHandlers } from "./server-methods/system.js"; import { talkHandlers } from "./server-methods/talk.js"; -import { voicewakeHandlers } from "./server-methods/voicewake.js"; -import { webHandlers } from "./server-methods/web.js"; -import { wizardHandlers } from "./server-methods/wizard.js"; import type { GatewayRequestHandlers, GatewayRequestOptions, } from "./server-methods/types.js"; +import { voicewakeHandlers } from "./server-methods/voicewake.js"; +import { webHandlers } from "./server-methods/web.js"; +import { wizardHandlers } from "./server-methods/wizard.js"; const handlers: GatewayRequestHandlers = { ...connectHandlers, diff --git a/src/gateway/server-methods/agent-job.ts b/src/gateway/server-methods/agent-job.ts index 13ea4f060..164f47bc1 100644 --- a/src/gateway/server-methods/agent-job.ts +++ b/src/gateway/server-methods/agent-job.ts @@ -54,7 +54,9 @@ function ensureAgentJobListener() { ? (evt.data.endedAt as number) : undefined; const error = - typeof evt.data?.error === "string" ? (evt.data.error as string) : undefined; + typeof evt.data?.error === "string" + ? (evt.data.error as string) + : undefined; agentRunStarts.delete(evt.runId); recordAgentJobSnapshot({ runId: evt.runId, @@ -115,7 +117,9 @@ export async function waitForAgentJob(params: { ? (evt.data.endedAt as number) : undefined; const error = - typeof evt.data?.error === "string" ? (evt.data.error as string) : undefined; + typeof evt.data?.error === "string" + ? (evt.data.error as string) + : undefined; const snapshot: AgentJobSnapshot = { runId: evt.runId, state: state === "error" ? "error" : "done", diff --git a/src/gateway/server-methods/agent.ts b/src/gateway/server-methods/agent.ts index 343cedcd2..16a348617 100644 --- a/src/gateway/server-methods/agent.ts +++ b/src/gateway/server-methods/agent.ts @@ -1,22 +1,22 @@ import { randomUUID } from "node:crypto"; import { agentCommand } from "../../commands/agent.js"; +import { loadConfig } from "../../config/config.js"; +import { type SessionEntry, saveSessionStore } from "../../config/sessions.js"; import { registerAgentRunContext } from "../../infra/agent-events.js"; import { defaultRuntime } from "../../runtime.js"; -import { normalizeE164 } from "../../utils.js"; -import { loadConfig } from "../../config/config.js"; -import { saveSessionStore, type SessionEntry } from "../../config/sessions.js"; import { resolveSendPolicy } from "../../sessions/send-policy.js"; +import { normalizeE164 } from "../../utils.js"; import { + type AgentWaitParams, ErrorCodes, errorShape, formatValidationErrors, validateAgentParams, validateAgentWaitParams, - type AgentWaitParams, } from "../protocol/index.js"; -import { formatForLog } from "../ws-log.js"; import { loadSessionEntry } from "../session-utils.js"; +import { formatForLog } from "../ws-log.js"; import { waitForAgentJob } from "./agent-job.js"; import type { GatewayRequestHandlers } from "./types.js"; @@ -67,7 +67,8 @@ export const agentHandlers: GatewayRequestHandlers = { let cfgForAgent: ReturnType | undefined; if (requestedSessionKey) { - const { cfg, storePath, store, entry } = loadSessionEntry(requestedSessionKey); + const { cfg, storePath, store, entry } = + loadSessionEntry(requestedSessionKey); cfgForAgent = cfg; const now = Date.now(); const sessionId = entry?.sessionId ?? randomUUID(); @@ -132,13 +133,17 @@ export const agentHandlers: GatewayRequestHandlers = { const lastChannel = sessionEntry?.lastChannel; const lastTo = - typeof sessionEntry?.lastTo === "string" ? sessionEntry.lastTo.trim() : ""; + typeof sessionEntry?.lastTo === "string" + ? sessionEntry.lastTo.trim() + : ""; const resolvedChannel = (() => { if (requestedChannel === "last") { // WebChat is not a deliverable surface. Treat it as "unset" for routing, // so VoiceWake and CLI callers don't get stuck with deliver=false. - return lastChannel && lastChannel !== "webchat" ? lastChannel : "whatsapp"; + return lastChannel && lastChannel !== "webchat" + ? lastChannel + : "whatsapp"; } if ( requestedChannel === "whatsapp" || @@ -150,7 +155,9 @@ export const agentHandlers: GatewayRequestHandlers = { ) { return requestedChannel; } - return lastChannel && lastChannel !== "webchat" ? lastChannel : "whatsapp"; + return lastChannel && lastChannel !== "webchat" + ? lastChannel + : "whatsapp"; })(); const resolvedTo = (() => { diff --git a/src/gateway/server-methods/chat.ts b/src/gateway/server-methods/chat.ts index e6039a4d8..ae8af53c3 100644 --- a/src/gateway/server-methods/chat.ts +++ b/src/gateway/server-methods/chat.ts @@ -2,9 +2,10 @@ import { randomUUID } from "node:crypto"; import { resolveThinkingDefault } from "../../agents/model-selection.js"; import { agentCommand } from "../../commands/agent.js"; -import { saveSessionStore, type SessionEntry } from "../../config/sessions.js"; +import { type SessionEntry, saveSessionStore } from "../../config/sessions.js"; import { defaultRuntime } from "../../runtime.js"; import { resolveSendPolicy } from "../../sessions/send-policy.js"; +import { buildMessageWithAttachments } from "../chat-attachments.js"; import { ErrorCodes, errorShape, @@ -21,7 +22,6 @@ import { resolveSessionModelRef, } from "../session-utils.js"; import { formatForLog } from "../ws-log.js"; -import { buildMessageWithAttachments } from "../chat-attachments.js"; import type { GatewayRequestHandlers } from "./types.js"; export const chatHandlers: GatewayRequestHandlers = { @@ -49,7 +49,8 @@ export const chatHandlers: GatewayRequestHandlers = { const defaultLimit = 200; const requested = typeof limit === "number" ? limit : defaultLimit; const max = Math.min(hardMax, requested); - const sliced = rawMessages.length > max ? rawMessages.slice(-max) : rawMessages; + const sliced = + rawMessages.length > max ? rawMessages.slice(-max) : rawMessages; const capped = capArrayByJsonBytes( sliced, MAX_CHAT_HISTORY_MESSAGES_BYTES, @@ -102,7 +103,10 @@ export const chatHandlers: GatewayRequestHandlers = { respond( false, undefined, - errorShape(ErrorCodes.INVALID_REQUEST, "runId does not match sessionKey"), + errorShape( + ErrorCodes.INVALID_REQUEST, + "runId does not match sessionKey", + ), ); return; } @@ -123,8 +127,18 @@ export const chatHandlers: GatewayRequestHandlers = { context.bridgeSendToSession(sessionKey, "chat", payload); respond(true, { ok: true, aborted: true }); }, - "chat.send": async ({ params, respond, context, client, isWebchatConnect }) => { - if (client && isWebchatConnect(client.connect) && !context.hasConnectedMobileNode()) { + "chat.send": async ({ + params, + respond, + context, + client, + isWebchatConnect, + }) => { + if ( + client && + isWebchatConnect(client.connect) && + !context.hasConnectedMobileNode() + ) { respond( false, undefined, @@ -220,7 +234,10 @@ export const chatHandlers: GatewayRequestHandlers = { respond( false, undefined, - errorShape(ErrorCodes.INVALID_REQUEST, "send blocked by session policy"), + errorShape( + ErrorCodes.INVALID_REQUEST, + "send blocked by session policy", + ), ); return; } diff --git a/src/gateway/server-methods/cron.ts b/src/gateway/server-methods/cron.ts index 0126deab2..d173fe26f 100644 --- a/src/gateway/server-methods/cron.ts +++ b/src/gateway/server-methods/cron.ts @@ -1,8 +1,8 @@ -import type { CronJobCreate, CronJobPatch } from "../../cron/types.js"; import { readCronRunLogEntries, resolveCronRunLogPath, } from "../../cron/run-log.js"; +import type { CronJobCreate, CronJobPatch } from "../../cron/types.js"; import { ErrorCodes, errorShape, @@ -102,7 +102,10 @@ export const cronHandlers: GatewayRequestHandlers = { id: string; patch: Record; }; - const job = await context.cron.update(p.id, p.patch as unknown as CronJobPatch); + const job = await context.cron.update( + p.id, + p.patch as unknown as CronJobPatch, + ); respond(true, job, undefined); }, "cron.remove": async ({ params, respond, context }) => { diff --git a/src/gateway/server-methods/health.ts b/src/gateway/server-methods/health.ts index be94ec0df..dd128db39 100644 --- a/src/gateway/server-methods/health.ts +++ b/src/gateway/server-methods/health.ts @@ -13,7 +13,9 @@ export const healthHandlers: GatewayRequestHandlers = { if (cached && now - cached.ts < HEALTH_REFRESH_INTERVAL_MS) { respond(true, cached, undefined, { cached: true }); void refreshHealthSnapshot({ probe: false }).catch((err) => - logHealth.error(`background health refresh failed: ${formatError(err)}`), + logHealth.error( + `background health refresh failed: ${formatError(err)}`, + ), ); return; } diff --git a/src/gateway/server-methods/models.ts b/src/gateway/server-methods/models.ts index ec2f5a0aa..ab5db6434 100644 --- a/src/gateway/server-methods/models.ts +++ b/src/gateway/server-methods/models.ts @@ -23,7 +23,11 @@ export const modelsHandlers: GatewayRequestHandlers = { const models = await context.loadGatewayModelCatalog(); respond(true, { models }, undefined); } catch (err) { - respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, String(err))); + respond( + false, + undefined, + errorShape(ErrorCodes.UNAVAILABLE, String(err)), + ); } }, }; diff --git a/src/gateway/server-methods/nodes.ts b/src/gateway/server-methods/nodes.ts index 0a56190d7..17206b470 100644 --- a/src/gateway/server-methods/nodes.ts +++ b/src/gateway/server-methods/nodes.ts @@ -244,7 +244,11 @@ export const nodeHandlers: GatewayRequestHandlers = { ); return; } - respond(true, { nodeId: updated.nodeId, displayName: updated.displayName }, undefined); + respond( + true, + { nodeId: updated.nodeId, displayName: updated.displayName }, + undefined, + ); } catch (err) { respond( false, @@ -449,7 +453,9 @@ export const nodeHandlers: GatewayRequestHandlers = { try { const paramsJSON = - "params" in p && p.params !== undefined ? JSON.stringify(p.params) : null; + "params" in p && p.params !== undefined + ? JSON.stringify(p.params) + : null; const res = await context.bridge.invoke({ nodeId, command, diff --git a/src/gateway/server-methods/providers.ts b/src/gateway/server-methods/providers.ts index 698ff9d42..fbc272d41 100644 --- a/src/gateway/server-methods/providers.ts +++ b/src/gateway/server-methods/providers.ts @@ -1,12 +1,16 @@ +import type { ClawdisConfig } from "../../config/config.js"; +import { + loadConfig, + readConfigFileSnapshot, + writeConfigFile, +} from "../../config/config.js"; import { type DiscordProbe, probeDiscord } from "../../discord/probe.js"; import { type IMessageProbe, probeIMessage } from "../../imessage/probe.js"; -import type { ClawdisConfig } from "../../config/config.js"; -import { loadConfig, readConfigFileSnapshot, writeConfigFile } from "../../config/config.js"; import { webAuthExists } from "../../providers/web/index.js"; -import { getWebAuthAgeMs, readWebSelfId } from "../../web/session.js"; import { probeSignal, type SignalProbe } from "../../signal/probe.js"; import { probeTelegram, type TelegramProbe } from "../../telegram/probe.js"; import { resolveTelegramToken } from "../../telegram/token.js"; +import { getWebAuthAgeMs, readWebSelfId } from "../../web/session.js"; import { ErrorCodes, errorShape, @@ -35,7 +39,8 @@ export const providersHandlers: GatewayRequestHandlers = { typeof timeoutMsRaw === "number" ? Math.max(1000, timeoutMsRaw) : 10_000; const cfg = loadConfig(); const telegramCfg = cfg.telegram; - const telegramEnabled = Boolean(telegramCfg) && telegramCfg?.enabled !== false; + const telegramEnabled = + Boolean(telegramCfg) && telegramCfg?.enabled !== false; const { token: telegramToken, source: tokenSource } = telegramEnabled ? resolveTelegramToken(cfg) : { token: "", source: "none" as const }; @@ -55,9 +60,7 @@ export const providersHandlers: GatewayRequestHandlers = { const discordEnvToken = discordEnabled ? process.env.DISCORD_BOT_TOKEN?.trim() : ""; - const discordConfigToken = discordEnabled - ? discordCfg?.token?.trim() - : ""; + const discordConfigToken = discordEnabled ? discordCfg?.token?.trim() : ""; const discordToken = discordEnvToken || discordConfigToken || ""; const discordTokenSource = discordEnvToken ? "env" @@ -203,7 +206,11 @@ export const providersHandlers: GatewayRequestHandlers = { delete nextCfg.telegram; } await writeConfigFile(nextCfg); - respond(true, { cleared: hadToken, envToken: Boolean(envToken) }, undefined); + respond( + true, + { cleared: hadToken, envToken: Boolean(envToken) }, + undefined, + ); } catch (err) { respond( false, diff --git a/src/gateway/server-methods/send.ts b/src/gateway/server-methods/send.ts index 278fc91fc..f8557537f 100644 --- a/src/gateway/server-methods/send.ts +++ b/src/gateway/server-methods/send.ts @@ -1,7 +1,7 @@ +import { loadConfig } from "../../config/config.js"; import { sendMessageDiscord } from "../../discord/index.js"; import { shouldLogVerbose } from "../../globals.js"; import { sendMessageIMessage } from "../../imessage/index.js"; -import { loadConfig } from "../../config/config.js"; import { sendMessageSignal } from "../../signal/index.js"; import { sendMessageTelegram } from "../../telegram/send.js"; import { resolveTelegramToken } from "../../telegram/token.js"; diff --git a/src/gateway/server-methods/sessions.ts b/src/gateway/server-methods/sessions.ts index 5c82dfd4f..a0ec54352 100644 --- a/src/gateway/server-methods/sessions.ts +++ b/src/gateway/server-methods/sessions.ts @@ -423,22 +423,35 @@ export const sessionsHandlers: GatewayRequestHandlers = { const { storePath, store, entry } = loadSessionEntry(key); const sessionId = entry?.sessionId; if (!sessionId) { - respond(true, { ok: true, key, compacted: false, reason: "no sessionId" }, undefined); + respond( + true, + { ok: true, key, compacted: false, reason: "no sessionId" }, + undefined, + ); return; } - const filePath = resolveSessionTranscriptCandidates(sessionId, storePath).find( - (candidate) => fs.existsSync(candidate), - ); + const filePath = resolveSessionTranscriptCandidates( + sessionId, + storePath, + ).find((candidate) => fs.existsSync(candidate)); if (!filePath) { - respond(true, { ok: true, key, compacted: false, reason: "no transcript" }, undefined); + respond( + true, + { ok: true, key, compacted: false, reason: "no transcript" }, + undefined, + ); return; } const raw = fs.readFileSync(filePath, "utf-8"); const lines = raw.split(/\r?\n/).filter((l) => l.trim().length > 0); if (lines.length <= maxLines) { - respond(true, { ok: true, key, compacted: false, kept: lines.length }, undefined); + respond( + true, + { ok: true, key, compacted: false, kept: lines.length }, + undefined, + ); return; } diff --git a/src/gateway/server-methods/skills.ts b/src/gateway/server-methods/skills.ts index 77705d649..fc86548b8 100644 --- a/src/gateway/server-methods/skills.ts +++ b/src/gateway/server-methods/skills.ts @@ -1,6 +1,6 @@ -import { DEFAULT_AGENT_WORKSPACE_DIR } from "../../agents/workspace.js"; import { installSkill } from "../../agents/skills-install.js"; import { buildWorkspaceSkillStatus } from "../../agents/skills-status.js"; +import { DEFAULT_AGENT_WORKSPACE_DIR } from "../../agents/workspace.js"; import type { ClawdisConfig } from "../../config/config.js"; import { loadConfig, writeConfigFile } from "../../config/config.js"; import { resolveUserPath } from "../../utils.js"; @@ -64,7 +64,9 @@ export const skillsHandlers: GatewayRequestHandlers = { respond( result.ok, result, - result.ok ? undefined : errorShape(ErrorCodes.UNAVAILABLE, result.message), + result.ok + ? undefined + : errorShape(ErrorCodes.UNAVAILABLE, result.message), ); }, "skills.update": async ({ params, respond }) => { @@ -115,6 +117,10 @@ export const skillsHandlers: GatewayRequestHandlers = { skills, }; await writeConfigFile(nextConfig); - respond(true, { ok: true, skillKey: p.skillKey, config: current }, undefined); + respond( + true, + { ok: true, skillKey: p.skillKey, config: current }, + undefined, + ); }, }; diff --git a/src/gateway/server-methods/system.ts b/src/gateway/server-methods/system.ts index fdfc84434..db9e42774 100644 --- a/src/gateway/server-methods/system.ts +++ b/src/gateway/server-methods/system.ts @@ -65,7 +65,8 @@ export const systemHandlers: GatewayRequestHandlers = { Number.isFinite(params.lastInputSeconds) ? params.lastInputSeconds : undefined; - const reason = typeof params.reason === "string" ? params.reason : undefined; + const reason = + typeof params.reason === "string" ? params.reason : undefined; const tags = Array.isArray(params.tags) && params.tags.every((t) => typeof t === "string") diff --git a/src/gateway/server-methods/talk.ts b/src/gateway/server-methods/talk.ts index 47d7b1092..990c7fd30 100644 --- a/src/gateway/server-methods/talk.ts +++ b/src/gateway/server-methods/talk.ts @@ -8,7 +8,11 @@ import type { GatewayRequestHandlers } from "./types.js"; export const talkHandlers: GatewayRequestHandlers = { "talk.mode": ({ params, respond, context, client, isWebchatConnect }) => { - if (client && isWebchatConnect(client.connect) && !context.hasConnectedMobileNode()) { + if ( + client && + isWebchatConnect(client.connect) && + !context.hasConnectedMobileNode() + ) { respond( false, undefined, diff --git a/src/gateway/server-methods/types.ts b/src/gateway/server-methods/types.ts index 7fdc9defc..7bd607963 100644 --- a/src/gateway/server-methods/types.ts +++ b/src/gateway/server-methods/types.ts @@ -4,9 +4,13 @@ import type { HealthSummary } from "../../commands/health.js"; import type { CronService } from "../../cron/service.js"; import type { startNodeBridgeServer } from "../../infra/bridge/server.js"; import type { WizardSession } from "../../wizard/session.js"; -import type { ConnectParams, ErrorShape, RequestFrame } from "../protocol/index.js"; -import type { DedupeEntry } from "../server-shared.js"; +import type { + ConnectParams, + ErrorShape, + RequestFrame, +} from "../protocol/index.js"; import type { ProviderRuntimeSnapshot } from "../server-providers.js"; +import type { DedupeEntry } from "../server-shared.js"; export type GatewayClient = { connect: ConnectParams; diff --git a/src/gateway/server-methods/voicewake.ts b/src/gateway/server-methods/voicewake.ts index e69fd46d6..cfd9fe3a5 100644 --- a/src/gateway/server-methods/voicewake.ts +++ b/src/gateway/server-methods/voicewake.ts @@ -1,4 +1,7 @@ -import { loadVoiceWakeConfig, setVoiceWakeTriggers } from "../../infra/voicewake.js"; +import { + loadVoiceWakeConfig, + setVoiceWakeTriggers, +} from "../../infra/voicewake.js"; import { ErrorCodes, errorShape } from "../protocol/index.js"; import { normalizeVoiceWakeTriggers } from "../server-utils.js"; import { formatForLog } from "../ws-log.js"; diff --git a/src/gateway/server-methods/wizard.ts b/src/gateway/server-methods/wizard.ts index 43477c503..ece66823f 100644 --- a/src/gateway/server-methods/wizard.ts +++ b/src/gateway/server-methods/wizard.ts @@ -1,7 +1,6 @@ import { randomUUID } from "node:crypto"; - -import { WizardSession } from "../../wizard/session.js"; import { defaultRuntime } from "../../runtime.js"; +import { WizardSession } from "../../wizard/session.js"; import { ErrorCodes, errorShape, @@ -39,7 +38,8 @@ export const wizardHandlers: GatewayRequestHandlers = { const sessionId = randomUUID(); const opts = { mode: params.mode as "local" | "remote" | undefined, - workspace: typeof params.workspace === "string" ? params.workspace : undefined, + workspace: + typeof params.workspace === "string" ? params.workspace : undefined, }; const session = new WizardSession((prompter) => context.wizardRunner(opts, defaultRuntime, prompter), diff --git a/src/gateway/server.cron.test.ts b/src/gateway/server.cron.test.ts index aa6bf6839..b2af8bbc8 100644 --- a/src/gateway/server.cron.test.ts +++ b/src/gateway/server.cron.test.ts @@ -214,9 +214,7 @@ describe("gateway server cron", () => { testState.cronStorePath = undefined; }); - test( - "enables cron scheduler by default and runs due jobs automatically", - async () => { + test("enables cron scheduler by default and runs due jobs automatically", async () => { const dir = await fs.mkdtemp( path.join(os.tmpdir(), "clawdis-gw-cron-default-on-"), ); @@ -307,7 +305,5 @@ describe("gateway server cron", () => { testState.cronStorePath = undefined; await fs.rm(dir, { recursive: true, force: true }); } - }, - 15_000, - ); + }, 15_000); }); diff --git a/src/gateway/test-helpers.ts b/src/gateway/test-helpers.ts index 404013e38..e08430580 100644 --- a/src/gateway/test-helpers.ts +++ b/src/gateway/test-helpers.ts @@ -366,7 +366,7 @@ export function installGatewayTestHooks() { piSdkMock.enabled = false; piSdkMock.discoverCalls = 0; piSdkMock.models = []; - }, 20_000); + }, 60_000); afterEach(async () => { process.env.HOME = previousHome;