@aarwitz/tapp 0.35.9 → 0.35.11

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.35.9",
4
+ "version": "0.35.11",
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.35.9",
27
+ "@aarwitz/tapp@0.35.11",
28
28
  "mcp"
29
29
  ],
30
30
  "cwd": "${CLAUDE_PROJECT_DIR}"
package/README.md CHANGED
@@ -31,10 +31,9 @@ Supported targets:
31
31
  | Android | Connected emulator or device with `adb`; driven through UIAutomator |
32
32
  | Web | Owned browser app in Playwright Chromium |
33
33
  | macOS desktop | Any `.app` on a Mac, driven through the Accessibility API; needs the Accessibility permission (`tapp doctor` says how) |
34
- | Windows desktop | WPF, WinForms, and WinUI apps through Windows UI Automation — early runs are set up through the pilot |
35
34
 
36
- Windows hosts Android and web testing when their prerequisites are installed, and is the home of
37
- the Windows desktop target.
35
+ Windows hosts Android and web testing when their prerequisites are installed. Windows desktop
36
+ applications are not a target.
38
37
 
39
38
  ## Give Tapp to your coding agent
40
39
 
package/bin/tapp.js CHANGED
@@ -290,8 +290,8 @@ function repeatedFlagValues(argv, name) {
290
290
  }
291
291
 
292
292
  // `--platform windows` used to be indistinguishable from `--platform wbe`: both got
293
- // "must be ios|android|web", which tells someone who read runtapp.com's Windows card that they
294
- // typed it wrong. They did not — tapp has no driver for it yet. Say which of the two it is.
293
+ // "must be ios|android|web". Windows desktop is not a target (owner decision, 2026-11-25), and
294
+ // somebody who asks for it deserves that sentence rather than "you typed it wrong".
295
295
  const DRIVEN_PLATFORMS = ["ios", "android", "web", "macos"];
