@jinn-network/client 0.1.2 → 0.1.3-canary.24b69ea4

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