@chankov/agent-fleet 0.0.11 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (494) hide show
  1. package/.pi/extensions/agent-fleet-update-check/README.md +4 -4
  2. package/.pi/extensions/btw/README.md +26 -25
  3. package/.pi/extensions/btw/index.ts +80 -83
  4. package/.pi/extensions/pi-voice-stt/README.md +4 -3
  5. package/.pi/extensions/pi-voice-stt/config.ts +1 -1
  6. package/.pi/harnesses/agent-hub/README.md +106 -54
  7. package/.pi/harnesses/agent-hub/backend-policy.js +25 -4
  8. package/.pi/harnesses/agent-hub/footer.ts +4 -0
  9. package/.pi/harnesses/agent-hub/helpers.ts +18 -0
  10. package/.pi/harnesses/agent-hub/index.ts +537 -369
  11. package/.pi/harnesses/agent-hub/monitor-session-bridge.ts +10 -1
  12. package/.pi/harnesses/agent-hub/package.json +1 -1
  13. package/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
  14. package/.pi/harnesses/agent-hub/posture.ts +103 -0
  15. package/.pi/harnesses/ask-user-remote/README.md +37 -3
  16. package/.pi/harnesses/ask-user-remote/index.ts +173 -17
  17. package/.pi/harnesses/coms/package.json +1 -1
  18. package/.pi/harnesses/damage-control-continue/package.json +1 -1
  19. package/.pi/harnesses/lib/fleet-dashboard-ops.ts +118 -0
  20. package/.pi/harnesses/lib/fleet-dashboard-view.ts +140 -0
  21. package/.pi/harnesses/lib/fleet-detail-view.ts +43 -0
  22. package/.pi/harnesses/lib/fleet-overlay.ts +26 -0
  23. package/.pi/harnesses/lib/fleet-panel.ts +34 -0
  24. package/.pi/harnesses/lib/fleet-read-model.ts +131 -0
  25. package/.pi/harnesses/lib/fleet-selection.ts +24 -0
  26. package/.pi/harnesses/package-lock.json +2011 -0
  27. package/.pi/harnesses/package.json +1 -0
  28. package/.versions/0.0.11/.pi/extensions/agent-fleet-update-check/README.md +4 -4
  29. package/.versions/0.0.11/.pi/extensions/pi-voice-stt/README.md +4 -3
  30. package/.versions/0.0.11/.pi/extensions/pi-voice-stt/config.ts +1 -1
  31. package/.versions/0.0.11/.pi/harnesses/agent-hub/monitor-session-bridge.ts +10 -1
  32. package/.versions/0.0.11/.pi/harnesses/ask-user-remote/README.md +37 -3
  33. package/.versions/0.0.11/.pi/harnesses/ask-user-remote/index.ts +173 -17
  34. package/.versions/0.0.11/.pi/harnesses/package-lock.json +2011 -0
  35. package/.versions/0.0.11/.pi/harnesses/package.json +1 -0
  36. package/.versions/0.0.11/docs/ARCHITECTURE.md +6 -8
  37. package/.versions/0.0.11/docs/agent-fleet-setup.md +17 -43
  38. package/.versions/0.0.11/docs/claude-code-coms-bridge.md +20 -2
  39. package/.versions/0.0.11/docs/coms-hermes-bridge.md +1 -1
  40. package/.versions/0.0.11/docs/getting-started.md +26 -237
  41. package/.versions/0.0.11/docs/npm-install.md +60 -478
  42. package/.versions/0.0.11/docs/pi-extensions.md +4 -4
  43. package/.versions/0.0.11/docs/pi-setup.md +37 -551
  44. package/.versions/0.0.11/hermes/README.md +1 -1
  45. package/.versions/0.0.11/install-manifest.json +375 -1247
  46. package/.versions/0.0.11/justfile +13 -6
  47. package/.versions/0.0.11/manifest-meta.json +543 -134
  48. package/.versions/0.0.11/scripts/lib/fleet-command.ts +8 -0
  49. package/.versions/0.0.11/scripts/lib/monitor-env.ts +18 -6
  50. package/.versions/0.0.11/skills/designing-agents/SKILL.md +1 -1
  51. package/.versions/0.0.11/skills/designing-agents/pi-harness-authoring.md +1 -1
  52. package/.versions/1.0.0/.pi/agents/dispatch-policy.yaml +32 -0
  53. package/.versions/1.0.0/.pi/agents/model-profiles.yaml +27 -0
  54. package/.versions/1.0.0/.pi/agents/peers.yaml +142 -0
  55. package/.versions/1.0.0/.pi/agents/teams.yaml +41 -0
  56. package/.versions/1.0.0/.pi/damage-control-rules.yaml +297 -0
  57. package/.versions/1.0.0/.pi/extensions/agent-fleet-update-check/README.md +57 -0
  58. package/.versions/1.0.0/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
  59. package/.versions/1.0.0/.pi/extensions/agent-fleet-update-check/package.json +6 -0
  60. package/.versions/1.0.0/.pi/extensions/btw/README.md +120 -0
  61. package/.versions/1.0.0/.pi/extensions/btw/index.ts +914 -0
  62. package/.versions/1.0.0/.pi/extensions/btw/package.json +6 -0
  63. package/.versions/1.0.0/.pi/extensions/btw/state.js +179 -0
  64. package/.versions/1.0.0/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
  65. package/.versions/1.0.0/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
  66. package/.versions/1.0.0/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  67. package/.versions/1.0.0/.pi/extensions/compact-and-continue/README.md +42 -0
  68. package/.versions/1.0.0/.pi/extensions/compact-and-continue/index.ts +120 -0
  69. package/.versions/1.0.0/.pi/extensions/compact-and-continue/package.json +6 -0
  70. package/.versions/1.0.0/.pi/extensions/mcp-bridge/README.md +46 -0
  71. package/.versions/1.0.0/.pi/extensions/mcp-bridge/index.ts +206 -0
  72. package/.versions/1.0.0/.pi/extensions/mcp-bridge/package.json +6 -0
  73. package/.versions/1.0.0/.pi/extensions/package-lock.json +1143 -0
  74. package/.versions/1.0.0/.pi/extensions/package.json +9 -0
  75. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/README.md +205 -0
  76. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/config.ts +198 -0
  77. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  78. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/index.ts +248 -0
  79. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/package.json +6 -0
  80. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  81. package/.versions/1.0.0/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  82. package/.versions/1.0.0/.pi/harnesses/agent-hub/README.md +1056 -0
  83. package/.versions/1.0.0/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  84. package/.versions/1.0.0/.pi/harnesses/agent-hub/artifacts.js +146 -0
  85. package/.versions/1.0.0/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
  86. package/.versions/1.0.0/.pi/harnesses/agent-hub/backend-policy.js +174 -0
  87. package/.versions/1.0.0/.pi/harnesses/agent-hub/context-window.js +106 -0
  88. package/.versions/1.0.0/.pi/harnesses/agent-hub/delegate.ts +435 -0
  89. package/.versions/1.0.0/.pi/harnesses/agent-hub/docs-lane.js +122 -0
  90. package/.versions/1.0.0/.pi/harnesses/agent-hub/drift-watchdog.js +211 -0
  91. package/.versions/1.0.0/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  92. package/.versions/1.0.0/.pi/harnesses/agent-hub/external-blocker.js +85 -0
  93. package/.versions/1.0.0/.pi/harnesses/agent-hub/footer.ts +35 -0
  94. package/.versions/1.0.0/.pi/harnesses/agent-hub/helpers.ts +266 -0
  95. package/.versions/1.0.0/.pi/harnesses/agent-hub/index.ts +9279 -0
  96. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  97. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
  98. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
  99. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  100. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  101. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  102. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  103. package/.versions/1.0.0/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
  104. package/.versions/1.0.0/.pi/harnesses/agent-hub/package.json +7 -0
  105. package/.versions/1.0.0/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
  106. package/.versions/1.0.0/.pi/harnesses/agent-hub/posture.ts +103 -0
  107. package/.versions/1.0.0/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
  108. package/.versions/1.0.0/.pi/harnesses/agent-hub/research-retention.js +34 -0
  109. package/.versions/1.0.0/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  110. package/.versions/1.0.0/.pi/harnesses/agent-hub/return-contract.js +293 -0
  111. package/.versions/1.0.0/.pi/harnesses/agent-hub/return-extract.js +75 -0
  112. package/.versions/1.0.0/.pi/harnesses/agent-hub/review-findings.js +102 -0
  113. package/.versions/1.0.0/.pi/harnesses/agent-hub/run-budget.js +479 -0
  114. package/.versions/1.0.0/.pi/harnesses/agent-hub/run-namespace.js +87 -0
  115. package/.versions/1.0.0/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  116. package/.versions/1.0.0/.pi/harnesses/agent-hub/scope-gate.js +103 -0
  117. package/.versions/1.0.0/.pi/harnesses/agent-hub/session-health.js +110 -0
  118. package/.versions/1.0.0/.pi/harnesses/agent-hub/spawn.ts +354 -0
  119. package/.versions/1.0.0/.pi/harnesses/agent-hub/version.ts +42 -0
  120. package/.versions/1.0.0/.pi/harnesses/ask-user-remote/README.md +53 -0
  121. package/.versions/1.0.0/.pi/harnesses/ask-user-remote/index.ts +477 -0
  122. package/.versions/1.0.0/.pi/harnesses/ask-user-remote/race-core.js +106 -0
  123. package/.versions/1.0.0/.pi/harnesses/coms/README.md +100 -0
  124. package/.versions/1.0.0/.pi/harnesses/coms/index.ts +1767 -0
  125. package/.versions/1.0.0/.pi/harnesses/coms/package.json +7 -0
  126. package/.versions/1.0.0/.pi/harnesses/coms/version.ts +42 -0
  127. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/README.md +124 -0
  128. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/index.ts +536 -0
  129. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/package.json +7 -0
  130. package/.versions/1.0.0/.pi/harnesses/damage-control-continue/version.ts +42 -0
  131. package/.versions/1.0.0/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
  132. package/.versions/1.0.0/.pi/harnesses/lib/damage-control-shared.ts +197 -0
  133. package/.versions/1.0.0/.pi/harnesses/lib/fleet-dashboard-ops.ts +118 -0
  134. package/.versions/1.0.0/.pi/harnesses/lib/fleet-dashboard-view.ts +140 -0
  135. package/.versions/1.0.0/.pi/harnesses/lib/fleet-detail-view.ts +43 -0
  136. package/.versions/1.0.0/.pi/harnesses/lib/fleet-overlay.ts +26 -0
  137. package/.versions/1.0.0/.pi/harnesses/lib/fleet-panel.ts +34 -0
  138. package/.versions/1.0.0/.pi/harnesses/lib/fleet-read-model.ts +131 -0
  139. package/.versions/1.0.0/.pi/harnesses/lib/fleet-selection.ts +24 -0
  140. package/.versions/1.0.0/.pi/harnesses/lib/herdr-client.ts +472 -0
  141. package/.versions/1.0.0/.pi/harnesses/lib/herdr-presence.ts +399 -0
  142. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
  143. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
  144. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
  145. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
  146. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
  147. package/.versions/1.0.0/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
  148. package/.versions/1.0.0/.pi/harnesses/lib/spawned-peers.js +190 -0
  149. package/.versions/1.0.0/.pi/harnesses/package-lock.json +2046 -0
  150. package/.versions/1.0.0/.pi/harnesses/package.json +10 -0
  151. package/.versions/1.0.0/.pi/prompts/af-build.md +24 -0
  152. package/{.claude/commands/code-simplify.md → .versions/1.0.0/.pi/prompts/af-code-simplify.md} +3 -3
  153. package/{.claude/commands/plan.md → .versions/1.0.0/.pi/prompts/af-plan.md} +1 -1
  154. package/.versions/{0.0.11/.claude/commands/review.md → 1.0.0/.pi/prompts/af-review.md} +3 -3
  155. package/.versions/1.0.0/.pi/prompts/af-set-hermes-watchdog.md +6 -0
  156. package/.versions/1.0.0/.pi/prompts/af-ship.md +17 -0
  157. package/.versions/{0.0.11/.claude/commands/spec.md → 1.0.0/.pi/prompts/af-spec.md} +1 -1
  158. package/.versions/{0.0.11/.claude/commands/test.md → 1.0.0/.pi/prompts/af-test.md} +2 -2
  159. package/.versions/1.0.0/.pi/skills/bowser/SKILL.md +145 -0
  160. package/.versions/1.0.0/.version +1 -0
  161. package/.versions/1.0.0/agents/architect.md +24 -0
  162. package/.versions/1.0.0/agents/bowser.md +27 -0
  163. package/.versions/1.0.0/agents/builder.md +54 -0
  164. package/.versions/1.0.0/agents/code-reviewer.md +208 -0
  165. package/.versions/1.0.0/agents/deep-researcher.md +32 -0
  166. package/.versions/1.0.0/agents/documenter.md +18 -0
  167. package/.versions/1.0.0/agents/orchestrator.md +72 -0
  168. package/.versions/1.0.0/agents/plan-reviewer.md +83 -0
  169. package/.versions/1.0.0/agents/planner.md +70 -0
  170. package/.versions/1.0.0/agents/releaser.md +24 -0
  171. package/.versions/1.0.0/agents/researcher.md +28 -0
  172. package/.versions/1.0.0/agents/security-auditor.md +167 -0
  173. package/.versions/1.0.0/agents/test-engineer.md +153 -0
  174. package/.versions/1.0.0/agents/web-debugger.md +43 -0
  175. package/.versions/1.0.0/agents/web-performance-auditor.md +193 -0
  176. package/.versions/1.0.0/codex/CONDUCTOR.md +148 -0
  177. package/.versions/1.0.0/docs/ARCHITECTURE.md +337 -0
  178. package/.versions/1.0.0/docs/agent-fleet-setup.md +437 -0
  179. package/.versions/1.0.0/docs/claude-code-coms-bridge.md +128 -0
  180. package/.versions/1.0.0/docs/codex-remote-conductor.md +170 -0
  181. package/.versions/1.0.0/docs/coms-hermes-bridge.md +189 -0
  182. package/.versions/1.0.0/docs/getting-started.md +98 -0
  183. package/.versions/1.0.0/docs/npm-install.md +292 -0
  184. package/.versions/1.0.0/docs/pi-extensions.md +412 -0
  185. package/.versions/1.0.0/docs/pi-setup.md +74 -0
  186. package/.versions/1.0.0/docs/skill-anatomy.md +150 -0
  187. package/.versions/1.0.0/hermes/README.md +347 -0
  188. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
  189. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
  190. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  191. package/.versions/1.0.0/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  192. package/.versions/1.0.0/hermes/gates/gate-o-capability.md +8 -0
  193. package/.versions/1.0.0/hermes/gates/gate-o-validator-fixtures.json +1 -0
  194. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
  195. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
  196. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
  197. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
  198. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
  199. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
  200. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
  201. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
  202. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
  203. package/.versions/1.0.0/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
  204. package/.versions/1.0.0/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
  205. package/.versions/1.0.0/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  206. package/.versions/1.0.0/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  207. package/.versions/1.0.0/hermes/skills/hub-conductor/SKILL.md +84 -0
  208. package/.versions/1.0.0/hermes/skills/hub-liaison/SKILL.md +84 -0
  209. package/.versions/1.0.0/hermes/skills/hub-watchdog/SKILL.md +76 -0
  210. package/.versions/1.0.0/hermes/skills/hub-watchdog/manifest.json +1 -0
  211. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
  212. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
  213. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
  214. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
  215. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
  216. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
  217. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
  218. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
  219. package/.versions/1.0.0/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
  220. package/.versions/1.0.0/hermes/watchdog-tests/__init__.py +0 -0
  221. package/.versions/1.0.0/hooks/coms-stop-hook.mjs +84 -0
  222. package/.versions/1.0.0/install-manifest.json +2745 -0
  223. package/.versions/1.0.0/justfile +272 -0
  224. package/.versions/1.0.0/manifest-meta.json +882 -0
  225. package/.versions/1.0.0/references/accessibility-checklist.md +160 -0
  226. package/.versions/1.0.0/references/definition-of-done.md +67 -0
  227. package/.versions/1.0.0/references/fleet-coordination-patterns.md +151 -0
  228. package/.versions/1.0.0/references/observability-checklist.md +91 -0
  229. package/.versions/1.0.0/references/orchestration-patterns.md +370 -0
  230. package/.versions/1.0.0/references/performance-checklist.md +153 -0
  231. package/.versions/1.0.0/references/prompting-patterns.md +380 -0
  232. package/.versions/1.0.0/references/security-checklist.md +179 -0
  233. package/.versions/1.0.0/references/testing-patterns.md +236 -0
  234. package/.versions/1.0.0/scripts/codex-conductor.ts +41 -0
  235. package/.versions/1.0.0/scripts/codex-remote-control.ts +167 -0
  236. package/.versions/1.0.0/scripts/coms-claude-bridge.ts +411 -0
  237. package/.versions/1.0.0/scripts/coms-cli.ts +484 -0
  238. package/.versions/1.0.0/scripts/coms-hermes-bridge.ts +413 -0
  239. package/.versions/1.0.0/scripts/fleet.ts +185 -0
  240. package/.versions/1.0.0/scripts/hermes-monitor-capability-runner.ts +25 -0
  241. package/.versions/1.0.0/scripts/hermes-monitor-scenario.ts +474 -0
  242. package/.versions/1.0.0/scripts/hermes-watchdog-capability-probe.ts +45 -0
  243. package/.versions/1.0.0/scripts/install-hermes-plugin.sh +180 -0
  244. package/.versions/1.0.0/scripts/lib/claude-bridge-core.ts +210 -0
  245. package/.versions/1.0.0/scripts/lib/codex-conductor.ts +88 -0
  246. package/.versions/1.0.0/scripts/lib/codex-remote-control.ts +480 -0
  247. package/.versions/1.0.0/scripts/lib/coms-envelope.ts +582 -0
  248. package/.versions/1.0.0/scripts/lib/fake-herdr-server.ts +88 -0
  249. package/.versions/1.0.0/scripts/lib/fleet-command.ts +266 -0
  250. package/.versions/1.0.0/scripts/lib/herdr-layout.ts +281 -0
  251. package/.versions/1.0.0/scripts/lib/hermes-bridge-core.ts +241 -0
  252. package/.versions/1.0.0/scripts/lib/hermes-monitor-events.ts +1 -0
  253. package/.versions/1.0.0/scripts/lib/hermes-monitor-herdr.ts +2 -0
  254. package/.versions/1.0.0/scripts/lib/hermes-monitor-model.ts +3 -0
  255. package/.versions/1.0.0/scripts/lib/hermes-monitor-registry.ts +2 -0
  256. package/.versions/1.0.0/scripts/lib/hermes-monitor-socket.ts +2 -0
  257. package/.versions/1.0.0/scripts/lib/hermes-monitor-store.ts +2 -0
  258. package/.versions/1.0.0/scripts/lib/monitor-env.ts +146 -0
  259. package/.versions/1.0.0/scripts/lib/peer-launch.ts +318 -0
  260. package/.versions/1.0.0/scripts/lib/persona-banner.ts +62 -0
  261. package/.versions/1.0.0/scripts/lib/spawn-stagger.ts +101 -0
  262. package/.versions/1.0.0/scripts/lib/team-project.ts +213 -0
  263. package/.versions/1.0.0/scripts/lib/team-snapshot.ts +147 -0
  264. package/.versions/1.0.0/scripts/peer-banner.ts +40 -0
  265. package/.versions/1.0.0/scripts/peer-launch.ts +259 -0
  266. package/.versions/1.0.0/scripts/team-snapshot.ts +237 -0
  267. package/.versions/1.0.0/scripts/team-up.ts +406 -0
  268. package/.versions/1.0.0/skills/_internal/grilling.md +11 -0
  269. package/.versions/1.0.0/skills/browser-testing-with-devtools/SKILL.md +351 -0
  270. package/.versions/1.0.0/skills/code-review-and-quality/SKILL.md +381 -0
  271. package/.versions/1.0.0/skills/compound-learning/SKILL.md +137 -0
  272. package/.versions/1.0.0/skills/context-engineering/SKILL.md +291 -0
  273. package/.versions/1.0.0/skills/deprecation-and-migration/SKILL.md +206 -0
  274. package/.versions/1.0.0/skills/designing-agents/SKILL.md +394 -0
  275. package/.versions/1.0.0/skills/designing-agents/pi-harness-authoring.md +222 -0
  276. package/.versions/1.0.0/skills/frontend-ui-engineering/SKILL.md +328 -0
  277. package/.versions/1.0.0/skills/git-workflow-and-versioning/SKILL.md +316 -0
  278. package/.versions/1.0.0/skills/idea-refine/SKILL.md +182 -0
  279. package/.versions/1.0.0/skills/idea-refine/examples.md +238 -0
  280. package/.versions/1.0.0/skills/idea-refine/frameworks.md +99 -0
  281. package/.versions/1.0.0/skills/idea-refine/refinement-criteria.md +113 -0
  282. package/.versions/1.0.0/skills/idea-refine/scripts/idea-refine.sh +15 -0
  283. package/.versions/1.0.0/skills/incremental-implementation/SKILL.md +287 -0
  284. package/.versions/1.0.0/skills/interview-me/SKILL.md +226 -0
  285. package/.versions/1.0.0/skills/orchestration-verification/SKILL.md +181 -0
  286. package/.versions/1.0.0/skills/peer-coms/SKILL.md +90 -0
  287. package/.versions/1.0.0/skills/performance-optimization/SKILL.md +350 -0
  288. package/.versions/1.0.0/skills/planning-and-task-breakdown/SKILL.md +254 -0
  289. package/.versions/1.0.0/skills/security-and-hardening/SKILL.md +461 -0
  290. package/.versions/1.0.0/skills/spec-driven-development/SKILL.md +257 -0
  291. package/.versions/1.0.0/skills/using-agent-skills/SKILL.md +199 -0
  292. package/.versions/1.0.0/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
  293. package/.versions/1.0.0/vendor/agent-skills-upstream/LICENSE +21 -0
  294. package/.versions/1.0.0/vendor/agent-skills-upstream/README.md +11 -0
  295. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
  296. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  297. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  298. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  299. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  300. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
  301. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  302. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  303. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
  304. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  305. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  306. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  307. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  308. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  309. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  310. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  311. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  312. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  313. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  314. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
  315. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
  316. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
  317. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
  318. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
  319. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
  320. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
  321. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
  322. package/.versions/1.0.0/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
  323. package/CHANGELOG.md +142 -0
  324. package/README.md +117 -79
  325. package/agents/orchestrator.md +1 -1
  326. package/bin/cli.js +289 -359
  327. package/bin/force-patch-changesets.js +18 -2
  328. package/bin/lib/apply.js +86 -32
  329. package/bin/lib/desired.js +87 -0
  330. package/bin/lib/detect-agent.js +22 -38
  331. package/bin/lib/doctor.js +283 -33
  332. package/bin/lib/features.js +78 -0
  333. package/bin/lib/manifest.js +127 -48
  334. package/bin/lib/overrides.js +35 -0
  335. package/bin/lib/personas.js +37 -0
  336. package/bin/lib/plan.js +18 -9
  337. package/bin/lib/purge.js +11 -0
  338. package/bin/lib/reconcile.js +68 -0
  339. package/bin/lib/scan.js +24 -0
  340. package/bin/lib/state.js +25 -1
  341. package/bin/lib/stt-wizard.js +33 -0
  342. package/bin/lib/transaction.js +149 -0
  343. package/bin/lib/tui.js +71 -0
  344. package/bin/lib/verify.js +9 -26
  345. package/bin/snapshot-version.js +3 -6
  346. package/docs/ARCHITECTURE.md +55 -21
  347. package/docs/MIGRATION-agent-fleet.md +222 -0
  348. package/docs/agent-fleet-setup.md +124 -64
  349. package/docs/claude-code-coms-bridge.md +21 -2
  350. package/docs/coms-hermes-bridge.md +1 -1
  351. package/docs/getting-started.md +61 -217
  352. package/docs/npm-install.md +207 -429
  353. package/docs/pi-extensions.md +85 -41
  354. package/docs/pi-setup.md +48 -545
  355. package/hermes/README.md +1 -1
  356. package/install-manifest.json +385 -1255
  357. package/justfile +45 -27
  358. package/manifest-meta.json +544 -134
  359. package/node_modules/pi-ask-user/README.md +43 -5
  360. package/node_modules/pi-ask-user/index.ts +630 -75
  361. package/node_modules/pi-ask-user/package.json +1 -1
  362. package/package.json +5 -11
  363. package/scripts/coms-claude-bridge.ts +10 -0
  364. package/scripts/fleet.ts +107 -90
  365. package/scripts/lib/claude-bridge-core.ts +45 -0
  366. package/scripts/lib/fleet-command.ts +170 -15
  367. package/scripts/lib/monitor-env.ts +18 -6
  368. package/scripts/lib/peer-launch.ts +6 -2
  369. package/scripts/lib/team-project.ts +24 -4
  370. package/scripts/team-up.ts +57 -11
  371. package/skills/designing-agents/SKILL.md +1 -1
  372. package/skills/designing-agents/pi-harness-authoring.md +3 -3
  373. package/.claude/commands/build.md +0 -44
  374. package/.claude/commands/design-agent.md +0 -14
  375. package/.claude/commands/doctor-agent-fleet.md +0 -22
  376. package/.claude/commands/orchestrate.md +0 -112
  377. package/.claude/commands/prime.md +0 -22
  378. package/.claude/commands/review.md +0 -16
  379. package/.claude/commands/set-hermes-telegram.md +0 -15
  380. package/.claude/commands/set-hermes-watchdog.md +0 -6
  381. package/.claude/commands/setup-agent-fleet.md +0 -17
  382. package/.claude/commands/ship.md +0 -72
  383. package/.claude/commands/spec.md +0 -15
  384. package/.claude/commands/test.md +0 -19
  385. package/.claude/commands/webperf.md +0 -32
  386. package/.claude/orchestrate-teams.yaml +0 -24
  387. package/.opencode/commands/af-build.md +0 -17
  388. package/.opencode/commands/af-code-simplify.md +0 -16
  389. package/.opencode/commands/af-compound.md +0 -16
  390. package/.opencode/commands/af-design-agent.md +0 -15
  391. package/.opencode/commands/af-doctor-agent-fleet.md +0 -22
  392. package/.opencode/commands/af-orchestrate.md +0 -112
  393. package/.opencode/commands/af-plan.md +0 -16
  394. package/.opencode/commands/af-prime.md +0 -22
  395. package/.opencode/commands/af-review.md +0 -15
  396. package/.opencode/commands/af-set-hermes-watchdog.md +0 -6
  397. package/.opencode/commands/af-setup-agent-fleet.md +0 -17
  398. package/.opencode/commands/af-ship.md +0 -16
  399. package/.opencode/commands/af-spec.md +0 -16
  400. package/.opencode/commands/af-test.md +0 -21
  401. package/.opencode/commands/af-webperf.md +0 -32
  402. package/.opencode/orchestrate-teams.yaml +0 -24
  403. package/.pi/prompts/af-doctor-agent-fleet.md +0 -22
  404. package/.pi/prompts/af-setup-agent-fleet.md +0 -19
  405. package/.versions/0.0.1/.opencode/commands/af-doctor-agent-fleet.md +0 -15
  406. package/.versions/0.0.1/.opencode/commands/af-setup-agent-fleet.md +0 -15
  407. package/.versions/0.0.1/skills/guided-workspace-setup/SKILL.md +0 -506
  408. package/.versions/0.0.10/.opencode/commands/af-doctor-agent-fleet.md +0 -22
  409. package/.versions/0.0.10/.opencode/commands/af-setup-agent-fleet.md +0 -17
  410. package/.versions/0.0.10/.pi/prompts/af-doctor-agent-fleet.md +0 -22
  411. package/.versions/0.0.10/.pi/prompts/af-setup-agent-fleet.md +0 -19
  412. package/.versions/0.0.10/skills/guided-workspace-setup/SKILL.md +0 -226
  413. package/.versions/0.0.11/.claude/commands/build.md +0 -44
  414. package/.versions/0.0.11/.claude/commands/code-simplify.md +0 -22
  415. package/.versions/0.0.11/.claude/commands/design-agent.md +0 -14
  416. package/.versions/0.0.11/.claude/commands/doctor-agent-fleet.md +0 -22
  417. package/.versions/0.0.11/.claude/commands/orchestrate.md +0 -112
  418. package/.versions/0.0.11/.claude/commands/plan.md +0 -16
  419. package/.versions/0.0.11/.claude/commands/prime.md +0 -22
  420. package/.versions/0.0.11/.claude/commands/set-hermes-telegram.md +0 -15
  421. package/.versions/0.0.11/.claude/commands/set-hermes-watchdog.md +0 -6
  422. package/.versions/0.0.11/.claude/commands/setup-agent-fleet.md +0 -17
  423. package/.versions/0.0.11/.claude/commands/ship.md +0 -72
  424. package/.versions/0.0.11/.claude/commands/webperf.md +0 -32
  425. package/.versions/0.0.11/.claude/orchestrate-teams.yaml +0 -24
  426. package/.versions/0.0.11/.opencode/commands/af-build.md +0 -17
  427. package/.versions/0.0.11/.opencode/commands/af-code-simplify.md +0 -16
  428. package/.versions/0.0.11/.opencode/commands/af-compound.md +0 -16
  429. package/.versions/0.0.11/.opencode/commands/af-design-agent.md +0 -15
  430. package/.versions/0.0.11/.opencode/commands/af-doctor-agent-fleet.md +0 -22
  431. package/.versions/0.0.11/.opencode/commands/af-orchestrate.md +0 -112
  432. package/.versions/0.0.11/.opencode/commands/af-plan.md +0 -16
  433. package/.versions/0.0.11/.opencode/commands/af-prime.md +0 -22
  434. package/.versions/0.0.11/.opencode/commands/af-review.md +0 -15
  435. package/.versions/0.0.11/.opencode/commands/af-set-hermes-telegram.md +0 -15
  436. package/.versions/0.0.11/.opencode/commands/af-set-hermes-watchdog.md +0 -6
  437. package/.versions/0.0.11/.opencode/commands/af-setup-agent-fleet.md +0 -17
  438. package/.versions/0.0.11/.opencode/commands/af-ship.md +0 -16
  439. package/.versions/0.0.11/.opencode/commands/af-spec.md +0 -16
  440. package/.versions/0.0.11/.opencode/commands/af-test.md +0 -21
  441. package/.versions/0.0.11/.opencode/commands/af-webperf.md +0 -32
  442. package/.versions/0.0.11/.opencode/orchestrate-teams.yaml +0 -24
  443. package/.versions/0.0.11/.pi/prompts/af-doctor-agent-fleet.md +0 -22
  444. package/.versions/0.0.11/.pi/prompts/af-setup-agent-fleet.md +0 -19
  445. package/.versions/0.0.11/docs/opencode-setup.md +0 -281
  446. package/.versions/0.0.11/hooks/SIMPLIFY-IGNORE.md +0 -90
  447. package/.versions/0.0.11/hooks/hooks.json +0 -14
  448. package/.versions/0.0.11/hooks/session-start.sh +0 -74
  449. package/.versions/0.0.11/hooks/simplify-ignore.sh +0 -302
  450. package/.versions/0.0.11/skills/guided-workspace-setup/SKILL.md +0 -226
  451. package/.versions/0.0.4/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  452. package/.versions/0.0.4/.opencode/commands/af-setup-agent-fleet.md +0 -15
  453. package/.versions/0.0.4/skills/guided-workspace-setup/SKILL.md +0 -535
  454. package/.versions/0.0.4/skills/guided-workspace-setup/companion-manifest.json +0 -33
  455. package/.versions/0.0.5/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  456. package/.versions/0.0.5/.opencode/commands/af-setup-agent-fleet.md +0 -15
  457. package/.versions/0.0.5/skills/guided-workspace-setup/SKILL.md +0 -542
  458. package/.versions/0.0.5/skills/guided-workspace-setup/companion-manifest.json +0 -35
  459. package/.versions/0.0.6/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  460. package/.versions/0.0.6/.opencode/commands/af-setup-agent-fleet.md +0 -15
  461. package/.versions/0.0.6/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  462. package/.versions/0.0.6/.pi/prompts/af-setup-agent-fleet.md +0 -27
  463. package/.versions/0.0.6/skills/guided-workspace-setup/SKILL.md +0 -544
  464. package/.versions/0.0.6/skills/guided-workspace-setup/companion-manifest.json +0 -35
  465. package/.versions/0.0.7/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  466. package/.versions/0.0.7/.opencode/commands/af-setup-agent-fleet.md +0 -15
  467. package/.versions/0.0.7/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  468. package/.versions/0.0.7/.pi/prompts/af-setup-agent-fleet.md +0 -27
  469. package/.versions/0.0.7/skills/guided-workspace-setup/SKILL.md +0 -544
  470. package/.versions/0.0.7/skills/guided-workspace-setup/companion-manifest.json +0 -35
  471. package/.versions/0.0.8/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  472. package/.versions/0.0.8/.opencode/commands/af-setup-agent-fleet.md +0 -15
  473. package/.versions/0.0.8/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  474. package/.versions/0.0.8/.pi/prompts/af-setup-agent-fleet.md +0 -27
  475. package/.versions/0.0.8/skills/guided-workspace-setup/SKILL.md +0 -544
  476. package/.versions/0.0.8/skills/guided-workspace-setup/companion-manifest.json +0 -36
  477. package/.versions/0.0.9/.opencode/commands/af-doctor-agent-fleet.md +0 -17
  478. package/.versions/0.0.9/.opencode/commands/af-setup-agent-fleet.md +0 -15
  479. package/.versions/0.0.9/.pi/prompts/af-doctor-agent-fleet.md +0 -15
  480. package/.versions/0.0.9/.pi/prompts/af-setup-agent-fleet.md +0 -27
  481. package/.versions/0.0.9/skills/guided-workspace-setup/SKILL.md +0 -544
  482. package/bin/lib/bootstrap.js +0 -323
  483. package/bin/lib/transform-persona.js +0 -180
  484. package/docs/opencode-setup.md +0 -281
  485. package/hooks/SIMPLIFY-IGNORE.md +0 -90
  486. package/hooks/hooks.json +0 -14
  487. package/hooks/session-start.sh +0 -74
  488. package/hooks/simplify-ignore.sh +0 -302
  489. package/skills/guided-workspace-setup/SKILL.md +0 -226
  490. /package/.versions/0.0.10/{skills/guided-workspace-setup/companion-manifest.json → bin/catalog/harness-runtime-closure.json} +0 -0
  491. /package/.versions/0.0.11/{skills/guided-workspace-setup/companion-manifest.json → bin/catalog/harness-runtime-closure.json} +0 -0
  492. /package/{.opencode/commands → .versions/1.0.0/.pi/prompts}/af-set-hermes-telegram.md +0 -0
  493. /package/.versions/{0.0.9/skills/guided-workspace-setup/companion-manifest.json → 1.0.0/bin/catalog/harness-runtime-closure.json} +0 -0
  494. /package/{skills/guided-workspace-setup/companion-manifest.json → bin/catalog/harness-runtime-closure.json} +0 -0
