@aarwitz/tapp 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.25.0",
4
+ "version": "0.26.0",
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.25.0",
27
+ "@aarwitz/tapp@0.26.0",
28
28
  "mcp"
29
29
  ],
30
30
  "cwd": "${CLAUDE_PROJECT_DIR}"
package/bin/tapp.js CHANGED
@@ -399,7 +399,7 @@ function safeCommandUsage(verb) {
399
399
  shot: "tapp look --sim [--out FILE]",
400
400
  apps: "tapp apps",
401
401
  build: "tapp build [repo] [--scheme NAME] [--configuration NAME]",
402
- 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",
402
+ flow: "tapp run FLOW.yml [--var NAME=VALUE ...] [--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",
403
403
  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]",
404
404
  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",
405
405
  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",
@@ -516,14 +516,23 @@ if (typedCommand === "run" && (typedRest.includes("--studio") || process.env.TAP
516
516
  const { flags, positionals } = parseVerbArgs(typedRest);
517
517
  const name = String(positionals[0] || "").replace(/\.ya?ml$/i, "");
518
518
  if (!name) {
519
- console.error("❌ tapp run <journey> --studio https://app.runtapp.com (the journey's name in the Studio)");
519
+ console.error("❌ tapp run <journey|flow.yml> --studio https://app.runtapp.com\n a name replays the journey already there; a local Flow file is added as a journey and then replayed");
520
520
  process.exit(2);
521
521
  }
522
- const { studioConfig, runStudioJourney } = await import(path.join(packageRoot, "mcp-server", "src", "studio-client.js"));
522
+ const { studioConfig, runStudioJourney, pushStudioJourney } = await import(path.join(packageRoot, "mcp-server", "src", "studio-client.js"));
523
523
  try {
524
524
  const config = studioConfig({ studio: flags.studio, token: flags.token });
525
- console.log(`▶ ${name} · ${config.origin}`);
526
- const result = await runStudioJourney(config, name, { onProgress: (line) => console.log(` ${line}`) });
525
+ // A local Flow file means "put this journey on my Studio and run it there"; a bare name means
526
+ // "run the one already there". A repository's committed journey becomes a checked one this way.
527
+ const localFlow = path.resolve(String(positionals[0] || ""));
528
+ let journeyName = name;
529
+ if (/\.(ya?ml|json)$/i.test(localFlow) && fs.existsSync(localFlow)) {
530
+ const pushed = await pushStudioJourney(config, { yaml: fs.readFileSync(localFlow, "utf8"), name, replace: flags.replace === true });
531
+ console.log(`↑ ${pushed.name} — ${pushed.steps} steps → ${config.origin}`);
532
+ journeyName = pushed.slug;
533
+ }
534
+ console.log(`▶ ${journeyName} · ${config.origin}`);
535
+ const result = await runStudioJourney(config, journeyName, { onProgress: (line) => console.log(` ${line}`) });
527
536
  if (result.kind === "self-host") {
528
537
  console.log(`ℹ️ ${result.message}`);
529
538
  process.exit(2);
@@ -1409,7 +1418,7 @@ switch (command) {
1409
1418
  break;
1410
1419
  }
1411
1420
  if (!["run", "validate"].includes(verb) || !flowPath) {
1412
- console.error("usage: tapp validate --example\n tapp flow steps [--json]\n tapp run <flow.yml|glob> [...more] [--platform ios|android|web] [--actor NAME] [--email VALUE] [--password VALUE] [--url URL] [--app-id ID] [--apk FILE] [--serial ID]\n tapp validate <flow.yml|glob> [...more]\n Several Flows (or a glob) run in sequence and print one line per Flow; exit 1 if any failed.");
1421
+ console.error("usage: tapp validate --example\n tapp flow steps [--json]\n tapp run <flow.yml|glob> [...more] [--var NAME=VALUE ...] [--platform ios|android|web] [--actor NAME] [--email VALUE] [--password VALUE] [--url URL] [--app-id ID] [--apk FILE] [--serial ID]\n tapp validate <flow.yml|glob> [...more]\n Several Flows (or a glob) run in sequence and print one line per Flow; exit 1 if any failed.");
1413
1422
  process.exit(2);
1414
1423
  }
1415
1424
  // Several Flows in one command (field issue #9): the shell usually expands the glob, but a
@@ -1528,6 +1537,20 @@ switch (command) {
1528
1537
  env[envKey] = value;
1529
1538
  }
1530
1539
  }
1540
+ // Repeated --var NAME=VALUE. parseVerbArgs keeps only the last value for a repeated flag, so
1541
+ // read them off the argument list directly.
1542
+ const flowVars = {};
1543
+ for (let i = 0; i < rest.length - 1; i += 1) {
1544
+ if (rest[i] !== "--var") continue;
1545
+ const [name, ...value] = String(rest[i + 1]).split("=");
1546
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name) || !value.length) {
1547
+ console.error(`❌ --var expects NAME=VALUE (got '${rest[i + 1]}')`);
1548
+ process.exit(2);
1549
+ }
1550
+ flowVars[name] = value.join("=");
1551
+ }
1552
+ if (Object.keys(flowVars).length) env.TAPP_FLOW_VARS = JSON.stringify(flowVars);
1553
+
1531
1554
  let invocation;
1532
1555
  if (platform === "web") {
1533
1556
  const url = typeof flags.url === "string" ? flags.url : flow.url || flow.app;
@@ -160,7 +160,7 @@ function accountAllows(method, pathname) {
160
160
  if (method === "DELETE" && /^\/api\/tokens\/[a-f0-9]{12}$/.test(pathname)) return true;
161
161
  if (method === "DELETE" && /^\/api\/actors\/[A-Za-z0-9.:-]{1,253}\/[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(pathname)) return true;
162
162
  // Journeys: keep a proven run, replay it, forget it (ADR-0009 slice 3).
163
- if (method === "POST" && (/^\/api\/captures\/[A-Za-z0-9._-]{1,128}\/keep$/.test(pathname) || pathname === "/api/operations/run-flow")) return true;
163
+ if (method === "POST" && (/^\/api\/captures\/[A-Za-z0-9._-]{1,128}\/keep$/.test(pathname) || pathname === "/api/operations/run-flow" || pathname === "/api/journeys")) return true;
164
164
  if (method === "DELETE" && /^\/api\/journeys\/[a-z0-9-]{1,60}$/.test(pathname)) return true;
165
165
  return false;
166
166
  }
@@ -952,6 +952,49 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
952
952
  json(response, 200, { journeys });
953
953
  return;
954
954
  }
955
+ // Bring a journey you already have. A repository's committed Flow, or one an agent wrote,
956
+ // becomes a journey this account owns and tapp checks daily. The Studio replays it from
957
+ // here, so it must be a web journey against a public address — the same rule the egress
958
+ // proxy enforces at runtime, said plainly at import instead of failing mid-replay.
959
+ if (!anonymous && request.method === "POST" && url.pathname === "/api/journeys") {
960
+ guardMutation(request);
961
+ const body = await readJsonBody(request);
962
+ const yaml = String(body.yaml || "");
963
+ if (!yaml.trim()) { json(response, 400, { error: "Send the journey's YAML as `yaml`." }); return; }
964
+ if (yaml.length > 64_000) { json(response, 413, { error: "That journey is too large." }); return; }
965
+ const store = journeyStore();
966
+ const { loadFlowFile, validateFlowSteps, inferFlowPlatform } = await import("./flow-runtime.js");
967
+ const staging = path.join(os.tmpdir(), `tapp-journey-${crypto.randomBytes(8).toString("hex")}.yml`);
968
+ let flow;
969
+ try {
970
+ fs.writeFileSync(staging, yaml, { mode: 0o600 });
971
+ flow = loadFlowFile(staging);
972
+ } catch (error) {
973
+ json(response, 400, { error: `That is not a Flow tapp can read: ${String(error.message || error).slice(0, 200)}` });
974
+ return;
975
+ } finally { try { fs.rmSync(staging, { force: true }); } catch { /* temp */ } }
976
+ // The file is kept verbatim — its comments, `vars:` defaults and step shape are the
977
+ // journey. The journey's own `name:` wins; `name` only fills one in when the file has none.
978
+ const name = String(flow.name || body.name || "").trim().slice(0, 120);
979
+ if (!name) { json(response, 400, { error: "A journey needs a name: give the Flow a `name:` or pass one." }); return; }
980
+ if (inferFlowPlatform(flow) !== "web") { json(response, 400, { error: "The Studio replays web journeys; an iOS or Android one runs where that device is." }); return; }
981
+ const errors = validateFlowSteps(flow);
982
+ if (errors.length) { json(response, 400, { error: `That journey has steps tapp cannot replay: ${errors.slice(0, 3).join("; ")}` }); return; }
983
+ let target;
984
+ try { target = new URL(flow.url || flow.app || ""); } catch { target = null; }
985
+ if (!target || !/^https?:$/.test(target.protocol)) { json(response, 400, { error: "The journey needs a `url:` the Studio can open." }); return; }
986
+ if (/^(localhost|127\.|0\.|10\.|192\.168\.|\[?::1)/i.test(target.hostname) || /\.local$/i.test(target.hostname)) {
987
+ json(response, 400, { error: `This Studio cannot reach ${target.hostname} — it only opens public addresses. Run tapp where that app is: npx -y @aarwitz/tapp@latest app` });
988
+ return;
989
+ }
990
+ let kept;
991
+ const storedYaml = /^name:/m.test(yaml) ? yaml : `name: ${JSON.stringify(name)}\n${yaml}`;
992
+ try { kept = store.keep({ flow: { ...flow, name }, yaml: storedYaml }, { replace: body.replace === true }); }
993
+ catch (error) { json(response, error.statusCode || 500, { error: error.message }); return; }
994
+ logUsage("journey.imported", { owner: (ownerKey || "operator").slice(0, 13), host: safeHost(target.href) });
995
+ json(response, 200, { name, slug: kept.slug, steps: (flow.steps || []).length, imported: true });
996
+ return;
997
+ }
955
998
  const forgetJourneyMatch = !anonymous && request.method === "DELETE" ? url.pathname.match(/^\/api\/journeys\/([a-z0-9-]{1,60})$/) : null;
956
999
  if (forgetJourneyMatch) {
957
1000
  guardMutation(request);
@@ -46,6 +46,11 @@ export async function listStudioJourneys(config) {
46
46
  return journeys;
47
47
  }
48
48
 
49
+ /** Put a journey you already have on the Studio, so it is owned and checked there. */
50
+ export async function pushStudioJourney(config, { name = "", yaml, replace = false }) {
51
+ return call(config, "/api/journeys", { method: "POST", body: { name, yaml, replace } });
52
+ }
53
+
49
54
  /** Replay one journey and wait for the verdict. */
50
55
  export async function runStudioJourney(config, name, { onProgress = () => {}, timeoutMs = DEFAULT_TIMEOUT_MS, sleep = (ms) => new Promise((r) => setTimeout(r, ms)) } = {}) {
51
56
  const started = await call(config, "/api/operations/run-flow", { method: "POST", body: { name } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
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",
@@ -28,6 +28,9 @@ try {
28
28
  ...(process.env.TAPP_WORKFLOW_REPLAY === "1" ? {strictOrigin:true,variables:{
29
29
  TEST_RUN_ID:process.env.TEST_RUN_ID || "",TEST_EMAIL:process.env.OCQA_TEST_EMAIL || "",TEST_PASSWORD:process.env.OCQA_TEST_PASSWORD || "",
30
30
  }} : {}),
31
+ // `tapp run FLOW --var NAME=VALUE` — the same journey against another environment, coach or
32
+ // tenant without editing it. Merged over the Flow's own `vars:` defaults (flowVariables).
33
+ ...(process.env.TAPP_FLOW_VARS ? { variables: JSON.parse(process.env.TAPP_FLOW_VARS) } : {}),
31
34
  device: process.env.TAPP_WEB_DEVICE || "",
32
35
  viewport: process.env.TAPP_WEB_VIEWPORT || "",
33
36
  });