@blackbelt-technology/pi-agent-dashboard 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -0
- package/README.md +17 -12
- package/docs/architecture.md +973 -224
- package/package.json +29 -18
- package/packages/extension/package.json +16 -9
- package/packages/extension/src/bridge-context.ts +6 -0
- package/packages/extension/src/bridge-handlers/dispatch.ts +54 -69
- package/packages/extension/src/bridge-handlers/forwarders.ts +19 -42
- package/packages/extension/src/bridge-handlers/instance.ts +21 -12
- package/packages/extension/src/bridge-handlers/lifecycle.ts +84 -40
- package/packages/extension/src/bridge-shutdown.ts +44 -0
- package/packages/extension/src/bridge.ts +272 -260
- package/packages/extension/src/command-handler.ts +26 -31
- package/packages/extension/src/connection.ts +123 -31
- package/packages/extension/src/credential-guard.ts +300 -0
- package/packages/extension/src/custom-entry-forward.ts +27 -18
- package/packages/extension/src/default-model-apply.ts +83 -0
- package/packages/extension/src/flow-event-wiring.ts +19 -95
- package/packages/extension/src/followup-drain.ts +19 -5
- package/packages/extension/src/path-gate/decide.ts +68 -5
- package/packages/extension/src/path-gate/handler.ts +16 -8
- package/packages/extension/src/path-gate/index.ts +2 -2
- package/packages/extension/src/path-gate/roots.ts +15 -3
- package/packages/extension/src/path-gate/suppression.ts +3 -0
- package/packages/extension/src/pi-env.d.ts +8 -1
- package/packages/extension/src/pi-retry-settings.ts +11 -2
- package/packages/extension/src/plugin-event-forward-registry.ts +90 -14
- package/packages/extension/src/preview-path-link.ts +151 -0
- package/packages/extension/src/project-init/scaffold.ts +98 -35
- package/packages/extension/src/project-trust.ts +24 -15
- package/packages/extension/src/provider-model-cache.ts +118 -0
- package/packages/extension/src/provider-register.ts +428 -28
- package/packages/extension/src/retry-tracker.ts +90 -7
- package/packages/extension/src/role-manager.ts +4 -2
- package/packages/extension/src/role-model-tools.ts +21 -4
- package/packages/extension/src/server-auto-start.ts +68 -2
- package/packages/extension/src/server-launcher.ts +26 -8
- package/packages/extension/src/session-sync.ts +11 -12
- package/packages/extension/src/spawn-new-session.ts +22 -0
- package/packages/extension/src/steer-buffer.ts +164 -0
- package/packages/extension/src/stream-forward-buffer.ts +64 -15
- package/packages/extension/src/sudo-askpass/config-reader.ts +32 -0
- package/packages/extension/src/sudo-askpass/controller.ts +405 -0
- package/packages/extension/src/sudo-askpass/helper-script.ts +69 -0
- package/packages/extension/src/sudo-askpass/in-flight.ts +79 -0
- package/packages/extension/src/sudo-askpass/index.ts +11 -0
- package/packages/extension/src/sudo-askpass/install.ts +143 -0
- package/packages/extension/src/sudo-askpass/password-cache.ts +118 -0
- package/packages/extension/src/sudo-askpass/prompt-text.ts +55 -0
- package/packages/extension/src/sudo-askpass/protocol.ts +18 -0
- package/packages/extension/src/sudo-askpass/sudo-mask-registry.ts +52 -0
- package/packages/extension/src/terminal-reload.ts +19 -5
- package/packages/extension/src/tool-update-filter-registry.ts +210 -0
- package/packages/extension/src/vault-redaction.ts +4 -3
- package/packages/server/package.json +17 -14
- package/packages/server/src/access/access-denials.ts +8 -0
- package/packages/server/src/access/access-grants.ts +244 -58
- package/packages/server/src/access/access-plane.ts +7 -0
- package/packages/server/src/access/containment-gate.ts +66 -21
- package/packages/server/src/access/denial-hold.ts +3 -0
- package/packages/server/src/access/grant-coordinator.ts +17 -1
- package/packages/server/src/access/named-grant.ts +3 -0
- package/packages/server/src/access/pending-grant-registry.ts +32 -5
- package/packages/server/src/access/pi-trust-mirror-service.ts +7 -1
- package/packages/server/src/access/planes.ts +1 -0
- package/packages/server/src/access/verified-read.ts +24 -7
- package/packages/server/src/acp-bridge/acp-session-adapter.ts +10 -2
- package/packages/server/src/acp-bridge/server-requests.ts +10 -4
- package/packages/server/src/agent-events/agent-event-hub.ts +1 -1
- package/packages/server/src/auth/audit-log.ts +28 -0
- package/packages/server/src/auth/auth-plugin.ts +188 -15
- package/packages/server/src/auth/auth.ts +80 -0
- package/packages/server/src/auth/bridge-ticket-eligibility.ts +53 -10
- package/packages/server/src/auth/cors-origin.ts +14 -1
- package/packages/server/src/auth/credential-envelope.ts +233 -0
- package/packages/server/src/auth/credential-key-worker.d.mts +16 -0
- package/packages/server/src/auth/credential-key-worker.mjs +108 -0
- package/packages/server/src/auth/credential-key.ts +479 -0
- package/packages/server/src/auth/credential-migration.ts +162 -0
- package/packages/server/src/auth/csp-report-paths.ts +0 -5
- package/packages/server/src/auth/csp.ts +74 -36
- package/packages/server/src/auth/device-proof.ts +202 -0
- package/packages/server/src/auth/duplicate-cookie-gate.ts +271 -0
- package/packages/server/src/auth/host-admission.ts +7 -0
- package/packages/server/src/auth/host-gate.ts +13 -2
- package/packages/server/src/auth/localhost-guard.ts +50 -23
- package/packages/server/src/auth/locked-json-file.ts +68 -6
- package/packages/server/src/auth/models-json-store.ts +269 -0
- package/packages/server/src/auth/mutation-origin-gate.ts +5 -2
- package/packages/server/src/auth/node-guard.ts +36 -49
- package/packages/server/src/auth/plugin-credential-store.ts +81 -10
- package/packages/server/src/auth/provider-auth-storage.ts +208 -11
- package/packages/server/src/auth/provider-block-checks.ts +321 -0
- package/packages/server/src/auth/provider-host-detect.ts +151 -0
- package/packages/server/src/auth/provider-key-file.ts +71 -0
- package/packages/server/src/auth/provider-readiness.ts +91 -0
- package/packages/server/src/auth/route-tier-gate.ts +3 -2
- package/packages/server/src/auth/vertex-key-check.ts +140 -0
- package/packages/server/src/auth/ws-ticket.ts +1 -1
- package/packages/server/src/browse.ts +73 -20
- package/packages/server/src/browser-handlers/acp-guard.ts +1 -4
- package/packages/server/src/browser-handlers/directory-handler.ts +11 -24
- package/packages/server/src/browser-handlers/session-action-handler.ts +158 -62
- package/packages/server/src/browser-handlers/spawn-choice.ts +138 -1
- package/packages/server/src/browser-handlers/subscription-handler.ts +46 -1
- package/packages/server/src/build-plugin-send-prompt.ts +18 -0
- package/packages/server/src/cli/credentials-command.ts +555 -0
- package/packages/server/src/cli.ts +21 -16
- package/packages/server/src/config-api.ts +34 -38
- package/packages/server/src/config-snapshot.ts +149 -0
- package/packages/server/src/directory-service.ts +33 -14
- package/packages/server/src/embed-lifecycle/idle-reaper.ts +13 -3
- package/packages/server/src/event-wiring.ts +181 -101
- package/packages/server/src/git-worktree/ensure-worktree.ts +185 -0
- package/packages/server/src/git-worktree/git-operations.ts +1 -1
- package/packages/server/src/git-worktree/repo-lock.ts +42 -0
- package/packages/server/src/git-worktree/start-worktree-init.ts +151 -0
- package/packages/server/src/git-worktree/worktree-init.ts +5 -1
- package/packages/server/src/identity/http-road-classification.ts +5 -1
- package/packages/server/src/identity/identity-floor.ts +5 -2
- package/packages/server/src/identity/ws-message-scope.ts +10 -3
- package/packages/server/src/identity/ws-road-classification.ts +2 -1
- package/packages/server/src/lib/browse-roots.ts +13 -2
- package/packages/server/src/lib/content-disposition.ts +20 -0
- package/packages/server/src/lib/dashboard-state-guard.ts +304 -21
- package/packages/server/src/lib/eml.ts +2 -2
- package/packages/server/src/lib/frame-policy-probe.ts +308 -0
- package/packages/server/src/lib/frame-policy-test-seam.ts +99 -0
- package/packages/server/src/lib/frame-policy-verdict.ts +125 -0
- package/packages/server/src/lib/grep.ts +4 -1
- package/packages/server/src/lib/index-html.ts +2 -2
- package/packages/server/src/lib/mention-fuzzy-index.ts +263 -0
- package/packages/server/src/lib/office-preview.ts +47 -10
- package/packages/server/src/lib/path-containment.ts +45 -12
- package/packages/server/src/lib/resolve-file-mention.ts +230 -38
- package/packages/server/src/lib/resolve-mentions-batch.ts +143 -0
- package/packages/server/src/lib/writable-handler-target.ts +4 -0
- package/packages/server/src/lib/writable-md-target.ts +22 -0
- package/packages/server/src/lifecycle/boot-parent-liveness.ts +10 -25
- package/packages/server/src/lifecycle/credential-exit-barrier.ts +207 -0
- package/packages/server/src/lifecycle/exit-signal.ts +43 -0
- package/packages/server/src/live-server/capability-redact.ts +21 -5
- package/packages/server/src/live-server/live-capability.ts +416 -52
- package/packages/server/src/live-server/live-csp-report.ts +1 -1
- package/packages/server/src/live-server/live-csp.ts +64 -16
- package/packages/server/src/live-server/live-log.ts +5 -1
- package/packages/server/src/live-server/live-server-manager.ts +11 -0
- package/packages/server/src/live-server/live-server-proxy.ts +268 -52
- package/packages/server/src/live-server/live-static.ts +4 -1
- package/packages/server/src/live-server/preview-dispatch.ts +286 -0
- package/packages/server/src/live-server/preview-observe.ts +53 -0
- package/packages/server/src/live-server/preview-origin.ts +182 -0
- package/packages/server/src/live-server/preview-path-bridge.ts +70 -0
- package/packages/server/src/live-server/preview-path-store.ts +420 -0
- package/packages/server/src/live-server/preview-path.ts +40 -0
- package/packages/server/src/live-server/preview-pool.ts +385 -0
- package/packages/server/src/live-server/preview-preflight.ts +41 -0
- package/packages/server/src/live-server/preview-reserve.ts +44 -0
- package/packages/server/src/live-server/preview-tier.ts +217 -0
- package/packages/server/src/live-server/preview-viewers.ts +54 -0
- package/packages/server/src/live-server/preview-ws-registry.ts +43 -0
- package/packages/server/src/model-proxy/custom-provider-discovery.ts +4 -2
- package/packages/server/src/model-proxy/internal-auth-storage.ts +5 -1
- package/packages/server/src/model-proxy/internal-registry.ts +283 -21
- package/packages/server/src/model-proxy/models-block-apply.ts +291 -0
- package/packages/server/src/model-proxy/pi-models-validator.ts +164 -0
- package/packages/server/src/model-proxy/registry-singleton.ts +44 -9
- package/packages/server/src/model-proxy/server-model-runtime.ts +17 -0
- package/packages/server/src/openspec/readiness.ts +1 -1
- package/packages/server/src/package/provider-probe.ts +194 -5
- package/packages/server/src/pairing/browser-gateway.ts +140 -42
- package/packages/server/src/pairing/device-key-intake.ts +120 -0
- package/packages/server/src/pairing/paired-devices.ts +370 -8
- package/packages/server/src/pairing/pairing.ts +69 -7
- package/packages/server/src/pairing/{subagent-resync-routing.ts → resync-requester-registry.ts} +6 -10
- package/packages/server/src/pairing/ws-tier-gate.ts +74 -0
- package/packages/server/src/pending/pending-attach-registry.ts +15 -0
- package/packages/server/src/pending/pending-initial-prompt-registry.ts +15 -0
- package/packages/server/src/persistence/memory-event-store.ts +251 -296
- package/packages/server/src/persistence/preferences-store.ts +52 -2
- package/packages/server/src/pi/bridge-contention.ts +84 -2
- package/packages/server/src/pi/host-project-trust.ts +15 -9
- package/packages/server/src/pi/pi-gateway.ts +208 -21
- package/packages/server/src/pi/provisional-registration.ts +4 -1
- package/packages/server/src/pi/resource-toggle-trust.ts +17 -6
- package/packages/server/src/pi-agent-settings.ts +95 -301
- package/packages/server/src/pi-default-remirror.ts +89 -0
- package/packages/server/src/plugin-append-event.ts +35 -0
- package/packages/server/src/plugin-entry-stats.ts +61 -0
- package/packages/server/src/plugin-local-request.ts +207 -0
- package/packages/server/src/plugin-ownership.ts +111 -0
- package/packages/server/src/plugin-policy-registry.ts +297 -0
- package/packages/server/src/plugin-request-lane.ts +92 -16
- package/packages/server/src/preferences-relay.ts +20 -0
- package/packages/server/src/project-seed.ts +347 -0
- package/packages/server/src/push/push-transports/webhook-url.ts +8 -5
- package/packages/server/src/questions/question-store.ts +3 -2
- package/packages/server/src/routes/access-routes.ts +23 -6
- package/packages/server/src/routes/acme-routes.ts +14 -4
- package/packages/server/src/routes/agent-event-stream-routes.ts +1 -1
- package/packages/server/src/routes/file-routes.ts +327 -86
- package/packages/server/src/routes/file-write-binary-routes.ts +20 -4
- package/packages/server/src/routes/frame-policy-routes.ts +215 -0
- package/packages/server/src/routes/git-routes.ts +29 -78
- package/packages/server/src/routes/grep-routes.ts +26 -0
- package/packages/server/src/routes/live-server-routes.ts +198 -4
- package/packages/server/src/routes/models-introspection-routes.ts +1 -1
- package/packages/server/src/routes/openspec-routes.ts +17 -3
- package/packages/server/src/routes/pairing-routes.ts +200 -11
- package/packages/server/src/routes/pi-settings-routes.ts +2 -0
- package/packages/server/src/routes/preferences-auto-name-routes.ts +5 -2
- package/packages/server/src/routes/preferences-claude-compat-routes.ts +49 -0
- package/packages/server/src/routes/provider-auth-routes.ts +167 -9
- package/packages/server/src/routes/provider-override-routes.ts +158 -0
- package/packages/server/src/routes/provider-routes.ts +348 -86
- package/packages/server/src/routes/session-routes.ts +25 -22
- package/packages/server/src/routes/system-routes.ts +87 -39
- package/packages/server/src/rpc-keeper/keeper-manager.ts +196 -25
- package/packages/server/src/rpc-keeper/keeper.cjs +37 -23
- package/packages/server/src/runtime-overlay/extension-reload.ts +16 -10
- package/packages/server/src/runtime-overlay/runtime-stager.ts +4 -2
- package/packages/server/src/server.ts +512 -175
- package/packages/server/src/services/cli-service.ts +59 -10
- package/packages/server/src/services/secrets-resolver.ts +46 -30
- package/packages/server/src/session/custom-event-group-annotation.ts +3 -3
- package/packages/server/src/session/custom-event-group-resolver.ts +10 -5
- package/packages/server/src/session/death-reason.ts +11 -7
- package/packages/server/src/session/event-status-extraction.ts +5 -1
- package/packages/server/src/session/memory-session-manager.ts +24 -2
- package/packages/server/src/session/open-tool-calls.ts +81 -47
- package/packages/server/src/session/pid-target.ts +127 -0
- package/packages/server/src/session/replay-compaction.ts +18 -5
- package/packages/server/src/session/seed-discovered-history.ts +85 -0
- package/packages/server/src/session/server-pid-context.ts +14 -0
- package/packages/server/src/session/session-api.ts +78 -29
- package/packages/server/src/session/session-archive.ts +7 -0
- package/packages/server/src/session/session-bootstrap.ts +9 -54
- package/packages/server/src/session/session-load-worker-pool.ts +11 -1
- package/packages/server/src/session/session-load-worker.ts +22 -3
- package/packages/server/src/spawn-process/abort-spawned-run.ts +28 -9
- package/packages/server/src/spawn-process/acp-spawn.ts +8 -2
- package/packages/server/src/spawn-process/headless-pid-registry.ts +383 -72
- package/packages/server/src/spawn-process/link-register.ts +42 -0
- package/packages/server/src/spawn-process/plugin-spawn-choice.ts +48 -0
- package/packages/server/src/spawn-process/plugin-spawn-worktree.ts +290 -0
- package/packages/server/src/spawn-process/process-classifier.ts +8 -3
- package/packages/server/src/spawn-process/process-manager.ts +61 -6
- package/packages/server/src/spawn-process/restored-identity.ts +112 -0
- package/packages/server/src/spawn-process/session-terminator.ts +179 -18
- package/packages/server/src/spawn-process/spawn-env-contributors.ts +2 -1
- package/packages/server/src/spawn-process/spawn-failure-log.ts +9 -0
- package/packages/server/src/spawn-process/spawn-register-watchdog.ts +44 -19
- package/packages/server/src/sudo-credential/relay.ts +337 -0
- package/packages/server/src/terminal/terminal-gateway.ts +10 -0
- package/packages/server/src/tls/sources/acme/credentials.ts +3 -2
- package/packages/server/src/tls/sources/acme/runtime.ts +2 -1
- package/packages/server/src/vault/vault-delivery-hub.ts +17 -1
- package/packages/server/src/vault/vault-routes.ts +9 -2
- package/packages/server/src/vault/vault-store.ts +87 -24
- package/packages/server/vendor/xlsx/LICENSE +201 -0
- package/packages/server/vendor/xlsx/PROVENANCE.json +13 -0
- package/packages/server/vendor/xlsx/xlsx.d.mts +1065 -0
- package/packages/server/vendor/xlsx/xlsx.mjs +28228 -0
- package/packages/shared/package.json +4 -2
- package/packages/shared/src/agent-credential-files.ts +32 -0
- package/packages/shared/src/browser-protocol.ts +137 -57
- package/packages/shared/src/canvas-detect.ts +1 -1
- package/packages/shared/src/canvas-types.ts +2 -2
- package/packages/shared/src/config.ts +73 -136
- package/packages/shared/src/containment-guard.ts +14 -4
- package/packages/shared/src/credential-encryption.ts +87 -0
- package/packages/shared/src/custom-event-groups.ts +2 -0
- package/packages/shared/src/dashboard-plugin/claude-compat.ts +159 -0
- package/packages/shared/src/dashboard-plugin/host-api.ts +1 -1
- package/packages/shared/src/dashboard-plugin/manifest-types.ts +46 -0
- package/packages/shared/src/dashboard-plugin/plugin-status.ts +4 -3
- package/packages/shared/src/dashboard-plugin/replay-entry-types.ts +46 -0
- package/packages/shared/src/dashboard-plugin/slot-props.ts +2 -0
- package/packages/shared/src/dashboard-plugin/slot-types.ts +1 -1
- package/packages/shared/src/dashboard-plugin/ui-primitives.ts +11 -3
- package/packages/shared/src/device-key-proof.ts +309 -0
- package/packages/shared/src/event-forward-declaration.ts +85 -12
- package/packages/shared/src/forbidden-subjects.ts +126 -14
- package/packages/shared/src/heap-limits.ts +0 -30
- package/packages/shared/src/host-admission.ts +2 -1
- package/packages/shared/src/index.ts +7 -6
- package/packages/shared/src/live-server.ts +20 -0
- package/packages/shared/src/mcp/verb-tiers.generated.ts +1 -3
- package/packages/shared/src/models-json-reader.ts +41 -0
- package/packages/shared/src/network-denial-signal.ts +15 -0
- package/packages/shared/src/node-version.ts +63 -60
- package/packages/shared/src/pairing-knock-client.ts +92 -8
- package/packages/shared/src/pi-agent-settings-lock.ts +311 -0
- package/packages/shared/src/pi-path-compare.ts +31 -0
- package/packages/shared/src/pi-settings-schema.ts +52 -9
- package/packages/shared/src/pi-trust-mirror-snapshot.ts +16 -4
- package/packages/shared/src/pi-trust-mirror-types.ts +2 -0
- package/packages/shared/src/pi-trust-mirror.ts +18 -8
- package/packages/shared/src/pi-trust-resource-digest.ts +18 -12
- package/packages/shared/src/pid-namespace.ts +86 -0
- package/packages/shared/src/platform/native-ts-register.mjs +1 -1
- package/packages/shared/src/platform/process.ts +404 -1
- package/packages/shared/src/platform/resolve-pi-shell.ts +38 -9
- package/packages/shared/src/platform/spawn-runtime.ts +193 -7
- package/packages/shared/src/preview-egress.ts +56 -2
- package/packages/shared/src/preview-origins.ts +398 -0
- package/packages/shared/src/prompt-answer.ts +9 -5
- package/packages/shared/src/protocol.ts +147 -85
- package/packages/shared/src/provider-env-catalog.ts +413 -0
- package/packages/shared/src/provider-overrides.ts +112 -0
- package/packages/shared/src/question-types.ts +6 -0
- package/packages/shared/src/recommended-extensions.ts +79 -26
- package/packages/shared/src/renderer-by-ext.ts +5 -2
- package/packages/shared/src/rest-api.ts +93 -3
- package/packages/shared/src/role-schema.ts +24 -0
- package/packages/shared/src/route-tiers.ts +94 -3
- package/packages/shared/src/runtime-overlay/compat.ts +70 -6
- package/packages/shared/src/secret-patterns.ts +49 -0
- package/packages/shared/src/source-matching.ts +2 -2
- package/packages/shared/src/state-replay.ts +40 -24
- package/packages/shared/src/sudo-credential.ts +71 -0
- package/packages/shared/src/tool-path-resolve.ts +16 -1
- package/packages/shared/src/tool-registry/strategies.ts +1 -1
- package/packages/shared/src/tool-workdir.ts +56 -0
- package/packages/shared/src/trusted-types-mode.ts +72 -0
- package/packages/shared/src/types.ts +68 -109
- package/packages/shared/src/vertex-regions.ts +81 -0
- package/packages/shared/src/ws-message-tiers.ts +10 -3
- package/packages/extension/src/subagent-fanout-admission.ts +0 -234
- package/packages/extension/src/subagent-forward-sites.ts +0 -69
- package/packages/extension/src/subagent-frame-buffer.ts +0 -245
- package/packages/extension/src/subagent-frame-strip.ts +0 -109
- package/packages/extension/src/subagent-saturation.ts +0 -196
- package/packages/extension/src/subagent-tick-throttle.ts +0 -252
- package/packages/shared/src/anthropic-messages-source.ts +0 -8
- package/packages/shared/src/dashboard-plugin/anthropic-peer-names.ts +0 -9
- package/packages/shared/src/dashboard-plugin/subagent-types.ts +0 -219
package/docs/architecture.md
CHANGED
|
@@ -53,7 +53,7 @@ Node.js HTTP + WebSocket server that:
|
|
|
53
53
|
- Serves the built web client as static files (production) or proxies to Vite dev server (dev mode)
|
|
54
54
|
- Writes per-session `.meta.json` sidecar files with dashboard state and cached stats
|
|
55
55
|
- Exposes REST API for session management, event content fetch, pinned directories, and file reading
|
|
56
|
-
- Provides session control REST endpoints (`/api/session/:id/*`) wrapping WebSocket-only operations (prompt, abort, spawn, resume, rename, hide,
|
|
56
|
+
- Provides session control REST endpoints (`/api/session/:id/*`) wrapping WebSocket-only operations (prompt, abort, spawn, resume, rename, hide, model, thinking-level, attach/detach-proposal) — see `src/server/session-api.ts`
|
|
57
57
|
|
|
58
58
|
**Bind model.** HTTP listener + pi gateway WS listener bind `127.0.0.1` by default. Loopback removes socket from wire.
|
|
59
59
|
|
|
@@ -330,18 +330,17 @@ See change: add-acp-session-driver.
|
|
|
330
330
|
- `registerEventBusForwarding`. `packages/extension/src/flow-event-wiring.ts`.
|
|
331
331
|
- ONE `pi.events.on(channel, ...)` subscription per declared channel.
|
|
332
332
|
- `on()` observes every emitter.
|
|
333
|
-
- Declared set =
|
|
333
|
+
- Declared set = plugin-declared channels via `extraMaps`. Core maps removed (`FLOW_EVENT_MAP`, `SUBAGENT_EVENT_MAP`).
|
|
334
334
|
- Channel list IS the contract. Undeclared channel -> never forwarded.
|
|
335
335
|
- New channel -> new map entry. Identity entry when no rename wanted.
|
|
336
336
|
- Retired: wildcard forwarding of any unknown channel. Unimplementable without an emit intercept.
|
|
337
337
|
|
|
338
338
|
**Forward gates.** `forwardBusEvent`, same file.
|
|
339
339
|
|
|
340
|
-
-
|
|
341
|
-
-
|
|
342
|
-
- Other declared channel -> forward when `sessionReady && isActive()`.
|
|
340
|
+
- Plugin `latest`-group channel -> buffered latest-wins in `StreamForwardBuffer` while not forwardable. Flushed on re-register / reconnect.
|
|
341
|
+
- Declared channel -> forward when `sessionReady && isActive()`.
|
|
343
342
|
- Forwarding failure never propagates to the emitter.
|
|
344
|
-
- Forwarding failure drops that live frame. Nothing re-sends it.
|
|
343
|
+
- Forwarding failure drops that live frame. Nothing re-sends it. `latest`-group frames are the exception (buffered).
|
|
345
344
|
|
|
346
345
|
**Teardown.** dispose returned by `registerEventBusForwarding`.
|
|
347
346
|
|
|
@@ -363,6 +362,9 @@ See change: add-acp-session-driver.
|
|
|
363
362
|
**Validation.** `validateDeclaration` — untrusted input.
|
|
364
363
|
- Channel regex requires `:`. Caps: 32 channels/plugin, 256 total.
|
|
365
364
|
- Rejected: `RESERVED_EVENT_TYPES`, channel already in core `EVENT_BUS_MAP`. First owner wins on conflict (counted).
|
|
365
|
+
- `RESERVED_EVENT_TYPES` no longer lists `flow_*`.
|
|
366
|
+
- `as`-type owner index: declaration whose `as` type owned by another `pluginId` → rejected, counted in `pluginEventForward.conflicts`. Same plugin may map two channels to one `as`. Source `packages/extension/src/plugin-event-forward-registry.ts`.
|
|
367
|
+
- Optional `replayEntryTypes: string[]` (plugin's persisted custom-entry types). Registry exposes `replayEntryTypes()`. Live bridge excludes those types from generic custom-entry forwarding and replays them on reconnect.
|
|
366
368
|
- `pluginId`/key regex-validated. Key value string or finite number ≤128 chars, else delivered live-only.
|
|
367
369
|
|
|
368
370
|
**Delivery.**
|
|
@@ -370,6 +372,30 @@ See change: add-acp-session-driver.
|
|
|
370
372
|
- `latest` — keep newest per key until ready.
|
|
371
373
|
- `stream` — keep all, in order, never coalesced.
|
|
372
374
|
|
|
375
|
+
**Example consumer: flows.** Flow catalog rides this path. Replaces core `flows_list` / `getFlowsList` / `FlowInfo` (removed). See change: flows-dock-chip-and-panel-actions.
|
|
376
|
+
- Declares `dashboard-flows:catalog` → `as: flow_catalog`, `delivery: latest`, `key: catalogKey`. Source: `packages/flows-plugin/src/bridge/flow-catalog-publisher.ts`.
|
|
377
|
+
- Payload: `{ catalogKey: "catalog", flows: [{ name, description, source, taskRequired }] }`.
|
|
378
|
+
- Probe: `flow:list-flows` (`flow-probe.ts`). Unanswered → no publish. Answered `[]` → publish empty catalog.
|
|
379
|
+
- Debounce 300 ms. Triggers: `session_start`, `flow:(un)register-(flows|agents)-dir`, `flow:rediscover`, `flow:complete`, publisher attach, server ask `dashboard-flows:report-files`.
|
|
380
|
+
- `report-files` with `{rediscover:true}` → pi-flows rediscovers before publish.
|
|
381
|
+
- Plugin server `packages/flows-plugin/src/server/flow-catalog.ts`:
|
|
382
|
+
- `ctx.onEvent` `flow_catalog` → `stateStore.setFlows`.
|
|
383
|
+
- Handles `plugin_action` `flow.request-catalog` (per-session ask limit, default 2 s).
|
|
384
|
+
- Sibling rediscover ask when known catalog changes.
|
|
385
|
+
- Server-start re-ask: 5 s interval × 60 s.
|
|
386
|
+
- Client `useFlowCatalog`: re-asks every 5 s, max 12 per view, while catalog unknown.
|
|
387
|
+
- Timings: flows plugin settings (`configSchema`).
|
|
388
|
+
|
|
389
|
+
**Example consumer: flow runs.**
|
|
390
|
+
- Flows bridge `packages/flows-plugin/src/bridge/flow-event-forward.ts` (`FLOW_RUN_CHANNELS`) declares 16 pi-flows channels.
|
|
391
|
+
- Step channels (`agent-*`, `subagent-tool-*` → `flow_tool_*`, `assistant-text`, `thinking-text`, `loop-iteration`, `decision` → `flow_decision`) `stream`, keyed `stepId`.
|
|
392
|
+
- `flow:flow-started` / `flow:complete` `stream`, keyed `flowName`.
|
|
393
|
+
- `flow:question` / `flow:answer` `stream`, keyed `stepId` (→ `flow_question` / `flow_answer`). See "Flow parent mailbox".
|
|
394
|
+
- `flow:ask-session-result` `live` (→ `flow_ask_session_result`).
|
|
395
|
+
- `summary-*` `live`.
|
|
396
|
+
- Core `FLOW_EVENT_MAP` and `SUBAGENT_EVENT_MAP` removed. Channels plugin-declared (`packages/extension/src/flow-event-wiring.ts`).
|
|
397
|
+
- Flows disabled → no flow events forwarded.
|
|
398
|
+
|
|
373
399
|
**Retention.** `StreamForwardBuffer` (`packages/extension/src/stream-forward-buffer.ts`).
|
|
374
400
|
- One buffer keyed by (pluginId, key value) — cross-channel order (delta vs entry) survives.
|
|
375
401
|
- ≤2000 msgs or 2MiB per key; 64-key budget shared by latest+stream across plugins, drop-oldest, counted.
|
|
@@ -400,182 +426,100 @@ See change: add-acp-session-driver.
|
|
|
400
426
|
**Second consumer.** `packages/roles-plugin/src/bridge/index.ts`.
|
|
401
427
|
- `before_agent_start` appends one `toolGuidelines.Agent` bullet. Prefer `model:"@role"`, ≤12 configured roles. Only when Agent tool selected.
|
|
402
428
|
|
|
403
|
-
###
|
|
404
|
-
|
|
405
|
-
**Why thin ticks.**
|
|
406
|
-
|
|
407
|
-
- Producer builds ONE `snapshotDetails()` object.
|
|
408
|
-
- Feeds BOTH carriers: `subagents:*` EventBus frame + pi-core `tool_execution_update`.
|
|
409
|
-
- `entries[]` append-only → tick size grows linearly with run length.
|
|
410
|
-
- Long run = fat intermediate ticks.
|
|
411
|
-
- Solution: strip timeline from intermediate ticks.
|
|
412
|
-
- Push terminal frame fat.
|
|
413
|
-
- Pull full timeline on demand.
|
|
414
|
-
|
|
415
|
-
**Strip module.**
|
|
416
|
-
|
|
417
|
-
- File: `packages/extension/src/subagent-frame-strip.ts`.
|
|
418
|
-
- Exports `stripSubagentEntries`, `stripForForward`, `NON_TERMINAL_STATUSES`.
|
|
419
|
-
- Strips `details.entries` on FORWARD path when frame status `queued` or `running`.
|
|
420
|
-
|
|
421
|
-
**Allowlist, never negation.**
|
|
422
|
-
|
|
423
|
-
- `NON_TERMINAL_STATUSES` = explicit allowlist.
|
|
424
|
-
- Never `!terminal`.
|
|
425
|
-
- `AgentStatus` also has `stopped`; negation would strip it and lose that run's timeline.
|
|
426
|
-
- `stopped` counts as terminal: never stripped.
|
|
427
|
-
|
|
428
|
-
**Strip clones.**
|
|
429
|
+
### Generic commands-changed seam (change: update-flows-plugin)
|
|
429
430
|
|
|
430
|
-
-
|
|
431
|
-
- `
|
|
432
|
-
-
|
|
433
|
-
- Fat snapshot survives intact for resync.
|
|
431
|
+
- Bus channel `dashboard:commands-changed` (`COMMANDS_CHANGED_CHANNEL`, `packages/shared/src/event-forward-declaration.ts`). Payload ignored.
|
|
432
|
+
- Core bridge: `registerCommandsChangedListener` (`packages/extension/src/flow-event-wiring.ts`), wired from `bridge-handlers/lifecycle.ts`. Resends `commands_list`.
|
|
433
|
+
- Flows bridge emits it on `flow:rediscover` / `flow:complete`. Replaces former core listeners.
|
|
434
434
|
|
|
435
|
-
|
|
435
|
+
### Plugin entry replay (change: update-flows-plugin)
|
|
436
436
|
|
|
437
|
-
-
|
|
438
|
-
-
|
|
439
|
-
-
|
|
440
|
-
-
|
|
441
|
-
-
|
|
442
|
-
-
|
|
443
|
-
-
|
|
437
|
+
- Manifest field `pi-dashboard-plugin.replayEntryTypes: string[]` (flows: `["flow-event"]`). Lenient: malformed → contributes nothing.
|
|
438
|
+
- `packages/shared/src/dashboard-plugin/replay-entry-types.ts`: `normalizeReplayEntryTypes`, `computeReplayEntryTypes` → `{ replay (enabled plugins), hidden (every declaring plugin) }`.
|
|
439
|
+
- Server `packages/server/src/plugin-entry-stats.ts`: provider set at boot from discovered manifests (5 s cache).
|
|
440
|
+
- Session load (`session-load-worker-pool.ts` → `session-load-worker.ts`) passes sets to `replayEntriesAsEvents`. OFFLINE sessions replay from manifests, not a live bridge.
|
|
441
|
+
- `packages/shared/src/state-replay.ts`:
|
|
442
|
+
- `opts.replayEntryTypes` replays `{ seq, eventType, data }` records, seq-sorted, verbatim. Extra fields (`flowRunId`) ignored. Malformed skipped.
|
|
443
|
+
- `opts.hiddenEntryTypes` keeps disabled plugins' entries off every generic path. No replay.
|
|
444
|
+
- Core names no entry type.
|
|
445
|
+
- Live bridge: `custom-entry-forward.ts` excludes declared types.
|
|
446
|
+
- Client reducer `lib/plugins/plugin-entry-types.ts` (seeded in `App.tsx` from bundled registry) refuses generic rows.
|
|
447
|
+
- Server `CustomEventGroupResolver` never groups them.
|
|
448
|
+
- KNOWN BLOCKER: pi flushes custom entries only after first assistant message.
|
|
449
|
+
- `/api/health` `pluginEntries`: `declaredReplayTypes`, `replayedPluginEntries`, `rejectedPluginActions`.
|
|
444
450
|
|
|
445
|
-
|
|
451
|
+
### Subagent delivery via plugin seams (change: move-subagents-to-plugin)
|
|
446
452
|
|
|
447
|
-
-
|
|
448
|
-
- Terminal frame = durable record behind `tool_execution_end` backfill.
|
|
449
|
-
- Second independent terminal guard: `stripForForward(data, channel)` never strips when `channel` in `TERMINAL_CHANNELS` (`subagents:completed`, `subagents:failed`).
|
|
450
|
-
- Guard fires regardless of `details.status`.
|
|
451
|
-
- Both signals must be wrong to lose a timeline.
|
|
453
|
+
Replaces the core thin-tick push/pull split (change: reduce-subagent-details-payload). Core names no subagent contract.
|
|
452
454
|
|
|
453
|
-
**
|
|
455
|
+
**Boundary.**
|
|
454
456
|
|
|
455
|
-
-
|
|
456
|
-
-
|
|
457
|
-
-
|
|
458
|
-
-
|
|
459
|
-
- No version negotiation.
|
|
460
|
-
- No producer change.
|
|
461
|
-
- Dropped thin tick leaves no permanent hole.
|
|
457
|
+
- Core carries no `subagents:*` channel, event map, frame buffer, strip, or resync frame.
|
|
458
|
+
- Enforced by `scripts/check-subagent-boundary.mjs`. Runs in `npm test`.
|
|
459
|
+
- Deleted from core: `SUBAGENT_EVENT_MAP`, `SubagentFrameBuffer`, `subagent-frame-strip.ts`, `subagent-forward-sites.ts`, `subagent_resync_request`, `useSubagentResyncCadence.ts`, `PI_DASHBOARD_SUBAGENT_STRIP`, tick throttle.
|
|
460
|
+
- Deleted e2e: tick-throttle, pull-measurements, thin-tick-liveness, pull-under-load specs.
|
|
462
461
|
|
|
463
|
-
**
|
|
462
|
+
**Generic seams.**
|
|
464
463
|
|
|
465
|
-
-
|
|
466
|
-
-
|
|
464
|
+
- Ownership: plugin manifest declares owned channels/event types. Server sends `plugin_ownership` table (`packages/server/src/plugin-ownership.ts`).
|
|
465
|
+
- Buffer: `StreamForwardBuffer` supports `latest` `group` + per-plugin `maxKeys`. Latest-wins per group key.
|
|
466
|
+
- Tool-update filter: bridge event `dashboard:register-tool-update-filter`. Registry `packages/extension/src/tool-update-filter-registry.ts`. Plugin filters `tool_execution_update` carrier.
|
|
467
|
+
- Server policies: `ctx.registerStorePolicy`, `registerDeliveryPolicy`, `registerReplayCarry`, `onSessionStatusEnded`, `appendEvent`. Registry `packages/server/src/plugin-policy-registry.ts`. Runtime types `packages/dashboard-plugin-runtime/src/server/plugin-policies.ts`.
|
|
468
|
+
- Replay carry: server sends `plugin_event_carry` frame after `history_window`, before first `event_replay`.
|
|
469
|
+
- Client state: `SessionState.pluginState` + `useSessionPluginState`. Reducer finalizer lookup `findFinalizerForEventType`.
|
|
470
|
+
- Version gate: manifest `requires.piExtensionVersions`. Subagents plugin `>=0.7.0`. Unmet range → `missingRequirements` → shown by shell plugin surfaces (Settings → Plugins, plugin settings page, Add-ons issues). Plugin renders no notice, reads no status.
|
|
467
471
|
|
|
468
|
-
**
|
|
472
|
+
**Subagents plugin implementations.**
|
|
469
473
|
|
|
470
|
-
- `
|
|
471
|
-
-
|
|
472
|
-
-
|
|
473
|
-
-
|
|
474
|
-
-
|
|
475
|
-
- `
|
|
474
|
+
- `packages/subagents-plugin/src/bridge/index.ts` — forward channels, latest-wins buffer, tool-update filter, registry reconcile on `subagents:list`.
|
|
475
|
+
- `server/store-policy.ts` — store trim/keep rules for subagent events.
|
|
476
|
+
- `server/delivery-policy.ts` — per-connection delivery rules.
|
|
477
|
+
- `server/session-end-heal.ts` — `onSessionStatusEnded` heal of non-terminal agents.
|
|
478
|
+
- `server/replay-carry.ts` — `plugin_event_carry` payload for reconnect.
|
|
479
|
+
- `client/pluginState.ts` — plugin-owned reducer state in `SessionState.pluginState`.
|
|
476
480
|
|
|
477
|
-
**
|
|
481
|
+
**Invariants kept.**
|
|
478
482
|
|
|
479
|
-
-
|
|
480
|
-
-
|
|
481
|
-
-
|
|
482
|
-
- ONE timer per subagent → inline inspector + popout do not double-fire.
|
|
483
|
-
- No `emptyTimeline` precondition on this trigger (open-time trigger keeps it).
|
|
483
|
+
- Every frame = idempotent FULL snapshot. Latest-supersedes.
|
|
484
|
+
- Terminal frames (`completed`/`failed`/`aborted`/`stopped`/`error`) never stripped.
|
|
485
|
+
- Dropped intermediate tick leaves no permanent hole.
|
|
484
486
|
|
|
485
|
-
|
|
487
|
+
### Subagent concurrency and stop (change: subagent-queue-visibility)
|
|
486
488
|
|
|
487
|
-
-
|
|
488
|
-
- Bridge echoes it on reply as `__resyncRequestId`.
|
|
489
|
-
- Server routes reply to that one connection (`packages/server/src/pairing/subagent-resync-routing.ts`, `ResyncRequesterRegistry`, TTL 30000 ms).
|
|
490
|
-
- Unknown/expired token falls back to normal broadcast.
|
|
489
|
+
**Ownership.** Producer `@blackbelt-technology/pi-dashboard-subagents` >= 0.6.0 owns the one concurrency limit (`maxConcurrent`). Dashboard holds no `tool_call` admission gate. Excess `Agent` calls queue, never refused.
|
|
491
490
|
|
|
492
|
-
**
|
|
491
|
+
**Setting.**
|
|
493
492
|
|
|
494
|
-
-
|
|
495
|
-
-
|
|
496
|
-
|
|
497
|
-
**Rollback. PARTIAL, not total.**
|
|
498
|
-
|
|
499
|
-
- One flag: `PI_DASHBOARD_SUBAGENT_STRIP=0` forwards unstripped.
|
|
500
|
-
- Flag disables STRIPPING ONLY.
|
|
501
|
-
- Wire payload returns to pre-change shape: intermediate ticks fat again.
|
|
502
|
-
- These stay ACTIVE under the flag: `locateSubagentTimeline` `subagent_*` gate.
|
|
503
|
-
- Stay active: resync cadence in `useSubagentResyncCadence.ts`.
|
|
504
|
-
- Stay active: requester-scoped routing (`requestId` / `__resyncRequestId`).
|
|
505
|
-
- Stay active: additive `storeTrim` subagent-tick counters.
|
|
506
|
-
- Each of those is additive or a bug fix. None depends on the strip.
|
|
507
|
-
- No producer, protocol, or store rollback exists to do.
|
|
508
|
-
|
|
509
|
-
**Known regression, stated deliberately.**
|
|
510
|
-
|
|
511
|
-
- Run dying with NO terminal frame (crash/kill) leaves only thin ticks in store.
|
|
512
|
-
- Recovery needs a LIVE bridge with agent still in the 64-slot `SubagentFrameBuffer`.
|
|
513
|
-
- Evicted or post-reset agents answer `resyncNoop`.
|
|
514
|
-
- Client keeps its last rendered state.
|
|
515
|
-
|
|
516
|
-
### Subagent Fan-out Admission (change: bound-subagent-fanout-under-host-pressure)
|
|
517
|
-
|
|
518
|
-
**Problem.**
|
|
493
|
+
- UI: Settings → Plugins → Subagents, field "Max parallel subagents" (`/settings/plugins/subagents`).
|
|
494
|
+
- Default `4`. Clamp `0`–`64`. `0` = unlimited.
|
|
495
|
+
- Live: applies within ~1 s, incl. waiting subagents.
|
|
519
496
|
|
|
520
|
-
|
|
521
|
-
- 13/14 census sessions died with unanswered fan-out as final transcript entry.
|
|
522
|
-
- Stall triggers `hostPressure` unresponsive verdict; host reaps parent process.
|
|
497
|
+
**Config mirror.**
|
|
523
498
|
|
|
524
|
-
|
|
499
|
+
- `packages/subagents-plugin/src/server/index.ts` mirrors value to `~/.pi/agent/extensions/pi-dashboard-subagents/config.json`.
|
|
500
|
+
- Startup reconcile clamps file value.
|
|
501
|
+
- Write-through only when explicit and different from value producer runs.
|
|
525
502
|
|
|
526
|
-
|
|
527
|
-
- Registered AFTER pass-through forwarder in `bridge.ts`.
|
|
528
|
-
- `runner.emitToolCall` stops at first `{block: true}` handler.
|
|
529
|
-
- Earlier registration starves forwarder; dashboard misses `tool_call` while seeing `tool_execution_end`. Order load-bearing.
|
|
503
|
+
**Heap coupling.**
|
|
530
504
|
|
|
531
|
-
|
|
505
|
+
- `subagentHeapBudget(maxOldSpaceMb, maxConcurrent)` (`packages/shared/src/heap-limits.ts`) warns on plugin field.
|
|
506
|
+
- Warns when `floor(mb/(n+1)) < 100`; `0` warns under ceiling.
|
|
507
|
+
- Reads `GET /api/plugins/subagents/limits` → `{heapCeilingMb}`.
|
|
532
508
|
|
|
533
|
-
|
|
534
|
-
- Platform drops assistant message before extension sees `tool_call`; batch size and batch identity unknowable.
|
|
535
|
-
- In-flight counter increments at admission, not execution.
|
|
536
|
-
- Siblings preflight sequentially before any executes; execution-time counter reads zero across whole batch.
|
|
537
|
-
- Synchronous reject-only decision. Gate never awaits child; awaiting deadlocks preflight sequence.
|
|
509
|
+
**Removed.**
|
|
538
510
|
|
|
539
|
-
|
|
511
|
+
- Admission config keys removed from `packages/shared/src/config.ts`. Leftover keys in `config.json` ignored.
|
|
512
|
+
- Automatic narrowing to 1 under host saturation removed. Constrained hosts lower the limit by hand.
|
|
513
|
+
- Old `subagent-admission-refused` entries resolve to `diagnostics` custom-event group (hidden by default).
|
|
540
514
|
|
|
541
|
-
-
|
|
542
|
-
- Config key: `maxConcurrentSubagents`.
|
|
543
|
-
- Value `0` disables gate (rollback).
|
|
544
|
-
- Absent value resolves to active default (2).
|
|
545
|
-
- Malformed non-integer or negative value resolves to `Infinity` (fail-open).
|
|
515
|
+
**Per-subagent stop.**
|
|
546
516
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
-
|
|
550
|
-
-
|
|
551
|
-
-
|
|
552
|
-
-
|
|
553
|
-
- Separates process domain (`process.cpuUsage()`, event loop delay) from machine domain (`os.loadavg()`).
|
|
554
|
-
- Hysteresis: enter at threshold, exit only when all metrics fall below 80 % of threshold (`SATURATION_EXIT_RATIO = 0.8`).
|
|
555
|
-
|
|
556
|
-
**Permit release.**
|
|
557
|
-
|
|
558
|
-
- Releases permit on `tool_execution_end`.
|
|
559
|
-
- Fires on normal, blocked, and aborted execution paths.
|
|
560
|
-
- Never releases on `tool_result`: aborted call (Esc) skips result hook, leaking permits and starving session.
|
|
561
|
-
|
|
562
|
-
**Refusal semantics.**
|
|
563
|
-
|
|
564
|
-
- Refusal returns `{block: true, reason}`.
|
|
565
|
-
- Produces real errored tool result; renders terminal card with actionable retry reason.
|
|
566
|
-
- Never sets `terminate`: refusal means re-issue later, not session abort.
|
|
567
|
-
|
|
568
|
-
**Observability and durability.**
|
|
569
|
-
|
|
570
|
-
- Refusal writes durable session entry `subagent-admission-refused` via `pi.appendEntry`. Survives process reap.
|
|
571
|
-
- Admissions skip disk writes to protect hot path.
|
|
572
|
-
- Live counters on `ProcessMetrics`: `fanoutAdmitted`, `fanoutRefused`, `fanoutSaturationRefused`.
|
|
573
|
-
|
|
574
|
-
**Scope boundary.**
|
|
575
|
-
|
|
576
|
-
- Gate runs per gated session, not per host process.
|
|
577
|
-
- Subagent sessions skip bridge initialization via re-entry guard.
|
|
578
|
-
- Grandchildren and `flow_agents` run ungated.
|
|
517
|
+
- Route `POST /api/plugins/subagents/stop`, body `{sessionId, agentId}`.
|
|
518
|
+
- Authority: `ctx.identity?.hasOperateAuthority` else `403`.
|
|
519
|
+
- Ids 1–128 chars, no control chars, else `400`. Unknown session `404`.
|
|
520
|
+
- Emits fixed `subagents:stop {agentId}` via `ctx.emitEventToSession`. Manifest `emits: ["subagents:stop"]`. Emit returns `false` → `503`.
|
|
521
|
+
- Behind `ctx.networkGuard`. Each request logs `stop request session=… agent=… outcome=…`.
|
|
522
|
+
- No fallback to session abort.
|
|
579
523
|
|
|
580
524
|
### Retry Lifecycle (change: retry-forever-with-stop-control)
|
|
581
525
|
|
|
@@ -583,10 +527,14 @@ Pi owns the retry loop. Dashboard configures + observes + renders it. Attempts f
|
|
|
583
527
|
|
|
584
528
|
**1. Retry ownership & settings.**
|
|
585
529
|
|
|
586
|
-
- Pi `RetrySettings` = `{ enabled, maxRetries, baseDelayMs, provider: {timeoutMs, maxRetries, maxRetryDelayMs} }`.
|
|
587
|
-
- Session-layer delay = `baseDelayMs * 2^(attempt-1)
|
|
530
|
+
- Pi `RetrySettings` = `{ enabled, maxRetries, baseDelayMs, maxAgentDelayMs, provider: {timeoutMs, maxRetries, maxRetryDelayMs} }`.
|
|
531
|
+
- Session-layer delay = pi-ai `retryDelayMs`: `min(baseDelayMs * 2^max(0,attempt-1), maxAgentDelayMs ?? 60000)`.
|
|
532
|
+
- Unsafe product saturates to `MAX_SAFE_INTEGER`. Capped.
|
|
533
|
+
- Present since pi-ai 1.3.0 (extension peer floor). Call site: pi `AgentSession._prepareRetry`.
|
|
534
|
+
- Hidden cap made raised `baseDelayMs` look ignored past the cap. Old dashboard countdown used uncapped copy → showed e.g. 1382 s while pi slept 60 s. Fixed by change fix-retry-delay-cap.
|
|
588
535
|
- `retry.maxDelayMs` REMOVED from session layer. pi migrates to `retry.provider.maxRetryDelayMs` (different layer, different semantics).
|
|
589
|
-
- Overshoot consequence: next attempt lands ~2x elapsed.
|
|
536
|
+
- Overshoot consequence: next attempt lands ~2x elapsed. Holds only below the cap. Once `base*2^(n-1) > maxAgentDelayMs` every wait = cap (constant).
|
|
537
|
+
- Scale-invariant below cap. Tuning `baseDelayMs` shifts which attempt lands where, never the ratio.
|
|
590
538
|
- Dashboard runs NO retry loop. Raising `retry.maxRetries` is the whole "retry forever" mechanism.
|
|
591
539
|
- `resume mode:"continue"` cannot re-drive live turn (refused `resume.already_active`). For ended session resolves to `pi --session <file>` which reopens IDLE + drives no turn. No re-drive mechanism exists — none needed, since pi never settles turn while budget remains.
|
|
592
540
|
|
|
@@ -597,18 +545,25 @@ Pi owns the retry loop. Dashboard configures + observes + renders it. Attempts f
|
|
|
597
545
|
- New rules: error `message_end` records pending error text → emits nothing. Error `agent_end` = attempt over + another coming → emits `auto_retry_start` + `auto_retry_waiting` (carries `attempt`, `delayMs`, `nextAttemptAt`), does NOT clear chain. `agent_settled` = SOLE terminal → emits `auto_retry_end`, clears chain.
|
|
598
546
|
- Waiting signal suppressed once `attempt >= maxAttempts`.
|
|
599
547
|
- `agent_settled` carries NO `messages` (verified pi 0.81.1/0.83), so tracker remembers terminal disposition via `lastEndWasError` at `agent_end`.
|
|
600
|
-
- `-1` sentinels REMOVED. `maxAttempts` / `delayMs` sourced read-only from pi settings via `packages/extension/src/pi-retry-settings.ts` (defaults 3 / 2000
|
|
548
|
+
- `-1` sentinels REMOVED. `maxAttempts` / `delayMs` sourced read-only from pi settings via `packages/extension/src/pi-retry-settings.ts` (defaults 3 / 2000 / cap 60000).
|
|
549
|
+
- `pi-retry-settings.ts` reads `retry.maxAgentDelayMs` (any finite number; project overrides global).
|
|
550
|
+
- `delayMs` from pi-ai `retryDelayMs` installed via `installPiAiDelayFn(tracker)` (fire-and-forget dynamic import, rejection swallowed); else local mirror `cappedDelay`.
|
|
551
|
+
- Guard in `delayFor`: base `<=0` or attempt `<1` → 0.
|
|
552
|
+
- fn throw / non-number / non-finite → `cappedDelay`.
|
|
553
|
+
- Final negative or non-finite → 0 (elapsed-only).
|
|
554
|
+
- Parity test `packages/extension/src/__tests__/retry-delay-parity.test.ts` asserts mirror == pi-ai across grid.
|
|
601
555
|
- pi 0.83 exposes retry lifecycle events to RPC/SDK consumers ONLY. ExtensionAPI has no `auto_retry_*` and nothing on EventBus. `willRetry` in 0.83 is compaction-only (`session_before_compact`/`session_compact`). Bridge is extension → must observe-synthesize.
|
|
602
|
-
- Native `agent_settled` guaranteed at the 1.
|
|
556
|
+
- Native `agent_settled` guaranteed at the 1.7.0 lockstep floor (`piCompatibility.minimum == recommended == 1.7.0`). Bridge consumes the native settle unconditionally — no version gate, no floor-pi synthesis. Floor-pi synthesis module `packages/extension/src/agent-settled.ts` DELETED. `agent_settled` remains the SOLE terminal retry signal. See change: update-pi-core-0-85-adopt-apis, update-pi-core-1-7-adopt-apis.
|
|
603
557
|
- Bridge follow-up drain (`bridgeFollowUp`) triggers on `agent_settled`, not `agent_end`. Forwarder schedules `drainFollowupQueue()` via `setTimeout(0)`; pi clears run-active before `agent_settled`, so `isIdle()` is true. No retry loop: a false `isIdle()` returns, the next `agent_settled` drains. Gate sequence: `packages/extension/src/followup-drain.ts`. See change: update-pi-core-1-3-adopt-apis.
|
|
604
558
|
|
|
605
559
|
**3. Settings write + reload-on-save** (`packages/server/src/pi-agent-settings.ts`).
|
|
606
560
|
|
|
607
|
-
- Reads/writes all
|
|
561
|
+
- Reads/writes all SEVEN native fields: `retry.{enabled,maxRetries,baseDelayMs,maxAgentDelayMs}` (`maxAgentDelayMs` default 60000) + `retry.provider.{timeoutMs,maxRetries,maxRetryDelayMs}` in GLOBAL `~/.pi/agent/settings.json`. Blank `provider.timeoutMs` OMITTED on write (never `0`/`null`).
|
|
608
562
|
- Write is MERGE-PRESERVING: every other key survives, including `retry.provider.*`.
|
|
609
563
|
- Project `<cwd>/.pi/settings.json` NEVER written.
|
|
610
564
|
- Distinct from `config-api.ts`, which writes dashboard's own `~/.pi/dashboard/config.json`.
|
|
611
|
-
- Validation: `maxRetries` non-negative integer; `baseDelayMs` positive integer. Invalid → nothing written.
|
|
565
|
+
- Validation: `maxRetries` non-negative integer; `baseDelayMs` positive integer; `maxAgentDelayMs` non-negative integer (0 = no wait, legal). Invalid → nothing written.
|
|
566
|
+
- Preview `computeSchedule(maxRetries, base, cap)` in `packages/client/src/components/settings/RetrySettingsSection.tsx` uses capped curve. O(1) past cap (closed-form remainder). `retry-cap-notice` names first capped attempt.
|
|
612
567
|
- No UI cap on `maxRetries`; long tail WARNED, never capped.
|
|
613
568
|
- REST: `GET/PUT /api/pi-retry` (`packages/server/src/routes/pi-retry-routes.ts`), auth-gated by same network guard as `/api/config`.
|
|
614
569
|
- pi reads settings only at session construction. Write alone inert for running sessions.
|
|
@@ -616,7 +571,7 @@ Pi owns the retry loop. Dashboard configures + observes + renders it. Attempts f
|
|
|
616
571
|
- Target set = `reloadTargetSessionIds` = `piGateway.getConnectedSessionIds()` ∪ `headlessPidRegistry.listSessions()`.
|
|
617
572
|
- Connected-only set missed headless sessions with dead bridge WS. See change: fix-out-of-band-reload.
|
|
618
573
|
- Failed write reloads nothing.
|
|
619
|
-
- **UI placement + save.** Editor renders on Settings **Sessions** tab (NOT Providers). Reason:
|
|
574
|
+
- **UI placement + save.** Editor renders on Settings **Sessions** tab (NOT Providers). Reason: 4 fields (`enabled`, `maxRetries`, `baseDelayMs`, `maxAgentDelayMs`) turn-level not provider-scoped; observable effect on session (waiting / attempt n / countdown / Stop). Sibling turn-lifecycle settings co-located.
|
|
620
575
|
- Enclosing section titled "Retry".
|
|
621
576
|
- NO private Save button. Registers with panel unified-Save draft registry via `useSettingsDraftSource({id:"pi-retry", page:"sessions", isDirty, commit, reset})`. See change: unify-settings-save-contract.
|
|
622
577
|
- Consequences: one Save commits every dirty store. Sessions nav shows per-page dirty dot. Leave guard offers Save / Discard / Cancel.
|
|
@@ -755,6 +710,8 @@ Status-based dispatch rests on invariant: `register()` is only path to non-ended
|
|
|
755
710
|
|
|
756
711
|
**Health.** `/api/health#droppedFrames` counters `statusReconcileQueued` (entries recorded owed) + `statusReconcileSent` (reconcile frames re-sent) count every registry kind. No new `/api/health` field. Accepted health-counter shift: shed reorders move from `droppedFrames.total` to `coalescedState`. `/api/health#socketBufferOccupancy` = `{ max, p95, msAboveThreshold }` over browser-socket `bufferedAmount`; typed-zero fallback `EMPTY_SOCKET_BUFFER_OCCUPANCY`. Sampled at the send-decision sites, which already read `bufferedAmount` for the shed predicate — **not** on a timer. A periodic sampler was implemented first and rejected: it breaks the "zero timers on an unsaturated socket" invariant (`browser-gateway-critical-frames` P3/E9). Time-above-threshold uses a per-socket entry/exit span (`occupancyAboveSince`); the hot exit branch is gated on `size > 0`.
|
|
757
712
|
|
|
713
|
+
**Subagent end / liveness frames are deferred, not shed** (change: fix-background-subagent-ghost-rows). `deferKeyOfEvent(msg)` keys `subagent_completed` / `subagent_failed` (real end `subagent_end:<sid>:<id>`, heal `subagent_heal:<sid>:<id>`), `subagent_stop_result` (`subagent_stop_result:<sid>:<agentId>`) and `subagent_registry_snapshot` (`subagent_registry_snapshot:<sid>`); no string id → no key → shed. `frameClassOf` is unchanged (still `transcript`). Healthy socket → full frame. Where `sendTo` would shed, a bounded projection (`projectDeferredSubagentFrame`: no timeline, `result`/`error` ≤ 8 KB, `deferredProjection:true`) goes to `sendState` under its key. Counted `/api/health#droppedFrames.deferredSubagentFrames` (also under `serverToBrowser`) — not a drop. The client replay persister never caches a `deferredProjection` event.
|
|
714
|
+
|
|
758
715
|
**`msAboveThreshold` is OBSERVATION-based, not continuous wall-clock.** Sampling happens at send decisions, so a crossing that starts and ends between two decisions is never observed, and a reported duration is bounded by the samples that delimit it. `getSocketBufferOccupancy()` adds spans still open at read time (else an in-progress stall reports 0), and SETTLES a span whose socket has since drained or closed — without that, an event-driven sampler leaves such a span open forever and it grows on every health read (unbounded over-report). Settling deletes the entry, so a later exit cannot accrue it twice.
|
|
759
716
|
|
|
760
717
|
**Test-only injector.** `POST /api/test/force-shed { enabled }` forces transcript-class frames to shed while leaving `bufferedAmount` untouched. Registered ONLY under `PI_E2E_FORCE_SHED=1` (set in `docker/compose.test.yml`, never a real image); still `networkGuard`-gated. Returns the effective state, so an unflagged server reports refusal instead of a silent no-op. Exists because real saturation is a browser failing to drain its own socket, which Playwright cannot induce. Drives `tests/e2e/status-reconcile.spec.ts`.
|
|
@@ -986,8 +943,50 @@ pi-flows runs multi-agent workflows in-process. Subagent sessions use `SessionMa
|
|
|
986
943
|
5. React renders `FlowDashboard` (sticky card grid above ChatView), `FlowAgentDetail` (replaces chat), `FlowSummary` (post-completion). Component code lives in `packages/flows-plugin/src/client/` and is imported by the shell via `@blackbelt-technology/pi-dashboard-flows-plugin/client`. Slot-consumer-based mounting is tracked as the follow-up change `migrate-flows-jsx-to-slots`; the current shell imports the components directly. See change: extract-flows-as-plugin.
|
|
987
944
|
|
|
988
945
|
**Flow controls (browser → pi-flows):**
|
|
989
|
-
-
|
|
990
|
-
-
|
|
946
|
+
- Flow commands: `plugin_action { pluginId: "flows", action }`, action ∈ `flow.abort | flow.ask-session | flow.dismiss-summary | flow.run | flow.delete | flow.set-edit-mode`. Handled in `packages/flows-plugin/src/server/flow-control.ts`.
|
|
947
|
+
- REST: `POST /api/plugins/flows/control` (operate authority + network guard). ACP session → 409 `unsupported_for_acp`.
|
|
948
|
+
- MCP tool: `flows_control`.
|
|
949
|
+
- Probe channel for models: `models:get-available`.
|
|
950
|
+
- Flow types (`FlowState` etc.) live in `packages/flows-plugin/src/types.ts`, not shared.
|
|
951
|
+
|
|
952
|
+
**Flow actions UI (flows-dock-chip-and-panel-actions):**
|
|
953
|
+
- `FLOWS` chip: `composer-context-group` claim.
|
|
954
|
+
- Panel headers (`FlowDashboard`, `FlowSummary`): Run again / Open flow… / Edit….
|
|
955
|
+
- Panels default collapsed.
|
|
956
|
+
- Session actions menu: New flow… / "Turn on edit mode for this project" only for flowless sessions.
|
|
957
|
+
- Shared logic: `useFlowActions(session)` + `<FlowActionDialogs>`.
|
|
958
|
+
- Flow list source: `useFlowCatalog(sessionId)` → `flow_catalog` (see Plugin-declared event forwarding).
|
|
959
|
+
|
|
960
|
+
**Agent `flow_open` tool (add-flow-open-tool):**
|
|
961
|
+
- Bridge `packages/flows-plugin/src/bridge/flow-open-tool.ts` registers pi tool `flow_open` via `pi.registerTool`.
|
|
962
|
+
- Loads only where flows plugin bridge loads. pi-flows unchanged.
|
|
963
|
+
- Params: exactly one of `flow` (catalog `<ns>:<name>`, runnable) or `path` (flow.yaml/flow.yml or dir directly containing one; view-only). Else `refused/invalid-arguments`.
|
|
964
|
+
- `promptGuidelines`: call `flow_open` after writing/editing/inspecting a flow.
|
|
965
|
+
- Bridge tracks active `runId`: `flow:flow-started` sets; `flow:complete` same `runId` clears; `session_start` resets. Active run → local `refused/flow-running`.
|
|
966
|
+
- Relative `path` resolved vs tool ctx cwd.
|
|
967
|
+
- Lane `requestPluginServer("flows","flow/open")`. Lane error or missing seam → `refused/unavailable`. Never throws.
|
|
968
|
+
- Server `packages/flows-plugin/src/server/flow-open.ts` `registerFlowOpen`: lane `hubLocalOnly`. Session id from lane meta only.
|
|
969
|
+
- `flow`: lookup `stateStore` catalog. Miss → `requestCatalog(sid,{rediscover:true})`, retried while cooldown-suppressed, poll 100 ms up to 1.5 s → else `unknown-flow`.
|
|
970
|
+
- `path` admission (`locateFlowPath`): resolve vs session cwd → realpath → dir ⇒ direct `flow.yaml|flow.yml` → regular file ≤ `MAX_FILE_BYTES` (1 MiB) → confined to `realpath(cwd)` (cwd `/` handled). Refusals `path-not-allowed` / `not-a-flow`.
|
|
971
|
+
- No content read before admission. Then read via host `readFileGuarded` (absent → `unavailable`).
|
|
972
|
+
- Dir without direct flow → `candidates` (≤20, cwd-relative). Walk: lstat BFS depth ≤6, skip `node_modules`/`.git`, no symlink follow. Walk visits ≤2000 dirs.
|
|
973
|
+
- Dir pick: first regular `flow.yaml`, else `flow.yml`. Definition must carry `steps` array, else `not-a-flow`.
|
|
974
|
+
- Path equal to catalog definition (canonical; catalog `source` resolved vs cwd) → opens as catalog flow (runnable).
|
|
975
|
+
- Path-opened flow files → `FlowFileRegistry.open()` (shared `flowFileRegistry`): def + code handlers + reported agents it names, each confined to cwd.
|
|
976
|
+
- Registry entries survive `report()`. Dropped on session end.
|
|
977
|
+
- Each `/api/plugins/flows/file` read re-realpaths (must be unchanged + inside cwd) else 403. Host routes unchanged.
|
|
978
|
+
- Delivery: broadcast `flows_open {sessionId, requestId, attachment{name, source, viewOnly, baselineStartedAt: Date.now()}}`.
|
|
979
|
+
- `baselineStartedAt` = call accept time, stamped before catalog rediscovery wait.
|
|
980
|
+
- `frameClassOf` classes it `state`, key `flows_open:<sessionId>:<requestId>` (never shed; never coalesced; each pin acked). Owner-scoped where identity enforced.
|
|
981
|
+
- Client `FlowOpenListener` (`shell-headless` claim): stores attachment per device (`flow-attach-store`).
|
|
982
|
+
- Client expands panel (`setFlowCollapsed(sid,["dashboard"],false)`). Sends `flows_open_ack {sessionId, requestId}` (tier `observe`, session-owned). Dedupe 128 requestIds.
|
|
983
|
+
- Server counts acks per ws over fixed 1.5 s window (pending map ≤ 64) → `shown {acks, name, path, viewOnly}` or `no-viewer`.
|
|
984
|
+
- Full pending map → new call `refused/rate-limited`; never evicts an open window.
|
|
985
|
+
- Rate limit 10 calls / 10 s per session (cleared on session end) → `rate-limited`.
|
|
986
|
+
- One `logger.info` per call: `flow_open session=<id> kind=<flow|path> outcome=<…> reason=<…> acks=<n>`. Never file content.
|
|
987
|
+
- View-only panel: no Run, no Edit…. Label "view only - not registered".
|
|
988
|
+
- View-only definition fetched with `fetchFlowFile(..., {noHostFallback:true})`.
|
|
989
|
+
- Load error adds "ask the agent to open it again" hint + Close.
|
|
991
990
|
|
|
992
991
|
### Extension UI System (Phases 1 + 2 shipped)
|
|
993
992
|
|
|
@@ -1105,7 +1104,7 @@ sequenceDiagram
|
|
|
1105
1104
|
|
|
1106
1105
|
**Relationship to existing capabilities:**
|
|
1107
1106
|
- `interactive-ui-dialogs` / `ui-proxy` / PromptBus — handle one-shot `ctx.ui.*` dialogs (request/response, awaited). The extension-ui-system handles persistent push-based descriptors (no awaiting). Orthogonal mechanisms; both ship.
|
|
1108
|
-
- `extension-ui-forwarding` (per-channel declared-set forwarding) — bridge forwards via one `pi.events.on` subscription per declared channel (`registerEventBusForwarding`). Channels:
|
|
1107
|
+
- `extension-ui-forwarding` (per-channel declared-set forwarding) — bridge forwards via one `pi.events.on` subscription per declared channel (`registerEventBusForwarding`). Channels: plugin-declared (no core map) via `dashboard:register-event-forward`. RPC probe channels (`flow:list-flows`, `roles:*`, `model:resolve`, `ui:list-modules`…) kept out of core map; plugin declarations naming one not rejected. No `emit` wrapper. The new system is the *declarative* path for UI specifically. No authored spec — file removed (0-byte placeholder since initial commit). See change: repair-corrupted-main-specs. See change: skip-rpc-probes-in-event-forwarder.
|
|
1109
1108
|
- pi-flows: in Phase 3 pi-flows itself adopts the system to surface registered workflows (breadcrumb), gates, and cards (agent-metric) for any flow-using extension automatically.
|
|
1110
1109
|
|
|
1111
1110
|
**No-dashboard fallback:** When no bridge is connected, `ui:list-modules` is never emitted; extension listeners are dormant; slash commands fall back to existing text-output behavior. Extensions remain pi-runnable in pure-pi mode without code changes.
|
|
@@ -1137,7 +1136,7 @@ First-party slots (React, possibly also descriptor):
|
|
|
1137
1136
|
```mermaid
|
|
1138
1137
|
flowchart TB
|
|
1139
1138
|
CV["ChatView (shrinkable)"] --> SB["SessionBanner (fixed)"]
|
|
1140
|
-
SB --> AN["composer-stack-anchor (fixed,
|
|
1139
|
+
SB --> AN["composer-stack-anchor (fixed, content-height chip slot)"]
|
|
1141
1140
|
AN --> DK
|
|
1142
1141
|
subgraph DK["composer-dock (shrinkable)"]
|
|
1143
1142
|
direction TB
|
|
@@ -1147,6 +1146,8 @@ flowchart TB
|
|
|
1147
1146
|
DK --> CI["CommandInput card: textarea + one toolbar row"]
|
|
1148
1147
|
```
|
|
1149
1148
|
|
|
1149
|
+
- `composer-stack-anchor` = canvas chip slot (`shrink-0 mx-5`, 0 px while no chip). `CanvasDriver` portals chip tray into it while live composer + chat pane visible. No live composer or `full` editor mode → fixed bottom-right overlay fallback. See change: fix-chat-transcript-layout.
|
|
1150
|
+
|
|
1150
1151
|
- Sibling of `CommandInput`, never inside it. Mounted by `ComposerDockHost.tsx` (hook boundary for `App.tsx`; also `DirectoryHomeView.tsx`). Visual join CSS only: `mx-5` inset (8px inside card edges, drawer look), `-mb-6 pb-6` tucks bottom edge 12px under card; `composer-root` drops its full-width `border-t` while dock visible (index.css sibling rule). team-app `ChatPane` embeds `CommandInput` bare: no dock.
|
|
1151
1152
|
- Nothing renders for `readOnly` (archived) views or when no lane and no YOLO footer.
|
|
1152
1153
|
- Files (`packages/client/src/components/chat/`): `ComposerDock.tsx` (layout, accordion render, compact mode, YOLO footer, live region), `composer-dock-model.ts` (`DockLane`, `DockLaneKey`, `DOCK_LANE_ORDER`, `useDockAccordion`), `useComposerDockLanes.ts` (builds Changes/OpenSpec/Queue/Context lanes), `ProcessesLane.tsx` + `ProcessesLaneBody.tsx` (built into dock), `ChangesLane.tsx`, `QueueLane.tsx`, `ContextLane.tsx`, `useDockCompactMode.ts`.
|
|
@@ -1292,7 +1293,7 @@ Dual-write contract. `registerPluginBridge` writes BOTH locations in `~/.pi/agen
|
|
|
1292
1293
|
- `packages[]` — user-visible package list. pi-coding-agent reads only this.
|
|
1293
1294
|
- `_dashboardManagedPackages` — ownership map. Tracks which `packages[]` entries owned by dashboard vs user. Prevents clobbering user-added entries.
|
|
1294
1295
|
|
|
1295
|
-
pi-coding-agent ignores `dashboardPluginBridges` entirely. Bridge extensions invisible to pi until written to `packages[]`. Symptom of single-write bug: plugin bridge loaded by dashboard but never invoked by pi runtime;
|
|
1296
|
+
pi-coding-agent ignores `dashboardPluginBridges` entirely. Bridge extensions invisible to pi until written to `packages[]`. Symptom of single-write bug: plugin bridge loaded by dashboard but never invoked by pi runtime; Symptom: bridge status reports "no sessions reporting".
|
|
1296
1297
|
|
|
1297
1298
|
Reconciliation: one-shot `reconcilePluginBridgePackages` runs at server start. Replays current plugin manifests through `ensurePackageEntry` for every claim with a `bridge` entry. Drops dangling managed entries via `removePackageEntry` when manifest gone. Atomic settings write (tmp + rename).
|
|
1298
1299
|
|
|
@@ -1493,7 +1494,7 @@ flowchart LR
|
|
|
1493
1494
|
- Client pieces: `packages/client/src/lib/plugins/runtime-plugin-loader.ts`, `packages/client/src/host-shims/*`.
|
|
1494
1495
|
- Remote-server mode (`getApiBase()` non-empty) + Vite `--dev` page: loader does nothing.
|
|
1495
1496
|
|
|
1496
|
-
**Core/plugin boundary.** `npm run check:plugin-boundary` (`scripts/check-plugin-boundary.mjs`, ratcheting `scripts/plugin-boundary-allowlist.json`, vitest wrapper). Plugin set from manifests. Shared contracts + `packages/mcp-core` in `docs/plugin-seams.md`.
|
|
1497
|
+
**Core/plugin boundary.** `npm run check:plugin-boundary` (`scripts/check-plugin-boundary.mjs`, ratcheting `scripts/plugin-boundary-allowlist.json`, vitest wrapper). Plugin set from manifests. Flow-literal check: string literals starting `flow:` / `flow_` / `flow-` or containing `pi-flows` in non-test `packages/{extension,server,shared,client}/src` fail unless in allowlist `literalRows`. Shared contracts + `packages/mcp-core` in `docs/plugin-seams.md`.
|
|
1497
1498
|
|
|
1498
1499
|
**Absent-owner UX.** Manifest `eventTypes` → one group row per owned event type; availability decided at render time by `pluginAvailability`. Subagent state written by subagents-plugin slice + finalizers; generic heals in core. See `docs/plugin-seams.md`.
|
|
1499
1500
|
|
|
@@ -1661,6 +1662,168 @@ Automation plugin = `packages/automation-plugin/`. Schedule-triggered background
|
|
|
1661
1662
|
- Not a sandbox. Shell/MCP tools not path-checked. List them in `deniedTools`.
|
|
1662
1663
|
- See change: add-path-containment-guard-extension.
|
|
1663
1664
|
|
|
1665
|
+
### Plugin Spawn Worktree (`add-plugin-spawn-worktree`)
|
|
1666
|
+
|
|
1667
|
+
- `ServerPluginContext.spawnSession(opts)` gains optional `opts.worktree?: { branch; base?; ifExists: "reuse"|"fail"; attachChange? }`.
|
|
1668
|
+
- Honoured only with `mode: "worktree"`. Types: `packages/dashboard-plugin-runtime/src/server/server-context.ts`.
|
|
1669
|
+
- Bare `mode: "worktree"` (no block) → legacy local fallback: runs in `cwd`, warning logged.
|
|
1670
|
+
- Older host ignores block too. Caller treats success without `PluginSpawnResult.worktreePath` as "not in a worktree".
|
|
1671
|
+
- Trusted plugins only (`manifest.priority <= 100`). Same gate as `spawnSession`.
|
|
1672
|
+
- Hook body: `packages/server/src/spawn-process/plugin-spawn-worktree.ts` (`createPluginSpawnHook(deps)`). `server.ts` wires real deps.
|
|
1673
|
+
- Git step: `ensureWorktree` in `packages/server/src/git-worktree/ensure-worktree.ts`. Never throws.
|
|
1674
|
+
- Result: `{ok,path,branch,created}` | `{ok:false,code,message}`.
|
|
1675
|
+
|
|
1676
|
+
`ensureWorktree` order:
|
|
1677
|
+
|
|
1678
|
+
1. Known-folder admission (`admitRouteCwd`, same set as `POST /api/git/worktree`).
|
|
1679
|
+
2. Main-checkout resolve → `not_git`.
|
|
1680
|
+
3. Branch validation: `isValidRefArg`, `git check-ref-format --branch`, `@{` rejected, derived path under `<main>/.worktrees/`.
|
|
1681
|
+
4. Per-repo lock.
|
|
1682
|
+
5. Resolution.
|
|
1683
|
+
|
|
1684
|
+
Resolution:
|
|
1685
|
+
|
|
1686
|
+
- Registered worktree for branch → reuse (`created:false`). `ifExists:"fail"` → `exists`.
|
|
1687
|
+
- Stale registration (dir gone) → `git worktree prune` once.
|
|
1688
|
+
- Main checkout, or path outside `.worktrees/` → `branch_in_use`.
|
|
1689
|
+
- No registration:
|
|
1690
|
+
- local branch → checkout.
|
|
1691
|
+
- only `origin/<branch>` → `addWorktree({base:"origin/<branch>", newBranch})`.
|
|
1692
|
+
- else fork `base ?? resolveDefaultBase` (verified; fail `base_not_found`).
|
|
1693
|
+
- `base` ignored when branch or worktree exists.
|
|
1694
|
+
|
|
1695
|
+
Lock:
|
|
1696
|
+
|
|
1697
|
+
- `withRepoLock(repoLockKey(cwd))` in `git-worktree/repo-lock.ts`.
|
|
1698
|
+
- Key = realpath of git common dir.
|
|
1699
|
+
- `POST /api/git/worktree` takes same lock. Responses unchanged.
|
|
1700
|
+
|
|
1701
|
+
cwd-policy:
|
|
1702
|
+
|
|
1703
|
+
- Hook `checkTarget` compares `cwdPolicyRegistry.resolve(worktreePath)` vs `resolve(opts.cwd)` before any git write.
|
|
1704
|
+
- Differ → `policy_mismatch`.
|
|
1705
|
+
|
|
1706
|
+
Init:
|
|
1707
|
+
|
|
1708
|
+
- `autoInitWorktreeOnSpawn` on → hook calls `startWorktreeInit(cwd,{skipIfRunning:true})` before filing intents. Awaits it.
|
|
1709
|
+
- `startWorktreeInit` in `git-worktree/start-worktree-init.ts`. Also used by `POST /api/git/worktree/init`.
|
|
1710
|
+
- Failed → `init_failed`. No spawn. Worktree kept.
|
|
1711
|
+
- Untrusted hook → never run. Spawn proceeds. Init stays pending.
|
|
1712
|
+
- `already_running` → `awaitInitRun` polls registry.
|
|
1713
|
+
- Server-side trigger. Browser-side twin: `auto-init-worktree.ts`.
|
|
1714
|
+
|
|
1715
|
+
After success, every cwd-keyed step uses worktree path:
|
|
1716
|
+
|
|
1717
|
+
- `pendingInitialPromptRegistry`.
|
|
1718
|
+
- `pendingAttachRegistry` (`attachChange`, kebab-case `^[a-z0-9][a-z0-9-]{0,99}$`). Withdrawn on spawn failure.
|
|
1719
|
+
- Full queue → `warning: "attach queue full; session not attached"`.
|
|
1720
|
+
- `spawnPiSession` / `spawnAcpSession`.
|
|
1721
|
+
- `armSpawnWatchdog`.
|
|
1722
|
+
- Headless PID registry.
|
|
1723
|
+
- No `gitWorktreeBase` written (dialog-only per `git-context`).
|
|
1724
|
+
|
|
1725
|
+
Failure:
|
|
1726
|
+
|
|
1727
|
+
- `success:false`. Nothing spawned, nothing queued. Never falls back to local.
|
|
1728
|
+
- Codes (`PluginSpawnWorktreeCode`): `invalid_block`, `not_git`, `admission_unavailable` (retryable), `branch_invalid`, `exists`, `base_not_found`, `branch_in_use`, `policy_mismatch`, `init_failed`, `git_failed`.
|
|
1729
|
+
|
|
1730
|
+
Log per worktree spawn:
|
|
1731
|
+
|
|
1732
|
+
- `[plugin-spawn] worktree <created|reused|failed> plugin=<id> branch=<json> code=<code>`.
|
|
1733
|
+
|
|
1734
|
+
- See change: add-plugin-spawn-worktree.
|
|
1735
|
+
|
|
1736
|
+
### Agent Teams Plugin (`add-agent-teams-core`)
|
|
1737
|
+
|
|
1738
|
+
Package `packages/agent-teams-plugin/` (`@blackbelt-technology/pi-dashboard-agent-teams-plugin`). Plugin id `agent-teams` (NOT `team`; `packages/team-plugin` = unrelated persona product). Manifest `priority: 100`. `emits: [agent-teams:mail, agent-teams:team_closed]`.
|
|
1739
|
+
|
|
1740
|
+
- Entries:
|
|
1741
|
+
- bridge (`src/bridge/index.ts`): pi extension per session. CC-named tools. Mail → `pi.sendMessage` custom message (`customType` from `customTypeForKind`: `agent-teams-mail` default, `-idle`, `-notice`). Idle report on `agent_settled`. Teammate guards (`guard.ts`, `shell-guard.ts`).
|
|
1742
|
+
- server (`src/server/index.ts`): server-owned team store, `<dataDir>/teams/<id>.json` (`persistence.ts`). Request lane (`lane.ts`). Teammate spawn (`driver.ts`). Read REST routes (`routes.ts`).
|
|
1743
|
+
- client (`src/client/index.tsx`): eager exports only (`catalog`, `TeamBadge`, `isTeamSession`). UI claims lazy; see Team view below.
|
|
1744
|
+
- Lead + teammates = pi sessions. One team per lead session. No nested teams.
|
|
1745
|
+
- Server store = single source of truth: members, task list, mail log.
|
|
1746
|
+
- Lead-only tools: `TeamCreate`, `TeammateSpawn`, `TeamDelete`, `ShutdownRequest`, broadcast, urgent mail.
|
|
1747
|
+
- Teammate tool set = `TEAM_TOOLS_BY_ROLE.member` (`shared/protocol.ts`).
|
|
1748
|
+
- Task list: sequential ids, synchronous claim, `owner` field, auto-unblock, self-claim on `agent_settled`.
|
|
1749
|
+
- Mail: direct + broadcast. Queued for busy/spawning/disconnected recipients. `urgent` interrupts.
|
|
1750
|
+
- Teammate spawn: `spawnSession` (session mode). Spawn prompt sent as `spawn_prompt` mail after bind + guarded `hello`. No `initialPrompt`.
|
|
1751
|
+
- Caps (`configSchema.json`): `maxTeammates` 5 (1–10), `maxActiveTeams` 3, `maxTasks` 50, `maxMessageChars` 8000, `maxResultChars` 4000, `maxFinalTextChars` 2000, `mailRatePerMin` 6, `pairExchangeLimit` 10.
|
|
1752
|
+
- Security inventory: `docs/security/plugins-client-electron.md` (A2 + bundled table), `tool-call-guards.md`, `websocket-and-bridge.md`.
|
|
1753
|
+
- Seams used: `docs/plugin-seams.md` § Consumer: agent-teams.
|
|
1754
|
+
- See change: add-agent-teams-core
|
|
1755
|
+
|
|
1756
|
+
### Agent Teams Team view (`add-agent-teams-ui`)
|
|
1757
|
+
|
|
1758
|
+
Team view, mail cards, tool renderers, session badge: same plugin `agent-teams`. Owner rule + control tiers: [`security/plugins-client-electron.md`](security/plugins-client-electron.md) row A2.
|
|
1759
|
+
|
|
1760
|
+
- Claims (`package.json` `pluginMeta.claims`):
|
|
1761
|
+
- `session-card-badge` → `TeamBadge` (eager, predicate `isTeamSession`).
|
|
1762
|
+
- `shell-overlay-route` → `TeamViewClaim` (lazy `src/client/TeamView.tsx`), path `/session/:sessionId/team`, `parentPath` `/session/:sessionId`, `presentation: content`.
|
|
1763
|
+
- `custom-entry-renderer` → `MailEntryCard` for `agent-teams-mail`, `-idle`, `-notice`.
|
|
1764
|
+
- `tool-renderer` ×11 → `TeamLifecycleToolRenderer` (TeamCreate, TeammateSpawn, TeamStatus, TeamDelete), `TeamMessageToolRenderer` (SendMessage), `TeamTaskToolRenderer` (TaskCreate/List/Get/Update), `TeamShutdownToolRenderer` (ShutdownRequest, ShutdownResponse).
|
|
1765
|
+
- Route `/session/:sessionId/team`: lead or teammate session id. Resolves via `GET /api/plugins/agent-teams/teams?sessionId=<id>`. Pick order: live over closed, then latest change, then smaller id.
|
|
1766
|
+
- Layout: header, then `Members · Tasks · Messages` tabs on every width (APG roving tabindex; ←/→ wrap; Home/End).
|
|
1767
|
+
- Members: table ≥ `sm` (640 px), stacked cards below. Stop button: busy ∧ `viewerCanControl` ∧ team not `closing`/`closed`.
|
|
1768
|
+
- Tasks: Pending · In progress · Completed sections ≥ `lg` (1024 px); grouped collapsible list below. Completed folded by default. Read-only.
|
|
1769
|
+
- Messages: mail log (`MessageLog`).
|
|
1770
|
+
- Header: `Shut down team` iff `viewerCanControl` ∧ status ∈ {`starting`, `active`, `orphaned`}. Confirm via `ui:confirm-dialog`.
|
|
1771
|
+
- States: loading skeleton (`aria-busy`); `team-none` (unknown and invisible share copy); `team-not-found` (only after resolved 404); `team-error` + retry; stale notice over kept snapshot; closed banner.
|
|
1772
|
+
|
|
1773
|
+
Live-state protocol:
|
|
1774
|
+
|
|
1775
|
+
- Snapshot `GET /api/plugins/agent-teams/teams/:id` → `TeamUiSnapshot` = core `TeamSnapshot` + `epoch` + `viewerCanControl`.
|
|
1776
|
+
- `epoch`: `randomBytes(8)` hex, minted per server start (`server/epoch.ts`). Epoch change ⇒ refetch.
|
|
1777
|
+
- ETag strong `"<epoch>:<rev>"` (`:ro` suffix for a viewer without control); `Cache-Control: private, no-cache`, `Vary: authorization, cookie`. `If-None-Match` exact match ⇒ `304`, no body.
|
|
1778
|
+
- Frame `plugin_event`: `pluginId: agent-teams`, `sessionId: <lead>`, `eventType: agent-teams:changed`, `data: {teamId, epoch, rev, closed?}`. Content-free: ids + rev only.
|
|
1779
|
+
- Server coalesce (`server/ui-bridge.ts`): ≤1 frame per team per `CHANGED_COALESCE_MS` (1000), leading + trailing. Close = last frame, `closed: true`.
|
|
1780
|
+
- Client refetch (`client/teams-store.ts`): single-flight, conditional (`If-None-Match`).
|
|
1781
|
+
- First use: immediate. Other triggers (frame, reconnect, tab visible): 500 ms debounce, 2000 ms max-wait.
|
|
1782
|
+
- 60 s safety timer while visible. Hidden tab defers fetch.
|
|
1783
|
+
- Frame stale iff epoch differs or `rev` greater. Frame during in-flight request ⇒ one follow-up.
|
|
1784
|
+
- Failure keeps snapshot + stale flag. Retry 1 s, 2 s, 4 s, then 30 s.
|
|
1785
|
+
- 429 honours `Retry-After` (delta-seconds or HTTP-date), clamped 1–120 s. No trigger shortens a wait.
|
|
1786
|
+
- Control POST (`stopMember`, `shutdownTeam`): client timeout 15 s, then refetch truth. Never auto-retried.
|
|
1787
|
+
- Lead stamp (`server/ui-bridge.ts`): `assignSessionRef(lead, {"agent-teams-lead": {teamId}})`; clear `{teamId: null}`. Written on diff only. Teammates keep core pluginRef key `agent-teams`.
|
|
1788
|
+
|
|
1789
|
+
Access + controls:
|
|
1790
|
+
|
|
1791
|
+
- `Team.owner` = `ownerKeyOf({iss, sub})` = `JSON.stringify([iss, sub])`. Set at create from host `principalOwner`; set at bind if unset.
|
|
1792
|
+
- `setRouteVisibility(canViewTeam)` at start. Registration failure ⇒ plugin refuses to start.
|
|
1793
|
+
- Invisible or unknown ⇒ `404 {"error":"not_found"}`, never 403. Hook throw or >1000 ms (`ROUTE_VISIBILITY_TIMEOUT_MS`) ⇒ fail closed.
|
|
1794
|
+
- Owner rule (`server/access.ts`): enforcement off ⇒ allow; no principal ⇒ deny; `urn:pi-dashboard:local-operator` ⇒ allow; else `team.owner === ownerKeyOf(principal)`; no owner ⇒ operator only.
|
|
1795
|
+
- `viewerCanControl` = owner rule only. Credential tier enforced by host gate (403).
|
|
1796
|
+
- `POST /api/plugins/agent-teams/teams/:id/members/:name/stop` (tier `control`, `route-tiers.ts:451`): 200 `{aborted:true}`; 409 `not_busy` / `not_connected`.
|
|
1797
|
+
- `POST /api/plugins/agent-teams/teams/:id/shutdown` (tier `control`, `route-tiers.ts:452`): 202 `{closing:true}`; 409 `team_closed`.
|
|
1798
|
+
- `?sessionId=`: 400 `bad_session_id` when repeated, `sessionId[]`, empty, NUL, or >128 chars.
|
|
1799
|
+
- Limits: read 8/s burst 16; POST writes 2/s burst 5. 429 ⇒ `rate_limited`.
|
|
1800
|
+
- See change: add-agent-teams-ui.
|
|
1801
|
+
|
|
1802
|
+
### Agent Teams templates, hooks, plan approval (`add-agent-teams-templates-hooks`)
|
|
1803
|
+
|
|
1804
|
+
Same plugin `agent-teams`. Additive over core seams (`registerOpGate`, `registerDispatchEligibility`, `registerSpawnContributor`, `registerMailKind`, `Team.overrides`, `Member.hold`). Full guide: [`agent-teams.md`](agent-teams.md). Security: [`security/agent-teams-hooks-and-plans.md`](security/agent-teams-hooks-and-plans.md).
|
|
1805
|
+
|
|
1806
|
+
```mermaid
|
|
1807
|
+
flowchart LR
|
|
1808
|
+
T["templates.ts<br/>user + project(trusted)"] --> S["start.ts team.start"]
|
|
1809
|
+
C["bridge /agent-team"] -->|lane| S
|
|
1810
|
+
D["Start team dialog"] -->|"POST teams/start"| S
|
|
1811
|
+
A["agents.ts .pi/agents"] --> R["spawn-resolve.ts"]
|
|
1812
|
+
S --> CORE["core createTeam · bindLead · spawnMember"]
|
|
1813
|
+
R --> CORE
|
|
1814
|
+
H["hooks.ts"] -->|registerOpGate| CORE
|
|
1815
|
+
P["plans.ts"] -->|eligibility · mail kinds| CORE
|
|
1816
|
+
```
|
|
1817
|
+
|
|
1818
|
+
- Template = markdown + YAML frontmatter. Sources `user` (`<piAgentDir>/teams/`), `project` (`<cwd>/.pi/teams/`, needs `host.isProjectTrusted`). Vars `{{goal}}`, `{{cwd}}` only.
|
|
1819
|
+
- Start: `/agent-team start|templates` (bridge, current session becomes lead) or `POST /api/plugins/agent-teams/teams/start` (server spawns lead, deadline `leadBindDeadline`, `closeReason: lead_spawn_failed`). Template snapshot persisted on team; frozen.
|
|
1820
|
+
- Teammate types: `.pi/agents/<Name>.md` re-implemented reader (`agents.ts`). Precedence + ceiling + plan floor in `spawn-resolve.ts`.
|
|
1821
|
+
- Hooks `TeammateIdle|TaskCreated|TaskCompleted`: op gates, exit 0 allow / 2 block / other allow (fail-open), one `opGateBudgetMs` (12 s) deadline, concurrency 2/team 4/global, `hookMaxRetries` 3. TOFU `<dataDir>/hook-trust.json` keyed `realpath(cwd)`+sha256. Frozen at start.
|
|
1822
|
+
- Plan approval: `planning → pending → approved`. `PlanSubmit` / `PlanDecision` tools + `plan-decision` route. Layers: spawn tool list, `setActiveTools` narrowing, `tool_call` backstop (`bridge/plan-mode.ts`).
|
|
1823
|
+
- Config: `maxTemplateBytes`, `hookTimeoutMs`, `hookMaxRetries`, `planMaxChars`, `planModeTools`.
|
|
1824
|
+
- Routes: GET `templates`, GET `teams/:id/plans` (observe); POST `teams/start`, POST `…/members/:name/plan-decision`, POST/DELETE `hook-trust` (operate).
|
|
1825
|
+
- See change: add-agent-teams-templates-hooks.
|
|
1826
|
+
|
|
1664
1827
|
### Plugin Session Lifecycle Declarations (`hide-chat-gateway-sessions`)
|
|
1665
1828
|
|
|
1666
1829
|
`ServerPluginContext.spawnSession` accepts `PluginSpawnOptions.lifecycle: PluginSessionLifecycle` (`packages/dashboard-plugin-runtime/src/server/server-context.ts`). Owning plugin declares per-session lifecycle decisions; core reads the flags, never the plugin name.
|
|
@@ -1891,20 +2054,42 @@ pi/openspec/tsx are regular npm dependencies of `@blackbelt-technology/pi-dashbo
|
|
|
1891
2054
|
|
|
1892
2055
|
`launchSource` (returned by `/api/health`) is `"electron" | "standalone" | "bridge"`, derived from `DASHBOARD_STARTER`. Client uses it via `useLaunchSource()` to hide pi-core update UI on Electron (immutable bundle has no writable target).
|
|
1893
2056
|
|
|
1894
|
-
Compatibility skew helpers in `pi-version-skew.ts` (`readPiCompatibility`, `readCurrentPiVersion`, `computeCompatibility`) survive as pure helpers. The pinned range is `minimum: "1.
|
|
2057
|
+
Compatibility skew helpers in `pi-version-skew.ts` (`readPiCompatibility`, `readCurrentPiVersion`, `computeCompatibility`) survive as pure helpers. The pinned range is `minimum: "1.7.0"`, `recommended: "1.7.0"`, `maximum: null` (lockstep — one supported pi means no conditional code paths on that artifact). `piCompatibility` unchanged: a `@earendil-works/pi-coding-agent` range, a DIFFERENT artifact from the pi-ai pin below.
|
|
1895
2058
|
|
|
1896
2059
|
1.1.0 adds: `tool_execution_end.durationMs` preferred for tool row duration; `samplingParamsByThinkingLevel` passthrough; `GET /api/provider-auth/legacy-provider-ids` (`azure-openai-responses` -> `azure` rename scan). See change: update-pi-core-1-1-adopt-apis.
|
|
1897
2060
|
|
|
1898
2061
|
1.3.0 adds: follow-up drain on `agent_settled` (see `### Retry Lifecycle`). Single-bang `!cmd` output sent via `pi.sendUserMessage(msg, {deliverAs: "followUp"})`. Retry turn `before_agent_start` `messageType: "custom"` (pi ≥ 1.2.0) → gets session-context fragment, kb doctrine, role guidelines, untrusted-content guideline, team skill filter; also runs compaction check + `nextTurn` prelude. Typed setting `sessionShareDestination` (`auto`|`gist`|`radius`, default `auto`). Lockstep floor → 1.3.0. Dropped `@earendil-works/chord`. See change: update-pi-core-1-3-adopt-apis.
|
|
1899
2062
|
|
|
2063
|
+
1.5.0 adds: `decidePiTrust` order = recorded pi entry → implicit (no trust-requiring resources) → dashboard trust (over `never`) → `defaultProjectTrust`. Trust-file keys matched like pi `pathsEqual` (`packages/shared/src/pi-path-compare.ts`). Tool-argument validation = `@earendil-works/pi-schema`. Typed PATCH accepts exactly `"disabled"` for `httpIdleTimeoutMs` / `websocketConnectTimeoutMs`; form shows stored `"disabled"` as `0`. `extensionChangelogVersions` read-only managed key. Windows shell replica names pi 1.5.0 (see Windows section). `mcp.json` reads strip one leading UTF-8 BOM. `!`/`!!`/slash-exec `bash_output.exitCode` = pi `ExecResult.code` (was always 0). Lockstep floor → 1.5.0. See change: update-pi-core-1-5-adopt-apis.
|
|
2064
|
+
|
|
1900
2065
|
**Below-floor session signal.** Replaces per-feature pi version gates. Bridge `sendPiVersionIfChanged` (`packages/extension/src/model-tracker.ts`) reads the running pi argv-anchored via `readRunningPiVersion` and sends `pi_version_update`; server runs `computePiBelowFloor(version, serverPiMinimum())` (`packages/server/src/pi/pi-version-skew.ts`) → sets `DashboardSession.piBelowFloor: { minimum } | null`; client `PiBelowFloorWarning` renders on `SessionCard` + `SessionHeader`. Unknown or unparseable version → no flag. `minimum` sourced from `piCompatibility.minimum`. See change: update-pi-core-1-0-adopt-apis.
|
|
1901
2066
|
|
|
1902
|
-
**pi-ai generation window.** Legacy generation REMOVED — the dashboard supports ONE **pi-ai** generation (pi >= 1.
|
|
2067
|
+
**pi-ai generation window.** Legacy generation REMOVED — the dashboard supports ONE **pi-ai** generation (pi >= 1.7.0). Supported range `>=1.7.0` (root `package.json` + `packages/extension/package.json` peerDependencies). Root devDependency pin `^1.7.0`. The server streams through pi-coding-agent's own **`ModelRuntime`** (ONE server runtime — see `### Single model runtime`), which owns module shape (factory API only), transcript normalization (`normalizeContext` before dispatch, else systemPrompt + tools drop silently) and OAuth relocation (`dist/oauth.js` is a TYPE-ONLY stub, never consulted; real loaders at `dist/auth/oauth/*.js`, a path NOT in the package `exports` map). `packages/extension/src/bridge.ts` streams through pi's own `ctx.modelRegistry.streamSimple`. The `packages/shared/src/piai-compat/` seam (`adaptPiAi`), its `api-table.ts` / `NON_TEXT_LAZY_FILES` helpers and `packages/shared/src/test-support/piai-factory-fixture.ts` are DELETED.
|
|
1903
2068
|
|
|
1904
2069
|
See change: collapse-model-proxy-onto-modelruntime.
|
|
1905
2070
|
|
|
1906
2071
|
**Host project-trust service.** `packages/server/src/server.ts` registers `host.isProjectTrusted(cwd)` (awaited at boot) next to `host.knownFolderCwds`, plus `host.projectTrustSource` and `host.piTrustCoverInteractive`. `packages/server/src/pi/host-project-trust.ts` `createHostProjectTrustService` / `loadHostProjectTrustService` run shared `decidePiTrust` (pi's own rule + dashboard mirror; see Pi trust mirror). `coveringDashboardEntry` finds covering entry. Honours `PI_CODING_AGENT_DIR`. Pi core unresolvable → one log line (not silent untrusted). Legacy `createHostProjectTrust({recordedDecision, defaultProjectTrust})` kept for compat only; not the decision path. `mcp-client` injects it as `isProjectTrusted` so folder MCP rows load the project layer only in trusted folders. See change: migrate-mcp-to-pi-builtin, mirror-dashboard-trust-to-pi.
|
|
1907
2072
|
|
|
2073
|
+
**Host local-request service.** `packages/server/src/plugin-local-request.ts` `host.localRequest({method, url, body?, timeoutMs?})`. Registered in `packages/server/src/server.ts` beside `host.resolveCwdPolicy`. Registry key const `HOST_LOCAL_REQUEST_KEY`.
|
|
2074
|
+
- Why: credential-less `fastify.inject` writes refused `local_proof_required` under `requireLocalProof=true` (default). Proof = endpoint-bound HMAC over connection local addr+port, method+target, ts, nonce. Cannot mint for `inject` (no socket).
|
|
2075
|
+
- How: real loopback HTTP fetch to server's own listener. Header `X-Pi-Local-Proof` minted per request from in-process local token (same helper as CLI `pi-dashboard api`: `httpProofHeaders`, `localDialHost`). Route runs every normal guard (host gate, network guard, credential verify + replay cache, route-tier gate). Real client, no bypass.
|
|
2076
|
+
- Allowlist FIXED in source, exact pathnames, not registrant-configurable (any plugin can `consume` it; configurable list would let first consumer widen all). Only `query`-flagged entry takes query string.
|
|
2077
|
+
|
|
2078
|
+
| Method | Path |
|
|
2079
|
+
|---|---|
|
|
2080
|
+
| POST | `/api/git/worktree` |
|
|
2081
|
+
| POST | `/api/git/worktree/init` |
|
|
2082
|
+
| POST | `/api/git/worktree/orphan-cleanup` |
|
|
2083
|
+
| GET | `/api/openspec/tasks` (query allowed) |
|
|
2084
|
+
| POST | `/api/openspec/tasks/toggle` |
|
|
2085
|
+
|
|
2086
|
+
- Caps: request body 256 KiB (`LOCAL_REQUEST_MAX_BODY_BYTES`), response 4 MiB (`LOCAL_REQUEST_MAX_RESPONSE_BYTES`), timeout default 60 s, max 300 s.
|
|
2087
|
+
- No caller headers, host, or credential. Plugin never sees token or proof. Proof single-use, bound to one method + target + endpoint.
|
|
2088
|
+
- Result: `{ok:true, statusCode, body}` (route 4xx guard refusal still `ok:true`) or `{ok:false, code}`. Codes: `invalid_request`, `path_not_allowed`, `body_too_large`, `response_too_large`, `timeout`, `unavailable`, `unreachable`. No message echoes URL, header, proof. Nothing logged.
|
|
2089
|
+
- Consumer: agent-teams OpenSpec profiles, `packages/agent-teams-plugin/src/server/openspec/inject.ts` (`createInject`). Prefers service; falls back to loopback `fastify.inject` (no credential) on older host — strict `requireLocalProof` then answers 401/403, caller never retries.
|
|
2090
|
+
- Add route = edit allowlist in `plugin-local-request.ts`, in review, next to route-tier table.
|
|
2091
|
+
- See [agent-teams.md](agent-teams.md) § OpenSpec profiles. See change: add-agent-teams-openspec.
|
|
2092
|
+
|
|
1908
2093
|
#### Legacy `~/.pi-dashboard/` advisory
|
|
1909
2094
|
|
|
1910
2095
|
Pre-R3 builds installed pi/openspec/tsx into `~/.pi-dashboard/node_modules/` at runtime. R3 leaves that directory untouched. `detectLegacyManagedDir({ homedir })` in `packages/shared/src/legacy-managed-dir.ts` returns `{present, path, pkgCount, sizeMb}`. Doctor surfaces a warning-severity row "Legacy install directory" with a `rm -rf <path>` suggestion. Server `cli.ts` logs the path once at startup after the `[bootstrap] ready` line. Repo-lint `no-managed-dir-reference.test.ts` blocks any new write into the legacy directory from `packages/electron/src/lib/`, `packages/server/src/`, or `packages/shared/src/` outside the explicit allowlist.
|
|
@@ -1980,6 +2165,22 @@ The Stop button supports two-click escalation for stuck sessions:
|
|
|
1980
2165
|
|
|
1981
2166
|
The bridge includes `process.pid` in `session_register` so the server can kill the process. The server also force-closes the bridge WebSocket and uses the headless PID registry as a fallback. If no PID is available, only the WebSocket is closed.
|
|
1982
2167
|
|
|
2168
|
+
### Bridge shutdown fallback
|
|
2169
|
+
|
|
2170
|
+
Bridge `shutdown` handler (`packages/extension/src/bridge.ts`) → `runBridgeShutdown(inst.cachedCtx)` (`packages/extension/src/bridge-shutdown.ts`).
|
|
2171
|
+
- Calls `ctx.shutdown()` first. Errors swallowed (stale ctx must not skip fallback).
|
|
2172
|
+
- Arms unref'd `process.exit(0)` fallback after `BRIDGE_SHUTDOWN_FALLBACK_MS` = 5000 (was 500).
|
|
2173
|
+
- Why: pi >=1.5.1 exits itself when idle. Its `dispose()` waits for credential write (single-use OAuth refresh token already replaced by provider). Early exit loses rotated token.
|
|
2174
|
+
- Callers: server `{type:"shutdown"}` WS msg, `/quit`, `/exit`.
|
|
2175
|
+
- See change: `update-pi-core-1-6-adopt-apis` (spec `bridge-extension`).
|
|
2176
|
+
|
|
2177
|
+
Residual risks (not fixed; server side tracked by follow-up `settle-server-credential-writes-on-exit`, `ModelRuntime.settleCredentialWrites`):
|
|
2178
|
+
- Windows: `killProcess` = `taskkill /F`. Busy session gets no clean dispose.
|
|
2179
|
+
- POSIX: SIGKILL 2 s after SIGTERM can cut dispose or credential write that runs longer.
|
|
2180
|
+
- Idle tmux (interactive) session: clean shutdown starts at once. pi unregisters signal handlers when it stops TUI (`interactive-mode.js` `stop()`). Ladder SIGTERM 1.5 s later ends dispose still waiting on credential write.
|
|
2181
|
+
- Headless: registry rung spends up to 2 s before grace + final escalation. 5 s fallback can fire before ladder's last SIGKILL. Process ends either way.
|
|
2182
|
+
- Keeper-hosted pi with unlinked PID: ended by keeper SIGKILL (`rpc-keeper-sidecar`). Skips dispose.
|
|
2183
|
+
|
|
1983
2184
|
### Platform-routed kill paths
|
|
1984
2185
|
All process termination across the codebase goes through `packages/shared/src/platform/process.ts`. No code outside that module may call `process.kill(...)` directly — enforcement is handled by `packages/shared/src/__tests__/no-direct-process-kill.test.ts`, a repo-level lint that scans every `.ts` file under `packages/*/src/` and fails CI if a direct call slips in. The three canonical helpers are:
|
|
1985
2186
|
|
|
@@ -2215,9 +2416,9 @@ The shared `<RichDiff>` component is also consumed by `DiffPanel` (Path A / chan
|
|
|
2215
2416
|
- Work through PromptBus — `TuiFlowIOAdapter` calls `ctx.ui.select/confirm/input` which the bridge routes through the bus to registered adapters (dashboard, TUI, or custom)
|
|
2216
2417
|
|
|
2217
2418
|
**Flow launcher:**
|
|
2218
|
-
-
|
|
2219
|
-
- Launch dispatched as `send_prompt` with `/<flow-name> <task
|
|
2220
|
-
-
|
|
2419
|
+
- Flow list: plugin-owned catalog `flow_catalog` (`useFlowCatalog`). Core holds no flow list.
|
|
2420
|
+
- Launch dispatched as `send_prompt` with `/<flow-name> <task>`.
|
|
2421
|
+
- Typed `/<flow-name>` runs pi-flows' registered command via extension dispatch. No bridge fast-path.
|
|
2221
2422
|
|
|
2222
2423
|
**pi-flows local patches required** (upstream report prepared):
|
|
2223
2424
|
- `EventEmitObserver`: 5 missing methods added (flow-started, agent-started, agent-complete, assistant-text, thinking-text)
|
|
@@ -2276,7 +2477,7 @@ flowchart TD
|
|
|
2276
2477
|
|
|
2277
2478
|
**Feedback contract** — exactly one terminal `command_feedback` per reload, `command` field always `/reload`.
|
|
2278
2479
|
|
|
2279
|
-
**Bridge side** — terminal-hosted path only; ladder step 2 wins for dashboard-spawned sessions. `BridgeCommandOptions.reload` = `terminalReload.reload` (`createTerminalReload`, `packages/extension/src/terminal-reload.ts`). `ExtensionContext` has no `reload()`; only a command handler's `ExtensionCommandContext` does. So `reload()` self-dispatches `pi.sendUserMessage("/__dashboard_reload <token>", {expandPromptTemplates: true})` — pi runs `_tryExecuteExtensionCommand`, hands handler FRESH command ctx → `ctx.reload()`. No TUI bootstrap. Nothing callable captured — works every reload (retired captured-fn-on-`globalThis` path was single-use, stale ctx after first reload). No pi version gate (`update-pi-core-1-0-adopt-apis`): `supportsInProcessCommandDispatch` and `NO_RELOAD_PATH_REASON` retired — the check could never fail on a supported pi (1.
|
|
2480
|
+
**Bridge side** — terminal-hosted path only; ladder step 2 wins for dashboard-spawned sessions. `BridgeCommandOptions.reload` = `terminalReload.reload` (`createTerminalReload`, `packages/extension/src/terminal-reload.ts`). `ExtensionContext` has no `reload()`; only a command handler's `ExtensionCommandContext` does. So `reload()` self-dispatches `pi.sendUserMessage("/__dashboard_reload <token>", {expandPromptTemplates: true})` — pi runs `_tryExecuteExtensionCommand`, hands handler FRESH command ctx → `ctx.reload()`. No TUI bootstrap. Nothing callable captured — works every reload (retired captured-fn-on-`globalThis` path was single-use, stale ctx after first reload). No pi version gate (`update-pi-core-1-0-adopt-apis`): `supportsInProcessCommandDispatch` and `NO_RELOAD_PATH_REASON` retired — the check could never fail on a supported pi (1.7.0 floor). `BridgeCommandOptions.reload` returns `ReloadOutcome` (`{ok:true, handedOff:true}` | `{ok:false, reason}`). See change: fix-terminal-session-dashboard-reload, update-pi-core-1-7-adopt-apis.
|
|
2280
2481
|
|
|
2281
2482
|
**Token handshake** — slot `process.__pi_dashboard_pending_reload__ = {token, sessionId, state, armedAt}`. State `armed → started → delivered | expired`. Transitions compare-and-set — requesting instance `error` and reloaded instance `completed` mutually exclusive. `START_TIMEOUT_MS` = 5000, `FINISH_TIMEOUT_MS` = 60000, both measured from `armedAt`.
|
|
2282
2483
|
|
|
@@ -2483,7 +2684,7 @@ Run-configuring surfaces, all five now paired:
|
|
|
2483
2684
|
- Settings → Sessions → Default Model — `packages/client/src/components/settings/SettingsPanel.tsx`, persists `config.defaultThinkingLevel`
|
|
2484
2685
|
- OpenSpec run-config row — `packages/client/src/components/openspec/useOpenSpecRunConfigRow.tsx`
|
|
2485
2686
|
- Roles → assign model to `@role` — `packages/roles-plugin/src/RolesSettingsSection.tsx`
|
|
2486
|
-
- Automation → Create, direct-model branch — `packages/automation-plugin/src/client/
|
|
2687
|
+
- Automation → Create/edit, direct-model branch ("Runs as" group) — `packages/automation-plugin/src/client/AutomationEditor.tsx`, rendered inline by `AutomationBoard.tsx` (editing card or `automation-draft` card)
|
|
2487
2688
|
|
|
2488
2689
|
Reference-listing surfaces, deliberately excluded: Model Proxy preferred-models list and Model Proxy alias→model table, both in `packages/client/src/components/settings/ModelProxySection.tsx`.
|
|
2489
2690
|
|
|
@@ -2838,6 +3039,23 @@ See change: add-git-checkout-root-resolver.
|
|
|
2838
3039
|
- origin `live` = latest ACCEPTED non-empty `commands_list` (`SessionCommandRegistry.getEntry().receivedAt`) among sessions with `piGateway.isSessionConnected` and cwd EXACTLY equal (trailing sep stripped + `canonicalPath`); else `scan` (enabled skills as `skill:<n>`, prompts as `<n>`); else `none`.
|
|
2839
3040
|
- Each command carries `scope` folder|global (path in `local.*` / local-scope packages / under `<cwd>/.pi`, else global). Impl `packages/server/src/pi/folder-commands.ts`.
|
|
2840
3041
|
- Spawn choices: `spawn_session` / `send_prompt` / `resume_session` gain optional `model`, `thinkingLevel`. Validator `packages/server/src/browser-handlers/spawn-choice.ts` (`validateSpawnChoice`, `resolveResumeChoice`): model `provider/id` ≤200 chars, charset-restricted, no empty/dash-led segment; `:<level>` suffix split only when no `thinkingLevel` field; thinkingLevel ∈ `THINKING_LEVELS`; invalid → dropped + `console.warn`.
|
|
3042
|
+
- Spawn-choice resolver: `resolveSpawnChoice(input, {defaultModel, readRoles})` in `packages/server/src/browser-handlers/spawn-choice.ts`. One resolver for all spawn roads: WS `spawn_session`, REST `POST /api/session/spawn`, plugin `spawnSession` hook (+ MCP `spawn_session`), bridge `spawn_new_session`. Returns `{choice, warnings}`. Never throws.
|
|
3043
|
+
- `model` accepts `provider/id`, `provider/id:<level>`, `@role`, `@role:<level>`. `@role` resolved ONCE at spawn via `readRoleConfigFromDisk()` (`~/.pi/agent/providers.json#roles`) + `resolveModelRef`. Roles file read only for `@` refs. Spawned session keeps concrete model. No role following.
|
|
3044
|
+
- Role level precedence: `thinkingLevel` field > ref `:<level>` suffix > role-assigned level. Level never appended to `--model`. Literal refs keep `validateSpawnChoice` rules. Thinking-only choice pairs with `config.defaultModel`. Empty string = absent. `agent` + model/thinking → empty choice + warning.
|
|
3045
|
+
- Road policy:
|
|
3046
|
+
- REST strict → `400` before any side effect (owner token, queued intents, spawn).
|
|
3047
|
+
- WS lenient → drop + `console.warn` + `spawn_result.choiceWarning` (client warning toast; bus `SpawnOptions.onWarning`).
|
|
3048
|
+
- Plugin hook lenient → `PluginSpawnResult.warning`. Literal `model` passes through verbatim (`mapPluginSpawnOptions`, `packages/server/src/spawn-process/plugin-spawn-choice.ts`). `agent` + `model`/`thinkingLevel` rejected (`validatePluginAcpSpawn`).
|
|
3049
|
+
- Bridge log-only.
|
|
3050
|
+
- Bridge inheritance: `buildSpawnNewSessionMessage` (`packages/extension/src/spawn-new-session.ts`) adds current `model` + `thinkingLevel` to `spawn_new_session`. Unknown model or throw → plain frame.
|
|
3051
|
+
- Pending registries (`pending-attach-registry.ts`, `pending-initial-prompt-registry.ts`) gain `withdraw(cwd, value)`: removes NEWEST matching entry. Failed WS / REST / plugin spawn withdraws only its own intents.
|
|
3052
|
+
- Web client:
|
|
3053
|
+
- Per-folder memory `packages/client/src/lib/spawn/spawn-choice-memory.ts`: localStorage `pi-dashboard:spawn-choice:<cwd>`, `{model?, thinkingLevel?}`, `@role` stored verbatim.
|
|
3054
|
+
- `getEffectiveSpawnChoice` = remembered ?? Settings default, per field. Settings defaults mirrored by App via `setSpawnDefaults`.
|
|
3055
|
+
- Chip `packages/client/src/components/spawn/SpawnChoiceChip.tsx` (ModelSelector + Role tab + `default` entries) in `WorktreeSpawnDialog` (`modelChoice="show"|"hidden"`) and `AgentSpawnPicker` menu (chevron always rendered).
|
|
3056
|
+
- Quick spawns (folder button, OpenSpec board via `useAgentAwareSpawn`, Initialize project) use effective choice when agent is pi.
|
|
3057
|
+
- Sibling spawn copies source `model`/`thinkingLevel` (`siblingSpawnOpts`, `lib/spawn/spawn-opts.ts`).
|
|
3058
|
+
- See change: add-spawn-model-choice.
|
|
2841
3059
|
- Thinking-only spawn → config `defaultModel` so bridge default thinking cannot override. `SessionFlags.thinking` → `--thinking`; `--model`/`--thinking` on fresh + `continue` argv; fork keeps parent model; tmux pane escapes each token (`shellEscape`).
|
|
2842
3060
|
- Ended-session composer (`useEndedSessionComposer`): folder command list + catalogue models replace absent bridge lists. Folder list kept until live `commands_list` arrives (no empty flash).
|
|
2843
3061
|
- Model/thinking pick stored client-side per session; sent on resuming `send_prompt`/`resume_session` (continue only; applied to that resume's `spawnPiSession`, never via cwd-keyed `pendingResumeRegistry`); dropped once session no longer ended.
|
|
@@ -3035,7 +3253,7 @@ One server-derived per-cwd readiness state gates every OpenSpec affordance — f
|
|
|
3035
3253
|
|
|
3036
3254
|
**Reconfiguration re-broadcast.** `reconfigurePolling` diffs readiness-affecting keys (`enabled`, `optOutDirectories`, `offerInitialization`) against the previous config; poll-tuning writes (interval, concurrency, jitter, worker flag) never trigger a readiness broadcast. `optOutDirectories` membership change re-broadcasts only the affected cwds; `enabled`/`offerInitialization` change re-broadcasts every cached cwd.
|
|
3037
3255
|
|
|
3038
|
-
**`hasOpenSpecSkills`.** Stat `<configRoot>/.pi/skills/openspec-explore/`. Config root via `resolveConfigRoot` (git-worktree/git-operations.ts):
|
|
3256
|
+
**`hasOpenSpecSkills`.** Stat `<configRoot>/.pi/skills/openspec-explore/`, then `<configRoot>/.agents/skills/openspec-explore/`. Legacy first, short-circuit (common case 1 stat). Either layout → `true`. `.agents/skills/` = committed shared layout. Config root only, no ancestor walk. Config root via `resolveConfigRoot` (git-worktree/git-operations.ts): worktree answers from main checkout, because `.pi/skills/openspec-*` is gitignored and never checks out into a worktree. Root memoized per cwd (P4); `null` re-probed after 60s TTL. Unresolvable (`null`) root → `false`, NOT cwd fallback (probing cwd adopts stray tree). Presence recomputed every poll in `finalizeOpenSpecData` (not carried from unchanged-`openspec/` gate), so relocation/removal shows next poll. Source: packages/server/src/directory-service.ts `hasOpenSpecSkillsFor`.
|
|
3039
3257
|
|
|
3040
3258
|
**Config keys** (`OpenSpecPollConfig`): `openspec.optOutDirectories: string[]` (default `[]`; pathKey-normalized at parse, trailing-slash spellings collapse to one entry), `openspec.offerInitialization: boolean` (default `true`; `false` suppresses only the ABSENT offer — `BROKEN`/`STALE`/`READY` unaffected; distinct from `openspec.enabled`, which disables the feature). Both writable via `PUT /api/config` partial `{ openspec: {...} }` — deep-merged, every other key preserved.
|
|
3041
3259
|
|
|
@@ -3159,7 +3377,7 @@ Bridge caps per-unit-time work that server or bridge-socket holder can trigger.
|
|
|
3159
3377
|
|
|
3160
3378
|
- `PI_DASHBOARD_BRIDGE_MAX_BASH` = max concurrent `!` / `!!` / exec-template bash per session. Default `4`.
|
|
3161
3379
|
- `PI_DASHBOARD_BRIDGE_PROMPT_RATE` = `<burst>/<refillPerSec>`. One token bucket per bridge process. Default `30/10`.
|
|
3162
|
-
- Prompt bucket shared by: `send_prompt`, `retry_session`, `git_commit_draft`,
|
|
3380
|
+
- Prompt bucket shared by: `send_prompt`, `retry_session`, `git_commit_draft`, flows `flow.run`, `plugin_emit_event`, `promote_followup_entry`.
|
|
3163
3381
|
- Valid values: positive integers only. Invalid (`0`, negative, non-integer, empty) → default + one log line per process per variable. `0` ≠ unlimited.
|
|
3164
3382
|
- Bucket survives WS reconnect and `/reload` (per bridge process). Keyed on process-global shared state (`inst.shared`), not the connection: a per-connection key let the server refill it via `send_prompt /reload`.
|
|
3165
3383
|
- Refusal visible: inline `command_feedback` error in chat. Never silent drop.
|
|
@@ -3533,7 +3751,7 @@ Source: `packages/server/src/live-server/` (`live-static.ts`, `live-csp.ts`, `li
|
|
|
3533
3751
|
| scripts off | empty | `sandbox` (+ egress directives if restricted) |
|
|
3534
3752
|
- Applies to port AND static targets on every capability response (`buildLiveCsp`).
|
|
3535
3753
|
- Our CSP appended to upstream CSP. Upstream never stripped. Browser enforces intersection.
|
|
3536
|
-
- Restricted: `default-src 'none'`; `script-src` / `style-src` = `<P> 'unsafe-inline'` (+ `'unsafe-eval'` with scripts) + `<G>`; `connect-src <P> <G>`; `form-action 'none'`; `base-uri 'none'`; `frame-src 'none'`; `object-src 'none'`; `worker-src <P> blob:`; `manifest-src 'none'`; `frame-ancestors 'self'`; `report-uri`
|
|
3754
|
+
- Restricted: `default-src 'none'`; `script-src` / `style-src` = `<P> 'unsafe-inline'` (+ `'unsafe-eval'` with scripts) + `<G>`; `connect-src <P> <G>`; `form-action 'none'`; `base-uri 'none'`; `frame-src 'none'`; `object-src 'none'`; `worker-src <P> blob:`; `manifest-src 'none'`; `frame-ancestors 'self'`; `report-uri` only (no `report-to`, no `Reporting-Endpoints`).
|
|
3537
3755
|
- `<P>` = prefix from validated `Host`. Never `'self'`. Never dashboard origin.
|
|
3538
3756
|
- `<G>` = project grants ∪ viewer allow-once set.
|
|
3539
3757
|
|
|
@@ -3589,6 +3807,140 @@ flowchart TD
|
|
|
3589
3807
|
- Store: `~/.pi/dashboard/preview-egress.json` `{[projectKey]: string[]}` via `auth/locked-json-file.ts`. Override `PI_PREVIEW_EGRESS_STORE`.
|
|
3590
3808
|
- `projectKey` = canonical subject of git common root, else cwd.
|
|
3591
3809
|
|
|
3810
|
+
#### Capability origins and tiers (change: serve-live-previews-on-capability-origin)
|
|
3811
|
+
|
|
3812
|
+
Source: `packages/server/src/live-server/` (`preview-origin.ts`, `preview-dispatch.ts`, `preview-pool.ts`, `preview-preflight.ts`, `preview-path-store.ts`, `preview-reserve.ts`, `preview-viewers.ts`, `preview-path-bridge.ts`, `live-server-proxy.ts`, `live-capability.ts`), `packages/server/src/auth/duplicate-cookie-gate.ts`, `packages/shared/src/preview-origins.ts`, `packages/server/src/routes/live-server-routes.ts`.
|
|
3813
|
+
|
|
3814
|
+
Config: `liveServer.previewOrigins` = `{ enabled, wildcard: {suffix, forHosts[], scheme?}, portPool: "a-b", ipDnsSuffix }`.
|
|
3815
|
+
|
|
3816
|
+
##### Mint negotiation
|
|
3817
|
+
- Client `POST /api/live-server/:id/capability` with `accept: ["origin","preview"]`.
|
|
3818
|
+
- No or invalid `accept` ⇒ legacy path.
|
|
3819
|
+
- Response: `{tier, origin?, path, base?, expiresAt, tokenId, policy}`.
|
|
3820
|
+
- Client validates shape. Refuses `origin` equal to dashboard origin.
|
|
3821
|
+
|
|
3822
|
+
##### Tier table
|
|
3823
|
+
First match wins. Tier input = RAW `Host` header + socket peer. Never `request.protocol`.
|
|
3824
|
+
|
|
3825
|
+
| Tier | Match | Origin | Path |
|
|
3826
|
+
|---|---|---|---|
|
|
3827
|
+
| 1 | Host `localhost` / `127.0.0.1`; peer loopback; no forwarding header; no TLS | `http://<label>.localhost:<port>` | `/` |
|
|
3828
|
+
| 2 | Host ∈ `wildcard.forHosts` | `<scheme>://<label>.<suffix>[:port]` | `/` |
|
|
3829
|
+
| 3 | login session principal; IPv4 Host the bind answers; pool port free | `http://<ip>:<poolPort>` | `/?k=<one-shot secret>` |
|
|
3830
|
+
| 4 | IPv4 Host; `ipDnsSuffix` set | `http://<label>.<a-b-c-d>.<suffix>[:port]` | `/` |
|
|
3831
|
+
| 5 | no earlier tier matches (incl. IPv6 Host, pool full) | dashboard origin | `/preview/<pid>/` |
|
|
3832
|
+
| legacy | no/invalid `accept`; or `enabled:false` | dashboard origin | `/live/<id>/~c/<token>/` |
|
|
3833
|
+
|
|
3834
|
+
##### Tier 1
|
|
3835
|
+
- Same-host reverse proxy adding no forwarding header looks like local browser. Pinned limitation.
|
|
3836
|
+
- Fix: proxy sends `X-Forwarded-For`, or set `enabled:false`.
|
|
3837
|
+
|
|
3838
|
+
##### Tier 2
|
|
3839
|
+
- Warns when `suffix` shares parent domain with a `forHosts` entry (cookie tossing).
|
|
3840
|
+
|
|
3841
|
+
##### Tier 3 (port pool)
|
|
3842
|
+
- `portPool` `"a-b"`: ≤100 ports, all ≥1024. Excludes dashboard, gateway, TLS, model-proxy ports.
|
|
3843
|
+
- Invalid value ⇒ tier 3 off. Logged once.
|
|
3844
|
+
- Eligible principal: login session cookie `pi_dash_token` (`Path=/`) only.
|
|
3845
|
+
- One plain-HTTP listener per live capability, lowest free pool port. `EADDRINUSE` ⇒ skip next port.
|
|
3846
|
+
- ≤8 listeners per principal. Pool full ⇒ tier 4/5 with log `pool exhausted`. Never an error.
|
|
3847
|
+
- Listener released on every capability deletion: expiry, revoke, eviction, config change, shutdown.
|
|
3848
|
+
- Pool ports in `ownPorts`. No target may point at them. Forbidden to mock site.
|
|
3849
|
+
- Opt-in in Docker: see `docker/README.md` § Live previews.
|
|
3850
|
+
|
|
3851
|
+
Pool-port request pipeline (in order, first failure stops):
|
|
3852
|
+
1. Fixed Host binding. Else `403`.
|
|
3853
|
+
2. Minting session cookie matches. Else `404`.
|
|
3854
|
+
3. One-shot `?k=` hop: sets host-only `pi_dash_pool_<port>` (`HttpOnly; SameSite=Strict; Path=/`), then redirects to clean URL. `to` must be single-slash root-relative, no `\` or control chars, ≤2048; else `/`.
|
|
3855
|
+
4. Later requests: cookie `pi_dash_pool_<port>` required. Else `404`.
|
|
3856
|
+
5. `Origin` present ⇒ must equal entry origin. Else `404` (upgrades `403`).
|
|
3857
|
+
|
|
3858
|
+
##### Tier 4
|
|
3859
|
+
- `ipDnsSuffix` (e.g. `sslip.io`). IPv4 Host only.
|
|
3860
|
+
|
|
3861
|
+
##### Tier 5 (`/preview/<pid>/`)
|
|
3862
|
+
- `pid` = 22 chars. One current pid per port target. Shared by all holders. Policy = narrowest holder.
|
|
3863
|
+
- Mint within last 20 min of lifetime ⇒ new pid, `restartRequired`.
|
|
3864
|
+
- Bounds: 32 pids per principal, 256 total.
|
|
3865
|
+
- Opaque origin: sandbox without `allow-same-origin`.
|
|
3866
|
+
- Full path forwarded upstream.
|
|
3867
|
+
- CORS: `Access-Control-Allow-Origin: null` for opaque origin. `OPTIONS` preflight answered for valid pid.
|
|
3868
|
+
- Authorised by pid, not dashboard auth.
|
|
3869
|
+
- WS upgrades on `/preview/<pid>/...` supported.
|
|
3870
|
+
- Pid drop (revoke, expiry, target removed, disabled) closes its tracked WS and in-flight responses (`preview-ws-registry.ts`; `server.ts` `previewWs.closePid`).
|
|
3871
|
+
- Tiers 1-5: `Referrer-Policy: no-referrer` replaces any upstream value. Legacy: only when app set none.
|
|
3872
|
+
- Tier 5 root-absolute `Location` rewritten into `/preview/<pid>/…`.
|
|
3873
|
+
- Dead or reset upstream on `/preview/` ⇒ `502 {"error":"bad_gateway"}`. Timeout ⇒ `504 {"error":"gateway_timeout"}`.
|
|
3874
|
+
- Residual: client abort does not destroy upstream HTTP request (`@fastify/reply-from`; same on `/live/`). Proxy timeout bounds it.
|
|
3875
|
+
|
|
3876
|
+
##### Tier-5 base reservation
|
|
3877
|
+
- `POST /api/live-server/preview-path {port}|{targetId}` (control) ⇒ `{path:"/preview/<pid>/", expiresAt, tier5Viewers:true}`.
|
|
3878
|
+
- No tier-5-capable browser ⇒ `{path:null, tier5Viewers:false}`. Nothing reserved.
|
|
3879
|
+
- Browser announces `live_preview_accept`. Counted only if its upgrade Host classifies to tier 5.
|
|
3880
|
+
- `DELETE /api/live-server/preview-path/:pid` releases UNBOUND reservation. Reserver only.
|
|
3881
|
+
- Limits: 8 per principal, 64 total.
|
|
3882
|
+
- TTL: 10 min from creation; 12 h while port target exists.
|
|
3883
|
+
- Adopted by next control-tier tier-5 mint for that port. Unadopted pid unknown to everyone.
|
|
3884
|
+
- Agent path: bridge `preview_path_request` / `preview_path_result` / `preview_path_release`.
|
|
3885
|
+
- Tier 1-4 mint of port with live pid ⇒ `base:"/preview/<pid>/"`.
|
|
3886
|
+
- `serve_mock_site{base?}`: explicit base allowlist `^/([A-Za-z0-9._~-]+/)+$`, ≤256. Else neutral event `mock-site:base-reservation` (2 s wait, then root).
|
|
3887
|
+
|
|
3888
|
+
##### Dispatch
|
|
3889
|
+
- Preview-shaped Host (`label.localhost`, wildcard suffix, IP-DNS suffix) ⇒ route-less `previewApp` (second Fastify instance).
|
|
3890
|
+
- `previewApp` never reaches host gate, CORS, cookie auth, `/api`, `/ws`, SPA, plugin routes.
|
|
3891
|
+
- Refusal: identical `403 {"error":"host_not_allowed"}`.
|
|
3892
|
+
- Dead upstream: `502`. Dispatcher failure: `503`. Never falls through to dashboard.
|
|
3893
|
+
- Preview WS upgrades handled before host gate.
|
|
3894
|
+
|
|
3895
|
+
##### Duplicate-cookie gate
|
|
3896
|
+
- Repeated `pi_dash_*` cookie name ⇒ `400` (JSON or static HTML by `Accept`).
|
|
3897
|
+
- Response expires the name at every path (self-heal).
|
|
3898
|
+
- Set-Cookie expiry lines capped at 8 KiB total (`EXPIRY_MAX_BYTES`, `fitExpiryBudget`). `/`, `/api/`, `/auth/` kept first. Keeps 400 head under Node 16 KiB header limit.
|
|
3899
|
+
- Applies to WS upgrades.
|
|
3900
|
+
- Repeated `pi_dash_token` / `pi_dash_pool_*` ⇒ counts as missing credential.
|
|
3901
|
+
- `previewApp` exempt.
|
|
3902
|
+
|
|
3903
|
+
##### CSP
|
|
3904
|
+
- Capability responses: CSP built from entry, never request.
|
|
3905
|
+
- Tiers 1-4: `allow-same-origin` + exact `frame-ancestors`.
|
|
3906
|
+
- Tier 5: path-scoped `frame-src`. No `frame-ancestors` (T11 fallback: Chromium blocks same-pid nested panes under `'self'`; sandboxed parent is opaque).
|
|
3907
|
+
- Tier 5 sandbox CSP still forces opaque origin. Pid is the capability.
|
|
3908
|
+
- Legacy: `frame-ancestors 'self'`.
|
|
3909
|
+
- Dashboard `frame-src` built per request from Host: `http://*.localhost`, wildcard suffix, `http://<host>:*` for pool.
|
|
3910
|
+
- `/preview/` skips dashboard baseline CSP (same as `/live/`).
|
|
3911
|
+
|
|
3912
|
+
##### Rollback
|
|
3913
|
+
- `liveServer.previewOrigins.enabled: false` ⇒ every mint returns legacy path.
|
|
3914
|
+
- Existing origin-bound capabilities revoked at next sweep, reason `disabled`.
|
|
3915
|
+
- Boot log: `[live-preview] tiers: 1, 3(8100-8199), 5`.
|
|
3916
|
+
|
|
3917
|
+
##### Client guards (D6(b), cookie reset)
|
|
3918
|
+
- Dashboard doc framed by live frame (`data-pi-live-frame`) or cross-origin parent (`frameElement === null`): no boot, no render, no boot-time API calls.
|
|
3919
|
+
- Source: `lib/live-preview/frame-guard.ts` `isDashboardBootBlocked`; `main.tsx`; `lib/boot/client-boot.ts`.
|
|
3920
|
+
- After each live-frame `load`: readable `contentWindow.location.href` ⇒ frame `about:blank` + "Preview navigated to the dashboard; blocked." until Reload.
|
|
3921
|
+
- Source: `components/editor-pane/live/LiveFrame.tsx`, `LiveFrameParts.tsx`.
|
|
3922
|
+
- Same-origin `/api/*` 400 `duplicate_dashboard_cookie` ⇒ tier 2/3 frames blank to `about:blank` + "A preview reset dashboard cookies; reopen it to continue."
|
|
3923
|
+
- Tier 1 untouched. Nothing auto-reopens. Reload / Reopen re-mints.
|
|
3924
|
+
- Source: `lib/live-preview/cookie-reset.ts`.
|
|
3925
|
+
|
|
3926
|
+
##### Browser tests (live preview)
|
|
3927
|
+
- `npm run test:e2e:live-preview` ⇒ `playwright.live-preview.config.ts`. Specs: `tests/e2e/live-preview/`. Guide: `tests/e2e/live-preview/README.md`.
|
|
3928
|
+
- Host-run isolated dashboard (global-setup, `HOME=<tmp>`, tiers 1/2/3/5). Not docker harness.
|
|
3929
|
+
- Projects: `chromium`, `firefox`, `chromium-resolver`.
|
|
3930
|
+
- `chromium-resolver`: `*.resolver.spec.ts` only. `--host-resolver-rules` maps `*.preview.test`, `dash.test`, `dash5.test` → `127.0.0.1`.
|
|
3931
|
+
- Docker-harness tier-5 / legacy spec: `tests/e2e/live-preview-harness-tiers.spec.ts`.
|
|
3932
|
+
|
|
3933
|
+
##### Observability (redacted)
|
|
3934
|
+
- `[live-preview] mint tier= target= h= via= peerLocal= reason=`
|
|
3935
|
+
- `[live-preview] pool bind|release|exhausted`
|
|
3936
|
+
- `[live-preview] reserve port= session= h=`
|
|
3937
|
+
- `[live-preview] pid dropped reason=holder-revoked|expired|target-removed|adoption-refused`
|
|
3938
|
+
- `[live-preview] refuse h= reason=` (one per `h` per 60 s)
|
|
3939
|
+
- `[live-preview] admit h= tier=` (first per entry)
|
|
3940
|
+
- `h` = first 8 hex of `sha256(secret)`. Never label, pid, token.
|
|
3941
|
+
|
|
3942
|
+
See change: serve-live-previews-on-capability-origin.
|
|
3943
|
+
|
|
3592
3944
|
### Network Access Control
|
|
3593
3945
|
|
|
3594
3946
|
One universal network guard plus the auth plugin. Universal guard runs whether or not auth is configured.
|
|
@@ -3629,6 +3981,8 @@ Both views are load-bearing because the router and the guard disagree about dot-
|
|
|
3629
3981
|
|
|
3630
3982
|
**Denial contract.** `403` with body `{ success: false, error: "network_not_allowed", reason, hint }` — clients branch on `error`. Recorded in the buffer behind `GET /api/tunnel/block-events`, which powers the "Trust this network?" prompt. Logged as `[network-guard] denied reason=… path=… ip=…` — path + socket-peer IP + reason only; no body, no token.
|
|
3631
3983
|
|
|
3984
|
+
**Second denial surface: `/api/health`.** Health is a public exception, so the guard never refuses it. Health answers `200` carrying `networkAccess: { error: "network_not_allowed", hint }` — present iff `evaluateNetworkPass` (`packages/server/src/auth/localhost-guard.ts`) would refuse THIS caller and `localProof: "required"` not already reported (localProof wins). Constant value: no mode, no list, no address. Presence = caller's own admission only. No block event, no grant prompt, no telemetry — health never reaches `sendNetworkDenied`. Verdict reads admission list through 1 s TTL memo (≤1 config `statSync`/s); local / token / authenticated callers short-circuit first. Constants: `packages/shared/src/network-denial-signal.ts`. Client `useNetworkDenied` maps the field to denial → banner offers Request access, not Offline. See change: surface-network-denial-on-health.
|
|
3985
|
+
|
|
3632
3986
|
**Second port.** Optional model-proxy second-port Fastify instance runs ONLY the proxy gate, no universal guard. Safe solely because it binds `127.0.0.1` (asserted by `packages/server/src/__tests__/model-proxy-second-port.test.ts`). If that bind ever becomes configurable, install the universal guard there too.
|
|
3633
3987
|
|
|
3634
3988
|
**Namespace-coverage test.** `packages/server/src/__tests__/network-guard-namespace-coverage.test.ts` enumerates the real route table with plugin routes loaded. Fails if any non-static/non-`/auth`/non-public route sits outside the guarded namespaces or the enumerated independently-authenticated set (`/mcp`).
|
|
@@ -3740,35 +4094,45 @@ NOT counted in snapshot: server-lifetime trust (session worktree trust, session
|
|
|
3740
4094
|
- Identity: canonical path + `dev` + `ino` (+ `birthtimeMs` when recorded). Entry applies only on identity match.
|
|
3741
4095
|
- Identity mismatch → fail closed. Other machine, re-created folder, moved folder.
|
|
3742
4096
|
|
|
3743
|
-
**Deny rules** `mirrorDenyRules`.
|
|
4097
|
+
**Deny rules** `mirrorDenyRules`. Builds on grant-subject `forbidden-subjects` (`grant.sensitive`), wider since change: harden-agent-tool-guards (D7).
|
|
3744
4098
|
- Exact: `/`, `$HOME`, ancestors of `$HOME`, system dirs, broad parents (`/Users /home /Volumes /private /var/tmp /mnt /media`; win: drive root, `C:\Users`).
|
|
3745
|
-
- Subtree: `~/.ssh
|
|
4099
|
+
- Subtree: every grant-subject sensitive subject (`~/.ssh`, `~/.pi`, `~/.aws`, `~/.config/gh`, `~/.gnupg`, `~/.kube`, `~/.docker`, `~/.netrc`, browser user-data roots) + OS temp (`os.tmpdir`, `/tmp`, `/private/tmp`), `~/.cache`, `~/Downloads`.
|
|
3746
4100
|
|
|
3747
4101
|
**Decision order** `decidePiTrust` (shared by bridge, `host.isProjectTrusted`, toggle gate). First match wins.
|
|
3748
4102
|
|
|
3749
4103
|
```mermaid
|
|
3750
4104
|
flowchart TD
|
|
3751
|
-
A["project_trust / host.isProjectTrusted(cwd)"] -->
|
|
3752
|
-
B -- no --> R0["trusted: implicit"]
|
|
3753
|
-
B -- yes --> C{"pi recorded entry?"}
|
|
4105
|
+
A["project_trust / host.isProjectTrusted(cwd)"] --> C{"pi recorded entry?"}
|
|
3754
4106
|
C -- "true / false" --> R1["pi decision wins"]
|
|
3755
|
-
C -- none -->
|
|
4107
|
+
C -- none --> B{"trust-requiring resources?"}
|
|
4108
|
+
B -- no --> R0["trusted: implicit"]
|
|
4109
|
+
B -- yes --> D{"mirror on AND covering entry?"}
|
|
3756
4110
|
D -- yes --> R2["trusted: dashboard source"]
|
|
3757
4111
|
D -- no --> R3["defaultProjectTrust"]
|
|
3758
4112
|
```
|
|
3759
4113
|
|
|
4114
|
+
- Order = pi 1.5 (`project-trust.js:22-23`). See change: update-pi-core-1-5-adopt-apis.
|
|
3760
4115
|
- `--approve` / `--no-approve` applied by pi first.
|
|
3761
4116
|
- `--no-extensions`: bridge never decides.
|
|
3762
4117
|
- `pi mcp list` reads only `trust.json`.
|
|
3763
4118
|
- Dashboard trust overrides `defaultProjectTrust`, INCLUDING `never`.
|
|
3764
4119
|
- Recorded pi entry (true or false, nearest ancestor) beats dashboard trust.
|
|
4120
|
+
- Trust-file keys compared like pi `pathsEqual` (`packages/shared/src/pi-path-compare.ts`: `piPathComparisonKey`, `piPathsEqual`, `nativePathApi`). Resolved; lower-cased on win32.
|
|
3765
4121
|
|
|
3766
4122
|
**Bridge** `decideBridgeProjectTrust` (`packages/extension/src/project-trust.ts`).
|
|
3767
4123
|
- No server round trip on snapshot step. Live query only on snapshot miss (see Live trust query).
|
|
3768
4124
|
- Per event: reads `config.json`, `trust.json` (lockless; BOM stripped; null = absent; bad shape/parse = undecided `store-unreadable`), snapshot.
|
|
3769
4125
|
- Returns `{trusted:"yes", remember:false}` or undecided.
|
|
3770
4126
|
- Dashboard-spawned headless sessions consult mirror always. Other sessions only if `coverInteractive`.
|
|
3771
|
-
-
|
|
4127
|
+
- **Activation cwd: no unconditional `yes`** (change: harden-agent-tool-guards D3). Activation cwd decided like any other cwd: recorded pi entry → snapshot mirror → live query. Auto-trusted only when dashboard trust covers it (pinned folder, workspace folder, covered grant, YOLO root via live query).
|
|
4128
|
+
- Nothing covers the activation cwd → `withheld("not-covered")`; pi decides (`trust.json`, then `defaultProjectTrust`; RPC has no prompt, `ask` = untrusted).
|
|
4129
|
+
- Road-independent: UI, MCP `spawn_session`, REST, WS, automation, goal, `/new`, worktree. No spawner cooperation, no flag, no state.
|
|
4130
|
+
- Forbidden/temporary activation folder (`/private/tmp`, `~/Downloads`, `~/.cache`, `$HOME`) → logs `forbidden-folder`. Never trusted **by the dashboard mirror**: no dashboard source covers a forbidden folder, bridge never returns `yes`.
|
|
4131
|
+
- pi still decides there: `piStoreBlocks` returns `recorded-entry` for a recorded pi entry; with none, bridge returns `undecided` → pi applies `trust.json`, then `defaultProjectTrust` (incl. `always`).
|
|
4132
|
+
- `piTrustMirror.enabled:false` also disables it (bridge returns undecided, pi decides).
|
|
4133
|
+
- Remedy for lost project `.pi/` resources: pin the folder, add it to a workspace, or `/trust` in a terminal pi.
|
|
4134
|
+
- Reason codes logged when withheld: `forbidden-folder`, `recorded-entry`, `identity-mismatch`, `hook-changed`, `not-project-root`, `source-off`, `source-not-installed`, `choice-unreadable`, `store-unreadable`, `not-covered-session`, `not-covered`, `identity-weak` + 7 `live-*` (see Live trust query).
|
|
4135
|
+
- Recorded-entry lookup `nearestRecordedEntry` (`packages/shared/src/pi-trust-mirror-snapshot.ts`) matches keys via `piPathsEqual`. Withholds yes for `/r/` or Windows case-different refusal.
|
|
3772
4136
|
- p95 < 20 ms (1,000 entries, 20-deep cwd).
|
|
3773
4137
|
- Spawn token: `PI_DASHBOARD_SPAWN_TOKEN` read + removed from env at bridge activation (`packages/extension/src/spawn-token.ts`). Process-global until first `session_register`. Agent-started nested pi never counts as dashboard-spawned.
|
|
3774
4138
|
|
|
@@ -3790,15 +4154,16 @@ flowchart TD
|
|
|
3790
4154
|
|
|
3791
4155
|
**UI.**
|
|
3792
4156
|
- Settings → Access → "Pi trust from the dashboard" (`packages/client/src/components/settings/PiTrustMirrorSection.tsx`): switches, effective list, per-entry choice, ignored rows (reason + label), pi `trust.json` entries + agent dir, disclosures.
|
|
3793
|
-
- Disclosures: precedence over `defaultProjectTrust` (incl `never`); scope; `--no-approve` / `--no-extensions` / pi CLI not covered; activation-
|
|
4157
|
+
- Disclosures: precedence over `defaultProjectTrust` (incl `never`); scope; `--no-approve` / `--no-extensions` / pi CLI not covered; no activation auto-trust outside dashboard trust.
|
|
3794
4158
|
- Folder page banner: pi / dashboard (source + folder; "dashboard sessions, not terminal pi" unless `coverInteractive`) / neither (links Settings → Access).
|
|
3795
4159
|
|
|
3796
4160
|
**Breaking bridge behaviour.** NOT reverted by `enabled:false`.
|
|
3797
|
-
- (a) Recorded pi entry beats
|
|
3798
|
-
- (b)
|
|
3799
|
-
- (c)
|
|
4161
|
+
- (a) Recorded pi entry beats dashboard trust.
|
|
4162
|
+
- (b) No unconditional activation-cwd `yes` (harden-agent-tool-guards D3): a dashboard spawn in a folder dashboard trust does not cover gets `undecided` (`not-covered`) and pi decides.
|
|
4163
|
+
- (c) Bridge `yes` withheld in forbidden/temporary folders (logged `forbidden-folder`): dashboard trust never covers them, pi decides.
|
|
4164
|
+
- (d) Spawn token removed from env at activation (see Bridge).
|
|
3800
4165
|
|
|
3801
|
-
**Rollback.** `piTrustMirror.enabled: false`. Bridge reads config live. Works with server down. Does not revert (a)-(
|
|
4166
|
+
**Rollback.** `piTrustMirror.enabled: false`. Bridge reads config live. Works with server down. Does not revert (a)-(d).
|
|
3802
4167
|
|
|
3803
4168
|
**Security residuals.**
|
|
3804
4169
|
- Hook trust widened to full project trust for the subtree. Checkbox text states it.
|
|
@@ -3818,7 +4183,7 @@ sequenceDiagram
|
|
|
3818
4183
|
participant B as bridge decideBridgeProjectTrust
|
|
3819
4184
|
participant S as server POST /api/pi-trust/query
|
|
3820
4185
|
P->>B: project_trust(cwd)
|
|
3821
|
-
B->>B: store, recorded entry, activation
|
|
4186
|
+
B->>B: store, recorded entry, snapshot cover (activation cwd = any cwd)
|
|
3822
4187
|
Note over B: snapshot miss, ask conditions hold
|
|
3823
4188
|
B->>S: { cwd } + local proof OR Bearer PI_DASHBOARD_TOKEN
|
|
3824
4189
|
S->>S: auth, rate limit, cap 8 KiB, deny rules, cover lookup
|
|
@@ -3867,6 +4232,8 @@ Bridge `decideBridgeProjectTrust` now async. Snapshot step stays sync (p95 < 20
|
|
|
3867
4232
|
- Snapshot field `liveCount` only. Never paths or identities. Boot writes `0`. Rewritten only when count changes, synchronously in the changing action. Failed rewrite logged, action succeeds. Reader treats missing/invalid as 0. Snapshot `version` stays 1.
|
|
3868
4233
|
- Stale count = extra or missed query, never wrong yes.
|
|
3869
4234
|
- Server consumers (`host.isProjectTrusted`, `projectTrustSource`, MCP view) run `decidePiTrust` over durable + live entries, no folder proof.
|
|
4235
|
+
- Server host predicate (`packages/server/src/pi/host-project-trust.ts`) reads recorded pi entry for EVERY folder. Dashboard trust + `defaultProjectTrust` read only when folder has trust-requiring resources and nothing recorded. Unreadable store / lock held → undecided (untrusted).
|
|
4236
|
+
- Toggle gate own-folder check (`packages/server/src/pi/resource-toggle-trust.ts`) uses `piPathsEqual`. Digest user-skills exclusion (`packages/shared/src/pi-trust-resource-digest.ts`) uses it too.
|
|
3870
4237
|
|
|
3871
4238
|
**Proofs.**
|
|
3872
4239
|
- Local: recorded `dev`+`ino`[+`birthtimeMs`]. Bridge compares via `identityMatches`. Re-created folder → `identity-mismatch`.
|
|
@@ -3884,9 +4251,10 @@ Bridge `decideBridgeProjectTrust` now async. Snapshot step stays sync (p95 < 20
|
|
|
3884
4251
|
- Bounds request + proof. `Promise.race([work, deadline→live-timeout])`. `AbortController` per call aborts `fetch` (`redirect:"error"`) + every `fs/promises` read.
|
|
3885
4252
|
- After race: `inst.isActive()` re-check. Stale instance → undecided.
|
|
3886
4253
|
|
|
3887
|
-
**Reason codes** (`MirrorWithheldReason`, `packages/shared/src/pi-trust-mirror-types.ts`;
|
|
4254
|
+
**Reason codes** (`MirrorWithheldReason`, `packages/shared/src/pi-trust-mirror-types.ts`; 19, labels in `MIRROR_WITHHELD_LABELS`):
|
|
3888
4255
|
- Parent (7): `forbidden-folder`, `not-project-root`, `hook-changed`, `source-off`, `source-not-installed`, `identity-mismatch`, `choice-unreadable`.
|
|
3889
|
-
- Bridge (
|
|
4256
|
+
- Bridge (5): `recorded-entry`, `store-unreadable`, `not-covered-session`, `not-covered`, `identity-weak`.
|
|
4257
|
+
- `not-covered` = bridge log only (label "no dashboard trust source covers this folder"); never an Access-page ignored row, no source produced the folder.
|
|
3890
4258
|
- Live (7): `live-timeout`, `live-unreachable`, `live-refused`, `live-unsupported`, `live-rate-limited`, `live-not-covered`, `live-error`.
|
|
3891
4259
|
|
|
3892
4260
|
| Outcome | Code |
|
|
@@ -3965,6 +4333,21 @@ The rejected alternative, `within(realpath(resolved), realpath(grant))`, was a *
|
|
|
3965
4333
|
|
|
3966
4334
|
**The store.** `packages/server/src/access/access-grants.ts`. Persisted at `~/.pi/dashboard/access-grants.json` (`PI_ACCESS_GRANTS_STORE` overrides; schema `{ version: 1, grants }`). One grant carries `subject` (realpath), `scope` (`"session"` — in-memory until server restart — or `"project"` — persisted), `grantedAt`, `origin` (the session whose denial produced it), and optional `widenedFrom` (the denied subject when the grant came from an offered ancestor). Invariants: absent/malformed store → empty, never throws; **cap 200 per scope**, oldest-`grantedAt` evicted within that scope only (a union cap would let an ephemeral session grant delete a persisted project grant); writes atomic (temp + rename) so a crash mid-write cannot truncate the store into its own malformed→empty rule; a failed write is non-fatal — the subject stays ungranted, the failure is logged **and returned to the caller** so the UI cannot claim a grant that does not exist. Recorded grants are audited (`[access-grant] granted subject=… scope=… site=… denialId=…`).
|
|
3967
4335
|
|
|
4336
|
+
**Write-mode grants** (change: fix-file-link-editor-routing, D2). Out-of-cwd text-doc save (`POST /api/file/write`) needs write grant. Read grant never admits write.
|
|
4337
|
+
|
|
4338
|
+
- `AccessGrant.mode?: "read" | "write"`. Absent = read. Store stays `version: 1`; rollback-safe (old build reads entry as read grant).
|
|
4339
|
+
- `loadFromDisk` fail-closed: `mode` other than exact `"write"` → read.
|
|
4340
|
+
- One entry per `(subject, scope, mode)`. Write grant = second entry beside read grant. Revocable independently.
|
|
4341
|
+
- `grantedSubjects()` unchanged, includes write entries (write ⊃ read). `grantedWriteSubjects()` = `mode:"write"` only.
|
|
4342
|
+
- Write evaluation: `evaluateContainment(..., {action:"write"})`. Skips layer ② (`checkoutAnchors`): checkout roots never admit write. Grant layer uses write subjects only.
|
|
4343
|
+
- Denial side field = `action: "read" | "write"` (`PathDenial`, `DenialFacts`, `PendingGrant`). Not `mode`: `mode` already names held/deferred prompt plane.
|
|
4344
|
+
- Pending registry key = `plane \0 action \0 subject`. Read + write denial for same dir = separate entries.
|
|
4345
|
+
- Grant mode derived server-side from recorded denial/prompt `action`. Never from client field. `grant_response` carries verdict + rung only.
|
|
4346
|
+
- `allow-once` = transient real-path grant for this request, write predicate, never persisted. `performAtomicMdWrite` re-realpath must equal gated realpath, else refuse.
|
|
4347
|
+
- YOLO: write hold = filesystem-plane denial → auto allow-once, only within YOLO roots (default root = session cwd → outside write still prompts). No persisted grant.
|
|
4348
|
+
- Prompt before existence: nonexistent outside doc prompts, then `404`. Stat-first = existence oracle, refused.
|
|
4349
|
+
- Access page: write row shows "Write" badge. `DELETE /api/access/grants` optional `mode`; last-entry removal only un-mirrors pi-trust.
|
|
4350
|
+
|
|
3968
4351
|
`"session"` scope means the **server process**, not the pi session whose denial produced it (design D17): one grant widens the grant layer for every session and every connected client; `origin` is what the Access tab shows.
|
|
3969
4352
|
|
|
3970
4353
|
**Read-once, cost-bounded on the hot path** (design D16). The store is loaded into memory once and invalidated on write; the containment path never reads the store synchronously. `isAllowed` is async by explicit design (one caller stalling would block every request), so a sync read on that path would regress it. With an empty store the predicate short-circuits with zero syscalls — that is what makes "empty store is byte-identical to today" true of **cost** as well as outcome. When grants exist, evaluation is a linear scan of distinct subjects with one `realpath` on the request side; `grep-routes.ts` awaits the predicate per match, so N matches x 200 grants x a `realpath` is the worst case the cap alone does not bound. `GET /api/access/store-stats` exposes the load count so a test can prove the hot path never re-reads the store. Rollback consequence: deleting the store file changes nothing until the process restarts — the supported rollback is **revoke through the Access tab** (which invalidates the in-memory set), or delete-then-restart.
|
|
@@ -4002,7 +4385,7 @@ Bridge-side companion to **Access-Grant Prompts and YOLO** and **Access Grants a
|
|
|
4002
4385
|
|
|
4003
4386
|
**Approve, not sandbox.** Gate asks operator when a covered tool leaves its roots. Does **not** confine: `bash`, `grep`, `find`, `ls`, custom and MCP tools are not covered (shell strings are not reliably parseable). UI copy must not call it a sandbox or confinement. Agent runs as the operator's user and can write `access-grants.json` itself; nothing here defends against a hostile local process.
|
|
4004
4387
|
|
|
4005
|
-
**Where it lives** (design D1). Pure decision module `packages/extension/src/path-gate/` (`decidePathAccess`, plus `resolve.ts`, `roots.ts`, `grant-cache.ts`, `suppression.ts`, `grant-link.ts`, `handler.ts`, `index.ts`). Registered in `bridge.ts` as its own `tool_call` handler
|
|
4388
|
+
**Where it lives** (design D1). Pure decision module `packages/extension/src/path-gate/` (`decidePathAccess`, plus `resolve.ts`, `roots.ts`, `grant-cache.ts`, `suppression.ts`, `grant-link.ts`, `handler.ts`, `index.ts`). Registered in `bridge.ts` as its own `tool_call` handler, **not** wrapped in the fail-open `safe(...)`. Own `try/catch` maps any internal error — including a throwing `ctx.cwd` getter after session teardown — to `{ block: true, reason }`. In-root calls take no round-trip.
|
|
4006
4389
|
|
|
4007
4390
|
**Gated tools.** `read`, `write`, `edit` only, matched by name.
|
|
4008
4391
|
|
|
@@ -4680,6 +5063,49 @@ Approval: operator types numeric confirm code shown on device → `POST /api/pai
|
|
|
4680
5063
|
|
|
4681
5064
|
Gate: `reachableUrls()` (`packages/server/src/pairing.ts`) read-time filter (D4/D14) advertises only secure `wss`/`https` endpoints. Keeps `urls[]` secure. `createPayload()` returns null when no reachable url → route returns `{success:false,error:"no_reachable_endpoint"}` (HTTP 200).
|
|
4682
5065
|
|
|
5066
|
+
### Device keys and the mutual device check (change: device-key-mutual-check)
|
|
5067
|
+
|
|
5068
|
+
Paired device proves possession of its own key. One key per server fingerprint. Check is mutual: device proves the server first, signs second.
|
|
5069
|
+
|
|
5070
|
+
```mermaid
|
|
5071
|
+
sequenceDiagram
|
|
5072
|
+
participant C as Client
|
|
5073
|
+
participant S as Server (route)
|
|
5074
|
+
C->>S: POST /api/pair/challenge {nonce}
|
|
5075
|
+
S-->>C: {fingerprint, publicKey, signature, deviceNonce}
|
|
5076
|
+
Note over C: verify signature + fingerprint vs pin or advert
|
|
5077
|
+
alt route not proven
|
|
5078
|
+
Note over C: stop — no proof to this route
|
|
5079
|
+
else route proven
|
|
5080
|
+
C->>S: POST /api/pair/device-status {deviceNonce, pub, sig}
|
|
5081
|
+
S-->>C: {status: paired|expired|unknown|revoked, tier?, scope?}
|
|
5082
|
+
end
|
|
5083
|
+
Note over S: any failure → {status:"unverified"} at HTTP 200
|
|
5084
|
+
```
|
|
5085
|
+
|
|
5086
|
+
- Step 1 — `POST /api/pair/challenge {nonce}` reply gains `deviceNonce`: 32 random bytes, base64url (43 chars). Store single-use, 60 s TTL, bound 10 000 entries, oldest evicted. Carries no secret.
|
|
5087
|
+
- Client verifies step 1 against pin or advertised fingerprint FIRST. Unproven route → stop, no proof sent.
|
|
5088
|
+
- Step 2 — `POST /api/pair/device-status {deviceNonce, pub, sig}`. `sig` = Ed25519 over `pi-devcheck/v2\n<fp>\n<deviceNonce>`. `pub` = raw 32-byte key, unpadded base64url (43), not SPKI; `sig` 64 bytes (86). Charset + length checked before decode. Nonce consumed on first presentation, so no client timestamp.
|
|
5089
|
+
- Reply `{status: paired|expired|unknown|revoked, tier?, scope?}`. Full paired key → `tier` + `scope:"full"`. Companion → `scope:"status-only"`, no tier. `expired` / `revoked` → neither. `revoked` decided first, wins over `expired`.
|
|
5090
|
+
- `expired` reuses the per-row judgement that refuses a bearer `401 bearer_expired` (`currentVerdict`, `packages/server/src/pairing/paired-devices.ts`), never a copy of the expiry arithmetic.
|
|
5091
|
+
- Every failure — bad signature, malformed field, unknown / expired / consumed nonce, rate-limited peer — answers `{status:"unverified"}` at HTTP 200. Discloses only the caller's own key status.
|
|
5092
|
+
- Limit 60/min per peer address, sliding window, invalid attempts counted. Limiter map bound 1024 peers, oldest evicted. Step 1 never limited.
|
|
5093
|
+
- Route public (`PUBLIC_PAIRING_PREFIXES`), tier `observe` like the challenge. Not a prefix of `/api/pair/device-key` — auth hook matches `startsWith`.
|
|
5094
|
+
- Proof, key bind, keyed knock go ONLY to the route that proved the pin in that selection. Electron `http:` route → the address literal that proved it, never the host name or a sibling literal. `https:` → proven host name.
|
|
5095
|
+
- Key per fingerprint: browser `packages/client/src/lib/pairing/device-key.ts` — non-extractable WebCrypto key in IndexedDB, secure contexts only. Electron main `packages/electron/src/lib/device-key.ts`, private part under `safeStorage` (`server-keyring.ts`). Shell `packages/shell/src/lib/device-key.ts` — IndexedDB.
|
|
5096
|
+
- Created only when pairing starts (Request access, Pair with code, Pair again). Listing creates nothing.
|
|
5097
|
+
- Registered at approval: knock / redeem body carries `deviceKey: {deviceNonce, pub, sig}`, `sig` over `pi-devbind/v1`. Held on `PendingDevice`, passed to `registry.add` — deny / expiry / lockout leaves nothing behind.
|
|
5098
|
+
- Later bind: `POST /api/pair/device-key {deviceNonce, pub, sig}` with the device's own credential (`authVia === "device"`). `400` bad proof, `401` no credential, `409` key held by another row, tier `observe`. One primary key per row; replaces the old one.
|
|
5099
|
+
- Uniqueness: one public key across primary + companion keys of active and revoked rows. Duplicate at approval → pairing proceeds keyless; duplicate at bind → `409`.
|
|
5100
|
+
- Companion key: `#companion=<pub>.<ts>.<sig>&from=<origin>` fragment, `sig` over `pi-companion/v1`, `ts` ±300 s. Status-only, accepted nowhere else. Opt-in, unticked at approval, max 4 per device.
|
|
5101
|
+
- Revoke is a state. Whole row (hash, tier, keys, companions, expiry fields) moves to `~/.pi/dashboard/revoked-devices.json` (0600) plus `revokedAt` / `revokedBy`. Revoked written FIRST, then active removed; id in both files → revoked wins.
|
|
5102
|
+
- Undo restores hash, tier, keys, companions, expiry fields unchanged — never extends expiry, never restarts the grace window. Purge at 90 d (`REVOKED_RETENTION_MS`) or Delete now.
|
|
5103
|
+
- Unreadable revoked file → set aside as `revoked-devices.corrupt-<time>.json`, empty list, `warning` on `GET /api/paired-devices/revoked`.
|
|
5104
|
+
- `registry.onRevoked(listener)` → browser gateway + pi gateway close matching sockets, code `4401`, reason `device revoked`. `verify()` scans active rows only, so REST, device-session, ws-ticket, bridge mint need no change.
|
|
5105
|
+
- Rollback-safe: older builds ignore the second file, degrade to "revoke = delete". Only Undo is lost.
|
|
5106
|
+
- Discard rule: no device-status answer discards anything — `unknown`, `expired`, `revoked` all keep credential and key. Only a refused credential at a proven route (`401`, incl. `401 bearer_expired`; refused cookie exchange) discards credential + key together.
|
|
5107
|
+
- Shared helpers: `packages/shared/src/device-key-proof.ts` — message builders, validators, `deviceRowState`. Server verifier `packages/server/src/auth/device-proof.ts`.
|
|
5108
|
+
|
|
4683
5109
|
### Built-in TLS listener (change: add-tailscale-cert-tls)
|
|
4684
5110
|
|
|
4685
5111
|
Optional second `https.Server`. Off by default (`tls.enabled: false`). Serves the SAME Fastify app as the main listener.
|
|
@@ -5295,8 +5721,8 @@ When a browser subscribes to a session whose events have been evicted from memor
|
|
|
5295
5721
|
5. If the session file is missing or corrupt, server sends `dataUnavailable: true`
|
|
5296
5722
|
6. Concurrent loads for the same session are deduplicated
|
|
5297
5723
|
|
|
5298
|
-
### Flows Refresh Deduplication
|
|
5299
|
-
|
|
5724
|
+
### Flow Catalog Refresh (replaces Flows Refresh Deduplication)
|
|
5725
|
+
`flows_list` and `request_flows_refresh` removed. Catalog refresh runs through plugin channel `dashboard-flows:catalog` (see Plugin-declared event forwarding). Sibling rediscover ask fires only when a known catalog changes. Former `recentFlowsRefresh` 5 s cooldown no longer exists.
|
|
5300
5726
|
|
|
5301
5727
|
### Event Broadcast During Replay (change: fix-large-session-resume-replay, #928/#929)
|
|
5302
5728
|
|
|
@@ -5421,6 +5847,69 @@ flowchart LR
|
|
|
5421
5847
|
List --> Fold["Archive (N) fold"]
|
|
5422
5848
|
```
|
|
5423
5849
|
|
|
5850
|
+
## Mid-turn prompt queue (steer + follow-up)
|
|
5851
|
+
|
|
5852
|
+
- Follow-ups: bridge-owned `bridgeFollowUp` (`packages/extension/src/followup-buffer.ts`).
|
|
5853
|
+
- pi never sees held follow-ups until `drainOneFollowup` (`followup-drain.ts`) ships one per `agent_settled` as fresh prompt.
|
|
5854
|
+
- Steers: bridge holds dashboard steers sent while streaming in `inst.bridgeSteer` (`packages/extension/src/steer-buffer.ts`, `createSteerBuffer(instanceNonce)`).
|
|
5855
|
+
- Steer ids `<nonce>:<seq>`; entries `{id,text,images?,promptId?}`.
|
|
5856
|
+
- Steer buffer: cap 20 + byte ceiling 32 MiB, same as follow-ups, accounted independently.
|
|
5857
|
+
- `admitSteer` validates images. Refusal → `command_feedback` for `send_prompt`.
|
|
5858
|
+
- Routing (`command-handler.ts` passthrough + `bridge.ts` `sessionPrompt` fallback):
|
|
5859
|
+
- flags `bufferFollowUp` / `bufferSteer`.
|
|
5860
|
+
- streaming steer → steer buffer, no pi call, `prompt_received` ack without `promptId`.
|
|
5861
|
+
- idle steer → direct `pi.sendUserMessage`.
|
|
5862
|
+
- Hand-off: `handOffHeldSteers` (`bridge-handlers/lifecycle.ts`) runs inside awaited `turn_end` handler, `outcome === "completed"` only.
|
|
5863
|
+
- pi awaits extension `turn_end` handlers before `getSteeringMessages()` (`pi-agent-core` `agent-loop.js`).
|
|
5864
|
+
- Hand-off takes oldest (`steeringMode` `"one-at-a-time"`, default) or all (`"all"`).
|
|
5865
|
+
- Hand-off removes entries + emits `queue_update` synchronously BEFORE sends.
|
|
5866
|
+
- Hand-off per entry: `pi.sendUserMessage(content,{deliverAs:"steer"})` → `prompt_received{fresh:false,promptId}` → one macrotask yield.
|
|
5867
|
+
- After hand-off: not cancellable. Bubble gone. pi renders user message.
|
|
5868
|
+
- Settle drain: `drainOneFollowup` ships oldest held steer BEFORE follow-ups, one per `agent_settled`, same gates, acks `promptId`.
|
|
5869
|
+
- Settle drain covers steer after last turn and aborted/error runs.
|
|
5870
|
+
- Cancel: browser → server → bridge `remove_steering_entry{sessionId,id}` / `clear_steering_entries{sessionId}`.
|
|
5871
|
+
- Cancel handlers: `bridge-handlers/dispatch.ts`. No pi call.
|
|
5872
|
+
- Unknown id → `command_feedback` "Steer already sent or cancelled".
|
|
5873
|
+
- Server relay: `session-action-handler.ts` `handleRemoveSteeringEntry` / `handleClearSteeringEntries`.
|
|
5874
|
+
- ACP sessions ignore cancel (`acp-bridge/server-requests.ts`).
|
|
5875
|
+
- `clear_steering_queue` stays deleted (pi exposes no queue removal).
|
|
5876
|
+
- Wire: `queue_update.steering` / `pendingQueues.steering` = `(SteerEntryView | string)[]`.
|
|
5877
|
+
- `SteerEntryView{id,text,imageCount}`.
|
|
5878
|
+
- Plain strings = legacy bridges (one release), no cancel.
|
|
5879
|
+
- `message_start` matcher touches follow-ups only.
|
|
5880
|
+
- Re-announce `queue_update` (empty included) on:
|
|
5881
|
+
- register: `lifecycle.ts`, after `sessionReady = true`.
|
|
5882
|
+
- re-register: `bridge.ts` `onReconnect`, after `sendStateSync`.
|
|
5883
|
+
- Trade-off: held steers live in bridge memory. Bridge reload mid-turn drops them.
|
|
5884
|
+
- Client: `PendingSteerCard.tsx`.
|
|
5885
|
+
- ✕ `pending-steer-cancel-<id>`.
|
|
5886
|
+
- image badge.
|
|
5887
|
+
- `PendingSteerClearAll` from 2 entries.
|
|
5888
|
+
- no confirmation.
|
|
5889
|
+
|
|
5890
|
+
```mermaid
|
|
5891
|
+
sequenceDiagram
|
|
5892
|
+
participant D as Dashboard
|
|
5893
|
+
participant S as Server
|
|
5894
|
+
participant B as Bridge
|
|
5895
|
+
participant P as pi
|
|
5896
|
+
D->>S: send_prompt (streaming, steer)
|
|
5897
|
+
S->>B: send_prompt
|
|
5898
|
+
B->>B: held in inst.bridgeSteer (cancellable)
|
|
5899
|
+
B-->>S: prompt_received (no promptId)
|
|
5900
|
+
B-->>S: queue_update
|
|
5901
|
+
Note over B,P: turn_end (outcome completed)
|
|
5902
|
+
B->>B: handOffHeldSteers: remove + queue_update
|
|
5903
|
+
B->>P: sendUserMessage(deliverAs steer)
|
|
5904
|
+
B-->>S: prompt_received{fresh:false,promptId}
|
|
5905
|
+
Note over B: cancel path
|
|
5906
|
+
D->>S: remove_steering_entry{id}
|
|
5907
|
+
S->>B: remove_steering_entry{sessionId,id}
|
|
5908
|
+
B->>B: drop entry (no pi call)
|
|
5909
|
+
B-->>S: queue_update
|
|
5910
|
+
S-->>D: queue_update
|
|
5911
|
+
```
|
|
5912
|
+
|
|
5424
5913
|
## Persistence
|
|
5425
5914
|
|
|
5426
5915
|
| Data | Storage | Details |
|
|
@@ -5856,25 +6345,23 @@ pi extensions + plugin bridges still load under pi's jiti (separate process).
|
|
|
5856
6345
|
|
|
5857
6346
|
Both server-launch call sites (`packages/server/src/cli.ts` and `packages/extension/src/server-launcher.ts`) capture **both** stdout and stderr into `~/.pi/dashboard/server.log`. The CLI uses `stdio: ["ignore", logFd, logFd]` on its direct `spawn()` call; the bridge uses `spawnDetached({ stdoutFd: logFd, logFd })`. Without this parity, crash diagnostics from jiti / Fastify / ajv-compiler that reach stdout would be invisible via the bridge path while remaining visible via the CLI path. See change: `fix-bridge-autostart-diagnostics`.
|
|
5858
6347
|
|
|
5859
|
-
#### CJS preload for Fastify (
|
|
5860
|
-
|
|
5861
|
-
Every server-spawn call site injects `--require <preload-fastify.cjs>` BEFORE `--import <native-loader>` in the child's argv, as long as the resolver `resolvePreloadFastifyPath()` in `packages/shared/src/platform/preload-fastify.ts` finds the preload file. The order matters: Node processes `--require` before `--import`, so the preload runs through Node's **legacy synchronous CJS loader** (which predates and bypasses the ESM→CJS translator). The preload synchronously `require()`s `@fastify/ajv-compiler/standalone`, `@fastify/ajv-compiler`, and `fastify` — populating `require.cache` with those modules in `kEvaluated` state.
|
|
6348
|
+
#### CJS preload for Fastify (removed)
|
|
5862
6349
|
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
This is a **race-independent fix**: it doesn't try to close the timing window, it removes the racy code path from the execution trace. All four spawn sites (CLI daemon, bridge auto-start, Electron, restart orchestrator) share the resolver and the same injection pattern. See change: `preload-fastify-cjs`.
|
|
6350
|
+
The `--require preload-fastify.cjs` injection no longer exists. `preload-fastify.cjs` and `resolvePreloadFastifyPath()` are deleted; spawn argv carries no `--require`. The #58515 `Unexpected module status 3` assertion affects Node 22.0.0–22.18.x and 24.1.0–24.2.x only — all below the Node 26 server floor. See change: `raise-node-floor-to-26`.
|
|
5866
6351
|
|
|
5867
6352
|
#### Node-version preflight
|
|
5868
6353
|
|
|
5869
|
-
Single source of truth: `packages/shared/src/node-version.ts`. Exports `
|
|
6354
|
+
Single source of truth: `packages/shared/src/node-version.ts`. Exports `MIN_SERVER_NODE` (`"26.0.0"`), `MIN_PI_SPAWN_NODE` (`"22.19.0"`), `SERVER_ENGINES_RANGE` (`">=26.0.0 <27"`), `meetsFloor(version, floor)`, `isAffectedNode(version)`, `isOutOfEnginesRange(version)`, `isUsableNodeVersion(version)`, `isAtOrAboveEnginesCap(version)`. Version predicates live solely here — single module, no platform-split checker.
|
|
5870
6355
|
|
|
5871
|
-
|
|
6356
|
+
- Server floor `26.0.0`; range `>=26.0.0 <27`. Cap `<27` bounds tested range; cap excess flagged, not refused by the server guard.
|
|
6357
|
+
- `isUsableNodeVersion` = clean semver AND `!isOutOfEnginesRange`. No separate #58515 check.
|
|
6358
|
+
- `isAffectedNode` ([nodejs/node#58515](https://github.com/nodejs/node/issues/58515); `22.0.0–22.18.x` + `24.1.0–24.2.x`) used only by the pi-session spawn-ladder gate. Pi itself keeps `>=22.19.0`.
|
|
5872
6359
|
|
|
5873
|
-
Startup guard
|
|
6360
|
+
Startup guard: `packages/server/src/auth/node-guard.ts` `assertNodeVersionSupported()` checks `isOutOfEnginesRange` only; exits(1) on failure. `buildEnginesRangeMessage` prints `Required: >=26.0.0 <27`, `nvm install 26 && nvm use 26`, `brew install node`. Managed hint printed only when `<managedDir>/node/.version` marker meets the range (marker read, no spawn). The former #58515 startup check and `buildNodeUpgradeMessage` are removed.
|
|
5874
6361
|
|
|
5875
|
-
Consumers: startup guard; Electron `lib/dependency-detector.ts` `
|
|
6362
|
+
Consumers: startup guard; Electron `lib/dependency-detector.ts` `detectSystemNode` (accept-set Node 26 only, via `isUsableNodeVersion`); server spawn via `resolveServerRuntime()` (below); pi-session spawn-runtime gate `evaluateVersionGate`.
|
|
5876
6363
|
|
|
5877
|
-
Root `package.json` declares `"engines": { "node": ">=
|
|
6364
|
+
Root `package.json` declares `"engines": { "node": ">=26.0.0 <27" }`; `packages/server/package.json` `"node": ">=26.0.0"`.
|
|
5878
6365
|
|
|
5879
6366
|
#### Spawn runtime resolution
|
|
5880
6367
|
|
|
@@ -5887,7 +6374,7 @@ Four rungs, first hit wins:
|
|
|
5887
6374
|
3. User Node — login-shell first on Electron arm, PATH first on terminal arms (`npm`/`docker`); then version-manager fs probe (`~/.nvm/alias/default`), no shell.
|
|
5888
6375
|
4. Managed `<managedDir>/node`; else bundled; else `process.execPath` — terminal rung, never fails.
|
|
5889
6376
|
|
|
5890
|
-
Gate (`evaluateVersionGate`): pass pi engines floor + not nodejs/node#58515-affected; cap excess (`isAtOrAboveEnginesCap`, `<27`) accepted, flagged `capExceeded`. Floor read from spawned pi copy engines; fallback `
|
|
6377
|
+
Gate (`evaluateVersionGate`): pass pi engines floor + not nodejs/node#58515-affected; cap excess (`isAtOrAboveEnginesCap`, `<27`) accepted, flagged `capExceeded`. Floor read from spawned pi copy engines; fallback `MIN_PI_SPAWN_NODE`.
|
|
5891
6378
|
|
|
5892
6379
|
Publication: `runtime.resolved` written to `~/.pi/dashboard/config.json` every server start (`packages/server/src/runtime-publication.ts::publishResolvedRuntime`). Diagnostic-only; override never written. `pi-dashboard runtime` CLI subcommand prints resolved runtime.
|
|
5893
6380
|
|
|
@@ -5895,6 +6382,59 @@ Spawn-time re-validation (`packages/server/src/runtime-resolution.ts`): boot-tim
|
|
|
5895
6382
|
|
|
5896
6383
|
Doctor rows: resolved runtime (+ rung/via), ABI mismatch, legacy `~/.pi-dashboard/` dir orphan test. Home split: `~/.pi/dashboard/` = user config + published runtime state; `~/.pi-dashboard/` = machine-managed runtime, managed node_modules, logs.
|
|
5897
6384
|
|
|
6385
|
+
#### Server spawn runtime resolution (`resolveServerRuntime`)
|
|
6386
|
+
|
|
6387
|
+
Resolves the Node binary that runs the dashboard **server**. Separate from the pi-session ladder above. Gate = `SERVER_ENGINES_RANGE` (`>=26.0.0 <27`). Source: `packages/shared/src/platform/spawn-runtime.ts`.
|
|
6388
|
+
|
|
6389
|
+
Order, first in-range hit wins:
|
|
6390
|
+
|
|
6391
|
+
1. `runtime.override` (`~/.pi/dashboard/config.json`).
|
|
6392
|
+
2. First `node` on PATH.
|
|
6393
|
+
3. Version-manager defaults: nvm `alias/default`, volta, asdf, mise, fnm.
|
|
6394
|
+
4. Managed `<managedDir>/node`.
|
|
6395
|
+
5. Starter's own runtime (`ownRuntime`; version from running process, never probed).
|
|
6396
|
+
|
|
6397
|
+
```mermaid
|
|
6398
|
+
flowchart TD
|
|
6399
|
+
S([resolveServerRuntime]) --> O{override in range?}
|
|
6400
|
+
O -- yes --> R([resolved])
|
|
6401
|
+
O -- no --> P{PATH node in range?}
|
|
6402
|
+
P -- yes --> R
|
|
6403
|
+
P -- no --> V{version-manager default in range?}
|
|
6404
|
+
V -- yes --> R
|
|
6405
|
+
V -- no --> M{managed node in range?}
|
|
6406
|
+
M -- yes --> R
|
|
6407
|
+
M -- no --> W{own runtime in range?}
|
|
6408
|
+
W -- yes --> R
|
|
6409
|
+
W -- no --> X([resolved false + trail])
|
|
6410
|
+
```
|
|
6411
|
+
|
|
6412
|
+
Properties:
|
|
6413
|
+
|
|
6414
|
+
- Not total: no match → `{resolved:false, range, trail}`.
|
|
6415
|
+
- No shell ever run. nvm without `alias/default` is not found.
|
|
6416
|
+
- ≤1 `--version` probe per distinct path (`execFile`).
|
|
6417
|
+
- `describeServerRuntimeTrail()` formats trail for logs.
|
|
6418
|
+
|
|
6419
|
+
#### Bridge auto-start runtime + refusal
|
|
6420
|
+
|
|
6421
|
+
Source: `packages/extension/src/server-auto-start.ts`. Inside the single-flight lock:
|
|
6422
|
+
|
|
6423
|
+
- Resolves server Node via `resolveServerRuntime()`. Skipped when dashboard already answers.
|
|
6424
|
+
- Resolved: logs `server runtime: <path> <version> via <step>` (`appendAutoStartLog`); passes `nodeBin` to `launchServer` (`packages/extension/src/server-launcher.ts`).
|
|
6425
|
+
- Unresolved: re-probe port (attach if up, silent). Else logs `[auto-start] refused: no Node satisfying >=26.0.0 <27 ...; candidates: ...` and shows one `ui.notify` warning per session (range, pi's Node version, install Node 26 or desktop app, `~/.pi/dashboard/server.log` path).
|
|
6426
|
+
|
|
6427
|
+
#### Electron server Node pick
|
|
6428
|
+
|
|
6429
|
+
Source: `packages/electron/src/lib/pick-node.ts`. Order:
|
|
6430
|
+
|
|
6431
|
+
1. Bundled Node (`BUNDLED_NODE_VERSION` v26.13.0; `BUNDLED_NODE_MAJOR` 26).
|
|
6432
|
+
2. System Node — pre-resolved by `launch-source.ts` via `resolveServerRuntime({ownRuntime:null})`, only when bundled Node missing.
|
|
6433
|
+
3. Electron executable with `ELECTRON_RUN_AS_NODE=1` — only if embedded Node (`process.versions.node`) in range. Electron 44 embeds 24.22.0 → never qualifies.
|
|
6434
|
+
4. `unavailable` — `launch-source` throws `pick.reason`; no `launchDashboardServer` call; `requestServerLaunch` → `{kind:"failed"}`.
|
|
6435
|
+
|
|
6436
|
+
Electron dev / localLink launches need Node 26 on PATH or in a version manager.
|
|
6437
|
+
|
|
5898
6438
|
#### AppImage CLI self-recursion guard (Linux power-user mode)
|
|
5899
6439
|
|
|
5900
6440
|
Electron's power-user launch path (`ensureServer()` → `detectPiDashboardCli()` → `launchViaCli()`) prefers already-installed `pi-dashboard` CLI on PATH. On Linux **AppImage** builds, AppImage runtime prepends its squashfs mount dir (e.g. `/tmp/.mount_PI-Das.../`) to `PATH` of Electron child. Mount contains binary literally named `pi-dashboard` because `forge.config.ts` declares `packagerConfig.executableName: "pi-dashboard"` for branding consistency. Without guard, `which pi-dashboard` returns AppImage's own launcher first; `launchViaCli()` spawns Electron app recursively as if it were dashboard CLI; recursive child silently ignores `start --port 8000`, never opens dashboard port, `waitForReady` polls until 15s deadline expires — user sees indefinite loading screen.
|
|
@@ -5939,7 +6479,9 @@ Electron-bound presentation concerns (tray icons, menu template, dock behavior,
|
|
|
5939
6479
|
|
|
5940
6480
|
### Windows runtime dependencies (git + bash)
|
|
5941
6481
|
|
|
5942
|
-
On Windows agent needs `git.exe` + bash. git backs repo ops. bash backs agent `bash` tool, `!`/`!!` bang commands, `!cmd` config values. Pi resolves bash itself (`getShellConfig()`, pi-coding-agent 1.
|
|
6482
|
+
On Windows agent needs `git.exe` + bash. git backs repo ops. bash backs agent `bash` tool, `!`/`!!` bang commands, `!cmd` config values. Pi resolves bash itself (`getShellConfig()`, pi-coding-agent 1.5.0). Dashboard never calls `pi.exec("sh")`. macOS/Linux ship both system-wide; Windows-only problem.
|
|
6483
|
+
|
|
6484
|
+
Shell replica `packages/shared/src/platform/resolve-pi-shell.ts` (names pi 1.5.0). `isWslLauncherBash(p, env)` SystemRoot-aware: launcher = `<SystemRoot>\System32|Sysnative\bash.exe`. Non-drive-absolute SystemRoot → not launcher. Fixed `<drive>:\Windows\…` regex used only when SystemRoot unset. Existence check = `accessSync(F_OK)`.
|
|
5943
6485
|
|
|
5944
6486
|
Installers embed dugite-native (git 2.53.0.windows.4). Bundle ships GNU bash only as `usr/bin/sh.exe`. Config key `windowsGitSource`: `"auto"`\|`"host"`\|`"bundled"`, default `"auto"`.
|
|
5945
6487
|
|
|
@@ -6031,6 +6573,13 @@ Per-session keeper process owns pi's stdin pipe. Keeper forwards verbatim to pi'
|
|
|
6031
6573
|
|
|
6032
6574
|
Keeper outlives dashboard server restarts. Replaced Unix `tail -f /dev/null | pi` wrapper and Windows direct-stdin pipe. Uniform durability across Unix and Windows.
|
|
6033
6575
|
|
|
6576
|
+
Keeper logging off by default. Settings > Developer toggle `keeperLog.capturePiOutput` (default `false`) gates ALL keeper log output.
|
|
6577
|
+
- Off: no `keeper-<id>.log`, no `keeper-launch-<id>.log`. `log()` no-op. Rotation not armed. PID sidecars (`.pid`, `.pi-pid`) still written.
|
|
6578
|
+
- On: lifecycle lines + pi stdout/stderr → `keeper-<id>.log` (in-place rotation at `keeperLog.maxBytes`); keeper startup stderr → `keeper-launch-<id>.log`.
|
|
6579
|
+
- Server sets `PI_KEEPER_CAPTURE_PI_OUTPUT=1` from config only. Deletes inherited value (case-insensitive) when off. Inherited env cannot enable.
|
|
6580
|
+
- Read at spawn: applies to new sessions only. Running keepers keep prior behavior.
|
|
6581
|
+
- Server closes launch-log fd after spawn.
|
|
6582
|
+
|
|
6034
6583
|
Three-process topology + dual-channel boundary:
|
|
6035
6584
|
|
|
6036
6585
|
```mermaid
|
|
@@ -6181,7 +6730,7 @@ The dashboard uses mDNS (via `bonjour-service`) for zero-config server discovery
|
|
|
6181
6730
|
- Host normalised (`normalizeHost`): lower-case, one trailing dot removed, brackets and zone id stripped, IPv4-mapped IPv6 as IPv4.
|
|
6182
6731
|
- Route proof, two concurrent calls per route:
|
|
6183
6732
|
- identity challenge (`POST /api/pair/challenge`, route scheme): proof + latency.
|
|
6184
|
-
- `GET /api/health`: access. `403 network_not_allowed` → "Network not allowed".
|
|
6733
|
+
- `GET /api/health`: access. `403 network_not_allowed` → "Network not allowed". A `200` carrying `networkAccess.error` means same denial but this checker ignores it (`server-route-check.ts` unchanged; `surface-network-denial-on-health` design D6).
|
|
6185
6734
|
|
|
6186
6735
|
| Challenge | Health | Route state |
|
|
6187
6736
|
| --- | --- | --- |
|
|
@@ -6458,7 +7007,7 @@ See change: add-radius-provider-login (D5, D6).
|
|
|
6458
7007
|
|
|
6459
7008
|
**Non-goal.** Model proxy has no Radius OAuth refresh loader.
|
|
6460
7009
|
|
|
6461
|
-
**Dependency pin.** The server imports only `@earendil-works/pi-coding-agent` (`await import(...)`, public index `ModelRuntime`), never `@earendil-works/pi-ai` and never either package's `dist/` (both unreachable — export maps / hoisted `1.
|
|
7010
|
+
**Dependency pin.** The server imports only `@earendil-works/pi-coding-agent` (`await import(...)`, public index `ModelRuntime`), never `@earendil-works/pi-ai` and never either package's `dist/` (both unreachable — export maps / hoisted `1.7.0`). Binding to the pi-ai copy pi-coding-agent was built against gives version parity by construction. Six governed pins move together: `packages/server/package.json` dep `^1.7.0`, `piCompatibility.minimum`, `piCompatibility.recommended`, the `pnpm-workspace.yaml` override, `docker/Dockerfile`, and `scripts/verify-release-deps.mjs` `minVersion` (`checkPiPinCoherence`). Every `@earendil-works` peer is `>=1.7.0` (optional, no upper bound); every `@earendil-works` devDependency is `^1.7.0`; `pnpm-workspace.yaml` overrides pin `pi-coding-agent`, `pi-ai`, `pi-tui`. See changes: update-pi-core-1-0-adopt-apis, update-pi-core-1-1-adopt-apis, update-pi-core-1-3-adopt-apis; floor moved to 1.1.0 in update-pi-core-1-1-adopt-apis, to 1.3.0 in update-pi-core-1-3-adopt-apis, to 1.5.0 in update-pi-core-1-5-adopt-apis.
|
|
6462
7011
|
|
|
6463
7012
|
**Routes** (`packages/server/src/routes/provider-auth-routes.ts`):
|
|
6464
7013
|
|
|
@@ -6526,6 +7075,109 @@ The endpoint resolves `$ENV_VAR` references and the `***` REDACTED sentinel (for
|
|
|
6526
7075
|
| `src/client/components/settings/ProviderAuthSection.tsx` | Settings UI component |
|
|
6527
7076
|
| `src/client/components/settings/RadiusMcpOffer.tsx` | Inline Radius MCP offer shown after a completed `radius` sign-in |
|
|
6528
7077
|
|
|
7078
|
+
### Provider advanced settings
|
|
7079
|
+
|
|
7080
|
+
Edit opens `ProviderEditDialog.tsx` (panes in `ProviderAdvancedPanes.tsx`). Shared `PaneShell` = title + Back footer. Change: `add-provider-advanced-settings`.
|
|
7081
|
+
|
|
7082
|
+
Panes:
|
|
7083
|
+
- Main: per-kind content (sign-in facts, `ProviderEnvFields`, custom-endpoint fields + Test).
|
|
7084
|
+
- Advanced (collapsed): Endpoint, Models (→ one model), Edit as JSON, Add another `<name>` (copies).
|
|
7085
|
+
- Title `<provider> - <pane>`. One draft of whole block. Save writes once. Disabled until draft changes.
|
|
7086
|
+
- Endpoint/Models/JSON read-only when `writable:false`. Reasons: `provider_overrides.has_comments`, `.set_by_extension`, `.unreadable`, `.legacy_shape`, `.invalid_before`.
|
|
7087
|
+
|
|
7088
|
+
#### Two stores
|
|
7089
|
+
|
|
7090
|
+
```mermaid
|
|
7091
|
+
flowchart LR
|
|
7092
|
+
D[ProviderEditDialog] -->|built-in / models.json-only| O["/api/provider-overrides/:provider"]
|
|
7093
|
+
D -->|custom endpoint / copy| P["/api/providers/:name"]
|
|
7094
|
+
O --> M[(agentDir/models.json providers.id)]
|
|
7095
|
+
P --> J[(providers.json providers.id.block)]
|
|
7096
|
+
```
|
|
7097
|
+
|
|
7098
|
+
| Provider | Block lives in | Routes |
|
|
7099
|
+
|---|---|---|
|
|
7100
|
+
| pi built-in, or only in `models.json` | `models.json` `providers.<id>` | `GET`/`PUT /api/provider-overrides/:provider` |
|
|
7101
|
+
| custom endpoint, copy | `providers.json#providers.<id>.block` | `GET`/`PATCH /api/providers/:name` |
|
|
7102
|
+
|
|
7103
|
+
- `GET /api/providers/:name` (`operate`): entry, `block` masked, `revision`.
|
|
7104
|
+
- `PUT /api/provider-overrides/:provider` on `providers.json` id → 409 `owned_by_providers_json`.
|
|
7105
|
+
- Unknown id, no `models.json` block → 404.
|
|
7106
|
+
- Extension-set models: bridge reports `modelsSetByExtension: true` on `providers_list` catalogue entry. GET → `writable:false, reason:"provider_overrides.set_by_extension"`. PUT → 409 same code.
|
|
7107
|
+
- Split API-key row id `<id>-api` resolves to pi provider `<id>` on override routes (`provider-override-routes.ts`).
|
|
7108
|
+
- `PUT /api/providers` carries `block`, `copyOf`, unknown keys through unchanged.
|
|
7109
|
+
- `PATCH /api/providers/:name` keeps stored `block`/`copyOf` when omitted. Accepts `revision`; stale → 409 `stale_revision`. No `revision` → last-write-wins.
|
|
7110
|
+
- `block` may not hold `baseUrl`/`apiKey`/`api` → `block_field_owned_by_entry`.
|
|
7111
|
+
|
|
7112
|
+
#### `models.json` writer (`auth/models-json-store.ts`, `auth/provider-block-checks.ts`)
|
|
7113
|
+
|
|
7114
|
+
- Lock: `acquireLock(path, 2000, …)` from `locked-json-file.ts`. Held >2 s → 503 `provider_overrides.locked`.
|
|
7115
|
+
- Read, replace one key under `providers`, write tmp next to realpath, validate, rename. Symlink + mode kept. New file `0600`.
|
|
7116
|
+
- Tmp/rename I/O error → 500 `provider_overrides.write_failed`. Tmp deleted. `models.json` byte-identical.
|
|
7117
|
+
- Normalise: empty `headers`/`modelOverrides`/`models`/`compat` removed. Block with no fields → key deleted.
|
|
7118
|
+
- Revision: GET returns hash of stored block. PUT re-checks under lock before rename. Residual: unlocked hand edit between check and rename lost.
|
|
7119
|
+
- Refusals before write: `unreadable` (pi can't parse; `/* */` too), `has_comments` (`//` outside strings), `legacy_shape` (no `providers` object), `invalid_before` (file already fails pi).
|
|
7120
|
+
- Trailing commas + BOM not comments. Rewrite drops them. Values kept, formatting not.
|
|
7121
|
+
- Validation (two layers):
|
|
7122
|
+
- pi `ModelConfig.load(<tmp>)`, imported by resolved path `<pi>/dist/core/model-config.js` (`model-proxy/pi-models-validator.ts`).
|
|
7123
|
+
- Composer rules (dashboard fn): block needs ≥1 of `baseUrl`/`headers`/`compat`/`modelOverrides`/`models`; added model needs `baseUrl` somewhere. Parity test runs pi composer on same fixtures.
|
|
7124
|
+
- Import failure → fail closed, 503 `validator_missing`. Test pins path.
|
|
7125
|
+
- Other refusals (nothing written): body >256 KiB (262144) → 413 `too_large`; 400 `prototype_key`, `duplicate_model_id`, `orphan_mask`, `userinfo_refused`, `command_refused`, `RECURSIVE_PROXY` (self-pointing `baseUrl`). Codes under `provider_overrides.`; `PATCH` block path uses `providers.`.
|
|
7126
|
+
- After write: `refreshModelRegistry()` + `credentials_updated` (no `refreshProviders`). Sessions `ModelRegistry.refresh()` reload `models.json`.
|
|
7127
|
+
- Logs: provider, outcome, code. Never values.
|
|
7128
|
+
|
|
7129
|
+
#### Masking value classes
|
|
7130
|
+
|
|
7131
|
+
Follows pi resolver (`resolve-config-value`):
|
|
7132
|
+
- `!…` → command.
|
|
7133
|
+
- Unescaped `$NAME` / `${NAME}` → reference. `$$`, `$!` escape.
|
|
7134
|
+
- Else → literal.
|
|
7135
|
+
|
|
7136
|
+
Rules:
|
|
7137
|
+
- Literal `apiKey`, header values (any depth), `baseUrl` userinfo, `baseUrl` query values → masked `ENV_MASK_MARKER`.
|
|
7138
|
+
- Restore keys: provider header by case-insensitive name; model header by (model id, name); `modelOverrides` header by (model id, name); userinfo/query by (path, part/param).
|
|
7139
|
+
- Orphan marker → `orphan_mask`.
|
|
7140
|
+
- References + commands shown as text.
|
|
7141
|
+
- New/changed command from browser → `command_refused`. Unchanged kept.
|
|
7142
|
+
- Userinfo refused only when new/changed.
|
|
7143
|
+
- `ENV_MASK_MARKER` accepted only inside `block` + override routes. Legacy `***` stays on `GET /api/providers` `apiKey`.
|
|
7144
|
+
|
|
7145
|
+
#### Server hybrid apply (`model-proxy/models-block-apply.ts`, `internal-registry.ts`)
|
|
7146
|
+
|
|
7147
|
+
Runtime keeps `modelsPath: null`. Shared reader parses like pi (BOM, comments, trailing commas). On each registry refresh:
|
|
7148
|
+
1. Auth-side (`baseUrl`, `headers`, `authHeader`, `apiKey`) → `runtime.registerProvider(id, …)` for built-ins with block. pi composer applies in `getAuth`. OAuth kept. Removed block → unregister to bare built-in.
|
|
7149
|
+
2. Model-side (`baseUrl`, `compat`, `modelOverrides`, `models[]`) → dashboard applies to built-in model copies in `getAllModels()`. Pi order: `models[]` entry replaces same id, overrides last. Feeds `/api/models` + `streamSimple` object.
|
|
7150
|
+
3. `!command` value: server never runs it. Applied without value. Credential falls back to stored. Dependent models excluded, reason `command_value`.
|
|
7151
|
+
4. Block fails both checks → skipped (bare built-in) + registry error.
|
|
7152
|
+
- `GET /api/models` excludes credentials + `headers`.
|
|
7153
|
+
- `radius-override.ts` keeps precedence.
|
|
7154
|
+
- `$NAME` resolves in server env. Session resolves in session env. May differ. Row warning reflects server.
|
|
7155
|
+
|
|
7156
|
+
#### Copies
|
|
7157
|
+
|
|
7158
|
+
- Offered for built-ins whose sign-in = API key only (incl. key command).
|
|
7159
|
+
- Id `<base>-<slug(name)>`. Empty slug refused. Collision with any registry id refused on create only.
|
|
7160
|
+
- `copyOf` immutable.
|
|
7161
|
+
- Entry in `providers.json`; row `<base> · <name>`, `custom: true`.
|
|
7162
|
+
- Bridge (`extension/src/provider-register.ts`): skips discovery. Models = base effective models from session `ModelRegistry`, `baseUrl`+`headers` stripped. Config = base `models.json` block (`baseUrl`, `headers`, `authHeader`) overlaid by copy `block`. `compat`/`modelOverrides` merged per model. `name` set at registration.
|
|
7163
|
+
- Key: copy's own `apiKey`, else `ModelRegistry.getApiKeyForProvider(base)`. Server: `auth.json[base]` + server env.
|
|
7164
|
+
- Shared key = command → server excludes (`command_value`). Row warning "Server can't use `<base>`'s key command". Sessions still work.
|
|
7165
|
+
- Snapshot (`lastRegistered`/`entriesEqual`): `baseUrl`, `apiKey`, `api`, hash of `block`, `copyOf`, copy fingerprint (resolved key hash + base block hash + base model ids). Copies re-register on `credentials_updated` + `ModelRegistry.refresh()`.
|
|
7166
|
+
- Discovery, catalogue cache, `provider-probe` skip `copyOf`. `POST /api/providers/:name/refresh` on copy → 400 `copy_has_no_discovery`.
|
|
7167
|
+
|
|
7168
|
+
#### Vertex Project / Region
|
|
7169
|
+
|
|
7170
|
+
API-key method gets `Project` + `Region` fields (`shared/src/vertex-regions.ts`, `provider-overrides.ts`). Not env vars. Write `baseUrl`.
|
|
7171
|
+
- Project regex `^[a-z][a-z0-9-]{4,28}[a-z0-9]$`. Invalid → inline error, Save disabled.
|
|
7172
|
+
- Region: `global` | pinned list | Other (`^[a-z]+-[a-z]+[0-9]+$`). Disabled until Project set. No `us`/`eu`.
|
|
7173
|
+
- `global` → `https://aiplatform.googleapis.com/v1/projects/<p>/locations/global`.
|
|
7174
|
+
- Else → `https://<r>-aiplatform.googleapis.com/v1/projects/<p>/locations/<r>`.
|
|
7175
|
+
- Forms parse back. Other `baseUrl` → fields disabled ("Endpoint URL set under Advanced").
|
|
7176
|
+
- Built-in Vertex → override write. Copy → `block.baseUrl` via `PATCH`.
|
|
7177
|
+
- Save order (built-in): `baseUrl` first, then credential. `baseUrl` refused → nothing written; offer Save key without region. Credential refused → restore previous `baseUrl`. Restore fails → report both, Open Endpoint action.
|
|
7178
|
+
- Method switch / key removal removes Vertex-form `baseUrl` in same save. Refused → save refused.
|
|
7179
|
+
- Key check (`vertex-key-check.ts`): runs only when effective `baseUrl` empty or Vertex-form. `countTokens` under that `baseUrl`. Other host → `not_checked` (key never sent to custom host). 401/403/timeout/network/404 → failed. Else ok.
|
|
7180
|
+
|
|
6529
7181
|
## Terminal Emulator
|
|
6530
7182
|
|
|
6531
7183
|
The dashboard includes a browser-based terminal emulator for direct shell access.
|
|
@@ -6635,7 +7287,7 @@ See FAQ: How do I clean up stale entries from settings.json?
|
|
|
6635
7287
|
|
|
6636
7288
|
### Bundled first-party extensions (Electron installer)
|
|
6637
7289
|
|
|
6638
|
-
The Electron installer can optionally ship a curated subset of recommended pi extensions inside `resources/bundled-extensions/<id>/` so first-run works with zero network access. The set is declared by `BUNDLED_EXTENSION_IDS` in `packages/shared/src/recommended-extensions.ts` (currently `pi-
|
|
7290
|
+
The Electron installer can optionally ship a curated subset of recommended pi extensions inside `resources/bundled-extensions/<id>/` so first-run works with zero network access. The set is declared by `BUNDLED_EXTENSION_IDS` in `packages/shared/src/recommended-extensions.ts` (currently `pi-flows`) — a strict subset of `RECOMMENDED_EXTENSIONS`, enforced by a unit test.
|
|
6639
7291
|
|
|
6640
7292
|
**Build time** (`packages/electron/scripts/bundle-recommended-extensions.sh`): gated on `BUNDLE_RECOMMENDED_EXTENSIONS=1` (set in `.github/workflows/publish.yml`, unset everywhere else). Clones each id shallow, records the commit SHA to `.bundled-sha`, validates the SPDX identifier against a fixed allowlist (MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC), and fails the build if the combined bundle exceeds 15 MB. `forge.config.ts` conditionally appends `./resources/bundled-extensions` to `extraResource` when the directory exists.
|
|
6641
7293
|
|
|
@@ -6732,9 +7384,9 @@ The `.pi/skills/pi-dashboard/` directory is both a local project skill (discover
|
|
|
6732
7384
|
| `POST /api/session/:id/rename` | Rename a session |
|
|
6733
7385
|
| `POST /api/session/:id/hide` | Hide session |
|
|
6734
7386
|
| `POST /api/session/:id/unhide` | Unhide session |
|
|
6735
|
-
| `POST /api/session/spawn` | Spawn new session in a directory |
|
|
7387
|
+
| `POST /api/session/spawn` | Spawn new session in a directory. Body `{cwd, agent?, model?, thinkingLevel?, initialPrompt?, attachProposal?}`; `@role` resolved once; invalid choice → 400 (before side effects) |
|
|
6736
7388
|
| `POST /api/session/:id/resume` | Resume or fork ended session |
|
|
6737
|
-
| `POST /api/
|
|
7389
|
+
| `POST /api/plugins/flows/control` | Flow controls (abort, ask-session, run, delete, edit mode). Operate authority + network guard; ACP → 409 `unsupported_for_acp` |
|
|
6738
7390
|
| `POST /api/session/:id/model` | Set provider + model |
|
|
6739
7391
|
| `POST /api/session/:id/thinking-level` | Set thinking level |
|
|
6740
7392
|
| `POST /api/session/:id/attach-proposal` | Attach OpenSpec change |
|
|
@@ -7654,6 +8306,10 @@ See change: require-git-on-boot.
|
|
|
7654
8306
|
|
|
7655
8307
|
Package manager: **pnpm**, pinned to `pnpm@11.15.1` via root `package.json` `packageManager` field + `corepack enable`.
|
|
7656
8308
|
|
|
8309
|
+
- Node 25+ ships no `corepack`. Node 26 = required runtime/dev Node.
|
|
8310
|
+
- Docker: `ARG COREPACK_VERSION=0.36.0`; `npm install -g "corepack@${COREPACK_VERSION}"` then `corepack enable`.
|
|
8311
|
+
- Dev setup: `npm install -g corepack && corepack enable`.
|
|
8312
|
+
|
|
7657
8313
|
Scope: pnpm drives ALL dev, CI, Docker, and build work. `npm` survives ONLY in locations listed below.
|
|
7658
8314
|
|
|
7659
8315
|
Lockfile: Single committed lockfile = `pnpm-lock.yaml`. Old `package-lock.json` removed.
|
|
@@ -7990,6 +8646,52 @@ Caps (caps.ts): `maxActiveEmbedSessionsPerVisitor` + `maxActiveEmbedSessionsGlob
|
|
|
7990
8646
|
|
|
7991
8647
|
See change: add-embed-session-lifecycle.
|
|
7992
8648
|
|
|
8649
|
+
## Flow parent mailbox
|
|
8650
|
+
|
|
8651
|
+
pi-flows 0.11+ steps ask questions to a parent. Dashboard shows them in flow panel. Change: `adopt-flow-parent-mailbox`.
|
|
8652
|
+
|
|
8653
|
+
**Events (bridge → server → client).**
|
|
8654
|
+
- `flow:question` → `flow_question`. `stream`, keyed `stepId`.
|
|
8655
|
+
- `flow:answer` → `flow_answer`. `stream`, keyed `stepId`.
|
|
8656
|
+
- `flow:ask-session-result` → `flow_ask_session_result`. `live`.
|
|
8657
|
+
- Declared in `packages/flows-plugin/src/bridge/flow-event-forward.ts` (`FLOW_RUN_CHANNELS`).
|
|
8658
|
+
|
|
8659
|
+
**Reducer.**
|
|
8660
|
+
- `FlowState.questions` keyed by `question_id`.
|
|
8661
|
+
- First close wins (answer or cancel). Later closes ignored.
|
|
8662
|
+
- Run end closes leftover open questions as `cancel`.
|
|
8663
|
+
|
|
8664
|
+
**UI.**
|
|
8665
|
+
- Asking step node: purple, `?` marker.
|
|
8666
|
+
- Agent card: Question block. Button "Ask session".
|
|
8667
|
+
- Whole run waiting on a question → run-level waiting state.
|
|
8668
|
+
|
|
8669
|
+
**Ask session path.**
|
|
8670
|
+
```mermaid
|
|
8671
|
+
sequenceDiagram
|
|
8672
|
+
participant C as Client
|
|
8673
|
+
participant S as Server (flows plugin)
|
|
8674
|
+
participant B as Bridge
|
|
8675
|
+
participant F as pi-flows
|
|
8676
|
+
C->>S: plugin_action flow.ask-session {questionId, requestId?}
|
|
8677
|
+
S->>B: emit flow:ask-session {question_id, requestId?}
|
|
8678
|
+
B->>F: flow:ask-session
|
|
8679
|
+
F-->>B: flow:ask-session-result
|
|
8680
|
+
F->>F: post flow:ask follow-up into session
|
|
8681
|
+
```
|
|
8682
|
+
- Payload `questionId` 1-64 chars `[A-Za-z0-9_-]`; `requestId` same charset.
|
|
8683
|
+
- Repeat per (sessionId, questionId) within 30 s → throttled. REST 429 `{ code: "throttled" }`.
|
|
8684
|
+
- REST twin: `POST /api/plugins/flows/control { sessionId, action: "flow.ask-session", questionId, requestId? }`. Operate authority.
|
|
8685
|
+
|
|
8686
|
+
**Run attach.**
|
|
8687
|
+
- `flow.run` relays `notifyParent: true`. Dashboard-started runs attached; steps can ask parent session.
|
|
8688
|
+
- Automations stay detached.
|
|
8689
|
+
|
|
8690
|
+
**Removed.**
|
|
8691
|
+
- PromptBus `FlowQuestionAdapter`. Flow questions no longer enter PromptBus / chat stream.
|
|
8692
|
+
- AUTO (autonomous mode): pi-flows 0.12 dropped it. `flow.toggle-autonomous`, `/dashboard:flow-auto` gone.
|
|
8693
|
+
- `autonomousMode` key in `providers.json` preserved as unknown key (`dashboard-roles-ownership`).
|
|
8694
|
+
|
|
7993
8695
|
## Question stack (open prompts → one global list)
|
|
7994
8696
|
|
|
7995
8697
|
One list of every open PromptBus prompt the caller may see. Client: header pill, panel, dialog. Server: `question-store` keyed by `(sessionId, promptId)`. Change: add-pending-question-stack.
|
|
@@ -8191,6 +8893,33 @@ Result render emits leaf heading, not breadcrumb, plus `(+N more sections)`. Ful
|
|
|
8191
8893
|
|
|
8192
8894
|
Path-only fetch (`getChunk` without `headingPath`) returns first chunk plus `suppressedSections` count. Never a silent 1-of-N slice.
|
|
8193
8895
|
|
|
8896
|
+
- `kb_get` tool + `kb get` CLI share `resolveFetch` / `renderFetch` / `buildFetchRoots` (`packages/kb/src/fetch-resolve.ts`).
|
|
8897
|
+
- Roots = `store.listRoots()` (`SELECT DISTINCT root FROM chunks`). Remote git/https roots included.
|
|
8898
|
+
- NOT `resolvedSources[0]`. Old bug: ~88% sections unfetchable in 9-root KB (issue #1114).
|
|
8899
|
+
- Path readings:
|
|
8900
|
+
- literal in every root.
|
|
8901
|
+
- id-qualified `<source-id>:<path>`. Longest id wins. Ids with `:` round-trip.
|
|
8902
|
+
- dir-qualified `<relDir>/<path>`. `relDir` = `relative(cwd, dir)`, `/`-normalized, filesystem roots only.
|
|
8903
|
+
- Dedup by (root, path).
|
|
8904
|
+
- 1 reading → hit.
|
|
8905
|
+
- 0 → `(not found: <arg>)`. Unresolved path only.
|
|
8906
|
+
- >1 → `(ambiguous: <arg> is indexed in N sources — pass one of:)` + sorted `<source-id>:<path>` candidates. No body. Details `{found:false, candidates:N}`.
|
|
8907
|
+
- Section: `getChunkBySection(root, path, section)` (`packages/kb/src/sqlite-store.ts`).
|
|
8908
|
+
- Exact `heading_path` first.
|
|
8909
|
+
- Else (no ` > ` in arg) last-heading suffix match.
|
|
8910
|
+
- Several distinct heading paths → ambiguous section candidate list.
|
|
8911
|
+
- `getChunk` exact semantics unchanged.
|
|
8912
|
+
- No match in a resolved file → `section-missing` result. Render `(section not found: <section> in <arg> — sections:)` + ≤50 distinct body heading paths (rowid order, `:meta` chunk excluded) + `(+K more section[s])` when K > 0. Empty list → `(section not found: <section> in <arg> — no sections)`. `found:false`. Paths via required `FetchStore.getChunks(root, path)`. See change: fix-kb-parent-link-and-section-miss.
|
|
8913
|
+
- Source classification (`classifyRef`, `packages/kb/src/sources.ts`):
|
|
8914
|
+
- `ssh://` → `git`.
|
|
8915
|
+
- GitHub repo ref (`[https://]github.com/<o>/<r>` + optional `.git`, `@<ref>`, `/tree/<ref>`) → `git` (regex `GITHUB_REPO`). Cloned as `https://github.com/<o>/<r>` (`.git` kept if given). Revision from `@ref`/`/tree/<ref>`. `pin` wins. No auto-subdir.
|
|
8916
|
+
- Other `github.com/...` paths, raw, `/blob/`, `/archive/` → `https`.
|
|
8917
|
+
- https plain fetch: `assertIndexableBody` rejects HTML body or file name without configured extension (`ResolveCtx.extensions`, default `DEFAULTS.extensions`, case-insensitive). Runs before cache swap → old cache + `.fetched` marker survive.
|
|
8918
|
+
- Error names URL. `/blob/` → raw URL hint. Else `kind: "git"` hint.
|
|
8919
|
+
- Remote sources still index via `kb index` CLI only. Extension auto-reindex walks filesystem `resolvedSources`.
|
|
8920
|
+
|
|
8921
|
+
See change: fix-kb-get-roots-and-guard.
|
|
8922
|
+
|
|
8194
8923
|
#### DOX doctrine injection (`doctrine` config)
|
|
8195
8924
|
|
|
8196
8925
|
Config group `doctrine: { "inject": "kb" | "off", "write": boolean }`. Layered project `.pi/dashboard/knowledge_base.json` → global `~/.pi/dashboard/knowledge_base.json` → defaults. Deep-merged one level, same as `readDiscipline` / `ranking`. Defaults `{ inject: "kb", write: false }`. Validation: `inject` ∈ {`kb`,`off`}; `write` boolean.
|
|
@@ -8242,12 +8971,16 @@ Settings page `packages/kb-plugin/src/client/KbSettingsPanel.tsx`. Add via `KbSo
|
|
|
8242
8971
|
|
|
8243
8972
|
`reindexAll` (`packages/kb-plugin/src/server/kb-routes.ts`) walks `cfg.allSourceSpecs` — all kinds (filesystem/git/https/npm) via engine resolvers. Each source isolated: failure → `error` outcome, job `jobStatus:"error"`, `lastError` `"N source(s) failed: …"` (≤500 chars); untrusted → skipped, job stays idle; failed/skipped source keeps prior chunks. `git`/`https` resolution async (`execFile`, 120 s timeout) — never blocks server event loop. Reindex gate = saved `allSourceSpecs.length > 0`.
|
|
8244
8973
|
|
|
8974
|
+
Worker: job runs in `worker_threads` worker `reindex-worker.mjs` (`reindex-runner.ts`, core `reindex-core.ts`). Kill-switch `PI_DASHBOARD_KB_REINDEX_WORKER=0` → in-process. Read per job. Worker load failure before ready → in-process fallback. Crash after ready → job fails. Cancel → `cancel` msg, `terminate()` after `REINDEX_CANCEL_GRACE_MS` (5 s). Batch loop yields after `INDEX_BATCH_MAX_MS` (50 ms). One `[kb-plugin] reindex mode=worker|inprocess … outcome=…` log line per job.
|
|
8975
|
+
|
|
8245
8976
|
Trust = TOFU, global. Store `~/.pi/dashboard/kb-source-trust.json`, keyed sha256 of `{kind,ref,subdir,pin}`. One grant covers identical spec in every folder. Revoke under Access → `DELETE /api/kb/source-trust`. Grant path: UI trust dialog (`Trust & add` / `Add without trusting` / `Cancel`) → `PUT /api/kb/config` `trustRefs`, or `POST /api/kb/source-trust {ref}`. Server records SAVED spec matched by exact `ref` (404 none, 409 duplicate refs, 400 filesystem, 500 persist failure). `untrustedRefs` in PUT response lists grants that failed. Trust-store write atomic (`tmp`+rename); `recordTrust` returns boolean. Fetch-side SSRF/zip-slip guards from change `harden-untrusted-content-ingestion` (`net-guard.ts`, `archive-guard.ts`).
|
|
8246
8977
|
|
|
8247
8978
|
### KB source & search routes
|
|
8248
8979
|
|
|
8249
8980
|
- `GET /api/kb/sources?cwd=` — per-source kind, files, trusted, outside, last outcome.
|
|
8250
8981
|
- `GET /api/kb/search?cwd=&q=&limit=&docType=` — read-only test search over SAVED index. Opens existing store only — no init, no migrate, no create. `q` 1–512, `limit` 1–50 (default 10), `docType` `doc|agents|source-md`. No reindex, no verdicts. Stale schema → `needsReindex:true`.
|
|
8982
|
+
- `POST /api/kb/reindex/cancel?cwd=` — operator tier. Asks running job to stop. `200 {cancelled:true|false}`. Shares reindex admission. Job still `running` in `/stats` until settled. Repeat during grace → `cancelled:true`, no second stop.
|
|
8983
|
+
- `GET /api/kb/stats?cwd=` — adds transient `progress {root,done,total}` while running.
|
|
8251
8984
|
|
|
8252
8985
|
All cwd-guarded (`isAllowedCwd`).
|
|
8253
8986
|
|
|
@@ -8824,13 +9557,25 @@ flowchart LR
|
|
|
8824
9557
|
## Client sink hardening (Trusted Types, URL policy, navigation intents)
|
|
8825
9558
|
|
|
8826
9559
|
### Trusted Types mode
|
|
8827
|
-
-
|
|
8828
|
-
-
|
|
8829
|
-
-
|
|
9560
|
+
- Modes: `off|report|enforce`. Default `report`.
|
|
9561
|
+
- Resolution order: env `PI_DASHBOARD_TRUSTED_TYPES` → config `security.trustedTypes` (`~/.pi/dashboard/config.json`) → default.
|
|
9562
|
+
- Default → `off` iff `PI_DASHBOARD_CSP=off`, else `report`.
|
|
9563
|
+
- "Set" source = not `undefined` and not whitespace-only string. First set source decides.
|
|
9564
|
+
- Value trimmed + lowercased. `off|report|enforce` → itself.
|
|
9565
|
+
- Other set value (typo, number, object) → `report` + one startup warning naming source (`env`|`config`). Never logs raw value.
|
|
9566
|
+
- Every set source validated, incl. env shadowing valid config. Mirrors `hostGate.mode` no-lockout convention.
|
|
9567
|
+
- Resolver: `packages/shared/src/trusted-types-mode.ts` `resolveTrustedTypesMode({env,config,cspMode})` → `{mode,source,warnings}`; `recognizeTrustedTypesMode(raw)`.
|
|
9568
|
+
- `packages/server/src/auth/csp.ts` re-exports resolver. Old `(raw, cspMode)` signature removed.
|
|
8830
9569
|
- `registerCsp` appends `require-trusted-types-for 'script'` to baseline header when modes match. Else sets other header kind with directive alone.
|
|
8831
9570
|
- Add-if-absent per header kind. `/live/` skipped. `serveApp` mounts keep own enforcing policy.
|
|
8832
9571
|
- Server injects `<meta name="pi-trusted-types" content="<mode>">` into index.html (`lib/index-html.ts`).
|
|
8833
|
-
-
|
|
9572
|
+
- `server.ts` resolves once at startup (`loadConfig().security?.trustedTypes`). Logs each warning once (`[csp] Trusted Types: …`). Same mode → `registerCsp` + `createIndexHtmlSender`.
|
|
9573
|
+
- `createIndexHtmlSender` option `trustedTypesMode` required (no `report` fallback). Document meta always equals header mode.
|
|
9574
|
+
- Dev: `trustedTypesDevPlugin` in `packages/client/trusted-types-dev-plugin.ts` (imported by `packages/client/vite.config.ts`). Uses same shared resolver. Reads config file. States same mode as server.
|
|
9575
|
+
- Config API: `PUT /api/config` deep-merges `security`. `trustedTypes: null` deletes key (emptied `security` removed). Restart flagged only when normalized value changes.
|
|
9576
|
+
- `GET /api/config` adds computed, never-persisted `trustedTypesEnvOverride` (recognized env value or `null`). Stripped on write.
|
|
9577
|
+
- UI: Settings → Security → Trusted Types select (`TrustedTypesSection.tsx`): Default / Enforce / Report only / Off. Env override → read-only text `Set by PI_DASHBOARD_TRUSTED_TYPES: <mode>`. Change needs server restart.
|
|
9578
|
+
- Rollback / opt-in: config key, Settings, or env + restart.
|
|
8834
9579
|
- Missing meta → client treats as `report`.
|
|
8835
9580
|
|
|
8836
9581
|
### Client policies
|
|
@@ -8902,13 +9647,17 @@ Two policies, one sink, persisted counter. Default mode stays `report`; nothing
|
|
|
8902
9647
|
| any, Vite `--dev` (per proxied response) | baseline only (legacy `script-src`), enforcing under `enforce`. No strict header. No report destination. Dev never feeds strict counter. |
|
|
8903
9648
|
|
|
8904
9649
|
- Strict = baseline with `script-src 'self' 'nonce-<n>'`. No `'unsafe-inline'`, no `'unsafe-eval'`. Enforced only under explicit `enforce`.
|
|
8905
|
-
- Every emitted policy carries `report-uri /__pi/csp-report/<label>`
|
|
9650
|
+
- Every emitted policy carries `report-uri /__pi/csp-report/<label>` ONLY.
|
|
9651
|
+
- No `report-to` directive. No `Reporting-Endpoints` header. `cspReportEndpointName` removed from `csp-report-paths.ts`.
|
|
9652
|
+
- Live preview same (`buildLiveCsp`): `report-uri /live/<id>/~c/<token>/__pi/csp-report` only.
|
|
9653
|
+
- Why: Chromium 157 / Firefox 153 never delivered `report-to` + `Reporting-Endpoints` reports on plain http. `report-to` suppresses `report-uri` in Chromium. Prod counters stayed 0.
|
|
9654
|
+
- Residual: `report-uri` deprecated in CSP3. Tripwire = Chromium-only `tests/e2e/csp-report-delivery.spec.ts`. Safari / Firefox need a manual canary.
|
|
8906
9655
|
- Route-level per-response policies (`/api/file/raw` sandbox, `ctx.serveApp` mounts, `/live/`) untouched by mode.
|
|
8907
9656
|
- Release note: explicit `enforce` now enforces the STRICT policy (before: baseline). Existing `enforce` deployments see it.
|
|
8908
9657
|
|
|
8909
9658
|
### Trusted Types interaction
|
|
8910
9659
|
|
|
8911
|
-
- TT follows `PI_DASHBOARD_TRUSTED_TYPES
|
|
9660
|
+
- TT follows resolved mode (env `PI_DASHBOARD_TRUSTED_TYPES` → config `security.trustedTypes` → default), independent of CSP mode (see § Client sink hardening).
|
|
8912
9661
|
- Matching modes append `require-trusted-types-for 'script'`: `report` → baseline Report-Only header; `enforce` → strict enforcing header. Reports go to that header's label.
|
|
8913
9662
|
- Differing modes → other header kind carries TT directive alone, labelled `trusted-types` → `/__pi/csp-report/trusted-types`.
|
|
8914
9663
|
- TT violations count in `require-trusted-types-for` bucket. Never in strict `script-src*` measure.
|
|
@@ -8996,4 +9745,4 @@ Two policies, one sink, persisted counter. Default mode stays `report`; nothing
|
|
|
8996
9745
|
- Follow-up `enforce-strict-csp-default` owns soak + default flip. Exit gate: ≥ 14 d window, zero strict `script-src*` violations, `dropped == 0`, ≥ 1 release shipped, enforce-lane E2E green. Inspect directive / document breakdown before flip.
|
|
8997
9746
|
- E2E lanes: see `docs/faq.md` § "CSP enforce + OAuth real-gate E2E lanes".
|
|
8998
9747
|
|
|
8999
|
-
See change: harden-cors-and-csp-reporting (D8, D9, D10).
|
|
9748
|
+
See change: harden-cors-and-csp-reporting (D8, D9, D10), fix-csp-report-delivery.
|