@blackbelt-technology/pi-agent-dashboard 0.6.1 → 0.7.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 (105) hide show
  1. package/README.md +40 -38
  2. package/docs/architecture.md +148 -2
  3. package/package.json +6 -4
  4. package/packages/extension/package.json +4 -3
  5. package/packages/extension/src/AGENTS.md +1 -0
  6. package/packages/extension/src/__tests__/bridge-resume-disconnect.test.ts +333 -0
  7. package/packages/extension/src/__tests__/openspec-cli-shim.test.ts +145 -0
  8. package/packages/extension/src/__tests__/provider-register-native-models.test.ts +182 -0
  9. package/packages/extension/src/__tests__/provider-register-thinking-levels.test.ts +54 -1
  10. package/packages/extension/src/__tests__/single-derivation-guard.test.ts +39 -0
  11. package/packages/extension/src/bridge-context.ts +21 -0
  12. package/packages/extension/src/bridge.ts +41 -6
  13. package/packages/extension/src/openspec-cli-shim.ts +173 -0
  14. package/packages/extension/src/openspec-cli-shim.ts.AGENTS.md +7 -0
  15. package/packages/extension/src/provider-register.ts +180 -17
  16. package/packages/extension/src/provider-register.ts.AGENTS.md +1 -1
  17. package/packages/extension/src/session-sync.ts +9 -4
  18. package/packages/server/package.json +8 -8
  19. package/packages/server/src/__tests__/decorate-goals-spend.test.ts +79 -0
  20. package/packages/server/src/__tests__/embed-lifecycle-boot-smoke.test.ts +44 -0
  21. package/packages/server/src/__tests__/goal-routes.test.ts +62 -7
  22. package/packages/server/src/__tests__/goal-supervisor.test.ts +4 -4
  23. package/packages/server/src/__tests__/headless-pid-registry.test.ts +7 -3
  24. package/packages/server/src/__tests__/memory-event-store.test.ts +369 -13
  25. package/packages/server/src/__tests__/models-introspection-thinking-map.test.ts +67 -0
  26. package/packages/server/src/__tests__/pi-changelog-routes.test.ts +9 -2
  27. package/packages/server/src/__tests__/recovery-offer.test.ts +42 -7
  28. package/packages/server/src/__tests__/recovery-reattach-retraction.test.ts +188 -0
  29. package/packages/server/src/__tests__/session-tags-persistence.test.ts +29 -0
  30. package/packages/server/src/browser-handlers/AGENTS.md +1 -1
  31. package/packages/server/src/browser-handlers/__tests__/session-meta-handler.test.ts +98 -1
  32. package/packages/server/src/browser-handlers/handler-context.ts +24 -13
  33. package/packages/server/src/browser-handlers/session-action-handler.ts +12 -1
  34. package/packages/server/src/browser-handlers/session-meta-handler.ts +29 -0
  35. package/packages/server/src/embed-lifecycle/AGENTS.md +17 -0
  36. package/packages/server/src/embed-lifecycle/__tests__/caps.test.ts +129 -0
  37. package/packages/server/src/embed-lifecycle/__tests__/embed-lifecycle-controller.test.ts +84 -0
  38. package/packages/server/src/embed-lifecycle/__tests__/identity-key.test.ts +73 -0
  39. package/packages/server/src/embed-lifecycle/__tests__/idle-reaper.test.ts +173 -0
  40. package/packages/server/src/embed-lifecycle/__tests__/lifecycle-config.test.ts +26 -0
  41. package/packages/server/src/embed-lifecycle/__tests__/lifecycle-event-capture.test.ts +32 -0
  42. package/packages/server/src/embed-lifecycle/__tests__/lifecycle-marker-persistence.test.ts +106 -0
  43. package/packages/server/src/embed-lifecycle/__tests__/lifecycle-metrics.test.ts +39 -0
  44. package/packages/server/src/embed-lifecycle/__tests__/liveness-probe.test.ts +77 -0
  45. package/packages/server/src/embed-lifecycle/__tests__/quiescence.test.ts +175 -0
  46. package/packages/server/src/embed-lifecycle/__tests__/reclamation-soak.test.ts +77 -0
  47. package/packages/server/src/embed-lifecycle/__tests__/session-lifecycle-policy.test.ts +38 -0
  48. package/packages/server/src/embed-lifecycle/__tests__/visitor-session-registry.test.ts +140 -0
  49. package/packages/server/src/embed-lifecycle/caps.ts +88 -0
  50. package/packages/server/src/embed-lifecycle/cwd-allowlist.ts +50 -0
  51. package/packages/server/src/embed-lifecycle/embed-lifecycle-controller.ts +90 -0
  52. package/packages/server/src/embed-lifecycle/identity-key.ts +73 -0
  53. package/packages/server/src/embed-lifecycle/idle-reaper.ts +161 -0
  54. package/packages/server/src/embed-lifecycle/lifecycle-event-capture.ts +30 -0
  55. package/packages/server/src/embed-lifecycle/lifecycle-metrics.ts +70 -0
  56. package/packages/server/src/embed-lifecycle/liveness-probe.ts +123 -0
  57. package/packages/server/src/embed-lifecycle/quiescence.ts +159 -0
  58. package/packages/server/src/embed-lifecycle/session-lifecycle-policy.ts +31 -0
  59. package/packages/server/src/embed-lifecycle/visitor-session-registry.ts +178 -0
  60. package/packages/server/src/event-wiring.ts +20 -0
  61. package/packages/server/src/event-wiring.ts.AGENTS.md +1 -0
  62. package/packages/server/src/goal/AGENTS.md +1 -0
  63. package/packages/server/src/goal/decorate-goals-spend.ts +47 -0
  64. package/packages/server/src/goal/goal-supervisor.ts +5 -3
  65. package/packages/server/src/model-proxy/AGENTS.md +2 -2
  66. package/packages/server/src/model-proxy/__tests__/internal-registry-native-merge.test.ts +155 -0
  67. package/packages/server/src/model-proxy/__tests__/read-native-models.test.ts +92 -0
  68. package/packages/server/src/model-proxy/internal-registry.ts +49 -23
  69. package/packages/server/src/model-proxy/registry-singleton.ts +15 -9
  70. package/packages/server/src/pairing/browser-gateway.ts +40 -11
  71. package/packages/server/src/pairing/browser-gateway.ts.AGENTS.md +1 -1
  72. package/packages/server/src/persistence/memory-event-store.ts +369 -23
  73. package/packages/server/src/persistence/memory-event-store.ts.AGENTS.md +1 -1
  74. package/packages/server/src/routes/AGENTS.md +2 -2
  75. package/packages/server/src/routes/goal-routes.ts +14 -9
  76. package/packages/server/src/routes/models-introspection-routes.ts +10 -0
  77. package/packages/server/src/routes/system-routes.ts +16 -1
  78. package/packages/server/src/server.ts +216 -65
  79. package/packages/server/src/server.ts.AGENTS.md +1 -1
  80. package/packages/server/src/session/memory-session-manager.ts +4 -0
  81. package/packages/server/src/session/session-scanner.ts +9 -0
  82. package/packages/server/src/session/session-to-meta.ts +6 -0
  83. package/packages/server/src/spawn-process/headless-pid-registry.ts +14 -4
  84. package/packages/shared/package.json +1 -1
  85. package/packages/shared/src/AGENTS.md +5 -3
  86. package/packages/shared/src/__tests__/models-json-reader.test.ts +100 -0
  87. package/packages/shared/src/__tests__/nightly-workflow-contract.test.ts +125 -0
  88. package/packages/shared/src/__tests__/openspec-poller-1.6.0-compat.test.ts +112 -0
  89. package/packages/shared/src/__tests__/pnpm-migration-contract.test.ts +177 -0
  90. package/packages/shared/src/__tests__/publish-workflow-contract.test.ts +6 -3
  91. package/packages/shared/src/browser-protocol.ts +22 -0
  92. package/packages/shared/src/config.ts +70 -0
  93. package/packages/shared/src/dashboard-plugin/AGENTS.md +1 -1
  94. package/packages/shared/src/dashboard-plugin/slot-props.ts +9 -0
  95. package/packages/shared/src/dashboard-plugin/ui-primitives.ts +19 -0
  96. package/packages/shared/src/models-json-reader.ts +98 -0
  97. package/packages/shared/src/platform/AGENTS.md +1 -1
  98. package/packages/shared/src/platform/paths.ts +12 -0
  99. package/packages/shared/src/session-meta.ts +9 -0
  100. package/packages/shared/src/types.ts +52 -1
  101. package/docs/AGENTS.md +0 -47
  102. package/packages/extension/AGENTS.md +0 -7
  103. package/packages/server/AGENTS.md +0 -7
  104. package/packages/shared/AGENTS.md +0 -7
  105. package/scripts/AGENTS.md +0 -38
