harnery 0.30.0 → 0.31.1

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 (517) hide show
  1. package/README.md +4 -4
  2. package/dist/commander.d.ts +8 -0
  3. package/dist/commander.d.ts.map +1 -1
  4. package/dist/commander.js +14 -13
  5. package/dist/commands/adapter.d.ts +12 -0
  6. package/dist/commands/adapter.d.ts.map +1 -0
  7. package/dist/commands/{harness.js → adapter.js} +35 -35
  8. package/dist/commands/agents.d.ts +3 -2
  9. package/dist/commands/agents.d.ts.map +1 -1
  10. package/dist/commands/agents.js +185 -74
  11. package/dist/commands/artifacts.d.ts +4 -0
  12. package/dist/commands/artifacts.d.ts.map +1 -0
  13. package/dist/commands/artifacts.js +143 -0
  14. package/dist/commands/backup.d.ts +1 -1
  15. package/dist/commands/backup.d.ts.map +1 -1
  16. package/dist/commands/backup.js +5 -2
  17. package/dist/commands/browse.d.ts.map +1 -1
  18. package/dist/commands/browse.js +310 -7
  19. package/dist/commands/checkpoint.d.ts +12 -0
  20. package/dist/commands/checkpoint.d.ts.map +1 -0
  21. package/dist/commands/checkpoint.js +162 -0
  22. package/dist/commands/context.d.ts +2 -2
  23. package/dist/commands/context.d.ts.map +1 -1
  24. package/dist/commands/context.js +3 -151
  25. package/dist/commands/decision.d.ts.map +1 -1
  26. package/dist/commands/decision.js +31 -7
  27. package/dist/commands/deinit.d.ts +2 -2
  28. package/dist/commands/deinit.js +15 -15
  29. package/dist/commands/doctor.js +23 -23
  30. package/dist/commands/governor.d.ts +4 -0
  31. package/dist/commands/governor.d.ts.map +1 -0
  32. package/dist/commands/{supervisor.js → governor.js} +133 -108
  33. package/dist/commands/grep.d.ts +1 -1
  34. package/dist/commands/grep.d.ts.map +1 -1
  35. package/dist/commands/grep.js +19 -2
  36. package/dist/commands/init.d.ts +12 -12
  37. package/dist/commands/init.d.ts.map +1 -1
  38. package/dist/commands/init.js +44 -30
  39. package/dist/commands/{session.d.ts → journal.d.ts} +2 -2
  40. package/dist/commands/journal.d.ts.map +1 -0
  41. package/dist/commands/{scratch.js → journal.js} +47 -47
  42. package/dist/commands/policy.js +1 -1
  43. package/dist/commands/presence.js +2 -2
  44. package/dist/commands/sync.d.ts +1 -1
  45. package/dist/commands/sync.js +3 -3
  46. package/dist/commands/tunnel.d.ts +16 -0
  47. package/dist/commands/tunnel.d.ts.map +1 -1
  48. package/dist/commands/tunnel.js +213 -27
  49. package/dist/commands/web-fetch.js +1 -1
  50. package/dist/commands/web.d.ts +19 -0
  51. package/dist/commands/web.d.ts.map +1 -1
  52. package/dist/commands/web.js +51 -0
  53. package/dist/commands/work.d.ts.map +1 -1
  54. package/dist/commands/work.js +38 -22
  55. package/dist/commands/workflow.d.ts.map +1 -1
  56. package/dist/commands/workflow.js +35 -28
  57. package/dist/core/{harnesses → adapters}/attest-projection.d.ts +2 -2
  58. package/dist/core/adapters/attest-projection.d.ts.map +1 -0
  59. package/dist/core/{harnesses → adapters}/attest.d.ts +16 -16
  60. package/dist/core/adapters/attest.d.ts.map +1 -0
  61. package/dist/core/{harnesses → adapters}/attest.js +9 -9
  62. package/dist/core/{harnesses → adapters}/attestation.d.ts +16 -16
  63. package/dist/core/adapters/attestation.d.ts.map +1 -0
  64. package/dist/core/{harnesses → adapters}/attestation.js +20 -20
  65. package/dist/core/{harnesses → adapters}/bench.d.ts +12 -12
  66. package/dist/core/adapters/bench.d.ts.map +1 -0
  67. package/dist/core/{harnesses → adapters}/bench.js +12 -12
  68. package/dist/core/adapters/index.d.ts +13 -0
  69. package/dist/core/adapters/index.d.ts.map +1 -0
  70. package/dist/core/adapters/index.js +6 -0
  71. package/dist/core/{harnesses → adapters}/profiles.d.ts +11 -11
  72. package/dist/core/adapters/profiles.d.ts.map +1 -0
  73. package/dist/core/{harnesses → adapters}/profiles.js +11 -11
  74. package/dist/core/adapters/registry.d.ts +15 -0
  75. package/dist/core/adapters/registry.d.ts.map +1 -0
  76. package/dist/core/{harnesses → adapters}/registry.js +11 -11
  77. package/dist/core/{harnesses → adapters}/types.d.ts +23 -23
  78. package/dist/core/adapters/types.d.ts.map +1 -0
  79. package/dist/core/{harnesses → adapters}/types.js +1 -1
  80. package/dist/core/agents/canonical-emit.d.ts +9 -14
  81. package/dist/core/agents/canonical-emit.d.ts.map +1 -1
  82. package/dist/core/agents/canonical-emit.js +15 -44
  83. package/dist/core/agents/cli-emit.js +1 -1
  84. package/dist/core/agents/cli.js +30 -26
  85. package/dist/core/agents/codex-replay.d.ts +1 -1
  86. package/dist/core/agents/codex-replay.js +6 -6
  87. package/dist/core/agents/coord-bin.d.ts +33 -0
  88. package/dist/core/agents/coord-bin.d.ts.map +1 -0
  89. package/dist/core/agents/coord-bin.js +89 -0
  90. package/dist/core/agents/coord-client.d.ts +78 -8
  91. package/dist/core/agents/coord-client.d.ts.map +1 -1
  92. package/dist/core/agents/coord-client.js +303 -75
  93. package/dist/core/agents/events/consume.d.ts +1 -1
  94. package/dist/core/agents/events/emit.d.ts +5 -6
  95. package/dist/core/agents/events/emit.d.ts.map +1 -1
  96. package/dist/core/agents/events/emit.js +2 -2
  97. package/dist/core/agents/paths.d.ts +5 -2
  98. package/dist/core/agents/paths.d.ts.map +1 -1
  99. package/dist/core/agents/paths.js +7 -13
  100. package/dist/core/agents/render/prompt-context.d.ts +21 -9
  101. package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
  102. package/dist/core/agents/render/prompt-context.js +82 -30
  103. package/dist/core/agents/render/session-context.d.ts +1 -1
  104. package/dist/core/agents/render/session-context.js +5 -5
  105. package/dist/core/agents/rules/claim-conflict.d.ts +2 -6
  106. package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
  107. package/dist/core/agents/rules/claim-conflict.js +1 -1
  108. package/dist/core/agents/rules/commit-conflict.js +98 -22
  109. package/dist/core/agents/rules/stop-hook.d.ts +9 -9
  110. package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
  111. package/dist/core/agents/rules/stop-hook.js +23 -5
  112. package/dist/core/agents/rules/verdict.d.ts +14 -0
  113. package/dist/core/agents/rules/verdict.d.ts.map +1 -0
  114. package/dist/core/agents/rules/verdict.js +1 -0
  115. package/dist/core/agents/session-events.js +3 -3
  116. package/dist/core/agents/state/council.d.ts +1 -1
  117. package/dist/core/agents/state/council.js +1 -1
  118. package/dist/core/agents/state/heartbeat-projector.d.ts +3 -2
  119. package/dist/core/agents/state/heartbeat-projector.d.ts.map +1 -1
  120. package/dist/core/agents/state/heartbeat-projector.js +14 -10
  121. package/dist/core/agents/state/heartbeat-writer.d.ts +1 -1
  122. package/dist/core/agents/state/heartbeat-writer.js +12 -12
  123. package/dist/core/agents/state/{scratch.d.ts → journal.d.ts} +7 -7
  124. package/dist/core/agents/state/{scratch.d.ts.map → journal.d.ts.map} +1 -1
  125. package/dist/core/agents/state/{scratch.js → journal.js} +12 -12
  126. package/dist/core/agents/state/pidmap.d.ts +28 -4
  127. package/dist/core/agents/state/pidmap.d.ts.map +1 -1
  128. package/dist/core/agents/state/pidmap.js +130 -15
  129. package/dist/core/agents/state/proc-start.d.ts +95 -0
  130. package/dist/core/agents/state/proc-start.d.ts.map +1 -0
  131. package/dist/core/agents/state/proc-start.js +199 -0
  132. package/dist/core/agents/state/shell-mutation.d.ts +1 -1
  133. package/dist/core/agents/state/shell-mutation.js +1 -1
  134. package/dist/core/agents/state/stale-sweep.js +7 -7
  135. package/dist/core/artifacts/index.d.ts +86 -0
  136. package/dist/core/artifacts/index.d.ts.map +1 -0
  137. package/dist/core/artifacts/index.js +421 -0
  138. package/dist/core/config.d.ts +9 -2
  139. package/dist/core/config.d.ts.map +1 -1
  140. package/dist/core/config.js +26 -2
  141. package/dist/core/context/index.d.ts +12 -12
  142. package/dist/core/context/index.js +10 -10
  143. package/dist/core/governor/adapter-spread.d.ts +52 -0
  144. package/dist/core/governor/adapter-spread.d.ts.map +1 -0
  145. package/dist/core/governor/adapter-spread.js +52 -0
  146. package/dist/core/governor/index.d.ts +7 -0
  147. package/dist/core/governor/index.d.ts.map +1 -0
  148. package/dist/core/governor/index.js +6 -0
  149. package/dist/core/governor/plan-api.d.ts +38 -0
  150. package/dist/core/governor/plan-api.d.ts.map +1 -0
  151. package/dist/core/governor/plan-api.js +83 -0
  152. package/dist/core/governor/plan-read.d.ts +5 -0
  153. package/dist/core/governor/plan-read.d.ts.map +1 -0
  154. package/dist/core/{supervisor → governor}/plan-read.js +66 -52
  155. package/dist/core/{supervisor → governor}/plan-types.d.ts +57 -56
  156. package/dist/core/governor/plan-types.d.ts.map +1 -0
  157. package/dist/core/{supervisor → governor}/plan-types.js +4 -4
  158. package/dist/core/governor/planning.d.ts +48 -0
  159. package/dist/core/governor/planning.d.ts.map +1 -0
  160. package/dist/core/{supervisor → governor}/planning.js +125 -94
  161. package/dist/core/governor/read.d.ts +6 -0
  162. package/dist/core/governor/read.d.ts.map +1 -0
  163. package/dist/core/governor/read.js +4 -0
  164. package/dist/core/governor/runner.d.ts +37 -0
  165. package/dist/core/governor/runner.d.ts.map +1 -0
  166. package/dist/core/{supervisor → governor}/runner.js +15 -15
  167. package/dist/core/governor/service-read.d.ts +6 -0
  168. package/dist/core/governor/service-read.d.ts.map +1 -0
  169. package/dist/core/{supervisor → governor}/service-read.js +12 -12
  170. package/dist/core/governor/service.d.ts +114 -0
  171. package/dist/core/governor/service.d.ts.map +1 -0
  172. package/dist/core/{supervisor → governor}/service.js +57 -57
  173. package/dist/core/governor/state.d.ts +116 -0
  174. package/dist/core/governor/state.d.ts.map +1 -0
  175. package/dist/core/{supervisor → governor}/state.js +228 -108
  176. package/dist/core/hooks/adapter/detect.d.ts +9 -0
  177. package/dist/core/hooks/{harness → adapter}/detect.d.ts.map +1 -1
  178. package/dist/core/hooks/{harness → adapter}/detect.js +8 -8
  179. package/dist/core/hooks/{harness → adapter}/events.d.ts +15 -14
  180. package/dist/core/hooks/adapter/events.d.ts.map +1 -0
  181. package/dist/core/hooks/{harness → adapter}/events.js +5 -5
  182. package/dist/core/hooks/{harness → adapter}/output.d.ts +20 -14
  183. package/dist/core/hooks/adapter/output.d.ts.map +1 -0
  184. package/dist/core/hooks/{harness → adapter}/output.js +30 -22
  185. package/dist/core/hooks/{harness → adapter}/parse.d.ts +5 -5
  186. package/dist/core/hooks/{harness → adapter}/parse.d.ts.map +1 -1
  187. package/dist/core/hooks/{harness → adapter}/parse.js +4 -4
  188. package/dist/core/hooks/{harness → adapter}/wiring.d.ts +15 -15
  189. package/dist/core/hooks/{harness → adapter}/wiring.d.ts.map +1 -1
  190. package/dist/core/hooks/{harness → adapter}/wiring.js +13 -13
  191. package/dist/core/hooks/cli.d.ts +3 -3
  192. package/dist/core/hooks/cli.js +187 -162
  193. package/dist/core/hooks/effects/image-capture.d.ts +5 -5
  194. package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
  195. package/dist/core/hooks/effects/image-capture.js +3 -3
  196. package/dist/core/hooks/effects/index.d.ts +12 -12
  197. package/dist/core/hooks/effects/index.d.ts.map +1 -1
  198. package/dist/core/hooks/effects/index.js +19 -19
  199. package/dist/core/hooks/events/emit.d.ts +2 -2
  200. package/dist/core/hooks/events/emit.d.ts.map +1 -1
  201. package/dist/core/hooks/events/emit.js +1 -1
  202. package/dist/core/hooks/events/rotate.js +1 -1
  203. package/dist/core/hooks/events/schema.d.ts +13 -5
  204. package/dist/core/hooks/events/schema.d.ts.map +1 -1
  205. package/dist/core/hooks/guard-path.d.ts +2 -2
  206. package/dist/core/hooks/guard-path.js +2 -2
  207. package/dist/core/hooks/index.d.ts +1 -1
  208. package/dist/core/hooks/index.d.ts.map +1 -1
  209. package/dist/core/hooks/resolve/anchor.d.ts +14 -5
  210. package/dist/core/hooks/resolve/anchor.d.ts.map +1 -1
  211. package/dist/core/hooks/resolve/anchor.js +64 -7
  212. package/dist/core/hooks/resolve/coord-root.d.ts +16 -11
  213. package/dist/core/hooks/resolve/coord-root.d.ts.map +1 -1
  214. package/dist/core/hooks/resolve/coord-root.js +18 -43
  215. package/dist/core/hooks/resolve/intent.js +1 -1
  216. package/dist/core/hooks/resolve/owner.d.ts +1 -1
  217. package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
  218. package/dist/core/hooks/resolve/owner.js +11 -5
  219. package/dist/core/{scratch → journal}/index.d.ts +25 -25
  220. package/dist/core/{scratch → journal}/index.d.ts.map +1 -1
  221. package/dist/core/{scratch → journal}/index.js +38 -38
  222. package/dist/core/policy/evaluate.d.ts +1 -1
  223. package/dist/core/policy/evaluate.d.ts.map +1 -1
  224. package/dist/core/policy/evaluate.js +7 -7
  225. package/dist/core/policy/types.d.ts +3 -3
  226. package/dist/core/policy/types.d.ts.map +1 -1
  227. package/dist/core/work/state.d.ts +12 -4
  228. package/dist/core/work/state.d.ts.map +1 -1
  229. package/dist/core/work/state.js +50 -17
  230. package/dist/core/workflow/adapters.d.ts +17 -0
  231. package/dist/core/workflow/adapters.d.ts.map +1 -0
  232. package/dist/core/workflow/adapters.js +21 -0
  233. package/dist/core/workflow/approvals.js +6 -6
  234. package/dist/core/workflow/billing.d.ts +9 -9
  235. package/dist/core/workflow/billing.js +9 -9
  236. package/dist/core/workflow/child-env.d.ts +10 -2
  237. package/dist/core/workflow/child-env.d.ts.map +1 -1
  238. package/dist/core/workflow/child-env.js +12 -4
  239. package/dist/core/workflow/engine.d.ts +15 -5
  240. package/dist/core/workflow/engine.d.ts.map +1 -1
  241. package/dist/core/workflow/engine.js +138 -83
  242. package/dist/core/workflow/evidence-preflight.d.ts +24 -0
  243. package/dist/core/workflow/evidence-preflight.d.ts.map +1 -0
  244. package/dist/core/workflow/evidence-preflight.js +134 -0
  245. package/dist/core/workflow/index.d.ts +1 -1
  246. package/dist/core/workflow/index.d.ts.map +1 -1
  247. package/dist/core/workflow/proof.d.ts +11 -5
  248. package/dist/core/workflow/proof.d.ts.map +1 -1
  249. package/dist/core/workflow/proof.js +45 -36
  250. package/dist/core/workflow/run-state.d.ts +1 -1
  251. package/dist/core/workflow/run-state.js +7 -7
  252. package/dist/core/workflow/sandbox-projection.d.ts +6 -6
  253. package/dist/core/workflow/sandbox-projection.d.ts.map +1 -1
  254. package/dist/core/workflow/sandbox-projection.js +11 -11
  255. package/dist/core/workflow/spawn-claude.d.ts +3 -3
  256. package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
  257. package/dist/core/workflow/spawn-claude.js +9 -6
  258. package/dist/core/workflow/spawn-codex.d.ts +4 -4
  259. package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
  260. package/dist/core/workflow/spawn-codex.js +9 -6
  261. package/dist/core/workflow/spawn-cursor.d.ts +4 -4
  262. package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
  263. package/dist/core/workflow/spawn-cursor.js +9 -6
  264. package/dist/core/workflow/spawn-failure.d.ts +1 -1
  265. package/dist/core/workflow/spawn-failure.js +1 -1
  266. package/dist/core/workflow/specialists.js +2 -2
  267. package/dist/core/workflow/{journal.d.ts → transcript.d.ts} +8 -8
  268. package/dist/core/workflow/transcript.d.ts.map +1 -0
  269. package/dist/core/workflow/{journal.js → transcript.js} +14 -14
  270. package/dist/core/workflow/types.d.ts +98 -51
  271. package/dist/core/workflow/types.d.ts.map +1 -1
  272. package/dist/core/workflow/types.js +11 -1
  273. package/dist/core/workflow/validate.d.ts +1 -1
  274. package/dist/core/workflow/validate.js +1 -1
  275. package/dist/core/workflow/workspaces/cancellation.js +2 -2
  276. package/dist/core/workflow/workspaces/cleanup.js +2 -2
  277. package/dist/core/workflow/workspaces/execution.js +6 -6
  278. package/dist/core/workflow/workspaces/inspect.js +9 -9
  279. package/dist/core/workflow/workspaces/integration.js +14 -14
  280. package/dist/core/workflow/workspaces/lifecycle.d.ts +1 -1
  281. package/dist/core/workflow/workspaces/lifecycle.d.ts.map +1 -1
  282. package/dist/core/workflow/workspaces/lifecycle.js +9 -9
  283. package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
  284. package/dist/core/workflow/workspaces/local-git.js +39 -5
  285. package/dist/core/workflow/workspaces/recovery.js +3 -3
  286. package/dist/core/workflow/workspaces/state.d.ts +1 -1
  287. package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
  288. package/dist/core/workflow/workspaces/state.js +3 -3
  289. package/dist/core/workflow/workspaces/types.d.ts +1 -1
  290. package/dist/core/workflow/workspaces/types.d.ts.map +1 -1
  291. package/dist/lib/browser/asserts.d.ts +28 -0
  292. package/dist/lib/browser/asserts.d.ts.map +1 -0
  293. package/dist/lib/browser/asserts.js +152 -0
  294. package/dist/lib/browser/client.d.ts +49 -0
  295. package/dist/lib/browser/client.d.ts.map +1 -1
  296. package/dist/lib/browser/client.js +155 -14
  297. package/dist/lib/browser/content-checks.d.ts +108 -0
  298. package/dist/lib/browser/content-checks.d.ts.map +1 -0
  299. package/dist/lib/browser/content-checks.js +474 -0
  300. package/dist/lib/browser/critique.d.ts +91 -0
  301. package/dist/lib/browser/critique.d.ts.map +1 -0
  302. package/dist/lib/browser/critique.js +167 -0
  303. package/dist/lib/browser/geometry.d.ts +32 -0
  304. package/dist/lib/browser/geometry.d.ts.map +1 -1
  305. package/dist/lib/browser/geometry.js +244 -1
  306. package/dist/lib/browser/index.d.ts +4 -1
  307. package/dist/lib/browser/index.d.ts.map +1 -1
  308. package/dist/lib/browser/index.js +2 -0
  309. package/dist/lib/claude-desktop.d.ts.map +1 -1
  310. package/dist/lib/claude-desktop.js +4 -1
  311. package/dist/lib/context/index.js +9 -2
  312. package/dist/lib/council/index.d.ts +6 -6
  313. package/dist/lib/council/index.d.ts.map +1 -1
  314. package/dist/lib/council/index.js +8 -8
  315. package/dist/lib/identities/assume.d.ts +2 -2
  316. package/dist/lib/identities/assume.js +7 -7
  317. package/dist/lib/instructions/apply.d.ts +3 -3
  318. package/dist/lib/instructions/apply.d.ts.map +1 -1
  319. package/dist/lib/instructions/apply.js +75 -27
  320. package/dist/lib/instructions/host-addendum.d.ts +54 -0
  321. package/dist/lib/instructions/host-addendum.d.ts.map +1 -0
  322. package/dist/lib/instructions/host-addendum.js +107 -0
  323. package/dist/lib/instructions/templates.d.ts +10 -3
  324. package/dist/lib/instructions/templates.d.ts.map +1 -1
  325. package/dist/lib/instructions/templates.js +41 -12
  326. package/dist/lib/machine.d.ts +2 -2
  327. package/dist/lib/machine.js +2 -2
  328. package/package.json +26 -21
  329. package/schemas/config.schema.json +26 -1
  330. package/src/commander.ts +22 -13
  331. package/src/commands/{harness.ts → adapter.ts} +46 -46
  332. package/src/commands/agents.ts +200 -78
  333. package/src/commands/artifacts.ts +168 -0
  334. package/src/commands/backup.ts +47 -33
  335. package/src/commands/browse.ts +438 -2
  336. package/src/commands/checkpoint.ts +196 -0
  337. package/src/commands/context.ts +3 -176
  338. package/src/commands/decision.ts +41 -7
  339. package/src/commands/deinit.ts +16 -16
  340. package/src/commands/doctor.ts +28 -28
  341. package/src/commands/{supervisor.ts → governor.ts} +184 -154
  342. package/src/commands/grep.ts +19 -2
  343. package/src/commands/init.ts +50 -34
  344. package/src/commands/{scratch.ts → journal.ts} +60 -60
  345. package/src/commands/policy.ts +1 -1
  346. package/src/commands/presence.ts +2 -2
  347. package/src/commands/sync.ts +3 -3
  348. package/src/commands/tunnel.ts +256 -38
  349. package/src/commands/web-fetch.ts +1 -1
  350. package/src/commands/web.ts +56 -1
  351. package/src/commands/work.ts +50 -35
  352. package/src/commands/workflow.ts +43 -34
  353. package/src/core/{harnesses → adapters}/attest-projection.ts +2 -2
  354. package/src/core/{harnesses → adapters}/attest.ts +27 -27
  355. package/src/core/{harnesses → adapters}/attestation.ts +41 -41
  356. package/src/core/{harnesses → adapters}/bench.ts +34 -43
  357. package/src/core/adapters/index.ts +56 -0
  358. package/src/core/{harnesses → adapters}/profiles.ts +16 -16
  359. package/src/core/{harnesses → adapters}/registry.ts +23 -23
  360. package/src/core/{harnesses → adapters}/types.ts +23 -23
  361. package/src/core/agents/canonical-emit.ts +16 -43
  362. package/src/core/agents/cli-emit.ts +1 -1
  363. package/src/core/agents/cli.ts +30 -28
  364. package/src/core/agents/codex-replay.ts +6 -6
  365. package/src/core/agents/coord-bin.ts +92 -0
  366. package/src/core/agents/coord-client.ts +302 -78
  367. package/src/core/agents/events/consume.ts +1 -1
  368. package/src/core/agents/events/emit.ts +7 -6
  369. package/src/core/agents/paths.ts +7 -11
  370. package/src/core/agents/render/prompt-context.ts +107 -31
  371. package/src/core/agents/render/session-context.ts +6 -6
  372. package/src/core/agents/rules/claim-conflict.ts +4 -7
  373. package/src/core/agents/rules/commit-conflict.ts +103 -22
  374. package/src/core/agents/rules/stop-hook.ts +33 -17
  375. package/src/core/agents/rules/verdict.ts +13 -0
  376. package/src/core/agents/session-events.ts +4 -4
  377. package/src/core/agents/state/council.ts +1 -1
  378. package/src/core/agents/state/heartbeat-projector.ts +16 -12
  379. package/src/core/agents/state/heartbeat-writer.ts +12 -12
  380. package/src/core/agents/state/{scratch.ts → journal.ts} +12 -12
  381. package/src/core/agents/state/pidmap.ts +130 -15
  382. package/src/core/agents/state/proc-start.ts +208 -0
  383. package/src/core/agents/state/shell-mutation.ts +1 -1
  384. package/src/core/agents/state/stale-sweep.ts +7 -7
  385. package/src/core/artifacts/index.ts +557 -0
  386. package/src/core/config.ts +30 -2
  387. package/src/core/context/index.ts +15 -15
  388. package/src/core/governor/adapter-spread.ts +82 -0
  389. package/src/core/governor/index.ts +91 -0
  390. package/src/core/governor/plan-api.ts +115 -0
  391. package/src/core/{supervisor → governor}/plan-read.ts +112 -97
  392. package/src/core/{supervisor → governor}/plan-types.ts +59 -56
  393. package/src/core/{supervisor → governor}/planning.ts +223 -192
  394. package/src/core/governor/read.ts +59 -0
  395. package/src/core/{supervisor → governor}/runner.ts +39 -39
  396. package/src/core/{supervisor → governor}/service-read.ts +22 -22
  397. package/src/core/{supervisor → governor}/service.ts +117 -119
  398. package/src/core/{supervisor → governor}/state.ts +325 -167
  399. package/src/core/hooks/adapter/detect.ts +30 -0
  400. package/src/core/hooks/{harness → adapter}/events.ts +16 -14
  401. package/src/core/hooks/{harness → adapter}/output.ts +31 -23
  402. package/src/core/hooks/{harness → adapter}/parse.ts +5 -5
  403. package/src/core/hooks/{harness → adapter}/wiring.ts +21 -21
  404. package/src/core/hooks/cli.ts +197 -173
  405. package/src/core/hooks/effects/image-capture.ts +6 -6
  406. package/src/core/hooks/effects/index.ts +19 -19
  407. package/src/core/hooks/events/emit.ts +3 -3
  408. package/src/core/hooks/events/rotate.ts +1 -1
  409. package/src/core/hooks/events/schema.ts +15 -7
  410. package/src/core/hooks/guard-path.ts +2 -2
  411. package/src/core/hooks/index.ts +1 -1
  412. package/src/core/hooks/resolve/anchor.ts +63 -8
  413. package/src/core/hooks/resolve/coord-root.ts +18 -40
  414. package/src/core/hooks/resolve/intent.ts +1 -1
  415. package/src/core/hooks/resolve/owner.ts +11 -5
  416. package/src/core/{scratch → journal}/index.ts +53 -53
  417. package/src/core/policy/evaluate.ts +8 -8
  418. package/src/core/policy/types.ts +3 -3
  419. package/src/core/work/state.ts +65 -23
  420. package/src/core/workflow/adapters.ts +33 -0
  421. package/src/core/workflow/approvals.ts +7 -7
  422. package/src/core/workflow/billing.ts +12 -12
  423. package/src/core/workflow/child-env.ts +13 -4
  424. package/src/core/workflow/engine.ts +155 -90
  425. package/src/core/workflow/evidence-preflight.ts +165 -0
  426. package/src/core/workflow/index.ts +3 -3
  427. package/src/core/workflow/proof.ts +60 -50
  428. package/src/core/workflow/run-state.ts +7 -7
  429. package/src/core/workflow/sandbox-projection.ts +16 -16
  430. package/src/core/workflow/spawn-claude.ts +13 -10
  431. package/src/core/workflow/spawn-codex.ts +13 -10
  432. package/src/core/workflow/spawn-cursor.ts +13 -10
  433. package/src/core/workflow/spawn-failure.ts +1 -1
  434. package/src/core/workflow/specialists.ts +2 -2
  435. package/src/core/workflow/{journal.ts → transcript.ts} +16 -16
  436. package/src/core/workflow/types.ts +108 -51
  437. package/src/core/workflow/validate.ts +1 -1
  438. package/src/core/workflow/workspaces/cancellation.ts +2 -2
  439. package/src/core/workflow/workspaces/cleanup.ts +2 -2
  440. package/src/core/workflow/workspaces/execution.ts +6 -6
  441. package/src/core/workflow/workspaces/inspect.ts +14 -11
  442. package/src/core/workflow/workspaces/integration.ts +18 -14
  443. package/src/core/workflow/workspaces/lifecycle.ts +10 -10
  444. package/src/core/workflow/workspaces/local-git.ts +47 -5
  445. package/src/core/workflow/workspaces/recovery.ts +3 -3
  446. package/src/core/workflow/workspaces/state.ts +4 -3
  447. package/src/core/workflow/workspaces/types.ts +1 -1
  448. package/src/lib/browser/asserts.ts +177 -0
  449. package/src/lib/browser/client.ts +189 -14
  450. package/src/lib/browser/content-checks.ts +571 -0
  451. package/src/lib/browser/critique.ts +231 -0
  452. package/src/lib/browser/geometry.ts +297 -1
  453. package/src/lib/browser/index.ts +34 -0
  454. package/src/lib/claude-desktop.ts +4 -1
  455. package/src/lib/context/index.ts +11 -1
  456. package/src/lib/council/index.ts +9 -9
  457. package/src/lib/identities/assume.ts +7 -7
  458. package/src/lib/instructions/apply.ts +87 -25
  459. package/src/lib/instructions/host-addendum.ts +126 -0
  460. package/src/lib/instructions/templates.ts +44 -15
  461. package/src/lib/machine.ts +2 -2
  462. package/dist/commands/harness.d.ts +0 -12
  463. package/dist/commands/harness.d.ts.map +0 -1
  464. package/dist/commands/scratch.d.ts +0 -4
  465. package/dist/commands/scratch.d.ts.map +0 -1
  466. package/dist/commands/session.d.ts.map +0 -1
  467. package/dist/commands/session.js +0 -162
  468. package/dist/commands/supervisor.d.ts +0 -4
  469. package/dist/commands/supervisor.d.ts.map +0 -1
  470. package/dist/core/harnesses/attest-projection.d.ts.map +0 -1
  471. package/dist/core/harnesses/attest.d.ts.map +0 -1
  472. package/dist/core/harnesses/attestation.d.ts.map +0 -1
  473. package/dist/core/harnesses/bench.d.ts.map +0 -1
  474. package/dist/core/harnesses/index.d.ts +0 -13
  475. package/dist/core/harnesses/index.d.ts.map +0 -1
  476. package/dist/core/harnesses/index.js +0 -6
  477. package/dist/core/harnesses/profiles.d.ts.map +0 -1
  478. package/dist/core/harnesses/registry.d.ts +0 -15
  479. package/dist/core/harnesses/registry.d.ts.map +0 -1
  480. package/dist/core/harnesses/types.d.ts.map +0 -1
  481. package/dist/core/hooks/harness/detect.d.ts +0 -9
  482. package/dist/core/hooks/harness/events.d.ts.map +0 -1
  483. package/dist/core/hooks/harness/output.d.ts.map +0 -1
  484. package/dist/core/supervisor/index.d.ts +0 -7
  485. package/dist/core/supervisor/index.d.ts.map +0 -1
  486. package/dist/core/supervisor/index.js +0 -6
  487. package/dist/core/supervisor/plan-api.d.ts +0 -23
  488. package/dist/core/supervisor/plan-api.d.ts.map +0 -1
  489. package/dist/core/supervisor/plan-api.js +0 -50
  490. package/dist/core/supervisor/plan-read.d.ts +0 -5
  491. package/dist/core/supervisor/plan-read.d.ts.map +0 -1
  492. package/dist/core/supervisor/plan-types.d.ts.map +0 -1
  493. package/dist/core/supervisor/planning.d.ts +0 -33
  494. package/dist/core/supervisor/planning.d.ts.map +0 -1
  495. package/dist/core/supervisor/read.d.ts +0 -6
  496. package/dist/core/supervisor/read.d.ts.map +0 -1
  497. package/dist/core/supervisor/read.js +0 -4
  498. package/dist/core/supervisor/runner.d.ts +0 -37
  499. package/dist/core/supervisor/runner.d.ts.map +0 -1
  500. package/dist/core/supervisor/service-read.d.ts +0 -6
  501. package/dist/core/supervisor/service-read.d.ts.map +0 -1
  502. package/dist/core/supervisor/service.d.ts +0 -114
  503. package/dist/core/supervisor/service.d.ts.map +0 -1
  504. package/dist/core/supervisor/state.d.ts +0 -95
  505. package/dist/core/supervisor/state.d.ts.map +0 -1
  506. package/dist/core/workflow/harnesses.d.ts +0 -17
  507. package/dist/core/workflow/harnesses.d.ts.map +0 -1
  508. package/dist/core/workflow/harnesses.js +0 -21
  509. package/dist/core/workflow/journal.d.ts.map +0 -1
  510. package/src/commands/session.ts +0 -187
  511. package/src/core/harnesses/index.ts +0 -56
  512. package/src/core/hooks/harness/detect.ts +0 -30
  513. package/src/core/supervisor/index.ts +0 -89
  514. package/src/core/supervisor/plan-api.ts +0 -73
  515. package/src/core/supervisor/read.ts +0 -59
  516. package/src/core/workflow/harnesses.ts +0 -33
  517. /package/dist/core/{harnesses → adapters}/attest-projection.js +0 -0
