@blackbelt-technology/pi-dashboard-extension 0.10.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 (42) hide show
  1. package/.pi/skills/browser/SKILL.md +2 -2
  2. package/.pi/skills/browser/references/dashboard-relay.md +21 -20
  3. package/.pi/skills/pi-dashboard/SKILL.md +37 -22
  4. package/.pi/skills/pi-dashboard/commands/dashboard-peer-list.md +1 -1
  5. package/.pi/skills/pi-dashboard/commands/dashboard-peer-scan.md +1 -1
  6. package/.pi/skills/pi-dashboard/commands/dashboard-server-config.md +1 -1
  7. package/.pi/skills/pi-dashboard/references/api-reference.agent.md +14 -1
  8. package/.pi/skills/pi-dashboard/references/api-reference.md +100 -2
  9. package/.pi/skills/pi-dashboard/scripts/dashboard-api.sh +39 -1
  10. package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +3 -1
  11. package/.pi/skills/pi-dashboard/scripts/local-proof.ts +40 -0
  12. package/.pi/skills/project-access/SKILL.md +190 -0
  13. package/.pi/skills/project-init/SKILL.agent.md +7 -0
  14. package/.pi/skills/project-init/SKILL.md +37 -4
  15. package/package.json +5 -3
  16. package/src/bridge-handlers/dispatch.ts +57 -3
  17. package/src/bridge-handlers/instance.ts +10 -1
  18. package/src/bridge-handlers/lifecycle.ts +65 -26
  19. package/src/bridge-ticket-client.ts +61 -7
  20. package/src/bridge-tls-checks.ts +79 -0
  21. package/src/bridge.ts +41 -28
  22. package/src/canvas-tool.ts +2 -0
  23. package/src/command-handler.ts +80 -6
  24. package/src/connect-target.ts +23 -0
  25. package/src/connection.ts +30 -7
  26. package/src/dashboard-http-origin.ts +88 -0
  27. package/src/dev-build.ts +11 -1
  28. package/src/git-link-builder.ts +11 -2
  29. package/src/inbound-limits.ts +138 -0
  30. package/src/local-token-header.ts +77 -6
  31. package/src/model-refresh.ts +69 -0
  32. package/src/pinned-endpoint.ts +44 -0
  33. package/src/project-trust-live.ts +143 -0
  34. package/src/project-trust.ts +159 -20
  35. package/src/provider-register.ts +59 -18
  36. package/src/remote-registration-gate.ts +21 -21
  37. package/src/remote-upgrade-preparer.ts +104 -0
  38. package/src/role-model-tools.ts +47 -6
  39. package/src/server-auto-start.ts +1 -1
  40. package/src/server-proof-probe.ts +117 -0
  41. package/src/session-sync.ts +42 -12
  42. package/src/vault-delivery.ts +11 -1
@@ -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"
@@ -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
 
@@ -62,8 +62,9 @@ browser.
62
62
 
63
63
  ## Fallback recipe — REST, for sessions without `browser_connect`
64
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
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
67
68
  `defaultBrowser` / `onUnavailable` policy: you choose.
68
69
 
69
70
  1. Probe status (Step 1).
