@chankov/agent-fleet 2.0.10 → 2.0.11

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 (531) hide show
  1. package/.pi/agent-fleet/scripts/flow.ts +26 -8
  2. package/.pi/agent-fleet/scripts/workflows/lib/agent-phase.ts +56 -12
  3. package/.pi/agent-fleet/scripts/workflows/lib/isolated-snapshot.ts +125 -0
  4. package/.pi/agent-fleet/scripts/workflows/lib/run.ts +2 -2
  5. package/.pi/agent-fleet/scripts/workflows/lib/scout-data-boundary.ts +55 -0
  6. package/.pi/agent-fleet/scripts/workflows/lib/trace.ts +2 -2
  7. package/.pi/agent-fleet/scripts/workflows/wf-scout.ts +3 -1
  8. package/.pi/harnesses/agent-hub/README.md +53 -18
  9. package/.pi/harnesses/agent-hub/acceptance.ts +137 -0
  10. package/.pi/harnesses/agent-hub/assertion-ledger.js +15 -6
  11. package/.pi/harnesses/agent-hub/assist-profile.ts +16 -0
  12. package/.pi/harnesses/agent-hub/bounded-output.ts +26 -0
  13. package/.pi/harnesses/agent-hub/budget-recovery.ts +112 -18
  14. package/.pi/harnesses/agent-hub/capability-packs.ts +4 -1
  15. package/.pi/harnesses/agent-hub/commands/audit.ts +9 -0
  16. package/.pi/harnesses/agent-hub/commands/context.ts +1 -0
  17. package/.pi/harnesses/agent-hub/commands/retry.ts +1 -1
  18. package/.pi/harnesses/agent-hub/config/agents.ts +1 -0
  19. package/.pi/harnesses/agent-hub/config/model-profiles.ts +20 -1
  20. package/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +10 -2
  21. package/.pi/harnesses/agent-hub/context/budgets.ts +2 -0
  22. package/.pi/harnesses/agent-hub/delegate.ts +19 -2
  23. package/.pi/harnesses/agent-hub/deterministic-fs.ts +127 -0
  24. package/.pi/harnesses/agent-hub/diagnostic-probe-extension.ts +26 -0
  25. package/.pi/harnesses/agent-hub/diagnostic-series-budget.ts +178 -0
  26. package/.pi/harnesses/agent-hub/dispatch-native-complete.ts +14 -5
  27. package/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +74 -7
  28. package/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +5 -1
  29. package/.pi/harnesses/agent-hub/dispatch-native-types.ts +15 -0
  30. package/.pi/harnesses/agent-hub/dispatch-native.ts +24 -11
  31. package/.pi/harnesses/agent-hub/filesystem-tool.ts +73 -0
  32. package/.pi/harnesses/agent-hub/helpers.ts +5 -1
  33. package/.pi/harnesses/agent-hub/hub-state-audit.js +1 -0
  34. package/.pi/harnesses/agent-hub/index.ts +145 -14
  35. package/.pi/harnesses/agent-hub/no-progress.ts +194 -64
  36. package/.pi/harnesses/agent-hub/package.json +1 -1
  37. package/.pi/harnesses/agent-hub/policy/work-mode.ts +10 -3
  38. package/.pi/harnesses/agent-hub/process-obligations.ts +57 -0
  39. package/.pi/harnesses/agent-hub/prompts/context.ts +4 -0
  40. package/.pi/harnesses/agent-hub/prompts/fragments.ts +5 -2
  41. package/.pi/harnesses/agent-hub/prompts/system-prompt.ts +1 -1
  42. package/.pi/harnesses/agent-hub/recovery-contract.ts +78 -0
  43. package/.pi/harnesses/agent-hub/research/runtime.ts +1 -0
  44. package/.pi/harnesses/agent-hub/research/spawn-run.ts +20 -5
  45. package/.pi/harnesses/agent-hub/runtime-test-check.ts +54 -0
  46. package/.pi/harnesses/agent-hub/session-audit.ts +161 -0
  47. package/.pi/harnesses/agent-hub/spawn.ts +61 -7
  48. package/.pi/harnesses/agent-hub/task-resume-contract.ts +70 -0
  49. package/.pi/harnesses/agent-hub/tool-catalog-runtime.ts +68 -0
  50. package/.pi/harnesses/agent-hub/tool-catalog-state.ts +123 -0
  51. package/.pi/harnesses/agent-hub/tool-protocol.ts +134 -0
  52. package/.pi/harnesses/agent-hub/tools/action-executors.ts +41 -5
  53. package/.pi/harnesses/agent-hub/tools/context.ts +9 -1
  54. package/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +1 -1
  55. package/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +176 -26
  56. package/.pi/harnesses/agent-hub/tools/run-flow.ts +122 -0
  57. package/.pi/harnesses/agent-hub/tools/set-task-tier.ts +5 -3
  58. package/.pi/harnesses/agent-hub/tools/spawn-research.ts +4 -1
  59. package/.pi/harnesses/agent-hub/tools/verification-contract.ts +5 -2
  60. package/.pi/harnesses/agent-hub/types.ts +2 -0
  61. package/.pi/harnesses/agent-hub/unknown-tool-counter.ts +116 -0
  62. package/.pi/harnesses/agent-hub/work-mode.ts +8 -2
  63. package/.pi/harnesses/agent-hub/write-isolation.ts +187 -0
  64. package/.pi/harnesses/ask-user-remote/runtime-ask.ts +31 -6
  65. package/.pi/harnesses/coms/package.json +1 -1
  66. package/.pi/harnesses/damage-control-continue/index.ts +9 -0
  67. package/.pi/harnesses/damage-control-continue/package.json +1 -1
  68. package/.pi/harnesses/lib/deterministic-handle-path.ts +23 -0
  69. package/.versions/2.0.11/.pi/agent-fleet/hermes/README.md +347 -0
  70. package/.versions/2.0.11/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
  71. package/.versions/2.0.11/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
  72. package/.versions/2.0.11/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  73. package/.versions/2.0.11/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  74. package/.versions/2.0.11/.pi/agent-fleet/hermes/gates/gate-o-capability.md +8 -0
  75. package/.versions/2.0.11/.pi/agent-fleet/hermes/gates/gate-o-validator-fixtures.json +1 -0
  76. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +773 -0
  77. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
  78. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
  79. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
  80. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
  81. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
  82. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
  83. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
  84. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
  85. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
  86. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
  87. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  88. package/.versions/2.0.11/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  89. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-conductor/SKILL.md +84 -0
  90. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-liaison/SKILL.md +84 -0
  91. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-watchdog/SKILL.md +76 -0
  92. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-watchdog/manifest.json +1 -0
  93. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
  94. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
  95. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
  96. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
  97. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
  98. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
  99. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
  100. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
  101. package/.versions/2.0.11/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
  102. package/.versions/2.0.11/.pi/agent-fleet/hermes/watchdog-tests/__init__.py +0 -0
  103. package/.versions/2.0.11/.pi/agent-fleet/hooks/coms-stop-hook.mjs +84 -0
  104. package/.versions/2.0.11/.pi/agent-fleet/scripts/claude-code-preflight.ts +70 -0
  105. package/.versions/2.0.11/.pi/agent-fleet/scripts/coms-claude-bridge.ts +411 -0
  106. package/.versions/2.0.11/.pi/agent-fleet/scripts/coms-cli.ts +425 -0
  107. package/.versions/2.0.11/.pi/agent-fleet/scripts/coms-hermes-bridge.ts +413 -0
  108. package/.versions/2.0.11/.pi/agent-fleet/scripts/fleet-codex-client.ts +69 -0
  109. package/.versions/2.0.11/.pi/agent-fleet/scripts/fleet-codex-read.py +148 -0
  110. package/.versions/2.0.11/.pi/agent-fleet/scripts/fleet.ts +216 -0
  111. package/.versions/2.0.11/.pi/agent-fleet/scripts/flow.ts +155 -0
  112. package/.versions/2.0.11/.pi/agent-fleet/scripts/hermes-monitor-capability-runner.ts +25 -0
  113. package/.versions/2.0.11/.pi/agent-fleet/scripts/hermes-monitor-scenario.ts +474 -0
  114. package/.versions/2.0.11/.pi/agent-fleet/scripts/hermes-watchdog-capability-probe.ts +45 -0
  115. package/.versions/2.0.11/.pi/agent-fleet/scripts/install-hermes-plugin.sh +180 -0
  116. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/claude-bridge-core.ts +210 -0
  117. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/coms-envelope.ts +582 -0
  118. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/fake-herdr-server.ts +88 -0
  119. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/fleet-codex-catalog.ts +63 -0
  120. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/fleet-codex-operations.ts +190 -0
  121. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/fleet-codex-session.ts +166 -0
  122. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/fleet-codex-transport.ts +124 -0
  123. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/fleet-command.ts +252 -0
  124. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/flow-command.ts +93 -0
  125. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/flow-maintenance.ts +230 -0
  126. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/herdr-layout.ts +281 -0
  127. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/hermes-bridge-core.ts +241 -0
  128. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/hermes-monitor-events.ts +1 -0
  129. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/hermes-monitor-herdr.ts +2 -0
  130. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/hermes-monitor-model.ts +3 -0
  131. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/hermes-monitor-registry.ts +2 -0
  132. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/hermes-monitor-socket.ts +2 -0
  133. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/hermes-monitor-store.ts +2 -0
  134. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/monitor-env.ts +146 -0
  135. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/peer-launch.ts +318 -0
  136. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/persona-banner.ts +62 -0
  137. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/persona-dirs.ts +25 -0
  138. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/runtime-dependencies.js +124 -0
  139. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/spawn-stagger.ts +101 -0
  140. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/team-project.ts +178 -0
  141. package/.versions/2.0.11/.pi/agent-fleet/scripts/lib/team-snapshot.ts +147 -0
  142. package/.versions/2.0.11/.pi/agent-fleet/scripts/package-lock.json +35 -0
  143. package/.versions/2.0.11/.pi/agent-fleet/scripts/package.json +9 -0
  144. package/.versions/2.0.11/.pi/agent-fleet/scripts/peer-banner.ts +41 -0
  145. package/.versions/2.0.11/.pi/agent-fleet/scripts/peer-launch.ts +283 -0
  146. package/.versions/2.0.11/.pi/agent-fleet/scripts/team-snapshot.ts +237 -0
  147. package/.versions/2.0.11/.pi/agent-fleet/scripts/team-up.ts +378 -0
  148. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/agent-phase.ts +177 -0
  149. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/changes.ts +61 -0
  150. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/debate.ts +149 -0
  151. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/env.ts +34 -0
  152. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/envelopes.ts +169 -0
  153. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/gates.ts +81 -0
  154. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/git.ts +96 -0
  155. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/isolated-snapshot.ts +125 -0
  156. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/merge.ts +95 -0
  157. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/model-profile.ts +22 -0
  158. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/model-visibility.ts +92 -0
  159. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/permissions.ts +130 -0
  160. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/personas.ts +57 -0
  161. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/poll.ts +86 -0
  162. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/quality.ts +64 -0
  163. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/run.ts +108 -0
  164. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/scout-data-boundary.ts +55 -0
  165. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/trace.ts +34 -0
  166. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/voices.ts +128 -0
  167. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/lib/writer-lease.ts +112 -0
  168. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/tsconfig.json +22 -0
  169. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/wf-build-test.ts +61 -0
  170. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/wf-debate.ts +87 -0
  171. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/wf-document.ts +50 -0
  172. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/wf-poll.ts +95 -0
  173. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/wf-quality.ts +20 -0
  174. package/.versions/2.0.11/.pi/agent-fleet/scripts/workflows/wf-scout.ts +40 -0
  175. package/.versions/2.0.11/.pi/agents/dispatch-policy.yaml +32 -0
  176. package/.versions/2.0.11/.pi/agents/model-profiles.yaml +83 -0
  177. package/.versions/2.0.11/.pi/agents/peers.yaml +147 -0
  178. package/.versions/2.0.11/.pi/agents/teams.yaml +41 -0
  179. package/.versions/2.0.11/.pi/agents/voices.yaml +13 -0
  180. package/.versions/2.0.11/.pi/damage-control-rules.yaml +297 -0
  181. package/.versions/2.0.11/.pi/extensions/btw/README.md +120 -0
  182. package/.versions/2.0.11/.pi/extensions/btw/index.ts +914 -0
  183. package/.versions/2.0.11/.pi/extensions/btw/package.json +6 -0
  184. package/.versions/2.0.11/.pi/extensions/btw/state.js +179 -0
  185. package/.versions/2.0.11/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
  186. package/.versions/2.0.11/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
  187. package/.versions/2.0.11/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  188. package/.versions/2.0.11/.pi/extensions/compact-and-continue/README.md +42 -0
  189. package/.versions/2.0.11/.pi/extensions/compact-and-continue/index.ts +120 -0
  190. package/.versions/2.0.11/.pi/extensions/compact-and-continue/package.json +6 -0
  191. package/.versions/2.0.11/.pi/extensions/mcp-bridge/README.md +46 -0
  192. package/.versions/2.0.11/.pi/extensions/mcp-bridge/index.ts +206 -0
  193. package/.versions/2.0.11/.pi/extensions/mcp-bridge/package.json +6 -0
  194. package/.versions/2.0.11/.pi/extensions/package-lock.json +1175 -0
  195. package/.versions/2.0.11/.pi/extensions/package.json +9 -0
  196. package/.versions/2.0.11/.pi/extensions/pi-voice-stt/README.md +224 -0
  197. package/.versions/2.0.11/.pi/extensions/pi-voice-stt/config.ts +198 -0
  198. package/.versions/2.0.11/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  199. package/.versions/2.0.11/.pi/extensions/pi-voice-stt/index.ts +248 -0
  200. package/.versions/2.0.11/.pi/extensions/pi-voice-stt/package.json +6 -0
  201. package/.versions/2.0.11/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  202. package/.versions/2.0.11/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  203. package/.versions/2.0.11/.pi/harnesses/agent-hub/README.md +1252 -0
  204. package/.versions/2.0.11/.pi/harnesses/agent-hub/acceptance.ts +199 -0
  205. package/.versions/2.0.11/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  206. package/.versions/2.0.11/.pi/harnesses/agent-hub/artifacts.js +146 -0
  207. package/.versions/2.0.11/.pi/harnesses/agent-hub/assertion-ledger.js +67 -0
  208. package/.versions/2.0.11/.pi/harnesses/agent-hub/assist-profile.ts +16 -0
  209. package/.versions/2.0.11/.pi/harnesses/agent-hub/backend-policy.js +174 -0
  210. package/.versions/2.0.11/.pi/harnesses/agent-hub/bounded-output.ts +26 -0
  211. package/.versions/2.0.11/.pi/harnesses/agent-hub/budget-continuation.ts +13 -0
  212. package/.versions/2.0.11/.pi/harnesses/agent-hub/budget-recovery.ts +191 -0
  213. package/.versions/2.0.11/.pi/harnesses/agent-hub/capability-confirmation.ts +47 -0
  214. package/.versions/2.0.11/.pi/harnesses/agent-hub/capability-packs.ts +183 -0
  215. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/agent-model-thinking.ts +10 -0
  216. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/agent-model.ts +10 -0
  217. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/agent-models-substitute.ts +10 -0
  218. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/agents-add.ts +9 -0
  219. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/agents-drop.ts +9 -0
  220. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/agents-history.ts +9 -0
  221. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/agents-kill.ts +10 -0
  222. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/agents-list.ts +9 -0
  223. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/agents-restart.ts +10 -0
  224. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/agents-save.ts +9 -0
  225. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/agents-team.ts +9 -0
  226. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/audit.ts +9 -0
  227. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/budget-continue.ts +10 -0
  228. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/compound.ts +9 -0
  229. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/coms.ts +9 -0
  230. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/context-command.ts +9 -0
  231. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/context.ts +44 -0
  232. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/debate.ts +9 -0
  233. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/dispatch-policy.ts +9 -0
  234. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/handoff.ts +10 -0
  235. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/hub-report.ts +9 -0
  236. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/models.ts +10 -0
  237. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/poll.ts +9 -0
  238. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/retry.ts +10 -0
  239. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/watchdog.ts +9 -0
  240. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/work-mode.ts +29 -0
  241. package/.versions/2.0.11/.pi/harnesses/agent-hub/commands/zoom.ts +10 -0
  242. package/.versions/2.0.11/.pi/harnesses/agent-hub/config/agents.ts +178 -0
  243. package/.versions/2.0.11/.pi/harnesses/agent-hub/config/model-profiles.ts +235 -0
  244. package/.versions/2.0.11/.pi/harnesses/agent-hub/config/overrides.ts +153 -0
  245. package/.versions/2.0.11/.pi/harnesses/agent-hub/context/agent-state.ts +30 -0
  246. package/.versions/2.0.11/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +221 -0
  247. package/.versions/2.0.11/.pi/harnesses/agent-hub/context/budgets.ts +204 -0
  248. package/.versions/2.0.11/.pi/harnesses/agent-hub/context/hub-state.ts +40 -0
  249. package/.versions/2.0.11/.pi/harnesses/agent-hub/context-budget-snapshot.ts +105 -0
  250. package/.versions/2.0.11/.pi/harnesses/agent-hub/context-pressure.ts +191 -0
  251. package/.versions/2.0.11/.pi/harnesses/agent-hub/context-window.js +106 -0
  252. package/.versions/2.0.11/.pi/harnesses/agent-hub/debate-command.ts +176 -0
  253. package/.versions/2.0.11/.pi/harnesses/agent-hub/delegate.ts +463 -0
  254. package/.versions/2.0.11/.pi/harnesses/agent-hub/deterministic-fs.ts +127 -0
  255. package/.versions/2.0.11/.pi/harnesses/agent-hub/diagnostic-probe-extension.ts +26 -0
  256. package/.versions/2.0.11/.pi/harnesses/agent-hub/diagnostic-series-budget.ts +178 -0
  257. package/.versions/2.0.11/.pi/harnesses/agent-hub/dispatch-coms.ts +237 -0
  258. package/.versions/2.0.11/.pi/harnesses/agent-hub/dispatch-core.ts +27 -0
  259. package/.versions/2.0.11/.pi/harnesses/agent-hub/dispatch-native-complete.ts +163 -0
  260. package/.versions/2.0.11/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +223 -0
  261. package/.versions/2.0.11/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +197 -0
  262. package/.versions/2.0.11/.pi/harnesses/agent-hub/dispatch-native-types.ts +245 -0
  263. package/.versions/2.0.11/.pi/harnesses/agent-hub/dispatch-native.ts +226 -0
  264. package/.versions/2.0.11/.pi/harnesses/agent-hub/dispatch-observability.ts +225 -0
  265. package/.versions/2.0.11/.pi/harnesses/agent-hub/docs-lane.js +122 -0
  266. package/.versions/2.0.11/.pi/harnesses/agent-hub/drift-watchdog.js +218 -0
  267. package/.versions/2.0.11/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  268. package/.versions/2.0.11/.pi/harnesses/agent-hub/execution-evidence.ts +80 -0
  269. package/.versions/2.0.11/.pi/harnesses/agent-hub/external-blocker.js +85 -0
  270. package/.versions/2.0.11/.pi/harnesses/agent-hub/filesystem-tool.ts +73 -0
  271. package/.versions/2.0.11/.pi/harnesses/agent-hub/fixtures/registration-surface.json +60 -0
  272. package/.versions/2.0.11/.pi/harnesses/agent-hub/fixtures/t0a-synthetic/catalog.ts +189 -0
  273. package/.versions/2.0.11/.pi/harnesses/agent-hub/footer.ts +30 -0
  274. package/.versions/2.0.11/.pi/harnesses/agent-hub/helpers.ts +270 -0
  275. package/.versions/2.0.11/.pi/harnesses/agent-hub/hub-state-audit.js +65 -0
  276. package/.versions/2.0.11/.pi/harnesses/agent-hub/index.ts +2263 -0
  277. package/.versions/2.0.11/.pi/harnesses/agent-hub/input/completions.ts +76 -0
  278. package/.versions/2.0.11/.pi/harnesses/agent-hub/input/shortcuts.ts +20 -0
  279. package/.versions/2.0.11/.pi/harnesses/agent-hub/lifecycle/context-pressure.ts +123 -0
  280. package/.versions/2.0.11/.pi/harnesses/agent-hub/lifecycle/monitor-session.ts +104 -0
  281. package/.versions/2.0.11/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +143 -0
  282. package/.versions/2.0.11/.pi/harnesses/agent-hub/lifecycle/turn-handlers.ts +74 -0
  283. package/.versions/2.0.11/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  284. package/.versions/2.0.11/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
  285. package/.versions/2.0.11/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
  286. package/.versions/2.0.11/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  287. package/.versions/2.0.11/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  288. package/.versions/2.0.11/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  289. package/.versions/2.0.11/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  290. package/.versions/2.0.11/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
  291. package/.versions/2.0.11/.pi/harnesses/agent-hub/no-progress.ts +206 -0
  292. package/.versions/2.0.11/.pi/harnesses/agent-hub/package.json +7 -0
  293. package/.versions/2.0.11/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
  294. package/.versions/2.0.11/.pi/harnesses/agent-hub/policy/models.ts +153 -0
  295. package/.versions/2.0.11/.pi/harnesses/agent-hub/policy/profile-activation.ts +62 -0
  296. package/.versions/2.0.11/.pi/harnesses/agent-hub/policy/profile-runtime.ts +120 -0
  297. package/.versions/2.0.11/.pi/harnesses/agent-hub/policy/roster.ts +94 -0
  298. package/.versions/2.0.11/.pi/harnesses/agent-hub/policy/work-mode.ts +126 -0
  299. package/.versions/2.0.11/.pi/harnesses/agent-hub/poll-command.ts +176 -0
  300. package/.versions/2.0.11/.pi/harnesses/agent-hub/presentation.ts +48 -0
  301. package/.versions/2.0.11/.pi/harnesses/agent-hub/process-obligations.ts +57 -0
  302. package/.versions/2.0.11/.pi/harnesses/agent-hub/prompts/context.ts +51 -0
  303. package/.versions/2.0.11/.pi/harnesses/agent-hub/prompts/fragments.ts +118 -0
  304. package/.versions/2.0.11/.pi/harnesses/agent-hub/prompts/session-start.ts +90 -0
  305. package/.versions/2.0.11/.pi/harnesses/agent-hub/prompts/system-prompt.ts +112 -0
  306. package/.versions/2.0.11/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
  307. package/.versions/2.0.11/.pi/harnesses/agent-hub/recovery-contract.ts +78 -0
  308. package/.versions/2.0.11/.pi/harnesses/agent-hub/research/controls.ts +74 -0
  309. package/.versions/2.0.11/.pi/harnesses/agent-hub/research/runtime.ts +193 -0
  310. package/.versions/2.0.11/.pi/harnesses/agent-hub/research/spawn-run.ts +171 -0
  311. package/.versions/2.0.11/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  312. package/.versions/2.0.11/.pi/harnesses/agent-hub/return-contract.js +327 -0
  313. package/.versions/2.0.11/.pi/harnesses/agent-hub/return-extract.js +75 -0
  314. package/.versions/2.0.11/.pi/harnesses/agent-hub/review-findings.js +102 -0
  315. package/.versions/2.0.11/.pi/harnesses/agent-hub/run-budget.js +537 -0
  316. package/.versions/2.0.11/.pi/harnesses/agent-hub/run-namespace.js +87 -0
  317. package/.versions/2.0.11/.pi/harnesses/agent-hub/runtime-test-check.ts +54 -0
  318. package/.versions/2.0.11/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  319. package/.versions/2.0.11/.pi/harnesses/agent-hub/scope-gate.js +123 -0
  320. package/.versions/2.0.11/.pi/harnesses/agent-hub/session-audit.ts +161 -0
  321. package/.versions/2.0.11/.pi/harnesses/agent-hub/session-health.js +110 -0
  322. package/.versions/2.0.11/.pi/harnesses/agent-hub/session-start.ts +42 -0
  323. package/.versions/2.0.11/.pi/harnesses/agent-hub/spawn.ts +458 -0
  324. package/.versions/2.0.11/.pi/harnesses/agent-hub/task-resume-contract.ts +70 -0
  325. package/.versions/2.0.11/.pi/harnesses/agent-hub/timeline.ts +54 -0
  326. package/.versions/2.0.11/.pi/harnesses/agent-hub/tool-catalog-runtime.ts +68 -0
  327. package/.versions/2.0.11/.pi/harnesses/agent-hub/tool-catalog-state.ts +123 -0
  328. package/.versions/2.0.11/.pi/harnesses/agent-hub/tool-protocol.ts +134 -0
  329. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/action-executors.ts +185 -0
  330. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/coms-tools.ts +139 -0
  331. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/context.ts +142 -0
  332. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +82 -0
  333. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +485 -0
  334. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/execution-orchestration.ts +22 -0
  335. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/fleet-tools.ts +200 -0
  336. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/herdr-executors.ts +86 -0
  337. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/run-flow.ts +122 -0
  338. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/set-task-tier.ts +31 -0
  339. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/spawn-research.ts +65 -0
  340. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/team-adjust.ts +29 -0
  341. package/.versions/2.0.11/.pi/harnesses/agent-hub/tools/verification-contract.ts +80 -0
  342. package/.versions/2.0.11/.pi/harnesses/agent-hub/types.ts +65 -0
  343. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/activity-dots.ts +16 -0
  344. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/context-budget.ts +86 -0
  345. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/detail-panel.ts +178 -0
  346. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/fleet-actions.ts +76 -0
  347. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +99 -0
  348. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/fleet-editor.ts +44 -0
  349. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/fleet-source.ts +157 -0
  350. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/grid.ts +154 -0
  351. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/history-store.ts +137 -0
  352. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/history.ts +234 -0
  353. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/pool.ts +103 -0
  354. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/running-strip.ts +2 -0
  355. package/.versions/2.0.11/.pi/harnesses/agent-hub/ui/zoom.ts +204 -0
  356. package/.versions/2.0.11/.pi/harnesses/agent-hub/unknown-tool-counter.ts +116 -0
  357. package/.versions/2.0.11/.pi/harnesses/agent-hub/version.ts +42 -0
  358. package/.versions/2.0.11/.pi/harnesses/agent-hub/work-mode-controls.ts +56 -0
  359. package/.versions/2.0.11/.pi/harnesses/agent-hub/work-mode.ts +173 -0
  360. package/.versions/2.0.11/.pi/harnesses/agent-hub/write-isolation.ts +187 -0
  361. package/.versions/2.0.11/.pi/harnesses/ask-user-remote/README.md +59 -0
  362. package/.versions/2.0.11/.pi/harnesses/ask-user-remote/index.ts +558 -0
  363. package/.versions/2.0.11/.pi/harnesses/ask-user-remote/questions.ts +161 -0
  364. package/.versions/2.0.11/.pi/harnesses/ask-user-remote/race-core.js +124 -0
  365. package/.versions/2.0.11/.pi/harnesses/ask-user-remote/runtime-ask.ts +68 -0
  366. package/.versions/2.0.11/.pi/harnesses/coms/README.md +100 -0
  367. package/.versions/2.0.11/.pi/harnesses/coms/index.ts +282 -0
  368. package/.versions/2.0.11/.pi/harnesses/coms/package.json +7 -0
  369. package/.versions/2.0.11/.pi/harnesses/coms/version.ts +42 -0
  370. package/.versions/2.0.11/.pi/harnesses/damage-control-continue/README.md +135 -0
  371. package/.versions/2.0.11/.pi/harnesses/damage-control-continue/index.ts +550 -0
  372. package/.versions/2.0.11/.pi/harnesses/damage-control-continue/package.json +7 -0
  373. package/.versions/2.0.11/.pi/harnesses/damage-control-continue/version.ts +42 -0
  374. package/.versions/2.0.11/.pi/harnesses/lib/changed-file-diagnostics.ts +642 -0
  375. package/.versions/2.0.11/.pi/harnesses/lib/coms-core-io.ts +385 -0
  376. package/.versions/2.0.11/.pi/harnesses/lib/coms-core.ts +577 -0
  377. package/.versions/2.0.11/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
  378. package/.versions/2.0.11/.pi/harnesses/lib/context-budget-child-prompt.ts +180 -0
  379. package/.versions/2.0.11/.pi/harnesses/lib/context-budget-hub-prompt.ts +114 -0
  380. package/.versions/2.0.11/.pi/harnesses/lib/context-budget-view.ts +107 -0
  381. package/.versions/2.0.11/.pi/harnesses/lib/context-budget.ts +114 -0
  382. package/.versions/2.0.11/.pi/harnesses/lib/damage-control-shared.ts +197 -0
  383. package/.versions/2.0.11/.pi/harnesses/lib/deterministic-handle-path.ts +23 -0
  384. package/.versions/2.0.11/.pi/harnesses/lib/fixtures/context-budget-profiles.json +11 -0
  385. package/.versions/2.0.11/.pi/harnesses/lib/fixtures/hub-prompt-operator.legacy.txt +73 -0
  386. package/.versions/2.0.11/.pi/harnesses/lib/fixtures/hub-prompt-orchestrator.legacy.txt +73 -0
  387. package/.versions/2.0.11/.pi/harnesses/lib/fleet-dashboard-ops.ts +178 -0
  388. package/.versions/2.0.11/.pi/harnesses/lib/fleet-dashboard-view.ts +134 -0
  389. package/.versions/2.0.11/.pi/harnesses/lib/fleet-detail-view.ts +247 -0
  390. package/.versions/2.0.11/.pi/harnesses/lib/fleet-overlay.ts +26 -0
  391. package/.versions/2.0.11/.pi/harnesses/lib/fleet-panel.ts +34 -0
  392. package/.versions/2.0.11/.pi/harnesses/lib/fleet-read-model.ts +213 -0
  393. package/.versions/2.0.11/.pi/harnesses/lib/fleet-selection.ts +24 -0
  394. package/.versions/2.0.11/.pi/harnesses/lib/fleet-strip-controller.ts +74 -0
  395. package/.versions/2.0.11/.pi/harnesses/lib/fleet-strip-view.ts +132 -0
  396. package/.versions/2.0.11/.pi/harnesses/lib/fleet-transcript-store.ts +244 -0
  397. package/.versions/2.0.11/.pi/harnesses/lib/herdr-client.ts +472 -0
  398. package/.versions/2.0.11/.pi/harnesses/lib/herdr-presence.ts +399 -0
  399. package/.versions/2.0.11/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
  400. package/.versions/2.0.11/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
  401. package/.versions/2.0.11/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
  402. package/.versions/2.0.11/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
  403. package/.versions/2.0.11/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
  404. package/.versions/2.0.11/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
  405. package/.versions/2.0.11/.pi/harnesses/lib/spawned-peers.js +190 -0
  406. package/.versions/2.0.11/.pi/harnesses/lib/update-check.ts +222 -0
  407. package/.versions/2.0.11/.pi/harnesses/package-lock.json +2039 -0
  408. package/.versions/2.0.11/.pi/harnesses/package.json +10 -0
  409. package/.versions/2.0.11/.pi/prompts/af-build.md +24 -0
  410. package/.versions/2.0.11/.pi/prompts/af-code-simplify.md +22 -0
  411. package/.versions/2.0.11/.pi/prompts/af-constraints.md +31 -0
  412. package/.versions/2.0.11/.pi/prompts/af-plan.md +17 -0
  413. package/.versions/2.0.11/.pi/prompts/af-review.md +16 -0
  414. package/.versions/2.0.11/.pi/prompts/af-set-hermes-telegram.md +15 -0
  415. package/.versions/2.0.11/.pi/prompts/af-set-hermes-watchdog.md +6 -0
  416. package/.versions/2.0.11/.pi/prompts/af-ship.md +17 -0
  417. package/.versions/2.0.11/.pi/prompts/af-spec.md +15 -0
  418. package/.versions/2.0.11/.pi/prompts/af-test.md +19 -0
  419. package/.versions/2.0.11/.pi/skills/bowser/SKILL.md +145 -0
  420. package/.versions/2.0.11/.version +1 -0
  421. package/.versions/2.0.11/agents/architect.md +25 -0
  422. package/.versions/2.0.11/agents/bowser.md +28 -0
  423. package/.versions/2.0.11/agents/builder.md +56 -0
  424. package/.versions/2.0.11/agents/code-reviewer.md +210 -0
  425. package/.versions/2.0.11/agents/deep-researcher.md +33 -0
  426. package/.versions/2.0.11/agents/documenter.md +23 -0
  427. package/.versions/2.0.11/agents/orchestrator.md +23 -0
  428. package/.versions/2.0.11/agents/plan-reviewer.md +84 -0
  429. package/.versions/2.0.11/agents/planner.md +106 -0
  430. package/.versions/2.0.11/agents/releaser.md +25 -0
  431. package/.versions/2.0.11/agents/researcher.md +31 -0
  432. package/.versions/2.0.11/agents/security-auditor.md +168 -0
  433. package/.versions/2.0.11/agents/test-engineer.md +154 -0
  434. package/.versions/2.0.11/agents/web-debugger.md +44 -0
  435. package/.versions/2.0.11/agents/web-performance-auditor.md +194 -0
  436. package/.versions/2.0.11/bin/catalog/harness-runtime-closure.json +61 -0
  437. package/.versions/2.0.11/codex/fleet-session-client/SKILL.md +34 -0
  438. package/.versions/2.0.11/codex/fleet-session-client.zip +0 -0
  439. package/.versions/2.0.11/docs/ARCHITECTURE.md +595 -0
  440. package/.versions/2.0.11/docs/agent-fleet-setup.md +586 -0
  441. package/.versions/2.0.11/docs/claude-code-coms-bridge.md +134 -0
  442. package/.versions/2.0.11/docs/codex-session-bridge.md +219 -0
  443. package/.versions/2.0.11/docs/coms-hermes-bridge.md +188 -0
  444. package/.versions/2.0.11/docs/getting-started.md +126 -0
  445. package/.versions/2.0.11/docs/npm-install.md +383 -0
  446. package/.versions/2.0.11/docs/pi-extensions.md +449 -0
  447. package/.versions/2.0.11/docs/pi-setup.md +92 -0
  448. package/.versions/2.0.11/docs/skill-anatomy.md +150 -0
  449. package/.versions/2.0.11/install-manifest.json +3020 -0
  450. package/.versions/2.0.11/justfile +247 -0
  451. package/.versions/2.0.11/manifest-meta.json +970 -0
  452. package/.versions/2.0.11/references/accessibility-checklist.md +160 -0
  453. package/.versions/2.0.11/references/communication-contract.md +26 -0
  454. package/.versions/2.0.11/references/definition-of-done.md +67 -0
  455. package/.versions/2.0.11/references/fleet-coordination-patterns.md +171 -0
  456. package/.versions/2.0.11/references/observability-checklist.md +92 -0
  457. package/.versions/2.0.11/references/orchestration-patterns.md +370 -0
  458. package/.versions/2.0.11/references/performance-checklist.md +236 -0
  459. package/.versions/2.0.11/references/prompting-patterns.md +380 -0
  460. package/.versions/2.0.11/references/security-checklist.md +245 -0
  461. package/.versions/2.0.11/references/testing-patterns.md +235 -0
  462. package/.versions/2.0.11/references/workflow-authoring.md +304 -0
  463. package/.versions/2.0.11/skills/_internal/grilling.md +59 -0
  464. package/.versions/2.0.11/skills/browser-testing-with-devtools/SKILL.md +351 -0
  465. package/.versions/2.0.11/skills/code-review-and-quality/SKILL.md +396 -0
  466. package/.versions/2.0.11/skills/compound-learning/SKILL.md +137 -0
  467. package/.versions/2.0.11/skills/constraint-driven-development/SKILL.md +338 -0
  468. package/.versions/2.0.11/skills/constraint-driven-development/references/floor-guard.md +99 -0
  469. package/.versions/2.0.11/skills/context-engineering/SKILL.md +341 -0
  470. package/.versions/2.0.11/skills/deprecation-and-migration/SKILL.md +247 -0
  471. package/.versions/2.0.11/skills/designing-agents/SKILL.md +394 -0
  472. package/.versions/2.0.11/skills/designing-agents/pi-harness-authoring.md +222 -0
  473. package/.versions/2.0.11/skills/drafting-workflows/SKILL.md +143 -0
  474. package/.versions/2.0.11/skills/drafting-workflows/scripts/make-workflow.ts +177 -0
  475. package/.versions/2.0.11/skills/frontend-ui-engineering/SKILL.md +328 -0
  476. package/.versions/2.0.11/skills/git-workflow-and-versioning/SKILL.md +316 -0
  477. package/.versions/2.0.11/skills/idea-refine/SKILL.md +182 -0
  478. package/.versions/2.0.11/skills/idea-refine/examples.md +238 -0
  479. package/.versions/2.0.11/skills/idea-refine/frameworks.md +99 -0
  480. package/.versions/2.0.11/skills/idea-refine/refinement-criteria.md +113 -0
  481. package/.versions/2.0.11/skills/idea-refine/scripts/idea-refine.sh +15 -0
  482. package/.versions/2.0.11/skills/incremental-implementation/SKILL.md +302 -0
  483. package/.versions/2.0.11/skills/interview-me/SKILL.md +226 -0
  484. package/.versions/2.0.11/skills/orchestration-verification/SKILL.md +182 -0
  485. package/.versions/2.0.11/skills/peer-coms/SKILL.md +90 -0
  486. package/.versions/2.0.11/skills/performance-optimization/SKILL.md +496 -0
  487. package/.versions/2.0.11/skills/planning-and-task-breakdown/SKILL.md +289 -0
  488. package/.versions/2.0.11/skills/security-and-hardening/SKILL.md +524 -0
  489. package/.versions/2.0.11/skills/spec-driven-development/SKILL.md +295 -0
  490. package/.versions/2.0.11/skills/using-agent-skills/SKILL.md +198 -0
  491. package/.versions/2.0.11/vendor/agent-skills-upstream/LICENSE +21 -0
  492. package/.versions/2.0.11/vendor/agent-skills-upstream/README.md +430 -0
  493. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +367 -0
  494. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  495. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  496. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  497. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  498. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/constraint-driven-development/SKILL.md +311 -0
  499. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/constraint-driven-development/references/floor-guard.md +99 -0
  500. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +337 -0
  501. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  502. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  503. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +288 -0
  504. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  505. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  506. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  507. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  508. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  509. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  510. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  511. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  512. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  513. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  514. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +238 -0
  515. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +496 -0
  516. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +257 -0
  517. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +524 -0
  518. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +330 -0
  519. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +216 -0
  520. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +245 -0
  521. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +398 -0
  522. package/.versions/2.0.11/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +192 -0
  523. package/CHANGELOG.md +8 -0
  524. package/README.md +1 -0
  525. package/bin/catalog/harness-runtime-closure.json +29 -0
  526. package/bin/cli.js +15 -4
  527. package/bin/lib/doctor.js +83 -1
  528. package/docs/ARCHITECTURE.md +181 -2
  529. package/docs/workflows.md +8 -2
  530. package/install-manifest.json +31 -2
  531. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import { retainDeliverable } from "../execution-evidence.ts";
