fix: allow inline directives to continue and add mixed-message test

This commit is contained in:
Peter Steinberger
2025-12-05 22:57:52 +00:00
parent d7a188fb34
commit 3241d81ce5
2 changed files with 39 additions and 34 deletions

View File

@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import { extractVerboseDirective, extractThinkDirective } from "./reply.js";
import { describe, expect, it, vi } from "vitest";
import * as tauRpc from "../process/tau-rpc.js";
import { getReplyFromConfig, extractVerboseDirective, extractThinkDirective } from "./reply.js";
describe("directive parsing", () => {
it("ignores verbose directive inside URL", () => {
@@ -26,4 +27,38 @@ describe("directive parsing", () => {
expect(res.hasDirective).toBe(true);
expect(res.thinkLevel).toBe("high");
});
it("applies inline think and still runs agent content", async () => {
const rpcMock = vi.spyOn(tauRpc, "runPiRpc").mockResolvedValue({
stdout:
'{"type":"message_end","message":{"role":"assistant","content":[{"type":"text","text":"done"}]}}',
stderr: "",
code: 0,
signal: null,
killed: false,
});
const res = await getReplyFromConfig(
{
Body: "please sync /think:high now",
From: "+1004",
To: "+2000",
},
{},
{
inbound: {
reply: {
mode: "command",
command: ["pi", "{{Body}}"],
agent: { kind: "pi" },
session: {},
},
},
},
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toBe("done");
expect(rpcMock).toHaveBeenCalledOnce();
});
});