spana-test 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/spana-testing/SKILL.md +0 -0
- package/LICENSE +0 -0
- package/README.md +199 -68
- package/dist/{accessibility-audit-RS3VIWRT.js → accessibility-audit-YZOPUY3D.js} +7 -3
- package/dist/accessibility-audit-YZOPUY3D.js.map +1 -0
- package/dist/agent/index.d.ts +3 -84
- package/dist/agent/index.js +11 -10
- package/dist/agent/index.js.map +0 -0
- package/dist/allure-RNMEYTXS.js +0 -0
- package/dist/allure-RNMEYTXS.js.map +0 -0
- package/dist/{android-GFW6OXPQ.js → android-4NVTZMHL.js} +6 -2
- package/dist/{android-GFW6OXPQ.js.map → android-4NVTZMHL.js.map} +0 -0
- package/dist/appium-server-66GVUL24.js +0 -0
- package/dist/appium-server-66GVUL24.js.map +0 -0
- package/dist/baseline-manager-5TIUCNP5.js +0 -0
- package/dist/baseline-manager-5TIUCNP5.js.map +0 -0
- package/dist/chunk-3FSZNKEF.js +0 -0
- package/dist/chunk-3FSZNKEF.js.map +0 -0
- package/dist/chunk-3TRMQCUT.js +0 -0
- package/dist/chunk-3TRMQCUT.js.map +0 -0
- package/dist/chunk-3YE2POGD.js +471 -0
- package/dist/chunk-3YE2POGD.js.map +1 -0
- package/dist/chunk-5245YBLL.js +0 -0
- package/dist/chunk-5245YBLL.js.map +0 -0
- package/dist/{chunk-3J4NG7JU.js → chunk-CY3DKTBZ.js} +8 -2
- package/dist/chunk-CY3DKTBZ.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +0 -0
- package/dist/chunk-DGUM43GV.js.map +0 -0
- package/dist/chunk-DTNK54C2.js +127 -0
- package/dist/chunk-DTNK54C2.js.map +1 -0
- package/dist/{chunk-EWIR2GVV.js → chunk-H27IBIGA.js} +19 -2
- package/dist/chunk-H27IBIGA.js.map +1 -0
- package/dist/chunk-H3RWZCID.js +439 -0
- package/dist/chunk-H3RWZCID.js.map +1 -0
- package/dist/{chunk-PZYZ4O6D.js → chunk-HCG4CJKR.js} +23 -5
- package/dist/chunk-HCG4CJKR.js.map +1 -0
- package/dist/{chunk-YGHDMA6D.js → chunk-HYSTRWYN.js} +142 -41
- package/dist/chunk-HYSTRWYN.js.map +1 -0
- package/dist/chunk-IHVZKQQW.js +0 -0
- package/dist/chunk-IHVZKQQW.js.map +0 -0
- package/dist/chunk-KJPHH2TW.js +0 -0
- package/dist/chunk-KJPHH2TW.js.map +0 -0
- package/dist/chunk-LAMTF4LX.js +89 -0
- package/dist/chunk-LAMTF4LX.js.map +1 -0
- package/dist/chunk-LRGT342X.js +2300 -0
- package/dist/chunk-LRGT342X.js.map +1 -0
- package/dist/chunk-OBCFACUW.js +0 -0
- package/dist/chunk-OBCFACUW.js.map +0 -0
- package/dist/chunk-PJKIXVSO.js +5019 -0
- package/dist/chunk-PJKIXVSO.js.map +1 -0
- package/dist/chunk-S5JNNDXS.js +0 -0
- package/dist/chunk-S5JNNDXS.js.map +0 -0
- package/dist/{chunk-7VOWF42B.js → chunk-SQL3YRR5.js} +74 -8
- package/dist/chunk-SQL3YRR5.js.map +1 -0
- package/dist/{chunk-KYPLYRKW.js → chunk-UJQ7PID5.js} +47 -15
- package/dist/chunk-UJQ7PID5.js.map +1 -0
- package/dist/{chunk-FJAJ4YNC.js → chunk-WSA5QPTA.js} +2 -2
- package/dist/{chunk-FJAJ4YNC.js.map → chunk-WSA5QPTA.js.map} +0 -0
- package/dist/chunk-X2TJP7LB.js +0 -0
- package/dist/chunk-X2TJP7LB.js.map +0 -0
- package/dist/chunk-XENRC3YO.js +2486 -0
- package/dist/chunk-XENRC3YO.js.map +1 -0
- package/dist/cli.js +60 -20
- package/dist/cli.js.map +1 -1
- package/dist/compiler-X6WTFMYF.js +0 -0
- package/dist/compiler-X6WTFMYF.js.map +0 -0
- package/dist/config-loader-XGDDJGVY.js +9 -0
- package/dist/{config-loader-QM72GKEL.js.map → config-loader-XGDDJGVY.js.map} +0 -0
- package/dist/{console-7UW7VROK.js → console-MI2XB5RG.js} +8 -2
- package/dist/console-MI2XB5RG.js.map +1 -0
- package/dist/daemon-manager-FBISTX24.js +28 -0
- package/dist/{discover-CAQY6EG6.js.map → daemon-manager-FBISTX24.js.map} +0 -0
- package/dist/{discover-CAQY6EG6.js → discover-LHEBSUIP.js} +3 -3
- package/dist/{installer-PVBSX7UC.js.map → discover-LHEBSUIP.js.map} +0 -0
- package/dist/doctor-command-WB3O2H64.js +378 -0
- package/dist/doctor-command-WB3O2H64.js.map +1 -0
- package/dist/filters-Q3ALKWZ5.js +24 -0
- package/dist/{session-2MZVGYAC.js.map → filters-Q3ALKWZ5.js.map} +0 -0
- package/dist/{flow-thjUxXXx.d.ts → flow-CyRC-tTc.d.ts} +15 -7
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/gherkin/steps.js +0 -0
- package/dist/gherkin/steps.js.map +0 -0
- package/dist/github-pr-YMWIPCCZ.js +10 -0
- package/dist/github-pr-YMWIPCCZ.js.map +1 -0
- package/dist/html-F3X3XPSX.js +0 -0
- package/dist/html-F3X3XPSX.js.map +0 -0
- package/dist/index.d.ts +1129 -6
- package/dist/index.js +575 -6
- package/dist/index.js.map +1 -1
- package/dist/{init-command-U66XCM66.js → init-command-Z3QREABL.js} +60 -1
- package/dist/init-command-Z3QREABL.js.map +1 -0
- package/dist/{init-flow-command-PR7J5FBM.js → init-flow-command-4EKRVTNT.js} +2 -2
- package/dist/{init-flow-command-PR7J5FBM.js.map → init-flow-command-4EKRVTNT.js.map} +0 -0
- package/dist/{installer-PVBSX7UC.js → installer-VUPFWP5X.js} +7 -2
- package/dist/installer-VUPFWP5X.js.map +1 -0
- package/dist/ios-JPK43TFZ.js +0 -0
- package/dist/ios-JPK43TFZ.js.map +0 -0
- package/dist/json-JMRPUVY2.js +0 -0
- package/dist/json-JMRPUVY2.js.map +0 -0
- package/dist/junit-HLC62MK6.js +0 -0
- package/dist/junit-HLC62MK6.js.map +0 -0
- package/dist/machine-6H25TRTU.js +0 -0
- package/dist/machine-6H25TRTU.js.map +0 -0
- package/dist/provider-YIPU5K42.js +0 -0
- package/dist/provider-YIPU5K42.js.map +0 -0
- package/dist/redact-U72BUBBR.js +0 -0
- package/dist/redact-U72BUBBR.js.map +0 -0
- package/dist/runner-6HK62Q7B.js +0 -0
- package/dist/runner-6HK62Q7B.js.map +0 -0
- package/dist/screenshot-compare-3QRHHSFZ.js +116 -0
- package/dist/screenshot-compare-3QRHHSFZ.js.map +1 -0
- package/dist/{server-PZBRGU7P.js → server-PRM7BVVD.js} +14 -13
- package/dist/{server-PZBRGU7P.js.map → server-PRM7BVVD.js.map} +1 -1
- package/dist/server-QWJJB3WG.js +14 -0
- package/dist/server-QWJJB3WG.js.map +1 -0
- package/dist/session-2E6OK6BH.js +18 -0
- package/dist/session-2E6OK6BH.js.map +1 -0
- package/dist/session-Ddem-Q5n.d.ts +119 -0
- package/dist/{storybook-pBOPe_1D.d.ts → storybook-CxaP3YDz.d.ts} +265 -4
- package/dist/{studio-command-YDWQOMRX.js → studio-command-O3NN5BCG.js} +2 -2
- package/dist/{studio-command-YDWQOMRX.js.map → studio-command-O3NN5BCG.js.map} +0 -0
- package/dist/{test-command-B2VLWGDK.js → test-command-FYOZ6QAE.js} +231 -1341
- package/dist/test-command-FYOZ6QAE.js.map +1 -0
- package/dist/validator-HZ2A3NEI.js +0 -0
- package/dist/validator-HZ2A3NEI.js.map +0 -0
- package/package.json +7 -3
- package/studio-dist/assets/index-C-Io44gy.js +0 -0
- package/studio-dist/assets/index-DfM9lK4p.css +0 -0
- package/studio-dist/index.html +0 -0
- package/dist/accessibility-audit-RS3VIWRT.js.map +0 -1
- package/dist/chunk-3J4NG7JU.js.map +0 -1
- package/dist/chunk-7VOWF42B.js.map +0 -1
- package/dist/chunk-EWIR2GVV.js.map +0 -1
- package/dist/chunk-KYPLYRKW.js.map +0 -1
- package/dist/chunk-LC3QJIHY.js +0 -440
- package/dist/chunk-LC3QJIHY.js.map +0 -1
- package/dist/chunk-MCT4DYDK.js +0 -2671
- package/dist/chunk-MCT4DYDK.js.map +0 -1
- package/dist/chunk-PZYZ4O6D.js.map +0 -1
- package/dist/chunk-YAV6KBSW.js +0 -1318
- package/dist/chunk-YAV6KBSW.js.map +0 -1
- package/dist/chunk-YGHDMA6D.js.map +0 -1
- package/dist/config-loader-QM72GKEL.js +0 -9
- package/dist/console-7UW7VROK.js.map +0 -1
- package/dist/doctor-command-YGQPO7GH.js +0 -71
- package/dist/doctor-command-YGQPO7GH.js.map +0 -1
- package/dist/element-DZ0HyJ3C.d.ts +0 -25
- package/dist/init-command-U66XCM66.js.map +0 -1
- package/dist/screenshot-compare-JFHH2WR4.js +0 -75
- package/dist/screenshot-compare-JFHH2WR4.js.map +0 -1
- package/dist/session-2MZVGYAC.js +0 -17
- package/dist/test-command-B2VLWGDK.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
import '
|
|
1
|
+
import { F as FlowDefinition, a as FlowContext, b as FlowConfig, P as PromiseApp } from './flow-CyRC-tTc.js';
|
|
2
|
+
export { c as FlowFn, d as PromiseExpectation, S as SecondarySession, e as SecondarySessionOptions, f as Sessions, g as flow } from './flow-CyRC-tTc.js';
|
|
3
|
+
import { R as RawDriverService, D as DriverError, a as DomElementMatch, P as Platform, E as ExtendedSelector, T as TapMode, b as ProvConfig, c as DomChannel, d as DomTargetInfo, S as Selector, e as DomWaitForSelectorOptions, f as DomIdleOptions, g as DomStorageEntries, h as DomClearStorageOptions, B as BrowserRouteMatcher, i as BrowserMockResponse, j as BrowserConsoleLog, k as BrowserJSError, l as BrowserName, m as ElectrobunAppConfig, n as ElectrobunRenderer, A as AppiumExecutionConfig, o as AppConfig } from './storybook-CxaP3YDz.js';
|
|
4
|
+
export { p as ArtifactConfig, q as BackUntilVisibleOptions, r as BridgeConfig, s as BrowserHAR, t as BrowserNetworkConditions, u as DeviceInfo, v as DeviceStateConfig, w as DismissKeyboardOptions, x as DomChannelKind, y as DomRect, z as ElectronAppConfig, L as LaunchOptions, C as RelativeSelector, F as ScrollUntilVisibleOptions, G as StorybookConfig, H as StorybookOpenOptions, I as StorybookValue, J as TouchAction, K as TouchSequence, W as WarmDaemonConfig, M as WebBrowserEngine, N as WebExecutionConfig, O as WebResourceBlockType, Q as buildDomWaitForSelectorScript, U as defineConfig, V as isSystemUISelector, X as isTestIDSelector, Y as systemUI } from './storybook-CxaP3YDz.js';
|
|
5
|
+
import { E as Element, B as Bounds, C as ConnectOptions, S as Session } from './session-Ddem-Q5n.js';
|
|
6
|
+
import { Socket } from 'node:net';
|
|
7
|
+
import { Effect } from 'effect';
|
|
8
|
+
import { Browser, _electron, chromium } from 'playwright-core';
|
|
9
|
+
import { spawn } from 'node:child_process';
|
|
10
|
+
|
|
11
|
+
interface HierarchyCache {
|
|
12
|
+
/** Get the hierarchy, using cache if fresh enough. */
|
|
13
|
+
get(driver: RawDriverService, parse: (raw: string) => Element): Effect.Effect<Element, DriverError>;
|
|
14
|
+
/** Invalidate the cache (call after mutation actions like tap, type, scroll). */
|
|
15
|
+
invalidate(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type ResolvedChannel = "dom" | "native";
|
|
19
|
+
interface ResolvedElementResult {
|
|
20
|
+
element: Element;
|
|
21
|
+
channel: ResolvedChannel;
|
|
22
|
+
/** Raw DOM match when resolved via DOM channel */
|
|
23
|
+
domMatch?: DomElementMatch;
|
|
24
|
+
/** Resolved WebView frame in native coordinates (when mapped to native coords) */
|
|
25
|
+
webViewFrame?: Bounds;
|
|
26
|
+
}
|
|
27
|
+
/** Explicitly invalidate the cached WebView frame for a driver (e.g. after navigation or rotation). */
|
|
28
|
+
declare function invalidateWebViewFrameCache(driver: RawDriverService<any, any>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Locate the active WebView container's frame inside a parsed native
|
|
31
|
+
* accessibility hierarchy (iOS `XCUIElementTypeWebView` or Android
|
|
32
|
+
* `android.webkit.WebView`). Picks the largest visible WebView container so
|
|
33
|
+
* tiny auxiliary/ad webviews don't win over the primary Capacitor WebView.
|
|
34
|
+
*/
|
|
35
|
+
declare function findWebViewFrame(nativeRoot: Element): Bounds | undefined;
|
|
36
|
+
interface CoordinateMappingOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Override coordinate scale factor (CSS px -> native coordinate units).
|
|
39
|
+
* When omitted, derived automatically from `webViewFrame.width / match.viewportWidth`,
|
|
40
|
+
* falling back to `devicePixelRatio` on Android (physical pixels) and `1` on iOS (logical points).
|
|
41
|
+
*/
|
|
42
|
+
scaleOverride?: number;
|
|
43
|
+
platform?: Platform;
|
|
44
|
+
/**
|
|
45
|
+
* Optional explicit scroll offset adjustment if a caller provides document-relative
|
|
46
|
+
* coordinates instead of viewport-relative `getBoundingClientRect()` coordinates.
|
|
47
|
+
* Default: false (because `getBoundingClientRect()` is already viewport-relative).
|
|
48
|
+
*/
|
|
49
|
+
subtractScrollOffset?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Convert a DOM element's `getBoundingClientRect()` into native screen
|
|
53
|
+
* coordinates using the WebView's native frame, viewport/DPR scale, and
|
|
54
|
+
* optional scroll adjustment.
|
|
55
|
+
*
|
|
56
|
+
* - On iOS (WDA): native coordinates are logical points (~1× CSS px).
|
|
57
|
+
* `webViewFrame.width / viewportWidth` is ~1.0, and `webViewFrame.y` adds
|
|
58
|
+
* the status bar / safe-area / native header offset.
|
|
59
|
+
* - On Android (UiAutomator2): native coordinates are physical pixels
|
|
60
|
+
* (`CSS px × devicePixelRatio`). `webViewFrame.width / viewportWidth`
|
|
61
|
+
* equals `devicePixelRatio` automatically (e.g. 1080 / 393 ≈ 2.75).
|
|
62
|
+
*/
|
|
63
|
+
declare function domRectToScreenBounds(match: DomElementMatch, webViewFrame?: Bounds, options?: CoordinateMappingOptions): Bounds;
|
|
64
|
+
/**
|
|
65
|
+
* Returns true if the element's center lies outside the visible WebView viewport
|
|
66
|
+
* so we know to auto-scroll it into view before issuing a native coordinate tap.
|
|
67
|
+
*/
|
|
68
|
+
declare function isOffscreenInViewport(match: DomElementMatch): boolean;
|
|
69
|
+
interface ChannelResolveOptions {
|
|
70
|
+
/** Whether we're resolving for a touch/click action (maps to screen coords unless tapMode === "dom") */
|
|
71
|
+
forAction?: boolean;
|
|
72
|
+
/** Default "native" (real touch via native driver). Opt-in "dom" skips native coordinate mapping. */
|
|
73
|
+
tapMode?: TapMode;
|
|
74
|
+
platform?: Platform;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Channel-hiding resolver — core of Spana's web-first architecture:
|
|
78
|
+
*
|
|
79
|
+
* 1. If selector is explicitly marked `systemUI` (e.g. SFSafariViewController,
|
|
80
|
+
* Chrome Custom Tabs, OS permission dialogs), query the native tree directly.
|
|
81
|
+
* 2. If selector is `{ testID }` (or a simple non-relative selector when the
|
|
82
|
+
* DOM channel is already connected) and a `domChannel` exists on the driver,
|
|
83
|
+
* query the DOM first (~1ms, locale-independent).
|
|
84
|
+
* - For assertions/reads or `tapMode: "dom"`, return immediately without
|
|
85
|
+
* fetching the native page source.
|
|
86
|
+
* - For real native taps (`tapMode: "native"`), fetch/cache the native
|
|
87
|
+
* hierarchy once to locate the WebView frame, convert the DOM rect into
|
|
88
|
+
* screen coordinates, and return the screen-positioned element.
|
|
89
|
+
* 3. Otherwise, or if step 2 finds nothing (out-of-process browser sheet or
|
|
90
|
+
* native chrome), fall back seamlessly to the native accessibility tree.
|
|
91
|
+
*/
|
|
92
|
+
declare function resolveElementAcrossChannels<T extends string = string, R extends string = string>(driver: RawDriverService<T, R>, selector: ExtendedSelector<T>, parse: (raw: string) => Element, cache?: HierarchyCache, options?: ChannelResolveOptions): Effect.Effect<ResolvedElementResult | undefined, DriverError>;
|
|
6
93
|
|
|
7
94
|
/** Result of a single test step (tap, assertVisible, typeText, etc.) within a flow. */
|
|
8
95
|
interface StepResult {
|
|
@@ -149,6 +236,544 @@ interface Reporter {
|
|
|
149
236
|
platformFlowCounts?: Partial<Record<Platform, number>>;
|
|
150
237
|
}
|
|
151
238
|
|
|
239
|
+
type TargetShell = "browser" | "capacitor" | "electron" | "electrobun";
|
|
240
|
+
type TargetEngine = "chromium" | "webkit" | "firefox" | "wkwebview" | "webview2" | "webkitgtk" | "android-webview" | "cef";
|
|
241
|
+
type TargetChannel = "bridge" | "cdp" | "webkit-inspector" | "native-ax";
|
|
242
|
+
interface TargetDescriptor {
|
|
243
|
+
platform: Platform;
|
|
244
|
+
shell: TargetShell;
|
|
245
|
+
engine: TargetEngine;
|
|
246
|
+
channels: readonly TargetChannel[];
|
|
247
|
+
domChannels: readonly Exclude<TargetChannel, "native-ax">[];
|
|
248
|
+
nativeChannel: "native-ax" | null;
|
|
249
|
+
supportsSystemSheets: boolean;
|
|
250
|
+
notes: string;
|
|
251
|
+
}
|
|
252
|
+
type HostOS = "darwin" | "win32" | "linux";
|
|
253
|
+
/**
|
|
254
|
+
* Canonical matrix describing how Spana reaches the DOM and native UI on each
|
|
255
|
+
* supported web-first target:
|
|
256
|
+
* target = shell + engine + channels
|
|
257
|
+
*/
|
|
258
|
+
declare const TARGET_CHANNEL_MATRIX: Record<Platform, TargetDescriptor>;
|
|
259
|
+
declare function resolveElectrobunEngine(renderer?: "native" | "cef", hostOs?: HostOS): {
|
|
260
|
+
engine: TargetEngine;
|
|
261
|
+
channels: TargetChannel[];
|
|
262
|
+
};
|
|
263
|
+
declare function resolveTargetDescriptor(platform: Platform, config?: ProvConfig, hostOs?: HostOS): TargetDescriptor;
|
|
264
|
+
declare function formatTargetMatrixTable(platforms?: Platform[], config?: ProvConfig, hostOs?: HostOS): string;
|
|
265
|
+
|
|
266
|
+
interface MinimalWebSocket {
|
|
267
|
+
readonly readyState: number;
|
|
268
|
+
send(data: string): void;
|
|
269
|
+
close(): void;
|
|
270
|
+
addEventListener(type: string, listener: (event: any) => void): void;
|
|
271
|
+
removeEventListener?(type: string, listener: (event: any) => void): void;
|
|
272
|
+
}
|
|
273
|
+
type WebSocketFactory = (url: string) => MinimalWebSocket;
|
|
274
|
+
interface CdpDomChannelOptions {
|
|
275
|
+
/** Base HTTP URL of the CDP debug endpoint, e.g. `http://127.0.0.1:9222` */
|
|
276
|
+
endpointUrl: string;
|
|
277
|
+
/** Optional direct WebSocket URL (skips `/json/list` discovery) */
|
|
278
|
+
webSocketUrl?: string;
|
|
279
|
+
/** Optional target filter (matches URL or title substring/RegExp) */
|
|
280
|
+
targetFilter?: string | RegExp;
|
|
281
|
+
/** Command timeout in ms. Default: 10_000. */
|
|
282
|
+
timeoutMs?: number;
|
|
283
|
+
/** Injectable fetch for testing */
|
|
284
|
+
fetchFn?: typeof fetch;
|
|
285
|
+
/** Injectable WebSocket factory for testing */
|
|
286
|
+
createWebSocket?: WebSocketFactory;
|
|
287
|
+
}
|
|
288
|
+
declare class CdpDomChannel implements DomChannel {
|
|
289
|
+
readonly kind: "cdp";
|
|
290
|
+
private readonly endpointUrl;
|
|
291
|
+
private readonly explicitWsUrl?;
|
|
292
|
+
private readonly targetFilter?;
|
|
293
|
+
private readonly timeoutMs;
|
|
294
|
+
private readonly fetchFn;
|
|
295
|
+
private readonly createWebSocket;
|
|
296
|
+
private ws;
|
|
297
|
+
private connected;
|
|
298
|
+
private nextId;
|
|
299
|
+
private pending;
|
|
300
|
+
private currentTargetId;
|
|
301
|
+
constructor(options: CdpDomChannelOptions);
|
|
302
|
+
isConnected(): boolean;
|
|
303
|
+
listTargets(): Promise<DomTargetInfo[]>;
|
|
304
|
+
private fetchTargets;
|
|
305
|
+
selectTarget(targetId: string): Promise<void>;
|
|
306
|
+
connect(): Promise<void>;
|
|
307
|
+
private openSocket;
|
|
308
|
+
private rejectAllPending;
|
|
309
|
+
sendCommand<T = any>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
310
|
+
evaluate<T = unknown>(script: string | ((...args: any[]) => T), ...args: any[]): Promise<T>;
|
|
311
|
+
query(selector: Selector): Promise<DomElementMatch[]>;
|
|
312
|
+
waitForSelector(selector: Selector, opts?: DomWaitForSelectorOptions): Promise<DomElementMatch[]>;
|
|
313
|
+
tapDom(selector: Selector): Promise<boolean>;
|
|
314
|
+
scrollIntoView(selector: Selector): Promise<DomElementMatch | null>;
|
|
315
|
+
reload(): Promise<void>;
|
|
316
|
+
disconnect(): Promise<void>;
|
|
317
|
+
get targetId(): string | null;
|
|
318
|
+
}
|
|
319
|
+
declare function createCdpDomChannel(options: CdpDomChannelOptions): CdpDomChannel;
|
|
320
|
+
|
|
321
|
+
interface AndroidWebViewSocket {
|
|
322
|
+
socketName: string;
|
|
323
|
+
pid?: number;
|
|
324
|
+
}
|
|
325
|
+
interface AndroidWebViewCdpOptions {
|
|
326
|
+
serial: string;
|
|
327
|
+
packageName?: string;
|
|
328
|
+
/** Optional explicit local TCP port to forward to */
|
|
329
|
+
localPort?: number;
|
|
330
|
+
/** Optional explicit abstract socket name (skips /proc/net/unix discovery) */
|
|
331
|
+
socketName?: string;
|
|
332
|
+
timeoutMs?: number;
|
|
333
|
+
/** Injectable command runner for tests */
|
|
334
|
+
runAdb?: (args: string) => string;
|
|
335
|
+
fetchFn?: typeof fetch;
|
|
336
|
+
createWebSocket?: WebSocketFactory;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Parse `/proc/net/unix` output from an Android device and extract all
|
|
340
|
+
* `webview_devtools_remote_*` abstract Unix domain sockets.
|
|
341
|
+
*/
|
|
342
|
+
declare function parseAndroidWebViewSockets(procNetUnixOutput: string): AndroidWebViewSocket[];
|
|
343
|
+
/**
|
|
344
|
+
* Direct Android System WebView CDP channel without Appium.
|
|
345
|
+
*
|
|
346
|
+
* Requires `WebView.setWebContentsDebuggingEnabled(true)` (Capacitor's
|
|
347
|
+
* `webContentsDebuggingEnabled: true`). Discovers `webview_devtools_remote_<pid>`,
|
|
348
|
+
* forwards it via `adb forward tcp:<port> localabstract:<socket>`, and speaks
|
|
349
|
+
* CDP directly over WebSocket.
|
|
350
|
+
*/
|
|
351
|
+
declare class AndroidWebViewCdpChannel implements DomChannel {
|
|
352
|
+
readonly kind: "cdp";
|
|
353
|
+
private readonly options;
|
|
354
|
+
private forwardedPort;
|
|
355
|
+
private allocatedByUs;
|
|
356
|
+
private activeSocketName;
|
|
357
|
+
private cdp;
|
|
358
|
+
constructor(options: AndroidWebViewCdpOptions);
|
|
359
|
+
private execAdb;
|
|
360
|
+
isConnected(): boolean;
|
|
361
|
+
get socketName(): string | null;
|
|
362
|
+
get localPort(): number | null;
|
|
363
|
+
connect(): Promise<void>;
|
|
364
|
+
evaluate<T = unknown>(script: string | ((...args: any[]) => T), ...args: any[]): Promise<T>;
|
|
365
|
+
query(selector: Selector): Promise<DomElementMatch[]>;
|
|
366
|
+
tapDom(selector: Selector): Promise<boolean>;
|
|
367
|
+
scrollIntoView(selector: Selector): Promise<DomElementMatch | null>;
|
|
368
|
+
listTargets(): Promise<DomTargetInfo[]>;
|
|
369
|
+
selectTarget(targetId: string): Promise<void>;
|
|
370
|
+
reload(): Promise<void>;
|
|
371
|
+
disconnect(): Promise<void>;
|
|
372
|
+
}
|
|
373
|
+
declare function createAndroidWebViewCdpChannel(options: AndroidWebViewCdpOptions): AndroidWebViewCdpChannel;
|
|
374
|
+
|
|
375
|
+
interface WebKitInspectorOptions {
|
|
376
|
+
/** Base HTTP URL of the WebKit inspector proxy (e.g. `http://127.0.0.1:9221` or `27753`) */
|
|
377
|
+
endpointUrl?: string;
|
|
378
|
+
/** Port for ios-webkit-debug-proxy / simulator webinspectord bridge (default: 9221) */
|
|
379
|
+
port?: number;
|
|
380
|
+
/** Direct WebSocket URL (skips `/json` target listing) */
|
|
381
|
+
webSocketUrl?: string;
|
|
382
|
+
/** Target device / simulator UDID (used when auto-starting ios_webkit_debug_proxy) */
|
|
383
|
+
udid?: string;
|
|
384
|
+
/** Optional bundleId / URL filter to pick the right WKWebView page */
|
|
385
|
+
bundleId?: string;
|
|
386
|
+
/** Automatically spawn `ios_webkit_debug_proxy` if installed and endpoint isn't up */
|
|
387
|
+
autoStartProxy?: boolean;
|
|
388
|
+
timeoutMs?: number;
|
|
389
|
+
fetchFn?: typeof fetch;
|
|
390
|
+
createWebSocket?: WebSocketFactory;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Direct WebKit Remote Inspector channel for iOS `WKWebView` (iOS 16.4+
|
|
394
|
+
* `webView.isInspectable = true`) and macOS WKWebView — without Appium.
|
|
395
|
+
*
|
|
396
|
+
* Talks WebKit Inspector JSON-RPC (`Runtime.evaluate` with `returnByValue`)
|
|
397
|
+
* over WebSocket via `ios_webkit_debug_proxy` or a simulator `webinspectord`
|
|
398
|
+
* endpoint.
|
|
399
|
+
*/
|
|
400
|
+
declare class WebKitInspectorChannel implements DomChannel {
|
|
401
|
+
readonly kind: "webkit-inspector";
|
|
402
|
+
private readonly endpointUrl;
|
|
403
|
+
private readonly explicitWsUrl?;
|
|
404
|
+
private readonly udid?;
|
|
405
|
+
private readonly bundleId?;
|
|
406
|
+
private readonly port;
|
|
407
|
+
private readonly autoStartProxy;
|
|
408
|
+
private readonly timeoutMs;
|
|
409
|
+
private readonly fetchFn;
|
|
410
|
+
private readonly createWebSocket;
|
|
411
|
+
private ws;
|
|
412
|
+
private nativeInspector;
|
|
413
|
+
private proxyProcess;
|
|
414
|
+
private connected;
|
|
415
|
+
private nextId;
|
|
416
|
+
private pending;
|
|
417
|
+
private currentTargetId;
|
|
418
|
+
constructor(options?: WebKitInspectorOptions);
|
|
419
|
+
isConnected(): boolean;
|
|
420
|
+
private ensureProxyIfNeeded;
|
|
421
|
+
private fetchTargets;
|
|
422
|
+
listTargets(): Promise<DomTargetInfo[]>;
|
|
423
|
+
selectTarget(targetId: string): Promise<void>;
|
|
424
|
+
connect(): Promise<void>;
|
|
425
|
+
private openSocket;
|
|
426
|
+
private rejectAllPending;
|
|
427
|
+
sendCommand<T = any>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
428
|
+
evaluate<T = unknown>(script: string | ((...args: any[]) => T), ...args: any[]): Promise<T>;
|
|
429
|
+
query(selector: Selector): Promise<DomElementMatch[]>;
|
|
430
|
+
tapDom(selector: Selector): Promise<boolean>;
|
|
431
|
+
scrollIntoView(selector: Selector): Promise<DomElementMatch | null>;
|
|
432
|
+
reload(): Promise<void>;
|
|
433
|
+
private disconnectSocketOnly;
|
|
434
|
+
disconnect(): Promise<void>;
|
|
435
|
+
get targetId(): string | null;
|
|
436
|
+
}
|
|
437
|
+
declare function createWebKitInspectorChannel(options?: WebKitInspectorOptions): WebKitInspectorChannel;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Zero-dependency Apple WebInspector RPC framing over Unix domain sockets
|
|
441
|
+
* (iOS Simulator `com.apple.webinspector` / CoreSimulator tmp sockets).
|
|
442
|
+
*
|
|
443
|
+
* Apple's `webinspectord` exchanges length-prefixed XML/binary plist envelopes:
|
|
444
|
+
* - 4-byte big-endian uint32 byte length
|
|
445
|
+
* - XML plist payload containing `__selector` + `__argument` dictionary
|
|
446
|
+
*
|
|
447
|
+
* This lets Spana evaluate JS and query WKWebView DOMs on iOS Simulators even
|
|
448
|
+
* when `ios_webkit_debug_proxy` is not installed.
|
|
449
|
+
*/
|
|
450
|
+
interface WebInspectorListingPage {
|
|
451
|
+
appId: string;
|
|
452
|
+
pageId: number;
|
|
453
|
+
title?: string;
|
|
454
|
+
url?: string;
|
|
455
|
+
type?: string;
|
|
456
|
+
}
|
|
457
|
+
/** Encode an Apple WebInspector RPC message into a 4-byte length-prefixed XML plist frame. */
|
|
458
|
+
declare function encodeWebInspectorPacket(selector: string, args: Record<string, unknown>): Buffer;
|
|
459
|
+
/**
|
|
460
|
+
* Decode complete 4-byte length-prefixed frames from a streaming byte buffer.
|
|
461
|
+
* Returns decoded UTF-8 XML strings plus any trailing incomplete bytes.
|
|
462
|
+
*/
|
|
463
|
+
declare function decodeWebInspectorFrames(buffer: Buffer): {
|
|
464
|
+
frames: string[];
|
|
465
|
+
remaining: Buffer;
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* Extract the `__selector` and key fields (`WIRApplicationIdentifierKey`,
|
|
469
|
+
* `WIRMessageDataKey`, `WIRListingKey`) from a decoded XML plist frame.
|
|
470
|
+
*/
|
|
471
|
+
declare function parseWebInspectorXmlFrame(xml: string): {
|
|
472
|
+
selector: string | null;
|
|
473
|
+
appId?: string;
|
|
474
|
+
messageDataJson?: Record<string, any>;
|
|
475
|
+
pages?: WebInspectorListingPage[];
|
|
476
|
+
};
|
|
477
|
+
/**
|
|
478
|
+
* Discover a running iOS Simulator's `com.apple.webinspector` Unix domain
|
|
479
|
+
* socket path (no external binaries required).
|
|
480
|
+
*/
|
|
481
|
+
declare function findSimulatorWebInspectorSocket(udid?: string): string | null;
|
|
482
|
+
interface AppleWebInspectorClientOptions {
|
|
483
|
+
socketPath: string;
|
|
484
|
+
bundleId?: string;
|
|
485
|
+
timeoutMs?: number;
|
|
486
|
+
/** Injectable socket connector for unit tests */
|
|
487
|
+
connectSocket?: (socketPath: string) => Socket;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Direct Apple `webinspectord` Unix-socket client implementing the
|
|
491
|
+
* `_rpc_reportIdentifier:` → `_rpc_forwardSocketSetup:` → `_rpc_forwardSocketData:`
|
|
492
|
+
* JSON-RPC flow without `ios_webkit_debug_proxy` or Appium.
|
|
493
|
+
*/
|
|
494
|
+
declare class AppleWebInspectorClient {
|
|
495
|
+
private readonly socketPath;
|
|
496
|
+
private readonly bundleId?;
|
|
497
|
+
private readonly timeoutMs;
|
|
498
|
+
private readonly connectSocket;
|
|
499
|
+
private readonly connectionId;
|
|
500
|
+
private readonly senderKey;
|
|
501
|
+
private socket;
|
|
502
|
+
private readBuffer;
|
|
503
|
+
private connected;
|
|
504
|
+
private nextRpcId;
|
|
505
|
+
private pages;
|
|
506
|
+
private activePage;
|
|
507
|
+
private pendingRpc;
|
|
508
|
+
private listingWaiters;
|
|
509
|
+
constructor(options: AppleWebInspectorClientOptions);
|
|
510
|
+
isConnected(): boolean;
|
|
511
|
+
connect(): Promise<void>;
|
|
512
|
+
private handleFrame;
|
|
513
|
+
listPages(): Promise<WebInspectorListingPage[]>;
|
|
514
|
+
ensurePageAttached(): Promise<WebInspectorListingPage>;
|
|
515
|
+
sendInspectorCommand<T = any>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
516
|
+
disconnect(): Promise<void>;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
interface WsConnection {
|
|
520
|
+
readonly id: string;
|
|
521
|
+
readonly isOpen: boolean;
|
|
522
|
+
send(text: string): void;
|
|
523
|
+
close(code?: number): void;
|
|
524
|
+
onMessage(listener: (text: string) => void): void;
|
|
525
|
+
onClose(listener: () => void): void;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
interface SpanaBridgeServerOptions {
|
|
529
|
+
host?: string;
|
|
530
|
+
port?: number;
|
|
531
|
+
connectTimeoutMs?: number;
|
|
532
|
+
requestTimeoutMs?: number;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Runner-side WebSocket server that accepts connections from `spana-bridge`
|
|
536
|
+
* running inside the app under test (web, Capacitor iOS/Android, Electron,
|
|
537
|
+
* or Electrobun) and exposes the unified `DomChannel` interface.
|
|
538
|
+
*/
|
|
539
|
+
declare class SpanaBridgeChannel implements DomChannel {
|
|
540
|
+
readonly kind: "bridge";
|
|
541
|
+
private readonly host;
|
|
542
|
+
private readonly requestedPort;
|
|
543
|
+
private readonly connectTimeoutMs;
|
|
544
|
+
private readonly requestTimeoutMs;
|
|
545
|
+
private server;
|
|
546
|
+
private activeConn;
|
|
547
|
+
private nextId;
|
|
548
|
+
private pending;
|
|
549
|
+
private connectionWaiters;
|
|
550
|
+
private helloMeta;
|
|
551
|
+
constructor(options?: SpanaBridgeServerOptions);
|
|
552
|
+
get url(): string | null;
|
|
553
|
+
get port(): number | null;
|
|
554
|
+
get clientMetadata(): Record<string, unknown> | null;
|
|
555
|
+
isConnected(): boolean;
|
|
556
|
+
/** Start listening for an incoming `spana-bridge` WebSocket connection. */
|
|
557
|
+
start(): Promise<{
|
|
558
|
+
host: string;
|
|
559
|
+
port: number;
|
|
560
|
+
url: string;
|
|
561
|
+
}>;
|
|
562
|
+
/** Wait until a `spana-bridge` client connects (starting the server if needed). */
|
|
563
|
+
connect(): Promise<void>;
|
|
564
|
+
waitForClient(timeoutMs?: number): Promise<WsConnection>;
|
|
565
|
+
/** Wait for a brand-new bridge client connection (e.g. after a page navigation or reload). */
|
|
566
|
+
waitForNextClient(timeoutMs?: number): Promise<WsConnection>;
|
|
567
|
+
private handleMessage;
|
|
568
|
+
private rejectAllPending;
|
|
569
|
+
call<T = any>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
570
|
+
evaluate<T = unknown>(script: string | ((...args: any[]) => T), ...args: any[]): Promise<T>;
|
|
571
|
+
query(selector: Selector): Promise<DomElementMatch[]>;
|
|
572
|
+
tapDom(selector: Selector): Promise<boolean>;
|
|
573
|
+
scrollIntoView(selector: Selector): Promise<DomElementMatch | null>;
|
|
574
|
+
dispatch(selector: Selector, eventType: string, eventInit?: Record<string, unknown>): Promise<boolean>;
|
|
575
|
+
waitForIdle(opts?: DomIdleOptions): Promise<void>;
|
|
576
|
+
setStorage(entries: DomStorageEntries): Promise<void>;
|
|
577
|
+
clearStorage(opts?: DomClearStorageOptions): Promise<void>;
|
|
578
|
+
reload(): Promise<void>;
|
|
579
|
+
mockNetwork(matcher: BrowserRouteMatcher, response: BrowserMockResponse): Promise<void>;
|
|
580
|
+
blockNetwork(matcher: BrowserRouteMatcher): Promise<void>;
|
|
581
|
+
clearNetworkMocks(): Promise<void>;
|
|
582
|
+
getConsoleLogs(): Promise<BrowserConsoleLog[]>;
|
|
583
|
+
getJSErrors(): Promise<BrowserJSError[]>;
|
|
584
|
+
disconnect(): Promise<void>;
|
|
585
|
+
}
|
|
586
|
+
declare function createSpanaBridgeChannel(options?: SpanaBridgeServerOptions): SpanaBridgeChannel;
|
|
587
|
+
/**
|
|
588
|
+
* Composite channel that tries an ordered list of DOM channels (e.g. bridge
|
|
589
|
+
* first, then WebKit Inspector or Android WebView CDP).
|
|
590
|
+
*/
|
|
591
|
+
declare function createCompositeDomChannel(channels: DomChannel[]): DomChannel;
|
|
592
|
+
|
|
593
|
+
interface PlaywrightConfig {
|
|
594
|
+
browser?: BrowserName;
|
|
595
|
+
headless?: boolean;
|
|
596
|
+
baseUrl?: string;
|
|
597
|
+
storageState?: string;
|
|
598
|
+
verboseLogging?: boolean;
|
|
599
|
+
/** Optional pre-launched Browser instance shared across parallel BrowserContext workers. */
|
|
600
|
+
sharedBrowser?: Browser;
|
|
601
|
+
/** Optional browser channel (e.g. "chrome") or explicit executable path. */
|
|
602
|
+
channel?: string;
|
|
603
|
+
executablePath?: string;
|
|
604
|
+
/** Navigation wait condition for launchApp / openLink (e.g. "domcontentloaded" for prefetch-heavy SSR apps). */
|
|
605
|
+
waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
|
|
606
|
+
/** Record per-request HAR metadata over CDP/IPC. Disable when `artifacts.har` is off for faster page loads. Default: true. */
|
|
607
|
+
recordHar?: boolean;
|
|
608
|
+
/** Flashwright-inspired: speed up CSS transitions & animations to 0.001ms so actions never stall on transitions. */
|
|
609
|
+
instantAnimations?: boolean;
|
|
610
|
+
/** Flashwright-inspired: abort specified resource types (e.g. ["image", "font", "media"]) before hitting the network. */
|
|
611
|
+
blockResources?: Array<"image" | "font" | "media" | "stylesheet">;
|
|
612
|
+
/** Connect to an already-running warm Chromium CDP endpoint instead of launching a new browser process. */
|
|
613
|
+
cdpEndpoint?: string;
|
|
614
|
+
/** Reuse a persistent detached headless Chromium daemon across CLI runs (Flashwright-style warm session). */
|
|
615
|
+
warmBrowser?: boolean;
|
|
616
|
+
/** Attach a built-in zero-setup Playwright DOM channel for ~1ms `{ testID }` queries without full DOM dumps. Default: true. */
|
|
617
|
+
enableDomChannel?: boolean;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Connect to an existing warm headless Chromium daemon or start a detached one
|
|
621
|
+
* registered in Spana's warm daemon registry (`spana daemon status|stop`).
|
|
622
|
+
*/
|
|
623
|
+
declare function ensureWarmBrowserDaemon(config?: Pick<PlaywrightConfig, "executablePath" | "headless">): Promise<{
|
|
624
|
+
browser: Browser;
|
|
625
|
+
cdpUrl: string;
|
|
626
|
+
reused: boolean;
|
|
627
|
+
}>;
|
|
628
|
+
declare function connectPlaywrightOverCDP(cdpEndpoint: string): Promise<Browser>;
|
|
629
|
+
declare function launchPlaywrightBrowser(config?: Pick<PlaywrightConfig, "browser" | "headless" | "channel" | "executablePath">): Promise<Browser>;
|
|
630
|
+
|
|
631
|
+
interface PrelaunchedWebBrowser {
|
|
632
|
+
browserPromise: Promise<Browser>;
|
|
633
|
+
ownsBrowser: boolean;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Start launching (or connecting to a warm/CDP) Playwright browser immediately
|
|
637
|
+
* so browser boot overlaps with flow discovery and TypeScript imports.
|
|
638
|
+
*/
|
|
639
|
+
declare function speculativelyPrelaunchWebBrowser(config: ProvConfig): PrelaunchedWebBrowser | undefined;
|
|
640
|
+
|
|
641
|
+
interface LightweightCdpDriverOptions {
|
|
642
|
+
/**
|
|
643
|
+
* HTTP CDP endpoint (e.g. `"http://127.0.0.1:9222"` for Lightpanda or Chrome `--remote-debugging-port`)
|
|
644
|
+
* OR direct WebSocket debugger URL (`"ws://127.0.0.1:9222/devtools/page/..."`).
|
|
645
|
+
*/
|
|
646
|
+
cdpUrl: string;
|
|
647
|
+
/** Optional base URL used when `launchApp()` receives a relative path. */
|
|
648
|
+
baseUrl?: string;
|
|
649
|
+
/** Engine label reported in `getDeviceInfo()` (e.g. `"lightpanda"` or `"cdp"`). */
|
|
650
|
+
engineLabel?: string;
|
|
651
|
+
/** Optional viewport dimensions reported to coordinator (default: 1280×720). */
|
|
652
|
+
viewport?: {
|
|
653
|
+
width: number;
|
|
654
|
+
height: number;
|
|
655
|
+
};
|
|
656
|
+
/** Injectable fetch & WebSocket factory for tests. */
|
|
657
|
+
fetchFn?: typeof fetch;
|
|
658
|
+
createWebSocket?: WebSocketFactory;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Lightweight CDP-direct browser driver for **Lightpanda**, remote CDP grids,
|
|
662
|
+
* or headless Chrome `--remote-debugging-port` — zero Playwright client overhead!
|
|
663
|
+
*
|
|
664
|
+
* Attaches `CdpDomChannel` directly so `{ testID }` queries (including Shadow DOM
|
|
665
|
+
* & same-origin `<iframe>` piercing) resolve in ~1 ms without full DOM dumps.
|
|
666
|
+
*/
|
|
667
|
+
declare function makeLightweightCdpDriver(options: LightweightCdpDriverOptions): Effect.Effect<RawDriverService, DriverError>;
|
|
668
|
+
|
|
669
|
+
/** Order flows descending by known duration (longest first) while preserving order on ties. */
|
|
670
|
+
declare function orderFlowsLongestFirst(flows: FlowDefinition[], durationHintsMs?: Record<string, number>): FlowDefinition[];
|
|
671
|
+
|
|
672
|
+
interface ElectronDriverOptions {
|
|
673
|
+
/** Path to Electron main entry file or app directory (passed to `_electron.launch`) */
|
|
674
|
+
entry?: string;
|
|
675
|
+
/** Path to packaged Electron executable */
|
|
676
|
+
executablePath?: string;
|
|
677
|
+
/** Extra CLI args passed to Electron */
|
|
678
|
+
args?: string[];
|
|
679
|
+
cwd?: string;
|
|
680
|
+
env?: Record<string, string>;
|
|
681
|
+
/** Attach to an already running Electron app over CDP instead of launching */
|
|
682
|
+
cdpUrl?: string;
|
|
683
|
+
/** Remote debugging port (when attaching over CDP or launching with debugging enabled) */
|
|
684
|
+
cdpPort?: number;
|
|
685
|
+
/** Optional initial URL to load inside the first Electron window */
|
|
686
|
+
url?: string;
|
|
687
|
+
/** Optional spana-bridge DOM channel */
|
|
688
|
+
domChannel?: DomChannel;
|
|
689
|
+
/** Injectable launchers for unit testing */
|
|
690
|
+
launchElectron?: typeof _electron.launch;
|
|
691
|
+
connectOverCDP?: typeof chromium.connectOverCDP;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Create a Spana driver for Electron apps.
|
|
695
|
+
*
|
|
696
|
+
* Uses Playwright's `_electron.launch()` by default (zero extra setup), or
|
|
697
|
+
* connects via CDP (`chromium.connectOverCDP`) when `cdpUrl` / `cdpPort` is
|
|
698
|
+
* specified. Reuses the running Electron process across flows and resets
|
|
699
|
+
* storage cleanly between runs.
|
|
700
|
+
*/
|
|
701
|
+
declare function makeElectronDriver(options: ElectronDriverOptions): Effect.Effect<RawDriverService, DriverError>;
|
|
702
|
+
|
|
703
|
+
interface ElectrobunLaunchPlan {
|
|
704
|
+
renderer: ElectrobunRenderer;
|
|
705
|
+
engine: TargetEngine;
|
|
706
|
+
hostOs: HostOS;
|
|
707
|
+
preferredChannels: TargetChannel[];
|
|
708
|
+
env: Record<string, string>;
|
|
709
|
+
args: string[];
|
|
710
|
+
cdpUrl?: string;
|
|
711
|
+
webkitInspectorUrl?: string;
|
|
712
|
+
notes: string;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Resolve the exact Electrobun engine flags & environment variables for each
|
|
716
|
+
* OS and renderer combination:
|
|
717
|
+
*
|
|
718
|
+
* - Bundled CEF (`renderer: "cef"`):
|
|
719
|
+
* Passes `--remote-debugging-port=<port>` + `ELECTROBUN_CDP_PORT=<port>`.
|
|
720
|
+
* In packaged builds, also configure `build.<os>.chromiumFlags["remote-debugging-port"]`
|
|
721
|
+
* in `electrobun.config.ts`.
|
|
722
|
+
* - Windows native (`WebView2`):
|
|
723
|
+
* Sets `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS="--remote-debugging-port=<port>"`
|
|
724
|
+
* and `ELECTROBUN_CDP_PORT=<port>`, then attaches via CDP.
|
|
725
|
+
* - macOS native (`WKWebView`):
|
|
726
|
+
* Uses `spana-bridge` (preferred) or WebKit Remote Inspector (`webkitInspectorPort`).
|
|
727
|
+
* - Linux native (`WebKitGTK`):
|
|
728
|
+
* Sets `WEBKIT_INSPECTOR_SERVER=127.0.0.1:<port>` and attaches via `spana-bridge`
|
|
729
|
+
* or WebKit Inspector / WebKitWebDriver.
|
|
730
|
+
*/
|
|
731
|
+
declare function resolveElectrobunLaunchPlan(config: ElectrobunAppConfig, hostOs?: HostOS): ElectrobunLaunchPlan;
|
|
732
|
+
interface ElectrobunDriverOptions extends ElectrobunAppConfig {
|
|
733
|
+
/** Optional spana-bridge DOM channel (recommended for cross-OS consistency on Electrobun) */
|
|
734
|
+
domChannel?: DomChannel;
|
|
735
|
+
hostOs?: HostOS;
|
|
736
|
+
/** Optional custom spawner for testing */
|
|
737
|
+
spawnProcess?: typeof spawn;
|
|
738
|
+
/** Skip spawning executable (e.g. attach-only mode) */
|
|
739
|
+
attachOnly?: boolean;
|
|
740
|
+
}
|
|
741
|
+
declare function makeElectrobunDriver(options: ElectrobunDriverOptions): Effect.Effect<RawDriverService, DriverError>;
|
|
742
|
+
|
|
743
|
+
type WarmDaemonKind = "wda" | "uiautomator2" | "iproxy" | "chromium";
|
|
744
|
+
interface WarmDaemonRecord {
|
|
745
|
+
kind: WarmDaemonKind;
|
|
746
|
+
deviceId: string;
|
|
747
|
+
host: string;
|
|
748
|
+
port: number;
|
|
749
|
+
pid?: number;
|
|
750
|
+
tunnelPid?: number;
|
|
751
|
+
xctestrunPath?: string;
|
|
752
|
+
/** Optional reusable WDA/UiAutomator2 session ID persisted across runs */
|
|
753
|
+
sessionId?: string;
|
|
754
|
+
bundleId?: string;
|
|
755
|
+
startedAt: string;
|
|
756
|
+
}
|
|
757
|
+
/** Persist a warm WDA/UiAutomator2 session ID on an existing daemon record for cross-run reuse. */
|
|
758
|
+
declare function updateWarmDaemonSession(kind: WarmDaemonKind, deviceId: string, sessionId: string, bundleId?: string, stateFile?: string): void;
|
|
759
|
+
declare function listWarmDaemons(stateFile?: string): WarmDaemonRecord[];
|
|
760
|
+
/**
|
|
761
|
+
* Probe whether a recorded warm WDA / UiAutomator2 daemon is still healthy on
|
|
762
|
+
* `GET http://<host>:<port>/status`. Removes stale records automatically.
|
|
763
|
+
*/
|
|
764
|
+
declare function getHealthyWarmDaemon(kind: WarmDaemonKind, deviceId: string, options?: {
|
|
765
|
+
stateFile?: string;
|
|
766
|
+
fetchFn?: typeof fetch;
|
|
767
|
+
timeoutMs?: number;
|
|
768
|
+
/** HTTP health endpoint path (default: "/status", use "/json/version" for chromium). */
|
|
769
|
+
statusPath?: string;
|
|
770
|
+
}): Promise<WarmDaemonRecord | null>;
|
|
771
|
+
/**
|
|
772
|
+
* Stop only the specific process PIDs started by Spana for this daemon record.
|
|
773
|
+
*/
|
|
774
|
+
declare function stopWarmDaemon(kind: WarmDaemonKind, deviceId: string, stateFile?: string): boolean;
|
|
775
|
+
declare function stopAllWarmDaemons(stateFile?: string): number;
|
|
776
|
+
|
|
152
777
|
interface ProviderRunResult {
|
|
153
778
|
passed: boolean;
|
|
154
779
|
name?: string;
|
|
@@ -165,4 +790,502 @@ interface CloudProvider {
|
|
|
165
790
|
reportResult(appiumUrl: string, meta: Record<string, string>, result: ProviderRunResult): Promise<void>;
|
|
166
791
|
}
|
|
167
792
|
|
|
168
|
-
|
|
793
|
+
interface GitHubPrReporterOptions {
|
|
794
|
+
/** Directory where `github-pr-summary.md` is written (default: `./spana-output`). */
|
|
795
|
+
outputDir?: string;
|
|
796
|
+
/** Optional filter summary lines (from `--changed-since` filters) to include in the comment. */
|
|
797
|
+
filterSummaries?: string[];
|
|
798
|
+
/** Write to `process.env.GITHUB_STEP_SUMMARY` automatically when present (default: true). */
|
|
799
|
+
writeStepSummary?: boolean;
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Format a concise Markdown summary suitable for GitHub Actions Job Summaries
|
|
803
|
+
* and Pull Request comments (inspired by `@e2e-dev/github`).
|
|
804
|
+
*/
|
|
805
|
+
declare function formatGitHubPrMarkdown(summary: RunSummary, filterSummaries?: string[]): string;
|
|
806
|
+
/**
|
|
807
|
+
* Built-in `"github"` reporter: writes `github-pr-summary.md` to the artifact
|
|
808
|
+
* output directory and appends to `$GITHUB_STEP_SUMMARY` in GitHub Actions.
|
|
809
|
+
*/
|
|
810
|
+
declare function createGitHubPrReporter(options?: GitHubPrReporterOptions): Reporter;
|
|
811
|
+
|
|
812
|
+
/** A file changed between `baseRef` and `HEAD` (or working tree). */
|
|
813
|
+
interface ChangedFile {
|
|
814
|
+
path: string;
|
|
815
|
+
status: "A" | "M" | "D" | "R" | "C" | string;
|
|
816
|
+
}
|
|
817
|
+
/** Git diff snapshot provided to test filters when `--changed-since <ref>` is active. */
|
|
818
|
+
interface GitChanges {
|
|
819
|
+
baseRef: string;
|
|
820
|
+
mergeBase?: string;
|
|
821
|
+
files: string[];
|
|
822
|
+
entries: ChangedFile[];
|
|
823
|
+
/** Unified diff text (truncated when exceeding `maxDiffBytes`). */
|
|
824
|
+
diff: string;
|
|
825
|
+
/** Full byte length of the raw diff before truncation. */
|
|
826
|
+
diffBytes: number;
|
|
827
|
+
/** True when the diff exceeded the configured safety cap. */
|
|
828
|
+
truncated: boolean;
|
|
829
|
+
}
|
|
830
|
+
/** Descriptor for a candidate flow passed into a `TestFilter`. */
|
|
831
|
+
interface FilterCandidate {
|
|
832
|
+
id: string;
|
|
833
|
+
name: string;
|
|
834
|
+
file: string;
|
|
835
|
+
tags: string[];
|
|
836
|
+
platforms?: Platform[];
|
|
837
|
+
source?: string;
|
|
838
|
+
}
|
|
839
|
+
/** Context supplied to every `TestFilter.filter()` invocation. */
|
|
840
|
+
interface FilterContext {
|
|
841
|
+
cwd: string;
|
|
842
|
+
changes: GitChanges;
|
|
843
|
+
configPath?: string;
|
|
844
|
+
platforms: Platform[];
|
|
845
|
+
}
|
|
846
|
+
interface FilterUsage {
|
|
847
|
+
calls?: number;
|
|
848
|
+
tokens?: number;
|
|
849
|
+
costUsd?: number;
|
|
850
|
+
}
|
|
851
|
+
interface FilterDecisionOutput {
|
|
852
|
+
/** Map of candidate `id` -> human-readable skip reason. Any ID not present is kept. */
|
|
853
|
+
exclude: Record<string, string>;
|
|
854
|
+
/** Optional summary note displayed next to the filter output. */
|
|
855
|
+
note?: string;
|
|
856
|
+
/** Optional model/API usage metrics for summary logging. */
|
|
857
|
+
usage?: FilterUsage;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Pluggable CI test filter inspired by `e2e-inc/e2e`'s Filters API.
|
|
861
|
+
* Compose deterministic path/tag rules or plug in a decision model / LLM.
|
|
862
|
+
*/
|
|
863
|
+
interface TestFilter {
|
|
864
|
+
name: string;
|
|
865
|
+
filter(flows: FilterCandidate[], context: FilterContext): Promise<FilterDecisionOutput> | FilterDecisionOutput;
|
|
866
|
+
}
|
|
867
|
+
interface AppliedFilterReport {
|
|
868
|
+
filterName: string;
|
|
869
|
+
total: number;
|
|
870
|
+
kept: number;
|
|
871
|
+
excluded: number;
|
|
872
|
+
note?: string;
|
|
873
|
+
usage?: FilterUsage;
|
|
874
|
+
failedOpen?: boolean;
|
|
875
|
+
}
|
|
876
|
+
interface ApplyFiltersResult<T> {
|
|
877
|
+
kept: T[];
|
|
878
|
+
excluded: Array<{
|
|
879
|
+
item: T;
|
|
880
|
+
candidate: FilterCandidate;
|
|
881
|
+
filterName: string;
|
|
882
|
+
reason: string;
|
|
883
|
+
}>;
|
|
884
|
+
reports: AppliedFilterReport[];
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Collect changed files and unified diff relative to `baseRef` using `git merge-base`.
|
|
888
|
+
* Fails cleanly if git is unavailable or `baseRef` does not exist (shallow checkout).
|
|
889
|
+
*/
|
|
890
|
+
declare function collectGitChanges(baseRef: string, cwd?: string, maxDiffBytes?: number, runGit?: (args: string[], workdir: string) => string): GitChanges;
|
|
891
|
+
/** Build filter candidates from loaded Spana flows (including source file content when readable). */
|
|
892
|
+
declare function buildFilterCandidates(loaded: Array<{
|
|
893
|
+
sourcePath: string;
|
|
894
|
+
flow: FlowDefinition;
|
|
895
|
+
}>, cwd?: string): FilterCandidate[];
|
|
896
|
+
interface DecisionJudgeInput {
|
|
897
|
+
candidate: FilterCandidate;
|
|
898
|
+
changes: GitChanges;
|
|
899
|
+
}
|
|
900
|
+
interface DecisionJudgeResult {
|
|
901
|
+
/** Probability [0..1] that the PR changes can affect this flow. */
|
|
902
|
+
probability: number;
|
|
903
|
+
reason?: string;
|
|
904
|
+
usage?: FilterUsage;
|
|
905
|
+
}
|
|
906
|
+
type DecisionModelJudge = (input: DecisionJudgeInput) => Promise<DecisionJudgeResult> | DecisionJudgeResult;
|
|
907
|
+
interface DecisionBatchJudgeResult {
|
|
908
|
+
/** Map of candidate `id` -> probability `[0, 1]` that the PR changes affect it. */
|
|
909
|
+
probabilities: Record<string, number>;
|
|
910
|
+
reasons?: Record<string, string>;
|
|
911
|
+
usage?: FilterUsage;
|
|
912
|
+
}
|
|
913
|
+
type DecisionBatchJudge = (input: {
|
|
914
|
+
candidates: FilterCandidate[];
|
|
915
|
+
changes: GitChanges;
|
|
916
|
+
}) => Promise<DecisionBatchJudgeResult> | DecisionBatchJudgeResult;
|
|
917
|
+
interface DecisionFilterOptions {
|
|
918
|
+
/** Optional custom name (default: "decision") */
|
|
919
|
+
name?: string;
|
|
920
|
+
/**
|
|
921
|
+
* Per-flow model judge function returning an impact probability in `[0, 1]`.
|
|
922
|
+
* Provide either `judge` or `batchJudge` (batched evaluates all flows in 1 LLM call).
|
|
923
|
+
*/
|
|
924
|
+
judge?: DecisionModelJudge;
|
|
925
|
+
/**
|
|
926
|
+
* Batched model judge evaluating all candidate flows in a single model call
|
|
927
|
+
* (dramatically faster for local Ollama/MLX models and cloud decision models).
|
|
928
|
+
*/
|
|
929
|
+
batchJudge?: DecisionBatchJudge;
|
|
930
|
+
/**
|
|
931
|
+
* Skip a flow only when `probability < threshold`.
|
|
932
|
+
* Default: `0.20` (fail-open safety bias — runs anything >= 20% likely affected).
|
|
933
|
+
*/
|
|
934
|
+
threshold?: number;
|
|
935
|
+
/** Max diff size in bytes before failing open and running everything. Default: 60 kB. */
|
|
936
|
+
maxDiffBytes?: number;
|
|
937
|
+
/** Max single flow file size in bytes before failing open for that flow. Default: 32 kB. */
|
|
938
|
+
maxFileBytes?: number;
|
|
939
|
+
/** Tags that are NEVER excluded (e.g. `["smoke"]`). */
|
|
940
|
+
alwaysRunTags?: string[];
|
|
941
|
+
/** Path prefixes that force the entire suite to run (e.g. `["infra/", "db/migrations/"]`). */
|
|
942
|
+
runAllOnPaths?: string[];
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Create a fail-open decision-model filter for `--changed-since`:
|
|
946
|
+
*
|
|
947
|
+
* Safety invariants (never skip important tests):
|
|
948
|
+
* 1. Changed flow files always run.
|
|
949
|
+
* 2. Config or lockfile changes run the entire suite.
|
|
950
|
+
* 3. Diffs over `maxDiffBytes` (default 60 kB) run the entire suite.
|
|
951
|
+
* 4. Flows tagged in `alwaysRunTags` always run.
|
|
952
|
+
* 5. Any judge error or invalid probability fails open (flow runs).
|
|
953
|
+
* 6. A flow is excluded only when `probability < threshold` (default 0.20).
|
|
954
|
+
*/
|
|
955
|
+
declare function decisionFilter(options: DecisionFilterOptions): TestFilter;
|
|
956
|
+
interface OllamaDecisionJudgeOptions {
|
|
957
|
+
/** Ollama model tag, e.g. `"qwen2.5:1.5b"` or `"qwen2.5:0.5b"`. */
|
|
958
|
+
model: string;
|
|
959
|
+
/** Ollama HTTP endpoint (default: `"http://127.0.0.1:11434"`). */
|
|
960
|
+
baseUrl?: string;
|
|
961
|
+
/** Request timeout in ms (default: 15000). */
|
|
962
|
+
timeoutMs?: number;
|
|
963
|
+
/** Optional custom fetch implementation for testing. */
|
|
964
|
+
fetchFn?: typeof fetch;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Built-in local batched decision judge for Ollama (Apple Silicon / local GPU).
|
|
968
|
+
* Evaluates all candidate flows against a PR diff in ONE structured JSON call
|
|
969
|
+
* with `temperature: 0` and zero cloud token cost ($0.0000).
|
|
970
|
+
*/
|
|
971
|
+
declare function createOllamaDecisionJudge(options: OllamaDecisionJudgeOptions): DecisionBatchJudge;
|
|
972
|
+
interface LogprobDecisionJudgeOptions {
|
|
973
|
+
/** Model identifier (e.g. `"hf.co/apus-ailab/APUS-OpenJev-v1-9B-GGUF:Q8_0"`, `"jevk5-4b-v0.3:q8_0"`, `"decider4b-v2:bf16"`, `"plumb-4b"`). */
|
|
974
|
+
model: string;
|
|
975
|
+
/** Protocol backend: `"openai"` (vLLM / SGLang / llama-server / OpenRouter / Typesafe AI) or `"ollama"`. */
|
|
976
|
+
provider: "openai" | "ollama";
|
|
977
|
+
/** Base URL (default: `http://127.0.0.1:8000/v1` for openai, `http://127.0.0.1:11434` for ollama). */
|
|
978
|
+
baseUrl?: string;
|
|
979
|
+
/** Optional Bearer API key for hosted OpenAI-compatible endpoints. */
|
|
980
|
+
apiKey?: string;
|
|
981
|
+
/** Request timeout per flow judgment in ms (default: 15000). */
|
|
982
|
+
timeoutMs?: number;
|
|
983
|
+
/** Injectable fetch for unit tests. */
|
|
984
|
+
fetchFn?: typeof fetch;
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Compute calibrated binary YES probability from OpenAI-style `top_logprobs`
|
|
988
|
+
* on a 1-token decision model response (`max_tokens: 1`, `logprobs: true`).
|
|
989
|
+
* Returns `null` when neither YES nor NO tokens appeared in top_logprobs.
|
|
990
|
+
*/
|
|
991
|
+
declare function probabilityFromTopLogprobs(topLogprobs: Array<{
|
|
992
|
+
token: string;
|
|
993
|
+
logprob: number;
|
|
994
|
+
}>): number | null;
|
|
995
|
+
/**
|
|
996
|
+
* Native 1-Token Logprob Decision Judge for System-1 decision models
|
|
997
|
+
* (OpenJev, JevK5, Decider-4B, Plumb-4B, Winnow-12B, Typesafe AI Jev).
|
|
998
|
+
*
|
|
999
|
+
* Places the shared git diff prefix at the start of every prompt so vLLM,
|
|
1000
|
+
* SGLang, and llama.cpp automatically reuse the KV cache across all flows in a PR,
|
|
1001
|
+
* generating only **1 single token** (`YES` / `NO`) with exact calibrated probabilities.
|
|
1002
|
+
*/
|
|
1003
|
+
declare function createLogprobDecisionJudge(options: LogprobDecisionJudgeOptions): DecisionModelJudge;
|
|
1004
|
+
interface PathRule {
|
|
1005
|
+
/** Flow tag or path prefix this rule owns. */
|
|
1006
|
+
matchFlow: {
|
|
1007
|
+
tag?: string;
|
|
1008
|
+
filePrefix?: string;
|
|
1009
|
+
};
|
|
1010
|
+
/** Source path prefixes that can affect matching flows. */
|
|
1011
|
+
watchPaths: string[];
|
|
1012
|
+
}
|
|
1013
|
+
interface PathRuleFilterOptions {
|
|
1014
|
+
name?: string;
|
|
1015
|
+
rules: PathRule[];
|
|
1016
|
+
alwaysRunTags?: string[];
|
|
1017
|
+
runAllOnPaths?: string[];
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* 100% deterministic zero-LLM filter mapping repo path prefixes to flow tags/files.
|
|
1021
|
+
* Flows not matched by any rule fail open and run automatically.
|
|
1022
|
+
*/
|
|
1023
|
+
declare function pathRuleFilter(options: PathRuleFilterOptions): TestFilter;
|
|
1024
|
+
/**
|
|
1025
|
+
* Run a chain of `TestFilter`s sequentially over candidate flows.
|
|
1026
|
+
* Any filter that throws fails open (keeps all remaining flows) and logs a note.
|
|
1027
|
+
*/
|
|
1028
|
+
declare function applyTestFilters<T>(items: T[], candidates: FilterCandidate[], filters: TestFilter[], context: FilterContext): Promise<ApplyFiltersResult<T>>;
|
|
1029
|
+
/** Format a concise, `e2e`-style CI summary line for each applied filter. */
|
|
1030
|
+
declare function formatFilterSummary(reports: AppliedFilterReport[]): string[];
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Declarative named setup state (e.g. `"admin"`, `"authenticated"`, `"seeded-cart"`).
|
|
1034
|
+
* Automatically uses `spana-bridge` storage injection on mobile/desktop/bridge-web
|
|
1035
|
+
* and Playwright `loadAuthState` / `evaluate` on web.
|
|
1036
|
+
*/
|
|
1037
|
+
interface NamedSetupDefinition<T extends string = string, R extends string = string> {
|
|
1038
|
+
name: string;
|
|
1039
|
+
/** Clear storage before restoring state (default: true). */
|
|
1040
|
+
clearBefore?: boolean | DomClearStorageOptions;
|
|
1041
|
+
/** Storage entries injected via `app.setStorage(...)` (localStorage/sessionStorage/cookies/Preferences). */
|
|
1042
|
+
storage?: DomStorageEntries;
|
|
1043
|
+
/** Optional Playwright storageState JSON file path for web runs. */
|
|
1044
|
+
storageStatePath?: string;
|
|
1045
|
+
/** Optional URL/route to navigate to after injecting state (or `reload` when omitted and storage was injected). */
|
|
1046
|
+
navigateTo?: R;
|
|
1047
|
+
/** Whether to reload the WebView/page after injecting storage when `navigateTo` is omitted (default: true). */
|
|
1048
|
+
reloadAfterStorage?: boolean;
|
|
1049
|
+
/** Optional custom setup hook for seeding API state or performing extra actions. */
|
|
1050
|
+
run?: (ctx: FlowContext<T, R>) => Promise<void>;
|
|
1051
|
+
}
|
|
1052
|
+
/** Define a reusable named setup state for `{ session: "<name>" }` flows. */
|
|
1053
|
+
declare function defineSetup<T extends string = string, R extends string = string>(name: string, config: Omit<NamedSetupDefinition<T, R>, "name">): NamedSetupDefinition<T, R>;
|
|
1054
|
+
/** Apply a named setup state to the active `FlowContext`. */
|
|
1055
|
+
declare function applyNamedSetup<T extends string = string, R extends string = string>(setup: NamedSetupDefinition<T, R>, ctx: FlowContext<T, R>): Promise<void>;
|
|
1056
|
+
type FixtureFn<Value, Deps extends Record<string, unknown>, T extends string = string, R extends string = string> = (ctx: FlowContext<T, R> & Deps, use: (value: Value) => Promise<void>) => Promise<void>;
|
|
1057
|
+
type FixtureDefinition<Value, Deps extends Record<string, unknown>, T extends string = string, R extends string = string> = FixtureFn<Value, Deps, T, R> | {
|
|
1058
|
+
setup: FixtureFn<Value, Deps, T, R>;
|
|
1059
|
+
/** When true, always runs for every flow even if not destructured. */
|
|
1060
|
+
auto?: boolean;
|
|
1061
|
+
/** Explicit fixture dependency names (optional — also inferred from parameter destructuring). */
|
|
1062
|
+
deps?: Array<keyof Deps & string>;
|
|
1063
|
+
};
|
|
1064
|
+
type FixtureMap<Fixtures extends Record<string, unknown>, T extends string = string, R extends string = string> = {
|
|
1065
|
+
[K in keyof Fixtures]: FixtureDefinition<Fixtures[K], Omit<Fixtures, K>, T, R>;
|
|
1066
|
+
};
|
|
1067
|
+
interface ExtendedFlowConfig<R extends string = string, SessionName extends string = string> extends FlowConfig<R> {
|
|
1068
|
+
/** Optional named setup state applied before any lazy fixtures run. */
|
|
1069
|
+
session?: SessionName;
|
|
1070
|
+
/** Optional explicit fixture names to activate (in addition to destructured params). */
|
|
1071
|
+
uses?: string[];
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Extract top-level destructured parameter names from the first argument of a function:
|
|
1075
|
+
* `async ({ app, project, task: t }) => ...` -> `["app", "project", "task"]`
|
|
1076
|
+
*/
|
|
1077
|
+
declare function extractDestructuredParamNames(fn: (...args: any[]) => unknown): string[];
|
|
1078
|
+
interface CreateFixturesOptions<Fixtures extends Record<string, unknown>, SessionName extends string = string, T extends string = string, R extends string = string> {
|
|
1079
|
+
fixtures?: FixtureMap<Fixtures, T, R>;
|
|
1080
|
+
setups?: Record<SessionName, NamedSetupDefinition<T, R>>;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Create a `flow()` builder enhanced with lazy composable fixtures and named
|
|
1084
|
+
* setup states (`{ session: "admin" }`), inspired by Playwright and `e2e`.
|
|
1085
|
+
*
|
|
1086
|
+
* - Fixtures only run when destructured by the flow (or marked `{ auto: true }`).
|
|
1087
|
+
* - Fixtures can depend on other fixtures; cycles are detected immediately.
|
|
1088
|
+
* - Teardown runs in strict reverse (LIFO) order even when the flow throws.
|
|
1089
|
+
*/
|
|
1090
|
+
declare function createFlowWithFixtures<Fixtures extends Record<string, unknown> = Record<string, never>, SessionName extends string = string, T extends string = string, R extends string = string>(options: CreateFixturesOptions<Fixtures, SessionName, T, R>): {
|
|
1091
|
+
(name: string, fn: (ctx: FlowContext<T, R> & Fixtures) => Promise<void>): FlowDefinition<T, R>;
|
|
1092
|
+
(name: string, config: ExtendedFlowConfig<R, SessionName>, fn: (ctx: FlowContext<T, R> & Fixtures) => Promise<void>): FlowDefinition<T, R>;
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
/** A deterministic action recorded from an `agent.act(goal)` execution. */
|
|
1096
|
+
type RecordedAction = {
|
|
1097
|
+
kind: "tap";
|
|
1098
|
+
selector: ExtendedSelector;
|
|
1099
|
+
} | {
|
|
1100
|
+
kind: "doubleTap";
|
|
1101
|
+
selector: ExtendedSelector;
|
|
1102
|
+
} | {
|
|
1103
|
+
kind: "longPress";
|
|
1104
|
+
selector: ExtendedSelector;
|
|
1105
|
+
} | {
|
|
1106
|
+
kind: "inputText";
|
|
1107
|
+
text: string;
|
|
1108
|
+
} | {
|
|
1109
|
+
kind: "pressKey";
|
|
1110
|
+
key: string;
|
|
1111
|
+
} | {
|
|
1112
|
+
kind: "scroll";
|
|
1113
|
+
direction: "up" | "down" | "left" | "right";
|
|
1114
|
+
} | {
|
|
1115
|
+
kind: "scrollUntilVisible";
|
|
1116
|
+
selector: ExtendedSelector;
|
|
1117
|
+
} | {
|
|
1118
|
+
kind: "openLink";
|
|
1119
|
+
url: string;
|
|
1120
|
+
};
|
|
1121
|
+
interface ReplayCacheEntry {
|
|
1122
|
+
schemaVersion: 1;
|
|
1123
|
+
key: string;
|
|
1124
|
+
goal: string;
|
|
1125
|
+
flowName: string;
|
|
1126
|
+
platform: string;
|
|
1127
|
+
actions: RecordedAction[];
|
|
1128
|
+
recordedAt: string;
|
|
1129
|
+
verifiedBy: string;
|
|
1130
|
+
}
|
|
1131
|
+
type ReplayCacheMode = "read-write" | "strict" | "off";
|
|
1132
|
+
type CacheWriteStatus = "saved" | "kept" | "unconfirmed" | "evicted" | "skipped";
|
|
1133
|
+
interface ReplayStepOutcome {
|
|
1134
|
+
goal: string;
|
|
1135
|
+
key: string;
|
|
1136
|
+
status: "replayed" | "handed-off" | "missed" | "live";
|
|
1137
|
+
writeStatus?: CacheWriteStatus;
|
|
1138
|
+
actionCount: number;
|
|
1139
|
+
error?: string;
|
|
1140
|
+
}
|
|
1141
|
+
interface ReplayCacheSummary {
|
|
1142
|
+
replayed: number;
|
|
1143
|
+
handedOff: number;
|
|
1144
|
+
missed: number;
|
|
1145
|
+
saved: number;
|
|
1146
|
+
evicted: number;
|
|
1147
|
+
unconfirmed: number;
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Pluggable agent executor called ONLY on cache miss or self-healing handoff.
|
|
1151
|
+
* Returns the deterministic list of actions it executed to achieve `goal`.
|
|
1152
|
+
*/
|
|
1153
|
+
interface AgentActExecutor {
|
|
1154
|
+
act(input: {
|
|
1155
|
+
goal: string;
|
|
1156
|
+
app: PromiseApp;
|
|
1157
|
+
handoffReason?: string;
|
|
1158
|
+
}): Promise<{
|
|
1159
|
+
actions: RecordedAction[];
|
|
1160
|
+
}>;
|
|
1161
|
+
}
|
|
1162
|
+
/** Compute a stable cache key for a `(flowName, platform, goal)` tuple. */
|
|
1163
|
+
declare function buildReplayCacheKey(flowName: string, platform: string, goal: string): string;
|
|
1164
|
+
/** Disk-backed replay cache store (default directory: `.spana/cache`). */
|
|
1165
|
+
declare class ReplayCacheStore {
|
|
1166
|
+
readonly cacheDir: string;
|
|
1167
|
+
constructor(cacheDir?: string);
|
|
1168
|
+
private filePath;
|
|
1169
|
+
get(key: string): ReplayCacheEntry | null;
|
|
1170
|
+
set(entry: ReplayCacheEntry): void;
|
|
1171
|
+
delete(key: string): boolean;
|
|
1172
|
+
}
|
|
1173
|
+
/** Execute a single recorded deterministic action against `PromiseApp`. */
|
|
1174
|
+
declare function replayRecordedAction(app: PromiseApp, action: RecordedAction): Promise<void>;
|
|
1175
|
+
interface ReplaySessionOptions {
|
|
1176
|
+
flowName: string;
|
|
1177
|
+
platform: string;
|
|
1178
|
+
app: PromiseApp;
|
|
1179
|
+
store?: ReplayCacheStore;
|
|
1180
|
+
mode?: ReplayCacheMode;
|
|
1181
|
+
executor?: AgentActExecutor;
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Verified Replay Cache session inspired by `e2e-inc/e2e`:
|
|
1185
|
+
*
|
|
1186
|
+
* - On cache hit: replays deterministic `{ testID }` / `systemUI()` actions with ZERO LLM calls.
|
|
1187
|
+
* - In `strict` mode (`--strict-cache`): fails deterministically if a recording is missing or no longer matches.
|
|
1188
|
+
* - In `read-write` mode: hands off to `executor` on miss or mismatch (self-healing), and ONLY commits
|
|
1189
|
+
* new/healed recordings to `.spana/cache/` after `markVerified(verifierName)` is called by a real assertion!
|
|
1190
|
+
*/
|
|
1191
|
+
declare class ReplaySession {
|
|
1192
|
+
private readonly flowName;
|
|
1193
|
+
private readonly platform;
|
|
1194
|
+
private readonly app;
|
|
1195
|
+
private readonly store;
|
|
1196
|
+
private readonly mode;
|
|
1197
|
+
private readonly executor?;
|
|
1198
|
+
private pendingWrites;
|
|
1199
|
+
private replayedKeys;
|
|
1200
|
+
private outcomes;
|
|
1201
|
+
constructor(options: ReplaySessionOptions);
|
|
1202
|
+
/** Execute a natural-language goal using replay cache first, falling back to `executor`. */
|
|
1203
|
+
act(goal: string): Promise<ReplayStepOutcome>;
|
|
1204
|
+
private runLiveAndQueue;
|
|
1205
|
+
/**
|
|
1206
|
+
* Call when a real post-action assertion (`expect(...).toBeVisible()`, `toHaveText()`, etc.)
|
|
1207
|
+
* succeeds. Flushes all preceding pending recordings to disk in `read-write` mode.
|
|
1208
|
+
*/
|
|
1209
|
+
markVerified(verifierName: string): number;
|
|
1210
|
+
/**
|
|
1211
|
+
* Call when the flow attempt fails: evicts any replayed recordings involved in the
|
|
1212
|
+
* failure (in `read-write` mode) and discards unconfirmed recordings so broken paths
|
|
1213
|
+
* are never persisted.
|
|
1214
|
+
*/
|
|
1215
|
+
markFailed(): number;
|
|
1216
|
+
getOutcomes(): ReplayStepOutcome[];
|
|
1217
|
+
getSummary(): ReplayCacheSummary;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
/** MCP Tool definition advertised by `tools/list`. */
|
|
1221
|
+
interface McpToolDefinition {
|
|
1222
|
+
name: string;
|
|
1223
|
+
description: string;
|
|
1224
|
+
inputSchema: {
|
|
1225
|
+
type: "object";
|
|
1226
|
+
properties: Record<string, unknown>;
|
|
1227
|
+
required?: string[];
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
interface McpContentBlock {
|
|
1231
|
+
type: "text" | "image";
|
|
1232
|
+
text?: string;
|
|
1233
|
+
data?: string;
|
|
1234
|
+
mimeType?: string;
|
|
1235
|
+
}
|
|
1236
|
+
interface McpToolResult {
|
|
1237
|
+
content: McpContentBlock[];
|
|
1238
|
+
isError?: boolean;
|
|
1239
|
+
}
|
|
1240
|
+
interface JsonRpcRequest {
|
|
1241
|
+
jsonrpc: "2.0";
|
|
1242
|
+
id?: string | number | null;
|
|
1243
|
+
method: string;
|
|
1244
|
+
params?: Record<string, unknown>;
|
|
1245
|
+
}
|
|
1246
|
+
interface JsonRpcResponse {
|
|
1247
|
+
jsonrpc: "2.0";
|
|
1248
|
+
id: string | number | null;
|
|
1249
|
+
result?: unknown;
|
|
1250
|
+
error?: {
|
|
1251
|
+
code: number;
|
|
1252
|
+
message: string;
|
|
1253
|
+
data?: unknown;
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
interface SpanaMcpServerOptions {
|
|
1257
|
+
/** Custom session connector (defaults to `connect()` from `agent/session.js`). */
|
|
1258
|
+
connectFn?: (opts: ConnectOptions) => Promise<Session>;
|
|
1259
|
+
/** Custom flow runner for `spana_run_flow` (defaults to `runTestCommand`). */
|
|
1260
|
+
runFlowFn?: (opts: {
|
|
1261
|
+
flowPath: string;
|
|
1262
|
+
platform?: Platform;
|
|
1263
|
+
}) => Promise<boolean>;
|
|
1264
|
+
}
|
|
1265
|
+
/** Format a Spana selector into clean TypeScript code for verified `.flow.ts` generation. */
|
|
1266
|
+
declare function formatSelectorCode(selector: ExtendedSelector): string;
|
|
1267
|
+
/** Generate a complete `.flow.ts` file from recorded verified MCP actions. */
|
|
1268
|
+
declare function buildFlowFileFromLines(flowName: string, lines: string[]): string;
|
|
1269
|
+
declare const SPANA_MCP_TOOLS: McpToolDefinition[];
|
|
1270
|
+
/**
|
|
1271
|
+
* Model-free MCP (Model Context Protocol) server for Spana.
|
|
1272
|
+
*
|
|
1273
|
+
* Lets coding agents (Claude Code, Codex, Cursor, Antigravity) drive live
|
|
1274
|
+
* web, iOS, Android, Electron, and Electrobun sessions, inspect unified
|
|
1275
|
+
* DOM/native + console/error diagnostics, and receive verified `.flow.ts` lines.
|
|
1276
|
+
*/
|
|
1277
|
+
declare class SpanaMcpServer {
|
|
1278
|
+
private session;
|
|
1279
|
+
private recordedLines;
|
|
1280
|
+
private readonly connectFn;
|
|
1281
|
+
private readonly runFlowFn;
|
|
1282
|
+
constructor(options?: SpanaMcpServerOptions);
|
|
1283
|
+
private requireSession;
|
|
1284
|
+
handleRequest(req: JsonRpcRequest): Promise<JsonRpcResponse | null>;
|
|
1285
|
+
callTool(name: string, args: Record<string, unknown>): Promise<McpToolResult>;
|
|
1286
|
+
private jsonResult;
|
|
1287
|
+
/** Run the server over newline-delimited JSON-RPC stdio until stdin closes. */
|
|
1288
|
+
runStdio(): Promise<void>;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
export { type AgentActExecutor, AndroidWebViewCdpChannel, type AndroidWebViewCdpOptions, AppConfig, AppleWebInspectorClient, type AppliedFilterReport, type ApplyFiltersResult, type Attachment, BrowserConsoleLog, BrowserJSError, BrowserMockResponse, BrowserName, BrowserRouteMatcher, type CacheWriteStatus, CdpDomChannel, type CdpDomChannelOptions, type ChangedFile, type CloudProvider, type CloudProviderHelper, type CreateFixturesOptions, type DecisionBatchJudge, type DecisionBatchJudgeResult, type DecisionFilterOptions, type DecisionModelJudge, DomChannel, DomClearStorageOptions, DomElementMatch, DomIdleOptions, DomStorageEntries, DomTargetInfo, DomWaitForSelectorOptions, ElectrobunAppConfig, type ElectrobunDriverOptions, type ElectrobunLaunchPlan, ElectrobunRenderer, type ElectronDriverOptions, Element, type ExtendedFlowConfig, ExtendedSelector, type FailureCategory, type FilterCandidate, type FilterContext, type FilterDecisionOutput, type FilterUsage, type FixtureDefinition, type FixtureFn, type FixtureMap, FlowConfig, FlowContext, FlowDefinition, type FlowError, type FlowResult, type GitChanges, type GitHubPrReporterOptions, type HostOS, type JsonRpcRequest, type JsonRpcResponse, type LightweightCdpDriverOptions, type LogprobDecisionJudgeOptions, type McpContentBlock, type McpToolDefinition, type McpToolResult, type NamedSetupDefinition, type OllamaDecisionJudgeOptions, type PathRule, type PathRuleFilterOptions, Platform, type PrelaunchedWebBrowser, PromiseApp, ProvConfig, type RecordedAction, type ReplayCacheEntry, type ReplayCacheMode, ReplayCacheStore, type ReplayCacheSummary, ReplaySession, type ReplaySessionOptions, type ReplayStepOutcome, type Reporter, type ResolvedElementResult, type RunSummary, SPANA_MCP_TOOLS, type ScenarioStepResult, Selector, SpanaBridgeChannel, type SpanaBridgeServerOptions, SpanaMcpServer, type SpanaMcpServerOptions, type StepResult, TARGET_CHANNEL_MATRIX, TapMode, type TargetChannel, type TargetDescriptor, type TargetEngine, type TargetShell, type TestFilter, type WarmDaemonRecord, type WebInspectorListingPage, WebKitInspectorChannel, type WebKitInspectorOptions, applyNamedSetup, applyTestFilters, buildFilterCandidates, buildFlowFileFromLines, buildReplayCacheKey, collectGitChanges, connectPlaywrightOverCDP, createAndroidWebViewCdpChannel, createCdpDomChannel, createCompositeDomChannel, createFlowWithFixtures, createGitHubPrReporter, createLogprobDecisionJudge, createOllamaDecisionJudge, createSpanaBridgeChannel, createWebKitInspectorChannel, decisionFilter, decodeWebInspectorFrames, defineSetup, domRectToScreenBounds, encodeWebInspectorPacket, ensureWarmBrowserDaemon, extractDestructuredParamNames, findSimulatorWebInspectorSocket, findWebViewFrame, formatFilterSummary, formatGitHubPrMarkdown, formatSelectorCode, formatTargetMatrixTable, getHealthyWarmDaemon, invalidateWebViewFrameCache, isOffscreenInViewport, launchPlaywrightBrowser, listWarmDaemons, makeElectrobunDriver, makeElectronDriver, makeLightweightCdpDriver, orderFlowsLongestFirst, parseAndroidWebViewSockets, parseWebInspectorXmlFrame, pathRuleFilter, probabilityFromTopLogprobs, replayRecordedAction, resolveElectrobunEngine, resolveElectrobunLaunchPlan, resolveElementAcrossChannels, resolveTargetDescriptor, speculativelyPrelaunchWebBrowser, stopAllWarmDaemons, stopWarmDaemon, updateWarmDaemonSession };
|