@blackbelt-technology/pi-dashboard-extension 0.9.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.
Files changed (56) hide show
  1. package/.pi/skills/browser/SKILL.md +12 -7
  2. package/.pi/skills/browser/references/dashboard-relay.md +232 -31
  3. package/.pi/skills/browser/references/own-browser.agent.md +73 -0
  4. package/.pi/skills/pi-dashboard/references/api-reference.md +56 -0
  5. package/.pi/skills/project-init/SKILL.agent.md +70 -0
  6. package/.pi/skills/project-init/SKILL.md +136 -24
  7. package/package.json +8 -8
  8. package/src/ask-user-tool.ts +65 -3
  9. package/src/auto-session-namer.ts +190 -50
  10. package/src/bridge-handlers/dispatch.ts +450 -0
  11. package/src/bridge-handlers/forwarders.ts +616 -0
  12. package/src/bridge-handlers/instance.ts +220 -0
  13. package/src/bridge-handlers/lifecycle.ts +1030 -0
  14. package/src/bridge-handlers/ui-prompt-patch.ts +198 -0
  15. package/src/bridge-identity-log.ts +45 -0
  16. package/src/bridge.ts +480 -2510
  17. package/src/command-handler.ts +180 -11
  18. package/src/connection.ts +265 -18
  19. package/src/dashboard-context-injector.ts +26 -47
  20. package/src/empty-actionable-guard.ts +8 -3
  21. package/src/flow-event-wiring.ts +1 -1
  22. package/src/followup-buffer.ts +1 -1
  23. package/src/followup-drain.ts +79 -0
  24. package/src/local-token-header.ts +161 -17
  25. package/src/message-update-coalescer.ts +3 -1
  26. package/src/model-refresh.ts +19 -0
  27. package/src/multiselect-list.ts +6 -2
  28. package/src/multiselect-polyfill.ts +2 -2
  29. package/src/openspec-cli-shim.ts +1 -1
  30. package/src/path-gate/decide.ts +15 -41
  31. package/src/path-gate/grant-cache.ts +3 -1
  32. package/src/path-gate/handler.ts +51 -2
  33. package/src/path-gate/index.ts +12 -1
  34. package/src/path-gate/resolve.ts +6 -124
  35. package/src/path-gate/roots.ts +4 -1
  36. package/src/path-gate/suppression.ts +4 -1
  37. package/src/path-gate/yolo-link.ts +104 -0
  38. package/src/plugin-event-forward-registry.ts +200 -0
  39. package/src/project-trust.ts +119 -25
  40. package/src/prompt-expander.ts +5 -1
  41. package/src/prompt-meta.ts +64 -0
  42. package/src/provider-register.ts +87 -20
  43. package/src/role-manager.ts +5 -4
  44. package/src/server-auto-start.ts +12 -5
  45. package/src/server-launcher.ts +11 -13
  46. package/src/session-move.ts +19 -0
  47. package/src/session-sync.ts +31 -38
  48. package/src/spawn-token.ts +46 -0
  49. package/src/stream-forward-buffer.ts +161 -0
  50. package/src/subagent-frame-buffer.ts +6 -2
  51. package/src/subagent-tick-throttle.ts +3 -1
  52. package/src/vault-delivery.ts +394 -0
  53. package/src/vault-forwarder.ts +128 -0
  54. package/src/vault-masker.ts +165 -0
  55. package/src/vault-redaction.ts +181 -0
  56. package/src/vcs-info.ts +5 -2
@@ -26,9 +26,9 @@ Three recipes:
26
26
  Reference: [`references/electron.md`](references/electron.md).
27
27
  - **The user's own logged-in browser** — reach SSO/2FA-gated sites using the
28
28
  user's real cookies. Two paths:
