@developerz.ai/ui-debugger-mcp 1.3.0 → 1.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 (107) hide show
  1. package/README.md +28 -0
  2. package/dist/adapters/android/adb.js +3 -1
  3. package/dist/adapters/android/adb.js.map +1 -1
  4. package/dist/adapters/android/android-adapter.js +24 -14
  5. package/dist/adapters/android/android-adapter.js.map +1 -1
  6. package/dist/adapters/android/commands.d.ts +7 -4
  7. package/dist/adapters/android/commands.js +11 -6
  8. package/dist/adapters/android/commands.js.map +1 -1
  9. package/dist/adapters/browser/browser-adapter.d.ts +4 -50
  10. package/dist/adapters/browser/browser-adapter.js +55 -223
  11. package/dist/adapters/browser/browser-adapter.js.map +1 -1
  12. package/dist/adapters/browser/cdp.d.ts +12 -42
  13. package/dist/adapters/browser/cdp.js +122 -261
  14. package/dist/adapters/browser/cdp.js.map +1 -1
  15. package/dist/adapters/browser/geometry.d.ts +97 -0
  16. package/dist/adapters/browser/geometry.js +158 -0
  17. package/dist/adapters/browser/geometry.js.map +1 -0
  18. package/dist/adapters/browser/launch.d.ts +42 -2
  19. package/dist/adapters/browser/launch.js +77 -2
  20. package/dist/adapters/browser/launch.js.map +1 -1
  21. package/dist/adapters/browser/locate.d.ts +44 -0
  22. package/dist/adapters/browser/locate.js +93 -0
  23. package/dist/adapters/browser/locate.js.map +1 -0
  24. package/dist/adapters/browser/log-filters.d.ts +25 -0
  25. package/dist/adapters/browser/log-filters.js +149 -0
  26. package/dist/adapters/browser/log-filters.js.map +1 -0
  27. package/dist/adapters/browser/log-format.d.ts +52 -0
  28. package/dist/adapters/browser/log-format.js +131 -0
  29. package/dist/adapters/browser/log-format.js.map +1 -0
  30. package/dist/adapters/contract.d.ts +22 -2
  31. package/dist/adapters/desktop/atspi.d.ts +7 -0
  32. package/dist/adapters/desktop/atspi.js +3 -0
  33. package/dist/adapters/desktop/atspi.js.map +1 -1
  34. package/dist/adapters/desktop/desktop-adapter.d.ts +8 -1
  35. package/dist/adapters/desktop/desktop-adapter.js +38 -20
  36. package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
  37. package/dist/adapters/desktop/input.d.ts +8 -1
  38. package/dist/adapters/desktop/input.js +12 -3
  39. package/dist/adapters/desktop/input.js.map +1 -1
  40. package/dist/adapters/desktop/proc.d.ts +13 -2
  41. package/dist/adapters/desktop/proc.js +42 -2
  42. package/dist/adapters/desktop/proc.js.map +1 -1
  43. package/dist/adapters/factory.js +5 -1
  44. package/dist/adapters/factory.js.map +1 -1
  45. package/dist/agent/belt/act.d.ts +3 -2
  46. package/dist/agent/belt/act.js +51 -7
  47. package/dist/agent/belt/act.js.map +1 -1
  48. package/dist/agent/belt/look.d.ts +5 -8
  49. package/dist/agent/belt/look.js +47 -8
  50. package/dist/agent/belt/look.js.map +1 -1
  51. package/dist/agent/belt/observe.d.ts +28 -2
  52. package/dist/agent/belt/observe.js +102 -27
  53. package/dist/agent/belt/observe.js.map +1 -1
  54. package/dist/agent/capabilities.d.ts +9 -0
  55. package/dist/agent/capabilities.js +10 -1
  56. package/dist/agent/capabilities.js.map +1 -1
  57. package/dist/agent/loop.d.ts +11 -2
  58. package/dist/agent/loop.js +55 -6
  59. package/dist/agent/loop.js.map +1 -1
  60. package/dist/agent/prompts/android-addendum.d.ts +1 -1
  61. package/dist/agent/prompts/android-addendum.js +20 -5
  62. package/dist/agent/prompts/android-addendum.js.map +1 -1
  63. package/dist/agent/prompts/compose.d.ts +8 -0
  64. package/dist/agent/prompts/compose.js +15 -2
  65. package/dist/agent/prompts/compose.js.map +1 -1
  66. package/dist/agent/prompts/debug-agent.js +12 -0
  67. package/dist/agent/prompts/debug-agent.js.map +1 -1
  68. package/dist/agent/prompts/desktop-addendum.d.ts +1 -1
  69. package/dist/agent/prompts/desktop-addendum.js +18 -5
  70. package/dist/agent/prompts/desktop-addendum.js.map +1 -1
  71. package/dist/agent/prompts/web-addendum.d.ts +1 -1
  72. package/dist/agent/prompts/web-addendum.js +0 -10
  73. package/dist/agent/prompts/web-addendum.js.map +1 -1
  74. package/dist/config/fingerprint.d.ts +6 -0
  75. package/dist/config/fingerprint.js +16 -4
  76. package/dist/config/fingerprint.js.map +1 -1
  77. package/dist/config/schema.d.ts +10 -4
  78. package/dist/config/schema.js +21 -5
  79. package/dist/config/schema.js.map +1 -1
  80. package/dist/index.d.ts +1 -1
  81. package/dist/index.js +1 -1
  82. package/dist/main.js +11 -13
  83. package/dist/main.js.map +1 -1
  84. package/dist/services/debug-service.d.ts +2 -1
  85. package/dist/services/debug-service.js +82 -29
  86. package/dist/services/debug-service.js.map +1 -1
  87. package/dist/services/replay.d.ts +14 -3
  88. package/dist/services/replay.js +57 -10
  89. package/dist/services/replay.js.map +1 -1
  90. package/dist/services/session-builder.js +30 -5
  91. package/dist/services/session-builder.js.map +1 -1
  92. package/dist/services/shutdown.d.ts +37 -0
  93. package/dist/services/shutdown.js +51 -0
  94. package/dist/services/shutdown.js.map +1 -0
  95. package/dist/session/findings-store.d.ts +6 -2
  96. package/dist/session/findings-store.js +39 -6
  97. package/dist/session/findings-store.js.map +1 -1
  98. package/dist/session/session.d.ts +4 -2
  99. package/dist/session/session.js +7 -2
  100. package/dist/session/session.js.map +1 -1
  101. package/dist/session/state-file.d.ts +8 -2
  102. package/dist/session/state-file.js +8 -2
  103. package/dist/session/state-file.js.map +1 -1
  104. package/dist/session/workspace.d.ts +2 -1
  105. package/dist/session/workspace.js +28 -3
  106. package/dist/session/workspace.js.map +1 -1
  107. package/package.json +1 -1