package/README.md CHANGED
@@ -139,8 +139,9 @@ C++ build tools are typically **not** required — `node-pty` ships a Windows x6
139
139
  ```bash
140
140
  git clone https://github.com/BlackBeltTechnology/pi-agent-dashboard.git
141
141
  cd pi-agent-dashboard
142
- npm install
143
- npm run build # one-time client build
142
+ corepack enable # activates the pinned pnpm (packageManager field)
143
+ pnpm install
144
+ pnpm run build # one-time client build
144
145
  pi install /path/to/pi-agent-dashboard # global
145
146
  # or: pi install -l /path/to/pi-agent-dashboard # project-local only
146
147
  ```
@@ -150,12 +151,12 @@ pi install /path/to/pi-agent-dashboard # global
150
151
  By default, `pi-dashboard` on your PATH refers to whatever copy was installed globally (via `npm i -g` or the Electron bundle). To make it point at your working tree instead — so every edit is live and bridge auto-start uses your changes — link the workspace:
151
152
 
152
153
  ```bash
153
- npm run link:local # symlinks `pi-dashboard` on PATH to packages/server/bin/pi-dashboard.mjs
154
+ pnpm run link:local # symlinks `pi-dashboard` on PATH to packages/server/bin/pi-dashboard.mjs
154
155
  pi-dashboard status
155
- npm run unlink:local # restore (removes the global symlink)
156
+ pnpm run unlink:local # restore (removes the global symlink)
156
157
  ```
157
158
 
158
- The link survives across shells. Every invocation — including `pi`'s bridge auto-spawn — runs `packages/server/src/cli.ts` via jiti, so you don't need to rebuild the server on edits. The client still requires `npm run build` (or `npm run dev` for HMR).
159
+ The link survives across shells. Every invocation — including `pi`'s bridge auto-spawn — runs `packages/server/src/cli.ts` via jiti, so you don't need to rebuild the server on edits. The client still requires `pnpm run build` (or `pnpm run dev` for HMR).
159
160
 
160
161
  > **Windows note:** symlink creation needs an admin shell or Windows Developer Mode enabled. Everything else works the same as POSIX.
161
162
 
@@ -228,7 +229,7 @@ PI Dashboard now includes a lightweight Simplified Chinese interface for the cor
228
229
  The language selector lives in **Settings → General → Interface**. English remains the default for existing users, and the selection is saved in the browser. Deployments that want to start in Chinese can build the web client with:
