@aarwitz/tapp 0.21.0 → 0.21.2

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.21.0",
4
+ "version": "0.21.2",
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.21.0",
27
+ "@aarwitz/tapp@0.21.2",
28
28
  "mcp"
29
29
  ],
30
30
  "cwd": "${CLAUDE_PROJECT_DIR}"
@@ -559,15 +559,27 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
559
559
  if (publicAccess && !authenticated) {
560
560
  anonymous = true;
561
561
  visitorId = String(cookies(request)[VISITOR_COOKIE] || "");
562
- if (!/^[a-f0-9]{32}$/.test(visitorId)) {
562
+ const returning = /^[a-f0-9]{32}$/.test(visitorId);
563
+ if (!returning) {
563
564
  visitorId = crypto.randomBytes(16).toString("hex");
564
565
  response.setHeader("set-cookie", `${VISITOR_COOKIE}=${visitorId}; HttpOnly; SameSite=Lax; Secure; Path=/; Max-Age=2592000`);
565
- usage.visitors.add(visitorId.slice(0, 8));
566
+ }
567
+ const permitted = anonymousAllows(request.method, url.pathname);
568
+ // Count someone as a visitor only when they ask for something the Studio actually
569
+ // offers. A public host is scanned constantly — in one afternoon this recorded 404
570
+ // "new visitors", 383 of which were bots probing for .env files, which is a reading
571
+ // that answers "is anyone using this?" with noise.
572
+ if (!returning && permitted) {
573
+ if (usage.visitors.size < 50_000) usage.visitors.add(visitorId.slice(0, 8));
566
574
  logUsage("visitor.new", { visitor: visitorId.slice(0, 8), distinctVisitors: usage.visitors.size });
567
575
  }
568
- if (!anonymousAllows(request.method, url.pathname)) {
576
+ if (!permitted) {
569
577
  usage.refusals += 1;
570
- logUsage("refused", { visitor: visitorId.slice(0, 8), reason: "not-public", method: request.method, path: url.pathname, status: 401 });
578
+ // Scanners are the overwhelming majority of refusals and say nothing about the
579
+ // product; count them, and keep one line per path rather than one per request.
580
+ const scanning = /\.(env|git|aws|ssh)|wp-|phpunit|vendor\/|\.ya?ml$|\.ini$|credentials/i.test(url.pathname);
581
+ if (!scanning) logUsage("refused", { visitor: visitorId.slice(0, 8), reason: "not-public", method: request.method, path: url.pathname, status: 401 });
582
+ else if (usage.refusals % 100 === 0) logUsage("scanned", { refusalsSoFar: usage.refusals, note: "automated probes for secrets; all refused" });
571
583
  json(response, 401, { error: "Sign in to use this. A public visitor can audit a website read-only; repositories, live sessions and the release gate need an account." });
572
584
  return;
573
585
  }
@@ -817,7 +829,10 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
817
829
  let target;
818
830
  try { target = new URL(String(body.url || "")); } catch { throw Object.assign(new Error("Audit needs a valid http(s) URL"), { statusCode: 400 }); }
819
831
  if (!/^https?:$/.test(target.protocol)) throw Object.assign(new Error("Audit needs a valid http(s) URL"), { statusCode: 400 });
820
- const pages = Math.max(1, Math.min(20, Number(body.pages) || 6));
832
+ // Six was a quiet default with nothing in the UI to change it, so every site a visitor
833
+ // pointed the Studio at came back as a six-page site — including ones with a dozen
834
+ // sections, a login and a booking flow. A read-only page costs a couple of seconds.
835
+ const pages = Math.max(1, Math.min(20, Number(body.pages) || 12));
821
836
  // Mint the capture id here so the evidence can be stamped as this visitor's before the
822
837
  // run writes anything; a capture that appeared first and was claimed afterwards would be
823
838
  // briefly readable by everyone.
@@ -439,7 +439,7 @@ export async function dismissBlockingOverlay(page) {
439
439
  .map((element) => (element.innerText || element.getAttribute("aria-label") || "").replace(/\s+/g, " ").trim())
440
440
  .filter(Boolean)
441
441
  .slice(0, 20);
442
- }).catch(() => null);
442
+ }, undefined, { timeout: 2_000 }).catch(() => null);
443
443
  if (!choice || !choice.length) return null;
444
444
  const label = chooseOverlayDismissal(choice);
445
445
  if (!label) return null;
@@ -1236,16 +1236,24 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1236
1236
  const buttons = page.locator("button:visible, [role=button]:visible, input[type=submit]:visible, summary:visible");
1237
1237
  const buttonTotal = await buttons.count().catch(() => 0);
1238
1238
  const buttonsPerPage = webButtonsPerPage(maxActions);
1239
+ // Reset per page: a blocker that defeats recovery here says nothing about the next route.
1240
+ let pageRecoveryHopeless = false;
1239
1241
  const n = Math.min(buttonTotal, buttonsPerPage);
1240
1242
  if (buttonTotal > buttonsPerPage) probeCapHit = true;
