@devries-cameron20 / t3code-1 / commits / ed44f251d8
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(server): cut T3's MCP tool schemas by a third and merge 18 tools into action tools (#25423)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 26, 2026 at 18:49 UTC ed44f251d89d4dae2f8dcf11c24fb3dec9dda4c7
29 files changed +772 -628
apps/mobile/src/lib/threadActivity.ts
+4 -1
@@ -643,7 +643,10 @@ function itemToolPresentation(item: OrchestrationV2TurnItem): T3McpToolPresentat
643 if (item.type !== "dynamic_tool") {
644 return null;
645 }
646 - return resolveT3McpToolPresentation(item.toolName) ?? resolveT3McpToolPresentation(item.title);
646 + return (
647 + resolveT3McpToolPresentation(item.toolName, item.input) ??
648 + resolveT3McpToolPresentation(item.title, item.input)
649 + );
650 }
651
652 function itemSummary(
apps/server/src/mcp/McpHttpServer.test.ts
+24 -1
@@ -344,7 +344,7 @@ it.effect("refuses preview tools to a client outside a thread before they run",
344 client: { sessionId: "session-1", label: "Claude Code", access: "read-only" as const },
345 };
346 const click = yield* server
347 - .callTool({ name: "preview_click", arguments: { locator: "text=Send" } })
347 + .callTool({ name: "preview_act", arguments: { action: "click", locator: "text=Send" } })
348 .pipe(
349 Effect.provideService(McpInvocationContext.McpInvocationContext, readOnly),
350 Effect.provideService(McpSchema.McpServerClient, client),
@@ -356,6 +356,29 @@ it.effect("refuses preview tools to a client outside a thread before they run",
356 }).pipe(Effect.provide(layerTest)),
357 );
358
359 +it.effect("checks each preview_act action against that action's own input", () =>
360 + Effect.scoped(
361 + Effect.gen(function* () {
362 + const inputs = yield* serveSnapshots("mcp-act-client", {});
363 +
364 + const missingKey = yield* callTool("preview_act", { action: "press" });
365 + expect(missingKey.isError).toBe(true);
366 + expect(inputs).toEqual([]);
367 +
368 + const click = yield* callTool("preview_act", {
369 + action: "click",
370 + locator: "text=Send",
371 + key: "Enter",
372 + });
373 + expect(click.isError).toBe(false);
374 + expect(inputs[0]).toEqual({ locator: "text=Send" });
375 +
376 + yield* callTool("preview_act", { action: "type", selector: "#name", text: "Ada" });
377 + expect(inputs.at(-2)).toEqual({ selector: "#name", text: "Ada" });
378 + }),
379 + ).pipe(Effect.provide(layerTest)),
380 +);
381 +
382 it.effect("decodes null optional arguments the way it decodes omitted ones", () => {
383 const calls: Array<unknown> = [];
384 return Effect.gen(function* () {
apps/server/src/mcp/McpHttpServer.ts
+29 -15
@@ -35,6 +35,7 @@ import {
35 MAX_REPORTED_DEPTH,
36 toolOutcome,
37 } from "../telemetry/ProviderDimensions.ts";
38 +import { advertisedJsonSchema } from "./advertisedJsonSchema.ts";
39 import * as McpInvocationContext from "./McpInvocationContext.ts";
40 import * as McpToolAccess from "./McpToolAccess.ts";
41 import * as OrchestratorMcpService from "./OrchestratorMcpService.ts";
@@ -450,7 +451,7 @@ const registerPreviewSnapshot = Effect.fn("McpHttpServer.registerPreviewSnapshot
451 tool: new McpSchema.Tool({
452 name: tool.name,
453 description: Tool.getDescription(tool),
453 - inputSchema: Tool.getJsonSchema(tool),
454 + inputSchema: advertisedJsonSchema(tool),
455 annotations: {
456 ...Context.getOption(tool.annotations, Tool.Title).pipe(
457 Option.map((title) => ({ title })),
@@ -634,7 +635,7 @@ const registerImageTool = Effect.fn("McpHttpServer.registerImageTool")(function*
635 tool: new McpSchema.Tool({
636 name: tool.name,
637 description: Tool.getDescription(tool),
637 - inputSchema: Tool.getJsonSchema(tool),
638 + inputSchema: advertisedJsonSchema(tool),
639 annotations: {
640 ...Context.getOption(tool.annotations, Tool.Title).pipe(
641 Option.map((title) => ({ title })),
@@ -751,21 +752,31 @@ const HANDOFF_TOOLS: ReadonlySet<string> = new Set([
752 "t3_thread_launch",
753 "t3_thread_send",
754 "t3_thread_send_attachments",
754 - "t3_thread_fork",
755 - "t3_thread_merge_back",
756 - "t3_queue_edit",
757 - "t3_queue_promote_to_steer",
758 - "t3_pending_request_respond",
755 "schedule_task",
756 "run_scheduled_task_now",
757 ]);
758
763 -/** Handoff tools whose result is only `{ sequence }`; their input names the receiving thread. */
764 -const INPUT_TARGET_TOOLS: ReadonlySet<string> = new Set([
765 - "t3_queue_edit",
766 - "t3_queue_promote_to_steer",
767 - "t3_pending_request_respond",
768 -]);
759 +/** Tool actions that hand work over with only a `{ sequence }` result; the input names the thread. */
760 +const INPUT_TARGET_ACTIONS: Readonly<Record<string, ReadonlySet<string>>> = {
761 + t3_queue: new Set(["edit", "promote_to_steer"]),
762 + t3_pending_request: new Set(["respond"]),
763 +};
764 +
765 +/** Tool actions that hand work over and name the receiving thread in their result. */
766 +const RESULT_TARGET_ACTIONS: Readonly<Record<string, ReadonlySet<string>>> = {
767 + t3_thread_transfer: new Set(["fork", "merge_back"]),
768 +};
769 +
770 +const hasAction = (
771 + actions: Readonly<Record<string, ReadonlySet<string>>>,
772 + tool: string,
773 + args: unknown,
774 +) =>
775 + actions[tool]?.has(String((args as { readonly action?: unknown } | null | undefined)?.action)) ===
776 + true;
777 +
778 +const isInputTargetHandoff = (tool: string, args: unknown) =>
779 + hasAction(INPUT_TARGET_ACTIONS, tool, args);
780
781 const resultThreadKeys = ["childThreadId", "targetThreadId", "boundThreadId", "threadId"] as const;
782
@@ -787,7 +798,7 @@ const handoffTargetIds = (
798 args: unknown,
799 result: McpSchema.CallToolResult | undefined,
800 ): ReadonlyArray<string> => {
790 - if (!INPUT_TARGET_TOOLS.has(tool)) return resultThreadIds(result?.structuredContent);
801 + if (!isInputTargetHandoff(tool, args)) return resultThreadIds(result?.structuredContent);
802 if (result === undefined || toolOutcome(result).outcome !== "ok") return [];
803 const threadId = (args as { readonly threadId?: unknown } | null | undefined)?.threadId;
804 return typeof threadId === "string" ? [threadId] : [];
@@ -853,7 +864,10 @@ const withToolAnalytics =
864 result: McpSchema.CallToolResult | undefined,
865 durationMs: number,
866 ) {
856 - const handoff = HANDOFF_TOOLS.has(tool);
867 + const handoff =
868 + HANDOFF_TOOLS.has(tool) ||
869 + isInputTargetHandoff(tool, args) ||
870 + hasAction(RESULT_TARGET_ACTIONS, tool, args);
871 const outcome = toolOutcome(result);
872 // Agents call status, read, and preview tools in tight loops, so an
873 // event per successful call floods analytics. Only failures count there.
apps/server/src/mcp/McpToolAccess.ts
+10
@@ -181,6 +181,16 @@ export const startsThreads = <P, A, E, R>(
181 }),
182 );
183
184 +/** One tool with two access rules, picked per call, such as create versus update. */
185 +export const either = <P, A, E, R, A2, E2, R2>(
186 + useFirst: (params: P) => boolean,
187 + first: Declaration<(params: P) => Effect.Effect<A, E, R>>,
188 + second: Declaration<(params: P) => Effect.Effect<A2, E2, R2>>,
189 +) =>
190 + declare((params: P): Effect.Effect<A | A2, E | E2, R | R2> =>
191 + useFirst(params) ? checkedHandler(first)(params) : checkedHandler(second)(params),
192 + );
193 +
194 const fullAccessRequired =
195 "Changing projects or environment settings needs a live full-access/default calling thread or a full-access client.";
196
apps/server/src/mcp/ThreadMetadataMcpService.ts
-30
@@ -36,14 +36,6 @@ function errorMessage(error: unknown): string {
36 return error instanceof Error ? error.message : String(error);
37 }
38
39 -function threadLookupFailure(
40 - error: ThreadManagementService.ThreadManagementError,
41 -): OrchestratorMcpFailure {
42 - return error._tag === "ThreadManagementThreadNotFoundError"
43 - ? failure("thread_not_found", error.message)
44 - : failure("orchestration_error", error.message);
45 -}
46 -
39 function stablePart(value: string): string {
40 return encodeURIComponent(value);
41 }
@@ -70,7 +62,6 @@ function commandId(input: {
62 function metadataCommand(input: {
63 readonly commandId: CommandId;
64 readonly threadId: ThreadId;
73 - readonly projectId: OrchestrationV2AppThread["projectId"];
65 readonly update: ThreadMetadataMcpUpdateInput;
66 }): Extract<OrchestrationV2Command, { readonly type: "thread.metadata.update" }> {
67 switch (input.update.action) {
@@ -88,23 +79,6 @@ function metadataCommand(input: {
79 threadId: input.threadId,
80 regenerateTitle: true,
81 };
91 - case "link_pull_request":
92 - return {
93 - type: "thread.metadata.update",
94 - commandId: input.commandId,
95 - threadId: input.threadId,
96 - linkedPullRequest: {
97 - projectId: input.projectId,
98 - ...input.update.pullRequest!,
99 - },
100 - };
101 - case "unlink_pull_request":
102 - return {
103 - type: "thread.metadata.update",
104 - commandId: input.commandId,
105 - threadId: input.threadId,
106 - linkedPullRequest: null,
107 - };
82 }
83 }
84
@@ -170,9 +144,6 @@ const make = Effect.gen(function* () {
144 if (shell === null || shell.deletedAt !== null) {
145 return yield* threadNotFound(threadManagement, threadId, `Thread ${threadId} was not found.`);
146 }
173 - const target = yield* threadManagement
174 - .getProjectThreadRecords({ projectId: shell.projectId, threadId }, [])
175 - .pipe(Effect.mapError(threadLookupFailure));
147 const requestKey =
148 input.clientRequestId === undefined
149 ? yield* crypto.randomUUIDv4().pipe(Effect.orDie)
@@ -188,7 +159,6 @@ const make = Effect.gen(function* () {
159 metadataCommand({
160 commandId: updateCommandId,
161 threadId,
191 - projectId: target.thread.projectId,
162 update: input,
163 }),
164 )
apps/server/src/mcp/advertisedJsonSchema.test.ts new
+45
@@ -0,0 +1,45 @@
1 +import { expect, it } from "@effect/vitest";
2 +import * as Schema from "effect/Schema";
3 +import { Tool } from "effect/ai";
4 +
5 +import { advertisedJsonSchema } from "./advertisedJsonSchema.ts";
6 +
7 +it("drops JSON noise, merges tagged unions, and keeps null where it is required", () => {
8 + const Every = Schema.Struct({ ms: Schema.Int });
9 + const tool = Tool.make("example", {
10 + parameters: Schema.Struct({
11 + threadId: Schema.optional(Schema.NullOr(Schema.String)),
12 + beforeRunId: Schema.NullOr(Schema.String),
13 + limit: Schema.optional(Schema.Int),
14 + every: Schema.Union([Every, Schema.fromJsonString(Every)]),
15 + target: Schema.optional(
16 + Schema.NullOr(
17 + Schema.Union([
18 + Schema.Struct({ kind: Schema.Literal("url"), url: Schema.String }),
19 + Schema.Struct({ kind: Schema.Literal("number"), number: Schema.Int }),
20 + ]),
21 + ),
22 + ),
23 + }),
24 + });
25 +
26 + expect(advertisedJsonSchema(tool)).toEqual({
27 + type: "object",
28 + properties: {
29 + threadId: { type: "string" },
30 + beforeRunId: { anyOf: [{ type: "string" }, { type: "null" }] },
31 + limit: { type: "integer" },
32 + every: { type: "object", properties: { ms: { type: "integer" } }, required: ["ms"] },
33 + target: {
34 + type: "object",
35 + properties: {
36 + kind: { type: "string", enum: ["url", "number"] },
37 + url: { type: "string" },
38 + number: { type: "integer" },
39 + },
40 + required: ["kind"],
41 + },
42 + },
43 + required: ["beforeRunId", "every"],
44 + });
45 +});
apps/server/src/mcp/advertisedJsonSchema.ts new
+106
@@ -0,0 +1,106 @@
1 +import * as Predicate from "effect/Predicate";
2 +import { Tool } from "effect/ai";
3 +
4 +type Json = unknown;
5 +type JsonObject = { [key: string]: Json };
6 +
7 +const isNullSchema = (value: Json) =>
8 + Predicate.isObject(value) && value.type === "null" && Object.keys(value).length === 1;
9 +
10 +const isBareAnyOf = (value: Json): value is { anyOf: Array<Json> } =>
11 + Predicate.isObject(value) && Array.isArray(value.anyOf) && Object.keys(value).length === 1;
12 +
13 +// A `Schema.fromJsonString` fallback. Advertised beside object shapes, it invites stringified input.
14 +const isJsonStringSchema = (value: Json) =>
15 + Predicate.isObject(value) &&
16 + value.type === "string" &&
17 + value.contentMediaType === "application/json";
18 +
19 +const SAFE_INTEGER_BOUNDS: Record<string, number> = {
20 + maximum: Number.MAX_SAFE_INTEGER,
21 + minimum: Number.MIN_SAFE_INTEGER,
22 +};
23 +
24 +const tagOf = (branch: JsonObject, key: string): Json => {
25 + const property = Predicate.isObject(branch.properties) ? branch.properties[key] : undefined;
26 + return Predicate.isObject(property) && Array.isArray(property.enum) && property.enum.length === 1
27 + ? property.enum[0]
28 + : undefined;
29 +};
30 +
31 +/** One object for a tagged union of objects: each property once, the tag listing every value. */
32 +const mergeTaggedObjects = (branches: ReadonlyArray<Json>): JsonObject | undefined => {
33 + if (branches.length < 2) return undefined;
34 + const objects = branches.filter(
35 + (branch): branch is JsonObject & { properties: JsonObject } =>
36 + Predicate.isObject(branch) &&
37 + branch.type === "object" &&
38 + Predicate.isObject(branch.properties),
39 + );
40 + if (objects.length !== branches.length) return undefined;
41 + const tag = Object.keys(objects[0]!.properties).find((key) => {
42 + const values = objects.map((object) => tagOf(object, key));
43 + return values.every((value) => value !== undefined) && new Set(values).size === values.length;
44 + });
45 + if (tag === undefined) return undefined;
46 + const properties: JsonObject = {
47 + [tag]: { type: "string", enum: objects.map((object) => tagOf(object, tag)) },
48 + };
49 + for (const object of objects) {
50 + for (const [name, property] of Object.entries(object.properties)) {
51 + if (name === tag) continue;
52 + const seen = properties[name];
53 + if (seen === undefined) properties[name] = property;
54 + else if (JSON.stringify(seen) !== JSON.stringify(property)) {
55 + const options = Predicate.isObject(seen) && isBareAnyOf(seen) ? seen.anyOf : [seen];
56 + if (!options.some((option) => JSON.stringify(option) === JSON.stringify(property)))
57 + properties[name] = { anyOf: [...options, property] };
58 + }
59 + }
60 + }
61 + const [first = [], ...others] = objects.map((object) =>
62 + Array.isArray(object.required) ? object.required : [],
63 + );
64 + const requiredByAll = first.filter(
65 + (name) => name !== tag && others.every((required) => required.includes(name)),
66 + );
67 + return { type: "object", properties, required: [tag, ...requiredByAll] };
68 +};
69 +
70 +const compact = (schema: Json, optional: boolean): Json => {
71 + if (Array.isArray(schema)) return schema.map((item) => compact(item, false));
72 + if (!Predicate.isObject(schema)) return schema;
73 + const required = new Set(Array.isArray(schema.required) ? schema.required : []);
74 + let result: JsonObject = {};
75 + for (const [key, value] of Object.entries(schema)) {
76 + if (key === "additionalProperties" && value === true) continue;
77 + if (SAFE_INTEGER_BOUNDS[key] === value) continue;
78 + result[key] =
79 + key === "properties" && Predicate.isObject(value)
80 + ? Object.fromEntries(
81 + Object.entries(value).map(([name, property]) => [
82 + name,
83 + compact(property, !required.has(name)),
84 + ]),
85 + )
86 + : compact(value, false);
87 + }
88 + if (Array.isArray(result.anyOf)) {
89 + const branches = result.anyOf
90 + .flatMap((branch) => (isBareAnyOf(branch) ? branch.anyOf : [branch]))
91 + .filter((branch) => !(optional && isNullSchema(branch)) && !isJsonStringSchema(branch));
92 + const { anyOf: _anyOf, ...rest } = result;
93 + const only = branches.length === 1 ? branches[0] : mergeTaggedObjects(branches);
94 + result = Predicate.isObject(only) ? { ...only, ...rest } : { ...rest, anyOf: branches };
95 + }
96 + return result;
97 +};
98 +
99 +/**
100 + * The input schema T3 advertises for a tool. Drops JSON noise that every thread pays for:
101 + * `additionalProperties: true`, safe-integer bounds, nested `anyOf`, JSON-string fallbacks, and
102 + * the `null` branch of optional properties. A tagged union of objects becomes one object.
103 + * Decoding still uses the full schema, so each tag's own required fields still apply.
104 + */
105 +export const advertisedJsonSchema = (tool: Tool.Any) =>
106 + compact(Tool.getJsonSchema(tool), false) as ReturnType<typeof Tool.getJsonSchema>;
apps/server/src/mcp/toolkits/core.test.ts
+9 -7
@@ -136,8 +136,8 @@ it.effect("an answered question reports already answered instead of not found",
136 const respond = (id: string) =>
137 server
138 .callTool({
139 - name: "t3_pending_request_respond",
140 - arguments: { requestId: id, answers: { size: "large" } },
139 + name: "t3_pending_request",
140 + arguments: { action: "respond", requestId: id, answers: { size: "large" } },
141 })
142 .pipe(
143 Effect.provideService(McpInvocationContext.McpInvocationContext, scope),
@@ -470,8 +470,8 @@ it.effect("a client caller targets any thread within its ceiling and cannot act
470 });
471
472 const forked = yield* call(
473 - "t3_thread_fork",
474 - { sourcePoint: { type: "latest_stable" } },
473 + "t3_thread_transfer",
474 + { action: "fork", sourcePoint: { type: "latest_stable" } },
475 clientScope("auto"),
476 );
477 expect(declaredFailure(forked)).toMatchObject({ code: "target_required" });
@@ -516,7 +516,7 @@ it.effect("a read-only client reads threads and is refused every write before it
516 Effect.provideService(McpSchema.McpServerClient, client),
517 );
518
519 - const configuration = yield* call("t3_thread_configuration", {
519 + const configuration = yield* call("t3_thread_configure", {
520 threadId: "other-project-thread",
521 });
522 expect(configuration.isError).toBe(false);
@@ -615,18 +615,20 @@ it.effect("a caller cannot rewrite a scheduled task that runs above its own mode
615 Effect.provideService(McpInvocationContext.McpInvocationContext, clientScope("auto")),
616 Effect.provideService(McpSchema.McpServerClient, client),
617 );
618 - const update = yield* call("update_scheduled_task", {
618 + const update = yield* call("schedule_task", {
619 scheduledTaskId: "task-full-access",
620 prompt: "Run something else",
621 });
622 expect(declaredFailure(update)).toMatchObject({ code: "runtime_mode_escalation_denied" });
623 const remove = yield* call("delete_scheduled_task", { scheduledTaskId: "task-full-access" });
624 expect(declaredFailure(remove)).toMatchObject({ code: "runtime_mode_escalation_denied" });
625 - const allowed = yield* call("update_scheduled_task", {
625 + const allowed = yield* call("schedule_task", {
626 scheduledTaskId: "task-auto",
627 enabled: false,
628 });
629 expect(allowed.isError).toBe(false);
630 + const incomplete = yield* call("schedule_task", { prompt: "Run nightly" });
631 + expect(declaredFailure(incomplete)).toMatchObject({ code: "invalid_request" });
632 }).pipe(
633 Effect.provide(
634 layerOrchestratorToolkit.pipe(
apps/server/src/mcp/toolkits/orchestrator/handlers.ts
+33 -15
@@ -78,14 +78,39 @@ const handlers = {
78 );
79 }),
80 ),
81 - schedule_task: McpToolAccess.startsThreads(
82 - () => ({}),
83 - (input) =>
84 - Effect.gen(function* () {
85 - const scope = yield* McpInvocationContext.McpInvocationContext;
86 - const service = yield* OrchestratorMcpService.OrchestratorMcpService;
87 - return yield* service.scheduleTask(scope, input);
88 - }),
81 + schedule_task: McpToolAccess.either(
82 + (input) => input.scheduledTaskId === undefined,
83 + McpToolAccess.startsThreads(
84 + () => ({}),
85 + ({ prompt, schedule, ...input }) =>
86 + Effect.gen(function* () {
87 + if (prompt === undefined || schedule === undefined) {
88 + return yield* new OrchestratorMcpFailure({
89 + code: "invalid_request",
90 + message: "A new scheduled task needs `prompt` and `schedule`.",
91 + });
92 + }
93 + const scope = yield* McpInvocationContext.McpInvocationContext;
94 + const service = yield* OrchestratorMcpService.OrchestratorMcpService;
95 + return yield* service.scheduleTask(scope, { ...input, prompt, schedule });
96 + }),
97 + ),
98 + McpToolAccess.writes(
99 + ({ scheduledTaskId, prompt, title, schedule, enabled, bindToCurrentThread }) =>
100 + Effect.gen(function* () {
101 + if (scheduledTaskId === undefined) return yield* Effect.die("unreachable");
102 + const scope = yield* McpInvocationContext.McpInvocationContext;
103 + const service = yield* OrchestratorMcpService.OrchestratorMcpService;
104 + return yield* service.updateScheduledTask(scope, {
105 + scheduledTaskId,
106 + prompt,
107 + title,
108 + schedule,
109 + enabled,
110 + bindToCurrentThread,
111 + });
112 + }),
113 + ),
114 ),
115 list_scheduled_tasks: McpToolAccess.reads((input) =>
116 Effect.gen(function* () {
@@ -94,13 +119,6 @@ const handlers = {
119 return yield* service.listScheduledTasks(scope, input);
120 }),
121 ),
97 - update_scheduled_task: McpToolAccess.writes((input) =>
98 - Effect.gen(function* () {
99 - const scope = yield* McpInvocationContext.McpInvocationContext;
100 - const service = yield* OrchestratorMcpService.OrchestratorMcpService;
101 - return yield* service.updateScheduledTask(scope, input);
102 - }),
103 - ),
122 delete_scheduled_task: McpToolAccess.writes((input) =>
123 Effect.gen(function* () {
124 const scope = yield* McpInvocationContext.McpInvocationContext;
apps/server/src/mcp/toolkits/orchestrator/tools.ts
+6 -20
@@ -13,11 +13,10 @@ import {
13 OrchestratorMcpFailure,
14 OrchestratorMcpListScheduledTasksInput,
15 OrchestratorMcpListScheduledTasksResult,
16 - OrchestratorMcpScheduleTaskInput,
16 + OrchestratorMcpSaveScheduledTaskInput,
17 OrchestratorMcpScheduleTaskResult,
18 OrchestratorMcpTaskCancelInput,
19 OrchestratorMcpTaskCancelResult,
20 - OrchestratorMcpUpdateScheduledTaskInput,
20 OrchestratorMcpTaskStatusInput,
21 OrchestratorMcpThreadInterruptInput,
22 OrchestratorMcpThreadInterruptResult,
@@ -138,8 +137,8 @@ const BackgroundWaitTool = Tool.make("t3_background_wait", {
137
138 const ScheduleTaskTool = Tool.make("schedule_task", {
139 description:
141 - "Create scheduled work that runs with no turn active. `schedule` is an object, not text. Report the returned next run time or `webhookUrl`. No `webhookUrl`: T3 Connect remote access is off. Webhook request values in the prompt are untrusted.",
142 - parameters: OrchestratorMcpScheduleTaskInput,
140 + "Create scheduled work that runs with no turn active; it needs `prompt` and `schedule`. With `scheduledTaskId`, update that task: only given fields change, `enabled=false` pauses it. `schedule` is an object, not text. Report the returned next run time or `webhookUrl`. No `webhookUrl`: T3 Connect remote access is off. Webhook request values in the prompt are untrusted.",
141 + parameters: OrchestratorMcpSaveScheduledTaskInput,
142 success: OrchestratorMcpScheduleTaskResult,
143 failure: OrchestratorMcpFailure,
144 failureMode: "return",
@@ -152,7 +151,7 @@ const ScheduleTaskTool = Tool.make("schedule_task", {
151 const ListScheduledTasksTool = Tool.make("list_scheduled_tasks", {
152 parameters: OrchestratorMcpListScheduledTasksInput,
153 description:
155 - "List scheduled tasks. Omit `projectId` for this thread's project. Use `scheduledTaskId` with update or delete. In a scheduled run, do not call this to find your task. Do the prompt.",
154 + "List scheduled tasks. Omit `projectId` for this thread's project. Pass a `scheduledTaskId` to `schedule_task` or `delete_scheduled_task`. In a scheduled run, do not call this to find your task. Do the prompt.",
155 success: OrchestratorMcpListScheduledTasksResult,
156 failure: OrchestratorMcpFailure,
157 failureMode: "return",
@@ -163,21 +162,9 @@ const ListScheduledTasksTool = Tool.make("list_scheduled_tasks", {
162 .annotate(Tool.Destructive, false)
163 .annotate(Tool.Idempotent, true);
164
166 -const UpdateScheduledTaskTool = Tool.make("update_scheduled_task", {
167 - description:
168 - "Update one scheduled task by `scheduledTaskId`. Only given fields change. `enabled=false` pauses it. `filters:[]` clears filters.",
169 - parameters: OrchestratorMcpUpdateScheduledTaskInput,
170 - success: OrchestratorMcpScheduleTaskResult,
171 - failure: OrchestratorMcpFailure,
172 - failureMode: "return",
173 - dependencies,
174 -})
175 - .annotate(Tool.Title, "Update a scheduled task")
176 - .annotate(Tool.Destructive, true);
177 -
165 const DeleteScheduledTaskTool = Tool.make("delete_scheduled_task", {
166 description:
180 - "Delete one scheduled task by `scheduledTaskId`. It stops at once. To pause instead, update it with `enabled=false`.",
167 + "Delete one scheduled task by `scheduledTaskId`. It stops at once. To pause instead, use `schedule_task` with `enabled=false`.",
168 parameters: OrchestratorMcpDeleteScheduledTaskInput,
169 success: OrchestratorMcpDeleteScheduledTaskResult,
170 failure: OrchestratorMcpFailure,
@@ -243,7 +230,7 @@ const ThreadReadTool = Tool.make("t3_thread_read", {
230
231 const ThreadUpdateTool = Tool.make("t3_thread_update", {
232 description:
246 - "Rename a thread (`action:'rename'` with `title`), regenerate its title, or link or unlink a PR. Omit `threadId` for this thread. Workspace and branch cannot change here.",
233 + "Rename a thread (`action:'rename'` with `title`) or regenerate its title. Omit `threadId` for this thread. Workspace and branch cannot change here.",
234 parameters: ThreadMetadataMcpUpdateInput,
235 success: ThreadMetadataMcpUpdateResult,
236 failure: OrchestratorMcpFailure,
@@ -302,7 +289,6 @@ export const OrchestratorToolkit = Toolkit.make(
289 BackgroundWaitTool,
290 ScheduleTaskTool,
291 ListScheduledTasksTool,
305 - UpdateScheduledTaskTool,
292 DeleteScheduledTaskTool,
293 RequestSecretTool,
294 CreateThreadsTool,
apps/server/src/mcp/toolkits/preview/handlers.ts
+20 -20
@@ -1,5 +1,6 @@
1 import * as Effect from "effect/Effect";
2 import * as FileSystem from "effect/FileSystem";
3 +import * as Record from "effect/Record";
4 import * as Schema from "effect/Schema";
5 import {
6 PROVIDER_SEND_TURN_MAX_FILE_BYTES,
@@ -7,13 +8,14 @@ import {
8 PreviewAutomationRecordingTransferError,
9 PreviewAutomationRecordingDesktopUpdateRequiredError,
10 PreviewAutomationRecordingArtifact,
11 + PreviewAutomationActInputs,
12 + OrchestratorMcpFailure,
13 type ToolActivityIcon,
14 type ThreadId,
15 type PreviewAutomationOperation,
16 type PreviewAutomationOpenInput,
17 type PreviewAutomationRecordingStatus,
18 type PreviewAutomationResizeResult,
16 - type PreviewAutomationSelectResult,
19 type PreviewAutomationSetColorSchemeResult,
20 type PreviewAutomationSnapshot,
21 type PreviewAutomationStatus,
@@ -110,6 +112,10 @@ const invokeTargeted = <A extends object>(
112 );
113 };
114
115 +const decodeActInput = Record.map(PreviewAutomationActInputs, (schema) =>
116 + Schema.decodeUnknownEffect(schema),
117 +);
118 +
119 const UploadedRecordingArtifact = Schema.Struct({
120 ...PreviewAutomationRecordingArtifact.fields,
121 uploadedAttachmentId: Schema.optional(Schema.String),
@@ -205,26 +211,20 @@ const handlers = {
211 const { includeImage: _includeImage, save: _save, ...operationInput } = input ?? {};
212 return invokeTargeted<PreviewAutomationSnapshot>("snapshot", operationInput);
213 }),
208 - preview_click: McpToolAccess.actsAsCaller((input) =>
209 - invokeTargeted<object>("click", input, input.timeoutMs),
210 - ),
211 - preview_type: McpToolAccess.actsAsCaller((input) =>
212 - invokeTargeted<object>("type", input, input.timeoutMs),
213 - ),
214 - preview_hover: McpToolAccess.actsAsCaller((input) =>
215 - invokeTargeted<object>("hover", input, input.timeoutMs),
216 - ),
217 - preview_select: McpToolAccess.actsAsCaller((input) =>
218 - invokeTargeted<PreviewAutomationSelectResult>("select", input, input.timeoutMs),
219 - ),
220 - preview_drag: McpToolAccess.actsAsCaller((input) =>
221 - invokeTargeted<object>("drag", input, input.timeoutMs),
222 - ),
223 - preview_upload: McpToolAccess.actsAsCaller((input) =>
224 - invokeTargeted<object>("upload", input, input.timeoutMs),
214 + preview_act: McpToolAccess.actsAsCaller(({ action, ...input }) =>
215 + decodeActInput[action](input).pipe(
216 + Effect.mapError(
217 + (cause) => new OrchestratorMcpFailure({ code: "invalid_request", message: cause.message }),
218 + ),
219 + Effect.flatMap((decoded) =>
220 + invokeTargeted<object>(
221 + action,
222 + decoded,
223 + "timeoutMs" in decoded ? decoded.timeoutMs : undefined,
224 + ),
225 + ),
226 + ),
227 ),
226 - preview_press: McpToolAccess.actsAsCaller((input) => invokeTargeted<object>("press", input)),
227 - preview_scroll: McpToolAccess.actsAsCaller((input) => invokeTargeted<object>("scroll", input)),
228 preview_evaluate: McpToolAccess.actsAsCaller(({ tabId, ...input }) =>
229 invoke<unknown>("evaluate", input, undefined, tabId).pipe(
230 Effect.map(({ result, toolIcon }) => ({
apps/server/src/mcp/toolkits/preview/tools.ts
+13 -106
@@ -1,29 +1,22 @@
1 import {
2 OrchestratorMcpFailure,
3 ToolActivityIcon,
4 - PreviewAutomationClickInput,
4 + PreviewAutomationActInput,
5 PreviewAutomationDialogInput,
6 - PreviewAutomationDragInput,
6 PreviewAutomationError,
7 PreviewAutomationEvaluateInput,
9 - PreviewAutomationHoverInput,
8 PreviewAutomationNavigateInput,
9 PreviewAutomationOpenInput,
12 - PreviewAutomationPressInput,
10 PreviewAutomationRecordingArtifact,
11 PreviewAutomationRecordingStatus,
12 PreviewAutomationResizeInput,
13 PreviewAutomationResizeResult,
17 - PreviewAutomationScrollInput,
18 - PreviewAutomationSelectInput,
14 PreviewAutomationSelectResult,
15 PreviewAutomationSetColorSchemeInput,
16 PreviewAutomationSetColorSchemeResult,
17 PreviewAutomationSnapshot,
18 PreviewAutomationStatus,
19 PreviewAutomationTabTargetInput,
25 - PreviewAutomationTypeInput,
26 - PreviewAutomationUploadInput,
20 PreviewAutomationWaitForInput,
21 } from "@t3tools/contracts";
22 import * as Schema from "effect/Schema";
@@ -137,7 +130,7 @@ const PreviewSetAppearanceTool = safeBrowserTool(
130 export const PreviewSnapshotTool = safeBrowserTool(
131 Tool.make("preview_snapshot", {
132 description:
140 - "Use it only when the current request asks for browser work, including checking an edit in the browser. Never use it unasked to verify your own edit, or to repeat a snapshot from an earlier turn. Works on a tab the user is driving. Returns page state, elements, diagnostics, and screenshot size. Target one element with `locator='aria-ref=<ref>'` from `accessibilityTree`, even in frames. Refs die on navigation, a new snapshot, or handoff. Text caps near 20 KB; on your own or an unclaimed tab, `preview_evaluate` reads more. To show a screenshot: `save=true`, then embed ![alt](screenshotPath).",
133 + "Use it only when the current request asks for browser work, including checking an edit in the browser. Never use it unasked to verify your own edit, or to repeat a snapshot from an earlier turn. Works on a tab the user is driving. Returns page state, elements, diagnostics, and screenshot size. Target one element with `locator='aria-ref=<ref>'` from `accessibilityTree`, even in frames. Refs die on navigation, a new snapshot, or handoff. Text caps near 20 KB; on your own or an unclaimed tab, `preview_evaluate` reads more. To show a screenshot when asked: `save=true`, then embed ![alt](screenshotPath).",
134 parameters: Schema.Struct({
135 ...PreviewAutomationTabTargetInput.fields,
136 includeImage: Schema.optional(
@@ -157,90 +150,18 @@ export const PreviewSnapshotTool = safeBrowserTool(
150 }).annotate(Tool.Title, "Inspect browser page"),
151 );
152
160 -const PreviewClickTool = browserTool(
161 - Tool.make("preview_click", {
162 - description: "Click exactly one target. Prefer a Playwright locator. `x` and `y` go together.",
163 - parameters: PreviewAutomationClickInput,
164 - success: PreviewActionResult,
165 - failure: PreviewToolFailure,
166 - dependencies,
167 - }).annotate(Tool.Title, "Click preview page"),
168 -);
169 -
170 -const PreviewTypeTool = browserTool(
171 - Tool.make("preview_type", {
172 - description: "Type literal text into one input. `clear=true` replaces the current text.",
173 - parameters: PreviewAutomationTypeInput,
174 - success: PreviewActionResult,
175 - failure: PreviewToolFailure,
176 - dependencies,
177 - }).annotate(Tool.Title, "Type into preview page"),
178 -);
179 -
180 -const PreviewHoverTool = safeBrowserTool(
181 - Tool.make("preview_hover", {
182 - description: "Hover one target to show menus or tooltips.",
183 - parameters: PreviewAutomationHoverInput,
184 - success: PreviewActionResult,
185 - failure: PreviewToolFailure,
186 - dependencies,
187 - }).annotate(Tool.Title, "Hover preview page"),
188 -);
189 -
190 -const PreviewSelectTool = browserTool(
191 - Tool.make("preview_select", {
192 - description:
193 - "Pick options in one native <select>, by value or label. For a custom dropdown, click it open, then click the option.",
194 - parameters: PreviewAutomationSelectInput,
195 - success: Schema.Struct({
196 - ...PreviewAutomationSelectResult.fields,
197 - ...presentationFields,
198 - }),
199 - failure: PreviewToolFailure,
200 - dependencies,
201 - }).annotate(Tool.Title, "Select preview option"),
202 -);
203 -
204 -const PreviewDragTool = browserTool(
205 - Tool.make("preview_drag", {
206 - description: "Drag one element onto another.",
207 - parameters: PreviewAutomationDragInput,
208 - success: PreviewActionResult,
209 - failure: PreviewToolFailure,
210 - dependencies,
211 - }).annotate(Tool.Title, "Drag in preview page"),
212 -);
213 -
214 -const PreviewUploadTool = browserTool(
215 - Tool.make("preview_upload", {
216 - description:
217 - "Give files from this environment to the page. After a click opens a file picker, `preview_status` reports it. Pass absolute paths to answer it, or an empty list to cancel. Or pass a locator for an <input type=file>.",
218 - parameters: PreviewAutomationUploadInput,
219 - success: PreviewActionResult,
220 - failure: PreviewToolFailure,
221 - dependencies,
222 - }).annotate(Tool.Title, "Upload files to preview page"),
223 -);
224 -
225 -const PreviewPressTool = browserTool(
226 - Tool.make("preview_press", {
227 - description: "Press one key, such as {key:'Enter'} or {key:'a',modifiers:['Meta']}.",
228 - parameters: PreviewAutomationPressInput,
229 - success: PreviewActionResult,
230 - failure: PreviewToolFailure,
231 - dependencies,
232 - }).annotate(Tool.Title, "Press key in preview page"),
233 -);
234 -
235 -const PreviewScrollTool = safeBrowserTool(
236 - Tool.make("preview_scroll", {
153 +const PreviewActTool = browserTool(
154 + Tool.make("preview_act", {
155 description:
238 - "Scroll the chosen tab, or one container with a locator or selector. Positive `deltaY` scrolls down. Positive `deltaX` scrolls right.",
239 - parameters: PreviewAutomationScrollInput,
240 - success: PreviewActionResult,
156 + "Act on the chosen tab. Target with `locator='aria-ref=<ref>'` from `preview_snapshot`; `x` and `y` go together. `timeoutMs` defaults to 15000. click: `button`, `clickCount` 1 to 3. type: literal `text`, `clear=true` replaces it. hover: shows menus or tooltips. select: `values` in one native <select>, by value or label; for a custom dropdown, click it open, then click the option. drag: `source` onto `target`. upload: absolute `paths` answer the file picker `preview_status` reports, [] cancels it, or a `locator` sets an <input type=file>. press: one `key`, such as 'Enter', with `modifiers`, to the focused element; click a field first to focus it. scroll: the tab, or one container with a locator; positive `deltaY` scrolls down, positive `deltaX` right.",
157 + parameters: PreviewAutomationActInput,
158 + success: Schema.Union([
159 + Schema.Struct({ ...PreviewAutomationSelectResult.fields, ...presentationFields }),
160 + PreviewActionResult,
161 + ]),
162 failure: PreviewToolFailure,
163 dependencies,
243 - }).annotate(Tool.Title, "Scroll preview page"),
164 + }).annotate(Tool.Title, "Act in preview page"),
165 );
166
167 /** Wrap non-objects: MCP requires object structuredContent, and Claude Code rejects invalid results entirely. */
@@ -302,14 +223,7 @@ export const PreviewToolkit = Toolkit.make(
223 PreviewResizeTool,
224 PreviewSetAppearanceTool,
225 PreviewSnapshotTool,
305 - PreviewClickTool,
306 - PreviewTypeTool,
307 - PreviewHoverTool,
308 - PreviewSelectTool,
309 - PreviewDragTool,
310 - PreviewUploadTool,
311 - PreviewPressTool,
312 - PreviewScrollTool,
226 + PreviewActTool,
227 PreviewEvaluateTool,
228 PreviewWaitForTool,
229 PreviewRecordingStartTool,
@@ -323,14 +237,7 @@ export const PreviewStandardToolkit = Toolkit.make(
237 PreviewNavigateTool,
238 PreviewResizeTool,
239 PreviewSetAppearanceTool,
326 - PreviewClickTool,
327 - PreviewTypeTool,
328 - PreviewHoverTool,
329 - PreviewSelectTool,
330 - PreviewDragTool,
331 - PreviewUploadTool,
332 - PreviewPressTool,
333 - PreviewScrollTool,
240 + PreviewActTool,
241 PreviewEvaluateTool,
242 PreviewWaitForTool,
243 PreviewRecordingStartTool,
apps/server/src/mcp/toolkits/pullRequests/handlers.test.ts
+20 -1
@@ -32,7 +32,7 @@ import * as McpToolAccess from "../../McpToolAccess.ts";
32 import * as McpToolAccessTestkit from "../../McpToolAccess.testkit.ts";
33 import { listThreadPullRequests } from "./handlers.ts";
34 import * as PullRequestsHandlers from "./handlers.ts";
35 -import { PullRequestsToolkit } from "./tools.ts";
35 +import { CHILD_PULL_REQUEST_REPORT_NEXT, PullRequestsToolkit } from "./tools.ts";
36
37 const PROJECT_ID = ProjectId.make("project-1");
38 const THREAD_ID = ThreadId.make("thread-1");
@@ -353,6 +353,25 @@ describe("pull request toolkit handlers", () => {
353 }),
354 );
355
356 + it.effect("asks a subagent thread to end with its PR report after it links", () =>
357 + Effect.gen(function* () {
358 + const harness = yield* makeHarness({
359 + thread: {
360 + ...makeThread([]),
361 + lineage: {
362 + rootThreadId: ThreadId.make("parent"),
363 + parentThreadId: ThreadId.make("parent"),
364 + relationshipToParent: "subagent",
365 + },
366 + },
367 + });
368 + const result = yield* harness.call("link_pull_request", {
369 + url: "https://github.com/t3tools/t3code/pull/124",
370 + });
371 + expect(result).toMatchObject({ number: 124, next: CHILD_PULL_REQUEST_REPORT_NEXT });
372 + }),
373 + );
374 +
375 it.effect("canonicalizes GitCafe links independently of the thread's project host", () =>
376 Effect.gen(function* () {
377 for (const host of ["git.cafe", "staging.git.cafe"]) {
apps/server/src/mcp/toolkits/pullRequests/handlers.ts
+7 -2
@@ -46,6 +46,7 @@ import {
46 PullRequestProjectNotFoundError,
47 PullRequestsToolkit,
48 type ThreadPullRequestEntry,
49 + CHILD_PULL_REQUEST_REPORT_NEXT,
50 } from "./tools.ts";
51
52 interface ResolvedTarget {
@@ -361,13 +362,17 @@ const make = Effect.gen(function* () {
362 link_pull_request: writesThread((input) =>
363 Effect.gen(function* () {
364 const thread = yield* requireThread(PullRequestLinkFailedError, input.threadId);
365 + const next =
366 + thread.lineage.relationshipToParent === "subagent"
367 + ? { next: CHILD_PULL_REQUEST_REPORT_NEXT }
368 + : {};
369 const project = yield* projectOf(thread, PullRequestLinkFailedError);
370 const target = yield* resolveTarget(input, project);
371 const existing = threadPullRequestsOf(thread).find((link) =>
372 threadPullRequestKeysEqual(link, target),
373 );
374 if (existing && existing.source !== "stack-dismissed")
370 - return { ...target, alreadyLinked: true };
375 + return { ...target, alreadyLinked: true, ...next };
376 const alreadyLinked = yield* engine
377 .dispatch({
378 type: "thread.pull-request.link",
@@ -384,7 +389,7 @@ const make = Effect.gen(function* () {
389
390 Effect.catchCause(dispatchFailure(PullRequestLinkFailedError)),
391 );
387 - return { ...target, alreadyLinked };
392 + return { ...target, alreadyLinked, ...next };
393 }),
394 ),
395 unlink_pull_request: writesThread((input) =>
apps/server/src/mcp/toolkits/pullRequests/tools.ts
+5
@@ -210,9 +210,14 @@ const PullRequestIdentity = {
210 url: Schema.String,
211 };
212
213 +/** A delegated child's report is how its parent learns the PR, so the link result asks for it. */
214 +export const CHILD_PULL_REQUEST_REPORT_NEXT =
215 + "End your reply with: PR <full URL>, head <SHA>, checks and reviews <state>.";
216 +
217 export const LinkPullRequestResult = Schema.Struct({
218 ...PullRequestIdentity,
219 alreadyLinked: Schema.Boolean,
220 + next: Schema.optional(Schema.String),
221 });
222 export type LinkPullRequestResult = typeof LinkPullRequestResult.Type;
223
apps/server/src/mcp/toolkits/thread/handlers.ts
+194 -167
@@ -76,6 +76,16 @@ const readQuestion = Effect.fn("mcp.readQuestion")(function* (input: {
76 });
77 return { ...context, request, item };
78 });
79 +/** A field the chosen action needs. `null` counts as given, as in `beforeRunId: null`. */
80 +const required = <A>(value: A | undefined, name: string) =>
81 + value === undefined
82 + ? Effect.fail(
83 + new OrchestratorMcpFailure({
84 + code: "invalid_request",
85 + message: `This action needs \`${name}\`.`,
86 + }),
87 + )
88 + : Effect.succeed(value);
89 const writesThread = <P extends { readonly threadId?: ThreadId | undefined }, A, E, R>(
90 handle: (params: P) => Effect.Effect<A, E, R>,
91 ) => McpToolAccess.writesThreads((params: P) => [params.threadId], handle);
@@ -117,181 +127,198 @@ export const layer = McpToolAccess.toLayer(ThreadToolkit, {
127 };
128 }),
129 ),
120 - t3_thread_fork: writesThread((input) =>
121 - Effect.gen(function* () {
122 - const { threads, projection } = yield* readThread(input.threadId);
123 - const commandId = yield* newCommandId();
124 - const targetThreadId = ThreadId.make(`${commandId}:fork`);
125 - const result = yield* threads
126 - .dispatch({
127 - type: "thread.fork",
128 - commandId,
129 - sourceThreadId: projection.thread.id,
130 - targetThreadId,
131 - sourcePoint: input.sourcePoint,
132 - ...(input.title === undefined ? {} : { title: input.title }),
133 - createdBy: "agent",
134 - creationSource: "mcp",
135 - })
136 - .pipe(Effect.mapError(dispatchFailure));
137 - return { sequence: result.sequence, targetThreadId };
138 - }),
130 + t3_thread_transfer: McpToolAccess.either(
131 + (input) => input.action === "status",
132 + McpToolAccess.reads((input) =>
133 + Effect.gen(function* () {
134 + const { projection } = yield* readThread(input.threadId, ["contextTransfers"]);
135 + return {
136 + transfers: projection.contextTransfers.map(
137 + ({ id, sourceThreadId, targetThreadId, status }) => ({
138 + id,
139 + sourceThreadId,
140 + targetThreadId,
141 + status,
142 + }),
143 + ),
144 + };
145 + }),
146 + ),
147 + McpToolAccess.writesThreads(
148 + (input) => [input.threadId, input.targetThreadId],
149 + (input) =>
150 + Effect.gen(function* () {
151 + const sourcePoint = input.sourcePoint ?? { type: "latest_stable" as const };
152 + const { threads, projection } = yield* readThread(input.threadId);
153 + const commandId = yield* newCommandId();
154 + if (input.action === "merge_back") {
155 + const targetThreadId = yield* required(input.targetThreadId, "targetThreadId");
156 + yield* readThread(targetThreadId);
157 + const result = yield* threads
158 + .dispatch({
159 + type: "thread.merge_back",
160 + commandId,
161 + sourceThreadId: projection.thread.id,
162 + targetThreadId,
163 + sourcePoint,
164 + createdBy: "agent",
165 + creationSource: "mcp",
166 + })
167 + .pipe(Effect.mapError(dispatchFailure));
168 + return { sequence: result.sequence, targetThreadId };
169 + }
170 + const targetThreadId = ThreadId.make(`${commandId}:fork`);
171 + const result = yield* threads
172 + .dispatch({
173 + type: "thread.fork",
174 + commandId,
175 + sourceThreadId: projection.thread.id,
176 + targetThreadId,
177 + sourcePoint,
178 + ...(input.title === undefined ? {} : { title: input.title }),
179 + createdBy: "agent",
180 + creationSource: "mcp",
181 + })
182 + .pipe(Effect.mapError(dispatchFailure));
183 + return { sequence: result.sequence, targetThreadId };
184 + }),
185 + ),
186 ),
140 - t3_thread_merge_back: McpToolAccess.writesThreads(
141 - (input) => [input.targetThreadId, input.sourceThreadId],
142 - (input) =>
187 + t3_thread_configure: McpToolAccess.either(
188 + (input) => input.modelSelection === undefined,
189 + McpToolAccess.reads((input) =>
190 + Effect.gen(function* () {
191 + const {
192 + projection: { thread },
193 + } = yield* readThread(input.threadId);
194 + return {
195 + threadId: thread.id,
196 + modelSelection: thread.modelSelection,
197 + runtimeMode: thread.runtimeMode,
198 + interactionMode: thread.interactionMode,
199 + };
200 + }),
201 + ),
202 + writesThread((input) =>
203 + Effect.gen(function* () {
204 + const modelSelection = yield* required(input.modelSelection, "modelSelection");
205 + const {
206 + threads,
207 + projection: { thread },
208 + } = yield* readThread(input.threadId);
209 + const type = modelSelectionCommandType(thread.providerInstanceId, modelSelection);
210 + const result = yield* threads
211 + .dispatch({ type, threadId: thread.id, commandId: yield* newCommandId(), modelSelection })
212 + .pipe(Effect.mapError(dispatchFailure));
213 + return { sequence: result.sequence };
214 + }),
215 + ),
216 + ),
217 + t3_pending_request: McpToolAccess.either(
218 + (input) => input.action !== "respond",
219 + McpToolAccess.reads((input) =>
220 + Effect.gen(function* () {
221 + if (input.action === "list") {
222 + const { projection } = yield* readThread(input.threadId, ["runtimeRequests"]);
223 + return {
224 + requestIds: projection.runtimeRequests
225 + .filter((request) => request.kind === "user_input" && request.status === "pending")
226 + .map((request) => request.id),
227 + };
228 + }
229 + const requestId = yield* required(input.requestId, "requestId");
230 + const { item } = yield* readQuestion({ threadId: input.threadId, requestId });
231 + return { requestId, questions: item.questions };
232 + }),
233 + ),
234 + writesThread((input) =>
235 Effect.gen(function* () {
144 - const context = yield* readThread(input.targetThreadId);
145 - const source = yield* readThread(input.sourceThreadId);
146 - const result = yield* context.threads
236 + const requestId = yield* required(input.requestId, "requestId");
237 + const answers = yield* required(input.answers, "answers");
238 + const { threads, projection } = yield* readQuestion({
239 + threadId: input.threadId,
240 + requestId,
241 + });
242 + const result = yield* threads
243 .dispatch({
148 - type: "thread.merge_back",
244 + type: "runtime-request.respond",
245 + threadId: projection.thread.id,
246 commandId: yield* newCommandId(),
150 - sourceThreadId: source.projection.thread.id,
151 - targetThreadId: input.targetThreadId,
152 - sourcePoint: input.sourcePoint,
153 - createdBy: "agent",
154 - creationSource: "mcp",
247 + requestId,
248 + answers,
249 })
250 .pipe(Effect.mapError(dispatchFailure));
157 - return { sequence: result.sequence, targetThreadId: input.targetThreadId };
251 + return { sequence: result.sequence };
252 }),
253 + ),
254 ),
160 - t3_thread_transfers: McpToolAccess.reads((input) =>
161 - Effect.gen(function* () {
162 - const { projection } = yield* readThread(input.threadId, ["contextTransfers"]);
163 - return {
164 - transfers: projection.contextTransfers.map(
165 - ({ id, sourceThreadId, targetThreadId, status }) => ({
166 - id,
167 - sourceThreadId,
168 - targetThreadId,
169 - status,
170 - }),
171 - ),
172 - };
173 - }),
174 - ),
175 - t3_thread_configuration: McpToolAccess.reads((input) =>
176 - Effect.gen(function* () {
177 - const {
178 - projection: { thread },
179 - } = yield* readThread(input.threadId);
180 - return {
181 - threadId: thread.id,
182 - modelSelection: thread.modelSelection,
183 - runtimeMode: thread.runtimeMode,
184 - interactionMode: thread.interactionMode,
185 - };
186 - }),
187 - ),
188 - t3_thread_configure: writesThread((input) =>
189 - Effect.gen(function* () {
190 - const {
191 - threads,
192 - projection: { thread },
193 - } = yield* readThread(input.threadId);
194 - const type = modelSelectionCommandType(thread.providerInstanceId, input.modelSelection);
195 - const result = yield* threads
196 - .dispatch({
197 - type,
198 - threadId: thread.id,
199 - commandId: yield* newCommandId(),
200 - modelSelection: input.modelSelection,
201 - })
202 - .pipe(Effect.mapError(dispatchFailure));
203 - return { sequence: result.sequence };
204 - }),
205 - ),
206 - t3_pending_request_list: McpToolAccess.reads((input) =>
207 - Effect.gen(function* () {
208 - const { projection } = yield* readThread(input.threadId, ["runtimeRequests"]);
209 - return {
210 - requestIds: projection.runtimeRequests
211 - .filter((request) => request.kind === "user_input" && request.status === "pending")
212 - .map((request) => request.id),
213 - };
214 - }),
215 - ),
216 - t3_pending_request_read: McpToolAccess.reads((input) =>
217 - Effect.gen(function* () {
218 - const { item } = yield* readQuestion(input);
219 - return { requestId: input.requestId, questions: item.questions };
220 - }),
221 - ),
222 - t3_pending_request_respond: writesThread((input) =>
223 - Effect.gen(function* () {
224 - const { threads, projection } = yield* readQuestion(input);
225 - const result = yield* threads
226 - .dispatch({
227 - type: "runtime-request.respond",
228 - threadId: projection.thread.id,
229 - commandId: yield* newCommandId(),
230 - requestId: input.requestId,
231 - answers: input.answers,
232 - })
233 - .pipe(Effect.mapError(dispatchFailure));
234 - return { sequence: result.sequence };
235 - }),
236 - ),
237 - t3_queue_list: McpToolAccess.reads((input) =>
238 - Effect.gen(function* () {
239 - const { projection } = yield* readThread(input.threadId, ["runs", "messages"]);
240 - const runs = queuedRunsInDeliveryOrder(projection);
241 - const cursor = input.cursor ?? 0;
242 - const end = cursor + (input.limit ?? 20);
243 - return {
244 - items: runs.slice(cursor, end).flatMap((run) => {
245 - const entry = queueEntry(projection, run.id, 1000);
246 - return entry === undefined ? [] : [entry];
247 - }),
248 - nextCursor: end < runs.length ? end : null,
249 - };
250 - }),
251 - ),
252 - t3_queue_read: McpToolAccess.reads((input) =>
253 - Effect.gen(function* () {
254 - const { projection } = yield* readThread(input.threadId, ["runs", "messages"]);
255 - const entry = queueEntry(projection, input.queuedRunId, 16000);
256 - return (
257 - entry ??
258 - (yield* new OrchestratorMcpFailure({
259 - code: "invalid_request",
260 - message: "The queued message was not found.",
261 - }))
262 - );
263 - }),
264 - ),
265 - t3_queue_edit: writesThread((input) =>
266 - dispatch(input.threadId, (common) => ({
267 - ...common,
268 - type: "queued-run.edit",
269 - runId: input.queuedRunId,
270 - text: input.text,
271 - })),
272 - ),
273 - t3_queue_cancel: writesThread((input) =>
274 - dispatch(input.threadId, (common) => ({
275 - ...common,
276 - type: "queued-run.cancel",
277 - runId: input.queuedRunId,
278 - })),
279 - ),
280 - t3_queue_reorder: writesThread((input) =>
281 - dispatch(input.threadId, (common) => ({
282 - ...common,
283 - type: "queued-run.reorder",
284 - runId: input.queuedRunId,
285 - beforeRunId: input.beforeRunId,
286 - })),
287 - ),
288 - t3_queue_promote_to_steer: writesThread((input) =>
289 - dispatch(input.threadId, (common) => ({
290 - ...common,
291 - type: "queued-message.promote-to-steer",
292 - queuedRunId: input.queuedRunId,
293 - targetRunId: input.targetRunId,
294 - })),
255 + t3_queue: McpToolAccess.either(
256 + (input) => input.action === "list" || input.action === "read",
257 + McpToolAccess.reads((input) =>
258 + Effect.gen(function* () {
259 + const { projection } = yield* readThread(input.threadId, ["runs", "messages"]);
260 + if (input.action === "list") {
261 + const runs = queuedRunsInDeliveryOrder(projection);
262 + const cursor = input.cursor ?? 0;
263 + const end = cursor + (input.limit ?? 20);
264 + return {
265 + items: runs.slice(cursor, end).flatMap((run) => {
266 + const entry = queueEntry(projection, run.id, 1000);
267 + return entry === undefined ? [] : [entry];
268 + }),
269 + nextCursor: end < runs.length ? end : null,
270 + };
271 + }
272 + const queuedRunId = yield* required(input.queuedRunId, "queuedRunId");
273 + return (
274 + queueEntry(projection, queuedRunId, 16000) ??
275 + (yield* new OrchestratorMcpFailure({
276 + code: "invalid_request",
277 + message: "The queued message was not found.",
278 + }))
279 + );
280 + }),
281 + ),
282 + writesThread((input) =>
283 + Effect.gen(function* () {
284 + const runId = yield* required(input.queuedRunId, "queuedRunId");
285 + switch (input.action) {
286 + case "edit": {
287 + const text = yield* required(input.text, "text");
288 + return yield* dispatch(input.threadId, (common) => ({
289 + ...common,
290 + type: "queued-run.edit",
291 + runId,
292 + text,
293 + }));
294 + }
295 + case "reorder": {
296 + const beforeRunId = yield* required(input.beforeRunId, "beforeRunId");
297 + return yield* dispatch(input.threadId, (common) => ({
298 + ...common,
299 + type: "queued-run.reorder",
300 + runId,
301 + beforeRunId,
302 + }));
303 + }
304 + case "promote_to_steer": {
305 + const targetRunId = yield* required(input.targetRunId, "targetRunId");
306 + return yield* dispatch(input.threadId, (common) => ({
307 + ...common,
308 + type: "queued-message.promote-to-steer",
309 + queuedRunId: runId,
310 + targetRunId,
311 + }));
312 + }
313 + default:
314 + return yield* dispatch(input.threadId, (common) => ({
315 + ...common,
316 + type: "queued-run.cancel",
317 + runId,
318 + }));
319 + }
320 + }),
321 + ),
322 ),
323 t3_thread_organize: writesThread((input) =>
324 Effect.gen(function* () {
apps/server/src/mcp/toolkits/thread/tools.ts
+63 -126
@@ -61,7 +61,6 @@ const ThreadOrganizeTool = Tool.make("t3_thread_organize", {
61 .annotate(Tool.Title, "Organize a thread")
62 .annotate(Tool.Destructive, true);
63
64 -const queueTarget = { threadId: Schema.optional(ThreadId), queuedRunId: RunId };
64 const commandTool = {
65 success: OrchestrationV2DispatchCommandResult,
66 failure: OrchestratorMcpFailure,
@@ -77,55 +76,34 @@ const queueEntry = Schema.Struct({
76 text: Schema.String,
77 truncated: Schema.Boolean,
78 });
80 -const QueueListTool = Tool.make("t3_queue_list", {
79 +const QUEUE_READ_ACTIONS = ["list", "read"] as const;
80 +const QueueTool = Tool.make("t3_queue", {
81 ...commandTool,
82 - description: "List queued messages in send order. For full history, use `t3_thread_read`.",
82 + description:
83 + "Manage a thread's queued messages. Omit `threadId` for this thread. list: send order, paged by `cursor` and `limit`. read: up to 16,000 chars of one. edit: replace its `text`; attachments stay. cancel. reorder: before `beforeRunId`, or to the end with null. promote_to_steer: send it now as steering to active `targetRunId`. Writes fail once the run is no longer queued.",
84 parameters: Schema.Struct({
85 + action: Schema.Literals([
86 + ...QUEUE_READ_ACTIONS,
87 + "edit",
88 + "cancel",
89 + "reorder",
90 + "promote_to_steer",
91 + ]),
92 threadId: Schema.optional(ThreadId),
93 + queuedRunId: Schema.optional(RunId),
94 + text: Schema.optional(Schema.String.check(Schema.isMaxLength(100000))),
95 + beforeRunId: Schema.optional(Schema.NullOr(RunId)),
96 + targetRunId: Schema.optional(RunId),
97 cursor: Schema.optional(NonNegativeInt),
98 limit: Schema.optional(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 }))),
99 }),
88 - success: Schema.Struct({
89 - items: Schema.Array(queueEntry),
90 - nextCursor: Schema.NullOr(NonNegativeInt),
91 - }),
92 -})
93 - .annotate(Tool.Readonly, true)
94 - .annotate(Tool.Destructive, false);
95 -const QueueReadTool = Tool.make("t3_queue_read", {
96 - ...commandTool,
97 - description: "Read up to 16,000 chars of one queued message. Omit `threadId` for this thread.",
98 - parameters: Schema.Struct(queueTarget),
99 - success: queueEntry,
100 -})
101 - .annotate(Tool.Readonly, true)
102 - .annotate(Tool.Destructive, false);
103 -const QueueEditTool = Tool.make("t3_queue_edit", {
104 - ...commandTool,
105 - description:
106 - "Replace one queued message's text. Attachments stay. Fails if the run is no longer queued.",
107 - parameters: Schema.Struct({
108 - ...queueTarget,
109 - text: Schema.String.check(Schema.isMaxLength(100000)),
110 - }),
111 -}).annotate(Tool.Destructive, true);
112 -const QueueCancelTool = Tool.make("t3_queue_cancel", {
113 - ...commandTool,
114 - description: "Cancel one queued run.",
115 - parameters: Schema.Struct(queueTarget),
116 -}).annotate(Tool.Destructive, true);
117 -const QueueReorderTool = Tool.make("t3_queue_reorder", {
118 - ...commandTool,
119 - description: "Move one queued run before another, or to the end with `beforeRunId=null`.",
120 - parameters: Schema.Struct({ ...queueTarget, beforeRunId: Schema.NullOr(RunId) }),
121 -}).annotate(Tool.Destructive, true);
122 -const QueuePromoteTool = Tool.make("t3_queue_promote_to_steer", {
123 - ...commandTool,
124 - description: "Send one queued message now as steering to the given active run.",
125 - parameters: Schema.Struct({ ...queueTarget, targetRunId: RunId }),
100 + success: Schema.Union([
101 + Schema.Struct({ items: Schema.Array(queueEntry), nextCursor: Schema.NullOr(NonNegativeInt) }),
102 + queueEntry,
103 + OrchestrationV2DispatchCommandResult,
104 + ]),
105 }).annotate(Tool.Destructive, true);
106
128 -const requestTarget = { threadId: Schema.optional(ThreadId), requestId: RuntimeRequestId };
107 const question = Schema.Struct({
108 id: Schema.String,
109 header: Schema.String,
@@ -142,98 +120,67 @@ const question = Schema.Struct({
120 initialAnswer: Schema.optional(Schema.String),
121 required: Schema.optional(Schema.Boolean),
122 });
145 -const pendingRequest = Schema.Struct({
146 - requestId: RuntimeRequestId,
147 - questions: Schema.Array(question),
148 -});
149 -const PendingRequestListTool = Tool.make("t3_pending_request_list", {
123 +const PendingRequestTool = Tool.make("t3_pending_request", {
124 ...commandTool,
125 description:
152 - "List pending user questions in a thread. Omit `threadId` for this thread. Approvals are not listed.",
153 - parameters: Schema.Struct({ threadId: Schema.optional(ThreadId) }),
154 - success: Schema.Struct({ requestIds: Schema.Array(RuntimeRequestId) }),
155 -})
156 - .annotate(Tool.Readonly, true)
157 - .annotate(Tool.Destructive, false);
158 -const PendingRequestReadTool = Tool.make("t3_pending_request_read", {
159 - ...commandTool,
160 - description: "Read one pending user question. Answer it with `t3_pending_request_respond`.",
161 - parameters: Schema.Struct(requestTarget),
162 - success: pendingRequest,
163 -})
164 - .annotate(Tool.Readonly, true)
165 - .annotate(Tool.Destructive, false);
166 -const PendingRequestRespondTool = Tool.make("t3_pending_request_respond", {
167 - ...commandTool,
168 - description: "Answer one pending user question. This cannot approve a permission request.",
169 - parameters: Schema.Struct({ ...requestTarget, answers: ProviderUserInputAnswers }),
126 + "Pending user questions in a thread. Omit `threadId` for this thread. list: their ids; approvals are not listed. read: one by `requestId`. respond: answer one with `answers`; this cannot approve a permission request.",
127 + parameters: Schema.Struct({
128 + action: Schema.Literals(["list", "read", "respond"]),
129 + threadId: Schema.optional(ThreadId),
130 + requestId: Schema.optional(RuntimeRequestId),
131 + answers: Schema.optional(ProviderUserInputAnswers),
132 + }),
133 + success: Schema.Union([
134 + Schema.Struct({ requestIds: Schema.Array(RuntimeRequestId) }),
135 + Schema.Struct({ requestId: RuntimeRequestId, questions: Schema.Array(question) }),
136 + OrchestrationV2DispatchCommandResult,
137 + ]),
138 })
139 .annotate(Tool.Destructive, true)
140 .annotate(Tool.OpenWorld, true);
141
174 -const ThreadConfigurationTool = Tool.make("t3_thread_configuration", {
175 - ...commandTool,
176 - description: "Read a thread's provider, model, and modes. Omit `threadId` for this thread.",
177 - parameters: Schema.Struct({ threadId: Schema.optional(ThreadId) }),
178 - success: Schema.Struct({
179 - threadId: ThreadId,
180 - modelSelection: ModelSelection,
181 - runtimeMode: RuntimeMode,
182 - interactionMode: ProviderInteractionMode,
183 - }),
184 -})
185 - .annotate(Tool.Readonly, true)
186 - .annotate(Tool.Destructive, false);
142 +const threadConfiguration = Schema.Struct({
143 + threadId: ThreadId,
144 + modelSelection: ModelSelection,
145 + runtimeMode: RuntimeMode,
146 + interactionMode: ProviderInteractionMode,
147 +});
148 const ThreadConfigureTool = Tool.make("t3_thread_configure", {
149 ...commandTool,
150 description:
190 - "Set a thread's provider, model, and options. Omit `threadId` for this thread. Permission modes stay. Values from `orchestrator_capabilities`.",
151 + "Read a thread's provider, model, and modes, or set its provider, model, and options with `modelSelection`. Omit `threadId` for this thread. Permission modes stay. Values from `orchestrator_capabilities`.",
152 parameters: Schema.Struct({
153 threadId: Schema.optional(ThreadId),
193 - modelSelection: ModelSelection,
154 + modelSelection: Schema.optional(ModelSelection),
155 }),
156 + success: Schema.Union([threadConfiguration, OrchestrationV2DispatchCommandResult]),
157 }).annotate(Tool.Destructive, true);
158
197 -const transferResult = Schema.Struct({ sequence: NonNegativeInt, targetThreadId: ThreadId });
198 -const ThreadForkTool = Tool.make("t3_thread_fork", {
159 +const ThreadTransferTool = Tool.make("t3_thread_transfer", {
160 ...commandTool,
161 description:
201 - "Fork a thread from a stable run or checkpoint. Omit `threadId` for this thread. Keeps source setup. No turn has run yet.",
162 + "Move context between threads. Omit `threadId` for this thread. fork: copy it from `sourcePoint` (default latest stable run) into a new thread with the same setup; no turn runs yet. merge_back: merge it from `sourcePoint` into a related `targetThreadId` in the same project. status: its context transfers.",
163 parameters: Schema.Struct({
164 + action: Schema.Literals(["fork", "merge_back", "status"]),
165 threadId: Schema.optional(ThreadId),
204 - sourcePoint: OrchestrationV2ThreadForkSourcePoint,
166 + sourcePoint: Schema.optional(OrchestrationV2ThreadForkSourcePoint),
167 + targetThreadId: Schema.optional(ThreadId),
168 title: Schema.optional(TrimmedNonEmptyString),
169 }),
207 - success: transferResult,
208 -}).annotate(Tool.Destructive, true);
209 -const ThreadMergeBackTool = Tool.make("t3_thread_merge_back", {
210 - ...commandTool,
211 - description:
212 - "Merge context from one thread into a related thread in the same project. Omit `sourceThreadId` for this thread.",
213 - parameters: Schema.Struct({
214 - sourceThreadId: Schema.optional(ThreadId),
215 - targetThreadId: ThreadId,
216 - sourcePoint: OrchestrationV2ThreadForkSourcePoint,
217 - }),
218 - success: transferResult,
170 + success: Schema.Union([
171 + Schema.Struct({ sequence: NonNegativeInt, targetThreadId: ThreadId }),
172 + Schema.Struct({
173 + transfers: Schema.Array(
174 + Schema.Struct({
175 + id: OrchestrationV2ContextTransfer.fields.id,
176 + sourceThreadId: OrchestrationV2ContextTransfer.fields.sourceThreadId,
177 + targetThreadId: OrchestrationV2ContextTransfer.fields.targetThreadId,
178 + status: OrchestrationV2ContextTransfer.fields.status,
179 + }),
180 + ),
181 + }),
182 + ]),
183 }).annotate(Tool.Destructive, true);
220 -const ThreadTransfersTool = Tool.make("t3_thread_transfers", {
221 - ...commandTool,
222 - description: "Read context transfer status for a thread. Omit `threadId` for this thread.",
223 - parameters: Schema.Struct({ threadId: Schema.optional(ThreadId) }),
224 - success: Schema.Struct({
225 - transfers: Schema.Array(
226 - Schema.Struct({
227 - id: OrchestrationV2ContextTransfer.fields.id,
228 - sourceThreadId: OrchestrationV2ContextTransfer.fields.sourceThreadId,
229 - targetThreadId: OrchestrationV2ContextTransfer.fields.targetThreadId,
230 - status: OrchestrationV2ContextTransfer.fields.status,
231 - }),
232 - ),
233 - }),
234 -})
235 - .annotate(Tool.Readonly, true)
236 - .annotate(Tool.Destructive, false);
184
185 const ThreadSearchTool = Tool.make("t3_thread_search", {
186 ...commandTool,
@@ -281,19 +228,9 @@ const ScheduledTaskRunTool = Tool.make("run_scheduled_task_now", {
228 export const ThreadToolkit = Toolkit.make(
229 ScheduledTaskRunTool,
230 ThreadSearchTool,
284 - ThreadForkTool,
285 - ThreadMergeBackTool,
286 - ThreadTransfersTool,
287 - ThreadConfigurationTool,
231 ThreadConfigureTool,
289 - PendingRequestListTool,
290 - PendingRequestReadTool,
291 - PendingRequestRespondTool,
232 + ThreadTransferTool,
233 ThreadOrganizeTool,
293 - QueueListTool,
294 - QueueReadTool,
295 - QueueEditTool,
296 - QueueCancelTool,
297 - QueueReorderTool,
298 - QueuePromoteTool,
234 + PendingRequestTool,
235 + QueueTool,
236 );
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
-6
@@ -1587,10 +1587,6 @@ export const CLAUDE_READ_ONLY_T3_MCP_ALLOWED_TOOLS: ReadonlyArray<string> = [
1587 "mcp__t3-code__list_scheduled_tasks",
1588 "mcp__t3-code__t3_thread_list",
1589 "mcp__t3-code__t3_thread_wait",
1590 - "mcp__t3-code__t3_pending_request_list",
1591 - "mcp__t3-code__t3_pending_request_read",
1592 - "mcp__t3-code__t3_thread_configuration",
1593 - "mcp__t3-code__t3_thread_transfers",
1590 "mcp__t3-code__t3_worktree_status",
1591 "mcp__t3-code__t3_worktree_list",
1592 "mcp__t3-code__t3_project_list",
@@ -1598,8 +1594,6 @@ export const CLAUDE_READ_ONLY_T3_MCP_ALLOWED_TOOLS: ReadonlyArray<string> = [
1594 "mcp__t3-code__t3_thread_search",
1595 "mcp__t3-code__t3_preview_list",
1596 "mcp__t3-code__t3_environment_read",
1601 - "mcp__t3-code__t3_queue_list",
1602 - "mcp__t3-code__t3_queue_read",
1597 "mcp__t3-code__html_preview",
1598 "mcp__t3-code__html_render",
1599 ];
apps/server/src/orchestration-v2/DelegatedTaskQuestionReactor.ts
+1 -1
@@ -45,7 +45,7 @@ const make = Effect.gen(function* () {
45 commandId: CommandId.make(`server:delegated-task-question:${key}`),
46 threadId: task.threadId,
47 messageId: MessageId.make(`message:delegated-task-question:${key}`),
48 - text: `${situation} Read it with t3_pending_request_read using threadId ${task.childThreadId} and requestId ${request.id}. Answer it with t3_pending_request_respond when the answer follows from the task or the user's instructions; otherwise ask the user, then answer it. If it is no longer pending, it was answered or dismissed.`,
48 + text: `${situation} Read it with t3_pending_request action read, threadId ${task.childThreadId}, and requestId ${request.id}. Answer it with action respond when the answer follows from the task or the user's instructions; otherwise ask the user, then answer it. If it is no longer pending, it was answered or dismissed.`,
49 notification: {
50 source: { kind: "delegated_task", taskIds: [task.id], childThreadId: task.childThreadId },
51 outcome: "updated",
docs/orchestration-v2/orchestrator-mcp-server.md
+2 -3
@@ -270,9 +270,8 @@ provider session. The request becomes the V2 command
270 the timeout expires. A wait timeout does not cancel the child; the result sets
271 `waitTimedOut: true`, and the caller can continue with `task_status`. A pending blocking
272 question also ends the wait with `hasPendingQuestion: true` and `waitTimedOut: false`.
273 -If `hasPendingQuestion`, pass `threadId=childThreadId` to `t3_pending_request_list`,
274 -`t3_pending_request_read` (with `requestId`) and `t3_pending_request_respond`, or ask
275 -the user; the task's completion still wakes this thread. A pending live approval for the
273 +If `hasPendingQuestion`, pass `threadId=childThreadId` to `t3_pending_request` with
274 +action `list`, `read` (with `requestId`), or `respond`, or ask the user; the task's completion still wakes this thread. A pending live approval for the
275 task's own unfinished work also ends the wait. Its identity appears in `pendingApproval`;
276 it grants no approval authority. Read the fresh full request in the child thread before
277 responding, since the durable record can outlive its provider callback. Async questions
packages/client-runtime/src/work-log/presentation.ts
+20 -11
@@ -10,6 +10,7 @@ import {
10 type ThreadId,
11 } from "@t3tools/contracts";
12 import {
13 + resolveT3McpSummaryAction,
14 resolveT3McpToolDefinition,
15 type T3McpToolDefinition,
16 type T3McpToolSummaryAction,
@@ -143,6 +144,16 @@ function workEntryToolName(
144 return resolveT3McpToolDefinition(entry.toolTitle) ? entry.toolTitle : entry.label;
145 }
146
147 +function workEntryToolInput(
148 + entry: Pick<WorkLogPresentationEntry, "toolData" | "structuredPayload">,
149 +): unknown {
150 + const item = entry.structuredPayload;
151 + const data = asRecord(entry.toolData);
152 + return item?.type === "dynamic_tool"
153 + ? item.input
154 + : (data?.arguments ?? data?.input ?? data?.rawInput);
155 +}
156 +
157 function workEntryToolOutput(
158 entry: Pick<WorkLogPresentationEntry, "toolData" | "structuredPayload">,
159 ): unknown {
@@ -219,7 +230,10 @@ export function resolveWorkEntryToolPresentation(
230 >,
231 fallbackStatus?: "inProgress" | "completed",
232 ) {
222 - const definition = resolveT3McpToolDefinition(workEntryToolName(entry));
233 + const definition = resolveT3McpToolDefinition(
234 + workEntryToolName(entry),
235 + workEntryToolInput(entry),
236 + );
237 const status = entry.toolLifecycleStatus ?? fallbackStatus;
238 return resolveT3McpToolPresentation(
239 definition,
@@ -454,16 +468,8 @@ function toolGroupActionLabel(action: ToolGroupAction, count: number): string {
468 }
469
470 function t3ToolSummaryCall(entry: WorkLogPresentationEntry): T3ToolSummaryCall {
457 - const item = entry.structuredPayload;
458 - const data =
459 - entry.toolData !== null && typeof entry.toolData === "object"
460 - ? (entry.toolData as Record<string, unknown>)
461 - : undefined;
471 return {
463 - input:
464 - item?.type === "dynamic_tool"
465 - ? item.input
466 - : (data?.arguments ?? data?.input ?? data?.rawInput),
472 + input: workEntryToolInput(entry),
473 output: workEntryToolOutput(entry),
474 outcome:
475 entry.toolLifecycleStatus === "failed" ||
@@ -541,7 +547,10 @@ export function summarizeToolGroup(entries: ReadonlyArray<WorkLogPresentationEnt
547 >();
548 const sources = new Map<string, ToolActivitySource>();
549 for (const entry of entries) {
544 - const t3Action = resolveT3McpToolDefinition(workEntryToolName(entry))?.summaryAction ?? null;
550 + const t3Action = resolveT3McpSummaryAction(
551 + workEntryToolName(entry),
552 + t3ToolSummaryCall(entry).input,
553 + );
554 if (entry.toolSource && t3Action === null) {
555 sources.set(entry.toolSource.key, entry.toolSource);
556 continue;
packages/contracts/src/orchestratorMcp.ts
+11 -1
@@ -200,7 +200,7 @@ export const OrchestratorMcpDelegateTaskResult = Schema.Struct({
200 resultContextTransferId: Schema.NullOr(ContextTransferId),
201 hasPendingQuestion: Schema.Boolean.annotate({
202 description:
203 - "A question blocks the child and ends a wait. Answer via `t3_pending_request_*` on `childThreadId`, or the user does.",
203 + "A question blocks the child and ends a wait. Answer via `t3_pending_request` on `childThreadId`, or the user does.",
204 }),
205 pendingApproval: Schema.NullOr(
206 Schema.Struct({ requestId: RuntimeRequestId, kind: ProviderRequestKind, runId: RunId }),
@@ -582,6 +582,16 @@ export const OrchestratorMcpScheduleTaskInput = Schema.Struct({
582 });
583 export type OrchestratorMcpScheduleTaskInput = typeof OrchestratorMcpScheduleTaskInput.Type;
584
585 +/** `schedule_task` creates a task, or updates one when `scheduledTaskId` is given. */
586 +export const OrchestratorMcpSaveScheduledTaskInput = Schema.Struct({
587 + ...OrchestratorMcpScheduleTaskInput.fields,
588 + scheduledTaskId: Schema.optional(ScheduledTaskId),
589 + prompt: Schema.optional(OrchestratorMcpPrompt),
590 + schedule: Schema.optional(OrchestratorMcpSchedule),
591 +});
592 +export type OrchestratorMcpSaveScheduledTaskInput =
593 + typeof OrchestratorMcpSaveScheduledTaskInput.Type;
594 +
595 export const OrchestratorMcpScheduledTask = Schema.Struct({
596 scheduledTaskId: ScheduledTaskId,
597 title: Schema.String,
packages/contracts/src/previewAutomation.ts
+46
@@ -411,6 +411,52 @@ export const PreviewAutomationScrollInput = Schema.Struct({
411 );
412 export type PreviewAutomationScrollInput = typeof PreviewAutomationScrollInput.Type;
413
414 +/** Strict input for each `preview_act` action. */
415 +export const PreviewAutomationActInputs = {
416 + click: PreviewAutomationClickInput,
417 + type: PreviewAutomationTypeInput,
418 + hover: PreviewAutomationHoverInput,
419 + select: PreviewAutomationSelectInput,
420 + drag: PreviewAutomationDragInput,
421 + upload: PreviewAutomationUploadInput,
422 + press: PreviewAutomationPressInput,
423 + scroll: PreviewAutomationScrollInput,
424 +} as const;
425 +export type PreviewAutomationAction = keyof typeof PreviewAutomationActInputs;
426 +
427 +/** One flat shape for every page action. The server decodes it with the action's strict input. */
428 +export const PreviewAutomationActInput = Schema.Struct({
429 + action: Schema.Literals([
430 + "click",
431 + "type",
432 + "hover",
433 + "select",
434 + "drag",
435 + "upload",
436 + "press",
437 + "scroll",
438 + ]),
439 + ...PreviewAutomationTabTargetFields,
440 + locator: Schema.optional(Locator),
441 + selector: Schema.optional(LegacySelector),
442 + x: Schema.optional(Schema.Finite),
443 + y: Schema.optional(Schema.Finite),
444 + button: Schema.optional(Schema.Literals(["left", "right", "middle"])),
445 + clickCount: Schema.optional(Schema.Int),
446 + text: Schema.optional(Schema.String),
447 + clear: Schema.optional(Schema.Boolean),
448 + values: Schema.optional(Schema.Array(Schema.String)),
449 + source: Schema.optional(Locator),
450 + target: Schema.optional(Locator),
451 + paths: Schema.optional(Schema.Array(Schema.String)),
452 + key: Schema.optional(Schema.String),
453 + modifiers: PreviewAutomationPressInput.fields.modifiers,
454 + deltaX: Schema.optional(Schema.Finite),
455 + deltaY: Schema.optional(Schema.Finite),
456 + timeoutMs: Schema.optional(Schema.Int),
457 +});
458 +export type PreviewAutomationActInput = typeof PreviewAutomationActInput.Type;
459 +
460 export const PreviewAutomationEvaluateInput = Schema.Struct({
461 ...PreviewAutomationTabTargetFields,
462 expression: Schema.String.check(Schema.isTrimmed())
packages/contracts/src/scheduledTask.ts
+2 -2
@@ -66,7 +66,7 @@ export const MAX_WEBHOOK_DELIVERY_AGE_MINUTES = 24 * 60;
66 const WebhookMaxDeliveryAgeMinutes = Schema.Int.check(
67 Schema.isBetween({ minimum: 1, maximum: MAX_WEBHOOK_DELIVERY_AGE_MINUTES }),
68 ).annotate({
69 - description: "Skip requests held offline over this many minutes. Null: run all.",
69 + description: "Skip requests held offline over this many minutes. Omit to run all.",
70 });
71
72 export function isWebhookDedupeTemplate(template: string): boolean {
@@ -152,7 +152,7 @@ const ScheduledTaskUpsertWebhookSchedule = Schema.Struct({
152 }),
153 ),
154 ).annotate({
155 - description: "Null or omitted: URL token only.",
155 + description: "Omit for URL token only.",
156 }),
157 maxDeliveryAgeMinutes: Schema.optional(Schema.NullOr(WebhookMaxDeliveryAgeMinutes)),
158 dedupe: Schema.optional(ScheduledTaskWebhookDedupe),
packages/contracts/src/threadMetadataMcp.test.ts
-27
@@ -19,31 +19,4 @@ describe("ThreadMetadataMcpUpdateInput", () => {
19 decodeUpdate({ action: "regenerate_title", clientRequestId: "metadata-\udc00" }),
20 );
21 });
22 -
23 - it("accepts HTTP(S) pull request URLs and rejects other or malformed URLs", () => {
24 - assert.deepEqual(
25 - decodeUpdate({
26 - action: "link_pull_request",
27 - pullRequest: {
28 - repository: "engineering/t3code",
29 - number: 42,
30 - url: "https://git.corp.example/engineering/t3code/pulls/42",
31 - },
32 - }).pullRequest,
33 - {
34 - repository: "engineering/t3code",
35 - number: 42,
36 - url: "https://git.corp.example/engineering/t3code/pulls/42",
37 - },
38 - );
39 -
40 - for (const url of ["not a URL", "javascript:alert(1)", "file:///tmp/pull-request"]) {
41 - assert.throws(() =>
42 - decodeUpdate({
43 - action: "link_pull_request",
44 - pullRequest: { repository: "pingdotgg/t3code", number: 8690, url },
45 - }),
46 - );
47 - }
48 - });
22 });
packages/contracts/src/threadMetadataMcp.ts
+7 -59
@@ -4,7 +4,6 @@ import {
4 CommandId,
5 IsoDateTime,
6 NonNegativeInt,
7 - PositiveInt,
7 ThreadId,
8 TrimmedNonEmptyString,
9 } from "./baseSchemas.ts";
@@ -27,15 +26,6 @@ function hasOnlyPairedSurrogates(value: string): boolean {
26 return true;
27 }
28
30 -function isHttpUrl(value: string): boolean {
31 - try {
32 - const url = new URL(value);
33 - return url.protocol === "http:" || url.protocol === "https:";
34 - } catch {
35 - return false;
36 - }
37 -}
38 -
29 const ThreadMetadataTitle = TrimmedNonEmptyString.check(Schema.isMaxLength(512)).annotate({
30 description: "New concise display title. Required only when action is rename.",
31 });
@@ -50,62 +40,20 @@ const ThreadMetadataClientRequestId = TrimmedNonEmptyString.check(Schema.isMaxLe
40 )
41 .annotate({ description: "Stable idempotency key to reuse when retrying this mutation." });
42
53 -const ThreadMetadataMcpPullRequestUrl = TrimmedNonEmptyString.check(
54 - Schema.makeFilter((value) =>
55 - isHttpUrl(value) ? true : "Pull request URL must be a well-formed HTTP(S) URL.",
56 - ),
57 -).annotate({
58 - description: "Canonical HTTP(S) pull request URL, including self-hosted repository URLs.",
59 -});
60 -
61 -export const ThreadMetadataMcpAction = Schema.Literals([
62 - "rename",
63 - "regenerate_title",
64 - "link_pull_request",
65 - "unlink_pull_request",
66 -]).annotate({
67 - description:
68 - "Metadata mutation: rename, regenerate_title, link_pull_request, or unlink_pull_request.",
69 -});
43 +export const ThreadMetadataMcpAction = Schema.Literals(["rename", "regenerate_title"]);
44 export type ThreadMetadataMcpAction = typeof ThreadMetadataMcpAction.Type;
45
72 -export const ThreadMetadataMcpPullRequest = Schema.Struct({
73 - repository: TrimmedNonEmptyString.annotate({
74 - description: "Repository name as owner/name.",
75 - }),
76 - number: PositiveInt.annotate({ description: "Pull request number." }),
77 - url: ThreadMetadataMcpPullRequestUrl,
78 -});
79 -export type ThreadMetadataMcpPullRequest = typeof ThreadMetadataMcpPullRequest.Type;
80 -
46 export const ThreadMetadataMcpUpdateInput = Schema.Struct({
82 - threadId: Schema.optional(ThreadId).annotate({
83 - description: "Thread to update. Omit to update the calling thread.",
84 - }),
47 + threadId: Schema.optional(ThreadId),
48 action: ThreadMetadataMcpAction,
49 title: Schema.optional(ThreadMetadataTitle),
87 - pullRequest: Schema.optional(ThreadMetadataMcpPullRequest).annotate({
88 - description: "Pull request to link. Required only when action is link_pull_request.",
89 - }),
50 clientRequestId: Schema.optional(ThreadMetadataClientRequestId),
51 }).check(
92 - Schema.makeFilter((input) => {
93 - switch (input.action) {
94 - case "rename":
95 - return input.title !== undefined && input.pullRequest === undefined
96 - ? true
97 - : "rename requires title and does not accept pullRequest.";
98 - case "link_pull_request":
99 - return input.pullRequest !== undefined && input.title === undefined
100 - ? true
101 - : "link_pull_request requires pullRequest and does not accept title.";
102 - case "regenerate_title":
103 - case "unlink_pull_request":
104 - return input.title === undefined && input.pullRequest === undefined
105 - ? true
106 - : `${input.action} does not accept title or pullRequest.`;
107 - }
108 - }),
52 + Schema.makeFilter((input) =>
53 + (input.action === "rename") === (input.title !== undefined)
54 + ? true
55 + : "rename requires title; regenerate_title does not accept one.",
56 + ),
57 );
58 export type ThreadMetadataMcpUpdateInput = typeof ThreadMetadataMcpUpdateInput.Type;
59
packages/provider-core/src/server/orchestrationInstructions.ts
+3 -3
@@ -6,9 +6,9 @@ export const T3_CODE_ORCHESTRATION_SECTIONS: ReadonlyArray<string> = [
6
7 Ordinary coding tasks need no T3 tools.
8
9 -- Subagents: use your native tool when the child uses your provider, a model it offers, and no settings beyond yours, and you wait in this turn (Claude \`Agent\` always with \`run_in_background:false\`; Codex \`spawn_agent\`, then wait). Use \`delegate_task\` for another provider's model, user-asked settings, a separate checkout (\`isolation:"worktree"\`), background work, or \`delegate_task\` by name. A native type running another provider's model counts too. Workflow only when asked.
10 -- Before \`delegate_task\`, call \`orchestrator_capabilities\` once. Again only after an error or a user-named provider change. Settings go in \`target.options\`. Provider or model unavailable: say so. Never switch unasked, or fall back to native tools, Workflow, or CLIs. Never make a child's checkout in the shell or in \`task\`.
11 -- Every new delegate review or re-check is a new \`delegate_task\` (brief, findings, objections), never a \`t3_thread_send\`. Fix small review findings yourself; start no delegate for them. When told to proceed without a delegate, \`task_cancel\` it. Start no replacement.
9 +- Subagents: use your native tool when the child uses your provider, a model it offers, and no settings beyond yours, and it finishes in this turn (Claude \`Agent\` always with \`run_in_background:false\`; Codex \`spawn_agent\`, then wait). Use \`delegate_task\` for another provider's model, user-asked settings, a separate checkout (\`isolation:"worktree"\`), background work, or \`delegate_task\` by name. A native type running another provider's model counts too. Workflow only when asked.
10 +- Call \`orchestrator_capabilities\` once per thread, before the first \`delegate_task\`. Again only after an error or a user-named provider change. Settings go in \`target.options\`. Provider or model unavailable: say so. Never switch unasked, or fall back to native tools, Workflow, or CLIs. Never make a child's checkout in the shell or in \`task\`.
11 +- Every new delegate review or re-check is a new \`delegate_task\` (brief, findings, objections), never a \`t3_thread_send\`. Fix small review findings yourself; start no delegate for them. When told to proceed without a delegate, or to run fewer, \`task_cancel\` the extras. Start no replacement.
12 - Follow a running delegate's \`next\`. Do not poll it (\`task_status\`, \`sleep\`, watchers, Monitor, ScheduleWakeup). Stop a delegate run you replace or no longer need with \`task_cancel\`, never \`t3_thread_interrupt\` on a \`childThreadId\`.
13 - If you are a subagent or child, do the work yourself. Start no subagents unless your task says to.`,
14 `- \`t3_thread_launch\` and \`create_threads\` make new top-level threads, only when the user asks for a new thread. "Subagent", "delegate", and "parallel" never mean one. Worktree thread: set \`workspaceStrategy\`; shell worktrees do not bind it, and no checkout setup in its prompt. No \`workspaceStrategy\`: project root, not your worktree.
packages/shared/src/t3McpToolPresentation.test.ts
+37 -1
@@ -1,6 +1,11 @@
1 import { describe, expect, it } from "vite-plus/test";
2
3 -import { T3_MCP_TOOL_NAMES, resolveT3McpToolPresentation } from "./t3McpToolPresentation.ts";
3 +import {
4 + T3_MCP_TOOL_NAMES,
5 + resolveT3McpSummaryAction,
6 + resolveT3McpToolDefinition,
7 + resolveT3McpToolPresentation,
8 +} from "./t3McpToolPresentation.ts";
9
10 describe("resolveT3McpToolPresentation", () => {
11 it("recognizes every T3 tool across provider prefixes and completion suffixes", () => {
@@ -32,3 +37,34 @@ describe("resolveT3McpToolPresentation", () => {
37 expect(resolveT3McpToolPresentation("t3-code-thread_opencode2-adapter_not_a_tool")).toBeNull();
38 });
39 });
40 +
41 +describe("resolveT3McpToolDefinition", () => {
42 + it("labels an action tool call as the action it ran", () => {
43 + expect(
44 + resolveT3McpToolDefinition("mcp__t3-code__preview_act", { action: "type" })?.labels,
45 + ).toEqual(resolveT3McpToolDefinition("preview_type")?.labels);
46 + expect(resolveT3McpToolDefinition("t3_thread_transfer", { action: "fork" })?.displayName).toBe(
47 + resolveT3McpToolDefinition("t3_thread_fork")?.displayName,
48 + );
49 + expect(resolveT3McpToolDefinition("preview_act", { action: "unknown" })?.labels[2]).toBe(
50 + "Used",
51 + );
52 + });
53 +});
54 +
55 +describe("resolveT3McpSummaryAction", () => {
56 + it("summarizes an action tool by the action each call ran", () => {
57 + expect(resolveT3McpSummaryAction("mcp__t3-code__t3_queue", { action: "list" })).toBe(
58 + "queue-list",
59 + );
60 + expect(resolveT3McpSummaryAction("t3_queue", { action: "edit" })).toBe("queue-edit");
61 + expect(resolveT3McpSummaryAction("t3_thread_transfer", { action: "status" })).toBe(
62 + "thread-transfers",
63 + );
64 + expect(resolveT3McpSummaryAction("t3_thread_configure", {})).toBe("thread-configuration");
65 + expect(resolveT3McpSummaryAction("schedule_task", { scheduledTaskId: "task-1" })).toBe(
66 + "schedule-update",
67 + );
68 + expect(resolveT3McpSummaryAction("delegate_task", { task: "x" })).toBe("delegate");
69 + });
70 +});
packages/shared/src/t3McpToolPresentation.ts
+55 -3
@@ -190,6 +190,7 @@ const T3_MCP_TOOLS: Readonly<Record<string, T3McpToolDefinition>> = {
190 "browser",
191 "Snapshot the preview page",
192 ),
193 + preview_act: tool(["Use", "Using", "Used", "the preview browser"], "browser", "browser"),
194 preview_click: tool(
195 ["Click", "Clicking", "Clicked", "in the preview browser"],
196 "browser",
@@ -272,6 +273,11 @@ const T3_MCP_TOOLS: Readonly<Record<string, T3McpToolDefinition>> = {
273 ["Run", "Running", "Requested a run of", "a scheduled task"],
274 "schedule-run",
275 ),
276 + t3_queue: tool(["Manage", "Managing", "Managed", "queued messages"], "queue-edit"),
277 + t3_pending_request: tool(
278 + ["Handle", "Handling", "Handled", "pending questions"],
279 + "question-respond",
280 + ),
281 t3_queue_list: tool(["List", "Listing", "Listed", "queued messages"], "queue-list"),
282 t3_queue_read: tool(["Read", "Reading", "Read", "a queued message"], "queue-read"),
283 t3_queue_edit: tool(["Edit", "Editing", "Edited", "a queued message"], "queue-edit"),
@@ -297,7 +303,8 @@ const T3_MCP_TOOLS: Readonly<Record<string, T3McpToolDefinition>> = {
303 ["Read", "Reading", "Read", "thread configuration"],
304 "thread-configuration",
305 ),
300 - t3_thread_configure: tool(["Set", "Setting", "Set", "thread model"], "thread-configure"),
306 + t3_thread_configure: tool(["Use", "Using", "Used", "thread model settings"], "thread-configure"),
307 + t3_thread_transfer: tool(["Use", "Using", "Used", "thread transfers"], "thread-fork"),
308 t3_thread_fork: tool(["Fork", "Forking", "Requested a fork of", "this thread"], "thread-fork"),
309 t3_thread_merge_back: tool(
310 ["Merge", "Merging", "Requested a merge of", "thread context"],
@@ -381,16 +388,61 @@ export function resolveT3McpToolId(toolName: string | null | undefined): string
388 return name !== null && Object.hasOwn(T3_MCP_TOOLS, name) ? name : null;
389 }
390
391 +type SummaryInput = Readonly<Record<string, unknown>>;
392 +
393 +const asSummaryInput = (input: unknown): SummaryInput | undefined =>
394 + typeof input === "object" && input !== null ? (input as SummaryInput) : undefined;
395 +
396 +/** Action tools present each call as the single-purpose tool its action replaced. */
397 +const ACTION_TOOLS: Readonly<Record<string, (action: string) => string | undefined>> = {
398 + preview_act: (action) => `preview_${action}`,
399 + t3_queue: (action) => `t3_queue_${action}`,
400 + t3_pending_request: (action) => `t3_pending_request_${action}`,
401 + t3_thread_transfer: (action) =>
402 + ({ fork: "t3_thread_fork", merge_back: "t3_thread_merge_back", status: "t3_thread_transfers" })[
403 + action
404 + ],
405 +};
406 +
407 +/** Pass the call's input so an action tool resolves to the labels and summary of its action. */
408 export function resolveT3McpToolDefinition(
409 toolName: string | null | undefined,
410 + input?: unknown,
411 ): T3McpToolDefinition | null {
412 const name = toolName == null ? null : resolveT3McpToolName(toolName);
388 - return name !== null && Object.hasOwn(T3_MCP_TOOLS, name) ? T3_MCP_TOOLS[name]! : null;
413 + if (name === null || !Object.hasOwn(T3_MCP_TOOLS, name)) return null;
414 + const action = asSummaryInput(input)?.action;
415 + const actionTool = typeof action === "string" ? ACTION_TOOLS[name]?.(action) : undefined;
416 + return actionTool !== undefined && Object.hasOwn(T3_MCP_TOOLS, actionTool)
417 + ? T3_MCP_TOOLS[actionTool]!
418 + : T3_MCP_TOOLS[name]!;
419 +}
420 +
421 +/** Tools whose summary depends on which fields a call sets. */
422 +const ACTION_SUMMARIES: Readonly<
423 + Record<string, (input: SummaryInput) => T3McpToolSummaryAction | undefined>
424 +> = {
425 + t3_thread_configure: ({ modelSelection }) =>
426 + modelSelection === undefined ? "thread-configuration" : "thread-configure",
427 + schedule_task: ({ scheduledTaskId }) =>
428 + scheduledTaskId === undefined ? "schedule-create" : "schedule-update",
429 +};
430 +
431 +export function resolveT3McpSummaryAction(
432 + toolName: string | null | undefined,
433 + input: unknown,
434 +): T3McpToolSummaryAction | null {
435 + const definition = resolveT3McpToolDefinition(toolName, input);
436 + if (definition === null) return null;
437 + const summarize = ACTION_SUMMARIES[resolveT3McpToolName(toolName!) ?? ""];
438 + const fields = asSummaryInput(input);
439 + return (fields && summarize?.(fields)) ?? definition.summaryAction;
440 }
441
442 export function resolveT3McpToolPresentation(
443 toolName: string | null | undefined,
444 + input?: unknown,
445 ): T3McpToolPresentation | null {
394 - const definition = resolveT3McpToolDefinition(toolName);
446 + const definition = resolveT3McpToolDefinition(toolName, input);
447 return definition === null ? null : { displayName: definition.displayName, logo: "t3-code" };
448 }