fix(auto-reply): prefer Pi RPC by default
This commit is contained in:
@@ -611,7 +611,9 @@ export async function runCommandReply(
|
||||
streamedAny = true;
|
||||
};
|
||||
|
||||
const preferRpc = process.env.CLAWDIS_USE_PI_RPC === "1";
|
||||
// Default to RPC (it is testable/offline and avoids spawning long-lived CLI processes).
|
||||
// Set `CLAWDIS_USE_PI_RPC=0` to force the JSON fallback path.
|
||||
const preferRpc = process.env.CLAWDIS_USE_PI_RPC !== "0";
|
||||
|
||||
const run = async () => {
|
||||
const runId = params.runId ?? crypto.randomUUID();
|
||||
|
||||
@@ -62,6 +62,7 @@ describe("directive parsing", () => {
|
||||
{},
|
||||
{
|
||||
inbound: {
|
||||
allowFrom: ["*"],
|
||||
reply: {
|
||||
mode: "command",
|
||||
command: ["pi", "{{Body}}"],
|
||||
|
||||
@@ -16,6 +16,7 @@ vi.mock("../web/session.js", () => webMocks);
|
||||
|
||||
const baseCfg = {
|
||||
inbound: {
|
||||
allowFrom: ["*"],
|
||||
reply: {
|
||||
mode: "command" as const,
|
||||
command: ["echo", "{{Body}}"],
|
||||
@@ -88,6 +89,7 @@ describe("trigger handling", () => {
|
||||
{},
|
||||
{
|
||||
inbound: {
|
||||
allowFrom: ["*"],
|
||||
reply: {
|
||||
mode: "command",
|
||||
command: ["echo", "{{Body}}"],
|
||||
@@ -104,6 +106,8 @@ describe("trigger handling", () => {
|
||||
});
|
||||
|
||||
it("ignores think directives that only appear in the context wrapper", async () => {
|
||||
const prevPreferRpc = process.env.CLAWDIS_USE_PI_RPC;
|
||||
process.env.CLAWDIS_USE_PI_RPC = "1";
|
||||
const rpcMock = vi.spyOn(tauRpc, "runPiRpc").mockResolvedValue({
|
||||
stdout:
|
||||
'{"type":"message_end","message":{"role":"assistant","content":[{"type":"text","text":"ok"}]}}',
|
||||
@@ -135,9 +139,17 @@ describe("trigger handling", () => {
|
||||
const prompt = rpcMock.mock.calls[0]?.[0]?.prompt ?? "";
|
||||
expect(prompt).toContain("Give me the status");
|
||||
expect(prompt).not.toContain("/thinking high");
|
||||
|
||||
if (prevPreferRpc === undefined) {
|
||||
delete process.env.CLAWDIS_USE_PI_RPC;
|
||||
} else {
|
||||
process.env.CLAWDIS_USE_PI_RPC = prevPreferRpc;
|
||||
}
|
||||
});
|
||||
|
||||
it("does not emit directive acks for heartbeats with /think", async () => {
|
||||
const prevPreferRpc = process.env.CLAWDIS_USE_PI_RPC;
|
||||
process.env.CLAWDIS_USE_PI_RPC = "1";
|
||||
const rpcMock = vi.spyOn(tauRpc, "runPiRpc").mockResolvedValue({
|
||||
stdout:
|
||||
'{"type":"message_end","message":{"role":"assistant","content":[{"type":"text","text":"ok"}]}}',
|
||||
@@ -170,5 +182,11 @@ describe("trigger handling", () => {
|
||||
expect(text).toBe("ok");
|
||||
expect(text).not.toMatch(/Thinking level set/i);
|
||||
expect(rpcMock).toHaveBeenCalledOnce();
|
||||
|
||||
if (prevPreferRpc === undefined) {
|
||||
delete process.env.CLAWDIS_USE_PI_RPC;
|
||||
} else {
|
||||
process.env.CLAWDIS_USE_PI_RPC = prevPreferRpc;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user