29
- - **Pi Dashboard browser relay** (preferred when the pi session runs on the
30
- dashboard host) — pair the Playwright Chrome Extension, connect to a
31
- loopback CDP URL. Reference:
29
+ - **Pi Dashboard browser** (preferred when the pi session runs on the
30
+ dashboard host) — `browser_connect` hands back a loopback CDP URL for the
31
+ dedicated profile or a Chrome profile (Playwright Chrome Extension). Reference:
32
32
  [`references/dashboard-relay.md`](references/dashboard-relay.md).
33
33
  - **Panerelay extension bridge** (legacy) — a native-messaging host for when
34
34
  there is no loopback dashboard. Reference:
@@ -108,11 +108,16 @@ tool the agent cannot sign into — route to a login-state recipe regardless of
108
108
  the probe. Pick by capability, in this order:
109
109
 
110
110
  1. **`references/dashboard-relay.md`** when the pi session runs on the
111
- dashboard host and the probe's `RELAY` is a JSON object with
112
- `"enabled":true` and `"canOpenChrome":true`. This is the preferred path;
113
- it needs no extra install and the dashboard holds the pairing token.
111
+ dashboard host and the dashboard browser is available. This is the preferred
112
+ path; it needs no extra install. Call `browser_connect {}` first (it picks
113
+ the dedicated profile by default); without that tool, use the recipe's REST
114
+ fallback — the probe's `RELAY` must be a JSON object with `"enabled":true`
115
+ and either `dedicated.available` or `"canOpenChrome":true`. A `headless`
116
+ result from `browser_connect` for a login task is a stop, not a fallback.
114
117
  2. **`references/own-browser.md`** (legacy Panerelay bridge) only when the
115
- relay is unavailable (`RELAY=unavailable`) or the session is remote.
118
+ dashboard browser is unavailable (`RELAY=unavailable`, `enabled:false`) or
119
+ the session is remote. `browser_connect` never routes to Panerelay; this
120
+ step is yours.
116
121
 
117
122
  The default bundled browser starts logged out and cannot be made to inherit
118
123
  those logins; `--profile` copies the profile and still loses macOS
@@ -1,19 +1,25 @@
1
- # Driving the user's real Chrome via the Pi Dashboard browser relay
1
+ # Driving a logged-in browser via the Pi Dashboard
2
2
 
3
- Recipe for when the task needs the user's **real, logged-in Chrome** — their
4
- cookies, SSO sessions, work logins, installed extensions — and the pi session
5
- is running **on the same host as the Pi Dashboard**. The relay pairs the
6
- Playwright Chrome Extension with the dashboard and hands back a loopback CDP
7
- URL that `agent-browser connect` can attach to directly.
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).
8
13
 
9
14
  Authored for this repo. Unlike `web.md` / `electron.md` this is **not**
10
15
  vendored; see [`UPSTREAM.md`](../UPSTREAM.md).
11
16
 
12
17
  > **Legacy note.** `references/own-browser.md` (Panerelay + native-messaging
13
- > host) is the older path. Prefer **this** recipe whenever the pi session runs
14
- > on the dashboard host — it needs no native-messaging host install and the
15
- > dashboard already holds the pairing token. Keep `own-browser.md` for the case
16
- > where the agent runs elsewhere and cannot reach a loopback dashboard.
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.
17
23
 
18
24
  ## When this recipe applies
19
25
 
@@ -27,32 +33,86 @@ Do **not** use it for ordinary automation — the bundled browser
27
33
 
28
34
  > **Never fall back to the bundled browser for a login-state task.** It starts
29
35
  > logged out and `--profile` copies the profile but loses Keychain-encrypted
30
- > cookies (macOS) — you would silently land logged out. If the relay is
31
- > unavailable, say so; do not "try anyway".
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.
32
85
 
33
86
  ## Prerequisites (user-facing, one time)
34
87
 
35
- 1. Chrome + the **Playwright Chrome Extension** installed in the profile you
36
- will drive. `GET /api/browser/profiles` reports `installed` per profile.
37
- 2. For zero-dialog connects, a pairing token pasted in
38
- **Settings → Browser Relay** (write-only; it never comes back out). Without
39
- it the user gets Chrome's **Allow** prompt on each connect.
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.
40
95
 
