diff --git a/apps/server/src/mcp/toolkits/workflow/tools.test.ts b/apps/server/src/mcp/toolkits/workflow/tools.test.ts index 996802992338f..7dad64df1fa73 100644 --- a/apps/server/src/mcp/toolkits/workflow/tools.test.ts +++ b/apps/server/src/mcp/toolkits/workflow/tools.test.ts @@ -3,8 +3,10 @@ import * as Schema from "effect/Schema"; import { WorkflowToolkit } from "./tools.ts"; -it("signal keeps a wait's exact name", () => { +it("keeps exact wait names and store keys", () => { const decode = Schema.decodeUnknownSync(WorkflowToolkit.tools.t3_workflow.parametersSchema); expect(decode({ action: "signal", runId: "run-1", wait: "review " }).wait).toBe("review "); expect(() => decode({ action: "signal", runId: "run-1", wait: " " })).toThrow(); + expect(decode({ action: "store", key: "team " }).key).toBe("team "); + expect(() => decode({ action: "store_set", key: " ", value: 1 })).toThrow(); }); diff --git a/apps/server/src/mcp/toolkits/workflow/tools.ts b/apps/server/src/mcp/toolkits/workflow/tools.ts index 70289badab205..847c0b191dd35 100644 --- a/apps/server/src/mcp/toolkits/workflow/tools.ts +++ b/apps/server/src/mcp/toolkits/workflow/tools.ts @@ -10,6 +10,11 @@ import * as McpInvocationContext from "../../McpInvocationContext.ts"; export const WORKFLOW_READ_ACTIONS = ["list", "read", "questions", "store"] as const; +// Wait names and store keys match exactly, so they keep their spaces. +const ExactName = Schema.String.check( + Schema.makeFilter((name: string) => name.trim().length > 0, { expected: "a non-blank string" }), +); + const WorkflowTool = Tool.make("t3_workflow", { description: "Durable workflow runs on this server. start: `workflow`, `input`, `idempotencyKey` (same key, same run). list: runs, by `status`. read: one run and its steps. questions: what runs ask a person. hooks: the URL paths that start runs. store: what workflows keep, under keys starting with `key`; store_set a `key` to `value`; store_delete. signal: wake a wait with `value`, addressed by `runId` and `wait`, or by `workflow` and `channel`; answers a question as `{choice, reason?}`. resume: run a paused run's failed step again. cancel.", @@ -29,15 +34,8 @@ const WorkflowTool = Tool.make("t3_workflow", { idempotencyKey: Schema.optional(TrimmedNonEmptyString), runId: Schema.optional(TrimmedNonEmptyString), status: Schema.optional(WorkflowRunStatus), - // Waits match by exact name, so a name keeps its spaces. - wait: Schema.optional( - Schema.String.check( - Schema.makeFilter((name: string) => name.trim().length > 0, { - expected: "a non-blank string", - }), - ), - ), - key: Schema.optional(TrimmedNonEmptyString), + wait: Schema.optional(ExactName), + key: Schema.optional(ExactName), channel: Schema.optional(TrimmedNonEmptyString), value: Schema.optional(Schema.Json), signalId: Schema.optional(