@aarwitz/tapp 0.35.8 → 0.35.9
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/bin/tapp.js +15 -2
- package/browser/app.css +39 -0
- package/browser/app.js +322 -27
- package/browser/index.html +36 -3
- package/browser/product-contract.js +1 -1
- package/browser/view-model.js +24 -0
- package/docs/BROWSER-PRODUCT.md +61 -1
- package/mcp-server/src/app-store-discovery.js +42 -0
- package/mcp-server/src/browser-product.js +349 -18
- package/mcp-server/src/engines.js +212 -0
- package/mcp-server/src/flow-runtime.js +9 -1
- package/mcp-server/src/platforms.js +18 -3
- package/mcp-server/src/web-explorer.js +24 -1
- package/mcp-server/src/web-flow.js +51 -2
- package/package.json +2 -2
|
@@ -31,7 +31,7 @@ export const customerProductContract = Object.freeze({
|
|
|
31
31
|
{ id: "platforms", label: "Platforms", capabilities: ["platform-matrix", "self-host-command", "platform-interest"] },
|
|
32
32
|
{ id: "admin", label: "Admin", capabilities: ["deployment-usage", "account-list", "platform-demand"] },
|
|
33
33
|
],
|
|
34
|
-
operations: ["initialize", "session-start", "session-act", "session-save-flow", "session-end", "gate", "audit"],
|
|
34
|
+
operations: ["initialize", "session-start", "session-act", "session-save-flow", "session-end", "gate", "audit", "agent", "agent-stop"],
|
|
35
35
|
invariants: [
|
|
36
36
|
"The Studio shows runs; it never scores or judges them. Only the deterministic gate decides.",
|
|
37
37
|
"Every run's evidence is the report.html the engine wrote; the Studio links to it rather than re-rendering it.",
|
package/browser/view-model.js
CHANGED
|
@@ -64,6 +64,12 @@ const RULES = [
|
|
|
64
64
|
export function narrate(entry = {}, { platform = "" } = {}) {
|
|
65
65
|
const text = String(entry.text || "").trim().replace(/\s+/g, " ");
|
|
66
66
|
if (!text) return null;
|
|
67
|
+
// The person's own agent talking (ADR-0012): its words, the tapp tool it reached for, a tool
|
|
68
|
+
// that answered with an error, and its final answer — each told apart at a glance.
|
|
69
|
+
if (entry.phase === "agent") return { kind: "agent", icon: "🤖", text };
|
|
70
|
+
if (entry.phase === "agent-tool") return { kind: "step", icon: "🛠️", text };
|
|
71
|
+
if (entry.phase === "agent-warning") return { kind: "warning", icon: "⚠️", text };
|
|
72
|
+
if (entry.phase === "agent-done") return { kind: "agent", icon: "✅", text };
|
|
67
73
|
const progress = text.match(/^(\d+)\/(\d+) actions(?: · (\d+) (?:states?|pages?|screens?)[^·]*)?/i);
|
|
68
74
|
if (progress) return { kind: "progress", icon: "⏳", text, current: Number(progress[1]), total: Number(progress[2]), states: progress[3] ? Number(progress[3]) : null };
|
|
69
75
|
for (const [pattern, icon] of RULES) {
|
|
@@ -99,6 +105,11 @@ export function summarize(name, result = {}, { access = "" } = {}) {
|
|
|
99
105
|
const noticedText = noticed ? ` It also found ${noticed} thing${noticed === 1 ? "" : "s"} a person would notice — faint text, controls too small to tap on a phone, copy nobody finished — listed under “Worth a look”.` : "";
|
|
100
106
|
return { tone: issues ? "caution" : noticed ? "caution" : "ready", pill, 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." : "Nothing is broken."}${noticedText}${next}` };
|
|
101
107
|
}
|
|
108
|
+
// A chat turn with the agent: what it said last, and how many turns it took. Never a verdict.
|
|
109
|
+
if (name === "agent") {
|
|
110
|
+
const turns = Number(result?.turns) || 0;
|
|
111
|
+
return { tone: result?.isError ? "caution" : "ready", pill: result?.isError ? "Stopped" : `✓ ${turns} turn${turns === 1 ? "" : "s"}`, text: String(result?.text || "Done.").slice(0, 600) };
|
|
112
|
+
}
|
|
102
113
|
if (gateOutcome) {
|
|
103
114
|
const tone = { pass: "ready", fail: "blocked", inconclusive: "caution" }[gateOutcome] || "caution";
|
|
104
115
|
const pill = { pass: "✓ Ready to merge", fail: "× Do not merge", inconclusive: "◐ Inconclusive" }[gateOutcome];
|
|
@@ -293,3 +304,16 @@ export function coverageGraph(uiMap, shots = [], { platform = "" } = {}) {
|
|
|
293
304
|
unreachable,
|
|
294
305
|
};
|
|
295
306
|
}
|
|
307
|
+
|
|
308
|
+
// app.runtapp.com driving the runtime on this person's machine (ADR-0011 §4, join B). The
|
|
309
|
+
// runtime opens the hosted page with its own address and the launch secret in the URL FRAGMENT,
|
|
310
|
+
// which a browser never sends to the server — so the hosted Studio learns where the machine is
|
|
311
|
+
// without the cloud ever seeing the secret.
|
|
312
|
+
export function parseConnectFragment(hash = "") {
|
|
313
|
+
const params = new URLSearchParams(String(hash || "").replace(/^#/, ""));
|
|
314
|
+
const origin = String(params.get("connect") || "").trim().replace(/\/$/, "");
|
|
315
|
+
const token = String(params.get("token") || "").trim();
|
|
316
|
+
if (!/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\])(?::\d{1,5})?$/.test(origin)) return null;
|
|
317
|
+
if (!/^[A-Za-z0-9_-]{20,}$/.test(token)) return null;
|
|
318
|
+
return { origin, token };
|
|
319
|
+
}
|
package/docs/BROWSER-PRODUCT.md
CHANGED
|
@@ -35,7 +35,7 @@ looping animation of a device being driven (launch, tap, tap, screenshot, ✓).
|
|
|
35
35
|
| `owner/repo`, `github.com/owner/repo` | Cloned with `gh` into an isolated workspace under `TAPP_HOME`, then the same. |
|
|
36
36
|
| `com.company.app` | Explored on the booted iOS simulator as it is (no build). |
|
|
37
37
|
| `/path/to/Demo.app`, `~/Downloads/app.apk` | Installed on the booted simulator / connected device, then explored. |
|
|
38
|
-
| a business name |
|
|
38
|
+
| a business name | Searches Apple's US App Store. Choose a matching publisher's website to start a run, or supply a URL directly. The App Store link opens the listing. |
|
|
39
39
|
|
|
40
40
|
The server classifies the input again (`classifyPrompt` in `browser/view-model.js` is shared) and
|
|
41
41
|
refuses what the mode cannot do: a hosted Studio cannot open a path or a build on your machine.
|
|
@@ -120,6 +120,53 @@ owner (`TAPP_ADMIN_EMAILS`) is never gated and marks an account paid or extends
|
|
|
120
120
|
Admin view (`POST /api/admin/plan`). There is no payment step yet: "paid" is the owner's word.
|
|
121
121
|
Nothing a local Studio does needs an account.
|
|
122
122
|
|
|
123
|
+
**Driven from app.runtapp.com (ADR-0011 §2/§4, join B).** `tapp app --connect` starts the runtime
|
|
124
|
+
on this machine and opens the hosted page with `#connect=<loopback origin>&token=<launch secret>`
|
|
125
|
+
— a fragment, so the hosted server never sees it. The page keeps the pair in this browser only
|
|
126
|
+
(`localStorage`, `tapp.connect`), takes it off the address bar, and from then on every `/api/*`
|
|
127
|
+
call goes to that origin with `Authorization: Bearer <secret>`; images and reports carry
|
|
128
|
+
`?token=` because an `<img>` cannot send a header. The runtime, started with `connectOrigin`,
|
|
129
|
+
answers CORS for exactly that origin (`Access-Control-Allow-Origin`, the preflight with
|
|
130
|
+
`Access-Control-Allow-Private-Network: true` for Chrome's local-network check), accepts the
|
|
131
|
+
bearer or the query token as the operator, still requires the CSRF token on mutations, and tells
|
|
132
|
+
every other origin nothing. The hosted page's CSP allows `http://127.0.0.1:*` and
|
|
133
|
+
`http://localhost:*` for `connect-src`, `img-src` and `media-src`; a local Studio's does not. The
|
|
134
|
+
header shows *Connected · your machine* with Disconnect, which forgets the pair. A runtime that
|
|
135
|
+
stops answering is said on the first screen, the pair is dropped, and the page carries on as a
|
|
136
|
+
visitor. A browser that refuses loopback from an https page (some do) is sent to the runtime's
|
|
137
|
+
own address, the same UI. For a visitor the cloud card says *coming soon* and takes an address
|
|
138
|
+
(`POST /api/cloud/interest` → `TAPP_HOME/cloud-interest.jsonl`, an address and a date, nothing
|
|
139
|
+
else); an existing account signs in from that card.
|
|
140
|
+
|
|
141
|
+
**Setting this machine up (ADR-0012's journey).** On a local Studio the first screen carries a
|
|
142
|
+
setup card above the prompt — *This machine* — with four steps, from one answer
|
|
143
|
+
(`GET /api/setup`): the **runtime** (tapp and Node versions, python3 and PyYAML for Flow replay,
|
|
144
|
+
disk); **your agent** (every engine found, how it is signed in, Use to choose which drives the
|
|
145
|
+
chat; a *Sign in with ChatGPT* button that runs `codex login --device-auth` and shows the link and
|
|
146
|
+
one-time code until Codex reports a plan, `POST/DELETE /api/engines/codex/sign-in`; and a field for
|
|
147
|
+
an Anthropic API key as the fallback brain, checked against Anthropic's models endpoint, kept 0600
|
|
148
|
+
under `TAPP_HOME/agent/`, shown by its last four characters, handed to Claude Code only when no
|
|
149
|
+
plan is signed in, `POST/DELETE /api/engines/api-key`); **what you'll test** (per target, what
|
|
150
|
+
`tapp doctor --json` found and the exact fix — "Install Xcode from the App Store and open it
|
|
151
|
+
once", "System Settings → Privacy & Security → Accessibility", "Install Android Studio…"); and
|
|
152
|
+
**your account** (the link, optional). It collapses to one line once an agent drives and more
|
|
153
|
+
than one target is ready, and *Check again* re-reads the machine (doctor's answer is reused for
|
|
154
|
+
30 s). The Platforms view says the same thing per platform, and on the right kind of machine
|
|
155
|
+
missing one thing it names the thing — a Mac without Xcode is told to install Xcode, not to
|
|
156
|
+
find a Mac (`platforms.js`). Claude Code's own sign-in opens a browser from a terminal, so the
|
|
157
|
+
card says to run `claude` and sign in, then Check again.
|
|
158
|
+
|
|
159
|
+
**The chat drives the person's own agent (ADR-0012).** On a local Studio, *Your agent* lists the
|
|
160
|
+
coding agents found on this machine — Claude Code, Codex, Gemini CLI — and how each is signed in:
|
|
161
|
+
a plan, an API key that bills per use, or not at all, with the fix (`mcp-server/src/engines.js`;
|
|
162
|
+
`GET/POST /api/engines`). tapp signs nobody in and holds no token. With Claude Code signed in, the
|
|
163
|
+
chat grows an input: a prompt is one `agent` operation on the operator's lane that runs
|
|
164
|
+
`claude -p … --output-format stream-json` with tapp's own MCP server attached and the tapp skill
|
|
165
|
+
appended, allowed `mcp__tapp,Read,Glob,Grep` and nothing that touches the machine; its events
|
|
166
|
+
arrive as chat lines (🤖 its words, 🛠️ the tool it reached for, ⚠️ a tool error, ✅ its answer) and
|
|
167
|
+
the thread continues with `--resume`. Stop (`agent-stop`) sends `SIGINT`. Codex and Gemini are
|
|
168
|
+
reported but do not drive the chat yet. A hosted Studio answers 401 to all of it.
|
|
169
|
+
|
|
123
170
|
**A self-hosted Studio can report to an account (ADR-0011 §4).** Results flow up; the browser
|
|
124
171
|
never reaches down. Under *Your tapp account* on a local Studio, the owner pastes a token created
|
|
125
172
|
on the hosted one (under *Your coding agent*); the local Studio checks it against that Studio,
|
|
@@ -246,3 +293,16 @@ Rules that keep it worth reading:
|
|
|
246
293
|
delivery. Anyone holding the URL can post into that channel.
|
|
247
294
|
- **Public https only.** The post comes from the server, so a webhook on localhost or a private
|
|
248
295
|
range is refused, the same rule the egress proxy enforces for exploration.
|
|
296
|
+
|
|
297
|
+
## Restricted runners: an approved browser (TM-1023)
|
|
298
|
+
|
|
299
|
+
Where the sandbox stops tapp starting Chromium itself (macOS: `bootstrap_check_in …
|
|
300
|
+
MachPortRendezvousServer: Permission denied (1100)`, SIGTRAP), use a browser started outside the
|
|
301
|
+
restriction:
|
|
302
|
+
|
|
303
|
+
- `TAPP_BROWSER_ENDPOINT=http://127.0.0.1:<port>` — tapp attaches to a Chromium already running with
|
|
304
|
+
`--remote-debugging-port=<port>`. Loopback only; refused under `TAPP_ENFORCE_PUBLIC_EGRESS=1`,
|
|
305
|
+
because tapp cannot enforce its proxy on a browser it did not start.
|
|
306
|
+
- `TAPP_BROWSER_EXECUTABLE=/path/to/chrome` — tapp starts that approved binary instead of its own.
|
|
307
|
+
|
|
308
|
+
Both apply to `tapp run`, `tapp look`, explore and audits.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Search Apple's public US software catalog. A listing identifies a possible app.
|
|
2
|
+
// The visitor chooses a publisher's website before the existing audit starts.
|
|
3
|
+
const cache = new Map();
|
|
4
|
+
let searches = [];
|
|
5
|
+
|
|
6
|
+
function website(value) {
|
|
7
|
+
try {
|
|
8
|
+
const url = new URL(value);
|
|
9
|
+
if (["https:", "http:"].includes(url.protocol) && !url.username && !url.password) return url.href;
|
|
10
|
+
} catch { /* Some publishers omit their website. */ }
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function discoverApps(input) {
|
|
15
|
+
const term = String(input).normalize("NFKC").trim();
|
|
16
|
+
if (!term || term.length > 80) return { matches: [], message: "Enter a shorter business name, or enter its website." };
|
|
17
|
+
const key = term.toLowerCase();
|
|
18
|
+
const now = Date.now();
|
|
19
|
+
const cached = cache.get(key);
|
|
20
|
+
if (cached?.until > now) return cached.result;
|
|
21
|
+
searches = searches.filter(time => now - time < 60_000);
|
|
22
|
+
if (searches.length >= 18) return { matches: [], message: "App Store search is busy. Enter the website or try again in a minute." };
|
|
23
|
+
searches.push(now);
|
|
24
|
+
try {
|
|
25
|
+
const url = new URL("https://itunes.apple.com/search");
|
|
26
|
+
url.search = new URLSearchParams({ country: "us", entity: "software", limit: "12", term });
|
|
27
|
+
const response = await fetch(url, { redirect: "error", signal: AbortSignal.timeout(6000) });
|
|
28
|
+
if (!response.ok) throw new Error("Catalog unavailable");
|
|
29
|
+
const { results } = await response.json();
|
|
30
|
+
const matches = results.filter(app => Number.isSafeInteger(app.trackId) && app.trackName &&
|
|
31
|
+
(app.trackName + " " + (app.sellerName || "")).toLowerCase().includes(key)).slice(0, 5).map(app => ({
|
|
32
|
+
name: String(app.trackName), publisher: String(app.sellerName || ""),
|
|
33
|
+
listing: "https://apps.apple.com/us/app/id" + app.trackId, website: website(app.sellerUrl),
|
|
34
|
+
}));
|
|
35
|
+
const result = { matches, message: matches.length ? "Which business did you mean?" : "No matching US App Store listing. Enter the business’s website to continue." };
|
|
36
|
+
if (cache.size >= 200) cache.delete(cache.keys().next().value);
|
|
37
|
+
cache.set(key, { until: now + 600_000, result });
|
|
38
|
+
return result;
|
|
39
|
+
} catch {
|
|
40
|
+
return { matches: [], message: "The App Store search is unavailable. You can still enter the business’s website." };
|
|
41
|
+
}
|
|
42
|
+
}
|