chore: fix lint formatting

This commit is contained in:
Peter Steinberger 2026-01-04 06:42:36 +00:00
parent ad1932dca3
commit bf4847c9ca
4 changed files with 61 additions and 51 deletions

View File

@ -129,7 +129,7 @@ describe("sessions tools", () => {
callGatewayMock.mockReset(); callGatewayMock.mockReset();
const calls: Array<{ method?: string; params?: unknown }> = []; const calls: Array<{ method?: string; params?: unknown }> = [];
let agentCallCount = 0; let agentCallCount = 0;
let historyCallCount = 0; let _historyCallCount = 0;
let sendCallCount = 0; let sendCallCount = 0;
let lastWaitedRunId: string | undefined; let lastWaitedRunId: string | undefined;
const replyByRunId = new Map<string, string>(); const replyByRunId = new Map<string, string>();
@ -165,7 +165,7 @@ describe("sessions tools", () => {
return { runId: params?.runId ?? "run-1", status: "ok" }; return { runId: params?.runId ?? "run-1", status: "ok" };
} }
if (request.method === "chat.history") { if (request.method === "chat.history") {
historyCallCount += 1; _historyCallCount += 1;
const text = const text =
(lastWaitedRunId && replyByRunId.get(lastWaitedRunId)) ?? ""; (lastWaitedRunId && replyByRunId.get(lastWaitedRunId)) ?? "";
return { return {
@ -193,9 +193,7 @@ describe("sessions tools", () => {
const tool = createClawdisTools({ const tool = createClawdisTools({
agentSessionKey: requesterKey, agentSessionKey: requesterKey,
agentSurface: "discord", agentSurface: "discord",
}).find( }).find((candidate) => candidate.name === "sessions_send");
(candidate) => candidate.name === "sessions_send",
);
expect(tool).toBeDefined(); expect(tool).toBeDefined();
if (!tool) throw new Error("missing sessions_send tool"); if (!tool) throw new Error("missing sessions_send tool");
@ -236,8 +234,9 @@ describe("sessions tools", () => {
(call) => (call) =>
typeof (call.params as { extraSystemPrompt?: string }) typeof (call.params as { extraSystemPrompt?: string })
?.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); ).toBe(true);
expect( expect(
@ -245,8 +244,9 @@ describe("sessions tools", () => {
(call) => (call) =>
typeof (call.params as { extraSystemPrompt?: string }) typeof (call.params as { extraSystemPrompt?: string })
?.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); ).toBe(true);
expect( expect(
@ -254,8 +254,9 @@ describe("sessions tools", () => {
(call) => (call) =>
typeof (call.params as { extraSystemPrompt?: string }) typeof (call.params as { extraSystemPrompt?: string })
?.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); ).toBe(true);
expect(waitCalls).toHaveLength(8); expect(waitCalls).toHaveLength(8);
@ -285,7 +286,11 @@ describe("sessions tools", () => {
agentCallCount += 1; agentCallCount += 1;
const runId = `run-${agentCallCount}`; const runId = `run-${agentCallCount}`;
const params = request.params as const params = request.params as
| { message?: string; sessionKey?: string; extraSystemPrompt?: string } | {
message?: string;
sessionKey?: string;
extraSystemPrompt?: string;
}
| undefined; | undefined;
let reply = "initial"; let reply = "initial";
if (params?.extraSystemPrompt?.includes("Agent-to-agent reply step")) { if (params?.extraSystemPrompt?.includes("Agent-to-agent reply step")) {
@ -359,8 +364,9 @@ describe("sessions tools", () => {
call.method === "agent" && call.method === "agent" &&
typeof (call.params as { extraSystemPrompt?: string }) typeof (call.params as { extraSystemPrompt?: string })
?.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(replySteps).toHaveLength(2);
expect(sendParams).toMatchObject({ expect(sendParams).toMatchObject({

View File

@ -2784,7 +2784,9 @@ function buildAgentToAgentReplyContext(params: {
? `Agent 1 (requester) surface: ${params.requesterSurface}.` ? `Agent 1 (requester) surface: ${params.requesterSurface}.`
: undefined, : undefined,
`Agent 2 (target) session: ${params.targetSessionKey}.`, `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}".`, `If you want to stop the ping-pong, reply exactly "${REPLY_SKIP_TOKEN}".`,
].filter(Boolean); ].filter(Boolean);
return lines.join("\n"); return lines.join("\n");
@ -2808,7 +2810,9 @@ function buildAgentToAgentAnnounceContext(params: {
? `Agent 1 (requester) surface: ${params.requesterSurface}.` ? `Agent 1 (requester) surface: ${params.requesterSurface}.`
: undefined, : undefined,
`Agent 2 (target) session: ${params.targetSessionKey}.`, `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}`, `Original request: ${params.originalMessage}`,
params.roundOneReply params.roundOneReply
? `Round 1 reply: ${params.roundOneReply}` ? `Round 1 reply: ${params.roundOneReply}`
@ -2892,34 +2896,35 @@ function createSessionsSendTool(opts?: {
const requesterSurface = opts?.agentSurface; const requesterSurface = opts?.agentSurface;
const maxPingPongTurns = resolvePingPongTurns(cfg); const maxPingPongTurns = resolvePingPongTurns(cfg);
const resolveAnnounceTarget = async (): Promise<AnnounceTarget | null> => { const resolveAnnounceTarget =
const parsed = resolveAnnounceTargetFromKey(resolvedKey); async (): Promise<AnnounceTarget | null> => {
if (parsed) return parsed; const parsed = resolveAnnounceTargetFromKey(resolvedKey);
try { if (parsed) return parsed;
const list = (await callGateway({ try {
method: "sessions.list", const list = (await callGateway({
params: { method: "sessions.list",
includeGlobal: true, params: {
includeUnknown: true, includeGlobal: true,
limit: 200, includeUnknown: true,
}, limit: 200,
})) as { sessions?: Array<Record<string, unknown>> }; },
const sessions = Array.isArray(list?.sessions) ? list.sessions : []; })) as { sessions?: Array<Record<string, unknown>> };
const match = const sessions = Array.isArray(list?.sessions) ? list.sessions : [];
sessions.find((entry) => entry?.key === resolvedKey) ?? const match =
sessions.find((entry) => entry?.key === displayKey); sessions.find((entry) => entry?.key === resolvedKey) ??
const channel = sessions.find((entry) => entry?.key === displayKey);
typeof match?.lastChannel === "string" const channel =
? match.lastChannel typeof match?.lastChannel === "string"
: undefined; ? match.lastChannel
const to = : undefined;
typeof match?.lastTo === "string" ? match.lastTo : undefined; const to =
if (channel && to) return { channel, to }; typeof match?.lastTo === "string" ? match.lastTo : undefined;
} catch { if (channel && to) return { channel, to };
// ignore; fall through to null } catch {
} // ignore; fall through to null
return null; }
}; return null;
};
const readLatestAssistantReply = async ( const readLatestAssistantReply = async (
sessionKeyToRead: string, sessionKeyToRead: string,

View File

@ -57,7 +57,10 @@ import { type DiscordProbe, probeDiscord } from "../discord/probe.js";
import { shouldLogVerbose } from "../globals.js"; import { shouldLogVerbose } from "../globals.js";
import { sendMessageIMessage } from "../imessage/index.js"; import { sendMessageIMessage } from "../imessage/index.js";
import { type IMessageProbe, probeIMessage } from "../imessage/probe.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 type { startNodeBridgeServer } from "../infra/bridge/server.js";
import { getLastHeartbeatEvent } from "../infra/heartbeat-events.js"; import { getLastHeartbeatEvent } from "../infra/heartbeat-events.js";
import { setHeartbeatsEnabled } from "../infra/heartbeat-runner.js"; import { setHeartbeatsEnabled } from "../infra/heartbeat-runner.js";

View File

@ -214,9 +214,7 @@ describe("gateway server cron", () => {
testState.cronStorePath = undefined; testState.cronStorePath = undefined;
}); });
test( test("enables cron scheduler by default and runs due jobs automatically", async () => {
"enables cron scheduler by default and runs due jobs automatically",
async () => {
const dir = await fs.mkdtemp( const dir = await fs.mkdtemp(
path.join(os.tmpdir(), "clawdis-gw-cron-default-on-"), path.join(os.tmpdir(), "clawdis-gw-cron-default-on-"),
); );
@ -307,7 +305,5 @@ describe("gateway server cron", () => {
testState.cronStorePath = undefined; testState.cronStorePath = undefined;
await fs.rm(dir, { recursive: true, force: true }); await fs.rm(dir, { recursive: true, force: true });
} }
}, }, 15_000);
15_000,
);
}); });