@blackbelt-technology/pi-agent-dashboard 0.10.0 → 0.11.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 (255) hide show
  1. package/AGENTS.md +2 -2
  2. package/README.md +47 -6
  3. package/docs/architecture.md +1369 -63
  4. package/package.json +14 -9
  5. package/packages/extension/package.json +5 -3
  6. package/packages/extension/src/bridge-handlers/dispatch.ts +57 -3
  7. package/packages/extension/src/bridge-handlers/instance.ts +10 -1
  8. package/packages/extension/src/bridge-handlers/lifecycle.ts +65 -26
  9. package/packages/extension/src/bridge-ticket-client.ts +61 -7
  10. package/packages/extension/src/bridge-tls-checks.ts +79 -0
  11. package/packages/extension/src/bridge.ts +41 -28
  12. package/packages/extension/src/canvas-tool.ts +2 -0
  13. package/packages/extension/src/command-handler.ts +80 -6
  14. package/packages/extension/src/connect-target.ts +23 -0
  15. package/packages/extension/src/connection.ts +30 -7
  16. package/packages/extension/src/dashboard-http-origin.ts +88 -0
  17. package/packages/extension/src/dev-build.ts +11 -1
  18. package/packages/extension/src/git-link-builder.ts +11 -2
  19. package/packages/extension/src/inbound-limits.ts +138 -0
  20. package/packages/extension/src/local-token-header.ts +77 -6
  21. package/packages/extension/src/model-refresh.ts +69 -0
  22. package/packages/extension/src/pinned-endpoint.ts +44 -0
  23. package/packages/extension/src/project-trust-live.ts +143 -0
  24. package/packages/extension/src/project-trust.ts +159 -20
  25. package/packages/extension/src/provider-register.ts +59 -18
  26. package/packages/extension/src/remote-registration-gate.ts +21 -21
  27. package/packages/extension/src/remote-upgrade-preparer.ts +104 -0
  28. package/packages/extension/src/role-model-tools.ts +47 -6
  29. package/packages/extension/src/server-auto-start.ts +1 -1
  30. package/packages/extension/src/server-proof-probe.ts +117 -0
  31. package/packages/extension/src/session-sync.ts +42 -12
  32. package/packages/extension/src/vault-delivery.ts +11 -1
  33. package/packages/server/package.json +8 -8
  34. package/packages/server/src/access/access-grants.ts +61 -8
  35. package/packages/server/src/access/access-health.ts +10 -0
  36. package/packages/server/src/access/access-plane.ts +5 -1
  37. package/packages/server/src/access/containment-gate.ts +55 -17
  38. package/packages/server/src/access/cwd-verdict.ts +3 -3
  39. package/packages/server/src/access/pi-trust-live.ts +244 -0
  40. package/packages/server/src/access/pi-trust-mirror-service.ts +44 -11
  41. package/packages/server/src/access/planes.ts +106 -1
  42. package/packages/server/src/access/preview-egress-store.ts +153 -0
  43. package/packages/server/src/access/prompt-channel.ts +5 -0
  44. package/packages/server/src/access/provisioning-wiring.ts +113 -0
  45. package/packages/server/src/access/provisioning.ts +763 -0
  46. package/packages/server/src/access/yolo-session.ts +54 -2
  47. package/packages/server/src/acp-bridge/acp-session-adapter.ts +8 -3
  48. package/packages/server/src/agent-events/agent-event-hub.ts +158 -0
  49. package/packages/server/src/auth/audit-log.ts +80 -0
  50. package/packages/server/src/auth/auth-plugin.ts +44 -25
  51. package/packages/server/src/auth/auth.ts +24 -4
  52. package/packages/server/src/auth/bearer-auth.ts +52 -12
  53. package/packages/server/src/auth/cors-origin.ts +76 -29
  54. package/packages/server/src/auth/csp-report-paths.ts +31 -0
  55. package/packages/server/src/auth/csp-report-sink.ts +302 -0
  56. package/packages/server/src/auth/csp-report-store.ts +406 -0
  57. package/packages/server/src/auth/csp.ts +105 -9
  58. package/packages/server/src/auth/dashboard-credential-store.ts +4 -0
  59. package/packages/server/src/auth/dashboard-state-caller.ts +29 -0
  60. package/packages/server/src/auth/local-proof-refusal-log.ts +89 -0
  61. package/packages/server/src/auth/local-proof.ts +69 -18
  62. package/packages/server/src/auth/localhost-guard.ts +48 -10
  63. package/packages/server/src/auth/nav-intent.ts +72 -0
  64. package/packages/server/src/auth/passkey/passkey-assets.ts +99 -0
  65. package/packages/server/src/auth/passkey/passkey-pages.ts +17 -81
  66. package/packages/server/src/auth/passkey/passkey-routes.ts +8 -0
  67. package/packages/server/src/auth/pi-legacy-credentials.ts +3 -0
  68. package/packages/server/src/auth/plugin-server-trust.ts +29 -0
  69. package/packages/server/src/auth/plugin-trust-store.ts +103 -0
  70. package/packages/server/src/auth/proven-tls.ts +45 -0
  71. package/packages/server/src/auth/provider-auth-storage.ts +6 -1
  72. package/packages/server/src/auth/radius-mcp.ts +1 -1
  73. package/packages/server/src/auth/request-principal.ts +32 -0
  74. package/packages/server/src/auth/secret-rotation.ts +246 -0
  75. package/packages/server/src/auth/secure-origin.ts +56 -0
  76. package/packages/server/src/auth/serve-app-host.ts +111 -11
  77. package/packages/server/src/auth/ws-ticket.ts +39 -1
  78. package/packages/server/src/auth/ws-upgrade-reject-log.ts +4 -1
  79. package/packages/server/src/browser-handlers/directory-handler.ts +23 -0
  80. package/packages/server/src/browser-handlers/folder-gate.ts +55 -0
  81. package/packages/server/src/browser-handlers/handler-context.ts +25 -2
  82. package/packages/server/src/browser-handlers/session-action-handler.ts +9 -1
  83. package/packages/server/src/browser-handlers/subscription-handler.ts +100 -2
  84. package/packages/server/src/browser-handlers/terminal-handler.ts +108 -10
  85. package/packages/server/src/canvas/canvas-accumulator.ts +35 -7
  86. package/packages/server/src/cli.ts +210 -39
  87. package/packages/server/src/config-api.ts +23 -1
  88. package/packages/server/src/config-snapshot.ts +48 -1
  89. package/packages/server/src/directory-service.ts +160 -54
  90. package/packages/server/src/event-wiring.ts +143 -108
  91. package/packages/server/src/git-worktree/git-operations.ts +44 -10
  92. package/packages/server/src/git-worktree/redact-git-text.ts +124 -0
  93. package/packages/server/src/git-worktree/ref-arg.ts +39 -0
  94. package/packages/server/src/git-worktree/worktree-init-trust.ts +43 -1
  95. package/packages/server/src/identity/http-road-classification.ts +13 -1
  96. package/packages/server/src/identity/ws-message-scope.ts +1 -0
  97. package/packages/server/src/identity/ws-road-classification.ts +1 -0
  98. package/packages/server/src/known-server-moves.ts +36 -15
  99. package/packages/server/src/lib/browse-roots.ts +118 -17
  100. package/packages/server/src/lib/client-dist.ts +36 -21
  101. package/packages/server/src/lib/dashboard-state-guard.ts +230 -0
  102. package/packages/server/src/lib/diagram-render.ts +4 -6
  103. package/packages/server/src/lib/eml.ts +3 -8
  104. package/packages/server/src/lib/file-cwd-admission.ts +145 -0
  105. package/packages/server/src/lib/grep-worker.ts +23 -0
  106. package/packages/server/src/lib/grep.ts +93 -7
  107. package/packages/server/src/lib/index-html.ts +81 -0
  108. package/packages/server/src/lib/office-preview.ts +2 -3
  109. package/packages/server/src/lib/path-containment.ts +7 -0
  110. package/packages/server/src/lib/resolve-file-mention.ts +11 -9
  111. package/packages/server/src/lib/route-admission.ts +80 -0
  112. package/packages/server/src/lib/writable-md-target.ts +4 -0
  113. package/packages/server/src/lifecycle/recovery-server.ts +65 -18
  114. package/packages/server/src/live-server/capability-redact.ts +15 -0
  115. package/packages/server/src/live-server/live-browser-gate.ts +22 -0
  116. package/packages/server/src/live-server/live-capability.ts +224 -17
  117. package/packages/server/src/live-server/live-csp-report.ts +63 -0
  118. package/packages/server/src/live-server/live-csp.ts +93 -0
  119. package/packages/server/src/live-server/live-egress.ts +435 -0
  120. package/packages/server/src/live-server/live-exposure.ts +149 -0
  121. package/packages/server/src/live-server/live-log.ts +21 -0
  122. package/packages/server/src/live-server/live-origin-scan.ts +298 -0
  123. package/packages/server/src/live-server/live-server-manager.ts +209 -33
  124. package/packages/server/src/live-server/live-server-proxy.ts +162 -17
  125. package/packages/server/src/live-server/live-static.ts +228 -0
  126. package/packages/server/src/openspec/dependencies-file.ts +122 -0
  127. package/packages/server/src/openspec/openspec-change-watcher.ts +3 -1
  128. package/packages/server/src/openspec/openspec-dependency-inputs.ts +281 -0
  129. package/packages/server/src/openspec/openspec-poll-fs-helpers.ts +72 -26
  130. package/packages/server/src/openspec/openspec-poll-worker-pool.ts +48 -12
  131. package/packages/server/src/openspec/openspec-poll-worker.ts +95 -9
  132. package/packages/server/src/openspec/workflow-schema-status.ts +379 -0
  133. package/packages/server/src/openspec/workflow-schema.ts +141 -267
  134. package/packages/server/src/package/npm-search-proxy.ts +5 -2
  135. package/packages/server/src/package/provider-probe.ts +8 -2
  136. package/packages/server/src/pairing/browser-gateway.ts +188 -12
  137. package/packages/server/src/pairing/device-token-services.ts +26 -0
  138. package/packages/server/src/pairing/paired-devices.ts +335 -22
  139. package/packages/server/src/pairing/pairing.ts +34 -4
  140. package/packages/server/src/pairing/socket-locality.ts +26 -0
  141. package/packages/server/src/persistence/preferences-store.ts +9 -0
  142. package/packages/server/src/pi/bridge-channel.ts +33 -0
  143. package/packages/server/src/pi/bridge-upgrade-auth.ts +18 -3
  144. package/packages/server/src/pi/gateway-listeners.ts +9 -3
  145. package/packages/server/src/pi/host-project-trust.ts +14 -6
  146. package/packages/server/src/pi/pi-gateway.ts +191 -21
  147. package/packages/server/src/pi/resource-toggle-trust.ts +1 -1
  148. package/packages/server/src/plugin-discovery-wiring.ts +142 -0
  149. package/packages/server/src/plugin-event-seam.ts +116 -4
  150. package/packages/server/src/plugin-runtime-clients.ts +89 -0
  151. package/packages/server/src/routes/access-routes.ts +159 -9
  152. package/packages/server/src/routes/agent-event-stream-routes.ts +137 -0
  153. package/packages/server/src/routes/canvas-types-routes.ts +20 -6
  154. package/packages/server/src/routes/csp-violations-routes.ts +162 -0
  155. package/packages/server/src/routes/file-routes.ts +329 -209
  156. package/packages/server/src/routes/file-write-binary-routes.ts +77 -20
  157. package/packages/server/src/routes/folder-project-routes.ts +18 -12
  158. package/packages/server/src/routes/git-routes.ts +319 -203
  159. package/packages/server/src/routes/grep-routes.ts +38 -14
  160. package/packages/server/src/routes/known-servers-routes.ts +189 -91
  161. package/packages/server/src/routes/live-server-routes.ts +378 -15
  162. package/packages/server/src/routes/local-proof-routes.ts +14 -0
  163. package/packages/server/src/routes/nav-intent-routes.ts +46 -0
  164. package/packages/server/src/routes/openspec-group-routes.ts +53 -44
  165. package/packages/server/src/routes/openspec-routes.ts +379 -28
  166. package/packages/server/src/routes/package-routes.ts +58 -10
  167. package/packages/server/src/routes/pairing-routes.ts +146 -10
  168. package/packages/server/src/routes/pi-trust-query-routes.ts +330 -0
  169. package/packages/server/src/routes/plugin-activation-routes.ts +59 -0
  170. package/packages/server/src/routes/plugin-runtime-client-routes.ts +149 -0
  171. package/packages/server/src/routes/provider-auth-routes.ts +15 -2
  172. package/packages/server/src/routes/resource-activation-routes.ts +18 -4
  173. package/packages/server/src/routes/session-routes.ts +51 -4
  174. package/packages/server/src/routes/system-routes.ts +84 -15
  175. package/packages/server/src/routes/ui-link-base.ts +88 -0
  176. package/packages/server/src/runtime-overlay/runtime-io.ts +2 -9
  177. package/packages/server/src/server.ts +648 -137
  178. package/packages/server/src/session/hydration-state.ts +148 -0
  179. package/packages/server/src/session/memory-session-manager.ts +7 -0
  180. package/packages/server/src/session/replay-exit-controller.ts +221 -0
  181. package/packages/server/src/session/retained-transcript.ts +9 -2
  182. package/packages/server/src/session/session-load-worker.ts +11 -2
  183. package/packages/server/src/spawn-process/headless-pid-registry.ts +14 -9
  184. package/packages/server/src/terminal/terminal-manager.ts +54 -46
  185. package/packages/server/src/tls/tls-bridge-route.ts +61 -0
  186. package/packages/server/src/tls/tls-config-validation.ts +2 -0
  187. package/packages/server/src/vault/device-expiry-sweep.ts +36 -0
  188. package/packages/server/src/vault/vault-delivery-hub.ts +155 -25
  189. package/packages/server/src/watch-files-handler.ts +66 -0
  190. package/packages/shared/package.json +1 -1
  191. package/packages/shared/src/browser-protocol.ts +148 -2
  192. package/packages/shared/src/canvas-declare.ts +27 -0
  193. package/packages/shared/src/config.ts +372 -53
  194. package/packages/shared/src/containment-guard.ts +35 -0
  195. package/packages/shared/src/dashboard-plugin/anthropic-peer-names.ts +9 -0
  196. package/packages/shared/src/dashboard-plugin/event-type-owners.ts +50 -0
  197. package/packages/shared/src/dashboard-plugin/file-handler.ts +2 -0
  198. package/packages/shared/src/dashboard-plugin/host-api.ts +61 -0
  199. package/packages/shared/src/dashboard-plugin/host-fx-classes.ts +23 -0
  200. package/packages/shared/src/dashboard-plugin/host-import-map.ts +38 -0
  201. package/packages/shared/src/dashboard-plugin/index.ts +2 -0
  202. package/packages/shared/src/dashboard-plugin/manifest-types.ts +54 -1
  203. package/packages/shared/src/dashboard-plugin/plugin-status.ts +54 -0
  204. package/packages/shared/src/dashboard-plugin/slot-props.ts +45 -3
  205. package/packages/shared/src/dashboard-plugin/slot-types.ts +8 -0
  206. package/packages/shared/src/dashboard-plugin/subagent-types.ts +219 -0
  207. package/packages/shared/src/dashboard-plugin/ui-primitives.ts +28 -0
  208. package/packages/shared/src/display-prefs.ts +13 -0
  209. package/packages/shared/src/doctor-core.ts +94 -27
  210. package/packages/shared/src/live-server.ts +141 -0
  211. package/packages/shared/src/local-proof-signal.ts +16 -0
  212. package/packages/shared/src/loopback-host.ts +26 -0
  213. package/packages/shared/src/mcp/verb-tiers.generated.ts +178 -0
  214. package/packages/shared/src/mdns-discovery.ts +25 -6
  215. package/packages/shared/src/nav-intent.ts +29 -0
  216. package/packages/shared/src/openspec-dependencies.ts +760 -0
  217. package/packages/shared/src/openspec-poller.ts +3 -2
  218. package/packages/shared/src/pairing-knock-client.ts +44 -4
  219. package/packages/shared/src/pi-trust-live-query.ts +93 -0
  220. package/packages/shared/src/pi-trust-mirror-snapshot.ts +5 -7
  221. package/packages/shared/src/pi-trust-mirror-types.ts +36 -3
  222. package/packages/shared/src/pi-trust-mirror.ts +29 -3
  223. package/packages/shared/src/pi-trust-resource-digest.ts +255 -0
  224. package/packages/shared/src/platform/ensure-bundled-git.ts +57 -34
  225. package/packages/shared/src/platform/git-source.ts +88 -26
  226. package/packages/shared/src/platform/git.ts +14 -8
  227. package/packages/shared/src/platform/process.ts +48 -4
  228. package/packages/shared/src/platform/resolve-pi-shell.ts +76 -0
  229. package/packages/shared/src/platform/select-git-source.ts +7 -0
  230. package/packages/shared/src/plugin-route-cwd.ts +95 -0
  231. package/packages/shared/src/preview-egress.ts +138 -0
  232. package/packages/shared/src/project-root.ts +16 -0
  233. package/packages/shared/src/protocol.ts +40 -1
  234. package/packages/shared/src/recommended-extensions.ts +18 -0
  235. package/packages/shared/src/recovery-timing.ts +27 -0
  236. package/packages/shared/src/remote-credentials.ts +63 -0
  237. package/packages/shared/src/rest-api.ts +55 -8
  238. package/packages/shared/src/route-tiers.ts +55 -1
  239. package/packages/shared/src/runtime-overlay/archive-safety.d.mts +2 -0
  240. package/packages/shared/src/runtime-overlay/archive-safety.mjs +33 -0
  241. package/packages/shared/src/runtime-overlay/manifest.d.mts +7 -0
  242. package/packages/shared/src/runtime-overlay/manifest.mjs +22 -2
  243. package/packages/shared/src/safe-local-path.ts +24 -0
  244. package/packages/shared/src/sanitize-profiles.ts +98 -0
  245. package/packages/shared/src/server-launcher.ts +9 -1
  246. package/packages/shared/src/server-pinning.ts +55 -2
  247. package/packages/shared/src/server-routes.ts +462 -0
  248. package/packages/shared/src/session-ui-path.ts +11 -0
  249. package/packages/shared/src/tls-only-token.ts +16 -0
  250. package/packages/shared/src/tool-registry/definitions.ts +5 -5
  251. package/packages/shared/src/tool-registry/strategies.ts +12 -11
  252. package/packages/shared/src/types.ts +66 -0
  253. package/packages/shared/src/url-policy.ts +96 -0
  254. package/packages/shared/src/vault-delivery.ts +15 -0
  255. package/packages/shared/src/ws-message-tiers.ts +1 -0
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Path-bound containment guard for static analysis.
3
+ *
4
+ * `evaluateContainment` (packages/server/src/access/containment-gate.ts) is async and
5
+ * returns a decision CodeQL cannot see through. File routes therefore branch on this
6
+ * sync predicate right after the `await`; it is modelled as a `js/path-injection`
7
+ * barrier guard in `.github/codeql/extensions/cwd-guard.model.yml`.
8
+ *
9
+ * The decision carries the exact string it decided (`resolved`) and the predicate
10
+ * compares it by strict equality, so a decision for path A can never bless path B.
11
+ * `PathDecision` is branded (type-only): only `containment-gate.ts` casts to it.
12
+ *
13
+ * See change: codeql-file-containment-barrier.
14
+ */
15
+
16
+ /** Type-only brand: no runtime value exists, so no module can forge a `PathDecision` without a cast. */
17
+ export declare const pathDecisionBrand: unique symbol;
18
+
19
+ /** A containment verdict bound to the path it was made for. Built only by `containment-gate.ts`. */
20
+ export interface PathDecision {
21
+ readonly allowed: boolean;
22
+ /** True when the grant layer (not layers ①/②) admitted the path. */
23
+ readonly viaGrant: boolean;
24
+ /** The exact string passed to the decision function. */
25
+ readonly resolved: string;
26
+ readonly [pathDecisionBrand]: true;
27
+ }
28
+
29
+ /**
30
+ * True only when `decision` allowed AND was made for exactly `resolved`. Sync, so
31
+ * static analysis treats a branch on it as a guard for `resolved`.
32
+ */
33
+ export function containmentAllows(decision: PathDecision, resolved: string): boolean {
34
+ return decision.allowed === true && decision.resolved === resolved;
35
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Peer-probe key for the `pi-anthropic-messages` peer. Lives in shared so core
3
+ * (client) and the flows-anthropic-bridge plugin read one constant without a
4
+ * core→plugin import. The plugin re-exports it.
5
+ * See change: decouple-plugins-from-core (task 2.1).
6
+ */
7
+
8
+ /** Legacy pre-rescope module name — also the only key the bridge's `probeAll` emits. */
9
+ export const PEER_AM_LEGACY = "@pi/anthropic-messages";
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Plugin event-type ownership — pure pattern matching.
3
+ *
4
+ * A plugin manifest declares `eventTypes`: exact names or `prefix_*` (a single
5
+ * trailing `*`). The shell reads ownership from every registered plugin's
6
+ * manifest (enabled or not) and never hard-codes a plugin prefix.
7
+ * See change: decouple-plugins-from-core (design D5 item 2).
8
+ */
9
+
10
+ /** One plugin's declared event types, as read from its manifest summary. */
11
+ export interface EventTypeOwner {
12
+ ownerId: string;
13
+ displayName: string;
14
+ eventTypes: readonly string[];
15
+ }
16
+
17
+ const PATTERN = /^[A-Za-z0-9_.:-]+\*?$/;
18
+
19
+ /** An exact event name, or a name followed by a single trailing `*`. */
20
+ export function isValidEventTypePattern(pattern: string): boolean {
21
+ return PATTERN.test(pattern);
22
+ }
23
+
24
+ /** Trailing `*` = prefix glob; otherwise exact equality. */
25
+ export function matchesEventTypePattern(pattern: string, eventType: string): boolean {
26
+ return pattern.endsWith("*") ? eventType.startsWith(pattern.slice(0, -1)) : pattern === eventType;
27
+ }
28
+
29
+ /**
30
+ * Owner of `eventType`, or undefined. An exact declaration beats a prefix glob;
31
+ * among globs the longest prefix wins; ties keep the earlier owner.
32
+ */
33
+ export function matchEventTypeOwner(
34
+ owners: readonly EventTypeOwner[],
35
+ eventType: string,
36
+ ): EventTypeOwner | undefined {
37
+ let best: EventTypeOwner | undefined;
38
+ let bestScore = -1;
39
+ for (const owner of owners) {
40
+ for (const pattern of owner.eventTypes) {
41
+ if (!matchesEventTypePattern(pattern, eventType)) continue;
42
+ const score = pattern.endsWith("*") ? pattern.length - 1 : Number.MAX_SAFE_INTEGER;
43
+ if (score > bestScore) {
44
+ best = owner;
45
+ bestScore = score;
46
+ }
47
+ }
48
+ }
49
+ return best;
50
+ }
@@ -49,6 +49,8 @@ export interface FileHandlerClaimMeta {
49
49
  maxBytes?: number;
50
50
  firstOverwriteNotice?: string;
51
51
  copySuffix?: string;
52
+ /** Edit mode: native sibling extensions (`write-binary?mode=copy&siblingExt=`). See change: extend-craft-web-to-all-apps (D6). */
53
+ siblingExtensions?: string[];
52
54
  validator?: boolean;
53
55
  }
54
56
 
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Plugin host API version contract (design D7).
3
+ *
4
+ * `PLUGIN_HOST_API_VERSION` is the semver of the public runtime surface
5
+ * (`dashboard-plugin-runtime/src/public.ts` + `./sdk`), NOT the package release
6
+ * version. A plugin manifest declares the range it was built against in
7
+ * `hostApi`; discovery evaluates it. Written in-house: caret + exact only, no
8
+ * semver dependency (shared stays dependency-free).
9
+ *
10
+ * See change: decouple-plugins-from-core.
11
+ */
12
+
13
+ /** Current host API version. Bump per the snapshot rules in `scripts/host-api-surface.mjs`. */
14
+ export const PLUGIN_HOST_API_VERSION = "1.3.0";
15
+
16
+ /** A manifest `hostApi` range: `^MAJOR.MINOR[.PATCH]` or an exact `MAJOR.MINOR.PATCH`. */
17
+ export type HostApiRange = string;
18
+
19
+ const NUM = "(0|[1-9]\\d*)";
20
+ const VERSION_RE = new RegExp(`^${NUM}\\.${NUM}\\.${NUM}$`);
21
+ const CARET_RE = new RegExp(`^\\^${NUM}\\.${NUM}(?:\\.${NUM})?$`);
22
+
23
+ type Triple = readonly [number, number, number];
24
+
25
+ function parseVersion(version: string): Triple | null {
26
+ const m = VERSION_RE.exec(version);
27
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
28
+ }
29
+
30
+ /** True when `range` is syntactically valid (caret `^MAJOR.MINOR[.PATCH]` or exact `MAJOR.MINOR.PATCH`). */
31
+ export function isValidHostApiRange(range: unknown): range is HostApiRange {
32
+ return typeof range === "string" && (CARET_RE.test(range) || VERSION_RE.test(range));
33
+ }
34
+
35
+ function compare(a: Triple, b: Triple): number {
36
+ return a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
37
+ }
38
+
39
+ /**
40
+ * Does `version` (`MAJOR.MINOR.PATCH`) satisfy `range`? Caret follows semver:
41
+ * `^1.2` = `>=1.2.0 <2.0.0`, `^0.9.0` = `>=0.9.0 <0.10.0`, `^0.0.3` = exactly `0.0.3`.
42
+ * An exact range matches only that version. Invalid input never satisfies.
43
+ */
44
+ export function satisfiesHostApiRange(version: string, range: string): boolean {
45
+ const v = parseVersion(version);
46
+ if (!v) return false;
47
+ const exact = parseVersion(range);
48
+ if (exact) return compare(v, exact) === 0;
49
+ const m = CARET_RE.exec(range);
50
+ if (!m) return false;
51
+ const low: Triple = [Number(m[1]), Number(m[2]), m[3] === undefined ? 0 : Number(m[3])];
52
+ if (compare(v, low) < 0) return false;
53
+ if (low[0] > 0) return v[0] === low[0];
54
+ if (low[1] > 0 || m[3] === undefined) return v[0] === 0 && v[1] === low[1];
55
+ return v[0] === 0 && v[1] === 0 && v[2] === low[2];
56
+ }
57
+
58
+ /** `satisfiesHostApiRange` bound to {@link PLUGIN_HOST_API_VERSION} — the HOST's version, never a bundled copy's. */
59
+ export function satisfiesHostApi(range: string): boolean {
60
+ return satisfiesHostApiRange(PLUGIN_HOST_API_VERSION, range);
61
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Host-owned global CSS FX class names a plugin may apply by name (session-card
3
+ * stripes / glow / ring). The rules live in `packages/client/src/index.css`, gated
4
+ * by `prefers-reduced-motion` and the `data-fx-*` user toggles. Plugin code uses
5
+ * these constants instead of literal class strings so a rename is one edit and the
6
+ * host API surface snapshot (`host-api-surface.json`) records every value.
7
+ *
8
+ * See change: decouple-plugins-from-core (design D6/D7).
9
+ */
10
+ export const HOST_FX_CLASSES = {
11
+ /** Diagonal-stripes overlay base. */
12
+ stripes: "card-stripes-fx",
13
+ /** Animated modifier of `stripes` for a running card. */
14
+ stripesRunning: "card-stripes-running",
15
+ /** Static neon glow overlay of a selected card. */
16
+ glow: "card-glow-fx",
17
+ /** Wider outer glow layer, paired with `glow`. */
18
+ glowOuter: "card-glow-fx-outer",
19
+ /** Rim ring of a selected card. */
20
+ ring: "card-ring-fx",
21
+ } as const;
22
+
23
+ export type HostFxClass = (typeof HOST_FX_CLASSES)[keyof typeof HOST_FX_CLASSES];
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The host import map (design D9/D21): bare specifier → URL of the host-built shim entry
3
+ * (`dist/host/<name>.js`, built by the client's rollup `input`, task 6.3).
4
+ *
5
+ * ONE list shared by the server (`sendIndexWithImportMap`) and the host-API surface snapshot
6
+ * (`scripts/host-api-surface.mjs` `IMPORT_MAP_SPECIFIERS`, kept in lock-step by a server test).
7
+ * Phase 6 appended `embedded-app`, `app-kit/react` and `wouter` (task 7.1).
8
+ *
9
+ * See change: decouple-plugins-from-core (tasks 6.3, 6.4).
10
+ */
11
+
12
+ /** `@blackbelt-technology/dashboard-plugin-runtime`, built by concatenation (pnpm contract test scans literals for undeclared workspace imports). */
13
+ export const HOST_RUNTIME_SPECIFIER = `${"@blackbelt-technology"}/dashboard-plugin-runtime`;
14
+
15
+ /** `@blackbelt-technology/dashboard-plugin-runtime/embedded-app` (concatenated for the same reason). */
16
+ export const HOST_EMBEDDED_APP_SPECIFIER = `${HOST_RUNTIME_SPECIFIER}/embedded-app`;
17
+
18
+ /** `@blackbelt-technology/pi-dashboard-app-kit/react` (concatenated: shared does not depend on app-kit). */
19
+ export const HOST_APP_KIT_REACT_SPECIFIER = `${"@blackbelt-technology"}/pi-dashboard-app-kit/react`;
20
+
21
+ /** Specifier → shim URL, in map order. */
22
+ export const HOST_IMPORT_MAP_IMPORTS: Readonly<Record<string, string>> = Object.freeze({
23
+ react: "/host/react.js",
24
+ "react/jsx-runtime": "/host/react-jsx-runtime.js",
25
+ "react-dom": "/host/react-dom.js",
26
+ "react-dom/client": "/host/react-dom-client.js",
27
+ [HOST_RUNTIME_SPECIFIER]: "/host/runtime.js",
28
+ [HOST_EMBEDDED_APP_SPECIFIER]: "/host/embedded-app.js",
29
+ [HOST_APP_KIT_REACT_SPECIFIER]: "/host/app-kit-react.js",
30
+ wouter: "/host/wouter.js",
31
+ });
32
+
33
+ export const HOST_IMPORT_MAP_SPECIFIERS: readonly string[] = Object.freeze(Object.keys(HOST_IMPORT_MAP_IMPORTS));
34
+
35
+ /** The static `<script type="importmap">` body. Deterministic: identical bytes on every call. */
36
+ export function hostImportMapJson(): string {
37
+ return JSON.stringify({ imports: HOST_IMPORT_MAP_IMPORTS });
38
+ }
@@ -7,6 +7,8 @@
7
7
  */
8
8
 
9
9
  export * from "./file-handler.js";
10
+ export * from "./host-api.js";
11
+ export * from "./host-fx-classes.js";
10
12
  export * from "./intent-types.js";
11
13
  export * from "./manifest-types.js";
12
14
  export * from "./plugin-status.js";
@@ -78,6 +78,13 @@ export interface PluginClaim {
78
78
  firstOverwriteNotice?: string;
79
79
  /** For `editor-pane-file-handler` edit mode: `<stem>.<copySuffix>.<ext>` suffix, `^[a-z][a-z0-9-]{1,31}$` (required for edit). */
80
80
  copySuffix?: string;
81
+ /**
82
+ * For `editor-pane-file-handler` edit mode: native-format extensions a save may create as a NEW sibling
83
+ * `<stem><ext>` next to the tab's file (never-overwrite). Same per-extension rules as `extensions`, disjoint
84
+ * from them; edit claims only. An older runtime drops the key (saves then go to the device).
85
+ * See change: extend-craft-web-to-all-apps (D6).
86
+ */
87
+ siblingExtensions?: string[];
81
88
  /**
82
89
  * For `editor-pane-file-handler`: `true` = saves require the plugin's
83
90
  * `ctx.registerFileValidator` validator; fail closed (503) while it is not loaded.
@@ -204,6 +211,21 @@ export interface PluginClaim {
204
211
  * See change: auto-hide-empty-session-subcards.
205
212
  */
206
213
  shouldRender?: string;
214
+ /**
215
+ * `tool-renderer` claims only: when true the tool row starts EXPANDED while
216
+ * its status is `running` (the card is the live progress surface). Replaces
217
+ * the shell's hard-coded per-tool auto-expand. Absent = false.
218
+ * See change: decouple-plugins-from-core (design D5 item 7).
219
+ */
220
+ expandWhileRunning?: boolean;
221
+ /**
222
+ * `tool-renderer` claims only: exported sync predicate name
223
+ * `(toolDetails, session) => boolean` that says the row's result never reached
224
+ * this browser; the shell then shows its neutral "recovered" badge. `session`
225
+ * is `ToolContext.session`. MUST be synchronous.
226
+ * See change: decouple-plugins-from-core (design D5 item 7).
227
+ */
228
+ resultPending?: string;
207
229
  }
208
230
 
209
231
  /**
@@ -283,8 +305,16 @@ export interface PluginManifest {
283
305
  * Default 1000. First-party plugins use 100.
284
306
  */
285
307
  priority?: number;
286
- /** Relative path to the bundled client entry (from package root). */
308
+ /** Relative path to the bundled client entry (from package root). The build-time source entry. */
287
309
  client?: string;
310
+ /**
311
+ * Package-relative path to a PREBUILT ES entry module for runtime delivery. Its directory is the
312
+ * served asset root and must be a dedicated client output dir (not the package root, no server/bridge
313
+ * entry inside). See change: decouple-plugins-from-core (design D10).
314
+ */
315
+ clientBundle?: string;
316
+ /** Package-relative path to a prebuilt CSS file; must lie inside the `clientBundle` directory. */
317
+ clientStyles?: string;
288
318
  /** Optional relative path to the server entry. */
289
319
  server?: string;
290
320
  /** Optional relative path to a pi-extension/bridge entry. */
@@ -347,6 +377,29 @@ export interface PluginManifest {
347
377
  * while this plugin is loaded and enabled. See change: add-project-scoped-apps.
348
378
  */
349
379
  projectTypes?: ProjectTypeRule[];
380
+ /**
381
+ * Event types this plugin owns: exact names or `prefix_*` (one trailing `*`).
382
+ * The shell groups an owned event that no reducer slice consumed into one row
383
+ * per type and names this plugin when it is unavailable. Ownership is known
384
+ * for every registered plugin, enabled or not.
385
+ * See change: decouple-plugins-from-core (design D5).
386
+ */
387
+ eventTypes?: string[];
388
+ /**
389
+ * Event types this plugin may emit into sessions via `ctx.emitEventToSession`
390
+ * (exact names, no reserved host prefix). Absent / empty = emits nothing.
391
+ * Distinct from the inbound `eventTypes`. Enforced at the server seam.
392
+ * See change: harden-git-terminal-plugin-boundaries (D16).
393
+ */
394
+ emits?: string[];
395
+ /**
396
+ * Host API range this plugin was built against: `^MAJOR.MINOR[.PATCH]` or an
397
+ * exact `MAJOR.MINOR.PATCH`. Evaluated at discovery against
398
+ * `PLUGIN_HOST_API_VERSION`; one range covers the server and client halves.
399
+ * Required for `pi-package`-source plugins and `clientBundle` plugins.
400
+ * See change: decouple-plugins-from-core (design D7).
401
+ */
402
+ hostApi?: string;
350
403
  }
351
404
 
352
405
  /**
@@ -45,6 +45,48 @@ export interface BridgeProbeSnapshot {
45
45
  at: number;
46
46
  }
47
47
 
48
+ /**
49
+ * Which discovery source a plugin came from. `pi-package` = a `settings.json#packages[]`
50
+ * (user scope) package carrying a manifest (lowest priority, server entry default-deny);
51
+ * `local-detected` = a project-scope (`<cwd>/.pi/settings.json`) package that is reported
52
+ * but never loaded. See change: decouple-plugins-from-core (design D7, D12, D15).
53
+ */
54
+ export type PluginDiscoverySource = "workspace" | "installed" | "bundled" | "pi-package" | "local-detected";
55
+
56
+ /** A losing duplicate of a plugin id, recorded on the winner (never loaded). */
57
+ export interface PluginShadowedCopy {
58
+ source: PluginDiscoverySource;
59
+ packageDir: string;
60
+ }
61
+
62
+ /** Result of evaluating a manifest `hostApi` range at discovery. */
63
+ export interface PluginHostApiStatus {
64
+ /** The manifest range; absent when the plugin declares none. */
65
+ range?: string;
66
+ compatible: boolean;
67
+ }
68
+
69
+ /** Why a plugin's client was refused (design D12 precedence: structural, then config, then consent). */
70
+ export type PluginClientRefusedReason =
71
+ | "build-undeclared"
72
+ | "no-bundle"
73
+ | "host-api"
74
+ | "disabled"
75
+ | "missing-dep"
76
+ | "untrusted"
77
+ | "pin-mismatch";
78
+
79
+ /** Client delivery state. Phase 5 adds the `bundled`/`runtime`/`none` handling that fills `sha256`. */
80
+ export interface PluginClientStatus {
81
+ delivery: "bundled" | "runtime" | "refused" | "none";
82
+ refusedReason?: PluginClientRefusedReason;
83
+ /**
84
+ * Content hash of the runtime client bundle. Appears only on the guarded `GET /api/plugins` and
85
+ * `plugins_changed`; NEVER on the unauthenticated `/api/health.plugins[]`.
86
+ */
87
+ sha256?: string;
88
+ }
89
+
48
90
  /** Status of a single discovered plugin, reported by /api/health. */
49
91
  export interface PluginStatus {
50
92
  id: string;
@@ -60,6 +102,18 @@ export interface PluginStatus {
60
102
  error?: string;
61
103
  /** Number of slot claims declared in the plugin's manifest. */
62
104
  claims: number;
105
+ /** Discovery source of the plugin. See change: decouple-plugins-from-core. */
106
+ source?: PluginDiscoverySource;
107
+ /** Losing duplicates of this id (one row per id; never loaded). See change: decouple-plugins-from-core (D15). */
108
+ shadowed?: PluginShadowedCopy[];
109
+ /** Loaded plugin whose package changed or vanished: the running copy is stale until a server restart. */
110
+ restartRequired?: boolean;
111
+ /** Host API range evaluation (absent when the plugin declares none and none is required). */
112
+ hostApi?: PluginHostApiStatus;
113
+ /** Client delivery; `refused` + `host-api` when the host API gate refused the plugin. */
114
+ client?: PluginClientStatus;
115
+ /** `serveApp` mount outcome; `refused` when the host refused the mount. */
116
+ serveApp?: "mounted" | "refused";
63
117
  /**
64
118
  * Where the bridge entry is registered, classified at health-check time.
65
119
  * See change: fix-pi-flows-end-to-end Group 2.
@@ -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;
@@ -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",
@@ -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