@chankov/agent-fleet 2.1.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (861) hide show
  1. package/.pi/agent-fleet/hooks/coms-stop-hook.mjs +53 -13
  2. package/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/README.md +223 -0
  3. package/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/bootstrap-profile-0.167.json +5627 -0
  4. package/.pi/agent-fleet/scripts/fleet-codex-local-mcp.ts +4 -0
  5. package/.pi/agent-fleet/scripts/fleet.ts +13 -17
  6. package/.pi/agent-fleet/scripts/flow.ts +2 -2
  7. package/.pi/agent-fleet/scripts/lib/codex-bootstrap-files.ts +46 -0
  8. package/.pi/agent-fleet/scripts/lib/codex-bootstrap-probe.ts +44 -0
  9. package/.pi/agent-fleet/scripts/lib/codex-bootstrap-producer.ts +131 -0
  10. package/.pi/agent-fleet/scripts/lib/codex-daemon-observer.ts +137 -0
  11. package/.pi/agent-fleet/scripts/lib/codex-desktop-discovery.ts +84 -0
  12. package/.pi/agent-fleet/scripts/lib/codex-desktop-preflight.ts +130 -0
  13. package/.pi/agent-fleet/scripts/lib/codex-desktop-queue-host.ts +20 -13
  14. package/.pi/agent-fleet/scripts/lib/codex-measurement.ts +218 -0
  15. package/.pi/agent-fleet/scripts/lib/codex-native-presence.ts +61 -0
  16. package/.pi/agent-fleet/scripts/lib/codex-probe-transcript.ts +135 -0
  17. package/.pi/agent-fleet/scripts/lib/codex-send-lineage.ts +72 -0
  18. package/.pi/agent-fleet/scripts/lib/codex-unix-queue-rpc.ts +23 -13
  19. package/.pi/agent-fleet/scripts/lib/fleet-codex-allowlist-store.ts +100 -14
  20. package/.pi/agent-fleet/scripts/lib/fleet-codex-answers.ts +1 -1
  21. package/.pi/agent-fleet/scripts/lib/fleet-codex-bootstrap.ts +204 -0
  22. package/.pi/agent-fleet/scripts/lib/fleet-codex-connections.ts +9 -3
  23. package/.pi/agent-fleet/scripts/lib/fleet-codex-event-runtime.ts +32 -16
  24. package/.pi/agent-fleet/scripts/lib/fleet-codex-local-mcp.ts +41 -21
  25. package/.pi/agent-fleet/scripts/lib/fleet-codex-permission-transport.ts +21 -0
  26. package/.pi/agent-fleet/scripts/lib/fleet-command.ts +4 -8
  27. package/.pi/agent-fleet/scripts/lib/flow-maintenance.ts +2 -1
  28. package/.pi/agent-fleet/scripts/lib/team-project.ts +0 -2
  29. package/.pi/agent-fleet/scripts/team-up.ts +5 -12
  30. package/.pi/agent-fleet/scripts/workflows/lib/git.ts +9 -0
  31. package/.pi/agent-fleet/scripts/workflows/lib/quality.ts +17 -4
  32. package/.pi/agents/model-profiles.yaml +0 -2
  33. package/.pi/harnesses/agent-hub/README.md +116 -67
  34. package/.pi/harnesses/agent-hub/capability-packs.ts +7 -4
  35. package/.pi/harnesses/agent-hub/codex-bootstrap.ts +117 -0
  36. package/.pi/harnesses/agent-hub/commands/context.ts +0 -4
  37. package/.pi/harnesses/agent-hub/commands/recover.ts +2 -1
  38. package/.pi/harnesses/agent-hub/config/agents.ts +3 -1
  39. package/.pi/harnesses/agent-hub/config/model-profiles.ts +3 -0
  40. package/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +14 -1
  41. package/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +17 -0
  42. package/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +3 -1
  43. package/.pi/harnesses/agent-hub/dispatch-native-types.ts +4 -0
  44. package/.pi/harnesses/agent-hub/dispatch-native.ts +9 -3
  45. package/.pi/harnesses/agent-hub/drift-watchdog.js +5 -10
  46. package/.pi/harnesses/agent-hub/execution-trace.ts +1 -1
  47. package/.pi/harnesses/agent-hub/filesystem-tool.ts +1 -1
  48. package/.pi/harnesses/agent-hub/footer.ts +2 -3
  49. package/.pi/harnesses/agent-hub/helpers.ts +4 -5
  50. package/.pi/harnesses/agent-hub/history-projection.ts +1 -1
  51. package/.pi/harnesses/agent-hub/index.ts +213 -196
  52. package/.pi/harnesses/agent-hub/input/shortcuts.ts +0 -7
  53. package/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +0 -2
  54. package/.pi/harnesses/agent-hub/no-progress.ts +14 -9
  55. package/.pi/harnesses/agent-hub/operator-current-state.ts +5 -1
  56. package/.pi/harnesses/agent-hub/package.json +1 -1
  57. package/.pi/harnesses/agent-hub/policy/roster.ts +12 -3
  58. package/.pi/harnesses/agent-hub/policy/work-mode.ts +10 -49
  59. package/.pi/harnesses/agent-hub/poll-command.ts +12 -4
  60. package/.pi/harnesses/agent-hub/proactive-snapshot.ts +12 -4
  61. package/.pi/harnesses/agent-hub/process-obligations.ts +42 -9
  62. package/.pi/harnesses/agent-hub/prompts/context.ts +17 -0
  63. package/.pi/harnesses/agent-hub/prompts/fragments.ts +9 -1
  64. package/.pi/harnesses/agent-hub/prompts/session-start.ts +2 -3
  65. package/.pi/harnesses/agent-hub/prompts/system-prompt.ts +25 -8
  66. package/.pi/harnesses/agent-hub/provider-semaphore.js +5 -0
  67. package/.pi/harnesses/agent-hub/review-continuity.ts +5 -2
  68. package/.pi/harnesses/agent-hub/review-reuse.ts +2 -1
  69. package/.pi/harnesses/agent-hub/run-budget.js +22 -2
  70. package/.pi/harnesses/agent-hub/scope-gate.js +38 -0
  71. package/.pi/harnesses/agent-hub/scope-overlap.ts +46 -0
  72. package/.pi/harnesses/agent-hub/task-brief.ts +98 -0
  73. package/.pi/harnesses/agent-hub/tool-catalog-runtime.ts +4 -0
  74. package/.pi/harnesses/agent-hub/tool-catalog-state.ts +5 -3
  75. package/.pi/harnesses/agent-hub/tools/action-executors.ts +5 -7
  76. package/.pi/harnesses/agent-hub/tools/context.ts +2 -0
  77. package/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +2 -1
  78. package/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +184 -33
  79. package/.pi/harnesses/agent-hub/tools/poll-panel-core.ts +30 -0
  80. package/.pi/harnesses/agent-hub/tools/poll-panel.ts +33 -0
  81. package/.pi/harnesses/agent-hub/tools/run-flow.ts +41 -10
  82. package/.pi/harnesses/agent-hub/tools/team-adjust.ts +1 -1
  83. package/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +12 -2
  84. package/.pi/harnesses/agent-hub/work-mode.ts +44 -49
  85. package/.pi/harnesses/agent-hub/write-isolation.ts +53 -8
  86. package/.pi/harnesses/coms/package.json +1 -1
  87. package/.pi/harnesses/damage-control-continue/package.json +1 -1
  88. package/.pi/harnesses/lib/codex-compat.ts +97 -0
  89. package/.pi/harnesses/lib/codex-contract.ts +259 -0
  90. package/.pi/harnesses/lib/codex-notification-profile.ts +75 -0
  91. package/.pi/harnesses/lib/coms-core.ts +8 -4
  92. package/.pi/harnesses/lib/context-budget-child-prompt.ts +1 -1
  93. package/.pi/harnesses/lib/context-budget-hub-prompt.ts +6 -3
  94. package/.pi/harnesses/lib/fleet-bootstrap-channel.ts +148 -0
  95. package/.pi/harnesses/lib/fleet-codex-catalog.ts +30 -0
  96. package/.pi/harnesses/lib/fleet-codex-chat-view.ts +43 -0
  97. package/.pi/harnesses/lib/fleet-codex-namespace.ts +2 -0
  98. package/.pi/harnesses/lib/fleet-codex-policy-snapshot.ts +10 -0
  99. package/.pi/harnesses/lib/fleet-connection-control.ts +20 -3
  100. package/.pi/harnesses/lib/fleet-notification-admission.ts +32 -0
  101. package/.pi/harnesses/lib/fleet-notification-bootstrap.ts +152 -0
  102. package/.pi/harnesses/lib/fleet-notification-validation.ts +80 -25
  103. package/.pi/harnesses/lib/fleet-target-identity.ts +9 -0
  104. package/.versions/2.2.0/.pi/agent-fleet/hermes/README.md +347 -0
  105. package/.versions/2.2.0/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
  106. package/.versions/2.2.0/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
  107. package/.versions/2.2.0/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  108. package/.versions/2.2.0/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  109. package/.versions/2.2.0/.pi/agent-fleet/hermes/gates/gate-o-capability.md +8 -0
  110. package/.versions/2.2.0/.pi/agent-fleet/hermes/gates/gate-o-validator-fixtures.json +1 -0
  111. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +773 -0
  112. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
  113. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
  114. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
  115. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
  116. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
  117. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
  118. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
  119. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
  120. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
  121. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
  122. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  123. package/.versions/2.2.0/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  124. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-conductor/SKILL.md +84 -0
  125. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-liaison/SKILL.md +84 -0
  126. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/SKILL.md +76 -0
  127. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/manifest.json +1 -0
  128. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
  129. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
  130. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
  131. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
  132. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
  133. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
  134. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
  135. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
  136. package/.versions/2.2.0/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
  137. package/.versions/2.2.0/.pi/agent-fleet/hermes/watchdog-tests/__init__.py +0 -0
  138. package/.versions/2.2.0/.pi/agent-fleet/hooks/coms-stop-hook.mjs +124 -0
  139. package/.versions/2.2.0/.pi/agent-fleet/scripts/claude-code-preflight.ts +70 -0
  140. package/.versions/2.2.0/.pi/agent-fleet/scripts/coms-claude-bridge.ts +440 -0
  141. package/.versions/2.2.0/.pi/agent-fleet/scripts/coms-cli.ts +430 -0
  142. package/.versions/2.2.0/.pi/agent-fleet/scripts/coms-hermes-bridge.ts +416 -0
  143. package/.versions/2.2.0/.pi/agent-fleet/scripts/exec-at-target.ts +10 -0
  144. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/0.167-shared.json +1900 -0
  145. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/README.md +223 -0
  146. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/assessment.md +83 -0
  147. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/bootstrap-profile-0.167.json +5627 -0
  148. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/bootstrap-profile.md +43 -0
  149. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/bootstrap.md +45 -0
  150. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/capture-profile.ts +53 -0
  151. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/capture.ts +102 -0
  152. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/catalog.md +91 -0
  153. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/channel.md +21 -0
  154. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/measurement.md +133 -0
  155. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/measurements.json +74 -0
  156. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/notification-profile-0.167.json +2679 -0
  157. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/observer.md +101 -0
  158. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/opaque-response.md +57 -0
  159. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/open-sent.md +68 -0
  160. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/probe-reader.md +51 -0
  161. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/profile.md +71 -0
  162. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/projection.md +147 -0
  163. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/reconnect.md +40 -0
  164. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/response-unions.md +74 -0
  165. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/semver.md +124 -0
  166. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/codex-notification-contracts/surface.md +73 -0
  167. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/fleet-codex-allowlist-store-child.ts +31 -0
  168. package/.versions/2.2.0/.pi/agent-fleet/scripts/fixtures/response-fixture.ts +23 -0
  169. package/.versions/2.2.0/.pi/agent-fleet/scripts/fleet-codex-local-mcp.mjs +26 -0
  170. package/.versions/2.2.0/.pi/agent-fleet/scripts/fleet-codex-local-mcp.ts +63 -0
  171. package/.versions/2.2.0/.pi/agent-fleet/scripts/fleet.ts +244 -0
  172. package/.versions/2.2.0/.pi/agent-fleet/scripts/flow.ts +166 -0
  173. package/.versions/2.2.0/.pi/agent-fleet/scripts/hermes-monitor-capability-runner.ts +25 -0
  174. package/.versions/2.2.0/.pi/agent-fleet/scripts/hermes-monitor-scenario.ts +474 -0
  175. package/.versions/2.2.0/.pi/agent-fleet/scripts/hermes-watchdog-capability-probe.ts +45 -0
  176. package/.versions/2.2.0/.pi/agent-fleet/scripts/install-hermes-plugin.sh +180 -0
  177. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/claude-bridge-core.ts +208 -0
  178. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-bootstrap-files.ts +46 -0
  179. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-bootstrap-probe.ts +44 -0
  180. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-bootstrap-producer.ts +131 -0
  181. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-daemon-observer.ts +137 -0
  182. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-desktop-discovery.ts +84 -0
  183. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-desktop-preflight.ts +130 -0
  184. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-desktop-queue-host.ts +113 -0
  185. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-measurement.ts +218 -0
  186. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-native-presence.ts +61 -0
  187. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-probe-transcript.ts +135 -0
  188. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-send-lineage.ts +72 -0
  189. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/codex-unix-queue-rpc.ts +101 -0
  190. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/coms-envelope.ts +582 -0
  191. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fake-herdr-server.ts +88 -0
  192. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-allowlist-store.ts +453 -0
  193. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-allowlist.ts +175 -0
  194. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-answer-transport.ts +73 -0
  195. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-answers.ts +74 -0
  196. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-bootstrap.ts +204 -0
  197. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-connections.ts +76 -0
  198. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-event-reply.ts +58 -0
  199. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-event-runtime.ts +132 -0
  200. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-instruction-store.ts +428 -0
  201. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-instruction-transport.ts +160 -0
  202. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-instructions.ts +175 -0
  203. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-local-mcp.ts +435 -0
  204. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-native-history.ts +215 -0
  205. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-observation-store.ts +208 -0
  206. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-observe-transport.ts +49 -0
  207. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-observe.ts +93 -0
  208. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-overview.ts +52 -0
  209. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-permission-transport.ts +44 -0
  210. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-permissions.ts +83 -0
  211. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-readonly.ts +213 -0
  212. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-relay-latency.ts +45 -0
  213. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-response-read.ts +26 -0
  214. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-response-transport.ts +38 -0
  215. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-codex-resync.ts +212 -0
  216. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/fleet-command.ts +264 -0
  217. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/flow-command.ts +107 -0
  218. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/flow-maintenance.ts +239 -0
  219. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/herdr-layout.ts +281 -0
  220. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-bridge-core.ts +241 -0
  221. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-events.ts +1 -0
  222. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-herdr.ts +2 -0
  223. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-model.ts +3 -0
  224. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-registry.ts +2 -0
  225. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-socket.ts +2 -0
  226. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/hermes-monitor-store.ts +2 -0
  227. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/monitor-env.ts +146 -0
  228. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/peer-launch.ts +318 -0
  229. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/peer-target.ts +1 -0
  230. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/persona-banner.ts +62 -0
  231. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/persona-dirs.ts +25 -0
  232. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/resource-closure.js +1 -0
  233. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/runtime-dependencies.js +124 -0
  234. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/session-launch.ts +56 -0
  235. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/spawn-stagger.ts +101 -0
  236. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/team-project.ts +176 -0
  237. package/.versions/2.2.0/.pi/agent-fleet/scripts/lib/team-snapshot.ts +160 -0
  238. package/.versions/2.2.0/.pi/agent-fleet/scripts/package-lock.json +57 -0
  239. package/.versions/2.2.0/.pi/agent-fleet/scripts/package.json +10 -0
  240. package/.versions/2.2.0/.pi/agent-fleet/scripts/peer-banner.ts +41 -0
  241. package/.versions/2.2.0/.pi/agent-fleet/scripts/peer-launch.ts +289 -0
  242. package/.versions/2.2.0/.pi/agent-fleet/scripts/pi-session.ts +9 -0
  243. package/.versions/2.2.0/.pi/agent-fleet/scripts/team-snapshot.ts +245 -0
  244. package/.versions/2.2.0/.pi/agent-fleet/scripts/team-up.ts +378 -0
  245. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/agent-phase.ts +181 -0
  246. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/changes.ts +61 -0
  247. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/debate.ts +149 -0
  248. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/env.ts +36 -0
  249. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/envelopes.ts +169 -0
  250. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/gates.ts +81 -0
  251. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/git.ts +108 -0
  252. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/isolated-snapshot.ts +130 -0
  253. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/merge.ts +95 -0
  254. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/model-profile.ts +22 -0
  255. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/model-visibility.ts +92 -0
  256. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/permissions.ts +137 -0
  257. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/personas.ts +57 -0
  258. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/poll.ts +86 -0
  259. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/project-policy.ts +37 -0
  260. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/quality.ts +78 -0
  261. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/run.ts +109 -0
  262. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/scout-data-boundary.ts +55 -0
  263. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/trace.ts +52 -0
  264. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/voices.ts +128 -0
  265. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/writer-lease-race.worker.mjs +36 -0
  266. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/lib/writer-lease.ts +148 -0
  267. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/tsconfig.json +22 -0
  268. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-build-test.ts +61 -0
  269. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-debate.ts +87 -0
  270. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-document.ts +50 -0
  271. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-poll.ts +95 -0
  272. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-quality.ts +20 -0
  273. package/.versions/2.2.0/.pi/agent-fleet/scripts/workflows/wf-scout.ts +40 -0
  274. package/.versions/2.2.0/.pi/agents/dispatch-policy.yaml +32 -0
  275. package/.versions/2.2.0/.pi/agents/model-profiles.yaml +132 -0
  276. package/.versions/2.2.0/.pi/agents/peers.yaml +147 -0
  277. package/.versions/2.2.0/.pi/agents/teams.yaml +41 -0
  278. package/.versions/2.2.0/.pi/agents/voices.yaml +13 -0
  279. package/.versions/2.2.0/.pi/damage-control-rules.yaml +297 -0
  280. package/.versions/2.2.0/.pi/extensions/btw/README.md +120 -0
  281. package/.versions/2.2.0/.pi/extensions/btw/index.ts +916 -0
  282. package/.versions/2.2.0/.pi/extensions/btw/package.json +6 -0
  283. package/.versions/2.2.0/.pi/extensions/btw/state.js +179 -0
  284. package/.versions/2.2.0/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
  285. package/.versions/2.2.0/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
  286. package/.versions/2.2.0/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  287. package/.versions/2.2.0/.pi/extensions/compact-and-continue/README.md +42 -0
  288. package/.versions/2.2.0/.pi/extensions/compact-and-continue/index.ts +136 -0
  289. package/.versions/2.2.0/.pi/extensions/compact-and-continue/package.json +6 -0
  290. package/.versions/2.2.0/.pi/extensions/mcp-bridge/README.md +46 -0
  291. package/.versions/2.2.0/.pi/extensions/mcp-bridge/index.ts +206 -0
  292. package/.versions/2.2.0/.pi/extensions/mcp-bridge/package.json +6 -0
  293. package/.versions/2.2.0/.pi/extensions/package-lock.json +1175 -0
  294. package/.versions/2.2.0/.pi/extensions/package.json +9 -0
  295. package/.versions/2.2.0/.pi/extensions/pi-voice-stt/README.md +224 -0
  296. package/.versions/2.2.0/.pi/extensions/pi-voice-stt/config.ts +199 -0
  297. package/.versions/2.2.0/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  298. package/.versions/2.2.0/.pi/extensions/pi-voice-stt/index.ts +248 -0
  299. package/.versions/2.2.0/.pi/extensions/pi-voice-stt/package.json +6 -0
  300. package/.versions/2.2.0/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  301. package/.versions/2.2.0/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  302. package/.versions/2.2.0/.pi/harnesses/agent-hub/README.md +1633 -0
  303. package/.versions/2.2.0/.pi/harnesses/agent-hub/acceptance.ts +204 -0
  304. package/.versions/2.2.0/.pi/harnesses/agent-hub/access-approval.ts +266 -0
  305. package/.versions/2.2.0/.pi/harnesses/agent-hub/action-authorization.ts +10 -0
  306. package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-contract.ts +43 -0
  307. package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-evidence.ts +64 -0
  308. package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-hub.ts +55 -0
  309. package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-runtime.ts +56 -0
  310. package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-sources-worker.mjs +4 -0
  311. package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-sources.ts +74 -0
  312. package/.versions/2.2.0/.pi/harnesses/agent-hub/agentic-state.ts +23 -0
  313. package/.versions/2.2.0/.pi/harnesses/agent-hub/approval-wait.ts +1 -0
  314. package/.versions/2.2.0/.pi/harnesses/agent-hub/artifacts.js +146 -0
  315. package/.versions/2.2.0/.pi/harnesses/agent-hub/assertion-ledger.js +68 -0
  316. package/.versions/2.2.0/.pi/harnesses/agent-hub/assist-profile.ts +19 -0
  317. package/.versions/2.2.0/.pi/harnesses/agent-hub/backend-policy.js +174 -0
  318. package/.versions/2.2.0/.pi/harnesses/agent-hub/bounded-output.ts +26 -0
  319. package/.versions/2.2.0/.pi/harnesses/agent-hub/budget-recovery.ts +123 -0
  320. package/.versions/2.2.0/.pi/harnesses/agent-hub/capability-confirmation.ts +47 -0
  321. package/.versions/2.2.0/.pi/harnesses/agent-hub/capability-packs.ts +187 -0
  322. package/.versions/2.2.0/.pi/harnesses/agent-hub/codex-bootstrap.ts +117 -0
  323. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agent-model-thinking.ts +10 -0
  324. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agent-model.ts +10 -0
  325. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agent-models-substitute.ts +10 -0
  326. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-add.ts +9 -0
  327. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-drop.ts +9 -0
  328. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-history.ts +9 -0
  329. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-kill.ts +10 -0
  330. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-list.ts +9 -0
  331. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-restart.ts +10 -0
  332. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-save.ts +9 -0
  333. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/agents-team.ts +9 -0
  334. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/audit.ts +9 -0
  335. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/compound.ts +9 -0
  336. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/coms.ts +9 -0
  337. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/config.ts +9 -0
  338. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/context-command.ts +9 -0
  339. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/context.ts +43 -0
  340. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/debate.ts +9 -0
  341. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/dispatch-policy.ts +9 -0
  342. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/handoff.ts +10 -0
  343. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/hub-report.ts +9 -0
  344. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/models.ts +10 -0
  345. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/poll.ts +9 -0
  346. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/recover.ts +62 -0
  347. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/retry.ts +10 -0
  348. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/task-triage-recover.ts +12 -0
  349. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/task-triage-waive.ts +12 -0
  350. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/watchdog.ts +9 -0
  351. package/.versions/2.2.0/.pi/harnesses/agent-hub/commands/zoom.ts +10 -0
  352. package/.versions/2.2.0/.pi/harnesses/agent-hub/config/agents.ts +183 -0
  353. package/.versions/2.2.0/.pi/harnesses/agent-hub/config/model-profiles.ts +240 -0
  354. package/.versions/2.2.0/.pi/harnesses/agent-hub/config/overrides.ts +166 -0
  355. package/.versions/2.2.0/.pi/harnesses/agent-hub/context/agent-state.ts +30 -0
  356. package/.versions/2.2.0/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +234 -0
  357. package/.versions/2.2.0/.pi/harnesses/agent-hub/context/budgets.ts +152 -0
  358. package/.versions/2.2.0/.pi/harnesses/agent-hub/context/hub-state.ts +40 -0
  359. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-budget-snapshot.ts +105 -0
  360. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-compaction-monitor.ts +35 -0
  361. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-compaction-preflight.ts +21 -0
  362. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-compaction-runtime.ts +69 -0
  363. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-compaction.ts +34 -0
  364. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-broker.ts +44 -0
  365. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-child.ts +83 -0
  366. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-client.ts +22 -0
  367. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-compat.ts +45 -0
  368. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-owners.ts +17 -0
  369. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity-registry.ts +8 -0
  370. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-continuity.ts +82 -0
  371. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-pressure.ts +222 -0
  372. package/.versions/2.2.0/.pi/harnesses/agent-hub/context-window.js +108 -0
  373. package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-approval.ts +83 -0
  374. package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-broker.ts +125 -0
  375. package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-contract.ts +22 -0
  376. package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-descendant.ts +76 -0
  377. package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-hub.ts +263 -0
  378. package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-identity.ts +12 -0
  379. package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-owners.ts +59 -0
  380. package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-state.ts +43 -0
  381. package/.versions/2.2.0/.pi/harnesses/agent-hub/damage-guard-test-tsconfig.json +19 -0
  382. package/.versions/2.2.0/.pi/harnesses/agent-hub/debate-command.ts +176 -0
  383. package/.versions/2.2.0/.pi/harnesses/agent-hub/delegate.ts +478 -0
  384. package/.versions/2.2.0/.pi/harnesses/agent-hub/deterministic-fs.ts +195 -0
  385. package/.versions/2.2.0/.pi/harnesses/agent-hub/diagnostic-probe-extension.ts +26 -0
  386. package/.versions/2.2.0/.pi/harnesses/agent-hub/diagnostic-series-budget.ts +178 -0
  387. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-coms.ts +258 -0
  388. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-core.ts +27 -0
  389. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-native-complete.ts +176 -0
  390. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +318 -0
  391. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +264 -0
  392. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-native-types.ts +297 -0
  393. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-native.ts +242 -0
  394. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-observability.ts +225 -0
  395. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-triage-contract.ts +27 -0
  396. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-triage-eval.ts +77 -0
  397. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-triage-policy.ts +29 -0
  398. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-triage-runtime.ts +55 -0
  399. package/.versions/2.2.0/.pi/harnesses/agent-hub/dispatch-triage-state.ts +33 -0
  400. package/.versions/2.2.0/.pi/harnesses/agent-hub/docs-lane.js +123 -0
  401. package/.versions/2.2.0/.pi/harnesses/agent-hub/drift-judge.ts +352 -0
  402. package/.versions/2.2.0/.pi/harnesses/agent-hub/drift-runtime.ts +480 -0
  403. package/.versions/2.2.0/.pi/harnesses/agent-hub/drift-system1-policy.ts +39 -0
  404. package/.versions/2.2.0/.pi/harnesses/agent-hub/drift-system1.ts +469 -0
  405. package/.versions/2.2.0/.pi/harnesses/agent-hub/drift-watchdog.js +344 -0
  406. package/.versions/2.2.0/.pi/harnesses/agent-hub/evidence-manifest.ts +51 -0
  407. package/.versions/2.2.0/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  408. package/.versions/2.2.0/.pi/harnesses/agent-hub/execution-evidence.ts +96 -0
  409. package/.versions/2.2.0/.pi/harnesses/agent-hub/execution-trace.ts +241 -0
  410. package/.versions/2.2.0/.pi/harnesses/agent-hub/external-blocker.js +92 -0
  411. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/adapters.ts +88 -0
  412. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/broker-client.ts +62 -0
  413. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/broker.ts +128 -0
  414. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/child-extension.ts +42 -0
  415. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/descendant.ts +67 -0
  416. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/discovery-worker.mjs +15 -0
  417. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/discovery.ts +126 -0
  418. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/evaluate.ts +57 -0
  419. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/hub.ts +170 -0
  420. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/native-context.ts +8 -0
  421. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/native-fixture.test-support.ts +108 -0
  422. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/owners.ts +100 -0
  423. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/results.ts +55 -0
  424. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/runtime.ts +130 -0
  425. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/semantic-profiles.ts +18 -0
  426. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/sources.ts +69 -0
  427. package/.versions/2.2.0/.pi/harnesses/agent-hub/file-discovery/state.ts +22 -0
  428. package/.versions/2.2.0/.pi/harnesses/agent-hub/filesystem-tool.ts +166 -0
  429. package/.versions/2.2.0/.pi/harnesses/agent-hub/fixtures/registration-surface.json +68 -0
  430. package/.versions/2.2.0/.pi/harnesses/agent-hub/fixtures/t0a-synthetic/catalog.ts +189 -0
  431. package/.versions/2.2.0/.pi/harnesses/agent-hub/footer.ts +29 -0
  432. package/.versions/2.2.0/.pi/harnesses/agent-hub/helpers.ts +269 -0
  433. package/.versions/2.2.0/.pi/harnesses/agent-hub/history-projection.ts +116 -0
  434. package/.versions/2.2.0/.pi/harnesses/agent-hub/hub-state-audit.js +41 -0
  435. package/.versions/2.2.0/.pi/harnesses/agent-hub/index.ts +2722 -0
  436. package/.versions/2.2.0/.pi/harnesses/agent-hub/input/completions.ts +82 -0
  437. package/.versions/2.2.0/.pi/harnesses/agent-hub/input/shortcuts.ts +16 -0
  438. package/.versions/2.2.0/.pi/harnesses/agent-hub/lifecycle/context-pressure.ts +231 -0
  439. package/.versions/2.2.0/.pi/harnesses/agent-hub/lifecycle/monitor-session.ts +104 -0
  440. package/.versions/2.2.0/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +143 -0
  441. package/.versions/2.2.0/.pi/harnesses/agent-hub/lifecycle/turn-handlers.ts +90 -0
  442. package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  443. package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
  444. package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
  445. package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  446. package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  447. package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  448. package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  449. package/.versions/2.2.0/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
  450. package/.versions/2.2.0/.pi/harnesses/agent-hub/no-progress.ts +627 -0
  451. package/.versions/2.2.0/.pi/harnesses/agent-hub/operator-current-state.ts +57 -0
  452. package/.versions/2.2.0/.pi/harnesses/agent-hub/operator-watchdog.ts +97 -0
  453. package/.versions/2.2.0/.pi/harnesses/agent-hub/orchestration-activation.ts +109 -0
  454. package/.versions/2.2.0/.pi/harnesses/agent-hub/orchestration-metrics.ts +78 -0
  455. package/.versions/2.2.0/.pi/harnesses/agent-hub/orchestration-route.ts +68 -0
  456. package/.versions/2.2.0/.pi/harnesses/agent-hub/package.json +7 -0
  457. package/.versions/2.2.0/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
  458. package/.versions/2.2.0/.pi/harnesses/agent-hub/permission-channel.ts +87 -0
  459. package/.versions/2.2.0/.pi/harnesses/agent-hub/permission-relay.ts +84 -0
  460. package/.versions/2.2.0/.pi/harnesses/agent-hub/policy/models.ts +153 -0
  461. package/.versions/2.2.0/.pi/harnesses/agent-hub/policy/profile-activation.ts +62 -0
  462. package/.versions/2.2.0/.pi/harnesses/agent-hub/policy/profile-runtime.ts +120 -0
  463. package/.versions/2.2.0/.pi/harnesses/agent-hub/policy/roster.ts +103 -0
  464. package/.versions/2.2.0/.pi/harnesses/agent-hub/policy/work-mode.ts +103 -0
  465. package/.versions/2.2.0/.pi/harnesses/agent-hub/poll-command.ts +184 -0
  466. package/.versions/2.2.0/.pi/harnesses/agent-hub/presentation.ts +54 -0
  467. package/.versions/2.2.0/.pi/harnesses/agent-hub/private-config-current-state.ts +81 -0
  468. package/.versions/2.2.0/.pi/harnesses/agent-hub/private-config-fixtures.ts +26 -0
  469. package/.versions/2.2.0/.pi/harnesses/agent-hub/private-config-review.ts +100 -0
  470. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-config.ts +22 -0
  471. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-evaluate.ts +138 -0
  472. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-external-git.ts +82 -0
  473. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-external.ts +142 -0
  474. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-feedback.ts +104 -0
  475. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-findings.ts +115 -0
  476. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-local.ts +89 -0
  477. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-observer.ts +106 -0
  478. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-rules.ts +171 -0
  479. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-runtime.ts +318 -0
  480. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-selection.ts +68 -0
  481. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-snapshot-worker.mjs +12 -0
  482. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-snapshot.ts +287 -0
  483. package/.versions/2.2.0/.pi/harnesses/agent-hub/proactive-types.ts +70 -0
  484. package/.versions/2.2.0/.pi/harnesses/agent-hub/process-obligations.ts +210 -0
  485. package/.versions/2.2.0/.pi/harnesses/agent-hub/prompts/context.ts +72 -0
  486. package/.versions/2.2.0/.pi/harnesses/agent-hub/prompts/fragments.ts +94 -0
  487. package/.versions/2.2.0/.pi/harnesses/agent-hub/prompts/session-start.ts +89 -0
  488. package/.versions/2.2.0/.pi/harnesses/agent-hub/prompts/system-prompt.ts +142 -0
  489. package/.versions/2.2.0/.pi/harnesses/agent-hub/provider-semaphore.js +143 -0
  490. package/.versions/2.2.0/.pi/harnesses/agent-hub/reconcile.ts +26 -0
  491. package/.versions/2.2.0/.pi/harnesses/agent-hub/recover-policy.ts +44 -0
  492. package/.versions/2.2.0/.pi/harnesses/agent-hub/recover-state.ts +104 -0
  493. package/.versions/2.2.0/.pi/harnesses/agent-hub/recovery-contract.ts +151 -0
  494. package/.versions/2.2.0/.pi/harnesses/agent-hub/rerun-policy.ts +40 -0
  495. package/.versions/2.2.0/.pi/harnesses/agent-hub/research/controls.ts +74 -0
  496. package/.versions/2.2.0/.pi/harnesses/agent-hub/research/runtime.ts +215 -0
  497. package/.versions/2.2.0/.pi/harnesses/agent-hub/research/spawn-run.ts +221 -0
  498. package/.versions/2.2.0/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  499. package/.versions/2.2.0/.pi/harnesses/agent-hub/return-contract.js +371 -0
  500. package/.versions/2.2.0/.pi/harnesses/agent-hub/return-extract.js +77 -0
  501. package/.versions/2.2.0/.pi/harnesses/agent-hub/review-closure.ts +43 -0
  502. package/.versions/2.2.0/.pi/harnesses/agent-hub/review-continuity.ts +76 -0
  503. package/.versions/2.2.0/.pi/harnesses/agent-hub/review-findings.js +96 -0
  504. package/.versions/2.2.0/.pi/harnesses/agent-hub/review-reuse.ts +48 -0
  505. package/.versions/2.2.0/.pi/harnesses/agent-hub/review-verdict.ts +6 -0
  506. package/.versions/2.2.0/.pi/harnesses/agent-hub/routing-observation.ts +41 -0
  507. package/.versions/2.2.0/.pi/harnesses/agent-hub/routing-proposal.ts +46 -0
  508. package/.versions/2.2.0/.pi/harnesses/agent-hub/run-budget.js +362 -0
  509. package/.versions/2.2.0/.pi/harnesses/agent-hub/run-namespace.js +93 -0
  510. package/.versions/2.2.0/.pi/harnesses/agent-hub/runtime-receipts.ts +63 -0
  511. package/.versions/2.2.0/.pi/harnesses/agent-hub/runtime-test-check.ts +85 -0
  512. package/.versions/2.2.0/.pi/harnesses/agent-hub/safety-routing.ts +28 -0
  513. package/.versions/2.2.0/.pi/harnesses/agent-hub/scope-gate.js +271 -0
  514. package/.versions/2.2.0/.pi/harnesses/agent-hub/scope-overlap.ts +46 -0
  515. package/.versions/2.2.0/.pi/harnesses/agent-hub/session-audit.ts +331 -0
  516. package/.versions/2.2.0/.pi/harnesses/agent-hub/session-health.js +110 -0
  517. package/.versions/2.2.0/.pi/harnesses/agent-hub/session-start.ts +42 -0
  518. package/.versions/2.2.0/.pi/harnesses/agent-hub/spawn.ts +702 -0
  519. package/.versions/2.2.0/.pi/harnesses/agent-hub/specialist-result-receipt.ts +13 -0
  520. package/.versions/2.2.0/.pi/harnesses/agent-hub/specialist-result.ts +78 -0
  521. package/.versions/2.2.0/.pi/harnesses/agent-hub/system1-activity.ts +625 -0
  522. package/.versions/2.2.0/.pi/harnesses/agent-hub/system1-communication-store.ts +225 -0
  523. package/.versions/2.2.0/.pi/harnesses/agent-hub/system1-report.ts +275 -0
  524. package/.versions/2.2.0/.pi/harnesses/agent-hub/system1-runtime.ts +271 -0
  525. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-brief.ts +98 -0
  526. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-continuation.ts +4 -0
  527. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-resume-contract.ts +80 -0
  528. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-authorization.ts +170 -0
  529. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-config.ts +21 -0
  530. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-contract.ts +14 -0
  531. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-live-stage-boundary.mjs +49 -0
  532. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-obligations.ts +120 -0
  533. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-policy.ts +16 -0
  534. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-review-contract.mjs +43 -0
  535. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-reviewer-only-contract.mjs +156 -0
  536. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-reviewer-only-diagnostics.mjs +112 -0
  537. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-runtime.ts +130 -0
  538. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-stage-guard.ts +21 -0
  539. package/.versions/2.2.0/.pi/harnesses/agent-hub/task-triage-state.ts +46 -0
  540. package/.versions/2.2.0/.pi/harnesses/agent-hub/timeline.ts +72 -0
  541. package/.versions/2.2.0/.pi/harnesses/agent-hub/tool-catalog-runtime.ts +83 -0
  542. package/.versions/2.2.0/.pi/harnesses/agent-hub/tool-catalog-state.ts +125 -0
  543. package/.versions/2.2.0/.pi/harnesses/agent-hub/tool-protocol.ts +134 -0
  544. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/action-executors.ts +214 -0
  545. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/ask-system1-files.ts +15 -0
  546. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/ask-system1.ts +25 -0
  547. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/coms-tools.ts +139 -0
  548. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/context.ts +149 -0
  549. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +93 -0
  550. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +928 -0
  551. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/dispatch-triage.ts +16 -0
  552. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/execution-orchestration.ts +22 -0
  553. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/fleet-tools.ts +201 -0
  554. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/herdr-executors.ts +100 -0
  555. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/poll-panel-core.ts +30 -0
  556. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/poll-panel.ts +33 -0
  557. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/run-flow.ts +177 -0
  558. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/set-task-tier.ts +31 -0
  559. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/spawn-research.ts +67 -0
  560. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/team-adjust.ts +29 -0
  561. package/.versions/2.2.0/.pi/harnesses/agent-hub/tools/verification-contract.ts +81 -0
  562. package/.versions/2.2.0/.pi/harnesses/agent-hub/tsconfig.json +22 -0
  563. package/.versions/2.2.0/.pi/harnesses/agent-hub/types.ts +66 -0
  564. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/activity-dots.ts +25 -0
  565. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/context-budget.ts +89 -0
  566. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/detail-panel.ts +192 -0
  567. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/fleet-actions.ts +78 -0
  568. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +173 -0
  569. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/fleet-editor.ts +44 -0
  570. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/fleet-source.ts +179 -0
  571. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/grid.ts +159 -0
  572. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/history-store.ts +137 -0
  573. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/history.ts +234 -0
  574. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/pool.ts +103 -0
  575. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/running-strip.ts +2 -0
  576. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/system1-communication.ts +59 -0
  577. package/.versions/2.2.0/.pi/harnesses/agent-hub/ui/zoom.ts +206 -0
  578. package/.versions/2.2.0/.pi/harnesses/agent-hub/unknown-tool-counter.ts +116 -0
  579. package/.versions/2.2.0/.pi/harnesses/agent-hub/version.ts +42 -0
  580. package/.versions/2.2.0/.pi/harnesses/agent-hub/watchdog-evaluation.ts +110 -0
  581. package/.versions/2.2.0/.pi/harnesses/agent-hub/work-mode.ts +183 -0
  582. package/.versions/2.2.0/.pi/harnesses/agent-hub/write-isolation.ts +232 -0
  583. package/.versions/2.2.0/.pi/harnesses/ask-user-remote/README.md +59 -0
  584. package/.versions/2.2.0/.pi/harnesses/ask-user-remote/index.ts +571 -0
  585. package/.versions/2.2.0/.pi/harnesses/ask-user-remote/questions.ts +206 -0
  586. package/.versions/2.2.0/.pi/harnesses/ask-user-remote/race-core.js +124 -0
  587. package/.versions/2.2.0/.pi/harnesses/ask-user-remote/runtime-ask.ts +90 -0
  588. package/.versions/2.2.0/.pi/harnesses/coms/README.md +105 -0
  589. package/.versions/2.2.0/.pi/harnesses/coms/index.ts +308 -0
  590. package/.versions/2.2.0/.pi/harnesses/coms/package.json +7 -0
  591. package/.versions/2.2.0/.pi/harnesses/coms/version.ts +42 -0
  592. package/.versions/2.2.0/.pi/harnesses/damage-control-continue/README.md +161 -0
  593. package/.versions/2.2.0/.pi/harnesses/damage-control-continue/index.ts +659 -0
  594. package/.versions/2.2.0/.pi/harnesses/damage-control-continue/package.json +7 -0
  595. package/.versions/2.2.0/.pi/harnesses/damage-control-continue/result-screen.ts +98 -0
  596. package/.versions/2.2.0/.pi/harnesses/damage-control-continue/system1-child.ts +45 -0
  597. package/.versions/2.2.0/.pi/harnesses/damage-control-continue/system1-client.ts +85 -0
  598. package/.versions/2.2.0/.pi/harnesses/damage-control-continue/system1-guard.ts +65 -0
  599. package/.versions/2.2.0/.pi/harnesses/damage-control-continue/version.ts +42 -0
  600. package/.versions/2.2.0/.pi/harnesses/lib/approval-wait.ts +17 -0
  601. package/.versions/2.2.0/.pi/harnesses/lib/bash-policy-analysis.ts +185 -0
  602. package/.versions/2.2.0/.pi/harnesses/lib/changed-file-diagnostics.ts +642 -0
  603. package/.versions/2.2.0/.pi/harnesses/lib/clarification-policy.ts +9 -0
  604. package/.versions/2.2.0/.pi/harnesses/lib/codex-compat.ts +97 -0
  605. package/.versions/2.2.0/.pi/harnesses/lib/codex-contract.ts +259 -0
  606. package/.versions/2.2.0/.pi/harnesses/lib/codex-notification-profile.ts +75 -0
  607. package/.versions/2.2.0/.pi/harnesses/lib/coms-core-io.ts +422 -0
  608. package/.versions/2.2.0/.pi/harnesses/lib/coms-core.ts +738 -0
  609. package/.versions/2.2.0/.pi/harnesses/lib/coms-instruction-receipts.ts +113 -0
  610. package/.versions/2.2.0/.pi/harnesses/lib/coms-observation.ts +74 -0
  611. package/.versions/2.2.0/.pi/harnesses/lib/coms-registry-entry.ts +99 -0
  612. package/.versions/2.2.0/.pi/harnesses/lib/coms-response-read.ts +107 -0
  613. package/.versions/2.2.0/.pi/harnesses/lib/context-budget-child-prompt.ts +214 -0
  614. package/.versions/2.2.0/.pi/harnesses/lib/context-budget-hub-prompt.ts +124 -0
  615. package/.versions/2.2.0/.pi/harnesses/lib/context-budget-view.ts +112 -0
  616. package/.versions/2.2.0/.pi/harnesses/lib/context-budget.ts +114 -0
  617. package/.versions/2.2.0/.pi/harnesses/lib/context-compaction-policy.js +35 -0
  618. package/.versions/2.2.0/.pi/harnesses/lib/damage-action-hash.ts +28 -0
  619. package/.versions/2.2.0/.pi/harnesses/lib/damage-auto-policy.ts +52 -0
  620. package/.versions/2.2.0/.pi/harnesses/lib/damage-control-presentation.ts +14 -0
  621. package/.versions/2.2.0/.pi/harnesses/lib/damage-control-shared.ts +276 -0
  622. package/.versions/2.2.0/.pi/harnesses/lib/damage-guard-port.ts +25 -0
  623. package/.versions/2.2.0/.pi/harnesses/lib/damage-policy.ts +35 -0
  624. package/.versions/2.2.0/.pi/harnesses/lib/damage-result-evidence.ts +25 -0
  625. package/.versions/2.2.0/.pi/harnesses/lib/damage-result-view.ts +16 -0
  626. package/.versions/2.2.0/.pi/harnesses/lib/deterministic-handle-path.ts +25 -0
  627. package/.versions/2.2.0/.pi/harnesses/lib/exact-permission-port.ts +38 -0
  628. package/.versions/2.2.0/.pi/harnesses/lib/execution-trace.ts +45 -0
  629. package/.versions/2.2.0/.pi/harnesses/lib/fixtures/context-budget-profiles.json +11 -0
  630. package/.versions/2.2.0/.pi/harnesses/lib/fixtures/hub-prompt-operator.legacy.txt +73 -0
  631. package/.versions/2.2.0/.pi/harnesses/lib/fixtures/hub-prompt-orchestrator.legacy.txt +73 -0
  632. package/.versions/2.2.0/.pi/harnesses/lib/fleet-bootstrap-channel.ts +148 -0
  633. package/.versions/2.2.0/.pi/harnesses/lib/fleet-codex-catalog.ts +30 -0
  634. package/.versions/2.2.0/.pi/harnesses/lib/fleet-codex-chat-view.ts +43 -0
  635. package/.versions/2.2.0/.pi/harnesses/lib/fleet-codex-event-bridge.ts +82 -0
  636. package/.versions/2.2.0/.pi/harnesses/lib/fleet-codex-namespace.ts +2 -0
  637. package/.versions/2.2.0/.pi/harnesses/lib/fleet-codex-policy-snapshot.ts +10 -0
  638. package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/cli-bridge.ts +111 -0
  639. package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/mutations.ts +201 -0
  640. package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/snapshot.ts +417 -0
  641. package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/transition.ts +68 -0
  642. package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/ui.ts +269 -0
  643. package/.versions/2.2.0/.pi/harnesses/lib/fleet-config/view.ts +338 -0
  644. package/.versions/2.2.0/.pi/harnesses/lib/fleet-connection-control.ts +94 -0
  645. package/.versions/2.2.0/.pi/harnesses/lib/fleet-dashboard-ops.ts +178 -0
  646. package/.versions/2.2.0/.pi/harnesses/lib/fleet-dashboard-view.ts +174 -0
  647. package/.versions/2.2.0/.pi/harnesses/lib/fleet-detail-view.ts +339 -0
  648. package/.versions/2.2.0/.pi/harnesses/lib/fleet-event-source.ts +21 -0
  649. package/.versions/2.2.0/.pi/harnesses/lib/fleet-notification-admission.ts +32 -0
  650. package/.versions/2.2.0/.pi/harnesses/lib/fleet-notification-bootstrap.ts +152 -0
  651. package/.versions/2.2.0/.pi/harnesses/lib/fleet-notification-validation.ts +122 -0
  652. package/.versions/2.2.0/.pi/harnesses/lib/fleet-overlay.ts +26 -0
  653. package/.versions/2.2.0/.pi/harnesses/lib/fleet-panel.ts +34 -0
  654. package/.versions/2.2.0/.pi/harnesses/lib/fleet-question-reference.ts +42 -0
  655. package/.versions/2.2.0/.pi/harnesses/lib/fleet-read-model.ts +609 -0
  656. package/.versions/2.2.0/.pi/harnesses/lib/fleet-selection.ts +24 -0
  657. package/.versions/2.2.0/.pi/harnesses/lib/fleet-strip-controller.ts +75 -0
  658. package/.versions/2.2.0/.pi/harnesses/lib/fleet-strip-view.ts +179 -0
  659. package/.versions/2.2.0/.pi/harnesses/lib/fleet-target-identity.ts +9 -0
  660. package/.versions/2.2.0/.pi/harnesses/lib/fleet-transcript-store.ts +244 -0
  661. package/.versions/2.2.0/.pi/harnesses/lib/herdr-client.ts +472 -0
  662. package/.versions/2.2.0/.pi/harnesses/lib/herdr-presence.ts +399 -0
  663. package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
  664. package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
  665. package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
  666. package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
  667. package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
  668. package/.versions/2.2.0/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
  669. package/.versions/2.2.0/.pi/harnesses/lib/identical-dialog.ts +27 -0
  670. package/.versions/2.2.0/.pi/harnesses/lib/installation-state.js +62 -0
  671. package/.versions/2.2.0/.pi/harnesses/lib/peer-target.ts +24 -0
  672. package/.versions/2.2.0/.pi/harnesses/lib/policy-roots.js +117 -0
  673. package/.versions/2.2.0/.pi/harnesses/lib/policy-roots.ts +32 -0
  674. package/.versions/2.2.0/.pi/harnesses/lib/process-shared.ts +9 -0
  675. package/.versions/2.2.0/.pi/harnesses/lib/resource-closure.js +26 -0
  676. package/.versions/2.2.0/.pi/harnesses/lib/safe-source-read.js +29 -0
  677. package/.versions/2.2.0/.pi/harnesses/lib/semantic-approval.ts +80 -0
  678. package/.versions/2.2.0/.pi/harnesses/lib/session-target.ts +62 -0
  679. package/.versions/2.2.0/.pi/harnesses/lib/spawned-peers.js +191 -0
  680. package/.versions/2.2.0/.pi/harnesses/lib/system1/config-agentic.js +15 -0
  681. package/.versions/2.2.0/.pi/harnesses/lib/system1/config-context-compaction.js +16 -0
  682. package/.versions/2.2.0/.pi/harnesses/lib/system1/config-damage-guard.js +24 -0
  683. package/.versions/2.2.0/.pi/harnesses/lib/system1/config-file-discovery.js +23 -0
  684. package/.versions/2.2.0/.pi/harnesses/lib/system1/config-json.js +37 -0
  685. package/.versions/2.2.0/.pi/harnesses/lib/system1/config-loader.js +53 -0
  686. package/.versions/2.2.0/.pi/harnesses/lib/system1/config-proactive.js +68 -0
  687. package/.versions/2.2.0/.pi/harnesses/lib/system1/config-triage.js +42 -0
  688. package/.versions/2.2.0/.pi/harnesses/lib/system1/config-v2.js +112 -0
  689. package/.versions/2.2.0/.pi/harnesses/lib/system1/config.js +50 -0
  690. package/.versions/2.2.0/.pi/harnesses/lib/system1/contracts.ts +154 -0
  691. package/.versions/2.2.0/.pi/harnesses/lib/system1/demo.ts +95 -0
  692. package/.versions/2.2.0/.pi/harnesses/lib/system1/jev.ts +503 -0
  693. package/.versions/2.2.0/.pi/harnesses/lib/system1/payload-screen.ts +65 -0
  694. package/.versions/2.2.0/.pi/harnesses/lib/system1/selection.js +11 -0
  695. package/.versions/2.2.0/.pi/harnesses/lib/system1/service.ts +245 -0
  696. package/.versions/2.2.0/.pi/harnesses/lib/system1/worktree-scopes.js +110 -0
  697. package/.versions/2.2.0/.pi/harnesses/lib/system1/worktree-scopes.ts +13 -0
  698. package/.versions/2.2.0/.pi/harnesses/lib/system1/worktree-service.ts +24 -0
  699. package/.versions/2.2.0/.pi/harnesses/lib/target-capabilities.js +7 -0
  700. package/.versions/2.2.0/.pi/harnesses/lib/update-check.ts +227 -0
  701. package/.versions/2.2.0/.pi/harnesses/lib/workspace-context.js +115 -0
  702. package/.versions/2.2.0/.pi/harnesses/lib/workspace-context.ts +22 -0
  703. package/.versions/2.2.0/.pi/harnesses/package-lock.json +2121 -0
  704. package/.versions/2.2.0/.pi/harnesses/package.json +13 -0
  705. package/.versions/2.2.0/.pi/prompts/af-build.md +27 -0
  706. package/.versions/2.2.0/.pi/prompts/af-code-simplify.md +22 -0
  707. package/.versions/2.2.0/.pi/prompts/af-constraints.md +31 -0
  708. package/.versions/2.2.0/.pi/prompts/af-plan.md +17 -0
  709. package/.versions/2.2.0/.pi/prompts/af-review.md +16 -0
  710. package/.versions/2.2.0/.pi/prompts/af-set-hermes-telegram.md +15 -0
  711. package/.versions/2.2.0/.pi/prompts/af-set-hermes-watchdog.md +6 -0
  712. package/.versions/2.2.0/.pi/prompts/af-setup-rules.md +20 -0
  713. package/.versions/2.2.0/.pi/prompts/af-ship.md +17 -0
  714. package/.versions/2.2.0/.pi/prompts/af-spec.md +15 -0
  715. package/.versions/2.2.0/.pi/prompts/af-test.md +19 -0
  716. package/.versions/2.2.0/.pi/skills/bowser/SKILL.md +145 -0
  717. package/.versions/2.2.0/.version +1 -0
  718. package/.versions/2.2.0/agents/architect.md +24 -0
  719. package/.versions/2.2.0/agents/bowser.md +28 -0
  720. package/.versions/2.2.0/agents/builder.md +55 -0
  721. package/.versions/2.2.0/agents/code-reviewer.md +209 -0
  722. package/.versions/2.2.0/agents/deep-researcher.md +32 -0
  723. package/.versions/2.2.0/agents/documenter.md +22 -0
  724. package/.versions/2.2.0/agents/plan-reviewer.md +83 -0
  725. package/.versions/2.2.0/agents/planner.md +107 -0
  726. package/.versions/2.2.0/agents/releaser.md +24 -0
  727. package/.versions/2.2.0/agents/researcher.md +30 -0
  728. package/.versions/2.2.0/agents/security-auditor.md +167 -0
  729. package/.versions/2.2.0/agents/test-engineer.md +153 -0
  730. package/.versions/2.2.0/agents/web-debugger.md +44 -0
  731. package/.versions/2.2.0/agents/web-performance-auditor.md +194 -0
  732. package/.versions/2.2.0/bin/catalog/harness-runtime-closure.json +85 -0
  733. package/.versions/2.2.0/docs/ARCHITECTURE.md +1291 -0
  734. package/.versions/2.2.0/docs/agent-fleet-setup.md +1161 -0
  735. package/.versions/2.2.0/docs/claude-code-coms-bridge.md +147 -0
  736. package/.versions/2.2.0/docs/codex-local-mcp.md +520 -0
  737. package/.versions/2.2.0/docs/codex-session-bridge.md +44 -0
  738. package/.versions/2.2.0/docs/codex-setup.md +183 -0
  739. package/.versions/2.2.0/docs/coms-hermes-bridge.md +188 -0
  740. package/.versions/2.2.0/docs/fleet-native-voice.md +151 -0
  741. package/.versions/2.2.0/docs/getting-started.md +126 -0
  742. package/.versions/2.2.0/docs/npm-install.md +535 -0
  743. package/.versions/2.2.0/docs/pi-extensions.md +450 -0
  744. package/.versions/2.2.0/docs/pi-setup.md +92 -0
  745. package/.versions/2.2.0/docs/skill-anatomy.md +150 -0
  746. package/.versions/2.2.0/install-manifest.json +3226 -0
  747. package/.versions/2.2.0/justfile +246 -0
  748. package/.versions/2.2.0/manifest-meta.json +1098 -0
  749. package/.versions/2.2.0/references/accessibility-checklist.md +160 -0
  750. package/.versions/2.2.0/references/communication-contract.md +26 -0
  751. package/.versions/2.2.0/references/definition-of-done.md +67 -0
  752. package/.versions/2.2.0/references/fleet-coordination-patterns.md +171 -0
  753. package/.versions/2.2.0/references/observability-checklist.md +92 -0
  754. package/.versions/2.2.0/references/orchestration-patterns.md +370 -0
  755. package/.versions/2.2.0/references/performance-checklist.md +236 -0
  756. package/.versions/2.2.0/references/prompting-patterns.md +380 -0
  757. package/.versions/2.2.0/references/security-checklist.md +245 -0
  758. package/.versions/2.2.0/references/testing-patterns.md +235 -0
  759. package/.versions/2.2.0/references/workflow-authoring.md +304 -0
  760. package/.versions/2.2.0/skills/_internal/grilling.md +59 -0
  761. package/.versions/2.2.0/skills/browser-testing-with-devtools/SKILL.md +351 -0
  762. package/.versions/2.2.0/skills/code-review-and-quality/SKILL.md +396 -0
  763. package/.versions/2.2.0/skills/compound-learning/SKILL.md +137 -0
  764. package/.versions/2.2.0/skills/constraint-driven-development/SKILL.md +338 -0
  765. package/.versions/2.2.0/skills/constraint-driven-development/references/floor-guard.md +99 -0
  766. package/.versions/2.2.0/skills/context-engineering/SKILL.md +341 -0
  767. package/.versions/2.2.0/skills/deprecation-and-migration/SKILL.md +247 -0
  768. package/.versions/2.2.0/skills/designing-agents/SKILL.md +394 -0
  769. package/.versions/2.2.0/skills/designing-agents/pi-harness-authoring.md +222 -0
  770. package/.versions/2.2.0/skills/drafting-workflows/SKILL.md +143 -0
  771. package/.versions/2.2.0/skills/drafting-workflows/scripts/make-workflow.ts +177 -0
  772. package/.versions/2.2.0/skills/fleet-connect/SKILL.md +29 -0
  773. package/.versions/2.2.0/skills/fleet-connect.zip +0 -0
  774. package/.versions/2.2.0/skills/fleet-native-voice/SKILL.md +103 -0
  775. package/.versions/2.2.0/skills/fleet-native-voice/agents/openai.yaml +4 -0
  776. package/.versions/2.2.0/skills/fleet-native-voice.zip +0 -0
  777. package/.versions/2.2.0/skills/frontend-ui-engineering/SKILL.md +328 -0
  778. package/.versions/2.2.0/skills/git-workflow-and-versioning/SKILL.md +316 -0
  779. package/.versions/2.2.0/skills/idea-refine/SKILL.md +182 -0
  780. package/.versions/2.2.0/skills/idea-refine/examples.md +238 -0
  781. package/.versions/2.2.0/skills/idea-refine/frameworks.md +99 -0
  782. package/.versions/2.2.0/skills/idea-refine/refinement-criteria.md +113 -0
  783. package/.versions/2.2.0/skills/idea-refine/scripts/idea-refine.sh +15 -0
  784. package/.versions/2.2.0/skills/incremental-implementation/SKILL.md +353 -0
  785. package/.versions/2.2.0/skills/incremental-implementation.zip +0 -0
  786. package/.versions/2.2.0/skills/interview-me/SKILL.md +226 -0
  787. package/.versions/2.2.0/skills/orchestration-verification/SKILL.md +182 -0
  788. package/.versions/2.2.0/skills/peer-coms/SKILL.md +90 -0
  789. package/.versions/2.2.0/skills/performance-optimization/SKILL.md +496 -0
  790. package/.versions/2.2.0/skills/planning-and-task-breakdown/SKILL.md +318 -0
  791. package/.versions/2.2.0/skills/planning-and-task-breakdown.zip +0 -0
  792. package/.versions/2.2.0/skills/repository-ai-setup/SKILL.md +135 -0
  793. package/.versions/2.2.0/skills/repository-ai-setup/references/agent-fleet-ai-state.template.json +4 -0
  794. package/.versions/2.2.0/skills/repository-ai-setup/references/apply-contract.md +74 -0
  795. package/.versions/2.2.0/skills/repository-ai-setup/references/provenance-template.md +16 -0
  796. package/.versions/2.2.0/skills/repository-ai-setup/references/setup-flow.md +108 -0
  797. package/.versions/2.2.0/skills/repository-ai-setup/references/verify-setup.md +20 -0
  798. package/.versions/2.2.0/skills/repository-ai-setup.zip +0 -0
  799. package/.versions/2.2.0/skills/security-and-hardening/SKILL.md +524 -0
  800. package/.versions/2.2.0/skills/spec-driven-development/SKILL.md +295 -0
  801. package/.versions/2.2.0/skills/spec-driven-development.zip +0 -0
  802. package/.versions/2.2.0/skills/using-agent-skills/SKILL.md +198 -0
  803. package/.versions/2.2.0/vendor/agent-skills-upstream/LICENSE +21 -0
  804. package/.versions/2.2.0/vendor/agent-skills-upstream/README.md +430 -0
  805. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +367 -0
  806. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  807. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  808. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  809. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  810. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/constraint-driven-development/SKILL.md +311 -0
  811. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/constraint-driven-development/references/floor-guard.md +99 -0
  812. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +337 -0
  813. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  814. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  815. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +288 -0
  816. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  817. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  818. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  819. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  820. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  821. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  822. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  823. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  824. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  825. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  826. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +238 -0
  827. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +496 -0
  828. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +257 -0
  829. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +524 -0
  830. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +330 -0
  831. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +216 -0
  832. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +245 -0
  833. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +398 -0
  834. package/.versions/2.2.0/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +192 -0
  835. package/CHANGELOG.md +33 -0
  836. package/README.md +7 -10
  837. package/bin/lib/set-codex-mcp.js +1 -1
  838. package/bin/lib/validate-overrides.js +8 -1
  839. package/docs/ARCHITECTURE.md +122 -26
  840. package/docs/MIGRATION-agent-fleet.md +26 -5
  841. package/docs/agent-fleet-setup.md +44 -26
  842. package/docs/claude-code-coms-bridge.md +1 -1
  843. package/docs/codex-local-mcp.md +29 -12
  844. package/docs/codex-session-bridge.md +2 -2
  845. package/docs/codex-setup.md +1 -1
  846. package/docs/fleet-native-voice.md +10 -4
  847. package/docs/npm-install.md +1 -1
  848. package/docs/pi-extensions.md +13 -18
  849. package/docs/system1-agentic.md +1 -1
  850. package/docs/system1-file-discovery.md +2 -2
  851. package/docs/workflows.md +24 -1
  852. package/install-manifest.json +15 -28
  853. package/justfile +3 -4
  854. package/manifest-meta.json +13 -2
  855. package/package.json +4 -2
  856. package/skills/fleet-connect/SKILL.md +20 -16
  857. package/skills/fleet-connect.zip +0 -0
  858. package/skills/fleet-native-voice.zip +0 -0
  859. package/.pi/harnesses/agent-hub/commands/work-mode.ts +0 -29
  860. package/.pi/harnesses/agent-hub/work-mode-controls.ts +0 -56
  861. package/agents/orchestrator.md +0 -22
