fix(cron): use jobId parameter instead of id for AI tool schema
Fixes parameter mismatch between AI tool schema and internal validation. The TypeBox schema now uses `jobId` for update/remove/run/runs actions, matching what users expect based on the returned job objects. Changes: - Changed parameter from `id` to `jobId` in TypeBox schema for update/remove/run/runs - Updated execute function to read `jobId` parameter - Updated tests to use `jobId` in input parameters The gateway protocol still uses `id` internally - the tool now maps `jobId` from the AI to `id` for the gateway call. Fixes #185 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
28a0864de8
commit
4dac298ae2
@@ -47,7 +47,7 @@ const CronToolSchema = Type.Union([
|
||||
gatewayUrl: Type.Optional(Type.String()),
|
||||
gatewayToken: Type.Optional(Type.String()),
|
||||
timeoutMs: Type.Optional(Type.Number()),
|
||||
id: Type.String(),
|
||||
jobId: Type.String(),
|
||||
patch: Type.Object({}, { additionalProperties: true }),
|
||||
}),
|
||||
Type.Object({
|
||||
@@ -55,21 +55,21 @@ const CronToolSchema = Type.Union([
|
||||
gatewayUrl: Type.Optional(Type.String()),
|
||||
gatewayToken: Type.Optional(Type.String()),
|
||||
timeoutMs: Type.Optional(Type.Number()),
|
||||
id: Type.String(),
|
||||
jobId: Type.String(),
|
||||
}),
|
||||
Type.Object({
|
||||
action: Type.Literal("run"),
|
||||
gatewayUrl: Type.Optional(Type.String()),
|
||||
gatewayToken: Type.Optional(Type.String()),
|
||||
timeoutMs: Type.Optional(Type.Number()),
|
||||
id: Type.String(),
|
||||
jobId: Type.String(),
|
||||
}),
|
||||
Type.Object({
|
||||
action: Type.Literal("runs"),
|
||||
gatewayUrl: Type.Optional(Type.String()),
|
||||
gatewayToken: Type.Optional(Type.String()),
|
||||
timeoutMs: Type.Optional(Type.Number()),
|
||||
id: Type.String(),
|
||||
jobId: Type.String(),
|
||||
}),
|
||||
Type.Object({
|
||||
action: Type.Literal("wake"),
|
||||
@@ -121,7 +121,7 @@ export function createCronTool(): AnyAgentTool {
|
||||
);
|
||||
}
|
||||
case "update": {
|
||||
const id = readStringParam(params, "id", { required: true });
|
||||
const id = readStringParam(params, "jobId", { required: true });
|
||||
if (!params.patch || typeof params.patch !== "object") {
|
||||
throw new Error("patch required");
|
||||
}
|
||||
@@ -134,19 +134,19 @@ export function createCronTool(): AnyAgentTool {
|
||||
);
|
||||
}
|
||||
case "remove": {
|
||||
const id = readStringParam(params, "id", { required: true });
|
||||
const id = readStringParam(params, "jobId", { required: true });
|
||||
return jsonResult(
|
||||
await callGatewayTool("cron.remove", gatewayOpts, { id }),
|
||||
);
|
||||
}
|
||||
case "run": {
|
||||
const id = readStringParam(params, "id", { required: true });
|
||||
const id = readStringParam(params, "jobId", { required: true });
|
||||
return jsonResult(
|
||||
await callGatewayTool("cron.run", gatewayOpts, { id }),
|
||||
);
|
||||
}
|
||||
case "runs": {
|
||||
const id = readStringParam(params, "id", { required: true });
|
||||
const id = readStringParam(params, "jobId", { required: true });
|
||||
return jsonResult(
|
||||
await callGatewayTool("cron.runs", gatewayOpts, { id }),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user