harnery 0.36.0 → 0.38.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 (432) hide show
  1. package/dist/commander.d.ts +9 -0
  2. package/dist/commander.d.ts.map +1 -1
  3. package/dist/commander.js +10 -1
  4. package/dist/commands/admission.d.ts +21 -0
  5. package/dist/commands/admission.d.ts.map +1 -0
  6. package/dist/commands/admission.js +565 -0
  7. package/dist/commands/agents.d.ts +7 -0
  8. package/dist/commands/agents.d.ts.map +1 -1
  9. package/dist/commands/agents.js +148 -47
  10. package/dist/commands/artifacts.d.ts.map +1 -1
  11. package/dist/commands/artifacts.js +73 -2
  12. package/dist/commands/browse-ai.d.ts +2 -2
  13. package/dist/commands/browse-ai.d.ts.map +1 -1
  14. package/dist/commands/browse-ai.js +6 -4
  15. package/dist/commands/browse.d.ts.map +1 -1
  16. package/dist/commands/browse.js +360 -21
  17. package/dist/commands/diagnostics.d.ts +4 -0
  18. package/dist/commands/diagnostics.d.ts.map +1 -0
  19. package/dist/commands/diagnostics.js +229 -0
  20. package/dist/commands/fetch.js +1 -0
  21. package/dist/commands/files.d.ts +12 -0
  22. package/dist/commands/files.d.ts.map +1 -1
  23. package/dist/commands/files.js +54 -1
  24. package/dist/commands/governor.d.ts.map +1 -1
  25. package/dist/commands/governor.js +4 -0
  26. package/dist/commands/ledger-v3.d.ts.map +1 -1
  27. package/dist/commands/ledger-v3.js +71 -2
  28. package/dist/commands/qa-record.d.ts +144 -0
  29. package/dist/commands/qa-record.d.ts.map +1 -0
  30. package/dist/commands/qa-record.js +0 -0
  31. package/dist/commands/qa-run.d.ts +8 -0
  32. package/dist/commands/qa-run.d.ts.map +1 -0
  33. package/dist/commands/qa-run.js +396 -0
  34. package/dist/commands/qa-status.d.ts +71 -0
  35. package/dist/commands/qa-status.d.ts.map +1 -0
  36. package/dist/commands/qa-status.js +490 -0
  37. package/dist/commands/qa-verify.d.ts +40 -0
  38. package/dist/commands/qa-verify.d.ts.map +1 -0
  39. package/dist/commands/qa-verify.js +180 -0
  40. package/dist/commands/resources.d.ts +4 -0
  41. package/dist/commands/resources.d.ts.map +1 -0
  42. package/dist/commands/resources.js +29 -0
  43. package/dist/commands/review-pack.d.ts +4 -0
  44. package/dist/commands/review-pack.d.ts.map +1 -0
  45. package/dist/commands/review-pack.js +1001 -0
  46. package/dist/commands/supervisor.d.ts +4 -0
  47. package/dist/commands/supervisor.d.ts.map +1 -0
  48. package/dist/commands/supervisor.js +101 -0
  49. package/dist/commands/web.d.ts.map +1 -1
  50. package/dist/commands/web.js +17 -0
  51. package/dist/commands/workflow.d.ts.map +1 -1
  52. package/dist/commands/workflow.js +4 -0
  53. package/dist/core/agents/cli.js +7 -3
  54. package/dist/core/agents/health.d.ts +17 -0
  55. package/dist/core/agents/health.d.ts.map +1 -0
  56. package/dist/core/agents/health.js +109 -0
  57. package/dist/core/agents/mailbox.d.ts +92 -0
  58. package/dist/core/agents/mailbox.d.ts.map +1 -0
  59. package/dist/core/agents/mailbox.js +325 -0
  60. package/dist/core/agents/qa-signal.d.ts +111 -0
  61. package/dist/core/agents/qa-signal.d.ts.map +1 -0
  62. package/dist/core/agents/qa-signal.js +231 -0
  63. package/dist/core/agents/reconcile-coordination-v3.d.ts +44 -0
  64. package/dist/core/agents/reconcile-coordination-v3.d.ts.map +1 -0
  65. package/dist/core/agents/reconcile-coordination-v3.js +58 -0
  66. package/dist/core/agents/render/prompt-context.d.ts +5 -0
  67. package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
  68. package/dist/core/agents/render/prompt-context.js +34 -13
  69. package/dist/core/agents/render/session-context.d.ts +8 -0
  70. package/dist/core/agents/render/session-context.d.ts.map +1 -1
  71. package/dist/core/agents/render/session-context.js +34 -3
  72. package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
  73. package/dist/core/agents/rules/commit-conflict.js +50 -1
  74. package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
  75. package/dist/core/agents/rules/stop-hook.js +6 -10
  76. package/dist/core/agents/session-finalizer-v3.js +4 -1
  77. package/dist/core/agents/session-name-display.d.ts +20 -5
  78. package/dist/core/agents/session-name-display.d.ts.map +1 -1
  79. package/dist/core/agents/session-name-display.js +67 -7
  80. package/dist/core/agents/state/heartbeat-reader.d.ts +7 -0
  81. package/dist/core/agents/state/heartbeat-reader.d.ts.map +1 -1
  82. package/dist/core/agents/state/heartbeat-writer.d.ts +11 -0
  83. package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
  84. package/dist/core/agents/state/heartbeat-writer.js +17 -0
  85. package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
  86. package/dist/core/agents/state/live-coordination-view.js +1 -0
  87. package/dist/core/agents/state/live-coordination-writer.js +5 -0
  88. package/dist/core/artifacts/constants.d.ts +1 -1
  89. package/dist/core/artifacts/constants.js +1 -1
  90. package/dist/core/artifacts/index.d.ts +82 -6
  91. package/dist/core/artifacts/index.d.ts.map +1 -1
  92. package/dist/core/artifacts/index.js +410 -15
  93. package/dist/core/config.d.ts +20 -0
  94. package/dist/core/config.d.ts.map +1 -1
  95. package/dist/core/config.js +59 -0
  96. package/dist/core/diagnostics/advice.d.ts +9 -0
  97. package/dist/core/diagnostics/advice.d.ts.map +1 -0
  98. package/dist/core/diagnostics/advice.js +112 -0
  99. package/dist/core/diagnostics/bundle.d.ts +51 -0
  100. package/dist/core/diagnostics/bundle.d.ts.map +1 -0
  101. package/dist/core/diagnostics/bundle.js +968 -0
  102. package/dist/core/diagnostics/comparison.d.ts +5 -0
  103. package/dist/core/diagnostics/comparison.d.ts.map +1 -0
  104. package/dist/core/diagnostics/comparison.js +444 -0
  105. package/dist/core/diagnostics/contract.d.ts +245 -0
  106. package/dist/core/diagnostics/contract.d.ts.map +1 -0
  107. package/dist/core/diagnostics/contract.js +18 -0
  108. package/dist/core/diagnostics/identity.d.ts +3 -0
  109. package/dist/core/diagnostics/identity.d.ts.map +1 -0
  110. package/dist/core/diagnostics/identity.js +10 -0
  111. package/dist/core/diagnostics/index.d.ts +8 -0
  112. package/dist/core/diagnostics/index.d.ts.map +1 -0
  113. package/dist/core/diagnostics/index.js +7 -0
  114. package/dist/core/diagnostics/replay.d.ts +8 -0
  115. package/dist/core/diagnostics/replay.d.ts.map +1 -0
  116. package/dist/core/diagnostics/replay.js +213 -0
  117. package/dist/core/diagnostics/sanitize.d.ts +9 -0
  118. package/dist/core/diagnostics/sanitize.d.ts.map +1 -0
  119. package/dist/core/diagnostics/sanitize.js +84 -0
  120. package/dist/core/events/legacy-storage/compression.d.ts +13 -0
  121. package/dist/core/events/legacy-storage/compression.d.ts.map +1 -0
  122. package/dist/core/events/legacy-storage/compression.js +107 -0
  123. package/dist/core/events/legacy-storage/index.d.ts +1 -0
  124. package/dist/core/events/legacy-storage/index.d.ts.map +1 -1
  125. package/dist/core/events/legacy-storage/index.js +1 -0
  126. package/dist/core/events/v3/archive-retention.d.ts +33 -0
  127. package/dist/core/events/v3/archive-retention.d.ts.map +1 -0
  128. package/dist/core/events/v3/archive-retention.js +195 -0
  129. package/dist/core/events/v3/bootstrap.d.ts.map +1 -1
  130. package/dist/core/events/v3/bootstrap.js +10 -0
  131. package/dist/core/events/v3/capabilities.d.ts +1 -1
  132. package/dist/core/events/v3/capabilities.d.ts.map +1 -1
  133. package/dist/core/events/v3/capabilities.js +1 -0
  134. package/dist/core/events/v3/coordination-view.d.ts +3 -0
  135. package/dist/core/events/v3/coordination-view.d.ts.map +1 -1
  136. package/dist/core/events/v3/coordination-view.js +69 -8
  137. package/dist/core/events/v3/index.d.ts +1 -0
  138. package/dist/core/events/v3/index.d.ts.map +1 -1
  139. package/dist/core/events/v3/index.js +1 -0
  140. package/dist/core/events/v3/live-routing.d.ts.map +1 -1
  141. package/dist/core/events/v3/live-routing.js +1 -0
  142. package/dist/core/events/v3/producers/hook-base.d.ts +1 -1
  143. package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
  144. package/dist/core/events/v3/producers/hook-base.js +13 -2
  145. package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
  146. package/dist/core/events/v3/producers/intake.js +10 -2
  147. package/dist/core/events/v3/producers/recorder.d.ts +39 -0
  148. package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
  149. package/dist/core/events/v3/producers/recorder.js +350 -17
  150. package/dist/core/hooks/adapter/output.d.ts +8 -0
  151. package/dist/core/hooks/adapter/output.d.ts.map +1 -1
  152. package/dist/core/hooks/adapter/output.js +11 -1
  153. package/dist/core/hooks/cli.js +303 -219
  154. package/dist/core/hooks/health.d.ts +59 -0
  155. package/dist/core/hooks/health.d.ts.map +1 -0
  156. package/dist/core/hooks/health.js +84 -0
  157. package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
  158. package/dist/core/hooks/resolve/transcript.js +10 -3
  159. package/dist/core/hooks/session-name-presence.d.ts.map +1 -1
  160. package/dist/core/hooks/session-name-presence.js +4 -1
  161. package/dist/core/qa-artifacts.d.ts +20 -0
  162. package/dist/core/qa-artifacts.d.ts.map +1 -0
  163. package/dist/core/qa-artifacts.js +110 -0
  164. package/dist/core/resources/contract.d.ts +96 -0
  165. package/dist/core/resources/contract.d.ts.map +1 -0
  166. package/dist/core/resources/contract.js +2 -0
  167. package/dist/core/resources/index.d.ts +6 -0
  168. package/dist/core/resources/index.d.ts.map +1 -0
  169. package/dist/core/resources/index.js +5 -0
  170. package/dist/core/resources/sampler.d.ts +34 -0
  171. package/dist/core/resources/sampler.d.ts.map +1 -0
  172. package/dist/core/resources/sampler.js +458 -0
  173. package/dist/core/resources/service-status.d.ts +3 -0
  174. package/dist/core/resources/service-status.d.ts.map +1 -0
  175. package/dist/core/resources/service-status.js +48 -0
  176. package/dist/core/resources/service.d.ts +26 -0
  177. package/dist/core/resources/service.d.ts.map +1 -0
  178. package/dist/core/resources/service.js +292 -0
  179. package/dist/core/resources/storage.d.ts +13 -0
  180. package/dist/core/resources/storage.d.ts.map +1 -0
  181. package/dist/core/resources/storage.js +30 -0
  182. package/dist/core/storage/atomic-json.d.ts +3 -0
  183. package/dist/core/storage/atomic-json.d.ts.map +1 -0
  184. package/dist/core/storage/atomic-json.js +15 -0
  185. package/dist/core/storage/builtins.d.ts.map +1 -1
  186. package/dist/core/storage/builtins.js +45 -6
  187. package/dist/core/storage/logger.d.ts +2 -0
  188. package/dist/core/storage/logger.d.ts.map +1 -1
  189. package/dist/core/storage/logger.js +2 -0
  190. package/dist/core/storage/query.d.ts +14 -0
  191. package/dist/core/storage/query.d.ts.map +1 -1
  192. package/dist/core/storage/query.js +51 -0
  193. package/dist/core/supervisor/activity.d.ts +4 -0
  194. package/dist/core/supervisor/activity.d.ts.map +1 -0
  195. package/dist/core/supervisor/activity.js +141 -0
  196. package/dist/core/supervisor/contract.d.ts +268 -0
  197. package/dist/core/supervisor/contract.d.ts.map +1 -0
  198. package/dist/core/supervisor/contract.js +35 -0
  199. package/dist/core/supervisor/explanations.d.ts +4 -0
  200. package/dist/core/supervisor/explanations.d.ts.map +1 -0
  201. package/dist/core/supervisor/explanations.js +71 -0
  202. package/dist/core/supervisor/findings.d.ts +20 -0
  203. package/dist/core/supervisor/findings.d.ts.map +1 -0
  204. package/dist/core/supervisor/findings.js +399 -0
  205. package/dist/core/supervisor/history.d.ts +9 -0
  206. package/dist/core/supervisor/history.d.ts.map +1 -0
  207. package/dist/core/supervisor/history.js +46 -0
  208. package/dist/core/supervisor/hook-health-alerts.d.ts +14 -0
  209. package/dist/core/supervisor/hook-health-alerts.d.ts.map +1 -0
  210. package/dist/core/supervisor/hook-health-alerts.js +70 -0
  211. package/dist/core/supervisor/hook-health-storage.d.ts +5 -0
  212. package/dist/core/supervisor/hook-health-storage.d.ts.map +1 -0
  213. package/dist/core/supervisor/hook-health-storage.js +24 -0
  214. package/dist/core/supervisor/hook-health.d.ts +72 -0
  215. package/dist/core/supervisor/hook-health.d.ts.map +1 -0
  216. package/dist/core/supervisor/hook-health.js +203 -0
  217. package/dist/core/supervisor/hooks.d.ts +10 -0
  218. package/dist/core/supervisor/hooks.d.ts.map +1 -0
  219. package/dist/core/supervisor/hooks.js +28 -0
  220. package/dist/core/supervisor/index.d.ts +15 -0
  221. package/dist/core/supervisor/index.d.ts.map +1 -0
  222. package/dist/core/supervisor/index.js +14 -0
  223. package/dist/core/supervisor/log-feed.d.ts +9 -0
  224. package/dist/core/supervisor/log-feed.d.ts.map +1 -0
  225. package/dist/core/supervisor/log-feed.js +103 -0
  226. package/dist/core/supervisor/service.d.ts +29 -0
  227. package/dist/core/supervisor/service.d.ts.map +1 -0
  228. package/dist/core/supervisor/service.js +450 -0
  229. package/dist/core/supervisor/services.d.ts +11 -0
  230. package/dist/core/supervisor/services.d.ts.map +1 -0
  231. package/dist/core/supervisor/services.js +155 -0
  232. package/dist/core/supervisor/status.d.ts +3 -0
  233. package/dist/core/supervisor/status.d.ts.map +1 -0
  234. package/dist/core/supervisor/status.js +48 -0
  235. package/dist/core/supervisor/storage.d.ts +30 -0
  236. package/dist/core/supervisor/storage.d.ts.map +1 -0
  237. package/dist/core/supervisor/storage.js +73 -0
  238. package/dist/core/supervisor/timeline.d.ts +3 -0
  239. package/dist/core/supervisor/timeline.d.ts.map +1 -0
  240. package/dist/core/supervisor/timeline.js +87 -0
  241. package/dist/core/workflow/admission.d.ts +23 -0
  242. package/dist/core/workflow/admission.d.ts.map +1 -0
  243. package/dist/core/workflow/admission.js +136 -0
  244. package/dist/core/workflow/engine.d.ts.map +1 -1
  245. package/dist/core/workflow/engine.js +77 -2
  246. package/dist/core/workflow/index.d.ts +3 -2
  247. package/dist/core/workflow/index.d.ts.map +1 -1
  248. package/dist/core/workflow/index.js +2 -1
  249. package/dist/core/workflow/proof.d.ts +2 -1
  250. package/dist/core/workflow/proof.d.ts.map +1 -1
  251. package/dist/core/workflow/proof.js +39 -1
  252. package/dist/core/workflow/run-state.d.ts +3 -2
  253. package/dist/core/workflow/run-state.d.ts.map +1 -1
  254. package/dist/core/workflow/run-state.js +8 -1
  255. package/dist/core/workflow/types.d.ts +33 -1
  256. package/dist/core/workflow/types.d.ts.map +1 -1
  257. package/dist/core/workflow/types.js +2 -1
  258. package/dist/lib/admission.d.ts +71 -0
  259. package/dist/lib/admission.d.ts.map +1 -0
  260. package/dist/lib/admission.js +264 -0
  261. package/dist/lib/agent-browser/client.d.ts +1 -1
  262. package/dist/lib/agent-browser/client.d.ts.map +1 -1
  263. package/dist/lib/agent-browser/client.js +1 -5
  264. package/dist/lib/browser/capture-fidelity.d.ts +39 -0
  265. package/dist/lib/browser/capture-fidelity.d.ts.map +1 -0
  266. package/dist/lib/browser/capture-fidelity.js +84 -0
  267. package/dist/lib/browser/client.d.ts +46 -1
  268. package/dist/lib/browser/client.d.ts.map +1 -1
  269. package/dist/lib/browser/client.js +168 -9
  270. package/dist/lib/browser/critique.d.ts +38 -1
  271. package/dist/lib/browser/critique.d.ts.map +1 -1
  272. package/dist/lib/browser/critique.js +34 -6
  273. package/dist/lib/browser/index.d.ts +5 -1
  274. package/dist/lib/browser/index.d.ts.map +1 -1
  275. package/dist/lib/browser/index.js +4 -0
  276. package/dist/lib/browser/page-review-judge.d.ts +64 -0
  277. package/dist/lib/browser/page-review-judge.d.ts.map +1 -0
  278. package/dist/lib/browser/page-review-judge.js +270 -0
  279. package/dist/lib/browser/page-review-pack.d.ts +613 -0
  280. package/dist/lib/browser/page-review-pack.d.ts.map +1 -0
  281. package/dist/lib/browser/page-review-pack.js +1751 -0
  282. package/dist/lib/browser/qa-run-contracts.d.ts +377 -0
  283. package/dist/lib/browser/qa-run-contracts.d.ts.map +1 -0
  284. package/dist/lib/browser/qa-run-contracts.js +361 -0
  285. package/dist/lib/browser/qa-run.d.ts +141 -0
  286. package/dist/lib/browser/qa-run.d.ts.map +1 -0
  287. package/dist/lib/browser/qa-run.js +1283 -0
  288. package/dist/lib/browser/request-diagnostics.d.ts +13 -0
  289. package/dist/lib/browser/request-diagnostics.d.ts.map +1 -0
  290. package/dist/lib/browser/request-diagnostics.js +18 -0
  291. package/dist/lib/browser/tiling.d.ts +19 -0
  292. package/dist/lib/browser/tiling.d.ts.map +1 -1
  293. package/dist/lib/browser/tiling.js +28 -0
  294. package/dist/lib/cookies/client.d.ts +9 -0
  295. package/dist/lib/cookies/client.d.ts.map +1 -1
  296. package/dist/lib/cookies/client.js +197 -44
  297. package/dist/lib/cookies/extra.d.ts +18 -0
  298. package/dist/lib/cookies/extra.d.ts.map +1 -0
  299. package/dist/lib/cookies/extra.js +14 -0
  300. package/dist/lib/cookies/index.d.ts +2 -1
  301. package/dist/lib/cookies/index.d.ts.map +1 -1
  302. package/dist/lib/cookies/index.js +2 -1
  303. package/dist/lib/coord-root-id.d.ts +9 -0
  304. package/dist/lib/coord-root-id.d.ts.map +1 -0
  305. package/dist/lib/coord-root-id.js +17 -0
  306. package/dist/lib/durable-job.d.ts +124 -0
  307. package/dist/lib/durable-job.d.ts.map +1 -0
  308. package/dist/lib/durable-job.js +296 -0
  309. package/dist/lib/http/client.d.ts +7 -1
  310. package/dist/lib/http/client.d.ts.map +1 -1
  311. package/dist/lib/http/client.js +2 -0
  312. package/dist/lib/instructions/apply.d.ts +3 -1
  313. package/dist/lib/instructions/apply.d.ts.map +1 -1
  314. package/dist/lib/instructions/apply.js +74 -3
  315. package/dist/lib/instructions/templates.d.ts.map +1 -1
  316. package/dist/lib/instructions/templates.js +11 -2
  317. package/package.json +19 -2
  318. package/src/commander.ts +75 -1
  319. package/src/commands/admission.ts +699 -0
  320. package/src/commands/agents.ts +189 -50
  321. package/src/commands/artifacts.ts +132 -18
  322. package/src/commands/browse-ai.ts +10 -5
  323. package/src/commands/browse.ts +496 -20
  324. package/src/commands/diagnostics.ts +271 -0
  325. package/src/commands/fetch.ts +1 -0
  326. package/src/commands/files.ts +102 -2
  327. package/src/commands/governor.ts +8 -0
  328. package/src/commands/ledger-v3.ts +82 -0
  329. package/src/commands/qa-record.ts +682 -0
  330. package/src/commands/qa-run.ts +503 -0
  331. package/src/commands/qa-status.ts +608 -0
  332. package/src/commands/qa-verify.ts +238 -0
  333. package/src/commands/resources.ts +38 -0
  334. package/src/commands/review-pack.ts +1281 -0
  335. package/src/commands/supervisor.ts +141 -0
  336. package/src/commands/web.ts +19 -0
  337. package/src/commands/workflow.ts +8 -0
  338. package/src/core/agents/cli.ts +7 -3
  339. package/src/core/agents/health.ts +142 -0
  340. package/src/core/agents/mailbox.ts +373 -0
  341. package/src/core/agents/qa-signal.ts +261 -0
  342. package/src/core/agents/reconcile-coordination-v3.ts +77 -0
  343. package/src/core/agents/render/prompt-context.ts +42 -12
  344. package/src/core/agents/render/session-context.ts +37 -3
  345. package/src/core/agents/rules/commit-conflict.ts +58 -1
  346. package/src/core/agents/rules/stop-hook.ts +6 -12
  347. package/src/core/agents/session-finalizer-v3.ts +4 -1
  348. package/src/core/agents/session-name-display.ts +78 -7
  349. package/src/core/agents/state/heartbeat-reader.ts +7 -0
  350. package/src/core/agents/state/heartbeat-writer.ts +23 -0
  351. package/src/core/agents/state/live-coordination-view.ts +1 -0
  352. package/src/core/agents/state/live-coordination-writer.ts +5 -0
  353. package/src/core/artifacts/constants.ts +1 -1
  354. package/src/core/artifacts/index.ts +565 -30
  355. package/src/core/config.ts +134 -2
  356. package/src/core/diagnostics/advice.ts +147 -0
  357. package/src/core/diagnostics/bundle.ts +1250 -0
  358. package/src/core/diagnostics/comparison.ts +565 -0
  359. package/src/core/diagnostics/contract.ts +311 -0
  360. package/src/core/diagnostics/identity.ts +11 -0
  361. package/src/core/diagnostics/index.ts +7 -0
  362. package/src/core/diagnostics/replay.ts +314 -0
  363. package/src/core/diagnostics/sanitize.ts +97 -0
  364. package/src/core/events/legacy-storage/compression.ts +130 -0
  365. package/src/core/events/legacy-storage/index.ts +1 -0
  366. package/src/core/events/v3/archive-retention.ts +251 -0
  367. package/src/core/events/v3/bootstrap.ts +10 -0
  368. package/src/core/events/v3/capabilities.ts +2 -0
  369. package/src/core/events/v3/coordination-view.ts +100 -11
  370. package/src/core/events/v3/index.ts +9 -0
  371. package/src/core/events/v3/live-routing.ts +1 -0
  372. package/src/core/events/v3/producers/hook-base.ts +14 -2
  373. package/src/core/events/v3/producers/intake.ts +10 -2
  374. package/src/core/events/v3/producers/recorder.ts +420 -17
  375. package/src/core/hooks/adapter/output.ts +12 -1
  376. package/src/core/hooks/cli.ts +332 -247
  377. package/src/core/hooks/health.ts +146 -0
  378. package/src/core/hooks/resolve/transcript.ts +10 -3
  379. package/src/core/hooks/session-name-presence.ts +6 -1
  380. package/src/core/qa-artifacts.ts +126 -0
  381. package/src/core/resources/contract.ts +105 -0
  382. package/src/core/resources/index.ts +5 -0
  383. package/src/core/resources/sampler.ts +590 -0
  384. package/src/core/resources/service-status.ts +62 -0
  385. package/src/core/resources/service.ts +337 -0
  386. package/src/core/resources/storage.ts +44 -0
  387. package/src/core/storage/atomic-json.ts +15 -0
  388. package/src/core/storage/builtins.ts +62 -6
  389. package/src/core/storage/logger.ts +2 -0
  390. package/src/core/storage/query.ts +58 -0
  391. package/src/core/supervisor/activity.ts +193 -0
  392. package/src/core/supervisor/contract.ts +312 -0
  393. package/src/core/supervisor/explanations.ts +104 -0
  394. package/src/core/supervisor/findings.ts +788 -0
  395. package/src/core/supervisor/history.ts +61 -0
  396. package/src/core/supervisor/hook-health-alerts.ts +108 -0
  397. package/src/core/supervisor/hook-health-storage.ts +25 -0
  398. package/src/core/supervisor/hook-health.ts +301 -0
  399. package/src/core/supervisor/hooks.ts +35 -0
  400. package/src/core/supervisor/index.ts +14 -0
  401. package/src/core/supervisor/log-feed.ts +131 -0
  402. package/src/core/supervisor/service.ts +511 -0
  403. package/src/core/supervisor/services.ts +203 -0
  404. package/src/core/supervisor/status.ts +59 -0
  405. package/src/core/supervisor/storage.ts +126 -0
  406. package/src/core/supervisor/timeline.ts +133 -0
  407. package/src/core/workflow/admission.ts +215 -0
  408. package/src/core/workflow/engine.ts +93 -1
  409. package/src/core/workflow/index.ts +10 -0
  410. package/src/core/workflow/proof.ts +54 -1
  411. package/src/core/workflow/run-state.ts +13 -1
  412. package/src/core/workflow/types.ts +39 -1
  413. package/src/lib/admission.ts +347 -0
  414. package/src/lib/agent-browser/client.ts +2 -10
  415. package/src/lib/browser/capture-fidelity.ts +98 -0
  416. package/src/lib/browser/client.ts +212 -10
  417. package/src/lib/browser/critique.ts +62 -7
  418. package/src/lib/browser/index.ts +65 -0
  419. package/src/lib/browser/page-review-judge.ts +360 -0
  420. package/src/lib/browser/page-review-pack.ts +2384 -0
  421. package/src/lib/browser/qa-run-contracts.ts +743 -0
  422. package/src/lib/browser/qa-run.ts +1462 -0
  423. package/src/lib/browser/request-diagnostics.ts +27 -0
  424. package/src/lib/browser/tiling.ts +32 -0
  425. package/src/lib/cookies/client.ts +228 -42
  426. package/src/lib/cookies/extra.ts +28 -0
  427. package/src/lib/cookies/index.ts +2 -0
  428. package/src/lib/coord-root-id.ts +23 -0
  429. package/src/lib/durable-job.ts +407 -0
  430. package/src/lib/http/client.ts +13 -1
  431. package/src/lib/instructions/apply.ts +81 -2
  432. package/src/lib/instructions/templates.ts +11 -2
