@blackbelt-technology/pi-dashboard-extension 0.5.4 → 0.6.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 (254) hide show
  1. package/.pi/skills/browser/LICENSE +201 -0
  2. package/.pi/skills/browser/SKILL.md +105 -0
  3. package/.pi/skills/browser/UPSTREAM.md +46 -0
  4. package/.pi/skills/browser/references/electron.md +351 -0
  5. package/.pi/skills/browser/references/web.md +2789 -0
  6. package/.pi/skills/browser/scripts/detect-dashboard.sh +55 -0
  7. package/.pi/skills/doctor/AGENTS.md +27 -0
  8. package/.pi/skills/doctor/SKILL.md +89 -0
  9. package/.pi/skills/doctor/_lib/checks.ts +177 -0
  10. package/.pi/skills/doctor/_lib/derive-tokens.ts +43 -0
  11. package/.pi/skills/doctor/_lib/front-matter.ts +122 -0
  12. package/.pi/skills/doctor/_lib/index.ts +14 -0
  13. package/.pi/skills/doctor/_lib/knowledge-hash.ts +74 -0
  14. package/.pi/skills/doctor/_lib/provenance.ts +50 -0
  15. package/.pi/skills/doctor/_lib/regenerate.ts +100 -0
  16. package/.pi/skills/doctor/_lib/router.ts +155 -0
  17. package/.pi/skills/doctor/_lib/server-tier.ts +62 -0
  18. package/.pi/skills/doctor/modules/build-reload.knowledge.hash +1 -0
  19. package/.pi/skills/doctor/modules/build-reload.md +51 -0
  20. package/.pi/skills/doctor/modules/env-node.knowledge.hash +1 -0
  21. package/.pi/skills/doctor/modules/env-node.md +49 -0
  22. package/.pi/skills/doctor/modules/install-topology.knowledge.hash +1 -0
  23. package/.pi/skills/doctor/modules/install-topology.md +53 -0
  24. package/.pi/skills/doctor/modules/model-resolution.knowledge.hash +1 -0
  25. package/.pi/skills/doctor/modules/model-resolution.md +53 -0
  26. package/.pi/skills/doctor/modules/peers.knowledge.hash +1 -0
  27. package/.pi/skills/doctor/modules/peers.md +57 -0
  28. package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -0
  29. package/.pi/skills/doctor/modules/pi-resolution.md +60 -0
  30. package/.pi/skills/doctor/modules/plugins-bridges.knowledge.hash +1 -0
  31. package/.pi/skills/doctor/modules/plugins-bridges.md +56 -0
  32. package/.pi/skills/pi-dashboard/SKILL.md +68 -0
  33. package/.pi/skills/pi-dashboard/commands/README.md +45 -0
  34. package/.pi/skills/pi-dashboard/commands/dashboard-flow-abort.md +10 -0
  35. package/.pi/skills/pi-dashboard/commands/dashboard-flow-auto.md +10 -0
  36. package/.pi/skills/pi-dashboard/commands/dashboard-git-branches.md +6 -0
  37. package/.pi/skills/pi-dashboard/commands/dashboard-git-init.md +8 -0
  38. package/.pi/skills/pi-dashboard/commands/dashboard-git-stash-pop.md +8 -0
  39. package/.pi/skills/pi-dashboard/commands/dashboard-list-models.md +10 -0
  40. package/.pi/skills/pi-dashboard/commands/dashboard-peer-list.md +6 -0
  41. package/.pi/skills/pi-dashboard/commands/dashboard-peer-scan.md +6 -0
  42. package/.pi/skills/pi-dashboard/commands/dashboard-pin-list.md +5 -0
  43. package/.pi/skills/pi-dashboard/commands/dashboard-proposal-archive.md +6 -0
  44. package/.pi/skills/pi-dashboard/commands/dashboard-proposal-attach.md +10 -0
  45. package/.pi/skills/pi-dashboard/commands/dashboard-proposal-detach.md +10 -0
  46. package/.pi/skills/pi-dashboard/commands/dashboard-server-config.md +5 -0
  47. package/.pi/skills/pi-dashboard/commands/dashboard-server-health.md +6 -0
  48. package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-off.md +6 -0
  49. package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-on.md +6 -0
  50. package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-status.md +6 -0
  51. package/.pi/skills/pi-dashboard/commands/dashboard-session-abort-all.md +14 -0
  52. package/.pi/skills/pi-dashboard/commands/dashboard-session-abort.md +10 -0
  53. package/.pi/skills/pi-dashboard/commands/dashboard-session-diff.md +11 -0
  54. package/.pi/skills/pi-dashboard/commands/dashboard-session-fork.md +10 -0
  55. package/.pi/skills/pi-dashboard/commands/dashboard-session-hide.md +10 -0
  56. package/.pi/skills/pi-dashboard/commands/dashboard-session-info.md +11 -0
  57. package/.pi/skills/pi-dashboard/commands/dashboard-session-kill.md +10 -0
  58. package/.pi/skills/pi-dashboard/commands/dashboard-session-list-active.md +8 -0
  59. package/.pi/skills/pi-dashboard/commands/dashboard-session-list-here.md +8 -0
  60. package/.pi/skills/pi-dashboard/commands/dashboard-session-list.md +6 -0
  61. package/.pi/skills/pi-dashboard/commands/dashboard-session-model.md +10 -0
  62. package/.pi/skills/pi-dashboard/commands/dashboard-session-rename.md +10 -0
  63. package/.pi/skills/pi-dashboard/commands/dashboard-session-resume.md +10 -0
  64. package/.pi/skills/pi-dashboard/commands/dashboard-session-spawn.md +10 -0
  65. package/.pi/skills/pi-dashboard/commands/dashboard-session-tell.md +10 -0
  66. package/.pi/skills/pi-dashboard/commands/dashboard-session-thinking.md +10 -0
  67. package/.pi/skills/pi-dashboard/commands/dashboard-session-unhide.md +10 -0
  68. package/.pi/skills/pi-dashboard/references/api-reference.md +30 -0
  69. package/.pi/skills/pi-dashboard/references/recipes.md +38 -0
  70. package/.pi/skills/pi-dashboard/references/slash-commands.md +71 -0
  71. package/.pi/skills/pi-dashboard/scripts/dashboard-api.sh +6 -0
  72. package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +217 -0
  73. package/.pi/skills/project-init/SKILL.md +279 -0
  74. package/.pi/skills/project-init/dox-doctrine.md +104 -0
  75. package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +111 -0
  76. package/.pi/skills/project-init/profiles/coding/profile.json +5 -0
  77. package/.pi/skills/project-init/profiles/coding/prompts/plan-change.md +5 -0
  78. package/.pi/skills/project-init/profiles/coding/prompts/tdd-loop.md +6 -0
  79. package/.pi/skills/project-init/profiles/coding/settings.json.tmpl +9 -0
  80. package/.pi/skills/project-init/profiles/docs/AGENTS.md.tmpl +37 -0
  81. package/.pi/skills/project-init/profiles/docs/profile.json +4 -0
  82. package/.pi/skills/project-init/profiles/docs/prompts/draft-page.md +5 -0
  83. package/.pi/skills/project-init/profiles/docs/settings.json.tmpl +9 -0
  84. package/package.json +12 -4
  85. package/src/AGENTS.md +56 -0
  86. package/src/__tests__/abort-latch.test.ts +97 -0
  87. package/src/__tests__/agent-settled.test.ts +82 -0
  88. package/src/__tests__/artifact-roots.test.ts +83 -0
  89. package/src/__tests__/ask-user-attachments.test.ts +106 -0
  90. package/src/__tests__/ask-user-tool.test.ts +90 -27
  91. package/src/__tests__/auto-session-namer.test.ts +339 -0
  92. package/src/__tests__/bridge-default-model-apply.test.ts +242 -0
  93. package/src/__tests__/bridge-default-model-gate.test.ts +6 -3
  94. package/src/__tests__/bridge-followup-mutation.test.ts +217 -0
  95. package/src/__tests__/bridge-followup-queue-drain.test.ts +266 -0
  96. package/src/__tests__/bridge-hasui-flip.test.ts +109 -0
  97. package/src/__tests__/bridge-no-queue-mutation.test.ts +112 -0
  98. package/src/__tests__/bridge-plugin-emit-event.test.ts +44 -0
  99. package/src/__tests__/bridge-shutdown-reset.test.ts +57 -136
  100. package/src/__tests__/bridge-slash-command-routing.test.ts +7 -7
  101. package/src/__tests__/bridge-stop-after-turn.test.ts +72 -0
  102. package/src/__tests__/bridge-system-followup.test.ts +163 -0
  103. package/src/__tests__/bridge-thinking-level-select.test.ts +68 -0
  104. package/src/__tests__/browser-skill-registered.test.ts +84 -0
  105. package/src/__tests__/build-provider-catalogue.test.ts +35 -1
  106. package/src/__tests__/command-handler.test.ts +331 -35
  107. package/src/__tests__/commit-draft.test.ts +100 -0
  108. package/src/__tests__/connection-dropped-frames.test.ts +78 -0
  109. package/src/__tests__/custom-provider-apikey-roundtrip.test.ts +128 -0
  110. package/src/__tests__/cwd-missing-probe.test.ts +82 -0
  111. package/src/__tests__/dashboard-commands-shipped.test.ts +53 -0
  112. package/src/__tests__/dashboard-context-injector.test.ts +190 -0
  113. package/src/__tests__/doctor/checks.test.ts +121 -0
  114. package/src/__tests__/doctor/modules.test.ts +64 -0
  115. package/src/__tests__/doctor/provenance-hash.test.ts +94 -0
  116. package/src/__tests__/doctor/router.test.ts +143 -0
  117. package/src/__tests__/empty-actionable-guard-config.test.ts +32 -0
  118. package/src/__tests__/empty-actionable-guard.test.ts +73 -0
  119. package/src/__tests__/enrich-model-metadata.test.ts +21 -0
  120. package/src/__tests__/extension-slash-command-detection.test.ts +37 -1
  121. package/src/__tests__/filter-enabled-models.test.ts +151 -0
  122. package/src/__tests__/fixtures/turn-actionability-fixtures.ts +69 -0
  123. package/src/__tests__/git-info-status.test.ts +73 -0
  124. package/src/__tests__/git-poll.test.ts +69 -0
  125. package/src/__tests__/markdown-image-inliner.test.ts +37 -0
  126. package/src/__tests__/model-resolve.test.ts +379 -0
  127. package/src/__tests__/pi-version-tracker.test.ts +109 -0
  128. package/src/__tests__/process-scanner.test.ts +112 -22
  129. package/src/__tests__/project-init-detect-stack.test.ts +61 -0
  130. package/src/__tests__/project-init-dox-kb-config.test.ts +53 -0
  131. package/src/__tests__/project-init-profiles.test.ts +84 -0
  132. package/src/__tests__/project-init-scaffold.test.ts +139 -0
  133. package/src/__tests__/project-init-seed-doctrine.test.ts +100 -0
  134. package/src/__tests__/project-trust.test.ts +92 -0
  135. package/src/__tests__/prompt-expander.test.ts +191 -1
  136. package/src/__tests__/provider-register-reload.test.ts +36 -6
  137. package/src/__tests__/provider-register-thinking-levels.test.ts +51 -0
  138. package/src/__tests__/retry-tracker.test.ts +75 -70
  139. package/src/__tests__/role-manager.test.ts +585 -0
  140. package/src/__tests__/role-model-tools-registry-readiness.test.ts +114 -0
  141. package/src/__tests__/role-model-tools.test.ts +229 -0
  142. package/src/__tests__/search-files-completeness.test.ts +111 -0
  143. package/src/__tests__/search-files-ranking.test.ts +168 -0
  144. package/src/__tests__/server-auto-start.test.ts +121 -4
  145. package/src/__tests__/server-launcher-launch.test.ts +24 -6
  146. package/src/__tests__/server-launcher.test.ts +19 -2
  147. package/src/__tests__/session-sync.test.ts +36 -0
  148. package/src/__tests__/subagent-frame-buffer.test.ts +239 -0
  149. package/src/__tests__/tool-result-image-inliner.test.ts +206 -0
  150. package/src/__tests__/tui-prompt-adapter.test.ts +70 -64
  151. package/src/__tests__/turn-actionability.test.ts +86 -0
  152. package/src/__tests__/vcs-info.test.ts +145 -4
  153. package/src/__tests__/visibility-intent.test.ts +43 -0
  154. package/src/abort-latch.ts +55 -0
  155. package/src/abort-latch.ts.AGENTS.md +3 -0
  156. package/src/agent-settled.ts +72 -0
  157. package/src/agent-settled.ts.AGENTS.md +3 -0
  158. package/src/artifact-roots.ts +73 -0
  159. package/src/artifact-roots.ts.AGENTS.md +3 -0
  160. package/src/ask-user-attachments.ts +121 -0
  161. package/src/ask-user-attachments.ts.AGENTS.md +3 -0
  162. package/src/ask-user-tool.ts +56 -58
  163. package/src/ask-user-tool.ts.AGENTS.md +3 -0
  164. package/src/auto-session-namer.ts +334 -0
  165. package/src/auto-session-namer.ts.AGENTS.md +3 -0
  166. package/src/bridge-context.ts +86 -8
  167. package/src/bridge-context.ts.AGENTS.md +3 -0
  168. package/src/bridge-default-model-gate.ts +22 -6
  169. package/src/bridge-default-model-gate.ts.AGENTS.md +3 -0
  170. package/src/bridge.ts +1241 -360
  171. package/src/bridge.ts.AGENTS.md +3 -0
  172. package/src/canvas-tool.ts +107 -0
  173. package/src/command-handler.ts +490 -51
  174. package/src/command-handler.ts.AGENTS.md +3 -0
  175. package/src/commit-draft-agent.ts +114 -0
  176. package/src/commit-draft-agent.ts.AGENTS.md +3 -0
  177. package/src/commit-draft.ts +136 -0
  178. package/src/commit-draft.ts.AGENTS.md +3 -0
  179. package/src/connection.ts +32 -1
  180. package/src/connection.ts.AGENTS.md +3 -0
  181. package/src/dashboard-context-injector.ts +124 -0
  182. package/src/dashboard-context-injector.ts.AGENTS.md +3 -0
  183. package/src/dashboard-default-adapter.ts.AGENTS.md +3 -0
  184. package/src/dev-build.ts.AGENTS.md +3 -0
  185. package/src/empty-actionable-guard-config.ts +32 -0
  186. package/src/empty-actionable-guard-config.ts.AGENTS.md +3 -0
  187. package/src/empty-actionable-guard.ts +90 -0
  188. package/src/empty-actionable-guard.ts.AGENTS.md +3 -0
  189. package/src/event-forwarder.ts.AGENTS.md +3 -0
  190. package/src/flow-event-wiring.ts +4 -14
  191. package/src/flow-event-wiring.ts.AGENTS.md +3 -0
  192. package/src/git-link-builder.ts.AGENTS.md +3 -0
  193. package/src/git-poll.ts +38 -0
  194. package/src/git-poll.ts.AGENTS.md +3 -0
  195. package/src/hasui-flip.ts +56 -0
  196. package/src/hasui-flip.ts.AGENTS.md +3 -0
  197. package/src/markdown-image-inliner.ts +45 -2
  198. package/src/markdown-image-inliner.ts.AGENTS.md +3 -0
  199. package/src/model-tracker.ts +145 -19
  200. package/src/model-tracker.ts.AGENTS.md +3 -0
  201. package/src/multiselect-decode.ts.AGENTS.md +3 -0
  202. package/src/multiselect-list.ts.AGENTS.md +3 -0
  203. package/src/multiselect-polyfill.ts.AGENTS.md +3 -0
  204. package/src/process-metrics.ts.AGENTS.md +3 -0
  205. package/src/process-scanner.ts +114 -103
  206. package/src/process-scanner.ts.AGENTS.md +3 -0
  207. package/src/project-init/AGENTS.md +12 -0
  208. package/src/project-init/detect-stack.ts +146 -0
  209. package/src/project-init/dox-kb-config.ts +47 -0
  210. package/src/project-init/profiles.ts +135 -0
  211. package/src/project-init/scaffold.ts +192 -0
  212. package/src/project-init/seed-doctrine.ts +95 -0
  213. package/src/project-trust.ts +63 -0
  214. package/src/project-trust.ts.AGENTS.md +3 -0
  215. package/src/prompt-bus.ts +10 -1
  216. package/src/prompt-bus.ts.AGENTS.md +3 -0
  217. package/src/prompt-expander.ts +238 -37
  218. package/src/prompt-expander.ts.AGENTS.md +3 -0
  219. package/src/provider-register.ts +323 -54
  220. package/src/provider-register.ts.AGENTS.md +3 -0
  221. package/src/retry-tracker.ts +64 -39
  222. package/src/retry-tracker.ts.AGENTS.md +3 -0
  223. package/src/role-manager.ts +436 -0
  224. package/src/role-manager.ts.AGENTS.md +3 -0
  225. package/src/role-model-tools.ts +301 -0
  226. package/src/role-model-tools.ts.AGENTS.md +3 -0
  227. package/src/server-auto-start.ts +59 -23
  228. package/src/server-auto-start.ts.AGENTS.md +3 -0
  229. package/src/server-launcher.ts +56 -16
  230. package/src/server-launcher.ts.AGENTS.md +3 -0
  231. package/src/session-sync.ts +111 -15
  232. package/src/session-sync.ts.AGENTS.md +3 -0
  233. package/src/slash-dispatch.ts +13 -11
  234. package/src/slash-dispatch.ts.AGENTS.md +3 -0
  235. package/src/source-detector.ts.AGENTS.md +3 -0
  236. package/src/subagent-frame-buffer.ts +220 -0
  237. package/src/subagent-frame-buffer.ts.AGENTS.md +3 -0
  238. package/src/tool-result-image-inliner.ts +204 -0
  239. package/src/tool-result-image-inliner.ts.AGENTS.md +3 -0
  240. package/src/tui-prompt-adapter.ts +123 -0
  241. package/src/tui-prompt-adapter.ts.AGENTS.md +3 -0
  242. package/src/turn-actionability.ts +117 -0
  243. package/src/turn-actionability.ts.AGENTS.md +3 -0
  244. package/src/ui-modules.ts.AGENTS.md +3 -0
  245. package/src/vcs-info.ts +91 -129
  246. package/src/vcs-info.ts.AGENTS.md +3 -0
  247. package/src/visibility-intent.ts +34 -0
  248. package/src/visibility-intent.ts.AGENTS.md +3 -0
  249. package/src/__tests__/bridge-retry-ordering.test.ts +0 -148
  250. package/src/__tests__/bridge-shadow-queue-drain.test.ts +0 -221
  251. package/src/__tests__/fixtures/usage-limit-error-strings.ts +0 -127
  252. package/src/__tests__/usage-limit-orderer.test.ts +0 -117
  253. package/src/__tests__/vcs-info-jj.test.ts +0 -145
  254. package/src/usage-limit-orderer.ts +0 -93
