spana-test 0.8.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.
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +5 -5
- package/dist/{app-CgbLADmF.d.ts → app-DSh1ejLh.d.ts} +97 -22
- package/dist/{chunk-NS2HLJO4.js → chunk-2KRVN4WN.js} +3 -3
- package/dist/{chunk-AJCSETN6.js → chunk-3UVSUVHW.js} +619 -174
- package/dist/chunk-3UVSUVHW.js.map +1 -0
- package/dist/{chunk-3FXDOTFI.js → chunk-ALPQES3J.js} +187 -36
- package/dist/chunk-ALPQES3J.js.map +1 -0
- package/dist/{chunk-PMXSU5MS.js → chunk-FP6PVHHR.js} +2 -2
- package/dist/{chunk-WKVU24B6.js → chunk-IGTK5MHB.js} +4 -4
- package/dist/{chunk-2T4K7BJ3.js → chunk-JZZ2W2XH.js} +3 -2
- package/dist/chunk-JZZ2W2XH.js.map +1 -0
- package/dist/{chunk-SNL4X67N.js → chunk-UEWZ2EXL.js} +352 -111
- package/dist/chunk-UEWZ2EXL.js.map +1 -0
- package/dist/{chunk-QP4MDUBY.js → chunk-VP6V4XEJ.js} +2 -2
- package/dist/{chunk-RKYKRGHB.js → chunk-Z6K4QQAR.js} +128 -6
- package/dist/chunk-Z6K4QQAR.js.map +1 -0
- package/dist/cli.js +9 -9
- package/dist/config-loader-F5YAY7RP.js +9 -0
- package/dist/{daemon-manager-DDYQITPD.js → daemon-manager-2EQDVUVM.js} +8 -2
- package/dist/{doctor-command-HEQQOYUR.js → doctor-command-YTCQ2SC7.js} +4 -4
- package/dist/{flow-Md5xLwbX.d.ts → flow-CSMwD9Fh.d.ts} +1 -1
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/index.d.ts +38 -8
- package/dist/index.js +25 -9
- package/dist/index.js.map +1 -1
- package/dist/{installer-IYGMG7LS.js → installer-5UHTYQTB.js} +3 -3
- package/dist/{server-JPNH33MX.js → server-4YLBAZEM.js} +6 -6
- package/dist/{server-4PEREPHY.js → server-IS4K5FCT.js} +2 -2
- package/dist/{session-D9e30RVS.d.ts → session-CgvT-Oso.d.ts} +3 -1
- package/dist/{session-V4PYJXNB.js → session-K7FCRKOC.js} +6 -6
- package/dist/{studio-command-JOIFCOHC.js → studio-command-RFPV2DS7.js} +2 -2
- package/dist/{test-command-JCO2HPYI.js → test-command-UEJG5AI6.js} +11 -9
- package/dist/test-command-UEJG5AI6.js.map +1 -0
- package/native/win32-x64/spana_native.dll +0 -0
- package/package.json +1 -1
- package/dist/chunk-2T4K7BJ3.js.map +0 -1
- package/dist/chunk-3FXDOTFI.js.map +0 -1
- package/dist/chunk-AJCSETN6.js.map +0 -1
- package/dist/chunk-RKYKRGHB.js.map +0 -1
- package/dist/chunk-SNL4X67N.js.map +0 -1
- package/dist/config-loader-5FU45FXK.js +0 -9
- package/dist/test-command-JCO2HPYI.js.map +0 -1
- /package/dist/{chunk-NS2HLJO4.js.map → chunk-2KRVN4WN.js.map} +0 -0
- /package/dist/{chunk-PMXSU5MS.js.map → chunk-FP6PVHHR.js.map} +0 -0
- /package/dist/{chunk-WKVU24B6.js.map → chunk-IGTK5MHB.js.map} +0 -0
- /package/dist/{chunk-QP4MDUBY.js.map → chunk-VP6V4XEJ.js.map} +0 -0
- /package/dist/{config-loader-5FU45FXK.js.map → config-loader-F5YAY7RP.js.map} +0 -0
- /package/dist/{daemon-manager-DDYQITPD.js.map → daemon-manager-2EQDVUVM.js.map} +0 -0
- /package/dist/{doctor-command-HEQQOYUR.js.map → doctor-command-YTCQ2SC7.js.map} +0 -0
- /package/dist/{installer-IYGMG7LS.js.map → installer-5UHTYQTB.js.map} +0 -0
- /package/dist/{server-JPNH33MX.js.map → server-4YLBAZEM.js.map} +0 -0
- /package/dist/{server-4PEREPHY.js.map → server-IS4K5FCT.js.map} +0 -0
- /package/dist/{session-V4PYJXNB.js.map → session-K7FCRKOC.js.map} +0 -0
- /package/dist/{studio-command-JOIFCOHC.js.map → studio-command-RFPV2DS7.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getHealthyWarmDaemon,
|
|
3
3
|
registerWarmDaemon
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-Z6K4QQAR.js";
|
|
5
5
|
import {
|
|
6
6
|
allocatePort,
|
|
7
7
|
releasePort
|
|
@@ -342,4 +342,4 @@ export {
|
|
|
342
342
|
setupWDAForDevice,
|
|
343
343
|
setupWDA
|
|
344
344
|
};
|
|
345
|
-
//# sourceMappingURL=chunk-
|
|
345
|
+
//# sourceMappingURL=chunk-VP6V4XEJ.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/runtime/daemon-manager.ts
|
|
2
|
+
import { execFileSync } from "child_process";
|
|
2
3
|
import { createHash } from "crypto";
|
|
3
4
|
import {
|
|
4
5
|
existsSync,
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
} from "fs";
|
|
13
14
|
import { tmpdir } from "os";
|
|
14
15
|
import { dirname, join } from "path";
|
|
16
|
+
var DEFAULT_WARM_DAEMON_IDLE_TTL_MS = 30 * 60 * 1e3;
|
|
15
17
|
function defaultDaemonStatePath() {
|
|
16
18
|
return join(tmpdir(), "spana-warm-daemons.json");
|
|
17
19
|
}
|
|
@@ -71,7 +73,7 @@ function deleteScopeRecord(kind, deviceId) {
|
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
function killPidTree(pid) {
|
|
74
|
-
if (!pid || pid <= 0) return;
|
|
76
|
+
if (!pid || pid <= 0 || pid === process.pid) return;
|
|
75
77
|
const targets = process.platform !== "win32" ? [-pid, pid] : [pid];
|
|
76
78
|
for (const target of targets) {
|
|
77
79
|
try {
|
|
@@ -108,6 +110,15 @@ function loadDaemonRegistry(stateFile = defaultDaemonStatePath()) {
|
|
|
108
110
|
function saveDaemonRegistry(registry, stateFile = defaultDaemonStatePath()) {
|
|
109
111
|
atomicWriteJson(stateFile, registry);
|
|
110
112
|
}
|
|
113
|
+
function resolveIdleTtlMs(explicit) {
|
|
114
|
+
if (explicit !== void 0) return explicit;
|
|
115
|
+
const envRaw = process.env["SPANA_DAEMON_IDLE_TTL_MS"];
|
|
116
|
+
if (envRaw !== void 0) {
|
|
117
|
+
const parsed = Number(envRaw);
|
|
118
|
+
if (Number.isFinite(parsed) && parsed >= 0) return parsed;
|
|
119
|
+
}
|
|
120
|
+
return DEFAULT_WARM_DAEMON_IDLE_TTL_MS;
|
|
121
|
+
}
|
|
111
122
|
function registerWarmDaemon(record, stateFile = defaultDaemonStatePath()) {
|
|
112
123
|
const key = daemonKey(record.kind, record.deviceId);
|
|
113
124
|
const existing = loadDaemonRegistry(stateFile);
|
|
@@ -118,11 +129,30 @@ function registerWarmDaemon(record, stateFile = defaultDaemonStatePath()) {
|
|
|
118
129
|
);
|
|
119
130
|
}
|
|
120
131
|
}
|
|
132
|
+
const prev = existing.daemons[key];
|
|
133
|
+
if (prev) {
|
|
134
|
+
if (prev.pid && prev.pid !== record.pid && isPidAlive(prev.pid)) {
|
|
135
|
+
killPidTree(prev.pid);
|
|
136
|
+
}
|
|
137
|
+
if (prev.tunnelPid && prev.tunnelPid !== record.tunnelPid && isPidAlive(prev.tunnelPid)) {
|
|
138
|
+
killPidTree(prev.tunnelPid);
|
|
139
|
+
}
|
|
140
|
+
if (prev.userDataDir && prev.userDataDir !== record.userDataDir) {
|
|
141
|
+
try {
|
|
142
|
+
rmSync(prev.userDataDir, { recursive: true, force: true });
|
|
143
|
+
} catch {
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const stamped = {
|
|
148
|
+
...record,
|
|
149
|
+
lastUsedAt: record.lastUsedAt ?? record.startedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
150
|
+
};
|
|
121
151
|
if (isUsingDefaultStateFile(stateFile)) {
|
|
122
|
-
atomicWriteJson(scopeRecordPath(record.kind, record.deviceId),
|
|
152
|
+
atomicWriteJson(scopeRecordPath(record.kind, record.deviceId), stamped);
|
|
123
153
|
return;
|
|
124
154
|
}
|
|
125
|
-
existing.daemons[key] =
|
|
155
|
+
existing.daemons[key] = stamped;
|
|
126
156
|
saveDaemonRegistry(existing, stateFile);
|
|
127
157
|
}
|
|
128
158
|
function updateWarmDaemonSession(kind, deviceId, sessionId, bundleId, stateFile = defaultDaemonStatePath()) {
|
|
@@ -173,8 +203,17 @@ async function getHealthyWarmDaemon(kind, deviceId, options = {}) {
|
|
|
173
203
|
const fetchFn = options.fetchFn ?? fetch;
|
|
174
204
|
const timeoutMs = options.timeoutMs ?? 1500;
|
|
175
205
|
const statusPath = options.statusPath ?? (kind === "chromium" ? "/json/version" : "/status");
|
|
206
|
+
const idleTtlMs = resolveIdleTtlMs(options.idleTtlMs);
|
|
207
|
+
const nowMs = options.nowMs ?? Date.now();
|
|
176
208
|
const record = isUsingDefaultStateFile(stateFile) ? readScopeRecord(kind, deviceId) ?? loadDaemonRegistry(stateFile).daemons[daemonKey(kind, deviceId)] : loadDaemonRegistry(stateFile).daemons[daemonKey(kind, deviceId)];
|
|
177
209
|
if (!record) return null;
|
|
210
|
+
if (idleTtlMs > 0) {
|
|
211
|
+
const lastTs = Date.parse(record.lastUsedAt ?? record.startedAt);
|
|
212
|
+
if (Number.isFinite(lastTs) && nowMs - lastTs > idleTtlMs) {
|
|
213
|
+
stopWarmDaemon(kind, deviceId, stateFile);
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
178
217
|
try {
|
|
179
218
|
const controller = new AbortController();
|
|
180
219
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -183,16 +222,93 @@ async function getHealthyWarmDaemon(kind, deviceId, options = {}) {
|
|
|
183
222
|
signal: controller.signal
|
|
184
223
|
});
|
|
185
224
|
if (res.ok) {
|
|
186
|
-
|
|
225
|
+
const touched = {
|
|
226
|
+
...record,
|
|
227
|
+
lastUsedAt: new Date(nowMs).toISOString()
|
|
228
|
+
};
|
|
229
|
+
if (isUsingDefaultStateFile(stateFile)) {
|
|
230
|
+
try {
|
|
231
|
+
atomicWriteJson(scopeRecordPath(kind, deviceId), touched);
|
|
232
|
+
} catch {
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
try {
|
|
236
|
+
const registry = loadDaemonRegistry(stateFile);
|
|
237
|
+
registry.daemons[daemonKey(kind, deviceId)] = touched;
|
|
238
|
+
saveDaemonRegistry(registry, stateFile);
|
|
239
|
+
} catch {
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return touched;
|
|
187
243
|
}
|
|
188
244
|
} finally {
|
|
189
245
|
clearTimeout(timer);
|
|
190
246
|
}
|
|
191
247
|
} catch {
|
|
192
248
|
}
|
|
193
|
-
|
|
249
|
+
stopWarmDaemon(kind, deviceId, stateFile);
|
|
194
250
|
return null;
|
|
195
251
|
}
|
|
252
|
+
function reapIdleWarmDaemons(options = {}) {
|
|
253
|
+
const stateFile = options.stateFile ?? defaultDaemonStatePath();
|
|
254
|
+
const idleTtlMs = resolveIdleTtlMs(options.idleTtlMs);
|
|
255
|
+
if (idleTtlMs <= 0) return 0;
|
|
256
|
+
const nowMs = options.nowMs ?? Date.now();
|
|
257
|
+
const records = listWarmDaemons(stateFile);
|
|
258
|
+
let reaped = 0;
|
|
259
|
+
for (const record of records) {
|
|
260
|
+
const lastTs = Date.parse(record.lastUsedAt ?? record.startedAt);
|
|
261
|
+
if (Number.isFinite(lastTs) && nowMs - lastTs > idleTtlMs) {
|
|
262
|
+
if (stopWarmDaemon(record.kind, record.deviceId, stateFile)) {
|
|
263
|
+
reaped++;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return reaped;
|
|
268
|
+
}
|
|
269
|
+
var SPANA_BROWSER_PROFILE_MARKERS = [
|
|
270
|
+
"spana-cdp-profile-",
|
|
271
|
+
"spana-pw-profile-",
|
|
272
|
+
"spana-browser-profile-"
|
|
273
|
+
];
|
|
274
|
+
function sweepOrphanedSpanaBrowsers(options = {}) {
|
|
275
|
+
if (process.platform === "win32") return 0;
|
|
276
|
+
let psOut = "";
|
|
277
|
+
try {
|
|
278
|
+
psOut = execFileSync("ps", ["-ax", "-o", "pid=,command="], {
|
|
279
|
+
encoding: "utf8",
|
|
280
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
281
|
+
});
|
|
282
|
+
} catch {
|
|
283
|
+
return 0;
|
|
284
|
+
}
|
|
285
|
+
const exclude = options.excludePids ?? /* @__PURE__ */ new Set();
|
|
286
|
+
let killed = 0;
|
|
287
|
+
const profileDirsToClean = /* @__PURE__ */ new Set();
|
|
288
|
+
for (const rawLine of psOut.split("\n")) {
|
|
289
|
+
const line = rawLine.trim();
|
|
290
|
+
if (!line) continue;
|
|
291
|
+
const match = /^(\d+)\s+(.*)$/.exec(line);
|
|
292
|
+
if (!match) continue;
|
|
293
|
+
const pid = Number.parseInt(match[1], 10);
|
|
294
|
+
const cmd = match[2] ?? "";
|
|
295
|
+
if (!Number.isFinite(pid) || pid <= 0 || pid === process.pid || exclude.has(pid)) continue;
|
|
296
|
+
if (!SPANA_BROWSER_PROFILE_MARKERS.some((marker) => cmd.includes(marker))) continue;
|
|
297
|
+
const dirMatch = /--user-data-dir=([^\s]+)/.exec(cmd);
|
|
298
|
+
if (dirMatch?.[1] && SPANA_BROWSER_PROFILE_MARKERS.some((m) => dirMatch[1].includes(m))) {
|
|
299
|
+
profileDirsToClean.add(dirMatch[1]);
|
|
300
|
+
}
|
|
301
|
+
killPidTree(pid);
|
|
302
|
+
killed++;
|
|
303
|
+
}
|
|
304
|
+
for (const dir of profileDirsToClean) {
|
|
305
|
+
try {
|
|
306
|
+
rmSync(dir, { recursive: true, force: true });
|
|
307
|
+
} catch {
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return killed;
|
|
311
|
+
}
|
|
196
312
|
function stopWarmDaemon(kind, deviceId, stateFile = defaultDaemonStatePath()) {
|
|
197
313
|
const key = daemonKey(kind, deviceId);
|
|
198
314
|
const record = isUsingDefaultStateFile(stateFile) ? readScopeRecord(kind, deviceId) ?? loadDaemonRegistry(stateFile).daemons[key] : loadDaemonRegistry(stateFile).daemons[key];
|
|
@@ -216,10 +332,14 @@ function stopAllWarmDaemons(stateFile = defaultDaemonStatePath()) {
|
|
|
216
332
|
stopped++;
|
|
217
333
|
}
|
|
218
334
|
}
|
|
335
|
+
if (isUsingDefaultStateFile(stateFile)) {
|
|
336
|
+
stopped += sweepOrphanedSpanaBrowsers();
|
|
337
|
+
}
|
|
219
338
|
return stopped;
|
|
220
339
|
}
|
|
221
340
|
|
|
222
341
|
export {
|
|
342
|
+
DEFAULT_WARM_DAEMON_IDLE_TTL_MS,
|
|
223
343
|
defaultDaemonStatePath,
|
|
224
344
|
defaultDaemonStateDir,
|
|
225
345
|
loadDaemonRegistry,
|
|
@@ -230,7 +350,9 @@ export {
|
|
|
230
350
|
listWarmDaemons,
|
|
231
351
|
isPidAlive,
|
|
232
352
|
getHealthyWarmDaemon,
|
|
353
|
+
reapIdleWarmDaemons,
|
|
354
|
+
sweepOrphanedSpanaBrowsers,
|
|
233
355
|
stopWarmDaemon,
|
|
234
356
|
stopAllWarmDaemons
|
|
235
357
|
};
|
|
236
|
-
//# sourceMappingURL=chunk-
|
|
358
|
+
//# sourceMappingURL=chunk-Z6K4QQAR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/daemon-manager.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n renameSync,\n rmSync,\n unlinkSync,\n writeFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nexport type WarmDaemonKind = \"wda\" | \"uiautomator2\" | \"iproxy\" | \"chromium\";\n\nexport const DEFAULT_WARM_DAEMON_IDLE_TTL_MS = 30 * 60 * 1000;\n\nexport interface WarmDaemonRecord {\n kind: WarmDaemonKind;\n deviceId: string;\n host: string;\n port: number;\n pid?: number;\n tunnelPid?: number;\n xctestrunPath?: string;\n /** Optional temporary profile directory created for this daemon (cleaned up on stop). */\n userDataDir?: string;\n /** Optional reusable WDA/UiAutomator2 session ID persisted across runs */\n sessionId?: string;\n bundleId?: string;\n startedAt: string;\n /** Last timestamp this daemon was verified healthy / reused (used for idle TTL reaping). */\n lastUsedAt?: string;\n}\n\ninterface DaemonRegistryFile {\n version: 1;\n daemons: Record<string, WarmDaemonRecord>;\n}\n\nexport function defaultDaemonStatePath(): string {\n return join(tmpdir(), \"spana-warm-daemons.json\");\n}\n\n/** Per-scope atomic state directory so concurrent OS processes never overwrite each other's daemon records. */\nexport function defaultDaemonStateDir(): string {\n return join(tmpdir(), \"spana-daemons\");\n}\n\nfunction daemonKey(kind: WarmDaemonKind, deviceId: string): string {\n return `${kind}:${deviceId}`;\n}\n\nfunction scopeRecordPath(kind: WarmDaemonKind, deviceId: string): string {\n const safe = `${kind}-${deviceId}`.replaceAll(/[^a-zA-Z0-9._-]/g, \"_\").slice(0, 64);\n const hash = createHash(\"sha256\").update(daemonKey(kind, deviceId)).digest(\"hex\").slice(0, 10);\n return join(defaultDaemonStateDir(), `${safe}-${hash}.json`);\n}\n\nfunction isUsingDefaultStateFile(stateFile?: string): boolean {\n return !stateFile || stateFile === defaultDaemonStatePath();\n}\n\nfunction atomicWriteJson(filePath: string, data: unknown): void {\n mkdirSync(dirname(filePath), { recursive: true });\n const tmpPath = `${filePath}.${process.pid}.${Math.random().toString(36).slice(2, 8)}.tmp`;\n writeFileSync(tmpPath, JSON.stringify(data, null, 2), \"utf-8\");\n renameSync(tmpPath, filePath);\n}\n\nfunction loadScopeRecords(): Record<string, WarmDaemonRecord> {\n const dir = defaultDaemonStateDir();\n const out: Record<string, WarmDaemonRecord> = {};\n if (!existsSync(dir)) return out;\n try {\n for (const file of readdirSync(dir)) {\n if (!file.endsWith(\".json\")) continue;\n try {\n const parsed = JSON.parse(readFileSync(join(dir, file), \"utf-8\")) as WarmDaemonRecord;\n if (parsed && typeof parsed.kind === \"string\" && typeof parsed.deviceId === \"string\") {\n out[daemonKey(parsed.kind, parsed.deviceId)] = parsed;\n }\n } catch {\n // skip corrupted scope file\n }\n }\n } catch {\n // ignore unreadable dir\n }\n return out;\n}\n\nfunction readScopeRecord(kind: WarmDaemonKind, deviceId: string): WarmDaemonRecord | undefined {\n const filePath = scopeRecordPath(kind, deviceId);\n if (!existsSync(filePath)) return undefined;\n try {\n return JSON.parse(readFileSync(filePath, \"utf-8\")) as WarmDaemonRecord;\n } catch {\n return undefined;\n }\n}\n\nfunction deleteScopeRecord(kind: WarmDaemonKind, deviceId: string): void {\n const filePath = scopeRecordPath(kind, deviceId);\n try {\n if (existsSync(filePath)) unlinkSync(filePath);\n } catch {\n // already removed\n }\n}\n\nfunction killPidTree(pid: number | undefined): void {\n if (!pid || pid <= 0 || pid === process.pid) return;\n const targets = process.platform !== \"win32\" ? [-pid, pid] : [pid];\n for (const target of targets) {\n try {\n process.kill(target, \"SIGTERM\");\n } catch {\n // process or group already exited\n }\n }\n // If the detached daemon ignores SIGTERM, escalate to SIGKILL immediately when still alive\n if (isPidAlive(pid)) {\n for (const target of targets) {\n try {\n process.kill(target, \"SIGKILL\");\n } catch {\n // already exited\n }\n }\n }\n}\n\nexport function loadDaemonRegistry(stateFile = defaultDaemonStatePath()): DaemonRegistryFile {\n const merged: Record<string, WarmDaemonRecord> = {};\n if (existsSync(stateFile)) {\n try {\n const raw = readFileSync(stateFile, \"utf-8\");\n const parsed = JSON.parse(raw) as DaemonRegistryFile;\n if (parsed && parsed.version === 1 && typeof parsed.daemons === \"object\") {\n Object.assign(merged, parsed.daemons);\n }\n } catch {\n // corrupted state file — reset cleanly\n }\n }\n if (isUsingDefaultStateFile(stateFile)) {\n Object.assign(merged, loadScopeRecords());\n }\n return { version: 1, daemons: merged };\n}\n\nexport function saveDaemonRegistry(\n registry: DaemonRegistryFile,\n stateFile = defaultDaemonStatePath(),\n): void {\n atomicWriteJson(stateFile, registry);\n}\n\nfunction resolveIdleTtlMs(explicit?: number): number {\n if (explicit !== undefined) return explicit;\n const envRaw = process.env[\"SPANA_DAEMON_IDLE_TTL_MS\"];\n if (envRaw !== undefined) {\n const parsed = Number(envRaw);\n if (Number.isFinite(parsed) && parsed >= 0) return parsed;\n }\n return DEFAULT_WARM_DAEMON_IDLE_TTL_MS;\n}\n\nexport function registerWarmDaemon(\n record: WarmDaemonRecord,\n stateFile = defaultDaemonStatePath(),\n): void {\n const key = daemonKey(record.kind, record.deviceId);\n const existing = loadDaemonRegistry(stateFile);\n // Fail loudly if another live daemon with a DIFFERENT scope already owns this exact host:port\n for (const [otherKey, other] of Object.entries(existing.daemons)) {\n if (\n otherKey !== key &&\n other.host === record.host &&\n other.port === record.port &&\n isPidAlive(other.pid)\n ) {\n throw new Error(\n `Warm daemon port clash on ${record.host}:${record.port}: scope \"${otherKey}\" (pid ${other.pid}) already owns this port.`,\n );\n }\n }\n\n // If this exact scope already had a previous live daemon PID, terminate & clean it up\n // before overwriting the scope record so we never orphan a running browser/daemon process.\n const prev = existing.daemons[key];\n if (prev) {\n if (prev.pid && prev.pid !== record.pid && isPidAlive(prev.pid)) {\n killPidTree(prev.pid);\n }\n if (prev.tunnelPid && prev.tunnelPid !== record.tunnelPid && isPidAlive(prev.tunnelPid)) {\n killPidTree(prev.tunnelPid);\n }\n if (prev.userDataDir && prev.userDataDir !== record.userDataDir) {\n try {\n rmSync(prev.userDataDir, { recursive: true, force: true });\n } catch {\n // ignore temp profile cleanup error\n }\n }\n }\n\n const stamped: WarmDaemonRecord = {\n ...record,\n lastUsedAt: record.lastUsedAt ?? record.startedAt ?? new Date().toISOString(),\n };\n\n if (isUsingDefaultStateFile(stateFile)) {\n atomicWriteJson(scopeRecordPath(record.kind, record.deviceId), stamped);\n return;\n }\n\n existing.daemons[key] = stamped;\n saveDaemonRegistry(existing, stateFile);\n}\n\n/** Persist a warm WDA/UiAutomator2 session ID on an existing daemon record for cross-run reuse. */\nexport function updateWarmDaemonSession(\n kind: WarmDaemonKind,\n deviceId: string,\n sessionId: string,\n bundleId?: string,\n stateFile = defaultDaemonStatePath(),\n): void {\n if (isUsingDefaultStateFile(stateFile)) {\n const scopeRec = readScopeRecord(kind, deviceId);\n if (scopeRec) {\n atomicWriteJson(scopeRecordPath(kind, deviceId), {\n ...scopeRec,\n sessionId,\n ...(bundleId ? { bundleId } : {}),\n });\n return;\n }\n }\n const registry = loadDaemonRegistry(stateFile);\n const key = daemonKey(kind, deviceId);\n const existing = registry.daemons[key];\n if (!existing) return;\n registry.daemons[key] = { ...existing, sessionId, ...(bundleId ? { bundleId } : {}) };\n saveDaemonRegistry(registry, stateFile);\n}\n\nexport function unregisterWarmDaemon(\n kind: WarmDaemonKind,\n deviceId: string,\n stateFile = defaultDaemonStatePath(),\n): void {\n if (isUsingDefaultStateFile(stateFile)) {\n deleteScopeRecord(kind, deviceId);\n }\n if (existsSync(stateFile)) {\n const raw = loadDaemonRegistry(stateFile);\n if (daemonKey(kind, deviceId) in raw.daemons) {\n delete raw.daemons[daemonKey(kind, deviceId)];\n saveDaemonRegistry(raw, stateFile);\n }\n }\n}\n\nexport function listWarmDaemons(stateFile = defaultDaemonStatePath()): WarmDaemonRecord[] {\n return Object.values(loadDaemonRegistry(stateFile).daemons);\n}\n\nexport function isPidAlive(pid: number | undefined): boolean {\n if (!pid || pid <= 0) return false;\n try {\n process.kill(pid, 0);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Probe whether a recorded warm WDA / UiAutomator2 / Chromium daemon is still healthy.\n * Removes stale or idle-expired records automatically.\n */\nexport async function getHealthyWarmDaemon(\n kind: WarmDaemonKind,\n deviceId: string,\n options: {\n stateFile?: string;\n fetchFn?: typeof fetch;\n timeoutMs?: number;\n /** HTTP health endpoint path (default: \"/status\", use \"/json/version\" for chromium). */\n statusPath?: string;\n /** Idle TTL in ms (default: 30 minutes or `SPANA_DAEMON_IDLE_TTL_MS`). Pass 0 to disable. */\n idleTtlMs?: number;\n /** Current wall-clock time in ms (for deterministic testing). */\n nowMs?: number;\n } = {},\n): Promise<WarmDaemonRecord | null> {\n const stateFile = options.stateFile ?? defaultDaemonStatePath();\n const fetchFn = options.fetchFn ?? fetch;\n const timeoutMs = options.timeoutMs ?? 1500;\n const statusPath = options.statusPath ?? (kind === \"chromium\" ? \"/json/version\" : \"/status\");\n const idleTtlMs = resolveIdleTtlMs(options.idleTtlMs);\n const nowMs = options.nowMs ?? Date.now();\n\n const record = isUsingDefaultStateFile(stateFile)\n ? (readScopeRecord(kind, deviceId) ??\n loadDaemonRegistry(stateFile).daemons[daemonKey(kind, deviceId)])\n : loadDaemonRegistry(stateFile).daemons[daemonKey(kind, deviceId)];\n if (!record) return null;\n\n if (idleTtlMs > 0) {\n const lastTs = Date.parse(record.lastUsedAt ?? record.startedAt);\n if (Number.isFinite(lastTs) && nowMs - lastTs > idleTtlMs) {\n stopWarmDaemon(kind, deviceId, stateFile);\n return null;\n }\n }\n\n try {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n const res = await fetchFn(`http://${record.host}:${record.port}${statusPath}`, {\n signal: controller.signal,\n });\n if (res.ok) {\n const touched: WarmDaemonRecord = {\n ...record,\n lastUsedAt: new Date(nowMs).toISOString(),\n };\n if (isUsingDefaultStateFile(stateFile)) {\n try {\n atomicWriteJson(scopeRecordPath(kind, deviceId), touched);\n } catch {\n // ignore touch errors\n }\n } else {\n try {\n const registry = loadDaemonRegistry(stateFile);\n registry.daemons[daemonKey(kind, deviceId)] = touched;\n saveDaemonRegistry(registry, stateFile);\n } catch {\n // ignore touch errors\n }\n }\n return touched;\n }\n } finally {\n clearTimeout(timer);\n }\n } catch {\n // unreachable — prune stale entry\n }\n\n stopWarmDaemon(kind, deviceId, stateFile);\n return null;\n}\n\n/**\n * Stop any warm daemons whose `lastUsedAt` (or `startedAt`) exceeds `idleTtlMs`.\n */\nexport function reapIdleWarmDaemons(\n options: { stateFile?: string; idleTtlMs?: number; nowMs?: number } = {},\n): number {\n const stateFile = options.stateFile ?? defaultDaemonStatePath();\n const idleTtlMs = resolveIdleTtlMs(options.idleTtlMs);\n if (idleTtlMs <= 0) return 0;\n const nowMs = options.nowMs ?? Date.now();\n const records = listWarmDaemons(stateFile);\n let reaped = 0;\n for (const record of records) {\n const lastTs = Date.parse(record.lastUsedAt ?? record.startedAt);\n if (Number.isFinite(lastTs) && nowMs - lastTs > idleTtlMs) {\n if (stopWarmDaemon(record.kind, record.deviceId, stateFile)) {\n reaped++;\n }\n }\n }\n return reaped;\n}\n\nconst SPANA_BROWSER_PROFILE_MARKERS = [\n \"spana-cdp-profile-\",\n \"spana-pw-profile-\",\n \"spana-browser-profile-\",\n];\n\n/**\n * Sweep orphaned Chromium processes launched by Spana (identified by Spana's unique\n * temporary `--user-data-dir=.../spana-*-profile-*` argument) whose PIDs are no longer\n * tracked in the daemon registry, and remove their temporary profile directories.\n */\nexport function sweepOrphanedSpanaBrowsers(options: { excludePids?: Set<number> } = {}): number {\n if (process.platform === \"win32\") return 0;\n let psOut = \"\";\n try {\n psOut = execFileSync(\"ps\", [\"-ax\", \"-o\", \"pid=,command=\"], {\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n });\n } catch {\n return 0;\n }\n\n const exclude = options.excludePids ?? new Set<number>();\n let killed = 0;\n const profileDirsToClean = new Set<string>();\n\n for (const rawLine of psOut.split(\"\\n\")) {\n const line = rawLine.trim();\n if (!line) continue;\n const match = /^(\\d+)\\s+(.*)$/.exec(line);\n if (!match) continue;\n const pid = Number.parseInt(match[1]!, 10);\n const cmd = match[2] ?? \"\";\n if (!Number.isFinite(pid) || pid <= 0 || pid === process.pid || exclude.has(pid)) continue;\n if (!SPANA_BROWSER_PROFILE_MARKERS.some((marker) => cmd.includes(marker))) continue;\n\n // Extract --user-data-dir=<path> for cleanup\n const dirMatch = /--user-data-dir=([^\\s]+)/.exec(cmd);\n if (dirMatch?.[1] && SPANA_BROWSER_PROFILE_MARKERS.some((m) => dirMatch[1]!.includes(m))) {\n profileDirsToClean.add(dirMatch[1]!);\n }\n\n killPidTree(pid);\n killed++;\n }\n\n for (const dir of profileDirsToClean) {\n try {\n rmSync(dir, { recursive: true, force: true });\n } catch {\n // ignore temp profile cleanup errors\n }\n }\n\n return killed;\n}\n\n/**\n * Stop the specific process PIDs (and process groups) started by Spana for this daemon record.\n */\nexport function stopWarmDaemon(\n kind: WarmDaemonKind,\n deviceId: string,\n stateFile = defaultDaemonStatePath(),\n): boolean {\n const key = daemonKey(kind, deviceId);\n const record = isUsingDefaultStateFile(stateFile)\n ? (readScopeRecord(kind, deviceId) ?? loadDaemonRegistry(stateFile).daemons[key])\n : loadDaemonRegistry(stateFile).daemons[key];\n if (!record) return false;\n\n killPidTree(record.pid);\n killPidTree(record.tunnelPid);\n\n if (record.userDataDir) {\n try {\n rmSync(record.userDataDir, { recursive: true, force: true });\n } catch {\n // ignore temp profile cleanup error\n }\n }\n\n unregisterWarmDaemon(kind, deviceId, stateFile);\n return true;\n}\n\nexport function stopAllWarmDaemons(stateFile = defaultDaemonStatePath()): number {\n const records = listWarmDaemons(stateFile);\n let stopped = 0;\n for (const record of records) {\n if (stopWarmDaemon(record.kind, record.deviceId, stateFile)) {\n stopped++;\n }\n }\n if (isUsingDefaultStateFile(stateFile)) {\n stopped += sweepOrphanedSpanaBrowsers();\n }\n return stopped;\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,SAAS,YAAY;AAIvB,IAAM,kCAAkC,KAAK,KAAK;AAyBlD,SAAS,yBAAiC;AAC/C,SAAO,KAAK,OAAO,GAAG,yBAAyB;AACjD;AAGO,SAAS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,gBAAgB,MAAM,QAAQ,KAAK,mBAAmB,SAAS,EAAE,QAAQ,GAAG,IAC7E,mBAAmB,SAAS,EAAE,QAAQ,GAAG;AAC7C,MAAI,CAAC,OAAQ,QAAO;AAEpB,cAAY,OAAO,GAAG;AACtB,cAAY,OAAO,SAAS;AAE5B,MAAI,OAAO,aAAa;AACtB,QAAI;AACF,aAAO,OAAO,aAAa,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IAC7D,QAAQ;AAAA,IAER;AAAA,EACF;AAEA,uBAAqB,MAAM,UAAU,SAAS;AAC9C,SAAO;AACT;AAEO,SAAS,mBAAmB,YAAY,uBAAuB,GAAW;AAC/E,QAAM,UAAU,gBAAgB,SAAS;AACzC,MAAI,UAAU;AACd,aAAW,UAAU,SAAS;AAC5B,QAAI,eAAe,OAAO,MAAM,OAAO,UAAU,SAAS,GAAG;AAC3D;AAAA,IACF;AAAA,EACF;AACA,MAAI,wBAAwB,SAAS,GAAG;AACtC,eAAW,2BAA2B;AAAA,EACxC;AACA,SAAO;AACT;","names":[]}
|
package/dist/cli.js
CHANGED
|
@@ -138,7 +138,7 @@ if (command === "test") {
|
|
|
138
138
|
flowPath = arg;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
const { runTestCommand } = await import("./test-command-
|
|
141
|
+
const { runTestCommand } = await import("./test-command-UEJG5AI6.js");
|
|
142
142
|
const success = await runTestCommand({
|
|
143
143
|
platforms,
|
|
144
144
|
tags,
|
|
@@ -186,7 +186,7 @@ if (command === "test") {
|
|
|
186
186
|
}
|
|
187
187
|
let config = {};
|
|
188
188
|
try {
|
|
189
|
-
const { loadConfig } = await import("./config-loader-
|
|
189
|
+
const { loadConfig } = await import("./config-loader-F5YAY7RP.js");
|
|
190
190
|
config = (await loadConfig({ configPath, allowMissing: true })).config;
|
|
191
191
|
} catch (error) {
|
|
192
192
|
const message = normalizeErrorMessage(error);
|
|
@@ -197,7 +197,7 @@ if (command === "test") {
|
|
|
197
197
|
}
|
|
198
198
|
process.exit(1);
|
|
199
199
|
}
|
|
200
|
-
const { connect } = await import("./session-
|
|
200
|
+
const { connect } = await import("./session-K7FCRKOC.js");
|
|
201
201
|
let session;
|
|
202
202
|
try {
|
|
203
203
|
session = await connect({
|
|
@@ -324,7 +324,7 @@ if (command === "test") {
|
|
|
324
324
|
configPath = arg;
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
const { loadConfig } = await import("./config-loader-
|
|
327
|
+
const { loadConfig } = await import("./config-loader-F5YAY7RP.js");
|
|
328
328
|
try {
|
|
329
329
|
const result = await loadConfig({ configPath });
|
|
330
330
|
if (jsonMode) {
|
|
@@ -375,7 +375,7 @@ if (command === "test") {
|
|
|
375
375
|
pretty = true;
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
|
-
const { runDoctorCommand } = await import("./doctor-command-
|
|
378
|
+
const { runDoctorCommand } = await import("./doctor-command-YTCQ2SC7.js");
|
|
379
379
|
const success = await runDoctorCommand({
|
|
380
380
|
configPath,
|
|
381
381
|
platforms,
|
|
@@ -398,13 +398,13 @@ if (command === "test") {
|
|
|
398
398
|
}
|
|
399
399
|
let config = {};
|
|
400
400
|
try {
|
|
401
|
-
const { loadConfig } = await import("./config-loader-
|
|
401
|
+
const { loadConfig } = await import("./config-loader-F5YAY7RP.js");
|
|
402
402
|
config = (await loadConfig({ configPath, allowMissing: true })).config;
|
|
403
403
|
} catch (error) {
|
|
404
404
|
console.log(error instanceof Error ? error.message : String(error));
|
|
405
405
|
process.exit(1);
|
|
406
406
|
}
|
|
407
|
-
const { runStudioCommand } = await import("./studio-command-
|
|
407
|
+
const { runStudioCommand } = await import("./studio-command-RFPV2DS7.js");
|
|
408
408
|
await runStudioCommand({ port, open, config });
|
|
409
409
|
} else if (command === "init") {
|
|
410
410
|
const force = args.includes("--force");
|
|
@@ -491,7 +491,7 @@ if (command === "test") {
|
|
|
491
491
|
}
|
|
492
492
|
} else if (command === "daemon") {
|
|
493
493
|
const sub = args[1] ?? "status";
|
|
494
|
-
const { listWarmDaemons, stopAllWarmDaemons } = await import("./daemon-manager-
|
|
494
|
+
const { listWarmDaemons, stopAllWarmDaemons } = await import("./daemon-manager-2EQDVUVM.js");
|
|
495
495
|
if (sub === "stop") {
|
|
496
496
|
const count = stopAllWarmDaemons();
|
|
497
497
|
console.log(`Stopped ${count} warm daemon(s).`);
|
|
@@ -508,7 +508,7 @@ if (command === "test") {
|
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
510
|
} else if (command === "mcp") {
|
|
511
|
-
const { SpanaMcpServer } = await import("./server-
|
|
511
|
+
const { SpanaMcpServer } = await import("./server-IS4K5FCT.js");
|
|
512
512
|
const server = new SpanaMcpServer();
|
|
513
513
|
await server.runStdio();
|
|
514
514
|
} else if (command === "version" || args.includes("--version") || args.includes("-v")) {
|
|
@@ -1,30 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_WARM_DAEMON_IDLE_TTL_MS,
|
|
2
3
|
defaultDaemonStateDir,
|
|
3
4
|
defaultDaemonStatePath,
|
|
4
5
|
getHealthyWarmDaemon,
|
|
5
6
|
isPidAlive,
|
|
6
7
|
listWarmDaemons,
|
|
7
8
|
loadDaemonRegistry,
|
|
9
|
+
reapIdleWarmDaemons,
|
|
8
10
|
registerWarmDaemon,
|
|
9
11
|
saveDaemonRegistry,
|
|
10
12
|
stopAllWarmDaemons,
|
|
11
13
|
stopWarmDaemon,
|
|
14
|
+
sweepOrphanedSpanaBrowsers,
|
|
12
15
|
unregisterWarmDaemon,
|
|
13
16
|
updateWarmDaemonSession
|
|
14
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-Z6K4QQAR.js";
|
|
15
18
|
import "./chunk-DGUM43GV.js";
|
|
16
19
|
export {
|
|
20
|
+
DEFAULT_WARM_DAEMON_IDLE_TTL_MS,
|
|
17
21
|
defaultDaemonStateDir,
|
|
18
22
|
defaultDaemonStatePath,
|
|
19
23
|
getHealthyWarmDaemon,
|
|
20
24
|
isPidAlive,
|
|
21
25
|
listWarmDaemons,
|
|
22
26
|
loadDaemonRegistry,
|
|
27
|
+
reapIdleWarmDaemons,
|
|
23
28
|
registerWarmDaemon,
|
|
24
29
|
saveDaemonRegistry,
|
|
25
30
|
stopAllWarmDaemons,
|
|
26
31
|
stopWarmDaemon,
|
|
32
|
+
sweepOrphanedSpanaBrowsers,
|
|
27
33
|
unregisterWarmDaemon,
|
|
28
34
|
updateWarmDaemonSession
|
|
29
35
|
};
|
|
30
|
-
//# sourceMappingURL=daemon-manager-
|
|
36
|
+
//# sourceMappingURL=daemon-manager-2EQDVUVM.js.map
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
isWebKitDebugProxyInstalled,
|
|
5
5
|
resolveElectrobunLaunchPlan,
|
|
6
6
|
resolveTargetDescriptor
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-UEWZ2EXL.js";
|
|
8
8
|
import {
|
|
9
9
|
listWarmDaemons
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-Z6K4QQAR.js";
|
|
11
11
|
import "./chunk-JPZCZHL4.js";
|
|
12
12
|
import "./chunk-2AFWVHQK.js";
|
|
13
13
|
import "./chunk-DGUM43GV.js";
|
|
@@ -135,7 +135,7 @@ async function collectDoctorReport(options) {
|
|
|
135
135
|
const checks = [];
|
|
136
136
|
let loadedConfig = {};
|
|
137
137
|
try {
|
|
138
|
-
const { loadConfig } = await import("./config-loader-
|
|
138
|
+
const { loadConfig } = await import("./config-loader-F5YAY7RP.js");
|
|
139
139
|
const loaded = await loadConfig({ configPath: options.configPath, allowMissing: true });
|
|
140
140
|
loadedConfig = loaded.config;
|
|
141
141
|
checks.push({
|
|
@@ -383,4 +383,4 @@ export {
|
|
|
383
383
|
collectDoctorReport,
|
|
384
384
|
runDoctorCommand
|
|
385
385
|
};
|
|
386
|
-
//# sourceMappingURL=doctor-command-
|
|
386
|
+
//# sourceMappingURL=doctor-command-YTCQ2SC7.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as BrowserName,
|
|
1
|
+
import { p as BrowserName, a9 as StorybookConfig, v as PromiseApp, E as ExtendedSelector, a3 as PromiseExpectation, a2 as PromiseExpectFn, P as Platform, Z as LaunchOptions, w as ArtifactConfig } from './app-DSh1ejLh.js';
|
|
2
2
|
|
|
3
3
|
interface SecondarySessionOptions {
|
|
4
4
|
name: string;
|
package/dist/gherkin/steps.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as FlowDefinition, F as FlowContext, b as FlowConfig } from './flow-
|
|
2
|
-
export { c as FlowFn, S as SecondarySession, d as SecondarySessionOptions, e as Sessions, f as flow } from './flow-
|
|
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-
|
|
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
|
|
5
|
-
import { E as Element, B as Bounds, C as ConnectOptions, S as Session } from './session-
|
|
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';
|
|
@@ -343,7 +343,8 @@ declare class CdpDomChannel implements DomChannel {
|
|
|
343
343
|
setFrameOffsetResolver(resolver: CdpFrameOffsetResolver | undefined): void;
|
|
344
344
|
onEvent(method: string, listener: (params: any, sessionId?: string) => void): () => void;
|
|
345
345
|
waitForEvent<T = any>(method: string, timeoutMs?: number, predicate?: (params: T, sessionId?: string) => boolean): Promise<T>;
|
|
346
|
-
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;
|
|
347
348
|
evaluateOnSession<T = unknown>(sessionId: string | null | undefined, script: string | ((...args: any[]) => T), ...args: any[]): Promise<T>;
|
|
348
349
|
evaluate<T = unknown>(script: string | ((...args: any[]) => T), ...args: any[]): Promise<T>;
|
|
349
350
|
private applyChildOffset;
|
|
@@ -765,6 +766,7 @@ interface LightweightCdpDriverOptions {
|
|
|
765
766
|
fetchFn?: typeof fetch;
|
|
766
767
|
createWebSocket?: WebSocketFactory;
|
|
767
768
|
}
|
|
769
|
+
declare const UPLOAD_ATTACH_TIMEOUT_MS = 30000;
|
|
768
770
|
/**
|
|
769
771
|
* Direct CDP Chromium / Lightpanda driver speaking raw WebSocket CDP directly
|
|
770
772
|
* from Bun/Node to the browser — completely eliminating Playwright's Node
|
|
@@ -874,6 +876,7 @@ interface ElectrobunDriverOptions extends ElectrobunAppConfig {
|
|
|
874
876
|
declare function makeElectrobunDriver(options: ElectrobunDriverOptions): Effect.Effect<RawDriverService, DriverError>;
|
|
875
877
|
|
|
876
878
|
type WarmDaemonKind = "wda" | "uiautomator2" | "iproxy" | "chromium";
|
|
879
|
+
declare const DEFAULT_WARM_DAEMON_IDLE_TTL_MS: number;
|
|
877
880
|
interface WarmDaemonRecord {
|
|
878
881
|
kind: WarmDaemonKind;
|
|
879
882
|
deviceId: string;
|
|
@@ -888,6 +891,8 @@ interface WarmDaemonRecord {
|
|
|
888
891
|
sessionId?: string;
|
|
889
892
|
bundleId?: string;
|
|
890
893
|
startedAt: string;
|
|
894
|
+
/** Last timestamp this daemon was verified healthy / reused (used for idle TTL reaping). */
|
|
895
|
+
lastUsedAt?: string;
|
|
891
896
|
}
|
|
892
897
|
/** Per-scope atomic state directory so concurrent OS processes never overwrite each other's daemon records. */
|
|
893
898
|
declare function defaultDaemonStateDir(): string;
|
|
@@ -896,7 +901,7 @@ declare function updateWarmDaemonSession(kind: WarmDaemonKind, deviceId: string,
|
|
|
896
901
|
declare function listWarmDaemons(stateFile?: string): WarmDaemonRecord[];
|
|
897
902
|
/**
|
|
898
903
|
* Probe whether a recorded warm WDA / UiAutomator2 / Chromium daemon is still healthy.
|
|
899
|
-
* Removes stale records automatically.
|
|
904
|
+
* Removes stale or idle-expired records automatically.
|
|
900
905
|
*/
|
|
901
906
|
declare function getHealthyWarmDaemon(kind: WarmDaemonKind, deviceId: string, options?: {
|
|
902
907
|
stateFile?: string;
|
|
@@ -904,7 +909,27 @@ declare function getHealthyWarmDaemon(kind: WarmDaemonKind, deviceId: string, op
|
|
|
904
909
|
timeoutMs?: number;
|
|
905
910
|
/** HTTP health endpoint path (default: "/status", use "/json/version" for chromium). */
|
|
906
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;
|
|
907
916
|
}): Promise<WarmDaemonRecord | null>;
|
|
917
|
+
/**
|
|
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;
|
|
908
933
|
/**
|
|
909
934
|
* Stop the specific process PIDs (and process groups) started by Spana for this daemon record.
|
|
910
935
|
*/
|
|
@@ -1715,6 +1740,11 @@ interface MultiProcessPoolResult {
|
|
|
1715
1740
|
processCount: number;
|
|
1716
1741
|
processResults: ProcessShardOutcome[];
|
|
1717
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>;
|
|
1718
1748
|
/**
|
|
1719
1749
|
* Execute a high-concurrency suite (16–32+ workers) across multiple OS worker processes,
|
|
1720
1750
|
* each running up to `maxWorkersPerProcess` in-process workers with its own JS heap & event loop.
|
|
@@ -1867,4 +1897,4 @@ declare class SpanaMcpServer {
|
|
|
1867
1897
|
runStdio(): Promise<void>;
|
|
1868
1898
|
}
|
|
1869
1899
|
|
|
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 };
|
|
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 };
|