@blackbelt-technology/pi-dashboard-extension 0.9.0 → 0.11.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 (79) hide show
  1. package/.pi/skills/browser/SKILL.md +14 -9
  2. package/.pi/skills/browser/references/dashboard-relay.md +242 -40
  3. package/.pi/skills/browser/references/own-browser.agent.md +73 -0
  4. package/.pi/skills/pi-dashboard/SKILL.md +37 -22
  5. package/.pi/skills/pi-dashboard/commands/dashboard-peer-list.md +1 -1
  6. package/.pi/skills/pi-dashboard/commands/dashboard-peer-scan.md +1 -1
  7. package/.pi/skills/pi-dashboard/commands/dashboard-server-config.md +1 -1
  8. package/.pi/skills/pi-dashboard/references/api-reference.agent.md +14 -1
  9. package/.pi/skills/pi-dashboard/references/api-reference.md +156 -2
  10. package/.pi/skills/pi-dashboard/scripts/dashboard-api.sh +39 -1
  11. package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +3 -1
  12. package/.pi/skills/pi-dashboard/scripts/local-proof.ts +40 -0
  13. package/.pi/skills/project-access/SKILL.md +190 -0
  14. package/.pi/skills/project-init/SKILL.agent.md +77 -0
  15. package/.pi/skills/project-init/SKILL.md +170 -25
  16. package/package.json +10 -8
  17. package/src/ask-user-tool.ts +65 -3
  18. package/src/auto-session-namer.ts +190 -50
  19. package/src/bridge-handlers/dispatch.ts +504 -0
  20. package/src/bridge-handlers/forwarders.ts +616 -0
  21. package/src/bridge-handlers/instance.ts +229 -0
  22. package/src/bridge-handlers/lifecycle.ts +1069 -0
  23. package/src/bridge-handlers/ui-prompt-patch.ts +198 -0
  24. package/src/bridge-identity-log.ts +45 -0
  25. package/src/bridge-ticket-client.ts +61 -7
  26. package/src/bridge-tls-checks.ts +79 -0
  27. package/src/bridge.ts +517 -2534
  28. package/src/canvas-tool.ts +2 -0
  29. package/src/command-handler.ts +259 -16
  30. package/src/connect-target.ts +23 -0
  31. package/src/connection.ts +294 -24
  32. package/src/dashboard-context-injector.ts +26 -47
  33. package/src/dashboard-http-origin.ts +88 -0
  34. package/src/dev-build.ts +11 -1
  35. package/src/empty-actionable-guard.ts +8 -3
  36. package/src/flow-event-wiring.ts +1 -1
  37. package/src/followup-buffer.ts +1 -1
  38. package/src/followup-drain.ts +79 -0
  39. package/src/git-link-builder.ts +11 -2
  40. package/src/inbound-limits.ts +138 -0
  41. package/src/local-token-header.ts +232 -17
  42. package/src/message-update-coalescer.ts +3 -1
  43. package/src/model-refresh.ts +88 -0
  44. package/src/multiselect-list.ts +6 -2
  45. package/src/multiselect-polyfill.ts +2 -2
  46. package/src/openspec-cli-shim.ts +1 -1
  47. package/src/path-gate/decide.ts +15 -41
  48. package/src/path-gate/grant-cache.ts +3 -1
  49. package/src/path-gate/handler.ts +51 -2
  50. package/src/path-gate/index.ts +12 -1
  51. package/src/path-gate/resolve.ts +6 -124
  52. package/src/path-gate/roots.ts +4 -1
  53. package/src/path-gate/suppression.ts +4 -1
  54. package/src/path-gate/yolo-link.ts +104 -0
  55. package/src/pinned-endpoint.ts +44 -0
  56. package/src/plugin-event-forward-registry.ts +200 -0
  57. package/src/project-trust-live.ts +143 -0
  58. package/src/project-trust.ts +258 -25
  59. package/src/prompt-expander.ts +5 -1
  60. package/src/prompt-meta.ts +64 -0
  61. package/src/provider-register.ts +146 -38
  62. package/src/remote-registration-gate.ts +21 -21
  63. package/src/remote-upgrade-preparer.ts +104 -0
  64. package/src/role-manager.ts +5 -4
  65. package/src/role-model-tools.ts +47 -6
  66. package/src/server-auto-start.ts +13 -6
  67. package/src/server-launcher.ts +11 -13
  68. package/src/server-proof-probe.ts +117 -0
  69. package/src/session-move.ts +19 -0
  70. package/src/session-sync.ts +73 -50
  71. package/src/spawn-token.ts +46 -0
  72. package/src/stream-forward-buffer.ts +161 -0
  73. package/src/subagent-frame-buffer.ts +6 -2
  74. package/src/subagent-tick-throttle.ts +3 -1
  75. package/src/vault-delivery.ts +404 -0
  76. package/src/vault-forwarder.ts +128 -0
  77. package/src/vault-masker.ts +165 -0
  78. package/src/vault-redaction.ts +181 -0
  79. package/src/vcs-info.ts +5 -2
