@chankov/agent-fleet 0.0.11 → 1.0.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 (494) hide show
  1. package/.pi/extensions/agent-fleet-update-check/README.md +4 -4
  2. package/.pi/extensions/btw/README.md +26 -25
  3. package/.pi/extensions/btw/index.ts +80 -83
  4. package/.pi/extensions/pi-voice-stt/README.md +4 -3
  5. package/.pi/extensions/pi-voice-stt/config.ts +1 -1
  6. package/.pi/harnesses/agent-hub/README.md +106 -54
  7. package/.pi/harnesses/agent-hub/backend-policy.js +25 -4
  8. package/.pi/harnesses/agent-hub/footer.ts +4 -0
  9. package/.pi/harnesses/agent-hub/helpers.ts +18 -0
  10. package/.pi/harnesses/agent-hub/index.ts +537 -369
  11. package/.pi/harnesses/agent-hub/monitor-session-bridge.ts +10 -1
  12. package/.pi/harnesses/agent-hub/package.json +1 -1
  13. package/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
  14. package/.pi/harnesses/agent-hub/posture.ts +103 -0
  15. package/.pi/harnesses/ask-user-remote/README.md +37 -3
  16. package/.pi/harnesses/ask-user-remote/index.ts +173 -17
  17. package/.pi/harnesses/coms/package.json +1 -1
  18. package/.pi/harnesses/damage-control-continue/package.json +1 -1
  19. package/.pi/harnesses/lib/fleet-dashboard-ops.ts +118 -0
  20. package/.pi/harnesses/lib/fleet-dashboard-view.ts +140 -0
  21. package/.pi/harnesses/lib/fleet-detail-view.ts +43 -0
  22. package/.pi/harnesses/lib/fleet-overlay.ts +26 -0
  23. package/.pi/harnesses/lib/fleet-panel.ts +34 -0
  24. package/.pi/harnesses/lib/fleet-read-model.ts +131 -0
  25. package/.pi/harnesses/lib/fleet-selection.ts +24 -0
  26. package/.pi/harnesses/package-lock.json +2011 -0
  27. package/.pi/harnesses/package.json +1 -0
  28. package/.versions/0.0.11/.pi/extensions/agent-fleet-update-check/README.md +4 -4
  29. package/.versions/0.0.11/.pi/extensions/pi-voice-stt/README.md +4 -3
  30. package/.versions/0.0.11/.pi/extensions/pi-voice-stt/config.ts +1 -1
  31. package/.versions/0.0.11/.pi/harnesses/agent-hub/monitor-session-bridge.ts +10 -1
  32. package/.versions/0.0.11/.pi/harnesses/ask-user-remote/README.md +37 -3
  33. package/.versions/0.0.11/.pi/harnesses/ask-user-remote/index.ts +173 -17
  34. package/.versions/0.0.11/.pi/harnesses/package-lock.json +2011 -0
  35. package/.versions/0.0.11/.pi/harnesses/package.json +1 -0
  36. package/.versions/0.0.11/docs/ARCHITECTURE.md +6 -8
  37. package/.versions/0.0.11/docs/agent-fleet-setup.md +17 -43
  38. package/.versions/0.0.11/docs/claude-code-coms-bridge.md +20 -2
  39. package/.versions/0.0.11/docs/coms-hermes-bridge.md +1 -1
  40. package/.versions/0.0.11/docs/getting-started.md +26 -237
  41. package/.versions/0.0.11/docs/npm-install.md +60 -478
  42. package/.versions/0.0.11/docs/pi-extensions.md +4 -4
  43. package/.versions/0.0.11/docs/pi-setup.md +37 -551
  44. package/.versions/0.0.11/hermes/README.md +1 -1
  45. package/.versions/0.0.11/install-manifest.json +375 -1247
  46. package/.versions/0.0.11/justfile +13 -6
  47. package/.versions/0.0.11/manifest-meta.json +543 -134
  48. package/.versions/0.0.11/scripts/lib/fleet-command.ts +8 -0
  49. package/.versions/0.0.11/scripts/lib/monitor-env.ts +18 -6
  50. package/.versions/0.0.11/skills/designing-agents/SKILL.md +1 -1
  51. package/.versions/0.0.11/skills/designing-agents/pi-harness-authoring.md +1 -1
  52. package/.versions/1.0.0/.pi/agents/dispatch-policy.yaml +32 -0
  53. package/.versions/1.0.0/.pi/agents/model-profiles.yaml +27 -0
  54. package/.versions/1.0.0/.pi/agents/peers.yaml +142 -0
  55. package/.versions/1.0.0/.pi/agents/teams.yaml +41 -0
  56. package/.versions/1.0.0/.pi/damage-control-rules.yaml +297 -0
  57. package/.versions/1.0.0/.pi/extensions/agent-fleet-update-check/README.md +57 -0
  58. package/.versions/1.0.0/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
  59. package/.versions/1.0.0/.pi/extensions/agent-fleet-update-check/package.json +6 -0
  60. package/.versions/1.0.0/.pi/extensions/btw/README.md +120 -0
  61. package/.versions/1.0.0/.pi/extensions/btw/index.ts +914 -0
  62. package/.versions/1.0.0/.pi/extensions/btw/package.json +6 -0
  63. package/.versions/1.0.0/.pi/extensions/btw/state.js +179 -0
  64. package/.versions/1.0.0/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
  65. package/.versions/1.0.0/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
  66. package/.versions/1.0.0/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  67. package/.versions/1.0.0/.pi/extensions/compact-and-continue/README.md +42 -0
  68. package/.versions/1.0.0/.pi/extensions/compact-and-continue/index.ts +120 -0
  69. package/.versions/1.0.0/.pi/extensions/compact-and-continue/package.json +6 -0
  70. package/.versions/1.0.0/.pi/extensions/mcp-bridge/README.md +46 -0
  71. package/.versions/1.0.0/.pi/extensions/mcp-bridge/index.ts +206 -0
  72. package/.versions/1.0.0/.pi/extensions/mcp-bridge/package.json +6 -0
  73. package/.versions/1.0.0/.pi/extensions/package-lock.json +1143 -0
  74. package/.versions/1.0.0/.pi/extensions/package.json +9 -0
  75. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/README.md +205 -0
  76. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/config.ts +198 -0
  77. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  78. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/index.ts +248 -0
  79. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/package.json +6 -0
  80. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  81. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  82. package/.versions/1.0.0/.pi/harnesses/agent-hub/README.md +1056 -0
  83. package/.versions/1.0.0/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  84. package/.versions/1.0.0/.pi/harnesses/agent-hub/artifacts.js +146 -0
  85. package/.versions/1.0.0/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
  86. package/.versions/1.0.0/.pi/harnesses/agent-hub/backend-policy.js +174 -0
  87. package/.versions/1.0.0/.pi/harnesses/agent-hub/context-window.js +106 -0
  88. package/.versions/1.0.0/.pi/harnesses/agent-hub/delegate.ts +435 -0
  89. package/.versions/1.0.0/.pi/harnesses/agent-hub/docs-lane.js +122 -0
  90. package/.versions/1.0.0/.pi/harnesses/agent-hub/drift-watchdog.js +211 -0
  91. package/.versions/1.0.0/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  92. package/.versions/1.0.0/.pi/harnesses/agent-hub/external-blocker.js +85 -0
  93. package/.versions/1.0.0/.pi/harnesses/agent-hub/footer.ts +35 -0
  94. package/.versions/1.0.0/.pi/harnesses/agent-hub/helpers.ts +266 -0
  95. package/.versions/1.0.0/.pi/harnesses/agent-hub/index.ts +9279 -0
  96. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  97. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
  98. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
  99. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  100. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  101. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  102. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  103. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
  104. package/.versions/1.0.0/.pi/harnesses/agent-hub/package.json +7 -0
  105. package/.versions/1.0.0/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
  106. package/.versions/1.0.0/.pi/harnesses/agent-hub/posture.ts +103 -0
  107. package/.versions/1.0.0/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
  108. package/.versions/1.0.0/.pi/harnesses/agent-hub/research-retention.js +34 -0
  109. package/.versions/1.0.0/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  110. package/.versions/1.0.0/.pi/harnesses/agent-hub/return-contract.js +293 -0
  111. package/.versions/1.0.0/.pi/harnesses/agent-hub/return-extract.js +75 -0
  112. package/.versions/1.0.0/.pi/harnesses/agent-hub/review-findings.js +102 -0
  113. package/.versions/1.0.0/.pi/harnesses/agent-hub/run-budget.js +479 -0
  114. package/.versions/1.0.0/.pi/harnesses/agent-hub/run-namespace.js +87 -0
  115. package/.versions/1.0.0/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  116. package/.versions/1.0.0/.pi/harnesses/agent-hub/scope-gate.js +103 -0
  117. package/.versions/1.0.0/.pi/harnesses/agent-hub/session-health.js +110 -0
  118. package/.versions/1.0.0/.pi/harnesses/agent-hub/spawn.ts +354 -0
  119. package/.versions/1.0.0/.pi/harnesses/agent-hub/version.ts +42 -0
  120. package/.versions/1.0.0/.pi/harnesses/ask-user-remote/README.md +53 -0
  121. package/.versions/1.0.0/.pi/harnesses/ask-user-remote/index.ts +477 -0
  122. package/.versions/1.0.0/.pi/harnesses/ask-user-remote/race-core.js +106 -0
  123. package/.versions/1.0.0/.pi/harnesses/coms/README.md +100 -0
  124. package/.versions/1.0.0/.pi/harnesses/coms/index.ts +1767 -0
  125. package/.versions/1.0.0/.pi/harnesses/coms/package.json +7 -0
  126. package/.versions/1.0.0/.pi/harnesses/coms/version.ts +42 -0
  127. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/README.md +124 -0
  128. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/index.ts +536 -0
  129. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/package.json +7 -0
  130. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/version.ts +42 -0
  131. package/.versions/1.0.0/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
  132. package/.versions/1.0.0/.pi/harnesses/lib/damage-control-shared.ts +197 -0
  133. package/.versions/1.0.0/.pi/harnesses/lib/fleet-dashboard-ops.ts +118 -0
  134. package/.versions/1.0.0/.pi/harnesses/lib/fleet-dashboard-view.ts +140 -0
  135. package/.versions/1.0.0/.pi/harnesses/lib/fleet-detail-view.ts +43 -0
  136. package/.versions/1.0.0/.pi/harnesses/lib/fleet-overlay.ts +26 -0
  137. package/.versions/1.0.0/.pi/harnesses/lib/fleet-panel.ts +34 -0
  138. package/.versions/1.0.0/.pi/harnesses/lib/fleet-read-model.ts +131 -0
  139. package/.versions/1.0.0/.pi/harnesses/lib/fleet-selection.ts +24 -0
  140. package/.versions/1.0.0/.pi/harnesses/lib/herdr-client.ts +472 -0
  141. package/.versions/1.0.0/.pi/harnesses/lib/herdr-presence.ts +399 -0
  142. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
  143. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
  144. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
  145. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
  146. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
  147. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
  148. package/.versions/1.0.0/.pi/harnesses/lib/spawned-peers.js +190 -0
  149. package/.versions/1.0.0/.pi/harnesses/package-lock.json +2046 -0
  150. package/.versions/1.0.0/.pi/harnesses/package.json +10 -0
  151. package/.versions/1.0.0/.pi/prompts/af-build.md +24 -0
  152. package/{.claude/commands/code-simplify.md → .versions/1.0.0/.pi/prompts/af-code-simplify.md} +3 -3
  153. package/{.claude/commands/plan.md → .versions/1.0.0/.pi/prompts/af-plan.md} +1 -1
  154. package/.versions/{0.0.11/.claude/commands/review.md → 1.0.0/.pi/prompts/af-review.md} +3 -3
  155. package/.versions/1.0.0/.pi/prompts/af-set-hermes-watchdog.md +6 -0
  156. package/.versions/1.0.0/.pi/prompts/af-ship.md +17 -0
  157. package/.versions/{0.0.11/.claude/commands/spec.md → 1.0.0/.pi/prompts/af-spec.md} +1 -1
  158. package/.versions/{0.0.11/.claude/commands/test.md → 1.0.0/.pi/prompts/af-test.md} +2 -2
  159. package/.versions/1.0.0/.pi/skills/bowser/SKILL.md +145 -0
  160. package/.versions/1.0.0/.version +1 -0
  161. package/.versions/1.0.0/agents/architect.md +24 -0
  162. package/.versions/1.0.0/agents/bowser.md +27 -0
  163. package/.versions/1.0.0/agents/builder.md +54 -0
  164. package/.versions/1.0.0/agents/code-reviewer.md +208 -0
  165. package/.versions/1.0.0/agents/deep-researcher.md +32 -0
  166. package/.versions/1.0.0/agents/documenter.md +18 -0
  167. package/.versions/1.0.0/agents/orchestrator.md +72 -0
  168. package/.versions/1.0.0/agents/plan-reviewer.md +83 -0
  169. package/.versions/1.0.0/agents/planner.md +70 -0
  170. package/.versions/1.0.0/agents/releaser.md +24 -0
  171. package/.versions/1.0.0/agents/researcher.md +28 -0
  172. package/.versions/1.0.0/agents/security-auditor.md +167 -0
  173. package/.versions/1.0.0/agents/test-engineer.md +153 -0
  174. package/.versions/1.0.0/agents/web-debugger.md +43 -0
  175. package/.versions/1.0.0/agents/web-performance-auditor.md +193 -0
  176. package/.versions/1.0.0/codex/CONDUCTOR.md +148 -0
  177. package/.versions/1.0.0/docs/ARCHITECTURE.md +337 -0
  178. package/.versions/1.0.0/docs/agent-fleet-setup.md +437 -0
  179. package/.versions/1.0.0/docs/claude-code-coms-bridge.md +128 -0
  180. package/.versions/1.0.0/docs/codex-remote-conductor.md +170 -0
  181. package/.versions/1.0.0/docs/coms-hermes-bridge.md +189 -0
  182. package/.versions/1.0.0/docs/getting-started.md +98 -0
  183. package/.versions/1.0.0/docs/npm-install.md +292 -0
  184. package/.versions/1.0.0/docs/pi-extensions.md +412 -0
  185. package/.versions/1.0.0/docs/pi-setup.md +74 -0
  186. package/.versions/1.0.0/docs/skill-anatomy.md +150 -0
  187. package/.versions/1.0.0/hermes/README.md +347 -0
  188. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
  189. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
  190. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  191. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  192. package/.versions/1.0.0/hermes/gates/gate-o-capability.md +8 -0
  193. package/.versions/1.0.0/hermes/gates/gate-o-validator-fixtures.json +1 -0
  194. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
  195. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
  196. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
  197. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
  198. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
  199. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
  200. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
  201. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
  202. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
  203. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
  204. package/.versions/1.0.0/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
  205. package/.versions/1.0.0/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  206. package/.versions/1.0.0/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  207. package/.versions/1.0.0/hermes/skills/hub-conductor/SKILL.md +84 -0
  208. package/.versions/1.0.0/hermes/skills/hub-liaison/SKILL.md +84 -0
  209. package/.versions/1.0.0/hermes/skills/hub-watchdog/SKILL.md +76 -0
  210. package/.versions/1.0.0/hermes/skills/hub-watchdog/manifest.json +1 -0
  211. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
  212. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
  213. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
  214. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
  215. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
  216. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
  217. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
  218. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
  219. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
  220. package/.versions/1.0.0/hermes/watchdog-tests/__init__.py +0 -0
  221. package/.versions/1.0.0/hooks/coms-stop-hook.mjs +84 -0
  222. package/.versions/1.0.0/install-manifest.json +2745 -0
  223. package/.versions/1.0.0/justfile +272 -0
  224. package/.versions/1.0.0/manifest-meta.json +882 -0
  225. package/.versions/1.0.0/references/accessibility-checklist.md +160 -0
  226. package/.versions/1.0.0/references/definition-of-done.md +67 -0
  227. package/.versions/1.0.0/references/fleet-coordination-patterns.md +151 -0
  228. package/.versions/1.0.0/references/observability-checklist.md +91 -0
  229. package/.versions/1.0.0/references/orchestration-patterns.md +370 -0
  230. package/.versions/1.0.0/references/performance-checklist.md +153 -0
  231. package/.versions/1.0.0/references/prompting-patterns.md +380 -0
  232. package/.versions/1.0.0/references/security-checklist.md +179 -0
  233. package/.versions/1.0.0/references/testing-patterns.md +236 -0
  234. package/.versions/1.0.0/scripts/codex-conductor.ts +41 -0
  235. package/.versions/1.0.0/scripts/codex-remote-control.ts +167 -0
  236. package/.versions/1.0.0/scripts/coms-claude-bridge.ts +411 -0
  237. package/.versions/1.0.0/scripts/coms-cli.ts +484 -0
  238. package/.versions/1.0.0/scripts/coms-hermes-bridge.ts +413 -0
  239. package/.versions/1.0.0/scripts/fleet.ts +185 -0
  240. package/.versions/1.0.0/scripts/hermes-monitor-capability-runner.ts +25 -0
  241. package/.versions/1.0.0/scripts/hermes-monitor-scenario.ts +474 -0
  242. package/.versions/1.0.0/scripts/hermes-watchdog-capability-probe.ts +45 -0
  243. package/.versions/1.0.0/scripts/install-hermes-plugin.sh +180 -0
  244. package/.versions/1.0.0/scripts/lib/claude-bridge-core.ts +210 -0
  245. package/.versions/1.0.0/scripts/lib/codex-conductor.ts +88 -0
  246. package/.versions/1.0.0/scripts/lib/codex-remote-control.ts +480 -0
  247. package/.versions/1.0.0/scripts/lib/coms-envelope.ts +582 -0
  248. package/.versions/1.0.0/scripts/lib/fake-herdr-server.ts +88 -0
  249. package/.versions/1.0.0/scripts/lib/fleet-command.ts +266 -0
  250. package/.versions/1.0.0/scripts/lib/herdr-layout.ts +281 -0
  251. package/.versions/1.0.0/scripts/lib/hermes-bridge-core.ts +241 -0
  252. package/.versions/1.0.0/scripts/lib/hermes-monitor-events.ts +1 -0
  253. package/.versions/1.0.0/scripts/lib/hermes-monitor-herdr.ts +2 -0
  254. package/.versions/1.0.0/scripts/lib/hermes-monitor-model.ts +3 -0
  255. package/.versions/1.0.0/scripts/lib/hermes-monitor-registry.ts +2 -0
  256. package/.versions/1.0.0/scripts/lib/hermes-monitor-socket.ts +2 -0
  257. package/.versions/1.0.0/scripts/lib/hermes-monitor-store.ts +2 -0
  258. package/.versions/1.0.0/scripts/lib/monitor-env.ts +146 -0
  259. package/.versions/1.0.0/scripts/lib/peer-launch.ts +318 -0
  260. package/.versions/1.0.0/scripts/lib/persona-banner.ts +62 -0
  261. package/.versions/1.0.0/scripts/lib/spawn-stagger.ts +101 -0
  262. package/.versions/1.0.0/scripts/lib/team-project.ts +213 -0
  263. package/.versions/1.0.0/scripts/lib/team-snapshot.ts +147 -0
  264. package/.versions/1.0.0/scripts/peer-banner.ts +40 -0
  265. package/.versions/1.0.0/scripts/peer-launch.ts +259 -0
  266. package/.versions/1.0.0/scripts/team-snapshot.ts +237 -0
  267. package/.versions/1.0.0/scripts/team-up.ts +406 -0
  268. package/.versions/1.0.0/skills/_internal/grilling.md +11 -0
  269. package/.versions/1.0.0/skills/browser-testing-with-devtools/SKILL.md +351 -0
  270. package/.versions/1.0.0/skills/code-review-and-quality/SKILL.md +381 -0
  271. package/.versions/1.0.0/skills/compound-learning/SKILL.md +137 -0
  272. package/.versions/1.0.0/skills/context-engineering/SKILL.md +291 -0
  273. package/.versions/1.0.0/skills/deprecation-and-migration/SKILL.md +206 -0
  274. package/.versions/1.0.0/skills/designing-agents/SKILL.md +394 -0
  275. package/.versions/1.0.0/skills/designing-agents/pi-harness-authoring.md +222 -0
  276. package/.versions/1.0.0/skills/frontend-ui-engineering/SKILL.md +328 -0
  277. package/.versions/1.0.0/skills/git-workflow-and-versioning/SKILL.md +316 -0
  278. package/.versions/1.0.0/skills/idea-refine/SKILL.md +182 -0
  279. package/.versions/1.0.0/skills/idea-refine/examples.md +238 -0
  280. package/.versions/1.0.0/skills/idea-refine/frameworks.md +99 -0
  281. package/.versions/1.0.0/skills/idea-refine/refinement-criteria.md +113 -0
  282. package/.versions/1.0.0/skills/idea-refine/scripts/idea-refine.sh +15 -0
  283. package/.versions/1.0.0/skills/incremental-implementation/SKILL.md +287 -0
  284. package/.versions/1.0.0/skills/interview-me/SKILL.md +226 -0
  285. package/.versions/1.0.0/skills/orchestration-verification/SKILL.md +181 -0
  286. package/.versions/1.0.0/skills/peer-coms/SKILL.md +90 -0
  287. package/.versions/1.0.0/skills/performance-optimization/SKILL.md +350 -0
  288. package/.versions/1.0.0/skills/planning-and-task-breakdown/SKILL.md +254 -0
  289. package/.versions/1.0.0/skills/security-and-hardening/SKILL.md +461 -0
  290. package/.versions/1.0.0/skills/spec-driven-development/SKILL.md +257 -0
  291. package/.versions/1.0.0/skills/using-agent-skills/SKILL.md +199 -0
  292. package/.versions/1.0.0/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
  293. package/.versions/1.0.0/vendor/agent-skills-upstream/LICENSE +21 -0
  294. package/.versions/1.0.0/vendor/agent-skills-upstream/README.md +11 -0
  295. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
  296. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  297. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  298. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  299. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  300. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
  301. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  302. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  303. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
  304. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  305. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  306. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  307. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  308. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  309. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  310. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  311. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  312. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  313. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  314. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
  315. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
  316. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
  317. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
  318. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
  319. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
  320. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
  321. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
  322. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
  323. package/CHANGELOG.md +142 -0
  324. package/README.md +117 -79
  325. package/agents/orchestrator.md +1 -1
  326. package/bin/cli.js +289 -359
  327. package/bin/force-patch-changesets.js +18 -2
  328. package/bin/lib/apply.js +86 -32
  329. package/bin/lib/desired.js +87 -0
  330. package/bin/lib/detect-agent.js +22 -38
  331. package/bin/lib/doctor.js +283 -33
  332. package/bin/lib/features.js +78 -0
  333. package/bin/lib/manifest.js +127 -48
  334. package/bin/lib/overrides.js +35 -0
  335. package/bin/lib/personas.js +37 -0
  336. package/bin/lib/plan.js +18 -9
  337. package/bin/lib/purge.js +11 -0
  338. package/bin/lib/reconcile.js +68 -0
  339. package/bin/lib/scan.js +24 -0
  340. package/bin/lib/state.js +25 -1
  341. package/bin/lib/stt-wizard.js +33 -0
  342. package/bin/lib/transaction.js +149 -0
  343. package/bin/lib/tui.js +71 -0
  344. package/bin/lib/verify.js +9 -26
  345. package/bin/snapshot-version.js +3 -6
  346. package/docs/ARCHITECTURE.md +55 -21
  347. package/docs/MIGRATION-agent-fleet.md +222 -0
  348. package/docs/agent-fleet-setup.md +124 -64
  349. package/docs/claude-code-coms-bridge.md +21 -2
  350. package/docs/coms-hermes-bridge.md +1 -1
  351. package/docs/getting-started.md +61 -217
  352. package/docs/npm-install.md +207 -429
  353. package/docs/pi-extensions.md +85 -41
  354. package/docs/pi-setup.md +48 -545
  355. package/hermes/README.md +1 -1
  356. package/install-manifest.json +385 -1255
  357. package/justfile +45 -27
  358. package/manifest-meta.json +544 -134
  359. package/node_modules/pi-ask-user/README.md +43 -5
  360. package/node_modules/pi-ask-user/index.ts +630 -75
  361. package/node_modules/pi-ask-user/package.json +1 -1
  362. package/package.json +5 -11
  363. package/scripts/coms-claude-bridge.ts +10 -0
  364. package/scripts/fleet.ts +107 -90
  365. package/scripts/lib/claude-bridge-core.ts +45 -0
  366. package/scripts/lib/fleet-command.ts +170 -15
  367. package/scripts/lib/monitor-env.ts +18 -6
  368. package/scripts/lib/peer-launch.ts +6 -2
  369. package/scripts/lib/team-project.ts +24 -4
  370. package/scripts/team-up.ts +57 -11
  371. package/skills/designing-agents/SKILL.md +1 -1
  372. package/skills/designing-agents/pi-harness-authoring.md +3 -3
  373. package/.claude/commands/build.md +0 -44
  374. package/.claude/commands/design-agent.md +0 -14
  375. package/.claude/commands/doctor-agent-fleet.md +0 -22
  376. package/.claude/commands/orchestrate.md +0 -112
  377. package/.claude/commands/prime.md +0 -22
  378. package/.claude/commands/review.md +0 -16
  379. package/.claude/commands/set-hermes-telegram.md +0 -15
  380. package/.claude/commands/set-hermes-watchdog.md +0 -6
  381. package/.claude/commands/setup-agent-fleet.md +0 -17
  382. package/.claude/commands/ship.md +0 -72
  383. package/.claude/commands/spec.md +0 -15
  384. package/.claude/commands/test.md +0 -19
  385. package/.claude/commands/webperf.md +0 -32
  386. package/.claude/orchestrate-teams.yaml +0 -24
  387. package/.opencode/commands/af-build.md +0 -17
  388. package/.opencode/commands/af-code-simplify.md +0 -16
  389. package/.opencode/commands/af-compound.md +0 -16
  390. package/.opencode/commands/af-design-agent.md +0 -15
  391. package/.opencode/commands/af-doctor-agent-fleet.md +0 -22
  392. package/.opencode/commands/af-orchestrate.md +0 -112
  393. package/.opencode/commands/af-plan.md +0 -16
  394. package/.opencode/commands/af-prime.md +0 -22
  395. package/.opencode/commands/af-review.md +0 -15
  396. package/.opencode/commands/af-set-hermes-watchdog.md +0 -6
  397. package/.opencode/commands/af-setup-agent-fleet.md +0 -17
  398. package/.opencode/commands/af-ship.md +0 -16
  399. package/.opencode/commands/af-spec.md +0 -16
  400. package/.opencode/commands/af-test.md +0 -21
  401. package/.opencode/commands/af-webperf.md +0 -32
  402. package/.opencode/orchestrate-teams.yaml +0 -24
  403. package/.pi/prompts/af-doctor-agent-fleet.md +0 -22
  404. package/.pi/prompts/af-setup-agent-fleet.md +0 -19
  405. package/.versions/0.0.1/.opencode/commands/af-doctor-agent-fleet.md +0 -15
  406. package/.versions/0.0.1/.opencode/commands/af-setup-agent-fleet.md +0 -15
  407. package/.versions/0.0.1/skills/guided-workspace-setup/SKILL.md +0 -506
  408. package/.versions/0.0.10/.opencode/commands/af-doctor-agent-fleet.md +0 -22
  409. package/.versions/0.0.10/.opencode/commands/af-setup-agent-fleet.md +0 -17
  410. package/.versions/0.0.10/.pi/prompts/af-doctor-agent-fleet.md +0 -22
  411. package/.versions/0.0.10/.pi/prompts/af-setup-agent-fleet.md +0 -19
  412. package/.versions/0.0.10/skills/guided-workspace-setup/SKILL.md +0 -226
  413. package/.versions/0.0.11/.claude/commands/build.md +0 -44
  414. package/.versions/0.0.11/.claude/commands/code-simplify.md +0 -22
  415. package/.versions/0.0.11/.claude/commands/design-agent.md +0 -14
  416. package/.versions/0.0.11/.claude/commands/doctor-agent-fleet.md +0 -22
  417. package/.versions/0.0.11/.claude/commands/orchestrate.md +0 -112
  418. package/.versions/0.0.11/.claude/commands/plan.md +0 -16
  419. package/.versions/0.0.11/.claude/commands/prime.md +0 -22
  420. package/.versions/0.0.11/.claude/commands/set-hermes-telegram.md +0 -15
  421. package/.versions/0.0.11/.claude/commands/set-hermes-watchdog.md +0 -6
  422. package/.versions/0.0.11/.claude/commands/setup-agent-fleet.md +0 -17
  423. package/.versions/0.0.11/.claude/commands/ship.md +0 -72
  424. package/.versions/0.0.11/.claude/commands/webperf.md +0 -32
  425. package/.versions/0.0.11/.claude/orchestrate-teams.yaml +0 -24
  426. package/.versions/0.0.11/.opencode/commands/af-build.md +0 -17
  427. package/.versions/0.0.11/.opencode/commands/af-code-simplify.md +0 -16
  428. package/.versions/0.0.11/.opencode/commands/af-compound.md +0 -16
  429. package/.versions/0.0.11/.opencode/commands/af-design-agent.md +0 -15
  430. package/.versions/0.0.11/.opencode/commands/af-doctor-agent-fleet.md +0 -22
  431. package/.versions/0.0.11/.opencode/commands/af-orchestrate.md +0 -112
  432. package/.versions/0.0.11/.opencode/commands/af-plan.md +0 -16
  433. package/.versions/0.0.11/.opencode/commands/af-prime.md +0 -22
  434. package/.versions/0.0.11/.opencode/commands/af-review.md +0 -15
  435. package/.versions/0.0.11/.opencode/commands/af-set-hermes-telegram.md +0 -15
  436. package/.versions/0.0.11/.opencode/commands/af-set-hermes-watchdog.md +0 -6
  437. package/.versions/0.0.11/.opencode/commands/af-setup-agent-fleet.md +0 -17
  438. package/.versions/0.0.11/.opencode/commands/af-ship.md +0 -16
  439. package/.versions/0.0.11/.opencode/commands/af-spec.md +0 -16
  440. package/.versions/0.0.11/.opencode/commands/af-test.md +0 -21
  441. package/.versions/0.0.11/.opencode/commands/af-webperf.md +0 -32
  442. package/.versions/0.0.11/.opencode/orchestrate-teams.yaml +0 -24
  443. package/.versions/0.0.11/.pi/prompts/af-doctor-agent-fleet.md +0 -22
  444. package/.versions/0.0.11/.pi/prompts/af-setup-agent-fleet.md +0 -19
  445. package/.versions/0.0.11/docs/opencode-setup.md +0 -281
  446. package/.versions/0.0.11/hooks/SIMPLIFY-IGNORE.md +0 -90
  447. package/.versions/0.0.11/hooks/hooks.json +0 -14
  448. package/.versions/0.0.11/hooks/session-start.sh +0 -74
  449. package/.versions/0.0.11/hooks/simplify-ignore.sh +0 -302
  450. package/.versions/0.0.11/skills/guided-workspace-setup/SKILL.md +0 -226
  451. package/.versions/0.0.4/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  452. package/.versions/0.0.4/.opencode/commands/af-setup-agent-fleet.md +0 -15
  453. package/.versions/0.0.4/skills/guided-workspace-setup/SKILL.md +0 -535
  454. package/.versions/0.0.4/skills/guided-workspace-setup/companion-manifest.json +0 -33
  455. package/.versions/0.0.5/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  456. package/.versions/0.0.5/.opencode/commands/af-setup-agent-fleet.md +0 -15
  457. package/.versions/0.0.5/skills/guided-workspace-setup/SKILL.md +0 -542
  458. package/.versions/0.0.5/skills/guided-workspace-setup/companion-manifest.json +0 -35
  459. package/.versions/0.0.6/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  460. package/.versions/0.0.6/.opencode/commands/af-setup-agent-fleet.md +0 -15
  461. package/.versions/0.0.6/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  462. package/.versions/0.0.6/.pi/prompts/af-setup-agent-fleet.md +0 -27
  463. package/.versions/0.0.6/skills/guided-workspace-setup/SKILL.md +0 -544
  464. package/.versions/0.0.6/skills/guided-workspace-setup/companion-manifest.json +0 -35
  465. package/.versions/0.0.7/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  466. package/.versions/0.0.7/.opencode/commands/af-setup-agent-fleet.md +0 -15
  467. package/.versions/0.0.7/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  468. package/.versions/0.0.7/.pi/prompts/af-setup-agent-fleet.md +0 -27
  469. package/.versions/0.0.7/skills/guided-workspace-setup/SKILL.md +0 -544
  470. package/.versions/0.0.7/skills/guided-workspace-setup/companion-manifest.json +0 -35
  471. package/.versions/0.0.8/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  472. package/.versions/0.0.8/.opencode/commands/af-setup-agent-fleet.md +0 -15
  473. package/.versions/0.0.8/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  474. package/.versions/0.0.8/.pi/prompts/af-setup-agent-fleet.md +0 -27
  475. package/.versions/0.0.8/skills/guided-workspace-setup/SKILL.md +0 -544
  476. package/.versions/0.0.8/skills/guided-workspace-setup/companion-manifest.json +0 -36
  477. package/.versions/0.0.9/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  478. package/.versions/0.0.9/.opencode/commands/af-setup-agent-fleet.md +0 -15
  479. package/.versions/0.0.9/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  480. package/.versions/0.0.9/.pi/prompts/af-setup-agent-fleet.md +0 -27
  481. package/.versions/0.0.9/skills/guided-workspace-setup/SKILL.md +0 -544
  482. package/bin/lib/bootstrap.js +0 -323
  483. package/bin/lib/transform-persona.js +0 -180
  484. package/docs/opencode-setup.md +0 -281
  485. package/hooks/SIMPLIFY-IGNORE.md +0 -90
  486. package/hooks/hooks.json +0 -14
  487. package/hooks/session-start.sh +0 -74
  488. package/hooks/simplify-ignore.sh +0 -302
  489. package/skills/guided-workspace-setup/SKILL.md +0 -226
  490. /package/.versions/0.0.10/{skills/guided-workspace-setup/companion-manifest.json → bin/catalog/harness-runtime-closure.json} +0 -0
  491. /package/.versions/0.0.11/{skills/guided-workspace-setup/companion-manifest.json → bin/catalog/harness-runtime-closure.json} +0 -0
  492. /package/{.opencode/commands → .versions/1.0.0/.pi/prompts}/af-set-hermes-telegram.md +0 -0
  493. /package/.versions/{0.0.9/skills/guided-workspace-setup/companion-manifest.json → 1.0.0/bin/catalog/harness-runtime-closure.json} +0 -0
  494. /package/{skills/guided-workspace-setup/companion-manifest.json → bin/catalog/harness-runtime-closure.json} +0 -0
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * Commands:
17
17
  * /af-agents-team — switch active team
