@chankov/agent-fleet 1.0.4 → 2.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 (476) hide show
  1. package/.pi/harnesses/agent-hub/README.md +57 -66
  2. package/.pi/harnesses/agent-hub/capability-packs.ts +4 -4
  3. package/.pi/harnesses/agent-hub/commands/agent-model-thinking.ts +10 -0
  4. package/.pi/harnesses/agent-hub/commands/agent-model.ts +10 -0
  5. package/.pi/harnesses/agent-hub/commands/agent-models-substitute.ts +10 -0
  6. package/.pi/harnesses/agent-hub/commands/agents-add.ts +9 -0
  7. package/.pi/harnesses/agent-hub/commands/agents-drop.ts +9 -0
  8. package/.pi/harnesses/agent-hub/commands/agents-history.ts +9 -0
  9. package/.pi/harnesses/agent-hub/commands/agents-kill.ts +10 -0
  10. package/.pi/harnesses/agent-hub/commands/agents-list.ts +9 -0
  11. package/.pi/harnesses/agent-hub/commands/agents-restart.ts +10 -0
  12. package/.pi/harnesses/agent-hub/commands/agents-save.ts +9 -0
  13. package/.pi/harnesses/agent-hub/commands/agents-team.ts +9 -0
  14. package/.pi/harnesses/agent-hub/commands/compound.ts +9 -0
  15. package/.pi/harnesses/agent-hub/commands/coms.ts +9 -0
  16. package/.pi/harnesses/agent-hub/commands/context-command.ts +9 -0
  17. package/.pi/harnesses/agent-hub/commands/context.ts +39 -0
  18. package/.pi/harnesses/agent-hub/commands/dispatch-policy.ts +9 -0
  19. package/.pi/harnesses/agent-hub/commands/handoff.ts +10 -0
  20. package/.pi/harnesses/agent-hub/commands/hub-report.ts +9 -0
  21. package/.pi/harnesses/agent-hub/commands/models.ts +10 -0
  22. package/.pi/harnesses/agent-hub/commands/watchdog.ts +9 -0
  23. package/.pi/harnesses/agent-hub/commands/work-mode.ts +29 -0
  24. package/.pi/harnesses/agent-hub/commands/zoom.ts +10 -0
  25. package/.pi/harnesses/agent-hub/config/agents.ts +171 -0
  26. package/.pi/harnesses/agent-hub/config/overrides.ts +118 -0
  27. package/.pi/harnesses/agent-hub/context/agent-state.ts +30 -0
  28. package/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +211 -0
  29. package/.pi/harnesses/agent-hub/context/budgets.ts +208 -0
  30. package/.pi/harnesses/agent-hub/context/hub-state.ts +40 -0
  31. package/.pi/harnesses/agent-hub/dispatch-coms.ts +232 -0
  32. package/.pi/harnesses/agent-hub/dispatch-core.ts +27 -0
  33. package/.pi/harnesses/agent-hub/dispatch-native-complete.ts +135 -0
  34. package/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +153 -0
  35. package/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +191 -0
  36. package/.pi/harnesses/agent-hub/dispatch-native-types.ts +207 -0
  37. package/.pi/harnesses/agent-hub/dispatch-native.ts +184 -0
  38. package/.pi/harnesses/agent-hub/dispatch-observability.ts +220 -0
  39. package/.pi/harnesses/agent-hub/drift-watchdog.js +3 -3
  40. package/.pi/harnesses/agent-hub/footer.ts +3 -9
  41. package/.pi/harnesses/agent-hub/helpers.ts +2 -2
  42. package/.pi/harnesses/agent-hub/index.ts +1324 -9645
  43. package/.pi/harnesses/agent-hub/input/completions.ts +76 -0
  44. package/.pi/harnesses/agent-hub/input/shortcuts.ts +47 -0
  45. package/.pi/harnesses/agent-hub/lifecycle/context-pressure.ts +123 -0
  46. package/.pi/harnesses/agent-hub/lifecycle/monitor-session.ts +104 -0
  47. package/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +139 -0
  48. package/.pi/harnesses/agent-hub/lifecycle/turn-handlers.ts +95 -0
  49. package/.pi/harnesses/agent-hub/package.json +1 -1
  50. package/.pi/harnesses/agent-hub/policy/models.ts +126 -0
  51. package/.pi/harnesses/agent-hub/policy/roster.ts +79 -0
  52. package/.pi/harnesses/agent-hub/policy/work-mode.ts +118 -0
  53. package/.pi/harnesses/agent-hub/presentation.ts +48 -0
  54. package/.pi/harnesses/agent-hub/prompts/context.ts +46 -0
  55. package/.pi/harnesses/agent-hub/prompts/fragments.ts +115 -0
  56. package/.pi/harnesses/agent-hub/prompts/session-start.ts +88 -0
  57. package/.pi/harnesses/agent-hub/prompts/system-prompt.ts +110 -0
  58. package/.pi/harnesses/agent-hub/research/controls.ts +75 -0
  59. package/.pi/harnesses/agent-hub/research/runtime.ts +184 -0
  60. package/.pi/harnesses/agent-hub/research/spawn-run.ts +146 -0
  61. package/.pi/harnesses/agent-hub/session-start.ts +42 -0
  62. package/.pi/harnesses/agent-hub/timeline.ts +54 -0
  63. package/.pi/harnesses/agent-hub/tools/action-executors.ts +146 -0
  64. package/.pi/harnesses/agent-hub/tools/coms-tools.ts +139 -0
  65. package/.pi/harnesses/agent-hub/tools/context.ts +132 -0
  66. package/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +79 -0
  67. package/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +200 -0
  68. package/.pi/harnesses/agent-hub/tools/execution-orchestration.ts +22 -0
  69. package/.pi/harnesses/agent-hub/tools/fleet-tools.ts +202 -0
  70. package/.pi/harnesses/agent-hub/tools/herdr-executors.ts +82 -0
  71. package/.pi/harnesses/agent-hub/tools/set-task-tier.ts +29 -0
  72. package/.pi/harnesses/agent-hub/tools/spawn-research.ts +62 -0
  73. package/.pi/harnesses/agent-hub/tools/team-adjust.ts +29 -0
  74. package/.pi/harnesses/agent-hub/tools/verification-contract.ts +77 -0
  75. package/.pi/harnesses/agent-hub/types.ts +60 -0
  76. package/.pi/harnesses/agent-hub/ui/context-budget.ts +86 -0
  77. package/.pi/harnesses/agent-hub/ui/detail-panel.ts +175 -0
  78. package/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +130 -0
  79. package/.pi/harnesses/agent-hub/ui/grid.ts +306 -0
  80. package/.pi/harnesses/agent-hub/ui/history-store.ts +137 -0
  81. package/.pi/harnesses/agent-hub/ui/history.ts +234 -0
  82. package/.pi/harnesses/agent-hub/ui/pool.ts +103 -0
  83. package/.pi/harnesses/agent-hub/ui/zoom.ts +204 -0
  84. package/.pi/harnesses/agent-hub/work-mode-controls.ts +56 -0
  85. package/.pi/harnesses/agent-hub/{posture.ts → work-mode.ts} +36 -27
  86. package/.pi/harnesses/coms/index.ts +139 -1630
  87. package/.pi/harnesses/coms/package.json +1 -1
  88. package/.pi/harnesses/damage-control-continue/package.json +1 -1
  89. package/.pi/harnesses/lib/coms-core-io.ts +385 -0
  90. package/.pi/harnesses/lib/coms-core.ts +577 -0
  91. package/.pi/harnesses/lib/context-budget-hub-prompt.ts +3 -5
  92. package/.versions/2.0.0/.pi/agents/dispatch-policy.yaml +32 -0
  93. package/.versions/2.0.0/.pi/agents/model-profiles.yaml +27 -0
  94. package/.versions/2.0.0/.pi/agents/peers.yaml +142 -0
  95. package/.versions/2.0.0/.pi/agents/teams.yaml +41 -0
  96. package/.versions/2.0.0/.pi/damage-control-rules.yaml +297 -0
  97. package/.versions/2.0.0/.pi/extensions/agent-fleet-update-check/README.md +57 -0
  98. package/.versions/2.0.0/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
  99. package/.versions/2.0.0/.pi/extensions/agent-fleet-update-check/package.json +6 -0
  100. package/.versions/2.0.0/.pi/extensions/btw/README.md +120 -0
  101. package/.versions/2.0.0/.pi/extensions/btw/index.ts +914 -0
  102. package/.versions/2.0.0/.pi/extensions/btw/package.json +6 -0
  103. package/.versions/2.0.0/.pi/extensions/btw/state.js +179 -0
  104. package/.versions/2.0.0/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
  105. package/.versions/2.0.0/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
  106. package/.versions/2.0.0/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  107. package/.versions/2.0.0/.pi/extensions/compact-and-continue/README.md +42 -0
  108. package/.versions/2.0.0/.pi/extensions/compact-and-continue/index.ts +120 -0
  109. package/.versions/2.0.0/.pi/extensions/compact-and-continue/package.json +6 -0
  110. package/.versions/2.0.0/.pi/extensions/mcp-bridge/README.md +46 -0
  111. package/.versions/2.0.0/.pi/extensions/mcp-bridge/index.ts +206 -0
  112. package/.versions/2.0.0/.pi/extensions/mcp-bridge/package.json +6 -0
  113. package/.versions/2.0.0/.pi/extensions/package-lock.json +1175 -0
  114. package/.versions/2.0.0/.pi/extensions/package.json +9 -0
  115. package/.versions/2.0.0/.pi/extensions/pi-voice-stt/README.md +205 -0
  116. package/.versions/2.0.0/.pi/extensions/pi-voice-stt/config.ts +198 -0
  117. package/.versions/2.0.0/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  118. package/.versions/2.0.0/.pi/extensions/pi-voice-stt/index.ts +248 -0
  119. package/.versions/2.0.0/.pi/extensions/pi-voice-stt/package.json +6 -0
  120. package/.versions/2.0.0/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  121. package/.versions/2.0.0/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  122. package/.versions/2.0.0/.pi/harnesses/agent-hub/README.md +1161 -0
  123. package/.versions/2.0.0/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  124. package/.versions/2.0.0/.pi/harnesses/agent-hub/artifacts.js +146 -0
  125. package/.versions/2.0.0/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
  126. package/.versions/2.0.0/.pi/harnesses/agent-hub/backend-policy.js +174 -0
  127. package/.versions/2.0.0/.pi/harnesses/agent-hub/budget-continuation.ts +73 -0
  128. package/.versions/2.0.0/.pi/harnesses/agent-hub/capability-confirmation.ts +47 -0
  129. package/.versions/2.0.0/.pi/harnesses/agent-hub/capability-packs.ts +180 -0
  130. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agent-model-thinking.ts +10 -0
  131. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agent-model.ts +10 -0
  132. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agent-models-substitute.ts +10 -0
  133. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-add.ts +9 -0
  134. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-drop.ts +9 -0
  135. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-history.ts +9 -0
  136. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-kill.ts +10 -0
  137. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-list.ts +9 -0
  138. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-restart.ts +10 -0
  139. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-save.ts +9 -0
  140. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-team.ts +9 -0
  141. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/compound.ts +9 -0
  142. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/coms.ts +9 -0
  143. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/context-command.ts +9 -0
  144. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/context.ts +39 -0
  145. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/dispatch-policy.ts +9 -0
  146. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/handoff.ts +10 -0
  147. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/hub-report.ts +9 -0
  148. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/models.ts +10 -0
  149. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/watchdog.ts +9 -0
  150. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/work-mode.ts +29 -0
  151. package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/zoom.ts +10 -0
  152. package/.versions/2.0.0/.pi/harnesses/agent-hub/config/agents.ts +171 -0
  153. package/.versions/2.0.0/.pi/harnesses/agent-hub/config/overrides.ts +118 -0
  154. package/.versions/2.0.0/.pi/harnesses/agent-hub/context/agent-state.ts +30 -0
  155. package/.versions/2.0.0/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +211 -0
  156. package/.versions/2.0.0/.pi/harnesses/agent-hub/context/budgets.ts +208 -0
  157. package/.versions/2.0.0/.pi/harnesses/agent-hub/context/hub-state.ts +40 -0
  158. package/.versions/2.0.0/.pi/harnesses/agent-hub/context-budget-snapshot.ts +105 -0
  159. package/.versions/2.0.0/.pi/harnesses/agent-hub/context-pressure.ts +191 -0
  160. package/.versions/2.0.0/.pi/harnesses/agent-hub/context-window.js +106 -0
  161. package/.versions/2.0.0/.pi/harnesses/agent-hub/delegate.ts +446 -0
  162. package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-coms.ts +232 -0
  163. package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-core.ts +27 -0
  164. package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-native-complete.ts +135 -0
  165. package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +153 -0
  166. package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +191 -0
  167. package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-native-types.ts +207 -0
  168. package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-native.ts +184 -0
  169. package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-observability.ts +220 -0
  170. package/.versions/2.0.0/.pi/harnesses/agent-hub/docs-lane.js +122 -0
  171. package/.versions/2.0.0/.pi/harnesses/agent-hub/drift-watchdog.js +218 -0
  172. package/.versions/2.0.0/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  173. package/.versions/2.0.0/.pi/harnesses/agent-hub/external-blocker.js +85 -0
  174. package/.versions/2.0.0/.pi/harnesses/agent-hub/fixtures/registration-surface.json +53 -0
  175. package/.versions/2.0.0/.pi/harnesses/agent-hub/footer.ts +30 -0
  176. package/.versions/2.0.0/.pi/harnesses/agent-hub/helpers.ts +266 -0
  177. package/.versions/2.0.0/.pi/harnesses/agent-hub/hub-state-audit.js +59 -0
  178. package/.versions/2.0.0/.pi/harnesses/agent-hub/index.ts +1850 -0
  179. package/.versions/2.0.0/.pi/harnesses/agent-hub/input/completions.ts +76 -0
  180. package/.versions/2.0.0/.pi/harnesses/agent-hub/input/shortcuts.ts +47 -0
  181. package/.versions/2.0.0/.pi/harnesses/agent-hub/lifecycle/context-pressure.ts +123 -0
  182. package/.versions/2.0.0/.pi/harnesses/agent-hub/lifecycle/monitor-session.ts +104 -0
  183. package/.versions/2.0.0/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +139 -0
  184. package/.versions/2.0.0/.pi/harnesses/agent-hub/lifecycle/turn-handlers.ts +95 -0
  185. package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  186. package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
  187. package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
  188. package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  189. package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  190. package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  191. package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  192. package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
  193. package/.versions/2.0.0/.pi/harnesses/agent-hub/package.json +7 -0
  194. package/.versions/2.0.0/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
  195. package/.versions/2.0.0/.pi/harnesses/agent-hub/policy/models.ts +126 -0
  196. package/.versions/2.0.0/.pi/harnesses/agent-hub/policy/roster.ts +79 -0
  197. package/.versions/2.0.0/.pi/harnesses/agent-hub/policy/work-mode.ts +118 -0
  198. package/.versions/2.0.0/.pi/harnesses/agent-hub/presentation.ts +48 -0
  199. package/.versions/2.0.0/.pi/harnesses/agent-hub/prompts/context.ts +46 -0
  200. package/.versions/2.0.0/.pi/harnesses/agent-hub/prompts/fragments.ts +115 -0
  201. package/.versions/2.0.0/.pi/harnesses/agent-hub/prompts/session-start.ts +88 -0
  202. package/.versions/2.0.0/.pi/harnesses/agent-hub/prompts/system-prompt.ts +110 -0
  203. package/.versions/2.0.0/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
  204. package/.versions/2.0.0/.pi/harnesses/agent-hub/research/controls.ts +75 -0
  205. package/.versions/2.0.0/.pi/harnesses/agent-hub/research/runtime.ts +184 -0
  206. package/.versions/2.0.0/.pi/harnesses/agent-hub/research/spawn-run.ts +146 -0
  207. package/.versions/2.0.0/.pi/harnesses/agent-hub/research-retention.js +34 -0
  208. package/.versions/2.0.0/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  209. package/.versions/2.0.0/.pi/harnesses/agent-hub/return-contract.js +293 -0
  210. package/.versions/2.0.0/.pi/harnesses/agent-hub/return-extract.js +75 -0
  211. package/.versions/2.0.0/.pi/harnesses/agent-hub/review-findings.js +102 -0
  212. package/.versions/2.0.0/.pi/harnesses/agent-hub/run-budget.js +537 -0
  213. package/.versions/2.0.0/.pi/harnesses/agent-hub/run-namespace.js +87 -0
  214. package/.versions/2.0.0/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  215. package/.versions/2.0.0/.pi/harnesses/agent-hub/scope-gate.js +103 -0
  216. package/.versions/2.0.0/.pi/harnesses/agent-hub/session-health.js +110 -0
  217. package/.versions/2.0.0/.pi/harnesses/agent-hub/session-start.ts +42 -0
  218. package/.versions/2.0.0/.pi/harnesses/agent-hub/spawn.ts +388 -0
  219. package/.versions/2.0.0/.pi/harnesses/agent-hub/timeline.ts +54 -0
  220. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/action-executors.ts +146 -0
  221. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/coms-tools.ts +139 -0
  222. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/context.ts +132 -0
  223. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +79 -0
  224. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +200 -0
  225. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/execution-orchestration.ts +22 -0
  226. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/fleet-tools.ts +202 -0
  227. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/herdr-executors.ts +82 -0
  228. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/set-task-tier.ts +29 -0
  229. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/spawn-research.ts +62 -0
  230. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/team-adjust.ts +29 -0
  231. package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/verification-contract.ts +77 -0
  232. package/.versions/2.0.0/.pi/harnesses/agent-hub/types.ts +60 -0
  233. package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/context-budget.ts +86 -0
  234. package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/detail-panel.ts +175 -0
  235. package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +130 -0
  236. package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/grid.ts +306 -0
  237. package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/history-store.ts +137 -0
  238. package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/history.ts +234 -0
  239. package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/pool.ts +103 -0
  240. package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/zoom.ts +204 -0
  241. package/.versions/2.0.0/.pi/harnesses/agent-hub/version.ts +42 -0
  242. package/.versions/2.0.0/.pi/harnesses/agent-hub/work-mode-controls.ts +56 -0
  243. package/.versions/2.0.0/.pi/harnesses/agent-hub/work-mode.ts +167 -0
  244. package/.versions/2.0.0/.pi/harnesses/ask-user-remote/README.md +53 -0
  245. package/.versions/2.0.0/.pi/harnesses/ask-user-remote/index.ts +532 -0
  246. package/.versions/2.0.0/.pi/harnesses/ask-user-remote/race-core.js +106 -0
  247. package/.versions/2.0.0/.pi/harnesses/coms/README.md +100 -0
  248. package/.versions/2.0.0/.pi/harnesses/coms/index.ts +276 -0
  249. package/.versions/2.0.0/.pi/harnesses/coms/package.json +7 -0
  250. package/.versions/2.0.0/.pi/harnesses/coms/version.ts +42 -0
  251. package/.versions/2.0.0/.pi/harnesses/damage-control-continue/README.md +124 -0
  252. package/.versions/2.0.0/.pi/harnesses/damage-control-continue/index.ts +536 -0
  253. package/.versions/2.0.0/.pi/harnesses/damage-control-continue/package.json +7 -0
  254. package/.versions/2.0.0/.pi/harnesses/damage-control-continue/version.ts +42 -0
  255. package/.versions/2.0.0/.pi/harnesses/lib/coms-core-io.ts +385 -0
  256. package/.versions/2.0.0/.pi/harnesses/lib/coms-core.ts +577 -0
  257. package/.versions/2.0.0/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
  258. package/.versions/2.0.0/.pi/harnesses/lib/context-budget-child-prompt.ts +179 -0
  259. package/.versions/2.0.0/.pi/harnesses/lib/context-budget-hub-prompt.ts +114 -0
  260. package/.versions/2.0.0/.pi/harnesses/lib/context-budget-view.ts +107 -0
  261. package/.versions/2.0.0/.pi/harnesses/lib/context-budget.ts +114 -0
  262. package/.versions/2.0.0/.pi/harnesses/lib/damage-control-shared.ts +197 -0
  263. package/.versions/2.0.0/.pi/harnesses/lib/fixtures/context-budget-profiles.json +11 -0
  264. package/.versions/2.0.0/.pi/harnesses/lib/fixtures/hub-prompt-operator.legacy.txt +73 -0
  265. package/.versions/2.0.0/.pi/harnesses/lib/fixtures/hub-prompt-orchestrator.legacy.txt +73 -0
  266. package/.versions/2.0.0/.pi/harnesses/lib/fleet-dashboard-ops.ts +155 -0
  267. package/.versions/2.0.0/.pi/harnesses/lib/fleet-dashboard-view.ts +142 -0
  268. package/.versions/2.0.0/.pi/harnesses/lib/fleet-detail-view.ts +247 -0
  269. package/.versions/2.0.0/.pi/harnesses/lib/fleet-overlay.ts +26 -0
  270. package/.versions/2.0.0/.pi/harnesses/lib/fleet-panel.ts +34 -0
  271. package/.versions/2.0.0/.pi/harnesses/lib/fleet-read-model.ts +131 -0
  272. package/.versions/2.0.0/.pi/harnesses/lib/fleet-selection.ts +24 -0
  273. package/.versions/2.0.0/.pi/harnesses/lib/fleet-transcript-store.ts +244 -0
  274. package/.versions/2.0.0/.pi/harnesses/lib/herdr-client.ts +472 -0
  275. package/.versions/2.0.0/.pi/harnesses/lib/herdr-presence.ts +399 -0
  276. package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
  277. package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
  278. package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
  279. package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
  280. package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
  281. package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
  282. package/.versions/2.0.0/.pi/harnesses/lib/spawned-peers.js +190 -0
  283. package/.versions/2.0.0/.pi/harnesses/package-lock.json +2039 -0
  284. package/.versions/2.0.0/.pi/harnesses/package.json +10 -0
  285. package/.versions/2.0.0/.pi/prompts/af-build.md +24 -0
  286. package/.versions/2.0.0/.pi/prompts/af-code-simplify.md +22 -0
  287. package/.versions/2.0.0/.pi/prompts/af-plan.md +17 -0
  288. package/.versions/2.0.0/.pi/prompts/af-review.md +16 -0
  289. package/.versions/2.0.0/.pi/prompts/af-set-hermes-telegram.md +15 -0
  290. package/.versions/2.0.0/.pi/prompts/af-set-hermes-watchdog.md +6 -0
  291. package/.versions/2.0.0/.pi/prompts/af-ship.md +17 -0
  292. package/.versions/2.0.0/.pi/prompts/af-spec.md +15 -0
  293. package/.versions/2.0.0/.pi/prompts/af-test.md +19 -0
  294. package/.versions/2.0.0/.pi/skills/bowser/SKILL.md +145 -0
  295. package/.versions/2.0.0/.version +1 -0
  296. package/.versions/2.0.0/agents/architect.md +25 -0
  297. package/.versions/2.0.0/agents/bowser.md +28 -0
  298. package/.versions/2.0.0/agents/builder.md +56 -0
  299. package/.versions/2.0.0/agents/code-reviewer.md +209 -0
  300. package/.versions/2.0.0/agents/deep-researcher.md +33 -0
  301. package/.versions/2.0.0/agents/documenter.md +19 -0
  302. package/.versions/2.0.0/agents/orchestrator.md +23 -0
  303. package/.versions/2.0.0/agents/plan-reviewer.md +84 -0
  304. package/.versions/2.0.0/agents/planner.md +71 -0
  305. package/.versions/2.0.0/agents/releaser.md +25 -0
  306. package/.versions/2.0.0/agents/researcher.md +29 -0
  307. package/.versions/2.0.0/agents/security-auditor.md +168 -0
  308. package/.versions/2.0.0/agents/test-engineer.md +154 -0
  309. package/.versions/2.0.0/agents/web-debugger.md +44 -0
  310. package/.versions/2.0.0/agents/web-performance-auditor.md +194 -0
  311. package/.versions/2.0.0/bin/catalog/harness-runtime-closure.json +38 -0
  312. package/.versions/2.0.0/codex/CONDUCTOR.md +148 -0
  313. package/.versions/2.0.0/docs/ARCHITECTURE.md +404 -0
  314. package/.versions/2.0.0/docs/agent-fleet-setup.md +468 -0
  315. package/.versions/2.0.0/docs/claude-code-coms-bridge.md +128 -0
  316. package/.versions/2.0.0/docs/codex-remote-conductor.md +170 -0
  317. package/.versions/2.0.0/docs/coms-hermes-bridge.md +189 -0
  318. package/.versions/2.0.0/docs/getting-started.md +98 -0
  319. package/.versions/2.0.0/docs/npm-install.md +292 -0
  320. package/.versions/2.0.0/docs/pi-extensions.md +439 -0
  321. package/.versions/2.0.0/docs/pi-setup.md +74 -0
  322. package/.versions/2.0.0/docs/skill-anatomy.md +150 -0
  323. package/.versions/2.0.0/hermes/README.md +347 -0
  324. package/.versions/2.0.0/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
  325. package/.versions/2.0.0/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
  326. package/.versions/2.0.0/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  327. package/.versions/2.0.0/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  328. package/.versions/2.0.0/hermes/gates/gate-o-capability.md +8 -0
  329. package/.versions/2.0.0/hermes/gates/gate-o-validator-fixtures.json +1 -0
  330. package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
  331. package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
  332. package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
  333. package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
  334. package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
  335. package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
  336. package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
  337. package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
  338. package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
  339. package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
  340. package/.versions/2.0.0/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
  341. package/.versions/2.0.0/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  342. package/.versions/2.0.0/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  343. package/.versions/2.0.0/hermes/skills/hub-conductor/SKILL.md +84 -0
  344. package/.versions/2.0.0/hermes/skills/hub-liaison/SKILL.md +84 -0
  345. package/.versions/2.0.0/hermes/skills/hub-watchdog/SKILL.md +76 -0
  346. package/.versions/2.0.0/hermes/skills/hub-watchdog/manifest.json +1 -0
  347. package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
  348. package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
  349. package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
  350. package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
  351. package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
  352. package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
  353. package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
  354. package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
  355. package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
  356. package/.versions/2.0.0/hermes/watchdog-tests/__init__.py +0 -0
  357. package/.versions/2.0.0/hooks/coms-stop-hook.mjs +84 -0
  358. package/.versions/2.0.0/install-manifest.json +2745 -0
  359. package/.versions/2.0.0/justfile +272 -0
  360. package/.versions/2.0.0/manifest-meta.json +882 -0
  361. package/.versions/2.0.0/references/accessibility-checklist.md +160 -0
  362. package/.versions/2.0.0/references/definition-of-done.md +67 -0
  363. package/.versions/2.0.0/references/fleet-coordination-patterns.md +151 -0
  364. package/.versions/2.0.0/references/observability-checklist.md +91 -0
  365. package/.versions/2.0.0/references/orchestration-patterns.md +370 -0
  366. package/.versions/2.0.0/references/performance-checklist.md +153 -0
  367. package/.versions/2.0.0/references/prompting-patterns.md +380 -0
  368. package/.versions/2.0.0/references/security-checklist.md +179 -0
  369. package/.versions/2.0.0/references/testing-patterns.md +236 -0
  370. package/.versions/2.0.0/scripts/codex-conductor.ts +41 -0
  371. package/.versions/2.0.0/scripts/codex-remote-control.ts +167 -0
  372. package/.versions/2.0.0/scripts/coms-claude-bridge.ts +411 -0
  373. package/.versions/2.0.0/scripts/coms-cli.ts +484 -0
  374. package/.versions/2.0.0/scripts/coms-hermes-bridge.ts +413 -0
  375. package/.versions/2.0.0/scripts/fleet.ts +185 -0
  376. package/.versions/2.0.0/scripts/hermes-monitor-capability-runner.ts +25 -0
  377. package/.versions/2.0.0/scripts/hermes-monitor-scenario.ts +474 -0
  378. package/.versions/2.0.0/scripts/hermes-watchdog-capability-probe.ts +45 -0
  379. package/.versions/2.0.0/scripts/install-hermes-plugin.sh +180 -0
  380. package/.versions/2.0.0/scripts/lib/claude-bridge-core.ts +210 -0
  381. package/.versions/2.0.0/scripts/lib/codex-conductor.ts +88 -0
  382. package/.versions/2.0.0/scripts/lib/codex-remote-control.ts +480 -0
  383. package/.versions/2.0.0/scripts/lib/coms-envelope.ts +582 -0
  384. package/.versions/2.0.0/scripts/lib/fake-herdr-server.ts +88 -0
  385. package/.versions/2.0.0/scripts/lib/fleet-command.ts +270 -0
  386. package/.versions/2.0.0/scripts/lib/herdr-layout.ts +281 -0
  387. package/.versions/2.0.0/scripts/lib/hermes-bridge-core.ts +241 -0
  388. package/.versions/2.0.0/scripts/lib/hermes-monitor-events.ts +1 -0
  389. package/.versions/2.0.0/scripts/lib/hermes-monitor-herdr.ts +2 -0
  390. package/.versions/2.0.0/scripts/lib/hermes-monitor-model.ts +3 -0
  391. package/.versions/2.0.0/scripts/lib/hermes-monitor-registry.ts +2 -0
  392. package/.versions/2.0.0/scripts/lib/hermes-monitor-socket.ts +2 -0
  393. package/.versions/2.0.0/scripts/lib/hermes-monitor-store.ts +2 -0
  394. package/.versions/2.0.0/scripts/lib/monitor-env.ts +146 -0
  395. package/.versions/2.0.0/scripts/lib/peer-launch.ts +318 -0
  396. package/.versions/2.0.0/scripts/lib/persona-banner.ts +62 -0
  397. package/.versions/2.0.0/scripts/lib/spawn-stagger.ts +101 -0
  398. package/.versions/2.0.0/scripts/lib/team-project.ts +213 -0
  399. package/.versions/2.0.0/scripts/lib/team-snapshot.ts +147 -0
  400. package/.versions/2.0.0/scripts/peer-banner.ts +40 -0
  401. package/.versions/2.0.0/scripts/peer-launch.ts +259 -0
  402. package/.versions/2.0.0/scripts/team-snapshot.ts +237 -0
  403. package/.versions/2.0.0/scripts/team-up.ts +406 -0
  404. package/.versions/2.0.0/skills/_internal/grilling.md +59 -0
  405. package/.versions/2.0.0/skills/browser-testing-with-devtools/SKILL.md +351 -0
  406. package/.versions/2.0.0/skills/code-review-and-quality/SKILL.md +381 -0
  407. package/.versions/2.0.0/skills/compound-learning/SKILL.md +137 -0
  408. package/.versions/2.0.0/skills/context-engineering/SKILL.md +291 -0
  409. package/.versions/2.0.0/skills/deprecation-and-migration/SKILL.md +206 -0
  410. package/.versions/2.0.0/skills/designing-agents/SKILL.md +394 -0
  411. package/.versions/2.0.0/skills/designing-agents/pi-harness-authoring.md +222 -0
  412. package/.versions/2.0.0/skills/frontend-ui-engineering/SKILL.md +328 -0
  413. package/.versions/2.0.0/skills/git-workflow-and-versioning/SKILL.md +316 -0
  414. package/.versions/2.0.0/skills/idea-refine/SKILL.md +182 -0
  415. package/.versions/2.0.0/skills/idea-refine/examples.md +238 -0
  416. package/.versions/2.0.0/skills/idea-refine/frameworks.md +99 -0
  417. package/.versions/2.0.0/skills/idea-refine/refinement-criteria.md +113 -0
  418. package/.versions/2.0.0/skills/idea-refine/scripts/idea-refine.sh +15 -0
  419. package/.versions/2.0.0/skills/incremental-implementation/SKILL.md +298 -0
  420. package/.versions/2.0.0/skills/interview-me/SKILL.md +226 -0
  421. package/.versions/2.0.0/skills/orchestration-verification/SKILL.md +181 -0
  422. package/.versions/2.0.0/skills/peer-coms/SKILL.md +90 -0
  423. package/.versions/2.0.0/skills/performance-optimization/SKILL.md +350 -0
  424. package/.versions/2.0.0/skills/planning-and-task-breakdown/SKILL.md +263 -0
  425. package/.versions/2.0.0/skills/security-and-hardening/SKILL.md +461 -0
  426. package/.versions/2.0.0/skills/spec-driven-development/SKILL.md +256 -0
  427. package/.versions/2.0.0/skills/using-agent-skills/SKILL.md +197 -0
  428. package/.versions/2.0.0/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
  429. package/.versions/2.0.0/vendor/agent-skills-upstream/LICENSE +21 -0
  430. package/.versions/2.0.0/vendor/agent-skills-upstream/README.md +11 -0
  431. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
  432. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  433. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  434. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  435. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  436. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
  437. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  438. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  439. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
  440. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  441. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  442. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  443. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  444. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  445. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  446. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  447. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  448. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  449. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  450. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
  451. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
  452. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
  453. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
  454. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
  455. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
  456. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
  457. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
  458. package/.versions/2.0.0/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
  459. package/CHANGELOG.md +33 -0
  460. package/README.md +5 -5
  461. package/agents/orchestrator.md +3 -1
  462. package/bin/lib/overrides.js +2 -0
  463. package/bin/lib/validate-overrides.js +1 -1
  464. package/docs/ARCHITECTURE.md +42 -13
  465. package/docs/MIGRATION-agent-fleet.md +4 -4
  466. package/docs/agent-fleet-setup.md +15 -15
  467. package/docs/npm-install.md +1 -1
  468. package/docs/pi-extensions.md +16 -18
  469. package/install-manifest.json +1 -1
  470. package/justfile +2 -2
  471. package/package.json +3 -2
  472. package/scripts/fleet.ts +10 -10
  473. package/scripts/lib/fleet-command.ts +15 -11
  474. package/scripts/lib/team-project.ts +2 -2
  475. package/scripts/team-up.ts +10 -10
  476. package/.pi/harnesses/agent-hub/execution-profile.ts +0 -69
