From c194247dab7fa2d9996a1374c7e46209be5956de Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 26 Nov 2025 03:03:13 +0100 Subject: [PATCH] test(auto-reply): cover cwd timeout hint and queue meta --- src/auto-reply/command-reply.test.ts | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/auto-reply/command-reply.test.ts b/src/auto-reply/command-reply.test.ts index f318be229..d7887826d 100644 --- a/src/auto-reply/command-reply.test.ts +++ b/src/auto-reply/command-reply.test.ts @@ -139,6 +139,25 @@ describe("runCommandReply", () => { expect(meta.killed).toBe(true); }); + it("includes cwd hint in timeout message", async () => { + const runner = vi.fn(async () => { + throw { stdout: "", killed: true, signal: "SIGKILL" }; + }); + const { payload } = await runCommandReply({ + reply: { mode: "command", command: ["echo", "hi"], cwd: "/tmp/work" }, + templatingCtx: noopTemplateCtx, + sendSystemOnce: false, + isNewSession: true, + isFirstTurnInSession: true, + systemSent: false, + timeoutMs: 5, + timeoutSeconds: 1, + commandRunner: runner, + enqueue: enqueueImmediate, + }); + expect(payload?.text).toContain("(cwd: /tmp/work)"); + }); + it("parses MEDIA tokens and respects mediaMaxMb for local files", async () => { const tmp = path.join(os.tmpdir(), `warelay-test-${Date.now()}.bin`); const bigBuffer = Buffer.alloc(2 * 1024 * 1024, 1); @@ -186,4 +205,22 @@ describe("runCommandReply", () => { expect(meta.claudeMeta).toContain("duration=50ms"); expect(meta.claudeMeta).toContain("tool_calls=1"); }); + + it("captures queue wait metrics in meta", async () => { + const runner = makeRunner({ stdout: "ok" }); + const { meta } = await runCommandReply({ + reply: { mode: "command", command: ["echo", "{{Body}}"] }, + templatingCtx: noopTemplateCtx, + sendSystemOnce: false, + isNewSession: true, + isFirstTurnInSession: true, + systemSent: false, + timeoutMs: 100, + timeoutSeconds: 1, + commandRunner: runner, + enqueue: enqueueImmediate, + }); + expect(meta.queuedMs).toBe(25); + expect(meta.queuedAhead).toBe(2); + }); });