@aarwitz/tapp 0.25.1 → 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.1",
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.1",
27
+ "@aarwitz/tapp@0.26.0",
28
28
  "mcp"
29
29
  ],
30
30
  "cwd": "${CLAUDE_PROJECT_DIR}"
package/bin/tapp.js CHANGED
@@ -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);
@@ -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.1",
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",