1241
1243
  for (let i = 0; i < n && actions < maxActions && Date.now() < deadline; i++) {
1242
1244
  const b = buttons.nth(i);
1245
+ // Reading a label is metadata, not navigation, but every locator call inherits the
1246
+ // page's 15s default — so five reads on one unstable element cost seventy-five seconds,
1247
+ // which is how three controls consumed three hundred and forty seconds of a run. If an
1248
+ // attribute cannot be read in a second the element is not in a state worth waiting for,
1249
+ // and an empty label is the honest answer.
1250
+ const READ = { timeout: 1_000 };
1243
1251
  const label = webControlLabel({
1244
- text: await b.textContent().catch(() => ""),
1245
- value: await b.getAttribute("value").catch(() => ""),
1246
- ariaLabel: await b.getAttribute("aria-label").catch(() => ""),
1247
- title: await b.getAttribute("title").catch(() => ""),
1248
- id: await b.getAttribute("id").catch(() => ""),
1252
+ text: await b.textContent(READ).catch(() => ""),
1253
+ value: await b.getAttribute("value", READ).catch(() => ""),
1254
+ ariaLabel: await b.getAttribute("aria-label", READ).catch(() => ""),
1255
+ title: await b.getAttribute("title", READ).catch(() => ""),
1256
+ id: await b.getAttribute("id", READ).catch(() => ""),
1249
1257
  }).slice(0, 40);
1250
1258
  if (/log ?out|sign ?out|delete|remove/i.test(label)) continue; // don't destroy test state
1251
1259
  // Nor consent on anyone's behalf. Probing clicks every button it can reach, which on a
@@ -1269,31 +1277,38 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1269
1277
  } catch {}
1270
1278
  if (!clickSucceeded) {
1271
1279
  // Something is covering this control — almost always a modal, drawer or cookie banner
1272
- // opened by a button probed moments ago. Every remaining control on the page used to
1273
- // be clicked into that overlay and silently skipped, so a page with a modal reported
1274
- // no dead controls at all however many it had. Clear the overlay and try once more.
1275
- const dismissed = await dismissBlockingOverlay(page).catch(() => null);
1276
- if (dismissed) narrate(`Dismissed an overlay with "${dismissed}"`, { screen: ob.screen });
1277
- else await page.keyboard.press("Escape").catch(() => {});
1278
- await waitForWebStability(page);
1279
- // Clearing the obstruction is itself a change to the page, so anything compared against
1280
- // the snapshot taken before it would look as though this control had done something.
1281
- beforeState = await captureWebControlState(page, b);
1282
- try {
1283
- await b.click({ timeout: 2000 });
1284
- clickSucceeded = true;
1285
- } catch {
1286
- // Escape did not dismiss it. Reloading is the reliable reset, and the BFS frontier
1287
- // is keyed by route rather than by page object, so it stays valid.
1288
- await page.goto(beforeState.url, { waitUntil: "domcontentloaded" }).catch(() => {});
1289
- await waitForWebStability(page);
1290
- // The reload is itself a change, so the pre-reload snapshot would make any control
1291
- // look like it did something. Judge this click against the page as it is now.
1280
+ // opened by a button probed moments ago. Every remaining control on the page used to be
1281
+ // clicked into that overlay and silently skipped, so a page with a modal reported no
1282
+ // dead controls at all however many it had.
1283
+ //
1284
+ // Recovery is bounded, and gives up for the whole page rather than per control. An
1285
+ // overlay that survived a dismissal and a reload will survive the next control too, and
1286
+ // paying the reload again for each one is how a single stubborn page turned three
1287
+ // clicks into three hundred and forty seconds.
1288
+ if (!pageRecoveryHopeless) {
1289
+ const dismissed = await dismissBlockingOverlay(page).catch(() => null);
1290
+ if (dismissed) narrate(`Dismissed an overlay with "${dismissed}"`, { screen: ob.screen });
1291
+ else await page.keyboard.press("Escape").catch(() => {});
1292
+ await waitForWebStability(page, { timeoutMs: 2_000 });
1293
+ // Clearing the obstruction is itself a change, so anything compared against the
1294
+ // snapshot taken before it would look as though this control had done something.
1292
1295
  beforeState = await captureWebControlState(page, b);
1293
1296
  try {
1294
- await b.click({ timeout: 2000 });
1297
+ await b.click({ timeout: 2_000 });
1295
1298
  clickSucceeded = true;
1296
- } catch {}
1299
+ } catch {
1300
+ // One reload per page, with a short navigation deadline: the default is thirty
1301
+ // seconds, which is most of a run to spend on one unreachable button.
1302
+ await page.goto(beforeState.url, { waitUntil: "domcontentloaded", timeout: 5_000 }).catch(() => {});
1303
+ await waitForWebStability(page, { timeoutMs: 2_000 });
1304
+ beforeState = await captureWebControlState(page, b);
1305
+ try {
1306
+ await b.click({ timeout: 2_000 });
1307
+ clickSucceeded = true;
1308
+ } catch {
1309
+ pageRecoveryHopeless = true;
1310
+ }
1311
+ }
1297
1312
  }
1298
1313
  }
1299
1314
  if (!clickSucceeded) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
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",