@@ -75,8 +76,8 @@ Same dashboard, plain `curl`. Use the dashboard port (`8000` by default;
75
76
  (Step 5).
76
77
 
77
78
  ```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-…"}
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-…"}
80
81
  ```
81
82
 
82
83
  The REST routes for the dedicated profile are
@@ -96,7 +97,7 @@ only `connect` and `open`; `stop` and `reset` belong to the user in Settings.
96
97
  ## Step 1 — Probe status
97
98
 
98
99
  ```bash
99
- curl -s http://localhost:8000/api/browser/status
100
+ pi-dashboard api GET /api/browser/status
100
101
  # → {"enabled":true,"canOpenChrome":true,"operatorHosts":true,
101
102
  # "dedicated":{"available":true,"state":"stopped",…}}
102
103
  ```
@@ -117,8 +118,8 @@ Branch on the response:
117
118
  ### Step 1b — Enable the relay (only if `enabled:false`)
118
119
 
119
120
  ```bash
120
- curl -s -X PUT http://localhost:8000/api/browser/enabled \
121
- -H 'content-type: application/json' -d '{"enabled":true}'
121
+ pi-dashboard api PUT /api/browser/enabled \
122
+ --data '{"enabled":true}'
122
123
  ```
123
124
 
124
125
  The kill switch is safe to flip: turning it off closes every live instance
@@ -127,7 +128,7 @@ first (the response returns only after they are gone).
127
128
  ## Step 2 — Pick a profile
128
129
 
129
130
  ```bash
130
- curl -s http://localhost:8000/api/browser/profiles
131
+ pi-dashboard api GET /api/browser/profiles
131
132
  ```
132
133
 
133
134
  Rows are keyed by `profileDirectory`. Pick one with `"installed":true`; match a
@@ -144,12 +145,14 @@ profiles never appear in it.
144
145
  ## Step 3 — Connect to a Chrome profile
145
146
 
146
147
  ```bash
147
- curl -s -X POST http://localhost:8000/api/browser/connect \
148
- -H 'content-type: application/json' \
149
- -d '{"profileDirectory":"Default"}'
148
+ pi-dashboard api POST /api/browser/connect \
149
+ --data '{"profileDirectory":"Default"}'
150
150
  ```
151
151
 
152
- 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.
153
156
  **Keep the `instanceId`** — it is how you disconnect, and the only public handle
154
157
  to this instance.
155
158
 
@@ -170,9 +173,8 @@ see the extra reasons in the next section):
170
173
  `hostId`:
171
174
 
172
175
  ```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
+ pi-dashboard api POST /api/browser/connect \
177
+ --data '{"profileDirectory":"Default","host":"<hostId from Step 2 operatorHosts[]>"}'
176
178
  ```
177
179
 
178
180
  Rules:
@@ -214,7 +216,7 @@ relay behaves like any CDP endpoint for the allowed surface.
214
216
  ## Step 5 — Disconnect when done
215
217
 
216
218
  ```bash
217
- curl -s -X POST "http://localhost:8000/api/browser/disconnect?instanceId=<instanceId>"
219
+ pi-dashboard api POST "/api/browser/disconnect?instanceId=<instanceId>"
218
220
  ```
219
221
 
220
222
  Do this as soon as the task ends (it closes the dedicated instance too). A live instance holds a **tab group open in
@@ -288,9 +290,8 @@ When a page driven through the dedicated profile needs the user to sign in:
288
290
  1. Open the sign-in page with `POST /api/browser/dedicated/open {url}`, in a
289
291
  **hidden** tab the agent cannot see:
290
292
  ```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"}'
293
+ pi-dashboard api POST /api/browser/dedicated/open \
294
+ --data '{"url":"https://example.com/login"}'
294
295
  ```
295
296
  Only `https:` URLs are accepted (`400` otherwise). The user can also press
296
297
  **Open to sign in** in Settings → Browser Relay.
@@ -307,7 +308,7 @@ almost always a password-manager extension (LastPass, iCloud Passwords)
307
308
  detaching the debugger. Diagnose it from the audit (`GET /api/browser/audit`):
308
309
 
309
310
  ```bash
310
- curl -s http://localhost:8000/api/browser/audit
311
+ pi-dashboard api GET /api/browser/audit
311
312
  ```
312
313
 
313
314
  A `detach` entry for that `instanceId` with detail `closed:<reason>` (the
@@ -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)"'
@@ -2,5 +2,5 @@
2
2
  executable: bash
3
3
  description: mDNS scan for peer dashboard servers on the network. Runs locally, no LLM.
4
4
  ---
5
- curl -s -X POST "$PI_DASHBOARD_BASE/api/discover-servers" \
5
+ eval "$PI_DASHBOARD_CLI" api POST /api/discover-servers \
6
6
  | jq -r '.data[]? | "\(.host):\(.port) v\(.version // "-") \(if .isLocal then "(local)" else "" end)"'
@@ -2,4 +2,4 @@
2
2
  executable: bash
3
3
  description: Dashboard server config (secrets redacted). Runs locally, no LLM.
4
4
  ---
5
- curl -s "$PI_DASHBOARD_BASE/api/config" | jq .
5
+ eval "$PI_DASHBOARD_CLI" api GET /api/config | jq .
@@ -5,11 +5,17 @@ Pull-only condensed map. Source: packages/extension/.pi/skills/pi-dashboard/refe
5
5
  ## WebSocket bus verbs
