@blackbelt-technology/pi-agent-dashboard 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -0
- package/README.md +17 -12
- package/docs/architecture.md +973 -224
- package/package.json +29 -18
- package/packages/extension/package.json +16 -9
- package/packages/extension/src/bridge-context.ts +6 -0
- package/packages/extension/src/bridge-handlers/dispatch.ts +54 -69
- package/packages/extension/src/bridge-handlers/forwarders.ts +19 -42
- package/packages/extension/src/bridge-handlers/instance.ts +21 -12
- package/packages/extension/src/bridge-handlers/lifecycle.ts +84 -40
- package/packages/extension/src/bridge-shutdown.ts +44 -0
- package/packages/extension/src/bridge.ts +272 -260
- package/packages/extension/src/command-handler.ts +26 -31
- package/packages/extension/src/connection.ts +123 -31
- package/packages/extension/src/credential-guard.ts +300 -0
- package/packages/extension/src/custom-entry-forward.ts +27 -18
- package/packages/extension/src/default-model-apply.ts +83 -0
- package/packages/extension/src/flow-event-wiring.ts +19 -95
- package/packages/extension/src/followup-drain.ts +19 -5
- package/packages/extension/src/path-gate/decide.ts +68 -5
- package/packages/extension/src/path-gate/handler.ts +16 -8
- package/packages/extension/src/path-gate/index.ts +2 -2
- package/packages/extension/src/path-gate/roots.ts +15 -3
- package/packages/extension/src/path-gate/suppression.ts +3 -0
- package/packages/extension/src/pi-env.d.ts +8 -1
- package/packages/extension/src/pi-retry-settings.ts +11 -2
- package/packages/extension/src/plugin-event-forward-registry.ts +90 -14
- package/packages/extension/src/preview-path-link.ts +151 -0
- package/packages/extension/src/project-init/scaffold.ts +98 -35
- package/packages/extension/src/project-trust.ts +24 -15
- package/packages/extension/src/provider-model-cache.ts +118 -0
- package/packages/extension/src/provider-register.ts +428 -28
- package/packages/extension/src/retry-tracker.ts +90 -7
- package/packages/extension/src/role-manager.ts +4 -2
- package/packages/extension/src/role-model-tools.ts +21 -4
- package/packages/extension/src/server-auto-start.ts +68 -2
- package/packages/extension/src/server-launcher.ts +26 -8
- package/packages/extension/src/session-sync.ts +11 -12
- package/packages/extension/src/spawn-new-session.ts +22 -0
- package/packages/extension/src/steer-buffer.ts +164 -0
- package/packages/extension/src/stream-forward-buffer.ts +64 -15
- package/packages/extension/src/sudo-askpass/config-reader.ts +32 -0
- package/packages/extension/src/sudo-askpass/controller.ts +405 -0
- package/packages/extension/src/sudo-askpass/helper-script.ts +69 -0
- package/packages/extension/src/sudo-askpass/in-flight.ts +79 -0
- package/packages/extension/src/sudo-askpass/index.ts +11 -0
- package/packages/extension/src/sudo-askpass/install.ts +143 -0
- package/packages/extension/src/sudo-askpass/password-cache.ts +118 -0
- package/packages/extension/src/sudo-askpass/prompt-text.ts +55 -0
- package/packages/extension/src/sudo-askpass/protocol.ts +18 -0
- package/packages/extension/src/sudo-askpass/sudo-mask-registry.ts +52 -0
- package/packages/extension/src/terminal-reload.ts +19 -5
- package/packages/extension/src/tool-update-filter-registry.ts +210 -0
- package/packages/extension/src/vault-redaction.ts +4 -3
- package/packages/server/package.json +17 -14
- package/packages/server/src/access/access-denials.ts +8 -0
- package/packages/server/src/access/access-grants.ts +244 -58
- package/packages/server/src/access/access-plane.ts +7 -0
- package/packages/server/src/access/containment-gate.ts +66 -21
- package/packages/server/src/access/denial-hold.ts +3 -0
- package/packages/server/src/access/grant-coordinator.ts +17 -1
- package/packages/server/src/access/named-grant.ts +3 -0
- package/packages/server/src/access/pending-grant-registry.ts +32 -5
- package/packages/server/src/access/pi-trust-mirror-service.ts +7 -1
- package/packages/server/src/access/planes.ts +1 -0
- package/packages/server/src/access/verified-read.ts +24 -7
- package/packages/server/src/acp-bridge/acp-session-adapter.ts +10 -2
- package/packages/server/src/acp-bridge/server-requests.ts +10 -4
- package/packages/server/src/agent-events/agent-event-hub.ts +1 -1
- package/packages/server/src/auth/audit-log.ts +28 -0
- package/packages/server/src/auth/auth-plugin.ts +188 -15
- package/packages/server/src/auth/auth.ts +80 -0
- package/packages/server/src/auth/bridge-ticket-eligibility.ts +53 -10
- package/packages/server/src/auth/cors-origin.ts +14 -1
- package/packages/server/src/auth/credential-envelope.ts +233 -0
- package/packages/server/src/auth/credential-key-worker.d.mts +16 -0
- package/packages/server/src/auth/credential-key-worker.mjs +108 -0
- package/packages/server/src/auth/credential-key.ts +479 -0
- package/packages/server/src/auth/credential-migration.ts +162 -0
- package/packages/server/src/auth/csp-report-paths.ts +0 -5
- package/packages/server/src/auth/csp.ts +74 -36
- package/packages/server/src/auth/device-proof.ts +202 -0
- package/packages/server/src/auth/duplicate-cookie-gate.ts +271 -0
- package/packages/server/src/auth/host-admission.ts +7 -0
- package/packages/server/src/auth/host-gate.ts +13 -2
- package/packages/server/src/auth/localhost-guard.ts +50 -23
- package/packages/server/src/auth/locked-json-file.ts +68 -6
- package/packages/server/src/auth/models-json-store.ts +269 -0
- package/packages/server/src/auth/mutation-origin-gate.ts +5 -2
- package/packages/server/src/auth/node-guard.ts +36 -49
- package/packages/server/src/auth/plugin-credential-store.ts +81 -10
- package/packages/server/src/auth/provider-auth-storage.ts +208 -11
- package/packages/server/src/auth/provider-block-checks.ts +321 -0
- package/packages/server/src/auth/provider-host-detect.ts +151 -0
- package/packages/server/src/auth/provider-key-file.ts +71 -0
- package/packages/server/src/auth/provider-readiness.ts +91 -0
- package/packages/server/src/auth/route-tier-gate.ts +3 -2
- package/packages/server/src/auth/vertex-key-check.ts +140 -0
- package/packages/server/src/auth/ws-ticket.ts +1 -1
- package/packages/server/src/browse.ts +73 -20
- package/packages/server/src/browser-handlers/acp-guard.ts +1 -4
- package/packages/server/src/browser-handlers/directory-handler.ts +11 -24
- package/packages/server/src/browser-handlers/session-action-handler.ts +158 -62
- package/packages/server/src/browser-handlers/spawn-choice.ts +138 -1
- package/packages/server/src/browser-handlers/subscription-handler.ts +46 -1
- package/packages/server/src/build-plugin-send-prompt.ts +18 -0
- package/packages/server/src/cli/credentials-command.ts +555 -0
- package/packages/server/src/cli.ts +21 -16
- package/packages/server/src/config-api.ts +34 -38
- package/packages/server/src/config-snapshot.ts +149 -0
- package/packages/server/src/directory-service.ts +33 -14
- package/packages/server/src/embed-lifecycle/idle-reaper.ts +13 -3
- package/packages/server/src/event-wiring.ts +181 -101
- package/packages/server/src/git-worktree/ensure-worktree.ts +185 -0
- package/packages/server/src/git-worktree/git-operations.ts +1 -1
- package/packages/server/src/git-worktree/repo-lock.ts +42 -0
- package/packages/server/src/git-worktree/start-worktree-init.ts +151 -0
- package/packages/server/src/git-worktree/worktree-init.ts +5 -1
- package/packages/server/src/identity/http-road-classification.ts +5 -1
- package/packages/server/src/identity/identity-floor.ts +5 -2
- package/packages/server/src/identity/ws-message-scope.ts +10 -3
- package/packages/server/src/identity/ws-road-classification.ts +2 -1
- package/packages/server/src/lib/browse-roots.ts +13 -2
- package/packages/server/src/lib/content-disposition.ts +20 -0
- package/packages/server/src/lib/dashboard-state-guard.ts +304 -21
- package/packages/server/src/lib/eml.ts +2 -2
- package/packages/server/src/lib/frame-policy-probe.ts +308 -0
- package/packages/server/src/lib/frame-policy-test-seam.ts +99 -0
- package/packages/server/src/lib/frame-policy-verdict.ts +125 -0
- package/packages/server/src/lib/grep.ts +4 -1
- package/packages/server/src/lib/index-html.ts +2 -2
- package/packages/server/src/lib/mention-fuzzy-index.ts +263 -0
- package/packages/server/src/lib/office-preview.ts +47 -10
- package/packages/server/src/lib/path-containment.ts +45 -12
- package/packages/server/src/lib/resolve-file-mention.ts +230 -38
- package/packages/server/src/lib/resolve-mentions-batch.ts +143 -0
- package/packages/server/src/lib/writable-handler-target.ts +4 -0
- package/packages/server/src/lib/writable-md-target.ts +22 -0
- package/packages/server/src/lifecycle/boot-parent-liveness.ts +10 -25
- package/packages/server/src/lifecycle/credential-exit-barrier.ts +207 -0
- package/packages/server/src/lifecycle/exit-signal.ts +43 -0
- package/packages/server/src/live-server/capability-redact.ts +21 -5
- package/packages/server/src/live-server/live-capability.ts +416 -52
- package/packages/server/src/live-server/live-csp-report.ts +1 -1
- package/packages/server/src/live-server/live-csp.ts +64 -16
- package/packages/server/src/live-server/live-log.ts +5 -1
- package/packages/server/src/live-server/live-server-manager.ts +11 -0
- package/packages/server/src/live-server/live-server-proxy.ts +268 -52
- package/packages/server/src/live-server/live-static.ts +4 -1
- package/packages/server/src/live-server/preview-dispatch.ts +286 -0
- package/packages/server/src/live-server/preview-observe.ts +53 -0
- package/packages/server/src/live-server/preview-origin.ts +182 -0
- package/packages/server/src/live-server/preview-path-bridge.ts +70 -0
- package/packages/server/src/live-server/preview-path-store.ts +420 -0
- package/packages/server/src/live-server/preview-path.ts +40 -0
- package/packages/server/src/live-server/preview-pool.ts +385 -0
- package/packages/server/src/live-server/preview-preflight.ts +41 -0
- package/packages/server/src/live-server/preview-reserve.ts +44 -0
- package/packages/server/src/live-server/preview-tier.ts +217 -0
- package/packages/server/src/live-server/preview-viewers.ts +54 -0
- package/packages/server/src/live-server/preview-ws-registry.ts +43 -0
- package/packages/server/src/model-proxy/custom-provider-discovery.ts +4 -2
- package/packages/server/src/model-proxy/internal-auth-storage.ts +5 -1
- package/packages/server/src/model-proxy/internal-registry.ts +283 -21
- package/packages/server/src/model-proxy/models-block-apply.ts +291 -0
- package/packages/server/src/model-proxy/pi-models-validator.ts +164 -0
- package/packages/server/src/model-proxy/registry-singleton.ts +44 -9
- package/packages/server/src/model-proxy/server-model-runtime.ts +17 -0
- package/packages/server/src/openspec/readiness.ts +1 -1
- package/packages/server/src/package/provider-probe.ts +194 -5
- package/packages/server/src/pairing/browser-gateway.ts +140 -42
- package/packages/server/src/pairing/device-key-intake.ts +120 -0
- package/packages/server/src/pairing/paired-devices.ts +370 -8
- package/packages/server/src/pairing/pairing.ts +69 -7
- package/packages/server/src/pairing/{subagent-resync-routing.ts → resync-requester-registry.ts} +6 -10
- package/packages/server/src/pairing/ws-tier-gate.ts +74 -0
- package/packages/server/src/pending/pending-attach-registry.ts +15 -0
- package/packages/server/src/pending/pending-initial-prompt-registry.ts +15 -0
- package/packages/server/src/persistence/memory-event-store.ts +251 -296
- package/packages/server/src/persistence/preferences-store.ts +52 -2
- package/packages/server/src/pi/bridge-contention.ts +84 -2
- package/packages/server/src/pi/host-project-trust.ts +15 -9
- package/packages/server/src/pi/pi-gateway.ts +208 -21
- package/packages/server/src/pi/provisional-registration.ts +4 -1
- package/packages/server/src/pi/resource-toggle-trust.ts +17 -6
- package/packages/server/src/pi-agent-settings.ts +95 -301
- package/packages/server/src/pi-default-remirror.ts +89 -0
- package/packages/server/src/plugin-append-event.ts +35 -0
- package/packages/server/src/plugin-entry-stats.ts +61 -0
- package/packages/server/src/plugin-local-request.ts +207 -0
- package/packages/server/src/plugin-ownership.ts +111 -0
- package/packages/server/src/plugin-policy-registry.ts +297 -0
- package/packages/server/src/plugin-request-lane.ts +92 -16
- package/packages/server/src/preferences-relay.ts +20 -0
- package/packages/server/src/project-seed.ts +347 -0
- package/packages/server/src/push/push-transports/webhook-url.ts +8 -5
- package/packages/server/src/questions/question-store.ts +3 -2
- package/packages/server/src/routes/access-routes.ts +23 -6
- package/packages/server/src/routes/acme-routes.ts +14 -4
- package/packages/server/src/routes/agent-event-stream-routes.ts +1 -1
- package/packages/server/src/routes/file-routes.ts +327 -86
- package/packages/server/src/routes/file-write-binary-routes.ts +20 -4
- package/packages/server/src/routes/frame-policy-routes.ts +215 -0
- package/packages/server/src/routes/git-routes.ts +29 -78
- package/packages/server/src/routes/grep-routes.ts +26 -0
- package/packages/server/src/routes/live-server-routes.ts +198 -4
- package/packages/server/src/routes/models-introspection-routes.ts +1 -1
- package/packages/server/src/routes/openspec-routes.ts +17 -3
- package/packages/server/src/routes/pairing-routes.ts +200 -11
- package/packages/server/src/routes/pi-settings-routes.ts +2 -0
- package/packages/server/src/routes/preferences-auto-name-routes.ts +5 -2
- package/packages/server/src/routes/preferences-claude-compat-routes.ts +49 -0
- package/packages/server/src/routes/provider-auth-routes.ts +167 -9
- package/packages/server/src/routes/provider-override-routes.ts +158 -0
- package/packages/server/src/routes/provider-routes.ts +348 -86
- package/packages/server/src/routes/session-routes.ts +25 -22
- package/packages/server/src/routes/system-routes.ts +87 -39
- package/packages/server/src/rpc-keeper/keeper-manager.ts +196 -25
- package/packages/server/src/rpc-keeper/keeper.cjs +37 -23
- package/packages/server/src/runtime-overlay/extension-reload.ts +16 -10
- package/packages/server/src/runtime-overlay/runtime-stager.ts +4 -2
- package/packages/server/src/server.ts +512 -175
- package/packages/server/src/services/cli-service.ts +59 -10
- package/packages/server/src/services/secrets-resolver.ts +46 -30
- package/packages/server/src/session/custom-event-group-annotation.ts +3 -3
- package/packages/server/src/session/custom-event-group-resolver.ts +10 -5
- package/packages/server/src/session/death-reason.ts +11 -7
- package/packages/server/src/session/event-status-extraction.ts +5 -1
- package/packages/server/src/session/memory-session-manager.ts +24 -2
- package/packages/server/src/session/open-tool-calls.ts +81 -47
- package/packages/server/src/session/pid-target.ts +127 -0
- package/packages/server/src/session/replay-compaction.ts +18 -5
- package/packages/server/src/session/seed-discovered-history.ts +85 -0
- package/packages/server/src/session/server-pid-context.ts +14 -0
- package/packages/server/src/session/session-api.ts +78 -29
- package/packages/server/src/session/session-archive.ts +7 -0
- package/packages/server/src/session/session-bootstrap.ts +9 -54
- package/packages/server/src/session/session-load-worker-pool.ts +11 -1
- package/packages/server/src/session/session-load-worker.ts +22 -3
- package/packages/server/src/spawn-process/abort-spawned-run.ts +28 -9
- package/packages/server/src/spawn-process/acp-spawn.ts +8 -2
- package/packages/server/src/spawn-process/headless-pid-registry.ts +383 -72
- package/packages/server/src/spawn-process/link-register.ts +42 -0
- package/packages/server/src/spawn-process/plugin-spawn-choice.ts +48 -0
- package/packages/server/src/spawn-process/plugin-spawn-worktree.ts +290 -0
- package/packages/server/src/spawn-process/process-classifier.ts +8 -3
- package/packages/server/src/spawn-process/process-manager.ts +61 -6
- package/packages/server/src/spawn-process/restored-identity.ts +112 -0
- package/packages/server/src/spawn-process/session-terminator.ts +179 -18
- package/packages/server/src/spawn-process/spawn-env-contributors.ts +2 -1
- package/packages/server/src/spawn-process/spawn-failure-log.ts +9 -0
- package/packages/server/src/spawn-process/spawn-register-watchdog.ts +44 -19
- package/packages/server/src/sudo-credential/relay.ts +337 -0
- package/packages/server/src/terminal/terminal-gateway.ts +10 -0
- package/packages/server/src/tls/sources/acme/credentials.ts +3 -2
- package/packages/server/src/tls/sources/acme/runtime.ts +2 -1
- package/packages/server/src/vault/vault-delivery-hub.ts +17 -1
- package/packages/server/src/vault/vault-routes.ts +9 -2
- package/packages/server/src/vault/vault-store.ts +87 -24
- package/packages/server/vendor/xlsx/LICENSE +201 -0
- package/packages/server/vendor/xlsx/PROVENANCE.json +13 -0
- package/packages/server/vendor/xlsx/xlsx.d.mts +1065 -0
- package/packages/server/vendor/xlsx/xlsx.mjs +28228 -0
- package/packages/shared/package.json +4 -2
- package/packages/shared/src/agent-credential-files.ts +32 -0
- package/packages/shared/src/browser-protocol.ts +137 -57
- package/packages/shared/src/canvas-detect.ts +1 -1
- package/packages/shared/src/canvas-types.ts +2 -2
- package/packages/shared/src/config.ts +73 -136
- package/packages/shared/src/containment-guard.ts +14 -4
- package/packages/shared/src/credential-encryption.ts +87 -0
- package/packages/shared/src/custom-event-groups.ts +2 -0
- package/packages/shared/src/dashboard-plugin/claude-compat.ts +159 -0
- package/packages/shared/src/dashboard-plugin/host-api.ts +1 -1
- package/packages/shared/src/dashboard-plugin/manifest-types.ts +46 -0
- package/packages/shared/src/dashboard-plugin/plugin-status.ts +4 -3
- package/packages/shared/src/dashboard-plugin/replay-entry-types.ts +46 -0
- package/packages/shared/src/dashboard-plugin/slot-props.ts +2 -0
- package/packages/shared/src/dashboard-plugin/slot-types.ts +1 -1
- package/packages/shared/src/dashboard-plugin/ui-primitives.ts +11 -3
- package/packages/shared/src/device-key-proof.ts +309 -0
- package/packages/shared/src/event-forward-declaration.ts +85 -12
- package/packages/shared/src/forbidden-subjects.ts +126 -14
- package/packages/shared/src/heap-limits.ts +0 -30
- package/packages/shared/src/host-admission.ts +2 -1
- package/packages/shared/src/index.ts +7 -6
- package/packages/shared/src/live-server.ts +20 -0
- package/packages/shared/src/mcp/verb-tiers.generated.ts +1 -3
- package/packages/shared/src/models-json-reader.ts +41 -0
- package/packages/shared/src/network-denial-signal.ts +15 -0
- package/packages/shared/src/node-version.ts +63 -60
- package/packages/shared/src/pairing-knock-client.ts +92 -8
- package/packages/shared/src/pi-agent-settings-lock.ts +311 -0
- package/packages/shared/src/pi-path-compare.ts +31 -0
- package/packages/shared/src/pi-settings-schema.ts +52 -9
- package/packages/shared/src/pi-trust-mirror-snapshot.ts +16 -4
- package/packages/shared/src/pi-trust-mirror-types.ts +2 -0
- package/packages/shared/src/pi-trust-mirror.ts +18 -8
- package/packages/shared/src/pi-trust-resource-digest.ts +18 -12
- package/packages/shared/src/pid-namespace.ts +86 -0
- package/packages/shared/src/platform/native-ts-register.mjs +1 -1
- package/packages/shared/src/platform/process.ts +404 -1
- package/packages/shared/src/platform/resolve-pi-shell.ts +38 -9
- package/packages/shared/src/platform/spawn-runtime.ts +193 -7
- package/packages/shared/src/preview-egress.ts +56 -2
- package/packages/shared/src/preview-origins.ts +398 -0
- package/packages/shared/src/prompt-answer.ts +9 -5
- package/packages/shared/src/protocol.ts +147 -85
- package/packages/shared/src/provider-env-catalog.ts +413 -0
- package/packages/shared/src/provider-overrides.ts +112 -0
- package/packages/shared/src/question-types.ts +6 -0
- package/packages/shared/src/recommended-extensions.ts +79 -26
- package/packages/shared/src/renderer-by-ext.ts +5 -2
- package/packages/shared/src/rest-api.ts +93 -3
- package/packages/shared/src/role-schema.ts +24 -0
- package/packages/shared/src/route-tiers.ts +94 -3
- package/packages/shared/src/runtime-overlay/compat.ts +70 -6
- package/packages/shared/src/secret-patterns.ts +49 -0
- package/packages/shared/src/source-matching.ts +2 -2
- package/packages/shared/src/state-replay.ts +40 -24
- package/packages/shared/src/sudo-credential.ts +71 -0
- package/packages/shared/src/tool-path-resolve.ts +16 -1
- package/packages/shared/src/tool-registry/strategies.ts +1 -1
- package/packages/shared/src/tool-workdir.ts +56 -0
- package/packages/shared/src/trusted-types-mode.ts +72 -0
- package/packages/shared/src/types.ts +68 -109
- package/packages/shared/src/vertex-regions.ts +81 -0
- package/packages/shared/src/ws-message-tiers.ts +10 -3
- package/packages/extension/src/subagent-fanout-admission.ts +0 -234
- package/packages/extension/src/subagent-forward-sites.ts +0 -69
- package/packages/extension/src/subagent-frame-buffer.ts +0 -245
- package/packages/extension/src/subagent-frame-strip.ts +0 -109
- package/packages/extension/src/subagent-saturation.ts +0 -196
- package/packages/extension/src/subagent-tick-throttle.ts +0 -252
- package/packages/shared/src/anthropic-messages-source.ts +0 -8
- package/packages/shared/src/dashboard-plugin/anthropic-peer-names.ts +0 -9
- package/packages/shared/src/dashboard-plugin/subagent-types.ts +0 -219
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import type { HostGateMode } from "./host-admission.js";
|
|
20
20
|
import { DEFAULT_MEMORY_LIMITS, type MemoryLimitsConfig, MIN_REPLAY_WINDOW, type ReplayWindowMode } from "./memory-limits.js";
|
|
21
21
|
import type { WindowsBashSourceSetting, WindowsGitSourceSetting } from "./platform/select-git-source.js";
|
|
22
|
+
import { type PreviewOriginsConfig, parsePreviewOrigins } from "./preview-origins.js";
|
|
22
23
|
import {
|
|
23
24
|
defaultSchemeForPort,
|
|
24
25
|
isValidPort,
|
|
@@ -31,6 +32,7 @@ import {
|
|
|
31
32
|
routeKey,
|
|
32
33
|
} from "./server-routes.js";
|
|
33
34
|
import { inferPlatform, pathKey } from "./session-group-path.js";
|
|
35
|
+
import { DEFAULT_SUDO_CREDENTIAL_PROMPT, parseSudoCredentialPrompt, type SudoCredentialPromptConfig } from "./sudo-credential.js";
|
|
34
36
|
import { isTier, type Tier } from "./tiers.js";
|
|
35
37
|
import {
|
|
36
38
|
providerSupportsMode,
|
|
@@ -220,6 +222,12 @@ export interface TrustedPluginEntry {
|
|
|
220
222
|
export interface AuthConfig {
|
|
221
223
|
secret: string;
|
|
222
224
|
providers: Record<string, AuthProviderConfig>;
|
|
225
|
+
/**
|
|
226
|
+
* User allowlist (emails, usernames, `*@domain` wildcards). Empty/unset admits every
|
|
227
|
+
* account ONLY for non-public providers; a public provider (`github`, `google`, or an
|
|
228
|
+
* issuer on the public IdP host set) refuses login while this AND `groupTiers` are both
|
|
229
|
+
* empty. See change: close-security-map-high-findings (D3).
|
|
230
|
+
*/
|
|
223
231
|
allowedUsers?: string[];
|
|
224
232
|
bypassUrls?: string[];
|
|
225
233
|
bypassHosts?: string[];
|
|
@@ -242,8 +250,10 @@ export interface AuthConfig {
|
|
|
242
250
|
/**
|
|
243
251
|
* OIDC `groups` claim → session tier. Configured ⇒ highest matching tier
|
|
244
252
|
* wins and no match refuses login (fail closed). Absent ⇒ legacy
|
|
245
|
-
* behaviour (`allowedUsers`, tier `operate`).
|
|
246
|
-
*
|
|
253
|
+
* behaviour (`allowedUsers`, tier `operate`). Config-file-only (the Settings save
|
|
254
|
+
* preserves the stored value); a non-empty map also lifts the open-enrolment refusal
|
|
255
|
+
* of public providers. See change: add-passkey-user-auth (D4),
|
|
256
|
+
* close-security-map-high-findings (D3).
|
|
247
257
|
*/
|
|
248
258
|
groupTiers?: Record<string, Tier>;
|
|
249
259
|
/**
|
|
@@ -267,8 +277,6 @@ export {
|
|
|
267
277
|
MIN_HEAP_MB,
|
|
268
278
|
type ServerHeapConfig,
|
|
269
279
|
type SessionHeapConfig,
|
|
270
|
-
SUBAGENT_HEAP_GUIDANCE_MB,
|
|
271
|
-
subagentHeapBudget,
|
|
272
280
|
} from "./heap-limits.js";
|
|
273
281
|
/**
|
|
274
282
|
* Memory-limit types + defaults live in a BROWSER-SAFE module and are
|
|
@@ -470,11 +478,15 @@ export const SESSION_LIST_LIMITS = {
|
|
|
470
478
|
|
|
471
479
|
export interface KeeperLogConfig {
|
|
472
480
|
/**
|
|
473
|
-
* When `true`, per-session keepers
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
481
|
+
* Gates ALL keeper log output. When `true`, per-session keepers write
|
|
482
|
+
* `keeper-<sessionId>.log` (lifecycle lines plus pi's stdout/stderr,
|
|
483
|
+
* including full model API frames, size-bounded by `maxBytes`) and the
|
|
484
|
+
* server captures keeper startup stderr into `keeper-launch-<sessionId>.log`.
|
|
485
|
+
* When `false` (the default), a new headless session creates no keeper log
|
|
486
|
+
* file of any kind. The server derives `PI_KEEPER_CAPTURE_PI_OUTPUT` from
|
|
487
|
+
* this value alone (an inherited env value cannot override it). Debug-only.
|
|
488
|
+
* See changes: add-keeper-output-capture-toggle,
|
|
489
|
+
* keeper-log-toggle-gates-all-output.
|
|
478
490
|
*/
|
|
479
491
|
capturePiOutput: boolean;
|
|
480
492
|
/**
|
|
@@ -858,23 +870,6 @@ export function resolveKrokiEndpoint(
|
|
|
858
870
|
|
|
859
871
|
export type PluginsConfig = Record<string, Record<string, unknown>>;
|
|
860
872
|
|
|
861
|
-
/**
|
|
862
|
-
* Resource-saturation thresholds consulted by subagent admission. Each metric is
|
|
863
|
-
* optional and names the domain it measures — mixing the domains up makes a
|
|
864
|
-
* threshold silently never fire on a machine loaded by *many* sessions whose
|
|
865
|
-
* parent process reads low.
|
|
866
|
-
*
|
|
867
|
-
* See change: bound-subagent-fanout-under-host-pressure (D5).
|
|
868
|
-
*/
|
|
869
|
-
export interface SubagentSaturationThresholds {
|
|
870
|
-
/** PROCESS domain: event-loop delay max (ms) over the admission window. */
|
|
871
|
-
eventLoopDelayMs?: number;
|
|
872
|
-
/** PROCESS domain: this process's CPU share (percent). */
|
|
873
|
-
cpuPercent?: number;
|
|
874
|
-
/** MACHINE domain: the system 1-minute load average. */
|
|
875
|
-
loadAvg1m?: number;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
873
|
/**
|
|
879
874
|
* Access-grant prompting. Prompting is ON by default (an absent key means on);
|
|
880
875
|
* an explicit value is kept as written. Automated environments set
|
|
@@ -1065,6 +1060,15 @@ export interface DashboardConfig {
|
|
|
1065
1060
|
autoStart: boolean;
|
|
1066
1061
|
autoShutdown: boolean;
|
|
1067
1062
|
shutdownIdleSeconds: number;
|
|
1063
|
+
/**
|
|
1064
|
+
* Auto-seed the `coding` profile's missing artifacts into a project's config
|
|
1065
|
+
* root when a folder is pinned, a session registers, or the boot sweep runs.
|
|
1066
|
+
* `false` is the exact-no-op rollback path: every trigger point short-circuits
|
|
1067
|
+
* and nothing is written. Absent resolves to `true` (active by default), so an
|
|
1068
|
+
* unset config seeds — the switch exists to opt OUT.
|
|
1069
|
+
* Read once in `createServer` and applied via `configureProjectSeed`.
|
|
1070
|
+
*/
|
|
1071
|
+
autoSeedProjects: boolean;
|
|
1068
1072
|
/**
|
|
1069
1073
|
* Cold-start readiness budget (ms) the bridge's auto-spawn allows before
|
|
1070
1074
|
* giving up its health poll and reporting "readiness timeout". The spawned
|
|
@@ -1084,38 +1088,6 @@ export interface DashboardConfig {
|
|
|
1084
1088
|
* budget > poll invariant. See change: add-configurable-readiness-timeout.
|
|
1085
1089
|
*/
|
|
1086
1090
|
readinessTimeoutMs: number;
|
|
1087
|
-
/**
|
|
1088
|
-
* Coalescing window (ms) the bridge applies to subagent `Agent` ticks on the
|
|
1089
|
-
* `tool_execution_update` carrier. `0` disables the throttle entirely and is
|
|
1090
|
-
* the byte-identical rollback path. Only Agent updates carrying a
|
|
1091
|
-
* `details.agentId` are affected; every other tool forwards 1:1.
|
|
1092
|
-
* Non-numeric / negative values fall back to the default.
|
|
1093
|
-
* See change: reduce-bridge-tick-bandwidth (D2/D3/D4).
|
|
1094
|
-
*/
|
|
1095
|
-
subagentTickThrottleMs: number;
|
|
1096
|
-
/**
|
|
1097
|
-
* Effective cap on concurrently in-flight `Agent` children in one session.
|
|
1098
|
-
* `0` disables admission entirely and is the exact-no-op rollback path.
|
|
1099
|
-
* Absent resolves to `DEFAULT_MAX_CONCURRENT_SUBAGENTS` (active by default).
|
|
1100
|
-
* A negative / non-integer / non-numeric value is malformed and resolves to
|
|
1101
|
-
* the fail-open (uncapped) path — NOT to the disable path: a malformed gate
|
|
1102
|
-
* must never refuse a call.
|
|
1103
|
-
* See change: bound-subagent-fanout-under-host-pressure (D1/D6).
|
|
1104
|
-
*/
|
|
1105
|
-
maxConcurrentSubagents: number;
|
|
1106
|
-
/**
|
|
1107
|
-
* Optional resource-saturation thresholds. Any metric at/above its threshold
|
|
1108
|
-
* narrows the effective cap to 1 (never 0). Absent metric = "no signal".
|
|
1109
|
-
* See change: bound-subagent-fanout-under-host-pressure (D5).
|
|
1110
|
-
*/
|
|
1111
|
-
subagentSaturation?: SubagentSaturationThresholds;
|
|
1112
|
-
/**
|
|
1113
|
-
* One-shot marker: the boot migration has already rewritten a materialized
|
|
1114
|
-
* `0` to the current default. Declared here so the settings round-trip
|
|
1115
|
-
* PRESERVES it — a stripped marker re-runs the migration and silently undoes
|
|
1116
|
-
* a deliberate `0`. See change: heal-orphaned-tool-cards-on-session-end (D5).
|
|
1117
|
-
*/
|
|
1118
|
-
subagentTickThrottleMigrated?: boolean;
|
|
1119
1091
|
/**
|
|
1120
1092
|
* Max items per `POST /api/git/worktree/remove-batch` request. Each item is
|
|
1121
1093
|
* a synchronous, blocking removal on the event loop (D7), so the item count
|
|
@@ -1262,6 +1234,14 @@ export interface DashboardConfig {
|
|
|
1262
1234
|
* See change: add-host-allowlist-admission.
|
|
1263
1235
|
*/
|
|
1264
1236
|
hostGate: HostGateConfig;
|
|
1237
|
+
/**
|
|
1238
|
+
* Security knobs. `trustedTypes` is the RAW `security.trustedTypes` value
|
|
1239
|
+
* (`"off" | "report" | "enforce"` when valid); it is deliberately not
|
|
1240
|
+
* validated here — `resolveTrustedTypesMode` (trusted-types-mode.ts) owns
|
|
1241
|
+
* validation and warns once at server start. Never seeded by `ensureConfig()`.
|
|
1242
|
+
* See change: enforce-trusted-types-default.
|
|
1243
|
+
*/
|
|
1244
|
+
security?: { trustedTypes?: unknown };
|
|
1265
1245
|
/**
|
|
1266
1246
|
* Access-grant prompting settings. Default `{ promptEnabled: true }`.
|
|
1267
1247
|
* See change: add-access-grant-dialog.
|
|
@@ -1270,6 +1250,8 @@ export interface DashboardConfig {
|
|
|
1270
1250
|
/** Dashboard trust → pi project_trust mirror. See change: mirror-dashboard-trust-to-pi. */
|
|
1271
1251
|
piTrustMirror: PiTrustMirrorConfig;
|
|
1272
1252
|
agentPathGate: AgentPathGateConfig;
|
|
1253
|
+
/** Sudo credential prompt (default on). See change: add-sudo-credential-prompt. */
|
|
1254
|
+
sudoCredentialPrompt: SudoCredentialPromptConfig;
|
|
1273
1255
|
/** Per-process bridge activation (see `BridgeActivationConfig`). */
|
|
1274
1256
|
bridge: BridgeActivationConfig;
|
|
1275
1257
|
/** Networks trusted for full access without authentication (CIDR, wildcard, exact IP) */
|
|
@@ -1296,7 +1278,15 @@ export interface DashboardConfig {
|
|
|
1296
1278
|
* forwarding header (`ssh -L`, socat), which is otherwise undetectable. Absent / any
|
|
1297
1279
|
* other value → automatic detection. See change: improve-canvas-html-and-url-ux (D5).
|
|
1298
1280
|
*/
|
|
1299
|
-
liveServer?: {
|
|
1281
|
+
liveServer?: {
|
|
1282
|
+
previewExposure?: "exposed";
|
|
1283
|
+
/**
|
|
1284
|
+
* Preview-origin tiers (validated + normalised; invalid tiers already dropped, `issues` come from
|
|
1285
|
+
* `parsePreviewOrigins` on the raw file). Kept independently of `previewExposure`.
|
|
1286
|
+
* See change: serve-live-previews-on-capability-origin (D12).
|
|
1287
|
+
*/
|
|
1288
|
+
previewOrigins?: PreviewOriginsConfig;
|
|
1289
|
+
};
|
|
1300
1290
|
/** Merged trustedNetworks + auth.bypassHosts (deduplicated). Computed at load time. */
|
|
1301
1291
|
resolvedTrustedNetworks: string[];
|
|
1302
1292
|
/** CORS allowed origins for cross-origin client hosting */
|
|
@@ -1677,15 +1667,6 @@ export function resolveDashboardPorts(
|
|
|
1677
1667
|
return { port, piPort };
|
|
1678
1668
|
}
|
|
1679
1669
|
|
|
1680
|
-
/**
|
|
1681
|
-
* Throttle ON by default: the un-throttled Agent tick stream is what starves a
|
|
1682
|
-
* fan-out parent. Existing installs carry a materialized `0` from
|
|
1683
|
-
* `ensureConfig`, rewritten once by the server-boot migration.
|
|
1684
|
-
* See change: reduce-bridge-tick-bandwidth (D4),
|
|
1685
|
-
* heal-orphaned-tool-cards-on-session-end (D5).
|
|
1686
|
-
*/
|
|
1687
|
-
export const DEFAULT_SUBAGENT_TICK_THROTTLE_MS = 500;
|
|
1688
|
-
|
|
1689
1670
|
/** Inert default: no trusted resolver plugins beyond the bundled one, no policy. */
|
|
1690
1671
|
export const DEFAULT_IDENTITY: IdentityConfig = {
|
|
1691
1672
|
trustedResolverPlugins: [],
|
|
@@ -1740,56 +1721,6 @@ export function parseIdentityConfig(raw: any): IdentityConfig {
|
|
|
1740
1721
|
};
|
|
1741
1722
|
}
|
|
1742
1723
|
|
|
1743
|
-
/**
|
|
1744
|
-
* Default cap on concurrently in-flight `Agent` children per session.
|
|
1745
|
-
*
|
|
1746
|
-
* Fixed by Decision 1's measurement table in the change's `design.md`: it must
|
|
1747
|
-
* sit below every observed fatal fan-out width (3, 4, 7) so the default admits
|
|
1748
|
-
* no census batch unchanged, and the spec asserts the property "defined, at
|
|
1749
|
-
* least 2, below 3" rather than a literal so the constant survives that
|
|
1750
|
-
* measurement. The value is therefore 2.
|
|
1751
|
-
* See change: bound-subagent-fanout-under-host-pressure (D1/D6).
|
|
1752
|
-
*/
|
|
1753
|
-
export const DEFAULT_MAX_CONCURRENT_SUBAGENTS = 2;
|
|
1754
|
-
|
|
1755
|
-
/**
|
|
1756
|
-
* Resolve `maxConcurrentSubagents` from a raw config value.
|
|
1757
|
-
*
|
|
1758
|
-
* Absent → the active default. An explicit non-negative integer (including the
|
|
1759
|
-
* `0` disable value) is honoured. Anything else is MALFORMED and resolves to
|
|
1760
|
-
* the fail-open (uncapped) path — never to the disable path and never to a
|
|
1761
|
-
* refusal, because a broken gate refusing every `Agent` call is strictly worse
|
|
1762
|
-
* than the crash this capability mitigates.
|
|
1763
|
-
* See change: bound-subagent-fanout-under-host-pressure (D6).
|
|
1764
|
-
*/
|
|
1765
|
-
export function resolveMaxConcurrentSubagents(raw: unknown): number {
|
|
1766
|
-
if (raw === undefined) return DEFAULT_MAX_CONCURRENT_SUBAGENTS;
|
|
1767
|
-
if (typeof raw === "number" && Number.isInteger(raw) && raw >= 0) return raw;
|
|
1768
|
-
return Number.POSITIVE_INFINITY;
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
/**
|
|
1772
|
-
* Parse the optional saturation thresholds. A threshold that is not a positive
|
|
1773
|
-
* finite number is dropped (absent = "no signal from that metric", not zero);
|
|
1774
|
-
* an object with no usable threshold at all collapses to `undefined`.
|
|
1775
|
-
* See change: bound-subagent-fanout-under-host-pressure (D5).
|
|
1776
|
-
*/
|
|
1777
|
-
export function parseSubagentSaturation(raw: any): SubagentSaturationThresholds | undefined {
|
|
1778
|
-
if (!raw || typeof raw !== "object") return undefined;
|
|
1779
|
-
const positive = (v: unknown): number | undefined =>
|
|
1780
|
-
typeof v === "number" && Number.isFinite(v) && v > 0 ? v : undefined;
|
|
1781
|
-
const thresholds: SubagentSaturationThresholds = {
|
|
1782
|
-
eventLoopDelayMs: positive(raw.eventLoopDelayMs),
|
|
1783
|
-
cpuPercent: positive(raw.cpuPercent),
|
|
1784
|
-
loadAvg1m: positive(raw.loadAvg1m),
|
|
1785
|
-
};
|
|
1786
|
-
return thresholds.eventLoopDelayMs === undefined &&
|
|
1787
|
-
thresholds.cpuPercent === undefined &&
|
|
1788
|
-
thresholds.loadAvg1m === undefined
|
|
1789
|
-
? undefined
|
|
1790
|
-
: thresholds;
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
1724
|
const DEFAULTS: DashboardConfig = {
|
|
1794
1725
|
plugins: {},
|
|
1795
1726
|
terminals: { ...DEFAULT_TERMINALS_CONFIG },
|
|
@@ -1804,12 +1735,11 @@ const DEFAULTS: DashboardConfig = {
|
|
|
1804
1735
|
autoStart: true,
|
|
1805
1736
|
autoShutdown: false,
|
|
1806
1737
|
shutdownIdleSeconds: 300,
|
|
1738
|
+
autoSeedProjects: true,
|
|
1807
1739
|
// Historical hardcoded value of the bridge cold-start health window — the
|
|
1808
1740
|
// shared health-poll constant, referenced rather than respelled so the two
|
|
1809
1741
|
// cannot drift. See change: add-configurable-readiness-timeout.
|
|
1810
1742
|
readinessTimeoutMs: HEALTH_CHECK_TIMEOUT_MS,
|
|
1811
|
-
subagentTickThrottleMs: DEFAULT_SUBAGENT_TICK_THROTTLE_MS,
|
|
1812
|
-
maxConcurrentSubagents: DEFAULT_MAX_CONCURRENT_SUBAGENTS,
|
|
1813
1743
|
removeBatchCap: DEFAULT_REMOVE_BATCH_CAP,
|
|
1814
1744
|
spawnStrategy: "headless",
|
|
1815
1745
|
tunnel: {
|
|
@@ -1826,6 +1756,7 @@ const DEFAULTS: DashboardConfig = {
|
|
|
1826
1756
|
accessGrants: { promptEnabled: true },
|
|
1827
1757
|
piTrustMirror: { ...DEFAULT_PI_TRUST_MIRROR, sources: { ...DEFAULT_PI_TRUST_MIRROR.sources } },
|
|
1828
1758
|
agentPathGate: { ...DEFAULT_AGENT_PATH_GATE },
|
|
1759
|
+
sudoCredentialPrompt: { ...DEFAULT_SUDO_CREDENTIAL_PROMPT },
|
|
1829
1760
|
bridge: { ...DEFAULT_BRIDGE_ACTIVATION },
|
|
1830
1761
|
defaultModel: "",
|
|
1831
1762
|
defaultThinkingLevel: "",
|
|
@@ -2578,6 +2509,21 @@ export function knownServersNeedMigration(): boolean {
|
|
|
2578
2509
|
}
|
|
2579
2510
|
}
|
|
2580
2511
|
|
|
2512
|
+
/**
|
|
2513
|
+
* `liveServer` block: `previewExposure` (only `"exposed"` is kept) and
|
|
2514
|
+
* `previewOrigins`, kept independently of each other. A non-object block → defaults.
|
|
2515
|
+
* Never throws; per-tier problems are reported by `parsePreviewOrigins`.
|
|
2516
|
+
* See change: serve-live-previews-on-capability-origin (D12).
|
|
2517
|
+
*/
|
|
2518
|
+
function parseLiveServerConfig(raw: unknown): { liveServer?: NonNullable<DashboardConfig["liveServer"]> } {
|
|
2519
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return {};
|
|
2520
|
+
const r = raw as { previewExposure?: unknown; previewOrigins?: unknown };
|
|
2521
|
+
const liveServer: NonNullable<DashboardConfig["liveServer"]> = {};
|
|
2522
|
+
if (r.previewExposure === "exposed") liveServer.previewExposure = "exposed";
|
|
2523
|
+
if (r.previewOrigins !== undefined) liveServer.previewOrigins = parsePreviewOrigins(r.previewOrigins).value;
|
|
2524
|
+
return Object.keys(liveServer).length > 0 ? { liveServer } : {};
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2581
2527
|
function parseTrustedNetworks(raw: any): string[] {
|
|
2582
2528
|
if (!Array.isArray(raw)) return [];
|
|
2583
2529
|
return raw.filter((entry: unknown) => typeof entry === "string" && entry.length > 0);
|
|
@@ -2763,7 +2709,6 @@ export function loadConfig(): DashboardConfig {
|
|
|
2763
2709
|
const rawStrategy = parsed.spawnStrategy;
|
|
2764
2710
|
const spawnStrategy: SpawnStrategy =
|
|
2765
2711
|
VALID_SPAWN_STRATEGIES.includes(rawStrategy) ? rawStrategy : defaults.spawnStrategy;
|
|
2766
|
-
const subagentSaturation = parseSubagentSaturation(parsed.subagentSaturation);
|
|
2767
2712
|
|
|
2768
2713
|
const result: DashboardConfig = {
|
|
2769
2714
|
port: parsed.port ?? defaults.port,
|
|
@@ -2772,6 +2717,8 @@ export function loadConfig(): DashboardConfig {
|
|
|
2772
2717
|
autoStart: parsed.autoStart ?? defaults.autoStart,
|
|
2773
2718
|
autoShutdown: parsed.autoShutdown ?? defaults.autoShutdown,
|
|
2774
2719
|
shutdownIdleSeconds: parsed.shutdownIdleSeconds ?? defaults.shutdownIdleSeconds,
|
|
2720
|
+
autoSeedProjects:
|
|
2721
|
+
typeof parsed.autoSeedProjects === "boolean" ? parsed.autoSeedProjects : defaults.autoSeedProjects,
|
|
2775
2722
|
readinessTimeoutMs:
|
|
2776
2723
|
typeof parsed.readinessTimeoutMs === "number" &&
|
|
2777
2724
|
Number.isFinite(parsed.readinessTimeoutMs) &&
|
|
@@ -2781,15 +2728,6 @@ export function loadConfig(): DashboardConfig {
|
|
|
2781
2728
|
Math.max(READINESS_TIMEOUT_MIN_MS, parsed.readinessTimeoutMs),
|
|
2782
2729
|
)
|
|
2783
2730
|
: defaults.readinessTimeoutMs,
|
|
2784
|
-
subagentTickThrottleMs:
|
|
2785
|
-
typeof parsed.subagentTickThrottleMs === "number" &&
|
|
2786
|
-
Number.isFinite(parsed.subagentTickThrottleMs) &&
|
|
2787
|
-
parsed.subagentTickThrottleMs >= 0
|
|
2788
|
-
? parsed.subagentTickThrottleMs
|
|
2789
|
-
: defaults.subagentTickThrottleMs,
|
|
2790
|
-
maxConcurrentSubagents: resolveMaxConcurrentSubagents(parsed.maxConcurrentSubagents),
|
|
2791
|
-
...(subagentSaturation ? { subagentSaturation } : {}),
|
|
2792
|
-
...(parsed.subagentTickThrottleMigrated === true ? { subagentTickThrottleMigrated: true } : {}),
|
|
2793
2731
|
removeBatchCap: clampRemoveBatchCap(parsed.removeBatchCap),
|
|
2794
2732
|
spawnStrategy,
|
|
2795
2733
|
tunnel: normalizeTunnelConfig(parsed.tunnel, defaults.tunnel),
|
|
@@ -2817,10 +2755,13 @@ export function loadConfig(): DashboardConfig {
|
|
|
2817
2755
|
? parsed.allowedHosts.filter((h: unknown): h is string => typeof h === "string")
|
|
2818
2756
|
: defaults.allowedHosts,
|
|
2819
2757
|
hostGate: { mode: parseHostGateMode(parsed.hostGate?.mode) },
|
|
2758
|
+
...(parsed.security?.trustedTypes !== undefined
|
|
2759
|
+
? { security: { trustedTypes: parsed.security.trustedTypes } }
|
|
2760
|
+
: {}),
|
|
2820
2761
|
trustedNetworks: parseTrustedNetworks(parsed.trustedNetworks),
|
|
2821
2762
|
...(parseNetworkConfig(parsed.network) ? { network: parseNetworkConfig(parsed.network) } : {}),
|
|
2822
2763
|
requireLocalProof: typeof parsed.requireLocalProof === "boolean" ? parsed.requireLocalProof : true,
|
|
2823
|
-
...(parsed.liveServer
|
|
2764
|
+
...parseLiveServerConfig(parsed.liveServer),
|
|
2824
2765
|
resolvedTrustedNetworks: [],
|
|
2825
2766
|
cors: {
|
|
2826
2767
|
allowedOrigins: Array.isArray(parsed.cors?.allowedOrigins)
|
|
@@ -2854,6 +2795,7 @@ export function loadConfig(): DashboardConfig {
|
|
|
2854
2795
|
},
|
|
2855
2796
|
piTrustMirror: parsePiTrustMirror(parsed.piTrustMirror),
|
|
2856
2797
|
agentPathGate: parseAgentPathGate(parsed.agentPathGate),
|
|
2798
|
+
sudoCredentialPrompt: parseSudoCredentialPrompt(parsed.sudoCredentialPrompt),
|
|
2857
2799
|
bridge: parseBridgeActivation(parsed.bridge),
|
|
2858
2800
|
knownServers: parseKnownServers(parsed.knownServers),
|
|
2859
2801
|
reattachPlacement: parseReattachPlacement(parsed.reattachPlacement),
|
|
@@ -2923,11 +2865,6 @@ export function ensureConfig(): void {
|
|
|
2923
2865
|
autoShutdown: DEFAULTS.autoShutdown,
|
|
2924
2866
|
shutdownIdleSeconds: DEFAULTS.shutdownIdleSeconds,
|
|
2925
2867
|
readinessTimeoutMs: DEFAULTS.readinessTimeoutMs,
|
|
2926
|
-
subagentTickThrottleMs: DEFAULTS.subagentTickThrottleMs,
|
|
2927
|
-
// Seeded unconditionally: a fresh install is already AT the new default, so
|
|
2928
|
-
// a later deliberate `0` must not be re-migrated on the next boot.
|
|
2929
|
-
// See change: heal-orphaned-tool-cards-on-session-end (D5).
|
|
2930
|
-
subagentTickThrottleMigrated: true,
|
|
2931
2868
|
removeBatchCap: DEFAULTS.removeBatchCap,
|
|
2932
2869
|
spawnStrategy: DEFAULTS.spawnStrategy,
|
|
2933
2870
|
tunnel: DEFAULTS.tunnel,
|
|
@@ -23,13 +23,23 @@ export interface PathDecision {
|
|
|
23
23
|
readonly viaGrant: boolean;
|
|
24
24
|
/** The exact string passed to the decision function. */
|
|
25
25
|
readonly resolved: string;
|
|
26
|
+
/**
|
|
27
|
+
* The real path the decision was made on (symlinks resolved once). Callers open THIS, bound by
|
|
28
|
+
* `decidedReal`, never the lexical `resolved`. `undefined` on every refusal.
|
|
29
|
+
* See change: close-local-listener-and-egress-gaps.
|
|
30
|
+
*/
|
|
31
|
+
readonly real: string | undefined;
|
|
26
32
|
readonly [pathDecisionBrand]: true;
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
/**
|
|
30
|
-
* True only when `decision` allowed AND was made for exactly `resolved
|
|
31
|
-
*
|
|
36
|
+
* True only when `decision` allowed AND was made for exactly `resolved` AND carries the real path it
|
|
37
|
+
* decided on (an admitting decision without `real` cannot bind an open, so it fails closed). Sync, so
|
|
38
|
+
* static analysis treats a branch on it as a guard for `resolved`; narrows `real` to `string`.
|
|
32
39
|
*/
|
|
33
|
-
export function containmentAllows
|
|
34
|
-
|
|
40
|
+
export function containmentAllows<D extends PathDecision>(
|
|
41
|
+
decision: D,
|
|
42
|
+
resolved: string,
|
|
43
|
+
): decision is D & { readonly real: string } {
|
|
44
|
+
return decision.allowed === true && decision.resolved === resolved && decision.real !== undefined;
|
|
35
45
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants for credential-at-rest encryption: keychain identity, file
|
|
3
|
+
* ids, the envelope magic line, the lock/key reason codes and the fixed
|
|
4
|
+
* reason → remedy table (used by the vault status, the page and refusal
|
|
5
|
+
* messages). Import-free leaf: no node built-ins, safe for client bundles.
|
|
6
|
+
*
|
|
7
|
+
* Remedy texts are fixed, non-secret strings: never interpolate key material.
|
|
8
|
+
* See change: encrypt-credentials-at-rest (D3, D4, D5, D6, D12).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Keychain service. Distinct from `pi-dashboard`, which users own for `keychain:` refs (D4, D10). */
|
|
12
|
+
export const CREDENTIAL_KEYCHAIN_SERVICE = "pi-dashboard-credential-key";
|
|
13
|
+
|
|
14
|
+
/** Keychain account (item username). */
|
|
15
|
+
export const CREDENTIAL_KEYCHAIN_ACCOUNT = "data-key-v1";
|
|
16
|
+
|
|
17
|
+
/** Env var naming the explicit key file. When set it is the ONLY key source (D6). */
|
|
18
|
+
export const DATA_KEY_FILE_ENV = "PI_DASHBOARD_DATA_KEY_FILE";
|
|
19
|
+
|
|
20
|
+
/** Identity of an encrypted credential file; bound into the AEAD additional data. */
|
|
21
|
+
export const CREDENTIAL_FILE_IDS = ["plugin-credentials", "vault"] as const;
|
|
22
|
+
export type CredentialFileId = (typeof CREDENTIAL_FILE_IDS)[number];
|
|
23
|
+
|
|
24
|
+
/** On-disk basename of each credential file (the agent credential guard protects these). */
|
|
25
|
+
export const CREDENTIAL_FILE_BASENAMES: Readonly<Record<CredentialFileId, string>> = {
|
|
26
|
+
"plugin-credentials": "plugin-credentials.json",
|
|
27
|
+
vault: "vault.json",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** Any file whose first line starts with this is an envelope and is never "corrupt" (D2). */
|
|
31
|
+
export const ENVELOPE_MAGIC_PREFIX = "pi-dashboard-encrypted:";
|
|
32
|
+
|
|
33
|
+
/** First line of a v1 envelope file. */
|
|
34
|
+
export const ENVELOPE_MAGIC_V1 = "pi-dashboard-encrypted:v1";
|
|
35
|
+
|
|
36
|
+
/** Reasons the data key is not available (the key state's reason). */
|
|
37
|
+
export const CREDENTIAL_KEY_FAILURE_REASONS = [
|
|
38
|
+
"keychain_unavailable",
|
|
39
|
+
"keychain_timeout",
|
|
40
|
+
"key_missing",
|
|
41
|
+
"key_file_missing",
|
|
42
|
+
"key_file_invalid",
|
|
43
|
+
"key_file_insecure",
|
|
44
|
+
"key_uninitialized",
|
|
45
|
+
] as const;
|
|
46
|
+
export type CredentialKeyFailureReason = (typeof CREDENTIAL_KEY_FAILURE_REASONS)[number];
|
|
47
|
+
|
|
48
|
+
/** Reasons a file is locked: a key failure, or a problem with the envelope itself. */
|
|
49
|
+
export const CREDENTIAL_LOCK_REASONS = [
|
|
50
|
+
...CREDENTIAL_KEY_FAILURE_REASONS,
|
|
51
|
+
"key_mismatch",
|
|
52
|
+
"unsupported_format",
|
|
53
|
+
"envelope_damaged",
|
|
54
|
+
] as const;
|
|
55
|
+
export type CredentialLockReason = (typeof CREDENTIAL_LOCK_REASONS)[number];
|
|
56
|
+
|
|
57
|
+
/** Narrowing guard. An unknown future reason must still render as locked, never as ok. */
|
|
58
|
+
export function isCredentialLockReason(value: unknown): value is CredentialLockReason {
|
|
59
|
+
return typeof value === "string" && (CREDENTIAL_LOCK_REASONS as readonly string[]).includes(value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const KEY_FILE_HINT =
|
|
63
|
+
`Set ${DATA_KEY_FILE_ENV} to an owner-only file holding \`openssl rand -base64 32\` and restart the server.`;
|
|
64
|
+
const RESET_HINT =
|
|
65
|
+
"Restore the key, or run `pi-dashboard credentials reset --vault` " +
|
|
66
|
+
"(`--plugin-credentials` for the plugin credential file) with the server stopped and enter the credentials again.";
|
|
67
|
+
|
|
68
|
+
/** Reason → remedy (decision G3). Every reason has a non-empty, non-secret remedy. */
|
|
69
|
+
export const CREDENTIAL_REASON_REMEDY: Readonly<Record<CredentialLockReason, string>> = {
|
|
70
|
+
keychain_unavailable: `The OS keychain cannot be used. ${KEY_FILE_HINT}`,
|
|
71
|
+
keychain_timeout: `The OS keychain did not answer in time. ${KEY_FILE_HINT}`,
|
|
72
|
+
key_missing: `The data key is missing. ${RESET_HINT}`,
|
|
73
|
+
key_file_missing: `The key file named by ${DATA_KEY_FILE_ENV} does not exist. ${KEY_FILE_HINT}`,
|
|
74
|
+
key_file_invalid: `The key file named by ${DATA_KEY_FILE_ENV} is not a readable base64 32-byte key. ${KEY_FILE_HINT}`,
|
|
75
|
+
key_file_insecure: `The key file named by ${DATA_KEY_FILE_ENV} is readable by other users. Run chmod 600 on it, then restart the server.`,
|
|
76
|
+
key_uninitialized: "The data key has not been loaded yet. Restart the server.",
|
|
77
|
+
key_mismatch: `The file was encrypted with a different key. ${RESET_HINT}`,
|
|
78
|
+
unsupported_format: "The file uses a newer encryption format. Upgrade the dashboard.",
|
|
79
|
+
envelope_damaged: "The encrypted file is damaged. Restore it from a backup, or reset it with `pi-dashboard credentials reset`.",
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** The remedy for a lock reason. Unknown reasons get the generic fallback. */
|
|
83
|
+
export function credentialRemedy(reason: string): string {
|
|
84
|
+
return isCredentialLockReason(reason)
|
|
85
|
+
? CREDENTIAL_REASON_REMEDY[reason]
|
|
86
|
+
: "The credential file is locked. Check the dashboard server log.";
|
|
87
|
+
}
|
|
@@ -60,6 +60,8 @@ export const SHIPPED_CUSTOM_EVENT_GROUPS: readonly CustomEventGroup[] = [
|
|
|
60
60
|
{ id: "goals", label: "Goals", pattern: "^pi-goal-hermes:", default: true },
|
|
61
61
|
// Forensic records (subagent fan-out admission refusals). Hidden by default:
|
|
62
62
|
// the refused tool call already shows its reason. See change: render-unclaimed-custom-entries.
|
|
63
|
+
// No longer written (the admission gate was removed, change: subagent-queue-visibility);
|
|
64
|
+
// kept so OLD transcripts still carrying these entries stay hidden by default.
|
|
63
65
|
{ id: "diagnostics", label: "Diagnostics", pattern: "^subagent-admission-refused$", default: false },
|
|
64
66
|
];
|
|
65
67
|
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude subscription compat — rewrites pi's built-in `docs` prompt section.
|
|
3
|
+
*
|
|
4
|
+
* Anthropic bills a Claude subscription request as "extra usage" when pi's
|
|
5
|
+
* default `docs` section carries the lines "pi itself" and "pi packages".
|
|
6
|
+
* When the dashboard compat switch is on and the model provider is
|
|
7
|
+
* `anthropic`, the handlers replace exactly those two phrases inside that one
|
|
8
|
+
* section. They never force the whole prompt, never touch other sections, and
|
|
9
|
+
* never rename tools.
|
|
10
|
+
*
|
|
11
|
+
* `before_agent_start` (pi 1.4.0): an extension-supplied `sections.docs`
|
|
12
|
+
* replaces the built-in section; the body is read from the rendered
|
|
13
|
+
* `event.systemPrompt`, anchored on pi's first docs line, rewritten only when
|
|
14
|
+
* exactly one such block exists.
|
|
15
|
+
*
|
|
16
|
+
* `before_provider_request`: pi 1.4 sends a session's FIRST system message as
|
|
17
|
+
* Anthropic's `system` field for the session's whole life (pi-ai
|
|
18
|
+
* `anthropic-messages.js` buildParams); a later section change reaches the
|
|
19
|
+
* wire only as a mid-conversation patch. So the outgoing `system` text is
|
|
20
|
+
* rewritten too, covering sessions started before the switch was on.
|
|
21
|
+
*
|
|
22
|
+
* The dashboard extension registers `claudeCompatExtension` on EVERY pi it
|
|
23
|
+
* loads into (main sessions, subagent children, any session built from the
|
|
24
|
+
* settings packages), so no plugin or package must opt in.
|
|
25
|
+
*
|
|
26
|
+
* See change: retire-anthropic-messages-bridge (design D1, D2, D6b),
|
|
27
|
+
* seed-claude-compat-on-upgrade.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const DOCS_BLOCK_RE = /<docs>\n(Pi documentation \([\s\S]*?)\n<\/docs>/g;
|
|
31
|
+
const REPLACEMENTS: ReadonlyArray<readonly [string, string]> = [
|
|
32
|
+
["pi itself", "the cli itself"],
|
|
33
|
+
["pi packages", "cli packages"],
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
type CompatState = "applied" | "off" | "not-anthropic" | "custom-or-forced" | "no-match";
|
|
37
|
+
|
|
38
|
+
/** Replace the flagged phrases. Idempotent: rewritten text has none left. */
|
|
39
|
+
export function rewriteDocsSection(text: string): { text: string; replaced: number } {
|
|
40
|
+
let out = text;
|
|
41
|
+
let replaced = 0;
|
|
42
|
+
for (const [from, to] of REPLACEMENTS) {
|
|
43
|
+
const parts = out.split(from);
|
|
44
|
+
replaced += parts.length - 1;
|
|
45
|
+
out = parts.join(to);
|
|
46
|
+
}
|
|
47
|
+
return { text: out, replaced };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Body of pi's built-in docs section when the prompt holds exactly one anchored block. */
|
|
51
|
+
function extractDocsBody(systemPrompt: string): { body: string } | { count: number } {
|
|
52
|
+
const matches = [...systemPrompt.matchAll(DOCS_BLOCK_RE)];
|
|
53
|
+
if (matches.length !== 1) return { count: matches.length };
|
|
54
|
+
return { body: matches[0]![1]! };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface PromptOptionsLike {
|
|
58
|
+
sections?: Record<string, string>;
|
|
59
|
+
customPrompt?: string;
|
|
60
|
+
forceSystemPrompt?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface BeforeAgentStartLike {
|
|
64
|
+
systemPrompt?: string;
|
|
65
|
+
systemPromptOptions?: PromptOptionsLike;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface PiLike {
|
|
69
|
+
on(name: string, handler: (event: unknown, ctx: unknown) => unknown): unknown;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function decide(event: BeforeAgentStartLike, ctx: unknown, switchOn: boolean): { state: CompatState; docs?: string } {
|
|
73
|
+
if (!switchOn) return { state: "off" };
|
|
74
|
+
const provider = (ctx as { model?: { provider?: unknown } } | undefined)?.model?.provider;
|
|
75
|
+
if (provider !== "anthropic") return { state: "not-anthropic" };
|
|
76
|
+
const opts = event.systemPromptOptions;
|
|
77
|
+
if (!opts || typeof opts !== "object") return { state: "custom-or-forced" };
|
|
78
|
+
if (opts.customPrompt || opts.forceSystemPrompt !== undefined) return { state: "custom-or-forced" };
|
|
79
|
+
const found = extractDocsBody(typeof event.systemPrompt === "string" ? event.systemPrompt : "");
|
|
80
|
+
if ("count" in found) return { state: found.count === 0 ? "custom-or-forced" : "no-match" };
|
|
81
|
+
const { text, replaced } = rewriteDocsSection(found.body);
|
|
82
|
+
if (replaced === 0) return { state: "no-match" };
|
|
83
|
+
return { state: "applied", docs: text };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type SystemBlock = { type?: unknown; text?: unknown };
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Rewrite the one anchored docs block in an Anthropic payload's `system`
|
|
90
|
+
* (string or text-block array). Returns a new payload, or `undefined` when
|
|
91
|
+
* there is nothing to change: no `system`, zero or several anchored blocks
|
|
92
|
+
* across all system text, or no flagged phrase left.
|
|
93
|
+
*/
|
|
94
|
+
export function rewritePayloadSystem(payload: unknown): unknown {
|
|
95
|
+
if (!payload || typeof payload !== "object") return undefined;
|
|
96
|
+
const system = (payload as { system?: unknown }).system;
|
|
97
|
+
const texts: string[] =
|
|
98
|
+
typeof system === "string"
|
|
99
|
+
? [system]
|
|
100
|
+
: Array.isArray(system)
|
|
101
|
+
? system.map((b: SystemBlock) => (b && b.type === "text" && typeof b.text === "string" ? b.text : ""))
|
|
102
|
+
: [];
|
|
103
|
+
const blockCounts = texts.map((t) => [...t.matchAll(DOCS_BLOCK_RE)].length);
|
|
104
|
+
if (blockCounts.reduce((a, b) => a + b, 0) !== 1) return undefined;
|
|
105
|
+
const idx = blockCounts.indexOf(1);
|
|
106
|
+
let replaced = 0;
|
|
107
|
+
const newText = texts[idx]!.replace(DOCS_BLOCK_RE, (_whole, body: string) => {
|
|
108
|
+
const r = rewriteDocsSection(body);
|
|
109
|
+
replaced = r.replaced;
|
|
110
|
+
return `<docs>\n${r.text}\n</docs>`;
|
|
111
|
+
});
|
|
112
|
+
if (replaced === 0) return undefined;
|
|
113
|
+
const newSystem =
|
|
114
|
+
typeof system === "string"
|
|
115
|
+
? newText
|
|
116
|
+
: (system as SystemBlock[]).map((b, i) => (i === idx ? { ...b, text: newText } : b));
|
|
117
|
+
return { ...(payload as object), system: newSystem };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Extension factory. `readSwitch` returns the live switch value. One factory
|
|
122
|
+
* call per pi instance keeps its own log state, so
|
|
123
|
+
* each session or agent logs its state once and again only on change.
|
|
124
|
+
*/
|
|
125
|
+
export function claudeCompatExtension(readSwitch: () => boolean): (pi: PiLike) => void {
|
|
126
|
+
return (pi: PiLike) => {
|
|
127
|
+
if (!pi || typeof pi.on !== "function") return;
|
|
128
|
+
let lastState: CompatState | undefined;
|
|
129
|
+
pi.on("before_agent_start", (event: unknown, ctx: unknown) => {
|
|
130
|
+
try {
|
|
131
|
+
const e = (event ?? {}) as BeforeAgentStartLike;
|
|
132
|
+
const { state, docs } = decide(e, ctx, readSwitch());
|
|
133
|
+
if (docs !== undefined && e.systemPromptOptions) {
|
|
134
|
+
e.systemPromptOptions.sections ??= {};
|
|
135
|
+
e.systemPromptOptions.sections.docs = docs;
|
|
136
|
+
}
|
|
137
|
+
if (state !== lastState) {
|
|
138
|
+
lastState = state;
|
|
139
|
+
const line = `[dashboard] claude-compat: state=${state}`;
|
|
140
|
+
if (state === "no-match") console.warn(`${line} (switch on, but pi's docs wording did not match; requests may be billed as extra usage)`);
|
|
141
|
+
else console.log(line);
|
|
142
|
+
}
|
|
143
|
+
} catch {
|
|
144
|
+
/* compat is best-effort; never block a run */
|
|
145
|
+
}
|
|
146
|
+
return undefined;
|
|
147
|
+
});
|
|
148
|
+
pi.on("before_provider_request", (event: unknown, ctx: unknown) => {
|
|
149
|
+
try {
|
|
150
|
+
if (!readSwitch()) return undefined;
|
|
151
|
+
const provider = (ctx as { model?: { provider?: unknown } } | undefined)?.model?.provider;
|
|
152
|
+
if (provider !== "anthropic") return undefined;
|
|
153
|
+
return rewritePayloadSystem((event as { payload?: unknown } | undefined)?.payload);
|
|
154
|
+
} catch {
|
|
155
|
+
return undefined; /* best-effort; never block a request */
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/** Current host API version. Bump per the snapshot rules in `scripts/host-api-surface.mjs`. */
|
|
14
|
-
export const PLUGIN_HOST_API_VERSION = "
|
|
14
|
+
export const PLUGIN_HOST_API_VERSION = "2.2.0";
|
|
15
15
|
|
|
16
16
|
/** A manifest `hostApi` range: `^MAJOR.MINOR[.PATCH]` or an exact `MAJOR.MINOR.PATCH`. */
|
|
17
17
|
export type HostApiRange = string;
|