@ait-co/devtools 0.1.121 → 0.1.123
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/dist/{attach-orchestrator-DEJfLm7V.js → attach-orchestrator-CPMQWkGV.js} +3 -3
- package/dist/{attach-orchestrator-DEJfLm7V.js.map → attach-orchestrator-CPMQWkGV.js.map} +1 -1
- package/dist/{attach-orchestrator-qFEMBUwb.js → attach-orchestrator-CpE0dMew.js} +2 -2
- package/dist/{attach-orchestrator-qFEMBUwb.js.map → attach-orchestrator-CpE0dMew.js.map} +1 -1
- package/dist/{attach-orchestrator-CFotueL3.js → attach-orchestrator-RhOdO3DS.js} +2 -2
- package/dist/{attach-orchestrator-CFotueL3.js.map → attach-orchestrator-RhOdO3DS.js.map} +1 -1
- package/dist/{bundle-CA1TCXED.d.ts → bundle-Cb3GFuw6.d.ts} +1 -1
- package/dist/{bundle-CA1TCXED.d.ts.map → bundle-Cb3GFuw6.d.ts.map} +1 -1
- package/dist/{capture-BmK_cBqQ.d.ts → capture-B1zfGyTo.d.ts} +1 -1
- package/dist/{capture-BmK_cBqQ.d.ts.map → capture-B1zfGyTo.d.ts.map} +1 -1
- package/dist/{cdp-connection-DB2zgthr.d.ts → cdp-connection-Dxw_EY8s.d.ts} +1 -1
- package/dist/{cdp-connection-DB2zgthr.d.ts.map → cdp-connection-Dxw_EY8s.d.ts.map} +1 -1
- package/dist/{cell-Cv3e_qwn.js → cell-Ba9lCI3B.js} +3 -3
- package/dist/{cell-BPWZUm_X.js.map → cell-Ba9lCI3B.js.map} +1 -1
- package/dist/{cell-BPWZUm_X.js → cell-CX92lDI0.js} +3 -3
- package/dist/{cell-Cv3e_qwn.js.map → cell-CX92lDI0.js.map} +1 -1
- package/dist/{cell-nrWFeqvG.js → cell-D0dJSGHi.js} +3 -3
- package/dist/{cell-Cj-u6JTG.js.map → cell-D0dJSGHi.js.map} +1 -1
- package/dist/{debug-server-BhHVy3XT.js → debug-server-Bup2AJ5H.js} +7 -226
- package/dist/debug-server-Bup2AJ5H.js.map +1 -0
- package/dist/{debug-server-Buc8yoa7.js → debug-server-C0A_Kujq.js} +8 -945
- package/dist/debug-server-C0A_Kujq.js.map +1 -0
- package/dist/{debug-server-C_5ag9jj.js → debug-server-DywH5GU-.js} +5 -4
- package/dist/{debug-server-C_5ag9jj.js.map → debug-server-DywH5GU-.js.map} +1 -1
- package/dist/mcp/cli.js +8204 -4
- package/dist/mcp/cli.js.map +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/panel/index.js +1 -1
- package/dist/{pool-D5QH6Ydv.d.ts → pool-B9wSRPOU.d.ts} +3 -3
- package/dist/{pool-D5QH6Ydv.d.ts.map → pool-B9wSRPOU.d.ts.map} +1 -1
- package/dist/qr-http-server-CKbtqvKy.js +1505 -0
- package/dist/qr-http-server-CKbtqvKy.js.map +1 -0
- package/dist/qr-http-server-DDmFS7fX.js +1506 -0
- package/dist/qr-http-server-DDmFS7fX.js.map +1 -0
- package/dist/{relay-factory-DVI7TrX4.js → relay-factory-DnHMDxMA.js} +25 -5
- package/dist/relay-factory-DnHMDxMA.js.map +1 -0
- package/dist/{relay-secret-store-DNPJKHNs.js → relay-secret-store-DKxs7zwq.js} +1 -1
- package/dist/{relay-secret-store-DNPJKHNs.js.map → relay-secret-store-DKxs7zwq.js.map} +1 -1
- package/dist/{relay-secret-store-CmDDfZMh.js → relay-secret-store-DhzAnnj-.js} +3 -3
- package/dist/{relay-secret-store-CmDDfZMh.js.map → relay-secret-store-DhzAnnj-.js.map} +1 -1
- package/dist/{relay-url-store-CnL2zwbH.js → relay-url-store-CwKT7i04.js} +2 -2
- package/dist/{relay-url-store-CnL2zwbH.js.map → relay-url-store-CwKT7i04.js.map} +1 -1
- package/dist/{relay-url-store-Dv5HSzwb.js → relay-url-store-xmUuTjXA.js} +2 -2
- package/dist/{relay-url-store-Dv5HSzwb.js.map → relay-url-store-xmUuTjXA.js.map} +1 -1
- package/dist/{relay-worker-BBu1oEqC.d.ts → relay-worker-7biDlEjo.d.ts} +5 -5
- package/dist/{relay-worker-BBu1oEqC.d.ts.map → relay-worker-7biDlEjo.d.ts.map} +1 -1
- package/dist/{runtime-Bm_sT1C9.d.ts → runtime-ozyPnRbU.d.ts} +1 -1
- package/dist/{runtime-Bm_sT1C9.d.ts.map → runtime-ozyPnRbU.d.ts.map} +1 -1
- package/dist/test-runner/bin.d.ts +2 -0
- package/dist/{cli-RhzASQef.js → test-runner/bin.js} +50 -7
- package/dist/test-runner/bin.js.map +1 -0
- package/dist/test-runner/bundle.d.ts +1 -1
- package/dist/test-runner/capture.d.ts +1 -1
- package/dist/test-runner/config.d.ts +1 -1
- package/dist/test-runner/config.d.ts.map +1 -1
- package/dist/test-runner/config.js +1 -1
- package/dist/test-runner/pool.d.ts +1 -1
- package/dist/test-runner/relay-factory.d.ts.map +1 -1
- package/dist/test-runner/relay-factory.js +24 -4
- package/dist/test-runner/relay-factory.js.map +1 -1
- package/dist/test-runner/relay-worker.d.ts +1 -1
- package/dist/test-runner/report.d.ts +3 -3
- package/dist/test-runner/rpc.d.ts +2 -2
- package/dist/test-runner/runtime.d.ts +1 -1
- package/dist/test-runner/task-graph.d.ts +1 -1
- package/dist/totp-D1pulXLa.js +3 -0
- package/dist/{totp-0bvlo9Yb.js → totp-WY6l0ysP.js} +1 -1
- package/dist/{totp-0bvlo9Yb.js.map → totp-WY6l0ysP.js.map} +1 -1
- package/package.json +2 -2
- package/dist/attach-orchestrator-BTsEHXfq.js +0 -3
- package/dist/attach-orchestrator-DPMBN06p.js +0 -2797
- package/dist/attach-orchestrator-DPMBN06p.js.map +0 -1
- package/dist/cell-Bca_k5ne.js +0 -3
- package/dist/cell-Cj-u6JTG.js +0 -85
- package/dist/cell-nrWFeqvG.js.map +0 -1
- package/dist/cli-RhzASQef.js.map +0 -1
- package/dist/debug-server-BhHVy3XT.js.map +0 -1
- package/dist/debug-server-Buc8yoa7.js.map +0 -1
- package/dist/debug-server-m9lIC9YW.js +0 -5758
- package/dist/debug-server-m9lIC9YW.js.map +0 -1
- package/dist/relay-factory-DVI7TrX4.js.map +0 -1
- package/dist/relay-secret-store-BlFEhqwb.js +0 -3
- package/dist/test-runner/cli.d.ts +0 -547
- package/dist/test-runner/cli.d.ts.map +0 -1
- package/dist/test-runner/cli.js +0 -3
- package/dist/totp-zGIlDsZS.js +0 -3
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relay-factory-DVI7TrX4.js","names":[],"sources":["../src/test-runner/relay-factory.ts"],"sourcesContent":["/**\n * Relay connection factory for the Vitest custom pool (devtools#696).\n *\n * The Vitest pool (`pool.ts`) takes a {@link RelayConnectionFactory} that knows\n * how to `open()` a live CDP relay connection (boot relay → QR → phone scan →\n * cell inject → enableDomains) and `close()` it. Before this module that exact\n * assembly lived only inside the `devtools-test` CLI's `main()`; the standalone\n * CLI and the Vitest pool would otherwise each hand-roll it and drift.\n *\n * This is the single source of that assembly. `cli.ts` is refactored to call\n * `createRelayConnectionFactory(...).open()`, and `definePhoneVitestConfig`\n * (config.ts) exposes it so a downstream `vitest.config.ts` can wire the pool:\n *\n * import { createRelayConnectionFactory } from '@ait-co/devtools/test-runner';\n * const connection = createRelayConnectionFactory({\n * schemeUrl,\n * cell,\n * // REQUIRED — own the stdout decision (the chunks carry the relay wss +\n * // TOTP code). Suppress on non-interactive stdout; print otherwise.\n * onQrContent: (chunks) => {\n * if (!process.stdout.isTTY) return;\n * for (const c of chunks) process.stdout.write(`${c}\\n`);\n * },\n * });\n * export default defineConfig({ test: definePhoneVitestConfig({ connection }) });\n *\n * The heavy boot graph (chii relay, cloudflared, ws, debug-server) is pulled via\n * DYNAMIC import inside `open()` — so merely importing this module (or the\n * `@ait-co/devtools/test-runner` barrel) does NOT statically drag that graph in.\n *\n * SECRET-HANDLING: relay wss URLs, scheme URLs, and the TOTP secret/code are\n * never logged. `open()` reads the project-local `.ait_relay` secret read-only\n * (never mints) and the minted TOTP code rides only inside the QR `at=` param.\n *\n * Node-only. react-free (CdpConnection + lazily-imported MCP boot helpers only).\n */\n\nimport type { AttachDeps } from '../mcp/attach-orchestrator.js';\nimport type { CdpConnection } from '../mcp/cdp-connection.js';\nimport type { RelayConnectionFactory } from './pool.js';\n\n// NOTE: every value import below is a DYNAMIC import inside `open()`. This module\n// keeps ONLY type-level static imports so that re-exporting it from the\n// `@ait-co/devtools/test-runner` barrel (config.ts) does NOT statically drag the\n// heavy MCP graph (cell.ts → attach-orchestrator.ts → tools.ts → server-lock,\n// plus chii/cloudflared via debug-server) onto that Node-config entry.\n\n/** Options for {@link createRelayConnectionFactory}. */\nexport interface RelayConnectionFactoryOptions {\n /**\n * intoss-private:// scheme URL from `ait deploy --scheme-only` (env3). The\n * phone cold-loads the candidate bundle this URL points at. SECRET-HANDLING:\n * never logged.\n */\n schemeUrl: string;\n /**\n * Project root for the `.ait_relay` secret lookup (read-only). Defaults to\n * `process.cwd()`.\n */\n projectRoot?: string;\n /**\n * Attach wait timeout in ms — how long `open()` waits for the phone to scan\n * the QR and attach. Defaults to 600 000 (10 min) to give time for a manual\n * scan. (The per-file evaluate timeout is separate, passed via the pool's\n * `run` options.)\n */\n timeoutMs?: number;\n /** Disable browser auto-open of the QR dashboard (text QR only). */\n headless?: boolean;\n /**\n * Cell axes injected as `__AIT_CELL__` before the first test bundle runs, so\n * sdk-example's capture picks up the correct sdkLine/platform. Optional — when\n * omitted no cell is injected. The values are not secrets.\n */\n cell?: { sdkLine: string; platform: string };\n /**\n * Receives the QR/attach render content (text chunks) from\n * `renderAndMaybeWait`, so the caller decides whether to print them — e.g.\n * suppress on non-interactive stdout.\n *\n * REQUIRED (not optional) on purpose: these chunks contain the QR payload\n * (which encodes the relay wss + TOTP `at=` code) and the attach JSON block.\n * Making the hook mandatory means the factory never falls back to printing\n * them itself — a downstream `vitest.config.ts` consumer that wires this via\n * the `@ait-co/devtools/test-runner` barrel is forced to make an explicit\n * stdout decision rather than silently leaking the secret-bearing block.\n *\n * SECRET-HANDLING: when a non-interactive caller is detected the hook MUST\n * suppress the WHOLE chunk (not just `attachUrl`), since `relayUrl` rides in\n * the same block.\n */\n onQrContent: (textChunks: string[]) => void;\n}\n\n/**\n * Builds a {@link RelayConnectionFactory} that opens a standalone env3 relay\n * connection.\n *\n * `open()` performs the full attach lifecycle and BLOCKS for tens of seconds (up\n * to `timeoutMs`) while a human scans the rendered QR with their phone — there\n * is no way around the manual scan for env3. It resolves with the live\n * `CdpConnection` once a matching page attaches; `close()` tears the relay\n * family down.\n *\n * The factory holds the booted relay family in a closure so `close()` can stop\n * it. A second `open()` on the same factory boots a fresh family (the previous\n * one should have been `close()`d first).\n */\nexport function createRelayConnectionFactory(\n opts: RelayConnectionFactoryOptions,\n): RelayConnectionFactory {\n const projectRoot = opts.projectRoot ?? process.cwd();\n const timeoutMs = opts.timeoutMs ?? 600_000;\n const headless = opts.headless === true;\n\n // Captured so close() can stop the family that open() booted.\n let family: { connection: CdpConnection; stop(): void } | undefined;\n\n return {\n async open(): Promise<CdpConnection> {\n // Dynamic imports: keep the chii/cloudflared/debug-server graph OFF the\n // static import graph of this module (and the test-runner config barrel).\n const { prepareAttach, renderAndMaybeWait } = await import('../mcp/attach-orchestrator.js');\n const { injectDebugIndicator, injectGlobals } = await import('./cell.js');\n const { loadRelaySecretReadOnly } = await import('../mcp/relay-secret-store.js');\n const { bootRelayFamily, buildRelayVerifyAuth } = await import('../mcp/debug-server.js');\n\n // Load the project-local .ait_relay secret into AIT_DEBUG_TOTP_SECRET\n // BEFORE booting the relay so assertRelayAuthConfigured()/buildRelayVerifyAuth()\n // at the boot site see it. Read-only — never mints. SECRET-HANDLING: the\n // value is never logged here.\n await loadRelaySecretReadOnly({ projectRoot });\n\n const booted = await bootRelayFamily({ verifyAuth: buildRelayVerifyAuth() });\n family = booted;\n\n // Assemble AttachDeps with no dashboard/SSE (CLI/pool is not the daemon).\n const attachDeps: AttachDeps = {\n getTunnelStatus: booted.getTunnelStatus ?? (() => ({ up: false, wssUrl: null })),\n getTotpSecret: () => process.env.AIT_DEBUG_TOTP_SECRET,\n qrHttpServer: undefined,\n onAttachUrlBuilt: undefined,\n canOpenBrowser: () => !headless,\n };\n\n const prep = await prepareAttach(\n attachDeps,\n 'relay-dev',\n { scheme_url: opts.schemeUrl },\n booted.connection,\n );\n if (!prep.ok) {\n booted.stop();\n family = undefined;\n // SECRET-HANDLING: do NOT surface `prep.error.content` in the thrown\n // message. Some prep error paths build their text from attach\n // components, and the CLI catch writes `e.message` to stderr — embedding\n // that text risks leaking the scheme/relay wss URL. The detailed\n // diagnostic is the daemon/dashboard's job; the factory throws a\n // secret-free message only.\n throw new Error(\n 'createRelayConnectionFactory: attach preparation failed — check the scheme_url and that the relay tunnel is up',\n );\n }\n\n // Render the QR + wait for the phone to attach. SECRET-HANDLING: this\n // function never logs scheme/wss/TOTP values.\n const waitResult = await renderAndMaybeWait(\n attachDeps,\n prep,\n true,\n timeoutMs,\n booted.connection,\n );\n if (waitResult.isError) {\n booted.stop();\n family = undefined;\n // SECRET-HANDLING (BLOCKER fix): `waitResult.content` is the timeout\n // result built from `buildTimeoutError(baseText, ...)`, and `baseText`\n // is `JSON.stringify({ attachUrl, relayUrl, ... })` — `attachUrl` carries\n // the TOTP `at=` code and `relayUrl` is the relay `wss://` URL. The CLI\n // catch writes `e.message` to stderr, so extracting that text here would\n // leak the relay wss + TOTP code on every timeout. Throw a secret-free\n // message with only the timeout duration.\n const timeoutSec = Math.round(timeoutMs / 1000);\n throw new Error(\n `createRelayConnectionFactory: attach timed out after ${timeoutSec}s — phone did not scan the QR within the timeout`,\n );\n }\n\n // Surface the QR/attach render content to the caller, which owns the\n // stdout decision (suppress on non-interactive stdout). There is no\n // fallback that prints here itself: `onQrContent` is a required option so\n // the secret-bearing block (attachUrl TOTP + relayUrl wss) can never be\n // emitted without an explicit caller decision. SECRET-HANDLING.\n const qrChunks = waitResult.content\n .filter((c): c is { type: 'text'; text: string } => c.type === 'text')\n .map((c) => c.text);\n opts.onQrContent(qrChunks);\n\n // Debugger attached — show the on-phone \"Debugger Connected\" badge.\n await injectDebugIndicator(booted.connection);\n\n // Inject the cell globals before any test bundle runs (session-global).\n if (opts.cell !== undefined) {\n await injectGlobals(booted.connection, { __AIT_CELL__: opts.cell });\n }\n\n // Open the CDP client websocket + enable domains so the first run's\n // Runtime.evaluate and console stream are live. enableDomains is\n // idempotent; runTestFilesOverRelay also calls it defensively.\n await booted.connection.enableDomains();\n\n return booted.connection;\n },\n\n async close(_connection: CdpConnection): Promise<void> {\n // family.stop() is synchronous best-effort: closes the CDP connection and\n // shuts down the relay + cloudflared child.\n family?.stop();\n family = undefined;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4GA,SAAgB,6BACd,MACwB;CACxB,MAAM,cAAc,KAAK,eAAe,QAAQ,KAAK;CACrD,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,WAAW,KAAK,aAAa;CAGnC,IAAI;AAEJ,QAAO;EACL,MAAM,OAA+B;GAGnC,MAAM,EAAE,eAAe,uBAAuB,MAAM,OAAO;GAC3D,MAAM,EAAE,sBAAsB,kBAAkB,MAAM,OAAO;GAC7D,MAAM,EAAE,4BAA4B,MAAM,OAAO;GACjD,MAAM,EAAE,iBAAiB,yBAAyB,MAAM,OAAO;AAM/D,SAAM,wBAAwB,EAAE,aAAa,CAAC;GAE9C,MAAM,SAAS,MAAM,gBAAgB,EAAE,YAAY,sBAAsB,EAAE,CAAC;AAC5E,YAAS;GAGT,MAAM,aAAyB;IAC7B,iBAAiB,OAAO,2BAA2B;KAAE,IAAI;KAAO,QAAQ;KAAM;IAC9E,qBAAqB,QAAQ,IAAI;IACjC,cAAc,KAAA;IACd,kBAAkB,KAAA;IAClB,sBAAsB,CAAC;IACxB;GAED,MAAM,OAAO,MAAM,cACjB,YACA,aACA,EAAE,YAAY,KAAK,WAAW,EAC9B,OAAO,WACR;AACD,OAAI,CAAC,KAAK,IAAI;AACZ,WAAO,MAAM;AACb,aAAS,KAAA;AAOT,UAAM,IAAI,MACR,iHACD;;GAKH,MAAM,aAAa,MAAM,mBACvB,YACA,MACA,MACA,WACA,OAAO,WACR;AACD,OAAI,WAAW,SAAS;AACtB,WAAO,MAAM;AACb,aAAS,KAAA;IAQT,MAAM,aAAa,KAAK,MAAM,YAAY,IAAK;AAC/C,UAAM,IAAI,MACR,wDAAwD,WAAW,kDACpE;;GAQH,MAAM,WAAW,WAAW,QACzB,QAAQ,MAA2C,EAAE,SAAS,OAAO,CACrE,KAAK,MAAM,EAAE,KAAK;AACrB,QAAK,YAAY,SAAS;AAG1B,SAAM,qBAAqB,OAAO,WAAW;AAG7C,OAAI,KAAK,SAAS,KAAA,EAChB,OAAM,cAAc,OAAO,YAAY,EAAE,cAAc,KAAK,MAAM,CAAC;AAMrE,SAAM,OAAO,WAAW,eAAe;AAEvC,UAAO,OAAO;;EAGhB,MAAM,MAAM,aAA2C;AAGrD,WAAQ,MAAM;AACd,YAAS,KAAA;;EAEZ"}
|
|
@@ -1,547 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/mcp/cdp-connection.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Injectable CDP connection abstraction for the debug-mode MCP server.
|
|
5
|
-
*
|
|
6
|
-
* The Phase 1 tool layer (`list_console_messages`, `list_network_requests`,
|
|
7
|
-
* `list_pages`) reads from CDP events captured off a Chii relay connection.
|
|
8
|
-
* To keep that tool layer CI-verifiable without a phone roundtrip, the actual
|
|
9
|
-
* relay websocket sits behind this interface. Production wires
|
|
10
|
-
* `ChiiCdpConnection` (see `chii-connection.ts`); tests inject a fake that
|
|
11
|
-
* emits canned `Runtime.consoleAPICalled` / `Network.*` events.
|
|
12
|
-
*
|
|
13
|
-
* Phase 2 adds CDP *commands* (request→response): `DOM.getDocument`,
|
|
14
|
-
* `DOMSnapshot.captureSnapshot`, `Page.captureScreenshot`. Unlike Phase 1's
|
|
15
|
-
* event streams these need a `send(method, params)` round-trip, so the
|
|
16
|
-
* connection grows a typed `send`. The fake returns canned command results.
|
|
17
|
-
*
|
|
18
|
-
* Phase 2 extension: `Runtime.evaluate` (read-only probe) added for the
|
|
19
|
-
* `measure_safe_area` tool — executes a JS snippet on the attached page and
|
|
20
|
-
* returns the result as a `RemoteObject`. The fake returns canned results for
|
|
21
|
-
* unit tests without a phone roundtrip.
|
|
22
|
-
*
|
|
23
|
-
* Only the slice of the Chrome DevTools Protocol the tools need is typed here.
|
|
24
|
-
*/
|
|
25
|
-
/** A target (page) the Chii relay currently sees attached. */
|
|
26
|
-
interface CdpTarget {
|
|
27
|
-
/** Chii's internal target id (session UUID). */
|
|
28
|
-
id: string;
|
|
29
|
-
/** Page title reported by the in-app target. */
|
|
30
|
-
title: string;
|
|
31
|
-
/** Page URL reported by the in-app target. */
|
|
32
|
-
url: string;
|
|
33
|
-
}
|
|
34
|
-
/** `Runtime.RemoteObject` subset we surface for console args. */
|
|
35
|
-
interface CdpRemoteObject {
|
|
36
|
-
type: string;
|
|
37
|
-
subtype?: string;
|
|
38
|
-
value?: unknown;
|
|
39
|
-
description?: string;
|
|
40
|
-
className?: string;
|
|
41
|
-
}
|
|
42
|
-
/** Payload of a `Runtime.consoleAPICalled` event. */
|
|
43
|
-
interface ConsoleApiCalledEvent {
|
|
44
|
-
/** log | warning | error | info | debug | … */
|
|
45
|
-
type: string;
|
|
46
|
-
args: CdpRemoteObject[];
|
|
47
|
-
/** Milliseconds since epoch (CDP `Runtime.Timestamp`). */
|
|
48
|
-
timestamp: number;
|
|
49
|
-
executionContextId?: number;
|
|
50
|
-
stackTrace?: {
|
|
51
|
-
callFrames: Array<{
|
|
52
|
-
functionName: string;
|
|
53
|
-
url: string;
|
|
54
|
-
lineNumber: number;
|
|
55
|
-
columnNumber: number;
|
|
56
|
-
}>;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/** Payload of a `Network.requestWillBeSent` event (subset). */
|
|
60
|
-
interface NetworkRequestWillBeSentEvent {
|
|
61
|
-
requestId: string;
|
|
62
|
-
request: {
|
|
63
|
-
url: string;
|
|
64
|
-
method: string;
|
|
65
|
-
headers?: Record<string, string>;
|
|
66
|
-
};
|
|
67
|
-
/** CDP `Network.MonotonicTime` (seconds). */
|
|
68
|
-
timestamp: number;
|
|
69
|
-
/** Wall-clock seconds since epoch, when available. */
|
|
70
|
-
wallTime?: number;
|
|
71
|
-
type?: string;
|
|
72
|
-
}
|
|
73
|
-
/** Payload of a `Network.responseReceived` event (subset). */
|
|
74
|
-
interface NetworkResponseReceivedEvent {
|
|
75
|
-
requestId: string;
|
|
76
|
-
response: {
|
|
77
|
-
url: string;
|
|
78
|
-
status: number;
|
|
79
|
-
statusText: string;
|
|
80
|
-
mimeType?: string;
|
|
81
|
-
};
|
|
82
|
-
timestamp: number;
|
|
83
|
-
type?: string;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* A single call frame in a `Runtime.exceptionThrown` stack trace.
|
|
87
|
-
* Subset of the CDP `Runtime.CallFrame` shape.
|
|
88
|
-
*/
|
|
89
|
-
interface CdpCallFrame {
|
|
90
|
-
functionName: string;
|
|
91
|
-
scriptId?: string;
|
|
92
|
-
url: string;
|
|
93
|
-
lineNumber: number;
|
|
94
|
-
columnNumber: number;
|
|
95
|
-
}
|
|
96
|
-
/** Payload of a `Runtime.exceptionThrown` event. */
|
|
97
|
-
interface RuntimeExceptionThrownEvent {
|
|
98
|
-
/** Milliseconds since epoch (CDP `Runtime.Timestamp`). */
|
|
99
|
-
timestamp: number;
|
|
100
|
-
exceptionDetails: {
|
|
101
|
-
exceptionId: number;
|
|
102
|
-
text: string;
|
|
103
|
-
lineNumber: number;
|
|
104
|
-
columnNumber: number;
|
|
105
|
-
scriptId?: string;
|
|
106
|
-
url?: string;
|
|
107
|
-
stackTrace?: {
|
|
108
|
-
callFrames: CdpCallFrame[];
|
|
109
|
-
}; /** The thrown value as a CDP `RemoteObject`. */
|
|
110
|
-
exception?: CdpRemoteObject;
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
/** Map of the CDP event names Phase 1 consumes to their payload shapes. */
|
|
114
|
-
interface CdpEventMap {
|
|
115
|
-
'Runtime.consoleAPICalled': ConsoleApiCalledEvent;
|
|
116
|
-
'Network.requestWillBeSent': NetworkRequestWillBeSentEvent;
|
|
117
|
-
'Network.responseReceived': NetworkResponseReceivedEvent;
|
|
118
|
-
'Runtime.exceptionThrown': RuntimeExceptionThrownEvent;
|
|
119
|
-
}
|
|
120
|
-
type CdpEventName = keyof CdpEventMap;
|
|
121
|
-
/** A `DOM.Node` subset (recursive) returned by `DOM.getDocument`. */
|
|
122
|
-
interface CdpDomNode {
|
|
123
|
-
nodeId: number;
|
|
124
|
-
/** CDP node type (1 = element, 3 = text, 9 = document, …). */
|
|
125
|
-
nodeType: number;
|
|
126
|
-
nodeName: string;
|
|
127
|
-
/** Tag/local name for elements. */
|
|
128
|
-
localName?: string;
|
|
129
|
-
nodeValue?: string;
|
|
130
|
-
/** Flattened attribute list: `[name, value, name, value, …]`. */
|
|
131
|
-
attributes?: string[];
|
|
132
|
-
childNodeCount?: number;
|
|
133
|
-
children?: CdpDomNode[];
|
|
134
|
-
documentURL?: string;
|
|
135
|
-
baseURL?: string;
|
|
136
|
-
}
|
|
137
|
-
/** Result of `DOM.getDocument`. */
|
|
138
|
-
interface DomGetDocumentResult {
|
|
139
|
-
root: CdpDomNode;
|
|
140
|
-
}
|
|
141
|
-
/** Result of `DOMSnapshot.captureSnapshot` (subset we surface). */
|
|
142
|
-
interface DomSnapshotResult {
|
|
143
|
-
documents: unknown[];
|
|
144
|
-
strings: string[];
|
|
145
|
-
}
|
|
146
|
-
/** Result of `Page.captureScreenshot`. */
|
|
147
|
-
interface PageCaptureScreenshotResult {
|
|
148
|
-
/** Base64-encoded image bytes (PNG by default). */
|
|
149
|
-
data: string;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Params for `Runtime.evaluate`.
|
|
153
|
-
* Covers the subset used by the `measure_safe_area` read-only probe.
|
|
154
|
-
*/
|
|
155
|
-
interface RuntimeEvaluateParams {
|
|
156
|
-
/** JavaScript expression to evaluate in the page context. */
|
|
157
|
-
expression: string;
|
|
158
|
-
/** Return the result as a plain JSON value (vs. a handle). Default false. */
|
|
159
|
-
returnByValue?: boolean;
|
|
160
|
-
/** Await a returned Promise before resolving. Default false. */
|
|
161
|
-
awaitPromise?: boolean;
|
|
162
|
-
}
|
|
163
|
-
/** Result of `Runtime.evaluate`. */
|
|
164
|
-
interface RuntimeEvaluateResult {
|
|
165
|
-
/** The evaluation result. */
|
|
166
|
-
result: CdpRemoteObject;
|
|
167
|
-
/** Present when evaluation threw an uncaught exception. */
|
|
168
|
-
exceptionDetails?: {
|
|
169
|
-
text: string;
|
|
170
|
-
exception?: CdpRemoteObject;
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Map of CDP command method → params/result shape. Keeps `send` typed so a
|
|
175
|
-
* `DOM.getDocument` call resolves to a `DomGetDocumentResult`, etc.
|
|
176
|
-
*/
|
|
177
|
-
interface CdpCommandMap {
|
|
178
|
-
'DOM.getDocument': {
|
|
179
|
-
params: {
|
|
180
|
-
depth?: number;
|
|
181
|
-
pierce?: boolean;
|
|
182
|
-
};
|
|
183
|
-
result: DomGetDocumentResult;
|
|
184
|
-
};
|
|
185
|
-
'DOMSnapshot.captureSnapshot': {
|
|
186
|
-
params: {
|
|
187
|
-
computedStyles?: string[];
|
|
188
|
-
};
|
|
189
|
-
result: DomSnapshotResult;
|
|
190
|
-
};
|
|
191
|
-
'Page.captureScreenshot': {
|
|
192
|
-
params: {
|
|
193
|
-
format?: 'png' | 'jpeg' | 'webp';
|
|
194
|
-
quality?: number;
|
|
195
|
-
};
|
|
196
|
-
result: PageCaptureScreenshotResult;
|
|
197
|
-
};
|
|
198
|
-
'Runtime.evaluate': {
|
|
199
|
-
params: RuntimeEvaluateParams;
|
|
200
|
-
result: RuntimeEvaluateResult;
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
type CdpCommandName = keyof CdpCommandMap;
|
|
204
|
-
/**
|
|
205
|
-
* The connection the tool layer reads from. The production implementation
|
|
206
|
-
* wraps the Chii relay's CDP websocket; tests inject a fake.
|
|
207
|
-
*
|
|
208
|
-
* Implementations are expected to maintain an internal ring buffer of recent
|
|
209
|
-
* events (so a tool call returns recent history rather than only live events).
|
|
210
|
-
*/
|
|
211
|
-
interface CdpConnection {
|
|
212
|
-
/**
|
|
213
|
-
* Authoritative kind of this connection's transport (issue #348).
|
|
214
|
-
*
|
|
215
|
-
* - `'relay'` — backed by the Chii relay + cloudflared tunnel (a real-device
|
|
216
|
-
* WebView, env 3/4). `ChiiCdpConnection`.
|
|
217
|
-
* - `'local'` — backed by a direct CDP websocket to a local Chromium (env 1).
|
|
218
|
-
* `LocalCdpConnection`.
|
|
219
|
-
*
|
|
220
|
-
* This replaces the old `getEnvironment()` URL-pattern sniffing: the
|
|
221
|
-
* `mock` vs `relay` split is now a free, authoritative property of the
|
|
222
|
-
* connection itself, known before any target attaches. The `relay-dev` vs
|
|
223
|
-
* `relay-live` distinction is orthogonal (operator-supplied `liveIntent`,
|
|
224
|
-
* see `environment.ts`) because dog-food and production relays are
|
|
225
|
-
* byte-identical on the wire.
|
|
226
|
-
*/
|
|
227
|
-
readonly kind: 'relay' | 'local';
|
|
228
|
-
/**
|
|
229
|
-
* Enable the CDP domains Phase 1 needs (`Runtime.enable`, `Network.enable`).
|
|
230
|
-
* Idempotent. Resolves once the relay has acknowledged (or immediately for a
|
|
231
|
-
* fake connection).
|
|
232
|
-
*/
|
|
233
|
-
enableDomains(): Promise<void>;
|
|
234
|
-
/** Targets (pages) the relay currently sees attached. */
|
|
235
|
-
listTargets(): CdpTarget[];
|
|
236
|
-
/** Recent buffered events for a domain, oldest-first. */
|
|
237
|
-
getBufferedEvents<E extends CdpEventName>(event: E): ReadonlyArray<CdpEventMap[E]>;
|
|
238
|
-
/** Subscribe to live events. Returns an unsubscribe function. */
|
|
239
|
-
on<E extends CdpEventName>(event: E, listener: (payload: CdpEventMap[E]) => void): () => void;
|
|
240
|
-
/**
|
|
241
|
-
* Issue a CDP command (request → response). Phase 2's DOM/snapshot/screenshot
|
|
242
|
-
* tools use this; resolves with the typed result or rejects on a CDP error.
|
|
243
|
-
* Implementations must have called {@link enableDomains} first.
|
|
244
|
-
*/
|
|
245
|
-
send<M extends CdpCommandName>(method: M, params?: CdpCommandMap[M]['params']): Promise<CdpCommandMap[M]['result']>;
|
|
246
|
-
/**
|
|
247
|
-
* Close the underlying transport and reject any in-flight commands.
|
|
248
|
-
* Optional so that minimal test fakes that don't need teardown remain
|
|
249
|
-
* compatible without change. Both `ChiiCdpConnection` and
|
|
250
|
-
* `LocalCdpConnection` already implement this.
|
|
251
|
-
*/
|
|
252
|
-
close?(): void;
|
|
253
|
-
/**
|
|
254
|
-
* Refresh the attached-target list from the relay and return the result.
|
|
255
|
-
* Emits an internal `'target:attached'` event when a new target appears so
|
|
256
|
-
* that {@link waitForFirstTarget} can race against the polling round.
|
|
257
|
-
*
|
|
258
|
-
* Optional — only `ChiiCdpConnection` (relay mode) supports this; local
|
|
259
|
-
* connections and test fakes may omit it. Callers should guard with
|
|
260
|
-
* `connection.refreshTargets?.()`.
|
|
261
|
-
*/
|
|
262
|
-
refreshTargets?(): Promise<CdpTarget[]>;
|
|
263
|
-
/**
|
|
264
|
-
* Waits until at least one target satisfying `filterFn` is attached, then
|
|
265
|
-
* resolves with the full target list at that moment.
|
|
266
|
-
*
|
|
267
|
-
* Optional — only `ChiiCdpConnection` provides the event-driven
|
|
268
|
-
* implementation. When absent, callers fall back to a generic polling loop.
|
|
269
|
-
*
|
|
270
|
-
* @param filterFn - Predicate the resolved targets must satisfy.
|
|
271
|
-
* @param timeoutMs - Reject after this many ms (default 90 000).
|
|
272
|
-
* @param pollIntervalMs - Fallback poll interval (default 500 ms).
|
|
273
|
-
*/
|
|
274
|
-
waitForFirstTarget?(filterFn: (targets: CdpTarget[]) => boolean, timeoutMs?: number, pollIntervalMs?: number): Promise<CdpTarget[]>;
|
|
275
|
-
}
|
|
276
|
-
//#endregion
|
|
277
|
-
//#region src/test-runner/bundle.d.ts
|
|
278
|
-
/**
|
|
279
|
-
* esbuild-based bundler for user test files.
|
|
280
|
-
*
|
|
281
|
-
* Bundles a single test file into a self-contained IIFE string that can be
|
|
282
|
-
* injected into a WebView via `Runtime.evaluate`. The bundle includes the
|
|
283
|
-
* test runtime (`runtime.ts`), which provides `describe/it/test/expect` and
|
|
284
|
-
* the `runTestModule(factory)` entry point.
|
|
285
|
-
*
|
|
286
|
-
* ## How the wiring works
|
|
287
|
-
*
|
|
288
|
-
* The bundle exposes two exports on `globalThis.__testBundle`:
|
|
289
|
-
* - `runTestModule` — the runtime's entry function.
|
|
290
|
-
* - `__userFactory` — an async function whose body is the user's top-level
|
|
291
|
-
* test registration code (describe/it/test calls).
|
|
292
|
-
*
|
|
293
|
-
* The Node-side RPC (`rpc.ts`) calls:
|
|
294
|
-
* `globalThis.__testBundle.runTestModule(globalThis.__testBundle.__userFactory)`
|
|
295
|
-
*
|
|
296
|
-
* `runTestModule` then installs `describe/it/test/expect` as globals, invokes
|
|
297
|
-
* the factory (which registers all tests), runs them, and returns a `RunReport`.
|
|
298
|
-
*
|
|
299
|
-
* ## Why a factory wrapper is needed
|
|
300
|
-
*
|
|
301
|
-
* Naively adding the runtime to `entryPoints` and bundling the user file would
|
|
302
|
-
* fail for two reasons:
|
|
303
|
-
* 1. `describe/it/test/expect` from the runtime are module-local in the IIFE
|
|
304
|
-
* scope. The user's top-level `describe(...)` calls expect them as globals —
|
|
305
|
-
* they are not globals until `runTestModule` installs them.
|
|
306
|
-
* 2. Even with globals pre-installed, the user file runs at IIFE-evaluation
|
|
307
|
-
* time, before the RPC layer calls `runTestModule` to reset state and start
|
|
308
|
-
* the test clock.
|
|
309
|
-
*
|
|
310
|
-
* The factory approach solves both: the user's registration code is deferred
|
|
311
|
-
* into a function that `runTestModule` calls AFTER installing the globals.
|
|
312
|
-
*
|
|
313
|
-
* ## Factory extraction algorithm
|
|
314
|
-
*
|
|
315
|
-
* The `userFactoryPlugin` reads the user file and splits lines into:
|
|
316
|
-
* - **top-level**: `import …` and re-export lines — kept at module scope
|
|
317
|
-
* (the only valid position for static `import` in ESM).
|
|
318
|
-
* - **body**: all other statements — moved into the body of the exported
|
|
319
|
-
* `__userFactory` async function.
|
|
320
|
-
*
|
|
321
|
-
* esbuild processes the re-generated module, following each static import
|
|
322
|
-
* through the normal dependency graph (including the SDK-redirect plugin).
|
|
323
|
-
*
|
|
324
|
-
* ## SDK redirect
|
|
325
|
-
*
|
|
326
|
-
* Imports of `@apps-in-toss/web-framework` (and sub-paths) are intercepted via
|
|
327
|
-
* the `sdkRedirectPlugin` and replaced with a virtual `window.__sdk` proxy that
|
|
328
|
-
* `src/in-app/auto.ts` installs at runtime. This works for both 2.x and 3.x SDK.
|
|
329
|
-
*
|
|
330
|
-
* SECRET-HANDLING: the returned bundle code is caller-managed; never log it.
|
|
331
|
-
*/
|
|
332
|
-
/** Options accepted by `bundleTestFile`. */
|
|
333
|
-
interface BundleOptions {
|
|
334
|
-
/**
|
|
335
|
-
* Additional esbuild `external` patterns. The SDK package
|
|
336
|
-
* (`@apps-in-toss/web-framework` and `@apps-in-toss/web-framework/*`) is
|
|
337
|
-
* always handled by the SDK redirect plugin — callers may add more patterns
|
|
338
|
-
* to be left as globals.
|
|
339
|
-
*/
|
|
340
|
-
extraExternals?: string[];
|
|
341
|
-
/**
|
|
342
|
-
* Global name for the IIFE output object. Defaults to `__testBundle`.
|
|
343
|
-
* The runtime entry uses this to call `__testBundle.runTestModule(__userFactory)`.
|
|
344
|
-
*/
|
|
345
|
-
globalName?: string;
|
|
346
|
-
}
|
|
347
|
-
//#endregion
|
|
348
|
-
//#region src/test-runner/capture.d.ts
|
|
349
|
-
/**
|
|
350
|
-
* `__AIT_CAPTURE__` console-line parser (devtools#696).
|
|
351
|
-
*
|
|
352
|
-
* env3 test runs inject sdk-example's `aitCapture.ts`, which — when running in a
|
|
353
|
-
* WebView (no filesystem) — emits one `console.log` line per category in the
|
|
354
|
-
* stable form:
|
|
355
|
-
*
|
|
356
|
-
* __AIT_CAPTURE__ <category> <json>
|
|
357
|
-
*
|
|
358
|
-
* The relay-worker harvests `Runtime.consoleAPICalled` events as plain text
|
|
359
|
-
* lines (see `relay-worker.ts`) and hands them here. This module's only job is
|
|
360
|
-
* to recognise the allowlisted prefix, split off the category, and keep the
|
|
361
|
-
* remaining JSON string OPAQUE — devtools does NOT own or interpret the
|
|
362
|
-
* `__AIT_CAPTURE__` record shape (that lives in sdk-example). We carry
|
|
363
|
-
* `{ category, json }` through untouched so the 2.x↔3.0 line comparison stays a
|
|
364
|
-
* downstream concern.
|
|
365
|
-
*
|
|
366
|
-
* Why a strict allowlist prefix (SECRET-HANDLING): the raw console stream may
|
|
367
|
-
* also contain wss/scheme/relay noise lines. Only lines that EXACTLY start with
|
|
368
|
-
* `'__AIT_CAPTURE__ '` pass; everything else is discarded, so a stray relay URL
|
|
369
|
-
* can never be serialised into a capture artifact.
|
|
370
|
-
*
|
|
371
|
-
* react-free, dependency-free — safe to import from any test-runner entry
|
|
372
|
-
* without dragging in the chii/cloudflared Node graph.
|
|
373
|
-
*/
|
|
374
|
-
/**
|
|
375
|
-
* One parsed capture line. `json` is the raw JSON string exactly as the page
|
|
376
|
-
* emitted it (an array of sdk-example capture records). devtools treats it as
|
|
377
|
-
* opaque — it is validated as parseable JSON but never inspected.
|
|
378
|
-
*/
|
|
379
|
-
interface AitCaptureLine {
|
|
380
|
-
/** The capture category (first whitespace-delimited token after the prefix). */
|
|
381
|
-
category: string;
|
|
382
|
-
/** The remaining JSON payload, verbatim. Opaque to devtools. */
|
|
383
|
-
json: string;
|
|
384
|
-
}
|
|
385
|
-
//#endregion
|
|
386
|
-
//#region src/test-runner/runtime.d.ts
|
|
387
|
-
/**
|
|
388
|
-
* Thin test runtime for WebView execution.
|
|
389
|
-
*
|
|
390
|
-
* This file is bundled by `bundle.ts` together with the user's test file
|
|
391
|
-
* into a single IIFE injected into the WebView via `Runtime.evaluate`.
|
|
392
|
-
* It MUST stay browser-compatible — no Node.js APIs allowed.
|
|
393
|
-
*
|
|
394
|
-
* Design: rather than shipping @vitest/runner verbatim into a WebView (where
|
|
395
|
-
* its Node-side internals cause issues), this runtime provides a minimal
|
|
396
|
-
* compatible API surface — describe/it/test/expect globals — collects results
|
|
397
|
-
* into a plain JSON-safe object, and exports `runTestModule` as the entry point.
|
|
398
|
-
*
|
|
399
|
-
* @vitest/runner and @vitest/expect are listed as dependencies so that the
|
|
400
|
-
* package's type contracts are available and so the browser-compatible subsets
|
|
401
|
-
* can be referenced. The Vitest custom pool that drives this runtime through
|
|
402
|
-
* Vitest's `PoolRunnerInitializer` lives in `pool.ts`.
|
|
403
|
-
*
|
|
404
|
-
* NOTE: this file is imported by type from Node-side code (rpc.ts / relay-worker.ts)
|
|
405
|
-
* for the RunReport / TestResult type shapes. The runtime ITSELF is not imported
|
|
406
|
-
* at runtime on the Node side — only the types are used.
|
|
407
|
-
*/
|
|
408
|
-
/**
|
|
409
|
-
* Result of a single test case.
|
|
410
|
-
* All fields are JSON-serialisable.
|
|
411
|
-
*/
|
|
412
|
-
interface TestResult {
|
|
413
|
-
/** Full dot-joined test name including nested suite names. */
|
|
414
|
-
name: string;
|
|
415
|
-
/** `'pass'` or `'fail'`. `'skip'` for skipped tests. */
|
|
416
|
-
status: 'pass' | 'fail' | 'skip';
|
|
417
|
-
/** Duration in milliseconds. */
|
|
418
|
-
duration: number;
|
|
419
|
-
/** Error message (fail only). Does NOT include the expression/secret. */
|
|
420
|
-
error?: string;
|
|
421
|
-
}
|
|
422
|
-
/** Aggregate report returned by `runTestModule`. */
|
|
423
|
-
interface RunReport {
|
|
424
|
-
/** ISO timestamp of when `runTestModule` was called. */
|
|
425
|
-
startedAt: string;
|
|
426
|
-
/** Total elapsed milliseconds (wall-clock). */
|
|
427
|
-
duration: number;
|
|
428
|
-
passed: number;
|
|
429
|
-
failed: number;
|
|
430
|
-
skipped: number;
|
|
431
|
-
tests: TestResult[];
|
|
432
|
-
}
|
|
433
|
-
//#endregion
|
|
434
|
-
//#region src/test-runner/relay-worker.d.ts
|
|
435
|
-
/** Per-file result in the aggregate `RunReport`. */
|
|
436
|
-
interface FileResult {
|
|
437
|
-
/** Absolute or relative path to the test file. */
|
|
438
|
-
file: string;
|
|
439
|
-
/** Full run report for this file, or an error if bundling/injection failed. */
|
|
440
|
-
result: RunReport | {
|
|
441
|
-
error: string;
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
/** Aggregate report returned by `runTestFilesOverRelay`. */
|
|
445
|
-
interface RelayRunReport {
|
|
446
|
-
/** ISO timestamp of when the run started. */
|
|
447
|
-
startedAt: string;
|
|
448
|
-
/** Total elapsed wall-clock milliseconds. */
|
|
449
|
-
duration: number;
|
|
450
|
-
/** Per-file results in execution order. */
|
|
451
|
-
files: FileResult[];
|
|
452
|
-
/** Flattened totals across all files. */
|
|
453
|
-
totals: {
|
|
454
|
-
passed: number;
|
|
455
|
-
failed: number;
|
|
456
|
-
skipped: number;
|
|
457
|
-
total: number;
|
|
458
|
-
};
|
|
459
|
-
/**
|
|
460
|
-
* `__AIT_CAPTURE__` lines harvested from the page console during the run
|
|
461
|
-
* (additive field, devtools#696). Empty unless `collectCaptures` was set.
|
|
462
|
-
* Each entry is opaque (`{ category, json }`) — devtools does not interpret
|
|
463
|
-
* the record shape, only forwards it for downstream 2.x↔3.0 diffing.
|
|
464
|
-
*
|
|
465
|
-
* SECRET-HANDLING: only lines matching the `__AIT_CAPTURE__ ` allowlist
|
|
466
|
-
* prefix reach here; relay/wss/scheme noise lines are dropped in
|
|
467
|
-
* `parseCaptureLines`.
|
|
468
|
-
*/
|
|
469
|
-
captures: AitCaptureLine[];
|
|
470
|
-
}
|
|
471
|
-
/** Options for `runTestFilesOverRelay`. */
|
|
472
|
-
interface RelayRunOptions {
|
|
473
|
-
/**
|
|
474
|
-
* Options forwarded to `bundleTestFile` for each file.
|
|
475
|
-
*/
|
|
476
|
-
bundleOptions?: BundleOptions;
|
|
477
|
-
/**
|
|
478
|
-
* Per-file evaluate timeout in milliseconds. Defaults to 30 000.
|
|
479
|
-
* Increase for long-running suites or split the file.
|
|
480
|
-
*/
|
|
481
|
-
timeoutMs?: number;
|
|
482
|
-
/**
|
|
483
|
-
* When `true`, registers a live `Runtime.consoleAPICalled` listener for the
|
|
484
|
-
* duration of the run and harvests `__AIT_CAPTURE__` lines into
|
|
485
|
-
* `RelayRunReport.captures`. Defaults to **false** so the build-only
|
|
486
|
-
* eval/e2e path (and the Vitest pool) pay no listener/state overhead —
|
|
487
|
-
* `captures` is then an empty array.
|
|
488
|
-
*
|
|
489
|
-
* The listener is registered just BEFORE the first file runs and removed in a
|
|
490
|
-
* `finally` so it never accumulates across runs (no ring-buffer drain — the
|
|
491
|
-
* default 500-entry buffer would silently drop lines via `shift`).
|
|
492
|
-
*/
|
|
493
|
-
collectCaptures?: boolean;
|
|
494
|
-
}
|
|
495
|
-
//#endregion
|
|
496
|
-
//#region src/test-runner/cli.d.ts
|
|
497
|
-
/** Options for `runWithConnection`. */
|
|
498
|
-
interface RunWithConnectionOptions extends RelayRunOptions {
|
|
499
|
-
/** If true, print a summary to stdout. Defaults to false in tests. */
|
|
500
|
-
printSummary?: boolean;
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* Runs `files` over `connection` and returns the aggregate report.
|
|
504
|
-
* This pure function is the testable core of the CLI (and is what the
|
|
505
|
-
* `run_tests` MCP tool calls against the daemon's attached connection); it is
|
|
506
|
-
* separate from `main()` so tests can call it without spawning a subprocess.
|
|
507
|
-
*/
|
|
508
|
-
declare function runWithConnection(connection: CdpConnection, files: string[], opts?: RunWithConnectionOptions): Promise<RelayRunReport>;
|
|
509
|
-
/**
|
|
510
|
-
* Decides whether to suppress the QR/attach block on stdout.
|
|
511
|
-
*
|
|
512
|
-
* Suppress when EITHER the user passed `--no-qr-stdout`, OR stdout is not a TTY
|
|
513
|
-
* / `CI` is set / `AIT_NO_QR_STDOUT` is set (non-interactive — a captured stdout
|
|
514
|
-
* must not leak the relay wss + TOTP `at=` code that the QR block encodes). The
|
|
515
|
-
* suppression is whole-chunk: `attachUrl` AND `relayUrl` ride in the same block.
|
|
516
|
-
*
|
|
517
|
-
* Exported for unit testing.
|
|
518
|
-
*/
|
|
519
|
-
declare function shouldSuppressQr(noQrFlag: boolean): boolean;
|
|
520
|
-
/**
|
|
521
|
-
* CLI entry point.
|
|
522
|
-
*
|
|
523
|
-
* Performs a standalone relay attach → run lifecycle, sharing the attach
|
|
524
|
-
* assembly with the Vitest pool via `createRelayConnectionFactory` (single
|
|
525
|
-
* source — no drift):
|
|
526
|
-
*
|
|
527
|
-
* 1. Parse args: globs, --timeout, --cell-sdk-line, --cell-platform,
|
|
528
|
-
* --scheme-url (required for env3), --report-dir, --no-qr-stdout,
|
|
529
|
-
* --headless, --project-root.
|
|
530
|
-
* 2. Discover test files; exit 1 if none.
|
|
531
|
-
* 3. factory.open() — boot relay → render QR (suppressed on non-interactive
|
|
532
|
-
* stdout) → wait for phone → inject cell → enableDomains. Returns the conn.
|
|
533
|
-
* 4. runWithConnection(conn, files, { timeoutMs, collectCaptures, printSummary }).
|
|
534
|
-
* 5. With --report-dir: write the runner-agnostic report + capture files.
|
|
535
|
-
* 6. factory.close(); process.exitCode = failed > 0 ? 1 : 0.
|
|
536
|
-
*
|
|
537
|
-
* The CLI is not a daemon — no lock, router, SSE, or tools_list is needed.
|
|
538
|
-
* Attach timeout exits with code 1; test failures exit with code 1.
|
|
539
|
-
*
|
|
540
|
-
* SECRET-HANDLING: scheme_url / relay wssUrl / TOTP codes are never written to
|
|
541
|
-
* stdout/stderr directly. The QR block (which encodes the TOTP `at=` code) is
|
|
542
|
-
* printed only when stdout is interactive AND not suppressed.
|
|
543
|
-
*/
|
|
544
|
-
declare function main(argv?: string[]): Promise<void>;
|
|
545
|
-
//#endregion
|
|
546
|
-
export { RunWithConnectionOptions, main, runWithConnection, shouldSuppressQr };
|
|
547
|
-
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","names":[],"sources":["../../src/mcp/cdp-connection.ts","../../src/test-runner/bundle.ts","../../src/test-runner/capture.ts","../../src/test-runner/runtime.ts","../../src/test-runner/relay-worker.ts","../../src/test-runner/cli.ts"],"mappings":"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"}
|
package/dist/test-runner/cli.js
DELETED
package/dist/totp-zGIlDsZS.js
DELETED