41
96
  ## Step 1 — Probe status
42
97
 
43
98
  ```bash
44
99
  curl -s http://localhost:8000/api/browser/status
45
- # → {"enabled":true,"canOpenChrome":true}
100
+ # → {"enabled":true,"canOpenChrome":true,"operatorHosts":true,
101
+ # "dedicated":{"available":true,"state":"stopped",…}}
46
102
  ```
47
103
 
48
- Use the dashboard port (`8000` by default; `PI_DASHBOARD_PORT` overrides).
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
+
49
109
  Branch on the response:
50
110
 
51
111
  | Response | Meaning | Do |
52
112
  |---|---|---|
53
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. |
54
114
  | `{"enabled":false}` | Kill switch is off | Enable it (Step 1b) or ask the user to; a `connect` will `403` until then. |
55
- | `{"canOpenChrome":false}` | Host has no desktop Chrome (container / headless / no `Google Chrome`) | The relay cannot open a profile; `connect` will `503`. Stop. |
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). |
56
116
 
57
117
  ### Step 1b — Enable the relay (only if `enabled:false`)
58
118
 
@@ -74,7 +134,14 @@ Rows are keyed by `profileDirectory`. Pick one with `"installed":true`; match a
74
134
  `label` / `email` when the user named an account. A row's `instances` lists any
75
135
  live connection already holding that profile.
76
136
 
77
- ## Step 3 — Connect
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
78
145
 
79
146
  ```bash
80
147
  curl -s -X POST http://localhost:8000/api/browser/connect \
@@ -86,7 +153,8 @@ Success returns `{"cdpUrl":"ws://127.0.0.1:<port>/ws/browser-cdp/<guid>","instan
86
153
  **Keep the `instanceId`** — it is how you disconnect, and the only public handle
87
154
  to this instance.
88
155
 
89
- Branch on failure (the HTTP status is authoritative):
156
+ Branch on failure (the HTTP status is authoritative; for an operator `host`
157
+ see the extra reasons in the next section):
90
158
 
91
159
  | Status | `reason` | Meaning | Do |
92
160
  |---|---|---|---|
@@ -96,6 +164,44 @@ Branch on failure (the HTTP status is authoritative):
96
164
  | `503` | — | Host cannot open Chrome | Stop; do not fall back to the bundled browser for a login-state task. |
97
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. |
98
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
+
99
205
  ## Step 4 — Attach the CDP client
100
206
 
101
207
  ```bash
@@ -111,25 +217,29 @@ relay behaves like any CDP endpoint for the allowed surface.
111
217
  curl -s -X POST "http://localhost:8000/api/browser/disconnect?instanceId=<instanceId>"
112
218
  ```
113
219
 
114
- Do this as soon as the task ends. A live instance holds a **tab group open in
220
+ Do this as soon as the task ends (it closes the dedicated instance too). A live instance holds a **tab group open in
115
221
  the user's Chrome**; the dashboard also auto-closes it ~30 s after the CDP
116
222
  client detaches or disconnects, but an explicit disconnect is faster.
117
223
 
118
224
  ## Behaviour you must expect
119
225
 
120
- - **One tab group per instance.** The extension opens a dedicated, colour-coded
226
+ - **One tab group per Chrome-profile instance.** The extension opens a dedicated, colour-coded
121
227
  Chrome tab group and drives only those tabs. Do not touch the user's other
122
228
  tabs; closing the last controlled tab ends the instance.
123
229
  - **Policy denials are LOUD, not silent.** The relay denies a fixed set of CDP
124
230
  verbs and unsafe navigation. A denial is a CDP error `-32000` whose message
125
231
  reads `Denied by dashboard relay policy: <method>`:
126
232
  - always denied: `Storage.getCookies`, `Network.getAllCookies`,
127
- `Network.getCookies` (cookie exfiltration), `Browser.setDownloadBehavior`.
233
+ `Network.getCookies` (cookie exfiltration).
128
234
  - navigation fence on `Page.navigate` / `Target.createTarget`: `file:`,
129
- `javascript:`, `data:`, `blob:`, and — when the profile has
235
+ `javascript:`, `vbscript:`, `data:`, `blob:`, and — when the profile has
130
236
  `allowedDomains` set — any host-less URL or a host outside the list.
131
237
  Treat `-32000` as a hard stop: report which call was denied, do not retry it
132
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.
133
243
  - **One CDP client per instance.** A second `connect` to the same `cdpUrl` is
134
244
  closed with `Another CDP client already connected`. Use the `instanceId` you
135
245
  already hold.
@@ -138,13 +248,104 @@ client detaches or disconnects, but an explicit disconnect is faster.
138
248
  `Target detached: devtools`; live-view input stops until DevTools closes.
139
249
  - **Loopback only.** Both relay endpoints reject tunnel / non-loopback peers
140
250
  (checking `Host` and forwarding headers). A pi session that is not on the
141
- dashboard host cannot use this recipe.
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`.
142
338
 
143
339
  ## Diagnostics
144
340
 
145
341
  - Settings → Browser Relay shows the audit trail (`GET /api/browser/audit`) —
146
- `denied` rows name the refused verb, `navigate` rows name the URL.
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`).
147
345
  - `POST /api/browser/disconnect` then reconnect to clear a wedged instance.