@@ -24,8 +24,14 @@
24
24
  * durable record. Filters fail loud — an unknown key or wrong value type throws
25
25
  * {@link AdapterError}, never a silent ignore.
26
26
  */
27
- import { AdapterError } from '../../errors.js';
28
27
  import { capToLimit } from '../limit.js';
28
+ import { filterConsole, filterNetwork } from './log-filters.js';
29
+ import { formatConsoleLine, formatNetworkLine, normalizeConsoleLevel, redactHeaders, redactUrl, truncateBody, } from './log-format.js';
30
+ // Filtering lives in `log-filters.ts` and rendering/redaction in `log-format.ts`
31
+ // (500-LOC cap); both are re-exported here so `cdp.js` stays the single import
32
+ // surface for the capture channel.
33
+ export { CONSOLE_FILTER_KEYS, filterConsole, filterNetwork, NETWORK_FILTER_KEYS, } from './log-filters.js';
34
+ export { BODY_CAP, formatConsoleLine, formatNetworkLine, normalizeConsoleLevel, redactHeaders, redactUrl, truncateBody, } from './log-format.js';
29
35
  /** Default ring size per channel — keeps memory bounded on chatty pages. */
30
36
  const DEFAULT_BUFFER_CAP = 1000;
31
37
  /**
@@ -36,10 +42,14 @@ const DEFAULT_BUFFER_CAP = 1000;
36
42
  */
37
43
  export const BODY_RESOURCE_TYPES = new Set(['fetch', 'xhr']);
38
44
  /**
39
- * Per-body character cap. Big enough for an error payload or a small collection,
40
- * small enough that the driver re-reading tool results every step cannot drown.
45
+ * How long a response body/header read may take before the exchange is recorded
46
+ * without it. A streaming response (SSE, long-poll, a chunked download) only
47
+ * "finishes" when the page tears it down, so an uncapped read would keep the
48
+ * durable log line hostage for the whole run.
41
49
  */
