spana-test 0.7.0 → 0.9.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.
Files changed (96) hide show
  1. package/dist/agent/index.d.ts +2 -2
  2. package/dist/agent/index.js +9 -9
  3. package/dist/{allure-RNMEYTXS.js → allure-RAEK4SIH.js} +2 -2
  4. package/dist/allure-RAEK4SIH.js.map +1 -0
  5. package/dist/{android-4NVTZMHL.js → android-6BOQTMM3.js} +2 -2
  6. package/dist/app-DSh1ejLh.d.ts +1266 -0
  7. package/dist/{chunk-H27IBIGA.js → chunk-2AFWVHQK.js} +63 -43
  8. package/dist/chunk-2AFWVHQK.js.map +1 -0
  9. package/dist/{chunk-RURZVMZ7.js → chunk-2KRVN4WN.js} +3 -3
  10. package/dist/{chunk-T5CROOR7.js → chunk-3UVSUVHW.js} +1828 -299
  11. package/dist/chunk-3UVSUVHW.js.map +1 -0
  12. package/dist/{chunk-6B5Y75V4.js → chunk-ALPQES3J.js} +1001 -281
  13. package/dist/chunk-ALPQES3J.js.map +1 -0
  14. package/dist/{chunk-2IXXEXTL.js → chunk-FP6PVHHR.js} +2 -2
  15. package/dist/{chunk-KNSAHEXI.js → chunk-IGTK5MHB.js} +8 -8
  16. package/dist/chunk-JPZCZHL4.js +79 -0
  17. package/dist/chunk-JPZCZHL4.js.map +1 -0
  18. package/dist/{chunk-JYFPZRCN.js → chunk-JZZ2W2XH.js} +5 -2
  19. package/dist/chunk-JZZ2W2XH.js.map +1 -0
  20. package/dist/{chunk-HCG4CJKR.js → chunk-SF7UYW4I.js} +3 -3
  21. package/dist/{chunk-T3EBOYLS.js → chunk-UEWZ2EXL.js} +1314 -129
  22. package/dist/chunk-UEWZ2EXL.js.map +1 -0
  23. package/dist/{chunk-HYSTRWYN.js → chunk-VP6V4XEJ.js} +4 -4
  24. package/dist/{chunk-S5JNNDXS.js → chunk-WV3ALL3H.js} +65 -37
  25. package/dist/chunk-WV3ALL3H.js.map +1 -0
  26. package/dist/chunk-Z6K4QQAR.js +358 -0
  27. package/dist/chunk-Z6K4QQAR.js.map +1 -0
  28. package/dist/cli.js +23 -11
  29. package/dist/cli.js.map +1 -1
  30. package/dist/config-loader-F5YAY7RP.js +9 -0
  31. package/dist/{console-MI2XB5RG.js → console-BGAK7Z2L.js} +11 -1
  32. package/dist/{console-MI2XB5RG.js.map → console-BGAK7Z2L.js.map} +1 -1
  33. package/dist/{daemon-manager-FBISTX24.js → daemon-manager-2EQDVUVM.js} +10 -2
  34. package/dist/{discover-LHEBSUIP.js → discover-RLSKEBAX.js} +5 -5
  35. package/dist/{doctor-command-WPEVZEZ4.js → doctor-command-YTCQ2SC7.js} +26 -18
  36. package/dist/doctor-command-YTCQ2SC7.js.map +1 -0
  37. package/dist/{flow-g6AICPAl.d.ts → flow-CSMwD9Fh.d.ts} +3 -29
  38. package/dist/gherkin/steps.d.ts +2 -2
  39. package/dist/{html-IKCTZH2U.js → html-JO2YNRWX.js} +3 -3
  40. package/dist/html-JO2YNRWX.js.map +1 -0
  41. package/dist/index.d.ts +215 -21
  42. package/dist/index.js +246 -147
  43. package/dist/index.js.map +1 -1
  44. package/dist/{installer-VUPFWP5X.js → installer-5UHTYQTB.js} +4 -4
  45. package/dist/{ios-JPK43TFZ.js → ios-Y4TO5MBR.js} +7 -3
  46. package/dist/{server-EBPYK3VE.js → server-4YLBAZEM.js} +50 -36
  47. package/dist/server-4YLBAZEM.js.map +1 -0
  48. package/dist/{server-IGLBFEU7.js → server-IS4K5FCT.js} +2 -2
  49. package/dist/{session-cJ_tZjCL.d.ts → session-CgvT-Oso.d.ts} +3 -1
  50. package/dist/session-K7FCRKOC.js +18 -0
  51. package/dist/{studio-command-FLA5HKRK.js → studio-command-RFPV2DS7.js} +2 -2
  52. package/dist/{test-command-P5W7UD52.js → test-command-UEJG5AI6.js} +223 -27
  53. package/dist/test-command-UEJG5AI6.js.map +1 -0
  54. package/native/darwin-arm64/libspana_native.dylib +0 -0
  55. package/native/darwin-x64/libspana_native.dylib +0 -0
  56. package/native/linux-arm64/libspana_native.so +0 -0
  57. package/native/linux-x64/libspana_native.so +0 -0
  58. package/native/win32-x64/spana_native.dll +0 -0
  59. package/package.json +1 -1
  60. package/studio-dist/assets/index-CBFsOh-9.js +193 -0
  61. package/studio-dist/assets/index-DH_18EyL.css +1 -0
  62. package/studio-dist/index.html +2 -2
  63. package/dist/allure-RNMEYTXS.js.map +0 -1
  64. package/dist/app-D_UyZBsl.d.ts +0 -915
  65. package/dist/chunk-6B5Y75V4.js.map +0 -1
  66. package/dist/chunk-DTNK54C2.js +0 -127
  67. package/dist/chunk-DTNK54C2.js.map +0 -1
  68. package/dist/chunk-H27IBIGA.js.map +0 -1
  69. package/dist/chunk-JYFPZRCN.js.map +0 -1
  70. package/dist/chunk-OBCFACUW.js +0 -28
  71. package/dist/chunk-OBCFACUW.js.map +0 -1
  72. package/dist/chunk-S5JNNDXS.js.map +0 -1
  73. package/dist/chunk-T3EBOYLS.js.map +0 -1
  74. package/dist/chunk-T5CROOR7.js.map +0 -1
  75. package/dist/config-loader-NIDQGP3K.js +0 -9
  76. package/dist/doctor-command-WPEVZEZ4.js.map +0 -1
  77. package/dist/html-IKCTZH2U.js.map +0 -1
  78. package/dist/server-EBPYK3VE.js.map +0 -1
  79. package/dist/session-QRWH3SPW.js +0 -18
  80. package/dist/test-command-P5W7UD52.js.map +0 -1
  81. package/studio-dist/assets/index-C-Io44gy.js +0 -193
  82. package/studio-dist/assets/index-DfM9lK4p.css +0 -1
  83. /package/dist/{android-4NVTZMHL.js.map → android-6BOQTMM3.js.map} +0 -0
  84. /package/dist/{chunk-RURZVMZ7.js.map → chunk-2KRVN4WN.js.map} +0 -0
  85. /package/dist/{chunk-2IXXEXTL.js.map → chunk-FP6PVHHR.js.map} +0 -0
  86. /package/dist/{chunk-KNSAHEXI.js.map → chunk-IGTK5MHB.js.map} +0 -0
  87. /package/dist/{chunk-HCG4CJKR.js.map → chunk-SF7UYW4I.js.map} +0 -0
  88. /package/dist/{chunk-HYSTRWYN.js.map → chunk-VP6V4XEJ.js.map} +0 -0
  89. /package/dist/{config-loader-NIDQGP3K.js.map → config-loader-F5YAY7RP.js.map} +0 -0
  90. /package/dist/{daemon-manager-FBISTX24.js.map → daemon-manager-2EQDVUVM.js.map} +0 -0
  91. /package/dist/{discover-LHEBSUIP.js.map → discover-RLSKEBAX.js.map} +0 -0
  92. /package/dist/{installer-VUPFWP5X.js.map → installer-5UHTYQTB.js.map} +0 -0
  93. /package/dist/{ios-JPK43TFZ.js.map → ios-Y4TO5MBR.js.map} +0 -0
  94. /package/dist/{server-IGLBFEU7.js.map → server-IS4K5FCT.js.map} +0 -0
  95. /package/dist/{session-QRWH3SPW.js.map → session-K7FCRKOC.js.map} +0 -0
  96. /package/dist/{studio-command-FLA5HKRK.js.map → studio-command-RFPV2DS7.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { F as FlowDefinition, a as FlowContext, b as FlowConfig } from './flow-g6AICPAl.js';
2
- export { c as FlowFn, P as PromiseExpectation, S as SecondarySession, d as SecondarySessionOptions, e as Sessions, f as flow } from './flow-g6AICPAl.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 DomWaitForHiddenOptions, g as DomWaitForMatchOptions, h as DomWaitForMatchResult, i as DomFillOptions, j as DomIdleOptions, k as DomStorageEntries, l as DomClearStorageOptions, B as BrowserRouteMatcher, m as BrowserMockResponse, n as BrowserConsoleLog, o as BrowserJSError, p as BrowserName, V as VirtualAuthenticatorOptions, q as ElectrobunAppConfig, r as ElectrobunRenderer, A as AppiumExecutionConfig, s as AppConfig, t as PromiseApp } from './app-D_UyZBsl.js';
4
- export { u as ArtifactConfig, v as BackUntilVisibleOptions, w as BridgeConfig, x as BrowserHAR, y as BrowserNetworkConditions, z as DeviceInfo, C as DeviceStateConfig, F as DismissKeyboardOptions, G as DomChannelKind, H as DomRect, I as ElectronAppConfig, L as LaunchOptions, J as RelativeSelector, K as ScrollUntilVisibleOptions, M as StorybookConfig, N as StorybookOpenOptions, O as StorybookValue, Q as TouchAction, U as TouchSequence, W as VideoRecordingMode, X as VirtualCredential, Y as WarmDaemonConfig, Z as WebBrowserEngine, _ as WebExecutionConfig, $ as WebResourceBlockType, a0 as buildDomFillScript, a1 as buildDomWaitForHiddenScript, a2 as buildDomWaitForMatchScript, a3 as buildDomWaitForSelectorScript, a4 as defineConfig, a5 as isSystemUISelector, a6 as isTestIDSelector, a7 as systemUI } from './app-D_UyZBsl.js';
5
- import { E as Element, B as Bounds, C as ConnectOptions, S as Session } from './session-cJ_tZjCL.js';
1
+ import { a as FlowDefinition, F as FlowContext, b as FlowConfig } from './flow-CSMwD9Fh.js';
2
+ export { c as FlowFn, S as SecondarySession, d as SecondarySessionOptions, e as Sessions, f as flow } from './flow-CSMwD9Fh.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 DomWaitForHiddenOptions, g as DomWaitForMatchOptions, h as DomWaitForMatchResult, i as DomFillOptions, j as DomIdleOptions, k as DomStorageEntries, l as DomClearStorageOptions, B as BrowserRouteMatcher, m as BrowserMockResponse, n as BrowserConsoleLog, o as BrowserJSError, p as BrowserName, V as VirtualAuthenticatorOptions, q as ElectrobunAppConfig, r as ElectrobunRenderer, A as AppiumExecutionConfig, s as AppConfig, t as VirtualCredential, u as VirtualCredentialInput, v as PromiseApp } from './app-DSh1ejLh.js';
4
+ export { w as ArtifactConfig, x as BackUntilVisibleOptions, y as BridgeConfig, z as BrowserCookie, C as BrowserHAR, F as BrowserNetworkConditions, G as BrowserRequestClient, H as BrowserRequestOptions, I as BrowserRequestResponse, J as BrowserResponseInfo, K as CdpSessionHandle, L as DeviceInfo, M as DeviceStateConfig, N as DismissKeyboardOptions, O as DomChannelKind, Q as DomRect, U as ElectronAppConfig, W as FrameScope, X as InjectedRuntimeMethod, Y as IsolatedBrowserContext, Z as LaunchOptions, _ as NegatedPromiseExpectation, $ as ObjectSelector, a0 as PollExpectation, a1 as PollMatchers, a2 as PromiseExpectFn, a3 as PromiseExpectation, a4 as RelativeSelector, a5 as RetryAssertionOptions, a6 as SPANA_INJECTED_RUNTIME_SCRIPT, a7 as ScrollUntilVisibleOptions, a8 as SelectorModifiers, a9 as StorybookConfig, aa as StorybookOpenOptions, ab as StorybookValue, ac as ToPassExpectation, ad as TouchAction, ae as TouchSequence, af as VideoRecordingMode, ag as WarmDaemonConfig, ah as WebBrowserEngine, ai as WebContextIsolation, aj as WebExecutionConfig, ak as WebResourceBlockType, al as buildDomActionabilityDiagScript, am as buildDomFillScript, an as buildDomWaitForHiddenScript, ao as buildDomWaitForMatchScript, ap as buildDomWaitForSelectorScript, aq as buildInjectedCallScript, ar as byCss, as as byRole, at as defineConfig, au as filterSelector, av as first, aw as inFrame, ax as isComposableDomSelector, ay as isSystemUISelector, az as isTestIDSelector, aA as last, aB as nth, aC as or, aD as systemUI, aE as within } from './app-DSh1ejLh.js';
5
+ import { E as Element, B as Bounds, C as ConnectOptions, S as Session } from './session-CgvT-Oso.js';
6
6
  import { Socket } from 'node:net';
7
7
  import { Effect } from 'effect';
8
8
  import { Browser, _electron, chromium } from 'playwright-core';
@@ -149,6 +149,14 @@ interface FlowError {
149
149
  suggestion?: string;
150
150
  /** Machine-readable error code for programmatic handling. */
151
151
  errorCode?: string;
152
+ /** Source file location in the user's flow where the failure originated. */
153
+ location?: {
154
+ file: string;
155
+ line: number;
156
+ column: number;
157
+ };
158
+ /** Annotated source code snippet centered on `location`. */
159
+ codeFrame?: string;
152
160
  }
153
161
  /** Result of a single flow execution on a specific platform. */
154
162
  interface FlowResult {
@@ -329,10 +337,14 @@ declare class CdpDomChannel implements DomChannel {
329
337
  removeChildSession(sessionId: string): void;
330
338
  clearChildSessions(): void;
331
339
  getChildSessions(): CdpChildSessionInfo[];
340
+ private useInjectedRuntime;
341
+ enableInjectedRuntime(enabled?: boolean): void;
342
+ private invokeDom;
332
343
  setFrameOffsetResolver(resolver: CdpFrameOffsetResolver | undefined): void;
333
344
  onEvent(method: string, listener: (params: any, sessionId?: string) => void): () => void;
334
345
  waitForEvent<T = any>(method: string, timeoutMs?: number, predicate?: (params: T, sessionId?: string) => boolean): Promise<T>;
335
- sendCommand<T = any>(method: string, params?: Record<string, unknown>, sessionId?: string | null): Promise<T>;
346
+ sendCommand<T = any>(method: string, params?: Record<string, unknown>, sessionId?: string | null, timeoutMs?: number): Promise<T>;
347
+ private evaluateOnSessionWithTimeout;
336
348
  evaluateOnSession<T = unknown>(sessionId: string | null | undefined, script: string | ((...args: any[]) => T), ...args: any[]): Promise<T>;
337
349
  evaluate<T = unknown>(script: string | ((...args: any[]) => T), ...args: any[]): Promise<T>;
338
350
  private applyChildOffset;
@@ -731,7 +743,16 @@ interface LightweightCdpDriverOptions {
731
743
  useBrowserContexts?: boolean;
732
744
  /** Pre-warm the next isolated CDP browser context while the current flow runs, and dispose old contexts asynchronously. */
733
745
  freshContextPerFlow?: boolean;
734
- /** Navigation wait condition (`"load"`, `"domcontentloaded"`, or `"commit"`). Default: `"load"` in browser-context mode. */
746
+ /**
747
+ * Context isolation mode when `freshContextPerFlow` is enabled:
748
+ * - `"fresh"` (default): creates a brand-new `Target.createBrowserContext` per flow.
749
+ * - `"hot-cache"`: keeps Chromium's HTTP & V8 bytecode caches warm while wiping cookies,
750
+ * localStorage, sessionStorage, IndexedDB, CacheStorage, and service workers (~4 ms reset).
751
+ */
752
+ contextIsolation?: "fresh" | "hot-cache";
753
+ /** Install persistent `window.__spanaRt` once per document to cut CDP wire payload ~100× (default: true on live sockets). */
754
+ useInjectedRuntime?: boolean;
755
+ /** Navigation wait condition (`"domcontentloaded"`, `"load"`, or `"commit"`). Default: `"domcontentloaded"` in browser-context mode. */
735
756
  waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
736
757
  /** Collapse CSS transitions & animations to 0.001ms via `Page.addScriptToEvaluateOnNewDocument`. */
737
758
  instantAnimations?: boolean;
@@ -745,6 +766,7 @@ interface LightweightCdpDriverOptions {
745
766
  fetchFn?: typeof fetch;
746
767
  createWebSocket?: WebSocketFactory;
747
768
  }
769
+ declare const UPLOAD_ATTACH_TIMEOUT_MS = 30000;
748
770
  /**
749
771
  * Direct CDP Chromium / Lightpanda driver speaking raw WebSocket CDP directly
750
772
  * from Bun/Node to the browser — completely eliminating Playwright's Node
@@ -854,6 +876,7 @@ interface ElectrobunDriverOptions extends ElectrobunAppConfig {
854
876
  declare function makeElectrobunDriver(options: ElectrobunDriverOptions): Effect.Effect<RawDriverService, DriverError>;
855
877
 
856
878
  type WarmDaemonKind = "wda" | "uiautomator2" | "iproxy" | "chromium";
879
+ declare const DEFAULT_WARM_DAEMON_IDLE_TTL_MS: number;
857
880
  interface WarmDaemonRecord {
858
881
  kind: WarmDaemonKind;
859
882
  deviceId: string;
@@ -862,17 +885,23 @@ interface WarmDaemonRecord {
862
885
  pid?: number;
863
886
  tunnelPid?: number;
864
887
  xctestrunPath?: string;
888
+ /** Optional temporary profile directory created for this daemon (cleaned up on stop). */
889
+ userDataDir?: string;
865
890
  /** Optional reusable WDA/UiAutomator2 session ID persisted across runs */
866
891
  sessionId?: string;
867
892
  bundleId?: string;
868
893
  startedAt: string;
894
+ /** Last timestamp this daemon was verified healthy / reused (used for idle TTL reaping). */
895
+ lastUsedAt?: string;
869
896
  }
897
+ /** Per-scope atomic state directory so concurrent OS processes never overwrite each other's daemon records. */
898
+ declare function defaultDaemonStateDir(): string;
870
899
  /** Persist a warm WDA/UiAutomator2 session ID on an existing daemon record for cross-run reuse. */
871
900
  declare function updateWarmDaemonSession(kind: WarmDaemonKind, deviceId: string, sessionId: string, bundleId?: string, stateFile?: string): void;
872
901
  declare function listWarmDaemons(stateFile?: string): WarmDaemonRecord[];
873
902
  /**
874
- * Probe whether a recorded warm WDA / UiAutomator2 daemon is still healthy on
875
- * `GET http://<host>:<port>/status`. Removes stale records automatically.
903
+ * Probe whether a recorded warm WDA / UiAutomator2 / Chromium daemon is still healthy.
904
+ * Removes stale or idle-expired records automatically.
876
905
  */
877
906
  declare function getHealthyWarmDaemon(kind: WarmDaemonKind, deviceId: string, options?: {
878
907
  stateFile?: string;
@@ -880,13 +909,59 @@ declare function getHealthyWarmDaemon(kind: WarmDaemonKind, deviceId: string, op
880
909
  timeoutMs?: number;
881
910
  /** HTTP health endpoint path (default: "/status", use "/json/version" for chromium). */
882
911
  statusPath?: string;
912
+ /** Idle TTL in ms (default: 30 minutes or `SPANA_DAEMON_IDLE_TTL_MS`). Pass 0 to disable. */
913
+ idleTtlMs?: number;
914
+ /** Current wall-clock time in ms (for deterministic testing). */
915
+ nowMs?: number;
883
916
  }): Promise<WarmDaemonRecord | null>;
884
917
  /**
885
- * Stop only the specific process PIDs started by Spana for this daemon record.
918
+ * Stop any warm daemons whose `lastUsedAt` (or `startedAt`) exceeds `idleTtlMs`.
919
+ */
920
+ declare function reapIdleWarmDaemons(options?: {
921
+ stateFile?: string;
922
+ idleTtlMs?: number;
923
+ nowMs?: number;
924
+ }): number;
925
+ /**
926
+ * Sweep orphaned Chromium processes launched by Spana (identified by Spana's unique
927
+ * temporary `--user-data-dir=.../spana-*-profile-*` argument) whose PIDs are no longer
928
+ * tracked in the daemon registry, and remove their temporary profile directories.
929
+ */
930
+ declare function sweepOrphanedSpanaBrowsers(options?: {
931
+ excludePids?: Set<number>;
932
+ }): number;
933
+ /**
934
+ * Stop the specific process PIDs (and process groups) started by Spana for this daemon record.
886
935
  */
887
936
  declare function stopWarmDaemon(kind: WarmDaemonKind, deviceId: string, stateFile?: string): boolean;
888
937
  declare function stopAllWarmDaemons(stateFile?: string): number;
889
938
 
939
+ /** Probe the OS TCP stack to verify a port is genuinely bindable on `host`. */
940
+ declare function isPortAvailable(port: number, host?: string): Promise<boolean>;
941
+ /** Fail loudly if an explicitly requested port is already bound by another process. */
942
+ declare function assertPortAvailable(port: number, label?: string, host?: string): Promise<void>;
943
+ /**
944
+ * Allocate a genuinely free OS TCP port (safe across concurrent OS processes!),
945
+ * starting near `preferredBase` and falling back to an OS ephemeral port (`0`).
946
+ */
947
+ declare function allocateFreePort(preferredBase?: number, maxAttempts?: number, host?: string): Promise<number>;
948
+
949
+ interface CodeLocation {
950
+ file: string;
951
+ line: number;
952
+ column: number;
953
+ }
954
+ interface ExtractedCodeFrame {
955
+ location: CodeLocation;
956
+ frame: string;
957
+ }
958
+ declare function formatCodeFrame(source: string, line: number, column: number, contextLines?: number): string;
959
+ /**
960
+ * Extract the most relevant user-code location and annotated source snippet
961
+ * from an Error stack trace (Playwright-style code frame for failure triage).
962
+ */
963
+ declare function extractCodeFrame(stack: string | undefined, preferredFile?: string, contextLines?: number): ExtractedCodeFrame | undefined;
964
+
890
965
  interface ProviderRunResult {
891
966
  passed: boolean;
892
967
  name?: string;
@@ -1273,37 +1348,58 @@ declare function createApiClient(options: ApiClientOptions): ApiClient;
1273
1348
  declare function createApiFixture<Deps extends Record<string, unknown> = Record<string, never>, T extends string = string, R extends string = string>(options: ApiClientOptions | ((ctx: FlowContext<T, R> & Deps) => ApiClientOptions)): FixtureFn<ApiClient, Deps, T, R>;
1274
1349
  interface PersonaDefinition<T extends string = string, R extends string = string> {
1275
1350
  name: string;
1276
- /** Sign in once (via API, virtual passkey, or UI) and return storage entries or a saved storageStatePath. */
1351
+ /** Sign in once (via API, virtual passkey, or UI) and return storage entries, storageStatePath, or virtualCredentials. */
1277
1352
  signIn: (ctx: FlowContext<T, R>) => Promise<{
1278
1353
  storage?: DomStorageEntries;
1279
1354
  storageStatePath?: string;
1355
+ virtualCredentials?: VirtualCredential[];
1280
1356
  } | void>;
1281
1357
  /** Optional cache key discriminator (e.g. base URL or tenant ID). */
1282
1358
  cacheKey?: string;
1283
1359
  /** Optional route to navigate to after restoring cached auth state. */
1284
1360
  navigateTo?: R;
1361
+ /** Automatically capture active WebAuthn virtual credentials after `signIn` and re-import into fresh contexts (default: true). */
1362
+ captureVirtualCredentials?: boolean;
1363
+ /** Options used when re-enabling the virtual authenticator on cache hits. */
1364
+ authenticatorOptions?: VirtualAuthenticatorOptions;
1285
1365
  }
1286
1366
  /** Define a reusable authenticated persona for `PersonaAuthCache`. */
1287
1367
  declare function definePersona<T extends string = string, R extends string = string>(name: string, config: Omit<PersonaDefinition<T, R>, "name">): PersonaDefinition<T, R>;
1288
1368
  interface CachedPersonaState {
1289
1369
  storage?: DomStorageEntries;
1290
1370
  storageStatePath?: string;
1371
+ virtualCredentials?: VirtualCredential[];
1291
1372
  cachedAt: number;
1292
1373
  }
1374
+ /**
1375
+ * Per-persona WebAuthn virtual passkey store that survives fresh browser contexts.
1376
+ * Save credentials after registering once (`store.save("alice", await app.getVirtualCredentials())`)
1377
+ * and restore them into any fresh context (`await store.restore("alice", app)`).
1378
+ */
1379
+ declare class VirtualCredentialStore {
1380
+ private readonly store;
1381
+ save(persona: string, credentials: VirtualCredential[]): void;
1382
+ get(persona: string): VirtualCredentialInput[];
1383
+ has(persona: string): boolean;
1384
+ clear(persona?: string): void;
1385
+ restore(persona: string, app: Pick<PromiseApp, "enableVirtualAuthenticator" | "addVirtualCredential">, opts?: VirtualAuthenticatorOptions): Promise<number>;
1386
+ }
1293
1387
  /**
1294
1388
  * In-memory per-persona auth state cache (single-flight safe across parallel workers).
1295
- * Signs a persona in ONCE (including passkey / WebAuthn flows), caches its auth state,
1296
- * and restores it in milliseconds across all remaining flows.
1389
+ * Signs a persona in ONCE (including passkey / WebAuthn flows), caches its auth state
1390
+ * AND virtual passkey credentials, and restores them in milliseconds across fresh contexts.
1297
1391
  */
1298
1392
  declare class PersonaAuthCache {
1299
1393
  private readonly cache;
1300
1394
  private readonly inflight;
1395
+ readonly credentials: VirtualCredentialStore;
1301
1396
  private keyFor;
1302
1397
  get(name: string, cacheKey?: string): CachedPersonaState | undefined;
1303
1398
  invalidate(name?: string, cacheKey?: string): void;
1304
1399
  /**
1305
1400
  * Ensure `persona` is authenticated in `ctx`. On cache miss, executes `persona.signIn(ctx)`
1306
- * once (coalescing concurrent callers); on cache hit, restores cookies/storageState directly.
1401
+ * once (coalescing concurrent callers); on cache hit, restores cookies/storageState and
1402
+ * imports any stored WebAuthn virtual passkeys directly into the fresh context.
1307
1403
  */
1308
1404
  authenticate<T extends string = string, R extends string = string>(persona: PersonaDefinition<T, R>, ctx: FlowContext<T, R>): Promise<CachedPersonaState>;
1309
1405
  }
@@ -1578,14 +1674,30 @@ interface ProcessPartitionPlan {
1578
1674
  processCount: number;
1579
1675
  workersPerProcess: number[];
1580
1676
  }
1677
+ interface SharedFlowQueueServer {
1678
+ /** Local loopback HTTP URL (e.g. `http://127.0.0.1:54321`) passed to child processes via `SPANA_QUEUE_URL`. */
1679
+ url: string;
1680
+ /** Number of unclaimed flows left in the queue. */
1681
+ remaining(): number;
1682
+ /** Shut down the loopback queue server cleanly. */
1683
+ close(): Promise<void>;
1684
+ }
1685
+ /**
1686
+ * Start a lightweight local HTTP work-stealing queue serving an already-ordered
1687
+ * (longest-first) list of flow names to `M` isolated OS worker processes.
1688
+ * Eliminates static `--shard` tail stragglers when running `spana test --workers N --processes M`.
1689
+ */
1690
+ declare function startSharedFlowQueueServer(orderedFlowNames: string[]): Promise<SharedFlowQueueServer>;
1691
+ /** Client helper for a worker process to claim the next flow name from `SPANA_QUEUE_URL`. */
1692
+ declare function createRemoteFlowClaimer(queueUrl: string): () => Promise<string | null>;
1581
1693
  /**
1582
1694
  * Plan how to split `totalWorkers` across OS processes.
1583
- * - Up to `maxWorkersPerProcess` (default 8): 1 single in-process Bun event loop (zero IPC overhead).
1584
- * - Above `maxWorkersPerProcess` (e.g. 16 or 32 workers on large CI boxes): evenly divides
1585
- * workers across `Math.ceil(totalWorkers / maxWorkersPerProcess)` OS processes so each
1586
- * process gets its own JS heap, GC, and event loop.
1695
+ * - When `explicitProcesses` is set (`--processes M`), splits `totalWorkers` evenly across
1696
+ * `min(explicitProcesses, totalWorkers)` isolated OS processes.
1697
+ * - Otherwise, up to `maxWorkersPerProcess` (default 8) runs in 1 in-process event loop,
1698
+ * and above that splits evenly across `Math.ceil(totalWorkers / maxWorkersPerProcess)` OS processes.
1587
1699
  */
1588
- declare function planProcessPool(totalWorkers: number, maxWorkersPerProcess?: number): ProcessPartitionPlan;
1700
+ declare function planProcessPool(totalWorkers: number, maxWorkersPerProcess?: number, explicitProcesses?: number): ProcessPartitionPlan;
1589
1701
  /**
1590
1702
  * Partition flows across `processCount` buckets using Longest-Processing-Time-First (LPT)
1591
1703
  * bin packing when `durationHintsMs` are available so every child process finishes together.
@@ -1611,9 +1723,11 @@ interface ProcessShardOutcome {
1611
1723
  interface MultiProcessPoolOptions {
1612
1724
  totalWorkers: number;
1613
1725
  maxWorkersPerProcess?: number;
1726
+ /** Explicit OS process count (`--processes M`). */
1727
+ processes?: number;
1614
1728
  buildShardCommand: (shardIndex: number, shardTotal: number, workerCount: number) => ProcessShardCommand;
1615
1729
  spawnFn?: typeof spawn;
1616
- readReportFn?: (reportJsonPath: string) => TestResult[];
1730
+ readReportFn?: (reportJsonPath: string) => TestResult[] | Promise<TestResult[]>;
1617
1731
  cleanupReportFiles?: boolean;
1618
1732
  }
1619
1733
  interface MultiProcessPoolResult {
@@ -1626,12 +1740,92 @@ interface MultiProcessPoolResult {
1626
1740
  processCount: number;
1627
1741
  processResults: ProcessShardOutcome[];
1628
1742
  }
1743
+ /**
1744
+ * Persist a worker child's `TestResult[]` to `SPANA_WORKER_REPORT_PATH` so the
1745
+ * parent multi-process pool can aggregate results across `--processes M` children.
1746
+ */
1747
+ declare function writeWorkerProcessReport(results: TestResult[], env?: NodeJS.ProcessEnv): Promise<string | null>;
1629
1748
  /**
1630
1749
  * Execute a high-concurrency suite (16–32+ workers) across multiple OS worker processes,
1631
1750
  * each running up to `maxWorkersPerProcess` in-process workers with its own JS heap & event loop.
1632
1751
  */
1633
1752
  declare function runMultiProcessPool(options: MultiProcessPoolOptions): Promise<MultiProcessPoolResult>;
1634
1753
 
1754
+ type NetworkCacheMode = "record" | "replay" | "auto";
1755
+ interface CachedNetworkEntry {
1756
+ version: 1;
1757
+ key: string;
1758
+ method: string;
1759
+ url: string;
1760
+ status: number;
1761
+ contentType: string;
1762
+ headers?: Record<string, string>;
1763
+ body: string;
1764
+ recordedAt: string;
1765
+ }
1766
+ interface NetworkReplayCacheOptions {
1767
+ /** Directory where recorded API responses are stored. Default: `.spana/network-cache`. */
1768
+ cacheDir?: string;
1769
+ }
1770
+ declare function buildNetworkCacheKey(method: string, url: string): string;
1771
+ /**
1772
+ * Deterministic local HTTP API response cache (`.spana/network-cache/`).
1773
+ * Eliminates real-world backend/DB round-trip latency (often 60–80% of suite wall time)
1774
+ * by recording read-only API responses once and replaying them in <1ms via `app.mockNetwork`.
1775
+ */
1776
+ declare class NetworkReplayCache {
1777
+ readonly cacheDir: string;
1778
+ constructor(options?: NetworkReplayCacheOptions);
1779
+ private entryPath;
1780
+ get(method: string, url: string): CachedNetworkEntry | null;
1781
+ set(entry: Omit<CachedNetworkEntry, "version" | "key" | "recordedAt">): CachedNetworkEntry;
1782
+ /**
1783
+ * Fetch an endpoint live on cache miss (in `"record"` or `"auto"` mode) or return
1784
+ * the cached response in <1ms on cache hit (in `"replay"` or `"auto"` mode).
1785
+ */
1786
+ resolve(url: string, options?: {
1787
+ method?: string;
1788
+ mode?: NetworkCacheMode;
1789
+ headers?: Record<string, string>;
1790
+ fetchFn?: typeof fetch;
1791
+ }): Promise<{
1792
+ entry: CachedNetworkEntry;
1793
+ source: "cache" | "network";
1794
+ }>;
1795
+ }
1796
+ interface AttachNetworkCacheOptions {
1797
+ /** URLs (and optional route matchers) to pre-warm/replay via `app.mockNetwork`. */
1798
+ routes: Array<{
1799
+ url: string;
1800
+ matcher?: BrowserRouteMatcher;
1801
+ method?: string;
1802
+ headers?: Record<string, string>;
1803
+ }>;
1804
+ mode?: NetworkCacheMode;
1805
+ cacheDir?: string;
1806
+ fetchFn?: typeof fetch;
1807
+ }
1808
+ interface AttachNetworkCacheResult {
1809
+ cacheHits: number;
1810
+ networkFetches: number;
1811
+ totalRoutes: number;
1812
+ }
1813
+ /**
1814
+ * Attach deterministic recorded API mocks to any Spana `app` (`mockNetwork`-capable)
1815
+ * so read-only backend endpoints respond in <1ms locally instead of hitting live DBs.
1816
+ */
1817
+ declare function attachNetworkReplayCache(app: {
1818
+ mockNetwork(matcher: BrowserRouteMatcher, response: BrowserMockResponse): Promise<void>;
1819
+ }, options: AttachNetworkCacheOptions): Promise<AttachNetworkCacheResult>;
1820
+
1821
+ /**
1822
+ * Clone an existing iOS Simulator for parallel multi-worker CI execution (`xcrun simctl clone`).
1823
+ * Returns the newly created simulator UDID.
1824
+ */
1825
+ declare function cloneIOSSimulator(sourceUdid: string, cloneName: string): string;
1826
+ /** Shut down and delete a temporary cloned iOS Simulator (`xcrun simctl delete`). */
1827
+ declare function deleteIOSSimulator(udid: string): void;
1828
+
1635
1829
  /** MCP Tool definition advertised by `tools/list`. */
1636
1830
  interface McpToolDefinition {
1637
1831
  name: string;
@@ -1703,4 +1897,4 @@ declare class SpanaMcpServer {
1703
1897
  runStdio(): Promise<void>;
1704
1898
  }
1705
1899
 
1706
- export { type AgentActExecutor, AndroidWebViewCdpChannel, type AndroidWebViewCdpOptions, type ApiClient, type ApiClientOptions, type ApiRequestOptions, type ApiResponse, AppConfig, AppleWebInspectorClient, type AppliedFilterReport, type ApplyFiltersResult, type Attachment, BrowserConsoleLog, BrowserJSError, BrowserMockResponse, BrowserName, BrowserRouteMatcher, type CacheWriteStatus, type CachedPersonaState, type CdpChildSessionInfo, CdpDomChannel, type CdpDomChannelOptions, type CdpFrameOffsetResolver, type CdpScreencastLike, type CdpScreencastRecorderOptions, type ChangedFile, type CloudProvider, type CloudProviderHelper, type CreateFixturesOptions, DEFAULT_MAX_WORKERS_PER_PROCESS, type DecisionBatchJudge, type DecisionBatchJudgeResult, type DecisionFilterOptions, type DecisionModelJudge, type DeterministicImpactFilterOptions, type DirectCdpBrowserHandle, type DirectCdpBrowserLaunchOptions, DomChannel, DomClearStorageOptions, DomElementMatch, DomFillOptions, DomIdleOptions, DomStorageEntries, DomTargetInfo, DomWaitForHiddenOptions, DomWaitForMatchOptions, DomWaitForMatchResult, 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 FlowPlaybackTrace, type FlowResult, type GitChanges, type GitHubPrReporterOptions, type HostOS, type JsonRpcRequest, type JsonRpcResponse, type LightweightCdpDriverOptions, type LogprobDecisionJudgeOptions, type McpContentBlock, type McpToolDefinition, type McpToolResult, type MultiProcessPoolOptions, type MultiProcessPoolResult, type NamedSetupDefinition, type NativePngCompareResult, type NativeXmlRawNode, type OllamaDecisionJudgeOptions, type PathRule, type PathRuleFilterOptions, PersonaAuthCache, type PersonaDefinition, Platform, type PlaybackFrame, type PlaybackStepMarker, type PrelaunchedWebBrowser, type ProcessPartitionPlan, type ProcessShardCommand, type ProcessShardOutcome, 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, type StopRecordingOptions, type StopRecordingResult, TARGET_CHANNEL_MATRIX, TapMode, type TargetChannel, type TargetDescriptor, type TargetEngine, type TargetShell, type TestFilter, type VideoRecorderHandle, VirtualAuthenticatorOptions, type WarmDaemonRecord, type WebInspectorListingPage, WebKitInspectorChannel, type WebKitInspectorOptions, applyNamedSetup, applyTestFilters, buildFilterCandidates, buildFlowFileFromLines, buildPlaybackTraceFromSteps, buildReplayCacheKey, collectGitChanges, comparePngNative, connectPlaywrightOverCDP, connectPlaywrightOverWS, createAndroidWebViewCdpChannel, createApiClient, createApiFixture, createCdpDomChannel, createCompositeDomChannel, createFlowWithFixtures, createGitHubPrReporter, createLogprobDecisionJudge, createOllamaDecisionJudge, createSpanaBridgeChannel, createWebKitInspectorChannel, decisionFilter, decodeWebInspectorFrames, definePersona, defineSetup, deterministicImpactFilter, domRectToScreenBounds, encodeWebInspectorPacket, ensureWarmBrowserDaemon, exportFramesToMp4, extractDestructuredParamNames, findSimulatorWebInspectorSocket, findWebViewFrame, formatFilterSummary, formatGitHubPrMarkdown, formatSelectorCode, formatTargetMatrixTable, getHealthyWarmDaemon, getNativeAcceleratorPath, invalidateWebViewFrameCache, isNativeAcceleratorActive, isOffscreenInViewport, launchDirectCdpBrowser, launchPlaywrightBrowser, listWarmDaemons, makeElectrobunDriver, makeElectronDriver, makeLightweightCdpDriver, orderFlowsLongestFirst, parseAndroidWebViewSockets, parseWebInspectorXmlFrame, partitionFlowsAcrossProcesses, pathRuleFilter, planProcessPool, probabilityFromTopLogprobs, replayRecordedAction, resolveElectrobunEngine, resolveElectrobunLaunchPlan, resolveElementAcrossChannels, resolveTargetDescriptor, resolveWebEngine, runMultiProcessPool, speculativelyPrelaunchWebBrowser, startAndroidVideoRecorder, startCdpScreencastRecorder, startIosSimulatorVideoRecorder, stopAllWarmDaemons, stopWarmDaemon, tokenizeXmlNative, updateWarmDaemonSession };
1900
+ export { type AgentActExecutor, AndroidWebViewCdpChannel, type AndroidWebViewCdpOptions, type ApiClient, type ApiClientOptions, type ApiRequestOptions, type ApiResponse, AppConfig, AppleWebInspectorClient, type AppliedFilterReport, type ApplyFiltersResult, type AttachNetworkCacheOptions, type AttachNetworkCacheResult, type Attachment, BrowserConsoleLog, BrowserJSError, BrowserMockResponse, BrowserName, BrowserRouteMatcher, type CacheWriteStatus, type CachedNetworkEntry, type CachedPersonaState, type CdpChildSessionInfo, CdpDomChannel, type CdpDomChannelOptions, type CdpFrameOffsetResolver, type CdpScreencastLike, type CdpScreencastRecorderOptions, type ChangedFile, type CloudProvider, type CloudProviderHelper, type CodeLocation, type CreateFixturesOptions, DEFAULT_MAX_WORKERS_PER_PROCESS, DEFAULT_WARM_DAEMON_IDLE_TTL_MS, type DecisionBatchJudge, type DecisionBatchJudgeResult, type DecisionFilterOptions, type DecisionModelJudge, type DeterministicImpactFilterOptions, type DirectCdpBrowserHandle, type DirectCdpBrowserLaunchOptions, DomChannel, DomClearStorageOptions, DomElementMatch, DomFillOptions, DomIdleOptions, DomStorageEntries, DomTargetInfo, DomWaitForHiddenOptions, DomWaitForMatchOptions, DomWaitForMatchResult, DomWaitForSelectorOptions, ElectrobunAppConfig, type ElectrobunDriverOptions, type ElectrobunLaunchPlan, ElectrobunRenderer, type ElectronDriverOptions, Element, type ExtendedFlowConfig, ExtendedSelector, type ExtractedCodeFrame, type FailureCategory, type FilterCandidate, type FilterContext, type FilterDecisionOutput, type FilterUsage, type FixtureDefinition, type FixtureFn, type FixtureMap, FlowConfig, FlowContext, FlowDefinition, type FlowError, type FlowPlaybackTrace, type FlowResult, type GitChanges, type GitHubPrReporterOptions, type HostOS, type JsonRpcRequest, type JsonRpcResponse, type LightweightCdpDriverOptions, type LogprobDecisionJudgeOptions, type McpContentBlock, type McpToolDefinition, type McpToolResult, type MultiProcessPoolOptions, type MultiProcessPoolResult, type NamedSetupDefinition, type NativePngCompareResult, type NativeXmlRawNode, type NetworkCacheMode, NetworkReplayCache, type NetworkReplayCacheOptions, type OllamaDecisionJudgeOptions, type PathRule, type PathRuleFilterOptions, PersonaAuthCache, type PersonaDefinition, Platform, type PlaybackFrame, type PlaybackStepMarker, type PrelaunchedWebBrowser, type ProcessPartitionPlan, type ProcessShardCommand, type ProcessShardOutcome, 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, type SharedFlowQueueServer, SpanaBridgeChannel, type SpanaBridgeServerOptions, SpanaMcpServer, type SpanaMcpServerOptions, type StepResult, type StopRecordingOptions, type StopRecordingResult, TARGET_CHANNEL_MATRIX, TapMode, type TargetChannel, type TargetDescriptor, type TargetEngine, type TargetShell, type TestFilter, UPLOAD_ATTACH_TIMEOUT_MS, type VideoRecorderHandle, VirtualAuthenticatorOptions, VirtualCredential, VirtualCredentialInput, VirtualCredentialStore, type WarmDaemonRecord, type WebInspectorListingPage, WebKitInspectorChannel, type WebKitInspectorOptions, allocateFreePort, applyNamedSetup, applyTestFilters, assertPortAvailable, attachNetworkReplayCache, buildFilterCandidates, buildFlowFileFromLines, buildNetworkCacheKey, buildPlaybackTraceFromSteps, buildReplayCacheKey, cloneIOSSimulator, collectGitChanges, comparePngNative, connectPlaywrightOverCDP, connectPlaywrightOverWS, createAndroidWebViewCdpChannel, createApiClient, createApiFixture, createCdpDomChannel, createCompositeDomChannel, createFlowWithFixtures, createGitHubPrReporter, createLogprobDecisionJudge, createOllamaDecisionJudge, createRemoteFlowClaimer, createSpanaBridgeChannel, createWebKitInspectorChannel, decisionFilter, decodeWebInspectorFrames, defaultDaemonStateDir, definePersona, defineSetup, deleteIOSSimulator, deterministicImpactFilter, domRectToScreenBounds, encodeWebInspectorPacket, ensureWarmBrowserDaemon, exportFramesToMp4, extractCodeFrame, extractDestructuredParamNames, findSimulatorWebInspectorSocket, findWebViewFrame, formatCodeFrame, formatFilterSummary, formatGitHubPrMarkdown, formatSelectorCode, formatTargetMatrixTable, getHealthyWarmDaemon, getNativeAcceleratorPath, invalidateWebViewFrameCache, isNativeAcceleratorActive, isOffscreenInViewport, isPortAvailable, launchDirectCdpBrowser, launchPlaywrightBrowser, listWarmDaemons, makeElectrobunDriver, makeElectronDriver, makeLightweightCdpDriver, orderFlowsLongestFirst, parseAndroidWebViewSockets, parseWebInspectorXmlFrame, partitionFlowsAcrossProcesses, pathRuleFilter, planProcessPool, probabilityFromTopLogprobs, reapIdleWarmDaemons, replayRecordedAction, resolveElectrobunEngine, resolveElectrobunLaunchPlan, resolveElementAcrossChannels, resolveTargetDescriptor, resolveWebEngine, runMultiProcessPool, speculativelyPrelaunchWebBrowser, startAndroidVideoRecorder, startCdpScreencastRecorder, startIosSimulatorVideoRecorder, startSharedFlowQueueServer, stopAllWarmDaemons, stopWarmDaemon, sweepOrphanedSpanaBrowsers, tokenizeXmlNative, updateWarmDaemonSession, writeWorkerProcessReport };