framewatch-mcp-server 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +98 -7
  2. package/dist/constants.d.ts +10 -0
  3. package/dist/constants.js +11 -0
  4. package/dist/constants.js.map +1 -1
  5. package/dist/engine/browser.d.ts +20 -4
  6. package/dist/engine/browser.js +22 -9
  7. package/dist/engine/browser.js.map +1 -1
  8. package/dist/engine/interaction.d.ts +6 -6
  9. package/dist/engine/interaction.js +89 -12
  10. package/dist/engine/interaction.js.map +1 -1
  11. package/dist/index.js +4 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/tools/accessibility.d.ts +4 -0
  14. package/dist/tools/accessibility.js +7 -1
  15. package/dist/tools/accessibility.js.map +1 -1
  16. package/dist/tools/capture.d.ts +21 -17
  17. package/dist/tools/capture.js +7 -1
  18. package/dist/tools/capture.js.map +1 -1
  19. package/dist/tools/compare.d.ts +4 -0
  20. package/dist/tools/compare.js +14 -4
  21. package/dist/tools/compare.js.map +1 -1
  22. package/dist/tools/index.d.ts +1 -0
  23. package/dist/tools/index.js +3 -0
  24. package/dist/tools/index.js.map +1 -1
  25. package/dist/tools/interact.d.ts +12 -6
  26. package/dist/tools/interact.js +21 -7
  27. package/dist/tools/interact.js.map +1 -1
  28. package/dist/tools/responsive.d.ts +4 -0
  29. package/dist/tools/responsive.js +20 -3
  30. package/dist/tools/responsive.js.map +1 -1
  31. package/dist/tools/save-auth.d.ts +263 -0
  32. package/dist/tools/save-auth.js +253 -0
  33. package/dist/tools/save-auth.js.map +1 -0
  34. package/dist/tools/screenshot.d.ts +4 -0
  35. package/dist/tools/screenshot.js +4 -1
  36. package/dist/tools/screenshot.js.map +1 -1
  37. package/dist/utils/storage-state.d.ts +35 -0
  38. package/dist/utils/storage-state.js +84 -0
  39. package/dist/utils/storage-state.js.map +1 -0
  40. package/package.json +1 -1
