diff --git a/src/commands/message.test.ts b/src/commands/message.test.ts index 1db84e1bb..c3237d29e 100644 --- a/src/commands/message.test.ts +++ b/src/commands/message.test.ts @@ -8,7 +8,6 @@ import type { CliDeps } from "../cli/deps.js"; import type { RuntimeEnv } from "../runtime.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { captureEnv } from "../test-utils/env.js"; -const loadMessageCommand = async () => await import("./message.js"); let testConfig: Record = {}; vi.mock("../config/config.js", async (importOriginal) => { @@ -158,6 +157,8 @@ const createTelegramSendPluginRegistration = () => ({ }), }); +const { messageCommand } = await import("./message.js"); + describe("messageCommand", () => { it("defaults channel when only one configured", async () => { process.env.TELEGRAM_BOT_TOKEN = "token-abc"; @@ -169,7 +170,6 @@ describe("messageCommand", () => { ]), ); const deps = makeDeps(); - const { messageCommand } = await loadMessageCommand(); await messageCommand( { target: "123456", @@ -195,7 +195,6 @@ describe("messageCommand", () => { ]), ); const deps = makeDeps(); - const { messageCommand } = await loadMessageCommand(); await expect( messageCommand( { @@ -226,7 +225,6 @@ describe("messageCommand", () => { ]), ); const deps = makeDeps(); - const { messageCommand } = await loadMessageCommand(); await messageCommand( { action: "send", @@ -249,7 +247,6 @@ describe("messageCommand", () => { ]), ); const deps = makeDeps(); - const { messageCommand } = await loadMessageCommand(); await messageCommand( { action: "poll", diff --git a/src/gateway/server.chat.gateway-server-chat-b.test.ts b/src/gateway/server.chat.gateway-server-chat-b.test.ts index cd95b32e2..bda93dbf0 100644 --- a/src/gateway/server.chat.gateway-server-chat-b.test.ts +++ b/src/gateway/server.chat.gateway-server-chat-b.test.ts @@ -85,16 +85,16 @@ async function fetchHistoryMessages( describe("gateway server chat", () => { test("smoke: caps history payload and preserves routing metadata", async () => { await withGatewayChatHarness(async ({ ws, createSessionDir }) => { - const historyMaxBytes = 192 * 1024; + const historyMaxBytes = 64 * 1024; __setMaxChatHistoryMessagesBytesForTest(historyMaxBytes); await connectOk(ws); const sessionDir = await createSessionDir(); await writeMainSessionStore(); - const bigText = "x".repeat(4_000); + const bigText = "x".repeat(2_000); const historyLines: string[] = []; - for (let i = 0; i < 60; i += 1) { + for (let i = 0; i < 45; i += 1) { historyLines.push( JSON.stringify({ message: { @@ -109,7 +109,7 @@ describe("gateway server chat", () => { const messages = await fetchHistoryMessages(ws); const bytes = Buffer.byteLength(JSON.stringify(messages), "utf8"); expect(bytes).toBeLessThanOrEqual(historyMaxBytes); - expect(messages.length).toBeLessThan(60); + expect(messages.length).toBeLessThan(45); await writeSessionStore({ entries: { @@ -169,7 +169,7 @@ describe("gateway server chat", () => { () => { expect(spy.mock.calls.length).toBeGreaterThan(0); }, - { timeout: 2_000, interval: 10 }, + { timeout: 500, interval: 10 }, ); expect(capturedOpts?.disableBlockStreaming).toBeUndefined(); @@ -188,7 +188,7 @@ describe("gateway server chat", () => { const sessionDir = await createSessionDir(); await writeMainSessionStore(); - const hugeNestedText = "n".repeat(450_000); + const hugeNestedText = "n".repeat(120_000); const oversizedLine = JSON.stringify({ message: { role: "assistant", @@ -241,7 +241,7 @@ describe("gateway server chat", () => { ); } - const hugeNestedText = "z".repeat(450_000); + const hugeNestedText = "z".repeat(120_000); lines.push( JSON.stringify({ message: { @@ -365,7 +365,7 @@ describe("gateway server chat", () => { return undefined; }); - const sendResP = onceMessage(ws, (o) => o.type === "res" && o.id === "send-abort-1", 8_000); + const sendResP = onceMessage(ws, (o) => o.type === "res" && o.id === "send-abort-1", 2_000); sendReq(ws, "send-abort-1", "chat.send", { sessionKey: "main", message: "hello", @@ -379,7 +379,7 @@ describe("gateway server chat", () => { () => { expect(spy.mock.calls.length).toBeGreaterThan(0); }, - { timeout: 2_000, interval: 10 }, + { timeout: 500, interval: 10 }, ); const inFlight = await rpcReq<{ status?: string }>(ws, "chat.send", { @@ -400,7 +400,7 @@ describe("gateway server chat", () => { () => { expect(aborted).toBe(true); }, - { timeout: 2_000, interval: 10 }, + { timeout: 500, interval: 10 }, ); spy.mockClear(); @@ -423,7 +423,7 @@ describe("gateway server chat", () => { expect(again.ok).toBe(true); expect(again.payload?.status).toBe("ok"); }, - { timeout: 2_000, interval: 10 }, + { timeout: 500, interval: 10 }, ); }); }); diff --git a/src/security/temp-path-guard.test.ts b/src/security/temp-path-guard.test.ts index 1d2a0c1dc..1a2b4f548 100644 --- a/src/security/temp-path-guard.test.ts +++ b/src/security/temp-path-guard.test.ts @@ -136,23 +136,15 @@ function prefilterLikelyTmpdirJoinFiles(root: string): Set | null { "!**/*.d.ts", "--no-messages", ]; - const joined = spawnSync("rg", [...commonArgs, "path\\.join", root], { encoding: "utf8" }); - if (joined.error || (joined.status !== 0 && joined.status !== 1)) { + const candidateCall = spawnSync( + "rg", + [...commonArgs, "path\\s*\\.\\s*join\\s*\\(\\s*os\\s*\\.\\s*tmpdir\\s*\\(", root], + { encoding: "utf8" }, + ); + if (candidateCall.error || (candidateCall.status !== 0 && candidateCall.status !== 1)) { return null; } - const tmpdir = spawnSync("rg", [...commonArgs, "os\\.tmpdir", root], { encoding: "utf8" }); - if (tmpdir.error || (tmpdir.status !== 0 && tmpdir.status !== 1)) { - return null; - } - const joinMatches = parsePathList(joined.stdout); - const tmpdirMatches = parsePathList(tmpdir.stdout); - const intersection = new Set(); - for (const file of joinMatches) { - if (tmpdirMatches.has(file)) { - intersection.add(file); - } - } - return intersection; + return parsePathList(candidateCall.stdout); } describe("temp path guard", () => {