@aarwitz/tapp 0.18.3 โ†’ 0.19.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.
@@ -2741,7 +2741,9 @@ export const TOOLS = [
2741
2741
  "The fast way (seconds) to SEE the app: with appBundleId/androidAppId it launches the installed app fresh and returns a screenshot " +
2742
2742
  "plus the accessibility tree of the screen it lands on; with no target it photographs whatever is on the booted simulator right now " +
2743
2743
  "(tree:true returns the accessibility tree instead). No exploration, no findings. Use appLaunchArgs/appLaunchEnv for a login bypass " +
2744
- "or backend override. For a screen reached by signing in or several taps, use tapp_session.",
2744
+ "or backend override. For a screen reached by signing in or several taps, use tapp_session. " +
2745
+ "Pass `capture` (an id, a path, or \"latest\") to read a finished run instead of a live app: its screens with the moment each " +
2746
+ "was reached, `at` for one screen's frame, `frames:true` for contact sheets that make a recording cheap to scan.",
2745
2747
  inputSchema: {
2746
2748
  type: "object",
2747
2749
  properties: {
@@ -2752,6 +2754,9 @@ export const TOOLS = [
2752
2754
  appLaunchArgs: { type: "array", items: { type: "string" }, description: "Launch args, e.g. [\"--uitesting\"]" },
2753
2755
  appLaunchEnv: { type: "object", additionalProperties: { type: "string" }, description: "Launch env, e.g. {\"UI_TEST_BACKEND\": \"staging\"}" },
2754
2756
  maxWidth: { type: "integer", minimum: 200, maximum: 1400, default: 700, description: "Max screenshot width in px" },
2757
+ capture: { type: "string", description: "Read a FINISHED run instead of a live app: a capture id, a capture directory, or \"latest\". Returns the screens it observed with the moment each was reached." },
2758
+ at: { type: "string", description: "With capture: pull the frame for one screen, by index (\"3\") or screen name (\"Checkout\")" },
2759
+ frames: { type: "boolean", default: false, description: "With capture: contact sheets โ€” many frames per image, for scanning a recording cheaply instead of one frame at a time" },
2755
2760
  },
2756
2761
  },
2757
2762
  },
@@ -3048,6 +3053,67 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }))
3048
3053
  // The in-flight MCP request (progress tokens); routed and legacy calls share it.
3049
3054
  let currentRequest = null;
3050
3055
 
