@chankov/agent-fleet 0.0.8 → 0.0.10

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 (682) hide show
  1. package/.claude/commands/doctor-agent-fleet.md +12 -7
  2. package/.claude/commands/setup-agent-fleet.md +7 -15
  3. package/.opencode/commands/af-doctor-agent-fleet.md +12 -7
  4. package/.opencode/commands/af-setup-agent-fleet.md +8 -6
  5. package/.pi/agents/model-profiles.yaml +9 -2
  6. package/.pi/agents/peers.yaml +12 -16
  7. package/.pi/agents/teams.yaml +4 -2
  8. package/.pi/extensions/agent-fleet-update-check/README.md +2 -3
  9. package/.pi/extensions/btw/README.md +2 -2
  10. package/.pi/extensions/chrome-devtools-mcp/README.md +3 -6
  11. package/.pi/extensions/compact-and-continue/README.md +3 -3
  12. package/.pi/extensions/mcp-bridge/README.md +1 -1
  13. package/.pi/harnesses/agent-hub/README.md +159 -15
  14. package/.pi/harnesses/agent-hub/docs-lane.js +122 -0
  15. package/.pi/harnesses/agent-hub/external-blocker.js +85 -0
  16. package/.pi/harnesses/agent-hub/footer.ts +4 -2
  17. package/.pi/harnesses/agent-hub/index.ts +552 -50
  18. package/.pi/harnesses/agent-hub/package.json +1 -1
  19. package/.pi/harnesses/agent-hub/review-findings.js +102 -0
  20. package/.pi/harnesses/agent-hub/run-budget.js +302 -4
  21. package/.pi/harnesses/agent-hub/run-namespace.js +87 -0
  22. package/.pi/harnesses/agent-hub/version.ts +25 -1
  23. package/.pi/harnesses/coms/README.md +8 -1
  24. package/.pi/harnesses/coms/package.json +1 -1
  25. package/.pi/harnesses/coms/version.ts +25 -1
  26. package/.pi/harnesses/damage-control-continue/README.md +8 -1
  27. package/.pi/harnesses/damage-control-continue/package.json +1 -1
  28. package/.pi/harnesses/damage-control-continue/version.ts +25 -1
  29. package/.pi/harnesses/lib/herdr-client.ts +10 -1
  30. package/.pi/harnesses/lib/spawned-peers.js +190 -0
  31. package/.pi/prompts/af-doctor-agent-fleet.md +13 -6
  32. package/.pi/prompts/af-setup-agent-fleet.md +7 -15
  33. package/.versions/0.0.10/.claude/commands/build.md +44 -0
  34. package/.versions/0.0.10/.claude/commands/code-simplify.md +22 -0
  35. package/.versions/0.0.10/.claude/commands/design-agent.md +14 -0
  36. package/.versions/0.0.10/.claude/commands/doctor-agent-fleet.md +22 -0
  37. package/.versions/0.0.10/.claude/commands/orchestrate.md +112 -0
  38. package/.versions/0.0.10/.claude/commands/plan.md +16 -0
  39. package/.versions/0.0.10/.claude/commands/prime.md +22 -0
  40. package/.versions/0.0.10/.claude/commands/review.md +16 -0
  41. package/.versions/0.0.10/.claude/commands/set-hermes-telegram.md +15 -0
  42. package/.versions/0.0.10/.claude/commands/set-hermes-watchdog.md +6 -0
  43. package/.versions/0.0.10/.claude/commands/setup-agent-fleet.md +17 -0
  44. package/.versions/0.0.10/.claude/commands/ship.md +72 -0
  45. package/.versions/0.0.10/.claude/commands/spec.md +15 -0
  46. package/.versions/0.0.10/.claude/commands/test.md +19 -0
  47. package/.versions/0.0.10/.claude/commands/webperf.md +32 -0
  48. package/.versions/0.0.10/.claude/orchestrate-teams.yaml +24 -0
  49. package/.versions/0.0.10/.opencode/commands/af-build.md +17 -0
  50. package/.versions/0.0.10/.opencode/commands/af-code-simplify.md +16 -0
  51. package/.versions/0.0.10/.opencode/commands/af-compound.md +16 -0
  52. package/.versions/0.0.10/.opencode/commands/af-design-agent.md +15 -0
  53. package/.versions/0.0.10/.opencode/commands/af-doctor-agent-fleet.md +22 -0
  54. package/.versions/0.0.10/.opencode/commands/af-orchestrate.md +112 -0
  55. package/.versions/0.0.10/.opencode/commands/af-plan.md +16 -0
  56. package/.versions/0.0.10/.opencode/commands/af-prime.md +22 -0
  57. package/.versions/0.0.10/.opencode/commands/af-review.md +15 -0
  58. package/.versions/0.0.10/.opencode/commands/af-set-hermes-telegram.md +15 -0
  59. package/.versions/0.0.10/.opencode/commands/af-set-hermes-watchdog.md +6 -0
  60. package/.versions/0.0.10/.opencode/commands/af-setup-agent-fleet.md +17 -0
  61. package/.versions/0.0.10/.opencode/commands/af-ship.md +16 -0
  62. package/.versions/0.0.10/.opencode/commands/af-spec.md +16 -0
  63. package/.versions/0.0.10/.opencode/commands/af-test.md +21 -0
  64. package/.versions/0.0.10/.opencode/commands/af-webperf.md +32 -0
  65. package/.versions/0.0.10/.opencode/orchestrate-teams.yaml +24 -0
  66. package/.versions/0.0.10/.pi/agents/dispatch-policy.yaml +32 -0
  67. package/.versions/0.0.10/.pi/agents/model-profiles.yaml +27 -0
  68. package/.versions/0.0.10/.pi/agents/peers.yaml +142 -0
  69. package/.versions/0.0.10/.pi/agents/teams.yaml +41 -0
  70. package/.versions/0.0.10/.pi/damage-control-rules.yaml +297 -0
  71. package/.versions/0.0.10/.pi/extensions/agent-fleet-update-check/README.md +57 -0
  72. package/.versions/0.0.10/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
  73. package/.versions/0.0.10/.pi/extensions/agent-fleet-update-check/package.json +6 -0
  74. package/.versions/0.0.10/.pi/extensions/btw/README.md +118 -0
  75. package/.versions/0.0.10/.pi/extensions/btw/index.ts +917 -0
  76. package/.versions/0.0.10/.pi/extensions/btw/package.json +6 -0
  77. package/.versions/0.0.10/.pi/extensions/btw/state.js +179 -0
  78. package/.versions/0.0.10/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
  79. package/.versions/0.0.10/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
  80. package/.versions/0.0.10/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  81. package/.versions/0.0.10/.pi/extensions/compact-and-continue/README.md +42 -0
  82. package/.versions/0.0.10/.pi/extensions/compact-and-continue/index.ts +120 -0
  83. package/.versions/0.0.10/.pi/extensions/compact-and-continue/package.json +6 -0
  84. package/.versions/0.0.10/.pi/extensions/mcp-bridge/README.md +46 -0
  85. package/.versions/0.0.10/.pi/extensions/mcp-bridge/index.ts +206 -0
  86. package/.versions/0.0.10/.pi/extensions/mcp-bridge/package.json +6 -0
  87. package/.versions/0.0.10/.pi/extensions/package-lock.json +1143 -0
  88. package/.versions/0.0.10/.pi/extensions/package.json +9 -0
  89. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/README.md +201 -0
  90. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/config.ts +198 -0
  91. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  92. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/index.ts +248 -0
  93. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/package.json +6 -0
  94. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  95. package/.versions/0.0.10/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  96. package/.versions/0.0.10/.pi/harnesses/agent-hub/README.md +1001 -0
  97. package/.versions/0.0.10/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  98. package/.versions/0.0.10/.pi/harnesses/agent-hub/artifacts.js +146 -0
  99. package/.versions/0.0.10/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
  100. package/.versions/0.0.10/.pi/harnesses/agent-hub/backend-policy.js +153 -0
  101. package/.versions/0.0.10/.pi/harnesses/agent-hub/context-window.js +106 -0
  102. package/.versions/0.0.10/.pi/harnesses/agent-hub/delegate.ts +435 -0
  103. package/.versions/0.0.10/.pi/harnesses/agent-hub/docs-lane.js +122 -0
  104. package/.versions/0.0.10/.pi/harnesses/agent-hub/drift-watchdog.js +211 -0
  105. package/.versions/0.0.10/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  106. package/.versions/0.0.10/.pi/harnesses/agent-hub/external-blocker.js +85 -0
  107. package/.versions/0.0.10/.pi/harnesses/agent-hub/footer.ts +31 -0
  108. package/.versions/0.0.10/.pi/harnesses/agent-hub/helpers.ts +248 -0
  109. package/.versions/0.0.10/.pi/harnesses/agent-hub/index.ts +9111 -0
  110. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  111. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
  112. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
  113. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  114. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  115. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  116. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  117. package/.versions/0.0.10/.pi/harnesses/agent-hub/monitor-session-bridge.ts +257 -0
  118. package/.versions/0.0.10/.pi/harnesses/agent-hub/package.json +7 -0
  119. package/.versions/0.0.10/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
  120. package/.versions/0.0.10/.pi/harnesses/agent-hub/research-retention.js +34 -0
  121. package/.versions/0.0.10/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  122. package/.versions/0.0.10/.pi/harnesses/agent-hub/return-contract.js +293 -0
  123. package/.versions/0.0.10/.pi/harnesses/agent-hub/return-extract.js +75 -0
  124. package/.versions/0.0.10/.pi/harnesses/agent-hub/review-findings.js +102 -0
  125. package/.versions/0.0.10/.pi/harnesses/agent-hub/run-budget.js +479 -0
  126. package/.versions/0.0.10/.pi/harnesses/agent-hub/run-namespace.js +87 -0
  127. package/.versions/0.0.10/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  128. package/.versions/0.0.10/.pi/harnesses/agent-hub/scope-gate.js +103 -0
  129. package/.versions/0.0.10/.pi/harnesses/agent-hub/session-health.js +110 -0
  130. package/.versions/0.0.10/.pi/harnesses/agent-hub/spawn.ts +354 -0
  131. package/.versions/0.0.10/.pi/harnesses/agent-hub/version.ts +42 -0
  132. package/.versions/0.0.10/.pi/harnesses/ask-user-remote/README.md +19 -0
  133. package/.versions/0.0.10/.pi/harnesses/ask-user-remote/index.ts +321 -0
  134. package/.versions/0.0.10/.pi/harnesses/ask-user-remote/race-core.js +106 -0
  135. package/.versions/0.0.10/.pi/harnesses/coms/README.md +100 -0
  136. package/.versions/0.0.10/.pi/harnesses/coms/index.ts +1767 -0
  137. package/.versions/0.0.10/.pi/harnesses/coms/package.json +7 -0
  138. package/.versions/0.0.10/.pi/harnesses/coms/version.ts +42 -0
  139. package/.versions/0.0.10/.pi/harnesses/damage-control-continue/README.md +124 -0
  140. package/.versions/0.0.10/.pi/harnesses/damage-control-continue/index.ts +536 -0
  141. package/.versions/0.0.10/.pi/harnesses/damage-control-continue/package.json +7 -0
  142. package/.versions/0.0.10/.pi/harnesses/damage-control-continue/version.ts +42 -0
  143. package/.versions/0.0.10/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
  144. package/.versions/0.0.10/.pi/harnesses/lib/damage-control-shared.ts +197 -0
  145. package/.versions/0.0.10/.pi/harnesses/lib/herdr-client.ts +472 -0
  146. package/.versions/0.0.10/.pi/harnesses/lib/herdr-presence.ts +399 -0
  147. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
  148. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
  149. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
  150. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
  151. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
  152. package/.versions/0.0.10/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
  153. package/.versions/0.0.10/.pi/harnesses/lib/spawned-peers.js +190 -0
  154. package/.versions/0.0.10/.pi/harnesses/package-lock.json +35 -0
  155. package/.versions/0.0.10/.pi/harnesses/package.json +9 -0
  156. package/.versions/0.0.10/.pi/prompts/af-build.md +24 -0
  157. package/.versions/0.0.10/.pi/prompts/af-code-simplify.md +22 -0
  158. package/.versions/0.0.10/.pi/prompts/af-doctor-agent-fleet.md +22 -0
  159. package/.versions/0.0.10/.pi/prompts/af-plan.md +16 -0
  160. package/.versions/0.0.10/.pi/prompts/af-review.md +16 -0
  161. package/.versions/0.0.10/.pi/prompts/af-set-hermes-telegram.md +15 -0
  162. package/.versions/0.0.10/.pi/prompts/af-set-hermes-watchdog.md +6 -0
  163. package/.versions/0.0.10/.pi/prompts/af-setup-agent-fleet.md +19 -0
  164. package/.versions/0.0.10/.pi/prompts/af-ship.md +17 -0
  165. package/.versions/0.0.10/.pi/prompts/af-spec.md +15 -0
  166. package/.versions/0.0.10/.pi/prompts/af-test.md +19 -0
  167. package/.versions/0.0.10/.pi/skills/bowser/SKILL.md +145 -0
  168. package/.versions/0.0.10/.version +1 -0
  169. package/.versions/0.0.10/agents/architect.md +24 -0
  170. package/.versions/0.0.10/agents/bowser.md +27 -0
  171. package/.versions/0.0.10/agents/builder.md +54 -0
  172. package/.versions/0.0.10/agents/code-reviewer.md +208 -0
  173. package/.versions/0.0.10/agents/deep-researcher.md +32 -0
  174. package/.versions/0.0.10/agents/documenter.md +18 -0
  175. package/.versions/0.0.10/agents/orchestrator.md +72 -0
  176. package/.versions/0.0.10/agents/plan-reviewer.md +83 -0
  177. package/.versions/0.0.10/agents/planner.md +70 -0
  178. package/.versions/0.0.10/agents/releaser.md +24 -0
  179. package/.versions/0.0.10/agents/researcher.md +28 -0
  180. package/.versions/0.0.10/agents/security-auditor.md +167 -0
  181. package/.versions/0.0.10/agents/test-engineer.md +153 -0
  182. package/.versions/0.0.10/agents/web-debugger.md +43 -0
  183. package/.versions/0.0.10/agents/web-performance-auditor.md +193 -0
  184. package/.versions/0.0.10/codex/CONDUCTOR.md +148 -0
  185. package/.versions/0.0.10/docs/ARCHITECTURE.md +303 -0
  186. package/.versions/0.0.10/docs/agent-fleet-setup.md +377 -0
  187. package/.versions/0.0.10/docs/claude-code-coms-bridge.md +109 -0
  188. package/.versions/0.0.10/docs/codex-remote-conductor.md +170 -0
  189. package/.versions/0.0.10/docs/coms-hermes-bridge.md +189 -0
  190. package/.versions/0.0.10/docs/getting-started.md +254 -0
  191. package/.versions/0.0.10/docs/npm-install.md +514 -0
  192. package/.versions/0.0.10/docs/opencode-setup.md +281 -0
  193. package/.versions/0.0.10/docs/pi-extensions.md +363 -0
  194. package/.versions/0.0.10/docs/pi-setup.md +571 -0
  195. package/.versions/0.0.10/docs/skill-anatomy.md +150 -0
  196. package/.versions/0.0.10/hermes/README.md +347 -0
  197. package/.versions/0.0.10/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
  198. package/.versions/0.0.10/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
  199. package/.versions/0.0.10/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  200. package/.versions/0.0.10/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  201. package/.versions/0.0.10/hermes/gates/gate-o-capability.md +8 -0
  202. package/.versions/0.0.10/hermes/gates/gate-o-validator-fixtures.json +1 -0
  203. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
  204. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
  205. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
  206. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
  207. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
  208. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
  209. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
  210. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
  211. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
  212. package/.versions/0.0.10/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
  213. package/.versions/0.0.10/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
  214. package/.versions/0.0.10/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  215. package/.versions/0.0.10/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  216. package/.versions/0.0.10/hermes/skills/hub-conductor/SKILL.md +84 -0
  217. package/.versions/0.0.10/hermes/skills/hub-liaison/SKILL.md +84 -0
  218. package/.versions/0.0.10/hermes/skills/hub-watchdog/SKILL.md +76 -0
  219. package/.versions/0.0.10/hermes/skills/hub-watchdog/manifest.json +1 -0
  220. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
  221. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
  222. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
  223. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
  224. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
  225. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
  226. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
  227. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
  228. package/.versions/0.0.10/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
  229. package/.versions/0.0.10/hermes/watchdog-tests/__init__.py +0 -0
  230. package/.versions/0.0.10/hooks/SIMPLIFY-IGNORE.md +90 -0
  231. package/.versions/0.0.10/hooks/coms-stop-hook.mjs +84 -0
  232. package/.versions/0.0.10/hooks/hooks.json +14 -0
  233. package/.versions/0.0.10/hooks/session-start.sh +74 -0
  234. package/.versions/0.0.10/hooks/simplify-ignore.sh +302 -0
  235. package/.versions/0.0.10/install-manifest.json +3615 -0
  236. package/.versions/0.0.10/justfile +254 -0
  237. package/.versions/0.0.10/manifest-meta.json +472 -0
  238. package/.versions/0.0.10/references/accessibility-checklist.md +160 -0
  239. package/.versions/0.0.10/references/definition-of-done.md +67 -0
  240. package/.versions/0.0.10/references/fleet-coordination-patterns.md +151 -0
  241. package/.versions/0.0.10/references/observability-checklist.md +91 -0
  242. package/.versions/0.0.10/references/orchestration-patterns.md +370 -0
  243. package/.versions/0.0.10/references/performance-checklist.md +153 -0
  244. package/.versions/0.0.10/references/prompting-patterns.md +380 -0
  245. package/.versions/0.0.10/references/security-checklist.md +179 -0
  246. package/.versions/0.0.10/references/testing-patterns.md +236 -0
  247. package/.versions/0.0.10/scripts/codex-conductor.ts +41 -0
  248. package/.versions/0.0.10/scripts/codex-remote-control.ts +167 -0
  249. package/.versions/0.0.10/scripts/coms-claude-bridge.ts +401 -0
  250. package/.versions/0.0.10/scripts/coms-cli.ts +484 -0
  251. package/.versions/0.0.10/scripts/coms-hermes-bridge.ts +413 -0
  252. package/.versions/0.0.10/scripts/fleet.ts +168 -0
  253. package/.versions/0.0.10/scripts/hermes-monitor-capability-runner.ts +25 -0
  254. package/.versions/0.0.10/scripts/hermes-monitor-scenario.ts +474 -0
  255. package/.versions/0.0.10/scripts/hermes-watchdog-capability-probe.ts +45 -0
  256. package/.versions/0.0.10/scripts/install-hermes-plugin.sh +180 -0
  257. package/.versions/0.0.10/scripts/lib/claude-bridge-core.ts +165 -0
  258. package/.versions/0.0.10/scripts/lib/codex-conductor.ts +88 -0
  259. package/.versions/0.0.10/scripts/lib/codex-remote-control.ts +480 -0
  260. package/.versions/0.0.10/scripts/lib/coms-envelope.ts +582 -0
  261. package/.versions/0.0.10/scripts/lib/fake-herdr-server.ts +88 -0
  262. package/.versions/0.0.10/scripts/lib/fleet-command.ts +111 -0
  263. package/.versions/0.0.10/scripts/lib/herdr-layout.ts +281 -0
  264. package/.versions/0.0.10/scripts/lib/hermes-bridge-core.ts +241 -0
  265. package/.versions/0.0.10/scripts/lib/hermes-monitor-events.ts +1 -0
  266. package/.versions/0.0.10/scripts/lib/hermes-monitor-herdr.ts +2 -0
  267. package/.versions/0.0.10/scripts/lib/hermes-monitor-model.ts +3 -0
  268. package/.versions/0.0.10/scripts/lib/hermes-monitor-registry.ts +2 -0
  269. package/.versions/0.0.10/scripts/lib/hermes-monitor-socket.ts +2 -0
  270. package/.versions/0.0.10/scripts/lib/hermes-monitor-store.ts +2 -0
  271. package/.versions/0.0.10/scripts/lib/monitor-env.ts +120 -0
  272. package/.versions/0.0.10/scripts/lib/peer-launch.ts +314 -0
  273. package/.versions/0.0.10/scripts/lib/persona-banner.ts +62 -0
  274. package/.versions/0.0.10/scripts/lib/spawn-stagger.ts +101 -0
  275. package/.versions/0.0.10/scripts/lib/team-project.ts +193 -0
  276. package/.versions/0.0.10/scripts/lib/team-snapshot.ts +147 -0
  277. package/.versions/0.0.10/scripts/peer-banner.ts +40 -0
  278. package/.versions/0.0.10/scripts/peer-launch.ts +259 -0
  279. package/.versions/0.0.10/scripts/team-snapshot.ts +237 -0
  280. package/.versions/0.0.10/scripts/team-up.ts +360 -0
  281. package/.versions/0.0.10/skills/_internal/grilling.md +11 -0
  282. package/.versions/0.0.10/skills/browser-testing-with-devtools/SKILL.md +351 -0
  283. package/.versions/0.0.10/skills/code-review-and-quality/SKILL.md +381 -0
  284. package/.versions/0.0.10/skills/compound-learning/SKILL.md +137 -0
  285. package/.versions/0.0.10/skills/context-engineering/SKILL.md +291 -0
  286. package/.versions/0.0.10/skills/deprecation-and-migration/SKILL.md +206 -0
  287. package/.versions/0.0.10/skills/designing-agents/SKILL.md +394 -0
  288. package/.versions/0.0.10/skills/designing-agents/pi-harness-authoring.md +222 -0
  289. package/.versions/0.0.10/skills/frontend-ui-engineering/SKILL.md +328 -0
  290. package/.versions/0.0.10/skills/git-workflow-and-versioning/SKILL.md +316 -0
  291. package/.versions/0.0.10/skills/guided-workspace-setup/SKILL.md +226 -0
  292. package/.versions/0.0.10/skills/guided-workspace-setup/companion-manifest.json +38 -0
  293. package/.versions/0.0.10/skills/idea-refine/SKILL.md +182 -0
  294. package/.versions/0.0.10/skills/idea-refine/examples.md +238 -0
  295. package/.versions/0.0.10/skills/idea-refine/frameworks.md +99 -0
  296. package/.versions/0.0.10/skills/idea-refine/refinement-criteria.md +113 -0
  297. package/.versions/0.0.10/skills/idea-refine/scripts/idea-refine.sh +15 -0
  298. package/.versions/0.0.10/skills/incremental-implementation/SKILL.md +287 -0
  299. package/.versions/0.0.10/skills/interview-me/SKILL.md +226 -0
  300. package/.versions/0.0.10/skills/orchestration-verification/SKILL.md +181 -0
  301. package/.versions/0.0.10/skills/peer-coms/SKILL.md +90 -0
  302. package/.versions/0.0.10/skills/performance-optimization/SKILL.md +350 -0
  303. package/.versions/0.0.10/skills/planning-and-task-breakdown/SKILL.md +254 -0
  304. package/.versions/0.0.10/skills/security-and-hardening/SKILL.md +461 -0
  305. package/.versions/0.0.10/skills/spec-driven-development/SKILL.md +257 -0
  306. package/.versions/0.0.10/skills/using-agent-skills/SKILL.md +199 -0
  307. package/.versions/0.0.10/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
  308. package/.versions/0.0.10/vendor/agent-skills-upstream/LICENSE +21 -0
  309. package/.versions/0.0.10/vendor/agent-skills-upstream/README.md +11 -0
  310. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
  311. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  312. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  313. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  314. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  315. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
  316. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  317. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  318. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
  319. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  320. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  321. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  322. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  323. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  324. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  325. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  326. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  327. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  328. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  329. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
  330. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
  331. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
  332. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
  333. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
  334. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
  335. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
  336. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
  337. package/.versions/0.0.10/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
  338. package/.versions/0.0.9/.claude/commands/build.md +44 -0
  339. package/.versions/0.0.9/.claude/commands/code-simplify.md +22 -0
  340. package/.versions/0.0.9/.claude/commands/design-agent.md +14 -0
  341. package/.versions/0.0.9/.claude/commands/doctor-agent-fleet.md +17 -0
  342. package/.versions/0.0.9/.claude/commands/orchestrate.md +112 -0
  343. package/.versions/0.0.9/.claude/commands/plan.md +16 -0
  344. package/.versions/0.0.9/.claude/commands/prime.md +22 -0
  345. package/.versions/0.0.9/.claude/commands/review.md +16 -0
  346. package/.versions/0.0.9/.claude/commands/set-hermes-telegram.md +15 -0
  347. package/.versions/0.0.9/.claude/commands/set-hermes-watchdog.md +6 -0
  348. package/.versions/0.0.9/.claude/commands/setup-agent-fleet.md +25 -0
  349. package/.versions/0.0.9/.claude/commands/ship.md +72 -0
  350. package/.versions/0.0.9/.claude/commands/spec.md +15 -0
  351. package/.versions/0.0.9/.claude/commands/test.md +19 -0
  352. package/.versions/0.0.9/.claude/commands/webperf.md +32 -0
  353. package/.versions/0.0.9/.claude/orchestrate-teams.yaml +24 -0
  354. package/.versions/0.0.9/.opencode/commands/af-build.md +17 -0
  355. package/.versions/0.0.9/.opencode/commands/af-code-simplify.md +16 -0
  356. package/.versions/0.0.9/.opencode/commands/af-compound.md +16 -0
  357. package/.versions/0.0.9/.opencode/commands/af-design-agent.md +15 -0
  358. package/.versions/0.0.9/.opencode/commands/af-doctor-agent-fleet.md +17 -0
  359. package/.versions/0.0.9/.opencode/commands/af-orchestrate.md +112 -0
  360. package/.versions/0.0.9/.opencode/commands/af-plan.md +16 -0
  361. package/.versions/0.0.9/.opencode/commands/af-prime.md +22 -0
  362. package/.versions/0.0.9/.opencode/commands/af-review.md +15 -0
  363. package/.versions/0.0.9/.opencode/commands/af-set-hermes-telegram.md +15 -0
  364. package/.versions/0.0.9/.opencode/commands/af-set-hermes-watchdog.md +6 -0
  365. package/.versions/0.0.9/.opencode/commands/af-setup-agent-fleet.md +15 -0
  366. package/.versions/0.0.9/.opencode/commands/af-ship.md +16 -0
  367. package/.versions/0.0.9/.opencode/commands/af-spec.md +16 -0
  368. package/.versions/0.0.9/.opencode/commands/af-test.md +21 -0
  369. package/.versions/0.0.9/.opencode/commands/af-webperf.md +32 -0
  370. package/.versions/0.0.9/.opencode/orchestrate-teams.yaml +24 -0
  371. package/.versions/0.0.9/.pi/agents/dispatch-policy.yaml +32 -0
  372. package/.versions/0.0.9/.pi/agents/model-profiles.yaml +27 -0
  373. package/.versions/0.0.9/.pi/agents/peers.yaml +142 -0
  374. package/.versions/0.0.9/.pi/agents/teams.yaml +41 -0
  375. package/.versions/0.0.9/.pi/damage-control-rules.yaml +297 -0
  376. package/.versions/0.0.9/.pi/extensions/agent-fleet-update-check/README.md +58 -0
  377. package/.versions/0.0.9/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
  378. package/.versions/0.0.9/.pi/extensions/agent-fleet-update-check/package.json +6 -0
  379. package/.versions/0.0.9/.pi/extensions/btw/README.md +118 -0
  380. package/.versions/0.0.9/.pi/extensions/btw/index.ts +917 -0
  381. package/.versions/0.0.9/.pi/extensions/btw/package.json +6 -0
  382. package/.versions/0.0.9/.pi/extensions/btw/state.js +179 -0
  383. package/.versions/0.0.9/.pi/extensions/chrome-devtools-mcp/README.md +58 -0
  384. package/.versions/0.0.9/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
  385. package/.versions/0.0.9/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  386. package/.versions/0.0.9/.pi/extensions/compact-and-continue/README.md +42 -0
  387. package/.versions/0.0.9/.pi/extensions/compact-and-continue/index.ts +120 -0
  388. package/.versions/0.0.9/.pi/extensions/compact-and-continue/package.json +6 -0
  389. package/.versions/0.0.9/.pi/extensions/mcp-bridge/README.md +46 -0
  390. package/.versions/0.0.9/.pi/extensions/mcp-bridge/index.ts +206 -0
  391. package/.versions/0.0.9/.pi/extensions/mcp-bridge/package.json +6 -0
  392. package/.versions/0.0.9/.pi/extensions/package-lock.json +1143 -0
  393. package/.versions/0.0.9/.pi/extensions/package.json +9 -0
  394. package/.versions/0.0.9/.pi/extensions/pi-voice-stt/README.md +201 -0
  395. package/.versions/0.0.9/.pi/extensions/pi-voice-stt/config.ts +198 -0
  396. package/.versions/0.0.9/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  397. package/.versions/0.0.9/.pi/extensions/pi-voice-stt/index.ts +248 -0
  398. package/.versions/0.0.9/.pi/extensions/pi-voice-stt/package.json +6 -0
  399. package/.versions/0.0.9/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  400. package/.versions/0.0.9/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  401. package/.versions/0.0.9/.pi/harnesses/agent-hub/README.md +872 -0
  402. package/.versions/0.0.9/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  403. package/.versions/0.0.9/.pi/harnesses/agent-hub/artifacts.js +146 -0
  404. package/.versions/0.0.9/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
  405. package/.versions/0.0.9/.pi/harnesses/agent-hub/backend-policy.js +153 -0
  406. package/.versions/0.0.9/.pi/harnesses/agent-hub/context-window.js +106 -0
  407. package/.versions/0.0.9/.pi/harnesses/agent-hub/delegate.ts +435 -0
  408. package/.versions/0.0.9/.pi/harnesses/agent-hub/drift-watchdog.js +211 -0
  409. package/.versions/0.0.9/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  410. package/.versions/0.0.9/.pi/harnesses/agent-hub/footer.ts +31 -0
  411. package/.versions/0.0.9/.pi/harnesses/agent-hub/helpers.ts +248 -0
  412. package/.versions/0.0.9/.pi/harnesses/agent-hub/index.ts +8702 -0
  413. package/.versions/0.0.9/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  414. package/.versions/0.0.9/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
  415. package/.versions/0.0.9/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
  416. package/.versions/0.0.9/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  417. package/.versions/0.0.9/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  418. package/.versions/0.0.9/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  419. package/.versions/0.0.9/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  420. package/.versions/0.0.9/.pi/harnesses/agent-hub/monitor-session-bridge.ts +257 -0
  421. package/.versions/0.0.9/.pi/harnesses/agent-hub/package.json +7 -0
  422. package/.versions/0.0.9/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
  423. package/.versions/0.0.9/.pi/harnesses/agent-hub/research-retention.js +34 -0
  424. package/.versions/0.0.9/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  425. package/.versions/0.0.9/.pi/harnesses/agent-hub/return-contract.js +293 -0
  426. package/.versions/0.0.9/.pi/harnesses/agent-hub/return-extract.js +75 -0
  427. package/.versions/0.0.9/.pi/harnesses/agent-hub/run-budget.js +181 -0
  428. package/.versions/0.0.9/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  429. package/.versions/0.0.9/.pi/harnesses/agent-hub/scope-gate.js +103 -0
  430. package/.versions/0.0.9/.pi/harnesses/agent-hub/session-health.js +110 -0
  431. package/.versions/0.0.9/.pi/harnesses/agent-hub/spawn.ts +354 -0
  432. package/.versions/0.0.9/.pi/harnesses/agent-hub/version.ts +42 -0
  433. package/.versions/0.0.9/.pi/harnesses/ask-user-remote/README.md +19 -0
  434. package/.versions/0.0.9/.pi/harnesses/ask-user-remote/index.ts +321 -0
  435. package/.versions/0.0.9/.pi/harnesses/ask-user-remote/race-core.js +106 -0
  436. package/.versions/0.0.9/.pi/harnesses/coms/README.md +100 -0
  437. package/.versions/0.0.9/.pi/harnesses/coms/index.ts +1767 -0
  438. package/.versions/0.0.9/.pi/harnesses/coms/package.json +7 -0
  439. package/.versions/0.0.9/.pi/harnesses/coms/version.ts +42 -0
  440. package/.versions/0.0.9/.pi/harnesses/damage-control-continue/README.md +124 -0
  441. package/.versions/0.0.9/.pi/harnesses/damage-control-continue/index.ts +536 -0
  442. package/.versions/0.0.9/.pi/harnesses/damage-control-continue/package.json +7 -0
  443. package/.versions/0.0.9/.pi/harnesses/damage-control-continue/version.ts +42 -0
  444. package/.versions/0.0.9/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
  445. package/.versions/0.0.9/.pi/harnesses/lib/damage-control-shared.ts +197 -0
  446. package/.versions/0.0.9/.pi/harnesses/lib/herdr-client.ts +472 -0
  447. package/.versions/0.0.9/.pi/harnesses/lib/herdr-presence.ts +399 -0
  448. package/.versions/0.0.9/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
  449. package/.versions/0.0.9/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
  450. package/.versions/0.0.9/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
  451. package/.versions/0.0.9/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
  452. package/.versions/0.0.9/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
  453. package/.versions/0.0.9/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
  454. package/.versions/0.0.9/.pi/harnesses/lib/spawned-peers.js +190 -0
  455. package/.versions/0.0.9/.pi/harnesses/package-lock.json +35 -0
  456. package/.versions/0.0.9/.pi/harnesses/package.json +9 -0
  457. package/.versions/0.0.9/.pi/prompts/af-build.md +24 -0
  458. package/.versions/0.0.9/.pi/prompts/af-code-simplify.md +22 -0
  459. package/.versions/0.0.9/.pi/prompts/af-doctor-agent-fleet.md +15 -0
  460. package/.versions/0.0.9/.pi/prompts/af-plan.md +16 -0
  461. package/.versions/0.0.9/.pi/prompts/af-review.md +16 -0
  462. package/.versions/0.0.9/.pi/prompts/af-set-hermes-telegram.md +15 -0
  463. package/.versions/0.0.9/.pi/prompts/af-set-hermes-watchdog.md +6 -0
  464. package/.versions/0.0.9/.pi/prompts/af-setup-agent-fleet.md +27 -0
  465. package/.versions/0.0.9/.pi/prompts/af-ship.md +17 -0
  466. package/.versions/0.0.9/.pi/prompts/af-spec.md +15 -0
  467. package/.versions/0.0.9/.pi/prompts/af-test.md +19 -0
  468. package/.versions/0.0.9/.pi/skills/bowser/SKILL.md +145 -0
  469. package/.versions/0.0.9/.version +1 -0
  470. package/.versions/0.0.9/agents/architect.md +24 -0
  471. package/.versions/0.0.9/agents/bowser.md +27 -0
  472. package/.versions/0.0.9/agents/builder.md +54 -0
  473. package/.versions/0.0.9/agents/code-reviewer.md +204 -0
  474. package/.versions/0.0.9/agents/deep-researcher.md +32 -0
  475. package/.versions/0.0.9/agents/documenter.md +18 -0
  476. package/.versions/0.0.9/agents/orchestrator.md +66 -0
  477. package/.versions/0.0.9/agents/plan-reviewer.md +62 -0
  478. package/.versions/0.0.9/agents/planner.md +70 -0
  479. package/.versions/0.0.9/agents/releaser.md +24 -0
  480. package/.versions/0.0.9/agents/researcher.md +28 -0
  481. package/.versions/0.0.9/agents/security-auditor.md +167 -0
  482. package/.versions/0.0.9/agents/test-engineer.md +153 -0
  483. package/.versions/0.0.9/agents/web-debugger.md +43 -0
  484. package/.versions/0.0.9/agents/web-performance-auditor.md +193 -0
  485. package/.versions/0.0.9/codex/CONDUCTOR.md +148 -0
  486. package/.versions/0.0.9/docs/ARCHITECTURE.md +262 -0
  487. package/.versions/0.0.9/docs/agent-fleet-setup.md +366 -0
  488. package/.versions/0.0.9/docs/claude-code-coms-bridge.md +109 -0
  489. package/.versions/0.0.9/docs/codex-remote-conductor.md +170 -0
  490. package/.versions/0.0.9/docs/coms-hermes-bridge.md +189 -0
  491. package/.versions/0.0.9/docs/getting-started.md +231 -0
  492. package/.versions/0.0.9/docs/npm-install.md +337 -0
  493. package/.versions/0.0.9/docs/opencode-setup.md +249 -0
  494. package/.versions/0.0.9/docs/pi-extensions.md +356 -0
  495. package/.versions/0.0.9/docs/pi-setup.md +476 -0
  496. package/.versions/0.0.9/docs/skill-anatomy.md +150 -0
  497. package/.versions/0.0.9/hermes/README.md +347 -0
  498. package/.versions/0.0.9/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
  499. package/.versions/0.0.9/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
  500. package/.versions/0.0.9/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  501. package/.versions/0.0.9/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  502. package/.versions/0.0.9/hermes/gates/gate-o-capability.md +8 -0
  503. package/.versions/0.0.9/hermes/gates/gate-o-validator-fixtures.json +1 -0
  504. package/.versions/0.0.9/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
  505. package/.versions/0.0.9/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
  506. package/.versions/0.0.9/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
  507. package/.versions/0.0.9/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
  508. package/.versions/0.0.9/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
  509. package/.versions/0.0.9/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
  510. package/.versions/0.0.9/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
  511. package/.versions/0.0.9/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
  512. package/.versions/0.0.9/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
  513. package/.versions/0.0.9/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
  514. package/.versions/0.0.9/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
  515. package/.versions/0.0.9/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  516. package/.versions/0.0.9/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  517. package/.versions/0.0.9/hermes/skills/hub-conductor/SKILL.md +84 -0
  518. package/.versions/0.0.9/hermes/skills/hub-liaison/SKILL.md +84 -0
  519. package/.versions/0.0.9/hermes/skills/hub-watchdog/SKILL.md +76 -0
  520. package/.versions/0.0.9/hermes/skills/hub-watchdog/manifest.json +1 -0
  521. package/.versions/0.0.9/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
  522. package/.versions/0.0.9/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
  523. package/.versions/0.0.9/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
  524. package/.versions/0.0.9/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
  525. package/.versions/0.0.9/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
  526. package/.versions/0.0.9/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
  527. package/.versions/0.0.9/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
  528. package/.versions/0.0.9/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
  529. package/.versions/0.0.9/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
  530. package/.versions/0.0.9/hermes/watchdog-tests/__init__.py +0 -0
  531. package/.versions/0.0.9/hooks/SIMPLIFY-IGNORE.md +90 -0
  532. package/.versions/0.0.9/hooks/coms-stop-hook.mjs +84 -0
  533. package/.versions/0.0.9/hooks/hooks.json +14 -0
  534. package/.versions/0.0.9/hooks/session-start.sh +74 -0
  535. package/.versions/0.0.9/hooks/simplify-ignore.sh +302 -0
  536. package/.versions/0.0.9/justfile +254 -0
  537. package/.versions/0.0.9/references/accessibility-checklist.md +160 -0
  538. package/.versions/0.0.9/references/definition-of-done.md +67 -0
  539. package/.versions/0.0.9/references/fleet-coordination-patterns.md +151 -0
  540. package/.versions/0.0.9/references/observability-checklist.md +91 -0
  541. package/.versions/0.0.9/references/orchestration-patterns.md +370 -0
  542. package/.versions/0.0.9/references/performance-checklist.md +153 -0
  543. package/.versions/0.0.9/references/prompting-patterns.md +380 -0
  544. package/.versions/0.0.9/references/security-checklist.md +179 -0
  545. package/.versions/0.0.9/references/testing-patterns.md +236 -0
  546. package/.versions/0.0.9/scripts/codex-conductor.ts +41 -0
  547. package/.versions/0.0.9/scripts/codex-remote-control.ts +167 -0
  548. package/.versions/0.0.9/scripts/coms-claude-bridge.ts +401 -0
  549. package/.versions/0.0.9/scripts/coms-cli.ts +484 -0
  550. package/.versions/0.0.9/scripts/coms-hermes-bridge.ts +413 -0
  551. package/.versions/0.0.9/scripts/fleet.ts +168 -0
  552. package/.versions/0.0.9/scripts/hermes-monitor-capability-runner.ts +25 -0
  553. package/.versions/0.0.9/scripts/hermes-monitor-scenario.ts +474 -0
  554. package/.versions/0.0.9/scripts/hermes-watchdog-capability-probe.ts +45 -0
  555. package/.versions/0.0.9/scripts/install-hermes-plugin.sh +180 -0
  556. package/.versions/0.0.9/scripts/lib/claude-bridge-core.ts +165 -0
  557. package/.versions/0.0.9/scripts/lib/codex-conductor.ts +88 -0
  558. package/.versions/0.0.9/scripts/lib/codex-remote-control.ts +480 -0
  559. package/.versions/0.0.9/scripts/lib/coms-envelope.ts +582 -0
  560. package/.versions/0.0.9/scripts/lib/fake-herdr-server.ts +88 -0
  561. package/.versions/0.0.9/scripts/lib/fleet-command.ts +111 -0
  562. package/.versions/0.0.9/scripts/lib/herdr-layout.ts +281 -0
  563. package/.versions/0.0.9/scripts/lib/hermes-bridge-core.ts +241 -0
  564. package/.versions/0.0.9/scripts/lib/hermes-monitor-events.ts +1 -0
  565. package/.versions/0.0.9/scripts/lib/hermes-monitor-herdr.ts +2 -0
  566. package/.versions/0.0.9/scripts/lib/hermes-monitor-model.ts +3 -0
  567. package/.versions/0.0.9/scripts/lib/hermes-monitor-registry.ts +2 -0
  568. package/.versions/0.0.9/scripts/lib/hermes-monitor-socket.ts +2 -0
  569. package/.versions/0.0.9/scripts/lib/hermes-monitor-store.ts +2 -0
  570. package/.versions/0.0.9/scripts/lib/monitor-env.ts +120 -0
  571. package/.versions/0.0.9/scripts/lib/peer-launch.ts +314 -0
  572. package/.versions/0.0.9/scripts/lib/persona-banner.ts +62 -0
  573. package/.versions/0.0.9/scripts/lib/spawn-stagger.ts +101 -0
  574. package/.versions/0.0.9/scripts/lib/team-project.ts +193 -0
  575. package/.versions/0.0.9/scripts/lib/team-snapshot.ts +147 -0
  576. package/.versions/0.0.9/scripts/peer-banner.ts +40 -0
  577. package/.versions/0.0.9/scripts/peer-launch.ts +259 -0
  578. package/.versions/0.0.9/scripts/team-snapshot.ts +237 -0
  579. package/.versions/0.0.9/scripts/team-up.ts +360 -0
  580. package/.versions/0.0.9/skills/_internal/grilling.md +11 -0
  581. package/.versions/0.0.9/skills/browser-testing-with-devtools/SKILL.md +352 -0
  582. package/.versions/0.0.9/skills/code-review-and-quality/SKILL.md +381 -0
  583. package/.versions/0.0.9/skills/compound-learning/SKILL.md +137 -0
  584. package/.versions/0.0.9/skills/context-engineering/SKILL.md +291 -0
  585. package/.versions/0.0.9/skills/deprecation-and-migration/SKILL.md +206 -0
  586. package/.versions/0.0.9/skills/designing-agents/SKILL.md +394 -0
  587. package/.versions/0.0.9/skills/designing-agents/pi-harness-authoring.md +222 -0
  588. package/.versions/0.0.9/skills/frontend-ui-engineering/SKILL.md +328 -0
  589. package/.versions/0.0.9/skills/git-workflow-and-versioning/SKILL.md +316 -0
  590. package/.versions/0.0.9/skills/guided-workspace-setup/SKILL.md +544 -0
  591. package/.versions/0.0.9/skills/guided-workspace-setup/companion-manifest.json +38 -0
  592. package/.versions/0.0.9/skills/idea-refine/SKILL.md +182 -0
  593. package/.versions/0.0.9/skills/idea-refine/examples.md +238 -0
  594. package/.versions/0.0.9/skills/idea-refine/frameworks.md +99 -0
  595. package/.versions/0.0.9/skills/idea-refine/refinement-criteria.md +113 -0
  596. package/.versions/0.0.9/skills/idea-refine/scripts/idea-refine.sh +15 -0
  597. package/.versions/0.0.9/skills/incremental-implementation/SKILL.md +287 -0
  598. package/.versions/0.0.9/skills/interview-me/SKILL.md +226 -0
  599. package/.versions/0.0.9/skills/orchestration-verification/SKILL.md +181 -0
  600. package/.versions/0.0.9/skills/peer-coms/SKILL.md +90 -0
  601. package/.versions/0.0.9/skills/performance-optimization/SKILL.md +350 -0
  602. package/.versions/0.0.9/skills/planning-and-task-breakdown/SKILL.md +236 -0
  603. package/.versions/0.0.9/skills/security-and-hardening/SKILL.md +461 -0
  604. package/.versions/0.0.9/skills/spec-driven-development/SKILL.md +245 -0
  605. package/.versions/0.0.9/skills/using-agent-skills/SKILL.md +199 -0
  606. package/.versions/0.0.9/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
  607. package/.versions/0.0.9/vendor/agent-skills-upstream/LICENSE +21 -0
  608. package/.versions/0.0.9/vendor/agent-skills-upstream/README.md +11 -0
  609. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
  610. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  611. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  612. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  613. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  614. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
  615. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  616. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  617. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
  618. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  619. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  620. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  621. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  622. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  623. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  624. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  625. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  626. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  627. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  628. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
  629. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
  630. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
  631. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
  632. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
  633. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
  634. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
  635. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
  636. package/.versions/0.0.9/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
  637. package/CHANGELOG.md +141 -0
  638. package/README.md +22 -5
  639. package/agents/architect.md +1 -0
  640. package/agents/bowser.md +1 -0
  641. package/agents/builder.md +1 -0
  642. package/agents/code-reviewer.md +8 -5
  643. package/agents/deep-researcher.md +2 -1
  644. package/agents/orchestrator.md +8 -1
  645. package/agents/plan-reviewer.md +25 -2
  646. package/agents/planner.md +3 -2
  647. package/agents/security-auditor.md +1 -0
  648. package/agents/test-engineer.md +3 -1
  649. package/agents/web-debugger.md +1 -0
  650. package/agents/web-performance-auditor.md +1 -0
  651. package/bin/build-manifest.js +68 -0
  652. package/bin/cli.js +679 -49
  653. package/bin/lib/apply.js +641 -0
  654. package/bin/lib/manifest.js +731 -0
  655. package/bin/lib/merge-forms.js +106 -0
  656. package/bin/lib/plan.js +569 -0
  657. package/bin/lib/state.js +213 -0
  658. package/bin/lib/verify.js +576 -0
  659. package/bin/snapshot-version.js +5 -0
  660. package/docs/ARCHITECTURE.md +53 -12
  661. package/docs/agent-fleet-setup.md +59 -48
  662. package/docs/getting-started.md +29 -6
  663. package/docs/npm-install.md +208 -31
  664. package/docs/opencode-setup.md +32 -0
  665. package/docs/pi-extensions.md +83 -13
  666. package/docs/pi-setup.md +164 -69
  667. package/install-manifest.json +3615 -0
  668. package/justfile +10 -1
  669. package/manifest-meta.json +472 -0
  670. package/package.json +8 -3
  671. package/scripts/fleet.ts +22 -3
  672. package/scripts/lib/fleet-command.ts +5 -3
  673. package/scripts/lib/herdr-layout.ts +18 -0
  674. package/scripts/lib/peer-launch.ts +314 -0
  675. package/scripts/lib/team-project.ts +3 -1
  676. package/scripts/peer-launch.ts +259 -0
  677. package/skills/browser-testing-with-devtools/SKILL.md +3 -4
  678. package/skills/guided-workspace-setup/SKILL.md +172 -490
  679. package/skills/guided-workspace-setup/companion-manifest.json +2 -0
  680. package/skills/planning-and-task-breakdown/SKILL.md +18 -0
  681. package/skills/spec-driven-development/SKILL.md +12 -0
  682. package/.pi/harnesses/agent-hub/spawned-peers.js +0 -74