@@ -0,0 +1,301 @@
1
+ /**
2
+ * Agent-facing role/model tools (capability `agent-role-model-tools`).
3
+ *
4
+ * Three decoupled tools registered via `pi.registerTool` at bridge activation:
5
+ * - `list_models` — READ. Assignable model catalogue from the IN-PROCESS
6
+ * session registry (the exact ModelSelector source:
7
+ * `cachedModelRegistry.getAvailable()`), roles-independent.
8
+ * - `list_roles` — READ. `{ roles(bound-only), presets, activePreset }`.
9
+ * - `update_roles` — WRITE, action-dispatched, `ask_user`-confirmed. Mutates
10
+ * the global `~/.pi/agent/providers.json` role slice.
11
+ *
12
+ * Model listing and role reading are DECOUPLED: `list_models` never touches the
13
+ * role slice, so a missing/malformed `providers.json#roles` cannot break model
14
+ * discovery.
15
+ *
16
+ * See change: add-agent-role-model-tools.
17
+ */
18
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
19
+ import { Type } from "typebox";
20
+ import { getCustomProviderNames } from "./provider-register.js";
21
+ import {
22
+ addRoleName,
23
+ loadRoleConfig,
24
+ removeRoleFromSchema,
25
+ saveRoleConfig,
26
+ } from "./role-manager.js";
27
+
28
+ export interface RoleModelToolsDeps {
29
+ /** Returns the in-process session ModelRegistry (bridge's cachedModelRegistry). */
30
+ getRegistry: () => any;
31
+ }
32
+
33
+ // ── list_models row shape ───────────────────────────────────────────────────
34
+
35
+ export interface ModelRow {
36
+ ref: string;
37
+ provider: string;
38
+ id: string;
39
+ custom?: boolean;
40
+ reasoning?: boolean;
41
+ input?: string[];
42
+ contextWindow?: number;
43
+ cost?: unknown;
44
+ excludedReason?: "no-credential" | "oauth-incompatible" | null;
45
+ }
46
+
47
+ function rowFromModel(m: any, custom: boolean): ModelRow {
48
+ return {
49
+ ref: `${m?.provider ?? ""}/${m?.id ?? ""}`,
50
+ provider: m?.provider ?? "",
51
+ id: m?.id ?? "",
52
+ ...(custom ? { custom: true } : {}),
53
+ reasoning: typeof m?.reasoning === "boolean" ? m.reasoning : undefined,
54
+ input: Array.isArray(m?.input) ? m.input : undefined,
55
+ contextWindow: typeof m?.contextWindow === "number" ? m.contextWindow : undefined,
56
+ cost: m?.cost,
57
+ };
58
+ }
59
+
60
+ /**
61
+ * Build the model rows from the session registry. Default = reachability-
62
+ * filtered (`getAvailable()`, the ModelSelector source). `annotated` = every
63
+ * known model (`getAll()`) with an `excludedReason` for those not reachable
64
+ * (pi's ModelRegistry has no `getAllAnnotated()`, so we derive it here).
65
+ * Roles-independent: reads only the registry, never the role slice.
66
+ */
67
+ export function buildModelRows(registry: any, annotated: boolean): ModelRow[] {
68
+ if (!registry) return [];
69
+ const custom = getCustomProviderNames();
70
+ if (!annotated) {
71
+ const avail: any[] = registry.getAvailable?.() ?? [];
72
+ return avail.map((m) => rowFromModel(m, custom.has(m?.provider)));
73
+ }
74
+ const all: any[] = registry.getAll?.() ?? [];
75
+ const avail: any[] = registry.getAvailable?.() ?? [];
76
+ const availKeys = new Set(avail.map((m) => `${m?.provider}/${m?.id}`));
77
+ return all.map((m) => {
78
+ const row = rowFromModel(m, custom.has(m?.provider));
79
+ row.excludedReason = availKeys.has(`${m?.provider}/${m?.id}`) ? null : "no-credential";
80
+ return row;
81
+ });
82
+ }
83
+
84
+ // ── list_models result envelope (registry-readiness discriminator) ──────────
85
+
86
+ export interface ModelsResult {
87
+ models: ModelRow[];
88
+ /** false iff the in-process registry is absent (not yet hydrated). */
89
+ registryReady: boolean;
90
+ /** Present only when registryReady === false. */
91
+ reason?: string;
92
+ }
93
+
94
+ /**
95
+ * Wrap `buildModelRows` in the readiness envelope. A falsy registry (the
96
+ * spawn-before-discovery window) yields `registryReady: false` + a `reason`
97
+ * instead of a silent empty catalogue, so an empty `models` is never ambiguous
98
+ * between "registry not hydrated" (retry) and "registry hydrated, no reachable
99
+ * models" (true answer). Additive/backward-compatible: consumers reading only
100
+ * `models` are unaffected. See change: fix-list-models-empty-on-unhydrated-registry.
101
+ */
102
+ export function buildModelsResult(registry: any, annotated: boolean): ModelsResult {
103
+ if (!registry) {
104
+ return {
105
+ models: [],
106
+ registryReady: false,
107
+ reason: "model registry not yet hydrated in this session; retry shortly",
108
+ };
109
+ }
110
+ return { models: buildModelRows(registry, annotated), registryReady: true };
111
+ }
112
+
113
+ // ── Registration ─────────────────────────────────────────────────────────────
114
+
115
+ export function registerRoleModelTools(pi: ExtensionAPI, deps: RoleModelToolsDeps): void {
116
+ // ── list_models (read, roles-independent) ─────────────────────────────────
117
+ pi.registerTool({
118
+ name: "list_models",
119
+ label: "List Models",
120
+ description:
121
+ "List the assignable model catalogue from this session's registry — the exact set the human Model Selector shows (including custom providers). Each row carries a `ref` (\"provider/id\") assignable via update_roles. Pass `annotated: true` to also include models excluded for lack of credentials (each with an `excludedReason`). Independent of roles — works even when no roles are configured. The result also carries `registryReady`: when `false` the in-process registry is not yet hydrated (empty `models` + a `reason`) — retry shortly, do NOT conclude no models exist. When `registryReady` is `true` and `models` is unexpectedly empty, try `annotated: true` to reveal `no-credential`/`oauth-incompatible` exclusions.",
122
+ parameters: Type.Object({
123
+ annotated: Type.Optional(
124
+ Type.Boolean({
125
+ description:
126
+ "When true, include every known model (not just reachable ones), each with an `excludedReason` (\"no-credential\" / \"oauth-incompatible\") or null when included.",
127
+ }),
128
+ ),
129
+ }),
130
+ async execute(_id: any, params: any, _signal: any, _onUpdate: any, _ctx: any) {
131
+ const annotated = params?.annotated === true;
132
+ const result = buildModelsResult(deps.getRegistry(), annotated);
133
+ return {
134
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
135
+ details: result,
136
+ };
137
+ },
138
+ });
139
+
140
+ // ── list_roles (read) ─────────────────────────────────────────────────────
141
+ pi.registerTool({
142
+ name: "list_roles",
143
+ label: "List Roles",
144
+ description:
145
+ "List the configured role → model bindings, the preset names, and the active preset. Returns only roles with an assigned model (empty slots are omitted). No model catalogue — use list_models for that. Tolerates a missing/malformed role config (returns empty).",
146
+ parameters: Type.Object({}),
147
+ async execute(_id: any, _params: any, _signal: any, _onUpdate: any, _ctx: any) {
148
+ const cfg = loadRoleConfig();
149
+ const roles: Record<string, string> = {};
150
+ for (const [k, v] of Object.entries(cfg.roles)) {
151
+ if (typeof v === "string" && v.trim() !== "") roles[k] = v.trim();
152
+ }
153
+ const result = {
154
+ roles,
155
+ presets: cfg.rolePresets.map((p) => p.name),
156
+ activePreset: cfg.activePreset,
157
+ };
158
+ return {
159
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
160
+ details: result,
161
+ };
162
+ },
163
+ });
164
+
165
+ // ── update_roles (write, confirmed, dispatched) ───────────────────────────
166
+ pi.registerTool({
167
+ name: "update_roles",
168
+ label: "Update Roles",
169
+ description:
170
+ "Wire roles and presets. Actions: set_role {role, ref, preset?} (assigns a model ref to a role; creates the role if new; targets a named preset when `preset` given, else the active map), remove_role {role} (purges the role from the schema, the active map, and every preset), create_preset {name}, load_preset {name}, delete_preset {name}. EVERY action mutates the global ~/.pi/agent/providers.json shared by all sessions, so each requires user confirmation before writing.",
171
+ parameters: Type.Object({
172
+ action: Type.Union(
173
+ [
174
+ Type.Literal("set_role"),
175
+ Type.Literal("remove_role"),
176
+ Type.Literal("create_preset"),
177
+ Type.Literal("load_preset"),
178
+ Type.Literal("delete_preset"),
179
+ ],
180
+ { description: "Which mutation to perform." },
181
+ ),
182
+ role: Type.Optional(Type.String({ description: "Role name (set_role, remove_role)." })),
183
+ ref: Type.Optional(
184
+ Type.String({ description: "Model ref \"provider/id\" (set_role). Use list_models to find valid refs." }),
185
+ ),
186
+ preset: Type.Optional(
187
+ Type.String({ description: "Target preset name for set_role (writes into that preset without loading it)." }),
188
+ ),
189
+ name: Type.Optional(
190
+ Type.String({ description: "Preset name (create_preset, load_preset, delete_preset)." }),
191
+ ),
192
+ }),
193
+ async execute(_id: any, params: any, _signal: any, _onUpdate: any, ctx: any) {
194
+ const fail = (error: string) => ({
195
+ content: [{ type: "text", text: JSON.stringify({ success: false, error }) }],
196
+ details: { success: false, error },
197
+ });
198
+ const ok = () => ({
199
+ content: [{ type: "text", text: JSON.stringify({ success: true }) }],
200
+ details: { success: true },
201
+ });
202
+
203
+ const action: string = params?.action;
204
+
205
+ // Confirmation gate — every mutating action. `providers.json` is shared
206
+ // machine-wide; confirm before any write.
207
+ const confirmMsg = describeAction(params);
208
+ const confirmed = await ctx?.ui?.confirm?.(
209
+ "Update global roles?",
210
+ `${confirmMsg}\n\nThis edits ~/.pi/agent/providers.json, shared by all sessions on this machine.`,
211
+ );
212
+ if (!confirmed) return { ...fail("User declined the change."), details: { success: false } };
213
+
214
+ try {
215
+ const cfg = loadRoleConfig();
216
+ switch (action) {
217
+ case "set_role": {
218
+ const role = String(params?.role ?? "").trim();
219
+ const ref = String(params?.ref ?? "").trim();
220
+ if (!role || !ref) return fail("set_role requires `role` and `ref`.");
221
+ addRoleName(cfg, role);
222
+ const preset = typeof params?.preset === "string" ? params.preset.trim() : "";
223
+ if (preset) {
224
+ const p = cfg.rolePresets.find((x) => x.name === preset);
225
+ if (!p) return fail(`Preset "${preset}" not found.`);
226
+ p.roles[role] = ref;
227
+ } else {
228
+ cfg.roles[role] = ref;
229
+ if (cfg.activePreset) {
230
+ const p = cfg.rolePresets.find((x) => x.name === cfg.activePreset);
231
+ if (p) p.roles = { ...cfg.roles };
232
+ }
233
+ }
234
+ saveRoleConfig(cfg);
235
+ return ok();
236
+ }
237
+ case "remove_role": {
238
+ const role = String(params?.role ?? "").trim();
239
+ if (!role) return fail("remove_role requires `role`.");
240
+ removeRoleFromSchema(cfg, role);
241
+ saveRoleConfig(cfg);
242
+ return ok();
243
+ }
244
+ case "create_preset": {
245
+ const name = String(params?.name ?? "").trim();
246
+ if (!name) return fail("create_preset requires `name`.");
247
+ const idx = cfg.rolePresets.findIndex((p) => p.name === name);
248
+ const preset = { name, roles: { ...cfg.roles } };
249
+ if (idx >= 0) cfg.rolePresets[idx] = preset;
250
+ else cfg.rolePresets.push(preset);
251
+ saveRoleConfig(cfg);
252
+ return ok();
253
+ }
254
+ case "load_preset": {
255
+ const name = String(params?.name ?? "").trim();
256
+ if (!name) return fail("load_preset requires `name`.");
257
+ const p = cfg.rolePresets.find((x) => x.name === name);
258
+ if (!p) return fail(`Preset "${name}" not found.`);
259
+ cfg.roles = { ...p.roles };
260
+ cfg.activePreset = name;
261
+ saveRoleConfig(cfg);
262
+ return ok();
263
+ }
264
+ case "delete_preset": {
265
+ const name = String(params?.name ?? "").trim();
266
+ if (!name) return fail("delete_preset requires `name`.");
267
+ const before = cfg.rolePresets.length;
268
+ cfg.rolePresets = cfg.rolePresets.filter((p) => p.name !== name);
269
+ if (cfg.rolePresets.length === before) return fail(`Preset "${name}" not found.`);
270
+ if (cfg.activePreset === name) cfg.activePreset = null;
271
+ saveRoleConfig(cfg);
272
+ return ok();
273
+ }
274
+ default:
275
+ return fail(`Unknown action "${action}".`);
276
+ }
277
+ } catch (err: any) {
278
+ return fail(err?.message ?? String(err));
279
+ }
280
+ },
281
+ });
282
+ }
283
+
284
+ function describeAction(params: any): string {
285
+ switch (params?.action) {
286
+ case "set_role":
287
+ return params?.preset
288
+ ? `Set role "${params?.role}" → "${params?.ref}" in preset "${params?.preset}".`
289
+ : `Set role "${params?.role}" → "${params?.ref}".`;
290
+ case "remove_role":
291
+ return `Remove role "${params?.role}" from every preset.`;
292
+ case "create_preset":
293
+ return `Save the current roles as preset "${params?.name}".`;
294
+ case "load_preset":
295
+ return `Load preset "${params?.name}" (replaces the active roles).`;
296
+ case "delete_preset":
297
+ return `Delete preset "${params?.name}".`;
298
+ default:
299
+ return `Perform "${params?.action}".`;
300
+ }
301
+ }
@@ -0,0 +1,3 @@
1
+ # role-model-tools.ts — index
2
+
3
+ Agent-facing tools registered via `pi.registerTool` (capability agent-role-model-tools). Exports `registerRoleModelTools(pi,{getRegistry})`, `buildModelRows`, `buildModelsResult`, `ModelRow`, `ModelsResult`. `list_models` (read, roles-independent, source = `getRegistry().getAvailable()` = ModelSelector path; `annotated` derives `excludedReason` from `getAll()`\`getAvailable()` since pi ModelRegistry lacks `getAllAnnotated()`; custom flag via `getCustomProviderNames()`; result carries `registryReady` discriminator via `buildModelsResult` — falsy registry ⇒ `{ models:[], registryReady:false, reason }` (spawn-before-hydration, retry), else `registryReady:true`; disambiguates empty-vs-unhydrated; annotated obeys same discriminator. See change: fix-list-models-empty-on-unhydrated-registry), `list_roles` (read, bound-only, no models key), `update_roles` (write, discriminated `action`, every mutation gated behind `ctx.ui.confirm`, routes through role-manager accessors + atomic write). See change: add-agent-role-model-tools.
@@ -2,8 +2,7 @@
2
2
  * Auto-start logic for the dashboard server.