42
- export const BODY_CAP = 4096;
50
+ export const BODY_WAIT_MS = 2_000;
51
+ /** Stand-in body for a response that was still streaming when the cap expired. */
52
+ export const BODY_UNFINISHED = '<body not finished>';
43
53
  /**
44
54
  * `{ key: value }` when the value exists, `{}` when it does not — spread into an
45
55
  * entry so an absent optional never serializes as an explicit `undefined` (and
@@ -64,228 +74,41 @@ async function readBody(response) {
64
74
  return undefined;
65
75
  }
66
76
  }
67
- /** Redacted headers off a request or response; `undefined` if they cannot be read. */
68
- async function readHeaders(source) {
69
- try {
70
- return redactHeaders(await source.allHeaders());
71
- }
72
- catch {
73
- return undefined;
74
- }
75
- }
76
- /** Header names whose VALUE is a credential — kept as a length marker, never verbatim. */
77
- const SENSITIVE_HEADER = /^(authorization|proxy-authorization|cookie|set-cookie|x-api-key|x-auth-token|x-csrf-token)$/i;
78
- /** Truncate a captured body, marking what was dropped (never silently shortened). */
79
- export function truncateBody(body, cap = BODY_CAP) {
80
- if (body.length <= cap)
81
- return body;
82
- return `${body.slice(0, cap)}…[truncated, ${body.length} chars total]`;
83
- }
84
77
  /**
85
- * Copy headers with credential values replaced by `<redacted, N chars>`.
78
+ * `promise`'s value, or `undefined` when it takes longer than `ms`.
86
79
  *
87
- * Presence is diagnostic (an absent `cookie` explains a 401 as well as a wrong
88
- * one), the value is a secret that must not reach the model's context, the log
89
- * files, or the findings the caller reads back.
80
+ * Never leaves a timer behind: the loser is cleared as soon as the race settles,
81
+ * so a capped read cannot hold the process open past the run.
90
82
  */