@@ -89,10 +89,22 @@ import {
89
89
  exemptionsFilePath, type AccessRequest,
90
90
  } from "../lib/damage-control-shared.ts";
91
91
  import { applyModelOverride, clampDelegateDepth, DELEGATE_TREE_SPAWN_BUDGET, fallbackModelFor, isReadOnlyToolList, MAX_DELEGATE_DEPTH, normalizeAgentInput, parseTeamsYaml, safeAgentKey, safePathWithin, taskFingerprint, upsertTeamInYaml } from "./helpers.ts";
92
- import { DEFAULT_HUB_MODE, DEFAULT_TASK_TIER, HUB_MODES, TASK_TIERS, budgetStatusLine, checkTurnBudget, contextOverflowDiagnostic, normalizeHubMode, normalizeTaskTier, resolveTurnBudget, shouldRecycleSession } from "./run-budget.js";
92
+ import { DEFAULT_HUB_MODE, DEFAULT_TASK_TIER, HUB_MODES, TASK_BUDGET_MULTIPLIER, applyTierChange, blockingFindingCap, budgetStatusLine, checkReviewRoundCap, checkTaskBudget, checkTierPersonaGate, checkTurnBudget, contextOverflowDiagnostic, isReviewPersona, normalizeHubMode, remainingTaskResearch, resolveTaskBudget, resolveTurnBudget, reviewBudgetClause, reviewRoundCap, shouldRecycleSession, turnActiveMs } from "./run-budget.js";
93
+ import { countReviewFindings, findingBudgetNotice } from "./review-findings.js";
94
+ import { checkDocsLane, docsLaneNotice } from "./docs-lane.js";
95
+ import { checkExternalBlockerGate, externalBlockedProtocol, extractExternalBlockers } from "./external-blocker.js";
96
+ import { DEFAULT_RUN_HISTORY_KEEP, appendRunIndex, buildRunMeta, makeRunId, normalizeRunHistoryKeep, pruneRunDirs, RUN_INDEX_FILENAME, RUNS_DIRNAME } from "./run-namespace.js";
93
97
  import { MAX_OPEN_ASSERTIONS, validateAssertionBatch } from "./assertion-ledger.js";
