@ait-co/devtools 0.1.106 → 0.1.108
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-BJm5jk56.d.ts +49 -0
- package/dist/bundle-BJm5jk56.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 +507 -11
- package/dist/mcp/cli.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +60 -3
- package/dist/mcp/server.js.map +1 -1
- package/dist/panel/index.js +1 -1
- package/dist/pool-Dkp7I9Bf.d.ts +14577 -0
- package/dist/pool-Dkp7I9Bf.d.ts.map +1 -0
- package/dist/{relay-secret-store-I5q2Wvvv.cjs → relay-secret-store-CPBBlV3J.cjs} +2 -2
- package/dist/{relay-secret-store-I5q2Wvvv.cjs.map → relay-secret-store-CPBBlV3J.cjs.map} +1 -1
- package/dist/{relay-secret-store-Bns5rndt.js → relay-secret-store-DBwzoCXQ.js} +2 -2
- package/dist/{relay-secret-store-Bns5rndt.js.map → relay-secret-store-DBwzoCXQ.js.map} +1 -1
- package/dist/{relay-secret-store-B0DH-8Qb.js → relay-secret-store-DhzAnnj-.js} +2 -2
- package/dist/{relay-secret-store-B0DH-8Qb.js.map → relay-secret-store-DhzAnnj-.js.map} +1 -1
- package/dist/{relay-url-store-CvmnevcO.cjs → relay-url-store-C9QLhB2p.cjs} +2 -2
- package/dist/{relay-url-store-CvmnevcO.cjs.map → relay-url-store-C9QLhB2p.cjs.map} +1 -1
- package/dist/{relay-url-store-BPeUZsiY.js → relay-url-store-CwKT7i04.js} +2 -2
- package/dist/{relay-url-store-BPeUZsiY.js.map → relay-url-store-CwKT7i04.js.map} +1 -1
- package/dist/{relay-url-store-DJHZjk8o.js → relay-url-store-j16TRTiJ.js} +2 -2
- package/dist/{relay-url-store-DJHZjk8o.js.map → relay-url-store-j16TRTiJ.js.map} +1 -1
- package/dist/relay-worker-BzFQ3fv9.d.ts +74 -0
- package/dist/relay-worker-BzFQ3fv9.d.ts.map +1 -0
- package/dist/runtime-ORdrpizY.d.ts +50 -0
- package/dist/runtime-ORdrpizY.d.ts.map +1 -0
- package/dist/test-runner/bundle.d.ts +2 -0
- package/dist/test-runner/bundle.js +95 -0
- package/dist/test-runner/bundle.js.map +1 -0
- package/dist/test-runner/cli.d.ts +417 -0
- package/dist/test-runner/cli.d.ts.map +1 -0
- package/dist/test-runner/cli.js +377 -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/{totp-BmKSPb5d.js → totp-95OAa20j.js} +2 -2
- package/dist/totp-95OAa20j.js.map +1 -0
- package/dist/{totp-BwDZ6dUT.cjs → totp-BjtoQNfu.cjs} +2 -2
- package/dist/totp-BjtoQNfu.cjs.map +1 -0
- package/dist/totp-D1pulXLa.js +3 -0
- package/dist/{totp-DYdP9N3o.js → totp-DIbrZtI7.js} +2 -2
- package/dist/totp-DIbrZtI7.js.map +1 -0
- package/dist/{totp-CNw0w89F.cjs → totp-Df252ZdA.cjs} +2 -2
- package/dist/totp-Df252ZdA.cjs.map +1 -0
- package/dist/{totp-Xq3ACwkm.js → totp-WY6l0ysP.js} +2 -2
- package/dist/totp-WY6l0ysP.js.map +1 -0
- package/dist/{tunnel-BmDcTrnU.js → tunnel-BjJROkcj.js} +2 -2
- package/dist/{tunnel-BmDcTrnU.js.map → tunnel-BjJROkcj.js.map} +1 -1
- package/dist/{tunnel-RB5zB8IK.cjs → tunnel-d_G9AIFn.cjs} +2 -2
- package/dist/{tunnel-RB5zB8IK.cjs.map → tunnel-d_G9AIFn.cjs.map} +1 -1
- package/dist/unplugin/index.cjs +4 -4
- 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/dist/unplugin/index.js +4 -4
- package/dist/unplugin/tunnel.cjs +1 -1
- package/dist/unplugin/tunnel.js +1 -1
- package/package.json +13 -3
- package/dist/totp-BcBNRoDD.js +0 -3
- package/dist/totp-BmKSPb5d.js.map +0 -1
- package/dist/totp-BwDZ6dUT.cjs.map +0 -1
- package/dist/totp-CNw0w89F.cjs.map +0 -1
- package/dist/totp-DYdP9N3o.js.map +0 -1
- package/dist/totp-Xq3ACwkm.js.map +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region src/test-runner/bundle.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* esbuild-based bundler for user test files.
|
|
4
|
+
*
|
|
5
|
+
* Bundles a single test file into a self-contained IIFE string that can be
|
|
6
|
+
* injected into a WebView via `Runtime.evaluate`. The user's SDK imports
|
|
7
|
+
* (`@apps-in-toss/web-framework` and sub-paths) are intercepted via an
|
|
8
|
+
* esbuild plugin that redirects them to `window.__sdk`, which the in-app
|
|
9
|
+
* debug gate (`src/in-app/auto.ts`) installs as a namespace mirror of the
|
|
10
|
+
* SDK exports (works for both 2.x and 3.x SDK).
|
|
11
|
+
*
|
|
12
|
+
* SECRET-HANDLING: the returned bundle code is caller-managed; never log it.
|
|
13
|
+
*/
|
|
14
|
+
/** Options accepted by `bundleTestFile`. */
|
|
15
|
+
interface BundleOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Additional esbuild `external` patterns. The SDK package
|
|
18
|
+
* (`@apps-in-toss/web-framework` and `@apps-in-toss/web-framework/*`) is
|
|
19
|
+
* always handled by the SDK redirect plugin — callers may add more patterns
|
|
20
|
+
* to be left as globals.
|
|
21
|
+
*/
|
|
22
|
+
extraExternals?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Global name for the IIFE output object. Defaults to `__testBundle`.
|
|
25
|
+
* The runtime entry uses this to call `__testBundle.runTestModule()`.
|
|
26
|
+
*/
|
|
27
|
+
globalName?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The result of bundling a test file.
|
|
31
|
+
* `code` is a self-contained IIFE string ready for `Runtime.evaluate`.
|
|
32
|
+
*/
|
|
33
|
+
interface BundleResult {
|
|
34
|
+
code: string;
|
|
35
|
+
warnings: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Bundles `absPath` into a single IIFE string suitable for `Runtime.evaluate`.
|
|
39
|
+
*
|
|
40
|
+
* The IIFE installs `window.__testBundle` (or the custom `globalName`) with
|
|
41
|
+
* `runTestModule` as the callable entry point.
|
|
42
|
+
*
|
|
43
|
+
* @param absPath - Absolute path to the user test file.
|
|
44
|
+
* @param opts - Optional bundling overrides.
|
|
45
|
+
*/
|
|
46
|
+
declare function bundleTestFile(absPath: string, opts?: BundleOptions): Promise<BundleResult>;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { BundleResult as n, bundleTestFile as r, BundleOptions as t };
|
|
49
|
+
//# sourceMappingURL=bundle-BJm5jk56.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-BJm5jk56.d.ts","names":[],"sources":["../src/test-runner/bundle.ts"],"mappings":";;AAwBA;;;;;AAmBA;;;;;AAqEA;;UAxFiB,aAAA;EAwF4C;;;;;;EAjF3D,cAAA;EAiFoD;;;;EA5EpD,UAAA;AAAA;;;;;UAOe,YAAA;EACf,IAAA;EACA,QAAA;AAAA;;;;;;;;;;iBAmEoB,cAAA,CAAe,OAAA,UAAiB,IAAA,GAAO,aAAA,GAAgB,OAAA,CAAQ,YAAA"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
//#region src/mcp/cdp-connection.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Injectable CDP connection abstraction for the debug-mode MCP server.
|
|
4
|
+
*
|
|
5
|
+
* The Phase 1 tool layer (`list_console_messages`, `list_network_requests`,
|
|
6
|
+
* `list_pages`) reads from CDP events captured off a Chii relay connection.
|
|
7
|
+
* To keep that tool layer CI-verifiable without a phone roundtrip, the actual
|
|
8
|
+
* relay websocket sits behind this interface. Production wires
|
|
9
|
+
* `ChiiCdpConnection` (see `chii-connection.ts`); tests inject a fake that
|
|
10
|
+
* emits canned `Runtime.consoleAPICalled` / `Network.*` events.
|
|
11
|
+
*
|
|
12
|
+
* Phase 2 adds CDP *commands* (request→response): `DOM.getDocument`,
|
|
13
|
+
* `DOMSnapshot.captureSnapshot`, `Page.captureScreenshot`. Unlike Phase 1's
|
|
14
|
+
* event streams these need a `send(method, params)` round-trip, so the
|
|
15
|
+
* connection grows a typed `send`. The fake returns canned command results.
|
|
16
|
+
*
|
|
17
|
+
* Phase 2 extension: `Runtime.evaluate` (read-only probe) added for the
|
|
18
|
+
* `measure_safe_area` tool — executes a JS snippet on the attached page and
|
|
19
|
+
* returns the result as a `RemoteObject`. The fake returns canned results for
|
|
20
|
+
* unit tests without a phone roundtrip.
|
|
21
|
+
*
|
|
22
|
+
* Only the slice of the Chrome DevTools Protocol the tools need is typed here.
|
|
23
|
+
*/
|
|
24
|
+
/** A target (page) the Chii relay currently sees attached. */
|
|
25
|
+
interface CdpTarget {
|
|
26
|
+
/** Chii's internal target id (session UUID). */
|
|
27
|
+
id: string;
|
|
28
|
+
/** Page title reported by the in-app target. */
|
|
29
|
+
title: string;
|
|
30
|
+
/** Page URL reported by the in-app target. */
|
|
31
|
+
url: string;
|
|
32
|
+
}
|
|
33
|
+
/** `Runtime.RemoteObject` subset we surface for console args. */
|
|
34
|
+
interface CdpRemoteObject {
|
|
35
|
+
type: string;
|
|
36
|
+
subtype?: string;
|
|
37
|
+
value?: unknown;
|
|
38
|
+
description?: string;
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
/** Payload of a `Runtime.consoleAPICalled` event. */
|
|
42
|
+
interface ConsoleApiCalledEvent {
|
|
43
|
+
/** log | warning | error | info | debug | … */
|
|
44
|
+
type: string;
|
|
45
|
+
args: CdpRemoteObject[];
|
|
46
|
+
/** Milliseconds since epoch (CDP `Runtime.Timestamp`). */
|
|
47
|
+
timestamp: number;
|
|
48
|
+
executionContextId?: number;
|
|
49
|
+
stackTrace?: {
|
|
50
|
+
callFrames: Array<{
|
|
51
|
+
functionName: string;
|
|
52
|
+
url: string;
|
|
53
|
+
lineNumber: number;
|
|
54
|
+
columnNumber: number;
|
|
55
|
+
}>;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Payload of a `Network.requestWillBeSent` event (subset). */
|
|
59
|
+
interface NetworkRequestWillBeSentEvent {
|
|
60
|
+
requestId: string;
|
|
61
|
+
request: {
|
|
62
|
+
url: string;
|
|
63
|
+
method: string;
|
|
64
|
+
headers?: Record<string, string>;
|
|
65
|
+
};
|
|
66
|
+
/** CDP `Network.MonotonicTime` (seconds). */
|
|
67
|
+
timestamp: number;
|
|
68
|
+
/** Wall-clock seconds since epoch, when available. */
|
|
69
|
+
wallTime?: number;
|
|
70
|
+
type?: string;
|
|
71
|
+
}
|
|
72
|
+
/** Payload of a `Network.responseReceived` event (subset). */
|
|
73
|
+
interface NetworkResponseReceivedEvent {
|
|
74
|
+
requestId: string;
|
|
75
|
+
response: {
|
|
76
|
+
url: string;
|
|
77
|
+
status: number;
|
|
78
|
+
statusText: string;
|
|
79
|
+
mimeType?: string;
|
|
80
|
+
};
|
|
81
|
+
timestamp: number;
|
|
82
|
+
type?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A single call frame in a `Runtime.exceptionThrown` stack trace.
|
|
86
|
+
* Subset of the CDP `Runtime.CallFrame` shape.
|
|
87
|
+
*/
|
|
88
|
+
interface CdpCallFrame {
|
|
89
|
+
functionName: string;
|
|
90
|
+
scriptId?: string;
|
|
91
|
+
url: string;
|
|
92
|
+
lineNumber: number;
|
|
93
|
+
columnNumber: number;
|
|
94
|
+
}
|
|
95
|
+
/** Payload of a `Runtime.exceptionThrown` event. */
|
|
96
|
+
interface RuntimeExceptionThrownEvent {
|
|
97
|
+
/** Milliseconds since epoch (CDP `Runtime.Timestamp`). */
|
|
98
|
+
timestamp: number;
|
|
99
|
+
exceptionDetails: {
|
|
100
|
+
exceptionId: number;
|
|
101
|
+
text: string;
|
|
102
|
+
lineNumber: number;
|
|
103
|
+
columnNumber: number;
|
|
104
|
+
scriptId?: string;
|
|
105
|
+
url?: string;
|
|
106
|
+
stackTrace?: {
|
|
107
|
+
callFrames: CdpCallFrame[];
|
|
108
|
+
}; /** The thrown value as a CDP `RemoteObject`. */
|
|
109
|
+
exception?: CdpRemoteObject;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** Map of the CDP event names Phase 1 consumes to their payload shapes. */
|
|
113
|
+
interface CdpEventMap {
|
|
114
|
+
'Runtime.consoleAPICalled': ConsoleApiCalledEvent;
|
|
115
|
+
'Network.requestWillBeSent': NetworkRequestWillBeSentEvent;
|
|
116
|
+
'Network.responseReceived': NetworkResponseReceivedEvent;
|
|
117
|
+
'Runtime.exceptionThrown': RuntimeExceptionThrownEvent;
|
|
118
|
+
}
|
|
119
|
+
type CdpEventName = keyof CdpEventMap;
|
|
120
|
+
/** A `DOM.Node` subset (recursive) returned by `DOM.getDocument`. */
|
|
121
|
+
interface CdpDomNode {
|
|
122
|
+
nodeId: number;
|
|
123
|
+
/** CDP node type (1 = element, 3 = text, 9 = document, …). */
|
|
124
|
+
nodeType: number;
|
|
125
|
+
nodeName: string;
|
|
126
|
+
/** Tag/local name for elements. */
|
|
127
|
+
localName?: string;
|
|
128
|
+
nodeValue?: string;
|
|
129
|
+
/** Flattened attribute list: `[name, value, name, value, …]`. */
|
|
130
|
+
attributes?: string[];
|
|
131
|
+
childNodeCount?: number;
|
|
132
|
+
children?: CdpDomNode[];
|
|
133
|
+
documentURL?: string;
|
|
134
|
+
baseURL?: string;
|
|
135
|
+
}
|
|
136
|
+
/** Result of `DOM.getDocument`. */
|
|
137
|
+
interface DomGetDocumentResult {
|
|
138
|
+
root: CdpDomNode;
|
|
139
|
+
}
|
|
140
|
+
/** Result of `DOMSnapshot.captureSnapshot` (subset we surface). */
|
|
141
|
+
interface DomSnapshotResult {
|
|
142
|
+
documents: unknown[];
|
|
143
|
+
strings: string[];
|
|
144
|
+
}
|
|
145
|
+
/** Result of `Page.captureScreenshot`. */
|
|
146
|
+
interface PageCaptureScreenshotResult {
|
|
147
|
+
/** Base64-encoded image bytes (PNG by default). */
|
|
148
|
+
data: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Params for `Runtime.evaluate`.
|
|
152
|
+
* Covers the subset used by the `measure_safe_area` read-only probe.
|
|
153
|
+
*/
|
|
154
|
+
interface RuntimeEvaluateParams {
|
|
155
|
+
/** JavaScript expression to evaluate in the page context. */
|
|
156
|
+
expression: string;
|
|
157
|
+
/** Return the result as a plain JSON value (vs. a handle). Default false. */
|
|
158
|
+
returnByValue?: boolean;
|
|
159
|
+
/** Await a returned Promise before resolving. Default false. */
|
|
160
|
+
awaitPromise?: boolean;
|
|
161
|
+
}
|
|
162
|
+
/** Result of `Runtime.evaluate`. */
|
|
163
|
+
interface RuntimeEvaluateResult {
|
|
164
|
+
/** The evaluation result. */
|
|
165
|
+
result: CdpRemoteObject;
|
|
166
|
+
/** Present when evaluation threw an uncaught exception. */
|
|
167
|
+
exceptionDetails?: {
|
|
168
|
+
text: string;
|
|
169
|
+
exception?: CdpRemoteObject;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Map of CDP command method → params/result shape. Keeps `send` typed so a
|
|
174
|
+
* `DOM.getDocument` call resolves to a `DomGetDocumentResult`, etc.
|
|
175
|
+
*/
|
|
176
|
+
interface CdpCommandMap {
|
|
177
|
+
'DOM.getDocument': {
|
|
178
|
+
params: {
|
|
179
|
+
depth?: number;
|
|
180
|
+
pierce?: boolean;
|
|
181
|
+
};
|
|
182
|
+
result: DomGetDocumentResult;
|
|
183
|
+
};
|
|
184
|
+
'DOMSnapshot.captureSnapshot': {
|
|
185
|
+
params: {
|
|
186
|
+
computedStyles?: string[];
|
|
187
|
+
};
|
|
188
|
+
result: DomSnapshotResult;
|
|
189
|
+
};
|
|
190
|
+
'Page.captureScreenshot': {
|
|
191
|
+
params: {
|
|
192
|
+
format?: 'png' | 'jpeg' | 'webp';
|
|
193
|
+
quality?: number;
|
|
194
|
+
};
|
|
195
|
+
result: PageCaptureScreenshotResult;
|
|
196
|
+
};
|
|
197
|
+
'Runtime.evaluate': {
|
|
198
|
+
params: RuntimeEvaluateParams;
|
|
199
|
+
result: RuntimeEvaluateResult;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
type CdpCommandName = keyof CdpCommandMap;
|
|
203
|
+
/**
|
|
204
|
+
* The connection the tool layer reads from. The production implementation
|
|
205
|
+
* wraps the Chii relay's CDP websocket; tests inject a fake.
|
|
206
|
+
*
|
|
207
|
+
* Implementations are expected to maintain an internal ring buffer of recent
|
|
208
|
+
* events (so a tool call returns recent history rather than only live events).
|
|
209
|
+
*/
|
|
210
|
+
interface CdpConnection {
|
|
211
|
+
/**
|
|
212
|
+
* Authoritative kind of this connection's transport (issue #348).
|
|
213
|
+
*
|
|
214
|
+
* - `'relay'` — backed by the Chii relay + cloudflared tunnel (a real-device
|
|
215
|
+
* WebView, env 3/4). `ChiiCdpConnection`.
|
|
216
|
+
* - `'local'` — backed by a direct CDP websocket to a local Chromium (env 1).
|
|
217
|
+
* `LocalCdpConnection`.
|
|
218
|
+
*
|
|
219
|
+
* This replaces the old `getEnvironment()` URL-pattern sniffing: the
|
|
220
|
+
* `mock` vs `relay` split is now a free, authoritative property of the
|
|
221
|
+
* connection itself, known before any target attaches. The `relay-dev` vs
|
|
222
|
+
* `relay-live` distinction is orthogonal (operator-supplied `liveIntent`,
|
|
223
|
+
* see `environment.ts`) because dog-food and production relays are
|
|
224
|
+
* byte-identical on the wire.
|
|
225
|
+
*/
|
|
226
|
+
readonly kind: 'relay' | 'local';
|
|
227
|
+
/**
|
|
228
|
+
* Enable the CDP domains Phase 1 needs (`Runtime.enable`, `Network.enable`).
|
|
229
|
+
* Idempotent. Resolves once the relay has acknowledged (or immediately for a
|
|
230
|
+
* fake connection).
|
|
231
|
+
*/
|
|
232
|
+
enableDomains(): Promise<void>;
|
|
233
|
+
/** Targets (pages) the relay currently sees attached. */
|
|
234
|
+
listTargets(): CdpTarget[];
|
|
235
|
+
/** Recent buffered events for a domain, oldest-first. */
|
|
236
|
+
getBufferedEvents<E extends CdpEventName>(event: E): ReadonlyArray<CdpEventMap[E]>;
|
|
237
|
+
/** Subscribe to live events. Returns an unsubscribe function. */
|
|
238
|
+
on<E extends CdpEventName>(event: E, listener: (payload: CdpEventMap[E]) => void): () => void;
|
|
239
|
+
/**
|
|
240
|
+
* Issue a CDP command (request → response). Phase 2's DOM/snapshot/screenshot
|
|
241
|
+
* tools use this; resolves with the typed result or rejects on a CDP error.
|
|
242
|
+
* Implementations must have called {@link enableDomains} first.
|
|
243
|
+
*/
|
|
244
|
+
send<M extends CdpCommandName>(method: M, params?: CdpCommandMap[M]['params']): Promise<CdpCommandMap[M]['result']>;
|
|
245
|
+
/**
|
|
246
|
+
* Close the underlying transport and reject any in-flight commands.
|
|
247
|
+
* Optional so that minimal test fakes that don't need teardown remain
|
|
248
|
+
* compatible without change. Both `ChiiCdpConnection` and
|
|
249
|
+
* `LocalCdpConnection` already implement this.
|
|
250
|
+
*/
|
|
251
|
+
close?(): void;
|
|
252
|
+
/**
|
|
253
|
+
* Refresh the attached-target list from the relay and return the result.
|
|
254
|
+
* Emits an internal `'target:attached'` event when a new target appears so
|
|
255
|
+
* that {@link waitForFirstTarget} can race against the polling round.
|
|
256
|
+
*
|
|
257
|
+
* Optional — only `ChiiCdpConnection` (relay mode) supports this; local
|
|
258
|
+
* connections and test fakes may omit it. Callers should guard with
|
|
259
|
+
* `connection.refreshTargets?.()`.
|
|
260
|
+
*/
|
|
261
|
+
refreshTargets?(): Promise<CdpTarget[]>;
|
|
262
|
+
/**
|
|
263
|
+
* Waits until at least one target satisfying `filterFn` is attached, then
|
|
264
|
+
* resolves with the full target list at that moment.
|
|
265
|
+
*
|
|
266
|
+
* Optional — only `ChiiCdpConnection` provides the event-driven
|
|
267
|
+
* implementation. When absent, callers fall back to a generic polling loop.
|
|
268
|
+
*
|
|
269
|
+
* @param filterFn - Predicate the resolved targets must satisfy.
|
|
270
|
+
* @param timeoutMs - Reject after this many ms (default 90 000).
|
|
271
|
+
* @param pollIntervalMs - Fallback poll interval (default 500 ms).
|
|
272
|
+
*/
|
|
273
|
+
waitForFirstTarget?(filterFn: (targets: CdpTarget[]) => boolean, timeoutMs?: number, pollIntervalMs?: number): Promise<CdpTarget[]>;
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
export { CdpConnection as t };
|
|
277
|
+
//# sourceMappingURL=cdp-connection-C0AP0tH2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdp-connection-C0AP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CAAc,CAAA;EAnBR;;;;;;EA2BjB,KAAA;EArB0C;;;;;;;;;EAgC1C,cAAA,KAAmB,OAAA,CAAQ,SAAA;EA7B0C;;;;;;;;;;;EA0CrE,kBAAA,EACE,QAAA,GAAW,OAAA,EAAS,SAAA,gBACpB,SAAA,WACA,cAAA,YACC,OAAA,CAAQ,SAAA;AAAA"}
|
package/dist/in-app/auto.d.ts
CHANGED
|
@@ -11,6 +11,23 @@
|
|
|
11
11
|
* imported chunk stays dormant and `window.__sdk` / `window.__sdkCall` are
|
|
12
12
|
* never installed on a normal production load.
|
|
13
13
|
*
|
|
14
|
+
* DEPRECATED for builds that require debug code to be PHYSICALLY ABSENT from
|
|
15
|
+
* the release bundle. This entry is a RUNTIME self-gate, not a build-time one:
|
|
16
|
+
* the imported chunk (Chii target.js injection, the SDK bridge, and the eruda
|
|
17
|
+
* console it pulls in via `maybeAttach()`) stays in the production bundle as a
|
|
18
|
+
* dormant chunk and is only kept asleep at runtime. If your threat model needs
|
|
19
|
+
* "zero bytes of debug surface in release" (no dormant chunk to extract or
|
|
20
|
+
* re-enable), do NOT use this entry. Instead guard the call site yourself:
|
|
21
|
+
*
|
|
22
|
+
* if (__DEBUG_BUILD__) {
|
|
23
|
+
* import('@ait-co/devtools/in-app').then((m) => m.maybeAttach());
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* with `define: { __DEBUG_BUILD__: 'false' }` in your release build — the
|
|
27
|
+
* bundler then dead-code-eliminates the whole `@ait-co/devtools/in-app` graph
|
|
28
|
+
* (verified on Vite 8/rolldown). This entry stays for the convenience case
|
|
29
|
+
* where a dormant chunk gated at runtime is acceptable.
|
|
30
|
+
*
|
|
14
31
|
* When the gate passes it:
|
|
15
32
|
* 1. Calls `maybeAttach()` — runs the full Layer B/C gate (host allowlist,
|
|
16
33
|
* opt-in params, relay URL, TOTP) and injects the Chii `target.js` script.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.d.ts","names":[],"sources":["../../src/in-app/auto.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"auto.d.ts","names":[],"sources":["../../src/in-app/auto.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6IA;;;;;AAkCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAhGQ,MAAA;EAAA,UACI,MAAA;;;;;;;;;;IAUR,KAAA,GAAQ,MAAA;;;;;;;;;IAUR,SAAA,IACE,IAAA,aACG,IAAA,gBACA,OAAA;MAAU,EAAA;MAAa,KAAA;MAAiB,KAAA;IAAA;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;iBAsCjC,eAAA,CAAA;;;;;;;;;;;;;;iBAkCA,cAAA,CACd,KAAA,YACA,SAAA"}
|
package/dist/in-app/auto.js
CHANGED
|
@@ -40,6 +40,64 @@ const RELAY_AUTH_REJECT_CLOSE_CODE = 4401;
|
|
|
40
40
|
*/
|
|
41
41
|
const RELAY_AUTH_REJECT_REASON = "totp-rejected";
|
|
42
42
|
//#endregion
|
|
43
|
+
//#region src/in-app/eruda-overlay.ts
|
|
44
|
+
/**
|
|
45
|
+
* In-app eruda console overlay for the debug attach flow.
|
|
46
|
+
*
|
|
47
|
+
* Spec: docs/superpowers/specs/2026-05-18-in-app-debug-mcp.md
|
|
48
|
+
*
|
|
49
|
+
* This module mounts the eruda in-page console (https://github.com/liriliri/eruda)
|
|
50
|
+
* on the phone screen when a debug session attaches. It is the mobile-only
|
|
51
|
+
* counterpart to the Chii `target.js` injection in {@link attach.ts}: Chii is a
|
|
52
|
+
* REMOTE CDP transport (phone → relay → PC DevTools frontend), whereas eruda is
|
|
53
|
+
* a LOCAL in-page view — a floating button + console/network/DOM/storage panels
|
|
54
|
+
* rendered directly on the phone, with no relay or second device. The two are
|
|
55
|
+
* orthogonal and coexist (eruda opens no WebSocket, mounts into its own
|
|
56
|
+
* `#eruda` shadow host — it cannot collide with the relay WS or the Chii DOM).
|
|
57
|
+
*
|
|
58
|
+
* Build-time absence (the security contract): this module lives in the
|
|
59
|
+
* `@ait-co/devtools/in-app` graph. A consumer wraps its
|
|
60
|
+
* `import('@ait-co/devtools/in-app')` call site in `if (__DEBUG_BUILD__) { … }`;
|
|
61
|
+
* a release build folds that constant to `false` and dead-code-eliminates the
|
|
62
|
+
* whole module — so eruda (and its dynamic `import('eruda')` chunk) is simply
|
|
63
|
+
* absent from release bundles, exactly like the Chii target.js injection. The
|
|
64
|
+
* `import('eruda')` here is a dynamic import precisely so the bundler emits it
|
|
65
|
+
* as a separate chunk that the dead branch never pulls in.
|
|
66
|
+
*
|
|
67
|
+
* Runtime gate: `mountEruda()` is called only from `maybeAttach()` AFTER the
|
|
68
|
+
* full Layer B/C gate has passed (`gateResult.attach === true`) — host
|
|
69
|
+
* allowlist, `debug=1`, relay URL, and TOTP. So eruda inherits the same
|
|
70
|
+
* four-layer defence as the Chii injection, byte-for-byte, with no eruda-
|
|
71
|
+
* specific gate of its own.
|
|
72
|
+
*
|
|
73
|
+
* SECRET-HANDLING: this module reads no secret, TOTP code, relay URL, or host
|
|
74
|
+
* value, and logs none. eruda observes only the page it is mounted on.
|
|
75
|
+
*/
|
|
76
|
+
/** Module-level guard against double mount across repeated `maybeAttach` calls. */
|
|
77
|
+
let erudaMounted = false;
|
|
78
|
+
/**
|
|
79
|
+
* Mounts the eruda in-page console once.
|
|
80
|
+
*
|
|
81
|
+
* Idempotent: repeated calls after a successful mount are no-ops, mirroring the
|
|
82
|
+
* `attached` guard in {@link attach.ts}. Fail-silent: if the dynamic import or
|
|
83
|
+
* `eruda.init()` throws (eruda absent, or a runtime that rejects it), the Chii
|
|
84
|
+
* debug session is unaffected — eruda is an additive convenience, not a
|
|
85
|
+
* dependency of the relay path.
|
|
86
|
+
*
|
|
87
|
+
* `eruda.init()` mounts eruda's own floating entry button on the phone screen;
|
|
88
|
+
* tapping it opens the console. We do not add a separate button.
|
|
89
|
+
*/
|
|
90
|
+
async function mountEruda() {
|
|
91
|
+
if (erudaMounted || typeof document === "undefined") return;
|
|
92
|
+
erudaMounted = true;
|
|
93
|
+
try {
|
|
94
|
+
(await import("eruda")).default.init();
|
|
95
|
+
} catch (err) {
|
|
96
|
+
erudaMounted = false;
|
|
97
|
+
console.debug("[@ait-co/devtools] eruda console mount skipped:", err);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
43
101
|
//#region src/in-app/gate.ts
|
|
44
102
|
/**
|
|
45
103
|
* The host suffix the Toss app uses to serve dogfood / private mini-apps.
|
|
@@ -499,6 +557,7 @@ function maybeAttach(gateResult = checkDebugGate()) {
|
|
|
499
557
|
};
|
|
500
558
|
(document.head ?? document.documentElement).appendChild(script);
|
|
501
559
|
attached = true;
|
|
560
|
+
mountEruda();
|
|
502
561
|
if (typeof window !== "undefined" && new URLSearchParams(window.location.search).get("noKeepAwake") === "1") return;
|
|
503
562
|
setScreenAwakeMode({ enabled: true }).then(() => {
|
|
504
563
|
window.addEventListener("beforeunload", () => {
|
|
@@ -522,6 +581,23 @@ function maybeAttach(gateResult = checkDebugGate()) {
|
|
|
522
581
|
* imported chunk stays dormant and `window.__sdk` / `window.__sdkCall` are
|
|
523
582
|
* never installed on a normal production load.
|
|
524
583
|
*
|
|
584
|
+
* DEPRECATED for builds that require debug code to be PHYSICALLY ABSENT from
|
|
585
|
+
* the release bundle. This entry is a RUNTIME self-gate, not a build-time one:
|
|
586
|
+
* the imported chunk (Chii target.js injection, the SDK bridge, and the eruda
|
|
587
|
+
* console it pulls in via `maybeAttach()`) stays in the production bundle as a
|
|
588
|
+
* dormant chunk and is only kept asleep at runtime. If your threat model needs
|
|
589
|
+
* "zero bytes of debug surface in release" (no dormant chunk to extract or
|
|
590
|
+
* re-enable), do NOT use this entry. Instead guard the call site yourself:
|
|
591
|
+
*
|
|
592
|
+
* if (__DEBUG_BUILD__) {
|
|
593
|
+
* import('@ait-co/devtools/in-app').then((m) => m.maybeAttach());
|
|
594
|
+
* }
|
|
595
|
+
*
|
|
596
|
+
* with `define: { __DEBUG_BUILD__: 'false' }` in your release build — the
|
|
597
|
+
* bundler then dead-code-eliminates the whole `@ait-co/devtools/in-app` graph
|
|
598
|
+
* (verified on Vite 8/rolldown). This entry stays for the convenience case
|
|
599
|
+
* where a dormant chunk gated at runtime is acceptable.
|
|
600
|
+
*
|
|
525
601
|
* When the gate passes it:
|
|
526
602
|
* 1. Calls `maybeAttach()` — runs the full Layer B/C gate (host allowlist,
|
|
527
603
|
* opt-in params, relay URL, TOTP) and injects the Chii `target.js` script.
|