@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.
Files changed (337) hide show
  1. package/AGENTS.md +2 -0
  2. package/README.md +17 -12
  3. package/docs/architecture.md +973 -224
  4. package/package.json +29 -18
  5. package/packages/extension/package.json +16 -9
  6. package/packages/extension/src/bridge-context.ts +6 -0
  7. package/packages/extension/src/bridge-handlers/dispatch.ts +54 -69
  8. package/packages/extension/src/bridge-handlers/forwarders.ts +19 -42
  9. package/packages/extension/src/bridge-handlers/instance.ts +21 -12
  10. package/packages/extension/src/bridge-handlers/lifecycle.ts +84 -40
  11. package/packages/extension/src/bridge-shutdown.ts +44 -0
  12. package/packages/extension/src/bridge.ts +272 -260
  13. package/packages/extension/src/command-handler.ts +26 -31
  14. package/packages/extension/src/connection.ts +123 -31
  15. package/packages/extension/src/credential-guard.ts +300 -0
  16. package/packages/extension/src/custom-entry-forward.ts +27 -18
  17. package/packages/extension/src/default-model-apply.ts +83 -0
  18. package/packages/extension/src/flow-event-wiring.ts +19 -95
  19. package/packages/extension/src/followup-drain.ts +19 -5
  20. package/packages/extension/src/path-gate/decide.ts +68 -5
  21. package/packages/extension/src/path-gate/handler.ts +16 -8
  22. package/packages/extension/src/path-gate/index.ts +2 -2
  23. package/packages/extension/src/path-gate/roots.ts +15 -3
  24. package/packages/extension/src/path-gate/suppression.ts +3 -0
  25. package/packages/extension/src/pi-env.d.ts +8 -1
  26. package/packages/extension/src/pi-retry-settings.ts +11 -2
  27. package/packages/extension/src/plugin-event-forward-registry.ts +90 -14
  28. package/packages/extension/src/preview-path-link.ts +151 -0
  29. package/packages/extension/src/project-init/scaffold.ts +98 -35
  30. package/packages/extension/src/project-trust.ts +24 -15
  31. package/packages/extension/src/provider-model-cache.ts +118 -0
  32. package/packages/extension/src/provider-register.ts +428 -28
  33. package/packages/extension/src/retry-tracker.ts +90 -7
  34. package/packages/extension/src/role-manager.ts +4 -2
  35. package/packages/extension/src/role-model-tools.ts +21 -4
  36. package/packages/extension/src/server-auto-start.ts +68 -2
  37. package/packages/extension/src/server-launcher.ts +26 -8
  38. package/packages/extension/src/session-sync.ts +11 -12
  39. package/packages/extension/src/spawn-new-session.ts +22 -0
  40. package/packages/extension/src/steer-buffer.ts +164 -0
  41. package/packages/extension/src/stream-forward-buffer.ts +64 -15
  42. package/packages/extension/src/sudo-askpass/config-reader.ts +32 -0
  43. package/packages/extension/src/sudo-askpass/controller.ts +405 -0
  44. package/packages/extension/src/sudo-askpass/helper-script.ts +69 -0
  45. package/packages/extension/src/sudo-askpass/in-flight.ts +79 -0
  46. package/packages/extension/src/sudo-askpass/index.ts +11 -0
  47. package/packages/extension/src/sudo-askpass/install.ts +143 -0
  48. package/packages/extension/src/sudo-askpass/password-cache.ts +118 -0
  49. package/packages/extension/src/sudo-askpass/prompt-text.ts +55 -0
  50. package/packages/extension/src/sudo-askpass/protocol.ts +18 -0
  51. package/packages/extension/src/sudo-askpass/sudo-mask-registry.ts +52 -0
  52. package/packages/extension/src/terminal-reload.ts +19 -5
  53. package/packages/extension/src/tool-update-filter-registry.ts +210 -0
  54. package/packages/extension/src/vault-redaction.ts +4 -3
  55. package/packages/server/package.json +17 -14
  56. package/packages/server/src/access/access-denials.ts +8 -0
  57. package/packages/server/src/access/access-grants.ts +244 -58
  58. package/packages/server/src/access/access-plane.ts +7 -0
  59. package/packages/server/src/access/containment-gate.ts +66 -21
  60. package/packages/server/src/access/denial-hold.ts +3 -0
  61. package/packages/server/src/access/grant-coordinator.ts +17 -1
  62. package/packages/server/src/access/named-grant.ts +3 -0
  63. package/packages/server/src/access/pending-grant-registry.ts +32 -5
  64. package/packages/server/src/access/pi-trust-mirror-service.ts +7 -1
  65. package/packages/server/src/access/planes.ts +1 -0
  66. package/packages/server/src/access/verified-read.ts +24 -7
  67. package/packages/server/src/acp-bridge/acp-session-adapter.ts +10 -2
  68. package/packages/server/src/acp-bridge/server-requests.ts +10 -4
  69. package/packages/server/src/agent-events/agent-event-hub.ts +1 -1
  70. package/packages/server/src/auth/audit-log.ts +28 -0
  71. package/packages/server/src/auth/auth-plugin.ts +188 -15
  72. package/packages/server/src/auth/auth.ts +80 -0
  73. package/packages/server/src/auth/bridge-ticket-eligibility.ts +53 -10
  74. package/packages/server/src/auth/cors-origin.ts +14 -1
  75. package/packages/server/src/auth/credential-envelope.ts +233 -0
  76. package/packages/server/src/auth/credential-key-worker.d.mts +16 -0
  77. package/packages/server/src/auth/credential-key-worker.mjs +108 -0
  78. package/packages/server/src/auth/credential-key.ts +479 -0
  79. package/packages/server/src/auth/credential-migration.ts +162 -0
  80. package/packages/server/src/auth/csp-report-paths.ts +0 -5
  81. package/packages/server/src/auth/csp.ts +74 -36
  82. package/packages/server/src/auth/device-proof.ts +202 -0
  83. package/packages/server/src/auth/duplicate-cookie-gate.ts +271 -0
  84. package/packages/server/src/auth/host-admission.ts +7 -0
  85. package/packages/server/src/auth/host-gate.ts +13 -2
  86. package/packages/server/src/auth/localhost-guard.ts +50 -23
  87. package/packages/server/src/auth/locked-json-file.ts +68 -6
  88. package/packages/server/src/auth/models-json-store.ts +269 -0
  89. package/packages/server/src/auth/mutation-origin-gate.ts +5 -2
  90. package/packages/server/src/auth/node-guard.ts +36 -49
  91. package/packages/server/src/auth/plugin-credential-store.ts +81 -10
  92. package/packages/server/src/auth/provider-auth-storage.ts +208 -11
  93. package/packages/server/src/auth/provider-block-checks.ts +321 -0
  94. package/packages/server/src/auth/provider-host-detect.ts +151 -0
  95. package/packages/server/src/auth/provider-key-file.ts +71 -0
  96. package/packages/server/src/auth/provider-readiness.ts +91 -0
  97. package/packages/server/src/auth/route-tier-gate.ts +3 -2
  98. package/packages/server/src/auth/vertex-key-check.ts +140 -0
  99. package/packages/server/src/auth/ws-ticket.ts +1 -1
  100. package/packages/server/src/browse.ts +73 -20
  101. package/packages/server/src/browser-handlers/acp-guard.ts +1 -4
  102. package/packages/server/src/browser-handlers/directory-handler.ts +11 -24
  103. package/packages/server/src/browser-handlers/session-action-handler.ts +158 -62
  104. package/packages/server/src/browser-handlers/spawn-choice.ts +138 -1
  105. package/packages/server/src/browser-handlers/subscription-handler.ts +46 -1
  106. package/packages/server/src/build-plugin-send-prompt.ts +18 -0
  107. package/packages/server/src/cli/credentials-command.ts +555 -0
  108. package/packages/server/src/cli.ts +21 -16
  109. package/packages/server/src/config-api.ts +34 -38
  110. package/packages/server/src/config-snapshot.ts +149 -0
  111. package/packages/server/src/directory-service.ts +33 -14
  112. package/packages/server/src/embed-lifecycle/idle-reaper.ts +13 -3
  113. package/packages/server/src/event-wiring.ts +181 -101
  114. package/packages/server/src/git-worktree/ensure-worktree.ts +185 -0
  115. package/packages/server/src/git-worktree/git-operations.ts +1 -1
  116. package/packages/server/src/git-worktree/repo-lock.ts +42 -0
  117. package/packages/server/src/git-worktree/start-worktree-init.ts +151 -0
  118. package/packages/server/src/git-worktree/worktree-init.ts +5 -1
  119. package/packages/server/src/identity/http-road-classification.ts +5 -1
  120. package/packages/server/src/identity/identity-floor.ts +5 -2
  121. package/packages/server/src/identity/ws-message-scope.ts +10 -3
  122. package/packages/server/src/identity/ws-road-classification.ts +2 -1
  123. package/packages/server/src/lib/browse-roots.ts +13 -2
  124. package/packages/server/src/lib/content-disposition.ts +20 -0
  125. package/packages/server/src/lib/dashboard-state-guard.ts +304 -21
  126. package/packages/server/src/lib/eml.ts +2 -2
  127. package/packages/server/src/lib/frame-policy-probe.ts +308 -0
  128. package/packages/server/src/lib/frame-policy-test-seam.ts +99 -0
  129. package/packages/server/src/lib/frame-policy-verdict.ts +125 -0
  130. package/packages/server/src/lib/grep.ts +4 -1
  131. package/packages/server/src/lib/index-html.ts +2 -2
  132. package/packages/server/src/lib/mention-fuzzy-index.ts +263 -0
  133. package/packages/server/src/lib/office-preview.ts +47 -10
  134. package/packages/server/src/lib/path-containment.ts +45 -12
  135. package/packages/server/src/lib/resolve-file-mention.ts +230 -38
  136. package/packages/server/src/lib/resolve-mentions-batch.ts +143 -0
  137. package/packages/server/src/lib/writable-handler-target.ts +4 -0
  138. package/packages/server/src/lib/writable-md-target.ts +22 -0
  139. package/packages/server/src/lifecycle/boot-parent-liveness.ts +10 -25
  140. package/packages/server/src/lifecycle/credential-exit-barrier.ts +207 -0
  141. package/packages/server/src/lifecycle/exit-signal.ts +43 -0
  142. package/packages/server/src/live-server/capability-redact.ts +21 -5
  143. package/packages/server/src/live-server/live-capability.ts +416 -52
  144. package/packages/server/src/live-server/live-csp-report.ts +1 -1
  145. package/packages/server/src/live-server/live-csp.ts +64 -16
  146. package/packages/server/src/live-server/live-log.ts +5 -1
  147. package/packages/server/src/live-server/live-server-manager.ts +11 -0
  148. package/packages/server/src/live-server/live-server-proxy.ts +268 -52
  149. package/packages/server/src/live-server/live-static.ts +4 -1
  150. package/packages/server/src/live-server/preview-dispatch.ts +286 -0
  151. package/packages/server/src/live-server/preview-observe.ts +53 -0
  152. package/packages/server/src/live-server/preview-origin.ts +182 -0
  153. package/packages/server/src/live-server/preview-path-bridge.ts +70 -0
  154. package/packages/server/src/live-server/preview-path-store.ts +420 -0
  155. package/packages/server/src/live-server/preview-path.ts +40 -0
  156. package/packages/server/src/live-server/preview-pool.ts +385 -0
  157. package/packages/server/src/live-server/preview-preflight.ts +41 -0
  158. package/packages/server/src/live-server/preview-reserve.ts +44 -0
  159. package/packages/server/src/live-server/preview-tier.ts +217 -0
  160. package/packages/server/src/live-server/preview-viewers.ts +54 -0
  161. package/packages/server/src/live-server/preview-ws-registry.ts +43 -0
  162. package/packages/server/src/model-proxy/custom-provider-discovery.ts +4 -2
  163. package/packages/server/src/model-proxy/internal-auth-storage.ts +5 -1
  164. package/packages/server/src/model-proxy/internal-registry.ts +283 -21
  165. package/packages/server/src/model-proxy/models-block-apply.ts +291 -0
  166. package/packages/server/src/model-proxy/pi-models-validator.ts +164 -0
  167. package/packages/server/src/model-proxy/registry-singleton.ts +44 -9
  168. package/packages/server/src/model-proxy/server-model-runtime.ts +17 -0
  169. package/packages/server/src/openspec/readiness.ts +1 -1
  170. package/packages/server/src/package/provider-probe.ts +194 -5
  171. package/packages/server/src/pairing/browser-gateway.ts +140 -42
  172. package/packages/server/src/pairing/device-key-intake.ts +120 -0
  173. package/packages/server/src/pairing/paired-devices.ts +370 -8
  174. package/packages/server/src/pairing/pairing.ts +69 -7
  175. package/packages/server/src/pairing/{subagent-resync-routing.ts → resync-requester-registry.ts} +6 -10
  176. package/packages/server/src/pairing/ws-tier-gate.ts +74 -0
  177. package/packages/server/src/pending/pending-attach-registry.ts +15 -0
  178. package/packages/server/src/pending/pending-initial-prompt-registry.ts +15 -0
  179. package/packages/server/src/persistence/memory-event-store.ts +251 -296
  180. package/packages/server/src/persistence/preferences-store.ts +52 -2
  181. package/packages/server/src/pi/bridge-contention.ts +84 -2
  182. package/packages/server/src/pi/host-project-trust.ts +15 -9
  183. package/packages/server/src/pi/pi-gateway.ts +208 -21
  184. package/packages/server/src/pi/provisional-registration.ts +4 -1
  185. package/packages/server/src/pi/resource-toggle-trust.ts +17 -6
  186. package/packages/server/src/pi-agent-settings.ts +95 -301
  187. package/packages/server/src/pi-default-remirror.ts +89 -0
  188. package/packages/server/src/plugin-append-event.ts +35 -0
  189. package/packages/server/src/plugin-entry-stats.ts +61 -0
  190. package/packages/server/src/plugin-local-request.ts +207 -0
  191. package/packages/server/src/plugin-ownership.ts +111 -0
  192. package/packages/server/src/plugin-policy-registry.ts +297 -0
  193. package/packages/server/src/plugin-request-lane.ts +92 -16
  194. package/packages/server/src/preferences-relay.ts +20 -0
  195. package/packages/server/src/project-seed.ts +347 -0
  196. package/packages/server/src/push/push-transports/webhook-url.ts +8 -5
  197. package/packages/server/src/questions/question-store.ts +3 -2
  198. package/packages/server/src/routes/access-routes.ts +23 -6
  199. package/packages/server/src/routes/acme-routes.ts +14 -4
  200. package/packages/server/src/routes/agent-event-stream-routes.ts +1 -1
  201. package/packages/server/src/routes/file-routes.ts +327 -86
  202. package/packages/server/src/routes/file-write-binary-routes.ts +20 -4
  203. package/packages/server/src/routes/frame-policy-routes.ts +215 -0
  204. package/packages/server/src/routes/git-routes.ts +29 -78
  205. package/packages/server/src/routes/grep-routes.ts +26 -0
  206. package/packages/server/src/routes/live-server-routes.ts +198 -4
  207. package/packages/server/src/routes/models-introspection-routes.ts +1 -1
  208. package/packages/server/src/routes/openspec-routes.ts +17 -3
  209. package/packages/server/src/routes/pairing-routes.ts +200 -11
  210. package/packages/server/src/routes/pi-settings-routes.ts +2 -0
  211. package/packages/server/src/routes/preferences-auto-name-routes.ts +5 -2
  212. package/packages/server/src/routes/preferences-claude-compat-routes.ts +49 -0
  213. package/packages/server/src/routes/provider-auth-routes.ts +167 -9
  214. package/packages/server/src/routes/provider-override-routes.ts +158 -0
  215. package/packages/server/src/routes/provider-routes.ts +348 -86
  216. package/packages/server/src/routes/session-routes.ts +25 -22
  217. package/packages/server/src/routes/system-routes.ts +87 -39
  218. package/packages/server/src/rpc-keeper/keeper-manager.ts +196 -25
  219. package/packages/server/src/rpc-keeper/keeper.cjs +37 -23
  220. package/packages/server/src/runtime-overlay/extension-reload.ts +16 -10
  221. package/packages/server/src/runtime-overlay/runtime-stager.ts +4 -2
  222. package/packages/server/src/server.ts +512 -175
  223. package/packages/server/src/services/cli-service.ts +59 -10
  224. package/packages/server/src/services/secrets-resolver.ts +46 -30
  225. package/packages/server/src/session/custom-event-group-annotation.ts +3 -3
  226. package/packages/server/src/session/custom-event-group-resolver.ts +10 -5
  227. package/packages/server/src/session/death-reason.ts +11 -7
  228. package/packages/server/src/session/event-status-extraction.ts +5 -1
  229. package/packages/server/src/session/memory-session-manager.ts +24 -2
  230. package/packages/server/src/session/open-tool-calls.ts +81 -47
  231. package/packages/server/src/session/pid-target.ts +127 -0
  232. package/packages/server/src/session/replay-compaction.ts +18 -5
  233. package/packages/server/src/session/seed-discovered-history.ts +85 -0
  234. package/packages/server/src/session/server-pid-context.ts +14 -0
  235. package/packages/server/src/session/session-api.ts +78 -29
  236. package/packages/server/src/session/session-archive.ts +7 -0
  237. package/packages/server/src/session/session-bootstrap.ts +9 -54
  238. package/packages/server/src/session/session-load-worker-pool.ts +11 -1
  239. package/packages/server/src/session/session-load-worker.ts +22 -3
  240. package/packages/server/src/spawn-process/abort-spawned-run.ts +28 -9
  241. package/packages/server/src/spawn-process/acp-spawn.ts +8 -2
  242. package/packages/server/src/spawn-process/headless-pid-registry.ts +383 -72
  243. package/packages/server/src/spawn-process/link-register.ts +42 -0
  244. package/packages/server/src/spawn-process/plugin-spawn-choice.ts +48 -0
  245. package/packages/server/src/spawn-process/plugin-spawn-worktree.ts +290 -0
  246. package/packages/server/src/spawn-process/process-classifier.ts +8 -3
  247. package/packages/server/src/spawn-process/process-manager.ts +61 -6
  248. package/packages/server/src/spawn-process/restored-identity.ts +112 -0
  249. package/packages/server/src/spawn-process/session-terminator.ts +179 -18
  250. package/packages/server/src/spawn-process/spawn-env-contributors.ts +2 -1
  251. package/packages/server/src/spawn-process/spawn-failure-log.ts +9 -0
  252. package/packages/server/src/spawn-process/spawn-register-watchdog.ts +44 -19
  253. package/packages/server/src/sudo-credential/relay.ts +337 -0
  254. package/packages/server/src/terminal/terminal-gateway.ts +10 -0
  255. package/packages/server/src/tls/sources/acme/credentials.ts +3 -2
  256. package/packages/server/src/tls/sources/acme/runtime.ts +2 -1
  257. package/packages/server/src/vault/vault-delivery-hub.ts +17 -1
  258. package/packages/server/src/vault/vault-routes.ts +9 -2
  259. package/packages/server/src/vault/vault-store.ts +87 -24
  260. package/packages/server/vendor/xlsx/LICENSE +201 -0
  261. package/packages/server/vendor/xlsx/PROVENANCE.json +13 -0
  262. package/packages/server/vendor/xlsx/xlsx.d.mts +1065 -0
  263. package/packages/server/vendor/xlsx/xlsx.mjs +28228 -0
  264. package/packages/shared/package.json +4 -2
  265. package/packages/shared/src/agent-credential-files.ts +32 -0
  266. package/packages/shared/src/browser-protocol.ts +137 -57
  267. package/packages/shared/src/canvas-detect.ts +1 -1
  268. package/packages/shared/src/canvas-types.ts +2 -2
  269. package/packages/shared/src/config.ts +73 -136
  270. package/packages/shared/src/containment-guard.ts +14 -4
  271. package/packages/shared/src/credential-encryption.ts +87 -0
  272. package/packages/shared/src/custom-event-groups.ts +2 -0
  273. package/packages/shared/src/dashboard-plugin/claude-compat.ts +159 -0
  274. package/packages/shared/src/dashboard-plugin/host-api.ts +1 -1
  275. package/packages/shared/src/dashboard-plugin/manifest-types.ts +46 -0
  276. package/packages/shared/src/dashboard-plugin/plugin-status.ts +4 -3
  277. package/packages/shared/src/dashboard-plugin/replay-entry-types.ts +46 -0
  278. package/packages/shared/src/dashboard-plugin/slot-props.ts +2 -0
  279. package/packages/shared/src/dashboard-plugin/slot-types.ts +1 -1
  280. package/packages/shared/src/dashboard-plugin/ui-primitives.ts +11 -3
  281. package/packages/shared/src/device-key-proof.ts +309 -0
  282. package/packages/shared/src/event-forward-declaration.ts +85 -12
  283. package/packages/shared/src/forbidden-subjects.ts +126 -14
  284. package/packages/shared/src/heap-limits.ts +0 -30
  285. package/packages/shared/src/host-admission.ts +2 -1
  286. package/packages/shared/src/index.ts +7 -6
  287. package/packages/shared/src/live-server.ts +20 -0
  288. package/packages/shared/src/mcp/verb-tiers.generated.ts +1 -3
  289. package/packages/shared/src/models-json-reader.ts +41 -0
  290. package/packages/shared/src/network-denial-signal.ts +15 -0
  291. package/packages/shared/src/node-version.ts +63 -60
  292. package/packages/shared/src/pairing-knock-client.ts +92 -8
  293. package/packages/shared/src/pi-agent-settings-lock.ts +311 -0
  294. package/packages/shared/src/pi-path-compare.ts +31 -0
  295. package/packages/shared/src/pi-settings-schema.ts +52 -9
  296. package/packages/shared/src/pi-trust-mirror-snapshot.ts +16 -4
  297. package/packages/shared/src/pi-trust-mirror-types.ts +2 -0
  298. package/packages/shared/src/pi-trust-mirror.ts +18 -8
  299. package/packages/shared/src/pi-trust-resource-digest.ts +18 -12
  300. package/packages/shared/src/pid-namespace.ts +86 -0
  301. package/packages/shared/src/platform/native-ts-register.mjs +1 -1
  302. package/packages/shared/src/platform/process.ts +404 -1
  303. package/packages/shared/src/platform/resolve-pi-shell.ts +38 -9
  304. package/packages/shared/src/platform/spawn-runtime.ts +193 -7
  305. package/packages/shared/src/preview-egress.ts +56 -2
  306. package/packages/shared/src/preview-origins.ts +398 -0
  307. package/packages/shared/src/prompt-answer.ts +9 -5
  308. package/packages/shared/src/protocol.ts +147 -85
  309. package/packages/shared/src/provider-env-catalog.ts +413 -0
  310. package/packages/shared/src/provider-overrides.ts +112 -0
  311. package/packages/shared/src/question-types.ts +6 -0
  312. package/packages/shared/src/recommended-extensions.ts +79 -26
  313. package/packages/shared/src/renderer-by-ext.ts +5 -2
  314. package/packages/shared/src/rest-api.ts +93 -3
  315. package/packages/shared/src/role-schema.ts +24 -0
  316. package/packages/shared/src/route-tiers.ts +94 -3
  317. package/packages/shared/src/runtime-overlay/compat.ts +70 -6
  318. package/packages/shared/src/secret-patterns.ts +49 -0
  319. package/packages/shared/src/source-matching.ts +2 -2
  320. package/packages/shared/src/state-replay.ts +40 -24
  321. package/packages/shared/src/sudo-credential.ts +71 -0
  322. package/packages/shared/src/tool-path-resolve.ts +16 -1
  323. package/packages/shared/src/tool-registry/strategies.ts +1 -1
  324. package/packages/shared/src/tool-workdir.ts +56 -0
  325. package/packages/shared/src/trusted-types-mode.ts +72 -0
  326. package/packages/shared/src/types.ts +68 -109
  327. package/packages/shared/src/vertex-regions.ts +81 -0
  328. package/packages/shared/src/ws-message-tiers.ts +10 -3
  329. package/packages/extension/src/subagent-fanout-admission.ts +0 -234
  330. package/packages/extension/src/subagent-forward-sites.ts +0 -69
  331. package/packages/extension/src/subagent-frame-buffer.ts +0 -245
  332. package/packages/extension/src/subagent-frame-strip.ts +0 -109
  333. package/packages/extension/src/subagent-saturation.ts +0 -196
  334. package/packages/extension/src/subagent-tick-throttle.ts +0 -252
  335. package/packages/shared/src/anthropic-messages-source.ts +0 -8
  336. package/packages/shared/src/dashboard-plugin/anthropic-peer-names.ts +0 -9
  337. 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
