cdp-mcp 0.2.1 → 0.4.0

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 (96) hide show
  1. package/README.md +28 -303
  2. package/bin.js +23 -0
  3. package/contract.d.ts +1 -0
  4. package/contract.js +2 -0
  5. package/index.d.ts +1 -0
  6. package/index.js +2 -0
  7. package/package.json +31 -73
  8. package/dist/contract.d.ts +0 -11
  9. package/dist/contract.js +0 -11
  10. package/dist/contract.js.map +0 -1
  11. package/dist/index.d.ts +0 -18
  12. package/dist/index.js +0 -402
  13. package/dist/index.js.map +0 -1
  14. package/dist/locator.d.ts +0 -108
  15. package/dist/locator.js +0 -176
  16. package/dist/locator.js.map +0 -1
  17. package/dist/server.d.ts +0 -2
  18. package/dist/server.js +0 -41
  19. package/dist/server.js.map +0 -1
  20. package/dist/session/browser.d.ts +0 -29
  21. package/dist/session/browser.js +0 -409
  22. package/dist/session/browser.js.map +0 -1
  23. package/dist/session/buffers.d.ts +0 -48
  24. package/dist/session/buffers.js +0 -43
  25. package/dist/session/buffers.js.map +0 -1
  26. package/dist/session/pause.d.ts +0 -21
  27. package/dist/session/pause.js +0 -99
  28. package/dist/session/pause.js.map +0 -1
  29. package/dist/session/state.d.ts +0 -53
  30. package/dist/session/state.js +0 -93
  31. package/dist/session/state.js.map +0 -1
  32. package/dist/sourcemap/loader.d.ts +0 -4
  33. package/dist/sourcemap/loader.js +0 -138
  34. package/dist/sourcemap/loader.js.map +0 -1
  35. package/dist/sourcemap/normalize.d.ts +0 -2
  36. package/dist/sourcemap/normalize.js +0 -59
  37. package/dist/sourcemap/normalize.js.map +0 -1
  38. package/dist/sourcemap/store.d.ts +0 -57
  39. package/dist/sourcemap/store.js +0 -185
  40. package/dist/sourcemap/store.js.map +0 -1
  41. package/dist/tools/_locator_runtime.d.ts +0 -31
  42. package/dist/tools/_locator_runtime.js +0 -243
  43. package/dist/tools/_locator_runtime.js.map +0 -1
  44. package/dist/tools/_register.d.ts +0 -2
  45. package/dist/tools/_register.js +0 -30
  46. package/dist/tools/_register.js.map +0 -1
  47. package/dist/tools/breakpoints.d.ts +0 -4
  48. package/dist/tools/breakpoints.js +0 -164
  49. package/dist/tools/breakpoints.js.map +0 -1
  50. package/dist/tools/console.d.ts +0 -2
  51. package/dist/tools/console.js +0 -48
  52. package/dist/tools/console.js.map +0 -1
  53. package/dist/tools/dom.d.ts +0 -2
  54. package/dist/tools/dom.js +0 -309
  55. package/dist/tools/dom.js.map +0 -1
  56. package/dist/tools/execution.d.ts +0 -29
  57. package/dist/tools/execution.js +0 -89
  58. package/dist/tools/execution.js.map +0 -1
  59. package/dist/tools/forms.d.ts +0 -8
  60. package/dist/tools/forms.js +0 -256
  61. package/dist/tools/forms.js.map +0 -1
  62. package/dist/tools/inspect.d.ts +0 -2
  63. package/dist/tools/inspect.js +0 -178
  64. package/dist/tools/inspect.js.map +0 -1
  65. package/dist/tools/nav.d.ts +0 -2
  66. package/dist/tools/nav.js +0 -136
  67. package/dist/tools/nav.js.map +0 -1
  68. package/dist/tools/network.d.ts +0 -2
  69. package/dist/tools/network.js +0 -137
  70. package/dist/tools/network.js.map +0 -1
  71. package/dist/tools/session.d.ts +0 -2
  72. package/dist/tools/session.js +0 -76
  73. package/dist/tools/session.js.map +0 -1
  74. package/dist/tools/source.d.ts +0 -2
  75. package/dist/tools/source.js +0 -63
  76. package/dist/tools/source.js.map +0 -1
  77. package/dist/tools/storage.d.ts +0 -2
  78. package/dist/tools/storage.js +0 -296
  79. package/dist/tools/storage.js.map +0 -1
  80. package/dist/util/browser-resolve.d.ts +0 -19
  81. package/dist/util/browser-resolve.js +0 -263
  82. package/dist/util/browser-resolve.js.map +0 -1
  83. package/dist/util/errors.d.ts +0 -7
  84. package/dist/util/errors.js +0 -12
  85. package/dist/util/errors.js.map +0 -1
  86. package/dist/util/format.d.ts +0 -20
  87. package/dist/util/format.js +0 -65
  88. package/dist/util/format.js.map +0 -1
  89. package/dist/util/log.d.ts +0 -6
  90. package/dist/util/log.js +0 -34
  91. package/dist/util/log.js.map +0 -1
  92. package/docs/chromium-sandboxing.md +0 -197
  93. package/docs/known-chromium-gaps.md +0 -138
  94. package/docs/launchd-service.md +0 -217
  95. package/docs/local-l3-e2e-setup.md +0 -199
  96. package/docs/systemd-service.md +0 -233
