@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
|
@@ -28,6 +28,11 @@ import { fileURLToPath } from "node:url";
|
|
|
28
28
|
* pi-dashboard pair deny <pendingId>
|
|
29
29
|
* Approve/deny a pending device pairing from this host. The code is read from a
|
|
30
30
|
* prompt or stdin; --code is visible in `ps`.
|
|
31
|
+
* pi-dashboard api <METHOD> <path> [--data <json>] [--port n]
|
|
32
|
+
* Call the running dashboard's REST API with a freshly minted local proof
|
|
33
|
+
* (what curl cannot do under the strict `requireLocalProof` default).
|
|
34
|
+
* Exit 0 on 2xx, 1 on any other status (body on stderr), 2 on usage error
|
|
35
|
+
* or server not running.
|
|
31
36
|
*
|
|
32
37
|
* Flags:
|
|
33
38
|
* --port <n> HTTP port (default: 8000)
|
|
@@ -42,6 +47,7 @@ import { fileURLToPath } from "node:url";
|
|
|
42
47
|
import { ensureConfig, loadConfig, SERVER_STARTUP_DEADLINE_MS } from "@blackbelt-technology/pi-dashboard-shared/config.js";
|
|
43
48
|
import { getDashboardConfigDir } from "@blackbelt-technology/pi-dashboard-shared/dashboard-paths.js";
|
|
44
49
|
import { isLauncherOrigin } from "@blackbelt-technology/pi-dashboard-shared/launcher-origin.js";
|
|
50
|
+
import { isSafeLocalPath } from "@blackbelt-technology/pi-dashboard-shared/safe-local-path.js";
|
|
45
51
|
import { httpProofHeaders, localDialHost } from "@blackbelt-technology/pi-dashboard-shared/local-credential-proof.js";
|
|
46
52
|
import {
|
|
47
53
|
findPortHolders as platformFindPortHolders,
|
|
@@ -56,8 +62,9 @@ import {
|
|
|
56
62
|
} from "@blackbelt-technology/pi-dashboard-shared/server-launcher.js";
|
|
57
63
|
import { terminalSafe } from "@blackbelt-technology/pi-dashboard-shared/terminal-safe.js";
|
|
58
64
|
import { defaultLocalTokenDir, ensureLocalToken, readLocalTokenIfPresent } from "./auth/local-token.js";
|
|
59
|
-
import { migrateSubagentTickThrottle } from "./config-api.js";
|
|
60
65
|
import { classifyDashboardPort, type PortClassification } from "./lifecycle/classify-dashboard-port.js";
|
|
66
|
+
import { settleThenExit } from "./lifecycle/credential-exit-barrier.js";
|
|
67
|
+
import { createExitSignalHandler } from "./lifecycle/exit-signal.js";
|
|
61
68
|
import {
|
|
62
69
|
isModuleNotFoundError,
|
|
63
70
|
parseModuleNotFoundError,
|
|
@@ -91,6 +98,7 @@ import {
|
|
|
91
98
|
import { isDashboardRunning } from "@blackbelt-technology/pi-dashboard-shared/server-identity.js";
|
|
92
99
|
import { getDefaultRegistry, ingestInstalledSkillTools, resolveInstallRoot } from "@blackbelt-technology/pi-dashboard-shared/tool-registry/index.js";
|
|
93
100
|
import { assertNodeVersionSupported, warnTsLoaderState } from "./auth/node-guard.js";
|
|
101
|
+
import { cmdCredentials } from "./cli/credentials-command.js";
|
|
94
102
|
import { recordExitIntent } from "./persistence/boot-state.js";
|
|
95
103
|
import { publishResolvedRuntime, readPublishedRuntimeBlock } from "./runtime-publication.js";
|
|
96
104
|
import { resolveLiveSpawnRuntime } from "./runtime-resolution.js";
|
|
@@ -100,6 +108,42 @@ import { servicesPaths } from "./services/paths.js";
|
|
|
100
108
|
|
|
101
109
|
const SUBCOMMANDS = ["start", "stop", "restart", "status", "runtime", "open"] as const;
|
|
102
110
|
type Subcommand = (typeof SUBCOMMANDS)[number];
|
|
111
|
+
/** Words dispatched to their own command (before `parseArgs`), not to a daemon subcommand. */
|
|
112
|
+
const COMMAND_WORDS = ["token", "service", "pair", "login", "api", "credentials"] as const;
|
|
113
|
+
type CommandWord = (typeof COMMAND_WORDS)[number];
|
|
114
|
+
/** Flags whose NEXT token is their value, never the subcommand word. */
|
|
115
|
+
const VALUE_FLAGS: ReadonlySet<string> = new Set(["--port", "--host", "--pi-port", "--url", "--data", "--code", "--name", "--tier"]);
|
|
116
|
+
|
|
117
|
+
/** The one-line usage printed for an unknown subcommand word (exit 2). */
|
|
118
|
+
export const CLI_USAGE =
|
|
119
|
+
"usage: pi-dashboard [start|stop|restart|status|runtime|open|pair|token|service|login|api|credentials] [flags] (no word: run in the foreground)";
|
|
120
|
+
|
|
121
|
+
export type ArgvClass =
|
|
122
|
+
| { kind: "none" }
|
|
123
|
+
| { kind: "subcommand"; word: Subcommand; index: number }
|
|
124
|
+
| { kind: "command"; word: CommandWord; index: number }
|
|
125
|
+
| { kind: "unknown"; word: string; index: number };
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The subcommand word: the FIRST positional that is not a flag value. `--port 9000 api GET /x`
|
|
129
|
+
* resolves to `api` (9000 is `--port`'s value). One scan serves `api`, `token`, `service`,
|
|
130
|
+
* `pair`, `login` and the daemon subcommands, so none of them can be missed behind a flag.
|
|
131
|
+
* A flag-only invocation has no word and runs in the foreground.
|
|
132
|
+
*/
|
|
133
|
+
export function classifyArgv(args: readonly string[]): ArgvClass {
|
|
134
|
+
for (let i = 0; i < args.length; i++) {
|
|
135
|
+
const a = args[i] as string;
|
|
136
|
+
if (a === "--") break;
|
|
137
|
+
if (a.startsWith("-")) {
|
|
138
|
+
if (VALUE_FLAGS.has(a)) i++; // skip its value
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if ((SUBCOMMANDS as readonly string[]).includes(a)) return { kind: "subcommand", word: a as Subcommand, index: i };
|
|
142
|
+
if ((COMMAND_WORDS as readonly string[]).includes(a)) return { kind: "command", word: a as CommandWord, index: i };
|
|
143
|
+
return { kind: "unknown", word: a, index: i };
|
|
144
|
+
}
|
|
145
|
+
return { kind: "none" };
|
|
146
|
+
}
|
|
103
147
|
|
|
104
148
|
export interface ParsedArgs {
|
|
105
149
|
subcommand: Subcommand | null;
|
|
@@ -353,15 +397,16 @@ async function runForeground(config: ServerConfig): Promise<void> {
|
|
|
353
397
|
// SIGTERM→SIGKILL ladder: `/api/restart` already recorded `"restart"` before
|
|
354
398
|
// the ladder runs, so the later `"signal"` is a no-op.
|
|
355
399
|
// See change: fix-recovery-exit-intent (D4).
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
400
|
+
//
|
|
401
|
+
// Exit waits (bounded) for in-flight credential writes: a rotated OAuth
|
|
402
|
+
// single-use refresh token must not be cut off. The handler body lives in
|
|
403
|
+
// `lifecycle/exit-signal.ts`. See change: settle-server-credential-writes-on-exit.
|
|
404
|
+
const onExitSignal = createExitSignalHandler({
|
|
405
|
+
recordExitIntent: (intent) => recordExitIntent(intent),
|
|
406
|
+
flush: () => server.flush(),
|
|
407
|
+
settleThenExit,
|
|
408
|
+
log: (message) => console.log(message),
|
|
409
|
+
});
|
|
365
410
|
process.on("SIGTERM", onExitSignal);
|
|
366
411
|
process.on("SIGINT", onExitSignal);
|
|
367
412
|
|
|
@@ -1043,7 +1088,30 @@ export async function cmdLogin(
|
|
|
1043
1088
|
err(`[login] failed to issue a code: ${json.error ?? "unknown error"}`);
|
|
1044
1089
|
return 1;
|
|
1045
1090
|
}
|
|
1046
|
-
|
|
1091
|
+
// The browser that opens the link is a plain tab: under the strict `requireLocalProof` default it
|
|
1092
|
+
// cannot even redeem the code (`/api/identity/local-exchange` needs proof), so route it through the
|
|
1093
|
+
// local-proof bootstrap first — same as `pi-dashboard open` — and land on the `pi_local` link.
|
|
1094
|
+
// Falls back to the plain link when no proof code can be minted.
|
|
1095
|
+
const plain = `/?pi_local=${encodeURIComponent(json.data.code)}`;
|
|
1096
|
+
let link = `${base}${plain}`;
|
|
1097
|
+
try {
|
|
1098
|
+
const proofUrl = `${localBase(opts)}/api/local-proof`;
|
|
1099
|
+
const pr = await fetchFn(proofUrl, {
|
|
1100
|
+
method: "POST",
|
|
1101
|
+
headers: { "content-type": "application/json", ...localCredentialHeaders("POST", proofUrl, localToken) },
|
|
1102
|
+
body: "{}",
|
|
1103
|
+
signal: AbortSignal.timeout(deps.timeoutMs ?? 5000),
|
|
1104
|
+
});
|
|
1105
|
+
if (pr.ok) {
|
|
1106
|
+
const pj = (await pr.json()) as { success?: boolean; data?: { code?: string } };
|
|
1107
|
+
if (pj.success && typeof pj.data?.code === "string") {
|
|
1108
|
+
link = `${base}/auth/local-proof?code=${encodeURIComponent(pj.data.code)}&next=${encodeURIComponent(plain)}`;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
} catch {
|
|
1112
|
+
/* keep the plain link */
|
|
1113
|
+
}
|
|
1114
|
+
out(link);
|
|
1047
1115
|
out(`Open this link on this machine within ${json.data.expiresInSeconds} s (single-use). You sign in as the local operator (break-glass).`);
|
|
1048
1116
|
return 0;
|
|
1049
1117
|
} catch (e) {
|
|
@@ -1052,6 +1120,98 @@ export async function cmdLogin(
|
|
|
1052
1120
|
}
|
|
1053
1121
|
}
|
|
1054
1122
|
|
|
1123
|
+
/** HTTP methods `pi-dashboard api` accepts. */
|
|
1124
|
+
const API_METHODS: ReadonlySet<string> = new Set(["GET", "POST", "PUT", "PATCH", "DELETE"]);
|
|
1125
|
+
|
|
1126
|
+
export interface CmdApiDeps {
|
|
1127
|
+
fetchImpl?: typeof fetch;
|
|
1128
|
+
out?: (text: string) => void;
|
|
1129
|
+
err?: (line: string) => void;
|
|
1130
|
+
/** Local token; defaults to the on-disk one (created if absent — the server owns it). */
|
|
1131
|
+
localToken?: string | null;
|
|
1132
|
+
timeoutMs?: number;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* `pi-dashboard api <METHOD> <path> [--data <json>] [--port n]` — call the running dashboard's REST
|
|
1137
|
+
* API from a shell with a freshly minted local proof, which a bare `curl` cannot do under the
|
|
1138
|
+
* strict `requireLocalProof` default. It dials the address literal `restart` dials, sends ONE proof
|
|
1139
|
+
* for this method + target, and never follows a redirect (a `Location` to another origin must not
|
|
1140
|
+
* receive the proof's request). The path is checked by the same predicate the OAuth return-URL
|
|
1141
|
+
* sanitiser uses, plus `#`; a rejected path sends nothing.
|
|
1142
|
+
*
|
|
1143
|
+
* Exit: 0 on 2xx (body on stdout) · 1 on any other status (body on stderr) · 2 on a usage error
|
|
1144
|
+
* or when the server is not running.
|
|
1145
|
+
* See change: close-container-loopback-impersonation (D4).
|
|
1146
|
+
*/
|
|
1147
|
+
export async function cmdApi(
|
|
1148
|
+
argv: string[],
|
|
1149
|
+
opts: { port: number; host?: string },
|
|
1150
|
+
deps: CmdApiDeps = {},
|
|
1151
|
+
): Promise<number> {
|
|
1152
|
+
const out = deps.out ?? ((t: string) => process.stdout.write(t.endsWith("\n") ? t : `${t}\n`));
|
|
1153
|
+
const err = deps.err ?? ((l: string) => console.error(l));
|
|
1154
|
+
const usage = (why: string): number => {
|
|
1155
|
+
err(`[api] ${why}`);
|
|
1156
|
+
err("usage: pi-dashboard api <GET|POST|PUT|PATCH|DELETE> </path> [--data <json>] [--port <n>]");
|
|
1157
|
+
return 2;
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
const positionals: string[] = [];
|
|
1161
|
+
let data: string | undefined;
|
|
1162
|
+
for (let i = 0; i < argv.length; i++) {
|
|
1163
|
+
const a = argv[i] as string;
|
|
1164
|
+
if (a === "--data") {
|
|
1165
|
+
data = argv[++i];
|
|
1166
|
+
if (data === undefined) return usage("--data needs a JSON value");
|
|
1167
|
+
} else if (a.startsWith("-")) {
|
|
1168
|
+
if (VALUE_FLAGS.has(a)) i++; // --port/--host value: already applied by buildConfig
|
|
1169
|
+
} else {
|
|
1170
|
+
positionals.push(a);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
if (positionals.length !== 2) return usage("expected a method and a path");
|
|
1174
|
+
const method = (positionals[0] as string).toUpperCase();
|
|
1175
|
+
const target = positionals[1] as string;
|
|
1176
|
+
if (!API_METHODS.has(method)) return usage(`unsupported method ${terminalSafe(positionals[0] as string, 20)}`);
|
|
1177
|
+
if (!isSafeLocalPath(target) || target.includes("#")) return usage("path must be a same-origin path starting with a single '/' (no '#', no control characters)");
|
|
1178
|
+
if (data !== undefined) {
|
|
1179
|
+
try {
|
|
1180
|
+
JSON.parse(data);
|
|
1181
|
+
} catch {
|
|
1182
|
+
return usage("--data must be valid JSON");
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
const url = `${localBase(opts)}${target}`;
|
|
1187
|
+
const token = deps.localToken !== undefined ? deps.localToken : safeEnsureLocalToken();
|
|
1188
|
+
const fetchFn = deps.fetchImpl ?? fetch;
|
|
1189
|
+
let res: Response;
|
|
1190
|
+
try {
|
|
1191
|
+
res = await fetchFn(url, {
|
|
1192
|
+
method,
|
|
1193
|
+
redirect: "manual",
|
|
1194
|
+
headers: {
|
|
1195
|
+
...(data !== undefined ? { "content-type": "application/json" } : {}),
|
|
1196
|
+
...localCredentialHeaders(method, url, token),
|
|
1197
|
+
},
|
|
1198
|
+
...(data !== undefined ? { body: data } : {}),
|
|
1199
|
+
signal: AbortSignal.timeout(deps.timeoutMs ?? 30_000),
|
|
1200
|
+
});
|
|
1201
|
+
} catch (e) {
|
|
1202
|
+
err(`[api] dashboard server not running at ${localBase(opts)} (${(e as Error).message ?? e})`);
|
|
1203
|
+
return 2;
|
|
1204
|
+
}
|
|
1205
|
+
const body = await res.text().catch(() => "");
|
|
1206
|
+
if (res.status >= 200 && res.status < 300) {
|
|
1207
|
+
if (body) out(body);
|
|
1208
|
+
return 0;
|
|
1209
|
+
}
|
|
1210
|
+
if (body) err(body);
|
|
1211
|
+
else err(`[api] HTTP ${res.status}`);
|
|
1212
|
+
return 1;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1055
1215
|
/** The dial base for local calls: the address LITERAL the server's bind maps to, never `localhost`. */
|
|
1056
1216
|
function localBase(c: { host?: string; port: number }): string {
|
|
1057
1217
|
return `http://${localDialHost(c.host)}:${c.port}`;
|
|
@@ -1737,52 +1897,68 @@ function flagValue(args: string[], flag: string): string | undefined {
|
|
|
1737
1897
|
|
|
1738
1898
|
async function main() {
|
|
1739
1899
|
installCrashSafetyNet();
|
|
1900
|
+
// Refuse an unknown subcommand word BEFORE anything is created or bound: an older binary fell
|
|
1901
|
+
// through to the foreground server for it. Flag-only invocations still run in the foreground.
|
|
1902
|
+
const early = classifyArgv(process.argv.slice(2));
|
|
1903
|
+
if (early.kind === "unknown") {
|
|
1904
|
+
console.error(`[cli] unknown subcommand '${terminalSafe(early.word, 40)}'`);
|
|
1905
|
+
console.error(CLI_USAGE);
|
|
1906
|
+
process.exit(2);
|
|
1907
|
+
}
|
|
1740
1908
|
ensureConfig();
|
|
1741
|
-
// One-shot: rewrite a pre-flip materialized `subagentTickThrottleMs: 0`.
|
|
1742
|
-
// Boot path only — `loadConfig` is a pure read called by every bridge
|
|
1743
|
-
// process. See change: heal-orphaned-tool-cards-on-session-end (design D5).
|
|
1744
|
-
migrateSubagentTickThrottle();
|
|
1745
1909
|
|
|
1746
1910
|
const rawArgs = process.argv.slice(2);
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1911
|
+
const cls = classifyArgv(rawArgs);
|
|
1912
|
+
if (cls.kind === "command") {
|
|
1913
|
+
// Everything but the command word: its own args plus any flags that came BEFORE it (`--port 9000 api …`).
|
|
1914
|
+
const rest = [...rawArgs.slice(0, cls.index), ...rawArgs.slice(cls.index + 1)];
|
|
1915
|
+
if (cls.word === "token") {
|
|
1916
|
+
const { flags } = parseArgs(rest);
|
|
1917
|
+
const config = buildConfig(flags);
|
|
1918
|
+
process.exit(await cmdTokenCreate(rest, { port: config.port, host: config.host }));
|
|
1919
|
+
}
|
|
1920
|
+
if (cls.word === "service") {
|
|
1921
|
+
// Managed services consumer contract. See change: add-service-registry-core.
|
|
1922
|
+
const { flags } = parseArgs(rest);
|
|
1923
|
+
const config = buildConfig(flags, () => {});
|
|
1924
|
+
const resolveBinary = (name: string) => {
|
|
1925
|
+
try {
|
|
1926
|
+
const r = getDefaultRegistry().resolve(name);
|
|
1927
|
+
return r.ok ? r.path : null;
|
|
1928
|
+
} catch {
|
|
1929
|
+
return null;
|
|
1930
|
+
}
|
|
1931
|
+
};
|
|
1932
|
+
process.exit(
|
|
1933
|
+
await cmdService(rest, {
|
|
1934
|
+
port: config.port,
|
|
1935
|
+
host: config.host,
|
|
1936
|
+
authHeaders: (method, target) => localCredentialHeaders(method, `${localBase(config)}${target}`),
|
|
1937
|
+
resolveExecSecrets: localExecSecretsResolver({ paths: servicesPaths(), run: defaultCommandRunner, resolveBinary }),
|
|
1938
|
+
}),
|
|
1939
|
+
);
|
|
1940
|
+
}
|
|
1941
|
+
if (cls.word === "pair") {
|
|
1942
|
+
// Host-side approval of a pending device. See change: fix-pairing-approval-credential.
|
|
1943
|
+
const { flags } = parseArgs(rest);
|
|
1944
|
+
const config = buildConfig(flags, () => {});
|
|
1945
|
+
process.exit(await cmdPair(rest, { port: config.port, host: config.host }));
|
|
1946
|
+
}
|
|
1947
|
+
if (cls.word === "credentials") {
|
|
1948
|
+
// status | decrypt | reset: local-only, no value printed. See change: encrypt-credentials-at-rest (8.1).
|
|
1949
|
+
const { flags } = parseArgs(rest);
|
|
1950
|
+
const config = buildConfig(flags, () => {});
|
|
1951
|
+
process.exit(await cmdCredentials(rest, { port: config.port, host: config.host }));
|
|
1952
|
+
}
|
|
1953
|
+
if (cls.word === "login") {
|
|
1954
|
+
const { flags } = parseArgs(rest);
|
|
1955
|
+
const config = buildConfig(flags);
|
|
1956
|
+
process.exit(await cmdLogin(rest, { port: config.port, host: config.host }));
|
|
1957
|
+
}
|
|
1958
|
+
// api
|
|
1959
|
+
const { flags } = parseArgs(rest);
|
|
1778
1960
|
const config = buildConfig(flags, () => {});
|
|
1779
|
-
process.exit(await
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1782
|
-
if (rawArgs[0] === "login") {
|
|
1783
|
-
const { flags } = parseArgs(rawArgs.slice(1));
|
|
1784
|
-
const config = buildConfig(flags);
|
|
1785
|
-
process.exit(await cmdLogin(rawArgs.slice(1), { port: config.port, host: config.host }));
|
|
1961
|
+
process.exit(await cmdApi(rest, { port: config.port, host: config.host }));
|
|
1786
1962
|
}
|
|
1787
1963
|
|
|
1788
1964
|
const { subcommand, flags } = parseArgs(rawArgs);
|
|
@@ -9,11 +9,14 @@ import {
|
|
|
9
9
|
type AuthConfig,
|
|
10
10
|
type DashboardConfig,
|
|
11
11
|
DEFAULT_SERVER_HEAP,
|
|
12
|
-
DEFAULT_SUBAGENT_TICK_THROTTLE_MS,
|
|
13
12
|
loadConfig,
|
|
14
13
|
writeConfigFileSecure,
|
|
15
14
|
} from "@blackbelt-technology/pi-dashboard-shared/config.js";
|
|
16
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
setWindowsBashSourceSetting,
|
|
17
|
+
setWindowsGitSourceSetting,
|
|
18
|
+
} from "@blackbelt-technology/pi-dashboard-shared/platform/git-source.js";
|
|
19
|
+
import { parseSudoCredentialPrompt } from "@blackbelt-technology/pi-dashboard-shared/sudo-credential.js";
|
|
17
20
|
import { getPiTrustMirror } from "./access/pi-trust-mirror-service.js";
|
|
18
21
|
import { refreshModelRegistry } from "./model-proxy/registry-singleton.js";
|
|
19
22
|
|
|
@@ -305,6 +308,9 @@ export function writeConfigPartial(
|
|
|
305
308
|
mergedAuth.capabilityRoutePlugins = partial.auth.capabilityRoutePlugins;
|
|
306
309
|
}
|
|
307
310
|
|
|
311
|
+
// `auth.trustedPlugins` is deliberately NOT merged: only the trust endpoints write it
|
|
312
|
+
// (`auth/plugin-trust-store.ts`). `mergedAuth` starts from the stored auth block and copies only the
|
|
313
|
+
// keys named above, so the stored list is kept whatever the body carries (design D12, R1).
|
|
308
314
|
partial.auth = mergedAuth;
|
|
309
315
|
}
|
|
310
316
|
|
|
@@ -400,6 +406,28 @@ export function writeConfigPartial(
|
|
|
400
406
|
if (changed) restartRequired = true;
|
|
401
407
|
}
|
|
402
408
|
|
|
409
|
+
// Merge `security` key-by-key so a Trusted Types write keeps sibling keys. `trustedTypes: null`
|
|
410
|
+
// deletes the key (Settings "Default"); an emptied `security` object is removed. Read once at
|
|
411
|
+
// server start, so a CHANGED value (compared normalized, absent == undefined) owes a restart.
|
|
412
|
+
// See change: enforce-trusted-types-default (D5).
|
|
413
|
+
if (partial.security && typeof partial.security === "object" && !Array.isArray(partial.security)) {
|
|
414
|
+
const existingSecurity =
|
|
415
|
+
existing.security && typeof existing.security === "object" && !Array.isArray(existing.security) ? existing.security : {};
|
|
416
|
+
const { trustedTypes, ...otherSecurity } = partial.security as Record<string, unknown>;
|
|
417
|
+
const mergedSecurity: Record<string, unknown> = { ...existingSecurity, ...otherSecurity };
|
|
418
|
+
if ("trustedTypes" in partial.security) {
|
|
419
|
+
const next = trustedTypes === null ? undefined : trustedTypes;
|
|
420
|
+
if (next !== existingSecurity.trustedTypes) restartRequired = true;
|
|
421
|
+
if (next === undefined) delete mergedSecurity.trustedTypes;
|
|
422
|
+
else mergedSecurity.trustedTypes = next;
|
|
423
|
+
}
|
|
424
|
+
if (Object.keys(mergedSecurity).length > 0) partial.security = mergedSecurity;
|
|
425
|
+
else {
|
|
426
|
+
delete partial.security;
|
|
427
|
+
delete existing.security;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
403
431
|
// Merge openspec sub-object (no restart required — live-reconfigured)
|
|
404
432
|
if (partial.openspec) {
|
|
405
433
|
partial.openspec = { ...existing.openspec, ...partial.openspec };
|
|
@@ -429,6 +457,12 @@ export function writeConfigPartial(
|
|
|
429
457
|
partial.agentPathGate = { ...existing.agentPathGate, ...partial.agentPathGate };
|
|
430
458
|
}
|
|
431
459
|
|
|
460
|
+
// Merge sudoCredentialPrompt sub-object, clamp-and-default (a write is never rejected).
|
|
461
|
+
// See change: add-sudo-credential-prompt.
|
|
462
|
+
if (partial.sudoCredentialPrompt) {
|
|
463
|
+
partial.sudoCredentialPrompt = parseSudoCredentialPrompt({ ...existing.sudoCredentialPrompt, ...partial.sudoCredentialPrompt });
|
|
464
|
+
}
|
|
465
|
+
|
|
432
466
|
// Merge sessionList sub-object: the Settings panel sends only the CHANGED
|
|
433
467
|
// keys, so a replace would drop a sibling (e.g. an
|
|
434
468
|
// `archiveServiceSessionsOnEnd: false` opt-out set in the config file).
|
|
@@ -466,6 +500,11 @@ export function writeConfigPartial(
|
|
|
466
500
|
delete merged.resolvedTrustedNetworks;
|
|
467
501
|
delete merged.reachability;
|
|
468
502
|
delete merged.agentPathGateEnvOverride;
|
|
503
|
+
delete merged.trustedTypesEnvOverride;
|
|
504
|
+
// Removed settings: a stored copy is dropped on the next save.
|
|
505
|
+
// See change: move-subagents-to-plugin (D6).
|
|
506
|
+
delete merged.subagentTickThrottleMs;
|
|
507
|
+
delete merged.subagentTickThrottleMigrated;
|
|
469
508
|
|
|
470
509
|
// Write
|
|
471
510
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -484,6 +523,11 @@ export function writeConfigPartial(
|
|
|
484
523
|
if (partial.windowsGitSource === "auto" || partial.windowsGitSource === "host" || partial.windowsGitSource === "bundled") {
|
|
485
524
|
setWindowsGitSourceSetting(partial.windowsGitSource);
|
|
486
525
|
}
|
|
526
|
+
// windowsBashSource: same live-apply contract (moves bundled usr/bin on the
|
|
527
|
+
// spawn PATH for new children). See change: fix-windows-bundled-bash-exe.
|
|
528
|
+
if (partial.windowsBashSource === "bundled" || partial.windowsBashSource === "host") {
|
|
529
|
+
setWindowsBashSourceSetting(partial.windowsBashSource);
|
|
530
|
+
}
|
|
487
531
|
|
|
488
532
|
return { success: true, restartRequired };
|
|
489
533
|
} catch (err: any) {
|
|
@@ -492,38 +536,12 @@ export function writeConfigPartial(
|
|
|
492
536
|
}
|
|
493
537
|
|
|
494
538
|
/**
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
* so flipping the default alone reaches nobody. The MARKER, not the value,
|
|
500
|
-
* decides: a `0` written after the marker exists is a deliberate opt-out and is
|
|
501
|
-
* kept. Boot path only (`cli.ts`, beside `ensureConfig()`) — never `loadConfig`,
|
|
502
|
-
* which every bridge process calls and which must never write.
|
|
503
|
-
* See change: heal-orphaned-tool-cards-on-session-end (design D5).
|
|
539
|
+
* Seed the Windows git/bash source state from the stored config so spawn-env
|
|
540
|
+
* augmentation (ToolResolver.buildSpawnEnv + PTY) places the bundled tree
|
|
541
|
+
* correctly. Called once at server startup; reads, never writes. No-op effect
|
|
542
|
+
* on macOS/Linux. See change: embed-git-bash-on-windows, fix-windows-bundled-bash-exe.
|
|
504
543
|
*/
|
|
505
|
-
export function
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
try {
|
|
509
|
-
existing = JSON.parse(fs.readFileSync(file, "utf-8"));
|
|
510
|
-
} catch {
|
|
511
|
-
return; // no config yet — `ensureConfig()` seeds the marker itself
|
|
512
|
-
}
|
|
513
|
-
// A file that parses to a non-object (array, string) is not a config; writing
|
|
514
|
-
// through it would persist junk keys via the merge writer's spread.
|
|
515
|
-
if (typeof existing !== "object" || existing === null || Array.isArray(existing)) return;
|
|
516
|
-
if (existing.subagentTickThrottleMigrated !== undefined) return;
|
|
517
|
-
if (existing.subagentTickThrottleMs !== 0) {
|
|
518
|
-
// Nothing to rewrite, but STAMP the marker: a config that never carried the
|
|
519
|
-
// key (hand-pruned, or seeded by something other than `ensureConfig`) would
|
|
520
|
-
// otherwise stay markerless, and a deliberate `0` set later through the
|
|
521
|
-
// settings UI would be migrated away on the next boot.
|
|
522
|
-
writeConfigPartial({ subagentTickThrottleMigrated: true });
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
writeConfigPartial({
|
|
526
|
-
subagentTickThrottleMs: DEFAULT_SUBAGENT_TICK_THROTTLE_MS,
|
|
527
|
-
subagentTickThrottleMigrated: true,
|
|
528
|
-
});
|
|
544
|
+
export function seedWindowsSourceSettings(cfg: DashboardConfig = loadConfig()): void {
|
|
545
|
+
setWindowsGitSourceSetting(cfg.windowsGitSource);
|
|
546
|
+
setWindowsBashSourceSetting(cfg.windowsBashSource);
|
|
529
547
|
}
|