@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
|
@@ -13,24 +13,56 @@
|
|
|
13
13
|
* and to every rung of an offered-ancestor ladder (task 7b.2), so a ladder can
|
|
14
14
|
* never walk up into a forbidden directory.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
16
|
+
* The `sensitive` list also holds the CLI credential directories (`~/.aws`, `~/.config/gh`,
|
|
17
|
+
* `~/.gnupg`, `~/.kube`, `~/.docker`), the exact file `~/.netrc` and the browser user-data
|
|
18
|
+
* roots of the running platform (`browserProfileRoots`). Because every consumer funnels through
|
|
19
|
+
* this module (agent gate flag, grant backstop, ladder, planes, YOLO roots + auto-allow,
|
|
20
|
+
* provisioning, cwd verdicts, allow-once admission, agent grant acceptance, trust-mirror deny,
|
|
21
|
+
* browse roots), one edit here makes them sensitive everywhere. Residual drift: the local lists in
|
|
22
|
+
* `server/src/access/provisioning.ts` and `shared/src/pi-trust-mirror.ts` are left alone (supersets
|
|
23
|
+
* are verified); a fourth list is NOT added.
|
|
24
|
+
*
|
|
25
|
+
* See change: add-access-grants-and-review; harden-agent-tool-guards (D7).
|
|
17
26
|
*/
|
|
18
27
|
import * as fs from "node:fs";
|
|
19
28
|
import os from "node:os";
|
|
20
29
|
import path from "node:path";
|
|
21
30
|
import { samePath } from "./platform/paths.js";
|
|
22
31
|
|
|
23
|
-
/** Resolve symlinks in the nearest existing ancestor, re-appending the tail. */
|
|
32
|
+
/** Resolve symlinks in the nearest existing ancestor, re-appending the tail. Used for a caller-supplied subject. */
|
|
24
33
|
export function realpathNearestAncestor(p: string): string {
|
|
25
34
|
try {
|
|
26
35
|
return fs.realpathSync(p);
|
|
27
36
|
} catch {
|
|
28
37
|
const parent = path.dirname(p);
|
|
29
|
-
|
|
30
|
-
return path.join(realpathNearestAncestor(parent), path.basename(p));
|
|
38
|
+
return parent === p ? p : path.join(realpathNearestAncestor(parent), path.basename(p));
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Same resolution for the LISTED credential locations (home-derived constants, never request input).
|
|
44
|
+
*
|
|
45
|
+
* Most listed entries do not exist on a given host, and each miss throws ENOENT from `realpathSync`.
|
|
46
|
+
* With the extended sensitive list (harden-agent-tool-guards D7, ~30 entries) that was a measurable
|
|
47
|
+
* cost on the denial path, almost all of it capturing a stack trace nobody reads. The caller
|
|
48
|
+
* (`forbiddenGrantSubjects`) therefore zeroes `Error.stackTraceLimit` around the whole list build, and
|
|
49
|
+
* `cache` shares the parent resolution across entries. No extra fs probe is added: an `lstat` here was a
|
|
50
|
+
* CodeQL js/path-injection sink, while `realpathSync` is not.
|
|
51
|
+
*/
|
|
52
|
+
function realpathListedAncestor(p: string, cache: Map<string, string>): string {
|
|
53
|
+
const hit = cache.get(p);
|
|
54
|
+
if (hit !== undefined) return hit;
|
|
55
|
+
let result: string;
|
|
56
|
+
try {
|
|
57
|
+
result = fs.realpathSync(p);
|
|
58
|
+
} catch {
|
|
59
|
+
const parent = path.dirname(p);
|
|
60
|
+
result = parent === p ? p : path.join(realpathListedAncestor(parent, cache), path.basename(p));
|
|
61
|
+
}
|
|
62
|
+
cache.set(p, result);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
|
|
34
66
|
/** Inputs to the forbidden list. Every field defaults to the running process. */
|
|
35
67
|
export interface ForbiddenSubjectsEnv {
|
|
36
68
|
homedir?: string;
|
|
@@ -85,24 +117,72 @@ const WINDOWS_SYSTEM_DIRS: ReadonlyArray<readonly [string, string]> = [
|
|
|
85
117
|
* and its equality. Shared by the list and every predicate, so a simulated
|
|
86
118
|
* `win32` is Windows end to end (design D8).
|
|
87
119
|
*/
|
|
88
|
-
function pathOps(env?: ForbiddenSubjectsEnv) {
|
|
120
|
+
function pathOps(env?: ForbiddenSubjectsEnv, cache?: Map<string, string>) {
|
|
89
121
|
const platform = env?.platform ?? process.platform;
|
|
90
122
|
const windows = platform === "win32";
|
|
91
123
|
const p = windows ? path.win32 : path.posix;
|
|
92
124
|
const hostIsWindows = process.platform === "win32"; // platform-branch-ok: same path family as the host? (not host behaviour)
|
|
93
125
|
const canonical = (x: string): string => {
|
|
94
126
|
const resolved = p.resolve(x);
|
|
95
|
-
|
|
127
|
+
if (windows !== hostIsWindows) return resolved;
|
|
128
|
+
return cache ? realpathListedAncestor(resolved, cache) : realpathNearestAncestor(resolved);
|
|
96
129
|
};
|
|
97
130
|
const same = (a: string, b: string): boolean => samePath(a, b, platform);
|
|
98
131
|
return { platform, windows, p, canonical, same };
|
|
99
132
|
}
|
|
100
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Browser user-data roots per platform (design D7, NORMATIVE; one test row per browser and platform
|
|
136
|
+
* asserts this table by equality). Chrome equals `chromeUserDataDir` (`chrome-profiles.ts`).
|
|
137
|
+
* Brave is the VENDOR root (`BraveSoftware`, which contains `Brave-Browser/User Data`).
|
|
138
|
+
* Snap / flatpak locations (`~/snap/firefox`, `~/.var/app/*`) are a recorded residual.
|
|
139
|
+
*
|
|
140
|
+
* To add a browser: add its root to the matching platform branch below, add a row to
|
|
141
|
+
* `forbidden-subjects.test.ts` (and the design D7 table), nothing else - every consumer follows.
|
|
142
|
+
*/
|
|
143
|
+
export function browserProfileRoots(
|
|
144
|
+
platform: NodeJS.Platform,
|
|
145
|
+
home: string,
|
|
146
|
+
vars: NodeJS.ProcessEnv,
|
|
147
|
+
): string[] {
|
|
148
|
+
if (platform === "win32") {
|
|
149
|
+
const local = vars.LOCALAPPDATA || path.win32.join(home, "AppData", "Local");
|
|
150
|
+
const roaming = vars.APPDATA || path.win32.join(home, "AppData", "Roaming");
|
|
151
|
+
return [
|
|
152
|
+
path.win32.join(local, "Google", "Chrome", "User Data"),
|
|
153
|
+
path.win32.join(local, "Microsoft", "Edge", "User Data"),
|
|
154
|
+
path.win32.join(local, "BraveSoftware"),
|
|
155
|
+
path.win32.join(roaming, "Mozilla"),
|
|
156
|
+
];
|
|
157
|
+
}
|
|
158
|
+
if (platform === "darwin") {
|
|
159
|
+
const support = path.posix.join(home, "Library", "Application Support");
|
|
160
|
+
return ["Google/Chrome", "Chromium", "Microsoft Edge", "BraveSoftware", "Firefox"].map((d) => path.posix.join(support, d));
|
|
161
|
+
}
|
|
162
|
+
const config = path.posix.join(home, ".config");
|
|
163
|
+
return [
|
|
164
|
+
...["google-chrome", "chromium", "microsoft-edge", "BraveSoftware"].map((d) => path.posix.join(config, d)),
|
|
165
|
+
path.posix.join(home, ".mozilla"),
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** CLI credential directories and files under `$HOME` (same on every platform). */
|
|
170
|
+
const HOME_CREDENTIAL_SUBPATHS: ReadonlyArray<readonly string[]> = [
|
|
171
|
+
[".aws"],
|
|
172
|
+
[".config", "gh"],
|
|
173
|
+
[".gnupg"],
|
|
174
|
+
[".kube"],
|
|
175
|
+
[".docker"],
|
|
176
|
+
// exact file only: `~/.netrc.*` siblings and Windows `_netrc` are a recorded residual
|
|
177
|
+
[".netrc"],
|
|
178
|
+
];
|
|
179
|
+
|
|
101
180
|
export function forbiddenGrantSubjects(env?: ForbiddenSubjectsEnv): {
|
|
102
181
|
whole: string[];
|
|
103
182
|
sensitive: string[];
|
|
104
183
|
} {
|
|
105
|
-
|
|
184
|
+
// One resolution cache per call: the ~30 listed paths share parents (`~/.config/*`, `~/Library/...`).
|
|
185
|
+
const { platform, windows, p, canonical } = pathOps(env, new Map());
|
|
106
186
|
const vars = env?.env ?? process.env;
|
|
107
187
|
const home = env?.homedir ?? os.homedir();
|
|
108
188
|
const system = windows
|
|
@@ -110,8 +190,24 @@ export function forbiddenGrantSubjects(env?: ForbiddenSubjectsEnv): {
|
|
|
110
190
|
: POSIX_SYSTEM_DIRS;
|
|
111
191
|
const root = windows ? p.parse(p.resolve(vars.SystemRoot || "C:\\")).root : "/";
|
|
112
192
|
const whole = [root, home, ...system];
|
|
113
|
-
const sensitive = [
|
|
114
|
-
|
|
193
|
+
const sensitive = [
|
|
194
|
+
p.join(home, ".ssh"),
|
|
195
|
+
p.join(home, ".pi"),
|
|
196
|
+
...HOME_CREDENTIAL_SUBPATHS.map((sub) => p.join(home, ...sub)),
|
|
197
|
+
...browserProfileRoots(platform, home, vars),
|
|
198
|
+
];
|
|
199
|
+
return withoutStackTraces(() => ({ whole: whole.map(canonical), sensitive: sensitive.map(canonical) }));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Run `fn` with error stack capture off: a missing path throws ENOENT from `realpathSync`, and the stack is never read. */
|
|
203
|
+
function withoutStackTraces<T>(fn: () => T): T {
|
|
204
|
+
const limit = Error.stackTraceLimit;
|
|
205
|
+
Error.stackTraceLimit = 0;
|
|
206
|
+
try {
|
|
207
|
+
return fn();
|
|
208
|
+
} finally {
|
|
209
|
+
Error.stackTraceLimit = limit;
|
|
210
|
+
}
|
|
115
211
|
}
|
|
116
212
|
|
|
117
213
|
/**
|
|
@@ -140,8 +236,12 @@ export function isForbiddenGrantSubject(
|
|
|
140
236
|
/** True when `candidate` equals, or is an ancestor of, `other` (selected platform's semantics). */
|
|
141
237
|
function subsumes(candidate: string, other: string, ops: ReturnType<typeof pathOps>): boolean {
|
|
142
238
|
if (ops.same(candidate, other)) return true;
|
|
239
|
+
// POSIX `relative` is a case-sensitive resolve + split: a descendant must be a string-prefix match, so the
|
|
240
|
+
// costly relative() is skipped for the (many) unrelated pairs of the ~30-entry sensitive list.
|
|
241
|
+
if (!ops.windows && !other.startsWith(candidate)) return false;
|
|
143
242
|
const rel = ops.p.relative(candidate, other);
|
|
144
|
-
|
|
243
|
+
// `..x` is a child NAME; only `..` or `..<sep>…` leaves the candidate.
|
|
244
|
+
return rel !== "" && rel !== ".." && !rel.startsWith(`..${ops.p.sep}`) && !ops.p.isAbsolute(rel);
|
|
145
245
|
}
|
|
146
246
|
|
|
147
247
|
/**
|
|
@@ -179,8 +279,20 @@ export function subsumesForbiddenGrantSubject(
|
|
|
179
279
|
* dropped without any test noticing. Callers must pass the subject that will be
|
|
180
280
|
* PERSISTED, not a pre-normalization input (design D15).
|
|
181
281
|
*/
|
|
182
|
-
export function isUngrantableSubject(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
282
|
+
export function isUngrantableSubject(
|
|
283
|
+
subject: string,
|
|
284
|
+
env?: ForbiddenSubjectsEnv,
|
|
285
|
+
/** Precomputed `forbiddenGrantSubjects(env)`, for a caller testing many subjects (e.g. a stored list). */
|
|
286
|
+
sets?: ReturnType<typeof forbiddenGrantSubjects>,
|
|
287
|
+
): boolean {
|
|
288
|
+
// Built once per call (or by the caller) and shared by both halves (design D7); the subject is
|
|
289
|
+
// canonicalised once, not once per half.
|
|
290
|
+
const ops = pathOps(env);
|
|
291
|
+
const real = withoutStackTraces(() => ops.canonical(subject));
|
|
292
|
+
const { whole, sensitive } = sets ?? forbiddenGrantSubjects(env);
|
|
293
|
+
return (
|
|
294
|
+
whole.some((f) => ops.same(real, f)) ||
|
|
295
|
+
sensitive.some((f) => subsumes(f, real, ops)) ||
|
|
296
|
+
[...whole, ...sensitive].some((f) => subsumes(real, f, ops))
|
|
297
|
+
);
|
|
186
298
|
}
|
|
@@ -76,36 +76,6 @@ export const DEFAULT_SERVER_HEAP: ServerHeapConfig = {
|
|
|
76
76
|
maxOldSpaceMb: 1536,
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
/**
|
|
80
|
-
* Per-child heap guidance figure (MB) below which the session ceiling and the
|
|
81
|
-
* subagent fan-out bound are a risky pairing.
|
|
82
|
-
*/
|
|
83
|
-
export const SUBAGENT_HEAP_GUIDANCE_MB = 100;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Subagents run IN-PROCESS and share the parent's single V8 heap, so
|
|
87
|
-
* `maxConcurrentSubagents` is a memory-safety knob once a ceiling is enforced.
|
|
88
|
-
* `+ 1` accounts for the parent itself.
|
|
89
|
-
*
|
|
90
|
-
* One formula, used by both the settings panel and its tests, so the warning
|
|
91
|
-
* the operator sees and the number the test asserts cannot drift.
|
|
92
|
-
* See change: bound-session-heap-and-gc-telemetry (task 10.8).
|
|
93
|
-
*/
|
|
94
|
-
export function subagentHeapBudget(
|
|
95
|
-
maxOldSpaceMb: number,
|
|
96
|
-
maxConcurrentSubagents: number,
|
|
97
|
-
): { perChildMb: number; warn: boolean } {
|
|
98
|
-
if (
|
|
99
|
-
!Number.isFinite(maxOldSpaceMb) ||
|
|
100
|
-
!Number.isFinite(maxConcurrentSubagents) ||
|
|
101
|
-
maxConcurrentSubagents < 0
|
|
102
|
-
) {
|
|
103
|
-
return { perChildMb: 0, warn: false };
|
|
104
|
-
}
|
|
105
|
-
const perChildMb = Math.floor(maxOldSpaceMb / (maxConcurrentSubagents + 1));
|
|
106
|
-
return { perChildMb, warn: perChildMb < SUBAGENT_HEAP_GUIDANCE_MB };
|
|
107
|
-
}
|
|
108
|
-
|
|
109
79
|
/**
|
|
110
80
|
* Heap MB one MiB of `maxTotalEventBytes` budget costs: 768 MiB of serialized
|
|
111
81
|
* event data ≈ 1 GiB of V8 heap. Per MiB, NOT per byte — the budget is stored
|
|
@@ -40,7 +40,8 @@ export type HostGateAdmittedSource =
|
|
|
40
40
|
| "cors-origin"
|
|
41
41
|
| "live-tunnel"
|
|
42
42
|
| "allowed-host"
|
|
43
|
-
| "tls-listener"
|
|
43
|
+
| "tls-listener"
|
|
44
|
+
| "live-preview";
|
|
44
45
|
|
|
45
46
|
/** One row of the operator-visible *Currently admitted* list. */
|
|
46
47
|
export interface HostGateAdmittedRow {
|
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
* Added by change: doctor-rich-output.
|
|
8
8
|
*/
|
|
9
9
|
export * from "./doctor-core.js";
|
|
10
|
-
export
|
|
11
|
-
export { isValidRoleName } from "./role-name-validation.js";
|
|
12
|
-
export type { RoleNameValidation } from "./role-name-validation.js";
|
|
13
|
-
export type { ViewTarget } from "./types.js";
|
|
10
|
+
export type { FileKind, FileKindResult, ViewerKind } from "./file-kind.js";
|
|
14
11
|
export {
|
|
15
12
|
fileKind,
|
|
16
|
-
TEXT_EXTENSIONS,
|
|
17
13
|
IMAGE_EXTENSIONS,
|
|
14
|
+
TEXT_EXTENSIONS,
|
|
18
15
|
} from "./file-kind.js";
|
|
19
|
-
export
|
|
16
|
+
export * from "./node-version.js";
|
|
17
|
+
export type { RoleNameValidation } from "./role-name-validation.js";
|
|
18
|
+
export { isValidRoleName } from "./role-name-validation.js";
|
|
19
|
+
export { toolWorkdir } from "./tool-workdir.js";
|
|
20
|
+
export type { ViewTarget } from "./types.js";
|
|
@@ -225,3 +225,23 @@ export function validateAddressPath(input: string): AddressPathResult {
|
|
|
225
225
|
}
|
|
226
226
|
return { ok: true, path: out.join("/") + (trailing ? "/" : "") + suffix };
|
|
227
227
|
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* `POST /api/live-server/:id/capability` success body. `tier` 1-4 carry an `origin`; 5 is `/preview/<pid>/`;
|
|
231
|
+
* `"legacy"` is `/live/<id>/~c/<token>/`. Tiers 1, 2, 4 carry `origin` and `path: "/"`; tier 3 `origin` and
|
|
232
|
+
* `path: "/?k=<secret>"`; tier 5 `path: "/preview/<pid>/"` with no `origin`. Tiers 1-4 MAY carry
|
|
233
|
+
* `base: "/preview/<pid>/"`. Without `accept` the response is `"legacy"`.
|
|
234
|
+
*/
|
|
235
|
+
export interface LiveCapabilityMintResponse {
|
|
236
|
+
success: true;
|
|
237
|
+
ok: true;
|
|
238
|
+
tier: 1 | 2 | 3 | 4 | 5 | "legacy";
|
|
239
|
+
origin?: string;
|
|
240
|
+
path: string;
|
|
241
|
+
base?: string;
|
|
242
|
+
/** Tier 5: a previous pid of this target was superseded, so the running site must restart under the new base. */
|
|
243
|
+
restartRequired?: boolean;
|
|
244
|
+
expiresAt: number;
|
|
245
|
+
tokenId: string;
|
|
246
|
+
policy: { egress: "open" | "restricted"; scripts: boolean };
|
|
247
|
+
}
|
|
@@ -26,8 +26,6 @@ export const GENERATED_VERB_TIERS: readonly GeneratedVerbTier[] = [
|
|
|
26
26
|
{"name":"rename_session","tier":"control"},
|
|
27
27
|
{"name":"set_model","tier":"control"},
|
|
28
28
|
{"name":"set_thinking_level","tier":"control"},
|
|
29
|
-
{"name":"flow_control","tier":"control"},
|
|
30
|
-
{"name":"extension_ui_response","tier":"control"},
|
|
31
29
|
{"name":"attach_proposal","tier":"control"},
|
|
32
30
|
{"name":"detach_proposal","tier":"control"},
|
|
33
31
|
{"name":"list_archived_sessions","tier":"observe"},
|
|
@@ -72,6 +70,7 @@ export const GENERATED_VERB_TIERS: readonly GeneratedVerbTier[] = [
|
|
|
72
70
|
{"name":"list_automation","tier":"observe"},
|
|
73
71
|
{"name":"run_automation","tier":"control"},
|
|
74
72
|
{"name":"stop_automation","tier":"control"},
|
|
73
|
+
{"name":"flows_control","tier":"operate"},
|
|
75
74
|
{"name":"list_models","tier":"observe"},
|
|
76
75
|
{"name":"list_providers","tier":"observe"},
|
|
77
76
|
{"name":"set_providers","tier":"operate"},
|
|
@@ -104,7 +103,6 @@ export const GENERATED_VERB_TIERS: readonly GeneratedVerbTier[] = [
|
|
|
104
103
|
{"name":"force_kill","tier":"operate"},
|
|
105
104
|
{"name":"kill_process","tier":"operate"},
|
|
106
105
|
{"name":"set_session_tags","tier":"control"},
|
|
107
|
-
{"name":"prompt_response","tier":"control"},
|
|
108
106
|
{"name":"edit_followup_entry","tier":"control"},
|
|
109
107
|
{"name":"history_backfill","tier":"observe"},
|
|
110
108
|
{"name":"config_auth_providers_id","tier":"control"},
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
* See change: honor-native-models-json-metadata (D-X2).
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import type { ProviderBlock } from "./provider-overrides.js";
|
|
26
|
+
|
|
25
27
|
/** A flattened custom-model entry as read from `models.json`. */
|
|
26
28
|
export interface NativeModelEntry {
|
|
27
29
|
id: string;
|
|
@@ -109,3 +111,42 @@ export function flattenModelsJson(parsed: unknown): NativeModelEntry[] {
|
|
|
109
111
|
|
|
110
112
|
return [...byKey.values()];
|
|
111
113
|
}
|
|
114
|
+
|
|
115
|
+
// ── Whole-block reader (pi syntax, agentDir path) ───────────────────────────
|
|
116
|
+
// See change: add-provider-advanced-settings (D4).
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
/** Strip a leading UTF-8 BOM, as pi does before parsing. */
|
|
120
|
+
export function stripBom(text: string): string {
|
|
121
|
+
return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* pi's `stripJsonComments` (`pi-coding-agent/src/utils/json.ts`): drops `//`
|
|
126
|
+
* line comments and trailing commas outside string literals. `/* *\/` comments
|
|
127
|
+
* are NOT accepted by pi and stay in (so `JSON.parse` fails, as in pi).
|
|
128
|
+
*/
|
|
129
|
+
export function stripJsonComments(input: string): string {
|
|
130
|
+
return input
|
|
131
|
+
.replace(/"(?:\\.|[^"\\])*"|\/\/[^\n]*/g, (m) => (m[0] === '"' ? m : ""))
|
|
132
|
+
.replace(/"(?:\\.|[^"\\])*"|,(\s*[}\]])/g, (m, tail) => tail ?? (m[0] === '"' ? m : ""));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Parse `models.json` text exactly as pi does (BOM, `//` comments, trailing commas). Throws on a syntax error. */
|
|
136
|
+
export function parsePiJson(text: string): unknown {
|
|
137
|
+
return JSON.parse(stripJsonComments(stripBom(text)));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Every provider block under `providers`, with or without `models[]`.
|
|
142
|
+
* Per-provider defensive: a non-object block is skipped, never throws.
|
|
143
|
+
* Returns `{}` for a legacy shape (no `providers` object).
|
|
144
|
+
*/
|
|
145
|
+
export function readProviderBlocks(parsed: unknown): Record<string, ProviderBlock> {
|
|
146
|
+
const out: Record<string, ProviderBlock> = {};
|
|
147
|
+
if (!isRecord(parsed) || !isRecord(parsed.providers)) return out;
|
|
148
|
+
for (const [id, block] of Object.entries(parsed.providers)) {
|
|
149
|
+
if (isRecord(block)) out[id] = block as ProviderBlock;
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `network_not_allowed` denial signal shared by the server's generic 403 body and
|
|
3
|
+
* the additive `GET /api/health` `networkAccess` field.
|
|
4
|
+
*
|
|
5
|
+
* Own dependency-free module (not `rest-api.ts`) because the browser client value-imports it.
|
|
6
|
+
*
|
|
7
|
+
* See change: surface-network-denial-on-health (D4).
|
|
8
|
+
*/
|
|
9
|
+
export const NETWORK_NOT_ALLOWED = "network_not_allowed" as const;
|
|
10
|
+
export const GENERIC_NETWORK_DENIED_HINT = "Pair this device (Request access) or sign in.";
|
|
11
|
+
|
|
12
|
+
/** The additive `/api/health` field: present iff the caller's own request would be refused by the network guard. */
|
|
13
|
+
export interface HealthNetworkAccessField {
|
|
14
|
+
networkAccess?: { error: typeof NETWORK_NOT_ALLOWED; hint: string };
|
|
15
|
+
}
|
|
@@ -2,63 +2,69 @@
|
|
|
2
2
|
* Canonical Node.js version predicates — single source of truth.
|
|
3
3
|
*
|
|
4
4
|
* Both the dashboard server's startup guard (`packages/server/src/auth/node-guard.ts`,
|
|
5
|
-
* which re-exports `
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* which re-exports `isOutOfEnginesRange`) and the Electron doctor's system-Node
|
|
6
|
+
* detection (`packages/electron/src/lib/dependency-detector.ts`, which consumes
|
|
7
|
+
* `isUsableNodeVersion`) import from here. No package keeps a private inline
|
|
8
|
+
* copy — that is the drift hazard this module exists to remove.
|
|
9
9
|
*
|
|
10
|
-
* Two
|
|
10
|
+
* Two floors, one cap:
|
|
11
11
|
*
|
|
12
|
-
* -
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* to `< 22.19` in change `bump-pi-compat-to-0-75` (pi 0.75.0 raised its own
|
|
17
|
-
* Node floor to 22.19).
|
|
12
|
+
* - Dashboard server range: root `package.json#engines.node` (`>=26.0.0 <27`).
|
|
13
|
+
* Floor = `MIN_SERVER_NODE`; at/above the cap (`>=27`): untested, refused.
|
|
14
|
+
* The floor moved 22.19.0 -> 26.0.0 in change `raise-node-floor-to-26`
|
|
15
|
+
* (Node 26 Active LTS 2026-10-28).
|
|
18
16
|
*
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* - pi spawn floor: `MIN_PI_SPAWN_NODE` (`22.19.0`, pi's own engines floor),
|
|
18
|
+
* used only by the pi-session spawn-runtime ladder together with
|
|
19
|
+
* `isAffectedNode`.
|
|
22
20
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* EBADENGINE was an nvm subprocess-PATH artifact, not a real engines failure.
|
|
28
|
-
* Cap moved to `<26`, restoring Node 25 as a first-class target. The 22.x
|
|
29
|
-
* Fastify cutoff widened `< 22.18` -> `< 22.19` in change `bump-pi-compat-to-0-75`
|
|
30
|
-
* (pi 0.75.0 raised its own Node floor to 22.19).
|
|
31
|
-
* Cap moved `<26` -> `<27` in change `fix-pi-install-node26-and-omit-dev-build`:
|
|
32
|
-
* `pi install git:...` aborted with EBADENGINE on Node 26 (issue #357). Node 26
|
|
33
|
-
* is CI-validated by the `_smoke.yml` `standalone-install-smoke-linux` Node 26
|
|
34
|
-
* legs, which run WITHOUT `--config.engine-strict=false` so the EBADENGINE half
|
|
35
|
-
* of #357 stays regression-tested.
|
|
21
|
+
* - nodejs/node#58515 Fastify-affected: Node v22.0–v22.18 and v24.1–v24.2
|
|
22
|
+
* (`ERR_INTERNAL_ASSERTION: Unexpected module status 3`). Entirely below
|
|
23
|
+
* the server floor, so the server no longer checks it at startup; it stays
|
|
24
|
+
* exported solely for the pi-session ladder gate.
|
|
36
25
|
*
|
|
37
|
-
*
|
|
38
|
-
* fix
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
26
|
+
* Cap history: `<25` (openspec-worktree-spawn-button) -> `<26` -> `<27`
|
|
27
|
+
* (fix-pi-install-node26-and-omit-dev-build, issue #357).
|
|
28
|
+
*
|
|
29
|
+
* Lockstep contract: when `package.json#engines.node` changes, only this file
|
|
30
|
+
* changes — plus the `_smoke.yml` `standalone-install-smoke-linux` Node-major
|
|
31
|
+
* set (currently `26`), which must cover exactly the supported majors. The
|
|
32
|
+
* `Required: >=26.0.0 <27` literal in `buildEnginesRangeMessage`
|
|
33
|
+
* (`packages/server/src/auth/node-guard.ts`) is a cap site the contract cannot
|
|
34
|
+
* express in code; it is guarded by the `node-cap-message-matches-engines`
|
|
35
|
+
* repo-lint instead. See change: unify-node-version-gate, raise-node-floor-to-26.
|
|
46
36
|
*/
|
|
47
37
|
|
|
48
38
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
39
|
+
* Dashboard SERVER floor — the lower bound of root `package.json#engines.node`
|
|
40
|
+
* (`>=26.0.0 <27`) and `packages/server` (`>=26.0.0`). `isOutOfEnginesRange`
|
|
41
|
+
* implements its floor half THROUGH this constant + `meetsFloor`, and the
|
|
42
|
+
* server-spawn resolver (`spawn-runtime.ts` `resolveServerRuntime`) gates on
|
|
43
|
+
* that predicate — no consumer carries a private floor literal.
|
|
44
|
+
* See change: raise-node-floor-to-26 (design D2/D3).
|
|
45
|
+
*/
|
|
46
|
+
export const MIN_SERVER_NODE = "26.0.0";
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* pi SPAWN floor — pi's own `engines.node` minimum (pi 0.75+ ships
|
|
50
|
+
* `>=22.19.0`). The pi-session spawn-runtime ladder
|
|
55
51
|
* (`packages/shared/src/platform/spawn-runtime.ts`) gates candidates against
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
52
|
+
* the floor read from the spawned pi copy, falling back to this constant when
|
|
53
|
+
* unreadable. Distinct from `MIN_SERVER_NODE`: raising the server floor SHALL
|
|
54
|
+
* NOT raise the floor applied to pi-session spawns.
|
|
55
|
+
* Lockstep-guarded by `node-version.test.ts` and the floor-vs-pi repo-lint in
|
|
56
|
+
* `bundled-node-meets-pi-floor.test.ts` (`MIN_SERVER_NODE` >= pi's floor).
|
|
57
|
+
* See change: unify-pi-runtime-identity (task 1.1), raise-node-floor-to-26 (D3).
|
|
58
|
+
*/
|
|
59
|
+
export const MIN_PI_SPAWN_NODE = "22.19.0";
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The dashboard server engines range as text (`>=26.0.0 <27`) — for
|
|
63
|
+
* diagnostics and user-facing notices. Built from `MIN_SERVER_NODE` + the cap
|
|
64
|
+
* so no consumer re-types the range. Lint-pinned to root
|
|
65
|
+
* `package.json#engines.node` by `node-version.test.ts`.
|
|
60
66
|
*/
|
|
61
|
-
export const
|
|
67
|
+
export const SERVER_ENGINES_RANGE = `>=${MIN_SERVER_NODE} <27`;
|
|
62
68
|
|
|
63
69
|
/**
|
|
64
70
|
* Accept a clean semver triplet, optionally `v`-prefixed, optionally with a
|
|
@@ -126,31 +132,28 @@ export function isAffectedNode(version: string): boolean {
|
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
/**
|
|
129
|
-
* True when Node is OUTSIDE the
|
|
130
|
-
*
|
|
131
|
-
*
|
|
135
|
+
* True when Node is OUTSIDE the dashboard server engines range
|
|
136
|
+
* (`>=26.0.0 <27`): below `MIN_SERVER_NODE`, or major >= 27.
|
|
137
|
+
* Unparseable input returns false ("not provably out of range").
|
|
132
138
|
*/
|
|
133
139
|
export function isOutOfEnginesRange(version: string): boolean {
|
|
134
140
|
const m = version.match(NODE_VERSION_RE);
|
|
135
141
|
if (!m) return false;
|
|
136
142
|
// Floor half implemented THROUGH the canonical constant — lockstep by
|
|
137
143
|
// construction, not by convention.
|
|
138
|
-
if (!meetsFloor(version,
|
|
144
|
+
if (!meetsFloor(version, MIN_SERVER_NODE)) return true;
|
|
139
145
|
return isAtOrAboveEnginesCap(version);
|
|
140
146
|
}
|
|
141
147
|
|
|
142
148
|
/**
|
|
143
149
|
* True when `version` is something the dashboard server will actually run on:
|
|
144
|
-
* within the engines range
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* every major between the floor and the cap; the doc comment previously
|
|
148
|
-
* omitted it. See change: unify-pi-runtime-identity, Part 3 docs-drift pass.)
|
|
150
|
+
* a clean semver within the engines range. Accept-set: 26.x only. The
|
|
151
|
+
* #58515 affected ranges lie below the floor, so no separate check is needed.
|
|
152
|
+
* See change: raise-node-floor-to-26.
|
|
149
153
|
*/
|
|
150
154
|
export function isUsableNodeVersion(version: string): boolean {
|
|
151
|
-
// Unparseable / non-version strings are NOT usable
|
|
152
|
-
//
|
|
153
|
-
// predicates return false ("not out of range", "not affected") on no-match.
|
|
155
|
+
// Unparseable / non-version strings are NOT usable: isOutOfEnginesRange
|
|
156
|
+
// returns false ("not out of range") on no-match.
|
|
154
157
|
if (!NODE_VERSION_RE.test(version)) return false;
|
|
155
|
-
return !isOutOfEnginesRange(version)
|
|
158
|
+
return !isOutOfEnginesRange(version);
|
|
156
159
|
}
|