Skip to content

Commit a74f33c

Browse files
committed
test(agents): isolate exec description contracts
1 parent 6685010 commit a74f33c

2 files changed

Lines changed: 45 additions & 40 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/** Model-facing description contracts at the public Bash/process tool factory boundary. */
2+
import { describe, expect, it } from "vitest";
3+
import { withMockedPlatform } from "../test-utils/vitest-spies.js";
4+
import { createExecTool, createProcessTool } from "./bash-tools.js";
5+
6+
const execDefaults = { host: "gateway", security: "full", ask: "off" } as const;
7+
const execTool = createExecTool(execDefaults);
8+
const processTool = createProcessTool();
9+
10+
describe("tool descriptions", () => {
11+
it("adds automation follow-up guidance only when the scheduler is available", () => {
12+
const execWithCron = createExecTool({ ...execDefaults, hasCronTool: true });
13+
const processWithCron = createProcessTool({ hasCronTool: true });
14+
15+
expect(execWithCron.description).toContain(
16+
"automatic completion wake when enabled and output/failure occurs; otherwise process confirms completion",
17+
);
18+
expect(processWithCron.description).toContain("completion without auto-wake");
19+
expect(processWithCron.description).toContain("write, send-keys, submit, paste, kill");
20+
expect(execWithCron.description).toContain(
21+
"No sleep loops for reminders/follow-ups; use automations.",
22+
);
23+
expect(processWithCron.description).toContain(
24+
"No polling as timer/reminder; scheduled follow-up uses automations.",
25+
);
26+
expect(execTool.description).not.toContain("use cron instead");
27+
expect(processTool.description).not.toContain("scheduled follow-ups");
28+
expect(execTool.description).toContain("otherwise process confirms completion");
29+
expect(processTool.description).toContain("completion without auto-wake");
30+
expect(processTool.description).toContain("write, send-keys, submit, paste, kill");
31+
});
32+
33+
it.each(["darwin", "linux", "win32"] as const)(
34+
"limits shell-quoting guidance to Unix hosts: %s",
35+
(platform) => {
36+
withMockedPlatform(platform, () => {
37+
expect(
38+
execTool.description.includes(
39+
"Quote arguments containing shell metacharacters, including URL query strings with `?` or `&`.",
40+
),
41+
).toBe(platform !== "win32");
42+
});
43+
},
44+
);
45+
});

‎src/agents/bash-tools.test.ts‎

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -687,46 +687,6 @@ const runNotifyNoopCase = async ({ label, defaults, expectNotification }: Notify
687687
expectNotifyNoopEvents(events, expectNotification, sessionId, label);
688688
};
689689

690-
describe("tool descriptions", () => {
691-
it("adds automation follow-up guidance only when the scheduler is available", () => {
692-
const execWithCron = createTestExecTool({ hasCronTool: true });
693-
const processWithCron = createProcessTool({ hasCronTool: true });
694-
695-
expect(execWithCron.description).toContain(
696-
"automatic completion wake when enabled and output/failure occurs; otherwise process confirms completion",
697-
);
698-
expect(processWithCron.description).toContain("completion without auto-wake");
699-
expect(processWithCron.description).toContain("write, send-keys, submit, paste, kill");
700-
expect(execWithCron.description).toContain(
701-
"No sleep loops for reminders/follow-ups; use automations.",
702-
);
703-
expect(processWithCron.description).toContain(
704-
"No polling as timer/reminder; scheduled follow-up uses automations.",
705-
);
706-
expect(execTool.description).not.toContain("use cron instead");
707-
expect(processTool.description).not.toContain("scheduled follow-ups");
708-
expect(execTool.description).toContain("otherwise process confirms completion");
709-
expect(processTool.description).toContain("completion without auto-wake");
710-
expect(processTool.description).toContain("write, send-keys, submit, paste, kill");
711-
});
712-
713-
it.each(["darwin", "linux", "win32"] as const)(
714-
"limits shell-quoting guidance to Unix hosts: %s",
715-
(platform) => {
716-
const platformSpy = vi.spyOn(process, "platform", "get").mockReturnValue(platform);
717-
try {
718-
expect(
719-
execTool.description.includes(
720-
"Quote arguments containing shell metacharacters, including URL query strings with `?` or `&`.",
721-
),
722-
).toBe(platform !== "win32");
723-
} finally {
724-
platformSpy.mockRestore();
725-
}
726-
},
727-
);
728-
});
729-
730690
beforeEach(() => {
731691
callIdCounter = 0;
732692
resetProcessRegistryForTests();

0 commit comments

Comments
 (0)