@aarwitz/tapp 0.20.2 → 0.21.1
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.
|
|
4
|
+
"version": "0.21.1",
|
|
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.
|
|
27
|
+
"@aarwitz/tapp@0.21.1",
|
|
28
28
|
"mcp"
|
|
29
29
|
],
|
|
30
30
|
"cwd": "${CLAUDE_PROJECT_DIR}"
|
|
@@ -817,7 +817,10 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
817
817
|
let target;
|
|
818
818
|
try { target = new URL(String(body.url || "")); } catch { throw Object.assign(new Error("Audit needs a valid http(s) URL"), { statusCode: 400 }); }
|
|
819
819
|
if (!/^https?:$/.test(target.protocol)) throw Object.assign(new Error("Audit needs a valid http(s) URL"), { statusCode: 400 });
|
|
820
|
-
|
|
820
|
+
// Six was a quiet default with nothing in the UI to change it, so every site a visitor
|
|
821
|
+
// pointed the Studio at came back as a six-page site — including ones with a dozen
|
|
822
|
+
// sections, a login and a booking flow. A read-only page costs a couple of seconds.
|
|
823
|
+
const pages = Math.max(1, Math.min(20, Number(body.pages) || 12));
|
|
821
824
|
// Mint the capture id here so the evidence can be stamped as this visitor's before the
|
|
822
825
|
// run writes anything; a capture that appeared first and was claimed afterwards would be
|
|
823
826
|
// briefly readable by everyone.
|
|
@@ -389,6 +389,71 @@ export function webStateSignature(info) {
|
|
|
389
389
|
return `${h1.toString(36)}${h2.toString(36)}`.slice(0, 12);
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
+
// What a dismissal looks like, in the order we would rather press it.
|
|
393
|
+
//
|
|
394
|
+
// Consent first, and declining: a crawler must not grant permissions or accept tracking on
|
|
395
|
+
// someone's behalf, so "reject" beats "accept" and "Allow Device Location" is never a candidate
|
|
396
|
+
// however prominent it is. Then the ordinary ways out of an intake modal. A bare "no" or "close"
|
|
397
|
+
// is last because it is the most likely to mean something else on a page.
|
|
398
|
+
const OVERLAY_DISMISSALS = [
|
|
399
|
+
/^(reject|decline)( all| cookies| non-essential)?$/i,
|
|
400
|
+
/^(necessary|essential) (cookies )?only$/i,
|
|
401
|
+
/^(manage |cookie )?(preferences|settings)$/i,
|
|
402
|
+
/^(not now|no thanks?|maybe later|later|skip|skip for now)$/i,
|
|
403
|
+
/^(dismiss|close|got it|ok|okay|continue without|don't ask again)$/i,
|
|
404
|
+
/^(×|✕|✖|x)$/i,
|
|
405
|
+
];
|
|
406
|
+
// Never press these to get past an overlay: each one grants something on the person's behalf.
|
|
407
|
+
const OVERLAY_NEVER = /allow|accept|enable|agree|subscribe|sign ?up|turn on|share (my )?location|grant/i;
|
|
408
|
+
|
|
409
|
+
export function chooseOverlayDismissal(labels = []) {
|
|
410
|
+
const cleaned = labels.map((label) => String(label || "").replace(/\s+/g, " ").trim()).filter(Boolean);
|
|
411
|
+
for (const pattern of OVERLAY_DISMISSALS) {
|
|
412
|
+
const match = cleaned.find((label) => pattern.test(label) && !OVERLAY_NEVER.test(label));
|
|
413
|
+
if (match) return match;
|
|
414
|
+
}
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Clear whatever is covering the page, by pressing its own way out.
|
|
420
|
+
*
|
|
421
|
+
* Cookie banners and intake modals sit in front of a large share of real sites, and a crawler
|
|
422
|
+
* that cannot get past them never sees the application at all — on one real site this left every
|
|
423
|
+
* control on the home page unreachable and the coach search, sign-in and booking flows entirely
|
|
424
|
+
* undiscovered. Escape closes a well-built dialog and nothing else, so find the dismissal the
|
|
425
|
+
* overlay itself offers.
|
|
426
|
+
*/
|
|
427
|
+
export async function dismissBlockingOverlay(page) {
|
|
428
|
+
const choice = await page.evaluate(() => {
|
|
429
|
+
const covering = [...document.querySelectorAll("div,section,aside,dialog")].filter((element) => {
|
|
430
|
+
const style = window.getComputedStyle(element);
|
|
431
|
+
if (style.position !== "fixed" && style.position !== "sticky") return false;
|
|
432
|
+
if (style.display === "none" || style.visibility === "hidden") return false;
|
|
433
|
+
const rect = element.getBoundingClientRect();
|
|
434
|
+
return rect.width > window.innerWidth * 0.4 && rect.height > window.innerHeight * 0.2;
|
|
435
|
+
});
|
|
436
|
+
if (!covering.length) return null;
|
|
437
|
+
const topmost = covering.sort((a, b) => (Number(window.getComputedStyle(b).zIndex) || 0) - (Number(window.getComputedStyle(a).zIndex) || 0))[0];
|
|
438
|
+
return [...topmost.querySelectorAll("button,a,[role=button]")]
|
|
439
|
+
.map((element) => (element.innerText || element.getAttribute("aria-label") || "").replace(/\s+/g, " ").trim())
|
|
440
|
+
.filter(Boolean)
|
|
441
|
+
.slice(0, 20);
|
|
442
|
+
}, undefined, { timeout: 2_000 }).catch(() => null);
|
|
443
|
+
if (!choice || !choice.length) return null;
|
|
444
|
+
const label = chooseOverlayDismissal(choice);
|
|
445
|
+
if (!label) return null;
|
|
446
|
+
try {
|
|
447
|
+
await page.getByRole("button", { name: label, exact: true }).first().click({ timeout: 2500 });
|
|
448
|
+
return label;
|
|
449
|
+
} catch {
|
|
450
|
+
try {
|
|
451
|
+
await page.getByText(label, { exact: true }).first().click({ timeout: 2000 });
|
|
452
|
+
return label;
|
|
453
|
+
} catch { return null; }
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
392
457
|
export function webScreenTitle(info, fallback) {
|
|
393
458
|
return String(info?.heading || info?.title || fallback || "").trim();
|
|
394
459
|
}
|
|
@@ -1067,6 +1132,14 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
|
|
|
1067
1132
|
}
|
|
1068
1133
|
if (watch) await showWebWatchAction(page, { action: "Open", target });
|
|
1069
1134
|
await waitForWebStability(page);
|
|
1135
|
+
// Clear whatever greets a first visit before looking at the page, rather than discovering
|
|
1136
|
+
// it control by control. A cookie banner or intake modal covering the viewport otherwise
|
|
1137
|
+
// makes every control on the page unreachable and the application behind it invisible.
|
|
1138
|
+
const greeting = await dismissBlockingOverlay(page).catch(() => null);
|
|
1139
|
+
if (greeting) {
|
|
1140
|
+
narrate(`Dismissed an overlay with "${greeting}"`, { screen: target });
|
|
1141
|
+
await waitForWebStability(page);
|
|
1142
|
+
}
|
|
1070
1143
|
if (nav && typeof nav.status === "function" && nav.status() === 404) {
|
|
1071
1144
|
issue("broken_link", "medium", `Broken link: ${target} → 404`, target);
|
|
1072
1145
|
}
|
|
@@ -1163,18 +1236,32 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
|
|
|
1163
1236
|
const buttons = page.locator("button:visible, [role=button]:visible, input[type=submit]:visible, summary:visible");
|
|
1164
1237
|
const buttonTotal = await buttons.count().catch(() => 0);
|
|
1165
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;
|
|
1166
1241
|
const n = Math.min(buttonTotal, buttonsPerPage);
|
|
1167
1242
|
if (buttonTotal > buttonsPerPage) probeCapHit = true;
|
|
1168
1243
|
for (let i = 0; i < n && actions < maxActions && Date.now() < deadline; i++) {
|
|
1169
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 };
|
|
1170
1251
|
const label = webControlLabel({
|
|
1171
|
-
text: await b.textContent().catch(() => ""),
|
|
1172
|
-
value: await b.getAttribute("value").catch(() => ""),
|
|
1173
|
-
ariaLabel: await b.getAttribute("aria-label").catch(() => ""),
|
|
1174
|
-
title: await b.getAttribute("title").catch(() => ""),
|
|
1175
|
-
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(() => ""),
|
|
1176
1257
|
}).slice(0, 40);
|
|
1177
1258
|
if (/log ?out|sign ?out|delete|remove/i.test(label)) continue; // don't destroy test state
|
|
1259
|
+
// Nor consent on anyone's behalf. Probing clicks every button it can reach, which on a
|
|
1260
|
+
// real site means pressing "Allow Device Location", "Accept all cookies" or "Subscribe"
|
|
1261
|
+
// — granting a permission, accepting tracking, or signing someone up, none of which an
|
|
1262
|
+
// observation should do. Dismissals ("Not now", "Reject all") stay clickable, so an
|
|
1263
|
+
// overlay can still be got past; see chooseOverlayDismissal.
|
|
1264
|
+
if (OVERLAY_NEVER.test(label)) continue;
|
|
1178
1265
|
// Capture only durable, user-visible semantics around this control. A global
|
|
1179
1266
|
// MutationObserver is intentionally avoided: carousels, chat launchers, and live
|
|
1180
1267
|
// counters can mutate while an unrelated dead button is clicked, creating verdict jitter.
|
|
@@ -1190,26 +1277,38 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
|
|
|
1190
1277
|
} catch {}
|
|
1191
1278
|
if (!clickSucceeded) {
|
|
1192
1279
|
// Something is covering this control — almost always a modal, drawer or cookie banner
|
|
1193
|
-
// opened by a button probed moments ago. Every remaining control on the page used to
|
|
1194
|
-
//
|
|
1195
|
-
//
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
await page.
|
|
1205
|
-
await waitForWebStability(page);
|
|
1206
|
-
//
|
|
1207
|
-
//
|
|
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.
|
|
1208
1295
|
beforeState = await captureWebControlState(page, b);
|
|
1209
1296
|
try {
|
|
1210
|
-
await b.click({ timeout:
|
|
1297
|
+
await b.click({ timeout: 2_000 });
|
|
1211
1298
|
clickSucceeded = true;
|
|
1212
|
-
} 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
|
+
}
|
|
1213
1312
|
}
|
|
1214
1313
|
}
|
|
1215
1314
|
if (!clickSucceeded) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aarwitz/tapp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
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",
|