94
98
  import { DEFAULT_PROVIDER_LIMITS, createProviderSemaphore, parseProviderLimits } from "./provider-semaphore.js";
95
- import { PEER_READY_TIMEOUT_MS, peerReadyDelayMs, peerReadyVerdict, unaddressedPeerSweep } from "./spawned-peers.js";
99
+ import {
100
+ PANE_PROMPT_TIMEOUT_MS,
101
+ PEER_READY_TIMEOUT_MS,
102
+ launchPeerInPane,
103
+ peerReadyDelayMs,
104
+ peerReadyVerdict,
105
+ spawnStaggerSeconds,
106
+ unaddressedPeerSweep,
107
+ } from "../lib/spawned-peers.js";
96
108
  import { contextPct, estimatePromptTokens, overWindowDiagnostic, resolveContextWindow, shouldRecycleBeforeSpawn } from "./context-window.js";
97
109
  import { DEFAULT_WATCHDOG_SETTING, WATCHDOG_SETTINGS, buildJudgePrompt, createDriftMonitor, hubOwnedScopeGlobs, normalizeWatchdogSetting, parseJudgeVerdict, resolveWatchdogActive } from "./drift-watchdog.js";
98
110
  import { forceQuarantineSession, isCorruptSessionExit, quarantineIfUnusable } from "./session-health.js";