6
6
  - Session/flow COMMAND verbs — prefer WS bus over REST; client `@blackbelt-technology/pi-dashboard-bus-client` (`scripts/dashboard-bus.ts`). Verbs = `BrowserToServerMessage` union; `plugin_config_write` excluded → stays REST. `spawn`/`resume` replies exact-correlated; other waits structural (session-id + status).
7
7
 
8
+ ## UI routes (browser)
9
+ - Prefix with `BASE`. Sessions: `/session/:id`, `/session/:id/diff`, `/session/:id/editor`. Folders: `/folder/:encodedCwd`, `.../openspec`, `.../openspec/specs`, `.../openspec/:changeName/:artifactId`, `.../openspec/archive[/:entry[/:artifact]]`.
10
+ - Session id: full id from `GET /api/sessions`; unique prefix >= 8 chars (case-insensitive) converges to the full id; shorter/unknown → inline "Session not found" (no redirect), ambiguous → candidate links. Archived: `/session/<full id>?archived=1` only (no prefix).
11
+ - `?embed=1` → no session list (sticky per tab until `?embed=0`). `uiUrl` / `diffUrl` per session row; base = matching configured origin/tunnel, else admitted `Host`, else `http://localhost:<port>` (https proxy not in `publicBaseUrls` → `http://`).
12
+ - `:encodedCwd` = base64url UTF-8 path, no `=`: `printf %s "$CWD" | base64 | tr '+/' '-_' | tr -d '=\n'`. Other params `encodeURIComponent`. No credentials in UI URLs.
13
+
8
14
  ## Health & Status
9
15
  - `GET /api/health` — liveness `{ ok, pid, uptime }`. `GET /auth/status` — `{ authenticated, authEnabled }`.
10
16
 
11
17
  ## Sessions
12
- - `GET /api/sessions` — list all. Fields: `id, cwd, name?, source (tui|zed|tmux|dashboard|terminal|unknown), status (active|idle|streaming|ended), model?, thinkingLevel?, startedAt, endedAt?, tokensIn?, tokensOut?, cost?, currentTool?, gitBranch?, attachedProposal?, hidden?, activeFlowName?, flowStatus? (running|success|error|aborted), sessionFile?`.
18
+ - `GET /api/sessions` — list all; optional `?id=` (single value; exact or >= 8-char prefix, case-insensitive; repeated → 400). Fields: `uiUrl, diffUrl` (absolute browser links, never stored), `id, cwd, name?, source (tui|zed|tmux|dashboard|terminal|unknown), status (active|idle|streaming|ended), model?, thinkingLevel?, startedAt, endedAt?, tokensIn?, tokensOut?, cost?, currentTool?, gitBranch?, attachedProposal?, hidden?, activeFlowName?, flowStatus? (running|success|error|aborted), sessionFile?`.
13
19
 
14
20
  ## Session Control
15
21
  - `POST /api/session/:id/prompt` — `{ text (required), images? [{ type:"image", data, mimeType }] }`. 400 no text, 404, 502 no bridge.
@@ -45,6 +51,7 @@ Pull-only condensed map. Source: packages/extension/.pi/skills/pi-dashboard/refe
45
51
 
46
52
  ## Events
47
53
  - `GET /api/events/:sessionId/:seq` — `{ eventType, timestamp, data }`.
54
+ - `GET /api/events/stream?session=ID,…&types=T,…` — SSE, never ends. `ready`, then open questions, then live: `session_added`, `status {from?,to}` (changes only), `session_removed`, `question_opened {questionId, questionType, preview, sessionLabel}`, `question_closed {reason: answered|removed}`. `: ping` every 20 s. Unknown type → 400. observe; visibility = session list; not an MCP tool.
48
55
  - `GET /api/session-diff?sessionId=ID` — localhost-only. `{ isGitRepo, files:[{ path, changes:[{ type, timestamp, message }], gitDiff }] }`.
49
56
 
50
57
  ## Configuration
@@ -67,3 +74,9 @@ Pull-only condensed map. Source: packages/extension/.pi/skills/pi-dashboard/refe
67
74
 
68
75
  ## Pinned Directories