2
- import { preflightDeliverables, readBackDeliverables, type DeliverableContract } from "../acceptance.ts";
3
- import { withNoProgress, type NoProgressGuard } from "../no-progress.ts";
2
+ import { buildRuntimeResult, minimalChangeRequirement, preflightDeliverables, readBackDeliverables, type AcceptanceRequirement, type DeliverableContract, type VerificationCheckInput } from "../acceptance.ts";
3
+ import { normalizeResearchContract, withNoProgress, type NoProgressGuard } from "../no-progress.ts";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { mkdirSync, writeFileSync } from "node:fs";
6
6
  import type { ExtensionContext } from "@mariozechner/pi-coding-agent";
@@ -9,7 +9,7 @@ import { countReviewFindings, findingBudgetNotice } from "../review-findings.js"
9
9
  import { checkDocsLane, docsLaneNotice } from "../docs-lane.js";
10
10
  import { checkExternalBlockerGate, extractExternalBlockers } from "../external-blocker.js";
11
11
  import type { BudgetRecovery } from "../budget-recovery.ts";
12
- import { checkScope, diffAgainst, snapshotWorktree } from "../scope-gate.js";
12
+ import { checkScope, diffAgainst, snapshotWorktree, worktreeRevision } from "../scope-gate.js";
13
13
  import { diagnoseChangedTypeScript, formatAdvisory, type DiagnosticsResult } from "../../lib/changed-file-diagnostics.ts";
