@developerz.ai/ui-debugger-mcp 1.9.0 → 1.10.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 +56 -44
- 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 +42 -2
- package/dist/adapters/android/android-adapter.js +366 -36
- package/dist/adapters/android/android-adapter.js.map +1 -1
- package/dist/adapters/android/commands.js.map +1 -1
- 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 +98 -67
- package/dist/adapters/browser/browser-adapter.js.map +1 -1
- package/dist/adapters/browser/cdp.d.ts +15 -7
- package/dist/adapters/browser/cdp.js +25 -3
- package/dist/adapters/browser/cdp.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 +58 -0
- package/dist/adapters/browser/lifecycle.js +98 -0
- package/dist/adapters/browser/lifecycle.js.map +1 -0
- package/dist/adapters/browser/log-filters.d.ts +2 -2
- package/dist/adapters/browser/log-filters.js.map +1 -1
- package/dist/adapters/browser/log-format.d.ts +14 -23
- package/dist/adapters/browser/log-format.js +16 -55
- 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 +91 -5
- 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 +330 -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 +75 -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 +20 -2
- package/dist/adapters/desktop/desktop-adapter.js +91 -9
- package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
- package/dist/adapters/desktop/input.d.ts +18 -4
- package/dist/adapters/desktop/input.js +15 -10
- package/dist/adapters/desktop/input.js.map +1 -1
- package/dist/adapters/desktop/proc.d.ts +32 -4
- package/dist/adapters/desktop/proc.js +33 -6
- package/dist/adapters/desktop/proc.js.map +1 -1
- package/dist/adapters/factory.d.ts +12 -5
- package/dist/adapters/factory.js +29 -3
- package/dist/adapters/factory.js.map +1 -1
- package/dist/adapters/log-format.d.ts +32 -0
- package/dist/adapters/log-format.js +39 -0
- package/dist/adapters/log-format.js.map +1 -0
- package/dist/agent/belt/act.d.ts +421 -21
- package/dist/agent/belt/act.js +4 -4
- package/dist/agent/belt/act.js.map +1 -1
- package/dist/agent/belt/look.d.ts +471 -14
- package/dist/agent/belt/look.js +74 -12
- package/dist/agent/belt/look.js.map +1 -1
- package/dist/agent/belt/observe.d.ts +663 -42
- package/dist/agent/belt/observe.js +76 -12
- package/dist/agent/belt/observe.js.map +1 -1
- 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/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/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.d.ts +54 -52
- package/dist/agent/loop.js +173 -176
- 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 +45 -8
- package/dist/agent/prompts/debug-agent.js.map +1 -1
- package/dist/agent/prompts/web-addendum.d.ts +1 -1
- package/dist/agent/prompts/web-addendum.js +15 -3
- package/dist/agent/prompts/web-addendum.js.map +1 -1
- package/dist/agent/provider.d.ts +38 -0
- package/dist/agent/provider.js +55 -3
- package/dist/agent/provider.js.map +1 -1
- package/dist/boot.d.ts +64 -0
- package/dist/boot.js +145 -0
- package/dist/boot.js.map +1 -0
- package/dist/cli/chromium-libs.d.ts +262 -0
- package/dist/cli/chromium-libs.js +522 -0
- package/dist/cli/chromium-libs.js.map +1 -0
- package/dist/cli/control.js +51 -9
- 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 +40 -13
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +18 -6
- package/dist/config/schema.js +22 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +18 -0
- 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.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 +7 -3
- package/dist/mcp/tools/end-session.js.map +1 -1
- package/dist/mcp/tools/output.d.ts +5 -4
- package/dist/mcp/tools/output.js +10 -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 +8 -6
- 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 +28 -0
- package/dist/redact.js +51 -0
- package/dist/redact.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 +172 -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 +25 -173
- package/dist/services/debug-service.js +108 -175
- package/dist/services/debug-service.js.map +1 -1
- package/dist/services/login.d.ts +7 -2
- package/dist/services/login.js +203 -29
- package/dist/services/login.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 +46 -19
- package/dist/services/session-builder.js.map +1 -1
- package/dist/services/start-guards.d.ts +32 -0
- package/dist/services/start-guards.js +50 -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.js.map +1 -1
- 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/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 +208 -0
- package/dist/session/owner-lock.js +499 -0
- package/dist/session/owner-lock.js.map +1 -0
- package/dist/session/process-identity.js.map +1 -1
- package/dist/session/session.js +61 -7
- package/dist/session/session.js.map +1 -1
- package/dist/session/state-file.d.ts +74 -14
- package/dist/session/state-file.js +203 -21
- package/dist/session/state-file.js.map +1 -1
- package/package.json +7 -7
- 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
|
@@ -0,0 +1,58 @@
|
|
|
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 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
|
+
/** The slice of `chromium` this adapter actually calls — the test seam below overrides it. */
|
|
37
|
+
type ChromiumLauncher = Pick<typeof chromium, 'launchPersistentContext' | 'connectOverCDP'>;
|
|
38
|
+
export interface BrowserAdapterInit {
|
|
39
|
+
/** Resolved web-target config (url, headless, debugLogin, cdpUrl, …). */
|
|
40
|
+
config: WebTarget;
|
|
41
|
+
/** Absolute persistent-profile dir for a managed launch; ignored when attaching. */
|
|
42
|
+
profileDir: string;
|
|
43
|
+
/** Optional sink for streaming captured console/network lines to `findings-store`. */
|
|
44
|
+
onLog?: CaptureSink;
|
|
45
|
+
/** Override the Playwright launcher/connector (test seam) — defaults to the real `chromium`. */
|
|
46
|
+
chromium?: ChromiumLauncher;
|
|
47
|
+
/**
|
|
48
|
+
* The run's remaining wall-clock budget (ms) for getting Chrome up. Shortens the
|
|
49
|
+
* launch/connect wait so it fits inside the caller's `timeout`; omit for the default.
|
|
50
|
+
*/
|
|
51
|
+
timeoutMs?: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Assemble the adapter's raw handles: attach over `cdpUrl` when set, else launch a
|
|
55
|
+
* managed persistent context.
|
|
56
|
+
*/
|
|
57
|
+
export declare function openBrowserHandles(init: BrowserAdapterInit): Promise<AdapterHandles>;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
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 { closeOnFailure, createFailure, LAUNCH_TIMEOUT_MS, resolveLaunchBinary } from './launch.js';
|
|
25
|
+
import { TabContext } from './tab-context.js';
|
|
26
|
+
/**
|
|
27
|
+
* Assemble the adapter's raw handles: attach over `cdpUrl` when set, else launch a
|
|
28
|
+
* managed persistent context.
|
|
29
|
+
*/
|
|
30
|
+
export async function openBrowserHandles(init) {
|
|
31
|
+
const { cdpUrl } = init.config;
|
|
32
|
+
const launcher = init.chromium ?? chromium;
|
|
33
|
+
// ONE registry names every tab of this run: the capture stamps a row with the
|
|
34
|
+
// label of the page it fired on, and the adapter's `tabs()` listing reports
|
|
35
|
+
// the same label — so a `[tab-2]` marker in the durable log resolves to the
|
|
36
|
+
// tab the driver drove.
|
|
37
|
+
const tabs = new TabContext();
|
|
38
|
+
// Nothing raw escapes: launch, connect and post-connect wiring all leave here as
|
|
39
|
+
// AdapterError (header contract). Cleanup of a half-built adapter happens below.
|
|
40
|
+
const wait = capWait(LAUNCH_TIMEOUT_MS, init.timeoutMs);
|
|
41
|
+
try {
|
|
42
|
+
return cdpUrl
|
|
43
|
+
? await attachHandles(init.config, launcher, wait, init.onLog, tabs)
|
|
44
|
+
: await launchHandles(init.config, init.profileDir, launcher, wait, init.onLog, tabs);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
throw createFailure(error, cdpUrl ? { mode: 'attach', cdpUrl } : { mode: 'managed', profileDir: init.profileDir });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function launchHandles(config, profileDir, launcher, timeout, onLog, tabs) {
|
|
51
|
+
// Still CDP: Playwright drives Chromium exclusively over the DevTools Protocol
|
|
52
|
+
// (here a CDP pipe; `attachHandles` uses a CDP WebSocket). A persistent context is the
|
|
53
|
+
// supported way to own a Chrome process WITH the per-project profile — both
|
|
54
|
+
// managed and attach speak the same protocol, only the transport differs.
|
|
55
|
+
const context = await launcher.launchPersistentContext(profileDir, {
|
|
56
|
+
headless: config.headless,
|
|
57
|
+
timeout,
|
|
58
|
+
// Signals stay with `main.ts`, which owns the graceful shutdown. These default
|
|
59
|
+
// to `true`, and Playwright's own SIGINT handler is
|
|
60
|
+
// `gracefullyCloseAll().then(() => process.exit(130))` — it ran right after
|
|
61
|
+
// ours started and killed the process mid-teardown, so the terminal findings
|
|
62
|
+
// write, the summary and `replay.mp4` never landed and `state.json` was left
|
|
63
|
+
// saying `running`. On SIGTERM it closed Chrome underneath a loop that was
|
|
64
|
+
// still unwinding, and the last flush died as `Target closed`.
|
|
65
|
+
handleSIGINT: false,
|
|
66
|
+
handleSIGTERM: false,
|
|
67
|
+
handleSIGHUP: false,
|
|
68
|
+
...resolveLaunchBinary(config),
|
|
69
|
+
});
|
|
70
|
+
// Chrome is LIVE from here on and holds the profile lock — a throw past this point
|
|
71
|
+
// must close it, or every later run of this project fails to launch.
|
|
72
|
+
return closeOnFailure(context, async () => {
|
|
73
|
+
const page = context.pages()[0] ?? (await context.newPage());
|
|
74
|
+
const capture = startCapture(page, onLog, tabs);
|
|
75
|
+
return { config, context, page, browser: null, mode: 'managed', capture, tabs };
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async function attachHandles(config, launcher, timeout, onLog, tabs) {
|
|
79
|
+
if (!config.cdpUrl) {
|
|
80
|
+
throw new AdapterError('attach mode requires `cdpUrl`');
|
|
81
|
+
}
|
|
82
|
+
const browser = await launcher.connectOverCDP(config.cdpUrl, { timeout });
|
|
83
|
+
// Cleanup here drops the CONNECTION only — same disconnect semantics `close()`
|
|
84
|
+
// relies on, so a failed attach never stops a browser we did not start.
|
|
85
|
+
return closeOnFailure(browser, async () => {
|
|
86
|
+
const context = browser.contexts()[0] ?? (await browser.newContext());
|
|
87
|
+
const page = context.pages()[0] ?? (await context.newPage());
|
|
88
|
+
const capture = startCapture(page, onLog, tabs);
|
|
89
|
+
return { config, context, page, browser, mode: 'attach', capture, tabs };
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** Wire console/network capture onto the live page before the first navigation. */
|
|
93
|
+
function startCapture(page, onLog, tabs) {
|
|
94
|
+
const capture = new CdpCapture({ page, sink: onLog, tabs });
|
|
95
|
+
capture.start();
|
|
96
|
+
return capture;
|
|
97
|
+
}
|
|
98
|
+
//# 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,cAAc,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAgC9C;;;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;IACjF,MAAM,IAAI,GAAG,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACxD,IAAI,CAAC;QACH,OAAO,MAAM;YACX,CAAC,CAAC,MAAM,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC;YACpE,CAAC,CAAC,MAAM,aAAa,CAAC,I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;AACjB,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', '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
|
|
@@ -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,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,YAAY,CAAC,YAAY,GAAG,sBAAsB,CAAC,CAAC;IAC9F,OAAO,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AU,IAAI,IAAI,CAAC,CAAC;gBAC5E,MAAM;YACR,CAAC;YACD,KAAK,eAAe,EAAE,CAAC;gBACrB,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;gBACtD,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CACrB,GAAG,CAAC,CAAC,WAAW,IAAI,EAAE,KAAK,CAAC,CAAC,YAAY,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CACjF,CAAC;gBACF,MAAM;YACR,CAAC;YACD;gBACE,MAAM,IAAI,YAAY,CACpB,4BAA4B,GAAG,gBAAgB,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACjF,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.
|
|
@@ -32,28 +43,8 @@ export declare function redactHeaders(headers: Record<string, string>): Record<s
|
|
|
32
43
|
* driver needs to recognize.
|
|
33
44
|
*/
|
|
34
45
|
export declare function redactUrl(url: string): string;
|
|
35
|
-
/**
|
|
36
|
-
* Values a CONFIGURED auth persona types into the app (`targets.<t>.auth.<p>.fields`).
|
|
37
|
-
*
|
|
38
|
-
* The two redactors above key off a NAME they recognize (`authorization`,
|
|
39
|
-
* `?password=`). A persona's values have no such tell: they land in a form POST
|
|
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`.
|
|
49
|
-
*
|
|
50
|
-
* Longest first, so a value that contains another still redacts whole.
|
|
51
|
-
*/
|
|
52
|
-
export declare function createSecretRedactor(secrets: readonly string[]): (line: string) => string;
|
|
53
46
|
/** Map a CDP console `type()` onto the normalized {@link ConsoleEntry} level. */
|
|
54
47
|
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
48
|
/**
|
|
58
49
|
* Render a {@link NetworkEntry} as one greppable `logs/network.log` line.
|
|
59
50
|
*
|
|
@@ -2,11 +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
|
*/
|
|
20
|
+
import { stamp, tabMarker } from '../log-format.js';
|
|
21
|
+
export { formatConsoleLine } from '../log-format.js';
|
|
10
22
|
/**
|
|
11
23
|
* Per-body character cap. Big enough for an error payload or a small collection,
|
|
12
24
|
* small enough that the driver re-reading tool results every step cannot drown.
|
|
@@ -70,48 +82,6 @@ export function redactUrl(url) {
|
|
|
70
82
|
.join('&');
|
|
71
83
|
return `${url.slice(0, start + 1)}${query}${url.slice(end)}`;
|
|
72
84
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Values a CONFIGURED auth persona types into the app (`targets.<t>.auth.<p>.fields`).
|
|
75
|
-
*
|
|
76
|
-
* The two redactors above key off a NAME they recognize (`authorization`,
|
|
77
|
-
* `?password=`). A persona's values have no such tell: they land in a form POST
|
|
78
|
-
* body, in a `type` tool input on the agent trail, in whatever an adapter error
|
|
79
|
-
* echoes back. So this one keys off the VALUE — the only thing all three share —
|
|
80
|
-
* and is bound per run to the persona the caller named.
|
|
81
|
-
*
|
|
82
|
-
* Same posture as the other two: presence stays diagnostic (`<redacted, N chars>`
|
|
83
|
-
* still tells you a password of the right length was typed), the secret itself
|
|
84
|
-
* never reaches the durable trail. Form-encoded and JSON-escaped spellings are
|
|
85
|
-
* redacted too — a password with an `@` rides a form POST as `%40`, and matching
|
|
86
|
-
* only the plain text would leave the real body in `logs/network.log`.
|
|
87
|
-
*
|
|
88
|
-
* Longest first, so a value that contains another still redacts whole.
|
|
89
|
-
*/
|
|
90
|
-
export function createSecretRedactor(secrets) {
|
|
91
|
-
const spellings = new Set();
|
|
92
|
-
for (const secret of secrets) {
|
|
93
|
-
if (secret.length === 0)
|
|
94
|
-
continue;
|
|
95
|
-
spellings.add(secret);
|
|
96
|
-
const encoded = encodeURIComponent(secret);
|
|
97
|
-
spellings.add(encoded);
|
|
98
|
-
spellings.add(encoded.replaceAll('%20', '+')); // form encoding spells a space `+`
|
|
99
|
-
spellings.add(JSON.stringify(secret).slice(1, -1)); // JSON body escaping
|
|
100
|
-
}
|
|
101
|
-
const values = [...spellings].sort((a, b) => b.length - a.length);
|
|
102
|
-
if (values.length === 0)
|
|
103
|
-
return (line) => line;
|
|
104
|
-
return (line) => {
|
|
105
|
-
let out = line;
|
|
106
|
-
for (const value of values) {
|
|
107
|
-
// `split`/`join`, not a regex: a credential is arbitrary text and escaping it
|
|
108
|
-
// for a pattern is one missed metacharacter away from not redacting at all.
|
|
109
|
-
if (out.includes(value))
|
|
110
|
-
out = out.split(value).join(`<redacted, ${value.length} chars>`);
|
|
111
|
-
}
|
|
112
|
-
return out;
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
85
|
// --- Normalizers ------------------------------------------------------------
|
|
116
86
|
/** Map a CDP console `type()` onto the normalized {@link ConsoleEntry} level. */
|
|
117
87
|
export function normalizeConsoleLevel(type) {
|
|
@@ -133,15 +103,6 @@ export function normalizeConsoleLevel(type) {
|
|
|
133
103
|
}
|
|
134
104
|
}
|
|
135
105
|
// --- Line formatting (durable log trail) ------------------------------------
|
|
136
|
-
/** ISO-8601 stamp from epoch ms; deterministic given the injected clock. */
|
|
137
|
-
function stamp(ts) {
|
|
138
|
-
return new Date(ts).toISOString();
|
|
139
|
-
}
|
|
140
|
-
/** Render a {@link ConsoleEntry} as one greppable `logs/console.log` line. */
|
|
141
|
-
export function formatConsoleLine(entry) {
|
|
142
|
-
const where = entry.location ? ` @ ${entry.location}` : '';
|
|
143
|
-
return `${stamp(entry.timestamp)} ${entry.level.toUpperCase()} ${entry.text}${where}`;
|
|
144
|
-
}
|
|
145
106
|
/** One log line's worth of a captured body — single-line, hard-capped, never secret-bearing. */
|
|
146
107
|
function bodySnippet(label, body) {
|
|
147
108
|
if (body === undefined || body.length === 0)
|
|
@@ -156,7 +117,7 @@ function bodySnippet(label, body) {
|
|
|
156
117
|
* the exact dead end this log exists to prevent.
|
|
157
118
|
*/
|
|
158
119
|
export function formatNetworkLine(entry) {
|
|
159
|
-
const head = `${stamp(entry.timestamp)} ${entry.method} ${entry.url}`;
|
|
120
|
+
const head = `${stamp(entry.timestamp)}${tabMarker(entry.tab)} ${entry.method} ${entry.url}`;
|
|
160
121
|
const sent = bodySnippet('req', entry.requestBody);
|
|
161
122
|
if (entry.error !== undefined)
|
|
162
123
|
return `${head} → FAILED ${entry.error}${sent}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-format.js","sourceRoot":"","sources":["../../../src/adapters/browser/log-format.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"log-format.js","source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G,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tab identity for one browser run — the registry that NAMES a tab.
|
|
3
|
+
*
|
|
4
|
+
* A browser tab is named by a stable label (`tab-1`, `tab-2`, …) that follows
|
|
5
|
+
* the PAGE, never its position in the tab list. Positions do not survive the
|
|
6
|
+
* run: `switch_tab` takes an index, closing an earlier tab shifts every later
|
|
7
|
+
* index down, and a row captured before the shift would land under the wrong
|
|
8
|
+
* tab. So a label is handed out on FIRST SIGHT of a page and is never
|
|
9
|
+
* renumbered and never reused — a closed tab's label is never handed to some
|
|
10
|
+
* other page later in the same run.
|
|
11
|
+
*
|
|
12
|
+
* ONE registry per run: the CDP capture stamps a row with the label of the
|
|
13
|
+
* page the event fired on, and the adapter's `tabs()` listing reports the same
|
|
14
|
+
* label — so a `[tab-2]` marker in `logs/console.log` resolves to the tab the
|
|
15
|
+
* driver drove, and a row captured before a switch still names its own tab.
|
|
16
|
+
*
|
|
17
|
+
* The label is an opaque marker: it carries no URL, no title and no secret —
|
|
18
|
+
* only the shape `tab-N`.
|
|
19
|
+
*/
|
|
20
|
+
import type { Page } from 'playwright-core';
|
|
21
|
+
export declare class TabContext {
|
|
22
|
+
#private;
|
|
23
|
+
/**
|
|
24
|
+
* The label of `page`, assigning one the first time the page is seen.
|
|
25
|
+
*
|
|
26
|
+
* Idempotent: the same page always gets the same label for the whole run,
|
|
27
|
+
* and a page seen for the first time joins the sequence at the end.
|
|
28
|
+
*/
|
|
29
|
+
label(page: Page): string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tab identity for one browser run — the registry that NAMES a tab.
|
|
3
|
+
*
|
|
4
|
+
* A browser tab is named by a stable label (`tab-1`, `tab-2`, …) that follows
|
|
5
|
+
* the PAGE, never its position in the tab list. Positions do not survive the
|
|
6
|
+
* run: `switch_tab` takes an index, closing an earlier tab shifts every later
|
|
7
|
+
* index down, and a row captured before the shift would land under the wrong
|
|
8
|
+
* tab. So a label is handed out on FIRST SIGHT of a page and is never
|
|
9
|
+
* renumbered and never reused — a closed tab's label is never handed to some
|
|
10
|
+
* other page later in the same run.
|
|
11
|
+
*
|
|
12
|
+
* ONE registry per run: the CDP capture stamps a row with the label of the
|
|
13
|
+
* page the event fired on, and the adapter's `tabs()` listing reports the same
|
|
14
|
+
* label — so a `[tab-2]` marker in `logs/console.log` resolves to the tab the
|
|
15
|
+
* driver drove, and a row captured before a switch still names its own tab.
|
|
16
|
+
*
|
|
17
|
+
* The label is an opaque marker: it carries no URL, no title and no secret —
|
|
18
|
+
* only the shape `tab-N`.
|
|
19
|
+
*/
|
|
20
|
+
export class TabContext {
|
|
21
|
+
/** Page → its label. Weak: a closed tab's entry evaporates with the page. */
|
|
22
|
+
#labels = new WeakMap();
|
|
23
|
+
/** Next label number — monotonic and never reused, so a marker never changes meaning. */
|
|
24
|
+
#next = 1;
|
|
25
|
+
/**
|
|
26
|
+
* The label of `page`, assigning one the first time the page is seen.
|
|
27
|
+
*
|
|
28
|
+
* Idempotent: the same page always gets the same label for the whole run,
|
|
29
|
+
* and a page seen for the first time joins the sequence at the end.
|
|
30
|
+
*/
|
|
31
|
+
label(page) {
|
|
32
|
+
const known = this.#labels.get(page);
|
|
33
|
+
if (known !== undefined)
|
|
34
|
+
return known;
|
|
35
|
+
const label = `tab-${this.#next}`;
|
|
36
|
+
this.#next += 1;
|
|
37
|
+
this.#labels.set(page, label);
|
|
38
|
+
return label;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=tab-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab-context.js","sourceRoot":"","sources":["../../../src/adapters/browser/tab-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,MAAM,OAAO,UAAU;IACrB,6EAA6E;IACpE,OAAO,GAAG,IAAI,OAAO,EAAgB,CAAC;IAC/C,yFAAyF;IACzF,KAAK,GAAG,CAAC,CAAC;IAEV;;;;;OAKG;IACH,KAAK,CAAC,IAAU;QACd,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QACtC,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;QAClC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QAChB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -5,8 +5,13 @@
|
|
|
5
5
|
* same small interface, so the debug agent's loop is **adapter-blind**: the
|
|
6
6
|
* inner tool belt (`observe`/`act`/`look`) hits these methods and never learns
|
|
7
7
|
* which protocol is underneath. Web reads the DOM, desktop the a11y tree, mobile
|
|
8
|
-
* the view hierarchy —
|
|
9
|
-
*
|
|
8
|
+
* the view hierarchy — all three normalize to the {@link Node} shape below, and
|
|
9
|
+
* each adapter exposes exactly ONE structured tree (DOM / AT-SPI / uiautomator).
|
|
10
|
+
* There is no automatic vision/OCR fallback in this contract, and the adapter
|
|
11
|
+
* never switches to pixels: a read yields tree nodes or nothing. `screenshot`
|
|
12
|
+
* only captures a frame — for evidence, and for the agent-level `look` belt
|
|
13
|
+
* call, the one path by which pixels reach a model. `look` describes and judges
|
|
14
|
+
* a frame; it never yields elements an adapter could find, click or type into.
|
|
10
15
|
*
|
|
11
16
|
* Reads are **SQL-like**, not RPC: a handful of verbs with composable params
|
|
12
17
|
* (`query`/`fields`/`filters`/`limit`/`within`) — see {@link Query}. The belt's
|
|
@@ -152,6 +157,15 @@ export interface ConsoleEntry {
|
|
|
152
157
|
location?: string;
|
|
153
158
|
/** Capture time, ms since epoch. */
|
|
154
159
|
timestamp: number;
|
|
160
|
+
/**
|
|
161
|
+
* Stable label of the tab that produced the row (`tab-1`, `tab-2`, …).
|
|
162
|
+
*
|
|
163
|
+
* The label follows the PAGE for the whole run: it survives a tab switch and
|
|
164
|
+
* a closing tab shifting the positional indices, so the index a driver passes
|
|
165
|
+
* to `switch_tab` never has to name a tab. Absent on targets that have no
|
|
166
|
+
* tabs (desktop, mobile).
|
|
167
|
+
*/
|
|
168
|
+
tab?: string;
|
|
155
169
|
}
|
|
156
170
|
/** One network exchange captured from the target (CDP responses + failures). */
|
|
157
171
|
export interface NetworkEntry {
|
|
@@ -196,23 +210,88 @@ export interface NetworkEntry {
|
|
|
196
210
|
* (and from there, logs, findings, and the caller's transcript).
|
|
197
211
|
*/
|
|
198
212
|
responseHeaders?: Record<string, string>;
|
|
213
|
+
/**
|
|
214
|
+
* Stable label of the tab that produced the exchange (`tab-1`, `tab-2`, …).
|
|
215
|
+
*
|
|
216
|
+
* Stamped when the response FIRED, not when its log line is written: the line
|
|
217
|
+
* lands only after the body/header await resolves, and by then the driver may
|
|
218
|
+
* have switched tabs. Same rationale as {@link ConsoleEntry.tab}.
|
|
219
|
+
*/
|
|
220
|
+
tab?: string;
|
|
199
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Where captured console/network lines are streamed — the seam between an
|
|
224
|
+
* adapter's capture and the run's durable log trail.
|
|
225
|
+
*
|
|
226
|
+
* Declared HERE, in the contract, because two adapters stream to it (the browser's
|
|
227
|
+
* CDP capture and the android logcat drain): a second declaration would be a second
|
|
228
|
+
* type identity for the same seam. `browser/cdp.ts` re-exports it, so every reader
|
|
229
|
+
* of the capture channel keeps its import path.
|
|
230
|
+
*/
|
|
231
|
+
export type CaptureSink = (channel: 'console' | 'network', line: string) => void;
|
|
200
232
|
/** One open tab/window of a multi-tab target (web). */
|
|
201
233
|
export interface TabInfo {
|
|
202
234
|
/** Position in the target's tab list — what {@link Adapter.selectTab} takes. */
|
|
203
235
|
index: number;
|
|
204
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* Current URL of the tab. Credential-bearing query values (`?code=`,
|
|
238
|
+
* `?token=`, `?signature=`, …) are redacted to `<redacted, N chars>` before
|
|
239
|
+
* the URL is returned — the same posture as {@link NetworkEntry.url} and
|
|
240
|
+
* unrequested loads — so tab listings are safe to surface. Any future
|
|
241
|
+
* `tabs()` implementation must keep this guarantee.
|
|
242
|
+
*/
|
|
205
243
|
url: string;
|
|
206
244
|
/** Document title, empty while a fresh tab is still loading. */
|
|
207
245
|
title: string;
|
|
208
|
-
/**
|
|
246
|
+
/**
|
|
247
|
+
* Stable label of this tab (`tab-1`, `tab-2`, …) — the same marker the
|
|
248
|
+
* console/network rows carry, so a `[tab-2]` line in the durable log resolves
|
|
249
|
+
* to the tab that produced it. The label follows the PAGE, so it stays valid
|
|
250
|
+
* after an earlier tab closes and the indices shift. Absent when the target
|
|
251
|
+
* has no tab registry.
|
|
252
|
+
*/
|
|
253
|
+
id?: string;
|
|
254
|
+
/** Whether this is the tab the adapter currently drives, independent of visibility. */
|
|
209
255
|
active: boolean;
|
|
256
|
+
/** Live document.visibilityState === 'visible', when measured; not OS-window focus. */
|
|
257
|
+
visible?: boolean;
|
|
210
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Which selector grammar a target's `find({query})` parses — and therefore which
|
|
261
|
+
* grammar the belt must EMIT, since the driver copies a node's `target` verbatim
|
|
262
|
+
* into `act`.
|
|
263
|
+
*
|
|
264
|
+
* - `web` — Playwright engines (`data-testid="…"`, `role=button[name="…" i]`,
|
|
265
|
+
* `text=…`, `>> nth=N`), normalized by `adapters/browser/query.ts`.
|
|
266
|
+
* - `native` — the desktop (AT-SPI) and android (uiautomator) parsers, which take
|
|
267
|
+
* exactly two shapes and NOTHING else: `role "name"`, or a bare substring. The
|
|
268
|
+
* substring matches the node's name on desktop, and the node's name OR its
|
|
269
|
+
* `resource-id` on android — so a bare `resource-id` (android's `testid`)
|
|
270
|
+
* resolves there too. An engine-prefixed web selector degrades to a literal
|
|
271
|
+
* substring, matches nothing, and `act` throws `no element matched …`.
|
|
272
|
+
*
|
|
273
|
+
* DECLARED per adapter ({@link Adapter.selectorDialect}) — never inferred from
|
|
274
|
+
* the optional `tabs` capability, which says nothing about the grammar a target
|
|
275
|
+
* parses.
|
|
276
|
+
*/
|
|
277
|
+
export type SelectorDialect = 'web' | 'native';
|
|
211
278
|
/**
|
|
212
279
|
* One contract, three protocols. The agent loop calls only these methods; each
|
|
213
280
|
* adapter wires them to its real backend (CDP / X11-Wayland / ADB).
|
|
214
281
|
*/
|
|
215
282
|
export interface Adapter {
|
|
283
|
+
/**
|
|
284
|
+
* The selector grammar this adapter's `find`/`click`/`type` parse — DECLARED,
|
|
285
|
+
* never inferred.
|
|
286
|
+
*
|
|
287
|
+
* The belt emits every tree node's `target` in this dialect and the driver
|
|
288
|
+
* copies it verbatim, so a target in the wrong dialect makes every click and
|
|
289
|
+
* type fail. It used to be inferred from {@link Adapter.tabs}, which is a
|
|
290
|
+
* CAPABILITY, not a dialect marker: a target that grows a tab listing must not
|
|
291
|
+
* silently switch the grammar the belt hands the driver. A missing or unknown
|
|
292
|
+
* declaration now fails loud rather than falling back to `web`.
|
|
293
|
+
*/
|
|
294
|
+
readonly selectorDialect: SelectorDialect;
|
|
216
295
|
/**
|
|
217
296
|
* Go to the app: navigate to a URL (web) · launch/focus the window (desktop) · start the activity (android).
|
|
218
297
|
*
|
|
@@ -258,6 +337,9 @@ export interface Adapter {
|
|
|
258
337
|
* List the target's open tabs, newest last. OPTIONAL — implemented by targets
|
|
259
338
|
* that have a tab concept (web); absent elsewhere, and the belt says so rather
|
|
260
339
|
* than pretending a single-window target has one tab.
|
|
340
|
+
*
|
|
341
|
+
* A CAPABILITY, not a dialect marker: it says nothing about
|
|
342
|
+
* {@link Adapter.selectorDialect}, which every adapter declares on its own.
|
|
261
343
|
*/
|
|
262
344
|
tabs?(): Promise<TabInfo[]>;
|
|
263
345
|
/**
|
|
@@ -286,6 +368,10 @@ export interface Adapter {
|
|
|
286
368
|
* durable findings, the same posture the network capture holds for its URLs.
|
|
287
369
|
*/
|
|
288
370
|
takeUnrequestedLoads?(): Promise<string[]>;
|
|
289
|
-
/**
|
|
371
|
+
/**
|
|
372
|
+
* Release the target: stop a **managed** process; for **attach**, disconnect
|
|
373
|
+
* only — never stop it. The web adapter first returns an adopted tab to its
|
|
374
|
+
* pre-run URL (best-effort).
|
|
375
|
+
*/
|
|
290
376
|
close(): Promise<void>;
|
|
291
377
|
}
|
|
@@ -5,8 +5,13 @@
|
|
|
5
5
|
* same small interface, so the debug agent's loop is **adapter-blind**: the
|
|
6
6
|
* inner tool belt (`observe`/`act`/`look`) hits these methods and never learns
|
|
7
7
|
* which protocol is underneath. Web reads the DOM, desktop the a11y tree, mobile
|
|
8
|
-
* the view hierarchy —
|
|
9
|
-
*
|
|
8
|
+
* the view hierarchy — all three normalize to the {@link Node} shape below, and
|
|
9
|
+
* each adapter exposes exactly ONE structured tree (DOM / AT-SPI / uiautomator).
|
|
10
|
+
* There is no automatic vision/OCR fallback in this contract, and the adapter
|
|
11
|
+
* never switches to pixels: a read yields tree nodes or nothing. `screenshot`
|
|
12
|
+
* only captures a frame — for evidence, and for the agent-level `look` belt
|
|
13
|
+
* call, the one path by which pixels reach a model. `look` describes and judges
|
|
14
|
+
* a frame; it never yields elements an adapter could find, click or type into.
|
|
10
15
|
*
|
|
11
16
|
* Reads are **SQL-like**, not RPC: a handful of verbs with composable params
|
|
12
17
|
* (`query`/`fields`/`filters`/`limit`/`within`) — see {@link Query}. The belt's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/adapters/contract.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/adapters/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG"}
|