@chankov/agent-fleet 2.0.16 → 2.0.17

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 (569) hide show
  1. package/.pi/harnesses/agent-hub/README.md +4 -0
  2. package/.pi/harnesses/agent-hub/agentic-contract.ts +43 -0
  3. package/.pi/harnesses/agent-hub/agentic-evidence.ts +64 -0
  4. package/.pi/harnesses/agent-hub/agentic-hub.ts +54 -0
  5. package/.pi/harnesses/agent-hub/agentic-runtime.ts +56 -0
  6. package/.pi/harnesses/agent-hub/agentic-sources-worker.mjs +4 -0
  7. package/.pi/harnesses/agent-hub/agentic-sources.ts +50 -0
  8. package/.pi/harnesses/agent-hub/agentic-state.ts +23 -0
  9. package/.pi/harnesses/agent-hub/index.ts +8 -2
  10. package/.pi/harnesses/agent-hub/package.json +1 -1
  11. package/.pi/harnesses/agent-hub/peer-spawn-plan.ts +1 -1
  12. package/.pi/harnesses/agent-hub/policy/work-mode.ts +2 -1
  13. package/.pi/harnesses/agent-hub/proactive-snapshot.ts +9 -24
  14. package/.pi/harnesses/agent-hub/prompts/context.ts +2 -0
  15. package/.pi/harnesses/agent-hub/prompts/fragments.ts +7 -0
  16. package/.pi/harnesses/agent-hub/prompts/system-prompt.ts +3 -1
  17. package/.pi/harnesses/agent-hub/system1-communication-store.ts +29 -7
  18. package/.pi/harnesses/agent-hub/tools/ask-system1.ts +25 -0
  19. package/.pi/harnesses/agent-hub/ui/system1-communication.ts +1 -1
  20. package/.pi/harnesses/agent-hub/work-mode.ts +6 -1
  21. package/.pi/harnesses/coms/package.json +1 -1
  22. package/.pi/harnesses/damage-control-continue/index.ts +6 -23
  23. package/.pi/harnesses/damage-control-continue/package.json +1 -1
  24. package/.pi/harnesses/lib/damage-control-shared.ts +29 -0
  25. package/.pi/harnesses/lib/safe-source-read.js +29 -0
  26. package/.pi/harnesses/lib/system1/config-agentic.js +14 -0
  27. package/.pi/harnesses/lib/system1/config-v2.js +6 -3
  28. package/.versions/2.0.17/.pi/agent-fleet/hermes/README.md +347 -0
  29. package/.versions/2.0.17/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
  30. package/.versions/2.0.17/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
  31. package/.versions/2.0.17/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  32. package/.versions/2.0.17/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  33. package/.versions/2.0.17/.pi/agent-fleet/hermes/gates/gate-o-capability.md +8 -0
  34. package/.versions/2.0.17/.pi/agent-fleet/hermes/gates/gate-o-validator-fixtures.json +1 -0
  35. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +773 -0
  36. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
  37. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
  38. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
  39. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
  40. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
  41. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
  42. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
  43. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
  44. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
  45. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
  46. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  47. package/.versions/2.0.17/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  48. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-conductor/SKILL.md +84 -0
  49. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-liaison/SKILL.md +84 -0
  50. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-watchdog/SKILL.md +76 -0
  51. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-watchdog/manifest.json +1 -0
  52. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
  53. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
  54. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
  55. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
  56. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
  57. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
  58. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
  59. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
  60. package/.versions/2.0.17/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
  61. package/.versions/2.0.17/.pi/agent-fleet/hermes/watchdog-tests/__init__.py +0 -0
  62. package/.versions/2.0.17/.pi/agent-fleet/hooks/coms-stop-hook.mjs +84 -0
  63. package/.versions/2.0.17/.pi/agent-fleet/scripts/claude-code-preflight.ts +70 -0
  64. package/.versions/2.0.17/.pi/agent-fleet/scripts/coms-claude-bridge.ts +411 -0
  65. package/.versions/2.0.17/.pi/agent-fleet/scripts/coms-cli.ts +425 -0
  66. package/.versions/2.0.17/.pi/agent-fleet/scripts/coms-hermes-bridge.ts +413 -0
  67. package/.versions/2.0.17/.pi/agent-fleet/scripts/fleet-codex-client.ts +69 -0
  68. package/.versions/2.0.17/.pi/agent-fleet/scripts/fleet-codex-read.py +148 -0
  69. package/.versions/2.0.17/.pi/agent-fleet/scripts/fleet.ts +217 -0
  70. package/.versions/2.0.17/.pi/agent-fleet/scripts/flow.ts +157 -0
  71. package/.versions/2.0.17/.pi/agent-fleet/scripts/hermes-monitor-capability-runner.ts +25 -0
  72. package/.versions/2.0.17/.pi/agent-fleet/scripts/hermes-monitor-scenario.ts +474 -0
  73. package/.versions/2.0.17/.pi/agent-fleet/scripts/hermes-watchdog-capability-probe.ts +45 -0
  74. package/.versions/2.0.17/.pi/agent-fleet/scripts/install-hermes-plugin.sh +180 -0
  75. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/claude-bridge-core.ts +210 -0
  76. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/coms-envelope.ts +582 -0
  77. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/fake-herdr-server.ts +88 -0
  78. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/fleet-codex-catalog.ts +63 -0
  79. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/fleet-codex-operations.ts +190 -0
  80. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/fleet-codex-session.ts +166 -0
  81. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/fleet-codex-transport.ts +124 -0
  82. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/fleet-command.ts +252 -0
  83. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/flow-command.ts +98 -0
  84. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/flow-maintenance.ts +230 -0
  85. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/herdr-layout.ts +281 -0
  86. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/hermes-bridge-core.ts +241 -0
  87. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/hermes-monitor-events.ts +1 -0
  88. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/hermes-monitor-herdr.ts +2 -0
  89. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/hermes-monitor-model.ts +3 -0
  90. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/hermes-monitor-registry.ts +2 -0
  91. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/hermes-monitor-socket.ts +2 -0
  92. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/hermes-monitor-store.ts +2 -0
  93. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/monitor-env.ts +146 -0
  94. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/peer-launch.ts +318 -0
  95. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/persona-banner.ts +62 -0
  96. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/persona-dirs.ts +25 -0
  97. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/runtime-dependencies.js +124 -0
  98. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/spawn-stagger.ts +101 -0
  99. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/team-project.ts +178 -0
  100. package/.versions/2.0.17/.pi/agent-fleet/scripts/lib/team-snapshot.ts +147 -0
  101. package/.versions/2.0.17/.pi/agent-fleet/scripts/package-lock.json +35 -0
  102. package/.versions/2.0.17/.pi/agent-fleet/scripts/package.json +9 -0
  103. package/.versions/2.0.17/.pi/agent-fleet/scripts/peer-banner.ts +41 -0
  104. package/.versions/2.0.17/.pi/agent-fleet/scripts/peer-launch.ts +283 -0
  105. package/.versions/2.0.17/.pi/agent-fleet/scripts/team-snapshot.ts +237 -0
  106. package/.versions/2.0.17/.pi/agent-fleet/scripts/team-up.ts +378 -0
  107. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/agent-phase.ts +179 -0
  108. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/changes.ts +61 -0
  109. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/debate.ts +149 -0
  110. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/env.ts +34 -0
  111. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/envelopes.ts +169 -0
  112. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/gates.ts +81 -0
  113. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/git.ts +96 -0
  114. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/isolated-snapshot.ts +125 -0
  115. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/merge.ts +95 -0
  116. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/model-profile.ts +22 -0
  117. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/model-visibility.ts +92 -0
  118. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/permissions.ts +130 -0
  119. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/personas.ts +57 -0
  120. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/poll.ts +86 -0
  121. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/project-policy.ts +34 -0
  122. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/quality.ts +64 -0
  123. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/run.ts +108 -0
  124. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/scout-data-boundary.ts +55 -0
  125. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/trace.ts +34 -0
  126. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/voices.ts +128 -0
  127. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/lib/writer-lease.ts +112 -0
  128. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/tsconfig.json +22 -0
  129. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/wf-build-test.ts +61 -0
  130. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/wf-debate.ts +87 -0
  131. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/wf-document.ts +50 -0
  132. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/wf-poll.ts +95 -0
  133. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/wf-quality.ts +20 -0
  134. package/.versions/2.0.17/.pi/agent-fleet/scripts/workflows/wf-scout.ts +40 -0
  135. package/.versions/2.0.17/.pi/agents/dispatch-policy.yaml +32 -0
  136. package/.versions/2.0.17/.pi/agents/model-profiles.yaml +134 -0
  137. package/.versions/2.0.17/.pi/agents/peers.yaml +147 -0
  138. package/.versions/2.0.17/.pi/agents/teams.yaml +41 -0
  139. package/.versions/2.0.17/.pi/agents/voices.yaml +13 -0
  140. package/.versions/2.0.17/.pi/damage-control-rules.yaml +297 -0
  141. package/.versions/2.0.17/.pi/extensions/btw/README.md +120 -0
  142. package/.versions/2.0.17/.pi/extensions/btw/index.ts +914 -0
  143. package/.versions/2.0.17/.pi/extensions/btw/package.json +6 -0
  144. package/.versions/2.0.17/.pi/extensions/btw/state.js +179 -0
  145. package/.versions/2.0.17/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
  146. package/.versions/2.0.17/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
  147. package/.versions/2.0.17/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  148. package/.versions/2.0.17/.pi/extensions/compact-and-continue/README.md +42 -0
  149. package/.versions/2.0.17/.pi/extensions/compact-and-continue/index.ts +120 -0
  150. package/.versions/2.0.17/.pi/extensions/compact-and-continue/package.json +6 -0
  151. package/.versions/2.0.17/.pi/extensions/mcp-bridge/README.md +46 -0
  152. package/.versions/2.0.17/.pi/extensions/mcp-bridge/index.ts +206 -0
  153. package/.versions/2.0.17/.pi/extensions/mcp-bridge/package.json +6 -0
  154. package/.versions/2.0.17/.pi/extensions/package-lock.json +1175 -0
  155. package/.versions/2.0.17/.pi/extensions/package.json +9 -0
  156. package/.versions/2.0.17/.pi/extensions/pi-voice-stt/README.md +224 -0
  157. package/.versions/2.0.17/.pi/extensions/pi-voice-stt/config.ts +198 -0
  158. package/.versions/2.0.17/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  159. package/.versions/2.0.17/.pi/extensions/pi-voice-stt/index.ts +248 -0
  160. package/.versions/2.0.17/.pi/extensions/pi-voice-stt/package.json +6 -0
  161. package/.versions/2.0.17/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  162. package/.versions/2.0.17/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  163. package/.versions/2.0.17/.pi/harnesses/agent-hub/README.md +1456 -0
  164. package/.versions/2.0.17/.pi/harnesses/agent-hub/acceptance.ts +199 -0
  165. package/.versions/2.0.17/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  166. package/.versions/2.0.17/.pi/harnesses/agent-hub/agentic-contract.ts +43 -0
  167. package/.versions/2.0.17/.pi/harnesses/agent-hub/agentic-evidence.ts +64 -0
  168. package/.versions/2.0.17/.pi/harnesses/agent-hub/agentic-hub.ts +54 -0
  169. package/.versions/2.0.17/.pi/harnesses/agent-hub/agentic-runtime.ts +56 -0
  170. package/.versions/2.0.17/.pi/harnesses/agent-hub/agentic-sources-worker.mjs +4 -0
  171. package/.versions/2.0.17/.pi/harnesses/agent-hub/agentic-sources.ts +50 -0
  172. package/.versions/2.0.17/.pi/harnesses/agent-hub/agentic-state.ts +23 -0
  173. package/.versions/2.0.17/.pi/harnesses/agent-hub/artifacts.js +146 -0
  174. package/.versions/2.0.17/.pi/harnesses/agent-hub/assertion-ledger.js +67 -0
  175. package/.versions/2.0.17/.pi/harnesses/agent-hub/assist-profile.ts +16 -0
  176. package/.versions/2.0.17/.pi/harnesses/agent-hub/backend-policy.js +174 -0
  177. package/.versions/2.0.17/.pi/harnesses/agent-hub/bounded-output.ts +26 -0
  178. package/.versions/2.0.17/.pi/harnesses/agent-hub/budget-continuation.ts +13 -0
  179. package/.versions/2.0.17/.pi/harnesses/agent-hub/budget-recovery.ts +214 -0
  180. package/.versions/2.0.17/.pi/harnesses/agent-hub/capability-confirmation.ts +47 -0
  181. package/.versions/2.0.17/.pi/harnesses/agent-hub/capability-packs.ts +184 -0
  182. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/agent-model-thinking.ts +10 -0
  183. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/agent-model.ts +10 -0
  184. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/agent-models-substitute.ts +10 -0
  185. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/agents-add.ts +9 -0
  186. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/agents-drop.ts +9 -0
  187. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/agents-history.ts +9 -0
  188. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/agents-kill.ts +10 -0
  189. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/agents-list.ts +9 -0
  190. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/agents-restart.ts +10 -0
  191. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/agents-save.ts +9 -0
  192. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/agents-team.ts +9 -0
  193. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/audit.ts +9 -0
  194. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/budget-continue.ts +10 -0
  195. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/compound.ts +9 -0
  196. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/coms.ts +9 -0
  197. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/context-command.ts +9 -0
  198. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/context.ts +47 -0
  199. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/debate.ts +9 -0
  200. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/dispatch-policy.ts +9 -0
  201. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/handoff.ts +10 -0
  202. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/hub-report.ts +9 -0
  203. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/models.ts +10 -0
  204. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/poll.ts +9 -0
  205. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/recover.ts +61 -0
  206. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/retry.ts +10 -0
  207. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/task-triage-recover.ts +12 -0
  208. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/task-triage-waive.ts +12 -0
  209. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/watchdog.ts +9 -0
  210. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/work-mode.ts +29 -0
  211. package/.versions/2.0.17/.pi/harnesses/agent-hub/commands/zoom.ts +10 -0
  212. package/.versions/2.0.17/.pi/harnesses/agent-hub/config/agents.ts +178 -0
  213. package/.versions/2.0.17/.pi/harnesses/agent-hub/config/model-profiles.ts +236 -0
  214. package/.versions/2.0.17/.pi/harnesses/agent-hub/config/overrides.ts +155 -0
  215. package/.versions/2.0.17/.pi/harnesses/agent-hub/context/agent-state.ts +30 -0
  216. package/.versions/2.0.17/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +221 -0
  217. package/.versions/2.0.17/.pi/harnesses/agent-hub/context/budgets.ts +206 -0
  218. package/.versions/2.0.17/.pi/harnesses/agent-hub/context/hub-state.ts +40 -0
  219. package/.versions/2.0.17/.pi/harnesses/agent-hub/context-budget-snapshot.ts +105 -0
  220. package/.versions/2.0.17/.pi/harnesses/agent-hub/context-pressure.ts +191 -0
  221. package/.versions/2.0.17/.pi/harnesses/agent-hub/context-window.js +108 -0
  222. package/.versions/2.0.17/.pi/harnesses/agent-hub/debate-command.ts +176 -0
  223. package/.versions/2.0.17/.pi/harnesses/agent-hub/delegate.ts +467 -0
  224. package/.versions/2.0.17/.pi/harnesses/agent-hub/deterministic-fs.ts +166 -0
  225. package/.versions/2.0.17/.pi/harnesses/agent-hub/diagnostic-probe-extension.ts +26 -0
  226. package/.versions/2.0.17/.pi/harnesses/agent-hub/diagnostic-series-budget.ts +178 -0
  227. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-coms.ts +252 -0
  228. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-core.ts +27 -0
  229. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-native-complete.ts +173 -0
  230. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +259 -0
  231. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +231 -0
  232. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-native-types.ts +260 -0
  233. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-native.ts +234 -0
  234. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-observability.ts +225 -0
  235. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-triage-contract.ts +27 -0
  236. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-triage-eval.ts +77 -0
  237. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-triage-policy.ts +29 -0
  238. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-triage-runtime.ts +55 -0
  239. package/.versions/2.0.17/.pi/harnesses/agent-hub/dispatch-triage-state.ts +33 -0
  240. package/.versions/2.0.17/.pi/harnesses/agent-hub/docs-lane.js +123 -0
  241. package/.versions/2.0.17/.pi/harnesses/agent-hub/drift-judge.ts +352 -0
  242. package/.versions/2.0.17/.pi/harnesses/agent-hub/drift-runtime.ts +480 -0
  243. package/.versions/2.0.17/.pi/harnesses/agent-hub/drift-system1-policy.ts +39 -0
  244. package/.versions/2.0.17/.pi/harnesses/agent-hub/drift-system1.ts +469 -0
  245. package/.versions/2.0.17/.pi/harnesses/agent-hub/drift-watchdog.js +349 -0
  246. package/.versions/2.0.17/.pi/harnesses/agent-hub/evidence-manifest.ts +51 -0
  247. package/.versions/2.0.17/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  248. package/.versions/2.0.17/.pi/harnesses/agent-hub/execution-evidence.ts +80 -0
  249. package/.versions/2.0.17/.pi/harnesses/agent-hub/external-blocker.js +85 -0
  250. package/.versions/2.0.17/.pi/harnesses/agent-hub/filesystem-tool.ts +137 -0
  251. package/.versions/2.0.17/.pi/harnesses/agent-hub/fixtures/registration-surface.json +65 -0
  252. package/.versions/2.0.17/.pi/harnesses/agent-hub/fixtures/t0a-synthetic/catalog.ts +189 -0
  253. package/.versions/2.0.17/.pi/harnesses/agent-hub/footer.ts +30 -0
  254. package/.versions/2.0.17/.pi/harnesses/agent-hub/helpers.ts +270 -0
  255. package/.versions/2.0.17/.pi/harnesses/agent-hub/hub-state-audit.js +65 -0
  256. package/.versions/2.0.17/.pi/harnesses/agent-hub/index.ts +2607 -0
  257. package/.versions/2.0.17/.pi/harnesses/agent-hub/input/completions.ts +82 -0
  258. package/.versions/2.0.17/.pi/harnesses/agent-hub/input/shortcuts.ts +20 -0
  259. package/.versions/2.0.17/.pi/harnesses/agent-hub/lifecycle/context-pressure.ts +133 -0
  260. package/.versions/2.0.17/.pi/harnesses/agent-hub/lifecycle/monitor-session.ts +104 -0
  261. package/.versions/2.0.17/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +143 -0
  262. package/.versions/2.0.17/.pi/harnesses/agent-hub/lifecycle/turn-handlers.ts +74 -0
  263. package/.versions/2.0.17/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  264. package/.versions/2.0.17/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
  265. package/.versions/2.0.17/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
  266. package/.versions/2.0.17/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  267. package/.versions/2.0.17/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  268. package/.versions/2.0.17/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  269. package/.versions/2.0.17/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  270. package/.versions/2.0.17/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
  271. package/.versions/2.0.17/.pi/harnesses/agent-hub/no-progress.ts +563 -0
  272. package/.versions/2.0.17/.pi/harnesses/agent-hub/orchestration-activation.ts +112 -0
  273. package/.versions/2.0.17/.pi/harnesses/agent-hub/orchestration-metrics.ts +78 -0
  274. package/.versions/2.0.17/.pi/harnesses/agent-hub/orchestration-route.ts +76 -0
  275. package/.versions/2.0.17/.pi/harnesses/agent-hub/package.json +7 -0
  276. package/.versions/2.0.17/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
  277. package/.versions/2.0.17/.pi/harnesses/agent-hub/policy/models.ts +153 -0
  278. package/.versions/2.0.17/.pi/harnesses/agent-hub/policy/profile-activation.ts +62 -0
  279. package/.versions/2.0.17/.pi/harnesses/agent-hub/policy/profile-runtime.ts +120 -0
  280. package/.versions/2.0.17/.pi/harnesses/agent-hub/policy/roster.ts +94 -0
  281. package/.versions/2.0.17/.pi/harnesses/agent-hub/policy/work-mode.ts +136 -0
  282. package/.versions/2.0.17/.pi/harnesses/agent-hub/poll-command.ts +176 -0
  283. package/.versions/2.0.17/.pi/harnesses/agent-hub/presentation.ts +48 -0
  284. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-config.ts +16 -0
  285. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-evaluate.ts +138 -0
  286. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-feedback.ts +104 -0
  287. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-findings.ts +115 -0
  288. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-local.ts +71 -0
  289. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-observer.ts +105 -0
  290. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-rules.ts +143 -0
  291. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-runtime.ts +316 -0
  292. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-selection.ts +68 -0
  293. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-snapshot-worker.mjs +12 -0
  294. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-snapshot.ts +228 -0
  295. package/.versions/2.0.17/.pi/harnesses/agent-hub/proactive-types.ts +63 -0
  296. package/.versions/2.0.17/.pi/harnesses/agent-hub/process-obligations.ts +158 -0
  297. package/.versions/2.0.17/.pi/harnesses/agent-hub/prompts/context.ts +56 -0
  298. package/.versions/2.0.17/.pi/harnesses/agent-hub/prompts/fragments.ts +123 -0
  299. package/.versions/2.0.17/.pi/harnesses/agent-hub/prompts/session-start.ts +90 -0
  300. package/.versions/2.0.17/.pi/harnesses/agent-hub/prompts/system-prompt.ts +124 -0
  301. package/.versions/2.0.17/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
  302. package/.versions/2.0.17/.pi/harnesses/agent-hub/reconcile.ts +26 -0
  303. package/.versions/2.0.17/.pi/harnesses/agent-hub/recover-policy.ts +44 -0
  304. package/.versions/2.0.17/.pi/harnesses/agent-hub/recover-state.ts +104 -0
  305. package/.versions/2.0.17/.pi/harnesses/agent-hub/recovery-contract.ts +150 -0
  306. package/.versions/2.0.17/.pi/harnesses/agent-hub/rerun-policy.ts +40 -0
  307. package/.versions/2.0.17/.pi/harnesses/agent-hub/research/controls.ts +74 -0
  308. package/.versions/2.0.17/.pi/harnesses/agent-hub/research/runtime.ts +197 -0
  309. package/.versions/2.0.17/.pi/harnesses/agent-hub/research/spawn-run.ts +183 -0
  310. package/.versions/2.0.17/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  311. package/.versions/2.0.17/.pi/harnesses/agent-hub/return-contract.js +349 -0
  312. package/.versions/2.0.17/.pi/harnesses/agent-hub/return-extract.js +77 -0
  313. package/.versions/2.0.17/.pi/harnesses/agent-hub/review-closure.ts +43 -0
  314. package/.versions/2.0.17/.pi/harnesses/agent-hub/review-findings.js +104 -0
  315. package/.versions/2.0.17/.pi/harnesses/agent-hub/routing-observation.ts +41 -0
  316. package/.versions/2.0.17/.pi/harnesses/agent-hub/routing-proposal.ts +46 -0
  317. package/.versions/2.0.17/.pi/harnesses/agent-hub/run-budget.js +554 -0
  318. package/.versions/2.0.17/.pi/harnesses/agent-hub/run-namespace.js +93 -0
  319. package/.versions/2.0.17/.pi/harnesses/agent-hub/runtime-test-check.ts +54 -0
  320. package/.versions/2.0.17/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  321. package/.versions/2.0.17/.pi/harnesses/agent-hub/scope-gate.js +144 -0
  322. package/.versions/2.0.17/.pi/harnesses/agent-hub/session-audit.ts +313 -0
  323. package/.versions/2.0.17/.pi/harnesses/agent-hub/session-health.js +110 -0
  324. package/.versions/2.0.17/.pi/harnesses/agent-hub/session-start.ts +42 -0
  325. package/.versions/2.0.17/.pi/harnesses/agent-hub/spawn.ts +534 -0
  326. package/.versions/2.0.17/.pi/harnesses/agent-hub/system1-activity.ts +625 -0
  327. package/.versions/2.0.17/.pi/harnesses/agent-hub/system1-communication-store.ts +151 -0
  328. package/.versions/2.0.17/.pi/harnesses/agent-hub/system1-report.ts +275 -0
  329. package/.versions/2.0.17/.pi/harnesses/agent-hub/system1-runtime.ts +258 -0
  330. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-resume-contract.ts +70 -0
  331. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-authorization.ts +122 -0
  332. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-config.ts +29 -0
  333. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-contract.ts +14 -0
  334. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-live-stage-boundary.mjs +49 -0
  335. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-obligations.ts +104 -0
  336. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-policy.ts +16 -0
  337. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-review-contract.mjs +43 -0
  338. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-reviewer-only-contract.mjs +156 -0
  339. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-reviewer-only-diagnostics.mjs +112 -0
  340. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-runtime.ts +125 -0
  341. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-stage-guard.ts +21 -0
  342. package/.versions/2.0.17/.pi/harnesses/agent-hub/task-triage-state.ts +46 -0
  343. package/.versions/2.0.17/.pi/harnesses/agent-hub/timeline.ts +72 -0
  344. package/.versions/2.0.17/.pi/harnesses/agent-hub/tool-catalog-runtime.ts +68 -0
  345. package/.versions/2.0.17/.pi/harnesses/agent-hub/tool-catalog-state.ts +123 -0
  346. package/.versions/2.0.17/.pi/harnesses/agent-hub/tool-protocol.ts +134 -0
  347. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/action-executors.ts +208 -0
  348. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/ask-system1.ts +25 -0
  349. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/coms-tools.ts +139 -0
  350. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/context.ts +144 -0
  351. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +88 -0
  352. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +558 -0
  353. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/dispatch-triage.ts +16 -0
  354. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/execution-orchestration.ts +22 -0
  355. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/fleet-tools.ts +200 -0
  356. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/herdr-executors.ts +95 -0
  357. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/run-flow.ts +136 -0
  358. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/set-task-tier.ts +31 -0
  359. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/spawn-research.ts +65 -0
  360. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/team-adjust.ts +29 -0
  361. package/.versions/2.0.17/.pi/harnesses/agent-hub/tools/verification-contract.ts +80 -0
  362. package/.versions/2.0.17/.pi/harnesses/agent-hub/tsconfig.json +22 -0
  363. package/.versions/2.0.17/.pi/harnesses/agent-hub/types.ts +66 -0
  364. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/activity-dots.ts +25 -0
  365. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/context-budget.ts +87 -0
  366. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/detail-panel.ts +192 -0
  367. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/fleet-actions.ts +78 -0
  368. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +155 -0
  369. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/fleet-editor.ts +44 -0
  370. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/fleet-source.ts +179 -0
  371. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/grid.ts +159 -0
  372. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/history-store.ts +137 -0
  373. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/history.ts +234 -0
  374. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/pool.ts +103 -0
  375. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/running-strip.ts +2 -0
  376. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/system1-communication.ts +59 -0
  377. package/.versions/2.0.17/.pi/harnesses/agent-hub/ui/zoom.ts +206 -0
  378. package/.versions/2.0.17/.pi/harnesses/agent-hub/unknown-tool-counter.ts +116 -0
  379. package/.versions/2.0.17/.pi/harnesses/agent-hub/version.ts +42 -0
  380. package/.versions/2.0.17/.pi/harnesses/agent-hub/watchdog-evaluation.ts +110 -0
  381. package/.versions/2.0.17/.pi/harnesses/agent-hub/work-mode-controls.ts +56 -0
  382. package/.versions/2.0.17/.pi/harnesses/agent-hub/work-mode.ts +184 -0
  383. package/.versions/2.0.17/.pi/harnesses/agent-hub/write-isolation.ts +187 -0
  384. package/.versions/2.0.17/.pi/harnesses/ask-user-remote/README.md +59 -0
  385. package/.versions/2.0.17/.pi/harnesses/ask-user-remote/index.ts +558 -0
  386. package/.versions/2.0.17/.pi/harnesses/ask-user-remote/questions.ts +161 -0
  387. package/.versions/2.0.17/.pi/harnesses/ask-user-remote/race-core.js +124 -0
  388. package/.versions/2.0.17/.pi/harnesses/ask-user-remote/runtime-ask.ts +68 -0
  389. package/.versions/2.0.17/.pi/harnesses/coms/README.md +100 -0
  390. package/.versions/2.0.17/.pi/harnesses/coms/index.ts +282 -0
  391. package/.versions/2.0.17/.pi/harnesses/coms/package.json +7 -0
  392. package/.versions/2.0.17/.pi/harnesses/coms/version.ts +42 -0
  393. package/.versions/2.0.17/.pi/harnesses/damage-control-continue/README.md +135 -0
  394. package/.versions/2.0.17/.pi/harnesses/damage-control-continue/index.ts +533 -0
  395. package/.versions/2.0.17/.pi/harnesses/damage-control-continue/package.json +7 -0
  396. package/.versions/2.0.17/.pi/harnesses/damage-control-continue/version.ts +42 -0
  397. package/.versions/2.0.17/.pi/harnesses/lib/changed-file-diagnostics.ts +642 -0
  398. package/.versions/2.0.17/.pi/harnesses/lib/coms-core-io.ts +385 -0
  399. package/.versions/2.0.17/.pi/harnesses/lib/coms-core.ts +577 -0
  400. package/.versions/2.0.17/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
  401. package/.versions/2.0.17/.pi/harnesses/lib/context-budget-child-prompt.ts +219 -0
  402. package/.versions/2.0.17/.pi/harnesses/lib/context-budget-hub-prompt.ts +121 -0
  403. package/.versions/2.0.17/.pi/harnesses/lib/context-budget-view.ts +107 -0
  404. package/.versions/2.0.17/.pi/harnesses/lib/context-budget.ts +114 -0
  405. package/.versions/2.0.17/.pi/harnesses/lib/damage-control-shared.ts +226 -0
  406. package/.versions/2.0.17/.pi/harnesses/lib/deterministic-handle-path.ts +23 -0
  407. package/.versions/2.0.17/.pi/harnesses/lib/fixtures/context-budget-profiles.json +11 -0
  408. package/.versions/2.0.17/.pi/harnesses/lib/fixtures/hub-prompt-operator.legacy.txt +73 -0
  409. package/.versions/2.0.17/.pi/harnesses/lib/fixtures/hub-prompt-orchestrator.legacy.txt +73 -0
  410. package/.versions/2.0.17/.pi/harnesses/lib/fleet-dashboard-ops.ts +178 -0
  411. package/.versions/2.0.17/.pi/harnesses/lib/fleet-dashboard-view.ts +172 -0
  412. package/.versions/2.0.17/.pi/harnesses/lib/fleet-detail-view.ts +339 -0
  413. package/.versions/2.0.17/.pi/harnesses/lib/fleet-overlay.ts +26 -0
  414. package/.versions/2.0.17/.pi/harnesses/lib/fleet-panel.ts +34 -0
  415. package/.versions/2.0.17/.pi/harnesses/lib/fleet-read-model.ts +609 -0
  416. package/.versions/2.0.17/.pi/harnesses/lib/fleet-selection.ts +24 -0
  417. package/.versions/2.0.17/.pi/harnesses/lib/fleet-strip-controller.ts +75 -0
  418. package/.versions/2.0.17/.pi/harnesses/lib/fleet-strip-view.ts +179 -0
  419. package/.versions/2.0.17/.pi/harnesses/lib/fleet-transcript-store.ts +244 -0
  420. package/.versions/2.0.17/.pi/harnesses/lib/herdr-client.ts +472 -0
  421. package/.versions/2.0.17/.pi/harnesses/lib/herdr-presence.ts +399 -0
  422. package/.versions/2.0.17/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
  423. package/.versions/2.0.17/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
  424. package/.versions/2.0.17/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
  425. package/.versions/2.0.17/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
  426. package/.versions/2.0.17/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
  427. package/.versions/2.0.17/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
  428. package/.versions/2.0.17/.pi/harnesses/lib/safe-source-read.js +29 -0
  429. package/.versions/2.0.17/.pi/harnesses/lib/spawned-peers.js +191 -0
  430. package/.versions/2.0.17/.pi/harnesses/lib/system1/config-agentic.js +14 -0
  431. package/.versions/2.0.17/.pi/harnesses/lib/system1/config-json.js +37 -0
  432. package/.versions/2.0.17/.pi/harnesses/lib/system1/config-loader.js +44 -0
  433. package/.versions/2.0.17/.pi/harnesses/lib/system1/config-proactive.js +57 -0
  434. package/.versions/2.0.17/.pi/harnesses/lib/system1/config-triage.js +42 -0
  435. package/.versions/2.0.17/.pi/harnesses/lib/system1/config-v2.js +103 -0
  436. package/.versions/2.0.17/.pi/harnesses/lib/system1/config.js +50 -0
  437. package/.versions/2.0.17/.pi/harnesses/lib/system1/contracts.ts +154 -0
  438. package/.versions/2.0.17/.pi/harnesses/lib/system1/demo.ts +95 -0
  439. package/.versions/2.0.17/.pi/harnesses/lib/system1/jev.ts +503 -0
  440. package/.versions/2.0.17/.pi/harnesses/lib/system1/selection.js +11 -0
  441. package/.versions/2.0.17/.pi/harnesses/lib/system1/service.ts +245 -0
  442. package/.versions/2.0.17/.pi/harnesses/lib/update-check.ts +222 -0
  443. package/.versions/2.0.17/.pi/harnesses/package-lock.json +2039 -0
  444. package/.versions/2.0.17/.pi/harnesses/package.json +10 -0
  445. package/.versions/2.0.17/.pi/prompts/af-build.md +27 -0
  446. package/.versions/2.0.17/.pi/prompts/af-code-simplify.md +22 -0
  447. package/.versions/2.0.17/.pi/prompts/af-constraints.md +31 -0
  448. package/.versions/2.0.17/.pi/prompts/af-plan.md +17 -0
  449. package/.versions/2.0.17/.pi/prompts/af-review.md +16 -0
  450. package/.versions/2.0.17/.pi/prompts/af-set-hermes-telegram.md +15 -0
  451. package/.versions/2.0.17/.pi/prompts/af-set-hermes-watchdog.md +6 -0
  452. package/.versions/2.0.17/.pi/prompts/af-setup-rules.md +20 -0
  453. package/.versions/2.0.17/.pi/prompts/af-ship.md +17 -0
  454. package/.versions/2.0.17/.pi/prompts/af-spec.md +15 -0
  455. package/.versions/2.0.17/.pi/prompts/af-test.md +19 -0
  456. package/.versions/2.0.17/.pi/skills/bowser/SKILL.md +145 -0
  457. package/.versions/2.0.17/.version +1 -0
  458. package/.versions/2.0.17/agents/architect.md +24 -0
  459. package/.versions/2.0.17/agents/bowser.md +28 -0
  460. package/.versions/2.0.17/agents/builder.md +55 -0
  461. package/.versions/2.0.17/agents/code-reviewer.md +209 -0
  462. package/.versions/2.0.17/agents/deep-researcher.md +32 -0
  463. package/.versions/2.0.17/agents/documenter.md +22 -0
  464. package/.versions/2.0.17/agents/orchestrator.md +22 -0
  465. package/.versions/2.0.17/agents/plan-reviewer.md +83 -0
  466. package/.versions/2.0.17/agents/planner.md +105 -0
  467. package/.versions/2.0.17/agents/releaser.md +24 -0
  468. package/.versions/2.0.17/agents/researcher.md +30 -0
  469. package/.versions/2.0.17/agents/security-auditor.md +167 -0
  470. package/.versions/2.0.17/agents/test-engineer.md +153 -0
  471. package/.versions/2.0.17/agents/web-debugger.md +44 -0
  472. package/.versions/2.0.17/agents/web-performance-auditor.md +194 -0
  473. package/.versions/2.0.17/bin/catalog/harness-runtime-closure.json +73 -0
  474. package/.versions/2.0.17/codex/fleet-session-client/SKILL.md +34 -0
  475. package/.versions/2.0.17/codex/fleet-session-client.zip +0 -0
  476. package/.versions/2.0.17/docs/ARCHITECTURE.md +834 -0
  477. package/.versions/2.0.17/docs/agent-fleet-setup.md +1101 -0
  478. package/.versions/2.0.17/docs/claude-code-coms-bridge.md +134 -0
  479. package/.versions/2.0.17/docs/codex-session-bridge.md +219 -0
  480. package/.versions/2.0.17/docs/coms-hermes-bridge.md +188 -0
  481. package/.versions/2.0.17/docs/getting-started.md +126 -0
  482. package/.versions/2.0.17/docs/npm-install.md +530 -0
  483. package/.versions/2.0.17/docs/pi-extensions.md +454 -0
  484. package/.versions/2.0.17/docs/pi-setup.md +92 -0
  485. package/.versions/2.0.17/docs/skill-anatomy.md +150 -0
  486. package/.versions/2.0.17/install-manifest.json +3193 -0
  487. package/.versions/2.0.17/justfile +247 -0
  488. package/.versions/2.0.17/manifest-meta.json +1071 -0
  489. package/.versions/2.0.17/references/accessibility-checklist.md +160 -0
  490. package/.versions/2.0.17/references/communication-contract.md +26 -0
  491. package/.versions/2.0.17/references/definition-of-done.md +67 -0
  492. package/.versions/2.0.17/references/fleet-coordination-patterns.md +171 -0
  493. package/.versions/2.0.17/references/observability-checklist.md +92 -0
  494. package/.versions/2.0.17/references/orchestration-patterns.md +370 -0
  495. package/.versions/2.0.17/references/performance-checklist.md +236 -0
  496. package/.versions/2.0.17/references/prompting-patterns.md +380 -0
  497. package/.versions/2.0.17/references/security-checklist.md +245 -0
  498. package/.versions/2.0.17/references/testing-patterns.md +235 -0
  499. package/.versions/2.0.17/references/workflow-authoring.md +304 -0
  500. package/.versions/2.0.17/skills/_internal/grilling.md +59 -0
  501. package/.versions/2.0.17/skills/browser-testing-with-devtools/SKILL.md +351 -0
  502. package/.versions/2.0.17/skills/code-review-and-quality/SKILL.md +396 -0
  503. package/.versions/2.0.17/skills/compound-learning/SKILL.md +137 -0
  504. package/.versions/2.0.17/skills/constraint-driven-development/SKILL.md +338 -0
  505. package/.versions/2.0.17/skills/constraint-driven-development/references/floor-guard.md +99 -0
  506. package/.versions/2.0.17/skills/context-engineering/SKILL.md +341 -0
  507. package/.versions/2.0.17/skills/deprecation-and-migration/SKILL.md +247 -0
  508. package/.versions/2.0.17/skills/designing-agents/SKILL.md +394 -0
  509. package/.versions/2.0.17/skills/designing-agents/pi-harness-authoring.md +222 -0
  510. package/.versions/2.0.17/skills/drafting-workflows/SKILL.md +143 -0
  511. package/.versions/2.0.17/skills/drafting-workflows/scripts/make-workflow.ts +177 -0
  512. package/.versions/2.0.17/skills/frontend-ui-engineering/SKILL.md +328 -0
  513. package/.versions/2.0.17/skills/git-workflow-and-versioning/SKILL.md +316 -0
  514. package/.versions/2.0.17/skills/idea-refine/SKILL.md +182 -0
  515. package/.versions/2.0.17/skills/idea-refine/examples.md +238 -0
  516. package/.versions/2.0.17/skills/idea-refine/frameworks.md +99 -0
  517. package/.versions/2.0.17/skills/idea-refine/refinement-criteria.md +113 -0
  518. package/.versions/2.0.17/skills/idea-refine/scripts/idea-refine.sh +15 -0
  519. package/.versions/2.0.17/skills/incremental-implementation/SKILL.md +353 -0
  520. package/.versions/2.0.17/skills/interview-me/SKILL.md +226 -0
  521. package/.versions/2.0.17/skills/orchestration-verification/SKILL.md +182 -0
  522. package/.versions/2.0.17/skills/peer-coms/SKILL.md +90 -0
  523. package/.versions/2.0.17/skills/performance-optimization/SKILL.md +496 -0
  524. package/.versions/2.0.17/skills/planning-and-task-breakdown/SKILL.md +318 -0
  525. package/.versions/2.0.17/skills/repository-ai-setup/SKILL.md +117 -0
  526. package/.versions/2.0.17/skills/repository-ai-setup/references/agent-fleet-ai-state.template.json +4 -0
  527. package/.versions/2.0.17/skills/repository-ai-setup/references/apply-contract.md +74 -0
  528. package/.versions/2.0.17/skills/repository-ai-setup/references/provenance-template.md +16 -0
  529. package/.versions/2.0.17/skills/repository-ai-setup/references/setup-flow.md +108 -0
  530. package/.versions/2.0.17/skills/repository-ai-setup/references/verify-setup.md +20 -0
  531. package/.versions/2.0.17/skills/security-and-hardening/SKILL.md +524 -0
  532. package/.versions/2.0.17/skills/spec-driven-development/SKILL.md +295 -0
  533. package/.versions/2.0.17/skills/using-agent-skills/SKILL.md +198 -0
  534. package/.versions/2.0.17/vendor/agent-skills-upstream/LICENSE +21 -0
  535. package/.versions/2.0.17/vendor/agent-skills-upstream/README.md +430 -0
  536. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +367 -0
  537. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  538. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  539. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  540. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  541. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/constraint-driven-development/SKILL.md +311 -0
  542. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/constraint-driven-development/references/floor-guard.md +99 -0
  543. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +337 -0
  544. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  545. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  546. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +288 -0
  547. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  548. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  549. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  550. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  551. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  552. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  553. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  554. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  555. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  556. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  557. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +238 -0
  558. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +496 -0
  559. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +257 -0
  560. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +524 -0
  561. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +330 -0
  562. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +216 -0
  563. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +245 -0
  564. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +398 -0
  565. package/.versions/2.0.17/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +192 -0
  566. package/CHANGELOG.md +12 -0
  567. package/docs/system1-agentic.md +106 -0
  568. package/install-manifest.json +1 -1
  569. package/package.json +5 -2