69
76
  - `GET /api/pinned-dirs` — `{ success, data: ["/path"] }`.
77
+
78
+ ## Access Provisioning
79
+ - Proposal only: writes no grant/config. In-memory, expires 10 min. Prefer the `project-access` skill.
80
+ - `POST /api/access/provision` — `{ projectRoot, lines:[{path, why?}] (≤32), remote?:["lan"|"internet"|"device"] }` → `data:{ requestId, status, projectRoot, lines:[{lineId, path, why, classification}], remote, expiresAt }`. Classification: `invalid|missing|forbidden|sensitive|in-root|covered|grantable`. Refusals `{success:false, error, reason?, requestId?, retryAfterMs?}`: 400 `empty|too-many-lines|invalid-request|invalid-root`; 409 `pending-exists|no-operator|prompting-disabled|report-mode`; 429 `capacity|rate-limited|cooldown`; 503 `disabled`.
81
+ - `GET /api/access/provision` — `data.requests` (pending). `GET /api/access/provision/:id` — status `pending|settled|dismissed|expired` + per-line `outcome` (`granted|rejected|changed|refused|failed`, remote `handed-off`); 404 after restart.
82
+ - `POST /api/access/provision/:id/settle`, `POST /api/access/provision/dismiss-all` — operator-only (`403 no-capability`); skills never call.
@@ -20,6 +20,41 @@ no-WS-twin endpoints.
20
20
 
21
21
  ---
22
22
 