229
230
 
230
231
  ```bash
231
- VITE_PI_DASHBOARD_DEFAULT_LANGUAGE=zh-CN npm run build --workspace=@blackbelt-technology/pi-dashboard-web
232
+ VITE_PI_DASHBOARD_DEFAULT_LANGUAGE=zh-CN pnpm --filter @blackbelt-technology/pi-dashboard-web run build
232
233
  ```
233
234
 
234
235
  This keeps plugin-provided dynamic content, package names, model names, and command output unchanged while making the main dashboard usable for Chinese-speaking operators out of the box.
@@ -412,7 +413,7 @@ The bridge extension **automatically starts the dashboard server** when pi launc
412
413
 
413
414
  In the Electron app, if the initial launch attempts fail (or the server is stopped externally), the **loading page exposes a Start server button**, an **Open Doctor link**, and a collapsible **Server log** panel showing the last 20 lines of `~/.pi/dashboard/server.log`. The system tray menu also includes a **Start server / Restart server** item that reflects current server state. All entry points share a single idempotent launch routine in the Electron main process.
414
415
 
415
- **Debugging the Electron app via CDP.** The desktop app accepts an opt-in `--debug-cdp[=<port>]` CLI flag (and equivalent `PI_DEBUG_CDP` env var) that exposes Chromium's Chrome DevTools Protocol on a loopback-only port (default `9222`) so `agent-browser`, Playwright, Chrome DevTools, or any CDP client can attach to the *installed shell* — not just a separate browser pointed at `http://localhost:8000`. The flag wins if both flag and env are set. CDP is **off by default**, never binds beyond `127.0.0.1`, and logs a one-line `[debug-cdp]` warning to stderr when active. **Single-instance contract:** CDP must be enabled at first-instance launch; passing the flag to an already-running instance cannot enable CDP retroactively and only logs a warning — fully quit and relaunch. From this repo, `cd packages/electron && npm run dev:cdp` launches the dev Electron with CDP on. The bundled universal `browser` skill (shipped by the bridge extension) contains a worked-example recipe for attaching `agent-browser` to the Pi Dashboard app.
416
+ **Debugging the Electron app via CDP.** The desktop app accepts an opt-in `--debug-cdp[=<port>]` CLI flag (and equivalent `PI_DEBUG_CDP` env var) that exposes Chromium's Chrome DevTools Protocol on a loopback-only port (default `9222`) so `agent-browser`, Playwright, Chrome DevTools, or any CDP client can attach to the *installed shell* — not just a separate browser pointed at `http://localhost:8000`. The flag wins if both flag and env are set. CDP is **off by default**, never binds beyond `127.0.0.1`, and logs a one-line `[debug-cdp]` warning to stderr when active. **Single-instance contract:** CDP must be enabled at first-instance launch; passing the flag to an already-running instance cannot enable CDP retroactively and only logs a warning — fully quit and relaunch. From this repo, `cd packages/electron && pnpm run dev:cdp` launches the dev Electron with CDP on. The bundled universal `browser` skill (shipped by the bridge extension) contains a worked-example recipe for attaching `agent-browser` to the Pi Dashboard app.
416
417
 
417
418
  **Doctor diagnostics.** Help → Doctor (or the loading-page link) opens a styled `BrowserWindow` (`doctor.html`) that runs the same checks the Electron app already performed — grouped into sections (Runtime, Pi, Server, Bundles, Diagnostics) with status pills, paths, and per-row suggestion callouts; toolbar offers Re-run, Copy as Markdown / Plain, Open server log, Open doctor log, Run setup wizard. The web client exposes the portable subset at **Settings → Diagnostics**, which fetches `/api/doctor` and renders the same sections (Electron-only rows omitted). Both surfaces share `packages/shared/src/doctor-core.ts`, so a check defined once shows up everywhere.
418
419
 
@@ -713,24 +714,25 @@ Agent metrics are collected every 15s via heartbeats and include `eventLoopMaxMs
713
714
  ### Commands
714
715
 
715
716
  ```bash
716
- npm install # Install dependencies
717
- npm test # Run all tests (vitest)
718
- npm run test:watch # Watch mode
719
- npm run build # Build web client (Vite)
720
- npm run dev # Start Vite dev server (HMR)
721
- npm run lint # Type-check (tsc --noEmit)
722
- npm run reload # Reload all connected pi sessions
723
- npm run reload:check # Type-check + reload all pi sessions
717
+ corepack enable # once: activate the pinned pnpm (packageManager field)
718
+ pnpm install # Install dependencies
719
+ pnpm test # Run all tests (vitest)
720
+ pnpm run test:watch # Watch mode
721
+ pnpm run build # Build web client (Vite)
722
+ pnpm run dev # Start Vite dev server (HMR)
723
+ pnpm run lint # Type-check (tsc --noEmit)
724
+ pnpm run reload # Reload all connected pi sessions
725
+ pnpm run reload:check # Type-check + reload all pi sessions
724
726
  ```
725
727
 
726
728
  ### Typical local dev workflow
727
729
 
728
730
  ```bash
729
731
  # Terminal 1: Dashboard server in dev mode
730
- npx tsx packages/server/src/cli.ts --dev
732
+ pnpm exec tsx packages/server/src/cli.ts --dev
731
733
 
732
734
  # Terminal 2: Vite dev server (HMR for the web client)
733
- npm run dev
735
+ pnpm run dev
734
736
 
735
737
  # Terminal 3: pi with the bridge extension
736
738
  pi -e packages/extension/src/bridge.ts # or just `pi` if installed
@@ -743,19 +745,19 @@ pi -e packages/extension/src/bridge.ts # or just `pi` if installed
743
745
 
