@aarwitz/tapp 0.35.6 → 0.35.8
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.
- package/.claude-plugin/plugin.json +2 -2
- package/AGENTS.md +13 -1
- package/Harness/OCQAHarnessUITests/ExplorerTests.swift +242 -32
- package/bin/tapp.js +96 -1
- package/browser/app.css +90 -1
- package/browser/app.js +295 -14
- package/browser/index.html +36 -1
- package/browser/product-contract.js +11 -0
- package/browser/view-model.js +185 -0
- package/docs/BROWSER-PRODUCT.md +54 -8
- package/mcp-server/src/account-store.js +46 -2
- package/mcp-server/src/android-flow.js +5 -0
- package/mcp-server/src/browser-product.js +136 -3
- package/mcp-server/src/flow-recording.js +27 -3
- package/mcp-server/src/flow-runtime.js +20 -2
- package/mcp-server/src/index.js +5 -4
- package/mcp-server/src/journeys.js +29 -1
- package/mcp-server/src/macos-flow.js +2 -0
- package/mcp-server/src/sim-recorder.js +273 -0
- package/mcp-server/src/studio-client.js +47 -1
- package/mcp-server/src/web-audit.js +2 -2
- package/mcp-server/src/web-explorer.js +51 -3
- package/mcp-server/src/web-flow.js +120 -5
- package/package.json +2 -2
- package/scripts/ci-gate.sh +1 -1
- package/scripts/flow_lib.py +4 -1
- package/scripts/quick-capture.sh +44 -24
package/browser/view-model.js
CHANGED
|
@@ -108,3 +108,188 @@ export function summarize(name, result = {}, { access = "" } = {}) {
|
|
|
108
108
|
if (report?.headline) return { tone: "neutral", pill: `${report.screensExplored || 0} screens · ${report.actionsPerformed || 0} actions · ${(report.findings || []).length} findings`, text: /not a release decision/i.test(report.headline) ? report.headline : `${report.headline} An observation, not a release decision.` };
|
|
109
109
|
return { tone: "neutral", pill: "Done", text: `${name} completed.` };
|
|
110
110
|
}
|
|
111
|
+
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
// Findings, grouped so a run can be read (TM-794)
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// The engine keeps every finding distinct — its signature is type|screen|target, so two dead
|
|
116
|
+
// buttons on one screen stay two findings and fixing one while breaking the other still reads as
|
|
117
|
+
// a change. That identity is right for regressions and wrong for reading: one site-wide contrast
|
|
118
|
+
// problem arrives as thirty-four lines and buries the two things worth fixing. Grouping is
|
|
119
|
+
// therefore a view concern only. Nothing here drops a finding; every one of them is inside a group.
|
|
120
|
+
|
|
121
|
+
const SEVERITY_ORDER = ["critical", "high", "medium", "low", "info"];
|
|
122
|
+
const severityRank = (value) => {
|
|
123
|
+
const index = SEVERITY_ORDER.indexOf(String(value || "info").toLowerCase());
|
|
124
|
+
return index === -1 ? SEVERITY_ORDER.length : index;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
function prettyType(value) {
|
|
128
|
+
const text = String(value || "finding").replace(/[_-]+/g, " ").trim();
|
|
129
|
+
return text ? text[0].toUpperCase() + text.slice(1) : "Finding";
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// The group's name is the engine's own words where the group agrees on them: the longest prefix
|
|
133
|
+
// every title shares, cut back to a word boundary. Thirty-four titles starting `Hard to read: "…`
|
|
134
|
+
// name themselves "Hard to read". When they share too little to be a name, fall back to the type.
|
|
135
|
+
function groupLabel(items, type) {
|
|
136
|
+
const titles = items.map((item) => String(item?.title || "")).filter(Boolean);
|
|
137
|
+
if (!titles.length) return prettyType(type);
|
|
138
|
+
if (titles.length === 1) return titles[0];
|
|
139
|
+
let prefix = titles[0];
|
|
140
|
+
for (const title of titles.slice(1)) {
|
|
141
|
+
let index = 0;
|
|
142
|
+
while (index < prefix.length && index < title.length && prefix[index] === title[index]) index += 1;
|
|
143
|
+
prefix = prefix.slice(0, index);
|
|
144
|
+
if (!prefix) break;
|
|
145
|
+
}
|
|
146
|
+
// The shared prefix usually stops inside a word — `Hard to read: "S` for "Services" and
|
|
147
|
+
// "Scope…". Drop that partial word, unless the prefix is a whole title (identical titles on
|
|
148
|
+
// different screens), where the last word really is the engine's and keeping it is right.
|
|
149
|
+
const cut = titles.includes(prefix) ? prefix : prefix.replace(/\S+$/u, "");
|
|
150
|
+
const trimmed = cut.replace(/[\s"'‘’“”:;,.\-—(\[]+$/u, "").trim();
|
|
151
|
+
return trimmed.length >= 8 ? trimmed : prettyType(type);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function groupFindings(findings = []) {
|
|
155
|
+
const groups = new Map();
|
|
156
|
+
for (const finding of findings) {
|
|
157
|
+
if (!finding) continue;
|
|
158
|
+
const type = String(finding.type || finding.category || "finding");
|
|
159
|
+
if (!groups.has(type)) groups.set(type, []);
|
|
160
|
+
groups.get(type).push(finding);
|
|
161
|
+
}
|
|
162
|
+
return [...groups.entries()]
|
|
163
|
+
.map(([type, items]) => {
|
|
164
|
+
const severity = [...items].sort((a, b) => severityRank(a.severity) - severityRank(b.severity))[0]?.severity || "info";
|
|
165
|
+
const screens = [...new Set(items.map((item) => item.screen).filter(Boolean))];
|
|
166
|
+
return {
|
|
167
|
+
type,
|
|
168
|
+
label: groupLabel(items, type),
|
|
169
|
+
severity: String(severity).toLowerCase(),
|
|
170
|
+
count: items.length,
|
|
171
|
+
screens,
|
|
172
|
+
// Worst first inside the group too, so opening it does not start on a trailing low.
|
|
173
|
+
items: [...items].sort((a, b) => severityRank(a.severity) - severityRank(b.severity)),
|
|
174
|
+
};
|
|
175
|
+
})
|
|
176
|
+
.sort((a, b) => severityRank(a.severity) - severityRank(b.severity) || b.count - a.count || a.label.localeCompare(b.label));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// The row of counts above the list, worst kind first. It is counted from the findings
|
|
180
|
+
// themselves, so it can never claim a severity the list below it does not show.
|
|
181
|
+
export function severityTally(items = []) {
|
|
182
|
+
const counts = new Map();
|
|
183
|
+
for (const item of items) {
|
|
184
|
+
if (!item) continue;
|
|
185
|
+
const severity = String(item.severity || "info").toLowerCase();
|
|
186
|
+
counts.set(severity, (counts.get(severity) || 0) + 1);
|
|
187
|
+
}
|
|
188
|
+
return [...counts.entries()]
|
|
189
|
+
.sort(([a], [b]) => severityRank(a) - severityRank(b))
|
|
190
|
+
.map(([severity, count]) => ({ severity, count }));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
// Coverage: the shape of what a run walked through (TM-794)
|
|
195
|
+
// ---------------------------------------------------------------------------
|
|
196
|
+
// Every capture already holds the map the engine built from its own markers: screens it reached,
|
|
197
|
+
// and the action that led from one to the next. Nothing here measures anything — it arranges what
|
|
198
|
+
// the engine recorded into columns by distance from the screen the run started on, and joins each
|
|
199
|
+
// screen to the stills written beside it. A screen the engine saw but never recorded a way into
|
|
200
|
+
// is listed as such rather than quietly placed next to the others.
|
|
201
|
+
|
|
202
|
+
const screenKey = (value) => String(value || "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
203
|
+
|
|
204
|
+
// `tap "Pricing"`, `open /solutions`, `back` — the engine's own action, not a sentence about it.
|
|
205
|
+
export function transitionLabel(action = {}) {
|
|
206
|
+
const type = String(action?.type || "").trim() || "goes to";
|
|
207
|
+
const target = String(action?.target || "").trim();
|
|
208
|
+
return target ? `${type} “${target}”` : type;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function coverageGraph(uiMap, shots = [], { platform = "" } = {}) {
|
|
212
|
+
const nodes = Array.isArray(uiMap?.nodes) ? uiMap.nodes : [];
|
|
213
|
+
const edges = Array.isArray(uiMap?.edges) ? uiMap.edges : [];
|
|
214
|
+
if (!nodes.length) return { screens: [], columns: [], counts: { screens: 0, transitions: 0 }, entryId: "", unreachable: [] };
|
|
215
|
+
|
|
216
|
+
// The stills are named for the screen they are of (`state_3_pricing.png`), which is the node's
|
|
217
|
+
// own key with its separators spelled differently. Match on that and nothing cleverer: a screen
|
|
218
|
+
// with no still shows as a named card, never as a guess at someone else's picture.
|
|
219
|
+
const byKey = new Map();
|
|
220
|
+
for (const shot of shots) {
|
|
221
|
+
const key = screenKey(shot?.caption);
|
|
222
|
+
if (!key) continue;
|
|
223
|
+
if (!byKey.has(key)) byKey.set(key, []);
|
|
224
|
+
byKey.get(key).push(shot.src);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const entryId = uiMap?.app?.entryNodes?.[platform] || Object.values(uiMap?.app?.entryNodes || {})[0] || nodes[0].id;
|
|
228
|
+
const outgoing = new Map(nodes.map((node) => [node.id, []]));
|
|
229
|
+
for (const edge of edges) {
|
|
230
|
+
if (!outgoing.has(edge?.from)) continue;
|
|
231
|
+
outgoing.get(edge.from).push(edge);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const depth = new Map([[entryId, 0]]);
|
|
235
|
+
let frontier = [entryId];
|
|
236
|
+
while (frontier.length) {
|
|
237
|
+
const next = [];
|
|
238
|
+
for (const id of frontier) {
|
|
239
|
+
for (const edge of outgoing.get(id) || []) {
|
|
240
|
+
if (!edge?.to || depth.has(edge.to) || !outgoing.has(edge.to)) continue;
|
|
241
|
+
depth.set(edge.to, depth.get(id) + 1);
|
|
242
|
+
next.push(edge.to);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
frontier = next;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const reachedDepth = Math.max(0, ...[...depth.values()]);
|
|
249
|
+
const unreachable = nodes.filter((node) => !depth.has(node.id)).map((node) => node.id);
|
|
250
|
+
const nameById = new Map(nodes.map((node) => [node.id, node.name || node.semanticKey || node.id]));
|
|
251
|
+
|
|
252
|
+
const screens = nodes.map((node) => {
|
|
253
|
+
const key = screenKey(node.semanticKey || node.name);
|
|
254
|
+
// The engine marks a screen it met in a second structural state (`variant`, with the screen it
|
|
255
|
+
// is a state of in `baseSemanticKey`). The stills are captioned by title, so they cannot tell
|
|
256
|
+
// those apart. Fall back to the base screen's still for a variant and say that is what it is,
|
|
257
|
+
// rather than either showing nothing or implying the picture is of this exact state.
|
|
258
|
+
const base = node.variant ? screenKey(node.baseSemanticKey) : "";
|
|
259
|
+
const matched = byKey.get(key) || (base ? byKey.get(base) || [] : []);
|
|
260
|
+
const borrowed = !(byKey.get(key) || []).length && matched.length > 0;
|
|
261
|
+
return {
|
|
262
|
+
id: node.id,
|
|
263
|
+
name: node.stateLabel || node.name || node.semanticKey || "Screen",
|
|
264
|
+
key: node.semanticKey || key,
|
|
265
|
+
variantOf: node.variant ? (node.name || node.baseSemanticKey || "") : "",
|
|
266
|
+
// A screen the run never found a recorded way into sits in a column of its own, after the
|
|
267
|
+
// ones it did — never implied to follow from the last screen simply by being drawn there.
|
|
268
|
+
column: depth.has(node.id) ? depth.get(node.id) : reachedDepth + 1,
|
|
269
|
+
reached: depth.has(node.id),
|
|
270
|
+
shot: matched[0] || null,
|
|
271
|
+
shotCount: matched.length,
|
|
272
|
+
// True when the picture is of this screen in a different state than the one recorded here.
|
|
273
|
+
shotIsOfBaseScreen: borrowed,
|
|
274
|
+
controls: (node.controls || []).length,
|
|
275
|
+
outgoing: (outgoing.get(node.id) || []).map((edge) => ({
|
|
276
|
+
label: transitionLabel(edge.action),
|
|
277
|
+
to: edge.to,
|
|
278
|
+
toName: nameById.get(edge.to) || "",
|
|
279
|
+
})),
|
|
280
|
+
};
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
const columns = [];
|
|
284
|
+
for (const screen of screens) {
|
|
285
|
+
(columns[screen.column] ||= []).push(screen.id);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return {
|
|
289
|
+
screens,
|
|
290
|
+
columns: columns.map((column) => column || []),
|
|
291
|
+
counts: { screens: nodes.length, transitions: edges.length },
|
|
292
|
+
entryId,
|
|
293
|
+
unreachable,
|
|
294
|
+
};
|
|
295
|
+
}
|
package/docs/BROWSER-PRODUCT.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# Browser Studio
|
|
2
2
|
|
|
3
|
-
Status: current product contract as of 2026-
|
|
4
|
-
|
|
3
|
+
Status: current product contract as of 2026-11-20 (ADR-0006, owner decision, amended three
|
|
4
|
+
times: 2026-10-19; TM-794 on 2026-11-15 bringing Findings and Coverage back; and ADR-0011 on
|
|
5
|
+
2026-11-20 making the hosted first page the front door). Supersedes the "desktop-parity Command
|
|
6
|
+
Center" framing of 2026-10-14.
|
|
5
7
|
|
|
6
8
|
The Studio in `browser/` is the one browser surface. It is a **run viewer**: point Tapp at a
|
|
7
9
|
repository target or a website, watch the run live, open its evidence. It never scores or judges
|
|
@@ -38,12 +40,21 @@ looping animation of a device being driven (launch, tap, tap, screenshot, ✓).
|
|
|
38
40
|
The server classifies the input again (`classifyPrompt` in `browser/view-model.js` is shared) and
|
|
39
41
|
refuses what the mode cannot do: a hosted Studio cannot open a path or a build on your machine.
|
|
40
42
|
|
|
43
|
+
**On a hosted Studio the page is the front door (ADR-0011).** The box takes a public website. A
|
|
44
|
+
self-host card under it names everything else — repositories, iOS and Android builds, macOS apps,
|
|
45
|
+
staging and localhost — with the command that opens this same Studio on the person's machine, and
|
|
46
|
+
the examples the deployment cannot start are not offered. Typing one anyway still gets the
|
|
47
|
+
structured `self-host` answer in the chat (ADR-0010). The platform chips are the same in both
|
|
48
|
+
modes; on a laptop most of them say "ready".
|
|
49
|
+
|
|
41
50
|
## What is on the page
|
|
42
51
|
|
|
43
52
|
| View | What it shows | Operations |
|
|
44
53
|
|---|---|---|
|
|
45
54
|
| Overview | The **stage**: the device as large as the window allows, in its platform's aspect ratio (phone portrait for iOS and Android, browser landscape for web), showing the live frame or the newest screenshot the run wrote. The **chat** floats over its corner on a translucent ground, collapses to a pill, and narrates the engine's own progress log one emoji-led line at a time (👆 Tapped, ⌨️ Typed, 🔐 Signed in, 📍 Opened, 🧭 Reached, 📸 screenshots inline), then attaches the recording and `report.html` and ends with a pill — `✓ Ready to merge`, `× Do not merge`, `◐ Inconclusive`, or for an exploration its counts — and the headline. Nothing is generated after the fact and nothing is a score. Below the stage: the detected targets (an explicit choice when there are several), the live-session controls, and the current decision from the last gate. | `open`, `initialize` (inspect, then build + explore), `explore-build`, live session `start / act / save-flow / end`, release check |
|
|
46
55
|
| Runs | Every run on this repository, every exploration started from the prompt, and every read-only website audit, newest first; each opens its evidence page. A URL field runs an audit from here. | `gate`, `audit` |
|
|
56
|
+
| Findings | What the selected run reported, **grouped by kind** and worst first: one row per kind with the count of places it covers (`Hard to read · 34 · 4 screens`), opening onto every individual place. The engine's identity for a finding is `type|screen|target`, so one site-wide problem arrives as dozens of lines and buries the two worth fixing; grouping is a reading aid in the view and drops nothing — every finding is inside exactly one group. A read-only audit's two kinds stay apart, as the engine draws them: **Broken** (structural defects) and **Worth a look** (not broken; what a person would notice). Never a verdict. | — |
|
|
57
|
+
| Coverage | The screens the selected run reached, in columns by distance from the screen it started on, each a card with the still the run wrote and the actions that led on from it (`tap "Pricing" → Pricing`). Built from the `ui-map.json` the engine writes into every capture: `nodes` are screens, `edges` the recorded transitions. Only recorded transitions are drawn — a screen reached with no recorded way in gets its own column and says so, and a run with no transitions at all (a read-only audit clicks nothing) is a plain grid of what it opened, with the reason stated. | — |
|
|
47
58
|
|
|
48
59
|
A **website audit** is `explore --read-only`: up to twenty same-origin pages (twelve by default) are rendered and read —
|
|
49
60
|
dead controls, broken images/assets/links, failed requests, JS exceptions, mixed content,
|
|
@@ -54,12 +65,20 @@ real small-business sites in October 2026; the remaining findings were verified
|
|
|
54
65
|
|
|
55
66
|
## What was removed, and where it lives instead
|
|
56
67
|
|
|
57
|
-
The Contracts
|
|
68
|
+
The Contracts and Settings views, the six-step journey stepper, and the folder-upload,
|
|
58
69
|
GitHub-clone and remote-runner onboarding were removed on 2026-10-15. Reviewing and promoting
|
|
59
|
-
contracts is `tapp plan` / `tapp validate` in the repository;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
contracts is `tapp plan` / `tapp validate` in the repository; actors and credentials live in
|
|
71
|
+
`.tapp/project.json`; CI installation is `tapp ci`. The Studio keeps only what a browser does
|
|
72
|
+
better than a terminal: watching a real device while a run happens, driving it by hand, and
|
|
73
|
+
reading evidence.
|
|
74
|
+
|
|
75
|
+
**Findings and Coverage came back on 2026-11-15** (TM-794, owner decision). They were removed in
|
|
76
|
+
the same pass on the argument that `report.html` already carried them. It carries the findings —
|
|
77
|
+
as the same flat list, which is the problem — and it never carried the map at all: the engine has
|
|
78
|
+
written `ui-map.json` into every capture throughout, and nothing drew it. Reading a run is a thing
|
|
79
|
+
a browser does better than a terminal, so it belongs to the same rule as the rest of the Studio.
|
|
80
|
+
Neither view computes anything: Findings groups what the engine reported, Coverage arranges the
|
|
81
|
+
map it wrote. Neither judges — only the gate does.
|
|
63
82
|
|
|
64
83
|
## Verified reference journey
|
|
65
84
|
|
|
@@ -68,7 +87,9 @@ target choice, exploration, a live session that records a Flow, the gate, and th
|
|
|
68
87
|
`tests/browser-onboarding.test.js` covers the no-repository start and a read-only website audit;
|
|
69
88
|
`tests/browser-product.test.js` covers authentication, CSRF, the audit operation and the removed
|
|
70
89
|
endpoints answering 404. `tests/browser-chat-narration.test.js` covers prompt classification and
|
|
71
|
-
the chat's narration and summary without a browser
|
|
90
|
+
the chat's narration and summary without a browser, and
|
|
91
|
+
`tests/browser-run-reading.test.js` covers finding groups and the coverage graph the same way —
|
|
92
|
+
the browser journey then drives both views against a real run.
|
|
72
93
|
|
|
73
94
|
## Hosted relationship
|
|
74
95
|
|
|
@@ -88,6 +109,31 @@ an allowlist in `browser-product.js` (`anonymousAllows`, `accountAllows`):
|
|
|
88
109
|
| Evidence | Captures stamped with their visitor cookie | Captures stamped `acct:<id>` | All captures on the machine |
|
|
89
110
|
| Test accounts | None — a visitor is never asked | Encrypted, per account: `TAPP_HOME/accounts/actors/<id>/` | `TAPP_HOME/actors/` |
|
|
90
111
|
|
|
112
|
+
**The cloud beyond the visitor audit is for an account on a plan or in its free trial (ADR-0011
|
|
113
|
+
§3).** A new account starts a 14-day trial (`plan` on the account record; `account-store.js`
|
|
114
|
+
`entitlement`); an account from before plans existed gets its trial from the day it is next seen.
|
|
115
|
+
Starting a cloud run — `POST /api/operations/explore`, `/api/operations/run-flow`,
|
|
116
|
+
`/api/journeys`, `/api/captures/<id>/keep` — answers **402** with the reason once the trial has
|
|
117
|
+
lapsed, and the daily checks skip that account's journeys; reading what the account owns stays
|
|
118
|
+
open, so it can still see and forget its journeys, test accounts and tokens. The deployment's
|
|
119
|
+
owner (`TAPP_ADMIN_EMAILS`) is never gated and marks an account paid or extends its trial from the
|
|
120
|
+
Admin view (`POST /api/admin/plan`). There is no payment step yet: "paid" is the owner's word.
|
|
121
|
+
Nothing a local Studio does needs an account.
|
|
122
|
+
|
|
123
|
+
**A self-hosted Studio can report to an account (ADR-0011 §4).** Results flow up; the browser
|
|
124
|
+
never reaches down. Under *Your tapp account* on a local Studio, the owner pastes a token created
|
|
125
|
+
on the hosted one (under *Your coding agent*); the local Studio checks it against that Studio,
|
|
126
|
+
records whose it is, and keeps it in `TAPP_HOME/studio-link.json` (0600, this user only). From
|
|
127
|
+
then on every journey run on this machine — including against staging and localhost — posts its
|
|
128
|
+
name, platform, step count, machine name and result to `POST /api/journeys/report`; the journey
|
|
129
|
+
itself, credentials and screenshots never leave. The account's Journeys list shows it with "runs
|
|
130
|
+
on <machine>", no Run button (the cloud has no flow for it), and Forget; a pass↔fail change between
|
|
131
|
+
reports delivers the same alert a cloud check's would; the daily checks never pick it up. A Studio
|
|
132
|
+
that cannot be reached is said in the chat and never fails the run. `tapp run` on this machine
|
|
133
|
+
reports the same way — so an iOS or Android journey run from a terminal shows on the account too —
|
|
134
|
+
using the machine's link, or `TAPP_STUDIO` + `TAPP_TOKEN` when set; `--no-report` keeps one run to
|
|
135
|
+
itself.
|
|
136
|
+
|
|
91
137
|
**Signing in** is `POST /api/auth/link` with an email, then `GET /auth/<token>` from the email.
|
|
92
138
|
There is no password. Links work once and expire in 15 minutes; sessions last 90 days; only the
|
|
93
139
|
SHA-256 of either token is on disk (`account-store.js`). One address may ask for five links per
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
//
|
|
11
11
|
// Layout: TAPP_HOME/accounts/
|
|
12
12
|
// by-email/<sha256(email)> → account id
|
|
13
|
-
// accounts/<id>.json { id, email, createdAt, lastSeenAt }
|
|
13
|
+
// accounts/<id>.json { id, email, createdAt, lastSeenAt, plan }
|
|
14
14
|
// links/<sha256(token)>.json { email, expiresAt } (removed on use)
|
|
15
15
|
// sessions/<sha256(token)>.json { accountId, createdAt, expiresAt }
|
|
16
16
|
// tokens/<sha256(token)>.json { id, accountId, label, createdAt, lastUsedAt }
|
|
@@ -25,6 +25,10 @@ import path from "node:path";
|
|
|
25
25
|
export const TOKEN_PREFIX = "tapp_";
|
|
26
26
|
export const LINK_TTL_MS = 15 * 60 * 1000;
|
|
27
27
|
export const SESSION_TTL_MS = 90 * 24 * 60 * 60 * 1000;
|
|
28
|
+
// The cloud beyond the visitor audit is for an account on a plan or in its free trial
|
|
29
|
+
// (ADR-0011 §3). A trial is a date, nothing more: no card, no counter of runs.
|
|
30
|
+
export const TRIAL_DAYS = 14;
|
|
31
|
+
export const TRIAL_MS = TRIAL_DAYS * 24 * 60 * 60 * 1000;
|
|
28
32
|
// One address may ask for this many links in a ten-minute window; more is someone else's mailbox
|
|
29
33
|
// being flooded through us.
|
|
30
34
|
const LINKS_PER_WINDOW = 5;
|
|
@@ -171,6 +175,46 @@ export class AccountStore {
|
|
|
171
175
|
return false;
|
|
172
176
|
}
|
|
173
177
|
|
|
178
|
+
/** The account record by id, or null. */
|
|
179
|
+
getAccount(accountId) {
|
|
180
|
+
if (!/^[a-f0-9]{24}$/.test(String(accountId || ""))) return null;
|
|
181
|
+
return readJson(this.#file("accounts", accountId));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Whether this account may start a cloud run, and why. `paid` has no end; `trial` has one and
|
|
186
|
+
* is allowed until it; `lapsed` is a trial whose date has passed. An account from before plans
|
|
187
|
+
* existed has none on record — it is given a trial from the day it is next seen, not from the
|
|
188
|
+
* day it joined, so a change in the rules never locks out someone who was already here.
|
|
189
|
+
*/
|
|
190
|
+
entitlement(accountOrId) {
|
|
191
|
+
const account = typeof accountOrId === "string" ? this.getAccount(accountOrId) : accountOrId;
|
|
192
|
+
if (!account) return { kind: "lapsed", allowed: false, endsAt: null, daysLeft: 0 };
|
|
193
|
+
if (!account.plan || typeof account.plan !== "object") {
|
|
194
|
+
account.plan = { kind: "trial", endsAt: new Date(this.now() + TRIAL_MS).toISOString() };
|
|
195
|
+
writeJson(this.#file("accounts", account.id), account);
|
|
196
|
+
}
|
|
197
|
+
if (account.plan.kind === "paid") return { kind: "paid", allowed: true, endsAt: null, daysLeft: null };
|
|
198
|
+
const endsAt = Date.parse(account.plan.endsAt);
|
|
199
|
+
const left = Number.isFinite(endsAt) ? endsAt - this.now() : -1;
|
|
200
|
+
if (left <= 0) return { kind: "lapsed", allowed: false, endsAt: account.plan.endsAt || null, daysLeft: 0 };
|
|
201
|
+
return { kind: "trial", allowed: true, endsAt: account.plan.endsAt, daysLeft: Math.ceil(left / 86_400_000) };
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** The owner of the deployment decides: mark an account paid, or give it a trial of so many days from now. */
|
|
205
|
+
setPlan(accountId, { kind, days } = {}) {
|
|
206
|
+
const account = this.getAccount(accountId);
|
|
207
|
+
if (!account) throw Object.assign(new Error("No such account"), { statusCode: 404 });
|
|
208
|
+
if (kind === "paid") account.plan = { kind: "paid" };
|
|
209
|
+
else if (kind === "trial") {
|
|
210
|
+
const length = Number(days);
|
|
211
|
+
if (!Number.isInteger(length) || length < 1 || length > 365) throw Object.assign(new Error("A trial is 1 to 365 days"), { statusCode: 400 });
|
|
212
|
+
account.plan = { kind: "trial", endsAt: new Date(this.now() + length * 86_400_000).toISOString() };
|
|
213
|
+
} else throw Object.assign(new Error("A plan is 'paid' or 'trial'"), { statusCode: 400 });
|
|
214
|
+
writeJson(this.#file("accounts", account.id), account);
|
|
215
|
+
return this.entitlement(account);
|
|
216
|
+
}
|
|
217
|
+
|
|
174
218
|
/** Where this account's encrypted test accounts live. */
|
|
175
219
|
actorRoot(accountId) {
|
|
176
220
|
if (!/^[a-f0-9]{24}$/.test(String(accountId || ""))) throw new Error("Not an account id");
|
|
@@ -186,7 +230,7 @@ export class AccountStore {
|
|
|
186
230
|
if (existing) return existing;
|
|
187
231
|
}
|
|
188
232
|
id = crypto.randomBytes(12).toString("hex");
|
|
189
|
-
const account = { id, email, createdAt: new Date(this.now()).toISOString(), lastSeenAt: new Date(this.now()).toISOString() };
|
|
233
|
+
const account = { id, email, createdAt: new Date(this.now()).toISOString(), lastSeenAt: new Date(this.now()).toISOString(), plan: { kind: "trial", endsAt: new Date(this.now() + TRIAL_MS).toISOString() } };
|
|
190
234
|
writeJson(this.#file("accounts", id), account);
|
|
191
235
|
fs.mkdirSync(path.dirname(indexFile), { recursive: true, mode: 0o700 });
|
|
192
236
|
fs.writeFileSync(indexFile, `${id}\n`, { mode: 0o600 });
|
|
@@ -107,6 +107,11 @@ export async function runAndroidFlow({ flow, appId, apkPath, serial, logPath, sc
|
|
|
107
107
|
await d.swipe(target || "up");
|
|
108
108
|
} else if (action === "back") {
|
|
109
109
|
await d.back();
|
|
110
|
+
} else if (action === "open_url") {
|
|
111
|
+
// A journey starting from an email link ("tap the sign-in link in your receipt") opens it
|
|
112
|
+
// the way Android itself would hand it to the app — a VIEW intent, not a shell workaround.
|
|
113
|
+
const r = await d.adb(["shell", "am", "start", "-a", "android.intent.action.VIEW", "-d", target]);
|
|
114
|
+
if (r.code !== 0 || /Error:/i.test(r.stdout || "")) throw new Error(`could not open ‘${target}’: ${(r.stdout || r.stderr || "").trim() || "no app handled this link"}`);
|
|
110
115
|
} else if (action === "wait_for") {
|
|
111
116
|
const waited = await d.waitFor(target, timeout);
|
|
112
117
|
if (!waited) throw new Error(`‘${target}’ never appeared within ${timeout}ms`);
|
|
@@ -170,14 +170,32 @@ function accountAllows(method, pathname) {
|
|
|
170
170
|
if (method === "POST" && (pathname === "/api/alerts" || pathname === "/api/alerts/test")) return true;
|
|
171
171
|
// Personal access tokens: the owner's coding agent acting as them (ADR-0009 slice 4).
|
|
172
172
|
if (method === "POST" && pathname === "/api/tokens") return true;
|
|
173
|
+
// The deployment's owner marks an account paid or extends its trial; the handler checks who.
|
|
174
|
+
if (method === "POST" && pathname === "/api/admin/plan") return true;
|
|
173
175
|
if (method === "DELETE" && /^\/api\/tokens\/[a-f0-9]{12}$/.test(pathname)) return true;
|
|
174
176
|
if (method === "DELETE" && /^\/api\/actors\/[A-Za-z0-9.:-]{1,253}\/[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(pathname)) return true;
|
|
175
177
|
// Journeys: keep a proven run, replay it, forget it (ADR-0009 slice 3).
|
|
176
178
|
if (method === "POST" && (/^\/api\/captures\/[A-Za-z0-9._-]{1,128}\/keep$/.test(pathname) || pathname === "/api/operations/run-flow" || pathname === "/api/journeys")) return true;
|
|
179
|
+
// A journey run on the owner's own machine reports how it went (ADR-0011 §4).
|
|
180
|
+
if (method === "POST" && pathname === "/api/journeys/report") return true;
|
|
177
181
|
if (method === "DELETE" && /^\/api\/journeys\/[a-z0-9-]{1,60}$/.test(pathname)) return true;
|
|
178
182
|
return false;
|
|
179
183
|
}
|
|
180
184
|
|
|
185
|
+
// Starting a cloud run — going inside a site, keeping or replaying a journey, importing one —
|
|
186
|
+
// is what a plan or a free trial buys (ADR-0011 §3). Reading what you own is not gated, so a
|
|
187
|
+
// lapsed trial can still see its journeys, test accounts and tokens, and forget them.
|
|
188
|
+
function cloudRunRoute(method, pathname) {
|
|
189
|
+
if (method !== "POST") return false;
|
|
190
|
+
return pathname === "/api/operations/explore" || pathname === "/api/operations/run-flow" || pathname === "/api/journeys"
|
|
191
|
+
|| /^\/api\/captures\/[A-Za-z0-9._-]{1,128}\/keep$/.test(pathname);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function trialEndedMessage(plan) {
|
|
195
|
+
const when = plan?.endsAt ? ` on ${String(plan.endsAt).slice(0, 10)}` : "";
|
|
196
|
+
return `Your free trial ended${when}. Cloud runs — going inside a site, kept journeys and daily checks — are for accounts on a plan. Write to hello@runtapp.com, or run everything on your own machine, where nothing is gated: npx -y @aarwitz/tapp@latest app`;
|
|
197
|
+
}
|
|
198
|
+
|
|
181
199
|
// One visitor may start a bounded number of audits per hour. Each audit drives a real browser
|
|
182
200
|
// over as many as 20 pages, so this is about the machine, not about abuse alone.
|
|
183
201
|
const AUDIT_LIMIT_PER_HOUR = 10;
|
|
@@ -358,7 +376,32 @@ async function replayJourney({ store, slug, flow, actorRoot = "", ownerKey = nul
|
|
|
358
376
|
// due when its last result is older than the interval (TAPP_JOURNEY_CHECK_HOURS, default 24);
|
|
359
377
|
// a restart therefore does not re-run everything, and a busy lane simply waits for the next tick.
|
|
360
378
|
export function dueJourneys(journeys, { intervalMs, now = Date.now() }) {
|
|
361
|
-
|
|
379
|
+
// A reported journey runs on somebody's own machine; the cloud has no flow to replay.
|
|
380
|
+
return journeys.filter((j) => j.source !== "reported" && (j.platform || "web") === "web" && (!j.status || now - Date.parse(j.status.at || 0) >= intervalMs));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// ADR-0011 §4: results flow up, the browser never reaches down. A self-hosted Studio can be
|
|
384
|
+
// linked to an account on a hosted one with a token the owner created there; from then on a
|
|
385
|
+
// journey run here reports its name and result to that account. The link lives beside the
|
|
386
|
+
// machine's other state, readable by this user only. Never on a hosted Studio: its account IS
|
|
387
|
+
// the account.
|
|
388
|
+
function studioLinkPath() {
|
|
389
|
+
return path.join(process.env.TAPP_HOME || path.join(os.homedir(), ".tapp"), "studio-link.json");
|
|
390
|
+
}
|
|
391
|
+
function readStudioLink() {
|
|
392
|
+
try {
|
|
393
|
+
const link = JSON.parse(fs.readFileSync(studioLinkPath(), "utf8"));
|
|
394
|
+
return link && typeof link.origin === "string" && typeof link.token === "string" ? link : null;
|
|
395
|
+
} catch { return null; }
|
|
396
|
+
}
|
|
397
|
+
function writeStudioLink(link) {
|
|
398
|
+
const file = studioLinkPath();
|
|
399
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
400
|
+
fs.writeFileSync(file, JSON.stringify(link), { mode: 0o600 });
|
|
401
|
+
}
|
|
402
|
+
function studioLinkSummary() {
|
|
403
|
+
const link = readStudioLink();
|
|
404
|
+
return link ? { origin: link.origin, email: link.email || "", linkedAt: link.linkedAt || null } : null;
|
|
362
405
|
}
|
|
363
406
|
|
|
364
407
|
function openBrowser(url) {
|
|
@@ -733,6 +776,10 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
733
776
|
for (const accountId of owners) {
|
|
734
777
|
const store = JourneyStore.forAccount(accountId);
|
|
735
778
|
const ownerKey = `acct:${accountId}`;
|
|
779
|
+
// A daily check is a cloud run: a lapsed trial's journeys keep their last result and are
|
|
780
|
+
// not re-run until the account is on a plan again (ADR-0011 §3).
|
|
781
|
+
const record = accounts.getAccount(accountId);
|
|
782
|
+
if (record && !isAdmin(record) && !accounts.entitlement(record).allowed) continue;
|
|
736
783
|
for (const journey of dueJourneys(store.list(), { intervalMs: checkIntervalMs })) {
|
|
737
784
|
const flowPath = store.flowPath(journey.slug);
|
|
738
785
|
let flow;
|
|
@@ -804,6 +851,16 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
804
851
|
json(response, 401, { error: "That part of the Studio runs on your own machine: npx -y @aarwitz/tapp@latest app" });
|
|
805
852
|
return;
|
|
806
853
|
}
|
|
854
|
+
// The cloud beyond the visitor audit is for an account on a plan or in its free trial
|
|
855
|
+
// (ADR-0011 §3). The deployment's owner is never gated on their own machine.
|
|
856
|
+
if (account && !isAdmin(account) && cloudRunRoute(request.method, url.pathname)) {
|
|
857
|
+
const plan = accounts.entitlement(account);
|
|
858
|
+
if (!plan.allowed) {
|
|
859
|
+
logUsage("refused", { account: account.id.slice(0, 8), reason: "trial-ended", method: request.method, path: url.pathname, status: 402 });
|
|
860
|
+
json(response, 402, { error: trialEndedMessage(plan), plan });
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
807
864
|
if (publicAccess && !authenticated && !account) {
|
|
808
865
|
anonymous = true;
|
|
809
866
|
visitorId = String(cookies(request)[VISITOR_COOKIE] || "");
|
|
@@ -1037,6 +1094,57 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
1037
1094
|
json(response, 200, { name: journey.flow.name, slug: kept.slug, steps: journey.steps, screens: journey.screens, signedIn: journey.signedIn, path: registry.currentRoot() && !account ? path.relative(registry.currentRoot(), kept.path) : null });
|
|
1038
1095
|
return;
|
|
1039
1096
|
}
|
|
1097
|
+
// A journey that ran on the owner's own machine says how it went (ADR-0011 §4). The name
|
|
1098
|
+
// and the result are kept under the account; nothing else is accepted, and a change
|
|
1099
|
+
// between runs is announced the way a cloud check's would be.
|
|
1100
|
+
if (account && request.method === "POST" && url.pathname === "/api/journeys/report") {
|
|
1101
|
+
guardMutation(request);
|
|
1102
|
+
const body = await readJsonBody(request);
|
|
1103
|
+
const name = String(body.name || "").replace(/[\u0000-\u001f]/g, "").trim().slice(0, 120);
|
|
1104
|
+
if (!name) throw Object.assign(new Error("A report names the journey"), { statusCode: 400 });
|
|
1105
|
+
const platform = ["web", "ios", "android", "macos"].includes(body.platform) ? body.platform : "web";
|
|
1106
|
+
const machine = String(body.machine || "").replace(/[\u0000-\u001f]/g, "").trim().slice(0, 64);
|
|
1107
|
+
const count = (value) => Math.max(0, Math.min(10_000, Number.isFinite(Number(value)) ? Math.trunc(Number(value)) : 0));
|
|
1108
|
+
const at = Number.isFinite(Date.parse(body.at)) ? new Date(Date.parse(body.at)).toISOString() : null;
|
|
1109
|
+
const store = JourneyStore.forAccount(account.id);
|
|
1110
|
+
const previous = store.reported(slugify(name))?.status || null;
|
|
1111
|
+
const record = store.report({ name, platform, url: String(body.url || "").slice(0, 2048), steps: count(body.steps), machine, passed: body.passed === true, executed: count(body.executed), total: count(body.total), failed: count(body.failed), at });
|
|
1112
|
+
const change = alertForChange({ previous, current: record.status });
|
|
1113
|
+
if (change) {
|
|
1114
|
+
const alerts = AlertStore.forAccount(accounts.root, account.id);
|
|
1115
|
+
const settings = alerts.read();
|
|
1116
|
+
if (settings.webhook) {
|
|
1117
|
+
const alert = await deliverAlert({ webhook: settings.webhook, message: alertMessage({ kind: change, journey: `${name}${machine ? ` (on ${machine})` : ""}`, status: record.status, origin: publicOrigins[0] || "" }) });
|
|
1118
|
+
alerts.write({ lastDelivery: { at: new Date().toISOString(), journey: name, change, ...alert } });
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
logUsage("journey.reported", { account: account.id.slice(0, 8), passed: record.status.passed, platform, change: change || null });
|
|
1122
|
+
json(response, 200, { ok: true, slug: record.slug, status: record.status, change: change || null });
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
// Linking this machine to an account on a hosted Studio (ADR-0011 §4). Operator only, and
|
|
1126
|
+
// only on a self-hosted Studio: a hosted one has nothing to link to but itself.
|
|
1127
|
+
if (!hosted && authenticated && url.pathname === "/api/studio-link") {
|
|
1128
|
+
if (request.method === "GET") { json(response, 200, { link: studioLinkSummary() }); return; }
|
|
1129
|
+
guardMutation(request);
|
|
1130
|
+
if (request.method === "DELETE") { try { fs.rmSync(studioLinkPath(), { force: true }); } catch { /* gone */ } json(response, 200, { ok: true, link: null }); return; }
|
|
1131
|
+
if (request.method === "POST") {
|
|
1132
|
+
const body = await readJsonBody(request);
|
|
1133
|
+
const { studioConfig, verifyStudioToken } = await import("./studio-client.js");
|
|
1134
|
+
let config;
|
|
1135
|
+
try { config = studioConfig({ studio: String(body.origin || "https://app.runtapp.com"), token: String(body.token || "") }, {}); }
|
|
1136
|
+
catch (error) { json(response, 400, { error: error.message }); return; }
|
|
1137
|
+
if (!config) { json(response, 400, { error: "A Studio URL is needed" }); return; }
|
|
1138
|
+
let who;
|
|
1139
|
+
try { who = await verifyStudioToken(config); }
|
|
1140
|
+
catch (error) { json(response, 400, { error: error.message }); return; }
|
|
1141
|
+
const link = { origin: config.origin, token: config.token, email: who.email, linkedAt: new Date().toISOString() };
|
|
1142
|
+
writeStudioLink(link);
|
|
1143
|
+
logUsage("studio.linked", { origin: config.origin });
|
|
1144
|
+
json(response, 200, { ok: true, link: studioLinkSummary() });
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1040
1148
|
if (!anonymous && request.method === "GET" && url.pathname === "/api/journeys") {
|
|
1041
1149
|
const store = journeyStore();
|
|
1042
1150
|
const root = !account ? registry.currentRoot() : null;
|
|
@@ -1109,6 +1217,17 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
1109
1217
|
// What the owner of this deployment can see: how it is being used, who has an account, and
|
|
1110
1218
|
// which journeys are failing. Never a credential — they are encrypted and never decrypted
|
|
1111
1219
|
// for display — and never anyone's evidence.
|
|
1220
|
+
// The owner decides who is on a plan: mark an account paid, or give it a trial of so many
|
|
1221
|
+
// days from today. Anyone else asking gets 403, not a hint of who has an account.
|
|
1222
|
+
if (account && request.method === "POST" && url.pathname === "/api/admin/plan") {
|
|
1223
|
+
if (!isAdmin(account)) { json(response, 403, { error: "Only the owner of this deployment can do that" }); return; }
|
|
1224
|
+
guardMutation(request);
|
|
1225
|
+
const body = await readJsonBody(request);
|
|
1226
|
+
const plan = accounts.setPlan(String(body.accountId || ""), { kind: String(body.kind || ""), days: body.days });
|
|
1227
|
+
logUsage("plan.set", { account: String(body.accountId || "").slice(0, 8), kind: plan.kind, by: account.id.slice(0, 8) });
|
|
1228
|
+
json(response, 200, { ok: true, plan });
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1112
1231
|
if (account && isAdmin(account) && request.method === "GET" && url.pathname === "/api/admin/overview") {
|
|
1113
1232
|
const accountsRoot = accounts.root;
|
|
1114
1233
|
const listAccounts = () => {
|
|
@@ -1127,7 +1246,8 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
1127
1246
|
}
|
|
1128
1247
|
} catch { /* none yet */ }
|
|
1129
1248
|
return {
|
|
1130
|
-
email: record.email, createdAt: record.createdAt, lastSeenAt: record.lastSeenAt || null,
|
|
1249
|
+
id: record.id, email: record.email, createdAt: record.createdAt, lastSeenAt: record.lastSeenAt || null,
|
|
1250
|
+
plan: isAdmin(record) ? { kind: "owner", allowed: true, endsAt: null, daysLeft: null } : accounts.entitlement(record),
|
|
1131
1251
|
journeys: journeys.length,
|
|
1132
1252
|
failing: journeys.filter((j) => j.status && !j.status.passed).length,
|
|
1133
1253
|
neverRun: journeys.filter((j) => !j.status).length,
|
|
@@ -1291,6 +1411,8 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
1291
1411
|
csrfToken, mode: "public", product: "Tapp", root: null, repository: null, repositories: [],
|
|
1292
1412
|
contract: customerProductContract, supportedPlatforms: ["web"], runners: [],
|
|
1293
1413
|
access: "account", email: account.email, signInProvider, signInOptions, viaToken, admin: isAdmin(account),
|
|
1414
|
+
// What the cloud will do for this account, and until when (ADR-0011 §3).
|
|
1415
|
+
plan: isAdmin(account) ? { kind: "owner", allowed: true, endsAt: null, daysLeft: null } : accounts.entitlement(account),
|
|
1294
1416
|
accepts: ["url"],
|
|
1295
1417
|
selfHostOnly: ["path", "github", "bundle", "app", "apk"],
|
|
1296
1418
|
// What tapp drives, and what THIS machine can start. The Studio shows all of it:
|
|
@@ -1316,7 +1438,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
1316
1438
|
});
|
|
1317
1439
|
return;
|
|
1318
1440
|
}
|
|
1319
|
-
json(response, 200, { csrfToken, mode: hosted ? "managed" : "local", product: "Tapp", root: hosted ? null : registry.currentRoot(), repository: hosted ? hostedRepository(registry.current()) : registry.current(), repositories: hosted ? registry.list().map(hostedRepository) : registry.list(), contract: customerProductContract, supportedPlatforms: customerProductContract.targetPlatforms, runners: runnerSummary({ hosted }), platforms: platformStates({ hosted }) });
|
|
1441
|
+
json(response, 200, { csrfToken, mode: hosted ? "managed" : "local", product: "Tapp", root: hosted ? null : registry.currentRoot(), repository: hosted ? hostedRepository(registry.current()) : registry.current(), repositories: hosted ? registry.list().map(hostedRepository) : registry.list(), contract: customerProductContract, supportedPlatforms: customerProductContract.targetPlatforms, runners: runnerSummary({ hosted }), platforms: platformStates({ hosted }), studioLink: hosted ? null : studioLinkSummary() });
|
|
1320
1442
|
return;
|
|
1321
1443
|
}
|
|
1322
1444
|
if (request.method === "GET" && url.pathname === "/api/repositories") { json(response, 200, hosted ? { current:hostedRepository(registry.current()), repositories:registry.list().map(hostedRepository) } : { current: registry.current(), repositories: registry.list() }); return; }
|
|
@@ -1572,6 +1694,17 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
|
|
|
1572
1694
|
const job = startJob(operation, async (progress) => {
|
|
1573
1695
|
const result = await replayJourney({ store, slug, flow, actorRoot: actorRootFor() || "", ownerKey, progress, alerts: account ? AlertStore.forAccount(accounts.root, account.id) : null, origin: publicOrigins[0] || "" });
|
|
1574
1696
|
logUsage("journey.run", { owner: (ownerKey || "operator").slice(0, 13), passed: result.passed });
|
|
1697
|
+
// A run on this machine reports to the linked account: the name and how it went,
|
|
1698
|
+
// never the journey, a credential or a screenshot (ADR-0011 §4). Best effort — a
|
|
1699
|
+
// Studio that cannot be reached is said in the chat and never fails the run.
|
|
1700
|
+
const link = !hosted && !account ? readStudioLink() : null;
|
|
1701
|
+
if (link) {
|
|
1702
|
+
try {
|
|
1703
|
+
const { reportStudioJourney } = await import("./studio-client.js");
|
|
1704
|
+
await reportStudioJourney({ origin: link.origin, token: link.token }, { name: flow.name || slug, platform, url: flow.url || "", steps: (flow.steps || []).length, machine: os.hostname(), passed: result.passed, executed: result.executed, total: result.total, failed: result.failed, at: result.status?.at || null });
|
|
1705
|
+
progress({ phase: "replay", text: `Reported to ${link.origin} as ${link.email || "your account"}` });
|
|
1706
|
+
} catch (error) { progress({ phase: "replay", text: `Could not report to ${link.origin}: ${error.message}` }); }
|
|
1707
|
+
}
|
|
1575
1708
|
return result;
|
|
1576
1709
|
}, null, { lane: ownerKey || OPERATOR_LANE });
|
|
1577
1710
|
job.ownerKey = ownerKey;
|