23
+ ## UI routes (browser)
24
+
25
+ Open these in a browser (an agent's browser pane) to show the dashboard UI. Prefix every route with `BASE` (for example `http://localhost:8000`). Prefer the ready-made `uiUrl` / `diffUrl` from `GET /api/sessions` for sessions.
26
+
27
+ | Route | Shows |
28
+ |-------|-------|
29
+ | `/session/:id` | Session chat |
30
+ | `/session/:id/diff` | Session changed-files diff |
31
+ | `/session/:id/editor` | Session editor pane |
32
+ | `/folder/:encodedCwd` | Folder home |
33
+ | `/folder/:encodedCwd/openspec` | OpenSpec board |
34
+ | `/folder/:encodedCwd/openspec/specs` | OpenSpec specs browser |
35
+ | `/folder/:encodedCwd/openspec/:changeName/:artifactId` | One OpenSpec change artifact |
36
+ | `/folder/:encodedCwd/openspec/archive[/:entry[/:artifact]]` | OpenSpec archive list, one entry, one artifact |
37
+
38
+ **Session ids.** Use the full `id` from `GET /api/sessions`. A prefix of at least 8 characters (case-insensitive) is accepted when it matches exactly one session, and the URL converges to the full id. Session ids are time-ordered UUIDs, so sessions created within about a minute share their first 8 characters: prefer `uiUrl` over a hand-cut prefix. A shorter or unknown id shows "Session not found" (the page is not redirected), and an ambiguous prefix lists the candidates. `GET /api/sessions?id=<id>` returns only the matching rows (same rules).
39
+
40
+ **Archived sessions.** Open `/session/<full id>?archived=1`. The full id is required, a prefix is not resolved for archived sessions. Get ids from `GET /api/sessions/archived`.
41
+
42
+ **Embed.** Append `?embed=1` to show the session without the session list (for a narrow pane). It sticks for that browser tab until `?embed=0`. The "Open full dashboard" control leaves embed mode.
43
+
44
+ **`uiUrl` / `diffUrl`.** Each `GET /api/sessions` row carries absolute links built from the origin you called: a configured public base URL or live tunnel whose host matches, else an admitted `Host` as given, else `http://localhost:<port>`. A reverse proxy that terminates https but is not listed in `publicBaseUrls` therefore yields `http://` links: add its origin to `publicBaseUrls`.
45
+
46
+ **`:encodedCwd`.** base64url of the UTF-8 absolute path, with no `=` padding. In a POSIX shell:
47
+
48
+ ```bash
49
+ printf %s "$CWD" | base64 | tr '+/' '-_' | tr -d '=\n'
50
+ ```
51
+
52
+ `:changeName`, `:artifactId`, `:entry` and `:artifact` are `encodeURIComponent`-encoded.
53
+
54
+ **No credentials in UI URLs.** Never put a token, header value or password in a UI URL. When the page asks to sign in, the user signs in inside the browser.
55
+
56
+ ---
57
+
23
58
  ## Health & Status
24
59
 
25
60
  ### `GET /api/health`
@@ -43,7 +78,7 @@ Check authentication status.
43
78
  ## Sessions
44
79
 
45
80
  ### `GET /api/sessions`
46
- List all sessions.
81
+ List all sessions. Optional `?id=<id>` (single value) returns only the matching session(s): case-insensitive exact id, or a prefix of 8+ characters. A repeated `id` returns 400.
47
82
 
48
83
  **Response:**
49
84
  ```json
@@ -63,7 +98,9 @@ List all sessions.
63
98
  "cost": 0.05,
64
99
  "currentTool": "Edit",
65
100
  "gitBranch": "main",
66
- "hidden": false
101
+ "hidden": false,
102
+ "uiUrl": "http://localhost:8000/session/abc123",
103
+ "diffUrl": "http://localhost:8000/session/abc123/diff"
67
104
  }
68
105
  ]
69
106
  }
@@ -91,6 +128,8 @@ List all sessions.
91
128
  | `activeFlowName` | string? | Running flow name |
92
129
  | `flowStatus` | string? | `running`, `success`, `error`, `aborted` |
93
130
  | `sessionFile` | string? | Path to session JSONL file |
131
+ | `uiUrl` | string | Absolute browser link to the session chat, built from the origin of this request. Append `?embed=1` for a narrow pane. Never stored |
132
+ | `diffUrl` | string | Absolute browser link to the session diff (`uiUrl` + `/diff`) |
94
133
 
95
134
  ---
96
135
 
@@ -391,6 +430,31 @@ Fetch a specific event by sequence number.
391
430
  }
392
431
  ```
393
432
 
433
+ ### `GET /api/events/stream`
434
+ Server-Sent Events feed of agent transitions, for a controller that reacts instead of polling (observe tier).
435
+ Query: `session=<id>[,<id>…]` (full ids) and `types=<type>[,<type>…]`. Unknown type → `400`.
436
+ The response never ends: it starts with a `ready` frame, then every currently open question as `question_opened`, then live events. A `: ping` comment arrives every 20 s.
437
+
438
+ ```
439
+ retry: 3000
440
+ event: ready
441
+ data: {"sessions":["<id>"],"types":["status","question_opened"]}
442
+
443
+ id: 1
444
+ event: question_opened
445
+ data: {"type":"question_opened","sessionId":"<id>","questionId":"<qid>","questionType":"select","preview":"Push to main?","sessionLabel":"<label>"}
446
+ ```
447
+
448
+ | Event | Data |
449
+ |---|---|
450
+ | `session_added` | `sessionId`, `status?`, `cwd?`, `name?` |
451
+ | `status` | `sessionId`, `from?` (absent when the previous status is unknown), `to` (`active`, `idle`, `streaming`, `ended`). Emitted only when the status changes |
452
+ | `session_removed` | `sessionId` |
453
+ | `question_opened` | `sessionId`, `questionId`, `questionType`, `preview`, `sessionLabel`. Detail and answer: `GET /api/questions/:id`, `POST /api/questions/:id/answer` |
454
+ | `question_closed` | `sessionId`, `questionId`, `reason` (`answered`, `removed`) |
455
+
456
+ Visibility follows the session list: an event for a session the caller may not see is not sent. Not exposed as an MCP tool.
457
+
394
458
  ### `GET /api/session-diff?sessionId=ID`
395
459
  Get file changes made during a session (localhost-only).
396
460
 
@@ -501,6 +565,40 @@ List pinned directories.
501
565
 
502
566
  ---
503
567
 
568
+ ## Access Provisioning
569
+
570
+ An agent proposes the folders a project needs; the dashboard operator approves them line by line. A request is a proposal: it writes no grant and no configuration. Requests are in memory only (a server restart forgets them) and expire 10 minutes after creation. Use the `project-access` skill rather than calling these by hand. Replies use the usual envelope: `{ "success": true, "data": … }` or `{ "success": false, "error": "<code>", … }`.
571
+
572
+ ### `POST /api/access/provision`
573
+ Propose a request. Delivered as a dialog only to operator browsers (operate tier holding a prompt capability).
574
+
575
+ **Body:**
576
+ ```json
577
+ { "projectRoot": "/abs/project", "lines": [{ "path": "../shared-lib", "why": "sibling package" }], "remote": ["lan"] }
578
+ ```
579
+ - `projectRoot`: absolute path to a directory holding `.git` or `.pi`; its real path is the per-project key
580
+ - `lines`: 0–32 entries; `path` absolute, `~/`-rooted or relative to the root; `why` optional (cut at 200 characters, control characters removed)
581
+ - `remote` (optional): `lan`, `internet`, `device` — hand-off to the Remote access dialog, nothing is configured
582
+
583
+ **Response `200`:** `{ "success": true, "data": { "requestId", "status": "pending", "projectRoot", "lines": [{ "lineId", "path", "why", "classification", "projectRoot"? }], "remote": [{ "goal" }], "createdAt", "expiresAt" } }`. `classification`: `invalid`, `missing`, `forbidden`, `sensitive`, `in-root`, `covered`, `grantable`.
584
+
585
+ **Refusals** (`error`, plus `reason` / `requestId` / `retryAfterMs` where noted; `retry-after` header on 429):
586
+ - `400`: `empty`, `too-many-lines`, `invalid-request`, `invalid-root` (`reason`: `not-absolute`, `missing`, `not-directory`, `forbidden`, `no-marker`)
587
+ - `409`: `pending-exists` (`requestId` of the open one), `no-operator`, `prompting-disabled`, `report-mode`
588
+ - `429`: `capacity`, `rate-limited`, `cooldown` (each with `retryAfterMs`)
589
+ - `503`: `disabled` (grant prompt kill switch)
590
+
591
+ ### `GET /api/access/provision`
592
+ Pending requests: `{ "success": true, "data": { "requests": [ …request views ] } }`. Observe tier.
593
+
594
+ ### `GET /api/access/provision/:id`
595
+ One request: `status` (`pending`, `settled`, `dismissed`, `expired`) and, once ended, each line's `outcome` (`granted`, `rejected`, `changed`, `refused`, `failed`) with `reason`, and each remote goal's `outcome` (`handed-off`). `404 not-found` for an unknown id or after a server restart.
596
+
597
+ ### `POST /api/access/provision/:id/settle` · `POST /api/access/provision/dismiss-all`
598
+ Operator-only: `403 no-capability` without a live prompt capability. Used by the dashboard UI, never by an agent or skill. `settle` is `409 already-settled` once the request ended.
599
+
600
+ ---
601
+
504
602
  ## Open Questions
505
603
 
506
604
  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.
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env bash
2
- # Pi Dashboard API helper — wraps curl with port auto-detection and JSON formatting.
2
+ # Pi Dashboard API helper — wraps curl (or `pi-dashboard api` for a local target, which sends local proof)
3
+ # with port auto-detection and JSON formatting.
3
4
  #
4
5
  # This is the REST layer for READ-ONLY + no-WS-twin operations (session/health/
5
6
  # config reads, git ops, grep/browse, plugin_config_write, tunnel, peer scan,
@@ -40,9 +41,46 @@ else
40
41
  PORT=8000
41
42
  fi
42
43
 
44
+ # The config file can hold several "port" keys (e.g. nested ones): the first match is the server port.
45
+ PORT="${PORT%%$'\n'*}"
46
+
43
47
  HOST="${DASHBOARD_HOST:-localhost}"
44
48
  BASE="http://$HOST:$PORT"
45
49
 
50
+ # ── Local callers: send local proof ────────────────────────────────
51
+ #
52
+ # The strict `requireLocalProof` default refuses a bare-loopback curl on every non-observe route.
53
+ # When the target is THIS host and no JWT is in play, delegate to `pi-dashboard api`, which mints a
54
+ # fresh local proof for the request. A remote HOST (or a JWT) keeps the plain curl path below.
55
+ # See change: close-container-loopback-impersonation (D5).
56
+ case "$HOST" in
57
+ localhost|127.0.0.1|::1|"[::1]")
58
+ if [ -z "${DASHBOARD_TOKEN:-}" ] && command -v pi-dashboard >/dev/null 2>&1; then
59
+ API_ARGS=(api "$METHOD" "$PATH_ARG" --port "$PORT")
60
+ case "$METHOD" in
61
+ POST|PUT|PATCH)
62
+ BODY_OUT="$BODY"
63
+ [ -n "$BODY_OUT" ] || BODY_OUT='{}'
64
+ API_ARGS+=(--data "$BODY_OUT")
65
+ ;;
66
+ esac
67
+ if RESPONSE=$(pi-dashboard "${API_ARGS[@]}" 2>&1); then
68
+ :
69
+ else
70
+ RC=$?
71
+ # A non-2xx answer: show the server's body, then fail like curl -f would not (curl -s prints it and exits 0).
72
+ if [ "$RC" = "2" ]; then
73
+ echo "ERROR: Failed to reach dashboard at $BASE" >&2
74
+ echo "Is the server running? Try: pi-dashboard status" >&2
75
+ exit 1
76
+ fi
77
+ fi
78
+ if command -v jq &>/dev/null; then echo "$RESPONSE" | jq . 2>/dev/null || echo "$RESPONSE"; else echo "$RESPONSE"; fi
79
+ exit 0
80
+ fi
81
+ ;;
82
+ esac
83
+
46
84
  # ── Build curl args ────────────────────────────────────────────────