@@ -0,0 +1,146 @@
1
+ import type { Adapter } from "../adapter.ts";
2
+ import { processLogger } from "../storage/logger.ts";
3
+
4
+ export const HOOK_HEALTH_EVENT = "agent_hook.completed" as const;
5
+ export const HOOK_HEALTH_RECEIPT_VERSION = 1 as const;
6
+ export const HOOK_HEALTH_ERROR_PHASE_LIMIT = 8;
7
+
8
+ export type HookHealthOutcome = "completed" | "skipped" | "degraded" | "faulted";
9
+
10
+ export interface HookHealthState {
11
+ readonly started_at_ms: number;
12
+ readonly started_rss_bytes: number;
13
+ readonly event_name: string | null;
14
+ readonly adapter: Adapter | null;
15
+ readonly payload_bytes: number;
16
+ coord_root: string | null;
17
+ owner_id?: string;
18
+ skipped_reason?: string;
19
+ v3_state?: string;
20
+ error_phases: string[];
21
+ }
22
+
23
+ export interface HookHealthReceipt {
24
+ receipt_version: typeof HOOK_HEALTH_RECEIPT_VERSION;
25
+ hook_name: string;
26
+ adapter: Adapter | "unknown";
27
+ outcome: HookHealthOutcome;
28
+ exit_contract: "always-zero";
29
+ exit_code: 0;
30
+ duration_ms: number;
31
+ payload_bytes: number;
32
+ pid: number;
33
+ rss_start_bytes: number;
34
+ rss_end_bytes: number;
35
+ rss_delta_bytes: number;
36
+ retry_worker: boolean;
37
+ error_count: number;
38
+ error_phases: readonly string[];
39
+ owner_id?: string;
40
+ skipped_reason?: string;
41
+ v3_state?: string;
42
+ }
43
+
44
+ export function beginHookHealth(input: {
45
+ started_at_ms: number;
46
+ started_rss_bytes: number;
47
+ event_name: string | null;
48
+ adapter: Adapter | null;
49
+ payload_bytes: number;
50
+ }): HookHealthState {
51
+ return {
52
+ ...input,
53
+ coord_root: null,
54
+ error_phases: [],
55
+ };
56
+ }
57
+
58
+ export function observeHookDebug(
59
+ state: HookHealthState | undefined,
60
+ entry: Readonly<Record<string, unknown>>,
61
+ ): void {
62
+ if (!state) return;
63
+ const skipped = safeToken(entry.skipped);
64
+ if (skipped) state.skipped_reason = skipped;
65
+ const v3State = safeToken(entry.event_v3_state);
66
+ if (v3State) state.v3_state = v3State;
67
+ }
68
+
69
+ export function observeHookError(state: HookHealthState | undefined, phase: unknown): void {
70
+ if (!state || state.error_phases.length >= HOOK_HEALTH_ERROR_PHASE_LIMIT) return;
71
+ state.error_phases.push(safeToken(phase) ?? "unknown");
72
+ }
73
+
74
+ export function finalizeHookHealth(
75
+ state: HookHealthState,
76
+ input: {
77
+ finished_at_ms: number;
78
+ finished_rss_bytes: number;
79
+ pid: number;
80
+ faulted?: boolean;
81
+ },
82
+ ): HookHealthReceipt {
83
+ const duration = Math.max(0, Math.floor(input.finished_at_ms - state.started_at_ms));
84
+ const rssStart = boundedInteger(state.started_rss_bytes);
85
+ const rssEnd = boundedInteger(input.finished_rss_bytes);
86
+ const hookName = safeToken(state.event_name) ?? "unknown";
87
+ return {
88
+ receipt_version: HOOK_HEALTH_RECEIPT_VERSION,
89
+ hook_name: hookName,
90
+ adapter: state.adapter ?? "unknown",
91
+ outcome: input.faulted
92
+ ? "faulted"
93
+ : state.error_phases.length > 0
94
+ ? "degraded"
95
+ : state.skipped_reason
96
+ ? "skipped"
97
+ : "completed",
98
+ exit_contract: "always-zero",
99
+ exit_code: 0,
100
+ duration_ms: duration,
101
+ payload_bytes: boundedInteger(state.payload_bytes),
102
+ pid: boundedInteger(input.pid),
103
+ rss_start_bytes: rssStart,
104
+ rss_end_bytes: rssEnd,
105
+ rss_delta_bytes: rssEnd - rssStart,
106
+ retry_worker: hookName === "runtime-context-retry",
107
+ error_count: state.error_phases.length,
108
+ error_phases: [...state.error_phases],
109
+ ...(state.owner_id ? { owner_id: state.owner_id } : {}),
110
+ ...(state.skipped_reason ? { skipped_reason: state.skipped_reason } : {}),
111
+ ...(state.v3_state ? { v3_state: state.v3_state } : {}),
112
+ };
113
+ }
114
+
115
+ export function writeHookHealthCompletion(
116
+ state: HookHealthState | undefined,
117
+ input: {
118
+ finished_at_ms: number;
119
+ finished_rss_bytes: number;
120
+ pid: number;
121
+ faulted?: boolean;
122
+ },
123
+ ): HookHealthReceipt | undefined {
124
+ if (!state?.coord_root) return undefined;
125
+ const receipt = finalizeHookHealth(state, input);
126
+ try {
127
+ processLogger(state.coord_root, "agent-hook").info(HOOK_HEALTH_EVENT, { ...receipt });
128
+ } catch {
129
+ // Hook health is observer-only. Logging can never change adapter behavior.
130
+ }
131
+ return receipt;
132
+ }
133
+
134
+ function safeToken(value: unknown): string | undefined {
135
+ if (typeof value !== "string") return undefined;
136
+ const normalized = value
137
+ .trim()
138
+ .slice(0, 128)
139
+ .replace(/[^a-zA-Z0-9._:/+-]+/g, "-");
140
+ return /^[a-zA-Z0-9]/.test(normalized) ? normalized : undefined;
141
+ }
142
+
143
+ function boundedInteger(value: number): number {
144
+ if (!Number.isFinite(value)) return 0;
145
+ return Math.max(0, Math.min(Number.MAX_SAFE_INTEGER, Math.floor(value)));
146
+ }
@@ -167,9 +167,16 @@ export function inspectSessionNameDisplayImmediately(
167
167
  awaitingReply = false;
168
168
  }