@@ -16,16 +16,18 @@ import { spawnSync } from "node:child_process";
16
16
  import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync, } from "node:fs";
17
17
  import { homedir, tmpdir } from "node:os";
18
18
  import { basename, join, resolve } from "node:path";
19
+ import { coordBinPath } from "../core/agents/coord-bin.js";
19
20
  import { readStreamTailBounded } from "../core/agents/events/consume.js";
20
- import { emitCanonical, monorepoRoot, normalizeHarness, readHeartbeat, resolveOwner, resolveOwnerBySessionEnv, resolveOwnerWithSource, } from "../core/agents/index.js";
21
+ import { emitCanonical, monorepoRoot, normalizeAdapter, readHeartbeat, resolveOwner, resolveOwnerBySessionEnv, resolveOwnerWithSource, } from "../core/agents/index.js";
21
22
  import { coordFreshnessSeconds, resolveBinName } from "../core/config.js";
22
23
  import { readRemoteMachines } from "../core/presence/index.js";
24
+ import { registerContextCommand } from "./context.js";
23
25
  /** Cap for CLI scans of the unbounded event ledger (`trace` / `health`). Well
24
26
  * under V8's ~512MB max string length so a `readFileSync` of the whole file can
25
27
  * never throw; covers ample recent history for a diagnostic scan. */
