authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-08 01:17:24-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-08 01:17:24-07:00
log1f0a14cf7f1bb1b6167fca475e9b7183bc8ec8af
tree75efce567c8b6259059226ffee83719de6c2f12c
parent7cdeb696e699309b827c1d1b613397f9bcd73b3d
signature Signed by PGP key B5690EEEBB952194

refactor(server): classify preview toolkit exports (#10281)


2 files changed, 13 insertions(+), 15 deletions(-)

apps/server/src/mcp/toolkits/preview/handlers.ts-2
...@@ -200,5 +200,3 @@ export const PreviewStandardToolkitHandlersLive = PreviewStandardToolkit.toLayer...@@ -200,5 +200,3 @@ export const PreviewStandardToolkitHandlersLive = PreviewStandardToolkit.toLayer
200export const PreviewSnapshotToolkitHandlersLive = PreviewSnapshotToolkit.toLayer({200export const PreviewSnapshotToolkitHandlersLive = PreviewSnapshotToolkit.toLayer({
201 preview_snapshot,201 preview_snapshot,
202});202});
203
204export const PreviewToolkitHandlersLive = PreviewToolkit.toLayer(handlers);
apps/server/src/mcp/toolkits/preview/tools.ts+13-13
...@@ -47,7 +47,7 @@ const safeBrowserTool = <T extends Tool.Any>(tool: T): T =>...@@ -47,7 +47,7 @@ const safeBrowserTool = <T extends Tool.Any>(tool: T): T =>
47const readonlyBrowserTool = <T extends Tool.Any>(tool: T): T =>47const readonlyBrowserTool = <T extends Tool.Any>(tool: T): T =>
48 safeBrowserTool(tool).annotate(Tool.Readonly, true).annotate(Tool.Idempotent, true) as T;48 safeBrowserTool(tool).annotate(Tool.Readonly, true).annotate(Tool.Idempotent, true) as T;
4949
50export const PreviewStatusTool = Tool.make("preview_status", {50const PreviewStatusTool = Tool.make("preview_status", {
51 description:51 description:
52 "Report whether a collaborative browser tab is automation-capable, including its URL, title, visibility, loading state, viewport mode, and measured CSS-pixel size. Pass tabId to inspect a specific tab; omit it to use this agent session's current tab.",52 "Report whether a collaborative browser tab is automation-capable, including its URL, title, visibility, loading state, viewport mode, and measured CSS-pixel size. Pass tabId to inspect a specific tab; omit it to use this agent session's current tab.",
53 parameters: PreviewAutomationTabTargetInput,53 parameters: PreviewAutomationTabTargetInput,
...@@ -60,7 +60,7 @@ export const PreviewStatusTool = Tool.make("preview_status", {...@@ -60,7 +60,7 @@ export const PreviewStatusTool = Tool.make("preview_status", {
60 .annotate(Tool.Destructive, false)60 .annotate(Tool.Destructive, false)
61 .annotate(Tool.Idempotent, true);61 .annotate(Tool.Idempotent, true);
6262
63export const PreviewOpenTool = browserTool(63const PreviewOpenTool = browserTool(
64 Tool.make("preview_open", {64 Tool.make("preview_open", {
65 description:65 description:
66 "Initialize a collaborative browser tab and open its thread-bound inline preview by default. Set open=false for background-only automation. Pass tabId to reuse a specific existing tab, set reuseExistingTab=false to create another tab, or omit both to use this agent session's current tab.",66 "Initialize a collaborative browser tab and open its thread-bound inline preview by default. Set open=false for background-only automation. Pass tabId to reuse a specific existing tab, set reuseExistingTab=false to create another tab, or omit both to use this agent session's current tab.",
...@@ -73,7 +73,7 @@ export const PreviewOpenTool = browserTool(...@@ -73,7 +73,7 @@ export const PreviewOpenTool = browserTool(
73 .annotate(Tool.Destructive, false),73 .annotate(Tool.Destructive, false),
74);74);
7575
76export const PreviewNavigateTool = safeBrowserTool(76const PreviewNavigateTool = safeBrowserTool(
77 Tool.make("preview_navigate", {77 Tool.make("preview_navigate", {
78 description:78 description:
79 "Navigate a collaborative browser tab. Pass tabId to target a specific tab, plus {url:'https://t3.chat'} for a website or {target:{kind:'environment-port',port:5173}} for a dev server. Exactly one of url or target is required.",79 "Navigate a collaborative browser tab. Pass tabId to target a specific tab, plus {url:'https://t3.chat'} for a website or {target:{kind:'environment-port',port:5173}} for a dev server. Exactly one of url or target is required.",
...@@ -84,7 +84,7 @@ export const PreviewNavigateTool = safeBrowserTool(...@@ -84,7 +84,7 @@ export const PreviewNavigateTool = safeBrowserTool(
84 }).annotate(Tool.Title, "Navigate browser preview"),84 }).annotate(Tool.Title, "Navigate browser preview"),
85);85);
8686
87export const PreviewResizeTool = safeBrowserTool(87const PreviewResizeTool = safeBrowserTool(
88 Tool.make("preview_resize", {88 Tool.make("preview_resize", {
89 description:89 description:
90 "Resize a collaborative browser tab, optionally selected by tabId. Use {mode:'fill'}, {mode:'freeform',width:1024,height:768}, or {mode:'preset',preset:'iphone-12-pro',orientation:'portrait'}. This changes CSS layout breakpoints without changing the desktop browser user agent.",90 "Resize a collaborative browser tab, optionally selected by tabId. Use {mode:'fill'}, {mode:'freeform',width:1024,height:768}, or {mode:'preset',preset:'iphone-12-pro',orientation:'portrait'}. This changes CSS layout breakpoints without changing the desktop browser user agent.",
...@@ -97,7 +97,7 @@ export const PreviewResizeTool = safeBrowserTool(...@@ -97,7 +97,7 @@ export const PreviewResizeTool = safeBrowserTool(
97 .annotate(Tool.Idempotent, true),97 .annotate(Tool.Idempotent, true),
98);98);
9999
100export const PreviewSetAppearanceTool = safeBrowserTool(100const PreviewSetAppearanceTool = safeBrowserTool(
101 Tool.make("preview_set_appearance", {101 Tool.make("preview_set_appearance", {
102 description:102 description:
103 "Emulate prefers-color-scheme in a collaborative browser tab, optionally selected by tabId. Use {colorScheme:'dark'} or {colorScheme:'light'} to preview the page in that appearance, and {colorScheme:'system'} to clear the override and follow the OS appearance.",103 "Emulate prefers-color-scheme in a collaborative browser tab, optionally selected by tabId. Use {colorScheme:'dark'} or {colorScheme:'light'} to preview the page in that appearance, and {colorScheme:'system'} to clear the override and follow the OS appearance.",
...@@ -129,7 +129,7 @@ export const PreviewSnapshotTool = readonlyBrowserTool(...@@ -129,7 +129,7 @@ export const PreviewSnapshotTool = readonlyBrowserTool(
129 }).annotate(Tool.Title, "Inspect browser page"),129 }).annotate(Tool.Title, "Inspect browser page"),
130);130);
131131
132export const PreviewClickTool = browserTool(132const PreviewClickTool = browserTool(
133 Tool.make("preview_click", {133 Tool.make("preview_click", {
134 description:134 description:
135 "Click exactly one target in the tab selected by tabId, or this agent session's current tab when omitted. Prefer a Playwright locator; selector accepts legacy CSS; x and y must be supplied together.",135 "Click exactly one target in the tab selected by tabId, or this agent session's current tab when omitted. Prefer a Playwright locator; selector accepts legacy CSS; x and y must be supplied together.",
...@@ -140,7 +140,7 @@ export const PreviewClickTool = browserTool(...@@ -140,7 +140,7 @@ export const PreviewClickTool = browserTool(
140 }).annotate(Tool.Title, "Click preview page"),140 }).annotate(Tool.Title, "Click preview page"),
141);141);
142142
143export const PreviewTypeTool = browserTool(143const PreviewTypeTool = browserTool(
144 Tool.make("preview_type", {144 Tool.make("preview_type", {
145 description:145 description:
146 "Insert literal text into one input in the tab selected by tabId, or this agent session's current tab when omitted. Prefer a Playwright locator; set clear=true to replace existing text.",146 "Insert literal text into one input in the tab selected by tabId, or this agent session's current tab when omitted. Prefer a Playwright locator; set clear=true to replace existing text.",
...@@ -151,7 +151,7 @@ export const PreviewTypeTool = browserTool(...@@ -151,7 +151,7 @@ export const PreviewTypeTool = browserTool(
151 }).annotate(Tool.Title, "Type into preview page"),151 }).annotate(Tool.Title, "Type into preview page"),
152);152);
153153
154export const PreviewPressTool = browserTool(154const PreviewPressTool = browserTool(
155 Tool.make("preview_press", {155 Tool.make("preview_press", {
156 description:156 description:
157 "Press one keyboard key in the tab selected by tabId, or this agent session's current tab when omitted. Examples: {key:'Enter'}, {key:'Escape'}, or {key:'a',modifiers:['Meta']}.",157 "Press one keyboard key in the tab selected by tabId, or this agent session's current tab when omitted. Examples: {key:'Enter'}, {key:'Escape'}, or {key:'a',modifiers:['Meta']}.",
...@@ -162,7 +162,7 @@ export const PreviewPressTool = browserTool(...@@ -162,7 +162,7 @@ export const PreviewPressTool = browserTool(
162 }).annotate(Tool.Title, "Press key in preview page"),162 }).annotate(Tool.Title, "Press key in preview page"),
163);163);
164164
165export const PreviewScrollTool = safeBrowserTool(165const PreviewScrollTool = safeBrowserTool(
166 Tool.make("preview_scroll", {166 Tool.make("preview_scroll", {
167 description:167 description:
168 "Scroll the tab selected by tabId, or this agent session's current tab when omitted. Positive deltaY scrolls down and positive deltaX scrolls right; a locator/selector targets a container.",168 "Scroll the tab selected by tabId, or this agent session's current tab when omitted. Positive deltaY scrolls down and positive deltaX scrolls right; a locator/selector targets a container.",
...@@ -173,7 +173,7 @@ export const PreviewScrollTool = safeBrowserTool(...@@ -173,7 +173,7 @@ export const PreviewScrollTool = safeBrowserTool(
173 }).annotate(Tool.Title, "Scroll preview page"),173 }).annotate(Tool.Title, "Scroll preview page"),
174);174);
175175
176export const PreviewEvaluateTool = browserTool(176const PreviewEvaluateTool = browserTool(
177 Tool.make("preview_evaluate", {177 Tool.make("preview_evaluate", {
178 description:178 description:
179 "Evaluate JavaScript in the tab selected by tabId, or this agent session's current tab when omitted. Returns a serializable result up to 64 KB; the expression may mutate page state.",179 "Evaluate JavaScript in the tab selected by tabId, or this agent session's current tab when omitted. Returns a serializable result up to 64 KB; the expression may mutate page state.",
...@@ -184,7 +184,7 @@ export const PreviewEvaluateTool = browserTool(...@@ -184,7 +184,7 @@ export const PreviewEvaluateTool = browserTool(
184 }).annotate(Tool.Title, "Evaluate JavaScript in preview"),184 }).annotate(Tool.Title, "Evaluate JavaScript in preview"),
185);185);
186186
187export const PreviewWaitForTool = readonlyBrowserTool(187const PreviewWaitForTool = readonlyBrowserTool(
188 Tool.make("preview_wait_for", {188 Tool.make("preview_wait_for", {
189 description:189 description:
190 "Wait in the tab selected by tabId, or this agent session's current tab when omitted, until all supplied locator, selector, text, and URL conditions match.",190 "Wait in the tab selected by tabId, or this agent session's current tab when omitted, until all supplied locator, selector, text, and URL conditions match.",
...@@ -195,7 +195,7 @@ export const PreviewWaitForTool = readonlyBrowserTool(...@@ -195,7 +195,7 @@ export const PreviewWaitForTool = readonlyBrowserTool(
195 }).annotate(Tool.Title, "Wait for preview page condition"),195 }).annotate(Tool.Title, "Wait for preview page condition"),
196);196);
197197
198export const PreviewRecordingStartTool = safeBrowserTool(198const PreviewRecordingStartTool = safeBrowserTool(
199 Tool.make("preview_recording_start", {199 Tool.make("preview_recording_start", {
200 description:200 description:
201 "Start recording the collaborative browser tab selected by tabId, or this agent session's current tab when omitted.",201 "Start recording the collaborative browser tab selected by tabId, or this agent session's current tab when omitted.",
...@@ -206,7 +206,7 @@ export const PreviewRecordingStartTool = safeBrowserTool(...@@ -206,7 +206,7 @@ export const PreviewRecordingStartTool = safeBrowserTool(
206 }).annotate(Tool.Title, "Start browser recording"),206 }).annotate(Tool.Title, "Start browser recording"),
207);207);
208208
209export const PreviewRecordingStopTool = safeBrowserTool(209const PreviewRecordingStopTool = safeBrowserTool(
210 Tool.make("preview_recording_stop", {210 Tool.make("preview_recording_stop", {
211 description:211 description:
212 "Stop recording the collaborative browser tab selected by tabId, or this agent session's current tab when omitted, and transfer the compressed recording once (up to 50 MiB) to an evidence file readable in this agent's environment. Returns its environment-local path after transfer succeeds.",212 "Stop recording the collaborative browser tab selected by tabId, or this agent session's current tab when omitted, and transfer the compressed recording once (up to 50 MiB) to an evidence file readable in this agent's environment. Returns its environment-local path after transfer succeeds.",