harnery 0.30.0 → 0.31.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 (501) 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 +61 -60
  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/init.d.ts +12 -12
  34. package/dist/commands/init.d.ts.map +1 -1
  35. package/dist/commands/init.js +44 -30
  36. package/dist/commands/{session.d.ts → journal.d.ts} +2 -2
  37. package/dist/commands/journal.d.ts.map +1 -0
  38. package/dist/commands/{scratch.js → journal.js} +47 -47
  39. package/dist/commands/policy.js +1 -1
  40. package/dist/commands/presence.js +2 -2
  41. package/dist/commands/sync.d.ts +1 -1
  42. package/dist/commands/sync.js +3 -3
  43. package/dist/commands/tunnel.d.ts +16 -0
  44. package/dist/commands/tunnel.d.ts.map +1 -1
  45. package/dist/commands/tunnel.js +193 -23
  46. package/dist/commands/web-fetch.js +1 -1
  47. package/dist/commands/web.d.ts +19 -0
  48. package/dist/commands/web.d.ts.map +1 -1
  49. package/dist/commands/web.js +51 -0
  50. package/dist/commands/work.d.ts.map +1 -1
  51. package/dist/commands/work.js +38 -22
  52. package/dist/commands/workflow.d.ts.map +1 -1
  53. package/dist/commands/workflow.js +35 -28
  54. package/dist/core/{harnesses → adapters}/attest-projection.d.ts +2 -2
  55. package/dist/core/adapters/attest-projection.d.ts.map +1 -0
  56. package/dist/core/{harnesses → adapters}/attest.d.ts +16 -16
  57. package/dist/core/adapters/attest.d.ts.map +1 -0
  58. package/dist/core/{harnesses → adapters}/attest.js +9 -9
  59. package/dist/core/{harnesses → adapters}/attestation.d.ts +16 -16
  60. package/dist/core/adapters/attestation.d.ts.map +1 -0
  61. package/dist/core/{harnesses → adapters}/attestation.js +20 -20
  62. package/dist/core/{harnesses → adapters}/bench.d.ts +12 -12
  63. package/dist/core/adapters/bench.d.ts.map +1 -0
  64. package/dist/core/{harnesses → adapters}/bench.js +12 -12
  65. package/dist/core/adapters/index.d.ts +13 -0
  66. package/dist/core/adapters/index.d.ts.map +1 -0
  67. package/dist/core/adapters/index.js +6 -0
  68. package/dist/core/{harnesses → adapters}/profiles.d.ts +11 -11
  69. package/dist/core/adapters/profiles.d.ts.map +1 -0
  70. package/dist/core/{harnesses → adapters}/profiles.js +11 -11
  71. package/dist/core/adapters/registry.d.ts +15 -0
  72. package/dist/core/adapters/registry.d.ts.map +1 -0
  73. package/dist/core/{harnesses → adapters}/registry.js +11 -11
  74. package/dist/core/{harnesses → adapters}/types.d.ts +23 -23
  75. package/dist/core/adapters/types.d.ts.map +1 -0
  76. package/dist/core/{harnesses → adapters}/types.js +1 -1
  77. package/dist/core/agents/canonical-emit.d.ts +4 -4
  78. package/dist/core/agents/canonical-emit.js +5 -5
  79. package/dist/core/agents/cli-emit.js +1 -1
  80. package/dist/core/agents/cli.js +30 -26
  81. package/dist/core/agents/codex-replay.d.ts +1 -1
  82. package/dist/core/agents/codex-replay.js +6 -6
  83. package/dist/core/agents/coord-client.d.ts +21 -2
  84. package/dist/core/agents/coord-client.d.ts.map +1 -1
  85. package/dist/core/agents/coord-client.js +122 -27
  86. package/dist/core/agents/events/consume.d.ts +1 -1
  87. package/dist/core/agents/events/emit.d.ts +5 -6
  88. package/dist/core/agents/events/emit.d.ts.map +1 -1
  89. package/dist/core/agents/events/emit.js +2 -2
  90. package/dist/core/agents/render/prompt-context.d.ts +21 -9
  91. package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
  92. package/dist/core/agents/render/prompt-context.js +82 -30
  93. package/dist/core/agents/render/session-context.d.ts +1 -1
  94. package/dist/core/agents/render/session-context.js +5 -5
  95. package/dist/core/agents/rules/claim-conflict.d.ts +2 -6
  96. package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
  97. package/dist/core/agents/rules/claim-conflict.js +1 -1
  98. package/dist/core/agents/rules/commit-conflict.js +98 -22
  99. package/dist/core/agents/rules/stop-hook.d.ts +9 -9
  100. package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
  101. package/dist/core/agents/rules/stop-hook.js +23 -5
  102. package/dist/core/agents/rules/verdict.d.ts +14 -0
  103. package/dist/core/agents/rules/verdict.d.ts.map +1 -0
  104. package/dist/core/agents/rules/verdict.js +1 -0
  105. package/dist/core/agents/session-events.js +3 -3
  106. package/dist/core/agents/state/council.d.ts +1 -1
  107. package/dist/core/agents/state/council.js +1 -1
  108. package/dist/core/agents/state/heartbeat-projector.d.ts +3 -2
  109. package/dist/core/agents/state/heartbeat-projector.d.ts.map +1 -1
  110. package/dist/core/agents/state/heartbeat-projector.js +14 -10
  111. package/dist/core/agents/state/heartbeat-writer.d.ts +1 -1
  112. package/dist/core/agents/state/heartbeat-writer.js +12 -12
  113. package/dist/core/agents/state/{scratch.d.ts → journal.d.ts} +7 -7
  114. package/dist/core/agents/state/{scratch.d.ts.map → journal.d.ts.map} +1 -1
  115. package/dist/core/agents/state/{scratch.js → journal.js} +12 -12
  116. package/dist/core/agents/state/pidmap.d.ts +28 -4
  117. package/dist/core/agents/state/pidmap.d.ts.map +1 -1
  118. package/dist/core/agents/state/pidmap.js +130 -15
  119. package/dist/core/agents/state/proc-start.d.ts +95 -0
  120. package/dist/core/agents/state/proc-start.d.ts.map +1 -0
  121. package/dist/core/agents/state/proc-start.js +199 -0
  122. package/dist/core/agents/state/shell-mutation.d.ts +1 -1
  123. package/dist/core/agents/state/shell-mutation.js +1 -1
  124. package/dist/core/agents/state/stale-sweep.js +7 -7
  125. package/dist/core/artifacts/index.d.ts +86 -0
  126. package/dist/core/artifacts/index.d.ts.map +1 -0
  127. package/dist/core/artifacts/index.js +421 -0
  128. package/dist/core/config.d.ts +9 -2
  129. package/dist/core/config.d.ts.map +1 -1
  130. package/dist/core/config.js +26 -2
  131. package/dist/core/context/index.d.ts +12 -12
  132. package/dist/core/context/index.js +10 -10
  133. package/dist/core/governor/adapter-spread.d.ts +52 -0
  134. package/dist/core/governor/adapter-spread.d.ts.map +1 -0
  135. package/dist/core/governor/adapter-spread.js +52 -0
  136. package/dist/core/governor/index.d.ts +7 -0
  137. package/dist/core/governor/index.d.ts.map +1 -0
  138. package/dist/core/governor/index.js +6 -0
  139. package/dist/core/governor/plan-api.d.ts +38 -0
  140. package/dist/core/governor/plan-api.d.ts.map +1 -0
  141. package/dist/core/governor/plan-api.js +83 -0
  142. package/dist/core/governor/plan-read.d.ts +5 -0
  143. package/dist/core/governor/plan-read.d.ts.map +1 -0
  144. package/dist/core/{supervisor → governor}/plan-read.js +66 -52
  145. package/dist/core/{supervisor → governor}/plan-types.d.ts +57 -56
  146. package/dist/core/governor/plan-types.d.ts.map +1 -0
  147. package/dist/core/{supervisor → governor}/plan-types.js +4 -4
  148. package/dist/core/governor/planning.d.ts +48 -0
  149. package/dist/core/governor/planning.d.ts.map +1 -0
  150. package/dist/core/{supervisor → governor}/planning.js +125 -94
  151. package/dist/core/governor/read.d.ts +6 -0
  152. package/dist/core/governor/read.d.ts.map +1 -0
  153. package/dist/core/governor/read.js +4 -0
  154. package/dist/core/governor/runner.d.ts +37 -0
  155. package/dist/core/governor/runner.d.ts.map +1 -0
  156. package/dist/core/{supervisor → governor}/runner.js +15 -15
  157. package/dist/core/governor/service-read.d.ts +6 -0
  158. package/dist/core/governor/service-read.d.ts.map +1 -0
  159. package/dist/core/{supervisor → governor}/service-read.js +12 -12
  160. package/dist/core/governor/service.d.ts +114 -0
  161. package/dist/core/governor/service.d.ts.map +1 -0
  162. package/dist/core/{supervisor → governor}/service.js +57 -57
  163. package/dist/core/governor/state.d.ts +116 -0
  164. package/dist/core/governor/state.d.ts.map +1 -0
  165. package/dist/core/{supervisor → governor}/state.js +228 -108
  166. package/dist/core/hooks/adapter/detect.d.ts +9 -0
  167. package/dist/core/hooks/{harness → adapter}/detect.d.ts.map +1 -1
  168. package/dist/core/hooks/{harness → adapter}/detect.js +8 -8
  169. package/dist/core/hooks/{harness → adapter}/events.d.ts +15 -14
  170. package/dist/core/hooks/adapter/events.d.ts.map +1 -0
  171. package/dist/core/hooks/{harness → adapter}/events.js +5 -5
  172. package/dist/core/hooks/{harness → adapter}/output.d.ts +20 -14
  173. package/dist/core/hooks/adapter/output.d.ts.map +1 -0
  174. package/dist/core/hooks/{harness → adapter}/output.js +30 -22
  175. package/dist/core/hooks/{harness → adapter}/parse.d.ts +5 -5
  176. package/dist/core/hooks/{harness → adapter}/parse.d.ts.map +1 -1
  177. package/dist/core/hooks/{harness → adapter}/parse.js +4 -4
  178. package/dist/core/hooks/{harness → adapter}/wiring.d.ts +15 -15
  179. package/dist/core/hooks/{harness → adapter}/wiring.d.ts.map +1 -1
  180. package/dist/core/hooks/{harness → adapter}/wiring.js +13 -13
  181. package/dist/core/hooks/cli.d.ts +3 -3
  182. package/dist/core/hooks/cli.js +175 -151
  183. package/dist/core/hooks/effects/image-capture.d.ts +5 -5
  184. package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
  185. package/dist/core/hooks/effects/image-capture.js +3 -3
  186. package/dist/core/hooks/effects/index.d.ts +12 -12
  187. package/dist/core/hooks/effects/index.d.ts.map +1 -1
  188. package/dist/core/hooks/effects/index.js +17 -17
  189. package/dist/core/hooks/events/emit.d.ts +2 -2
  190. package/dist/core/hooks/events/emit.d.ts.map +1 -1
  191. package/dist/core/hooks/events/emit.js +1 -1
  192. package/dist/core/hooks/events/rotate.js +1 -1
  193. package/dist/core/hooks/events/schema.d.ts +13 -5
  194. package/dist/core/hooks/events/schema.d.ts.map +1 -1
  195. package/dist/core/hooks/guard-path.d.ts +2 -2
  196. package/dist/core/hooks/guard-path.js +2 -2
  197. package/dist/core/hooks/index.d.ts +1 -1
  198. package/dist/core/hooks/index.d.ts.map +1 -1
  199. package/dist/core/hooks/resolve/anchor.d.ts +14 -5
  200. package/dist/core/hooks/resolve/anchor.d.ts.map +1 -1
  201. package/dist/core/hooks/resolve/anchor.js +64 -7
  202. package/dist/core/hooks/resolve/coord-root.d.ts +3 -3
  203. package/dist/core/hooks/resolve/coord-root.js +4 -4
  204. package/dist/core/hooks/resolve/intent.js +1 -1
  205. package/dist/core/hooks/resolve/owner.d.ts +1 -1
  206. package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
  207. package/dist/core/hooks/resolve/owner.js +11 -5
  208. package/dist/core/{scratch → journal}/index.d.ts +25 -25
  209. package/dist/core/{scratch → journal}/index.d.ts.map +1 -1
  210. package/dist/core/{scratch → journal}/index.js +38 -38
  211. package/dist/core/policy/evaluate.d.ts +1 -1
  212. package/dist/core/policy/evaluate.d.ts.map +1 -1
  213. package/dist/core/policy/evaluate.js +7 -7
  214. package/dist/core/policy/types.d.ts +3 -3
  215. package/dist/core/policy/types.d.ts.map +1 -1
  216. package/dist/core/work/state.d.ts +12 -4
  217. package/dist/core/work/state.d.ts.map +1 -1
  218. package/dist/core/work/state.js +50 -17
  219. package/dist/core/workflow/adapters.d.ts +17 -0
  220. package/dist/core/workflow/adapters.d.ts.map +1 -0
  221. package/dist/core/workflow/adapters.js +21 -0
  222. package/dist/core/workflow/approvals.js +6 -6
  223. package/dist/core/workflow/billing.d.ts +9 -9
  224. package/dist/core/workflow/billing.js +9 -9
  225. package/dist/core/workflow/child-env.d.ts +10 -2
  226. package/dist/core/workflow/child-env.d.ts.map +1 -1
  227. package/dist/core/workflow/child-env.js +12 -4
  228. package/dist/core/workflow/engine.d.ts +15 -5
  229. package/dist/core/workflow/engine.d.ts.map +1 -1
  230. package/dist/core/workflow/engine.js +138 -83
  231. package/dist/core/workflow/evidence-preflight.d.ts +24 -0
  232. package/dist/core/workflow/evidence-preflight.d.ts.map +1 -0
  233. package/dist/core/workflow/evidence-preflight.js +134 -0
  234. package/dist/core/workflow/index.d.ts +1 -1
  235. package/dist/core/workflow/index.d.ts.map +1 -1
  236. package/dist/core/workflow/proof.d.ts +11 -5
  237. package/dist/core/workflow/proof.d.ts.map +1 -1
  238. package/dist/core/workflow/proof.js +45 -36
  239. package/dist/core/workflow/run-state.d.ts +1 -1
  240. package/dist/core/workflow/run-state.js +7 -7
  241. package/dist/core/workflow/sandbox-projection.d.ts +6 -6
  242. package/dist/core/workflow/sandbox-projection.d.ts.map +1 -1
  243. package/dist/core/workflow/sandbox-projection.js +11 -11
  244. package/dist/core/workflow/spawn-claude.d.ts +3 -3
  245. package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
  246. package/dist/core/workflow/spawn-claude.js +9 -6
  247. package/dist/core/workflow/spawn-codex.d.ts +4 -4
  248. package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
  249. package/dist/core/workflow/spawn-codex.js +9 -6
  250. package/dist/core/workflow/spawn-cursor.d.ts +4 -4
  251. package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
  252. package/dist/core/workflow/spawn-cursor.js +9 -6
  253. package/dist/core/workflow/spawn-failure.d.ts +1 -1
  254. package/dist/core/workflow/spawn-failure.js +1 -1
  255. package/dist/core/workflow/specialists.js +2 -2
  256. package/dist/core/workflow/{journal.d.ts → transcript.d.ts} +8 -8
  257. package/dist/core/workflow/transcript.d.ts.map +1 -0
  258. package/dist/core/workflow/{journal.js → transcript.js} +14 -14
  259. package/dist/core/workflow/types.d.ts +98 -51
  260. package/dist/core/workflow/types.d.ts.map +1 -1
  261. package/dist/core/workflow/types.js +11 -1
  262. package/dist/core/workflow/validate.d.ts +1 -1
  263. package/dist/core/workflow/validate.js +1 -1
  264. package/dist/core/workflow/workspaces/cancellation.js +2 -2
  265. package/dist/core/workflow/workspaces/cleanup.js +2 -2
  266. package/dist/core/workflow/workspaces/execution.js +6 -6
  267. package/dist/core/workflow/workspaces/inspect.js +9 -9
  268. package/dist/core/workflow/workspaces/integration.js +14 -14
  269. package/dist/core/workflow/workspaces/lifecycle.d.ts +1 -1
  270. package/dist/core/workflow/workspaces/lifecycle.d.ts.map +1 -1
  271. package/dist/core/workflow/workspaces/lifecycle.js +9 -9
  272. package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
  273. package/dist/core/workflow/workspaces/local-git.js +39 -5
  274. package/dist/core/workflow/workspaces/recovery.js +3 -3
  275. package/dist/core/workflow/workspaces/state.d.ts +1 -1
  276. package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
  277. package/dist/core/workflow/workspaces/state.js +3 -3
  278. package/dist/core/workflow/workspaces/types.d.ts +1 -1
  279. package/dist/core/workflow/workspaces/types.d.ts.map +1 -1
  280. package/dist/lib/browser/asserts.d.ts +28 -0
  281. package/dist/lib/browser/asserts.d.ts.map +1 -0
  282. package/dist/lib/browser/asserts.js +152 -0
  283. package/dist/lib/browser/client.d.ts +49 -0
  284. package/dist/lib/browser/client.d.ts.map +1 -1
  285. package/dist/lib/browser/client.js +155 -14
  286. package/dist/lib/browser/content-checks.d.ts +108 -0
  287. package/dist/lib/browser/content-checks.d.ts.map +1 -0
  288. package/dist/lib/browser/content-checks.js +474 -0
  289. package/dist/lib/browser/critique.d.ts +91 -0
  290. package/dist/lib/browser/critique.d.ts.map +1 -0
  291. package/dist/lib/browser/critique.js +167 -0
  292. package/dist/lib/browser/geometry.d.ts +32 -0
  293. package/dist/lib/browser/geometry.d.ts.map +1 -1
  294. package/dist/lib/browser/geometry.js +244 -1
  295. package/dist/lib/browser/index.d.ts +4 -1
  296. package/dist/lib/browser/index.d.ts.map +1 -1
  297. package/dist/lib/browser/index.js +2 -0
  298. package/dist/lib/claude-desktop.d.ts.map +1 -1
  299. package/dist/lib/claude-desktop.js +4 -1
  300. package/dist/lib/council/index.d.ts +6 -6
  301. package/dist/lib/council/index.d.ts.map +1 -1
  302. package/dist/lib/council/index.js +8 -8
  303. package/dist/lib/identities/assume.d.ts +2 -2
  304. package/dist/lib/identities/assume.js +7 -7
  305. package/dist/lib/instructions/apply.d.ts +3 -3
  306. package/dist/lib/instructions/apply.d.ts.map +1 -1
  307. package/dist/lib/instructions/apply.js +75 -27
  308. package/dist/lib/instructions/host-addendum.d.ts +54 -0
  309. package/dist/lib/instructions/host-addendum.d.ts.map +1 -0
  310. package/dist/lib/instructions/host-addendum.js +107 -0
  311. package/dist/lib/instructions/templates.d.ts +10 -3
  312. package/dist/lib/instructions/templates.d.ts.map +1 -1
  313. package/dist/lib/instructions/templates.js +41 -12
  314. package/dist/lib/machine.d.ts +2 -2
  315. package/dist/lib/machine.js +2 -2
  316. package/package.json +26 -21
  317. package/schemas/config.schema.json +26 -1
  318. package/src/commander.ts +22 -13
  319. package/src/commands/{harness.ts → adapter.ts} +46 -46
  320. package/src/commands/agents.ts +71 -64
  321. package/src/commands/artifacts.ts +168 -0
  322. package/src/commands/backup.ts +47 -33
  323. package/src/commands/browse.ts +438 -2
  324. package/src/commands/checkpoint.ts +196 -0
  325. package/src/commands/context.ts +3 -176
  326. package/src/commands/decision.ts +41 -7
  327. package/src/commands/deinit.ts +16 -16
  328. package/src/commands/doctor.ts +28 -28
  329. package/src/commands/{supervisor.ts → governor.ts} +184 -154
  330. package/src/commands/init.ts +50 -34
  331. package/src/commands/{scratch.ts → journal.ts} +60 -60
  332. package/src/commands/policy.ts +1 -1
  333. package/src/commands/presence.ts +2 -2
  334. package/src/commands/sync.ts +3 -3
  335. package/src/commands/tunnel.ts +237 -34
  336. package/src/commands/web-fetch.ts +1 -1
  337. package/src/commands/web.ts +56 -1
  338. package/src/commands/work.ts +50 -35
  339. package/src/commands/workflow.ts +43 -34
  340. package/src/core/{harnesses → adapters}/attest-projection.ts +2 -2
  341. package/src/core/{harnesses → adapters}/attest.ts +27 -27
  342. package/src/core/{harnesses → adapters}/attestation.ts +41 -41
  343. package/src/core/{harnesses → adapters}/bench.ts +34 -43
  344. package/src/core/adapters/index.ts +56 -0
  345. package/src/core/{harnesses → adapters}/profiles.ts +16 -16
  346. package/src/core/{harnesses → adapters}/registry.ts +23 -23
  347. package/src/core/{harnesses → adapters}/types.ts +23 -23
  348. package/src/core/agents/canonical-emit.ts +6 -6
  349. package/src/core/agents/cli-emit.ts +1 -1
  350. package/src/core/agents/cli.ts +30 -28
  351. package/src/core/agents/codex-replay.ts +6 -6
  352. package/src/core/agents/coord-client.ts +119 -28
  353. package/src/core/agents/events/consume.ts +1 -1
  354. package/src/core/agents/events/emit.ts +7 -6
  355. package/src/core/agents/render/prompt-context.ts +107 -31
  356. package/src/core/agents/render/session-context.ts +6 -6
  357. package/src/core/agents/rules/claim-conflict.ts +4 -7
  358. package/src/core/agents/rules/commit-conflict.ts +103 -22
  359. package/src/core/agents/rules/stop-hook.ts +33 -17
  360. package/src/core/agents/rules/verdict.ts +13 -0
  361. package/src/core/agents/session-events.ts +4 -4
  362. package/src/core/agents/state/council.ts +1 -1
  363. package/src/core/agents/state/heartbeat-projector.ts +16 -12
  364. package/src/core/agents/state/heartbeat-writer.ts +12 -12
  365. package/src/core/agents/state/{scratch.ts → journal.ts} +12 -12
  366. package/src/core/agents/state/pidmap.ts +130 -15
  367. package/src/core/agents/state/proc-start.ts +208 -0
  368. package/src/core/agents/state/shell-mutation.ts +1 -1
  369. package/src/core/agents/state/stale-sweep.ts +7 -7
  370. package/src/core/artifacts/index.ts +557 -0
  371. package/src/core/config.ts +30 -2
  372. package/src/core/context/index.ts +15 -15
  373. package/src/core/governor/adapter-spread.ts +82 -0
  374. package/src/core/governor/index.ts +91 -0
  375. package/src/core/governor/plan-api.ts +115 -0
  376. package/src/core/{supervisor → governor}/plan-read.ts +112 -97
  377. package/src/core/{supervisor → governor}/plan-types.ts +59 -56
  378. package/src/core/{supervisor → governor}/planning.ts +223 -192
  379. package/src/core/governor/read.ts +59 -0
  380. package/src/core/{supervisor → governor}/runner.ts +39 -39
  381. package/src/core/{supervisor → governor}/service-read.ts +22 -22
  382. package/src/core/{supervisor → governor}/service.ts +117 -119
  383. package/src/core/{supervisor → governor}/state.ts +325 -167
  384. package/src/core/hooks/adapter/detect.ts +30 -0
  385. package/src/core/hooks/{harness → adapter}/events.ts +16 -14
  386. package/src/core/hooks/{harness → adapter}/output.ts +31 -23
  387. package/src/core/hooks/{harness → adapter}/parse.ts +5 -5
  388. package/src/core/hooks/{harness → adapter}/wiring.ts +21 -21
  389. package/src/core/hooks/cli.ts +185 -162
  390. package/src/core/hooks/effects/image-capture.ts +6 -6
  391. package/src/core/hooks/effects/index.ts +17 -17
  392. package/src/core/hooks/events/emit.ts +3 -3
  393. package/src/core/hooks/events/rotate.ts +1 -1
  394. package/src/core/hooks/events/schema.ts +15 -7
  395. package/src/core/hooks/guard-path.ts +2 -2
  396. package/src/core/hooks/index.ts +1 -1
  397. package/src/core/hooks/resolve/anchor.ts +63 -8
  398. package/src/core/hooks/resolve/coord-root.ts +4 -4
  399. package/src/core/hooks/resolve/intent.ts +1 -1
  400. package/src/core/hooks/resolve/owner.ts +11 -5
  401. package/src/core/{scratch → journal}/index.ts +53 -53
  402. package/src/core/policy/evaluate.ts +8 -8
  403. package/src/core/policy/types.ts +3 -3
  404. package/src/core/work/state.ts +65 -23
  405. package/src/core/workflow/adapters.ts +33 -0
  406. package/src/core/workflow/approvals.ts +7 -7
  407. package/src/core/workflow/billing.ts +12 -12
  408. package/src/core/workflow/child-env.ts +13 -4
  409. package/src/core/workflow/engine.ts +155 -90
  410. package/src/core/workflow/evidence-preflight.ts +165 -0
  411. package/src/core/workflow/index.ts +3 -3
  412. package/src/core/workflow/proof.ts +60 -50
  413. package/src/core/workflow/run-state.ts +7 -7
  414. package/src/core/workflow/sandbox-projection.ts +16 -16
  415. package/src/core/workflow/spawn-claude.ts +13 -10
  416. package/src/core/workflow/spawn-codex.ts +13 -10
  417. package/src/core/workflow/spawn-cursor.ts +13 -10
  418. package/src/core/workflow/spawn-failure.ts +1 -1
  419. package/src/core/workflow/specialists.ts +2 -2
  420. package/src/core/workflow/{journal.ts → transcript.ts} +16 -16
  421. package/src/core/workflow/types.ts +108 -51
  422. package/src/core/workflow/validate.ts +1 -1
  423. package/src/core/workflow/workspaces/cancellation.ts +2 -2
  424. package/src/core/workflow/workspaces/cleanup.ts +2 -2
  425. package/src/core/workflow/workspaces/execution.ts +6 -6
  426. package/src/core/workflow/workspaces/inspect.ts +14 -11
  427. package/src/core/workflow/workspaces/integration.ts +18 -14
  428. package/src/core/workflow/workspaces/lifecycle.ts +10 -10
  429. package/src/core/workflow/workspaces/local-git.ts +47 -5
  430. package/src/core/workflow/workspaces/recovery.ts +3 -3
  431. package/src/core/workflow/workspaces/state.ts +4 -3
  432. package/src/core/workflow/workspaces/types.ts +1 -1
  433. package/src/lib/browser/asserts.ts +177 -0
  434. package/src/lib/browser/client.ts +189 -14
  435. package/src/lib/browser/content-checks.ts +571 -0
  436. package/src/lib/browser/critique.ts +231 -0
  437. package/src/lib/browser/geometry.ts +297 -1
  438. package/src/lib/browser/index.ts +34 -0
  439. package/src/lib/claude-desktop.ts +4 -1
  440. package/src/lib/council/index.ts +9 -9
  441. package/src/lib/identities/assume.ts +7 -7
  442. package/src/lib/instructions/apply.ts +87 -25
  443. package/src/lib/instructions/host-addendum.ts +126 -0
  444. package/src/lib/instructions/templates.ts +44 -15
  445. package/src/lib/machine.ts +2 -2
  446. package/dist/commands/harness.d.ts +0 -12
  447. package/dist/commands/harness.d.ts.map +0 -1
  448. package/dist/commands/scratch.d.ts +0 -4
  449. package/dist/commands/scratch.d.ts.map +0 -1
  450. package/dist/commands/session.d.ts.map +0 -1
  451. package/dist/commands/session.js +0 -162
  452. package/dist/commands/supervisor.d.ts +0 -4
  453. package/dist/commands/supervisor.d.ts.map +0 -1
  454. package/dist/core/harnesses/attest-projection.d.ts.map +0 -1
  455. package/dist/core/harnesses/attest.d.ts.map +0 -1
  456. package/dist/core/harnesses/attestation.d.ts.map +0 -1
  457. package/dist/core/harnesses/bench.d.ts.map +0 -1
  458. package/dist/core/harnesses/index.d.ts +0 -13
  459. package/dist/core/harnesses/index.d.ts.map +0 -1
  460. package/dist/core/harnesses/index.js +0 -6
  461. package/dist/core/harnesses/profiles.d.ts.map +0 -1
  462. package/dist/core/harnesses/registry.d.ts +0 -15
  463. package/dist/core/harnesses/registry.d.ts.map +0 -1
  464. package/dist/core/harnesses/types.d.ts.map +0 -1
  465. package/dist/core/hooks/harness/detect.d.ts +0 -9
  466. package/dist/core/hooks/harness/events.d.ts.map +0 -1
  467. package/dist/core/hooks/harness/output.d.ts.map +0 -1
  468. package/dist/core/supervisor/index.d.ts +0 -7
  469. package/dist/core/supervisor/index.d.ts.map +0 -1
  470. package/dist/core/supervisor/index.js +0 -6
  471. package/dist/core/supervisor/plan-api.d.ts +0 -23
  472. package/dist/core/supervisor/plan-api.d.ts.map +0 -1
  473. package/dist/core/supervisor/plan-api.js +0 -50
  474. package/dist/core/supervisor/plan-read.d.ts +0 -5
  475. package/dist/core/supervisor/plan-read.d.ts.map +0 -1
  476. package/dist/core/supervisor/plan-types.d.ts.map +0 -1
  477. package/dist/core/supervisor/planning.d.ts +0 -33
  478. package/dist/core/supervisor/planning.d.ts.map +0 -1
  479. package/dist/core/supervisor/read.d.ts +0 -6
  480. package/dist/core/supervisor/read.d.ts.map +0 -1
  481. package/dist/core/supervisor/read.js +0 -4
  482. package/dist/core/supervisor/runner.d.ts +0 -37
  483. package/dist/core/supervisor/runner.d.ts.map +0 -1
  484. package/dist/core/supervisor/service-read.d.ts +0 -6
  485. package/dist/core/supervisor/service-read.d.ts.map +0 -1
  486. package/dist/core/supervisor/service.d.ts +0 -114
  487. package/dist/core/supervisor/service.d.ts.map +0 -1
  488. package/dist/core/supervisor/state.d.ts +0 -95
  489. package/dist/core/supervisor/state.d.ts.map +0 -1
  490. package/dist/core/workflow/harnesses.d.ts +0 -17
  491. package/dist/core/workflow/harnesses.d.ts.map +0 -1
  492. package/dist/core/workflow/harnesses.js +0 -21
  493. package/dist/core/workflow/journal.d.ts.map +0 -1
  494. package/src/commands/session.ts +0 -187
  495. package/src/core/harnesses/index.ts +0 -56
  496. package/src/core/hooks/harness/detect.ts +0 -30
  497. package/src/core/supervisor/index.ts +0 -89
  498. package/src/core/supervisor/plan-api.ts +0 -73
  499. package/src/core/supervisor/read.ts +0 -59
  500. package/src/core/workflow/harnesses.ts +0 -33
  501. /package/dist/core/{harnesses → adapters}/attest-projection.js +0 -0