@@ -0,0 +1,738 @@
1
+ import {publishFleetSourceEvent,fleetSourceDigest} from './fleet-event-source.ts';
2
+ import {SessionResponseReader} from './coms-response-read.ts';
3
+ import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
4
+ import { instructionReceipt, ownerOf, sameOwner, validateInstructionTag } from './coms-instruction-receipts.ts';
5
+ import * as fs from "node:fs";
6
+ import {sessionRootsFromEnv,projectForSession} from './workspace-context.ts';
7
+ import * as net from "node:net";
8
+ import * as path from "node:path";
9
+
10
+ import { buildLiveRegistryEntry } from "./coms-registry-entry.ts";
11
+ import {
12
+ HerdrAgentWatch,
13
+ HerdrPresence,
14
+ herdrPaneId,
15
+ herdrPresenceAvailable,
16
+ peerNameFrom,
17
+ type HerdrAgentInfo,
18
+ } from "./herdr-presence.ts";
19
+ import {
20
+ COMS_DIR,
21
+ KEEPALIVE_INTERVAL_MS,
22
+ LINE_CAP_BYTES,
23
+ MAX_HOPS,
24
+ PING_INTERVAL_MS,
25
+ TIMEOUT_MS,
26
+ bindEndpoint,
27
+ derivePeerStatus,
28
+ fallbackColor,
29
+ isValidHex,
30
+ listProjects,
31
+ makeEndpoint,
32
+ nextInboundForDispatch,
33
+ nowIso,
34
+ projectAgentsDir,
35
+ pruneDeadEntries,
36
+ pruneDeadEntriesAllProjects,
37
+ readCliFlags,
38
+ readFrontmatterFromArgv,
39
+ removeRegistryEntry,
40
+ resolveUniqueName,
41
+ sendEnvelope,
42
+ ulid,
43
+ writeRegistryAtomic,
44
+ type AgentCard,
45
+ type ComsIdentity,
46
+ type ComsTurnState,
47
+ type InboundContext,
48
+ type PendingReply,
49
+ type PeerStatus,
50
+ type PingEnvelope,
51
+ type Pong,
52
+ type PromptEnvelope,
53
+ type RegistryEntry,
54
+ type ResponseEnvelope,
55
+ } from "./coms-core-io.ts";
56
+
57
+ export * from "./coms-core-io.ts";
58
+
59
+ export interface ComsListParams {
60
+ project?: string;
61
+ include_explicit?: boolean;
62
+ }
63
+
64
+ export interface ComsSendParams {
65
+ target: string;
66
+ prompt: string;
67
+ conversation_id?: string | null;
68
+ response_schema?: object | null;
69
+ reply_timeout_ms?: number | null;
70
+ }
71
+
72
+ export interface ComsSendResult {
73
+ msg_id: string;
74
+ target: string;
75
+ target_session: string;
76
+ hops: number;
77
+ promise: PendingReply["promise"];
78
+ }
79
+
80
+ export interface ComsListResult {
81
+ agents: Array<{
82
+ name: string;
83
+ session_id: string;
84
+ purpose: string;
85
+ model: string;
86
+ cwd: string;
87
+ project: string;
88
+ alive: boolean;
89
+ context_used_pct: number | null;
90
+ pane_id: string | null;
91
+ status: PeerStatus | null;
92
+ queue_depth: number | null;
93
+ color: string;
94
+ }>;
95
+ project: string;
96
+ scoped: true;
97
+ widenRequested: boolean;
98
+ }
99
+
100
+ export interface CreateComsPeerDeps {
101
+ pi: ExtensionAPI;
102
+ getContext: () => ExtensionContext | null;
103
+ onPeersChanged?: () => void;
104
+ acceptInbound?: () => string | null;
105
+ instructionReceipts?: boolean;
106
+ handleCustomEnvelope?: (socket: net.Socket, envelope: any) => boolean;
107
+ /** A true result transfers the socket and untouched trailing bytes to the
108
+ * trusted handler. Ordinary COMS envelopes remain one-shot. */
109
+ handleCustomStream?: (socket: net.Socket, envelope: any, buffered: Buffer) => boolean;
110
+ }
111
+
112
+ export interface ConnectComsOptions {
113
+ ctx: ExtensionContext;
114
+ defaultNamePrefix: string;
115
+ defaultPurpose: string;
116
+ }
117
+
118
+ export type ComsConnectStage = "dirs" | "bind" | "registry";
119
+
120
+ export class ComsConnectError extends Error {
121
+ readonly stage: ComsConnectStage;
122
+
123
+ constructor(stage: ComsConnectStage, cause: unknown) {
124
+ super(cause instanceof Error ? cause.message : String(cause), { cause });
125
+ this.name = "ComsConnectError";
126
+ this.stage = stage;
127
+ }
128
+ }
129
+
130
+ export function createComsPeer(deps: CreateComsPeerDeps) {
131
+ const { pi } = deps;
132
+ const peerCards = new Map<string, AgentCard & { staleCount: number }>();
133
+ const pendingReplies = new Map<string, PendingReply>();
134
+ const inboundQueue = new Map<string, InboundContext>();
135
+ const responses = new SessionResponseReader();
136
+ const scope = { includeExplicit: false, displayProject: null as string | null };
137
+ let identity: ComsIdentity | null = null;
138
+ let currentInbound: InboundContext | null = null;
139
+ let server: net.Server | null = null;
140
+ let pingTimer: NodeJS.Timeout | null = null;
141
+ let keepaliveTimer: NodeJS.Timeout | null = null;
142
+ let herdrPresence: HerdrPresence | null = null;
143
+ let herdrWatch: HerdrAgentWatch | null = null;
144
+ let turnState: ComsTurnState = "idle";
145
+ let dispatchPaused = false;
146
+ let shuttingDown = false;
147
+
148
+ const changed = () => deps.onPeersChanged?.();
149
+ const audit = (entry: Record<string, unknown>) => {
150
+ try { pi.appendEntry("coms-log", entry); } catch { /* best effort */ }
151
+ };
152
+ const ack = (socket: net.Socket, msgId: string) => {
153
+ try { socket.write(`${JSON.stringify({ type: "ack", msg_id: msgId })}\n`); } catch { /* ignore */ }
154
+ try { socket.end(); } catch { /* ignore */ }
155
+ };
156
+ const nack = (socket: net.Socket, msgId: string, error: string) => {
157
+ try { socket.write(`${JSON.stringify({ type: "nack", msg_id: msgId, error })}\n`); } catch { /* ignore */ }
158
+ try { socket.end(); } catch { /* ignore */ }
159
+ };
160
+
161
+ function peersInScope(): RegistryEntry[] {
162
+ if (!identity) return [];
163
+ const filter = scope.displayProject ?? identity.project;
164
+ const entries = filter === "*" ? pruneDeadEntriesAllProjects() : pruneDeadEntries(filter);
165
+ return entries.filter(entry => entry.session_id !== identity!.session_id && (scope.includeExplicit || !entry.explicit));
166
+ }
167
+
168
+ function resolveTarget(target: string): RegistryEntry | null {
169
+ const entries = peersInScope();
170
+ return entries.find(entry => entry.name === target) ?? entries.find(entry => entry.session_id === target) ?? null;
171
+ }
172
+
173
+ function herdrSyncPeerCards(agents: HerdrAgentInfo[]): void {
174
+ if (!identity) return;
175
+ const liveNames = new Set(agents.map(peerNameFrom).filter((name): name is string => !!name));
176
+ const liveSessions = new Set<string>();
177
+ let didChange = false;
178
+ for (const entry of peersInScope()) {
179
+ if (!liveNames.has(entry.name)) continue;
180
+ liveSessions.add(entry.session_id);
181
+ const next = {
182
+ name: entry.name, purpose: entry.purpose, model: entry.model, color: entry.color,
183
+ context_used_pct: entry.context_measurement === "measured" ? entry.context_used_pct ?? null : null, context_measurement:entry.context_measurement??"unknown", queue_depth: entry.queue_depth ?? 0, staleCount: 0,
184
+ };
185
+ const previous = peerCards.get(entry.session_id);
186
+ if (!previous || JSON.stringify(previous) !== JSON.stringify(next)) {
187
+ peerCards.set(entry.session_id, next);
188
+ didChange = true;
189
+ }
190
+ }
191
+ for (const sessionId of [...peerCards.keys()]) {
192
+ if (sessionId !== identity.session_id && !liveSessions.has(sessionId)) {
193
+ peerCards.delete(sessionId);
194
+ didChange = true;
195
+ }
196
+ }
197
+ if (didChange) changed();
198
+ }
199
+
200
+ function waitingInboundCount(): number {
201
+ let count = 0;
202
+ for (const queued of inboundQueue.values()) {
203
+ if (!queued.fulfilled && queued !== currentInbound) count += 1;
204
+ }
205
+ return count;
206
+ }
207
+
208
+ function peerStatus(): PeerStatus {
209
+ return derivePeerStatus(turnState, waitingInboundCount(), currentInbound !== null);
210
+ }
211
+
212
+ function instructionCapability() {
213
+ const manager = deps.getContext()?.sessionManager;
214
+ return deps.instructionReceipts && identity && typeof pi.appendEntry === 'function'
215
+ && typeof manager?.getLeafId === 'function' && typeof manager?.getEntry === 'function'
216
+ ? { version: 1 as const, owner: ownerOf(identity) } : undefined;
217
+ }
218
+ function terminalFor(inbound: InboundContext, response: unknown, error: unknown, sourceEntryId?: string) {
219
+ if (!inbound.instruction || !identity || !sameOwner(ownerOf(identity),inbound.instruction.owner)) return undefined;
220
+ const captured=responses.capture(ownerOf(identity),inbound.msg_id,sourceEntryId,deps.getContext()?.sessionManager,(kind,data)=>pi.appendEntry(kind,data));
221
+ if(captured.sourceSha256)try{
222
+ publishFleetSourceEvent({kind:'message',owner:ownerOf(identity),sourceId:captured.reference.slice('fleet:message/'.length),createdAt:Date.now(),deadline:null,contentDigest:captured.sourceSha256});
223
+ }catch{
224
+ // Notification failure must not destroy a ready response or authorize instruction replay.
225
+ try{pi.appendEntry('coms-response-notification',{reference:captured.reference,status:'unavailable'});}catch{/* Receipt/source remain independently readable. */}
226
+ }
227
+ const receipt = instructionReceipt(ownerOf(identity),inbound.msg_id,response,error);
228
+ try { pi.appendEntry('coms-instruction-receipt',receipt); } catch { /* Wire evidence remains valid; later history may be unknown. */ }
229
+ return receipt;
230
+ }
231
+ function handlePrompt(socket: net.Socket, envelope: PromptEnvelope): void {
232
+ let native = false;
233
+ try { native = validateInstructionTag(envelope,identity ? ownerOf(identity) : {project:'',peer:'',sessionId:'',startedAt:''}); }
234
+ catch { nack(socket,envelope.msg_id,'instruction owner/version/payload mismatch'); return; }
235
+ if (native && (!instructionCapability() || inboundQueue.has(envelope.msg_id))) { nack(socket,envelope.msg_id,'instruction unsupported or duplicate'); return; }
236
+ const refusal = deps.acceptInbound?.();
237
+ if (refusal) { nack(socket, envelope.msg_id, refusal); return; }
238
+ if (typeof envelope.hops !== "number" || envelope.hops >= MAX_HOPS) {
239
+ nack(socket, envelope.msg_id, "hops exceeded");
240
+ return;
241
+ }
242
+ const inbound: InboundContext = {
243
+ msg_id: envelope.msg_id,
244
+ hops: envelope.hops,
245
+ sender_endpoint: envelope.sender_endpoint,
246
+ sender_session: envelope.sender_session,
247
+ sender_name: envelope.sender_name,
248
+ sender_cwd: envelope.sender_cwd,
249
+ prompt: envelope.prompt,
250
+ response_schema: envelope.response_schema ?? null,
251
+ fulfilled: false,
252
+ ...(native ? {instruction: structuredClone(envelope.instruction!)} : {}),
253
+ };
254
+ const admission = currentInbound || turnState !== 'idle' || dispatchPaused ? 'queued' : 'submitted';
255
+ if(identity)try{publishFleetSourceEvent({kind:'message',owner:ownerOf(identity),sourceId:envelope.msg_id,createdAt:Date.parse(envelope.timestamp),deadline:null,contentDigest:fleetSourceDigest({prompt:envelope.prompt,sender:envelope.sender_session})});}catch{nack(socket,envelope.msg_id,'notification durable ingress unavailable');return;}
256
+ inboundQueue.set(envelope.msg_id, inbound);
257
+ if(native&&identity)responses.begin(ownerOf(identity),envelope.msg_id);
258
+ if (native) { socket.write(JSON.stringify({type:'ack',msg_id:envelope.msg_id,instruction:{...instructionCapability(),admission}})+'\n');socket.end(); }
259
+ else ack(socket, envelope.msg_id);
260
+ audit({ event: "inbound_prompt", msg_id: envelope.msg_id, sender: envelope.sender_session, hops: envelope.hops });
261
+ dispatchNextInbound();
262
+ }
263
+
264
+ function dispatchNextInbound(): void {
265
+ if (dispatchPaused) return;
266
+ const inbound = nextInboundForDispatch(inboundQueue.values(), turnState, currentInbound !== null);
267
+ if (!inbound) return;
268
+ currentInbound = inbound;
269
+ try {
270
+ pi.sendMessage({
271
+ customType: "coms-inbound",
272
+ content: `[from ${inbound.sender_name} @ ${inbound.sender_cwd}]\n\n${inbound.prompt}`,
273
+ display: true,
274
+ details: { msg_id: inbound.msg_id, sender_session: inbound.sender_session, response_schema: inbound.response_schema ?? null },
275
+ }, { deliverAs: "followUp", triggerTurn: true });
276
+ } catch (error: any) {
277
+ const reason = error?.message ?? String(error);
278
+ inbound.fulfilled = true;
279
+ inboundQueue.delete(inbound.msg_id);
280
+ currentInbound = null;
281
+ audit({ event: "inbound_delivery_failed", msg_id: inbound.msg_id, reason });
282
+ if (identity) {
283
+ const receipt=terminalFor(inbound,null,'peer agent could not start the queued turn');
284
+ void sendEnvelope(inbound.sender_endpoint, {
285
+ ...(inbound.instruction ? {instruction:{version:1 as const,owner:ownerOf(identity),receipt:receipt??null}} : {}),
286
+ type: "response", msg_id: inbound.msg_id, sender_session: identity.session_id,
287
+ sender_endpoint: identity.endpoint, hops: 0, timestamp: nowIso(), response: null,
288
+ error: "peer agent could not start the queued turn",
289
+ } as ResponseEnvelope).catch((sendError: any) => {
290
+ audit({ event: "inbound_delivery_error_response_failed", msg_id: inbound.msg_id, reason: sendError?.message ?? String(sendError) });
291
+ });
292
+ }
293
+ dispatchNextInbound();
294
+ }
295
+ }
296
+
297
+ function handleResponse(socket: net.Socket, envelope: ResponseEnvelope): void {
298
+ const pending = pendingReplies.get(envelope.msg_id);
299
+ if (pending) {
300
+ if (envelope.sender_session !== pending.target_session || envelope.sender_endpoint !== pending.target_endpoint) {
301
+ audit({
302
+ event: "mismatched_response",
303
+ msg_id: envelope.msg_id,
304
+ expected_session: pending.target_session,
305
+ actual_session: envelope.sender_session,
306
+ });
307
+ nack(socket, envelope.msg_id, "response sender mismatch");
308
+ return;
309
+ }
310
+ if (pending.timer) { try { clearTimeout(pending.timer); } catch { /* ignore */ } pending.timer = null; }
311
+ pending.result = { response: envelope.response, error: envelope.error ?? null };
312
+ try { pending.resolve(pending.result); } catch { /* ignore */ }
313
+ } else {
314
+ audit({ event: "orphan_response", msg_id: envelope.msg_id });
315
+ }
316
+ ack(socket, envelope.msg_id);
317
+ }
318
+
319
+ function handlePing(socket: net.Socket, envelope: PingEnvelope): void {
320
+ const ctx = deps.getContext();
321
+ const card: AgentCard = {
322
+ name: identity?.name ?? "unknown",
323
+ purpose: identity?.purpose ?? "",
324
+ model: ctx?.model?.id ?? identity?.model ?? "unknown",
325
+ color: identity?.color ?? "#36F9F6",
326
+ context_used_pct: ctx?.getContextUsage()?.percent ?? null,
327
+ context_measurement: ctx?.getContextUsage()?.percent == null ? "unknown" : "measured",
328
+ queue_depth: waitingInboundCount(),
329
+ pane_id: herdrPaneId() ?? null,
330
+ status: peerStatus(),
331
+ };
332
+ try { socket.write(`${JSON.stringify({ type: "pong", msg_id: envelope.msg_id, agent_card: card, ...(instructionCapability() ? {instruction:instructionCapability()} : {}) })}\n`); } catch { /* ignore */ }
333
+ try { socket.end(); } catch { /* ignore */ }
334
+ }
335
+
336
+ function connectionHandler(socket: net.Socket): void {
337
+ let buffer = Buffer.alloc(0);
338
+ let handled = false;
339
+ const onData = (chunk: Buffer) => {
340
+ if (handled) return;
341
+ buffer = Buffer.concat([buffer, chunk]);
342
+ if (buffer.length > LINE_CAP_BYTES) {
343
+ handled = true;
344
+ socket.removeListener("data", onData);
345
+ nack(socket, "", "malformed envelope");
346
+ return;
347
+ }
348
+ const newline = buffer.indexOf(10);
349
+ if (newline < 0) return;
350
+ handled = true;
351
+ socket.removeListener("data", onData);
352
+ let parsed: any;
353
+ try { parsed = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(buffer.subarray(0, newline))); } catch { nack(socket, "", "malformed envelope"); return; }
354
+ if (!parsed || typeof parsed !== "object" || typeof parsed.type !== "string" || typeof parsed.msg_id !== "string" || typeof parsed.sender_session !== "string" || typeof parsed.sender_endpoint !== "string") {
355
+ nack(socket, typeof parsed?.msg_id === "string" ? parsed.msg_id : "", "malformed envelope");
356
+ return;
357
+ }
358
+ try {
359
+ if (deps.handleCustomStream?.(socket, parsed, buffer.subarray(newline + 1))) return;
360
+ if (parsed.type === "prompt") handlePrompt(socket, parsed);
361
+ else if (parsed.type === "response") handleResponse(socket, parsed);
362
+ else if (parsed.type === "ping") handlePing(socket, parsed);
363
+ else if (deps.instructionReceipts && responses.handle(socket,parsed,()=>identity?ownerOf(identity):null,deps.getContext()?.sessionManager)) socket.end();
364
+ else if (!deps.handleCustomEnvelope?.(socket, parsed)) nack(socket, parsed.msg_id, "unknown type");
365
+ } catch {
366
+ nack(socket, parsed.msg_id, "internal error");
367
+ }
368
+ };
369
+ socket.on("data", onData);
370
+ socket.once("error", () => { try { socket.destroy(); } catch { /* ignore */ } });
371
+ }
372
+
373
+ function writeLiveRegistry(): void {
374
+ if (!identity) return;
375
+ const ctx = deps.getContext();
376
+ try {
377
+ writeRegistryAtomic(buildLiveRegistryEntry(identity, {
378
+ now: nowIso(), pid: process.pid, model: ctx?.model?.id,
379
+ contextUsedPct: ctx?.getContextUsage()?.percent, queueDepth: waitingInboundCount(),
380
+ }), identity.project);
381
+ } catch { /* best effort */ }
382
+ }
383
+
384
+ async function refresh(): Promise<void> {
385
+ if (!identity) return;
386
+ const peers = peersInScope();
387
+ const results = await Promise.allSettled(peers.map(async entry => {
388
+ const pong = await sendEnvelope(entry.endpoint, {
389
+ type: "ping", msg_id: ulid(), sender_session: identity!.session_id,
390
+ sender_endpoint: identity!.endpoint, hops: 0, timestamp: nowIso(),
391
+ } as PingEnvelope);
392
+ return { entry, pong: pong as Pong };
393
+ }));
394
+ const seen = new Set<string>();
395
+ let didChange = false;
396
+ for (const result of results) {
397
+ if (result.status !== "fulfilled" || !result.value.pong?.agent_card) continue;
398
+ seen.add(result.value.entry.session_id);
399
+ const next = { ...result.value.pong.agent_card, staleCount: 0 };
400
+ const previous = peerCards.get(result.value.entry.session_id);
401
+ if (!previous || JSON.stringify({ ...previous, staleCount: 0 }) !== JSON.stringify(next)) {
402
+ peerCards.set(result.value.entry.session_id, next);
403
+ didChange = true;
404
+ }
405
+ }
406
+ for (const [sessionId, card] of peerCards) {
407
+ if (sessionId === identity.session_id || seen.has(sessionId)) continue;
408
+ card.staleCount = (card.staleCount ?? 0) + 1;
409
+ if (card.staleCount > 6) peerCards.delete(sessionId);
410
+ didChange = true;
411
+ }
412
+ if (didChange) changed();
413
+ }
414
+
415
+ async function ping(endpoint: string): Promise<AgentCard | null> {
416
+ if (!identity) return null;
417
+ try {
418
+ const response = await sendEnvelope(endpoint, {
419
+ type: "ping", msg_id: ulid(), sender_session: identity.session_id,
420
+ sender_endpoint: identity.endpoint, hops: 0, timestamp: nowIso(),
421
+ } as PingEnvelope);
422
+ return response?.type === "pong" && response.agent_card ? response.agent_card : null;
423
+ } catch { return null; }
424
+ }
425
+
426
+ async function connect(options: ConnectComsOptions): Promise<ComsIdentity> {
427
+ if (identity) return identity;
428
+ shuttingDown = false;
429
+ const flags = readCliFlags(pi);
430
+ const frontmatter = readFrontmatterFromArgv(process.argv);
431
+ const roots=sessionRootsFromEnv();
432
+ const scopedProject=roots?.mode==='targeted'?projectForSession(flags.project||'default',roots):undefined;
433
+ const project=scopedProject?.project??flags.project??'default';
434
+ const sessionId = ulid();
435
+ const sessionName = typeof pi.getSessionName === "function" ? pi.getSessionName() || undefined : undefined;
436
+ const desiredName = flags.name || sessionName || frontmatter.name || `${options.defaultNamePrefix}-${sessionId.slice(-6)}`;
437
+ const name = resolveUniqueName(project, desiredName);
438
+ if (name !== desiredName) audit({ event: "name_collision", desired: desiredName, assigned: name, project });
439
+ let color = fallbackColor(sessionId);
440
+ if (frontmatter.color && isValidHex(frontmatter.color)) color = frontmatter.color;
441
+ if (flags.color && isValidHex(flags.color)) color = flags.color;
442
+ const endpoint = makeEndpoint(sessionId);
443
+ const cwd = options.ctx.cwd || process.cwd();
444
+ if(roots?.mode==='targeted'&&fs.realpathSync(cwd)!==roots.executionRoot)throw Error('coms_target_cwd_mismatch');
445
+ const model = options.ctx.model?.id ?? "unknown";
446
+ const purpose = flags.purpose || frontmatter.description || options.defaultPurpose;
447
+ try {
448
+ fs.mkdirSync(projectAgentsDir(project), { recursive: true });
449
+ if (process.platform !== "win32") {
450
+ fs.mkdirSync(path.join(COMS_DIR, "sockets"), { recursive: true });
451
+ try { fs.chmodSync(COMS_DIR, 0o700); } catch { /* best effort */ }
452
+ }
453
+ } catch (error) {
454
+ throw new ComsConnectError("dirs", error);
455
+ }
456
+ try { server = await bindEndpoint(endpoint, connectionHandler); }
457
+ catch (error) { throw new ComsConnectError("bind", error); }
458
+ const startedAt = nowIso();
459
+ let contextUsedPct: number | null = null;
460
+ try { contextUsedPct = options.ctx.getContextUsage()?.percent ?? null; }
461
+ catch { /* unavailable measurement must not prevent registration */ }
462
+ // Publish a complete entry atomically on the FIRST write. Native readers
463
+ // require heartbeat_at; waiting for keepalive otherwise exposes ENTRY_INVALID.
464
+ const entry: RegistryEntry = buildLiveRegistryEntry({
465
+ ...(scopedProject ? { targetId: roots!.targetId } : {}),
466
+ session_id: sessionId, name, purpose, model, color,
467
+ endpoint, cwd, started_at: startedAt, explicit: flags.explicit === true,
468
+ }, { now: nowIso(), pid: process.pid, contextUsedPct, queueDepth: waitingInboundCount() });
469
+ let registryFile: string;
470
+ try { registryFile = writeRegistryAtomic(entry, project); }
471
+ catch (error) {
472
+ try { server.close(); } catch { /* ignore */ }
473
+ server = null;
474
+ throw new ComsConnectError("registry", error);
475
+ }
476
+ identity = {
477
+ session_id: sessionId, name, purpose, color, project, explicit: flags.explicit === true,
478
+ ...(scopedProject?{baseProject:scopedProject.baseProject,targetId:roots!.targetId}:{}),
479
+ cwd, model, endpoint, registryFile, started_at: startedAt,
480
+ };
481
+ scope.includeExplicit = false;
482
+ scope.displayProject = project;
483
+ audit({ event: "boot", session_id: sessionId, name, project });
484
+
485
+ const useHerdr = await herdrPresenceAvailable();
486
+ if (useHerdr) {
487
+ const paneId = herdrPaneId()!;
488
+ herdrPresence = new HerdrPresence({
489
+ paneId,
490
+ source: `coms:${sessionId}`,
491
+ onError: (error, dialect) => audit({ event: "presence_dialect_rejected", dialect, reason: error?.message ?? String(error) }),
492
+ });
493
+ void herdrPresence.report("idle", { name, project, contextUsedPct: 0, queueDepth: 0 });
494
+ herdrWatch = new HerdrAgentWatch({ ownPaneId: paneId, onChange: herdrSyncPeerCards });
495
+ void herdrWatch.start();
496
+ audit({ event: "presence_backend", backend: "herdr", pane: paneId });
497
+ } else {
498
+ pingTimer = setInterval(() => { void refresh(); }, PING_INTERVAL_MS);
499
+ try { (pingTimer as any).unref?.(); } catch { /* ignore */ }
500
+ }
501
+ keepaliveTimer = setInterval(() => {
502
+ if (!identity) return;
503
+ const missing = !fs.existsSync(identity.registryFile);
504
+ writeLiveRegistry();
505
+ if (missing) {
506
+ audit({ event: "self_heal", session_id: identity.session_id, reason: "registry file missing" });
507
+ if (!fs.existsSync(identity.registryFile)) writeLiveRegistry();
508
+ }
509
+ if (herdrPresence) {
510
+ void herdrPresence.report(turnState, {
511
+ name: identity.name, project: identity.project,
512
+ contextUsedPct: Math.round(deps.getContext()?.getContextUsage()?.percent ?? 0), queueDepth: waitingInboundCount(),
513
+ });
514
+ }
515
+ if (herdrWatch) herdrSyncPeerCards(herdrWatch.current());
516
+ }, KEEPALIVE_INTERVAL_MS);
517
+ try { (keepaliveTimer as any).unref?.(); } catch { /* ignore */ }
518
+ if (!useHerdr) void refresh();
519
+ return identity;
520
+ }
521
+
522
+ async function list(params: ComsListParams = {}): Promise<ComsListResult> {
523
+ if (!identity) return { agents: [], project: "default", scoped: true, widenRequested: false };
524
+ const scopeProject = scope.displayProject ?? identity.project;
525
+ let widened = false;
526
+ let projects: string[];
527
+ if (scopeProject === "*") projects = params.project && params.project !== "*" ? [params.project] : listProjects();
528
+ else {
529
+ projects = [scopeProject];
530
+ if (params.project && params.project !== scopeProject) widened = true;
531
+ }
532
+ const includeExplicit = scope.includeExplicit && params.include_explicit !== false;
533
+ if (params.include_explicit === true && !scope.includeExplicit) widened = true;
534
+ const collected: Array<{ entry: RegistryEntry; project: string }> = [];
535
+ for (const project of projects) {
536
+ for (const entry of pruneDeadEntries(project)) {
537
+ if (entry.explicit && !includeExplicit) continue;
538
+ if (entry.session_id !== identity.session_id) collected.push({ entry, project });
539
+ }
540
+ }
541
+ const pongs = await Promise.allSettled(collected.map(item => ping(item.entry.endpoint)));
542
+ const agents = collected.map((item, index) => {
543
+ const result = pongs[index];
544
+ const pong = result.status === "fulfilled" ? result.value : null;
545
+ return {
546
+ name: item.entry.name, session_id: item.entry.session_id, purpose: item.entry.purpose,
547
+ model: item.entry.model, cwd: item.entry.cwd, project: item.project, alive: pong !== null,
548
+ context_used_pct: pong?.context_used_pct ?? null, pane_id: pong?.pane_id ?? null,
549
+ status: pong?.status ?? "booting", queue_depth: pong?.queue_depth ?? null, color: item.entry.color,
550
+ };
551
+ });
552
+ return { agents, project: scopeProject, scoped: true, widenRequested: widened };
553
+ }
554
+
555
+ async function send(params: ComsSendParams, auditExtra: Record<string, unknown> = {}): Promise<ComsSendResult> {
556
+ if (!identity) throw new Error("coms not initialised");
557
+ const target = resolveTarget(params.target);
558
+ if (!target) {
559
+ const project = scope.displayProject ?? identity.project;
560
+ throw new Error(`coms: no connected peer "${params.target}" in your pool (project ${project}). Only peers shown in the coms pool are reachable. If you expected this peer, ask the human to widen scope with /af-coms --project <name> or /af-coms --all, then retry.`);
561
+ }
562
+ const hops = currentInbound ? currentInbound.hops + 1 : 0;
563
+ if (hops >= MAX_HOPS) throw new Error(`coms: hop limit reached (${hops} >= ${MAX_HOPS})`);
564
+ const msgId = ulid();
565
+ let resolve!: PendingReply["resolve"];
566
+ let reject!: PendingReply["reject"];
567
+ const promise = new Promise<{ response?: any; error?: string | null }>((res, rej) => { resolve = res; reject = rej; });
568
+ pendingReplies.set(msgId, {
569
+ resolve,
570
+ reject,
571
+ timer: null,
572
+ promise,
573
+ target_name: target.name,
574
+ target_session: target.session_id,
575
+ target_endpoint: target.endpoint,
576
+ created_at: nowIso(),
577
+ });
578
+ try {
579
+ await sendEnvelope(target.endpoint, {
580
+ type: "prompt", msg_id: msgId, sender_session: identity.session_id, sender_endpoint: identity.endpoint,
581
+ sender_name: identity.name, sender_cwd: identity.cwd, hops, timestamp: nowIso(), prompt: params.prompt,
582
+ conversation_id: params.conversation_id ?? null, response_schema: params.response_schema ?? null,
583
+ reply_timeout_ms: params.reply_timeout_ms ?? null,
584
+ } as PromptEnvelope);
585
+ } catch (error) {
586
+ pendingReplies.delete(msgId);
587
+ throw error;
588
+ }
589
+ audit({ event: "outbound_prompt", msg_id: msgId, target: target.name, hops, ...auditExtra });
590
+ return { msg_id: msgId, target: target.name, target_session: target.session_id, hops, promise };
591
+ }
592
+
593
+ function get(msgId: string): { status: "pending" | "complete" | "error"; response?: any; error?: string | null } {
594
+ const entry = pendingReplies.get(msgId);
595
+ if (!entry) return { status: "error", error: "unknown msg_id" };
596
+ if (!entry.result) return { status: "pending" };
597
+ return { status: "complete", response: entry.result.response, error: entry.result.error ?? null };
598
+ }
599
+
600
+ async function awaitReply(msgId: string, timeoutMs = TIMEOUT_MS): Promise<{ status: "pending" | "complete" | "error"; response?: any; error?: string | null }> {
601
+ const entry = pendingReplies.get(msgId);
602
+ if (!entry) return { status: "error", error: "unknown msg_id" };
603
+ const timeout = new Promise<{ error: "timeout" }>(resolve => {
604
+ const timer = setTimeout(() => resolve({ error: "timeout" }), timeoutMs);
605
+ try { (timer as any).unref?.(); } catch { /* ignore */ }
606
+ });
607
+ const result = await Promise.race([entry.promise, timeout]);
608
+ if (result.error === "timeout") return { status: "pending" };
609
+ if (result.error) return { status: "error", error: result.error };
610
+ return { status: "complete", response: "response" in result ? result.response : undefined };
611
+ }
612
+
613
+ function responseForInbound(ctx: ExtensionContext, inbound: InboundContext): { response: any; error: string | null; sourceEntryId?: string } {
614
+ const branch = ctx.sessionManager.getBranch();
615
+ let markerIndex = -1;
616
+ for (let index = branch.length - 1; index >= 0; index -= 1) {
617
+ const entry = branch[index] as any;
618
+ if (entry?.type === "custom_message" && entry?.customType === "coms-inbound" && entry?.details?.msg_id === inbound.msg_id) {
619
+ markerIndex = index;
620
+ break;
621
+ }
622
+ }
623
+ if (markerIndex < 0) return { response: null, error: "peer agent ended without a successful final answer" };
624
+
625
+ let message: any = null;
626
+ let sourceEntryId: string | undefined;
627
+ for (let index = branch.length - 1; index > markerIndex; index -= 1) {
628
+ const candidate = branch[index] as any;
629
+ if (candidate?.type === "message" && candidate?.message?.role === "assistant") {
630
+ message = candidate.message;
631
+ sourceEntryId = candidate.id;
632
+ break;
633
+ }
634
+ }
635
+ if (!message || message.stopReason !== "stop") {
636
+ return { response: null, error: "peer agent ended without a successful final answer", sourceEntryId };
637
+ }
638
+ const text = typeof message.content === "string"
639
+ ? message.content
640
+ : Array.isArray(message.content)
641
+ ? message.content.filter((block: any) => block?.type === "text").map((block: any) => block.text).join("\n")
642
+ : "";
643
+ if (!text.trim()) return { response: null, error: "peer agent produced an empty final answer", sourceEntryId };
644
+ if (inbound.response_schema && typeof inbound.response_schema === "object") {
645
+ try { return { response: JSON.parse(text), error: null }; }
646
+ catch { return { response: null, error: "response not valid JSON" }; }
647
+ }
648
+ return { response: text, error: null, sourceEntryId };
649
+ }
650
+
651
+ async function respond(ctx: ExtensionContext, inbound = currentInbound): Promise<void> {
652
+ if (!inbound || !identity || inbound.fulfilled) return;
653
+ const { response, error, sourceEntryId } = responseForInbound(ctx, inbound);
654
+ const receipt=terminalFor(inbound,response,error,sourceEntryId);
655
+ try {
656
+ await sendEnvelope(inbound.sender_endpoint, {
657
+ type: "response", msg_id: inbound.msg_id, sender_session: identity.session_id,
658
+ sender_endpoint: identity.endpoint, hops: 0, timestamp: nowIso(),
659
+ response: inbound.instruction ? receipt?.text??null : response,
660
+ error: inbound.instruction ? receipt?.state==='failed'?'instruction failed':null : error,
661
+ ...(inbound.instruction ? {instruction:{version:1 as const,owner:ownerOf(identity),receipt:receipt??null}} : {}),
662
+ } as ResponseEnvelope);
663
+ audit({ event: "outbound_response", msg_id: inbound.msg_id, error });
664
+ } catch (sendError: any) {
665
+ audit({ event: "outbound_response_failed", msg_id: inbound.msg_id, reason: sendError?.message ?? String(sendError) });
666
+ }
667
+ inbound.fulfilled = true;
668
+ inboundQueue.delete(inbound.msg_id);
669
+ if (currentInbound === inbound) currentInbound = null;
670
+ }
671
+
672
+ function setTurnState(state: ComsTurnState): void {
673
+ turnState = state;
674
+ if (herdrPresence && identity) {
675
+ void herdrPresence.report(state, {
676
+ name: identity.name, project: identity.project,
677
+ contextUsedPct: Math.round(deps.getContext()?.getContextUsage()?.percent ?? 0), queueDepth: waitingInboundCount(),
678
+ });
679
+ }
680
+ }
681
+
682
+ async function settleTurn(
683
+ ctx: ExtensionContext,
684
+ options: { dispatchQueued?: boolean } = {},
685
+ ): Promise<void> {
686
+ const shouldDispatchQueued = options.dispatchQueued !== false;
687
+ dispatchPaused = !shouldDispatchQueued;
688
+ turnState = "idle";
689
+ const settledInbound = currentInbound;
690
+ if (settledInbound) await respond(ctx, settledInbound);
691
+ if (shouldDispatchQueued) dispatchNextInbound();
692
+ }
693
+
694
+ function dispatchQueued(): void {
695
+ dispatchPaused = false;
696
+ dispatchNextInbound();
697
+ }
698
+
699
+ async function updateScope(args: string, ctx?: ExtensionContext): Promise<void> {
700
+ if (args.includes("--all")) {
701
+ scope.includeExplicit = !scope.includeExplicit;
702
+ try { ctx?.ui.notify(`coms: include_explicit = ${scope.includeExplicit}`, "info"); } catch { /* ignore */ }
703
+ }
704
+ const projectMatch = args.match(/--project\s+(\S+)/);
705
+ if (projectMatch) {
706
+ scope.displayProject = projectMatch[1];
707
+ try { ctx?.ui.notify(`coms: displaying project ${scope.displayProject}`, "info"); } catch { /* ignore */ }
708
+ }
709
+ if (herdrWatch) await herdrWatch.start();
710
+ else await refresh();
711
+ }
712
+
713
+ async function shutdown(): Promise<void> {
714
+ if (shuttingDown) return;
715
+ shuttingDown = true;
716
+ responses.clear();
717
+ if (pingTimer) { try { clearInterval(pingTimer); } catch { /* ignore */ } pingTimer = null; }
718
+ if (keepaliveTimer) { try { clearInterval(keepaliveTimer); } catch { /* ignore */ } keepaliveTimer = null; }
719
+ if (herdrWatch) { try { herdrWatch.stop(); } catch { /* ignore */ } herdrWatch = null; }
720
+ if (herdrPresence) { try { void herdrPresence.release(); } catch { /* ignore */ } herdrPresence = null; }
721
+ if (server) { try { server.close(); } catch { /* ignore */ } server = null; }
722
+ if (identity) {
723
+ if (process.platform !== "win32") { try { fs.unlinkSync(identity.endpoint); } catch { /* ignore */ } }
724
+ removeRegistryEntry(identity.project, identity.name);
725
+ audit({ event: "shutdown", session_id: identity.session_id });
726
+ }
727
+ }
728
+
729
+ return {
730
+ connect, send, list, get, await: awaitReply, refresh, respond, settleTurn, dispatchQueued, shutdown,
731
+ setTurnState, updateScope, writeLiveRegistry, ping, peersInScope, resolveTarget,
732
+ peerCards, pendingReplies, inboundQueue, scope,
733
+ get identity() { return identity; },
734
+ get ready() { return identity !== null && server !== null; },
735
+ };
736
+ }
737
+
738
+ export type ComsPeer = ReturnType<typeof createComsPeer>;