744
746
  ```bash
745
747
  # After client changes (production mode)
746
- npm run build
748
+ pnpm run build
747
749
  curl -X POST http://localhost:8000/api/restart
748
750
 
749
751
  # After server changes (runs TypeScript directly, no build needed)
750
752
  curl -X POST http://localhost:8000/api/restart
751
753
 
752
754
  # After bridge extension changes
753
- npm run reload
755
+ pnpm run reload
754
756
 
755
757
  # Full rebuild (e.g., after pulling updates)
756
- npm run build
758
+ pnpm run build
757
759
  curl -X POST http://localhost:8000/api/restart
758
- npm run reload
760
+ pnpm run reload
759
761
  ```
760
762
 
761
763
  ### Extension UI events
@@ -794,18 +796,18 @@ packages/
794
796
  ### Native build (current platform)
795
797
 
796
798
  ```bash
797
- npm run electron:build # Build for current platform & arch
798
- npm run electron:build -- --arch x64 # Override architecture
799
- npm run electron:build -- --skip-client # Skip client rebuild
799
+ pnpm run electron:build # Build for current platform & arch
800
+ pnpm run electron:build -- --arch x64 # Override architecture
801
+ pnpm run electron:build -- --skip-client # Skip client rebuild
800
802
  ```
801
803
 
802
804
  Or step by step:
803
805
 
804
806
  ```bash
805
- npm run build # Build web client
807
+ pnpm run build # Build web client
806
808
  cd packages/electron
807
809
  bash scripts/download-node.sh # Download Node.js for bundling
808
- npm run make # Build installer
810
+ pnpm run make # Build installer
809
811
  ```
810
812
 
811
813
  Output by platform:
@@ -821,10 +823,10 @@ Output by platform:
821
823
  From macOS or Linux, build installers for all platforms:
822
824
 
823
825
  ```bash
824
- npm run electron:build -- --all # macOS (native) + Linux + Windows (Docker)
825
- npm run electron:build -- --linux # Linux .deb + .AppImage only
826
- npm run electron:build -- --windows # Windows .zip only
827
- npm run electron:build -- --linux --windows # Both, skip native
826
+ pnpm run electron:build -- --all # macOS (native) + Linux + Windows (Docker)
827
+ pnpm run electron:build -- --linux # Linux .deb + .AppImage only
828
+ pnpm run electron:build -- --windows # Windows .zip only
829
+ pnpm run electron:build -- --linux --windows # Both, skip native
828
830
  ```
829
831
 
830
832
  ### Building both macOS DMGs locally (`--mac-both`)
@@ -832,7 +834,7 @@ npm run electron:build -- --linux --windows # Both, skip native
832
834
  On an Apple Silicon mac, produce both the arm64 and Intel x64 DMGs in one invocation:
833
835
 
834
836
  ```bash
835
- npm run electron:build -- --mac-both
837
+ pnpm run electron:build -- --mac-both
836
838
  ```
837
839
 
838
840
  Requires Rosetta 2 (`softwareupdate --install-rosetta --agree-to-license`) so node-pty's x64 prebuilt binary can be unpacked during the cross-arch run. The script wipes per-arch caches between the two builds (`resources/.last-arch` sentinel) so back-to-back runs don't accidentally ship arm64 binaries inside an x64 DMG. Intel macs cannot cross-build arm64 locally (Rosetta is one-way) — use CI for arm64 validation.
@@ -844,11 +846,11 @@ Docker builds use a Node 22 Debian container for Windows cross-compilation. Outp
844
846
  ```bash
845
847
  # Start the dashboard server and Vite dev server first
846
848
  pi-dashboard start --dev
847
- npm run dev
849
+ pnpm run dev
848
850
 
849
851
  # Then launch Electron pointing at the dev server
850
852
  cd packages/electron
851
- npm run start:dev
853
+ pnpm run start:dev
852
854
  ```
853
855
 
854
856
  ### Regenerating icons
@@ -857,7 +859,7 @@ All platform icon variants are generated from the master icon at `packages/elect
857
859
 
858
860
  ```bash
859
861
  cd packages/electron
