harnery 0.33.0 → 0.34.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 (657) hide show
  1. package/dist/commander.d.ts.map +1 -1
  2. package/dist/commander.js +4 -0
  3. package/dist/commands/adapter.js +2 -2
  4. package/dist/commands/agents.d.ts +144 -1
  5. package/dist/commands/agents.d.ts.map +1 -1
  6. package/dist/commands/agents.js +1220 -588
  7. package/dist/commands/artifacts.d.ts.map +1 -1
  8. package/dist/commands/artifacts.js +7 -6
  9. package/dist/commands/backup.d.ts +1 -1
  10. package/dist/commands/backup.d.ts.map +1 -1
  11. package/dist/commands/backup.js +29 -16
  12. package/dist/commands/browse.d.ts.map +1 -1
  13. package/dist/commands/browse.js +234 -12
  14. package/dist/commands/checkpoint.d.ts.map +1 -1
  15. package/dist/commands/checkpoint.js +3 -2
  16. package/dist/commands/claude-desktop.d.ts +1 -1
  17. package/dist/commands/claude-desktop.d.ts.map +1 -1
  18. package/dist/commands/claude-desktop.js +3 -74
  19. package/dist/commands/context.js +1 -6
  20. package/dist/commands/decision.d.ts.map +1 -1
  21. package/dist/commands/decision.js +22 -38
  22. package/dist/commands/docs.d.ts.map +1 -1
  23. package/dist/commands/docs.js +91 -28
  24. package/dist/commands/doctor.js +10 -1
  25. package/dist/commands/events.d.ts +5 -0
  26. package/dist/commands/events.d.ts.map +1 -0
  27. package/dist/commands/events.js +189 -0
  28. package/dist/commands/governor.d.ts.map +1 -1
  29. package/dist/commands/governor.js +13 -4
  30. package/dist/commands/init.d.ts +9 -2
  31. package/dist/commands/init.d.ts.map +1 -1
  32. package/dist/commands/init.js +223 -51
  33. package/dist/commands/journal.d.ts.map +1 -1
  34. package/dist/commands/journal.js +4 -13
  35. package/dist/commands/ledger-v3.d.ts +5 -0
  36. package/dist/commands/ledger-v3.d.ts.map +1 -0
  37. package/dist/commands/ledger-v3.js +91 -0
  38. package/dist/commands/presence.d.ts.map +1 -1
  39. package/dist/commands/presence.js +11 -5
  40. package/dist/commands/sync.d.ts +1 -1
  41. package/dist/commands/sync.js +1 -1
  42. package/dist/commands/web.d.ts +6 -0
  43. package/dist/commands/web.d.ts.map +1 -1
  44. package/dist/commands/web.js +67 -7
  45. package/dist/commands/work.d.ts.map +1 -1
  46. package/dist/commands/work.js +22 -5
  47. package/dist/core/adapter.d.ts +5 -0
  48. package/dist/core/adapter.d.ts.map +1 -0
  49. package/dist/core/adapter.js +1 -0
  50. package/dist/core/adapters/attest.d.ts +5 -2
  51. package/dist/core/adapters/attest.d.ts.map +1 -1
  52. package/dist/core/adapters/attest.js +8 -3
  53. package/dist/core/adapters/profiles.d.ts +6 -6
  54. package/dist/core/adapters/profiles.d.ts.map +1 -1
  55. package/dist/core/adapters/profiles.js +4 -4
  56. package/dist/core/agents/canonical-emit.d.ts +17 -15
  57. package/dist/core/agents/canonical-emit.d.ts.map +1 -1
  58. package/dist/core/agents/canonical-emit.js +22 -22
  59. package/dist/core/agents/cli.js +207 -234
  60. package/dist/core/agents/codex-archive-v3.d.ts +14 -0
  61. package/dist/core/agents/codex-archive-v3.d.ts.map +1 -0
  62. package/dist/core/agents/codex-archive-v3.js +110 -0
  63. package/dist/core/agents/coord-client.d.ts +19 -81
  64. package/dist/core/agents/coord-client.d.ts.map +1 -1
  65. package/dist/core/agents/coord-client.js +65 -155
  66. package/dist/core/agents/finalization.d.ts +4 -1
  67. package/dist/core/agents/finalization.d.ts.map +1 -1
  68. package/dist/core/agents/finalization.js +89 -32
  69. package/dist/core/agents/index.d.ts +4 -5
  70. package/dist/core/agents/index.d.ts.map +1 -1
  71. package/dist/core/agents/index.js +4 -5
  72. package/dist/core/agents/live-authority-v3.d.ts +59 -0
  73. package/dist/core/agents/live-authority-v3.d.ts.map +1 -0
  74. package/dist/core/agents/live-authority-v3.js +233 -0
  75. package/dist/core/agents/live-lifecycle-v3.d.ts +20 -0
  76. package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -0
  77. package/dist/core/agents/live-lifecycle-v3.js +91 -0
  78. package/dist/core/agents/live-observation-v3.d.ts +25 -0
  79. package/dist/core/agents/live-observation-v3.d.ts.map +1 -0
  80. package/dist/core/agents/live-observation-v3.js +157 -0
  81. package/dist/core/agents/render/prompt-context.d.ts +4 -4
  82. package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
  83. package/dist/core/agents/render/prompt-context.js +23 -58
  84. package/dist/core/agents/render/session-context.d.ts +1 -1
  85. package/dist/core/agents/render/session-context.d.ts.map +1 -1
  86. package/dist/core/agents/render/session-context.js +8 -32
  87. package/dist/core/agents/rules/claim-conflict.d.ts +3 -3
  88. package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
  89. package/dist/core/agents/rules/claim-conflict.js +79 -127
  90. package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
  91. package/dist/core/agents/rules/commit-conflict.js +3 -18
  92. package/dist/core/agents/rules/stop-hook.d.ts +9 -50
  93. package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
  94. package/dist/core/agents/rules/stop-hook.js +193 -236
  95. package/dist/core/agents/session-events.d.ts +5 -7
  96. package/dist/core/agents/session-events.d.ts.map +1 -1
  97. package/dist/core/agents/session-events.js +127 -95
  98. package/dist/core/agents/session-finalization-state-v3.d.ts +30 -0
  99. package/dist/core/agents/session-finalization-state-v3.d.ts.map +1 -0
  100. package/dist/core/agents/session-finalization-state-v3.js +40 -0
  101. package/dist/core/agents/session-finalizer-v3.d.ts +107 -0
  102. package/dist/core/agents/session-finalizer-v3.d.ts.map +1 -0
  103. package/dist/core/agents/session-finalizer-v3.js +734 -0
  104. package/dist/core/agents/session-name-display.d.ts +40 -0
  105. package/dist/core/agents/session-name-display.d.ts.map +1 -0
  106. package/dist/core/agents/session-name-display.js +119 -0
  107. package/dist/core/agents/state/activity-log.d.ts +3 -3
  108. package/dist/core/agents/state/activity-log.d.ts.map +1 -1
  109. package/dist/core/agents/state/activity-log.js +7 -16
  110. package/dist/core/agents/state/heartbeat-writer.d.ts +23 -55
  111. package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
  112. package/dist/core/agents/state/heartbeat-writer.js +56 -228
  113. package/dist/core/agents/state/live-coordination-view.d.ts +31 -0
  114. package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -0
  115. package/dist/core/agents/state/live-coordination-view.js +209 -0
  116. package/dist/core/agents/state/session-state.d.ts +4 -3
  117. package/dist/core/agents/state/session-state.d.ts.map +1 -1
  118. package/dist/core/agents/state/session-state.js +18 -9
  119. package/dist/core/agents/state/stale-sweep.d.ts +1 -1
  120. package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
  121. package/dist/core/agents/state/stale-sweep.js +26 -15
  122. package/dist/core/artifacts/index.d.ts.map +1 -1
  123. package/dist/core/artifacts/index.js +5 -7
  124. package/dist/core/config.d.ts +33 -2
  125. package/dist/core/config.d.ts.map +1 -1
  126. package/dist/core/config.js +98 -2
  127. package/dist/core/context/index.d.ts +1 -4
  128. package/dist/core/context/index.d.ts.map +1 -1
  129. package/dist/core/context/index.js +9 -9
  130. package/dist/core/events/span-parent.d.ts +15 -0
  131. package/dist/core/events/span-parent.d.ts.map +1 -0
  132. package/dist/core/events/span-parent.js +34 -0
  133. package/dist/core/events/v3/advance.d.ts +14 -0
  134. package/dist/core/events/v3/advance.d.ts.map +1 -0
  135. package/dist/core/events/v3/advance.js +134 -0
  136. package/dist/core/events/v3/authority-outbox.d.ts +78 -0
  137. package/dist/core/events/v3/authority-outbox.d.ts.map +1 -0
  138. package/dist/core/events/v3/authority-outbox.js +399 -0
  139. package/dist/core/events/v3/base-builder.d.ts +20 -0
  140. package/dist/core/events/v3/base-builder.d.ts.map +1 -0
  141. package/dist/core/events/v3/base-builder.js +29 -0
  142. package/dist/core/events/v3/base-contract.d.ts +7576 -0
  143. package/dist/core/events/v3/base-contract.d.ts.map +1 -0
  144. package/dist/core/events/v3/base-contract.js +647 -0
  145. package/dist/core/events/v3/bootstrap.d.ts +34 -0
  146. package/dist/core/events/v3/bootstrap.d.ts.map +1 -0
  147. package/dist/core/events/v3/bootstrap.js +175 -0
  148. package/dist/core/events/v3/builder.d.ts +20 -0
  149. package/dist/core/events/v3/builder.d.ts.map +1 -0
  150. package/dist/core/events/v3/builder.js +28 -0
  151. package/dist/core/events/v3/canonical.d.ts +31 -0
  152. package/dist/core/events/v3/canonical.d.ts.map +1 -0
  153. package/dist/core/events/v3/canonical.js +100 -0
  154. package/dist/core/events/v3/capabilities.d.ts +31 -0
  155. package/dist/core/events/v3/capabilities.d.ts.map +1 -0
  156. package/dist/core/events/v3/capabilities.js +107 -0
  157. package/dist/core/events/v3/capability-drift.d.ts +22 -0
  158. package/dist/core/events/v3/capability-drift.d.ts.map +1 -0
  159. package/dist/core/events/v3/capability-drift.js +134 -0
  160. package/dist/core/events/v3/catalog.d.ts +38 -0
  161. package/dist/core/events/v3/catalog.d.ts.map +1 -0
  162. package/dist/core/events/v3/catalog.js +135 -0
  163. package/dist/core/events/v3/clock-order.d.ts +34 -0
  164. package/dist/core/events/v3/clock-order.d.ts.map +1 -0
  165. package/dist/core/events/v3/clock-order.js +35 -0
  166. package/dist/core/events/v3/contract.d.ts +171 -0
  167. package/dist/core/events/v3/contract.d.ts.map +1 -0
  168. package/dist/core/events/v3/contract.js +180 -0
  169. package/dist/core/events/v3/control.d.ts +111 -0
  170. package/dist/core/events/v3/control.d.ts.map +1 -0
  171. package/dist/core/events/v3/control.js +419 -0
  172. package/dist/core/events/v3/coordination-view.d.ts +69 -0
  173. package/dist/core/events/v3/coordination-view.d.ts.map +1 -0
  174. package/dist/core/events/v3/coordination-view.js +119 -0
  175. package/dist/core/events/v3/economics.d.ts +77 -0
  176. package/dist/core/events/v3/economics.d.ts.map +1 -0
  177. package/dist/core/events/v3/economics.js +274 -0
  178. package/dist/core/events/v3/finalization-view.d.ts +26 -0
  179. package/dist/core/events/v3/finalization-view.d.ts.map +1 -0
  180. package/dist/core/events/v3/finalization-view.js +37 -0
  181. package/dist/core/events/v3/fingerprint-keys.d.ts +25 -0
  182. package/dist/core/events/v3/fingerprint-keys.d.ts.map +1 -0
  183. package/dist/core/events/v3/fingerprint-keys.js +217 -0
  184. package/dist/core/events/v3/generated.d.ts +4 -0
  185. package/dist/core/events/v3/generated.d.ts.map +1 -0
  186. package/dist/core/events/v3/generated.js +47 -0
  187. package/dist/core/events/v3/ids.d.ts +9 -0
  188. package/dist/core/events/v3/ids.d.ts.map +1 -0
  189. package/dist/core/events/v3/ids.js +25 -0
  190. package/dist/core/events/v3/index.d.ts +35 -0
  191. package/dist/core/events/v3/index.d.ts.map +1 -0
  192. package/dist/core/events/v3/index.js +33 -0
  193. package/dist/core/events/v3/latency.d.ts +63 -0
  194. package/dist/core/events/v3/latency.d.ts.map +1 -0
  195. package/dist/core/events/v3/latency.js +412 -0
  196. package/dist/core/events/v3/live-feed.d.ts +45 -0
  197. package/dist/core/events/v3/live-feed.d.ts.map +1 -0
  198. package/dist/core/events/v3/live-feed.js +246 -0
  199. package/dist/core/events/v3/live-observation.d.ts +35 -0
  200. package/dist/core/events/v3/live-observation.d.ts.map +1 -0
  201. package/dist/core/events/v3/live-observation.js +1 -0
  202. package/dist/core/events/v3/live-routing.d.ts +57 -0
  203. package/dist/core/events/v3/live-routing.d.ts.map +1 -0
  204. package/dist/core/events/v3/live-routing.js +107 -0
  205. package/dist/core/events/v3/producers/command-recorder.d.ts +67 -0
  206. package/dist/core/events/v3/producers/command-recorder.d.ts.map +1 -0
  207. package/dist/core/events/v3/producers/command-recorder.js +477 -0
  208. package/dist/core/events/v3/producers/command.d.ts +50 -0
  209. package/dist/core/events/v3/producers/command.d.ts.map +1 -0
  210. package/dist/core/events/v3/producers/command.js +135 -0
  211. package/dist/core/events/v3/producers/coordination-recorder.d.ts +53 -0
  212. package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -0
  213. package/dist/core/events/v3/producers/coordination-recorder.js +376 -0
  214. package/dist/core/events/v3/producers/coordination.d.ts +90 -0
  215. package/dist/core/events/v3/producers/coordination.d.ts.map +1 -0
  216. package/dist/core/events/v3/producers/coordination.js +229 -0
  217. package/dist/core/events/v3/producers/hook-base.d.ts +54 -0
  218. package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -0
  219. package/dist/core/events/v3/producers/hook-base.js +424 -0
  220. package/dist/core/events/v3/producers/hook.d.ts +29 -0
  221. package/dist/core/events/v3/producers/hook.d.ts.map +1 -0
  222. package/dist/core/events/v3/producers/hook.js +71 -0
  223. package/dist/core/events/v3/producers/intake.d.ts +65 -0
  224. package/dist/core/events/v3/producers/intake.d.ts.map +1 -0
  225. package/dist/core/events/v3/producers/intake.js +244 -0
  226. package/dist/core/events/v3/producers/recorder.d.ts +240 -0
  227. package/dist/core/events/v3/producers/recorder.d.ts.map +1 -0
  228. package/dist/core/events/v3/producers/recorder.js +2176 -0
  229. package/dist/core/events/v3/projection.d.ts +101 -0
  230. package/dist/core/events/v3/projection.d.ts.map +1 -0
  231. package/dist/core/events/v3/projection.js +479 -0
  232. package/dist/core/events/v3/reader.d.ts +75 -0
  233. package/dist/core/events/v3/reader.d.ts.map +1 -0
  234. package/dist/core/events/v3/reader.js +778 -0
  235. package/dist/core/events/v3/recovery-record.d.ts +47 -0
  236. package/dist/core/events/v3/recovery-record.d.ts.map +1 -0
  237. package/dist/core/events/v3/recovery-record.js +167 -0
  238. package/dist/core/events/v3/recovery.d.ts +22 -0
  239. package/dist/core/events/v3/recovery.d.ts.map +1 -0
  240. package/dist/core/events/v3/recovery.js +227 -0
  241. package/dist/core/events/v3/span-state.d.ts +52 -0
  242. package/dist/core/events/v3/span-state.d.ts.map +1 -0
  243. package/dist/core/events/v3/span-state.js +142 -0
  244. package/dist/core/events/v3/targets.d.ts +23 -0
  245. package/dist/core/events/v3/targets.d.ts.map +1 -0
  246. package/dist/core/events/v3/targets.js +134 -0
  247. package/dist/core/events/v3/turn-telemetry.d.ts +41 -0
  248. package/dist/core/events/v3/turn-telemetry.d.ts.map +1 -0
  249. package/dist/core/events/v3/turn-telemetry.js +168 -0
  250. package/dist/core/events/v3/validate.d.ts +9 -0
  251. package/dist/core/events/v3/validate.d.ts.map +1 -0
  252. package/dist/core/events/v3/validate.js +281 -0
  253. package/dist/core/events/v3/writer.d.ts +56 -0
  254. package/dist/core/events/v3/writer.d.ts.map +1 -0
  255. package/dist/core/events/v3/writer.js +335 -0
  256. package/dist/core/governor/index.d.ts +1 -1
  257. package/dist/core/governor/index.d.ts.map +1 -1
  258. package/dist/core/governor/index.js +1 -1
  259. package/dist/core/governor/plan-api.d.ts +2 -1
  260. package/dist/core/governor/plan-api.d.ts.map +1 -1
  261. package/dist/core/governor/plan-api.js +6 -3
  262. package/dist/core/governor/read.d.ts +1 -1
  263. package/dist/core/governor/read.d.ts.map +1 -1
  264. package/dist/core/governor/read.js +1 -1
  265. package/dist/core/governor/state.d.ts +9 -0
  266. package/dist/core/governor/state.d.ts.map +1 -1
  267. package/dist/core/governor/state.js +40 -3
  268. package/dist/core/guard/config.d.ts +5 -0
  269. package/dist/core/guard/config.d.ts.map +1 -0
  270. package/dist/core/guard/config.js +157 -0
  271. package/dist/core/guard/coordinator.d.ts +14 -0
  272. package/dist/core/guard/coordinator.d.ts.map +1 -0
  273. package/dist/core/guard/coordinator.js +173 -0
  274. package/dist/core/guard/evaluator.d.ts +4 -0
  275. package/dist/core/guard/evaluator.d.ts.map +1 -0
  276. package/dist/core/guard/evaluator.js +242 -0
  277. package/dist/core/guard/evidence-v3.d.ts +15 -0
  278. package/dist/core/guard/evidence-v3.d.ts.map +1 -0
  279. package/dist/core/guard/evidence-v3.js +171 -0
  280. package/dist/core/guard/index.d.ts +10 -0
  281. package/dist/core/guard/index.d.ts.map +1 -0
  282. package/dist/core/guard/index.js +6 -0
  283. package/dist/core/guard/live-source-v3.d.ts +40 -0
  284. package/dist/core/guard/live-source-v3.d.ts.map +1 -0
  285. package/dist/core/guard/live-source-v3.js +128 -0
  286. package/dist/core/guard/storage.d.ts +27 -0
  287. package/dist/core/guard/storage.d.ts.map +1 -0
  288. package/dist/core/guard/storage.js +140 -0
  289. package/dist/core/guard/types.d.ts +119 -0
  290. package/dist/core/guard/types.d.ts.map +1 -0
  291. package/dist/core/guard/types.js +1 -0
  292. package/dist/core/hooks/adapter/detect.d.ts +18 -1
  293. package/dist/core/hooks/adapter/detect.d.ts.map +1 -1
  294. package/dist/core/hooks/adapter/detect.js +29 -0
  295. package/dist/core/hooks/adapter/events.d.ts +7 -4
  296. package/dist/core/hooks/adapter/events.d.ts.map +1 -1
  297. package/dist/core/hooks/adapter/events.js +12 -4
  298. package/dist/core/hooks/adapter/output.d.ts +2 -2
  299. package/dist/core/hooks/adapter/output.d.ts.map +1 -1
  300. package/dist/core/hooks/adapter/parse.d.ts +7 -4
  301. package/dist/core/hooks/adapter/parse.d.ts.map +1 -1
  302. package/dist/core/hooks/adapter/parse.js +63 -25
  303. package/dist/core/hooks/adapter/wiring.d.ts +30 -4
  304. package/dist/core/hooks/adapter/wiring.d.ts.map +1 -1
  305. package/dist/core/hooks/adapter/wiring.js +89 -11
  306. package/dist/core/hooks/cli.d.ts +1 -1
  307. package/dist/core/hooks/cli.js +305 -444
  308. package/dist/core/hooks/effects/image-capture.d.ts +20 -34
  309. package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
  310. package/dist/core/hooks/effects/image-capture.js +212 -221
  311. package/dist/core/hooks/effects/index.d.ts +1 -9
  312. package/dist/core/hooks/effects/index.d.ts.map +1 -1
  313. package/dist/core/hooks/effects/index.js +1 -24
  314. package/dist/core/hooks/events/input-hash.d.ts +7 -0
  315. package/dist/core/hooks/events/input-hash.d.ts.map +1 -0
  316. package/dist/core/hooks/events/input-hash.js +43 -0
  317. package/dist/core/hooks/index.d.ts +4 -3
  318. package/dist/core/hooks/index.d.ts.map +1 -1
  319. package/dist/core/hooks/index.js +2 -3
  320. package/dist/core/hooks/resolve/coord-root.d.ts +1 -1
  321. package/dist/core/hooks/resolve/coord-root.js +1 -1
  322. package/dist/core/hooks/resolve/owner.d.ts +16 -15
  323. package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
  324. package/dist/core/hooks/resolve/owner.js +51 -42
  325. package/dist/core/hooks/resolve/transcript.d.ts +33 -3
  326. package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
  327. package/dist/core/hooks/resolve/transcript.js +155 -14
  328. package/dist/core/hooks/session-name-presence.d.ts +9 -10
  329. package/dist/core/hooks/session-name-presence.d.ts.map +1 -1
  330. package/dist/core/hooks/session-name-presence.js +15 -15
  331. package/dist/core/hooks/unsafe-cross-shell.d.ts +1 -1
  332. package/dist/core/hooks/unsafe-cross-shell.d.ts.map +1 -1
  333. package/dist/core/journal/index.d.ts +2 -2
  334. package/dist/core/journal/index.d.ts.map +1 -1
  335. package/dist/core/journal/index.js +9 -22
  336. package/dist/core/presence/blob.d.ts +4 -3
  337. package/dist/core/presence/blob.d.ts.map +1 -1
  338. package/dist/core/presence/blob.js +45 -44
  339. package/dist/core/presence/codec-digest.d.ts +29 -0
  340. package/dist/core/presence/codec-digest.d.ts.map +1 -0
  341. package/dist/core/presence/codec-digest.js +170 -0
  342. package/dist/core/presence/relay-client.d.ts +1 -1
  343. package/dist/core/presence/relay-client.d.ts.map +1 -1
  344. package/dist/core/presence/relay-client.js +5 -5
  345. package/dist/core/work/index.d.ts +1 -1
  346. package/dist/core/work/index.d.ts.map +1 -1
  347. package/dist/core/work/index.js +1 -1
  348. package/dist/core/work/read.d.ts +1 -1
  349. package/dist/core/work/read.d.ts.map +1 -1
  350. package/dist/core/work/read.js +1 -1
  351. package/dist/core/work/runner.d.ts.map +1 -1
  352. package/dist/core/work/runner.js +6 -0
  353. package/dist/core/work/state.d.ts +9 -0
  354. package/dist/core/work/state.d.ts.map +1 -1
  355. package/dist/core/work/state.js +17 -3
  356. package/dist/core/workflow/engine.js +24 -25
  357. package/dist/core/workflow/live-session-v3.d.ts +19 -0
  358. package/dist/core/workflow/live-session-v3.d.ts.map +1 -0
  359. package/dist/core/workflow/live-session-v3.js +86 -0
  360. package/dist/core/workflow/scope-id.d.ts +3 -0
  361. package/dist/core/workflow/scope-id.d.ts.map +1 -0
  362. package/dist/core/workflow/scope-id.js +5 -0
  363. package/dist/core/workflow/workspaces/leases.d.ts +4 -0
  364. package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
  365. package/dist/core/workflow/workspaces/leases.js +53 -19
  366. package/dist/index.d.ts +1 -1
  367. package/dist/index.js +1 -1
  368. package/dist/lib/browser/client.d.ts +41 -0
  369. package/dist/lib/browser/client.d.ts.map +1 -1
  370. package/dist/lib/browser/client.js +203 -0
  371. package/dist/lib/browser/critique.d.ts +28 -2
  372. package/dist/lib/browser/critique.d.ts.map +1 -1
  373. package/dist/lib/browser/critique.js +74 -18
  374. package/dist/lib/browser/geometry.d.ts +1 -1
  375. package/dist/lib/browser/geometry.d.ts.map +1 -1
  376. package/dist/lib/browser/geometry.js +130 -6
  377. package/dist/lib/browser/index.d.ts +3 -0
  378. package/dist/lib/browser/index.d.ts.map +1 -1
  379. package/dist/lib/browser/index.js +3 -0
  380. package/dist/lib/browser/qa-plan.d.ts +174 -0
  381. package/dist/lib/browser/qa-plan.d.ts.map +1 -0
  382. package/dist/lib/browser/qa-plan.js +321 -0
  383. package/dist/lib/browser/qa-reuse.d.ts +99 -0
  384. package/dist/lib/browser/qa-reuse.d.ts.map +1 -0
  385. package/dist/lib/browser/qa-reuse.js +222 -0
  386. package/dist/lib/browser/qa-snapshot.d.ts +64 -0
  387. package/dist/lib/browser/qa-snapshot.d.ts.map +1 -0
  388. package/dist/lib/browser/qa-snapshot.js +171 -0
  389. package/dist/lib/browser/runts.d.ts.map +1 -1
  390. package/dist/lib/browser/runts.js +22 -1
  391. package/dist/lib/browser/tiling.d.ts +71 -0
  392. package/dist/lib/browser/tiling.d.ts.map +1 -0
  393. package/dist/lib/browser/tiling.js +118 -0
  394. package/dist/lib/claude-desktop.d.ts +0 -47
  395. package/dist/lib/claude-desktop.d.ts.map +1 -1
  396. package/dist/lib/claude-desktop.js +1 -169
  397. package/dist/lib/context/index.d.ts +0 -3
  398. package/dist/lib/context/index.d.ts.map +1 -1
  399. package/dist/lib/context/index.js +20 -42
  400. package/dist/lib/council/index.d.ts +2 -2
  401. package/dist/lib/council/index.d.ts.map +1 -1
  402. package/dist/lib/council/index.js +9 -20
  403. package/dist/lib/docs-frontmatter.d.ts +1 -6
  404. package/dist/lib/docs-frontmatter.d.ts.map +1 -1
  405. package/dist/lib/docs-frontmatter.js +12 -78
  406. package/dist/lib/docs-index.d.ts +9 -0
  407. package/dist/lib/docs-index.d.ts.map +1 -1
  408. package/dist/lib/docs-index.js +32 -3
  409. package/dist/lib/docs-lint.d.ts.map +1 -1
  410. package/dist/lib/docs-lint.js +14 -30
  411. package/dist/lib/docs-metadata-audit.d.ts +19 -0
  412. package/dist/lib/docs-metadata-audit.d.ts.map +1 -0
  413. package/dist/lib/docs-metadata-audit.js +132 -0
  414. package/dist/lib/docs-metadata-managed.d.ts +23 -0
  415. package/dist/lib/docs-metadata-managed.d.ts.map +1 -0
  416. package/dist/lib/docs-metadata-managed.js +78 -0
  417. package/dist/lib/docs-metadata-sync.d.ts +20 -0
  418. package/dist/lib/docs-metadata-sync.d.ts.map +1 -0
  419. package/dist/lib/docs-metadata-sync.js +222 -0
  420. package/dist/lib/docs-metadata-v2-schema.d.ts +273 -0
  421. package/dist/lib/docs-metadata-v2-schema.d.ts.map +1 -0
  422. package/dist/lib/docs-metadata-v2-schema.js +134 -0
  423. package/dist/lib/docs-metadata-v2.d.ts +21 -0
  424. package/dist/lib/docs-metadata-v2.d.ts.map +1 -0
  425. package/dist/lib/docs-metadata-v2.js +424 -0
  426. package/dist/lib/docs-new.d.ts +11 -0
  427. package/dist/lib/docs-new.d.ts.map +1 -0
  428. package/dist/lib/docs-new.js +52 -0
  429. package/dist/lib/docs-sweep.d.ts.map +1 -1
  430. package/dist/lib/docs-sweep.js +45 -29
  431. package/dist/lib/headless/index.d.ts +98 -0
  432. package/dist/lib/headless/index.d.ts.map +1 -0
  433. package/dist/lib/headless/index.js +211 -0
  434. package/dist/lib/identities/assume.d.ts +4 -4
  435. package/dist/lib/identities/assume.d.ts.map +1 -1
  436. package/dist/lib/identities/assume.js +52 -68
  437. package/dist/lib/instructions/apply.d.ts +5 -4
  438. package/dist/lib/instructions/apply.d.ts.map +1 -1
  439. package/dist/lib/instructions/apply.js +32 -20
  440. package/dist/lib/instructions/bundle.d.ts +1 -1
  441. package/dist/lib/instructions/bundle.d.ts.map +1 -1
  442. package/dist/lib/instructions/bundle.js +1 -1
  443. package/dist/lib/instructions/splice.d.ts +0 -1
  444. package/dist/lib/instructions/splice.d.ts.map +1 -1
  445. package/dist/lib/instructions/splice.js +22 -6
  446. package/dist/lib/instructions/templates.d.ts +7 -5
  447. package/dist/lib/instructions/templates.d.ts.map +1 -1
  448. package/dist/lib/instructions/templates.js +79 -9
  449. package/package.json +26 -5
  450. package/schemas/config.schema.json +120 -2
  451. package/schemas/docs-metadata-v2.schema.json +441 -0
  452. package/schemas/event-v3.schema.json +24472 -0
  453. package/src/commander.ts +4 -0
  454. package/src/commands/adapter.ts +2 -2
  455. package/src/commands/agents.ts +1512 -592
  456. package/src/commands/artifacts.ts +7 -6
  457. package/src/commands/backup.ts +29 -21
  458. package/src/commands/browse.ts +349 -8
  459. package/src/commands/checkpoint.ts +4 -3
  460. package/src/commands/claude-desktop.ts +2 -101
  461. package/src/commands/context.ts +1 -6
  462. package/src/commands/decision.ts +27 -44
  463. package/src/commands/docs.ts +100 -33
  464. package/src/commands/doctor.ts +14 -1
  465. package/src/commands/events.ts +256 -0
  466. package/src/commands/governor.ts +18 -4
  467. package/src/commands/init.ts +253 -57
  468. package/src/commands/instructions.ts +1 -1
  469. package/src/commands/journal.ts +4 -13
  470. package/src/commands/ledger-v3.ts +111 -0
  471. package/src/commands/presence.ts +11 -10
  472. package/src/commands/sync.ts +1 -1
  473. package/src/commands/web.ts +67 -8
  474. package/src/commands/work.ts +28 -5
  475. package/src/core/adapter.ts +5 -0
  476. package/src/core/adapters/attest.ts +8 -3
  477. package/src/core/adapters/profiles.ts +4 -6
  478. package/src/core/agents/canonical-emit.ts +34 -25
  479. package/src/core/agents/cli.ts +236 -262
  480. package/src/core/agents/codex-archive-v3.ts +138 -0
  481. package/src/core/agents/coord-client.ts +75 -188
  482. package/src/core/agents/finalization.ts +120 -38
  483. package/src/core/agents/index.ts +4 -5
  484. package/src/core/agents/live-authority-v3.ts +375 -0
  485. package/src/core/agents/live-lifecycle-v3.ts +140 -0
  486. package/src/core/agents/live-observation-v3.ts +216 -0
  487. package/src/core/agents/render/prompt-context.ts +29 -60
  488. package/src/core/agents/render/session-context.ts +10 -31
  489. package/src/core/agents/rules/claim-conflict.ts +85 -126
  490. package/src/core/agents/rules/commit-conflict.ts +3 -14
  491. package/src/core/agents/rules/stop-hook.ts +239 -293
  492. package/src/core/agents/session-events.ts +137 -104
  493. package/src/core/agents/session-finalization-state-v3.ts +90 -0
  494. package/src/core/agents/session-finalizer-v3.ts +953 -0
  495. package/src/core/agents/session-name-display.ts +149 -0
  496. package/src/core/agents/state/activity-log.ts +6 -14
  497. package/src/core/agents/state/heartbeat-writer.ts +82 -277
  498. package/src/core/agents/state/live-coordination-view.ts +290 -0
  499. package/src/core/agents/state/session-state.ts +24 -12
  500. package/src/core/agents/state/stale-sweep.ts +40 -17
  501. package/src/core/artifacts/index.ts +4 -5
  502. package/src/core/config.ts +148 -3
  503. package/src/core/context/index.ts +9 -17
  504. package/src/core/events/span-parent.ts +46 -0
  505. package/src/core/events/v3/advance.ts +168 -0
  506. package/src/core/events/v3/authority-outbox.ts +548 -0
  507. package/src/core/events/v3/base-builder.ts +60 -0
  508. package/src/core/events/v3/base-contract.ts +882 -0
  509. package/src/core/events/v3/bootstrap.ts +226 -0
  510. package/src/core/events/v3/builder.ts +59 -0
  511. package/src/core/events/v3/canonical.ts +153 -0
  512. package/src/core/events/v3/capabilities.ts +171 -0
  513. package/src/core/events/v3/capability-drift.ts +177 -0
  514. package/src/core/events/v3/catalog.ts +202 -0
  515. package/src/core/events/v3/clock-order.ts +41 -0
  516. package/src/core/events/v3/contract.ts +365 -0
  517. package/src/core/events/v3/control.ts +576 -0
  518. package/src/core/events/v3/coordination-view.ts +193 -0
  519. package/src/core/events/v3/economics.ts +384 -0
  520. package/src/core/events/v3/finalization-view.ts +67 -0
  521. package/src/core/events/v3/fingerprint-keys.ts +260 -0
  522. package/src/core/events/v3/generated.ts +48 -0
  523. package/src/core/events/v3/ids.ts +33 -0
  524. package/src/core/events/v3/index.ts +322 -0
  525. package/src/core/events/v3/latency.ts +551 -0
  526. package/src/core/events/v3/live-feed.ts +319 -0
  527. package/src/core/events/v3/live-observation.ts +39 -0
  528. package/src/core/events/v3/live-routing.ts +135 -0
  529. package/src/core/events/v3/producers/command-recorder.ts +631 -0
  530. package/src/core/events/v3/producers/command.ts +201 -0
  531. package/src/core/events/v3/producers/coordination-recorder.ts +538 -0
  532. package/src/core/events/v3/producers/coordination.ts +355 -0
  533. package/src/core/events/v3/producers/hook-base.ts +578 -0
  534. package/src/core/events/v3/producers/hook.ts +119 -0
  535. package/src/core/events/v3/producers/intake.ts +319 -0
  536. package/src/core/events/v3/producers/recorder.ts +2805 -0
  537. package/src/core/events/v3/projection.ts +653 -0
  538. package/src/core/events/v3/reader.ts +1127 -0
  539. package/src/core/events/v3/recovery-record.ts +244 -0
  540. package/src/core/events/v3/recovery.ts +271 -0
  541. package/src/core/events/v3/span-state.ts +187 -0
  542. package/src/core/events/v3/targets.ts +182 -0
  543. package/src/core/events/v3/turn-telemetry.ts +259 -0
  544. package/src/core/events/v3/validate.ts +361 -0
  545. package/src/core/events/v3/writer.ts +419 -0
  546. package/src/core/governor/index.ts +3 -0
  547. package/src/core/governor/plan-api.ts +10 -2
  548. package/src/core/governor/read.ts +3 -0
  549. package/src/core/governor/state.ts +52 -5
  550. package/src/core/guard/config.ts +206 -0
  551. package/src/core/guard/coordinator.ts +227 -0
  552. package/src/core/guard/evaluator.ts +343 -0
  553. package/src/core/guard/evidence-v3.ts +227 -0
  554. package/src/core/guard/index.ts +35 -0
  555. package/src/core/guard/live-source-v3.ts +204 -0
  556. package/src/core/guard/storage.ts +188 -0
  557. package/src/core/guard/types.ts +152 -0
  558. package/src/core/hooks/adapter/detect.ts +28 -1
  559. package/src/core/hooks/adapter/events.ts +14 -6
  560. package/src/core/hooks/adapter/output.ts +7 -2
  561. package/src/core/hooks/adapter/parse.ts +80 -38
  562. package/src/core/hooks/adapter/wiring.ts +119 -13
  563. package/src/core/hooks/cli.ts +351 -466
  564. package/src/core/hooks/effects/image-capture.ts +228 -238
  565. package/src/core/hooks/effects/index.ts +1 -36
  566. package/src/core/hooks/events/input-hash.ts +47 -0
  567. package/src/core/hooks/index.ts +4 -11
  568. package/src/core/hooks/resolve/coord-root.ts +1 -1
  569. package/src/core/hooks/resolve/owner.ts +52 -45
  570. package/src/core/hooks/resolve/transcript.ts +165 -14
  571. package/src/core/hooks/session-name-presence.ts +14 -15
  572. package/src/core/hooks/unsafe-cross-shell.ts +1 -1
  573. package/src/core/journal/index.ts +15 -22
  574. package/src/core/presence/blob.ts +48 -41
  575. package/src/core/presence/codec-digest.ts +215 -0
  576. package/src/core/presence/relay-client.ts +5 -5
  577. package/src/core/work/index.ts +3 -0
  578. package/src/core/work/read.ts +3 -0
  579. package/src/core/work/runner.ts +6 -0
  580. package/src/core/work/state.ts +27 -3
  581. package/src/core/workflow/engine.ts +24 -24
  582. package/src/core/workflow/live-session-v3.ts +126 -0
  583. package/src/core/workflow/scope-id.ts +6 -0
  584. package/src/core/workflow/workspaces/leases.ts +56 -19
  585. package/src/index.ts +1 -1
  586. package/src/lib/browser/client.ts +230 -0
  587. package/src/lib/browser/critique.ts +104 -27
  588. package/src/lib/browser/geometry.ts +143 -14
  589. package/src/lib/browser/index.ts +34 -0
  590. package/src/lib/browser/qa-plan.ts +501 -0
  591. package/src/lib/browser/qa-reuse.ts +306 -0
  592. package/src/lib/browser/qa-snapshot.ts +223 -0
  593. package/src/lib/browser/runts.ts +27 -2
  594. package/src/lib/browser/tiling.ts +164 -0
  595. package/src/lib/claude-desktop.ts +1 -232
  596. package/src/lib/context/index.ts +22 -46
  597. package/src/lib/council/index.ts +9 -21
  598. package/src/lib/docs-frontmatter.ts +8 -79
  599. package/src/lib/docs-index.ts +33 -3
  600. package/src/lib/docs-lint.ts +15 -29
  601. package/src/lib/docs-metadata-audit.ts +166 -0
  602. package/src/lib/docs-metadata-managed.ts +83 -0
  603. package/src/lib/docs-metadata-sync.ts +262 -0
  604. package/src/lib/docs-metadata-v2-schema.ts +138 -0
  605. package/src/lib/docs-metadata-v2.ts +646 -0
  606. package/src/lib/docs-new.ts +63 -0
  607. package/src/lib/docs-sweep.ts +42 -28
  608. package/src/lib/headless/index.ts +287 -0
  609. package/src/lib/identities/assume.ts +67 -86
  610. package/src/lib/instructions/apply.ts +33 -20
  611. package/src/lib/instructions/bundle.ts +2 -2
  612. package/src/lib/instructions/splice.ts +21 -7
  613. package/src/lib/instructions/templates.ts +85 -13
  614. package/dist/core/agents/cli-emit.d.ts +0 -27
  615. package/dist/core/agents/cli-emit.d.ts.map +0 -1
  616. package/dist/core/agents/cli-emit.js +0 -57
  617. package/dist/core/agents/codex-replay.d.ts +0 -29
  618. package/dist/core/agents/codex-replay.d.ts.map +0 -1
  619. package/dist/core/agents/codex-replay.js +0 -138
  620. package/dist/core/agents/events/consume.d.ts +0 -82
  621. package/dist/core/agents/events/consume.d.ts.map +0 -1
  622. package/dist/core/agents/events/consume.js +0 -195
  623. package/dist/core/agents/events/emit.d.ts +0 -42
  624. package/dist/core/agents/events/emit.d.ts.map +0 -1
  625. package/dist/core/agents/events/emit.js +0 -75
  626. package/dist/core/agents/events/ulid.d.ts +0 -11
  627. package/dist/core/agents/events/ulid.d.ts.map +0 -1
  628. package/dist/core/agents/events/ulid.js +0 -47
  629. package/dist/core/agents/state/heartbeat-projector.d.ts +0 -76
  630. package/dist/core/agents/state/heartbeat-projector.d.ts.map +0 -1
  631. package/dist/core/agents/state/heartbeat-projector.js +0 -581
  632. package/dist/core/hooks/events/emit.d.ts +0 -31
  633. package/dist/core/hooks/events/emit.d.ts.map +0 -1
  634. package/dist/core/hooks/events/emit.js +0 -93
  635. package/dist/core/hooks/events/rotate.d.ts +0 -43
  636. package/dist/core/hooks/events/rotate.d.ts.map +0 -1
  637. package/dist/core/hooks/events/rotate.js +0 -142
  638. package/dist/core/hooks/events/schema.d.ts +0 -341
  639. package/dist/core/hooks/events/schema.d.ts.map +0 -1
  640. package/dist/core/hooks/events/schema.js +0 -12
  641. package/dist/core/hooks/events/ulid.d.ts +0 -10
  642. package/dist/core/hooks/events/ulid.d.ts.map +0 -1
  643. package/dist/core/hooks/events/ulid.js +0 -47
  644. package/dist/lib/docs-frontmatter-migrate.d.ts +0 -33
  645. package/dist/lib/docs-frontmatter-migrate.d.ts.map +0 -1
  646. package/dist/lib/docs-frontmatter-migrate.js +0 -364
  647. package/src/core/agents/cli-emit.ts +0 -64
  648. package/src/core/agents/codex-replay.ts +0 -163
  649. package/src/core/agents/events/consume.ts +0 -254
  650. package/src/core/agents/events/emit.ts +0 -115
  651. package/src/core/agents/events/ulid.ts +0 -51
  652. package/src/core/agents/state/heartbeat-projector.ts +0 -645
  653. package/src/core/hooks/events/emit.ts +0 -125
  654. package/src/core/hooks/events/rotate.ts +0 -151
  655. package/src/core/hooks/events/schema.ts +0 -582
  656. package/src/core/hooks/events/ulid.ts +0 -51
  657. package/src/lib/docs-frontmatter-migrate.ts +0 -427