@@ -1,164 +0,0 @@
1
- import { z } from "zod";
2
- import { requireSession, ROOT_SESSION_KEY } from "../session/state.js";
3
- import { mapOriginalToGenerated, mapCdpToOriginal } from "../sourcemap/store.js";
4
- import { ToolError } from "../util/errors.js";
5
- import { registerJsonTool } from "./_register.js";
6
- // Look up an existing breakpoint by normalized (file, line, column). Column
7
- // is always a number here — the caller is responsible for collapsing an
8
- // omitted or undefined `input.column` to 0 before calling, matching the
9
- // `input.column ?? 0` shape that mapOriginalToGenerated and list_breakpoints
10
- // already use. If the three normalizations ever diverge, set_breakpoint's
11
- // idempotent path silently breaks (see PR #20 review).
12
- function findBreakpointAt(breakpoints, file, line, column) {
13
- for (const r of breakpoints.values()) {
14
- if (r.file === file && r.line === line && (r.column ?? 0) === column)
15
- return r;
16
- }
17
- return undefined;
18
- }
19
- function breakpointEnvelope(r, status) {
20
- return {
21
- id: r.id,
22
- resolved_locations: r.resolvedLocations,
23
- binding_count: r.bindings.length,
24
- sessions_bound: Array.from(new Set(r.bindings.map((b) => b.sessionId ?? ROOT_SESSION_KEY))),
25
- status,
26
- };
27
- }
28
- export function registerBreakpointTools(server) {
29
- registerJsonTool(server, "set_breakpoint", 'Set a breakpoint in TypeScript source. Resolves matching scripts via source maps (including in workers and iframes) and binds in each one\'s session. Returns the resolved JS->TS locations. Idempotent: re-calling with identical (file, line, column, condition, log_message) returns the existing breakpoint id with status: "already-set". Same location with a different condition/log_message returns error: "breakpoint_conflict" — remove the existing breakpoint first.', {
30
- file: z.string().describe("TS file path or fragment (e.g. src/foo.ts)"),
31
- line: z.number().int().positive().describe("1-based"),
32
- column: z.number().int().nonnegative().optional(),
33
- condition: z.string().optional().describe("Expression — pause only when truthy"),
34
- log_message: z.string().optional().describe("Logpoint: log instead of pausing"),
35
- }, async (input) => {
36
- const s = requireSession();
37
- // Normalize once at the top so lookup, mapping, and storage cannot
38
- // drift. column collapses `undefined` and omitted to 0 — matching what
39
- // mapOriginalToGenerated and list_breakpoints already do. condition /
40
- // logMessage truthy-normalize so the empty string and undefined match.
41
- const file = input.file;
42
- const line = input.line;
43
- const column = input.column ?? 0;
44
- const condition = input.condition || undefined;
45
- const logMessage = input.log_message || undefined;
46
- const existing = findBreakpointAt(s.breakpoints, file, line, column);
47
- if (existing) {
48
- if (existing.condition === condition && existing.logMessage === logMessage) {
49
- return breakpointEnvelope(existing, "already-set");
50
- }
51
- const locStr = `${file}:${line}:${column}`;
52
- throw new ToolError("breakpoint_conflict", `Breakpoint already exists at ${locStr} (id ${existing.id}) with a different condition or log_message. Remove it first (remove_breakpoint) before setting a new one.`);
53
- }
54
- const candidates = mapOriginalToGenerated(s.scripts, file, line, column);
55
- if (candidates.length === 0) {
56
- throw new ToolError("no_mapping", `No source-mapped script matches '${file}:${line}'. Try list_scripts to confirm what's loaded.`);
57
- }
58
- const id = s.nextBpId();
59
- const bindings = [];
60
- const resolved = [];
61
- const conditionExpr = buildConditionExpression(condition, logMessage);
62
- for (const c of candidates) {
63
- // Use the exact `url` field rather than `urlRegex`. CDP's regex is
64
- // unanchored — `http://localhost/main.js` as a urlRegex also matches
65
- // `http://localhost/main.js?v=2`, `…?vue&type=template`, etc.
66
- const params = {
67
- url: c.scriptUrl,
68
- lineNumber: c.lineNumber,
69
- columnNumber: c.columnNumber,
70
- ...(conditionExpr ? { condition: conditionExpr } : {}),
71
- };
72
- const res = await s.client.send("Debugger.setBreakpointByUrl", params, c.sessionId);
73
- bindings.push({ cdpId: res.breakpointId, ...(c.sessionId ? { sessionId: c.sessionId } : {}) });
74
- for (const loc of res.locations) {
75
- const orig = mapCdpToOriginal(s.scripts, loc, c.sessionId);
76
- if (orig)
77
- resolved.push(orig);
78
- else
79
- resolved.push({ file: c.scriptUrl, line: loc.lineNumber + 1, column: loc.columnNumber ?? 0 });
80
- }
81
- }
82
- const record = {
83
- id,
84
- file,
85
- line,
86
- column,
87
- ...(condition ? { condition } : {}),
88
- ...(logMessage ? { logMessage } : {}),
89
- resolvedLocations: resolved,
90
- bindings,
91
- };
92
- s.breakpoints.set(id, record);
93
- return breakpointEnvelope(record, "set");
94
- });
95
- registerJsonTool(server, "remove_breakpoint", "Remove a breakpoint by ID (returned from set_breakpoint).", { id: z.string() }, async (input) => {
96
- const s = requireSession();
97
- const rec = s.breakpoints.get(input.id);
98
- if (!rec)
99
- throw new ToolError("not_found", `No breakpoint with id ${input.id}`);
100
- for (const b of rec.bindings) {
101
- try {
102
- await s.client.send("Debugger.removeBreakpoint", { breakpointId: b.cdpId }, b.sessionId);
103
- }
104
- catch {
105
- /* ignore — session may already be gone */
106
- }
107
- }
108
- s.breakpoints.delete(input.id);
109
- return "removed";
110
- });
111
- registerJsonTool(server, "list_breakpoints", "List all currently active breakpoints.", undefined, async () => {
112
- const s = requireSession();
113
- return Array.from(s.breakpoints.values()).map((bp) => ({
114
- id: bp.id,
115
- file: bp.file,
116
- line: bp.line,
117
- column: bp.column ?? 0,
118
- condition: bp.condition,
119
- log_message: bp.logMessage,
120
- resolved_locations: bp.resolvedLocations,
121
- binding_count: bp.bindings.length,
122
- }));
123
- });
124
- registerJsonTool(server, "set_pause_on_exceptions", "Configure whether the debugger pauses on exceptions. Applies to the root AND all currently-attached child sessions (workers/iframes/service workers), and is remembered so newly-attached children inherit the setting.", {
125
- state: z.enum(["none", "uncaught", "all"]),
126
- }, async (input) => {
127
- const s = requireSession();
128
- // Persist so onChildAttached can replay to future attachments.
129
- s.pauseOnExceptions = input.state;
130
- // Apply to every currently-attached session. ROOT_SESSION_KEY → undefined
131
- // for the CDP call; child keys are the literal sessionId.
132
- const targetSessions = [];
133
- for (const key of s.sessionHandlers.keys()) {
134
- targetSessions.push(key === ROOT_SESSION_KEY ? undefined : key);
135
- }
136
- if (targetSessions.length === 0)
137
- targetSessions.push(undefined); // safety net
138
- const results = await Promise.allSettled(targetSessions.map((sid) => s.client.send("Debugger.setPauseOnExceptions", { state: input.state }, sid)));
139
- const failures = results
140
- .map((r, i) => (r.status === "rejected" ? { sid: targetSessions[i] ?? "__root__", error: String(r.reason) } : null))
141
- .filter((x) => x !== null);
142
- return {
143
- state: input.state,
144
- sessions_applied: targetSessions.length - failures.length,
145
- failures,
146
- };
147
- });
148
- }
149
- // Combine an optional `condition` predicate with an optional `logMessage`.
150
- // Logpoint: emit a console.log and never pause (`false` short-circuits).
151
- /** @internal exported for unit tests; not part of the MCP tool surface. */
152
- export function buildConditionExpression(condition, logMessage) {
153
- if (!condition && !logMessage)
154
- return undefined;
155
- if (logMessage) {
156
- const tmpl = JSON.stringify(logMessage);
157
- const log = `console.log(${tmpl}.replace(/\\{([^}]+)\\}/g, (m, expr) => { try { return String(eval(expr)); } catch (e) { return "{" + expr + "=?}"; } }))`;
158
- if (condition)
159
- return `(${condition}) && (${log}, false)`;
160
- return `(${log}, false)`;
161
- }
162
- return condition;
163
- }
164
- //# sourceMappingURL=breakpoints.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"breakpoints.js","sourceRoot":"","sources":["../../src/tools/breakpoints.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAiD,MAAM,qBAAqB,CAAC;AACtH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,4EAA4E;AAC5E,wEAAwE;AACxE,wEAAwE;AACxE,6EAA6E;AAC7E,0EAA0E;AAC1E,uDAAuD;AACvD,SAAS,gBAAgB,CACvB,WAA0C,EAC1C,IAA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eAAe,IAAI,2HAA2H,CAAC;QAC3J,IAAI,SAAS;YAAE,OAAO,IAAI,SAAS,SAAS,GAAG,UAAU,CAAC;QAC1D,OAAO,IAAI,GAAG,UAAU,CAAC;IAC3B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,2 +0,0 @@
1
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- export declare function registerConsoleTools(server: McpServer): void;
@@ -1,48 +0,0 @@
1
- import { z } from "zod";
2
- import { requireSession } from "../session/state.js";
3
- import { truncate } from "../util/format.js";
4
- import { registerJsonTool } from "./_register.js";
5
- const LEVELS = ["log", "info", "warn", "error", "debug", "trace", "verbose"];
6
- export function registerConsoleTools(server) {
7
- registerJsonTool(server, "get_console_logs", "Query the buffered console + uncaught-exception stream. Paginate with `since` (the seq from the last call).", {
8
- since: z.number().int().nonnegative().optional(),
9
- level: z.enum(LEVELS).optional(),
10
- search: z.string().optional().describe("Substring filter on message text"),
11
- limit: z.number().int().positive().optional(),
12
- }, async (input) => {
13
- const s = requireSession();
14
- const search = input.search?.toLowerCase();
15
- const items = s.console.query({
16
- since: input.since ?? 0,
17
- limit: input.limit ?? 100,
18
- filter: (e) => {
19
- if (input.level && e.level !== input.level)
20
- return false;
21
- if (search && !e.text.toLowerCase().includes(search))
22
- return false;
23
- return true;
24
- },
25
- });
26
- return {
27
- cursor: items.length ? items[items.length - 1].seq : input.since ?? 0,
28
- items: items.map((e) => ({
29
- seq: e.seq,
30
- ts: e.ts,
31
- level: e.level,
32
- source: e.source,
33
- text: truncate(e.text, 1000),
34
- file: e.mappedFile,
35
- line: e.mappedLine,
36
- column: e.mappedColumn,
37
- js_url: e.url,
38
- js_line: e.lineNumber != null ? e.lineNumber + 1 : undefined,
39
- })),
40
- };
41
- });
42
- registerJsonTool(server, "clear_console", "Clear the buffered console stream (does not clear the browser's own console).", undefined, async () => {
43
- const s = requireSession();
44
- s.console.clear();
45
- return "cleared";
46
- });
47
- }
48
- //#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,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,SAAS,CAAC;IACnB,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1,2 +0,0 @@
1
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- export declare function registerDomTools(server: McpServer): void;
package/dist/tools/dom.js DELETED
@@ -1,309 +0,0 @@
1
- import { z } from "zod";
2
- import { writeFile } from "node:fs/promises";
3
- import { requireSession } from "../session/state.js";
4
- import { ToolError } from "../util/errors.js";
5
- import { registerJsonTool } from "./_register.js";
6
- import { locatorShape } from "../locator.js";
7
- import { normalizeLocator, locatorHelpersScript, locatorReadScript } from "./_locator_runtime.js";
8
- const waitStateSchema = z.enum(["visible", "hidden", "attached", "detached"]);
9
- export function registerDomTools(server) {
10
- registerJsonTool(server, "query_selector", "Find an element by CSS selector. Returns nodeId + a short preview.", { selector: z.string() }, async (input) => {
11
- const s = requireSession();
12
- const doc = await s.client.send("DOM.getDocument", { depth: 1 });
13
- const found = await s.client.send("DOM.querySelector", {
14
- nodeId: doc.root.nodeId,
15
- selector: input.selector,
16
- });
17
- if (!found.nodeId)
18
- return { found: false };
19
- const desc = await s.client.send("DOM.describeNode", { nodeId: found.nodeId, depth: 0 });
20
- return {
21
- found: true,
22
- node_id: found.nodeId,
23
- tag: desc.node.nodeName?.toLowerCase(),
24
- attrs: pairsToObj(desc.node.attributes ?? []),
25
- text_preview: (desc.node.nodeValue ?? "").slice(0, 200),
26
- backend_node_id: desc.node.backendNodeId,
27
- };
28
- });
29
- registerJsonTool(server, "get_element_html", "Get the outer (or inner) HTML for an element.", {
30
- selector: z.string().optional(),
31
- node_id: z.number().int().positive().optional(),
32
- outer: z.boolean().optional().describe("Default true"),
33
- }, async (input) => {
34
- const s = requireSession();
35
- let nodeId = input.node_id;
36
- if (!nodeId) {
37
- if (!input.selector)
38
- throw new ToolError("missing_arg", "selector or node_id required");
39
- const doc = await s.client.send("DOM.getDocument", { depth: 1 });
40
- const found = await s.client.send("DOM.querySelector", {
41
- nodeId: doc.root.nodeId,
42
- selector: input.selector,
43
- });
44
- if (!found.nodeId)
45
- throw new ToolError("not_found", `No element matches ${input.selector}`);
46
- nodeId = found.nodeId;
47
- }
48
- const outer = input.outer ?? true;
49
- const html = await s.client.send("DOM.getOuterHTML", { nodeId });
50
- if (outer)
51
- return { node_id: nodeId, html: html.outerHTML };
52
- // CDP has no direct innerHTML — derive it.
53
- const wrapper = html.outerHTML.replace(/^<[^>]+>/, "").replace(/<\/[^>]+>$/, "");
54
- return { node_id: nodeId, html: wrapper };
55
- });
56
- registerJsonTool(server, "locate", "Find elements with a structured LocatorSpec, e.g. { by: 'role', role: 'button', name: 'Submit' }.", {
57
- ...locatorShape,
58
- include_hidden: z.boolean().optional().describe("Default false: only return visible matches."),
59
- limit: z.number().int().positive().max(100).optional().describe("Default 20."),
60
- }, async (input) => {
61
- const locator = normalizeLocator(input);
62
- const result = await evaluateLocator(locator, {
63
- includeHidden: input.include_hidden ?? false,
64
- limit: input.limit ?? 20,
65
- });
66
- if (!result.ok)
67
- throw new ToolError("invalid_locator", result.error ?? "Invalid locator");
68
- return result;
69
- });
70
- registerJsonTool(server, "wait_for", "Poll until a structured LocatorSpec reaches the requested DOM state.", {
71
- ...locatorShape,
72
- state: waitStateSchema.optional().describe("Default visible."),
73
- timeout_ms: z.number().int().positive().optional().describe("Default 5000."),
74
- interval_ms: z.number().int().positive().optional().describe("Default 100."),
75
- }, async (input) => {
76
- const locator = normalizeLocator(input);
77
- const state = input.state ?? "visible";
78
- const timeoutMs = input.timeout_ms ?? 5000;
79
- const intervalMs = input.interval_ms ?? 100;
80
- const started = Date.now();
81
- let lastResult = null;
82
- while (Date.now() - started <= timeoutMs) {
83
- lastResult = await evaluateLocator(locator, { includeHidden: true, limit: 20 });
84
- if (!lastResult.ok)
85
- throw new ToolError("invalid_locator", lastResult.error ?? "Invalid locator");
86
- if (matchesWaitState(lastResult, state)) {
87
- return {
88
- state,
89
- elapsed_ms: Date.now() - started,
90
- locator,
91
- result: lastResult,
92
- };
93
- }
94
- await delay(Math.min(intervalMs, Math.max(1, timeoutMs - (Date.now() - started))));
95
- }
96
- throw new ToolError("timeout", `Timed out after ${timeoutMs}ms waiting for ${describeLocator(locator)} to be ${state}; last count=${lastResult?.count ?? 0}, visible=${lastResult?.visible_count ?? 0}`);
97
- });
98
- registerJsonTool(server, "get_form_state", "Read named form fields using [name=\"...\"] selectors. Omit names to read every named control in the form/page.", {
99
- names: z.array(z.string()).optional(),
100
- form_selector: z.string().optional().describe("Optional CSS selector for the form or container to inspect."),
101
- }, async (input) => {
102
- const s = requireSession();
103
- const res = await s.client.send("Runtime.evaluate", {
104
- expression: buildFormStateExpression(input),
105
- returnByValue: true,
106
- });
107
- const value = res.result.value;
108
- if (!value.ok)
109
- throw new ToolError("invalid_selector", value.error ?? "Unable to read form state");
110
- return value;
111
- });
112
- registerJsonTool(server, "click", "Click an element matched by CSS selector. Uses synthetic input events.", { selector: z.string() }, async (input) => {
113
- const s = requireSession();
114
- const expr = `(() => {
115
- const el = document.querySelector(${JSON.stringify(input.selector)});
116
- if (!el) return { ok: false, error: "no match" };
117
- el.scrollIntoView({ block: "center", inline: "center" });
118
- const r = el.getBoundingClientRect();
119
- return { ok: true, x: r.left + r.width / 2, y: r.top + r.height / 2 };
120
- })()`;
121
- const res = await s.client.send("Runtime.evaluate", {
122
- expression: expr,
123
- returnByValue: true,
124
- });
125
- const v = res.result.value;
126
- if (!v.ok)
127
- throw new ToolError("not_found", `click: ${v.error ?? "unknown"}`);
128
- const x = v.x;
129
- const y = v.y;
130
- await s.client.send("Input.dispatchMouseEvent", { type: "mouseMoved", x, y });
131
- await s.client.send("Input.dispatchMouseEvent", { type: "mousePressed", x, y, button: "left", clickCount: 1 });
132
- await s.client.send("Input.dispatchMouseEvent", { type: "mouseReleased", x, y, button: "left", clickCount: 1 });
133
- return { clicked: input.selector, x, y };
134
- });
135
- registerJsonTool(server, "type_text", "Focus a CSS-selected element and type text into it.", { selector: z.string(), text: z.string(), clear_first: z.boolean().optional() }, async (input) => {
136
- const s = requireSession();
137
- const focus = await s.client.send("Runtime.evaluate", {
138
- expression: `(() => {
139
- const el = document.querySelector(${JSON.stringify(input.selector)});
140
- if (!el) return false;
141
- el.focus();
142
- ${input.clear_first ? "if ('value' in el) el.value = '';" : ""}
143
- return true;
144
- })()`,
145
- returnByValue: true,
146
- });
147
- if (focus.result.value !== true)
148
- throw new ToolError("not_found", `type_text: ${input.selector}`);
149
- await s.client.send("Input.insertText", { text: input.text });
150
- return { typed: input.text.length, into: input.selector };
151
- });
152
- registerJsonTool(server, "press_key", "Send a key press to the focused element (e.g. Enter, Tab, Escape).", { key: z.string() }, async (input) => {
153
- const s = requireSession();
154
- await s.client.send("Input.dispatchKeyEvent", { type: "keyDown", key: input.key });
155
- await s.client.send("Input.dispatchKeyEvent", { type: "keyUp", key: input.key });
156
- return { pressed: input.key };
157
- });
158
- registerJsonTool(server, "screenshot", "Take a screenshot of the current page. Returns base64 PNG by default, or saves to a file.", {
159
- full_page: z.boolean().optional(),
160
- path: z.string().optional().describe("If set, save to this absolute path and return path instead of base64"),
161
- format: z.enum(["png", "jpeg"]).optional(),
162
- quality: z.number().int().min(1).max(100).optional(),
163
- }, async (input) => {
164
- const s = requireSession();
165
- const r = await s.client.send("Page.captureScreenshot", {
166
- format: input.format ?? "png",
167
- ...(input.quality && input.format === "jpeg" ? { quality: input.quality } : {}),
168
- captureBeyondViewport: !!input.full_page,
169
- });
170
- if (input.path) {
171
- await writeFile(input.path, Buffer.from(r.data, "base64"));
172
- return { saved: input.path, bytes: r.data.length };
173
- }
174
- return { format: input.format ?? "png", base64: r.data };
175
- });
176
- }
177
- function pairsToObj(pairs) {
178
- const out = {};
179
- for (let i = 0; i < pairs.length; i += 2) {
180
- out[pairs[i] ?? ""] = pairs[i + 1] ?? "";
181
- }
182
- return out;
183
- }
184
- async function evaluateLocator(locator, options) {
185
- const s = requireSession();
186
- const res = await s.client.send("Runtime.evaluate", {
187
- expression: buildLocateExpression(locator, options),
188
- returnByValue: true,
189
- });
190
- return res.result.value;
191
- }
192
- function matchesWaitState(result, state) {
193
- switch (state) {
194
- case "visible":
195
- return result.visible_count > 0;
196
- case "attached":
197
- return result.count > 0;
198
- case "hidden":
199
- return result.count === 0 || result.visible_count === 0;
200
- case "detached":
201
- return result.count === 0;
202
- }
203
- }
204
- function delay(ms) {
205
- return new Promise((resolve) => setTimeout(resolve, ms));
206
- }
207
- function describeLocator(locator) {
208
- return JSON.stringify(locator);
209
- }
210
- function buildLocateExpression(locator, options) {
211
- return `(() => {
212
- const spec = ${JSON.stringify(locator)};
213
- const options = ${JSON.stringify(options)};
214
- ${locatorHelpersScript()}${locatorReadScript()}
215
- return locate(spec, options);
216
- })()`;
217
- }
218
- function buildFormStateExpression(input) {
219
- return `(() => {
220
- const input = ${JSON.stringify(input)};
221
- ${formStateRuntimeScript()}
222
- return readFormState(input);
223
- })()`;
224
- }
225
- function formStateRuntimeScript() {
226
- return String.raw `
227
- const compact = (value) => (value || "").replace(/\s+/g, " ").trim();
228
- const isVisible = (el) => {
229
- if (!el.isConnected) return false;
230
- const style = getComputedStyle(el);
231
- if (style.visibility === "hidden" || style.display === "none" || Number(style.opacity) === 0) return false;
232
- const rect = el.getBoundingClientRect();
233
- return rect.width > 0 && rect.height > 0;
234
- };
235
- const controlValue = (el) => {
236
- if (el instanceof HTMLSelectElement) {
237
- if (el.multiple) return Array.from(el.selectedOptions).map((option) => option.value);
238
- return el.value;
239
- }
240
- if (el instanceof HTMLInputElement && el.type === "checkbox") return el.checked;
241
- if (el instanceof HTMLInputElement && el.type === "radio") return el.checked ? el.value : null;
242
- return "value" in el ? el.value : null;
243
- };
244
- const describeControl = (el) => ({
245
- tag: el.tagName.toLowerCase(),
246
- type: el.getAttribute("type") || undefined,
247
- value: controlValue(el),
248
- raw_value: "value" in el ? el.value : undefined,
249
- checked: "checked" in el ? !!el.checked : undefined,
250
- disabled: "disabled" in el ? !!el.disabled : undefined,
251
- visible: isVisible(el),
252
- text: compact(el.innerText || el.textContent || "").slice(0, 200) || undefined,
253
- });
254
- const summarizeGroup = (controls) => {
255
- const radioControls = controls.filter((el) => el instanceof HTMLInputElement && el.type === "radio");
256
- if (radioControls.length > 0) {
257
- const checked = radioControls.find((el) => el.checked);
258
- return {
259
- kind: "radio_group",
260
- value: checked ? checked.value : null,
261
- controls: radioControls.map(describeControl),
262
- };
263
- }
264
- const checkboxControls = controls.filter((el) => el instanceof HTMLInputElement && el.type === "checkbox");
265
- if (checkboxControls.length > 1) {
266
- return {
267
- kind: "checkbox_group",
268
- value: checkboxControls.filter((el) => el.checked).map((el) => el.value),
269
- controls: checkboxControls.map(describeControl),
270
- };
271
- }
272
- return {
273
- kind: controls.length === 1 ? "field" : "field_group",
274
- value: controls.length === 1 ? controlValue(controls[0]) : controls.map(controlValue),
275
- controls: controls.map(describeControl),
276
- };
277
- };
278
- const readFormState = (input) => {
279
- let root = document;
280
- if (input.form_selector) {
281
- try {
282
- root = document.querySelector(input.form_selector);
283
- } catch (error) {
284
- return { ok: false, error: "Invalid form_selector " + input.form_selector + ": " + error.message };
285
- }
286
- if (!root) return { ok: false, error: "No element matches form_selector " + input.form_selector };
287
- }
288
- const controls = Array.from(root.querySelectorAll("input[name], textarea[name], select[name], button[name]"));
289
- const wantedNames = input.names || Array.from(new Set(controls.map((el) => el.getAttribute("name")).filter(Boolean)));
290
- const fields = {};
291
- const missing = [];
292
- for (const name of wantedNames) {
293
- const matches = controls.filter((el) => el.getAttribute("name") === name);
294
- if (matches.length === 0) {
295
- missing.push(name);
296
- continue;
297
- }
298
- fields[name] = summarizeGroup(matches);
299
- }
300
- return {
301
- ok: true,
302
- form_selector: input.form_selector || null,
303
- fields,
304
- missing,
305
- };
306
- };
307
- `;
308
- }
309
- //# sourceMappingURL=dom.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dom.js","sourceRoot":"","sources":["../../src/tools/dom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EA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AC7B,OAAO,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFhB,CAAC;AACJ,CAAC"}
@@ -1,29 +0,0 @@
1
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import type { Protocol } from "devtools-protocol";
3
- import { requireSession } from "../session/state.js";
4
- export declare function registerExecutionTools(server: McpServer): void;
5
- export declare function summarizePause(s: ReturnType<typeof requireSession>, reason: Protocol.Debugger.PausedEvent["reason"], hitBreakpoints: string[] | undefined, data: object | undefined, callFrames: Protocol.Debugger.CallFrame[], sessionId: string | undefined): {
6
- reason: "ambiguous" | "assert" | "CSPViolation" | "debugCommand" | "DOM" | "EventListener" | "exception" | "instrumentation" | "OOM" | "other" | "promiseRejection" | "XHR" | "step";
7
- hit_breakpoint_ids: string[];
8
- session_id: string | null;
9
- data: object | null;
10
- call_stack: {
11
- index: number;
12
- frame_id: string;
13
- session_id: string | null;
14
- function_name: string;
15
- file: string;
16
- line: number;
17
- column: number;
18
- js_url: string | undefined;
19
- js_line: number;
20
- js_column: number;
21
- scope_types: ("catch" | "global" | "local" | "with" | "closure" | "block" | "script" | "eval" | "module" | "wasm-expression-stack")[];
22
- this: {
23
- type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "map" | "error" | "array" | "null" | "node" | "regexp" | "date" | "set" | "weakmap" | "weakset" | "iterator" | "generator" | "proxy" | "promise" | "typedarray" | "arraybuffer" | "dataview" | "webassemblymemory" | "wasmvalue" | "trustedtype";
24
- preview: string;
25
- } | null;
26
- }[];
27
- };
28
- /** @internal exported for unit tests; not part of the MCP tool surface. */
29
- export declare function matchUserBreakpoints(s: ReturnType<typeof requireSession>, hit: string[], pauseSessionId: string | undefined): string[];