18
- * /af-agents-list — list loaded agents
18
+ * /af-agents-list — open the Fleet Dashboard
19
19
  * /af-agents-history — timeline of agent execution (durations + grand total)
20
20
  * /af-agent-model <persona>[.<role>] — switch a team or research persona's (or
21
21
  * delegate sub-role's) model from its declared candidates
@@ -72,7 +72,7 @@ import {
72
72
  import { spawn, type ChildProcess } from "child_process";
73
73
  import { spawnPiAgent, spawnPiAgentWithModelFallback, killPiTree, type PiRunControl, type SpawnPiAgentCallbacks, type SpawnPiAgentOptions, type Termination } from "./spawn.ts";
74
74
  import { researchTerminationOutcome, researchWatchdogSpawnOptions } from "./research-watchdog.ts";
75
- import { renderHubFooterLeft } from "./footer.ts";
75
+ import { composeFleetFooterHint, renderHubFooterLeft } from "./footer.ts";
76
76
  import { HARNESS_VERSION, registerVersionStatus } from "./version.ts";
77
77
  import { cancelLocalOwnedProcess, cancelLocalWaitOnly, monitorKeyForAgent } from "./monitor-control.ts";
78
78
  import { createMonitorLifecycle, monitorLifecycleConfig } from "./monitor-lifecycle.ts";
@@ -88,7 +88,7 @@ import {
88
88
  AGENT_ID_ENV, ASK_ENDPOINT_ENV, EXEMPTIONS_FILE_ENV,
89
89
  exemptionsFilePath, type AccessRequest,
90
90
  } from "../lib/damage-control-shared.ts";
91
- import { applyModelOverride, clampDelegateDepth, DELEGATE_TREE_SPAWN_BUDGET, fallbackModelFor, isReadOnlyToolList, MAX_DELEGATE_DEPTH, normalizeAgentInput, parseTeamsYaml, safeAgentKey, safePathWithin, taskFingerprint, upsertTeamInYaml } from "./helpers.ts";
91
+ import { applyModelOverride, clampDelegateDepth, DELEGATE_TREE_SPAWN_BUDGET, fallbackModelFor, isReadOnlyToolList, MAX_DELEGATE_DEPTH, normalizeAgentInput, orchestratorNeedsRoster, parseTeamsYaml, resolveStartupRoster, safeAgentKey, safePathWithin, taskFingerprint, upsertTeamInYaml } from "./helpers.ts";
92
92
  import { DEFAULT_HUB_MODE, DEFAULT_TASK_TIER, HUB_MODES, TASK_BUDGET_MULTIPLIER, applyTierChange, blockingFindingCap, budgetStatusLine, checkReviewRoundCap, checkTaskBudget, checkTierPersonaGate, checkTurnBudget, contextOverflowDiagnostic, isReviewPersona, normalizeHubMode, remainingTaskResearch, resolveTaskBudget, resolveTurnBudget, reviewBudgetClause, reviewRoundCap, shouldRecycleSession, turnActiveMs } from "./run-budget.js";
93
93
  import { countReviewFindings, findingBudgetNotice } from "./review-findings.js";
94
94
  import { checkDocsLane, docsLaneNotice } from "./docs-lane.js";
@@ -113,7 +113,9 @@ import { artifactPreviewFromText, formatInputArtifactsSection, resolveArtifactPa
113
113
  import { crossCheck, deliveryDisposition, extractAssertionIds, parseDeliveredReturn, parseStructuredReturn } from "./return-contract.js";
114
114
  import { checkScope, diffAgainst, snapshotWorktree } from "./scope-gate.js";
115
115
  import { validateEvidence } from "./evidence-rules.js";
116
- import { comsRequiredRefusal, parseDispatchPolicy, resolveDispatchBackend } from "./backend-policy.js";
116
+ import { comsRequiredRefusal, explicitComsRefusal, parseDispatchPolicy, resolveDispatchBackend } from "./backend-policy.js";
117
+ import { parsePosture, posturePrompt, resolvePostureTools, resolveSessionPosture, type Posture } from "./posture.ts";
118
+ import { buildHubPeerSpawnPlan, launchHubPeerInPane } from "./peer-spawn-plan.ts";
117
119
  import { DEFAULT_RESEARCH_KEEP, parseResearchKeep, selectResearchPrunable } from "./research-retention.js";
118
120
  import { requireSafetyHarness, resolveSafetyHarness } from "./safety-routing.ts";
119
121
  import { createAccessApprovalRouter } from "./access-approval.ts";
@@ -128,8 +130,15 @@ import {
128
130
  } from "../lib/herdr-presence.ts";
129
131
  import { herdr as herdrApi, herdrAvailable } from "../lib/herdr-client.ts";
130
132
  import { buildLiveRegistryEntry, type ComsRegistryEntry } from "../lib/coms-registry-entry.ts";
131
- import { findPeerByName, parseEnvFile, parsePeersYaml, peerCommand, resolveEnvFilePath } from "../../../scripts/lib/herdr-layout.ts";
132
- import { DEFAULT_PROJECT } from "../../../scripts/lib/team-project.ts";
133
+ import { FULLSCREEN_OVERLAY, bodyRows, clampScroll, fitToHeight } from "../lib/fleet-overlay.ts";
134
+ import { createPanelResources } from "../lib/fleet-panel.ts";
135
+ import { buildFleetRows, fleetTiming, summarise, unionMs, type DelegateInput, type FleetRow, type FleetSource, type PeerInput, type ResearchInput, type SpecialistInput } from "../lib/fleet-read-model.ts";
136
+ import { attachFleetDashboardTicker, compactWidgetsEnabled, liveTimeline, resolveFleetKill, resolveFleetRestart } from "../lib/fleet-dashboard-ops.ts";
137
+ import { dashboardTransition, renderFleetDashboard, FLEET_CHROME_ROWS, type DashboardConfirm } from "../lib/fleet-dashboard-view.ts";
138
+ import { detailContent, detailTransition, renderFleetDetail, DETAIL_CHROME_ROWS } from "../lib/fleet-detail-view.ts";
139
+ import { reconcileSelection, type Selection } from "../lib/fleet-selection.ts";
140
+ import { parseEnvFile, resolveEnvFilePath } from "../../../scripts/lib/herdr-layout.ts";
141
+ import { worktreeTag } from "../../../scripts/lib/team-project.ts";
133
142
  import { STAGGER_ENV_VAR, WARMUP_SECONDS, oauthNeedsWarmup } from "../../../scripts/lib/spawn-stagger.ts";
134
143
  import { join, resolve } from "path";
135
144
  import * as net from "node:net";
@@ -296,6 +305,7 @@ interface ResearchState {
296
305
  killedByOperator?: boolean;
297
306
  timeline: TimelineEntry[];
298
307
  zoomRender?: (force?: boolean) => void;
308
+ histEntry?: HistoryEntry;
299
309
  }
300
310
 
301
311
  // The subset of state `/af-zoom` needs. Both AgentState (standing team) and ResearchState
@@ -338,30 +348,6 @@ function fmtDuration(ms: number): string {
338
348
  return `${m}:${String(s).padStart(2, "0")}min`;
339
349
  }
340
350
 
341
- // Total covered length of a set of (possibly overlapping) time intervals — the
342
- // wall-clock during which AT LEAST ONE interval was active. Used to subtract the
343
- // time a node spent awaiting children: a parent's "real work" is its own span
344
- // minus the union of its children's runs (so parallel awaits aren't counted twice,
345
- // and a dispatcher blocked on six concurrent agents is credited once, not six times).
346
- function unionMs(intervals: Array<[number, number]>): number {
347
- if (intervals.length === 0) return 0;
348
- const sorted = intervals.slice().sort((a, b) => a[0] - b[0]);
349
- let total = 0;
350
- let curStart = sorted[0][0];
351
- let curEnd = sorted[0][1];
352
- for (let i = 1; i < sorted.length; i++) {
353
- const [s, e] = sorted[i];
354
- if (s > curEnd) {
355
- total += curEnd - curStart;
356
- curStart = s;
357
- curEnd = e;
358
- } else if (e > curEnd) {
359
- curEnd = e;
360
- }
361
- }
362
- return total + (curEnd - curStart);
363
- }
364
-
365
351
  // ── Display Name Helper ──────────────────────────
366
352
 
367
353
  function displayName(name: string): string {
@@ -908,6 +894,8 @@ function parseResearchHandle(arg: string): number | null {
908
894
  return m ? parseInt(m[1], 10) : null;
909
895
  }
910
896
 
897
+ const ZOOM_CHROME_ROWS = 5;
898
+
911
899
  class ZoomUI {
912
900
  private selectedIndex = 0;
913
901
  private expandedIndex: number | null = null;
@@ -1003,7 +991,7 @@ class ZoomUI {
1003
991
  if (this.scrollOffset < 0) this.scrollOffset = 0;
1004
992
  }
1005
993
 
1006
- render(width: number, height: number, theme: any): string[] {
994
+ render(width: number, contentHeight: number, theme: any): string[] {
1007
995
  const items = this.state.timeline;
1008
996
  // Live tail-follow: keep the selection pinned to the newest entry as the
1009
997
  // stream grows, until the user scrolls up. Auto-expand each new tail entry
@@ -1037,8 +1025,7 @@ class ZoomUI {
1037
1025
  bottom.addChild(new Text(theme.fg("dim", " ↑/↓ Navigate • Enter Collapse/Expand • Space/Ctrl+C Copy • Q/Esc Close • live"), 1, 0));
1038
1026
  bottom.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
1039
1027
  const bottomLines = bottom.render(width);
1040
-
1041
- const contentHeight = Math.max(3, height - topLines.length - bottomLines.length);
1028
+ const bodyHeight = Math.max(0, contentHeight + ZOOM_CHROME_ROWS - topLines.length - bottomLines.length);
1042
1029
 
1043
1030
  let bodyLines: string[];
1044
1031
  if (items.length === 0) {
@@ -1046,17 +1033,17 @@ class ZoomUI {
1046
1033
  } else {
1047
1034
  const blocks = items.map((item, i) => this.renderItemBlock(item, i, width, theme, mdTheme));
1048
1035
  const heights = blocks.map(b => b.length);
1049
- this.ensureVisible(heights, contentHeight);
1036
+ this.ensureVisible(heights, bodyHeight);
1050
1037
  bodyLines = [];
1051
1038
  for (let i = this.scrollOffset; i < blocks.length; i++) {
1052
1039
  // Always show the first windowed entry (the selected one fits by
1053
1040
  // construction); stop before a later entry would overflow the budget.
1054
- if (bodyLines.length > 0 && bodyLines.length + heights[i] > contentHeight) break;
1041
+ if (bodyLines.length > 0 && bodyLines.length + heights[i] > bodyHeight) break;
1055
1042
  bodyLines.push(...blocks[i]);
1056
1043
  }
1057
1044
  }
1058
1045
 
1059
- return [...topLines, ...bodyLines, ...bottomLines];
1046
+ return fitToHeight([...topLines, ...fitToHeight(bodyLines, bodyHeight), ...bottomLines], contentHeight + ZOOM_CHROME_ROWS);
1060
1047
  }
1061
1048
  }
1062
1049
 
@@ -1066,6 +1053,8 @@ class ZoomUI {
1066
1053
  // connector. Every row shows a live duration; the footer carries the grand total.
1067
1054
  // Shares the zoom overlay's chrome (bordered header/footer, windowed body) and is
1068
1055
  // re-rendered on a 1s tick so running durations advance while it is open.
1056
+ const HISTORY_CHROME_ROWS = 6;
1057
+
1069
1058
  class HistoryUI {
1070
1059
  private scrollOffset = 0;
1071
1060
  private followTail = true;
@@ -1205,7 +1194,7 @@ class HistoryUI {
1205
1194
  return rows;
1206
1195
  }
1207
1196
 
1208
- render(width: number, height: number, theme: any): string[] {
1197
+ render(width: number, contentHeight: number, theme: any): string[] {
1209
1198
  const entries = this.getEntries();
1210
1199
  const now = Date.now();
1211
1200
  const runningCount = entries.filter(e => e.status === "running" && e.kind !== "orchestrator").length;
@@ -1242,20 +1231,20 @@ class HistoryUI {
1242
1231
  bottom.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
1243
1232
  const bottomLines = bottom.render(width);
1244
1233
 
1245
- const contentHeight = Math.max(3, height - topLines.length - bottomLines.length);
1246
1234
  const rows = this.buildRows(childrenOf, width, theme, now);
1235
+ const bodyHeight = Math.max(0, contentHeight + HISTORY_CHROME_ROWS - topLines.length - bottomLines.length);
1247
1236
 
1248
1237
  let bodyLines: string[];
1249
1238
  if (rows.length === 0) {
1250
1239
  bodyLines = [theme.fg("dim", " No dispatches yet — history fills as agents run.")];
1251
1240
  } else {
1252
- const maxOffset = Math.max(0, rows.length - contentHeight);
1241
+ const maxOffset = Math.max(0, rows.length - bodyHeight);
1253
1242
  if (this.followTail) this.scrollOffset = maxOffset;
1254
1243
  this.scrollOffset = Math.max(0, Math.min(this.scrollOffset, maxOffset));
1255
- bodyLines = rows.slice(this.scrollOffset, this.scrollOffset + contentHeight);
1244
+ bodyLines = rows.slice(this.scrollOffset, this.scrollOffset + bodyHeight);
1256
1245
  }
1257
1246
 
1258
- return [...topLines, ...bodyLines, ...bottomLines];
1247
+ return fitToHeight([...topLines, ...fitToHeight(bodyLines, bodyHeight), ...bottomLines], contentHeight + HISTORY_CHROME_ROWS);
1259
1248
  }
1260
1249
  }
1261
1250
 
@@ -1795,6 +1784,8 @@ export default function (pi: ExtensionAPI) {
1795
1784
  pi.registerFlag("color", { description: "Coms: hex color #RRGGBB (else frontmatter or palette fallback)", type: "string", default: undefined });
1796
1785
  pi.registerFlag("explicit", { description: "Coms: hide from auto-discovery; addressable only by exact name", type: "boolean", default: false });
1797
1786
  pi.registerFlag("solo", { description: "Run without the coms layer (fixed specialists + research only — `just fleet hub --solo`)", type: "boolean", default: false });
1787
+ pi.registerFlag("posture", { description: "Fleet main-agent posture: operator|orchestrator", type: "string", default: undefined });
1788
+ pi.registerFlag("agent-team", { description: "Internal: activate a named native roster from .pi/agents/teams.yaml", type: "string", default: undefined });
1798
1789
 
1799
1790
  // ── Embedded coms: peer state ──
1800
1791
  let identity: {
@@ -1979,7 +1970,7 @@ export default function (pi: ExtensionAPI) {
1979
1970
  // editor; "compact" = one line per *running* agent (name · context · state)
1980
1971
  // rendered BELOW the editor, just above the footer. Compact is the default;
1981
1972
  // idle/done agents are hidden so an idle session shows only the prompt + footer.
1982
- let viewMode: "dashboard" | "compact" = "compact";
1973
+ let viewMode: "compact" | "off" = "compact";
1983
1974
  // Compact-view agent switcher: the key of the marked subagent (lowercase persona
1984
1975
  // name for team specialists, `rN` for research helpers — matching /af-zoom
1985
1976
  // resolution), or null when nothing is marked. main is never listed (it is the
@@ -2709,6 +2700,7 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2709
2700
  }
2710
2701
  const adoption = adoptableSessionFile(def);
2711
2702
  agentStates.set(def.name.toLowerCase(), freshAgentState(def, adoption));
2703
+ if (!activeTeamName) activeTeamName = "ad-hoc";
2712
2704
  recomputeGrid();
2713
2705
  updateWidget();
2714
2706
  const quarantineNote = adoption.quarantined
@@ -2726,10 +2718,11 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2726
2718
  if (state.status === "running") {
2727
2719
  return { ok: false, message: `${displayName(state.def.name)} is running — wait for it to finish or /af-agents-kill it first` };
2728
2720
  }
2729
- if (agentStates.size <= 1) {
2730
- return { ok: false, message: `${displayName(state.def.name)} is the last team member — add a replacement before dropping it` };
2721
+ if (orchestratorNeedsRoster(posture, agentStates.size - 1)) {
2722
+ return { ok: false, message: `${displayName(state.def.name)} is the last team member — switch to operator posture or add a replacement before dropping it` };
2731
2723
  }
2732
2724
  agentStates.delete(key);
2725
+ if (agentStates.size === 0) activeTeamName = "";
2733
2726
  recomputeGrid();
2734
2727
  updateWidget();
2735
2728
  // Promise a reusable session file only when pi would actually accept it.
@@ -2912,60 +2905,6 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2912
2905
  // Cap on nested rows per card; beyond it a "+N more" summary line renders.
2913
2906
  const MAX_CHILD_ROWS = 6;
2914
2907
 
2915
- function renderCard(state: AgentState, colWidth: number, theme: any): string[] {
2916
- const w = Math.max(0, colWidth - 2);
2917
- const status = cardStatus(state.status, state.elapsed);
2918
- const headerLine = renderCardHeaderLine(
2919
- displayName(state.def.name),
2920
- state.contextPct,
2921
- // A coms-routed run shows the serving peer's model behind a ⇄coms badge
2922
- // instead of the native persona model it did NOT dispatch with.
2923
- state.lastBackend === "coms" ? `⇄coms ${shortModel(state.comsPeerModel)}` : modelWithThinking(state.def),
2924
- status.text,
2925
- status.color,
2926
- w,
2927
- theme,
2928
- contextPressure(state.contextPct),
2929
- );
2930
- const workRaw = state.task
2931
- ? (state.lastWork || state.task)
2932
- : state.def.description;
2933
-
2934
- // Nested delegate-child rows + a subtree rollup line (children count and
2935
- // token total — sub-sub spend is included in both its own row and here).
2936
- // Running children sort ahead of finished ones so a live child is never the
2937
- // row dropped by MAX_CHILD_ROWS; spawn order (startedAt) breaks ties within
2938
- // a group so the list stays stable as children complete.
2939
- const children = state.delegations ? Array.from(state.delegations.values()) : [];
2940
- children.sort((a, b) => {
2941
- const ar = a.status === "running" ? 0 : 1;
2942
- const br = b.status === "running" ? 0 : 1;
2943
- return ar !== br ? ar - br : a.startedAt - b.startedAt;
2944
- });
2945
- const childLines: string[] = [];
2946
- if (children.length > 0) {
2947
- for (const c of children.slice(0, MAX_CHILD_ROWS)) {
2948
- childLines.push(renderBorderedLine(renderChildLine(c, w, theme), w, theme));
2949
- }
2950
- if (children.length > MAX_CHILD_ROWS) {
2951
- childLines.push(renderBorderedLine(" " + theme.fg("dim", `… +${children.length - MAX_CHILD_ROWS} more`), w, theme));
2952
- }
2953
- const subtreeTokens = children.reduce((n, c) => n + c.tokens, 0);
2954
- childLines.push(renderBorderedLine(
2955
- " " + theme.fg("dim", `└ ${children.length} delegate${children.length !== 1 ? "s" : ""} · ${formatTokens(subtreeTokens)} tok`),
2956
- w, theme,
2957
- ));
2958
- }
2959
-
2960
- return [
2961
- theme.fg("dim", "┌" + "─".repeat(Math.max(0, w)) + "┐"),
2962
- renderBorderedLine(headerLine, w, theme),
2963
- renderBorderedLine(renderWorkLine(workRaw, w, theme), w, theme),
2964
- ...childLines,
2965
- theme.fg("dim", "└" + "─".repeat(Math.max(0, w)) + "┘"),
2966
- ];
2967
- }
2968
-
2969
2908
  // A research-helper card. Mirrors renderCard's compact two-line layout while
2970
2909
  // keeping the `rN` handle + persona/anon label + turn in the name slot.
2971
2910
  function renderResearchCard(state: ResearchState, colWidth: number, theme: any): string[] {
@@ -3001,41 +2940,9 @@ APIs, commands, structure), say so in your final response so the docs can be upd
3001
2940
 
3002
2941
  return {
3003
2942
  render(width: number): string[] {
3004
- // Compact mode hides the dashboard grid; running agents are shown
3005
- // in the belowEditor "agent-running" widget instead.
3006
- if (viewMode === "compact") return [];
3007
-
3008
- if (agentStates.size === 0) {
3009
- text.setText(theme.fg("dim", "No agents found. Add .md files to agents/"));
3010
- return text.render(width);
3011
- }
2943
+ // The full fleet list is now a separate overlay; this legacy widget is retired.
2944
+ return [];
3012
2945
 
3013
- const cols = Math.min(gridCols, agentStates.size);
3014
- const gap = 1;
3015
- const colWidth = Math.floor((width - gap * (cols - 1)) / cols);
3016
- const agents = Array.from(agentStates.values());
3017
- const rows: string[][] = [];
3018
-
3019
- for (let i = 0; i < agents.length; i += cols) {
3020
- const rowAgents = agents.slice(i, i + cols);
3021
- const cards = rowAgents.map(a => renderCard(a, colWidth, theme));
3022
-
3023
- // Cards vary in height (delegate-child rows) — pad every card in
3024
- // the row to the tallest one so columns stay aligned.
3025
- const cardHeight = Math.max(CARD_HEIGHT, ...cards.map(c => c.length));
3026
- while (cards.length < cols) {
3027
- cards.push(Array(cardHeight).fill(" ".repeat(Math.max(0, colWidth))));
3028
- }
3029
-
3030
- const blank = " ".repeat(Math.max(0, colWidth));
3031
- for (let line = 0; line < cardHeight; line++) {
3032
- rows.push(cards.map(card => card[line] ?? blank));
3033
- }
3034
- }
3035
-
3036
- const output = rows.map(cols => cols.join(" ".repeat(gap)));
3037
- text.setText(output.join("\n"));
3038
- return text.render(width);
3039
2946
  },
3040
2947
  invalidate() {
3041
2948
  text.invalidate();
@@ -3066,7 +2973,7 @@ APIs, commands, structure), say so in your final response so the docs can be upd
3066
2973
 
3067
2974
  // Compact mode hides the research grid; running helpers are folded
3068
2975
  // into the belowEditor "agent-running" widget instead.
3069
- if (viewMode === "compact") return [];
2976
+ if (!compactWidgetsEnabled(viewMode)) return [];
3070
2977
 
3071
2978
  const cols = Math.min(gridCols, states.length);
3072
2979
  const gap = 1;
@@ -3151,7 +3058,7 @@ APIs, commands, structure), say so in your final response so the docs can be upd
3151
3058
  widgetCtx.ui.setWidget("agent-running", (_tui: any, theme: any) => ({
3152
3059
  invalidate() {},
3153
3060
  render(width: number): string[] {
3154
- if (viewMode !== "compact") return [];
3061
+ if (!compactWidgetsEnabled(viewMode)) return [];
3155
3062
  const running = switchableAgents();
3156
3063
  if (running.length === 0) return [];
3157
3064
  const nameWidth = Math.min(24, Math.max(...running.map(r => visibleWidth(r.name))));
@@ -3530,6 +3437,7 @@ ${externalBlockedProtocol()}
3530
3437
  inputArtifacts: InputArtifactPreview[] = [],
3531
3438
  scopeGlobs: string[] = [],
3532
3439
  watchdogParam?: boolean,
3440
+ requestedBackend: "auto" | "native" | "coms" = "auto",
3533
3441
  ): Promise<{
3534
3442
  output: string;
3535
3443
  exitCode: number;
@@ -3562,6 +3470,8 @@ ${externalBlockedProtocol()}
3562
3470
  state.toolCount = 0;
3563
3471
  state.elapsed = 0;
3564
3472
  state.lastWork = "";
3473
+ state.lastBackend = undefined;
3474
+ state.comsPeerModel = undefined;
3565
3475
  state.runCount++;
3566
3476
  state.killedByOperator = false;
3567
3477
  state.restarting = false;
@@ -3616,7 +3526,18 @@ ${externalBlockedProtocol()}
3616
3526
 
3617
3527
  const personaKey = state.def.name.toLowerCase();
3618
3528
  const livePeerNames = () => (comsReady && identity ? peersInScope().map(e => e.name) : []);
3619
- let route: any = resolveDispatchBackend({ agentName: state.def.name, policy: dispatchPolicy, livePeerNames: livePeerNames() });
3529
+ let route: any = resolveDispatchBackend({
3530
+ agentName: state.def.name,
3531
+ policy: dispatchPolicy,
3532
+ livePeerNames: livePeerNames(),
3533
+ requestedBackend,
3534
+ });
3535
+ if (route.backend === "invalid") {
3536
+ return finishRun(`Invalid dispatch backend "${route.requestedBackend}". Expected auto|native|coms.`, 1);
3537
+ }
3538
+ if (route.backend === "coms-unavailable") {
3539
+ return finishRun(explicitComsRefusal(displayName(state.def.name)), 1);
3540
+ }
3620
3541
  if (route.backend === "await-coms") {
3621
3542
  // coms-required member (fallback: none) whose peer is not live yet:
3622
3543
  // poll the pool through the grace window, then refuse with guidance.
@@ -3626,7 +3547,7 @@ ${externalBlockedProtocol()}
3626
3547
  updateWidget();
3627
3548
  while (Date.now() < deadline && route.backend !== "coms") {
3628
3549
  await new Promise(res => setTimeout(res, 1000));
3629
- route = resolveDispatchBackend({ agentName: state.def.name, policy: dispatchPolicy, livePeerNames: livePeerNames() });
3550
+ route = resolveDispatchBackend({ agentName: state.def.name, policy: dispatchPolicy, livePeerNames: livePeerNames(), requestedBackend });
3630
3551
  }
3631
3552
  if (route.backend !== "coms") {
3632
3553
  return finishRun(comsRequiredRefusal(displayName(state.def.name), graceS), 1);
@@ -3638,7 +3559,7 @@ ${externalBlockedProtocol()}
3638
3559
  }
3639
3560
  if (route.backend === "coms") {
3640
3561
  void monitorBridge?.registerWaitOnly(monitorKey, () => state.comsAbort?.());
3641
- const allowNativeFallback = (dispatchPolicy.substitutions[personaKey]?.fallback ?? "native") !== "none";
3562
+ const allowNativeFallback = !route.explicit && (dispatchPolicy.substitutions[personaKey]?.fallback ?? "native") !== "none";
3642
3563
  const timeoutMs = route.timeout_s ? route.timeout_s * 1000 : TIMEOUT_MS;
3643
3564
  const comsRes = await dispatchViaComs(state, task, route.peerName, timeoutMs, allowNativeFallback, ctx, inputArtifacts, scopeGlobs);
3644
3565
  if (comsRes) {
@@ -4307,6 +4228,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
4307
4228
  updateResearchWidget();
4308
4229
 
4309
4230
  const histEntry = historyStart("research", `Research r${state.id}`);
4231
+ state.histEntry = histEntry;
4310
4232
 
4311
4233
  const startTime = Date.now();
4312
4234
  state.timer = setInterval(() => {
@@ -4743,57 +4665,47 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
4743
4665
  return null;
4744
4666
  }
4745
4667
 
4746
- function renderPool(width: number, theme: Theme): string[] {
4747
- // Compact mode hides the coms pool too — only running agents show below the editor.
4748
- if (viewMode === "compact") return [];
4668
+ let cachedRegistryProject: string | undefined;
4669
+ let cachedRegistryEntries: ComsRegistryEntry[] = [];
4670
+ let cachedRegistryAt = 0;
4671
+ const scrubFleetText = (text: string) => text.replace(/[\x00-\x1f\x7f]+/g, " ").replace(/\s+/g, " ").trim();
4672
+ /** Build the one peer source consumed by both the compact pool and dashboard. */
4673
+ function fleetPeerInputs(formatModel: (model: string) => string = (model) => model): PeerInput[] {
4749
4674
  const projectFilter = displayProject ?? identity?.project ?? "default";
4750
- const registryEntries = projectFilter === "*"
4751
- ? readAllRegistryEntriesAcrossProjects()
4752
- : readAllRegistryEntries(projectFilter);
4753
-
4754
- interface Row {
4755
- name: string;
4756
- model: string;
4757
- color: string;
4758
- purpose: string;
4759
- pct: number | null;
4760
- pending: boolean;
4761
- stale: boolean;
4762
- }
4763
- const rows: Row[] = [];
4675
+ if (cachedRegistryProject !== projectFilter || Date.now() - cachedRegistryAt > 1000) {
4676
+ cachedRegistryProject = projectFilter;
4677
+ cachedRegistryEntries = projectFilter === "*" ? readAllRegistryEntriesAcrossProjects() : readAllRegistryEntries(projectFilter);
4678
+ cachedRegistryAt = Date.now();
4679
+ }
4680
+ const registryEntries = cachedRegistryEntries;
4681
+ const peers: PeerInput[] = [];
4764
4682
  const seenSessions = new Set<string>();
4683
+ const seenNames = new Set<string>();
4765
4684
 
4766
4685
  for (const [sid, card] of peerCards.entries()) {
4767
4686
  if (identity && sid === identity.session_id) continue;
4768
4687
  seenSessions.add(sid);
4769
- rows.push({
4770
- name: card.name,
4771
- model: card.model,
4772
- color: card.color,
4773
- purpose: card.purpose,
4774
- pct: card.context_used_pct,
4775
- pending: false,
4776
- stale: (card.staleCount ?? 0) >= 3,
4777
- });
4688
+ seenNames.add(card.name);
4689
+ peers.push({ key: `peer:${sid}`, name: scrubFleetText(card.name), model: formatModel(card.model), lastWork: scrubFleetText(card.purpose), colorHex: card.color, staleCount: card.staleCount });
4778
4690
  }
4779
4691
 
4780
- // Registry-only entries that aren't yet in peerCards → pending
4781
- const seenNames = new Set(rows.map((r) => r.name));
4692
+ // Registry-only entries have not answered a ping, so the read model owns their pending status.
4782
4693
  for (const entry of registryEntries) {
4783
4694
  if (identity && entry.session_id === identity.session_id) continue;
4784
4695
  if (!includeExplicit && entry.explicit) continue;
4785
- if (seenSessions.has(entry.session_id)) continue;
4786
- if (seenNames.has(entry.name)) continue;
4787
- rows.push({
4788
- name: entry.name,
4789
- model: entry.model,
4790
- color: entry.color,
4791
- purpose: entry.purpose,
4792
- pct: null,
4793
- pending: true,
4794
- stale: false,
4795
- });
4696
+ if (seenSessions.has(entry.session_id) || seenNames.has(entry.name)) continue;
4697
+ peers.push({ key: `peer:${entry.session_id}`, name: scrubFleetText(entry.name), model: formatModel(entry.model), lastWork: scrubFleetText(entry.purpose), colorHex: entry.color, pending: true });
4796
4698
  }
4699
+ return peers;
4700
+ }
4701
+
4702
+ function renderPool(width: number, theme: Theme): string[] {
4703
+ // Compact mode hides the coms pool too — only running agents show below the editor.
4704
+ if (!compactWidgetsEnabled(viewMode)) return [];
4705
+ const rows = buildFleetRows(
4706
+ { specialists: [], research: [], peers: fleetPeerInputs() },
4707
+ { showFinished: true },
4708
+ );
4797
4709
 
4798
4710
  // Border helpers — sandwich the body with single-line box-drawing rules
4799
4711
  // so the widget reads as its own block. The top border carries a branded
@@ -4840,27 +4752,29 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
4840
4752
  const out: string[] = [topBorder];
4841
4753
 
4842
4754
  for (const r of rows) {
4843
- const pctNum = r.pct ?? 0;
4755
+ const pctNum = r.contextPct ?? 0;
4844
4756
  const filled = Math.max(0, Math.min(15, Math.round((pctNum / 100) * 15)));
4845
4757
  const empty = 15 - filled;
4846
- const pctLabel = r.pct == null ? "--%" : `${r.pct}%`;
4758
+ const pctLabel = r.contextPct == null ? "--%" : `${r.contextPct}%`;
4847
4759
 
4848
- if (r.stale) {
4849
- const dimRow = `✗ ${r.name.padEnd(12)} ${abbreviateModel(r.model).padEnd(14)} [${"-".repeat(15)}] ${pctLabel.padStart(4)} — ${r.purpose || ""}`;
4760
+ if (r.status === "stale") {
4761
+ const dimRow = `✗ ${r.name.padEnd(12)} ${abbreviateModel(r.model).padEnd(14)} [${"-".repeat(15)}] ${pctLabel.padStart(4)} — ${r.lastWork || ""}`;
4850
4762
  out.push(truncateToWidth(" " + theme.fg("dim", dimRow), width));
4851
4763
  continue;
4852
4764
  }
4853
4765
 
4854
- const swatch = r.pending ? theme.fg("dim", "●") : hexFg(r.color, "●");
4766
+ const pending = r.status === "pending";
4767
+ const color = r.colorHex ?? "#808080";
4768
+ const swatch = pending ? theme.fg("dim", "●") : hexFg(color, "●");
4855
4769
  const namePart = theme.fg("accent", r.name.padEnd(12));
4856
4770
  const modelPart = theme.fg("dim", abbreviateModel(r.model).padEnd(14));
4857
- const barFill = r.pending
4771
+ const barFill = pending
4858
4772
  ? theme.fg("dim", "-".repeat(15))
4859
- : hexFg(r.color, "#".repeat(filled)) + theme.fg("dim", "-".repeat(empty));
4773
+ : hexFg(color, "#".repeat(filled)) + theme.fg("dim", "-".repeat(empty));
4860
4774
  const bar = theme.fg("warning", "[") + barFill + theme.fg("warning", "]");
4861
4775
  const pctPart = " " + theme.fg("accent", pctLabel.padStart(4));
4862
4776
  const sep = theme.fg("dim", " — ");
4863
- const purposePart = theme.fg("muted", r.purpose || "");
4777
+ const purposePart = theme.fg("muted", r.lastWork || "");
4864
4778
 
4865
4779
  const line = " " + swatch + " " + namePart + " " + modelPart + " " + bar + pctPart + sep + purposePart;
4866
4780
  out.push(truncateToWidth(line, width));
@@ -5031,10 +4945,15 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5031
4945
  scope: Type.Optional(Type.Array(Type.String({ description: "Optional advisory file scope globs for writable agents. Changes outside are reported in details.scopeViolations; nothing is auto-reverted. Also arms the drift watchdog's live out-of-scope rule." }))),
5032
4946
  watchdog: Type.Optional(Type.Boolean({ description: "Force the drift watchdog on/off for THIS dispatch (default: per-agent /af-watchdog override, then the hub-wide setting)." })),
5033
4947
  review_reason: Type.Optional(Type.String({ description: "Why a documentation-only change needs a review gate (e.g. it publishes a credential, or states a contract other systems rely on). Only needed when dispatching a review persona with a docs-only `scope`." })),
4948
+ backend: Type.Optional(Type.Union([
4949
+ Type.Literal("auto"),
4950
+ Type.Literal("native"),
4951
+ Type.Literal("coms"),
4952
+ ], { description: "Dispatch backend. auto follows dispatch-policy.yaml (default); native always starts the local Pi specialist; coms requires a live same-name peer and never falls back." })),
5034
4953
  }),
5035
4954
 
5036
4955
  async execute(_toolCallId, params, _signal, onUpdate, ctx) {
5037
- const { task, artifacts, scope, watchdog, review_reason } = params as { agent: string; task: string; artifacts?: string[]; scope?: string[]; watchdog?: boolean; review_reason?: string };
4956
+ const { task, artifacts, scope, watchdog, review_reason, backend = "auto" } = params as { agent: string; task: string; artifacts?: string[]; scope?: string[]; watchdog?: boolean; review_reason?: string; backend?: "auto" | "native" | "coms" };
5038
4957
  // Display names / underscores resolve to the persona slug key space, so
5039
4958
  // `agent: "Test Engineer"` never burns a dispatch on a lookup error.
5040
4959
  const agent = normalizeAgentInput((params as { agent: string }).agent);
@@ -5166,7 +5085,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5166
5085
  const findingClause = reviewBudgetClause(taskTier, agent);
5167
5086
  const dispatchedTask = findingClause ? `${task}\n\n${findingClause}` : task;
5168
5087
 
5169
- let result = await dispatchAgent(agent, dispatchedTask, ctx, inputArtifacts, scopeGlobs, watchdog);
5088
+ let result = await dispatchAgent(agent, dispatchedTask, ctx, inputArtifacts, scopeGlobs, watchdog, backend);
5170
5089
  let dispatchBilled = result.billed ?? 0;
5171
5090
  let dispatchOut = result.out ?? 0;
5172
5091
 
@@ -5226,7 +5145,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5226
5145
  const resumePrompt = "Research findings for your NEEDS_RESEARCH questions are ready. " +
5227
5146
  "Read each file with your read tool, then continue from where you paused:\n" +
5228
5147
  answered.map((a, i) => `${i + 1}. ${a.question}\n → ${a.file}`).join("\n");
5229
- result = await dispatchAgent(agent, resumePrompt, ctx, inputArtifacts, scopeGlobs, watchdog);
5148
+ result = await dispatchAgent(agent, resumePrompt, ctx, inputArtifacts, scopeGlobs, watchdog, backend);
5230
5149
  dispatchBilled += result.billed ?? 0;
5231
5150
  dispatchOut += result.out ?? 0;
5232
5151
  }
@@ -5403,6 +5322,8 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5403
5322
  agent,
5404
5323
  task,
5405
5324
  status,
5325
+ backendRequested: backend,
5326
+ backendUsed: state?.lastBackend ?? null,
5406
5327
  elapsed: result.elapsed,
5407
5328
  exitCode: result.exitCode,
5408
5329
  fullOutput: result.output,
@@ -6326,22 +6247,22 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6326
6247
  }
6327
6248
  }
6328
6249
 
6329
- /**
6330
- * The peers.yaml declaration for a peer name, when the repo has one. A hub
6331
- * spawn is handed a bare name, but the fleet may define that name as a
6332
- * `runner: claude-code` peer or one that needs extra extensions — launching
6333
- * a plain pi peer instead would silently produce a different agent.
6334
- */
6335
- function declaredPeer(name: string): ReturnType<typeof findPeerByName> {
6336
- const cwd = currentCtx?.cwd ?? process.cwd();
6250
+ /** Manifest and persona probes supplied to the shared Fleet peer resolver. */
6251
+ function peerManifest(cwd: string): string {
6337
6252
  try {
6338
- const raw = fs.readFileSync(path.join(cwd, ".pi", "agents", "peers.yaml"), "utf-8");
6339
- return findPeerByName(parsePeersYaml(raw), name);
6253
+ return fs.readFileSync(path.join(cwd, ".pi", "agents", "peers.yaml"), "utf-8");
6340
6254
  } catch {
6341
- return undefined;
6255
+ return "";
6342
6256
  }
6343
6257
  }
6344
6258
 
6259
+ function peerPersonaExists(cwd: string, persona: string): boolean {
6260
+ return (
6261
+ fs.existsSync(path.join(cwd, "agents", `${persona}.md`)) ||
6262
+ fs.existsSync(path.join(cwd, ".pi", "agents", `${persona}.md`))
6263
+ );
6264
+ }
6265
+
6345
6266
  /** Seconds this spawn should sleep before launching pi (stale-OAuth lock race). */
6346
6267
  function spawnDelaySeconds(): number {
6347
6268
  let authRaw: string | undefined;
@@ -6362,12 +6283,16 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6362
6283
  name: "herdr_spawn_peer",
6363
6284
  label: "Herdr Spawn Peer",
6364
6285
  description:
6365
- "Spawn a pane in the CURRENT herdr workspace: either a peers.yaml-style coms peer (persona [+ name/model], launched via `just _peer`) or a raw command pane. The peer joins THIS session's coms project pool, and a name declared in .pi/agents/peers.yaml keeps its declared runner/extensions. A persona peer boots IDLE and does nothing until you coms_send to it — spawning delivers no work. The call waits (bounded) for the peer to register and returns `peer_ready` plus its coms name, or `peer_ready: false` with the pane's last output — treat that as a failed start, not a slow one. Spawn one only immediately before the first message you will send it; a peer that receives no work is named in the session digest.",
6286
+ "Spawn one reusable coms peer in a sibling pane of the CURRENT Herdr workspace. Name-only resolution is identical to `just fleet peer`: peers.yaml may select a Pi persona, personaless Fleet Core, or Claude Code plus declared model/extensions/env_file. Explicit compatible fields override the declaration, but the Hub forces its own coms project and never accepts an env path or raw command. The peer boots IDLE; this call waits for `peer_ready` before it may receive coms work.",
6366
6287
  parameters: Type.Object({
6367
- persona: Type.Optional(Type.String({ description: "Persona under agents/ (e.g. researcher). Omit for a raw command pane." })),
6368
- name: Type.String({ description: "Pane label; for persona peers also the coms peer name." }),
6369
- model: Type.Optional(Type.String({ description: "Optional model spec for the peer (pi --model)." })),
6370
- command: Type.Optional(Type.String({ description: "Raw shell command for a non-peer pane (mutually exclusive with persona)." })),
6288
+ name: Type.String({ description: "Pane label and coms peer name." }),
6289
+ runner: Type.Optional(Type.Union([Type.Literal("pi"), Type.Literal("claude-code")], { description: "Override the declared runner." })),
6290
+ persona: Type.Optional(Type.String({ description: "Explicit Pi persona under agents/ or .pi/agents/." })),
6291
+ no_persona: Type.Optional(Type.Boolean({ description: "Force a personaless Fleet Core Pi peer." })),
6292
+ model: Type.Optional(Type.String({ description: "Override the declared model." })),
6293
+ extensions: Type.Optional(Type.String({ description: "Comma-separated extensions for a Pi persona peer." })),
6294
+ browser: Type.Optional(Type.Boolean({ description: "Add browser capability to a Pi peer." })),
6295
+ all_extensions: Type.Optional(Type.Boolean({ description: "Load all extensions; personaless Fleet Core only." })),
6371
6296
  direction: Type.Optional(Type.Union([Type.Literal("right"), Type.Literal("down")], { description: "Split direction (default right)." })),
6372
6297
  }),
6373
6298
  async execute(_callId, params) {
@@ -6378,85 +6303,122 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6378
6303
  if (!ownPane) {
6379
6304
  return { content: [{ type: "text" as const, text: "not inside a herdr pane." }], details: { error: "no pane" } };
6380
6305
  }
6306
+ if (!comsReady || !identity) {
6307
+ return {
6308
+ content: [{ type: "text" as const, text: "Cannot spawn an addressable peer while coms is unavailable. Start without --solo/--no-coms, or use herdr_spawn_pane for a non-peer command." }],
6309
+ details: { error: "no coms" },
6310
+ };
6311
+ }
6381
6312
  try {
6382
6313
  const cwd = currentCtx?.cwd ?? process.cwd();
6314
+ const plan = buildHubPeerSpawnPlan(params, {
6315
+ project: identity.project,
6316
+ peersYaml: peerManifest(cwd),
6317
+ personaExists: (persona) => peerPersonaExists(cwd, persona),
6318
+ worktreeTag: worktreeTag(cwd),
6319
+ });
6320
+ if (peersInScope().some(peer => peer.name.toLowerCase() === plan.name.toLowerCase())) {
6321
+ throw new Error(`Peer "${plan.name}" is already visible in project "${identity.project}"; use coms_send instead of spawning a duplicate.`);
6322
+ }
6383
6323
  const env: Record<string, string> = {};
6384
- let argv: string[];
6385
- if (params.persona) {
6386
- // The peer joins THIS hub's coms pool. Defaulting to "default"
6387
- // (as this once did) puts it in a pool the hub cannot see, so it
6388
- // never registers no matter how long the readiness wait runs.
6389
- const declared = declaredPeer(params.name);
6390
- argv = peerCommand(
6391
- {
6392
- persona: params.persona,
6393
- name: params.name,
6394
- model: params.model ?? declared?.model,
6395
- extensions: declared?.extensions,
6396
- runner: declared?.runner,
6397
- },
6398
- "hub-spawned",
6399
- undefined,
6400
- identity?.project ?? DEFAULT_PROJECT,
6401
- );
6402
- if (declared?.env_file) {
6403
- Object.assign(env, parseEnvFile(fs.readFileSync(resolveEnvFilePath(declared.env_file, cwd), "utf-8"), declared.env_file));
6404
- }
6405
- const delay = declared?.runner === "claude-code" ? 0 : spawnDelaySeconds();
6406
- if (delay > 0) env[STAGGER_ENV_VAR] = String(delay);
6407
- } else if (params.command) {
6408
- argv = ["bash", "-lc", params.command];
6409
- } else {
6410
- return { content: [{ type: "text" as const, text: "pass persona (peer) or command (raw pane)." }], details: { error: "bad args" } };
6324
+ if (plan.envFile) {
6325
+ const envPath = resolveEnvFilePath(plan.envFile, cwd);
6326
+ if (!fs.existsSync(envPath)) throw new Error(`env_file not found: ${plan.envFile} (resolved: ${envPath})`);
6327
+ Object.assign(env, parseEnvFile(fs.readFileSync(envPath, "utf-8"), plan.envFile));
6411
6328
  }
6412
- // pane.split takes no command — it opens a shell in `cwd`.
6329
+ const delay = plan.runner === "pi" ? spawnDelaySeconds() : 0;
6330
+ if (delay > 0) env[STAGGER_ENV_VAR] = String(delay);
6331
+ const launched = await launchHubPeerInPane(plan, {
6332
+ client: herdrApi,
6333
+ targetPaneId: ownPane,
6334
+ cwd,
6335
+ env,
6336
+ waitForRegistration: waitForPeerRegistration,
6337
+ paneTail,
6338
+ onLaunched: (paneId) => {
6339
+ hubSpawnedPeers.set(plan.name.toLowerCase(), { name: plan.name, paneId, addressed: false });
6340
+ if (plan.runner === "pi") lastHubPiSpawnAt = Date.now();
6341
+ },
6342
+ });
6343
+ const promptNote = launched.promptSeen
6344
+ ? ""
6345
+ : `\n⚠ pane ${launched.paneId} showed no shell prompt within ${Math.round(PANE_PROMPT_TIMEOUT_MS / 1000)}s; the command was sent anyway.`;
6346
+ return {
6347
+ content: [{ type: "text" as const, text: `spawned ${plan.kind} in pane ${launched.paneId} (${plan.name}): ${plan.command.join(" ")}${promptNote}\n\n${launched.verdict.message}` }],
6348
+ details: {
6349
+ pane_id: launched.paneId,
6350
+ name: plan.name,
6351
+ kind: plan.kind,
6352
+ runner: plan.runner,
6353
+ project: plan.project,
6354
+ prompt_seen: launched.promptSeen,
6355
+ env_file: plan.envFile ?? null,
6356
+ ...launched.verdict,
6357
+ },
6358
+ };
6359
+ } catch (err) {
6360
+ const m = err instanceof Error ? err.message : String(err);
6361
+ return { content: [{ type: "text" as const, text: `herdr_spawn_peer failed before readiness: ${m}` }], details: { error: m } };
6362
+ }
6363
+ },
6364
+ renderCall(args, theme) {
6365
+ const a = args as any;
6366
+ return new Text(
6367
+ theme.fg("toolTitle", theme.bold("herdr_spawn_peer ")) + theme.fg("accent", a.name ?? "?") + theme.fg("dim", a.runner ? ` (${a.runner})` : ""),
6368
+ 0, 0,
6369
+ );
6370
+ },
6371
+ renderResult(result, _options, theme) {
6372
+ const d = result.details as any;
6373
+ if (d?.error) return new Text(theme.fg("error", `✗ ${d.error}`), 0, 0);
6374
+ if (d?.peer_ready === false) return new Text(theme.fg("error", `✗ ${d?.pane_id ?? "peer failed"}`), 0, 0);
6375
+ return new Text(theme.fg("success", `✓ ${d?.pane_id ?? "spawned"}`), 0, 0);
6376
+ },
6377
+ });
6378
+
6379
+ pi.registerTool({
6380
+ name: "herdr_spawn_pane",
6381
+ label: "Herdr Spawn Pane",
6382
+ description:
6383
+ "Spawn a raw shell command in a sibling pane of the CURRENT Herdr workspace. This is not a coms peer: it has no persona, project, registration wait, or peer_ready result. Use herdr_spawn_peer for addressable Pi/Claude workers.",
6384
+ parameters: Type.Object({
6385
+ name: Type.String({ description: "Human-visible pane label." }),
6386
+ command: Type.String({ description: "Raw shell command executed with bash -lc." }),
6387
+ direction: Type.Optional(Type.Union([Type.Literal("right"), Type.Literal("down")], { description: "Split direction (default right)." })),
6388
+ }),
6389
+ async execute(_callId, params) {
6390
+ if (!herdrFleetReady) {
6391
+ return { content: [{ type: "text" as const, text: "herdr is not available in this session." }], details: { error: "no herdr" } };
6392
+ }
6393
+ const ownPane = herdrPaneId();
6394
+ if (!ownPane) {
6395
+ return { content: [{ type: "text" as const, text: "not inside a herdr pane." }], details: { error: "no pane" } };
6396
+ }
6397
+ try {
6398
+ const cwd = currentCtx?.cwd ?? process.cwd();
6399
+ const argv = ["bash", "-lc", params.command];
6413
6400
  const { pane } = await herdrApi.paneSplit({
6414
6401
  target_pane_id: ownPane,
6415
6402
  direction: params.direction ?? "right",
6416
6403
  cwd,
6417
- ...(Object.keys(env).length > 0 ? { env } : {}),
6418
6404
  focus: false,
6419
6405
  });
6420
6406
  try { await herdrApi.paneRename(pane.pane_id, params.name); } catch { /* cosmetic */ }
6421
- // …so the argv is typed into that shell once it shows a prompt.
6422
6407
  const launch = await launchPeerInPane(herdrApi, pane.pane_id, argv);
6423
- if (params.persona) lastHubPiSpawnAt = Date.now();
6424
6408
  const promptNote = launch.promptSeen
6425
6409
  ? ""
6426
6410
  : `\n⚠ pane ${pane.pane_id} showed no shell prompt within ${Math.round(PANE_PROMPT_TIMEOUT_MS / 1000)}s; the command was sent anyway.`;
6427
- // A raw command pane is not a coms peer — nothing to wait for and
6428
- // nothing to sweep. A persona peer is only useful once addressable,
6429
- // so report that verdict instead of a bare pane id.
6430
- if (!params.persona) {
6431
- return {
6432
- content: [{ type: "text" as const, text: `spawned pane ${pane.pane_id} (${params.name}): ${argv.join(" ")}${promptNote}` }],
6433
- details: { pane_id: pane.pane_id, name: params.name, prompt_seen: launch.promptSeen },
6434
- };
6435
- }
6436
- hubSpawnedPeers.set(params.name.toLowerCase(), { name: params.name, paneId: pane.pane_id, addressed: false });
6437
- const { found, waitedMs } = await waitForPeerRegistration(params.name);
6438
- const verdict = peerReadyVerdict({
6439
- name: params.name,
6440
- paneId: pane.pane_id,
6441
- found,
6442
- waitedMs,
6443
- paneTail: found ? undefined : await paneTail(pane.pane_id),
6444
- });
6445
6411
  return {
6446
- content: [{ type: "text" as const, text: `spawned pane ${pane.pane_id} (${params.name}): ${argv.join(" ")}${promptNote}\n\n${verdict.message}` }],
6447
- details: { pane_id: pane.pane_id, name: params.name, prompt_seen: launch.promptSeen, ...verdict },
6412
+ content: [{ type: "text" as const, text: `spawned raw pane ${pane.pane_id} (${params.name}): ${params.command}${promptNote}` }],
6413
+ details: { pane_id: pane.pane_id, name: params.name, prompt_seen: launch.promptSeen },
6448
6414
  };
6449
6415
  } catch (err) {
6450
6416
  const m = err instanceof Error ? err.message : String(err);
6451
- return { content: [{ type: "text" as const, text: `herdr_spawn_peer failed: ${m}` }], details: { error: m } };
6417
+ return { content: [{ type: "text" as const, text: `herdr_spawn_pane failed: ${m}` }], details: { error: m } };
6452
6418
  }
6453
6419
  },
6454
6420
  renderCall(args, theme) {
6455
- const a = args as any;
6456
- return new Text(
6457
- theme.fg("toolTitle", theme.bold("herdr_spawn_peer ")) + theme.fg("accent", a.name ?? "?") + theme.fg("dim", a.persona ? ` (${a.persona})` : " (raw)"),
6458
- 0, 0,
6459
- );
6421
+ return new Text(theme.fg("toolTitle", theme.bold("herdr_spawn_pane ")) + theme.fg("accent", (args as any).name ?? "?"), 0, 0);
6460
6422
  },
6461
6423
  renderResult(result, _options, theme) {
6462
6424
  const d = result.details as any;
@@ -6586,6 +6548,32 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6586
6548
  // and warn the user to `pi install npm:pi-ask-user` if it's missing.
6587
6549
 
6588
6550
  let askUserAvailable = false;
6551
+ let posture: Posture = "operator";
6552
+ let baselineTools: string[] = [];
6553
+
6554
+ function applyPostureTools(): void {
6555
+ pi.setActiveTools(resolvePostureTools({
6556
+ posture,
6557
+ baselineTools,
6558
+ comsReady,
6559
+ herdrReady: herdrFleetReady,
6560
+ askUserAvailable,
6561
+ }));
6562
+ }
6563
+
6564
+ function updatePostureStatus(ctx: ExtensionContext): void {
6565
+ ctx.ui.setStatus("hub-posture", `Posture: ${posture}`);
6566
+ }
6567
+
6568
+ function postureStatusText(): string {
6569
+ return [
6570
+ `Posture: ${posture}`,
6571
+ `Direct tools: ${posture === "operator" ? "enabled" : "disabled"}`,
6572
+ `Native roster: ${activeTeamName || "(none)"} (${agentStates.size})`,
6573
+ `Coms: ${comsReady ? `ready${identity ? ` (${identity.name}@${identity.project})` : ""}` : "unavailable"}`,
6574
+ `Herdr: ${herdrFleetReady ? "ready" : "unavailable"}`,
6575
+ ].join("\n");
6576
+ }
6589
6577
 
6590
6578
  // ── Dispatcher persona picker (blocking gate) ──
6591
6579
  // Mirrors purpose-gate's blocking loop, but over a select of orchestrator
@@ -6644,29 +6632,158 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6644
6632
  },
6645
6633
  });
6646
6634
 
6635
+ let fleetShowFinished = false;
6636
+ let fleetFilter = "";
6637
+ function fleetRows(unfiltered = false): FleetRow[] {
6638
+ // agentStates is the roster and its live state in one keyed map: a dispatch
6639
+ // updates this row instead of adding a second live-specialist source.
6640
+ const specialists: SpecialistInput[] = Array.from(agentStates.entries()).map(([key, state]) => ({
6641
+ key, name: displayName(state.def.name), status: state.status,
6642
+ model: state.lastBackend === "coms" ? `⇄ ${shortModel(state.comsPeerModel)}` : modelWithThinking(state.def), backend: state.lastBackend ?? "native",
6643
+ contextPct: state.contextPct, contextTokens: state.contextTokens, ...fleetTiming(state.histEntry),
6644
+ toolCount: state.toolCount, lastWork: state.lastWork || state.task || state.def.description, hasTimeline: true,
6645
+ delegates: Array.from(state.delegations?.values() ?? []).map(child => ({ key: child.id, name: child.role || child.id, status: child.status, model: shortModel(child.model), contextPct: null, contextTokens: child.tokens, elapsed: child.status === "running" ? Date.now() - child.startedAt : child.elapsed, startedAt: child.startedAt, toolCount: child.toolCount, lastWork: child.lastWork, children: [] })),
6646
+ }));
6647
+ const research: ResearchInput[] = Array.from(researchStates.values()).map(state => ({ key: `r${state.id}`, name: `r${state.id} ${state.persona ? displayName(state.def.name) : "research"}`, status: state.status, model: shortModel(state.model) + thinkingSuffix(resolvedThinking(state.def)), backend: "native", contextPct: state.contextPct, contextTokens: null, ...fleetTiming(state.histEntry), toolCount: state.toolCount, lastWork: state.lastWork || state.task, hasTimeline: true }));
6648
+ const peers = fleetPeerInputs(model => `⇄ ${abbreviateModel(model)}`);
6649
+ return buildFleetRows({ specialists, research, peers }, unfiltered ? { showFinished: true } : { showFinished: fleetShowFinished, query: fleetFilter });
6650
+ }
6651
+ async function openFleetDetail(row: FleetRow, ctx: any): Promise<void> {
6652
+ const target = row.kind === "research" ? researchStates.get(parseResearchHandle(row.key)!) : row.kind === "delegate" ? findDelegationChild(row.key)?.child : agentStates.get(row.key);
6653
+ const resources = createPanelResources();
6654
+ let scrollOffset = 0, selectedIndex = 0, expandedIndex: number | null = null, followTail = true, lastRender = 0;
6655
+ const timeline = () => liveTimeline(target);
6656
+ try { await ctx.ui.custom((tui: any, theme: any, _kb: any, done: () => void) => {
6657
+ if (target) target.zoomRender = (force?: boolean) => { const now = Date.now(); if (force || now - lastRender > 80) { lastRender = now; tui.requestRender(); } };
6658
+ return { render: (w: number) => { const body = bodyRows(tui.terminal?.rows, DETAIL_CHROME_ROWS); const entries = timeline(); if (followTail) scrollOffset = Math.max(0, detailContent(entries, w, expandedIndex).length - body); return renderFleetDetail(row, entries, scrollOffset, w, body, theme, expandedIndex); }, handleInput: async (data: string) => { const entries = timeline(); const state = { scrollOffset, selectedIndex, expandedIndex, followTail }; const action = detailTransition(data, state, entries, bodyRows(tui.terminal?.rows, DETAIL_CHROME_ROWS), detailContent(entries, tui.terminal?.columns ?? 80, expandedIndex).length); ({ scrollOffset, selectedIndex, expandedIndex, followTail } = state); if (action === "close") done(); else if (action === "copy") { const item = entries[selectedIndex]; if (item) { try { await copyToClipboard(item.content); ctx.ui.notify("Copied selected zoom row", "success"); } catch { ctx.ui.notify("Failed to copy selected zoom row", "error"); } } } tui.requestRender(); }, invalidate() {}, dispose: () => resources.dispose() };
6659
+ }, FULLSCREEN_OVERLAY); } finally { resources.dispose(); if (target) target.zoomRender = undefined; }
6660
+ }
6661
+ async function restartFleetRow(selected: FleetRow, ctx: any): Promise<void> {
6662
+ const decision = resolveFleetRestart(selected, {
6663
+ researchRestartable: (key) => {
6664
+ const state = researchStates.get(parseResearchHandle(key)!);
6665
+ return !!(state?.task && state.status !== "running");
6666
+ },
6667
+ specialistRestartable: (key) => !!(agentStates.get(key)?.task),
6668
+ });
6669
+ if (decision.action === "unsupported") {
6670
+ ctx.ui.notify(decision.message, decision.level);
6671
+ return;
6672
+ }
6673
+ if (decision.action === "restart-research") {
6674
+ const state = researchStates.get(parseResearchHandle(selected.key)!);
6675
+ if (!state?.task) { ctx.ui.notify(decision.message.replace("Restarting", "Cannot restart"), "warning"); return; }
6676
+ state.sessionFile = null; state.turnCount = 1;
6677
+ ctx.ui.notify(decision.message, "info");
6678
+ spawnResearch(state, state.task, ctx).then(result => deliverResearchFollowUp(state, result));
6679
+ return;
6680
+ }
6681
+ const state = agentStates.get(selected.key);
6682
+ if (!state?.task) { ctx.ui.notify(decision.message.replace("Restarting", "Cannot restart"), "warning"); return; }
6683
+ if (state.status === "running" && (state.proc || state.comsAbort)) {
6684
+ let resolveTermination!: () => void;
6685
+ const terminated = new Promise<void>(resolve => { resolveTermination = resolve; });
6686
+ state.onTerminate = resolveTermination;
6687
+ if (state.proc) { state.killedByOperator = true; state.restarting = true; killPiTree(state.proc); }
6688
+ else await cancelLocalWaitOnly({ abort: state.comsAbort, monitorBridge, monitorKey: monitorKeyForAgent(state.def.name, state.runCount), event: { kind: "restart" } });
6689
+ await terminated;
6690
+ }
6691
+ state.sessionFile = null;
6692
+ ctx.ui.notify(decision.message.includes(displayName(state.def.name)) ? decision.message : `Restarting ${displayName(state.def.name)} (fresh)...`, "info");
6693
+ const result = await dispatchAgent(state.def.name, state.task, ctx);
6694
+ pi.sendMessage({ customType: "agent-restart-result", content: `[${displayName(state.def.name)}] restarted by operator and ${result.exitCode === 0 ? "completed" : "failed"} in ${Math.round(result.elapsed / 1000)}s.`, display: true }, { deliverAs: "followUp", triggerTurn: true });
6695
+ }
6696
+ async function openFleetDashboard(ctx: any): Promise<void> {
6697
+ const resources = createPanelResources();
6698
+ const selection: Selection = { index: 0 };
6699
+ let scrollOffset = 0;
6700
+ let filtering = false;
6701
+ let confirm: DashboardConfirm = null;
6702
+ const toInput = (data: string): string => {
6703
+ if (matchesKey(data, Key.up)) return "\u001b[A";
6704
+ if (matchesKey(data, Key.down)) return "\u001b[B";
6705
+ if (matchesKey(data, Key.pageUp)) return "\u001b[5~";
6706
+ if (matchesKey(data, Key.pageDown)) return "\u001b[6~";
6707
+ if (matchesKey(data, Key.enter)) return "\r";
6708
+ if (matchesKey(data, Key.escape)) return "\u001b";
6709
+ return data;
6710
+ };
6711
+ try {
6712
+ await ctx.ui.custom((tui: any, theme: any, _kb: any, done: () => void) => {
6713
+ attachFleetDashboardTicker(resources, () => tui.requestRender());
6714
+ return {
6715
+ render: (w: number) => {
6716
+ const rows = fleetRows();
6717
+ reconcileSelection(selection, rows);
6718
+ const body = bodyRows(tui.terminal?.rows, FLEET_CHROME_ROWS);
6719
+ scrollOffset = clampScroll(scrollOffset, rows.length, body);
6720
+ const summary = summarise(rows);
6721
+ return renderFleetDashboard({
6722
+ rows, selection, scrollOffset, filterQuery: fleetFilter, showFinished: fleetShowFinished,
6723
+ confirmation: confirm && confirm.until > Date.now()
6724
+ ? `press ${confirm.action === "kill" ? "x" : "r"} again to ${confirm.action} ${rows.find(r => r.key === confirm!.key)?.name ?? "agent"}`
6725
+ : undefined,
6726
+ summary: { ...summary, wallMs: unionMs(summary.intervals) },
6727
+ }, w, body, theme);
6728
+ },
6729
+ handleInput: async (data: string) => {
6730
+ const rows = fleetRows();
6731
+ reconcileSelection(selection, rows);
6732
+ const body = bodyRows(tui.terminal?.rows, FLEET_CHROME_ROWS);
6733
+ const state = { selection, scrollOffset, filtering, filterQuery: fleetFilter, showFinished: fleetShowFinished, confirm };
6734
+ const intent = dashboardTransition(toInput(data), state, rows, body);
6735
+ ({ scrollOffset, filtering, confirm } = state);
6736
+ fleetFilter = state.filterQuery;
6737
+ fleetShowFinished = state.showFinished;
6738
+ if (intent === "close") done();
6739
+ else if (intent && typeof intent === "object" && "open" in intent) {
6740
+ const selected = rows.find(r => r.key === intent.open) ?? rows[selection.index];
6741
+ if (selected) await openFleetDetail(selected, ctx);
6742
+ } else if (intent && typeof intent === "object" && "kill" in intent) {
6743
+ const selected = rows.find(r => r.key === intent.kill);
6744
+ if (!selected) ctx.ui.notify("Selected fleet row no longer exists.", "warning");
6745
+ else {
6746
+ const decision = resolveFleetKill(selected, {
6747
+ researchExists: (key) => !!researchStates.get(parseResearchHandle(key)!),
6748
+ agentHandles: (key) => {
6749
+ const agent = agentStates.get(key);
6750
+ return agent ? { proc: agent.proc, comsAbort: agent.comsAbort } : undefined;
6751
+ },
6752
+ });
6753
+ if (decision.action === "kill-research") {
6754
+ const rs = researchStates.get(parseResearchHandle(selected.key)!);
6755
+ if (rs) { removeResearchHelper(rs, ctx); ctx.ui.notify(decision.message, "info"); }
6756
+ else ctx.ui.notify(`Research ${selected.name} is no longer available.`, "warning");
6757
+ } else if (decision.action === "kill-proc") {
6758
+ const agent = agentStates.get(selected.key)!;
6759
+ agent.killedByOperator = true;
6760
+ cancelLocalOwnedProcess({ process: agent.proc, monitorBridge, monitorKey: monitorKeyForAgent(agent.def.name, agent.runCount), treeKill: killPiTree });
6761
+ ctx.ui.notify(decision.message, "info");
6762
+ } else if (decision.action === "coms-abort") {
6763
+ agentStates.get(selected.key)?.comsAbort?.();
6764
+ ctx.ui.notify(decision.message, "info");
6765
+ } else {
6766
+ ctx.ui.notify(decision.message, decision.level);
6767
+ }
6768
+ }
6769
+ } else if (intent && typeof intent === "object" && "restart" in intent) {
6770
+ const selected = rows.find(r => r.key === intent.restart);
6771
+ if (selected) await restartFleetRow(selected, ctx);
6772
+ }
6773
+ tui.requestRender();
6774
+ },
6775
+ invalidate() {},
6776
+ dispose: () => resources.dispose(),
6777
+ };
6778
+ }, FULLSCREEN_OVERLAY);
6779
+ } finally { resources.dispose(); }
6780
+ }
6781
+
6647
6782
  pi.registerCommand("af-agents-list", {
6648
- description: "List all loaded agents",
6783
+ description: "Open Fleet Dashboard",
6649
6784
  handler: async (_args, _ctx) => {
6650
6785
  widgetCtx = _ctx;
6651
- const names = Array.from(agentStates.values())
6652
- .map(s => {
6653
- const session = s.sessionFile ? "resumed" : "new";
6654
- const override = modelOverrides.get(s.def.name.toLowerCase());
6655
- const model = override ? `${override} (switched)` : (s.def.model || "dispatcher's");
6656
- const thinkOverride = thinkingOverrides.get(s.def.name.toLowerCase());
6657
- const thinking = thinkOverride
6658
- ? `${resolveThinkingLevel(thinkOverride)} (switched)`
6659
- : resolveThinkingLevel(s.def.thinking);
6660
- const switchedRoles = Object.keys(s.def.subagents || {})
6661
- .map(role => ({ role, m: subagentModelOverrides.get(`${s.def.name.toLowerCase()}.${role.toLowerCase()}`) }))
6662
- .filter((x): x is { role: string; m: string } => !!x.m);
6663
- const subLabel = switchedRoles.length
6664
- ? `, switched sub-roles: ${switchedRoles.map(x => `${x.role}→${shortModel(x.m)}`).join(", ")}`
6665
- : "";
6666
- return `${displayName(s.def.name)} (${s.status}, ${session}, model: ${model}, thinking: ${thinking}, runs: ${s.runCount}${subLabel}): ${s.def.description}`;
6667
- })
6668
- .join("\n");
6669
- _ctx.ui.notify(names || "No agents loaded", "info");
6786
+ await openFleetDashboard(_ctx);
6670
6787
  },
6671
6788
  });
6672
6789
 
@@ -6674,26 +6791,27 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6674
6791
  // a 1s tick so running durations advance live; `historyRender` lets a new
6675
6792
  // dispatch refresh the panel the instant it starts/ends.
6676
6793
  async function openHistory(ctx: any): Promise<void> {
6677
- let tick: ReturnType<typeof setInterval> | null = null;
6678
- await ctx.ui.custom((tui: any, theme: any, _kb: any, done: (r: unknown) => void) => {
6679
- const ui = new HistoryUI(
6680
- () => executionHistory,
6681
- () => (activeTeamName ? `Team: ${activeTeamName}` : "Agent Hub"),
6682
- () => done(undefined),
6683
- );
6684
- historyRender = () => tui.requestRender();
6685
- tick = setInterval(() => tui.requestRender(), 1000);
6686
- return {
6687
- render: (w: number) => ui.render(w, Math.max(10, Math.floor((tui.terminal?.rows ?? 36) * 0.85)), theme),
6688
- handleInput: (data: string) => ui.handleInput(data, tui),
6689
- invalidate: () => {},
6690
- };
6691
- }, {
6692
- overlay: true,
6693
- overlayOptions: { width: "80%", anchor: "center", maxHeight: "90%" },
6694
- });
6695
- if (tick) clearInterval(tick);
6696
- historyRender = null;
6794
+ const resources = createPanelResources();
6795
+ try {
6796
+ await ctx.ui.custom((tui: any, theme: any, _kb: any, done: (r: unknown) => void) => {
6797
+ const ui = new HistoryUI(
6798
+ () => executionHistory,
6799
+ () => (activeTeamName ? `Team: ${activeTeamName}` : "Agent Hub"),
6800
+ () => done(undefined),
6801
+ );
6802
+ historyRender = () => tui.requestRender();
6803
+ resources.every(1000, () => tui.requestRender());
6804
+ return {
6805
+ render: (w: number) => ui.render(w, bodyRows(tui.terminal?.rows, HISTORY_CHROME_ROWS), theme),
6806
+ handleInput: (data: string) => ui.handleInput(data, tui),
6807
+ invalidate: () => {},
6808
+ dispose: () => resources.dispose(),
6809
+ };
6810
+ }, FULLSCREEN_OVERLAY);
6811
+ } finally {
6812
+ resources.dispose();
6813
+ historyRender = null;
6814
+ }
6697
6815
  }
6698
6816
 
6699
6817
  pi.registerCommand("af-agents-history", {
@@ -6704,6 +6822,36 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6704
6822
  },
6705
6823
  });
6706
6824
 
6825
+ // ── /af-posture: direct operator ↔ restricted orchestrator ──
6826
+ pi.registerCommand("af-posture", {
6827
+ description: "Show or set the Fleet posture: operator (direct tools) | orchestrator (delegate-only)",
6828
+ handler: async (args, ctx) => {
6829
+ widgetCtx = ctx;
6830
+ const requested = (args || "").trim();
6831
+ if (!requested) {
6832
+ ctx.ui.notify(`${postureStatusText()}\nSwitch with /af-posture operator|orchestrator`, "info");
6833
+ return;
6834
+ }
6835
+ const next = parsePosture(requested);
6836
+ if (!next) {
6837
+ ctx.ui.notify(`Unknown posture "${requested}" — expected operator|orchestrator.`, "error");
6838
+ return;
6839
+ }
6840
+ if (orchestratorNeedsRoster(next, agentStates.size)) {
6841
+ ctx.ui.notify("Orchestrator posture requires at least one native specialist. Add one with /af-agents-add or select /af-agents-team first.", "warning");
6842
+ return;
6843
+ }
6844
+ posture = next;
6845
+ if (posture === "orchestrator" && personaGateEnabled && !personaGateSatisfied) {
6846
+ await pickDispatcherPersona(ctx);
6847
+ }
6848
+ applyPostureTools();
6849
+ updatePostureStatus(ctx);
6850
+ pi.appendEntry("agent-hub-posture", { posture });
6851
+ ctx.ui.notify(`${postureStatusText()}\nPrompt and tools update on the next model call.`, "success");
6852
+ },
6853
+ });
6854
+
6707
6855
  // ── /af-hub-mode: execution mode (fast|standard|strict) ──
6708
6856
  // Session-lifetime switch over the overrides-file default. Budgets bind on
6709
6857
  // the NEXT tool call (counters are per user turn and keep running); the
@@ -6822,7 +6970,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6822
6970
  const results = names.map(n => rosterAdd(n));
6823
6971
  const level = results.some(r => r.ok) ? "success" : "error";
6824
6972
  ctx.ui.notify(results.map(r => r.message).join("\n"), level as any);
6825
- ctx.ui.setStatus("agent-team", `Team: ${activeTeamName}* (${agentStates.size})`);
6973
+ ctx.ui.setStatus("agent-team", `Native roster: ${activeTeamName || "(none)"}* (${agentStates.size})`);
6826
6974
  },
6827
6975
  });
6828
6976
 
@@ -6838,7 +6986,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6838
6986
  const results = names.map(n => rosterDrop(n));
6839
6987
  const level = results.some(r => r.ok) ? "success" : "error";
6840
6988
  ctx.ui.notify(results.map(r => r.message).join("\n"), level as any);
6841
- ctx.ui.setStatus("agent-team", `Team: ${activeTeamName}* (${agentStates.size})`);
6989
+ ctx.ui.setStatus("agent-team", `Native roster: ${activeTeamName || "(none)"}* (${agentStates.size})`);
6842
6990
  },
6843
6991
  });
6844
6992
 
@@ -6912,15 +7060,16 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6912
7060
  // session-rename), and alt+a is not consumed by the editor, so it reaches the
6913
7061
  // extension shortcut handler in the main input.
6914
7062
  pi.registerShortcut("alt+a", {
6915
- description: "Toggle agent view: dashboard ↔ compact",
7063
+ description: "Open Fleet Dashboard",
6916
7064
  handler: (ctx) => {
6917
7065
  widgetCtx = ctx;
6918
- viewMode = viewMode === "dashboard" ? "compact" : "dashboard";
6919
- updateWidget();
6920
- updateResearchWidget();
6921
- ctx.ui.notify(`Agent view: ${viewMode}`, "info");
7066
+ void openFleetDashboard(ctx);
6922
7067
  },
6923
7068
  });
7069
+ pi.registerShortcut("alt+shift+a", {
7070
+ description: "Toggle compact agent widget",
7071
+ handler: (ctx) => { widgetCtx = ctx; viewMode = viewMode === "compact" ? "off" : "compact"; updateWidget(); updateResearchWidget(); ctx.ui.notify(`Compact agent widget: ${viewMode}`, "info"); },
7072
+ });
6924
7073
 
6925
7074
  // Compact-view agent switcher. Alt+] / Alt+[ move the marker through the running
6926
7075
  // subagents; Alt+\ zooms the marked one (same overlay as /af-zoom). main is never a
@@ -6931,7 +7080,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6931
7080
  // eaten by the escape parser — alt+] and alt+\ are the reliable pair.
6932
7081
  function cycleMarker(delta: number, ctx: any) {
6933
7082
  widgetCtx = ctx;
6934
- if (viewMode !== "compact") {
7083
+ if (!compactWidgetsEnabled(viewMode)) {
6935
7084
  ctx.ui.notify("Agent switching is a compact-view feature — press Alt+A first", "info");
6936
7085
  return;
6937
7086
  }
@@ -6959,7 +7108,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6959
7108
  description: "Compact view: zoom the marked subagent",
6960
7109
  handler: async (ctx) => {
6961
7110
  widgetCtx = ctx;
6962
- if (viewMode !== "compact") {
7111
+ if (!compactWidgetsEnabled(viewMode)) {
6963
7112
  ctx.ui.notify("Agent zoom from the marker is a compact-view feature — press Alt+A first", "info");
6964
7113
  return;
6965
7114
  }
@@ -6976,7 +7125,9 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6976
7125
  ctx.ui.notify(`Marked agent ${markedAgent} is no longer available`, "warning");
6977
7126
  return;
6978
7127
  }
6979
- await openZoom(target, ctx);
7128
+ const row = fleetRows(true).find(r => r.key === markedAgent);
7129
+ if (row) await openFleetDetail(row, ctx);
7130
+ else await openZoom(target, ctx);
6980
7131
  },
6981
7132
  });
6982
7133
 
@@ -6995,7 +7146,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6995
7146
  function findDelegationChild(arg: string): { child: DelegationChild; owner: AgentState } | null {
6996
7147
  const lower = arg.toLowerCase();
6997
7148
  for (const st of agentStates.values()) {
6998
- const child = st.delegations?.get(lower);
7149
+ const child = Array.from(st.delegations?.values() ?? []).find(candidate => candidate.id.toLowerCase() === lower);
6999
7150
  if (child) return { child, owner: st };
7000
7151
  }
7001
7152
  return null;
@@ -7029,28 +7180,30 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
7029
7180
  // parser refresh it on new events (throttled to ~12fps; force=true pushes the
7030
7181
  // final frame on completion).
7031
7182
  async function openZoom(target: Zoomable, ctx: any): Promise<void> {
7183
+ const resources = createPanelResources();
7032
7184
  let lastRender = 0;
7033
- await ctx.ui.custom((tui: any, theme: any, _kb: any, done: (r: unknown) => void) => {
7034
- const ui = new ZoomUI(target, () => done(undefined), (message, type) => ctx.ui.notify(message, type as any));
7035
- target.zoomRender = (force?: boolean) => {
7036
- const now = Date.now();
7037
- if (force || now - lastRender > 80) {
7038
- lastRender = now;
7039
- tui.requestRender();
7040
- }
7041
- };
7042
- return {
7043
- // Pass the real terminal height (not a hard-coded 30) so the
7044
- // height-aware scroll keeps the selected/last entry fully visible.
7045
- render: (w: number) => ui.render(w, Math.max(10, Math.floor(((tui.terminal?.rows ?? 36) * 0.85))), theme),
7046
- handleInput: (data: string) => ui.handleInput(data, tui),
7047
- invalidate: () => {},
7048
- };
7049
- }, {
7050
- overlay: true,
7051
- overlayOptions: { width: "80%", anchor: "center", maxHeight: "90%" },
7052
- });
7053
- target.zoomRender = undefined;
7185
+ try {
7186
+ await ctx.ui.custom((tui: any, theme: any, _kb: any, done: (r: unknown) => void) => {
7187
+ const ui = new ZoomUI(target, () => done(undefined), (message, type) => ctx.ui.notify(message, type as any));
7188
+ target.zoomRender = (force?: boolean) => {
7189
+ const now = Date.now();
7190
+ if (force || now - lastRender > 80) {
7191
+ lastRender = now;
7192
+ tui.requestRender();
7193
+ }
7194
+ };
7195
+ resources.onDispose(() => { target.zoomRender = undefined; });
7196
+ return {
7197
+ render: (w: number) => ui.render(w, bodyRows(tui.terminal?.rows, ZOOM_CHROME_ROWS), theme),
7198
+ handleInput: (data: string) => ui.handleInput(data, tui),
7199
+ invalidate: () => {},
7200
+ dispose: () => resources.dispose(),
7201
+ };
7202
+ }, FULLSCREEN_OVERLAY);
7203
+ } finally {
7204
+ resources.dispose();
7205
+ target.zoomRender = undefined;
7206
+ }
7054
7207
  }
7055
7208
 
7056
7209
  pi.registerCommand("af-zoom", {
@@ -7077,7 +7230,10 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
7077
7230
  ctx.ui.notify(`Usage: /af-zoom <name|rN|child-id>. Known: ${known || "none"}`, "error");
7078
7231
  return;
7079
7232
  }
7080
- await openZoom(target, ctx);
7233
+ const rowKey = (rid != null ? `r${rid}` : arg).toLowerCase();
7234
+ const row = fleetRows(true).find(r => r.key.toLowerCase() === rowKey);
7235
+ if (row) await openFleetDetail(row, ctx);
7236
+ else await openZoom(target, ctx);
7081
7237
  },
7082
7238
  });
7083
7239
 
@@ -8041,6 +8197,9 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
8041
8197
  // ── System Prompt Override ───────────────────
8042
8198
 
8043
8199
  pi.on("before_agent_start", async (_event, _ctx) => {
8200
+ // Re-assert the selected posture for every turn so prompt and tool policy stay
8201
+ // synchronized after commands or runtime capability changes.
8202
+ applyPostureTools();
8044
8203
  // Open a fresh dispatcher turn for /af-agents-history. The orchestrator entry is
8045
8204
  // created lazily (only if this turn actually dispatches), so chat-only turns
8046
8205
  // add no history rows. Defensively close any entry a prior turn left open
@@ -8322,14 +8481,14 @@ your own team you can talk to the peers in your coms POOL — the agents shown i
8322
8481
  `
8323
8482
  : "";
8324
8483
 
8325
- const orchestratorPrompt = `You are a dispatcher agent — an orchestrator. You coordinate specialist agents
8326
- to accomplish tasks. You do NOT have direct access to the codebase. You have ${toolList}.
8484
+ const postureText = posturePrompt(posture);
8485
+ const orchestratorPrompt = `${postureText.intro} You have ${toolList}.
8327
8486
 
8328
8487
  ## Language
8329
8488
  ${languageLines}
8330
8489
 
8331
- ## Active Team: ${activeTeamName}
8332
- Members: ${teamMembers}
8490
+ ## Native Roster: ${activeTeamName || "(none)"}
8491
+ Members: ${teamMembers || "(none — add a persona before using dispatch_agent)"}
8333
8492
  You can ONLY dispatch to agents listed below. Do not attempt to dispatch to agents
8334
8493
  outside this team. The roster CAN change mid-session: the human via /af-agents-add,
8335
8494
  /af-agents-drop, /af-agents-team — or you via \`team_adjust\` (add/drop with a reason)
@@ -8340,6 +8499,7 @@ personas is usually the wrong answer.
8340
8499
  - Analyze the user's request and break it into clear sub-tasks.
8341
8500
  - Choose the right agent(s) for each sub-task.
8342
8501
  ${dispatchSection}
8502
+ - Choose \`backend: native\` when the user explicitly requests a local Pi specialist, \`backend: coms\` when they explicitly request a live same-name peer, and \`backend: auto\` otherwise. Never substitute one explicit backend for another.
8343
8503
  - Review results and dispatch follow-up agents if needed.
8344
8504
  - If a task fails, try a different agent or adjust the task description.
8345
8505
  - Summarize the outcome for the user in ${userLanguage}.
@@ -8365,10 +8525,12 @@ ${verificationSection}
8365
8525
  ${comsSection}${herdrFleetReady ? `
8366
8526
  ## Fleet (herdr)
8367
8527
  This session runs inside a herdr workspace and can drive panes:
8368
- - \`herdr_spawn_peer\` stands up an extra worker next to you — a persona peer (joins the coms
8369
- pool, then talk to it via \`coms_send\`) or a raw command pane (a build watcher, a server).
8370
- Spawn deliberately; every pane is a process the human sees. Tear down what you spawned.
8371
- - A spawned persona peer BOOTS IDLE and waits for \`coms_send\`: the spawn hands it no task.
8528
+ - \`herdr_spawn_peer\` starts an addressable Pi persona, personaless Fleet Core, or Claude Code
8529
+ peer next to you. Name-only calls inherit peers.yaml; explicit fields use the same resolver as
8530
+ \`just fleet peer\`. Every peer is locked to this Hub's coms project.
8531
+ - \`herdr_spawn_pane\` starts a raw command pane (for example a build watcher or server). It is
8532
+ not a coms peer and has no readiness result. Spawn deliberately; every pane is human-visible.
8533
+ - A spawned peer BOOTS IDLE and waits for \`coms_send\`: the spawn hands it no task.
8372
8534
  The call waits for it to register and returns \`peer_ready\` with its coms name. Spawn one
8373
8535
  only immediately before the first message you will send it — a peer spawned "to have it
8374
8536
  ready" and never addressed is an empty pane named like a worker. If you sent it no work
@@ -8388,8 +8550,7 @@ This session runs inside a herdr workspace and can drive panes:
8388
8550
  a long fleet task finishes or needs attention; it does not replace \`ask_user\`.
8389
8551
  ` : ""}
8390
8552
  ## Hard Rules
8391
- - NEVER try to read, write, or execute code directly — you have no such tools.
8392
- - ALWAYS use \`dispatch_agent\` to get work done; use \`spawn_research\` for read-only recon.
8553
+ ${postureText.hardRules}
8393
8554
  ${ambiguityRule}
8394
8555
  - You can chain agents: spawn_research to gather context, builder to implement.
8395
8556
  - You can dispatch the same agent multiple times with different tasks.
@@ -8415,7 +8576,7 @@ ${researchCatalog}`;
8415
8576
 
8416
8577
  // ── Persona gate: block input until a dispatcher persona is picked ──
8417
8578
  pi.on("input", async (_event, ctx) => {
8418
- if (personaGateEnabled && !personaGateSatisfied) {
8579
+ if (posture === "orchestrator" && personaGateEnabled && !personaGateSatisfied) {
8419
8580
  ctx.ui.notify("Pick a dispatcher persona first (see the select dialog).", "warning");
8420
8581
  return { action: "handled" as const };
8421
8582
  }
@@ -8426,6 +8587,9 @@ ${researchCatalog}`;
8426
8587
 
8427
8588
  pi.on("session_start", async (_event, _ctx) => {
8428
8589
  registerVersionStatus(_ctx);
8590
+ // Capture the configured surface before Agent Hub applies either posture.
8591
+ // Operator mode restores this baseline (minus gated Hub-owned tools).
8592
+ baselineTools = pi.getActiveTools();
8429
8593
  accessApprovalRouter.reset();
8430
8594
  // Clear widgets + any research helpers from a previous session
8431
8595
  for (const [, st] of Array.from(researchStates.entries())) {
@@ -8829,34 +8993,35 @@ ${researchCatalog}`;
8829
8993
  personaGateEnabled = overrides.personaGate && orchestratorPersonas.length > 0;
8830
8994
  personaGateSatisfied = !personaGateEnabled;
8831
8995
 
8832
- // Default to first team — use /af-agents-team to switch
8833
- const teamNames = Object.keys(teams);
8834
- if (teamNames.length > 0) {
8835
- activateTeam(teamNames[0]);
8996
+ // A roster is opt-in. Resolve it before posture so --agent-team can imply
8997
+ // orchestrator while an explicit --posture operator still wins.
8998
+ agentStates.clear();
8999
+ activeTeamName = "";
9000
+ comsMissNotified.clear();
9001
+ recomputeGrid();
9002
+ const startupRoster = resolveStartupRoster(teams, pi.getFlag("agent-team"));
9003
+ posture = resolveSessionPosture({
9004
+ entries: _ctx.sessionManager.getEntries(),
9005
+ explicitPosture: pi.getFlag("posture"),
9006
+ hasExplicitRoster: startupRoster !== null,
9007
+ });
9008
+ if (orchestratorNeedsRoster(posture, startupRoster?.members.length ?? 0)) {
9009
+ throw new Error("Orchestrator posture requires --agent-team <name> with at least one native specialist.");
8836
9010
  }
9011
+ if (startupRoster) activateTeam(startupRoster.name);
8837
9012
 
8838
9013
  // Probe for `ask_user` (registered by the `pi-ask-user` companion package
8839
9014
  // when installed). Action methods like getAllTools are runtime-only, so
8840
9015
  // this MUST happen at session_start, not at extension load.
8841
9016
  askUserAvailable = pi.getAllTools().some(t => t.name === "ask_user");
8842
9017
 
8843
- // Dispatcher's tool surface: dispatch_agent + spawn_research always; the
8844
- // assertion-ledger tools (set/update/get) own the Verification Contract —
8845
- // get_assertions is the bounded read-only recovery path so the dispatcher can
8846
- // re-read the full ledger after a compaction (the status line shows only counts).
8847
- // The coms_* tools when the peer layer bound successfully; ask_user only when
8848
- // pi-ask-user is installed. Per decision G4 the dispatcher persona NEVER narrows
8849
- // this surface.
8850
- const dispatcherTools = ["dispatch_agent", "spawn_research", "set_task_tier", "team_adjust", "set_assertions", "update_assertion", "get_assertions"];
8851
- if (comsReady) dispatcherTools.push("coms_list", "coms_send", "coms_get", "coms_await");
8852
- if (askUserAvailable) dispatcherTools.push("ask_user");
8853
- // Fleet tools only inside a herdr pane with a live server (graceful
8854
- // degradation like coms — outside herdr the tools are absent).
9018
+ // Fleet tools are available only inside a herdr pane with a live server.
9019
+ // The posture policy adds gated groups without activating unavailable tools.
8855
9020
  herdrFleetReady = herdrPaneId() !== null && (await herdrAvailable()) !== null;
8856
- if (herdrFleetReady) dispatcherTools.push("herdr_spawn_peer", "herdr_read_pane", "herdr_close_pane", "herdr_notify");
8857
- pi.setActiveTools(dispatcherTools);
9021
+ applyPostureTools();
9022
+ updatePostureStatus(_ctx);
8858
9023
 
8859
- _ctx.ui.setStatus("agent-team", `Team: ${activeTeamName} (${agentStates.size})`);
9024
+ _ctx.ui.setStatus("agent-team", `Native roster: ${activeTeamName || "(none)"} (${agentStates.size})`);
8860
9025
  const members = Array.from(agentStates.values()).map(s => displayName(s.def.name)).join(", ");
8861
9026
  const askUserLabel = askUserAvailable
8862
9027
  ? "available (via pi-ask-user)"
@@ -8883,16 +9048,18 @@ ${researchCatalog}`;
8883
9048
  ? `coms-preferred: ${comsPreferred.join(", ")} (live peer wins, /af-dispatch-policy for status)`
8884
9049
  : "all native (no substitutions in .pi/agents/dispatch-policy.yaml)";
8885
9050
  _ctx.ui.notify(
8886
- `Team: ${activeTeamName} (${members})\n` +
8887
- `Team sets loaded from: .pi/agents/teams.yaml\n` +
9051
+ `Posture: ${posture} (${posture === "operator" ? "direct tools enabled" : "delegate-only"})\n` +
9052
+ `Native roster: ${activeTeamName || "(none)"} (${agentStates.size}${members ? `: ${members}` : ""})\n` +
9053
+ `Native roster sets loaded from: .pi/agents/teams.yaml\n` +
8888
9054
  `Dispatch backends: ${dispatchLabel}\n` +
8889
9055
  `User-facing language: ${userLanguage} (override in .ai/agent-fleet-overrides.md)\n` +
8890
9056
  `ask_user: ${askUserLabel}; specialists bubble up via ASK_USER:\n` +
8891
9057
  `Persona gate: ${personaGateLabel}\n` +
8892
9058
  `Coms: ${comsLabel}\n` +
8893
9059
  `Fleet: ${fleetLabel}\n\n` +
9060
+ `/af-posture [mode] Show/switch operator|orchestrator posture\n` +
8894
9061
  `/af-agents-team Select a team\n` +
8895
- `/af-agents-list List active agents and status\n` +
9062
+ `/af-agents-list Open Fleet Dashboard\n` +
8896
9063
  `/af-agents-history Timeline of agent runs — durations, parallel markers, grand total\n` +
8897
9064
  `/af-agent-model <persona>[.<role>] Switch a persona's or sub-role's model\n` +
8898
9065
  `/af-agent-model-thinking <persona> Switch a persona's thinking level\n` +
@@ -8915,8 +9082,9 @@ ${researchCatalog}`;
8915
9082
  _ctx.ui.setStatus("dispatcher-persona", personaGateEnabled ? "Persona: (pick one)" : "Persona: Default");
8916
9083
  updateWidget();
8917
9084
 
8918
- // Fire the blocking persona gate (input stays swallowed until satisfied).
8919
- if (personaGateEnabled) {
9085
+ // The persona gate restricts only orchestrator posture. Operators can work
9086
+ // directly and choose a dispatcher persona later without being blocked.
9087
+ if (posture === "orchestrator" && personaGateEnabled) {
8920
9088
  void pickDispatcherPersona(_ctx);
8921
9089
  }
8922
9090
 
@@ -8937,7 +9105,7 @@ ${researchCatalog}`;
8937
9105
  const bar = "#".repeat(filled) + "-".repeat(10 - filled);
8938
9106
 
8939
9107
  const left = renderHubFooterLeft(theme, HARNESS_VERSION, model, think, activeTeamName);
8940
- const hint = theme.fg("muted", "Alt+A ") + theme.fg("dim", `view:${viewMode}`);
9108
+ const hint = theme.fg("dim", composeFleetFooterHint(viewMode));
8941
9109
  // The btw extension flips this global the first time a /af-btw command or
8942
9110
  // Alt+' is used; surface its reopen shortcut right next to the Alt+A hint.
8943
9111
  const btwHint = (globalThis as { __btwActivated?: boolean }).__btwActivated