@@ -14,8 +14,9 @@
14
14
  * so a fresh consumer gets a CLAUDE.md whose managed region imports
15
15
  * `@AGENTS.md`. A CLAUDE.md that already imports AGENTS.md or already carries
16
16
  * the block (a host that generates CLAUDE.md from AGENTS.md) is left alone.
17
- * - `.claude/skills/<skill>/SKILL.md` — claude-code only; fully-owned files,
18
- * honoring `skills.exclude` in `.harnery/config.jsonc`.
17
+ * - `<adapter-skill-dir>/<skill>/SKILL.md` — fully-owned files, honoring
18
+ * `skills.exclude` in `.harnery/config.jsonc`. Claude Code uses
19
+ * `.claude/skills/`; Cursor and Codex use `.agents/skills/`.
19
20
  */
20
21
 
21
22
  import {
@@ -49,7 +50,15 @@ import {
49
50
 
50
51
  const AGENTS_FILE = "AGENTS.md";
51
52
  const CLAUDE_FILE = "CLAUDE.md";
52
- const CLAUDE_SKILLS_DIR = join(".claude", "skills");
53
+ const ADAPTER_SKILLS_DIR: Readonly<Record<string, string>> = {
54
+ "claude-code": join(".claude", "skills"),
55
+ cursor: join(".agents", "skills"),
56
+ codex: join(".agents", "skills"),
57
+ };
58
+
59
+ function adapterSkillsDir(adapter: string): string | null {
60
+ return ADAPTER_SKILLS_DIR[adapter] ?? null;
61
+ }
53
62
 
54
63
  /** CLAUDE.md import-shim body: points Claude Code (which reads CLAUDE.md, not AGENTS.md) at AGENTS.md. */
55
64
  function importBody(): string {
@@ -79,16 +88,17 @@ export function readSkillsExclude(projectRoot: string): Set<string> {
79
88
 
80
89
  /**
81
90
  * Which shipped skills exist for this project, so the block references only the
82
- * ones actually present: claude-code writes skills (unless excluded); cursor and
83
- * codex get the block but no skill files, so both read false there. Kept in one
84
- * place so `applyInstructions` and `checkInstructions` render byte-identical blocks.
91
+ * ones actually present for every supported adapter, unless excluded. Kept in
92
+ * one place so `applyInstructions` and `checkInstructions` render byte-identical
93
+ * blocks.
85
94
  */
86
95
  function blockSkills(projectRoot: string, adapter: string): BlockSkills {
87
- const claudeCode = adapter === "claude-code";
96
+ const supported = adapterSkillsDir(adapter) !== null;
88
97
  const exclude = readSkillsExclude(projectRoot);
89
98
  return {
90
- decide: claudeCode && !exclude.has("harn-decide"),
91
- council: claudeCode && !exclude.has("harn-council"),
99
+ decide: supported && !exclude.has("harn-decide"),
100
+ council: supported && !exclude.has("harn-council"),
101
+ end: supported && !exclude.has("harn-end"),
92
102
  };
93
103
  }
94
104
 
@@ -105,13 +115,14 @@ export interface ApplyResult {
105
115
 
106
116
  /**
107
117
  * Inject / refresh the instructions block, the CLAUDE.md import shim (claude-code),
108
- * and the shipped skills (claude-code). Idempotent: a re-run on current content
118
+ * and the adapter-native shipped skills. Idempotent: a re-run on current content
109
119
  * writes nothing. `dryRun` reports without touching the fs.
110
120
  */
111
121
  export function applyInstructions(projectRoot: string, opts: ApplyOpts): ApplyResult {
112
122
  const actions: string[] = [];
113
123
  const warnings: string[] = [];
114
124
  const claudeCode = opts.adapter === "claude-code";
125
+ const skillsDir = adapterSkillsDir(opts.adapter);
115
126
  // dry-run narrates the future ("would create"); a real run narrates the past.
116
127
  const verbed = (base: string, past: string) => (opts.dryRun ? `would ${base}` : past);
117
128
 
@@ -191,15 +202,15 @@ export function applyInstructions(projectRoot: string, opts: ApplyOpts): ApplyRe
191
202
  }
192
203
  }
193
204
 
194
- // ── shipped skills (claude-code only) ───────────────────────────────────
195
- if (claudeCode) {
205
+ // ── shipped skills ───────────────────────────────────────────────────────
206
+ if (skillsDir) {
196
207
  const exclude = readSkillsExclude(projectRoot);
197
208
  for (const skill of SKILLS) {
198
209
  if (exclude.has(skill.id)) {
199
210
  actions.push(`· skipped skill ${skill.id} (skills.exclude)`);
200
211
  continue;
201
212
  }
202
- const skillPath = join(projectRoot, CLAUDE_SKILLS_DIR, skill.relPath);
213
+ const skillPath = join(projectRoot, skillsDir, skill.relPath);
203
214
  const content = skill.render(opts.binName);
204
215
  const before = existsSync(skillPath) ? readFileSync(skillPath, "utf8") : null;
205
216
  if (before === content) {
@@ -235,6 +246,7 @@ export function removeInstructions(projectRoot: string, opts: RemoveOpts): Apply
235
246
  const actions: string[] = [];
236
247
  const warnings: string[] = [];
237
248
  const claudeCode = opts.adapter === "claude-code";
249
+ const skillsDir = adapterSkillsDir(opts.adapter);
238
250
 
239
251
  // ── AGENTS.md block + host addendum ─────────────────────────────────────
240
252
  const agentsPath = join(projectRoot, AGENTS_FILE);
@@ -288,10 +300,10 @@ export function removeInstructions(projectRoot: string, opts: RemoveOpts): Apply
288
300
  }
289
301
  }
290
302
 
291
- // ── shipped skills (claude-code) ────────────────────────────────────────
292
- if (claudeCode) {
303
+ // ── shipped skills ───────────────────────────────────────────────────────
304
+ if (skillsDir) {
293
305
  for (const skill of SKILLS) {
294
- const skillPath = join(projectRoot, CLAUDE_SKILLS_DIR, skill.relPath);
306
+ const skillPath = join(projectRoot, skillsDir, skill.relPath);
295
307
  if (!existsSync(skillPath)) continue;
296
308
  if (!isOwnedFile(readFileSync(skillPath, "utf8"))) {
297
309
  warnings.push(`left ${skill.relPath} (hand-edited; no harnery ownership marker)`);
@@ -299,7 +311,7 @@ export function removeInstructions(projectRoot: string, opts: RemoveOpts): Apply
299
311
  }
300
312
  if (!opts.dryRun) {
301
313
  rmSync(skillPath);
302
- // drop the now-empty skill dir (harn-decide/), leaving .claude/skills/ intact
314
+ // Drop the now-empty harn-* dir, leaving the adapter skills root intact.
303
315
  const dir = dirname(skillPath);
304
316
  try {
305
317
  if (readdirSync(dir).length === 0) rmdirSync(dir);
@@ -321,7 +333,7 @@ export interface CheckResult {
321
333
 
322
334
  /**
323
335
  * Read-only drift report for `init --check`: the AGENTS.md block and each
324
- * shipped skill (claude-code). Fresh → exit 0; any stale / missing / hand-edit
336
+ * shipped skill for the selected adapter. Fresh → exit 0; stale / missing / hand-edit
325
337
  * → drift (exit 2); an unreadable file → error (exit 1). Mirrors the wiki-theme
326
338
  * `--check-only` contract the first host wires into pre-commit.
327
339
  */
@@ -361,11 +373,12 @@ export function checkInstructions(
361
373
  issues.push(`${AGENTS_FILE} host addendum: present but no longer configured (re-run init)`);
362
374
  }
363
375
 
364
- if (opts.adapter === "claude-code") {
376
+ const skillsDir = adapterSkillsDir(opts.adapter);
377
+ if (skillsDir) {
365
378
  const exclude = readSkillsExclude(projectRoot);
366
379
  for (const skill of SKILLS) {
367
380
  if (exclude.has(skill.id)) continue;
368
- const skillPath = join(projectRoot, CLAUDE_SKILLS_DIR, skill.relPath);
381
+ const skillPath = join(projectRoot, skillsDir, skill.relPath);
369
382
  const c = existsSync(skillPath) ? readFileSync(skillPath, "utf8") : "";
370
383
  note(`skill ${skill.id}`, checkOwnedSkill(c, skillBody(skill.render, opts.binName)));
371
384
  }
@@ -1,7 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { existsSync, lstatSync, readdirSync, readFileSync } from "node:fs";
3
3
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
4
- import type { Adapter } from "../../core/hooks/events/schema.ts";
4
+ import type { Adapter } from "../../core/adapter.ts";
5
5
 
6
6
  export type InstructionComponentRole = "always_loaded" | "just_in_time" | "runtime_config";
7
7
 
@@ -109,7 +109,7 @@ function adapterCandidates(root: string, adapter: Adapter): Candidate[] {
109
109
  addFile(join(root, ".cursor", "hooks.json"), "runtime_config");
110
110
  } else {
111
111
  addFile(join(root, "AGENTS.md"), "always_loaded");
112
- addTree(join(root, ".harnery", "skills"), "just_in_time");
112
+ addTree(join(root, ".agents", "skills"), "just_in_time");
113
113
  addFile(join(root, ".codex", "hooks.json"), "runtime_config");
114
114
  }
115
115
 
@@ -32,6 +32,24 @@ function escapeRe(s: string): string {
32
32
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
33
33
  }
34
34
 
35
+ function trimHorizontalWhitespaceBeforeNewlines(content: string): string {
36
+ const chunks: string[] = [];
37
+ let segmentStart = 0;
38
+ for (let index = 0; index < content.length; index++) {
39
+ if (content.charCodeAt(index) !== 10) continue;
40
+ let segmentEnd = index;
41
+ while (segmentEnd > segmentStart) {
42
+ const code = content.charCodeAt(segmentEnd - 1);
43
+ if (code !== 32 && code !== 9) break;
44
+ segmentEnd--;
45
+ }
46
+ chunks.push(content.slice(segmentStart, segmentEnd), "\n");
47
+ segmentStart = index + 1;
48
+ }
49
+ chunks.push(content.slice(segmentStart));
50
+ return chunks.join("");
51
+ }
52
+
35
53
  /**
36
54
  * Marker comment style. Markdown/HTML files wrap markers in HTML comments;
37
55
  * shell files (git hooks) use `#` line comments. The style only changes the
@@ -94,7 +112,7 @@ export function spliceRegion(
94
112
  const text = content.replace(re, () => fresh);
95
113
  return { text, changed: text !== content, had: true, stale };
96
114
  }
97
- const trimmed = content.replace(/\s+$/, "");
115
+ const trimmed = content.trimEnd();
98
116
  const text = trimmed ? `${trimmed}\n\n${fresh}\n` : `${fresh}\n`;
99
117
  return { text, changed: true, had: false, stale: false };
100
118
  }
@@ -112,9 +130,7 @@ export function removeRegion(
112
130
  ): { text: string; removed: boolean } {
113
131
  const re = regionRe(region, style);
114
132
  if (!re.test(content)) return { text: content, removed: false };
115
- const stripped = content
116
- .replace(re, "")
117
- .replace(/[ \t]+\n/g, "\n")
133
+ const stripped = trimHorizontalWhitespaceBeforeNewlines(content.replace(re, ""))
118
134
  .replace(/\n{3,}/g, "\n\n")
119
135
  .trim();
120
136
  return { text: stripped ? `${stripped}\n` : "", removed: true };
@@ -150,15 +166,13 @@ export function isOwnedFile(content: string): boolean {
150
166
  export function buildOwnedSkill(opts: {
151
167
  name: string;
152
168
  description: string;
153
- argumentHint?: string;
154
169
  binName: string;
155
170
  body: string;
156
171
  }): string {
157
172
  const fm = [
158
173
  "---",
159
174
  `name: ${opts.name}`,
160
- `description: ${opts.description}`,
161
- ...(opts.argumentHint ? [`argument-hint: ${JSON.stringify(opts.argumentHint)}`] : []),
175
+ `description: ${JSON.stringify(opts.description)}`,
162
176
  "---",
163
177
  ].join("\n");
164
178
  const body = opts.body.trim();
@@ -28,10 +28,12 @@ export const HOST_ADDENDUM_REGION = "host-addendum";
28
28
 
29
29
  /** Which shipped skills exist in the project the block is rendered for. */
30
30
  export interface BlockSkills {
31
- /** the `harn-decide` skill file is present (claude-code, not excluded) */
31
+ /** the `harn-decide` skill file is present */
32
32
  decide: boolean;
33
33
  /** the `harn-council` skill file is present */
34
34
  council: boolean;
35
+ /** the `harn-end` skill file is present */
36
+ end: boolean;
35
37
  }
36
38
 
37
39
  /**
@@ -39,22 +41,24 @@ export interface BlockSkills {
39
41
  * lines: it costs every agent context on every turn, so it states that each
40
42
  * surface *exists* and gives one line of *when* — the *how* lives in the skills
41
43
  * and each command's `--help`. Skill names are fixed (`harn-decide`,
42
- * `harn-council`) even for a renamed bin; only command strings track `binName`.
44
+ * `harn-council`, `harn-end`) even for a renamed bin; only command strings
45
+ * track `binName`.
43
46
  *
44
47
  * The block only points at a skill that actually exists here: a host that
45
- * excludes one via `skills.exclude`, or a adapter with no skill primitive
46
- * (cursor/codex get the block but no skill files), gets a `--help` pointer
47
- * instead of a dangling reference to a skill it doesn't have.
48
+ * excludes one via `skills.exclude` gets a CLI pointer instead of a dangling
49
+ * reference to a skill it doesn't have.
48
50
  */
49
51
  export function renderInstructionsBlock(
50
52
  binName: string,
51
- skills: BlockSkills = { decide: true, council: true },
53
+ skills: BlockSkills = { decide: true, council: true, end: true },
52
54
  ): string {
53
55
  const b = binName;
54
56
 
55
- const named = [skills.decide && "`harn-decide`", skills.council && "`harn-council`"].filter(
56
- Boolean,
57
- ) as string[];
57
+ const named = [
58
+ skills.decide && "`harn-decide`",
59
+ skills.council && "`harn-council`",
60
+ skills.end && "`harn-end`",
61
+ ].filter(Boolean) as string[];
58
62
  const deeper =
59
63
  named.length > 0
60
64
  ? `Procedures for the deeper flows live in the ${named.join(" and ")} skill${named.length > 1 ? "s" : ""}.`
@@ -65,6 +69,9 @@ export function renderInstructionsBlock(
65
69
  const councilPointer = skills.council
66
70
  ? "The `harn-council` skill has the steward and member flow."
67
71
  : `See \`${b} agents council --help\` for the steward and member flow.`;
72
+ const endPointer = skills.end
73
+ ? "When the whole session is genuinely finished, use the `harn-end` skill as the final workflow."
74
+ : `When the whole session is genuinely finished, run \`${b} agents status --end-turn --end-session\` as the final tool action.`;
68
75
  // Render the journal categories from the canonical enum so this prose can
69
76
  // never drift from what `journal add` actually accepts (the "note, plan…" list
70
77
  // silently lagged the tool by two categories before this).
@@ -87,6 +94,14 @@ active peers and the files they've claimed; \`${b} agents set-task "<focus>"\`
87
94
  declares your current focus so peers can see it. Check for peers before editing
88
95
  widely-shared files.
89
96
 
97
+ **Task lifecycle.** Beside the activity peers already see, declare whether your
98
+ objective is still open: \`${b} agents lifecycle blocked --reason "<why>"\` when
99
+ it cannot proceed, \`${b} agents lifecycle done\` when it is complete, and
100
+ \`${b} agents lifecycle active\` to reopen. \`done\` requires a current task and
101
+ a passing Git finalization check (dirty or unpushed work refuses, and nothing is
102
+ written). Ordinary \`set-task\` calls never change lifecycle, and a transition
103
+ that re-mints the session title tells you the new name to copy. ${endPointer}
104
+
90
105
  **Dispatching a team.** Everything else here coordinates the agents already
91
106
  present. These three start new ones, and they differ by how long the objective
92
107
  outlives a single execution. \`${b} run <script>\` is one bounded pass:
@@ -251,7 +266,7 @@ The web UI is the member + steward picker; don't create from the CLI (that skips
251
266
  the steward choice). Emit the link with the objective URL-encoded:
252
267
 
253
268
  \`\`\`
254
- http://localhost:9000/councils/new?objective=<encoded>
269
+ http://localhost:4276/councils/new?objective=<encoded>
255
270
  \`\`\`
256
271
 
257
272
  If the dev server isn't up, start it with \`${b} web up\`.
@@ -307,6 +322,54 @@ mismatch), and offer the right next step. Don't propose a workaround that bypass
307
322
  the guard.`;
308
323
  }
309
324
 
325
+ function endBody(b: string): string {
326
+ return `Finalize only after the work is genuinely complete. This is the deliberate,
327
+ high-confidence escape hatch for adapters that do not provide a trustworthy
328
+ native session-end callback.
329
+
330
+ ## Workflow
331
+
332
+ 1. Finish all in-scope work, tests, documentation, commits, pushes, and
333
+ user-facing reporting first.
334
+ 2. Confirm no tool call, open turn, delegated child, file claim, or uncommitted
335
+ session write remains. Do not fabricate completion or use this skill to hide
336
+ unfinished work.
337
+ 3. Run the closing status and end request as the final tool action:
338
+
339
+ \`\`\`bash
340
+ ${b} agents status --end-turn --end-session
341
+ \`\`\`
342
+
343
+ When automatic identity resolution is unavailable, pass the current native
344
+ adapter session ID with \`--session-id <id>\`. The command durably queues the
345
+ authoritative end while it is still running. The adapter's stop hook records
346
+ \`session.ended\` only after this command, its tool span, and the current turn
347
+ have closed.
348
+ 4. Do not run another tool after a successful request. Reproduce the status
349
+ output, tell the operator the end is queued, and yield. The terminal event ID
350
+ becomes available after the response completes and can be verified from a
351
+ later session or the web UI.
352
+
353
+ ## Refusals and recovery
354
+
355
+ - If the command reports delegated work, finish or explicitly cancel those
356
+ children, then try again.
357
+ - If Git finalization fails, complete the repository's required commit and push
358
+ workflow before retrying.
359
+ - If the V3 ledger is unavailable or unsafe, do not fall back to deleting a
360
+ projection or writing a synthetic ledger row. Report the failure.
361
+ - Starting a new turn or tool after the request cancels the pending end. Run the
362
+ workflow again when the session is actually finished.
363
+ - On a manual \`${b} agents end\` call, use \`--outcome failed\`, \`cancelled\`,
364
+ \`interrupted\`, or \`unknown\` only when that describes the completed session
365
+ honestly.
366
+
367
+ Never use this skill to end another operator's session unless the operator
368
+ explicitly identifies it. Use the web control or \`${b} agents end --instance-id
369
+ <id>\` for that operator action; it records immediately for an idle session or
370
+ durably queues the end for its current turn.`;
371
+ }
372
+
310
373
  export const SKILLS: SkillTemplate[] = [
311
374
  {
312
375
  id: "harn-decide",
@@ -316,7 +379,6 @@ export const SKILLS: SkillTemplate[] = [
316
379
  name: "harn-decide",
317
380
  description:
318
381
  "File a decision into the docket instead of blocking on a human: search precedent, file it, and proceed on a reversible default; or pick up and resolve an open decision with cited evidence. Use whenever you're about to ask a human a decision-shaped question you could resolve yourself.",
319
- argumentHint: "[<the decision / question you're facing> | resolve <id> | review]",
320
382
  binName,
321
383
  body: decideBody(binName),
322
384
  }),
@@ -329,10 +391,20 @@ export const SKILLS: SkillTemplate[] = [
329
391
  name: "harn-council",
330
392
  description:
331
393
  "Interact with the multi-agent council system: list / create / show / prompts (steward) / contribute (member). Guards against misrouting: refuses to contribute when you aren't a member, have already contributed, or weren't routed a prompt.",
332
- argumentHint:
333
- "[<id-or-fragment> | create <objective> | contribute <id> | prompts <id> | show <id>]",
334
394
  binName,
335
395
  body: councilBody(binName),
336
396
  }),
337
397
  },
398
+ {
399
+ id: "harn-end",
400
+ relPath: "harn-end/SKILL.md",
401
+ render: (binName) =>
402
+ buildOwnedSkill({
403
+ name: "harn-end",
404
+ description:
405
+ "Safely finalize the current Harnery agent session with an authoritative V3 session-ended event. Use when the operator says /harn-end, asks to end or close the current session, or when all work is complete and the session should stop counting as live.",
406
+ binName,
407
+ body: endBody(binName),
408
+ }),
409
+ },
338
410
  ];
@@ -1,27 +0,0 @@
1
- /**
2
- * CLI-side canonical event emission helper. Importable from any CLI surface
3
- * to emit-then-project in one call.
4
- *
5
- * Pattern: every state-changing CLI command appends its event first, then
6
- * runs the projector synchronously for the affected owner.
7
- */
8
- import { type EmitInput, type Envelope } from "./events/emit.js";
9
- export interface EmitAndProjectResult {
10
- envelope: Envelope;
11
- projected: boolean;
12
- }
13
- /**
14
- * Emit a canonical event AND synchronously project it into the owner's v2
15
- * heartbeat. Idempotent on event_id: replays don't double-apply.
16
- *
17
- * Returns the emitted envelope so callers can inspect / log.
18
- *
19
- * Soft-fails on any internal error: never throws into the caller, because
20
- * this runs inside operator-facing CLI commands and a corrupt events.ndjson
21
- * line shouldn't break `agents set-task`.
22
- */
23
- export declare function emitAndProject(input: EmitInput, opts?: {
24
- coordRoot?: string;
25
- skipProject?: boolean;
26
- }): EmitAndProjectResult | null;
27
- //# sourceMappingURL=cli-emit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli-emit.d.ts","sourceRoot":"","sources":["../../../src/core/agents/cli-emit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAQ,MAAM,kBAAkB,CAAC;AAIvE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,EAChB,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACvD,oBAAoB,GAAG,IAAI,CAiC7B"}
@@ -1,57 +0,0 @@
1
- /**
2
- * CLI-side canonical event emission helper. Importable from any CLI surface
3
- * to emit-then-project in one call.
4
- *
5
- * Pattern: every state-changing CLI command appends its event first, then
6
- * runs the projector synchronously for the affected owner.
7
- */
8
- import { emit } from "./events/emit.js";
9
- import { findCoordRoot } from "./paths.js";
10
- import { projectHeartbeats } from "./state/heartbeat-projector.js";
11
- /**
12
- * Emit a canonical event AND synchronously project it into the owner's v2
13
- * heartbeat. Idempotent on event_id: replays don't double-apply.
14
- *
15
- * Returns the emitted envelope so callers can inspect / log.
16
- *
17
- * Soft-fails on any internal error: never throws into the caller, because
18
- * this runs inside operator-facing CLI commands and a corrupt events.ndjson
19
- * line shouldn't break `agents set-task`.
20
- */
21
- export function emitAndProject(input, opts = {}) {
22
- const root = opts.coordRoot ?? findCoordRoot();
23
- if (!root)
24
- return null;
25
- try {
26
- const envelope = emit(root, input);
27
- let projected = false;
28
- if (!opts.skipProject) {
29
- try {
30
- projectHeartbeats(root, [
31
- {
32
- schema_version: envelope.schema_version,
33
- event_id: envelope.event_id,
34
- event_type: envelope.event_type,
35
- ts: envelope.ts,
36
- instance_id: envelope.instance_id,
37
- session_id: envelope.session_id,
38
- parent_session_id: envelope.parent_session_id,
39
- turn_id: envelope.turn_id,
40
- parent_turn_id: envelope.parent_turn_id,
41
- adapter: envelope.adapter,
42
- source: envelope.source,
43
- data: envelope.data,
44
- },
45
- ]);
46
- projected = true;
47
- }
48
- catch {
49
- /* projector failure is non-fatal; next agent-coord project run catches up */
50
- }
51
- }
52
- return { envelope, projected };
53
- }
54
- catch {
55
- return null;
56
- }
57
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Codex JSONL → canonical event replay.
3
- *
4
- * Production codex sessions emit canonical events from each `harn` invocation
5
- * via the in-process session-tee middleware (which calls `agent-coord
6
- * emit-event` for state.task_set / state.status_checked). But the codex
7
- * adapter itself doesn't wire agent-hook on preToolUse, so user_prompt.submit
8
- * + tool.pre_use + turn.stop aren't emitted live.
9
- *
10
- * This module parses the Codex JSONL transcript at stop time and emits the
11
- * missing canonical events so the verdict has a complete turn-window view.
12
- *
13
- * Scope: just the events the stop-hook verdict reads: user_prompt.submit,
14
- * tool.pre_use (for exec_command function calls), state.status_checked
15
- * (when the cmd contains `<bin> agents status`), state.task_set (when the cmd
16
- * contains `<bin> agents set-task`), turn.stop (with status_box_present derived
17
- * from the last_assistant_message).
18
- */
19
- export interface CodexReplayOpts {
20
- coordRoot: string;
21
- sessionId: string;
22
- instanceId: string;
23
- jsonlPath: string;
24
- lastAssistantMessage?: string;
25
- }
26
- export declare function replayCodexJsonl(opts: CodexReplayOpts): {
27
- emitted: number;
28
- };
29
- //# sourceMappingURL=codex-replay.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codex-replay.d.ts","sourceRoot":"","sources":["../../../src/core/agents/codex-replay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAkBH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAkH3E"}
@@ -1,138 +0,0 @@
1
- /**
2
- * Codex JSONL → canonical event replay.
3
- *
4
- * Production codex sessions emit canonical events from each `harn` invocation
5
- * via the in-process session-tee middleware (which calls `agent-coord
6
- * emit-event` for state.task_set / state.status_checked). But the codex
7
- * adapter itself doesn't wire agent-hook on preToolUse, so user_prompt.submit
8
- * + tool.pre_use + turn.stop aren't emitted live.
9
- *
10
- * This module parses the Codex JSONL transcript at stop time and emits the
11
- * missing canonical events so the verdict has a complete turn-window view.
12
- *
13
- * Scope: just the events the stop-hook verdict reads: user_prompt.submit,
14
- * tool.pre_use (for exec_command function calls), state.status_checked
15
- * (when the cmd contains `<bin> agents status`), state.task_set (when the cmd
16
- * contains `<bin> agents set-task`), turn.stop (with status_box_present derived
17
- * from the last_assistant_message).
18
- */
19
- import { existsSync, readFileSync } from "node:fs";
20
- import { emit } from "./events/emit.js";
21
- const STATUS_BOX_PREFIX = "┌─ agent-";
22
- export function replayCodexJsonl(opts) {
23
- const { coordRoot, sessionId, instanceId, jsonlPath, lastAssistantMessage } = opts;
24
- if (!existsSync(jsonlPath))
25
- return { emitted: 0 };
26
- let raw;
27
- try {
28
- raw = readFileSync(jsonlPath, "utf8");
29
- }
30
- catch {
31
- return { emitted: 0 };
32
- }
33
- let emitted = 0;
34
- const lines = raw.split("\n");
35
- for (const line of lines) {
36
- if (!line.trim())
37
- continue;
38
- let entry;
39
- try {
40
- entry = JSON.parse(line);
41
- }
42
- catch {
43
- continue;
44
- }
45
- const ts = entry.timestamp;
46
- const t = entry.type;
47
- if (t === "event_msg" && entry.payload?.type === "user_message") {
48
- emit(coordRoot, {
49
- event_type: "user_prompt.submit",
50
- instance_id: instanceId,
51
- session_id: sessionId,
52
- adapter: "codex",
53
- ts,
54
- data: {
55
- prompt_text: clamp(entry.payload.message ?? "", 4000),
56
- },
57
- });
58
- emitted += 1;
59
- continue;
60
- }
61
- if (t === "response_item" && entry.payload?.type === "function_call") {
62
- const name = entry.payload.name ?? "";
63
- let cmd = "";
64
- if (entry.payload.arguments) {
65
- try {
66
- const parsed = JSON.parse(entry.payload.arguments);
67
- cmd = parsed.cmd ?? "";
68
- }
69
- catch {
70
- /* skip */
71
- }
72
- }
73
- // Emit tool.pre_use for every function call.
74
- emit(coordRoot, {
75
- event_type: "tool.pre_use",
76
- instance_id: instanceId,
77
- session_id: sessionId,
78
- adapter: "codex",
79
- ts,
80
- data: {
81
- tool_name: name === "exec_command" ? "Bash" : name,
82
- tool_input: JSON.stringify({ command: cmd }),
83
- intent: "",
84
- intent_source: "codex-replay",
85
- },
86
- });
87
- emitted += 1;
88
- // Match `<bin> agents status` / `<bin> agents set-task`, bin-agnostic, so
89
- // it works for harn or any host CLI that composes harnery (a consumer's own
90
- // binary). Wrapped invocations (cd && <bin> ...; PATH=... <bin> ...) pass
91
- // because we scan the whole cmd string and anchor on the token before `agents`.
92
- if (/(^|\s|;|&&)[\w./-]+\s+agents\s+status(\b|$)/.test(cmd)) {
93
- emit(coordRoot, {
94
- event_type: "state.status_checked",
95
- instance_id: instanceId,
96
- session_id: sessionId,
97
- adapter: "codex",
98
- ts,
99
- data: { source: "codex-replay" },
100
- });
101
- emitted += 1;
102
- }
103
- if (/(^|\s|;|&&)[\w./-]+\s+agents\s+set-task(\b|$)/.test(cmd)) {
104
- emit(coordRoot, {
105
- event_type: "state.task_set",
106
- instance_id: instanceId,
107
- session_id: sessionId,
108
- adapter: "codex",
109
- ts,
110
- data: { source: "codex-replay" },
111
- });
112
- emitted += 1;
113
- }
114
- }
115
- }
116
- // Finally, emit turn.stop with status_box_present derived from the last
117
- // assistant message (codex's stop payload carries the assistant text
118
- // directly, unlike CC which only has transcript_path).
119
- const boxPresent = !!lastAssistantMessage && lastAssistantMessage.includes(STATUS_BOX_PREFIX);
120
- emit(coordRoot, {
121
- event_type: "turn.stop",
122
- instance_id: instanceId,
123
- session_id: sessionId,
124
- adapter: "codex",
125
- data: {
126
- status_box_present: boxPresent,
127
- tool_call_count: -1,
128
- text_length: lastAssistantMessage?.length ?? 0,
129
- },
130
- });
131
- emitted += 1;
132
- return { emitted };
133
- }
134
- function clamp(s, max) {
135
- if (s.length <= max)
136
- return s;
137
- return s.slice(0, max);
138
- }