From bf4847c9cac42a1b77ab991b00fce07f95a4a197 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 4 Jan 2026 06:42:36 +0000 Subject: [PATCH] chore: fix lint formatting --- src/agents/clawdis-tools.sessions.test.ts | 34 +++++++----- src/agents/clawdis-tools.ts | 65 ++++++++++++----------- src/gateway/server-methods.ts | 5 +- src/gateway/server.cron.test.ts | 8 +-- 4 files changed, 61 insertions(+), 51 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 f9b2f8ee2..df6e5a5e4 100644 --- a/src/gateway/server-methods.ts +++ b/src/gateway/server-methods.ts @@ -57,7 +57,10 @@ import { type DiscordProbe, probeDiscord } from "../discord/probe.js"; import { shouldLogVerbose } from "../globals.js"; import { sendMessageIMessage } from "../imessage/index.js"; import { type IMessageProbe, probeIMessage } from "../imessage/probe.js"; -import { onAgentEvent, registerAgentRunContext } from "../infra/agent-events.js"; +import { + onAgentEvent, + registerAgentRunContext, +} from "../infra/agent-events.js"; import type { startNodeBridgeServer } from "../infra/bridge/server.js"; import { getLastHeartbeatEvent } from "../infra/heartbeat-events.js"; import { setHeartbeatsEnabled } from "../infra/heartbeat-runner.js"; 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); });