@@ -0,0 +1,165 @@
1
+ import { EVIDENCE_KINDS } from "./types.ts";
2
+
3
+ /**
4
+ * Reject an unusable evidence kind before the first agent is spawned.
5
+ *
6
+ * `evidence()` is by construction near the end of a workflow, so an invalid
7
+ * kind throws after every agent has finished. Measured: a fifty-minute run with
8
+ * three completed agents died at its final line on `kind: "design"`, reported
9
+ * `work_failed`, and burned an attempt. The work survived only because it had
10
+ * already been written to the tree; nothing in the proof could recover it.
11
+ *
12
+ * A workflow's evidence kinds are usually written literally, and a literal is
13
+ * checkable by reading the file. Where a kind is computed the scan says nothing
14
+ * and the existing runtime validation still applies — a partial check that
15
+ * costs one file read is worth more than a complete one nobody can implement.
16
+ */
17
+
18
+ export interface EvidencePreflightProblem {
19
+ kind: string;
20
+ line: number;
21
+ }
22
+
23
+ /** Every literal `evidence({ kind: … })` in this source whose kind is not in the
24
+ * vocabulary. Computed kinds are invisible here, by design. */
25
+ export function findInvalidEvidenceKinds(source: string): EvidencePreflightProblem[] {
26
+ const { masked, literals } = maskSource(source);
27
+ const problems: EvidencePreflightProblem[] = [];
28
+ const valid = new Set<string>(EVIDENCE_KINDS);
29
+
30
+ for (const call of evidenceCallRanges(masked)) {
31
+ // `kind` as an object key, then the value's first character. A quote there
32
+ // means a literal we can read; anything else is computed, so skip it.
33
+ const property = /\bkind\s*:\s*/g;
34
+ property.lastIndex = 0;
35
+ const slice = masked.slice(call.start, call.end);
36
+ let match = property.exec(slice);
37
+ while (match !== null) {
38
+ const valueAt = call.start + match.index + match[0].length;
39
+ const literal = literals.get(valueAt);
40
+ if (literal !== undefined && !valid.has(literal)) {
41
+ problems.push({ kind: literal, line: lineOf(source, valueAt) });
42
+ }
43
+ match = property.exec(slice);
44
+ }
45
+ }
46
+ return problems;
47
+ }
48
+
49
+ /** The thrown message, or undefined when the script is clean or unreadable. */
50
+ export function evidencePreflightError(source: string, scriptPath: string): string | undefined {
51
+ const problems = findInvalidEvidenceKinds(source);
52
+ if (problems.length === 0) return undefined;
53
+ const listed = problems
54
+ .map((problem) => `line ${problem.line}: ${JSON.stringify(problem.kind)}`)
55
+ .join(", ");
56
+ return (
57
+ `${scriptPath}: evidence kind must be one of: ${EVIDENCE_KINDS.join(", ")} ` +
58
+ `(${listed}). Rejected before running, because an invalid kind would otherwise ` +
59
+ `throw at the end of the workflow and discard the work every agent had already done.`
60
+ );
61
+ }
62
+
63
+ interface MaskedSource {
64
+ /** The source with comment bodies and string interiors blanked to spaces, so
65
+ * structural scanning cannot be fooled by a brace or paren inside either.
66
+ * Same length as the input, so every index still maps back. */
67
+ masked: string;
68
+ /** String-literal value, keyed by the index of its opening quote. Template
69
+ * literals are absent: one may interpolate, so its value is not static. */
70
+ literals: Map<number, string>;
71
+ }
72
+
73
+ function maskSource(source: string): MaskedSource {
74
+ const out = source.split("");
75
+ const literals = new Map<number, string>();
76
+ let index = 0;
77
+ const blank = (from: number, to: number): void => {
78
+ for (let i = from; i < to && i < out.length; i++) {
79
+ if (out[i] !== "\n") out[i] = " ";
80
+ }
81
+ };
82
+
83
+ while (index < source.length) {
84
+ const char = source[index];
85
+ const next = source[index + 1];
86
+ if (char === "/" && next === "/") {
87
+ const end = source.indexOf("\n", index);
88
+ blank(index, end === -1 ? source.length : end);
89
+ index = end === -1 ? source.length : end;
90
+ continue;
91
+ }
92
+ if (char === "/" && next === "*") {
93
+ const end = source.indexOf("*/", index + 2);
94
+ const stop = end === -1 ? source.length : end + 2;
95
+ blank(index, stop);
96
+ index = stop;
97
+ continue;
98
+ }
99
+ if (char === '"' || char === "'" || char === "`") {
100
+ const start = index;
101
+ let cursor = index + 1;
102
+ let value = "";
103
+ while (cursor < source.length) {
104
+ const inner = source[cursor];
105
+ if (inner === "\\") {
106
+ value += source[cursor + 1] ?? "";
107
+ cursor += 2;
108
+ continue;
109
+ }
110
+ if (inner === char) break;
111
+ // An unterminated single- or double-quoted string cannot span lines, so
112
+ // stop rather than swallowing the rest of the file on a syntax error.
113
+ if (inner === "\n" && char !== "`") break;
114
+ value += inner;
115
+ cursor++;
116
+ }
117
+ const closed = source[cursor] === char;
118
+ blank(start + 1, cursor);
119
+ if (closed && char !== "`") literals.set(start, value);
120
+ index = closed ? cursor + 1 : cursor;
121
+ continue;
122
+ }
123
+ index++;
124
+ }
125
+ return { masked: out.join(""), literals };
126
+ }
127
+
128
+ /** The argument list of every `evidence(` call, as index ranges into the masked
129
+ * source. A dotted receiver (`ctx.evidence(`) counts; a longer identifier that
130
+ * merely ends in "evidence" does not. */
131
+ function evidenceCallRanges(masked: string): { start: number; end: number }[] {
132
+ const ranges: { start: number; end: number }[] = [];
133
+ const call = /evidence\s*\(/g;
134
+ let match = call.exec(masked);
135
+ while (match !== null) {
136
+ const before = match.index > 0 ? masked[match.index - 1]! : "";
137
+ if (!/[A-Za-z0-9_$]/.test(before)) {
138
+ const open = match.index + match[0].length - 1;
139
+ const close = matchingParen(masked, open);
140
+ if (close > open) ranges.push({ start: open + 1, end: close });
141
+ }
142
+ match = call.exec(masked);
143
+ }
144
+ return ranges;
145
+ }
146
+
147
+ function matchingParen(masked: string, open: number): number {
148
+ let depth = 0;
149
+ for (let i = open; i < masked.length; i++) {
150
+ if (masked[i] === "(") depth++;
151
+ else if (masked[i] === ")") {
152
+ depth--;
153
+ if (depth === 0) return i;
154
+ }
155
+ }
156
+ return -1;
157
+ }
158
+
159
+ function lineOf(source: string, index: number): number {
160
+ let line = 1;
161
+ for (let i = 0; i < index && i < source.length; i++) {
162
+ if (source[i] === "\n") line++;
163
+ }
164
+ return line;
165
+ }
@@ -50,14 +50,14 @@ export type {
50
50
  AcceptanceResult,
51
51
  AcceptanceStatus,
52
52
  AcceptanceSummary,
53
+ AdapterEvidenceCapability,
54
+ AdapterEvidenceCoverage,
55
+ AdapterName,
53
56
  AgentOpts,
54
57
  EngineOpts,
55
58
  EvidenceKind,
56
59
  EvidenceSource,
57
60
  EvidenceStatus,
58
- HarnessEvidenceCapability,
59
- HarnessEvidenceCoverage,
60
- HarnessName,
61
61
  ResultDigest,
62
62
  RunReport,
63
63
  Spawner,
@@ -16,10 +16,11 @@ import type {
16
16
  AcceptanceCriterion,
17
17
  AcceptanceResult,
18
18
  AcceptanceSummary,
19
- HarnessAttestationCitation,
20
- HarnessEvidenceCapability,
21
- HarnessEvidenceCoverage,
19
+ AdapterAttestationCitation,
20
+ AdapterEvidenceCapability,
21
+ AdapterEvidenceCoverage,
22
22
  ResultDigest,
23
+ RunFailureClass,
23
24
  SpawnFailureClass,
24
25
  WorkflowAgentProof,
25
26
  WorkflowAttemptContext,
@@ -34,7 +35,7 @@ import type {
34
35
  WorkflowSandboxProjectionEvidence,
35
36
  WorkflowWorkContext,
36
37
  } from "./types.ts";
37
- import { WORKFLOW_PROOF_SCHEMA_VERSION } from "./types.ts";
38
+ import { EVIDENCE_KINDS, WORKFLOW_PROOF_SCHEMA_VERSION } from "./types.ts";
38
39
  import { isCanonicalWorkflowWorkContext } from "./work-context.ts";
39
40
  import type {
40
41
  WorkspaceAttestation,
@@ -78,23 +79,26 @@ export interface BuildWorkflowProofInput {
78
79
  startedAt: string;
79
80
  endedAt: string;
80
81
  durationMs: number;
81
- journalPath: string;
82
+ transcriptPath: string;
82
83
  before: RepoSnapshot;
83
84
  after: RepoSnapshot;
84
85
  agents: WorkflowAgentProof[];
85
86
  evidence: WorkflowEvidenceRecord[];
86
- harnessEvidence?: Readonly<Record<string, HarnessEvidenceCapability | undefined>>;
87
+ adapterEvidence?: Readonly<Record<string, AdapterEvidenceCapability | undefined>>;
87
88
  /** Filesystem policy actually projected into children (ADR 0039). */
88
89
  sandboxProjection?: WorkflowSandboxProjectionEvidence;
89
- /** Live attestations backing each harness's claims (ADR 0038). Injected by
90
+ /** Live attestations backing each adapter's claims (ADR 0038). Injected by
90
91
  * the caller so proof stays free of filesystem lookups. */
91
- harnessAttestations?: Readonly<Record<string, HarnessAttestationCitation | undefined>>;
92
+ adapterAttestations?: Readonly<Record<string, AdapterAttestationCitation | undefined>>;
92
93
  policy?: {
93
94
  config: Readonly<NormalizedPolicy>;
94
95
  decisions: readonly PolicyDecision[];
95
96
  isolation: PolicyIsolation;
96
97
  networkAccess: PolicyNetworkAccess;
97
98
  };
99
+ /** Set when the script called ctx.blocked(): the run stopped because a human
100
+ * must rule. Forces run class "decision" regardless of the agents' classes. */
101
+ blocked?: { reason: string; decisionId?: string };
98
102
  workspaceBinding?: WorkspaceBinding;
99
103
  workspaceAttestation?: WorkspaceAttestation;
100
104
  workspaceFallback?: WorkspaceUnsupportedExecutionEvidence;
@@ -167,11 +171,7 @@ export function createEvidenceRecord(input: {
167
171
  id: `e${input.sequence}`,
168
172
  source: "workflow",
169
173
  recorded_at: input.recordedAt ?? new Date().toISOString(),
170
- kind: enumValue(
171
- value.kind,
172
- ["test", "command", "artifact", "change", "review", "observation"],
173
- "evidence kind",
174
- ),
174
+ kind: enumValue(value.kind, EVIDENCE_KINDS, "evidence kind"),
175
175
  status: enumValue(value.status, ["passed", "failed", "observed", "unknown"], "evidence status"),
176
176
  label: boundedRequired(value.label, "evidence label", MAX_LABEL_CHARS),
177
177
  summary: boundedOptional(value.summary, "evidence summary", MAX_SUMMARY_CHARS),
@@ -260,10 +260,16 @@ export function buildWorkflowProof(input: BuildWorkflowProofInput): WorkflowProo
260
260
  session_id: clippedOptional(agent.session_id, MAX_REF_CHARS),
261
261
  error: clippedOptional(agent.error, MAX_SUMMARY_CHARS),
262
262
  }));
263
- const harnesses = buildHarnessCoverage(agents, input.harnessEvidence, input.harnessAttestations);
264
- const unknowns = buildUnknowns(agents, harnesses, repository);
265
- const runClass = deriveRunFailureClass(input.status, agents);
266
- const journal = readFileSync(input.journalPath);
263
+ const adapters = buildAdapterCoverage(agents, input.adapterEvidence, input.adapterAttestations);
264
+ const unknowns = buildUnknowns(agents, adapters, repository);
265
+ // A declared stop-on-human beats a derived spawn class. If the script said a
266
+ // human must rule, that is the true reason the run ended, even when some agent
267
+ // also happened to hit a flaky vendor on the way there.
268
+ const runClass: RunFailureClass | undefined =
269
+ input.status === "failed" && input.blocked
270
+ ? "decision"
271
+ : deriveRunFailureClass(input.status, agents);
272
+ const transcript = readFileSync(input.transcriptPath);
267
273
  return {
268
274
  schema_version: WORKFLOW_PROOF_SCHEMA_VERSION,
269
275
  run: {
@@ -280,6 +286,9 @@ export function buildWorkflowProof(input: BuildWorkflowProofInput): WorkflowProo
280
286
  error: clippedOptional(input.error, MAX_SUMMARY_CHARS),
281
287
  result: input.result === undefined ? undefined : digestResult(input.result),
282
288
  ...(runClass ? { class: runClass } : {}),
289
+ ...(runClass === "decision" && input.blocked?.decisionId
290
+ ? { decision_id: clipped(input.blocked.decisionId, MAX_REF_CHARS) }
291
+ : {}),
283
292
  },
284
293
  acceptance,
285
294
  agents,
@@ -291,13 +300,13 @@ export function buildWorkflowProof(input: BuildWorkflowProofInput): WorkflowProo
291
300
  : input.workspaceFallback,
292
301
  repository,
293
302
  ...(input.sandboxProjection ? { sandbox_projection: input.sandboxProjection } : {}),
294
- harnesses,
303
+ adapters,
295
304
  unknowns,
296
305
  integrity: {
297
- journal: {
298
- path: "journal.jsonl",
299
- sha256: createHash("sha256").update(journal).digest("hex"),
300
- bytes: journal.byteLength,
306
+ transcript: {
307
+ path: "transcript.jsonl",
308
+ sha256: createHash("sha256").update(transcript).digest("hex"),
309
+ bytes: transcript.byteLength,
301
310
  },
302
311
  },
303
312
  };
@@ -361,7 +370,8 @@ export function readWorkflowProof(coordRoot: string, runId: string): WorkflowPro
361
370
  proof.run?.id !== runId ||
362
371
  (proof.run.class !== undefined &&
363
372
  proof.run.class !== "environment" &&
364
- proof.run.class !== "upstream") ||
373
+ proof.run.class !== "upstream" &&
374
+ proof.run.class !== "decision") ||
365
375
  (proof.run.work_context !== undefined &&
366
376
  (!proof.run.work_item_id ||
367
377
  proof.run.work_context.id !== proof.run.work_item_id ||
@@ -454,7 +464,7 @@ export function renderWorkflowProof(proof: WorkflowProof): string {
454
464
  lines.push(`unknowns: ${proof.unknowns.length}`);
455
465
  for (const unknown of proof.unknowns) lines.push(` - ${unknown.message}`);
456
466
  }
457
- lines.push(`journal sha256: ${proof.integrity.journal.sha256}`);
467
+ lines.push(`transcript sha256: ${proof.integrity.transcript.sha256}`);
458
468
  return `${lines.join("\n")}\n`;
459
469
  }
460
470
 
@@ -496,47 +506,47 @@ function normalizeRepoSnapshot(snapshot: RepoSnapshot): WorkflowRepoSnapshot {
496
506
  };
497
507
  }
498
508
 
499
- function buildHarnessCoverage(
509
+ function buildAdapterCoverage(
500
510
  agents: WorkflowAgentProof[],
501
- claims: Readonly<Record<string, HarnessEvidenceCapability | undefined>> | undefined,
502
- attestations: Readonly<Record<string, HarnessAttestationCitation | undefined>> | undefined,
503
- ): HarnessEvidenceCoverage[] {
504
- return [...new Set(agents.map((agent) => agent.harness))].map((harness) => {
505
- const harnessAgents = agents.filter((agent) => agent.harness === harness);
511
+ claims: Readonly<Record<string, AdapterEvidenceCapability | undefined>> | undefined,
512
+ attestations: Readonly<Record<string, AdapterAttestationCitation | undefined>> | undefined,
513
+ ): AdapterEvidenceCoverage[] {
514
+ return [...new Set(agents.map((agent) => agent.adapter))].map((adapter) => {
515
+ const adapterAgents = agents.filter((agent) => agent.adapter === adapter);
506
516
  return {
507
- harness,
508
- tool_evidence: claims?.[harness]?.toolEvidence ?? {
517
+ adapter,
518
+ tool_evidence: claims?.[adapter]?.toolEvidence ?? {
509
519
  support: "unknown",
510
- note: "No harness capability claim was supplied to this workflow run.",
520
+ note: "No adapter capability claim was supplied to this workflow run.",
511
521
  },
512
522
  observed: {
513
- final_results: harnessAgents.filter((agent) => agent.result).length,
514
- session_ids: harnessAgents.filter((agent) => agent.session_id).length,
515
- costs: harnessAgents.filter((agent) => agent.cost_usd !== undefined).length,
523
+ final_results: adapterAgents.filter((agent) => agent.result).length,
524
+ session_ids: adapterAgents.filter((agent) => agent.session_id).length,
525
+ costs: adapterAgents.filter((agent) => agent.cost_usd !== undefined).length,
516
526
  },
517
- ...(attestations?.[harness] ? { attestation: attestations[harness] } : {}),
527
+ ...(attestations?.[adapter] ? { attestation: attestations[adapter] } : {}),
518
528
  };
519
529
  });
520
530
  }
521
531
 
522
532
  function buildUnknowns(
523
533
  agents: WorkflowAgentProof[],
524
- harnesses: HarnessEvidenceCoverage[],
534
+ adapters: AdapterEvidenceCoverage[],
525
535
  repository: WorkflowRepoEvidence,
526
536
  ): WorkflowProofUnknown[] {
527
537
  const unknowns: WorkflowProofUnknown[] = [];
528
- for (const harness of harnesses) {
529
- if (harness.tool_evidence.support === "unknown") {
538
+ for (const adapter of adapters) {
539
+ if (adapter.tool_evidence.support === "unknown") {
530
540
  unknowns.push({
531
- code: "harness_capability_unregistered",
532
- harness: harness.harness,
533
- message: `${harness.harness}: tool-evidence capability was not registered for this run.`,
541
+ code: "adapter_capability_unregistered",
542
+ adapter: adapter.adapter,
543
+ message: `${adapter.adapter}: tool-evidence capability was not registered for this run.`,
534
544
  });
535
- } else if (harness.tool_evidence.support !== "supported") {
545
+ } else if (adapter.tool_evidence.support !== "supported") {
536
546
  unknowns.push({
537
547
  code: "tool_evidence_unavailable",
538
- harness: harness.harness,
539
- message: `${harness.harness}: adapter-native tool evidence is ${harness.tool_evidence.support}.`,
548
+ adapter: adapter.adapter,
549
+ message: `${adapter.adapter}: adapter-native tool evidence is ${adapter.tool_evidence.support}.`,
540
550
  });
541
551
  }
542
552
  }
@@ -544,17 +554,17 @@ function buildUnknowns(
544
554
  if (agent.cost_usd === undefined) {
545
555
  unknowns.push({
546
556
  code: "agent_cost_unreported",
547
- harness: agent.harness,
557
+ adapter: agent.adapter,
548
558
  agent_id: agent.id,
549
- message: `${agent.id}: ${agent.harness} did not report per-run cost.`,
559
+ message: `${agent.id}: ${agent.adapter} did not report per-run cost.`,
550
560
  });
551
561
  }
552
562
  if (!agent.session_id) {
553
563
  unknowns.push({
554
564
  code: "agent_session_unreported",
555
- harness: agent.harness,
565
+ adapter: agent.adapter,
556
566
  agent_id: agent.id,
557
- message: `${agent.id}: ${agent.harness} did not report a child session id.`,
567
+ message: `${agent.id}: ${agent.adapter} did not report a child session id.`,
558
568
  });
559
569
  }
560
570
  }
@@ -58,7 +58,7 @@ export interface WorkflowRunManifest {
58
58
  repository_before: RepoSnapshot;
59
59
  execution: {
60
60
  cwd: string;
61
- default_harness: string;
61
+ default_adapter: string;
62
62
  max_agents: number;
63
63
  concurrency: number;
64
64
  subscription_only: boolean;
@@ -149,11 +149,11 @@ export function assertWorkflowRunResumable(
149
149
  runId: string,
150
150
  ): { manifest: WorkflowRunManifest; approvalId: string } {
151
151
  const manifest = readWorkflowRunManifest(coordRoot, runId);
152
- const journalPath = join(coordRoot, ".harnery", "workflows", runId, "journal.jsonl");
153
- if (!existsSync(journalPath)) throw new Error(`workflow run ${runId} has no journal`);
152
+ const transcriptPath = join(coordRoot, ".harnery", "workflows", runId, "transcript.jsonl");
153
+ if (!existsSync(transcriptPath)) throw new Error(`workflow run ${runId} has no transcript`);
154
154
  let approvalId: string | undefined;
155
155
  let terminal = false;
156
- for (const line of readFileSync(journalPath, "utf8").split("\n")) {
156
+ for (const line of readFileSync(transcriptPath, "utf8").split("\n")) {
157
157
  if (!line.trim()) continue;
158
158
  try {
159
159
  const event = JSON.parse(line) as { event?: string; approval_id?: string };
@@ -162,7 +162,7 @@ export function assertWorkflowRunResumable(
162
162
  }
163
163
  if (event.event === "run.end") terminal = true;
164
164
  } catch {
165
- throw new Error(`workflow run ${runId} has a malformed journal line`);
165
+ throw new Error(`workflow run ${runId} has a malformed transcript line`);
166
166
  }
167
167
  }
168
168
  if (terminal) throw new Error(`workflow run ${runId} is already terminal`);
@@ -270,8 +270,8 @@ function validExecution(value: WorkflowRunManifest["execution"]): boolean {
270
270
  if (!value || typeof value !== "object") return false;
271
271
  return (
272
272
  isAbsolute(value.cwd) &&
273
- typeof value.default_harness === "string" &&
274
- value.default_harness.length > 0 &&
273
+ typeof value.default_adapter === "string" &&
274
+ value.default_adapter.length > 0 &&
275
275
  positiveSafeInteger(value.max_agents) &&
276
276
  positiveSafeInteger(value.concurrency) &&
277
277
  typeof value.subscription_only === "boolean" &&
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Project the host's filesystem policy into a harness's own vendor sandbox
2
+ * Project the host's filesystem policy into a adapter's own vendor sandbox
3
3
  * (ADR 0039).
4
4
  *
5
5
  * Harnery decides where a workflow child may write. Until this existed it never
@@ -14,12 +14,12 @@
14
14
  * not, which is worse than refusing and worse than never offering the feature.
15
15
  */
16
16
 
17
- import type { HarnessSandboxProjection } from "../harnesses/types.ts";
17
+ import type { AdapterSandboxProjection } from "../adapters/types.ts";
18
18
  import type { GitAdministrativeGrant, SpawnFilesystemPolicy } from "./types.ts";
19
19
  import type { WorkspaceBinding } from "./workspaces/types.ts";
20
20
 
21
21
  export class SandboxProjectionError extends Error {
22
- readonly harness: string;
22
+ readonly adapter: string;
23
23
  readonly reason:
24
24
  | "mode_unrepresentable"
25
25
  | "writable_roots_unrepresentable"
@@ -27,10 +27,10 @@ export class SandboxProjectionError extends Error {
27
27
  | "writable_root_escapes_workspace"
28
28
  | "git_grant_unavailable";
29
29
 
30
- constructor(harness: string, reason: SandboxProjectionError["reason"], message: string) {
30
+ constructor(adapter: string, reason: SandboxProjectionError["reason"], message: string) {
31
31
  super(message);
32
32
  this.name = "SandboxProjectionError";
33
- this.harness = harness;
33
+ this.adapter = adapter;
34
34
  this.reason = reason;
35
35
  }
36
36
  }
@@ -46,31 +46,31 @@ export interface ResolvedSandboxProjection {
46
46
  * Throws rather than degrading; see the module note.
47
47
  */
48
48
  export function resolveSandboxProjection(
49
- harness: string,
50
- declaration: HarnessSandboxProjection | undefined,
49
+ adapter: string,
50
+ declaration: AdapterSandboxProjection | undefined,
51
51
  policy: SpawnFilesystemPolicy,
52
52
  ): ResolvedSandboxProjection {
53
53
  if (!declaration) {
54
54
  throw new SandboxProjectionError(
55
- harness,
55
+ adapter,
56
56
  "no_projection",
57
- `${harness} cannot project a filesystem policy into its sandbox; remove the policy or use a harness that can`,
57
+ `${adapter} cannot project a filesystem policy into its sandbox; remove the policy or use a adapter that can`,
58
58
  );
59
59
  }
60
60
  const nativeMode = declaration.modes[policy.mode];
61
61
  if (!nativeMode) {
62
62
  throw new SandboxProjectionError(
63
- harness,
63
+ adapter,
64
64
  "mode_unrepresentable",
65
- `${harness} does not distinguish the "${policy.mode}" filesystem mode, so it cannot be enforced`,
65
+ `${adapter} does not distinguish the "${policy.mode}" filesystem mode, so it cannot be enforced`,
66
66
  );
67
67
  }
68
68
  const writableRoots = policy.writableRoots ?? [];
69
69
  if (writableRoots.length > 0 && !declaration.writableRoots) {
70
70
  throw new SandboxProjectionError(
71
- harness,
71
+ adapter,
72
72
  "writable_roots_unrepresentable",
73
- `${harness} does not accept an explicit writable-root set, so ${writableRoots.length} declared path(s) could not be enforced`,
73
+ `${adapter} does not accept an explicit writable-root set, so ${writableRoots.length} declared path(s) could not be enforced`,
74
74
  );
75
75
  }
76
76
  for (const root of writableRoots) {
@@ -78,7 +78,7 @@ export function resolveSandboxProjection(
78
78
  // resolved differently by every vendor, so they are refused outright.
79
79
  if (typeof root !== "string" || !root.startsWith("/")) {
80
80
  throw new SandboxProjectionError(
81
- harness,
81
+ adapter,
82
82
  "writable_roots_unrepresentable",
83
83
  `writable root ${JSON.stringify(root)} must be an absolute path`,
84
84
  );
@@ -103,14 +103,14 @@ function isWithin(root: string, candidate: string): boolean {
103
103
  * radius of a run that the workspace lifecycle believes it has contained.
104
104
  */
105
105
  export function assertProjectionWithinWorkspace(
106
- harness: string,
106
+ adapter: string,
107
107
  allowedRootRealpath: string,
108
108
  writableRoots: readonly string[],
109
109
  ): void {
110
110
  for (const root of writableRoots) {
111
111
  if (!isWithin(allowedRootRealpath, root)) {
112
112
  throw new SandboxProjectionError(
113
- harness,
113
+ adapter,
114
114
  "writable_root_escapes_workspace",
115
115
  `writable root ${JSON.stringify(root)} is outside the workspace root ${JSON.stringify(allowedRootRealpath)} the provider validated`,
116
116
  );
@@ -19,10 +19,10 @@
19
19
  */
20
20
 
21
21
  import { exec } from "../../lib/exec.ts";
22
- import { builtinHarnessProfile, validateHarnessEffort } from "../harnesses/profiles.ts";
23
- import type { HarnessInvocation, HarnessRawResult } from "../harnesses/types.ts";
22
+ import { builtinAdapterProfile, validateAdapterEffort } from "../adapters/profiles.ts";
23
+ import type { AdapterInvocation, AdapterRawResult } from "../adapters/types.ts";
24
+ import { notFoundError } from "./adapters.ts";
24
25
  import { buildChildEnv } from "./child-env.ts";
25
- import { notFoundError } from "./harnesses.ts";
26
26
  import { resolveSandboxProjection } from "./sandbox-projection.ts";
27
27
  import { isUpstreamFailureText, vendorFailureText } from "./spawn-failure.ts";
28
28
  import type { Spawner, SpawnRequest, SpawnResult } from "./types.ts";
@@ -37,13 +37,13 @@ interface ClaudeEnvelope {
37
37
  errors?: string[];
38
38
  }
39
39
 
40
- export function buildClaudeInvocation(req: SpawnRequest): HarnessInvocation {
41
- validateHarnessEffort("claude-code", req.effort);
40
+ export function buildClaudeInvocation(req: SpawnRequest): AdapterInvocation {
41
+ validateAdapterEffort("claude-code", req.effort);
42
42
  if (req.filesystemPolicy) {
43
43
  // Declared unrepresentable: refuse rather than drop it silently (ADR 0039).
44
44
  resolveSandboxProjection(
45
45
  "claude-code",
46
- builtinHarnessProfile("claude-code")?.sandboxProjection,
46
+ builtinAdapterProfile("claude-code")?.sandboxProjection,
47
47
  req.filesystemPolicy,
48
48
  );
49
49
  }
@@ -61,7 +61,7 @@ export function buildClaudeInvocation(req: SpawnRequest): HarnessInvocation {
61
61
  return { argv };
62
62
  }
63
63
 
64
- export function normalizeClaudeResult(raw: HarnessRawResult): SpawnResult {
64
+ export function normalizeClaudeResult(raw: AdapterRawResult): SpawnResult {
65
65
  if (raw.timedOut) {
66
66
  return {
67
67
  ok: false,
@@ -124,7 +124,7 @@ export function normalizeClaudeResult(raw: HarnessRawResult): SpawnResult {
124
124
  sessionId: envelope.session_id,
125
125
  costUsd: envelope.total_cost_usd,
126
126
  durationMs: raw.durationMs,
127
- error: `harness error (${envelope.subtype ?? "unknown"}): ${(envelope.errors ?? []).join("; ") || "see envelope"}`,
127
+ error: `adapter error (${envelope.subtype ?? "unknown"}): ${(envelope.errors ?? []).join("; ") || "see envelope"}`,
128
128
  ...(isUpstreamFailureText(envelopeError) ? { class: "upstream" as const } : {}),
129
129
  };
130
130
  }
@@ -140,7 +140,7 @@ export function normalizeClaudeResult(raw: HarnessRawResult): SpawnResult {
140
140
 
141
141
  export const claudeCodeSpawner: Spawner = async (req: SpawnRequest): Promise<SpawnResult> => {
142
142
  const t0 = Date.now();
143
- let invocation: HarnessInvocation;
143
+ let invocation: AdapterInvocation;
144
144
  try {
145
145
  invocation = buildClaudeInvocation(req);
146
146
  } catch (error) {
@@ -148,7 +148,10 @@ export const claudeCodeSpawner: Spawner = async (req: SpawnRequest): Promise<Spa
148
148
  }
149
149
  const r = await exec(invocation.argv, {
150
150
  cwd: req.cwd,
151
- env: buildChildEnv(req.runId, { subscriptionOnly: req.subscriptionOnly }),
151
+ env: buildChildEnv(req.runId, {
152
+ subscriptionOnly: req.subscriptionOnly,
153
+ agentId: req.agentId,
154
+ }),
152
155
  timeout: req.timeoutMs,
153
156
  });
154
157
  return normalizeClaudeResult({ ...r, durationMs: Date.now() - t0 });