@@ -0,0 +1,577 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
2
+ import * as fs from "node:fs";
3
+ import * as net from "node:net";
4
+ import * as path from "node:path";
5
+
6
+ import { buildLiveRegistryEntry } from "./coms-registry-entry.ts";
7
+ import {
8
+ HerdrAgentWatch,
9
+ HerdrPresence,
10
+ herdrPaneId,
11
+ herdrPresenceAvailable,
12
+ peerNameFrom,
13
+ type HerdrAgentInfo,
14
+ } from "./herdr-presence.ts";
15
+ import {
16
+ COMS_DIR,
17
+ KEEPALIVE_INTERVAL_MS,
18
+ LINE_CAP_BYTES,
19
+ MAX_HOPS,
20
+ PING_INTERVAL_MS,
21
+ TIMEOUT_MS,
22
+ bindEndpoint,
23
+ fallbackColor,
24
+ isValidHex,
25
+ listProjects,
26
+ makeEndpoint,
27
+ nowIso,
28
+ projectAgentsDir,
29
+ pruneDeadEntries,
30
+ pruneDeadEntriesAllProjects,
31
+ readCliFlags,
32
+ readFrontmatterFromArgv,
33
+ removeRegistryEntry,
34
+ resolveUniqueName,
35
+ sendEnvelope,
36
+ ulid,
37
+ writeRegistryAtomic,
38
+ type AgentCard,
39
+ type ComsIdentity,
40
+ type InboundContext,
41
+ type PendingReply,
42
+ type PeerStatus,
43
+ type PingEnvelope,
44
+ type Pong,
45
+ type PromptEnvelope,
46
+ type RegistryEntry,
47
+ type ResponseEnvelope,
48
+ } from "./coms-core-io.ts";
49
+
50
+ export * from "./coms-core-io.ts";
51
+
52
+ export interface ComsListParams {
53
+ project?: string;
54
+ include_explicit?: boolean;
55
+ }
56
+
57
+ export interface ComsSendParams {
58
+ target: string;
59
+ prompt: string;
60
+ conversation_id?: string | null;
61
+ response_schema?: object | null;
62
+ reply_timeout_ms?: number | null;
63
+ }
64
+
65
+ export interface ComsSendResult {
66
+ msg_id: string;
67
+ target: string;
68
+ target_session: string;
69
+ hops: number;
70
+ promise: PendingReply["promise"];
71
+ }
72
+
73
+ export interface ComsListResult {
74
+ agents: Array<{
75
+ name: string;
76
+ session_id: string;
77
+ purpose: string;
78
+ model: string;
79
+ cwd: string;
80
+ project: string;
81
+ alive: boolean;
82
+ context_used_pct: number | null;
83
+ pane_id: string | null;
84
+ status: PeerStatus | null;
85
+ queue_depth: number | null;
86
+ color: string;
87
+ }>;
88
+ project: string;
89
+ scoped: true;
90
+ widenRequested: boolean;
91
+ }
92
+
93
+ export interface CreateComsPeerDeps {
94
+ pi: ExtensionAPI;
95
+ getContext: () => ExtensionContext | null;
96
+ onPeersChanged?: () => void;
97
+ acceptInbound?: () => string | null;
98
+ handleCustomEnvelope?: (socket: net.Socket, envelope: any) => boolean;
99
+ }
100
+
101
+ export interface ConnectComsOptions {
102
+ ctx: ExtensionContext;
103
+ defaultNamePrefix: string;
104
+ defaultPurpose: string;
105
+ }
106
+
107
+ export type ComsConnectStage = "dirs" | "bind" | "registry";
108
+
109
+ export class ComsConnectError extends Error {
110
+ readonly stage: ComsConnectStage;
111
+
112
+ constructor(stage: ComsConnectStage, cause: unknown) {
113
+ super(cause instanceof Error ? cause.message : String(cause), { cause });
114
+ this.name = "ComsConnectError";
115
+ this.stage = stage;
116
+ }
117
+ }
118
+
119
+ export function createComsPeer(deps: CreateComsPeerDeps) {
120
+ const { pi } = deps;
121
+ const peerCards = new Map<string, AgentCard & { staleCount: number }>();
122
+ const pendingReplies = new Map<string, PendingReply>();
123
+ const inboundQueue = new Map<string, InboundContext>();
124
+ const scope = { includeExplicit: false, displayProject: null as string | null };
125
+ let identity: ComsIdentity | null = null;
126
+ let currentInbound: InboundContext | null = null;
127
+ let server: net.Server | null = null;
128
+ let pingTimer: NodeJS.Timeout | null = null;
129
+ let keepaliveTimer: NodeJS.Timeout | null = null;
130
+ let herdrPresence: HerdrPresence | null = null;
131
+ let herdrWatch: HerdrAgentWatch | null = null;
132
+ let turnState: "idle" | "working" = "idle";
133
+ let shuttingDown = false;
134
+
135
+ const changed = () => deps.onPeersChanged?.();
136
+ const audit = (entry: Record<string, unknown>) => {
137
+ try { pi.appendEntry("coms-log", entry); } catch { /* best effort */ }
138
+ };
139
+ const ack = (socket: net.Socket, msgId: string) => {
140
+ try { socket.write(`${JSON.stringify({ type: "ack", msg_id: msgId })}\n`); } catch { /* ignore */ }
141
+ try { socket.end(); } catch { /* ignore */ }
142
+ };
143
+ const nack = (socket: net.Socket, msgId: string, error: string) => {
144
+ try { socket.write(`${JSON.stringify({ type: "nack", msg_id: msgId, error })}\n`); } catch { /* ignore */ }
145
+ try { socket.end(); } catch { /* ignore */ }
146
+ };
147
+
148
+ function peersInScope(): RegistryEntry[] {
149
+ if (!identity) return [];
150
+ const filter = scope.displayProject ?? identity.project;
151
+ const entries = filter === "*" ? pruneDeadEntriesAllProjects() : pruneDeadEntries(filter);
152
+ return entries.filter(entry => entry.session_id !== identity!.session_id && (scope.includeExplicit || !entry.explicit));
153
+ }
154
+
155
+ function resolveTarget(target: string): RegistryEntry | null {
156
+ const entries = peersInScope();
157
+ return entries.find(entry => entry.name === target) ?? entries.find(entry => entry.session_id === target) ?? null;
158
+ }
159
+
160
+ function herdrSyncPeerCards(agents: HerdrAgentInfo[]): void {
161
+ if (!identity) return;
162
+ const liveNames = new Set(agents.map(peerNameFrom).filter((name): name is string => !!name));
163
+ const liveSessions = new Set<string>();
164
+ let didChange = false;
165
+ for (const entry of peersInScope()) {
166
+ if (!liveNames.has(entry.name)) continue;
167
+ liveSessions.add(entry.session_id);
168
+ const next = {
169
+ name: entry.name, purpose: entry.purpose, model: entry.model, color: entry.color,
170
+ context_used_pct: entry.context_used_pct ?? 0, queue_depth: entry.queue_depth ?? 0, staleCount: 0,
171
+ };
172
+ const previous = peerCards.get(entry.session_id);
173
+ if (!previous || JSON.stringify(previous) !== JSON.stringify(next)) {
174
+ peerCards.set(entry.session_id, next);
175
+ didChange = true;
176
+ }
177
+ }
178
+ for (const sessionId of [...peerCards.keys()]) {
179
+ if (sessionId !== identity.session_id && !liveSessions.has(sessionId)) {
180
+ peerCards.delete(sessionId);
181
+ didChange = true;
182
+ }
183
+ }
184
+ if (didChange) changed();
185
+ }
186
+
187
+ function handlePrompt(socket: net.Socket, envelope: PromptEnvelope): void {
188
+ const refusal = deps.acceptInbound?.();
189
+ if (refusal) { nack(socket, envelope.msg_id, refusal); return; }
190
+ if (typeof envelope.hops !== "number" || envelope.hops >= MAX_HOPS) {
191
+ nack(socket, envelope.msg_id, "hops exceeded");
192
+ return;
193
+ }
194
+ const inbound: InboundContext = {
195
+ msg_id: envelope.msg_id,
196
+ hops: envelope.hops,
197
+ sender_endpoint: envelope.sender_endpoint,
198
+ sender_session: envelope.sender_session,
199
+ response_schema: envelope.response_schema ?? null,
200
+ fulfilled: false,
201
+ };
202
+ inboundQueue.set(envelope.msg_id, inbound);
203
+ currentInbound = inbound;
204
+ try {
205
+ pi.sendMessage({
206
+ customType: "coms-inbound",
207
+ content: `[from ${envelope.sender_name} @ ${envelope.sender_cwd}]\n\n${envelope.prompt}`,
208
+ display: true,
209
+ details: { msg_id: envelope.msg_id, sender_session: envelope.sender_session, response_schema: envelope.response_schema ?? null },
210
+ }, { deliverAs: "followUp", triggerTurn: true });
211
+ } catch {
212
+ inboundQueue.delete(envelope.msg_id);
213
+ currentInbound = null;
214
+ nack(socket, envelope.msg_id, "internal error");
215
+ return;
216
+ }
217
+ ack(socket, envelope.msg_id);
218
+ audit({ event: "inbound_prompt", msg_id: envelope.msg_id, sender: envelope.sender_session, hops: envelope.hops });
219
+ }
220
+
221
+ function handleResponse(socket: net.Socket, envelope: ResponseEnvelope): void {
222
+ const pending = pendingReplies.get(envelope.msg_id);
223
+ if (pending) {
224
+ if (pending.timer) { try { clearTimeout(pending.timer); } catch { /* ignore */ } pending.timer = null; }
225
+ pending.result = { response: envelope.response, error: envelope.error ?? null };
226
+ try { pending.resolve(pending.result); } catch { /* ignore */ }
227
+ } else {
228
+ audit({ event: "orphan_response", msg_id: envelope.msg_id });
229
+ }
230
+ ack(socket, envelope.msg_id);
231
+ }
232
+
233
+ function handlePing(socket: net.Socket, envelope: PingEnvelope): void {
234
+ const ctx = deps.getContext();
235
+ const card: AgentCard = {
236
+ name: identity?.name ?? "unknown",
237
+ purpose: identity?.purpose ?? "",
238
+ model: ctx?.model?.id ?? identity?.model ?? "unknown",
239
+ color: identity?.color ?? "#36F9F6",
240
+ context_used_pct: Math.round(ctx?.getContextUsage()?.percent ?? 0),
241
+ queue_depth: inboundQueue.size,
242
+ pane_id: herdrPaneId() ?? null,
243
+ status: turnState === "working" || inboundQueue.size > 0 ? "working" : "idle",
244
+ };
245
+ try { socket.write(`${JSON.stringify({ type: "pong", msg_id: envelope.msg_id, agent_card: card })}\n`); } catch { /* ignore */ }
246
+ try { socket.end(); } catch { /* ignore */ }
247
+ }
248
+
249
+ function connectionHandler(socket: net.Socket): void {
250
+ let buffer = "";
251
+ let handled = false;
252
+ const onData = (chunk: Buffer) => {
253
+ if (handled) return;
254
+ buffer += chunk.toString("utf8");
255
+ if (buffer.length > LINE_CAP_BYTES) {
256
+ handled = true;
257
+ socket.removeListener("data", onData);
258
+ nack(socket, "", "malformed envelope");
259
+ return;
260
+ }
261
+ const newline = buffer.indexOf("\n");
262
+ if (newline < 0) return;
263
+ handled = true;
264
+ socket.removeListener("data", onData);
265
+ let parsed: any;
266
+ try { parsed = JSON.parse(buffer.slice(0, newline)); } catch { nack(socket, "", "malformed envelope"); return; }
267
+ if (!parsed || typeof parsed !== "object" || typeof parsed.type !== "string" || typeof parsed.msg_id !== "string" || typeof parsed.sender_session !== "string" || typeof parsed.sender_endpoint !== "string") {
268
+ nack(socket, typeof parsed?.msg_id === "string" ? parsed.msg_id : "", "malformed envelope");
269
+ return;
270
+ }
271
+ try {
272
+ if (parsed.type === "prompt") handlePrompt(socket, parsed);
273
+ else if (parsed.type === "response") handleResponse(socket, parsed);
274
+ else if (parsed.type === "ping") handlePing(socket, parsed);
275
+ else if (!deps.handleCustomEnvelope?.(socket, parsed)) nack(socket, parsed.msg_id, "unknown type");
276
+ } catch {
277
+ nack(socket, parsed.msg_id, "internal error");
278
+ }
279
+ };
280
+ socket.on("data", onData);
281
+ socket.once("error", () => { try { socket.destroy(); } catch { /* ignore */ } });
282
+ }
283
+
284
+ function writeLiveRegistry(): void {
285
+ if (!identity) return;
286
+ const ctx = deps.getContext();
287
+ try {
288
+ writeRegistryAtomic(buildLiveRegistryEntry(identity, {
289
+ now: nowIso(), pid: process.pid, model: ctx?.model?.id,
290
+ contextUsedPct: ctx?.getContextUsage()?.percent, queueDepth: inboundQueue.size,
291
+ }), identity.project);
292
+ } catch { /* best effort */ }
293
+ }
294
+
295
+ async function refresh(): Promise<void> {
296
+ if (!identity) return;
297
+ const peers = peersInScope();
298
+ const results = await Promise.allSettled(peers.map(async entry => {
299
+ const pong = await sendEnvelope(entry.endpoint, {
300
+ type: "ping", msg_id: ulid(), sender_session: identity!.session_id,
301
+ sender_endpoint: identity!.endpoint, hops: 0, timestamp: nowIso(),
302
+ } as PingEnvelope);
303
+ return { entry, pong: pong as Pong };
304
+ }));
305
+ const seen = new Set<string>();
306
+ let didChange = false;
307
+ for (const result of results) {
308
+ if (result.status !== "fulfilled" || !result.value.pong?.agent_card) continue;
309
+ seen.add(result.value.entry.session_id);
310
+ const next = { ...result.value.pong.agent_card, staleCount: 0 };
311
+ const previous = peerCards.get(result.value.entry.session_id);
312
+ if (!previous || JSON.stringify({ ...previous, staleCount: 0 }) !== JSON.stringify(next)) {
313
+ peerCards.set(result.value.entry.session_id, next);
314
+ didChange = true;
315
+ }
316
+ }
317
+ for (const [sessionId, card] of peerCards) {
318
+ if (sessionId === identity.session_id || seen.has(sessionId)) continue;
319
+ card.staleCount = (card.staleCount ?? 0) + 1;
320
+ if (card.staleCount > 6) peerCards.delete(sessionId);
321
+ didChange = true;
322
+ }
323
+ if (didChange) changed();
324
+ }
325
+
326
+ async function ping(endpoint: string): Promise<AgentCard | null> {
327
+ if (!identity) return null;
328
+ try {
329
+ const response = await sendEnvelope(endpoint, {
330
+ type: "ping", msg_id: ulid(), sender_session: identity.session_id,
331
+ sender_endpoint: identity.endpoint, hops: 0, timestamp: nowIso(),
332
+ } as PingEnvelope);
333
+ return response?.type === "pong" && response.agent_card ? response.agent_card : null;
334
+ } catch { return null; }
335
+ }
336
+
337
+ async function connect(options: ConnectComsOptions): Promise<ComsIdentity> {
338
+ if (identity) return identity;
339
+ shuttingDown = false;
340
+ const flags = readCliFlags(pi);
341
+ const frontmatter = readFrontmatterFromArgv(process.argv);
342
+ const project = flags.project || "default";
343
+ const sessionId = ulid();
344
+ const sessionName = typeof pi.getSessionName === "function" ? pi.getSessionName() || undefined : undefined;
345
+ const desiredName = flags.name || sessionName || frontmatter.name || `${options.defaultNamePrefix}-${sessionId.slice(-6)}`;
346
+ const name = resolveUniqueName(project, desiredName);
347
+ if (name !== desiredName) audit({ event: "name_collision", desired: desiredName, assigned: name, project });
348
+ let color = fallbackColor(sessionId);
349
+ if (frontmatter.color && isValidHex(frontmatter.color)) color = frontmatter.color;
350
+ if (flags.color && isValidHex(flags.color)) color = flags.color;
351
+ const endpoint = makeEndpoint(sessionId);
352
+ const cwd = options.ctx.cwd || process.cwd();
353
+ const model = options.ctx.model?.id ?? "unknown";
354
+ const purpose = flags.purpose || frontmatter.description || options.defaultPurpose;
355
+ try {
356
+ fs.mkdirSync(projectAgentsDir(project), { recursive: true });
357
+ if (process.platform !== "win32") {
358
+ fs.mkdirSync(path.join(COMS_DIR, "sockets"), { recursive: true });
359
+ try { fs.chmodSync(COMS_DIR, 0o700); } catch { /* best effort */ }
360
+ }
361
+ } catch (error) {
362
+ throw new ComsConnectError("dirs", error);
363
+ }
364
+ try { server = await bindEndpoint(endpoint, connectionHandler); }
365
+ catch (error) { throw new ComsConnectError("bind", error); }
366
+ const startedAt = nowIso();
367
+ const entry: RegistryEntry = {
368
+ session_id: sessionId, name, purpose, model, color, pid: process.pid,
369
+ endpoint, cwd, started_at: startedAt, explicit: flags.explicit === true, version: 1,
370
+ };
371
+ let registryFile: string;
372
+ try { registryFile = writeRegistryAtomic(entry, project); }
373
+ catch (error) {
374
+ try { server.close(); } catch { /* ignore */ }
375
+ server = null;
376
+ throw new ComsConnectError("registry", error);
377
+ }
378
+ identity = {
379
+ session_id: sessionId, name, purpose, color, project, explicit: flags.explicit === true,
380
+ cwd, model, endpoint, registryFile, started_at: startedAt,
381
+ };
382
+ scope.includeExplicit = false;
383
+ scope.displayProject = project;
384
+ audit({ event: "boot", session_id: sessionId, name, project });
385
+
386
+ const useHerdr = await herdrPresenceAvailable();
387
+ if (useHerdr) {
388
+ const paneId = herdrPaneId()!;
389
+ herdrPresence = new HerdrPresence({
390
+ paneId,
391
+ source: `coms:${sessionId}`,
392
+ onError: (error, dialect) => audit({ event: "presence_dialect_rejected", dialect, reason: error?.message ?? String(error) }),
393
+ });
394
+ void herdrPresence.report("idle", { name, project, contextUsedPct: 0, queueDepth: 0 });
395
+ herdrWatch = new HerdrAgentWatch({ ownPaneId: paneId, onChange: herdrSyncPeerCards });
396
+ void herdrWatch.start();
397
+ audit({ event: "presence_backend", backend: "herdr", pane: paneId });
398
+ } else {
399
+ pingTimer = setInterval(() => { void refresh(); }, PING_INTERVAL_MS);
400
+ try { (pingTimer as any).unref?.(); } catch { /* ignore */ }
401
+ }
402
+ keepaliveTimer = setInterval(() => {
403
+ if (!identity) return;
404
+ const missing = !fs.existsSync(identity.registryFile);
405
+ writeLiveRegistry();
406
+ if (missing) {
407
+ audit({ event: "self_heal", session_id: identity.session_id, reason: "registry file missing" });
408
+ if (!fs.existsSync(identity.registryFile)) writeLiveRegistry();
409
+ }
410
+ if (herdrPresence) {
411
+ void herdrPresence.report(turnState, {
412
+ name: identity.name, project: identity.project,
413
+ contextUsedPct: Math.round(deps.getContext()?.getContextUsage()?.percent ?? 0), queueDepth: inboundQueue.size,
414
+ });
415
+ }
416
+ if (herdrWatch) herdrSyncPeerCards(herdrWatch.current());
417
+ }, KEEPALIVE_INTERVAL_MS);
418
+ try { (keepaliveTimer as any).unref?.(); } catch { /* ignore */ }
419
+ if (!useHerdr) void refresh();
420
+ return identity;
421
+ }
422
+
423
+ async function list(params: ComsListParams = {}): Promise<ComsListResult> {
424
+ if (!identity) return { agents: [], project: "default", scoped: true, widenRequested: false };
425
+ const scopeProject = scope.displayProject ?? identity.project;
426
+ let widened = false;
427
+ let projects: string[];
428
+ if (scopeProject === "*") projects = params.project && params.project !== "*" ? [params.project] : listProjects();
429
+ else {
430
+ projects = [scopeProject];
431
+ if (params.project && params.project !== scopeProject) widened = true;
432
+ }
433
+ const includeExplicit = scope.includeExplicit && params.include_explicit !== false;
434
+ if (params.include_explicit === true && !scope.includeExplicit) widened = true;
435
+ const collected: Array<{ entry: RegistryEntry; project: string }> = [];
436
+ for (const project of projects) {
437
+ for (const entry of pruneDeadEntries(project)) {
438
+ if (entry.explicit && !includeExplicit) continue;
439
+ if (entry.session_id !== identity.session_id) collected.push({ entry, project });
440
+ }
441
+ }
442
+ const pongs = await Promise.allSettled(collected.map(item => ping(item.entry.endpoint)));
443
+ const agents = collected.map((item, index) => {
444
+ const result = pongs[index];
445
+ const pong = result.status === "fulfilled" ? result.value : null;
446
+ return {
447
+ name: item.entry.name, session_id: item.entry.session_id, purpose: item.entry.purpose,
448
+ model: item.entry.model, cwd: item.entry.cwd, project: item.project, alive: pong !== null,
449
+ context_used_pct: pong?.context_used_pct ?? null, pane_id: pong?.pane_id ?? null,
450
+ status: pong?.status ?? null, queue_depth: pong?.queue_depth ?? null, color: item.entry.color,
451
+ };
452
+ });
453
+ return { agents, project: scopeProject, scoped: true, widenRequested: widened };
454
+ }
455
+
456
+ async function send(params: ComsSendParams, auditExtra: Record<string, unknown> = {}): Promise<ComsSendResult> {
457
+ if (!identity) throw new Error("coms not initialised");
458
+ const target = resolveTarget(params.target);
459
+ if (!target) {
460
+ const project = scope.displayProject ?? identity.project;
461
+ throw new Error(`coms: no connected peer "${params.target}" in your pool (project ${project}). Only peers shown in the coms pool are reachable. If you expected this peer, ask the human to widen scope with /af-coms --project <name> or /af-coms --all, then retry.`);
462
+ }
463
+ const hops = currentInbound ? currentInbound.hops + 1 : 0;
464
+ if (hops >= MAX_HOPS) throw new Error(`coms: hop limit reached (${hops} >= ${MAX_HOPS})`);
465
+ const msgId = ulid();
466
+ await sendEnvelope(target.endpoint, {
467
+ type: "prompt", msg_id: msgId, sender_session: identity.session_id, sender_endpoint: identity.endpoint,
468
+ sender_name: identity.name, sender_cwd: identity.cwd, hops, timestamp: nowIso(), prompt: params.prompt,
469
+ conversation_id: params.conversation_id ?? null, response_schema: params.response_schema ?? null,
470
+ reply_timeout_ms: params.reply_timeout_ms ?? null,
471
+ } as PromptEnvelope);
472
+ let resolve!: PendingReply["resolve"];
473
+ let reject!: PendingReply["reject"];
474
+ const promise = new Promise<{ response?: any; error?: string | null }>((res, rej) => { resolve = res; reject = rej; });
475
+ pendingReplies.set(msgId, { resolve, reject, timer: null, promise, target_name: target.name, created_at: nowIso() });
476
+ audit({ event: "outbound_prompt", msg_id: msgId, target: target.name, hops, ...auditExtra });
477
+ return { msg_id: msgId, target: target.name, target_session: target.session_id, hops, promise };
478
+ }
479
+
480
+ function get(msgId: string): { status: "pending" | "complete" | "error"; response?: any; error?: string | null } {
481
+ const entry = pendingReplies.get(msgId);
482
+ if (!entry) return { status: "error", error: "unknown msg_id" };
483
+ if (!entry.result) return { status: "pending" };
484
+ return { status: "complete", response: entry.result.response, error: entry.result.error ?? null };
485
+ }
486
+
487
+ async function awaitReply(msgId: string, timeoutMs = TIMEOUT_MS): Promise<{ status: "pending" | "complete" | "error"; response?: any; error?: string | null }> {
488
+ const entry = pendingReplies.get(msgId);
489
+ if (!entry) return { status: "error", error: "unknown msg_id" };
490
+ const timeout = new Promise<{ error: "timeout" }>(resolve => {
491
+ const timer = setTimeout(() => resolve({ error: "timeout" }), timeoutMs);
492
+ try { (timer as any).unref?.(); } catch { /* ignore */ }
493
+ });
494
+ const result = await Promise.race([entry.promise, timeout]);
495
+ if (result.error === "timeout") return { status: "pending" };
496
+ if (result.error) return { status: "error", error: result.error };
497
+ return { status: "complete", response: result.response };
498
+ }
499
+
500
+ async function respond(ctx: ExtensionContext): Promise<void> {
501
+ const inbound = [...inboundQueue.values()].reverse().find(item => !item.fulfilled);
502
+ if (!inbound || !identity) return;
503
+ let text = "";
504
+ for (const entry of ctx.sessionManager.getBranch()) {
505
+ if (entry.type !== "message" || entry.message.role !== "assistant") continue;
506
+ const message = entry.message as any;
507
+ text = typeof message.content === "string"
508
+ ? message.content
509
+ : Array.isArray(message.content) ? message.content.filter((block: any) => block?.type === "text").map((block: any) => block.text).join("\n") : text;
510
+ }
511
+ let response: any = text;
512
+ let error: string | null = null;
513
+ if (inbound.response_schema && typeof inbound.response_schema === "object") {
514
+ try { response = JSON.parse(text); } catch { response = null; error = "response not valid JSON"; }
515
+ }
516
+ try {
517
+ await sendEnvelope(inbound.sender_endpoint, {
518
+ type: "response", msg_id: inbound.msg_id, sender_session: identity.session_id,
519
+ sender_endpoint: identity.endpoint, hops: 0, timestamp: nowIso(), response, error,
520
+ } as ResponseEnvelope);
521
+ audit({ event: "outbound_response", msg_id: inbound.msg_id, error });
522
+ } catch (sendError: any) {
523
+ audit({ event: "outbound_response_failed", msg_id: inbound.msg_id, reason: sendError?.message ?? String(sendError) });
524
+ }
525
+ inbound.fulfilled = true;
526
+ inboundQueue.delete(inbound.msg_id);
527
+ if (currentInbound?.msg_id === inbound.msg_id) currentInbound = null;
528
+ }
529
+
530
+ async function setTurnState(state: "idle" | "working"): Promise<void> {
531
+ turnState = state;
532
+ if (!herdrPresence || !identity) return;
533
+ void herdrPresence.report(state, {
534
+ name: identity.name, project: identity.project,
535
+ contextUsedPct: Math.round(deps.getContext()?.getContextUsage()?.percent ?? 0), queueDepth: inboundQueue.size,
536
+ });
537
+ }
538
+
539
+ async function updateScope(args: string, ctx?: ExtensionContext): Promise<void> {
540
+ if (args.includes("--all")) {
541
+ scope.includeExplicit = !scope.includeExplicit;
542
+ try { ctx?.ui.notify(`coms: include_explicit = ${scope.includeExplicit}`, "info"); } catch { /* ignore */ }
543
+ }
544
+ const projectMatch = args.match(/--project\s+(\S+)/);
545
+ if (projectMatch) {
546
+ scope.displayProject = projectMatch[1];
547
+ try { ctx?.ui.notify(`coms: displaying project ${scope.displayProject}`, "info"); } catch { /* ignore */ }
548
+ }
549
+ if (herdrWatch) await herdrWatch.start();
550
+ else await refresh();
551
+ }
552
+
553
+ async function shutdown(): Promise<void> {
554
+ if (shuttingDown) return;
555
+ shuttingDown = true;
556
+ if (pingTimer) { try { clearInterval(pingTimer); } catch { /* ignore */ } pingTimer = null; }
557
+ if (keepaliveTimer) { try { clearInterval(keepaliveTimer); } catch { /* ignore */ } keepaliveTimer = null; }
558
+ if (herdrWatch) { try { herdrWatch.stop(); } catch { /* ignore */ } herdrWatch = null; }
559
+ if (herdrPresence) { try { void herdrPresence.release(); } catch { /* ignore */ } herdrPresence = null; }
560
+ if (server) { try { server.close(); } catch { /* ignore */ } server = null; }
561
+ if (identity) {
562
+ if (process.platform !== "win32") { try { fs.unlinkSync(identity.endpoint); } catch { /* ignore */ } }
563
+ removeRegistryEntry(identity.project, identity.name);
564
+ audit({ event: "shutdown", session_id: identity.session_id });
565
+ }
566
+ }
567
+
568
+ return {
569
+ connect, send, list, get, await: awaitReply, refresh, respond, shutdown,
570
+ setTurnState, updateScope, writeLiveRegistry, ping, peersInScope, resolveTarget,
571
+ peerCards, pendingReplies, inboundQueue, scope,
572
+ get identity() { return identity; },
573
+ get ready() { return identity !== null && server !== null; },
574
+ };
575
+ }
576
+
577
+ export type ComsPeer = ReturnType<typeof createComsPeer>;
@@ -24,7 +24,6 @@ export interface HubPromptParts {
24
24
  researchCatalog: string;
25
25
  /** Changes per turn: tier, budgets, active counters, and pending state only. */
26
26
  stateCapsule?: string;
27
- dispatcherPersonaPrompt?: string;
28
27
  }