@@ -21,9 +21,9 @@ export declare const captureInteractionSchema: z.ZodEffects<z.ZodObject<{
21
21
  y: z.ZodOptional<z.ZodNumber>;
22
22
  delta_x: z.ZodOptional<z.ZodNumber>;
23
23
  delta_y: z.ZodOptional<z.ZodNumber>;
24
- action: z.ZodEnum<["click", "tap", "type", "scroll", "swipe", "wait", "navigate"]>;
24
+ action: z.ZodEnum<["click", "tap", "type", "key", "scroll", "swipe", "hover", "select", "wait", "navigate"]>;
25
25
  }, "strip", z.ZodTypeAny, {
26
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
26
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
27
27
  delay_ms: number;
28
28
  value?: string | undefined;
29
29
  x?: number | undefined;
@@ -32,7 +32,7 @@ export declare const captureInteractionSchema: z.ZodEffects<z.ZodObject<{
32
32
  delta_x?: number | undefined;
33
33
  delta_y?: number | undefined;
34
34
  }, {
35
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
35
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
36
36
  value?: string | undefined;
37
37
  x?: number | undefined;
38
38
  y?: number | undefined;
@@ -41,7 +41,7 @@ export declare const captureInteractionSchema: z.ZodEffects<z.ZodObject<{
41
41
  delta_y?: number | undefined;
42
42
  delay_ms?: number | undefined;
43
43
  }>, {
44
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
44
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
45
45
  delay_ms: number;
46
46
  value?: string | undefined;
47
47
  x?: number | undefined;
@@ -50,7 +50,7 @@ export declare const captureInteractionSchema: z.ZodEffects<z.ZodObject<{
50
50
  delta_x?: number | undefined;
51
51
  delta_y?: number | undefined;
52
52
  }, {
53
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
53
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
54
54
  value?: string | undefined;
55
55
  x?: number | undefined;
56
56
  y?: number | undefined;
@@ -85,9 +85,9 @@ export declare const captureInputShape: {
85
85
  y: z.ZodOptional<z.ZodNumber>;
86
86
  delta_x: z.ZodOptional<z.ZodNumber>;
87
87
  delta_y: z.ZodOptional<z.ZodNumber>;
88
- action: z.ZodEnum<["click", "tap", "type", "scroll", "swipe", "wait", "navigate"]>;
88
+ action: z.ZodEnum<["click", "tap", "type", "key", "scroll", "swipe", "hover", "select", "wait", "navigate"]>;
89
89
  }, "strip", z.ZodTypeAny, {
90
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
90
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
91
91
  delay_ms: number;
92
92
  value?: string | undefined;
93
93
  x?: number | undefined;
@@ -96,7 +96,7 @@ export declare const captureInputShape: {
96
96
  delta_x?: number | undefined;
97
97
  delta_y?: number | undefined;
98
98
  }, {
99
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
99
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
100
100
  value?: string | undefined;
101
101
  x?: number | undefined;
102
102
  y?: number | undefined;
@@ -105,7 +105,7 @@ export declare const captureInputShape: {
105
105
  delta_y?: number | undefined;
106
106
  delay_ms?: number | undefined;
107
107
  }>, {
108
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
108
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
109
109
  delay_ms: number;
110
110
  value?: string | undefined;
111
111
  x?: number | undefined;
@@ -114,7 +114,7 @@ export declare const captureInputShape: {
114
114
  delta_x?: number | undefined;
115
115
  delta_y?: number | undefined;
116
116
  }, {
117
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
117
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
118
118
  value?: string | undefined;
119
119
  x?: number | undefined;
120
120
  y?: number | undefined;
@@ -128,6 +128,7 @@ export declare const captureInputShape: {
128
128
  include_network: z.ZodDefault<z.ZodBoolean>;
129
129
  include_dom: z.ZodDefault<z.ZodBoolean>;
130
130
  include_performance: z.ZodDefault<z.ZodBoolean>;
131
+ storage_state: z.ZodOptional<z.ZodString>;
131
132
  };
132
133
  export declare const captureInputSchema: z.ZodObject<{
133
134
  url: z.ZodString;
@@ -155,9 +156,9 @@ export declare const captureInputSchema: z.ZodObject<{
155
156
  y: z.ZodOptional<z.ZodNumber>;
156
157
  delta_x: z.ZodOptional<z.ZodNumber>;
157
158
  delta_y: z.ZodOptional<z.ZodNumber>;
158
- action: z.ZodEnum<["click", "tap", "type", "scroll", "swipe", "wait", "navigate"]>;
159
+ action: z.ZodEnum<["click", "tap", "type", "key", "scroll", "swipe", "hover", "select", "wait", "navigate"]>;
159
160
  }, "strip", z.ZodTypeAny, {
160
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
161
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
161
162
  delay_ms: number;
162
163
  value?: string | undefined;
163
164
  x?: number | undefined;
@@ -166,7 +167,7 @@ export declare const captureInputSchema: z.ZodObject<{
166
167
  delta_x?: number | undefined;
167
168
  delta_y?: number | undefined;
168
169
  }, {
169
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
170
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
170
171
  value?: string | undefined;
171
172
  x?: number | undefined;
172
173
  y?: number | undefined;
@@ -175,7 +176,7 @@ export declare const captureInputSchema: z.ZodObject<{
175
176
  delta_y?: number | undefined;
176
177
  delay_ms?: number | undefined;
177
178
  }>, {
178
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
179
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
179
180
  delay_ms: number;
180
181
  value?: string | undefined;
181
182
  x?: number | undefined;
@@ -184,7 +185,7 @@ export declare const captureInputSchema: z.ZodObject<{
184
185
  delta_x?: number | undefined;
185
186
  delta_y?: number | undefined;
186
187
  }, {
187
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
188
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
188
189
  value?: string | undefined;
189
190
  x?: number | undefined;
190
191
  y?: number | undefined;
@@ -198,6 +199,7 @@ export declare const captureInputSchema: z.ZodObject<{
198
199
  include_network: z.ZodDefault<z.ZodBoolean>;
199
200
  include_dom: z.ZodDefault<z.ZodBoolean>;
200
201
  include_performance: z.ZodDefault<z.ZodBoolean>;
202
+ storage_state: z.ZodOptional<z.ZodString>;
201
203
  }, "strip", z.ZodTypeAny, {
202
204
  url: string;
203
205
  wait_for_timeout_ms: number;
@@ -215,8 +217,9 @@ export declare const captureInputSchema: z.ZodObject<{
215
217
  height: number;
216
218
  } | undefined;
217
219
  wait_for?: string | undefined;
220
+ storage_state?: string | undefined;
218
221
  interactions?: {
219
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
222
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
220
223
  delay_ms: number;
221
224
  value?: string | undefined;
222
225
  x?: number | undefined;
@@ -233,12 +236,13 @@ export declare const captureInputSchema: z.ZodObject<{
233
236
  } | undefined;
234
237
  wait_for?: string | undefined;
235
238
  wait_for_timeout_ms?: number | undefined;
239
+ storage_state?: string | undefined;
236
240
  duration_ms?: number | undefined;
237
241
  sensitivity?: number | undefined;
238
242
  max_frames?: number | undefined;
239
243
  interval_ms?: number | undefined;
240
244
  interactions?: {
241
- action: "type" | "click" | "tap" | "scroll" | "swipe" | "wait" | "navigate";
245
+ action: "type" | "click" | "tap" | "key" | "scroll" | "swipe" | "hover" | "select" | "wait" | "navigate";
242
246
  value?: string | undefined;
243
247
  x?: number | undefined;
244
248
  y?: number | undefined;
@@ -6,6 +6,7 @@ import { applyContext, attachLayers, summariseContext } from "../engine/layers/i
6
6
  import { CAPTURE_ACTIONS, describeInteraction, executeInteraction, interactionFieldShape, needsTouch, refineInteraction, } from "../engine/interaction.js";
7
7
  import { recordFrames } from "../engine/recorder.js";
8
8
  import { formatDiffCards } from "../utils/format.js";
9
+ import { readStorageState, storageStateField } from "../utils/storage-state.js";
9
10
  export const CAPTURE_TOOL_NAME = "framewatch_capture";
10
11
  /**
11
12
  * Re-exported where it is used: the capture summary's context lines. It lives
@@ -19,7 +20,9 @@ export { summariseContext };
19
20
  */
20
21
  export const captureInteractionSchema = z
21
22
  .object({
22
- action: z.enum(CAPTURE_ACTIONS).describe("What to do: click, tap, type, scroll, swipe, wait or navigate"),
23
+ action: z
24
+ .enum(CAPTURE_ACTIONS)
25
+ .describe("What to do: click, tap, type, key, scroll, swipe, hover, select, wait or navigate"),
23
26
  ...interactionFieldShape,
24
27
  delay_ms: z.number().int().min(0).default(0).describe("Wait this long (ms) before performing this action"),
25
28
  })
@@ -94,6 +97,7 @@ export const captureInputShape = {
94
97
  .boolean()
95
98
  .default(false)
96
99
  .describe("Attach paint timing, largest contentful paint and layout shifts to the frames they were measured at"),
100
+ storage_state: storageStateField,
97
101
  };
98
102
  export const captureInputSchema = z.object(captureInputShape);
99
103
  /**
@@ -125,6 +129,8 @@ export async function capturePage(rawInput) {
125
129
  const contextOptions = needsTouch(interactions) ? { hasTouch: true } : {};
126
130
  const report = interactions.length > 0 ? { total: interactions.length, completed: 0, steps: [] } : undefined;
127
131
  try {
132
+ if (input.storage_state)
133
+ contextOptions.storageState = await readStorageState(input.storage_state);
128
134
  const recording = await withPage({ viewport, contextOptions }, async (page) => {
129
135
  // Layers go on before the navigation: a script that throws while the page
130
136
  // loads, the request that never comes back and first paint all happen
@@ -1 +1 @@
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AAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE;KACxG,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAClC,CAAC;AACJ,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { Page } from \"playwright\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n CAPTURE_INTERVAL_MS,\n DEFAULT_CAPTURE_DURATION_MS,\n DEFAULT_MAX_FRAMES,\n DEFAULT_SENSITIVITY,\n DEFAULT_VIEWPORT,\n MAX_CAPTURE_DURATION_MS,\n MAX_VIEWPORT_HEIGHT,\n MAX_VIEWPORT_WIDTH,\n MAX_FRAMES_CAP,\n MAX_INTERACTIONS,\n MIN_CAPTURE_DURATION_MS,\n NAVIGATION_TIMEOUT_MS,\n PAGE_INFO_TIMEOUT_MS,\n SELECTOR_TIMEOUT_MS,\n} from \"../constants.js\";\nimport { withPage } from \"../engine/browser.js\";\nimport { buildDiffCards } from \"../engine/differ.js\";\nimport { applyContext, attachLayers, summariseContext } from \"../engine/layers/index.js\";\nimport {\n CAPTURE_ACTIONS,\n describeInteraction,\n executeInteraction,\n interactionFieldShape,\n needsTouch,\n refineInteraction,\n type Interaction,\n} from \"../engine/interaction.js\";\nimport { recordFrames, type FrameRecorder } from \"../engine/recorder.js\";\nimport { formatDiffCards, type InteractionReport } from \"../utils/format.js\";\n\nexport const CAPTURE_TOOL_NAME = \"framewatch_capture\";\n\n/**\n * Re-exported where it is used: the capture summary's context lines. It lives\n * with the layers themselves now that `framewatch_interact` reports them too.\n */\nexport { summariseContext };\n\n/**\n * One step of a replayable interaction script. `delay_ms` is a wait *before*\n * the action, so a `wait` step is just a delay with nothing after it, and the\n * delays of successive steps accumulate over the recording.\n */\nexport const captureInteractionSchema = z\n .object({\n action: z.enum(CAPTURE_ACTIONS).describe(\"What to do: click, tap, type, scroll, swipe, wait or navigate\"),\n ...interactionFieldShape,\n delay_ms: z.number().int().min(0).default(0).describe(\"Wait this long (ms) before performing this action\"),\n })\n .superRefine(refineInteraction);\n\nexport const captureInputShape = {\n url: z.string().url().describe(\"URL to capture, e.g. http://localhost:3000 (http, https and file URLs are accepted)\"),\n duration_ms: z\n .number()\n .int()\n .min(MIN_CAPTURE_DURATION_MS)\n .max(MAX_CAPTURE_DURATION_MS)\n .default(DEFAULT_CAPTURE_DURATION_MS)\n .describe(\"How long to record (ms)\"),\n sensitivity: z\n .number()\n .min(0)\n .max(1)\n .default(DEFAULT_SENSITIVITY)\n .describe(\"Frame change threshold (0 = keep all, 1 = keep none). 0.06 means ~6% of grid cells must change.\"),\n max_frames: z\n .number()\n .int()\n .min(1)\n .max(MAX_FRAMES_CAP)\n .default(DEFAULT_MAX_FRAMES)\n .describe(\"Maximum diff cards to return\"),\n interval_ms: z\n .number()\n .int()\n .min(16)\n .max(2000)\n .default(CAPTURE_INTERVAL_MS)\n .describe(\"Raw frame capture interval (ms) — 100 = 10fps\"),\n viewport: z\n .object({\n width: z.number().int().min(1).max(MAX_VIEWPORT_WIDTH).default(DEFAULT_VIEWPORT.width),\n height: z.number().int().min(1).max(MAX_VIEWPORT_HEIGHT).default(DEFAULT_VIEWPORT.height),\n })\n .optional()\n .describe(\"Viewport size (defaults to 1280x720)\"),\n wait_for: z.string().optional().describe(\"CSS selector to wait for (visible) before recording starts\"),\n wait_for_timeout_ms: z\n .number()\n .int()\n .min(1)\n .default(SELECTOR_TIMEOUT_MS)\n .describe(\"Max time (ms) to wait for `wait_for` to appear (must be > 0)\"),\n interactions: z\n .array(captureInteractionSchema)\n .max(MAX_INTERACTIONS)\n .optional()\n .describe(\"Sequence of user interactions to replay during the recording\"),\n interaction_timeout_ms: z\n .number()\n .int()\n .min(1)\n .default(SELECTOR_TIMEOUT_MS)\n .describe(\"Max time (ms) an interaction step may spend waiting for its target element\"),\n include_console: z\n .boolean()\n .default(true)\n .describe(\"Attach console logs, uncaught errors and unhandled rejections to the frames they happened between\"),\n include_network: z\n .boolean()\n .default(false)\n .describe(\"Attach network requests (method, url, status, duration) to the frames they settled between\"),\n include_dom: z\n .boolean()\n .default(false)\n .describe(\"Attach a summary of the DOM mutations between frames — which elements were added, removed or restyled\"),\n include_performance: z\n .boolean()\n .default(false)\n .describe(\"Attach paint timing, largest contentful paint and layout shifts to the frames they were measured at\"),\n};\n\nexport const captureInputSchema = z.object(captureInputShape);\nexport type CaptureInput = z.input<typeof captureInputSchema>;\ntype ParsedCaptureInput = z.output<typeof captureInputSchema>;\n\n/**\n * The main FrameWatch tool: record a page for `duration_ms` and return only\n * the meaningful visual changes as diff cards (see CLAUDE.md \"Diff Cards\" and\n * \"MCP Response Format\").\n *\n * Flow: navigate (waiting only for the navigation to commit, so loading and\n * splash animations are recorded from their first frame) → optionally wait\n * for `wait_for` → record raw frames every `interval_ms`, replaying\n * `interactions` as the recording runs → smart-diff them into at most\n * `max_frames` cards → format. All failures — including invalid input — are\n * reported as `isError` results rather than thrown so the MCP client sees a\n * useful message.\n */\nexport async function capturePage(rawInput: CaptureInput): Promise<CallToolResult> {\n const parsed = captureInputSchema.safeParse(rawInput);\n if (!parsed.success) {\n const issues = parsed.error.issues.map((i) => `${i.path.join(\".\") || \"input\"}: ${i.message}`).join(\"; \");\n return errorResult(`Capture failed: invalid input — ${issues}`);\n }\n const input = parsed.data;\n const viewport = input.viewport ?? { ...DEFAULT_VIEWPORT };\n const interactions = input.interactions ?? [];\n // Touch has to be decided when the context is created, so read it off the\n // script rather than turning it on for every capture: `hasTouch` puts\n // `ontouchstart` on window, which flips feature detection in most UI\n // libraries and would silently change what a plain capture records.\n const contextOptions = needsTouch(interactions) ? { hasTouch: true } : {};\n\n const report: InteractionReport | undefined =\n interactions.length > 0 ? { total: interactions.length, completed: 0, steps: [] } : undefined;\n\n try {\n const recording = await withPage({ viewport, contextOptions }, async (page) => {\n // Layers go on before the navigation: a script that throws while the page\n // loads, the request that never comes back and first paint all happen\n // before frame 0 exists, and they are the most useful things here.\n const layers = await attachLayers(page, {\n console: input.include_console,\n network: input.include_network,\n dom: input.include_dom,\n performance: input.include_performance,\n });\n try {\n // \"commit\" rather than \"load\": splash/loading animations must be recorded from the very start.\n await page.goto(input.url, { waitUntil: \"commit\", timeout: NAVIGATION_TIMEOUT_MS });\n if (input.wait_for) {\n await page.waitForSelector(input.wait_for, { state: \"visible\", timeout: input.wait_for_timeout_ms });\n }\n const result = await recordFrames(\n page,\n { duration_ms: input.duration_ms, interval_ms: input.interval_ms },\n report && ((recorder) => replayScript(page, recorder, interactions, input.interaction_timeout_ms, report)),\n );\n // Drain the layers before anything else can close the page. `collect`\n // reads only what Node already holds, so a page that froze, navigated\n // away or crashed still yields everything it managed to report.\n const context = layers.collect(result.started_at);\n // The page may have died mid-recording (crash, closed browser). Frames\n // already captured are still worth returning, so never let reading the\n // title or url turn a partial recording into an error.\n return { ...result, context, ...(await describePage(page)) };\n } finally {\n layers.detach();\n }\n });\n\n const { cards, total_frames } = await buildDiffCards(recording.frames, {\n sensitivity: input.sensitivity,\n max_frames: input.max_frames,\n });\n applyContext(cards, recording.context);\n\n return formatDiffCards({\n cards,\n total_frames,\n duration_ms: recording.duration_ms,\n url: input.url,\n final_url: recording.finalUrl,\n title: recording.title,\n dropped: recording.dropped,\n interactions: report,\n notes: summariseContext(recording.context, cards.length),\n });\n } catch (error) {\n return errorResult(describeCaptureFailure(input, error));\n }\n}\n\n/**\n * Replay the interaction script while the recorder runs, forcing a frame after\n * every step so the differ always keeps the result of each action.\n *\n * A failing step ends the script but never the capture: the frames recorded so\n * far are the most useful thing FrameWatch can hand back (they show the state\n * the page was actually in when the selector did not match), so the failure is\n * recorded in `report` and a forced \"error\" frame is captured instead of\n * throwing. The recording then plays out the rest of its duration.\n */\nasync function replayScript(\n page: Page,\n recorder: FrameRecorder,\n interactions: Interaction[],\n timeoutMs: number,\n report: InteractionReport,\n): Promise<void> {\n for (let i = 0; i < interactions.length; i++) {\n const step = interactions[i];\n try {\n await executeInteraction(page, step, { timeout_ms: timeoutMs });\n } catch (error) {\n report.error = error instanceof Error ? error.message : String(error);\n report.failed_index = i + 1;\n await recorder.captureNow(\"error\");\n return;\n }\n report.completed++;\n report.steps.push(describeInteraction(step));\n await recorder.captureNow(\"interaction\");\n }\n}\n\n/**\n * Title and final url of a page. Both are cosmetic, so neither is allowed to\n * fail or delay the result: the page may have died during the recording, and\n * `page.title()` blocks for Playwright's full default timeout while the main\n * thread is busy — exactly the case a developer points this tool at.\n */\nasync function describePage(page: Page): Promise<{ title?: string; finalUrl?: string }> {\n if (page.isClosed()) return {};\n const finalUrl = safely(() => page.url());\n // Settle the losing side too: a page.title() that outlives the race would\n // otherwise reject unobserved when the context is closed underneath it.\n const title = page.title().catch(() => undefined);\n let timer: NodeJS.Timeout | undefined;\n const giveUp = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), PAGE_INFO_TIMEOUT_MS);\n });\n try {\n return { title: await Promise.race([title, giveUp]), finalUrl };\n } finally {\n clearTimeout(timer);\n }\n}\n\nfunction safely<T>(read: () => T): T | undefined {\n try {\n return read();\n } catch {\n return undefined;\n }\n}\n\nfunction errorResult(text: string): CallToolResult {\n return { isError: true, content: [{ type: \"text\", text }] };\n}\n\n/**\n * Turn a Playwright/Node error into a one-line, actionable message. Mirrors\n * `describeFailure` in screenshot.ts: matches on the failing Playwright call\n * (the message prefix) rather than on substrings of user-supplied selectors,\n * so a navigation failure is never blamed on an element.\n */\nexport function describeCaptureFailure(\n input: Pick<ParsedCaptureInput, \"url\" | \"wait_for\" | \"wait_for_timeout_ms\">,\n error: unknown,\n): string {\n const message = error instanceof Error ? error.message : String(error);\n const firstLine = message.split(\"\\n\")[0];\n const prefix = `Capture of ${input.url} failed:`;\n\n if (/Executable doesn't exist|browserType\\.launch/i.test(message)) {\n return (\n `${prefix} Playwright's Chromium browser is not installed. ` +\n `Run \\`npx playwright install chromium\\` and try again. (${firstLine})`\n );\n }\n if (input.wait_for && /^page\\.waitForSelector:/.test(message)) {\n return `${prefix} selector \"${input.wait_for}\" did not become visible within ${input.wait_for_timeout_ms}ms.`;\n }\n return `${prefix} ${firstLine}`;\n}\n\nexport function registerCaptureTool(server: McpServer): void {\n server.registerTool(\n CAPTURE_TOOL_NAME,\n {\n title: \"Capture\",\n description:\n \"Record a web page for a few seconds and return only the meaningful visual changes as diff cards: \" +\n \"a full-frame PNG plus a crop of the changed region and its position for each kept frame. \" +\n \"Use it to check animations, splash/loading screens, transitions and anything that changes over time. \" +\n \"Lower `sensitivity` to keep more frames; `max_frames` caps the output. \" +\n \"Each frame can also carry the context for the interval that produced it: console output and uncaught \" +\n \"errors (on by default), plus network requests, DOM mutations and paint/layout-shift timing via \" +\n \"`include_network`, `include_dom` and `include_performance` — that is how you find out *why* a frame \" +\n \"looks wrong, not just that it does.\",\n inputSchema: captureInputShape,\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: false, openWorldHint: true },\n },\n async (args) => capturePage(args),\n );\n}\n"]}
1
+ {"version":3,"file":"capture.js","sourceRoot":"","sources":["../../src/tools/capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EACL,eAAe,EACf,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AC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,cAAc,KAAK,CAAC,GAAG,UAAU,CAAC;IAEjD,IAAI,+CAA+C,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAClE,OAAO,CACL,GAAG,MAAM,mDAAmD;YAC5D,2DAA2D,SAAS,GAAG,CACxE,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,IAAI,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9D,OAAO,GAAG,MAAM,cAAc,KAAK,CAAC,QAAQ,mCAAmC,KAAK,CAAC,mBAAmB,KAAK,CAAC;IAChH,CAAC;IACD,OAAO,GAAG,MAAM,IAAI,SAAS,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,SAAS;QAChB,WAAW,EACT,mGAAmG;YACnG,2FAA2F;YAC3F,uGAAuG;YACvG,yEAAyE;YACzE,uGAAuG;YACvG,iGAAiG;YACjG,sGAAsG;YACtG,qCAAqC;QACvC,WAAW,EAAE,iBAAiB;QAC9B,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE;KACxG,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAClC,CAAC;AACJ,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { BrowserContextOptions, Page } from \"playwright\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n CAPTURE_INTERVAL_MS,\n DEFAULT_CAPTURE_DURATION_MS,\n DEFAULT_MAX_FRAMES,\n DEFAULT_SENSITIVITY,\n DEFAULT_VIEWPORT,\n MAX_CAPTURE_DURATION_MS,\n MAX_VIEWPORT_HEIGHT,\n MAX_VIEWPORT_WIDTH,\n MAX_FRAMES_CAP,\n MAX_INTERACTIONS,\n MIN_CAPTURE_DURATION_MS,\n NAVIGATION_TIMEOUT_MS,\n PAGE_INFO_TIMEOUT_MS,\n SELECTOR_TIMEOUT_MS,\n} from \"../constants.js\";\nimport { withPage } from \"../engine/browser.js\";\nimport { buildDiffCards } from \"../engine/differ.js\";\nimport { applyContext, attachLayers, summariseContext } from \"../engine/layers/index.js\";\nimport {\n CAPTURE_ACTIONS,\n describeInteraction,\n executeInteraction,\n interactionFieldShape,\n needsTouch,\n refineInteraction,\n type Interaction,\n} from \"../engine/interaction.js\";\nimport { recordFrames, type FrameRecorder } from \"../engine/recorder.js\";\nimport { formatDiffCards, type InteractionReport } from \"../utils/format.js\";\nimport { readStorageState, storageStateField } from \"../utils/storage-state.js\";\n\nexport const CAPTURE_TOOL_NAME = \"framewatch_capture\";\n\n/**\n * Re-exported where it is used: the capture summary's context lines. It lives\n * with the layers themselves now that `framewatch_interact` reports them too.\n */\nexport { summariseContext };\n\n/**\n * One step of a replayable interaction script. `delay_ms` is a wait *before*\n * the action, so a `wait` step is just a delay with nothing after it, and the\n * delays of successive steps accumulate over the recording.\n */\nexport const captureInteractionSchema = z\n .object({\n action: z\n .enum(CAPTURE_ACTIONS)\n .describe(\"What to do: click, tap, type, key, scroll, swipe, hover, select, wait or navigate\"),\n ...interactionFieldShape,\n delay_ms: z.number().int().min(0).default(0).describe(\"Wait this long (ms) before performing this action\"),\n })\n .superRefine(refineInteraction);\n\nexport const captureInputShape = {\n url: z.string().url().describe(\"URL to capture, e.g. http://localhost:3000 (http, https and file URLs are accepted)\"),\n duration_ms: z\n .number()\n .int()\n .min(MIN_CAPTURE_DURATION_MS)\n .max(MAX_CAPTURE_DURATION_MS)\n .default(DEFAULT_CAPTURE_DURATION_MS)\n .describe(\"How long to record (ms)\"),\n sensitivity: z\n .number()\n .min(0)\n .max(1)\n .default(DEFAULT_SENSITIVITY)\n .describe(\"Frame change threshold (0 = keep all, 1 = keep none). 0.06 means ~6% of grid cells must change.\"),\n max_frames: z\n .number()\n .int()\n .min(1)\n .max(MAX_FRAMES_CAP)\n .default(DEFAULT_MAX_FRAMES)\n .describe(\"Maximum diff cards to return\"),\n interval_ms: z\n .number()\n .int()\n .min(16)\n .max(2000)\n .default(CAPTURE_INTERVAL_MS)\n .describe(\"Raw frame capture interval (ms) — 100 = 10fps\"),\n viewport: z\n .object({\n width: z.number().int().min(1).max(MAX_VIEWPORT_WIDTH).default(DEFAULT_VIEWPORT.width),\n height: z.number().int().min(1).max(MAX_VIEWPORT_HEIGHT).default(DEFAULT_VIEWPORT.height),\n })\n .optional()\n .describe(\"Viewport size (defaults to 1280x720)\"),\n wait_for: z.string().optional().describe(\"CSS selector to wait for (visible) before recording starts\"),\n wait_for_timeout_ms: z\n .number()\n .int()\n .min(1)\n .default(SELECTOR_TIMEOUT_MS)\n .describe(\"Max time (ms) to wait for `wait_for` to appear (must be > 0)\"),\n interactions: z\n .array(captureInteractionSchema)\n .max(MAX_INTERACTIONS)\n .optional()\n .describe(\"Sequence of user interactions to replay during the recording\"),\n interaction_timeout_ms: z\n .number()\n .int()\n .min(1)\n .default(SELECTOR_TIMEOUT_MS)\n .describe(\"Max time (ms) an interaction step may spend waiting for its target element\"),\n include_console: z\n .boolean()\n .default(true)\n .describe(\"Attach console logs, uncaught errors and unhandled rejections to the frames they happened between\"),\n include_network: z\n .boolean()\n .default(false)\n .describe(\"Attach network requests (method, url, status, duration) to the frames they settled between\"),\n include_dom: z\n .boolean()\n .default(false)\n .describe(\"Attach a summary of the DOM mutations between frames — which elements were added, removed or restyled\"),\n include_performance: z\n .boolean()\n .default(false)\n .describe(\"Attach paint timing, largest contentful paint and layout shifts to the frames they were measured at\"),\n storage_state: storageStateField,\n};\n\nexport const captureInputSchema = z.object(captureInputShape);\nexport type CaptureInput = z.input<typeof captureInputSchema>;\ntype ParsedCaptureInput = z.output<typeof captureInputSchema>;\n\n/**\n * The main FrameWatch tool: record a page for `duration_ms` and return only\n * the meaningful visual changes as diff cards (see CLAUDE.md \"Diff Cards\" and\n * \"MCP Response Format\").\n *\n * Flow: navigate (waiting only for the navigation to commit, so loading and\n * splash animations are recorded from their first frame) → optionally wait\n * for `wait_for` → record raw frames every `interval_ms`, replaying\n * `interactions` as the recording runs → smart-diff them into at most\n * `max_frames` cards → format. All failures — including invalid input — are\n * reported as `isError` results rather than thrown so the MCP client sees a\n * useful message.\n */\nexport async function capturePage(rawInput: CaptureInput): Promise<CallToolResult> {\n const parsed = captureInputSchema.safeParse(rawInput);\n if (!parsed.success) {\n const issues = parsed.error.issues.map((i) => `${i.path.join(\".\") || \"input\"}: ${i.message}`).join(\"; \");\n return errorResult(`Capture failed: invalid input — ${issues}`);\n }\n const input = parsed.data;\n const viewport = input.viewport ?? { ...DEFAULT_VIEWPORT };\n const interactions = input.interactions ?? [];\n // Touch has to be decided when the context is created, so read it off the\n // script rather than turning it on for every capture: `hasTouch` puts\n // `ontouchstart` on window, which flips feature detection in most UI\n // libraries and would silently change what a plain capture records.\n const contextOptions: BrowserContextOptions = needsTouch(interactions) ? { hasTouch: true } : {};\n\n const report: InteractionReport | undefined =\n interactions.length > 0 ? { total: interactions.length, completed: 0, steps: [] } : undefined;\n\n try {\n if (input.storage_state) contextOptions.storageState = await readStorageState(input.storage_state);\n\n const recording = await withPage({ viewport, contextOptions }, async (page) => {\n // Layers go on before the navigation: a script that throws while the page\n // loads, the request that never comes back and first paint all happen\n // before frame 0 exists, and they are the most useful things here.\n const layers = await attachLayers(page, {\n console: input.include_console,\n network: input.include_network,\n dom: input.include_dom,\n performance: input.include_performance,\n });\n try {\n // \"commit\" rather than \"load\": splash/loading animations must be recorded from the very start.\n await page.goto(input.url, { waitUntil: \"commit\", timeout: NAVIGATION_TIMEOUT_MS });\n if (input.wait_for) {\n await page.waitForSelector(input.wait_for, { state: \"visible\", timeout: input.wait_for_timeout_ms });\n }\n const result = await recordFrames(\n page,\n { duration_ms: input.duration_ms, interval_ms: input.interval_ms },\n report && ((recorder) => replayScript(page, recorder, interactions, input.interaction_timeout_ms, report)),\n );\n // Drain the layers before anything else can close the page. `collect`\n // reads only what Node already holds, so a page that froze, navigated\n // away or crashed still yields everything it managed to report.\n const context = layers.collect(result.started_at);\n // The page may have died mid-recording (crash, closed browser). Frames\n // already captured are still worth returning, so never let reading the\n // title or url turn a partial recording into an error.\n return { ...result, context, ...(await describePage(page)) };\n } finally {\n layers.detach();\n }\n });\n\n const { cards, total_frames } = await buildDiffCards(recording.frames, {\n sensitivity: input.sensitivity,\n max_frames: input.max_frames,\n });\n applyContext(cards, recording.context);\n\n return formatDiffCards({\n cards,\n total_frames,\n duration_ms: recording.duration_ms,\n url: input.url,\n final_url: recording.finalUrl,\n title: recording.title,\n dropped: recording.dropped,\n interactions: report,\n notes: summariseContext(recording.context, cards.length),\n });\n } catch (error) {\n return errorResult(describeCaptureFailure(input, error));\n }\n}\n\n/**\n * Replay the interaction script while the recorder runs, forcing a frame after\n * every step so the differ always keeps the result of each action.\n *\n * A failing step ends the script but never the capture: the frames recorded so\n * far are the most useful thing FrameWatch can hand back (they show the state\n * the page was actually in when the selector did not match), so the failure is\n * recorded in `report` and a forced \"error\" frame is captured instead of\n * throwing. The recording then plays out the rest of its duration.\n */\nasync function replayScript(\n page: Page,\n recorder: FrameRecorder,\n interactions: Interaction[],\n timeoutMs: number,\n report: InteractionReport,\n): Promise<void> {\n for (let i = 0; i < interactions.length; i++) {\n const step = interactions[i];\n try {\n await executeInteraction(page, step, { timeout_ms: timeoutMs });\n } catch (error) {\n report.error = error instanceof Error ? error.message : String(error);\n report.failed_index = i + 1;\n await recorder.captureNow(\"error\");\n return;\n }\n report.completed++;\n report.steps.push(describeInteraction(step));\n await recorder.captureNow(\"interaction\");\n }\n}\n\n/**\n * Title and final url of a page. Both are cosmetic, so neither is allowed to\n * fail or delay the result: the page may have died during the recording, and\n * `page.title()` blocks for Playwright's full default timeout while the main\n * thread is busy — exactly the case a developer points this tool at.\n */\nasync function describePage(page: Page): Promise<{ title?: string; finalUrl?: string }> {\n if (page.isClosed()) return {};\n const finalUrl = safely(() => page.url());\n // Settle the losing side too: a page.title() that outlives the race would\n // otherwise reject unobserved when the context is closed underneath it.\n const title = page.title().catch(() => undefined);\n let timer: NodeJS.Timeout | undefined;\n const giveUp = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), PAGE_INFO_TIMEOUT_MS);\n });\n try {\n return { title: await Promise.race([title, giveUp]), finalUrl };\n } finally {\n clearTimeout(timer);\n }\n}\n\nfunction safely<T>(read: () => T): T | undefined {\n try {\n return read();\n } catch {\n return undefined;\n }\n}\n\nfunction errorResult(text: string): CallToolResult {\n return { isError: true, content: [{ type: \"text\", text }] };\n}\n\n/**\n * Turn a Playwright/Node error into a one-line, actionable message. Mirrors\n * `describeFailure` in screenshot.ts: matches on the failing Playwright call\n * (the message prefix) rather than on substrings of user-supplied selectors,\n * so a navigation failure is never blamed on an element.\n */\nexport function describeCaptureFailure(\n input: Pick<ParsedCaptureInput, \"url\" | \"wait_for\" | \"wait_for_timeout_ms\">,\n error: unknown,\n): string {\n const message = error instanceof Error ? error.message : String(error);\n const firstLine = message.split(\"\\n\")[0];\n const prefix = `Capture of ${input.url} failed:`;\n\n if (/Executable doesn't exist|browserType\\.launch/i.test(message)) {\n return (\n `${prefix} Playwright's Chromium browser is not installed. ` +\n `Run \\`npx playwright install chromium\\` and try again. (${firstLine})`\n );\n }\n if (input.wait_for && /^page\\.waitForSelector:/.test(message)) {\n return `${prefix} selector \"${input.wait_for}\" did not become visible within ${input.wait_for_timeout_ms}ms.`;\n }\n return `${prefix} ${firstLine}`;\n}\n\nexport function registerCaptureTool(server: McpServer): void {\n server.registerTool(\n CAPTURE_TOOL_NAME,\n {\n title: \"Capture\",\n description:\n \"Record a web page for a few seconds and return only the meaningful visual changes as diff cards: \" +\n \"a full-frame PNG plus a crop of the changed region and its position for each kept frame. \" +\n \"Use it to check animations, splash/loading screens, transitions and anything that changes over time. \" +\n \"Lower `sensitivity` to keep more frames; `max_frames` caps the output. \" +\n \"Each frame can also carry the context for the interval that produced it: console output and uncaught \" +\n \"errors (on by default), plus network requests, DOM mutations and paint/layout-shift timing via \" +\n \"`include_network`, `include_dom` and `include_performance` — that is how you find out *why* a frame \" +\n \"looks wrong, not just that it does.\",\n inputSchema: captureInputShape,\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: false, openWorldHint: true },\n },\n async (args) => capturePage(args),\n );\n}\n"]}
@@ -20,6 +20,7 @@ export declare const compareInputShape: {
20
20
  width?: number | undefined;
21
21
  height?: number | undefined;
22
22
  }>>;
23
+ storage_state: z.ZodOptional<z.ZodString>;
23
24
  };
24
25
  export declare const compareInputSchema: z.ZodObject<{
25
26
  url_a: z.ZodEffects<z.ZodString, string, string>;
@@ -37,6 +38,7 @@ export declare const compareInputSchema: z.ZodObject<{
37
38
  width?: number | undefined;
38
39
  height?: number | undefined;
39
40
  }>>;
41
+ storage_state: z.ZodOptional<z.ZodString>;
40
42
  }, "strip", z.ZodTypeAny, {
41
43
  wait_ms: number;
42
44
  wait_for_timeout_ms: number;
@@ -47,6 +49,7 @@ export declare const compareInputSchema: z.ZodObject<{
47
49
  height: number;
48
50
  } | undefined;
49
51
  wait_for?: string | undefined;
52
+ storage_state?: string | undefined;
50
53
  }, {
51
54
  url_a: string;
52
55
  url_b: string;
@@ -57,6 +60,7 @@ export declare const compareInputSchema: z.ZodObject<{
57
60
  wait_ms?: number | undefined;
58
61
  wait_for?: string | undefined;
59
62
  wait_for_timeout_ms?: number | undefined;
63
+ storage_state?: string | undefined;
60
64
  }>;
61
65
  export type CompareInput = z.input<typeof compareInputSchema>;
62
66
  type ParsedCompareInput = z.output<typeof compareInputSchema>;
@@ -3,6 +3,7 @@ import { CROP_PADDING_PX, DEFAULT_COMPARE_WAIT_MS, DEFAULT_VIEWPORT, MAX_VIEWPOR
3
3
  import { getSessionPage, withPage, withSessionLock } from "../engine/browser.js";
4
4
  import { computePixelMask, padBoundingBox } from "../engine/differ.js";
5
5
  import { getDimensions, overlayMask, resizeForOutput, toBase64, toGrayscale } from "../utils/image.js";
6
+ import { readStorageState, storageStateField } from "../utils/storage-state.js";
6
7
  export const COMPARE_TOOL_NAME = "framewatch_compare";
7
8
  /** `url_a` accepts this instead of a URL, meaning "whatever framewatch_interact is looking at". */
8
9
  export const CURRENT_PAGE = "current";
@@ -38,6 +39,7 @@ export const compareInputShape = {
38
39
  })
39
40
  .optional()
40
41
  .describe("Viewport for both sides (defaults to 1280x720, or the open page's size when comparing against `current`)"),
42
+ storage_state: storageStateField,
41
43
  };
42
44
  export const compareInputSchema = z.object(compareInputShape);
43
45
  /**
@@ -69,7 +71,11 @@ export async function comparePages(rawInput) {
69
71
  const openIsB = input.url_b === CURRENT_PAGE && input.url_a !== CURRENT_PAGE;
70
72
  const [firstSide, secondSide] = openIsB ? [input.url_b, input.url_a] : [input.url_a, input.url_b];
71
73
  try {
72
- const first = await captureSide(input, firstSide);
74
+ // Both URL sides get the same saved auth: they are two views of one app,
75
+ // and a comparison where only one side is signed in compares the login
76
+ // screen with the app. ("current" is read as it is, never reloaded.)
77
+ const storageState = input.storage_state ? await readStorageState(input.storage_state) : undefined;
78
+ const first = await captureSide(input, firstSide, undefined, storageState);
73
79
  const notes = [];
74
80
  let viewport = input.viewport ?? { ...DEFAULT_VIEWPORT };
75
81
  if (firstSide === CURRENT_PAGE) {
@@ -81,7 +87,7 @@ export async function comparePages(rawInput) {
81
87
  }
82
88
  viewport = open;
83
89
  }
84
- const second = await captureSide(input, secondSide, viewport);
90
+ const second = await captureSide(input, secondSide, viewport, storageState);
85
91
  const [a, b] = openIsB ? [second, first] : [first, second];
86
92
  return await render(input, a, b, notes);
87
93
  }
@@ -99,7 +105,7 @@ export async function comparePages(rawInput) {
99
105
  * flow — against a plain URL, and reloading or resizing it would destroy the
100
106
  * very thing being compared.
101
107
  */
102
- async function captureSide(input, side, viewport) {
108
+ async function captureSide(input, side, viewport, storageState) {
103
109
  if (side === CURRENT_PAGE) {
104
110
  // Under the session lock: an interaction running in parallel would
105
111
  // otherwise be screenshotted half way through.
@@ -112,7 +118,11 @@ async function captureSide(input, side, viewport) {
112
118
  return { png: await page.screenshot({ type: "png" }), url: page.url(), title: await safeTitle(page) };
113
119
  });
114
120
  }
115
- return withPage({ viewport: viewport ?? input.viewport ?? { ...DEFAULT_VIEWPORT } }, async (page) => {
121
+ const options = {
122
+ viewport: viewport ?? input.viewport ?? { ...DEFAULT_VIEWPORT },
123
+ ...(storageState ? { contextOptions: { storageState } } : {}),
124
+ };
125
+ return withPage(options, async (page) => {
116
126
  await page.goto(side, { waitUntil: "load", timeout: NAVIGATION_TIMEOUT_MS });
117
127
  if (input.wait_for) {
118
128
  await page.waitForSelector(input.wait_for, { state: "visible", timeout: input.wait_for_timeout_ms });
@@ -1 +1 @@
1
- {"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/tools/compare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEvG,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAA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AAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;KACvG,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CACnC,CAAC;AACJ,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { Page } from \"playwright\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n CROP_PADDING_PX,\n DEFAULT_COMPARE_WAIT_MS,\n DEFAULT_VIEWPORT,\n MAX_VIEWPORT_HEIGHT,\n MAX_VIEWPORT_WIDTH,\n NAVIGATION_TIMEOUT_MS,\n PAGE_INFO_TIMEOUT_MS,\n SELECTOR_TIMEOUT_MS,\n} from \"../constants.js\";\nimport { getSessionPage, withPage, withSessionLock } from \"../engine/browser.js\";\nimport { computePixelMask, padBoundingBox } from \"../engine/differ.js\";\nimport type { BoundingBox, Viewport } from \"../types.js\";\nimport { getDimensions, overlayMask, resizeForOutput, toBase64, toGrayscale } from \"../utils/image.js\";\n\nexport const COMPARE_TOOL_NAME = \"framewatch_compare\";\n\n/** `url_a` accepts this instead of a URL, meaning \"whatever framewatch_interact is looking at\". */\nexport const CURRENT_PAGE = \"current\";\n\n/**\n * Either a URL or the literal \"current\". `z.string().url()` cannot express\n * that, so the check is spelled out — and the message says both options,\n * because \"invalid url\" on the word `current` is a confusing thing to read.\n */\nconst sideSchema = z.string().refine((value) => value === CURRENT_PAGE || isUrl(value), {\n message: `must be a URL, or \"${CURRENT_PAGE}\" to use the page framewatch_interact currently has open`,\n});\n\nexport const compareInputShape = {\n url_a: sideSchema.describe(\n `First URL — the \"before\" side. Pass \"${CURRENT_PAGE}\" to compare against the page framewatch_interact has open, ` +\n \"in whatever state your interactions left it.\",\n ),\n url_b: sideSchema.describe('Second URL — the \"after\" side.'),\n wait_ms: z\n .number()\n .int()\n .min(0)\n .default(DEFAULT_COMPARE_WAIT_MS)\n .describe(\"Wait time (ms) after page load before each screenshot\"),\n wait_for: z.string().optional().describe(\"CSS selector to wait for (visible) on both sides before capturing\"),\n wait_for_timeout_ms: z\n .number()\n .int()\n .min(1)\n .default(SELECTOR_TIMEOUT_MS)\n .describe(\"Max time (ms) to wait for `wait_for` to appear (must be > 0)\"),\n viewport: z\n .object({\n width: z.number().int().min(1).max(MAX_VIEWPORT_WIDTH).default(DEFAULT_VIEWPORT.width),\n height: z.number().int().min(1).max(MAX_VIEWPORT_HEIGHT).default(DEFAULT_VIEWPORT.height),\n })\n .optional()\n .describe(\"Viewport for both sides (defaults to 1280x720, or the open page's size when comparing against `current`)\"),\n};\n\nexport const compareInputSchema = z.object(compareInputShape);\nexport type CompareInput = z.input<typeof compareInputSchema>;\ntype ParsedCompareInput = z.output<typeof compareInputSchema>;\n\n/** One captured side of the comparison. */\ninterface Side {\n png: Buffer;\n /** Where the shot was actually taken (after redirects), or the open page's URL. */\n url: string;\n title?: string;\n}\n\n/**\n * Compare two pages — or the same page before and after a change — and show\n * what moved.\n *\n * Returns both screenshots plus an overlay: side B with every differing pixel\n * tinted, which is the part that turns \"3.4% changed\" into something a reader\n * can act on. The comparison is the same pixel comparison the capture engine\n * uses between frames, so a change region here means what it means there.\n *\n * The two sides are captured one after the other rather than at once, so both\n * get an unloaded machine and the same `wait_ms` means the same thing for\n * each; a difference in the result should come from the pages, not from which\n * of them was competing for the CPU. (Which of the two goes first is decided\n * by `\"current\"` — see below — not by their order in the input.)\n */\nexport async function comparePages(rawInput: CompareInput): Promise<CallToolResult> {\n const parsed = compareInputSchema.safeParse(rawInput);\n if (!parsed.success) {\n const issues = parsed.error.issues.map((i) => `${i.path.join(\".\") || \"input\"}: ${i.message}`).join(\"; \");\n return errorResult(`Compare failed: invalid input — ${issues}`);\n }\n const input = parsed.data;\n\n // The open page is the one side that cannot be resized — doing so would\n // change the state being compared — so it is captured first whichever side\n // it is, and its size is what the other side is then captured at. Frames of\n // two different sizes cannot be compared pixel for pixel at all.\n const openIsB = input.url_b === CURRENT_PAGE && input.url_a !== CURRENT_PAGE;\n const [firstSide, secondSide] = openIsB ? [input.url_b, input.url_a] : [input.url_a, input.url_b];\n\n try {\n const first = await captureSide(input, firstSide);\n const notes: string[] = [];\n let viewport = input.viewport ?? { ...DEFAULT_VIEWPORT };\n\n if (firstSide === CURRENT_PAGE) {\n const open = await sizeOf(first.png);\n if (input.viewport && (input.viewport.width !== open.width || input.viewport.height !== open.height)) {\n notes.push(\n `Ignored \\`viewport\\` ${input.viewport.width}x${input.viewport.height}: the open page is ` +\n `${open.width}x${open.height} and resizing it would change the state being compared. ` +\n \"Both sides were captured at the open page's size.\",\n );\n }\n viewport = open;\n }\n\n const second = await captureSide(input, secondSide, viewport);\n const [a, b] = openIsB ? [second, first] : [first, second];\n return await render(input, a, b, notes);\n } catch (error) {\n return errorResult(describeCompareFailure(input, error));\n }\n}\n\n/**\n * Screenshot one side.\n *\n * A URL gets a fresh context, so nothing from the other side (or from an\n * earlier tool call) can leak into it. \"current\" instead reads the page\n * `framewatch_interact` has open, *without* touching it: the whole point of\n * that option is to compare a hand-built state — three clicks deep into a\n * flow — against a plain URL, and reloading or resizing it would destroy the\n * very thing being compared.\n */\nasync function captureSide(input: ParsedCompareInput, side: string, viewport?: Viewport): Promise<Side> {\n if (side === CURRENT_PAGE) {\n // Under the session lock: an interaction running in parallel would\n // otherwise be screenshotted half way through.\n return withSessionLock(async () => {\n const { page } = await getSessionPage();\n if (page.url() === \"about:blank\") {\n throw new Error(\n `no page is open, so there is no \"${CURRENT_PAGE}\" state to compare — ` +\n \"use framewatch_interact first, or pass a URL here.\",\n );\n }\n return { png: await page.screenshot({ type: \"png\" }), url: page.url(), title: await safeTitle(page) };\n });\n }\n\n return withPage({ viewport: viewport ?? input.viewport ?? { ...DEFAULT_VIEWPORT } }, async (page) => {\n await page.goto(side, { waitUntil: \"load\", timeout: NAVIGATION_TIMEOUT_MS });\n if (input.wait_for) {\n await page.waitForSelector(input.wait_for, { state: \"visible\", timeout: input.wait_for_timeout_ms });\n }\n if (input.wait_ms > 0) {\n await page.waitForTimeout(input.wait_ms);\n }\n return { png: await page.screenshot({ type: \"png\" }), url: page.url(), title: await safeTitle(page) };\n });\n}\n\n/**\n * Build the result: a summary, both frames, and (when the two are comparable\n * and actually differ) the overlay.\n *\n * Sides of different sizes are reported as such rather than being stretched to\n * match. Rescaling one of them would resample every pixel in it, and the\n * \"differences\" that came back would be the resampling, not the pages.\n */\nasync function render(input: ParsedCompareInput, a: Side, b: Side, notes: string[]): Promise<CallToolResult> {\n const [grayA, grayB] = await Promise.all([toGrayscale(a.png), toGrayscale(b.png)]);\n const nameA = describeSide(input.url_a, a);\n const nameB = describeSide(input.url_b, b);\n const sameSize = grayA.width === grayB.width && grayA.height === grayB.height;\n\n const lines: string[] = [];\n let overlay: Buffer | undefined;\n let overlayNote = \"\";\n\n if (!sameSize) {\n lines.push(\n `Compared ${nameA} against ${nameB} — the two frames are different sizes ` +\n `(${grayA.width}x${grayA.height} vs ${grayB.width}x${grayB.height}), so they cannot be compared pixel ` +\n \"for pixel. Both are below.\",\n );\n } else {\n const diff = computePixelMask(grayA.data, grayB.data, grayA.width, grayA.height);\n const region: BoundingBox | null =\n diff.bbox === null ? null : padBoundingBox(diff.bbox, CROP_PADDING_PX, grayA.width, grayA.height);\n\n lines.push(\n `Compared ${nameA} against ${nameB} at ${grayA.width}x${grayA.height} — ` +\n `${diff.changePercent.toFixed(2)}% of pixels differ` +\n (region === null\n ? \". The two are pixel-identical.\"\n : `, all of it within ${region.x},${region.y} ${region.width}x${region.height}.`),\n );\n\n if (region !== null) {\n overlay = await resizeForOutput(await overlayMask(b.png, diff.mask, grayA.width, grayA.height));\n overlayNote =\n `Diff overlay — B with every differing pixel tinted. ${diff.changedPixels} of ${diff.totalPixels} ` +\n `pixels changed (${diff.changePercent.toFixed(2)}%), within ` +\n `${region.x},${region.y} ${region.width}x${region.height}.`;\n }\n }\n\n const content: CallToolResult[\"content\"] = [{ type: \"text\", text: [...lines, ...notes].join(\"\\n\") }];\n await pushFrame(content, a.png, `A — ${nameA}`);\n await pushFrame(content, b.png, `B — ${nameB}`);\n if (overlay) {\n content.push({ type: \"image\", data: toBase64(overlay), mimeType: \"image/png\" });\n content.push({ type: \"text\", text: overlayNote });\n }\n return { content };\n}\n\nasync function pushFrame(content: CallToolResult[\"content\"], png: Buffer, label: string): Promise<void> {\n const resized = await resizeForOutput(png);\n const { width, height } = await getDimensions(resized);\n content.push({ type: \"image\", data: toBase64(resized), mimeType: \"image/png\" });\n content.push({ type: \"text\", text: `${label} — image ${width}x${height}` });\n}\n\n/** How a side is named in the output: where it ended up, and its title if it has one. */\nfunction describeSide(requested: string, side: Side): string {\n const where = requested === CURRENT_PAGE ? `the open page (${side.url})` : side.url;\n return side.title ? `${where} \"${side.title}\"` : where;\n}\n\n/** Cosmetic, and never allowed to fail or stall: a busy page still gets compared. */\nasync function safeTitle(page: Page): Promise<string | undefined> {\n return Promise.race([\n page.title().catch(() => undefined),\n new Promise<undefined>((resolve) => setTimeout(() => resolve(undefined), PAGE_INFO_TIMEOUT_MS)),\n ]);\n}\n\nasync function sizeOf(png: Buffer): Promise<Viewport> {\n const { width, height } = await getDimensions(png);\n return { width, height };\n}\n\nfunction isUrl(value: string): boolean {\n try {\n new URL(value);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction errorResult(text: string): CallToolResult {\n return { isError: true, content: [{ type: \"text\", text }] };\n}\n\n/**\n * One actionable line for a failed comparison. Mirrors `describeFailure` in\n * screenshot.ts, with one addition: a `page.goto` failure names which of the\n * two sides could not be opened, which is the first thing you want to know.\n */\nexport function describeCompareFailure(\n input: Pick<ParsedCompareInput, \"url_a\" | \"url_b\" | \"wait_for\" | \"wait_for_timeout_ms\">,\n error: unknown,\n): string {\n const message = error instanceof Error ? error.message : String(error);\n const firstLine = message.split(\"\\n\")[0];\n const prefix = \"Compare failed:\";\n\n if (/Executable doesn't exist|browserType\\.launch/i.test(message)) {\n return (\n `${prefix} Playwright's Chromium browser is not installed. ` +\n `Run \\`npx playwright install chromium\\` and try again. (${firstLine})`\n );\n }\n if (/^page\\.goto:/.test(message)) {\n const side = failingSide(input, message);\n return `${prefix} could not open ${side} — ${firstLine}`;\n }\n if (input.wait_for && /^page\\.waitForSelector:/.test(message)) {\n return `${prefix} selector \"${input.wait_for}\" did not become visible within ${input.wait_for_timeout_ms}ms.`;\n }\n return `${prefix} ${firstLine}`;\n}\n\n/** Playwright quotes the URL it tried in a goto failure; that says which side broke. */\nfunction failingSide(input: Pick<ParsedCompareInput, \"url_a\" | \"url_b\">, message: string): string {\n if (input.url_b !== CURRENT_PAGE && message.includes(input.url_b)) return `url_b (${input.url_b})`;\n if (input.url_a !== CURRENT_PAGE && message.includes(input.url_a)) return `url_a (${input.url_a})`;\n return \"one of the two pages\";\n}\n\nexport function registerCompareTool(server: McpServer): void {\n server.registerTool(\n COMPARE_TOOL_NAME,\n {\n title: \"Compare\",\n description:\n \"Compare two pages — two URLs, or the same URL before and after a code change — and show what moved. \" +\n \"Returns both screenshots, the percentage of pixels that differ, the region they differ in, and an \" +\n `overlay of the second page with every changed pixel tinted. Pass \"${CURRENT_PAGE}\" as \\`url_a\\` to ` +\n \"compare against the page framewatch_interact has open, in whatever state your interactions left it.\",\n inputSchema: compareInputShape,\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },\n },\n async (args) => comparePages(args),\n );\n}\n"]}
1
+ {"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/tools/compare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,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FAAwF;AACxF,SAAS,WAAW,CAAC,KAAkD,EAAE,OAAe;IACtF,IAAI,KAAK,CAAC,KAAK,KAAK,YAAY,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,UAAU,KAAK,CAAC,KAAK,GAAG,CAAC;IACnG,IAAI,KAAK,CAAC,KAAK,KAAK,YAAY,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,UAAU,KAAK,CAAC,KAAK,GAAG,CAAC;IACnG,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,SAAS;QAChB,WAAW,EACT,sGAAsG;YACtG,oGAAoG;YACpG,qEAAqE,YAAY,oBAAoB;YACrG,qGAAqG;QACvG,WAAW,EAAE,iBAAiB;QAC9B,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;KACvG,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CACnC,CAAC;AACJ,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { Page } from \"playwright\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n CROP_PADDING_PX,\n DEFAULT_COMPARE_WAIT_MS,\n DEFAULT_VIEWPORT,\n MAX_VIEWPORT_HEIGHT,\n MAX_VIEWPORT_WIDTH,\n NAVIGATION_TIMEOUT_MS,\n PAGE_INFO_TIMEOUT_MS,\n SELECTOR_TIMEOUT_MS,\n} from \"../constants.js\";\nimport { getSessionPage, withPage, withSessionLock } from \"../engine/browser.js\";\nimport { computePixelMask, padBoundingBox } from \"../engine/differ.js\";\nimport type { BoundingBox, Viewport } from \"../types.js\";\nimport { getDimensions, overlayMask, resizeForOutput, toBase64, toGrayscale } from \"../utils/image.js\";\nimport { readStorageState, storageStateField, type StorageState } from \"../utils/storage-state.js\";\n\nexport const COMPARE_TOOL_NAME = \"framewatch_compare\";\n\n/** `url_a` accepts this instead of a URL, meaning \"whatever framewatch_interact is looking at\". */\nexport const CURRENT_PAGE = \"current\";\n\n/**\n * Either a URL or the literal \"current\". `z.string().url()` cannot express\n * that, so the check is spelled out — and the message says both options,\n * because \"invalid url\" on the word `current` is a confusing thing to read.\n */\nconst sideSchema = z.string().refine((value) => value === CURRENT_PAGE || isUrl(value), {\n message: `must be a URL, or \"${CURRENT_PAGE}\" to use the page framewatch_interact currently has open`,\n});\n\nexport const compareInputShape = {\n url_a: sideSchema.describe(\n `First URL — the \"before\" side. Pass \"${CURRENT_PAGE}\" to compare against the page framewatch_interact has open, ` +\n \"in whatever state your interactions left it.\",\n ),\n url_b: sideSchema.describe('Second URL — the \"after\" side.'),\n wait_ms: z\n .number()\n .int()\n .min(0)\n .default(DEFAULT_COMPARE_WAIT_MS)\n .describe(\"Wait time (ms) after page load before each screenshot\"),\n wait_for: z.string().optional().describe(\"CSS selector to wait for (visible) on both sides before capturing\"),\n wait_for_timeout_ms: z\n .number()\n .int()\n .min(1)\n .default(SELECTOR_TIMEOUT_MS)\n .describe(\"Max time (ms) to wait for `wait_for` to appear (must be > 0)\"),\n viewport: z\n .object({\n width: z.number().int().min(1).max(MAX_VIEWPORT_WIDTH).default(DEFAULT_VIEWPORT.width),\n height: z.number().int().min(1).max(MAX_VIEWPORT_HEIGHT).default(DEFAULT_VIEWPORT.height),\n })\n .optional()\n .describe(\"Viewport for both sides (defaults to 1280x720, or the open page's size when comparing against `current`)\"),\n storage_state: storageStateField,\n};\n\nexport const compareInputSchema = z.object(compareInputShape);\nexport type CompareInput = z.input<typeof compareInputSchema>;\ntype ParsedCompareInput = z.output<typeof compareInputSchema>;\n\n/** One captured side of the comparison. */\ninterface Side {\n png: Buffer;\n /** Where the shot was actually taken (after redirects), or the open page's URL. */\n url: string;\n title?: string;\n}\n\n/**\n * Compare two pages — or the same page before and after a change — and show\n * what moved.\n *\n * Returns both screenshots plus an overlay: side B with every differing pixel\n * tinted, which is the part that turns \"3.4% changed\" into something a reader\n * can act on. The comparison is the same pixel comparison the capture engine\n * uses between frames, so a change region here means what it means there.\n *\n * The two sides are captured one after the other rather than at once, so both\n * get an unloaded machine and the same `wait_ms` means the same thing for\n * each; a difference in the result should come from the pages, not from which\n * of them was competing for the CPU. (Which of the two goes first is decided\n * by `\"current\"` — see below — not by their order in the input.)\n */\nexport async function comparePages(rawInput: CompareInput): Promise<CallToolResult> {\n const parsed = compareInputSchema.safeParse(rawInput);\n if (!parsed.success) {\n const issues = parsed.error.issues.map((i) => `${i.path.join(\".\") || \"input\"}: ${i.message}`).join(\"; \");\n return errorResult(`Compare failed: invalid input — ${issues}`);\n }\n const input = parsed.data;\n\n // The open page is the one side that cannot be resized — doing so would\n // change the state being compared — so it is captured first whichever side\n // it is, and its size is what the other side is then captured at. Frames of\n // two different sizes cannot be compared pixel for pixel at all.\n const openIsB = input.url_b === CURRENT_PAGE && input.url_a !== CURRENT_PAGE;\n const [firstSide, secondSide] = openIsB ? [input.url_b, input.url_a] : [input.url_a, input.url_b];\n\n try {\n // Both URL sides get the same saved auth: they are two views of one app,\n // and a comparison where only one side is signed in compares the login\n // screen with the app. (\"current\" is read as it is, never reloaded.)\n const storageState = input.storage_state ? await readStorageState(input.storage_state) : undefined;\n\n const first = await captureSide(input, firstSide, undefined, storageState);\n const notes: string[] = [];\n let viewport = input.viewport ?? { ...DEFAULT_VIEWPORT };\n\n if (firstSide === CURRENT_PAGE) {\n const open = await sizeOf(first.png);\n if (input.viewport && (input.viewport.width !== open.width || input.viewport.height !== open.height)) {\n notes.push(\n `Ignored \\`viewport\\` ${input.viewport.width}x${input.viewport.height}: the open page is ` +\n `${open.width}x${open.height} and resizing it would change the state being compared. ` +\n \"Both sides were captured at the open page's size.\",\n );\n }\n viewport = open;\n }\n\n const second = await captureSide(input, secondSide, viewport, storageState);\n const [a, b] = openIsB ? [second, first] : [first, second];\n return await render(input, a, b, notes);\n } catch (error) {\n return errorResult(describeCompareFailure(input, error));\n }\n}\n\n/**\n * Screenshot one side.\n *\n * A URL gets a fresh context, so nothing from the other side (or from an\n * earlier tool call) can leak into it. \"current\" instead reads the page\n * `framewatch_interact` has open, *without* touching it: the whole point of\n * that option is to compare a hand-built state — three clicks deep into a\n * flow — against a plain URL, and reloading or resizing it would destroy the\n * very thing being compared.\n */\nasync function captureSide(\n input: ParsedCompareInput,\n side: string,\n viewport?: Viewport,\n storageState?: StorageState,\n): Promise<Side> {\n if (side === CURRENT_PAGE) {\n // Under the session lock: an interaction running in parallel would\n // otherwise be screenshotted half way through.\n return withSessionLock(async () => {\n const { page } = await getSessionPage();\n if (page.url() === \"about:blank\") {\n throw new Error(\n `no page is open, so there is no \"${CURRENT_PAGE}\" state to compare — ` +\n \"use framewatch_interact first, or pass a URL here.\",\n );\n }\n return { png: await page.screenshot({ type: \"png\" }), url: page.url(), title: await safeTitle(page) };\n });\n }\n\n const options = {\n viewport: viewport ?? input.viewport ?? { ...DEFAULT_VIEWPORT },\n ...(storageState ? { contextOptions: { storageState } } : {}),\n };\n return withPage(options, async (page) => {\n await page.goto(side, { waitUntil: \"load\", timeout: NAVIGATION_TIMEOUT_MS });\n if (input.wait_for) {\n await page.waitForSelector(input.wait_for, { state: \"visible\", timeout: input.wait_for_timeout_ms });\n }\n if (input.wait_ms > 0) {\n await page.waitForTimeout(input.wait_ms);\n }\n return { png: await page.screenshot({ type: \"png\" }), url: page.url(), title: await safeTitle(page) };\n });\n}\n\n/**\n * Build the result: a summary, both frames, and (when the two are comparable\n * and actually differ) the overlay.\n *\n * Sides of different sizes are reported as such rather than being stretched to\n * match. Rescaling one of them would resample every pixel in it, and the\n * \"differences\" that came back would be the resampling, not the pages.\n */\nasync function render(input: ParsedCompareInput, a: Side, b: Side, notes: string[]): Promise<CallToolResult> {\n const [grayA, grayB] = await Promise.all([toGrayscale(a.png), toGrayscale(b.png)]);\n const nameA = describeSide(input.url_a, a);\n const nameB = describeSide(input.url_b, b);\n const sameSize = grayA.width === grayB.width && grayA.height === grayB.height;\n\n const lines: string[] = [];\n let overlay: Buffer | undefined;\n let overlayNote = \"\";\n\n if (!sameSize) {\n lines.push(\n `Compared ${nameA} against ${nameB} — the two frames are different sizes ` +\n `(${grayA.width}x${grayA.height} vs ${grayB.width}x${grayB.height}), so they cannot be compared pixel ` +\n \"for pixel. Both are below.\",\n );\n } else {\n const diff = computePixelMask(grayA.data, grayB.data, grayA.width, grayA.height);\n const region: BoundingBox | null =\n diff.bbox === null ? null : padBoundingBox(diff.bbox, CROP_PADDING_PX, grayA.width, grayA.height);\n\n lines.push(\n `Compared ${nameA} against ${nameB} at ${grayA.width}x${grayA.height} — ` +\n `${diff.changePercent.toFixed(2)}% of pixels differ` +\n (region === null\n ? \". The two are pixel-identical.\"\n : `, all of it within ${region.x},${region.y} ${region.width}x${region.height}.`),\n );\n\n if (region !== null) {\n overlay = await resizeForOutput(await overlayMask(b.png, diff.mask, grayA.width, grayA.height));\n overlayNote =\n `Diff overlay — B with every differing pixel tinted. ${diff.changedPixels} of ${diff.totalPixels} ` +\n `pixels changed (${diff.changePercent.toFixed(2)}%), within ` +\n `${region.x},${region.y} ${region.width}x${region.height}.`;\n }\n }\n\n const content: CallToolResult[\"content\"] = [{ type: \"text\", text: [...lines, ...notes].join(\"\\n\") }];\n await pushFrame(content, a.png, `A — ${nameA}`);\n await pushFrame(content, b.png, `B — ${nameB}`);\n if (overlay) {\n content.push({ type: \"image\", data: toBase64(overlay), mimeType: \"image/png\" });\n content.push({ type: \"text\", text: overlayNote });\n }\n return { content };\n}\n\nasync function pushFrame(content: CallToolResult[\"content\"], png: Buffer, label: string): Promise<void> {\n const resized = await resizeForOutput(png);\n const { width, height } = await getDimensions(resized);\n content.push({ type: \"image\", data: toBase64(resized), mimeType: \"image/png\" });\n content.push({ type: \"text\", text: `${label} — image ${width}x${height}` });\n}\n\n/** How a side is named in the output: where it ended up, and its title if it has one. */\nfunction describeSide(requested: string, side: Side): string {\n const where = requested === CURRENT_PAGE ? `the open page (${side.url})` : side.url;\n return side.title ? `${where} \"${side.title}\"` : where;\n}\n\n/** Cosmetic, and never allowed to fail or stall: a busy page still gets compared. */\nasync function safeTitle(page: Page): Promise<string | undefined> {\n return Promise.race([\n page.title().catch(() => undefined),\n new Promise<undefined>((resolve) => setTimeout(() => resolve(undefined), PAGE_INFO_TIMEOUT_MS)),\n ]);\n}\n\nasync function sizeOf(png: Buffer): Promise<Viewport> {\n const { width, height } = await getDimensions(png);\n return { width, height };\n}\n\nfunction isUrl(value: string): boolean {\n try {\n new URL(value);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction errorResult(text: string): CallToolResult {\n return { isError: true, content: [{ type: \"text\", text }] };\n}\n\n/**\n * One actionable line for a failed comparison. Mirrors `describeFailure` in\n * screenshot.ts, with one addition: a `page.goto` failure names which of the\n * two sides could not be opened, which is the first thing you want to know.\n */\nexport function describeCompareFailure(\n input: Pick<ParsedCompareInput, \"url_a\" | \"url_b\" | \"wait_for\" | \"wait_for_timeout_ms\">,\n error: unknown,\n): string {\n const message = error instanceof Error ? error.message : String(error);\n const firstLine = message.split(\"\\n\")[0];\n const prefix = \"Compare failed:\";\n\n if (/Executable doesn't exist|browserType\\.launch/i.test(message)) {\n return (\n `${prefix} Playwright's Chromium browser is not installed. ` +\n `Run \\`npx playwright install chromium\\` and try again. (${firstLine})`\n );\n }\n if (/^page\\.goto:/.test(message)) {\n const side = failingSide(input, message);\n return `${prefix} could not open ${side} — ${firstLine}`;\n }\n if (input.wait_for && /^page\\.waitForSelector:/.test(message)) {\n return `${prefix} selector \"${input.wait_for}\" did not become visible within ${input.wait_for_timeout_ms}ms.`;\n }\n return `${prefix} ${firstLine}`;\n}\n\n/** Playwright quotes the URL it tried in a goto failure; that says which side broke. */\nfunction failingSide(input: Pick<ParsedCompareInput, \"url_a\" | \"url_b\">, message: string): string {\n if (input.url_b !== CURRENT_PAGE && message.includes(input.url_b)) return `url_b (${input.url_b})`;\n if (input.url_a !== CURRENT_PAGE && message.includes(input.url_a)) return `url_a (${input.url_a})`;\n return \"one of the two pages\";\n}\n\nexport function registerCompareTool(server: McpServer): void {\n server.registerTool(\n COMPARE_TOOL_NAME,\n {\n title: \"Compare\",\n description:\n \"Compare two pages — two URLs, or the same URL before and after a code change — and show what moved. \" +\n \"Returns both screenshots, the percentage of pixels that differ, the region they differ in, and an \" +\n `overlay of the second page with every changed pixel tinted. Pass \"${CURRENT_PAGE}\" as \\`url_a\\` to ` +\n \"compare against the page framewatch_interact has open, in whatever state your interactions left it.\",\n inputSchema: compareInputShape,\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },\n },\n async (args) => comparePages(args),\n );\n}\n"]}
@@ -5,6 +5,7 @@ export { registerInteractTool, performInteraction, INTERACT_TOOL_NAME } from "./
5
5
  export { registerResponsiveTool, captureResponsive, RESPONSIVE_TOOL_NAME } from "./responsive.js";
6
6
  export { registerAccessibilityTool, auditAccessibility, ACCESSIBILITY_TOOL_NAME } from "./accessibility.js";
7
7
  export { registerCompareTool, comparePages, COMPARE_TOOL_NAME, CURRENT_PAGE } from "./compare.js";
8
+ export { registerSaveAuthTool, saveAuth, SAVE_AUTH_TOOL_NAME } from "./save-auth.js";
8
9
  export { registerServerTools, startServer, stopServer, START_SERVER_TOOL_NAME, STOP_SERVER_TOOL_NAME, } from "./server.js";
9
10
  /** Register every FrameWatch tool on the given server. */
10
11
  export declare function registerAllTools(server: McpServer): void;
@@ -3,6 +3,7 @@ import { registerCaptureTool } from "./capture.js";
3
3
  import { registerCompareTool } from "./compare.js";
4
4
  import { registerInteractTool } from "./interact.js";
5
5
  import { registerResponsiveTool } from "./responsive.js";
6
+ import { registerSaveAuthTool } from "./save-auth.js";
6
7
  import { registerScreenshotTool } from "./screenshot.js";
7
8
  import { registerServerTools } from "./server.js";
8
9
  export { registerScreenshotTool, takeScreenshot, SCREENSHOT_TOOL_NAME } from "./screenshot.js";
@@ -11,6 +12,7 @@ export { registerInteractTool, performInteraction, INTERACT_TOOL_NAME } from "./
11
12
  export { registerResponsiveTool, captureResponsive, RESPONSIVE_TOOL_NAME } from "./responsive.js";
12
13
  export { registerAccessibilityTool, auditAccessibility, ACCESSIBILITY_TOOL_NAME } from "./accessibility.js";
13
14
  export { registerCompareTool, comparePages, COMPARE_TOOL_NAME, CURRENT_PAGE } from "./compare.js";
15
+ export { registerSaveAuthTool, saveAuth, SAVE_AUTH_TOOL_NAME } from "./save-auth.js";
14
16
  export { registerServerTools, startServer, stopServer, START_SERVER_TOOL_NAME, STOP_SERVER_TOOL_NAME, } from "./server.js";
15
17
  /** Register every FrameWatch tool on the given server. */
16
18
  export function registerAllTools(server) {
@@ -20,6 +22,7 @@ export function registerAllTools(server) {
20
22
  registerResponsiveTool(server);
21
23
  registerAccessibilityTool(server);
22
24
  registerCompareTool(server);
25
+ registerSaveAuthTool(server);
23
26
  registerServerTools(server);
24
27
  }
25
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAClG,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAClG,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,0DAA0D;AAC1D,MAAM,UAAU,gBAAgB,CAAC,MAAiB;IAChD,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/B,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5B,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/B,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAClC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5B,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { registerAccessibilityTool } from \"./accessibility.js\";\nimport { registerCaptureTool } from \"./capture.js\";\nimport { registerCompareTool } from \"./compare.js\";\nimport { registerInteractTool } from \"./interact.js\";\nimport { registerResponsiveTool } from \"./responsive.js\";\nimport { registerScreenshotTool } from \"./screenshot.js\";\nimport { registerServerTools } from \"./server.js\";\n\nexport { registerScreenshotTool, takeScreenshot, SCREENSHOT_TOOL_NAME } from \"./screenshot.js\";\nexport { registerCaptureTool, capturePage, CAPTURE_TOOL_NAME } from \"./capture.js\";\nexport { registerInteractTool, performInteraction, INTERACT_TOOL_NAME } from \"./interact.js\";\nexport { registerResponsiveTool, captureResponsive, RESPONSIVE_TOOL_NAME } from \"./responsive.js\";\nexport { registerAccessibilityTool, auditAccessibility, ACCESSIBILITY_TOOL_NAME } from \"./accessibility.js\";\nexport { registerCompareTool, comparePages, COMPARE_TOOL_NAME, CURRENT_PAGE } from \"./compare.js\";\nexport {\n registerServerTools,\n startServer,\n stopServer,\n START_SERVER_TOOL_NAME,\n STOP_SERVER_TOOL_NAME,\n} from \"./server.js\";\n\n/** Register every FrameWatch tool on the given server. */\nexport function registerAllTools(server: McpServer): void {\n registerScreenshotTool(server);\n registerCaptureTool(server);\n registerInteractTool(server);\n registerResponsiveTool(server);\n registerAccessibilityTool(server);\n registerCompareTool(server);\n registerServerTools(server);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAClG,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAClG,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,0DAA0D;AAC1D,MAAM,UAAU,gBAAgB,CAAC,MAAiB;IAChD,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/B,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5B,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/B,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAClC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5B,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { registerAccessibilityTool } from \"./accessibility.js\";\nimport { registerCaptureTool } from \"./capture.js\";\nimport { registerCompareTool } from \"./compare.js\";\nimport { registerInteractTool } from \"./interact.js\";\nimport { registerResponsiveTool } from \"./responsive.js\";\nimport { registerSaveAuthTool } from \"./save-auth.js\";\nimport { registerScreenshotTool } from \"./screenshot.js\";\nimport { registerServerTools } from \"./server.js\";\n\nexport { registerScreenshotTool, takeScreenshot, SCREENSHOT_TOOL_NAME } from \"./screenshot.js\";\nexport { registerCaptureTool, capturePage, CAPTURE_TOOL_NAME } from \"./capture.js\";\nexport { registerInteractTool, performInteraction, INTERACT_TOOL_NAME } from \"./interact.js\";\nexport { registerResponsiveTool, captureResponsive, RESPONSIVE_TOOL_NAME } from \"./responsive.js\";\nexport { registerAccessibilityTool, auditAccessibility, ACCESSIBILITY_TOOL_NAME } from \"./accessibility.js\";\nexport { registerCompareTool, comparePages, COMPARE_TOOL_NAME, CURRENT_PAGE } from \"./compare.js\";\nexport { registerSaveAuthTool, saveAuth, SAVE_AUTH_TOOL_NAME } from \"./save-auth.js\";\nexport {\n registerServerTools,\n startServer,\n stopServer,\n START_SERVER_TOOL_NAME,\n STOP_SERVER_TOOL_NAME,\n} from \"./server.js\";\n\n/** Register every FrameWatch tool on the given server. */\nexport function registerAllTools(server: McpServer): void {\n registerScreenshotTool(server);\n registerCaptureTool(server);\n registerInteractTool(server);\n registerResponsiveTool(server);\n registerAccessibilityTool(server);\n registerCompareTool(server);\n registerSaveAuthTool(server);\n registerServerTools(server);\n}\n"]}