3056
+ // Reading a finished run: the same question `tapp_look` always answered ("what was on screen"),
3057
+ // asked of a recording instead of a live app. The engine indexed the states while the run
3058
+ // happened, so a screen's frame is a seek rather than a scan of the whole video.
3059
+ async function lookAtCapture(args = {}) {
3060
+ const frames = await import("./capture-frames.js");
3061
+ const dir = frames.resolveCapture(args.capture);
3062
+ if (!dir) return errorResult(`No capture found for '${args.capture}'`, { hint: "Pass a capture id, a capture directory, or \"latest\"." });
3063
+ const index = frames.captureIndex(dir);
3064
+
3065
+ if (isNonEmptyString(args.at)) {
3066
+ const state = frames.selectState(index, args.at);
3067
+ if (!state) {
3068
+ return errorResult(`No screen matching '${args.at}' in ${index.capture}`, { screens: index.states.map((s) => ({ index: s.index, screen: s.screen })) });
3069
+ }
3070
+ const out = path.join(dir, `frame_${state.index}.png`);
3071
+ const got = await frames.extractFrame(index, state, out).catch((error) => ({ error }));
3072
+ if (!got || got.error) return errorResult(`No frame or screenshot for screen ${state.index}`, { detail: got?.error?.message });
3073
+ const summary = `๐Ÿ“ผ ${index.capture} ยท screen ${state.index}/${index.states.length}: ${state.screen}${state.url ? ` (${state.url})` : ""}` +
3074
+ `\n${got.from === "recording" ? `frame at ${(got.atMs / 1000).toFixed(1)}s of ${index.recording.file}` : "screenshot written during the run"}` +
3075
+ (state.findings.length ? `\nfindings here: ${state.findings.map((f) => `${f.severity} ${f.title}`).join("; ")}` : "");
3076
+ return {
3077
+ content: [
3078
+ { type: "text", text: summary },
3079
+ { type: "image", data: fs.readFileSync(out).toString("base64"), mimeType: "image/png" },
3080
+ ],
3081
+ structuredContent: { capture: index.capture, state },
3082
+ };
3083
+ }
3084
+
3085
+ if (args.frames === true) {
3086
+ const sheets = await frames.contactSheets(index, path.join(dir, "frames")).catch((error) => ({ error }));
3087
+ if (!sheets || sheets.error || !sheets.length) {
3088
+ return errorResult("Could not build contact sheets", { detail: sheets?.error?.message || "the run recorded no video and no screenshots" });
3089
+ }
3090
+ return {
3091
+ content: [
3092
+ { type: "text", text: `๐Ÿ“ผ ${index.capture} ยท ${sheets.length} contact sheet(s), many frames per image.` +
3093
+ `\nSheets: ${sheets.map((sheet) => path.basename(sheet)).join(", ")} in ${path.join(dir, "frames")}` +
3094
+ `\nShowing the first; read the rest from disk, or ask for one screen with at:"<n|screen>".` },
3095
+ { type: "image", data: fs.readFileSync(sheets[0]).toString("base64"), mimeType: "image/png" },
3096
+ ],
3097
+ structuredContent: { capture: index.capture, sheets },
3098
+ };
3099
+ }
3100
+
3101
+ const screens = index.states.map((state) => `${String(state.index).padStart(2)}. ${state.videoAtMs != null ? `${(state.videoAtMs / 1000).toFixed(1)}s` : "โ€”"} ${state.screen}${state.url ? ` ${state.url}` : ""}`).join("\n");
3102
+ return {
3103
+ content: [{ type: "text", text: `๐Ÿ“ผ ${index.capture} โ€” ${index.states.length} screen(s), ${index.actions} action(s), ${index.findings} finding(s)\n${index.recording ? `recording: ${index.recording.file}${index.recording.indexed ? "" : " (no frame index)"}` : "recording: none"}\n\n${screens}` }],
3104
+ structuredContent: {
3105
+ capture: index.capture,
3106
+ recording: index.recording ? { file: index.recording.file, indexed: index.recording.indexed } : null,
3107
+ screens: index.states.map((s) => ({ index: s.index, screen: s.screen, url: s.url, atMs: s.videoAtMs ?? s.t, screenshot: s.screenshot, findings: s.findings })),
3108
+ actions: index.actions,
3109
+ findings: index.findings,
3110
+ next: index.recording?.indexed
3111
+ ? 'Ask for one screen with at:"<n|screen>", or frames:true to scan the recording.'
3112
+ : 'This run predates frame indexing, so screens have no video timestamp; at:"<n>" falls back to the screenshot.',
3113
+ },
3114
+ };
3115
+ }
3116
+
3051
3117
  async function handleTool(name, args = {}) {
3052
3118
  const request = currentRequest || { params: { name, arguments: args, _meta: {} } };
3053
3119
 
@@ -3951,6 +4017,8 @@ async function handleTool(name, args = {}) {
3951
4017
  url: isNonEmptyString(args.url) ? args.url.trim() : undefined,
3952
4018
  logPath: flowLog,
3953
4019
  screenshotDir: evidenceDir,
4020
+ // Opt-in, matching scripts/run-web-flow.js rather than inventing a second convention.
4021
+ ...(process.env.TAPP_FLOW_RECORD_VIDEO === "1" ? { recordVideoDir: evidenceDir } : {}),
3954
4022
  device: isNonEmptyString(args.device) ? args.device.trim() : "",
3955
4023
  viewport: isNonEmptyString(args.viewport) ? args.viewport.trim() : "",
3956
4024
  });