29
28
 
30
29
  export const HUB_HERDR_SECTION = `
@@ -77,7 +76,7 @@ ${parts.comsSection}${parts.herdrSection}${parts.compactionSection ?? ""}
77
76
  ${parts.hardRules}
78
77
  ${parts.ambiguityRule}
79
78
  - Keep each dispatch focused and use the returned evidence before reporting completion.`;
80
- return parts.dispatcherPersonaPrompt ? `${parts.dispatcherPersonaPrompt}\n\n${policy}` : policy;
79
+ return policy;
81
80
  }
82
81
 
83
82
  export interface NamedHubPart { id: string; text: string; category: ContextCategory; persistence?: ContextBudgetComponent["persistence"]; source?: string; }
@@ -85,10 +84,10 @@ export interface NamedHubPart { id: string; text: string; category: ContextCateg
85
84
  export function namedHubLedgerParts(input: {
86
85
  intro: string; languageLines: string; teamMembers: string; agentCards: readonly { id: string; text: string }[];
87
86
  dispatchSection: string; modeSection: string; verificationSection: string; researchCards: readonly { id: string; text: string }[];
88
- researchCatalog: string; comsSection: string; herdrSection: string; compactionSection?: string; stateCapsule?: string; dispatcherPersonaPrompt?: string;
87
+ researchCatalog: string; comsSection: string; herdrSection: string; compactionSection?: string; stateCapsule?: string;
89
88
  }): NamedHubPart[] {
90
89
  return [
91
- { id: "hub/policy/posture", text: input.intro, category: "system", persistence: "fixed", source: "posture.ts" },
90
+ { id: "hub/policy/work-mode", text: input.intro, category: "system", persistence: "fixed", source: "work-mode.ts" },
92
91
  { id: "hub/policy/language", text: input.languageLines, category: "protocol", persistence: "fixed", source: "hub-policy" },
93
92
  { id: "hub/roster-header", text: input.teamMembers, category: "roster", persistence: "session", source: "active-roster" },
94
93
  ...input.agentCards.map(card => ({ id: `hub/roster/${card.id}`, text: card.text, category: "roster" as const, persistence: "session" as const, source: "agent-persona" })),
@@ -100,7 +99,6 @@ export function namedHubLedgerParts(input: {
100
99
  { id: "hub/policy/coms", text: input.comsSection, category: "protocol", persistence: "fixed", source: "coms" },
101
100
  { id: "hub/policy/workspace", text: input.herdrSection, category: "protocol", persistence: "fixed", source: "herdr" },
102
101
  { id: "hub/policy/compaction", text: input.compactionSection ?? "", category: "protocol", persistence: "fixed", source: "compaction" },
103
- { id: "hub/persona", text: input.dispatcherPersonaPrompt ?? "", category: "persona", persistence: "session", source: "dispatcher-persona" },
104
102
  ];
105
103
  }
106
104
 
@@ -0,0 +1,32 @@
1
+ # Backend routing for the agent-hub dispatcher (dispatch_agent). Decided at
2
+ # DISPATCH time, never at team activation — the hub and its peers boot in
3
+ # parallel (`just fleet team <team>`), so a member's coms peer may register
4
+ # after the session starts.
5
+ #
6
+ # default: native | coms — coms substitutes ANY active-team member that has
7
+ # a live same-name peer in the coms pool
8
+ # grace_s: <seconds> — how long a `fallback: none` member polls the pool
9
+ # for its peer before the dispatch is refused
10
+ # substitutions:
11
+ # <member>: — team-member/persona name (case-insensitive)
12
+ # prefer: native|coms — bare member block defaults to coms
13
+ # fallback: native|none — none = coms-required (refuse when no live peer)
14
+ # timeout_s: <seconds> — per-member reply timeout (default PI_COMS_TIMEOUT_MS)
15
+ #
16
+ # Missing file = everything native (no behavior change). This file is an
17
+ # orchestration decision; HOW each peer runs (model, runner: claude-code, env)
18
+ # stays in peers.yaml.
19
+
20
+ default: native
21
+ grace_s: 30
22
+
23
+ substitutions:
24
+ plan-reviewer:
25
+ prefer: coms
26
+ fallback: native
27
+ code-reviewer:
28
+ prefer: coms
29
+ fallback: native
30
+ documenter:
31
+ prefer: coms
32
+ fallback: native
@@ -0,0 +1,27 @@
1
+ # Named model profiles for /models — each entry must be one of the persona's
2
+ # declared candidates (frontmatter `model:` + `models:` list). A profile with
3
+ # any invalid entry is dropped whole at session start, with an error notify.
4
+ #
5
+ # Profiles only switch the personas they list; everyone else keeps their
6
+ # current model. They never touch delegate-children (`subagents:`) models.
7
+ mix-max:
8
+ code-reviewer: github-copilot/claude-opus-5
9
+ builder: openai-codex/gpt-5.6-sol
10
+ planner: github-copilot/claude-fable-5
11
+ plan-reviewer: openai-codex/gpt-5.6-sol
12
+ security-auditor: xai/grok-4.6
13
+ test-engineer: xai/grok-4.6
14
+ sol:
15
+ code-reviewer: openai-codex/gpt-5.6-sol
16
+ builder: openai-codex/gpt-5.6-sol
17
+ planner: openai-codex/gpt-5.6-sol
18
+ plan-reviewer: openai-codex/gpt-5.6-sol
19
+ security-auditor: openai-codex/gpt-5.6-sol
20
+ test-engineer: openai-codex/gpt-5.6-sol
21
+ terra:
22
+ code-reviewer: openai-codex/gpt-5.6-terra
23
+ builder: openai-codex/gpt-5.6-terra
24
+ planner: openai-codex/gpt-5.6-terra
25
+ plan-reviewer: openai-codex/gpt-5.6-terra
26
+ security-auditor: openai-codex/gpt-5.6-terra
27
+ test-engineer: openai-codex/gpt-5.6-terra