@jinn-network/client 0.1.2 → 0.1.3-canary.216cf7e6

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 (1461) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/CONTRIBUTING.md +9 -2
  3. package/README.md +67 -47
  4. package/deployments/deployment-jinn-mvi-l1-sepolia-fast.json +36 -0
  5. package/deployments/deployment-jinn-mvi-l1-sepolia.json +36 -0
  6. package/deployments/deployment-jinn-mvi-l2-baseSepolia.json +12 -0
  7. package/deployments/deployment-phase1b-mech-baseSepolia-fast.json +3 -3
  8. package/deployments/deployment-stolas-l2-baseSepolia-fast.json +1 -1
  9. package/deployments/deployment-task-coordinator-router-v3-baseSepolia-fast.json +38 -0
  10. package/dist/adapters/adapter.d.ts +19 -8
  11. package/dist/adapters/local/adapter.d.ts +10 -9
  12. package/dist/adapters/local/adapter.js +52 -79
  13. package/dist/adapters/local/adapter.js.map +1 -1
  14. package/dist/adapters/mech/adapter.d.ts +41 -15
  15. package/dist/adapters/mech/adapter.js +623 -362
  16. package/dist/adapters/mech/adapter.js.map +1 -1
  17. package/dist/adapters/mech/contracts.d.ts +82 -20
  18. package/dist/adapters/mech/contracts.js +374 -100
  19. package/dist/adapters/mech/contracts.js.map +1 -1
  20. package/dist/adapters/mech/ipfs.d.ts +66 -12
  21. package/dist/adapters/mech/ipfs.js +165 -30
  22. package/dist/adapters/mech/ipfs.js.map +1 -1
  23. package/dist/adapters/mech/safe-revert.d.ts +40 -0
  24. package/dist/adapters/mech/safe-revert.js +261 -0
  25. package/dist/adapters/mech/safe-revert.js.map +1 -0
  26. package/dist/adapters/mech/safe.js +48 -22
  27. package/dist/adapters/mech/safe.js.map +1 -1
  28. package/dist/adapters/mech/task-subgraph.d.ts +23 -0
  29. package/dist/adapters/mech/task-subgraph.js +157 -0
  30. package/dist/adapters/mech/task-subgraph.js.map +1 -0
  31. package/dist/adapters/mech/types.d.ts +263 -84
  32. package/dist/adapters/mech/types.js +125 -50
  33. package/dist/adapters/mech/types.js.map +1 -1
  34. package/dist/agent/agent-ws.d.ts +57 -0
  35. package/dist/agent/agent-ws.js +301 -0
  36. package/dist/agent/agent-ws.js.map +1 -0
  37. package/dist/agent/auto-mode-detect.d.ts +6 -0
  38. package/dist/agent/auto-mode-detect.js +44 -0
  39. package/dist/agent/auto-mode-detect.js.map +1 -0
  40. package/dist/agent/operator-claude.d.ts +22 -0
  41. package/dist/agent/operator-claude.js +176 -0
  42. package/dist/agent/operator-claude.js.map +1 -0
  43. package/dist/api/admin-endpoint.d.ts +12 -0
  44. package/dist/api/admin-endpoint.js +71 -0
  45. package/dist/api/admin-endpoint.js.map +1 -0
  46. package/dist/api/agent-binding-endpoint.d.ts +26 -0
  47. package/dist/api/agent-binding-endpoint.js +28 -0
  48. package/dist/api/agent-binding-endpoint.js.map +1 -0
  49. package/dist/api/bootstrap-endpoint.d.ts +25 -0
  50. package/dist/api/bootstrap-endpoint.js +104 -0
  51. package/dist/api/bootstrap-endpoint.js.map +1 -0
  52. package/dist/api/captures.d.ts +22 -0
  53. package/dist/api/captures.js +88 -0
  54. package/dist/api/captures.js.map +1 -0
  55. package/dist/api/events-endpoint.d.ts +9 -0
  56. package/dist/api/events-endpoint.js +46 -0
  57. package/dist/api/events-endpoint.js.map +1 -0
  58. package/dist/api/fleet-build.d.ts +1 -1
  59. package/dist/api/fleet-build.js +17 -8
  60. package/dist/api/fleet-build.js.map +1 -1
  61. package/dist/api/gather-status.d.ts +16 -1
  62. package/dist/api/gather-status.js +194 -3
  63. package/dist/api/gather-status.js.map +1 -1
  64. package/dist/api/handshake.d.ts +17 -0
  65. package/dist/api/handshake.js +28 -0
  66. package/dist/api/handshake.js.map +1 -0
  67. package/dist/api/harness-status-endpoint.d.ts +20 -0
  68. package/dist/api/harness-status-endpoint.js +13 -0
  69. package/dist/api/harness-status-endpoint.js.map +1 -0
  70. package/dist/api/history-build.d.ts +2 -2
  71. package/dist/api/history-build.js +3 -3
  72. package/dist/api/history-build.js.map +1 -1
  73. package/dist/api/launcher-endpoints.d.ts +43 -0
  74. package/dist/api/launcher-endpoints.js +50 -0
  75. package/dist/api/launcher-endpoints.js.map +1 -0
  76. package/dist/api/launcher-status.d.ts +93 -0
  77. package/dist/api/launcher-status.js +84 -0
  78. package/dist/api/launcher-status.js.map +1 -0
  79. package/dist/api/launcher-tasks.d.ts +76 -0
  80. package/dist/api/launcher-tasks.js +127 -0
  81. package/dist/api/launcher-tasks.js.map +1 -0
  82. package/dist/api/leaderboard-api.d.ts +20 -0
  83. package/dist/api/leaderboard-api.js +18 -0
  84. package/dist/api/leaderboard-api.js.map +1 -0
  85. package/dist/api/operator-artifacts-endpoint.d.ts +19 -0
  86. package/dist/api/operator-artifacts-endpoint.js +271 -0
  87. package/dist/api/operator-artifacts-endpoint.js.map +1 -0
  88. package/dist/api/peers.js +21 -6
  89. package/dist/api/peers.js.map +1 -1
  90. package/dist/api/portfolio-v0-build.d.ts +16 -10
  91. package/dist/api/portfolio-v0-build.js +36 -31
  92. package/dist/api/portfolio-v0-build.js.map +1 -1
  93. package/dist/api/portfolio-v0-doctor.js +1 -1
  94. package/dist/api/portfolio-v0-doctor.js.map +1 -1
  95. package/dist/api/prediction-v1-build.d.ts +65 -0
  96. package/dist/api/prediction-v1-build.js +73 -0
  97. package/dist/api/prediction-v1-build.js.map +1 -0
  98. package/dist/api/rewards-build.js +3 -8
  99. package/dist/api/rewards-build.js.map +1 -1
  100. package/dist/api/server.d.ts +106 -1
  101. package/dist/api/server.js +418 -17
  102. package/dist/api/server.js.map +1 -1
  103. package/dist/api/setup-endpoints.d.ts +62 -0
  104. package/dist/api/setup-endpoints.js +752 -0
  105. package/dist/api/setup-endpoints.js.map +1 -0
  106. package/dist/api/solvernets-catalog-build.d.ts +47 -0
  107. package/dist/api/solvernets-catalog-build.js +19 -0
  108. package/dist/api/solvernets-catalog-build.js.map +1 -0
  109. package/dist/api/solvernets-endpoint.d.ts +15 -0
  110. package/dist/api/solvernets-endpoint.js +5 -0
  111. package/dist/api/solvernets-endpoint.js.map +1 -0
  112. package/dist/api/solvernets-endpoints.d.ts +104 -0
  113. package/dist/api/solvernets-endpoints.js +1121 -0
  114. package/dist/api/solvernets-endpoints.js.map +1 -0
  115. package/dist/api/status-build.d.ts +26 -2
  116. package/dist/api/status-build.js +46 -9
  117. package/dist/api/status-build.js.map +1 -1
  118. package/dist/api/status-rollup-build.d.ts +46 -1
  119. package/dist/api/status-rollup-build.js +174 -8
  120. package/dist/api/status-rollup-build.js.map +1 -1
  121. package/dist/api/stop-hook.d.ts +36 -0
  122. package/dist/api/stop-hook.js +77 -0
  123. package/dist/api/stop-hook.js.map +1 -0
  124. package/dist/api/task-runs-build.d.ts +29 -0
  125. package/dist/api/task-runs-build.js +50 -0
  126. package/dist/api/task-runs-build.js.map +1 -0
  127. package/dist/api/ui-token.d.ts +5 -0
  128. package/dist/api/ui-token.js +36 -0
  129. package/dist/api/ui-token.js.map +1 -0
  130. package/dist/bin/jinn-stop-hook.d.ts +9 -0
  131. package/dist/bin/jinn-stop-hook.js +52 -0
  132. package/dist/bin/jinn-stop-hook.js.map +1 -0
  133. package/dist/build-info.d.ts +32 -0
  134. package/dist/build-info.js +69 -0
  135. package/dist/build-info.js.map +1 -0
  136. package/dist/build-info.json +6 -0
  137. package/dist/build-meta.json +1 -1
  138. package/dist/captures/dedup.d.ts +27 -0
  139. package/dist/captures/dedup.js +48 -0
  140. package/dist/captures/dedup.js.map +1 -0
  141. package/dist/captures/index.d.ts +4 -0
  142. package/dist/captures/index.js +5 -0
  143. package/dist/captures/index.js.map +1 -0
  144. package/dist/captures/live-publisher.d.ts +33 -0
  145. package/dist/captures/live-publisher.js +101 -0
  146. package/dist/captures/live-publisher.js.map +1 -0
  147. package/dist/captures/publish.d.ts +83 -0
  148. package/dist/captures/publish.js +212 -0
  149. package/dist/captures/publish.js.map +1 -0
  150. package/dist/captures/rate-limit.d.ts +39 -0
  151. package/dist/captures/rate-limit.js +79 -0
  152. package/dist/captures/rate-limit.js.map +1 -0
  153. package/dist/cli/command.d.ts +9 -0
  154. package/dist/cli/commands/auth.js +6 -3
  155. package/dist/cli/commands/auth.js.map +1 -1
  156. package/dist/cli/commands/balance.d.ts +7 -0
  157. package/dist/cli/commands/balance.js +38 -32
  158. package/dist/cli/commands/balance.js.map +1 -1
  159. package/dist/cli/commands/bootstrap.d.ts +13 -1
  160. package/dist/cli/commands/bootstrap.js +150 -133
  161. package/dist/cli/commands/bootstrap.js.map +1 -1
  162. package/dist/cli/commands/capture.d.ts +33 -0
  163. package/dist/cli/commands/capture.js +345 -0
  164. package/dist/cli/commands/capture.js.map +1 -0
  165. package/dist/cli/commands/checkpoint.d.ts +85 -0
  166. package/dist/cli/commands/checkpoint.js +75 -0
  167. package/dist/cli/commands/checkpoint.js.map +1 -0
  168. package/dist/cli/commands/claim-rewards.js +14 -2
  169. package/dist/cli/commands/claim-rewards.js.map +1 -1
  170. package/dist/cli/commands/conformance.d.ts +12 -0
  171. package/dist/cli/commands/conformance.js +140 -0
  172. package/dist/cli/commands/conformance.js.map +1 -0
  173. package/dist/cli/commands/create.d.ts +22 -0
  174. package/dist/cli/commands/create.js +226 -0
  175. package/dist/cli/commands/create.js.map +1 -0
  176. package/dist/cli/commands/doctor.d.ts +49 -1
  177. package/dist/cli/commands/doctor.js +162 -134
  178. package/dist/cli/commands/doctor.js.map +1 -1
  179. package/dist/cli/commands/fleet-scale.d.ts +19 -1
  180. package/dist/cli/commands/fleet-scale.js +378 -361
  181. package/dist/cli/commands/fleet-scale.js.map +1 -1
  182. package/dist/cli/commands/fleet.d.ts +7 -0
  183. package/dist/cli/commands/fleet.js +39 -33
  184. package/dist/cli/commands/fleet.js.map +1 -1
  185. package/dist/cli/commands/fund-requirements.d.ts +14 -1
  186. package/dist/cli/commands/fund-requirements.js +182 -174
  187. package/dist/cli/commands/fund-requirements.js.map +1 -1
  188. package/dist/cli/commands/harnesses.d.ts +38 -0
  189. package/dist/cli/commands/harnesses.js +376 -0
  190. package/dist/cli/commands/harnesses.js.map +1 -0
  191. package/dist/cli/commands/history.d.ts +10 -1
  192. package/dist/cli/commands/history.js +68 -59
  193. package/dist/cli/commands/history.js.map +1 -1
  194. package/dist/cli/commands/init.js +4 -1
  195. package/dist/cli/commands/init.js.map +1 -1
  196. package/dist/cli/commands/integrations.d.ts +13 -0
  197. package/dist/cli/commands/integrations.js +1010 -0
  198. package/dist/cli/commands/integrations.js.map +1 -0
  199. package/dist/cli/commands/logs.d.ts +6 -1
  200. package/dist/cli/commands/logs.js +77 -70
  201. package/dist/cli/commands/logs.js.map +1 -1
  202. package/dist/cli/commands/migrate-agent-id.d.ts +26 -0
  203. package/dist/cli/commands/migrate-agent-id.js +164 -0
  204. package/dist/cli/commands/migrate-agent-id.js.map +1 -0
  205. package/dist/cli/commands/prediction-scoreboard.d.ts +10 -0
  206. package/dist/cli/commands/prediction-scoreboard.js +136 -0
  207. package/dist/cli/commands/prediction-scoreboard.js.map +1 -0
  208. package/dist/cli/commands/quickstart.d.ts +51 -1
  209. package/dist/cli/commands/quickstart.js +514 -296
  210. package/dist/cli/commands/quickstart.js.map +1 -1
  211. package/dist/cli/commands/rewards.d.ts +7 -0
  212. package/dist/cli/commands/rewards.js +46 -40
  213. package/dist/cli/commands/rewards.js.map +1 -1
  214. package/dist/cli/commands/run.d.ts +14 -1
  215. package/dist/cli/commands/run.js +243 -91
  216. package/dist/cli/commands/run.js.map +1 -1
  217. package/dist/cli/commands/solver-nets.js +231 -0
  218. package/dist/cli/commands/solver-nets.js.map +1 -0
  219. package/dist/cli/commands/solver-plugins.d.ts +9 -0
  220. package/dist/cli/commands/solver-plugins.js +186 -0
  221. package/dist/cli/commands/solver-plugins.js.map +1 -0
  222. package/dist/cli/commands/status.d.ts +13 -0
  223. package/dist/cli/commands/status.js +105 -34
  224. package/dist/cli/commands/status.js.map +1 -1
  225. package/dist/cli/commands/stop.js +87 -14
  226. package/dist/cli/commands/stop.js.map +1 -1
  227. package/dist/cli/commands/tasks.js +405 -0
  228. package/dist/cli/commands/tasks.js.map +1 -0
  229. package/dist/cli/commands/ui.d.ts +3 -0
  230. package/dist/cli/commands/ui.js +45 -0
  231. package/dist/cli/commands/ui.js.map +1 -0
  232. package/dist/cli/commands/update.d.ts +12 -0
  233. package/dist/cli/commands/update.js +321 -91
  234. package/dist/cli/commands/update.js.map +1 -1
  235. package/dist/cli/commands/version.js +3 -2
  236. package/dist/cli/commands/version.js.map +1 -1
  237. package/dist/cli/commands/withdraw.d.ts +21 -1
  238. package/dist/cli/commands/withdraw.js +175 -159
  239. package/dist/cli/commands/withdraw.js.map +1 -1
  240. package/dist/cli/deployment-digest.js +0 -5
  241. package/dist/cli/deployment-digest.js.map +1 -1
  242. package/dist/cli/execution-context.d.ts +1 -1
  243. package/dist/cli/execution-context.js +4 -4
  244. package/dist/cli/execution-context.js.map +1 -1
  245. package/dist/cli/help.js +8 -1
  246. package/dist/cli/help.js.map +1 -1
  247. package/dist/cli/index.d.ts +7 -0
  248. package/dist/cli/index.js +28 -6
  249. package/dist/cli/index.js.map +1 -1
  250. package/dist/cli/introspection-context.js +0 -1
  251. package/dist/cli/introspection-context.js.map +1 -1
  252. package/dist/cli/open-browser.d.ts +1 -0
  253. package/dist/cli/open-browser.js +18 -0
  254. package/dist/cli/open-browser.js.map +1 -0
  255. package/dist/cli/password.d.ts +3 -3
  256. package/dist/cli/password.js +6 -6
  257. package/dist/cli/password.js.map +1 -1
  258. package/dist/cli/task-native-readiness.d.ts +27 -0
  259. package/dist/cli/task-native-readiness.js +170 -0
  260. package/dist/cli/task-native-readiness.js.map +1 -0
  261. package/dist/config.d.ts +1907 -60
  262. package/dist/config.js +608 -33
  263. package/dist/config.js.map +1 -1
  264. package/dist/conformance/checks/artifacts.d.ts +37 -0
  265. package/dist/conformance/checks/artifacts.js +110 -0
  266. package/dist/conformance/checks/artifacts.js.map +1 -0
  267. package/dist/conformance/checks/envelope-schema.d.ts +17 -0
  268. package/dist/conformance/checks/envelope-schema.js +36 -0
  269. package/dist/conformance/checks/envelope-schema.js.map +1 -0
  270. package/dist/conformance/checks/hash-signature.d.ts +26 -0
  271. package/dist/conformance/checks/hash-signature.js +70 -0
  272. package/dist/conformance/checks/hash-signature.js.map +1 -0
  273. package/dist/conformance/checks/payload.d.ts +19 -0
  274. package/dist/conformance/checks/payload.js +52 -0
  275. package/dist/conformance/checks/payload.js.map +1 -0
  276. package/dist/conformance/checks/secret-scrub.d.ts +33 -0
  277. package/dist/conformance/checks/secret-scrub.js +118 -0
  278. package/dist/conformance/checks/secret-scrub.js.map +1 -0
  279. package/dist/conformance/checks/source-runtime.d.ts +43 -0
  280. package/dist/conformance/checks/source-runtime.js +68 -0
  281. package/dist/conformance/checks/source-runtime.js.map +1 -0
  282. package/dist/conformance/checks/source-static.d.ts +61 -0
  283. package/dist/conformance/checks/source-static.js +311 -0
  284. package/dist/conformance/checks/source-static.js.map +1 -0
  285. package/dist/conformance/checks/trajectory-chain.d.ts +18 -0
  286. package/dist/conformance/checks/trajectory-chain.js +51 -0
  287. package/dist/conformance/checks/trajectory-chain.js.map +1 -0
  288. package/dist/conformance/checks/trajectory-profile.d.ts +17 -0
  289. package/dist/conformance/checks/trajectory-profile.js +51 -0
  290. package/dist/conformance/checks/trajectory-profile.js.map +1 -0
  291. package/dist/conformance/checks/trajectory-schema.d.ts +20 -0
  292. package/dist/conformance/checks/trajectory-schema.js +40 -0
  293. package/dist/conformance/checks/trajectory-schema.js.map +1 -0
  294. package/dist/conformance/checks/verdict.d.ts +44 -0
  295. package/dist/conformance/checks/verdict.js +122 -0
  296. package/dist/conformance/checks/verdict.js.map +1 -0
  297. package/dist/conformance/harness.d.ts +32 -0
  298. package/dist/conformance/harness.js +227 -0
  299. package/dist/conformance/harness.js.map +1 -0
  300. package/dist/conformance/types.d.ts +88 -0
  301. package/dist/conformance/types.js +31 -0
  302. package/dist/conformance/types.js.map +1 -0
  303. package/dist/corpus/acquire.d.ts +42 -0
  304. package/dist/corpus/acquire.js +213 -0
  305. package/dist/corpus/acquire.js.map +1 -0
  306. package/dist/corpus/cache.d.ts +14 -0
  307. package/dist/corpus/cache.js +18 -0
  308. package/dist/corpus/cache.js.map +1 -0
  309. package/dist/corpus/envelope-projection.d.ts +12 -0
  310. package/dist/corpus/envelope-projection.js +110 -0
  311. package/dist/corpus/envelope-projection.js.map +1 -0
  312. package/dist/corpus/fetch.d.ts +9 -0
  313. package/dist/corpus/fetch.js +24 -0
  314. package/dist/corpus/fetch.js.map +1 -0
  315. package/dist/corpus/index.d.ts +19 -0
  316. package/dist/corpus/index.js +118 -0
  317. package/dist/corpus/index.js.map +1 -0
  318. package/dist/corpus/onchain-query.d.ts +13 -0
  319. package/dist/corpus/onchain-query.js +165 -0
  320. package/dist/corpus/onchain-query.js.map +1 -0
  321. package/dist/corpus/prediction-brier-scoreboard-report.d.ts +17 -0
  322. package/dist/corpus/prediction-brier-scoreboard-report.js +148 -0
  323. package/dist/corpus/prediction-brier-scoreboard-report.js.map +1 -0
  324. package/dist/corpus/prediction-brier-scoreboard.d.ts +56 -0
  325. package/dist/corpus/prediction-brier-scoreboard.js +269 -0
  326. package/dist/corpus/prediction-brier-scoreboard.js.map +1 -0
  327. package/dist/corpus/prediction-scoreable-verdicts.d.ts +4 -0
  328. package/dist/corpus/prediction-scoreable-verdicts.js +23 -0
  329. package/dist/corpus/prediction-scoreable-verdicts.js.map +1 -0
  330. package/dist/corpus/query.d.ts +17 -0
  331. package/dist/corpus/query.js +113 -0
  332. package/dist/corpus/query.js.map +1 -0
  333. package/dist/corpus/route-resolver.d.ts +16 -0
  334. package/dist/corpus/route-resolver.js +20 -0
  335. package/dist/corpus/route-resolver.js.map +1 -0
  336. package/dist/corpus/types.d.ts +153 -0
  337. package/dist/corpus/types.js +50 -0
  338. package/dist/corpus/types.js.map +1 -0
  339. package/dist/daemon/balance-topup-loop.js +2 -1
  340. package/dist/daemon/balance-topup-loop.js.map +1 -1
  341. package/dist/daemon/creator.d.ts +7 -7
  342. package/dist/daemon/creator.js +11 -14
  343. package/dist/daemon/creator.js.map +1 -1
  344. package/dist/daemon/daemon.d.ts +83 -31
  345. package/dist/daemon/daemon.js +206 -67
  346. package/dist/daemon/daemon.js.map +1 -1
  347. package/dist/daemon/delivery-watcher.js +50 -4
  348. package/dist/daemon/delivery-watcher.js.map +1 -1
  349. package/dist/daemon/freeze-fence.d.ts +42 -0
  350. package/dist/daemon/freeze-fence.js +71 -0
  351. package/dist/daemon/freeze-fence.js.map +1 -0
  352. package/dist/daemon/jinn-claim-loop-canonical.d.ts +207 -0
  353. package/dist/daemon/jinn-claim-loop-canonical.js +296 -0
  354. package/dist/daemon/jinn-claim-loop-canonical.js.map +1 -0
  355. package/dist/daemon/jinn-claim-loop-mock.d.ts +61 -0
  356. package/dist/daemon/jinn-claim-loop-mock.js +122 -0
  357. package/dist/daemon/jinn-claim-loop-mock.js.map +1 -0
  358. package/dist/daemon/jinn-claim-loop.d.ts +123 -0
  359. package/dist/daemon/jinn-claim-loop.js +256 -0
  360. package/dist/daemon/jinn-claim-loop.js.map +1 -0
  361. package/dist/daemon/reward-claim-loop.d.ts +2 -0
  362. package/dist/daemon/reward-claim-loop.js +32 -27
  363. package/dist/daemon/reward-claim-loop.js.map +1 -1
  364. package/dist/dashboard/assets/index-D_NMfDfV.css +32 -0
  365. package/dist/dashboard/assets/index-gfrALgiG.js +76 -0
  366. package/dist/dashboard/index.html +18 -74
  367. package/dist/earning/agent-wallet-binding.d.ts +133 -0
  368. package/dist/earning/agent-wallet-binding.js +202 -0
  369. package/dist/earning/agent-wallet-binding.js.map +1 -0
  370. package/dist/earning/bootstrap.d.ts +88 -1
  371. package/dist/earning/bootstrap.js +409 -56
  372. package/dist/earning/bootstrap.js.map +1 -1
  373. package/dist/earning/contracts.d.ts +328 -6
  374. package/dist/earning/contracts.js +295 -14
  375. package/dist/earning/contracts.js.map +1 -1
  376. package/dist/earning/evidence-simhash.d.ts +1 -1
  377. package/dist/earning/faucet.d.ts +31 -0
  378. package/dist/earning/faucet.js +37 -0
  379. package/dist/earning/faucet.js.map +1 -1
  380. package/dist/earning/funding-plan.d.ts +89 -0
  381. package/dist/earning/funding-plan.js +202 -0
  382. package/dist/earning/funding-plan.js.map +1 -0
  383. package/dist/earning/migrate-agent-id.d.ts +129 -0
  384. package/dist/earning/migrate-agent-id.js +256 -0
  385. package/dist/earning/migrate-agent-id.js.map +1 -0
  386. package/dist/earning/orphan-sweep.d.ts +14 -0
  387. package/dist/earning/orphan-sweep.js +63 -2
  388. package/dist/earning/orphan-sweep.js.map +1 -1
  389. package/dist/earning/reconcile.d.ts +2 -0
  390. package/dist/earning/reconcile.js +30 -0
  391. package/dist/earning/reconcile.js.map +1 -1
  392. package/dist/earning/safe-adapter.js +45 -3
  393. package/dist/earning/safe-adapter.js.map +1 -1
  394. package/dist/earning/stolas-claim.d.ts +86 -6
  395. package/dist/earning/stolas-claim.js +123 -9
  396. package/dist/earning/stolas-claim.js.map +1 -1
  397. package/dist/earning/store.d.ts +47 -0
  398. package/dist/earning/store.js +113 -1
  399. package/dist/earning/store.js.map +1 -1
  400. package/dist/earning/testnet-setup-migration.d.ts +32 -0
  401. package/dist/earning/testnet-setup-migration.js +214 -0
  402. package/dist/earning/testnet-setup-migration.js.map +1 -0
  403. package/dist/earning/types.d.ts +57 -9
  404. package/dist/earning/types.js +51 -2
  405. package/dist/earning/types.js.map +1 -1
  406. package/dist/earning/viem-clients.d.ts +20 -0
  407. package/dist/earning/viem-clients.js +32 -1
  408. package/dist/earning/viem-clients.js.map +1 -1
  409. package/dist/erc8004/abis.d.ts +423 -0
  410. package/dist/erc8004/abis.js +265 -0
  411. package/dist/erc8004/abis.js.map +1 -0
  412. package/dist/erc8004/addresses.d.ts +40 -0
  413. package/dist/erc8004/addresses.js +64 -0
  414. package/dist/erc8004/addresses.js.map +1 -0
  415. package/dist/erc8004/identity.d.ts +273 -0
  416. package/dist/erc8004/identity.js +405 -0
  417. package/dist/erc8004/identity.js.map +1 -0
  418. package/dist/erc8004/index.d.ts +13 -0
  419. package/dist/erc8004/index.js +20 -0
  420. package/dist/erc8004/index.js.map +1 -0
  421. package/dist/erc8004/reputation.d.ts +349 -0
  422. package/dist/erc8004/reputation.js +464 -0
  423. package/dist/erc8004/reputation.js.map +1 -0
  424. package/dist/erc8004/subgraph.d.ts +46 -0
  425. package/dist/erc8004/subgraph.js +37 -0
  426. package/dist/erc8004/subgraph.js.map +1 -0
  427. package/dist/erc8004/validation.d.ts +145 -0
  428. package/dist/erc8004/validation.js +219 -0
  429. package/dist/erc8004/validation.js.map +1 -0
  430. package/dist/errors/persisted-bootstrap-error.d.ts +4 -0
  431. package/dist/errors/persisted-bootstrap-error.js +50 -0
  432. package/dist/errors/persisted-bootstrap-error.js.map +1 -0
  433. package/dist/events/emitter.d.ts +12 -0
  434. package/dist/events/emitter.js +23 -0
  435. package/dist/events/emitter.js.map +1 -0
  436. package/dist/events/ring-buffer.d.ts +25 -0
  437. package/dist/events/ring-buffer.js +46 -0
  438. package/dist/events/ring-buffer.js.map +1 -0
  439. package/dist/events/types.d.ts +42 -0
  440. package/dist/events/types.js +28 -0
  441. package/dist/events/types.js.map +1 -0
  442. package/dist/harnesses/capability/index.d.ts +82 -0
  443. package/dist/harnesses/capability/index.js +12 -0
  444. package/dist/harnesses/capability/index.js.map +1 -0
  445. package/dist/harnesses/capability/scoped-rpc.d.ts +12 -0
  446. package/dist/harnesses/capability/scoped-rpc.js +34 -0
  447. package/dist/harnesses/capability/scoped-rpc.js.map +1 -0
  448. package/dist/harnesses/capability/scoped-secrets.d.ts +8 -0
  449. package/dist/harnesses/capability/scoped-secrets.js +10 -0
  450. package/dist/harnesses/capability/scoped-secrets.js.map +1 -0
  451. package/dist/harnesses/capability/scoped-signer.d.ts +46 -0
  452. package/dist/harnesses/capability/scoped-signer.js +73 -0
  453. package/dist/harnesses/capability/scoped-signer.js.map +1 -0
  454. package/dist/harnesses/engine/artifact-scrub.d.ts +12 -0
  455. package/dist/harnesses/engine/artifact-scrub.js +104 -0
  456. package/dist/harnesses/engine/artifact-scrub.js.map +1 -0
  457. package/dist/harnesses/engine/canonical-json.d.ts +1 -0
  458. package/dist/harnesses/engine/canonical-json.js +66 -0
  459. package/dist/harnesses/engine/canonical-json.js.map +1 -0
  460. package/dist/harnesses/engine/delivery.d.ts +58 -0
  461. package/dist/harnesses/engine/delivery.js +67 -0
  462. package/dist/harnesses/engine/delivery.js.map +1 -0
  463. package/dist/harnesses/engine/engine.d.ts +534 -0
  464. package/dist/harnesses/engine/engine.js +1626 -0
  465. package/dist/harnesses/engine/engine.js.map +1 -0
  466. package/dist/harnesses/engine/envelope-assembly.d.ts +73 -0
  467. package/dist/harnesses/engine/envelope-assembly.js +60 -0
  468. package/dist/harnesses/engine/envelope-assembly.js.map +1 -0
  469. package/dist/harnesses/engine/packaging.d.ts +99 -0
  470. package/dist/harnesses/engine/packaging.js +424 -0
  471. package/dist/harnesses/engine/packaging.js.map +1 -0
  472. package/dist/harnesses/engine/persistence.d.ts +198 -0
  473. package/dist/harnesses/engine/persistence.js +443 -0
  474. package/dist/harnesses/engine/persistence.js.map +1 -0
  475. package/dist/harnesses/engine/recovery.d.ts +22 -0
  476. package/dist/harnesses/engine/recovery.js +24 -0
  477. package/dist/harnesses/engine/recovery.js.map +1 -0
  478. package/dist/harnesses/engine/registry.d.ts +55 -0
  479. package/dist/harnesses/engine/registry.js +66 -0
  480. package/dist/harnesses/engine/registry.js.map +1 -0
  481. package/dist/harnesses/engine/signing.d.ts +30 -0
  482. package/dist/harnesses/engine/signing.js +39 -0
  483. package/dist/harnesses/engine/signing.js.map +1 -0
  484. package/dist/harnesses/engine/state.d.ts +42 -0
  485. package/dist/harnesses/engine/state.js +87 -0
  486. package/dist/harnesses/engine/state.js.map +1 -0
  487. package/dist/harnesses/engine/validate-manifest.d.ts +23 -0
  488. package/dist/harnesses/engine/validate-manifest.js +63 -0
  489. package/dist/harnesses/engine/validate-manifest.js.map +1 -0
  490. package/dist/harnesses/engine/verification-stub.d.ts +18 -0
  491. package/dist/harnesses/engine/verification-stub.js +18 -0
  492. package/dist/harnesses/engine/verification-stub.js.map +1 -0
  493. package/dist/harnesses/external-impls/index.d.ts +3 -0
  494. package/dist/harnesses/external-impls/index.js +2 -0
  495. package/dist/harnesses/external-impls/index.js.map +1 -0
  496. package/dist/harnesses/external-impls/loader.d.ts +50 -0
  497. package/dist/harnesses/external-impls/loader.js +139 -0
  498. package/dist/harnesses/external-impls/loader.js.map +1 -0
  499. package/dist/harnesses/external-impls/package-hash.d.ts +26 -0
  500. package/dist/harnesses/external-impls/package-hash.js +102 -0
  501. package/dist/harnesses/external-impls/package-hash.js.map +1 -0
  502. package/dist/harnesses/external-impls/types.d.ts +42 -0
  503. package/dist/harnesses/external-impls/types.js +10 -0
  504. package/dist/harnesses/external-impls/types.js.map +1 -0
  505. package/dist/harnesses/freeze.d.ts +34 -0
  506. package/dist/harnesses/freeze.js +60 -0
  507. package/dist/harnesses/freeze.js.map +1 -0
  508. package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.d.ts +61 -0
  509. package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.js +243 -0
  510. package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.js.map +1 -0
  511. package/dist/harnesses/impls/claude-code-learner/adapters/codex-code.d.ts +35 -0
  512. package/dist/harnesses/impls/claude-code-learner/adapters/codex-code.js +280 -0
  513. package/dist/harnesses/impls/claude-code-learner/adapters/codex-code.js.map +1 -0
  514. package/dist/harnesses/impls/claude-code-learner/adapters/codex-workspace.d.ts +21 -0
  515. package/dist/harnesses/impls/claude-code-learner/adapters/codex-workspace.js +193 -0
  516. package/dist/harnesses/impls/claude-code-learner/adapters/codex-workspace.js.map +1 -0
  517. package/dist/harnesses/impls/claude-code-learner/harness.d.ts +22 -0
  518. package/dist/harnesses/impls/claude-code-learner/harness.js +62 -0
  519. package/dist/harnesses/impls/claude-code-learner/harness.js.map +1 -0
  520. package/dist/harnesses/impls/claude-code-learner/harvest.d.ts +20 -0
  521. package/dist/harnesses/impls/claude-code-learner/harvest.js +558 -0
  522. package/dist/harnesses/impls/claude-code-learner/harvest.js.map +1 -0
  523. package/dist/harnesses/impls/claude-code-learner/index.d.ts +18 -0
  524. package/dist/harnesses/impls/claude-code-learner/index.js +15 -0
  525. package/dist/harnesses/impls/claude-code-learner/index.js.map +1 -0
  526. package/dist/harnesses/impls/claude-code-learner/plugin-path.d.ts +14 -0
  527. package/dist/harnesses/impls/claude-code-learner/plugin-path.js +30 -0
  528. package/dist/harnesses/impls/claude-code-learner/plugin-path.js.map +1 -0
  529. package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.d.ts +50 -0
  530. package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.js +192 -0
  531. package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.js.map +1 -0
  532. package/dist/harnesses/impls/claude-code-learner/test-utils/noop-adapter.d.ts +22 -0
  533. package/dist/harnesses/impls/claude-code-learner/test-utils/noop-adapter.js +35 -0
  534. package/dist/harnesses/impls/claude-code-learner/test-utils/noop-adapter.js.map +1 -0
  535. package/dist/harnesses/impls/claude-code-learner/types.d.ts +114 -0
  536. package/dist/harnesses/impls/claude-code-learner/types.js.map +1 -0
  537. package/dist/harnesses/impls/claude-mcp-hyperliquid/api-wallet.d.ts +64 -0
  538. package/dist/harnesses/impls/claude-mcp-hyperliquid/api-wallet.js.map +1 -0
  539. package/dist/harnesses/impls/claude-mcp-hyperliquid/index.d.ts +106 -0
  540. package/dist/harnesses/impls/claude-mcp-hyperliquid/index.js +723 -0
  541. package/dist/harnesses/impls/claude-mcp-hyperliquid/index.js.map +1 -0
  542. package/dist/harnesses/impls/claude-mcp-hyperliquid/mcp-tools.js.map +1 -0
  543. package/dist/harnesses/impls/claude-mcp-hyperliquid/safety-rails.js.map +1 -0
  544. package/dist/harnesses/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +104 -0
  545. package/dist/harnesses/impls/claude-mcp-hyperliquid/session-orchestrator.js +264 -0
  546. package/dist/harnesses/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +1 -0
  547. package/dist/harnesses/impls/claude-mcp-prediction/index.d.ts +44 -0
  548. package/dist/harnesses/impls/claude-mcp-prediction/index.js +250 -0
  549. package/dist/harnesses/impls/claude-mcp-prediction/index.js.map +1 -0
  550. package/dist/harnesses/impls/claude-mcp-prediction/mcp-tools.js +135 -0
  551. package/dist/harnesses/impls/claude-mcp-prediction/mcp-tools.js.map +1 -0
  552. package/dist/harnesses/impls/claude-mcp-prediction/prompt.d.ts +8 -0
  553. package/dist/harnesses/impls/claude-mcp-prediction/prompt.js +54 -0
  554. package/dist/harnesses/impls/claude-mcp-prediction/prompt.js.map +1 -0
  555. package/dist/harnesses/impls/claude-mcp-prediction/session-orchestrator.d.ts +43 -0
  556. package/dist/harnesses/impls/claude-mcp-prediction/session-orchestrator.js +21 -0
  557. package/dist/harnesses/impls/claude-mcp-prediction/session-orchestrator.js.map +1 -0
  558. package/dist/harnesses/impls/claude-mcp-prediction/types.d.ts +84 -0
  559. package/dist/harnesses/impls/claude-mcp-prediction/types.js +6 -0
  560. package/dist/harnesses/impls/claude-mcp-prediction/types.js.map +1 -0
  561. package/dist/harnesses/impls/claude-mcp-prediction-apy/index.d.ts +36 -0
  562. package/dist/harnesses/impls/claude-mcp-prediction-apy/index.js +241 -0
  563. package/dist/harnesses/impls/claude-mcp-prediction-apy/index.js.map +1 -0
  564. package/dist/harnesses/impls/claude-mcp-prediction-apy/mcp-tools.js +136 -0
  565. package/dist/harnesses/impls/claude-mcp-prediction-apy/mcp-tools.js.map +1 -0
  566. package/dist/harnesses/impls/claude-mcp-prediction-apy/prompt.d.ts +7 -0
  567. package/dist/harnesses/impls/claude-mcp-prediction-apy/prompt.js +46 -0
  568. package/dist/harnesses/impls/claude-mcp-prediction-apy/prompt.js.map +1 -0
  569. package/dist/harnesses/impls/claude-mcp-prediction-apy/session-orchestrator.d.ts +37 -0
  570. package/dist/harnesses/impls/claude-mcp-prediction-apy/session-orchestrator.js +19 -0
  571. package/dist/harnesses/impls/claude-mcp-prediction-apy/session-orchestrator.js.map +1 -0
  572. package/dist/harnesses/impls/claude-mcp-prediction-apy/types.d.ts +64 -0
  573. package/dist/harnesses/impls/claude-mcp-prediction-apy/types.js +6 -0
  574. package/dist/harnesses/impls/claude-mcp-prediction-apy/types.js.map +1 -0
  575. package/dist/harnesses/impls/claude-mcp-shared/single-session-orchestrator.d.ts +84 -0
  576. package/dist/harnesses/impls/claude-mcp-shared/single-session-orchestrator.js +206 -0
  577. package/dist/harnesses/impls/claude-mcp-shared/single-session-orchestrator.js.map +1 -0
  578. package/dist/harnesses/impls/evaluation-context.d.ts +23 -0
  579. package/dist/harnesses/impls/evaluation-context.js +25 -0
  580. package/dist/harnesses/impls/evaluation-context.js.map +1 -0
  581. package/dist/harnesses/impls/index.d.ts +84 -0
  582. package/dist/harnesses/impls/index.js +136 -0
  583. package/dist/harnesses/impls/index.js.map +1 -0
  584. package/dist/harnesses/impls/legacy-claude/index.d.ts +66 -0
  585. package/dist/harnesses/impls/legacy-claude/index.js +168 -0
  586. package/dist/harnesses/impls/legacy-claude/index.js.map +1 -0
  587. package/dist/harnesses/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +68 -0
  588. package/dist/harnesses/impls/portfolio-v0-evaluator/canonical-metrics.js +117 -0
  589. package/dist/harnesses/impls/portfolio-v0-evaluator/canonical-metrics.js.map +1 -0
  590. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/availability.js.map +1 -0
  591. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/consistency.d.ts +78 -0
  592. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/consistency.js +274 -0
  593. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/consistency.js.map +1 -0
  594. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +23 -0
  595. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/eligibility.js +49 -0
  596. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/eligibility.js.map +1 -0
  597. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/integrity.d.ts +25 -0
  598. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/integrity.js +44 -0
  599. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/integrity.js.map +1 -0
  600. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/spec.d.ts +17 -0
  601. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/spec.js +43 -0
  602. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/spec.js.map +1 -0
  603. package/dist/harnesses/impls/portfolio-v0-evaluator/index.d.ts +44 -0
  604. package/dist/harnesses/impls/portfolio-v0-evaluator/index.js +569 -0
  605. package/dist/harnesses/impls/portfolio-v0-evaluator/index.js.map +1 -0
  606. package/dist/harnesses/impls/portfolio-v0-evaluator/score.js.map +1 -0
  607. package/dist/harnesses/impls/portfolio-v0-evaluator/types.d.ts +34 -0
  608. package/dist/harnesses/impls/portfolio-v0-evaluator/types.js.map +1 -0
  609. package/dist/harnesses/impls/prediction-apy-v0-baseline/index.d.ts +42 -0
  610. package/dist/harnesses/impls/prediction-apy-v0-baseline/index.js +114 -0
  611. package/dist/harnesses/impls/prediction-apy-v0-baseline/index.js.map +1 -0
  612. package/dist/harnesses/impls/prediction-apy-v0-baseline/strategy.js.map +1 -0
  613. package/dist/harnesses/impls/prediction-apy-v0-baseline/types.js.map +1 -0
  614. package/dist/harnesses/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +6 -0
  615. package/dist/harnesses/impls/prediction-apy-v0-evaluator/canonical-metrics.js +11 -0
  616. package/dist/harnesses/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +1 -0
  617. package/dist/harnesses/impls/prediction-apy-v0-evaluator/index.d.ts +42 -0
  618. package/dist/harnesses/impls/prediction-apy-v0-evaluator/index.js +346 -0
  619. package/dist/harnesses/impls/prediction-apy-v0-evaluator/index.js.map +1 -0
  620. package/dist/harnesses/impls/prediction-apy-v0-evaluator/parse-submission.d.ts +16 -0
  621. package/dist/harnesses/impls/prediction-apy-v0-evaluator/parse-submission.js +22 -0
  622. package/dist/harnesses/impls/prediction-apy-v0-evaluator/parse-submission.js.map +1 -0
  623. package/dist/harnesses/impls/prediction-apy-v0-evaluator/score.js.map +1 -0
  624. package/dist/harnesses/impls/prediction-apy-v0-evaluator/types.js.map +1 -0
  625. package/dist/harnesses/impls/prediction-v0-baseline/index.d.ts +33 -0
  626. package/dist/harnesses/impls/prediction-v0-baseline/index.js +109 -0
  627. package/dist/harnesses/impls/prediction-v0-baseline/index.js.map +1 -0
  628. package/dist/harnesses/impls/prediction-v0-baseline/strategy.d.ts +8 -0
  629. package/dist/harnesses/impls/prediction-v0-baseline/strategy.js +41 -0
  630. package/dist/harnesses/impls/prediction-v0-baseline/strategy.js.map +1 -0
  631. package/dist/harnesses/impls/prediction-v0-baseline/types.d.ts +7 -0
  632. package/dist/harnesses/impls/prediction-v0-baseline/types.js.map +1 -0
  633. package/dist/harnesses/impls/prediction-v0-evaluator/canonical-metrics.d.ts +20 -0
  634. package/dist/harnesses/impls/prediction-v0-evaluator/canonical-metrics.js.map +1 -0
  635. package/dist/harnesses/impls/prediction-v0-evaluator/checks/availability.d.ts +9 -0
  636. package/dist/harnesses/impls/prediction-v0-evaluator/checks/availability.js.map +1 -0
  637. package/dist/harnesses/impls/prediction-v0-evaluator/checks/eligibility.d.ts +3 -0
  638. package/dist/harnesses/impls/prediction-v0-evaluator/checks/eligibility.js.map +1 -0
  639. package/dist/harnesses/impls/prediction-v0-evaluator/checks/integrity.d.ts +15 -0
  640. package/dist/harnesses/impls/prediction-v0-evaluator/checks/integrity.js +111 -0
  641. package/dist/harnesses/impls/prediction-v0-evaluator/checks/integrity.js.map +1 -0
  642. package/dist/harnesses/impls/prediction-v0-evaluator/checks/spec.d.ts +5 -0
  643. package/dist/harnesses/impls/prediction-v0-evaluator/checks/spec.js.map +1 -0
  644. package/dist/harnesses/impls/prediction-v0-evaluator/index.d.ts +36 -0
  645. package/dist/harnesses/impls/prediction-v0-evaluator/index.js +342 -0
  646. package/dist/harnesses/impls/prediction-v0-evaluator/index.js.map +1 -0
  647. package/dist/harnesses/impls/prediction-v0-evaluator/score.js.map +1 -0
  648. package/dist/harnesses/impls/prediction-v0-evaluator/types.js +2 -0
  649. package/dist/harnesses/impls/prediction-v0-evaluator/types.js.map +1 -0
  650. package/dist/harnesses/impls/prediction-v1-baseline/index.d.ts +31 -0
  651. package/dist/harnesses/impls/prediction-v1-baseline/index.js +79 -0
  652. package/dist/harnesses/impls/prediction-v1-baseline/index.js.map +1 -0
  653. package/dist/harnesses/impls/prediction-v1-evaluator/index.d.ts +32 -0
  654. package/dist/harnesses/impls/prediction-v1-evaluator/index.js +219 -0
  655. package/dist/harnesses/impls/prediction-v1-evaluator/index.js.map +1 -0
  656. package/dist/harnesses/impls/session-derived-evaluator/index.d.ts +4 -0
  657. package/dist/harnesses/impls/session-derived-evaluator/index.js +5 -0
  658. package/dist/harnesses/impls/session-derived-evaluator/index.js.map +1 -0
  659. package/dist/harnesses/impls/session-derived-evaluator/llm-judge.d.ts +16 -0
  660. package/dist/harnesses/impls/session-derived-evaluator/llm-judge.js +16 -0
  661. package/dist/harnesses/impls/session-derived-evaluator/llm-judge.js.map +1 -0
  662. package/dist/harnesses/impls/session-derived-evaluator/signals.d.ts +13 -0
  663. package/dist/harnesses/impls/session-derived-evaluator/signals.js +15 -0
  664. package/dist/harnesses/impls/session-derived-evaluator/signals.js.map +1 -0
  665. package/dist/harnesses/impls/session-derived-evaluator/structural-similarity.d.ts +7 -0
  666. package/dist/harnesses/impls/session-derived-evaluator/structural-similarity.js +28 -0
  667. package/dist/harnesses/impls/session-derived-evaluator/structural-similarity.js.map +1 -0
  668. package/dist/harnesses/impls/session-derived-evaluator/test-suite-rerun.d.ts +15 -0
  669. package/dist/harnesses/impls/session-derived-evaluator/test-suite-rerun.js +17 -0
  670. package/dist/harnesses/impls/session-derived-evaluator/test-suite-rerun.js.map +1 -0
  671. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.d.ts +20 -0
  672. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js +107 -0
  673. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js.map +1 -0
  674. package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.d.ts +74 -0
  675. package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js +288 -0
  676. package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js.map +1 -0
  677. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.d.ts +33 -0
  678. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js +96 -0
  679. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js.map +1 -0
  680. package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.d.ts +61 -0
  681. package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js +42 -0
  682. package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js.map +1 -0
  683. package/dist/harnesses/manifest/index.d.ts +3 -0
  684. package/dist/harnesses/manifest/index.js +3 -0
  685. package/dist/harnesses/manifest/index.js.map +1 -0
  686. package/dist/harnesses/manifest/load.d.ts +7 -0
  687. package/dist/harnesses/manifest/load.js +49 -0
  688. package/dist/harnesses/manifest/load.js.map +1 -0
  689. package/dist/harnesses/manifest/types.d.ts +75 -0
  690. package/dist/harnesses/manifest/types.js +8 -0
  691. package/dist/harnesses/manifest/types.js.map +1 -0
  692. package/dist/harnesses/manifest/verify.d.ts +15 -0
  693. package/dist/harnesses/manifest/verify.js +53 -0
  694. package/dist/harnesses/manifest/verify.js.map +1 -0
  695. package/dist/harnesses/mode-state.d.ts +7 -0
  696. package/dist/harnesses/mode-state.js +43 -0
  697. package/dist/harnesses/mode-state.js.map +1 -0
  698. package/dist/harnesses/names.d.ts +6 -0
  699. package/dist/harnesses/names.js +24 -0
  700. package/dist/harnesses/names.js.map +1 -0
  701. package/dist/harnesses/types.d.ts +276 -0
  702. package/dist/harnesses/types.js +28 -0
  703. package/dist/harnesses/types.js.map +1 -0
  704. package/dist/index.d.ts +1 -1
  705. package/dist/main.d.ts +17 -2
  706. package/dist/main.js +1615 -147
  707. package/dist/main.js.map +1 -1
  708. package/dist/mcp/acquire-artifact.d.ts +42 -0
  709. package/dist/mcp/acquire-artifact.js +169 -0
  710. package/dist/mcp/acquire-artifact.js.map +1 -0
  711. package/dist/mcp/operator-server.d.ts +21 -4
  712. package/dist/mcp/operator-server.js +505 -30
  713. package/dist/mcp/operator-server.js.map +1 -1
  714. package/dist/mcp/search-records.d.ts +95 -0
  715. package/dist/mcp/search-records.js +407 -0
  716. package/dist/mcp/search-records.js.map +1 -0
  717. package/dist/mcp/server.d.ts +4 -4
  718. package/dist/mcp/server.js +258 -61
  719. package/dist/mcp/server.js.map +1 -1
  720. package/dist/observability/emit-event.d.ts +2 -2
  721. package/dist/observability/emit-event.js +2 -2
  722. package/dist/observability/emit-event.js.map +1 -1
  723. package/dist/operator-errors.d.ts +14 -0
  724. package/dist/operator-errors.js +39 -10
  725. package/dist/operator-errors.js.map +1 -1
  726. package/dist/plugins/digest.d.ts +1 -0
  727. package/dist/plugins/digest.js +28 -0
  728. package/dist/plugins/digest.js.map +1 -0
  729. package/dist/plugins/index.d.ts +6 -0
  730. package/dist/plugins/index.js +6 -0
  731. package/dist/plugins/index.js.map +1 -0
  732. package/dist/plugins/manifest.d.ts +7 -0
  733. package/dist/plugins/manifest.js +22 -0
  734. package/dist/plugins/manifest.js.map +1 -0
  735. package/dist/plugins/registry.d.ts +9 -0
  736. package/dist/plugins/registry.js +24 -0
  737. package/dist/plugins/registry.js.map +1 -0
  738. package/dist/plugins/resolvers.d.ts +2 -0
  739. package/dist/plugins/resolvers.js +126 -0
  740. package/dist/plugins/resolvers.js.map +1 -0
  741. package/dist/plugins/types.d.ts +35 -0
  742. package/dist/plugins/types.js +2 -0
  743. package/dist/plugins/types.js.map +1 -0
  744. package/dist/plugins/validator.d.ts +3 -0
  745. package/dist/plugins/validator.js +50 -0
  746. package/dist/plugins/validator.js.map +1 -0
  747. package/dist/preflight/claude-auth.d.ts +14 -12
  748. package/dist/preflight/claude-auth.js +23 -37
  749. package/dist/preflight/claude-auth.js.map +1 -1
  750. package/dist/preflight/claude-required.d.ts +8 -0
  751. package/dist/preflight/claude-required.js +17 -0
  752. package/dist/preflight/claude-required.js.map +1 -0
  753. package/dist/runner/claude.d.ts +3 -3
  754. package/dist/runner/claude.js +66 -26
  755. package/dist/runner/claude.js.map +1 -1
  756. package/dist/runner/runner.d.ts +33 -2
  757. package/dist/runner/simple.d.ts +2 -2
  758. package/dist/runner/simple.js +2 -2
  759. package/dist/runner/simple.js.map +1 -1
  760. package/dist/scripts/donation-consumption-acceptance.d.ts +81 -0
  761. package/dist/scripts/donation-consumption-acceptance.js +1385 -0
  762. package/dist/scripts/donation-consumption-acceptance.js.map +1 -0
  763. package/dist/scripts/fix-node-pty.mjs +113 -0
  764. package/dist/setup/claude-code-install.d.ts +19 -0
  765. package/dist/setup/claude-code-install.js +51 -0
  766. package/dist/setup/claude-code-install.js.map +1 -0
  767. package/dist/setup-mode.d.ts +34 -0
  768. package/dist/setup-mode.js +49 -0
  769. package/dist/setup-mode.js.map +1 -0
  770. package/dist/solver-nets/contracts.d.ts +2 -0
  771. package/dist/solver-nets/contracts.js +2 -0
  772. package/dist/solver-nets/contracts.js.map +1 -0
  773. package/dist/solver-nets/prediction-operator-ux.d.ts +112 -0
  774. package/dist/solver-nets/prediction-operator-ux.js +463 -0
  775. package/dist/solver-nets/prediction-operator-ux.js.map +1 -0
  776. package/dist/solver-nets/registry.d.ts +64 -0
  777. package/dist/solver-nets/registry.js +218 -0
  778. package/dist/solver-nets/registry.js.map +1 -0
  779. package/dist/solver-types/_session-derived-distill.d.ts +28 -0
  780. package/dist/solver-types/_session-derived-distill.js +52 -0
  781. package/dist/solver-types/_session-derived-distill.js.map +1 -0
  782. package/dist/solver-types/_session-derived-pool.d.ts +10 -0
  783. package/dist/solver-types/_session-derived-pool.js +27 -0
  784. package/dist/solver-types/_session-derived-pool.js.map +1 -0
  785. package/dist/solver-types/_session-derived-state.d.ts +17 -0
  786. package/dist/solver-types/_session-derived-state.js +25 -0
  787. package/dist/solver-types/_session-derived-state.js.map +1 -0
  788. package/dist/solver-types/_swe-rebench-v2-aggregate.d.ts +31 -0
  789. package/dist/solver-types/_swe-rebench-v2-aggregate.js +49 -0
  790. package/dist/solver-types/_swe-rebench-v2-aggregate.js.map +1 -0
  791. package/dist/solver-types/_swe-rebench-v2-escrow.d.ts +27 -0
  792. package/dist/solver-types/_swe-rebench-v2-escrow.js +26 -0
  793. package/dist/solver-types/_swe-rebench-v2-escrow.js.map +1 -0
  794. package/dist/solver-types/_swe-rebench-v2-pool.d.ts +51 -0
  795. package/dist/solver-types/_swe-rebench-v2-pool.js +72 -0
  796. package/dist/solver-types/_swe-rebench-v2-pool.js.map +1 -0
  797. package/dist/solver-types/_swe-rebench-v2-state.d.ts +24 -0
  798. package/dist/solver-types/_swe-rebench-v2-state.js +54 -0
  799. package/dist/solver-types/_swe-rebench-v2-state.js.map +1 -0
  800. package/dist/solver-types/constants.d.ts +5 -0
  801. package/dist/solver-types/constants.js +6 -0
  802. package/dist/solver-types/constants.js.map +1 -0
  803. package/dist/solver-types/index.d.ts +10 -0
  804. package/dist/solver-types/index.js +32 -0
  805. package/dist/solver-types/index.js.map +1 -0
  806. package/dist/solver-types/learner-loop-test.d.ts +2 -0
  807. package/dist/solver-types/learner-loop-test.js +39 -0
  808. package/dist/solver-types/learner-loop-test.js.map +1 -0
  809. package/dist/solver-types/portfolio-v0.d.ts +2 -0
  810. package/dist/solver-types/portfolio-v0.js +13 -0
  811. package/dist/solver-types/portfolio-v0.js.map +1 -0
  812. package/dist/solver-types/prediction-apy-v0-auto.d.ts +27 -0
  813. package/dist/solver-types/prediction-apy-v0-auto.js +109 -0
  814. package/dist/solver-types/prediction-apy-v0-auto.js.map +1 -0
  815. package/dist/solver-types/prediction-apy-v0-template.d.ts +8 -0
  816. package/dist/solver-types/prediction-apy-v0-template.js +22 -0
  817. package/dist/solver-types/prediction-apy-v0-template.js.map +1 -0
  818. package/dist/solver-types/prediction-apy-v0.d.ts +3 -0
  819. package/dist/solver-types/prediction-apy-v0.js +25 -0
  820. package/dist/solver-types/prediction-apy-v0.js.map +1 -0
  821. package/dist/solver-types/prediction-v0-auto.d.ts +69 -0
  822. package/dist/solver-types/prediction-v0-auto.js +146 -0
  823. package/dist/solver-types/prediction-v0-auto.js.map +1 -0
  824. package/dist/solver-types/prediction-v0-template.d.ts +70 -0
  825. package/dist/solver-types/prediction-v0-template.js +145 -0
  826. package/dist/solver-types/prediction-v0-template.js.map +1 -0
  827. package/dist/solver-types/prediction-v0.d.ts +13 -0
  828. package/dist/solver-types/prediction-v0.js +31 -0
  829. package/dist/solver-types/prediction-v0.js.map +1 -0
  830. package/dist/solver-types/prediction-v1-auto.d.ts +122 -0
  831. package/dist/solver-types/prediction-v1-auto.js +366 -0
  832. package/dist/solver-types/prediction-v1-auto.js.map +1 -0
  833. package/dist/solver-types/prediction-v1.d.ts +11 -0
  834. package/dist/solver-types/prediction-v1.js +27 -0
  835. package/dist/solver-types/prediction-v1.js.map +1 -0
  836. package/dist/solver-types/session-derived.d.ts +2 -0
  837. package/dist/solver-types/session-derived.js +24 -0
  838. package/dist/solver-types/session-derived.js.map +1 -0
  839. package/dist/solver-types/solver-type.d.ts +53 -0
  840. package/dist/solver-types/solver-type.js +6 -0
  841. package/dist/solver-types/solver-type.js.map +1 -0
  842. package/dist/solver-types/swe-rebench-v2-auto.d.ts +38 -0
  843. package/dist/solver-types/swe-rebench-v2-auto.js +56 -0
  844. package/dist/solver-types/swe-rebench-v2-auto.js.map +1 -0
  845. package/dist/solver-types/swe-rebench-v2.d.ts +69 -0
  846. package/dist/solver-types/swe-rebench-v2.js +356 -0
  847. package/dist/solver-types/swe-rebench-v2.js.map +1 -0
  848. package/dist/solvernets/daemon-init.d.ts +291 -0
  849. package/dist/solvernets/daemon-init.js +431 -0
  850. package/dist/solvernets/daemon-init.js.map +1 -0
  851. package/dist/solvernets/launch-state-machine.d.ts +165 -0
  852. package/dist/solvernets/launch-state-machine.js +406 -0
  853. package/dist/solvernets/launch-state-machine.js.map +1 -0
  854. package/dist/solvernets/launched-record-dispatcher.d.ts +55 -0
  855. package/dist/solvernets/launched-record-dispatcher.js +169 -0
  856. package/dist/solvernets/launched-record-dispatcher.js.map +1 -0
  857. package/dist/solvernets/lifecycle-transitions.d.ts +183 -0
  858. package/dist/solvernets/lifecycle-transitions.js +386 -0
  859. package/dist/solvernets/lifecycle-transitions.js.map +1 -0
  860. package/dist/solvernets/manifest.d.ts +120 -0
  861. package/dist/solvernets/manifest.js +166 -0
  862. package/dist/solvernets/manifest.js.map +1 -0
  863. package/dist/solvernets/most-recent-wins.d.ts +77 -0
  864. package/dist/solvernets/most-recent-wins.js +82 -0
  865. package/dist/solvernets/most-recent-wins.js.map +1 -0
  866. package/dist/solvernets/registry-client-erc8004.d.ts +239 -0
  867. package/dist/solvernets/registry-client-erc8004.js +396 -0
  868. package/dist/solvernets/registry-client-erc8004.js.map +1 -0
  869. package/dist/solvernets/registry-client.d.ts +121 -0
  870. package/dist/solvernets/registry-client.js +19 -0
  871. package/dist/solvernets/registry-client.js.map +1 -0
  872. package/dist/solvernets/store.d.ts +298 -0
  873. package/dist/solvernets/store.js +271 -0
  874. package/dist/solvernets/store.js.map +1 -0
  875. package/dist/store/captures.d.ts +85 -0
  876. package/dist/store/captures.js +167 -0
  877. package/dist/store/captures.js.map +1 -0
  878. package/dist/store/store.d.ts +235 -21
  879. package/dist/store/store.js +1000 -46
  880. package/dist/store/store.js.map +1 -1
  881. package/dist/tasks/posting-service.d.ts +25 -0
  882. package/dist/tasks/posting-service.js +149 -0
  883. package/dist/tasks/posting-service.js.map +1 -0
  884. package/dist/tasks/signing.d.ts +4 -0
  885. package/dist/tasks/signing.js +18 -0
  886. package/dist/tasks/signing.js.map +1 -0
  887. package/dist/tasks/sources.d.ts +46 -0
  888. package/dist/tasks/sources.js +45 -0
  889. package/dist/tasks/sources.js.map +1 -0
  890. package/dist/templates/harnesses/alternative-harness/README.md.tmpl +44 -0
  891. package/dist/templates/harnesses/alternative-harness/gitignore.tmpl +3 -0
  892. package/dist/templates/harnesses/alternative-harness/jinn.manifest.json.tmpl +22 -0
  893. package/dist/templates/harnesses/alternative-harness/package.json.tmpl +26 -0
  894. package/dist/templates/harnesses/alternative-harness/src/coordinator.ts.tmpl +50 -0
  895. package/dist/templates/harnesses/alternative-harness/src/harness.ts.tmpl +31 -0
  896. package/dist/templates/harnesses/alternative-harness/src/index.ts.tmpl +44 -0
  897. package/dist/templates/harnesses/alternative-harness/src/mock-harness.ts.tmpl +41 -0
  898. package/dist/templates/harnesses/alternative-harness/src/phases/debrief.ts.tmpl +28 -0
  899. package/dist/templates/harnesses/alternative-harness/src/phases/execute.ts.tmpl +33 -0
  900. package/dist/templates/harnesses/alternative-harness/src/phases/improve.ts.tmpl +31 -0
  901. package/dist/templates/harnesses/alternative-harness/src/phases/memory.ts.tmpl +31 -0
  902. package/dist/templates/harnesses/alternative-harness/src/phases/orient.ts.tmpl +21 -0
  903. package/dist/templates/harnesses/alternative-harness/src/phases/plan.ts.tmpl +25 -0
  904. package/dist/templates/harnesses/alternative-harness/src/phases/strategize.ts.tmpl +29 -0
  905. package/dist/templates/harnesses/alternative-harness/test/coordinator.test.ts.tmpl +53 -0
  906. package/dist/templates/harnesses/alternative-harness/test/unit.test.ts.tmpl +55 -0
  907. package/dist/templates/harnesses/alternative-harness/tsconfig.json.tmpl +16 -0
  908. package/dist/templates/harnesses/evaluator/README.md.tmpl +36 -0
  909. package/dist/templates/harnesses/evaluator/gitignore.tmpl +3 -0
  910. package/dist/templates/harnesses/evaluator/jinn.manifest.json.tmpl +22 -0
  911. package/dist/templates/harnesses/evaluator/package.json.tmpl +26 -0
  912. package/dist/templates/harnesses/evaluator/src/index.ts.tmpl +35 -0
  913. package/dist/templates/harnesses/evaluator/test/unit.test.ts.tmpl +49 -0
  914. package/dist/templates/harnesses/evaluator/tsconfig.json.tmpl +16 -0
  915. package/dist/templates/harnesses/forecaster/README.md.tmpl +25 -0
  916. package/dist/templates/harnesses/forecaster/gitignore.tmpl +5 -0
  917. package/dist/templates/harnesses/forecaster/jinn.manifest.json.tmpl +22 -0
  918. package/dist/templates/harnesses/forecaster/package.json.tmpl +26 -0
  919. package/dist/templates/harnesses/forecaster/src/index.ts.tmpl +33 -0
  920. package/dist/templates/harnesses/forecaster/test/unit.test.ts.tmpl +42 -0
  921. package/dist/templates/harnesses/forecaster/tsconfig.json.tmpl +16 -0
  922. package/dist/trajectory/collector.d.ts +59 -0
  923. package/dist/trajectory/collector.js +164 -0
  924. package/dist/trajectory/collector.js.map +1 -0
  925. package/dist/trajectory/emit.d.ts +29 -0
  926. package/dist/trajectory/emit.js +81 -0
  927. package/dist/trajectory/emit.js.map +1 -0
  928. package/dist/trajectory/harness-bundle-rules/aider.d.ts +13 -0
  929. package/dist/trajectory/harness-bundle-rules/aider.js +26 -0
  930. package/dist/trajectory/harness-bundle-rules/aider.js.map +1 -0
  931. package/dist/trajectory/harness-bundle-rules/claude-code.d.ts +16 -0
  932. package/dist/trajectory/harness-bundle-rules/claude-code.js +71 -0
  933. package/dist/trajectory/harness-bundle-rules/claude-code.js.map +1 -0
  934. package/dist/trajectory/harness-bundle-rules/codex.d.ts +13 -0
  935. package/dist/trajectory/harness-bundle-rules/codex.js +96 -0
  936. package/dist/trajectory/harness-bundle-rules/codex.js.map +1 -0
  937. package/dist/trajectory/harness-bundle-rules/continue.d.ts +10 -0
  938. package/dist/trajectory/harness-bundle-rules/continue.js +43 -0
  939. package/dist/trajectory/harness-bundle-rules/continue.js.map +1 -0
  940. package/dist/trajectory/harness-bundle-rules/cursor.d.ts +20 -0
  941. package/dist/trajectory/harness-bundle-rules/cursor.js +55 -0
  942. package/dist/trajectory/harness-bundle-rules/cursor.js.map +1 -0
  943. package/dist/trajectory/harness-bundle-rules/gemini-cli.d.ts +15 -0
  944. package/dist/trajectory/harness-bundle-rules/gemini-cli.js +112 -0
  945. package/dist/trajectory/harness-bundle-rules/gemini-cli.js.map +1 -0
  946. package/dist/trajectory/harness-bundle-rules/types.d.ts +25 -0
  947. package/dist/trajectory/harness-bundle-rules/types.js +15 -0
  948. package/dist/trajectory/harness-bundle-rules/types.js.map +1 -0
  949. package/dist/trajectory/harness-bundle-schema.d.ts +74 -0
  950. package/dist/trajectory/harness-bundle-schema.js +34 -0
  951. package/dist/trajectory/harness-bundle-schema.js.map +1 -0
  952. package/dist/trajectory/harness-bundle.d.ts +73 -0
  953. package/dist/trajectory/harness-bundle.js +128 -0
  954. package/dist/trajectory/harness-bundle.js.map +1 -0
  955. package/dist/trajectory/hash-chain.d.ts +18 -0
  956. package/dist/trajectory/hash-chain.js +23 -0
  957. package/dist/trajectory/hash-chain.js.map +1 -0
  958. package/dist/trajectory/index.d.ts +28 -0
  959. package/dist/trajectory/index.js +28 -0
  960. package/dist/trajectory/index.js.map +1 -0
  961. package/dist/trajectory/llm-proxy-spans.d.ts +14 -0
  962. package/dist/trajectory/llm-proxy-spans.js +51 -0
  963. package/dist/trajectory/llm-proxy-spans.js.map +1 -0
  964. package/dist/trajectory/llm-proxy.d.ts +32 -0
  965. package/dist/trajectory/llm-proxy.js +97 -0
  966. package/dist/trajectory/llm-proxy.js.map +1 -0
  967. package/dist/trajectory/processors/credential-scrub.d.ts +11 -0
  968. package/dist/trajectory/processors/credential-scrub.js +40 -0
  969. package/dist/trajectory/processors/credential-scrub.js.map +1 -0
  970. package/dist/trajectory/processors/identity-scrub.d.ts +18 -0
  971. package/dist/trajectory/processors/identity-scrub.js +43 -0
  972. package/dist/trajectory/processors/identity-scrub.js.map +1 -0
  973. package/dist/trajectory/processors/manifest-builder.d.ts +18 -0
  974. package/dist/trajectory/processors/manifest-builder.js +26 -0
  975. package/dist/trajectory/processors/manifest-builder.js.map +1 -0
  976. package/dist/trajectory/processors/path-scrub.d.ts +15 -0
  977. package/dist/trajectory/processors/path-scrub.js +52 -0
  978. package/dist/trajectory/processors/path-scrub.js.map +1 -0
  979. package/dist/trajectory/processors/sentinel.d.ts +16 -0
  980. package/dist/trajectory/processors/sentinel.js +17 -0
  981. package/dist/trajectory/processors/sentinel.js.map +1 -0
  982. package/dist/trajectory/processors/sqlite-exporter.d.ts +32 -0
  983. package/dist/trajectory/processors/sqlite-exporter.js +48 -0
  984. package/dist/trajectory/processors/sqlite-exporter.js.map +1 -0
  985. package/dist/trajectory/processors/transcript-content-scrub.d.ts +9 -0
  986. package/dist/trajectory/processors/transcript-content-scrub.js +58 -0
  987. package/dist/trajectory/processors/transcript-content-scrub.js.map +1 -0
  988. package/dist/trajectory/receiver.d.ts +37 -0
  989. package/dist/trajectory/receiver.js +616 -0
  990. package/dist/trajectory/receiver.js.map +1 -0
  991. package/dist/trajectory/schema.d.ts +102 -14
  992. package/dist/trajectory/schema.js +29 -0
  993. package/dist/trajectory/schema.js.map +1 -1
  994. package/dist/trajectory/secret-scrub.d.ts +32 -0
  995. package/dist/trajectory/secret-scrub.js +51 -0
  996. package/dist/trajectory/secret-scrub.js.map +1 -0
  997. package/dist/trajectory/span-profile.d.ts +27 -0
  998. package/dist/trajectory/span-profile.js +51 -0
  999. package/dist/trajectory/span-profile.js.map +1 -0
  1000. package/dist/trajectory/synthetic-span-builder.d.ts +50 -0
  1001. package/dist/trajectory/synthetic-span-builder.js +115 -0
  1002. package/dist/trajectory/synthetic-span-builder.js.map +1 -0
  1003. package/dist/trajectory/transcript-parsers/aider-history.d.ts +42 -0
  1004. package/dist/trajectory/transcript-parsers/aider-history.js +182 -0
  1005. package/dist/trajectory/transcript-parsers/aider-history.js.map +1 -0
  1006. package/dist/trajectory/transcript-parsers/claude-code-jsonl.d.ts +37 -0
  1007. package/dist/trajectory/transcript-parsers/claude-code-jsonl.js +143 -0
  1008. package/dist/trajectory/transcript-parsers/claude-code-jsonl.js.map +1 -0
  1009. package/dist/trajectory/transcript-parsers/codex-session.d.ts +36 -0
  1010. package/dist/trajectory/transcript-parsers/codex-session.js +135 -0
  1011. package/dist/trajectory/transcript-parsers/codex-session.js.map +1 -0
  1012. package/dist/trajectory/transcript-parsers/continue-devdata.d.ts +41 -0
  1013. package/dist/trajectory/transcript-parsers/continue-devdata.js +191 -0
  1014. package/dist/trajectory/transcript-parsers/continue-devdata.js.map +1 -0
  1015. package/dist/trajectory/transcript-parsers/cursor-sqlite.d.ts +38 -0
  1016. package/dist/trajectory/transcript-parsers/cursor-sqlite.js +119 -0
  1017. package/dist/trajectory/transcript-parsers/cursor-sqlite.js.map +1 -0
  1018. package/dist/trajectory/transcript-parsers/gemini-session.d.ts +35 -0
  1019. package/dist/trajectory/transcript-parsers/gemini-session.js +138 -0
  1020. package/dist/trajectory/transcript-parsers/gemini-session.js.map +1 -0
  1021. package/dist/trajectory/transcript-parsers/types.d.ts +101 -0
  1022. package/dist/trajectory/transcript-parsers/types.js +33 -0
  1023. package/dist/trajectory/transcript-parsers/types.js.map +1 -0
  1024. package/dist/trajectory/transcript-watcher.d.ts +62 -0
  1025. package/dist/trajectory/transcript-watcher.js +157 -0
  1026. package/dist/trajectory/transcript-watcher.js.map +1 -0
  1027. package/dist/trajectory/wrappers/http.d.ts +37 -0
  1028. package/dist/trajectory/wrappers/http.js +85 -0
  1029. package/dist/trajectory/wrappers/http.js.map +1 -0
  1030. package/dist/trajectory/wrappers/mcp.d.ts +17 -0
  1031. package/dist/trajectory/wrappers/mcp.js +58 -0
  1032. package/dist/trajectory/wrappers/mcp.js.map +1 -0
  1033. package/dist/trajectory/wrappers/subprocess.d.ts +32 -0
  1034. package/dist/trajectory/wrappers/subprocess.js +70 -0
  1035. package/dist/trajectory/wrappers/subprocess.js.map +1 -0
  1036. package/dist/tx-retry.js +90 -9
  1037. package/dist/tx-retry.js.map +1 -1
  1038. package/dist/types/envelope.d.ts +2742 -0
  1039. package/dist/types/envelope.js +149 -0
  1040. package/dist/types/envelope.js.map +1 -0
  1041. package/dist/types/index.d.ts +4 -4
  1042. package/dist/types/index.js +4 -4
  1043. package/dist/types/index.js.map +1 -1
  1044. package/dist/types/payloads/index.d.ts +12 -0
  1045. package/dist/types/payloads/index.js +62 -0
  1046. package/dist/types/payloads/index.js.map +1 -0
  1047. package/dist/types/payloads/portfolio-v0.d.ts +481 -0
  1048. package/dist/types/payloads/portfolio-v0.js +94 -0
  1049. package/dist/types/payloads/portfolio-v0.js.map +1 -0
  1050. package/dist/types/payloads/prediction-apy-v0.d.ts +231 -0
  1051. package/dist/types/payloads/prediction-apy-v0.js +63 -0
  1052. package/dist/types/payloads/prediction-apy-v0.js.map +1 -0
  1053. package/dist/types/payloads/prediction-v0.d.ts +262 -0
  1054. package/dist/types/payloads/prediction-v0.js +73 -0
  1055. package/dist/types/payloads/prediction-v0.js.map +1 -0
  1056. package/dist/types/payloads/prediction-v1.d.ts +2 -0
  1057. package/dist/types/payloads/prediction-v1.js +2 -0
  1058. package/dist/types/payloads/prediction-v1.js.map +1 -0
  1059. package/dist/types/portfolio.d.ts +31 -698
  1060. package/dist/types/portfolio.js +20 -110
  1061. package/dist/types/portfolio.js.map +1 -1
  1062. package/dist/types/prediction-apy.d.ts +26 -366
  1063. package/dist/types/prediction-apy.js +12 -68
  1064. package/dist/types/prediction-apy.js.map +1 -1
  1065. package/dist/types/prediction-v1.d.ts +2 -0
  1066. package/dist/types/prediction-v1.js +2 -0
  1067. package/dist/types/prediction-v1.js.map +1 -0
  1068. package/dist/types/prediction.d.ts +546 -382
  1069. package/dist/types/prediction.js +16 -87
  1070. package/dist/types/prediction.js.map +1 -1
  1071. package/dist/types/session-provenance.d.ts +71 -0
  1072. package/dist/types/session-provenance.js +19 -0
  1073. package/dist/types/session-provenance.js.map +1 -0
  1074. package/dist/types/task-document.d.ts +1121 -0
  1075. package/dist/types/task-document.js +99 -0
  1076. package/dist/types/task-document.js.map +1 -0
  1077. package/dist/types/task.d.ts +805 -0
  1078. package/dist/types/task.js +88 -0
  1079. package/dist/types/task.js.map +1 -0
  1080. package/dist/types/window.d.ts +12 -0
  1081. package/dist/types/window.js +6 -0
  1082. package/dist/types/window.js.map +1 -0
  1083. package/dist/util/path-safety.d.ts +21 -0
  1084. package/dist/util/path-safety.js +28 -0
  1085. package/dist/util/path-safety.js.map +1 -0
  1086. package/dist/util/redact-rpc-urls.d.ts +5 -0
  1087. package/dist/util/redact-rpc-urls.js +9 -0
  1088. package/dist/util/redact-rpc-urls.js.map +1 -0
  1089. package/dist/vendor/@jinn-network/sdk/README.md +89 -0
  1090. package/dist/vendor/@jinn-network/sdk/dist/capabilities.d.ts +52 -0
  1091. package/dist/vendor/@jinn-network/sdk/dist/capabilities.js +1 -0
  1092. package/dist/vendor/@jinn-network/sdk/dist/checkpoint.d.ts +120 -0
  1093. package/dist/vendor/@jinn-network/sdk/dist/checkpoint.js +39 -0
  1094. package/dist/vendor/@jinn-network/sdk/dist/contracts.d.ts +145 -0
  1095. package/dist/vendor/@jinn-network/sdk/dist/contracts.js +317 -0
  1096. package/dist/vendor/@jinn-network/sdk/dist/harness.d.ts +120 -0
  1097. package/dist/vendor/@jinn-network/sdk/dist/harness.js +31 -0
  1098. package/dist/vendor/@jinn-network/sdk/dist/index.d.ts +4 -0
  1099. package/dist/vendor/@jinn-network/sdk/dist/index.js +7 -0
  1100. package/dist/vendor/@jinn-network/sdk/dist/json-schema.d.ts +32 -0
  1101. package/dist/vendor/@jinn-network/sdk/dist/json-schema.js +131 -0
  1102. package/dist/vendor/@jinn-network/sdk/dist/manifest.d.ts +69 -0
  1103. package/dist/vendor/@jinn-network/sdk/dist/manifest.js +3 -0
  1104. package/dist/vendor/@jinn-network/sdk/dist/payloads/prediction-v1.d.ts +223 -0
  1105. package/dist/vendor/@jinn-network/sdk/dist/payloads/prediction-v1.js +64 -0
  1106. package/dist/vendor/@jinn-network/sdk/dist/payloads/session-derived.d.ts +359 -0
  1107. package/dist/vendor/@jinn-network/sdk/dist/payloads/session-derived.js +60 -0
  1108. package/dist/vendor/@jinn-network/sdk/dist/payloads/swe-rebench-v2.d.ts +110 -0
  1109. package/dist/vendor/@jinn-network/sdk/dist/payloads/swe-rebench-v2.js +58 -0
  1110. package/dist/vendor/@jinn-network/sdk/dist/plugins.d.ts +36 -0
  1111. package/dist/vendor/@jinn-network/sdk/dist/plugins.js +54 -0
  1112. package/dist/vendor/@jinn-network/sdk/dist/prediction-v1.d.ts +870 -0
  1113. package/dist/vendor/@jinn-network/sdk/dist/prediction-v1.js +80 -0
  1114. package/dist/vendor/@jinn-network/sdk/dist/session-derived/distill-prompt-v1.d.ts +2 -0
  1115. package/dist/vendor/@jinn-network/sdk/dist/session-derived/distill-prompt-v1.js +10 -0
  1116. package/dist/vendor/@jinn-network/sdk/dist/solvernets/index.d.ts +6 -0
  1117. package/dist/vendor/@jinn-network/sdk/dist/solvernets/index.js +8 -0
  1118. package/dist/vendor/@jinn-network/sdk/dist/solvernets/manifest-schema.d.ts +559 -0
  1119. package/dist/vendor/@jinn-network/sdk/dist/solvernets/manifest-schema.js +126 -0
  1120. package/dist/vendor/@jinn-network/sdk/dist/solvernets/prediction-v1.d.ts +6 -0
  1121. package/dist/vendor/@jinn-network/sdk/dist/solvernets/prediction-v1.js +3 -0
  1122. package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2.d.ts +4 -0
  1123. package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2.js +2 -0
  1124. package/dist/vendor/@jinn-network/sdk/dist/swe-rebench-v2.d.ts +66 -0
  1125. package/dist/vendor/@jinn-network/sdk/dist/swe-rebench-v2.js +44 -0
  1126. package/dist/vendor/@jinn-network/sdk/dist/types.d.ts +116 -0
  1127. package/dist/vendor/@jinn-network/sdk/dist/types.js +21 -0
  1128. package/dist/vendor/@jinn-network/sdk/package.json +43 -0
  1129. package/dist/venues/hyperliquid/account-value.d.ts +1 -1
  1130. package/dist/venues/hyperliquid/account-value.js +1 -1
  1131. package/dist/venues/polymarket/client.d.ts +77 -0
  1132. package/dist/venues/polymarket/client.js +309 -0
  1133. package/dist/venues/polymarket/client.js.map +1 -0
  1134. package/dist/withdraw/run-withdraw-plan.js +0 -2
  1135. package/dist/withdraw/run-withdraw-plan.js.map +1 -1
  1136. package/dist/x402/acquire.d.ts +14 -3
  1137. package/dist/x402/acquire.js +28 -11
  1138. package/dist/x402/acquire.js.map +1 -1
  1139. package/dist/x402/handler.d.ts +15 -3
  1140. package/dist/x402/handler.js +189 -24
  1141. package/dist/x402/handler.js.map +1 -1
  1142. package/package.json +60 -15
  1143. package/plugins/claude-code-learner/.claude-plugin/plugin.json +9 -0
  1144. package/plugins/claude-code-learner/.codex-plugin/plugin.json +39 -0
  1145. package/plugins/claude-code-learner/AGENTS.md +40 -0
  1146. package/plugins/claude-code-learner/CLAUDE.md +33 -0
  1147. package/plugins/claude-code-learner/README.md +59 -0
  1148. package/plugins/claude-code-learner/hooks/hooks.json +16 -0
  1149. package/plugins/claude-code-learner/hooks/session-start +38 -0
  1150. package/plugins/claude-code-learner/skills/learn/SKILL.md +412 -0
  1151. package/plugins/claude-code-learner/skills/learn/analyst-prompt.md +68 -0
  1152. package/plugins/claude-code-learner/skills/learn/consolidator-prompt.md +94 -0
  1153. package/plugins/claude-code-learner/skills/learn/explorer-prompt.md +53 -0
  1154. package/plugins/claude-code-learner/skills/learn/planner-prompt.md +87 -0
  1155. package/plugins/claude-code-learner/skills/learn/promoter-prompt.md +113 -0
  1156. package/plugins/claude-code-learner/skills/learn/step-worker-prompt.md +47 -0
  1157. package/plugins/claude-code-learner/skills/learn/strategist-prompt.md +85 -0
  1158. package/plugins/jinn-prediction-plugin/.claude-plugin/plugin.json +19 -0
  1159. package/plugins/jinn-prediction-plugin/.mcp.json +8 -0
  1160. package/plugins/jinn-prediction-plugin/GEMINI.md +7 -0
  1161. package/plugins/jinn-prediction-plugin/gemini-extension.json +13 -0
  1162. package/plugins/jinn-prediction-plugin/jinn.plugin.json +26 -0
  1163. package/plugins/jinn-prediction-plugin/mcp/polymarket-server.mjs +322 -0
  1164. package/plugins/jinn-prediction-plugin/schemas/prediction-v0-solution.schema.json +12 -0
  1165. package/plugins/jinn-prediction-plugin/schemas/prediction-v0-task.schema.json +25 -0
  1166. package/plugins/jinn-prediction-plugin/schemas/prediction-v0-verdict.schema.json +11 -0
  1167. package/plugins/jinn-prediction-plugin/schemas/prediction-v1-solution.schema.json +34 -0
  1168. package/plugins/jinn-prediction-plugin/schemas/prediction-v1-task.schema.json +118 -0
  1169. package/plugins/jinn-prediction-plugin/schemas/prediction-v1-verdict.schema.json +84 -0
  1170. package/plugins/jinn-prediction-plugin/skills/base-rate-forecasting/SKILL.md +3 -0
  1171. package/plugins/jinn-prediction-plugin/skills/calibration/SKILL.md +3 -0
  1172. package/plugins/jinn-prediction-plugin/skills/common-biases/SKILL.md +3 -0
  1173. package/plugins/jinn-prediction-plugin/skills/polymarket-task-handling/SKILL.md +5 -0
  1174. package/plugins/jinn-prediction-plugin/skills/prediction-corpus-retrieval/SKILL.md +35 -0
  1175. package/plugins/network-tools/.claude-plugin/plugin.json +12 -0
  1176. package/plugins/network-tools/.codex-plugin/plugin.json +39 -0
  1177. package/plugins/network-tools/.mcp.json +11 -0
  1178. package/plugins/network-tools/jinn.plugin.json +29 -0
  1179. package/plugins/network-tools/mcp/jinn-client-server.mjs +110 -0
  1180. package/plugins/swe-rebench-v2-runtime/.claude-plugin/plugin.json +5 -0
  1181. package/plugins/swe-rebench-v2-runtime/.codex-plugin/plugin.json +39 -0
  1182. package/plugins/swe-rebench-v2-runtime/README.md +11 -0
  1183. package/plugins/swe-rebench-v2-runtime/jinn.plugin.json +12 -0
  1184. package/plugins/swe-rebench-v2-runtime/skills/orient/SKILL.md +25 -0
  1185. package/plugins/swe-rebench-v2-runtime/skills/plan/SKILL.md +64 -0
  1186. package/skills/jinn-operator/SKILL.md +120 -101
  1187. package/templates/harnesses/alternative-harness/README.md.tmpl +44 -0
  1188. package/templates/harnesses/alternative-harness/gitignore.tmpl +3 -0
  1189. package/templates/harnesses/alternative-harness/jinn.manifest.json.tmpl +22 -0
  1190. package/templates/harnesses/alternative-harness/package.json.tmpl +26 -0
  1191. package/templates/harnesses/alternative-harness/src/coordinator.ts.tmpl +50 -0
  1192. package/templates/harnesses/alternative-harness/src/harness.ts.tmpl +31 -0
  1193. package/templates/harnesses/alternative-harness/src/index.ts.tmpl +44 -0
  1194. package/templates/harnesses/alternative-harness/src/mock-harness.ts.tmpl +41 -0
  1195. package/templates/harnesses/alternative-harness/src/phases/debrief.ts.tmpl +28 -0
  1196. package/templates/harnesses/alternative-harness/src/phases/execute.ts.tmpl +33 -0
  1197. package/templates/harnesses/alternative-harness/src/phases/improve.ts.tmpl +31 -0
  1198. package/templates/harnesses/alternative-harness/src/phases/memory.ts.tmpl +31 -0
  1199. package/templates/harnesses/alternative-harness/src/phases/orient.ts.tmpl +21 -0
  1200. package/templates/harnesses/alternative-harness/src/phases/plan.ts.tmpl +25 -0
  1201. package/templates/harnesses/alternative-harness/src/phases/strategize.ts.tmpl +29 -0
  1202. package/templates/harnesses/alternative-harness/test/coordinator.test.ts.tmpl +53 -0
  1203. package/templates/harnesses/alternative-harness/test/unit.test.ts.tmpl +55 -0
  1204. package/templates/harnesses/alternative-harness/tsconfig.json.tmpl +16 -0
  1205. package/templates/harnesses/evaluator/README.md.tmpl +36 -0
  1206. package/templates/harnesses/evaluator/gitignore.tmpl +3 -0
  1207. package/templates/harnesses/evaluator/jinn.manifest.json.tmpl +22 -0
  1208. package/templates/harnesses/evaluator/package.json.tmpl +26 -0
  1209. package/templates/harnesses/evaluator/src/index.ts.tmpl +35 -0
  1210. package/templates/harnesses/evaluator/test/unit.test.ts.tmpl +49 -0
  1211. package/templates/harnesses/evaluator/tsconfig.json.tmpl +16 -0
  1212. package/templates/harnesses/forecaster/README.md.tmpl +25 -0
  1213. package/templates/harnesses/forecaster/gitignore.tmpl +5 -0
  1214. package/templates/harnesses/forecaster/jinn.manifest.json.tmpl +22 -0
  1215. package/templates/harnesses/forecaster/package.json.tmpl +26 -0
  1216. package/templates/harnesses/forecaster/src/index.ts.tmpl +33 -0
  1217. package/templates/harnesses/forecaster/test/unit.test.ts.tmpl +42 -0
  1218. package/templates/harnesses/forecaster/tsconfig.json.tmpl +16 -0
  1219. package/dist/adapters/claim-registry/abi.d.ts +0 -127
  1220. package/dist/adapters/claim-registry/abi.js +0 -93
  1221. package/dist/adapters/claim-registry/abi.js.map +0 -1
  1222. package/dist/adapters/claim-registry/client.d.ts +0 -89
  1223. package/dist/adapters/claim-registry/client.js +0 -205
  1224. package/dist/adapters/claim-registry/client.js.map +0 -1
  1225. package/dist/adapters/mech/claim-policy.d.ts +0 -40
  1226. package/dist/adapters/mech/claim-policy.js +0 -104
  1227. package/dist/adapters/mech/claim-policy.js.map +0 -1
  1228. package/dist/bin/jinn-mcp.d.ts +0 -2
  1229. package/dist/bin/jinn-mcp.js +0 -10
  1230. package/dist/bin/jinn-mcp.js.map +0 -1
  1231. package/dist/cli/commands/intents.d.ts +0 -17
  1232. package/dist/cli/commands/intents.js +0 -489
  1233. package/dist/cli/commands/intents.js.map +0 -1
  1234. package/dist/cli/commands/plugin-install.js +0 -803
  1235. package/dist/cli/commands/plugin-install.js.map +0 -1
  1236. package/dist/cli/commands/submit-intent.js +0 -245
  1237. package/dist/cli/commands/submit-intent.js.map +0 -1
  1238. package/dist/cli/intent-registry-access.d.ts +0 -62
  1239. package/dist/cli/intent-registry-access.js +0 -165
  1240. package/dist/cli/intent-registry-access.js.map +0 -1
  1241. package/dist/discovery/registry.d.ts +0 -97
  1242. package/dist/discovery/registry.js +0 -177
  1243. package/dist/discovery/registry.js.map +0 -1
  1244. package/dist/discovery/subgraph.d.ts +0 -37
  1245. package/dist/discovery/subgraph.js +0 -87
  1246. package/dist/discovery/subgraph.js.map +0 -1
  1247. package/dist/intents/kinds/constants.d.ts +0 -5
  1248. package/dist/intents/kinds/constants.js +0 -6
  1249. package/dist/intents/kinds/constants.js.map +0 -1
  1250. package/dist/intents/kinds/index.d.ts +0 -28
  1251. package/dist/intents/kinds/index.js +0 -50
  1252. package/dist/intents/kinds/index.js.map +0 -1
  1253. package/dist/intents/kinds/portfolio-v0.d.ts +0 -2
  1254. package/dist/intents/kinds/portfolio-v0.js +0 -13
  1255. package/dist/intents/kinds/portfolio-v0.js.map +0 -1
  1256. package/dist/intents/kinds/prediction-apy-v0.d.ts +0 -3
  1257. package/dist/intents/kinds/prediction-apy-v0.js +0 -21
  1258. package/dist/intents/kinds/prediction-apy-v0.js.map +0 -1
  1259. package/dist/intents/kinds/prediction-v0.d.ts +0 -3
  1260. package/dist/intents/kinds/prediction-v0.js +0 -32
  1261. package/dist/intents/kinds/prediction-v0.js.map +0 -1
  1262. package/dist/intents/kinds/spec-kind.d.ts +0 -38
  1263. package/dist/intents/kinds/spec-kind.js +0 -6
  1264. package/dist/intents/kinds/spec-kind.js.map +0 -1
  1265. package/dist/intents/posting-service.d.ts +0 -26
  1266. package/dist/intents/posting-service.js +0 -218
  1267. package/dist/intents/posting-service.js.map +0 -1
  1268. package/dist/intents/prediction-apy-v0-auto.d.ts +0 -11
  1269. package/dist/intents/prediction-apy-v0-auto.js +0 -46
  1270. package/dist/intents/prediction-apy-v0-auto.js.map +0 -1
  1271. package/dist/intents/prediction-apy-v0-template.d.ts +0 -8
  1272. package/dist/intents/prediction-apy-v0-template.js +0 -22
  1273. package/dist/intents/prediction-apy-v0-template.js.map +0 -1
  1274. package/dist/intents/prediction-v0-auto.d.ts +0 -53
  1275. package/dist/intents/prediction-v0-auto.js +0 -84
  1276. package/dist/intents/prediction-v0-auto.js.map +0 -1
  1277. package/dist/intents/prediction-v0-template.d.ts +0 -70
  1278. package/dist/intents/prediction-v0-template.js +0 -145
  1279. package/dist/intents/prediction-v0-template.js.map +0 -1
  1280. package/dist/intents/sources.d.ts +0 -39
  1281. package/dist/intents/sources.js +0 -42
  1282. package/dist/intents/sources.js.map +0 -1
  1283. package/dist/restorer/engine/canonical-json.d.ts +0 -18
  1284. package/dist/restorer/engine/canonical-json.js +0 -59
  1285. package/dist/restorer/engine/canonical-json.js.map +0 -1
  1286. package/dist/restorer/engine/claim.d.ts +0 -69
  1287. package/dist/restorer/engine/claim.js +0 -104
  1288. package/dist/restorer/engine/claim.js.map +0 -1
  1289. package/dist/restorer/engine/delivery.d.ts +0 -52
  1290. package/dist/restorer/engine/delivery.js +0 -63
  1291. package/dist/restorer/engine/delivery.js.map +0 -1
  1292. package/dist/restorer/engine/engine.d.ts +0 -213
  1293. package/dist/restorer/engine/engine.js +0 -769
  1294. package/dist/restorer/engine/engine.js.map +0 -1
  1295. package/dist/restorer/engine/manifest-assembly.d.ts +0 -67
  1296. package/dist/restorer/engine/manifest-assembly.js +0 -79
  1297. package/dist/restorer/engine/manifest-assembly.js.map +0 -1
  1298. package/dist/restorer/engine/packaging.d.ts +0 -87
  1299. package/dist/restorer/engine/packaging.js +0 -350
  1300. package/dist/restorer/engine/packaging.js.map +0 -1
  1301. package/dist/restorer/engine/persistence.d.ts +0 -170
  1302. package/dist/restorer/engine/persistence.js +0 -381
  1303. package/dist/restorer/engine/persistence.js.map +0 -1
  1304. package/dist/restorer/engine/recovery.d.ts +0 -22
  1305. package/dist/restorer/engine/recovery.js +0 -24
  1306. package/dist/restorer/engine/recovery.js.map +0 -1
  1307. package/dist/restorer/engine/registry.d.ts +0 -62
  1308. package/dist/restorer/engine/registry.js +0 -73
  1309. package/dist/restorer/engine/registry.js.map +0 -1
  1310. package/dist/restorer/engine/signing.d.ts +0 -30
  1311. package/dist/restorer/engine/signing.js +0 -39
  1312. package/dist/restorer/engine/signing.js.map +0 -1
  1313. package/dist/restorer/engine/state.d.ts +0 -42
  1314. package/dist/restorer/engine/state.js +0 -87
  1315. package/dist/restorer/engine/state.js.map +0 -1
  1316. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.d.ts +0 -64
  1317. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js.map +0 -1
  1318. package/dist/restorer/impls/claude-mcp-hyperliquid/index.d.ts +0 -104
  1319. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js +0 -721
  1320. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js.map +0 -1
  1321. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js.map +0 -1
  1322. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js.map +0 -1
  1323. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +0 -97
  1324. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js +0 -226
  1325. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +0 -1
  1326. package/dist/restorer/impls/claude-mcp-prediction/index.d.ts +0 -44
  1327. package/dist/restorer/impls/claude-mcp-prediction/index.js +0 -239
  1328. package/dist/restorer/impls/claude-mcp-prediction/index.js.map +0 -1
  1329. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js +0 -135
  1330. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js.map +0 -1
  1331. package/dist/restorer/impls/claude-mcp-prediction/prompt.d.ts +0 -8
  1332. package/dist/restorer/impls/claude-mcp-prediction/prompt.js +0 -54
  1333. package/dist/restorer/impls/claude-mcp-prediction/prompt.js.map +0 -1
  1334. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.d.ts +0 -36
  1335. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js +0 -137
  1336. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js.map +0 -1
  1337. package/dist/restorer/impls/claude-mcp-prediction/types.d.ts +0 -84
  1338. package/dist/restorer/impls/claude-mcp-prediction/types.js +0 -6
  1339. package/dist/restorer/impls/claude-mcp-prediction/types.js.map +0 -1
  1340. package/dist/restorer/impls/claude-mcp-prediction-apy/index.d.ts +0 -34
  1341. package/dist/restorer/impls/claude-mcp-prediction-apy/index.js +0 -233
  1342. package/dist/restorer/impls/claude-mcp-prediction-apy/index.js.map +0 -1
  1343. package/dist/restorer/impls/claude-mcp-prediction-apy/mcp-tools.js +0 -136
  1344. package/dist/restorer/impls/claude-mcp-prediction-apy/mcp-tools.js.map +0 -1
  1345. package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.d.ts +0 -7
  1346. package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.js +0 -46
  1347. package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.js.map +0 -1
  1348. package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.d.ts +0 -27
  1349. package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js +0 -128
  1350. package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js.map +0 -1
  1351. package/dist/restorer/impls/claude-mcp-prediction-apy/types.d.ts +0 -64
  1352. package/dist/restorer/impls/claude-mcp-prediction-apy/types.js +0 -6
  1353. package/dist/restorer/impls/claude-mcp-prediction-apy/types.js.map +0 -1
  1354. package/dist/restorer/impls/evaluation-context.d.ts +0 -16
  1355. package/dist/restorer/impls/evaluation-context.js +0 -18
  1356. package/dist/restorer/impls/evaluation-context.js.map +0 -1
  1357. package/dist/restorer/impls/index.d.ts +0 -46
  1358. package/dist/restorer/impls/index.js +0 -88
  1359. package/dist/restorer/impls/index.js.map +0 -1
  1360. package/dist/restorer/impls/legacy-claude/index.d.ts +0 -52
  1361. package/dist/restorer/impls/legacy-claude/index.js +0 -140
  1362. package/dist/restorer/impls/legacy-claude/index.js.map +0 -1
  1363. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +0 -68
  1364. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js +0 -117
  1365. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js.map +0 -1
  1366. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js.map +0 -1
  1367. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.d.ts +0 -78
  1368. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js +0 -274
  1369. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js.map +0 -1
  1370. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +0 -23
  1371. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js +0 -49
  1372. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js.map +0 -1
  1373. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.d.ts +0 -25
  1374. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js +0 -44
  1375. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js.map +0 -1
  1376. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.d.ts +0 -17
  1377. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js +0 -43
  1378. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js.map +0 -1
  1379. package/dist/restorer/impls/portfolio-v0-evaluator/index.d.ts +0 -44
  1380. package/dist/restorer/impls/portfolio-v0-evaluator/index.js +0 -440
  1381. package/dist/restorer/impls/portfolio-v0-evaluator/index.js.map +0 -1
  1382. package/dist/restorer/impls/portfolio-v0-evaluator/score.js.map +0 -1
  1383. package/dist/restorer/impls/portfolio-v0-evaluator/types.d.ts +0 -34
  1384. package/dist/restorer/impls/portfolio-v0-evaluator/types.js.map +0 -1
  1385. package/dist/restorer/impls/prediction-apy-v0-baseline/index.d.ts +0 -40
  1386. package/dist/restorer/impls/prediction-apy-v0-baseline/index.js +0 -107
  1387. package/dist/restorer/impls/prediction-apy-v0-baseline/index.js.map +0 -1
  1388. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js.map +0 -1
  1389. package/dist/restorer/impls/prediction-apy-v0-baseline/types.js.map +0 -1
  1390. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +0 -6
  1391. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js +0 -11
  1392. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +0 -1
  1393. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.d.ts +0 -42
  1394. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js +0 -208
  1395. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js.map +0 -1
  1396. package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.d.ts +0 -7
  1397. package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js +0 -29
  1398. package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js.map +0 -1
  1399. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js.map +0 -1
  1400. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js.map +0 -1
  1401. package/dist/restorer/impls/prediction-v0-baseline/index.d.ts +0 -31
  1402. package/dist/restorer/impls/prediction-v0-baseline/index.js +0 -100
  1403. package/dist/restorer/impls/prediction-v0-baseline/index.js.map +0 -1
  1404. package/dist/restorer/impls/prediction-v0-baseline/strategy.d.ts +0 -8
  1405. package/dist/restorer/impls/prediction-v0-baseline/strategy.js +0 -41
  1406. package/dist/restorer/impls/prediction-v0-baseline/strategy.js.map +0 -1
  1407. package/dist/restorer/impls/prediction-v0-baseline/types.d.ts +0 -7
  1408. package/dist/restorer/impls/prediction-v0-baseline/types.js.map +0 -1
  1409. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.d.ts +0 -20
  1410. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js.map +0 -1
  1411. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.d.ts +0 -9
  1412. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js.map +0 -1
  1413. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.d.ts +0 -3
  1414. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js.map +0 -1
  1415. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.d.ts +0 -13
  1416. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js +0 -111
  1417. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js.map +0 -1
  1418. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.d.ts +0 -5
  1419. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js.map +0 -1
  1420. package/dist/restorer/impls/prediction-v0-evaluator/index.d.ts +0 -36
  1421. package/dist/restorer/impls/prediction-v0-evaluator/index.js +0 -234
  1422. package/dist/restorer/impls/prediction-v0-evaluator/index.js.map +0 -1
  1423. package/dist/restorer/impls/prediction-v0-evaluator/score.js.map +0 -1
  1424. package/dist/restorer/impls/prediction-v0-evaluator/types.js.map +0 -1
  1425. package/dist/restorer/types.d.ts +0 -194
  1426. package/dist/restorer/types.js +0 -28
  1427. package/dist/restorer/types.js.map +0 -1
  1428. package/dist/types/desired-state.d.ts +0 -94
  1429. package/dist/types/desired-state.js +0 -36
  1430. package/dist/types/desired-state.js.map +0 -1
  1431. /package/dist/cli/commands/{plugin-install.d.ts → solver-nets.d.ts} +0 -0
  1432. /package/dist/cli/commands/{submit-intent.d.ts → tasks.d.ts} +0 -0
  1433. /package/dist/{restorer/impls/prediction-apy-v0-baseline → harnesses/impls/claude-code-learner}/types.js +0 -0
  1434. /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/api-wallet.js +0 -0
  1435. /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/mcp-tools.d.ts +0 -0
  1436. /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/mcp-tools.js +0 -0
  1437. /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/safety-rails.d.ts +0 -0
  1438. /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/safety-rails.js +0 -0
  1439. /package/dist/{restorer → harnesses}/impls/claude-mcp-prediction/mcp-tools.d.ts +0 -0
  1440. /package/dist/{restorer → harnesses}/impls/claude-mcp-prediction-apy/mcp-tools.d.ts +0 -0
  1441. /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/availability.d.ts +0 -0
  1442. /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/availability.js +0 -0
  1443. /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/score.d.ts +0 -0
  1444. /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/score.js +0 -0
  1445. /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/types.js +0 -0
  1446. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-baseline/strategy.d.ts +0 -0
  1447. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-baseline/strategy.js +0 -0
  1448. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-baseline/types.d.ts +0 -0
  1449. /package/dist/{restorer/impls/prediction-apy-v0-evaluator → harnesses/impls/prediction-apy-v0-baseline}/types.js +0 -0
  1450. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-evaluator/score.d.ts +0 -0
  1451. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-evaluator/score.js +0 -0
  1452. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-evaluator/types.d.ts +0 -0
  1453. /package/dist/{restorer/impls/prediction-v0-baseline → harnesses/impls/prediction-apy-v0-evaluator}/types.js +0 -0
  1454. /package/dist/{restorer/impls/prediction-v0-evaluator → harnesses/impls/prediction-v0-baseline}/types.js +0 -0
  1455. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/canonical-metrics.js +0 -0
  1456. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/availability.js +0 -0
  1457. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/eligibility.js +0 -0
  1458. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/spec.js +0 -0
  1459. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/score.d.ts +0 -0
  1460. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/score.js +0 -0
  1461. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/types.d.ts +0 -0