@@ -105,7 +117,7 @@ import { comsRequiredRefusal, parseDispatchPolicy, resolveDispatchBackend } from
105
117
  import { DEFAULT_RESEARCH_KEEP, parseResearchKeep, selectResearchPrunable } from "./research-retention.js";
106
118
  import { requireSafetyHarness, resolveSafetyHarness } from "./safety-routing.ts";
107
119
  import { createAccessApprovalRouter } from "./access-approval.ts";
108
- import { readdirSync, readFileSync, existsSync, mkdirSync, renameSync, unlinkSync, writeFileSync, rmSync } from "fs";
120
+ import { chmodSync, readdirSync, readFileSync, existsSync, mkdirSync, renameSync, unlinkSync, writeFileSync, rmSync } from "fs";
109
121
  import {
110
122
  HerdrAgentWatch,
111
123
  HerdrPresence,
@@ -116,7 +128,9 @@ import {
116
128
  } from "../lib/herdr-presence.ts";
117
129
  import { herdr as herdrApi, herdrAvailable } from "../lib/herdr-client.ts";
118
130
  import { buildLiveRegistryEntry, type ComsRegistryEntry } from "../lib/coms-registry-entry.ts";
119
- import { peerCommand } from "../../../scripts/lib/herdr-layout.ts";
131
+ import { findPeerByName, parseEnvFile, parsePeersYaml, peerCommand, resolveEnvFilePath } from "../../../scripts/lib/herdr-layout.ts";
132
+ import { DEFAULT_PROJECT } from "../../../scripts/lib/team-project.ts";
133
+ import { STAGGER_ENV_VAR, WARMUP_SECONDS, oauthNeedsWarmup } from "../../../scripts/lib/spawn-stagger.ts";
120
134
  import { join, resolve } from "path";
121
135
  import * as net from "node:net";
122
136
  import * as fs from "node:fs";
@@ -439,6 +453,11 @@ function extractNeedsResearch(output: string): string[] {
439
453
  // watchdog-judge-model: <model spec> — model for the drift judge (default:
440
454
  // the researcher persona's model, else the
441
455
  // dispatcher's).
456
+ // run-history-keep: <n>|off — how many previous sessions' artifact archives to
457
+ // retain under .pi/agent-sessions/runs/ (default 10).
458
+ // Each session archives the previous one's artifacts
459
+ // into an immutable runs/<runId>/ namespace instead of
460
+ // deleting them; "off" retains every run.
442
461
 
443
462
  interface AgentTeamOverrides {
444
463
  language: string;
@@ -464,6 +483,9 @@ interface AgentTeamOverrides {
464
483
  };
465
484
  watchdogSetting: string;
466
485
  watchdogJudgeModel: string | null;
486
+ // How many previous sessions' artifact archives to keep under
487
+ // .pi/agent-sessions/runs/ (run-namespace.js). null = keep everything.
488
+ runHistoryKeep: number | null;
467
489
  warnings: string[];
468
490
  }
469
491
 
@@ -483,6 +505,7 @@ const DEFAULT_OVERRIDES: AgentTeamOverrides = {
483
505
  budgetOverrides: {},
484
506
  watchdogSetting: DEFAULT_WATCHDOG_SETTING,
485
507
  watchdogJudgeModel: null,
508
+ runHistoryKeep: DEFAULT_RUN_HISTORY_KEEP,
486
509
  warnings: [],
487
510
  };
488
511
 
@@ -535,6 +558,14 @@ function parseAgentTeamOverrides(cwd: string): AgentTeamOverrides {
535
558
  if (key === "docs" && value) {
536
559
  result.docsPaths = value.split(",").map(s => s.trim()).filter(Boolean);
537
560
  }
561
+ if (key === "run-history-keep" && value) {
562
+ const keep = normalizeRunHistoryKeep(value);
563
+ if (keep === undefined) {
564
+ result.warnings.push(`run-history-keep "${value}" is not a positive integer or "off" — using the default (${DEFAULT_RUN_HISTORY_KEEP})`);
565
+ } else {
566
+ result.runHistoryKeep = keep;
567
+ }
568
+ }
538
569
  if (key === "research-keep" && value) {
539
570
  const keep = parseResearchKeep(value);
540
571
  if (keep != null) {
@@ -2055,14 +2086,48 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2055
2086
  let budgetOverrides: AgentTeamOverrides["budgetOverrides"] = {};
2056
2087
  let turnDispatchCount = 0;
2057
2088
  let turnResearchCount = 0;
2058
- // Task tier (complexity triage): declared by the dispatcher via set_task_tier,
2059
- // reset each user turn. Null until declared; the first dispatch of a turn
2060
- // assumes DEFAULT_TASK_TIER outside strict mode. Caps = min(mode, tier).
2061
- let turnTaskTier: string | null = null;
2089
+ // ── Task-scoped budget & tier (run-budget.js) ──
2090
+ // A per-message allowance cannot bound a task: every steering message opened a
2091
+ // fresh turn window, so a run could spend 8 dispatches and 60 minutes again and
2092
+ // again without any counter ever binding. These counters span the whole TASK
2093
+ // and are cleared only by an explicit new task (/af-new-task or
2094
+ // set_task_tier `new_task: true`) — not by a user message.
2095
+ let taskDispatchCount = 0;
2096
+ let taskResearchCount = 0;
2097
+ let taskLabel: string | null = null;
2098
+ // The task clock charges ACTIVE time only — turns that ran, minus the time the
2099
+ // dispatcher spent blocked on ask_user. Raw wall clock would bill the human's
2100
+ // lunch break, an overnight pause, and every long answer against the task, and
2101
+ // at fast mode's 45-minute envelope that hard-stops a task with two dispatches
2102
+ // spent. A false stop is worse than no stop: it teaches people to reset the
2103
+ // task window reflexively, which is the one thing that must stay deliberate.
2104
+ // `taskActiveMs` accumulates finished turns; the open turn is added at check time.
2105
+ let taskActiveMs = 0;
2106
+ let turnAskUserWaitMs = 0;
2107
+ // Review dispatches spent on this task (review-round cap).
2108
+ let taskReviewRounds = 0;
2109
+ // Task tier (complexity triage): declared by the dispatcher via set_task_tier.
2110
+ // TASK-scoped, not turn-scoped, and it moves by ratchet — down freely, up only
2111
+ // with a stated reason (applyTierChange). Null until declared; the first
2112
+ // dispatch assumes DEFAULT_TASK_TIER outside strict mode. Caps = min(mode, tier).
2113
+ let taskTier: string | null = null;
2114
+ // Was the tier ASSUMED by the hub rather than declared by the dispatcher? The
2115
+ // distinction matters to the ratchet: an assumed tier must not turn the
2116
+ // dispatcher's own first triage call into an "escalation" that needs a reason.
2117
+ let taskTierAssumed = false;
2062
2118
  // Duplicate-dispatch guard: fingerprints of (agent, task) already dispatched
2063
2119
  // THIS turn. Auto-research resumes and /af-agents-restart call dispatchAgent
2064
2120
  // directly, so only real dispatcher tool calls are guarded.
2065
2121
  const turnDispatchFingerprints = new Set<string>();
2122
+ // ── External-blocker circuit breaker (external-blocker.js) ──
2123
+ // Set when a specialist reports it needs something outside the fleet's reach;
2124
+ // gates the next dispatch until the human has been addressed. Cleared by an
2125
+ // ask_user call, by a new user turn (the human spoke), and by a new task.
2126
+ let externalBlockers: { agent: string; what: string }[] = [];
2127
+ let externalBlockerAcknowledged = false;
2128
+ let externalBlockerRefusedOnce = false;
2129
+ // Per-run artifact archive retention (run-namespace.js).
2130
+ let runHistoryKeep: number | null = DEFAULT_RUN_HISTORY_KEEP;
2066
2131
  // ── Drift watchdog (drift-watchdog.js) ──
2067
2132
  // Hub-wide setting from the overrides file, live-switchable via /af-watchdog;
2068
2133
  // per-agent overrides ("on"/"off") win over it; a dispatch_agent `watchdog`
@@ -2071,13 +2136,81 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2071
2136
  let watchdogJudgeModel: string | null = null;
2072
2137
  const watchdogAgentOverrides = new Map<string, "on" | "off">();
2073
2138
  function currentBudget() {
2074
- return resolveTurnBudget(hubMode, budgetOverrides, turnTaskTier);
2139
+ return resolveTurnBudget(hubMode, budgetOverrides, taskTier);
2140
+ }
2141
+ function currentTaskBudget() {
2142
+ return resolveTaskBudget(currentBudget());
2143
+ }
2144
+ function taskCounters() {
2145
+ return { dispatches: taskDispatchCount, research: taskResearchCount };
2146
+ }
2147
+ /**
2148
+ * Active time spent on this task: finished turns plus the open turn, each
2149
+ * minus its ask_user waits. An ask_user still in flight is subtracted too, so
2150
+ * the clock does not tick while the dispatcher sits at a question.
2151
+ */
2152
+ function taskActiveElapsedMs(): number {
2153
+ let openWait = 0;
2154
+ const now = Date.now();
2155
+ for (const startedAt of askUserStarts.values()) openWait += Math.max(0, now - startedAt);
2156
+ return taskActiveMs + turnActiveMs(currentTurnStartedAt, now, turnAskUserWaitMs + openWait);
2157
+ }
2158
+ /** Fold the turn that is ending into the task's active-time accumulator. */
2159
+ function closeTurnActiveTime() {
2160
+ if (!currentTurnStartedAt) return;
2161
+ taskActiveMs += turnActiveMs(currentTurnStartedAt, Date.now(), turnAskUserWaitMs);
2162
+ turnAskUserWaitMs = 0;
2163
+ }
2164
+ /** Clear the task window: counters, tier, clock, review rounds, blocker breaker. */
2165
+ function resetTaskWindow(label: string | null = null) {
2166
+ taskDispatchCount = 0;
2167
+ taskResearchCount = 0;
2168
+ taskActiveMs = 0;
2169
+ turnAskUserWaitMs = 0;
2170
+ taskReviewRounds = 0;
2171
+ taskLabel = label;
2172
+ taskTier = null;
2173
+ taskTierAssumed = false;
2174
+ externalBlockers = [];
2175
+ externalBlockerAcknowledged = false;
2176
+ externalBlockerRefusedOnce = false;
2177
+ turnDispatchFingerprints.clear();
2178
+ updateModeStatus();
2075
2179
  }
2076
2180
  function updateModeStatus() {
2077
2181
  try {
2078
- widgetCtx?.ui?.setStatus("hub-mode", budgetStatusLine(hubMode, { dispatches: turnDispatchCount, research: turnResearchCount }, currentBudget(), turnTaskTier));
2182
+ widgetCtx?.ui?.setStatus(
2183
+ "hub-mode",
2184
+ budgetStatusLine(
2185
+ hubMode,
2186
+ { dispatches: turnDispatchCount, research: turnResearchCount },
2187
+ currentBudget(),
2188
+ // A trailing "?" marks a tier the hub assumed rather than one the
2189
+ // dispatcher declared — the human can see that triage was skipped.
2190
+ taskTier && taskTierAssumed ? `${taskTier}?` : taskTier,
2191
+ { counters: taskCounters(), budget: currentTaskBudget() },
2192
+ ),
2193
+ );
2079
2194
  } catch {}
2080
2195
  }
2196
+ /**
2197
+ * The two gates that must run BEFORE any budget is charged, in severity
2198
+ * order: an unacknowledged external blocker, then the tier's persona gate.
2199
+ * Returns the refusal text, or null when the call may proceed.
2200
+ */
2201
+ function preflightGate(persona: string): { reason: string; message: string } | null {
2202
+ const blocked = checkExternalBlockerGate({
2203
+ blockers: externalBlockers,
2204
+ acknowledged: externalBlockerAcknowledged,
2205
+ askUserAvailable,
2206
+ refusedOnce: externalBlockerRefusedOnce,
2207
+ });
2208
+ if (blocked) {
2209
+ externalBlockerRefusedOnce = true;
2210
+ return blocked;
2211
+ }
2212
+ return checkTierPersonaGate(taskTier, persona);
2213
+ }
2081
2214
  // ── Per-turn cost report (/af-hub-report) ──
2082
2215
  interface TurnReport {
2083
2216
  startedAt: number;
@@ -2213,6 +2346,68 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2213
2346
  return root;
2214
2347
  }
2215
2348
 
2349
+ /**
2350
+ * Move the PREVIOUS session's artifacts into `runs/<runId>/artifacts/` — a
2351
+ * namespace written once and never reused — record it in `runs/index.json`,
2352
+ * and prune to `run-history-keep` archives. Best-effort throughout: failing to
2353
+ * archive must never stop a session from starting, but it must also never
2354
+ * silently fall back to deleting the artifacts.
2355
+ */
2356
+ function archivePreviousRun(): string | null {
2357
+ const root = artifactsRoot();
2358
+ if (!existsSync(root)) return null;
2359
+ let counts: Record<string, number> = {};
2360
+ let total = 0;
2361
+ try {
2362
+ for (const kind of ARTIFACT_KINDS) {
2363
+ const dir = safePathWithin(root, kind);
2364
+ if (!existsSync(dir)) continue;
2365
+ const n = readdirSync(dir).length;
2366
+ if (n > 0) counts[kind] = n;
2367
+ total += n;
2368
+ }
2369
+ } catch { /* unreadable tree — fall through and try the move anyway */ }
2370
+ if (total === 0) {
2371
+ // Nothing worth keeping: an empty layout is not history.
2372
+ try { rmSync(root, { recursive: true, force: true }); } catch {}
2373
+ return null;
2374
+ }
2375
+ const runId = makeRunId();
2376
+ try {
2377
+ const runsDir = safePathWithin(sessionDir, RUNS_DIRNAME);
2378
+ const runDir = safePathWithin(runsDir, runId);
2379
+ mkdirSync(runDir, { recursive: true });
2380
+ renameSync(root, safePathWithin(runDir, "artifacts"));
2381
+ const meta = buildRunMeta({
2382
+ runId,
2383
+ archivedAt: Date.now(),
2384
+ cwd: sessionDir,
2385
+ project: process.env.PI_COMS_PROJECT || null,
2386
+ workspace: process.env.HERDR_WORKSPACE_ID || null,
2387
+ artifactCounts: counts,
2388
+ });
2389
+ const metaPath = safePathWithin(runDir, "meta.json");
2390
+ writeFileSync(metaPath, JSON.stringify(meta, null, 2));
2391
+ // Written once, never rewritten: make that a file mode, not a promise.
2392
+ try { chmodSync(metaPath, 0o444); } catch {}
2393
+
2394
+ const indexPath = safePathWithin(runsDir, RUN_INDEX_FILENAME);
2395
+ let existing: any = null;
2396
+ try { existing = JSON.parse(readFileSync(indexPath, "utf-8")); } catch {}
2397
+ const index = appendRunIndex(existing, { runId, archivedAt: meta.archivedAt, artifactCounts: counts, project: meta.project, workspace: meta.workspace }, runHistoryKeep);
2398
+ writeFileSync(indexPath, JSON.stringify(index, null, 2));
2399
+
2400
+ for (const stale of pruneRunDirs(readdirSync(runsDir), runHistoryKeep)) {
2401
+ try { rmSync(safePathWithin(runsDir, stale), { recursive: true, force: true }); } catch {}
2402
+ }
2403
+ return runId;
2404
+ } catch {
2405
+ // The archive failed. Leave the artifacts exactly where they are rather
2406
+ // than deleting them — a stale tree is recoverable, a deleted one is not.
2407
+ return null;
2408
+ }
2409
+ }
2410
+
2216
2411
  function loadInputArtifacts(paths: string[] | undefined, ctx: any): InputArtifactPreview[] {
2217
2412
  if (!paths || paths.length === 0) return [];
2218
2413
  const root = ensureArtifactsLayout();
@@ -2371,7 +2566,13 @@ APIs, commands, structure), say so in your final response so the docs can be upd
2371
2566
  // dirs (delegate children's events + sessions).
2372
2567
  try { rmSync(safePathWithin(sessionDir, "findings"), { recursive: true, force: true }); } catch {}
2373
2568
  try { rmSync(safePathWithin(sessionDir, "delegations"), { recursive: true, force: true }); } catch {}
2374
- try { rmSync(safePathWithin(sessionDir, "artifacts"), { recursive: true, force: true }); } catch {}
2569
+ // Artifacts are NOT ephemeral, and deleting them here is what made a
2570
+ // post-mortem record eleven specialist returns and two reviews as NOT
2571
+ // RECOVERABLE: the next session's `builder-run1.md` reused the same path as
2572
+ // the previous session's, and the wipe removed the originals first. Archive
2573
+ // the previous session's artifacts into an immutable per-run namespace
2574
+ // instead, then start this session with an empty tree.
2575
+ archivePreviousRun();
2375
2576
  ensureArtifactsLayout();
2376
2577
  // The assertion ledger is per-task and as ephemeral as the session that owns
2377
2578
  // it — wipe on session start like findings/, then start with an empty ledger.
@@ -3138,6 +3339,7 @@ APIs, commands, structure), say so in your final response so the docs can be upd
3138
3339
  ## Dispatch protocol (agent-hub)
3139
3340
  You are serving a dispatched task as a standing peer; the dispatcher only receives this reply, so make it your complete final answer.
3140
3341
  - Clarification: if you need a HUMAN decision (ambiguity, missing input, contradiction, or a destructive/irreversible next step), do NOT guess — include line(s) of the form \`ASK_USER: <one clear English question>\`; you will be re-dispatched with the answers.
3342
+ ${externalBlockedProtocol()}
3141
3343
  - Deliverable-to-file: when your deliverable is a document (plan, review, critique, inventory, report) and your tools allow writing, write the full document to .pi/agent-sessions/artifacts/<kind>/${agentKey}-run${runNumber}.md (kinds: plans, reviews, inventories, evidence) — never repo-root ./artifacts/... — and finish with the artifact-relative path (artifacts/<kind>/${agentKey}-run${runNumber}.md) plus a digest of at most 10 lines.
3142
3344
  - If the task includes acceptance assertions (A1, A2, ...), include the structured return from skills/orchestration-verification/SKILL.md.` +
3143
3345
  buildRulesProtocol() + buildDocsProtocol();
@@ -3538,6 +3740,9 @@ You may emit multiple ASK_USER lines if you have several questions. The dispatch
3538
3740
  will surface each to the human user in ${userLanguage} and re-dispatch you with the
3539
3741
  answers. Do not invent values, do not pick "reasonable defaults" silently — ask.
3540
3742
 
3743
+ ## External-blocker protocol
3744
+ ${externalBlockedProtocol()}
3745
+
3541
3746
  ## Research protocol
3542
3747
  If you need reconnaissance you cannot perform with your own tools (broad code search,
3543
3748
  reading unfamiliar areas of the codebase, summarizing docs), DO NOT guess and DO NOT
@@ -4825,21 +5030,56 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
4825
5030
  artifacts: Type.Optional(Type.Array(Type.String({ description: "Optional repo-relative or session-artifact-relative input artifact path. The hub injects only path + one-line preview; the specialist must read the file itself." }))),
4826
5031
  scope: Type.Optional(Type.Array(Type.String({ description: "Optional advisory file scope globs for writable agents. Changes outside are reported in details.scopeViolations; nothing is auto-reverted. Also arms the drift watchdog's live out-of-scope rule." }))),
4827
5032
  watchdog: Type.Optional(Type.Boolean({ description: "Force the drift watchdog on/off for THIS dispatch (default: per-agent /af-watchdog override, then the hub-wide setting)." })),
5033
+ review_reason: Type.Optional(Type.String({ description: "Why a documentation-only change needs a review gate (e.g. it publishes a credential, or states a contract other systems rely on). Only needed when dispatching a review persona with a docs-only `scope`." })),
4828
5034
  }),
4829
5035
 
4830
5036
  async execute(_toolCallId, params, _signal, onUpdate, ctx) {
4831
- const { task, artifacts, scope, watchdog } = params as { agent: string; task: string; artifacts?: string[]; scope?: string[]; watchdog?: boolean };
5037
+ const { task, artifacts, scope, watchdog, review_reason } = params as { agent: string; task: string; artifacts?: string[]; scope?: string[]; watchdog?: boolean; review_reason?: string };
4832
5038
  // Display names / underscores resolve to the persona slug key space, so
4833
5039
  // `agent: "Test Engineer"` never burns a dispatch on a lookup error.
4834
5040
  const agent = normalizeAgentInput((params as { agent: string }).agent);
4835
- // Unclassified turn: assume the default tier (outside strict, whose full
5041
+ // Unclassified task: assume the default tier (outside strict, whose full
4836
5042
  // contract runs uncapped by tiers). The prompt asks for set_task_tier
4837
5043
  // FIRST; this is the fail-safe, not the intended path.
4838
- if (turnTaskTier === null && hubMode !== "strict") {
4839
- turnTaskTier = DEFAULT_TASK_TIER;
4840
- turnReport.tier = turnTaskTier;
5044
+ if (taskTier === null && hubMode !== "strict") {
5045
+ taskTier = DEFAULT_TASK_TIER;
5046
+ taskTierAssumed = true;
5047
+ turnReport.tier = taskTier;
4841
5048
  updateModeStatus();
4842
5049
  }
5050
+ // Pre-flight refusals, in severity order, BEFORE anything is charged: an
5051
+ // unacknowledged external blocker, the tier's persona gate, the review-round
5052
+ // cap, then the docs-only lane. None of these reached a specialist, so none
5053
+ // of them costs a budget slot.
5054
+ const preflight = preflightGate(agent)
5055
+ ?? checkReviewRoundCap(taskTier, agent, taskReviewRounds)
5056
+ ?? checkDocsLane(agent, scope || [], review_reason);
5057
+ if (preflight) {
5058
+ turnReport.refusals++;
5059
+ sessionTotals.refusals++;
5060
+ return {
5061
+ content: [{ type: "text", text: preflight.message }],
5062
+ details: { agent, task, status: preflight.reason, reason: preflight.reason, elapsed: 0, exitCode: 1, fullOutput: "" },
5063
+ };
5064
+ }
5065
+ // Task-budget gate: the outer bound a turn window never provided. Checked
5066
+ // BEFORE the turn budget because it is the more severe stop — a new user
5067
+ // message reopens the turn window but not the task window.
5068
+ const taskRefusal = checkTaskBudget(
5069
+ "dispatch",
5070
+ taskCounters(),
5071
+ currentTaskBudget(),
5072
+ taskActiveElapsedMs(),
5073
+ taskTier,
5074
+ );
5075
+ if (taskRefusal) {
5076
+ turnReport.refusals++;
5077
+ sessionTotals.refusals++;
5078
+ return {
5079
+ content: [{ type: "text", text: taskRefusal.message }],
5080
+ details: { agent, task, status: "task_budget_refused", reason: taskRefusal.reason, elapsed: 0, exitCode: 1, fullOutput: "" },
5081
+ };
5082
+ }
4843
5083
  // Turn-budget gate: refuse BEFORE any spawn. The dispatcher must stop,
4844
5084
  // summarize, and ask the user; a new user turn opens a fresh window.
4845
5085
  const budgetRefusal = checkTurnBudget(
@@ -4887,6 +5127,8 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
4887
5127
  };
4888
5128
  }
4889
5129
  turnDispatchCount++;
5130
+ taskDispatchCount++;
5131
+ if (isReviewPersona(agent)) taskReviewRounds++;
4890
5132
  sessionTotals.dispatches++;
4891
5133
  updateModeStatus();
4892
5134
  let writableTracked = false;
@@ -4917,7 +5159,14 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
4917
5159
  scopeSnapshot = snapshotWorktree(ctx.cwd || process.cwd());
4918
5160
  }
4919
5161
 
4920
- let result = await dispatchAgent(agent, task, ctx, inputArtifacts, scopeGlobs, watchdog);
5162
+ // A review is a gate, and a gate has a size. Unbounded review authority
5163
+ // ratchets: each round's findings become plan invariants, and the larger
5164
+ // plan justifies another round. The cap binds BLOCKING findings only —
5165
+ // everything else is still reported, just not as a gate.
5166
+ const findingClause = reviewBudgetClause(taskTier, agent);
5167
+ const dispatchedTask = findingClause ? `${task}\n\n${findingClause}` : task;
5168
+
5169
+ let result = await dispatchAgent(agent, dispatchedTask, ctx, inputArtifacts, scopeGlobs, watchdog);
4921
5170
  let dispatchBilled = result.billed ?? 0;
4922
5171
  let dispatchOut = result.out ?? 0;
4923
5172
 
@@ -4927,9 +5176,25 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
4927
5176
  // session with the paths. The dispatcher only ever sees a short notice,
4928
5177
  // keeping its context clean of raw findings.
4929
5178
  const researchRounds: { questions: string[]; files: string[] }[] = [];
5179
+ let autoResearchTaskCapped = false;
4930
5180
  while (result.exitCode === 0 && researchRounds.length < MAX_AUTO_RESEARCH_ROUNDS) {
4931
- const researchQs = extractNeedsResearch(result.output).slice(0, MAX_AUTO_RESEARCH_QUESTIONS);
5181
+ // The auto-pipe is exempt from the TURN budget (it is hub mechanics,
5182
+ // not a dispatcher decision, and must not steal the dispatcher's
5183
+ // slots) but NOT from the TASK envelope. At 2 rounds x 4 questions per
5184
+ // dispatch and 18 dispatches per task, leaving it uncounted would put
5185
+ // 144 research runs inside the bound that is meant to be the outer one.
5186
+ const researchLeft = remainingTaskResearch(currentTaskBudget(), taskCounters());
5187
+ if (researchLeft === 0) {
5188
+ autoResearchTaskCapped = true;
5189
+ break;
5190
+ }
5191
+ const questionCap = researchLeft == null
5192
+ ? MAX_AUTO_RESEARCH_QUESTIONS
5193
+ : Math.min(MAX_AUTO_RESEARCH_QUESTIONS, researchLeft);
5194
+ const researchQs = extractNeedsResearch(result.output).slice(0, questionCap);
4932
5195
  if (researchQs.length === 0) break;
5196
+ taskResearchCount += researchQs.length;
5197
+ updateModeStatus();
4933
5198
 
4934
5199
  if (onUpdate) {
4935
5200
  onUpdate({
@@ -5053,6 +5318,12 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5053
5318
  ? `\n\n⚠ ${agent} still requests research (${unresolved.length} question(s)) but the auto-research budget is exhausted. ` +
5054
5319
  `Run spawn_research yourself and re-dispatch with the findings, or simplify the task.`
5055
5320
  : "";
5321
+ const autoResearchTaskNotice = autoResearchTaskCapped
5322
+ ? `\n\n⚠ ${agent} paused for research, but the TASK research envelope is spent ` +
5323
+ `(${taskResearchCount}/${currentTaskBudget().maxResearch}) — no helper was spawned and the specialist ` +
5324
+ `was not resumed. Its questions are unanswered. Narrow the task so it can proceed on what it has, ` +
5325
+ `or open a new task window with /af-new-task if this is genuinely different work.`
5326
+ : "";
5056
5327
 
5057
5328
  const returnPathNotice = returnPath ? `\n\nFull specialist output: ${returnPath}` : "";
5058
5329
  // Named as a delivery failure, not a result: the run did not answer.
@@ -5079,6 +5350,42 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5079
5350
  : "";
5080
5351
  const scopeNotice = scopeNoticeText(scopeViolations);
5081
5352
  const contractNotice = contractNoticeText(contractNotices);
5353
+ // External blockers arm the circuit breaker: the NEXT dispatch is refused
5354
+ // until the human has been addressed. Recording it here (not in the
5355
+ // dispatcher's reading of the prose) is the point — a blocker that only
5356
+ // exists in a summary gets routed around.
5357
+ const reportedBlockers = extractExternalBlockers(result.output);
5358
+ let externalBlockerNotice = "";
5359
+ if (reportedBlockers.length > 0) {
5360
+ for (const what of reportedBlockers) {
5361
+ if (!externalBlockers.some(b => b.what === what)) externalBlockers.push({ agent, what });
5362
+ }
5363
+ externalBlockerAcknowledged = false;
5364
+ externalBlockerRefusedOnce = false;
5365
+ externalBlockerNotice = `\n\n⛔ ${agent} reported an EXTERNAL BLOCKER — something outside the fleet's reach is missing:\n` +
5366
+ reportedBlockers.map((w, i) => ` ${i + 1}. ${w}`).join("\n") +
5367
+ `\nThe next dispatch/research call is refused until you escalate this to the human. ` +
5368
+ `Do not build a substitute for the missing fact.`;
5369
+ }
5370
+ // Review accounting: count what came back and say so when it exceeds the
5371
+ // tier's cap. The hub does NOT reclassify findings — no rule it can
5372
+ // evaluate tells "invents a manifest" from "this leaks a credential",
5373
+ // and demoting the second by position is worse than tolerating the
5374
+ // first. The enforcement is the review-ROUND cap above, which needs no
5375
+ // judgement about content.
5376
+ let findingNotice = "";
5377
+ if (isReviewPersona(agent)) {
5378
+ findingNotice = findingBudgetNotice(
5379
+ agent,
5380
+ blockingFindingCap(taskTier),
5381
+ countReviewFindings(result.output),
5382
+ taskReviewRounds,
5383
+ reviewRoundCap(taskTier),
5384
+ ) || "";
5385
+ }
5386
+ // A documentation-only dispatch closes on the writer's own verification.
5387
+ const docsNotice = docsLaneNotice(agent, scopeGlobs);
5388
+ const docsLaneText = docsNotice ? `\n\n${docsNotice}` : "";
5082
5389
  // An extracted block is labelled every time it is shown: it was restated
5083
5390
  // by a cheap pass, not declared by the specialist, and it must never be
5084
5391
  // mistaken for first-hand evidence when gating on it.
@@ -5091,7 +5398,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5091
5398
  : truncated;
5092
5399
 
5093
5400
  return {
5094
- content: [{ type: "text", text: `${summary}${questionsNotice}${researchNotice}${budgetNotice}${returnPathNotice}${pendingNotice}${failurePathNotice}${artifactKindNotice}${contextNotice}${scopeNotice}\n\n${digest}` }],
5401
+ content: [{ type: "text", text: `${summary}${externalBlockerNotice}${questionsNotice}${researchNotice}${budgetNotice}${autoResearchTaskNotice}${returnPathNotice}${pendingNotice}${failurePathNotice}${artifactKindNotice}${contextNotice}${scopeNotice}${findingNotice}${docsLaneText}\n\n${digest}` }],
5095
5402
  details: {
5096
5403
  agent,
5097
5404
  task,
@@ -5193,6 +5500,34 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5193
5500
  async execute(_toolCallId, params, _signal, onUpdate, ctx) {
5194
5501
  const { task, persona, model, artifacts } = params as { task: string; persona?: string; model?: string; artifacts?: string[] };
5195
5502
 
5503
+ // Pre-flight refusals before anything is charged: an unacknowledged
5504
+ // external blocker, then the tier's persona gate (deep-researcher is the
5505
+ // most expensive helper in the system and is not a trivial-tier tool).
5506
+ const preflight = preflightGate(persona || "");
5507
+ if (preflight) {
5508
+ turnReport.refusals++;
5509
+ sessionTotals.refusals++;
5510
+ return {
5511
+ content: [{ type: "text", text: preflight.message }],
5512
+ details: { status: preflight.reason, reason: preflight.reason },
5513
+ };
5514
+ }
5515
+ // Task-budget gate: checked before the turn budget (the more severe stop).
5516
+ const taskRefusal = checkTaskBudget(
5517
+ "research",
5518
+ taskCounters(),
5519
+ currentTaskBudget(),
5520
+ taskActiveElapsedMs(),
5521
+ taskTier,
5522
+ );
5523
+ if (taskRefusal) {
5524
+ turnReport.refusals++;
5525
+ sessionTotals.refusals++;
5526
+ return {
5527
+ content: [{ type: "text", text: taskRefusal.message }],
5528
+ details: { status: "task_budget_refused", reason: taskRefusal.reason },
5529
+ };
5530
+ }
5196
5531
  // Turn-budget gate (dispatcher-initiated research only — the auto-research
5197
5532
  // pipe and the /af-research command are exempt).
5198
5533
  const budgetRefusal = checkTurnBudget(
@@ -5246,6 +5581,7 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5246
5581
  }
5247
5582
 
5248
5583
  turnResearchCount++;
5584
+ taskResearchCount++;
5249
5585
  turnReport.research++;
5250
5586
  sessionTotals.research++;
5251
5587
  updateModeStatus();
@@ -5342,28 +5678,42 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5342
5678
  name: "set_task_tier",
5343
5679
  label: "Set Task Tier",
5344
5680
  description:
5345
- "Classify THIS user turn's ask before your first dispatch: trivial (one obvious, low-risk change — 1 dispatch), small (a contained change, no planning pipeline — 2 dispatches), feature (a normal multi-step feature — 6 dispatches), project (a large effort — mode budget applies). The hub enforces the resulting caps; re-call it if the ask turns out bigger than classified (raising the tier mid-turn is allowed and cheap — say why).",
5681
+ "Classify the CURRENT TASK before your first dispatch: trivial (one obvious, low-risk change — 1 dispatch), small (a contained change, no planning pipeline — 2 dispatches), feature (a normal multi-step feature — 6 dispatches), project (a large effort — mode budget applies). The tier persists across user messages and moves by ratchet: LOWERING it is always free, RAISING it requires `reason` naming what the ask turned out to contain. Pass `new_task: true` only when the human has moved on to a genuinely different piece of work — it also resets the task budget.",
5346
5682
  parameters: Type.Object({
5347
5683
  tier: Type.String({ description: "One of: trivial | small | feature | project" }),
5348
- reason: Type.Optional(Type.String({ description: "One line on why this tier fits the ask." })),
5684
+ reason: Type.Optional(Type.String({ description: "One line on why this tier fits the ask. REQUIRED when raising the tier above the current one." })),
5685
+ new_task: Type.Optional(Type.Boolean({ description: "The human moved on to a different piece of work: clears the task budget, the tier, and the duplicate guard. Not for a correction or a follow-up on the same work." })),
5349
5686
  }),
5350
5687
  async execute(_callId, params, _signal, _onUpdate, _ctx) {
5351
- const { tier, reason } = params as { tier: string; reason?: string };
5352
- const normalized = normalizeTaskTier(tier);
5353
- if (!normalized) {
5688
+ const { tier, reason, new_task } = params as { tier: string; reason?: string; new_task?: boolean };
5689
+ if (new_task) resetTaskWindow(null);
5690
+ // An ASSUMED tier is the hub's fail-safe, not a declaration to ratchet
5691
+ // against: the dispatcher's own first triage must not be refused as an
5692
+ // "escalation" for lacking a reason it had no way to know it needed.
5693
+ const change = applyTierChange(taskTierAssumed ? null : taskTier, tier, reason);
5694
+ if (!change.ok) {
5354
5695
  return {
5355
- content: [{ type: "text" as const, text: `Unknown tier "${tier}" — expected one of: ${TASK_TIERS.join(", ")}. Tier unchanged (${turnTaskTier ?? "unset"}).` }],
5356
- details: { status: "error", tier: turnTaskTier },
5696
+ content: [{ type: "text" as const, text: change.message }],
5697
+ details: { status: "error", reason: change.reason, tier: change.tier },
5357
5698
  };
5358
5699
  }
5359
- turnTaskTier = normalized;
5360
- turnReport.tier = normalized;
5700
+ taskTier = change.tier;
5701
+ taskTierAssumed = false;
5702
+ turnReport.tier = change.tier;
5361
5703
  updateModeStatus();
5362
5704
  const b = currentBudget();
5705
+ const tb = currentTaskBudget();
5363
5706
  const cap = (n: number | null) => (n == null ? "unlimited" : String(n));
5707
+ const spent = `${taskDispatchCount}/${cap(tb.maxDispatches)} dispatches, ${taskResearchCount}/${cap(tb.maxResearch)} research`;
5364
5708
  return {
5365
- content: [{ type: "text" as const, text: `Task tier: ${normalized}${reason ? ` (${reason})` : ""}. Effective caps this turn: ${cap(b.maxDispatches)} dispatches, ${cap(b.maxResearch)} research. Size the apparatus accordingly — do not spend a cap just because it exists.` }],
5366
- details: { status: "ok", tier: normalized },
5709
+ content: [{
5710
+ type: "text" as const,
5711
+ text: `${change.message}${new_task ? " (new task window opened)" : ""}\n` +
5712
+ `Per turn: ${cap(b.maxDispatches)} dispatches, ${cap(b.maxResearch)} research. ` +
5713
+ `Whole task: ${spent} spent. ` +
5714
+ `Size the apparatus accordingly — do not spend a cap just because it exists.`,
5715
+ }],
5716
+ details: { status: "ok", tier: change.tier, escalated: change.escalated, newTask: !!new_task },
5367
5717
  };
5368
5718
  },
5369
5719
  renderCall(args, theme) {
@@ -5963,11 +6313,56 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5963
6313
  }
5964
6314
  }
5965
6315
 
6316
+ /** When the last hub-spawned pi peer was launched — input to the stale-token stagger. */
6317
+ let lastHubPiSpawnAt: number | null = null;
6318
+
6319
+ /** Last lines of a pane, for reporting why a spawn failed. Never throws. */
6320
+ async function paneTail(paneId: string, lines = 12): Promise<string> {
6321
+ try {
6322
+ const { read } = await herdrApi.paneRead({ pane_id: paneId, lines });
6323
+ return read?.text ?? "";
6324
+ } catch {
6325
+ return "";
6326
+ }
6327
+ }
6328
+
6329
+ /**
6330
+ * The peers.yaml declaration for a peer name, when the repo has one. A hub
6331
+ * spawn is handed a bare name, but the fleet may define that name as a
6332
+ * `runner: claude-code` peer or one that needs extra extensions — launching
6333
+ * a plain pi peer instead would silently produce a different agent.
6334
+ */
6335
+ function declaredPeer(name: string): ReturnType<typeof findPeerByName> {
6336
+ const cwd = currentCtx?.cwd ?? process.cwd();
6337
+ try {
6338
+ const raw = fs.readFileSync(path.join(cwd, ".pi", "agents", "peers.yaml"), "utf-8");
6339
+ return findPeerByName(parsePeersYaml(raw), name);
6340
+ } catch {
6341
+ return undefined;
6342
+ }
6343
+ }
6344
+
6345
+ /** Seconds this spawn should sleep before launching pi (stale-OAuth lock race). */
6346
+ function spawnDelaySeconds(): number {
6347
+ let authRaw: string | undefined;
6348
+ try {
6349
+ authRaw = fs.readFileSync(path.join(os.homedir(), ".pi", "agent", "auth.json"), "utf-8");
6350
+ } catch {
6351
+ authRaw = undefined;
6352
+ }
6353
+ return spawnStaggerSeconds({
6354
+ needed: oauthNeedsWarmup(authRaw),
6355
+ lastSpawnAt: lastHubPiSpawnAt,
6356
+ now: Date.now(),
6357
+ warmupSeconds: WARMUP_SECONDS,
6358
+ });
6359
+ }
6360
+
5966
6361
  pi.registerTool({
5967
6362
  name: "herdr_spawn_peer",
5968
6363
  label: "Herdr Spawn Peer",
5969
6364
  description:
5970
- "Spawn a pane in the CURRENT herdr workspace: either a peers.yaml-style coms peer (persona [+ name/model], launched via `just _peer`) or a raw command pane. A persona peer boots IDLE and does nothing until you coms_send to it — spawning delivers no work. The call waits (bounded) for the peer to register and returns `peer_ready` plus its coms name, or `peer_ready: false` with the wait stated. Spawn one only immediately before the first message you will send it; a peer that receives no work is named in the session digest.",
6365
+ "Spawn a pane in the CURRENT herdr workspace: either a peers.yaml-style coms peer (persona [+ name/model], launched via `just _peer`) or a raw command pane. The peer joins THIS session's coms project pool, and a name declared in .pi/agents/peers.yaml keeps its declared runner/extensions. A persona peer boots IDLE and does nothing until you coms_send to it — spawning delivers no work. The call waits (bounded) for the peer to register and returns `peer_ready` plus its coms name, or `peer_ready: false` with the pane's last output — treat that as a failed start, not a slow one. Spawn one only immediately before the first message you will send it; a peer that receives no work is named in the session digest.",
5971
6366
  parameters: Type.Object({
5972
6367
  persona: Type.Optional(Type.String({ description: "Persona under agents/ (e.g. researcher). Omit for a raw command pane." })),
5973
6368
  name: Type.String({ description: "Pane label; for persona peers also the coms peer name." }),
@@ -5984,37 +6379,72 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
5984
6379
  return { content: [{ type: "text" as const, text: "not inside a herdr pane." }], details: { error: "no pane" } };
5985
6380
  }
5986
6381
  try {
6382
+ const cwd = currentCtx?.cwd ?? process.cwd();
6383
+ const env: Record<string, string> = {};
5987
6384
  let argv: string[];
5988
6385
  if (params.persona) {
5989
- argv = peerCommand({ persona: params.persona, name: params.name, model: params.model }, "hub-spawned");
6386
+ // The peer joins THIS hub's coms pool. Defaulting to "default"
6387
+ // (as this once did) puts it in a pool the hub cannot see, so it
6388
+ // never registers no matter how long the readiness wait runs.
6389
+ const declared = declaredPeer(params.name);
6390
+ argv = peerCommand(
6391
+ {
6392
+ persona: params.persona,
6393
+ name: params.name,
6394
+ model: params.model ?? declared?.model,
6395
+ extensions: declared?.extensions,
6396
+ runner: declared?.runner,
6397
+ },
6398
+ "hub-spawned",
6399
+ undefined,
6400
+ identity?.project ?? DEFAULT_PROJECT,
6401
+ );
6402
+ if (declared?.env_file) {
6403
+ Object.assign(env, parseEnvFile(fs.readFileSync(resolveEnvFilePath(declared.env_file, cwd), "utf-8"), declared.env_file));
6404
+ }
6405
+ const delay = declared?.runner === "claude-code" ? 0 : spawnDelaySeconds();
6406
+ if (delay > 0) env[STAGGER_ENV_VAR] = String(delay);
5990
6407
  } else if (params.command) {
5991
6408
  argv = ["bash", "-lc", params.command];
5992
6409
  } else {
5993
6410
  return { content: [{ type: "text" as const, text: "pass persona (peer) or command (raw pane)." }], details: { error: "bad args" } };
5994
6411
  }
6412
+ // pane.split takes no command — it opens a shell in `cwd`.
5995
6413
  const { pane } = await herdrApi.paneSplit({
5996
6414
  target_pane_id: ownPane,
5997
6415
  direction: params.direction ?? "right",
5998
- command: argv,
5999
- cwd: currentCtx?.cwd ?? process.cwd(),
6416
+ cwd,
6417
+ ...(Object.keys(env).length > 0 ? { env } : {}),
6000
6418
  focus: false,
6001
6419
  });
6002
6420
  try { await herdrApi.paneRename(pane.pane_id, params.name); } catch { /* cosmetic */ }
6421
+ // …so the argv is typed into that shell once it shows a prompt.
6422
+ const launch = await launchPeerInPane(herdrApi, pane.pane_id, argv);
6423
+ if (params.persona) lastHubPiSpawnAt = Date.now();
6424
+ const promptNote = launch.promptSeen
6425
+ ? ""
6426
+ : `\n⚠ pane ${pane.pane_id} showed no shell prompt within ${Math.round(PANE_PROMPT_TIMEOUT_MS / 1000)}s; the command was sent anyway.`;
6003
6427
  // A raw command pane is not a coms peer — nothing to wait for and
6004
6428
  // nothing to sweep. A persona peer is only useful once addressable,
6005
6429
  // so report that verdict instead of a bare pane id.
6006
6430
  if (!params.persona) {
6007
6431
  return {
6008
- content: [{ type: "text" as const, text: `spawned pane ${pane.pane_id} (${params.name}): ${argv.join(" ")}` }],
6009
- details: { pane_id: pane.pane_id, name: params.name },
6432
+ content: [{ type: "text" as const, text: `spawned pane ${pane.pane_id} (${params.name}): ${argv.join(" ")}${promptNote}` }],
6433
+ details: { pane_id: pane.pane_id, name: params.name, prompt_seen: launch.promptSeen },
6010
6434
  };
6011
6435
  }
6012
6436
  hubSpawnedPeers.set(params.name.toLowerCase(), { name: params.name, paneId: pane.pane_id, addressed: false });
6013
6437
  const { found, waitedMs } = await waitForPeerRegistration(params.name);
6014
- const verdict = peerReadyVerdict({ name: params.name, paneId: pane.pane_id, found, waitedMs });
6438
+ const verdict = peerReadyVerdict({
6439
+ name: params.name,
6440
+ paneId: pane.pane_id,
6441
+ found,
6442
+ waitedMs,
6443
+ paneTail: found ? undefined : await paneTail(pane.pane_id),
6444
+ });
6015
6445
  return {
6016
- content: [{ type: "text" as const, text: `spawned pane ${pane.pane_id} (${params.name}): ${argv.join(" ")}\n\n${verdict.message}` }],
6017
- details: { pane_id: pane.pane_id, name: params.name, ...verdict },
6446
+ content: [{ type: "text" as const, text: `spawned pane ${pane.pane_id} (${params.name}): ${argv.join(" ")}${promptNote}\n\n${verdict.message}` }],
6447
+ details: { pane_id: pane.pane_id, name: params.name, prompt_seen: launch.promptSeen, ...verdict },
6018
6448
  };
6019
6449
  } catch (err) {
6020
6450
  const m = err instanceof Error ? err.message : String(err);
@@ -6304,6 +6734,32 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
6304
6734
  },
6305
6735
  });
6306
6736
 
6737
+ // ── /af-new-task: open a fresh TASK window ──
6738
+ // The task budget is deliberately immune to a user message — a steering
6739
+ // message is a correction, not a new ask, and resetting on it is what let a
6740
+ // run spend a fresh envelope per correction. Opening a new window is
6741
+ // therefore an explicit, human decision, and this is where it is made.
6742
+ pi.registerCommand("af-new-task", {
6743
+ description: "Open a fresh task window: clears the task budget, the task tier, the duplicate guard, and any external-blocker stop. Use when moving on to different work — not for a correction to the current work.",
6744
+ handler: async (args, ctx) => {
6745
+ widgetCtx = ctx;
6746
+ const label = (args || "").trim() || null;
6747
+ const spentDispatches = taskDispatchCount;
6748
+ const spentResearch = taskResearchCount;
6749
+ const spentReviews = taskReviewRounds;
6750
+ const spentMin = Math.round(taskActiveElapsedMs() / 60_000);
6751
+ const priorTier = taskTier;
6752
+ resetTaskWindow(label);
6753
+ ctx.ui.notify(
6754
+ `New task window${label ? `: ${label}` : ""}\n` +
6755
+ `Previous task${priorTier ? ` (tier ${priorTier})` : ""} spent ${spentDispatches} dispatches, ` +
6756
+ `${spentResearch} research, ${spentReviews} review round(s), ${spentMin} min active.\n` +
6757
+ `Tier is unset — the dispatcher re-triages on its next dispatch.`,
6758
+ "success",
6759
+ );
6760
+ },
6761
+ });
6762
+
6307
6763
  pi.registerCommand("af-watchdog", {
6308
6764
  description: "Drift watchdog: /af-watchdog [on|off|auto] hub-wide, /af-watchdog <agent> [on|off|clear] per agent, no args to show",
6309
6765
  handler: async (args, ctx) => {
@@ -7560,12 +8016,20 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
7560
8016
  // ask_user call with its tool_execution start/end so /af-agents-history can subtract
7561
8017
  // that "away from keyboard" time from the dispatcher's real work.
7562
8018
  pi.on("tool_execution_start", async (event) => {
7563
- if (event.toolName === "ask_user") askUserStarts.set(event.toolCallId, Date.now());
8019
+ if (event.toolName !== "ask_user") return;
8020
+ askUserStarts.set(event.toolCallId, Date.now());
8021
+ // Asking the human IS the escalation the external-blocker breaker demands:
8022
+ // once it is under way, the gate opens.
8023
+ externalBlockerAcknowledged = true;
8024
+ externalBlockerRefusedOnce = false;
7564
8025
  });
7565
8026
  pi.on("tool_execution_end", async (event) => {
7566
8027
  if (event.toolName !== "ask_user") return;
7567
8028
  const startedAt = askUserStarts.get(event.toolCallId);
7568
8029
  askUserStarts.delete(event.toolCallId);
8030
+ // The task clock bills active time only — the human's answer is not the
8031
+ // fleet's work, and billing it is what would false-stop a steered session.
8032
+ if (startedAt) turnAskUserWaitMs += Math.max(0, Date.now() - startedAt);
7569
8033
  if (startedAt == null) return;
7570
8034
  const interval: [number, number] = [startedAt, Date.now()];
7571
8035
  // Attach to the live dispatcher entry, or buffer until one is created this turn.
@@ -7585,18 +8049,28 @@ Finish with the artifact-relative path plus a digest of no more than 10 lines. I
7585
8049
  currentOrchestratorEntry.endedAt = Date.now();
7586
8050
  if (currentOrchestratorEntry.status === "running") currentOrchestratorEntry.status = "done";
7587
8051
  }
8052
+ // Fold the turn that just ended into the task's active-time accumulator
8053
+ // before the clock is re-based; inter-turn idle is never charged because
8054
+ // no turn is open across it.
8055
+ closeTurnActiveTime();
7588
8056
  turnActive = true;
7589
8057
  currentTurnStartedAt = Date.now();
7590
8058
  currentOrchestratorEntry = null;
7591
8059
  askUserStarts.clear();
7592
8060
  turnAskUserIntervals.length = 0;
7593
- // Fresh turn → fresh budget window (mode itself persists across turns).
7594
- // The tier and the duplicate guard are turn-scoped too: a new user message
7595
- // is a new ask, so it re-triages and may legitimately repeat a task.
8061
+ // Fresh turn → fresh TURN budget window (mode persists across turns). The
8062
+ // TASK budget, the tier, and the external-blocker breaker deliberately do
8063
+ // NOT reset here: a steering message is a correction to the same work, not
8064
+ // a new ask, and resetting on it is precisely how a run spent eight fresh
8065
+ // dispatches per correction and never hit a bound. Only /af-new-task (or
8066
+ // set_task_tier `new_task: true`) opens a new task window.
7596
8067
  turnDispatchCount = 0;
7597
8068
  turnResearchCount = 0;
7598
- turnTaskTier = null;
7599
8069
  turnDispatchFingerprints.clear();
8070
+ // The human sent a message, so an external blocker has been surfaced to them
8071
+ // by definition — the breaker opens and re-arms on the next report.
8072
+ externalBlockerAcknowledged = true;
8073
+ externalBlockerRefusedOnce = false;
7600
8074
  // Snapshot the previous turn's cost report before opening a fresh one.
7601
8075
  if (turnReport.dispatches.length > 0 || turnReport.research > 0 || turnReport.refusals > 0) {
7602
8076
  lastTurnReport = turnReport;
@@ -7701,6 +8175,7 @@ ask the human. You MUST instead:
7701
8175
  // budgets in code (dispatch_agent/spawn_research refuse past them); the
7702
8176
  // prompt teaches the dispatcher to plan within them instead of hitting them.
7703
8177
  const budget = currentBudget();
8178
+ const taskBudget = currentTaskBudget();
7704
8179
  const cap = (n: number | null) => (n == null ? "unlimited" : String(n));
7705
8180
  const capMin = (ms: number | null) => (ms == null ? "unlimited" : `${Math.round(ms / 60_000)} min`);
7706
8181
  const modeSection = `## Task triage (FIRST, before any dispatch)
@@ -7717,14 +8192,31 @@ to how interesting the work is.
7717
8192
  file, a numbered breakdown), do NOT re-plan or re-spec it. Skip planner and
7718
8193
  plan-reviewer; batch the plan's tasks straight to the builder and use the plan's own
7719
8194
  acceptance criteria as the assertions.
8195
+ - A plan is a spec, NOT a mandate to execute all of it. When the plan is larger than what
8196
+ the user actually asked for, do the asked-for part and say which parts you left — the
8197
+ plan's existence is not consent to run its every gate. If a plan for a small ask has
8198
+ grown gates, manifests, or provenance machinery nobody requested, name that to the user
8199
+ instead of executing it.
7720
8200
  - Using every persona is a smell, not a virtue: each dispatch must change the outcome.
7721
8201
  If a dispatch's absence would change nothing, don't make it.
7722
-
7723
- ## Execution mode: ${hubMode}${turnTaskTier ? ` · tier: ${turnTaskTier}` : ""}
8202
+ - THE TIER IS THE TASK'S, NOT THE TURN'S. It survives the user's next message and moves by
8203
+ ratchet: lowering it is always free, raising it needs a \`reason\` naming what the ask
8204
+ turned out to contain. A correction or follow-up ("no, only the one line") is the SAME
8205
+ task — do not re-triage it upward, and do not pass \`new_task\` for it. At trivial/small
8206
+ tiers the hub refuses planner, plan-reviewer, architect, security-auditor and
8207
+ deep-researcher in code; that refusal is a signal to do the work, not to raise the tier.
8208
+
8209
+ ## Execution mode: ${hubMode}${taskTier ? ` · tier: ${taskTier}` : ""}
7724
8210
  Budgets for THIS user turn (enforced by the hub — exhausted budgets make dispatch_agent/
7725
8211
  spawn_research refuse; a new user message opens a fresh window; /af-hub-mode switches mode):
7726
8212
  - dispatch_agent calls: ${cap(budget.maxDispatches)} · spawn_research calls: ${cap(budget.maxResearch)}
7727
8213
  - turn wall clock: ${capMin(budget.wallMs)} · per-run deadline: ${capMin(budget.agentTurnMs)}
8214
+ Budgets for the WHOLE TASK (${TASK_BUDGET_MULTIPLIER}× the turn envelope; NOT reset by a user message —
8215
+ only by /af-new-task or set_task_tier \`new_task: true\`). Spent so far:
8216
+ - dispatches ${taskDispatchCount}/${cap(taskBudget.maxDispatches)} · research ${taskResearchCount}/${cap(taskBudget.maxResearch)} · active time ${Math.round(taskActiveElapsedMs() / 60_000)}/${capMin(taskBudget.wallMs)} min
8217
+ - review rounds ${taskReviewRounds}/${cap(reviewRoundCap(taskTier))} (a review is a gate, not a loop)
8218
+ Exhausting the TASK budget is a hard stop: it means the work outgrew its envelope three
8219
+ times over, which is a re-scoping decision for the human, not something to spend through.
7728
8220
  Plan within the budget: batch related work into ONE dispatch (a coherent slice of 4–6
7729
8221
  plan tasks, not one dispatch per micro-task), and when a budget refusal comes back, STOP —
7730
8222
  summarize progress and ask the user; never retry the refused call in the same turn.
@@ -7882,6 +8374,9 @@ This session runs inside a herdr workspace and can drive panes:
7882
8374
  ready" and never addressed is an empty pane named like a worker. If you sent it no work
7883
8375
  by the end of the turn, say so and offer to close it; the hub names unaddressed
7884
8376
  hub-spawned peers in the session digest.
8377
+ - \`peer_ready: false\` is a FAILED start, not a slow one. The result carries the pane's last
8378
+ output — read it, then fix the cause or close the pane and spawn again. Never \`coms_send\`
8379
+ to a name that never registered, and never spawn a second peer to route around the first.
7885
8380
  - \`herdr_read_pane\` is read-to-decide: peek at a worker/tool pane's recent output before
7886
8381
  acting on it. It is NOT a messaging channel and NOT a status poll — \`coms_list\` already
7887
8382
  reports each peer's \`pane_id\` and \`status\` (idle | working | booting), so check that
@@ -8207,6 +8702,13 @@ ${researchCatalog}`;
8207
8702
  }
8208
8703
  }
8209
8704
 
8705
+ // Per-project overrides are parsed BEFORE loadAgents: loadAgents archives the
8706
+ // previous session's artifacts, and that archive has to honor this project's
8707
+ // `run-history-keep` — reading it afterwards would apply the retention one
8708
+ // session late. Everything else the overrides drive is assigned below.
8709
+ const overrides = parseAgentTeamOverrides(_ctx.cwd);
8710
+ runHistoryKeep = overrides.runHistoryKeep;
8711
+
8210
8712
  loadAgents(_ctx.cwd);
8211
8713
 
8212
8714
  // Surface non-fatal persona frontmatter warnings (skipped subagents roles,
@@ -8222,8 +8724,8 @@ ${researchCatalog}`;
8222
8724
  );
8223
8725
  }
8224
8726
 
8225
- // Load per-project overrides (user-facing language, persona gate, models).
8226
- const overrides = parseAgentTeamOverrides(_ctx.cwd);
8727
+ // Apply the rest of the per-project overrides (user-facing language, persona
8728
+ // gate, models) — parsed above, before loadAgents.
8227
8729
  userLanguage = overrides.language;
8228
8730
  researchKeep = overrides.researchKeep;
8229
8731
  reconSearchTimeoutMs = overrides.reconSearchTimeoutMs;
@@ -8233,8 +8735,8 @@ ${researchCatalog}`;
8233
8735
  watchdogJudgeModel = overrides.watchdogJudgeModel;
8234
8736
  turnDispatchCount = 0;
8235
8737
  turnResearchCount = 0;
8236
- turnTaskTier = null;
8237
- turnDispatchFingerprints.clear();
8738
+ // A new session is a new task by definition.
8739
+ resetTaskWindow(null);
8238
8740
  updateModeStatus();
8239
8741
  if (overrides.warnings.length > 0) {
8240
8742
  _ctx.ui.notify(`agent-fleet-overrides warnings:\n${overrides.warnings.join("\n")}`, "warning");