@aarwitz/tapp 0.19.1 → 0.19.3
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.19.
|
|
4
|
+
"version": "0.19.3",
|
|
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.19.
|
|
27
|
+
"@aarwitz/tapp@0.19.3",
|
|
28
28
|
"mcp"
|
|
29
29
|
],
|
|
30
30
|
"cwd": "${CLAUDE_PROJECT_DIR}"
|
|
@@ -451,6 +451,46 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
451
451
|
const sessionToken = crypto.randomBytes(32).toString("base64url");
|
|
452
452
|
const csrfToken = crypto.randomBytes(24).toString("base64url");
|
|
453
453
|
const jobs = new Map();
|
|
454
|
+
// A public Studio serves strangers, and until now it recorded nothing about that — the journal
|
|
455
|
+
// held only startup lines, so "is anyone using this?" had no answer at all. These lines go to
|
|
456
|
+
// stdout, which systemd already captures, so there is no new storage to run:
|
|
457
|
+
//
|
|
458
|
+
// journalctl -u tapp-demo | grep tapp-usage
|
|
459
|
+
//
|
|
460
|
+
// Deliberately not collected: no IP address (Cloudflare fronts this and we do not need it), no
|
|
461
|
+
// full URL (a query string can carry a token or an email), and only the first eight characters
|
|
462
|
+
// of the visitor id — enough to tell two visitors apart in a day's log, not enough to be a
|
|
463
|
+
// durable handle for one. Off unless the Studio is public; a local Studio logging its owner's
|
|
464
|
+
// own use is noise.
|
|
465
|
+
const usage = { visitors: new Set(), audits: 0, refusals: 0, startedAt: new Date().toISOString() };
|
|
466
|
+
const logUsage = (event, fields = {}) => {
|
|
467
|
+
if (!publicAccess) return;
|
|
468
|
+
try {
|
|
469
|
+
console.log(`tapp-usage ${JSON.stringify({ at: new Date().toISOString(), event, ...fields })}`);
|
|
470
|
+
} catch { /* logging must never break a run */ }
|
|
471
|
+
};
|
|
472
|
+
// Where a visitor pointed us, without what they may have put in the query string.
|
|
473
|
+
const safeHost = (value) => { try { return new URL(value).host; } catch { return "unparsed"; } };
|
|
474
|
+
// Engine errors quote the URL they failed on, query string and all — which is how a token or
|
|
475
|
+
// an email in someone's link ends up in a log that was supposed to hold neither. Keep the
|
|
476
|
+
// origin and path, drop everything after it.
|
|
477
|
+
const redactUrls = (text) => String(text).replace(/https?:\/\/[^\s"'<>]+/gi, (match) => {
|
|
478
|
+
try { const u = new URL(match); return `${u.origin}${u.pathname}${u.search || u.hash ? "?…" : ""}`; }
|
|
479
|
+
catch { return "[url]"; }
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
// Individual lines age out of the journal; a rollup means one grep still answers "did anyone
|
|
483
|
+
// use this last week?". unref'd so it never holds the process open, and cleared on close.
|
|
484
|
+
const usageHeartbeat = publicAccess
|
|
485
|
+
? setInterval(() => logUsage("rollup", {
|
|
486
|
+
sinceStart: usage.startedAt,
|
|
487
|
+
distinctVisitors: usage.visitors.size,
|
|
488
|
+
audits: usage.audits,
|
|
489
|
+
refusals: usage.refusals,
|
|
490
|
+
}), 60 * 60 * 1000)
|
|
491
|
+
: null;
|
|
492
|
+
if (usageHeartbeat?.unref) usageHeartbeat.unref();
|
|
493
|
+
|
|
454
494
|
// Work is serialized per lane rather than globally; see job-lanes.js for why.
|
|
455
495
|
const OPERATOR_LANE = "operator";
|
|
456
496
|
const lanes = new JobLanes({ operatorLane: OPERATOR_LANE });
|
|
@@ -477,6 +517,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
477
517
|
}).catch((error) => {
|
|
478
518
|
job.status = "failed";
|
|
479
519
|
job.error = { message: error.message || String(error), ...(error.details ? { details: error.details } : {}) };
|
|
520
|
+
logUsage("job.failed", { operation, lane: String(lane).slice(0, 8), message: redactUrls(error.message || error).slice(0, 200) });
|
|
480
521
|
}).finally(() => {
|
|
481
522
|
job.completedAt = new Date().toISOString();
|
|
482
523
|
lanes.release(lane, job);
|
|
@@ -521,13 +562,17 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
521
562
|
if (!/^[a-f0-9]{32}$/.test(visitorId)) {
|
|
522
563
|
visitorId = crypto.randomBytes(16).toString("hex");
|
|
523
564
|
response.setHeader("set-cookie", `${VISITOR_COOKIE}=${visitorId}; HttpOnly; SameSite=Lax; Secure; Path=/; Max-Age=2592000`);
|
|
565
|
+
usage.visitors.add(visitorId.slice(0, 8));
|
|
566
|
+
logUsage("visitor.new", { visitor: visitorId.slice(0, 8), distinctVisitors: usage.visitors.size });
|
|
524
567
|
}
|
|
525
568
|
if (!anonymousAllows(request.method, url.pathname)) {
|
|
569
|
+
usage.refusals += 1;
|
|
570
|
+
logUsage("refused", { visitor: visitorId.slice(0, 8), reason: "not-public", method: request.method, path: url.pathname, status: 401 });
|
|
526
571
|
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." });
|
|
527
572
|
return;
|
|
528
573
|
}
|
|
529
574
|
const limited = auditRateLimit(visitorId, request.method, url.pathname);
|
|
530
|
-
if (limited) { response.writeHead(429, { "content-type": "application/json; charset=utf-8", "retry-after": String(limited) }); response.end(JSON.stringify({ error: `Too many audits from here. Try again in ${Math.ceil(limited / 60)} minute(s).` })); return; }
|
|
575
|
+
if (limited) { usage.refusals += 1; logUsage("refused", { visitor: visitorId.slice(0, 8), reason: "rate-limit", retryAfterSec: limited, status: 429 }); response.writeHead(429, { "content-type": "application/json; charset=utf-8", "retry-after": String(limited) }); response.end(JSON.stringify({ error: `Too many audits from here. Try again in ${Math.ceil(limited / 60)} minute(s).` })); return; }
|
|
531
576
|
}
|
|
532
577
|
// The operator sees every capture; a visitor sees only captures stamped with their id.
|
|
533
578
|
const evidenceOwner = anonymous ? visitorId : null;
|
|
@@ -688,6 +733,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
688
733
|
if (liveSession?.active) throw Object.assign(new Error("End the active live session before opening another project"), { statusCode: 409 });
|
|
689
734
|
if (prompt.kind === "path") {
|
|
690
735
|
if (anonymous) {
|
|
736
|
+
logUsage("self-host.answered", { visitor: visitorId.slice(0, 8), kind: "path" });
|
|
691
737
|
json(response, 200, { kind: "self-host", target: prompt.value, command: `npx -y @aarwitz/tapp@latest app ${prompt.value}`,
|
|
692
738
|
message: `A folder on your machine is not visible from the cloud. Open it with the Studio there: npx -y @aarwitz/tapp@latest app ${prompt.value}` });
|
|
693
739
|
return;
|
|
@@ -701,6 +747,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
701
747
|
}
|
|
702
748
|
if (prompt.kind === "github") {
|
|
703
749
|
if (anonymous) {
|
|
750
|
+
logUsage("self-host.answered", { visitor: visitorId.slice(0, 8), kind: "github" });
|
|
704
751
|
json(response, 200, { kind: "self-host", target: prompt.value, command: "npx -y @aarwitz/tapp@latest app",
|
|
705
752
|
message: `Cloning and building ${prompt.value} needs a machine with your toolchain on it. Run the Studio there and paste the same thing: npx -y @aarwitz/tapp@latest app` });
|
|
706
753
|
return;
|
|
@@ -719,6 +766,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
719
766
|
if (operation === "explore-build") {
|
|
720
767
|
if (anonymous) {
|
|
721
768
|
const asked = classifyPrompt(body.input);
|
|
769
|
+
logUsage("self-host.answered", { visitor: visitorId.slice(0, 8), kind: asked.kind });
|
|
722
770
|
const where = asked.kind === "apk" ? "an Android device or emulator" : "a Mac with an iOS simulator";
|
|
723
771
|
json(response, 200, { kind: "self-host", target: asked.value, command: "npx -y @aarwitz/tapp@latest app",
|
|
724
772
|
message: `Running ${asked.value || "a build"} needs ${where}, which the cloud does not have. Start the Studio on that machine: npx -y @aarwitz/tapp@latest app` });
|
|
@@ -778,6 +826,9 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
778
826
|
try { fs.mkdirSync(path.join(captureRoot(), auditCapture), { recursive: true }); } catch { /* the run reports its own failure */ }
|
|
779
827
|
setCaptureOwner(auditCapture, visitorId);
|
|
780
828
|
}
|
|
829
|
+
const auditStartedMs = Date.now();
|
|
830
|
+
usage.audits += 1;
|
|
831
|
+
logUsage("audit.start", { visitor: (visitorId || "operator").slice(0, 8), host: safeHost(target.href), pages, totalAudits: usage.audits });
|
|
781
832
|
const job = startJob(operation, async (progress) => {
|
|
782
833
|
const { auditWebSite } = await import("./web-audit.js");
|
|
783
834
|
progress({ phase: "runtime", text: `Opening ${target.href} read-only (up to ${pages} pages, nothing will be clicked)` });
|
|
@@ -788,6 +839,12 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
788
839
|
// whole run while the real screenshots sit in the capture.
|
|
789
840
|
onPage: (page, n) => progress({ phase: "explore", text: `Audited ${page.url} — ${page.findings.length} finding(s)`, current: n, total: pages, ...(page.screenshot ? { screenshot: page.screenshot } : {}) }),
|
|
790
841
|
});
|
|
842
|
+
logUsage("audit.done", {
|
|
843
|
+
visitor: (visitorId || "operator").slice(0, 8), host: safeHost(target.href),
|
|
844
|
+
pagesAudited: summary?.pagesAudited ?? null,
|
|
845
|
+
findings: summary?.issueCount ?? (summary?.issues || []).length,
|
|
846
|
+
seconds: Math.round((Date.now() - auditStartedMs) / 100) / 10,
|
|
847
|
+
});
|
|
791
848
|
return hosted ? hostedPayload(summary) : summary;
|
|
792
849
|
}, null, { lane: visitorId || OPERATOR_LANE });
|
|
793
850
|
job.visitorId = visitorId;
|
|
@@ -931,6 +988,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
931
988
|
if (liveManagedRuntime) await engine.stopManagedWebTarget(liveManagedRuntime).catch(() => {});
|
|
932
989
|
}
|
|
933
990
|
await new Promise((resolve, reject) => server.close((error) => error ? reject(error) : resolve()));
|
|
991
|
+
if (usageHeartbeat) clearInterval(usageHeartbeat);
|
|
934
992
|
if (egressProxy) { await egressProxy.close().catch(() => {}); restoreEgressEnv(); }
|
|
935
993
|
registry.close();
|
|
936
994
|
},
|
|
@@ -1078,7 +1078,11 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
|
|
|
1078
1078
|
const u = new URL(link.href);
|
|
1079
1079
|
if (!/^https?:$/.test(u.protocol)) continue;
|
|
1080
1080
|
if (u.origin !== start.origin) {
|
|
1081
|
-
|
|
1081
|
+
// Keep the query: for a great many links the query *is* the resource
|
|
1082
|
+
// (`/items?itemName=…`, `/search?q=…`, store and marketplace pages), and checking
|
|
1083
|
+
// the path alone reports a confident 404 for a link that works. Only the fragment
|
|
1084
|
+
// is dropped, since it names a place within an already-fetched page.
|
|
1085
|
+
const clean = u.origin + u.pathname + u.search;
|
|
1082
1086
|
if (!outboundLinks.has(clean)) outboundLinks.set(clean, { label: link.label, screen: ob.screen, sourceUrl: start.origin + ob.key });
|
|
1083
1087
|
continue;
|
|
1084
1088
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aarwitz/tapp",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
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",
|