@aarwitz/tapp 0.24.0 → 0.24.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.24.
|
|
4
|
+
"version": "0.24.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.24.
|
|
27
|
+
"@aarwitz/tapp@0.24.1",
|
|
28
28
|
"mcp"
|
|
29
29
|
],
|
|
30
30
|
"cwd": "${CLAUDE_PROJECT_DIR}"
|
package/browser/app.js
CHANGED
|
@@ -369,7 +369,9 @@ function renderJourneys() {
|
|
|
369
369
|
const note = $("#journeys-note");
|
|
370
370
|
if (note) note.textContent = journeys.some((j) => j.source === "repo")
|
|
371
371
|
? "Committed under .tapp/flows/. Each replays exactly as written — no model, no key — and is what the release gate guards."
|
|
372
|
-
:
|
|
372
|
+
: state.session?.access === "account"
|
|
373
|
+
? "Each replays exactly as written — no model, no key. Keep one from any run that got somewhere. tapp re-runs every kept journey daily and shows the result here."
|
|
374
|
+
: "Each replays exactly as written — no model, no key. Keep one from any run that got somewhere; run it any time to prove it still works.";
|
|
373
375
|
if (!journeys.length) { node.innerHTML = '<div class="empty">No journeys yet. Explore a site — when a run gets somewhere, tapp offers to keep it.</div>'; return; }
|
|
374
376
|
const groups = new Map();
|
|
375
377
|
for (const journey of journeys) { const key = journey.group || ""; if (!groups.has(key)) groups.set(key, []); groups.get(key).push(journey); }
|
|
@@ -640,7 +642,7 @@ async function finishTranscript(name, job) {
|
|
|
640
642
|
if (items.length) pushLine({ kind: "attachments", items });
|
|
641
643
|
} catch { /* the summary still renders */ }
|
|
642
644
|
}
|
|
643
|
-
pushLine({ kind: "summary", ...summarize(name, result.exploration ? { ...result, report } : result) });
|
|
645
|
+
pushLine({ kind: "summary", ...summarize(name, result.exploration ? { ...result, report } : result, { access: state.session?.access || "" }) });
|
|
644
646
|
}
|
|
645
647
|
|
|
646
648
|
function seedIdleTranscript() {
|
package/browser/view-model.js
CHANGED
|
@@ -85,12 +85,15 @@ export function narrateFinding(finding = {}) {
|
|
|
85
85
|
|
|
86
86
|
// The summary card at the end of a run: the gate's outcome when there is one, otherwise what the
|
|
87
87
|
// engine's headline says it observed. Never a score.
|
|
88
|
-
export function summarize(name, result = {}) {
|
|
88
|
+
export function summarize(name, result = {}, { access = "" } = {}) {
|
|
89
89
|
const report = result?.report || result;
|
|
90
90
|
const gateOutcome = report?.gate?.outcome || (report?.gate?.failed === true ? "fail" : report?.gate ? "pass" : null);
|
|
91
91
|
if (name === "audit") {
|
|
92
92
|
const issues = result.issueCount || 0;
|
|
93
|
-
|
|
93
|
+
// A visitor only ever gets the read-only look; say what the next step is, because the
|
|
94
|
+
// interesting part of any real application is behind its sign-in.
|
|
95
|
+
const next = access === "anonymous" ? " Sign in and tapp will go inside — and ask you for a test account if it meets a sign-in." : "";
|
|
96
|
+
return { tone: issues ? "caution" : "ready", pill: issues ? `${issues} issue${issues === 1 ? "" : "s"} found` : "✓ Nothing broken observed", 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." : "This says the pages are served without structural defects, not that the site works."}${next}` };
|
|
94
97
|
}
|
|
95
98
|
if (gateOutcome) {
|
|
96
99
|
const tone = { pass: "ready", fail: "blocked", inconclusive: "caution" }[gateOutcome] || "caution";
|
|
@@ -259,6 +259,57 @@ function markPromptStarted(structured) {
|
|
|
259
259
|
} catch { /* listing is a convenience; the capture is the evidence */ }
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
+
// Replay one web journey and record how it went. Shared by the Studio's Run button and the
|
|
263
|
+
// daily check, so both leave the same status and the same evidence behind.
|
|
264
|
+
async function replayJourney({ store, slug, flow, actorRoot = "", ownerKey = null, progress = () => {} }) {
|
|
265
|
+
// A journey that signs in does so as the test account tapp was told about for that site: the
|
|
266
|
+
// values come from the encrypted actor store at replay and never from the file.
|
|
267
|
+
const variables = {};
|
|
268
|
+
let storageStatePath = "";
|
|
269
|
+
if (flow.url && (flow.actor || (flow.steps || []).some((step) => step && typeof step === "object" && "login" in step))) {
|
|
270
|
+
const actors = new ActorStore(actorRoot ? { root: actorRoot } : {});
|
|
271
|
+
const record = actors.read(flow.url, flow.actor || "default");
|
|
272
|
+
if (record?.credentials?.email) variables.TEST_EMAIL = record.credentials.email;
|
|
273
|
+
if (record?.credentials?.password) variables.TEST_PASSWORD = record.credentials.password;
|
|
274
|
+
// A journey that began inside replays from the actor's saved session, like the run did.
|
|
275
|
+
if (flow.actor) storageStatePath = actors.sessionFile(flow.url, flow.actor) || "";
|
|
276
|
+
}
|
|
277
|
+
const captureId = `flow-web-${Date.now().toString(36)}-${crypto.randomBytes(4).toString("hex")}`;
|
|
278
|
+
const evidenceDir = path.join(captureRoot(), captureId);
|
|
279
|
+
fs.mkdirSync(evidenceDir, { recursive: true });
|
|
280
|
+
if (ownerKey) setCaptureOwner(captureId, ownerKey);
|
|
281
|
+
progress({ phase: "runtime", text: `Replaying ${flow.name || slug}` });
|
|
282
|
+
const { runWebFlow } = await import("./web-flow.js");
|
|
283
|
+
let result;
|
|
284
|
+
try { result = await runWebFlow({ flow, variables, storageStatePath, logPath: path.join(evidenceDir, "flow.log"), screenshotDir: evidenceDir, recordVideoDir: evidenceDir }); }
|
|
285
|
+
finally { if (storageStatePath) { try { fs.rmSync(storageStatePath, { force: true }); } catch { /* temp */ } } }
|
|
286
|
+
// The runner's log is marker lines; the chat wants one plain sentence per step.
|
|
287
|
+
for (const line of result.lines || []) {
|
|
288
|
+
const raw = typeof line === "string" ? line : (line.text || "");
|
|
289
|
+
const step = raw.match(/^OCQA_FLOW_STEP:(\{.*\})$/);
|
|
290
|
+
if (step) {
|
|
291
|
+
try {
|
|
292
|
+
const st = JSON.parse(step[1]);
|
|
293
|
+
const what = st.action === "login" ? "Signed in" : st.action === "wait_for" ? `Reached ${st.target}` : st.action === "assert_screen" ? `On ${st.target}` : st.action === "tap" ? `Tapped "${st.target}"` : `${st.action} ${st.target || ""}`.trim();
|
|
294
|
+
progress({ phase: "replay", text: st.status === "pass" ? `${what}` : `Step ${st.index}: ${what} — ${st.detail || "failed"}` });
|
|
295
|
+
} catch { progress({ phase: "replay", text: raw }); }
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (/^OCQA_(FLOW_RESULT|ISSUE):/.test(raw)) continue;
|
|
299
|
+
if (raw) progress({ phase: "replay", text: raw });
|
|
300
|
+
}
|
|
301
|
+
const status = store.recordRun(slug, { passed: result.passed, captureId, executed: result.executed, total: result.total, failed: result.failed });
|
|
302
|
+
return { kind: "journey", name: flow.name || slug, slug, passed: result.passed, executed: result.executed, total: result.total, failed: result.failed, status, capture: { id: captureId, path: evidenceDir } };
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// "Make sure this always works": kept journeys on a public Studio are replayed on a schedule,
|
|
306
|
+
// each in its owner's lane so a check never queues ahead of the owner's own run. A journey is
|
|
307
|
+
// due when its last result is older than the interval (TAPP_JOURNEY_CHECK_HOURS, default 24);
|
|
308
|
+
// a restart therefore does not re-run everything, and a busy lane simply waits for the next tick.
|
|
309
|
+
export function dueJourneys(journeys, { intervalMs, now = Date.now() }) {
|
|
310
|
+
return journeys.filter((j) => (j.platform || "web") === "web" && (!j.status || now - Date.parse(j.status.at || 0) >= intervalMs));
|
|
311
|
+
}
|
|
312
|
+
|
|
262
313
|
function openBrowser(url) {
|
|
263
314
|
const invocation = process.platform === "darwin" ? ["open", [url]]
|
|
264
315
|
: process.platform === "win32" ? ["cmd", ["/c", "start", "", url]]
|
|
@@ -587,6 +638,37 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
587
638
|
return job;
|
|
588
639
|
};
|
|
589
640
|
|
|
641
|
+
// Daily checks of every account's kept journeys (public Studio only; a local Studio is not
|
|
642
|
+
// always running, and its journeys are the repository's to guard in CI).
|
|
643
|
+
const checkIntervalMs = Math.max(1, Number(process.env.TAPP_JOURNEY_CHECK_HOURS) || 24) * 60 * 60 * 1000;
|
|
644
|
+
const runJourneyChecks = async () => {
|
|
645
|
+
if (!accounts) return;
|
|
646
|
+
const journeysRoot = path.join(accounts.root, "journeys");
|
|
647
|
+
let owners = [];
|
|
648
|
+
try { owners = fs.readdirSync(journeysRoot, { withFileTypes: true }).filter((d) => d.isDirectory() && /^[a-f0-9]{24}$/.test(d.name)).map((d) => d.name); } catch { return; }
|
|
649
|
+
for (const accountId of owners) {
|
|
650
|
+
const store = JourneyStore.forAccount(accountId);
|
|
651
|
+
const ownerKey = `acct:${accountId}`;
|
|
652
|
+
for (const journey of dueJourneys(store.list(), { intervalMs: checkIntervalMs })) {
|
|
653
|
+
const flowPath = store.flowPath(journey.slug);
|
|
654
|
+
let flow;
|
|
655
|
+
try { const { loadFlowFile } = await import("./flow-runtime.js"); flow = loadFlowFile(flowPath); } catch { continue; }
|
|
656
|
+
let job;
|
|
657
|
+
try {
|
|
658
|
+
job = startJob("check-journey", (progress) => replayJourney({ store, slug: journey.slug, flow, actorRoot: accounts.actorRoot(accountId), ownerKey, progress }), null, { lane: ownerKey });
|
|
659
|
+
} catch { continue; /* the owner is busy; next tick */ }
|
|
660
|
+
job.ownerKey = ownerKey;
|
|
661
|
+
// One at a time per owner: wait for this check before starting the next.
|
|
662
|
+
await new Promise((resolve) => { const tick = () => (job.status === "running" ? setTimeout(tick, 1000) : resolve()); tick(); });
|
|
663
|
+
logUsage("journey.checked", { owner: ownerKey.slice(0, 13), passed: job.result?.passed ?? null });
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
const checkTimer = publicAccess ? setInterval(() => { runJourneyChecks().catch(() => {}); }, 60 * 60 * 1000) : null;
|
|
668
|
+
if (checkTimer?.unref) checkTimer.unref();
|
|
669
|
+
const firstCheck = publicAccess ? setTimeout(() => { runJourneyChecks().catch(() => {}); }, 10 * 60 * 1000) : null;
|
|
670
|
+
if (firstCheck?.unref) firstCheck.unref();
|
|
671
|
+
|
|
590
672
|
const server = http.createServer(async (request, response) => {
|
|
591
673
|
const url = new URL(request.url || "/", origin || "http://127.0.0.1");
|
|
592
674
|
const baseHeaders = {
|
|
@@ -1103,46 +1185,11 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
1103
1185
|
message: `${flow.name || name} runs on ${platform === "android" ? "an Android device or emulator" : "an iOS simulator"}, which the Studio does not have. Run it where that is: npx -y @aarwitz/tapp@latest run ${shown}` });
|
|
1104
1186
|
return;
|
|
1105
1187
|
}
|
|
1106
|
-
|
|
1107
|
-
// site: the values come from the encrypted actor store at replay and never from the file.
|
|
1108
|
-
const variables = {};
|
|
1109
|
-
let storageStatePath = "";
|
|
1110
|
-
if (flow.url && (flow.actor || (flow.steps || []).some((step) => step && typeof step === "object" && "login" in step))) {
|
|
1111
|
-
const actors = new ActorStore(actorRootFor() ? { root: actorRootFor() } : {});
|
|
1112
|
-
const record = actors.read(flow.url, flow.actor || "default");
|
|
1113
|
-
if (record?.credentials?.email) variables.TEST_EMAIL = record.credentials.email;
|
|
1114
|
-
if (record?.credentials?.password) variables.TEST_PASSWORD = record.credentials.password;
|
|
1115
|
-
// A journey that began inside replays from the actor's saved session, like the run did.
|
|
1116
|
-
if (flow.actor) storageStatePath = actors.sessionFile(flow.url, flow.actor) || "";
|
|
1117
|
-
}
|
|
1118
|
-
const captureId = `flow-web-${Date.now().toString(36)}-${crypto.randomBytes(4).toString("hex")}`;
|
|
1119
|
-
const evidenceDir = path.join(captureRoot(), captureId);
|
|
1120
|
-
fs.mkdirSync(evidenceDir, { recursive: true });
|
|
1188
|
+
const slug = root ? name : slugify(name);
|
|
1121
1189
|
const job = startJob(operation, async (progress) => {
|
|
1122
|
-
|
|
1123
|
-
const { runWebFlow } = await import("./web-flow.js");
|
|
1124
|
-
let result;
|
|
1125
|
-
try { result = await runWebFlow({ flow, variables, storageStatePath, logPath: path.join(evidenceDir, "flow.log"), screenshotDir: evidenceDir, recordVideoDir: evidenceDir }); }
|
|
1126
|
-
finally { if (storageStatePath) { try { fs.rmSync(storageStatePath, { force: true }); } catch { /* temp */ } } }
|
|
1127
|
-
// The runner's log is marker lines; the chat wants one plain sentence per step.
|
|
1128
|
-
for (const line of result.lines || []) {
|
|
1129
|
-
const raw = typeof line === "string" ? line : (line.text || "");
|
|
1130
|
-
const step = raw.match(/^OCQA_FLOW_STEP:(\{.*\})$/);
|
|
1131
|
-
if (step) {
|
|
1132
|
-
try {
|
|
1133
|
-
const s = JSON.parse(step[1]);
|
|
1134
|
-
const what = s.action === "login" ? "Signed in" : s.action === "wait_for" ? `Reached ${s.target}` : s.action === "assert_screen" ? `On ${s.target}` : s.action === "tap" ? `Tapped "${s.target}"` : `${s.action} ${s.target || ""}`.trim();
|
|
1135
|
-
progress({ phase: "replay", text: s.status === "pass" ? `${what}` : `Step ${s.index}: ${what} — ${s.detail || "failed"}` });
|
|
1136
|
-
} catch { progress({ phase: "replay", text: raw }); }
|
|
1137
|
-
continue;
|
|
1138
|
-
}
|
|
1139
|
-
if (/^OCQA_(FLOW_RESULT|ISSUE):/.test(raw)) continue;
|
|
1140
|
-
if (raw) progress({ phase: "replay", text: raw });
|
|
1141
|
-
}
|
|
1142
|
-
const status = store.recordRun(root ? name : slugify(name), { passed: result.passed, captureId, executed: result.executed, total: result.total, failed: result.failed });
|
|
1143
|
-
if (ownerKey) setCaptureOwner(captureId, ownerKey);
|
|
1190
|
+
const result = await replayJourney({ store, slug, flow, actorRoot: actorRootFor() || "", ownerKey, progress });
|
|
1144
1191
|
logUsage("journey.run", { owner: (ownerKey || "operator").slice(0, 13), passed: result.passed });
|
|
1145
|
-
return
|
|
1192
|
+
return result;
|
|
1146
1193
|
}, null, { lane: ownerKey || OPERATOR_LANE });
|
|
1147
1194
|
job.ownerKey = ownerKey;
|
|
1148
1195
|
json(response, 202, { job: publicJob(job, { hosted }) });
|
|
@@ -1327,6 +1374,8 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
1327
1374
|
}
|
|
1328
1375
|
await new Promise((resolve, reject) => server.close((error) => error ? reject(error) : resolve()));
|
|
1329
1376
|
if (usageHeartbeat) clearInterval(usageHeartbeat);
|
|
1377
|
+
if (checkTimer) clearInterval(checkTimer);
|
|
1378
|
+
if (firstCheck) clearTimeout(firstCheck);
|
|
1330
1379
|
if (egressProxy) { await egressProxy.close().catch(() => {}); restoreEgressEnv(); }
|
|
1331
1380
|
registry.close();
|
|
1332
1381
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aarwitz/tapp",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.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",
|