@@ -2,7 +2,7 @@
2
2
  name: browser
3
3
  description: 'Browser automation via the `agent-browser` CLI. Use when the user needs to drive websites or Electron apps — navigating, forms, clicks, screenshots, data extraction, testing web apps, UI checks, the dashboard Electron shell, or the user''s own logged-in Chrome via the browser relay or Panerelay (SSO/2FA). Triggers: "open a website", "take a screenshot", "test this web app", "use my own browser".'
4
4
  license: Apache-2.0
5
- allowed-tools: Bash(agent-browser:*), Bash(npx agent-browser:*), Bash(npx @panerelay/setup:*), Bash(curl:*)
5
+ allowed-tools: Bash(agent-browser:*), Bash(npx agent-browser:*), Bash(npx @panerelay/setup:*), Bash(curl:*), Bash(pi-dashboard:*)
6
6
  metadata:
7
7
  author: pi-dashboard
8
8
  version: "1.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:
@@ -81,7 +81,7 @@ else
81
81
  fi
82
82
  PD_RUNNING=$(pgrep -f "Pi Dashboard|pi-dashboard" >/dev/null 2>&1 && echo yes || echo no)
83
83
  # Browser relay: the dashboard's own capability probe (see dashboard-relay.md).
84
- RELAY=$(curl -fsS http://localhost:8000/api/browser/status 2>/dev/null || echo unavailable)
84
+ RELAY=$(pi-dashboard api GET /api/browser/status 2>/dev/null || echo unavailable)
85
85
  echo "CDP_LIVE=$CDP_LIVE PD_RUNNING=$PD_RUNNING RELAY=$RELAY"
86
86
  ```
87
87
 
@@ -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,38 +33,93 @@ 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, via `pi-dashboard api` (a bare `curl` is refused on these routes under the strict
66
+ `requireLocalProof` default; the CLI sends local proof). Use the dashboard port (`8000` by default;
67
+ `PI_DASHBOARD_PORT` overrides; or pass `--port <n>`). The REST routes do **not** apply the
68
+ `defaultBrowser` / `onUnavailable` policy: you choose.
69
+
70
+ 1. Probe status (Step 1).
71
+ 2. When `enabled` and `dedicated.available` are both true, get a CDP URL with
72
+ `POST /api/browser/dedicated/connect`; otherwise list profiles (Step 2) and
73
+ use `POST /api/browser/connect` with the body form `{profileDirectory}`
74
+ (Step 3).
75
+ 3. Run `agent-browser connect <cdpUrl>` (Step 4); disconnect when done
76
+ (Step 5).
77
+
78
+ ```bash
79
+ pi-dashboard api POST /api/browser/dedicated/connect
80
+ # → {"cdpUrl":"ws://127.0.0.1:<port>/ws/browser-cdp/<guid>?ticket=<single-use>","instanceId":"inst-…"}
81
+ ```
82
+
83
+ The REST routes for the dedicated profile are
84
+ `POST /api/browser/dedicated/{connect,open,stop,reset}`. As an agent you call
85
+ only `connect` and `open`; `stop` and `reset` belong to the user in Settings.
32
86
 
33
87
  ## Prerequisites (user-facing, one time)
34
88
 
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.
89
+ - **Dedicated profile**: none. Chrome starts on demand; the user signs in once
90
+ (see "Login wall in the dedicated profile").
91
+ - **Chrome profile**: Chrome + the **Playwright Chrome Extension** installed in
92
+ the profile you will drive (`GET /api/browser/profiles` reports `installed`
93
+ per profile). For zero-dialog connects, a pairing token pasted in
94
+ **Settings → Browser Relay** (write-only; it never comes back out). Without
95
+ it the user gets Chrome's **Allow** prompt on each connect.
40
96
 
41
97
  ## Step 1 — Probe status
42
98
 
43
99
  ```bash
44
- curl -s http://localhost:8000/api/browser/status
45
- # → {"enabled":true,"canOpenChrome":true}
100
+ pi-dashboard api GET /api/browser/status
101
+ # → {"enabled":true,"canOpenChrome":true,"operatorHosts":true,
102
+ # "dedicated":{"available":true,"state":"stopped",…}}
46
103
  ```
47
104
 
48
- Use the dashboard port (`8000` by default; `PI_DASHBOARD_PORT` overrides).
105
+ `dedicated.available` (with `enabled`) is the dedicated-profile probe.
106
+ `operatorHosts: true` means this dashboard can also drive the browser on an
107
+ **operator's own computer** (see "Browser on the user's own computer" below).
108
+ Its absence means an older dashboard: never pass `host` to `connect` then.
109
+
49
110
  Branch on the response:
50
111
 
51
112
  | Response | Meaning | Do |
52
113
  |---|---|---|
53
114
  | `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
115
  | `{"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. |
116
+ | `{"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
117
 
57
118
  ### Step 1b — Enable the relay (only if `enabled:false`)
58
119
 
59
120
  ```bash
60
- curl -s -X PUT http://localhost:8000/api/browser/enabled \
61
- -H 'content-type: application/json' -d '{"enabled":true}'
121
+ pi-dashboard api PUT /api/browser/enabled \
122
+ --data '{"enabled":true}'
62
123
  ```
63
124
 
64
125
  The kill switch is safe to flip: turning it off closes every live instance
@@ -67,26 +128,36 @@ first (the response returns only after they are gone).
67
128
  ## Step 2 — Pick a profile
68
129
 
69
130
  ```bash
70
- curl -s http://localhost:8000/api/browser/profiles
131
+ pi-dashboard api GET /api/browser/profiles
71
132
  ```
72
133
 
73
134
  Rows are keyed by `profileDirectory`. Pick one with `"installed":true`; match a
74
135
  `label` / `email` when the user named an account. A row's `instances` lists any
75
136
  live connection already holding that profile.
76
137
 
77
- ## Step 3 — Connect
138
+ When Step 1 reported `operatorHosts: true`, the response also carries
139
+ `operatorHosts[]`: one entry per **online** operator computer —
140
+ `{hostId, label, platform, online, canOpenChrome, profiles[]}` with the same
141
+ profile rows (`profileDirectory`, `label`, `email`, `installed`, `instances`).
142
+ The top-level `profiles` map is always the dashboard host's Chrome; operator
143
+ profiles never appear in it.
144
+
145
+ ## Step 3 — Connect to a Chrome profile
78
146
 
79
147
  ```bash
80
- curl -s -X POST http://localhost:8000/api/browser/connect \
81
- -H 'content-type: application/json' \
82
- -d '{"profileDirectory":"Default"}'
148
+ pi-dashboard api POST /api/browser/connect \
149
+ --data '{"profileDirectory":"Default"}'
83
150
  ```
84
151
 
85
- Success returns `{"cdpUrl":"ws://127.0.0.1:<port>/ws/browser-cdp/<guid>","instanceId":"inst-…"}`.
152
+ Success returns `{"cdpUrl":"ws://127.0.0.1:<port>/ws/browser-cdp/<guid>?ticket=<single-use>","instanceId":"inst-…"}`.
153
+ The `?ticket=` is a one-time credential (valid 60 s, spent by the first dial): pass the **whole** `cdpUrl`
154
+ to `agent-browser connect` unchanged, and never log or share it. A client that drops cannot re-dial the same
155
+ URL — call `connect` again for a fresh one.
86
156
  **Keep the `instanceId`** — it is how you disconnect, and the only public handle
87
157
  to this instance.
88
158
 
89
- Branch on failure (the HTTP status is authoritative):
159
+ Branch on failure (the HTTP status is authoritative; for an operator `host`
160
+ see the extra reasons in the next section):
90
161
 
91
162
  | Status | `reason` | Meaning | Do |
92
163
  |---|---|---|---|
@@ -96,6 +167,43 @@ Branch on failure (the HTTP status is authoritative):
96
167
  | `503` | — | Host cannot open Chrome | Stop; do not fall back to the bundled browser for a login-state task. |
97
168
  | `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
169
 
170
+ ## Browser on the user's own computer (operator host)
171
+
172
+ `connect` targets the **dashboard host** unless the body names an operator
173
+ `hostId`:
174
+
175
+ ```bash
176
+ pi-dashboard api POST /api/browser/connect \
177
+ --data '{"profileDirectory":"Default","host":"<hostId from Step 2 operatorHosts[]>"}'
178
+ ```
179
+
180
+ Rules:
181
+
182
+ - Pass `host` **only when** `GET /api/browser/status` reported
183
+ `operatorHosts: true`. Without it, do not pass `host`, and tell the user that
184
+ this dashboard cannot drive the browser on their computer.
185
+ - When the user asks for the browser on **their own computer** (their laptop,
186
+ not the dashboard host), pass `host` if exactly one online operator host lists
187
+ that profile with `installed: true`. With several candidates, ask which one;
188
+ with none, say so — do not fall back to the dashboard host's Chrome.
189
+ - The success response is the same (`cdpUrl`, `instanceId`); continue with Step 4.
190
+ The operator sees a consent prompt on their computer on the first connect.
191
+
192
+ Operator-host failures (HTTP status is authoritative):
193
+
194
+ | Status | `reason` | Meaning | Do |
195
+ |---|---|---|---|
196
+ | `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. |
197
+ | `409` | `host-busy` | The operator host is already busy with a connect | Wait briefly and retry once. |
198
+ | `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. |
199
+ | `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. |
200
+ | `503` | `no-chrome` | The operator computer has no desktop Chrome | Stop; report it. |
201
+ | `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. |
202
+
203
+ An operator instance ends whenever that window's dashboard connection ends
204
+ (window closed, reload, server switched, network lost) — treat `host-gone` as a
205
+ normal end of the task, not a bug to retry in a loop.
206
+
99
207
  ## Step 4 — Attach the CDP client
100
208
 
101
209
  ```bash
@@ -108,28 +216,32 @@ relay behaves like any CDP endpoint for the allowed surface.
108
216
  ## Step 5 — Disconnect when done
109
217
 
110
218
  ```bash
111
- curl -s -X POST "http://localhost:8000/api/browser/disconnect?instanceId=<instanceId>"
219
+ pi-dashboard api POST "/api/browser/disconnect?instanceId=<instanceId>"
112
220
  ```
113
221
 
114
- Do this as soon as the task ends. A live instance holds a **tab group open in
222
+ Do this as soon as the task ends (it closes the dedicated instance too). A live instance holds a **tab group open in
115
223
  the user's Chrome**; the dashboard also auto-closes it ~30 s after the CDP
116
224
  client detaches or disconnects, but an explicit disconnect is faster.
117
225
 
118
226
  ## Behaviour you must expect
119
227
 
120
- - **One tab group per instance.** The extension opens a dedicated, colour-coded
228
+ - **One tab group per Chrome-profile instance.** The extension opens a dedicated, colour-coded
121
229
  Chrome tab group and drives only those tabs. Do not touch the user's other
122
230
  tabs; closing the last controlled tab ends the instance.
123
231
  - **Policy denials are LOUD, not silent.** The relay denies a fixed set of CDP
124
232
  verbs and unsafe navigation. A denial is a CDP error `-32000` whose message
125
233
  reads `Denied by dashboard relay policy: <method>`:
126
234
  - always denied: `Storage.getCookies`, `Network.getAllCookies`,
127
- `Network.getCookies` (cookie exfiltration), `Browser.setDownloadBehavior`.
235
+ `Network.getCookies` (cookie exfiltration).
128
236
  - navigation fence on `Page.navigate` / `Target.createTarget`: `file:`,
129
- `javascript:`, `data:`, `blob:`, and — when the profile has
237
+ `javascript:`, `vbscript:`, `data:`, `blob:`, and — when the profile has
130
238
  `allowedDomains` set — any host-less URL or a host outside the list.
131
239
  Treat `-32000` as a hard stop: report which call was denied, do not retry it
132
240
  in a loop, and do not try to reach the data another way.
241
+ - **`Browser.setDownloadBehavior` is acknowledged and dropped (ack-and-drop).**
242
+ Playwright `connectOverCDP` sends it during its handshake and aborts on an
243
+ error, so the relay answers success but never forwards it: the profile's
244
+ download behavior is **never** changed by you. Do not rely on download paths.
133
245
  - **One CDP client per instance.** A second `connect` to the same `cdpUrl` is
134
246
  closed with `Another CDP client already connected`. Use the `instanceId` you
135
247
  already hold.
@@ -138,13 +250,103 @@ client detaches or disconnects, but an explicit disconnect is faster.
138
250
  `Target detached: devtools`; live-view input stops until DevTools closes.
139
251
  - **Loopback only.** Both relay endpoints reject tunnel / non-loopback peers
140
252
  (checking `Host` and forwarding headers). A pi session that is not on the
141
- dashboard host cannot use this recipe.
253
+ dashboard host cannot use this recipe. This holds for an operator `host` too:
254
+ the `cdpUrl` is still served by the dashboard, so the pi session must still
255
+ run on the dashboard host.
256
+
257
+ ## Showing the page to the user, and handing over a step
258
+
259
+ Two pi tools (registered by the dashboard's browser plugin, only when you run
260
+ inside the dashboard) put your tab in the user's **editor pane**, next to the
261
+ chat. Both take the `instanceId` from the connect result; the dashboard knows
262
+ *your* session from the connection, so you never pass a session id.
263
+
264
+ - **`browser_show_in_pane {instanceId, tabId?}`** — open the tab in your
265
+ session's pane. `tabId` defaults to the instance's most recent tab (never the
266
+ extension's own page). One call per 5 s per instance (`rate-limited`
267
+ otherwise). Errors name the cause: `disabled`, `unknown-instance`,
268
+ `unknown-tab`, `no-tab`, `rate-limited`. Skip it for the first tab when
269
+ `browser_connect` returned `liveView: true`.
270
+ - **`browser_await_human {instanceId, reason}`** — for a step only the human
271
+ can do. It opens the tab, then **blocks** on a confirm prompt reading
272
+ `reason`; the user acts in the pane (they can type and click there, also from
273
+ a phone) and presses **Done ✓** (or answers in chat). Returns `done`, or
274
+ `cancelled` (declined, timed out, no interactive UI — reason `no-ui`). After
275
+ `done`, continue with your CDP client; after `cancelled`, do not pretend the
276
+ step happened.
277
+
278
+ **Scope of `browser_await_human`:**
279
+
280
+ - **Chrome profile**: use it for any human step — login, 2FA, consent,
281
+ CAPTCHA. Continue only on `done`, then re-snapshot the same tab.
282
+ - **Dedicated profile**: use it only for **non-sign-in** steps (consent,
283
+ challenge, CAPTCHA). A sign-in goes through `dedicated/open` + `ask_user`
284
+ (next section) — never ask the user to type credentials in your tab.
285
+
286
+ ### Login wall in the dedicated profile
287
+
288
+ When a page driven through the dedicated profile needs the user to sign in:
289
+
290
+ 1. Open the sign-in page with `POST /api/browser/dedicated/open {url}`, in a
291
+ **hidden** tab the agent cannot see:
292
+ ```bash
293
+ pi-dashboard api POST /api/browser/dedicated/open \
294
+ --data '{"url":"https://example.com/login"}'
295
+ ```
296
+ Only `https:` URLs are accepted (`400` otherwise). The user can also press
297
+ **Open to sign in** in Settings → Browser Relay.
298
+ 2. Ask the user with `ask_user` to sign in in that window, and wait for the
299
+ answer. The password never reaches you: do not read the hidden tab, do not
300
+ ask for credentials.
301
+ 3. After the answer, **reload your own tab** and re-snapshot. Still a login
302
+ wall → report it; do not loop.
303
+
304
+ ### Chrome profile closes on a password page
305
+
306
+ A Chrome-profile instance that closes after a page with a password field is
307
+ almost always a password-manager extension (LastPass, iCloud Passwords)
308
+ detaching the debugger. Diagnose it from the audit (`GET /api/browser/audit`):
309
+
310
+ ```bash
311
+ pi-dashboard api GET /api/browser/audit
312
+ ```
313
+
314
+ A `detach` entry for that `instanceId` with detail `closed:<reason>` (the
315
+ extension closed the connection) or `extension:<reason>` (another extension
316
+ took the tab) confirms it. `devtools` means the user opened DevTools instead.
317
+ Then explain the password-manager limit to the user and suggest the **dedicated
318
+ profile** for sign-ins. Do **not** retry the same page in that profile.
319
+
320
+ ## Dedicated profile — limits and hard rules
321
+
322
+ - **One session at a time.** The dedicated profile has a single holder; a
323
+ second `browser_connect` / `dedicated/connect` reports the live instance
324
+ (409 `busy`). Ask the user whether to disconnect it or use another browser.
325
+ Chrome profiles isolate by tab group instead.
326
+ - **Same-user limit.** The dedicated profile is **not** protected from other
327
+ programs running as the same OS user. Do not store anything there you would
328
+ not want those programs to read.
329
+ - **Never touch its directories.** The agent MUST NOT read, copy, or launch a
330
+ browser on the dedicated profile directory (`~/.pi/dashboard/agent-chrome`).
331
+ It MUST NOT read the dedicated downloads directory
332
+ (`~/.pi/dashboard/agent-chrome-downloads`) unless its task names a file
333
+ there. Reach the browser only through the CDP URL.
334
+ - **Downloads** are pinned to that downloads directory by the dashboard;
335
+ `Browser.setDownloadBehavior` from you is acknowledged and dropped.
336
+ - **Idle disconnect.** The instance closes after the configured idle time
337
+ (default 30 min), not while a `browser_await_human` is pending. Reconnect
338
+ with `browser_connect`.
142
339
 
143
340
  ## Diagnostics
144
341
 
145
342
  - Settings → Browser Relay shows the audit trail (`GET /api/browser/audit`) —
146
- `denied` rows name the refused verb, `navigate` rows name the URL.
343
+ `denied` rows name the refused verb, `navigate` rows name the URL (without
344
+ query string or fragment), `detach` rows carry the cause (`closed:`,
345
+ `extension:`, `devtools`, `idle`).
147
346
  - `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.
347
+ - The dashboard shows the same instance as editor-pane tabs
348
+ (`browser:<instanceId>:<tabId>`, opened from the session-card badge menu or by
349
+ `browser_show_in_pane`); if a tab shows the idle indicator (`no-frames`), the
350
+ page simply has not repainted (idle or hidden), which is normal.
351
+ - Audit `open` rows record every `browser_show_in_pane` / `browser_await_human`
352
+ 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`.
@@ -65,7 +65,12 @@ curl -s "$BASE/api/health" | jq .
65
65
 
66
66
  ## Authentication
67
67
 
68
- By default, auth is **disabled** and all localhost requests work without tokens.
68
+ By default, auth is **disabled**. Local requests still need to PROVE they come from this machine:
69
+ under the strict `requireLocalProof` default a bare `curl` to a non-observe route (anything that
70
+ changes state, plus `/api/config`, `/api/ws-ticket`, …) is refused with `403 local_proof_required`.
71
+ Read-only (observe) routes such as `/api/sessions` and `/api/health` stay open to a plain `curl`.
72
+ Use `pi-dashboard api <METHOD> <path> [--data '<json>']` (it mints a fresh local proof per request),
73
+ or `scripts/dashboard-api.sh`, for everything else.
69
74
 
70
75
  When auth is enabled (remote/tunnel access), include the JWT cookie:
71
76
 
@@ -97,12 +102,12 @@ curl -s -b "pi_dash_token=YOUR_JWT" "$BASE/api/sessions" | jq .
97
102
 
98
103
  | Action | Command |
99
104
  |--------|---------|
100
- | Send prompt | `curl -s -X POST "$BASE/api/session/ID/prompt" -H 'Content-Type: application/json' -d '{"text":"your message"}'` |
101
- | Abort | `curl -s -X POST "$BASE/api/session/ID/abort" -H 'Content-Type: application/json' -d '{}'` |
102
- | Shutdown session | `curl -s -X POST "$BASE/api/session/ID/shutdown" -H 'Content-Type: application/json' -d '{}'` |
103
- | Rename | `curl -s -X POST "$BASE/api/session/ID/rename" -H 'Content-Type: application/json' -d '{"name":"my-name"}'` |
104
- | Archive | `curl -s -X POST "$BASE/api/session/ID/archive" -H 'Content-Type: application/json' -d '{}'` |
105
- | Unarchive | `curl -s -X POST "$BASE/api/session/ID/unarchive" -H 'Content-Type: application/json' -d '{}'` |
105
+ | Send prompt | `pi-dashboard api POST /api/session/ID/prompt --data '{"text":"your message"}'` |
106
+ | Abort | `pi-dashboard api POST /api/session/ID/abort --data '{}'` |
107
+ | Shutdown session | `pi-dashboard api POST /api/session/ID/shutdown --data '{}'` |
108
+ | Rename | `pi-dashboard api POST /api/session/ID/rename --data '{"name":"my-name"}'` |
109
+ | Archive | `pi-dashboard api POST /api/session/ID/archive --data '{}'` |
110
+ | Unarchive | `pi-dashboard api POST /api/session/ID/unarchive --data '{}'` |
106
111
 
107
112
  > `GET /api/sessions` lists RESIDENT sessions only — archived sessions are excluded.
108
113
  > Resolve an archived id with `GET /api/sessions/archived?q=<text>` (or
@@ -110,54 +115,64 @@ curl -s -b "pi_dash_token=YOUR_JWT" "$BASE/api/sessions" | jq .
110
115
  > Archiving an alive-but-idle session terminates its pi process and completes on
111
116
  > the ended transition; a running or interrupted (`live:true`) session is refused
112
117
  > (WS error / REST 409).
113
- | Spawn new | `curl -s -X POST "$BASE/api/session/spawn" -H 'Content-Type: application/json' -d '{"cwd":"/path"}'` |
114
- | Resume/Fork | `curl -s -X POST "$BASE/api/session/ID/resume" -H 'Content-Type: application/json' -d '{"mode":"continue"}'` |
118
+ | Spawn new | `pi-dashboard api POST /api/session/spawn --data '{"cwd":"/path"}'` |
119
+ | Resume/Fork | `pi-dashboard api POST /api/session/ID/resume --data '{"mode":"continue"}'` |
115
120
 
116
121
  ### Flow Control
117
122
 
118
123
  | Action | Command |
119
124
  |--------|---------|
120
- | Abort flow | `curl -s -X POST "$BASE/api/session/ID/flow-control" -H 'Content-Type: application/json' -d '{"action":"abort"}'` |
121
- | Toggle autonomous | `curl -s -X POST "$BASE/api/session/ID/flow-control" -H 'Content-Type: application/json' -d '{"action":"toggle_autonomous"}'` |
125
+ | Abort flow | `pi-dashboard api POST /api/session/ID/flow-control --data '{"action":"abort"}'` |
126
+ | Toggle autonomous | `pi-dashboard api POST /api/session/ID/flow-control --data '{"action":"toggle_autonomous"}'` |
122
127
 
123
128
  ### Model / Thinking
124
129
 
125
130
  | Action | Command |
126
131
  |--------|---------|
127
- | Set model | `curl -s -X POST "$BASE/api/session/ID/model" -H 'Content-Type: application/json' -d '{"provider":"anthropic","modelId":"claude-sonnet-4-20250514"}'` |
128
- | Set thinking | `curl -s -X POST "$BASE/api/session/ID/thinking-level" -H 'Content-Type: application/json' -d '{"level":"high"}'` |
132
+ | Set model | `pi-dashboard api POST /api/session/ID/model --data '{"provider":"anthropic","modelId":"claude-sonnet-4-20250514"}'` |
133
+ | Set thinking | `pi-dashboard api POST /api/session/ID/thinking-level --data '{"level":"high"}'` |
129
134
 
130
135
  ### Git Operations
131
136
 
132
137
  | Action | Command |
133
138
  |--------|---------|
134
139
  | List branches | `curl -s "$BASE/api/git/branches?cwd=CWD" \| jq .` |
135
- | Checkout | `curl -s -X POST "$BASE/api/git/checkout" -H 'Content-Type: application/json' -d '{"cwd":"CWD","branch":"main"}'` |
136
- | Init repo | `curl -s -X POST "$BASE/api/git/init" -H 'Content-Type: application/json' -d '{"cwd":"CWD"}'` |
137
- | Stash pop | `curl -s -X POST "$BASE/api/git/stash-pop" -H 'Content-Type: application/json' -d '{"cwd":"CWD"}'` |
140
+ | Checkout | `pi-dashboard api POST /api/git/checkout --data '{"cwd":"CWD","branch":"main"}'` |
141
+ | Init repo | `pi-dashboard api POST /api/git/init --data '{"cwd":"CWD"}'` |
142
+ | Stash pop | `pi-dashboard api POST /api/git/stash-pop --data '{"cwd":"CWD"}'` |
138
143
 
139
144
  ### OpenSpec
140
145
 
141
146
  | Action | Command |
142
147
  |--------|---------|
143
- | Attach proposal | `curl -s -X POST "$BASE/api/session/ID/attach-proposal" -H 'Content-Type: application/json' -d '{"changeName":"change-name"}'` |
144
- | Detach proposal | `curl -s -X POST "$BASE/api/session/ID/detach-proposal" -H 'Content-Type: application/json' -d '{}'` |
148
+ | Attach proposal | `pi-dashboard api POST /api/session/ID/attach-proposal --data '{"changeName":"change-name"}'` |
149
+ | Detach proposal | `pi-dashboard api POST /api/session/ID/detach-proposal --data '{}'` |
145
150
  | Archive listing | `curl -s "$BASE/api/openspec-archive?cwd=CWD" \| jq .` |
146
151
 
147
152
  ### Configuration
148
153
 
149
154
  | Action | Command |
150
155
  |--------|---------|
151
- | Read config | `curl -s "$BASE/api/config" \| jq .` |
152
- | Update config | `curl -s -X PUT "$BASE/api/config" -H 'Content-Type: application/json' -d '{"autoShutdown":false}'` |
156
+ | Read config | `pi-dashboard api GET /api/config \| jq .` |
157
+ | Update config | `pi-dashboard api PUT /api/config --data '{"autoShutdown":false}'` |
158
+
159
+ ### Access Provisioning
160
+
161
+ Propose-only: the dashboard operator approves each folder. Prefer the `project-access` skill (map / suggest / provision); never call the operator-only `settle` / `dismiss-all` routes.
162
+
163
+ | Action | Command |
164
+ |--------|---------|
165
+ | Submit request | `pi-dashboard api POST /api/access/provision --data '{"projectRoot":"/abs/project","lines":[{"path":"../lib","why":"tests"}]}'` |
166
+ | Pending requests | `curl -s "$BASE/api/access/provision" \| jq .` |
167
+ | Request status | `pi-dashboard api GET /api/access/provision/ID \| jq .` |
153
168
 
154
169
  ### Tunnel
155
170
 
156
171
  | Action | Command |
157
172
  |--------|---------|
158
173
  | Tunnel status | `curl -s "$BASE/api/tunnel-status" \| jq .` |
159
- | Connect tunnel | `curl -s -X POST "$BASE/api/tunnel-connect"` |
160
- | Disconnect tunnel | `curl -s -X POST "$BASE/api/tunnel-disconnect"` |
174
+ | Connect tunnel | `pi-dashboard api POST /api/tunnel-connect` |
175
+ | Disconnect tunnel | `pi-dashboard api POST /api/tunnel-disconnect` |
161
176
 
162
177
  ## Helper Script
163
178
 
@@ -2,5 +2,5 @@
2
2
  executable: bash
3
3
  description: List known remote dashboard servers. Runs locally, no LLM.
4
4
  ---
5
- curl -s "$PI_DASHBOARD_BASE/api/known-servers" \
5
+ eval "$PI_DASHBOARD_CLI" api GET /api/known-servers \
6
6
  | jq -r '.data[]? | "\(.label // "-") \(.host):\(.port)"'