14
14
  import { correctStructuredReturnForCompiler, crossCheck, deliveryDisposition, extractAssertionIds, parseDeliveredReturn } from "../return-contract.js";
15
15
  import { shouldExtractReturn } from "../return-extract.js";
@@ -18,10 +18,13 @@ import { MAX_AUTO_RESEARCH_QUESTIONS, MAX_AUTO_RESEARCH_ROUNDS, type ResearchAge
18
18
  import type { BudgetContext, SessionTotals, TurnReport } from "../context/budgets.ts";
19
19
  import type { AssertionsArtifactsContext, InputArtifactPreview } from "../context/assertions-artifacts.ts";
20
20
  import type { DispatchAgentParams, SpawnResearchParams, ToolExecutionResult, ToolExecutor, ToolUpdate } from "./context.ts";
21
+ import type { AgentState } from "../types.ts";
22
+ import { diagnoseToolProtocol, type ToolProtocolDiagnostic } from "../tool-protocol.ts";
23
+ import type { TaskResumeInput } from "../task-resume-contract.ts";
24
+ import { evaluateProcessObligations, noteProcessStage, processAllowsPersona, processPreEffectGate, type ProcessObligationState, type ProcessVerdict } from "../process-obligations.ts";
21
25
 
22
26
  type Gate = { reason: string; message: string } | null;
23
27
  type DispatchResult = import("../dispatch-native-types.ts").NativeDispatchResult;
24
- type AgentState = { def: { name: string; tools: string }; runCount: number; contextPct: number; lastBackend?: string | null };
25
28
 
26
29
  export interface DispatchExecutionState {
27
30
  getTurnDispatchCount(): number; setTurnDispatchCount(value: number): void;
@@ -40,9 +43,13 @@ export interface DispatchExecutionState {
40
43
  getUserLanguage(): string;
41
44
  getSessionDir(): string;
42
45
  getAgentStates(): Map<string, AgentState>;
46
+ getAssertions(): Array<{ id: string; tag: string; text: string; source: string; reference?: string; criticalConditions?: string[]; testCommand?: string; status: string; evidence?: string; evidenceTaskId?: string; evidenceRevision?: string }>;
43
47
  getResearchPersonas(): ResearchAgentDef[];
44
48
  getActiveWritableDispatches(): number; setActiveWritableDispatches(value: number): void;
45
49
  getWritableOverlapCounter(): number; setWritableOverlapCounter(value: number): void;
50
+ getProcessState?(): ProcessObligationState;
51
+ setProcessState?(value: ProcessObligationState): void;
52
+ persistProcessVerdict?(state: ProcessObligationState, verdict: ProcessVerdict): void;
46
53
  }
47
54
 
48
55
  export interface DispatchExecutorDeps {
@@ -53,16 +60,18 @@ export interface DispatchExecutorDeps {
53
60
  artifacts: AssertionsArtifactsContext;
54
61
  research: ResearchRuntime<any>;
55
62
  provisionalCapabilityRefusal(pack: "fleet"): ToolExecutionResult | null;
56
- dispatchAgent(agent: string, task: string, ctx: ExtensionContext, artifacts: InputArtifactPreview[], scope: string[], watchdog?: boolean, backend?: "auto" | "native" | "coms", resume?: boolean): Promise<DispatchResult>;
63
+ dispatchAgent(agent: string, task: string, ctx: ExtensionContext, artifacts: InputArtifactPreview[], scope: string[], watchdog?: boolean, backend?: "auto" | "native" | "coms", resume?: boolean, resumeContract?: Omit<TaskResumeInput, "previous">): Promise<DispatchResult>;
57
64
  runReturnExtraction(path: string, ids: string[], ctx: ExtensionContext): Promise<any>;
58
65
  extractNeedsResearch(output: string): string[];
59
66
  extractAskUserQuestions(output: string): string[];
60
67
  contextPressure(percent: number): boolean;
61
68
  displayName(name: string): string;
69
+ getToolCatalogVersion?(): string;
70
+ resolvedAgentModel?(def: AgentState["def"], ctx: ExtensionContext): string | undefined;
62
71
  diagnoseChangedTypeScript?: typeof diagnoseChangedTypeScript;
63
72
  }
64
73
 
65
- interface PreparedDispatch { taskToken: object; contract: DeliverableContract; sessionDir: string; agent: string; task: string; inputArtifacts: InputArtifactPreview[]; scopeGlobs: string[]; fingerprint: string; }
74
+ interface PreparedDispatch { taskToken: object; taskId: string; beforeRevision: string; requirements: AcceptanceRequirement[]; contract: DeliverableContract; resumeContract: Omit<TaskResumeInput, "previous">; sessionDir: string; agent: string; task: string; inputArtifacts: InputArtifactPreview[]; scopeGlobs: string[]; fingerprint: string; }
66
75
  interface RunData { result: DispatchResult; billed: number; out: number; researchRounds: { questions: string[]; files: string[] }[]; autoResearchTaskCapped: boolean; }
67
76
  interface Tracking { writable: boolean; snapshot: any; overlapBaseline: number; concurrentAtStart: boolean; }
68
77
  interface WorktreeObservation { skipped: boolean; reason?: string; paths: string[]; concurrentWritableOverlap: boolean; }
@@ -71,7 +80,8 @@ export function preflightGate(d: DispatchExecutorDeps, persona: string): Gate {
71
80
  const s = d.state;
72
81
  const blocked = checkExternalBlockerGate({ blockers: s.getExternalBlockers(), acknowledged: s.getExternalBlockerAcknowledged(), askUserAvailable: s.isAskUserAvailable(), refusedOnce: s.getExternalBlockerRefusedOnce() });
73
82
  if (blocked) { s.setExternalBlockerRefusedOnce(true); return blocked; }
74
- return checkTierPersonaGate(s.getTaskTier(), persona);
83
+ const process = s.getProcessState?.();
84
+ return process && processAllowsPersona(process, persona) ? null : checkTierPersonaGate(s.getTaskTier(), persona);
75
85
  }
76
86
 
77
87
  function refusal(d: DispatchExecutorDeps, agent: string, task: string, status: string, message: string, reason?: string): ToolExecutionResult {
@@ -110,12 +120,37 @@ export function validateDispatchAgent(d: DispatchExecutorDeps, agent: string, ta
110
120
  return null;
111
121
  }
112
122
 
123
+ function dispatchRequirements(d: DispatchExecutorDeps, agent: string, task: string): AcceptanceRequirement[] {
124
+ const state = d.state.getAgentStates().get(agent.toLowerCase());
125
+ if (!state || !hasWriteCapability(state.def.tools)) return [];
126
+ const ids = new Set(extractAssertionIds(task));
127
+ const ledger = d.state.getAssertions().filter(assertion => ids.size === 0 || ids.has(assertion.id)).map(assertion => ({
128
+ id: assertion.id, tag: assertion.tag, text: assertion.text, source: assertion.source,
129
+ reference: assertion.reference, criticalConditions: assertion.criticalConditions, testCommand: assertion.testCommand,
130
+ status: assertion.status as AcceptanceRequirement["status"], evidenceTaskId: assertion.evidenceTaskId,
131
+ evidenceRevision: assertion.evidenceRevision, evidenceRefs: assertion.evidence ? [assertion.evidence] : [],
132
+ }));
133
+ return [...ledger, minimalChangeRequirement()];
134
+ }
135
+
136
+ function appendRuntimeAcceptanceContract(task: string, requirements: AcceptanceRequirement[]): string {
137
+ if (!requirements.length) return task;
138
+ const lines = requirements.map(requirement => {
139
+ const origin = [requirement.source, requirement.reference].filter(Boolean).join(" · ");
140
+ const critical = requirement.criticalConditions?.length ? ` Critical: ${requirement.criticalConditions.join("; ")}.` : "";
141
+ return `- ${requirement.id} [${requirement.tag}]: ${requirement.text} (source: ${origin}).${critical}${requirement.testCommand ? ` Explicit verification command: ${JSON.stringify(requirement.testCommand)} (execute only through approved bash).` : ""}`;
142
+ });
143
+ return `${task}\n\n## Runtime acceptance contract (machine-appended)\nThese requirements survive dispatch and compaction. A claim, file presence, or listed command is not proof; report evidence, while the runtime decides acceptance.\n${lines.join("\n")}`;
144
+ }
145
+
113
146
  export function prepareDispatch(d: DispatchExecutorDeps, params: DispatchAgentParams, ctx: ExtensionContext): PreparedDispatch | ToolExecutionResult {
114
147
  const s = d.state; const { task, artifacts, scope, review_reason } = params; const agent = normalizeAgentInput(params.agent);
115
- d.budget.ensureTaskTier();
116
148
  const rosterRefusal = validateDispatchAgent(d, agent, task);
117
149
  if (rosterRefusal) return rosterRefusal;
118
- const preflight = preflightGate(d, agent) ?? checkReviewRoundCap(s.getTaskTier(), agent, s.getTaskReviewRounds()) ?? checkDocsLane(agent, scope || [], review_reason);
150
+ if (s.getAgentStates().get(agent)?.status === "running") return { content: [{ type: "text", text: "Agent is busy; nothing started, queued or charged. Re-invoke explicitly after it is idle." }], details: { status: "busy", reason: "busy", recoveryCategory: "busy", started: false, exitCode: 1 } };
151
+ d.budget.ensureTaskTier();
152
+ const processGate = s.getProcessState ? processPreEffectGate(s.getProcessState(), "child", agent) : { reason: "process_state_unavailable", message: "Process state is unavailable; child launch fails closed." };
153
+ const preflight = preflightGate(d, agent) ?? processGate ?? checkReviewRoundCap(s.getTaskTier(), agent, s.getTaskReviewRounds()) ?? checkDocsLane(agent, scope || [], review_reason);
119
154
  if (preflight) return refusal(d, agent, task, preflight.reason, preflight.message, preflight.reason);
120
155
  const taskRefusal = checkTaskBudget("dispatch", d.budget.taskCounters(), d.budget.currentTaskBudget(), d.budget.taskActiveElapsedMs(), s.getTaskTier());
121
156
  if (taskRefusal) return refusal(d, agent, task, "task_budget_refused", taskRefusal.message, taskRefusal.reason);
@@ -132,8 +167,18 @@ export function prepareDispatch(d: DispatchExecutorDeps, params: DispatchAgentPa
132
167
  s.setTurnDispatchCount(s.getTurnDispatchCount() + 1); s.setTaskDispatchCount(s.getTaskDispatchCount() + 1);
133
168
  if (isReviewPersona(agent)) s.setTaskReviewRounds(s.getTaskReviewRounds() + 1);
134
169
  s.getSessionTotals().dispatches++; d.budget.updateModeStatus();
135
- const declaredTask = contract.files.length ? `${task}\n\n## Expected deliverables (explicit contract)\nProduce these exact files and report their paths. The hub will read them back; a prose claim is not delivery.\n${contract.files.map(file => `- ${file.path}`).join("\n")}` : task;
136
- return { taskToken: d.noProgress.taskToken(), contract, sessionDir: s.getSessionDir(), agent, task: declaredTask, inputArtifacts, scopeGlobs: (scope || []).map(String).map(x => x.trim()).filter(Boolean), fingerprint };
170
+ const scopeGlobs = (scope || []).map(String).map(x => x.trim()).filter(Boolean);
171
+ const requirements = dispatchRequirements(d, agent, task);
172
+ const acceptedTask = appendRuntimeAcceptanceContract(task, requirements);
173
+ const declaredTask = contract.files.length ? `${acceptedTask}\n\n## Expected deliverables (explicit contract)\nProduce these exact files and report their paths. The hub will read them back; a prose claim is not delivery.\n${contract.files.map(file => `- ${file.path}`).join("\n")}` : acceptedTask;
174
+ const agentState = s.getAgentStates().get(agent.toLowerCase());
175
+ const resumeContract = {
176
+ taskId: d.noProgress.taskId(), instructions: declaredTask, scope: scopeGlobs,
177
+ deliverables: contract.files.map(file => file.path), artifacts: inputArtifacts.map(artifact => artifact.path),
178
+ model: agentState ? (d.resolvedAgentModel?.(agentState.def, ctx) ?? agentState.def.model ?? (ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : null)) : null,
179
+ permissions: agentState?.def.tools ?? "",
180
+ };
181
+ return { taskToken: d.noProgress.taskToken(), taskId: resumeContract.taskId, beforeRevision: worktreeRevision(ctx.cwd || process.cwd(), []), requirements, contract, resumeContract, sessionDir: s.getSessionDir(), agent, task: declaredTask, inputArtifacts, scopeGlobs, fingerprint };
137
182
  }
138
183
 
139
184
  function startTracking(d: DispatchExecutorDeps, prepared: PreparedDispatch, ctx: ExtensionContext): Tracking {
@@ -150,7 +195,7 @@ function startTracking(d: DispatchExecutorDeps, prepared: PreparedDispatch, ctx:
150
195
 
151
196
  async function runWithAutoResearch(d: DispatchExecutorDeps, p: PreparedDispatch, params: DispatchAgentParams, ctx: ExtensionContext, onUpdate: ToolUpdate): Promise<RunData> {
152
197
  const findingClause = reviewBudgetClause(d.state.getTaskTier(), p.agent); const dispatchedTask = findingClause ? `${p.task}\n\n${findingClause}` : p.task;
153
- let result = await d.dispatchAgent(p.agent, dispatchedTask, ctx, p.inputArtifacts, p.scopeGlobs, params.watchdog, params.backend ?? "auto");
198
+ let result = await d.dispatchAgent(p.agent, dispatchedTask, ctx, p.inputArtifacts, p.scopeGlobs, params.watchdog, params.backend ?? "auto", false, p.resumeContract);
154
199
  let billed = result.billed ?? 0; let out = result.out ?? 0; const researchRounds: RunData["researchRounds"] = []; let autoResearchTaskCapped = false;
155
200
  while (result.exitCode === 0 && researchRounds.length < MAX_AUTO_RESEARCH_ROUNDS && p.taskToken === d.noProgress.taskToken() && p.sessionDir === d.state.getSessionDir()) {
156
201
  const left = remainingTaskResearch(d.budget.currentTaskBudget(), d.budget.taskCounters()); if (left === 0) { autoResearchTaskCapped = true; break; }
@@ -166,7 +211,7 @@ async function runWithAutoResearch(d: DispatchExecutorDeps, p: PreparedDispatch,
166
211
  researchRounds.push({ questions, files: answered.map(a => a.file) });
167
212
  const resume = "Research findings for your NEEDS_RESEARCH questions are ready. Read each file with your read tool, then continue from where you paused:\n" + answered.map((a, i) => `${i + 1}. ${a.question}\n → ${a.file}`).join("\n");
168
213
  if (p.taskToken !== d.noProgress.taskToken() || p.sessionDir !== d.state.getSessionDir()) break;
169
- result = await d.dispatchAgent(p.agent, resume, ctx, p.inputArtifacts, p.scopeGlobs, params.watchdog, params.backend ?? "auto", true); billed += result.billed ?? 0; out += result.out ?? 0;
214
+ result = await d.dispatchAgent(p.agent, resume, ctx, p.inputArtifacts, p.scopeGlobs, params.watchdog, params.backend ?? "auto", true, p.resumeContract); billed += result.billed ?? 0; out += result.out ?? 0;
170
215
  }
171
216
  return { result, billed, out, researchRounds, autoResearchTaskCapped };
172
217
  }
@@ -214,6 +259,7 @@ async function finishDispatch(d: DispatchExecutorDeps, p: PreparedDispatch, para
214
259
 
215
260
  // The one shared post-run delta feeds both scope reporting and compiler selection.
216
261
  let compilerDiagnostics: DiagnosticsResult | null = null; let compilerEvidencePath: string | null = null; let compilerEvidenceError: string | null = null;
262
+ const compilerInspectedRevision = worktreeRevision(cwd, []);
217
263
  const eligibleForCompiler = disposition.delivered && tracking.writable && backendUsed === "native" && sameTaskNow();
218
264
  if (eligibleForCompiler && observation?.skipped) {
219
265
  compilerDiagnostics = incompleteObservation(`worktree observation unavailable: ${observation.reason ?? "unknown reason"}`, observation.concurrentWritableOverlap);
@@ -248,19 +294,93 @@ async function finishDispatch(d: DispatchExecutorDeps, p: PreparedDispatch, para
248
294
  }
249
295
  const readback = disposition.pending ? [] : readBackDeliverables(p.contract, { cwd, sessionDir: p.sessionDir },
250
296
  (index, bytes) => retainDeliverable(p.sessionDir, assessmentId, index, bytes));
251
- const deliverableFailed = readback.some(file => file.status !== "read");
297
+ let protocolDiagnostic: ToolProtocolDiagnostic | null = null; let protocolEvidencePath: string | null = null;
298
+ if (disposition.delivered && backendUsed === "native") {
299
+ protocolDiagnostic = diagnoseToolProtocol({
300
+ output: result.output,
301
+ toolEvents: result.toolEvents ?? [],
302
+ deliverables: readback,
303
+ origin: { kind: "task", taskId: p.taskId, dispatchId: result.dispatchId ?? assessmentId },
304
+ effectiveConfiguration: {
305
+ backend: backendUsed,
306
+ model: result.diagnostics?.modelUsed ?? state?.def.model ?? null,
307
+ tools: result.diagnostics?.effectiveTools ?? String(state?.def.tools ?? "").split(",").map(tool => tool.trim()).filter(Boolean),
308
+ },
309
+ evidenceRefs: [returnPath ?? undefined, ...readback.map(item => item.retainedPath)].filter((value): value is string => !!value),
310
+ });
311
+ if (protocolDiagnostic) {
312
+ protocolEvidencePath = d.artifacts.writeRunArtifact(`${key}-tool-protocol`, state?.runCount ?? 0,
313
+ JSON.stringify(protocolDiagnostic, null, 2), "evidence", randomUUID(), p.sessionDir);
314
+ protocolDiagnostic.evidenceRefs = [...new Set([...protocolDiagnostic.evidenceRefs, protocolEvidencePath])];
315
+ }
316
+ }
252
317
  const executionStatus = disposition.pending ? "pending" : disposition.delivered ? "completed" : "failed";
253
- const status = disposition.delivered ? deliverableFailed ? "verification_failed" : "completed_unverified" : disposition.status;
254
- const acceptanceStatus = disposition.pending || !disposition.delivered ? "not_available" : deliverableFailed ? "deliverable_failed" : "needs_verification";
255
- const assessment = { executionStatus, acceptanceStatus, accepted: false, dispatchId: result.dispatchId ?? null, readback, scopeRoots: p.contract.scopeRoots,
256
- assertions: ids, structuredReturn: parsedReturn, contractNotices, compilerDiagnostics, compilerEvidencePath };
318
+ const afterRevision = worktreeRevision(cwd, []);
319
+ const changes = !tracking.writable || !observation
320
+ ? { status: "unknown" as const, paths: [] as string[], attribution: "not_observed" as const }
321
+ : observation.skipped
322
+ ? { status: "unknown" as const, paths: [] as string[], attribution: "not_observed" as const }
323
+ : { status: observation.paths.length ? "changed" as const : "unchanged" as const, paths: observation.paths, attribution: observation.concurrentWritableOverlap ? "uncertain" as const : "certain" as const };
324
+ const checks: VerificationCheckInput[] = (compilerDiagnostics?.projects ?? []).map(project => ({
325
+ producer: "runtime", kind: "compilation", taskId: p.taskId, command: [...(project.argv ?? [])], exitCode: project.exitCode,
326
+ inspectedRevision: compilerInspectedRevision, evidenceRef: compilerEvidencePath ?? "",
327
+ requirementIds: ["AF-MIN-CHANGE"],
328
+ }));
329
+ for (const record of backendUsed === "native" && tracking.writable ? result.runtimeTests ?? [] : []) for (const kind of ["test", "code-grep"] as const) {
330
+ const covered = p.requirements.filter(requirement => requirement.tag === kind && requirement.source && requirement.testCommand === record.command);
331
+ if (!covered.length) continue;
332
+ const evidenceRef = d.artifacts.writeRunArtifact(`${key}-test-check`, state?.runCount ?? 0, JSON.stringify({ taskId: p.taskId, dispatchId: result.dispatchId, record, requirements: covered }, null, 2), "evidence", randomUUID(), p.sessionDir);
333
+ checks.push({ producer: "runtime", kind, command: [record.command], exitCode: record.exitCode,
334
+ inspectedRevision: record.beforeRevision === record.afterRevision ? record.afterRevision : "changed-during-check",
335
+ evidenceRef, requirementIds: ["AF-MIN-CHANGE", ...covered.map(requirement => requirement.id)], taskId: p.taskId,
336
+ coverage: covered.map(requirement => ({ id: requirement.id, source: requirement.source, text: requirement.text, reference: requirement.reference, criticalConditions: requirement.criticalConditions ?? [] })),
337
+ });
338
+ }
339
+ const runtimeResult: any = buildRuntimeResult({
340
+ task: { id: p.taskId, current: sameTask && p.taskId === d.noProgress.taskId(), beforeRevision: p.beforeRevision, afterRevision },
341
+ execution: { status: executionStatus, exitCode: result.exitCode, dispatchId: result.dispatchId ?? null },
342
+ changes, requirements: p.requirements, deliverables: readback, checks,
343
+ evidenceRefs: [returnPath ?? undefined, failurePath ?? undefined, compilerEvidencePath ?? undefined, protocolEvidencePath ?? undefined].filter((value): value is string => !!value),
344
+ });
345
+ let processVerdict: ProcessVerdict | null = null;
346
+ if (s.getProcessState) {
347
+ let processState = s.getProcessState();
348
+ if (runtimeResult.acceptance.accepted && runtimeResult.verification.evidenceRefs[0]) {
349
+ processState = noteProcessStage(processState, "acceptance", { evidenceRef: runtimeResult.verification.evidenceRefs[0], revision: afterRevision, changedFiles: observation.paths });
350
+ }
351
+ const stage = p.agent === "planner" ? "plan" : isReviewPersona(p.agent) ? "review" : null;
352
+ const affirmativeReview = /(?:^|\n)\s*(?:verdict\s*:\s*)?APPROVE\b/im.test(result.output) && !/(?:^|\n)\s*(?:verdict\s*:\s*)?REJECT\b/im.test(result.output);
353
+ const reviewScope = checkScope(processState.changedFiles, p.scopeGlobs);
354
+ const reviewAuthorized = stage !== "review" || (affirmativeReview && processState.changedFiles.length > 0 && reviewScope.outOfScope.length === 0);
355
+ if (stage && reviewAuthorized && disposition.delivered && result.exitCode === 0 && sameTask && runPath) {
356
+ processState = noteProcessStage(processState, stage, { evidenceRef: runPath, revision: afterRevision });
357
+ }
358
+ s.setProcessState?.(processState);
359
+ processVerdict = evaluateProcessObligations(processState, { writable: tracking.writable || stage !== null, budgetTier: s.getTaskTier() ?? "small", t2Accepted: runtimeResult.acceptance.accepted, currentRevision: afterRevision });
360
+ runtimeResult.process = processVerdict;
361
+ if (!processVerdict.accepted) {
362
+ runtimeResult.acceptance = { status: "not_accepted", accepted: false, reasons: [...new Set([...runtimeResult.acceptance.reasons, ...Object.entries(processVerdict.obligations).filter(([, value]) => value.status === "open").map(([name]) => `process_${name}_open`)])] };
363
+ if (runtimeResult.compatibility.hubAcceptanceStatus !== "deliverable_failed") runtimeResult.compatibility = { hubAcceptanceStatus: "needs_verification", flowStatus: "rejected" };
364
+ }
365
+ s.persistProcessVerdict?.(processState, processVerdict);
366
+ }
367
+ const accepted = runtimeResult.acceptance.accepted;
368
+ const acceptanceStatus = runtimeResult.compatibility.hubAcceptanceStatus;
369
+ const status = protocolDiagnostic ? "tool_protocol_error" : accepted ? "accepted" : executionStatus === "completed" && (runtimeResult.verification.status === "failed" || acceptanceStatus === "deliverable_failed") ? "verification_failed" : executionStatus === "completed" ? "completed_unverified" : disposition.status;
370
+ const assessment = { ...runtimeResult,
371
+ executionStatus, acceptanceStatus, accepted, dispatchId: result.dispatchId ?? null, readback, scopeRoots: p.contract.scopeRoots,
372
+ assertions: ids, structuredReturn: parsedReturn, contractNotices, compilerDiagnostics, compilerEvidencePath, protocolDiagnostic, protocolEvidencePath };
257
373
  const assessmentPath = disposition.pending ? null : d.artifacts.writeRunArtifact(`${key}-acceptance`, state?.runCount ?? 0, JSON.stringify(assessment, null, 2), "evidence", assessmentId, p.sessionDir);
258
374
  if (sameTask && [0, 124, 125].includes(result.exitCode)) s.getTurnDispatchFingerprints().add(p.fingerprint);
259
375
  if (sameTask) { s.getTurnReport().dispatches.push({ agent: p.agent, status, elapsed: result.elapsed, billed: run.billed, out: run.out }); s.getSessionTotals().billed += run.billed; s.getSessionTotals().out += run.out; }
260
376
  const questions = d.extractAskUserQuestions(result.output); const unresolved = d.extractNeedsResearch(result.output); const answered = researchRounds.reduce((n, r) => n + r.questions.length, 0);
261
377
  const notices: string[] = [];
262
378
  if (!sameTask) notices.push("Late result from a prior task/session: evidence retained in its original namespace; current-task counters and blockers were not changed.");
263
- if (disposition.delivered) notices.push(`Execution completed, NOT accepted. ${deliverableFailed ? "Expected deliverable readback failed." : "Verify correctness against the assertion ledger; file presence and exit 0 are not proof."} Acceptance check: ${assessmentPath}`);
379
+ if (disposition.delivered) notices.push(accepted
380
+ ? `Execution and current-state verification accepted by the runtime contract. Acceptance check: ${assessmentPath}`
381
+ : protocolDiagnostic
382
+ ? `Tool protocol error: ${protocolDiagnostic.message} Evidence: ${protocolEvidencePath}. No text was executed and no retry was started.`
383
+ : `Execution completed, NOT accepted. ${acceptanceStatus === "deliverable_failed" ? "Expected deliverable readback failed." : "Verification is missing, failed, stale, unsupported, or attribution-uncertain; file presence, exit 0, and claims are not proof."} Acceptance check: ${assessmentPath}`);
264
384
  if (readback.some(file => file.changed === false)) notices.push("Some deliverables already existed unchanged. Do not attribute their creation to this execution.");
265
385
  const blockers = extractExternalBlockers(result.output); if (sameTask && blockers.length) { for (const what of blockers) if (!s.getExternalBlockers().some(b => b.what === what)) s.getExternalBlockers().push({ agent: p.agent, what }); s.setExternalBlockerAcknowledged(false); s.setExternalBlockerRefusedOnce(false); notices.push(`⛔ ${p.agent} reported an EXTERNAL BLOCKER — something outside the fleet's reach is missing:\n${blockers.map((w, i) => ` ${i + 1}. ${w}`).join("\n")}\nThe next dispatch/research call is refused until you escalate this to the human. Do not build a substitute for the missing fact.`); }
266
386
  if (questions.length) notices.push(`⚠ ${questions.length} ASK_USER question(s) raised by ${p.agent}. You MUST call ask_user for each (in ${s.getUserLanguage()}) before re-dispatching:\n${questions.map((q, i) => ` ${i + 1}. ${q}`).join("\n")}`);
@@ -283,16 +403,46 @@ async function finishDispatch(d: DispatchExecutorDeps, p: PreparedDispatch, para
283
403
  const docs = docsLaneNotice(p.agent, p.scopeGlobs); if (docs) notices.push(docs);
284
404
  const contract = contractNoticeText(contractNotices); const extraction = returnExtracted ? "ℹ The specialist declared no structured return. The block below was EXTRACTED from its report by a cheap read-only pass — weaker than a declared return. Verify the named evidence before you gate on it." : "";
285
405
  const digest = shouldUseDigest ? [extraction, structuredReturnDigest(parsedReturn) || "Structured return: (none parsed)", contract].filter(Boolean).join("\n\n") : (result.output.length > 8000 ? `${result.output.slice(0, 8000)}\n\n... [truncated]` : result.output);
286
- return { content: [{ type: "text", text: `[${p.agent}] ${status} in ${Math.round(result.elapsed / 1000)}s${notices.length ? `\n\n${notices.join("\n\n")}` : ""}\n\n${digest}` }], details: { agent: p.agent, task: p.task, status, executionStatus, acceptanceStatus, accepted: false, staleTask: !sameTask, deliverableReadback: readback, scopeRoots: p.contract.scopeRoots, assessmentPath, backendRequested: params.backend ?? "auto", backendUsed, elapsed: result.elapsed, exitCode: result.exitCode, fullOutput: result.output, dispatchId: result.dispatchId ?? null, transcriptPath: result.transcriptPath ?? null, diagnostics: result.diagnostics ?? null, evidencePath: result.evidencePath ?? null, compilerDiagnostics, compilerEvidencePath, structuredReturn: parsedReturn, returnExtracted, pending: disposition.pending, returnPath, failurePath, contractNotices, questions, researchRounds, scopeViolations, sessionReset: result.sessionReset ?? null, artifacts: p.inputArtifacts.map(a => ({ path: a.path, displayPath: a.displayPath, preview: a.preview, resolvedFromKind: a.resolvedFromKind ?? null })) } };
406
+ return { content: [{ type: "text", text: `[${p.agent}] ${status} in ${Math.round(result.elapsed / 1000)}s${notices.length ? `\n\n${notices.join("\n\n")}` : ""}${processVerdict ? `\n\nProcess: ${processVerdict.explanation}` : ""}\n\n${digest}` }], details: { agent: p.agent, task: p.task, status, ...(protocolDiagnostic ? { recoveryCategory: "tool_protocol_error", reason: protocolDiagnostic.message, protocolDiagnostic, protocolEvidencePath, protocolEffectsEvidenceRef: protocolEvidencePath } : { protocolDiagnostic: null, protocolEvidencePath: null }), executionStatus, acceptanceStatus, accepted, runtimeResult, processVerdict, taskIdentity: runtimeResult.task, changeResult: runtimeResult.changes, verificationResult: runtimeResult.verification, staleTask: !sameTask, deliverableReadback: readback, scopeRoots: p.contract.scopeRoots, assessmentPath, backendRequested: params.backend ?? "auto", backendUsed, elapsed: result.elapsed, exitCode: result.exitCode, fullOutput: result.output, dispatchId: result.dispatchId ?? null, transcriptPath: result.transcriptPath ?? null, diagnostics: result.diagnostics ?? null, evidencePath: result.evidencePath ?? null, compilerDiagnostics, compilerEvidencePath, structuredReturn: parsedReturn, returnExtracted, pending: disposition.pending, returnPath, failurePath, contractNotices, questions, researchRounds, scopeViolations, sessionReset: result.sessionReset ?? null, artifacts: p.inputArtifacts.map(a => ({ path: a.path, displayPath: a.displayPath, preview: a.preview, resolvedFromKind: a.resolvedFromKind ?? null })) } };
407
+ }
408
+
409
+ function dispatchExecutionConditions(d: DispatchExecutorDeps, params: DispatchAgentParams, ctx: ExtensionContext): Record<string, unknown> {
410
+ const state = d.state.getAgentStates().get(normalizeAgentInput(params.agent));
411
+ return {
412
+ model: (state ? d.resolvedAgentModel?.(state.def, ctx) : undefined) ?? state?.def.model ?? (ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : null),
413
+ backend: params.backend ?? "auto",
414
+ };
415
+ }
416
+
417
+ function researchExecutionConditions(d: DispatchExecutorDeps, params: SpawnResearchParams, ctx: ExtensionContext): Record<string, unknown> {
418
+ const persona = params.persona ? d.state.getResearchPersonas().find(item => item.name.toLowerCase() === params.persona!.toLowerCase()) : undefined;
419
+ try {
420
+ const def = persona ?? d.research.anonymousDef();
421
+ return { model: d.research.resolveModel(def, persona ? undefined : params.model, ctx), tools: "read,grep,find,ls" };
422
+ } catch {
423
+ return { model: params.model ?? null, tools: "read,grep,find,ls" };
424
+ }
425
+ }
426
+
427
+ export function structuredResearchPrompt(params: SpawnResearchParams): string {
428
+ const contract = normalizeResearchContract(params);
429
+ if (!contract.readScope.length && !contract.goal && !contract.expectedResult) return params.task;
430
+ return [params.task, "", "## Structured research contract",
431
+ contract.readScope.length ? `Read scope:\n${contract.readScope.map(path => `- ${path}`).join("\n")}` : "Read scope: not declared",
432
+ contract.goal ? `Goal: ${contract.goal}` : "Goal: not declared",
433
+ contract.expectedResult ? `Expected result: ${contract.expectedResult}` : "Expected result: not declared",
434
+ ].join("\n");
287
435
  }
288
436
 
289
437
  export function createDispatchExecutor(d: DispatchExecutorDeps): ToolExecutor<DispatchAgentParams> {
290
438
  return withNoProgress(d, "dispatch", async (_id, params, signal, onUpdate, ctx) => {
291
439
  const capability = d.provisionalCapabilityRefusal("fleet"); if (capability) return capability;
292
- d.budget.ensureTaskTier();
293
440
  const agent = normalizeAgentInput(params.agent);
294
441
  const invalid = validateDispatchAgent(d, agent, params.task); if (invalid) return invalid;
295
- const preflight = preflightGate(d, agent) ?? checkReviewRoundCap(d.state.getTaskTier(), agent, d.state.getTaskReviewRounds()) ?? checkDocsLane(agent, params.scope || [], params.review_reason);
442
+ if (d.state.getAgentStates().get(agent)?.status === "running") return { content: [{ type: "text", text: "Agent is busy; nothing started, queued or charged. Re-invoke explicitly after it is idle." }], details: { status: "busy", reason: "busy", recoveryCategory: "busy", started: false, exitCode: 1 } };
443
+ d.budget.ensureTaskTier();
444
+ const processGate = d.state.getProcessState ? processPreEffectGate(d.state.getProcessState(), "child", agent) : { reason: "process_state_unavailable", message: "Process state is unavailable; child launch fails closed." };
445
+ const preflight = preflightGate(d, agent) ?? processGate ?? checkReviewRoundCap(d.state.getTaskTier(), agent, d.state.getTaskReviewRounds()) ?? checkDocsLane(agent, params.scope || [], params.review_reason);
296
446
  if (preflight) return refusal(d, agent, params.task, preflight.reason, preflight.message);
297
447
  try { preflightDeliverables(params, { cwd: ctx.cwd || process.cwd(), sessionDir: d.state.getSessionDir() }); }
298
448
  catch (error) { return refusal(d, agent, params.task, "scope_preflight_failed", String(error)); }
@@ -304,7 +454,7 @@ export function createDispatchExecutor(d: DispatchExecutorDeps): ToolExecutor<Di
304
454
  try { onUpdate?.({ content: [{ type: "text", text: `Dispatching to ${prepared.agent}...` }], details: { agent: prepared.agent, task: prepared.task, status: "dispatching" } }); return await finishDispatch(d, prepared, params, await runWithAutoResearch(d, prepared, params, ctx, onUpdate), tracking, ctx, onUpdate); }
305
455
  catch (err: any) { return { content: [{ type: "text", text: `Error dispatching to ${prepared.agent}: ${err?.message || err}` }], details: { agent: prepared.agent, task: prepared.task, status: "error", elapsed: 0, exitCode: 1, fullOutput: "" } }; }
306
456
  finally { if (tracking.writable) d.state.setActiveWritableDispatches(Math.max(0, d.state.getActiveWritableDispatches() - 1)); }
307
- });
457
+ }, (params, ctx) => dispatchExecutionConditions(d, params, ctx));
308
458
  }
309
459
 
310
460
  export function createResearchExecutor(d: DispatchExecutorDeps): ToolExecutor<SpawnResearchParams> {
@@ -324,9 +474,9 @@ export function createResearchExecutor(d: DispatchExecutorDeps): ToolExecutor<Sp
324
474
  try { artifacts = d.artifacts.loadInputArtifacts(params.artifacts, ctx); } catch (err: any) { return { content: [{ type: "text", text: `⚠ Research NOT spawned and NOT counted against the turn budget — input artifact could not be resolved:\n${err?.message || err}\n\nFix the path and try again.` }], details: { status: "artifact_preflight_failed" } }; }
325
475
  s.setTurnResearchCount(s.getTurnResearchCount() + 1); s.setTaskResearchCount(s.getTaskResearchCount() + 1); s.getTurnReport().research++; s.getSessionTotals().research++; d.budget.updateModeStatus();
326
476
  const state = d.research.createState(def, persona, model); onUpdate?.({ content: [{ type: "text", text: `Spawning research helper r${state.id}...` }], details: { handle: `r${state.id}`, persona: persona ? def.name : null, status: "spawning" } });
327
- try { const result = await d.research.spawn(state, params.task, ctx, artifacts, signal); const status = result.termination ? result.termination.reason : result.exitCode === 0 ? "done" : "error"; const output = result.output.length > 8000 ? `${result.output.slice(0, 8000)}\n\n... [truncated]` : result.output; return { content: [{ type: "text", text: `[research r${state.id} · ${persona ? d.displayName(def.name) : "ad-hoc"} · read-only] ${status} in ${Math.round(result.elapsed / 1000)}s\n\n${output}${result.evidencePath ? `\n\nFull execution evidence: ${result.evidencePath}` : ""}` }], details: { handle: `r${state.id}`, persona: persona ? def.name : null, model, status, elapsed: result.elapsed, exitCode: result.exitCode, fullOutput: result.output, dispatchId: result.dispatchId, evidencePath: result.evidencePath, transcriptPath: result.transcriptPath, termination: result.termination, artifacts: artifacts.map(a => ({ path: a.path, displayPath: a.displayPath, preview: a.preview, resolvedFromKind: a.resolvedFromKind ?? null })) } }; }
328
- catch (err: any) { return { content: [{ type: "text", text: `Error spawning research helper: ${err?.message || err}` }], details: { handle: `r${state.id}`, status: "error", elapsed: 0, exitCode: 1, fullOutput: "" } }; }
329
- });
477
+ try { const result = await d.research.spawn(state, structuredResearchPrompt(params), ctx, artifacts, signal); const status = result.termination ? result.termination.reason : result.exitCode === 0 ? "done" : "error"; const output = result.output.length > 8000 ? `${result.output.slice(0, 8000)}\n\n... [truncated]` : result.output; return { content: [{ type: "text", text: `[research r${state.id} · ${persona ? d.displayName(def.name) : "ad-hoc"} · read-only] ${status} in ${Math.round(result.elapsed / 1000)}s\n\n${output}${result.evidencePath ? `\n\nFull execution evidence: ${result.evidencePath}` : ""}` }], details: { handle: `r${state.id}`, persona: persona ? def.name : null, model, status, elapsed: result.elapsed, exitCode: result.exitCode, fullOutput: result.output, dispatchId: result.dispatchId, evidencePath: result.evidencePath, transcriptPath: result.transcriptPath, termination: result.termination, researchContract: normalizeResearchContract(params), artifacts: artifacts.map(a => ({ path: a.path, displayPath: a.displayPath, preview: a.preview, resolvedFromKind: a.resolvedFromKind ?? null })) } }; }
478
+ catch (err: any) { return { content: [{ type: "text", text: `Error spawning research helper: ${err?.message || err}` }], details: { handle: `r${state.id}`, model, status: "error", elapsed: 0, exitCode: 1, fullOutput: "" } }; }
479
+ }, (params, ctx) => researchExecutionConditions(d, params, ctx));
330
480
  }
331
481
 
332
482
  function hasWriteCapability(tools: string): boolean { const set = new Set(String(tools || "").split(",").map(x => x.trim()).filter(Boolean)); return ["write", "edit", "bash"].some(x => set.has(x)); }
@@ -0,0 +1,122 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
2
+ import { Type } from "@sinclair/typebox";
3
+ import { randomUUID } from "node:crypto";
4
+ import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
5
+ import { join } from "node:path";
6
+ import { tmpdir } from "node:os";
7
+ import { executeFlow, type HubScoutExecution } from "../../../agent-fleet/scripts/flow.ts";
8
+ import { createIsolatedWorkingTreeSnapshot, type IsolatedSnapshotManifest } from "../../../agent-fleet/scripts/workflows/lib/isolated-snapshot.ts";
9
+ import type { ScoutWorkflowDeps } from "../../../agent-fleet/scripts/workflows/wf-scout.ts";
10
+ import { worktreeRevision } from "../scope-gate.js";
11
+ import { buildRuntimeResult } from "../acceptance.ts";
12
+
13
+ export interface RunFlowParams { procedure: "scout"; request: string; invocation_id: string }
14
+ export interface HubFlowBudgetReservation { charged: boolean; operation: "research"; owner: "hub"; refusal?: string }
15
+ export interface RunFlowDeps {
16
+ sessionDir(): string | null;
17
+ taskId(): string;
18
+ reserveBudget(params: RunFlowParams, ctx: ExtensionContext, signal?: AbortSignal): Promise<HubFlowBudgetReservation>;
19
+ processObligations(): unknown;
20
+ effectiveScoutConfig(cwd: string): { model: string; profile: string | null; tools: string[]; fallback: string | null; allowlisted: boolean };
21
+ execute?: typeof executeFlow;
22
+ createSnapshot?: typeof createIsolatedWorkingTreeSnapshot;
23
+ scoutAgent?: ScoutWorkflowDeps["agent"];
24
+ worktreeRevision?: typeof worktreeRevision;
25
+ buildRuntimeResult?: typeof buildRuntimeResult;
26
+ }
27
+
28
+ interface StoredRun { promise: Promise<any>; controller: AbortController; request: string }
29
+
30
+ function message(error: unknown): string { return error instanceof Error ? error.message : String(error); }
31
+ function failure(status: string, error: unknown, budgetCharged: boolean, executionStarted: boolean, extra: Record<string, unknown> = {}) {
32
+ return {
33
+ content: [{ type: "text", text: `Scout flow failed safely: ${message(error)}` }],
34
+ details: { status, budgetCharged, budgetOwner: "hub", executionStarted, parentAcceptance: { accepted: false, status: "not_accepted", assertionsProven: [] }, error: message(error), ...extra },
35
+ };
36
+ }
37
+
38
+ export function registerRunFlow(pi: ExtensionAPI, deps: RunFlowDeps): void {
39
+ const runs = new Map<string, StoredRun>();
40
+ let activeId: string | null = null;
41
+ pi.on("session_shutdown", () => { for (const run of runs.values()) run.controller.abort("session shutdown"); });
42
+ pi.registerTool({
43
+ name: "run_flow", label: "Run Flow", description: "Run the read-only scout workflow in an isolated no-branch snapshot. Initial T13 surface; writable flows are unavailable.",
44
+ parameters: Type.Object({
45
+ procedure: Type.Literal("scout"),
46
+ request: Type.String({ minLength: 1, description: "Exact read-only reconnaissance question." }),
47
+ invocation_id: Type.String({ minLength: 8, maxLength: 128, pattern: "^[A-Za-z0-9][A-Za-z0-9._-]+$", description: "Stable idempotency key; duplicates return the existing run." }),
48
+ }, { additionalProperties: false }),
49
+ execute(_toolCallId, raw, signal, onUpdate, ctx) {
50
+ const params = raw as RunFlowParams;
51
+ const existing = runs.get(params.invocation_id);
52
+ if (existing) {
53
+ if (existing.request !== params.request) return Promise.resolve({ content: [{ type: "text", text: "Stale duplicate refused: invocation_id is already bound to different scout inputs; no budget charged." }], details: { status: "stale-duplicate", budgetCharged: false, executionStarted: false } });
54
+ return existing.promise;
55
+ }
56
+ if (activeId) return Promise.resolve({ content: [{ type: "text", text: `Flow busy: ${activeId} is active; no budget charged.` }], details: { status: "busy", activeInvocationId: activeId, budgetCharged: false, executionStarted: false } });
57
+ const controller = new AbortController();
58
+ const forwardAbort = () => controller.abort(signal?.reason ?? "caller cancelled");
59
+ if (signal?.aborted) forwardAbort(); else signal?.addEventListener("abort", forwardAbort, { once: true });
60
+ activeId = params.invocation_id;
61
+ const promise = (async () => {
62
+ let snapshotRoot: string | null = null;
63
+ let budgetCharged = false;
64
+ let executionStarted = false;
65
+ let runId: string | null = null;
66
+ try {
67
+ const sessionDir = deps.sessionDir();
68
+ if (!sessionDir) return failure("invalid-environment", "run_flow requires an active managed Hub session", false, false);
69
+ const sourceCwd = ctx.cwd || process.cwd();
70
+ let config;
71
+ try {
72
+ config = deps.effectiveScoutConfig(sourceCwd);
73
+ const allowedTools = new Set(["read", "grep", "find", "ls"]);
74
+ if (!config.allowlisted || config.tools.length === 0 || config.tools.some(tool => !allowedTools.has(tool))) throw new Error("effective scout configuration is not allowlisted filesystem-read-only");
75
+ } catch (error) { return failure("preflight-refused", error, false, false); }
76
+ const revision = deps.worktreeRevision ?? worktreeRevision;
77
+ const beforeRevision = revision(sourceCwd, []);
78
+ runId = `hub-scout-${randomUUID()}`;
79
+ const artifactDir = join(sessionDir, "artifacts", "flow-runs", runId); mkdirSync(artifactDir, { recursive: true, mode: 0o700 });
80
+ snapshotRoot = mkdtempSync(join(tmpdir(), "agent-fleet-scout-snapshot-"));
81
+ const workspace = join(snapshotRoot, "workspace"), manifestPath = join(artifactDir, "snapshot-manifest.json");
82
+ let manifest: IsolatedSnapshotManifest;
83
+ try { manifest = (deps.createSnapshot ?? createIsolatedWorkingTreeSnapshot)(sourceCwd, workspace, manifestPath); }
84
+ catch (error) { return failure("snapshot-refused", error, false, false); }
85
+ let budget: HubFlowBudgetReservation;
86
+ try { budget = await deps.reserveBudget(params, ctx, controller.signal); }
87
+ catch (error) { return failure("budget-failed", error, false, false); }
88
+ if (!budget.charged) return { content: [{ type: "text", text: budget.refusal ?? "Hub budget refused flow." }], details: { status: "budget-refused", budgetCharged: false, budgetOwner: "hub", executionStarted: false, parentAcceptance: { accepted: false, status: "not_accepted", assertionsProven: [] } } };
89
+ budgetCharged = true;
90
+ executionStarted = true;
91
+ onUpdate?.({ content: [{ type: "text", text: "Running isolated read-only scout flow..." }], details: { status: "running", runId } });
92
+ let result;
93
+ try {
94
+ const hubScout: HubScoutExecution = { noBranch: true, traceDirectory: artifactDir, signal: controller.signal, ...(deps.scoutAgent ? { scoutAgent: deps.scoutAgent } : {}) };
95
+ result = await (deps.execute ?? executeFlow)({ name: "scout", args: [params.request], allowDirty: true, dryRun: false, runId }, { cwd: workspace, command: ["run_flow", "scout"], hubScout });
96
+ } catch (error) {
97
+ result = { accepted: false, status: "rejected" as const, exitCode: Number((error as any)?.exitCode ?? 1), reason: message(error), banner: "FLOW REJECTED" };
98
+ }
99
+ const afterRevision = revision(sourceCwd, []);
100
+ const unchanged = beforeRevision === afterRevision;
101
+ const runtimeResult = (deps.buildRuntimeResult ?? buildRuntimeResult)({
102
+ task: { id: deps.taskId(), current: unchanged, beforeRevision, afterRevision },
103
+ execution: { status: result.exitCode === 0 ? "completed" : "failed", exitCode: result.exitCode, dispatchId: runId },
104
+ changes: { status: "unchanged", paths: [], attribution: "certain" }, requirements: [], deliverables: [], checks: [],
105
+ evidenceRefs: [manifestPath, join(artifactDir, "trace.jsonl")],
106
+ });
107
+ const obligations = deps.processObligations();
108
+ const details = { status: result.status, runId, invocationId: params.invocation_id, procedure: "scout", budgetCharged: true, budgetOwner: "hub", budgetOperation: "research", executionStarted: true, flowAcceptance: { accepted: result.accepted, status: result.status, reason: result.reason ?? null }, parentAcceptance: { accepted: false, status: "not_accepted", assertionsProven: [], obligations }, runtimeResult, effectiveConfiguration: config, snapshot: { schema: manifest.schema, sourceRevision: manifest.sourceRevision, sourceStateHash: manifest.sourceStateHash, manifestPath, originalRevisionUnchanged: unchanged }, tracePath: join(artifactDir, "trace.jsonl") };
109
+ return { content: [{ type: "text", text: `${result.banner}\nFlow acceptance is separate; parent task remains not accepted and no assertion was promoted.\nTrace: ${details.tracePath}` }], details };
110
+ } catch (error) {
111
+ return failure(executionStarted ? "result-failed" : "setup-failed", error, budgetCharged, executionStarted, runId ? { runId } : {});
112
+ } finally {
113
+ if (snapshotRoot) { try { rmSync(snapshotRoot, { recursive: true, force: true }); } catch {} }
114
+ }
115
+ })();
116
+ runs.set(params.invocation_id, { promise, controller, request: params.request });
117
+ const cleanup = () => { if (activeId === params.invocation_id) activeId = null; signal?.removeEventListener("abort", forwardAbort); };
118
+ void promise.then(cleanup, cleanup);
119
+ return promise;
120
+ },
121
+ });
122
+ }
@@ -8,10 +8,12 @@ export function registerSetTaskTier(pi: ExtensionAPI, toolCtx: ToolContext): voi
8
8
  name: "set_task_tier",
9
9
  label: "Set Task Tier",
10
10
  description:
11
- "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 — 8 dispatches), project (a large effort — 12 dispatches). Nested delegation is off at trivial/small. 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.",
11
+ "Classify the CURRENT TASK on independent axes. `tier` controls spend only. `risk` (unknown|low|high) and `scope` (read-only|small|wide) control correctness obligations; risk is explicit and is never inferred from prose. Initial/legacy risk is unknown. Any risk change and any scope expansion requires `reason`; scope expansion also requires explicit risk reassessment. Lowering tier cannot erase open acceptance, plan, or review obligations. Pass `new_task: true` only for genuinely different work; same-task follow-ups, mode switches, resume, and compaction preserve obligations.",
12
12
  parameters: Type.Object({
13
- tier: Type.String({ description: "One of: trivial | small | feature | project" }),
14
- reason: Type.Optional(Type.String({ description: "One line on why this tier fits the ask. REQUIRED when raising the tier above the current one." })),
13
+ tier: Type.String({ description: "Spend tier only: trivial | small | feature | project" }),
14
+ risk: Type.Optional(Type.String({ description: "Explicit correctness risk: unknown | low | high. Omitted legacy calls remain unknown." })),
15
+ scope: Type.Optional(Type.String({ description: "Explicit process scope: read-only | small | wide." })),
16
+ reason: Type.Optional(Type.String({ description: "Required when raising budget tier, changing risk, or expanding scope; explain the observed change/reassessment." })),
15
17
  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." })),
16
18
  }),
17
19
  execute(toolCallId, params, signal, onUpdate, ctx) {
@@ -9,10 +9,13 @@ export function registerSpawnResearch(pi: ExtensionAPI, toolCtx: ToolContext): v
9
9
  label: "Spawn Research",
10
10
  description: "Run a read-only (read/grep/find/ls) helper and return findings.",
11
11
  parameters: Type.Object({
12
- task: Type.String({ description: "Investigation and expected findings." }),
12
+ task: Type.String(),
13
13
  persona: Type.Optional(Type.String({ description: "Research persona; omit for ad-hoc." })),
14
14
  model: Type.Optional(Type.String({ description: "Anonymous-helper model; ignored with persona." })),
15
15
  artifacts: Type.Optional(Type.Array(Type.String({ description: "Input artifact path." }))),
16
+ read_scope: Type.Optional(Type.Array(Type.String({ description: "Advisory relative scope; not isolation.", pattern: "^(?![/\\\\])(?![A-Za-z]:)(?!.*(?:^|[/\\\\])\\.\\.(?:[/\\\\]|$)).+$" }))),
17
+ goal: Type.Optional(Type.String()),
18
+ expected_result: Type.Optional(Type.String()),
16
19
  }),
17
20
 
18
21
  execute(toolCallId, params, signal, onUpdate, ctx) {
@@ -14,8 +14,11 @@ export function registerVerificationContract(pi: ExtensionAPI, toolCtx: ToolCont
14
14
  Type.Object({
15
15
  id: Type.String({ description: "Stable id (A1, A2)." }),
16
16
  tag: Type.String({ description: "test | runtime-ui | code-grep | manual." }),
17
- text: Type.String({ description: "One pass condition." }),
18
- source: Type.String({ description: "Requirement origin." }),
17
+ text: Type.String(),
18
+ source: Type.String(),
19
+ reference: Type.Optional(Type.String()),
20
+ test_command: Type.Optional(Type.String({ description: "Exact bash check for test/code-grep; execution is not semantic adequacy." })),
21
+ critical_conditions: Type.Optional(Type.Array(Type.String())),
19
22
  }),
20
23
  { description: `Replacement list; soft cap ${MAX_OPEN_ASSERTIONS}.` },
21
24
  ),
@@ -5,6 +5,7 @@ import type { FleetTranscriptStore } from "../lib/fleet-transcript-store.ts";
5
5
  import type { HistoryEntry } from "./ui/history-store.ts";
6
6
  import type { TimelineEntry } from "./ui/zoom.ts";
7
7
  import type { ResearchAgentDef, ResearchState as RuntimeResearchState } from "./research/runtime.ts";
8
+ import type { TaskResumeContract } from "./task-resume-contract.ts";
8
9
 
9
10
  export interface SubagentRole {
10
11
  model: string;
@@ -42,6 +43,7 @@ export interface AgentState {
42
43
  contextTokens: number;
43
44
  sessionFile: string | null;
44
45
  specialistManifest?: SpecialistContextManifest;
46
+ resumeContract?: TaskResumeContract;
45
47
  runCount: number;
46
48
  runsSinceFresh: number;
47
49
  timer?: ReturnType<typeof setInterval>;