47
85
 
48
86
  CURL_ARGS=(-s -X "$METHOD")
@@ -30,6 +30,7 @@
30
30
  */
31
31
  import { BusClient } from "@blackbelt-technology/pi-dashboard-bus-client";
32
32
  import type { SessionStatus } from "@blackbelt-technology/pi-dashboard-shared/types.js";
33
+ import { dialHost, proofHeaders } from "./local-proof.ts";
33
34
 
34
35
  function flag(args: string[], name: string): string | undefined {
35
36
  const i = args.indexOf(`--${name}`);
@@ -62,7 +63,8 @@ async function main(): Promise<void> {
62
63
  const [cmd, ...rest] = process.argv.slice(2);
63
64
  if (!cmd) die("usage: dashboard-bus.ts <command> … (see file header)");
64
65
 
65
- const client = new BusClient();
66
+ // Dial the loopback literal and prove locality for the ticket mint (the strict default refuses a bare caller).
67
+ const client = new BusClient({ host: dialHost(), proofHeaders });
66
68
  await client.connect();
67
69
 
68
70
  const resolveId = (prefix: string): string => {
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Local-proof headers for the dashboard skill's scripts.
3
+ *
4
+ * The strict `requireLocalProof` default refuses a bare-loopback caller on every non-observe route
5
+ * (including the `/api/ws-ticket` mint the bus client starts with). A script running on the dashboard's
6
+ * own host proves it by minting an `X-Pi-Local-Proof` from the local token, bound to the exact request.
7
+ * The proof binds an address LITERAL, so scripts dial `127.0.0.1`, never `localhost` (`dialHost`).
8
+ *
9
+ * Node built-ins + the shared proof primitive only. No token (the dashboard never ran here) ⇒ `{}`.
10
+ *
11
+ * See change: close-container-loopback-impersonation (D5).
12
+ */
13
+ import { readFileSync } from "node:fs";
14
+ import { homedir } from "node:os";
15
+ import { join } from "node:path";
16
+ import { httpProofHeaders, localDialHost } from "@blackbelt-technology/pi-dashboard-shared/local-credential-proof.js";
17
+
18
+ function localToken(): string | null {
19
+ try {
20
+ return readFileSync(join(homedir(), ".pi", "dashboard", "local", "token"), "utf8").trim() || null;
21
+ } catch {
22
+ return null;
23
+ }
24
+ }
25
+
26
+ /** The literal to dial for a configured host (`localhost` → `127.0.0.1`). */
27
+ export function dialHost(configured: string | undefined = process.env.DASHBOARD_HOST): string {
28
+ return localDialHost(configured);
29
+ }
30
+
31
+ /** A `BusClient` `proofHeaders` provider. */
32
+ export function proofHeaders(method: string, url: string): Record<string, string> {
33
+ const token = localToken();
34
+ if (!token) return {};
35
+ try {
36
+ return httpProofHeaders(token, url, method);
37
+ } catch {
38
+ return {};
39
+ }
40
+ }