@@ -0,0 +1,1626 @@
1
+ /**
2
+ * Harness engine — main TaskEngine class.
3
+ *
4
+ * §6.3, §6.5 of spec/2026-04-17-portfolio-v0-design.md
5
+ *
6
+ * Orchestrates the state machine lifecycle for each observed task.
7
+ * Transition method bodies are stubs; subsequent tasks fill them in.
8
+ */
9
+ import { join } from 'node:path';
10
+ import { createHash, randomUUID } from 'node:crypto';
11
+ import { keccak256, toBytes } from 'viem';
12
+ import { TaskRunPersistence } from './persistence.js';
13
+ import { TaskRunState, MissingEvidenceHashError } from './state.js';
14
+ import { provisionWorkingDir, provisionImplStateDir, walkArtifacts, uploadArtifacts, } from './packaging.js';
15
+ import { DONATION_ARTIFACT_ENCODING } from './artifact-scrub.js';
16
+ import { assembleAndSignEnvelope, } from './envelope-assembly.js';
17
+ import { deliverAndClaim, } from './delivery.js';
18
+ import { SkippableError } from '../types.js';
19
+ import { submitEvaluatorFeedback, codeDigestSha256ToBytes32, modeStringToFlag, } from '../../erc8004/index.js';
20
+ import { TrajectoryCollector, emitTrajectory } from '../../trajectory/index.js';
21
+ import { uploadToIpfs } from '../../adapters/mech/ipfs.js';
22
+ import { buildInfo } from '../../build-info.js';
23
+ import { getSolverNetContract } from '../../vendor/@jinn-network/sdk/dist/solvernets/index.js';
24
+ import { runHarnessWithFreezeFence, } from '../../daemon/freeze-fence.js';
25
+ import { harnessStateDirName } from '../names.js';
26
+ // ── Sentinel error ────────────────────────────────────────────────────────────
27
+ export class NotImplementedError extends Error {
28
+ transitionName;
29
+ constructor(transitionName) {
30
+ super(`[NotImplemented] ${transitionName} — fill in via subsequent task`);
31
+ this.name = 'NotImplementedError';
32
+ this.transitionName = transitionName;
33
+ }
34
+ }
35
+ /** Map task role to the operator role it requires in `joinedSolverNets`. */
36
+ function joinedRoleForTaskRole(taskRole) {
37
+ return taskRole === 'evaluation' ? 'evaluator' : 'solver';
38
+ }
39
+ /**
40
+ * Build a `JoinedSolverNetsView` from the raw operator-config block.
41
+ *
42
+ * The config carries the full `JoinedSolverNetEntry` shape (manifestCid,
43
+ * name, roles, harness, model, plugins, ...). The engine only needs
44
+ * `roles` and the CID-keyed lookup, so this helper narrows it.
45
+ */
46
+ export function joinedSolverNetsViewFromConfig(joined) {
47
+ if (!joined)
48
+ return undefined;
49
+ const map = new Map();
50
+ for (const [key, entry] of Object.entries(joined)) {
51
+ // The config keys joined nets by `manifestCid`. We accept either the key
52
+ // or the entry's `manifestCid` field; in practice they're identical.
53
+ const cid = entry.manifestCid ?? key;
54
+ map.set(cid, { roles: entry.roles });
55
+ }
56
+ return {
57
+ get: (cid) => map.get(cid),
58
+ manifestCids: () => [...map.keys()],
59
+ };
60
+ }
61
+ // ── TaskEngine ─────────────────────────────────────────────────────────
62
+ export class TaskEngine {
63
+ persistence;
64
+ paths;
65
+ packagingDeps;
66
+ envelopeDeps;
67
+ deliveryDeps;
68
+ implRegistry;
69
+ solverNetRegistry;
70
+ joinedSolverNets;
71
+ manifestResolver;
72
+ identityPublisher;
73
+ reputationFeedback;
74
+ operatorConfig;
75
+ /**
76
+ * Operator-configured harness mode. Defaults to 'train' when absent.
77
+ * Propagated to HarnessContext.mode for each runImpl dispatch.
78
+ */
79
+ harnessMode;
80
+ /** Local SQLite-backed store; used to emit `restoration-result` /
81
+ * `evaluation-verdict` artifact rows when a cycle completes via a
82
+ * deterministic impl (the legacy claude/MCP path writes them itself). */
83
+ store;
84
+ // Transient storage for impl output between runImpl and pack transitions.
85
+ // Keyed by requestId; cleared after successful pack.
86
+ solutionOutputs = new Map();
87
+ // Transient storage for the harness mode used during runImpl.
88
+ // Keyed by requestId; cleared after successful pack.
89
+ modesByRequest = new Map();
90
+ // Transient storage for the codeDigest returned by the freeze-fence.
91
+ // In train mode this is the post-run hash; in frozen mode it's the stable pre-hash.
92
+ // Keyed by requestId; cleared after successful pack.
93
+ codeDigestsByRequest = new Map();
94
+ // Transient storage for trajectory collectors produced in runImpl.
95
+ // emitTrajectory is deferred to pack() so that artifact spans can be added
96
+ // before the trajectory is finalised and uploaded (Task 16 bidirectional linkage).
97
+ // Keyed by requestId; cleared after successful pack.
98
+ // Protected (not private) to allow test subclasses to inject collectors.
99
+ trajectoryCollectors = new Map();
100
+ // Transient storage for trajectory CID+sha256 refs produced by runImpl.
101
+ // Keyed by requestId; cleared after successful pack.
102
+ trajectoryRefs = new Map();
103
+ runtimePluginsByRequest = new Map();
104
+ processingRequestIds = new Set();
105
+ /** Set by stop(); causes runTickLoop to exit at the next iteration. */
106
+ stopped = false;
107
+ stopResolve;
108
+ stopPromise = new Promise((resolve) => {
109
+ this.stopResolve = resolve;
110
+ });
111
+ constructor(opts) {
112
+ this.persistence = new TaskRunPersistence(opts.store.db);
113
+ this.store = opts.store;
114
+ this.paths = opts.paths;
115
+ this.packagingDeps = opts.packagingDeps;
116
+ this.envelopeDeps = opts.envelopeDeps;
117
+ this.deliveryDeps = opts.deliveryDeps;
118
+ this.implRegistry = opts.implRegistry;
119
+ this.solverNetRegistry = opts.solverNetRegistry;
120
+ this.joinedSolverNets = opts.joinedSolverNets;
121
+ this.manifestResolver = opts.manifestResolver;
122
+ this.identityPublisher = opts.identityPublisher;
123
+ this.reputationFeedback = opts.reputationFeedback;
124
+ this.operatorConfig = opts.operatorConfig;
125
+ this.harnessMode = opts.harnessMode ?? 'train';
126
+ }
127
+ // ── Public API ──────────────────────────────────────────────────────────────
128
+ /**
129
+ * Called when an task is observed from an on-chain event.
130
+ * Persists a DISCOVERED row. Idempotent: if the row already exists, no-op.
131
+ */
132
+ async observe(input) {
133
+ const existing = this.persistence.getByRequestId(input.requestId);
134
+ if (!existing) {
135
+ this.persistence.insertDiscovered(input);
136
+ console.log(`[harness-engine] observed task ${input.requestId} solverType=${input.solverType ?? 'null'}`);
137
+ }
138
+ }
139
+ async canAcceptTask(input) {
140
+ const reason = await this.runnableFailureReason(input.solverType, input.taskRole ?? 'restoration', input.task);
141
+ return reason ? { ok: false, reason } : { ok: true };
142
+ }
143
+ /**
144
+ * Recover all in-flight tasks from persisted state.
145
+ * Called at daemon startup before beginning normal event processing.
146
+ * Returns a per-task report for each task attempted.
147
+ */
148
+ async recoverInFlight() {
149
+ const inflight = this.persistence.getInFlight();
150
+ const results = await Promise.allSettled(inflight.map((task) => this._recoverOne(task)));
151
+ const reports = results.map((result, i) => {
152
+ const requestId = inflight[i].requestId;
153
+ if (result.status === 'fulfilled') {
154
+ return { requestId, outcome: 'ok' };
155
+ }
156
+ else {
157
+ const error = result.reason instanceof Error
158
+ ? result.reason.message
159
+ : String(result.reason);
160
+ return { requestId, outcome: 'failed', error };
161
+ }
162
+ });
163
+ const okCount = reports.filter((r) => r.outcome === 'ok').length;
164
+ console.log(`[harness-engine] recovery: ${okCount}/${reports.length} tasks resumed`);
165
+ return reports;
166
+ }
167
+ /**
168
+ * Periodic tick: advance every in-flight task by one transition.
169
+ * Called by `runTickLoop` so that tasks which entered a non-event-driven
170
+ * state (e.g. CLAIMED waiting for windowStartTs) get re-driven without
171
+ * waiting for a daemon restart or a fresh marketplace event.
172
+ *
173
+ * Errors from individual tasks are logged but do not stop the loop.
174
+ */
175
+ async tick(options = {}) {
176
+ const wait = options.wait ?? true;
177
+ const inflight = this.persistence.getInFlight();
178
+ const scheduled = [];
179
+ for (const task of inflight) {
180
+ const processPromise = this.scheduleProcess(task.requestId);
181
+ if (!processPromise)
182
+ continue;
183
+ scheduled.push(processPromise);
184
+ if (!wait) {
185
+ void processPromise.then((report) => this.logProcessReport('tick', report));
186
+ }
187
+ }
188
+ if (!wait)
189
+ return;
190
+ const reports = await Promise.all(scheduled);
191
+ for (const report of reports) {
192
+ this.logProcessReport('tick', report);
193
+ }
194
+ }
195
+ /**
196
+ * Drive `tick()` on a fixed interval until `stop()` is called.
197
+ * Errors thrown by tick() itself are logged and do not stop the loop.
198
+ */
199
+ async runTickLoop(intervalMs) {
200
+ while (!this.stopped) {
201
+ try {
202
+ await this.tick({ wait: false });
203
+ }
204
+ catch (err) {
205
+ console.error('[harness-engine] tick loop error (continuing):', err instanceof Error ? err.message : err);
206
+ }
207
+ if (this.stopped)
208
+ break;
209
+ await Promise.race([
210
+ new Promise((resolve) => setTimeout(resolve, intervalMs)),
211
+ this.stopPromise,
212
+ ]);
213
+ }
214
+ }
215
+ /** Signal `runTickLoop` to exit at the next iteration. */
216
+ stop() {
217
+ this.stopped = true;
218
+ this.stopResolve?.();
219
+ }
220
+ scheduleProcess(requestId) {
221
+ if (this.processingRequestIds.has(requestId)) {
222
+ return null;
223
+ }
224
+ this.processingRequestIds.add(requestId);
225
+ return this.process(requestId)
226
+ .then(() => ({ requestId, outcome: 'ok' }))
227
+ .catch((err) => ({
228
+ requestId,
229
+ outcome: 'failed',
230
+ error: err instanceof Error ? err.message : String(err),
231
+ }))
232
+ .finally(() => {
233
+ this.processingRequestIds.delete(requestId);
234
+ });
235
+ }
236
+ logProcessReport(source, report) {
237
+ if (report.outcome !== 'failed')
238
+ return;
239
+ console.warn(`[harness-engine] ${source}: process(${report.requestId}) failed: ${report.error ?? 'unknown error'}`);
240
+ }
241
+ /**
242
+ * Process a single task: dispatch by current state to the appropriate
243
+ * transition. Drives one state transition per call.
244
+ *
245
+ * Called both by recovery and by the ongoing event-processing loop.
246
+ */
247
+ async process(requestId) {
248
+ const task = this.persistence.getByRequestId(requestId);
249
+ if (!task) {
250
+ throw new Error(`process: task not found: ${requestId}`);
251
+ }
252
+ switch (task.state) {
253
+ case TaskRunState.DISCOVERED:
254
+ await this._runTransition(task, () => this.claim(task));
255
+ break;
256
+ case TaskRunState.CLAIMED: {
257
+ // Advance to WAITING — persist-before-invoke principle.
258
+ const oldState = task.state;
259
+ this.persistence.transition(task.requestId, TaskRunState.WAITING);
260
+ console.log(`[harness-engine] ${requestId} ${oldState} → ${TaskRunState.WAITING}`);
261
+ break;
262
+ }
263
+ case TaskRunState.WAITING: {
264
+ const advance = this.dataDrivenAdvance(task);
265
+ if (advance !== null) {
266
+ this.persistence.transition(task.requestId, advance);
267
+ console.log(`[harness-engine] ${requestId} ${task.state} → ${advance}`);
268
+ await this._runTransition(this.persistence.getOrThrow(requestId), () => this.takePreSnapshot(this.persistence.getOrThrow(requestId)));
269
+ // takePreSnapshot transitions PRE_SNAPSHOT → RUNNING. Re-dispatch on
270
+ // the post-transition state so RUNNING fires in the same pass (jinn-mono-sae).
271
+ const after = this.persistence.getByRequestId(task.requestId);
272
+ if (after && after.state === TaskRunState.RUNNING) {
273
+ await this.process(task.requestId);
274
+ }
275
+ }
276
+ // else: not yet time — caller is responsible for scheduling retry
277
+ break;
278
+ }
279
+ case TaskRunState.PRE_SNAPSHOT: {
280
+ const advance = this.dataDrivenAdvance(task);
281
+ if (advance !== null) {
282
+ // Snapshot already captured (e.g. recovered from crash mid-transition)
283
+ this.persistence.transition(task.requestId, advance);
284
+ console.log(`[harness-engine] ${requestId} ${task.state} → ${advance}`);
285
+ await this._runTransition(this.persistence.getOrThrow(requestId), () => this.runImpl(this.persistence.getOrThrow(requestId)));
286
+ }
287
+ else {
288
+ await this._runTransition(task, () => this.takePreSnapshot(task));
289
+ // takePreSnapshot transitions PRE_SNAPSHOT → RUNNING internally.
290
+ // Re-dispatch on the post-transition state so the RUNNING case fires
291
+ // in the same pass (jinn-mono-sae fix). Without this, tasks stall
292
+ // at RUNNING until the next tick/restart and runImpl never executes.
293
+ const after = this.persistence.getByRequestId(task.requestId);
294
+ if (after && after.state === TaskRunState.RUNNING) {
295
+ await this.process(task.requestId);
296
+ }
297
+ }
298
+ break;
299
+ }
300
+ case TaskRunState.RUNNING:
301
+ await this._runTransition(task, () => this.runImpl(task));
302
+ break;
303
+ case TaskRunState.POST_SNAPSHOT: {
304
+ const advance = this.dataDrivenAdvance(task);
305
+ if (advance !== null) {
306
+ this.persistence.transition(task.requestId, advance);
307
+ console.log(`[harness-engine] ${requestId} ${task.state} → ${advance}`);
308
+ await this._runTransition(this.persistence.getOrThrow(requestId), () => this.pack(this.persistence.getOrThrow(requestId)));
309
+ }
310
+ else {
311
+ await this._runTransition(task, () => this.takePostSnapshot(task));
312
+ }
313
+ break;
314
+ }
315
+ case TaskRunState.PACKAGING:
316
+ await this._runTransition(task, () => this.pack(task));
317
+ break;
318
+ case TaskRunState.DELIVERING:
319
+ await this._runTransition(task, () => this.deliver(task));
320
+ break;
321
+ case TaskRunState.COMPLETE:
322
+ case TaskRunState.FAILED:
323
+ // Terminal — nothing to do.
324
+ break;
325
+ }
326
+ }
327
+ // ── Transition stubs ────────────────────────────────────────────────────────
328
+ // Stubs throw NotImplementedError. claim() is implemented here; others are
329
+ // filled in by subsequent tasks.
330
+ /**
331
+ * TaskCoordinator clean-break claim transition.
332
+ *
333
+ * The on-chain Task claim happens before observe(), producing the internal
334
+ * Mech requestId stored in this row. The engine's CLAIM step now only verifies
335
+ * the operator has an enabled, ready Harness and advances DISCOVERED → CLAIMED.
336
+ */
337
+ async claim(task) {
338
+ const reason = await this.runnableFailureReason(task.solverType ?? undefined, task.taskRole ?? 'restoration', task.task, task.requestId);
339
+ if (reason) {
340
+ this.persistence.markFailed(task.requestId, reason);
341
+ console.log(`[harness-engine] ${task.requestId}: skipping claimed task — ${reason}`);
342
+ throw new Error(reason);
343
+ }
344
+ // The event path and tick loop can race on the same DISCOVERED row; if
345
+ // another caller already advanced it, treat this as idempotent.
346
+ const current = this.persistence.getByRequestId(task.requestId);
347
+ if (!current) {
348
+ throw new Error(`claim: task not found after claim: ${task.requestId}`);
349
+ }
350
+ if (current.state === TaskRunState.DISCOVERED) {
351
+ this.persistence.transition(task.requestId, TaskRunState.CLAIMED);
352
+ }
353
+ else {
354
+ console.log(`[harness-engine] ${task.requestId}: claim completed but state is already ${current.state}; skipping CLAIMED transition`);
355
+ }
356
+ }
357
+ async releaseClaimedNotStarted() {
358
+ // TaskCoordinator claims are made before observe(), so there is no
359
+ // recoverable "claimed but not started" engine row to release here.
360
+ return [];
361
+ }
362
+ /**
363
+ * Internal routing key alias for the daemon-internal `solverType`-keyed
364
+ * harness map. Per spec §15 (non-goal of
365
+ * `spec/2026-05-05-solvernet-creation-and-launch.md`), the harness
366
+ * dispatch alias is intentionally retained for one cycle past Task 30;
367
+ * the user-facing surface (manifest, SPA, SDK shapes) is `solverType`-
368
+ * free. Prefers the canonical `${contractId}.${contractVersion}` when
369
+ * the task carries them, and falls back to the legacy `task.solverType`
370
+ * field for pre-Task-24 shapes / health-check tasks. Mirrors the SDK's
371
+ * internal `solverTypeAlias` helper but operates on a `Task`.
372
+ */
373
+ routingKeyForTask(task, fallback) {
374
+ if (task?.contractId && task?.contractVersion) {
375
+ return `${task.contractId}.${task.contractVersion}`;
376
+ }
377
+ return task?.solverType ?? fallback;
378
+ }
379
+ /**
380
+ * Resolve the task's `solverNetManifestCid` via the registry, fetch the
381
+ * manifest, and validate the task body against `manifest.contract.schemas.task`.
382
+ *
383
+ * Returns `null` when validation passes (or is skipped because no
384
+ * `manifestResolver` is wired and the task carries no `solverNetManifestCid`),
385
+ * or a human-readable failure reason otherwise.
386
+ *
387
+ * Day-1 compatibility note: this validates via the SDK template's Zod schema
388
+ * looked up by `{contract.id, contract.version}`. The manifest's embedded
389
+ * JSON Schema is the canonical wire format; once external launchers can
390
+ * publish manifests with arbitrary task schemas, this will switch to a JSON
391
+ * Schema validator (or `jsonSchemaToZod`) over the manifest's own schema.
392
+ * See `spec/2026-05-05-solvernet-creation-and-launch.md` §14.
393
+ */
394
+ async manifestBackedValidation(task) {
395
+ const cid = task.solverNetManifestCid;
396
+ if (!cid) {
397
+ // Without a manifest CID, schema validation can't run via the §14
398
+ // pipeline. Production callers (mech adapter) require CIDs at task
399
+ // post-time — this branch is hit only by tests / health-check tasks
400
+ // that don't exercise schema validation. The legacy
401
+ // `solverType`-keyed validation path was retired here.
402
+ return null;
403
+ }
404
+ if (!this.manifestResolver) {
405
+ // Engine wasn't constructed with a registry. Tests that don't exercise
406
+ // manifest resolution leave this unwired; treat schema validation as
407
+ // a no-op rather than failing — the daemon's production wiring always
408
+ // supplies a resolver.
409
+ return null;
410
+ }
411
+ let manifest;
412
+ try {
413
+ manifest = await this.manifestResolver.getManifest({ manifestCid: cid });
414
+ }
415
+ catch (err) {
416
+ const message = err instanceof Error ? err.message : String(err);
417
+ return `manifest resolution failed for cid '${cid}': ${message}`;
418
+ }
419
+ const ref = { id: manifest.contract.id, version: manifest.contract.version };
420
+ // Defense against malformed task documents: if the task carries explicit
421
+ // `contractId`/`contractVersion`, they MUST agree with the manifest.
422
+ if (task.contractId !== undefined && task.contractId !== ref.id) {
423
+ return `task.contractId '${task.contractId}' does not match manifest contract.id '${ref.id}'`;
424
+ }
425
+ if (task.contractVersion !== undefined && task.contractVersion !== ref.version) {
426
+ return `task.contractVersion '${task.contractVersion}' does not match manifest contract.version '${ref.version}'`;
427
+ }
428
+ // Day-1 compatibility: validate via the SDK template's Zod for the
429
+ // resolved contract. Day-N (external launchers) will validate against
430
+ // `manifest.contract.schemas.task` directly via JSON Schema.
431
+ const sdkContract = getSolverNetContract(ref);
432
+ if (!sdkContract) {
433
+ return `unsupported contract '${ref.id}.${ref.version}' from manifest '${cid}'`;
434
+ }
435
+ const parsed = sdkContract.schemas.task.zod.safeParse(task);
436
+ if (!parsed.success) {
437
+ const parsedSpec = task.spec !== undefined
438
+ ? sdkContract.schemas.task.zod.safeParse(task.spec)
439
+ : undefined;
440
+ if (parsedSpec?.success)
441
+ return null;
442
+ const specIssuesLookLikeWholeTask = parsedSpec !== undefined &&
443
+ parsedSpec.error.issues.some((issue) => {
444
+ const head = issue.path[0];
445
+ return typeof head === 'string' && ['id', 'description', 'solverType', 'window', 'claimPolicy', 'spec'].includes(head);
446
+ });
447
+ const selected = parsedSpec !== undefined && !specIssuesLookLikeWholeTask ? parsedSpec : parsed;
448
+ const issues = selected.error.issues
449
+ .map((issue) => `${issue.path.length > 0 ? issue.path.join('.') : '<root>'}: ${issue.message}`)
450
+ .join('; ');
451
+ const scope = selected === parsedSpec ? 'task.spec' : 'task';
452
+ return `${ref.id}.${ref.version} ${scope} failed validation: ${issues}`;
453
+ }
454
+ return null;
455
+ }
456
+ /**
457
+ * Returns a human-readable failure reason when the task is NOT eligible
458
+ * for this operator under the manifest-bound per-launch attribution
459
+ * model (spec §14, Task 28), or `null` when the task passes the filter.
460
+ *
461
+ * Eligibility logic:
462
+ * - The operator must have an entry in `joinedSolverNets` whose
463
+ * `manifestCid` matches `task.solverNetManifestCid` (or whose
464
+ * `keccak256(manifestCid)` matches the task's on-chain
465
+ * `manifestDigest` when only the digest is available).
466
+ * - The entry's `roles` must include the role required by this task
467
+ * ('solver' for restoration, 'evaluator' for evaluation).
468
+ *
469
+ * Caller must have already guarded `this.joinedSolverNets` non-null and
470
+ * `task` non-null.
471
+ */
472
+ evaluateJoinedEligibility(task, role) {
473
+ const view = this.joinedSolverNets;
474
+ const requiredRole = joinedRoleForTaskRole(role);
475
+ // Preferred path: the task body carries the manifest CID directly.
476
+ const cid = task.solverNetManifestCid;
477
+ if (cid) {
478
+ const entry = view.get(cid);
479
+ if (!entry) {
480
+ return (`task carries solverNetManifestCid '${cid}' but operator has not joined that SolverNet ` +
481
+ `(joinedSolverNets keys: [${view.manifestCids().join(', ') || '<empty>'}])`);
482
+ }
483
+ if (!entry.roles.includes(requiredRole)) {
484
+ return (`operator joined SolverNet '${cid}' but did not opt into role '${requiredRole}' ` +
485
+ `(roles: [${entry.roles.join(', ')}])`);
486
+ }
487
+ return null;
488
+ }
489
+ // Fallback path: task carries an on-chain `manifestDigest` (bytes32
490
+ // hex) without an off-chain CID. Compute keccak256 of every joined CID
491
+ // and compare. Used when the daemon discovers a task via on-chain
492
+ // event before fetching its IPFS body.
493
+ const taskRecord = task;
494
+ const taskDigest = taskRecord.manifestDigest;
495
+ if (taskDigest) {
496
+ const wantHex = taskDigest.toLowerCase();
497
+ for (const joinedCid of view.manifestCids()) {
498
+ const joinedDigest = keccak256(toBytes(joinedCid)).toLowerCase();
499
+ if (joinedDigest === wantHex) {
500
+ const entry = view.get(joinedCid);
501
+ if (!entry.roles.includes(requiredRole)) {
502
+ return (`operator joined SolverNet '${joinedCid}' but did not opt into role '${requiredRole}' ` +
503
+ `(roles: [${entry.roles.join(', ')}])`);
504
+ }
505
+ return null;
506
+ }
507
+ }
508
+ return (`task manifestDigest '${taskDigest}' does not match any joined SolverNet ` +
509
+ `(joinedSolverNets keys: [${view.manifestCids().join(', ') || '<empty>'}])`);
510
+ }
511
+ // Task has neither solverNetManifestCid nor manifestDigest. Per spec §14,
512
+ // post-Task-24 task documents always carry a CID; absence here means a
513
+ // pre-migration / health-check / legacy task. We don't fail those — the
514
+ // legacy solverType-keyed gate downstream still runs.
515
+ return null;
516
+ }
517
+ async runnableFailureReason(solverType, role, task, currentRequestId) {
518
+ // Per-launch operator-eligibility filter (Task 28 of
519
+ // `spec/2026-05-05-solvernet-creation-and-launch.md` §14). When the
520
+ // operator has explicitly joined a set of SolverNets — keyed by the
521
+ // launched manifest's `manifestCid` — the engine refuses to accept any
522
+ // task whose on-chain `manifestDigest = keccak256(manifestCid)` doesn't
523
+ // match a joined entry, plus a role gate (restoration → 'solver',
524
+ // evaluation → 'evaluator'). This replaces the old protocol-level
525
+ // solverType filter and disambiguates Launcher A's Prediction from
526
+ // Launcher B's Prediction. The check is skipped when the engine has no
527
+ // `joinedSolverNets` view wired (legacy unit tests, in-memory adapter).
528
+ if (this.joinedSolverNets && task) {
529
+ const eligibility = this.evaluateJoinedEligibility(task, role);
530
+ if (eligibility)
531
+ return eligibility;
532
+ }
533
+ // Prefer the contract-derived routing alias when the task carries
534
+ // `contractId`/`contractVersion` (Task 24); fall back to the explicit
535
+ // `solverType` parameter for legacy pre-migration paths and PersistedTaskRun
536
+ // rows that pre-date `contractId`. See `routingKeyForTask`.
537
+ const routingKey = this.routingKeyForTask(task, solverType);
538
+ if (routingKey && this.persistence.hasInFlightFor({
539
+ solverType: routingKey,
540
+ taskRole: role,
541
+ excludeRequestId: currentRequestId,
542
+ })) {
543
+ return `another ${routingKey}/${role} task is already in flight`;
544
+ }
545
+ const solverNet = this.solverNetRegistry && routingKey
546
+ ? this.solverNetRegistry.forSolverType(routingKey, role)
547
+ : undefined;
548
+ if (this.solverNetRegistry && routingKey && !solverNet) {
549
+ return `no enabled SolverNet for solverType '${routingKey}' and role '${role}'; run \`jinn solver-nets enable <name>\``;
550
+ }
551
+ if (task) {
552
+ // Per spec §14 of `spec/2026-05-05-solvernet-creation-and-launch.md`,
553
+ // task validation resolves manifest → contract → schemas:
554
+ // manifest = registry.getManifest({ manifestCid: task.solverNetManifestCid })
555
+ // contract = manifest.contract
556
+ // validateAgainstSchema(task, contract.schemas.task)
557
+ // The legacy `solverType`-keyed `validateTask(solverType, task)` path
558
+ // is retired here; the routing alias is recovered from
559
+ // `manifest.contract.{id, version}` for the harness map lookup
560
+ // (which still keys on the `<id>.<version>` string until Task 30).
561
+ const validationFailure = await this.manifestBackedValidation(task);
562
+ if (validationFailure)
563
+ return validationFailure;
564
+ }
565
+ if (!this.implRegistry || !routingKey)
566
+ return null;
567
+ const impl = this.implRegistry.findFor({ solverType: routingKey, role });
568
+ if (!impl) {
569
+ const setHarnessHint = solverNet
570
+ ? `jinn solver-nets set-harness ${solverNet.name} <harness>`
571
+ : 'jinn solver-nets set-harness <name> <harness>';
572
+ return `no Harness registered or enabled for solverType '${routingKey}'; run \`${setHarnessHint}\``;
573
+ }
574
+ if (task) {
575
+ if (impl.canAttempt) {
576
+ const attempt = await impl.canAttempt(task);
577
+ if (!attempt.ok) {
578
+ return `impl '${impl.name}' cannot attempt task: ${attempt.reason}`;
579
+ }
580
+ }
581
+ }
582
+ if (impl.isReady) {
583
+ const status = await impl.isReady({ solverType: routingKey, role });
584
+ if (!status.ready) {
585
+ return `impl '${impl.name}' not ready: ${status.reason ?? 'unknown'}${status.nextStep?.cli ? ` — run \`${status.nextStep.cli}\`` : ''}`;
586
+ }
587
+ }
588
+ return null;
589
+ }
590
+ /**
591
+ * PRE_SNAPSHOT transition: provision workingDir + implStateDir, write
592
+ * task.json + env/ files, create sessions/ directory.
593
+ *
594
+ * Requires no external deps beyond filesystem access — always implemented.
595
+ * Advances state PRE_SNAPSHOT with workingDir + implStateDir patch.
596
+ */
597
+ async takePreSnapshot(run) {
598
+ const workingDir = join(this.paths.workingDirRoot, run.requestId);
599
+ // Resolve the impl via registry so implStateDir matches the path runImpl uses
600
+ // (join(implStateDirRoot, impl.name, solverType)). Falls back to solverType then 'default'
601
+ // when no impl is registered — legacy path preserved for health-check tasks.
602
+ const resolvedImpl = run.solverType
603
+ ? this.implRegistry?.findFor({ solverType: run.solverType, role: run.taskRole ?? 'restoration' }) ?? null
604
+ : null;
605
+ const implStateName = harnessStateDirName(run.implName ?? resolvedImpl?.name ?? run.solverType ?? 'default');
606
+ const kindSeg = (run.solverType ?? '').replace(/[.:]/g, '_');
607
+ const implStateDir = kindSeg
608
+ ? join(this.paths.implStateDirRoot, implStateName, kindSeg)
609
+ : join(this.paths.implStateDirRoot, implStateName);
610
+ // Prefer the persisted full Task; fall back to a stub for legacy
611
+ // (pre-migration) rows so the engine still works for health-check tasks.
612
+ const task = run.task ?? {
613
+ id: run.requestId,
614
+ description: '',
615
+ ...(run.solverType ? { solverType: run.solverType, spec: {} } : {}),
616
+ role: run.taskRole ?? 'restoration',
617
+ window: { startTs: run.windowStartTs, endTs: run.windowEndTs },
618
+ };
619
+ provisionWorkingDir(workingDir, task);
620
+ provisionImplStateDir(implStateDir);
621
+ // takePreSnapshot transitions directly to RUNNING with the snapshot payload
622
+ // and workingDir/implStateDir paths set. We cannot transition
623
+ // PRE_SNAPSHOT → PRE_SNAPSHOT (invalid); the snapshot is immediately ready
624
+ // (it's just the provisioned dir context), so we advance to RUNNING in one
625
+ // step. The impl is responsible for capturing real market data.
626
+ this.persistence.transition(run.requestId, TaskRunState.RUNNING, {
627
+ workingDir,
628
+ implStateDir,
629
+ preSnapshotCapturedAt: Date.now(),
630
+ preSnapshotPayload: { provisioned: true, workingDir },
631
+ });
632
+ console.log(`[harness-engine] ${run.requestId} PRE_SNAPSHOT -> RUNNING: workingDir=${workingDir}`);
633
+ }
634
+ /**
635
+ * RUNNING transition: dispatch to a Harness if implRegistry is provided.
636
+ *
637
+ * When no impl is found for the solverType, falls back to NotImplementedError
638
+ * so the engine does not silently swallow the request. In tests that don't
639
+ * exercise the impl path, override this method.
640
+ *
641
+ * Captures impl output in `solutionOutputs` map for pack() to consume. Also
642
+ * records a minimal post-snapshot so data-driven advance can fire.
643
+ */
644
+ async runImpl(task) {
645
+ // The persisted `solver_type` column is authoritative for harness
646
+ // dispatch — it was derived at observation time from the canonical
647
+ // `${contractId}.${contractVersion}` alias (see Task 24's TaskCreated
648
+ // path). Internal routing key only — Task 30 retires the legacy
649
+ // string-keyed harness map.
650
+ const solverType = task.solverType ?? '';
651
+ const role = task.taskRole ?? 'restoration';
652
+ const solverNet = solverType ? this.solverNetRegistry?.forSolverType(solverType, role) : undefined;
653
+ const impl = this.implRegistry?.findFor({ solverType, role });
654
+ if (!impl) {
655
+ throw new NotImplementedError('runImpl');
656
+ }
657
+ const runtimePlugins = solverNet?.runtimePlugins ?? [];
658
+ this.runtimePluginsByRequest.set(task.requestId, runtimePlugins);
659
+ const workingDir = task.workingDir ?? join(this.paths.workingDirRoot, task.requestId);
660
+ const kindSeg = solverType.replace(/[.:]/g, '_');
661
+ const implStateDir = task.implStateDir ?? (kindSeg
662
+ ? join(this.paths.implStateDirRoot, harnessStateDirName(impl.name), kindSeg)
663
+ : join(this.paths.implStateDirRoot, harnessStateDirName(impl.name)));
664
+ const windowEndTs = task.windowEndTs;
665
+ const abort = new AbortController();
666
+ const msUntilEndTs = () => Math.max(0, windowEndTs - Date.now());
667
+ const endTimer = setTimeout(() => abort.abort(), msUntilEndTs());
668
+ // Create a trajectory collector for this run.
669
+ const trajectory = new TrajectoryCollector({
670
+ taskCid: task.taskCid ?? '',
671
+ runId: randomUUID(),
672
+ });
673
+ try {
674
+ const ctx = {
675
+ task: (task.task ?? {
676
+ id: task.requestId,
677
+ description: '',
678
+ ...(task.solverType ? { solverType: task.solverType, spec: {} } : {}),
679
+ role,
680
+ window: { startTs: task.windowStartTs, endTs: task.windowEndTs },
681
+ }),
682
+ requestId: task.requestId,
683
+ taskCid: task.taskCid,
684
+ solverNet: solverNet
685
+ ? {
686
+ name: solverNet.name,
687
+ solverType: solverNet.solverType,
688
+ ...(solverNet.model ? { model: solverNet.model } : {}),
689
+ }
690
+ : undefined,
691
+ runtimePlugins,
692
+ solverPluginRoots: runtimePlugins.map((plugin) => plugin.root),
693
+ implStateDir,
694
+ workingDir,
695
+ log: (event) => {
696
+ console.log(`[harness-impl:${impl.name}] [${event.level}] ${event.msg}`, event.data ?? '');
697
+ },
698
+ abort: abort.signal,
699
+ msUntilEndTs,
700
+ trajectory,
701
+ mode: this.harnessMode,
702
+ };
703
+ // Run the harness through the freeze-fence so frozen-mode violations
704
+ // are detected, rolled back, and surfaced as a structured event before
705
+ // envelope assembly (spec §6.3). SkippableError thrown by the harness
706
+ // will bubble out of the fence and be caught below.
707
+ let fence;
708
+ try {
709
+ fence = await runHarnessWithFreezeFence(impl, ctx);
710
+ }
711
+ catch (err) {
712
+ if (err instanceof SkippableError) {
713
+ const skippedAt = Date.now();
714
+ const detail = err.message;
715
+ console.warn(`[harness-engine] ${task.requestId}: impl=${impl.name} skipped (${err.reason}): ${detail}`);
716
+ const skippedOutput = {
717
+ venueRef: { name: 'legacy' },
718
+ gating: {
719
+ skipped: true,
720
+ reason: err.reason,
721
+ skippedAt: String(skippedAt),
722
+ },
723
+ informational: {
724
+ status: 'skipped',
725
+ detail,
726
+ },
727
+ artifacts: [],
728
+ };
729
+ this.solutionOutputs.set(task.requestId, skippedOutput);
730
+ this.modesByRequest.set(task.requestId, ctx.mode);
731
+ // Preserve trajectory for downstream pack() access (Task 6 regression fix).
732
+ this.trajectoryCollectors.set(task.requestId, trajectory);
733
+ // No codeDigest for skipped runs — leave map empty.
734
+ // Fall through to persistence below via goto-equivalent pattern.
735
+ this.persistence.transition(task.requestId, TaskRunState.POST_SNAPSHOT, {
736
+ postSnapshotCapturedAt: Date.now(),
737
+ postSnapshotPayload: { capturedAt: Date.now(), hlTime: 0, payload: null },
738
+ fillsPayload: [],
739
+ gatingClaim: skippedOutput.gating,
740
+ informationalClaim: skippedOutput.informational ?? null,
741
+ solutionOutputsJson: JSON.stringify(skippedOutput),
742
+ implName: impl.name,
743
+ runtimePluginsJson: JSON.stringify(runtimePlugins),
744
+ });
745
+ console.log(`[harness-engine] ${task.requestId} RUNNING → POST_SNAPSHOT via impl=${impl.name} (skipped)`);
746
+ return;
747
+ }
748
+ throw err;
749
+ }
750
+ if (!fence.ok) {
751
+ // Violation: the harness mutated implStateDir in frozen mode.
752
+ // Snapshot already restored by the fence. Emit a structured log,
753
+ // skip envelope assembly, and mark the task FAILED.
754
+ ctx.log({
755
+ level: 'error',
756
+ msg: 'Harness violated frozen-mode contract — envelope rejected',
757
+ data: fence.violation,
758
+ });
759
+ this.persistence.markFailed(task.requestId, `freeze-fence violation: implStateDir mutated in frozen mode (harness=${fence.violation.harnessName}@${fence.violation.harnessVersion})`);
760
+ return;
761
+ }
762
+ // Store the codeDigest from the fence (post-run hash in train mode;
763
+ // stable pre-hash in frozen mode) for use in pack().
764
+ this.codeDigestsByRequest.set(task.requestId, `sha256:${fence.codeDigest}`);
765
+ this.modesByRequest.set(task.requestId, ctx.mode);
766
+ const output = fence.output;
767
+ this.solutionOutputs.set(task.requestId, output);
768
+ // Store the trajectory collector so pack() can:
769
+ // 1. pass it to uploadArtifacts (artifact.emit spans + producedBy metadata)
770
+ // 2. call emitTrajectory AFTER artifact upload so spans are included
771
+ // 3. backfill trajectoryCid on artifacts before envelope assembly
772
+ // emitTrajectory is intentionally deferred to pack() (Task 16).
773
+ this.trajectoryCollectors.set(task.requestId, trajectory);
774
+ // Persist impl output BEFORE the state transition so that a crash after
775
+ // the transition (RUNNING → POST_SNAPSHOT) but before pack() runs will
776
+ // find the serialised output in the DB on restart. pack() will hydrate the
777
+ // in-memory map from solutionOutputsJson if the map entry is absent (#6).
778
+ // Capture post-snapshot from impl output so data-driven advance fires
779
+ this.persistence.transition(task.requestId, TaskRunState.POST_SNAPSHOT, {
780
+ postSnapshotCapturedAt: Date.now(),
781
+ postSnapshotPayload: output.postSnapshot ?? { capturedAt: Date.now(), hlTime: 0, payload: null },
782
+ fillsPayload: output.fills ?? [],
783
+ gatingClaim: output.gating,
784
+ informationalClaim: output.informational ?? null,
785
+ solutionOutputsJson: JSON.stringify(output),
786
+ implName: impl.name,
787
+ runtimePluginsJson: JSON.stringify(runtimePlugins),
788
+ });
789
+ }
790
+ finally {
791
+ clearTimeout(endTimer);
792
+ }
793
+ console.log(`[harness-engine] ${task.requestId} RUNNING → POST_SNAPSHOT via impl=${impl.name}`);
794
+ }
795
+ async takePostSnapshot(_intent) {
796
+ throw new NotImplementedError('takePostSnapshot');
797
+ }
798
+ /**
799
+ * PACKAGING transition: walk workingDir, upload artifacts, assemble + sign
800
+ * envelope, upload envelope, persist envelope CID + artifact CIDs.
801
+ *
802
+ * Requires packagingDeps + envelopeDeps. When absent, falls back to
803
+ * NotImplementedError.
804
+ */
805
+ async pack(task) {
806
+ // Hydrate implOutput from DB if the in-memory map was lost (e.g. process restart
807
+ // after RUNNING → POST_SNAPSHOT but before pack() completed). This must run
808
+ // BEFORE the packagingDeps guard so subclass overrides that call super.pack()
809
+ // can still benefit from hydration even when packagingDeps is absent (#6).
810
+ if (!this.solutionOutputs.has(task.requestId) && task.solutionOutputsJson != null) {
811
+ try {
812
+ const recovered = JSON.parse(task.solutionOutputsJson);
813
+ this.solutionOutputs.set(task.requestId, recovered);
814
+ console.log(`[harness-engine] ${task.requestId}: hydrated solutionOutputs from DB (crash recovery)`);
815
+ }
816
+ catch (err) {
817
+ console.warn(`[harness-engine] ${task.requestId}: failed to hydrate solutionOutputsJson: ${err instanceof Error ? err.message : err}`);
818
+ }
819
+ }
820
+ if (!this.packagingDeps || !this.envelopeDeps) {
821
+ throw new NotImplementedError('pack');
822
+ }
823
+ const workingDir = task.workingDir ?? join(this.paths.workingDirRoot, task.requestId);
824
+ const implOutput = this.solutionOutputs.get(task.requestId);
825
+ const implArtifacts = implOutput?.artifacts ?? [];
826
+ // 1. Walk + upload artifacts (NO registration yet — manifest CID not known).
827
+ // Pass the trajectory collector (if present) so uploadArtifacts can emit
828
+ // jinn.artifact.emit spans and attach producedBy back-refs (Task 16 forward
829
+ // linkage). emitTrajectory is called AFTER upload so artifact spans are included.
830
+ const collector = this.trajectoryCollectors.get(task.requestId);
831
+ const packagingDepsWithReq = {
832
+ ...this.packagingDeps,
833
+ requestId: task.requestId,
834
+ ...(collector ? { collector } : {}),
835
+ };
836
+ const rawArtifacts = await walkArtifacts(workingDir, implArtifacts, packagingDepsWithReq.donation?.enabled
837
+ ? { scrub: packagingDepsWithReq.donation.scrub }
838
+ : {});
839
+ const uploadedArtifacts = await uploadArtifacts(rawArtifacts, packagingDepsWithReq);
840
+ // 1b. Emit trajectory to IPFS now that all artifact spans have been added.
841
+ // Non-fatal — envelope assembly continues with envelope.trajectory = null if upload fails.
842
+ let trajectoryRef = this.trajectoryRefs.get(task.requestId) ?? null;
843
+ if (!trajectoryRef && collector && this.envelopeDeps) {
844
+ try {
845
+ const { privateKeyToAccount } = await import('viem/accounts');
846
+ const account = privateKeyToAccount(this.envelopeDeps.agentEoaPrivateKey);
847
+ const { cid, sha256, signed } = await emitTrajectory({
848
+ collector,
849
+ runId: collector.runId,
850
+ signerPrivateKey: this.envelopeDeps.agentEoaPrivateKey,
851
+ signerAddress: account.address,
852
+ ipfsRegistryUrl: this.envelopeDeps.ipfsRegistryUrl,
853
+ scrub: packagingDepsWithReq.donation?.scrub,
854
+ });
855
+ const sources = [];
856
+ if (packagingDepsWithReq.donation?.enabled) {
857
+ const sourceCid = await uploadToIpfs(packagingDepsWithReq.donation.ipfsRegistryUrl, {
858
+ schemaVersion: DONATION_ARTIFACT_ENCODING,
859
+ artifactType: 'jinn.trajectory.v1',
860
+ sha256,
861
+ encoding: DONATION_ARTIFACT_ENCODING,
862
+ data: Buffer.from(JSON.stringify(signed), 'utf8').toString('base64'),
863
+ });
864
+ sources.push({
865
+ kind: 'ipfs',
866
+ cid: sourceCid,
867
+ sha256,
868
+ encoding: DONATION_ARTIFACT_ENCODING,
869
+ });
870
+ }
871
+ trajectoryRef = { cid, sha256, ...(sources.length > 0 ? { sources } : {}) };
872
+ console.log(`[harness-engine] ${task.requestId}: trajectory emitted cid=${cid}`);
873
+ }
874
+ catch (err) {
875
+ console.warn(`[harness-engine] ${task.requestId}: trajectory emit failed (non-fatal):`, err instanceof Error ? err.message : err);
876
+ }
877
+ }
878
+ this.trajectoryRefs.set(task.requestId, trajectoryRef);
879
+ // 1c. Backward linkage: backfill trajectoryCid on all artifacts that have a
880
+ // producedBy back-ref. This must happen BEFORE assembleAndSignEnvelope so the
881
+ // signed envelope carries the complete reference (Task 16).
882
+ if (trajectoryRef) {
883
+ const trajectoryCid = trajectoryRef.cid;
884
+ for (const art of uploadedArtifacts) {
885
+ const pb = art.metadata?.['producedBy'];
886
+ if (pb != null && typeof pb === 'object' && 'spanId' in pb) {
887
+ pb['trajectoryCid'] = trajectoryCid;
888
+ }
889
+ }
890
+ }
891
+ // Map to Artifact shape (strip localPath)
892
+ const artifacts = uploadedArtifacts.map(({ localPath: _localPath, ...art }) => art);
893
+ // 2. Derive agentEoa from private key
894
+ const { privateKeyToAccount } = await import('viem/accounts');
895
+ const account = privateKeyToAccount(this.envelopeDeps.agentEoaPrivateKey);
896
+ const agentEoa = account.address;
897
+ // Safe multisig address — sourced from envelopeDeps (preferred) or deliveryDeps.
898
+ // Hard throw if absent: falling back to agentEoa would produce a
899
+ // protocol-invalid envelope (safeAddress MUST differ from agentEoa, §5.1).
900
+ const safeAddress = this.envelopeDeps.safeAddress ?? this.deliveryDeps?.safeAddress;
901
+ if (!safeAddress) {
902
+ throw new Error('pack: safeAddress not configured in envelopeDeps or deliveryDeps');
903
+ }
904
+ // 3. Build envelope payload from impl output (kind-typed, wrapped into payload field)
905
+ const preSnapshotPayload = task.preSnapshotPayload;
906
+ const postSnapshotPayload = task.postSnapshotPayload;
907
+ // The solverType drives payload schema selection. Fall back to 'legacy.v0'
908
+ // for tasks without a solverType (legacy health-check / daemon-loop-test
909
+ // tasks that use the legacy-claude impl). The legacy.v0 kind accepts any
910
+ // Record payload so validatePayload does not reject the output.
911
+ const solverType = task.solverType ?? 'legacy.v0';
912
+ // Derive role from Task.role. Evaluator tasks produce 'verdict' envelopes;
913
+ // all other tasks produce 'restoration' envelopes.
914
+ const isEvaluation = task.taskRole === 'evaluation';
915
+ const role = isEvaluation ? 'verdict' : 'restoration';
916
+ let envelopePayload;
917
+ if (isEvaluation) {
918
+ // ── Verdict envelope payload ──────────────────────────────────────────────
919
+ // The evaluator impl populates verdictPayload on Solution with a
920
+ // PortfolioV0VerdictPayload-shaped object. Engine passes it through to the
921
+ // envelope assembler, which runs validatePayload('portfolio.v0', 'verdict', ...).
922
+ //
923
+ // If verdictPayload is absent (impl bug / crash recovery), fall back to a
924
+ // minimal INDETERMINATE stub so the envelope assembly does not silently succeed
925
+ // with a wrong shape — validatePayload will catch schema mismatches.
926
+ //
927
+ // verificationOfRestoration: stubbed — Plan D will connect the real SDK.
928
+ // restorationEnvelope.sha256: placeholder — Plan D wires real sha256 derivation.
929
+ const verdictPayload = implOutput?.verdictPayload;
930
+ if (!verdictPayload) {
931
+ throw new Error(`pack: evaluator impl for ${task.requestId} did not produce verdictPayload on Solution; ` +
932
+ `ensure the impl populates output.verdictPayload`);
933
+ }
934
+ // If the (stub) verificationOfRestoration reports 'invalid', downgrade verdict
935
+ // to REJECTED per scope §3.3. For V1 the stub always returns 'valid', so this
936
+ // path does not fire in practice — Plan D makes it real.
937
+ const verif = verdictPayload['verificationOfRestoration'];
938
+ if (verif?.overall === 'invalid') {
939
+ // Override verdict to REJECTED; preserve the rest of the payload.
940
+ envelopePayload = {
941
+ ...verdictPayload,
942
+ verdict: 'REJECTED',
943
+ };
944
+ }
945
+ else {
946
+ envelopePayload = verdictPayload;
947
+ }
948
+ }
949
+ else if (implOutput?.solutionPayload) {
950
+ // ── Non-portfolio restoration envelope payload ────────────────────────────
951
+ // Impls for kinds with a non-portfolio payload schema (e.g. prediction.v1)
952
+ // declare their own fully-formed payload. Engine passes it through directly
953
+ // so validatePayload() can check it against the per-kind schema.
954
+ envelopePayload = implOutput.solutionPayload;
955
+ }
956
+ else {
957
+ // ── Portfolio restoration envelope payload (legacy / portfolio.v0) ─────────
958
+ envelopePayload = {
959
+ preSnapshot: {
960
+ capturedAt: task.preSnapshotCapturedAt ?? Date.now(),
961
+ hlTime: preSnapshotPayload?.hlTime ?? 0,
962
+ // Double-fallback: first tries the structured .payload field (normal shape),
963
+ // then falls back to the whole payload object (handles takePreSnapshot's
964
+ // synthetic shape where the snapshot IS the top-level object, not nested).
965
+ payload: preSnapshotPayload?.payload ?? preSnapshotPayload ?? {},
966
+ },
967
+ postSnapshot: {
968
+ capturedAt: task.postSnapshotCapturedAt ?? Date.now(),
969
+ hlTime: postSnapshotPayload?.hlTime ?? 0,
970
+ // Same double-fallback as above.
971
+ payload: postSnapshotPayload?.payload ?? postSnapshotPayload ?? {},
972
+ },
973
+ fills: task.fillsPayload ?? [],
974
+ gating: task.gatingClaim ?? {},
975
+ ...(task.informationalClaim != null
976
+ ? { informational: task.informationalClaim }
977
+ : {}),
978
+ ...(implOutput?.rationale != null ? { rationale: implOutput.rationale } : {}),
979
+ };
980
+ }
981
+ // 4. Persist generatedAt once (first pack); reuse on retry for CID determinism.
982
+ const generatedAt = task.manifestGeneratedAt ?? Date.now();
983
+ if (!task.manifestGeneratedAt) {
984
+ // Persist before assembling so that a crash after assembly but before
985
+ // transition still gets the same generatedAt on the next attempt.
986
+ this.persistence.setManifestGeneratedAt(task.requestId, generatedAt);
987
+ }
988
+ // 5. Assemble + sign envelope → envelope CID now known.
989
+ // trajectoryRef was computed in step 1b above (emitted after artifact upload).
990
+ // Per the post-gating-fix schema, trajectory references carry sha256 + access
991
+ // (the operator HTTP endpoint that serves the bytes). Phase 3 (jinn-mono-vy37.1.3)
992
+ // sources this from the engine's operatorConfig; absent operatorConfig (e.g. test
993
+ // fixtures) falls back to packagingDeps.operatorEndpoint, then to a localhost
994
+ // sentinel so suites that don't exercise the publish path still pack cleanly.
995
+ const operatorEndpointForTraj = this.operatorConfig?.publicEndpoint
996
+ ?? this.packagingDeps?.operatorEndpoint
997
+ ?? 'http://localhost:7331';
998
+ const envelopeTrajectory = trajectoryRef
999
+ ? {
1000
+ sha256: trajectoryRef.sha256,
1001
+ access: { endpoint: operatorEndpointForTraj, priceUsdc: '0' },
1002
+ ...(trajectoryRef.sources && trajectoryRef.sources.length > 0
1003
+ ? { sources: trajectoryRef.sources }
1004
+ : {}),
1005
+ }
1006
+ : null;
1007
+ // evidenceTier reflects the on-chain commitment state at the time of signing.
1008
+ // For the V2 claim flow, claimDelivery will write an evidenceHash on-chain,
1009
+ // so the envelope should be declared 'committed'. For V1 or unknown flows,
1010
+ // 'self-signed' is accurate (no on-chain hash commitment).
1011
+ const evidenceTier = this.deliveryDeps?.claimDeliveryVariant === 'v2' || this.deliveryDeps?.claimDeliveryVariant === 'v3'
1012
+ ? 'committed'
1013
+ : 'self-signed';
1014
+ const runtimePlugins = this.runtimePluginsByRequest.get(task.requestId)
1015
+ ?? (task.runtimePluginsJson ? JSON.parse(task.runtimePluginsJson) : []);
1016
+ const executorPlugins = runtimePlugins
1017
+ .map((plugin) => ({
1018
+ name: plugin.name,
1019
+ version: plugin.version,
1020
+ ...(plugin.cid ? { cid: plugin.cid } : {}),
1021
+ sha256: plugin.sha256,
1022
+ }))
1023
+ .sort((a, b) => `${a.name}@${a.version}`.localeCompare(`${b.name}@${b.version}`));
1024
+ const implNameForEnvelope = task.implName ?? solverType;
1025
+ const solverNet = solverType
1026
+ ? this.solverNetRegistry?.forSolverType(solverType, task.taskRole ?? 'restoration')
1027
+ : undefined;
1028
+ const runtimeBundleDigest = `sha256:${createHash('sha256')
1029
+ .update(JSON.stringify({
1030
+ harness: {
1031
+ name: implNameForEnvelope,
1032
+ version: buildInfo.implVersion,
1033
+ codeDigest: buildInfo.codeDigest,
1034
+ },
1035
+ solverNet: solverNet ? { name: solverNet.name, solverType: solverNet.solverType } : null,
1036
+ plugins: executorPlugins,
1037
+ }))
1038
+ .digest('hex')}`;
1039
+ // Resolve the mode and codeDigest from the in-memory maps populated by
1040
+ // runImpl. Defaults: mode = 'train' (backward compat), codeDigest from
1041
+ // buildInfo (fallback when runImpl did not run through the fence, e.g.
1042
+ // crash-recovery from solutionOutputsJson without a fresh runImpl).
1043
+ const executorMode = this.modesByRequest.get(task.requestId) ?? 'train';
1044
+ const fenceCodeDigest = this.codeDigestsByRequest.get(task.requestId) ?? buildInfo.codeDigest;
1045
+ const envelopeInputs = {
1046
+ solverType,
1047
+ role,
1048
+ task: {
1049
+ cid: task.taskCid,
1050
+ onchainCreationTx: task.onchainCreationTx,
1051
+ onchainCreationBlock: task.onchainCreationBlock,
1052
+ requestId: task.requestId,
1053
+ },
1054
+ participant: { safeAddress, agentEoa },
1055
+ window: { startTs: task.windowStartTs, endTs: task.windowEndTs },
1056
+ executor: {
1057
+ implName: implNameForEnvelope,
1058
+ // buildInfo resolves to real values in production builds; falls back to
1059
+ // clearly-labelled placeholders ('dev' / 'sha256:dev-build') when running
1060
+ // via tsx without a prior `yarn build` (dev mode).
1061
+ implVersion: buildInfo.implVersion,
1062
+ clientGitSha: buildInfo.clientGitSha,
1063
+ codeDigest: fenceCodeDigest,
1064
+ runtimeBundleDigest,
1065
+ plugins: executorPlugins,
1066
+ signingKey: { kind: 'agent-eoa', pubkey: agentEoa },
1067
+ // Propagate the harness execution mode (train | frozen) so the
1068
+ // envelope records whether implStateDir was locked during this run.
1069
+ mode: executorMode,
1070
+ },
1071
+ evidenceTier,
1072
+ trajectory: envelopeTrajectory,
1073
+ artifacts,
1074
+ payload: envelopePayload,
1075
+ generatedAt,
1076
+ };
1077
+ const { envelopeCid, envelopeHash } = await assembleAndSignEnvelope(envelopeInputs, this.envelopeDeps);
1078
+ const manifestCid = envelopeCid;
1079
+ const signatureHash = envelopeHash;
1080
+ // 6. ERC-8004 IdentityRegistry per-execution `setMetadata` fires in
1081
+ // deliver() AFTER claimDelivery succeeds. 'committed' must mean
1082
+ // "observable on-chain evidenceHash exists" — publishing before claim
1083
+ // would lie during failures. The evidenceHash (signatureHash) is
1084
+ // persisted to DELIVERING state below and reused by deliver().
1085
+ // Operator-rooted entity model: docs/superpowers/specs/2026-04-27-erc-8004-entity-model-design.md.
1086
+ // 7. Build artifact sha256 map for persistence.
1087
+ // Post-gating-fix (spec §1): artifacts no longer have IPFS CIDs — bytes
1088
+ // live in served_artifacts keyed by sha256. We reuse the legacy
1089
+ // `artifactCids` persistence column (key: localPath) but populate it with
1090
+ // sha256 hashes so downstream readers still get a stable identifier.
1091
+ const artifactCids = {};
1092
+ for (const art of uploadedArtifacts) {
1093
+ artifactCids[art.localPath] = art.sha256;
1094
+ }
1095
+ // Backfill envelope_cid (manifestCid) on every served_artifacts row so
1096
+ // the operator can answer manifest-rooted lookups later. Done after the
1097
+ // manifest CID is known.
1098
+ for (const art of uploadedArtifacts) {
1099
+ this.store.setServedArtifactEnvelopeCid(art.sha256, manifestCid);
1100
+ }
1101
+ // 8. Persist DELIVERING with manifest CID + artifact CIDs + evidence hash.
1102
+ // evidenceHash gets its own dedicated column (not stashed in informationalClaim).
1103
+ // executorMode + executorCodeDigest are also persisted so deliver() can
1104
+ // emit a payload v2 setMetadata after the transient maps are cleared.
1105
+ // See `client/src/erc8004/identity.ts` (publishContentV2) and the
1106
+ // payload-v2 ABI tuple in `abis.ts`.
1107
+ this.persistence.transition(task.requestId, TaskRunState.DELIVERING, {
1108
+ manifestCid,
1109
+ artifactCids,
1110
+ evidenceHash: signatureHash,
1111
+ executorMode,
1112
+ executorCodeDigest: fenceCodeDigest,
1113
+ });
1114
+ console.log(`[harness-engine] ${task.requestId} PACKAGING → DELIVERING manifestCid=${manifestCid}`);
1115
+ // Clean up transient state (no longer needed after DELIVERING)
1116
+ this.solutionOutputs.delete(task.requestId);
1117
+ this.trajectoryCollectors.delete(task.requestId);
1118
+ this.trajectoryRefs.delete(task.requestId);
1119
+ this.modesByRequest.delete(task.requestId);
1120
+ this.codeDigestsByRequest.delete(task.requestId);
1121
+ }
1122
+ /**
1123
+ * DELIVERING transition: call mech.deliverToMarketplace + JinnRouter.claimDelivery.
1124
+ *
1125
+ * Requires deliveryDeps. When absent, falls back to NotImplementedError.
1126
+ *
1127
+ * Crash-recovery safe: if `task.deliveryTxHash` is already set (persisted
1128
+ * after a previous deliverToMarketplace call that completed before the process
1129
+ * crashed), we skip the deliver step and go straight to claimDelivery.
1130
+ */
1131
+ async deliver(task) {
1132
+ if (!this.deliveryDeps) {
1133
+ throw new NotImplementedError('deliver');
1134
+ }
1135
+ const manifestCid = task.manifestCid;
1136
+ if (!manifestCid) {
1137
+ throw new Error(`deliver: manifestCid missing for ${task.requestId}`);
1138
+ }
1139
+ // Guard: v2 claimDelivery requires an evidenceHash — a zero fallback would
1140
+ // silently brick staking rewards, so we fail loudly instead.
1141
+ const evidenceHash = task.evidenceHash;
1142
+ if (!evidenceHash && (this.deliveryDeps.claimDeliveryVariant === 'v2' || this.deliveryDeps.claimDeliveryVariant === 'v3')) {
1143
+ throw new MissingEvidenceHashError(task.requestId);
1144
+ }
1145
+ // Capture locals for use in the onDeliveryTxLanded closure.
1146
+ const requestId = task.requestId;
1147
+ const persistence = this.persistence;
1148
+ const { deliveryTxHash, claimTxHash } = await deliverAndClaim(requestId, manifestCid, evidenceHash, this.deliveryDeps,
1149
+ // Recovery: pass existing deliveryTxHash so deliverToMarketplace is skipped.
1150
+ task.deliveryTxHash ?? undefined,
1151
+ // Persist deliveryTxHash before claimDelivery so recovery can resume from here.
1152
+ async (txHash) => {
1153
+ persistence.setDeliveryTxHash(requestId, txHash);
1154
+ }, {
1155
+ kind: task.taskRole === 'evaluation' ? 'verdict' : 'solution',
1156
+ verdictCode: task.taskRole === 'evaluation' ? this.verdictCodeForTask(task) : undefined,
1157
+ });
1158
+ this.persistence.transition(requestId, TaskRunState.COMPLETE, {
1159
+ deliveryTxHash,
1160
+ });
1161
+ console.log(`[harness-engine] ${requestId} DELIVERING → COMPLETE deliveryTx=${deliveryTxHash} claimTx=${claimTxHash}`);
1162
+ // Emit a SQLite artifact row so consumers (release acceptance gate, search
1163
+ // API) see this cycle alongside legacy-claude / MCP-emitted rows. The
1164
+ // legacy claude path writes via the MCP `submit_restoration_result` tool;
1165
+ // deterministic impls (prediction.v1 baseline/evaluator,
1166
+ // …) don't go through MCP, so the engine emits on their behalf here.
1167
+ // Idempotent: skips when a row for this requestId+tag already exists
1168
+ // (legacy path may have already inserted).
1169
+ this.emitCycleArtifact(task, manifestCid, evidenceHash);
1170
+ // ── ERC-8004 setMetadata — fires AFTER claimDelivery succeeds ────────────
1171
+ //
1172
+ // Moved here from pack() per PR#37 review2 must-fix #2. 'committed' means
1173
+ // "observable on-chain evidenceHash exists" — publishing before claim would
1174
+ // lie during failures. evidenceHash comes from task (persisted in
1175
+ // DELIVERING state by pack()); idempotent on retry (setMetadata is a pure
1176
+ // key-value write; re-running with the same payload is safe).
1177
+ //
1178
+ // Restoration-only for now. Evaluator setMetadata lands with jinn-mono-2ff.
1179
+ if (this.identityPublisher) {
1180
+ const taskRoleRaw = task.taskRole ?? 'restoration';
1181
+ if (taskRoleRaw === 'restoration') {
1182
+ const signatureHash = evidenceHash;
1183
+ // v0 tier rule: with an evidenceHash on chain we declare `committed` (tier=1);
1184
+ // higher tiers (`attested`, `proved`) come later when TEE work lands.
1185
+ const tier = signatureHash ? 1 : 0;
1186
+ const manifestHashHex = signatureHash ?? '0x';
1187
+ // Prefer v2 when the harness identity is available — the engine
1188
+ // captures executorMode + executorCodeDigest in pack(). For legacy
1189
+ // rows that completed before payload v2 wiring (or for solver paths
1190
+ // that don't produce a fence digest), executorCodeDigest is null and
1191
+ // we fall back to the v1 encoder so the indexer still sees envelope
1192
+ // metadata, just without harness identity. v1 envelopes are decoded
1193
+ // by the subgraph as mode='train' with empty codeDigest/implName.
1194
+ const harnessImplName = task.implName;
1195
+ const canEmitV2 = !!task.executorMode &&
1196
+ !!task.executorCodeDigest &&
1197
+ !!harnessImplName;
1198
+ try {
1199
+ let pubTxHash;
1200
+ if (canEmitV2) {
1201
+ const v2Payload = {
1202
+ version: 2,
1203
+ tier,
1204
+ manifestHash: manifestHashHex,
1205
+ attestationQuoteCid: '0x',
1206
+ sourceMeasurement: '0x0000000000000000000000000000000000000000000000000000000000000000',
1207
+ codeDigest: codeDigestSha256ToBytes32(task.executorCodeDigest),
1208
+ implName: harnessImplName,
1209
+ modeFlag: modeStringToFlag(task.executorMode),
1210
+ };
1211
+ pubTxHash = await this.identityPublisher.publishContentV2({
1212
+ kind: 'envelope',
1213
+ cid: manifestCid,
1214
+ payload: v2Payload,
1215
+ });
1216
+ console.log(`[harness-engine] ${requestId}: setMetadata envelope:${manifestCid} tx=${pubTxHash} (payload v2 mode=${task.executorMode} impl=${harnessImplName})`);
1217
+ }
1218
+ else {
1219
+ const v1Payload = {
1220
+ version: 1,
1221
+ tier,
1222
+ manifestHash: manifestHashHex,
1223
+ attestationQuoteCid: '0x',
1224
+ sourceMeasurement: '0x0000000000000000000000000000000000000000000000000000000000000000',
1225
+ };
1226
+ pubTxHash = await this.identityPublisher.publishContent({
1227
+ kind: 'envelope',
1228
+ cid: manifestCid,
1229
+ payload: v1Payload,
1230
+ });
1231
+ console.log(`[harness-engine] ${requestId}: setMetadata envelope:${manifestCid} tx=${pubTxHash} (payload v1)`);
1232
+ }
1233
+ }
1234
+ catch (err) {
1235
+ console.warn(`[harness-engine] ${requestId}: setMetadata envelope publish failed (non-fatal): ${err instanceof Error ? err.message : err}`);
1236
+ }
1237
+ }
1238
+ }
1239
+ // ── Reputation feedback hook (jinn-mono-yg4) ─────────────────────────────
1240
+ //
1241
+ // Evaluator-only path: after `claimDelivery` settles the verdict, fire
1242
+ // `ReputationRegistry.giveFeedback(harnessAgentId, ...)` so the
1243
+ // harness's agent NFT accrues a rating (DR §4.3).
1244
+ //
1245
+ // Best-effort: any failure inside the hook is logged but does not
1246
+ // change the COMPLETE state. claimDelivery is already authoritative.
1247
+ if (task.taskRole === 'evaluation' && this.reputationFeedback) {
1248
+ await this._maybePostEvaluatorFeedback(task).catch((err) => {
1249
+ console.warn(`[harness-engine] ${requestId}: reputation feedback hook errored unexpectedly (non-fatal): ${err instanceof Error ? err.message : err}`);
1250
+ });
1251
+ }
1252
+ }
1253
+ /**
1254
+ * Post evaluator feedback on the harness's agent NFT.
1255
+ *
1256
+ * Pulls the verdict from the persisted gating claim (the evaluator impl
1257
+ * writes `{ verdict, score, scoreBasis, ... }` into `output.gating`),
1258
+ * resolves the harness's `agentId` via the configured subgraph
1259
+ * resolver, and submits a single `ReputationRegistry.giveFeedback` tx.
1260
+ *
1261
+ * Skipped silently when:
1262
+ * - No `reputationFeedback` deps wired.
1263
+ * - `gatingClaim` doesn't carry a verdict (impl shape mismatch — log and
1264
+ * return).
1265
+ * - The parent harness's manifest hash isn't reachable from the
1266
+ * persisted state — log and return).
1267
+ * - `resolveAgentId` returns null (subgraph not indexed yet, or no
1268
+ * subgraph URL configured at all — log and return).
1269
+ *
1270
+ * The mapping policy (PASS / FAIL / REJECTED / INDETERMINATE → score) lives
1271
+ * inside `submitEvaluatorFeedback` / `mapVerdictToScore` in the
1272
+ * feedback-hook module; we just hand it the verdict.
1273
+ */
1274
+ /**
1275
+ * Insert a SQLite `artifacts` row for a successfully delivered cycle so the
1276
+ * release acceptance gate (and the search API) can observe completion via
1277
+ * the same surface as the legacy claude / MCP path.
1278
+ *
1279
+ * The legacy `legacy-claude` impl writes via the MCP `submit_restoration_result`
1280
+ * tool when Claude reports success; deterministic impls don't go through MCP.
1281
+ * This emitter closes that gap by writing the row from the engine when the
1282
+ * cycle hits COMPLETE.
1283
+ *
1284
+ * Idempotent: if a row already exists for (requestId, tag) — e.g. the legacy
1285
+ * MCP path got there first — we leave it alone.
1286
+ */
1287
+ emitCycleArtifact(task, manifestCid, evidenceHash) {
1288
+ const taskId = task.task?.id;
1289
+ if (!taskId) {
1290
+ // Rows without task payload cannot be attributed to a Task id. Skip
1291
+ // rather than synthesise provenance.
1292
+ return;
1293
+ }
1294
+ const taskRole = task.taskRole ?? 'restoration';
1295
+ const tag = taskRole === 'evaluation' ? 'evaluation-verdict' : 'restoration-result';
1296
+ const existing = this.store.getArtifactByRequestId(task.requestId, tag);
1297
+ if (existing)
1298
+ return;
1299
+ this.store.insertArtifact({
1300
+ id: randomUUID(),
1301
+ taskId,
1302
+ requestId: task.requestId,
1303
+ title: `${tag}: ${task.solverType ?? 'cycle'} (${task.implName ?? 'engine'})`,
1304
+ content: JSON.stringify({
1305
+ manifestCid,
1306
+ evidenceHash: evidenceHash ?? null,
1307
+ implName: task.implName,
1308
+ }),
1309
+ tags: [tag, 'success'],
1310
+ outcome: 'SUCCESS',
1311
+ });
1312
+ }
1313
+ verdictCodeForTask(task) {
1314
+ const gating = task.gatingClaim;
1315
+ const raw = gating?.verdict;
1316
+ switch (raw) {
1317
+ case 'PASS':
1318
+ case 'SCORED':
1319
+ return 1;
1320
+ case 'FAIL':
1321
+ case 'REJECTED':
1322
+ return 2;
1323
+ case 'INVALID':
1324
+ return 3;
1325
+ case 'INDETERMINATE':
1326
+ case 'UNRESOLVED':
1327
+ return 4;
1328
+ default:
1329
+ return 1;
1330
+ }
1331
+ }
1332
+ async _maybePostEvaluatorFeedback(task) {
1333
+ if (!this.reputationFeedback)
1334
+ return;
1335
+ const gating = task.gatingClaim;
1336
+ const verdictRaw = gating?.['verdict'];
1337
+ if (verdictRaw !== 'PASS' &&
1338
+ verdictRaw !== 'FAIL' &&
1339
+ verdictRaw !== 'REJECTED' &&
1340
+ verdictRaw !== 'INDETERMINATE') {
1341
+ console.warn(`[harness-engine] ${task.requestId}: reputation feedback skipped — gatingClaim has no recognised verdict (got=${String(verdictRaw)})`);
1342
+ return;
1343
+ }
1344
+ const verdict = verdictRaw;
1345
+ // Pull the parent harness's manifest evidence from the inlined eval
1346
+ // payload. The evaluator impl receives the harness's signed manifest
1347
+ // JSON via `task.context.restorationResult`. Its `signature.hash` is
1348
+ // exactly what the harness committed via `claimDelivery(evidenceHash)`.
1349
+ const parent = this._extractHarnessManifestRef(task);
1350
+ if (!parent) {
1351
+ console.warn(`[harness-engine] ${task.requestId}: reputation feedback skipped — could not extract harness manifest hash from inlined evaluation payload`);
1352
+ return;
1353
+ }
1354
+ let resolved;
1355
+ try {
1356
+ resolved = await this.reputationFeedback.resolveAgentId(parent.evidenceHash);
1357
+ }
1358
+ catch (err) {
1359
+ console.warn(`[harness-engine] ${task.requestId}: reputation feedback resolver threw (non-fatal): ${err instanceof Error ? err.message : err}`);
1360
+ return;
1361
+ }
1362
+ if (!resolved) {
1363
+ console.log(`[harness-engine] ${task.requestId}: reputation feedback skipped — no agentId resolved for harness manifestHash=${parent.evidenceHash} (subgraph not indexed yet, or no envelope published)`);
1364
+ return;
1365
+ }
1366
+ // CID resolution priority: subgraph row's `manifestCid` (cheapest, the
1367
+ // operator already published an envelope under it), else the inlined
1368
+ // CID hint when present, else fall back to the bare hash. The subgraph
1369
+ // parses `manifest:<cid>` to a `manifestRef` regardless.
1370
+ const manifestCid = resolved.manifestCid ?? parent.manifestCid ?? '';
1371
+ // The SolverType is the same value used by the restoration —
1372
+ // `task.solverType` is "portfolio.v0" both for the restoration and its
1373
+ // evaluation. Tag1 is indexed on the on-chain event, so cheap to filter.
1374
+ const kind = task.solverType ?? undefined;
1375
+ const verdictArg = kind ? { verdict, solverType: kind } : { verdict };
1376
+ let outcome;
1377
+ try {
1378
+ outcome = await submitEvaluatorFeedback({
1379
+ registry: this.reputationFeedback.client,
1380
+ ref: {
1381
+ harnessAgentId: resolved.agentId,
1382
+ harnessManifestCid: manifestCid,
1383
+ harnessEvidenceHash: parent.evidenceHash,
1384
+ },
1385
+ verdict: verdictArg,
1386
+ });
1387
+ }
1388
+ catch (err) {
1389
+ // submitEvaluatorFeedback already swallows known reverts, but a
1390
+ // truly unexpected throw still must not propagate past delivery.
1391
+ console.warn(`[harness-engine] ${task.requestId}: reputation feedback unexpected throw (non-fatal): ${err instanceof Error ? err.message : err}`);
1392
+ return;
1393
+ }
1394
+ console.log(`[harness-engine] ${task.requestId}: reputation feedback ${outcome.kind} verdict=${verdict} harnessAgentId=${resolved.agentId.toString()}`);
1395
+ }
1396
+ /**
1397
+ * Extract the harness's `evidenceHash` (and best-effort `manifestCid`)
1398
+ * from the persisted evaluation task.
1399
+ *
1400
+ * The evaluator's `task.context.restorationResult` holds the harness's
1401
+ * full signed manifest JSON inlined as a string. We parse it and pull the
1402
+ * `signature.hash`, which is exactly the on-chain `evidenceHash`.
1403
+ *
1404
+ * The CID is not always inlined — the manifest carries its own
1405
+ * `task.cid` field (the *original task* CID), not its self-CID. We
1406
+ * therefore return `manifestCid: null` here and rely on the subgraph
1407
+ * resolver to surface the published manifest CID. Returns `null` when
1408
+ * the inlined payload is missing or malformed.
1409
+ */
1410
+ _extractHarnessManifestRef(task) {
1411
+ const ds = task.task;
1412
+ const inlined = ds?.context?.['restorationResult'];
1413
+ if (typeof inlined !== 'string' || inlined.length === 0) {
1414
+ return null;
1415
+ }
1416
+ let parsed;
1417
+ try {
1418
+ parsed = JSON.parse(inlined);
1419
+ }
1420
+ catch {
1421
+ return null;
1422
+ }
1423
+ if (typeof parsed !== 'object' || parsed === null) {
1424
+ return null;
1425
+ }
1426
+ const sig = parsed['signature'];
1427
+ if (typeof sig !== 'object' || sig === null) {
1428
+ return null;
1429
+ }
1430
+ const hashRaw = sig['hash'];
1431
+ if (typeof hashRaw !== 'string' || !/^0x[0-9a-fA-F]{64}$/.test(hashRaw)) {
1432
+ return null;
1433
+ }
1434
+ return {
1435
+ evidenceHash: hashRaw,
1436
+ manifestCid: null,
1437
+ };
1438
+ }
1439
+ // ── Internal helpers ────────────────────────────────────────────────────────
1440
+ /**
1441
+ * Returns the next state if the current state can be advanced purely from
1442
+ * persisted data (no external work needed), or null if external work is required.
1443
+ *
1444
+ * Used for crash recovery and for collapsing transitions in process()
1445
+ * when a previous run already produced the data.
1446
+ */
1447
+ dataDrivenAdvance(task) {
1448
+ switch (task.state) {
1449
+ case TaskRunState.WAITING:
1450
+ return Date.now() >= task.windowStartTs ? TaskRunState.PRE_SNAPSHOT : null;
1451
+ case TaskRunState.PRE_SNAPSHOT:
1452
+ return task.preSnapshotPayload != null ? TaskRunState.RUNNING : null;
1453
+ case TaskRunState.POST_SNAPSHOT:
1454
+ return task.postSnapshotPayload != null ? TaskRunState.PACKAGING : null;
1455
+ default:
1456
+ return null;
1457
+ }
1458
+ }
1459
+ /**
1460
+ * Wraps a transition method call with error handling: if the transition
1461
+ * throws, the task is marked FAILED with the error message.
1462
+ */
1463
+ async _runTransition(task, fn) {
1464
+ const oldState = task.state;
1465
+ try {
1466
+ await fn();
1467
+ const updated = this.persistence.getByRequestId(task.requestId);
1468
+ if (updated && updated.state !== oldState) {
1469
+ console.log(`[harness-engine] ${task.requestId} ${oldState} → ${updated.state}`);
1470
+ }
1471
+ }
1472
+ catch (err) {
1473
+ const reason = err instanceof Error ? err.message : String(err);
1474
+ this.persistence.markFailed(task.requestId, reason);
1475
+ throw err;
1476
+ }
1477
+ }
1478
+ /**
1479
+ * Recovery handler for a single in-flight task.
1480
+ * Dispatches by state per §6.5.
1481
+ */
1482
+ async _recoverOne(task) {
1483
+ try {
1484
+ await this._recoverDispatch(task);
1485
+ }
1486
+ catch (err) {
1487
+ // If recovery itself throws (e.g. NotImplementedError stub), mark failed.
1488
+ // NotImplementedError is expected during development; don't swallow it in prod.
1489
+ const reason = err instanceof Error ? err.message : String(err);
1490
+ // Only mark failed if the task is still in the same non-terminal state
1491
+ // (another concurrent recovery pass might have already advanced it).
1492
+ const current = this.persistence.getByRequestId(task.requestId);
1493
+ if (current && current.state === task.state) {
1494
+ this.persistence.markFailed(task.requestId, `recovery: ${reason}`);
1495
+ console.error(`[harness-engine] resume failed for ${task.requestId}: ${reason}`);
1496
+ }
1497
+ throw err;
1498
+ }
1499
+ }
1500
+ /**
1501
+ * Per-state recovery dispatch per §6.5.
1502
+ */
1503
+ async _recoverDispatch(task) {
1504
+ switch (task.state) {
1505
+ case TaskRunState.DISCOVERED:
1506
+ // Ready to claim — delegate to claim flow (subsequent task).
1507
+ // Stub: leaves state unchanged; logs task is ready.
1508
+ await this.claim(task);
1509
+ break;
1510
+ case TaskRunState.CLAIMED:
1511
+ // Advance to WAITING — no side effect needed.
1512
+ this.persistence.transition(task.requestId, TaskRunState.WAITING);
1513
+ await this._recoverDispatch(this.persistence.getOrThrow(task.requestId));
1514
+ break;
1515
+ case TaskRunState.WAITING: {
1516
+ const advance = this.dataDrivenAdvance(task);
1517
+ if (advance !== null) {
1518
+ // Window has started — advance immediately.
1519
+ this.persistence.transition(task.requestId, advance);
1520
+ await this._recoverDispatch(this.persistence.getOrThrow(task.requestId));
1521
+ }
1522
+ // else: schedule a timer for startTs — caller handles scheduling.
1523
+ break;
1524
+ }
1525
+ case TaskRunState.PRE_SNAPSHOT: {
1526
+ const advance = this.dataDrivenAdvance(task);
1527
+ if (advance !== null) {
1528
+ // Snapshot already in DB — advance to RUNNING.
1529
+ this.persistence.transition(task.requestId, advance);
1530
+ await this._recoverDispatch(this.persistence.getOrThrow(task.requestId));
1531
+ }
1532
+ else {
1533
+ // Need to (re-)fetch snapshot.
1534
+ await this.takePreSnapshot(task);
1535
+ // takePreSnapshot transitions PRE_SNAPSHOT → RUNNING. Re-dispatch
1536
+ // against the post-transition state so runImpl actually fires for
1537
+ // tasks that were persisted at CLAIMED/WAITING/PRE_SNAPSHOT
1538
+ // before a restart (otherwise recovery stops at RUNNING-but-not-run).
1539
+ const after = this.persistence.getByRequestId(task.requestId);
1540
+ if (after && after.state !== task.state && after.state !== TaskRunState.FAILED) {
1541
+ await this._recoverDispatch(after);
1542
+ }
1543
+ }
1544
+ break;
1545
+ }
1546
+ case TaskRunState.RUNNING:
1547
+ // Re-spawn impl with workingDir + implStateDir intact.
1548
+ await this.runImpl(task);
1549
+ break;
1550
+ case TaskRunState.POST_SNAPSHOT: {
1551
+ const advance = this.dataDrivenAdvance(task);
1552
+ if (advance !== null) {
1553
+ // Snapshot already in DB — advance to PACKAGING.
1554
+ this.persistence.transition(task.requestId, advance);
1555
+ await this._recoverDispatch(this.persistence.getOrThrow(task.requestId));
1556
+ }
1557
+ else {
1558
+ await this.takePostSnapshot(task);
1559
+ }
1560
+ break;
1561
+ }
1562
+ case TaskRunState.PACKAGING:
1563
+ // Re-walk workingDir + Solution; re-upload missing CIDs.
1564
+ await this.pack(task);
1565
+ break;
1566
+ case TaskRunState.DELIVERING:
1567
+ // Chain query — if already delivered → COMPLETE; else retry.
1568
+ await this.deliver(task);
1569
+ break;
1570
+ case TaskRunState.COMPLETE:
1571
+ case TaskRunState.FAILED:
1572
+ // Terminal — nothing to recover.
1573
+ break;
1574
+ }
1575
+ }
1576
+ }
1577
+ // ── runHarnessOnce ────────────────────────────────────────────────────────────
1578
+ /**
1579
+ * Thin, test-friendly entry point for the freeze-fence + mode propagation
1580
+ * path. Runs a single `harness.run(ctx)` call through `runHarnessWithFreezeFence`
1581
+ * and returns either a minimal envelope stub (carrying `executor.mode`) or a
1582
+ * structured violation result — without requiring a full DB-backed TaskEngine
1583
+ * state machine.
1584
+ *
1585
+ * This function is *not* the production dispatch path; it exists so integration
1586
+ * tests can drive the mode-propagation and freeze-fence behaviour in isolation.
1587
+ *
1588
+ * @returns
1589
+ * `{ envelope: { executor: { mode } } }` on success.
1590
+ * `{ violation: FreezeViolation }` when the fence rejects the harness output.
1591
+ *
1592
+ * Spec: docs/superpowers/specs/2026-05-06-agent-harness-solvernet-design.md §6.3
1593
+ */
1594
+ export async function runHarnessOnce(params) {
1595
+ const { harness, implStateDir, mode } = params;
1596
+ const workingDir = params.workingDir ?? implStateDir;
1597
+ const task = params.task ?? {
1598
+ id: 'test-task',
1599
+ description: '',
1600
+ role: 'restoration',
1601
+ window: { startTs: 0, endTs: Date.now() + 3_600_000 },
1602
+ };
1603
+ const ctx = {
1604
+ task,
1605
+ implStateDir,
1606
+ workingDir,
1607
+ log: () => { },
1608
+ abort: new AbortController().signal,
1609
+ msUntilEndTs: () => Math.max(0, (task.window?.endTs ?? Date.now() + 3_600_000) - Date.now()),
1610
+ trajectory: new TrajectoryCollector({ taskCid: '', runId: 'test-run' }),
1611
+ mode,
1612
+ };
1613
+ const fence = await runHarnessWithFreezeFence(harness, ctx);
1614
+ if (!fence.ok) {
1615
+ return { violation: fence.violation };
1616
+ }
1617
+ return {
1618
+ envelope: {
1619
+ executor: {
1620
+ mode,
1621
+ codeDigest: `sha256:${fence.codeDigest}`,
1622
+ },
1623
+ },
1624
+ };
1625
+ }
1626
+ //# sourceMappingURL=engine.js.map