@blackbelt-technology/pi-agent-dashboard 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (474) hide show
  1. package/AGENTS.md +4 -2
  2. package/README.md +64 -18
  3. package/docs/architecture.md +2325 -270
  4. package/package.json +36 -20
  5. package/packages/extension/package.json +18 -9
  6. package/packages/extension/src/bridge-context.ts +6 -0
  7. package/packages/extension/src/bridge-handlers/dispatch.ts +109 -70
  8. package/packages/extension/src/bridge-handlers/forwarders.ts +19 -42
  9. package/packages/extension/src/bridge-handlers/instance.ts +31 -13
  10. package/packages/extension/src/bridge-handlers/lifecycle.ts +149 -66
  11. package/packages/extension/src/bridge-shutdown.ts +44 -0
  12. package/packages/extension/src/bridge-ticket-client.ts +61 -7
  13. package/packages/extension/src/bridge-tls-checks.ts +79 -0
  14. package/packages/extension/src/bridge.ts +309 -284
  15. package/packages/extension/src/canvas-tool.ts +2 -0
  16. package/packages/extension/src/command-handler.ts +106 -37
  17. package/packages/extension/src/connect-target.ts +23 -0
  18. package/packages/extension/src/connection.ts +153 -38
  19. package/packages/extension/src/credential-guard.ts +300 -0
  20. package/packages/extension/src/custom-entry-forward.ts +27 -18
  21. package/packages/extension/src/dashboard-http-origin.ts +88 -0
  22. package/packages/extension/src/default-model-apply.ts +83 -0
  23. package/packages/extension/src/dev-build.ts +11 -1
  24. package/packages/extension/src/flow-event-wiring.ts +19 -95
  25. package/packages/extension/src/followup-drain.ts +19 -5
  26. package/packages/extension/src/git-link-builder.ts +11 -2
  27. package/packages/extension/src/inbound-limits.ts +138 -0
  28. package/packages/extension/src/local-token-header.ts +77 -6
  29. package/packages/extension/src/model-refresh.ts +69 -0
  30. package/packages/extension/src/path-gate/decide.ts +68 -5
  31. package/packages/extension/src/path-gate/handler.ts +16 -8
  32. package/packages/extension/src/path-gate/index.ts +2 -2
  33. package/packages/extension/src/path-gate/roots.ts +15 -3
  34. package/packages/extension/src/path-gate/suppression.ts +3 -0
  35. package/packages/extension/src/pi-env.d.ts +8 -1
  36. package/packages/extension/src/pi-retry-settings.ts +11 -2
  37. package/packages/extension/src/pinned-endpoint.ts +44 -0
  38. package/packages/extension/src/plugin-event-forward-registry.ts +90 -14
  39. package/packages/extension/src/preview-path-link.ts +151 -0
  40. package/packages/extension/src/project-init/scaffold.ts +98 -35
  41. package/packages/extension/src/project-trust-live.ts +143 -0
  42. package/packages/extension/src/project-trust.ts +178 -30
  43. package/packages/extension/src/provider-model-cache.ts +118 -0
  44. package/packages/extension/src/provider-register.ts +487 -46
  45. package/packages/extension/src/remote-registration-gate.ts +21 -21
  46. package/packages/extension/src/remote-upgrade-preparer.ts +104 -0
  47. package/packages/extension/src/retry-tracker.ts +90 -7
  48. package/packages/extension/src/role-manager.ts +4 -2
  49. package/packages/extension/src/role-model-tools.ts +68 -10
  50. package/packages/extension/src/server-auto-start.ts +69 -3
  51. package/packages/extension/src/server-launcher.ts +26 -8
  52. package/packages/extension/src/server-proof-probe.ts +117 -0
  53. package/packages/extension/src/session-sync.ts +53 -24
  54. package/packages/extension/src/spawn-new-session.ts +22 -0
  55. package/packages/extension/src/steer-buffer.ts +164 -0
  56. package/packages/extension/src/stream-forward-buffer.ts +64 -15
  57. package/packages/extension/src/sudo-askpass/config-reader.ts +32 -0
  58. package/packages/extension/src/sudo-askpass/controller.ts +405 -0
  59. package/packages/extension/src/sudo-askpass/helper-script.ts +69 -0
  60. package/packages/extension/src/sudo-askpass/in-flight.ts +79 -0
  61. package/packages/extension/src/sudo-askpass/index.ts +11 -0
  62. package/packages/extension/src/sudo-askpass/install.ts +143 -0
  63. package/packages/extension/src/sudo-askpass/password-cache.ts +118 -0
  64. package/packages/extension/src/sudo-askpass/prompt-text.ts +55 -0
  65. package/packages/extension/src/sudo-askpass/protocol.ts +18 -0
  66. package/packages/extension/src/sudo-askpass/sudo-mask-registry.ts +52 -0
  67. package/packages/extension/src/terminal-reload.ts +19 -5
  68. package/packages/extension/src/tool-update-filter-registry.ts +210 -0
  69. package/packages/extension/src/vault-delivery.ts +11 -1
  70. package/packages/extension/src/vault-redaction.ts +4 -3
  71. package/packages/server/package.json +17 -14
  72. package/packages/server/src/access/access-denials.ts +8 -0
  73. package/packages/server/src/access/access-grants.ts +303 -64
  74. package/packages/server/src/access/access-health.ts +10 -0
  75. package/packages/server/src/access/access-plane.ts +12 -1
  76. package/packages/server/src/access/containment-gate.ts +113 -30
  77. package/packages/server/src/access/cwd-verdict.ts +3 -3
  78. package/packages/server/src/access/denial-hold.ts +3 -0
  79. package/packages/server/src/access/grant-coordinator.ts +17 -1
  80. package/packages/server/src/access/named-grant.ts +3 -0
  81. package/packages/server/src/access/pending-grant-registry.ts +32 -5
  82. package/packages/server/src/access/pi-trust-live.ts +244 -0
  83. package/packages/server/src/access/pi-trust-mirror-service.ts +50 -11
  84. package/packages/server/src/access/planes.ts +107 -1
  85. package/packages/server/src/access/preview-egress-store.ts +153 -0
  86. package/packages/server/src/access/prompt-channel.ts +5 -0
  87. package/packages/server/src/access/provisioning-wiring.ts +113 -0
  88. package/packages/server/src/access/provisioning.ts +763 -0
  89. package/packages/server/src/access/verified-read.ts +24 -7
  90. package/packages/server/src/access/yolo-session.ts +54 -2
  91. package/packages/server/src/acp-bridge/acp-session-adapter.ts +18 -5
  92. package/packages/server/src/acp-bridge/server-requests.ts +10 -4
  93. package/packages/server/src/agent-events/agent-event-hub.ts +158 -0
  94. package/packages/server/src/auth/audit-log.ts +108 -0
  95. package/packages/server/src/auth/auth-plugin.ts +230 -38
  96. package/packages/server/src/auth/auth.ts +104 -4
  97. package/packages/server/src/auth/bearer-auth.ts +52 -12
  98. package/packages/server/src/auth/bridge-ticket-eligibility.ts +53 -10
  99. package/packages/server/src/auth/cors-origin.ts +90 -30
  100. package/packages/server/src/auth/credential-envelope.ts +233 -0
  101. package/packages/server/src/auth/credential-key-worker.d.mts +16 -0
  102. package/packages/server/src/auth/credential-key-worker.mjs +108 -0
  103. package/packages/server/src/auth/credential-key.ts +479 -0
  104. package/packages/server/src/auth/credential-migration.ts +162 -0
  105. package/packages/server/src/auth/csp-report-paths.ts +26 -0
  106. package/packages/server/src/auth/csp-report-sink.ts +302 -0
  107. package/packages/server/src/auth/csp-report-store.ts +406 -0
  108. package/packages/server/src/auth/csp.ts +145 -11
  109. package/packages/server/src/auth/dashboard-credential-store.ts +4 -0
  110. package/packages/server/src/auth/dashboard-state-caller.ts +29 -0
  111. package/packages/server/src/auth/device-proof.ts +202 -0
  112. package/packages/server/src/auth/duplicate-cookie-gate.ts +271 -0
  113. package/packages/server/src/auth/host-admission.ts +7 -0
  114. package/packages/server/src/auth/host-gate.ts +13 -2
  115. package/packages/server/src/auth/local-proof-refusal-log.ts +89 -0
  116. package/packages/server/src/auth/local-proof.ts +69 -18
  117. package/packages/server/src/auth/localhost-guard.ts +98 -33
  118. package/packages/server/src/auth/locked-json-file.ts +68 -6
  119. package/packages/server/src/auth/models-json-store.ts +269 -0
  120. package/packages/server/src/auth/mutation-origin-gate.ts +5 -2
  121. package/packages/server/src/auth/nav-intent.ts +72 -0
  122. package/packages/server/src/auth/node-guard.ts +36 -49
  123. package/packages/server/src/auth/passkey/passkey-assets.ts +99 -0
  124. package/packages/server/src/auth/passkey/passkey-pages.ts +17 -81
  125. package/packages/server/src/auth/passkey/passkey-routes.ts +8 -0
  126. package/packages/server/src/auth/pi-legacy-credentials.ts +3 -0
  127. package/packages/server/src/auth/plugin-credential-store.ts +81 -10
  128. package/packages/server/src/auth/plugin-server-trust.ts +29 -0
  129. package/packages/server/src/auth/plugin-trust-store.ts +103 -0
  130. package/packages/server/src/auth/proven-tls.ts +45 -0
  131. package/packages/server/src/auth/provider-auth-storage.ts +214 -12
  132. package/packages/server/src/auth/provider-block-checks.ts +321 -0
  133. package/packages/server/src/auth/provider-host-detect.ts +151 -0
  134. package/packages/server/src/auth/provider-key-file.ts +71 -0
  135. package/packages/server/src/auth/provider-readiness.ts +91 -0
  136. package/packages/server/src/auth/radius-mcp.ts +1 -1
  137. package/packages/server/src/auth/request-principal.ts +32 -0
  138. package/packages/server/src/auth/route-tier-gate.ts +3 -2
  139. package/packages/server/src/auth/secret-rotation.ts +246 -0
  140. package/packages/server/src/auth/secure-origin.ts +56 -0
  141. package/packages/server/src/auth/serve-app-host.ts +111 -11
  142. package/packages/server/src/auth/vertex-key-check.ts +140 -0
  143. package/packages/server/src/auth/ws-ticket.ts +40 -2
  144. package/packages/server/src/auth/ws-upgrade-reject-log.ts +4 -1
  145. package/packages/server/src/browse.ts +73 -20
  146. package/packages/server/src/browser-handlers/acp-guard.ts +1 -4
  147. package/packages/server/src/browser-handlers/directory-handler.ts +34 -24
  148. package/packages/server/src/browser-handlers/folder-gate.ts +55 -0
  149. package/packages/server/src/browser-handlers/handler-context.ts +25 -2
  150. package/packages/server/src/browser-handlers/session-action-handler.ts +167 -63
  151. package/packages/server/src/browser-handlers/spawn-choice.ts +138 -1
  152. package/packages/server/src/browser-handlers/subscription-handler.ts +146 -3
  153. package/packages/server/src/browser-handlers/terminal-handler.ts +108 -10
  154. package/packages/server/src/build-plugin-send-prompt.ts +18 -0
  155. package/packages/server/src/canvas/canvas-accumulator.ts +35 -7
  156. package/packages/server/src/cli/credentials-command.ts +555 -0
  157. package/packages/server/src/cli.ts +229 -53
  158. package/packages/server/src/config-api.ts +53 -35
  159. package/packages/server/src/config-snapshot.ts +197 -1
  160. package/packages/server/src/directory-service.ts +193 -68
  161. package/packages/server/src/embed-lifecycle/idle-reaper.ts +13 -3
  162. package/packages/server/src/event-wiring.ts +322 -207
  163. package/packages/server/src/git-worktree/ensure-worktree.ts +185 -0
  164. package/packages/server/src/git-worktree/git-operations.ts +45 -11
  165. package/packages/server/src/git-worktree/redact-git-text.ts +124 -0
  166. package/packages/server/src/git-worktree/ref-arg.ts +39 -0
  167. package/packages/server/src/git-worktree/repo-lock.ts +42 -0
  168. package/packages/server/src/git-worktree/start-worktree-init.ts +151 -0
  169. package/packages/server/src/git-worktree/worktree-init-trust.ts +43 -1
  170. package/packages/server/src/git-worktree/worktree-init.ts +5 -1
  171. package/packages/server/src/identity/http-road-classification.ts +18 -2
  172. package/packages/server/src/identity/identity-floor.ts +5 -2
  173. package/packages/server/src/identity/ws-message-scope.ts +11 -3
  174. package/packages/server/src/identity/ws-road-classification.ts +3 -1
  175. package/packages/server/src/known-server-moves.ts +36 -15
  176. package/packages/server/src/lib/browse-roots.ts +129 -17
  177. package/packages/server/src/lib/client-dist.ts +36 -21
  178. package/packages/server/src/lib/content-disposition.ts +20 -0
  179. package/packages/server/src/lib/dashboard-state-guard.ts +513 -0
  180. package/packages/server/src/lib/diagram-render.ts +4 -6
  181. package/packages/server/src/lib/eml.ts +5 -10
  182. package/packages/server/src/lib/file-cwd-admission.ts +145 -0
  183. package/packages/server/src/lib/frame-policy-probe.ts +308 -0
  184. package/packages/server/src/lib/frame-policy-test-seam.ts +99 -0
  185. package/packages/server/src/lib/frame-policy-verdict.ts +125 -0
  186. package/packages/server/src/lib/grep-worker.ts +23 -0
  187. package/packages/server/src/lib/grep.ts +96 -7
  188. package/packages/server/src/lib/index-html.ts +81 -0
  189. package/packages/server/src/lib/mention-fuzzy-index.ts +263 -0
  190. package/packages/server/src/lib/office-preview.ts +49 -13
  191. package/packages/server/src/lib/path-containment.ts +50 -10
  192. package/packages/server/src/lib/resolve-file-mention.ts +234 -40
  193. package/packages/server/src/lib/resolve-mentions-batch.ts +143 -0
  194. package/packages/server/src/lib/route-admission.ts +80 -0
  195. package/packages/server/src/lib/writable-handler-target.ts +4 -0
  196. package/packages/server/src/lib/writable-md-target.ts +26 -0
  197. package/packages/server/src/lifecycle/boot-parent-liveness.ts +10 -25
  198. package/packages/server/src/lifecycle/credential-exit-barrier.ts +207 -0
  199. package/packages/server/src/lifecycle/exit-signal.ts +43 -0
  200. package/packages/server/src/lifecycle/recovery-server.ts +65 -18
  201. package/packages/server/src/live-server/capability-redact.ts +31 -0
  202. package/packages/server/src/live-server/live-browser-gate.ts +22 -0
  203. package/packages/server/src/live-server/live-capability.ts +615 -44
  204. package/packages/server/src/live-server/live-csp-report.ts +63 -0
  205. package/packages/server/src/live-server/live-csp.ts +141 -0
  206. package/packages/server/src/live-server/live-egress.ts +435 -0
  207. package/packages/server/src/live-server/live-exposure.ts +149 -0
  208. package/packages/server/src/live-server/live-log.ts +25 -0
  209. package/packages/server/src/live-server/live-origin-scan.ts +298 -0
  210. package/packages/server/src/live-server/live-server-manager.ts +220 -33
  211. package/packages/server/src/live-server/live-server-proxy.ts +411 -50
  212. package/packages/server/src/live-server/live-static.ts +231 -0
  213. package/packages/server/src/live-server/preview-dispatch.ts +286 -0
  214. package/packages/server/src/live-server/preview-observe.ts +53 -0
  215. package/packages/server/src/live-server/preview-origin.ts +182 -0
  216. package/packages/server/src/live-server/preview-path-bridge.ts +70 -0
  217. package/packages/server/src/live-server/preview-path-store.ts +420 -0
  218. package/packages/server/src/live-server/preview-path.ts +40 -0
  219. package/packages/server/src/live-server/preview-pool.ts +385 -0
  220. package/packages/server/src/live-server/preview-preflight.ts +41 -0
  221. package/packages/server/src/live-server/preview-reserve.ts +44 -0
  222. package/packages/server/src/live-server/preview-tier.ts +217 -0
  223. package/packages/server/src/live-server/preview-viewers.ts +54 -0
  224. package/packages/server/src/live-server/preview-ws-registry.ts +43 -0
  225. package/packages/server/src/model-proxy/custom-provider-discovery.ts +4 -2
  226. package/packages/server/src/model-proxy/internal-auth-storage.ts +5 -1
  227. package/packages/server/src/model-proxy/internal-registry.ts +283 -21
  228. package/packages/server/src/model-proxy/models-block-apply.ts +291 -0
  229. package/packages/server/src/model-proxy/pi-models-validator.ts +164 -0
  230. package/packages/server/src/model-proxy/registry-singleton.ts +44 -9
  231. package/packages/server/src/model-proxy/server-model-runtime.ts +17 -0
  232. package/packages/server/src/openspec/dependencies-file.ts +122 -0
  233. package/packages/server/src/openspec/openspec-change-watcher.ts +3 -1
  234. package/packages/server/src/openspec/openspec-dependency-inputs.ts +281 -0
  235. package/packages/server/src/openspec/openspec-poll-fs-helpers.ts +72 -26
  236. package/packages/server/src/openspec/openspec-poll-worker-pool.ts +48 -12
  237. package/packages/server/src/openspec/openspec-poll-worker.ts +95 -9
  238. package/packages/server/src/openspec/readiness.ts +1 -1
  239. package/packages/server/src/openspec/workflow-schema-status.ts +379 -0
  240. package/packages/server/src/openspec/workflow-schema.ts +141 -267
  241. package/packages/server/src/package/npm-search-proxy.ts +5 -2
  242. package/packages/server/src/package/provider-probe.ts +202 -7
  243. package/packages/server/src/pairing/browser-gateway.ts +325 -51
  244. package/packages/server/src/pairing/device-key-intake.ts +120 -0
  245. package/packages/server/src/pairing/device-token-services.ts +26 -0
  246. package/packages/server/src/pairing/paired-devices.ts +702 -27
  247. package/packages/server/src/pairing/pairing.ts +103 -11
  248. package/packages/server/src/pairing/{subagent-resync-routing.ts → resync-requester-registry.ts} +6 -10
  249. package/packages/server/src/pairing/socket-locality.ts +26 -0
  250. package/packages/server/src/pairing/ws-tier-gate.ts +74 -0
  251. package/packages/server/src/pending/pending-attach-registry.ts +15 -0
  252. package/packages/server/src/pending/pending-initial-prompt-registry.ts +15 -0
  253. package/packages/server/src/persistence/memory-event-store.ts +251 -296
  254. package/packages/server/src/persistence/preferences-store.ts +61 -2
  255. package/packages/server/src/pi/bridge-channel.ts +33 -0
  256. package/packages/server/src/pi/bridge-contention.ts +84 -2
  257. package/packages/server/src/pi/bridge-upgrade-auth.ts +18 -3
  258. package/packages/server/src/pi/gateway-listeners.ts +9 -3
  259. package/packages/server/src/pi/host-project-trust.ts +29 -15
  260. package/packages/server/src/pi/pi-gateway.ts +398 -41
  261. package/packages/server/src/pi/provisional-registration.ts +4 -1
  262. package/packages/server/src/pi/resource-toggle-trust.ts +18 -7
  263. package/packages/server/src/pi-agent-settings.ts +95 -301
  264. package/packages/server/src/pi-default-remirror.ts +89 -0
  265. package/packages/server/src/plugin-append-event.ts +35 -0
  266. package/packages/server/src/plugin-discovery-wiring.ts +142 -0
  267. package/packages/server/src/plugin-entry-stats.ts +61 -0
  268. package/packages/server/src/plugin-event-seam.ts +116 -4
  269. package/packages/server/src/plugin-local-request.ts +207 -0
  270. package/packages/server/src/plugin-ownership.ts +111 -0
  271. package/packages/server/src/plugin-policy-registry.ts +297 -0
  272. package/packages/server/src/plugin-request-lane.ts +92 -16
  273. package/packages/server/src/plugin-runtime-clients.ts +89 -0
  274. package/packages/server/src/preferences-relay.ts +20 -0
  275. package/packages/server/src/project-seed.ts +347 -0
  276. package/packages/server/src/push/push-transports/webhook-url.ts +8 -5
  277. package/packages/server/src/questions/question-store.ts +3 -2
  278. package/packages/server/src/routes/access-routes.ts +182 -15
  279. package/packages/server/src/routes/acme-routes.ts +14 -4
  280. package/packages/server/src/routes/agent-event-stream-routes.ts +137 -0
  281. package/packages/server/src/routes/canvas-types-routes.ts +20 -6
  282. package/packages/server/src/routes/csp-violations-routes.ts +162 -0
  283. package/packages/server/src/routes/file-routes.ts +640 -279
  284. package/packages/server/src/routes/file-write-binary-routes.ts +97 -24
  285. package/packages/server/src/routes/folder-project-routes.ts +18 -12
  286. package/packages/server/src/routes/frame-policy-routes.ts +215 -0
  287. package/packages/server/src/routes/git-routes.ts +340 -273
  288. package/packages/server/src/routes/grep-routes.ts +64 -14
  289. package/packages/server/src/routes/known-servers-routes.ts +189 -91
  290. package/packages/server/src/routes/live-server-routes.ts +572 -15
  291. package/packages/server/src/routes/local-proof-routes.ts +14 -0
  292. package/packages/server/src/routes/models-introspection-routes.ts +1 -1
  293. package/packages/server/src/routes/nav-intent-routes.ts +46 -0
  294. package/packages/server/src/routes/openspec-group-routes.ts +53 -44
  295. package/packages/server/src/routes/openspec-routes.ts +396 -31
  296. package/packages/server/src/routes/package-routes.ts +58 -10
  297. package/packages/server/src/routes/pairing-routes.ts +342 -17
  298. package/packages/server/src/routes/pi-settings-routes.ts +2 -0
  299. package/packages/server/src/routes/pi-trust-query-routes.ts +330 -0
  300. package/packages/server/src/routes/plugin-activation-routes.ts +59 -0
  301. package/packages/server/src/routes/plugin-runtime-client-routes.ts +149 -0
  302. package/packages/server/src/routes/preferences-auto-name-routes.ts +5 -2
  303. package/packages/server/src/routes/preferences-claude-compat-routes.ts +49 -0
  304. package/packages/server/src/routes/provider-auth-routes.ts +181 -10
  305. package/packages/server/src/routes/provider-override-routes.ts +158 -0
  306. package/packages/server/src/routes/provider-routes.ts +348 -86
  307. package/packages/server/src/routes/resource-activation-routes.ts +18 -4
  308. package/packages/server/src/routes/session-routes.ts +75 -25
  309. package/packages/server/src/routes/system-routes.ts +169 -52
  310. package/packages/server/src/routes/ui-link-base.ts +88 -0
  311. package/packages/server/src/rpc-keeper/keeper-manager.ts +196 -25
  312. package/packages/server/src/rpc-keeper/keeper.cjs +37 -23
  313. package/packages/server/src/runtime-overlay/extension-reload.ts +16 -10
  314. package/packages/server/src/runtime-overlay/runtime-io.ts +2 -9
  315. package/packages/server/src/runtime-overlay/runtime-stager.ts +4 -2
  316. package/packages/server/src/server.ts +1139 -291
  317. package/packages/server/src/services/cli-service.ts +59 -10
  318. package/packages/server/src/services/secrets-resolver.ts +46 -30
  319. package/packages/server/src/session/custom-event-group-annotation.ts +3 -3
  320. package/packages/server/src/session/custom-event-group-resolver.ts +10 -5
  321. package/packages/server/src/session/death-reason.ts +11 -7
  322. package/packages/server/src/session/event-status-extraction.ts +5 -1
  323. package/packages/server/src/session/hydration-state.ts +148 -0
  324. package/packages/server/src/session/memory-session-manager.ts +31 -2
  325. package/packages/server/src/session/open-tool-calls.ts +81 -47
  326. package/packages/server/src/session/pid-target.ts +127 -0
  327. package/packages/server/src/session/replay-compaction.ts +18 -5
  328. package/packages/server/src/session/replay-exit-controller.ts +221 -0
  329. package/packages/server/src/session/retained-transcript.ts +9 -2
  330. package/packages/server/src/session/seed-discovered-history.ts +85 -0
  331. package/packages/server/src/session/server-pid-context.ts +14 -0
  332. package/packages/server/src/session/session-api.ts +78 -29
  333. package/packages/server/src/session/session-archive.ts +7 -0
  334. package/packages/server/src/session/session-bootstrap.ts +9 -54
  335. package/packages/server/src/session/session-load-worker-pool.ts +11 -1
  336. package/packages/server/src/session/session-load-worker.ts +32 -4
  337. package/packages/server/src/spawn-process/abort-spawned-run.ts +28 -9
  338. package/packages/server/src/spawn-process/acp-spawn.ts +8 -2
  339. package/packages/server/src/spawn-process/headless-pid-registry.ts +393 -77
  340. package/packages/server/src/spawn-process/link-register.ts +42 -0
  341. package/packages/server/src/spawn-process/plugin-spawn-choice.ts +48 -0
  342. package/packages/server/src/spawn-process/plugin-spawn-worktree.ts +290 -0
  343. package/packages/server/src/spawn-process/process-classifier.ts +8 -3
  344. package/packages/server/src/spawn-process/process-manager.ts +61 -6
  345. package/packages/server/src/spawn-process/restored-identity.ts +112 -0
  346. package/packages/server/src/spawn-process/session-terminator.ts +179 -18
  347. package/packages/server/src/spawn-process/spawn-env-contributors.ts +2 -1
  348. package/packages/server/src/spawn-process/spawn-failure-log.ts +9 -0
  349. package/packages/server/src/spawn-process/spawn-register-watchdog.ts +44 -19
  350. package/packages/server/src/sudo-credential/relay.ts +337 -0
  351. package/packages/server/src/terminal/terminal-gateway.ts +10 -0
  352. package/packages/server/src/terminal/terminal-manager.ts +54 -46
  353. package/packages/server/src/tls/sources/acme/credentials.ts +3 -2
  354. package/packages/server/src/tls/sources/acme/runtime.ts +2 -1
  355. package/packages/server/src/tls/tls-bridge-route.ts +61 -0
  356. package/packages/server/src/tls/tls-config-validation.ts +2 -0
  357. package/packages/server/src/vault/device-expiry-sweep.ts +36 -0
  358. package/packages/server/src/vault/vault-delivery-hub.ts +172 -26
  359. package/packages/server/src/vault/vault-routes.ts +9 -2
  360. package/packages/server/src/vault/vault-store.ts +87 -24
  361. package/packages/server/src/watch-files-handler.ts +66 -0
  362. package/packages/server/vendor/xlsx/LICENSE +201 -0
  363. package/packages/server/vendor/xlsx/PROVENANCE.json +13 -0
  364. package/packages/server/vendor/xlsx/xlsx.d.mts +1065 -0
  365. package/packages/server/vendor/xlsx/xlsx.mjs +28228 -0
  366. package/packages/shared/package.json +4 -2
  367. package/packages/shared/src/agent-credential-files.ts +32 -0
  368. package/packages/shared/src/browser-protocol.ts +285 -59
  369. package/packages/shared/src/canvas-declare.ts +27 -0
  370. package/packages/shared/src/canvas-detect.ts +1 -1
  371. package/packages/shared/src/canvas-types.ts +2 -2
  372. package/packages/shared/src/config.ts +443 -187
  373. package/packages/shared/src/containment-guard.ts +45 -0
  374. package/packages/shared/src/credential-encryption.ts +87 -0
  375. package/packages/shared/src/custom-event-groups.ts +2 -0
  376. package/packages/shared/src/dashboard-plugin/claude-compat.ts +159 -0
  377. package/packages/shared/src/dashboard-plugin/event-type-owners.ts +50 -0
  378. package/packages/shared/src/dashboard-plugin/file-handler.ts +2 -0
  379. package/packages/shared/src/dashboard-plugin/host-api.ts +61 -0
  380. package/packages/shared/src/dashboard-plugin/host-fx-classes.ts +23 -0
  381. package/packages/shared/src/dashboard-plugin/host-import-map.ts +38 -0
  382. package/packages/shared/src/dashboard-plugin/index.ts +2 -0
  383. package/packages/shared/src/dashboard-plugin/manifest-types.ts +100 -1
  384. package/packages/shared/src/dashboard-plugin/plugin-status.ts +58 -3
  385. package/packages/shared/src/dashboard-plugin/replay-entry-types.ts +46 -0
  386. package/packages/shared/src/dashboard-plugin/slot-props.ts +47 -3
  387. package/packages/shared/src/dashboard-plugin/slot-types.ts +9 -1
  388. package/packages/shared/src/dashboard-plugin/ui-primitives.ts +39 -3
  389. package/packages/shared/src/device-key-proof.ts +309 -0
  390. package/packages/shared/src/display-prefs.ts +13 -0
  391. package/packages/shared/src/doctor-core.ts +94 -27
  392. package/packages/shared/src/event-forward-declaration.ts +85 -12
  393. package/packages/shared/src/forbidden-subjects.ts +126 -14
  394. package/packages/shared/src/heap-limits.ts +0 -30
  395. package/packages/shared/src/host-admission.ts +2 -1
  396. package/packages/shared/src/index.ts +7 -6
  397. package/packages/shared/src/live-server.ts +161 -0
  398. package/packages/shared/src/local-proof-signal.ts +16 -0
  399. package/packages/shared/src/loopback-host.ts +26 -0
  400. package/packages/shared/src/mcp/verb-tiers.generated.ts +176 -0
  401. package/packages/shared/src/mdns-discovery.ts +25 -6
  402. package/packages/shared/src/models-json-reader.ts +41 -0
  403. package/packages/shared/src/nav-intent.ts +29 -0
  404. package/packages/shared/src/network-denial-signal.ts +15 -0
  405. package/packages/shared/src/node-version.ts +63 -60
  406. package/packages/shared/src/openspec-dependencies.ts +760 -0
  407. package/packages/shared/src/openspec-poller.ts +3 -2
  408. package/packages/shared/src/pairing-knock-client.ts +135 -11
  409. package/packages/shared/src/pi-agent-settings-lock.ts +311 -0
  410. package/packages/shared/src/pi-path-compare.ts +31 -0
  411. package/packages/shared/src/pi-settings-schema.ts +52 -9
  412. package/packages/shared/src/pi-trust-live-query.ts +93 -0
  413. package/packages/shared/src/pi-trust-mirror-snapshot.ts +21 -11
  414. package/packages/shared/src/pi-trust-mirror-types.ts +38 -3
  415. package/packages/shared/src/pi-trust-mirror.ts +47 -11
  416. package/packages/shared/src/pi-trust-resource-digest.ts +261 -0
  417. package/packages/shared/src/pid-namespace.ts +86 -0
  418. package/packages/shared/src/platform/ensure-bundled-git.ts +57 -34
  419. package/packages/shared/src/platform/git-source.ts +88 -26
  420. package/packages/shared/src/platform/git.ts +14 -8
  421. package/packages/shared/src/platform/native-ts-register.mjs +1 -1
  422. package/packages/shared/src/platform/process.ts +452 -5
  423. package/packages/shared/src/platform/resolve-pi-shell.ts +105 -0
  424. package/packages/shared/src/platform/select-git-source.ts +7 -0
  425. package/packages/shared/src/platform/spawn-runtime.ts +193 -7
  426. package/packages/shared/src/plugin-route-cwd.ts +95 -0
  427. package/packages/shared/src/preview-egress.ts +192 -0
  428. package/packages/shared/src/preview-origins.ts +398 -0
  429. package/packages/shared/src/project-root.ts +16 -0
  430. package/packages/shared/src/prompt-answer.ts +9 -5
  431. package/packages/shared/src/protocol.ts +187 -86
  432. package/packages/shared/src/provider-env-catalog.ts +413 -0
  433. package/packages/shared/src/provider-overrides.ts +112 -0
  434. package/packages/shared/src/question-types.ts +6 -0
  435. package/packages/shared/src/recommended-extensions.ts +97 -26
  436. package/packages/shared/src/recovery-timing.ts +27 -0
  437. package/packages/shared/src/remote-credentials.ts +63 -0
  438. package/packages/shared/src/renderer-by-ext.ts +5 -2
  439. package/packages/shared/src/rest-api.ts +148 -11
  440. package/packages/shared/src/role-schema.ts +24 -0
  441. package/packages/shared/src/route-tiers.ts +149 -4
  442. package/packages/shared/src/runtime-overlay/archive-safety.d.mts +2 -0
  443. package/packages/shared/src/runtime-overlay/archive-safety.mjs +33 -0
  444. package/packages/shared/src/runtime-overlay/compat.ts +70 -6
  445. package/packages/shared/src/runtime-overlay/manifest.d.mts +7 -0
  446. package/packages/shared/src/runtime-overlay/manifest.mjs +22 -2
  447. package/packages/shared/src/safe-local-path.ts +24 -0
  448. package/packages/shared/src/sanitize-profiles.ts +98 -0
  449. package/packages/shared/src/secret-patterns.ts +49 -0
  450. package/packages/shared/src/server-launcher.ts +9 -1
  451. package/packages/shared/src/server-pinning.ts +55 -2
  452. package/packages/shared/src/server-routes.ts +462 -0
  453. package/packages/shared/src/session-ui-path.ts +11 -0
  454. package/packages/shared/src/source-matching.ts +2 -2
  455. package/packages/shared/src/state-replay.ts +40 -24
  456. package/packages/shared/src/sudo-credential.ts +71 -0
  457. package/packages/shared/src/tls-only-token.ts +16 -0
  458. package/packages/shared/src/tool-path-resolve.ts +16 -1
  459. package/packages/shared/src/tool-registry/definitions.ts +5 -5
  460. package/packages/shared/src/tool-registry/strategies.ts +13 -12
  461. package/packages/shared/src/tool-workdir.ts +56 -0
  462. package/packages/shared/src/trusted-types-mode.ts +72 -0
  463. package/packages/shared/src/types.ts +134 -109
  464. package/packages/shared/src/url-policy.ts +96 -0
  465. package/packages/shared/src/vault-delivery.ts +15 -0
  466. package/packages/shared/src/vertex-regions.ts +81 -0
  467. package/packages/shared/src/ws-message-tiers.ts +11 -3
  468. package/packages/extension/src/subagent-fanout-admission.ts +0 -234
  469. package/packages/extension/src/subagent-forward-sites.ts +0 -69
  470. package/packages/extension/src/subagent-frame-buffer.ts +0 -245
  471. package/packages/extension/src/subagent-frame-strip.ts +0 -109
  472. package/packages/extension/src/subagent-saturation.ts +0 -196
  473. package/packages/extension/src/subagent-tick-throttle.ts +0 -252
  474. package/packages/shared/src/anthropic-messages-source.ts +0 -8
