@chankov/agent-fleet 0.0.11 → 1.0.1

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 (771) hide show
  1. package/.pi/agents/model-profiles.yaml +2 -2
  2. package/.pi/extensions/agent-fleet-update-check/README.md +4 -4
  3. package/.pi/extensions/btw/README.md +26 -25
  4. package/.pi/extensions/btw/index.ts +80 -83
  5. package/.pi/extensions/pi-voice-stt/README.md +4 -3
  6. package/.pi/extensions/pi-voice-stt/config.ts +1 -1
  7. package/.pi/harnesses/agent-hub/README.md +118 -57
  8. package/.pi/harnesses/agent-hub/backend-policy.js +25 -4
  9. package/.pi/harnesses/agent-hub/footer.ts +4 -0
  10. package/.pi/harnesses/agent-hub/helpers.ts +18 -0
  11. package/.pi/harnesses/agent-hub/hub-state-audit.js +55 -0
  12. package/.pi/harnesses/agent-hub/index.ts +657 -425
  13. package/.pi/harnesses/agent-hub/monitor-session-bridge.ts +10 -1
  14. package/.pi/harnesses/agent-hub/package.json +1 -1
  15. package/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
  16. package/.pi/harnesses/agent-hub/posture.ts +103 -0
  17. package/.pi/harnesses/agent-hub/run-budget.js +61 -0
  18. package/.pi/harnesses/ask-user-remote/README.md +37 -3
  19. package/.pi/harnesses/ask-user-remote/index.ts +173 -17
  20. package/.pi/harnesses/coms/package.json +1 -1
  21. package/.pi/harnesses/damage-control-continue/package.json +1 -1
  22. package/.pi/harnesses/lib/fleet-dashboard-ops.ts +155 -0
  23. package/.pi/harnesses/lib/fleet-dashboard-view.ts +140 -0
  24. package/.pi/harnesses/lib/fleet-detail-view.ts +43 -0
  25. package/.pi/harnesses/lib/fleet-overlay.ts +26 -0
  26. package/.pi/harnesses/lib/fleet-panel.ts +34 -0
  27. package/.pi/harnesses/lib/fleet-read-model.ts +131 -0
  28. package/.pi/harnesses/lib/fleet-selection.ts +24 -0
  29. package/.pi/harnesses/package-lock.json +2011 -0
  30. package/.pi/harnesses/package.json +1 -0
  31. package/.versions/0.0.11/.pi/extensions/agent-fleet-update-check/README.md +4 -4
  32. package/.versions/0.0.11/.pi/extensions/pi-voice-stt/README.md +4 -3
  33. package/.versions/0.0.11/.pi/extensions/pi-voice-stt/config.ts +1 -1
  34. package/.versions/0.0.11/.pi/harnesses/agent-hub/monitor-session-bridge.ts +10 -1
  35. package/.versions/0.0.11/.pi/harnesses/ask-user-remote/README.md +37 -3
  36. package/.versions/0.0.11/.pi/harnesses/ask-user-remote/index.ts +173 -17
  37. package/.versions/0.0.11/.pi/harnesses/package-lock.json +2011 -0
  38. package/.versions/0.0.11/.pi/harnesses/package.json +1 -0
  39. package/.versions/0.0.11/docs/ARCHITECTURE.md +6 -8
  40. package/.versions/0.0.11/docs/agent-fleet-setup.md +17 -43
  41. package/.versions/0.0.11/docs/claude-code-coms-bridge.md +20 -2
  42. package/.versions/0.0.11/docs/coms-hermes-bridge.md +1 -1
  43. package/.versions/0.0.11/docs/getting-started.md +26 -237
  44. package/.versions/0.0.11/docs/npm-install.md +60 -478
  45. package/.versions/0.0.11/docs/pi-extensions.md +4 -4
  46. package/.versions/0.0.11/docs/pi-setup.md +37 -551
  47. package/.versions/0.0.11/hermes/README.md +1 -1
  48. package/.versions/0.0.11/install-manifest.json +375 -1247
  49. package/.versions/0.0.11/justfile +13 -6
  50. package/.versions/0.0.11/manifest-meta.json +543 -134
  51. package/.versions/0.0.11/scripts/lib/fleet-command.ts +8 -0
  52. package/.versions/0.0.11/scripts/lib/monitor-env.ts +18 -6
  53. package/.versions/0.0.11/skills/designing-agents/SKILL.md +1 -1
  54. package/.versions/0.0.11/skills/designing-agents/pi-harness-authoring.md +1 -1
  55. package/.versions/1.0.0/.pi/agents/dispatch-policy.yaml +32 -0
  56. package/.versions/1.0.0/.pi/agents/model-profiles.yaml +27 -0
  57. package/.versions/1.0.0/.pi/agents/peers.yaml +142 -0
  58. package/.versions/1.0.0/.pi/agents/teams.yaml +41 -0
  59. package/.versions/1.0.0/.pi/damage-control-rules.yaml +297 -0
  60. package/.versions/1.0.0/.pi/extensions/agent-fleet-update-check/README.md +57 -0
  61. package/.versions/1.0.0/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
  62. package/.versions/1.0.0/.pi/extensions/agent-fleet-update-check/package.json +6 -0
  63. package/.versions/1.0.0/.pi/extensions/btw/README.md +120 -0
  64. package/.versions/1.0.0/.pi/extensions/btw/index.ts +914 -0
  65. package/.versions/1.0.0/.pi/extensions/btw/package.json +6 -0
  66. package/.versions/1.0.0/.pi/extensions/btw/state.js +179 -0
  67. package/.versions/1.0.0/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
  68. package/.versions/1.0.0/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
  69. package/.versions/1.0.0/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  70. package/.versions/1.0.0/.pi/extensions/compact-and-continue/README.md +42 -0
  71. package/.versions/1.0.0/.pi/extensions/compact-and-continue/index.ts +120 -0
  72. package/.versions/1.0.0/.pi/extensions/compact-and-continue/package.json +6 -0
  73. package/.versions/1.0.0/.pi/extensions/mcp-bridge/README.md +46 -0
  74. package/.versions/1.0.0/.pi/extensions/mcp-bridge/index.ts +206 -0
  75. package/.versions/1.0.0/.pi/extensions/mcp-bridge/package.json +6 -0
  76. package/.versions/1.0.0/.pi/extensions/package-lock.json +1143 -0
  77. package/.versions/1.0.0/.pi/extensions/package.json +9 -0
  78. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/README.md +205 -0
  79. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/config.ts +198 -0
  80. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  81. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/index.ts +248 -0
  82. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/package.json +6 -0
  83. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  84. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  85. package/.versions/1.0.0/.pi/harnesses/agent-hub/README.md +1056 -0
  86. package/.versions/1.0.0/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  87. package/.versions/1.0.0/.pi/harnesses/agent-hub/artifacts.js +146 -0
  88. package/.versions/1.0.0/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
  89. package/.versions/1.0.0/.pi/harnesses/agent-hub/backend-policy.js +174 -0
  90. package/.versions/1.0.0/.pi/harnesses/agent-hub/context-window.js +106 -0
  91. package/.versions/1.0.0/.pi/harnesses/agent-hub/delegate.ts +435 -0
  92. package/.versions/1.0.0/.pi/harnesses/agent-hub/docs-lane.js +122 -0
  93. package/.versions/1.0.0/.pi/harnesses/agent-hub/drift-watchdog.js +211 -0
  94. package/.versions/1.0.0/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  95. package/.versions/1.0.0/.pi/harnesses/agent-hub/external-blocker.js +85 -0
  96. package/.versions/1.0.0/.pi/harnesses/agent-hub/footer.ts +35 -0
  97. package/.versions/1.0.0/.pi/harnesses/agent-hub/helpers.ts +266 -0
  98. package/.versions/1.0.0/.pi/harnesses/agent-hub/index.ts +9279 -0
  99. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  100. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
  101. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
  102. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  103. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  104. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  105. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  106. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
  107. package/.versions/1.0.0/.pi/harnesses/agent-hub/package.json +7 -0
  108. package/.versions/1.0.0/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
  109. package/.versions/1.0.0/.pi/harnesses/agent-hub/posture.ts +103 -0
  110. package/.versions/1.0.0/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
  111. package/.versions/1.0.0/.pi/harnesses/agent-hub/research-retention.js +34 -0
  112. package/.versions/1.0.0/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  113. package/.versions/1.0.0/.pi/harnesses/agent-hub/return-contract.js +293 -0
  114. package/.versions/1.0.0/.pi/harnesses/agent-hub/return-extract.js +75 -0
  115. package/.versions/1.0.0/.pi/harnesses/agent-hub/review-findings.js +102 -0
  116. package/.versions/1.0.0/.pi/harnesses/agent-hub/run-budget.js +479 -0
  117. package/.versions/1.0.0/.pi/harnesses/agent-hub/run-namespace.js +87 -0
  118. package/.versions/1.0.0/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  119. package/.versions/1.0.0/.pi/harnesses/agent-hub/scope-gate.js +103 -0
  120. package/.versions/1.0.0/.pi/harnesses/agent-hub/session-health.js +110 -0
  121. package/.versions/1.0.0/.pi/harnesses/agent-hub/spawn.ts +354 -0
  122. package/.versions/1.0.0/.pi/harnesses/agent-hub/version.ts +42 -0
  123. package/.versions/1.0.0/.pi/harnesses/ask-user-remote/README.md +53 -0
  124. package/.versions/1.0.0/.pi/harnesses/ask-user-remote/index.ts +477 -0
  125. package/.versions/1.0.0/.pi/harnesses/ask-user-remote/race-core.js +106 -0
  126. package/.versions/1.0.0/.pi/harnesses/coms/README.md +100 -0
  127. package/.versions/1.0.0/.pi/harnesses/coms/index.ts +1767 -0
  128. package/.versions/1.0.0/.pi/harnesses/coms/package.json +7 -0
  129. package/.versions/1.0.0/.pi/harnesses/coms/version.ts +42 -0
  130. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/README.md +124 -0
  131. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/index.ts +536 -0
  132. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/package.json +7 -0
  133. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/version.ts +42 -0
  134. package/.versions/1.0.0/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
  135. package/.versions/1.0.0/.pi/harnesses/lib/damage-control-shared.ts +197 -0
  136. package/.versions/1.0.0/.pi/harnesses/lib/fleet-dashboard-ops.ts +118 -0
  137. package/.versions/1.0.0/.pi/harnesses/lib/fleet-dashboard-view.ts +140 -0
  138. package/.versions/1.0.0/.pi/harnesses/lib/fleet-detail-view.ts +43 -0
  139. package/.versions/1.0.0/.pi/harnesses/lib/fleet-overlay.ts +26 -0
  140. package/.versions/1.0.0/.pi/harnesses/lib/fleet-panel.ts +34 -0
  141. package/.versions/1.0.0/.pi/harnesses/lib/fleet-read-model.ts +131 -0
  142. package/.versions/1.0.0/.pi/harnesses/lib/fleet-selection.ts +24 -0
  143. package/.versions/1.0.0/.pi/harnesses/lib/herdr-client.ts +472 -0
  144. package/.versions/1.0.0/.pi/harnesses/lib/herdr-presence.ts +399 -0
  145. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
  146. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
  147. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
  148. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
  149. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
  150. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
  151. package/.versions/1.0.0/.pi/harnesses/lib/spawned-peers.js +190 -0
  152. package/.versions/1.0.0/.pi/harnesses/package-lock.json +2046 -0
  153. package/.versions/1.0.0/.pi/harnesses/package.json +10 -0
  154. package/.versions/1.0.0/.pi/prompts/af-build.md +24 -0
  155. package/{.claude/commands/code-simplify.md → .versions/1.0.0/.pi/prompts/af-code-simplify.md} +3 -3
  156. package/{.claude/commands/plan.md → .versions/1.0.0/.pi/prompts/af-plan.md} +1 -1
  157. package/.versions/{0.0.11/.claude/commands/review.md → 1.0.0/.pi/prompts/af-review.md} +3 -3
  158. package/.versions/1.0.0/.pi/prompts/af-set-hermes-watchdog.md +6 -0
  159. package/.versions/1.0.0/.pi/prompts/af-ship.md +17 -0
  160. package/.versions/{0.0.11/.claude/commands/spec.md → 1.0.0/.pi/prompts/af-spec.md} +1 -1
  161. package/.versions/{0.0.11/.claude/commands/test.md → 1.0.0/.pi/prompts/af-test.md} +2 -2
  162. package/.versions/1.0.0/.pi/skills/bowser/SKILL.md +145 -0
  163. package/.versions/1.0.0/.version +1 -0
  164. package/.versions/1.0.0/agents/architect.md +24 -0
  165. package/.versions/1.0.0/agents/bowser.md +27 -0
  166. package/.versions/1.0.0/agents/builder.md +54 -0
  167. package/.versions/1.0.0/agents/code-reviewer.md +208 -0
  168. package/.versions/1.0.0/agents/deep-researcher.md +32 -0
  169. package/.versions/1.0.0/agents/documenter.md +18 -0
  170. package/.versions/1.0.0/agents/orchestrator.md +72 -0
  171. package/.versions/1.0.0/agents/plan-reviewer.md +83 -0
  172. package/.versions/1.0.0/agents/planner.md +70 -0
  173. package/.versions/1.0.0/agents/releaser.md +24 -0
  174. package/.versions/1.0.0/agents/researcher.md +28 -0
  175. package/.versions/1.0.0/agents/security-auditor.md +167 -0
  176. package/.versions/1.0.0/agents/test-engineer.md +153 -0
  177. package/.versions/1.0.0/agents/web-debugger.md +43 -0
  178. package/.versions/1.0.0/agents/web-performance-auditor.md +193 -0
  179. package/.versions/1.0.0/codex/CONDUCTOR.md +148 -0
  180. package/.versions/1.0.0/docs/ARCHITECTURE.md +337 -0
  181. package/.versions/1.0.0/docs/agent-fleet-setup.md +437 -0
  182. package/.versions/1.0.0/docs/claude-code-coms-bridge.md +128 -0
  183. package/.versions/1.0.0/docs/codex-remote-conductor.md +170 -0
  184. package/.versions/1.0.0/docs/coms-hermes-bridge.md +189 -0
  185. package/.versions/1.0.0/docs/getting-started.md +98 -0
  186. package/.versions/1.0.0/docs/npm-install.md +292 -0
  187. package/.versions/1.0.0/docs/pi-extensions.md +412 -0
  188. package/.versions/1.0.0/docs/pi-setup.md +74 -0
  189. package/.versions/1.0.0/docs/skill-anatomy.md +150 -0
  190. package/.versions/1.0.0/hermes/README.md +347 -0
  191. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
  192. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
  193. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  194. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  195. package/.versions/1.0.0/hermes/gates/gate-o-capability.md +8 -0
  196. package/.versions/1.0.0/hermes/gates/gate-o-validator-fixtures.json +1 -0
  197. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
  198. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
  199. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
  200. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
  201. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
  202. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
  203. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
  204. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
  205. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
  206. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
  207. package/.versions/1.0.0/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
  208. package/.versions/1.0.0/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  209. package/.versions/1.0.0/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  210. package/.versions/1.0.0/hermes/skills/hub-conductor/SKILL.md +84 -0
  211. package/.versions/1.0.0/hermes/skills/hub-liaison/SKILL.md +84 -0
  212. package/.versions/1.0.0/hermes/skills/hub-watchdog/SKILL.md +76 -0
  213. package/.versions/1.0.0/hermes/skills/hub-watchdog/manifest.json +1 -0
  214. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
  215. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
  216. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
  217. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
  218. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
  219. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
  220. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
  221. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
  222. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
  223. package/.versions/1.0.0/hermes/watchdog-tests/__init__.py +0 -0
  224. package/.versions/1.0.0/hooks/coms-stop-hook.mjs +84 -0
  225. package/.versions/1.0.0/install-manifest.json +2745 -0
  226. package/.versions/1.0.0/justfile +272 -0
  227. package/.versions/1.0.0/manifest-meta.json +882 -0
  228. package/.versions/1.0.0/references/accessibility-checklist.md +160 -0
  229. package/.versions/1.0.0/references/definition-of-done.md +67 -0
  230. package/.versions/1.0.0/references/fleet-coordination-patterns.md +151 -0
  231. package/.versions/1.0.0/references/observability-checklist.md +91 -0
  232. package/.versions/1.0.0/references/orchestration-patterns.md +370 -0
  233. package/.versions/1.0.0/references/performance-checklist.md +153 -0
  234. package/.versions/1.0.0/references/prompting-patterns.md +380 -0
  235. package/.versions/1.0.0/references/security-checklist.md +179 -0
  236. package/.versions/1.0.0/references/testing-patterns.md +236 -0
  237. package/.versions/1.0.0/scripts/codex-conductor.ts +41 -0
  238. package/.versions/1.0.0/scripts/codex-remote-control.ts +167 -0
  239. package/.versions/1.0.0/scripts/coms-claude-bridge.ts +411 -0
  240. package/.versions/1.0.0/scripts/coms-cli.ts +484 -0
  241. package/.versions/1.0.0/scripts/coms-hermes-bridge.ts +413 -0
  242. package/.versions/1.0.0/scripts/fleet.ts +185 -0
  243. package/.versions/1.0.0/scripts/hermes-monitor-capability-runner.ts +25 -0
  244. package/.versions/1.0.0/scripts/hermes-monitor-scenario.ts +474 -0
  245. package/.versions/1.0.0/scripts/hermes-watchdog-capability-probe.ts +45 -0
  246. package/.versions/1.0.0/scripts/install-hermes-plugin.sh +180 -0
  247. package/.versions/1.0.0/scripts/lib/claude-bridge-core.ts +210 -0
  248. package/.versions/1.0.0/scripts/lib/codex-conductor.ts +88 -0
  249. package/.versions/1.0.0/scripts/lib/codex-remote-control.ts +480 -0
  250. package/.versions/1.0.0/scripts/lib/coms-envelope.ts +582 -0
  251. package/.versions/1.0.0/scripts/lib/fake-herdr-server.ts +88 -0
  252. package/.versions/1.0.0/scripts/lib/fleet-command.ts +266 -0
  253. package/.versions/1.0.0/scripts/lib/herdr-layout.ts +281 -0
  254. package/.versions/1.0.0/scripts/lib/hermes-bridge-core.ts +241 -0
  255. package/.versions/1.0.0/scripts/lib/hermes-monitor-events.ts +1 -0
  256. package/.versions/1.0.0/scripts/lib/hermes-monitor-herdr.ts +2 -0
  257. package/.versions/1.0.0/scripts/lib/hermes-monitor-model.ts +3 -0
  258. package/.versions/1.0.0/scripts/lib/hermes-monitor-registry.ts +2 -0
  259. package/.versions/1.0.0/scripts/lib/hermes-monitor-socket.ts +2 -0
  260. package/.versions/1.0.0/scripts/lib/hermes-monitor-store.ts +2 -0
  261. package/.versions/1.0.0/scripts/lib/monitor-env.ts +146 -0
  262. package/.versions/1.0.0/scripts/lib/peer-launch.ts +318 -0
  263. package/.versions/1.0.0/scripts/lib/persona-banner.ts +62 -0
  264. package/.versions/1.0.0/scripts/lib/spawn-stagger.ts +101 -0
  265. package/.versions/1.0.0/scripts/lib/team-project.ts +213 -0
  266. package/.versions/1.0.0/scripts/lib/team-snapshot.ts +147 -0
  267. package/.versions/1.0.0/scripts/peer-banner.ts +40 -0
  268. package/.versions/1.0.0/scripts/peer-launch.ts +259 -0
  269. package/.versions/1.0.0/scripts/team-snapshot.ts +237 -0
  270. package/.versions/1.0.0/scripts/team-up.ts +406 -0
  271. package/.versions/1.0.0/skills/_internal/grilling.md +11 -0
  272. package/.versions/1.0.0/skills/browser-testing-with-devtools/SKILL.md +351 -0
  273. package/.versions/1.0.0/skills/code-review-and-quality/SKILL.md +381 -0
  274. package/.versions/1.0.0/skills/compound-learning/SKILL.md +137 -0
  275. package/.versions/1.0.0/skills/context-engineering/SKILL.md +291 -0
  276. package/.versions/1.0.0/skills/deprecation-and-migration/SKILL.md +206 -0
  277. package/.versions/1.0.0/skills/designing-agents/SKILL.md +394 -0
  278. package/.versions/1.0.0/skills/designing-agents/pi-harness-authoring.md +222 -0
  279. package/.versions/1.0.0/skills/frontend-ui-engineering/SKILL.md +328 -0
  280. package/.versions/1.0.0/skills/git-workflow-and-versioning/SKILL.md +316 -0
  281. package/.versions/1.0.0/skills/idea-refine/SKILL.md +182 -0
  282. package/.versions/1.0.0/skills/idea-refine/examples.md +238 -0
  283. package/.versions/1.0.0/skills/idea-refine/frameworks.md +99 -0
  284. package/.versions/1.0.0/skills/idea-refine/refinement-criteria.md +113 -0
  285. package/.versions/1.0.0/skills/idea-refine/scripts/idea-refine.sh +15 -0
  286. package/.versions/1.0.0/skills/incremental-implementation/SKILL.md +287 -0
  287. package/.versions/1.0.0/skills/interview-me/SKILL.md +226 -0
  288. package/.versions/1.0.0/skills/orchestration-verification/SKILL.md +181 -0
  289. package/.versions/1.0.0/skills/peer-coms/SKILL.md +90 -0
  290. package/.versions/1.0.0/skills/performance-optimization/SKILL.md +350 -0
  291. package/.versions/1.0.0/skills/planning-and-task-breakdown/SKILL.md +254 -0
  292. package/.versions/1.0.0/skills/security-and-hardening/SKILL.md +461 -0
  293. package/.versions/1.0.0/skills/spec-driven-development/SKILL.md +257 -0
  294. package/.versions/1.0.0/skills/using-agent-skills/SKILL.md +199 -0
  295. package/.versions/1.0.0/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
  296. package/.versions/1.0.0/vendor/agent-skills-upstream/LICENSE +21 -0
  297. package/.versions/1.0.0/vendor/agent-skills-upstream/README.md +11 -0
  298. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
  299. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  300. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  301. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  302. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  303. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
  304. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  305. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  306. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
  307. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  308. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  309. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  310. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  311. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  312. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  313. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  314. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  315. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  316. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  317. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
  318. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
  319. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
  320. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
  321. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
  322. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
  323. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
  324. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
  325. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
  326. package/.versions/1.0.1/.pi/agents/dispatch-policy.yaml +32 -0
  327. package/.versions/1.0.1/.pi/agents/model-profiles.yaml +27 -0
  328. package/.versions/1.0.1/.pi/agents/peers.yaml +142 -0
  329. package/.versions/1.0.1/.pi/agents/teams.yaml +41 -0
  330. package/.versions/1.0.1/.pi/damage-control-rules.yaml +297 -0
  331. package/.versions/1.0.1/.pi/extensions/agent-fleet-update-check/README.md +57 -0
  332. package/.versions/1.0.1/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
  333. package/.versions/1.0.1/.pi/extensions/agent-fleet-update-check/package.json +6 -0
  334. package/.versions/1.0.1/.pi/extensions/btw/README.md +120 -0
  335. package/.versions/1.0.1/.pi/extensions/btw/index.ts +914 -0
  336. package/.versions/1.0.1/.pi/extensions/btw/package.json +6 -0
  337. package/.versions/1.0.1/.pi/extensions/btw/state.js +179 -0
  338. package/.versions/1.0.1/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
  339. package/.versions/1.0.1/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
  340. package/.versions/1.0.1/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  341. package/.versions/1.0.1/.pi/extensions/compact-and-continue/README.md +42 -0
  342. package/.versions/1.0.1/.pi/extensions/compact-and-continue/index.ts +120 -0
  343. package/.versions/1.0.1/.pi/extensions/compact-and-continue/package.json +6 -0
  344. package/.versions/1.0.1/.pi/extensions/mcp-bridge/README.md +46 -0
  345. package/.versions/1.0.1/.pi/extensions/mcp-bridge/index.ts +206 -0
  346. package/.versions/1.0.1/.pi/extensions/mcp-bridge/package.json +6 -0
  347. package/.versions/1.0.1/.pi/extensions/package-lock.json +1143 -0
  348. package/.versions/1.0.1/.pi/extensions/package.json +9 -0
  349. package/.versions/1.0.1/.pi/extensions/pi-voice-stt/README.md +205 -0
  350. package/.versions/1.0.1/.pi/extensions/pi-voice-stt/config.ts +198 -0
  351. package/.versions/1.0.1/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  352. package/.versions/1.0.1/.pi/extensions/pi-voice-stt/index.ts +248 -0
  353. package/.versions/1.0.1/.pi/extensions/pi-voice-stt/package.json +6 -0
  354. package/.versions/1.0.1/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  355. package/.versions/1.0.1/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  356. package/.versions/1.0.1/.pi/harnesses/agent-hub/README.md +1065 -0
  357. package/.versions/1.0.1/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  358. package/.versions/1.0.1/.pi/harnesses/agent-hub/artifacts.js +146 -0
  359. package/.versions/1.0.1/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
  360. package/.versions/1.0.1/.pi/harnesses/agent-hub/backend-policy.js +174 -0
  361. package/.versions/1.0.1/.pi/harnesses/agent-hub/context-window.js +106 -0
  362. package/.versions/1.0.1/.pi/harnesses/agent-hub/delegate.ts +435 -0
  363. package/.versions/1.0.1/.pi/harnesses/agent-hub/docs-lane.js +122 -0
  364. package/.versions/1.0.1/.pi/harnesses/agent-hub/drift-watchdog.js +211 -0
  365. package/.versions/1.0.1/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  366. package/.versions/1.0.1/.pi/harnesses/agent-hub/external-blocker.js +85 -0
  367. package/.versions/1.0.1/.pi/harnesses/agent-hub/footer.ts +35 -0
  368. package/.versions/1.0.1/.pi/harnesses/agent-hub/helpers.ts +266 -0
  369. package/.versions/1.0.1/.pi/harnesses/agent-hub/hub-state-audit.js +55 -0
  370. package/.versions/1.0.1/.pi/harnesses/agent-hub/index.ts +9343 -0
  371. package/.versions/1.0.1/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  372. package/.versions/1.0.1/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
  373. package/.versions/1.0.1/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
  374. package/.versions/1.0.1/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  375. package/.versions/1.0.1/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  376. package/.versions/1.0.1/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  377. package/.versions/1.0.1/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  378. package/.versions/1.0.1/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
  379. package/.versions/1.0.1/.pi/harnesses/agent-hub/package.json +7 -0
  380. package/.versions/1.0.1/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
  381. package/.versions/1.0.1/.pi/harnesses/agent-hub/posture.ts +103 -0
  382. package/.versions/1.0.1/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
  383. package/.versions/1.0.1/.pi/harnesses/agent-hub/research-retention.js +34 -0
  384. package/.versions/1.0.1/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  385. package/.versions/1.0.1/.pi/harnesses/agent-hub/return-contract.js +293 -0
  386. package/.versions/1.0.1/.pi/harnesses/agent-hub/return-extract.js +75 -0
  387. package/.versions/1.0.1/.pi/harnesses/agent-hub/review-findings.js +102 -0
  388. package/.versions/1.0.1/.pi/harnesses/agent-hub/run-budget.js +540 -0
  389. package/.versions/1.0.1/.pi/harnesses/agent-hub/run-namespace.js +87 -0
  390. package/.versions/1.0.1/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  391. package/.versions/1.0.1/.pi/harnesses/agent-hub/scope-gate.js +103 -0
  392. package/.versions/1.0.1/.pi/harnesses/agent-hub/session-health.js +110 -0
  393. package/.versions/1.0.1/.pi/harnesses/agent-hub/spawn.ts +354 -0
  394. package/.versions/1.0.1/.pi/harnesses/agent-hub/version.ts +42 -0
  395. package/.versions/1.0.1/.pi/harnesses/ask-user-remote/README.md +53 -0
  396. package/.versions/1.0.1/.pi/harnesses/ask-user-remote/index.ts +477 -0
  397. package/.versions/1.0.1/.pi/harnesses/ask-user-remote/race-core.js +106 -0
  398. package/.versions/1.0.1/.pi/harnesses/coms/README.md +100 -0
  399. package/.versions/1.0.1/.pi/harnesses/coms/index.ts +1767 -0
  400. package/.versions/1.0.1/.pi/harnesses/coms/package.json +7 -0
  401. package/.versions/1.0.1/.pi/harnesses/coms/version.ts +42 -0
  402. package/.versions/1.0.1/.pi/harnesses/damage-control-continue/README.md +124 -0
  403. package/.versions/1.0.1/.pi/harnesses/damage-control-continue/index.ts +536 -0
  404. package/.versions/1.0.1/.pi/harnesses/damage-control-continue/package.json +7 -0
  405. package/.versions/1.0.1/.pi/harnesses/damage-control-continue/version.ts +42 -0
  406. package/.versions/1.0.1/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
  407. package/.versions/1.0.1/.pi/harnesses/lib/damage-control-shared.ts +197 -0
  408. package/.versions/1.0.1/.pi/harnesses/lib/fleet-dashboard-ops.ts +155 -0
  409. package/.versions/1.0.1/.pi/harnesses/lib/fleet-dashboard-view.ts +140 -0
  410. package/.versions/1.0.1/.pi/harnesses/lib/fleet-detail-view.ts +43 -0
  411. package/.versions/1.0.1/.pi/harnesses/lib/fleet-overlay.ts +26 -0
  412. package/.versions/1.0.1/.pi/harnesses/lib/fleet-panel.ts +34 -0
  413. package/.versions/1.0.1/.pi/harnesses/lib/fleet-read-model.ts +131 -0
  414. package/.versions/1.0.1/.pi/harnesses/lib/fleet-selection.ts +24 -0
  415. package/.versions/1.0.1/.pi/harnesses/lib/herdr-client.ts +472 -0
  416. package/.versions/1.0.1/.pi/harnesses/lib/herdr-presence.ts +399 -0
  417. package/.versions/1.0.1/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
  418. package/.versions/1.0.1/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
  419. package/.versions/1.0.1/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
  420. package/.versions/1.0.1/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
  421. package/.versions/1.0.1/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
  422. package/.versions/1.0.1/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
  423. package/.versions/1.0.1/.pi/harnesses/lib/spawned-peers.js +190 -0
  424. package/.versions/1.0.1/.pi/harnesses/package-lock.json +2046 -0
  425. package/.versions/1.0.1/.pi/harnesses/package.json +10 -0
  426. package/.versions/1.0.1/.pi/prompts/af-build.md +24 -0
  427. package/.versions/{0.0.11/.claude/commands/code-simplify.md → 1.0.1/.pi/prompts/af-code-simplify.md} +3 -3
  428. package/.versions/{0.0.11/.claude/commands/plan.md → 1.0.1/.pi/prompts/af-plan.md} +1 -1
  429. package/{.claude/commands/review.md → .versions/1.0.1/.pi/prompts/af-review.md} +3 -3
  430. package/.versions/1.0.1/.pi/prompts/af-set-hermes-watchdog.md +6 -0
  431. package/.versions/1.0.1/.pi/prompts/af-ship.md +17 -0
  432. package/{.claude/commands/spec.md → .versions/1.0.1/.pi/prompts/af-spec.md} +1 -1
  433. package/{.claude/commands/test.md → .versions/1.0.1/.pi/prompts/af-test.md} +2 -2
  434. package/.versions/1.0.1/.pi/skills/bowser/SKILL.md +145 -0
  435. package/.versions/1.0.1/.version +1 -0
  436. package/.versions/1.0.1/agents/architect.md +24 -0
  437. package/.versions/1.0.1/agents/bowser.md +27 -0
  438. package/.versions/1.0.1/agents/builder.md +54 -0
  439. package/.versions/1.0.1/agents/code-reviewer.md +208 -0
  440. package/.versions/1.0.1/agents/deep-researcher.md +32 -0
  441. package/.versions/1.0.1/agents/documenter.md +18 -0
  442. package/.versions/1.0.1/agents/orchestrator.md +72 -0
  443. package/.versions/1.0.1/agents/plan-reviewer.md +83 -0
  444. package/.versions/1.0.1/agents/planner.md +70 -0
  445. package/.versions/1.0.1/agents/releaser.md +24 -0
  446. package/.versions/1.0.1/agents/researcher.md +28 -0
  447. package/.versions/1.0.1/agents/security-auditor.md +167 -0
  448. package/.versions/1.0.1/agents/test-engineer.md +153 -0
  449. package/.versions/1.0.1/agents/web-debugger.md +43 -0
  450. package/.versions/1.0.1/agents/web-performance-auditor.md +193 -0
  451. package/.versions/1.0.1/codex/CONDUCTOR.md +148 -0
  452. package/.versions/1.0.1/docs/ARCHITECTURE.md +337 -0
  453. package/.versions/1.0.1/docs/agent-fleet-setup.md +437 -0
  454. package/.versions/1.0.1/docs/claude-code-coms-bridge.md +128 -0
  455. package/.versions/1.0.1/docs/codex-remote-conductor.md +170 -0
  456. package/.versions/1.0.1/docs/coms-hermes-bridge.md +189 -0
  457. package/.versions/1.0.1/docs/getting-started.md +98 -0
  458. package/.versions/1.0.1/docs/npm-install.md +292 -0
  459. package/.versions/1.0.1/docs/pi-extensions.md +412 -0
  460. package/.versions/1.0.1/docs/pi-setup.md +74 -0
  461. package/.versions/1.0.1/docs/skill-anatomy.md +150 -0
  462. package/.versions/1.0.1/hermes/README.md +347 -0
  463. package/.versions/1.0.1/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
  464. package/.versions/1.0.1/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
  465. package/.versions/1.0.1/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  466. package/.versions/1.0.1/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  467. package/.versions/1.0.1/hermes/gates/gate-o-capability.md +8 -0
  468. package/.versions/1.0.1/hermes/gates/gate-o-validator-fixtures.json +1 -0
  469. package/.versions/1.0.1/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
  470. package/.versions/1.0.1/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
  471. package/.versions/1.0.1/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
  472. package/.versions/1.0.1/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
  473. package/.versions/1.0.1/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
  474. package/.versions/1.0.1/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
  475. package/.versions/1.0.1/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
  476. package/.versions/1.0.1/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
  477. package/.versions/1.0.1/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
  478. package/.versions/1.0.1/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
  479. package/.versions/1.0.1/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
  480. package/.versions/1.0.1/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  481. package/.versions/1.0.1/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  482. package/.versions/1.0.1/hermes/skills/hub-conductor/SKILL.md +84 -0
  483. package/.versions/1.0.1/hermes/skills/hub-liaison/SKILL.md +84 -0
  484. package/.versions/1.0.1/hermes/skills/hub-watchdog/SKILL.md +76 -0
  485. package/.versions/1.0.1/hermes/skills/hub-watchdog/manifest.json +1 -0
  486. package/.versions/1.0.1/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
  487. package/.versions/1.0.1/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
  488. package/.versions/1.0.1/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
  489. package/.versions/1.0.1/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
  490. package/.versions/1.0.1/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
  491. package/.versions/1.0.1/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
  492. package/.versions/1.0.1/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
  493. package/.versions/1.0.1/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
  494. package/.versions/1.0.1/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
  495. package/.versions/1.0.1/hermes/watchdog-tests/__init__.py +0 -0
  496. package/.versions/1.0.1/hooks/coms-stop-hook.mjs +84 -0
  497. package/.versions/1.0.1/install-manifest.json +2745 -0
  498. package/.versions/1.0.1/justfile +272 -0
  499. package/.versions/1.0.1/manifest-meta.json +882 -0
  500. package/.versions/1.0.1/references/accessibility-checklist.md +160 -0
  501. package/.versions/1.0.1/references/definition-of-done.md +67 -0
  502. package/.versions/1.0.1/references/fleet-coordination-patterns.md +151 -0
  503. package/.versions/1.0.1/references/observability-checklist.md +91 -0
  504. package/.versions/1.0.1/references/orchestration-patterns.md +370 -0
  505. package/.versions/1.0.1/references/performance-checklist.md +153 -0
  506. package/.versions/1.0.1/references/prompting-patterns.md +380 -0
  507. package/.versions/1.0.1/references/security-checklist.md +179 -0
  508. package/.versions/1.0.1/references/testing-patterns.md +236 -0
  509. package/.versions/1.0.1/scripts/codex-conductor.ts +41 -0
  510. package/.versions/1.0.1/scripts/codex-remote-control.ts +167 -0
  511. package/.versions/1.0.1/scripts/coms-claude-bridge.ts +411 -0
  512. package/.versions/1.0.1/scripts/coms-cli.ts +484 -0
  513. package/.versions/1.0.1/scripts/coms-hermes-bridge.ts +413 -0
  514. package/.versions/1.0.1/scripts/fleet.ts +185 -0
  515. package/.versions/1.0.1/scripts/hermes-monitor-capability-runner.ts +25 -0
  516. package/.versions/1.0.1/scripts/hermes-monitor-scenario.ts +474 -0
  517. package/.versions/1.0.1/scripts/hermes-watchdog-capability-probe.ts +45 -0
  518. package/.versions/1.0.1/scripts/install-hermes-plugin.sh +180 -0
  519. package/.versions/1.0.1/scripts/lib/claude-bridge-core.ts +210 -0
  520. package/.versions/1.0.1/scripts/lib/codex-conductor.ts +88 -0
  521. package/.versions/1.0.1/scripts/lib/codex-remote-control.ts +480 -0
  522. package/.versions/1.0.1/scripts/lib/coms-envelope.ts +582 -0
  523. package/.versions/1.0.1/scripts/lib/fake-herdr-server.ts +88 -0
  524. package/.versions/1.0.1/scripts/lib/fleet-command.ts +266 -0
  525. package/.versions/1.0.1/scripts/lib/herdr-layout.ts +281 -0
  526. package/.versions/1.0.1/scripts/lib/hermes-bridge-core.ts +241 -0
  527. package/.versions/1.0.1/scripts/lib/hermes-monitor-events.ts +1 -0
  528. package/.versions/1.0.1/scripts/lib/hermes-monitor-herdr.ts +2 -0
  529. package/.versions/1.0.1/scripts/lib/hermes-monitor-model.ts +3 -0
  530. package/.versions/1.0.1/scripts/lib/hermes-monitor-registry.ts +2 -0
  531. package/.versions/1.0.1/scripts/lib/hermes-monitor-socket.ts +2 -0
  532. package/.versions/1.0.1/scripts/lib/hermes-monitor-store.ts +2 -0
  533. package/.versions/1.0.1/scripts/lib/monitor-env.ts +146 -0
  534. package/.versions/1.0.1/scripts/lib/peer-launch.ts +318 -0
  535. package/.versions/1.0.1/scripts/lib/persona-banner.ts +62 -0
  536. package/.versions/1.0.1/scripts/lib/spawn-stagger.ts +101 -0
  537. package/.versions/1.0.1/scripts/lib/team-project.ts +213 -0
  538. package/.versions/1.0.1/scripts/lib/team-snapshot.ts +147 -0
  539. package/.versions/1.0.1/scripts/peer-banner.ts +40 -0
  540. package/.versions/1.0.1/scripts/peer-launch.ts +259 -0
  541. package/.versions/1.0.1/scripts/team-snapshot.ts +237 -0
  542. package/.versions/1.0.1/scripts/team-up.ts +406 -0
  543. package/.versions/1.0.1/skills/_internal/grilling.md +11 -0
  544. package/.versions/1.0.1/skills/browser-testing-with-devtools/SKILL.md +351 -0
  545. package/.versions/1.0.1/skills/code-review-and-quality/SKILL.md +381 -0
  546. package/.versions/1.0.1/skills/compound-learning/SKILL.md +137 -0
  547. package/.versions/1.0.1/skills/context-engineering/SKILL.md +291 -0
  548. package/.versions/1.0.1/skills/deprecation-and-migration/SKILL.md +206 -0
  549. package/.versions/1.0.1/skills/designing-agents/SKILL.md +394 -0
  550. package/.versions/1.0.1/skills/designing-agents/pi-harness-authoring.md +222 -0
  551. package/.versions/1.0.1/skills/frontend-ui-engineering/SKILL.md +328 -0
  552. package/.versions/1.0.1/skills/git-workflow-and-versioning/SKILL.md +316 -0
  553. package/.versions/1.0.1/skills/idea-refine/SKILL.md +182 -0
  554. package/.versions/1.0.1/skills/idea-refine/examples.md +238 -0
  555. package/.versions/1.0.1/skills/idea-refine/frameworks.md +99 -0
  556. package/.versions/1.0.1/skills/idea-refine/refinement-criteria.md +113 -0
  557. package/.versions/1.0.1/skills/idea-refine/scripts/idea-refine.sh +15 -0
  558. package/.versions/1.0.1/skills/incremental-implementation/SKILL.md +287 -0
  559. package/.versions/1.0.1/skills/interview-me/SKILL.md +226 -0
  560. package/.versions/1.0.1/skills/orchestration-verification/SKILL.md +181 -0
  561. package/.versions/1.0.1/skills/peer-coms/SKILL.md +90 -0
  562. package/.versions/1.0.1/skills/performance-optimization/SKILL.md +350 -0
  563. package/.versions/1.0.1/skills/planning-and-task-breakdown/SKILL.md +254 -0
  564. package/.versions/1.0.1/skills/security-and-hardening/SKILL.md +461 -0
  565. package/.versions/1.0.1/skills/spec-driven-development/SKILL.md +257 -0
  566. package/.versions/1.0.1/skills/using-agent-skills/SKILL.md +199 -0
  567. package/.versions/1.0.1/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
  568. package/.versions/1.0.1/vendor/agent-skills-upstream/LICENSE +21 -0
  569. package/.versions/1.0.1/vendor/agent-skills-upstream/README.md +11 -0
  570. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
  571. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  572. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  573. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  574. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  575. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
  576. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  577. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  578. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
  579. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  580. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  581. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  582. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  583. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  584. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  585. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  586. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  587. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  588. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  589. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
  590. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
  591. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
  592. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
  593. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
  594. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
  595. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
  596. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
  597. package/.versions/1.0.1/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
  598. package/CHANGELOG.md +148 -0
  599. package/README.md +117 -79
  600. package/agents/code-reviewer.md +1 -1
  601. package/agents/deep-researcher.md +1 -1
  602. package/agents/orchestrator.md +1 -1
  603. package/agents/plan-reviewer.md +1 -1
  604. package/agents/planner.md +1 -1
  605. package/agents/security-auditor.md +1 -1
  606. package/agents/test-engineer.md +1 -1
  607. package/bin/catalog/harness-runtime-closure.json +38 -0
  608. package/bin/cli.js +289 -359
  609. package/bin/force-patch-changesets.js +18 -2
  610. package/bin/lib/apply.js +86 -32
  611. package/bin/lib/desired.js +87 -0
  612. package/bin/lib/detect-agent.js +22 -38
  613. package/bin/lib/doctor.js +283 -33
  614. package/bin/lib/features.js +78 -0
  615. package/bin/lib/manifest.js +127 -48
  616. package/bin/lib/overrides.js +35 -0
  617. package/bin/lib/personas.js +37 -0
  618. package/bin/lib/plan.js +18 -9
  619. package/bin/lib/purge.js +11 -0
  620. package/bin/lib/reconcile.js +68 -0
  621. package/bin/lib/scan.js +24 -0
  622. package/bin/lib/state.js +25 -1
  623. package/bin/lib/stt-wizard.js +33 -0
  624. package/bin/lib/transaction.js +149 -0
  625. package/bin/lib/tui.js +71 -0
  626. package/bin/lib/verify.js +9 -26
  627. package/bin/snapshot-version.js +3 -6
  628. package/docs/ARCHITECTURE.md +55 -21
  629. package/docs/MIGRATION-agent-fleet.md +222 -0
  630. package/docs/agent-fleet-setup.md +124 -64
  631. package/docs/claude-code-coms-bridge.md +21 -2
  632. package/docs/coms-hermes-bridge.md +1 -1
  633. package/docs/getting-started.md +61 -217
  634. package/docs/npm-install.md +207 -429
  635. package/docs/pi-extensions.md +85 -41
  636. package/docs/pi-setup.md +48 -545
  637. package/hermes/README.md +1 -1
  638. package/install-manifest.json +385 -1255
  639. package/justfile +45 -27
  640. package/manifest-meta.json +544 -134
  641. package/node_modules/pi-ask-user/README.md +43 -5
  642. package/node_modules/pi-ask-user/index.ts +630 -75
  643. package/node_modules/pi-ask-user/package.json +1 -1
  644. package/package.json +5 -11
  645. package/scripts/coms-claude-bridge.ts +10 -0
  646. package/scripts/fleet.ts +107 -90
  647. package/scripts/lib/claude-bridge-core.ts +45 -0
  648. package/scripts/lib/fleet-command.ts +170 -15
  649. package/scripts/lib/monitor-env.ts +18 -6
  650. package/scripts/lib/peer-launch.ts +6 -2
  651. package/scripts/lib/team-project.ts +24 -4
  652. package/scripts/team-up.ts +57 -11
  653. package/skills/designing-agents/SKILL.md +1 -1
  654. package/skills/designing-agents/pi-harness-authoring.md +3 -3
  655. package/.claude/commands/build.md +0 -44
  656. package/.claude/commands/design-agent.md +0 -14
  657. package/.claude/commands/doctor-agent-fleet.md +0 -22
  658. package/.claude/commands/orchestrate.md +0 -112
  659. package/.claude/commands/prime.md +0 -22
  660. package/.claude/commands/set-hermes-telegram.md +0 -15
  661. package/.claude/commands/set-hermes-watchdog.md +0 -6
  662. package/.claude/commands/setup-agent-fleet.md +0 -17
  663. package/.claude/commands/ship.md +0 -72
  664. package/.claude/commands/webperf.md +0 -32
  665. package/.claude/orchestrate-teams.yaml +0 -24
  666. package/.opencode/commands/af-build.md +0 -17
  667. package/.opencode/commands/af-code-simplify.md +0 -16
  668. package/.opencode/commands/af-compound.md +0 -16
  669. package/.opencode/commands/af-design-agent.md +0 -15
  670. package/.opencode/commands/af-doctor-agent-fleet.md +0 -22
  671. package/.opencode/commands/af-orchestrate.md +0 -112
  672. package/.opencode/commands/af-plan.md +0 -16
  673. package/.opencode/commands/af-prime.md +0 -22
  674. package/.opencode/commands/af-review.md +0 -15
  675. package/.opencode/commands/af-set-hermes-watchdog.md +0 -6
  676. package/.opencode/commands/af-setup-agent-fleet.md +0 -17
  677. package/.opencode/commands/af-ship.md +0 -16
  678. package/.opencode/commands/af-spec.md +0 -16
  679. package/.opencode/commands/af-test.md +0 -21
  680. package/.opencode/commands/af-webperf.md +0 -32
  681. package/.opencode/orchestrate-teams.yaml +0 -24
  682. package/.pi/prompts/af-doctor-agent-fleet.md +0 -22
  683. package/.pi/prompts/af-setup-agent-fleet.md +0 -19
  684. package/.versions/0.0.1/.opencode/commands/af-doctor-agent-fleet.md +0 -15
  685. package/.versions/0.0.1/.opencode/commands/af-setup-agent-fleet.md +0 -15
  686. package/.versions/0.0.1/skills/guided-workspace-setup/SKILL.md +0 -506
  687. package/.versions/0.0.10/.opencode/commands/af-doctor-agent-fleet.md +0 -22
  688. package/.versions/0.0.10/.opencode/commands/af-setup-agent-fleet.md +0 -17
  689. package/.versions/0.0.10/.pi/prompts/af-doctor-agent-fleet.md +0 -22
  690. package/.versions/0.0.10/.pi/prompts/af-setup-agent-fleet.md +0 -19
  691. package/.versions/0.0.10/skills/guided-workspace-setup/SKILL.md +0 -226
  692. package/.versions/0.0.11/.claude/commands/build.md +0 -44
  693. package/.versions/0.0.11/.claude/commands/design-agent.md +0 -14
  694. package/.versions/0.0.11/.claude/commands/doctor-agent-fleet.md +0 -22
  695. package/.versions/0.0.11/.claude/commands/orchestrate.md +0 -112
  696. package/.versions/0.0.11/.claude/commands/prime.md +0 -22
  697. package/.versions/0.0.11/.claude/commands/set-hermes-telegram.md +0 -15
  698. package/.versions/0.0.11/.claude/commands/set-hermes-watchdog.md +0 -6
  699. package/.versions/0.0.11/.claude/commands/setup-agent-fleet.md +0 -17
  700. package/.versions/0.0.11/.claude/commands/ship.md +0 -72
  701. package/.versions/0.0.11/.claude/commands/webperf.md +0 -32
  702. package/.versions/0.0.11/.claude/orchestrate-teams.yaml +0 -24
  703. package/.versions/0.0.11/.opencode/commands/af-build.md +0 -17
  704. package/.versions/0.0.11/.opencode/commands/af-code-simplify.md +0 -16
  705. package/.versions/0.0.11/.opencode/commands/af-compound.md +0 -16
  706. package/.versions/0.0.11/.opencode/commands/af-design-agent.md +0 -15
  707. package/.versions/0.0.11/.opencode/commands/af-doctor-agent-fleet.md +0 -22
  708. package/.versions/0.0.11/.opencode/commands/af-orchestrate.md +0 -112
  709. package/.versions/0.0.11/.opencode/commands/af-plan.md +0 -16
  710. package/.versions/0.0.11/.opencode/commands/af-prime.md +0 -22
  711. package/.versions/0.0.11/.opencode/commands/af-review.md +0 -15
  712. package/.versions/0.0.11/.opencode/commands/af-set-hermes-watchdog.md +0 -6
  713. package/.versions/0.0.11/.opencode/commands/af-setup-agent-fleet.md +0 -17
  714. package/.versions/0.0.11/.opencode/commands/af-ship.md +0 -16
  715. package/.versions/0.0.11/.opencode/commands/af-spec.md +0 -16
  716. package/.versions/0.0.11/.opencode/commands/af-test.md +0 -21
  717. package/.versions/0.0.11/.opencode/commands/af-webperf.md +0 -32
  718. package/.versions/0.0.11/.opencode/orchestrate-teams.yaml +0 -24
  719. package/.versions/0.0.11/.pi/prompts/af-doctor-agent-fleet.md +0 -22
  720. package/.versions/0.0.11/.pi/prompts/af-setup-agent-fleet.md +0 -19
  721. package/.versions/0.0.11/docs/opencode-setup.md +0 -281
  722. package/.versions/0.0.11/hooks/SIMPLIFY-IGNORE.md +0 -90
  723. package/.versions/0.0.11/hooks/hooks.json +0 -14
  724. package/.versions/0.0.11/hooks/session-start.sh +0 -74
  725. package/.versions/0.0.11/hooks/simplify-ignore.sh +0 -302
  726. package/.versions/0.0.11/skills/guided-workspace-setup/SKILL.md +0 -226
  727. package/.versions/0.0.4/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  728. package/.versions/0.0.4/.opencode/commands/af-setup-agent-fleet.md +0 -15
  729. package/.versions/0.0.4/skills/guided-workspace-setup/SKILL.md +0 -535
  730. package/.versions/0.0.4/skills/guided-workspace-setup/companion-manifest.json +0 -33
  731. package/.versions/0.0.5/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  732. package/.versions/0.0.5/.opencode/commands/af-setup-agent-fleet.md +0 -15
  733. package/.versions/0.0.5/skills/guided-workspace-setup/SKILL.md +0 -542
  734. package/.versions/0.0.5/skills/guided-workspace-setup/companion-manifest.json +0 -35
  735. package/.versions/0.0.6/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  736. package/.versions/0.0.6/.opencode/commands/af-setup-agent-fleet.md +0 -15
  737. package/.versions/0.0.6/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  738. package/.versions/0.0.6/.pi/prompts/af-setup-agent-fleet.md +0 -27
  739. package/.versions/0.0.6/skills/guided-workspace-setup/SKILL.md +0 -544
  740. package/.versions/0.0.6/skills/guided-workspace-setup/companion-manifest.json +0 -35
  741. package/.versions/0.0.7/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  742. package/.versions/0.0.7/.opencode/commands/af-setup-agent-fleet.md +0 -15
  743. package/.versions/0.0.7/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  744. package/.versions/0.0.7/.pi/prompts/af-setup-agent-fleet.md +0 -27
  745. package/.versions/0.0.7/skills/guided-workspace-setup/SKILL.md +0 -544
  746. package/.versions/0.0.7/skills/guided-workspace-setup/companion-manifest.json +0 -35
  747. package/.versions/0.0.8/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  748. package/.versions/0.0.8/.opencode/commands/af-setup-agent-fleet.md +0 -15
  749. package/.versions/0.0.8/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  750. package/.versions/0.0.8/.pi/prompts/af-setup-agent-fleet.md +0 -27
  751. package/.versions/0.0.8/skills/guided-workspace-setup/SKILL.md +0 -544
  752. package/.versions/0.0.8/skills/guided-workspace-setup/companion-manifest.json +0 -36
  753. package/.versions/0.0.9/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  754. package/.versions/0.0.9/.opencode/commands/af-setup-agent-fleet.md +0 -15
  755. package/.versions/0.0.9/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  756. package/.versions/0.0.9/.pi/prompts/af-setup-agent-fleet.md +0 -27
  757. package/.versions/0.0.9/skills/guided-workspace-setup/SKILL.md +0 -544
  758. package/bin/lib/bootstrap.js +0 -323
  759. package/bin/lib/transform-persona.js +0 -180
  760. package/docs/opencode-setup.md +0 -281
  761. package/hooks/SIMPLIFY-IGNORE.md +0 -90
  762. package/hooks/hooks.json +0 -14
  763. package/hooks/session-start.sh +0 -74
  764. package/hooks/simplify-ignore.sh +0 -302
  765. package/skills/guided-workspace-setup/SKILL.md +0 -226
  766. /package/.versions/0.0.10/{skills/guided-workspace-setup/companion-manifest.json → bin/catalog/harness-runtime-closure.json} +0 -0
  767. /package/.versions/0.0.11/{skills/guided-workspace-setup/companion-manifest.json → bin/catalog/harness-runtime-closure.json} +0 -0
  768. /package/{.opencode/commands → .versions/1.0.0/.pi/prompts}/af-set-hermes-telegram.md +0 -0
  769. /package/.versions/{0.0.9/skills/guided-workspace-setup/companion-manifest.json → 1.0.0/bin/catalog/harness-runtime-closure.json} +0 -0
  770. /package/.versions/{0.0.11/.opencode/commands → 1.0.1/.pi/prompts}/af-set-hermes-telegram.md +0 -0
  771. /package/{skills/guided-workspace-setup/companion-manifest.json → .versions/1.0.1/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,8 +88,9 @@ 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";
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";
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
+ import { DEFAULT_HUB_MODE, DEFAULT_TASK_TIER, HUB_MODES, TASK_BUDGET_MULTIPLIER, addTaskClockWait, applyTierChange, blockingFindingCap, budgetStatusLine, checkReviewRoundCap, checkTaskBudget, checkTierPersonaGate, checkTurnBudget, closeTaskClock, contextOverflowDiagnostic, createTaskClock, isReviewPersona, normalizeHubMode, openTaskClock, remainingTaskResearch, resetTaskClock, resolveTaskBudget, resolveTurnBudget, reviewBudgetClause, reviewRoundCap, shouldRecycleSession, taskClockElapsedMs } from "./run-budget.js";
93
+ import { buildHubAuditIdentity, buildHubModeAudit, buildTaskResetAudit } from "./hub-state-audit.js";
93
94
  import { countReviewFindings, findingBudgetNotice } from "./review-findings.js";
94
95
  import { checkDocsLane, docsLaneNotice } from "./docs-lane.js";
95
96
  import { checkExternalBlockerGate, externalBlockedProtocol, extractExternalBlockers } from "./external-blocker.js";
@@ -113,7 +114,9 @@ import { artifactPreviewFromText, formatInputArtifactsSection, resolveArtifactPa
113
114
  import { crossCheck, deliveryDisposition, extractAssertionIds, parseDeliveredReturn, parseStructuredReturn } from "./return-contract.js";
114
115
  import { checkScope, diffAgainst, snapshotWorktree } from "./scope-gate.js";
115
116
  import { validateEvidence } from "./evidence-rules.js";
116
- import { comsRequiredRefusal, parseDispatchPolicy, resolveDispatchBackend } from "./backend-policy.js";
117
+ import { comsRequiredRefusal, explicitComsRefusal, parseDispatchPolicy, resolveDispatchBackend } from "./backend-policy.js";
118
+ import { parsePosture, posturePrompt, resolvePostureTools, resolveSessionPosture, type Posture } from "./posture.ts";
119
+ import { buildHubPeerSpawnPlan, launchHubPeerInPane } from "./peer-spawn-plan.ts";
117
120
  import { DEFAULT_RESEARCH_KEEP, parseResearchKeep, selectResearchPrunable } from "./research-retention.js";
118
121
  import { requireSafetyHarness, resolveSafetyHarness } from "./safety-routing.ts";
119
122
  import { createAccessApprovalRouter } from "./access-approval.ts";
@@ -128,8 +131,15 @@ import {
128
131
  } from "../lib/herdr-presence.ts";
129
132
  import { herdr as herdrApi, herdrAvailable } from "../lib/herdr-client.ts";
130
133
  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";
134
+ import { FULLSCREEN_OVERLAY, bodyRows, clampScroll, fitToHeight } from "../lib/fleet-overlay.ts";
135
+ import { createPanelResources } from "../lib/fleet-panel.ts";
136
+ import { buildFleetRows, fleetTiming, summarise, unionMs, type DelegateInput, type FleetRow, type FleetSource, type PeerInput, type ResearchInput, type SpecialistInput } from "../lib/fleet-read-model.ts";
137
+ import { attachFleetDashboardTicker, compactWidgetsEnabled, gridColumnsForItems, gridColumnsForSize, liveTimeline, renderCardGrid, resolveFleetKill, resolveFleetRestart } from "../lib/fleet-dashboard-ops.ts";
138
+ import { dashboardTransition, renderFleetDashboard, FLEET_CHROME_ROWS, type DashboardConfirm } from "../lib/fleet-dashboard-view.ts";
139
+ import { detailContent, detailTransition, renderFleetDetail, DETAIL_CHROME_ROWS } from "../lib/fleet-detail-view.ts";
140
+ import { reconcileSelection, type Selection } from "../lib/fleet-selection.ts";
141
+ import { parseEnvFile, resolveEnvFilePath } from "../../../scripts/lib/herdr-layout.ts";
142
+ import { worktreeTag } from "../../../scripts/lib/team-project.ts";
133
143
  import { STAGGER_ENV_VAR, WARMUP_SECONDS, oauthNeedsWarmup } from "../../../scripts/lib/spawn-stagger.ts";
134
144
  import { join, resolve } from "path";
135
145
  import * as net from "node:net";
@@ -296,6 +306,7 @@ interface ResearchState {
296
306
  killedByOperator?: boolean;
297
307
  timeline: TimelineEntry[];
298
308
  zoomRender?: (force?: boolean) => void;
309
+ histEntry?: HistoryEntry;
299
310
  }
300
311
 
301
312
  // The subset of state `/af-zoom` needs. Both AgentState (standing team) and ResearchState
@@ -338,30 +349,6 @@ function fmtDuration(ms: number): string {
338
349
  return `${m}:${String(s).padStart(2, "0")}min`;
339
350
  }
340
351
 
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
352
  // ── Display Name Helper ──────────────────────────
366
353
 
367
354
  function displayName(name: string): string {
@@ -472,6 +459,7 @@ interface AgentTeamOverrides {
472
459
  researchKeep: number;
473
460
  reconSearchTimeoutMs: number | null;
474
461
  hubMode: string;
462
+ hubModeSource: "default" | "project-override";
475
463
  // Per-axis turn-budget overrides for run-budget.js resolveTurnBudget():
476
464
  // number replaces the mode default, null = "off", undefined = keep default.
477
465
  budgetOverrides: {
@@ -502,6 +490,7 @@ const DEFAULT_OVERRIDES: AgentTeamOverrides = {
502
490
  researchKeep: DEFAULT_RESEARCH_KEEP,
503
491
  reconSearchTimeoutMs: 120_000,
504
492
  hubMode: DEFAULT_HUB_MODE,
493
+ hubModeSource: "default",
505
494
  budgetOverrides: {},
506
495
  watchdogSetting: DEFAULT_WATCHDOG_SETTING,
507
496
  watchdogJudgeModel: null,
@@ -587,6 +576,7 @@ function parseAgentTeamOverrides(cwd: string): AgentTeamOverrides {
587
576
  const mode = normalizeHubMode(value);
588
577
  if (mode) {
589
578
  result.hubMode = mode;
579
+ result.hubModeSource = "project-override";
590
580
  } else {
591
581
  result.warnings.push(`mode "${value}" is not one of ${HUB_MODES.join("|")} — using the default (${DEFAULT_HUB_MODE})`);
592
582
  }
@@ -908,6 +898,8 @@ function parseResearchHandle(arg: string): number | null {
908
898
  return m ? parseInt(m[1], 10) : null;
909
899
  }
910
900
 
901
+ const ZOOM_CHROME_ROWS = 5;
902
+
911
903
  class ZoomUI {
912
904
  private selectedIndex = 0;
913
905
  private expandedIndex: number | null = null;
@@ -1003,7 +995,7 @@ class ZoomUI {
1003
995
  if (this.scrollOffset < 0) this.scrollOffset = 0;
1004
996
  }
1005
997
 
1006
- render(width: number, height: number, theme: any): string[] {
998
+ render(width: number, contentHeight: number, theme: any): string[] {
1007
999
  const items = this.state.timeline;
1008
1000
  // Live tail-follow: keep the selection pinned to the newest entry as the
1009
1001
  // stream grows, until the user scrolls up. Auto-expand each new tail entry
@@ -1037,8 +1029,7 @@ class ZoomUI {
1037
1029
  bottom.addChild(new Text(theme.fg("dim", " ↑/↓ Navigate • Enter Collapse/Expand • Space/Ctrl+C Copy • Q/Esc Close • live"), 1, 0));
1038
1030
  bottom.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
1039
1031
  const bottomLines = bottom.render(width);
1040
-
1041
- const contentHeight = Math.max(3, height - topLines.length - bottomLines.length);
1032
+ const bodyHeight = Math.max(0, contentHeight + ZOOM_CHROME_ROWS - topLines.length - bottomLines.length);
1042
1033
 
1043
1034
  let bodyLines: string[];
1044
1035
  if (items.length === 0) {
@@ -1046,17 +1037,17 @@ class ZoomUI {
1046
1037
  } else {
1047
1038
  const blocks = items.map((item, i) => this.renderItemBlock(item, i, width, theme, mdTheme));
1048
1039
  const heights = blocks.map(b => b.length);
1049
- this.ensureVisible(heights, contentHeight);
1040
+ this.ensureVisible(heights, bodyHeight);
1050
1041
  bodyLines = [];
1051
1042
  for (let i = this.scrollOffset; i < blocks.length; i++) {
1052
1043
  // Always show the first windowed entry (the selected one fits by
1053
1044
  // construction); stop before a later entry would overflow the budget.
1054
- if (bodyLines.length > 0 && bodyLines.length + heights[i] > contentHeight) break;
1045
+ if (bodyLines.length > 0 && bodyLines.length + heights[i] > bodyHeight) break;
1055
1046
  bodyLines.push(...blocks[i]);
1056
1047
  }
1057
1048
  }
1058
1049
 
1059
- return [...topLines, ...bodyLines, ...bottomLines];
1050
+ return fitToHeight([...topLines, ...fitToHeight(bodyLines, bodyHeight), ...bottomLines], contentHeight + ZOOM_CHROME_ROWS);
1060
1051
  }
1061
1052
  }
1062
1053
 
@@ -1066,6 +1057,8 @@ class ZoomUI {
1066
1057
  // connector. Every row shows a live duration; the footer carries the grand total.
1067
1058
  // Shares the zoom overlay's chrome (bordered header/footer, windowed body) and is
1068
1059
  // re-rendered on a 1s tick so running durations advance while it is open.
1060
+ const HISTORY_CHROME_ROWS = 6;
1061
+
1069
1062
  class HistoryUI {
1070
1063
  private scrollOffset = 0;
1071
1064
  private followTail = true;
@@ -1205,7 +1198,7 @@ class HistoryUI {
1205
1198
  return rows;
1206
1199
  }
1207
1200
 
1208
- render(width: number, height: number, theme: any): string[] {
1201
+ render(width: number, contentHeight: number, theme: any): string[] {
1209
1202
  const entries = this.getEntries();
1210
1203
  const now = Date.now();
1211
1204
  const runningCount = entries.filter(e => e.status === "running" && e.kind !== "orchestrator").length;
@@ -1242,20 +1235,20 @@ class HistoryUI {
1242
1235
  bottom.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
1243
1236
  const bottomLines = bottom.render(width);
1244
1237
 
1245
- const contentHeight = Math.max(3, height - topLines.length - bottomLines.length);
1246
1238
  const rows = this.buildRows(childrenOf, width, theme, now);
1239
+ const bodyHeight = Math.max(0, contentHeight + HISTORY_CHROME_ROWS - topLines.length - bottomLines.length);
1247
1240
 
1248
1241
  let bodyLines: string[];
1249
1242
  if (rows.length === 0) {
1250
1243
  bodyLines = [theme.fg("dim", " No dispatches yet — history fills as agents run.")];
1251
1244
  } else {
1252
- const maxOffset = Math.max(0, rows.length - contentHeight);
1245
+ const maxOffset = Math.max(0, rows.length - bodyHeight);
1253
1246
  if (this.followTail) this.scrollOffset = maxOffset;
1254
1247
  this.scrollOffset = Math.max(0, Math.min(this.scrollOffset, maxOffset));
1255
- bodyLines = rows.slice(this.scrollOffset, this.scrollOffset + contentHeight);
1248
+ bodyLines = rows.slice(this.scrollOffset, this.scrollOffset + bodyHeight);
1256
1249
  }
1257
1250
 
1258
- return [...topLines, ...bodyLines, ...bottomLines];
1251
+ return fitToHeight([...topLines, ...fitToHeight(bodyLines, bodyHeight), ...bottomLines], contentHeight + HISTORY_CHROME_ROWS);
1259
1252
  }
1260
1253
  }
1261
1254
 
@@ -1795,6 +1788,8 @@ export default function (pi: ExtensionAPI) {
1795
1788
  pi.registerFlag("color", { description: "Coms: hex color #RRGGBB (else frontmatter or palette fallback)", type: "string", default: undefined });
1796
1789
  pi.registerFlag("explicit", { description: "Coms: hide from auto-discovery; addressable only by exact name", type: "boolean", default: false });
1797
1790
  pi.registerFlag("solo", { description: "Run without the coms layer (fixed specialists + research only — `just fleet hub --solo`)", type: "boolean", default: false });
1791
+ pi.registerFlag("posture", { description: "Fleet main-agent posture: operator|orchestrator", type: "string", default: undefined });
1792
+ pi.registerFlag("agent-team", { description: "Internal: activate a named native roster from .pi/agents/teams.yaml", type: "string", default: undefined });
1798
1793
 
1799
1794
  // ── Embedded coms: peer state ──
1800
1795
  let identity: {
@@ -1979,7 +1974,7 @@ export default function (pi: ExtensionAPI) {
1979
1974
  // editor; "compact" = one line per *running* agent (name · context · state)
1980
1975
  // rendered BELOW the editor, just above the footer. Compact is the default;
1981
1976
  // idle/done agents are hidden so an idle session shows only the prompt + footer.
1982
- let viewMode: "dashboard" | "compact" = "compact";
1977
+ let viewMode: "compact" | "off" = "compact";
1983
1978
  // Compact-view agent switcher: the key of the marked subagent (lowercase persona
1984
1979
  // name for team specialists, `rN` for research helpers — matching /af-zoom
1985
1980
  // resolution), or null when nothing is marked. main is never listed (it is the
@@ -2101,9 +2096,9 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2101
2096
  // at fast mode's 45-minute envelope that hard-stops a task with two dispatches
2102
2097
  // spent. A false stop is worse than no stop: it teaches people to reset the
2103
2098
  // task window reflexively, which is the one thing that must stay deliberate.
2104
- // `taskActiveMs` accumulates finished turns; the open turn is added at check time.
2105
- let taskActiveMs = 0;
2106
- let turnAskUserWaitMs = 0;
2099
+ // The explicit clock state makes `active` authoritative: a stale timestamp can
2100
+ // never turn inter-turn idle time into task work.
2101
+ let taskClock = createTaskClock();
2107
2102
  // Review dispatches spent on this task (review-round cap).
2108
2103
  let taskReviewRounds = 0;
2109
2104
  // Task tier (complexity triage): declared by the dispatcher via set_task_tier.
@@ -2149,24 +2144,20 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2149
2144
  * minus its ask_user waits. An ask_user still in flight is subtracted too, so
2150
2145
  * the clock does not tick while the dispatcher sits at a question.
2151
2146
  */
2152
- function taskActiveElapsedMs(): number {
2147
+ function taskActiveElapsedMs(now = Date.now()): number {
2153
2148
  let openWait = 0;
2154
- const now = Date.now();
2155
2149
  for (const startedAt of askUserStarts.values()) openWait += Math.max(0, now - startedAt);
2156
- return taskActiveMs + turnActiveMs(currentTurnStartedAt, now, turnAskUserWaitMs + openWait);
2150
+ return taskClockElapsedMs(taskClock, now, openWait);
2157
2151
  }
2158
2152
  /** Fold the turn that is ending into the task's active-time accumulator. */
2159
- function closeTurnActiveTime() {
2160
- if (!currentTurnStartedAt) return;
2161
- taskActiveMs += turnActiveMs(currentTurnStartedAt, Date.now(), turnAskUserWaitMs);
2162
- turnAskUserWaitMs = 0;
2153
+ function closeTurnActiveTime(now = Date.now()) {
2154
+ taskClock = closeTaskClock(taskClock, now);
2163
2155
  }
2164
2156
  /** Clear the task window: counters, tier, clock, review rounds, blocker breaker. */
2165
- function resetTaskWindow(label: string | null = null) {
2157
+ function resetTaskWindow(label: string | null = null, now = Date.now()) {
2166
2158
  taskDispatchCount = 0;
2167
2159
  taskResearchCount = 0;
2168
- taskActiveMs = 0;
2169
- turnAskUserWaitMs = 0;
2160
+ taskClock = resetTaskClock(taskClock, now);
2170
2161
  taskReviewRounds = 0;
2171
2162
  taskLabel = label;
2172
2163
  taskTier = null;
@@ -2177,6 +2168,56 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2177
2168
  turnDispatchFingerprints.clear();
2178
2169
  updateModeStatus();
2179
2170
  }
2171
+ function hubAuditIdentity(ctx?: ExtensionContext) {
2172
+ return buildHubAuditIdentity({
2173
+ cwd: ctx?.cwd ?? identity?.cwd ?? currentCtx?.cwd ?? process.cwd(),
2174
+ pid: process.pid,
2175
+ sessionId: identity?.session_id,
2176
+ project: identity?.project,
2177
+ workspaceId: process.env.HERDR_WORKSPACE_ID,
2178
+ paneId: process.env.HERDR_PANE_ID,
2179
+ });
2180
+ }
2181
+ function hubLocationSuffix(ctx?: ExtensionContext): string {
2182
+ const where = hubAuditIdentity(ctx);
2183
+ return `\nRepository: ${where.cwd ?? "unknown"}${where.herdr_pane_id ? ` · pane ${where.herdr_pane_id}` : ""}`;
2184
+ }
2185
+ function appendHubModeEntry(input: {
2186
+ previousMode: string;
2187
+ mode: string;
2188
+ source: "slash-command" | "project-override" | "default";
2189
+ overrideFile?: string | null;
2190
+ ctx?: ExtensionContext;
2191
+ }) {
2192
+ try {
2193
+ pi.appendEntry("agent-hub-mode", buildHubModeAudit({
2194
+ ...input,
2195
+ taskTier,
2196
+ turnDispatches: turnDispatchCount,
2197
+ turnResearch: turnResearchCount,
2198
+ identity: hubAuditIdentity(input.ctx),
2199
+ }));
2200
+ } catch { /* diagnostics are best-effort; state changes still succeed */ }
2201
+ }
2202
+ function taskResetSnapshot(now = Date.now()) {
2203
+ return {
2204
+ tier: taskTier,
2205
+ dispatches: taskDispatchCount,
2206
+ research: taskResearchCount,
2207
+ reviewRounds: taskReviewRounds,
2208
+ activeMs: taskActiveElapsedMs(now),
2209
+ };
2210
+ }
2211
+ function appendTaskResetEntry(source: "slash-command" | "tool:set_task_tier", label: string | null, prior: ReturnType<typeof taskResetSnapshot>, ctx?: ExtensionContext) {
2212
+ try {
2213
+ pi.appendEntry("agent-hub-task-reset", buildTaskResetAudit({
2214
+ source,
2215
+ label,
2216
+ prior,
2217
+ identity: hubAuditIdentity(ctx),
2218
+ }));
2219
+ } catch { /* diagnostics are best-effort; state changes still succeed */ }
2220
+ }
2180
2221
  function updateModeStatus() {
2181
2222
  try {
2182
2223
  widgetCtx?.ui?.setStatus(
@@ -2674,8 +2715,7 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2674
2715
 
2675
2716
  // Auto-size grid columns based on team size
2676
2717
  function recomputeGrid() {
2677
- const size = agentStates.size;
2678
- gridCols = size <= 3 ? size : size === 4 ? 2 : 3;
2718
+ gridCols = gridColumnsForSize(agentStates.size);
2679
2719
  }
2680
2720
 
2681
2721
  function activateTeam(teamName: string) {
@@ -2709,6 +2749,7 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2709
2749
  }
2710
2750
  const adoption = adoptableSessionFile(def);
2711
2751
  agentStates.set(def.name.toLowerCase(), freshAgentState(def, adoption));
2752
+ if (!activeTeamName) activeTeamName = "ad-hoc";
2712
2753
  recomputeGrid();
2713
2754
  updateWidget();
2714
2755
  const quarantineNote = adoption.quarantined
@@ -2726,10 +2767,11 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2726
2767
  if (state.status === "running") {
2727
2768
  return { ok: false, message: `${displayName(state.def.name)} is running — wait for it to finish or /af-agents-kill it first` };
2728
2769
  }
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` };
2770
+ if (orchestratorNeedsRoster(posture, agentStates.size - 1)) {
2771
+ 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
2772
  }
2732
2773
  agentStates.delete(key);
2774
+ if (agentStates.size === 0) activeTeamName = "";
2733
2775
  recomputeGrid();
2734
2776
  updateWidget();
2735
2777
  // Promise a reusable session file only when pi would actually accept it.
@@ -2912,60 +2954,6 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2912
2954
  // Cap on nested rows per card; beyond it a "+N more" summary line renders.
2913
2955
  const MAX_CHILD_ROWS = 6;
2914
2956
 
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
2957
  // A research-helper card. Mirrors renderCard's compact two-line layout while
2970
2958
  // keeping the `rN` handle + persona/anon label + turn in the name slot.
2971
2959
  function renderResearchCard(state: ResearchState, colWidth: number, theme: any): string[] {
@@ -3001,41 +2989,9 @@ APIs, commands, structure), say so in your final response so the docs can be upd
3001
2989
 
3002
2990
  return {
3003
2991
  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
- }
3012
-
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
- }
2992
+ // The full fleet list is now a separate overlay; this legacy widget is retired.
2993
+ return [];
3029
2994
 
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
2995
  },
3040
2996
  invalidate() {
3041
2997
  text.invalidate();
@@ -3066,30 +3022,21 @@ APIs, commands, structure), say so in your final response so the docs can be upd
3066
3022
 
3067
3023
  // Compact mode hides the research grid; running helpers are folded
3068
3024
  // into the belowEditor "agent-running" widget instead.
3069
- if (viewMode === "compact") return [];
3025
+ if (!compactWidgetsEnabled(viewMode)) return [];
3070
3026
 
3071
- const cols = Math.min(gridCols, states.length);
3027
+ const cols = gridColumnsForItems(gridCols, states.length);
3072
3028
  const gap = 1;
3073
3029
  const colWidth = Math.floor((width - gap * (cols - 1)) / cols);
3074
3030
  const labelText = "── research ";
3075
3031
  const header = theme.fg("dim", labelText + "─".repeat(Math.max(0, width - labelText.length)));
3076
- const rows: string[][] = [];
3077
-
3078
- for (let i = 0; i < states.length; i += cols) {
3079
- const rowStates = states.slice(i, i + cols);
3080
- const cards = rowStates.map(s => renderResearchCard(s, colWidth, theme));
3081
-
3082
- while (cards.length < cols) {
3083
- cards.push(Array(CARD_HEIGHT).fill(" ".repeat(Math.max(0, colWidth))));
3084
- }
3085
-
3086
- const cardHeight = cards[0].length;
3087
- for (let line = 0; line < cardHeight; line++) {
3088
- rows.push(cards.map(card => card[line] || ""));
3089
- }
3090
- }
3091
-
3092
- const grid = rows.map(cs => cs.join(" ".repeat(gap)));
3032
+ const grid = renderCardGrid(
3033
+ states,
3034
+ cols,
3035
+ CARD_HEIGHT,
3036
+ s => renderResearchCard(s, colWidth, theme),
3037
+ " ".repeat(gap),
3038
+ " ".repeat(Math.max(0, colWidth)),
3039
+ );
3093
3040
  text.setText([header, ...grid].join("\n"));
3094
3041
  return text.render(width);
3095
3042
  },
@@ -3151,7 +3098,7 @@ APIs, commands, structure), say so in your final response so the docs can be upd
3151
3098
  widgetCtx.ui.setWidget("agent-running", (_tui: any, theme: any) => ({
3152
3099
  invalidate() {},
3153
3100
  render(width: number): string[] {
3154
- if (viewMode !== "compact") return [];
3101
+ if (!compactWidgetsEnabled(viewMode)) return [];
3155
3102
  const running = switchableAgents();
3156
3103
  if (running.length === 0) return [];
3157
3104
  const nameWidth = Math.min(24, Math.max(...running.map(r => visibleWidth(r.name))));
@@ -3530,6 +3477,7 @@ ${externalBlockedProtocol()}
3530
3477
  inputArtifacts: InputArtifactPreview[] = [],
3531
3478
  scopeGlobs: string[] = [],
3532
3479
  watchdogParam?: boolean,
3480
+ requestedBackend: "auto" | "native" | "coms" = "auto",
3533
3481
  ): Promise<{
3534
3482
  output: string;
3535
3483
  exitCode: number;
@@ -3562,6 +3510,8 @@ ${externalBlockedProtocol()}
3562
3510
  state.toolCount = 0;
3563
3511
  state.elapsed = 0;
3564
3512
  state.lastWork = "";
3513
+ state.lastBackend = undefined;
3514
+ state.comsPeerModel = undefined;
3565
3515
  state.runCount++;
3566
3516
  state.killedByOperator = false;
3567
3517
  state.restarting = false;
@@ -3616,7 +3566,18 @@ ${externalBlockedProtocol()}
3616
3566
 
3617
3567
  const personaKey = state.def.name.toLowerCase();
3618
3568
  const livePeerNames = () => (comsReady && identity ? peersInScope().map(e => e.name) : []);
3619
- let route: any = resolveDispatchBackend({ agentName: state.def.name, policy: dispatchPolicy, livePeerNames: livePeerNames() });
3569
+ let route: any = resolveDispatchBackend({
3570
+ agentName: state.def.name,
3571
+ policy: dispatchPolicy,
3572
+ livePeerNames: livePeerNames(),
3573
+ requestedBackend,
3574
+ });
3575
+ if (route.backend === "invalid") {
3576
+ return finishRun(`Invalid dispatch backend "${route.requestedBackend}". Expected auto|native|coms.`, 1);
3577
+ }
3578
+ if (route.backend === "coms-unavailable") {
3579
+ return finishRun(explicitComsRefusal(displayName(state.def.name)), 1);
3580
+ }
3620
3581
  if (route.backend === "await-coms") {
3621
3582
  // coms-required member (fallback: none) whose peer is not live yet:
3622
3583
  // poll the pool through the grace window, then refuse with guidance.
@@ -3626,7 +3587,7 @@ ${externalBlockedProtocol()}
3626
3587
  updateWidget();
3627
3588
  while (Date.now() < deadline && route.backend !== "coms") {
3628
3589
  await new Promise(res => setTimeout(res, 1000));
3629
- route = resolveDispatchBackend({ agentName: state.def.name, policy: dispatchPolicy, livePeerNames: livePeerNames() });
3590
+ route = resolveDispatchBackend({ agentName: state.def.name, policy: dispatchPolicy, livePeerNames: livePeerNames(), requestedBackend });
3630
3591
  }
3631
3592
  if (route.backend !== "coms") {
3632
3593
  return finishRun(comsRequiredRefusal(displayName(state.def.name), graceS), 1);
@@ -3638,7 +3599,7 @@ ${externalBlockedProtocol()}
3638
3599
  }
3639
3600
  if (route.backend === "coms") {
3640
3601
  void monitorBridge?.registerWaitOnly(monitorKey, () => state.comsAbort?.());
3641
- const allowNativeFallback = (dispatchPolicy.substitutions[personaKey]?.fallback ?? "native") !== "none";
3602
+ const allowNativeFallback = !route.explicit && (dispatchPolicy.substitutions[personaKey]?.fallback ?? "native") !== "none";
3642
3603
  const timeoutMs = route.timeout_s ? route.timeout_s * 1000 : TIMEOUT_MS;
3643
3604
  const comsRes = await dispatchViaComs(state, task, route.peerName, timeoutMs, allowNativeFallback, ctx, inputArtifacts, scopeGlobs);
3644
3605
  if (comsRes) {
@@ -4307,6 +4268,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
4307
4268
  updateResearchWidget();
4308
4269
 
4309
4270
  const histEntry = historyStart("research", `Research r${state.id}`);
4271
+ state.histEntry = histEntry;
4310
4272
 
4311
4273
  const startTime = Date.now();
4312
4274
  state.timer = setInterval(() => {
@@ -4743,57 +4705,47 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
4743
4705
  return null;
4744
4706
  }
4745
4707
 
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 [];
4708
+ let cachedRegistryProject: string | undefined;
4709
+ let cachedRegistryEntries: ComsRegistryEntry[] = [];
4710
+ let cachedRegistryAt = 0;
4711
+ const scrubFleetText = (text: string) => text.replace(/[\x00-\x1f\x7f]+/g, " ").replace(/\s+/g, " ").trim();
4712
+ /** Build the one peer source consumed by both the compact pool and dashboard. */
4713
+ function fleetPeerInputs(formatModel: (model: string) => string = (model) => model): PeerInput[] {
4749
4714
  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[] = [];
4715
+ if (cachedRegistryProject !== projectFilter || Date.now() - cachedRegistryAt > 1000) {
4716
+ cachedRegistryProject = projectFilter;
4717
+ cachedRegistryEntries = projectFilter === "*" ? readAllRegistryEntriesAcrossProjects() : readAllRegistryEntries(projectFilter);
4718
+ cachedRegistryAt = Date.now();
4719
+ }
4720
+ const registryEntries = cachedRegistryEntries;
4721
+ const peers: PeerInput[] = [];
4764
4722
  const seenSessions = new Set<string>();
4723
+ const seenNames = new Set<string>();
4765
4724
 
4766
4725
  for (const [sid, card] of peerCards.entries()) {
4767
4726
  if (identity && sid === identity.session_id) continue;
4768
4727
  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
- });
4728
+ seenNames.add(card.name);
4729
+ peers.push({ key: `peer:${sid}`, name: scrubFleetText(card.name), model: formatModel(card.model), lastWork: scrubFleetText(card.purpose), colorHex: card.color, staleCount: card.staleCount });
4778
4730
  }
4779
4731
 
4780
- // Registry-only entries that aren't yet in peerCards → pending
4781
- const seenNames = new Set(rows.map((r) => r.name));
4732
+ // Registry-only entries have not answered a ping, so the read model owns their pending status.
4782
4733
  for (const entry of registryEntries) {
4783
4734
  if (identity && entry.session_id === identity.session_id) continue;
4784
4735
  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
- });
4736
+ if (seenSessions.has(entry.session_id) || seenNames.has(entry.name)) continue;
4737
+ 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
4738
  }
4739
+ return peers;
4740
+ }
4741
+
4742
+ function renderPool(width: number, theme: Theme): string[] {
4743
+ // Compact mode hides the coms pool too — only running agents show below the editor.
4744
+ if (!compactWidgetsEnabled(viewMode)) return [];
4745
+ const rows = buildFleetRows(
4746
+ { specialists: [], research: [], peers: fleetPeerInputs() },
4747
+ { showFinished: true },
4748
+ );
4797
4749
 
4798
4750
  // Border helpers — sandwich the body with single-line box-drawing rules
4799
4751
  // so the widget reads as its own block. The top border carries a branded
@@ -4840,27 +4792,29 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
4840
4792
  const out: string[] = [topBorder];
4841
4793
 
4842
4794
  for (const r of rows) {
4843
- const pctNum = r.pct ?? 0;
4795
+ const pctNum = r.contextPct ?? 0;
4844
4796
  const filled = Math.max(0, Math.min(15, Math.round((pctNum / 100) * 15)));
4845
4797
  const empty = 15 - filled;
4846
- const pctLabel = r.pct == null ? "--%" : `${r.pct}%`;
4798
+ const pctLabel = r.contextPct == null ? "--%" : `${r.contextPct}%`;
4847
4799
 
4848
- if (r.stale) {
4849
- const dimRow = `✗ ${r.name.padEnd(12)} ${abbreviateModel(r.model).padEnd(14)} [${"-".repeat(15)}] ${pctLabel.padStart(4)} — ${r.purpose || ""}`;
4800
+ if (r.status === "stale") {
4801
+ const dimRow = `✗ ${r.name.padEnd(12)} ${abbreviateModel(r.model).padEnd(14)} [${"-".repeat(15)}] ${pctLabel.padStart(4)} — ${r.lastWork || ""}`;
4850
4802
  out.push(truncateToWidth(" " + theme.fg("dim", dimRow), width));
4851
4803
  continue;
4852
4804
  }
4853
4805
 
4854
- const swatch = r.pending ? theme.fg("dim", "●") : hexFg(r.color, "●");
4806
+ const pending = r.status === "pending";
4807
+ const color = r.colorHex ?? "#808080";
4808
+ const swatch = pending ? theme.fg("dim", "●") : hexFg(color, "●");
4855
4809
  const namePart = theme.fg("accent", r.name.padEnd(12));
4856
4810
  const modelPart = theme.fg("dim", abbreviateModel(r.model).padEnd(14));
4857
- const barFill = r.pending
4811
+ const barFill = pending
4858
4812
  ? theme.fg("dim", "-".repeat(15))
4859
- : hexFg(r.color, "#".repeat(filled)) + theme.fg("dim", "-".repeat(empty));
4813
+ : hexFg(color, "#".repeat(filled)) + theme.fg("dim", "-".repeat(empty));
4860
4814
  const bar = theme.fg("warning", "[") + barFill + theme.fg("warning", "]");
4861
4815
  const pctPart = " " + theme.fg("accent", pctLabel.padStart(4));
4862
4816
  const sep = theme.fg("dim", " — ");
4863
- const purposePart = theme.fg("muted", r.purpose || "");
4817
+ const purposePart = theme.fg("muted", r.lastWork || "");
4864
4818
 
4865
4819
  const line = " " + swatch + " " + namePart + " " + modelPart + " " + bar + pctPart + sep + purposePart;
4866
4820
  out.push(truncateToWidth(line, width));
@@ -5031,10 +4985,15 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5031
4985
  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
4986
  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
4987
  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`." })),
4988
+ backend: Type.Optional(Type.Union([
4989
+ Type.Literal("auto"),
4990
+ Type.Literal("native"),
4991
+ Type.Literal("coms"),
4992
+ ], { 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
4993
  }),
5035
4994
 
5036
4995
  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 };
4996
+ 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
4997
  // Display names / underscores resolve to the persona slug key space, so
5039
4998
  // `agent: "Test Engineer"` never burns a dispatch on a lookup error.
5040
4999
  const agent = normalizeAgentInput((params as { agent: string }).agent);
@@ -5166,7 +5125,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5166
5125
  const findingClause = reviewBudgetClause(taskTier, agent);
5167
5126
  const dispatchedTask = findingClause ? `${task}\n\n${findingClause}` : task;
5168
5127
 
5169
- let result = await dispatchAgent(agent, dispatchedTask, ctx, inputArtifacts, scopeGlobs, watchdog);
5128
+ let result = await dispatchAgent(agent, dispatchedTask, ctx, inputArtifacts, scopeGlobs, watchdog, backend);
5170
5129
  let dispatchBilled = result.billed ?? 0;
5171
5130
  let dispatchOut = result.out ?? 0;
5172
5131
 
@@ -5226,7 +5185,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5226
5185
  const resumePrompt = "Research findings for your NEEDS_RESEARCH questions are ready. " +
5227
5186
  "Read each file with your read tool, then continue from where you paused:\n" +
5228
5187
  answered.map((a, i) => `${i + 1}. ${a.question}\n → ${a.file}`).join("\n");
5229
- result = await dispatchAgent(agent, resumePrompt, ctx, inputArtifacts, scopeGlobs, watchdog);
5188
+ result = await dispatchAgent(agent, resumePrompt, ctx, inputArtifacts, scopeGlobs, watchdog, backend);
5230
5189
  dispatchBilled += result.billed ?? 0;
5231
5190
  dispatchOut += result.out ?? 0;
5232
5191
  }
@@ -5403,6 +5362,8 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5403
5362
  agent,
5404
5363
  task,
5405
5364
  status,
5365
+ backendRequested: backend,
5366
+ backendUsed: state?.lastBackend ?? null,
5406
5367
  elapsed: result.elapsed,
5407
5368
  exitCode: result.exitCode,
5408
5369
  fullOutput: result.output,
@@ -5686,17 +5647,22 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5686
5647
  }),
5687
5648
  async execute(_callId, params, _signal, _onUpdate, _ctx) {
5688
5649
  const { tier, reason, new_task } = params as { tier: string; reason?: string; new_task?: boolean };
5689
- if (new_task) resetTaskWindow(null);
5690
- // An ASSUMED tier is the hub's fail-safe, not a declaration to ratchet
5691
- // against: the dispatcher's own first triage must not be refused as an
5692
- // "escalation" for lacking a reason it had no way to know it needed.
5693
- const change = applyTierChange(taskTierAssumed ? null : taskTier, tier, reason);
5650
+ // A new task classifies from an empty ratchet. Validate the requested tier
5651
+ // before mutating/resetting anything so invalid input cannot erase a task.
5652
+ const currentTier = new_task ? null : (taskTierAssumed ? null : taskTier);
5653
+ const change = applyTierChange(currentTier, tier, reason);
5694
5654
  if (!change.ok) {
5695
5655
  return {
5696
5656
  content: [{ type: "text" as const, text: change.message }],
5697
5657
  details: { status: "error", reason: change.reason, tier: change.tier },
5698
5658
  };
5699
5659
  }
5660
+ if (new_task) {
5661
+ const resetAt = Date.now();
5662
+ const prior = taskResetSnapshot(resetAt);
5663
+ resetTaskWindow(null, resetAt);
5664
+ appendTaskResetEntry("tool:set_task_tier", null, prior, _ctx);
5665
+ }
5700
5666
  taskTier = change.tier;
5701
5667
  taskTierAssumed = false;
5702
5668
  turnReport.tier = change.tier;
@@ -6326,22 +6292,22 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6326
6292
  }
6327
6293
  }
6328
6294
 
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();
6295
+ /** Manifest and persona probes supplied to the shared Fleet peer resolver. */
6296
+ function peerManifest(cwd: string): string {
6337
6297
  try {
6338
- const raw = fs.readFileSync(path.join(cwd, ".pi", "agents", "peers.yaml"), "utf-8");
6339
- return findPeerByName(parsePeersYaml(raw), name);
6298
+ return fs.readFileSync(path.join(cwd, ".pi", "agents", "peers.yaml"), "utf-8");
6340
6299
  } catch {
6341
- return undefined;
6300
+ return "";
6342
6301
  }
6343
6302
  }
6344
6303
 
6304
+ function peerPersonaExists(cwd: string, persona: string): boolean {
6305
+ return (
6306
+ fs.existsSync(path.join(cwd, "agents", `${persona}.md`)) ||
6307
+ fs.existsSync(path.join(cwd, ".pi", "agents", `${persona}.md`))
6308
+ );
6309
+ }
6310
+
6345
6311
  /** Seconds this spawn should sleep before launching pi (stale-OAuth lock race). */
6346
6312
  function spawnDelaySeconds(): number {
6347
6313
  let authRaw: string | undefined;
@@ -6362,12 +6328,16 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6362
6328
  name: "herdr_spawn_peer",
6363
6329
  label: "Herdr Spawn Peer",
6364
6330
  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.",
6331
+ "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
6332
  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)." })),
6333
+ name: Type.String({ description: "Pane label and coms peer name." }),
6334
+ runner: Type.Optional(Type.Union([Type.Literal("pi"), Type.Literal("claude-code")], { description: "Override the declared runner." })),
6335
+ persona: Type.Optional(Type.String({ description: "Explicit Pi persona under agents/ or .pi/agents/." })),
6336
+ no_persona: Type.Optional(Type.Boolean({ description: "Force a personaless Fleet Core Pi peer." })),
6337
+ model: Type.Optional(Type.String({ description: "Override the declared model." })),
6338
+ extensions: Type.Optional(Type.String({ description: "Comma-separated extensions for a Pi persona peer." })),
6339
+ browser: Type.Optional(Type.Boolean({ description: "Add browser capability to a Pi peer." })),
6340
+ all_extensions: Type.Optional(Type.Boolean({ description: "Load all extensions; personaless Fleet Core only." })),
6371
6341
  direction: Type.Optional(Type.Union([Type.Literal("right"), Type.Literal("down")], { description: "Split direction (default right)." })),
6372
6342
  }),
6373
6343
  async execute(_callId, params) {
@@ -6378,85 +6348,122 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6378
6348
  if (!ownPane) {
6379
6349
  return { content: [{ type: "text" as const, text: "not inside a herdr pane." }], details: { error: "no pane" } };
6380
6350
  }
6351
+ if (!comsReady || !identity) {
6352
+ return {
6353
+ 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." }],
6354
+ details: { error: "no coms" },
6355
+ };
6356
+ }
6381
6357
  try {
6382
6358
  const cwd = currentCtx?.cwd ?? process.cwd();
6359
+ const plan = buildHubPeerSpawnPlan(params, {
6360
+ project: identity.project,
6361
+ peersYaml: peerManifest(cwd),
6362
+ personaExists: (persona) => peerPersonaExists(cwd, persona),
6363
+ worktreeTag: worktreeTag(cwd),
6364
+ });
6365
+ if (peersInScope().some(peer => peer.name.toLowerCase() === plan.name.toLowerCase())) {
6366
+ throw new Error(`Peer "${plan.name}" is already visible in project "${identity.project}"; use coms_send instead of spawning a duplicate.`);
6367
+ }
6383
6368
  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" } };
6369
+ if (plan.envFile) {
6370
+ const envPath = resolveEnvFilePath(plan.envFile, cwd);
6371
+ if (!fs.existsSync(envPath)) throw new Error(`env_file not found: ${plan.envFile} (resolved: ${envPath})`);
6372
+ Object.assign(env, parseEnvFile(fs.readFileSync(envPath, "utf-8"), plan.envFile));
6411
6373
  }
6412
- // pane.split takes no command — it opens a shell in `cwd`.
6374
+ const delay = plan.runner === "pi" ? spawnDelaySeconds() : 0;
6375
+ if (delay > 0) env[STAGGER_ENV_VAR] = String(delay);
6376
+ const launched = await launchHubPeerInPane(plan, {
6377
+ client: herdrApi,
6378
+ targetPaneId: ownPane,
6379
+ cwd,
6380
+ env,
6381
+ waitForRegistration: waitForPeerRegistration,
6382
+ paneTail,
6383
+ onLaunched: (paneId) => {
6384
+ hubSpawnedPeers.set(plan.name.toLowerCase(), { name: plan.name, paneId, addressed: false });
6385
+ if (plan.runner === "pi") lastHubPiSpawnAt = Date.now();
6386
+ },
6387
+ });
6388
+ const promptNote = launched.promptSeen
6389
+ ? ""
6390
+ : `\n⚠ pane ${launched.paneId} showed no shell prompt within ${Math.round(PANE_PROMPT_TIMEOUT_MS / 1000)}s; the command was sent anyway.`;
6391
+ return {
6392
+ content: [{ type: "text" as const, text: `spawned ${plan.kind} in pane ${launched.paneId} (${plan.name}): ${plan.command.join(" ")}${promptNote}\n\n${launched.verdict.message}` }],
6393
+ details: {
6394
+ pane_id: launched.paneId,
6395
+ name: plan.name,
6396
+ kind: plan.kind,
6397
+ runner: plan.runner,
6398
+ project: plan.project,
6399
+ prompt_seen: launched.promptSeen,
6400
+ env_file: plan.envFile ?? null,
6401
+ ...launched.verdict,
6402
+ },
6403
+ };
6404
+ } catch (err) {
6405
+ const m = err instanceof Error ? err.message : String(err);
6406
+ return { content: [{ type: "text" as const, text: `herdr_spawn_peer failed before readiness: ${m}` }], details: { error: m } };
6407
+ }
6408
+ },
6409
+ renderCall(args, theme) {
6410
+ const a = args as any;
6411
+ return new Text(
6412
+ theme.fg("toolTitle", theme.bold("herdr_spawn_peer ")) + theme.fg("accent", a.name ?? "?") + theme.fg("dim", a.runner ? ` (${a.runner})` : ""),
6413
+ 0, 0,
6414
+ );
6415
+ },
6416
+ renderResult(result, _options, theme) {
6417
+ const d = result.details as any;
6418
+ if (d?.error) return new Text(theme.fg("error", `✗ ${d.error}`), 0, 0);
6419
+ if (d?.peer_ready === false) return new Text(theme.fg("error", `✗ ${d?.pane_id ?? "peer failed"}`), 0, 0);
6420
+ return new Text(theme.fg("success", `✓ ${d?.pane_id ?? "spawned"}`), 0, 0);
6421
+ },
6422
+ });
6423
+
6424
+ pi.registerTool({
6425
+ name: "herdr_spawn_pane",
6426
+ label: "Herdr Spawn Pane",
6427
+ description:
6428
+ "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.",
6429
+ parameters: Type.Object({
6430
+ name: Type.String({ description: "Human-visible pane label." }),
6431
+ command: Type.String({ description: "Raw shell command executed with bash -lc." }),
6432
+ direction: Type.Optional(Type.Union([Type.Literal("right"), Type.Literal("down")], { description: "Split direction (default right)." })),
6433
+ }),
6434
+ async execute(_callId, params) {
6435
+ if (!herdrFleetReady) {
6436
+ return { content: [{ type: "text" as const, text: "herdr is not available in this session." }], details: { error: "no herdr" } };
6437
+ }
6438
+ const ownPane = herdrPaneId();
6439
+ if (!ownPane) {
6440
+ return { content: [{ type: "text" as const, text: "not inside a herdr pane." }], details: { error: "no pane" } };
6441
+ }
6442
+ try {
6443
+ const cwd = currentCtx?.cwd ?? process.cwd();
6444
+ const argv = ["bash", "-lc", params.command];
6413
6445
  const { pane } = await herdrApi.paneSplit({
6414
6446
  target_pane_id: ownPane,
6415
6447
  direction: params.direction ?? "right",
6416
6448
  cwd,
6417
- ...(Object.keys(env).length > 0 ? { env } : {}),
6418
6449
  focus: false,
6419
6450
  });
6420
6451
  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
6452
  const launch = await launchPeerInPane(herdrApi, pane.pane_id, argv);
6423
- if (params.persona) lastHubPiSpawnAt = Date.now();
6424
6453
  const promptNote = launch.promptSeen
6425
6454
  ? ""
6426
6455
  : `\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
6456
  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 },
6457
+ content: [{ type: "text" as const, text: `spawned raw pane ${pane.pane_id} (${params.name}): ${params.command}${promptNote}` }],
6458
+ details: { pane_id: pane.pane_id, name: params.name, prompt_seen: launch.promptSeen },
6448
6459
  };
6449
6460
  } catch (err) {
6450
6461
  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 } };
6462
+ return { content: [{ type: "text" as const, text: `herdr_spawn_pane failed: ${m}` }], details: { error: m } };
6452
6463
  }
6453
6464
  },
6454
6465
  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
- );
6466
+ return new Text(theme.fg("toolTitle", theme.bold("herdr_spawn_pane ")) + theme.fg("accent", (args as any).name ?? "?"), 0, 0);
6460
6467
  },
6461
6468
  renderResult(result, _options, theme) {
6462
6469
  const d = result.details as any;
@@ -6586,6 +6593,32 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6586
6593
  // and warn the user to `pi install npm:pi-ask-user` if it's missing.
6587
6594
 
6588
6595
  let askUserAvailable = false;
6596
+ let posture: Posture = "operator";
6597
+ let baselineTools: string[] = [];
6598
+
6599
+ function applyPostureTools(): void {
6600
+ pi.setActiveTools(resolvePostureTools({
6601
+ posture,
6602
+ baselineTools,
6603
+ comsReady,
6604
+ herdrReady: herdrFleetReady,
6605
+ askUserAvailable,
6606
+ }));
6607
+ }
6608
+
6609
+ function updatePostureStatus(ctx: ExtensionContext): void {
6610
+ ctx.ui.setStatus("hub-posture", `Posture: ${posture}`);
6611
+ }
6612
+
6613
+ function postureStatusText(): string {
6614
+ return [
6615
+ `Posture: ${posture}`,
6616
+ `Direct tools: ${posture === "operator" ? "enabled" : "disabled"}`,
6617
+ `Native roster: ${activeTeamName || "(none)"} (${agentStates.size})`,
6618
+ `Coms: ${comsReady ? `ready${identity ? ` (${identity.name}@${identity.project})` : ""}` : "unavailable"}`,
6619
+ `Herdr: ${herdrFleetReady ? "ready" : "unavailable"}`,
6620
+ ].join("\n");
6621
+ }
6589
6622
 
6590
6623
  // ── Dispatcher persona picker (blocking gate) ──
6591
6624
  // Mirrors purpose-gate's blocking loop, but over a select of orchestrator
@@ -6644,29 +6677,158 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6644
6677
  },
6645
6678
  });
6646
6679
 
6680
+ let fleetShowFinished = false;
6681
+ let fleetFilter = "";
6682
+ function fleetRows(unfiltered = false): FleetRow[] {
6683
+ // agentStates is the roster and its live state in one keyed map: a dispatch
6684
+ // updates this row instead of adding a second live-specialist source.
6685
+ const specialists: SpecialistInput[] = Array.from(agentStates.entries()).map(([key, state]) => ({
6686
+ key, name: displayName(state.def.name), status: state.status,
6687
+ model: state.lastBackend === "coms" ? `⇄ ${shortModel(state.comsPeerModel)}` : modelWithThinking(state.def), backend: state.lastBackend ?? "native",
6688
+ contextPct: state.contextPct, contextTokens: state.contextTokens, ...fleetTiming(state.histEntry),
6689
+ toolCount: state.toolCount, lastWork: state.lastWork || state.task || state.def.description, hasTimeline: true,
6690
+ 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: [] })),
6691
+ }));
6692
+ 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 }));
6693
+ const peers = fleetPeerInputs(model => `⇄ ${abbreviateModel(model)}`);
6694
+ return buildFleetRows({ specialists, research, peers }, unfiltered ? { showFinished: true } : { showFinished: fleetShowFinished, query: fleetFilter });
6695
+ }
6696
+ async function openFleetDetail(row: FleetRow, ctx: any): Promise<void> {
6697
+ const target = row.kind === "research" ? researchStates.get(parseResearchHandle(row.key)!) : row.kind === "delegate" ? findDelegationChild(row.key)?.child : agentStates.get(row.key);
6698
+ const resources = createPanelResources();
6699
+ let scrollOffset = 0, selectedIndex = 0, expandedIndex: number | null = null, followTail = true, lastRender = 0;
6700
+ const timeline = () => liveTimeline(target);
6701
+ try { await ctx.ui.custom((tui: any, theme: any, _kb: any, done: () => void) => {
6702
+ if (target) target.zoomRender = (force?: boolean) => { const now = Date.now(); if (force || now - lastRender > 80) { lastRender = now; tui.requestRender(); } };
6703
+ 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() };
6704
+ }, FULLSCREEN_OVERLAY); } finally { resources.dispose(); if (target) target.zoomRender = undefined; }
6705
+ }
6706
+ async function restartFleetRow(selected: FleetRow, ctx: any): Promise<void> {
6707
+ const decision = resolveFleetRestart(selected, {
6708
+ researchRestartable: (key) => {
6709
+ const state = researchStates.get(parseResearchHandle(key)!);
6710
+ return !!(state?.task && state.status !== "running");
6711
+ },
6712
+ specialistRestartable: (key) => !!(agentStates.get(key)?.task),
6713
+ });
6714
+ if (decision.action === "unsupported") {
6715
+ ctx.ui.notify(decision.message, decision.level);
6716
+ return;
6717
+ }
6718
+ if (decision.action === "restart-research") {
6719
+ const state = researchStates.get(parseResearchHandle(selected.key)!);
6720
+ if (!state?.task) { ctx.ui.notify(decision.message.replace("Restarting", "Cannot restart"), "warning"); return; }
6721
+ state.sessionFile = null; state.turnCount = 1;
6722
+ ctx.ui.notify(decision.message, "info");
6723
+ spawnResearch(state, state.task, ctx).then(result => deliverResearchFollowUp(state, result));
6724
+ return;
6725
+ }
6726
+ const state = agentStates.get(selected.key);
6727
+ if (!state?.task) { ctx.ui.notify(decision.message.replace("Restarting", "Cannot restart"), "warning"); return; }
6728
+ if (state.status === "running" && (state.proc || state.comsAbort)) {
6729
+ let resolveTermination!: () => void;
6730
+ const terminated = new Promise<void>(resolve => { resolveTermination = resolve; });
6731
+ state.onTerminate = resolveTermination;
6732
+ if (state.proc) { state.killedByOperator = true; state.restarting = true; killPiTree(state.proc); }
6733
+ else await cancelLocalWaitOnly({ abort: state.comsAbort, monitorBridge, monitorKey: monitorKeyForAgent(state.def.name, state.runCount), event: { kind: "restart" } });
6734
+ await terminated;
6735
+ }
6736
+ state.sessionFile = null;
6737
+ ctx.ui.notify(decision.message.includes(displayName(state.def.name)) ? decision.message : `Restarting ${displayName(state.def.name)} (fresh)...`, "info");
6738
+ const result = await dispatchAgent(state.def.name, state.task, ctx);
6739
+ 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 });
6740
+ }
6741
+ async function openFleetDashboard(ctx: any): Promise<void> {
6742
+ const resources = createPanelResources();
6743
+ const selection: Selection = { index: 0 };
6744
+ let scrollOffset = 0;
6745
+ let filtering = false;
6746
+ let confirm: DashboardConfirm = null;
6747
+ const toInput = (data: string): string => {
6748
+ if (matchesKey(data, Key.up)) return "\u001b[A";
6749
+ if (matchesKey(data, Key.down)) return "\u001b[B";
6750
+ if (matchesKey(data, Key.pageUp)) return "\u001b[5~";
6751
+ if (matchesKey(data, Key.pageDown)) return "\u001b[6~";
6752
+ if (matchesKey(data, Key.enter)) return "\r";
6753
+ if (matchesKey(data, Key.escape)) return "\u001b";
6754
+ return data;
6755
+ };
6756
+ try {
6757
+ await ctx.ui.custom((tui: any, theme: any, _kb: any, done: () => void) => {
6758
+ attachFleetDashboardTicker(resources, () => tui.requestRender());
6759
+ return {
6760
+ render: (w: number) => {
6761
+ const rows = fleetRows();
6762
+ reconcileSelection(selection, rows);
6763
+ const body = bodyRows(tui.terminal?.rows, FLEET_CHROME_ROWS);
6764
+ scrollOffset = clampScroll(scrollOffset, rows.length, body);
6765
+ const summary = summarise(rows);
6766
+ return renderFleetDashboard({
6767
+ rows, selection, scrollOffset, filterQuery: fleetFilter, showFinished: fleetShowFinished,
6768
+ confirmation: confirm && confirm.until > Date.now()
6769
+ ? `press ${confirm.action === "kill" ? "x" : "r"} again to ${confirm.action} ${rows.find(r => r.key === confirm!.key)?.name ?? "agent"}`
6770
+ : undefined,
6771
+ summary: { ...summary, wallMs: unionMs(summary.intervals) },
6772
+ }, w, body, theme);
6773
+ },
6774
+ handleInput: async (data: string) => {
6775
+ const rows = fleetRows();
6776
+ reconcileSelection(selection, rows);
6777
+ const body = bodyRows(tui.terminal?.rows, FLEET_CHROME_ROWS);
6778
+ const state = { selection, scrollOffset, filtering, filterQuery: fleetFilter, showFinished: fleetShowFinished, confirm };
6779
+ const intent = dashboardTransition(toInput(data), state, rows, body);
6780
+ ({ scrollOffset, filtering, confirm } = state);
6781
+ fleetFilter = state.filterQuery;
6782
+ fleetShowFinished = state.showFinished;
6783
+ if (intent === "close") done();
6784
+ else if (intent && typeof intent === "object" && "open" in intent) {
6785
+ const selected = rows.find(r => r.key === intent.open) ?? rows[selection.index];
6786
+ if (selected) await openFleetDetail(selected, ctx);
6787
+ } else if (intent && typeof intent === "object" && "kill" in intent) {
6788
+ const selected = rows.find(r => r.key === intent.kill);
6789
+ if (!selected) ctx.ui.notify("Selected fleet row no longer exists.", "warning");
6790
+ else {
6791
+ const decision = resolveFleetKill(selected, {
6792
+ researchExists: (key) => !!researchStates.get(parseResearchHandle(key)!),
6793
+ agentHandles: (key) => {
6794
+ const agent = agentStates.get(key);
6795
+ return agent ? { proc: agent.proc, comsAbort: agent.comsAbort } : undefined;
6796
+ },
6797
+ });
6798
+ if (decision.action === "kill-research") {
6799
+ const rs = researchStates.get(parseResearchHandle(selected.key)!);
6800
+ if (rs) { removeResearchHelper(rs, ctx); ctx.ui.notify(decision.message, "info"); }
6801
+ else ctx.ui.notify(`Research ${selected.name} is no longer available.`, "warning");
6802
+ } else if (decision.action === "kill-proc") {
6803
+ const agent = agentStates.get(selected.key)!;
6804
+ agent.killedByOperator = true;
6805
+ cancelLocalOwnedProcess({ process: agent.proc, monitorBridge, monitorKey: monitorKeyForAgent(agent.def.name, agent.runCount), treeKill: killPiTree });
6806
+ ctx.ui.notify(decision.message, "info");
6807
+ } else if (decision.action === "coms-abort") {
6808
+ agentStates.get(selected.key)?.comsAbort?.();
6809
+ ctx.ui.notify(decision.message, "info");
6810
+ } else {
6811
+ ctx.ui.notify(decision.message, decision.level);
6812
+ }
6813
+ }
6814
+ } else if (intent && typeof intent === "object" && "restart" in intent) {
6815
+ const selected = rows.find(r => r.key === intent.restart);
6816
+ if (selected) await restartFleetRow(selected, ctx);
6817
+ }
6818
+ tui.requestRender();
6819
+ },
6820
+ invalidate() {},
6821
+ dispose: () => resources.dispose(),
6822
+ };
6823
+ }, FULLSCREEN_OVERLAY);
6824
+ } finally { resources.dispose(); }
6825
+ }
6826
+
6647
6827
  pi.registerCommand("af-agents-list", {
6648
- description: "List all loaded agents",
6828
+ description: "Open Fleet Dashboard",
6649
6829
  handler: async (_args, _ctx) => {
6650
6830
  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");
6831
+ await openFleetDashboard(_ctx);
6670
6832
  },
6671
6833
  });
6672
6834
 
@@ -6674,26 +6836,27 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6674
6836
  // a 1s tick so running durations advance live; `historyRender` lets a new
6675
6837
  // dispatch refresh the panel the instant it starts/ends.
6676
6838
  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;
6839
+ const resources = createPanelResources();
6840
+ try {
6841
+ await ctx.ui.custom((tui: any, theme: any, _kb: any, done: (r: unknown) => void) => {
6842
+ const ui = new HistoryUI(
6843
+ () => executionHistory,
6844
+ () => (activeTeamName ? `Team: ${activeTeamName}` : "Agent Hub"),
6845
+ () => done(undefined),
6846
+ );
6847
+ historyRender = () => tui.requestRender();
6848
+ resources.every(1000, () => tui.requestRender());
6849
+ return {
6850
+ render: (w: number) => ui.render(w, bodyRows(tui.terminal?.rows, HISTORY_CHROME_ROWS), theme),
6851
+ handleInput: (data: string) => ui.handleInput(data, tui),
6852
+ invalidate: () => {},
6853
+ dispose: () => resources.dispose(),
6854
+ };
6855
+ }, FULLSCREEN_OVERLAY);
6856
+ } finally {
6857
+ resources.dispose();
6858
+ historyRender = null;
6859
+ }
6697
6860
  }
6698
6861
 
6699
6862
  pi.registerCommand("af-agents-history", {
@@ -6704,6 +6867,36 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6704
6867
  },
6705
6868
  });
6706
6869
 
6870
+ // ── /af-posture: direct operator ↔ restricted orchestrator ──
6871
+ pi.registerCommand("af-posture", {
6872
+ description: "Show or set the Fleet posture: operator (direct tools) | orchestrator (delegate-only)",
6873
+ handler: async (args, ctx) => {
6874
+ widgetCtx = ctx;
6875
+ const requested = (args || "").trim();
6876
+ if (!requested) {
6877
+ ctx.ui.notify(`${postureStatusText()}\nSwitch with /af-posture operator|orchestrator`, "info");
6878
+ return;
6879
+ }
6880
+ const next = parsePosture(requested);
6881
+ if (!next) {
6882
+ ctx.ui.notify(`Unknown posture "${requested}" — expected operator|orchestrator.`, "error");
6883
+ return;
6884
+ }
6885
+ if (orchestratorNeedsRoster(next, agentStates.size)) {
6886
+ ctx.ui.notify("Orchestrator posture requires at least one native specialist. Add one with /af-agents-add or select /af-agents-team first.", "warning");
6887
+ return;
6888
+ }
6889
+ posture = next;
6890
+ if (posture === "orchestrator" && personaGateEnabled && !personaGateSatisfied) {
6891
+ await pickDispatcherPersona(ctx);
6892
+ }
6893
+ applyPostureTools();
6894
+ updatePostureStatus(ctx);
6895
+ pi.appendEntry("agent-hub-posture", { posture });
6896
+ ctx.ui.notify(`${postureStatusText()}\nPrompt and tools update on the next model call.`, "success");
6897
+ },
6898
+ });
6899
+
6707
6900
  // ── /af-hub-mode: execution mode (fast|standard|strict) ──
6708
6901
  // Session-lifetime switch over the overrides-file default. Budgets bind on
6709
6902
  // the NEXT tool call (counters are per user turn and keep running); the
@@ -6728,9 +6921,14 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6728
6921
  ctx.ui.notify(`Unknown mode "${requested}" — expected one of: ${HUB_MODES.join(", ")}`, "error");
6729
6922
  return;
6730
6923
  }
6924
+ const previousMode = hubMode;
6731
6925
  hubMode = mode;
6732
6926
  updateModeStatus();
6733
- ctx.ui.notify(`Execution mode → ${mode} (budgets apply from the next dispatch; prompt updates next turn)`, "success");
6927
+ appendHubModeEntry({ previousMode, mode, source: "slash-command", ctx });
6928
+ ctx.ui.notify(
6929
+ `Execution mode → ${mode} (budgets apply from the next dispatch; prompt updates next turn)` + hubLocationSuffix(ctx),
6930
+ "success",
6931
+ );
6734
6932
  },
6735
6933
  });
6736
6934
 
@@ -6744,17 +6942,15 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6744
6942
  handler: async (args, ctx) => {
6745
6943
  widgetCtx = ctx;
6746
6944
  const label = (args || "").trim() || null;
6747
- const spentDispatches = taskDispatchCount;
6748
- const spentResearch = taskResearchCount;
6749
- const spentReviews = taskReviewRounds;
6750
- const spentMin = Math.round(taskActiveElapsedMs() / 60_000);
6751
- const priorTier = taskTier;
6752
- resetTaskWindow(label);
6945
+ const resetAt = Date.now();
6946
+ const prior = taskResetSnapshot(resetAt);
6947
+ resetTaskWindow(label, resetAt);
6948
+ appendTaskResetEntry("slash-command", label, prior, ctx);
6753
6949
  ctx.ui.notify(
6754
6950
  `New task window${label ? `: ${label}` : ""}\n` +
6755
- `Previous task${priorTier ? ` (tier ${priorTier})` : ""} spent ${spentDispatches} dispatches, ` +
6756
- `${spentResearch} research, ${spentReviews} review round(s), ${spentMin} min active.\n` +
6757
- `Tier is unset — the dispatcher re-triages on its next dispatch.`,
6951
+ `Previous task${prior.tier ? ` (tier ${prior.tier})` : ""} spent ${prior.dispatches} dispatches, ` +
6952
+ `${prior.research} research, ${prior.reviewRounds} review round(s), ${Math.round(prior.activeMs / 60_000)} min active.\n` +
6953
+ `Tier is unset — the dispatcher re-triages on its next dispatch.` + hubLocationSuffix(ctx),
6758
6954
  "success",
6759
6955
  );
6760
6956
  },
@@ -6822,7 +7018,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6822
7018
  const results = names.map(n => rosterAdd(n));
6823
7019
  const level = results.some(r => r.ok) ? "success" : "error";
6824
7020
  ctx.ui.notify(results.map(r => r.message).join("\n"), level as any);
6825
- ctx.ui.setStatus("agent-team", `Team: ${activeTeamName}* (${agentStates.size})`);
7021
+ ctx.ui.setStatus("agent-team", `Native roster: ${activeTeamName || "(none)"}* (${agentStates.size})`);
6826
7022
  },
6827
7023
  });
6828
7024
 
@@ -6838,7 +7034,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6838
7034
  const results = names.map(n => rosterDrop(n));
6839
7035
  const level = results.some(r => r.ok) ? "success" : "error";
6840
7036
  ctx.ui.notify(results.map(r => r.message).join("\n"), level as any);
6841
- ctx.ui.setStatus("agent-team", `Team: ${activeTeamName}* (${agentStates.size})`);
7037
+ ctx.ui.setStatus("agent-team", `Native roster: ${activeTeamName || "(none)"}* (${agentStates.size})`);
6842
7038
  },
6843
7039
  });
6844
7040
 
@@ -6912,15 +7108,16 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6912
7108
  // session-rename), and alt+a is not consumed by the editor, so it reaches the
6913
7109
  // extension shortcut handler in the main input.
6914
7110
  pi.registerShortcut("alt+a", {
6915
- description: "Toggle agent view: dashboard ↔ compact",
7111
+ description: "Open Fleet Dashboard",
6916
7112
  handler: (ctx) => {
6917
7113
  widgetCtx = ctx;
6918
- viewMode = viewMode === "dashboard" ? "compact" : "dashboard";
6919
- updateWidget();
6920
- updateResearchWidget();
6921
- ctx.ui.notify(`Agent view: ${viewMode}`, "info");
7114
+ void openFleetDashboard(ctx);
6922
7115
  },
6923
7116
  });
7117
+ pi.registerShortcut("alt+shift+a", {
7118
+ description: "Toggle compact agent widget",
7119
+ handler: (ctx) => { widgetCtx = ctx; viewMode = viewMode === "compact" ? "off" : "compact"; updateWidget(); updateResearchWidget(); ctx.ui.notify(`Compact agent widget: ${viewMode}`, "info"); },
7120
+ });
6924
7121
 
6925
7122
  // Compact-view agent switcher. Alt+] / Alt+[ move the marker through the running
6926
7123
  // subagents; Alt+\ zooms the marked one (same overlay as /af-zoom). main is never a
@@ -6931,7 +7128,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6931
7128
  // eaten by the escape parser — alt+] and alt+\ are the reliable pair.
6932
7129
  function cycleMarker(delta: number, ctx: any) {
6933
7130
  widgetCtx = ctx;
6934
- if (viewMode !== "compact") {
7131
+ if (!compactWidgetsEnabled(viewMode)) {
6935
7132
  ctx.ui.notify("Agent switching is a compact-view feature — press Alt+A first", "info");
6936
7133
  return;
6937
7134
  }
@@ -6959,7 +7156,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6959
7156
  description: "Compact view: zoom the marked subagent",
6960
7157
  handler: async (ctx) => {
6961
7158
  widgetCtx = ctx;
6962
- if (viewMode !== "compact") {
7159
+ if (!compactWidgetsEnabled(viewMode)) {
6963
7160
  ctx.ui.notify("Agent zoom from the marker is a compact-view feature — press Alt+A first", "info");
6964
7161
  return;
6965
7162
  }
@@ -6976,7 +7173,9 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6976
7173
  ctx.ui.notify(`Marked agent ${markedAgent} is no longer available`, "warning");
6977
7174
  return;
6978
7175
  }
6979
- await openZoom(target, ctx);
7176
+ const row = fleetRows(true).find(r => r.key === markedAgent);
7177
+ if (row) await openFleetDetail(row, ctx);
7178
+ else await openZoom(target, ctx);
6980
7179
  },
6981
7180
  });
6982
7181
 
@@ -6995,7 +7194,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6995
7194
  function findDelegationChild(arg: string): { child: DelegationChild; owner: AgentState } | null {
6996
7195
  const lower = arg.toLowerCase();
6997
7196
  for (const st of agentStates.values()) {
6998
- const child = st.delegations?.get(lower);
7197
+ const child = Array.from(st.delegations?.values() ?? []).find(candidate => candidate.id.toLowerCase() === lower);
6999
7198
  if (child) return { child, owner: st };
7000
7199
  }
7001
7200
  return null;
@@ -7029,28 +7228,30 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
7029
7228
  // parser refresh it on new events (throttled to ~12fps; force=true pushes the
7030
7229
  // final frame on completion).
7031
7230
  async function openZoom(target: Zoomable, ctx: any): Promise<void> {
7231
+ const resources = createPanelResources();
7032
7232
  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;
7233
+ try {
7234
+ await ctx.ui.custom((tui: any, theme: any, _kb: any, done: (r: unknown) => void) => {
7235
+ const ui = new ZoomUI(target, () => done(undefined), (message, type) => ctx.ui.notify(message, type as any));
7236
+ target.zoomRender = (force?: boolean) => {
7237
+ const now = Date.now();
7238
+ if (force || now - lastRender > 80) {
7239
+ lastRender = now;
7240
+ tui.requestRender();
7241
+ }
7242
+ };
7243
+ resources.onDispose(() => { target.zoomRender = undefined; });
7244
+ return {
7245
+ render: (w: number) => ui.render(w, bodyRows(tui.terminal?.rows, ZOOM_CHROME_ROWS), theme),
7246
+ handleInput: (data: string) => ui.handleInput(data, tui),
7247
+ invalidate: () => {},
7248
+ dispose: () => resources.dispose(),
7249
+ };
7250
+ }, FULLSCREEN_OVERLAY);
7251
+ } finally {
7252
+ resources.dispose();
7253
+ target.zoomRender = undefined;
7254
+ }
7054
7255
  }
7055
7256
 
7056
7257
  pi.registerCommand("af-zoom", {
@@ -7077,7 +7278,10 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
7077
7278
  ctx.ui.notify(`Usage: /af-zoom <name|rN|child-id>. Known: ${known || "none"}`, "error");
7078
7279
  return;
7079
7280
  }
7080
- await openZoom(target, ctx);
7281
+ const rowKey = (rid != null ? `r${rid}` : arg).toLowerCase();
7282
+ const row = fleetRows(true).find(r => r.key.toLowerCase() === rowKey);
7283
+ if (row) await openFleetDetail(row, ctx);
7284
+ else await openZoom(target, ctx);
7081
7285
  },
7082
7286
  });
7083
7287
 
@@ -8029,9 +8233,10 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
8029
8233
  askUserStarts.delete(event.toolCallId);
8030
8234
  // The task clock bills active time only — the human's answer is not the
8031
8235
  // fleet's work, and billing it is what would false-stop a steered session.
8032
- if (startedAt) turnAskUserWaitMs += Math.max(0, Date.now() - startedAt);
8236
+ const endedAt = Date.now();
8237
+ if (startedAt) taskClock = addTaskClockWait(taskClock, Math.max(0, endedAt - startedAt));
8033
8238
  if (startedAt == null) return;
8034
- const interval: [number, number] = [startedAt, Date.now()];
8239
+ const interval: [number, number] = [startedAt, endedAt];
8035
8240
  // Attach to the live dispatcher entry, or buffer until one is created this turn.
8036
8241
  if (currentOrchestratorEntry) (currentOrchestratorEntry.awaitIntervals ??= []).push(interval);
8037
8242
  else turnAskUserIntervals.push(interval);
@@ -8041,6 +8246,9 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
8041
8246
  // ── System Prompt Override ───────────────────
8042
8247
 
8043
8248
  pi.on("before_agent_start", async (_event, _ctx) => {
8249
+ // Re-assert the selected posture for every turn so prompt and tool policy stay
8250
+ // synchronized after commands or runtime capability changes.
8251
+ applyPostureTools();
8044
8252
  // Open a fresh dispatcher turn for /af-agents-history. The orchestrator entry is
8045
8253
  // created lazily (only if this turn actually dispatches), so chat-only turns
8046
8254
  // add no history rows. Defensively close any entry a prior turn left open
@@ -8052,9 +8260,11 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
8052
8260
  // Fold the turn that just ended into the task's active-time accumulator
8053
8261
  // before the clock is re-based; inter-turn idle is never charged because
8054
8262
  // no turn is open across it.
8055
- closeTurnActiveTime();
8263
+ const turnStartedAt = Date.now();
8264
+ closeTurnActiveTime(turnStartedAt);
8265
+ taskClock = openTaskClock(taskClock, turnStartedAt);
8056
8266
  turnActive = true;
8057
- currentTurnStartedAt = Date.now();
8267
+ currentTurnStartedAt = turnStartedAt;
8058
8268
  currentOrchestratorEntry = null;
8059
8269
  askUserStarts.clear();
8060
8270
  turnAskUserIntervals.length = 0;
@@ -8322,14 +8532,14 @@ your own team you can talk to the peers in your coms POOL — the agents shown i
8322
8532
  `
8323
8533
  : "";
8324
8534
 
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}.
8535
+ const postureText = posturePrompt(posture);
8536
+ const orchestratorPrompt = `${postureText.intro} You have ${toolList}.
8327
8537
 
8328
8538
  ## Language
8329
8539
  ${languageLines}
8330
8540
 
8331
- ## Active Team: ${activeTeamName}
8332
- Members: ${teamMembers}
8541
+ ## Native Roster: ${activeTeamName || "(none)"}
8542
+ Members: ${teamMembers || "(none — add a persona before using dispatch_agent)"}
8333
8543
  You can ONLY dispatch to agents listed below. Do not attempt to dispatch to agents
8334
8544
  outside this team. The roster CAN change mid-session: the human via /af-agents-add,
8335
8545
  /af-agents-drop, /af-agents-team — or you via \`team_adjust\` (add/drop with a reason)
@@ -8340,6 +8550,7 @@ personas is usually the wrong answer.
8340
8550
  - Analyze the user's request and break it into clear sub-tasks.
8341
8551
  - Choose the right agent(s) for each sub-task.
8342
8552
  ${dispatchSection}
8553
+ - 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
8554
  - Review results and dispatch follow-up agents if needed.
8344
8555
  - If a task fails, try a different agent or adjust the task description.
8345
8556
  - Summarize the outcome for the user in ${userLanguage}.
@@ -8365,10 +8576,12 @@ ${verificationSection}
8365
8576
  ${comsSection}${herdrFleetReady ? `
8366
8577
  ## Fleet (herdr)
8367
8578
  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.
8579
+ - \`herdr_spawn_peer\` starts an addressable Pi persona, personaless Fleet Core, or Claude Code
8580
+ peer next to you. Name-only calls inherit peers.yaml; explicit fields use the same resolver as
8581
+ \`just fleet peer\`. Every peer is locked to this Hub's coms project.
8582
+ - \`herdr_spawn_pane\` starts a raw command pane (for example a build watcher or server). It is
8583
+ not a coms peer and has no readiness result. Spawn deliberately; every pane is human-visible.
8584
+ - A spawned peer BOOTS IDLE and waits for \`coms_send\`: the spawn hands it no task.
8372
8585
  The call waits for it to register and returns \`peer_ready\` with its coms name. Spawn one
8373
8586
  only immediately before the first message you will send it — a peer spawned "to have it
8374
8587
  ready" and never addressed is an empty pane named like a worker. If you sent it no work
@@ -8388,8 +8601,7 @@ This session runs inside a herdr workspace and can drive panes:
8388
8601
  a long fleet task finishes or needs attention; it does not replace \`ask_user\`.
8389
8602
  ` : ""}
8390
8603
  ## 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.
8604
+ ${postureText.hardRules}
8393
8605
  ${ambiguityRule}
8394
8606
  - You can chain agents: spawn_research to gather context, builder to implement.
8395
8607
  - You can dispatch the same agent multiple times with different tasks.
@@ -8415,7 +8627,7 @@ ${researchCatalog}`;
8415
8627
 
8416
8628
  // ── Persona gate: block input until a dispatcher persona is picked ──
8417
8629
  pi.on("input", async (_event, ctx) => {
8418
- if (personaGateEnabled && !personaGateSatisfied) {
8630
+ if (posture === "orchestrator" && personaGateEnabled && !personaGateSatisfied) {
8419
8631
  ctx.ui.notify("Pick a dispatcher persona first (see the select dialog).", "warning");
8420
8632
  return { action: "handled" as const };
8421
8633
  }
@@ -8426,6 +8638,9 @@ ${researchCatalog}`;
8426
8638
 
8427
8639
  pi.on("session_start", async (_event, _ctx) => {
8428
8640
  registerVersionStatus(_ctx);
8641
+ // Capture the configured surface before Agent Hub applies either posture.
8642
+ // Operator mode restores this baseline (minus gated Hub-owned tools).
8643
+ baselineTools = pi.getActiveTools();
8429
8644
  accessApprovalRouter.reset();
8430
8645
  // Clear widgets + any research helpers from a previous session
8431
8646
  for (const [, st] of Array.from(researchStates.entries())) {
@@ -8437,6 +8652,8 @@ ${researchCatalog}`;
8437
8652
  executionHistory.length = 0;
8438
8653
  currentOrchestratorEntry = null;
8439
8654
  turnActive = false;
8655
+ currentTurnStartedAt = 0;
8656
+ taskClock = createTaskClock();
8440
8657
  askUserStarts.clear();
8441
8658
  turnAskUserIntervals.length = 0;
8442
8659
  if (widgetCtx) {
@@ -8729,6 +8946,7 @@ ${researchCatalog}`;
8729
8946
  userLanguage = overrides.language;
8730
8947
  researchKeep = overrides.researchKeep;
8731
8948
  reconSearchTimeoutMs = overrides.reconSearchTimeoutMs;
8949
+ const previousMode = hubMode;
8732
8950
  hubMode = overrides.hubMode;
8733
8951
  budgetOverrides = overrides.budgetOverrides;
8734
8952
  watchdogSetting = overrides.watchdogSetting;
@@ -8738,6 +8956,13 @@ ${researchCatalog}`;
8738
8956
  // A new session is a new task by definition.
8739
8957
  resetTaskWindow(null);
8740
8958
  updateModeStatus();
8959
+ appendHubModeEntry({
8960
+ previousMode,
8961
+ mode: hubMode,
8962
+ source: overrides.hubModeSource,
8963
+ overrideFile: overrides.hubModeSource === "project-override" ? ".ai/agent-fleet-overrides.md" : null,
8964
+ ctx: _ctx,
8965
+ });
8741
8966
  if (overrides.warnings.length > 0) {
8742
8967
  _ctx.ui.notify(`agent-fleet-overrides warnings:\n${overrides.warnings.join("\n")}`, "warning");
8743
8968
  }
@@ -8829,34 +9054,35 @@ ${researchCatalog}`;
8829
9054
  personaGateEnabled = overrides.personaGate && orchestratorPersonas.length > 0;
8830
9055
  personaGateSatisfied = !personaGateEnabled;
8831
9056
 
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]);
9057
+ // A roster is opt-in. Resolve it before posture so --agent-team can imply
9058
+ // orchestrator while an explicit --posture operator still wins.
9059
+ agentStates.clear();
9060
+ activeTeamName = "";
9061
+ comsMissNotified.clear();
9062
+ recomputeGrid();
9063
+ const startupRoster = resolveStartupRoster(teams, pi.getFlag("agent-team"));
9064
+ posture = resolveSessionPosture({
9065
+ entries: _ctx.sessionManager.getEntries(),
9066
+ explicitPosture: pi.getFlag("posture"),
9067
+ hasExplicitRoster: startupRoster !== null,
9068
+ });
9069
+ if (orchestratorNeedsRoster(posture, startupRoster?.members.length ?? 0)) {
9070
+ throw new Error("Orchestrator posture requires --agent-team <name> with at least one native specialist.");
8836
9071
  }
9072
+ if (startupRoster) activateTeam(startupRoster.name);
8837
9073
 
8838
9074
  // Probe for `ask_user` (registered by the `pi-ask-user` companion package
8839
9075
  // when installed). Action methods like getAllTools are runtime-only, so
8840
9076
  // this MUST happen at session_start, not at extension load.
8841
9077
  askUserAvailable = pi.getAllTools().some(t => t.name === "ask_user");
8842
9078
 
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).
9079
+ // Fleet tools are available only inside a herdr pane with a live server.
9080
+ // The posture policy adds gated groups without activating unavailable tools.
8855
9081
  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);
9082
+ applyPostureTools();
9083
+ updatePostureStatus(_ctx);
8858
9084
 
8859
- _ctx.ui.setStatus("agent-team", `Team: ${activeTeamName} (${agentStates.size})`);
9085
+ _ctx.ui.setStatus("agent-team", `Native roster: ${activeTeamName || "(none)"} (${agentStates.size})`);
8860
9086
  const members = Array.from(agentStates.values()).map(s => displayName(s.def.name)).join(", ");
8861
9087
  const askUserLabel = askUserAvailable
8862
9088
  ? "available (via pi-ask-user)"
@@ -8883,16 +9109,18 @@ ${researchCatalog}`;
8883
9109
  ? `coms-preferred: ${comsPreferred.join(", ")} (live peer wins, /af-dispatch-policy for status)`
8884
9110
  : "all native (no substitutions in .pi/agents/dispatch-policy.yaml)";
8885
9111
  _ctx.ui.notify(
8886
- `Team: ${activeTeamName} (${members})\n` +
8887
- `Team sets loaded from: .pi/agents/teams.yaml\n` +
9112
+ `Posture: ${posture} (${posture === "operator" ? "direct tools enabled" : "delegate-only"})\n` +
9113
+ `Native roster: ${activeTeamName || "(none)"} (${agentStates.size}${members ? `: ${members}` : ""})\n` +
9114
+ `Native roster sets loaded from: .pi/agents/teams.yaml\n` +
8888
9115
  `Dispatch backends: ${dispatchLabel}\n` +
8889
9116
  `User-facing language: ${userLanguage} (override in .ai/agent-fleet-overrides.md)\n` +
8890
9117
  `ask_user: ${askUserLabel}; specialists bubble up via ASK_USER:\n` +
8891
9118
  `Persona gate: ${personaGateLabel}\n` +
8892
9119
  `Coms: ${comsLabel}\n` +
8893
9120
  `Fleet: ${fleetLabel}\n\n` +
9121
+ `/af-posture [mode] Show/switch operator|orchestrator posture\n` +
8894
9122
  `/af-agents-team Select a team\n` +
8895
- `/af-agents-list List active agents and status\n` +
9123
+ `/af-agents-list Open Fleet Dashboard\n` +
8896
9124
  `/af-agents-history Timeline of agent runs — durations, parallel markers, grand total\n` +
8897
9125
  `/af-agent-model <persona>[.<role>] Switch a persona's or sub-role's model\n` +
8898
9126
  `/af-agent-model-thinking <persona> Switch a persona's thinking level\n` +
@@ -8915,8 +9143,9 @@ ${researchCatalog}`;
8915
9143
  _ctx.ui.setStatus("dispatcher-persona", personaGateEnabled ? "Persona: (pick one)" : "Persona: Default");
8916
9144
  updateWidget();
8917
9145
 
8918
- // Fire the blocking persona gate (input stays swallowed until satisfied).
8919
- if (personaGateEnabled) {
9146
+ // The persona gate restricts only orchestrator posture. Operators can work
9147
+ // directly and choose a dispatcher persona later without being blocked.
9148
+ if (posture === "orchestrator" && personaGateEnabled) {
8920
9149
  void pickDispatcherPersona(_ctx);
8921
9150
  }
8922
9151
 
@@ -8937,7 +9166,7 @@ ${researchCatalog}`;
8937
9166
  const bar = "#".repeat(filled) + "-".repeat(10 - filled);
8938
9167
 
8939
9168
  const left = renderHubFooterLeft(theme, HARNESS_VERSION, model, think, activeTeamName);
8940
- const hint = theme.fg("muted", "Alt+A ") + theme.fg("dim", `view:${viewMode}`);
9169
+ const hint = theme.fg("dim", composeFleetFooterHint(viewMode));
8941
9170
  // The btw extension flips this global the first time a /af-btw command or
8942
9171
  // Alt+' is used; surface its reopen shortcut right next to the Alt+A hint.
8943
9172
  const btwHint = (globalThis as { __btwActivated?: boolean }).__btwActivated
@@ -8970,15 +9199,18 @@ ${researchCatalog}`;
8970
9199
  // When this agent was addressed by a peer (an inbound prompt in the queue), the
8971
9200
  // turn's final assistant text becomes the response we ship back to the sender.
8972
9201
  pi.on("agent_end", async (_event, ctx) => {
8973
- // Close the /af-agents-history dispatcher turn (if this turn opened one). The
8974
- // orchestrator entry's span covers all of its dispatches plus the wrap-up.
9202
+ // Close both the task clock and /af-agents-history dispatcher turn at the
9203
+ // actual end event, so time awaiting the next user message is never charged.
9204
+ const turnEndedAt = Date.now();
9205
+ closeTurnActiveTime(turnEndedAt);
8975
9206
  turnActive = false;
8976
9207
  if (currentOrchestratorEntry) {
8977
- currentOrchestratorEntry.endedAt = Date.now();
9208
+ currentOrchestratorEntry.endedAt = turnEndedAt;
8978
9209
  if (currentOrchestratorEntry.status === "running") currentOrchestratorEntry.status = "done";
8979
9210
  currentOrchestratorEntry = null;
8980
9211
  historyRender?.();
8981
9212
  }
9213
+ currentTurnStartedAt = 0;
8982
9214
 
8983
9215
  // End-of-turn sweep: a peer spawned this turn and never sent to is still
8984
9216
  // running. Named once per turn it stays unaddressed; the close itself is