@testver/testver 1.2.4 → 1.2.5
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
CHANGED
|
@@ -7520,7 +7520,9 @@ __export(local_mobile_tools_exports, {
|
|
|
7520
7520
|
resolveAdb: () => resolveAdb,
|
|
7521
7521
|
resolveLocalDeviceKey: () => resolveLocalDeviceKey,
|
|
7522
7522
|
startAvd: () => startAvd,
|
|
7523
|
+
startIosSimulator: () => startIosSimulator,
|
|
7523
7524
|
stopEmulator: () => stopEmulator,
|
|
7525
|
+
stopIosSimulator: () => stopIosSimulator,
|
|
7524
7526
|
wdaLocalPortFor: () => wdaLocalPortFor
|
|
7525
7527
|
});
|
|
7526
7528
|
import { spawn } from "child_process";
|
|
@@ -8076,6 +8078,38 @@ async function listIosSimulatorsUncached() {
|
|
|
8076
8078
|
if (!res.ok) return [];
|
|
8077
8079
|
return parseSimctlDevices(res.stdout);
|
|
8078
8080
|
}
|
|
8081
|
+
async function findIosSimulator(udid) {
|
|
8082
|
+
if (process.platform !== "darwin") throw new Error("iOS simulators run only on a Mac.");
|
|
8083
|
+
if (!isIosSimulatorUdid(udid)) throw new Error("Give the simulator UDID.");
|
|
8084
|
+
const sim = (await listIosSimulatorsUncached()).find((s) => s.serial.toUpperCase() === udid.toUpperCase());
|
|
8085
|
+
if (!sim) throw new Error("No iOS simulator with that UDID on this Mac.");
|
|
8086
|
+
return sim;
|
|
8087
|
+
}
|
|
8088
|
+
async function startIosSimulator(udid, opts = {}) {
|
|
8089
|
+
const sim = await findIosSimulator(udid);
|
|
8090
|
+
const label3 = simulatorLabel(sim);
|
|
8091
|
+
if (!sim.booted) {
|
|
8092
|
+
const boot = await run("xcrun", ["simctl", "boot", udid], { timeoutMs: 6e4 });
|
|
8093
|
+
if (!boot.ok && !/current state: Booted/i.test(boot.stderr)) {
|
|
8094
|
+
throw new Error(`The simulator "${label3}" did not start: ${(boot.stderr || boot.error || "").trim().split("\n")[0]}`);
|
|
8095
|
+
}
|
|
8096
|
+
}
|
|
8097
|
+
await run("open", ["-a", "Simulator", "--args", "-CurrentDeviceUDID", udid], { timeoutMs: 15e3 });
|
|
8098
|
+
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
8099
|
+
const ready = await run("xcrun", ["simctl", "bootstatus", udid], { timeoutMs });
|
|
8100
|
+
simulatorCache = null;
|
|
8101
|
+
if (!ready.ok) {
|
|
8102
|
+
throw new Error(`The simulator "${label3}" started but had not finished booting after ${Math.round(timeoutMs / 1e3)} s \u2014 wait for its home screen, then try again.`);
|
|
8103
|
+
}
|
|
8104
|
+
}
|
|
8105
|
+
async function stopIosSimulator(udid) {
|
|
8106
|
+
const sim = await findIosSimulator(udid);
|
|
8107
|
+
const r = await run("xcrun", ["simctl", "shutdown", udid], { timeoutMs: 3e4 });
|
|
8108
|
+
simulatorCache = null;
|
|
8109
|
+
if (!r.ok && !/current state: Shutdown/i.test(r.stderr)) {
|
|
8110
|
+
throw new Error(`Couldn't close "${simulatorLabel(sim)}": ${(r.stderr || r.error || "").trim().split("\n")[0]}`);
|
|
8111
|
+
}
|
|
8112
|
+
}
|
|
8079
8113
|
function parseSimctlDevices(stdout) {
|
|
8080
8114
|
try {
|
|
8081
8115
|
const parsed = JSON.parse(stdout);
|
|
@@ -8091,14 +8125,14 @@ function parseSimctlDevices(stdout) {
|
|
|
8091
8125
|
serial: sim.udid,
|
|
8092
8126
|
kind: "simulator",
|
|
8093
8127
|
// Label carries "(Simulator)" so every picker shows it without
|
|
8094
|
-
// needing its own kind-awareness
|
|
8095
|
-
|
|
8096
|
-
name: `${sim.name ?? "iOS Simulator"} (Simulator${booted ? ", booted" : ""})`,
|
|
8128
|
+
// needing its own kind-awareness.
|
|
8129
|
+
name: `${sim.name ?? "iOS Simulator"} (Simulator)`,
|
|
8097
8130
|
manufacturer: "Apple",
|
|
8098
8131
|
platformVersion: version,
|
|
8099
|
-
// 'connected' even when shutdown — XCUITest auto-boots by UDID,
|
|
8100
|
-
//
|
|
8101
|
-
//
|
|
8132
|
+
// 'connected' even when shutdown — XCUITest auto-boots by UDID, so
|
|
8133
|
+
// a saved run naming it still works. `booted` tells the two apart
|
|
8134
|
+
// for Settings (Start / Close, the count) and the device pickers
|
|
8135
|
+
// (running simulators only).
|
|
8102
8136
|
state: "connected",
|
|
8103
8137
|
booted
|
|
8104
8138
|
});
|
|
@@ -8264,7 +8298,7 @@ async function detectLocalMobileStatusNow(input) {
|
|
|
8264
8298
|
appium
|
|
8265
8299
|
};
|
|
8266
8300
|
}
|
|
8267
|
-
var ADB_HIT_CACHE_MS, ADB_MISS_CACHE_MS, adbCache, savedSdkCache, avdListCache, AVD_KEY_PREFIX, IOS_SHOT_FAIL_SKIP_MS, iosShotFailedAt, adbVersionCache, simulatorCache, xcodeCache, driversCache, driversInFlight, WEBVIEW_HINT, statusInFlight;
|
|
8301
|
+
var ADB_HIT_CACHE_MS, ADB_MISS_CACHE_MS, adbCache, savedSdkCache, avdListCache, AVD_KEY_PREFIX, IOS_SHOT_FAIL_SKIP_MS, iosShotFailedAt, adbVersionCache, simulatorCache, simulatorLabel, xcodeCache, driversCache, driversInFlight, WEBVIEW_HINT, statusInFlight;
|
|
8268
8302
|
var init_local_mobile_tools = __esm({
|
|
8269
8303
|
"src/mobile/local-mobile-tools.ts"() {
|
|
8270
8304
|
"use strict";
|
|
@@ -8278,6 +8312,7 @@ var init_local_mobile_tools = __esm({
|
|
|
8278
8312
|
iosShotFailedAt = /* @__PURE__ */ new Map();
|
|
8279
8313
|
adbVersionCache = /* @__PURE__ */ new Map();
|
|
8280
8314
|
simulatorCache = null;
|
|
8315
|
+
simulatorLabel = (sim) => (sim.name ?? sim.serial).replace(/\s*\(Simulator[^)]*\)$/, "");
|
|
8281
8316
|
xcodeCache = null;
|
|
8282
8317
|
driversCache = null;
|
|
8283
8318
|
driversInFlight = null;
|
|
@@ -9271,6 +9306,10 @@ var init_local_appium = __esm({
|
|
|
9271
9306
|
* show them with a "Tap to authorize" / "Offline" badge instead of
|
|
9272
9307
|
* silently dropping them — the user wants to know their device is
|
|
9273
9308
|
* plugged in even when something's wrong.
|
|
9309
|
+
*
|
|
9310
|
+
* Only devices that are on: emulators that aren't running and shut-down
|
|
9311
|
+
* simulators are left out (start them in Settings → Connectors → Local
|
|
9312
|
+
* Devices). A saved run that names one still starts it.
|
|
9274
9313
|
*/
|
|
9275
9314
|
async listDevices(creds) {
|
|
9276
9315
|
const out = [];
|
|
@@ -9280,23 +9319,12 @@ var init_local_appium = __esm({
|
|
|
9280
9319
|
for (const d of android.devices) {
|
|
9281
9320
|
out.push(probeToMobileDevice(d, "android"));
|
|
9282
9321
|
}
|
|
9283
|
-
for (const avd of android.avds ?? []) {
|
|
9284
|
-
if (avd.running) continue;
|
|
9285
|
-
out.push({
|
|
9286
|
-
id: `local-appium:${AVD_KEY_PREFIX}${avd.name}`,
|
|
9287
|
-
providerId: "local-appium",
|
|
9288
|
-
platform: "android",
|
|
9289
|
-
name: `${avd.name.replace(/_/g, " ")} (Emulator, starts when picked)`,
|
|
9290
|
-
os: "Android",
|
|
9291
|
-
realMobile: false,
|
|
9292
|
-
rawDeviceKey: `${AVD_KEY_PREFIX}${avd.name}`
|
|
9293
|
-
});
|
|
9294
|
-
}
|
|
9295
9322
|
const ios = await detectIosStatus(creds.iosToolsPath).catch((err5) => {
|
|
9296
9323
|
throw err5;
|
|
9297
9324
|
});
|
|
9298
9325
|
if (ios.available) {
|
|
9299
9326
|
for (const d of ios.devices) {
|
|
9327
|
+
if (d.kind === "simulator" && !d.booted) continue;
|
|
9300
9328
|
out.push(probeToMobileDevice(d, "ios"));
|
|
9301
9329
|
}
|
|
9302
9330
|
}
|
|
@@ -37538,18 +37566,21 @@ var init_mobile = __esm({
|
|
|
37538
37566
|
category: "mobile",
|
|
37539
37567
|
definition: {
|
|
37540
37568
|
name: "mobile_launch_app",
|
|
37541
|
-
description:
|
|
37569
|
+
description: 'Start the mobile automation session against the device and app the user already selected in the Mobile picker. Returns the session info and an accessibility snapshot of the current screen. Call it first when no session is running (the "Mobile session" note in the message says). When a session is already running it brings the app back to the front \u2014 use it to recover after the app crashed or closed.',
|
|
37542
37570
|
parameters: { type: "object", properties: {} }
|
|
37543
37571
|
},
|
|
37544
37572
|
handler: async (_args, ctx) => {
|
|
37545
37573
|
const manager = getManager(ctx);
|
|
37546
37574
|
try {
|
|
37575
|
+
const before = manager.isActive() ? manager.getSessionInfo()?.sessionId : void 0;
|
|
37547
37576
|
const info = await manager.start();
|
|
37577
|
+
const reused = !!before && before === info.sessionId;
|
|
37578
|
+
if (reused) await manager.reopenApp();
|
|
37548
37579
|
const adapter = manager.getAdapter();
|
|
37549
37580
|
const tree = await freshTree(adapter);
|
|
37550
37581
|
step(ctx, "mobile_launch_app", "ok", `${info.providerId}/${info.device}`);
|
|
37551
37582
|
return [
|
|
37552
|
-
|
|
37583
|
+
reused ? "Mobile session already running \u2014 the app is in front." : "Mobile session started.",
|
|
37553
37584
|
`Provider: ${info.providerId}`,
|
|
37554
37585
|
`Device: ${info.device}`,
|
|
37555
37586
|
`Platform: ${info.platform}`,
|
|
@@ -42637,7 +42668,7 @@ async function buildFetchOptions(request, vars, baseDir = process.cwd()) {
|
|
|
42637
42668
|
const resolvedKey = resolveVariables(field.key, vars);
|
|
42638
42669
|
if (field.fieldType === "file" && field.filePath) {
|
|
42639
42670
|
const { readFileSync: readFileSync101 } = await import("fs");
|
|
42640
|
-
const { resolve: resolve35, basename:
|
|
42671
|
+
const { resolve: resolve35, basename: basename31 } = await import("path");
|
|
42641
42672
|
const rel = resolveVariables(String(field.filePath), vars);
|
|
42642
42673
|
let buffer;
|
|
42643
42674
|
try {
|
|
@@ -42645,7 +42676,7 @@ async function buildFetchOptions(request, vars, baseDir = process.cwd()) {
|
|
|
42645
42676
|
} catch (err5) {
|
|
42646
42677
|
throw new Error(`Cannot read upload file "${rel}": ${err5.message}`);
|
|
42647
42678
|
}
|
|
42648
|
-
const fileName = field.fileName ||
|
|
42679
|
+
const fileName = field.fileName || basename31(rel);
|
|
42649
42680
|
const contentType = field.contentType;
|
|
42650
42681
|
form.append(resolvedKey, buffer, contentType ? { filename: fileName, contentType } : { filename: fileName });
|
|
42651
42682
|
} else if (field.fieldType === "file" && field.value) {
|
|
@@ -94661,9 +94692,10 @@ var init_permissions2 = __esm({
|
|
|
94661
94692
|
{ method: "PUT", pathPrefix: "/api/connectors", minRole: "admin" },
|
|
94662
94693
|
{ method: "DELETE", pathPrefix: "/api/connectors", minRole: "admin" },
|
|
94663
94694
|
{ method: "POST", pathPrefix: "/api/mobile/local/config", minRole: "admin" },
|
|
94664
|
-
// Starting / closing an Android emulator
|
|
94665
|
-
// Settings change — open to whoever can run tests.
|
|
94695
|
+
// Starting / closing an Android emulator or iOS simulator is running a
|
|
94696
|
+
// device, not a Settings change — open to whoever can run tests.
|
|
94666
94697
|
{ method: "POST", pathPrefix: "/api/mobile/local/emulator", minRole: "tester" },
|
|
94698
|
+
{ method: "POST", pathPrefix: "/api/mobile/local/simulator", minRole: "tester" },
|
|
94667
94699
|
{ method: "POST", pathPrefix: "/api/tests/ownership/config", minRole: "admin" },
|
|
94668
94700
|
// ── Tester (write operations) ─────────────────────────────────
|
|
94669
94701
|
// AI Test Gen — generation / reverse-engineer / review. Expensive LLM
|
|
@@ -99014,6 +99046,8 @@ var init_session_manager = __esm({
|
|
|
99014
99046
|
MobileSessionManager = class _MobileSessionManager {
|
|
99015
99047
|
adapter = null;
|
|
99016
99048
|
desired = null;
|
|
99049
|
+
/** start() calls in progress. */
|
|
99050
|
+
starting = 0;
|
|
99017
99051
|
disconnectCallbacks = [];
|
|
99018
99052
|
startedCallbacks = [];
|
|
99019
99053
|
lostCallbacks = [];
|
|
@@ -99054,9 +99088,29 @@ var init_session_manager = __esm({
|
|
|
99054
99088
|
}
|
|
99055
99089
|
/** Start (or re-attach to) the underlying Appium session. Idempotent. */
|
|
99056
99090
|
async start() {
|
|
99091
|
+
this.starting++;
|
|
99092
|
+
try {
|
|
99093
|
+
return await this.startOrReuse();
|
|
99094
|
+
} finally {
|
|
99095
|
+
this.starting--;
|
|
99096
|
+
}
|
|
99097
|
+
}
|
|
99098
|
+
/**
|
|
99099
|
+
* A start() is in progress — a fresh session being opened, possibly in
|
|
99100
|
+
* place of one that died. The session bar keeps showing the session
|
|
99101
|
+
* meanwhile instead of offering "Start session".
|
|
99102
|
+
*/
|
|
99103
|
+
isStarting() {
|
|
99104
|
+
return this.starting > 0;
|
|
99105
|
+
}
|
|
99106
|
+
async startOrReuse() {
|
|
99057
99107
|
if (this.adapter && this.adapter.isActive()) {
|
|
99058
99108
|
const before = this.adapter.getSessionInfo()?.sessionId;
|
|
99059
|
-
|
|
99109
|
+
let alive = this.adapter.ping ? await this.adapter.ping().catch(() => false) : true;
|
|
99110
|
+
if (!alive && this.adapter.isActive() && await this.reopenApp()) {
|
|
99111
|
+
alive = this.adapter.ping ? await this.adapter.ping().catch(() => false) : true;
|
|
99112
|
+
if (alive) logger26.info("MobileSession: the app was not running \u2014 reopened it in the same session.");
|
|
99113
|
+
}
|
|
99060
99114
|
if (alive) {
|
|
99061
99115
|
const info2 = this.adapter.getSessionInfo();
|
|
99062
99116
|
if (info2) return info2;
|
|
@@ -99103,6 +99157,26 @@ var init_session_manager = __esm({
|
|
|
99103
99157
|
}
|
|
99104
99158
|
return info;
|
|
99105
99159
|
}
|
|
99160
|
+
/**
|
|
99161
|
+
* Bring the app under test to the foreground in the current session —
|
|
99162
|
+
* starts it again after a crash, a no-op when it's already in front.
|
|
99163
|
+
* The app is the one Appium installed for the session (bundleId /
|
|
99164
|
+
* appPackage from the session's capabilities). False when there's no
|
|
99165
|
+
* session or no app id to go by.
|
|
99166
|
+
*/
|
|
99167
|
+
async reopenApp() {
|
|
99168
|
+
const adapter = this.adapter;
|
|
99169
|
+
if (!adapter || !adapter.isActive()) return false;
|
|
99170
|
+
const caps = adapter.getResolvedCapabilities?.() ?? null;
|
|
99171
|
+
const pick = (k) => {
|
|
99172
|
+
const v = caps?.[k] ?? caps?.[`appium:${k}`];
|
|
99173
|
+
return typeof v === "string" && v ? v : void 0;
|
|
99174
|
+
};
|
|
99175
|
+
const appId = this.desired?.platform === "android" ? pick("appPackage") ?? pick("bundleId") : pick("bundleId") ?? pick("appPackage");
|
|
99176
|
+
if (!appId) return false;
|
|
99177
|
+
const res = await adapter.activateApp(appId).catch(() => null);
|
|
99178
|
+
return !!res?.success;
|
|
99179
|
+
}
|
|
99106
99180
|
/**
|
|
99107
99181
|
* Told each time a NEW device session starts here — the first one, or a
|
|
99108
99182
|
* fresh one replacing a session that died (mobile_launch_app) — never when
|
|
@@ -99594,6 +99668,10 @@ function translateForWebview(loc) {
|
|
|
99594
99668
|
return { strategy: STRATEGY_MAP[loc.strategy], value: loc.value };
|
|
99595
99669
|
}
|
|
99596
99670
|
}
|
|
99671
|
+
function isAppNotRunningError(err5) {
|
|
99672
|
+
const msg = (err5 instanceof Error ? err5.message : String(err5 ?? "")).toLowerCase();
|
|
99673
|
+
return msg.includes("possibly crashed") || /application under test .* is not running/.test(msg);
|
|
99674
|
+
}
|
|
99597
99675
|
function detectSystemDialog(xml, platform4) {
|
|
99598
99676
|
const markers = platform4 === "ios" ? [/<XCUIElementTypeAlert/i] : [
|
|
99599
99677
|
/permissioncontroller/i,
|
|
@@ -99776,7 +99854,7 @@ ${out}`;
|
|
|
99776
99854
|
}
|
|
99777
99855
|
return out;
|
|
99778
99856
|
}
|
|
99779
|
-
var logger28, STRATEGY_MAP, ANDROID_KEYCODE, RemoteAppiumAdapter, HTML_VOID_TAGS, HTML_SKIP_TAGS, HTML_INTERACTIVE_TAGS;
|
|
99857
|
+
var logger28, STRATEGY_MAP, ANDROID_KEYCODE, RemoteAppiumAdapter, APP_NOT_RUNNING_HINT, HTML_VOID_TAGS, HTML_SKIP_TAGS, HTML_INTERACTIVE_TAGS;
|
|
99780
99858
|
var init_remote_appium_adapter = __esm({
|
|
99781
99859
|
"src/mobile/remote-appium-adapter.ts"() {
|
|
99782
99860
|
"use strict";
|
|
@@ -100296,6 +100374,7 @@ ${tree}`;
|
|
|
100296
100374
|
`The device automation session has crashed (UiAutomator2/WebDriverAgent instrumentation is no longer running on the device). This commonly happens after the app is cleared or force-stopped. Call mobile_launch_app to start a fresh session, then retry. (original: ${err5.message})`
|
|
100297
100375
|
);
|
|
100298
100376
|
}
|
|
100377
|
+
if (isAppNotRunningError(err5)) throw new Error(`${err5.message}${APP_NOT_RUNNING_HINT}`);
|
|
100299
100378
|
throw err5;
|
|
100300
100379
|
}
|
|
100301
100380
|
}
|
|
@@ -100364,13 +100443,15 @@ ${tree}`;
|
|
|
100364
100443
|
error: `Device automation session crashed \u2014 call mobile_launch_app to start a fresh session, then retry. (original: ${err5.message})`
|
|
100365
100444
|
};
|
|
100366
100445
|
}
|
|
100446
|
+
const hint = isAppNotRunningError(err5) ? APP_NOT_RUNNING_HINT : "";
|
|
100367
100447
|
if (err5 instanceof AppiumApiError) {
|
|
100368
|
-
return { success: false, error: `${err5.code}: ${err5.message}` };
|
|
100448
|
+
return { success: false, error: `${err5.code}: ${err5.message}${hint}` };
|
|
100369
100449
|
}
|
|
100370
|
-
return { success: false, error: err5.message };
|
|
100450
|
+
return { success: false, error: `${err5.message}${hint}` };
|
|
100371
100451
|
}
|
|
100372
100452
|
}
|
|
100373
100453
|
};
|
|
100454
|
+
APP_NOT_RUNNING_HINT = " \u2014 the app crashed or closed: call mobile_launch_app to reopen it in this session.";
|
|
100374
100455
|
HTML_VOID_TAGS = /* @__PURE__ */ new Set([
|
|
100375
100456
|
"area",
|
|
100376
100457
|
"base",
|
|
@@ -100482,6 +100563,10 @@ var init_session_pool = __esm({
|
|
|
100482
100563
|
manager.onSessionStarted((info) => {
|
|
100483
100564
|
reuseTicketStore.moveTo(clientId, info, isCloudSession(manager) ? this.ttlMs : void 0, withdrawn);
|
|
100484
100565
|
withdrawn = null;
|
|
100566
|
+
try {
|
|
100567
|
+
this.options.onSessionStarted?.(clientId, info);
|
|
100568
|
+
} catch {
|
|
100569
|
+
}
|
|
100485
100570
|
});
|
|
100486
100571
|
}
|
|
100487
100572
|
this.pool.set(key2, { manager, lastTouchedAt: Date.now(), createdAt: Date.now() });
|
|
@@ -109813,6 +109898,48 @@ var init_chat_sources = __esm({
|
|
|
109813
109898
|
}
|
|
109814
109899
|
});
|
|
109815
109900
|
|
|
109901
|
+
// src/mobile/session-prompt.ts
|
|
109902
|
+
import { basename as basename26 } from "path";
|
|
109903
|
+
function appLabel(appRef) {
|
|
109904
|
+
if (!appRef) return void 0;
|
|
109905
|
+
return /^[a-z][a-z0-9+.-]*:\/\//i.test(appRef) ? appRef : basename26(appRef);
|
|
109906
|
+
}
|
|
109907
|
+
function appIdOf(manager) {
|
|
109908
|
+
const caps = manager.getAdapter()?.getResolvedCapabilities?.() ?? null;
|
|
109909
|
+
for (const k of ["bundleId", "appPackage"]) {
|
|
109910
|
+
const v = caps?.[k] ?? caps?.[`appium:${k}`];
|
|
109911
|
+
if (typeof v === "string" && v) return v;
|
|
109912
|
+
}
|
|
109913
|
+
return void 0;
|
|
109914
|
+
}
|
|
109915
|
+
function describeMobileSession(manager, now = Date.now()) {
|
|
109916
|
+
const desired = manager?.getDesiredSession() ?? null;
|
|
109917
|
+
const info = manager?.isActive() ? manager.getSessionInfo() : null;
|
|
109918
|
+
if (info) {
|
|
109919
|
+
const app = appLabel(desired?.appRef);
|
|
109920
|
+
const appId = appIdOf(manager);
|
|
109921
|
+
const mins = Math.max(0, Math.round((now - info.startedAt) / 6e4));
|
|
109922
|
+
const details = [
|
|
109923
|
+
`device ${info.device} (${info.platform === "ios" ? "iOS" : "Android"}${desired?.osVersion ? ` ${desired.osVersion}` : ""}, ${info.providerId})`,
|
|
109924
|
+
app ? `app ${app}${appId ? ` (${appId})` : ""}` : appId ? `app ${appId}` : null,
|
|
109925
|
+
`started ${mins === 0 ? "just now" : `${mins} min ago`}`
|
|
109926
|
+
].filter(Boolean).join(", ");
|
|
109927
|
+
return `## Mobile session
|
|
109928
|
+
A device session is ALREADY RUNNING \u2014 ${details}. Do not call mobile_launch_app to start it: begin with mobile_snapshot to read the current screen. Call mobile_launch_app only to recover \u2014 when a mobile_* result says the session crashed or the app is not running (it reopens the app, or opens a fresh session).`;
|
|
109929
|
+
}
|
|
109930
|
+
if (desired) {
|
|
109931
|
+
const app = appLabel(desired.appRef);
|
|
109932
|
+
return `## Mobile session
|
|
109933
|
+
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
|
+
}
|
|
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.";
|
|
109936
|
+
}
|
|
109937
|
+
var init_session_prompt = __esm({
|
|
109938
|
+
"src/mobile/session-prompt.ts"() {
|
|
109939
|
+
"use strict";
|
|
109940
|
+
}
|
|
109941
|
+
});
|
|
109942
|
+
|
|
109816
109943
|
// src/ui/services/knowledge-inventory.ts
|
|
109817
109944
|
var knowledge_inventory_exports = {};
|
|
109818
109945
|
__export(knowledge_inventory_exports, {
|
|
@@ -111151,7 +111278,10 @@ ${sourcesBlock}` : "") + mcpHint;
|
|
|
111151
111278
|
fileContext: effectiveMode === "ask" ? [] : fileContext || [],
|
|
111152
111279
|
uploadedFiles: resolvedUploads,
|
|
111153
111280
|
projectPath: options.projectPath,
|
|
111154
|
-
browserBreadcrumb: includeBreadcrumb ? browserBreadcrumb : void 0
|
|
111281
|
+
browserBreadcrumb: includeBreadcrumb ? browserBreadcrumb : void 0,
|
|
111282
|
+
// Mobile: whether this tab already has a device session, so the AI
|
|
111283
|
+
// reads the screen instead of starting one (or knows it must).
|
|
111284
|
+
mobileSession: effectiveMode === "mobile" ? describeMobileSession(typeof clientId === "string" ? options.mobileSessionPool?.peek(clientId) : void 0) : void 0
|
|
111155
111285
|
});
|
|
111156
111286
|
const modeTools = tabOrchestrator.getToolRegistry().getDefinitions().filter((d) => !excludedToolNames.has(d.name));
|
|
111157
111287
|
const modeSystemPrompt = buildModeSystemPromptForChat(effectiveMode, options.projectPath, modeTools);
|
|
@@ -111879,6 +112009,7 @@ function buildModeSystemPromptForChat(mode, projectPath2, tools) {
|
|
|
111879
112009
|
}
|
|
111880
112010
|
function buildChatUserMessage(ctx) {
|
|
111881
112011
|
const parts = [];
|
|
112012
|
+
if (ctx.mobileSession) parts.push(ctx.mobileSession);
|
|
111882
112013
|
if (ctx.browserBreadcrumb) {
|
|
111883
112014
|
parts.push(
|
|
111884
112015
|
`${ctx.browserBreadcrumb}
|
|
@@ -111962,6 +112093,7 @@ var init_api_ai = __esm({
|
|
|
111962
112093
|
init_tool_action_kinds();
|
|
111963
112094
|
init_test_scanner();
|
|
111964
112095
|
init_test_run_command();
|
|
112096
|
+
init_session_prompt();
|
|
111965
112097
|
ALL_BROWSER_TOOLS = [
|
|
111966
112098
|
"browser_launch",
|
|
111967
112099
|
"browser_navigate",
|
|
@@ -112218,7 +112350,7 @@ Focus: native Android & iOS apps via Appium (cloud or USB-connected local device
|
|
|
112218
112350
|
MOBILE_DOMAIN_SECTION = `## Mobile Automation Strategy
|
|
112219
112351
|
The user already picked the device + app. Drive the live device with \`mobile_*\` tools over a native accessibility tree.
|
|
112220
112352
|
|
|
112221
|
-
**Launch \u2192 read \u2192 act:** call \`mobile_launch_app\` ONCE first (
|
|
112353
|
+
**Launch \u2192 read \u2192 act:** the "Mobile session" note in the message says whether a session is already running. Running \u2192 start with \`mobile_snapshot\`; not running \u2192 call \`mobile_launch_app\` ONCE first. After a crash, \`mobile_launch_app\` reopens the app (or a fresh session when the old one died). Read the accessibility tree it returns; \`mobile_snapshot\` re-reads the current screen. Every action returns the SETTLED tree of the resulting screen \u2014 read that instead of an extra snapshot. Use \`mobile_screenshot\` only when you truly need pixels.
|
|
112222
112354
|
|
|
112223
112355
|
**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.
|
|
112224
112356
|
|
|
@@ -112230,7 +112362,7 @@ The user already picked the device + app. Drive the live device with \`mobile_*\
|
|
|
112230
112362
|
|
|
112231
112363
|
**Interrupts:** a \`\u26A0 SYSTEM DIALOG/ALERT DETECTED\` banner \u2192 handle FIRST with \`mobile_alert\` accept|dismiss. A \`\u26A0 FOREGROUND CHANGED\` banner \u2192 the action switched apps/screens; the tree below is the NEW screen. Missing on-screen element in a hybrid app \u2192 it's in a webview: \`mobile_list_contexts\` \u2192 \`mobile_switch_context\` "WEBVIEW_\u2026" (a \`[hybrid screen \u2014 a WebView is present]\` banner in the tree is the tell). Inside a webview locate with \`css\` or \`xpath\` ONLY (native strategies don't exist in the HTML DOM); coordinate taps still use physical screen pixels. Switch back to "NATIVE_APP" when done. Truncated tree \u2192 \`mobile_snapshot\` query="<text or id>".
|
|
112232
112364
|
|
|
112233
|
-
**Recover:** failed actions include the current tree + hints \u2014 read them (exact accId/id, scroll_to, wait_for, alert, context switch). If the session shows crashed, \`mobile_launch_app\` to
|
|
112365
|
+
**Recover:** failed actions include the current tree + hints \u2014 read them (exact accId/id, scroll_to, wait_for, alert, context switch). If the session or the app shows crashed ("not running"), call \`mobile_launch_app\` to recover.
|
|
112234
112366
|
|
|
112235
112367
|
**Run against the picked device:** Testver injects the device + Appium connection automatically \u2014 do not hardcode a different hub or device in your run command.`;
|
|
112236
112368
|
API_IDENTITY = (projectPath2) => `You are an expert AI assistant for the API TESTING track of the project at: ${projectPath2}
|
|
@@ -113715,15 +113847,15 @@ function mountResultsRoutes(app, resultsStore4, artifactFetcher, projectRoot = p
|
|
|
113715
113847
|
const { scanAllTests: scanAllTests2 } = await Promise.resolve().then(() => (init_test_scanner(), test_scanner_exports));
|
|
113716
113848
|
const { generateHumanSteps: generateHumanSteps2 } = await Promise.resolve().then(() => (init_step_generator(), step_generator_exports));
|
|
113717
113849
|
const { readFileSync: readFileSync101, existsSync: existsSync124 } = await import("fs");
|
|
113718
|
-
const { resolve: resolve35, basename:
|
|
113850
|
+
const { resolve: resolve35, basename: basename31 } = await import("path");
|
|
113719
113851
|
const scanResult = scanAllTests2(run2.projectPath);
|
|
113720
113852
|
const allScannedTests = scanResult.suites.flatMap((s) => s.tests);
|
|
113721
113853
|
for (const t of run2.tests || []) {
|
|
113722
113854
|
if (t.steps && t.steps.length > 0) continue;
|
|
113723
113855
|
if (!t.file) continue;
|
|
113724
|
-
const fileBasename =
|
|
113856
|
+
const fileBasename = basename31(t.file);
|
|
113725
113857
|
const matchedTest = allScannedTests.find(
|
|
113726
|
-
(st) => st.name === t.name && (st.file === t.file ||
|
|
113858
|
+
(st) => st.name === t.name && (st.file === t.file || basename31(st.file) === fileBasename || st.file.endsWith(t.file) || t.file.endsWith(st.file))
|
|
113727
113859
|
);
|
|
113728
113860
|
if (matchedTest?.line) {
|
|
113729
113861
|
const fullPath = resolve35(run2.projectPath, matchedTest.file);
|
|
@@ -114513,7 +114645,7 @@ __export(api_explorer_exports, {
|
|
|
114513
114645
|
mountExplorerRoutes: () => mountExplorerRoutes
|
|
114514
114646
|
});
|
|
114515
114647
|
import { readFileSync as readFileSync81, existsSync as existsSync97 } from "fs";
|
|
114516
|
-
import { resolve as resolve27, basename as
|
|
114648
|
+
import { resolve as resolve27, basename as basename27 } from "path";
|
|
114517
114649
|
function mountExplorerRoutes(app, _scanner, options, resultsStore4) {
|
|
114518
114650
|
const { projectPath: projectPath2 } = options;
|
|
114519
114651
|
app.get("/api/tests/lifecycle", (_req, res) => {
|
|
@@ -114649,11 +114781,11 @@ function mountExplorerRoutes(app, _scanner, options, resultsStore4) {
|
|
|
114649
114781
|
}
|
|
114650
114782
|
} else if (testName) {
|
|
114651
114783
|
const scanResult = scanAllTests(projectPath2);
|
|
114652
|
-
const fileBasename =
|
|
114784
|
+
const fileBasename = basename27(file);
|
|
114653
114785
|
const allScanned = scanResult.suites.flatMap((s) => s.tests);
|
|
114654
114786
|
const norm6 = (n) => n.replace(/\[.*\]$/, "").trim();
|
|
114655
114787
|
const wantName = norm6(testName);
|
|
114656
|
-
const fileMatches = (t) => t.file === file ||
|
|
114788
|
+
const fileMatches = (t) => t.file === file || basename27(t.file) === fileBasename || t.file.endsWith(file) || file.endsWith(t.file);
|
|
114657
114789
|
const nameMatches2 = (t) => t.name === testName || norm6(t.name) === wantName;
|
|
114658
114790
|
const matchedTest = allScanned.find((t) => nameMatches2(t) && fileMatches(t) && t.line) || allScanned.find((t) => nameMatches2(t) && t.line);
|
|
114659
114791
|
if (!matchedTest || !matchedTest.line) {
|
|
@@ -130275,7 +130407,7 @@ function publicAutoHeal(cfg) {
|
|
|
130275
130407
|
}
|
|
130276
130408
|
function isMcpUiEnabled() {
|
|
130277
130409
|
const raw = (process.env.TESTVER_MCP_ENABLED ?? "").trim().toLowerCase();
|
|
130278
|
-
return
|
|
130410
|
+
return raw === "true" || raw === "1" || raw === "yes" || raw === "on";
|
|
130279
130411
|
}
|
|
130280
130412
|
function mountSystemRoutes(app, systemConfigStore, projectPath2, onRemoteUpdatesChanged) {
|
|
130281
130413
|
app.get("/api/system/app-mode", (_req, res) => {
|
|
@@ -135758,7 +135890,7 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
135758
135890
|
const manager = pool.peek(clientId);
|
|
135759
135891
|
if (!manager) return res.json({ session: null, desired: null, context: null });
|
|
135760
135892
|
const context = manager.getAdapter()?.getCachedContext?.() ?? null;
|
|
135761
|
-
res.json({ session: manager.getSessionInfo(), desired: manager.getDesiredSession(), context });
|
|
135893
|
+
res.json({ session: manager.getSessionInfo(), desired: manager.getDesiredSession(), context, starting: manager.isStarting() });
|
|
135762
135894
|
});
|
|
135763
135895
|
app.post("/api/mobile/session/keepalive", (req, res) => {
|
|
135764
135896
|
const pool = mobilePool();
|
|
@@ -137110,6 +137242,26 @@ function mountLocalMobileRoutes(app, options) {
|
|
|
137110
137242
|
if (!ok6) return res.status(400).json({ error: `Couldn't close ${serial} \u2014 it may have closed already.` });
|
|
137111
137243
|
res.json({ stopped: true });
|
|
137112
137244
|
});
|
|
137245
|
+
app.post("/api/mobile/local/simulator/start", async (req, res) => {
|
|
137246
|
+
const udid = typeof req.body?.udid === "string" ? req.body.udid.trim() : "";
|
|
137247
|
+
if (!isIosSimulatorUdid(udid)) return res.status(400).json({ error: "Give the simulator UDID." });
|
|
137248
|
+
try {
|
|
137249
|
+
await startIosSimulator(udid);
|
|
137250
|
+
res.json({ started: true });
|
|
137251
|
+
} catch (err5) {
|
|
137252
|
+
res.status(400).json({ error: err5.message });
|
|
137253
|
+
}
|
|
137254
|
+
});
|
|
137255
|
+
app.post("/api/mobile/local/simulator/stop", async (req, res) => {
|
|
137256
|
+
const udid = typeof req.body?.udid === "string" ? req.body.udid.trim() : "";
|
|
137257
|
+
if (!isIosSimulatorUdid(udid)) return res.status(400).json({ error: "Give the simulator UDID." });
|
|
137258
|
+
try {
|
|
137259
|
+
await stopIosSimulator(udid);
|
|
137260
|
+
res.json({ stopped: true });
|
|
137261
|
+
} catch (err5) {
|
|
137262
|
+
res.status(400).json({ error: err5.message });
|
|
137263
|
+
}
|
|
137264
|
+
});
|
|
137113
137265
|
app.get("/api/mobile/local/config", (_req, res) => {
|
|
137114
137266
|
res.json({ config: store4.get() });
|
|
137115
137267
|
});
|
|
@@ -137156,7 +137308,7 @@ __export(remote_updates_service_exports, {
|
|
|
137156
137308
|
RemoteUpdatesService: () => RemoteUpdatesService
|
|
137157
137309
|
});
|
|
137158
137310
|
import { existsSync as existsSync110, readFileSync as readFileSync90, mkdirSync as mkdirSync49 } from "fs";
|
|
137159
|
-
import { join as join107, basename as
|
|
137311
|
+
import { join as join107, basename as basename28 } from "path";
|
|
137160
137312
|
var FIRST_CHECK_DELAY_MS, RemoteUpdatesService;
|
|
137161
137313
|
var init_remote_updates_service = __esm({
|
|
137162
137314
|
"src/ui/services/remote-updates-service.ts"() {
|
|
@@ -137286,7 +137438,7 @@ var init_remote_updates_service = __esm({
|
|
|
137286
137438
|
if (!_RemoteUpdatesService.shouldNotify(check, cfg, this.persisted.notified?.[branch])) return;
|
|
137287
137439
|
this.persisted.notified = { ...this.persisted.notified ?? {}, [branch]: check.upstreamSha };
|
|
137288
137440
|
try {
|
|
137289
|
-
await this.deps.notify(check, cfg,
|
|
137441
|
+
await this.deps.notify(check, cfg, basename28(this.deps.projectPath));
|
|
137290
137442
|
} catch (err5) {
|
|
137291
137443
|
console.error("[remote-updates] notify failed:", err5.message);
|
|
137292
137444
|
}
|
|
@@ -145492,13 +145644,13 @@ var init_streaming_json = __esm({
|
|
|
145492
145644
|
});
|
|
145493
145645
|
|
|
145494
145646
|
// src/ui/util/script-framework-detect.ts
|
|
145495
|
-
function
|
|
145647
|
+
function basename29(filePath3) {
|
|
145496
145648
|
const norm6 = filePath3.replace(/\\/g, "/");
|
|
145497
145649
|
const idx = norm6.lastIndexOf("/");
|
|
145498
145650
|
return idx >= 0 ? norm6.slice(idx + 1) : norm6;
|
|
145499
145651
|
}
|
|
145500
145652
|
function detectScriptFramework(filePath3, content) {
|
|
145501
|
-
const name2 =
|
|
145653
|
+
const name2 = basename29(filePath3).toLowerCase();
|
|
145502
145654
|
const c2 = content || "";
|
|
145503
145655
|
if (name2.endsWith(".cy.ts") || name2.endsWith(".cy.js")) return "cypress";
|
|
145504
145656
|
if (name2.endsWith(".feature")) return "cucumber";
|
|
@@ -151449,7 +151601,7 @@ __export(api_documents_exports, {
|
|
|
151449
151601
|
sandboxActiveContent: () => sandboxActiveContent
|
|
151450
151602
|
});
|
|
151451
151603
|
import { existsSync as existsSync119, mkdirSync as mkdirSync56, writeFileSync as writeFileSync29, readFileSync as readFileSync97 } from "fs";
|
|
151452
|
-
import { join as join116, basename as
|
|
151604
|
+
import { join as join116, basename as basename30 } from "path";
|
|
151453
151605
|
function sandboxActiveContent(res) {
|
|
151454
151606
|
res.setHeader(
|
|
151455
151607
|
"Content-Security-Policy",
|
|
@@ -151556,7 +151708,7 @@ function mountDocumentRoutes(app, tmStore5, projectPath2) {
|
|
|
151556
151708
|
try {
|
|
151557
151709
|
const filename = req.params.filename;
|
|
151558
151710
|
const filePath3 = resolveDocumentPath(filename, projectPath2);
|
|
151559
|
-
if (!filePath3 ||
|
|
151711
|
+
if (!filePath3 || basename30(filePath3) !== filename) {
|
|
151560
151712
|
res.status(404).json({ error: "File not found" });
|
|
151561
151713
|
return;
|
|
151562
151714
|
}
|
|
@@ -152698,6 +152850,15 @@ async function createUIServer(options) {
|
|
|
152698
152850
|
} catch {
|
|
152699
152851
|
}
|
|
152700
152852
|
},
|
|
152853
|
+
// A new session for a tab — also one the AI opened after the old one
|
|
152854
|
+
// died — so its session bar and live view show it.
|
|
152855
|
+
onSessionStarted: async (clientId, info) => {
|
|
152856
|
+
try {
|
|
152857
|
+
const { sendTo: sendTo3 } = await Promise.resolve().then(() => (init_shared_streaming(), shared_streaming_exports));
|
|
152858
|
+
sendTo3(wss, clientId, { type: "mobile-session-started", session: info });
|
|
152859
|
+
} catch {
|
|
152860
|
+
}
|
|
152861
|
+
},
|
|
152701
152862
|
// A cloud session closes soon (idle, or at its maximum lifetime) — warn
|
|
152702
152863
|
// its tab, which can keep an idle one open.
|
|
152703
152864
|
onSessionExpiring: async (clientId, info) => {
|
|
@@ -156569,7 +156730,7 @@ server {
|
|
|
156569
156730
|
}
|
|
156570
156731
|
} else if (subcommand === "pm2") {
|
|
156571
156732
|
const { realpathSync: realpathSync3 } = await import("fs");
|
|
156572
|
-
const { basename:
|
|
156733
|
+
const { basename: basename31 } = await import("path");
|
|
156573
156734
|
const pmFlag = (name2) => {
|
|
156574
156735
|
const i = args.indexOf(`--${name2}`);
|
|
156575
156736
|
if (i !== -1 && args[i + 1] && !args[i + 1].startsWith("-")) return args[i + 1];
|
|
@@ -156579,7 +156740,7 @@ server {
|
|
|
156579
156740
|
const pmHas = (name2) => args.includes(`--${name2}`);
|
|
156580
156741
|
const port = pmFlag("port") || process.env.TESTVER_PORT || "3700";
|
|
156581
156742
|
const host = pmFlag("host") || "";
|
|
156582
|
-
const appName = (pmFlag("name") ||
|
|
156743
|
+
const appName = (pmFlag("name") || basename31(workingDirectory) || "testver").replace(/[^A-Za-z0-9._-]/g, "-");
|
|
156583
156744
|
const outName = "testver.pm2.config.js";
|
|
156584
156745
|
const outPath = join122(workingDirectory, outName);
|
|
156585
156746
|
let scriptPath = process.argv[1] || "testver";
|