- * See change: add-access-grants-and-review.
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
- if (parent === p) return p;
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
- return windows === hostIsWindows ? realpathNearestAncestor(resolved) : resolved;
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
- const { windows, p, canonical } = pathOps(env);
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 = [p.join(home, ".ssh"), p.join(home, ".pi")];
114
- return { whole: whole.map(canonical), sensitive: sensitive.map(canonical) };
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
- return rel !== "" && !rel.startsWith("..") && !ops.p.isAbsolute(rel);
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(subject: string, env?: ForbiddenSubjectsEnv): boolean {
183
- // Built once per call and shared by both halves (design D7): ~18 realpaths, not ~35.
184
- const sets = forbiddenGrantSubjects(env);
185
- return isForbiddenGrantSubject(subject, env, sets) || subsumesForbiddenGrantSubject(subject, env, sets);
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 * from "./node-version.js";
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 type { ViewerKind, FileKind, FileKindResult } from "./file-kind.js";
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 `isAffectedNode` / `isOutOfEnginesRange`) and the Electron
6
- * doctor's system-Node detection (`packages/electron/src/lib/dependency-detector.ts`,
7
- * which consumes `isUsableNodeVersion`) import from here. No package keeps a
8
- * private inline copy — that is the drift hazard this module exists to remove.
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 ranges are encoded:
10
+ * Two floors, one cap:
11
11
  *
