cdp-mcp 0.2.2 → 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 -54
  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 -196
  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 -200
  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,200 +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
- // Physical CDP breakpoint identity for a generated location. A breakpoint is
20
- // bound by (sessionId, url, line, col), so two candidates with the same key are
21
- // the same CDP breakpoint. Mirrors the dedup key in mapOriginalToGenerated.
22
- function genKey(g) {
23
- return `${g.sessionId ?? ""}|${g.scriptUrl}|${g.lineNumber}:${g.columnNumber}`;
24
- }
25
- function breakpointEnvelope(r, status) {
26
- return {
27
- id: r.id,
28
- resolved_locations: r.resolvedLocations,
29
- binding_count: r.bindings.length,
30
- sessions_bound: Array.from(new Set(r.bindings.map((b) => b.sessionId ?? ROOT_SESSION_KEY))),
31
- status,
32
- };
33
- }
34
- export function registerBreakpointTools(server) {
35
- 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 at the compiled-location level: re-calling at the same source location — or a different source line the source map collapses onto the same compiled JS position — returns the existing breakpoint id with status: "already-set" (when condition/log_message match). A compiled location already bound with a different condition/log_message, or only partially overlapping an existing breakpoint, returns error: "breakpoint_conflict" — remove the existing breakpoint first.', {
36
- file: z.string().describe("TS file path or fragment (e.g. src/foo.ts)"),
37
- line: z.number().int().positive().describe("1-based"),
38
- column: z.number().int().nonnegative().optional(),
39
- condition: z.string().optional().describe("Expression — pause only when truthy"),
40
- log_message: z.string().optional().describe("Logpoint: log instead of pausing"),
41
- }, async (input) => {
42
- const s = requireSession();
43
- // Normalize once at the top so lookup, mapping, and storage cannot
44
- // drift. column collapses `undefined` and omitted to 0 — matching what
45
- // mapOriginalToGenerated and list_breakpoints already do. condition /
46
- // logMessage truthy-normalize so the empty string and undefined match.
47
- const file = input.file;
48
- const line = input.line;
49
- const column = input.column ?? 0;
50
- const condition = input.condition || undefined;
51
- const logMessage = input.log_message || undefined;
52
- const existing = findBreakpointAt(s.breakpoints, file, line, column);
53
- if (existing) {
54
- if (existing.condition === condition && existing.logMessage === logMessage) {
55
- return breakpointEnvelope(existing, "already-set");
56
- }
57
- const locStr = `${file}:${line}:${column}`;
58
- 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.`);
59
- }
60
- const candidates = mapOriginalToGenerated(s.scripts, file, line, column);
61
- if (candidates.length === 0) {
62
- throw new ToolError("no_mapping", `No source-mapped script matches '${file}:${line}'. Try list_scripts to confirm what's loaded.`);
63
- }
64
- // Generated-layer idempotency. findBreakpointAt() above matches on the
65
- // *TS* coordinate, but two different TS lines can minify to the SAME
66
- // compiled position — and since we bind by `url`, CDP would reject the
67
- // second with "Breakpoint at specified location already exists" (a
68
- // non-recoverable internal_error, issue #24). We detect that against what
69
- // is PHYSICALLY bound — each binding's recorded genKey — not a re-mapping
70
- // of the live ScriptStore: a script that loads after a record was set
71
- // (dynamic import / code-split) must not make us claim coverage that was
72
- // never bound (PR #25 review, finding 1).
73
- const candKeys = candidates.map(genKey);
74
- for (const r of s.breakpoints.values()) {
75
- const boundKeys = new Set(r.bindings.map((b) => b.genKey).filter((k) => k !== undefined));
76
- if (!candKeys.some((k) => boundKeys.has(k)))
77
- continue;
78
- // Full coverage + same condition/log_message → genuinely the same
79
- // breakpoint. Anything else is recoverable conflict, never a silent
80
- // partial bind (finding 2): partial overlap means some candidates would
81
- // still collide in CDP, and a differing condition can't reuse r.
82
- const fullyCovered = candKeys.every((k) => boundKeys.has(k));
83
- if (fullyCovered && r.condition === condition && r.logMessage === logMessage) {
84
- return breakpointEnvelope(r, "already-set");
85
- }
86
- const locStr = `${file}:${line}:${column}`;
87
- const why = fullyCovered
88
- ? "the same compiled location with a different condition or log_message"
89
- : "an overlapping compiled location";
90
- throw new ToolError("breakpoint_conflict", `Breakpoint ${r.id} (${r.file}:${r.line}) already binds ${why} as ${locStr}. Remove it first (remove_breakpoint) before setting a new one.`);
91
- }
92
- const id = s.nextBpId();
93
- const bindings = [];
94
- const resolved = [];
95
- const conditionExpr = buildConditionExpression(condition, logMessage);
96
- for (const c of candidates) {
97
- // Use the exact `url` field rather than `urlRegex`. CDP's regex is
98
- // unanchored — `http://localhost/main.js` as a urlRegex also matches
99
- // `http://localhost/main.js?v=2`, `…?vue&type=template`, etc.
100
- const params = {
101
- url: c.scriptUrl,
102
- lineNumber: c.lineNumber,
103
- columnNumber: c.columnNumber,
104
- ...(conditionExpr ? { condition: conditionExpr } : {}),
105
- };
106
- const res = await s.client.send("Debugger.setBreakpointByUrl", params, c.sessionId);
107
- // Record the requested spec (genKey) so a later set_breakpoint can tell
108
- // a real CDP collision from a stale ScriptStore recompute (PR #25 review).
109
- bindings.push({ cdpId: res.breakpointId, genKey: genKey(c), ...(c.sessionId ? { sessionId: c.sessionId } : {}) });
110
- for (const loc of res.locations) {
111
- const orig = mapCdpToOriginal(s.scripts, loc, c.sessionId);
112
- if (orig)
113
- resolved.push(orig);
114
- else
115
- resolved.push({ file: c.scriptUrl, line: loc.lineNumber + 1, column: loc.columnNumber ?? 0 });
116
- }
117
- }
118
- const record = {
119
- id,
120
- file,
121
- line,
122
- column,
123
- ...(condition ? { condition } : {}),
124
- ...(logMessage ? { logMessage } : {}),
125
- resolvedLocations: resolved,
126
- bindings,
127
- };
128
- s.breakpoints.set(id, record);
129
- return breakpointEnvelope(record, "set");
130
- });
131
- registerJsonTool(server, "remove_breakpoint", "Remove a breakpoint by ID (returned from set_breakpoint).", { id: z.string() }, async (input) => {
132
- const s = requireSession();
133
- const rec = s.breakpoints.get(input.id);
134
- if (!rec)
135
- throw new ToolError("not_found", `No breakpoint with id ${input.id}`);
136
- for (const b of rec.bindings) {
137
- try {
138
- await s.client.send("Debugger.removeBreakpoint", { breakpointId: b.cdpId }, b.sessionId);
139
- }
140
- catch {
141
- /* ignore — session may already be gone */
142
- }
143
- }
144
- s.breakpoints.delete(input.id);
145
- return "removed";
146
- });
147
- registerJsonTool(server, "list_breakpoints", "List all currently active breakpoints.", undefined, async () => {
148
- const s = requireSession();
149
- return Array.from(s.breakpoints.values()).map((bp) => ({
150
- id: bp.id,
151
- file: bp.file,
152
- line: bp.line,
153
- column: bp.column ?? 0,
154
- condition: bp.condition,
155
- log_message: bp.logMessage,
156
- resolved_locations: bp.resolvedLocations,
157
- binding_count: bp.bindings.length,
158
- }));
159
- });
160
- 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.", {
161
- state: z.enum(["none", "uncaught", "all"]),
162
- }, async (input) => {
163
- const s = requireSession();
164
- // Persist so onChildAttached can replay to future attachments.
165
- s.pauseOnExceptions = input.state;
166
- // Apply to every currently-attached session. ROOT_SESSION_KEY → undefined
167
- // for the CDP call; child keys are the literal sessionId.
168
- const targetSessions = [];
169
- for (const key of s.sessionHandlers.keys()) {
170
- targetSessions.push(key === ROOT_SESSION_KEY ? undefined : key);
171
- }
172
- if (targetSessions.length === 0)
173
- targetSessions.push(undefined); // safety net
174
- const results = await Promise.allSettled(targetSessions.map((sid) => s.client.send("Debugger.setPauseOnExceptions", { state: input.state }, sid)));
175
- const failures = results
176
- .map((r, i) => (r.status === "rejected" ? { sid: targetSessions[i] ?? "__root__", error: String(r.reason) } : null))
177
- .filter((x) => x !== null);
178
- return {
179
- state: input.state,
180
- sessions_applied: targetSessions.length - failures.length,
181
- failures,
182
- };
183
- });
184
- }
185
- // Combine an optional `condition` predicate with an optional `logMessage`.
186
- // Logpoint: emit a console.log and never pause (`false` short-circuits).
187
- /** @internal exported for unit tests; not part of the MCP tool surface. */
188
- export function buildConditionExpression(condition, logMessage) {
189
- if (!condition && !logMessage)
190
- return undefined;
191
- if (logMessage) {
192
- const tmpl = JSON.stringify(logMessage);
193
- const log = `console.log(${tmpl}.replace(/\\{([^}]+)\\}/g, (m, expr) => { try { return String(eval(expr)); } catch (e) { return "{" + expr + "=?}"; } }))`;
194
- if (condition)
195
- return `(${condition}) && (${log}, false)`;
196
- return `(${log}, false)`;
197
- }
198
- return condition;
199
- }
200
- //# 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,EAA0B,MAAM,uBAAuB,CAAC;AACzG,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,I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,EAAE,cAAc,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM;YACzD,QAAQ;SACT,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,yEAAyE;AACzE,2EAA2E;AAC3E,MAAM,UAAU,wBAAwB,CAAC,SAAkB,EAAE,UAAmB;IAC9E,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAChD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QACxC,MAAM,GAAG,GAAG,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
- //# sourceMappingURL=console.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/tools/console.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAU,CAAC;AAEtF,MAAM,UAAU,oBAAoB,CAAC,MAAiB;IACpD,gBAAgB,CACd,MAAM,EACN,kBAAkB,EAClB,6GAA6G,EAC7G;QACE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;QAChD,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;QAChC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;QAC1E,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,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,MAAM,EAAE,CAAC,CAAC,YAAY;gBACtB,MAAM,EAAE,CAAC,CAAC,GAAG;gBACb,OAAO,EAAE,CAAC,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;aAC7D,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,gBAAgB,CACd,MAAM,EACN,eAAe,EACf,+EAA+E,EAC/E,SAAS,EACT,KAAK,IAAI,EAAE;QACT,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC;QAC3B,CAAC,CAAC,OAAO,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,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAoB,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAElG,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AA6B9E,MAAM,UAAU,gBAAgB,CAAC,MAAiB;IAChD,gBAAgB,CACd,MAAM,EACN,gBAAgB,EAChB,oEAAoE,EACpE,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,EACxB,KAAK,EAAE,KAA2B,EAAE,EAAE;QACpC,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,MAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAClE,MA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,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAoB,EAAE,OAAkD;IACrG,OAAO;mBACU,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;sBACpB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;MACvC,oBAAoB,EAAE,GAAG,iBAAiB,EAAE;;OAE3C,CAAC;AACR,CAAC;AAED,SAAS,wBAAwB,CAAC,KAAqB;IACrD,OAAO;oBACW,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;MACnC,sBAAsB,EAAE;;OAEvB,CAAC;AACR,CAAC;AAED,SAAS,sBAAsB;IAC7B,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[];