296
296
  const DECLARED_WITHOUT_DRIVER = {
297
297
  windows: "Windows desktop applications (WPF, WinForms, WinUI)",
@@ -300,9 +300,8 @@ const DECLARED_WITHOUT_DRIVER = {
300
300
  function refusePlatform(platform) {
301
301
  const described = DECLARED_WITHOUT_DRIVER[String(platform || "").toLowerCase()];
302
302
  if (described) {
303
- console.error(`❌ tapp has no driver for ${described} yet, so there is nothing to run here.`);
304
- console.error(" Early runs are set up with us while the driver lands: hello@runtapp.com");
305
- console.error(" Today tapp drives: web (anywhere), iOS and macOS apps (on a Mac), Android (adb).");
303
+ console.error(`❌ tapp does not drive ${described}, so there is nothing to run here.`);
304
+ console.error(" tapp drives: web (anywhere), iOS and macOS apps (on a Mac), Android (adb).");
306
305
  } else {
307
306
  console.error("❌ --platform must be ios|android|web|macos");
308
307
  }
package/browser/app.css CHANGED
@@ -477,6 +477,7 @@ dialog::backdrop { background:rgba(0,0,0,.6); }
477
477
  .prompt-suggestions button:hover { background:var(--tapp-panel); }
478
478
  .prompt-suggestions button span { font-size:16px; text-align:center; } .prompt-suggestions button b { font-weight:600; font-family:var(--tapp-font-mono); font-size:12.5px; white-space:nowrap; } .prompt-suggestions button small { color:var(--tapp-text-faint); font-size:12.5px; }
479
479
  .prompt-note { text-align:center; color:var(--tapp-text-faint); font-size:12px; margin:8px 0 0; }
480
+ .connecting-note { font-size:13px; color:var(--tapp-text-soft); margin:0 auto 14px; max-width:620px; }
480
481
  #business-results { display:grid; gap:10px; margin:12px 0; }
481
482
  #business-results p { margin:0; }
482
483
  .business-match { display:flex; flex-wrap:wrap; gap:6px 12px; align-items:center; border-top:1px solid var(--tapp-border); padding:10px 0; }
@@ -595,6 +596,15 @@ dialog::backdrop { background:rgba(0,0,0,.6); }
595
596
  .selfhost-row input { flex:1 1 220px; min-width:0; font:inherit; font-size:13px; padding:9px 12px; border-radius:10px; border:1px solid var(--line); background:rgba(0,0,0,.15); color:inherit; }
596
597
  .linklike { font:inherit; font-size:inherit; background:none; border:0; padding:0; color:var(--tapp-accent, #4f6cf7); cursor:pointer; text-decoration:underline; }
597
598
  .cloud-sent { margin:8px 0 0; }
599
+ /* A brand's surfaces (ADR-0013). */
600
+ .surface-row { display:grid; grid-template-columns:28px 1fr auto auto; gap:10px; align-items:center; padding:9px 10px; border-bottom:1px solid var(--tapp-border); font-size:13px; }
601
+ .surface-row:last-child { border-bottom:0; }
602
+ .surface-row .surface-icon { font-size:16px; text-align:center; }
603
+ .surface-row small { color:var(--muted); display:block; }
604
+ .surface-row a { color:inherit; }
605
+ .surface-row .journey-status.warning { background:rgba(210,153,34,.18); color:var(--tapp-amber-soft, #e3b341); }
606
+ .brand-offer { display:flex; gap:10px; align-items:center; flex-wrap:wrap; font-size:13px; }
607
+
598
608
  /* Setting this machine up (ADR-0012). */
599
609
  .setup-card { max-width:760px; margin:18px auto 0; padding:16px 18px; border-radius:var(--tapp-radius-lg, 14px); border:1px solid var(--line); background:var(--control); font-size:13px; line-height:1.5; text-align:left; }
600
610
  .setup-head { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; }
package/browser/app.js CHANGED
@@ -37,6 +37,12 @@ const state = {
37
37
  if (fromHash) { saveConnection(fromHash); history.replaceState(null, "", location.pathname + location.search); }
38
38
  state.connection = loadConnection();
39
39
  if (state.connection && state.connection.origin === location.origin) state.connection = null;
40
+ // A connect link pasted into a tab that is already open changes only the fragment, which is
41
+ // not a page load: take the pair the same way, then load the page properly.
42
+ window.addEventListener("hashchange", () => {
43
+ const pasted = parseConnectFragment(location.hash);
44
+ if (pasted) { saveConnection(pasted); location.replace(location.pathname + location.search); }
45
+ });
40
46
  }
41
47
  const $ = (selector) => document.querySelector(selector);
42
48
  const $$ = (selector) => [...document.querySelectorAll(selector)];
@@ -277,7 +283,7 @@ function applyAccessMode() {
277
283
  $("#selfhost-card")?.classList.remove("hidden");
278
284
  $("#cloud-card")?.classList.toggle("hidden", signedIn);
279
285
  const lead = $("#selfhost-lead");
280
- if (lead && state.connectionLost) lead.innerHTML = `<strong>Your machine stopped answering at ${esc(state.connectionLost.origin)}.</strong> Start the runtime again and this page connects to it; or open the address the command prints if this browser will not reach your machine.`;
286
+ if (lead && state.connectionLost) lead.innerHTML = `<strong>This page could not reach your machine at ${esc(state.connectionLost.origin)}</strong> (${esc(state.connectionLost.reason)}). If Chrome asked to access devices on your local network, allow it and run the command again. Otherwise open the Studio directly on your machine — the same thing, served from there: <a href="${esc(state.connectionLost.launch)}">${esc(state.connectionLost.origin)}</a>.`;
281
287
  const input = $("#prompt-input");
282
288
  if (input && !accepts.has("path")) input.placeholder = "A business name or website URL…";
283
289
  // Everything that only means something against a source repository: a target to build, a
@@ -1306,7 +1312,7 @@ function syncTranscriptFromJob(name, job) {
1306
1312
  function startLine(name, job) {
1307
1313
  const raw = job.input || "";
1308
1314
  const input = /\.(app|apk)$/i.test(raw) ? raw.split("/").filter(Boolean).at(-1) : raw;
1309
- return { initialize: "Starting a release check — build, launch and explore the real app", gate: "Running the release gate", audit: `Opening ${input} read-only — nothing will be clicked`, "explore-build": `Exploring ${input} on the booted device`, open: `Opening ${input}`, "session-start": "Opening a live session", "session-act": "Acting in the live session", "session-save-flow": "Saving the journey as a Flow", "session-end": "Ending the live session" }[name] || `${pretty(name)} started`;
1315
+ return { initialize: "Starting a release check — build, launch and explore the real app", gate: "Running the release gate", audit: `Opening ${input} read-only — nothing will be clicked`, "explore-build": `Exploring ${input} on the booted device`, open: `Opening ${input}`, "session-start": "Opening a live session", "session-act": "Acting in the live session", "session-save-flow": "Saving the journey as a Flow", "session-end": "Ending the live session", brand: `Mapping the brand from ${input} — its stores, channels and handles, read-only` }[name] || `${pretty(name)} started`;
1310
1316
  }
1311
1317
 
1312
1318
  async function finishTranscript(name, job) {
@@ -1405,17 +1411,21 @@ function renderProject() {
1405
1411
 
1406
1412
  async function refreshSession() {
1407
1413
  if (state.connection) {
1408
- try { state.session = await api("/api/session"); }
1414
+ // Chrome asks the person before a page may reach their local network, and the fetch waits
1415
+ // on their answer; give that long, then stop waiting rather than show a blank page.
1416
+ const waited = new Promise((_, reject) => setTimeout(() => reject(new Error("this page was not allowed to reach your machine")), 25_000));
1417
+ try { state.session = await Promise.race([api("/api/session"), waited]); }
1409
1418
  catch (error) {
1410
- // The machine stopped answering (the runtime was closed, or this browser will not reach
1411
- // loopback). Say so on the hosted page and carry on as a visitor; the saved connection is
1412
- // dropped so a reload does not loop on the same failure.
1413
- state.connectionLost = { origin: state.connection.origin, reason: error.message };
1419
+ // The machine stopped answering (the runtime was closed, Chrome refused, or this browser
1420
+ // will not reach loopback). Say so on the hosted page, with the way round it, and carry on
1421
+ // as a visitor; the saved connection is dropped so a reload does not loop on the failure.
1422
+ state.connectionLost = { origin: state.connection.origin, launch: `${state.connection.origin}/?token=${encodeURIComponent(state.connection.token)}`, reason: error.message };
1414
1423
  state.connection = null;
1415
1424
  saveConnection(null);
1416
1425
  state.session = await api("/api/session");
1417
1426
  }
1418
1427
  } else state.session = await api("/api/session");
1428
+ $("#connecting-note")?.classList.add("hidden");
1419
1429
  state.csrf = state.session.csrfToken;
1420
1430
  const local = state.session.mode === "local";
1421
1431
  $("#mode-pill").textContent = local ? (state.connection ? "Connected · your machine" : "Self-host · this machine") : "Cloud · outbound runner";
@@ -1557,15 +1567,57 @@ async function searchBusiness(name) {
1557
1567
  }));
1558
1568
  if (request !== businessRequest) return;
1559
1569
  panel.innerHTML = `<p>${esc(result.message)}</p>` + (result.matches || []).map(app =>
1560
- `<div class="business-match"><strong>${esc(app.name)}<small>${esc(app.publisher)}</small></strong><a href="${esc(app.listing)}" target="_blank" rel="noreferrer">App Store listing</a>${app.website ? `<button type="button" class="secondary" data-business-site="${esc(app.website)}">Audit ${esc(new URL(app.website).host)}</button>` : "<small>Publisher has no website listed.</small>"}</div>`
1570
+ `<div class="business-match"><strong>${esc(app.name)}<small>${esc(app.publisher)}</small></strong><a href="${esc(app.listing)}" target="_blank" rel="noreferrer">App Store listing</a>${app.website ? `<button type="button" class="primary" data-brand-site="${esc(app.website)}">Map ${esc(new URL(app.website).host)}</button><button type="button" class="secondary" data-business-site="${esc(app.website)}">Audit it</button>` : "<small>Publisher has no website listed.</small>"}</div>`
1561
1571
  ).join("");
1562
1572
  }
1563
1573
 
1574
+ // ——— A brand's surfaces (ADR-0013) ———————————————————————————————————————————————————————————
1575
+ // A name or a website becomes the business: its website, its listings in the stores, its
1576
+ // channels and handles, each with what a visitor could see of it — read-only, never signed in.
1577
+ const SURFACE_ICONS = { website: "🌐", "app-store": "🍎", "play-store": "🤖", youtube: "▶️", x: "✕", tiktok: "🎵", instagram: "📷", facebook: "📘", threads: "🧵", linkedin: "💼", "google-business": "📍" };
1578
+ async function mapBrand(url) {
1579
+ clearBusinessResults();
1580
+ state.brand = null; state.brandOffer = null;
1581
+ state.promptRun = true; state.promptPlatform = "web";
1582
+ showProduct(); activateView("overview"); renderDeviceChrome(); renderChat(); renderBrand();
1583
+ document.querySelector(".device-stage")?.classList.add("hidden");
1584
+ setHeading("Mapping the brand", "Finding its surfaces from the website — nothing is clicked, nobody is signed in.", { owned: true });
1585
+ let result;
1586
+ try { result = await runOperation("brand", { url }, { input: url }); }
1587
+ catch (error) { setHeading("Not mapped", error.message, { owned: true }); throw error; }
1588
+ state.brand = result;
1589
+ setHeading(result.name || "Brand", `${result.surfaces.length} surface${result.surfaces.length === 1 ? "" : "s"} found from ${new URL(result.url).host}.`, { owned: true });
1590
+ renderBrand();
1591
+ }
1592
+
1593
+ function renderBrand() {
1594
+ const panel = $("#brand-panel");
1595
+ if (!panel) return;
1596
+ const brand = state.brand;
1597
+ const offer = state.brandOffer;
1598
+ panel.classList.toggle("hidden", !brand && !offer);
1599
+ if (!brand && !offer) return;
1600
+ if (!brand) {
1601
+ $("#brand-title").textContent = "The rest of this brand";
1602
+ $("#brand-sub").textContent = "Its apps in the stores, its channels and handles — found from the website and checked read-only.";
1603
+ $("#brand-actions").innerHTML = `<button class="primary" type="button" data-brand-site="${esc(offer)}">Map ${esc(new URL(offer).host)}</button>`;
1604
+ $("#brand-list").innerHTML = "";
1605
+ return;
1606
+ }
1607
+ const pill = (status) => status === "ok" ? `<span class="journey-status passing">seen</span>` : status === "warning" ? `<span class="journey-status warning">missing</span>` : status === "unreachable" ? `<span class="journey-status failing">unreachable</span>` : `<span class="journey-status never">not checked</span>`;
1608
+ $("#brand-title").textContent = brand.name || new URL(brand.url).host;
1609
+ $("#brand-sub").textContent = `${brand.surfaces.length} surface${brand.surfaces.length === 1 ? "" : "s"} found from ${new URL(brand.url).host} · ${brand.counts?.ok || 0} seen${brand.counts?.["not-checked"] ? ` · ${brand.counts["not-checked"]} could not be checked` : ""}${brand.counts?.warning ? ` · ${brand.counts.warning} missing` : ""}. tapp reads what a visitor is shown and never signs in to a social account.`;
1610
+ $("#brand-actions").innerHTML = `<button class="secondary" type="button" data-brand-audit="${esc(brand.url)}">Audit the website read-only</button><button class="quiet" type="button" data-brand-site="${esc(brand.url)}">Map again</button>`;
1611
+ const row = (surface) => `<div class="surface-row"><span class="surface-icon">${SURFACE_ICONS[surface.kind] || "•"}</span><span><strong>${esc(surface.label)}</strong>${surface.kind !== "website" && surface.handle ? ` <small style="display:inline">${esc(surface.handle)}</small>` : ""}<small>${esc(surface.check?.note || "")}</small></span>${pill(surface.check?.status)}<a href="${esc(surface.url)}" target="_blank" rel="noreferrer">Open</a></div>`;
1612
+ $("#brand-list").innerHTML = [brand.website, ...brand.surfaces].map(row).join("");
1613
+ }
1614
+
1564
1615
  async function startFromPrompt(raw, { readOnly = false } = {}) {
1565
1616
  const prompt = classifyPrompt(raw);
1566
1617
  if (prompt.kind === "empty") return;
1567
1618
  if (prompt.kind === "business") return searchBusiness(prompt.value);
1568
1619
  clearBusinessResults();
1620
+ state.brand = null; state.brandOffer = null; renderBrand();
1569
1621
  if (prompt.kind === "url") {
1570
1622
  // On your own machine, or signed in to a public Studio, a website is explored for real — it
1571
1623
  // can stop at a sign-in and ask you. A visitor only ever reads.
@@ -1595,6 +1647,8 @@ async function startFromPrompt(raw, { readOnly = false } = {}) {
1595
1647
  setHeading("Website audit", "Read-only. Nothing on the page is clicked.", { owned: true });
1596
1648
  const result = await runOperation("audit", { url: prompt.value }, { input: prompt.value });
1597
1649
  state.selectedRunId = result?.capture?.id || state.selectedRunId;
1650
+ // The website is one surface; the brand has more (ADR-0013).
1651
+ state.brandOffer = prompt.value; renderBrand();
1598
1652
  return;
1599
1653
  }
1600
1654
  if (["bundle", "app", "apk"].includes(prompt.kind)) {
@@ -1624,6 +1678,10 @@ async function auditWebsite(url) {
1624
1678
  }
1625
1679
 
1626
1680
  document.addEventListener("click", (event) => {
1681
+ const brandSite = event.target.closest("[data-brand-site]");
1682
+ if (brandSite) { mapBrand(brandSite.dataset.brandSite).catch((error) => toast(error.message, true)); return; }
1683
+ const brandAudit = event.target.closest("[data-brand-audit]");
1684
+ if (brandAudit) { startFromPrompt(brandAudit.dataset.brandAudit, { readOnly: true }).catch((error) => toast(error.message, true)); return; }
1627
1685
  const site = event.target.closest("[data-business-site]");
1628
1686
  if (site) {
1629
1687
  $("#prompt-input").value = site.dataset.businessSite;
@@ -1845,6 +1903,14 @@ function handoffTarget() {
1845
1903
 
1846
1904
  try {
1847
1905
  try { setChatCollapsed(localStorage.getItem("tapp:chat-collapsed") === "1"); } catch { /* storage may be unavailable */ }
1906
+ if (state.connection) {
1907
+ // Say what is happening before the machine answers: a blank page while Chrome asks for
1908
+ // permission reads as broken.
1909
+ showPrompt();
1910
+ $("#onboarding-mode-pill").textContent = "Connecting · your machine";
1911
+ const note = $("#connecting-note");
1912
+ if (note) { note.textContent = `Connecting to your machine at ${state.connection.origin}… If Chrome asks whether this site may access devices on your local network, allow it — that is your own machine.`; note.classList.remove("hidden"); }
1913
+ }
1848
1914
  await refreshSession();
1849
1915
  await refresh();
1850
1916
  if (state.project?.connected && !state.project?.state?.inspected) await runOperation("initialize", { write:true });
@@ -63,6 +63,9 @@
63
63
  <ol class="setup-steps" id="setup-steps"><li class="empty">Checking this machine…</li></ol>
64
64
  </section>
65
65
  <section class="prompt-block">
66
+ <!-- The hosted page reaching the runtime on this person's machine (ADR-0011 §4): said while
67
+ it happens, because Chrome may be asking for permission and a blank page says nothing. -->
68
+ <p class="prompt-note connecting-note hidden" id="connecting-note"></p>
66
69
  <h1>What should tapp test?</h1>
67
70
  <form class="prompt-form" id="prompt-form" autocomplete="off">
68
71
  <label class="prompt-field"><span class="sr-only">Website, repository, folder, or build</span><input id="prompt-input" name="input" placeholder="A website URL, a GitHub repo, a folder on this Mac, a bundle id, an .app or .apk…" spellcheck="false" required></label>
@@ -182,6 +185,12 @@
182
185
  </aside>
183
186
  </section>
184
187
 
188
+ <!-- A brand's surfaces (ADR-0013): the website, its listings, channels and handles, each
189
+ with what a visitor could see of it. -->
190
+ <section class="panel section hidden" id="brand-panel">
191
+ <div class="section-heading compact"><div><p class="eyebrow">Brand</p><h2 id="brand-title">Surfaces</h2><p id="brand-sub"></p></div><div class="button-row" id="brand-actions"></div></div>
192
+ <div id="brand-list"></div>
193
+ </section>
185
194
  <section class="panel section" id="target-stage" data-repo-only>
186
195
  <div class="section-heading"><div><p class="eyebrow">Build & run</p><h2>Choose the product target</h2><p>Tapp detected these targets from source. With more than one, you choose; nothing builds until you do.</p></div><span class="status-chip" id="target-status">No target selected</span></div>
187
196
  <div class="target-choice-callout hidden" id="target-choice-callout"><span>1</span><div><strong>Choose what Tapp should test</strong><small>Nothing will build until you select a target. Tapp never guesses when a repository contains multiple applications.</small></div></div>
@@ -6,9 +6,8 @@ export const customerProductContract = Object.freeze({
6
6
  schemaVersion: 2,
7
7
  product: "Tapp",
8
8
  interface: "customer-browser",
9
- // What tapp has a driver for. Windows desktop applications are shown in the Studio's
10
- // Platforms view as having no driver yet — declared honestly, never counted here, because
11
- // this list is what the engine can actually drive (ADR-0010).
9
+ // What tapp has a driver for — this list is what the engine can actually drive (ADR-0010).
10
+ // Windows desktop is not a target (owner decision, 2026-11-25).
12
11
  targetPlatforms: ["ios", "android", "web", "macos"],
13
12
  // A repository is opened by path (`tapp app /path/to/repo`); a website by URL in the Studio.
14
13
  repositorySources: ["local-path", "github"],
@@ -70,6 +70,8 @@ export function narrate(entry = {}, { platform = "" } = {}) {
70
70
  if (entry.phase === "agent-tool") return { kind: "step", icon: "🛠️", text };
71
71
  if (entry.phase === "agent-warning") return { kind: "warning", icon: "⚠️", text };
72
72
  if (entry.phase === "agent-done") return { kind: "agent", icon: "✅", text };
73
+ // Mapping a brand's surfaces (ADR-0013): each line is one surface and what was seen of it.
74
+ if (entry.phase === "brand") return { kind: "step", icon: "🧭", text };
73
75
  const progress = text.match(/^(\d+)\/(\d+) actions(?: · (\d+) (?:states?|pages?|screens?)[^·]*)?/i);
74
76
  if (progress) return { kind: "progress", icon: "⏳", text, current: Number(progress[1]), total: Number(progress[2]), states: progress[3] ? Number(progress[3]) : null };
75
77
  for (const [pattern, icon] of RULES) {
@@ -105,6 +107,16 @@ export function summarize(name, result = {}, { access = "" } = {}) {
105
107
  const noticedText = noticed ? ` It also found ${noticed} thing${noticed === 1 ? "" : "s"} a person would notice — faint text, controls too small to tap on a phone, copy nobody finished — listed under “Worth a look”.` : "";
106
108
  return { tone: issues ? "caution" : noticed ? "caution" : "ready", pill, text: `${result.pagesAudited || 0} page(s) rendered read-only — nothing was clicked. ${issues ? "Each issue is listed in the run detail with the pages it appears on." : "Nothing is broken."}${noticedText}${next}` };
107
109
  }
110
+ // A brand map: how many surfaces, how many could be seen, how many could not — with the
111
+ // reasons in the rows. Never "all good" about a page that was not shown.
112
+ if (name === "brand") {
113
+ const counts = result?.counts || {};
114
+ const total = (result?.surfaces || []).length + 1;
115
+ const unseen = (counts["not-checked"] || 0) + (counts.unreachable || 0);
116
+ const pill = `${counts.ok || 0} of ${total} seen${counts.warning ? ` · ${counts.warning} missing` : ""}`;
117
+ const text = `${result?.name || "This brand"}: ${(result?.surfaces || []).length} surface${(result?.surfaces || []).length === 1 ? "" : "s"} found from the website.${unseen ? ` ${unseen} could not be checked — each row says why; tapp never signs in to a social account.` : ""}`;
118
+ return { tone: counts.warning ? "caution" : "neutral", pill, text };
119
+ }
108
120
  // A chat turn with the agent: what it said last, and how many turns it took. Never a verdict.
109
121
  if (name === "agent") {
110
122
  const turns = Number(result?.turns) || 0;
@@ -35,7 +35,7 @@ looping animation of a device being driven (launch, tap, tap, screenshot, ✓).
35
35
  | `owner/repo`, `github.com/owner/repo` | Cloned with `gh` into an isolated workspace under `TAPP_HOME`, then the same. |
36
36
  | `com.company.app` | Explored on the booted iOS simulator as it is (no build). |
37
37
  | `/path/to/Demo.app`, `~/Downloads/app.apk` | Installed on the booted simulator / connected device, then explored. |
38
- | a business name | Searches Apple's US App Store. Choose a matching publisher's website to start a run, or supply a URL directly. The App Store link opens the listing. |
38
+ | a business name | Apple's catalog is searched for the publisher; each match offers **Map** (its website's surfaces — stores, channels, handles — ADR-0013) and **Audit** (the website, read-only). The App Store link opens the listing. |
39
39
 
40
40
  The server classifies the input again (`classifyPrompt` in `browser/view-model.js` is shared) and
41
41
  refuses what the mode cannot do: a hosted Studio cannot open a path or a build on your machine.
@@ -120,6 +120,30 @@ owner (`TAPP_ADMIN_EMAILS`) is never gated and marks an account paid or extends
120
120
  Admin view (`POST /api/admin/plan`). There is no payment step yet: "paid" is the owner's word.
121
121
  Nothing a local Studio does needs an account.
122
122
 
123
+ **A brand map (ADR-0013).** `POST /api/operations/brand {url}` — allowed to a visitor like the
124
+ audit — reads the website's homepage (pinned to public addresses on a hosted Studio, `publicGet`;
125
+ plain on the person's own machine), takes every surface it claims (`rel="me"`, schema.org
126
+ `sameAs`, then links; explicit claims first, once each: App Store and Google Play listings,
127
+ YouTube, X, TikTok, Instagram, Facebook, Threads, LinkedIn, Google Business), and checks each
128
+ the way it allows (`mcp-server/src/surfaces.js`): Apple's public catalog, Google Play's and
129
+ YouTube's public pages, whatever a visitor is shown elsewhere; `not-checked` with the reason when
130
+ a platform shows the page only to signed-in users (X, without even asking). Four statuses, each
131
+ with a sentence: `ok`, `warning`, `not-checked`, `unreachable`. The Overview shows the **Brand**
132
+ panel — one row per surface with its status, note and link, *Audit the website read-only* and
133
+ *Map again* — and the chat narrates each surface as it is checked; after a URL audit the panel
134
+ offers to map the rest of the brand. An owner's map is kept under `TAPP_HOME/brands/`; a
135
+ visitor's is not. tapp never signs in to a social account.
136
+
137
+ Each kind of surface has one small adapter (`SURFACE_CHECKERS` in `surfaces.js`), and what an
138
+ adapter can see is set by the platform: YouTube has an official, free, read-only API for public
139
+ data, so with `TAPP_YOUTUBE_API_KEY` set (a Google Cloud API key with the YouTube Data API v3
140
+ enabled; `/etc/tapp-demo.env` on the hosted Studio) a channel is read through it — title,
141
+ subscribers unless hidden, video count, last upload, whether the description links back — and
142
+ through the public page otherwise, which YouTube often does not show to a visitor. The key goes
143
+ to Google and nowhere else; it is scrubbed from any sentence an error could carry. Meta's API
144
+ needs the business's own login and an app review, X's is paid, TikTok's is research-only: those
145
+ rows stay "not checked" with the reason until there is an honest way.
146
+
123
147
  **Driven from app.runtapp.com (ADR-0011 §2/§4, join B).** `tapp app --connect` starts the runtime
124
148
  on this machine and opens the hosted page with `#connect=<loopback origin>&token=<launch secret>`
125
149
  — a fragment, so the hosted server never sees it. The page keeps the pair in this browser only
@@ -130,7 +154,13 @@ answers CORS for exactly that origin (`Access-Control-Allow-Origin`, the preflig
130
154
  `Access-Control-Allow-Private-Network: true` for Chrome's local-network check), accepts the
131
155
  bearer or the query token as the operator, still requires the CSRF token on mutations, and tells
132
156
  every other origin nothing. The hosted page's CSP allows `http://127.0.0.1:*` and
133
- `http://localhost:*` for `connect-src`, `img-src` and `media-src`; a local Studio's does not. The
157
+ `http://localhost:*` for `connect-src`, `img-src` and `media-src`; a local Studio's does not.
158
+ **Chrome asks once.** Verified on the live site (Chrome 157/158, 2026-11-24): the page's first
159
+ call to the machine waits on Chrome's permission prompt — `navigator.permissions.query({ name:
160
+ "local-network-access" })` reads `prompt` until the person allows it, `granted` after, per site
161
+ — so the page says it is connecting and that the prompt is about their own machine, waits up to
162
+ 25 s, and otherwise offers the runtime's own address. The runtime answers both
163
+ `Access-Control-Allow-Local-Network` (Chrome ≥ 138's name) and `Access-Control-Allow-Private-Network`. The
134
164
  header shows *Connected · your machine* with Disconnect, which forgets the pair. A runtime that
135
165
  stops answering is said on the first screen, the pair is dropped, and the page carries on as a
136
166
  visitor. A browser that refuses loopback from an https page (some do) is sent to the runtime's
@@ -25,6 +25,8 @@ import { oauthProviders, oauthAuthorizeUrl, oauthEmailFromCode, isOauthProvider
25
25
  import { journeyFromCapture, JourneyStore, slugify } from "./journeys.js";
26
26
  import { AlertStore, alertForChange, alertMessage, deliverAlert } from "./alerts.js";
27
27
  import { ENGINES, detectEngines, claudeArguments, agentLines, runClaude, tappMcpConfig } from "./engines.js";
28
+ import { mapBrand, fetchPublicPage } from "./surfaces.js";
29
+ import { publicGet } from "./public-network.js";
28
30
  import { platformStates, selfHostAnswer, PLATFORM_TARGETS, hostToolchain } from "./platforms.js";
29
31
  import { isMacosAppBundle } from "./macos-driver.js";
30
32
  import { discoverApps } from "./app-store-discovery.js";
@@ -184,7 +186,9 @@ function anonymousAllows(method, pathname) {
184
186
  // Saying "I would use this for Android" is the one piece of demand a stranger can give us,
185
187
  // and the reason to ask is strongest exactly when the answer was "not from here".
186
188
  if (method === "POST" && pathname === "/api/platforms/interest") return true;
187
- return method === "POST" && ["/api/operations/audit", "/api/operations/open", "/api/operations/explore-build", "/api/operations/explore"].includes(pathname);
189
+ // A brand map is read-only on public pages, like the audit, and is what a name or a website
190
+ // typed on the first screen becomes (ADR-0013).
191
+ return method === "POST" && ["/api/operations/audit", "/api/operations/brand", "/api/operations/open", "/api/operations/explore-build", "/api/operations/explore"].includes(pathname);
188
192
  }
189
193
 
190
194
  // A signed-in account may do what a visitor may, plus: start a real exploration (which can stop
@@ -508,7 +512,6 @@ function setupTargets(report, platform = process.platform) {
508
512
  { id: "macos", label: "macOS app", items: mac ? [
509
513
  item(p.macos?.accessibility, p.macos?.accessibility ? "Accessibility permission granted" : "Accessibility permission not granted", "System Settings → Privacy & Security → Accessibility: allow the app that runs tapp (your terminal, or Node)."),
510
514
  ] : [item(false, "macOS apps run on a Mac", "A Mac runs macOS apps; this machine cannot.")] },
511
- { id: "windows", label: "Windows app", items: [item(false, "No Windows driver yet", "It is being built; early Windows runs are set up with us — hello@runtapp.com.")] },
512
515
  ];
513
516
  // A target is ready when nothing on its list is missing — web counts as ready because the one
514
517
  // thing it needs arrives by itself.
@@ -742,7 +745,7 @@ function serveLoginPage(response, { failed = false, next = "" } = {}) {
742
745
  response.end(html);
743
746
  }
744
747
 
745
- export async function startBrowserProduct({ projectDir, port = 0, launch = false, workspaceRoot, githubProvider, publicOrigin = "", trustedProxyToken = "", directLogin = null, publicEgressOnly = null, publicAccess = false, accessVerifier = undefined, oauthExchange = null, doctor = null, apiKeyVerifier = null, connectOrigin = "" } = {}) {
748
+ export async function startBrowserProduct({ projectDir, port = 0, launch = false, workspaceRoot, githubProvider, publicOrigin = "", trustedProxyToken = "", directLogin = null, publicEgressOnly = null, publicAccess = false, accessVerifier = undefined, oauthExchange = null, doctor = null, apiKeyVerifier = null, connectOrigin = "", surfaceFetch = null } = {}) {
746
749
  const hosted = !!trustedProxyToken || !!directLogin || !!publicAccess;
747
750
  // publicOrigin accepts a comma-separated allowlist; the first entry is canonical.
748
751
  const publicOrigins = String(publicOrigin || "").split(",").map((value) => value.trim().replace(/\/$/, "")).filter(Boolean);
@@ -986,7 +989,9 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
986
989
  }
987
990
  if (request.method === "OPTIONS") {
988
991
  if (connectedCaller) {
989
- response.writeHead(204, { "access-control-allow-methods": "GET,POST,DELETE,OPTIONS", "access-control-allow-headers": "authorization,content-type,x-tapp-csrf", "access-control-allow-private-network": "true", "access-control-max-age": "600" });
992
+ // Chrome asked this as "private network" until 2025 and asks it as "local network"
993
+ // since; both answers are given, so either generation lets the page through.
994
+ response.writeHead(204, { "access-control-allow-methods": "GET,POST,DELETE,OPTIONS", "access-control-allow-headers": "authorization,content-type,x-tapp-csrf", "access-control-allow-private-network": "true", "access-control-allow-local-network": "true", "access-control-max-age": "600" });
990
995
  } else response.writeHead(204);
991
996
  response.end();
992
997
  return;
@@ -2039,6 +2044,41 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
2039
2044
  json(response, 202, { job: publicJob(job, { hosted }) });
2040
2045
  return;
2041
2046
  }
2047
+ // A brand map (ADR-0013): the website's surfaces — stores, channels, handles — found from
2048
+ // its homepage and each checked the way it allows, read-only, never signed in. For a
2049
+ // visitor on the hosted Studio every fetch is pinned to a public address, as the audit's
2050
+ // browser is; on the person's own machine it reads what that machine can reach.
2051
+ if (operation === "brand") {
2052
+ let site;
2053
+ try { site = new URL(String(body.url || "")); } catch { throw Object.assign(new Error("A brand map starts from a website: give its http(s) URL"), { statusCode: 400 }); }
2054
+ if (!/^https?:$/.test(site.protocol)) throw Object.assign(new Error("A brand map starts from a website: give its http(s) URL"), { statusCode: 400 });
2055
+ const fetchPage = surfaceFetch || (enforcePublicEgress ? publicGet : fetchPublicPage);
2056
+ const brandHost = site.hostname.replace(/^www\./, "");
2057
+ logUsage("brand.start", { visitor: (visitorId || "operator").slice(0, 8), host: safeHost(site.href) });
2058
+ const job = startJob(operation, async (progress) => {
2059
+ progress({ phase: "brand", text: `Reading ${brandHost} — nothing will be clicked.` });
2060
+ let home;
2061
+ try { home = await fetchPage(site.href); } catch (error) { throw new Error(`Could not read ${brandHost}: ${error.message}`); }
2062
+ if (home.status < 200 || home.status >= 400) throw new Error(`${brandHost} answered ${home.status}.`);
2063
+ // YouTube through its official API when this deployment has a key (TAPP_YOUTUBE_API_KEY);
2064
+ // through the public page otherwise, which YouTube often does not show to a visitor.
2065
+ const brand = await mapBrand({ baseUrl: home.url || site.href, html: home.text, fetchPage, youtubeKey: String(process.env.TAPP_YOUTUBE_API_KEY || "").trim(), onProgress: (text) => progress({ phase: "brand", text }) });
2066
+ const counts = { ok: 0, warning: 0, "not-checked": 0, unreachable: 0 };
2067
+ for (const surface of [brand.website, ...brand.surfaces]) counts[surface.check.status] = (counts[surface.check.status] || 0) + 1;
2068
+ // A visitor's map is theirs for the page; an owner's is kept to come back to.
2069
+ if (!anonymous) {
2070
+ const owner = ownerKey ? ownerKey.replace(/[^A-Za-z0-9]/g, "_") : "operator";
2071
+ const file = path.join(process.env.TAPP_HOME || path.join(os.homedir(), ".tapp"), "brands", owner, `${slugify(brandHost)}.json`);
2072
+ fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
2073
+ fs.writeFileSync(file, JSON.stringify({ ...brand, url: site.href }), { mode: 0o600 });
2074
+ }
2075
+ logUsage("brand.mapped", { visitor: (visitorId || "operator").slice(0, 8), host: safeHost(site.href), surfaces: brand.surfaces.length, ...counts });
2076
+ return { kind: "brand", url: site.href, counts, ...brand };
2077
+ }, null, { lane: ownerKey || OPERATOR_LANE });
2078
+ job.ownerKey = ownerKey;
2079
+ json(response, 202, { job: publicJob(job, { hosted }) });
2080
+ return;
2081
+ }
2042
2082
  if (operation === "audit") {
2043
2083
  let target;
2044
2084
  try { target = new URL(String(body.url || "")); } catch { throw Object.assign(new Error("Audit needs a valid http(s) URL"), { statusCode: 400 }); }
@@ -24,8 +24,9 @@ import { macAccessibilityTrusted } from "./macos-driver.js";
24
24
  * ready — this Studio can start a run now.
25
25
  * needs-machine — tapp drives it, but not from this host. There is an exact command for the
26
26
  * machine that can, because self-hosting is the same product, not a lesser one.
27
- * pilot — tapp does NOT drive it yet. No driver exists. Early work is done with a
28
- * person while the driver lands (owner decision, 2026-09-14, for Windows).
27
+ * pilot — tapp does NOT drive it. No driver exists. Kept as a state for the next
28
+ * surface declared before its driver; no target uses it since Windows was
29
+ * dropped (owner decision, 2026-11-25: "windows is done").
29
30
  */
30
31
  export const PLATFORM_STATES = Object.freeze(["ready", "needs-machine", "pilot"]);
31
32
 
@@ -51,11 +52,6 @@ export const PLATFORM_TARGETS = Object.freeze([
51
52
  driver: "accessibility", needs: "macOS, and the Accessibility permission",
52
53
  machine: "a Mac",
53
54
  },
54
- {
55
- id: "windows", label: "Windows app", subject: "Windows apps", give: "A WPF, WinForms or WinUI app",
56
- driver: null, needs: "Windows",
57
- machine: "a Windows machine",
58
- },
59
55
  ]);
60
56
 
61
57
  // "A simulator .app" mid-sentence, without lowercasing the file extension or the brand.
@@ -34,6 +34,43 @@ export async function publicRequest(url, {method="POST",headers={},body,timeout=
34
34
  });
35
35
  }
36
36
 
37
+ /**
38
+ * A read-only GET the hosted Studio may make on a visitor's behalf (a brand's surfaces, ADR-0013):
39
+ * every hop resolves to a public address and connects to that address — a name that answers
40
+ * public first and private on the real connection gets nowhere. Follows a few redirects, each
41
+ * resolved again; reads at most half a megabyte; never sends credentials.
42
+ */
43
+ export async function publicGet(url, { timeout = 10_000, maxBytes = 512 * 1024, redirects = 3, headers = {} } = {}) {
44
+ let target = new URL(url);
45
+ for (let hop = 0; ; hop += 1) {
46
+ if (!/^https?:$/.test(target.protocol) || target.username || target.password) throw new Error("A public http(s) address is required");
47
+ if (target.port && target.port !== (target.protocol === "https:" ? "443" : "80")) throw new Error("Only the standard port is reachable from the hosted Studio");
48
+ const address = await resolvePublicHost(target.hostname);
49
+ const transport = target.protocol === "https:" ? https : http;
50
+ const answer = await new Promise((resolve, reject) => {
51
+ const req = transport.request(target, {
52
+ method: "GET", family: 4,
53
+ headers: { "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0 Safari/537.36 tapp/1", accept: "text/html,application/json;q=0.9,*/*;q=0.8", "accept-language": "en-US,en;q=0.8", ...headers },
54
+ lookup: (_host, options, callback) => options.all ? callback(null, [{ address, family: 4 }]) : callback(null, address, 4),
55
+ }, (response) => {
56
+ let size = 0; const chunks = [];
57
+ response.on("data", (chunk) => { if (size >= maxBytes) return; size += chunk.length; chunks.push(chunk); if (size >= maxBytes) response.destroy(); });
58
+ response.on("error", reject);
59
+ response.on("end", () => resolve({ status: response.statusCode, headers: response.headers, text: Buffer.concat(chunks).toString("utf8") }));
60
+ response.on("close", () => resolve({ status: response.statusCode, headers: response.headers, text: Buffer.concat(chunks).toString("utf8") }));
61
+ });
62
+ req.on("error", reject);
63
+ req.setTimeout(timeout, () => req.destroy(new Error("The page did not answer in time")));
64
+ req.end();
65
+ });
66
+ if ([301, 302, 303, 307, 308].includes(answer.status) && answer.headers.location && hop < redirects) {
67
+ target = new URL(answer.headers.location, target);
68
+ continue;
69
+ }
70
+ return { status: answer.status, url: target.href, text: answer.text };
71
+ }
72
+ }
73
+
37
74
  // Resolve and pin every TCP connection, including redirects and subresources.
38
75
  // This proxy is for URL-only work; it deliberately cannot reach local dev servers.
39
76
  export async function startPublicBrowserProxy() {
@@ -0,0 +1,293 @@
1
+ // Surfaces, not platforms (ADR-0013).
2
+ //
3
+ // A business has surfaces: a website, an app in two stores, a YouTube channel, an X profile, a
4
+ // TikTok, a Google Business listing. A "platform" is only how tapp reaches one of them. This
5
+ // module finds a brand's surfaces from its website — footer links, `rel="me"`, schema.org
6
+ // `sameAs` — and checks each one the way that surface allows: a store listing through its
7
+ // public catalog, a channel page by reading it, a profile that is only shown to signed-in users
8
+ // by saying so. tapp never signs in to a social account: acting on a brand's social presence by
9
+ // automation is against every one of those platforms' terms and gets the brand banned, which is
10
+ // the opposite of help. Read-only, public, and "could not check — here is why" everywhere else.
11
+ import { readFileSync } from "node:fs";
12
+
13
+ /** What a surface is, how it is shown, and the honest limit of what tapp can see of it. */
14
+ export const SURFACE_KINDS = Object.freeze({
15
+ website: { label: "Website", icon: "🌐" },
16
+ "app-store": { label: "App Store", icon: "🍎" },
17
+ "play-store": { label: "Google Play", icon: "🤖" },
18
+ youtube: { label: "YouTube", icon: "▶️" },
19
+ x: { label: "X", icon: "✕" },
20
+ tiktok: { label: "TikTok", icon: "🎵" },
21
+ instagram: { label: "Instagram", icon: "📷" },
22
+ facebook: { label: "Facebook", icon: "📘" },
23
+ threads: { label: "Threads", icon: "🧵" },
24
+ linkedin: { label: "LinkedIn", icon: "💼" },
25
+ "google-business": { label: "Google Business", icon: "📍" },
26
+ });
27
+
28
+ const RESERVED = {
29
+ x: /^(?:i|intent|share|home|explore|search|login|signup|settings|hashtag|about|privacy|tos|download)$/i,
30
+ instagram: /^(?:p|reel|reels|explore|accounts|stories|direct|about|legal|privacy|developer)$/i,
31
+ facebook: /^(?:sharer|share\.php|dialog|login|plugins|privacy|policies|help|groups|events|marketplace|watch|gaming|pages)$/i,
32
+ tiktok: /^(?:tag|discover|upload|login|about|legal|foryou|following|explore)$/i,
33
+ threads: /^(?:login|search|explore|about)$/i,
34
+ };
35
+
36
+ /**
37
+ * Which surface a link points at, by host and path shape, with the handle it names. Returns
38
+ * null for anything that is not a surface (a share link, a login page, an unrelated site).
39
+ */
40
+ export function classifySurface(raw, { baseUrl = "" } = {}) {
41
+ let url;
42
+ try { url = new URL(String(raw || "").trim(), baseUrl || undefined); } catch { return null; }
43
+ if (!/^https?:$/.test(url.protocol)) return null;
44
+ const host = url.hostname.toLowerCase().replace(/^www\./, "").replace(/^m\./, "").replace(/^mobile\./, "");
45
+ const parts = url.pathname.split("/").filter(Boolean).map((p) => { try { return decodeURIComponent(p); } catch { return p; } });
46
+ const first = parts[0] || "";
47
+ const clean = (kind, handle, canonical) => ({ kind, handle, url: canonical, label: SURFACE_KINDS[kind].label });
48
+
49
+ if (host === "youtube.com" || host === "youtu.be") {
50
+ if (/^@[\w.-]{2,}$/.test(first)) return clean("youtube", first, `https://www.youtube.com/${first}`);
51
+ if (["channel", "c", "user"].includes(first) && parts[1]) return clean("youtube", parts[1], `https://www.youtube.com/${first}/${parts[1]}`);
52
+ return null;
53
+ }
54
+ if (host === "x.com" || host === "twitter.com") {
55
+ if (!first || parts.length > 1 || RESERVED.x.test(first) || !/^[A-Za-z0-9_]{1,15}$/.test(first)) return null;
56
+ return clean("x", `@${first}`, `https://x.com/${first}`);
57
+ }
58
+ if (host === "tiktok.com") {
59
+ if (/^@[\w.-]{2,}$/.test(first) && !RESERVED.tiktok.test(first.slice(1))) return clean("tiktok", first, `https://www.tiktok.com/${first}`);
60
+ return null;
61
+ }
62
+ if (host === "instagram.com") {
63
+ if (!first || parts.length > 1 || RESERVED.instagram.test(first) || !/^[\w.]{1,30}$/.test(first)) return null;
64
+ return clean("instagram", `@${first}`, `https://www.instagram.com/${first}/`);
65
+ }
66
+ if (host === "facebook.com" || host === "fb.com") {
67
+ if (!first || RESERVED.facebook.test(first)) return null;
68
+ if (first === "profile.php") return null;
69
+ return clean("facebook", first, `https://www.facebook.com/${first}`);
70
+ }
71
+ if (host === "threads.net" || host === "threads.com") {
72
+ if (/^@[\w.]{1,30}$/.test(first) && !RESERVED.threads.test(first.slice(1))) return clean("threads", first, `https://www.threads.net/${first}`);
73
+ return null;
74
+ }
75
+ if (host === "linkedin.com") {
76
+ if (["company", "in", "school", "showcase"].includes(first) && parts[1]) return clean("linkedin", parts[1], `https://www.linkedin.com/${first}/${parts[1]}/`);
77
+ return null;
78
+ }
79
+ if (host === "apps.apple.com" || host === "itunes.apple.com") {
80
+ const id = url.pathname.match(/\/id(\d{6,})/)?.[1];
81
+ return id ? { ...clean("app-store", `id${id}`, `https://apps.apple.com/app/id${id}`), appId: id } : null;
82
+ }
83
+ if (host === "play.google.com") {
84
+ const id = url.searchParams.get("id");
85
+ return id && /^[\w.]+$/.test(id) ? { ...clean("play-store", id, `https://play.google.com/store/apps/details?id=${id}`), appId: id } : null;
86
+ }
87
+ if (host === "g.page" || host === "maps.app.goo.gl" || (host === "google.com" && /^\/maps\/place\//.test(url.pathname))) {
88
+ return clean("google-business", first || url.pathname, url.href);
89
+ }
90
+ return null;
91
+ }
92
+
93
+ const decode = (text) => String(text || "").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&#39;|&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&nbsp;/g, " ").trim();
94
+
95
+ /** The page's own name for itself: og:site_name, then <title>, then the host. */
96
+ export function pageTitle(html, { host = "" } = {}) {
97
+ const site = html.match(/<meta[^>]+property=["']og:site_name["'][^>]+content=["']([^"']+)["']/i)?.[1] || html.match(/<meta[^>]+content=["']([^"']+)["'][^>]+property=["']og:site_name["']/i)?.[1];
98
+ if (site) return decode(site).slice(0, 80);
99
+ const title = html.match(/<title[^>]*>([\s\S]*?)<\/title>/i)?.[1];
100
+ if (title) return decode(title.replace(/\s+/g, " ")).split(/\s[|–—-]\s/)[0].slice(0, 80);
101
+ return host;
102
+ }
103
+
104
+ function ogContent(html, property) {
105
+ return decode(html.match(new RegExp(`<meta[^>]+property=["']${property}["'][^>]+content=["']([^"']*)["']`, "i"))?.[1]
106
+ || html.match(new RegExp(`<meta[^>]+content=["']([^"']*)["'][^>]+property=["']${property}["']`, "i"))?.[1] || "");
107
+ }
108
+
109
+ /**
110
+ * Every surface a website points at: anchors, `rel="me"` links, and schema.org `sameAs`. One
111
+ * entry per surface, the first mention's source kept, in a stable order. Pure: HTML in, list out.
112
+ */
113
+ export function discoverSurfaces({ baseUrl, html }) {
114
+ const origin = new URL(baseUrl).origin;
115
+ const found = new Map();
116
+ const add = (href, source) => {
117
+ const surface = classifySurface(href, { baseUrl });
118
+ if (!surface) return;
119
+ const key = `${surface.kind}:${surface.handle.toLowerCase()}`;
120
+ if (!found.has(key)) found.set(key, { ...surface, source });
121
+ };
122
+ // The site's explicit claims first — rel="me" and schema.org sameAs say "this is us" — then
123
+ // whatever the page merely links to, so the recorded source is the strongest one.
124
+ for (const match of String(html).matchAll(/<link\b[^>]*rel=["'][^"']*\bme\b[^"']*["'][^>]*href=["']([^"']+)["']/gi)) add(match[1], "rel-me");
125
+ for (const match of String(html).matchAll(/<script[^>]+type=["']application\/ld\+json["'][^>]*>([\s\S]*?)<\/script>/gi)) {
126
+ let data;
127
+ try { data = JSON.parse(match[1]); } catch { continue; }
128
+ const walk = (node) => {
129
+ if (Array.isArray(node)) { node.forEach(walk); return; }
130
+ if (!node || typeof node !== "object") return;
131
+ const same = node.sameAs;
132
+ for (const href of Array.isArray(same) ? same : same ? [same] : []) if (typeof href === "string") add(href, "sameAs");
133
+ for (const value of Object.values(node)) if (value && typeof value === "object") walk(value);
134
+ };
135
+ walk(data);
136
+ }
137
+ for (const match of String(html).matchAll(/<a\b[^>]*href=["']([^"'#]+)["']/gi)) add(match[1], "link");
138
+ const order = Object.keys(SURFACE_KINDS);
139
+ const surfaces = [...found.values()].sort((a, b) => order.indexOf(a.kind) - order.indexOf(b.kind) || a.handle.localeCompare(b.handle));
140
+ return { website: { kind: "website", label: "Website", url: origin, handle: new URL(origin).host, title: pageTitle(html, { host: new URL(origin).host }), source: "prompt" }, surfaces };
141
+ }
142
+
143
+ /** A read-only GET that looks like a browser, never follows into a login, and caps what it reads. */
144
+ export async function fetchPublicPage(url, { timeoutMs = 10_000, maxBytes = 512 * 1024 } = {}) {
145
+ const response = await fetch(url, {
146
+ redirect: "follow",
147
+ signal: AbortSignal.timeout(timeoutMs),
148
+ headers: { "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0 Safari/537.36 tapp/1", accept: "text/html,application/json;q=0.9,*/*;q=0.8", "accept-language": "en-US,en;q=0.8" },
149
+ });
150
+ const reader = response.body?.getReader();
151
+ const chunks = [];
152
+ let size = 0;
153
+ if (reader) {
154
+ for (;;) {
155
+ const { done, value } = await reader.read();
156
+ if (done) break;
157
+ size += value.length;
158
+ chunks.push(value);
159
+ if (size >= maxBytes) { try { await reader.cancel(); } catch { /* enough */ } break; }
160
+ }
161
+ }
162
+ return { status: response.status, url: response.url, text: Buffer.concat(chunks).toString("utf8") };
163
+ }
164
+
165
+ const NO_SIGN_IN = "tapp does not sign in to social accounts: doing that by automation is against the platform's terms and gets a brand banned.";
166
+
167
+ // One small adapter per kind of surface. Each sees exactly what that platform lets a visitor —
168
+ // or an official, read-only API — see, and says so. Adding a surface is adding an entry here.
169
+ const result = (status, note, extra = {}) => ({ status, note, checkedAt: new Date().toISOString(), ...extra });
170
+ const linksBack = (text, siteHost) => !!siteHost && String(text || "").toLowerCase().includes(siteHost.toLowerCase());
171
+ const compact = (n) => { const value = Number(n); if (!Number.isFinite(value)) return ""; return value >= 1e6 ? `${(value / 1e6).toFixed(1).replace(/\.0$/, "")}M` : value >= 1e3 ? `${(value / 1e3).toFixed(1).replace(/\.0$/, "")}K` : String(value); };
172
+
173
+ // YouTube through its Data API (official, read-only, free for public data) when tapp has a key;
174
+ // otherwise through the public channel page, which YouTube often does not show to a visitor.
175
+ async function youtubeByApi(surface, { fetchPage, siteHost, youtubeKey }) {
176
+ const handle = surface.handle.startsWith("@") ? surface.handle.slice(1) : "";
177
+ const id = /^UC[\w-]{20,}$/.test(surface.handle) ? surface.handle : "";
178
+ const selector = handle ? `forHandle=${encodeURIComponent(handle)}` : id ? `id=${encodeURIComponent(id)}` : `forUsername=${encodeURIComponent(surface.handle)}`;
179
+ const hide = (text) => String(text || "").split(youtubeKey).join("…");
180
+ const api = async (pathAndQuery) => {
181
+ const page = await fetchPage(`https://www.googleapis.com/youtube/v3/${pathAndQuery}&key=${encodeURIComponent(youtubeKey)}`);
182
+ let data = null;
183
+ try { data = JSON.parse(page.text); } catch { /* not JSON */ }
184
+ if (page.status !== 200 || !data) throw new Error(hide(data?.error?.message || `YouTube's API answered ${page.status}`));
185
+ return data;
186
+ };
187
+ const channels = await api(`channels?part=snippet,statistics,contentDetails&${selector}`);
188
+ const channel = channels.items?.[0];
189
+ if (!channel) return result("warning", "No channel for that handle in YouTube's catalog.");
190
+ const stats = channel.statistics || {};
191
+ const parts = [`Channel: ${channel.snippet?.title || surface.handle}`];
192
+ if (!stats.hiddenSubscriberCount && stats.subscriberCount) parts.push(`${compact(stats.subscriberCount)} subscribers`);
193
+ if (stats.videoCount) parts.push(`${compact(stats.videoCount)} videos`);
194
+ const uploads = channel.contentDetails?.relatedPlaylists?.uploads;
195
+ if (uploads) {
196
+ try {
197
+ const latest = (await api(`playlistItems?part=snippet&maxResults=1&playlistId=${encodeURIComponent(uploads)}`)).items?.[0]?.snippet?.publishedAt;
198
+ if (latest) parts.push(`last upload ${String(latest).slice(0, 10)}`);
199
+ } catch { /* the channel is still real; the upload date is extra */ }
200
+ }
201
+ if (linksBack(channel.snippet?.description, siteHost)) parts.push("links back to the site");
202
+ return result("ok", parts.join(" · "), { title: channel.snippet?.title || "", via: "youtube-data-api" });
203
+ }
204
+
205
+ async function youtubeByPage(surface, { fetchPage, siteHost }) {
206
+ const page = await fetchPage(surface.url);
207
+ if (page.status === 404) return result("warning", "No channel at that address.");
208
+ if (page.status !== 200) return result("not-checked", `YouTube answered ${page.status}.`);
209
+ const title = ogContent(page.text, "og:title");
210
+ if (!title) return result("not-checked", "YouTube did not show the channel page to a visitor.");
211
+ return result("ok", `Channel: ${title}${linksBack(page.text, siteHost) ? " · links back to the site" : ""}`, { title });
212
+ }
213
+
214
+ async function visitorPage(surface, { fetchPage, siteHost }) {
215
+ const page = await fetchPage(surface.url);
216
+ const title = ogContent(page.text, "og:title");
217
+ if (page.status === 404) return result("warning", `${surface.label} has no page at that address.`);
218
+ if (page.status === 200 && title && !/log ?in|sign ?up/i.test(title)) return result("ok", `Found: ${title}${linksBack(page.text, siteHost) ? " · links back to the site" : ""}`, { title });
219
+ return result("not-checked", `${surface.label} did not show the page to a visitor${page.status !== 200 ? ` (answered ${page.status})` : ""}. ${NO_SIGN_IN}`);
220
+ }
221
+
222
+ export const SURFACE_CHECKERS = Object.freeze({
223
+ website: async (surface, { fetchPage }) => {
224
+ const page = await fetchPage(surface.url);
225
+ if (page.status >= 200 && page.status < 400) return result("ok", `Reachable: ${pageTitle(page.text, { host: surface.handle })}`);
226
+ return result("unreachable", `Answered ${page.status}.`);
227
+ },
228
+ "app-store": async (surface, { fetchPage, siteHost }) => {
229
+ const page = await fetchPage(`https://itunes.apple.com/lookup?id=${encodeURIComponent(surface.appId)}&country=us`);
230
+ let data = null;
231
+ try { data = JSON.parse(page.text); } catch { /* not JSON */ }
232
+ const app = data?.results?.[0];
233
+ if (!app) return result("warning", "No listing with that id in Apple's catalog.");
234
+ const when = app.currentVersionReleaseDate ? ` · last updated ${String(app.currentVersionReleaseDate).slice(0, 10)}` : "";
235
+ const rating = app.averageUserRating ? ` · ${Number(app.averageUserRating).toFixed(1)}★ (${app.userRatingCount || 0})` : "";
236
+ return result("ok", `${app.trackName} by ${app.sellerName || "?"}${rating}${when}${linksBack(app.sellerUrl, siteHost) ? " · links back to the site" : ""}`, { title: app.trackName });
237
+ },
238
+ "play-store": async (surface, { fetchPage, siteHost }) => {
239
+ const page = await fetchPage(surface.url);
240
+ if (page.status === 404) return result("warning", "No listing with that id on Google Play.");
241
+ if (page.status !== 200) return result("not-checked", `Google Play answered ${page.status}.`);
242
+ const title = ogContent(page.text, "og:title") || pageTitle(page.text);
243
+ return result("ok", `${title}${linksBack(page.text, siteHost) ? " · links back to the site" : ""}`, { title });
244
+ },
245
+ youtube: async (surface, options) => {
246
+ if (options.youtubeKey) {
247
+ try { return await youtubeByApi(surface, options); }
248
+ catch (error) { const fallback = await youtubeByPage(surface, options); return { ...fallback, note: `${fallback.note} (YouTube's API: ${error.message})` }; }
249
+ }
250
+ return youtubeByPage(surface, options);
251
+ },
252
+ x: async () => result("not-checked", `X shows profiles only to signed-in users. ${NO_SIGN_IN}`),
253
+ "google-business": async () => result("not-checked", "Google Business listings are not checked yet."),
254
+ tiktok: visitorPage, instagram: visitorPage, facebook: visitorPage, threads: visitorPage, linkedin: visitorPage,
255
+ });
256
+
257
+ /**
258
+ * Check one surface the way it allows. Never more than a GET; never a sign-in. Each answer says
259
+ * what was seen or exactly why nothing could be.
260
+ */
261
+ export async function checkSurface(surface, { fetchPage = fetchPublicPage, siteHost = "", youtubeKey = "" } = {}) {
262
+ const checker = SURFACE_CHECKERS[surface.kind];
263
+ if (!checker) return result("not-checked", "tapp does not know how to check this kind of surface yet.");
264
+ try { return await checker(surface, { fetchPage, siteHost, youtubeKey }); }
265
+ catch (error) { return result("unreachable", `Could not reach it: ${youtubeKey ? String(error.message).split(youtubeKey).join("…") : error.message}`); }
266
+ }
267
+
268
+ /** Find a brand's surfaces from its website and check each, a few at a time. */
269
+ export async function mapBrand({ baseUrl, html, fetchPage = fetchPublicPage, concurrency = 4, onProgress = () => {}, youtubeKey = "" }) {
270
+ const { website, surfaces } = discoverSurfaces({ baseUrl, html });
271
+ const siteHost = new URL(website.url).host.replace(/^www\./, "");
272
+ const all = [website, ...surfaces];
273
+ onProgress(`Found ${surfaces.length} surface${surfaces.length === 1 ? "" : "s"} linked from ${siteHost}.`);
274
+ const checked = new Array(all.length);
275
+ let next = 0;
276
+ const worker = async () => {
277
+ for (;;) {
278
+ const index = next++;
279
+ if (index >= all.length) return;
280
+ const surface = all[index];
281
+ const check = await checkSurface(surface, { fetchPage, siteHost, youtubeKey });
282
+ checked[index] = { ...surface, check };
283
+ onProgress(`${surface.label}${surface.handle && surface.kind !== "website" ? ` ${surface.handle}` : ""}: ${check.note}`);
284
+ }
285
+ };
286
+ await Promise.all(Array.from({ length: Math.min(concurrency, all.length) }, worker));
287
+ return { name: website.title, website: checked[0], surfaces: checked.slice(1), mappedAt: new Date().toISOString() };
288
+ }
289
+
290
+ /** For tests and the CLI: a brand map from a saved HTML file, without the network. */
291
+ export function discoverFromFile(file, baseUrl) {
292
+ return discoverSurfaces({ baseUrl, html: readFileSync(file, "utf8") });
293
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.35.9",
3
+ "version": "0.35.11",
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",
@@ -98,7 +98,7 @@
98
98
  "mobile"
99
99
  ],
100
100
  "scripts": {
101
- "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/flow-variables.test.js tests/flow-recording.test.js tests/sim-recorder.test.js tests/feedback.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-overlay.test.js tests/web-audit.test.js tests/page-observations.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/actor-store.test.js tests/account-store.test.js tests/alerts.test.js tests/access-jwt.test.js tests/oauth.test.js tests/studio-client.test.js tests/engines.test.js tests/journeys.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/sign-in.test.js tests/signin-honesty.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/evidence-retention.test.js tests/android-flow.test.js tests/macos-driver.test.js tests/macos-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/job-lanes.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-run-reading.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/platforms.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",
101
+ "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/flow-variables.test.js tests/flow-recording.test.js tests/sim-recorder.test.js tests/feedback.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-overlay.test.js tests/web-audit.test.js tests/page-observations.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/actor-store.test.js tests/account-store.test.js tests/alerts.test.js tests/access-jwt.test.js tests/oauth.test.js tests/studio-client.test.js tests/engines.test.js tests/surfaces.test.js tests/journeys.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/sign-in.test.js tests/signin-honesty.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/evidence-retention.test.js tests/android-flow.test.js tests/macos-driver.test.js tests/macos-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/job-lanes.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-run-reading.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/platforms.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",
102
102
  "test:browser-journey": "node --test tests/browser-journey.test.js",
103
103
  "test:browser-native": "TAPP_RUN_NATIVE_BROWSER=1 node --test tests/browser-native-journey.test.js"
104
104
  }