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
200200export const PreviewSnapshotToolkitHandlersLive = PreviewSnapshotToolkit.toLayer({
201201 preview_snapshot,
202202});
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 =>
4747const readonlyBrowserTool = <T extends Tool.Any>(tool: T): T =>
4848 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", {
5151 description:
5252 "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.",
5353 parameters: PreviewAutomationTabTargetInput,
......@@ -60,7 +60,7 @@ export const PreviewStatusTool = Tool.make("preview_status", {
6060 .annotate(Tool.Destructive, false)
6161 .annotate(Tool.Idempotent, true);
6262
63export const PreviewOpenTool = browserTool(
63const PreviewOpenTool = browserTool(
6464 Tool.make("preview_open", {
6565 description:
6666 "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(
7373 .annotate(Tool.Destructive, false),
7474);
7575
76export const PreviewNavigateTool = safeBrowserTool(
76const PreviewNavigateTool = safeBrowserTool(
7777 Tool.make("preview_navigate", {
7878 description:
7979 "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(
8484 }).annotate(Tool.Title, "Navigate browser preview"),
8585);
8686
87export const PreviewResizeTool = safeBrowserTool(
87const PreviewResizeTool = safeBrowserTool(
8888 Tool.make("preview_resize", {
8989 description:
9090 "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(
9797 .annotate(Tool.Idempotent, true),
9898);
9999
100export const PreviewSetAppearanceTool = safeBrowserTool(
100const PreviewSetAppearanceTool = safeBrowserTool(
101101 Tool.make("preview_set_appearance", {
102102 description:
103103 "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(
129129 }).annotate(Tool.Title, "Inspect browser page"),
130130);
131131
132export const PreviewClickTool = browserTool(
132const PreviewClickTool = browserTool(
133133 Tool.make("preview_click", {
134134 description:
135135 "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(
140140 }).annotate(Tool.Title, "Click preview page"),
141141);
142142
143export const PreviewTypeTool = browserTool(
143const PreviewTypeTool = browserTool(
144144 Tool.make("preview_type", {
145145 description:
146146 "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(
151151 }).annotate(Tool.Title, "Type into preview page"),
152152);
153153
154export const PreviewPressTool = browserTool(
154const PreviewPressTool = browserTool(
155155 Tool.make("preview_press", {
156156 description:
157157 "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(
162162 }).annotate(Tool.Title, "Press key in preview page"),
163163);
164164
165export const PreviewScrollTool = safeBrowserTool(
165const PreviewScrollTool = safeBrowserTool(
166166 Tool.make("preview_scroll", {
167167 description:
168168 "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(
173173 }).annotate(Tool.Title, "Scroll preview page"),
174174);
175175
176export const PreviewEvaluateTool = browserTool(
176const PreviewEvaluateTool = browserTool(
177177 Tool.make("preview_evaluate", {
178178 description:
179179 "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(
184184 }).annotate(Tool.Title, "Evaluate JavaScript in preview"),
185185);
186186
187export const PreviewWaitForTool = readonlyBrowserTool(
187const PreviewWaitForTool = readonlyBrowserTool(
188188 Tool.make("preview_wait_for", {
189189 description:
190190 "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(
195195 }).annotate(Tool.Title, "Wait for preview page condition"),
196196);
197197
198export const PreviewRecordingStartTool = safeBrowserTool(
198const PreviewRecordingStartTool = safeBrowserTool(
199199 Tool.make("preview_recording_start", {
200200 description:
201201 "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(
206206 }).annotate(Tool.Title, "Start browser recording"),
207207);
208208
209export const PreviewRecordingStopTool = safeBrowserTool(
209const PreviewRecordingStopTool = safeBrowserTool(
210210 Tool.make("preview_recording_stop", {
211211 description:
212212 "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.",