91
- export function redactHeaders(headers) {
92
- const out = {};
93
- for (const [name, value] of Object.entries(headers)) {
94
- out[name] = SENSITIVE_HEADER.test(name) ? `<redacted, ${value.length} chars>` : value;
83
+ async function withTimeout(promise, ms) {
84
+ let timer;
85
+ const capped = new Promise((resolve) => {
86
+ timer = setTimeout(() => resolve(undefined), ms);
87
+ });
88
+ try {
89
+ return await Promise.race([promise, capped]);
95
90
  }
96
- return out;
97
- }
98
- /** Whitelisted `filters` keys for the console channel — anything else is rejected. */
99
- export const CONSOLE_FILTER_KEYS = ['level_eq', 'level_in', 'text_contains'];
100
- /** Whitelisted `filters` keys for the network channel — anything else is rejected. */
101
- export const NETWORK_FILTER_KEYS = [
102
- 'status_eq',
103
- 'status_gte',
104
- 'status_lt',
105
- 'ok_eq',
106
- 'failed_eq',
107
- 'method_eq',
108
- 'resource_in',
109
- 'url_contains',
110
- 'duration_gte',
111
- 'body_contains',
112
- ];
113
- // --- Normalizers ------------------------------------------------------------
114
- /** Map a CDP console `type()` onto the normalized {@link ConsoleEntry} level. */
115
- export function normalizeConsoleLevel(type) {
116
- switch (type) {
117
- case 'error':
118
- case 'assert':
119
- return 'error';
120
- case 'warning':
121
- case 'warn':
122
- return 'warn';
123
- case 'info':
124
- case 'count':
125
- case 'timeEnd':
126
- return 'info';
127
- case 'debug':
128
- return 'debug';
129
- default:
130
- return 'log';
91
+ finally {
92
+ clearTimeout(timer);
131
93
  }
132
94
  }
133
- // --- Line formatting (durable log trail) ------------------------------------
134
- /** ISO-8601 stamp from epoch ms; deterministic given the injected clock. */
135
- function stamp(ts) {
136
- return new Date(ts).toISOString();
137
- }
138
- /** Render a {@link ConsoleEntry} as one greppable `logs/console.log` line. */
139
- export function formatConsoleLine(entry) {
140
- const where = entry.location ? ` @ ${entry.location}` : '';
141
- return `${stamp(entry.timestamp)} ${entry.level.toUpperCase()} ${entry.text}${where}`;
142
- }
143
- /** One log line's worth of a captured body — single-line, hard-capped, never secret-bearing. */
144
- function bodySnippet(label, body) {
145
- if (body === undefined || body.length === 0)
146
- return '';
147
- return ` ${label}=${JSON.stringify(truncateBody(body, 500))}`;
148
- }
149
95
  /**
150
- * Render a {@link NetworkEntry} as one greppable `logs/network.log` line.
151
- *
152
- * Failures carry their payloads inline: the durable log is what a human (or a
153
- * later agent) reads after the run, and `POST /login → 400` without the body is
154
- * the exact dead end this log exists to prevent.
96
+ * The response payload, capped in SIZE and in TIME — {@link BODY_UNFINISHED} when
97
+ * the stream had not finished within `waitMs`. The `{ body }` wrapper keeps the
98
+ * two `undefined`s apart: "no body to read" (a redirect) vs "still streaming".
155
99
  */
156
- export function formatNetworkLine(entry) {
157
- const head = `${stamp(entry.timestamp)} ${entry.method} ${entry.url}`;
158
- const sent = bodySnippet('req', entry.requestBody);
159
- if (entry.error !== undefined)
160
- return `${head} → FAILED ${entry.error}${sent}`;
161
- const type = entry.resourceType ? ` [${entry.resourceType}]` : '';
162
- const took = entry.durationMs !== undefined ? ` ${entry.durationMs}ms` : '';
163
- const got = entry.ok ? '' : bodySnippet('res', entry.responseBody);
164
- return `${head} → ${entry.status}${type}${took}${sent}${got}`;
100
+ async function readBodyWithin(response, waitMs) {
101
+ const settled = await withTimeout(readBody(response).then((body) => ({ body })), waitMs);
102
+ return settled === undefined ? BODY_UNFINISHED : settled.body;
165
103
  }
166
- // --- Filter value type-guards (fail loud, never coerce) ---------------------
167
- function expectBoolean(key, value) {
168
- if (typeof value !== 'boolean')
169
- throw new AdapterError(`filter \`${key}\` expects a boolean`);
170
- return value;
171
- }
172
- function expectNumber(key, value) {
173
- if (typeof value !== 'number')
174
- throw new AdapterError(`filter \`${key}\` expects a number`);
175
- return value;
176
- }
177
- function expectString(key, value) {
178
- if (typeof value !== 'string')
179
- throw new AdapterError(`filter \`${key}\` expects a string`);
180
- return value;
181
- }
182
- function expectStringArray(key, value) {
183
- if (!Array.isArray(value) || value.some((v) => typeof v !== 'string')) {
184
- throw new AdapterError(`filter \`${key}\` expects a string[]`);
185
- }
186
- return value;
187
- }
188
- // --- Filtering (whitelisted, per-channel) -----------------------------------
189
- /**
190
- * Narrow console entries by the whitelisted `filters` keys
191
- * ({@link CONSOLE_FILTER_KEYS}). Throws {@link AdapterError} on an unknown key
192
- * (no silent injection surface) or a wrong value type.
193
- */
194
- export function filterConsole(entries, filters) {
195
- if (!filters)
196
- return entries;
197
- let out = entries;
198
- for (const [key, value] of Object.entries(filters)) {
199
- switch (key) {
200
- case 'level_eq': {
201
- const want = expectString(key, value);
202
- out = out.filter((e) => e.level === want);
203
- break;
204
- }
205
- case 'level_in': {
206
- const want = expectStringArray(key, value);
207
- out = out.filter((e) => want.includes(e.level));
208
- break;
209
- }
210
- case 'text_contains': {
211
- const needle = expectString(key, value).toLowerCase();
212
- out = out.filter((e) => e.text.toLowerCase().includes(needle));
213
- break;
214
- }
215
- default:
216
- throw new AdapterError(`unknown console filter \`${key}\` (allowed: ${CONSOLE_FILTER_KEYS.join(', ')})`);
217
- }
104
+ /** Redacted headers off a request or response; `undefined` if they cannot be read. */
105
+ async function readHeaders(source) {
106
+ try {
107
+ return redactHeaders(await source.allHeaders());
218
108
  }
219
- return out;
220
- }
221
- /**
222
- * Narrow network entries by the whitelisted `filters` keys
223
- * ({@link NETWORK_FILTER_KEYS}). Throws {@link AdapterError} on an unknown key or
224
- * a wrong value type.
225
- */
226
- export function filterNetwork(entries, filters) {
227
- if (!filters)
228
- return entries;
229
- let out = entries;
230
- for (const [key, value] of Object.entries(filters)) {
231
- switch (key) {
232
- case 'status_eq': {
233
- const want = expectNumber(key, value);
234
- out = out.filter((e) => e.status === want);
235
- break;
236
- }
237
- case 'status_gte': {
238
- const want = expectNumber(key, value);
239
- out = out.filter((e) => e.status >= want);
240
- break;
241
- }
242
- case 'status_lt': {
243
- const want = expectNumber(key, value);
244
- out = out.filter((e) => e.status < want);
245
- break;
246
- }
247
- case 'ok_eq': {
248
- const want = expectBoolean(key, value);
249
- out = out.filter((e) => e.ok === want);
250
- break;
251
- }
252
- case 'failed_eq': {
253
- const want = expectBoolean(key, value);
254
- out = out.filter((e) => (e.error !== undefined) === want);
255
- break;
256
- }
257
- case 'method_eq': {
258
- const want = expectString(key, value).toUpperCase();
259
- out = out.filter((e) => e.method.toUpperCase() === want);
260
- break;
261
- }
262
- case 'resource_in': {
263
- const want = expectStringArray(key, value);
264
- out = out.filter((e) => e.resourceType !== undefined && want.includes(e.resourceType));
265
- break;
266
- }
267
- case 'url_contains': {
268
- const needle = expectString(key, value).toLowerCase();
269
- out = out.filter((e) => e.url.toLowerCase().includes(needle));
270
- break;
271
- }
272
- case 'duration_gte': {
273
- const want = expectNumber(key, value);
274
- // A request with no timing (never answered, or in flight before capture)
275
- // is not "slower than N" — excluded rather than counted as 0.
276
- out = out.filter((e) => e.durationMs !== undefined && e.durationMs >= want);
277
- break;
278
- }
279
- case 'body_contains': {
280
- const needle = expectString(key, value).toLowerCase();
281
- out = out.filter((e) => `${e.requestBody ?? ''}\n${e.responseBody ?? ''}`.toLowerCase().includes(needle));
282
- break;
283
- }
284
- default:
285
- throw new AdapterError(`unknown network filter \`${key}\` (allowed: ${NETWORK_FILTER_KEYS.join(', ')})`);
286
- }
109
+ catch {
110
+ return undefined;
287
111
  }
288
- return out;
289
112
  }
290
113
  /**
291
114
  * Reverse to newest-first and apply `limit` — the shared `console`/`network` read
@@ -298,12 +121,10 @@ function newestFirst(filtered, limit) {
298
121
  /**
299
122
  * Newest-first by capture time, then capped.
300
123
  *
301
- * Network entries are buffered only after their body has been awaited, so a slow
302
- * response can land in the ring *after* a fast one that started later — insertion
303
- * order is no longer capture order. Sorting on the recorded timestamp restores
304
- * "newest first" as a promise about the traffic rather than about our await
305
- * scheduling. The sort is stable, so same-timestamp entries keep the reversed
306
- * insertion order {@link newestFirst} alone would give them.
124
+ * Sorting on the recorded timestamp (rather than trusting insertion order) makes
125
+ * "newest first" a promise about the TRAFFIC, independent of how the handlers
126
+ * happened to be scheduled. The sort is stable, so same-timestamp entries keep
127
+ * the reversed insertion order {@link newestFirst} alone would give them.
307
128
  */
308
129
  function newestFirstByTime(filtered, limit) {
309
130
  return capToLimit([...filtered].reverse().sort((a, b) => b.timestamp - a.timestamp), limit);
@@ -319,6 +140,7 @@ export class CdpCapture {
319
140
  #sink;
320
141
  #now;
321
142
  #cap;
143
+ #bodyWait;
322
144
  #console = [];
323
145
  #network = [];
324
146
  /** Request → epoch ms it left the page, for {@link NetworkEntry.durationMs}. */
@@ -328,6 +150,10 @@ export class CdpCapture {
328
150
  * same one is recognized as teardown rather than logged as a second exchange.
329
151
  */
330
152
  #responded = new WeakSet();
153
+ /** Request → the buffered entry it produced, so a late failure can amend it in place. */
154
+ #entryOf = new WeakMap();
155
+ /** Entries whose log line was already streamed — the line lands once, when enrichment settles. */
156
+ #logged = new WeakSet();
331
157
  /** Detacher thunks captured at `start`, replayed at `stop`. */
332
158
  #detachers = [];
333
159
  #started = false;
@@ -336,6 +162,7 @@ export class CdpCapture {
336
162
  this.#sink = init.sink;
337
163
  this.#now = init.now ?? (() => Date.now());
338
164
  this.#cap = init.cap ?? DEFAULT_BUFFER_CAP;
165
+ this.#bodyWait = init.bodyWaitMs ?? BODY_WAIT_MS;
339
166
  }
340
167
  /** Subscribe to the console/error/network events. Idempotent (a re-`start` is a no-op). */
341
168
  start() {
@@ -385,7 +212,9 @@ export class CdpCapture {
385
212
  this.#pushConsole({
386
213
  level: normalizeConsoleLevel(msg.type()),
387
214
  text: msg.text(),
388
- location: loc.url ? `${loc.url}:${loc.line}:${loc.column}` : undefined,
215
+ // Playwright reports line/column 0-BASED; `url:line:col` is read (and opened
216
+ // in an editor) 1-based, so the raw numbers point one line too high.
217
+ location: loc.url ? `${loc.url}:${loc.line + 1}:${loc.column + 1}` : undefined,
389
218
  timestamp: this.#now(),
390
219
  });
391
220
  };
@@ -427,36 +256,51 @@ export class CdpCapture {
427
256
  return data ? truncateBody(data) : undefined;
428
257
  }
429
258
  #onRequestFailed = (request) => {
430
- // A request that ALREADY answered and is now aborted is not a failed request:
431
- // Chrome fires `requestfailed` with `net::ERR_ABORTED` when the connection is
432
- // torn down after the response (a logout that navigates, a fetch whose page
433
- // unloads). Logging both produced two rows for one exchange — a clean `204`
434
- // and a phantom `FAILED` at the same millisecond — and readers reasonably took
435
- // the phantom for a real outage. The response is the truth; drop the echo.
436
- if (this.#responded.has(request))
437
- return;
438
259
  const at = this.#now();
439
- this.#pushNetwork({
260
+ const error = request.failure()?.errorText ?? 'request failed';
261
+ const answered = this.#entryOf.get(request);
262
+ if (this.#responded.has(request)) {
263
+ // An abort AFTER the response is teardown, not a failed request: Chrome fires
264
+ // `requestfailed` with `net::ERR_ABORTED` when the connection is torn down
265
+ // once the exchange is over (a logout that navigates, a fetch whose page
266
+ // unloads, a stream we stopped reading). Logging that produced two rows for
267
+ // one exchange — a clean `204` and a phantom `FAILED` — so drop the echo.
268
+ if (error.includes('net::ERR_ABORTED'))
269
+ return;
270
+ // Anything else is a REAL failure that struck after the headers arrived (a
271
+ // connection reset mid-body). Amend the exchange in place: reported as a
272
+ // clean `200` it is indistinguishable from a body-less success.
273
+ if (answered) {
274
+ answered.error = error;
275
+ answered.ok = false;
276
+ if (this.#logged.has(answered))
277
+ this.#logNetwork(answered);
278
+ return;
279
+ }
280
+ }
281
+ const entry = {
440
282
  method: request.method(),
441
- url: request.url(),
283
+ url: redactUrl(request.url()),
442
284
  status: 0,
443
285
  ok: false,
444
286
  resourceType: request.resourceType(),
445
- error: request.failure()?.errorText ?? 'request failed',
287
+ error,
446
288
  timestamp: at,
447
289
  ...optional('durationMs', this.#elapsed(request, at)),
448
290
  ...optional('requestBody', this.#requestBodyOf(request)),
449
- });
291
+ };
292
+ this.#bufferNetwork(entry);
293
+ this.#logNetwork(entry);
450
294
  };
451
295
  /**
452
- * Buffer a finished exchange, enriched for API traffic.
296
+ * Record an exchange the moment its headers arrive, then enrich it in place.
453
297
  *
454
- * Async on purpose: the response body only exists behind an await, and a `400`
455
- * without its body is the dead end this capture exists to prevent. The
456
- * timestamp is taken UP FRONT (before the await) so ordering reflects when the
457
- * response actually arrived — `network()` sorts on it, since bodies resolve out
458
- * of order. Playwright tolerates an async listener; a rejection here must not
459
- * become an unhandled rejection that kills the run, so everything is guarded.
298
+ * The row is buffered SYNCHRONOUSLY — a body only exists behind an await, and a
299
+ * response that never finishes (SSE, long-poll, a stalled download) would
300
+ * otherwise leave no trace at all: no row for the driver to see, no line in the
301
+ * log. The bodies and headers land on the same object a moment later
302
+ * ({@link #enrichResponse}), which is also when its log line is written, so the
303
+ * durable trail still carries the payloads a `400` is explained by.
460
304
  */
461
305
  #onResponse = (response) => {
462
306
  const at = this.#now();
@@ -464,44 +308,61 @@ export class CdpCapture {
464
308
  // Marked SYNCHRONOUSLY, before the body await: an abort that lands while the
465
309
  // body is still resolving must already see this request as answered.
466
310
  this.#responded.add(request);
467
- void this.#captureResponse(response, request, at).catch(() => undefined);
468
- };
469
- async #captureResponse(response, request, at) {
470
- const isApi = BODY_RESOURCE_TYPES.has(request.resourceType());
471
- this.#pushNetwork({
311
+ const entry = {
472
312
  method: request.method(),
473
- url: response.url(),
313
+ url: redactUrl(response.url()),
474
314
  status: response.status(),
475
315
  ok: response.ok(),
476
316
  resourceType: request.resourceType(),
477
317
  timestamp: at,
478
318
  ...optional('durationMs', this.#elapsed(request, at)),
479
319
  ...optional('requestBody', this.#requestBodyOf(request)),
480
- ...optional('responseBody', isApi ? await readBody(response) : undefined),
481
- ...optional('requestHeaders', isApi ? await readHeaders(request) : undefined),
482
- ...optional('responseHeaders', isApi ? await readHeaders(response) : undefined),
483
- });
320
+ };
321
+ this.#entryOf.set(request, entry);
322
+ this.#bufferNetwork(entry);
323
+ // Playwright tolerates an async listener; a rejection here must not become an
324
+ // unhandled rejection that kills the run, so everything is guarded.
325
+ void this.#enrichResponse(entry, response, request).catch(() => undefined);
326
+ };
327
+ /** Attach bodies + headers to an already-buffered entry, then stream its log line. */
328
+ async #enrichResponse(entry, response, request) {
329
+ if (BODY_RESOURCE_TYPES.has(request.resourceType())) {
330
+ const [body, requestHeaders, responseHeaders] = await Promise.all([
331
+ readBodyWithin(response, this.#bodyWait),
332
+ withTimeout(readHeaders(request), this.#bodyWait),
333
+ withTimeout(readHeaders(response), this.#bodyWait),
334
+ ]);
335
+ if (body !== undefined)
336
+ entry.responseBody = body;
337
+ if (requestHeaders !== undefined)
338
+ entry.requestHeaders = requestHeaders;
339
+ if (responseHeaders !== undefined)
340
+ entry.responseHeaders = responseHeaders;
341
+ }
342
+ this.#logNetwork(entry);
484
343
  }
485
344
  /** Ring-buffer a console entry and stream its formatted line to the sink. */
486
345
  #pushConsole(entry) {
487
346
  this.#console.push(entry);
488
347
  if (this.#console.length > this.#cap)
489
348
  this.#console.shift();
490
- try {
491
- this.#sink?.('console', formatConsoleLine(entry));
492
- }
493
- catch (error) {
494
- // Sink failure must not crash the handler — log but continue.
495
- console.error(`CDP capture sink failed: ${error instanceof Error ? error.message : String(error)}`);
496
- }
349
+ this.#emit('console', formatConsoleLine(entry));
497
350
  }
498
- /** Ring-buffer a network entry and stream its formatted line to the sink. */
499
- #pushNetwork(entry) {
351
+ /** Ring-buffer a network entry. Its log line is written separately, once it is complete. */
352
+ #bufferNetwork(entry) {
500
353
  this.#network.push(entry);
501
354
  if (this.#network.length > this.#cap)
502
355
  this.#network.shift();
356
+ }
357
+ /** Stream a network entry's formatted line to the sink. */
358
+ #logNetwork(entry) {
359
+ this.#logged.add(entry);
360
+ this.#emit('network', formatNetworkLine(entry));
361
+ }
362
+ /** Hand one formatted line to the sink; a sink failure never crashes the handler. */
363
+ #emit(channel, line) {
503
364
  try {
504
- this.#sink?.('network', formatNetworkLine(entry));
365
+ this.#sink?.(channel, line);
505
366
  }
506
367
  catch (error) {
507
368
  // Sink failure must not crash the handler — log but continue.
@@ -1 +1 @@
1
- {"version":3,"file":"cdp.js","sourceRoot":"","sources":["../../../src/adapters/browser/cdp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,4EAA4E;AAC5E,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAE7B;;;;GAIG;AACH,SAAS,QAAQ,CAAsB,GAAM,EAAE,KAAoB;IACjE,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAmB,CAAC;AACvE,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,QAAQ,CAAC,QAAkB;IACxC,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,sFAAsF;AACtF,KAAK,UAAU,WAAW,CACxB,MAAkE;IAElE,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,O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AmB;QAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC9D,CAAC;IAED,2DAA2D;IAC3D,WAAW,CAAC,KAAmB;QAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,qFAAqF;IACrF,KAAK,CAAC,OAA8B,EAAE,IAAY;QAChD,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,8DAA8D;YAC9D,OAAO,CAAC,KAAK,CACX,4BAA4B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACrF,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Coordinates, frames and node shaping for the browser adapter — the pure
3
+ * geometry the page-driving class leans on. Split out of `browser-adapter.ts`
4
+ * to keep that file under the 500-LOC cap (same split `filters.ts` got), no
5
+ * behavior change.
6
+ *
7
+ * Two themes:
8
+ * - **the viewport**: is a point actually on screen, which way does a wheel go;
9
+ * - **frames**: where a child document's viewport sits in PAGE coordinates,
10
+ * and whether a mid-read failure was a frame going away or a real error.
11
+ */
12
+ import type { Frame } from 'playwright-core';
13
+ import type { Node, ScrollDirection } from '../contract.js';
14
+ import type { RawNode } from './extractor.js';
15
+ /**
16
+ * True when `point` falls outside a non-null `viewport`. Coordinate clicks use
17
+ * viewport-relative bounds (`getBoundingClientRect`), so an off-screen center
18
+ * dispatches a CDP click that lands on nothing — silently. A null viewport means
19
+ * the size could not be established AT ALL (see {@link BrowserAdapter.viewport},
20
+ * which falls back to the page's own `innerWidth/Height` first) → never outside;
21
+ * we can't judge.
22
+ */
23
+ export declare function isOutsideViewport(point: {
24
+ x: number;
25
+ y: number;
26
+ }, viewport: {
27
+ width: number;
28
+ height: number;
29
+ } | null): boolean;
30
+ /**
31
+ * Map a {@link ScrollDirection} + pixel `amount` onto Playwright wheel deltas
32
+ * `[deltaX, deltaY]` (the viewport scrolls toward that edge). Fails loud on an
33
+ * unrecognized direction — the switch is exhaustive over the union, so a bad
34
+ * value can only arrive from an unchecked boundary.
35
+ */
36
+ export declare function scrollDelta(direction: ScrollDirection, amount: number): [number, number];
37
+ /**
38
+ * In-page viewport probe — `innerWidth/Height` read off the page itself. Reaches
39
+ * the globals through `globalThis` because the DOM lib is off project-wide; the
40
+ * function is serialized into the page, so it must stay self-contained.
41
+ */
42
+ export declare const VIEWPORT_PROBE: () => {
43
+ width: number;
44
+ height: number;
45
+ };
46
+ /**
47
+ * True when a per-frame read failed because that FRAME vanished (navigation, an
48
+ * ad slot recycling itself), which is one document out of many and not an error.
49
+ *
50
+ * Anything else — an invalid selector above all, the jQuery-ism `div:contains(…)`
51
+ * an LLM emits constantly — is the caller's own mistake and must surface: swallowed,
52
+ * it reads back as `{count: 0}`, i.e. "the element does not exist", while `click()`
53
+ * with the same selector reports the real reason. `detached` is the frame's own
54
+ * live state, checked in addition to the message.
55
+ */
56
+ export declare function isFrameGone(error: unknown, detached: boolean): boolean;
57
+ /**
58
+ * True when a Playwright call failed by RUNNING OUT OF TIME rather than by being
59
+ * wrong — the one failure a cross-frame poll retries instead of surfacing.
60
+ * Playwright brands those as `TimeoutError`.
61
+ */
62
+ export declare function isTimeout(error: unknown): boolean;
63
+ /** Drop the internal `visible` flag — the public contract returns plain {@link Node}s. */
64
+ export declare function toNode(node: RawNode): Node;
65
+ /**
66
+ * The iframe element's own content origin relative to its border box: the
67
+ * border + padding inset, typed locally (the DOM lib is off project-wide) and
68
+ * serialized into the page by Playwright.
69
+ */
70
+ interface FrameBox {
71
+ x: number;
72
+ y: number;
73
+ }
74
+ /**
75
+ * Where a frame's viewport sits in page coordinates: `{x:0,y:0}` for the main
76
+ * document, the iframe element's CONTENT origin for a child, `null` when the
77
+ * frame is gone or not rendered (detached, `display:none`) and must be skipped.
78
+ *
79
+ * `boundingBox()` is the iframe's BORDER box, while an in-frame
80
+ * `getBoundingClientRect()` is relative to its content origin — so without the
81
+ * border+padding inset every node inside an iframe carrying the UA's default
82
+ * `2px inset` border is off by exactly that much.
83
+ */
84
+ export declare function frameOffset(frame: Frame): Promise<FrameBox | null>;
85
+ /**
86
+ * Translate a node read inside a frame into page coordinates and stamp which
87
+ * frame it came from.
88
+ *
89
+ * Bounds arrive relative to the frame's own viewport; clicks dispatch against
90
+ * the page. Without the shift, every click on embedded content would land at the
91
+ * wrong place on the page — silently, since the coordinates stay plausible.
92
+ */
93
+ export declare function placeInPage(node: RawNode, offset: {
94
+ x: number;
95
+ y: number;
96
+ }, frame: Frame): RawNode;
97
+ export {};