@@ -0,0 +1,54 @@
1
+ import { worktreeRevision } from "./scope-gate.js";
2
+
3
+ export interface RuntimeTestRecord {
4
+ producer: "agent-fleet.runtime-test/v1";
5
+ command: string;
6
+ exitCode: number | null;
7
+ beforeRevision: string;
8
+ afterRevision: string;
9
+ }
10
+
11
+ /** Observe the existing bash operation, never execute a second command or parse output. */
12
+ export function instrumentBash(createTool: any, operations: any, cwd: string, revision = () => worktreeRevision(cwd, []), options: any = {}) {
13
+ return async (id: string, params: any, signal: any, update: any, ctx?: any) => {
14
+ let record: RuntimeTestRecord | undefined;
15
+ const tool = createTool(cwd, { ...options, operations: { ...operations, exec: async (...args: any[]) => {
16
+ const beforeRevision = revision();
17
+ const result = await operations.exec(...args);
18
+ if (typeof args[0] === "string" && args[0] === (options.commandPrefix ? `${options.commandPrefix}\n${params.command}` : params.command)) record = { producer: "agent-fleet.runtime-test/v1", command: params.command, exitCode: result.exitCode, beforeRevision, afterRevision: revision() };
19
+ return result;
20
+ } } });
21
+ try {
22
+ const result = await tool.execute(id, params, signal, update, ctx);
23
+ return { ...result, details: { ...result.details, runtimeTest: record } };
24
+ } catch (error) {
25
+ if (!record) throw error;
26
+ return { content: [{ type: "text", text: String(error) }], isError: true, details: { runtimeTest: record } };
27
+ }
28
+ };
29
+ }
30
+
31
+ /** Use Pi's tool_result hook: agent-core ignores isError on resolved execute values. */
32
+ export function registerObservedBash(pi: any, api: any, cwd: string, options: any) {
33
+ const tool = api.createBashToolDefinition(cwd, options);
34
+ pi.registerTool({ ...tool, execute: instrumentBash(api.createBashToolDefinition, api.createLocalBashOperations({ shellPath: options.shellPath }), cwd, undefined, options) });
35
+ pi.on("tool_result", (event: any) => {
36
+ if (event.toolName === "bash" && event.details?.runtimeTest?.producer === "agent-fleet.runtime-test/v1" && event.details.runtimeTest.exitCode !== 0)
37
+ return { isError: true };
38
+ });
39
+ }
40
+
41
+ /** Same tool name/schema retains damage-control approval and built-in rendering. */
42
+ export default async function runtimeTestCheck(pi: any) {
43
+ const api = await import("@mariozechner/pi-coding-agent");
44
+ const cwd = process.cwd();
45
+ const settings = api.SettingsManager.create(cwd);
46
+ registerObservedBash(pi, api, cwd, { shellPath: settings.getShellPath(), commandPrefix: settings.getShellCommandPrefix() });
47
+ }
48
+
49
+ /** Accept observer events only on the explicitly enabled native transport and a matching tool start. */
50
+ export function runtimeTestFromResult(enabled: boolean | undefined, startedCommand: string | undefined, toolName: string, result: any): RuntimeTestRecord | null {
51
+ const record = result?.details?.runtimeTest;
52
+ if (!enabled || toolName !== "bash" || record?.producer !== "agent-fleet.runtime-test/v1" || typeof record.command !== "string" || !record.command || startedCommand !== record.command || !Number.isInteger(record.exitCode) || !record.beforeRevision || !record.afterRevision || typeof record.beforeRevision !== "string" || typeof record.afterRevision !== "string") return null;
53
+ return { producer: "agent-fleet.runtime-test/v1", command: record.command, exitCode: record.exitCode, beforeRevision: record.beforeRevision, afterRevision: record.afterRevision };
54
+ }
@@ -0,0 +1,22 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
3
+
4
+ const CONTINUE_ENTRY = /damage-control-continue[/\\]index\.ts$/;
5
+ const MISSING_SAFETY_ERROR = "damage-control-continue harness not found — guarded child dispatch refused";
6
+
7
+ /** Resolve only the surviving continue harness; never downgrade to an unguarded or hard-stop child. */
8
+ export function resolveSafetyHarness(cwd: string, argv: string[] = process.argv): string | null {
9
+ for (let i = 0; i < argv.length - 1; i++) {
10
+ if (argv[i] !== "-e" && argv[i] !== "--extension") continue;
11
+ const candidate = resolve(argv[i + 1]);
12
+ if (CONTINUE_ENTRY.test(candidate) && existsSync(candidate)) return candidate;
13
+ }
14
+ const local = join(cwd, ".pi", "harnesses", "damage-control-continue", "index.ts");
15
+ return existsSync(local) ? local : null;
16
+ }
17
+
18
+ export function requireSafetyHarness(path: string | null):
19
+ | { ok: true; extensions: string[] }
20
+ | { ok: false; error: string } {
21
+ return path ? { ok: true, extensions: [path] } : { ok: false, error: MISSING_SAFETY_ERROR };
22
+ }
@@ -0,0 +1,144 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { createHash } from "node:crypto";
3
+ import { lstatSync, readFileSync, readlinkSync } from "node:fs";
4
+ import { isAbsolute, join, relative, resolve } from "node:path";
5
+
6
+ export function snapshotWorktree(cwd) {
7
+ const status = gitStatus(cwd);
8
+ if (status.skipped) return { skipped: true, reason: status.reason, paths: new Set() };
9
+ try {
10
+ const fingerprints = new Map(status.paths.map(path => [path, fileFingerprint(cwd, path)]));
11
+ let head = "";
12
+ try { head = execFileSync("git", ["-C", cwd, "rev-parse", "HEAD"], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim(); } catch {}
13
+ return { skipped: false, paths: new Set(status.paths), fingerprints, head };
14
+ } catch (error) { return { skipped: true, reason: String(error), paths: new Set() }; }
15
+ }
16
+
17
+ function fileFingerprint(cwd, path) {
18
+ try {
19
+ const file = join(cwd, path), stat = lstatSync(file);
20
+ if (!stat.isFile() && !stat.isSymbolicLink()) throw new Error(`Cannot prove file-content delta for ${path}`);
21
+ return createHash("sha256").update(String(stat.mode)).update("\0").update(stat.isSymbolicLink() ? readlinkSync(file) : readFileSync(file)).digest("hex");
22
+ } catch (error) { if (error.code === "ENOENT") return "missing"; throw error; }
23
+ }
24
+
25
+ export function diffAgainst(snapshot, cwd) {
26
+ const current = snapshotWorktree(cwd);
27
+ if (snapshot?.skipped || current.skipped || snapshot?.head !== current.head) {
28
+ return { skipped: true, reason: snapshot?.reason || current.reason || "HEAD changed during observation; content attribution is incomplete", paths: [] };
29
+ }
30
+ try {
31
+ const paths = [...new Set([...snapshot.paths, ...current.paths])].filter(path => {
32
+ const before = snapshot.fingerprints.get(path);
33
+ return before === undefined || before !== (current.fingerprints.get(path) ?? fileFingerprint(cwd, path));
34
+ }).sort();
35
+ return { skipped: false, paths };
36
+ } catch (error) { return { skipped: true, reason: String(error), paths: [] }; }
37
+ }
38
+
39
+ const isSessionOutput = path => path.startsWith(".pi/agent-sessions/");
40
+
41
+ /** Review task edits, not outputs created inside this run's own session directory.
42
+ * A declared scope/deliverable under that directory is still a task edit to review.
43
+ * Other sessions' files and all non-session paths remain reviewable.
44
+ */
45
+ export function reviewableChangedPaths(paths, cwd, sessionDir, scopes = [], deliverables = []) {
46
+ const sessionPath = relative(resolve(cwd), resolve(sessionDir)).replace(/\\/g, "/");
47
+ const ownedSession = /^\.pi\/agent-sessions\/sessions\/[^/]+$/.test(sessionPath) && !isAbsolute(sessionPath);
48
+ // A generic glob (for example **/*.md) does not explicitly select runtime evidence.
49
+ const explicitSessionScopes = scopes.filter(scope => {
50
+ const normalized = normalizePath(scope);
51
+ return normalized === sessionPath || normalized.startsWith(`${sessionPath}/`);
52
+ });
53
+ return paths.filter(path => {
54
+ const output = path.startsWith(`${sessionPath}/`) ? path.slice(sessionPath.length + 1) : "";
55
+ if (!ownedSession || !/^(?:artifacts|dispatches|transcripts|findings|delegations)\/|^(?:session|assertions)\.json$/.test(output)) return true;
56
+ return checkScope([path], explicitSessionScopes).inScope.length > 0 || deliverables.some(file => relative(resolve(cwd), resolve(file)) === path);
57
+ });
58
+ }
59
+
60
+ /** Runtime outputs are not input progress. Callers add explicitly supplied evidence separately. */
61
+ export function worktreeRevision(cwd, scopes = []) {
62
+ const snapshot = snapshotWorktree(cwd);
63
+ if (snapshot.skipped) return "unavailable";
64
+ const entries = [...snapshot.fingerprints].filter(([path]) => !isSessionOutput(path) && (!scopes.length || checkScope([path], scopes).inScope.length)).sort(([a], [b]) => a.localeCompare(b));
65
+ return createHash("sha256").update(JSON.stringify([snapshot.head, entries])).digest("hex");
66
+ }
67
+
68
+ export function checkScope(changedPaths, scopeGlobs) {
69
+ const scopes = (scopeGlobs || []).map(normalizePath).filter(Boolean);
70
+ const inScope = [];
71
+ const outOfScope = [];
72
+ for (const rawPath of changedPaths || []) {
73
+ const changed = normalizePath(rawPath);
74
+ if (!changed) continue;
75
+ if (scopes.some((scope) => matchesScope(changed, scope))) inScope.push(changed);
76
+ else outOfScope.push(changed);
77
+ }
78
+ return { inScope: uniqueSorted(inScope), outOfScope: uniqueSorted(outOfScope) };
79
+ }
80
+
81
+ function gitStatus(cwd) {
82
+ try {
83
+ const output = execFileSync("git", ["-C", cwd, "status", "--porcelain", "-z", "--untracked-files=all"], {
84
+ encoding: "utf-8",
85
+ stdio: ["ignore", "pipe", "pipe"],
86
+ });
87
+ return { skipped: false, paths: parsePorcelain(output) };
88
+ } catch (err) {
89
+ return { skipped: true, reason: err?.message || "not a git worktree" };
90
+ }
91
+ }
92
+
93
+ function parsePorcelain(output) {
94
+ const entries = String(output || "").split("\0"), paths = [];
95
+ for (let i = 0; i < entries.length; i++) {
96
+ const entry = entries[i]; if (!entry) continue;
97
+ paths.push(entry.slice(3));
98
+ if (/[RC]/.test(entry.slice(0, 2)) && entries[i + 1]) paths.push(entries[++i]);
99
+ }
100
+ return uniqueSorted(paths);
101
+ }
102
+
103
+ function matchesScope(changedPath, scope) {
104
+ if (hasGlob(scope)) return globToRegExp(scope).test(changedPath);
105
+ const dir = scope.endsWith("/") ? scope.slice(0, -1) : scope;
106
+ return changedPath === dir || changedPath.startsWith(`${dir}/`);
107
+ }
108
+
109
+ function hasGlob(scope) {
110
+ return /[*?]/.test(scope);
111
+ }
112
+
113
+ function globToRegExp(glob) {
114
+ let out = "^";
115
+ for (let i = 0; i < glob.length; i++) {
116
+ const c = glob[i];
117
+ if (c === "*") {
118
+ if (glob[i + 1] === "*") {
119
+ if (glob[i + 2] === "/") { out += "(?:.*/)?"; i += 2; }
120
+ else { out += ".*"; i++; }
121
+ } else {
122
+ out += "[^/]*";
123
+ }
124
+ } else if (c === "?") {
125
+ out += "[^/]";
126
+ } else {
127
+ out += escapeRegExp(c);
128
+ }
129
+ }
130
+ out += "$";
131
+ return new RegExp(out);
132
+ }
133
+
134
+ function normalizePath(value) {
135
+ return String(value || "").trim().replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+/g, "/");
136
+ }
137
+
138
+ function uniqueSorted(values) {
139
+ return [...new Set(values)].sort();
140
+ }
141
+
142
+ function escapeRegExp(value) {
143
+ return value.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
144
+ }
@@ -0,0 +1,313 @@
1
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
2
+ import { basename, join } from "node:path";
3
+ import type { ExtensionContext } from "@mariozechner/pi-coding-agent";
4
+ import { redactSecrets } from "../lib/fleet-transcript-store.ts";
5
+ import { RECOVERY_CATEGORIES, type RecoveryCategory } from "./recovery-contract.ts";
6
+ import { readWatchdogEvents, buildProactiveReport, readProactiveReport, readTaskTriageReport, buildTaskTriageReport, type ProactiveReportInput } from "./system1-report.ts";
7
+ import { projectTaskTriage, type TaskTriageProjectionInput, type TaskTriageSessionView } from "../lib/fleet-read-model.ts";
8
+ import { projectWatchdogReadback, type TaskTriageActivity } from "./system1-activity.ts";
9
+ export type TaskTriageAuditInput = Omit<TaskTriageProjectionInput, "process"> & { activity?: ReturnType<TaskTriageActivity["live"]> };
10
+ import { createNoProgressGuard, projectRecoveryRows } from './no-progress.ts';
11
+ import { createHash } from "node:crypto";
12
+ import { taskTriageActionAuditRecord, type TaskTriageActionAuditRecord } from "./task-triage-authorization.ts";
13
+
14
+ const RESULT_SCHEMA = "agent-fleet.runtime-result/v1";
15
+ const PROTOCOL_SCHEMA = "agent-fleet.tool-protocol-diagnostic/v1";
16
+ const AUDIT_STATUSES = new Set(["accepted", "not_accepted", "authorized", "authorized_once", "budget_authorized", "retry_authorized_once", "passed", "failed", "missing", "stale", "unsupported", "busy", "invalid_input", "resource_exhausted", "operator_cancelled", "verification_failed", "tool_protocol_error", "unknown_tool", "indeterminate", "completed_unverified", "unavailable", "cleared", "open", "abandoned", "settled"]);
17
+ type Availability = "available" | "unavailable";
18
+ type AuditKind = "refusal" | "verification" | "tool_protocol" | "budget_permission" | "retry_permission" | "human_intervention" | "process_obligation" | "watchdog" | "recovery";
19
+
20
+ export interface SessionAuditEvent {
21
+ kind: AuditKind;
22
+ rootSessionId: string | null;
23
+ childDispatchId: string | null;
24
+ childSessionId: string | null;
25
+ snapshotId: string | null;
26
+ repeatCount: number;
27
+ category?: RecoveryCategory;
28
+ operationId?: string | null;
29
+ attemptId?: string | null;
30
+ technicalBlock?: 'open' | 'cleared';
31
+ openRequirements?: string[];
32
+ status: string;
33
+ taskId?: string | null;
34
+ requestId?: string | null;
35
+ operation?: string | null;
36
+ evidence: Availability;
37
+ risk?: "unknown" | "low" | "high";
38
+ scope?: "unknown" | "read-only" | "small" | "wide";
39
+ budgetTier?: string | null;
40
+ obligations?: Record<string, "satisfied" | "open" | "unsupported" | "waived">;
41
+ processAdditions?: TaskTriageSessionView["process"]["additions"];
42
+ appliedRuleIds?: string[];
43
+ currentStage?: string;
44
+ admissibleNextAction?: string;
45
+ auditScope?: string[];
46
+ explanation?: string;
47
+ watchdog?: { evaluation: string; llm: string; llmStatus: string; providerStatus: string; reason: string; source: string; applied: string; outcome: string };
48
+ }
49
+
50
+ export interface SessionAuditSummary {
51
+ schema: "agent-fleet.session-audit/v1";
52
+ readOnly: true;
53
+ identity: {
54
+ rootSessionId: string | null;
55
+ children: Array<{ dispatchId: string; sessionId: string | null }>;
56
+ snapshots: Array<{ snapshotId: string }>;
57
+ };
58
+ events: SessionAuditEvent[];
59
+ proactive: ReturnType<typeof buildProactiveReport> | ReturnType<typeof readProactiveReport>;
60
+ taskTriage: TaskTriageSessionView & { metrics: ReturnType<typeof readTaskTriageReport>; actions: ReturnType<typeof projectTaskTriageActions> };
61
+ unavailable: string[];
62
+ }
63
+
64
+ const text = (value: unknown, max = 256): string | null => typeof value === "string" && value.trim() ? value.trim().slice(0, max) : null;
65
+ const runtimeId = (value: unknown): string | null => { const normalized = text(value); return normalized && redactSecrets(normalized) === normalized && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/.test(normalized) ? normalized : null; };
66
+ const status = (value: unknown): string => { const normalized = text(value, 64); return normalized && AUDIT_STATUSES.has(normalized) ? normalized : "unavailable"; };
67
+ const operation = (value: unknown): string | null => { const normalized = text(value, 16); return normalized && ["dispatch", "research", "retry"].includes(normalized) ? normalized : null; };
68
+ const object = (value: unknown): Record<string, any> | null => value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, any> : null;
69
+ function readJson(path: string): Record<string, any> | null { try { return object(JSON.parse(readFileSync(path, "utf8"))); } catch { return null; } }
70
+ function recovery(value: unknown): RecoveryCategory | undefined { return RECOVERY_CATEGORIES.includes(value as RecoveryCategory) ? value as RecoveryCategory : undefined; }
71
+ function entryData(entry: unknown): { type: string | null; id: string | null; data: Record<string, any> | null; details: Record<string, any> | null } {
72
+ const row = object(entry), message = object(row?.message);
73
+ return {
74
+ type: text(row?.customType) ?? text(row?.type),
75
+ id: runtimeId(row?.id) ?? runtimeId(message?.id) ?? runtimeId(message?.toolCallId),
76
+ data: object(row?.data),
77
+ details: object(message?.details) ?? object(row?.details),
78
+ };
79
+ }
80
+ function runtimeResult(details: Record<string, any> | null): Record<string, any> | null {
81
+ const value = object(details?.runtimeResult) ?? (details?.schema === RESULT_SCHEMA ? details : null);
82
+ return value?.schema === RESULT_SCHEMA ? value : null;
83
+ }
84
+
85
+ /** Diagnostic joins only: durable consumption is not proof of execution or semantic acceptance. */
86
+ export function projectTaskTriageActions(entries: readonly unknown[], binding?: Pick<TaskTriageProjectionInput, "taskId" | "inputRevision">) {
87
+ type ActionRow = { metadata: TaskTriageActionAuditRecord; requested: boolean; denied: boolean; grant: boolean; consumed: boolean;
88
+ consumptionFailed: boolean; execution: "not_recorded" | "tool_result_ok" | "tool_result_error"; ambiguous: boolean; seen: Set<string> };
89
+ const rows = new Map<string, ActionRow>();
90
+ let invalidRecords = 0, overflow = false;
91
+ const hash = (v: unknown): v is string => typeof v === "string" && /^[a-f0-9]{64}$/.test(v);
92
+ const uuid = (v: unknown): v is string => typeof v === "string" && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(v);
93
+ for (const entry of entries) {
94
+ const record = entryData(entry);
95
+ const observation = record.type === "agent-hub-task-triage-action-observation";
96
+ const grant = record.type === "agent-hub-task-triage-action-grant", consumed = record.type === "agent-hub-task-triage-action-consumed";
97
+ if (observation || grant || consumed) {
98
+ const data = record.data;
99
+ let metadata: TaskTriageActionAuditRecord | null = null;
100
+ if (observation && data?.schema === "task-triage-action-audit/v1" && uuid(data.taskId) && hash(data.inputRevision)
101
+ && hash(data.actionFingerprint) && hash(data.callFingerprint) && ["bash", "edit", "write"].includes(data.operation)
102
+ && ["requested", "not_granted", "consumption_failed"].includes(data.status)
103
+ && Object.keys(data).length === 7) metadata = { schema: data.schema, taskId: data.taskId, inputRevision: data.inputRevision,
104
+ actionFingerprint: data.actionFingerprint, callFingerprint: data.callFingerprint, operation: data.operation, status: data.status };
105
+ else if (!observation && data) metadata = taskTriageActionAuditRecord(data as any, "requested");
106
+ if (!metadata) { invalidRecords++; continue; }
107
+ const key = JSON.stringify([metadata.taskId, metadata.inputRevision, metadata.callFingerprint]);
108
+ let row = rows.get(key);
109
+ if (!row) {
110
+ if (rows.size >= 300) { overflow = true; continue; }
111
+ row = { metadata, requested: false, denied: false, grant: false, consumed: false, consumptionFailed: false, execution: "not_recorded", ambiguous: false, seen: new Set() };
112
+ rows.set(key, row);
113
+ }
114
+ const type = grant ? "grant" : consumed ? "consumed" : metadata.status;
115
+ if (row.seen.has(type) || row.metadata.actionFingerprint !== metadata.actionFingerprint || row.metadata.operation !== metadata.operation) row.ambiguous = true;
116
+ row.seen.add(type);
117
+ if (grant) { if (row.denied || row.consumed) row.ambiguous = true; row.grant = true; }
118
+ else if (consumed) { if (!row.grant || row.denied || row.consumptionFailed) row.ambiguous = true; row.consumed = true; }
119
+ else if (metadata.status === "requested") row.requested = true;
120
+ else if (metadata.status === "not_granted") { if (row.grant || row.consumed) row.ambiguous = true; row.denied = true; }
121
+ else { if (row.consumed || !row.grant) row.ambiguous = true; row.consumptionFailed = true; }
122
+ continue;
123
+ }
124
+ const message = object(object(entry)?.message);
125
+ if (message?.role !== "toolResult" || typeof message.toolCallId !== "string" || !message.toolCallId || message.toolCallId.length > 512) continue;
126
+ const call = createHash("sha256").update(message.toolCallId).digest("hex");
127
+ const matching = [...rows.values()].filter(row => row.metadata.callFingerprint === call && row.metadata.operation === message.toolName && row.consumed);
128
+ if (matching.length > 1) { matching.forEach(row => { row.ambiguous = true; }); continue; }
129
+ const row = matching[0]; if (!row) continue;
130
+ if (row.execution !== "not_recorded") row.ambiguous = true;
131
+ if (typeof message.isError === "boolean") row.execution = message.isError ? "tool_result_error" : "tool_result_ok";
132
+ }
133
+ const records = [...rows.values()].map(row => ({ taskId: row.metadata.taskId, inputRevision: row.metadata.inputRevision,
134
+ actionFingerprint: row.metadata.actionFingerprint, operation: row.metadata.operation,
135
+ binding: !binding?.taskId || !binding?.inputRevision ? "unbound" : row.metadata.taskId === binding.taskId && row.metadata.inputRevision === binding.inputRevision ? "current" : "stale",
136
+ authorization: row.ambiguous ? "ambiguous" : row.grant ? "recorded_grant" : row.denied ? "not_granted" : "not_recorded",
137
+ consumption: row.ambiguous ? "ambiguous" : row.consumptionFailed ? "persistence_failed" : row.consumed ? "recorded_once" : "not_recorded",
138
+ execution: row.ambiguous ? "not_recorded" : row.denied || row.consumptionFailed ? "blocked" : row.execution }));
139
+ return { availability: records.length ? "recorded" : "unavailable", records, invalidRecords, overflow,
140
+ ambiguous: records.filter(row => row.authorization === "ambiguous").length, completeness: "retained session entries only; no replay authority" };
141
+ }
142
+
143
+ /** Build an allowlisted audit from runtime-owned records. Prompt, output, payload, paths and environment values are never copied. */
144
+ export function buildSessionAudit(input: { entries: readonly unknown[]; sessionDir: string; proactive?: ProactiveReportInput; taskTriage?: TaskTriageAuditInput }): SessionAuditSummary {
145
+ const unavailable = new Set<string>(), meta = readJson(join(input.sessionDir, "session.json"));
146
+ const rootSessionId = runtimeId(meta?.sessionId) ?? runtimeId(basename(input.sessionDir));
147
+ if (!meta) unavailable.add("root_session_metadata");
148
+ const children = new Map<string, string | null>(), snapshots = new Set<string>();
149
+ const rawEvents: Omit<SessionAuditEvent, "repeatCount">[] = [];
150
+ const add = (event: Omit<SessionAuditEvent, "repeatCount">) => rawEvents.push(event);
151
+ const dispatchRoot = join(input.sessionDir, "dispatches");
152
+ if (existsSync(dispatchRoot)) {
153
+ for (const dispatchPathId of readdirSync(dispatchRoot).sort()) {
154
+ const dispatchId = runtimeId(dispatchPathId);
155
+ if (!dispatchId) { unavailable.add("child_identity"); continue; }
156
+ const result = readJson(join(dispatchRoot, dispatchPathId, "result.json"));
157
+ if (!result) { unavailable.add(`child_result:${dispatchId}`); children.set(dispatchId, null); continue; }
158
+ const childSessionId = text(result.sessionPath) ? runtimeId(basename(String(result.sessionPath)).replace(/\.jsonl?$/i, "")) : null;
159
+ children.set(dispatchId, childSessionId);
160
+ const category = recovery(result.recoveryCategory);
161
+ if (category) add({ kind: "refusal", rootSessionId, childDispatchId: dispatchId, childSessionId, snapshotId: null, category, status: status(result.status), evidence: "available" });
162
+ if (object(result.protocolDiagnostic)?.schema === PROTOCOL_SCHEMA) add({ kind: "tool_protocol", rootSessionId, childDispatchId: dispatchId, childSessionId, snapshotId: null, category: "tool_protocol_error", status: "tool_protocol_error", evidence: "available" });
163
+ }
164
+ } else unavailable.add("child_execution_records");
165
+
166
+ // Compaction snapshots contain prior append-only rows; project once from the last snapshot.
167
+ let projected: any[] = [];
168
+ try {
169
+ // The audit must not infer an empty or clean history from an invalid checkpoint.
170
+ createNoProgressGuard().restore(input.entries);
171
+ projected = projectRecoveryRows(input.entries);
172
+ } catch {
173
+ unavailable.add('recovery_history_integrity');
174
+ }
175
+ const attemptDispatch = new Map<string, string>();
176
+ const recoveryDispatch = new Map<string, { operationId: string; attemptId: string }>();
177
+ const attemptCategory = new Map<string, RecoveryCategory>();
178
+ const attemptRequirements = new Map<string, string[]>();
179
+ for (const row of projected) {
180
+ const event = object(row?.event), type = text(event?.type), opId = runtimeId(event?.operationId), attemptId = runtimeId(event?.attemptId);
181
+ if (row?.kind === 'guard' && type === 'evidence') {
182
+ const evidence = object(event?.evidence), id = runtimeId(evidence?.dispatchId);
183
+ if (id && Array.isArray(evidence?.openRequirements)) attemptRequirements.set(id, evidence.openRequirements.map(runtimeId).filter((x: string | null): x is string => !!x).slice(0, 64));
184
+ }
185
+ if (row?.kind !== 'ledger' || !opId || !attemptId) continue;
186
+ const dispatchId = type === 'start' || type === 'dispatch' ? runtimeId(event?.dispatchId) : attemptDispatch.get(attemptId) ?? null;
187
+ if (dispatchId) { attemptDispatch.set(attemptId, dispatchId); recoveryDispatch.set(dispatchId, { operationId: opId, attemptId }); }
188
+ if (type === 'failure') { const category = recovery(event?.category); if (category) attemptCategory.set(attemptId, category); }
189
+ if (!['start','failure','settled','grant','technical','abandon','complete'].includes(type ?? '')) continue;
190
+ const category = attemptCategory.get(attemptId), technicalBlock = type === 'technical' && ['open','cleared'].includes(event?.status) ? event?.status as 'open' | 'cleared' : undefined;
191
+ add({ kind: 'recovery', rootSessionId, childDispatchId: dispatchId, childSessionId: dispatchId ? children.get(dispatchId) ?? null : null, snapshotId: null,
192
+ taskId: runtimeId(event?.taskId), operationId: opId, attemptId, category,
193
+ status: type === 'technical' ? technicalBlock ?? 'unavailable' : type === 'grant' ? 'authorized_once' : type === 'abandon' ? 'abandoned' : type === 'settled' ? 'settled' : type === 'failure' ? 'failed' : 'open',
194
+ technicalBlock, openRequirements: type === 'technical' && dispatchId ? attemptRequirements.get(dispatchId) ?? [] : undefined,
195
+ evidence: type === 'technical' || type === 'settled' ? 'available' : 'available',
196
+ explanation: type === 'grant' ? 'Human-authorized one-use indeterminate retry; partial side effects and duplicate effects were warned; no automatic execution.' : type === 'technical' ? 'Technical assessment only; failed execution and parent acceptance remain independent.' : undefined });
197
+ }
198
+ let latestProcess: unknown;
199
+ for (const entry of input.entries) {
200
+ const record = entryData(entry), snapshotId = record.type === "compaction" || record.type === "session_compact" ? record.id : null;
201
+ if (snapshotId) { snapshots.add(snapshotId); continue; }
202
+ if (record.type === "agent-hub-process-state") {
203
+ latestProcess = record.data;
204
+ if (record.data && Object.hasOwn(record.data, "additions")) {
205
+ const projected = projectTaskTriage({ ...input.taskTriage, process: record.data }).process;
206
+ add({ kind: "process_obligation", rootSessionId, childDispatchId: null, childSessionId: null, snapshotId: null,
207
+ status: projected.completion === "process_complete" ? "accepted" : "not_accepted",
208
+ risk: projected.declaration.risk as SessionAuditEvent["risk"], scope: projected.declaration.scope as SessionAuditEvent["scope"],
209
+ budgetTier: projected.declaration.budgetTier, obligations: projected.obligations ?? undefined, processAdditions: projected.additions,
210
+ currentStage: projected.currentStage, evidence: projected.availability === "available" ? "available" : "unavailable",
211
+ explanation: "Process status only; waivers remain waived and per-effect confirmation is independent of task acceptance." });
212
+ continue;
213
+ }
214
+ const data = record.data, risk = ["unknown", "low", "high"].includes(data?.risk) ? data!.risk as "unknown" | "low" | "high" : "unknown";
215
+ const budgetTier = ["trivial", "small", "feature", "project"].includes(data?.budgetTier) ? data!.budgetTier : null;
216
+ const scope = ["unknown", "read-only", "small", "wide"].includes(data?.scope) ? data!.scope : "unknown";
217
+ const appliedRuleIds = Array.isArray(data?.appliedRuleIds) ? data.appliedRuleIds.filter((v: unknown) => typeof v === "string").slice(0, 8) : [];
218
+ const currentStage = text(data?.currentStage, 64) ?? "unavailable", admissibleNextAction = text(data?.admissibleNextAction, 160) ?? "unavailable";
219
+ const auditScope = Array.isArray(data?.auditScope) ? data.auditScope.filter((v: unknown) => typeof v === "string").slice(0, 64) : [];
220
+ const raw = object(data?.obligations), obligations: Record<string, "satisfied" | "open" | "unsupported"> = {};
221
+ for (const name of ["risk", "acceptance", "review", "plan"]) {
222
+ const item = object(raw?.[name]), value = item?.status;
223
+ obligations[name] = ["satisfied", "open", "unsupported"].includes(value) ? value : "unsupported";
224
+ }
225
+ add({ kind: "process_obligation", rootSessionId, childDispatchId: null, childSessionId: null, snapshotId: null,
226
+ status: Object.values(obligations).some(value => value !== "satisfied") ? "not_accepted" : "accepted", risk, scope, budgetTier,
227
+ obligations, appliedRuleIds, currentStage, admissibleNextAction, auditScope, explanation: `Risk ${risk}; scope ${scope}; budget tier ${budgetTier ?? "unavailable"} limits spend only. Open obligations: ${Object.entries(obligations).filter(([, value]) => value !== "satisfied").map(([name]) => name).join(", ") || "none"}.`, evidence: "available" });
228
+ continue;
229
+ }
230
+ if (record.type === "agent-hub-budget-continuation") {
231
+ const correlation = object(record.data?.correlation), evidence = correlation ? "available" as const : "unavailable" as const;
232
+ const base = { rootSessionId, childDispatchId: null, childSessionId: null, snapshotId: null, taskId: runtimeId(correlation?.task_id), requestId: runtimeId(correlation?.request_id), operation: operation(correlation?.operation), evidence };
233
+ add({ ...base, kind: "budget_permission", status: "authorized" });
234
+ add({ ...base, kind: "human_intervention", status: "budget_authorized" });
235
+ continue;
236
+ }
237
+ if (record.type === "agent-hub-retry-authorized") {
238
+ const correlation = object(record.data?.correlation), dispatchId = runtimeId(record.data?.dispatchId), evidence = correlation ? "available" as const : "unavailable" as const;
239
+ const base = { rootSessionId, childDispatchId: dispatchId, childSessionId: dispatchId ? children.get(dispatchId) ?? null : null, snapshotId: null, taskId: runtimeId(correlation?.taskId), requestId: runtimeId(correlation?.requestId), operation: operation(correlation?.operation), evidence };
240
+ add({ ...base, kind: "retry_permission", status: "authorized_once" });
241
+ add({ ...base, kind: "human_intervention", status: "retry_authorized_once" });
242
+ continue;
243
+ }
244
+ const details = record.details, result = runtimeResult(details);
245
+ if (!result) {
246
+ const category = recovery(details?.recoveryCategory);
247
+ if (category) {
248
+ const dispatchId = runtimeId(details?.dispatchId) ?? runtimeId(details?.previousDispatchId);
249
+ add({ kind: category === "tool_protocol_error" ? "tool_protocol" : "refusal", rootSessionId, childDispatchId: dispatchId, childSessionId: dispatchId ? children.get(dispatchId) ?? null : null, snapshotId: null, category, status: status(details?.status ?? category), evidence: "available" });
250
+ }
251
+ continue;
252
+ }
253
+ const execution = object(result.execution), verification = object(result.verification), acceptance = object(result.acceptance), task = object(result.task);
254
+ const dispatchId = runtimeId(execution?.dispatchId), childSessionId = dispatchId ? children.get(dispatchId) ?? null : null;
255
+ if (verification?.status !== "passed") add({ kind: "verification", rootSessionId, childDispatchId: dispatchId, childSessionId, snapshotId: null, status: status(verification?.status), taskId: runtimeId(task?.id), evidence: verification?.status ? "available" : "unavailable" });
256
+ const category = recovery(details?.recoveryCategory);
257
+ if (category) add({ kind: category === "tool_protocol_error" ? "tool_protocol" : "refusal", rootSessionId, childDispatchId: dispatchId, childSessionId, snapshotId: null, category, status: status(details?.status ?? acceptance?.status), taskId: runtimeId(task?.id), evidence: "available" });
258
+ const linked = dispatchId ? recoveryDispatch.get(dispatchId) : undefined;
259
+ if (linked && acceptance?.status === 'accepted' && result.execution?.status === 'completed' && verification?.status === 'passed')
260
+ add({ kind:'recovery', rootSessionId, childDispatchId:dispatchId, childSessionId, snapshotId:null, taskId:runtimeId(task?.id), operationId:linked.operationId, attemptId:linked.attemptId, status:'accepted', evidence:'available' });
261
+ }
262
+
263
+ // Trace-only, read-only projection: unknown/interrupted is not guessed into a verdict.
264
+ const watchdogTrace = readWatchdogEvents(input.sessionDir);
265
+ if (watchdogTrace.integrity.partialTail || watchdogTrace.integrity.invalidRecords || watchdogTrace.integrity.readError) unavailable.add("watchdog_trace_integrity");
266
+ for (const check of projectWatchdogReadback(watchdogTrace.events)) {
267
+ const dispatchId = runtimeId(check.dispatchId), attemptId = runtimeId(check.attemptId), checkId = runtimeId(check.checkId);
268
+ if (!dispatchId || !attemptId || !checkId) continue;
269
+ const allowed = new Set(["continue", "advisory", "drift_stop", "judge_unavailable", "discard"]);
270
+ add({ kind: "watchdog", rootSessionId, childDispatchId: dispatchId, childSessionId: children.get(dispatchId) ?? null,
271
+ snapshotId: runtimeId(check.snapshotId), requestId: checkId, taskId: attemptId,
272
+ status: allowed.has(check.outcome) ? check.outcome : check.evaluation === "interrupted" || check.llm === "interrupted" ? "indeterminate" : "unavailable",
273
+ watchdog: {
274
+ evaluation: ["finished", "interrupted", "unknown"].includes(check.evaluation) ? check.evaluation : "unknown",
275
+ llm: ["finished", "interrupted", "none"].includes(check.llm) ? check.llm : "unknown",
276
+ llmStatus: ["verdict", "unavailable", "cancelled"].includes(check.llmStatus ?? "") ? check.llmStatus! : "unknown",
277
+ providerStatus: ["ok", "skipped", "unavailable", "unsupported", "cancelled"].includes(check.status) ? check.status : "unknown",
278
+ reason: ["timeout", "network", "auth", "rate_limit", "overloaded", "invalid_config", "invalid_request", "missing_key", "consumer_off", "state_too_large", "disposed", "interrupted", "unknown"].includes(check.reason) ? check.reason : "unknown",
279
+ source: ["llm", "none", "system1"].includes(check.source) ? check.source : "unknown",
280
+ applied: check.applied === "yes" || check.applied === "no" ? check.applied : "unknown",
281
+ outcome: allowed.has(check.outcome) ? check.outcome : "unknown",
282
+ },
283
+ evidence: check.evaluation === "interrupted" || check.llm === "interrupted" ? "unavailable" : "available" });
284
+ }
285
+ const diskMetrics = readTaskTriageReport(input.sessionDir);
286
+ // Disk includes prior session instances. Use bounded live fallback only if this
287
+ // observer lost writes; report the source rather than duplicating its events.
288
+ const liveActivity = input.taskTriage?.activity;
289
+ const metrics = liveActivity?.degraded ? { ...buildTaskTriageReport(liveActivity.events, liveActivity, diskMetrics.observability),
290
+ availability: "session-memory", scope: "bounded-live-observer; durable trace degraded" } : diskMetrics;
291
+ const taskTriage = { ...projectTaskTriage({ ...input.taskTriage, process: latestProcess }), metrics, actions: projectTaskTriageActions(input.entries, input.taskTriage) };
292
+ if (taskTriage.actions.invalidRecords || taskTriage.actions.ambiguous || taskTriage.actions.overflow) unavailable.add("task_triage_action_integrity");
293
+ if (latestProcess !== undefined && taskTriage.process.availability === "unavailable") unavailable.add("task_triage_process_integrity");
294
+ if (taskTriage.metrics.observability.degraded) unavailable.add("task_triage_trace_integrity");
295
+ const deduped = new Map<string, SessionAuditEvent>();
296
+ for (const event of rawEvents) {
297
+ const key = JSON.stringify([event.kind, event.rootSessionId, event.childDispatchId, event.childSessionId, event.snapshotId, event.category ?? null, event.status, event.taskId ?? null, event.requestId ?? null, event.operation ?? null, event.risk ?? null, event.scope ?? null, event.budgetTier ?? null, event.obligations ?? null, event.processAdditions ?? null, event.appliedRuleIds ?? null, event.currentStage ?? null, event.admissibleNextAction ?? null, event.auditScope ?? null, event.watchdog ?? null, event.operationId ?? null, event.attemptId ?? null, event.technicalBlock ?? null, event.openRequirements ?? null]);
298
+ const prior = deduped.get(key);
299
+ if (prior) prior.repeatCount++;
300
+ else deduped.set(key, { ...event, repeatCount: 1 });
301
+ }
302
+ return {
303
+ schema: "agent-fleet.session-audit/v1", readOnly: true,
304
+ identity: { rootSessionId, children: [...children].map(([dispatchId, sessionId]) => ({ dispatchId, sessionId })), snapshots: [...snapshots].map(snapshotId => ({ snapshotId })) },
305
+ events: [...deduped.values()], proactive: input.proactive ? buildProactiveReport(input.proactive) : readProactiveReport(input.sessionDir), taskTriage, unavailable: [...unavailable].sort(),
306
+ };
307
+ }
308
+
309
+ export function formatSessionAudit(summary: SessionAuditSummary): string { return JSON.stringify(summary, null, 2); }
310
+
311
+ export async function showSessionAudit(ctx: ExtensionContext, sessionDir: string, proactive?: ProactiveReportInput, taskTriage?: TaskTriageAuditInput): Promise<void> {
312
+ ctx.ui.notify(formatSessionAudit(buildSessionAudit({ entries: ctx.sessionManager.getEntries(), sessionDir, proactive, taskTriage })), "info");
313
+ }