@blackbelt-technology/pi-agent-dashboard 0.10.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 +4 -2
- package/README.md +64 -18
- package/docs/architecture.md +2325 -270
- package/package.json +36 -20
- package/packages/extension/package.json +18 -9
- package/packages/extension/src/bridge-context.ts +6 -0
- package/packages/extension/src/bridge-handlers/dispatch.ts +109 -70
- package/packages/extension/src/bridge-handlers/forwarders.ts +19 -42
- package/packages/extension/src/bridge-handlers/instance.ts +31 -13
- package/packages/extension/src/bridge-handlers/lifecycle.ts +149 -66
- package/packages/extension/src/bridge-shutdown.ts +44 -0
- package/packages/extension/src/bridge-ticket-client.ts +61 -7
- package/packages/extension/src/bridge-tls-checks.ts +79 -0
- package/packages/extension/src/bridge.ts +309 -284
- package/packages/extension/src/canvas-tool.ts +2 -0
- package/packages/extension/src/command-handler.ts +106 -37
- package/packages/extension/src/connect-target.ts +23 -0
- package/packages/extension/src/connection.ts +153 -38
- package/packages/extension/src/credential-guard.ts +300 -0
- package/packages/extension/src/custom-entry-forward.ts +27 -18
- package/packages/extension/src/dashboard-http-origin.ts +88 -0
- package/packages/extension/src/default-model-apply.ts +83 -0
- package/packages/extension/src/dev-build.ts +11 -1
- package/packages/extension/src/flow-event-wiring.ts +19 -95
- package/packages/extension/src/followup-drain.ts +19 -5
- package/packages/extension/src/git-link-builder.ts +11 -2
- package/packages/extension/src/inbound-limits.ts +138 -0
- package/packages/extension/src/local-token-header.ts +77 -6
- package/packages/extension/src/model-refresh.ts +69 -0
- 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/pinned-endpoint.ts +44 -0
- 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-live.ts +143 -0
- package/packages/extension/src/project-trust.ts +178 -30
- package/packages/extension/src/provider-model-cache.ts +118 -0
- package/packages/extension/src/provider-register.ts +487 -46
- package/packages/extension/src/remote-registration-gate.ts +21 -21
- package/packages/extension/src/remote-upgrade-preparer.ts +104 -0
- 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 +68 -10
- package/packages/extension/src/server-auto-start.ts +69 -3
- package/packages/extension/src/server-launcher.ts +26 -8
- package/packages/extension/src/server-proof-probe.ts +117 -0
- package/packages/extension/src/session-sync.ts +53 -24
- 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-delivery.ts +11 -1
- 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 +303 -64
- package/packages/server/src/access/access-health.ts +10 -0
- package/packages/server/src/access/access-plane.ts +12 -1
- package/packages/server/src/access/containment-gate.ts +113 -30
- package/packages/server/src/access/cwd-verdict.ts +3 -3
- 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-live.ts +244 -0
- package/packages/server/src/access/pi-trust-mirror-service.ts +50 -11
- package/packages/server/src/access/planes.ts +107 -1
- package/packages/server/src/access/preview-egress-store.ts +153 -0
- package/packages/server/src/access/prompt-channel.ts +5 -0
- package/packages/server/src/access/provisioning-wiring.ts +113 -0
- package/packages/server/src/access/provisioning.ts +763 -0
- package/packages/server/src/access/verified-read.ts +24 -7
- package/packages/server/src/access/yolo-session.ts +54 -2
- package/packages/server/src/acp-bridge/acp-session-adapter.ts +18 -5
- package/packages/server/src/acp-bridge/server-requests.ts +10 -4
- package/packages/server/src/agent-events/agent-event-hub.ts +158 -0
- package/packages/server/src/auth/audit-log.ts +108 -0
- package/packages/server/src/auth/auth-plugin.ts +230 -38
- package/packages/server/src/auth/auth.ts +104 -4
- package/packages/server/src/auth/bearer-auth.ts +52 -12
- package/packages/server/src/auth/bridge-ticket-eligibility.ts +53 -10
- package/packages/server/src/auth/cors-origin.ts +90 -30
- 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 +26 -0
- package/packages/server/src/auth/csp-report-sink.ts +302 -0
- package/packages/server/src/auth/csp-report-store.ts +406 -0
- package/packages/server/src/auth/csp.ts +145 -11
- package/packages/server/src/auth/dashboard-credential-store.ts +4 -0
- package/packages/server/src/auth/dashboard-state-caller.ts +29 -0
- 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/local-proof-refusal-log.ts +89 -0
- package/packages/server/src/auth/local-proof.ts +69 -18
- package/packages/server/src/auth/localhost-guard.ts +98 -33
- 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/nav-intent.ts +72 -0
- package/packages/server/src/auth/node-guard.ts +36 -49
- package/packages/server/src/auth/passkey/passkey-assets.ts +99 -0
- package/packages/server/src/auth/passkey/passkey-pages.ts +17 -81
- package/packages/server/src/auth/passkey/passkey-routes.ts +8 -0
- package/packages/server/src/auth/pi-legacy-credentials.ts +3 -0
- package/packages/server/src/auth/plugin-credential-store.ts +81 -10
- package/packages/server/src/auth/plugin-server-trust.ts +29 -0
- package/packages/server/src/auth/plugin-trust-store.ts +103 -0
- package/packages/server/src/auth/proven-tls.ts +45 -0
- package/packages/server/src/auth/provider-auth-storage.ts +214 -12
- 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/radius-mcp.ts +1 -1
- package/packages/server/src/auth/request-principal.ts +32 -0
- package/packages/server/src/auth/route-tier-gate.ts +3 -2
- package/packages/server/src/auth/secret-rotation.ts +246 -0
- package/packages/server/src/auth/secure-origin.ts +56 -0
- package/packages/server/src/auth/serve-app-host.ts +111 -11
- package/packages/server/src/auth/vertex-key-check.ts +140 -0
- package/packages/server/src/auth/ws-ticket.ts +40 -2
- package/packages/server/src/auth/ws-upgrade-reject-log.ts +4 -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 +34 -24
- package/packages/server/src/browser-handlers/folder-gate.ts +55 -0
- package/packages/server/src/browser-handlers/handler-context.ts +25 -2
- package/packages/server/src/browser-handlers/session-action-handler.ts +167 -63
- package/packages/server/src/browser-handlers/spawn-choice.ts +138 -1
- package/packages/server/src/browser-handlers/subscription-handler.ts +146 -3
- package/packages/server/src/browser-handlers/terminal-handler.ts +108 -10
- package/packages/server/src/build-plugin-send-prompt.ts +18 -0
- package/packages/server/src/canvas/canvas-accumulator.ts +35 -7
- package/packages/server/src/cli/credentials-command.ts +555 -0
- package/packages/server/src/cli.ts +229 -53
- package/packages/server/src/config-api.ts +53 -35
- package/packages/server/src/config-snapshot.ts +197 -1
- package/packages/server/src/directory-service.ts +193 -68
- package/packages/server/src/embed-lifecycle/idle-reaper.ts +13 -3
- package/packages/server/src/event-wiring.ts +322 -207
- package/packages/server/src/git-worktree/ensure-worktree.ts +185 -0
- package/packages/server/src/git-worktree/git-operations.ts +45 -11
- package/packages/server/src/git-worktree/redact-git-text.ts +124 -0
- package/packages/server/src/git-worktree/ref-arg.ts +39 -0
- 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-trust.ts +43 -1
- package/packages/server/src/git-worktree/worktree-init.ts +5 -1
- package/packages/server/src/identity/http-road-classification.ts +18 -2
- package/packages/server/src/identity/identity-floor.ts +5 -2
- package/packages/server/src/identity/ws-message-scope.ts +11 -3
- package/packages/server/src/identity/ws-road-classification.ts +3 -1
- package/packages/server/src/known-server-moves.ts +36 -15
- package/packages/server/src/lib/browse-roots.ts +129 -17
- package/packages/server/src/lib/client-dist.ts +36 -21
- package/packages/server/src/lib/content-disposition.ts +20 -0
- package/packages/server/src/lib/dashboard-state-guard.ts +513 -0
- package/packages/server/src/lib/diagram-render.ts +4 -6
- package/packages/server/src/lib/eml.ts +5 -10
- package/packages/server/src/lib/file-cwd-admission.ts +145 -0
- 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-worker.ts +23 -0
- package/packages/server/src/lib/grep.ts +96 -7
- package/packages/server/src/lib/index-html.ts +81 -0
- package/packages/server/src/lib/mention-fuzzy-index.ts +263 -0
- package/packages/server/src/lib/office-preview.ts +49 -13
- package/packages/server/src/lib/path-containment.ts +50 -10
- package/packages/server/src/lib/resolve-file-mention.ts +234 -40
- package/packages/server/src/lib/resolve-mentions-batch.ts +143 -0
- package/packages/server/src/lib/route-admission.ts +80 -0
- package/packages/server/src/lib/writable-handler-target.ts +4 -0
- package/packages/server/src/lib/writable-md-target.ts +26 -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/lifecycle/recovery-server.ts +65 -18
- package/packages/server/src/live-server/capability-redact.ts +31 -0
- package/packages/server/src/live-server/live-browser-gate.ts +22 -0
- package/packages/server/src/live-server/live-capability.ts +615 -44
- package/packages/server/src/live-server/live-csp-report.ts +63 -0
- package/packages/server/src/live-server/live-csp.ts +141 -0
- package/packages/server/src/live-server/live-egress.ts +435 -0
- package/packages/server/src/live-server/live-exposure.ts +149 -0
- package/packages/server/src/live-server/live-log.ts +25 -0
- package/packages/server/src/live-server/live-origin-scan.ts +298 -0
- package/packages/server/src/live-server/live-server-manager.ts +220 -33
- package/packages/server/src/live-server/live-server-proxy.ts +411 -50
- package/packages/server/src/live-server/live-static.ts +231 -0
- 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/dependencies-file.ts +122 -0
- package/packages/server/src/openspec/openspec-change-watcher.ts +3 -1
- package/packages/server/src/openspec/openspec-dependency-inputs.ts +281 -0
- package/packages/server/src/openspec/openspec-poll-fs-helpers.ts +72 -26
- package/packages/server/src/openspec/openspec-poll-worker-pool.ts +48 -12
- package/packages/server/src/openspec/openspec-poll-worker.ts +95 -9
- package/packages/server/src/openspec/readiness.ts +1 -1
- package/packages/server/src/openspec/workflow-schema-status.ts +379 -0
- package/packages/server/src/openspec/workflow-schema.ts +141 -267
- package/packages/server/src/package/npm-search-proxy.ts +5 -2
- package/packages/server/src/package/provider-probe.ts +202 -7
- package/packages/server/src/pairing/browser-gateway.ts +325 -51
- package/packages/server/src/pairing/device-key-intake.ts +120 -0
- package/packages/server/src/pairing/device-token-services.ts +26 -0
- package/packages/server/src/pairing/paired-devices.ts +702 -27
- package/packages/server/src/pairing/pairing.ts +103 -11
- package/packages/server/src/pairing/{subagent-resync-routing.ts → resync-requester-registry.ts} +6 -10
- package/packages/server/src/pairing/socket-locality.ts +26 -0
- 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 +61 -2
- package/packages/server/src/pi/bridge-channel.ts +33 -0
- package/packages/server/src/pi/bridge-contention.ts +84 -2
- package/packages/server/src/pi/bridge-upgrade-auth.ts +18 -3
- package/packages/server/src/pi/gateway-listeners.ts +9 -3
- package/packages/server/src/pi/host-project-trust.ts +29 -15
- package/packages/server/src/pi/pi-gateway.ts +398 -41
- package/packages/server/src/pi/provisional-registration.ts +4 -1
- package/packages/server/src/pi/resource-toggle-trust.ts +18 -7
- 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-discovery-wiring.ts +142 -0
- package/packages/server/src/plugin-entry-stats.ts +61 -0
- package/packages/server/src/plugin-event-seam.ts +116 -4
- 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/plugin-runtime-clients.ts +89 -0
- 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 +182 -15
- package/packages/server/src/routes/acme-routes.ts +14 -4
- package/packages/server/src/routes/agent-event-stream-routes.ts +137 -0
- package/packages/server/src/routes/canvas-types-routes.ts +20 -6
- package/packages/server/src/routes/csp-violations-routes.ts +162 -0
- package/packages/server/src/routes/file-routes.ts +640 -279
- package/packages/server/src/routes/file-write-binary-routes.ts +97 -24
- package/packages/server/src/routes/folder-project-routes.ts +18 -12
- package/packages/server/src/routes/frame-policy-routes.ts +215 -0
- package/packages/server/src/routes/git-routes.ts +340 -273
- package/packages/server/src/routes/grep-routes.ts +64 -14
- package/packages/server/src/routes/known-servers-routes.ts +189 -91
- package/packages/server/src/routes/live-server-routes.ts +572 -15
- package/packages/server/src/routes/local-proof-routes.ts +14 -0
- package/packages/server/src/routes/models-introspection-routes.ts +1 -1
- package/packages/server/src/routes/nav-intent-routes.ts +46 -0
- package/packages/server/src/routes/openspec-group-routes.ts +53 -44
- package/packages/server/src/routes/openspec-routes.ts +396 -31
- package/packages/server/src/routes/package-routes.ts +58 -10
- package/packages/server/src/routes/pairing-routes.ts +342 -17
- package/packages/server/src/routes/pi-settings-routes.ts +2 -0
- package/packages/server/src/routes/pi-trust-query-routes.ts +330 -0
- package/packages/server/src/routes/plugin-activation-routes.ts +59 -0
- package/packages/server/src/routes/plugin-runtime-client-routes.ts +149 -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 +181 -10
- 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/resource-activation-routes.ts +18 -4
- package/packages/server/src/routes/session-routes.ts +75 -25
- package/packages/server/src/routes/system-routes.ts +169 -52
- package/packages/server/src/routes/ui-link-base.ts +88 -0
- 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-io.ts +2 -9
- package/packages/server/src/runtime-overlay/runtime-stager.ts +4 -2
- package/packages/server/src/server.ts +1139 -291
- 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/hydration-state.ts +148 -0
- package/packages/server/src/session/memory-session-manager.ts +31 -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/replay-exit-controller.ts +221 -0
- package/packages/server/src/session/retained-transcript.ts +9 -2
- 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 +32 -4
- 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 +393 -77
- 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/terminal/terminal-manager.ts +54 -46
- 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/tls/tls-bridge-route.ts +61 -0
- package/packages/server/src/tls/tls-config-validation.ts +2 -0
- package/packages/server/src/vault/device-expiry-sweep.ts +36 -0
- package/packages/server/src/vault/vault-delivery-hub.ts +172 -26
- package/packages/server/src/vault/vault-routes.ts +9 -2
- package/packages/server/src/vault/vault-store.ts +87 -24
- package/packages/server/src/watch-files-handler.ts +66 -0
- 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 +285 -59
- package/packages/shared/src/canvas-declare.ts +27 -0
- package/packages/shared/src/canvas-detect.ts +1 -1
- package/packages/shared/src/canvas-types.ts +2 -2
- package/packages/shared/src/config.ts +443 -187
- package/packages/shared/src/containment-guard.ts +45 -0
- 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/event-type-owners.ts +50 -0
- package/packages/shared/src/dashboard-plugin/file-handler.ts +2 -0
- package/packages/shared/src/dashboard-plugin/host-api.ts +61 -0
- package/packages/shared/src/dashboard-plugin/host-fx-classes.ts +23 -0
- package/packages/shared/src/dashboard-plugin/host-import-map.ts +38 -0
- package/packages/shared/src/dashboard-plugin/index.ts +2 -0
- package/packages/shared/src/dashboard-plugin/manifest-types.ts +100 -1
- package/packages/shared/src/dashboard-plugin/plugin-status.ts +58 -3
- package/packages/shared/src/dashboard-plugin/replay-entry-types.ts +46 -0
- package/packages/shared/src/dashboard-plugin/slot-props.ts +47 -3
- package/packages/shared/src/dashboard-plugin/slot-types.ts +9 -1
- package/packages/shared/src/dashboard-plugin/ui-primitives.ts +39 -3
- package/packages/shared/src/device-key-proof.ts +309 -0
- package/packages/shared/src/display-prefs.ts +13 -0
- package/packages/shared/src/doctor-core.ts +94 -27
- 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 +161 -0
- package/packages/shared/src/local-proof-signal.ts +16 -0
- package/packages/shared/src/loopback-host.ts +26 -0
- package/packages/shared/src/mcp/verb-tiers.generated.ts +176 -0
- package/packages/shared/src/mdns-discovery.ts +25 -6
- package/packages/shared/src/models-json-reader.ts +41 -0
- package/packages/shared/src/nav-intent.ts +29 -0
- package/packages/shared/src/network-denial-signal.ts +15 -0
- package/packages/shared/src/node-version.ts +63 -60
- package/packages/shared/src/openspec-dependencies.ts +760 -0
- package/packages/shared/src/openspec-poller.ts +3 -2
- package/packages/shared/src/pairing-knock-client.ts +135 -11
- 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-live-query.ts +93 -0
- package/packages/shared/src/pi-trust-mirror-snapshot.ts +21 -11
- package/packages/shared/src/pi-trust-mirror-types.ts +38 -3
- package/packages/shared/src/pi-trust-mirror.ts +47 -11
- package/packages/shared/src/pi-trust-resource-digest.ts +261 -0
- package/packages/shared/src/pid-namespace.ts +86 -0
- package/packages/shared/src/platform/ensure-bundled-git.ts +57 -34
- package/packages/shared/src/platform/git-source.ts +88 -26
- package/packages/shared/src/platform/git.ts +14 -8
- package/packages/shared/src/platform/native-ts-register.mjs +1 -1
- package/packages/shared/src/platform/process.ts +452 -5
- package/packages/shared/src/platform/resolve-pi-shell.ts +105 -0
- package/packages/shared/src/platform/select-git-source.ts +7 -0
- package/packages/shared/src/platform/spawn-runtime.ts +193 -7
- package/packages/shared/src/plugin-route-cwd.ts +95 -0
- package/packages/shared/src/preview-egress.ts +192 -0
- package/packages/shared/src/preview-origins.ts +398 -0
- package/packages/shared/src/project-root.ts +16 -0
- package/packages/shared/src/prompt-answer.ts +9 -5
- package/packages/shared/src/protocol.ts +187 -86
- 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 +97 -26
- package/packages/shared/src/recovery-timing.ts +27 -0
- package/packages/shared/src/remote-credentials.ts +63 -0
- package/packages/shared/src/renderer-by-ext.ts +5 -2
- package/packages/shared/src/rest-api.ts +148 -11
- package/packages/shared/src/role-schema.ts +24 -0
- package/packages/shared/src/route-tiers.ts +149 -4
- package/packages/shared/src/runtime-overlay/archive-safety.d.mts +2 -0
- package/packages/shared/src/runtime-overlay/archive-safety.mjs +33 -0
- package/packages/shared/src/runtime-overlay/compat.ts +70 -6
- package/packages/shared/src/runtime-overlay/manifest.d.mts +7 -0
- package/packages/shared/src/runtime-overlay/manifest.mjs +22 -2
- package/packages/shared/src/safe-local-path.ts +24 -0
- package/packages/shared/src/sanitize-profiles.ts +98 -0
- package/packages/shared/src/secret-patterns.ts +49 -0
- package/packages/shared/src/server-launcher.ts +9 -1
- package/packages/shared/src/server-pinning.ts +55 -2
- package/packages/shared/src/server-routes.ts +462 -0
- package/packages/shared/src/session-ui-path.ts +11 -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/tls-only-token.ts +16 -0
- package/packages/shared/src/tool-path-resolve.ts +16 -1
- package/packages/shared/src/tool-registry/definitions.ts +5 -5
- package/packages/shared/src/tool-registry/strategies.ts +13 -12
- 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 +134 -109
- package/packages/shared/src/url-policy.ts +96 -0
- package/packages/shared/src/vault-delivery.ts +15 -0
- package/packages/shared/src/vertex-regions.ts +81 -0
- package/packages/shared/src/ws-message-tiers.ts +11 -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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Link a registering session to its headless spawn entry: token → pid →
|
|
3
|
+
* cwd-FIFO, gated by the register's pid target (resolved WITHOUT own-entry
|
|
4
|
+
* evidence, so linking is never circular — design D2 "link time").
|
|
5
|
+
*
|
|
6
|
+
* - `host`: all three tiers, as before.
|
|
7
|
+
* - `unknown`: pid tier only for an entry in the register's own cwd; cwd-FIFO allowed.
|
|
8
|
+
* - non-local (`wsl`, `legacy-wsl`, `foreign`): token tier only — a pid number
|
|
9
|
+
* from another namespace must never claim a local spawn, nor may cwd order.
|
|
10
|
+
*
|
|
11
|
+
* See change: scope-pids-to-namespace (D3, task 4.6).
|
|
12
|
+
*/
|
|
13
|
+
import { isNonLocalTarget, type PidTarget } from "../session/pid-target.js";
|
|
14
|
+
import type { HeadlessPidRegistry } from "./headless-pid-registry.js";
|
|
15
|
+
|
|
16
|
+
export interface LinkRegisterInput {
|
|
17
|
+
sessionId: string;
|
|
18
|
+
spawnToken?: string;
|
|
19
|
+
pid?: number;
|
|
20
|
+
cwd: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type LinkTier = "token" | "pid" | "cwd" | "none";
|
|
24
|
+
|
|
25
|
+
export function linkRegisterToSpawn(
|
|
26
|
+
registry: Pick<HeadlessPidRegistry, "linkByToken" | "linkByPid" | "linkSession">,
|
|
27
|
+
input: LinkRegisterInput,
|
|
28
|
+
target: PidTarget | undefined,
|
|
29
|
+
log: (line: string) => void = (l) => console.error(l),
|
|
30
|
+
): LinkTier {
|
|
31
|
+
const { sessionId, spawnToken, pid, cwd } = input;
|
|
32
|
+
if (spawnToken && registry.linkByToken(spawnToken, sessionId, pid)) return "token";
|
|
33
|
+
if (target && isNonLocalTarget(target)) return "none";
|
|
34
|
+
if (pid !== undefined) {
|
|
35
|
+
const opts = target?.kind === "unknown" ? { cwd } : undefined;
|
|
36
|
+
if (registry.linkByPid(sessionId, pid, opts)) return "pid";
|
|
37
|
+
}
|
|
38
|
+
if (spawnToken || pid !== undefined) {
|
|
39
|
+
log(`[event-wiring] cwd-FIFO fallback for session ${sessionId} — token=${spawnToken ?? ""} pid=${pid ?? ""} cwd=${cwd}`);
|
|
40
|
+
}
|
|
41
|
+
return registry.linkSession(sessionId, cwd) ? "cwd" : "none";
|
|
42
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin `spawnSession` hook: map plugin options to session options and apply
|
|
3
|
+
* the spawn-time model choice. Literal models keep the mapper's verbatim
|
|
4
|
+
* pass-through (trusted first-party callers); only `@role` refs resolve, via the
|
|
5
|
+
* shared resolver, and a thinking-only choice pairs with the default model.
|
|
6
|
+
* Drops are reported in `warning` (lenient road). Never throws. A role-ref
|
|
7
|
+
* default is resolved for the thinking-only pairing
|
|
8
|
+
* (See change: default-model-follows-role).
|
|
9
|
+
*
|
|
10
|
+
* See change: add-spawn-model-choice (design D1, D2).
|
|
11
|
+
*/
|
|
12
|
+
import { type MappedSpawnOptions, type PluginSpawnOptions, pluginSpawnToSessionOptions } from "@blackbelt-technology/dashboard-plugin-runtime/server";
|
|
13
|
+
import { THINKING_LEVELS } from "@blackbelt-technology/pi-dashboard-shared/role-schema.js";
|
|
14
|
+
import { pairDefaultModel, type ResolveSpawnChoiceContext, resolveSpawnChoice } from "../browser-handlers/spawn-choice.js";
|
|
15
|
+
|
|
16
|
+
export interface PluginSpawnMapping {
|
|
17
|
+
options: MappedSpawnOptions;
|
|
18
|
+
warning?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function mapPluginSpawnOptions(opts: PluginSpawnOptions, ctx: ResolveSpawnChoiceContext = {}): PluginSpawnMapping {
|
|
22
|
+
const options = pluginSpawnToSessionOptions(opts);
|
|
23
|
+
const warnings: string[] = [];
|
|
24
|
+
const level = (opts as { thinkingLevel?: unknown }).thinkingLevel;
|
|
25
|
+
const hasLevel = level !== undefined && level !== null && level !== "";
|
|
26
|
+
if (hasLevel && !(typeof level === "string" && (THINKING_LEVELS as readonly string[]).includes(level))) {
|
|
27
|
+
console.warn("[plugin-hook] ignoring invalid thinkingLevel");
|
|
28
|
+
warnings.push("invalid thinkingLevel ignored");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const model = (opts as { model?: unknown }).model;
|
|
32
|
+
if (typeof model === "string" && model.trim().startsWith("@")) {
|
|
33
|
+
const { choice, warnings: w } = resolveSpawnChoice(
|
|
34
|
+
{ model, ...(hasLevel ? { thinkingLevel: level } : {}) },
|
|
35
|
+
ctx,
|
|
36
|
+
);
|
|
37
|
+
// The resolver already reported an invalid level; keep one warning per drop.
|
|
38
|
+
warnings.push(...w.filter((x) => !warnings.includes(x)));
|
|
39
|
+
delete options.model;
|
|
40
|
+
delete options.thinking;
|
|
41
|
+
if (choice.model) options.model = choice.model;
|
|
42
|
+
if (choice.thinking) options.thinking = choice.thinking;
|
|
43
|
+
} else if (options.thinking && !options.model && ctx.defaultModel) {
|
|
44
|
+
const paired = pairDefaultModel(ctx.defaultModel, options.thinking, ctx);
|
|
45
|
+
if (paired) options.model = paired;
|
|
46
|
+
}
|
|
47
|
+
return warnings.length > 0 ? { options, warning: warnings.join("; ") } : { options };
|
|
48
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin `spawnSession` hook, with the optional `worktree` block.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `server.ts` so the whole flow can be driven with injected deps:
|
|
5
|
+
* trust gate → option validation → (worktree) create-or-reuse + init → file the
|
|
6
|
+
* plugin ref / queue the prompt and attach intents → spawn → watchdog / PID
|
|
7
|
+
* registry → rollback on failure. A spawn with a `worktree` block re-keys every
|
|
8
|
+
* cwd-keyed step onto the worktree path; a failure before the spawn leaves no
|
|
9
|
+
* queued intent and NEVER falls back to `cwd`. A bare `mode: "worktree"` (no
|
|
10
|
+
* block) keeps the documented local fallback.
|
|
11
|
+
*
|
|
12
|
+
* See change: add-plugin-spawn-worktree (design D2, D5, D6, D7).
|
|
13
|
+
*/
|
|
14
|
+
import type {
|
|
15
|
+
PluginSessionLifecycle,
|
|
16
|
+
PluginSpawnOptions,
|
|
17
|
+
PluginSpawnResult,
|
|
18
|
+
PluginSpawnWorktreeCode,
|
|
19
|
+
} from "@blackbelt-technology/dashboard-plugin-runtime/server";
|
|
20
|
+
import type { EnsureWorktreeOptions, EnsureWorktreeResult } from "../git-worktree/ensure-worktree.js";
|
|
21
|
+
import type { StartWorktreeInitOptions, StartWorktreeInitResult } from "../git-worktree/start-worktree-init.js";
|
|
22
|
+
import { mapPluginSpawnOptions } from "./plugin-spawn-choice.js";
|
|
23
|
+
|
|
24
|
+
/** The slice of a `spawnPiSession` / `spawnAcpSession` result the hook reads. */
|
|
25
|
+
interface PluginSpawnProcessResult {
|
|
26
|
+
success: boolean;
|
|
27
|
+
message?: string;
|
|
28
|
+
spawnToken?: string;
|
|
29
|
+
pid?: number;
|
|
30
|
+
process?: unknown;
|
|
31
|
+
logPath?: string;
|
|
32
|
+
keeperSockPath?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface PluginSpawnHookDeps {
|
|
36
|
+
plugin: { id: string; priority?: number };
|
|
37
|
+
defaultModel: () => string | undefined;
|
|
38
|
+
mintSpawnToken: () => string;
|
|
39
|
+
validateAcp: (opts: PluginSpawnOptions) => string | null | undefined;
|
|
40
|
+
pendingPluginRefRegistry: {
|
|
41
|
+
has(token: string): boolean;
|
|
42
|
+
file(token: string, ref: unknown, ownerId: string, lifecycle?: PluginSessionLifecycle): unknown;
|
|
43
|
+
remove(token: string): unknown;
|
|
44
|
+
};
|
|
45
|
+
pendingInitialPromptRegistry: { enqueue(cwd: string, prompt: string): unknown; withdraw(cwd: string, prompt: string): unknown };
|
|
46
|
+
pendingAttachRegistry: { enqueue(cwd: string, changeName: string): boolean; withdraw(cwd: string, changeName: string): unknown };
|
|
47
|
+
spawnPi: (cwd: string, opts: Record<string, unknown>) => Promise<PluginSpawnProcessResult>;
|
|
48
|
+
spawnAcp: (cwd: string, opts: { agent: string; spawnToken: string }) => Promise<PluginSpawnProcessResult>;
|
|
49
|
+
armWatchdog: (cwd: string, result: PluginSpawnProcessResult) => void;
|
|
50
|
+
registerHeadlessPid: (pid: number, cwd: string, child: unknown, spawnToken: string, result: PluginSpawnProcessResult) => void;
|
|
51
|
+
/** Create-or-reuse; the wiring supplies known-folder admission. */
|
|
52
|
+
ensureWorktree: (opts: Pick<EnsureWorktreeOptions, "cwd" | "branch" | "base" | "ifExists" | "checkTarget">) => Promise<EnsureWorktreeResult>;
|
|
53
|
+
/** Host cwd-policy floor for a path; compared (not interpreted) between the target and the spawn cwd. */
|
|
54
|
+
resolveCwdPolicy: (cwd: string) => unknown;
|
|
55
|
+
/** The `autoInitWorktreeOnSpawn` preference. */
|
|
56
|
+
autoInitEnabled: () => boolean;
|
|
57
|
+
startWorktreeInit: (cwd: string, opts: StartWorktreeInitOptions) => Promise<StartWorktreeInitResult>;
|
|
58
|
+
/** Wait for a run another trigger started; defaults to "proceed". */
|
|
59
|
+
awaitInitRun?: (cwd: string) => Promise<"done" | "failed" | "timeout">;
|
|
60
|
+
/** True once server shutdown has started; a launch that would outlive the shutdown sweeps is refused. */
|
|
61
|
+
isStopping?: () => boolean;
|
|
62
|
+
log?: (line: string) => void;
|
|
63
|
+
warn?: (line: string) => void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const CHANGE_NAME = /^[a-z0-9][a-z0-9-]{0,99}$/;
|
|
67
|
+
|
|
68
|
+
interface WorktreeBlock {
|
|
69
|
+
branch: string;
|
|
70
|
+
base?: string;
|
|
71
|
+
ifExists: "reuse" | "fail";
|
|
72
|
+
attachChange?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Shape check of the untrusted `worktree` value (design D3); returns the block or a reason. */
|
|
76
|
+
function parseWorktreeBlock(value: unknown): { block: WorktreeBlock } | { reason: string } {
|
|
77
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return { reason: "worktree must be an object" };
|
|
78
|
+
const v = value as Record<string, unknown>;
|
|
79
|
+
if (typeof v.branch !== "string" || v.branch.length === 0) return { reason: "worktree.branch must be a non-empty string" };
|
|
80
|
+
if (v.ifExists !== "reuse" && v.ifExists !== "fail") return { reason: 'worktree.ifExists must be "reuse" or "fail"' };
|
|
81
|
+
if (v.base !== undefined && typeof v.base !== "string") return { reason: "worktree.base must be a string" };
|
|
82
|
+
if (v.attachChange !== undefined && (typeof v.attachChange !== "string" || !CHANGE_NAME.test(v.attachChange))) {
|
|
83
|
+
return { reason: "worktree.attachChange must be a kebab-case change name" };
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
block: {
|
|
87
|
+
branch: v.branch,
|
|
88
|
+
ifExists: v.ifExists,
|
|
89
|
+
...(v.base !== undefined ? { base: v.base as string } : {}),
|
|
90
|
+
...(v.attachChange !== undefined ? { attachChange: v.attachChange as string } : {}),
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Key-order-insensitive JSON, so two equal floors compare equal however they were merged. */
|
|
96
|
+
function stable(value: unknown): string {
|
|
97
|
+
return JSON.stringify(value, (_k, v) =>
|
|
98
|
+
v && typeof v === "object" && !Array.isArray(v)
|
|
99
|
+
? Object.fromEntries(Object.entries(v as Record<string, unknown>).sort(([a], [b]) => (a < b ? -1 : 1)))
|
|
100
|
+
: v,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const fail = (code: PluginSpawnWorktreeCode, message: string): PluginSpawnResult => ({ success: false, code, message });
|
|
105
|
+
|
|
106
|
+
interface PreparedWorktree {
|
|
107
|
+
path: string;
|
|
108
|
+
branch: string;
|
|
109
|
+
created: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Create-or-reuse the worktree, then run its init when auto-init is on (design D6). Runs BEFORE
|
|
114
|
+
* anything is filed or queued, so a failure leaves no intent. An untrusted hook is never run.
|
|
115
|
+
*/
|
|
116
|
+
async function prepareWorktree(
|
|
117
|
+
deps: PluginSpawnHookDeps,
|
|
118
|
+
opts: PluginSpawnOptions,
|
|
119
|
+
block: WorktreeBlock,
|
|
120
|
+
log: (line: string) => void,
|
|
121
|
+
): Promise<{ worktree: PreparedWorktree } | { failure: PluginSpawnResult }> {
|
|
122
|
+
const logLine = (state: string, code?: string) =>
|
|
123
|
+
log(`[plugin-spawn] worktree ${state} plugin=${deps.plugin.id} branch=${JSON.stringify(block.branch)}${code ? ` code=${code}` : ""}`);
|
|
124
|
+
const ensured = await deps.ensureWorktree({
|
|
125
|
+
cwd: opts.cwd,
|
|
126
|
+
branch: block.branch,
|
|
127
|
+
...(block.base !== undefined ? { base: block.base } : {}),
|
|
128
|
+
ifExists: block.ifExists,
|
|
129
|
+
checkTarget: (target) => stable(deps.resolveCwdPolicy(target)) === stable(deps.resolveCwdPolicy(opts.cwd)),
|
|
130
|
+
});
|
|
131
|
+
if (!ensured.ok) {
|
|
132
|
+
logLine("failed", ensured.code);
|
|
133
|
+
return { failure: fail(ensured.code, ensured.message) };
|
|
134
|
+
}
|
|
135
|
+
const initFailure = deps.autoInitEnabled() ? await runInit(deps, ensured.path) : undefined;
|
|
136
|
+
if (initFailure !== undefined) {
|
|
137
|
+
logLine("failed", "init_failed");
|
|
138
|
+
return { failure: fail("init_failed", initFailure) };
|
|
139
|
+
}
|
|
140
|
+
logLine(ensured.created ? "created" : "reused");
|
|
141
|
+
return { worktree: { path: ensured.path, branch: ensured.branch, created: ensured.created } };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Start (and await) the worktree init; returns a failure message, or undefined when the spawn may proceed. */
|
|
145
|
+
async function runInit(deps: PluginSpawnHookDeps, cwd: string): Promise<string | undefined> {
|
|
146
|
+
try {
|
|
147
|
+
const started = await deps.startWorktreeInit(cwd, { skipIfRunning: true });
|
|
148
|
+
if (started.status === "failed") return started.hint;
|
|
149
|
+
if (started.status === "already_running") {
|
|
150
|
+
const phase = (await deps.awaitInitRun?.(cwd)) ?? "done";
|
|
151
|
+
if (phase === "timeout") return "worktree init is still running";
|
|
152
|
+
if (phase === "failed") return "worktree init failed";
|
|
153
|
+
}
|
|
154
|
+
// `untrusted` is never run: the spawn proceeds and init stays pending, as for a dialog spawn.
|
|
155
|
+
return undefined;
|
|
156
|
+
} catch (err) {
|
|
157
|
+
return err instanceof Error ? err.message : String(err);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Root-option checks that run before anything else; a result means "refuse". */
|
|
162
|
+
function rejectBadOptions(deps: PluginSpawnHookDeps, opts: PluginSpawnOptions): PluginSpawnResult | undefined {
|
|
163
|
+
if ((deps.plugin.priority ?? 1000) > 100) {
|
|
164
|
+
return { success: false, message: `spawn not permitted for plugin "${deps.plugin.id}"` };
|
|
165
|
+
}
|
|
166
|
+
// Validate the untrusted root options object BEFORE mapping or dereferencing `opts.pluginRef`/`opts.cwd`.
|
|
167
|
+
// A JS plugin can call `spawnSession(null)` or omit `cwd`; reject both with a structured result.
|
|
168
|
+
if (typeof opts !== "object" || opts === null) return { success: false, message: "spawn options must be an object" };
|
|
169
|
+
if (typeof opts.cwd !== "string" || opts.cwd.length === 0) {
|
|
170
|
+
return { success: false, message: "spawn options require a non-empty cwd" };
|
|
171
|
+
}
|
|
172
|
+
// ACP agent spawn: validate BEFORE anything is filed or spawned. See change: add-acp-session-driver (D14).
|
|
173
|
+
const acpRejection = deps.validateAcp(opts);
|
|
174
|
+
return acpRejection ? { success: false, message: acpRejection } : undefined;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Honour a caller-supplied spawn token VERBATIM (trusted-only). A token already pending for ANY owner is
|
|
179
|
+
* rejected via the non-destructive `has()` probe. Otherwise mint up front so the ownership ref is filed
|
|
180
|
+
* against it BEFORE the spawn await. See change: detach-automation-goal-from-core.
|
|
181
|
+
*/
|
|
182
|
+
function resolveSpawnToken(deps: PluginSpawnHookDeps, opts: PluginSpawnOptions): { token: string } | { failure: PluginSpawnResult } {
|
|
183
|
+
const requested = typeof opts.spawnToken === "string" ? opts.spawnToken : "";
|
|
184
|
+
if (requested?.includes("\0")) return { failure: { success: false, message: "spawnToken must not contain NUL" } };
|
|
185
|
+
const token = requested || deps.mintSpawnToken();
|
|
186
|
+
if (requested && deps.pendingPluginRefRegistry.has(token)) {
|
|
187
|
+
return { failure: { success: false, message: `spawnToken "${token}" is already pending for another spawn` } };
|
|
188
|
+
}
|
|
189
|
+
return { token };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Build the `spawnSession` hook of one plugin context. */
|
|
193
|
+
export function createPluginSpawnHook(deps: PluginSpawnHookDeps): (opts: PluginSpawnOptions) => Promise<PluginSpawnResult> {
|
|
194
|
+
const log = deps.log ?? ((l: string) => console.log(l));
|
|
195
|
+
const warn = deps.warn ?? ((l: string) => console.warn(l));
|
|
196
|
+
|
|
197
|
+
return async (opts) => {
|
|
198
|
+
const rejected = rejectBadOptions(deps, opts);
|
|
199
|
+
if (rejected) return rejected;
|
|
200
|
+
// Worktree block (design D2/D3): honoured only together with `mode: "worktree"`. A bare
|
|
201
|
+
// `mode: "worktree"` keeps the documented local fallback.
|
|
202
|
+
let block: WorktreeBlock | undefined;
|
|
203
|
+
if (opts.mode !== "worktree" && opts.worktree !== undefined) {
|
|
204
|
+
warn(`[plugin-spawn] plugin=${deps.plugin.id} passed a worktree block without mode "worktree"; ignoring it and running in-place`);
|
|
205
|
+
}
|
|
206
|
+
if (opts.mode === "worktree" && opts.worktree !== undefined) {
|
|
207
|
+
const parsed = parseWorktreeBlock(opts.worktree);
|
|
208
|
+
if ("reason" in parsed) {
|
|
209
|
+
log(`[plugin-spawn] worktree failed plugin=${deps.plugin.id} branch=(invalid) code=invalid_block`);
|
|
210
|
+
return fail("invalid_block", parsed.reason);
|
|
211
|
+
}
|
|
212
|
+
block = parsed.block;
|
|
213
|
+
}
|
|
214
|
+
// Literal model passes through; `@role` resolves once; a dropped choice is reported in
|
|
215
|
+
// `warning`. See change: add-spawn-model-choice.
|
|
216
|
+
const { options: sessionOptions, warning: choiceWarning } = mapPluginSpawnOptions(opts, {
|
|
217
|
+
defaultModel: deps.defaultModel() || undefined,
|
|
218
|
+
});
|
|
219
|
+
const minted = resolveSpawnToken(deps, opts);
|
|
220
|
+
if ("failure" in minted) return minted.failure;
|
|
221
|
+
const spawnToken = minted.token;
|
|
222
|
+
// Snapshot every value read after the provisioning await, so a caller mutating its options object
|
|
223
|
+
// while a worktree is being prepared cannot change which driver launches or what gets filed.
|
|
224
|
+
const { agent, pluginRef, lifecycle } = opts;
|
|
225
|
+
const callerToken = typeof opts.spawnToken === "string" && opts.spawnToken.length > 0;
|
|
226
|
+
const initialPrompt =
|
|
227
|
+
typeof opts.initialPrompt === "string" && opts.initialPrompt.length > 0 ? opts.initialPrompt : undefined;
|
|
228
|
+
|
|
229
|
+
let spawnCwd = opts.cwd;
|
|
230
|
+
let worktree: PreparedWorktree | undefined;
|
|
231
|
+
if (block) {
|
|
232
|
+
const prepared = await prepareWorktree(deps, opts, block, log);
|
|
233
|
+
if ("failure" in prepared) return prepared.failure;
|
|
234
|
+
worktree = prepared.worktree;
|
|
235
|
+
spawnCwd = worktree.path;
|
|
236
|
+
// `has()` does not reserve a token: re-check after the await so a concurrent spawn with the same
|
|
237
|
+
// caller-supplied token cannot overwrite (or roll back) this call's entry; and refuse a launch that
|
|
238
|
+
// would start after shutdown began (its child would escape the shutdown sweeps).
|
|
239
|
+
if (deps.isStopping?.()) return { success: false, message: "server is shutting down" };
|
|
240
|
+
if (callerToken && deps.pendingPluginRefRegistry.has(spawnToken)) {
|
|
241
|
+
return { success: false, message: `spawnToken "${spawnToken}" is already pending for another spawn` };
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
deps.pendingPluginRefRegistry.file(spawnToken, pluginRef, deps.plugin.id, lifecycle);
|
|
246
|
+
// Fresh-spawn reprime rides the per-cwd pending-initial-prompt FIFO exactly as core's own respawn
|
|
247
|
+
// path does: enqueue BEFORE the spawn await, withdraw on failure/throw so a dead spawn leaves no
|
|
248
|
+
// stale intent for an unrelated later register in the same cwd. See change: relocate-goal-product-to-plugin (D1-#3).
|
|
249
|
+
if (initialPrompt) deps.pendingInitialPromptRegistry.enqueue(spawnCwd, initialPrompt);
|
|
250
|
+
// Attach intent, identical to the dialog's `attachProposal`; no `gitWorktreeBase` (dialog-only).
|
|
251
|
+
const attachChange = block?.attachChange;
|
|
252
|
+
const attachQueued = attachChange ? deps.pendingAttachRegistry.enqueue(spawnCwd, attachChange) : false;
|
|
253
|
+
const attachWarning = attachChange && !attachQueued ? "attach queue full; session not attached" : undefined;
|
|
254
|
+
// Bare `mode: "worktree"` / a non-default sandbox are not enforced by the host hook (4.2 limitation).
|
|
255
|
+
if ((opts.mode === "worktree" && !block) || (opts.sandbox && opts.sandbox !== "workspace-write")) {
|
|
256
|
+
warn(
|
|
257
|
+
`[plugin-spawn] mode=${opts.mode ?? "local"} sandbox=${opts.sandbox ?? "(default)"} requested but not yet enforced by the host hook; running in-place at ${opts.cwd}`,
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
const rollback = () => {
|
|
261
|
+
deps.pendingPluginRefRegistry.remove(spawnToken);
|
|
262
|
+
if (initialPrompt) deps.pendingInitialPromptRegistry.withdraw(spawnCwd, initialPrompt);
|
|
263
|
+
if (attachQueued && attachChange) deps.pendingAttachRegistry.withdraw(spawnCwd, attachChange);
|
|
264
|
+
};
|
|
265
|
+
try {
|
|
266
|
+
const result =
|
|
267
|
+
typeof agent === "string"
|
|
268
|
+
? await deps.spawnAcp(spawnCwd, { agent, spawnToken })
|
|
269
|
+
: await deps.spawnPi(spawnCwd, { ...sessionOptions, spawnToken });
|
|
270
|
+
// Plugin/automation spawn: transport-less, reclaim required.
|
|
271
|
+
deps.armWatchdog(spawnCwd, result);
|
|
272
|
+
if (result.process && result.pid) {
|
|
273
|
+
deps.registerHeadlessPid(result.pid, spawnCwd, result.process, result.spawnToken ?? spawnToken, result);
|
|
274
|
+
}
|
|
275
|
+
// Token-keyed, idempotent rollback on failure so no later session resolves a stale ref.
|
|
276
|
+
if (!result.success) rollback();
|
|
277
|
+
const warnings = result.success ? [choiceWarning, attachWarning].filter(Boolean) : [];
|
|
278
|
+
return {
|
|
279
|
+
success: result.success,
|
|
280
|
+
message: result.message,
|
|
281
|
+
...(result.spawnToken ? { spawnToken: result.spawnToken } : { spawnToken }),
|
|
282
|
+
...(warnings.length > 0 ? { warning: warnings.join("; ") } : {}),
|
|
283
|
+
...(result.success && worktree ? { worktreePath: worktree.path, branch: worktree.branch, created: worktree.created } : {}),
|
|
284
|
+
};
|
|
285
|
+
} catch (err) {
|
|
286
|
+
rollback();
|
|
287
|
+
return { success: false, message: err instanceof Error ? err.message : String(err) };
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { ProcessKind } from "@blackbelt-technology/pi-dashboard-shared/protocol.js";
|
|
12
12
|
import type { DashboardSession } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
13
|
+
import { resolvePidTarget, type ServerPidContext } from "../session/pid-target.js";
|
|
13
14
|
|
|
14
15
|
/** A scanned process entry as received from the bridge. */
|
|
15
16
|
export interface RawProcessEntry {
|
|
@@ -37,14 +38,18 @@ export type PidIndex = Map<number, PidIndexEntry>;
|
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Build a `pid → session` index from connected sessions only. A session
|
|
40
|
-
* contributes iff it is not ended
|
|
41
|
-
* to live sessions avoids pid-reuse mislinks
|
|
41
|
+
* contributes iff it is not ended, carries a numeric `pid`, AND that pid's
|
|
42
|
+
* target is `host`. Restricting to live sessions avoids pid-reuse mislinks
|
|
43
|
+
* against dead sessions; restricting to `host` avoids cross-namespace mislinks
|
|
44
|
+
* (a remote / WSL / container pid number naming a local process).
|
|
45
|
+
* See change: scope-pids-to-namespace (D3).
|
|
42
46
|
*/
|
|
43
|
-
export function buildPidIndex(sessions: readonly DashboardSession[]): PidIndex {
|
|
47
|
+
export function buildPidIndex(sessions: readonly DashboardSession[], ctx: ServerPidContext): PidIndex {
|
|
44
48
|
const index: PidIndex = new Map();
|
|
45
49
|
for (const s of sessions) {
|
|
46
50
|
if (s.status === "ended") continue;
|
|
47
51
|
if (typeof s.pid !== "number") continue;
|
|
52
|
+
if (resolvePidTarget(s, ctx).kind !== "host") continue;
|
|
48
53
|
index.set(s.pid, { sessionId: s.id, name: s.name, model: s.model });
|
|
49
54
|
}
|
|
50
55
|
return index;
|
|
@@ -73,6 +73,7 @@ import {
|
|
|
73
73
|
import { type CwdPolicyRegistry, mergeCwdPolicy } from "./cwd-policy.js";
|
|
74
74
|
import { applyHeapArgsToPiArgv, recordHeapArgvFallback } from "./heap-args.js";
|
|
75
75
|
import { applySpawnEnvContributors, type ContributorMechanism } from "./spawn-env-contributors.js";
|
|
76
|
+
import { normalizeCwdKey } from "./spawn-register-watchdog.js";
|
|
76
77
|
|
|
77
78
|
// ── Resolver seam (injectable for tests) ────────────────────────────────────
|
|
78
79
|
|
|
@@ -297,6 +298,16 @@ export function buildSpawnEnv(
|
|
|
297
298
|
baseEnv: NodeJS.ProcessEnv = process.env,
|
|
298
299
|
opts?: {
|
|
299
300
|
spawnToken?: string;
|
|
301
|
+
/**
|
|
302
|
+
* The spawn cwd. When given (non-empty), `PWD` is set to its canonical
|
|
303
|
+
* physical path (`normalizeCwdKey(path.resolve(cwd))`: realpath, else the
|
|
304
|
+
* absolute lexical form), replacing the server's own stale `PWD` so
|
|
305
|
+
* PWD-reading tools (context-mode) resolve the session's project, not the
|
|
306
|
+
* dashboard's launch dir (#1079). Host-owned: contributors cannot touch
|
|
307
|
+
* it. Absent / empty ⇒ env byte-identical. See change:
|
|
308
|
+
* fix-spawned-session-pwd (D1, D4).
|
|
309
|
+
*/
|
|
310
|
+
cwd?: string;
|
|
300
311
|
/**
|
|
301
312
|
* The node-wrapped `argv[0]` this env will spawn (e.g. `piCmd[0]`).
|
|
302
313
|
* When it is the Electron GUI binary (`execpath-fallback` topology),
|
|
@@ -361,6 +372,12 @@ export function buildSpawnEnv(
|
|
|
361
372
|
// non-blocking finding — grandchild marker leak).
|
|
362
373
|
delete env.PI_DASHBOARD_ELECTRON;
|
|
363
374
|
delete env.PI_DASHBOARD_RESOURCES_PATH;
|
|
375
|
+
// Same class: the Electron runtime-overlay identity (D8). A leaked set makes
|
|
376
|
+
// a server started from inside a session (e.g. a checkout dev server) claim
|
|
377
|
+
// the Electron runtime, re-register ITS extension in settings.json and
|
|
378
|
+
// /reload every session on another extension. Electron re-stamps these on
|
|
379
|
+
// its own server spawns; no pi session reads them.
|
|
380
|
+
for (const k of RUNTIME_OVERLAY_ENV) delete env[k];
|
|
364
381
|
// context-mode's bridge-internal recursion guard / idle reaper vars. A server
|
|
365
382
|
// started from inside a context-mode sandbox would otherwise hand them to
|
|
366
383
|
// every session, where context-mode silently disables its `ctx_*` tools.
|
|
@@ -431,6 +448,10 @@ export function buildSpawnEnv(
|
|
|
431
448
|
// See change: spawn-correlation-token.
|
|
432
449
|
env.PI_DASHBOARD_SPAWN_TOKEN = opts.spawnToken;
|
|
433
450
|
}
|
|
451
|
+
// The child's `PWD` names ITS cwd, not the server's. Host shaping, before
|
|
452
|
+
// the contributors (PWD is on their deny list). See change:
|
|
453
|
+
// fix-spawned-session-pwd (D1, D4).
|
|
454
|
+
if (opts?.cwd) env.PWD = normalizeCwdKey(path.resolve(opts.cwd));
|
|
434
455
|
if (opts?.mechanism) {
|
|
435
456
|
const applied = applySpawnEnvContributors(env, opts.mechanism);
|
|
436
457
|
if (opts.contributedOut) Object.assign(opts.contributedOut, applied);
|
|
@@ -593,6 +614,18 @@ export function buildInteractivePiArgs(options?: SessionOptions): string[] {
|
|
|
593
614
|
* shell of its own, so `shellEscape` is still applied to the pane tokens (pi
|
|
594
615
|
* invocation + session flags). Do not strip it.
|
|
595
616
|
*/
|
|
617
|
+
/**
|
|
618
|
+
* Electron runtime-overlay identity (D8): owned by the server Electron spawned,
|
|
619
|
+
* never by its sessions. Stripped from every session env (and `env -u`'d in
|
|
620
|
+
* tmux panes, whose env comes from the long-lived tmux server).
|
|
621
|
+
*/
|
|
622
|
+
const RUNTIME_OVERLAY_ENV = [
|
|
623
|
+
"PI_DASHBOARD_ELECTRON_INSTANCE",
|
|
624
|
+
"PI_DASHBOARD_RUNTIME_ID",
|
|
625
|
+
"PI_DASHBOARD_RUNTIME_ORIGIN",
|
|
626
|
+
"PI_DASHBOARD_EXTENSION_DIR",
|
|
627
|
+
] as const;
|
|
628
|
+
|
|
596
629
|
export function buildTmuxCommand(
|
|
597
630
|
cwd: string,
|
|
598
631
|
sessionExists: boolean,
|
|
@@ -612,6 +645,7 @@ export function buildTmuxCommand(
|
|
|
612
645
|
"CONTEXT_MODE_BRIDGE_DEPTH",
|
|
613
646
|
"-u",
|
|
614
647
|
"CONTEXT_MODE_BRIDGE_IDLE_MS",
|
|
648
|
+
...RUNTIME_OVERLAY_ENV.flatMap((k) => ["-u", k]),
|
|
615
649
|
...piInvocation.map(shellEscape),
|
|
616
650
|
...sessionFlagsToArgv(options ?? {}).map(shellEscape),
|
|
617
651
|
].join(" ");
|
|
@@ -924,6 +958,7 @@ export function spawnTmux(cwd: string, options?: SessionOptions): SpawnResult {
|
|
|
924
958
|
const contributed: Record<string, string> = {};
|
|
925
959
|
const env = buildSpawnEnv(process.env, {
|
|
926
960
|
spawnToken: options?.spawnToken,
|
|
961
|
+
cwd,
|
|
927
962
|
argv0: piCmd[0],
|
|
928
963
|
spawnRuntime: rt,
|
|
929
964
|
mechanism: "tmux",
|
|
@@ -954,6 +989,7 @@ export function spawnWslTmux(cwd: string, options?: SessionOptions): SpawnResult
|
|
|
954
989
|
const contributed: Record<string, string> = {};
|
|
955
990
|
const env = buildSpawnEnv(process.env, {
|
|
956
991
|
spawnToken: options?.spawnToken,
|
|
992
|
+
cwd,
|
|
957
993
|
spawnRuntime: spawnRuntimeForSession(),
|
|
958
994
|
mechanism: "wsl-tmux",
|
|
959
995
|
contributedOut: contributed,
|
|
@@ -985,6 +1021,7 @@ async function spawnWt(cwd: string, options?: SessionOptions): Promise<SpawnResu
|
|
|
985
1021
|
const args = buildWtArgs({ cwd, title: path.basename(cwd) || "pi", piArgv });
|
|
986
1022
|
const wtEnv = buildSpawnEnv(process.env, {
|
|
987
1023
|
spawnToken: options?.spawnToken,
|
|
1024
|
+
cwd,
|
|
988
1025
|
argv0: piCmd[0],
|
|
989
1026
|
spawnRuntime: rt,
|
|
990
1027
|
mechanism: "wt",
|
|
@@ -1045,6 +1082,7 @@ async function spawnHeadless(cwd: string, options?: SessionOptions): Promise<Spa
|
|
|
1045
1082
|
// the keeper's base env, so the forwarded pi child inherits the flag too.
|
|
1046
1083
|
const env = buildSpawnEnv(process.env, {
|
|
1047
1084
|
spawnToken: options?.spawnToken,
|
|
1085
|
+
cwd,
|
|
1048
1086
|
argv0: piCmd[0],
|
|
1049
1087
|
extensionConfig: options?.extensionConfig,
|
|
1050
1088
|
spawnRuntime: rt,
|
|
@@ -1069,7 +1107,7 @@ async function spawnHeadless(cwd: string, options?: SessionOptions): Promise<Spa
|
|
|
1069
1107
|
*/
|
|
1070
1108
|
function spawnChildCmdViaKeeper(cwd: string, childCmd: string[], spawnToken?: string): Promise<SpawnResult> {
|
|
1071
1109
|
const [argv0, ...rest] = childCmd as [string, ...string[]];
|
|
1072
|
-
const env = buildSpawnEnv(process.env, { spawnToken, argv0, mechanism: "headless" });
|
|
1110
|
+
const env = buildSpawnEnv(process.env, { spawnToken, cwd, argv0, mechanism: "headless" });
|
|
1073
1111
|
return spawnHeadlessViaKeeper(cwd, env, rest, [argv0]);
|
|
1074
1112
|
}
|
|
1075
1113
|
|
|
@@ -1106,10 +1144,20 @@ async function spawnHeadlessViaKeeper(
|
|
|
1106
1144
|
// config flag (default OFF). Read at spawn time so toggling takes effect on
|
|
1107
1145
|
// the next spawn without a server restart. The keeper reads this env var to
|
|
1108
1146
|
// pick its pi-child stdio sink. See change: add-keeper-output-capture-toggle.
|
|
1147
|
+
//
|
|
1148
|
+
// The config toggle is the ONLY switch: it gates all keeper log output
|
|
1149
|
+
// (keeper-<id>.log + keeper-launch-<id>.log), and an inherited value from
|
|
1150
|
+
// the server's own env must not turn logging on behind it. Delete every
|
|
1151
|
+
// case-insensitive match (Windows child env lookup is case-insensitive) on a
|
|
1152
|
+
// fresh copy — buildSpawnEnv may hand back process.env itself.
|
|
1153
|
+
// See change: keeper-log-toggle-gates-all-output (D1).
|
|
1109
1154
|
const keeperLog = loadConfig().keeperLog;
|
|
1110
|
-
|
|
1111
|
-
|
|
1155
|
+
const captureEnabled = keeperLog.capturePiOutput === true;
|
|
1156
|
+
env = { ...env };
|
|
1157
|
+
for (const key of Object.keys(env)) {
|
|
1158
|
+
if (key.toUpperCase() === "PI_KEEPER_CAPTURE_PI_OUTPUT") delete env[key];
|
|
1112
1159
|
}
|
|
1160
|
+
if (captureEnabled) env.PI_KEEPER_CAPTURE_PI_OUTPUT = "1";
|
|
1113
1161
|
// The keeper is CJS-pure and cannot import the shared config, so the cap and
|
|
1114
1162
|
// check interval ride the same env path as capturePiOutput. Read at spawn
|
|
1115
1163
|
// time (per D7: the keeper's cap is a spawn-time value; keepers started
|
|
@@ -1150,12 +1198,19 @@ async function spawnHeadlessViaKeeper(
|
|
|
1150
1198
|
// within the window.
|
|
1151
1199
|
const gate = await waitForNoCrash({ child: result.process, windowMs: 300 });
|
|
1152
1200
|
if (!gate.ok) {
|
|
1201
|
+
// The message follows the capture value placed in the keeper env above
|
|
1202
|
+
// (D5): with capture on, name both files (startup errors raised before the
|
|
1203
|
+
// keeper opens its own log land only in the launch log); with it off,
|
|
1204
|
+
// there are no files — give the remedy instead.
|
|
1205
|
+
const remedy = captureEnabled
|
|
1206
|
+
? `Check ~/.pi/dashboard/sessions/keeper-${transportId}.log and ` +
|
|
1207
|
+
`~/.pi/dashboard/sessions/keeper-launch-${transportId}.log for details.`
|
|
1208
|
+
: `No keeper log was written. To capture one, enable "Capture pi session output (debug)" ` +
|
|
1209
|
+
`in Settings > Developer and start a new session.`;
|
|
1153
1210
|
return {
|
|
1154
1211
|
success: false,
|
|
1155
1212
|
code: "PI_CRASHED",
|
|
1156
|
-
message:
|
|
1157
|
-
`RPC keeper exited within crash window (code ${gate.exitCode}). ` +
|
|
1158
|
-
`Check ~/.pi/dashboard/sessions/keeper-${transportId}.log for details.`,
|
|
1213
|
+
message: `RPC keeper exited within crash window (code ${gate.exitCode}). ${remedy}`,
|
|
1159
1214
|
};
|
|
1160
1215
|
}
|
|
1161
1216
|
|