@ait-co/devtools 0.1.107 → 0.1.109
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/bundle-KFs4t-wc.d.ts +96 -0
- package/dist/bundle-KFs4t-wc.d.ts.map +1 -0
- package/dist/cdp-connection-C0AP0tH2.d.ts +277 -0
- package/dist/cdp-connection-C0AP0tH2.d.ts.map +1 -0
- package/dist/in-app/auto.d.ts +17 -0
- package/dist/in-app/auto.d.ts.map +1 -1
- package/dist/in-app/auto.js +76 -0
- package/dist/in-app/auto.js.map +1 -1
- package/dist/in-app/index.d.ts +48 -1
- package/dist/in-app/index.d.ts.map +1 -1
- package/dist/in-app/index.js +60 -1
- package/dist/in-app/index.js.map +1 -1
- package/dist/mcp/cli.js +651 -9
- package/dist/mcp/cli.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +59 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/panel/index.js +1 -1
- package/dist/pool-CuVMzWGB.d.ts +14577 -0
- package/dist/pool-CuVMzWGB.d.ts.map +1 -0
- package/dist/relay-worker-xxanNQGs.d.ts +74 -0
- package/dist/relay-worker-xxanNQGs.d.ts.map +1 -0
- package/dist/runtime-Wi5d6Ywz.d.ts +50 -0
- package/dist/runtime-Wi5d6Ywz.d.ts.map +1 -0
- package/dist/test-runner/bundle.d.ts +2 -0
- package/dist/test-runner/bundle.js +232 -0
- package/dist/test-runner/bundle.js.map +1 -0
- package/dist/test-runner/cli.d.ts +462 -0
- package/dist/test-runner/cli.d.ts.map +1 -0
- package/dist/test-runner/cli.js +516 -0
- package/dist/test-runner/cli.js.map +1 -0
- package/dist/test-runner/config.d.ts +80 -0
- package/dist/test-runner/config.d.ts.map +1 -0
- package/dist/test-runner/config.js +54 -0
- package/dist/test-runner/config.js.map +1 -0
- package/dist/test-runner/pool.d.ts +2 -0
- package/dist/test-runner/pool.js +136 -0
- package/dist/test-runner/pool.js.map +1 -0
- package/dist/test-runner/relay-worker.d.ts +2 -0
- package/dist/test-runner/relay-worker.js +96 -0
- package/dist/test-runner/relay-worker.js.map +1 -0
- package/dist/test-runner/rpc.d.ts +53 -0
- package/dist/test-runner/rpc.d.ts.map +1 -0
- package/dist/test-runner/rpc.js +78 -0
- package/dist/test-runner/rpc.js.map +1 -0
- package/dist/test-runner/task-graph.d.ts +38 -0
- package/dist/test-runner/task-graph.d.ts.map +1 -0
- package/dist/test-runner/task-graph.js +182 -0
- package/dist/test-runner/task-graph.js.map +1 -0
- package/dist/unplugin/index.d.cts +13 -32
- package/dist/unplugin/index.d.cts.map +1 -1
- package/dist/unplugin/index.d.ts +13 -32
- package/dist/unplugin/index.d.ts.map +1 -1
- package/package.json +13 -3
|
@@ -0,0 +1,462 @@
|
|
|
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/runtime.d.ts
|
|
349
|
+
/**
|
|
350
|
+
* Thin test runtime for WebView execution.
|
|
351
|
+
*
|
|
352
|
+
* This file is bundled by `bundle.ts` together with the user's test file
|
|
353
|
+
* into a single IIFE injected into the WebView via `Runtime.evaluate`.
|
|
354
|
+
* It MUST stay browser-compatible — no Node.js APIs allowed.
|
|
355
|
+
*
|
|
356
|
+
* Design: rather than shipping @vitest/runner verbatim into a WebView (where
|
|
357
|
+
* its Node-side internals cause issues), this runtime provides a minimal
|
|
358
|
+
* compatible API surface — describe/it/test/expect globals — collects results
|
|
359
|
+
* into a plain JSON-safe object, and exports `runTestModule` as the entry point.
|
|
360
|
+
*
|
|
361
|
+
* @vitest/runner and @vitest/expect are listed as dependencies so that the
|
|
362
|
+
* package's type contracts are available and so the browser-compatible subsets
|
|
363
|
+
* can be referenced. The Vitest custom pool that drives this runtime through
|
|
364
|
+
* Vitest's `PoolRunnerInitializer` lives in `pool.ts`.
|
|
365
|
+
*
|
|
366
|
+
* NOTE: this file is imported by type from Node-side code (rpc.ts / relay-worker.ts)
|
|
367
|
+
* for the RunReport / TestResult type shapes. The runtime ITSELF is not imported
|
|
368
|
+
* at runtime on the Node side — only the types are used.
|
|
369
|
+
*/
|
|
370
|
+
/**
|
|
371
|
+
* Result of a single test case.
|
|
372
|
+
* All fields are JSON-serialisable.
|
|
373
|
+
*/
|
|
374
|
+
interface TestResult {
|
|
375
|
+
/** Full dot-joined test name including nested suite names. */
|
|
376
|
+
name: string;
|
|
377
|
+
/** `'pass'` or `'fail'`. `'skip'` for skipped tests. */
|
|
378
|
+
status: 'pass' | 'fail' | 'skip';
|
|
379
|
+
/** Duration in milliseconds. */
|
|
380
|
+
duration: number;
|
|
381
|
+
/** Error message (fail only). Does NOT include the expression/secret. */
|
|
382
|
+
error?: string;
|
|
383
|
+
}
|
|
384
|
+
/** Aggregate report returned by `runTestModule`. */
|
|
385
|
+
interface RunReport {
|
|
386
|
+
/** ISO timestamp of when `runTestModule` was called. */
|
|
387
|
+
startedAt: string;
|
|
388
|
+
/** Total elapsed milliseconds (wall-clock). */
|
|
389
|
+
duration: number;
|
|
390
|
+
passed: number;
|
|
391
|
+
failed: number;
|
|
392
|
+
skipped: number;
|
|
393
|
+
tests: TestResult[];
|
|
394
|
+
}
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/test-runner/relay-worker.d.ts
|
|
397
|
+
/** Per-file result in the aggregate `RunReport`. */
|
|
398
|
+
interface FileResult {
|
|
399
|
+
/** Absolute or relative path to the test file. */
|
|
400
|
+
file: string;
|
|
401
|
+
/** Full run report for this file, or an error if bundling/injection failed. */
|
|
402
|
+
result: RunReport | {
|
|
403
|
+
error: string;
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
/** Aggregate report returned by `runTestFilesOverRelay`. */
|
|
407
|
+
interface RelayRunReport {
|
|
408
|
+
/** ISO timestamp of when the run started. */
|
|
409
|
+
startedAt: string;
|
|
410
|
+
/** Total elapsed wall-clock milliseconds. */
|
|
411
|
+
duration: number;
|
|
412
|
+
/** Per-file results in execution order. */
|
|
413
|
+
files: FileResult[];
|
|
414
|
+
/** Flattened totals across all files. */
|
|
415
|
+
totals: {
|
|
416
|
+
passed: number;
|
|
417
|
+
failed: number;
|
|
418
|
+
skipped: number;
|
|
419
|
+
total: number;
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
/** Options for `runTestFilesOverRelay`. */
|
|
423
|
+
interface RelayRunOptions {
|
|
424
|
+
/**
|
|
425
|
+
* Options forwarded to `bundleTestFile` for each file.
|
|
426
|
+
*/
|
|
427
|
+
bundleOptions?: BundleOptions;
|
|
428
|
+
/**
|
|
429
|
+
* Per-file evaluate timeout in milliseconds. Defaults to 30 000.
|
|
430
|
+
* Increase for long-running suites or split the file.
|
|
431
|
+
*/
|
|
432
|
+
timeoutMs?: number;
|
|
433
|
+
}
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region src/test-runner/cli.d.ts
|
|
436
|
+
/** Options for `runWithConnection`. */
|
|
437
|
+
interface RunWithConnectionOptions extends RelayRunOptions {
|
|
438
|
+
/** If true, print a summary to stdout. Defaults to false in tests. */
|
|
439
|
+
printSummary?: boolean;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Runs `files` over `connection` and returns the aggregate report.
|
|
443
|
+
* This pure function is the testable core of the CLI (and is what the
|
|
444
|
+
* `run_tests` MCP tool calls against the daemon's attached connection); it is
|
|
445
|
+
* separate from `main()` so tests can call it without spawning a subprocess.
|
|
446
|
+
*
|
|
447
|
+
* A standalone CLI relay attach/detach lifecycle (connect via Chii relay URL,
|
|
448
|
+
* `enableDomains`, run, then close) is not wired into `main()` yet.
|
|
449
|
+
*/
|
|
450
|
+
declare function runWithConnection(connection: CdpConnection, files: string[], opts?: RunWithConnectionOptions): Promise<RelayRunReport>;
|
|
451
|
+
/**
|
|
452
|
+
* CLI entry point.
|
|
453
|
+
*
|
|
454
|
+
* Resolves the matched test files and prints a "relay attach required" notice:
|
|
455
|
+
* the CLI's own standalone relay attach (resolve CDP URL, attach, run, close) is
|
|
456
|
+
* not wired yet, so today these files run via the `run_tests` MCP tool against
|
|
457
|
+
* the daemon's attached page.
|
|
458
|
+
*/
|
|
459
|
+
declare function main(argv?: string[]): Promise<void>;
|
|
460
|
+
//#endregion
|
|
461
|
+
export { RunWithConnectionOptions, main, runWithConnection };
|
|
462
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","names":[],"sources":["../../src/mcp/cdp-connection.ts","../../src/test-runner/bundle.ts","../../src/test-runner/runtime.ts","../../src/test-runner/relay-worker.ts","../../src/test-runner/cli.ts"],"mappings":";;;AAwBA;;;;;;;;;AAUA;;;;;;;;;;;AASA;;UAnBiB,SAAA;EA2BI;EAzBnB,EAAA;EAoBA;EAlBA,KAAA;EAoBA;EAlBA,GAAA;AAAA;;UAIe,eAAA;EACf,IAAA;EACA,OAAA;EACA,KAAA;EACA,WAAA;EACA,SAAA;AAAA;AAsBF;AAAA,UAlBiB,qBAAA;;EAEf,IAAA;EACA,IAAA,EAAM,eAAA;EAiBN;EAfA,SAAA;EACA,kBAAA;EACA,UAAA;IACE,UAAA,EAAY,KAAA;MACV,YAAA;MACA,GAAA;MACA,UAAA;MACA,YAAA;IAAA;EAAA;AAAA;;UAMW,6BAAA;EACf,SAAA;EACA,OAAA;IACE,GAAA;IACA,M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