860
- npm run icons # Generates .icns (macOS), .ico (Windows), and resized PNGs
862
+ pnpm run icons # Generates .icns (macOS), .ico (Windows), and resized PNGs
861
863
  ```
862
864
 
863
865
  ---
@@ -870,10 +872,10 @@ See [`docs/release-process.md`](docs/release-process.md) for the full cut-a-rele
870
872
 
871
873
  Every push to `develop` and every pull request against `develop` triggers [`ci.yml`](.github/workflows/ci.yml):
872
874
 
873
- 1. `npm ci` — install dependencies
874
- 2. `npm run lint` — type check
875
- 3. `npm test` — run tests
876
- 4. `npm run build` — build web client
875
+ 1. `pnpm install --frozen-lockfile` — install dependencies
876
+ 2. `pnpm run lint` — type check
877
+ 3. `pnpm test` — run tests
878
+ 4. `pnpm run build` — build web client
877
879
 
878
880
  ### Releasing
879
881
 
@@ -499,6 +499,20 @@ Automation plugin = `packages/automation-plugin/`. Schedule-triggered background
499
499
  - UI via shell slots: sidebar-folder-section, command-route `/automation`, shell-overlay-route, session-card-badge, settings-section general.
500
500
  - See change: add-automation-plugin.
501
501
 
502
+ ### Hermes Memory Settings Plugin (`add-hermes-memory-settings-plugin`)
503
+
504
+ New package `packages/hermes-memory-plugin` (client + server + shared). Settings-section plugin for the external `pi-hermes-memory` pi extension.
505
+
506
+ - Two Fastify routes on shared instance (`ctx.fastify`): `GET /api/plugins/hermes-memory/config` + `PUT /api/plugins/hermes-memory/config`.
507
+ - GET returns per `MemoryConfig` field: `{ value (on-disk else default), default, isDefault }` + `filePath` + `exists` + `raw`.
508
+ - PUT validates browser body via `validateHermesConfig` (shared) BEFORE any write — unknown-key allowlist, type/enum/numeric-bound, `correction*Patterns` regex-compile. Invalid → 400, no write.
509
+ - Write is atomic: tmp file in same dir + `fs.rename`, pretty 2-space JSON, `mkdir -p` parent. Full resolved config written on save (every field's effective value).
510
+ - External-file contract: edits the exact file the extension loads — `PI_CODING_AGENT_DIR` (trimmed, `~`-expanded) else `<home>/.pi/agent`, then fixed `hermes-memory-config.json`. Filename never from request input (no path traversal).
511
+ - No hermes API exists; plugin re-declares `MemoryConfig` + defaults in `src/shared/hermes-config.ts` (mirrors goal-plugin vs pi-goal-hermes). Drift risk accepted; source-version pin comment references pi-hermes-memory@0.8.1.
512
+ - `requires.piExtensions: ["pi-hermes-memory"]` — section + routes active only when extension installed.
513
+ - Runtime caveat: hermes reads config once at extension load → edits apply to newly started sessions only ("applies to new sessions" notice in the UI), not running ones.
514
+ - Structured logging: path + field count on read/write success, failure reason on error, NEVER field values (config may hold model/provider hints).
515
+
502
516
  ### Bootstrap & First Run (R3, immutable bundle)
503
517
 
504
518
  pi/openspec/tsx are regular npm dependencies of `@blackbelt-technology/pi-dashboard-server`. There is no runtime install pyramid. All three arms (Electron, standalone `npm i -g`, bridge) start ready.
@@ -608,7 +622,7 @@ The shared `<RichDiff>` component is also consumed by `DiffPanel` (Path A / chan
608
622
  - `flow-tui.ts`: `autonomousMode` included in `flow:flow-started` event data
609
623
 
610
624
  ### `/reload` Flow (two code paths)
611
- Reload from the dashboard (via `npm run reload`, the reload button, or `/reload` typed into the chat composer) follows one of two paths depending on how the pi session was spawned. The server transparently selects the right path:
625
+ Reload from the dashboard (via `pnpm run reload`, the reload button, or `/reload` typed into the chat composer) follows one of two paths depending on how the pi session was spawned. The server transparently selects the right path:
612
626
 
613
627
  ```mermaid
614
628
  flowchart TD
