Open History to see the last commit
1import {
2 NonNegativeInt,
3 OrchestratorMcpFailure,
4 PreviewAutomationUnavailableError,
5 PreviewListResult,
6 PreviewTabId,
7} from "@t3tools/contracts";
8import * as Schema from "effect/Schema";
9import { Tool, Toolkit } from "effect/unstable/ai";
10import * as PreviewManager from "../../../preview/Manager.ts";
11import * as McpInvocationContext from "../../McpInvocationContext.ts";
12
13const shared = {
14 failure: Schema.Union([OrchestratorMcpFailure, PreviewAutomationUnavailableError]),
15 failureMode: "return" as const,
16 dependencies: [McpInvocationContext.McpInvocationContext, PreviewManager.PreviewManager],
17};
18const PreviewListTool = Tool.make("t3_preview_list", {
19 ...shared,
20 description:
21 "List this thread's preview tabs. Pages reflect the current server state and may shift as tabs change.",
22 parameters: Schema.Struct({
23 cursor: Schema.optional(NonNegativeInt),
24 limit: Schema.optional(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 50 }))),
25 }),
26 success: Schema.Struct({
27 ...PreviewListResult.fields,
28 nextCursor: Schema.NullOr(NonNegativeInt),
29 }),
30})
31 .annotate(Tool.Readonly, true)
32 .annotate(Tool.Destructive, false);
33const PreviewCloseTool = Tool.make("t3_preview_close", {
34 ...shared,
35 description:
36 "Close one preview tab owned by this thread through the normal server/host tab lifecycle. This does not wait for renderer cleanup.",
37 parameters: Schema.Struct({ tabId: PreviewTabId }),
38 success: Schema.Struct({}),
39}).annotate(Tool.Destructive, true);
40export const PreviewControlsToolkit = Toolkit.make(PreviewListTool, PreviewCloseTool);