26
28
  const STREAM_SCAN_CAP_BYTES = 128 * 1024 * 1024; // 128 MiB
27
29
  import { parsePsChainLine } from "../core/hooks/resolve/anchor.js";
28
- import { appendEntry, resolveOwnerByName } from "../core/scratch/index.js";
30
+ import { appendEntry, resolveOwnerByName } from "../core/journal/index.js";
29
31
  import { buildCouncilId, buildInviteMarkdown, COUNCIL_SCHEMA_VERSION, contributorsInRound, councilBodyDir, councilsArchiveDir, deleteArchivedCouncil, effectiveSteward, findManifestByPartialId, listKnownAgents, listManifests, moveFromArchive, moveToArchive, normalizeAgentName, pendingCouncilsForMember, readArchivedManifest, readManifest, readRoundPrompts, roundDir, setCouncilSteward, writeContribution, writeManifest, writePrompt, } from "../lib/council/index.js";
30
32
  import { assumeIdentity, IdentityAssumeError } from "../lib/identities/assume.js";
31
33
  import { displayName as displayAgentName, ensureIdentity, listIdentities, lookupById as lookupIdentityById, lookupByName as lookupIdentityByName, } from "../lib/identities/index.js";
@@ -55,6 +57,41 @@ const SUBAGENT_NOTE = "Bash identity is process-level in v1; if you're running i
55
57
  export function coordHelperOpts(root) {
56
58
  return { cwd: root, env: { ...process.env, HARNERY_COORD_ROOT_OVERRIDE: root } };
57
59
  }