@@ -1160,7 +1174,7 @@ The web client includes a Settings panel (gear icon in sidebar header → `/sett
1160
1174
  3. Browser's event reducer processes replay, rebuilding state
1161
1175
 
1162
1176
  ### Bridge Reconnection (State Reset)
1163
- When a bridge extension reconnects (e.g., after `npm run reload` or network recovery):
1177
+ When a bridge extension reconnects (e.g., after `pnpm run reload` or network recovery):
1164
1178
  1. Bridge sends `session_register` with `eventCount` to re-register the session
1165
1179
  2. Server checks `canSkipWipe`: if the bridge's `eventCount` matches the server's `lastEntryCount` and events exist in the store, the wipe is skipped (fast reconnect path)
1166
1180
  3. **Full replay path** (`canSkipWipe = false`): Server clears the in-memory event store, broadcasts `session_state_reset` to browsers, stores replayed events, and sends them as `event_replay` batch after `replay_complete`
@@ -1689,6 +1703,20 @@ The dashboard supports browser-based authentication with pi's LLM providers, ena
1689
1703
 
1690
1704
  Custom-provider `/v1/models` endpoints only advertise `{id, owned_by}` — do not expose `context_window`, `max_tokens`, `cost`, `reasoning`. Rather than hardcode flat 200k / 16k / $0 / no-reasoning on every discovered model (silently wrong for proxied frontier models like `proxy/cc/claude-opus-4-7` → Opus 4.7's 1M window), bridge's `registerEntry()` runs each discovered id through pure `enrichModelMetadata(id, api, probe)` helper. Helper: (a) strips common proxy prefixes (`cc/`, `anthropic/`, `openrouter/openai/…`) so bare id tried; (b) probes pi's `modelRegistry.find(provider, id)` via ordered api-appropriate candidate list (`anthropic-messages` → `["anthropic", "opencode"]`, `google-generative-ai` → `["google", "google-vertex"]`, `openai-completions` → `["openai", "openrouter", "groq", "xai", "mistral"]`); (c) returns registry's full metadata when matched. Registry reference captured from `ctx.modelRegistry` first time pi fires `session_start` on extension (`model_select` as fallback capture point) — no direct `@earendil-works/pi-ai` import. Since `activate()` registers providers before any event handler fires, first pass uses fallback defaults; `session_start` handler re-registers all providers with enriched metadata via `pi.registerProvider`'s idempotent "replace" semantics. When registry never available or no match, fallback keeps `input: ["text","image"]` so image-capable-by-default contract preserved. Built-in + OAuth providers bypass entirely — metadata comes from pi's bundled `models.generated.js`. See `packages/extension/src/provider-register.ts` + change `enrich-custom-provider-model-metadata`.
1691
1705
 
1706
+ Native `~/.pi/agent/models.json` (nested `providers.<name>.models[]`) read by BOTH registry paths (bridge extension + dashboard server) via ONE shared reader `flattenModelsJson` in `@blackbelt-technology/pi-dashboard-shared/models-json-reader.js`. File read-only. Shared reader: flattens `providers.<p>.models[]` → entries stamped parent `provider` (parent key wins over in-entry `provider`); accepts legacy top-level array + `{models:[]}`; nested wins on `provider/id` collision; per-provider defensive (bad block → skip, no throw).
1707
+
1708
+ Extension `registerEntry`: registers UNION of `/v1/models` discovered ids + native `providers.<name>.models[]` ids (authored-only/`/v1/models`-down model still reaches session + web UI). Per-id metadata precedence: native `models.json` → registry `probe(name,id)` → `enrichModelMetadata` fallback. Native `contextWindow`/`maxTokens`/`reasoning`/`thinkingLevelMap`/`compat`/`input`/`cost` win. `thinkingLevelMap`+`compat` spread through `pi.registerProvider` + carried on `ModelInfo` via `toModelInfo`.
1709
+
1710
+ Server `getAllModels`: field-level outer join per `provider/id`. Routing (`baseUrl`/`api`/`oauthCompatible`) from discovery; capabilities from native `models.json`, native wins. Native-only surfaces (routing from `providers.json`). Discovered-only keeps fallback floors. Built-in wins over custom under built-in name. `oauthCompatible` NEVER from native.
1711
+
1712
+ `compat` carried on registry model for `streamSimple` proxy request-formatting. `toRow` (`GET /api/models`) NEVER emits `compat` or credentials; `toRow` passes RAW `thinkingLevelMap`, derives NO `supportedThinkingLevels` (sole derivation = extension `deriveSupportedThinkingLevels`, param `maxSupported`).
1713
+
1714
+ Web thinking-level selector gains opt-in `max`: shown only when session pi runtime advertises `max` (probed from runtime `getSupportedThinkingLevels`; 0.75.5 has no `max`, 0.80.10 has) AND `thinkingLevelMap.max` declared non-null. Fail-closed.
1715
+
1716
+ LIMITATION: no `models.json` hot-reload — edit needs refresh trigger (server) or session restart (extension, pi loads at startup).
1717
+
1718
+ See `packages/extension/src/provider-register.ts` + `packages/server/src/model-proxy/internal-registry.ts` + change `honor-native-models-json-metadata`.
1719
+
1692
1720
  ### Testing a custom provider (Test button)
1693
1721
 
1694
1722
  The Settings → Providers → LLM Providers card exposes a **Test** button that posts the unsaved `{ baseUrl, apiKey, api }` combination to `POST /api/providers/test`. The server performs a per-API-type probe:
@@ -2307,6 +2335,43 @@ instead of a red blocker and Continue is enabled.
2307
2335
 
2308
2336
  See change: require-git-on-boot.
2309
2337
 
2338
+ ## Package manager (pnpm)
2339
+
2340
+ Package manager: **pnpm**, pinned to `pnpm@11.15.1` via root `package.json` `packageManager` field + `corepack enable`.
2341
+
2342
+ Scope: pnpm drives ALL dev, CI, Docker, and build work. `npm` survives ONLY in locations listed below.
2343
+
2344
+ Lockfile: Single committed lockfile = `pnpm-lock.yaml`. Old `package-lock.json` removed.
2345
+
2346
+ Configuration lives in `pnpm-workspace.yaml` (NOT `package.json` `pnpm.*` — yaml file takes precedence when present). Config keys:
2347
+
2348
+ - `packages: ['packages/*']` — workspace scope.
2349
+ - `nodeLinker: hoisted` — **MANDATORY**. electron-forge preflight hard-fails with `"When using pnpm, node-linker must be set to 'hoisted'"`. Flattens `node_modules` npm-like. Third-party phantom deps auto-resolve.
2350
+ - `blockExoticSubdeps: false` — Allows transitive git subdep `@electron/node-gyp` (HTTPS codeload). Replaces old fragile `npm@11.12.1` EALLOWGIT pin.
2351
+ - `verifyDepsBeforeRun: false` — Avoids `runDepsStatusCheck`/`execaCoreSync` crash on `pnpm run`.
2352
+ - `linkWorkspacePackages: true` + `preferWorkspacePackages: true` — Local `@blackbelt-technology/*` linked from workspace even when local version > registry.
2353
+ - `confirmModulesPurge: false` — Non-interactive.
2354
+ - `strictDepBuilds: false` — Demotes `ERR_PNPM_IGNORED_BUILDS` from FATAL (pnpm 11 exit 1) to warning. Without it, every CI `pnpm install --frozen-lockfile` reds. (Note: `onlyBuiltDependencies` proved unreliable — allow-listed scripts stay ignored; permit all instead.)
2355
+ - `ignoredBuiltDependencies` — Names known build-script deps to quiet warning.
2356
+ - `overrides: { bonjour-service: 1.4.2 }` — Pins away bad 1.4.3 patch (re-exports `Service`/`Browser` as values, breaks `import { type Service }` in `packages/shared/src/mdns-discovery.ts`).
2357
+
2358
+ **Workspace phantom deps.** `nodeLinker: hoisted` auto-resolves THIRD-PARTY phantom deps. Eight WORKSPACE (`@blackbelt-technology/*`) phantom-dep edges declared explicitly in consuming `package.json` files (plain semver `^` ranges — `sync-versions.js` forbids `workspace:*`).
2359
+
2360
+ **Native builds.** NOT run at `pnpm install`. Rebuilt explicitly where needed:
2361
+ - `_electron-build.yml` runs `pnpm rebuild node-pty` + electron `node install.js`.
2362
+ - `bundle-server.mjs` runs its own `npm install` for electron bundle's `node_modules`.
2363
+
2364
+ **CI install.** Command: `pnpm install --frozen-lockfile`. Cache via `pnpm/action-setup` + `actions/setup-node` `cache: pnpm`.
2365
+
2366
+ **npm survivors (SHALL remain npm).**
2367
+
2368
+ 1. `npm publish --provenance` in `publish.yml` — OIDC Trusted Publishing. Needs no npm-installed tree. `publish` job upgrades to `npm@latest` only for OIDC ≥11.5.1 floor.
2369
+ 2. Column C runtime `npm install` on END-USER machines: `pi-core-updater.ts`, `pi-core-checker.ts`, `recovery-server.ts`, electron `update-checker.ts`.
2370
+ 3. `bundle-server.mjs` internal `npm install --omit=dev` for electron bundle.
2371
+ 4. `deploy-site.yml` `site/` job (separate `site/package-lock.json`; `site/` NOT a pnpm workspace member).
2372
+
2373
+ See change: adopt-pnpm-for-dev-ci.
2374
+
2310
2375
  ## Doctor Diagnostics
2311
2376
 
2312
2377
  Single rich-output diagnostic surface. Three consumers wrap one shared core.
@@ -2438,3 +2503,84 @@ Publish-channel contract: electron-builder writes `app-update.yml` into package
2438
2503
  Draft-vs-published gate: production tags `vX.Y.Z` publish so electron-updater `/releases/latest` resolves them. Pre-release tags `-rc.N` stay drafts → invisible to stable channel. publish.yml metadata-presence assertion fails release when installer ships without its `latest*.yml`.
2439
2504
 
2440
2505
  See change: fix-electron-auto-update-pipeline.
2506
+
2507
+
2508
+ ## Embed session lifecycle
2509
+
2510
+ `SessionSource` gains `"embed"`. New type `LifecyclePolicy = "ephemeral" | "durable"`. `DashboardSession.lifecyclePolicy?` absent means `"durable"`. Read via `isEphemeral()`/`effectiveLifecyclePolicy()` (`packages/server/src/embed-lifecycle/session-lifecycle-policy.ts`), never compared raw.
2511
+
2512
+ Only `ephemeral` sessions governed by reaper + caps. `durable` (human tui/dashboard) sessions keep forever-alive semantics. Persisted to `.meta.json` (`sessionToMeta`) + restored on cold start (`sessionFromMeta` in session-scanner.ts`) — restart never reclassifies ephemeral→durable.
2513
+
2514
+ Producers set `ephemeral`: automation/flow-triggered spawns (event-wiring.ts automation-run arm). Interactive human spawns stay durable. Embed acquire path (future embed front) also sets ephemeral.
2515
+
2516
+ ### Configuration
2517
+
2518
+ Config key `embedLifecycle` under `~/.pi/dashboard/config.json`. All default-inert, dormant when feature disabled. Defined in `packages/shared/src/config.ts` (`EmbedLifecycleConfig`, `DEFAULT_EMBED_LIFECYCLE`):
2519
+
2520
+ | Field | Default | Description |
2521
+ |-------|---------|-------------|
2522
+ | `enabled` | `false` | Reaper/caps/acquire dormant |
2523
+ | `idleTimeoutSeconds` | 1800 | Quiescent idle threshold |
2524
+ | `hardCeilingSeconds` | 3600 | Max ephemeral session lifetime |
2525
+ | `graceWindowSeconds` | 30 | SIGTERM→SIGKILL grace |
2526
+ | `sweepIntervalSeconds` | 60 | Reaper sweep period |
2527
+ | `registerTimeoutSeconds` | 30 | Acquire register await timeout |
2528
+ | `maxActiveEmbedSessionsPerVisitor` | 5 | Per-visitor ephemeral cap |
2529
+ | `maxActiveEmbedSessionsGlobal` | 50 | Global ephemeral cap |
2530
+
2531
+ ### Quiescence + Reaper
2532
+
2533
+ Source: `packages/server/src/embed-lifecycle/`. Quiescence at-rest derived from captured `agent_settled` timestamp (`lastSettledAt`) vs `agent_start` (`lastRunStartedAt`). NOT inferred from `status` — version-agnostic, no `piVersion` branch. Captured in event-wiring.ts via `captureLifecycleTimestamp`; cold-start seeded from session-file mtime.
2534
+
2535
+ Core: pure `decideReap(signals, thresholds, now)` in quiescence.ts. Three gears:
2536
+
2537
+ ```mermaid
2538
+ flowchart LR
2539
+ subgraph Gear1[Gear 1: Idle]
2540
+ A1[Fully quiescent
2541
+ + past idle timeout] --> K1[killBySessionId]
2542
+ end
2543
+ subgraph Gear2[Gear 2: Stop-after-turn]
2544
+ A2[Streaming
2545
+ + no watcher
2546
+ + empty queues
2547
+ + past idle] --> K2[stop_after_turn latch
2548
+ ends at turn_end]
2549
+ end
2550
+ subgraph Gear3[Gear 3: Phantom]
2551
+ A3[Streaming past hard ceiling
2552
+ + ~0 CPU
2553
+ + no child
2554
+ + no watcher
2555
+ + no pending ask
2556
+ + empty queues] --> K3[Force-reap reason "phantom"
2557
+ via graceful ladder]
2558
+ end
2559
+
2560
+ K1 -->|SIGTERM→grace→SIGKILL| D1[Lossless
2561
+ resumable]
2562
+ K2 -->|skipped when queues non-empty| D2[Session
2563
+ resumable]
2564
+ K3 -->|same graceful ladder| D3[Force
2565
+ reap]
2566
+ ```
2567
+
2568
+ Quiescence vetoes (any one blocks idle reap): active generation, currentTool, pending ask_user, followUp/steering queue, live pid-child, live terminal in cwd, active browser subscriber, within grace window.
2569
+
2570
+ Liveness probe (liveness-probe.ts): bounded `ps` pid-tree + CPU sum. Unknown result (ps fail) → safe direction — never idle-reap on unknown child, never phantom on unknown CPU.
2571
+
2572
+ ### Acquire + Caps
2573
+
2574
+ Shared layer, consumed by future embed front. `visitor-session-registry.ts`: idempotent `acquire(req)` keyed by `identityKey = visitorId + canonical cwd (realpath + case-normalized) + agent identity` (identity-key.ts). Ladder: reuse-live → resume-ended → spawn. Concurrent acquires coalesce onto one in-flight promise resolved on `session_register`. Bounded register timeout rejects + clears. Server owns key→sessionId, re-points across resume renumber. cwd validated vs allowlist (cwd-allowlist.ts, D11).
2575
+
2576
+ Caps (caps.ts): `maxActiveEmbedSessionsPerVisitor` + `maxActiveEmbedSessionsGlobal`, count only ephemeral. At cap reclaim oldest quiescent, else `CapacityError` (nothing terminated). Global cap = hard security bound vs spoofed visitorIds.
2577
+
2578
+ ### Observability
2579
+
2580
+ `/api/health` gains `embedLifecycle` field: active/idle ephemeral counts, reaped-by-reason (idle/stop-after-turn/phantom), capacityRejections, reuseHits/reuseMisses. Metrics via lifecycle-metrics.ts.
2581
+
2582
+ ### Wiring
2583
+
2584
+ `createEmbedLifecycleController` (embed-lifecycle-controller.ts) constructed in server.ts. Reaper `start()`/`stop()` tied to server lifecycle. Dormant when `enabled: false`.
2585
+
2586
+ See change: add-embed-session-lifecycle.
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@blackbelt-technology/pi-agent-dashboard",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Web dashboard for monitoring and interacting with pi agent sessions",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/BlackBeltTechnology/pi-agent-dashboard"
8
8
  },
9
9
  "license": "MIT",
10
+ "packageManager": "pnpm@11.15.1",
10
11
  "publishConfig": {
11
12
  "access": "public"
12
13
  },
@@ -91,15 +92,16 @@
91
92
  "node": ">=22.19.0 <26"
92
93
  },
93
94
  "dependencies": {
94
- "@blackbelt-technology/pi-dashboard-extension": "^0.6.1",
95
- "@blackbelt-technology/pi-dashboard-server": "^0.6.1",
96
- "@blackbelt-technology/pi-dashboard-web": "^0.6.1"
95
+ "@blackbelt-technology/pi-dashboard-extension": "^0.7.0",
96
+ "@blackbelt-technology/pi-dashboard-server": "^0.7.0",
97
+ "@blackbelt-technology/pi-dashboard-web": "^0.7.0"
97
98
  },
98
99
  "optionalDependencies": {
99
100
  "appdmg": "^0.6.6"
100
101
  },
101
102
  "devDependencies": {
102
103
  "@biomejs/biome": "2.5.1",
104
+ "@blackbelt-technology/pi-dashboard-shared": "^0.7.0",
103
105
  "@earendil-works/pi-ai": "^0.75.5",
104
106
  "@playwright/test": "1.61.1",
105
107
  "jsdom": "^29.0.2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blackbelt-technology/pi-dashboard-extension",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Pi bridge extension for pi-dashboard",
5
5
  "type": "module",
6
6
  "repository": {
@@ -30,8 +30,9 @@
30
30
  ".pi/skills/doctor/"
31
31
  ],
32
32
  "dependencies": {
33
- "@blackbelt-technology/pi-dashboard-bus-client": "^0.6.1",
34
- "@blackbelt-technology/pi-dashboard-shared": "^0.6.1",
33
+ "@blackbelt-technology/pi-dashboard-bus-client": "^0.7.0",
34
+ "@fission-ai/openspec": "^1.6.0",
35
+ "@blackbelt-technology/pi-dashboard-shared": "^0.7.0",
35
36
  "minimatch": "^10.0.0",
36
37
  "ws": "^8.18.0"
37
38
  },
@@ -32,6 +32,7 @@ Files in this directory. One row per source file.
32
32
  | `multiselect-decode.ts` | Pure helper decoding `PromptResponse` into `string[] | undefined`. → see `multiselect-decode.ts.AGENTS.md` |
33
33
  | `multiselect-list.ts` | TUI multi-select component implementing pi-tui `ComponentLike`. Exports `MultiSelectList`, `ComponentLike`. → see `multiselect-list.ts.AGENTS.md` |
34
34
  | `multiselect-polyfill.ts` | Polyfill `ctx.ui.multiselect`. Exports `polyfillMultiselect`, `PolyfillCtx`. → see `multiselect-polyfill.ts.AGENTS.md` |
35
+ | `openspec-cli-shim.ts` | Provision bare `openspec` in-session: shim pinned CLI onto `process.env.PATH` at bridge init (fail-soft). Exports `provisionOpenspecCli`,… → see `openspec-cli-shim.ts.AGENTS.md` |
35
36
  | `process-metrics.ts` | Lightweight process metrics collector for bridge heartbeats. → see `process-metrics.ts.AGENTS.md` |
36
37
  | `process-scanner.ts` | Detect child processes of a pi session. Exports `getOwnPgid`, `captureChildPgids`, `scanTrackedProcesses`,… → see `process-scanner.ts.AGENTS.md` |
37
38
  | `project-trust.ts` | `project_trust` auto-decision (pure gate + defensive cwd read). → see `project-trust.ts.AGENTS.md` |