@@ -20,7 +20,8 @@ export type BridgeLoadSource = "packages[]" | "dashboardPluginBridges" | "none";
20
20
  * See change: add-plugin-activation-ui (Layer 1.5).
21
21
  */
22
22
  export interface PluginRequirementReport {
23
- piExtensions: { name: string; satisfied: boolean }[];
23
+ /** `warning`: satisfied without a verifiable version (git/local install). See change: move-subagents-to-plugin. */
24
+ piExtensions: { name: string; satisfied: boolean; warning?: string }[];
24
25
  binaries: { name: string; satisfied: boolean; resolvedPath?: string }[];
25
26
  services: { name: string; satisfied: boolean; error?: string }[];
26
27
  /**
@@ -34,17 +35,59 @@ export interface PluginRequirementReport {
34
35
 
35
36
  /**
36
37
  * Latest bridge-status probe forwarded from the pi-side extension (for
37
- * status-emitting bridges like flows-anthropic-bridge). Omitted when the
38
+ * status-emitting bridges). Omitted when the
38
39
  * plugin has no bridge or hasn't reported yet.
39
40
  */
40
41
  export interface BridgeProbeSnapshot {
41
42
  status: "probing" | "waiting_peers" | "active" | "degraded";
42
- /** Per-peer probe results keyed by the peer spec (e.g. "@pi/anthropic-messages"). */
43
+ /** Per-peer probe results keyed by the peer spec (e.g. "pi-flows"). */
43
44
  peers: Record<string, { ok: boolean; reason?: string }>;
44
45
  /** Unix-ms timestamp when the bridge emitted this snapshot. */
45
46
  at: number;
46
47
  }
47
48
 
49
+ /**
50
+ * Which discovery source a plugin came from. `pi-package` = a `settings.json#packages[]`
51
+ * (user scope) package carrying a manifest (lowest priority, server entry default-deny);
52
+ * `local-detected` = a project-scope (`<cwd>/.pi/settings.json`) package that is reported
53
+ * but never loaded. See change: decouple-plugins-from-core (design D7, D12, D15).
54
+ */
55
+ export type PluginDiscoverySource = "workspace" | "installed" | "bundled" | "pi-package" | "local-detected";
56
+
57
+ /** A losing duplicate of a plugin id, recorded on the winner (never loaded). */
58
+ export interface PluginShadowedCopy {
59
+ source: PluginDiscoverySource;
60
+ packageDir: string;
61
+ }
62
+
63
+ /** Result of evaluating a manifest `hostApi` range at discovery. */
64
+ export interface PluginHostApiStatus {
65
+ /** The manifest range; absent when the plugin declares none. */
66
+ range?: string;
67
+ compatible: boolean;
68
+ }
69
+
70
+ /** Why a plugin's client was refused (design D12 precedence: structural, then config, then consent). */
71
+ export type PluginClientRefusedReason =
72
+ | "build-undeclared"
73
+ | "no-bundle"
74
+ | "host-api"
75
+ | "disabled"
76
+ | "missing-dep"
77
+ | "untrusted"
78
+ | "pin-mismatch";
79
+
80
+ /** Client delivery state. Phase 5 adds the `bundled`/`runtime`/`none` handling that fills `sha256`. */
81
+ export interface PluginClientStatus {
82
+ delivery: "bundled" | "runtime" | "refused" | "none";
83
+ refusedReason?: PluginClientRefusedReason;
84
+ /**
85
+ * Content hash of the runtime client bundle. Appears only on the guarded `GET /api/plugins` and
86
+ * `plugins_changed`; NEVER on the unauthenticated `/api/health.plugins[]`.
87
+ */
88
+ sha256?: string;
89
+ }
90
+
48
91
  /** Status of a single discovered plugin, reported by /api/health. */
49
92
  export interface PluginStatus {
50
93
  id: string;
@@ -60,6 +103,18 @@ export interface PluginStatus {
60
103
  error?: string;
61
104
  /** Number of slot claims declared in the plugin's manifest. */
62
105
  claims: number;
106
+ /** Discovery source of the plugin. See change: decouple-plugins-from-core. */
107
+ source?: PluginDiscoverySource;
108
+ /** Losing duplicates of this id (one row per id; never loaded). See change: decouple-plugins-from-core (D15). */
109
+ shadowed?: PluginShadowedCopy[];
110
+ /** Loaded plugin whose package changed or vanished: the running copy is stale until a server restart. */
111
+ restartRequired?: boolean;
112
+ /** Host API range evaluation (absent when the plugin declares none and none is required). */
113
+ hostApi?: PluginHostApiStatus;
114
+ /** Client delivery; `refused` + `host-api` when the host API gate refused the plugin. */
115
+ client?: PluginClientStatus;
116
+ /** `serveApp` mount outcome; `refused` when the host refused the mount. */
117
+ serveApp?: "mounted" | "refused";
63
118
  /**
64
119
  * Where the bridge entry is registered, classified at health-check time.
65
120
  * See change: fix-pi-flows-end-to-end Group 2.
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Plugin-owned persisted custom-entry types (`pi-dashboard-plugin.replayEntryTypes`).
3
+ *
4
+ * A plugin declares the `type: "custom"` entry `customType` values it owns.
5
+ * Core replays an ENABLED plugin's types as their recorded protocol events
6
+ * (`state-replay.ts`) and keeps EVERY declared type — enabled or not — out of
7
+ * the generic custom-entry paths (a disabled plugin's entries stay hidden).
8
+ * Core never names a plugin entry type. See change: update-flows-plugin (D3, G5, G6).
9
+ */
10
+
11
+ /** Same shape as a custom entry type: printable, no whitespace, ≤ 128 chars. */
12
+ const ENTRY_TYPE_RE = /^[A-Za-z0-9][A-Za-z0-9:._-]{0,127}$/;
13
+ /** Max declared entry types per plugin. */
14
+ export const MAX_REPLAY_ENTRY_TYPES = 16;
15
+
16
+ /**
17
+ * Lenient parse of an untrusted manifest value: an array of valid type names,
18
+ * else `[]` (a malformed value contributes nothing and never throws — G6).
19
+ */
20
+ export function normalizeReplayEntryTypes(value: unknown): string[] {
21
+ if (!Array.isArray(value) || value.length > MAX_REPLAY_ENTRY_TYPES) return [];
22
+ if (!value.every((t) => typeof t === "string" && ENTRY_TYPE_RE.test(t))) return [];
23
+ return [...new Set(value as string[])];
24
+ }
25
+
26
+ export interface ReplayEntryTypeSets {
27
+ /** Types replayed as recorded protocol events (enabled plugins only). */
28
+ replay: string[];
29
+ /** Types kept out of the generic custom-entry paths (every declaring plugin). */
30
+ hidden: string[];
31
+ }
32
+
33
+ /** Compute both sets from discovered plugins and their enabled state. */
34
+ export function computeReplayEntryTypes(
35
+ plugins: ReadonlyArray<{ replayEntryTypes?: unknown; enabled: boolean }>,
36
+ ): ReplayEntryTypeSets {
37
+ const replay = new Set<string>();
38
+ const hidden = new Set<string>();
39
+ for (const p of plugins) {
40
+ for (const t of normalizeReplayEntryTypes(p.replayEntryTypes)) {
41
+ hidden.add(t);
42
+ if (p.enabled) replay.add(t);
43
+ }
44
+ }
45
+ return { replay: [...replay], hidden: [...hidden] };
46
+ }
@@ -8,12 +8,13 @@
8
8
  * shared package doesn't depend on the runtime package. The runtime package
9
9
  * will re-export this map with the concrete PluginContext type filled in.
10
10
  */
11
+ import type { BrowserToServerMessage } from "../browser-protocol.js";
11
12
  import type { DashboardSession } from "../types.js";
12
13
  import type { SlotId } from "./slot-types.js";
13
14
 
14
15
  /**
15
16
  * Opaque marker type for PluginContext.
16
- * The concrete type is defined in @blackbelt-technology/dashboard-plugin-runtime/context.
17
+ * The concrete type is defined in @blackbelt-technology/dashboard-plugin-runtime (plugin-context.tsx).
17
18
  * Using `unknown` here keeps this shared types-only package free of runtime deps.
18
19
  */
19
20
  export type AnyPluginContext = unknown;
@@ -31,6 +32,16 @@ export interface FolderDescriptor {
31
32
  */
32
33
  export type SlotPlacement = "sidebar" | "card";
33
34
 
35
+ /**
36
+ * What a `composer-dock-process-group` claim reports in `"summary"` mode: how many
37
+ * items it has running and their plural noun (e.g. `{ count: 2, noun: "subagents" }`).
38
+ * See change: add-composer-dock.
39
+ */
40
+ export interface ProcessGroupSummary {
41
+ count: number;
42
+ noun: string;
43
+ }
44
+
34
45
  /**
35
46
  * Image payload forwarded to `tool-renderer` plugins. Structural mirror of the
36
47
  * client's `ChatImage` (kept inline so this types-only package stays free of a
@@ -52,6 +63,12 @@ export interface ToolRendererContext {
52
63
  editors?: unknown[];
53
64
  sessionId?: string;
54
65
  session?: unknown;
66
+ /**
67
+ * Send a browser→server message (e.g. a subagent resync request). The SAME
68
+ * function reference the built-in renderer receives; absent in tests and
69
+ * embedders without a connection. See change: decouple-plugins-from-core (D5 item 5).
70
+ */
71
+ send?: (message: BrowserToServerMessage) => void;
55
72
  }
56
73
 
57
74
  /**
@@ -154,8 +171,19 @@ export interface FileHandlerProps {
154
171
  isActive: boolean;
155
172
  /** Consistent digest-bracketed read; rejects with `too-large` above the claim's `maxBytes`. */
156
173
  snapshot(): Promise<FileHandlerSnapshot>;
157
- save(bytes: ArrayBuffer, opts: { target: "overwrite" | "copy" }): Promise<FileHandlerSaveResult>;
174
+ /**
175
+ * `sibling` (claims with `siblingExtensions`): create a NEW `<stem><ext>` next to the tab's file — never an
176
+ * overwrite, so no first-overwrite notice; 409 (every name taken) → `conflict-unresolved`.
177
+ * See change: extend-craft-web-to-all-apps (D6).
178
+ */
179
+ save(bytes: ArrayBuffer, opts: { target: "overwrite" | "copy" } | { target: "sibling"; ext: string }): Promise<FileHandlerSaveResult>;
158
180
  setDirty(state: boolean | "unknown"): void;
181
+ /**
182
+ * Open a workspace file (cwd-relative, as a save result returns it) in a new tab; `claimId` selects one of
183
+ * this plugin's file-handler modes on it. Optional: absent on an older runtime.
184
+ * See change: extend-craft-web-to-all-apps (D6 "Create and open").
185
+ */
186
+ openFile?(path: string, claimId?: string): void;
159
187
  context: AnyPluginContext;
160
188
  }
161
189
 
@@ -242,6 +270,14 @@ export interface SlotPropsMap {
242
270
  session: DashboardSession;
243
271
  pluginContext: AnyPluginContext;
244
272
  };
273
+ "composer-dock-process-group": {
274
+ session: DashboardSession;
275
+ pluginContext: AnyPluginContext;
276
+ /** `"summary"`: always mounted, render `null`, only call `reportSummary`. `"rows"`: mounted while the Processes lane body is shown. */
277
+ mode: "summary" | "rows";
278
+ /** Report this claim's running count; `null` means nothing runs (clears the entry). The dock drops the entry when the component unmounts. */
279
+ reportSummary: (summary: ProcessGroupSummary | null) => void;
280
+ };
245
281
  "anchored-popover": {
246
282
  anchorEl: HTMLElement;
247
283
  onDismiss: () => void;
@@ -254,7 +290,13 @@ export interface SlotPropsMap {
254
290
  pluginContext: AnyPluginContext;
255
291
  };
256
292
  "shell-overlay-route": {
257
- params: Record<string, string>;
293
+ /** Route params. `encodedCwd` (the base64url folder segment) is deprecated: use `cwd`. Kept for one minor. */
294
+ params: Record<string, string> & {
295
+ /** @deprecated Use the decoded `cwd` prop. */
296
+ encodedCwd?: string;
297
+ };
298
+ /** Decoded folder path of a `/folder/:encodedCwd/…` route; undefined when the route has no such param or it does not decode. */
299
+ cwd?: string;
258
300
  /** DashboardSession metadata resolved from the URL’s session param (`config.sessionParam`, default `"sid"`). Undefined when the URL has no session id or no matching session. */
259
301
  session?: DashboardSession;
260
302
  onBack: () => void;
@@ -285,6 +327,8 @@ export interface SlotPropsMap {
285
327
  toolDetails?: Record<string, unknown>;
286
328
  images?: ToolRendererImage[];
287
329
  context?: ToolRendererContext;
330
+ /** Epoch ms when the tool row started; lets a running card show a live budget. See change: add-agent-control-renderer (D4). */
331
+ startedAt?: number;
288
332
  };
289
333
  "custom-entry-renderer": CustomEntryRendererProps;
290
334
  "automation-action-editor": {
@@ -17,6 +17,7 @@ export type SlotId =
17
17
  | "session-card-action-bar"
18
18
  | "workspace-action-bar"
19
19
  | "composer-context-group"
20
+ | "composer-dock-process-group"
20
21
  | "composer-panel"
21
22
  | "shell-overlay-route"
22
23
  | "login-provider"
@@ -113,6 +114,12 @@ export const SLOT_DEFINITIONS: Record<SlotId, SlotDefinition> = {
113
114
  description:
114
115
  "Labelled context group inside the chat composer's session-action strip, after the Git group and before the Status group. Contributions render read-only and are NOT disabled while streaming. Pair with the runtime's `ComposerContextGroup` primitive. See change: move-quota-to-context-strip.",
115
116
  },
117
+ "composer-dock-process-group": {
118
+ multiplicity: "many",
119
+ payloadTier: "react-only",
120
+ description:
121
+ "Group of running-work rows inside the composer dock's Processes lane, before the core Commands and Background groups. Receives { session, pluginContext, mode, reportSummary }: in `summary` mode render null and report { count, noun } (or null); in `rows` mode render `ComposerDockRow`s. See change: add-composer-dock.",
122
+ },
116
123
  "composer-panel": {
117
124
  multiplicity: "many",
118
125
  payloadTier: "react-only",
@@ -162,7 +169,7 @@ export const SLOT_DEFINITIONS: Record<SlotId, SlotDefinition> = {
162
169
  multiplicity: "many",
163
170
  payloadTier: "react-only",
164
171
  description:
165
- "Custom React payload editor for a specific automation action id (keyed by config.actionId). Rendered by the create-automation dialog additively below the generic ActionPayloadForm; receives { payload, onChange, cwd }.",
172
+ "Custom React payload editor for a specific automation action id (keyed by config.actionId). Rendered by the inline automation editor additively below the generic ActionPayloadForm; receives { payload, onChange, cwd }.",
166
173
  },
167
174
  "editor-pane-tab": {
168
175
  multiplicity: "many",
@@ -288,6 +295,7 @@ type SessionScopedSlot =
288
295
  | "content-header-sticky"
289
296
  | "content-inline-footer"
290
297
  | "composer-context-group"
298
+ | "composer-dock-process-group"
291
299
  | "command-route"
292
300
  | "shell-overlay-route";
293
301
 
@@ -78,6 +78,13 @@ export const UI_PRIMITIVE_KEYS = {
78
78
  * (`useUiPrimitiveOrNull`) and hide the affordance when absent.
79
79
  * See change: improve-kb-settings-sources-and-search. */
80
80
  pathPicker: "ui:path-picker",
81
+ /** Live chat of one session (transcript + composer), host-styled. Self-providing:
82
+ * mounts the chat/session providers it needs, inside the app's registry.
83
+ * See change: decouple-plugins-from-core (D8). */
84
+ chatView: "ui:chat-view",
85
+ /** Small elapsed-time badge: live ticking from `startedAt`, static for `duration`.
86
+ * See change: decouple-plugins-from-core (D8). */
87
+ elapsedBadge: "ui:elapsed-badge",
81
88
  } as const;
82
89
 
83
90
  /** Union of all valid UI primitive keys (literal-string narrowed). */
@@ -99,6 +106,9 @@ export interface UiAgentCardProps {
99
106
  stats?: ReactNode;
100
107
  onClick?: () => void;
101
108
  selected?: boolean;
109
+ /** Border accent replacing the status accent (`question`: an open flow
110
+ * question). Selection still wins. See change: adopt-flow-parent-mailbox. */
111
+ accent?: "question";
102
112
  children?: ReactNode;
103
113
  }
104
114
 
@@ -400,18 +410,42 @@ export interface UiOAuthFlowViewProps {
400
410
 
401
411
  /**
402
412
  * Public prop signature for the path-picker primitive: a modal that confirms ONE
403
- * existing directory. `onSelect` receives an absolute path that the host has
404
- * verified to be a directory; a file / missing path shows an inline error and
405
- * never reaches `onSelect`. See change: improve-kb-settings-sources-and-search.
413
+ * existing path. `onSelect` receives an absolute path that the host has verified:
414
+ * a verified directory, or in file mode a verified file; anything else shows an
415
+ * inline error and never reaches `onSelect`.
416
+ * See change: improve-kb-settings-sources-and-search, add-provider-env-config.
406
417
  */
407
418
  export interface UiPathPickerDialogProps {
408
419
  open: boolean;
409
420
  initialPath?: string;
410
421
  title?: string;
422
+ /** `"file"` confirms a file instead of a directory. Default `"directory"`. */
423
+ mode?: "directory" | "file";
424
+ /** File mode: extensions offered behind the picker's filter toggle (e.g. `[".json"]`). */
425
+ accept?: string[];
411
426
  onSelect: (absPath: string) => void;
412
427
  onCancel: () => void;
413
428
  }
414
429
 
430
+ /**
431
+ * Public prop signature for the chat-view primitive: the live chat of session
432
+ * `sessionId`. `readOnly` hides the prompt composer; `compact` asks for a dense
433
+ * layout. See change: decouple-plugins-from-core (D8).
434
+ */
435
+ export interface UiChatViewProps {
436
+ sessionId: string;
437
+ readOnly?: boolean;
438
+ compact?: boolean;
439
+ }
440
+
441
+ /** Public prop signature for the elapsed-badge primitive (the host `ElapsedBadge` props). */
442
+ export interface UiElapsedBadgeProps {
443
+ /** Epoch ms when the operation started (live counter). */
444
+ startedAt?: number;
445
+ /** Duration in ms (static display; wins over the live counter). */
446
+ duration?: number;
447
+ }
448
+
415
449
  export interface UiPrimitiveMap {
416
450
  "ui:agent-card": ComponentType<UiAgentCardProps>;
417
451
  "ui:markdown-content": ComponentType<UiMarkdownContentProps>;
@@ -432,6 +466,8 @@ export interface UiPrimitiveMap {
432
466
  "ui:log-block": ComponentType<UiLogBlockProps>;
433
467
  "ui:oauth-flow": ComponentType<UiOAuthFlowViewProps>;
434
468
  "ui:path-picker": ComponentType<UiPathPickerDialogProps>;
469
+ "ui:chat-view": ComponentType<UiChatViewProps>;
470
+ "ui:elapsed-badge": ComponentType<UiElapsedBadgeProps>;
435
471
  }
436
472
 
437
473
  /**
@@ -0,0 +1,309 @@
1
+ /**
2
+ * Device-key proof helpers shared by the server, the browser client, the
3
+ * Electron main process and the mobile shell.
4
+ *
5
+ * Pure: string builders, validators, the companion fragment codec, the short
6
+ * key id and the row-state derivation. No `node:crypto` import — the browser
7
+ * bundles this file. Signing/verifying lives with each runtime (WebCrypto in
8
+ * the browser, `node:crypto` on the server and in Electron).
9
+ *
10
+ * Signed texts are LF-joined with no trailing LF, version-prefixed, and
11
+ * carry the server fingerprint, so a signature for one server or one purpose
12
+ * never verifies as another (design D1).
13
+ *
14
+ * See change: device-key-mutual-check (D1, D3, D5, D9).
15
+ */
16
+ import { INVISIBLE_OR_SEPARATOR } from "./terminal-safe.js";
17
+
18
+ export const DEVCHECK_PREFIX = "pi-devcheck/v2";
19
+ export const DEVBIND_PREFIX = "pi-devbind/v1";
20
+ export const COMPANION_PREFIX = "pi-companion/v1";
21
+
22
+ /** Server nonce lifetime and client re-challenge threshold. */
23
+ export const DEVICE_NONCE_TTL_MS = 60_000;
24
+ export const DEVICE_NONCE_REUSE_MS = 30_000;
25
+ export const COMPANION_TS_WINDOW_S = 300;
26
+ export const COMPANION_FRAGMENT_MAX = 512;
27
+ export const COMPANION_ORIGIN_MAX_BYTES = 255;
28
+ export const MAX_COMPANIONS = 4;
29
+
30
+ export function devcheckMessage(fingerprint: string, deviceNonce: string): string {
31
+ return `${DEVCHECK_PREFIX}\n${fingerprint}\n${deviceNonce}`;
32
+ }
33
+ export function devbindMessage(fingerprint: string, deviceNonce: string): string {
34
+ return `${DEVBIND_PREFIX}\n${fingerprint}\n${deviceNonce}`;
35
+ }
36
+ export function companionMessage(fingerprint: string, origin: string, ts: number): string {
37
+ return `${COMPANION_PREFIX}\n${fingerprint}\n${origin}\n${ts}`;
38
+ }
39
+
40
+ // 32 bytes → 43 chars, last char carries 2 zero pad bits; 64 bytes → 86 chars, 4 zero bits.
41
+ const PUB_RE = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
42
+ const SIG_RE = /^[A-Za-z0-9_-]{85}[AQgw]$/;
43
+
44
+ export function isDevicePub(v: unknown): v is string {
45
+ return typeof v === "string" && PUB_RE.test(v);
46
+ }
47
+ export function isDeviceSig(v: unknown): v is string {
48
+ return typeof v === "string" && SIG_RE.test(v);
49
+ }
50
+ /** Server-issued: 32 random bytes, base64url, 43 chars. */
51
+ export function isDeviceNonce(v: unknown): v is string {
52
+ return typeof v === "string" && PUB_RE.test(v);
53
+ }
54
+
55
+ export interface DeviceProof {
56
+ deviceNonce: string;
57
+ pub: string;
58
+ sig: string;
59
+ }
60
+
61
+ /** `{deviceNonce, pub, sig}` with every field shape-checked, else `null`. */
62
+ export function parseDeviceProof(v: unknown): DeviceProof | null {
63
+ if (!v || typeof v !== "object") return null;
64
+ const o = v as Record<string, unknown>;
65
+ if (!isDeviceNonce(o.deviceNonce) || !isDevicePub(o.pub) || !isDeviceSig(o.sig)) return null;
66
+ return { deviceNonce: o.deviceNonce, pub: o.pub, sig: o.sig };
67
+ }
68
+
69
+ /** Integer seconds, from a number or a decimal-digit string; else `null`. */
70
+ export function parseCompanionTs(v: unknown): number | null {
71
+ if (typeof v === "number") return Number.isSafeInteger(v) ? v : null;
72
+ if (typeof v === "string" && /^-?\d{1,15}$/.test(v)) return Number(v);
73
+ return null;
74
+ }
75
+
76
+ export function isCompanionTsFresh(ts: number, nowMs: number): boolean {
77
+ return Math.abs(nowMs / 1000 - ts) <= COMPANION_TS_WINDOW_S;
78
+ }
79
+
80
+ function utf8Bytes(s: string): number {
81
+ return new TextEncoder().encode(s).length;
82
+ }
83
+
84
+ /**
85
+ * `http(s)://host[:port]` only — no userinfo, path, query or fragment,
86
+ * at most 255 UTF-8 bytes. Parsed as sent; control/format characters are
87
+ * allowed here (the signature covers them) and stripped only for storage.
88
+ */
89
+ export function validCompanionOrigin(v: unknown): v is string {
90
+ if (typeof v !== "string" || utf8Bytes(v) > COMPANION_ORIGIN_MAX_BYTES) return false;
91
+ const m = /^https?:\/\/(\[[0-9A-Fa-f:.]+\]|[^\s/?#@\\:[\]]+)(?::(\d{1,5}))?$/.exec(v);
92
+ if (!m) return false;
93
+ if (m[2] !== undefined) {
94
+ const port = Number(m[2]);
95
+ if (port < 1 || port > 65535) return false;
96
+ }
97
+ return true;
98
+ }
99
+
100
+ /** Stored / displayed form: control and format characters removed. */
101
+ export function storedCompanionOrigin(origin: string): string {
102
+ return origin.replace(INVISIBLE_OR_SEPARATOR, "").replace(/\p{Cc}/gu, "");
103
+ }
104
+
105
+ export interface CompanionClaim {
106
+ pub: string;
107
+ ts: number;
108
+ sig: string;
109
+ origin: string;
110
+ }
111
+
112
+ export function encodeCompanionFragment(c: CompanionClaim): string {
113
+ return `companion=${c.pub}.${c.ts}.${c.sig}&from=${encodeURIComponent(c.origin)}`;
114
+ }
115
+
116
+ /**
117
+ * Structural parse of a `companion=` fragment (leading `#` optional): at most
118
+ * 512 chars, exactly three dot parts of the right shapes, a `from` value.
119
+ * Origin validity is the receiving server's call (`validCompanionOrigin`).
120
+ */
121
+ export function parseCompanionFragment(hash: string): CompanionClaim | null {
122
+ const frag = hash.startsWith("#") ? hash.slice(1) : hash;
123
+ if (frag.length > COMPANION_FRAGMENT_MAX) return null;
124
+ const m = /^companion=([^&]*)&from=([^&]*)$/.exec(frag);
125
+ if (!m) return null;
126
+ const parts = m[1].split(".");
127
+ if (parts.length !== 3) return null;
128
+ const [pub, tsRaw, sig] = parts;
129
+ const ts = parseCompanionTs(tsRaw);
130
+ if (!isDevicePub(pub) || !isDeviceSig(sig) || ts === null) return null;
131
+ let origin: string;
132
+ try {
133
+ origin = decodeURIComponent(m[2]);
134
+ } catch {
135
+ return null;
136
+ }
137
+ if (origin.length === 0) return null;
138
+ return { pub, ts, sig, origin };
139
+ }
140
+
141
+ /** Raw 32-byte Ed25519 key → SPKI DER (fixed 12-byte prefix). */
142
+ const SPKI_ED25519_PREFIX = Uint8Array.from([
143
+ 0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00,
144
+ ]);
145
+ export function rawEd25519PubToSpki(raw: Uint8Array): Uint8Array {
146
+ const out = new Uint8Array(SPKI_ED25519_PREFIX.length + raw.length);
147
+ out.set(SPKI_ED25519_PREFIX, 0);
148
+ out.set(raw, SPKI_ED25519_PREFIX.length);
149
+ return out;
150
+ }
151
+
152
+ const B64URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
153
+ export function bytesToBase64url(bytes: Uint8Array): string {
154
+ let out = "";
155
+ let i = 0;
156
+ for (; i + 2 < bytes.length; i += 3) {
157
+ const n = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
158
+ out += B64URL[(n >> 18) & 63] + B64URL[(n >> 12) & 63] + B64URL[(n >> 6) & 63] + B64URL[n & 63];
159
+ }
160
+ if (i < bytes.length) {
161
+ const n = (bytes[i] << 16) | ((bytes[i + 1] ?? 0) << 8);
162
+ out += B64URL[(n >> 18) & 63] + B64URL[(n >> 12) & 63];
163
+ if (i + 1 < bytes.length) out += B64URL[(n >> 6) & 63];
164
+ }
165
+ return out;
166
+ }
167
+ export function base64urlToBytes(s: string): Uint8Array {
168
+ const out: number[] = [];
169
+ let buf = 0;
170
+ let bits = 0;
171
+ for (const ch of s) {
172
+ const v = B64URL.indexOf(ch);
173
+ if (v < 0) throw new Error("bad base64url");
174
+ buf = (buf << 6) | v;
175
+ bits += 6;
176
+ if (bits >= 8) {
177
+ bits -= 8;
178
+ out.push((buf >> bits) & 0xff);
179
+ }
180
+ }
181
+ return Uint8Array.from(out);
182
+ }
183
+
184
+ /** `dk:` + first 12 base64url chars of SHA-256 over the raw public key. */
185
+ export function shortKeyIdFromDigest(digest: Uint8Array): string {
186
+ return `dk:${bytesToBase64url(digest).slice(0, 12)}`;
187
+ }
188
+ export async function shortKeyId(pub: string): Promise<string> {
189
+ const raw = base64urlToBytes(pub);
190
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", raw as BufferSource);
191
+ return shortKeyIdFromDigest(new Uint8Array(digest));
192
+ }
193
+
194
+ // ── Device-status reply + row state (D9) ─────────────────────────────
195
+
196
+ export type DeviceTier = "observe" | "control" | "operate";
197
+ export type DeviceStatus = "paired" | "expired" | "unknown" | "revoked" | "unverified";
198
+
199
+ /** Wire body of `POST /api/pair/device-status`. */
200
+ export interface DeviceStatusReply {
201
+ status: DeviceStatus;
202
+ tier?: DeviceTier;
203
+ scope?: "full" | "status-only";
204
+ }
205
+
206
+ /** Narrow an untrusted reply body; anything unrecognised is `unverified`. */
207
+ export function parseDeviceStatusReply(v: unknown): DeviceStatusReply {
208
+ if (!v || typeof v !== "object") return { status: "unverified" };
209
+ const o = v as Record<string, unknown>;
210
+ switch (o.status) {
211
+ case "paired": {
212
+ if (o.scope === "status-only") return { status: "paired", scope: "status-only" };
213
+ const tier = o.tier === "observe" || o.tier === "control" || o.tier === "operate" ? o.tier : undefined;
214
+ return tier ? { status: "paired", scope: "full", tier } : { status: "unverified" };
215
+ }
216
+ case "expired":
217
+ case "unknown":
218
+ case "revoked":
219
+ return { status: o.status };
220
+ default:
221
+ return { status: "unverified" };
222
+ }
223
+ }
224
+
225
+ /** What the client learnt from the two-step check. */
226
+ export type DeviceCheckReply =
227
+ | ({ kind: "answer" } & DeviceStatusReply)
228
+ /** The challenge reply carried no `deviceNonce` (older server). */
229
+ | { kind: "no-nonce" }
230
+ /** Timeout, transport error, or no check was run. */
231
+ | { kind: "no-answer" };
232
+
233
+ /** `unknowable`: a browser tab cannot see another origin's credential. */
234
+ export type DeviceRowCredential = "held" | "none" | "unknowable";
235
+
236
+ export type DeviceRowStateId =
237
+ | "paired"
238
+ | "paired-status-only"
239
+ | "access-removed"
240
+ | "access-expired"
241
+ | "not-paired"
242
+ | "key-pending"
243
+ | "status-unknown";
244
+
245
+ export interface DeviceRowState {
246
+ state: DeviceRowStateId;
247
+ tier?: DeviceTier;
248
+ label: string;
249
+ action?: "pair" | "pair-again";
250
+ }
251
+
252
+ export const TIER_LABELS: Record<DeviceTier, string> = {
253
+ observe: "Observe",
254
+ control: "Control",
255
+ operate: "Operate",
256
+ };
257
+
258
+ export const DEVICE_ROW_LABELS: Record<Exclude<DeviceRowStateId, "paired">, string> = {
259
+ "paired-status-only": "Paired · status only",
260
+ "access-removed": "Access removed",
261
+ "access-expired": "Access expired",
262
+ "not-paired": "Not paired",
263
+ "key-pending": "Paired · key pending",
264
+ "status-unknown": "Status unknown",
265
+ };
266
+
267
+ function row(state: Exclude<DeviceRowStateId, "paired">, action?: DeviceRowState["action"]): DeviceRowState {
268
+ return action ? { state, label: DEVICE_ROW_LABELS[state], action } : { state, label: DEVICE_ROW_LABELS[state] };
269
+ }
270
+
271
+ /**
272
+ * Pure `(credential, keyHeld, reply) → row state`. Never returns a discard
273
+ * instruction: only a refused credential at a proven route discards (D9).
274
+ * `credentialAccepted` is the outcome of the verifying authenticated call
275
+ * after an `unknown` answer (undefined while it is in flight).
276
+ */
277
+ export function deviceRowState(input: {
278
+ credential: DeviceRowCredential;
279
+ keyHeld: boolean;
280
+ reply: DeviceCheckReply;
281
+ credentialAccepted?: boolean;
282
+ }): DeviceRowState {
283
+ const { credential, keyHeld, reply, credentialAccepted } = input;
284
+ if (!keyHeld) {
285
+ if (credential === "held") return row("key-pending");
286
+ if (credential === "none") return row("not-paired", "pair");
287
+ return row("status-unknown");
288
+ }
289
+ if (reply.kind !== "answer") return row("status-unknown");
290
+ switch (reply.status) {
291
+ case "paired":
292
+ if (reply.scope === "status-only") return row("paired-status-only");
293
+ if (reply.tier) return { state: "paired", tier: reply.tier, label: `Paired · ${TIER_LABELS[reply.tier]}` };
294
+ return row("status-unknown");
295
+ case "revoked":
296
+ return row("access-removed", "pair-again");
297
+ case "expired":
298
+ return row("access-expired", "pair-again");
299
+ case "unknown":
300
+ if (credential === "none") return row("not-paired", "pair");
301
+ if (credential === "held") {
302
+ if (credentialAccepted === true) return row("key-pending");
303
+ if (credentialAccepted === false) return row("not-paired", "pair");
304
+ }
305
+ return row("status-unknown");
306
+ default:
307
+ return row("status-unknown");
308
+ }
309
+ }