3
3
  * Uses mDNS discovery first, falls back to health check, then auto-starts.
4
4
  */
5
- import os from "node:os";
6
- import path from "node:path";
5
+ import { getDashboardServerLogPath } from "@blackbelt-technology/pi-dashboard-shared/dashboard-paths.js";
7
6
 
8
7
  export interface DiscoveredServer {
9
8
  host: string;
@@ -16,7 +15,7 @@ export interface DiscoveredServer {
16
15
  export interface AutoStartDeps {
17
16
  discoverDashboard: (timeout?: number) => Promise<DiscoveredServer[]>;
18
17
  isDashboardRunning: (port: number) => Promise<{ running: boolean; portConflict?: boolean }>;
19
- launchServer: (config: any) => Promise<{ success: boolean; message: string }>;
18
+ launchServer: (config: any) => Promise<{ success: boolean; message: string; childPid?: number; logOwned?: boolean }>;
20
19
  notify: (message: string, level: "info" | "warning") => void;
21
20
  /**
22
21
  * Optional callback fired immediately BEFORE `launchServer(config)` is
@@ -32,6 +31,15 @@ export interface AutoStartDeps {
32
31
  * Passes the final success state so the caller can clear spinners.
33
32
  */
34
33
  onLaunchEnd?: (success: boolean) => void;
34
+ /**
35
+ * Optional callback fired synchronously after `launchServer` reports
36
+ * success and returned a `childPid`. Used by the bridge to register
37
+ * the spawned server's PID into its `selfSpawnedPgids` exclusion set
38
+ * BEFORE the next process-scan tick, so the dashboard's own server
39
+ * never surfaces in the session-card process list.
40
+ * See change: tighten-process-list-ux.
41
+ */
42
+ onServerSpawned?: (childPid: number) => void;
35
43
  /**
36
44
  * Optional predicate. When it returns true, the auto-start spawn step
37
45
  * (step 3 below) is skipped — mDNS discovery + health check still run,
@@ -47,6 +55,20 @@ export interface AutoStartResult {
47
55
  server?: { host: string; port: number; piPort: number };
48
56
  }
49
57
 
58
+ /**
59
+ * Opt-out gate for isolated / CI runs. When `PI_DASHBOARD_NO_MDNS` is truthy
60
+ * the bridge skips mDNS discovery entirely and binds to the explicit /
61
+ * configured URL via the health-check path. Mirrors the server's identical
62
+ * gate in `server.ts` (PI_DASHBOARD_NO_MDNS). Without this, a co-located real
63
+ * dashboard advertising on mDNS would be discovered here and override the
64
+ * bridge's explicit `PI_DASHBOARD_URL`, hijacking the connection off the
65
+ * isolated gateway. See change: resolve-global-prompt-templates-from-dashboard.
66
+ */
67
+ function mdnsDisabled(): boolean {
68
+ const raw = (process.env.PI_DASHBOARD_NO_MDNS ?? "").trim().toLowerCase();
69
+ return raw === "1" || raw === "true" || raw === "yes";
70
+ }
71
+
50
72
  /**
51
73
  * Discover or auto-start the dashboard server.
52
74
  * Discovery chain: mDNS browse → health check fallback → auto-start.
@@ -56,16 +78,20 @@ export async function autoStartServer(
56
78
  config: { piPort: number; port: number; autoStart: boolean },
57
79
  deps: AutoStartDeps,
58
80
  ): Promise<AutoStartResult> {
59
- // 1. Try mDNS discovery (2s timeout)
60
- try {
61
- const servers = await deps.discoverDashboard(2000);
62
- const local = servers.find(s => s.isLocal);
63
- if (local) {
64
- return { server: { host: local.host, port: local.port, piPort: local.piPort } };
81
+ const noMdns = mdnsDisabled();
82
+
83
+ // 1. Try mDNS discovery (2s timeout) — skipped when mDNS is disabled.
84
+ if (!noMdns) {
85
+ try {
86
+ const servers = await deps.discoverDashboard(2000);
87
+ const local = servers.find(s => s.isLocal);
88
+ if (local) {
89
+ return { server: { host: local.host, port: local.port, piPort: local.piPort } };
90
+ }
91
+ // Remote servers exist but no local — fall through to health check
92
+ } catch {
93
+ // mDNS failed — fall through to health check
65
94
  }
66
- // Remote servers exist but no local — fall through to health check
67
- } catch {
68
- // mDNS failed — fall through to health check
69
95
  }
70
96
 
71
97
  // 2. Fallback: health check on configured port
@@ -93,18 +119,24 @@ export async function autoStartServer(
93
119
  deps.onLaunchStart?.();
94
120
  const result = await deps.launchServer(config);
95
121
  if (result.success) {
122
+ if (typeof result.childPid === "number" && result.childPid > 0) {
123
+ deps.onServerSpawned?.(result.childPid);
124
+ }
96
125
  deps.onLaunchEnd?.(true);
97
126
  deps.notify(`🌐 Dashboard started at http://localhost:${config.port}`, "info");
98
127
 
99
- // Wait for mDNS advertisement from the newly started server (up to 10s)
100
- try {
101
- const discovered = await deps.discoverDashboard(10000);
102
- const local = discovered.find(s => s.isLocal);
103
- if (local) {
104
- return { server: { host: local.host, port: local.port, piPort: local.piPort } };
128
+ // Wait for mDNS advertisement from the newly started server (up to 10s).
129
+ // Skipped when mDNS is disabled — bind directly to the configured ports.
130
+ if (!noMdns) {
131
+ try {
132
+ const discovered = await deps.discoverDashboard(10000);
133
+ const local = discovered.find(s => s.isLocal);
134
+ if (local) {
135
+ return { server: { host: local.host, port: local.port, piPort: local.piPort } };
136
+ }
137
+ } catch {
138
+ // mDNS failed — use config defaults
105
139
  }
106
- } catch {
107
- // mDNS failed — use config defaults
108
140
  }
109
141
 
110
142
  return { server: { host: "localhost", port: config.port, piPort: config.piPort } };
@@ -118,11 +150,15 @@ export async function autoStartServer(
118
150
  }
119
151
 
120
152
  // Surface the log path so users can inspect the crash output without having
121
- // to know the convention. See change: fix-windows-server-parity.
153
+ // to know the convention. The bridge auto-spawn owns this file when the spawn
154
+ // reached the log-owning path (stdio:{logFile}); only failures that abort
155
+ // before the log fd opens (JitiNotFoundError → logOwned:false) skip the
156
+ // suffix, so we never point users at a server.log that was never written.
157
+ // See change: fix-windows-server-parity, fix-bridge-server-start-diagnostics.
122
158
  deps.onLaunchEnd?.(false);
123
- const logPath = path.join(os.homedir(), ".pi", "dashboard", "server.log");
159
+ const logSuffix = result.logOwned === false ? "" : `\nSee log: ${getDashboardServerLogPath()}`;
124
160
  deps.notify(
125
- `Dashboard server failed to start: ${result.message}\nSee log: ${logPath}`,
161
+ `Dashboard server failed to start: ${result.message}${logSuffix}`,
126
162
  "warning",
127
163
  );
128
164
  return {};
@@ -0,0 +1,3 @@
1
+ # server-auto-start.ts — index
2
+
3
+ Auto-start orchestration: discover dashboard via mDNS → health-check fallback → spawn server process. Exports `DiscoveredServer`, `AutoStartDeps`, `AutoStartResult`, `autoStartServer`. Honors `PI_DASHBOARD_NO_MDNS` opt-out gate, `shouldSuppressAutoStart` restart-quiesce hook, `onServerSpawned` PID exclusion callback, `onLaunchStart`/`onLaunchEnd` spinner hooks. Surfaces `getDashboardServerLogPath()` on launch failure.
@@ -3,15 +3,17 @@
3
3
  * The spawned server runs in foreground mode (no subcommand) and writes
4
4
  * its own PID file at ~/.pi/dashboard/server.pid.
5
5
  */
6
- import path from "node:path";
6
+
7
7
  import { createRequire } from "node:module";
8
+ import path from "node:path";
8
9
  import { fileURLToPath } from "node:url";
9
10
  import type { DashboardConfig } from "@blackbelt-technology/pi-dashboard-shared/config.js";
11
+ import { getDashboardServerLogPath } from "@blackbelt-technology/pi-dashboard-shared/dashboard-paths.js";
10
12
  import {
11
- launchDashboardServer,
13
+ EarlyExitError,
12
14
  JitiNotFoundError,
15
+ launchDashboardServer,
13
16
  PortConflictError,
14
- EarlyExitError,
15
17
  } from "@blackbelt-technology/pi-dashboard-shared/server-launcher.js";
16
18
 
17
19
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -20,6 +22,22 @@ const require = createRequire(import.meta.url);
20
22
  export interface LaunchResult {
21
23
  success: boolean;
22
24
  message: string;
25
+ /**
26
+ * PID of the spawned child process when `success === true`. Surfaces
27
+ * `launchDashboardServer`'s underlying `childPid` so callers (e.g. the
28
+ * bridge) can register self-spawned PIDs into their exclusion set
29
+ * synchronously after launch. See change: tighten-process-list-ux.
30
+ */
31
+ childPid?: number;
32
+ /**
33
+ * Whether the spawn reached the log-owning path (i.e. `launchDashboardServer`
34
+ * opened `~/.pi/dashboard/server.log` before failing). `false` only for
35
+ * failures that abort BEFORE the log fd is opened (currently just
36
+ * `JitiNotFoundError` — loader resolution precedes log creation). Callers use
37
+ * this to avoid pointing users at a `server.log` that was never written.
38
+ * See change: fix-bridge-server-start-diagnostics (CodeRabbit #3).
39
+ */
40
+ logOwned?: boolean;
23
41
  }
24
42
 
25
43
  /**
@@ -45,10 +63,19 @@ export function resolveServerCliPath(): string {
45
63
  }
46
64
  }
47
65
 
66
+ /**
67
+ * Default V8 old-space ceiling (MB) for the dashboard server. Guards against a
68
+ * single oversized forwarded event OOM-ing the process before the per-event
69
+ * size cap can degrade it — belt-and-braces, not the primary fix.
70
+ * See change: bound-subagent-event-serialization.
71
+ */
72
+ export const DEFAULT_SERVER_MAX_OLD_SPACE_MB = 8192;
73
+
48
74
  /**
49
75
  * Build the environment object passed to the spawned server process.
50
76
  * Always stamps DASHBOARD_STARTER=Bridge so the server knows it was
51
- * launched by the pi bridge extension.
77
+ * launched by the pi bridge extension. Adds `--max-old-space-size` to
78
+ * NODE_OPTIONS for heap headroom, but never overrides a user-supplied value.
52
79
  */
53
80
  export function buildSpawnEnv(
54
81
  baseEnv: NodeJS.ProcessEnv = process.env,
@@ -59,6 +86,12 @@ export function buildSpawnEnv(
59
86
  if (v !== undefined) out[k] = v;
60
87
  }
61
88
  out["DASHBOARD_STARTER"] = "Bridge";
89
+ // Only add heap headroom when the user has not already pinned a limit.
90
+ const existing = out["NODE_OPTIONS"] ?? "";
91
+ if (!/--max[-_]old[-_]space[-_]size/.test(existing)) {
92
+ const flag = `--max-old-space-size=${DEFAULT_SERVER_MAX_OLD_SPACE_MB}`;
93
+ out["NODE_OPTIONS"] = existing ? `${existing} ${flag}` : flag;
94
+ }
62
95
  return out;
63
96
  }
64
97
 
@@ -78,39 +111,46 @@ export function buildSpawnArgs(config: DashboardConfig): string[] {
78
111
  * loader resolution, argv shape, env merge, log-file policy, and
79
112
  * readiness polling (see `packages/shared/src/server-launcher.ts`).
80
113
  *
81
- * Bridge-specific contract preserved: `DASHBOARD_STARTER=Bridge`,
82
- * `stdio: "ignore"` (Bridge auto-spawn never owns the log file),
83
- * 2 s health timeout (Bridge expects a fast cold-start when the
84
- * server is already on the same machine).
114
+ * Bridge-specific contract: `DASHBOARD_STARTER=Bridge`,
115
+ * `stdio: { logFile: getDashboardServerLogPath() }` (Bridge auto-spawn
116
+ * now owns the shared `~/.pi/dashboard/server.log` so a slow/crashed
117
+ * cold start leaves an inspectable log), and a 10 s cold-start health
118
+ * timeout (slow hosts reach `writePid()` but are not health-OK within
119
+ * 2 s; `EarlyExitError` still surfaces a real crash instantly).
120
+ * See change: fix-bridge-server-start-diagnostics.
85
121
  */
86
122
  export async function launchServer(config: DashboardConfig): Promise<LaunchResult> {
87
123
  const cliPath = resolveServerCliPath();
88
124
  const args = buildSpawnArgs(config);
89
125
 
90
126
  try {
91
- await launchDashboardServer({
127
+ const result = await launchDashboardServer({
92
128
  cliPath,
93
129
  extraArgs: args,
94
- stdio: "ignore",
95
- healthTimeoutMs: 2_000,
130
+ stdio: { logFile: getDashboardServerLogPath() },
131
+ healthTimeoutMs: 10_000,
96
132
  port: config.port,
97
133
  starter: "Bridge",
98
134
  });
99
- return { success: true, message: "Server started" };
135
+ return { success: true, message: "Server started", childPid: result.childPid, logOwned: true };
100
136
  } catch (err: unknown) {
101
137
  if (err instanceof JitiNotFoundError) {
102
- return { success: false, message: err.message };
138
+ // Thrown before the log fd is opened — no server.log exists.
139
+ return { success: false, message: err.message, logOwned: false };
103
140
  }
104
141
  if (err instanceof PortConflictError) {
105
- return { success: false, message: err.message };
142
+ return { success: false, message: err.message, logOwned: true };
106
143
  }
107
144
  if (err instanceof EarlyExitError) {
108
145
  return {
109
146
  success: false,
110
- message: `Server process exited (code=${err.code}) before health check. See ~/.pi/dashboard/server.log`,
147
+ message: `Server process exited (code=${err.code}) before health check. See ${getDashboardServerLogPath()}`,
148
+ logOwned: true,
111
149
  };
112
150
  }
151
+ // Readiness timeout (and any other post-spawn error): the log was opened
152
+ // before the readiness loop, so it exists and is worth pointing at.
113
153
  const message = err instanceof Error ? err.message : String(err);
114
- return { success: false, message };
154
+ return { success: false, message, logOwned: true };
115
155
  }
116
156
  }
@@ -0,0 +1,3 @@
1
+ # server-launcher.ts — index
2
+
3
+ Spawns dashboard server as detached process via shared `launchDashboardServer`. Exports `LaunchResult`, `resolveServerCliPath`, `buildSpawnEnv`, `buildSpawnArgs`, `launchServer`, `DEFAULT_SERVER_MAX_OLD_SPACE_MB`. Resolves CLI path (monorepo-dev vs installed), stamps `DASHBOARD_STARTER=Bridge`, logs to `getDashboardServerLogPath()`, 10s health timeout. `buildSpawnEnv` adds `--max-old-space-size=8192` to `NODE_OPTIONS` (heap headroom) unless the user already pinned a limit. See change: bound-subagent-event-serialization. Classifies `JitiNotFoundError`/`PortConflictError`/`EarlyExitError` → `logOwned` flag.