@developerz.ai/ui-debugger-mcp 1.9.0 → 1.11.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.
- package/README.md +63 -47
- package/dist/adapters/android/abortable.d.ts +6 -0
- package/dist/adapters/android/abortable.js +22 -0
- package/dist/adapters/android/abortable.js.map +1 -0
- package/dist/adapters/android/adb.d.ts +19 -7
- package/dist/adapters/android/adb.js +50 -13
- package/dist/adapters/android/adb.js.map +1 -1
- package/dist/adapters/android/android-adapter.d.ts +20 -12
- package/dist/adapters/android/android-adapter.js +113 -165
- package/dist/adapters/android/android-adapter.js.map +1 -1
- package/dist/adapters/android/commands.d.ts +10 -0
- package/dist/adapters/android/commands.js +22 -0
- package/dist/adapters/android/commands.js.map +1 -1
- package/dist/adapters/android/emulator.d.ts +41 -0
- package/dist/adapters/android/emulator.js +115 -0
- package/dist/adapters/android/emulator.js.map +1 -0
- package/dist/adapters/android/logcat.d.ts +87 -0
- package/dist/adapters/android/logcat.js +352 -0
- package/dist/adapters/android/logcat.js.map +1 -0
- package/dist/adapters/android/ports.js.map +1 -1
- package/dist/adapters/android/sdk.d.ts +65 -0
- package/dist/adapters/android/sdk.js +107 -0
- package/dist/adapters/android/sdk.js.map +1 -0
- package/dist/adapters/android/uiautomator.d.ts +23 -7
- package/dist/adapters/android/uiautomator.js +31 -7
- package/dist/adapters/android/uiautomator.js.map +1 -1
- package/dist/adapters/availability.d.ts +39 -0
- package/dist/adapters/availability.js +62 -0
- package/dist/adapters/availability.js.map +1 -0
- package/dist/adapters/browser/browser-adapter.d.ts +11 -22
- package/dist/adapters/browser/browser-adapter.js +90 -71
- package/dist/adapters/browser/browser-adapter.js.map +1 -1
- package/dist/adapters/browser/cdp.d.ts +22 -17
- package/dist/adapters/browser/cdp.js +118 -72
- package/dist/adapters/browser/cdp.js.map +1 -1
- package/dist/adapters/browser/exchange-read.d.ts +39 -0
- package/dist/adapters/browser/exchange-read.js +102 -0
- package/dist/adapters/browser/exchange-read.js.map +1 -0
- package/dist/adapters/browser/extractor.js +9 -2
- package/dist/adapters/browser/extractor.js.map +1 -1
- package/dist/adapters/browser/filters.d.ts +1 -1
- package/dist/adapters/browser/filters.js.map +1 -1
- package/dist/adapters/browser/geometry.js.map +1 -1
- package/dist/adapters/browser/launch.d.ts +14 -5
- package/dist/adapters/browser/launch.js +14 -5
- package/dist/adapters/browser/launch.js.map +1 -1
- package/dist/adapters/browser/lifecycle.d.ts +91 -0
- package/dist/adapters/browser/lifecycle.js +141 -0
- package/dist/adapters/browser/lifecycle.js.map +1 -0
- package/dist/adapters/browser/locate.d.ts +18 -2
- package/dist/adapters/browser/locate.js +48 -3
- package/dist/adapters/browser/locate.js.map +1 -1
- package/dist/adapters/browser/log-filters.d.ts +2 -2
- package/dist/adapters/browser/log-filters.js +15 -4
- package/dist/adapters/browser/log-filters.js.map +1 -1
- package/dist/adapters/browser/log-format.d.ts +23 -20
- package/dist/adapters/browser/log-format.js +133 -56
- package/dist/adapters/browser/log-format.js.map +1 -1
- package/dist/adapters/browser/tab-context.d.ts +30 -0
- package/dist/adapters/browser/tab-context.js +41 -0
- package/dist/adapters/browser/tab-context.js.map +1 -0
- package/dist/adapters/contract.d.ts +113 -10
- package/dist/adapters/contract.js +7 -2
- package/dist/adapters/contract.js.map +1 -1
- package/dist/adapters/desktop/atspi-busctl.d.ts +26 -0
- package/dist/adapters/desktop/atspi-busctl.js +332 -0
- package/dist/adapters/desktop/atspi-busctl.js.map +1 -0
- package/dist/adapters/desktop/atspi-parse.d.ts +39 -0
- package/dist/adapters/desktop/atspi-parse.js +155 -0
- package/dist/adapters/desktop/atspi-parse.js.map +1 -0
- package/dist/adapters/desktop/atspi.d.ts +81 -50
- package/dist/adapters/desktop/atspi.js +64 -285
- package/dist/adapters/desktop/atspi.js.map +1 -1
- package/dist/adapters/desktop/capture.d.ts +11 -20
- package/dist/adapters/desktop/capture.js +68 -37
- package/dist/adapters/desktop/capture.js.map +1 -1
- package/dist/adapters/desktop/desktop-adapter.d.ts +22 -2
- package/dist/adapters/desktop/desktop-adapter.js +202 -86
- package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
- package/dist/adapters/desktop/input.d.ts +19 -5
- package/dist/adapters/desktop/input.js +29 -13
- package/dist/adapters/desktop/input.js.map +1 -1
- package/dist/adapters/desktop/managed-app.d.ts +43 -0
- package/dist/adapters/desktop/managed-app.js +114 -0
- package/dist/adapters/desktop/managed-app.js.map +1 -0
- package/dist/adapters/desktop/proc.d.ts +34 -4
- package/dist/adapters/desktop/proc.js +37 -6
- package/dist/adapters/desktop/proc.js.map +1 -1
- package/dist/adapters/desktop/wait-poll.d.ts +17 -0
- package/dist/adapters/desktop/wait-poll.js +38 -0
- package/dist/adapters/desktop/wait-poll.js.map +1 -0
- package/dist/adapters/factory.d.ts +13 -6
- package/dist/adapters/factory.js +30 -4
- package/dist/adapters/factory.js.map +1 -1
- package/dist/adapters/log-format.d.ts +38 -0
- package/dist/adapters/log-format.js +47 -0
- package/dist/adapters/log-format.js.map +1 -0
- package/dist/agent/belt/act.d.ts +426 -23
- package/dist/agent/belt/act.js +44 -64
- package/dist/agent/belt/act.js.map +1 -1
- package/dist/agent/belt/look.d.ts +479 -16
- package/dist/agent/belt/look.js +94 -16
- package/dist/agent/belt/look.js.map +1 -1
- package/dist/agent/belt/observe.d.ts +652 -65
- package/dist/agent/belt/observe.js +119 -231
- package/dist/agent/belt/observe.js.map +1 -1
- package/dist/agent/belt/redact-output.d.ts +20 -0
- package/dist/agent/belt/redact-output.js +70 -0
- package/dist/agent/belt/redact-output.js.map +1 -0
- package/dist/agent/belt/report.d.ts +754 -48
- package/dist/agent/belt/report.js +121 -38
- package/dist/agent/belt/report.js.map +1 -1
- package/dist/agent/belt/same-origin.d.ts +21 -0
- package/dist/agent/belt/same-origin.js +38 -0
- package/dist/agent/belt/same-origin.js.map +1 -0
- package/dist/agent/belt/target-refs.d.ts +39 -0
- package/dist/agent/belt/target-refs.js +60 -0
- package/dist/agent/belt/target-refs.js.map +1 -0
- package/dist/agent/belt/trail.d.ts +44 -16
- package/dist/agent/belt/trail.js +46 -11
- package/dist/agent/belt/trail.js.map +1 -1
- package/dist/agent/belt/tree-targets.d.ts +79 -0
- package/dist/agent/belt/tree-targets.js +242 -0
- package/dist/agent/belt/tree-targets.js.map +1 -0
- package/dist/agent/capabilities.js.map +1 -1
- package/dist/agent/fallback.d.ts +33 -0
- package/dist/agent/fallback.js +84 -0
- package/dist/agent/fallback.js.map +1 -0
- package/dist/agent/loop-frames.d.ts +26 -0
- package/dist/agent/loop-frames.js +106 -0
- package/dist/agent/loop-frames.js.map +1 -0
- package/dist/agent/loop.d.ts +56 -65
- package/dist/agent/loop.js +122 -189
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/models.d.ts +10 -6
- package/dist/agent/models.js +15 -9
- package/dist/agent/models.js.map +1 -1
- package/dist/agent/prompts/compose.d.ts +1 -1
- package/dist/agent/prompts/debug-agent.js +48 -10
- package/dist/agent/prompts/debug-agent.js.map +1 -1
- package/dist/agent/prompts/web-addendum.d.ts +2 -2
- package/dist/agent/prompts/web-addendum.js +26 -25
- package/dist/agent/prompts/web-addendum.js.map +1 -1
- package/dist/agent/provider.d.ts +41 -1
- package/dist/agent/provider.js +59 -5
- package/dist/agent/provider.js.map +1 -1
- package/dist/boot.d.ts +64 -0
- package/dist/boot.js +147 -0
- package/dist/boot.js.map +1 -0
- package/dist/cli/chromium-libs.d.ts +267 -0
- package/dist/cli/chromium-libs.js +546 -0
- package/dist/cli/chromium-libs.js.map +1 -0
- package/dist/cli/control.js +79 -12
- package/dist/cli/control.js.map +1 -1
- package/dist/cli/init.d.ts +52 -3
- package/dist/cli/init.js +62 -10
- package/dist/cli/init.js.map +1 -1
- package/dist/config/load.d.ts +25 -8
- package/dist/config/load.js +50 -13
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +18 -6
- package/dist/config/schema.js +34 -17
- package/dist/config/schema.js.map +1 -1
- package/dist/errors.d.ts +30 -15
- package/dist/errors.js +49 -30
- package/dist/errors.js.map +1 -1
- package/dist/findings/schema.d.ts +44 -6
- package/dist/findings/schema.js +39 -3
- package/dist/findings/schema.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +4 -82
- package/dist/main.js.map +1 -1
- package/dist/mcp/server.js +10 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/describe.d.ts +5 -4
- package/dist/mcp/tools/describe.js +14 -10
- package/dist/mcp/tools/describe.js.map +1 -1
- package/dist/mcp/tools/end-session.d.ts +3 -1
- package/dist/mcp/tools/end-session.js +8 -3
- package/dist/mcp/tools/end-session.js.map +1 -1
- package/dist/mcp/tools/output.d.ts +12 -4
- package/dist/mcp/tools/output.js +15 -2
- package/dist/mcp/tools/output.js.map +1 -1
- package/dist/mcp/tools/result.d.ts +10 -1
- package/dist/mcp/tools/result.js +12 -7
- package/dist/mcp/tools/result.js.map +1 -1
- package/dist/mcp/tools/start-debug.js +7 -5
- package/dist/mcp/tools/start-debug.js.map +1 -1
- package/dist/redact.d.ts +44 -0
- package/dist/redact.js +166 -0
- package/dist/redact.js.map +1 -0
- package/dist/services/auth-persona.d.ts +19 -0
- package/dist/services/auth-persona.js +32 -0
- package/dist/services/auth-persona.js.map +1 -0
- package/dist/services/catalog.d.ts +28 -0
- package/dist/services/catalog.js +65 -0
- package/dist/services/catalog.js.map +1 -0
- package/dist/services/debug-api.d.ts +179 -0
- package/dist/services/debug-api.js +9 -0
- package/dist/services/debug-api.js.map +1 -0
- package/dist/services/debug-service.d.ts +26 -174
- package/dist/services/debug-service.js +159 -227
- package/dist/services/debug-service.js.map +1 -1
- package/dist/services/foreign-findings.d.ts +22 -0
- package/dist/services/foreign-findings.js +38 -0
- package/dist/services/foreign-findings.js.map +1 -0
- package/dist/services/login-failure.d.ts +10 -0
- package/dist/services/login-failure.js +24 -0
- package/dist/services/login-failure.js.map +1 -0
- package/dist/services/login-selectors.d.ts +18 -0
- package/dist/services/login-selectors.js +44 -0
- package/dist/services/login-selectors.js.map +1 -0
- package/dist/services/login-session.d.ts +25 -0
- package/dist/services/login-session.js +59 -0
- package/dist/services/login-session.js.map +1 -0
- package/dist/services/login.d.ts +16 -29
- package/dist/services/login.js +269 -97
- package/dist/services/login.js.map +1 -1
- package/dist/services/replay.js +15 -3
- package/dist/services/replay.js.map +1 -1
- package/dist/services/retained-snapshot.d.ts +36 -0
- package/dist/services/retained-snapshot.js +63 -0
- package/dist/services/retained-snapshot.js.map +1 -0
- package/dist/services/session-builder.d.ts +26 -0
- package/dist/services/session-builder.js +63 -21
- package/dist/services/session-builder.js.map +1 -1
- package/dist/services/shutdown.d.ts +8 -4
- package/dist/services/shutdown.js +21 -8
- package/dist/services/shutdown.js.map +1 -1
- package/dist/services/start-guards.d.ts +37 -0
- package/dist/services/start-guards.js +61 -0
- package/dist/services/start-guards.js.map +1 -0
- package/dist/services/summarize.d.ts +12 -3
- package/dist/services/summarize.js +13 -5
- package/dist/services/summarize.js.map +1 -1
- package/dist/session/cleanup.d.ts +3 -2
- package/dist/session/cleanup.js +6 -2
- package/dist/session/cleanup.js.map +1 -1
- package/dist/session/finalize.d.ts +45 -0
- package/dist/session/finalize.js +150 -0
- package/dist/session/finalize.js.map +1 -0
- package/dist/session/findings-store.d.ts +2 -1
- package/dist/session/findings-store.js +30 -2
- package/dist/session/findings-store.js.map +1 -1
- package/dist/session/flock-backend.d.ts +117 -0
- package/dist/session/flock-backend.js +293 -0
- package/dist/session/flock-backend.js.map +1 -0
- package/dist/session/live-pointer.d.ts +19 -0
- package/dist/session/live-pointer.js +41 -0
- package/dist/session/live-pointer.js.map +1 -0
- package/dist/session/manager.d.ts +11 -1
- package/dist/session/manager.js +46 -2
- package/dist/session/manager.js.map +1 -1
- package/dist/session/owner-lock.d.ts +117 -0
- package/dist/session/owner-lock.js +218 -0
- package/dist/session/owner-lock.js.map +1 -0
- package/dist/session/process-identity.js.map +1 -1
- package/dist/session/session.js +40 -109
- package/dist/session/session.js.map +1 -1
- package/dist/session/state-file.d.ts +74 -14
- package/dist/session/state-file.js +211 -21
- package/dist/session/state-file.js.map +1 -1
- package/dist/session/workspace.d.ts +32 -2
- package/dist/session/workspace.js +65 -4
- package/dist/session/workspace.js.map +1 -1
- package/package.json +11 -11
- package/dist/adapters/android/android-adapter.test-helpers.d.ts +0 -52
- package/dist/adapters/android/android-adapter.test-helpers.js +0 -115
- package/dist/adapters/android/android-adapter.test-helpers.js.map +0 -1
- package/dist/mcp/server.test-helpers.d.ts +0 -23
- package/dist/mcp/server.test-helpers.js +0 -49
- package/dist/mcp/server.test-helpers.js.map +0 -1
|
@@ -24,6 +24,14 @@ import { AdapterError } from '../../errors.js';
|
|
|
24
24
|
*/
|
|
25
25
|
export declare const LAUNCH_TIMEOUT_MS = 30000;
|
|
26
26
|
export declare const NAV_TIMEOUT_MS = 30000;
|
|
27
|
+
/**
|
|
28
|
+
* The fixed cap for the attach-teardown restore navigation (returning an adopted
|
|
29
|
+
* tab to its pre-run URL). Teardown has no run budget left to shorten it — the
|
|
30
|
+
* run is already over — so this constant IS the bound: it caps how long
|
|
31
|
+
* `end_session` can hang on a wedged `goto` before the best-effort restore
|
|
32
|
+
* gives up and the disconnect proceeds.
|
|
33
|
+
*/
|
|
34
|
+
export declare const RESTORE_TIMEOUT_MS = 10000;
|
|
27
35
|
/**
|
|
28
36
|
* Pick the Chromium binary for a managed launch. Order:
|
|
29
37
|
* 1. explicit `executablePath` from config
|
|
@@ -56,11 +64,12 @@ export declare function appendDebugLogin(target: string, debugLogin?: {
|
|
|
56
64
|
* Recast a "nothing is listening" navigation failure as an error that names the
|
|
57
65
|
* address, or `null` when the failure was something else.
|
|
58
66
|
*
|
|
59
|
-
* `describe.operational`
|
|
60
|
-
*
|
|
61
|
-
* is
|
|
62
|
-
*
|
|
63
|
-
*
|
|
67
|
+
* `describe.operational` reports whether the adapter kind is wired in this build
|
|
68
|
+
* AND supported on the host platform — it says nothing about whether
|
|
69
|
+
* `http://localhost:5173` is actually serving. So a dev server that is down used
|
|
70
|
+
* to spend a whole run: the driver launched, navigated, read an empty page, and
|
|
71
|
+
* reported it as a broken UI — indistinguishable, to the caller, from a real
|
|
72
|
+
* defect. This is that run ending on step zero instead, with the port in the
|
|
64
73
|
* message.
|
|
65
74
|
*/
|
|
66
75
|
export declare function unreachableFailure(error: unknown, url: string): AdapterError | null;
|
|
@@ -29,6 +29,14 @@ const DEFAULT_CHANNEL = 'chrome';
|
|
|
29
29
|
*/
|
|
30
30
|
export const LAUNCH_TIMEOUT_MS = 30_000;
|
|
31
31
|
export const NAV_TIMEOUT_MS = 30_000;
|
|
32
|
+
/**
|
|
33
|
+
* The fixed cap for the attach-teardown restore navigation (returning an adopted
|
|
34
|
+
* tab to its pre-run URL). Teardown has no run budget left to shorten it — the
|
|
35
|
+
* run is already over — so this constant IS the bound: it caps how long
|
|
36
|
+
* `end_session` can hang on a wedged `goto` before the best-effort restore
|
|
37
|
+
* gives up and the disconnect proceeds.
|
|
38
|
+
*/
|
|
39
|
+
export const RESTORE_TIMEOUT_MS = 10_000;
|
|
32
40
|
/** Detect the Playwright-managed Chromium binary; null if it isn't installed. */
|
|
33
41
|
function detectManagedChromium() {
|
|
34
42
|
try {
|
|
@@ -96,11 +104,12 @@ const UNREACHABLE = /net::ERR_(CONNECTION_REFUSED|CONNECTION_RESET|CONNECTION_TI
|
|
|
96
104
|
* Recast a "nothing is listening" navigation failure as an error that names the
|
|
97
105
|
* address, or `null` when the failure was something else.
|
|
98
106
|
*
|
|
99
|
-
* `describe.operational`
|
|
100
|
-
*
|
|
101
|
-
* is
|
|
102
|
-
*
|
|
103
|
-
*
|
|
107
|
+
* `describe.operational` reports whether the adapter kind is wired in this build
|
|
108
|
+
* AND supported on the host platform — it says nothing about whether
|
|
109
|
+
* `http://localhost:5173` is actually serving. So a dev server that is down used
|
|
110
|
+
* to spend a whole run: the driver launched, navigated, read an empty page, and
|
|
111
|
+
* reported it as a broken UI — indistinguishable, to the caller, from a real
|
|
112
|
+
* defect. This is that run ending on step zero instead, with the port in the
|
|
104
113
|
* message.
|
|
105
114
|
*/
|
|
106
115
|
export function unreachableFailure(error, url) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launch.js","sourceRoot":"","sources":["../../../src/adapters/browser/launch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,+EAA+E;AAE/E,oFAAoF;AACpF,MAAM,eAAe,GAAG,QAAQ,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AAErC,iFAAiF;AACjF,SAAS,qBAAqB;IAC5B,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,QAAQ,CAAC,cAAc,EAAE,CAAC;QACpC,OAAO,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC,CAAC,mCAAmC;IAClD,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"launch.js","sourceRoot":"","sources":["../../../src/adapters/browser/launch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC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
+
*
|
|
4
|
+
* Two lifecycles (see `idea/adapters.md`):
|
|
5
|
+
* - **managed** (default): launch a persistent context with the per-project
|
|
6
|
+
* profile; we OWN start/stop. `executablePath` picks the binary, else system
|
|
7
|
+
* Chrome (`channel`) — `playwright-core` ships no bundled browser.
|
|
8
|
+
* - **attach**: connect to an already-running browser over CDP (`cdpUrl`) and
|
|
9
|
+
* NEVER start/stop it — `close()` returns the adopted tab to its pre-run
|
|
10
|
+
* URL (best-effort) and then disconnects.
|
|
11
|
+
*
|
|
12
|
+
* Split out of `browser-adapter.ts` (500-LOC cap): this module only ASSEMBLES the
|
|
13
|
+
* raw {@link AdapterHandles}; the adapter class alone turns them into a
|
|
14
|
+
* `BrowserAdapter` (its constructor stays private there), so the dependency runs
|
|
15
|
+
* one way — nothing here imports the class.
|
|
16
|
+
*
|
|
17
|
+
* Fails loud — every Playwright call is wrapped to throw {@link AdapterError}
|
|
18
|
+
* (`createFailure` names the failing lifecycle; see `launch.ts`).
|
|
19
|
+
*/
|
|
20
|
+
import type { Browser, BrowserContext, Page } from 'playwright-core';
|
|
21
|
+
import { chromium } from 'playwright-core';
|
|
22
|
+
import type { WebTarget } from '../../config/schema.js';
|
|
23
|
+
import type { CaptureSink } from './cdp.js';
|
|
24
|
+
import { CdpCapture } from './cdp.js';
|
|
25
|
+
import { TabContext } from './tab-context.js';
|
|
26
|
+
export interface AdapterHandles {
|
|
27
|
+
config: WebTarget;
|
|
28
|
+
context: BrowserContext;
|
|
29
|
+
page: Page;
|
|
30
|
+
browser: Browser | null;
|
|
31
|
+
mode: 'managed' | 'attach';
|
|
32
|
+
capture: CdpCapture;
|
|
33
|
+
/** The run's tab registry — one naming scheme for the capture and the adapter. */
|
|
34
|
+
tabs: TabContext;
|
|
35
|
+
/**
|
|
36
|
+
* `true` when attach found no tab to adopt and OPENED `page` itself — a tab in
|
|
37
|
+
* a browser we do not own, so teardown closes it rather than leave it behind.
|
|
38
|
+
* Always `false` for managed (the whole context is ours and closes anyway).
|
|
39
|
+
*/
|
|
40
|
+
createdPage: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** The slice of `chromium` this adapter actually calls — the test seam below overrides it. */
|
|
43
|
+
type ChromiumLauncher = Pick<typeof chromium, 'launchPersistentContext' | 'connectOverCDP'>;
|
|
44
|
+
export interface BrowserAdapterInit {
|
|
45
|
+
/** Resolved web-target config (url, headless, debugLogin, cdpUrl, …). */
|
|
46
|
+
config: WebTarget;
|
|
47
|
+
/** Absolute persistent-profile dir for a managed launch; ignored when attaching. */
|
|
48
|
+
profileDir: string;
|
|
49
|
+
/** Optional sink for streaming captured console/network lines to `findings-store`. */
|
|
50
|
+
onLog?: CaptureSink;
|
|
51
|
+
/** Override the Playwright launcher/connector (test seam) — defaults to the real `chromium`. */
|
|
52
|
+
chromium?: ChromiumLauncher;
|
|
53
|
+
/**
|
|
54
|
+
* The run's remaining wall-clock budget (ms) for getting Chrome up. Shortens the
|
|
55
|
+
* launch/connect wait so it fits inside the caller's `timeout`; omit for the default.
|
|
56
|
+
*/
|
|
57
|
+
timeoutMs?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Assemble the adapter's raw handles: attach over `cdpUrl` when set, else launch a
|
|
61
|
+
* managed persistent context.
|
|
62
|
+
*/
|
|
63
|
+
export declare function openBrowserHandles(init: BrowserAdapterInit): Promise<AdapterHandles>;
|
|
64
|
+
/**
|
|
65
|
+
* What attach teardown owes the tab it drove: the ADOPTED tab goes back to the
|
|
66
|
+
* URL it carried at attach; a tab attach OPENED itself (the browser had none to
|
|
67
|
+
* adopt) is closed — "restoring" it to `about:blank` would leave a stray tab in
|
|
68
|
+
* a browser that is not ours.
|
|
69
|
+
*/
|
|
70
|
+
export type TabHandBack = {
|
|
71
|
+
page: Page;
|
|
72
|
+
url: string;
|
|
73
|
+
} | {
|
|
74
|
+
page: Page;
|
|
75
|
+
close: true;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Hand the attached tab back (see {@link TabHandBack}); `null` does nothing.
|
|
79
|
+
*
|
|
80
|
+
* A tab the run never moved already sits on the snapshot, so it is not reloaded
|
|
81
|
+
* — navigating it again would only flash the owner's screen. Every failure is
|
|
82
|
+
* swallowed on purpose: the browser was never ours, the run is already over,
|
|
83
|
+
* and neither a wedged `goto` nor a tab the owner closed mid-run — reading a dead
|
|
84
|
+
* handle's address throws — may fail the teardown or skip the disconnect that
|
|
85
|
+
* follows (same best-effort posture as `closeOnFailure` in `launch.ts`).
|
|
86
|
+
* `waitMs` (default `RESTORE_TIMEOUT_MS`) caps BOTH waits — teardown has no run
|
|
87
|
+
* budget to shorten, and `page.close()` has no timeout of its own: a browser that
|
|
88
|
+
* keeps the socket open but never answers would otherwise block the disconnect.
|
|
89
|
+
*/
|
|
90
|
+
export declare function handBackTab(handBack: TabHandBack | null, waitMs?: number): Promise<void>;
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-adapter lifecycle — how the adapter's handles come to be.
|
|
3
|
+
*
|
|
4
|
+
* Two lifecycles (see `idea/adapters.md`):
|
|
5
|
+
* - **managed** (default): launch a persistent context with the per-project
|
|
6
|
+
* profile; we OWN start/stop. `executablePath` picks the binary, else system
|
|
7
|
+
* Chrome (`channel`) — `playwright-core` ships no bundled browser.
|
|
8
|
+
* - **attach**: connect to an already-running browser over CDP (`cdpUrl`) and
|
|
9
|
+
* NEVER start/stop it — `close()` returns the adopted tab to its pre-run
|
|
10
|
+
* URL (best-effort) and then disconnects.
|
|
11
|
+
*
|
|
12
|
+
* Split out of `browser-adapter.ts` (500-LOC cap): this module only ASSEMBLES the
|
|
13
|
+
* raw {@link AdapterHandles}; the adapter class alone turns them into a
|
|
14
|
+
* `BrowserAdapter` (its constructor stays private there), so the dependency runs
|
|
15
|
+
* one way — nothing here imports the class.
|
|
16
|
+
*
|
|
17
|
+
* Fails loud — every Playwright call is wrapped to throw {@link AdapterError}
|
|
18
|
+
* (`createFailure` names the failing lifecycle; see `launch.ts`).
|
|
19
|
+
*/
|
|
20
|
+
import { chromium } from 'playwright-core';
|
|
21
|
+
import { AdapterError } from '../../errors.js';
|
|
22
|
+
import { capWait } from '../budget.js';
|
|
23
|
+
import { CdpCapture } from './cdp.js';
|
|
24
|
+
import { withTimeout } from './exchange-read.js';
|
|
25
|
+
import { closeOnFailure, createFailure, LAUNCH_TIMEOUT_MS, RESTORE_TIMEOUT_MS, resolveLaunchBinary, } from './launch.js';
|
|
26
|
+
import { TabContext } from './tab-context.js';
|
|
27
|
+
/**
|
|
28
|
+
* Assemble the adapter's raw handles: attach over `cdpUrl` when set, else launch a
|
|
29
|
+
* managed persistent context.
|
|
30
|
+
*/
|
|
31
|
+
export async function openBrowserHandles(init) {
|
|
32
|
+
const { cdpUrl } = init.config;
|
|
33
|
+
const launcher = init.chromium ?? chromium;
|
|
34
|
+
// ONE registry names every tab of this run: the capture stamps a row with the
|
|
35
|
+
// label of the page it fired on, and the adapter's `tabs()` listing reports
|
|
36
|
+
// the same label — so a `[tab-2]` marker in the durable log resolves to the
|
|
37
|
+
// tab the driver drove.
|
|
38
|
+
const tabs = new TabContext();
|
|
39
|
+
// Nothing raw escapes: launch, connect and post-connect wiring all leave here as
|
|
40
|
+
// AdapterError (header contract). Cleanup of a half-built adapter happens below.
|
|
41
|
+
const wait = capWait(LAUNCH_TIMEOUT_MS, init.timeoutMs);
|
|
42
|
+
try {
|
|
43
|
+
return cdpUrl
|
|
44
|
+
? await attachHandles(init.config, launcher, wait, init.onLog, tabs)
|
|
45
|
+
: await launchHandles(init.config, init.profileDir, launcher, wait, init.onLog, tabs);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw createFailure(error, cdpUrl ? { mode: 'attach', cdpUrl } : { mode: 'managed', profileDir: init.profileDir });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function launchHandles(config, profileDir, launcher, timeout, onLog, tabs) {
|
|
52
|
+
// Still CDP: Playwright drives Chromium exclusively over the DevTools Protocol
|
|
53
|
+
// (here a CDP pipe; `attachHandles` uses a CDP WebSocket). A persistent context is the
|
|
54
|
+
// supported way to own a Chrome process WITH the per-project profile — both
|
|
55
|
+
// managed and attach speak the same protocol, only the transport differs.
|
|
56
|
+
const context = await launcher.launchPersistentContext(profileDir, {
|
|
57
|
+
headless: config.headless,
|
|
58
|
+
timeout,
|
|
59
|
+
// Signals stay with `main.ts`, which owns the graceful shutdown. These default
|
|
60
|
+
// to `true`, and Playwright's own SIGINT handler is
|
|
61
|
+
// `gracefullyCloseAll().then(() => process.exit(130))` — it ran right after
|
|
62
|
+
// ours started and killed the process mid-teardown, so the terminal findings
|
|
63
|
+
// write, the summary and `replay.mp4` never landed and `state.json` was left
|
|
64
|
+
// saying `running`. On SIGTERM it closed Chrome underneath a loop that was
|
|
65
|
+
// still unwinding, and the last flush died as `Target closed`.
|
|
66
|
+
handleSIGINT: false,
|
|
67
|
+
handleSIGTERM: false,
|
|
68
|
+
handleSIGHUP: false,
|
|
69
|
+
...resolveLaunchBinary(config),
|
|
70
|
+
});
|
|
71
|
+
// Chrome is LIVE from here on and holds the profile lock — a throw past this point
|
|
72
|
+
// must close it, or every later run of this project fails to launch.
|
|
73
|
+
return closeOnFailure(context, async () => {
|
|
74
|
+
const page = context.pages()[0] ?? (await context.newPage());
|
|
75
|
+
const capture = startCapture(page, onLog, tabs);
|
|
76
|
+
return {
|
|
77
|
+
config,
|
|
78
|
+
context,
|
|
79
|
+
page,
|
|
80
|
+
browser: null,
|
|
81
|
+
mode: 'managed',
|
|
82
|
+
capture,
|
|
83
|
+
tabs,
|
|
84
|
+
createdPage: false,
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async function attachHandles(config, launcher, timeout, onLog, tabs) {
|
|
89
|
+
if (!config.cdpUrl) {
|
|
90
|
+
throw new AdapterError('attach mode requires `cdpUrl`');
|
|
91
|
+
}
|
|
92
|
+
const browser = await launcher.connectOverCDP(config.cdpUrl, { timeout });
|
|
93
|
+
// Cleanup here drops the CONNECTION only — same disconnect semantics `close()`
|
|
94
|
+
// relies on, so a failed attach never stops a browser we did not start.
|
|
95
|
+
return closeOnFailure(browser, async () => {
|
|
96
|
+
const context = browser.contexts()[0] ?? (await browser.newContext());
|
|
97
|
+
const adopted = context.pages()[0];
|
|
98
|
+
const page = adopted ?? (await context.newPage());
|
|
99
|
+
const capture = startCapture(page, onLog, tabs);
|
|
100
|
+
const createdPage = adopted === undefined;
|
|
101
|
+
return { config, context, page, browser, mode: 'attach', capture, tabs, createdPage };
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/** Wire console/network capture onto the live page before the first navigation. */
|
|
105
|
+
function startCapture(page, onLog, tabs) {
|
|
106
|
+
const capture = new CdpCapture({ page, sink: onLog, tabs });
|
|
107
|
+
capture.start();
|
|
108
|
+
return capture;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Hand the attached tab back (see {@link TabHandBack}); `null` does nothing.
|
|
112
|
+
*
|
|
113
|
+
* A tab the run never moved already sits on the snapshot, so it is not reloaded
|
|
114
|
+
* — navigating it again would only flash the owner's screen. Every failure is
|
|
115
|
+
* swallowed on purpose: the browser was never ours, the run is already over,
|
|
116
|
+
* and neither a wedged `goto` nor a tab the owner closed mid-run — reading a dead
|
|
117
|
+
* handle's address throws — may fail the teardown or skip the disconnect that
|
|
118
|
+
* follows (same best-effort posture as `closeOnFailure` in `launch.ts`).
|
|
119
|
+
* `waitMs` (default `RESTORE_TIMEOUT_MS`) caps BOTH waits — teardown has no run
|
|
120
|
+
* budget to shorten, and `page.close()` has no timeout of its own: a browser that
|
|
121
|
+
* keeps the socket open but never answers would otherwise block the disconnect.
|
|
122
|
+
*/
|
|
123
|
+
export async function handBackTab(handBack, waitMs = RESTORE_TIMEOUT_MS) {
|
|
124
|
+
if (!handBack)
|
|
125
|
+
return;
|
|
126
|
+
try {
|
|
127
|
+
if ('close' in handBack) {
|
|
128
|
+
const closing = handBack.page.close();
|
|
129
|
+
closing.catch(() => undefined); // abandoned past the cap: never unhandled
|
|
130
|
+
await withTimeout(closing, waitMs);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (handBack.page.url() === handBack.url)
|
|
134
|
+
return;
|
|
135
|
+
await handBack.page.goto(handBack.url, { timeout: waitMs });
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// Best-effort only — the caller's disconnect must still happen.
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../src/adapters/browser/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EACL,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAsC9C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAwB;IAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC;IAC3C,8EAA8E;IAC9E,4EAA4E;IAC5E,4EAA4E;IAC5E,wBAAwB;IACxB,MAAM,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC;IAC9B,iFAAiF;IACjF,iFAAiF;I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,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IACxF,CAAC,CAAC,CAAC;AACL,CAAC;AAED,mFAAmF;AACnF,SAAS,YAAY,CAAC,IAAU,EAAE,KAA8B,EAAE,IAAgB;IAChF,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,OAAO,CAAC,KAAK,EAAE,CAAC;IAChB,OAAO,OAAO,CAAC;AACjB,CAAC;AAUD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,QAA4B,EAC5B,MAAM,GAAW,kBAAkB;IAEnC,IAAI,CAAC,QAAQ;QAAE,OAAO;IACtB,IAAI,CAAC;QACH,IAAI,OAAO,IAAI,QAAQ,EAAE,CAAC;YACxB,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACtC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,0CAA0C;YAC1E,MAAM,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACnC,OAAO;QACT,CAAC;QACD,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,QAAQ,CAAC,GAAG;YAAE,OAAO;QACjD,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACP,gEAAgE;IAClE,CAAC;AACH,CAAC"}
|
|
@@ -31,9 +31,10 @@ export declare function locateAcrossFrames(page: Page, selector: string): Promis
|
|
|
31
31
|
* frame in parallel. A Playwright wait cannot be cancelled, so the parallel form
|
|
32
32
|
* leaves a poller hammering the page for every frame that never matches — long
|
|
33
33
|
* after the wait it belonged to returned. Re-reading `frames()` each pass also
|
|
34
|
-
* picks up frames that appear mid-wait.
|
|
34
|
+
* picks up frames that appear mid-wait. The slices are also what make `signal`
|
|
35
|
+
* work: an abort is checked before every slice, so the poll stops within one.
|
|
35
36
|
*/
|
|
36
|
-
export declare function waitAcrossFrames(page: Page, query: string, timeout?: number): Promise<void>;
|
|
37
|
+
export declare function waitAcrossFrames(page: Page, query: string, timeout?: number, signal?: AbortSignal): Promise<void>;
|
|
37
38
|
/**
|
|
38
39
|
* Resolve a `within` scope to a rectangle in PAGE coordinates — {@link Node}
|
|
39
40
|
* bounds as given, a selector via {@link locateAcrossFrames} so a scrollable
|
|
@@ -42,3 +43,18 @@ export declare function waitAcrossFrames(page: Page, query: string, timeout?: nu
|
|
|
42
43
|
* element, so a viewport guard downstream stays correct.
|
|
43
44
|
*/
|
|
44
45
|
export declare function regionAcrossFrames(page: Page, within: NodeRef): Promise<Bounds>;
|
|
46
|
+
/**
|
|
47
|
+
* The rejection an aborted wait settles with: the signal's own reason when it is
|
|
48
|
+
* already `AbortError`-named (what `AbortController.abort()` gives), else a fresh
|
|
49
|
+
* `AbortError` — the contract promises that NAME, which is what the belt and the
|
|
50
|
+
* loop key off, and a custom reason (or `AbortSignal.timeout`'s `TimeoutError`)
|
|
51
|
+
* would otherwise read as an ordinary adapter failure.
|
|
52
|
+
*/
|
|
53
|
+
export declare function abortError(signal: AbortSignal): Error;
|
|
54
|
+
/**
|
|
55
|
+
* `work`, or an {@link abortError} the moment `signal` aborts — whichever comes
|
|
56
|
+
* first. The abort listener is removed on EVERY path, and the losing `work` gets
|
|
57
|
+
* a handler, so an abandoned wait that rejects later is never an unhandled
|
|
58
|
+
* rejection.
|
|
59
|
+
*/
|
|
60
|
+
export declare function raceAbort<T>(work: Promise<T>, signal: AbortSignal): Promise<T>;
|
|
@@ -51,27 +51,37 @@ export async function locateAcrossFrames(page, selector) {
|
|
|
51
51
|
* frame in parallel. A Playwright wait cannot be cancelled, so the parallel form
|
|
52
52
|
* leaves a poller hammering the page for every frame that never matches — long
|
|
53
53
|
* after the wait it belonged to returned. Re-reading `frames()` each pass also
|
|
54
|
-
* picks up frames that appear mid-wait.
|
|
54
|
+
* picks up frames that appear mid-wait. The slices are also what make `signal`
|
|
55
|
+
* work: an abort is checked before every slice, so the poll stops within one.
|
|
55
56
|
*/
|
|
56
|
-
export async function waitAcrossFrames(page, query, timeout) {
|
|
57
|
+
export async function waitAcrossFrames(page, query, timeout, signal) {
|
|
57
58
|
const selector = normalizeQuery(query);
|
|
58
59
|
const budget = timeout ?? WAIT_TIMEOUT_MS;
|
|
59
60
|
const deadline = Date.now() + budget;
|
|
60
61
|
do {
|
|
61
62
|
for (const frame of page.frames()) {
|
|
63
|
+
if (signal?.aborted)
|
|
64
|
+
throw abortError(signal);
|
|
62
65
|
const slice = Math.min(WAIT_SLICE_MS, Math.max(1, deadline - Date.now()));
|
|
63
66
|
try {
|
|
64
67
|
await frame.locator(selector).first().waitFor({ state: 'visible', timeout: slice });
|
|
65
|
-
return;
|
|
66
68
|
}
|
|
67
69
|
catch (error) {
|
|
68
70
|
// Not-here-yet (a slice timing out) and a frame that vanished are both
|
|
69
71
|
// "try the next one"; a bad selector is the caller's mistake — fail loud.
|
|
70
72
|
if (!isTimeout(error) && !isFrameGone(error, frame.isDetached()))
|
|
71
73
|
throw error;
|
|
74
|
+
continue;
|
|
72
75
|
}
|
|
76
|
+
// Found — but a match that lands AFTER an abort must not let the caller go on
|
|
77
|
+
// to its next phase (a networkidle wait) for a run that already ended.
|
|
78
|
+
if (signal?.aborted)
|
|
79
|
+
throw abortError(signal);
|
|
80
|
+
return;
|
|
73
81
|
}
|
|
74
82
|
} while (Date.now() < deadline);
|
|
83
|
+
if (signal?.aborted)
|
|
84
|
+
throw abortError(signal);
|
|
75
85
|
throw new AdapterError(`waitFor: ${JSON.stringify(query)} never became visible in any frame within ${budget}ms`);
|
|
76
86
|
}
|
|
77
87
|
/**
|
|
@@ -90,4 +100,39 @@ export async function regionAcrossFrames(page, within) {
|
|
|
90
100
|
}
|
|
91
101
|
return box;
|
|
92
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* The rejection an aborted wait settles with: the signal's own reason when it is
|
|
105
|
+
* already `AbortError`-named (what `AbortController.abort()` gives), else a fresh
|
|
106
|
+
* `AbortError` — the contract promises that NAME, which is what the belt and the
|
|
107
|
+
* loop key off, and a custom reason (or `AbortSignal.timeout`'s `TimeoutError`)
|
|
108
|
+
* would otherwise read as an ordinary adapter failure.
|
|
109
|
+
*/
|
|
110
|
+
export function abortError(signal) {
|
|
111
|
+
const reason = signal.reason;
|
|
112
|
+
if (reason instanceof Error && reason.name === 'AbortError')
|
|
113
|
+
return reason;
|
|
114
|
+
return new DOMException('waitFor aborted — the run ended', 'AbortError');
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* `work`, or an {@link abortError} the moment `signal` aborts — whichever comes
|
|
118
|
+
* first. The abort listener is removed on EVERY path, and the losing `work` gets
|
|
119
|
+
* a handler, so an abandoned wait that rejects later is never an unhandled
|
|
120
|
+
* rejection.
|
|
121
|
+
*/
|
|
122
|
+
export async function raceAbort(work, signal) {
|
|
123
|
+
let onAbort = () => undefined;
|
|
124
|
+
const aborted = new Promise((_, reject) => {
|
|
125
|
+
onAbort = () => reject(abortError(signal));
|
|
126
|
+
});
|
|
127
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
128
|
+
try {
|
|
129
|
+
if (signal.aborted)
|
|
130
|
+
onAbort();
|
|
131
|
+
return await Promise.race([work, aborted]);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
signal.removeEventListener('abort', onAbort);
|
|
135
|
+
work.catch(() => undefined);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
93
138
|
//# sourceMappingURL=locate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locate.js","sourceRoot":"","sources":["../../../src/adapters/browser/locate.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MAAM,CAAC,MAAM,CAAC;IACtC,IAAI,MAAM,YAAY,KAAK,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,MAAM,CAAC;IAC3E,OAAO,IAAI,YAAY,CAAC,iCAAiC,EAAE,YAAY,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,IAAgB,EAAE,MAAmB;IACtE,IAAI,OAAO,GAAG,GAAS,EAAE,CAAC,SAAS,CAAC;IACpC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAC/C,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,IAAI,CAAC;QACH,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO,EAAE,CAAC;QAC9B,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7C,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { ConsoleEntry, Filters, NetworkEntry } from '../contract.js';
|
|
10
10
|
/** Whitelisted `filters` keys for the console channel — anything else is rejected. */
|
|
11
|
-
export declare const CONSOLE_FILTER_KEYS: readonly [
|
|
11
|
+
export declare const CONSOLE_FILTER_KEYS: readonly ['level_eq', 'level_in', 'text_contains'];
|
|
12
12
|
/** Whitelisted `filters` keys for the network channel — anything else is rejected. */
|
|
13
|
-
export declare const NETWORK_FILTER_KEYS: readonly [
|
|
13
|
+
export declare const NETWORK_FILTER_KEYS: readonly ['status_eq', 'status_gte', 'status_lt', 'ok_eq', 'failed_eq', 'pending_eq', 'method_eq', 'resource_in', 'url_contains', 'duration_gte', 'body_contains'];
|
|
14
14
|
/**
|
|
15
15
|
* Narrow console entries by the whitelisted `filters` keys
|
|
16
16
|
* ({@link CONSOLE_FILTER_KEYS}). Throws {@link AdapterError} on an unknown key
|
|
@@ -16,6 +16,7 @@ export const NETWORK_FILTER_KEYS = [
|
|
|
16
16
|
'status_lt',
|
|
17
17
|
'ok_eq',
|
|
18
18
|
'failed_eq',
|
|
19
|
+
'pending_eq',
|
|
19
20
|
'method_eq',
|
|
20
21
|
'resource_in',
|
|
21
22
|
'url_contains',
|
|
@@ -85,27 +86,31 @@ export function filterConsole(entries, filters) {
|
|
|
85
86
|
export function filterNetwork(entries, filters) {
|
|
86
87
|
if (!filters)
|
|
87
88
|
return entries;
|
|
89
|
+
// An in-flight row's `status: 0` / `ok: false` mean "no answer YET", not a
|
|
90
|
+
// failure — so status/ok predicates skip it unless the caller names
|
|
91
|
+
// `pending_eq`, or `status_lt: 400` would file a slow request as a failed one.
|
|
92
|
+
const settled = 'pending_eq' in filters ? () => true : (e) => e.pending !== true;
|
|
88
93
|
let out = entries;
|
|
89
94
|
for (const [key, value] of Object.entries(filters)) {
|
|
90
95
|
switch (key) {
|
|
91
96
|
case 'status_eq': {
|
|
92
97
|
const want = expectNumber(key, value);
|
|
93
|
-
out = out.filter((e) => e.status === want);
|
|
98
|
+
out = out.filter((e) => settled(e) && e.status === want);
|
|
94
99
|
break;
|
|
95
100
|
}
|
|
96
101
|
case 'status_gte': {
|
|
97
102
|
const want = expectNumber(key, value);
|
|
98
|
-
out = out.filter((e) => e.status >= want);
|
|
103
|
+
out = out.filter((e) => settled(e) && e.status >= want);
|
|
99
104
|
break;
|
|
100
105
|
}
|
|
101
106
|
case 'status_lt': {
|
|
102
107
|
const want = expectNumber(key, value);
|
|
103
|
-
out = out.filter((e) => e.status < want);
|
|
108
|
+
out = out.filter((e) => settled(e) && e.status < want);
|
|
104
109
|
break;
|
|
105
110
|
}
|
|
106
111
|
case 'ok_eq': {
|
|
107
112
|
const want = expectBoolean(key, value);
|
|
108
|
-
out = out.filter((e) => e.ok === want);
|
|
113
|
+
out = out.filter((e) => settled(e) && e.ok === want);
|
|
109
114
|
break;
|
|
110
115
|
}
|
|
111
116
|
case 'failed_eq': {
|
|
@@ -113,6 +118,12 @@ export function filterNetwork(entries, filters) {
|
|
|
113
118
|
out = out.filter((e) => (e.error !== undefined) === want);
|
|
114
119
|
break;
|
|
115
120
|
}
|
|
121
|
+
case 'pending_eq': {
|
|
122
|
+
// In flight at read time — never `failed` (no error) and never `ok` yet.
|
|
123
|
+
const want = expectBoolean(key, value);
|
|
124
|
+
out = out.filter((e) => (e.pending === true) === want);
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
116
127
|
case 'method_eq': {
|
|
117
128
|
const want = expectString(key, value).toUpperCase();
|
|
118
129
|
out = out.filter((e) => e.method.toUpperCase() === want);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-filters.js","sourceRoot":"","sources":["../../../src/adapters/browser/log-filters.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,sFAAsF;AACtF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,CAAU,CAAC;AAEtF,sFAAsF;AACtF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,WAAW;IACX,YAAY;IACZ,WAAW;IACX,OAAO;IACP,WAAW;IACX,WAAW;IACX,aAAa;IACb,cAAc;IACd,cAAc;IACd,eAAe;CACP,CAAC;AAEX,+EAA+E;AAE/E,SAAS,aAAa,CAAC,GAAW,EAAE,KAAkB;IACpD,I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ACjF,CAAC;QACN,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -2,12 +2,23 @@
|
|
|
2
2
|
* Rendering + redaction for captured console/network entries.
|
|
3
3
|
*
|
|
4
4
|
* Split out of `cdp.ts` to keep that file under the 500-LOC cap — no behavior
|
|
5
|
-
* change. Everything here is pure: level normalization, body truncation, the
|
|
6
|
-
* `logs
|
|
7
|
-
* of the model's context and out of the durable trail (a secret in a header
|
|
5
|
+
* change. Everything here is pure: level normalization, body truncation, the
|
|
6
|
+
* `logs/network.log` line renderer, and the two redactors that keep a credential
|
|
7
|
+
* out of the model's context and out of the durable trail (a secret in a header
|
|
8
8
|
* VALUE, or in a query param of the URL itself).
|
|
9
|
+
*
|
|
10
|
+
* The console-line renderer is SHARED (the android logcat drain renders the
|
|
11
|
+
* same shape), so it lives in `src/adapters/log-format.ts` and is re-exported
|
|
12
|
+
* here — every existing reader keeps its import path.
|
|
13
|
+
*
|
|
14
|
+
* Both renderers put the TAB MARKER between the timestamp and the row
|
|
15
|
+
* (`<ISO> [tab-1] LEVEL text @ location`, `<ISO> [tab-1] METHOD url → 200 …`),
|
|
16
|
+
* so a line says which tab produced it. The marker is an opaque label — no
|
|
17
|
+
* URL, no title, no secret — and a row without a tab renders exactly as it did
|
|
18
|
+
* before the marker existed.
|
|
9
19
|
*/
|
|
10
20
|
import type { ConsoleEntry, NetworkEntry } from '../contract.js';
|
|
21
|
+
export { formatConsoleLine } from '../log-format.js';
|
|
11
22
|
/**
|
|
12
23
|
* Per-body character cap. Big enough for an error payload or a small collection,
|
|
13
24
|
* small enough that the driver re-reading tool results every step cannot drown.
|
|
@@ -33,27 +44,19 @@ export declare function redactHeaders(headers: Record<string, string>): Record<s
|
|
|
33
44
|
*/
|
|
34
45
|
export declare function redactUrl(url: string): string;
|
|
35
46
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* body, in a `type` tool input on the agent trail, in whatever an adapter error
|
|
41
|
-
* echoes back. So this one keys off the VALUE — the only thing all three share —
|
|
42
|
-
* and is bound per run to the persona the caller named.
|
|
43
|
-
*
|
|
44
|
-
* Same posture as the other two: presence stays diagnostic (`<redacted, N chars>`
|
|
45
|
-
* still tells you a password of the right length was typed), the secret itself
|
|
46
|
-
* never reaches the durable trail. Form-encoded and JSON-escaped spellings are
|
|
47
|
-
* redacted too — a password with an `@` rides a form POST as `%40`, and matching
|
|
48
|
-
* only the plain text would leave the real body in `logs/network.log`.
|
|
47
|
+
* Copy a captured request/response body with credential-keyed values replaced by
|
|
48
|
+
* `<redacted, N chars>` — JSON (at any depth) and `application/x-www-form-urlencoded`.
|
|
49
|
+
* `contentType`, when the exchange's header is known, makes a declared form
|
|
50
|
+
* parse as one even if it breaks the shape heuristic (raw spaces).
|
|
49
51
|
*
|
|
50
|
-
*
|
|
52
|
+
* A login POST and the token response it gets back carry the secret in the BODY,
|
|
53
|
+
* which reaches the driver on every network read and `network.log` on failure;
|
|
54
|
+
* the header and URL redactors above never see it. Anything else (plain text, HTML,
|
|
55
|
+
* a body with nothing sensitive in it) comes back byte-for-byte untouched.
|
|
51
56
|
*/
|
|
52
|
-
export declare function
|
|
57
|
+
export declare function redactBody(body: string, contentType?: string): string;
|
|
53
58
|
/** Map a CDP console `type()` onto the normalized {@link ConsoleEntry} level. */
|
|
54
59
|
export declare function normalizeConsoleLevel(type: string): ConsoleEntry['level'];
|
|
55
|
-
/** Render a {@link ConsoleEntry} as one greppable `logs/console.log` line. */
|
|
56
|
-
export declare function formatConsoleLine(entry: ConsoleEntry): string;
|
|
57
60
|
/**
|
|
58
61
|
* Render a {@link NetworkEntry} as one greppable `logs/network.log` line.
|
|
59
62
|
*
|