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