@@ -0,0 +1,1056 @@
1
+ # agent-hub
2
+
3
+ The unified Agent Fleet runtime for pi, with [`coms`](../coms/README.md) **embedded**. Bare
4
+ `just fleet` loads Fleet Core and starts `agent-hub` in **operator** posture with direct coding
5
+ and orchestration tools, but no standing native roster. The same live session can switch to
6
+ **orchestrator** posture, which removes direct coding tools and drives native specialists under
7
+ the Verification Contract. Fleet Core loads first: [`damage-control-continue`](../damage-control-continue/README.md),
8
+ [`ask-user-remote`](../ask-user-remote/README.md), STT, Compact & Continue, BTW, and the update
9
+ checker. Both postures can adjust the native roster, run research, collaborate with Pi/Claude
10
+ peers, and hand the session to a visible coms peer.
11
+
12
+ > Consolidates the retired `agent-team` dispatcher into this harness and embeds the ported `coms`
13
+ > P2P layer from [`pi-vs-claude-code`](https://github.com/disler/pi-vs-claude-code) by
14
+ > [disler](https://github.com/disler) (MIT). See the
15
+ > [extension catalog](../../../docs/pi-extensions.md) and the
16
+ > [design plan](../../../docs/plans/agent-hub/).
17
+
18
+ **Optional phone control:** `just fleet --agents <roster> --peers <preset> --project <name>` can supply the live peers for the experimental [Codex Android conductor](../../../docs/codex-remote-conductor.md). Configure Codex for the same project; do not also launch `just fleet conductor codex <team>` for the same peers. Hermes remains the inbound `ask_user` route, while Codex performs only human-confirmed, approval-gated outbound delegation.
19
+
20
+ ## Posture, roster, and topology
21
+
22
+ These are independent runtime axes:
23
+
24
+ - **Posture** — `/af-posture operator|orchestrator` switches prompt and active tools without
25
+ restarting or losing session state. Operator keeps `read`, `bash`, `edit`, `write`, approved
26
+ extension tools, and orchestration. Orchestrator withholds direct coding tools but keeps
27
+ dispatch, research, assertions, roster controls, `ask_user`, ready coms, and ready Herdr tools.
28
+ In orchestrator posture, raw Herdr panes are auxiliary-process orchestration—not a route around
29
+ delegation for reading, editing, testing, or implementing code.
30
+ - **Native roster** — local headless Pi specialists from `.pi/agents/teams.yaml`. Bare Fleet starts
31
+ empty; select one with `--agents frontend` or add one live with `/af-agents-add code-reviewer`.
32
+ - **Peer topology** — separate long-lived Pi or Claude Code processes from `peers.yaml`, connected
33
+ by coms and optionally placed in sibling Herdr panes. `--peers frontend` selects a standing
34
+ preset; `--herdr` creates a Hub-only workspace through the empty `base` preset.
35
+ - **Hub mode** — `/af-hub-mode` controls orchestration strictness and budgets; it does not change
36
+ posture, roster, or topology.
37
+
38
+ All Hub slash commands, including `/af-handoff`, are registered in both postures. A command whose
39
+ runtime capability is unavailable refuses with remediation rather than disappearing. `--no-coms`
40
+ disables only embedded coms; direct operator work and native dispatch remain available.
41
+
42
+ ## What it does
43
+
44
+ The whole dispatch loop, end to end:
45
+
46
+ ```mermaid
47
+ sequenceDiagram
48
+ autonumber
49
+ actor U as You
50
+ participant H as Hub (dispatcher)
51
+ participant S as Specialist (e.g. builder)
52
+ participant R as Research helper
53
+ participant D as Disk (.pi/agent-sessions/)
54
+
55
+ U->>H: task
56
+ H->>D: set_assertions — Verification Contract persisted
57
+ H->>S: dispatch_agent (task + advisory scope)
58
+ S-->>H: NEEDS_RESEARCH: how does X work?
59
+ H->>R: spawn_research (researcher / deep-researcher)
60
+ R->>D: write findings file
61
+ R-->>H: one-line notice + path
62
+ H->>S: resume with file paths — never raw findings
63
+ S-->>H: structured return + named evidence
64
+ H->>D: update_assertion
65
+ H-->>U: Assertions: 2✓ 1○ 1✗ · open: A4
66
+ ```
67
+
68
+ Every borrowed idea from another harness passes one test before it lands: *does this persistently enter the dispatcher context?* If yes, it goes to disk or a one-line status instead.
69
+
70
+ `agent-hub` is the supported home for the former standalone dispatcher features:
71
+
72
+ - **Dispatcher grid** — a live dashboard of the active, dynamically adjustable native roster from `.pi/agents/teams.yaml`.
73
+ - **Specialist delegation** — `dispatch_agent` sends writable tasks to configured specialists.
74
+ - **Research helpers** — `spawn_research` and `/af-research` launch read-only helper agents. Two
75
+ `kind: research` personas ship by default: `researcher` (fast `gpt-5.3-codex-spark`) for simple
76
+ reads and `deep-researcher` (`gpt-5.5` / xhigh) for hard, cross-cutting investigation. The
77
+ orchestrator routes by persona; each persona's model + thinking level is shown in its catalog.
78
+ Finished helpers are **auto-pruned** so the research row doesn't grow without bound: auto-research
79
+ pipe helpers disappear as soon as they finish (their findings persist as `findings/*.md` files and
80
+ their handles are never resumed), while manual/persona helpers keep only the `research-keep` most
81
+ recently finished (default 4 — resumable via `/af-agents-cont rN`; older cards, and their session
82
+ files, are dropped oldest-first). Set `research-keep: <n>|all` in the overrides file to change
83
+ the cap. Running helpers are never pruned and `rN` handles are never reused.
84
+ - **Human handoff path** — `ask_user` is exposed by the `ask-user-remote` wrapper (capturing stock
85
+ `pi-ask-user` and optionally racing a `user-remote` bridge), so specialists can bubble decisions
86
+ back through the dispatcher.
87
+ - **Auto-research pipe (`NEEDS_RESEARCH:`)** — a specialist that lacks information pauses by ending
88
+ its turn with `NEEDS_RESEARCH: <question>` lines (mirror of the `ASK_USER:` protocol). The hub
89
+ intercepts them **in code**: it fans out read-only research helpers (max 4 questions per pause,
90
+ 2 pauses per dispatch), writes each helper's findings to `.pi/agent-sessions/findings/*.md`, and
91
+ resumes the specialist's session with the file paths. The dispatcher LLM sees only a one-line
92
+ notice — raw findings never enter its context. Findings files are wiped at session start.
93
+ - **Verification Contract (assertion ledger)** — the dispatcher owns a ledger of checkable
94
+ acceptance assertions built from the request *before* any builder runs, so a clearly stated
95
+ requirement is never silently dropped. `set_assertions` records the numbered, tagged assertions
96
+ (`test` | `runtime-ui` | `code-grep` | `manual`, one pass condition each, plus a required
97
+ `source` naming where the requirement comes from) and rebuilds the whole
98
+ ledger on a "wrong again" regression reset; `update_assertion` marks each one proven (named
99
+ evidence required), unproven, or failed after a verification gate; `get_assertions` reads the
100
+ full ledger (ids, tags, pass conditions, evidence) back. The hub persists the ledger to
101
+ `.pi/agent-sessions/assertions.json` (wiped at session start like `findings/`) and renders a
102
+ one-line status (`Assertions: 2✓ 1○ 1✗ · open: A4`) so the contract survives compaction without
103
+ re-flooding the dispatcher LLM context — after a compaction the dispatcher calls `get_assertions`
104
+ to recover the full text the status line omits. The `orchestrator` persona drives it — a deep-researcher
105
+ parity inventory for "behave like" requests, runtime proof for UI/visibility assertions, the
106
+ regression reset on a re-ask — per
107
+ [`orchestration-verification`](../../../skills/orchestration-verification/SKILL.md). The hub also
108
+ machine-parses each assertion-carrying specialist's structured return, writes the full raw output
109
+ to `.pi/agent-sessions/artifacts/returns/<agentKey>-run<N>.md`, surfaces only a compact
110
+ `details.structuredReturn` digest plus `details.returnPath`, and marks contract notices such as
111
+ missing assertion ids or evidence-less `assertions_proven` entries (demoted to unproven in the
112
+ tool text). `details.fullOutput` remains for `/af-zoom`/compatibility, but dispatcher-visible text is
113
+ digest + path oriented. `update_assertion(status: "proven")` validates evidence by assertion tag:
114
+ test evidence needs a command/test and outcome, `code-grep` needs pattern plus result sample,
115
+ manual needs user/`ask_user` confirmation, and `runtime-ui` needs an existing artifact path under
116
+ `.pi/agent-sessions/artifacts/evidence/`. **Advisory by design** (PRD open question 2): status is
117
+ surfaced and "proven" requires named evidence, but a dispatch is never hard-refused on an unproven
118
+ assertion — code-enforcement is the Checkpoint A decision. Two contract rules ARE enforced at the
119
+ tool: a batch with any sourceless assertion is refused with the offending ids named (a specialist
120
+ told to prove `A9` must be able to read its origin instead of spending a dispatch and an ASK_USER
121
+ cycle asking where `A9` was defined), and a batch over **8** open assertions is accepted with a
122
+ warning suggesting the split — declare the batch the next dispatches actually prove, and
123
+ `set_assertions` the next one when it starts.
124
+ - **Artifact bus** — session handoffs live under `.pi/agent-sessions/artifacts/` with conventional
125
+ `returns/`, `failures/`, `plans/`, `reviews/`, `inventories/`, and `evidence/` subdirectories, all
126
+ **archived** into an immutable `runs/<runId>/` namespace at session start rather than wiped (see
127
+ [Immutable per-run artifact namespaces](#immutable-per-run-artifact-namespaces-run-namespacejs)),
128
+ so a later session can never overwrite an earlier one's returns. `failures/` is separate on purpose: a run
129
+ that errored or timed out produced no specialist result, so its output goes there and the dispatch
130
+ result names it a **delivery failure** carrying no assertion evidence. Filing a 142-byte coms error
131
+ stub as `returns/code-reviewer-run4.md` once cost a 103-second dispatch investigating a review that
132
+ had in fact succeeded — only its reply was lost. `dispatch_agent` and `spawn_research` accept optional
133
+ `artifacts: string[]` paths (repo-relative or session-artifact-relative); the hub validates that
134
+ they stay inside the repo/session roots and injects only the path plus first heading/one-line
135
+ preview, never file bodies. Document-producing specialists are instructed to write plans, reviews,
136
+ inventories, and reports to the real session path
137
+ `.pi/agent-sessions/artifacts/<kind>/<agentKey>-run<N>.md` when their tools allow it, then report/pass
138
+ the artifact-relative handoff path `artifacts/<kind>/<agentKey>-run<N>.md`, finish with that path plus
139
+ a ≤10-line digest, and still include structured returns when assertions are carried. Repo-root
140
+ `./artifacts/...` files are not session artifacts. Planner's existing PLAN_FILE behavior is preserved;
141
+ the artifact path is an additional handoff channel.
142
+ - **Dispatch scope advisory** — `dispatch_agent` accepts optional `scope: string[]` for writable
143
+ builder-style runs. The orchestrator should derive these globs from the plan task's file list,
144
+ and skip scope for exploratory/reconnaissance work where the right files are not known yet. The
145
+ hub snapshots git status before the writable dispatch, diffs after the whole tool call (including
146
+ auto-research resumes), and reports out-of-scope paths in `details.scopeViolations` plus a ⚠ text
147
+ notice. This is advisory only: the hub never blocks completion, reverts files, or escalates
148
+ automatically. Known limitation: concurrent writable dispatches can only be attributed
149
+ approximately, so overlapping runs are flagged in the notice.
150
+ - **Agent controls** — `/af-zoom` inspects a live agent timeline; `/af-agents-history` replays the run as a
151
+ timeline (orchestrator turns, dispatches, research helpers) with per-agent durations, parallel-run
152
+ markers, and a grand total; kill/restart controls manage running child agents; per-agent `model:`
153
+ fields select models from team config. The `agents-*` commands address **both target kinds** —
154
+ team specialists by persona name, research helpers by `rN` handle (mirroring `/af-zoom`):
155
+ `/af-agents-kill <name|rN|all>` SIGTERMs a specialist (keeping its standing card), while on a
156
+ research helper it kills **and removes** the card + session — helpers are disposable by design
157
+ (`all` clears every helper); `/af-agents-restart <name|rN>` re-runs the last task fresh (a research
158
+ helper must be finished first); `/af-agents-cont rN <prompt>` resumes a finished helper's session.
159
+ The old `/af-research-rm` and `/af-research-clear` spellings remain as aliases of the kill semantics,
160
+ `/af-research-cont` of `/af-agents-cont`.
161
+ Restartable team specialists at or above 70% context render
162
+ their context percentage with a warning marker/color in dashboard and compact views, and their next
163
+ `dispatch_agent` result adds a `/af-agents-restart <persona>` hint. Research helpers are not warned,
164
+ and the hub never restarts specialists automatically.
165
+ - **Model switching** — a persona's frontmatter `models:` list declares the models it may switch to
166
+ (the default `model:` is implicitly a candidate). `/af-agent-model <persona>` picks from that list;
167
+ the choice lasts for the session and takes effect on the persona's next dispatch
168
+ (`/af-agents-restart <persona>` applies it immediately). The dot form
169
+ `/af-agent-model <persona>.<role>` switches a delegate sub-role's model instead — its candidates are
170
+ the role's declared default plus the parent persona's own candidate list; the switch is applied
171
+ when the parent is next dispatched (it lands in the serialized delegate config, so nested
172
+ children inherit it). `/af-models [profile]` applies a named profile
173
+ from `.pi/agents/model-profiles.yaml` — a macro over the same declared candidates, validated at
174
+ session start (a profile with any entry outside a persona's candidates is dropped whole, with an
175
+ error); profiles never touch sub-role models — only `/af-agent-model` reaches those. Nothing
176
+ outside the declared lists is ever selectable. When an effective project or session override
177
+ fails with a model/provider error or aborted request before work begins (including local-model
178
+ memory-limit failures), the hub retries once with the model originally declared in the persona
179
+ frontmatter. For **write-capable** runs this is pre-work only: no fallback occurs after text
180
+ output, a tool call, cancellation, timeout, drift stop, or a Pi process-spawn failure, avoiding
181
+ duplicate writes. **Read-only children and research helpers** (tools limited to
182
+ `read,grep,find,ls`) also retry once when the provider fails *mid-run* — re-running a reader
183
+ repeats nothing, and those are exactly the children that exist to protect their parent's context,
184
+ so losing one to a local-endpoint OOM halfway through discards work for no safety gain. A
185
+ terminated run (watchdog, deadline, cancellation) never retries either way: that is a verdict on
186
+ the work, not a provider outage. The failed attempt is removed from the child session before retry. Per project,
187
+ `model.<persona>:` / `models.<persona>:` keys under `## agent-hub` in
188
+ `.ai/agent-fleet-overrides.md` replace a persona's default model / candidate list.
189
+ Research personas (`researcher` / `deep-researcher`, `kind: research`) are switchable the same
190
+ way — `/af-agent-model <persona>` and `/af-agent-model-thinking <persona>` accept them alongside team
191
+ members. Since research helpers are spawned fresh on each `/af-research` / `spawn_research`, the
192
+ switch lands on their next spawn (there is no running instance to `/af-agents-restart`).
193
+ `/af-agent-models-substitute <source> <target>` is the global one-shot form: walks every loaded
194
+ persona (team + research + orchestrator), and for each whose **current effective model** is
195
+ `<source>` and whose declared candidates include `<target>`, sets the session override to
196
+ `<target>`. One-step flow — the dry-run summary (affected vs skipped, with reasons) is shown
197
+ inline, then the swap is applied immediately and takes effect on each persona's next dispatch
198
+ (`/af-agents-restart` to apply now). It never touches the dispatcher or delegate sub-roles.
199
+ - **Thinking levels** — each persona's frontmatter `thinking:` sets its pi `--thinking`
200
+ reasoning effort (`off` · `minimal` · `low` · `medium` · `high` · `xhigh`). `/af-agent-model-thinking
201
+ <persona>` switches it among those six levels for the session; like a model switch it takes effect
202
+ on the persona's next dispatch (`/af-agents-restart <persona>` applies it now), and selecting the
203
+ frontmatter default clears the override. The level shows as a short badge after the model
204
+ everywhere a model is rendered — `gpt-5.5 (xh)` in the dashboard cards and the compact below-editor
205
+ view (`min`/`low`/`med`/`hi`/`xh`; `off` shows no badge). Per project, a `thinking.<persona>:` key
206
+ under `## agent-hub` in `.ai/agent-fleet-overrides.md` replaces a persona's default level.
207
+ - **Mid-turn delegation (`delegate` tool)** — a persona that declares a `subagents:` map in its
208
+ frontmatter (`role: { model, tools? }` entries, or an indented `model:`/`tools:` block per role)
209
+ gets a real mid-turn `delegate(role, instruction, context?, allow_write?)` tool, injected as an
210
+ extra `-e delegate.ts` extension into its spawned process (the `delegate` tool name is appended to
211
+ its `--tools` allowlist — pi filters extension tools too). Only declared roles are spawnable, on
212
+ their declared models — model choice is configuration, never the child LLM's. Budgets are readable
213
+ refusals: at most 4 delegate children per dispatch, tree-wide, and a per-persona `delegate_depth:`
214
+ budget capped at 1 (the default). Children spawned with remaining depth 0 do not receive the
215
+ `delegate` extension/tool. Write safety: children run read-only (`read,grep,find,ls`) unless a
216
+ SINGLE live child gets `allow_write: true`, which inherits the parent's tools intersected with the
217
+ role's `tools:` cap; if a declared role cap leaves no available tools, delegation is refused.
218
+ Concurrent children are always forced read-only. Children stream timeline events through
219
+ `.pi/agent-sessions/delegations/<persona>/events.jsonl`; the hub tails it and renders nested rows
220
+ under the parent's card (child id, model, tokens, status),
221
+ each openable with `/af-zoom <child-id>`. Each child also writes its full final output to
222
+ `.pi/agent-sessions/delegations/<persona>/results/<childId>.md`; the parent receives only status,
223
+ a required final `DIGEST:` section (≤30 lines with path:line citations), and the result-file path.
224
+ If a child omits `DIGEST:`, the parent gets the first ~30 lines plus a no-DIGEST warning and the
225
+ result path. Spend rolls up: every child row and the parent's subtree
226
+ total show tokens, and a session-wide `Δ delegated` counter sits in the status line.
227
+ `/af-agents-kill` on the parent SIGTERMs its whole process group, so the delegation tree dies with
228
+ it. `context: fork` is accepted but treated as a summary brief in v1. Per project,
229
+ `subagents.<persona>.<role>:` and `delegate-depth.<persona>:` keys under `## agent-hub` in
230
+ `.ai/agent-fleet-overrides.md` replace individual sub-roles / the depth budget. An overridden
231
+ role retains its frontmatter model as a one-shot fallback under the same pre-work-only safety
232
+ rule; delegate cards and results show the model that ultimately ran. Six personas ship with
233
+ declared sub-roles, on a three-tier OpenAI model ladder — `gpt-5.3-codex-spark` for
234
+ recon/grep sweeps, `gpt-5.4` for analysis sweeps, the `gpt-5.5` (or opus) parent reserved for
235
+ synthesis and verdicts:
236
+ - `code-reviewer` — `preflight`+`docs` (spark), `quality`+`perf` (gpt-5.4); its first delegate
237
+ call is always `preflight`, which studies the project rules and the files under review and
238
+ returns a summary that drives the rest of the fan-out. Deep security review is not a
239
+ sub-role — it belongs to the separate `security-auditor` persona, which the reviewer
240
+ recommends dispatching when it spots deeper risk.
241
+ - `planner` — `scout`+`rules` (spark) fan out before the plan is drafted; `risk` (gpt-5.4)
242
+ optionally challenges the draft breakdown.
243
+ - `plan-reviewer` — `feasibility` (gpt-5.4) checks plan claims against the actual codebase;
244
+ `deps` (spark) verifies dependency ordering and file overlap. No preflight — the plan is
245
+ the map.
246
+ - `security-auditor` — solo `recon` (spark) maps the attack surface first, then
247
+ `input-sweep` (gpt-5.4) and `secrets-sweep` (spark) fan out; exploit reasoning stays with
248
+ the parent.
249
+ - `builder` — `recon` (spark) maps call sites before edits; `verifier` (spark, the one
250
+ `allow_write: true` child) runs the test suite after them. Implementation is never
251
+ delegated.
252
+ - `test-engineer` — `coverage-scout`+`conventions` (spark) inventory gaps and test patterns;
253
+ test writing is never delegated.
254
+ - **Dispatcher persona gate** — optional `persona-gate: on` can require an orchestrator persona at
255
+ session start; by default the dispatcher starts without the gate.
256
+ - **Default damage-control guardrails** — `just fleet` and `just fleet --no-coms` load the
257
+ `damage-control-continue` harness before `agent-hub`, so dispatcher tool calls are checked against
258
+ `.pi/damage-control-rules.yaml` and a blocked call feeds back instead of aborting the turn. A
259
+ guardrail is also re-loaded into every native specialist, research helper, and nested delegate
260
+ (see [Safety scope](#safety-scope)). Missing safety plumbing refuses child dispatch.
261
+ - **Embedded coms** — the dispatcher is a discoverable peer on the local machine. Multiple
262
+ `agent-hub` (or plain `coms`) sessions on the same box find each other through per-project registry
263
+ files and exchange messages over a unix socket (named pipe on Windows).
264
+
265
+ `/af-zoom <name|rN|child-id>` opens the selected agent's full-screen stream detail. For fleet rows,
266
+ it uses the [Fleet Dashboard detail controls](#fleet-dashboard-and-detail); a directly addressed
267
+ fallback stream keeps the legacy zoom controls. Both overlays size to the terminal.
268
+
269
+ ### `/af-agents-history`
270
+
271
+ `/af-agents-history` opens a read-only overlay (same chrome as `/af-zoom`) that replays the session as an
272
+ execution **tree**:
273
+
274
+ - **Orchestrator turns** — each dispatcher turn that actually dispatched something is a depth-0 row
275
+ labelled `(dispatcher)`. Chat-only turns add no rows.
276
+ - **Dispatched specialists and research helpers** nest one level beneath the turn that launched them;
277
+ **delegate sub-sub-agents** nest one level deeper still under the specialist that spawned them — in
278
+ start order at every level.
279
+ - **Parallel runs** — siblings whose run times overlap are marked with a `│→` connector, so a
280
+ concurrent fan-out reads as a visually grouped block.
281
+ - **Real-work durations** — each row shows that node's *own* work: its span **minus the time it spent
282
+ awaiting children**. A dispatcher blocked on six concurrent agents is credited only for the time it
283
+ actually worked between/around the awaits, never for the await itself — so the same wall-clock isn't
284
+ counted twice up the tree. The same subtraction applies to a specialist awaiting its own delegate
285
+ children. Format: plain seconds under a minute (`42sec`), `m:ss` above it (`10:20min` for 620s).
286
+ Running rows tick live (the overlay re-renders once a second) and a new dispatch appears the instant
287
+ it starts.
288
+ - **Footer** shows `Σ real work <total> · <n> runs (agents <a> + dispatchers <d>)` — the real work of
289
+ *everyone*: the dispatched specialists' and research helpers' full runtime (`agents`) plus each
290
+ dispatcher turn's own work (`dispatchers` — its span minus the time it awaited agents **and** the
291
+ human via `ask_user`). Wall-clock is deliberately **not** shown: it would fold in the idle gaps
292
+ while you're away between turns, and `ask_user` waits are subtracted for the same reason.
293
+
294
+ Navigate with `↑/↓`, press `G` to jump back to the live tail, and `Q`/`Esc` to close. The log resets
295
+ on each session start.
296
+
297
+ The agent view starts with the **compact widget** enabled: one line per *running* agent —
298
+ `name · context% · state` — *below* the input box, just above pi's status bar. Idle and done agents
299
+ are hidden, and the coms pool widget collapses too, so an idle session collapses to just the prompt
300
+ and footer. **`Alt+Shift+A`** toggles that widget on or off; the footer reports
301
+ `Alt+A fleet · Alt+Shift+A widget:compact|off`.
302
+
303
+ ### Fleet Dashboard and detail
304
+
305
+ Press **`Alt+A`** or run **`/af-agents-list`** to open the full-screen **Fleet Dashboard**. It is a
306
+ separate, live overlay—not an alternate compact-widget mode—and lists specialists, nested delegates,
307
+ research helpers, and coms peers. It shows status, hierarchy, model, context/tokens, elapsed time,
308
+ tool count, and recent work; its summary counts running/done/failed rows, overlap-aware wall time,
309
+ and visible token totals. Finished/idle/stale rows are hidden by default.
310
+
311
+ - **`↑`/`↓`** or **`j`/`k`** selects a row; **`PgUp`/`PgDn`** pages; **Enter** opens its full-screen
312
+ detail view.
313
+ - **`f`** starts a name/model/recent-work filter; type the query and press **Enter** to apply it, or
314
+ **Esc** to clear it. **`a`** toggles finished rows.
315
+ - **`x`** requests a kill and **`r`** requests a restart; press the same key again within two seconds
316
+ to confirm. Kill acts on a local running specialist, a coms-backed specialist, or a research helper.
317
+ Confirmed restart terminates a running specialist when necessary, clears its session, and re-dispatches
318
+ its previous task fresh; it is refused for peer/delegate rows, running research, and rows with no previous task.
319
+ - **`q`** or **Esc** closes the dashboard.
320
+
321
+ The detail view streams the selected local agent's text, thinking, and tool timeline. Use **`↑`/`↓`**,
322
+ **`PgUp`/`PgDn`**, and **End** to navigate/tail; **Enter** expands a selected tool call; **Ctrl+C**
323
+ copies the selected entry; **Esc**/**`q`** returns to the dashboard. Coms peers have no local
324
+ transcript and show that explicitly. **`/af-zoom <name|rN>`** opens this same detail view directly.
325
+
326
+ ### Version footer
327
+
328
+ `agent-hub` renders its local harness version first in its custom footer:
329
+ `agent fleet v<version> · <model><thinking> · <team>`. It replaces pi's default footer, so it does **not**
330
+ consume or render the shared version status; it reads its own adjacent stamped manifest directly.
331
+ The three persistent-UI harnesses (`agent-hub`, `coms`, and
332
+ `damage-control-continue`) still register that one shared key, which gives default footers one
333
+ version in stacked non-hub sessions. In the supported guardrail-plus-hub stack, the hub's custom
334
+ footer supplies the single visible version. Damage-Control can update its own safety status after
335
+ a violation without overwriting the shared version entry. The canonical source is the
336
+ repository-root `package.json`; the adjacent harness manifest is a synchronized stamp maintained
337
+ by `bin/sync-harness-versions.js`. Its local `version.ts` reader intentionally stays with the
338
+ harness for copied or symlinked installs, but those installs still need the pre-existing full
339
+ `.pi/harnesses/` dependency installation.
340
+
341
+ The `agent fleet` half of the label is an OSC 8 terminal hyperlink to the project homepage —
342
+ clickable in terminals that support hyperlinks, ignored (rendered as plain text) elsewhere, and
343
+ free of footer columns because pi strips OSC sequences before measuring width. It opens the
344
+ repository in a browser, not a TUI panel: pi has no mouse tracking, so a click never reaches the
345
+ harness. `AGENT_FLEET_NO_LINKS=1` restores the plain label on multiplexers that mangle OSC 8
346
+ (GNU screen, tmux before 3.4).
347
+
348
+ ### Voice dictation indicator
349
+
350
+ The custom footer renders the optional [`pi-voice-stt`](../../extensions/pi-voice-stt/README.md)
351
+ extension's recording indicator on a line **below the model line** — e.g.
352
+ `● REC 0:01 ⏎ send · esc cancel` while recording, or a `transcribing…` dot. Because agent-hub
353
+ replaces pi's built-in footer (where that indicator normally lives), it reads the extension's
354
+ `setStatus("voice-stt", …)` value via the footer data provider and surfaces it itself. The
355
+ indicator only appears once `pi-voice-stt` is installed and configured; otherwise the footer is
356
+ the single model line. Press **`Alt+S`** to start/stop dictation as in a normal pi session.
357
+
358
+ ### Compact-view agent switcher
359
+
360
+ With the **compact widget enabled**, the running-subagents list below the input doubles as a
361
+ switcher. **`Alt+]`** and **`Alt+[`** move a marker (`›` + highlight) to the next/previous running
362
+ subagent; **`Alt+\`** opens the full-screen detail view on the marked one (`q`/`Esc` to return).
363
+ This only changes what you *view* — **the input box always prompts the main session**, and `main` is
364
+ never a marker target (it is the session under the input, not a subagent). There is no transcript
365
+ takeover: a subagent stream is shown in an overlay, never by replacing the main scrollback. These
366
+ keys require the compact widget; use `/af-zoom <name>` or the Fleet Dashboard otherwise.
367
+
368
+ > Terminal note: `Alt+[` emits `ESC [` (a CSI prefix) and may be swallowed by some terminals'
369
+ > escape parsers; `Alt+]` and `Alt+\` are the reliable pair. `Alt+↑/↓/←/→` are reserved by the pi
370
+ > editor, which is why the switcher uses the bracket/backslash keys.
371
+ >
372
+ > On macOS, configure the outer terminal to send Option as Meta. For Zed, set
373
+ > `terminal.option_as_meta` to `true`; otherwise Option combinations produce composed characters.
374
+
375
+ ## Configuration
376
+
377
+ At session start, `agent-hub` reads `.ai/agent-fleet-overrides.md` in the workspace. The
378
+ canonical section name is `## agent-hub` (the legacy `## agent-team` name is still accepted):
379
+
380
+ ```markdown
381
+ ## agent-hub
382
+ # Replace Bulgarian with any language name.
383
+ language: Bulgarian
384
+ ```
385
+
386
+ Omit the section to keep the default `English`. `language` applies to dispatcher replies,
387
+ `ask_user` questions and `context` fields, handoff summaries, and user-facing status text;
388
+ specialist task strings stay in English.
389
+
390
+ The same section can point the team at the project's own rule files and documentation
391
+ entry points:
392
+
393
+ ```markdown
394
+ ## agent-hub
395
+ rules: docs/rules, .ai/rules
396
+ docs: Docs/AGENTS.md, Docs/architecture/ARCHITECTURE_OVERVIEW.md
397
+ ```
398
+
399
+ `rules:` lists repo-relative folders of HOW rules — implementation patterns the work must
400
+ comply with. Resolution is **index-first**: a folder with a top-level `README.md`/`index.md`
401
+ is treated as curated — personas read the index first and follow its loading manifest
402
+ (session bundles, conditional-load lists) instead of bulk-reading the tree; a folder without
403
+ an index is searched **recursively** through all subfolders. When set, every dispatched
404
+ specialist's system prompt gains a "Project rules" block naming the folders and the
405
+ resolution order; the planner and code-reviewer personas additionally validate their subject
406
+ against the relevant rules and pass them on (cited in plan acceptance criteria / handed to
407
+ delegate sub-reviewers).
408
+
409
+ `docs:` lists repo-relative WHAT/WHY documentation entry points — canonical files (e.g. an
410
+ `AGENTS.md`, an architecture overview) or doc folders (personas start from the folder's
411
+ README/index). Docs orient rather than bind: every dispatched specialist **and every research
412
+ helper** gains a "Project docs" block telling it to read the entry points relevant to its
413
+ task and follow their links instead of bulk-reading doc trees. The code-reviewer flags
414
+ changes that alter documented behavior without a doc update; the documenter treats the entry
415
+ points and the trees they link as the documentation it maintains.
416
+
417
+ The same section also tunes research-helper retention:
418
+
419
+ ```markdown
420
+ ## agent-hub
421
+ research-keep: 8
422
+ ```
423
+
424
+ `research-keep:` caps how many **finished** manual/persona research helpers stay resumable
425
+ (LRU by finish time, default 4; `all` disables the cap). Auto-research pipe helpers are
426
+ always pruned as soon as they finish, regardless of this key.
427
+
428
+ ### Bounded local-disk searches
429
+
430
+ Every `read`, `grep`, `find`, and `ls` call made by a native research helper or a nested
431
+ `delegate` child has a **parent-side** watchdog. The default is **120 seconds per tool call**;
432
+ it is a per-tool bound, not a whole-run deadline — the whole-run bound is the execution
433
+ mode's per-run deadline below. Configure it in the repository-standard overrides file:
434
+
435
+ ```markdown
436
+ ## agent-hub
437
+ recon-search-timeout-s: 120 # integer 1..3600
438
+ # recon-search-timeout-s: off # disable this per-tool watchdog
439
+ ```
440
+
441
+ Invalid values warn at session start and use 120. Calls are tracked independently by their
442
+ JSONL `toolCallId`; a repeated start/update cannot extend an existing deadline. A timeout returns
443
+ `tool_timeout` with the call metadata, ends the research/delegate lifecycle, sends SIGTERM to the
444
+ child's explicitly owned process group, then SIGKILL after a finite grace period. The parent also
445
+ has a final settlement timer, so it settles rather than waiting indefinitely for `close` or
446
+ inherited pipe drain. If child/process-group death cannot be confirmed after this bounded cleanup,
447
+ the timeout metadata reports `terminationConfirmed: false`: this prevents the parent hanging, but
448
+ may indicate an uninterruptible OS-level process that needs operator attention. This group
449
+ ownership covers descendants even when the pi leader exits first; nested delegates own their groups
450
+ and forward parent cancellation, avoiding detached-orphan processes. Caller
451
+ cancellation follows the same bounded cleanup path but is reported as `cancelled`, not
452
+ `tool_timeout`.
453
+
454
+ ### Execution modes & turn budgets
455
+
456
+ The hub runs one of three **execution modes** — `fast`, `standard` (default), `strict` —
457
+ with **per-user-turn budgets enforced in code**, not prose. This is the guardrail against
458
+ runaway orchestration (the observed failure mode: 100+ dispatches and 100M+ tokens for one
459
+ task, most of it re-billed stale specialist context).
460
+
461
+ | Budget (per user turn) | fast | standard | strict |
462
+ |-----------------------------------|--------|----------|---------|
463
+ | `dispatch_agent` calls | 2 | 8 | 24 |
464
+ | `spawn_research` calls | 1 | 4 | 12 |
465
+ | Turn wall clock | 15 min | 60 min | 240 min |
466
+ | Per-run deadline (specialist/research/delegate) | 10 min | 30 min | off |
467
+ | Specialist session recycled after | 3 runs | 5 runs | 5 runs |
468
+ | Nested delegation | off | on | on |
469
+
470
+ - **fast** — single-specialist path for small, low-risk asks; assertion ledger optional,
471
+ no nested delegation.
472
+ - **standard** — batched execution: one recon max, builder batches of 4–6 plan tasks with
473
+ one gate each, one review gate at the end.
474
+ - **strict** — the full Verification Contract (parity inventories, per-batch gates,
475
+ second confirming reads); use for production migrations and security-sensitive work.
476
+
477
+ When a budget is exhausted, `dispatch_agent`/`spawn_research` **refuse** with instructions
478
+ to summarize and ask the user; the next user message opens a fresh window. Switch modes
479
+ live with `/af-hub-mode fast|standard|strict` (no argument shows the current mode and usage);
480
+ set the project default and per-axis overrides in the overrides file:
481
+
482
+ ```markdown
483
+ ## agent-hub
484
+ mode: standard # fast|standard|strict
485
+ max-dispatches-per-turn: 8 # integer or off
486
+ max-research-per-turn: 4 # integer or off
487
+ turn-wall-time-s: 3600 # integer or off
488
+ agent-turn-timeout-s: 1800 # whole-run deadline per spawned run; integer or off
489
+ session-recycle-runs: 5 # recycle a specialist session after N resumed runs; integer or off
490
+ run-history-keep: 10 # previous sessions' artifact archives to retain; integer or off
491
+ ```
492
+
493
+ #### Task budget (the bound a turn window cannot provide)
494
+
495
+ A per-message allowance cannot bound a task. In the run this guardrail comes from, every
496
+ steering message opened a fresh window of 8 dispatches and 60 minutes, so no counter ever
497
+ bound: one workspace stayed open **47 hours**, while the same change made in a narrow
498
+ workspace took **13 minutes**.
499
+
500
+ So there is a second envelope, **`TASK_BUDGET_MULTIPLIER` (3) × the turn envelope**, whose
501
+ counters are **not** reset by a user message:
502
+
503
+ | | per turn (standard, `feature`) | per task |
504
+ |---|---|---|
505
+ | `dispatch_agent` | 6 | 18 |
506
+ | `spawn_research` | 4 | 12 |
507
+ | clock | 60 min wall | 180 min **active** |
508
+
509
+ Exhausting it is a **hard stop**: the refusal says so, and another user message does not
510
+ reopen it. Only `/af-new-task [label]` (or `set_task_tier` with `new_task: true`) opens a
511
+ new task window — clearing the counters, the tier, the review-round count, the duplicate
512
+ guard, and any external-blocker stop. The status chip shows both (`… · task 4/18`).
513
+
514
+ The reasoning: a task that has burned three full envelopes has not hit a budget problem, it
515
+ has outgrown its scope, and re-scoping is the human's call.
516
+
517
+ The task clock charges **active time only** — turns that actually ran, each minus the time
518
+ the dispatcher sat blocked on `ask_user`. Inter-turn idle costs nothing, because no turn is
519
+ open across it. Raw wall clock would bill a lunch break, an overnight pause, and every long
520
+ human answer against the task; at `fast` mode's 45-minute envelope a coffee break would
521
+ hard-stop a task with two dispatches spent. A false stop is worse than no stop — it teaches
522
+ people to reset the task window reflexively, and that reset is the one thing that has to
523
+ stay deliberate. Dispatch and research counts remain the honest hard stops.
524
+
525
+ The **auto-research pipe** (specialist emits `NEEDS_RESEARCH`, the hub fans out read-only
526
+ helpers in code) stays exempt from the TURN budget — it is hub mechanics, not a dispatcher
527
+ decision, and it must not steal the dispatcher's slots — but it **is** charged against the
528
+ task envelope. At 2 rounds × 4 questions per dispatch and 18 dispatches per task, leaving it
529
+ uncounted would have put 144 research runs inside the bound that is supposed to be the outer
530
+ one. When the task's research envelope is spent the pipe does not spawn and the specialist is
531
+ not resumed; the dispatch result says so.
532
+
533
+ Two related always-on behaviors: specialist **context pressure is measured over
534
+ input + cacheRead + cacheWrite** (resumed sessions re-send their whole accumulated context
535
+ as cache reads — counting `input` alone hid that entirely), and a specialist session is
536
+ **recycled** (fresh session, no `-c` resume) once it has served `session-recycle-runs` runs
537
+ or its measured context passes 60%. The dispatch result notes the recycle so the dispatcher
538
+ knows the specialist starts without session memory — task text and `artifacts:` paths must
539
+ carry the state, which the deliverable-to-file protocol already ensures.
540
+
541
+ Context is measured against **that agent's own** model window, resolved from pi's model
542
+ registry (`ctx.modelRegistry.find`) with the source recorded on every resolution. Dividing a
543
+ 49k local model's usage by the dispatcher's window is what produced unactionable readings
544
+ like `⚠ Planner context at 315%`; a reading above 100% now emits a one-time diagnostic that
545
+ names the window and where the number came from, so a mis-resolved window is distinguishable
546
+ from a genuine overflow. Two recycle rules follow from it: a session at or past a **full**
547
+ window is recycled unconditionally (no threshold override keeps it alive), and a resumed
548
+ session whose *projected* prompt — prior tokens plus this task — would overflow is recycled
549
+ **before** the spawn instead of after the run.
550
+
551
+ #### Per-provider concurrency
552
+
553
+ A dispatch may fan out to four delegate children at once and several specialists can be
554
+ mid-run, with nothing bounding how many requests land on one provider. That is fine against
555
+ a hosted endpoint and not against a local one. Requests are capped per process — **2 in
556
+ flight for `custom/*` by default, unlimited elsewhere**:
557
+
558
+ ```bash
559
+ AGENT_HUB_PROVIDER_LIMITS="custom=4" # raise the local cap
560
+ AGENT_HUB_PROVIDER_LIMITS="custom=off" # disable it
561
+ AGENT_HUB_PROVIDER_LIMITS="custom=2,ollama=1"
562
+ ```
563
+
564
+ Queued runs still execute — they wait for a permit, and the wait is announced rather than
565
+ looking like a hang. The cap applies per **level** of the delegation tree (each pi process
566
+ runs its own semaphore over the children it spawns), and a nested spawn reuses its parent's
567
+ permit, so a child can never wait on its own ancestor. The drift judge and the return
568
+ extractor are deliberately ungated: both run while a specialist holds a permit, so queueing
569
+ them behind it would stall the watchdog meant to stop it.
570
+
571
+ The per-run deadline lands as `turn_timeout` (exit 124) with partial output preserved, for
572
+ dispatched specialists, research helpers, and nested delegate children alike — a hung child
573
+ can no longer hold its parent for hours.
574
+
575
+ ### Task triage (complexity tiers)
576
+
577
+ The dispatcher classifies the current TASK with the `set_task_tier` tool BEFORE its first
578
+ dispatch — `trivial` / `small` / `feature` / `project` — and the hub lowers the enforced
579
+ dispatch/research caps to **min(mode, tier)**: trivial = 1 dispatch / 1 research,
580
+ small = 2 / 2, feature = 6 / 4, `project` defers to the mode. The tier shows in the
581
+ `hub-mode` status chip (`Mode: standard·small · …`), with a trailing `?` while it is only
582
+ assumed.
583
+
584
+ Skipping the call makes the hub assume **`small`**, not `feature`. Because the tier is
585
+ task-scoped, a skipped triage latches for the whole task — and skipped triage is precisely
586
+ the case where the dispatcher was not thinking about proportionality. Assuming `feature`
587
+ there would unlock planner/plan-reviewer/security-auditor, loosen the review caps, and hand
588
+ out the full feature envelope: the over-apparatus failure mode, granted by forgetting a tool
589
+ call. Assuming `small` costs one explicit escalation when the work really is bigger, which
590
+ is the cheap direction to be wrong in. An assumed tier is not a ratchet baseline either: the
591
+ dispatcher's own first `set_task_tier` is treated as an initial declaration, so it never
592
+ needs a `reason` it had no way to know it needed.
593
+
594
+ The tier is **task-scoped and ratcheted**. It survives the user's next message, and it
595
+ moves in one direction cheaply: **lowering it is always free, raising it requires a
596
+ `reason`** naming what the ask turned out to contain (refused in code otherwise). A
597
+ turn-scoped tier could not bind on a steered run — every correction reset it to null, the
598
+ next dispatch re-assumed `feature`, and the effective tier drifted to the ceiling, because
599
+ nobody ever re-declares `trivial` after a steering message.
600
+
601
+ Three guards are enforced in code, not prose:
602
+
603
+ - **Duplicate-dispatch guard** — refuses re-dispatching the same agent with a
604
+ near-identical task inside one turn.
605
+ - **Tier persona gate** — at `trivial`/`small`, `dispatch_agent`/`spawn_research` refuse
606
+ `planner`, `plan-reviewer`, `architect`, `security-auditor` and `deep-researcher`
607
+ (`run-budget.js`). Each opens a document/finding loop whose output then has to be
608
+ executed and re-reviewed; the escape hatch is raising the tier *with a reason*, not a
609
+ flag. The refusal costs no budget slot.
610
+ - **Review round cap** — review dispatches per TASK are capped by tier (trivial/small 1,
611
+ feature 2, project uncapped) and the (N+1)-th is refused without spending a budget slot.
612
+ This is where the review ratchet is actually cut: findings become requirements and the
613
+ enlarged requirement set justifies the next round, so the round is the thing to bound.
614
+ - **Review finding budget** — a review persona's dispatch carries a blocking-finding cap
615
+ tied to the tier (trivial 1, small 2, feature 5, project uncapped) plus the rule that a
616
+ blocking finding may only enforce an invariant the task/plan/rules already state. The hub
617
+ **counts** what came back (`review-findings.js`) and appends a visible notice when the
618
+ return exceeds the cap — it never reclassifies a finding. No rule the hub can evaluate
619
+ distinguishes "invents a manifest nobody asked for" from "this logs a connection string";
620
+ both are a heading and a bullet, and silently demoting the second by position would, on
621
+ the day it matters, move a real security finding into the section nobody acts on.
622
+
623
+ Every budget/gate refusal is counted in `/af-hub-report`.
624
+
625
+ ### Docs lane (`docs-lane.js`)
626
+
627
+ A dispatch whose declared `scope` is documentation only — `Docs/**`, `**/*.md`,
628
+ `artifacts/evidence/*.png`, `.changeset/**` — runs in the single-worker docs lane:
629
+
630
+ - dispatching a review persona (`code-reviewer`, `plan-reviewer`, `security-auditor`,
631
+ `test-engineer`) on it is **refused** and costs no budget slot;
632
+ - any other persona's result carries a note telling the dispatcher not to open a review
633
+ gate for it.
634
+
635
+ An absent or empty `scope` is never the lighter lane — unknown is not docs. The refusal is
636
+ overridable per dispatch with `review_reason: "<why>"` for the cases that do warrant a gate
637
+ (the doc publishes a credential, or states a contract other systems depend on).
638
+
639
+ ### External-blocker stop (`external-blocker.js`)
640
+
641
+ A specialist that cannot proceed without something outside the fleet's reach — an account,
642
+ a permission, a deployment credential, a telemetry destination, a console-only action —
643
+ emits `EXTERNAL_BLOCKED: <what is missing, who owns it, what it blocks>` (the protocol is
644
+ injected into every specialist prompt). The hub records it and **refuses the next
645
+ dispatch/research** with an owner-escalation packet: what is missing and who owns it, which
646
+ assertions are blocked, what is already proven and where, and the human's options (provide
647
+ access / waive as UNPROVEN / drop from scope).
648
+
649
+ The gate opens when the human has been addressed — an `ask_user` call, or the next user
650
+ message. Without `ask_user` installed it fires exactly once, so a session that cannot reach
651
+ the human can still finish and report instead of deadlocking.
652
+
653
+ This exists because the alternative is the most expensive failure mode observed: with no
654
+ correlation destination available, a run kept substituting internal work for the missing
655
+ external fact — scripts, manifests, fixtures, diagnostic packets — for hours, and the
656
+ assertion still ended UNPROVEN.
657
+
658
+ ### Immutable per-run artifact namespaces (`run-namespace.js`)
659
+
660
+ Session start used to `rm -rf` `.pi/agent-sessions/artifacts/`, and specialist returns were
661
+ named by a per-session counter (`returns/builder-run1.md`). Both halves of that failed at
662
+ once: the next session's `builder-run1.md` claimed the same path as the previous one's, and
663
+ the wipe deleted the originals first — a post-mortem had to record eleven implementation
664
+ returns and two review artifacts as NOT RECOVERABLE.
665
+
666
+ Now each session **archives** the previous session's artifacts into
667
+ `.pi/agent-sessions/runs/<runId>/artifacts/` — a namespace written once and never reused —
668
+ alongside a read-only `meta.json` (run id, archive time, project, workspace, per-kind
669
+ artifact counts) and an appended `runs/index.json`. `runId` is a sortable UTC timestamp plus
670
+ a random suffix, so two sessions starting in the same second still get distinct namespaces.
671
+ Retention is `run-history-keep` (default 10, `off` keeps everything); an empty artifact tree
672
+ is not archived. If archiving fails the artifacts are **left in place** rather than deleted:
673
+ a stale tree is recoverable, a deleted one is not.
674
+
675
+ ### Drift watchdog (in-flight observation)
676
+
677
+ An armed dispatch is observed **while it runs**, from the same JSON event stream that
678
+ drives the cards — not post-hoc:
679
+
680
+ - **Layer 1 — deterministic rules, zero tokens** (`drift-watchdog.js`): a write/edit
681
+ outside the dispatch's declared `scope` globs, the identical tool call repeated 4×,
682
+ 5 consecutive failed tool calls, or 200 total tool calls in one run.
683
+ - **Layer 2 — LLM judge, escalation only**: when a rule fires (single-flight, 90 s
684
+ cooldown), a one-shot cheap run (default model: the researcher persona's; override with
685
+ `watchdog-judge-model`) reads the original task + declared scope + recent tool trail and
686
+ answers `VERDICT: ON_TRACK|DRIFTING|STUCK`. Judge failures fail open.
687
+ - **Intervention**: DRIFTING/STUCK terminates the run as **`drift_stop`** (exit 125,
688
+ partial output preserved) and the dispatch result instructs: re-dispatch ONCE with a
689
+ corrected, narrowed task — never the same task unchanged.
690
+
691
+ Enablement is dynamic, precedence top to bottom: the `watchdog: true|false` param on a
692
+ single `dispatch_agent` call → a per-agent override (`/af-watchdog builder on|off|clear`) →
693
+ the hub-wide setting (`/af-watchdog on|off|auto`, default `auto`, project default via the
694
+ `watchdog:` overrides key). Read-only research helpers are not monitored — they already
695
+ run under the per-tool watchdog + turn deadline and cannot write.
696
+
697
+ ### Dynamic teams
698
+
699
+ Rosters start from `.pi/agents/teams.yaml` but are not frozen there:
700
+
701
+ - `/af-agents-add <persona>…` / `/af-agents-drop <persona>…` — restructure the ACTIVE team
702
+ live (drop refuses running or last members; session files are kept for re-adding).
703
+ - `/af-agents-save <name>` — persist the current roster as a named team back into
704
+ `teams.yaml` (targeted block upsert; comments and other teams untouched).
705
+ - `team_adjust` — the dispatcher itself may add/drop a persona **with a stated reason**;
706
+ disabled in fast mode, capped at 8 roster members, and every change is notified to the
707
+ human. The system prompt is rebuilt each turn, so changes take effect immediately.
708
+
709
+ ### `/af-hub-report`
710
+
711
+ Per-turn cost accounting: dispatches (agent, status, elapsed, billed/output tokens),
712
+ research runs, session recycles, drift stops, and budget/duplicate refusals — for the
713
+ current turn, the last completed turn, and session totals. Billed tokens count
714
+ input + cacheRead + cacheWrite, the same measure the recycler uses.
715
+
716
+ Paths that don't exist produce a session-start warning, never an error. The full key list for
717
+ `## agent-hub` (models, sub-roles, depth budgets, persona gate, research retention, watchdog,
718
+ mode/budget keys) is documented in `docs/agent-fleet-setup.md`.
719
+
720
+ ## The coms layer
721
+
722
+ > The runtime coordination protocols this layer implements (sentinels, push over
723
+ > polling, barriers, fan-out digests, racing) are catalogued in
724
+ > [references/fleet-coordination-patterns.md](../../../references/fleet-coordination-patterns.md).
725
+
726
+ ### Fleet tools (herdr)
727
+
728
+ Inside a [herdr](https://herdr.dev) pane with a live server, the dispatcher's tool
729
+ surface additionally gets (absent otherwise, like coms):
730
+
731
+ - `herdr_spawn_peer` — stand up a constrained Fleet peer through the shared peer-launch resolver.
732
+ The peer joins **this session's `--project` pool** (the model cannot override it), and a name
733
+ declared in `.pi/agents/peers.yaml` keeps its declared `runner:`/`extensions:`/`env_file:`,
734
+ including `runner: claude-code`; undeclared explicit shapes may select a Pi persona, identity-only
735
+ Fleet Core peer, or Claude Code. Manifest-declared env is the only env admitted. The peer gets a
736
+ sibling pane in the current workspace/tab, not a second process in the Hub pane. A spawn by name
737
+ therefore produces the same declared agent as a preset launch. A persona peer **boots idle**
738
+ and does nothing until a `coms_send` reaches it, so the call waits (bounded, ~45s) for it to
739
+ register and returns `peer_ready` plus its coms name instead of a bare pane id; on failure it
740
+ returns the pane's last output, which means the peer did not start rather than that it is slow.
741
+ Peers spawned but never addressed are named at turn end and in `/af-hub-report` with a close
742
+ suggestion — closing stays the human's call.
743
+ Mechanism: herdr's `pane.split` takes **no command** — it opens a shell — so the spawn splits,
744
+ waits for the pane's prompt, and types the argv (text and Enter sent separately, because bash
745
+ bracketed paste would swallow a newline). Only `layout.apply` pane nodes carry an argv, which is
746
+ why declarative preset layouts were never affected by this.
747
+ - `herdr_spawn_pane` — create an arbitrary command pane when a constrained/addressable Fleet peer
748
+ is not the desired shape; raw commands are intentionally excluded from `herdr_spawn_peer`.
749
+ Orchestrators may use this for auxiliary processes such as watchers or servers, never to bypass
750
+ delegate-only implementation policy.
751
+ - `herdr_read_pane` — bounded `pane.read` (≤200 lines), read-to-decide on workers/tools;
752
+ messaging still goes through coms, and peer busy state comes from `coms_list`, not from
753
+ reading the screen
754
+ - `herdr_close_pane` — kills a pane; **asks the human to confirm every call**; the
755
+ bash-level `herdr pane close`/`workspace close`/`server stop` verbs are hard-blocked
756
+ for spawned specialists by `.pi/damage-control-rules.yaml`
757
+ - `herdr_notify` — desktop notification to reach the human when they are away
758
+
759
+ This closes the fleet loop: spawn a worker, watch it, notify the human, tear it down —
760
+ without leaving the session. Claude Code panes join the same pool via the
761
+ [coms bridge](../../../docs/claude-code-coms-bridge.md).
762
+
763
+ ### Presence backend (herdr or files)
764
+
765
+ Presence is pluggable, exactly as in the standalone [coms harness](../coms/README.md#presence-backends-herdr-vs-files):
766
+ inside a [herdr](https://herdr.dev) pane with a live server, the ping cycle is replaced by
767
+ push events (`agent.list` + `events.subscribe`) and the hub reports itself into the herdr
768
+ sidebar (`custom_status` = `<name> <pct>% q<depth>`); everywhere else the original 10s
769
+ ping loop runs unchanged. The file registry is written in both backends, and the
770
+ pool-scope boundary is enforced identically.
771
+
772
+ ### Identity
773
+
774
+ Each session registers a coms identity at start-up, resolved in this precedence order:
775
+
776
+ 1. **CLI flags** — `--name`, `--purpose`, `--project`, `--color`, `--explicit`
777
+ 2. **Dispatcher persona frontmatter** — `name`, `description` (→ purpose), `color` from the
778
+ selected `kind: orchestrator` persona (see [persona sync](#persona--coms-purpose-sync))
779
+ 3. **Defaults** — auto-generated name `hub-<id>`, purpose `agent-hub dispatcher`, project
780
+ `default`, a deterministic color derived from the session id
781
+
782
+ Names are de-duplicated per project (`resolveUniqueName`), so two hubs that both want `architect`
783
+ become `architect` and `architect-2`. `--explicit` marks a **private** peer — kept out of every
784
+ pool by default, so it is neither listed nor reachable until a human opts in with `/af-coms --all`
785
+ (see [Pool scope is the reach boundary](#pool-scope-is-the-reach-boundary)). The registry lives
786
+ under `~/.pi/coms/projects/<project>/agents/<name>.json` and is created at runtime.
787
+
788
+ ### Commands & tools (local dispatcher plus coms)
789
+
790
+ - `/af-coms` — coms control surface (peer list / status)
791
+ - `/af-handoff <peer>` — hand the whole session off to a coms peer (see [Handoff](#handoff))
792
+ - `/af-compound [focus]` — end-of-session **compound-learning pass**: the dispatcher composes a
793
+ candidate-lessons brief from the session (corrections, recurring findings, root causes),
794
+ confirms it with the user, then dispatches the `documenter` to land the approved lessons as
795
+ minimal diffs on the project's `rules:`/`docs:` targets per `skills/compound-learning/SKILL.md`.
796
+ Requires the `documenter` persona in the active team; run it before `/af-handoff` or session end.
797
+ - `coms_list` — discover the peers in your pool: names, models, live context usage, purpose,
798
+ `pane_id`, and `status` (`idle` | `working` | `booting`). Check status before sending: `working`
799
+ means your send waits behind the peer's current turn, `booting` means it is not addressable yet.
800
+ This is the field whose absence drove 127 `herdr_read_pane` calls in one session. Scoped
801
+ to your project and excluding private peers; the LLM cannot widen it (see
802
+ [Pool scope is the reach boundary](#pool-scope-is-the-reach-boundary)).
803
+ - `coms_send` — send a prompt to a peer **in your pool**; returns a `msg_id`
804
+ - `coms_await` — **block** until that `msg_id`'s reply lands (default 30 min,
805
+ `PI_COMS_TIMEOUT_MS`)
806
+ - `coms_get` — **non-blocking** poll of a `msg_id` (status `pending|complete|error`)
807
+
808
+ `/af-coms` and `/af-handoff` tab-complete live peer names **in your pool**.
809
+
810
+ ### Pool scope is the reach boundary
811
+
812
+ The set of peers shown in the pool widget is the security boundary: **a peer is reachable only if it
813
+ is in your pool.** `coms_list`, `coms_send`, and `/af-handoff` all resolve targets through the same
814
+ `peersInScope()` helper, so the dispatcher can never message a peer it cannot see. Two knobs define
815
+ the pool, and **both are human-only** — the LLM cannot widen scope to reach more peers:
816
+
817
+ - **Project** — defaults to your own `identity.project`. A human can retarget with `/af-coms --project
818
+ <name>` (one project) or `/af-coms --all` (every project). `coms_list`'s own parameters cannot
819
+ override this; an LLM request for a wider project is clamped back to the current pool and flagged.
820
+ - **Explicit (private) peers** — excluded from every pool by default. `/af-coms --all` opts them in.
821
+
822
+ This closes a cross-project leak where a peer reachable through the mesh was *not* shown in the
823
+ default project-scoped pool — so it could be messaged without being "connected." Now the reachable
824
+ set is always a subset of what the widget shows. To reach a peer outside the pool, a human widens
825
+ scope first; the dispatcher is told to **ask** rather than attempt it, and not to pass cross-project
826
+ context to a peer the human has not approved.
827
+
828
+ ### Peer as subagent
829
+
830
+ The dispatcher uses a peer as a subagent by pairing the tools: `coms_send(target, prompt)` to
831
+ issue the task, then `coms_await(msg_id)` to block for the reply (or `coms_get` to poll). This sits
832
+ alongside `dispatch_agent` — local persona specialists are dispatched as subprocesses; remote peers
833
+ are reached over coms. The two paths stay explicit for the LLM, but
834
+ [coms-backed dispatch](#coms-backed-dispatch-dispatch-policyyaml) can route a `dispatch_agent` call
835
+ to a same-name peer under the hood. (The specialist-level `delegate` tool is a third,
836
+ nested path: a dispatched specialist spawning its own declared sub-agents — it does not auto-route
837
+ between local and remote either.) Multi-hop is inherited from coms: a peer handling a dispatched task can `coms_send`
838
+ onward, hops accumulating up to `MAX_HOPS` (5).
839
+
840
+ ### Coms-backed dispatch (dispatch-policy.yaml)
841
+
842
+ `just fleet --agents <roster> --peers <preset>` boots the Hub next to standing peers from
843
+ `.pi/agents/peers.yaml` — and some
844
+ of them (e.g. `code-reviewer`, `plan-reviewer` with `runner: claude-code`) intentionally share a name
845
+ with a team member. `.pi/agents/dispatch-policy.yaml` tells the dispatcher to serve such members
846
+ **through the peer** instead of spawning a native subagent:
847
+
848
+ ```yaml
849
+ default: native # coms = substitute ANY member with a live same-name pool peer
850
+ grace_s: 30 # poll window for coms-required members
851
+ substitutions:
852
+ code-reviewer:
853
+ prefer: coms
854
+ fallback: native # none = coms-required: refuse with guidance instead of spawning
855
+ # timeout_s: 3600 # per-member reply timeout (default PI_COMS_TIMEOUT_MS, 30 min)
856
+ ```
857
+
858
+ Semantics:
859
+
860
+ - **One API with an explicit override.** `dispatch_agent(..., backend: "auto"|"native"|"coms")`
861
+ defaults to `auto`, which follows this policy. `native` always starts the local Pi specialist even
862
+ when a same-name peer is live. `coms` requires that live same-name peer and never falls back to
863
+ native. The whole downstream pipeline — structured return contract,
864
+ `ASK_USER:` extraction, the NEEDS_RESEARCH auto-research pipe, assertions, history, the grid —
865
+ consumes a coms reply exactly like a subagent's final output (the dispatch protocols ride in the
866
+ message body, since a standing peer only receives a user prompt).
867
+ - **Decided per dispatch, against the live pool.** Hub and peers boot in parallel, so the first
868
+ dispatch may land before the peer registers: with `fallback: native` it runs natively (one notice
869
+ per member per team activation), and later dispatches pick up the peer once it is live. With
870
+ `fallback: none` the dispatch polls the pool for `grace_s` seconds, then refuses with remediation
871
+ steps. The name match is scoped to the coms pool — the same security boundary as `coms_send`.
872
+ - **Standing context is the point.** Re-dispatches (ASK_USER answers, research resumes) go back to
873
+ the same peer session, so a Claude Code reviewer keeps its review context across rounds.
874
+ - **Visibility.** The member's grid card shows a `⇄coms <peer-model>` badge, history entries are
875
+ annotated `(coms)`, and `/af-dispatch-policy` prints the resolved routing per member with live-peer
876
+ status.
877
+ - **Limitations.** `/af-agents-kill` on a coms-backed run only abandons the wait — the peer keeps
878
+ running in its own pane and cannot be killed from the hub (`/af-agents-restart` abandons, then
879
+ re-dispatches). `/af-zoom` shows only the final reply (there is no stream), tool counts stay 0, and
880
+ context% is a registry snapshot. `/af-agent-model` overrides apply only to native(-fallback) runs —
881
+ the peer's model is set in `peers.yaml`.
882
+
883
+ Missing file = everything native. HOW a peer runs (persona, model, `runner: claude-code`, env) stays
884
+ in `peers.yaml`; this file only decides WHEN the hub prefers a peer over a native spawn.
885
+
886
+ ### Handoff
887
+
888
+ `/af-handoff <peer>` transfers the session to another **main** agent. Following the plan's
889
+ **decision G1**, it does *not* try to extract a compaction summary; instead it asks the dispatcher
890
+ LLM to compose a **self-contained brief** ("everything the target needs, assume no shared history"),
891
+ then `coms_send`s that brief to the peer, `coms_await`s the reply, and relays it back — in the
892
+ configured user-facing language. When the handoff `coms_send` fires, the hub appends machine-generated
893
+ sections after the LLM brief: `## Verification ledger (verbatim, machine-appended)` with every current
894
+ assertion in canonical ledger form, and `## Artifact index` with artifact paths plus first headings.
895
+ The target peer must treat the machine-appended ledger as the contract, not the paraphrased brief.
896
+ The target peer takes over; the source relays the result. There is no raw session copy (pi sessions
897
+ aren't portable between live agents). The target must be a peer in your pool — `/af-handoff` resolves
898
+ through the same [scope boundary](#pool-scope-is-the-reach-boundary) as `coms_send`, so you cannot
899
+ hand a session to a peer you cannot see.
900
+
901
+ ### Pool widget
902
+
903
+ A live "pool" widget lists connected peers with name, model, and live context usage, refreshed by a
904
+ ping cycle; a keepalive cycle re-writes this session's own registry entry (and self-heals it if an
905
+ external prune removed it). Both timers are `unref`'d so they never hold the process open.
906
+
907
+ ### Persona → coms purpose sync
908
+
909
+ The dispatcher persona gate fires *after* coms init, so the identity's `purpose` starts from the
910
+ flag/frontmatter/default and is then reconciled to the chosen persona: `syncComsPurpose()` maps the
911
+ selected `kind: orchestrator` persona to `"<Name> — <description>"` and re-writes the live registry
912
+ entry — **unless** `--purpose` was passed explicitly (an explicit flag always wins). Switching or
913
+ resetting the persona via `/af-persona` re-syncs.
914
+
915
+ ### Graceful degradation
916
+
917
+ If the coms socket can't bind at start-up (`comsReady` stays `false`), the session degrades to a
918
+ local dispatcher without coms: the `coms_*` tools are withheld from `setActiveTools`, the
919
+ `/af-handoff` command refuses with a notice, and the "Peer agents (coms)" prompt section is omitted.
920
+ Orchestration, research helpers, and the grid keep working.
921
+
922
+ ### Tool surface
923
+
924
+ `setActiveTools` always preserves the orchestration surface and adds runtime-ready capabilities.
925
+ Operator posture also preserves the baseline direct/extension tools; orchestrator posture does not.
926
+ Coms tools are active only when coms is ready, Herdr tools only in a live Herdr pane, and `ask_user`
927
+ only when registered. Posture switching recomputes this list live without touching session state.
928
+
929
+ `set_assertions` / `update_assertion` / `get_assertions` are the always-on Verification Contract ledger tools (see
930
+ [What it does](#what-it-does)); like `dispatch_agent` / `spawn_research` they are part of the
931
+ orchestration surface the dispatcher persona never narrows.
932
+
933
+ The dispatcher persona is **flavor-only** (decision G4 / 9) — it enriches the role but never narrows
934
+ this tool set, so coms and dispatch stay available regardless of the chosen persona.
935
+
936
+ ## Optional Hermes local monitor transport
937
+
938
+ The optional monitor is an Agent Fleet-owned transport boundary, not a Hermes runtime API or a
939
+ bundled Hermes plugin. When enabled, `agent-hub` publishes dispatcher-turn and specialist-run
940
+ state and owns generation-safe cancellation. A separate local Hermes UI or operator client may
941
+ consume the owner-only discovery + Unix-socket contract documented in
942
+ [`hermes/README.md`](../../../hermes/README.md#local-agent-hub-monitor-integration).
943
+
944
+ Set these before the hub starts:
945
+
946
+ ```bash
947
+ export AGENT_FLEET_PROFILE_ID="approved-profile-id"
948
+ export AGENT_FLEET_MONITOR_RUNTIME_DIR="/absolute/owner-only/runtime-root"
949
+ ```
950
+
951
+ Both are required for monitor startup; the runtime root must be absolute and owner-only, and the
952
+ profile ID must be a safe identifier. The monitor also starts only for a Herdr-backed hub with
953
+ `HERDR_WORKSPACE_ID` and `HERDR_PANE_ID`; retain those values and `HERDR_SOCKET_PATH` in the
954
+ standard `just fleet --agents <roster> --peers <preset>` flow. Workspace labels are display metadata, not monitor identity.
955
+
956
+ The live contract exposes three authenticated newline-delimited JSON requests: `snapshot`, cursor-
957
+ based `output`, and exact-generation `cancel`. The monitor is local-only and fails closed when its
958
+ profile discovery, lease, token, or Unix socket is unavailable. A native cancel targets only the
959
+ matching hub-owned process generation. A coms cancel abandons the local wait only; its peer can
960
+ continue. Neither path controls or closes a Herdr workspace/pane.
961
+
962
+ Example startup:
963
+
964
+ ```bash
965
+ monitor_runtime="${XDG_RUNTIME_DIR:?}/agent-fleet-monitor"
966
+ install -d -m 700 "$monitor_runtime"
967
+ AGENT_FLEET_PROFILE_ID=dev \
968
+ AGENT_FLEET_MONITOR_RUNTIME_DIR="$monitor_runtime" \
969
+ just fleet --agents default --peers default
970
+ ```
971
+
972
+ No Desktop/backend plugin installation is required or provided. Consumers must re-discover after
973
+ lease or socket loss and must never persist or log the token.
974
+
975
+ ## Requires
976
+
977
+ - `.pi/agents/teams.yaml` for fixed specialist teams, the referenced persona `.md` files, and
978
+ (strongly recommended) [`pi-ask-user`](https://github.com/edlsh/pi-ask-user).
979
+ - `.pi/damage-control-rules.yaml` for every guarded `just fleet` Pi mode.
980
+ - Nothing extra in-repo for coms — the peer registry lives at `~/.pi/coms/` and is created at
981
+ runtime.
982
+
983
+ ## Usage
984
+
985
+ ```bash
986
+ # Unified Fleet interface (Fleet Core + Agent Hub are loaded together)
987
+ just fleet
988
+ just fleet --posture operator --agents frontend --project myrepo
989
+ just fleet --agents frontend --peers frontend --project myrepo
990
+
991
+ # equivalent direct guarded launch
992
+ pi -e .pi/harnesses/damage-control-continue/index.ts -e .pi/harnesses/ask-user-remote/index.ts -e .pi/harnesses/agent-hub/index.ts
993
+ pi -e .pi/harnesses/damage-control-continue/index.ts -e .pi/harnesses/ask-user-remote/index.ts -e .pi/harnesses/agent-hub/index.ts --name releaser --explicit
994
+
995
+ # direct unguarded launch, only when you intentionally want to skip damage-control
996
+ pi -e .pi/harnesses/agent-hub/index.ts
997
+ ```
998
+
999
+ Identity flags: `--name`, `--purpose`, `--project`, `--color`, `--explicit`.
1000
+
1001
+ ### Safety scope
1002
+
1003
+ `just fleet` and `just fleet --no-coms` load Fleet Core before `agent-hub`, so guardrails and `ask_user` apply
1004
+ to hub/dispatcher tool calls in that parent pi process — and because it is the *continue* variant, a
1005
+ blocked dispatcher call feeds back and the turn keeps going rather than aborting. Specialist and
1006
+ research agents are spawned as separate pi subprocesses with `--no-extensions` — but `agent-hub`
1007
+ resolves `damage-control-continue` from this session's `-e` flags, else the repo-local harness, and
1008
+ re-loads it into every native specialist, research helper, and nested delegate via explicit `-e`.
1009
+ `--no-extensions` keeps discovery off, so children never auto-load `.pi/extensions/` utilities or
1010
+ recursively re-load `agent-hub`; the explicit guardrail still checks every child's tool calls against
1011
+ `.pi/damage-control-rules.yaml`. Protected-path blocks escalate to the hub for explicit approval;
1012
+ protected deletions offer only Deny or Allow once, while inherently dangerous command patterns are
1013
+ non-exemptible. Denial or timeout blocks the call without aborting the child's turn. If continue
1014
+ cannot be resolved, dispatch is refused—children are never spawned unguarded. Research helpers are
1015
+ additionally read-only by construction. Guided setup enforces `agent-hub` ⇒
1016
+ `damage-control-continue` + `ask-user-remote`.
1017
+
1018
+ ### Related recipes
1019
+
1020
+ ```bash
1021
+ # Operator/native work without coms
1022
+ just fleet --no-coms
1023
+
1024
+ # Hub-only Herdr workspace and a combined topology
1025
+ just fleet --herdr --project af
1026
+ just fleet --agents default --peers docs --project af
1027
+ just fleet --agents default --peers docs --project af --dry-run
1028
+
1029
+ # Compatibility aliases (accepted with migration warnings)
1030
+ just fleet hub --solo
1031
+ just fleet team docs
1032
+
1033
+ # Snapshot refs / close cleanly / restore conversations
1034
+ just fleet snapshot docs
1035
+ just fleet down docs
1036
+ just fleet resume docs
1037
+ ```
1038
+
1039
+ `peers.yaml` groups reusable peers into named teams; each entry is `name` / `persona`
1040
+ (+ optional `model`). The persona's frontmatter `description`/`color` become the peer's
1041
+ coms purpose/color.
1042
+
1043
+ ## How it differs from its sources
1044
+
1045
+ - **Embedded, not stacked (decision 1).** coms is folded into this one `index.ts`; the identity
1046
+ flags are registered once. Loading `coms` as a second `-e` would double-register
1047
+ `--name/--purpose/...` and abort start-up.
1048
+ - **Single `session_start`.** coms init is folded into the former dispatcher's `session_start` and
1049
+ guarded by `if (!comsReady)`, so `/new` reuses the same peer identity (no leaked socket).
1050
+ - **Dispatcher is also a peer.** `setActiveTools` lists `coms_*` alongside `dispatch_agent` +
1051
+ `spawn_research` (+ `ask_user`); the system prompt gains a "Peer agents (coms)" section when coms
1052
+ is ready. The persona's `description` drives the coms `purpose` (decision 6 / Phase 6 peer
1053
+ mapping) instead of a static `--purpose`.
1054
+ - **`/af-handoff` uses an LLM-composed brief**, not a compaction-summary extraction (decision G1).
1055
+ - **Clean shutdown** SIGTERMs any running specialist/research children, clears the coms pool
1056
+ widget, and removes the registry entry on `session_shutdown` / SIGINT / SIGTERM.