feat: add cron agent binding
This commit is contained in:
@@ -74,6 +74,39 @@ describe("cron cli", () => {
|
||||
expect(params?.payload?.thinking).toBe("low");
|
||||
});
|
||||
|
||||
it("sends agent id on cron add", async () => {
|
||||
callGatewayFromCli.mockClear();
|
||||
|
||||
const { registerCronCli } = await import("./cron-cli.js");
|
||||
const program = new Command();
|
||||
program.exitOverride();
|
||||
registerCronCli(program);
|
||||
|
||||
await program.parseAsync(
|
||||
[
|
||||
"cron",
|
||||
"add",
|
||||
"--name",
|
||||
"Agent pinned",
|
||||
"--cron",
|
||||
"* * * * *",
|
||||
"--session",
|
||||
"isolated",
|
||||
"--message",
|
||||
"hi",
|
||||
"--agent",
|
||||
"ops",
|
||||
],
|
||||
{ from: "user" },
|
||||
);
|
||||
|
||||
const addCall = callGatewayFromCli.mock.calls.find(
|
||||
(call) => call[0] === "cron.add",
|
||||
);
|
||||
const params = addCall?.[2] as { agentId?: string };
|
||||
expect(params?.agentId).toBe("ops");
|
||||
});
|
||||
|
||||
it("omits empty model and thinking on cron edit", async () => {
|
||||
callGatewayFromCli.mockClear();
|
||||
|
||||
@@ -142,6 +175,36 @@ describe("cron cli", () => {
|
||||
expect(patch?.patch?.payload?.thinking).toBe("high");
|
||||
});
|
||||
|
||||
it("sets and clears agent id on cron edit", async () => {
|
||||
callGatewayFromCli.mockClear();
|
||||
|
||||
const { registerCronCli } = await import("./cron-cli.js");
|
||||
const program = new Command();
|
||||
program.exitOverride();
|
||||
registerCronCli(program);
|
||||
|
||||
await program.parseAsync(
|
||||
["cron", "edit", "job-1", "--agent", " Ops ", "--message", "hello"],
|
||||
{ from: "user" },
|
||||
);
|
||||
|
||||
const updateCall = callGatewayFromCli.mock.calls.find(
|
||||
(call) => call[0] === "cron.update",
|
||||
);
|
||||
const patch = updateCall?.[2] as { patch?: { agentId?: unknown } };
|
||||
expect(patch?.patch?.agentId).toBe("Ops");
|
||||
|
||||
callGatewayFromCli.mockClear();
|
||||
await program.parseAsync(["cron", "edit", "job-2", "--clear-agent"], {
|
||||
from: "user",
|
||||
});
|
||||
const clearCall = callGatewayFromCli.mock.calls.find(
|
||||
(call) => call[0] === "cron.update",
|
||||
);
|
||||
const clearPatch = clearCall?.[2] as { patch?: { agentId?: unknown } };
|
||||
expect(clearPatch?.patch?.agentId).toBeNull();
|
||||
});
|
||||
|
||||
it("does not include model/thinking when no payload change is requested", async () => {
|
||||
callGatewayFromCli.mockClear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user