148
- - The dashboard's live-view tiles (`content-view`) mirror the same instance; if
149
- a tile shows `no-frames`, the tab simply has not repainted (idle or hidden),
150
- which is normal.
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`.
@@ -498,3 +498,59 @@ List pinned directories.
498
498
  ```json
499
499
  { "success": true, "data": ["/path/to/project1", "/path/to/project2"] }
500
500
  ```
501
+
502
+ ---
503
+
504
+ ## Open Questions
505
+
506
+ Every open `ask_user` question of every session the caller may see, including hidden, headless, automation and goal-driver sessions. Question ids are opaque URL-safe strings, stable while the question is pending (also across a bridge reconnect). A question the caller may not see is `404`, the same as an unknown id. Reads need the `observe` tier, answers the `control` tier. These routes are not exposed as MCP tools.
507
+
508
+ ### `GET /api/questions`
509
+ List open questions, newest first. Rows carry no context bodies.
510
+
511
+ **Response:**
512
+ ```json
513
+ { "success": true, "data": [
514
+ { "id": "Zk3...", "sessionId": "abc", "sessionLabel": "my session", "changeName": "add-x",
515
+ "preview": "Resume or hand back?", "type": "select", "origin": "chat-gateway",
516
+ "askedAt": 1700000000000, "briefStatus": "ready" } ] }
517
+ ```
518
+ - `origin` (optional): `file` (agent file-access prompt), `chat-gateway`, `widget-bar`
519
+ - `briefStatus`: `provided`, `pending`, `ready`, `failed` or `unavailable`
520
+
521
+ ### `GET /api/questions/:id`
522
+ Full question: options, brief (with `briefLabel`), context snapshot and an `answerable` flag (false for file-access prompts).
523
+
524
+ **Responses:**
525
+ - `200`: `{ "success": true, "data": { ...row, "question": "...", "options": [], "brief": "...", "snapshot": {}, "answerable": true } }`
526
+ - `404`: Unknown, no longer pending, already answered, or not visible to the caller
527
+
528
+ ### `POST /api/questions/:id/answer`
529
+ Answer or cancel an open question. At most one answer is ever transmitted per question, across this route, the dashboard chat and the question dialog.
530
+
531
+ **Body** (exactly one form):
532
+ ```json
533
+ { "answer": "Resume" }
534
+ ```
535
+ ```json
536
+ { "cancelled": true }
537
+ ```
538
+ `answer` uses the encoding the dashboard chat sends: `confirm` → `"true"` / `"false"`; `select` → one of the options; `multiselect` → JSON array of distinct options (`"[]"` allowed, distinct from cancel); `input` / `editor` → any string, empty allowed; `batch` → JSON array with one entry per sub-question. Text only: images cannot be sent on this route.
539
+
540
+ **Responses:**
541
+ - `200`: `{ "success": true, "data": { "transmitted": true } }`. `transmitted` is not a delivery guarantee. `false` means the session's bridge was not reachable: the question stays open and the same answer can be posted again.
542
+ - `400`: Both or neither of `answer` / `cancelled`, or an answer invalid for the prompt type; nothing is transmitted
543
+ - `403`: File-access prompt (answered on the Access page), or the caller's tier is below `control`
544
+ - `404`: Unknown or not visible (also an id answered more than 10 minutes ago, or before a server restart)
545
+ - `409`: `{ "error": "answered" }`: an answer was transmitted within the last 10 minutes
546
+
547
+ ### `POST /api/questions/:id/summarize`
548
+ Generate a brief for a question whose brief is not a generated one (the dialog's "Summarize" action). The result is stored like an automatic brief.
549
+
550
+ **Body:** `{}`
551
+
552
+ **Responses:**
553
+ - `200`: `{ "success": true, "data": { ...question detail with the new brief } }`
554
+ - `404`: Unknown or not visible
555
+ - `409`: Already answered, or the brief is already generated
556
+ - `502` / `503`: Generation failed or timed out / the `@fast` role does not resolve; the current brief is kept and the call may be retried
@@ -0,0 +1,70 @@
1
+ # SKILL.md — project-init index
2
+
3
+ Pull-only condensed map. Source: packages/extension/.pi/skills/project-init/SKILL.md. Scaffold unconfigured dir into configured pi project; interactive, profile-driven, preview before write.
4
+
5
+ Triggers: "create project", bare dir, dashboard "Initialize" button spawns session. Target = cwd. `<skill>` = this skill dir.
6
+
7
+ ## Step 1 — Profiles
8
+ - Sources (user wins by name): `<skill>/profiles/*`, `~/.pi/project-profiles/*`.
9
+ - Usable only if both `AGENTS.md.tmpl` + `settings.json.tmpl` exist.
10
+ - `profile.json`: `description`, `dox` (default false), `stackAware`.
11
+ - Shipped: `coding` (TDD/simplicity/surgical, OpenSpec on, `npm ci`), `docs` (OpenSpec off, no build).
12
+
13
+ ## Step 2 — Select profile
14
+ - `ask_user` select.
15
+
16
+ ## Step 2b — Stack (stackAware only)
17
+ - Placeholders: `{{INSTALL_CMD}}`, `{{TEST_CMD}}`, `{{BUILD_CMD}}`, `{{INIT_GATE}}`, `{{INIT_COMMAND}}`.
18
+ - Marker → stack: `pnpm-lock.yaml`→pnpm, `yarn.lock`→yarn, `bun.lock(b)`→bun, `package-lock.json`/`package.json`→npm, `Cargo.toml`→cargo, `go.mod`→go, `poetry.lock`→poetry, `requirements.txt`/`pyproject.toml`→pip, `pom.xml`→maven, `build.gradle(.kts)`→gradle.
19
+ - JS lockfile beats bare `package.json`. No guess on bare dir.
20
+ - Confirm via `ask_user`. Never scaffold stackAware without resolved stack.
21
+ - Post-write: no `{{…}}` left in `AGENTS.md` or `.pi/settings.json`.
22
+
23
+ ## Step 3 — Optional capabilities + preview
24
+ ### 3a DOX
25
+ - `ask_user` confirm; default = profile `dox`. Answer → `DOX_ENABLED`.
26
+ ### 3b OpenSpec (coding only) → `OPENSPEC_MODE`
27
+ - Config `~/.pi/dashboard/config.json` `openspec`: `enabled`, `offerInitialization` (default true), `optOutDirectories` (default []).
28
+ - Unreadable/invalid JSON or wrong types → fail closed → `skip`.
29
+ - Opt-out match: pathKey = resolve, `/` separators, strip trailing `/`, lowercase unless linux.
30
+ - Git placement fail-closed: linked worktree or subdir of checkout → `skip`.
31
+ - First match wins:
32
+ 1. config undeterminable → `skip`
33
+ 2. `enabled===false` or opt-out match → `skip`
34
+ 3. git placement skip → `skip`
35
+ 4. no `./openspec/` AND `offerInitialization===false` → `skip`
36
+ 5. no `./openspec/` → `offer` (confirm; runs `openspec init --tools pi --force`)
37
+ 6. `./openspec/` present, `.pi/skills/openspec-explore/` absent → `repair` (no question; preview confirm = overwrite confirm)
38
+ 7. both present → `skip`
39
+ - Legacy artifacts (offer/repair only): root `CLAUDE.md`, `AGENTS.md`, etc. only if `<!-- OPENSPEC:START/END -->` present; `.claude/commands/openspec`, `.cursor/commands`, `.codex/prompts`, etc. Disclose by path.
40
+ ### 3c Preview writes
41
+ - `./AGENTS.md` ← `AGENTS.md.tmpl` (`{{PROJECT_NAME}}` = basename)
42
+ - `./.pi/settings.json` ← `settings.json.tmpl`
43
+ - `./.pi/prompts/*.md` ← `prompts/`
44
+ - DOX: pointer block in AGENTS.md; `./.pi/dashboard/knowledge_base.json` doctrine flip.
45
+ - OpenSpec: `openspec init --tools pi --force`; overwrite `./.pi/skills/openspec-*`; may remove legacy files; may touch `~/.config/openspec`.
46
+ - coding: may `pi install` eng-disciplines user-global (`~/.pi/agent/settings.json`), opt-in.
47
+ - Idempotency: ask before overwriting existing `AGENTS.md` / `.pi/settings.json`.
48
+
49
+ ## Step 4 — Write
50
+ - Validate `worktreeInit`: `gate` non-empty string; `run` = `{type:"script",command}` or `{type:"agent",prompt}` non-empty. Invalid → warn (fails open).
51
+
52
+ ## Step 4b — Discipline skills (coding only)
53
+ - Detect: `pi list | grep pi-dashboard-eng-disciplines` or stat `~/.pi/agent/npm/node_modules/@blackbelt-technology/pi-dashboard-eng-disciplines`.
54
+ - PRESENT → skip prompt; remove stale "not detected" footnote.
55
+ - ABSENT → confirm; yes → `pi install npm:@blackbelt-technology/pi-dashboard-eng-disciplines`; no/fail → append footnote under `## Discipline Skills`: "Discipline skills not detected — run `pi install npm:…` to activate the checkpoints above."
56
+
57
+ ## Step 5 — DOX seed (only if DOX_ENABLED)
58
+ - Append marker block `<!-- dox-doctrine -->` to AGENTS.md unless marker present. No doctrine copied.
59
+ - `knowledge_base.json`: set only `doctrine: {inject:"kb", write:true}`. Absent file → full default: `sources` `[{kind:"filesystem",ref:"."}]`, `indexAgentsFiles:true`, `directoryLevelAgents:{enabled:true}`, plus doctrine.
60
+ - Run `kb dox init`.
61
+ - Offer `dox-describe` (≤50 rows/run, one subagent per AGENTS.md).
62
+
63
+ ## Step 6 — OpenSpec init (repair, or offer confirmed)
64
+ - Run `openspec init --tools pi --force`.
65
+ - Verify exit 0, `.pi/skills/openspec-explore/` exists (+ `./openspec/` for offer).
66
+ - Failure → warn, `ls .pi/skills`, manual cmd. Do not error.
67
+ - Re-run after success → skip.
68
+
69
+ ## Step 7 — Done
70
+ - `worktreeInit` written → Initialize button runs hook instead of this skill.