@testver/testver 1.2.5 → 1.2.6
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/index.js +733 -149
- package/dist/py-agent/testver_appium.py +553 -535
- package/dist/wdio-attach-service/index.cjs +236 -215
- package/dist/wdio-bootstrap/bootstrap.cjs +687 -666
- package/package.json +172 -172
- package/src/ui/static/assets/{index-YXt8A_Wf.js → index-CdvPhYu6.js} +616 -616
- package/src/ui/static/assets/{index-ageOJI9W.js → index-D8o46FhP.js} +1 -1
- package/src/ui/static/index.html +1 -1
package/dist/index.js
CHANGED
|
@@ -7847,7 +7847,7 @@ async function resolveLocalDeviceKey(deviceKey, explicitAdbPath) {
|
|
|
7847
7847
|
if (!deviceKey.startsWith(AVD_KEY_PREFIX)) return deviceKey;
|
|
7848
7848
|
return startAvd(deviceKey.slice(AVD_KEY_PREFIX.length), explicitAdbPath);
|
|
7849
7849
|
}
|
|
7850
|
-
async function captureAndroidScreenshotViaAdb(serial, explicitAdbPath) {
|
|
7850
|
+
async function captureAndroidScreenshotViaAdb(serial, explicitAdbPath, opts = {}) {
|
|
7851
7851
|
if (!serial) return null;
|
|
7852
7852
|
const adbPath = await findAdb(explicitAdbPath);
|
|
7853
7853
|
if (!adbPath) return null;
|
|
@@ -7862,7 +7862,7 @@ async function captureAndroidScreenshotViaAdb(serial, explicitAdbPath) {
|
|
|
7862
7862
|
} catch {
|
|
7863
7863
|
}
|
|
7864
7864
|
resolve35(null);
|
|
7865
|
-
}, 5e3);
|
|
7865
|
+
}, opts.timeoutMs ?? 5e3);
|
|
7866
7866
|
child2.stdout?.on("data", (b) => chunks.push(b));
|
|
7867
7867
|
child2.stderr?.on("data", (b) => {
|
|
7868
7868
|
err5 += b.toString("utf-8");
|
|
@@ -8316,7 +8316,8 @@ var init_local_mobile_tools = __esm({
|
|
|
8316
8316
|
xcodeCache = null;
|
|
8317
8317
|
driversCache = null;
|
|
8318
8318
|
driversInFlight = null;
|
|
8319
|
-
WEBVIEW_HINT =
|
|
8319
|
+
WEBVIEW_HINT = // Appium 3 (and 2.13+) refuses a feature name without its driver scope.
|
|
8320
|
+
"Hybrid apps (webviews): start Appium with `appium --allow-insecure uiautomator2:chromedriver_autodownload` (Appium before 2.13: `--allow-insecure chromedriver_autodownload`) so Android webview automation gets a matching chromedriver automatically. The app must also call setWebContentsDebuggingEnabled(true) (debug builds) \u2014 without it the webview never registers a WEBVIEW_* context and only native-tree automation of its content is possible.";
|
|
8320
8321
|
statusInFlight = null;
|
|
8321
8322
|
}
|
|
8322
8323
|
});
|
|
@@ -9370,8 +9371,14 @@ var init_local_appium = __esm({
|
|
|
9370
9371
|
// at once would otherwise both use 8100); a real device also gets
|
|
9371
9372
|
// the WebDriverAgent signing from Settings when it's filled in.
|
|
9372
9373
|
...isIos ? iosSessionCaps(creds, opts.deviceKey) : {},
|
|
9373
|
-
//
|
|
9374
|
-
|
|
9374
|
+
// No Appium idle timeout (0) for Testver's own local sessions: Testver
|
|
9375
|
+
// ends them itself (tab closed → 2 min, idle → 10 min, End session,
|
|
9376
|
+
// shutdown). The timeout was dangerous here — a session whose
|
|
9377
|
+
// UiAutomator2 server another session on the device had restarted
|
|
9378
|
+
// timed out 600 s later, and that cleanup force-stopped the device's
|
|
9379
|
+
// server, crashing whatever session was live then. Cloud providers
|
|
9380
|
+
// keep theirs (each session has its own vendor device).
|
|
9381
|
+
"appium:newCommandTimeout": 0,
|
|
9375
9382
|
"appium:noReset": false,
|
|
9376
9383
|
"appium:fullReset": false,
|
|
9377
9384
|
// Android launch-verification hardening. UiAutomator2 polls for
|
|
@@ -10821,8 +10828,15 @@ var init_cloud_bridge = __esm({
|
|
|
10821
10828
|
// src/mobile/reuse-ticket-store.ts
|
|
10822
10829
|
var reuse_ticket_store_exports = {};
|
|
10823
10830
|
__export(reuse_ticket_store_exports, {
|
|
10831
|
+
liveSessionMatches: () => liveSessionMatches,
|
|
10824
10832
|
reuseTicketStore: () => reuseTicketStore
|
|
10825
10833
|
});
|
|
10834
|
+
function liveSessionMatches(live, run2) {
|
|
10835
|
+
if (!live || live.providerId !== run2.providerId) return false;
|
|
10836
|
+
if (run2.deviceName && live.deviceName && String(live.deviceName).toLowerCase() !== String(run2.deviceName).toLowerCase()) return false;
|
|
10837
|
+
if (run2.appId && live.appId && String(live.appId) !== String(run2.appId)) return false;
|
|
10838
|
+
return true;
|
|
10839
|
+
}
|
|
10826
10840
|
var logger10, DEFAULT_TTL_MS, ReuseTicketStore, reuseTicketStore;
|
|
10827
10841
|
var init_reuse_ticket_store = __esm({
|
|
10828
10842
|
"src/mobile/reuse-ticket-store.ts"() {
|
|
@@ -10845,6 +10859,7 @@ var init_reuse_ticket_store = __esm({
|
|
|
10845
10859
|
deviceName: capabilities.deviceName,
|
|
10846
10860
|
platformName: capabilities.platformName,
|
|
10847
10861
|
platformVersion: capabilities.platformVersion,
|
|
10862
|
+
...capabilities.appId ? { appId: capabilities.appId } : {},
|
|
10848
10863
|
liveViewUrl: info.liveViewUrl,
|
|
10849
10864
|
dashboardUrl: info.dashboardUrl,
|
|
10850
10865
|
expiresAt: Date.now() + ttlMs,
|
|
@@ -10952,6 +10967,7 @@ __export(appium_project_exports, {
|
|
|
10952
10967
|
appiumTestFiles: () => appiumTestFiles,
|
|
10953
10968
|
deleteWebDriverSession: () => deleteWebDriverSession,
|
|
10954
10969
|
endLocalAppiumSessions: () => endLocalAppiumSessions,
|
|
10970
|
+
localRunSessionIds: () => localRunSessionIds,
|
|
10955
10971
|
usesAppiumClient: () => usesAppiumClient
|
|
10956
10972
|
});
|
|
10957
10973
|
import { readFileSync as readFileSync11, readdirSync as readdirSync5 } from "fs";
|
|
@@ -11003,6 +11019,18 @@ async function deleteWebDriverSession(hubUrl, sessionId) {
|
|
|
11003
11019
|
});
|
|
11004
11020
|
}
|
|
11005
11021
|
async function endLocalAppiumSessions(o) {
|
|
11022
|
+
const base = o.appiumUrl.replace(/\/+$/, "");
|
|
11023
|
+
let ended = 0;
|
|
11024
|
+
for (const id of await localRunSessionIds(o)) {
|
|
11025
|
+
try {
|
|
11026
|
+
await deleteWebDriverSession(base, id);
|
|
11027
|
+
ended++;
|
|
11028
|
+
} catch {
|
|
11029
|
+
}
|
|
11030
|
+
}
|
|
11031
|
+
return ended;
|
|
11032
|
+
}
|
|
11033
|
+
async function localRunSessionIds(o) {
|
|
11006
11034
|
const base = o.appiumUrl.replace(/\/+$/, "");
|
|
11007
11035
|
let sessions = [];
|
|
11008
11036
|
for (const path2 of ["/appium/sessions", "/sessions"]) {
|
|
@@ -11016,19 +11044,15 @@ async function endLocalAppiumSessions(o) {
|
|
|
11016
11044
|
} catch {
|
|
11017
11045
|
}
|
|
11018
11046
|
}
|
|
11019
|
-
|
|
11047
|
+
const ids = [];
|
|
11020
11048
|
for (const s of sessions) {
|
|
11021
11049
|
if (!s?.id || s.id === o.keep || typeof s.created !== "number" || s.created < o.since - 2e3) continue;
|
|
11022
11050
|
const caps = s.capabilities ?? {};
|
|
11023
11051
|
const device = String(caps.udid ?? caps["appium:udid"] ?? caps.deviceUDID ?? caps.deviceName ?? caps["appium:deviceName"] ?? "");
|
|
11024
11052
|
if (o.udid && device && device !== o.udid) continue;
|
|
11025
|
-
|
|
11026
|
-
await deleteWebDriverSession(base, s.id);
|
|
11027
|
-
ended++;
|
|
11028
|
-
} catch {
|
|
11029
|
-
}
|
|
11053
|
+
ids.push(s.id);
|
|
11030
11054
|
}
|
|
11031
|
-
return
|
|
11055
|
+
return ids;
|
|
11032
11056
|
}
|
|
11033
11057
|
function appRefRejected(output, ref) {
|
|
11034
11058
|
if (!ref || !/^(bs|lt|storage):/i.test(ref)) return false;
|
|
@@ -11278,7 +11302,7 @@ var init_request_guard = __esm({
|
|
|
11278
11302
|
|
|
11279
11303
|
// src/ui/routes/request-schemas.ts
|
|
11280
11304
|
import { z } from "zod";
|
|
11281
|
-
var text, optText, password, name, email, code, token, setupBody, loginBody, login2faBody, challengeBody, forgotPasswordBody, resetPasswordBody, changePasswordBody, confirmPasswordBody, profileBody, createUserBody, updateUserBody, adminResetPasswordBody, stringOrList, envMap, runBody, runCommandsBody, region2, stringMap, cloudProviderBody, cloudTestBody, llmTestBody, llmActiveModelBody, mcpServerBody, outputFolderBody;
|
|
11305
|
+
var text, optText, password, name, email, code, token, setupBody, loginBody, login2faBody, challengeBody, forgotPasswordBody, resetPasswordBody, changePasswordBody, confirmPasswordBody, profileBody, createUserBody, updateUserBody, adminResetPasswordBody, stringOrList, envMap, deviceSessionBody, runBody, runCommandsBody, region2, stringMap, cloudProviderBody, cloudTestBody, llmTestBody, llmActiveModelBody, mcpServerBody, outputFolderBody;
|
|
11282
11306
|
var init_request_schemas = __esm({
|
|
11283
11307
|
"src/ui/routes/request-schemas.ts"() {
|
|
11284
11308
|
"use strict";
|
|
@@ -11315,6 +11339,7 @@ var init_request_schemas = __esm({
|
|
|
11315
11339
|
adminResetPasswordBody = z.looseObject({ newPassword: password });
|
|
11316
11340
|
stringOrList = z.union([text(5e6), z.array(text(1e5)).max(1e5)]).nullish();
|
|
11317
11341
|
envMap = z.record(text(1e4), z.union([text(1e5), z.number(), z.boolean()])).nullish();
|
|
11342
|
+
deviceSessionBody = z.looseObject({ runId: optText(200), token: optText(200), sessionId: optText(200) });
|
|
11318
11343
|
runBody = z.looseObject({
|
|
11319
11344
|
command: optText(5e6),
|
|
11320
11345
|
files: stringOrList,
|
|
@@ -23099,6 +23124,7 @@ __export(auto_heal_webdriver_exports, {
|
|
|
23099
23124
|
onWdFailureSignal: () => onWdFailureSignal,
|
|
23100
23125
|
onWdRunExit: () => onWdRunExit,
|
|
23101
23126
|
registerCdpPort: () => registerCdpPort,
|
|
23127
|
+
registerSessionSource: () => registerSessionSource,
|
|
23102
23128
|
registerWdRun: () => registerWdRun,
|
|
23103
23129
|
runOwningClientPort: () => runOwningClientPort,
|
|
23104
23130
|
wdCaptureGaps: () => wdCaptureGaps,
|
|
@@ -23163,7 +23189,7 @@ async function shadowTick(runId, entry2) {
|
|
|
23163
23189
|
entry2.capturing = false;
|
|
23164
23190
|
}
|
|
23165
23191
|
}
|
|
23166
|
-
if (entry2.endpoints.length === 0 && entry2.remoteSessions.length === 0 && entry2.cdpPorts.length === 0) return;
|
|
23192
|
+
if (entry2.endpoints.length === 0 && entry2.remoteSessions.length === 0 && entry2.cdpPorts.length === 0 && !entry2.sessionSource) return;
|
|
23167
23193
|
entry2.capturing = true;
|
|
23168
23194
|
try {
|
|
23169
23195
|
await captureAll(entry2, false);
|
|
@@ -23172,6 +23198,12 @@ async function shadowTick(runId, entry2) {
|
|
|
23172
23198
|
entry2.capturing = false;
|
|
23173
23199
|
}
|
|
23174
23200
|
}
|
|
23201
|
+
function registerSessionSource(runId, list) {
|
|
23202
|
+
const entry2 = runs.get(runId);
|
|
23203
|
+
if (!entry2 || !entry2.capture || entry2.endedAt) return;
|
|
23204
|
+
entry2.sessionSource = list;
|
|
23205
|
+
console.log(`[auto-heal] shadow capture watching the local Appium server (run ${runId})`);
|
|
23206
|
+
}
|
|
23175
23207
|
function registerCdpPort(runId, port) {
|
|
23176
23208
|
const entry2 = runs.get(runId);
|
|
23177
23209
|
if (!entry2 || entry2.cdpPorts.includes(port)) return;
|
|
@@ -23226,7 +23258,7 @@ function stopPolling(entry2) {
|
|
|
23226
23258
|
function onWdFailureSignal(runId) {
|
|
23227
23259
|
const entry2 = runs.get(runId);
|
|
23228
23260
|
if (!entry2 || !entry2.capture || entry2.capturing) return;
|
|
23229
|
-
if (entry2.endpoints.length === 0 && entry2.remoteSessions.length === 0 && entry2.cdpPorts.length === 0) return;
|
|
23261
|
+
if (entry2.endpoints.length === 0 && entry2.remoteSessions.length === 0 && entry2.cdpPorts.length === 0 && !entry2.sessionSource) return;
|
|
23230
23262
|
const now = Date.now();
|
|
23231
23263
|
if (now - entry2.lastAttempt < CAPTURE_THROTTLE_MS) return;
|
|
23232
23264
|
entry2.lastAttempt = now;
|
|
@@ -23246,7 +23278,7 @@ function onWdRunExit(runId, exitCode) {
|
|
|
23246
23278
|
if (!entry2) return;
|
|
23247
23279
|
entry2.endedAt = Date.now();
|
|
23248
23280
|
stopPolling(entry2);
|
|
23249
|
-
if (entry2.capture && exitCode !== 0 && (entry2.endpoints.length > 0 || entry2.remoteSessions.length > 0 || entry2.cdpPorts.length > 0) && !entry2.capturing) {
|
|
23281
|
+
if (entry2.capture && exitCode !== 0 && (entry2.endpoints.length > 0 || entry2.remoteSessions.length > 0 || entry2.cdpPorts.length > 0 || !!entry2.sessionSource) && !entry2.capturing) {
|
|
23250
23282
|
entry2.capturing = true;
|
|
23251
23283
|
void captureAll(entry2, true).catch(() => {
|
|
23252
23284
|
}).finally(() => {
|
|
@@ -23312,6 +23344,14 @@ async function captureAll(entry2, failure) {
|
|
|
23312
23344
|
for (const id of await listSessions(endpoint)) targets.push({ endpoint, id });
|
|
23313
23345
|
}
|
|
23314
23346
|
targets.push(...entry2.remoteSessions);
|
|
23347
|
+
if (entry2.sessionSource) {
|
|
23348
|
+
try {
|
|
23349
|
+
for (const t of await entry2.sessionSource()) {
|
|
23350
|
+
if (!targets.some((x) => x.id === t.id)) targets.push(t);
|
|
23351
|
+
}
|
|
23352
|
+
} catch {
|
|
23353
|
+
}
|
|
23354
|
+
}
|
|
23315
23355
|
for (const port of entry2.cdpPorts) {
|
|
23316
23356
|
const capture = await captureCdp(port, failure);
|
|
23317
23357
|
if (capture) storeCapture(entry2, capture);
|
|
@@ -25457,6 +25497,7 @@ function buildSiteMatchers(b) {
|
|
|
25457
25497
|
};
|
|
25458
25498
|
switch (b.strategy) {
|
|
25459
25499
|
case "id": {
|
|
25500
|
+
const short = androidIdName(b.raw);
|
|
25460
25501
|
const ctx = [
|
|
25461
25502
|
`\\b(?:Appium|Mobile)?By\\.(?:id|Id)${OPEN}`,
|
|
25462
25503
|
`\\b(?:Appium|Mobile)?By\\.ID${S},${S}`,
|
|
@@ -25473,7 +25514,15 @@ function buildSiteMatchers(b) {
|
|
|
25473
25514
|
...quotedForms([""], `#${b.raw}`, "css #id"),
|
|
25474
25515
|
...nativeForms(b.raw, "resourceId|resourceIdMatches", "UiSelector resourceId")
|
|
25475
25516
|
],
|
|
25476
|
-
...tail(b.raw)
|
|
25517
|
+
...tail(b.raw).slice(0, 2),
|
|
25518
|
+
// An Android resource-id the code builds from its short name —
|
|
25519
|
+
// byId('sign-in') → `id=com.shop:id/${name}`: the helper call holds
|
|
25520
|
+
// only the name, so only a bare new name may go in (replacementFor).
|
|
25521
|
+
...short ? [
|
|
25522
|
+
quotedForms([HELPER_CALL], short, "resource-id helper", FIRST_ARG_END, "hint"),
|
|
25523
|
+
quotedForms([HELPER_ANY_ARG], short, "resource-id helper (argument)", FIRST_ARG_END, "hint")
|
|
25524
|
+
] : [],
|
|
25525
|
+
...tail(b.raw).slice(2)
|
|
25477
25526
|
];
|
|
25478
25527
|
}
|
|
25479
25528
|
case "name": {
|
|
@@ -25621,7 +25670,15 @@ function renderSite(site, newValue) {
|
|
|
25621
25670
|
const v = site.encode === "xml" ? xmlEsc(newValue) : site.quoted ? escFor(newValue, site.quote) : newValue;
|
|
25622
25671
|
return site.find.slice(0, site.valueStart) + v + site.find.slice(site.valueEnd);
|
|
25623
25672
|
}
|
|
25673
|
+
function androidIdName(raw) {
|
|
25674
|
+
return /^[\w.]+:id\/(.+)$/.exec(raw)?.[1];
|
|
25675
|
+
}
|
|
25624
25676
|
function replacementFor(site, b, p2) {
|
|
25677
|
+
if (site.holds === "hint" && b.strategy === "id" && androidIdName(b.raw)) {
|
|
25678
|
+
const pkg = b.raw.slice(0, b.raw.indexOf(":id/"));
|
|
25679
|
+
const name2 = p2.value.startsWith(`${pkg}:id/`) ? androidIdName(p2.value) : !p2.value.includes(":id/") && /^[\w.-]+$/.test(p2.value) ? p2.value : void 0;
|
|
25680
|
+
return p2.valueIsName && name2 ? renderSite(site, name2) : site.find;
|
|
25681
|
+
}
|
|
25625
25682
|
if (site.holds === "hint") {
|
|
25626
25683
|
return p2.valueIsName ? renderSite(site, p2.value) : site.find;
|
|
25627
25684
|
}
|
|
@@ -32759,6 +32816,7 @@ import { spawn as spawn4 } from "child_process";
|
|
|
32759
32816
|
import { existsSync as existsSync53, unlinkSync as unlinkSync6, mkdirSync as mkdirSync19, writeFileSync as writeFileSync17, readdirSync as readdirSync30, readFileSync as readFileSync48, statSync as statSync25, rmSync as rmSync3 } from "fs";
|
|
32760
32817
|
import { dirname as dirname22, isAbsolute as isAbsolute14, join as join53, relative as relative22, resolve as resolvePath9 } from "path";
|
|
32761
32818
|
import { cpus } from "os";
|
|
32819
|
+
import { randomBytes as randomBytes5, timingSafeEqual as timingSafeEqual3 } from "crypto";
|
|
32762
32820
|
import { createServer as createNetServer } from "net";
|
|
32763
32821
|
function redactGridSecrets(text2) {
|
|
32764
32822
|
let out = text2;
|
|
@@ -32937,6 +32995,22 @@ function mountRunnerRoutes(app, wss, scanner, options, resultsStore4, cloudConfi
|
|
|
32937
32995
|
res.status(500).json({ error: error instanceof Error ? error.message : String(error) });
|
|
32938
32996
|
}
|
|
32939
32997
|
});
|
|
32998
|
+
app.post("/api/runner/device-session", validateBody(deviceSessionBody), (req, res) => {
|
|
32999
|
+
const b = req.body || {};
|
|
33000
|
+
const runId = String(b.runId || "");
|
|
33001
|
+
const sessionId = String(b.sessionId || "");
|
|
33002
|
+
const local = localDeviceRuns.get(runId);
|
|
33003
|
+
const given = Buffer.from(String(b.token || ""));
|
|
33004
|
+
const want = Buffer.from(local?.token || "");
|
|
33005
|
+
if (!local || given.length !== want.length || !timingSafeEqual3(given, want)) {
|
|
33006
|
+
return res.status(404).json({ error: "No local device run with this id and token." });
|
|
33007
|
+
}
|
|
33008
|
+
if (!/^[\w.-]{1,128}$/.test(sessionId)) return res.status(400).json({ error: "sessionId is not a WebDriver session id." });
|
|
33009
|
+
if (!local.sessionIds.includes(sessionId)) local.sessionIds.push(sessionId);
|
|
33010
|
+
Promise.resolve().then(() => (init_auto_heal_webdriver(), auto_heal_webdriver_exports)).then(({ attachRelaySession: attachRelaySession2 }) => attachRelaySession2(local.appiumUrl, sessionId, void 0, runId)).catch(() => {
|
|
33011
|
+
});
|
|
33012
|
+
res.status(204).end();
|
|
33013
|
+
});
|
|
32940
33014
|
app.post("/api/runner/run", validateBody(runBody), async (req, res) => {
|
|
32941
33015
|
let cleanupOnThrow;
|
|
32942
33016
|
try {
|
|
@@ -33211,9 +33285,9 @@ function mountRunnerRoutes(app, wss, scanner, options, resultsStore4, cloudConfi
|
|
|
33211
33285
|
code: "GRID_UNSUPPORTED_FRAMEWORK"
|
|
33212
33286
|
});
|
|
33213
33287
|
}
|
|
33214
|
-
const { reuseTicketStore: reuseTicketStore2 } = await Promise.resolve().then(() => (init_reuse_ticket_store(), reuse_ticket_store_exports));
|
|
33288
|
+
const { reuseTicketStore: reuseTicketStore2, liveSessionMatches: liveSessionMatches2 } = await Promise.resolve().then(() => (init_reuse_ticket_store(), reuse_ticket_store_exports));
|
|
33215
33289
|
const live = clientHeader ? reuseTicketStore2.peek(clientHeader) : null;
|
|
33216
|
-
const sameTarget =
|
|
33290
|
+
const sameTarget = liveSessionMatches2(live, { providerId: cloudProvider, deviceName, appId });
|
|
33217
33291
|
const claimedTicket = clientHeader && sameTarget ? reuseTicketStore2.claim(clientHeader) : null;
|
|
33218
33292
|
mobileBridgeClientId = clientHeader || void 0;
|
|
33219
33293
|
mobileBridgeClaimedSessionId = claimedTicket ? claimedTicket.sessionId : void 0;
|
|
@@ -33301,8 +33375,26 @@ function mountRunnerRoutes(app, wss, scanner, options, resultsStore4, cloudConfi
|
|
|
33301
33375
|
mobileBridgeUsedOverlay = true;
|
|
33302
33376
|
mobileWdioResults = placement.wdioResultsFile;
|
|
33303
33377
|
}
|
|
33378
|
+
const runDeviceSerial = isLocalAppium ? plan.env.TESTVER_DEVICE_UDID || deviceName : void 0;
|
|
33379
|
+
if (runDeviceSerial && !effectiveReuseId && options.mobileSessionPool) {
|
|
33380
|
+
try {
|
|
33381
|
+
await options.mobileSessionPool.releaseLocalDevice(runDeviceSerial, {
|
|
33382
|
+
exceptClientId: clientHeader || void 0,
|
|
33383
|
+
reason: `A test run started on ${runDeviceSerial}, so this session was closed \u2014 a local device runs one session at a time.`
|
|
33384
|
+
});
|
|
33385
|
+
} catch (err5) {
|
|
33386
|
+
console.warn(`[testver] Freeing ${runDeviceSerial} before the run failed:`, err5.message);
|
|
33387
|
+
}
|
|
33388
|
+
}
|
|
33304
33389
|
if (isLocalAppium && plan.env.APPIUM_URL) {
|
|
33305
33390
|
localAppiumTarget = { appiumUrl: plan.env.APPIUM_URL, udid: plan.env.TESTVER_DEVICE_UDID, since: Date.now(), keep: effectiveReuseId };
|
|
33391
|
+
if (options.port) {
|
|
33392
|
+
const token2 = randomBytes5(24).toString("hex");
|
|
33393
|
+
localDeviceRuns.set(runId, { token: token2, appiumUrl: plan.env.APPIUM_URL.replace(/\/+$/, ""), sessionIds: [] });
|
|
33394
|
+
runEnv.TESTVER_SESSION_REPORT_URL = `http://127.0.0.1:${options.port}/api/runner/device-session`;
|
|
33395
|
+
runEnv.TESTVER_SESSION_REPORT_TOKEN = token2;
|
|
33396
|
+
runEnv.TESTVER_RUN_ID = runId;
|
|
33397
|
+
}
|
|
33306
33398
|
}
|
|
33307
33399
|
if (options.port && clientHeader) {
|
|
33308
33400
|
runEnv.TESTVER_REPORTBACK_URL = `http://localhost:${options.port}`;
|
|
@@ -33384,15 +33476,16 @@ function mountRunnerRoutes(app, wss, scanner, options, resultsStore4, cloudConfi
|
|
|
33384
33476
|
console.warn("[testver] cloud session poller start failed:", err5.message);
|
|
33385
33477
|
}
|
|
33386
33478
|
}
|
|
33387
|
-
|
|
33479
|
+
const targetPlatform = plan.env.TESTVER_PLATFORM_NAME || platformName;
|
|
33480
|
+
if (cloudConfigStore && deviceName && targetPlatform && (isLocalAppium ? appId : plan.env.TESTVER_PLATFORM_VERSION)) {
|
|
33388
33481
|
try {
|
|
33389
33482
|
cloudConfigStore.setLastMobileTarget({
|
|
33390
33483
|
provider: cloudProvider,
|
|
33391
33484
|
appId: appId || void 0,
|
|
33392
|
-
appRef: plan.appUrl,
|
|
33485
|
+
appRef: isLocalAppium ? void 0 : plan.appUrl,
|
|
33393
33486
|
deviceName,
|
|
33394
|
-
platformName:
|
|
33395
|
-
platformVersion: plan.env.TESTVER_PLATFORM_VERSION,
|
|
33487
|
+
platformName: /ios/i.test(String(targetPlatform)) ? "iOS" : "Android",
|
|
33488
|
+
platformVersion: plan.env.TESTVER_PLATFORM_VERSION || "",
|
|
33396
33489
|
setAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
33397
33490
|
});
|
|
33398
33491
|
} catch (err5) {
|
|
@@ -33977,7 +34070,12 @@ function mountRunnerRoutes(app, wss, scanner, options, resultsStore4, cloudConfi
|
|
|
33977
34070
|
// AI Assistant's live session this run reused).
|
|
33978
34071
|
...mobileBridgeRun ? {
|
|
33979
34072
|
endSessions: async (reported) => {
|
|
34073
|
+
const local = localDeviceRuns.get(runId);
|
|
33980
34074
|
if (localAppiumTarget) await endLocalAppiumSessions(localAppiumTarget).catch(() => 0);
|
|
34075
|
+
for (const id of local?.sessionIds ?? []) {
|
|
34076
|
+
if (id === localAppiumTarget?.keep) continue;
|
|
34077
|
+
await deleteWebDriverSession(local.appiumUrl, id).catch(() => void 0);
|
|
34078
|
+
}
|
|
33981
34079
|
for (const s of reported) {
|
|
33982
34080
|
if (s.providerId === "local-appium" || !s.hubUrl || s.sessionId === mobileBridgeClaimedSessionId) continue;
|
|
33983
34081
|
await deleteWebDriverSession(s.hubUrl, s.sessionId).catch(() => void 0);
|
|
@@ -34013,10 +34111,18 @@ function mountRunnerRoutes(app, wss, scanner, options, resultsStore4, cloudConfi
|
|
|
34013
34111
|
Promise.all([
|
|
34014
34112
|
Promise.resolve().then(() => (init_auto_heal_webdriver(), auto_heal_webdriver_exports)),
|
|
34015
34113
|
Promise.resolve().then(() => (init_auto_heal_service(), auto_heal_service_exports))
|
|
34016
|
-
]).then(async ([{ registerWdRun: registerWdRun2, registerCdpPort: registerCdpPort2 }, { couldHealRun: couldHealRun2 }]) => {
|
|
34114
|
+
]).then(async ([{ registerWdRun: registerWdRun2, registerCdpPort: registerCdpPort2, registerSessionSource: registerSessionSource2 }, { couldHealRun: couldHealRun2 }]) => {
|
|
34017
34115
|
const capture = await couldHealRun2({ origin: reqOrigin, parentRunId: reqParentRunId }).catch(() => true);
|
|
34018
34116
|
registerWdRun2(runId, proc.pid, fw || "", { capture });
|
|
34019
34117
|
if (capture && cypressCdpPort) registerCdpPort2(runId, cypressCdpPort);
|
|
34118
|
+
if (capture && localAppiumTarget) {
|
|
34119
|
+
const target2 = localAppiumTarget;
|
|
34120
|
+
const endpoint = target2.appiumUrl.replace(/\/+$/, "");
|
|
34121
|
+
registerSessionSource2(runId, async () => [
|
|
34122
|
+
...target2.keep ? [target2.keep] : [],
|
|
34123
|
+
...await localRunSessionIds(target2)
|
|
34124
|
+
].map((id) => ({ endpoint, id })));
|
|
34125
|
+
}
|
|
34020
34126
|
}).catch(() => {
|
|
34021
34127
|
});
|
|
34022
34128
|
let estimatedDuration;
|
|
@@ -34517,6 +34623,7 @@ ${closing.stderr}`, mobileAppRef)) {
|
|
|
34517
34623
|
broadcast(wss, { type: "complete", runId, exitCode: code2 ?? 1, duration, passed: parsedPassed, failed: parsedFailed, user: triggeredBy });
|
|
34518
34624
|
pushActivity?.({ type: "complete", runId, exitCode: code2 ?? 1, duration, passed: parsedPassed, failed: parsedFailed, user: triggeredBy, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
34519
34625
|
activeRuns.delete(runId);
|
|
34626
|
+
localDeviceRuns.delete(runId);
|
|
34520
34627
|
gridAccepted.delete(runId);
|
|
34521
34628
|
releaseGridHold();
|
|
34522
34629
|
runHistory.unshift(result);
|
|
@@ -34540,6 +34647,7 @@ ${closing.stderr}`, mobileAppRef)) {
|
|
|
34540
34647
|
cancelledRunIds.delete(runId);
|
|
34541
34648
|
cancelledSessions.delete(runId);
|
|
34542
34649
|
activeRuns.delete(runId);
|
|
34650
|
+
localDeviceRuns.delete(runId);
|
|
34543
34651
|
gridAccepted.delete(runId);
|
|
34544
34652
|
runHistory.unshift(result);
|
|
34545
34653
|
if (runHistory.length > MAX_HISTORY2) runHistory.pop();
|
|
@@ -34677,6 +34785,7 @@ ${closing.stderr}`, mobileAppRef)) {
|
|
|
34677
34785
|
active.result.status = "cancelled";
|
|
34678
34786
|
active.result.endTime = (/* @__PURE__ */ new Date()).toISOString();
|
|
34679
34787
|
activeRuns.delete(runId);
|
|
34788
|
+
localDeviceRuns.delete(runId);
|
|
34680
34789
|
runHistory.unshift(active.result);
|
|
34681
34790
|
audit(req, "run.cancel", { resourceType: "test-run", resourceId: runId });
|
|
34682
34791
|
res.json({ runId, status: "cancelled" });
|
|
@@ -35551,7 +35660,7 @@ function broadcast(wss, message) {
|
|
|
35551
35660
|
}
|
|
35552
35661
|
}
|
|
35553
35662
|
}
|
|
35554
|
-
var GRID_SECRET_PATTERNS, GRID_CEILING_RE, gridAccepted, gridPreflightChain, gridRefusals, activeRuns, startingRuns, cancelBeforeStart, cancelledRunIds, cancelledSessions, STARTING_TTL_MS, WAITING_FOR_VENDOR_TURN, WAITING_FOR_REPORT_TURN, waitingRuns, headlessNoted, runHistory, MAX_HISTORY2, MAX_RUN_BUFFER_CHARS, cypressProgress, robotProgress, ReportTurnCancelled, reportTurns, PW_RUN_DIR_MAX_AGE_MS, PLAYWRIGHT_SWITCHES, PROVIDER_LABELS, BROWSERSTACK_NODE_SDK_VERSION, BROWSERSTACK_CYPRESS_CLI_VERSION, LAMBDATEST_CYPRESS_CLI_VERSION;
|
|
35663
|
+
var GRID_SECRET_PATTERNS, GRID_CEILING_RE, gridAccepted, gridPreflightChain, gridRefusals, activeRuns, localDeviceRuns, startingRuns, cancelBeforeStart, cancelledRunIds, cancelledSessions, STARTING_TTL_MS, WAITING_FOR_VENDOR_TURN, WAITING_FOR_REPORT_TURN, waitingRuns, headlessNoted, runHistory, MAX_HISTORY2, MAX_RUN_BUFFER_CHARS, cypressProgress, robotProgress, ReportTurnCancelled, reportTurns, PW_RUN_DIR_MAX_AGE_MS, PLAYWRIGHT_SWITCHES, PROVIDER_LABELS, BROWSERSTACK_NODE_SDK_VERSION, BROWSERSTACK_CYPRESS_CLI_VERSION, LAMBDATEST_CYPRESS_CLI_VERSION;
|
|
35555
35664
|
var init_api_runner = __esm({
|
|
35556
35665
|
"src/ui/routes/api-runner.ts"() {
|
|
35557
35666
|
"use strict";
|
|
@@ -35598,6 +35707,7 @@ var init_api_runner = __esm({
|
|
|
35598
35707
|
gridPreflightChain = Promise.resolve();
|
|
35599
35708
|
gridRefusals = /* @__PURE__ */ new Map();
|
|
35600
35709
|
activeRuns = /* @__PURE__ */ new Map();
|
|
35710
|
+
localDeviceRuns = /* @__PURE__ */ new Map();
|
|
35601
35711
|
startingRuns = /* @__PURE__ */ new Map();
|
|
35602
35712
|
cancelBeforeStart = /* @__PURE__ */ new Set();
|
|
35603
35713
|
cancelledRunIds = /* @__PURE__ */ new Set();
|
|
@@ -35766,6 +35876,16 @@ async function wrapAiRunForCloud(opts) {
|
|
|
35766
35876
|
throw new AiRunSetupError(resolvedProvider, err5.message);
|
|
35767
35877
|
}
|
|
35768
35878
|
const deviceSerial = isLocalAppium && plan.env.TESTVER_DEVICE_UDID || deviceName;
|
|
35879
|
+
if (isLocalAppium && !reuseSessionId && sessionPool && deviceSerial) {
|
|
35880
|
+
try {
|
|
35881
|
+
await sessionPool.releaseLocalDevice(deviceSerial, {
|
|
35882
|
+
exceptClientId: clientId,
|
|
35883
|
+
reason: `A test run started on ${deviceSerial}, so this session was closed \u2014 a local device runs one session at a time.`
|
|
35884
|
+
});
|
|
35885
|
+
} catch (err5) {
|
|
35886
|
+
logger16.warn(`Freeing ${deviceSerial} before the run failed: ${err5.message}`);
|
|
35887
|
+
}
|
|
35888
|
+
}
|
|
35769
35889
|
if (opts.uiPort && clientId) {
|
|
35770
35890
|
plan.env = {
|
|
35771
35891
|
...plan.env,
|
|
@@ -37548,7 +37668,7 @@ ${snap.tree}`;
|
|
|
37548
37668
|
|
|
37549
37669
|
${NOT_FOUND_HINTS}${tree}`;
|
|
37550
37670
|
}
|
|
37551
|
-
var VALID_STRATEGIES, NOT_FOUND_HINTS, mobileLaunchApp, mobileTap, mobileType, mobileSwipe, mobileScrollTo, mobileWaitFor, mobilePressKey, mobileAlert, mobileTapAt, mobileListContexts, mobileSwitchContext, mobileOrientation, mobileScreenshot, mobileSnapshot, mobileWait, mobileTools;
|
|
37671
|
+
var VALID_STRATEGIES, NOT_FOUND_HINTS, mobileLaunchApp, mobileTap, mobileType, mobileSwipe, mobileDrag, mobileScrollTo, mobileWaitFor, mobilePressKey, mobileAlert, mobileTapAt, mobileListContexts, mobileSwitchContext, mobileOrientation, mobileScreenshot, mobileSnapshot, mobileWait, mobileTools;
|
|
37552
37672
|
var init_mobile = __esm({
|
|
37553
37673
|
"src/core/tools/mobile.ts"() {
|
|
37554
37674
|
"use strict";
|
|
@@ -37666,21 +37786,36 @@ var init_mobile = __esm({
|
|
|
37666
37786
|
category: "mobile",
|
|
37667
37787
|
definition: {
|
|
37668
37788
|
name: "mobile_swipe",
|
|
37669
|
-
description: "Swipe
|
|
37789
|
+
description: "Swipe \u2014 for dismissing cards, carousels, or custom gestures. **Give the element** (`strategy` + `value`) and a `direction`: Testver finds where it is and swipes across it \u2014 the tree has no coordinates, so never measure screenshots or call adb for bounds. Coordinates (`fromX`/`fromY`/`toX`/`toY`, device pixels) only for a swipe that belongs to no element. **To reach an off-screen element, prefer mobile_scroll_to \u2014 it scrolls natively and verifies arrival.** Returns the settled accessibility tree after the swipe.",
|
|
37670
37790
|
parameters: {
|
|
37671
37791
|
type: "object",
|
|
37672
37792
|
properties: {
|
|
37793
|
+
strategy: { type: "string", enum: VALID_STRATEGIES, description: "Locator strategy of the element to swipe on. Default: accessibility-id." },
|
|
37794
|
+
value: { type: "string", description: "Locator value of the element to swipe on." },
|
|
37795
|
+
direction: { type: "string", enum: ["left", "right", "up", "down"], description: "Direction the finger moves, with an element." },
|
|
37673
37796
|
fromX: { type: "number" },
|
|
37674
37797
|
fromY: { type: "number" },
|
|
37675
37798
|
toX: { type: "number" },
|
|
37676
37799
|
toY: { type: "number" },
|
|
37677
|
-
durationMs: { type: "number", description: "Swipe duration. Default 400." }
|
|
37678
|
-
}
|
|
37679
|
-
required: ["fromX", "fromY", "toX", "toY"]
|
|
37800
|
+
durationMs: { type: "number", description: "Swipe duration. Default 300 on an element, 400 between coordinates." }
|
|
37801
|
+
}
|
|
37680
37802
|
}
|
|
37681
37803
|
},
|
|
37682
37804
|
handler: async (args2, ctx) => {
|
|
37683
37805
|
const adapter = getAdapter(ctx);
|
|
37806
|
+
if (args2.value) {
|
|
37807
|
+
const loc = parseLocator(args2);
|
|
37808
|
+
const direction = String(args2.direction || "left");
|
|
37809
|
+
if (!["left", "right", "up", "down"].includes(direction)) throw new Error("direction must be left, right, up or down.");
|
|
37810
|
+
if (!adapter.swipeElement) throw new Error("Swiping on an element is not supported by the active mobile adapter \u2014 use coordinates.");
|
|
37811
|
+
const res2 = await adapter.swipeElement(loc, direction, args2.durationMs ? Number(args2.durationMs) : void 0);
|
|
37812
|
+
step(ctx, "mobile_swipe", res2.success ? "ok" : "fail", `${direction} on ${loc.strategy}=${loc.value}`, loc.value, res2.error);
|
|
37813
|
+
if (!res2.success) return await failWithTree(adapter, `Swipe FAILED on ${loc.strategy}=${loc.value}: ${res2.error || "unknown"}`);
|
|
37814
|
+
return `Swiped ${direction} on ${loc.value}.${await freshTree(adapter)}`;
|
|
37815
|
+
}
|
|
37816
|
+
if ([args2.fromX, args2.fromY, args2.toX, args2.toY].some((v) => v === void 0 || Number.isNaN(Number(v)))) {
|
|
37817
|
+
throw new Error("Give the element to swipe on (strategy + value + direction), or all four coordinates.");
|
|
37818
|
+
}
|
|
37684
37819
|
const res = await adapter.swipe(
|
|
37685
37820
|
{ x: Number(args2.fromX), y: Number(args2.fromY) },
|
|
37686
37821
|
{ x: Number(args2.toX), y: Number(args2.toY) },
|
|
@@ -37696,6 +37831,34 @@ var init_mobile = __esm({
|
|
|
37696
37831
|
return `Swiped.${await freshTree(adapter)}`;
|
|
37697
37832
|
}
|
|
37698
37833
|
};
|
|
37834
|
+
mobileDrag = {
|
|
37835
|
+
category: "mobile",
|
|
37836
|
+
definition: {
|
|
37837
|
+
name: "mobile_drag",
|
|
37838
|
+
description: "Drag one element onto another \u2014 drag and drop, reordering a list, moving a slider handle onto a mark. Give both elements by locator; Testver finds where they are, presses the first, holds so the drag starts, moves onto the second and releases. No coordinates needed. Returns the settled accessibility tree after the drop.",
|
|
37839
|
+
parameters: {
|
|
37840
|
+
type: "object",
|
|
37841
|
+
properties: {
|
|
37842
|
+
fromStrategy: { type: "string", enum: VALID_STRATEGIES, description: "Locator strategy of the element to drag. Default: accessibility-id." },
|
|
37843
|
+
fromValue: { type: "string", description: "Locator value of the element to drag." },
|
|
37844
|
+
toStrategy: { type: "string", enum: VALID_STRATEGIES, description: "Locator strategy of the drop target. Default: accessibility-id." },
|
|
37845
|
+
toValue: { type: "string", description: "Locator value of the drop target." },
|
|
37846
|
+
durationMs: { type: "number", description: "How long the move takes. Default 1000 (slow enough for drag-and-drop)." }
|
|
37847
|
+
},
|
|
37848
|
+
required: ["fromValue", "toValue"]
|
|
37849
|
+
}
|
|
37850
|
+
},
|
|
37851
|
+
handler: async (args2, ctx) => {
|
|
37852
|
+
const adapter = getAdapter(ctx);
|
|
37853
|
+
if (!adapter.drag) throw new Error("Drag is not supported by the active mobile adapter.");
|
|
37854
|
+
const from = parseLocator({ strategy: args2.fromStrategy, value: args2.fromValue });
|
|
37855
|
+
const to = parseLocator({ strategy: args2.toStrategy, value: args2.toValue });
|
|
37856
|
+
const res = await adapter.drag(from, to, args2.durationMs ? Number(args2.durationMs) : void 0);
|
|
37857
|
+
step(ctx, "mobile_drag", res.success ? "ok" : "fail", `${from.value} \u2192 ${to.value}`, from.value, res.error);
|
|
37858
|
+
if (!res.success) return await failWithTree(adapter, `Drag FAILED from ${from.strategy}=${from.value} to ${to.strategy}=${to.value}: ${res.error || "unknown"}`);
|
|
37859
|
+
return `Dragged ${from.value} onto ${to.value}.${await freshTree(adapter)}`;
|
|
37860
|
+
}
|
|
37861
|
+
};
|
|
37699
37862
|
mobileScrollTo = {
|
|
37700
37863
|
category: "mobile",
|
|
37701
37864
|
definition: {
|
|
@@ -37969,6 +38132,7 @@ var init_mobile = __esm({
|
|
|
37969
38132
|
mobileTap,
|
|
37970
38133
|
mobileType,
|
|
37971
38134
|
mobileSwipe,
|
|
38135
|
+
mobileDrag,
|
|
37972
38136
|
mobileScrollTo,
|
|
37973
38137
|
mobileWaitFor,
|
|
37974
38138
|
mobilePressKey,
|
|
@@ -38191,22 +38355,22 @@ var init_ai_cloud_run = __esm({
|
|
|
38191
38355
|
|
|
38192
38356
|
// src/core/tools/test-runner.ts
|
|
38193
38357
|
import { spawn as spawn6 } from "child_process";
|
|
38194
|
-
import { existsSync as existsSync54, readFileSync as readFileSync49 } from "fs";
|
|
38358
|
+
import { existsSync as existsSync54, readFileSync as readFileSync49, rmSync as rmSync4 } from "fs";
|
|
38195
38359
|
import { isAbsolute as isAbsolute15, join as join55, relative as relative24, resolve as resolve13 } from "path";
|
|
38196
38360
|
function runCmd(command, cwd, timeout, extraEnv = {}, onCloseHook, meta) {
|
|
38197
38361
|
return new Promise((resolve35, reject) => {
|
|
38198
|
-
const treeKill = !!meta?.onTimeoutKill;
|
|
38199
38362
|
const proc = spawn6(command, [], {
|
|
38200
38363
|
cwd,
|
|
38201
|
-
...treeKill ? {} : { timeout },
|
|
38202
38364
|
env: { ...process.env, ...extraEnv },
|
|
38203
38365
|
stdio: ["pipe", "pipe", "pipe"],
|
|
38204
38366
|
shell: true
|
|
38205
38367
|
});
|
|
38206
|
-
|
|
38368
|
+
let timedOut = false;
|
|
38369
|
+
const timer = setTimeout(() => {
|
|
38370
|
+
timedOut = true;
|
|
38207
38371
|
void (async () => {
|
|
38208
38372
|
try {
|
|
38209
|
-
await meta
|
|
38373
|
+
await meta?.onTimeoutKill?.();
|
|
38210
38374
|
} catch {
|
|
38211
38375
|
}
|
|
38212
38376
|
if (proc.pid) await killTree(proc.pid).catch(() => false);
|
|
@@ -38217,7 +38381,7 @@ function runCmd(command, cwd, timeout, extraEnv = {}, onCloseHook, meta) {
|
|
|
38217
38381
|
}
|
|
38218
38382
|
}
|
|
38219
38383
|
})();
|
|
38220
|
-
}, timeout)
|
|
38384
|
+
}, timeout);
|
|
38221
38385
|
const runId = `ai-${generateId()}`;
|
|
38222
38386
|
if (meta?.track) {
|
|
38223
38387
|
try {
|
|
@@ -38234,11 +38398,11 @@ function runCmd(command, cwd, timeout, extraEnv = {}, onCloseHook, meta) {
|
|
|
38234
38398
|
stderr += data.toString();
|
|
38235
38399
|
});
|
|
38236
38400
|
proc.on("error", (err5) => {
|
|
38237
|
-
|
|
38401
|
+
clearTimeout(timer);
|
|
38238
38402
|
reject(err5);
|
|
38239
38403
|
});
|
|
38240
38404
|
proc.on("close", async (code2) => {
|
|
38241
|
-
|
|
38405
|
+
clearTimeout(timer);
|
|
38242
38406
|
if (meta?.track) {
|
|
38243
38407
|
try {
|
|
38244
38408
|
runClosed(runId);
|
|
@@ -38250,7 +38414,7 @@ function runCmd(command, cwd, timeout, extraEnv = {}, onCloseHook, meta) {
|
|
|
38250
38414
|
${stderr}` });
|
|
38251
38415
|
} catch {
|
|
38252
38416
|
}
|
|
38253
|
-
resolve35({ stdout, stderr, exitCode: code2 ?? 1 });
|
|
38417
|
+
resolve35({ stdout, stderr, exitCode: code2 ?? 1, ...timedOut ? { timedOut } : {} });
|
|
38254
38418
|
});
|
|
38255
38419
|
});
|
|
38256
38420
|
}
|
|
@@ -38464,7 +38628,7 @@ var init_test_runner = __esm({
|
|
|
38464
38628
|
},
|
|
38465
38629
|
cloud_provider: {
|
|
38466
38630
|
type: "string",
|
|
38467
|
-
description: "Leave this out for normal runs \u2014 tests run locally, and `browser` / `environment` pick the target (an environment such as \"Staging\" is NOT a cloud provider). Set it ONLY when the user asked to run on that cloud and it is set up in Settings: browserstack, lambdatest, saucelabs, or testver-grid. The ONLY way to execute tests on a cloud provider \u2014 dispatches through Testver's runner (cloud env injection, SDK attach, session watch) and returns the run's ground-truth cloudExecution verdict. Never try to reach cloud grids via shell commands, the testver CLI, or Testver's HTTP API."
|
|
38631
|
+
description: "Leave this out for normal runs \u2014 tests run locally, and `browser` / `environment` pick the target (an environment such as \"Staging\" is NOT a cloud provider). Set it ONLY when the user asked to run on that cloud and it is set up in Settings: browserstack, lambdatest, saucelabs, or testver-grid. A Local Devices (local-appium) session is NOT a cloud \u2014 leave this out and the run uses that device. The ONLY way to execute tests on a cloud provider \u2014 dispatches through Testver's runner (cloud env injection, SDK attach, session watch) and returns the run's ground-truth cloudExecution verdict. Never try to reach cloud grids via shell commands, the testver CLI, or Testver's HTTP API."
|
|
38468
38632
|
}
|
|
38469
38633
|
}
|
|
38470
38634
|
}
|
|
@@ -38559,7 +38723,8 @@ var init_test_runner = __esm({
|
|
|
38559
38723
|
if (inserted === command) inserted = insertCypressArgs(command, targets.args, cwd) ?? command;
|
|
38560
38724
|
command = inserted !== command ? inserted : `${command} ${targets.args}`;
|
|
38561
38725
|
}
|
|
38562
|
-
const
|
|
38726
|
+
const rawProvider = String(args2.cloud_provider || "").trim().toLowerCase();
|
|
38727
|
+
const cloudProvider = /^(local|local[-_ ]?appium|local[-_ ]?devices?)$/.test(rawProvider) ? "" : rawProvider;
|
|
38563
38728
|
if (cloudProvider) {
|
|
38564
38729
|
if (!["browserstack", "lambdatest", "saucelabs", "testver-grid"].includes(cloudProvider)) {
|
|
38565
38730
|
throw new Error(`Unknown cloud_provider "${cloudProvider}" \u2014 use browserstack, lambdatest, saucelabs, or testver-grid.`);
|
|
@@ -38612,7 +38777,14 @@ var init_test_runner = __esm({
|
|
|
38612
38777
|
const finalCommand = wrap2?.command ?? command;
|
|
38613
38778
|
const secretsEnv = getRecordedSecretsEnv(ctx.workingDirectory);
|
|
38614
38779
|
const extraEnv = { ...secretsEnv, ...targets.env, ...wrap2?.env ?? {} };
|
|
38615
|
-
|
|
38780
|
+
for (const stale of [".testver-results.json", ".testver-results.json.parts"]) {
|
|
38781
|
+
try {
|
|
38782
|
+
rmSync4(join55(cwd, stale), { recursive: true, force: true });
|
|
38783
|
+
} catch {
|
|
38784
|
+
}
|
|
38785
|
+
}
|
|
38786
|
+
const timeoutMs = wrap2 ? 20 * 6e4 : 5 * 6e4;
|
|
38787
|
+
const result = await runCmd(finalCommand, cwd, timeoutMs, extraEnv, wrap2?.onComplete, {
|
|
38616
38788
|
framework,
|
|
38617
38789
|
track: !wrap2,
|
|
38618
38790
|
// a cloud device run: on timeout end its vendor sessions, then kill the whole tree
|
|
@@ -38641,6 +38813,9 @@ Errors:
|
|
|
38641
38813
|
${result.stderr.trim()}` : "",
|
|
38642
38814
|
`
|
|
38643
38815
|
Exit code: ${result.exitCode}`,
|
|
38816
|
+
result.timedOut ? `
|
|
38817
|
+
|
|
38818
|
+
TIMED OUT: the run was stopped after ${timeoutMs / 6e4} minutes (the run_tests time limit) and its processes were ended \u2014 the exit code and any missing results come from that, not from the tests. Run fewer tests at a time (one spec, or a name filter) so each run finishes in time.` : "",
|
|
38644
38819
|
zeroWarning ? `
|
|
38645
38820
|
|
|
38646
38821
|
${zeroWarning}` : ""
|
|
@@ -39796,6 +39971,7 @@ function classifyRole(file, isTestFile3) {
|
|
|
39796
39971
|
const p2 = file.replace(/\\/g, "/").toLowerCase();
|
|
39797
39972
|
if (/(^|\/)(step[-_]?def|step_definitions|steps)(\/|$)/.test(p2) || /_steps?\.|\.steps?\./.test(p2)) return "step";
|
|
39798
39973
|
if (/(^|\/)(pages?|page[-_]?objects?|pom)(\/|$)/.test(p2) || /page\.[a-z]+$|page_[a-z]/.test(p2) || /[a-z]page\./.test(p2)) return "page";
|
|
39974
|
+
if (/(^|\/)(screens?|screen[-_]?objects?)(\/|$)/.test(p2) || /screen\.[a-z]+$|screen_[a-z]/.test(p2)) return "page";
|
|
39799
39975
|
if (/conftest\.py$/.test(p2) || /(^|\/)fixtures?(\/|$)/.test(p2) || /fixture/.test(p2)) return "fixture";
|
|
39800
39976
|
if (/(^|\/)(helpers?|utils?|support|lib|common|core|shared)(\/|$)/.test(p2)) return "helper";
|
|
39801
39977
|
return "source";
|
|
@@ -45121,11 +45297,11 @@ async function send(method, url, headers, body, auth, timeout) {
|
|
|
45121
45297
|
}
|
|
45122
45298
|
async function writeReport(workingDirectory2, rel, fallbackName, data) {
|
|
45123
45299
|
const { mkdir: mkdir8, writeFile: writeFile11 } = await import("fs/promises");
|
|
45124
|
-
const { resolve: resolve35, dirname:
|
|
45300
|
+
const { resolve: resolve35, dirname: dirname34, relative: relative43 } = await import("path");
|
|
45125
45301
|
const target2 = resolve35(workingDirectory2, rel || `.testver/contracts/${fallbackName}`);
|
|
45126
45302
|
const relPath = relative43(workingDirectory2, target2);
|
|
45127
45303
|
if (relPath.startsWith("..")) return null;
|
|
45128
|
-
await mkdir8(
|
|
45304
|
+
await mkdir8(dirname34(target2), { recursive: true });
|
|
45129
45305
|
await writeFile11(target2, JSON.stringify(data, null, 2), "utf-8");
|
|
45130
45306
|
return relPath.replace(/\\/g, "/");
|
|
45131
45307
|
}
|
|
@@ -72419,7 +72595,7 @@ var init_testver2 = __esm({
|
|
|
72419
72595
|
|
|
72420
72596
|
// src/core/tools/send-email.ts
|
|
72421
72597
|
import { readFileSync as readFileSync53, statSync as statSync28 } from "fs";
|
|
72422
|
-
import { createHash as createHash9, randomBytes as
|
|
72598
|
+
import { createHash as createHash9, randomBytes as randomBytes6 } from "crypto";
|
|
72423
72599
|
import { basename as basename19 } from "path";
|
|
72424
72600
|
function initSendEmailTool(store4, projectPath2, opts) {
|
|
72425
72601
|
tmStore2 = store4;
|
|
@@ -72454,7 +72630,7 @@ function mintConfirmToken(hash3, owner) {
|
|
|
72454
72630
|
if (oldest === void 0) break;
|
|
72455
72631
|
pendingConfirms.delete(oldest);
|
|
72456
72632
|
}
|
|
72457
|
-
const token2 =
|
|
72633
|
+
const token2 = randomBytes6(16).toString("hex");
|
|
72458
72634
|
pendingConfirms.set(token2, { hash: hash3, expires: now + CONFIRM_TTL_MS, owner });
|
|
72459
72635
|
return token2;
|
|
72460
72636
|
}
|
|
@@ -75802,7 +75978,7 @@ __export(report_store_exports, {
|
|
|
75802
75978
|
canAccessRecord: () => canAccessRecord
|
|
75803
75979
|
});
|
|
75804
75980
|
import { readFileSync as readFileSync54, mkdirSync as mkdirSync21, existsSync as existsSync63 } from "fs";
|
|
75805
|
-
import { randomBytes as
|
|
75981
|
+
import { randomBytes as randomBytes7 } from "crypto";
|
|
75806
75982
|
import { join as join64 } from "path";
|
|
75807
75983
|
function canAccessRecord(record, user) {
|
|
75808
75984
|
if (record.ownerEmail === user.id) return true;
|
|
@@ -75874,7 +76050,7 @@ var init_report_store = __esm({
|
|
|
75874
76050
|
...input.pinned != null ? { pinned: input.pinned } : {}
|
|
75875
76051
|
}, input.templateId);
|
|
75876
76052
|
}
|
|
75877
|
-
const id = !input.id || existing ? `rpt_${Date.now().toString(36)}_${
|
|
76053
|
+
const id = !input.id || existing ? `rpt_${Date.now().toString(36)}_${randomBytes7(4).toString("hex")}` : input.id;
|
|
75878
76054
|
const report = {
|
|
75879
76055
|
...input,
|
|
75880
76056
|
id,
|
|
@@ -75924,7 +76100,7 @@ var init_report_store = __esm({
|
|
|
75924
76100
|
createShareToken(id, opts) {
|
|
75925
76101
|
const report = this.get(id);
|
|
75926
76102
|
if (!report) return null;
|
|
75927
|
-
report.shareToken =
|
|
76103
|
+
report.shareToken = randomBytes7(24).toString("hex");
|
|
75928
76104
|
report.shareCreatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
75929
76105
|
const days = Number(opts?.expiresInDays);
|
|
75930
76106
|
if (Number.isFinite(days) && days >= 1 && days <= 365) {
|
|
@@ -76190,7 +76366,7 @@ __export(report_schedules_exports, {
|
|
|
76190
76366
|
isScheduleFormat: () => isScheduleFormat,
|
|
76191
76367
|
updateSchedule: () => updateSchedule
|
|
76192
76368
|
});
|
|
76193
|
-
import { randomBytes as
|
|
76369
|
+
import { randomBytes as randomBytes8 } from "crypto";
|
|
76194
76370
|
function isPlausibleEmail(s) {
|
|
76195
76371
|
return typeof s === "string" && /^[^\s@,;<>]+@[^\s@,;<>]+\.[^\s@,;<>]+$/.test(s.trim());
|
|
76196
76372
|
}
|
|
@@ -76235,7 +76411,7 @@ function createSchedule(store4, user, input) {
|
|
|
76235
76411
|
if (!canAccessRecord(source, user)) return { error: "Cannot schedule another user's report", status: 403 };
|
|
76236
76412
|
const cron = String(input.cron).trim();
|
|
76237
76413
|
const schedule = store4.createSchedule({
|
|
76238
|
-
id: `sched_${Date.now().toString(36)}_${
|
|
76414
|
+
id: `sched_${Date.now().toString(36)}_${randomBytes8(3).toString("hex")}`,
|
|
76239
76415
|
ownerEmail: user.id,
|
|
76240
76416
|
title: input.title.trim().slice(0, 200),
|
|
76241
76417
|
sourceReportId: input.sourceReportId,
|
|
@@ -78114,6 +78290,7 @@ function lastRunOf(testName) {
|
|
|
78114
78290
|
return automatedResult(testName);
|
|
78115
78291
|
}
|
|
78116
78292
|
function whereOf(h) {
|
|
78293
|
+
if (h.cloudProvider === "local-appium") return "local device";
|
|
78117
78294
|
return h.source === "cloud" ? h.cloudProvider ? `cloud (${h.cloudProvider})` : "cloud" : "local";
|
|
78118
78295
|
}
|
|
78119
78296
|
function median(xs) {
|
|
@@ -82288,7 +82465,9 @@ author: testver
|
|
|
82288
82465
|
## When asked to CREATE / SCAFFOLD a framework \u2014 gather requirements first
|
|
82289
82466
|
This section applies ONLY when the user is asking you to create or scaffold a test framework \u2014 ignore it entirely for any other request. When they ARE asking to build a framework: do NOT create files, scaffold, or run anything until you have BOTH items below. If either is missing, ASK the user and WAIT. NEVER assume app/device details:
|
|
82290
82467
|
1. The app under test AND a device/platform. App format must match the platform: **Android = .apk/.aab \xB7 iOS real device / cloud = .ipa \xB7 iOS local simulator = .app bundle (macOS only)**. Testver aborts a run up front on a mismatch, so ask rather than guess.
|
|
82291
|
-
2. The first scenario to automate (e.g. "launch the app and see the home screen"). If not given, PROPOSE one and confirm.
|
|
82468
|
+
2. The first scenario to automate (e.g. "launch the app and see the home screen"). If not given, PROPOSE one and WAIT for the user to confirm it \u2014 before creating any file.
|
|
82469
|
+
A live Mobile session (the AI Assistant's Mobile mode) already tells you the app and the device: that settles item 1 only. Item 2 still needs the user's answer, so ask for it even when a session is running.
|
|
82470
|
+
Also ask ONCE, without waiting on it, whether there are other environments to run against. For an app these are usually separate builds of it (e.g. a Dev and a Staging build talking to different back ends): tell the user to upload each one in Settings \u2192 General \u2192 App Builds under the environment's name, so it can be picked per run in the device/app pickers \u2014 the framework then needs no change, because the picked build arrives as TESTVER_APP_URL. When environments are builds, the build decides the environment: a test must NOT switch it inside the app (no steps on an in-app environment or server picker, no extra environment variable for it), or a run on the Staging build would quietly end up on Dev. An empty provider ref for a build is normal \u2014 Testver installs or uploads each build the first time a run uses it. Do not register Browsers/Environments with configure_run_targets for a mobile project (a Mobile workspace has no such settings).
|
|
82292
82471
|
Only once you have both do you scaffold: put the app path and capabilities in configuration (capabilities file or env, never hardcoded), implement that one scenario as the smoke test, and run it to verify.
|
|
82293
82472
|
|
|
82294
82473
|
## Runner per language (all five are first-class in Testver)
|
|
@@ -82299,7 +82478,7 @@ Only once you have both do you scaffold: put the app path and capabilities in co
|
|
|
82299
82478
|
| Java | TestNG (Maven/Gradle) | \`src/test/java/ screens/ pom.xml\` | \`mvn test\` |
|
|
82300
82479
|
| C# | NUnit | \`Tests/ Screens/ *.csproj\` | \`dotnet test\` |
|
|
82301
82480
|
| Ruby | RSpec | \`spec/ screens/ Gemfile\` | \`bundle exec rspec\` |
|
|
82302
|
-
Testver's AI Record writes generated mobile
|
|
82481
|
+
Testver's AI Record writes a generated mobile spec next to the project's existing specs (\`tests/mobile/\` only when there are none yet) \u2014 keep ONE specs folder, and make sure the runner's config finds it.
|
|
82303
82482
|
|
|
82304
82483
|
## Install + detection deps (Testver classifies the project by these \u2014 get them in the manifest)
|
|
82305
82484
|
- **WDIO:** \`npm i -D @wdio/cli @wdio/appium-service appium\` (+ \`appium driver install uiautomator2\` and/or \`xcuitest\`). Detection needs \`@wdio/appium-service\` (or \`appium\`+\`webdriverio\`) in package.json plus a \`wdio.conf.*\`.
|
|
@@ -82347,7 +82526,7 @@ Runner-native logging (\`@wdio/logger\`, Python \`logging\`, SLF4J, RSpec output
|
|
|
82347
82526
|
## Verify the setup (do this, then stop)
|
|
82348
82527
|
- If the user did NOT give the app (in the format matching the platform) and a device/platform, ASK first \u2014 do not assume.
|
|
82349
82528
|
- Put the app path and capabilities in CONFIGURATION (capabilities file or the env contract) \u2014 NEVER hardcode app/device details inside a test.
|
|
82350
|
-
- Create exactly ONE
|
|
82529
|
+
- Create exactly ONE smoke test: the scenario the user confirmed (only when they explicitly leave it to you: launch the app and assert the first screen renders). Run it to confirm install, drivers, config and result capture all work. Do not generate a full suite unless the user asks.
|
|
82351
82530
|
`,
|
|
82352
82531
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
82353
82532
|
// 12. EXPLORE & AUTOMATE (web)
|
|
@@ -89274,6 +89453,9 @@ function ofFile(entries, file) {
|
|
|
89274
89453
|
return !f || f === want || f.endsWith(`/${want}`) || want.endsWith(`/${f}`);
|
|
89275
89454
|
});
|
|
89276
89455
|
}
|
|
89456
|
+
function ranOnCloud(r) {
|
|
89457
|
+
return r.source === "cloud" && r.cloudProvider !== "local-appium";
|
|
89458
|
+
}
|
|
89277
89459
|
var MAX_RUNS, MAX_HISTORY_PER_TEST, STATUS_RANK, TestResultsStore;
|
|
89278
89460
|
var init_test_results_store = __esm({
|
|
89279
89461
|
"src/ui/store/test-results-store.ts"() {
|
|
@@ -89423,9 +89605,7 @@ var init_test_results_store = __esm({
|
|
|
89423
89605
|
list = list.filter((r) => r.status === filter.status);
|
|
89424
89606
|
}
|
|
89425
89607
|
if (filter?.source && filter.source !== "all") {
|
|
89426
|
-
list = list.filter(
|
|
89427
|
-
(r) => filter.source === "cloud" ? r.source === "cloud" : r.source !== "cloud"
|
|
89428
|
-
);
|
|
89608
|
+
list = list.filter((r) => filter.source === "cloud" === ranOnCloud(r));
|
|
89429
89609
|
}
|
|
89430
89610
|
return {
|
|
89431
89611
|
runs: list.slice(offset, offset + limit),
|
|
@@ -93885,7 +94065,7 @@ var init_git_cache_store = __esm({
|
|
|
93885
94065
|
});
|
|
93886
94066
|
|
|
93887
94067
|
// src/ui/auth/token-manager.ts
|
|
93888
|
-
import { createHmac, randomBytes as
|
|
94068
|
+
import { createHmac, randomBytes as randomBytes9, timingSafeEqual as timingSafeEqual4 } from "crypto";
|
|
93889
94069
|
import { readFileSync as readFileSync67, writeFileSync as writeFileSync21, existsSync as existsSync77, mkdirSync as mkdirSync31 } from "fs";
|
|
93890
94070
|
import { join as join80 } from "path";
|
|
93891
94071
|
import { scryptSync } from "crypto";
|
|
@@ -93897,7 +94077,7 @@ function base64UrlDecode(str2) {
|
|
|
93897
94077
|
return Buffer.from(str2, "base64url").toString("utf-8");
|
|
93898
94078
|
}
|
|
93899
94079
|
function hashPassword(password2) {
|
|
93900
|
-
const salt =
|
|
94080
|
+
const salt = randomBytes9(16).toString("hex");
|
|
93901
94081
|
const hash3 = scryptSync(password2, salt, 64).toString("hex");
|
|
93902
94082
|
return `${salt}:${hash3}`;
|
|
93903
94083
|
}
|
|
@@ -93907,7 +94087,7 @@ function verifyPassword(password2, stored) {
|
|
|
93907
94087
|
const [salt, hash3] = parts;
|
|
93908
94088
|
try {
|
|
93909
94089
|
const test = scryptSync(password2, salt, 64);
|
|
93910
|
-
return
|
|
94090
|
+
return timingSafeEqual4(Buffer.from(hash3, "hex"), test);
|
|
93911
94091
|
} catch {
|
|
93912
94092
|
return false;
|
|
93913
94093
|
}
|
|
@@ -93929,7 +94109,7 @@ var init_token_manager = __esm({
|
|
|
93929
94109
|
const hex2 = readFileSync67(secretPath, "utf-8").trim();
|
|
93930
94110
|
this.secret = Buffer.from(hex2, "hex");
|
|
93931
94111
|
} else {
|
|
93932
|
-
this.secret =
|
|
94112
|
+
this.secret = randomBytes9(64);
|
|
93933
94113
|
writeFileSync21(secretPath, this.secret.toString("hex"), "utf-8");
|
|
93934
94114
|
}
|
|
93935
94115
|
}
|
|
@@ -93954,7 +94134,7 @@ var init_token_manager = __esm({
|
|
|
93954
94134
|
if (signature.length !== expectedSig.length) return null;
|
|
93955
94135
|
const sigBuf = Buffer.from(signature, "utf-8");
|
|
93956
94136
|
const expectedBuf = Buffer.from(expectedSig, "utf-8");
|
|
93957
|
-
if (!
|
|
94137
|
+
if (!timingSafeEqual4(sigBuf, expectedBuf)) return null;
|
|
93958
94138
|
const payload = JSON.parse(base64UrlDecode(body));
|
|
93959
94139
|
const now = Math.floor(Date.now() / 1e3);
|
|
93960
94140
|
if (payload.exp && payload.exp < now) return null;
|
|
@@ -93975,7 +94155,7 @@ var user_store_exports = {};
|
|
|
93975
94155
|
__export(user_store_exports, {
|
|
93976
94156
|
UserStore: () => UserStore
|
|
93977
94157
|
});
|
|
93978
|
-
import { createHash as createHash11, randomBytes as
|
|
94158
|
+
import { createHash as createHash11, randomBytes as randomBytes10 } from "crypto";
|
|
93979
94159
|
import Database2 from "better-sqlite3";
|
|
93980
94160
|
import { existsSync as existsSync78, mkdirSync as mkdirSync32 } from "fs";
|
|
93981
94161
|
import { join as join81 } from "path";
|
|
@@ -94229,7 +94409,7 @@ var init_user_store = __esm({
|
|
|
94229
94409
|
}
|
|
94230
94410
|
/** Issue a single-use reset token (older ones for the user are voided). */
|
|
94231
94411
|
createPasswordReset(userId, ttlMs = 60 * 60 * 1e3) {
|
|
94232
|
-
const token2 =
|
|
94412
|
+
const token2 = randomBytes10(32).toString("base64url");
|
|
94233
94413
|
const now = Date.now();
|
|
94234
94414
|
const expiresAt = now + ttlMs;
|
|
94235
94415
|
this.db.prepare("DELETE FROM password_resets WHERE user_id = ? OR expires_at < ?").run(userId, now);
|
|
@@ -94313,7 +94493,7 @@ var init_user_store = __esm({
|
|
|
94313
94493
|
// ── Trusted browsers ("Trust this browser") ─────────────────────────────────
|
|
94314
94494
|
/** Remember a browser for `days`; the raw token goes to the browser, only its hash is kept. */
|
|
94315
94495
|
createTrustedBrowser(userId, days, ipAddress, userAgent) {
|
|
94316
|
-
const token2 =
|
|
94496
|
+
const token2 = randomBytes10(32).toString("base64url");
|
|
94317
94497
|
const id = generateId("tb");
|
|
94318
94498
|
const now = Date.now();
|
|
94319
94499
|
const expiresAt = now + days * 24 * 36e5;
|
|
@@ -94909,6 +95089,7 @@ function isPublicPath(path2, req) {
|
|
|
94909
95089
|
if (path2 === "/api/askpass") return true;
|
|
94910
95090
|
if (path2 === "/api/mobile/session/register-external" && isLocalRequest(req)) return true;
|
|
94911
95091
|
if (path2 === "/api/mobile/session/unregister-external" && isLocalRequest(req)) return true;
|
|
95092
|
+
if (path2 === "/api/runner/device-session" && isLocalRequest(req)) return true;
|
|
94912
95093
|
if (path2 === "/api/system/app-mode" && req?.method === "GET") return true;
|
|
94913
95094
|
return false;
|
|
94914
95095
|
}
|
|
@@ -95189,7 +95370,7 @@ var init_connector_registry = __esm({
|
|
|
95189
95370
|
});
|
|
95190
95371
|
|
|
95191
95372
|
// src/ui/local-browser-tokens.ts
|
|
95192
|
-
import { randomBytes as
|
|
95373
|
+
import { randomBytes as randomBytes11 } from "crypto";
|
|
95193
95374
|
function getLocalBrowserTokenStore() {
|
|
95194
95375
|
if (!_store) _store = new LocalBrowserTokenStore();
|
|
95195
95376
|
return _store;
|
|
@@ -95216,7 +95397,7 @@ var init_local_browser_tokens = __esm({
|
|
|
95216
95397
|
userTokens.sort((a, b) => a.createdAt - b.createdAt);
|
|
95217
95398
|
this.byToken.delete(userTokens[0].token);
|
|
95218
95399
|
}
|
|
95219
|
-
const token2 = `lbt_${
|
|
95400
|
+
const token2 = `lbt_${randomBytes11(24).toString("base64url")}`;
|
|
95220
95401
|
const now = Date.now();
|
|
95221
95402
|
this.byToken.set(token2, {
|
|
95222
95403
|
token: token2,
|
|
@@ -99079,6 +99260,18 @@ var init_session_manager = __esm({
|
|
|
99079
99260
|
setAdapterFactory(factory) {
|
|
99080
99261
|
this.adapterFactory = factory;
|
|
99081
99262
|
}
|
|
99263
|
+
/**
|
|
99264
|
+
* Runs before every NEW device session (never when start() hands back
|
|
99265
|
+
* the live one). The pool uses it to make a local device exclusive: a
|
|
99266
|
+
* second session on the same Android device restarts its UiAutomator2
|
|
99267
|
+
* server and breaks the first. May throw to refuse the start; the
|
|
99268
|
+
* returned function (if any) is called once the new session is up or
|
|
99269
|
+
* has failed.
|
|
99270
|
+
*/
|
|
99271
|
+
beforeNewSession = null;
|
|
99272
|
+
setBeforeNewSession(hook) {
|
|
99273
|
+
this.beforeNewSession = hook;
|
|
99274
|
+
}
|
|
99082
99275
|
/** Caller (route handler / UI) sets the device+app the LLM should target. */
|
|
99083
99276
|
setDesiredSession(desired) {
|
|
99084
99277
|
this.desired = desired;
|
|
@@ -99146,8 +99339,17 @@ var init_session_manager = __esm({
|
|
|
99146
99339
|
}
|
|
99147
99340
|
this.adapter = null;
|
|
99148
99341
|
}
|
|
99149
|
-
this.
|
|
99150
|
-
|
|
99342
|
+
const done2 = this.beforeNewSession ? await this.beforeNewSession(this.desired) : void 0;
|
|
99343
|
+
let info;
|
|
99344
|
+
try {
|
|
99345
|
+
this.adapter = this.adapterFactory(this.desired);
|
|
99346
|
+
info = await this.adapter.startSession(this.desired);
|
|
99347
|
+
} finally {
|
|
99348
|
+
try {
|
|
99349
|
+
done2?.();
|
|
99350
|
+
} catch {
|
|
99351
|
+
}
|
|
99352
|
+
}
|
|
99151
99353
|
logger26.info(`MobileSession started (provider=${info.providerId} device=${info.device})`);
|
|
99152
99354
|
for (const cb of this.startedCallbacks) {
|
|
99153
99355
|
try {
|
|
@@ -99509,6 +99711,11 @@ var init_appium_client = __esm({
|
|
|
99509
99711
|
const res = await this.request("GET", `/element/${elementId}/text`);
|
|
99510
99712
|
return res.value || "";
|
|
99511
99713
|
}
|
|
99714
|
+
/** An element's position and size in device pixels (W3C element rect). */
|
|
99715
|
+
async getElementRect(elementId) {
|
|
99716
|
+
const res = await this.request("GET", `/element/${elementId}/rect`);
|
|
99717
|
+
return { x: res.value?.x ?? 0, y: res.value?.y ?? 0, width: res.value?.width ?? 0, height: res.value?.height ?? 0 };
|
|
99718
|
+
}
|
|
99512
99719
|
async takeScreenshot() {
|
|
99513
99720
|
const res = await this.request("GET", `/screenshot`);
|
|
99514
99721
|
return res.value;
|
|
@@ -100263,6 +100470,64 @@ ${tree}`;
|
|
|
100263
100470
|
return { success: true, message: `long-pressed ${locator.strategy}=${locator.value} (${durationMs}ms, W3C)`, elementId: id };
|
|
100264
100471
|
});
|
|
100265
100472
|
}
|
|
100473
|
+
/**
|
|
100474
|
+
* Swipe across an element. The AI's tree carries no coordinates, so the
|
|
100475
|
+
* element is resolved here: the driver's own swipe gesture first, then a
|
|
100476
|
+
* W3C swipe through the element's rect (85% of its width / height).
|
|
100477
|
+
*/
|
|
100478
|
+
async swipeElement(locator, direction, durationMs = 300) {
|
|
100479
|
+
return this.guarded(async () => {
|
|
100480
|
+
if (!this.session) throw new Error("No active mobile session");
|
|
100481
|
+
const id = await this.findElement(locator);
|
|
100482
|
+
try {
|
|
100483
|
+
if (this.session.platform === "android") {
|
|
100484
|
+
await this.client.executeMobileCommand("mobile: swipeGesture", [{ elementId: id, direction, percent: 0.85 }]);
|
|
100485
|
+
} else {
|
|
100486
|
+
await this.client.executeMobileCommand("mobile: swipe", [{ elementId: id, direction }]);
|
|
100487
|
+
}
|
|
100488
|
+
return { success: true, message: `swiped ${direction} on ${locator.strategy}=${locator.value}`, elementId: id };
|
|
100489
|
+
} catch (err5) {
|
|
100490
|
+
logger28.debug(`swipe extension failed, falling back to W3C: ${err5.message}`);
|
|
100491
|
+
}
|
|
100492
|
+
const r = await this.client.getElementRect(id);
|
|
100493
|
+
const cx = Math.round(r.x + r.width / 2);
|
|
100494
|
+
const cy = Math.round(r.y + r.height / 2);
|
|
100495
|
+
const [dx, dy] = [Math.round(r.width * 0.425), Math.round(r.height * 0.425)];
|
|
100496
|
+
const [from, to] = direction === "left" ? [{ x: cx + dx, y: cy }, { x: cx - dx, y: cy }] : direction === "right" ? [{ x: cx - dx, y: cy }, { x: cx + dx, y: cy }] : direction === "up" ? [{ x: cx, y: cy + dy }, { x: cx, y: cy - dy }] : [{ x: cx, y: cy - dy }, { x: cx, y: cy + dy }];
|
|
100497
|
+
const res = await this.swipe(from, to, durationMs);
|
|
100498
|
+
return res.success ? { ...res, message: `swiped ${direction} on ${locator.strategy}=${locator.value} (W3C)`, elementId: id } : res;
|
|
100499
|
+
});
|
|
100500
|
+
}
|
|
100501
|
+
/**
|
|
100502
|
+
* Drag one element onto another: press the source, hold so drag-and-drop
|
|
100503
|
+
* starts (a quick move reads as a fling), move to the target's centre,
|
|
100504
|
+
* release. W3C actions — the same gesture on Android and iOS.
|
|
100505
|
+
*/
|
|
100506
|
+
async drag(from, to, durationMs = 1e3) {
|
|
100507
|
+
return this.guarded(async () => {
|
|
100508
|
+
if (!this.session) throw new Error("No active mobile session");
|
|
100509
|
+
const src = await this.client.getElementRect(await this.findElement(from));
|
|
100510
|
+
const dst = await this.client.getElementRect(await this.findElement(to));
|
|
100511
|
+
const centre = (r) => ({ x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2) });
|
|
100512
|
+
const [a, b] = [centre(src), centre(dst)];
|
|
100513
|
+
await this.client.performActions([
|
|
100514
|
+
{
|
|
100515
|
+
type: "pointer",
|
|
100516
|
+
id: "finger1",
|
|
100517
|
+
parameters: { pointerType: "touch" },
|
|
100518
|
+
actions: [
|
|
100519
|
+
{ type: "pointerMove", duration: 0, x: a.x, y: a.y },
|
|
100520
|
+
{ type: "pointerDown", button: 0 },
|
|
100521
|
+
{ type: "pause", duration: 600 },
|
|
100522
|
+
{ type: "pointerMove", duration: Math.min(5e3, Math.max(300, durationMs)), x: b.x, y: b.y },
|
|
100523
|
+
{ type: "pause", duration: 200 },
|
|
100524
|
+
{ type: "pointerUp", button: 0 }
|
|
100525
|
+
]
|
|
100526
|
+
}
|
|
100527
|
+
]);
|
|
100528
|
+
return { success: true, message: `dragged ${from.strategy}=${from.value} onto ${to.strategy}=${to.value}` };
|
|
100529
|
+
});
|
|
100530
|
+
}
|
|
100266
100531
|
/**
|
|
100267
100532
|
* Accept/dismiss the current system alert or permission dialog.
|
|
100268
100533
|
* W3C alert endpoints first (XCUITest handles these well); Android
|
|
@@ -100499,17 +100764,22 @@ ${tree}`;
|
|
|
100499
100764
|
// src/mobile/session-pool.ts
|
|
100500
100765
|
var session_pool_exports = {};
|
|
100501
100766
|
__export(session_pool_exports, {
|
|
100767
|
+
LocalDeviceBusyError: () => LocalDeviceBusyError,
|
|
100502
100768
|
MobileSessionPool: () => MobileSessionPool
|
|
100503
100769
|
});
|
|
100504
100770
|
function defaultMaxLifetimeMs() {
|
|
100505
100771
|
const m = Number(process.env.TESTVER_MOBILE_SESSION_MAX_MINUTES);
|
|
100506
100772
|
return (Number.isFinite(m) && m > 0 ? m : 180) * 60 * 1e3;
|
|
100507
100773
|
}
|
|
100774
|
+
function localDeviceOf(manager) {
|
|
100775
|
+
const d = manager.getDesiredSession?.();
|
|
100776
|
+
return d && d.providerId === "local-appium" && d.deviceKey ? d.deviceKey : void 0;
|
|
100777
|
+
}
|
|
100508
100778
|
function isCloudSession(manager) {
|
|
100509
100779
|
const desired = manager.getDesiredSession?.();
|
|
100510
100780
|
return !!desired && desired.providerId !== "local-appium";
|
|
100511
100781
|
}
|
|
100512
|
-
var logger29, EXPIRY_WARNING_MS, HEARTBEAT_INTERVAL_MS, MobileSessionPool;
|
|
100782
|
+
var logger29, EXPIRY_WARNING_MS, HEARTBEAT_INTERVAL_MS, LocalDeviceBusyError, MobileSessionPool;
|
|
100513
100783
|
var init_session_pool = __esm({
|
|
100514
100784
|
"src/mobile/session-pool.ts"() {
|
|
100515
100785
|
"use strict";
|
|
@@ -100521,6 +100791,12 @@ var init_session_pool = __esm({
|
|
|
100521
100791
|
logger29 = createLogger("mobile-session-pool");
|
|
100522
100792
|
EXPIRY_WARNING_MS = 90 * 1e3;
|
|
100523
100793
|
HEARTBEAT_INTERVAL_MS = 60 * 1e3;
|
|
100794
|
+
LocalDeviceBusyError = class extends Error {
|
|
100795
|
+
constructor(device, owner) {
|
|
100796
|
+
super(`${device} is in use by "${owner}" in another tab. Wait for that run to finish, or pick another device.`);
|
|
100797
|
+
this.name = "LocalDeviceBusyError";
|
|
100798
|
+
}
|
|
100799
|
+
};
|
|
100524
100800
|
MobileSessionPool = class {
|
|
100525
100801
|
constructor(options, ttlMs = 10 * 60 * 1e3) {
|
|
100526
100802
|
this.options = options;
|
|
@@ -100533,6 +100809,10 @@ var init_session_pool = __esm({
|
|
|
100533
100809
|
}
|
|
100534
100810
|
options;
|
|
100535
100811
|
pool = /* @__PURE__ */ new Map();
|
|
100812
|
+
/** Why Testver closed a tab's session — handed to onManagerDisconnect once. */
|
|
100813
|
+
closeReasons = /* @__PURE__ */ new Map();
|
|
100814
|
+
/** New sessions on one local device start one at a time (device → tail of the queue). */
|
|
100815
|
+
deviceStarts = /* @__PURE__ */ new Map();
|
|
100536
100816
|
cleanupTimer = null;
|
|
100537
100817
|
ttlMs;
|
|
100538
100818
|
maxLifetimeMs;
|
|
@@ -100548,10 +100828,13 @@ var init_session_pool = __esm({
|
|
|
100548
100828
|
}
|
|
100549
100829
|
const manager = new MobileSessionManager();
|
|
100550
100830
|
manager.setAdapterFactory((desired) => this.buildAdapter(desired));
|
|
100831
|
+
manager.setBeforeNewSession((desired) => this.claimLocalDevice(desired, key2));
|
|
100551
100832
|
manager.onDisconnect(() => {
|
|
100552
100833
|
this.pool.delete(key2);
|
|
100834
|
+
const reason = this.closeReasons.get(key2);
|
|
100835
|
+
this.closeReasons.delete(key2);
|
|
100553
100836
|
try {
|
|
100554
|
-
this.options.onManagerDisconnect?.(clientId);
|
|
100837
|
+
this.options.onManagerDisconnect?.(clientId, reason);
|
|
100555
100838
|
} catch {
|
|
100556
100839
|
}
|
|
100557
100840
|
});
|
|
@@ -100609,16 +100892,81 @@ var init_session_pool = __esm({
|
|
|
100609
100892
|
} catch {
|
|
100610
100893
|
}
|
|
100611
100894
|
}
|
|
100612
|
-
/**
|
|
100613
|
-
|
|
100895
|
+
/**
|
|
100896
|
+
* Free a LOCAL device for a new session: end every other tab's Testver
|
|
100897
|
+
* session on it first, while those sessions are still healthy.
|
|
100898
|
+
*
|
|
100899
|
+
* Why: an Android device runs ONE UiAutomator2 server. A new session
|
|
100900
|
+
* restarts it, so an older session on the device dies — and Appium keeps
|
|
100901
|
+
* listing it. Testver can't DELETE it afterwards (deleting a UiAutomator2
|
|
100902
|
+
* session force-stops the device's server, which by then belongs to the
|
|
100903
|
+
* NEW session), so the old one used to sit until Appium's
|
|
100904
|
+
* newCommandTimeout, whose cleanup force-stopped the server and crashed
|
|
100905
|
+
* whatever session was live at that moment. Ending it BEFORE the new one
|
|
100906
|
+
* starts is the only safe moment.
|
|
100907
|
+
*
|
|
100908
|
+
* A session a test run is driving is never closed under the run:
|
|
100909
|
+
* `refuseIfRunning` throws LocalDeviceBusyError instead (a new interactive
|
|
100910
|
+
* session); otherwise it is left alone. Returns how many were closed.
|
|
100911
|
+
*/
|
|
100912
|
+
async releaseLocalDevice(device, opts) {
|
|
100913
|
+
if (!device) return 0;
|
|
100914
|
+
const others = [...this.pool.entries()].filter(([id, e]) => id !== opts.exceptClientId && localDeviceOf(e.manager) === device && e.manager.isActive());
|
|
100915
|
+
let closed = 0;
|
|
100916
|
+
for (const [id, e] of others) {
|
|
100917
|
+
if (e.manager.isLockedForRun?.()) {
|
|
100918
|
+
if (opts.refuseIfRunning) throw new LocalDeviceBusyError(device, e.manager.getLockInfo()?.ownerLabel || "a test run");
|
|
100919
|
+
continue;
|
|
100920
|
+
}
|
|
100921
|
+
if (await this.evict(id, opts.reason)) closed++;
|
|
100922
|
+
}
|
|
100923
|
+
if (closed > 0) logger29.info(`Closed ${closed} other session(s) on local device ${device} before a new one`);
|
|
100924
|
+
return closed;
|
|
100925
|
+
}
|
|
100926
|
+
/**
|
|
100927
|
+
* beforeNewSession hook: new sessions on one local device start one at a
|
|
100928
|
+
* time, and each first frees the device (releaseLocalDevice). Cloud
|
|
100929
|
+
* sessions each get their own vendor device — nothing to do.
|
|
100930
|
+
*/
|
|
100931
|
+
async claimLocalDevice(desired, clientKey) {
|
|
100932
|
+
if (desired.providerId !== "local-appium" || !desired.deviceKey) return;
|
|
100933
|
+
const device = desired.deviceKey;
|
|
100934
|
+
const prev = this.deviceStarts.get(device) ?? Promise.resolve();
|
|
100935
|
+
let release4;
|
|
100936
|
+
const mine = new Promise((resolve35) => {
|
|
100937
|
+
release4 = resolve35;
|
|
100938
|
+
});
|
|
100939
|
+
const tail = prev.then(() => mine);
|
|
100940
|
+
this.deviceStarts.set(device, tail);
|
|
100941
|
+
const done2 = () => {
|
|
100942
|
+
release4();
|
|
100943
|
+
if (this.deviceStarts.get(device) === tail) this.deviceStarts.delete(device);
|
|
100944
|
+
};
|
|
100945
|
+
await prev;
|
|
100946
|
+
try {
|
|
100947
|
+
await this.releaseLocalDevice(device, {
|
|
100948
|
+
exceptClientId: clientKey,
|
|
100949
|
+
reason: `Another tab started a session on ${device}, so this one was closed \u2014 a local device runs one session at a time.`,
|
|
100950
|
+
refuseIfRunning: true
|
|
100951
|
+
});
|
|
100952
|
+
} catch (err5) {
|
|
100953
|
+
done2();
|
|
100954
|
+
throw err5;
|
|
100955
|
+
}
|
|
100956
|
+
return done2;
|
|
100957
|
+
}
|
|
100958
|
+
/** Explicit eviction — closes the live session. `reason` reaches the tab. */
|
|
100959
|
+
async evict(clientId, reason) {
|
|
100614
100960
|
const entry2 = this.pool.get(clientId);
|
|
100615
100961
|
if (!entry2) return false;
|
|
100962
|
+
if (reason) this.closeReasons.set(clientId, reason);
|
|
100616
100963
|
this.pool.delete(clientId);
|
|
100617
100964
|
try {
|
|
100618
100965
|
await entry2.manager.stop();
|
|
100619
100966
|
} catch (err5) {
|
|
100620
100967
|
logger29.debug(`evict() stop error: ${err5.message}`);
|
|
100621
100968
|
}
|
|
100969
|
+
this.closeReasons.delete(clientId);
|
|
100622
100970
|
logger29.info(`Evicted MobileSessionManager for clientId=${clientId}`);
|
|
100623
100971
|
return true;
|
|
100624
100972
|
}
|
|
@@ -101251,7 +101599,7 @@ var askpass_service_exports = {};
|
|
|
101251
101599
|
__export(askpass_service_exports, {
|
|
101252
101600
|
AskPassService: () => AskPassService
|
|
101253
101601
|
});
|
|
101254
|
-
import { randomBytes as
|
|
101602
|
+
import { randomBytes as randomBytes12 } from "crypto";
|
|
101255
101603
|
import { tmpdir as tmpdir4 } from "os";
|
|
101256
101604
|
import { join as join85, sep as sep7 } from "path";
|
|
101257
101605
|
import {
|
|
@@ -101259,7 +101607,7 @@ import {
|
|
|
101259
101607
|
mkdirSync as mkdirSync35,
|
|
101260
101608
|
writeFileSync as writeFileSync22,
|
|
101261
101609
|
chmodSync,
|
|
101262
|
-
rmSync as
|
|
101610
|
+
rmSync as rmSync5
|
|
101263
101611
|
} from "fs";
|
|
101264
101612
|
import { execPath } from "process";
|
|
101265
101613
|
var AskPassService, HELPER_SCRIPT;
|
|
@@ -101328,7 +101676,7 @@ var init_askpass_service = __esm({
|
|
|
101328
101676
|
this.sessionCache.clear();
|
|
101329
101677
|
if (!this.helperDir) return;
|
|
101330
101678
|
try {
|
|
101331
|
-
|
|
101679
|
+
rmSync5(this.helperDir, { recursive: true, force: true });
|
|
101332
101680
|
} catch {
|
|
101333
101681
|
}
|
|
101334
101682
|
this.helperDir = null;
|
|
@@ -101341,7 +101689,7 @@ var init_askpass_service = __esm({
|
|
|
101341
101689
|
*/
|
|
101342
101690
|
register(opts) {
|
|
101343
101691
|
if (!this.helperPath) this.initialize();
|
|
101344
|
-
const token2 =
|
|
101692
|
+
const token2 = randomBytes12(32).toString("hex");
|
|
101345
101693
|
this.contexts.set(token2, {
|
|
101346
101694
|
clientId: opts.clientId,
|
|
101347
101695
|
userId: opts.userId,
|
|
@@ -101401,7 +101749,7 @@ var init_askpass_service = __esm({
|
|
|
101401
101749
|
}
|
|
101402
101750
|
return Promise.resolve({ cancelled: true });
|
|
101403
101751
|
}
|
|
101404
|
-
const requestId =
|
|
101752
|
+
const requestId = randomBytes12(12).toString("hex");
|
|
101405
101753
|
return new Promise((resolve35) => {
|
|
101406
101754
|
const closeDialog = () => this.broadcast(ctx.clientId, ctx.userId, { type: "askpass-closed", requestId });
|
|
101407
101755
|
const timer = setTimeout(() => {
|
|
@@ -102624,7 +102972,7 @@ var init_login_throttle = __esm({
|
|
|
102624
102972
|
});
|
|
102625
102973
|
|
|
102626
102974
|
// src/ui/auth/two-factor-challenges.ts
|
|
102627
|
-
import { createHash as createHash12, randomBytes as
|
|
102975
|
+
import { createHash as createHash12, randomBytes as randomBytes13 } from "crypto";
|
|
102628
102976
|
var MAX_CHALLENGE_ATTEMPTS, TTL, PENDING_TTL, hash2, TwoFactorChallenges;
|
|
102629
102977
|
var init_two_factor_challenges = __esm({
|
|
102630
102978
|
"src/ui/auth/two-factor-challenges.ts"() {
|
|
@@ -102643,7 +102991,7 @@ var init_two_factor_challenges = __esm({
|
|
|
102643
102991
|
/** Start a challenge; the raw token goes to the browser. Older challenges of the user are dropped. */
|
|
102644
102992
|
create(userId, purpose) {
|
|
102645
102993
|
for (const [k, c2] of this.challenges) if (c2.userId === userId) this.challenges.delete(k);
|
|
102646
|
-
const raw =
|
|
102994
|
+
const raw = randomBytes13(32).toString("base64url");
|
|
102647
102995
|
this.challenges.set(hash2(raw), { userId, purpose, expiresAt: this.now() + TTL[purpose], attempts: 0 });
|
|
102648
102996
|
this.prune();
|
|
102649
102997
|
return raw;
|
|
@@ -102696,7 +103044,7 @@ var init_two_factor_challenges = __esm({
|
|
|
102696
103044
|
});
|
|
102697
103045
|
|
|
102698
103046
|
// src/ui/auth/two-factor-crypto.ts
|
|
102699
|
-
import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, createHash as createHash13, randomBytes as
|
|
103047
|
+
import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, createHash as createHash13, randomBytes as randomBytes14 } from "crypto";
|
|
102700
103048
|
import { existsSync as existsSync86, mkdirSync as mkdirSync38, readFileSync as readFileSync72, writeFileSync as writeFileSync24 } from "fs";
|
|
102701
103049
|
import { join as join88 } from "path";
|
|
102702
103050
|
function twoFactorKeyPath() {
|
|
@@ -102715,7 +103063,7 @@ function loadKey(create) {
|
|
|
102715
103063
|
const dir = getTestverDir();
|
|
102716
103064
|
if (!existsSync86(dir)) mkdirSync38(dir, { recursive: true });
|
|
102717
103065
|
try {
|
|
102718
|
-
writeFileSync24(path2,
|
|
103066
|
+
writeFileSync24(path2, randomBytes14(32).toString("hex"), { encoding: "utf-8", mode: 384, flag: "wx" });
|
|
102719
103067
|
} catch (e) {
|
|
102720
103068
|
if (e.code !== "EEXIST") throw e;
|
|
102721
103069
|
}
|
|
@@ -102740,7 +103088,7 @@ function previousFileKey() {
|
|
|
102740
103088
|
}
|
|
102741
103089
|
function encryptTotpSecret(secret) {
|
|
102742
103090
|
const loaded = loadKey(true);
|
|
102743
|
-
const iv =
|
|
103091
|
+
const iv = randomBytes14(12);
|
|
102744
103092
|
const cipher = createCipheriv2("aes-256-gcm", loaded.key, iv);
|
|
102745
103093
|
const data = Buffer.concat([cipher.update(secret, "utf8"), cipher.final()]);
|
|
102746
103094
|
const tag2 = cipher.getAuthTag();
|
|
@@ -102780,7 +103128,7 @@ var init_two_factor_crypto = __esm({
|
|
|
102780
103128
|
});
|
|
102781
103129
|
|
|
102782
103130
|
// src/ui/auth/totp.ts
|
|
102783
|
-
import { createHmac as createHmac2, randomBytes as
|
|
103131
|
+
import { createHmac as createHmac2, randomBytes as randomBytes15, timingSafeEqual as timingSafeEqual5 } from "crypto";
|
|
102784
103132
|
function base32Encode(buf) {
|
|
102785
103133
|
let bits = 0;
|
|
102786
103134
|
let value = 0;
|
|
@@ -102814,7 +103162,7 @@ function base32Decode(input) {
|
|
|
102814
103162
|
return Buffer.from(out);
|
|
102815
103163
|
}
|
|
102816
103164
|
function generateTotpSecret() {
|
|
102817
|
-
return base32Encode(
|
|
103165
|
+
return base32Encode(randomBytes15(20));
|
|
102818
103166
|
}
|
|
102819
103167
|
function timeStep(nowMs) {
|
|
102820
103168
|
return Math.floor(nowMs / 1e3 / TOTP_STEP_SECONDS);
|
|
@@ -102868,7 +103216,7 @@ function generateRecoveryCodes(count = RECOVERY_CODE_COUNT) {
|
|
|
102868
103216
|
while (codes.size < count) {
|
|
102869
103217
|
let s = "";
|
|
102870
103218
|
while (s.length < 10) {
|
|
102871
|
-
for (const b of
|
|
103219
|
+
for (const b of randomBytes15(16)) {
|
|
102872
103220
|
if (b < limit && s.length < 10) s += RECOVERY_ALPHABET[b % RECOVERY_ALPHABET.length];
|
|
102873
103221
|
}
|
|
102874
103222
|
}
|
|
@@ -102889,7 +103237,7 @@ var init_totp = __esm({
|
|
|
102889
103237
|
TOTP_WINDOW = 1;
|
|
102890
103238
|
DRIFT_SEARCH = 10;
|
|
102891
103239
|
B32 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
102892
|
-
same3 = (a, b) => a.length === b.length &&
|
|
103240
|
+
same3 = (a, b) => a.length === b.length && timingSafeEqual5(Buffer.from(a), Buffer.from(b));
|
|
102893
103241
|
RECOVERY_ALPHABET = "abcdefghjkmnpqrstvwxyz23456789";
|
|
102894
103242
|
RECOVERY_CODE_COUNT = 10;
|
|
102895
103243
|
}
|
|
@@ -107353,7 +107701,7 @@ var api_auth_exports = {};
|
|
|
107353
107701
|
__export(api_auth_exports, {
|
|
107354
107702
|
mountAuthRoutes: () => mountAuthRoutes
|
|
107355
107703
|
});
|
|
107356
|
-
import { createHash as createHash14, timingSafeEqual as
|
|
107704
|
+
import { createHash as createHash14, timingSafeEqual as timingSafeEqual6 } from "crypto";
|
|
107357
107705
|
function mountAuthRoutes(app, userStore2, tokenManager, auditLogStore, systemConfigStore) {
|
|
107358
107706
|
const throttle = new LoginThrottle();
|
|
107359
107707
|
const challenges = new TwoFactorChallenges();
|
|
@@ -108698,7 +109046,7 @@ var init_api_auth = __esm({
|
|
|
108698
109046
|
if (typeof given !== "string" || !given) return false;
|
|
108699
109047
|
const a = createHash14("sha256").update(expected).digest();
|
|
108700
109048
|
const b = createHash14("sha256").update(given).digest();
|
|
108701
|
-
return
|
|
109049
|
+
return timingSafeEqual6(a, b);
|
|
108702
109050
|
};
|
|
108703
109051
|
}
|
|
108704
109052
|
});
|
|
@@ -109932,7 +110280,7 @@ A device session is ALREADY RUNNING \u2014 ${details}. Do not call mobile_launch
|
|
|
109932
110280
|
return `## Mobile session
|
|
109933
110281
|
No session is running yet. The user picked device ${desired.deviceKey} (${desired.platform === "ios" ? "iOS" : "Android"} ${desired.osVersion}, ${desired.providerId})${app ? ` and app ${app}` : ""} \u2014 call mobile_launch_app first to start it.`;
|
|
109934
110282
|
}
|
|
109935
|
-
return "## Mobile session\nNo device session is running and no device or app is picked. mobile_* tools need one: ask the user to pick a device and an app in the Mobile session bar above the chat and click Start session.";
|
|
110283
|
+
return "## Mobile session\nNo device session is running and no device or app is picked. mobile_* tools need one: ask the user to pick a device and an app in the Mobile session bar above the chat and click Start session. Until then, work from the code and the run output (run_tests still runs on the device and build the last run used) \u2014 do NOT reach the device another way: no adb commands, no unpacking the app build, no scripts that dump its ids.";
|
|
109936
110284
|
}
|
|
109937
110285
|
var init_session_prompt = __esm({
|
|
109938
110286
|
"src/mobile/session-prompt.ts"() {
|
|
@@ -112166,6 +112514,7 @@ var init_api_ai = __esm({
|
|
|
112166
112514
|
"mobile_tap",
|
|
112167
112515
|
"mobile_type",
|
|
112168
112516
|
"mobile_swipe",
|
|
112517
|
+
"mobile_drag",
|
|
112169
112518
|
"mobile_scroll_to",
|
|
112170
112519
|
"mobile_wait_for",
|
|
112171
112520
|
"mobile_alert",
|
|
@@ -112354,7 +112703,9 @@ The user already picked the device + app. Drive the live device with \`mobile_*\
|
|
|
112354
112703
|
|
|
112355
112704
|
**Native locators (never CSS/web refs), in order:** accessibility-id (\`content-desc\`/\`accessibilityIdentifier\`) > id (Android \`resource-id\`, iOS \`name\`) > \`-android-uiautomator\` / \`-ios-class-chain\` > xpath (last resort). Read exact values from the tree \u2014 never invent them.
|
|
112356
112705
|
|
|
112357
|
-
**Gestures:** \`mobile_tap\` (add \`longPressMs\` for long-press), \`mobile_type\`, \`mobile_press_key\`, \`mobile_orientation\`; \`mobile_tap_at\` is a last resort for system UI without locators. **Off-screen element \u2192 \`mobile_scroll_to\`** (scrolls natively and verifies), not coordinate math; reserve \`mobile_swipe\` for carousels/dismiss gestures.
|
|
112706
|
+
**Gestures:** \`mobile_tap\` (add \`longPressMs\` for long-press), \`mobile_type\`, \`mobile_press_key\`, \`mobile_orientation\`; \`mobile_tap_at\` is a last resort for system UI without locators. **Off-screen element \u2192 \`mobile_scroll_to\`** (scrolls natively and verifies), not coordinate math; reserve \`mobile_swipe\` for carousels/dismiss gestures \u2014 give it the element and a \`direction\`, not coordinates; \`mobile_drag\` drags one element onto another. The tree has no coordinates: never measure screenshots or call adb / Appium yourself to find element bounds.
|
|
112707
|
+
|
|
112708
|
+
**The device only through mobile_* tools:** no adb shell, no unpacking the app build (dex / resources), no scripts that dump ids or press keys \u2014 and no scratch scripts left in the project. If you need to see the app and no session can start (nothing picked), say so and ask the user to start one in the Mobile session bar.
|
|
112358
112709
|
|
|
112359
112710
|
**Element state is in the tree:** (checked)/(unchecked), (disabled), (selected), (focused), (scrollable) \u2014 read it, don't re-probe.
|
|
112360
112711
|
|
|
@@ -113646,9 +113997,7 @@ function mountResultsRoutes(app, resultsStore4, artifactFetcher, projectRoot = p
|
|
|
113646
113997
|
const sourceRaw = typeof req.query.source === "string" ? req.query.source : void 0;
|
|
113647
113998
|
const sourceFilter = sourceRaw === "cloud" || sourceRaw === "local" ? sourceRaw : void 0;
|
|
113648
113999
|
const { runs: allRuns } = resultsStore4.getRunHistory(Number.MAX_SAFE_INTEGER, 0);
|
|
113649
|
-
const scoped = sourceFilter ? allRuns.filter(
|
|
113650
|
-
(r) => sourceFilter === "cloud" ? r.source === "cloud" : r.source !== "cloud"
|
|
113651
|
-
) : allRuns;
|
|
114000
|
+
const scoped = sourceFilter ? allRuns.filter((r) => sourceFilter === "cloud" === ranOnCloud(r)) : allRuns;
|
|
113652
114001
|
const status = { all: scoped.length, completed: 0, failed: 0, running: 0, cancelled: 0 };
|
|
113653
114002
|
const source = { all: allRuns.length, local: 0, cloud: 0 };
|
|
113654
114003
|
let totalPassRate = 0;
|
|
@@ -113669,7 +114018,7 @@ function mountResultsRoutes(app, resultsStore4, artifactFetcher, projectRoot = p
|
|
|
113669
114018
|
}
|
|
113670
114019
|
}
|
|
113671
114020
|
for (const r of allRuns) {
|
|
113672
|
-
if (r
|
|
114021
|
+
if (ranOnCloud(r)) source.cloud++;
|
|
113673
114022
|
else source.local++;
|
|
113674
114023
|
}
|
|
113675
114024
|
res.json({
|
|
@@ -114225,6 +114574,7 @@ var init_api_results = __esm({
|
|
|
114225
114574
|
"src/ui/routes/api-results.ts"() {
|
|
114226
114575
|
"use strict";
|
|
114227
114576
|
init_artifact_path();
|
|
114577
|
+
init_test_results_store();
|
|
114228
114578
|
init_export_service();
|
|
114229
114579
|
init_cloud_secrets();
|
|
114230
114580
|
}
|
|
@@ -117559,11 +117909,11 @@ var init_selectors = __esm({
|
|
|
117559
117909
|
});
|
|
117560
117910
|
|
|
117561
117911
|
// src/recorder/recorder.ts
|
|
117562
|
-
import { randomBytes as
|
|
117912
|
+
import { randomBytes as randomBytes16 } from "crypto";
|
|
117563
117913
|
function tokenFor2(page) {
|
|
117564
117914
|
let t = pageTokens.get(page);
|
|
117565
117915
|
if (!t) {
|
|
117566
|
-
t =
|
|
117916
|
+
t = randomBytes16(16).toString("hex");
|
|
117567
117917
|
pageTokens.set(page, t);
|
|
117568
117918
|
}
|
|
117569
117919
|
return t;
|
|
@@ -131543,6 +131893,30 @@ function mountAutoHealRoutes(app, resultsStore4, options, systemConfig) {
|
|
|
131543
131893
|
}
|
|
131544
131894
|
return true;
|
|
131545
131895
|
};
|
|
131896
|
+
const codeLinesOf = (pairs, fileCache) => {
|
|
131897
|
+
if (!pairs?.length) return void 0;
|
|
131898
|
+
const out = [];
|
|
131899
|
+
for (const p2 of pairs) {
|
|
131900
|
+
if (p2.find.includes("\n") || p2.replace.includes("\n")) return void 0;
|
|
131901
|
+
let content = fileCache.get(p2.file);
|
|
131902
|
+
if (content === void 0) {
|
|
131903
|
+
try {
|
|
131904
|
+
content = readTextFile(join103(options.projectPath, p2.file)).text;
|
|
131905
|
+
} catch {
|
|
131906
|
+
content = null;
|
|
131907
|
+
}
|
|
131908
|
+
fileCache.set(p2.file, content);
|
|
131909
|
+
}
|
|
131910
|
+
if (!content) return void 0;
|
|
131911
|
+
const lineOf = (text2) => content.split(/\r?\n/).find((l) => l.includes(text2));
|
|
131912
|
+
const withFind = lineOf(p2.find);
|
|
131913
|
+
const withReplace = withFind === void 0 ? lineOf(p2.replace) : void 0;
|
|
131914
|
+
if (withFind !== void 0) out.push({ file: p2.file, before: withFind.trim(), after: withFind.replace(p2.find, p2.replace).trim() });
|
|
131915
|
+
else if (withReplace !== void 0) out.push({ file: p2.file, before: withReplace.replace(p2.replace, p2.find).trim(), after: withReplace.trim() });
|
|
131916
|
+
else return void 0;
|
|
131917
|
+
}
|
|
131918
|
+
return out;
|
|
131919
|
+
};
|
|
131546
131920
|
const allRuns = (limit) => {
|
|
131547
131921
|
const { runs: runs3 } = resultsStore4.getRunHistory(limit, 0);
|
|
131548
131922
|
const out = [];
|
|
@@ -131614,7 +131988,8 @@ function mountAutoHealRoutes(app, resultsStore4, options, systemConfig) {
|
|
|
131614
131988
|
actionable,
|
|
131615
131989
|
staleReason,
|
|
131616
131990
|
partialNote: s.partialNote,
|
|
131617
|
-
chain: s.chain
|
|
131991
|
+
chain: s.chain,
|
|
131992
|
+
codeLines: codeLinesOf(s.pairs, fileCache)
|
|
131618
131993
|
});
|
|
131619
131994
|
}
|
|
131620
131995
|
}
|
|
@@ -131846,16 +132221,31 @@ function contains(b, x, y) {
|
|
|
131846
132221
|
function area(b) {
|
|
131847
132222
|
return Math.max(0, b.x2 - b.x1) * Math.max(0, b.y2 - b.y1);
|
|
131848
132223
|
}
|
|
131849
|
-
function
|
|
131850
|
-
|
|
132224
|
+
function hasIdentity(node, platform4) {
|
|
132225
|
+
if (platform4 === "ios") return !!(node.attrs["name"] || node.attrs["accessibilityIdentifier"] || "").trim();
|
|
132226
|
+
const rid = node.attrs["resource-id"] || "";
|
|
132227
|
+
return rid.includes(":id/") && !rid.startsWith("android:") || !!(node.attrs["content-desc"] || "").trim();
|
|
132228
|
+
}
|
|
132229
|
+
function findTapTargetAt(pageSource, x, y, platform4) {
|
|
132230
|
+
const under = [];
|
|
132231
|
+
let screen = 0;
|
|
131851
132232
|
for (const node of walkElements(pageSource)) {
|
|
131852
132233
|
if (!node.bounds) continue;
|
|
131853
|
-
|
|
131854
|
-
if (
|
|
131855
|
-
best = node;
|
|
131856
|
-
}
|
|
132234
|
+
screen = Math.max(screen, area(node.bounds));
|
|
132235
|
+
if (contains(node.bounds, x, y)) under.push(node);
|
|
131857
132236
|
}
|
|
131858
|
-
|
|
132237
|
+
let inner = null;
|
|
132238
|
+
for (const node of under) {
|
|
132239
|
+
if (!inner || node.depth > inner.depth || node.depth === inner.depth && area(node.bounds) < area(inner.bounds)) inner = node;
|
|
132240
|
+
}
|
|
132241
|
+
if (!inner) return null;
|
|
132242
|
+
if (hasIdentity(inner, platform4)) return { target: inner, inner };
|
|
132243
|
+
const ancestors = under.filter((n) => n !== inner && n.depth < inner.depth && n.depth >= inner.depth - 4 && inner.path.startsWith(n.path + "/")).sort((a, b) => b.depth - a.depth);
|
|
132244
|
+
for (const a of ancestors) {
|
|
132245
|
+
if (screen && area(a.bounds) > screen * 0.4) break;
|
|
132246
|
+
if (hasIdentity(a, platform4) || a.attrs["clickable"] === "true") return { target: a, inner };
|
|
132247
|
+
}
|
|
132248
|
+
return { target: inner, inner };
|
|
131859
132249
|
}
|
|
131860
132250
|
function findWebviewAt(pageSource, x, y) {
|
|
131861
132251
|
let best = null;
|
|
@@ -132097,7 +132487,8 @@ function generateLocators(node, pageSource, platform4) {
|
|
|
132097
132487
|
return { primary, ranked: unique, label: label3 };
|
|
132098
132488
|
}
|
|
132099
132489
|
function describeElement2(node, platform4) {
|
|
132100
|
-
const
|
|
132490
|
+
const editable = /EditText|XCUIElementType(TextField|SecureTextField|TextView|SearchField)/i.test(node.attrs["class"] || node.tag || "");
|
|
132491
|
+
const text2 = platform4 === "android" ? (editable ? "" : node.attrs["text"]) || node.attrs["content-desc"] : (editable ? "" : node.attrs["label"]) || node.attrs["name"];
|
|
132101
132492
|
if (text2 && text2.trim()) return `"${text2.slice(0, 40)}"`;
|
|
132102
132493
|
const rid = node.attrs["resource-id"];
|
|
132103
132494
|
if (rid) {
|
|
@@ -132553,6 +132944,10 @@ return { locator: loc, tag: tag, text: text };
|
|
|
132553
132944
|
* field. Fixes the late-poll race where the first source poll already
|
|
132554
132945
|
* sees the typed text and mistakes it for the baseline. */
|
|
132555
132946
|
typingSeed = null;
|
|
132947
|
+
/** Text the recorder just typed itself (the "Type text" box): it is
|
|
132948
|
+
* already a step, so the typing detector takes the field's new value
|
|
132949
|
+
* as its baseline instead of recording the same text a second time. */
|
|
132950
|
+
explicitType = null;
|
|
132556
132951
|
/** Faster source-poll cadence while a field is focused (catches typing
|
|
132557
132952
|
* before the user navigates away). Restored to the idle cadence after. */
|
|
132558
132953
|
static TOUCH_PRIME_IDLE_MS = 1500;
|
|
@@ -132613,6 +133008,14 @@ return { locator: loc, tag: tag, text: text };
|
|
|
132613
133008
|
* Fire-and-forget — failures just mean the next tap fetches fresh.
|
|
132614
133009
|
*/
|
|
132615
133010
|
async primeSource() {
|
|
133011
|
+
if (this.primeInFlight) return this.primeInFlight;
|
|
133012
|
+
this.primeInFlight = this.doPrimeSource().finally(() => {
|
|
133013
|
+
this.primeInFlight = null;
|
|
133014
|
+
});
|
|
133015
|
+
return this.primeInFlight;
|
|
133016
|
+
}
|
|
133017
|
+
primeInFlight = null;
|
|
133018
|
+
async doPrimeSource() {
|
|
132616
133019
|
if (!this.recording) return;
|
|
132617
133020
|
const adapter = this.manager.getAdapter();
|
|
132618
133021
|
if (!adapter || !adapter.isActive()) return;
|
|
@@ -132671,7 +133074,7 @@ return { locator: loc, tag: tag, text: text };
|
|
|
132671
133074
|
const seed = this.typingSeed;
|
|
132672
133075
|
const b = focused.node.bounds;
|
|
132673
133076
|
const seedMatches = seed && Date.now() - seed.at < 8e3 && b && seed.x >= b.x1 && seed.x <= b.x2 && seed.y >= b.y1 && seed.y <= b.y2;
|
|
132674
|
-
const baseline = seedMatches ? seed.baseline : focused.text;
|
|
133077
|
+
const baseline = seedMatches && !this.absorbsExplicitType(focused) ? seed.baseline : focused.text;
|
|
132675
133078
|
this.typingSeed = null;
|
|
132676
133079
|
logger38.info(`Typing detected: field focused (baseline ${baseline.length} chars, current ${focused.text.length} chars).`);
|
|
132677
133080
|
this.pendingType = {
|
|
@@ -132692,12 +133095,24 @@ return { locator: loc, tag: tag, text: text };
|
|
|
132692
133095
|
if (focused.text !== this.pendingType.text) {
|
|
132693
133096
|
this.pendingType.text = focused.text;
|
|
132694
133097
|
this.pendingType.changedAt = Date.now();
|
|
133098
|
+
if (this.absorbsExplicitType(focused)) this.pendingType.baseline = focused.text;
|
|
132695
133099
|
return;
|
|
132696
133100
|
}
|
|
132697
133101
|
if (this.pendingType.text !== this.pendingType.baseline && Date.now() - this.pendingType.changedAt > 1e3) {
|
|
132698
133102
|
this.commitPendingType();
|
|
132699
133103
|
}
|
|
132700
133104
|
}
|
|
133105
|
+
/** Is the focused field showing text the recorder typed itself a moment
|
|
133106
|
+
* ago? (A password field shows dots, so any text there counts.) */
|
|
133107
|
+
absorbsExplicitType(focused) {
|
|
133108
|
+
const e = this.explicitType;
|
|
133109
|
+
if (!e || Date.now() - e.at > 6e3) return false;
|
|
133110
|
+
if (focused.text === e.text || isSecureNode(focused.node) && focused.text.length > 0) {
|
|
133111
|
+
this.explicitType = null;
|
|
133112
|
+
return true;
|
|
133113
|
+
}
|
|
133114
|
+
return false;
|
|
133115
|
+
}
|
|
132701
133116
|
/** Emit the pending typed text as a 'type' action (capture-only). */
|
|
132702
133117
|
commitPendingType() {
|
|
132703
133118
|
const p2 = this.pendingType;
|
|
@@ -132827,7 +133242,7 @@ return { locator: loc, tag: tag, text: text };
|
|
|
132827
133242
|
if (g.type === "tap") {
|
|
132828
133243
|
const src = this.cachedSource?.xml;
|
|
132829
133244
|
const platform4 = (this.sessionSnapshot ?? this.manager.getSessionInfo())?.platform;
|
|
132830
|
-
const node = src && platform4 ?
|
|
133245
|
+
const node = src && platform4 ? findTapTargetAt(src, g.x, g.y, platform4)?.target ?? null : null;
|
|
132831
133246
|
if (this.textFieldFocused && !node) return;
|
|
132832
133247
|
if (this.textFieldFocused || this.pendingType) {
|
|
132833
133248
|
await this.primeSource();
|
|
@@ -132951,8 +133366,15 @@ return { locator: loc, tag: tag, text: text };
|
|
|
132951
133366
|
}
|
|
132952
133367
|
this.cachedSource = null;
|
|
132953
133368
|
let locators = null;
|
|
132954
|
-
const
|
|
132955
|
-
|
|
133369
|
+
const hit = source ? findTapTargetAt(source, x, y, platform4) : null;
|
|
133370
|
+
const node = hit?.target ?? null;
|
|
133371
|
+
if (node && source) {
|
|
133372
|
+
locators = generateLocators(node, source, platform4);
|
|
133373
|
+
if (hit && hit.inner !== hit.target && !locators.label.startsWith('"')) {
|
|
133374
|
+
const innerLabel = generateLocators(hit.inner, source, platform4).label;
|
|
133375
|
+
if (innerLabel.startsWith('"')) locators = { ...locators, label: innerLabel };
|
|
133376
|
+
}
|
|
133377
|
+
}
|
|
132956
133378
|
const axContext = node && source ? getAccessibilityContext(source, node, 2) : null;
|
|
132957
133379
|
const webviewNode = source ? findWebviewAt(source, x, y) : null;
|
|
132958
133380
|
let webCapture = null;
|
|
@@ -133134,6 +133556,7 @@ return { locator: loc, tag: tag, text: text };
|
|
|
133134
133556
|
const res2 = await adapter.type(target2.primary, text2, true);
|
|
133135
133557
|
if (!res2.success) throw new Error(`Type failed: ${res2.error}`);
|
|
133136
133558
|
this.cachedSource = null;
|
|
133559
|
+
this.absorbTyping(text2);
|
|
133137
133560
|
let secretEnv;
|
|
133138
133561
|
if (target2.secure) secretEnv = this.secretSink?.(target2.label || "password", text2) || void 0;
|
|
133139
133562
|
const shown2 = target2.secure ? SECRET_MASK2 : text2;
|
|
@@ -133160,6 +133583,7 @@ return { locator: loc, tag: tag, text: text };
|
|
|
133160
133583
|
throw new Error(`Type failed: ${res.error || "no focused element to receive text"}. Tap an input field first.`);
|
|
133161
133584
|
}
|
|
133162
133585
|
this.cachedSource = null;
|
|
133586
|
+
this.absorbTyping(text2);
|
|
133163
133587
|
const action = {
|
|
133164
133588
|
index: this.nextIndex++,
|
|
133165
133589
|
type: "type",
|
|
@@ -133172,6 +133596,13 @@ return { locator: loc, tag: tag, text: text };
|
|
|
133172
133596
|
this.actions.push(action);
|
|
133173
133597
|
return action;
|
|
133174
133598
|
}
|
|
133599
|
+
/** The recorder typed `text` itself: drop what the typing detector was
|
|
133600
|
+
* tracking and let it absorb the field's new value (see explicitType). */
|
|
133601
|
+
absorbTyping(text2) {
|
|
133602
|
+
this.pendingType = null;
|
|
133603
|
+
this.typingSeed = null;
|
|
133604
|
+
this.explicitType = { text: text2, at: Date.now() };
|
|
133605
|
+
}
|
|
133175
133606
|
async recordSwipe(from, to, durationMs, thumbnail, screenshot, screenshotSize, perform = true) {
|
|
133176
133607
|
if (!this.recording) throw new Error("Recorder is not active.");
|
|
133177
133608
|
const adapter = this.manager.getAdapter();
|
|
@@ -133202,6 +133633,10 @@ return { locator: loc, tag: tag, text: text };
|
|
|
133202
133633
|
this.actions.push(action);
|
|
133203
133634
|
return action;
|
|
133204
133635
|
}
|
|
133636
|
+
/** The screen changed through something that isn't recorded (a tap or key while paused): drop the primed source. */
|
|
133637
|
+
screenChanged() {
|
|
133638
|
+
this.cachedSource = null;
|
|
133639
|
+
}
|
|
133205
133640
|
async recordPressKey(key2, thumbnail, screenshot, screenshotSize) {
|
|
133206
133641
|
if (!this.recording) throw new Error("Recorder is not active.");
|
|
133207
133642
|
const adapter = this.manager.getAdapter();
|
|
@@ -134713,7 +135148,7 @@ var init_recording_history_store = __esm({
|
|
|
134713
135148
|
|
|
134714
135149
|
// src/mobile/ai-codegen.ts
|
|
134715
135150
|
import { existsSync as existsSync108, readdirSync as readdirSync43, readFileSync as readFileSync89, statSync as statSync44 } from "fs";
|
|
134716
|
-
import { join as join105, relative as relative40 } from "path";
|
|
135151
|
+
import { dirname as dirname31, join as join105, relative as relative40 } from "path";
|
|
134717
135152
|
function readSample(fullPath, maxBytes = 3500) {
|
|
134718
135153
|
try {
|
|
134719
135154
|
if (!existsSync108(fullPath)) return null;
|
|
@@ -134843,6 +135278,13 @@ function inspectProject(projectPath2) {
|
|
|
134843
135278
|
allTestFiles.push(...findFiles2(join105(projectPath2, dir), /\.(spec|test)\.(ts|js|py|java|cs)$|^test_.+\.py$|_test\.py$|(Test|Tests|IT)\.(java|kt|cs)$/));
|
|
134844
135279
|
}
|
|
134845
135280
|
hints.sampleTestPaths = [...new Set(allTestFiles)].slice(0, 8);
|
|
135281
|
+
const dirCount = /* @__PURE__ */ new Map();
|
|
135282
|
+
for (const f of new Set(allTestFiles)) {
|
|
135283
|
+
const d = relative40(projectPath2, dirname31(f)).replace(/\\/g, "/");
|
|
135284
|
+
dirCount.set(d, (dirCount.get(d) || 0) + 1);
|
|
135285
|
+
}
|
|
135286
|
+
const topDir = [...dirCount.entries()].sort((a, b) => b[1] - a[1] || a[0].length - b[0].length)[0];
|
|
135287
|
+
if (topDir && topDir[0]) hints.testDir = topDir[0];
|
|
134846
135288
|
const embedTest = pickSmallest(allTestFiles.slice(0, 12));
|
|
134847
135289
|
if (embedTest) {
|
|
134848
135290
|
const sample = readSample(embedTest);
|
|
@@ -134850,7 +135292,24 @@ function inspectProject(projectPath2) {
|
|
|
134850
135292
|
hints.embeddedTestSample = { path: relative40(projectPath2, embedTest), ...sample };
|
|
134851
135293
|
}
|
|
134852
135294
|
}
|
|
134853
|
-
const pageDirs = [
|
|
135295
|
+
const pageDirs = [
|
|
135296
|
+
"tests/mobile/pages",
|
|
135297
|
+
"tests/pages",
|
|
135298
|
+
"tests/mobile/pageobjects",
|
|
135299
|
+
"src/pages",
|
|
135300
|
+
"src/pageobjects",
|
|
135301
|
+
"pages",
|
|
135302
|
+
"pageobjects",
|
|
135303
|
+
"tests/support/pages",
|
|
135304
|
+
"tests/mobile/screens",
|
|
135305
|
+
"tests/screens",
|
|
135306
|
+
"test/screens",
|
|
135307
|
+
"test/pages",
|
|
135308
|
+
"test/pageobjects",
|
|
135309
|
+
"src/screens",
|
|
135310
|
+
"screens"
|
|
135311
|
+
];
|
|
135312
|
+
const PAGE_FILE = /Page\.(ts|js|py|java|cs|kt)$|_page\.(ts|js|py)$|Screen\.(ts|js|py|java|cs|kt)$|\.screen\.(ts|js)$|_screen\.py$/;
|
|
134854
135313
|
for (const d of pageDirs) {
|
|
134855
135314
|
if (existsSync108(join105(projectPath2, d))) {
|
|
134856
135315
|
hints.pageObjectDir = d;
|
|
@@ -134859,10 +135318,10 @@ function inspectProject(projectPath2) {
|
|
|
134859
135318
|
}
|
|
134860
135319
|
let pageObjectCandidates = [];
|
|
134861
135320
|
if (hints.pageObjectDir) {
|
|
134862
|
-
pageObjectCandidates = findFiles2(join105(projectPath2, hints.pageObjectDir),
|
|
135321
|
+
pageObjectCandidates = findFiles2(join105(projectPath2, hints.pageObjectDir), PAGE_FILE);
|
|
134863
135322
|
} else {
|
|
134864
135323
|
for (const dir of testCandidates) {
|
|
134865
|
-
pageObjectCandidates.push(...findFiles2(join105(projectPath2, dir),
|
|
135324
|
+
pageObjectCandidates.push(...findFiles2(join105(projectPath2, dir), PAGE_FILE, 4, 10));
|
|
134866
135325
|
}
|
|
134867
135326
|
}
|
|
134868
135327
|
pageObjectCandidates = [...new Set(pageObjectCandidates)];
|
|
@@ -134872,7 +135331,7 @@ function inspectProject(projectPath2) {
|
|
|
134872
135331
|
const sample = readSample(embedPage);
|
|
134873
135332
|
if (sample) hints.embeddedPageObject = { path: relative40(projectPath2, embedPage), ...sample };
|
|
134874
135333
|
}
|
|
134875
|
-
const helperDirs = ["tests/mobile/helpers", "tests/helpers", "tests/support", "tests/fixtures", "tests/mobile/fixtures", "src/helpers", "src/support", "helpers", "support"];
|
|
135334
|
+
const helperDirs = ["tests/mobile/helpers", "tests/helpers", "tests/support", "tests/fixtures", "tests/mobile/fixtures", "test/support", "test/helpers", "test/fixtures", "src/helpers", "src/support", "helpers", "support"];
|
|
134876
135335
|
for (const d of helperDirs) {
|
|
134877
135336
|
if (existsSync108(join105(projectPath2, d))) {
|
|
134878
135337
|
hints.helperDir = d;
|
|
@@ -134916,6 +135375,14 @@ function formatActionForPrompt(a, n) {
|
|
|
134916
135375
|
if (a.from && a.to) parts.push(`swipe ${a.from.x},${a.from.y} \u2192 ${a.to.x},${a.to.y}`);
|
|
134917
135376
|
if (a.assertType) parts.push(`assert=${a.assertType}${a.expectedValue ? `="${a.expectedValue}"` : ""}`);
|
|
134918
135377
|
if (a.userIntent) parts.push(`intent="${a.userIntent}"`);
|
|
135378
|
+
const ea = a.elementAttrs;
|
|
135379
|
+
if (ea) {
|
|
135380
|
+
const bits = ["class", "text", "content-desc", "label", "name"].filter((k) => ea[k] && String(ea[k]).trim() && !(k === "text" && a.secretEnv)).map((k) => `${k}=${JSON.stringify(String(ea[k]).slice(0, 60))}`);
|
|
135381
|
+
if (bits.length) parts.push(`element{${bits.join(", ")}}`);
|
|
135382
|
+
}
|
|
135383
|
+
if ((a.type === "annotation" || a.type === "assertion") && a.axContext) {
|
|
135384
|
+
parts.push(`screen context (recorded): ${a.axContext.replace(/\s+/g, " ").slice(0, 700)}`);
|
|
135385
|
+
}
|
|
134919
135386
|
if (a.inWebview) {
|
|
134920
135387
|
parts.push(
|
|
134921
135388
|
a.webLocator ? `WEBVIEW step: DOM locator ${a.webLocator.strategy}:${a.webLocator.value}${a.webContext ? ` (context ${a.webContext})` : ""} \u2014 wrap in a switchContext pair` : `WEBVIEW step (no DOM locator captured): the locator above is the NATIVE accessibility projection \u2014 use it in NATIVE_APP context, do NOT switch`
|
|
@@ -134939,7 +135406,7 @@ function readMergeTarget(projectPath2, relPath) {
|
|
|
134939
135406
|
function buildMobileCodegenPrompt(input) {
|
|
134940
135407
|
const { actions, session, testName, projectPath: projectPath2 } = input;
|
|
134941
135408
|
const hints = inspectProject(projectPath2);
|
|
134942
|
-
const targetDir =
|
|
135409
|
+
const targetDir = hints.testDir || "tests/mobile";
|
|
134943
135410
|
const langChoice = input.preferredLanguage || (hints.detectedFramework === "pytest" ? "python" : hints.detectedFramework === "testng" || hints.detectedFramework === "junit" ? "java" : hints.detectedFramework === "nunit" || hints.detectedFramework === "xunit" || hints.detectedFramework === "mstest" ? "csharp" : "typescript");
|
|
134944
135411
|
const lines = [];
|
|
134945
135412
|
if (input.mergeMode && input.targetTestFile) {
|
|
@@ -134989,7 +135456,7 @@ function buildMobileCodegenPrompt(input) {
|
|
|
134989
135456
|
lines.push(`## Page-object convention detected`);
|
|
134990
135457
|
lines.push(`This project uses a page-object pattern under \`${hints.pageObjectDir}\`. EXTEND that pattern:`);
|
|
134991
135458
|
lines.push(` \u2022 If a page object already exists for the screen the recording targets, REUSE it (read with \`read_file\`, import, call its methods).`);
|
|
134992
|
-
lines.push(` \u2022 If not, CREATE a new
|
|
135459
|
+
lines.push(` \u2022 If not, CREATE a new one \u2014 same folder, same naming and shape as the sample below \u2014 before writing the spec.`);
|
|
134993
135460
|
if (hints.embeddedPageObject) {
|
|
134994
135461
|
lines.push(`### Sample page object \u2014 \`${hints.embeddedPageObject.path}\`${hints.embeddedPageObject.truncated ? " (truncated)" : ""}`);
|
|
134995
135462
|
lines.push("```");
|
|
@@ -135031,6 +135498,7 @@ function buildMobileCodegenPrompt(input) {
|
|
|
135031
135498
|
}
|
|
135032
135499
|
lines.push(`## Recorded actions (1-indexed)`);
|
|
135033
135500
|
actions.forEach((a, i) => lines.push(`- ${formatActionForPrompt(a, i + 1)}`));
|
|
135501
|
+
lines.push(`This list is the whole recording \u2014 locators, elements, values and screen context. Don't read Testver's own files under \`.testver/\` for it.`);
|
|
135034
135502
|
lines.push("");
|
|
135035
135503
|
lines.push(`## Locator guidance`);
|
|
135036
135504
|
lines.push(`- Each tap/type carries the PRIMARY locator we resolved \u2014 use it verbatim (validated against the live page source at record time).`);
|
|
@@ -135275,6 +135743,7 @@ var init_ai_codegen = __esm({
|
|
|
135275
135743
|
var api_mobile_exports = {};
|
|
135276
135744
|
__export(api_mobile_exports, {
|
|
135277
135745
|
cancelMobileClientGone: () => cancelMobileClientGone,
|
|
135746
|
+
ensureAdbPump: () => ensureAdbPump,
|
|
135278
135747
|
mountMobileRoutes: () => mountMobileRoutes,
|
|
135279
135748
|
scheduleMobileClientGone: () => scheduleMobileClientGone,
|
|
135280
135749
|
setMobileClientOwners: () => setMobileClientOwners
|
|
@@ -135334,6 +135803,44 @@ function startExternalFramePump(clientId) {
|
|
|
135334
135803
|
latestExternalFrames.delete(clientId);
|
|
135335
135804
|
})();
|
|
135336
135805
|
}
|
|
135806
|
+
function ensureAdbPump(clientId, serial, adbPath) {
|
|
135807
|
+
const existing = adbPumps.get(clientId);
|
|
135808
|
+
if (existing && !existing.stop && existing.serial === serial) {
|
|
135809
|
+
existing.wantedAt = Date.now();
|
|
135810
|
+
return existing;
|
|
135811
|
+
}
|
|
135812
|
+
if (existing) existing.stop = true;
|
|
135813
|
+
let signal;
|
|
135814
|
+
const pump = {
|
|
135815
|
+
serial,
|
|
135816
|
+
adbPath,
|
|
135817
|
+
wantedAt: Date.now(),
|
|
135818
|
+
stop: false,
|
|
135819
|
+
nextFrame: new Promise((r) => {
|
|
135820
|
+
signal = r;
|
|
135821
|
+
})
|
|
135822
|
+
};
|
|
135823
|
+
adbPumps.set(clientId, pump);
|
|
135824
|
+
void (async () => {
|
|
135825
|
+
const { captureAndroidScreenshotViaAdb: captureAndroidScreenshotViaAdb2 } = await Promise.resolve().then(() => (init_local_mobile_tools(), local_mobile_tools_exports));
|
|
135826
|
+
const { getLocalPreviewTarget: getLocalPreviewTarget2 } = await Promise.resolve().then(() => (init_local_preview_registry(), local_preview_registry_exports));
|
|
135827
|
+
while (!pump.stop) {
|
|
135828
|
+
if (getLocalPreviewTarget2(clientId)?.serial !== serial || Date.now() - pump.wantedAt > ADB_PUMP_IDLE_STOP_MS) break;
|
|
135829
|
+
const image = await captureAndroidScreenshotViaAdb2(serial, adbPath, { timeoutMs: ADB_PUMP_CAPTURE_TIMEOUT_MS }).catch(() => null);
|
|
135830
|
+
if (image) pump.latest = { image, capturedAt: Date.now() };
|
|
135831
|
+
const done2 = signal;
|
|
135832
|
+
pump.nextFrame = new Promise((r) => {
|
|
135833
|
+
signal = r;
|
|
135834
|
+
});
|
|
135835
|
+
done2();
|
|
135836
|
+
await new Promise((r) => setTimeout(r, image ? 150 : 1e3));
|
|
135837
|
+
}
|
|
135838
|
+
pump.stop = true;
|
|
135839
|
+
signal();
|
|
135840
|
+
if (adbPumps.get(clientId) === pump) adbPumps.delete(clientId);
|
|
135841
|
+
})();
|
|
135842
|
+
return pump;
|
|
135843
|
+
}
|
|
135337
135844
|
function extractClientId2(req) {
|
|
135338
135845
|
const h = req.headers["x-client-id"];
|
|
135339
135846
|
if (typeof h === "string" && h.length > 0) return h;
|
|
@@ -135841,7 +136348,8 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
135841
136348
|
reuseTicketStore.issue(clientId, info, {
|
|
135842
136349
|
deviceName: info.device,
|
|
135843
136350
|
platformName: info.platform === "ios" ? "iOS" : "Android",
|
|
135844
|
-
platformVersion: osVersion
|
|
136351
|
+
platformVersion: osVersion,
|
|
136352
|
+
appId
|
|
135845
136353
|
});
|
|
135846
136354
|
} catch (err5) {
|
|
135847
136355
|
logger41.warn(`reuseTicketStore.issue (start) failed: ${err5.message}`);
|
|
@@ -135879,7 +136387,8 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
135879
136387
|
res.json({ session: info });
|
|
135880
136388
|
} catch (err5) {
|
|
135881
136389
|
logger41.error(`session start failed: ${err5.message}`);
|
|
135882
|
-
|
|
136390
|
+
const busy2 = err5.name === "LocalDeviceBusyError";
|
|
136391
|
+
res.status(busy2 ? 409 : 500).json({ error: err5.message, ...busy2 ? { code: "LOCAL_DEVICE_BUSY" } : {} });
|
|
135883
136392
|
}
|
|
135884
136393
|
});
|
|
135885
136394
|
app.get("/api/mobile/session", (req, res) => {
|
|
@@ -135910,13 +136419,32 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
135910
136419
|
const { getLocalPreviewTarget: getLocalPreviewTarget2 } = await Promise.resolve().then(() => (init_local_preview_registry(), local_preview_registry_exports));
|
|
135911
136420
|
const target2 = getLocalPreviewTarget2(clientId);
|
|
135912
136421
|
if (target2 && target2.platform === "android") {
|
|
135913
|
-
const
|
|
135914
|
-
|
|
135915
|
-
|
|
136422
|
+
const pump = ensureAdbPump(clientId, target2.serial, target2.adbPath);
|
|
136423
|
+
if (!pump.latest) {
|
|
136424
|
+
await Promise.race([pump.nextFrame, new Promise((r) => setTimeout(r, ADB_FIRST_FRAME_WAIT_MS))]);
|
|
136425
|
+
}
|
|
136426
|
+
const since = Number(req.query.since) || 0;
|
|
136427
|
+
if (since && pump.latest && pump.latest.capturedAt <= since) {
|
|
136428
|
+
await Promise.race([pump.nextFrame, new Promise((r) => setTimeout(r, ADB_UNCHANGED_WAIT_MS))]);
|
|
136429
|
+
if (pump.latest && pump.latest.capturedAt <= since) {
|
|
136430
|
+
reuseTicketStore.refresh(clientId);
|
|
136431
|
+
res.json({ unchanged: true, capturedAt: pump.latest.capturedAt });
|
|
136432
|
+
return;
|
|
136433
|
+
}
|
|
136434
|
+
}
|
|
136435
|
+
const frame = pump.latest;
|
|
136436
|
+
if (frame) {
|
|
135916
136437
|
reuseTicketStore.refresh(clientId);
|
|
135917
|
-
res.json({ image, capturedAt: Date.now() });
|
|
136438
|
+
res.json({ image: frame.image, capturedAt: frame.capturedAt, ...Date.now() - frame.capturedAt > ADB_FRESH_MS ? { delayed: true } : {} });
|
|
136439
|
+
return;
|
|
136440
|
+
}
|
|
136441
|
+
const cachedExt = latestExternalFrames.get(clientId);
|
|
136442
|
+
if (cachedExt && Date.now() - cachedExt.capturedAt < 5e3) {
|
|
136443
|
+
res.json({ image: cachedExt.image, capturedAt: cachedExt.capturedAt, delayed: true });
|
|
135918
136444
|
return;
|
|
135919
136445
|
}
|
|
136446
|
+
res.status(503).json({ error: "Waiting for the device's first frame \u2014 it is busy with the test run.", code: "FRAME_PENDING" });
|
|
136447
|
+
return;
|
|
135920
136448
|
} else if (target2 && target2.platform === "ios") {
|
|
135921
136449
|
const { captureIosScreenshot: captureIosScreenshot2 } = await Promise.resolve().then(() => (init_local_mobile_tools(), local_mobile_tools_exports));
|
|
135922
136450
|
const image = await captureIosScreenshot2(target2.serial, target2.iosToolsPath);
|
|
@@ -136346,6 +136874,46 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
136346
136874
|
}
|
|
136347
136875
|
const r = await adapter.swipe(from, to, durationMs);
|
|
136348
136876
|
if (!r.success) return res.status(500).json({ error: r.error || "swipe failed" });
|
|
136877
|
+
recorderPool()?.getFor(clientId).screenChanged();
|
|
136878
|
+
res.json({ ok: true });
|
|
136879
|
+
} catch (err5) {
|
|
136880
|
+
res.status(500).json({ error: err5.message });
|
|
136881
|
+
}
|
|
136882
|
+
});
|
|
136883
|
+
app.post("/api/mobile/session/tap", async (req, res) => {
|
|
136884
|
+
const mPool = mobilePool();
|
|
136885
|
+
if (!mPool) return res.status(500).json({ error: "Mobile session pool not initialized." });
|
|
136886
|
+
const clientId = extractClientId2(req);
|
|
136887
|
+
if (!clientId) return res.status(400).json({ error: "Missing X-Client-Id header." });
|
|
136888
|
+
if (rejectIfLocked(req, res, clientId)) return;
|
|
136889
|
+
const x = Number(req.body?.x);
|
|
136890
|
+
const y = Number(req.body?.y);
|
|
136891
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return res.status(400).json({ error: "Body must include numeric x and y." });
|
|
136892
|
+
try {
|
|
136893
|
+
const adapter = mPool.getFor(clientId).getAdapter();
|
|
136894
|
+
if (!adapter || !adapter.isActive()) return res.status(400).json({ error: "No active mobile session." });
|
|
136895
|
+
const r = await adapter.tapAt({ x, y });
|
|
136896
|
+
if (!r.success) return res.status(500).json({ error: r.error || "tap failed" });
|
|
136897
|
+
recorderPool()?.getFor(clientId).screenChanged();
|
|
136898
|
+
res.json({ ok: true });
|
|
136899
|
+
} catch (err5) {
|
|
136900
|
+
res.status(500).json({ error: err5.message });
|
|
136901
|
+
}
|
|
136902
|
+
});
|
|
136903
|
+
app.post("/api/mobile/session/press-key", async (req, res) => {
|
|
136904
|
+
const mPool = mobilePool();
|
|
136905
|
+
if (!mPool) return res.status(500).json({ error: "Mobile session pool not initialized." });
|
|
136906
|
+
const clientId = extractClientId2(req);
|
|
136907
|
+
if (!clientId) return res.status(400).json({ error: "Missing X-Client-Id header." });
|
|
136908
|
+
if (rejectIfLocked(req, res, clientId)) return;
|
|
136909
|
+
const key2 = String(req.body?.key ?? "");
|
|
136910
|
+
if (!key2) return res.status(400).json({ error: "Body must include key." });
|
|
136911
|
+
try {
|
|
136912
|
+
const adapter = mPool.getFor(clientId).getAdapter();
|
|
136913
|
+
if (!adapter || !adapter.isActive()) return res.status(400).json({ error: "No active mobile session." });
|
|
136914
|
+
const r = await adapter.pressKey(key2);
|
|
136915
|
+
if (!r.success) return res.status(500).json({ error: r.error || "key press failed" });
|
|
136916
|
+
recorderPool()?.getFor(clientId).screenChanged();
|
|
136349
136917
|
res.json({ ok: true });
|
|
136350
136918
|
} catch (err5) {
|
|
136351
136919
|
res.status(500).json({ error: err5.message });
|
|
@@ -136396,7 +136964,9 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
136396
136964
|
reuseTicketStore.issue(clientId, liveInfo, {
|
|
136397
136965
|
deviceName: liveInfo.device,
|
|
136398
136966
|
platformName: liveInfo.platform === "ios" ? "iOS" : "Android",
|
|
136399
|
-
platformVersion: ""
|
|
136967
|
+
platformVersion: "",
|
|
136968
|
+
// Same session, same build: keep the app the session started with.
|
|
136969
|
+
appId: reuseTicketStore.peek(clientId)?.appId
|
|
136400
136970
|
});
|
|
136401
136971
|
} catch (err5) {
|
|
136402
136972
|
console.warn("[testver] reuseTicketStore.issue (stop) failed:", err5.message);
|
|
@@ -137092,7 +137662,7 @@ ${previousContext}`);
|
|
|
137092
137662
|
}
|
|
137093
137663
|
});
|
|
137094
137664
|
}
|
|
137095
|
-
var latestExternalFrames, externalFramePumps, FRAME_PUMP_INTERVAL_MS, logger41, MOBILE_PROVIDER_IDS, EXCLUDED_TOOLS_FOR_MOBILE_RECORDER, mobileClientOwnersRef, clientGoneTimers, onClientGone;
|
|
137665
|
+
var latestExternalFrames, externalFramePumps, FRAME_PUMP_INTERVAL_MS, adbPumps, ADB_PUMP_CAPTURE_TIMEOUT_MS, ADB_PUMP_IDLE_STOP_MS, ADB_FIRST_FRAME_WAIT_MS, ADB_FRESH_MS, ADB_UNCHANGED_WAIT_MS, logger41, MOBILE_PROVIDER_IDS, EXCLUDED_TOOLS_FOR_MOBILE_RECORDER, mobileClientOwnersRef, clientGoneTimers, onClientGone;
|
|
137096
137666
|
var init_api_mobile = __esm({
|
|
137097
137667
|
"src/ui/routes/api-mobile.ts"() {
|
|
137098
137668
|
"use strict";
|
|
@@ -137119,6 +137689,12 @@ var init_api_mobile = __esm({
|
|
|
137119
137689
|
latestExternalFrames = /* @__PURE__ */ new Map();
|
|
137120
137690
|
externalFramePumps = /* @__PURE__ */ new Map();
|
|
137121
137691
|
FRAME_PUMP_INTERVAL_MS = 800;
|
|
137692
|
+
adbPumps = /* @__PURE__ */ new Map();
|
|
137693
|
+
ADB_PUMP_CAPTURE_TIMEOUT_MS = 45e3;
|
|
137694
|
+
ADB_PUMP_IDLE_STOP_MS = 15e3;
|
|
137695
|
+
ADB_FIRST_FRAME_WAIT_MS = 4e3;
|
|
137696
|
+
ADB_FRESH_MS = 3e3;
|
|
137697
|
+
ADB_UNCHANGED_WAIT_MS = 2500;
|
|
137122
137698
|
logger41 = createLogger("api-mobile");
|
|
137123
137699
|
MOBILE_PROVIDER_IDS = ["browserstack", "saucelabs", "lambdatest", "local-appium"];
|
|
137124
137700
|
EXCLUDED_TOOLS_FOR_MOBILE_RECORDER = /* @__PURE__ */ new Set([
|
|
@@ -137127,6 +137703,14 @@ var init_api_mobile = __esm({
|
|
|
137127
137703
|
"mobile_tap",
|
|
137128
137704
|
"mobile_type",
|
|
137129
137705
|
"mobile_swipe",
|
|
137706
|
+
"mobile_drag",
|
|
137707
|
+
"mobile_scroll_to",
|
|
137708
|
+
"mobile_wait_for",
|
|
137709
|
+
"mobile_alert",
|
|
137710
|
+
"mobile_tap_at",
|
|
137711
|
+
"mobile_list_contexts",
|
|
137712
|
+
"mobile_switch_context",
|
|
137713
|
+
"mobile_orientation",
|
|
137130
137714
|
"mobile_press_key",
|
|
137131
137715
|
"mobile_screenshot",
|
|
137132
137716
|
"mobile_snapshot",
|
|
@@ -138064,7 +138648,7 @@ var init_skills_chat_history_store = __esm({
|
|
|
138064
138648
|
|
|
138065
138649
|
// src/ui/workflows/workflow-store.ts
|
|
138066
138650
|
import { readFileSync as readFileSync92, mkdirSync as mkdirSync52, existsSync as existsSync113, unlinkSync as unlinkSync12 } from "fs";
|
|
138067
|
-
import { randomBytes as
|
|
138651
|
+
import { randomBytes as randomBytes17 } from "crypto";
|
|
138068
138652
|
import { join as join110 } from "path";
|
|
138069
138653
|
var EMPTY_DATA, MAX_WORKFLOWS, WorkflowStore;
|
|
138070
138654
|
var init_workflow_store = __esm({
|
|
@@ -138189,8 +138773,8 @@ var init_workflow_store = __esm({
|
|
|
138189
138773
|
const workflow = this.data.workflows[workflowId];
|
|
138190
138774
|
if (!workflow) return void 0;
|
|
138191
138775
|
const config = {
|
|
138192
|
-
webhookId:
|
|
138193
|
-
secret:
|
|
138776
|
+
webhookId: randomBytes17(12).toString("hex"),
|
|
138777
|
+
secret: randomBytes17(32).toString("hex"),
|
|
138194
138778
|
name: options?.name,
|
|
138195
138779
|
enabled: true,
|
|
138196
138780
|
variableMapping: options?.variableMapping,
|
|
@@ -140820,7 +141404,7 @@ var api_workflows_exports = {};
|
|
|
140820
141404
|
__export(api_workflows_exports, {
|
|
140821
141405
|
mountWorkflowRoutes: () => mountWorkflowRoutes
|
|
140822
141406
|
});
|
|
140823
|
-
import { timingSafeEqual as
|
|
141407
|
+
import { timingSafeEqual as timingSafeEqual7 } from "crypto";
|
|
140824
141408
|
function broadcast5(wss, data) {
|
|
140825
141409
|
const msg = JSON.stringify(data);
|
|
140826
141410
|
for (const client of wss.clients) {
|
|
@@ -141490,7 +142074,7 @@ function matchesCronField2(field, value) {
|
|
|
141490
142074
|
function safeCompare(a, b) {
|
|
141491
142075
|
if (a.length !== b.length) return false;
|
|
141492
142076
|
try {
|
|
141493
|
-
return
|
|
142077
|
+
return timingSafeEqual7(Buffer.from(a, "utf-8"), Buffer.from(b, "utf-8"));
|
|
141494
142078
|
} catch {
|
|
141495
142079
|
return false;
|
|
141496
142080
|
}
|
|
@@ -150572,7 +151156,7 @@ __export(api_output_exports, {
|
|
|
150572
151156
|
});
|
|
150573
151157
|
import { existsSync as existsSync118, statSync as statSync46, readdirSync as readdirSync45, readFileSync as readFileSync96, createReadStream as createReadStream2 } from "fs";
|
|
150574
151158
|
import { resolve as resolve32, extname as extname20, join as join115, relative as relative41, isAbsolute as isAbsolute24 } from "path";
|
|
150575
|
-
import { randomBytes as
|
|
151159
|
+
import { randomBytes as randomBytes18 } from "crypto";
|
|
150576
151160
|
import { watch } from "chokidar";
|
|
150577
151161
|
function normalizePath(p2) {
|
|
150578
151162
|
return p2.replace(/\\/g, "/");
|
|
@@ -150587,7 +151171,7 @@ function issueViewTicket(folderId, path2) {
|
|
|
150587
151171
|
const now = Date.now();
|
|
150588
151172
|
for (const [k, v] of viewTickets) if (v.expires < now) viewTickets.delete(k);
|
|
150589
151173
|
while (viewTickets.size >= 500) viewTickets.delete(viewTickets.keys().next().value);
|
|
150590
|
-
const ticket =
|
|
151174
|
+
const ticket = randomBytes18(24).toString("base64url");
|
|
150591
151175
|
viewTickets.set(ticket, { folderId, path: path2, expires: now + VIEW_TICKET_MS });
|
|
150592
151176
|
return ticket;
|
|
150593
151177
|
}
|
|
@@ -152468,10 +153052,10 @@ __export(trace_viewer_exports, {
|
|
|
152468
153052
|
traceViewerCandidates: () => traceViewerCandidates,
|
|
152469
153053
|
traceViewerHandler: () => traceViewerHandler
|
|
152470
153054
|
});
|
|
152471
|
-
import { existsSync as existsSync120, mkdirSync as mkdirSync57, readdirSync as readdirSync46, readFileSync as readFileSync98, renameSync as renameSync6, rmSync as
|
|
153055
|
+
import { existsSync as existsSync120, mkdirSync as mkdirSync57, readdirSync as readdirSync46, readFileSync as readFileSync98, renameSync as renameSync6, rmSync as rmSync6, writeFileSync as writeFileSync30 } from "fs";
|
|
152472
153056
|
import { createRequire as createRequire4 } from "module";
|
|
152473
153057
|
import { homedir as homedir4 } from "os";
|
|
152474
|
-
import { dirname as
|
|
153058
|
+
import { dirname as dirname32, join as join117 } from "path";
|
|
152475
153059
|
function compareVersions(a, b) {
|
|
152476
153060
|
const parse = (v) => {
|
|
152477
153061
|
const [core = "", pre] = v.split("-", 2);
|
|
@@ -152499,7 +153083,7 @@ function fromPackageRoot(root, source) {
|
|
|
152499
153083
|
}
|
|
152500
153084
|
function resolvePackage(fromFile, name2) {
|
|
152501
153085
|
try {
|
|
152502
|
-
return
|
|
153086
|
+
return dirname32(createRequire4(fromFile).resolve(`${name2}/package.json`));
|
|
152503
153087
|
} catch {
|
|
152504
153088
|
return void 0;
|
|
152505
153089
|
}
|
|
@@ -152612,7 +153196,7 @@ function extractJavaTraceViewer(jar, dest) {
|
|
|
152612
153196
|
if (!index) return false;
|
|
152613
153197
|
const pkg = index.name.slice(0, index.name.indexOf("lib/vite/traceViewer/"));
|
|
152614
153198
|
const prefix = `${pkg}lib/vite/traceViewer/`;
|
|
152615
|
-
|
|
153199
|
+
rmSync6(tmp, { recursive: true, force: true });
|
|
152616
153200
|
for (const x of zip.entries) {
|
|
152617
153201
|
let rel;
|
|
152618
153202
|
if (x.name === `${pkg}package.json`) rel = "package.json";
|
|
@@ -152620,17 +153204,17 @@ function extractJavaTraceViewer(jar, dest) {
|
|
|
152620
153204
|
else continue;
|
|
152621
153205
|
if (/[\\:]/.test(rel) || rel.split("/").some((seg) => seg === "" || seg === "." || seg === "..")) continue;
|
|
152622
153206
|
const out = join117(tmp, ...rel.split("/"));
|
|
152623
|
-
mkdirSync57(
|
|
153207
|
+
mkdirSync57(dirname32(out), { recursive: true });
|
|
152624
153208
|
writeFileSync30(out, zip.read(x, MAX_VIEWER_FILE));
|
|
152625
153209
|
}
|
|
152626
153210
|
if (!existsSync120(join117(tmp, "lib", "vite", "traceViewer", "index.html")) || !existsSync120(join117(tmp, "package.json"))) throw new Error("no viewer");
|
|
152627
|
-
mkdirSync57(
|
|
152628
|
-
|
|
153211
|
+
mkdirSync57(dirname32(dest), { recursive: true });
|
|
153212
|
+
rmSync6(dest, { recursive: true, force: true });
|
|
152629
153213
|
renameSync6(tmp, dest);
|
|
152630
153214
|
return true;
|
|
152631
153215
|
} catch {
|
|
152632
153216
|
try {
|
|
152633
|
-
|
|
153217
|
+
rmSync6(tmp, { recursive: true, force: true });
|
|
152634
153218
|
} catch {
|
|
152635
153219
|
}
|
|
152636
153220
|
return false;
|
|
@@ -152718,7 +153302,7 @@ var init_client_resume = __esm({
|
|
|
152718
153302
|
|
|
152719
153303
|
// src/ui/server.ts
|
|
152720
153304
|
import { createServer as createServer3 } from "http";
|
|
152721
|
-
import { join as join118, dirname as
|
|
153305
|
+
import { join as join118, dirname as dirname33, relative as relative42 } from "path";
|
|
152722
153306
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
152723
153307
|
import { existsSync as existsSync121, readFileSync as readFileSync99, mkdirSync as mkdirSync58, unlinkSync as unlinkSync13 } from "fs";
|
|
152724
153308
|
async function createUIServer(options) {
|
|
@@ -152836,10 +153420,10 @@ async function createUIServer(options) {
|
|
|
152836
153420
|
if (!cfg || !cfg.enabled || !cfg.username || !cfg.accessKey) return null;
|
|
152837
153421
|
return { username: cfg.username, accessKey: cfg.accessKey, region: cfg.region };
|
|
152838
153422
|
},
|
|
152839
|
-
onManagerDisconnect: async (clientId) => {
|
|
153423
|
+
onManagerDisconnect: async (clientId, reason) => {
|
|
152840
153424
|
try {
|
|
152841
153425
|
const { sendTo: sendTo3 } = await Promise.resolve().then(() => (init_shared_streaming(), shared_streaming_exports));
|
|
152842
|
-
sendTo3(wss, clientId, { type: "mobile-session-closed" });
|
|
153426
|
+
sendTo3(wss, clientId, { type: "mobile-session-closed", ...reason ? { reason } : {} });
|
|
152843
153427
|
} catch {
|
|
152844
153428
|
}
|
|
152845
153429
|
try {
|
|
@@ -153378,7 +153962,7 @@ async function createUIServer(options) {
|
|
|
153378
153962
|
});
|
|
153379
153963
|
function getServerPackageVersion() {
|
|
153380
153964
|
try {
|
|
153381
|
-
const dir =
|
|
153965
|
+
const dir = dirname33(fileURLToPath4(import.meta.url));
|
|
153382
153966
|
return JSON.parse(readFileSync99(join118(dir, "..", "package.json"), "utf-8")).version || "0.0.0";
|
|
153383
153967
|
} catch {
|
|
153384
153968
|
return "0.0.0";
|
|
@@ -153416,7 +154000,7 @@ async function createUIServer(options) {
|
|
|
153416
154000
|
const req = createRequire5(import.meta.url);
|
|
153417
154001
|
let testverCoreRoot;
|
|
153418
154002
|
try {
|
|
153419
|
-
testverCoreRoot =
|
|
154003
|
+
testverCoreRoot = dirname33(req.resolve("playwright-core/package.json"));
|
|
153420
154004
|
} catch {
|
|
153421
154005
|
}
|
|
153422
154006
|
const { traceViewerHandler: traceViewerHandler2 } = await Promise.resolve().then(() => (init_trace_viewer(), trace_viewer_exports));
|
|
@@ -153667,7 +154251,7 @@ async function createUIServer(options) {
|
|
|
153667
154251
|
scheduler.stop();
|
|
153668
154252
|
remoteUpdatesService?.stop();
|
|
153669
154253
|
try {
|
|
153670
|
-
await mobileSessionPool.shutdown(1e4
|
|
154254
|
+
await mobileSessionPool.shutdown(1e4);
|
|
153671
154255
|
} catch {
|
|
153672
154256
|
}
|
|
153673
154257
|
clearInterval(wsHeartbeatInterval);
|
|
@@ -153775,7 +154359,7 @@ var init_server = __esm({
|
|
|
153775
154359
|
init_route_errors();
|
|
153776
154360
|
init_utils();
|
|
153777
154361
|
init_atomic_write();
|
|
153778
|
-
__dirname =
|
|
154362
|
+
__dirname = dirname33(fileURLToPath4(import.meta.url));
|
|
153779
154363
|
}
|
|
153780
154364
|
});
|
|
153781
154365
|
|
|
@@ -156203,11 +156787,11 @@ if (args[0] === "deploy") {
|
|
|
156203
156787
|
const deployDir = join122(workingDirectory, ".testver-deploy");
|
|
156204
156788
|
const ensureDeployEnvSafety = async () => {
|
|
156205
156789
|
const { readFileSync: readFileSync101, appendFileSync: appendFileSync2 } = await import("fs");
|
|
156206
|
-
const { randomBytes:
|
|
156790
|
+
const { randomBytes: randomBytes19 } = await import("crypto");
|
|
156207
156791
|
const { ensureTwoFactorKeyLine: ensureTwoFactorKeyLine2, ensureGitignoreLine: ensureGitignoreLine2 } = await Promise.resolve().then(() => (init_deploy_env(), deploy_env_exports));
|
|
156208
156792
|
const envFile = join122(deployDir, ".env");
|
|
156209
156793
|
const envText = existsSync124(envFile) ? readFileSync101(envFile, "utf-8") : "";
|
|
156210
|
-
const addition = ensureTwoFactorKeyLine2(envText, () =>
|
|
156794
|
+
const addition = ensureTwoFactorKeyLine2(envText, () => randomBytes19(32).toString("hex"));
|
|
156211
156795
|
if (addition) {
|
|
156212
156796
|
appendFileSync2(envFile, addition);
|
|
156213
156797
|
console.log(" \u2705 TESTVER_2FA_KEY added to .testver-deploy/.env \u2014 it keeps two-factor sign-in working across container rebuilds; back this file up and never change the value");
|