fix: use id for cron tool params

This commit is contained in:
Peter Steinberger
2026-01-05 02:15:11 +01:00
parent 359cb66e68
commit a322075764
3 changed files with 24 additions and 13 deletions

View File

@@ -14,7 +14,7 @@
- Control UI: render Markdown in tool result cards. - Control UI: render Markdown in tool result cards.
- Control UI: prevent overlapping action buttons in Discord guild rules on narrow layouts. - Control UI: prevent overlapping action buttons in Discord guild rules on narrow layouts.
- Android: tapping the foreground service notification brings the app to the front. (#179) — thanks @Syhids - Android: tapping the foreground service notification brings the app to the front. (#179) — thanks @Syhids
- Cron tool passes `id` to the gateway for update/remove/run/runs (keeps `jobId` input). (#180) — thanks @adamgall - Cron tool uses `id` for update/remove/run/runs (aligns with gateway params). (#180) — thanks @adamgall
- Control UI: chat view uses page scroll with sticky header/sidebar and fixed composer (no inner scroll frame). - Control UI: chat view uses page scroll with sticky header/sidebar and fixed composer (no inner scroll frame).
- macOS: treat location permission as always-only to avoid iOS-only enums. (#165) — thanks @Nachx639 - macOS: treat location permission as always-only to avoid iOS-only enums. (#165) — thanks @Nachx639
- macOS: make generated gateway protocol models `Sendable` for Swift 6 strict concurrency. (#195) — thanks @andranik-sahakyan - macOS: make generated gateway protocol models `Sendable` for Swift 6 strict concurrency. (#195) — thanks @andranik-sahakyan

View File

@@ -16,12 +16,12 @@ describe("cron tool", () => {
it.each([ it.each([
[ [
"update", "update",
{ action: "update", jobId: "job-1", patch: { foo: "bar" } }, { action: "update", id: "job-1", patch: { foo: "bar" } },
{ id: "job-1", patch: { foo: "bar" } }, { id: "job-1", patch: { foo: "bar" } },
], ],
["remove", { action: "remove", jobId: "job-1" }, { id: "job-1" }], ["remove", { action: "remove", id: "job-1" }, { id: "job-1" }],
["run", { action: "run", jobId: "job-1" }, { id: "job-1" }], ["run", { action: "run", id: "job-1" }, { id: "job-1" }],
["runs", { action: "runs", jobId: "job-1" }, { id: "job-1" }], ["runs", { action: "runs", id: "job-1" }, { id: "job-1" }],
])("%s sends id to gateway", async (action, args, expectedParams) => { ])("%s sends id to gateway", async (action, args, expectedParams) => {
const tool = createCronTool(); const tool = createCronTool();
await tool.execute("call1", args); await tool.execute("call1", args);
@@ -34,4 +34,15 @@ describe("cron tool", () => {
expect(call.method).toBe(`cron.${action}`); expect(call.method).toBe(`cron.${action}`);
expect(call.params).toEqual(expectedParams); expect(call.params).toEqual(expectedParams);
}); });
it("rejects jobId params", async () => {
const tool = createCronTool();
await expect(
tool.execute("call2", {
action: "update",
jobId: "job-1",
patch: { foo: "bar" },
}),
).rejects.toThrow("id required");
});
}); });

View File

@@ -29,7 +29,7 @@ const CronToolSchema = Type.Union([
gatewayUrl: Type.Optional(Type.String()), gatewayUrl: Type.Optional(Type.String()),
gatewayToken: Type.Optional(Type.String()), gatewayToken: Type.Optional(Type.String()),
timeoutMs: Type.Optional(Type.Number()), timeoutMs: Type.Optional(Type.Number()),
jobId: Type.String(), id: Type.String(),
patch: Type.Object({}, { additionalProperties: true }), patch: Type.Object({}, { additionalProperties: true }),
}), }),
Type.Object({ Type.Object({
@@ -37,21 +37,21 @@ const CronToolSchema = Type.Union([
gatewayUrl: Type.Optional(Type.String()), gatewayUrl: Type.Optional(Type.String()),
gatewayToken: Type.Optional(Type.String()), gatewayToken: Type.Optional(Type.String()),
timeoutMs: Type.Optional(Type.Number()), timeoutMs: Type.Optional(Type.Number()),
jobId: Type.String(), id: Type.String(),
}), }),
Type.Object({ Type.Object({
action: Type.Literal("run"), action: Type.Literal("run"),
gatewayUrl: Type.Optional(Type.String()), gatewayUrl: Type.Optional(Type.String()),
gatewayToken: Type.Optional(Type.String()), gatewayToken: Type.Optional(Type.String()),
timeoutMs: Type.Optional(Type.Number()), timeoutMs: Type.Optional(Type.Number()),
jobId: Type.String(), id: Type.String(),
}), }),
Type.Object({ Type.Object({
action: Type.Literal("runs"), action: Type.Literal("runs"),
gatewayUrl: Type.Optional(Type.String()), gatewayUrl: Type.Optional(Type.String()),
gatewayToken: Type.Optional(Type.String()), gatewayToken: Type.Optional(Type.String()),
timeoutMs: Type.Optional(Type.Number()), timeoutMs: Type.Optional(Type.Number()),
jobId: Type.String(), id: Type.String(),
}), }),
Type.Object({ Type.Object({
action: Type.Literal("wake"), action: Type.Literal("wake"),
@@ -102,7 +102,7 @@ export function createCronTool(): AnyAgentTool {
); );
} }
case "update": { case "update": {
const id = readStringParam(params, "jobId", { required: true }); const id = readStringParam(params, "id", { required: true });
if (!params.patch || typeof params.patch !== "object") { if (!params.patch || typeof params.patch !== "object") {
throw new Error("patch required"); throw new Error("patch required");
} }
@@ -114,19 +114,19 @@ export function createCronTool(): AnyAgentTool {
); );
} }
case "remove": { case "remove": {
const id = readStringParam(params, "jobId", { required: true }); const id = readStringParam(params, "id", { required: true });
return jsonResult( return jsonResult(
await callGatewayTool("cron.remove", gatewayOpts, { id }), await callGatewayTool("cron.remove", gatewayOpts, { id }),
); );
} }
case "run": { case "run": {
const id = readStringParam(params, "jobId", { required: true }); const id = readStringParam(params, "id", { required: true });
return jsonResult( return jsonResult(
await callGatewayTool("cron.run", gatewayOpts, { id }), await callGatewayTool("cron.run", gatewayOpts, { id }),
); );
} }
case "runs": { case "runs": {
const id = readStringParam(params, "jobId", { required: true }); const id = readStringParam(params, "id", { required: true });
return jsonResult( return jsonResult(
await callGatewayTool("cron.runs", gatewayOpts, { id }), await callGatewayTool("cron.runs", gatewayOpts, { id }),
); );