@@ -4510,9 +4578,12 @@ export async function routePublicTool(name, args = {}) {
4510
4578
  if (readOnly === true) return handleTool("tapp_audit", rest);
4511
4579
  if (isNonEmptyString(goal)) return handleTool("tapp_focus", { query: goal, projectDir: rest.projectDir, platform: rest.platform, mapPath: rest.mapPath, authToken: rest.authToken });
4512
4580
  return handleTool("tapp_explore", rest);
4513
- case "tapp_look":
4581
+ case "tapp_look": {
4582
+ // A capture is a target like any other; the screen is recorded rather than live.
4583
+ if (isNonEmptyString(rest.capture)) return lookAtCapture(rest);
4514
4584
  if (isNonEmptyString(rest.appBundleId) || isNonEmptyString(rest.androidAppId)) return handleTool("tapp_open_app", rest);
4515
4585
  return handleTool(tree === true ? "tapp_ui_tree" : "tapp_screenshot", rest);
4586
+ }
4516
4587
  case "tapp_run": {
4517
4588
  if (rest.flow || isNonEmptyString(rest.flowPath)) return handleTool("tapp_flow_run", rest);
4518
4589
  if (rest.scenario || isNonEmptyString(rest.scenarioPath)) return handleTool("tapp_scenario_run", rest);
@@ -257,10 +257,14 @@ async function auditOnePage(context, target, { timeoutMs, linkCheckLimit, captur
257
257
  const screen = target.pathname + target.search;
258
258
  for (const f of findings) { f.screen = screen; if (!f.url) f.url = page.url(); }
259
259
 
260
+ // Where this page's screenshot landed, so a live viewer can show the page being audited
261
+ // instead of an empty panel. Absolute, because that is what the progress channel forwards.
262
+ let statePath = "";
260
263
  if (capture) {
261
264
  capture.states += 1;
262
265
  const stateName = `state_${capture.states}_${slug(target.pathname === "/" ? (controls.title || "home") : target.pathname)}.png`;
263
- await page.screenshot({ path: path.join(capture.dir, stateName), fullPage: true }).catch(() => page.screenshot({ path: path.join(capture.dir, stateName) }).catch(() => {}));
266
+ statePath = path.join(capture.dir, stateName);
267
+ await page.screenshot({ path: statePath, fullPage: true }).catch(() => page.screenshot({ path: statePath }).catch(() => {}));
264
268
  capture.emit("STATE", { screen, url: page.url(), elements: controls.controlCount, role: "page", controls: controls.dead.map((d) => d.label).filter(Boolean).slice(0, 40), inputs: [], settled: true, screenshot: stateName });
265
269
  for (const f of findings) {
266
270
  if (f.selector) {
@@ -285,6 +289,7 @@ async function auditOnePage(context, target, { timeoutMs, linkCheckLimit, captur
285
289
  // Why the wiring-dependent checks were skipped on this page, if they were.
286
290
  ...(controls.wiringUnverifiable ? { wiringUnverifiable: controls.wiringUnverifiable } : {}),
287
291
  findings,
292
+ ...(statePath ? { screenshot: statePath } : {}),
288
293
  links: allowedLinks,
289
294
  };
290
295
  } finally {
@@ -686,7 +686,12 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
686
686
  emit("CONTEXT", { ...(String(device || "").trim() ? { device: String(device).trim() } : {}), viewport: captureProfile.viewport, deviceScaleFactor: captureProfile.deviceScaleFactor ?? 1 });
687
687
  // Playwright records natively (no ffmpeg transcode needed, unlike simctl's .mov output) โ€”
688
688
  // written to a Playwright-chosen filename in outDir, finalized only on context.close().
689
+ // The video and the markers have to share a clock, or a state's frame cannot be found without
690
+ // searching the whole recording. Record where the capture begins relative to the marker
691
+ // timebase; every STATE below carries the same `t`, so a frame is a seek.
692
+ const recordingStartedMs = Date.now() - startedAtMs;
689
693
  const context = await browser.newContext({ ...captureProfile, recordVideo: { dir: outDir, size: captureProfile.viewport } });
694
+ emit("RECORDING", { file: "exploration.webm", startsAtMs: recordingStartedMs, fps: 25 });
690
695
  await installWebListenerTracking(context);
691
696
  if (watch) await installWebWatchUi(context);
692
697
  const page = await context.newPage();
@@ -700,7 +705,7 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
700
705
  // current page; the post-crawl outbound audit passes the link's source page explicitly so
701
706
  // a bad footer link is never attributed to whatever page happened to be visited last.
702
707
  const pageUrl = sourceUrl || page.url();
703
- emit("ISSUE", { type, severity, title, screen, ...(target ? { target } : {}), ...(pageUrl && pageUrl !== "about:blank" ? { url: pageUrl } : {}), ...(evidence ? { evidence } : {}) });
708
+ emit("ISSUE", { t: Date.now() - startedAtMs, type, severity, title, screen, ...(target ? { target } : {}), ...(pageUrl && pageUrl !== "about:blank" ? { url: pageUrl } : {}), ...(evidence ? { evidence } : {}) });
704
709
  };
705
710
 
706
711
  // Async defect listeners: attribute to whatever screen is current when they fire.
@@ -856,7 +861,7 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
856
861
  const screen = webScreenTitle(info, key);
857
862
  const evidenceKey = `${key}::${screen}`;
858
863
  currentScreen = screen;
859
- emit("STATE", { screen, url: key, elements: info.controlCount, role: webScreenRole(screen, info.inputs), controls: info.controls, inputs: info.inputs, settled: !info.busy });
864
+ emit("STATE", { t: Date.now() - startedAtMs, screen, url: key, elements: info.controlCount, role: webScreenRole(screen, info.inputs), controls: info.controls, inputs: info.inputs, settled: !info.busy });
860
865
  const completedNavigation = pendingNavigation;
861
866
  const transitionFrom = webTransitionOrigin(completedNavigation, lastScreen);
862
867
  const transitionAction = completedNavigation?.action || lastActionTarget;
@@ -354,9 +354,19 @@ export async function runWebFlow({ flow, url, logPath, screenshotDir, recordVide
354
354
  }
355
355
  } finally {
356
356
  await requestPhase(teardown);
357
+ // Playwright only finalizes a recording when its context closes, and names the file by an
358
+ // internal id. Capture the handle first, then give it the name the evidence page expects โ€”
359
+ // the same convention exploration already uses.
360
+ const video = recordVideoDir && typeof page.video === "function" ? page.video() : null;
357
361
  // Test doubles for playwright may not model a context; a real one always closes.
358
362
  if (typeof context.close === "function") await context.close().catch(() => {});
359
363
  await browser.close().catch(() => {});
364
+ if (video) {
365
+ try {
366
+ const produced = await video.path();
367
+ if (produced && fs.existsSync(produced)) fs.renameSync(produced, path.join(recordVideoDir, "replay.webm"));
368
+ } catch { /* the replay result matters more than its recording */ }
369
+ }
360
370
  }
361
371
  return log.finish({ url: startUrl });
362
372
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.18.3",
3
+ "version": "0.19.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",
@@ -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/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-chat-narration.test.js tests/browser-onboarding.test.js tests/managed-operation.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/capture-frames.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-chat-narration.test.js tests/browser-onboarding.test.js tests/managed-operation.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
  }
@@ -14,6 +14,7 @@ screen or journey works from source inspection alone.
14
14
  |---|---|
15
15
  | See or screenshot one screen | `look` / `tapp_look` |
16
16
  | Inspect controls on the current screen | `look --tree` / `tapp_look {tree:true}` |
17
+ | See what a finished run saw | `look <capture>` / `tapp_look {capture}` โ€” add `at` for one screen's frame, `frames:true` to scan |
17
18
  | Reach a named screen/control | `explore --goal` / `tapp_explore {goal}` (source + observed UI Map fast path) |
18
19
  | Drive a specific journey | `tapp_session` start โ†’ act โ†’ end |
19
20
  | Find bugs autonomously (owned app/environment; it clicks) | `explore` / `tapp_explore` |
@@ -18,6 +18,9 @@ npx -y @aarwitz/tapp@latest explore --read-only https://example.com --pages 5 --
18
18
  # several URLs or --urls FILE batch sites ยท --device "iPhone 13" audits the mobile rendering ยท --json FILE writes the result ยท exit 1 = defects found
19
19
  npx -y @aarwitz/tapp@latest look [target] # one screen: summary + screenshot file
20
20
  npx -y @aarwitz/tapp@latest look [target] --tree --json # + the accessibility tree (every element with --json)
21
+ npx -y @aarwitz/tapp@latest look latest # a finished run: its screens and when each was reached
22
+ npx -y @aarwitz/tapp@latest look latest --at 6 # that screen's frame, seeked out of the recording
23
+ npx -y @aarwitz/tapp@latest look latest --frames # contact sheets: ~25 frames per image, for scanning
21
24
  npx -y @aarwitz/tapp@latest report latest
22
25
  npx -y @aarwitz/tapp@latest doctor # toolchain check ยท --install prebuilds the iOS harness (~2 min, once)
23
26
  npx -y @aarwitz/tapp@latest feedback "short title" --body "what happened" --type bug|idea|question # draft; add --submit to file (public)
@@ -56,6 +59,10 @@ npx -y @aarwitz/tapp@latest look https://example.com --tap "Not now" --wait-for
56
59
  - `tapp_look`: the current real surface โ€” screen summary plus inline screenshot; `tree:true` adds
57
60
  the accessibility tree (`full:true` for the complete raw element list when the default
58
61
  โ‰ค160-element projection might omit the text you are checking for).
62
+ Also reads a **finished run**: `capture:"<id>|<path>|latest"` returns the screens it observed
63
+ with the moment each was reached, `at:"<n>|<screen>"` pulls that screen's frame out of the
64
+ recording, `frames:true` returns contact sheets (many frames per image) for scanning a run
65
+ cheaply. Prefer `at:` over `frames:` when you know which screen you want โ€” it is one seek.
59
66
  - `tapp_session`: one persistent journey. `action:"start"` โ†’ `tap|type|swipe|back|wait|tree|login`
60
67
  โ†’ `action:"end"`. `action:"save_flow"` keeps the driven journey as a Flow; `action:"draft_flow"`
61
68
  proposes one from a goal (an untrusted draft until replayed). Sessions begin from a **cold**