60
+ /**
61
+ * Resolve the bundled `agent-coord` helper, or exit with an error that names the
62
+ * problem. Every heartbeat mutation goes through that binary, so a caller who
63
+ * cannot find it has nothing useful to do — but it has to SAY so, because the
64
+ * alternative was spawning a path that did not exist and then crashing on the
65
+ * result (see `spawnFailureMessage`).
66
+ */
67
+ function agentCoordOrExit(root) {
68
+ const binary = coordBinPath("agent-coord", root);
69
+ if (!binary) {
70
+ emit.error({
71
+ code: "coord_helper_missing",
72
+ message: `agent-coord helper not found for coord root ${root}; reinstall or rebuild harnery`,
73
+ });
74
+ process.exit(1);
75
+ }
76
+ return binary;
77
+ }
78
+ /**
79
+ * Describe a failed `spawnSync` without assuming it ran.
80
+ *
81
+ * When the binary cannot be executed at all (ENOENT, EACCES) node reports
82
+ * `status: null` AND `stderr: null`, so the obvious `result.stderr.trim()`
83
+ * threw "null is not an object" — replacing a legible "helper not found" with a
84
+ * crash that pointed at the wrong layer entirely. `error` carries the real
85
+ * cause on that path, so prefer it.
86
+ */
87
+ function spawnFailureMessage(result, what) {
88
+ if (result.error)
89
+ return `${what}: ${result.error.message}`;
90
+ const stderr = result.stderr?.trim();
91
+ if (stderr)
92
+ return stderr;
93
+ return result.status === null ? `${what}: did not run` : `${what} exited ${result.status}`;
94
+ }
58
95
  function formatPlatformLabel(platform) {
59
96
  if (platform === "cursor")
60
97
  return "Cursor";
@@ -63,11 +100,12 @@ function formatPlatformLabel(platform) {
63
100
  return "CC";
64
101
  }
65
102
  let emit;
66
- export function registerAgentsCommand(program, emitParam) {
103
+ export function registerAgentsCommand(program, emitParam, programContext) {
67
104
  emit = emitParam;
68
105
  const cmd = program
69
106
  .command("agents")
70
- .description("Query the multi-agent coordination layer (whoami / list / status / health)");
107
+ .description("The live agent sessions in this project: who is running now, what they hold, and their coordination state (whoami / list / status / health).");
108
+ registerContextCommand(cmd, emitParam, programContext);
71
109
  cmd
72
110
  .command("whoami")
73
111
  .description("Print the current agent's name + instance_id + files claimed")
@@ -97,7 +135,7 @@ export function registerAgentsCommand(program, emitParam) {
97
135
  cmd
98
136
  .command("suggest-name [description...]")
99
137
  .description('Reprint a session name ("Agent <you> - <description>") for the operator to set as their ' +
100
- "harness tab title. With no arg, derives it from your current task. The primary naming path " +
138
+ "adapter tab title. With no arg, derives it from your current task. The primary naming path " +
101
139
  "is set-task (it suggests a name on the first focus declaration); reach for this to reprint " +
102
140
  "or re-suggest after a topic pivot. Read-only.")
103
141
  .option("--json", "JSON output instead of the bare name")
@@ -154,7 +192,7 @@ export function registerAgentsCommand(program, emitParam) {
154
192
  });
155
193
  cmd
156
194
  .command("ping <name> <message...>")
157
- .description("Append a 'handoff' entry to a peer agent's scratchpad. Body prefixed with " +
195
+ .description("Append a 'handoff' entry to a peer agent's journal. Body prefixed with " +
158
196
  "`from agent-<me>:`. Use to leave actionable coordination notes for peers " +
159
197
  "currently holding files you need.")
160
198
  .option("--json", "JSON output")
@@ -194,17 +232,17 @@ export function registerAgentsCommand(program, emitParam) {
194
232
  runHealth(opts);
195
233
  });
196
234
  cmd
197
- .command("harness-probe <id>")
198
- .description("Harness wiring probe: ppid chain, comm names, pid-map anchor, sample payload paths. " +
235
+ .command("adapter-probe <id>")
236
+ .description("Adapter wiring probe: ppid chain, comm names, pid-map anchor, sample payload paths. " +
199
237
  "With --replay-samples, also replays every checked-in sample payload against the live " +
200
238
  "adapter in an isolated sandbox to catch adapter / payload-shape drift. " +
201
239
  "Complements heal-events (drift telemetry). Id: claude_code | cursor.")
202
240
  .option("--json", "JSON envelope output")
203
- .option("--replay-samples", "Replay docs/api/<harness>-hooks/samples/*.json against the live adapter in an isolated sandbox. " +
241
+ .option("--replay-samples", "Replay docs/api/<adapter>-hooks/samples/*.json against the live adapter in an isolated sandbox. " +
204
242
  "Exits non-zero if any sample crashes the adapter.")
205
243
  .option("--sample <path>", "Replay only the named sample file (basename match). Implies --replay-samples.")
206
244
  .action((id, opts) => {
207
- runHarnessProbe(id, opts);
245
+ runAdapterProbe(id, opts);
208
246
  });
209
247
  cmd
210
248
  .command("heal")
@@ -226,7 +264,6 @@ export function registerAgentsCommand(program, emitParam) {
226
264
  .action((opts) => {
227
265
  runHeal(opts);
228
266
  });
229
- registerCouncilCommands(cmd);
230
267
  registerIdentityCommands(cmd);
231
268
  }
232
269
  function registerIdentityCommands(parent) {
@@ -368,7 +405,7 @@ function runIdentityAssume(target, opts) {
368
405
  process.exit(1);
369
406
  }
370
407
  }
371
- function registerCouncilCommands(parent) {
408
+ export function registerCouncilCommands(parent) {
372
409
  const council = parent
373
410
  .command("council")
374
411
  .description("Multi-agent deliberation: convene a temporary group around an " +
@@ -453,7 +490,7 @@ function registerCouncilCommands(parent) {
453
490
  "(or omit [steward]) to drop the field and revert to the default " +
454
491
  "(the convener). Refuses to mutate archived councils. By default, " +
455
492
  "rejects names not in the known-agents list (active heartbeats + " +
456
- "scratchpads archived in the last 30 days); pass --allow-unknown " +
493
+ "journals archived in the last 30 days); pass --allow-unknown " +
457
494
  "to bypass when bootstrapping.")
458
495
  .option("--clear", "Clear the steward field, reverting to created_by default")
459
496
  .option("--allow-unknown", "Skip the known-agents check (bootstrap an agent that hasn't run yet)")
@@ -467,7 +504,7 @@ function registerCouncilCommands(parent) {
467
504
  "Pass either --message <inline> or --file <path>. Writes to " +
468
505
  ".harnery/councils/<id>/round-<N>/<agent-Name>.md. Pass --as <member> " +
469
506
  "to contribute under a council seat name that differs from the running " +
470
- "agent's heartbeat name (useful for cross-harness councils where each " +
507
+ "agent's heartbeat name (useful for cross-adapter councils where each " +
471
508
  "reviewer has a different auto-generated session name).")
472
509
  .option("--message <text>", "Inline contribution text (caps at 4KB)")
473
510
  .option("--file <path>", "Path to a file containing the contribution")
@@ -536,7 +573,7 @@ function runWhoami(opts) {
536
573
  if (!hb) {
537
574
  emit.error({
538
575
  code: "no_heartbeat",
539
- message: `pid-map resolved owner=${myOwner.slice(0, 8)} but no heartbeat exists`,
576
+ message: noHeartbeatMessage(myOwner),
540
577
  });
541
578
  process.exit(1);
542
579
  }
@@ -720,6 +757,42 @@ function normalizeKind(kind) {
720
757
  return "unknown";
721
758
  return kind;
722
759
  }
760
+ /**
761
+ * The `no_heartbeat` diagnostic, quoting the owner id in FULL.
762
+ *
763
+ * This id is actionable: the reader's next move is `agents heal --kind
764
+ * heartbeat --owner <id>`, and heartbeats are keyed by the whole
765
+ * `instance_id` (`.harnery/active/<instance_id>.json`). An abbreviated id
766
+ * here reads as complete, so it gets copy-pasted into `--owner` and mints a
767
+ * heartbeat at a filename no reader resolves — an orphan that leaves the
768
+ * session looking unhealable. Abbreviate ids for display elsewhere, never in
769
+ * a message whose whole purpose is to hand the reader an id to pass back.
770
+ */
771
+ function noHeartbeatMessage(owner) {
772
+ return `resolved owner=${owner} but no heartbeat exists at .harnery/active/${owner}.json`;
773
+ }
774
+ /**
775
+ * The instance_id of a live heartbeat that `prefix` strictly prefixes, or null.
776
+ *
777
+ * Used to recognize an abbreviated id handed back by a reader when the caller
778
+ * supplied no canonical id of their own. Ambiguity is treated as "no answer":
779
+ * two live sessions sharing the prefix means we cannot name the one intended,
780
+ * and refusing with the wrong id in the message would be worse than the orphan.
781
+ */
782
+ function liveIdWithPrefix(root, prefix) {
783
+ const activeDir = resolve(root, ".harnery", "active");
784
+ if (!existsSync(activeDir))
785
+ return null;
786
+ const matches = new Set();
787
+ for (const file of readdirSync(activeDir)) {
788
+ if (!file.endsWith(".json"))
789
+ continue;
790
+ const id = file.slice(0, -".json".length);
791
+ if (id !== prefix && id.startsWith(prefix))
792
+ matches.add(id);
793
+ }
794
+ return matches.size === 1 ? matches.values().next().value : null;
795
+ }
723
796
  async function runWatch(pollMs) {
724
797
  const root = monorepoRoot();
725
798
  if (!root) {
@@ -1011,8 +1084,8 @@ function ensureCursorSession(root) {
1011
1084
  const sessionId = cursorEnvSessionId();
1012
1085
  if (!sessionId)
1013
1086
  return;
1014
- const agentHook = resolve(root, "harnery", "bin", "agent-hook");
1015
- if (!existsSync(agentHook))
1087
+ const agentHook = coordBinPath("agent-hook", root);
1088
+ if (!agentHook)
1016
1089
  return;
1017
1090
  const payload = JSON.stringify({
1018
1091
  conversation_id: sessionId,
@@ -1023,7 +1096,7 @@ function ensureCursorSession(root) {
1023
1096
  composer_mode: "agent",
1024
1097
  is_background_agent: false,
1025
1098
  });
1026
- spawnSync("bash", [agentHook, "session-start", "--harness", "cursor"], {
1099
+ spawnSync("bash", [agentHook, "session-start", "--adapter", "cursor"], {
1027
1100
  input: payload,
1028
1101
  cwd: root,
1029
1102
  encoding: "utf8",
@@ -1059,7 +1132,7 @@ function runReleaseClaim(path) {
1059
1132
  let canonical = path;
1060
1133
  if (path.startsWith(`${root}/`))
1061
1134
  canonical = path.slice(root.length + 1);
1062
- const helper = resolve(root, "harnery", "bin", "agent-coord");
1135
+ const helper = agentCoordOrExit(root);
1063
1136
  const result = spawnSync(helper, ["release-claim", myOwner, canonical], {
1064
1137
  encoding: "utf8",
1065
1138
  ...coordHelperOpts(root),
@@ -1067,7 +1140,7 @@ function runReleaseClaim(path) {
1067
1140
  if (result.status !== 0) {
1068
1141
  emit.error({
1069
1142
  code: "release_claim_failed",
1070
- message: result.stderr.trim() || `agent-coord exited ${result.status}`,
1143
+ message: spawnFailureMessage(result, "agent-coord"),
1071
1144
  });
1072
1145
  process.exit(1);
1073
1146
  }
@@ -1105,7 +1178,7 @@ function runSetTask(task, opts) {
1105
1178
  const priorHb = readHeartbeat(myOwner);
1106
1179
  const firstOfSession = !priorHb?.task_updated_at;
1107
1180
  // Heartbeat mutation goes through agent-coord (atomic temp+rename).
1108
- const helper = resolve(root, "harnery", "bin", "agent-coord");
1181
+ const helper = agentCoordOrExit(root);
1109
1182
  const result = spawnSync(helper, ["set-task", myOwner, task], {
1110
1183
  encoding: "utf8",
1111
1184
  ...coordHelperOpts(root),
@@ -1113,7 +1186,7 @@ function runSetTask(task, opts) {
1113
1186
  if (result.status !== 0) {
1114
1187
  emit.error({
1115
1188
  code: "set_task_failed",
1116
- message: result.stderr.trim() || `agent-coord exited ${result.status}`,
1189
+ message: spawnFailureMessage(result, "agent-coord"),
1117
1190
  });
1118
1191
  process.exit(1);
1119
1192
  }
@@ -1122,11 +1195,11 @@ function runSetTask(task, opts) {
1122
1195
  type: "state.task_set",
1123
1196
  owner: myOwner,
1124
1197
  session: hb?.session_id ?? myOwner,
1125
- harness: normalizeHarness(hb?.platform),
1198
+ adapter: normalizeAdapter(hb?.platform),
1126
1199
  data: { task, cleared: !task || task.length === 0 },
1127
1200
  });
1128
1201
  // On the first focus declaration of a session, surface a suggested session
1129
- // name for the operator to set as their harness tab title. Read the result
1202
+ // name for the operator to set as their adapter tab title. Read the result
1130
1203
  // (`suggested_session_name`) and reproduce it in a fenced code block so the
1131
1204
  // UI's Copy button hands over the exact string. null on every later call.
1132
1205
  const built = firstOfSession && !opts?.sessionId ? buildSuggestedName(hb?.name ?? "unknown", [task]) : null;
@@ -1231,7 +1304,7 @@ function runStatus(opts) {
1231
1304
  if (!hb) {
1232
1305
  emit.error({
1233
1306
  code: "no_heartbeat",
1234
- message: `pid-map resolved owner=${myOwner.slice(0, 8)} but no heartbeat exists`,
1307
+ message: noHeartbeatMessage(myOwner),
1235
1308
  });
1236
1309
  process.exit(1);
1237
1310
  }
@@ -1240,7 +1313,7 @@ function runStatus(opts) {
1240
1313
  // populated for back-compat with consumers reading v1 directly. The stamp
1241
1314
  // goes through agent-coord (atomic write).
1242
1315
  try {
1243
- const helper = resolve(root, "harnery", "bin", "agent-coord");
1316
+ const helper = agentCoordOrExit(root);
1244
1317
  spawnSync(helper, ["stamp-status-call", myOwner], {
1245
1318
  encoding: "utf8",
1246
1319
  timeout: 2000,
@@ -1254,7 +1327,7 @@ function runStatus(opts) {
1254
1327
  type: "state.status_checked",
1255
1328
  owner: myOwner,
1256
1329
  session: hb.session_id ?? myOwner,
1257
- harness: normalizeHarness(hb.platform),
1330
+ adapter: normalizeAdapter(hb.platform),
1258
1331
  data: {
1259
1332
  format: opts.json ? "json" : "box",
1260
1333
  agent_count: 0, // computed below, not yet available here; Phase 5 verdict reads owner-scope only
@@ -1721,14 +1794,14 @@ function readCanonicalEventsInWindow(root, cutoffMs) {
1721
1794
  }
1722
1795
  return out;
1723
1796
  }
1724
- /** harness ("claude-code") → legacy platform label ("claude_code") so the
1797
+ /** adapter ("claude-code") → legacy platform label ("claude_code") so the
1725
1798
  * existing formatPlatformLabel rendering keeps working unchanged. */
1726
- function harnessToPlatform(harness) {
1727
- if (harness === "claude-code")
1799
+ function adapterToPlatform(adapter) {
1800
+ if (adapter === "claude-code")
1728
1801
  return "claude_code";
1729
- if (harness === "cursor")
1802
+ if (adapter === "cursor")
1730
1803
  return "cursor";
1731
- if (harness === "codex")
1804
+ if (adapter === "codex")
1732
1805
  return "codex";
1733
1806
  return "claude_code";
1734
1807
  }
@@ -1750,7 +1823,7 @@ function canonicalToHealEvent(ev, nameById) {
1750
1823
  agent,
1751
1824
  kind,
1752
1825
  reason,
1753
- platform: harnessToPlatform(ev.harness),
1826
+ platform: adapterToPlatform(ev.adapter),
1754
1827
  };
1755
1828
  if (kind === "pidmap" && data.pid !== undefined && data.pid !== null) {
1756
1829
  out.pid = String(data.pid);
@@ -2508,14 +2581,14 @@ function renderHealthBox(report) {
2508
2581
  }
2509
2582
  }
2510
2583
  }
2511
- function runHarnessProbe(id, opts) {
2584
+ function runAdapterProbe(id, opts) {
2512
2585
  if (opts.json)
2513
2586
  emit.config({ format: "json" });
2514
- const harness = id.trim();
2515
- if (harness !== "claude_code" && harness !== "cursor") {
2587
+ const adapter = id.trim();
2588
+ if (adapter !== "claude_code" && adapter !== "cursor") {
2516
2589
  emit.error({
2517
- code: "bad_harness",
2518
- message: "harness id must be claude_code or cursor",
2590
+ code: "bad_adapter",
2591
+ message: "adapter id must be claude_code or cursor",
2519
2592
  });
2520
2593
  process.exit(1);
2521
2594
  }
@@ -2527,13 +2600,13 @@ function runHarnessProbe(id, opts) {
2527
2600
  });
2528
2601
  process.exit(1);
2529
2602
  }
2530
- const subagentDir = harness === "cursor" ? ".harnery/.cursor-subagent-map" : `.harnery/.subagent-map/${harness}`;
2531
- const sampleDir = harness === "cursor" ? "docs/api/cursor-hooks/samples" : "docs/api/claude-code-hooks/samples";
2532
- const dispatchEntry = harness === "cursor"
2533
- ? "harnery/bin/agent-hook session-start --harness cursor"
2534
- : "harnery/bin/agent-hook session-start --harness claude-code";
2603
+ const subagentDir = adapter === "cursor" ? ".harnery/.cursor-subagent-map" : `.harnery/.subagent-map/${adapter}`;
2604
+ const sampleDir = adapter === "cursor" ? "docs/api/cursor-hooks/samples" : "docs/api/claude-code-hooks/samples";
2605
+ const dispatchEntry = adapter === "cursor"
2606
+ ? "harnery/bin/agent-hook session-start --adapter cursor"
2607
+ : "harnery/bin/agent-hook session-start --adapter claude-code";
2535
2608
  // TS-native probe. The owner + anchor-pid resolution it reports lives in
2536
- // `findHarnessAnchorPid` (core/hooks/cli.ts, the /proc walk mirrored below)
2609
+ // `findAdapterAnchorPid` (core/hooks/cli.ts, the /proc walk mirrored below)
2537
2610
  // and `resolveOwner` here, so the probe reports exactly what the live hot
2538
2611
  // path resolves.
2539
2612
  const anchorTokens = new Set(["claude", "claude-code", "cursor", "codex"]);
@@ -2573,7 +2646,7 @@ function runHarnessProbe(id, opts) {
2573
2646
  walkPid = ppid;
2574
2647
  }
2575
2648
  const data = {
2576
- harness,
2649
+ adapter,
2577
2650
  anchor_pid: anchorPid,
2578
2651
  hook_pid: String(process.pid),
2579
2652
  resolved_owner: resolveOwner() ?? "",
@@ -2581,13 +2654,13 @@ function runHarnessProbe(id, opts) {
2581
2654
  subagent_map_dir: subagentDir,
2582
2655
  sample_ref: sampleDir,
2583
2656
  dispatch_entry: dispatchEntry,
2584
- note: "heal-events counts drift; harness-probe answers wiring",
2657
+ note: "heal-events counts drift; adapter-probe answers wiring",
2585
2658
  };
2586
2659
  const wantReplay = opts.replaySamples || !!opts.sample;
2587
2660
  let samples = [];
2588
2661
  let replayExitCode = 0;
2589
2662
  if (wantReplay) {
2590
- const result = replayHarnessSamples(harness, root, sampleDir, opts.sample);
2663
+ const result = replayAdapterSamples(adapter, root, sampleDir, opts.sample);
2591
2664
  samples = result.samples;
2592
2665
  replayExitCode = result.exitCode;
2593
2666
  data.samples = samples;
@@ -2596,7 +2669,7 @@ function runHarnessProbe(id, opts) {
2596
2669
  emit.data(data);
2597
2670
  if (process.stdout.isTTY && !opts.json) {
2598
2671
  const lines = [
2599
- `Harness probe: ${harness}`,
2672
+ `Adapter probe: ${adapter}`,
2600
2673
  ` anchor_pid: ${String(data.anchor_pid) || "(empty, expected in sandbox/non-IDE)"}`,
2601
2674
  ` hook_pid: ${String(data.hook_pid)}`,
2602
2675
  ` resolved_owner: ${String(data.resolved_owner) || "(none)"}`,
@@ -2636,11 +2709,11 @@ function runHarnessProbe(id, opts) {
2636
2709
  }
2637
2710
  }
2638
2711
  /**
2639
- * Replay every JSON fixture in <root>/<sampleDir> against the live harness
2712
+ * Replay every JSON fixture in <root>/<sampleDir> against the live adapter
2640
2713
  * dispatcher in an isolated sandbox.
2641
2714
  *
2642
2715
  * Sandbox isolation strategy:
2643
- * - mkdtempSync(tmpdir(), "harn-harness-probe-") creates a non-git tmp dir.
2716
+ * - mkdtempSync(tmpdir(), "harn-adapter-probe-") creates a non-git tmp dir.
2644
2717
  * - The dispatcher's coord-root resolution falls back to
2645
2718
  * `HARNERY_COORD_ROOT_OVERRIDE` when git rev-parse fails. We set it to the sandbox.
2646
2719
  * - We rewrite the payload's `cwd` field (Cursor cds to it) to the sandbox,
@@ -2652,7 +2725,7 @@ function runHarnessProbe(id, opts) {
2652
2725
  * payload with `.hook_event_name`. Event name resolution falls back to the
2653
2726
  * filename (without `.json`) when neither field exists.
2654
2727
  */
2655
- function replayHarnessSamples(harness, root, relativeSampleDir, filter) {
2728
+ function replayAdapterSamples(adapter, root, relativeSampleDir, filter) {
2656
2729
  const sampleDir = resolve(root, relativeSampleDir);
2657
2730
  if (!existsSync(sampleDir)) {
2658
2731
  return {
@@ -2673,7 +2746,7 @@ function replayHarnessSamples(harness, root, relativeSampleDir, filter) {
2673
2746
  };
2674
2747
  }
2675
2748
  // agent-hook is the single entry point. Replay sample payloads against it,
2676
- // mapping the harness-native hook_event_name to the agent-hook CLI subcommand.
2749
+ // mapping the adapter-native hook_event_name to the agent-hook CLI subcommand.
2677
2750
  const agentHook = resolve(root, "harnery/bin/agent-hook");
2678
2751
  if (!existsSync(agentHook)) {
2679
2752
  return {
@@ -2711,8 +2784,8 @@ function replayHarnessSamples(harness, root, relativeSampleDir, filter) {
2711
2784
  stopFailure: "stop-failure",
2712
2785
  StopFailure: "stop-failure",
2713
2786
  };
2714
- const harnessFlag = harness === "claude_code" ? "claude-code" : harness;
2715
- const sandbox = mkdtempSync(join(tmpdir(), "harn-harness-probe-"));
2787
+ const adapterFlag = adapter === "claude_code" ? "claude-code" : adapter;
2788
+ const sandbox = mkdtempSync(join(tmpdir(), "harn-adapter-probe-"));
2716
2789
  const results = [];
2717
2790
  try {
2718
2791
  for (const file of fixtures) {
@@ -2749,7 +2822,7 @@ function replayHarnessSamples(harness, root, relativeSampleDir, filter) {
2749
2822
  payloadObj.workspace_roots = [sandbox];
2750
2823
  }
2751
2824
  const subcommand = EVENT_SUBCOMMAND[event] ?? event;
2752
- const dispatch = spawnSync("bash", [agentHook, subcommand, "--harness", harnessFlag], {
2825
+ const dispatch = spawnSync("bash", [agentHook, subcommand, "--adapter", adapterFlag], {
2753
2826
  cwd: sandbox,
2754
2827
  encoding: "utf8",
2755
2828
  input: JSON.stringify(payloadObj),
@@ -2757,8 +2830,8 @@ function replayHarnessSamples(harness, root, relativeSampleDir, filter) {
2757
2830
  env: {
2758
2831
  ...process.env,
2759
2832
  HARNERY_COORD_ROOT_OVERRIDE: sandbox,
2760
- HARNERY_AGENT_COORD_HARNESS: harness,
2761
- HARNERY_AGENT_COORD_PLATFORM: harness,
2833
+ HARNERY_AGENT_COORD_ADAPTER: adapter,
2834
+ HARNERY_AGENT_COORD_PLATFORM: adapter,
2762
2835
  HARNERY_AGENT_COORD_OFF: "0",
2763
2836
  },
2764
2837
  });
@@ -2893,8 +2966,8 @@ function runPing(name, message, opts) {
2893
2966
  peer_instance_id: peerOwner,
2894
2967
  from: fromName,
2895
2968
  body,
2896
- scratch_path: doc.path,
2897
- scratch_bytes: doc.bytes,
2969
+ journal_path: doc.path,
2970
+ journal_bytes: doc.bytes,
2898
2971
  };
2899
2972
  if (opts.json) {
2900
2973
  emit.config({ format: "json" });
@@ -3024,6 +3097,41 @@ function runHeal(opts) {
3024
3097
  process.exit(1);
3025
3098
  }
3026
3099
  const action = kind === "pidmap" ? "heal-pidmap" : kind === "heartbeat" ? "heal-heartbeat" : "kill-heartbeat";
3100
+ // Refuse to mint a heartbeat at a TRUNCATED owner id.
3101
+ //
3102
+ // Heartbeats are keyed by the whole instance_id, so healing at an
3103
+ // abbreviated id writes `.harnery/active/<prefix>.json` while every reader
3104
+ // (`status`, `set-task`, `whoami`) resolves `<instance_id>.json`. The heal
3105
+ // reports success, the session stays broken, and an orphan file is left
3106
+ // behind that the singleton fallback can then mis-resolve other callers to.
3107
+ //
3108
+ // A distinct instance_id (subagent, workflow child) is never a prefix of its
3109
+ // own session_id, so a strict prefix is unambiguously an abbreviated id
3110
+ // rather than a legitimately different owner. Only guard the create path: an
3111
+ // existing heartbeat at `owner` means the id is real, whatever its shape.
3112
+ //
3113
+ // Two sources for the canonical id, because the reported failure arrives
3114
+ // without `--session-id`: someone copies a truncated id out of a diagnostic
3115
+ // and passes it as `--owner` alone. Comparing against `--session-id` alone
3116
+ // therefore misses the exact path that produced the orphan; a live heartbeat
3117
+ // whose instance_id this id is a prefix of settles it just as well, and is
3118
+ // present in precisely the case that matters (the session the reader was
3119
+ // trying to heal is registered, just not under the abbreviated name).
3120
+ if (kind === "heartbeat" && !readHeartbeat(owner)) {
3121
+ const canonical = opts.sessionId && opts.sessionId.trim() !== owner && opts.sessionId.trim().startsWith(owner)
3122
+ ? opts.sessionId.trim()
3123
+ : liveIdWithPrefix(root, owner);
3124
+ if (canonical) {
3125
+ const source = opts.sessionId?.trim() === canonical ? "--session-id" : "a live heartbeat";
3126
+ emit.error({
3127
+ code: "truncated_owner",
3128
+ message: `--owner ${owner} is a prefix of ${canonical} (${source}), and no heartbeat exists ` +
3129
+ `at .harnery/active/${owner}.json. Healing here would create a heartbeat no reader ` +
3130
+ `resolves. Re-run with --owner ${canonical}.`,
3131
+ });
3132
+ process.exit(1);
3133
+ }
3134
+ }
3027
3135
  // Build positional args. agent-coord's arg layout:
3028
3136
  // heal-pidmap <instance_id> [<pid>]
3029
3137
  // heal-heartbeat <instance_id> [<session_id>]
@@ -3034,8 +3142,8 @@ function runHeal(opts) {
3034
3142
  if (kind === "heartbeat" && opts.sessionId)
3035
3143
  helperArgs.push(opts.sessionId);
3036
3144
  // heal-pidmap / heal-heartbeat / kill-heartbeat are handled by the
3037
- // agent-coord binary at harnery/bin/agent-coord.
3038
- const helper = `${root}/harnery/bin/agent-coord`;
3145
+ // bundled agent-coord binary.
3146
+ const helper = agentCoordOrExit(root);
3039
3147
  const proc = spawnSync(helper, helperArgs, {
3040
3148
  encoding: "utf8",
3041
3149
  ...coordHelperOpts(root),
@@ -3043,7 +3151,7 @@ function runHeal(opts) {
3043
3151
  if (proc.status !== 0) {
3044
3152
  emit.error({
3045
3153
  code: "heal_failed",
3046
- message: proc.stderr?.trim() || `agent-coord ${action} exited non-zero`,
3154
+ message: spawnFailureMessage(proc, `agent-coord ${action}`),
3047
3155
  });
3048
3156
  process.exit(1);
3049
3157
  }
@@ -3078,7 +3186,10 @@ function runHeal(opts) {
3078
3186
  ],
3079
3187
  meta: {
3080
3188
  kind,
3081
- helper: "harnery/bin/agent-coord",
3189
+ // The path actually spawned, not a guess at the layout: the helper is
3190
+ // resolved from harnery's own package location, which differs between a
3191
+ // submodule, an installed dependency, and a standalone checkout.
3192
+ helper,
3082
3193
  },
3083
3194
  });
3084
3195
  if (!opts.json) {
@@ -3109,7 +3220,7 @@ function emitCouncilStateEvent(type, manifest, extraData) {
3109
3220
  type,
3110
3221
  owner: myOwner,
3111
3222
  session: hb?.session_id ?? myOwner,
3112
- harness: normalizeHarness(hb?.platform),
3223
+ adapter: normalizeAdapter(hb?.platform),
3113
3224
  data: { council_id: manifest.council_id, ...extraData },
3114
3225
  });
3115
3226
  }
@@ -3214,7 +3325,7 @@ function runCouncilCreate(objective, opts) {
3214
3325
  type: "council.open",
3215
3326
  owner: myOwner,
3216
3327
  session: myHbForEmit?.session_id ?? myOwner,
3217
- harness: normalizeHarness(myHbForEmit?.platform),
3328
+ adapter: normalizeAdapter(myHbForEmit?.platform),
3218
3329
  data: {
3219
3330
  council_id: councilId,
3220
3331
  topic: trimmedObjective,
@@ -3223,7 +3334,7 @@ function runCouncilCreate(objective, opts) {
3223
3334
  },
3224
3335
  });
3225
3336
  }
3226
- // Best-effort: ping each currently-active member's scratchpad with a
3337
+ // Best-effort: ping each currently-active member's journal with a
3227
3338
  // handoff entry pointing them at the council. Members not currently active
3228
3339
  // get nothing here; the Phase 2 SessionStart adapter will surface the
3229
3340
  // invite on their next session.
@@ -3646,7 +3757,7 @@ function runCouncilSetSteward(id, stewardArg, opts) {
3646
3757
  const known_names = known.map((a) => a.name).join(", ") || "(none)";
3647
3758
  emit.error({
3648
3759
  code: "steward_not_known",
3649
- message: `'${steward}' is not a known agent (active heartbeats + scratchpads archived in the last 30 days). Pass --allow-unknown to bootstrap. Known: ${known_names}`,
3760
+ message: `'${steward}' is not a known agent (active heartbeats + journals archived in the last 30 days). Pass --allow-unknown to bootstrap. Known: ${known_names}`,
3650
3761
  });
3651
3762
  process.exit(1);
3652
3763
  }
@@ -3679,7 +3790,7 @@ function runCouncilSetSteward(id, stewardArg, opts) {
3679
3790
  emit.text(`council ${next.council_id} steward set to ${label}.\n`);
3680
3791
  }
3681
3792
  }
3682
- /** Build a markdown transcript of every round's contributions on disk. */
3793
+ /** Build a markdown journal of every round's contributions on disk. */
3683
3794
  function buildTranscript(manifest) {
3684
3795
  const body = councilBodyDir(manifest.council_id);
3685
3796
  const out = [];
@@ -3749,7 +3860,7 @@ function runCouncilContribute(id, opts) {
3749
3860
  }
3750
3861
  // Resolve the contributor name. Two paths:
3751
3862
  // 1. --as <member> override: caller explicitly names the council seat. Used
3752
- // for cross-harness councils where each reviewer agent has a different
3863
+ // for cross-adapter councils where each reviewer agent has a different
3753
3864
  // auto-generated session name from a different name pool; they can
3754
3865
  // contribute under a fixed seat name without renaming the session.
3755
3866
  // 2. Heartbeat-derived (default): resolve owner via ppid walk + read the
@@ -3792,7 +3903,7 @@ function runCouncilContribute(id, opts) {
3792
3903
  if (!myHb?.name) {
3793
3904
  emit.error({
3794
3905
  code: "no_self_name",
3795
- message: `resolved owner ${myOwner.slice(0, 8)} has no name on heartbeat (pass --as <member> to override)`,
3906
+ message: `resolved owner ${myOwner} has no name on heartbeat (pass --as <member> to override)`,
3796
3907
  });
3797
3908
  process.exit(1);
3798
3909
  }
@@ -3936,7 +4047,7 @@ function runCouncilPrompt(id, member, opts) {
3936
4047
  process.exit(1);
3937
4048
  }
3938
4049
  // Resolve caller identity (steward authority check). Same --as override
3939
- // shape as `contribute` for cross-harness scripting.
4050
+ // shape as `contribute` for cross-adapter scripting.
3940
4051
  let callerName;
3941
4052
  let actualName = null;
3942
4053
  if (opts.as) {
@@ -4142,7 +4253,7 @@ function runCouncilAdvance(id, opts) {
4142
4253
  * Shared advance helper used by both `advance` and auto-advance from
4143
4254
  * `contribute`. Increments current_round, flips round_status back to open,
4144
4255
  * creates the new round directory, writes the manifest, and pings each
4145
- * member's scratchpad with the advance notification.
4256
+ * member's journal with the advance notification.
4146
4257
  */
4147
4258
  function advanceCouncil(manifest, force) {
4148
4259
  const nextRound = manifest.current_round + 1;
@@ -4156,7 +4267,7 @@ function advanceCouncil(manifest, force) {
4156
4267
  if (rd && !existsSync(rd))
4157
4268
  mkdirSync(rd, { recursive: true });
4158
4269
  writeManifest(next);
4159
- // Ping each member's scratchpad with the advance notification.
4270
+ // Ping each member's journal with the advance notification.
4160
4271
  // (Convener already knows; we skip pinging them if they convened it from
4161
4272
  // their own session.)
4162
4273
  const myOwner = resolveOwner();
@@ -4172,7 +4283,7 @@ function advanceCouncil(manifest, force) {
4172
4283
  appendEntry(memberOwner, "handoff", `from council advance (${manifest.council_id}): round ${nextRound} is now open${force ? " (advanced with --force; some round-N members dropped)" : ""}. Run 'harn agents council show ${manifest.council_id}' to read prior round + 'harn agents council contribute ${manifest.council_id}' to weigh in.`);
4173
4284
  }
4174
4285
  catch {
4175
- /* best-effort; member scratchpad may not exist yet */
4286
+ /* best-effort; member journal may not exist yet */
4176
4287
  }
4177
4288
  }
4178
4289
  return next;
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { EmitContext, HarneryProgramContext } from "../commander.js";
3
+ export declare function registerArtifactsCommand(program: Command, emit: EmitContext, context?: HarneryProgramContext): void;
4
+ //# sourceMappingURL=artifacts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../../src/commands/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAa1E,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,WAAW,EACjB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,IAAI,CAmGN"}