12
- * - nodejs/node#58515 Fastify-affected: Node v22.0–v22.18 and v24.1–v24.2.
13
- * The bug (`ERR_INTERNAL_ASSERTION: Unexpected module status 3`) fires when
14
- * Fastify loads its internal ajv-compiler under affected Node versions.
15
- * Fixed in: v22.19+, v24.3+, v25.x. The 22.x cutoff widened from `< 22.18`
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
- * - engines cap from root `package.json#engines.node` (`>=22.19.0 <27`).
20
- * Below the floor: npm refuses with EBADENGINE and pi 0.75+ assumes 22.19
21
- * APIs. At/above the cap (`>=27`): untested.
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
- * Cap history: briefly `<25` in change `openspec-worktree-spawn-button`
24
- * (commit 63a8d531), on the theory that subprocess `npm ci` (worktree-spawn
25
- * bootstrap) would EBADENGINE on Node 25. CI smoke matrices had run Node 25
26
- * cleanly the whole time (they pass `--engine-strict=false`); the reported
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
- * Lockstep contract: when `package.json#engines.node` or the upstream Fastify
38
- * fix range changes, only this file changes — plus the `_smoke.yml`
39
- * `standalone-install-smoke-linux` Node-major set (currently `22, 24, 25, 26`),
40
- * which must cover every supported major. (`ci.yml` carries a single
41
- * `node-version: 22` setup-node step and no Node-major matrix.) The
42
- * `Required: >=22.19.0 <27` literal in `buildEnginesRangeMessage`
43
- * (`packages/server/src/auth/node-guard.ts`) is a third cap site the contract
44
- * cannot express in code; it is guarded by the `node-cap-message-matches-engines`
45
- * repo-lint instead. See change: unify-node-version-gate.
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
- * Canonical minimum Node version — the engines floor shared by the dashboard
50
- * root (`>=22.19.0 <27`), `packages/server` (`>=22.19.0`), and every pi copy
51
- * the dashboard spawns (pi 0.75+ ships `engines.node: ">=22.19.0"`).
52
- *
53
- * Single defining occurrence: `isOutOfEnginesRange` implements its floor half
54
- * THROUGH this constant + `meetsFloor`, and the spawn-runtime ladder
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
- * floors read from the spawned pi copy (or this constant as fallback) — so no
57
- * consumer carries a private floor literal. Lockstep-guarded by
58
- * `node-version.test.ts` (constant ⇄ predicate agreement).
59
- * See change: unify-pi-runtime-identity (task 1.1).
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 MIN_SUPPORTED_NODE = "22.19.0";
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 engines cap (`>=22.19.0 <27`):
130
- * - Too old: major < 22, OR major 22 with minor < 19.
131
- * - Too new: major >= 27.
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, MIN_SUPPORTED_NODE)) return true;
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 AND not Fastify-affected. Accept-set:
145
- * Node 22.19+, 23.x, 24.0, 24.3–24.x, 25.x, 26.x. Rejected: 21.x, 22.0–22.18,
146
- * 24.1–24.2, 27+. (The accept of 23.x is deliberate — the predicates accept
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. Without this guard a
152
- // garbage `--version` output would slip through, since both range
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) && !isAffectedNode(version);
158
+ return !isOutOfEnginesRange(version);
156
159
  }