169
169
  }
170
- return sawMintResult && awaitingReply
171
- ? { state: "unavailable", reason: "transcript_not_ready" }
172
- : { state: "absent" };
170
+ // Some adapter transcripts persist assistant messages and tool requests but
171
+ // omit tool-result rows entirely. A readable file with no mint result cannot
172
+ // establish the ordered verification boundary, so it is unavailable evidence
173
+ // rather than proof that the agent displayed the title incorrectly. Only a
174
+ // transcript that contains the mint followed by a non-matching assistant
175
+ // reply can safely deny the next tool.
176
+ if (!sawMintResult || awaitingReply) {
177
+ return { state: "unavailable", reason: "transcript_not_ready" };
178
+ }
179
+ return { state: "absent" };
173
180
  }
174
181
 
175
182
  /**
@@ -22,6 +22,7 @@
22
22
  * Never throws: coordination telemetry must not take down a hook.
23
23
  */
24
24
 
25
+ import { sessionNameDisplayAcceptedNames } from "../agents/session-name-display.ts";
25
26
  import { stampSessionNameSeen } from "../agents/state/heartbeat-writer.ts";
26
27
  import { readLiveCoordinationRow } from "../agents/state/live-coordination-view.ts";
27
28
 
@@ -42,7 +43,11 @@ export function sessionNamePresence(
42
43
  if (row?.session_name_seen_for === name) {
43
44
  return { session_name_present: true, session_name_present_for: name };
44
45
  }
45
- const present = scanAssistantText(name);
46
+ // A display of the title Harnery last asked for counts here too, so Stop
47
+ // and the PreToolUse gate cannot disagree about the same reply.
48
+ const present = sessionNameDisplayAcceptedNames(row).some((candidate) =>
49
+ scanAssistantText(candidate),
50
+ );
46
51
  if (present) stampSessionNameSeen(coordRoot, instanceId, name);
47
52
  return { session_name_present: present, session_name_present_for: name };
48
53
  } catch {
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Managed output workspaces for page-QA commands.
3
+ *
4
+ * An implicit qa-run/qa-record output is working evidence, not project source.
5
+ * Keep it in the bounded artifact store. Callers that pass --out-dir retain
6
+ * full control of that explicit destination.
7
+ */
8
+
9
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
10
+ import { join, resolve } from "node:path";
11
+ import type { HarneryProgramContext } from "../commander.ts";
12
+ import { monorepoRoot } from "./agents/index.ts";
13
+ import {
14
+ ARTIFACT_MANIFEST,
15
+ type ArtifactManifestV2,
16
+ artifactsRoot,
17
+ configuredArtifactRetentionDays,
18
+ createArtifact,
19
+ parseArtifactManifest,
20
+ } from "./artifacts/index.ts";
21
+
22
+ export type QaArtifactKind = "qa-run" | "qa-record" | "review-pack";
23
+
24
+ export function resolveQaRepoRoot(context?: HarneryProgramContext): string {
25
+ return resolve(context?.repoRoot ?? monorepoRoot() ?? process.cwd());
26
+ }
27
+
28
+ export function createManagedQaOutParent(
29
+ repoRoot: string,
30
+ kind: QaArtifactKind,
31
+ opts: { retentionMinutes?: number } = {},
32
+ ): string {
33
+ return createArtifact(repoRoot, {
34
+ slug: kind,
35
+ purpose:
36
+ kind === "qa-run"
37
+ ? "Page QA run evidence"
38
+ : kind === "review-pack"
39
+ ? "Page review pack"
40
+ : "Hand-recorded page QA evidence",
41
+ retentionDays: configuredArtifactRetentionDays(repoRoot),
42
+ // A standalone review-pack workspace IS the pack, so the artifact store's
43
+ // own expiry follows the pack's (90 minutes by default, ruled 2026-09-02).
44
+ ...(opts.retentionMinutes !== undefined ? { retentionMinutes: opts.retentionMinutes } : {}),
45
+ }).path;
46
+ }
47
+
48
+ /**
49
+ * Find the newest run in a valid managed QA workspace. This keeps no-path
50
+ * `qa-status` useful even though every implicit invocation gets an isolated
51
+ * artifact workspace instead of sharing one root-level `.qa-run` directory.
52
+ */
53
+ export function latestManagedQaRun(repoRoot: string): string | null {
54
+ const root = artifactsRoot(repoRoot);
55
+ if (!existsSync(root)) return null;
56
+
57
+ let workspaceNames: string[];
58
+ try {
59
+ workspaceNames = readdirSync(root).sort();
60
+ } catch {
61
+ return null;
62
+ }
63
+
64
+ let latest: { path: string; startedAtMs: number } | null = null;
65
+ for (const workspaceName of workspaceNames) {
66
+ const workspace = join(root, workspaceName);
67
+ const manifest = readQaManifest(join(workspace, ARTIFACT_MANIFEST));
68
+ if (!manifest) continue;
69
+
70
+ let runNames: string[];
71
+ try {
72
+ runNames = readdirSync(workspace)
73
+ .filter((name) => name.startsWith("run-"))
74
+ .sort();
75
+ } catch {
76
+ continue;
77
+ }
78
+ for (const runName of runNames) {
79
+ const runDir = join(workspace, runName);
80
+ const startedAtMs = readStartedAtMs(runDir);
81
+ if (startedAtMs === null) continue;
82
+ if (
83
+ latest === null ||
84
+ startedAtMs > latest.startedAtMs ||
85
+ (startedAtMs === latest.startedAtMs && runDir > latest.path)
86
+ ) {
87
+ latest = { path: runDir, startedAtMs };
88
+ }
89
+ }
90
+ }
91
+ return latest?.path ?? null;
92
+ }
93
+
94
+ function readQaManifest(path: string): ArtifactManifestV2 | null {
95
+ try {
96
+ const parsed = parseArtifactManifest(JSON.parse(readFileSync(path, "utf8")));
97
+ if (!parsed.ok) return null;
98
+ if (parsed.manifest.slug !== "qa-run" && parsed.manifest.slug !== "qa-record") return null;
99
+ return parsed.manifest;
100
+ } catch {
101
+ return null;
102
+ }
103
+ }
104
+
105
+ function readStartedAtMs(runDir: string): number | null {
106
+ for (const file of ["run-status.json", "page-qa-result.json"]) {
107
+ try {
108
+ const value = JSON.parse(readFileSync(join(runDir, file), "utf8")) as Record<string, unknown>;
109
+ const run = value.run;
110
+ const startedAt =
111
+ typeof value.started_at === "string"
112
+ ? value.started_at
113
+ : run &&
114
+ typeof run === "object" &&
115
+ typeof (run as Record<string, unknown>).started_at === "string"
116
+ ? ((run as Record<string, unknown>).started_at as string)
117
+ : null;
118
+ if (!startedAt) continue;
119
+ const parsed = Date.parse(startedAt);
120
+ if (!Number.isNaN(parsed)) return parsed;
121
+ } catch {
122
+ // Try the other authoritative run document.
123
+ }
124
+ }
125
+ return null;
126
+ }
@@ -0,0 +1,105 @@
1
+ export const RESOURCE_SNAPSHOT_SCHEMA_VERSION = 1;
2
+ export const RESOURCE_SERVICE_STATUS_SCHEMA_VERSION = 1;
3
+
4
+ export type ResourceSupportState = "supported" | "partial" | "unsupported" | "error";
5
+
6
+ export interface ResourceProcessSample {
7
+ pid: number;
8
+ ppid: number;
9
+ start_id: string;
10
+ state: string;
11
+ name: string;
12
+ command: string;
13
+ cpu_percent: number | null;
14
+ rss_bytes: number;
15
+ age_seconds: number;
16
+ owner_kind: "agent" | "service" | "unattributed";
17
+ owner_id: string | null;
18
+ owner_root_pid: number | null;
19
+ owner_source?: "pid-map" | "session-environment" | "service";
20
+ }
21
+
22
+ export interface ResourceProcessGroup {
23
+ kind: ResourceProcessSample["owner_kind"];
24
+ id: string;
25
+ process_count: number;
26
+ cpu_percent: number | null;
27
+ rss_bytes: number;
28
+ root_pids: number[];
29
+ }
30
+
31
+ export interface ResourceMachineSample {
32
+ cpu_percent: number | null;
33
+ cpu_logical_count: number;
34
+ load_average: [number, number, number] | null;
35
+ memory_total_bytes: number | null;
36
+ memory_available_bytes: number | null;
37
+ memory_used_bytes: number | null;
38
+ memory_percent: number | null;
39
+ swap_total_bytes: number | null;
40
+ swap_used_bytes: number | null;
41
+ process_count: number;
42
+ }
43
+
44
+ export interface ResourceSnapshot {
45
+ schema_version: typeof RESOURCE_SNAPSHOT_SCHEMA_VERSION;
46
+ sampled_at: string;
47
+ interval_ms: number | null;
48
+ sample_duration_ms: number;
49
+ collector_cpu_ms: number;
50
+ platform: NodeJS.Platform;
51
+ namespace: "host" | "wsl" | "unknown";
52
+ support: {
53
+ state: ResourceSupportState;
54
+ sampler: "procfs" | "unsupported";
55
+ reason?: string;
56
+ };
57
+ machine: ResourceMachineSample;
58
+ groups: ResourceProcessGroup[];
59
+ processes: ResourceProcessSample[];
60
+ visible_process_count: number;
61
+ omitted_process_count: number;
62
+ unattributed_process_count: number;
63
+ }
64
+
65
+ export interface ResourceServiceStatusRecord {
66
+ schema_version: typeof RESOURCE_SERVICE_STATUS_SCHEMA_VERSION;
67
+ pid: number;
68
+ start_token?: string;
69
+ host: string;
70
+ nonce: string;
71
+ state: "starting" | "running" | "stopping" | "stopped" | "error";
72
+ started_at: string;
73
+ heartbeat_at: string;
74
+ stopped_at?: string;
75
+ interval_ms: number;
76
+ sample_count: number;
77
+ last_sample_at?: string;
78
+ last_error_code?: string;
79
+ }
80
+
81
+ export interface ResourceServiceStatus {
82
+ running: boolean;
83
+ stale: boolean;
84
+ record?: ResourceServiceStatusRecord;
85
+ status_path: string;
86
+ snapshot_path: string;
87
+ }
88
+
89
+ export interface ResourceSamplerState {
90
+ sampled_at_ms: number;
91
+ cpu_total_ticks: number;
92
+ cpu_idle_ticks: number;
93
+ process_ticks: Map<string, number>;
94
+ process_owners: Map<string, ResourceProcessOwnerProof>;
95
+ }
96
+
97
+ export interface ResourceProcessOwnerProof {
98
+ session_id: string;
99
+ instance_id: string;
100
+ }
101
+
102
+ export interface ResourceSampleResult {
103
+ snapshot: ResourceSnapshot;
104
+ state?: ResourceSamplerState;
105
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./contract.ts";
2
+ export * from "./sampler.ts";
3
+ export * from "./service.ts";
4
+ export * from "./service-status.ts";
5
+ export * from "./storage.ts";