Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/server/src/mcp/toolkits/workflow/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
16 changes: 7 additions & 9 deletions apps/server/src/mcp/toolkits/workflow/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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(
Expand Down
Loading