@aarwitz/tapp 0.18.0 → 0.18.1
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/.claude-plugin/plugin.json +2 -2
- package/bin/tapp.js +13 -7
- package/mcp-server/src/index.js +69 -23
- package/package.json +4 -4
- package/scripts/quick-capture.sh +17 -5
- package/scripts/run-flow.sh +3 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tapp",
|
|
3
3
|
"description": "Give Claude hands and eyes on iOS, Android, and web apps, with exploration, replayable flows, evidence, and deterministic CI gates.",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aaron Horowitz",
|
|
7
7
|
"url": "https://github.com/aarwitz"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"command": "npx",
|
|
25
25
|
"args": [
|
|
26
26
|
"-y",
|
|
27
|
-
"@aarwitz/tapp@0.18.
|
|
27
|
+
"@aarwitz/tapp@0.18.1",
|
|
28
28
|
"mcp"
|
|
29
29
|
],
|
|
30
30
|
"cwd": "${CLAUDE_PROJECT_DIR}"
|
package/bin/tapp.js
CHANGED
|
@@ -340,15 +340,15 @@ async function resolveTargetOrExit(engine, input, { inspect = false } = {}) {
|
|
|
340
340
|
function safeCommandUsage(verb) {
|
|
341
341
|
const usage = {
|
|
342
342
|
workflows: "tapp plan workflows [repo] [--save FILE --confirm] [--workflow ID] [--json]",
|
|
343
|
-
explore: "tapp explore [target] [--platform ios|android|web] [--actions N] [--timeout SEC] [--email VALUE] [--password VALUE] [--baseline FILE] [--json FILE]\n --read-only <url>...: never clicks (dead controls, broken links/assets, failed requests, JS exceptions, mixed content, overflow) [--pages N] [--urls FILE] [--json [FILE]]\n --goal \"SCREEN OR CONTROL\": source-locate a screen/control and take the shortest observed route [--project-dir REPO] [--target NAME|PATH] [--map FILE] [--out FILE]\n Web: [--watch] opens Tapp's controlled browser and shows its actions; [--device \"iPhone 13\"] [--viewport 390x844] render at a device profile or explicit size\n iOS launch configuration: [--launch-arg VALUE ...] [--launch-env '{\"KEY\":\"VALUE\"}']\n Android: [--app-id ID] [--apk FILE] [--serial ID] [--keep-data]",
|
|
343
|
+
explore: "tapp explore [target] [--platform ios|android|web] [--actions N] [--timeout SEC] [--email VALUE] [--password VALUE] [--baseline FILE] [--json FILE]\n --read-only <url>...: never clicks (dead controls, broken links/assets, failed requests, JS exceptions, mixed content, overflow) [--pages N] [--urls FILE] [--json [FILE]]\n --goal \"SCREEN OR CONTROL\": source-locate a screen/control and take the shortest observed route [--project-dir REPO] [--target NAME|PATH] [--map FILE] [--out FILE]\n Web: [--watch] opens Tapp's controlled browser and shows its actions; [--device \"iPhone 13\"] [--viewport 390x844] render at a device profile or explicit size\n iOS: [--device \"iPhone 16\"|UDID] chooses the simulator (required when more than one is booted; TAPP_UDID is the default)\n iOS launch configuration: [--launch-arg VALUE ...] [--launch-env '{\"KEY\":\"VALUE\"}']\n Android: [--app-id ID] [--apk FILE] [--serial ID] [--keep-data]",
|
|
344
344
|
focus: "tapp explore --goal \"SCREEN OR CONTROL\" [target] [--platform ios|android|web] [--project-dir REPO] [--target NAME|PATH] [--map FILE] [--out FILE]",
|
|
345
345
|
init: "tapp init [repo] [--explore] [--refresh] [--platform PLATFORM] [--target NAME] [--url URL] [--watch] [--dry-run]",
|
|
346
|
-
open: "tapp look [target] [--platform ios|android|web] [--out FILE] [--tap TEXT] [--wait-for TEXT]\n --tree: accessibility tree of the current screen (--json for every element)\n --sim: screenshot the booted simulator only (never builds or installs)\n Web: [--device \"iPhone 13\"] [--viewport 390x844] [--full-page]",
|
|
346
|
+
open: "tapp look [target] [--platform ios|android|web] [--out FILE] [--tap TEXT] [--wait-for TEXT]\n --tree: accessibility tree of the current screen (--json for every element)\n --sim: screenshot the booted simulator only (never builds or installs)\n iOS: [--device \"iPhone 16\"|UDID] chooses the simulator (required when more than one is booted)\n Web: [--device \"iPhone 13\"] [--viewport 390x844] [--full-page]",
|
|
347
347
|
tree: "tapp look --tree [target] [--platform ios|android|web] [--json] [--tap TEXT] [--wait-for TEXT]\n iOS: inspects an installed app; never builds or installs.\n Web: [--device \"iPhone 13\"] [--viewport 390x844]",
|
|
348
348
|
shot: "tapp look --sim [--out FILE]",
|
|
349
349
|
apps: "tapp apps",
|
|
350
350
|
build: "tapp build [repo] [--scheme NAME] [--configuration NAME]",
|
|
351
|
-
flow: "tapp run FLOW.yml [--actor NAME] [--email VALUE] [--password VALUE] [--device \"iPhone 13\"] [--viewport 390x844]\n iOS: [--launch-arg ARG] [--launch-env JSON]\ntapp validate FLOW.yml [--platform PLATFORM] [--map FILE]\ntapp validate --example print a complete starter Flow YAML\n Exit codes: 0 replay passed · 1 replay failed · 2 infrastructure/usage error",
|
|
351
|
+
flow: "tapp run FLOW.yml [--actor NAME] [--email VALUE] [--password VALUE] [--device \"iPhone 13\"] [--viewport 390x844]\n iOS: [--device \"iPhone 16\"|UDID] chooses the simulator (required when more than one is booted; TAPP_UDID is the default) [--launch-arg ARG] [--launch-env JSON]\ntapp validate FLOW.yml [--platform PLATFORM] [--map FILE]\ntapp validate --example print a complete starter Flow YAML\n Exit codes: 0 replay passed · 1 replay failed · 2 infrastructure/usage error",
|
|
352
352
|
task: "tapp validate TASK.yml [--platform PLATFORM] [--map FILE]\ntapp validate TASK.yml --compile --platform PLATFORM [--inputs JSON] [--out FILE]\ntapp run TASK.yml --platform PLATFORM [--url URL|--bundle-id ID|--app-id ID] [--inputs JSON]",
|
|
353
353
|
contract: "tapp validate FILE.contract.ts [--platform PLATFORM] [--map FILE]\ntapp validate FILE.contract.ts --compile --platform PLATFORM [--out FILE]\ntapp run FILE.contract.ts --platform PLATFORM [--url URL|--bundle-id ID|--app-id ID]\n Exit codes: 0 contract held · 1 contract failed · 2 infrastructure/usage error",
|
|
354
354
|
scenario: "tapp validate SCENARIO.yml [--project-dir DIR]\ntapp run SCENARIO.yml --platform web --url URL [--project-dir DIR]\n Exit codes: 0 scenario passed · 1 scenario failed · 2 infrastructure/usage error",
|
|
@@ -917,6 +917,7 @@ switch (command) {
|
|
|
917
917
|
maxActions: flags.actions,
|
|
918
918
|
timeout: flags.timeout,
|
|
919
919
|
args: { testEmail: flags.email, testPassword: flags.password, baselineFindings, ...launchOptions },
|
|
920
|
+
device: typeof flags.device === "string" ? flags.device : "",
|
|
920
921
|
surface: "cli",
|
|
921
922
|
onProgress,
|
|
922
923
|
});
|
|
@@ -1002,7 +1003,7 @@ switch (command) {
|
|
|
1002
1003
|
}
|
|
1003
1004
|
if (sim.autoBooted) console.error(`📱 Booted ${sim.booted.name}`);
|
|
1004
1005
|
const bundleId = await resolveTargetOrExit(engine, positionals[0]);
|
|
1005
|
-
const r = await engine.openApp(bundleId, {}, 1000);
|
|
1006
|
+
const r = await engine.openApp(bundleId, {}, 1000, { device: typeof flags.device === "string" ? flags.device : "" });
|
|
1006
1007
|
if (r.error) {
|
|
1007
1008
|
console.error(`❌ ${r.error}`);
|
|
1008
1009
|
process.exit(1);
|
|
@@ -1343,10 +1344,15 @@ switch (command) {
|
|
|
1343
1344
|
const launch = iosLaunchOptions(flags, rest);
|
|
1344
1345
|
if (launch.appLaunchArgs) env.OCQA_APP_LAUNCH_ARGS_JSON = JSON.stringify(launch.appLaunchArgs);
|
|
1345
1346
|
if (launch.appLaunchEnv) env.OCQA_APP_LAUNCH_ENV_JSON = JSON.stringify(launch.appLaunchEnv);
|
|
1347
|
+
// --device is a simulator name or UDID here (issue #31); the runner gets the UDID, and with
|
|
1348
|
+
// several simulators booted and none chosen the run refuses rather than guess.
|
|
1349
|
+
const sim = await (await engineImport()).ensureBootedSim({ device: typeof flags.device === "string" ? flags.device : "" });
|
|
1350
|
+
if (sim.error) { console.error(`❌ ${sim.error}`); process.exit(2); }
|
|
1351
|
+
env.TAPP_UDID = sim.booted.udid;
|
|
1346
1352
|
}
|
|
1347
1353
|
if (typeof flags.email === "string") env.OCQA_TEST_EMAIL = flags.email;
|
|
1348
1354
|
if (typeof flags.password === "string") env.OCQA_TEST_PASSWORD = flags.password;
|
|
1349
|
-
if (typeof flags.device === "string") env.TAPP_WEB_DEVICE = flags.device;
|
|
1355
|
+
if (typeof flags.device === "string" && platform === "web") env.TAPP_WEB_DEVICE = flags.device;
|
|
1350
1356
|
if (typeof flags.viewport === "string") env.TAPP_WEB_VIEWPORT = flags.viewport;
|
|
1351
1357
|
if (typeof flags.actor === "string" && flags.actor) {
|
|
1352
1358
|
const { readProjectConfig } = await import(path.join(packageRoot, "mcp-server", "src", "project-config.js"));
|
|
@@ -1705,8 +1711,8 @@ switch (command) {
|
|
|
1705
1711
|
let healthy = true;
|
|
1706
1712
|
|
|
1707
1713
|
const major = Number(process.versions.node.split(".")[0]);
|
|
1708
|
-
report.node = { ok: major >=
|
|
1709
|
-
major >=
|
|
1714
|
+
report.node = { ok: major >= 20, version: process.versions.node };
|
|
1715
|
+
major >= 20 ? sayOk("Node", `v${process.versions.node}`) : (sayBad("Node", `v${process.versions.node} (need >= 20; Node 18 reached end of life in April 2025)`), (healthy = false));
|
|
1710
1716
|
|
|
1711
1717
|
const python = run("python3", ["--version"]);
|
|
1712
1718
|
report.python3 = { ok: python.code === 0, version: python.code === 0 ? python.stdout : null };
|
package/mcp-server/src/index.js
CHANGED
|
@@ -251,13 +251,53 @@ async function listSimulators() {
|
|
|
251
251
|
return { simulators: sims, booted: sims.filter((s) => s.booted) };
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
+
// Which simulator a run drives. Public issue #31: with two simulators booted, `--device` was
|
|
255
|
+
// honoured for web only and every iOS path took whichever simulator simctl listed first — a
|
|
256
|
+
// production build instead of the sandbox one, then another agent session's simulator. A
|
|
257
|
+
// device is a name or UDID (`TAPP_UDID` is the environment default); with several booted and
|
|
258
|
+
// none chosen the answer is the list, not a guess.
|
|
259
|
+
export function selectSimulator(sims, device = "") {
|
|
260
|
+
const wanted = String(device || process.env.TAPP_UDID || "").trim();
|
|
261
|
+
const all = sims.simulators || [];
|
|
262
|
+
const booted = sims.booted || all.filter((s) => s.booted);
|
|
263
|
+
const describe = (list) => list.map((s) => `${s.name} (${s.udid})`).join(", ");
|
|
264
|
+
if (wanted) {
|
|
265
|
+
const lower = wanted.toLowerCase();
|
|
266
|
+
const match = all.find((s) => s.udid.toLowerCase() === lower)
|
|
267
|
+
|| all.find((s) => s.name.toLowerCase() === lower)
|
|
268
|
+
|| (() => { const p = booted.filter((s) => s.name.toLowerCase().startsWith(lower)); return p.length === 1 ? p[0] : null; })();
|
|
269
|
+
if (!match) return { error: `No simulator matches "${wanted}". Booted: ${booted.length ? describe(booted) : "none"}.` };
|
|
270
|
+
if (!match.booted) return { notBooted: match };
|
|
271
|
+
return { booted: match };
|
|
272
|
+
}
|
|
273
|
+
if (booted.length === 1) return { booted: booted[0] };
|
|
274
|
+
if (booted.length === 0) return { none: true };
|
|
275
|
+
return { error: `simulator-selection-required: ${booted.length} simulators are booted — ${describe(booted)}. Pass device (a name or UDID) or set TAPP_UDID so the run does not drive someone else's simulator.`, ambiguous: booted };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// The simulator the current engine process has chosen. Every simctl call and every spawned
|
|
279
|
+
// harness script must address it by UDID: the `booted` alias means "whichever is first".
|
|
280
|
+
let selectedSimUdid = null;
|
|
281
|
+
function simTarget() { return selectedSimUdid || "booted"; }
|
|
282
|
+
function simEnv() { return selectedSimUdid ? { TAPP_UDID: selectedSimUdid } : {}; }
|
|
283
|
+
|
|
254
284
|
// Pre-flight for every iOS entry point: the #1 first-session failure is "no simulator
|
|
255
285
|
// booted", and the harness's raw failure text is unactionable. Long-running tools
|
|
256
286
|
// (run_qa) auto-boot the first available iPhone; fast tools return an instructive error
|
|
257
287
|
// the agent can act on instead of a shrug.
|
|
258
|
-
export async function ensureBootedSim({ autoBoot = false } = {}) {
|
|
288
|
+
export async function ensureBootedSim({ autoBoot = false, device = "" } = {}) {
|
|
259
289
|
const sims = await listSimulators();
|
|
260
|
-
|
|
290
|
+
const choice = sims.error ? { none: true } : selectSimulator(sims, device);
|
|
291
|
+
if (choice.booted) { selectedSimUdid = choice.booted.udid; return { booted: choice.booted }; }
|
|
292
|
+
if (choice.error) return { error: choice.error };
|
|
293
|
+
if (choice.notBooted) {
|
|
294
|
+
if (!autoBoot) return { error: `${choice.notBooted.name} (${choice.notBooted.udid}) is not booted. Boot it with tapp_build (action boot) and retry.` };
|
|
295
|
+
await runCommand("xcrun", ["simctl", "boot", choice.notBooted.udid], { timeoutMs: 2 * 60 * 1000 });
|
|
296
|
+
const st = await runCommand("xcrun", ["simctl", "bootstatus", choice.notBooted.udid, "-b"], { timeoutMs: 3 * 60 * 1000 });
|
|
297
|
+
if (st.code !== 0) return { error: `Boot of ${choice.notBooted.name} failed — boot it manually with tapp_build (action boot).` };
|
|
298
|
+
selectedSimUdid = choice.notBooted.udid;
|
|
299
|
+
return { booted: { ...choice.notBooted, booted: true }, autoBooted: true };
|
|
300
|
+
}
|
|
261
301
|
// A failed listing is NOT "no simulators" — surface the real reason (was silently
|
|
262
302
|
// misdiagnosed as "No iOS simulators exist" when simctl errored in odd environments).
|
|
263
303
|
if (sims.error) {
|
|
@@ -277,6 +317,7 @@ export async function ensureBootedSim({ autoBoot = false } = {}) {
|
|
|
277
317
|
await runCommand("xcrun", ["simctl", "boot", candidate.udid], { timeoutMs: 2 * 60 * 1000 });
|
|
278
318
|
const st = await runCommand("xcrun", ["simctl", "bootstatus", candidate.udid, "-b"], { timeoutMs: 3 * 60 * 1000 });
|
|
279
319
|
if (st.code !== 0) return { error: `Auto-boot of ${candidate.name} failed — boot one manually with tapp_build (action boot).` };
|
|
320
|
+
selectedSimUdid = candidate.udid;
|
|
280
321
|
return { booted: candidate, autoBooted: true };
|
|
281
322
|
}
|
|
282
323
|
|
|
@@ -284,7 +325,7 @@ export async function ensureBootedSim({ autoBoot = false } = {}) {
|
|
|
284
325
|
// never installed). Without this pre-flight the harness reports a misleading "crashed at launch"
|
|
285
326
|
// and sessions die with an unactionable error — check cheaply up front instead.
|
|
286
327
|
async function appInstalledOnBootedSim(bundleId) {
|
|
287
|
-
const r = await runCommand("xcrun", ["simctl", "get_app_container",
|
|
328
|
+
const r = await runCommand("xcrun", ["simctl", "get_app_container", simTarget(), bundleId, "app"], { timeoutMs: 15_000 });
|
|
288
329
|
return r.code === 0;
|
|
289
330
|
}
|
|
290
331
|
|
|
@@ -302,7 +343,7 @@ function notInstalledError(bundleId, booted) {
|
|
|
302
343
|
// and the tapp_build MCP tool.
|
|
303
344
|
|
|
304
345
|
export async function listInstalledUserApps() {
|
|
305
|
-
const r = await runCommand("xcrun", ["simctl", "listapps",
|
|
346
|
+
const r = await runCommand("xcrun", ["simctl", "listapps", simTarget()], { timeoutMs: 30_000, rawStdout: true });
|
|
306
347
|
if (r.code !== 0) return { error: "Could not list installed apps", details: { stderr: r.stderr } };
|
|
307
348
|
// simctl emits an old-style plist; plutil converts it.
|
|
308
349
|
const tmp = path.join(os.tmpdir(), `tapp-apps-${Date.now().toString(36)}.plist`);
|
|
@@ -510,16 +551,16 @@ export async function installAppOnBootedSim(appPath, { cleanInstall = true, onSt
|
|
|
510
551
|
const bundleId = (bid.stdout || "").trim();
|
|
511
552
|
if (!bundleId) return { error: `Could not read CFBundleIdentifier from ${appPath}/Info.plist — is this a simulator .app build?` };
|
|
512
553
|
if (cleanInstall) {
|
|
513
|
-
const existing = await runCommand("xcrun", ["simctl", "get_app_container",
|
|
554
|
+
const existing = await runCommand("xcrun", ["simctl", "get_app_container", simTarget(), bundleId, "app"], { timeoutMs: 15_000 });
|
|
514
555
|
if (existing.code === 0 && (existing.stdout || "").trim()) onStatus(replacingInstalledBuildNotice(bundleId));
|
|
515
556
|
}
|
|
516
557
|
if (cleanInstall) {
|
|
517
558
|
// Clean install: stale keychain items from a previous install leave apps half-signed-in
|
|
518
559
|
// (Firebase Auth's "error accessing the keychain") — uninstall first for a fresh state.
|
|
519
|
-
await runCommand("xcrun", ["simctl", "terminate",
|
|
520
|
-
await runCommand("xcrun", ["simctl", "uninstall",
|
|
560
|
+
await runCommand("xcrun", ["simctl", "terminate", simTarget(), bundleId], { timeoutMs: 30_000 });
|
|
561
|
+
await runCommand("xcrun", ["simctl", "uninstall", simTarget(), bundleId], { timeoutMs: 60_000 });
|
|
521
562
|
}
|
|
522
|
-
const inst = await runCommand("xcrun", ["simctl", "install",
|
|
563
|
+
const inst = await runCommand("xcrun", ["simctl", "install", simTarget(), appPath], { timeoutMs: 3 * 60 * 1000 });
|
|
523
564
|
if (inst.code !== 0) return { error: `Install failed: ${(inst.stderr || "").trim().slice(0, 300)}` };
|
|
524
565
|
return { bundleId };
|
|
525
566
|
}
|
|
@@ -762,11 +803,11 @@ function focusMetadata(result) {
|
|
|
762
803
|
return metadata;
|
|
763
804
|
}
|
|
764
805
|
|
|
765
|
-
async function startSession(bundleId, extraEnv = {}) {
|
|
806
|
+
async function startSession(bundleId, extraEnv = {}, { device = "" } = {}) {
|
|
766
807
|
if (activeSession && !activeSession.ended) {
|
|
767
808
|
return { error: "A session is already active; call tapp_session (action end) first.", screen: treeSnapshot() };
|
|
768
809
|
}
|
|
769
|
-
const sim = await ensureBootedSim();
|
|
810
|
+
const sim = await ensureBootedSim({ device });
|
|
770
811
|
if (sim.error) return { error: sim.error };
|
|
771
812
|
if (!(await appInstalledOnBootedSim(bundleId))) return { error: notInstalledError(bundleId, sim.booted) };
|
|
772
813
|
const token = Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
|
|
@@ -777,7 +818,7 @@ async function startSession(bundleId, extraEnv = {}) {
|
|
|
777
818
|
const captureScript = path.join(scriptsDir, "quick-capture.sh");
|
|
778
819
|
const proc = spawn("bash", [captureScript, "session", bundleId], {
|
|
779
820
|
cwd: repoRoot,
|
|
780
|
-
env: { ...process.env, ...extraEnv, OCQA_SESSION_CMD_PATH: cmdPath, OCQA_SESSION_RESULT_PATH: resultPath, OCQA_SESSION_TIMEOUT: "7200" },
|
|
821
|
+
env: { ...process.env, ...simEnv(), ...extraEnv, OCQA_SESSION_CMD_PATH: cmdPath, OCQA_SESSION_RESULT_PATH: resultPath, OCQA_SESSION_TIMEOUT: "7200" },
|
|
781
822
|
});
|
|
782
823
|
activeSession = {
|
|
783
824
|
platform:"ios", proc, bundleId, seq: 0, cmdPath, resultPath, latestTree: null, treeVersion: 0, buffer: "", ready: false, ended: false,
|
|
@@ -1403,8 +1444,8 @@ export async function captureInteractiveSessionFrame(maxWidth = 900) {
|
|
|
1403
1444
|
// Fast "just show me a screen": launch the app fresh (optionally bypassing login), grab a screenshot
|
|
1404
1445
|
// while it's on screen, return the tree too, then close it. No exploration. Uses the session
|
|
1405
1446
|
// machinery only to keep the app alive long enough to photograph it.
|
|
1406
|
-
export async function openApp(bundleId, extraEnv, maxWidth) {
|
|
1407
|
-
const start = await startSession(bundleId, extraEnv);
|
|
1447
|
+
export async function openApp(bundleId, extraEnv, maxWidth, { device = "" } = {}) {
|
|
1448
|
+
const start = await startSession(bundleId, extraEnv, { device });
|
|
1408
1449
|
if (start.error) return { error: start.error };
|
|
1409
1450
|
const img = await captureScreenshotImage(maxWidth);
|
|
1410
1451
|
const result = { screenTitle: start.screenTitle ?? null, elements: start.elements ?? [], img };
|
|
@@ -1419,7 +1460,7 @@ async function runExploreStreaming(bundleId, actions, timeout, env, onProgress)
|
|
|
1419
1460
|
const captureScript = path.join(scriptsDir, "quick-capture.sh");
|
|
1420
1461
|
const cmdArgs = [captureScript, "explore", bundleId, "--actions", String(actions), "--timeout", String(timeout)];
|
|
1421
1462
|
const before = new Set(listCaptureRuns(80).map((r) => r.id));
|
|
1422
|
-
const proc = spawn("bash", cmdArgs, { cwd: repoRoot, env: { ...process.env, ...env } });
|
|
1463
|
+
const proc = spawn("bash", cmdArgs, { cwd: repoRoot, env: { ...process.env, ...simEnv(), ...env } });
|
|
1423
1464
|
proc.stdout.on("data", () => {});
|
|
1424
1465
|
let captureStderr = "";
|
|
1425
1466
|
proc.stderr.on("data", (chunk) => {
|
|
@@ -1485,7 +1526,11 @@ async function runExploreStreaming(bundleId, actions, timeout, env, onProgress)
|
|
|
1485
1526
|
if (which === "closed") break;
|
|
1486
1527
|
if (Date.now() > hardDeadline) { try { proc.kill("SIGTERM"); } catch {} timedOut = true; break; }
|
|
1487
1528
|
}
|
|
1488
|
-
|
|
1529
|
+
// 'close' needs every stdio pipe released; a grandchild (the simulator recorder) that survives
|
|
1530
|
+
// the script holds them open, and waiting on it unconditionally turned a finished exploration
|
|
1531
|
+
// into a hang. Give the script a bounded grace period, then carry on with what it wrote.
|
|
1532
|
+
const closedInTime = await Promise.race([closed.then(() => true), sleep(20_000).then(() => false)]);
|
|
1533
|
+
if (!closedInTime) { try { proc.kill("SIGKILL"); } catch {} }
|
|
1489
1534
|
const created = listCaptureRuns(80).find((r) => !before.has(r.id))
|
|
1490
1535
|
|| (captureDir ? { id: path.basename(captureDir), path: captureDir, relativePath: path.relative(repoRoot, captureDir) } : null);
|
|
1491
1536
|
return { created, timedOut, captureStderr };
|
|
@@ -1509,7 +1554,7 @@ export async function captureScreenshotImage(maxWidth) {
|
|
|
1509
1554
|
const stamp = Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
|
|
1510
1555
|
const png = `/tmp/tapp-shot-${stamp}.png`;
|
|
1511
1556
|
const jpg = `/tmp/tapp-shot-${stamp}.jpg`;
|
|
1512
|
-
const r = await runCommand("xcrun", ["simctl", "io",
|
|
1557
|
+
const r = await runCommand("xcrun", ["simctl", "io", simTarget(), "screenshot", png], { timeoutMs: 30_000 });
|
|
1513
1558
|
if (!fs.existsSync(png)) return { error: "Screenshot failed (is a simulator booted?)", stderr: r.stderr };
|
|
1514
1559
|
await runCommand("sips", ["-Z", String(maxWidth), "-s", "format", "jpeg", "-s", "formatOptions", "60", png, "--out", jpg], { timeoutMs: 30_000 });
|
|
1515
1560
|
const file = fs.existsSync(jpg) ? jpg : png;
|
|
@@ -2025,7 +2070,7 @@ export async function runQaAndroid({ appId, apkPath, serial, maxActions, timeout
|
|
|
2025
2070
|
return { structured, text };
|
|
2026
2071
|
}
|
|
2027
2072
|
|
|
2028
|
-
export async function runQaIos({ bundleId, maxActions, timeout, args = {}, surface = "mcp", onProgress = () => {} }) {
|
|
2073
|
+
export async function runQaIos({ bundleId, maxActions, timeout, args = {}, device = "", surface = "mcp", onProgress = () => {} }) {
|
|
2029
2074
|
const { storagePreflight } = await import("./environment-preflight.js");
|
|
2030
2075
|
const storage = storagePreflight(capturesDir);
|
|
2031
2076
|
if (!storage.ok) return { error: storage.message, details: { environment: "storage", storage } };
|
|
@@ -2033,7 +2078,7 @@ export async function runQaIos({ bundleId, maxActions, timeout, args = {}, surfa
|
|
|
2033
2078
|
if (!fs.existsSync(captureScript)) return { error: "Capture script not found", details: { captureScript } };
|
|
2034
2079
|
|
|
2035
2080
|
// run_qa runs for minutes anyway — auto-boot rather than bounce the user.
|
|
2036
|
-
const sim = await ensureBootedSim({ autoBoot: true });
|
|
2081
|
+
const sim = await ensureBootedSim({ autoBoot: true, device });
|
|
2037
2082
|
if (sim.error) return { error: sim.error };
|
|
2038
2083
|
if (!(await appInstalledOnBootedSim(bundleId))) return { error: notInstalledError(bundleId, sim.booted) };
|
|
2039
2084
|
|
|
@@ -2668,7 +2713,7 @@ export const TOOLS = [
|
|
|
2668
2713
|
platform: { ...PLATFORM, description: "goal: optional when no session is active" },
|
|
2669
2714
|
clearData: { type: "boolean", default: true, description: "Android: clear app data before launch" },
|
|
2670
2715
|
watch: { type: "boolean", default: false, description: "Web: show Tapp's controlled Chromium window and a cursor/HUD" },
|
|
2671
|
-
device: { type: "string", description: "Web: Playwright device profile, e.g. \"iPhone 13\"" },
|
|
2716
|
+
device: { type: "string", description: "Web: Playwright device profile, e.g. \"iPhone 13\". iOS: simulator name or UDID — required when more than one simulator is booted (TAPP_UDID is the environment default)" },
|
|
2672
2717
|
viewport: { type: "string", description: "Web: viewport WIDTHxHEIGHT, e.g. \"390x844\"" },
|
|
2673
2718
|
maxActions: { type: "integer", minimum: 1, maximum: 1000, default: 60, description: "Exploration action budget" },
|
|
2674
2719
|
timeout: { type: "integer", minimum: 30, maximum: 3600, default: 600, description: "Max wall-clock seconds" },
|
|
@@ -2732,7 +2777,7 @@ export const TOOLS = [
|
|
|
2732
2777
|
testEmail: { type: "string", description: "Value for $TEST_EMAIL" },
|
|
2733
2778
|
testPassword: { type: "string", description: "Value for $TEST_PASSWORD" },
|
|
2734
2779
|
actor: { type: "string", description: "Configured actor; resolves $TEST_EMAIL/$TEST_PASSWORD from its env-var bindings" },
|
|
2735
|
-
device: { type: "string", description: "Web: Playwright device profile" },
|
|
2780
|
+
device: { type: "string", description: "Web: Playwright device profile. iOS: simulator name or UDID — required when more than one simulator is booted" },
|
|
2736
2781
|
viewport: { type: "string", description: "Web: viewport WIDTHxHEIGHT" },
|
|
2737
2782
|
},
|
|
2738
2783
|
},
|
|
@@ -2913,7 +2958,7 @@ export const TOOLS = [
|
|
|
2913
2958
|
action: { type: "string", enum: ["start", "login", "tap", "type", "swipe", "back", "wait", "tree", "screenshot", "save_flow", "draft_flow", "end"] },
|
|
2914
2959
|
...TARGET_PROPS,
|
|
2915
2960
|
target: { type: "string", description: "start: managed-web target name/path when the workspace has several" },
|
|
2916
|
-
device: { type: "string", description: "start
|
|
2961
|
+
device: { type: "string", description: "start: web Playwright device profile, or iOS simulator name/UDID (required when more than one simulator is booted)" },
|
|
2917
2962
|
viewport: { type: "string", description: "start (web): viewport WIDTHxHEIGHT" },
|
|
2918
2963
|
clearData: { type: "boolean", default: true, description: "start (Android): clear app data" },
|
|
2919
2964
|
testEmail: { type: "string" }, testPassword: { type: "string" },
|
|
@@ -3392,6 +3437,7 @@ async function handleTool(name, args = {}) {
|
|
|
3392
3437
|
maxActions: args.maxActions,
|
|
3393
3438
|
timeout: args.timeout,
|
|
3394
3439
|
args,
|
|
3440
|
+
device: isNonEmptyString(args.device) ? args.device.trim() : "",
|
|
3395
3441
|
onProgress: (p) => {
|
|
3396
3442
|
lastProgress = p;
|
|
3397
3443
|
iosProgress(p);
|
|
@@ -4138,7 +4184,7 @@ async function handleTool(name, args = {}) {
|
|
|
4138
4184
|
}
|
|
4139
4185
|
}
|
|
4140
4186
|
const maxWidth = Math.max(200, Math.min(1400, asInteger(args.maxWidth, 700)));
|
|
4141
|
-
const r = await openApp(String(args.appBundleId).trim(), explorationEnvFromArgs(args), maxWidth);
|
|
4187
|
+
const r = await openApp(String(args.appBundleId).trim(), explorationEnvFromArgs(args), maxWidth, { device: isNonEmptyString(args.device) ? args.device.trim() : "" });
|
|
4142
4188
|
if (r.error) return errorResult(r.error, r.details || {});
|
|
4143
4189
|
const content = [];
|
|
4144
4190
|
content.push({ type: "text", text: `🚀 Launched \`${String(args.appBundleId).trim()}\`\n\n` + formatScreen(r.screenTitle, r.elements) });
|
|
@@ -4250,7 +4296,7 @@ async function handleTool(name, args = {}) {
|
|
|
4250
4296
|
if (!isInsideDir(workspaceRoot, focusProjectDir) || !fs.statSync(focusProjectDir).isDirectory()) return errorResult("projectDir must be an existing directory inside the workspace");
|
|
4251
4297
|
}
|
|
4252
4298
|
const r = ios
|
|
4253
|
-
? await startSession(target, explorationEnvFromArgs(args))
|
|
4299
|
+
? await startSession(target, explorationEnvFromArgs(args), { device: isNonEmptyString(args.device) ? args.device.trim() : "" })
|
|
4254
4300
|
: android
|
|
4255
4301
|
? await startAndroidSession(target, { serial: args.androidSerial, apkPath: args.apkPath, clearData: args.clearData !== false, testEmail: args.testEmail, testPassword: args.testPassword })
|
|
4256
4302
|
: web
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aarwitz/tapp",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"mcpName": "io.github.aarwitz/tapp",
|
|
5
5
|
"description": "Let coding agents verify UI changes on real iOS, Android, and web surfaces, then enforce reviewed proof in deterministic CI.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"typescript": "^5.9.2"
|
|
58
58
|
},
|
|
59
59
|
"optionalDependencies": {
|
|
60
|
-
"playwright": "1.
|
|
60
|
+
"playwright": "1.64.0"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
|
-
"node": ">=
|
|
63
|
+
"node": ">=20"
|
|
64
64
|
},
|
|
65
65
|
"repository": {
|
|
66
66
|
"type": "git",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"mobile"
|
|
97
97
|
],
|
|
98
98
|
"scripts": {
|
|
99
|
-
"test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-audit.test.js tests/capture-provenance.test.js tests/ios-crash-attribution.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/browser-product.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/cloud-runner.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
|
|
99
|
+
"test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-audit.test.js tests/capture-provenance.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/browser-product.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/cloud-runner.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
|
|
100
100
|
"test:browser-journey": "node --test tests/browser-journey.test.js",
|
|
101
101
|
"test:browser-native": "TAPP_RUN_NATIVE_BROWSER=1 node --test tests/browser-native-journey.test.js"
|
|
102
102
|
}
|
package/scripts/quick-capture.sh
CHANGED
|
@@ -35,7 +35,9 @@ fi
|
|
|
35
35
|
HARNESS_PROJECT="$PROJECT_ROOT/Harness/OCQAHarness.xcodeproj"
|
|
36
36
|
DEFAULT_BUNDLE="io.github.aarwitz.tapp.demoapp"
|
|
37
37
|
|
|
38
|
+
# TAPP_UDID names the simulator the caller chose (issue #31); without it, the first booted one.
|
|
38
39
|
get_booted_sim() {
|
|
40
|
+
if [[ -n "${TAPP_UDID:-}" ]]; then echo "$TAPP_UDID"; return; fi
|
|
39
41
|
xcrun simctl list devices booted -j 2>/dev/null \
|
|
40
42
|
| python3 -c "
|
|
41
43
|
import sys, json
|
|
@@ -49,13 +51,14 @@ for runtime, devices in d.get('devices', {}).items():
|
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
get_sim_name() {
|
|
52
|
-
xcrun simctl list devices
|
|
53
|
-
| python3 -c "
|
|
54
|
-
import sys, json
|
|
54
|
+
xcrun simctl list devices -j 2>/dev/null \
|
|
55
|
+
| TAPP_UDID="${TAPP_UDID:-}" python3 -c "
|
|
56
|
+
import os, sys, json
|
|
55
57
|
d = json.load(sys.stdin)
|
|
58
|
+
want = os.environ.get('TAPP_UDID', '')
|
|
56
59
|
for runtime, devices in d.get('devices', {}).items():
|
|
57
60
|
for dev in devices:
|
|
58
|
-
if dev.get('state') == 'Booted':
|
|
61
|
+
if (want and dev.get('udid') == want) or (not want and dev.get('state') == 'Booted'):
|
|
59
62
|
print(dev['name'])
|
|
60
63
|
sys.exit(0)
|
|
61
64
|
" 2>/dev/null
|
|
@@ -376,9 +379,18 @@ OCQA_COMPLETE:{\"actions\":0,\"states\":0,\"issues\":1,\"screens\":\"\",\"outcom
|
|
|
376
379
|
wait "$HARNESS_PID" 2>/dev/null || true
|
|
377
380
|
OUTPUT="$(cat "$local_output_file" 2>/dev/null || true)"
|
|
378
381
|
|
|
379
|
-
# Stop recording
|
|
382
|
+
# Stop recording. simctl's recorder finalizes the file on SIGINT, but on hosted runners it
|
|
383
|
+
# sometimes ignores the signal; an unbounded wait here held the whole run (and its caller)
|
|
384
|
+
# until the test budget expired, with the harness long finished. Escalate on a deadline.
|
|
380
385
|
if [[ -n "$RECORD_PID" ]]; then
|
|
381
386
|
kill -INT "$RECORD_PID" 2>/dev/null || true
|
|
387
|
+
for _ in $(seq 1 40); do kill -0 "$RECORD_PID" 2>/dev/null || break; sleep 0.5; done
|
|
388
|
+
if kill -0 "$RECORD_PID" 2>/dev/null; then
|
|
389
|
+
echo "WARNING: simulator recorder did not stop on SIGINT; terminating it (the recording may be truncated)" >&2
|
|
390
|
+
kill -TERM "$RECORD_PID" 2>/dev/null || true
|
|
391
|
+
for _ in $(seq 1 10); do kill -0 "$RECORD_PID" 2>/dev/null || break; sleep 0.5; done
|
|
392
|
+
kill -KILL "$RECORD_PID" 2>/dev/null || true
|
|
393
|
+
fi
|
|
382
394
|
wait "$RECORD_PID" 2>/dev/null || true
|
|
383
395
|
fi
|
|
384
396
|
rm -f "$RECORDING_STARTED_PATH"
|
package/scripts/run-flow.sh
CHANGED
|
@@ -22,7 +22,9 @@ APP="${2:-}"
|
|
|
22
22
|
[ -z "$APP" ] && APP="$(python3 -c "import sys,json; print(json.loads(sys.argv[1]).get('app','') or '')" "$FLOW_JSON" 2>/dev/null)"
|
|
23
23
|
[ -z "$APP" ] && { echo "❌ No bundleId (pass one or set 'app:' in the flow)"; exit 2; }
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
# TAPP_UDID names the simulator the caller chose (issue #31); without it, the first booted one.
|
|
26
|
+
UDID="${TAPP_UDID:-}"
|
|
27
|
+
[ -z "$UDID" ] && UDID="$(xcrun simctl list devices booted -j 2>/dev/null | python3 -c 'import sys,json; d=json.load(sys.stdin); print(next((x["udid"] for v in d["devices"].values() for x in v if x.get("state")=="Booted"), ""))')"
|
|
26
28
|
[ -z "$UDID" ] && { echo "❌ No booted simulator."; exit 2; }
|
|
27
29
|
# CLI, MCP, sessions, and doctor share the same source/toolchain-validated descriptor.
|
|
28
30
|
XCTR="$(bash "$ROOT/scripts/quick-capture.sh" prepare-harness)" || exit 2
|