@blackbelt-technology/pi-dashboard-extension 0.8.0 → 0.10.0
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/.pi/skills/browser/SKILL.md +74 -28
- package/.pi/skills/browser/UPSTREAM.md +6 -3
- package/.pi/skills/browser/references/challenge.md +183 -0
- package/.pi/skills/browser/references/dashboard-relay.md +351 -0
- package/.pi/skills/browser/references/own-browser.agent.md +73 -0
- package/.pi/skills/browser/references/own-browser.md +7 -1
- package/.pi/skills/doctor/SKILL.md +1 -0
- package/.pi/skills/doctor/_lib/checks.ts +133 -0
- package/.pi/skills/doctor/_lib/derive-tokens.ts +4 -0
- package/.pi/skills/doctor/modules/apple-tools.md +2 -1
- package/.pi/skills/doctor/modules/mcp-builtin.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/mcp-builtin.md +61 -0
- package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -1
- package/.pi/skills/doctor/modules/plugins-bridges.md +14 -1
- package/.pi/skills/pi-dashboard/SKILL.md +10 -3
- package/.pi/skills/pi-dashboard/references/api-reference.md +56 -0
- package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +4 -4
- package/.pi/skills/project-init/SKILL.agent.md +70 -0
- package/.pi/skills/project-init/SKILL.md +175 -50
- package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +0 -23
- package/package.json +19 -16
- package/src/ask-user-tool.ts +69 -3
- package/src/auto-session-namer.ts +190 -50
- package/src/bridge-activation.ts +26 -0
- package/src/bridge-context.ts +21 -19
- package/src/bridge-default-model-gate.ts +38 -0
- package/src/bridge-handlers/dispatch.ts +450 -0
- package/src/bridge-handlers/forwarders.ts +616 -0
- package/src/bridge-handlers/instance.ts +220 -0
- package/src/bridge-handlers/lifecycle.ts +1030 -0
- package/src/bridge-handlers/ui-prompt-patch.ts +198 -0
- package/src/bridge-identity-log.ts +45 -0
- package/src/bridge-polling.ts +148 -0
- package/src/bridge.ts +968 -2292
- package/src/canvas-tool.ts +5 -0
- package/src/command-handler.ts +257 -42
- package/src/connection.ts +737 -25
- package/src/custom-entry-forward.ts +92 -0
- package/src/dashboard-context-injector.ts +26 -47
- package/src/empty-actionable-guard.ts +8 -3
- package/src/endpoint-resolution.ts +32 -0
- package/src/event-forwarder.ts +42 -0
- package/src/extension-identity.ts +59 -0
- package/src/flow-event-wiring.ts +1 -1
- package/src/followup-buffer.ts +1 -1
- package/src/followup-drain.ts +79 -0
- package/src/git-dir-watcher.ts +79 -0
- package/src/git-poll.ts +45 -12
- package/src/git-probe-scheduler.ts +119 -0
- package/src/git-tracker.ts +284 -0
- package/src/instance-verification.ts +31 -0
- package/src/local-token-header.ts +161 -17
- package/src/mcp-token-delivery.ts +147 -0
- package/src/message-update-coalescer.ts +342 -0
- package/src/model-refresh.ts +19 -0
- package/src/model-tracker.ts +118 -35
- package/src/multiselect-list.ts +6 -2
- package/src/multiselect-polyfill.ts +2 -2
- package/src/notify-proxy.ts +3 -0
- package/src/openspec-cli-shim.ts +1 -1
- package/src/path-gate/decide.ts +123 -0
- package/src/path-gate/grant-cache.ts +73 -0
- package/src/path-gate/grant-link.ts +108 -0
- package/src/path-gate/handler.ts +356 -0
- package/src/path-gate/index.ts +166 -0
- package/src/path-gate/resolve.ts +8 -0
- package/src/path-gate/roots.ts +140 -0
- package/src/path-gate/suppression.ts +30 -0
- package/src/path-gate/yolo-link.ts +104 -0
- package/src/pending-prompt-emitter.ts +59 -0
- package/src/pi-env.d.ts +2 -10
- package/src/plugin-event-forward-registry.ts +200 -0
- package/src/plugin-request-client.ts +114 -0
- package/src/poll-cost.ts +40 -0
- package/src/pr-status.ts +338 -0
- package/src/process-metrics.ts +77 -1
- package/src/process-scan-scheduler.ts +137 -0
- package/src/process-scanner.ts +226 -247
- package/src/project-init/dox-kb-config.ts +3 -0
- package/src/project-init/scaffold.ts +1 -4
- package/src/project-init/seed-doctrine.ts +23 -60
- package/src/project-trust.ts +119 -25
- package/src/prompt-bus.ts +13 -0
- package/src/prompt-expander.ts +5 -1
- package/src/prompt-meta.ts +64 -0
- package/src/provider-register.ts +93 -20
- package/src/retry-tracker.ts +0 -7
- package/src/role-manager.ts +27 -99
- package/src/role-model-tools.ts +6 -0
- package/src/server-auto-start.ts +202 -26
- package/src/server-launcher.ts +74 -40
- package/src/session-move.ts +23 -4
- package/src/session-sync.ts +81 -52
- package/src/slash-dispatch.ts +66 -81
- package/src/spawn-token.ts +46 -0
- package/src/stream-forward-buffer.ts +161 -0
- package/src/subagent-fanout-admission.ts +234 -0
- package/src/subagent-frame-buffer.ts +6 -2
- package/src/subagent-saturation.ts +196 -0
- package/src/subagent-tick-throttle.ts +3 -1
- package/src/terminal-reload.ts +298 -0
- package/src/tui-prompt-adapter.ts +13 -1
- package/src/usage-drain.ts +167 -0
- package/src/vault-delivery.ts +394 -0
- package/src/vault-forwarder.ts +128 -0
- package/src/vault-masker.ts +165 -0
- package/src/vault-redaction.ts +181 -0
- package/src/vcs-info.ts +264 -63
- package/.pi/skills/project-init/dox-doctrine.md +0 -146
- package/src/agent-settled.ts +0 -90
- package/src/transcript-request-guard.ts +0 -76
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# Driving a logged-in browser via the Pi Dashboard
|
|
2
|
+
|
|
3
|
+
Recipe for when the task needs a **logged-in browser** — cookies, SSO sessions,
|
|
4
|
+
work logins — and the pi session is running **on the same host as the Pi
|
|
5
|
+
Dashboard**. The dashboard hands back a loopback CDP URL that
|
|
6
|
+
`agent-browser connect` attaches to directly. Two browsers sit behind it:
|
|
7
|
+
|
|
8
|
+
- **Dedicated profile** (default) — a Chrome the dashboard starts for the
|
|
9
|
+
agent, with its own data directory. The user signs in once; the logins
|
|
10
|
+
persist.
|
|
11
|
+
- **Chrome profile** — one of the user's real Chrome profiles, driven through
|
|
12
|
+
the Playwright Chrome Extension (tab group per instance).
|
|
13
|
+
|
|
14
|
+
Authored for this repo. Unlike `web.md` / `electron.md` this is **not**
|
|
15
|
+
vendored; see [`UPSTREAM.md`](../UPSTREAM.md).
|
|
16
|
+
|
|
17
|
+
> **Legacy note.** `references/own-browser.md` (Panerelay + native-messaging
|
|
18
|
+
> host) is the older path. `browser_connect` **never** routes to Panerelay. Use
|
|
19
|
+
> `own-browser.md` only when the dashboard browser is unavailable (dashboard
|
|
20
|
+
> down, `GET /api/browser/status` is `404`, `enabled:false`, or neither the
|
|
21
|
+
> dedicated profile nor `canOpenChrome` is available) **and** that provider
|
|
22
|
+
> reports ready; otherwise halt with a clear message.
|
|
23
|
+
|
|
24
|
+
## When this recipe applies
|
|
25
|
+
|
|
26
|
+
- The target is behind a login the agent cannot perform (SSO / 2FA / internal
|
|
27
|
+
tool the user is already signed into), **and**
|
|
28
|
+
- the pi session runs on the **dashboard host** (the `cdpUrl` is loopback
|
|
29
|
+
`ws://127.0.0.1:<port>/…`; a remote session cannot dial it).
|
|
30
|
+
|
|
31
|
+
Do **not** use it for ordinary automation — the bundled browser
|
|
32
|
+
(`references/web.md`) is faster and disposable.
|
|
33
|
+
|
|
34
|
+
> **Never fall back to the bundled browser for a login-state task.** It starts
|
|
35
|
+
> logged out and `--profile` copies the profile but loses Keychain-encrypted
|
|
36
|
+
> cookies (macOS) — you would silently land logged out. If no logged-in browser
|
|
37
|
+
> is available, say so; do not "try anyway".
|
|
38
|
+
|
|
39
|
+
## Primary recipe — `browser_connect`
|
|
40
|
+
|
|
41
|
+
1. Call `browser_connect {}`. When the user names a browser, pass
|
|
42
|
+
`{target}`: `"@dedicated"`, `"@headless"`, or a `profileDirectory`.
|
|
43
|
+
The dashboard's `defaultBrowser` setting decides the first target when you
|
|
44
|
+
pass none.
|
|
45
|
+
2. Read the result:
|
|
46
|
+
|
|
47
|
+
| Result | Do |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `{browser: "dedicated" \| "profile", cdpUrl, instanceId, liveView}` | Run `agent-browser connect <cdpUrl>` and follow [`web.md`](web.md). Keep `cdpUrl` and `instanceId` for the whole task — there is no lookup endpoint. When `liveView` is `true`, do **not** call `browser_show_in_pane` for the first tab. |
|
|
50
|
+
| `{browser: "headless"}` and the task needs login state | **Stop.** Tell the user no logged-in browser is available. A headless result is a stop for a login task, never a fallback. Without login state, use the bundled `agent-browser` ([`web.md`](web.md)). |
|
|
51
|
+
| `{unavailable, options}` | Ask the user with `ask_user` which `options[].target` to use, then call `browser_connect {target}` again. Connect nothing before the answer. |
|
|
52
|
+
| `{unavailable, stopped: true}` | Stop and report `unavailable.reason`. |
|
|
53
|
+
|
|
54
|
+
3. **Report the browser used** (`browser`, and `profileDirectory` for a
|
|
55
|
+
profile) to the user.
|
|
56
|
+
4. Lost `cdpUrl` (compaction)? Call `browser_connect` again; it closes the
|
|
57
|
+
instance your session holds and connects a new one.
|
|
58
|
+
|
|
59
|
+
`browser_connect` never uses Panerelay. Denied CDP verbs fail loud (see
|
|
60
|
+
"Behaviour you must expect") and are **never** retried with a different
|
|
61
|
+
browser.
|
|
62
|
+
|
|
63
|
+
## Fallback recipe — REST, for sessions without `browser_connect`
|
|
64
|
+
|
|
65
|
+
Same dashboard, plain `curl`. Use the dashboard port (`8000` by default;
|
|
66
|
+
`PI_DASHBOARD_PORT` overrides). The REST routes do **not** apply the
|
|
67
|
+
`defaultBrowser` / `onUnavailable` policy: you choose.
|
|
68
|
+
|
|
69
|
+
1. Probe status (Step 1).
|
|
70
|
+
2. When `enabled` and `dedicated.available` are both true, get a CDP URL with
|
|
71
|
+
`POST /api/browser/dedicated/connect`; otherwise list profiles (Step 2) and
|
|
72
|
+
use `POST /api/browser/connect` with the body form `{profileDirectory}`
|
|
73
|
+
(Step 3).
|
|
74
|
+
3. Run `agent-browser connect <cdpUrl>` (Step 4); disconnect when done
|
|
75
|
+
(Step 5).
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
curl -s -X POST http://localhost:8000/api/browser/dedicated/connect
|
|
79
|
+
# → {"cdpUrl":"ws://127.0.0.1:<port>/ws/browser-cdp/<guid>","instanceId":"inst-…"}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The REST routes for the dedicated profile are
|
|
83
|
+
`POST /api/browser/dedicated/{connect,open,stop,reset}`. As an agent you call
|
|
84
|
+
only `connect` and `open`; `stop` and `reset` belong to the user in Settings.
|
|
85
|
+
|
|
86
|
+
## Prerequisites (user-facing, one time)
|
|
87
|
+
|
|
88
|
+
- **Dedicated profile**: none. Chrome starts on demand; the user signs in once
|
|
89
|
+
(see "Login wall in the dedicated profile").
|
|
90
|
+
- **Chrome profile**: Chrome + the **Playwright Chrome Extension** installed in
|
|
91
|
+
the profile you will drive (`GET /api/browser/profiles` reports `installed`
|
|
92
|
+
per profile). For zero-dialog connects, a pairing token pasted in
|
|
93
|
+
**Settings → Browser Relay** (write-only; it never comes back out). Without
|
|
94
|
+
it the user gets Chrome's **Allow** prompt on each connect.
|
|
95
|
+
|
|
96
|
+
## Step 1 — Probe status
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
curl -s http://localhost:8000/api/browser/status
|
|
100
|
+
# → {"enabled":true,"canOpenChrome":true,"operatorHosts":true,
|
|
101
|
+
# "dedicated":{"available":true,"state":"stopped",…}}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`dedicated.available` (with `enabled`) is the dedicated-profile probe.
|
|
105
|
+
`operatorHosts: true` means this dashboard can also drive the browser on an
|
|
106
|
+
**operator's own computer** (see "Browser on the user's own computer" below).
|
|
107
|
+
Its absence means an older dashboard: never pass `host` to `connect` then.
|
|
108
|
+
|
|
109
|
+
Branch on the response:
|
|
110
|
+
|
|
111
|
+
| Response | Meaning | Do |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| `404` | Plugin not loaded / disabled | The relay is not usable; report it. Do **not** fall back to the bundled browser for a login-state task. |
|
|
114
|
+
| `{"enabled":false}` | Kill switch is off | Enable it (Step 1b) or ask the user to; a `connect` will `403` until then. |
|
|
115
|
+
| `{"canOpenChrome":false}` | Host has no desktop Chrome (container / headless / no `Google Chrome`) | A Chrome profile cannot open on the dashboard host; `connect` will `503`. Use the dedicated profile when `dedicated.available`; otherwise stop — unless `operatorHosts: true` and Step 2 lists an online operator host with the profile you need (use it, see below). |
|
|
116
|
+
|
|
117
|
+
### Step 1b — Enable the relay (only if `enabled:false`)
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
curl -s -X PUT http://localhost:8000/api/browser/enabled \
|
|
121
|
+
-H 'content-type: application/json' -d '{"enabled":true}'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The kill switch is safe to flip: turning it off closes every live instance
|
|
125
|
+
first (the response returns only after they are gone).
|
|
126
|
+
|
|
127
|
+
## Step 2 — Pick a profile
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
curl -s http://localhost:8000/api/browser/profiles
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Rows are keyed by `profileDirectory`. Pick one with `"installed":true`; match a
|
|
134
|
+
`label` / `email` when the user named an account. A row's `instances` lists any
|
|
135
|
+
live connection already holding that profile.
|
|
136
|
+
|
|
137
|
+
When Step 1 reported `operatorHosts: true`, the response also carries
|
|
138
|
+
`operatorHosts[]`: one entry per **online** operator computer —
|
|
139
|
+
`{hostId, label, platform, online, canOpenChrome, profiles[]}` with the same
|
|
140
|
+
profile rows (`profileDirectory`, `label`, `email`, `installed`, `instances`).
|
|
141
|
+
The top-level `profiles` map is always the dashboard host's Chrome; operator
|
|
142
|
+
profiles never appear in it.
|
|
143
|
+
|
|
144
|
+
## Step 3 — Connect to a Chrome profile
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
curl -s -X POST http://localhost:8000/api/browser/connect \
|
|
148
|
+
-H 'content-type: application/json' \
|
|
149
|
+
-d '{"profileDirectory":"Default"}'
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Success returns `{"cdpUrl":"ws://127.0.0.1:<port>/ws/browser-cdp/<guid>","instanceId":"inst-…"}`.
|
|
153
|
+
**Keep the `instanceId`** — it is how you disconnect, and the only public handle
|
|
154
|
+
to this instance.
|
|
155
|
+
|
|
156
|
+
Branch on failure (the HTTP status is authoritative; for an operator `host`
|
|
157
|
+
see the extra reasons in the next section):
|
|
158
|
+
|
|
159
|
+
| Status | `reason` | Meaning | Do |
|
|
160
|
+
|---|---|---|---|
|
|
161
|
+
| `403` | — | Relay disabled | Enable first (Step 1b). |
|
|
162
|
+
| `409` | `not-installed` | Extension absent in that profile | Tell the user to install it in **that** profile; the store link is in Settings → Browser Relay. |
|
|
163
|
+
| `409` | `busy` | The profile already hosts a live instance (and the dashboard is configured to allow one) | Reuse the existing `instanceId` if it is yours, or `disconnect` it first. Do not retry blindly. |
|
|
164
|
+
| `503` | — | Host cannot open Chrome | Stop; do not fall back to the bundled browser for a login-state task. |
|
|
165
|
+
| `504` | — | The extension did not connect within 60 s | Almost always the user did not click **Allow**, or the pairing token mismatched (the dashboard deliberately cannot tell these apart). Ask the user to allow / re-check the token, then retry once. |
|
|
166
|
+
|
|
167
|
+
## Browser on the user's own computer (operator host)
|
|
168
|
+
|
|
169
|
+
`connect` targets the **dashboard host** unless the body names an operator
|
|
170
|
+
`hostId`:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
curl -s -X POST http://localhost:8000/api/browser/connect \
|
|
174
|
+
-H 'content-type: application/json' \
|
|
175
|
+
-d '{"profileDirectory":"Default","host":"<hostId from Step 2 operatorHosts[]>"}'
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Rules:
|
|
179
|
+
|
|
180
|
+
- Pass `host` **only when** `GET /api/browser/status` reported
|
|
181
|
+
`operatorHosts: true`. Without it, do not pass `host`, and tell the user that
|
|
182
|
+
this dashboard cannot drive the browser on their computer.
|
|
183
|
+
- When the user asks for the browser on **their own computer** (their laptop,
|
|
184
|
+
not the dashboard host), pass `host` if exactly one online operator host lists
|
|
185
|
+
that profile with `installed: true`. With several candidates, ask which one;
|
|
186
|
+
with none, say so — do not fall back to the dashboard host's Chrome.
|
|
187
|
+
- The success response is the same (`cdpUrl`, `instanceId`); continue with Step 4.
|
|
188
|
+
The operator sees a consent prompt on their computer on the first connect.
|
|
189
|
+
|
|
190
|
+
Operator-host failures (HTTP status is authoritative):
|
|
191
|
+
|
|
192
|
+
| Status | `reason` | Meaning | Do |
|
|
193
|
+
|---|---|---|---|
|
|
194
|
+
| `404` | `unknown-host` | That `hostId` is not online (offline, renamed or never registered) | Re-read Step 2 `operatorHosts[]`; if it is gone, report that the user's computer is not connected to the dashboard. |
|
|
195
|
+
| `409` | `host-busy` | The operator host is already busy with a connect | Wait briefly and retry once. |
|
|
196
|
+
| `403` | `operator-denied` | The user declined the prompt on their computer | Report that the user declined and **halt**. Never retry, never fall back to the dashboard host's Chrome. |
|
|
197
|
+
| `504` | `consent-timeout` | The user did not answer the prompt on their computer in time | Ask the user to be at their computer, then retry once. |
|
|
198
|
+
| `503` | `no-chrome` | The operator computer has no desktop Chrome | Stop; report it. |
|
|
199
|
+
| `503` | `host-gone` | The operator's dashboard window closed or reconnected mid-connect (the instance ends with it) | Re-read Step 2; reconnect once the host is back online. |
|
|
200
|
+
|
|
201
|
+
An operator instance ends whenever that window's dashboard connection ends
|
|
202
|
+
(window closed, reload, server switched, network lost) — treat `host-gone` as a
|
|
203
|
+
normal end of the task, not a bug to retry in a loop.
|
|
204
|
+
|
|
205
|
+
## Step 4 — Attach the CDP client
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
agent-browser connect "<cdpUrl from Step 3>"
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Then follow [`web.md`](web.md)'s workflow (`snapshot`, `click`, `type`, …). The
|
|
212
|
+
relay behaves like any CDP endpoint for the allowed surface.
|
|
213
|
+
|
|
214
|
+
## Step 5 — Disconnect when done
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
curl -s -X POST "http://localhost:8000/api/browser/disconnect?instanceId=<instanceId>"
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Do this as soon as the task ends (it closes the dedicated instance too). A live instance holds a **tab group open in
|
|
221
|
+
the user's Chrome**; the dashboard also auto-closes it ~30 s after the CDP
|
|
222
|
+
client detaches or disconnects, but an explicit disconnect is faster.
|
|
223
|
+
|
|
224
|
+
## Behaviour you must expect
|
|
225
|
+
|
|
226
|
+
- **One tab group per Chrome-profile instance.** The extension opens a dedicated, colour-coded
|
|
227
|
+
Chrome tab group and drives only those tabs. Do not touch the user's other
|
|
228
|
+
tabs; closing the last controlled tab ends the instance.
|
|
229
|
+
- **Policy denials are LOUD, not silent.** The relay denies a fixed set of CDP
|
|
230
|
+
verbs and unsafe navigation. A denial is a CDP error `-32000` whose message
|
|
231
|
+
reads `Denied by dashboard relay policy: <method>`:
|
|
232
|
+
- always denied: `Storage.getCookies`, `Network.getAllCookies`,
|
|
233
|
+
`Network.getCookies` (cookie exfiltration).
|
|
234
|
+
- navigation fence on `Page.navigate` / `Target.createTarget`: `file:`,
|
|
235
|
+
`javascript:`, `vbscript:`, `data:`, `blob:`, and — when the profile has
|
|
236
|
+
`allowedDomains` set — any host-less URL or a host outside the list.
|
|
237
|
+
Treat `-32000` as a hard stop: report which call was denied, do not retry it
|
|
238
|
+
in a loop, and do not try to reach the data another way.
|
|
239
|
+
- **`Browser.setDownloadBehavior` is acknowledged and dropped (ack-and-drop).**
|
|
240
|
+
Playwright `connectOverCDP` sends it during its handshake and aborts on an
|
|
241
|
+
error, so the relay answers success but never forwards it: the profile's
|
|
242
|
+
download behavior is **never** changed by you. Do not rely on download paths.
|
|
243
|
+
- **One CDP client per instance.** A second `connect` to the same `cdpUrl` is
|
|
244
|
+
closed with `Another CDP client already connected`. Use the `instanceId` you
|
|
245
|
+
already hold.
|
|
246
|
+
- **DevTools wins.** If the user opens DevTools on a controlled tab, the relay
|
|
247
|
+
reports that tab `detached` and answers its commands with
|
|
248
|
+
`Target detached: devtools`; live-view input stops until DevTools closes.
|
|
249
|
+
- **Loopback only.** Both relay endpoints reject tunnel / non-loopback peers
|
|
250
|
+
(checking `Host` and forwarding headers). A pi session that is not on the
|
|
251
|
+
dashboard host cannot use this recipe. This holds for an operator `host` too:
|
|
252
|
+
the `cdpUrl` is still served by the dashboard, so the pi session must still
|
|
253
|
+
run on the dashboard host.
|
|
254
|
+
|
|
255
|
+
## Showing the page to the user, and handing over a step
|
|
256
|
+
|
|
257
|
+
Two pi tools (registered by the dashboard's browser plugin, only when you run
|
|
258
|
+
inside the dashboard) put your tab in the user's **editor pane**, next to the
|
|
259
|
+
chat. Both take the `instanceId` from the connect result; the dashboard knows
|
|
260
|
+
*your* session from the connection, so you never pass a session id.
|
|
261
|
+
|
|
262
|
+
- **`browser_show_in_pane {instanceId, tabId?}`** — open the tab in your
|
|
263
|
+
session's pane. `tabId` defaults to the instance's most recent tab (never the
|
|
264
|
+
extension's own page). One call per 5 s per instance (`rate-limited`
|
|
265
|
+
otherwise). Errors name the cause: `disabled`, `unknown-instance`,
|
|
266
|
+
`unknown-tab`, `no-tab`, `rate-limited`. Skip it for the first tab when
|
|
267
|
+
`browser_connect` returned `liveView: true`.
|
|
268
|
+
- **`browser_await_human {instanceId, reason}`** — for a step only the human
|
|
269
|
+
can do. It opens the tab, then **blocks** on a confirm prompt reading
|
|
270
|
+
`reason`; the user acts in the pane (they can type and click there, also from
|
|
271
|
+
a phone) and presses **Done ✓** (or answers in chat). Returns `done`, or
|
|
272
|
+
`cancelled` (declined, timed out, no interactive UI — reason `no-ui`). After
|
|
273
|
+
`done`, continue with your CDP client; after `cancelled`, do not pretend the
|
|
274
|
+
step happened.
|
|
275
|
+
|
|
276
|
+
**Scope of `browser_await_human`:**
|
|
277
|
+
|
|
278
|
+
- **Chrome profile**: use it for any human step — login, 2FA, consent,
|
|
279
|
+
CAPTCHA. Continue only on `done`, then re-snapshot the same tab.
|
|
280
|
+
- **Dedicated profile**: use it only for **non-sign-in** steps (consent,
|
|
281
|
+
challenge, CAPTCHA). A sign-in goes through `dedicated/open` + `ask_user`
|
|
282
|
+
(next section) — never ask the user to type credentials in your tab.
|
|
283
|
+
|
|
284
|
+
### Login wall in the dedicated profile
|
|
285
|
+
|
|
286
|
+
When a page driven through the dedicated profile needs the user to sign in:
|
|
287
|
+
|
|
288
|
+
1. Open the sign-in page with `POST /api/browser/dedicated/open {url}`, in a
|
|
289
|
+
**hidden** tab the agent cannot see:
|
|
290
|
+
```bash
|
|
291
|
+
curl -s -X POST http://localhost:8000/api/browser/dedicated/open \
|
|
292
|
+
-H 'content-type: application/json' \
|
|
293
|
+
-d '{"url":"https://example.com/login"}'
|
|
294
|
+
```
|
|
295
|
+
Only `https:` URLs are accepted (`400` otherwise). The user can also press
|
|
296
|
+
**Open to sign in** in Settings → Browser Relay.
|
|
297
|
+
2. Ask the user with `ask_user` to sign in in that window, and wait for the
|
|
298
|
+
answer. The password never reaches you: do not read the hidden tab, do not
|
|
299
|
+
ask for credentials.
|
|
300
|
+
3. After the answer, **reload your own tab** and re-snapshot. Still a login
|
|
301
|
+
wall → report it; do not loop.
|
|
302
|
+
|
|
303
|
+
### Chrome profile closes on a password page
|
|
304
|
+
|
|
305
|
+
A Chrome-profile instance that closes after a page with a password field is
|
|
306
|
+
almost always a password-manager extension (LastPass, iCloud Passwords)
|
|
307
|
+
detaching the debugger. Diagnose it from the audit (`GET /api/browser/audit`):
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
curl -s http://localhost:8000/api/browser/audit
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
A `detach` entry for that `instanceId` with detail `closed:<reason>` (the
|
|
314
|
+
extension closed the connection) or `extension:<reason>` (another extension
|
|
315
|
+
took the tab) confirms it. `devtools` means the user opened DevTools instead.
|
|
316
|
+
Then explain the password-manager limit to the user and suggest the **dedicated
|
|
317
|
+
profile** for sign-ins. Do **not** retry the same page in that profile.
|
|
318
|
+
|
|
319
|
+
## Dedicated profile — limits and hard rules
|
|
320
|
+
|
|
321
|
+
- **One session at a time.** The dedicated profile has a single holder; a
|
|
322
|
+
second `browser_connect` / `dedicated/connect` reports the live instance
|
|
323
|
+
(409 `busy`). Ask the user whether to disconnect it or use another browser.
|
|
324
|
+
Chrome profiles isolate by tab group instead.
|
|
325
|
+
- **Same-user limit.** The dedicated profile is **not** protected from other
|
|
326
|
+
programs running as the same OS user. Do not store anything there you would
|
|
327
|
+
not want those programs to read.
|
|
328
|
+
- **Never touch its directories.** The agent MUST NOT read, copy, or launch a
|
|
329
|
+
browser on the dedicated profile directory (`~/.pi/dashboard/agent-chrome`).
|
|
330
|
+
It MUST NOT read the dedicated downloads directory
|
|
331
|
+
(`~/.pi/dashboard/agent-chrome-downloads`) unless its task names a file
|
|
332
|
+
there. Reach the browser only through the CDP URL.
|
|
333
|
+
- **Downloads** are pinned to that downloads directory by the dashboard;
|
|
334
|
+
`Browser.setDownloadBehavior` from you is acknowledged and dropped.
|
|
335
|
+
- **Idle disconnect.** The instance closes after the configured idle time
|
|
336
|
+
(default 30 min), not while a `browser_await_human` is pending. Reconnect
|
|
337
|
+
with `browser_connect`.
|
|
338
|
+
|
|
339
|
+
## Diagnostics
|
|
340
|
+
|
|
341
|
+
- Settings → Browser Relay shows the audit trail (`GET /api/browser/audit`) —
|
|
342
|
+
`denied` rows name the refused verb, `navigate` rows name the URL (without
|
|
343
|
+
query string or fragment), `detach` rows carry the cause (`closed:`,
|
|
344
|
+
`extension:`, `devtools`, `idle`).
|
|
345
|
+
- `POST /api/browser/disconnect` then reconnect to clear a wedged instance.
|
|
346
|
+
- The dashboard shows the same instance as editor-pane tabs
|
|
347
|
+
(`browser:<instanceId>:<tabId>`, opened from the session-card badge menu or by
|
|
348
|
+
`browser_show_in_pane`); if a tab shows the idle indicator (`no-frames`), the
|
|
349
|
+
page simply has not repainted (idle or hidden), which is normal.
|
|
350
|
+
- Audit `open` rows record every `browser_show_in_pane` / `browser_await_human`
|
|
351
|
+
call, accepted or refused; `dropped` rows record ack-and-drop verbs.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# own-browser.md — own logged-in browser index
|
|
2
|
+
|
|
3
|
+
Pull-only condensed map. Source: packages/extension/.pi/skills/browser/references/own-browser.md. Recipe: drive user's real browser (cookies, SSO, extensions) via Panerelay MV3 extension + native-messaging host. Not vendored; see `../UPSTREAM.md`.
|
|
4
|
+
|
|
5
|
+
Legacy path: prefer Pi Dashboard browser relay `dashboard-relay.md` when pi runs on dashboard host. Use this only when agent cannot reach loopback dashboard.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
- Target behind login agent cannot perform: SSO/2FA, internal tools, existing Gmail/Slack/Jira session.
|
|
9
|
+
- Not for ordinary automation → default bundled browser `references/web.md`.
|
|
10
|
+
|
|
11
|
+
## Dead ends (do not retry)
|
|
12
|
+
- `--remote-debugging-port` / `--cdp <port>`: Chrome M136+ refuses on real profile (Safe Storage HMAC).
|
|
13
|
+
- `--auto-connect`: needs `DevToolsActivePort`; absent in normal sessions.
|
|
14
|
+
- `--profile Default`: temp copy; macOS Keychain cookies undecryptable → logged out. Upstream vercel-labs/agent-browser#1319.
|
|
15
|
+
|
|
16
|
+
## Trade-off
|
|
17
|
+
- Extension path loses CDP: no `network route`, no isolated worlds, no `trace`/`profiler`. Need those → bundled browser.
|
|
18
|
+
|
|
19
|
+
## Strategy table
|
|
20
|
+
- No login → `references/web.md`.
|
|
21
|
+
- Agent-performable login → `auth save` + `auth login`, or `--session-name`.
|
|
22
|
+
- Auth replay headless → `state save` / `--state <path>`.
|
|
23
|
+
- Live SSO/2FA/user session → Panerelay.
|
|
24
|
+
|
|
25
|
+
## Setup
|
|
26
|
+
- Require `agent-browser >= 0.33.0` (`--provider <plugin name>`). Check: `agent-browser --version`.
|
|
27
|
+
- Consent gate: do NOT run installer autonomously (Step 0a of `../SKILL.md`). Diagnostics `doctor`, `check-panerelay.sh` read-only, safe.
|
|
28
|
+
- Install command for user: `npx --yes @panerelay/setup --agent-browser` (omit `--global-default`). Writes native host, registers `panerelay` in `~/.agent-browser/config.json`.
|
|
29
|
+
- User steps: install extension from Web Store; open side panel (connection registers on open). Agent cannot do this.
|
|
30
|
+
- Dedicated profile recommended: `--profile-directory="AgentAutomation"`. macOS path `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`; Linux `google-chrome`; Windows `chrome.exe`.
|
|
31
|
+
- Extension perms: `debugger`, `nativeMessaging`, `scripting`. Install only in that profile.
|
|
32
|
+
- Check `npm view @panerelay/setup` + repo age/stars before recommending; say dependency is new.
|
|
33
|
+
- Containment check: native-host manifest `allowed_origins` = exactly one `chrome-extension://<id>/`.
|
|
34
|
+
- Manifest dirs: macOS `~/Library/Application Support/Google/Chrome/NativeMessagingHosts/`; Linux `~/.config/google-chrome/NativeMessagingHosts/`; Windows `HKCU\Software\Google\Chrome\NativeMessagingHosts\`.
|
|
35
|
+
- Linux/Windows paths unverified (verified macOS). Confirm: `npx --yes @panerelay/setup doctor`.
|
|
36
|
+
|
|
37
|
+
## Profiles
|
|
38
|
+
- List: `agent-browser profiles` (left col = profile dir; label not valid selector).
|
|
39
|
+
- Bundled copied profile: `agent-browser --profile "Profile 21" open <url>` (loses macOS logins).
|
|
40
|
+
- Panerelay: no per-command profile flag; profile = where extension installed.
|
|
41
|
+
- Launch flags (`--profile`, `--headed`, `--cdp`) ignored if daemon running → `agent-browser close --all` first.
|
|
42
|
+
|
|
43
|
+
## Verify
|
|
44
|
+
- `bash scripts/check-panerelay.sh` → `key=value`: `AGENT_BROWSER`, `VERSION_OK`, `PLUGIN=registered`, `GLOBAL_DEFAULT`, `NATIVE_HOST`, `EXTENSION=connected`, `TABS`, `READY`; failure emits `NEXT=`.
|
|
45
|
+
- `--deep` adds `@panerelay/setup doctor` (npx + network).
|
|
46
|
+
- Identity test: `agent-browser --session panerelay-task --provider panerelay eval "navigator.userAgent"` → real Chrome version; bundled → `HeadlessChrome`. Both HeadlessChrome → `PLUGIN=registered` check.
|
|
47
|
+
|
|
48
|
+
## Use
|
|
49
|
+
- `agent-browser --session panerelay-task --provider panerelay <tab list|open <url>|snapshot -i>`. Stable `--session` name keeps attachment.
|
|
50
|
+
|
|
51
|
+
## Multiple browsers
|
|
52
|
+
- Extension registers per browser process. Multiple ready → call fails.
|
|
53
|
+
- Select: `PANERELAY_BROWSER_ID=<id> agent-browser --session ... --provider panerelay tab list`. IDs from `check-panerelay.sh` (`BROWSER_ID=` lines). Try each; real one lists tabs.
|
|
54
|
+
- Wrong ones: `about:blank` only, or `CDP error (Target.createTarget): No current window`.
|
|
55
|
+
- Alt: default set in side panel.
|
|
56
|
+
- Error `Plugin 'panerelay' returned success=false` hides real message. Probe native host directly: `echo '{"protocol":"agent-browser.plugin.v1","type":"browser.launch","capability":"browser.provider","request":{"sessionName":"probe"}}' | node ~/.panerelay/bin/panerelay-native-host.cjs --agent-browser-plugin`.
|
|
57
|
+
- `@panerelay/setup doctor` shows ✅ connected even when provider calls fail.
|
|
58
|
+
|
|
59
|
+
## Troubleshooting
|
|
60
|
+
- `Multiple Panerelay browsers are ready` → set `PANERELAY_BROWSER_ID`.
|
|
61
|
+
- Still fails after fix → daemon sticks to first browser; retry under fresh `--session`. Do NOT `close --all` (closes unrelated sessions). Challenge → `challenge.md`.
|
|
62
|
+
- `No current window` → `PANERELAY_BROWSER_ID` window closed; pick another.
|
|
63
|
+
- `Creating a new tab requires all-tabs authorization` → side panel: authorize all tabs (per-tab default).
|
|
64
|
+
- `Extension is not currently connected` → install in profile / open side panel.
|
|
65
|
+
- `--provider` rejected → CLI < 0.33.0.
|
|
66
|
+
- Wrong browser → `--provider panerelay` dropped; run userAgent test.
|
|
67
|
+
- Works in one profile only → expected; extension per-profile.
|
|
68
|
+
|
|
69
|
+
## Rollback
|
|
70
|
+
- `npx --yes @panerelay/setup uninstall`; then remove extension and delete dedicated profile dir.
|
|
71
|
+
|
|
72
|
+
## Related
|
|
73
|
+
- `web.md` (default browser), `electron.md`, `../scripts/check-panerelay.sh`.
|
|
@@ -7,6 +7,12 @@ Chrome for Testing that `agent-browser` launches by default.
|
|
|
7
7
|
Not vendored from upstream. Authored for this repo; see
|
|
8
8
|
[`UPSTREAM.md`](../UPSTREAM.md).
|
|
9
9
|
|
|
10
|
+
> **Legacy path.** The Pi Dashboard browser relay
|
|
11
|
+
> ([`dashboard-relay.md`](dashboard-relay.md)) is preferred whenever the pi
|
|
12
|
+
> session runs on the dashboard host — it needs no native-messaging host and
|
|
13
|
+
> the dashboard holds the pairing token. Use this Panerelay recipe only when
|
|
14
|
+
> the agent runs elsewhere and cannot reach a loopback dashboard.
|
|
15
|
+
|
|
10
16
|
## When this recipe applies
|
|
11
17
|
|
|
12
18
|
Use it when the target is behind a login the agent cannot perform: SSO /
|
|
@@ -274,7 +280,7 @@ call fails.
|
|
|
274
280
|
|---|---|
|
|
275
281
|
| `Plugin 'panerelay' returned success=false` (no detail) | Generic wrapper for any plugin error. Query the native host directly (above) or run `check-panerelay.sh` to get the real message. Most often multiple ready browsers. |
|
|
276
282
|
| `Multiple Panerelay browsers are ready` | Several browser processes carry the extension. Set `PANERELAY_BROWSER_ID` — see the section above. |
|
|
277
|
-
| Still fails right after fixing the real cause | The session daemon **sticks to the browser it first resolved**. Re-run under a fresh `--session` name. Do **not** use `close --all` to clear it — it is not session-scoped and closes every session, including unrelated ones. |
|
|
283
|
+
| Still fails right after fixing the real cause | The session daemon **sticks to the browser it first resolved**. Re-run under a fresh `--session` name (provider-resolution failures only — on a challenge follow [`challenge.md`](challenge.md)). Do **not** use `close --all` to clear it — it is not session-scoped and closes every session, including unrelated ones. |
|
|
278
284
|
| `CDP error (Target.createTarget): No current window` | That `PANERELAY_BROWSER_ID` names a registration whose window has closed. Pick another. |
|
|
279
285
|
| `Creating a new tab requires all-tabs authorization` | Panerelay defaults to **per-tab** consent. Open the side panel and authorize all tabs, or drive an already-authorized tab. Safe to grant inside a dedicated profile. |
|
|
280
286
|
| `Extension is not currently connected` | Extension not installed in the profile, or its side panel was never opened. Open the panel. |
|
|
@@ -28,6 +28,7 @@ CHECKS · FIX ROUTING · DERIVES-FROM** (+ a `<id>.knowledge.hash` sidecar).
|
|
|
28
28
|
| `model-resolution` | model:resolve handler, roles/preset, @role resolvability |
|
|
29
29
|
| `apple-tools` | iMCP (Apple PIM) provisioning state for the apple-tools plugin |
|
|
30
30
|
| `oauth-redirect-base` | which OAuth redirect base won + its tier (reverse-proxy `redirect_uri_mismatch`) |
|
|
31
|
+
| `mcp-builtin` | pi built-in MCP + per-session `pi-dashboard` registration (adapter installed, shadowing entry, non-strict `mcp.json`) |
|
|
31
32
|
|
|
32
33
|
## How to route
|
|
33
34
|
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
* See change: add-modular-doctor-skill (design.md D4/D8, spec: Derive-on-run).
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { readFileSync } from "node:fs";
|
|
11
12
|
import { createRequire } from "node:module";
|
|
13
|
+
import os from "node:os";
|
|
14
|
+
import path from "node:path";
|
|
12
15
|
import {
|
|
13
16
|
enumeratePiInstalls,
|
|
14
17
|
type PiInstall,
|
|
@@ -121,3 +124,133 @@ export function detectNameSkew(
|
|
|
121
124
|
return { resolvedName: null, staleNames: stale, tier: null, resolvedPath: null };
|
|
122
125
|
}
|
|
123
126
|
|
|
127
|
+
|
|
128
|
+
// ── pi built-in MCP (change: migrate-mcp-to-pi-builtin) ─────────────────────
|
|
129
|
+
|
|
130
|
+
export interface McpBuiltinFinding {
|
|
131
|
+
id: "adapter-disables-builtin" | "operator-entry-shadows-registration" | "mcp-json-not-strict";
|
|
132
|
+
/** The file the finding is about. */
|
|
133
|
+
path: string;
|
|
134
|
+
message: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface McpBuiltinCheckOptions {
|
|
138
|
+
/** Defaults to `$PI_CODING_AGENT_DIR` or `~/.pi/agent`. */
|
|
139
|
+
agentDir?: string;
|
|
140
|
+
/** When set, `<cwd>/.pi/settings.json` and `<cwd>/.pi/mcp.json` are checked too. */
|
|
141
|
+
cwd?: string;
|
|
142
|
+
/** Test seam; defaults to `fs.readFileSync` (null when absent). */
|
|
143
|
+
readFile?: (path: string) => string | null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const ADAPTER_SOURCE = "npm:pi-mcp-adapter";
|
|
147
|
+
|
|
148
|
+
function packageSourceOf(entry: unknown): string | null {
|
|
149
|
+
if (typeof entry === "string") return entry;
|
|
150
|
+
if (entry && typeof entry === "object" && typeof (entry as { source?: unknown }).source === "string") {
|
|
151
|
+
return (entry as { source: string }).source;
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function isAdapterSource(source: string): boolean {
|
|
157
|
+
try {
|
|
158
|
+
if (sourcesMatch(source, ADAPTER_SOURCE)) return true;
|
|
159
|
+
} catch {
|
|
160
|
+
/* unparseable source → fall through to the path test */
|
|
161
|
+
}
|
|
162
|
+
return /(^|[\\/])pi-mcp-adapter[\\/]?$/.test(source);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Three read-only diagnostics for pi's built-in MCP, one finding each:
|
|
167
|
+
* - `pi-mcp-adapter` in a settings `packages[]` registers `/mcp` and so
|
|
168
|
+
* DISABLES the built-in MCP — and with it the dashboard's per-session
|
|
169
|
+
* `pi-dashboard` registration (the bridge cannot see this; pi reports it as
|
|
170
|
+
* an extension error, not a throw).
|
|
171
|
+
* - an operator-authored `pi-dashboard` entry in the global `mcp.json` takes
|
|
172
|
+
* precedence over the registration (the dashboard-provisioned shape is
|
|
173
|
+
* removed at server start and is NOT reported).
|
|
174
|
+
* - an `mcp.json` that is not strict JSON (comments, trailing commas) is
|
|
175
|
+
* skipped WHOLE by pi; the file path is named.
|
|
176
|
+
* Never writes, never throws.
|
|
177
|
+
*/
|
|
178
|
+
export function checkMcpBuiltin(opts: McpBuiltinCheckOptions = {}): McpBuiltinFinding[] {
|
|
179
|
+
const agentDir =
|
|
180
|
+
opts.agentDir ?? (process.env.PI_CODING_AGENT_DIR || path.join(os.homedir(), ".pi", "agent"));
|
|
181
|
+
const read =
|
|
182
|
+
opts.readFile ??
|
|
183
|
+
((p: string): string | null => {
|
|
184
|
+
try {
|
|
185
|
+
return readFileSync(p, "utf8");
|
|
186
|
+
} catch {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const findings: McpBuiltinFinding[] = [];
|
|
191
|
+
|
|
192
|
+
const settingsFiles = [path.join(agentDir, "settings.json")];
|
|
193
|
+
if (opts.cwd) settingsFiles.push(path.join(opts.cwd, ".pi", "settings.json"));
|
|
194
|
+
for (const file of settingsFiles) {
|
|
195
|
+
const raw = read(file);
|
|
196
|
+
if (raw === null) continue;
|
|
197
|
+
let packages: unknown;
|
|
198
|
+
try {
|
|
199
|
+
packages = (JSON.parse(raw) as { packages?: unknown }).packages;
|
|
200
|
+
} catch {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (!Array.isArray(packages)) continue;
|
|
204
|
+
if (packages.some((e) => {
|
|
205
|
+
const s = packageSourceOf(e);
|
|
206
|
+
return s !== null && isAdapterSource(s);
|
|
207
|
+
})) {
|
|
208
|
+
findings.push({
|
|
209
|
+
id: "adapter-disables-builtin",
|
|
210
|
+
path: file,
|
|
211
|
+
message:
|
|
212
|
+
`pi-mcp-adapter is listed in ${file} packages[]: it takes over /mcp and DISABLES pi's built-in MCP, ` +
|
|
213
|
+
"so the dashboard's pi-dashboard MCP tools are unavailable in sessions. Fix: remove it from packages[] " +
|
|
214
|
+
"(convert adapter-only `disabled: true` entries to `enabled: false` in the MCP settings first).",
|
|
215
|
+
});
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const mcpFiles = [path.join(agentDir, "mcp.json")];
|
|
221
|
+
if (opts.cwd) mcpFiles.push(path.join(opts.cwd, ".pi", "mcp.json"));
|
|
222
|
+
for (const [i, file] of mcpFiles.entries()) {
|
|
223
|
+
const raw = read(file);
|
|
224
|
+
if (raw === null) continue;
|
|
225
|
+
let parsed: unknown;
|
|
226
|
+
try {
|
|
227
|
+
parsed = JSON.parse(raw);
|
|
228
|
+
} catch (e) {
|
|
229
|
+
findings.push({
|
|
230
|
+
id: "mcp-json-not-strict",
|
|
231
|
+
path: file,
|
|
232
|
+
message: `${file} is not strict JSON (${(e as Error).message}); pi skips the whole file. Remove comments and trailing commas.`,
|
|
233
|
+
});
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (i !== 0) continue; // the shadow check concerns the global file only
|
|
237
|
+
const entry = (parsed as { mcpServers?: Record<string, unknown> } | null)?.mcpServers?.["pi-dashboard"];
|
|
238
|
+
if (entry === undefined || entry === null || typeof entry !== "object") continue;
|
|
239
|
+
const rhc = (entry as { requestHeadersCommand?: { command?: unknown; args?: unknown } }).requestHeadersCommand;
|
|
240
|
+
const provisioned =
|
|
241
|
+
rhc?.command === "node" &&
|
|
242
|
+
Array.isArray(rhc.args) &&
|
|
243
|
+
typeof rhc.args[0] === "string" &&
|
|
244
|
+
/(^|[\\/])header-command\.mjs$/.test(rhc.args[0]);
|
|
245
|
+
if (!provisioned) {
|
|
246
|
+
findings.push({
|
|
247
|
+
id: "operator-entry-shadows-registration",
|
|
248
|
+
path: file,
|
|
249
|
+
message:
|
|
250
|
+
`${file} defines its own "pi-dashboard" MCP server; pi prefers it over the dashboard's per-session ` +
|
|
251
|
+
"registration. Remove or rename it unless you intend to override the dashboard endpoint.",
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return findings;
|
|
256
|
+
}
|
|
@@ -26,6 +26,10 @@ export const MODULE_TOKEN_SOURCES: Record<string, string[]> = {
|
|
|
26
26
|
"install-topology": ["packages/shared/src/dashboard-paths.ts"],
|
|
27
27
|
"model-resolution": ["packages/extension/src/provider-register.ts"],
|
|
28
28
|
"oauth-redirect-base": ["packages/server/src/auth/auth.ts", "packages/server/src/routes/system-routes.ts"],
|
|
29
|
+
"mcp-builtin": [
|
|
30
|
+
"packages/extension/src/mcp-token-delivery.ts",
|
|
31
|
+
"packages/mcp-server-plugin/src/server/legacy-entry-migration.ts",
|
|
32
|
+
],
|
|
29
33
|
};
|
|
30
34
|
|
|
31
35
|
/**
|
|
@@ -16,7 +16,8 @@ derives-from:
|
|
|
16
16
|
|
|
17
17
|
## SCOPE
|
|
18
18
|
Whether iMCP is provisioned for the `apple-tools` plugin on this host: platform,
|
|
19
|
-
macOS version floor, `imcp-server` discovery, and the
|
|
19
|
+
macOS version floor, `imcp-server` discovery, and the `mcp.json` write (pi's
|
|
20
|
+
built-in MCP; `settings.json` is never written). macOS
|
|
20
21
|
only — a non-macOS host is inert, never a fault.
|
|
21
22
|
|
|
22
23
|
## KNOWLEDGE
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
d48ae6dceec2cfc5
|