spana-test 0.7.0 → 0.8.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-CgbLADmF.d.ts +1191 -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-JYFPZRCN.js → chunk-2T4K7BJ3.js} +3 -1
  10. package/dist/chunk-2T4K7BJ3.js.map +1 -0
  11. package/dist/{chunk-6B5Y75V4.js → chunk-3FXDOTFI.js} +840 -271
  12. package/dist/chunk-3FXDOTFI.js.map +1 -0
  13. package/dist/{chunk-T5CROOR7.js → chunk-AJCSETN6.js} +1329 -245
  14. package/dist/chunk-AJCSETN6.js.map +1 -0
  15. package/dist/chunk-JPZCZHL4.js +79 -0
  16. package/dist/chunk-JPZCZHL4.js.map +1 -0
  17. package/dist/{chunk-RURZVMZ7.js → chunk-NS2HLJO4.js} +3 -3
  18. package/dist/{chunk-2IXXEXTL.js → chunk-PMXSU5MS.js} +2 -2
  19. package/dist/{chunk-HYSTRWYN.js → chunk-QP4MDUBY.js} +4 -4
  20. package/dist/chunk-RKYKRGHB.js +236 -0
  21. package/dist/chunk-RKYKRGHB.js.map +1 -0
  22. package/dist/{chunk-HCG4CJKR.js → chunk-SF7UYW4I.js} +3 -3
  23. package/dist/{chunk-T3EBOYLS.js → chunk-SNL4X67N.js} +1043 -99
  24. package/dist/chunk-SNL4X67N.js.map +1 -0
  25. package/dist/{chunk-KNSAHEXI.js → chunk-WKVU24B6.js} +8 -8
  26. package/dist/{chunk-S5JNNDXS.js → chunk-WV3ALL3H.js} +65 -37
  27. package/dist/chunk-WV3ALL3H.js.map +1 -0
  28. package/dist/cli.js +23 -11
  29. package/dist/cli.js.map +1 -1
  30. package/dist/config-loader-5FU45FXK.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-DDYQITPD.js} +4 -2
  34. package/dist/{discover-LHEBSUIP.js → discover-RLSKEBAX.js} +5 -5
  35. package/dist/{doctor-command-WPEVZEZ4.js → doctor-command-HEQQOYUR.js} +26 -18
  36. package/dist/doctor-command-HEQQOYUR.js.map +1 -0
  37. package/dist/{flow-g6AICPAl.d.ts → flow-Md5xLwbX.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 +184 -20
  42. package/dist/index.js +230 -147
  43. package/dist/index.js.map +1 -1
  44. package/dist/{installer-VUPFWP5X.js → installer-IYGMG7LS.js} +4 -4
  45. package/dist/{ios-JPK43TFZ.js → ios-Y4TO5MBR.js} +7 -3
  46. package/dist/{server-IGLBFEU7.js → server-4PEREPHY.js} +2 -2
  47. package/dist/{server-EBPYK3VE.js → server-JPNH33MX.js} +50 -36
  48. package/dist/server-JPNH33MX.js.map +1 -0
  49. package/dist/{session-cJ_tZjCL.d.ts → session-D9e30RVS.d.ts} +1 -1
  50. package/dist/session-V4PYJXNB.js +18 -0
  51. package/dist/{studio-command-FLA5HKRK.js → studio-command-JOIFCOHC.js} +2 -2
  52. package/dist/{test-command-P5W7UD52.js → test-command-JCO2HPYI.js} +221 -27
  53. package/dist/test-command-JCO2HPYI.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-NS2HLJO4.js.map} +0 -0
  85. /package/dist/{chunk-2IXXEXTL.js.map → chunk-PMXSU5MS.js.map} +0 -0
  86. /package/dist/{chunk-HYSTRWYN.js.map → chunk-QP4MDUBY.js.map} +0 -0
  87. /package/dist/{chunk-HCG4CJKR.js.map → chunk-SF7UYW4I.js.map} +0 -0
  88. /package/dist/{chunk-KNSAHEXI.js.map → chunk-WKVU24B6.js.map} +0 -0
  89. /package/dist/{config-loader-NIDQGP3K.js.map → config-loader-5FU45FXK.js.map} +0 -0
  90. /package/dist/{daemon-manager-FBISTX24.js.map → daemon-manager-DDYQITPD.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-IYGMG7LS.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-4PEREPHY.js.map} +0 -0
  95. /package/dist/{session-QRWH3SPW.js.map → session-V4PYJXNB.js.map} +0 -0
  96. /package/dist/{studio-command-FLA5HKRK.js.map → studio-command-JOIFCOHC.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-Md5xLwbX.js';
2
+ export { c as FlowFn, S as SecondarySession, d as SecondarySessionOptions, e as Sessions, f as flow } from './flow-Md5xLwbX.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-CgbLADmF.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 ObjectSelector, $ as PromiseExpectFn, a0 as PromiseExpectation, a1 as RelativeSelector, a2 as SPANA_INJECTED_RUNTIME_SCRIPT, a3 as ScrollUntilVisibleOptions, a4 as SelectorModifiers, a5 as StorybookConfig, a6 as StorybookOpenOptions, a7 as StorybookValue, a8 as TouchAction, a9 as TouchSequence, aa as VideoRecordingMode, ab as WarmDaemonConfig, ac as WebBrowserEngine, ad as WebContextIsolation, ae as WebExecutionConfig, af as WebResourceBlockType, ag as buildDomFillScript, ah as buildDomWaitForHiddenScript, ai as buildDomWaitForMatchScript, aj as buildDomWaitForSelectorScript, ak as buildInjectedCallScript, al as byCss, am as byRole, an as defineConfig, ao as filterSelector, ap as first, aq as inFrame, ar as isComposableDomSelector, as as isSystemUISelector, at as isTestIDSelector, au as last, av as nth, aw as systemUI, ax as within } from './app-CgbLADmF.js';
5
+ import { E as Element, B as Bounds, C as ConnectOptions, S as Session } from './session-D9e30RVS.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,6 +337,9 @@ 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>;
@@ -731,7 +742,16 @@ interface LightweightCdpDriverOptions {
731
742
  useBrowserContexts?: boolean;
732
743
  /** Pre-warm the next isolated CDP browser context while the current flow runs, and dispose old contexts asynchronously. */
733
744
  freshContextPerFlow?: boolean;
734
- /** Navigation wait condition (`"load"`, `"domcontentloaded"`, or `"commit"`). Default: `"load"` in browser-context mode. */
745
+ /**
746
+ * Context isolation mode when `freshContextPerFlow` is enabled:
747
+ * - `"fresh"` (default): creates a brand-new `Target.createBrowserContext` per flow.
748
+ * - `"hot-cache"`: keeps Chromium's HTTP & V8 bytecode caches warm while wiping cookies,
749
+ * localStorage, sessionStorage, IndexedDB, CacheStorage, and service workers (~4 ms reset).
750
+ */
751
+ contextIsolation?: "fresh" | "hot-cache";
752
+ /** Install persistent `window.__spanaRt` once per document to cut CDP wire payload ~100× (default: true on live sockets). */
753
+ useInjectedRuntime?: boolean;
754
+ /** Navigation wait condition (`"domcontentloaded"`, `"load"`, or `"commit"`). Default: `"domcontentloaded"` in browser-context mode. */
735
755
  waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
736
756
  /** Collapse CSS transitions & animations to 0.001ms via `Page.addScriptToEvaluateOnNewDocument`. */
737
757
  instantAnimations?: boolean;
@@ -862,17 +882,21 @@ interface WarmDaemonRecord {
862
882
  pid?: number;
863
883
  tunnelPid?: number;
864
884
  xctestrunPath?: string;
885
+ /** Optional temporary profile directory created for this daemon (cleaned up on stop). */
886
+ userDataDir?: string;
865
887
  /** Optional reusable WDA/UiAutomator2 session ID persisted across runs */
866
888
  sessionId?: string;
867
889
  bundleId?: string;
868
890
  startedAt: string;
869
891
  }
892
+ /** Per-scope atomic state directory so concurrent OS processes never overwrite each other's daemon records. */
893
+ declare function defaultDaemonStateDir(): string;
870
894
  /** Persist a warm WDA/UiAutomator2 session ID on an existing daemon record for cross-run reuse. */
871
895
  declare function updateWarmDaemonSession(kind: WarmDaemonKind, deviceId: string, sessionId: string, bundleId?: string, stateFile?: string): void;
872
896
  declare function listWarmDaemons(stateFile?: string): WarmDaemonRecord[];
873
897
  /**
874
- * Probe whether a recorded warm WDA / UiAutomator2 daemon is still healthy on
875
- * `GET http://<host>:<port>/status`. Removes stale records automatically.
898
+ * Probe whether a recorded warm WDA / UiAutomator2 / Chromium daemon is still healthy.
899
+ * Removes stale records automatically.
876
900
  */
877
901
  declare function getHealthyWarmDaemon(kind: WarmDaemonKind, deviceId: string, options?: {
878
902
  stateFile?: string;
@@ -882,11 +906,37 @@ declare function getHealthyWarmDaemon(kind: WarmDaemonKind, deviceId: string, op
882
906
  statusPath?: string;
883
907
  }): Promise<WarmDaemonRecord | null>;
884
908
  /**
885
- * Stop only the specific process PIDs started by Spana for this daemon record.
909
+ * Stop the specific process PIDs (and process groups) started by Spana for this daemon record.
886
910
  */
887
911
  declare function stopWarmDaemon(kind: WarmDaemonKind, deviceId: string, stateFile?: string): boolean;
888
912
  declare function stopAllWarmDaemons(stateFile?: string): number;
889
913
 
914
+ /** Probe the OS TCP stack to verify a port is genuinely bindable on `host`. */
915
+ declare function isPortAvailable(port: number, host?: string): Promise<boolean>;
916
+ /** Fail loudly if an explicitly requested port is already bound by another process. */
917
+ declare function assertPortAvailable(port: number, label?: string, host?: string): Promise<void>;
918
+ /**
919
+ * Allocate a genuinely free OS TCP port (safe across concurrent OS processes!),
920
+ * starting near `preferredBase` and falling back to an OS ephemeral port (`0`).
921
+ */
922
+ declare function allocateFreePort(preferredBase?: number, maxAttempts?: number, host?: string): Promise<number>;
923
+
924
+ interface CodeLocation {
925
+ file: string;
926
+ line: number;
927
+ column: number;
928
+ }
929
+ interface ExtractedCodeFrame {
930
+ location: CodeLocation;
931
+ frame: string;
932
+ }
933
+ declare function formatCodeFrame(source: string, line: number, column: number, contextLines?: number): string;
934
+ /**
935
+ * Extract the most relevant user-code location and annotated source snippet
936
+ * from an Error stack trace (Playwright-style code frame for failure triage).
937
+ */
938
+ declare function extractCodeFrame(stack: string | undefined, preferredFile?: string, contextLines?: number): ExtractedCodeFrame | undefined;
939
+
890
940
  interface ProviderRunResult {
891
941
  passed: boolean;
892
942
  name?: string;
@@ -1273,37 +1323,58 @@ declare function createApiClient(options: ApiClientOptions): ApiClient;
1273
1323
  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
1324
  interface PersonaDefinition<T extends string = string, R extends string = string> {
1275
1325
  name: string;
1276
- /** Sign in once (via API, virtual passkey, or UI) and return storage entries or a saved storageStatePath. */
1326
+ /** Sign in once (via API, virtual passkey, or UI) and return storage entries, storageStatePath, or virtualCredentials. */
1277
1327
  signIn: (ctx: FlowContext<T, R>) => Promise<{
1278
1328
  storage?: DomStorageEntries;
1279
1329
  storageStatePath?: string;
1330
+ virtualCredentials?: VirtualCredential[];
1280
1331
  } | void>;
1281
1332
  /** Optional cache key discriminator (e.g. base URL or tenant ID). */
1282
1333
  cacheKey?: string;
1283
1334
  /** Optional route to navigate to after restoring cached auth state. */
1284
1335
  navigateTo?: R;
1336
+ /** Automatically capture active WebAuthn virtual credentials after `signIn` and re-import into fresh contexts (default: true). */
1337
+ captureVirtualCredentials?: boolean;
1338
+ /** Options used when re-enabling the virtual authenticator on cache hits. */
1339
+ authenticatorOptions?: VirtualAuthenticatorOptions;
1285
1340
  }
1286
1341
  /** Define a reusable authenticated persona for `PersonaAuthCache`. */
1287
1342
  declare function definePersona<T extends string = string, R extends string = string>(name: string, config: Omit<PersonaDefinition<T, R>, "name">): PersonaDefinition<T, R>;
1288
1343
  interface CachedPersonaState {
1289
1344
  storage?: DomStorageEntries;
1290
1345
  storageStatePath?: string;
1346
+ virtualCredentials?: VirtualCredential[];
1291
1347
  cachedAt: number;
1292
1348
  }
1349
+ /**
1350
+ * Per-persona WebAuthn virtual passkey store that survives fresh browser contexts.
1351
+ * Save credentials after registering once (`store.save("alice", await app.getVirtualCredentials())`)
1352
+ * and restore them into any fresh context (`await store.restore("alice", app)`).
1353
+ */
1354
+ declare class VirtualCredentialStore {
1355
+ private readonly store;
1356
+ save(persona: string, credentials: VirtualCredential[]): void;
1357
+ get(persona: string): VirtualCredentialInput[];
1358
+ has(persona: string): boolean;
1359
+ clear(persona?: string): void;
1360
+ restore(persona: string, app: Pick<PromiseApp, "enableVirtualAuthenticator" | "addVirtualCredential">, opts?: VirtualAuthenticatorOptions): Promise<number>;
1361
+ }
1293
1362
  /**
1294
1363
  * 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.
1364
+ * Signs a persona in ONCE (including passkey / WebAuthn flows), caches its auth state
1365
+ * AND virtual passkey credentials, and restores them in milliseconds across fresh contexts.
1297
1366
  */
1298
1367
  declare class PersonaAuthCache {
1299
1368
  private readonly cache;
1300
1369
  private readonly inflight;
1370
+ readonly credentials: VirtualCredentialStore;
1301
1371
  private keyFor;
1302
1372
  get(name: string, cacheKey?: string): CachedPersonaState | undefined;
1303
1373
  invalidate(name?: string, cacheKey?: string): void;
1304
1374
  /**
1305
1375
  * 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.
1376
+ * once (coalescing concurrent callers); on cache hit, restores cookies/storageState and
1377
+ * imports any stored WebAuthn virtual passkeys directly into the fresh context.
1307
1378
  */
1308
1379
  authenticate<T extends string = string, R extends string = string>(persona: PersonaDefinition<T, R>, ctx: FlowContext<T, R>): Promise<CachedPersonaState>;
1309
1380
  }
@@ -1578,14 +1649,30 @@ interface ProcessPartitionPlan {
1578
1649
  processCount: number;
1579
1650
  workersPerProcess: number[];
1580
1651
  }
1652
+ interface SharedFlowQueueServer {
1653
+ /** Local loopback HTTP URL (e.g. `http://127.0.0.1:54321`) passed to child processes via `SPANA_QUEUE_URL`. */
1654
+ url: string;
1655
+ /** Number of unclaimed flows left in the queue. */
1656
+ remaining(): number;
1657
+ /** Shut down the loopback queue server cleanly. */
1658
+ close(): Promise<void>;
1659
+ }
1660
+ /**
1661
+ * Start a lightweight local HTTP work-stealing queue serving an already-ordered
1662
+ * (longest-first) list of flow names to `M` isolated OS worker processes.
1663
+ * Eliminates static `--shard` tail stragglers when running `spana test --workers N --processes M`.
1664
+ */
1665
+ declare function startSharedFlowQueueServer(orderedFlowNames: string[]): Promise<SharedFlowQueueServer>;
1666
+ /** Client helper for a worker process to claim the next flow name from `SPANA_QUEUE_URL`. */
1667
+ declare function createRemoteFlowClaimer(queueUrl: string): () => Promise<string | null>;
1581
1668
  /**
1582
1669
  * 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.
1670
+ * - When `explicitProcesses` is set (`--processes M`), splits `totalWorkers` evenly across
1671
+ * `min(explicitProcesses, totalWorkers)` isolated OS processes.
1672
+ * - Otherwise, up to `maxWorkersPerProcess` (default 8) runs in 1 in-process event loop,
1673
+ * and above that splits evenly across `Math.ceil(totalWorkers / maxWorkersPerProcess)` OS processes.
1587
1674
  */
1588
- declare function planProcessPool(totalWorkers: number, maxWorkersPerProcess?: number): ProcessPartitionPlan;
1675
+ declare function planProcessPool(totalWorkers: number, maxWorkersPerProcess?: number, explicitProcesses?: number): ProcessPartitionPlan;
1589
1676
  /**
1590
1677
  * Partition flows across `processCount` buckets using Longest-Processing-Time-First (LPT)
1591
1678
  * bin packing when `durationHintsMs` are available so every child process finishes together.
@@ -1611,9 +1698,11 @@ interface ProcessShardOutcome {
1611
1698
  interface MultiProcessPoolOptions {
1612
1699
  totalWorkers: number;
1613
1700
  maxWorkersPerProcess?: number;
1701
+ /** Explicit OS process count (`--processes M`). */
1702
+ processes?: number;
1614
1703
  buildShardCommand: (shardIndex: number, shardTotal: number, workerCount: number) => ProcessShardCommand;
1615
1704
  spawnFn?: typeof spawn;
1616
- readReportFn?: (reportJsonPath: string) => TestResult[];
1705
+ readReportFn?: (reportJsonPath: string) => TestResult[] | Promise<TestResult[]>;
1617
1706
  cleanupReportFiles?: boolean;
1618
1707
  }
1619
1708
  interface MultiProcessPoolResult {
@@ -1632,6 +1721,81 @@ interface MultiProcessPoolResult {
1632
1721
  */
1633
1722
  declare function runMultiProcessPool(options: MultiProcessPoolOptions): Promise<MultiProcessPoolResult>;
1634
1723
 
1724
+ type NetworkCacheMode = "record" | "replay" | "auto";
1725
+ interface CachedNetworkEntry {
1726
+ version: 1;
1727
+ key: string;
1728
+ method: string;
1729
+ url: string;
1730
+ status: number;
1731
+ contentType: string;
1732
+ headers?: Record<string, string>;
1733
+ body: string;
1734
+ recordedAt: string;
1735
+ }
1736
+ interface NetworkReplayCacheOptions {
1737
+ /** Directory where recorded API responses are stored. Default: `.spana/network-cache`. */
1738
+ cacheDir?: string;
1739
+ }
1740
+ declare function buildNetworkCacheKey(method: string, url: string): string;
1741
+ /**
1742
+ * Deterministic local HTTP API response cache (`.spana/network-cache/`).
1743
+ * Eliminates real-world backend/DB round-trip latency (often 60–80% of suite wall time)
1744
+ * by recording read-only API responses once and replaying them in <1ms via `app.mockNetwork`.
1745
+ */
1746
+ declare class NetworkReplayCache {
1747
+ readonly cacheDir: string;
1748
+ constructor(options?: NetworkReplayCacheOptions);
1749
+ private entryPath;
1750
+ get(method: string, url: string): CachedNetworkEntry | null;
1751
+ set(entry: Omit<CachedNetworkEntry, "version" | "key" | "recordedAt">): CachedNetworkEntry;
1752
+ /**
1753
+ * Fetch an endpoint live on cache miss (in `"record"` or `"auto"` mode) or return
1754
+ * the cached response in <1ms on cache hit (in `"replay"` or `"auto"` mode).
1755
+ */
1756
+ resolve(url: string, options?: {
1757
+ method?: string;
1758
+ mode?: NetworkCacheMode;
1759
+ headers?: Record<string, string>;
1760
+ fetchFn?: typeof fetch;
1761
+ }): Promise<{
1762
+ entry: CachedNetworkEntry;
1763
+ source: "cache" | "network";
1764
+ }>;
1765
+ }
1766
+ interface AttachNetworkCacheOptions {
1767
+ /** URLs (and optional route matchers) to pre-warm/replay via `app.mockNetwork`. */
1768
+ routes: Array<{
1769
+ url: string;
1770
+ matcher?: BrowserRouteMatcher;
1771
+ method?: string;
1772
+ headers?: Record<string, string>;
1773
+ }>;
1774
+ mode?: NetworkCacheMode;
1775
+ cacheDir?: string;
1776
+ fetchFn?: typeof fetch;
1777
+ }
1778
+ interface AttachNetworkCacheResult {
1779
+ cacheHits: number;
1780
+ networkFetches: number;
1781
+ totalRoutes: number;
1782
+ }
1783
+ /**
1784
+ * Attach deterministic recorded API mocks to any Spana `app` (`mockNetwork`-capable)
1785
+ * so read-only backend endpoints respond in <1ms locally instead of hitting live DBs.
1786
+ */
1787
+ declare function attachNetworkReplayCache(app: {
1788
+ mockNetwork(matcher: BrowserRouteMatcher, response: BrowserMockResponse): Promise<void>;
1789
+ }, options: AttachNetworkCacheOptions): Promise<AttachNetworkCacheResult>;
1790
+
1791
+ /**
1792
+ * Clone an existing iOS Simulator for parallel multi-worker CI execution (`xcrun simctl clone`).
1793
+ * Returns the newly created simulator UDID.
1794
+ */
1795
+ declare function cloneIOSSimulator(sourceUdid: string, cloneName: string): string;
1796
+ /** Shut down and delete a temporary cloned iOS Simulator (`xcrun simctl delete`). */
1797
+ declare function deleteIOSSimulator(udid: string): void;
1798
+
1635
1799
  /** MCP Tool definition advertised by `tools/list`. */
1636
1800
  interface McpToolDefinition {
1637
1801
  name: string;
@@ -1703,4 +1867,4 @@ declare class SpanaMcpServer {
1703
1867
  runStdio(): Promise<void>;
1704
1868
  }
1705
1869
 
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 };
1870
+ 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, 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, 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, replayRecordedAction, resolveElectrobunEngine, resolveElectrobunLaunchPlan, resolveElementAcrossChannels, resolveTargetDescriptor, resolveWebEngine, runMultiProcessPool, speculativelyPrelaunchWebBrowser, startAndroidVideoRecorder, startCdpScreencastRecorder, startIosSimulatorVideoRecorder, startSharedFlowQueueServer, stopAllWarmDaemons, stopWarmDaemon, tokenizeXmlNative, updateWarmDaemonSession };