@jinn-network/client 0.1.2 → 0.1.3-canary.2d6b2676

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 (995) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/CONTRIBUTING.md +8 -2
  3. package/README.md +68 -42
  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/dist/adapters/adapter.d.ts +7 -7
  10. package/dist/adapters/claim-registry/client.d.ts +9 -0
  11. package/dist/adapters/claim-registry/client.js +22 -2
  12. package/dist/adapters/claim-registry/client.js.map +1 -1
  13. package/dist/adapters/local/adapter.d.ts +4 -4
  14. package/dist/adapters/local/adapter.js +10 -10
  15. package/dist/adapters/local/adapter.js.map +1 -1
  16. package/dist/adapters/mech/adapter.d.ts +8 -6
  17. package/dist/adapters/mech/adapter.js +159 -95
  18. package/dist/adapters/mech/adapter.js.map +1 -1
  19. package/dist/adapters/mech/contracts.d.ts +8 -6
  20. package/dist/adapters/mech/contracts.js +119 -15
  21. package/dist/adapters/mech/contracts.js.map +1 -1
  22. package/dist/adapters/mech/ipfs.d.ts +66 -12
  23. package/dist/adapters/mech/ipfs.js +165 -30
  24. package/dist/adapters/mech/ipfs.js.map +1 -1
  25. package/dist/adapters/mech/safe-revert.d.ts +39 -0
  26. package/dist/adapters/mech/safe-revert.js +130 -0
  27. package/dist/adapters/mech/safe-revert.js.map +1 -0
  28. package/dist/adapters/mech/safe.js +48 -22
  29. package/dist/adapters/mech/safe.js.map +1 -1
  30. package/dist/adapters/mech/types.d.ts +8 -0
  31. package/dist/adapters/mech/types.js.map +1 -1
  32. package/dist/agent/agent-ws.d.ts +55 -0
  33. package/dist/agent/agent-ws.js +288 -0
  34. package/dist/agent/agent-ws.js.map +1 -0
  35. package/dist/agent/auto-mode-detect.d.ts +6 -0
  36. package/dist/agent/auto-mode-detect.js +44 -0
  37. package/dist/agent/auto-mode-detect.js.map +1 -0
  38. package/dist/agent/operator-claude.d.ts +22 -0
  39. package/dist/agent/operator-claude.js +130 -0
  40. package/dist/agent/operator-claude.js.map +1 -0
  41. package/dist/api/admin-endpoint.d.ts +12 -0
  42. package/dist/api/admin-endpoint.js +71 -0
  43. package/dist/api/admin-endpoint.js.map +1 -0
  44. package/dist/api/bootstrap-endpoint.d.ts +16 -0
  45. package/dist/api/bootstrap-endpoint.js +78 -0
  46. package/dist/api/bootstrap-endpoint.js.map +1 -0
  47. package/dist/api/events-endpoint.d.ts +9 -0
  48. package/dist/api/events-endpoint.js +46 -0
  49. package/dist/api/events-endpoint.js.map +1 -0
  50. package/dist/api/fleet-build.d.ts +1 -1
  51. package/dist/api/fleet-build.js +17 -8
  52. package/dist/api/fleet-build.js.map +1 -1
  53. package/dist/api/gather-status.js +6 -2
  54. package/dist/api/gather-status.js.map +1 -1
  55. package/dist/api/handshake.d.ts +17 -0
  56. package/dist/api/handshake.js +28 -0
  57. package/dist/api/handshake.js.map +1 -0
  58. package/dist/api/history-build.d.ts +2 -2
  59. package/dist/api/history-build.js +3 -3
  60. package/dist/api/history-build.js.map +1 -1
  61. package/dist/api/peers.js +21 -6
  62. package/dist/api/peers.js.map +1 -1
  63. package/dist/api/portfolio-v0-build.d.ts +16 -10
  64. package/dist/api/portfolio-v0-build.js +36 -31
  65. package/dist/api/portfolio-v0-build.js.map +1 -1
  66. package/dist/api/portfolio-v0-doctor.js +1 -1
  67. package/dist/api/portfolio-v0-doctor.js.map +1 -1
  68. package/dist/api/rewards-build.js +3 -8
  69. package/dist/api/rewards-build.js.map +1 -1
  70. package/dist/api/server.d.ts +55 -1
  71. package/dist/api/server.js +243 -17
  72. package/dist/api/server.js.map +1 -1
  73. package/dist/api/setup-endpoints.d.ts +34 -0
  74. package/dist/api/setup-endpoints.js +188 -0
  75. package/dist/api/setup-endpoints.js.map +1 -0
  76. package/dist/api/status-build.d.ts +10 -2
  77. package/dist/api/status-build.js +44 -9
  78. package/dist/api/status-build.js.map +1 -1
  79. package/dist/api/status-rollup-build.d.ts +46 -1
  80. package/dist/api/status-rollup-build.js +168 -5
  81. package/dist/api/status-rollup-build.js.map +1 -1
  82. package/dist/api/ui-token.d.ts +5 -0
  83. package/dist/api/ui-token.js +36 -0
  84. package/dist/api/ui-token.js.map +1 -0
  85. package/dist/build-info.d.ts +32 -0
  86. package/dist/build-info.js +69 -0
  87. package/dist/build-info.js.map +1 -0
  88. package/dist/build-info.json +6 -0
  89. package/dist/build-meta.json +1 -1
  90. package/dist/cli/command.d.ts +9 -0
  91. package/dist/cli/commands/balance.d.ts +7 -0
  92. package/dist/cli/commands/balance.js +38 -32
  93. package/dist/cli/commands/balance.js.map +1 -1
  94. package/dist/cli/commands/bootstrap.d.ts +13 -1
  95. package/dist/cli/commands/bootstrap.js +150 -132
  96. package/dist/cli/commands/bootstrap.js.map +1 -1
  97. package/dist/cli/commands/claim-rewards.js +14 -2
  98. package/dist/cli/commands/claim-rewards.js.map +1 -1
  99. package/dist/cli/commands/conformance.d.ts +12 -0
  100. package/dist/cli/commands/conformance.js +140 -0
  101. package/dist/cli/commands/conformance.js.map +1 -0
  102. package/dist/cli/commands/create.d.ts +22 -0
  103. package/dist/cli/commands/create.js +226 -0
  104. package/dist/cli/commands/create.js.map +1 -0
  105. package/dist/cli/commands/doctor.d.ts +34 -1
  106. package/dist/cli/commands/doctor.js +138 -123
  107. package/dist/cli/commands/doctor.js.map +1 -1
  108. package/dist/cli/commands/fleet-scale.d.ts +19 -1
  109. package/dist/cli/commands/fleet-scale.js +379 -361
  110. package/dist/cli/commands/fleet-scale.js.map +1 -1
  111. package/dist/cli/commands/fleet.d.ts +7 -0
  112. package/dist/cli/commands/fleet.js +39 -33
  113. package/dist/cli/commands/fleet.js.map +1 -1
  114. package/dist/cli/commands/fund-requirements.d.ts +14 -1
  115. package/dist/cli/commands/fund-requirements.js +183 -174
  116. package/dist/cli/commands/fund-requirements.js.map +1 -1
  117. package/dist/cli/commands/harnesses.d.ts +18 -0
  118. package/dist/cli/commands/harnesses.js +208 -0
  119. package/dist/cli/commands/harnesses.js.map +1 -0
  120. package/dist/cli/commands/history.d.ts +10 -1
  121. package/dist/cli/commands/history.js +68 -59
  122. package/dist/cli/commands/history.js.map +1 -1
  123. package/dist/cli/commands/init.js +4 -1
  124. package/dist/cli/commands/init.js.map +1 -1
  125. package/dist/cli/commands/integrations.d.ts +13 -0
  126. package/dist/cli/commands/{plugin-install.js → integrations.js} +240 -33
  127. package/dist/cli/commands/integrations.js.map +1 -0
  128. package/dist/cli/commands/logs.d.ts +6 -1
  129. package/dist/cli/commands/logs.js +77 -70
  130. package/dist/cli/commands/logs.js.map +1 -1
  131. package/dist/cli/commands/migrate-agent-id.d.ts +26 -0
  132. package/dist/cli/commands/migrate-agent-id.js +165 -0
  133. package/dist/cli/commands/migrate-agent-id.js.map +1 -0
  134. package/dist/cli/commands/quickstart.d.ts +51 -1
  135. package/dist/cli/commands/quickstart.js +514 -296
  136. package/dist/cli/commands/quickstart.js.map +1 -1
  137. package/dist/cli/commands/rewards.d.ts +7 -0
  138. package/dist/cli/commands/rewards.js +46 -40
  139. package/dist/cli/commands/rewards.js.map +1 -1
  140. package/dist/cli/commands/run.d.ts +14 -1
  141. package/dist/cli/commands/run.js +233 -91
  142. package/dist/cli/commands/run.js.map +1 -1
  143. package/dist/cli/commands/solver-nets.js +207 -0
  144. package/dist/cli/commands/solver-nets.js.map +1 -0
  145. package/dist/cli/commands/solver-plugins.d.ts +9 -0
  146. package/dist/cli/commands/solver-plugins.js +184 -0
  147. package/dist/cli/commands/solver-plugins.js.map +1 -0
  148. package/dist/cli/commands/status.d.ts +10 -0
  149. package/dist/cli/commands/status.js +97 -34
  150. package/dist/cli/commands/status.js.map +1 -1
  151. package/dist/cli/commands/tasks.js +365 -0
  152. package/dist/cli/commands/tasks.js.map +1 -0
  153. package/dist/cli/commands/ui.d.ts +3 -0
  154. package/dist/cli/commands/ui.js +45 -0
  155. package/dist/cli/commands/ui.js.map +1 -0
  156. package/dist/cli/commands/update.d.ts +5 -0
  157. package/dist/cli/commands/update.js +110 -105
  158. package/dist/cli/commands/update.js.map +1 -1
  159. package/dist/cli/commands/version.js +3 -1
  160. package/dist/cli/commands/version.js.map +1 -1
  161. package/dist/cli/commands/withdraw.d.ts +21 -1
  162. package/dist/cli/commands/withdraw.js +175 -159
  163. package/dist/cli/commands/withdraw.js.map +1 -1
  164. package/dist/cli/execution-context.d.ts +1 -1
  165. package/dist/cli/execution-context.js +4 -3
  166. package/dist/cli/execution-context.js.map +1 -1
  167. package/dist/cli/help.js +8 -1
  168. package/dist/cli/help.js.map +1 -1
  169. package/dist/cli/index.d.ts +7 -0
  170. package/dist/cli/index.js +24 -6
  171. package/dist/cli/index.js.map +1 -1
  172. package/dist/cli/open-browser.d.ts +1 -0
  173. package/dist/cli/open-browser.js +18 -0
  174. package/dist/cli/open-browser.js.map +1 -0
  175. package/dist/cli/password.d.ts +3 -3
  176. package/dist/cli/password.js +6 -6
  177. package/dist/cli/password.js.map +1 -1
  178. package/dist/config.d.ts +1232 -53
  179. package/dist/config.js +558 -24
  180. package/dist/config.js.map +1 -1
  181. package/dist/conformance/checks/artifacts.d.ts +37 -0
  182. package/dist/conformance/checks/artifacts.js +110 -0
  183. package/dist/conformance/checks/artifacts.js.map +1 -0
  184. package/dist/conformance/checks/envelope-schema.d.ts +17 -0
  185. package/dist/conformance/checks/envelope-schema.js +36 -0
  186. package/dist/conformance/checks/envelope-schema.js.map +1 -0
  187. package/dist/conformance/checks/hash-signature.d.ts +26 -0
  188. package/dist/conformance/checks/hash-signature.js +70 -0
  189. package/dist/conformance/checks/hash-signature.js.map +1 -0
  190. package/dist/conformance/checks/payload.d.ts +19 -0
  191. package/dist/conformance/checks/payload.js +52 -0
  192. package/dist/conformance/checks/payload.js.map +1 -0
  193. package/dist/conformance/checks/secret-scrub.d.ts +33 -0
  194. package/dist/conformance/checks/secret-scrub.js +118 -0
  195. package/dist/conformance/checks/secret-scrub.js.map +1 -0
  196. package/dist/conformance/checks/source-runtime.d.ts +43 -0
  197. package/dist/conformance/checks/source-runtime.js +68 -0
  198. package/dist/conformance/checks/source-runtime.js.map +1 -0
  199. package/dist/conformance/checks/source-static.d.ts +61 -0
  200. package/dist/conformance/checks/source-static.js +311 -0
  201. package/dist/conformance/checks/source-static.js.map +1 -0
  202. package/dist/conformance/checks/trajectory-chain.d.ts +18 -0
  203. package/dist/conformance/checks/trajectory-chain.js +51 -0
  204. package/dist/conformance/checks/trajectory-chain.js.map +1 -0
  205. package/dist/conformance/checks/trajectory-profile.d.ts +17 -0
  206. package/dist/conformance/checks/trajectory-profile.js +51 -0
  207. package/dist/conformance/checks/trajectory-profile.js.map +1 -0
  208. package/dist/conformance/checks/trajectory-schema.d.ts +20 -0
  209. package/dist/conformance/checks/trajectory-schema.js +40 -0
  210. package/dist/conformance/checks/trajectory-schema.js.map +1 -0
  211. package/dist/conformance/checks/verdict.d.ts +44 -0
  212. package/dist/conformance/checks/verdict.js +122 -0
  213. package/dist/conformance/checks/verdict.js.map +1 -0
  214. package/dist/conformance/harness.d.ts +32 -0
  215. package/dist/conformance/harness.js +227 -0
  216. package/dist/conformance/harness.js.map +1 -0
  217. package/dist/conformance/types.d.ts +88 -0
  218. package/dist/conformance/types.js +31 -0
  219. package/dist/conformance/types.js.map +1 -0
  220. package/dist/corpus/acquire.d.ts +37 -0
  221. package/dist/corpus/acquire.js +155 -0
  222. package/dist/corpus/acquire.js.map +1 -0
  223. package/dist/corpus/cache.d.ts +14 -0
  224. package/dist/corpus/cache.js +18 -0
  225. package/dist/corpus/cache.js.map +1 -0
  226. package/dist/corpus/fetch.d.ts +9 -0
  227. package/dist/corpus/fetch.js +24 -0
  228. package/dist/corpus/fetch.js.map +1 -0
  229. package/dist/corpus/index.d.ts +16 -0
  230. package/dist/corpus/index.js +78 -0
  231. package/dist/corpus/index.js.map +1 -0
  232. package/dist/corpus/query.d.ts +17 -0
  233. package/dist/corpus/query.js +108 -0
  234. package/dist/corpus/query.js.map +1 -0
  235. package/dist/corpus/route-resolver.d.ts +16 -0
  236. package/dist/corpus/route-resolver.js +20 -0
  237. package/dist/corpus/route-resolver.js.map +1 -0
  238. package/dist/corpus/types.d.ts +108 -0
  239. package/dist/corpus/types.js +50 -0
  240. package/dist/corpus/types.js.map +1 -0
  241. package/dist/daemon/balance-topup-loop.js +2 -1
  242. package/dist/daemon/balance-topup-loop.js.map +1 -1
  243. package/dist/daemon/creator.d.ts +5 -5
  244. package/dist/daemon/creator.js +8 -11
  245. package/dist/daemon/creator.js.map +1 -1
  246. package/dist/daemon/daemon.d.ts +84 -29
  247. package/dist/daemon/daemon.js +181 -63
  248. package/dist/daemon/daemon.js.map +1 -1
  249. package/dist/daemon/delivery-watcher.js +34 -4
  250. package/dist/daemon/delivery-watcher.js.map +1 -1
  251. package/dist/daemon/jinn-claim-loop-canonical.d.ts +207 -0
  252. package/dist/daemon/jinn-claim-loop-canonical.js +296 -0
  253. package/dist/daemon/jinn-claim-loop-canonical.js.map +1 -0
  254. package/dist/daemon/jinn-claim-loop-mock.d.ts +61 -0
  255. package/dist/daemon/jinn-claim-loop-mock.js +122 -0
  256. package/dist/daemon/jinn-claim-loop-mock.js.map +1 -0
  257. package/dist/daemon/jinn-claim-loop.d.ts +123 -0
  258. package/dist/daemon/jinn-claim-loop.js +256 -0
  259. package/dist/daemon/jinn-claim-loop.js.map +1 -0
  260. package/dist/daemon/reward-claim-loop.d.ts +2 -0
  261. package/dist/daemon/reward-claim-loop.js +32 -27
  262. package/dist/daemon/reward-claim-loop.js.map +1 -1
  263. package/dist/dashboard/assets/index-Bxlk5qpa.js +68 -0
  264. package/dist/dashboard/assets/index-DQ3u_vP5.css +32 -0
  265. package/dist/dashboard/index.html +18 -74
  266. package/dist/earning/agent-wallet-binding.d.ts +133 -0
  267. package/dist/earning/agent-wallet-binding.js +202 -0
  268. package/dist/earning/agent-wallet-binding.js.map +1 -0
  269. package/dist/earning/bootstrap.d.ts +64 -0
  270. package/dist/earning/bootstrap.js +325 -32
  271. package/dist/earning/bootstrap.js.map +1 -1
  272. package/dist/earning/contracts.d.ts +323 -0
  273. package/dist/earning/contracts.js +276 -0
  274. package/dist/earning/contracts.js.map +1 -1
  275. package/dist/earning/evidence-simhash.d.ts +1 -1
  276. package/dist/earning/funding-plan.d.ts +90 -0
  277. package/dist/earning/funding-plan.js +203 -0
  278. package/dist/earning/funding-plan.js.map +1 -0
  279. package/dist/earning/migrate-agent-id.d.ts +130 -0
  280. package/dist/earning/migrate-agent-id.js +257 -0
  281. package/dist/earning/migrate-agent-id.js.map +1 -0
  282. package/dist/earning/orphan-sweep.d.ts +14 -0
  283. package/dist/earning/orphan-sweep.js +63 -2
  284. package/dist/earning/orphan-sweep.js.map +1 -1
  285. package/dist/earning/reconcile.d.ts +2 -0
  286. package/dist/earning/reconcile.js +30 -0
  287. package/dist/earning/reconcile.js.map +1 -1
  288. package/dist/earning/stolas-claim.d.ts +86 -6
  289. package/dist/earning/stolas-claim.js +123 -9
  290. package/dist/earning/stolas-claim.js.map +1 -1
  291. package/dist/earning/store.d.ts +39 -0
  292. package/dist/earning/store.js +72 -1
  293. package/dist/earning/store.js.map +1 -1
  294. package/dist/earning/testnet-setup-migration.d.ts +32 -0
  295. package/dist/earning/testnet-setup-migration.js +214 -0
  296. package/dist/earning/testnet-setup-migration.js.map +1 -0
  297. package/dist/earning/types.d.ts +53 -9
  298. package/dist/earning/types.js +51 -2
  299. package/dist/earning/types.js.map +1 -1
  300. package/dist/earning/viem-clients.d.ts +20 -0
  301. package/dist/earning/viem-clients.js +32 -1
  302. package/dist/earning/viem-clients.js.map +1 -1
  303. package/dist/erc8004/abis.d.ts +381 -0
  304. package/dist/erc8004/abis.js +238 -0
  305. package/dist/erc8004/abis.js.map +1 -0
  306. package/dist/erc8004/addresses.d.ts +40 -0
  307. package/dist/erc8004/addresses.js +64 -0
  308. package/dist/erc8004/addresses.js.map +1 -0
  309. package/dist/erc8004/identity.d.ts +202 -0
  310. package/dist/erc8004/identity.js +305 -0
  311. package/dist/erc8004/identity.js.map +1 -0
  312. package/dist/erc8004/index.d.ts +13 -0
  313. package/dist/erc8004/index.js +20 -0
  314. package/dist/erc8004/index.js.map +1 -0
  315. package/dist/erc8004/reputation.d.ts +349 -0
  316. package/dist/erc8004/reputation.js +464 -0
  317. package/dist/erc8004/reputation.js.map +1 -0
  318. package/dist/erc8004/subgraph.d.ts +46 -0
  319. package/dist/erc8004/subgraph.js +37 -0
  320. package/dist/erc8004/subgraph.js.map +1 -0
  321. package/dist/erc8004/validation.d.ts +145 -0
  322. package/dist/erc8004/validation.js +219 -0
  323. package/dist/erc8004/validation.js.map +1 -0
  324. package/dist/errors/persisted-bootstrap-error.d.ts +4 -0
  325. package/dist/errors/persisted-bootstrap-error.js +50 -0
  326. package/dist/errors/persisted-bootstrap-error.js.map +1 -0
  327. package/dist/events/emitter.d.ts +12 -0
  328. package/dist/events/emitter.js +23 -0
  329. package/dist/events/emitter.js.map +1 -0
  330. package/dist/events/ring-buffer.d.ts +25 -0
  331. package/dist/events/ring-buffer.js +46 -0
  332. package/dist/events/ring-buffer.js.map +1 -0
  333. package/dist/events/types.d.ts +42 -0
  334. package/dist/events/types.js +28 -0
  335. package/dist/events/types.js.map +1 -0
  336. package/dist/harnesses/capability/index.d.ts +82 -0
  337. package/dist/harnesses/capability/index.js +12 -0
  338. package/dist/harnesses/capability/index.js.map +1 -0
  339. package/dist/harnesses/capability/scoped-rpc.d.ts +12 -0
  340. package/dist/harnesses/capability/scoped-rpc.js +34 -0
  341. package/dist/harnesses/capability/scoped-rpc.js.map +1 -0
  342. package/dist/harnesses/capability/scoped-secrets.d.ts +8 -0
  343. package/dist/harnesses/capability/scoped-secrets.js +10 -0
  344. package/dist/harnesses/capability/scoped-secrets.js.map +1 -0
  345. package/dist/harnesses/capability/scoped-signer.d.ts +46 -0
  346. package/dist/harnesses/capability/scoped-signer.js +73 -0
  347. package/dist/harnesses/capability/scoped-signer.js.map +1 -0
  348. package/dist/harnesses/engine/canonical-json.d.ts +1 -0
  349. package/dist/harnesses/engine/canonical-json.js +66 -0
  350. package/dist/harnesses/engine/canonical-json.js.map +1 -0
  351. package/dist/{restorer → harnesses}/engine/claim.d.ts +7 -7
  352. package/dist/{restorer → harnesses}/engine/claim.js +14 -7
  353. package/dist/harnesses/engine/claim.js.map +1 -0
  354. package/dist/{restorer → harnesses}/engine/delivery.d.ts +3 -1
  355. package/dist/{restorer → harnesses}/engine/delivery.js +8 -8
  356. package/dist/harnesses/engine/delivery.js.map +1 -0
  357. package/dist/harnesses/engine/engine.d.ts +341 -0
  358. package/dist/harnesses/engine/engine.js +1203 -0
  359. package/dist/harnesses/engine/engine.js.map +1 -0
  360. package/dist/harnesses/engine/envelope-assembly.d.ts +72 -0
  361. package/dist/harnesses/engine/envelope-assembly.js +60 -0
  362. package/dist/harnesses/engine/envelope-assembly.js.map +1 -0
  363. package/dist/harnesses/engine/packaging.d.ts +87 -0
  364. package/dist/{restorer → harnesses}/engine/packaging.js +83 -57
  365. package/dist/harnesses/engine/packaging.js.map +1 -0
  366. package/dist/harnesses/engine/persistence.d.ts +172 -0
  367. package/dist/{restorer → harnesses}/engine/persistence.js +78 -71
  368. package/dist/harnesses/engine/persistence.js.map +1 -0
  369. package/dist/harnesses/engine/recovery.d.ts +22 -0
  370. package/dist/{restorer → harnesses}/engine/recovery.js +5 -5
  371. package/dist/harnesses/engine/recovery.js.map +1 -0
  372. package/dist/harnesses/engine/registry.d.ts +53 -0
  373. package/dist/harnesses/engine/registry.js +62 -0
  374. package/dist/harnesses/engine/registry.js.map +1 -0
  375. package/dist/{restorer → harnesses}/engine/signing.d.ts +1 -1
  376. package/dist/{restorer → harnesses}/engine/signing.js +1 -1
  377. package/dist/harnesses/engine/signing.js.map +1 -0
  378. package/dist/{restorer → harnesses}/engine/state.d.ts +8 -8
  379. package/dist/{restorer → harnesses}/engine/state.js +23 -23
  380. package/dist/harnesses/engine/state.js.map +1 -0
  381. package/dist/harnesses/engine/validate-manifest.d.ts +23 -0
  382. package/dist/harnesses/engine/validate-manifest.js +49 -0
  383. package/dist/harnesses/engine/validate-manifest.js.map +1 -0
  384. package/dist/harnesses/engine/verification-stub.d.ts +18 -0
  385. package/dist/harnesses/engine/verification-stub.js +18 -0
  386. package/dist/harnesses/engine/verification-stub.js.map +1 -0
  387. package/dist/harnesses/external-impls/index.d.ts +3 -0
  388. package/dist/harnesses/external-impls/index.js +2 -0
  389. package/dist/harnesses/external-impls/index.js.map +1 -0
  390. package/dist/harnesses/external-impls/loader.d.ts +50 -0
  391. package/dist/harnesses/external-impls/loader.js +139 -0
  392. package/dist/harnesses/external-impls/loader.js.map +1 -0
  393. package/dist/harnesses/external-impls/package-hash.d.ts +26 -0
  394. package/dist/harnesses/external-impls/package-hash.js +102 -0
  395. package/dist/harnesses/external-impls/package-hash.js.map +1 -0
  396. package/dist/harnesses/external-impls/types.d.ts +42 -0
  397. package/dist/harnesses/external-impls/types.js +10 -0
  398. package/dist/harnesses/external-impls/types.js.map +1 -0
  399. package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.d.ts +38 -0
  400. package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.js +159 -0
  401. package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.js.map +1 -0
  402. package/dist/harnesses/impls/claude-code-learner/harness.d.ts +22 -0
  403. package/dist/harnesses/impls/claude-code-learner/harness.js +44 -0
  404. package/dist/harnesses/impls/claude-code-learner/harness.js.map +1 -0
  405. package/dist/harnesses/impls/claude-code-learner/harvest.d.ts +19 -0
  406. package/dist/harnesses/impls/claude-code-learner/harvest.js +146 -0
  407. package/dist/harnesses/impls/claude-code-learner/harvest.js.map +1 -0
  408. package/dist/harnesses/impls/claude-code-learner/index.d.ts +14 -0
  409. package/dist/harnesses/impls/claude-code-learner/index.js +13 -0
  410. package/dist/harnesses/impls/claude-code-learner/index.js.map +1 -0
  411. package/dist/harnesses/impls/claude-code-learner/plugin-path.d.ts +14 -0
  412. package/dist/harnesses/impls/claude-code-learner/plugin-path.js +30 -0
  413. package/dist/harnesses/impls/claude-code-learner/plugin-path.js.map +1 -0
  414. package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.d.ts +19 -0
  415. package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.js +111 -0
  416. package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.js.map +1 -0
  417. package/dist/harnesses/impls/claude-code-learner/test-utils/noop-adapter.d.ts +22 -0
  418. package/dist/harnesses/impls/claude-code-learner/test-utils/noop-adapter.js +35 -0
  419. package/dist/harnesses/impls/claude-code-learner/test-utils/noop-adapter.js.map +1 -0
  420. package/dist/harnesses/impls/claude-code-learner/types.d.ts +102 -0
  421. package/dist/harnesses/impls/claude-code-learner/types.js.map +1 -0
  422. package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/api-wallet.d.ts +1 -1
  423. package/dist/harnesses/impls/claude-mcp-hyperliquid/api-wallet.js.map +1 -0
  424. package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/index.d.ts +16 -14
  425. package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/index.js +62 -61
  426. package/dist/harnesses/impls/claude-mcp-hyperliquid/index.js.map +1 -0
  427. package/dist/harnesses/impls/claude-mcp-hyperliquid/mcp-tools.js.map +1 -0
  428. package/dist/harnesses/impls/claude-mcp-hyperliquid/safety-rails.js.map +1 -0
  429. package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +7 -0
  430. package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/session-orchestrator.js +38 -0
  431. package/dist/harnesses/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +1 -0
  432. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction/index.d.ts +11 -11
  433. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction/index.js +26 -16
  434. package/dist/harnesses/impls/claude-mcp-prediction/index.js.map +1 -0
  435. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction/mcp-tools.js +1 -1
  436. package/dist/harnesses/impls/claude-mcp-prediction/mcp-tools.js.map +1 -0
  437. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction/prompt.d.ts +2 -2
  438. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction/prompt.js +5 -5
  439. package/dist/harnesses/impls/claude-mcp-prediction/prompt.js.map +1 -0
  440. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction/session-orchestrator.d.ts +9 -2
  441. package/dist/harnesses/impls/claude-mcp-prediction/session-orchestrator.js +21 -0
  442. package/dist/harnesses/impls/claude-mcp-prediction/session-orchestrator.js.map +1 -0
  443. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction/types.d.ts +3 -3
  444. package/dist/harnesses/impls/claude-mcp-prediction/types.js +6 -0
  445. package/dist/harnesses/impls/claude-mcp-prediction/types.js.map +1 -0
  446. package/dist/harnesses/impls/claude-mcp-prediction-apy/index.d.ts +36 -0
  447. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction-apy/index.js +22 -15
  448. package/dist/harnesses/impls/claude-mcp-prediction-apy/index.js.map +1 -0
  449. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction-apy/mcp-tools.js +1 -1
  450. package/dist/harnesses/impls/claude-mcp-prediction-apy/mcp-tools.js.map +1 -0
  451. package/dist/harnesses/impls/claude-mcp-prediction-apy/prompt.d.ts +7 -0
  452. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction-apy/prompt.js +5 -5
  453. package/dist/harnesses/impls/claude-mcp-prediction-apy/prompt.js.map +1 -0
  454. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction-apy/session-orchestrator.d.ts +10 -0
  455. package/dist/harnesses/impls/claude-mcp-prediction-apy/session-orchestrator.js +19 -0
  456. package/dist/harnesses/impls/claude-mcp-prediction-apy/session-orchestrator.js.map +1 -0
  457. package/dist/{restorer → harnesses}/impls/claude-mcp-prediction-apy/types.d.ts +1 -1
  458. package/dist/harnesses/impls/claude-mcp-prediction-apy/types.js +6 -0
  459. package/dist/harnesses/impls/claude-mcp-prediction-apy/types.js.map +1 -0
  460. package/dist/harnesses/impls/claude-mcp-shared/single-session-orchestrator.d.ts +84 -0
  461. package/dist/{restorer/impls/claude-mcp-prediction/session-orchestrator.js → harnesses/impls/claude-mcp-shared/single-session-orchestrator.js} +85 -16
  462. package/dist/harnesses/impls/claude-mcp-shared/single-session-orchestrator.js.map +1 -0
  463. package/dist/harnesses/impls/evaluation-context.d.ts +23 -0
  464. package/dist/harnesses/impls/evaluation-context.js +25 -0
  465. package/dist/harnesses/impls/evaluation-context.js.map +1 -0
  466. package/dist/harnesses/impls/index.d.ts +74 -0
  467. package/dist/{restorer → harnesses}/impls/index.js +32 -7
  468. package/dist/harnesses/impls/index.js.map +1 -0
  469. package/dist/harnesses/impls/legacy-claude/index.d.ts +66 -0
  470. package/dist/{restorer → harnesses}/impls/legacy-claude/index.js +47 -19
  471. package/dist/harnesses/impls/legacy-claude/index.js.map +1 -0
  472. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +2 -2
  473. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/canonical-metrics.js +2 -2
  474. package/dist/harnesses/impls/portfolio-v0-evaluator/canonical-metrics.js.map +1 -0
  475. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/availability.js.map +1 -0
  476. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/consistency.d.ts +1 -1
  477. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/consistency.js +1 -1
  478. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/consistency.js.map +1 -0
  479. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +2 -2
  480. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/eligibility.js +2 -2
  481. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/eligibility.js.map +1 -0
  482. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/integrity.d.ts +2 -2
  483. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/integrity.js +2 -2
  484. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/integrity.js.map +1 -0
  485. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/spec.d.ts +2 -2
  486. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/spec.js +2 -2
  487. package/dist/harnesses/impls/portfolio-v0-evaluator/checks/spec.js.map +1 -0
  488. package/dist/harnesses/impls/portfolio-v0-evaluator/index.d.ts +44 -0
  489. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/index.js +217 -88
  490. package/dist/harnesses/impls/portfolio-v0-evaluator/index.js.map +1 -0
  491. package/dist/harnesses/impls/portfolio-v0-evaluator/score.js.map +1 -0
  492. package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/types.d.ts +1 -1
  493. package/dist/harnesses/impls/portfolio-v0-evaluator/types.js.map +1 -0
  494. package/dist/{restorer → harnesses}/impls/prediction-apy-v0-baseline/index.d.ts +10 -8
  495. package/dist/{restorer → harnesses}/impls/prediction-apy-v0-baseline/index.js +15 -8
  496. package/dist/harnesses/impls/prediction-apy-v0-baseline/index.js.map +1 -0
  497. package/dist/harnesses/impls/prediction-apy-v0-baseline/strategy.js.map +1 -0
  498. package/dist/harnesses/impls/prediction-apy-v0-baseline/types.js.map +1 -0
  499. package/dist/harnesses/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +6 -0
  500. package/dist/harnesses/impls/prediction-apy-v0-evaluator/canonical-metrics.js +11 -0
  501. package/dist/harnesses/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +1 -0
  502. package/dist/{restorer → harnesses}/impls/prediction-apy-v0-evaluator/index.d.ts +9 -9
  503. package/dist/harnesses/impls/prediction-apy-v0-evaluator/index.js +346 -0
  504. package/dist/harnesses/impls/prediction-apy-v0-evaluator/index.js.map +1 -0
  505. package/dist/harnesses/impls/prediction-apy-v0-evaluator/parse-submission.d.ts +16 -0
  506. package/dist/harnesses/impls/prediction-apy-v0-evaluator/parse-submission.js +22 -0
  507. package/dist/harnesses/impls/prediction-apy-v0-evaluator/parse-submission.js.map +1 -0
  508. package/dist/harnesses/impls/prediction-apy-v0-evaluator/score.js.map +1 -0
  509. package/dist/harnesses/impls/prediction-apy-v0-evaluator/types.js.map +1 -0
  510. package/dist/harnesses/impls/prediction-v0-baseline/index.d.ts +33 -0
  511. package/dist/{restorer → harnesses}/impls/prediction-v0-baseline/index.js +25 -16
  512. package/dist/harnesses/impls/prediction-v0-baseline/index.js.map +1 -0
  513. package/dist/{restorer → harnesses}/impls/prediction-v0-baseline/strategy.d.ts +2 -2
  514. package/dist/{restorer → harnesses}/impls/prediction-v0-baseline/strategy.js +2 -2
  515. package/dist/harnesses/impls/prediction-v0-baseline/strategy.js.map +1 -0
  516. package/dist/harnesses/impls/prediction-v0-baseline/types.d.ts +7 -0
  517. package/dist/harnesses/impls/prediction-v0-baseline/types.js.map +1 -0
  518. package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/canonical-metrics.d.ts +2 -2
  519. package/dist/harnesses/impls/prediction-v0-evaluator/canonical-metrics.js.map +1 -0
  520. package/dist/harnesses/impls/prediction-v0-evaluator/checks/availability.js.map +1 -0
  521. package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/eligibility.d.ts +1 -1
  522. package/dist/harnesses/impls/prediction-v0-evaluator/checks/eligibility.js.map +1 -0
  523. package/dist/harnesses/impls/prediction-v0-evaluator/checks/integrity.d.ts +15 -0
  524. package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/integrity.js +12 -12
  525. package/dist/harnesses/impls/prediction-v0-evaluator/checks/integrity.js.map +1 -0
  526. package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/spec.d.ts +2 -2
  527. package/dist/harnesses/impls/prediction-v0-evaluator/checks/spec.js.map +1 -0
  528. package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/index.d.ts +10 -10
  529. package/dist/harnesses/impls/prediction-v0-evaluator/index.js +342 -0
  530. package/dist/harnesses/impls/prediction-v0-evaluator/index.js.map +1 -0
  531. package/dist/harnesses/impls/prediction-v0-evaluator/score.js.map +1 -0
  532. package/dist/harnesses/impls/prediction-v0-evaluator/types.js +2 -0
  533. package/dist/harnesses/impls/prediction-v0-evaluator/types.js.map +1 -0
  534. package/dist/harnesses/manifest/index.d.ts +3 -0
  535. package/dist/harnesses/manifest/index.js +3 -0
  536. package/dist/harnesses/manifest/index.js.map +1 -0
  537. package/dist/harnesses/manifest/load.d.ts +7 -0
  538. package/dist/harnesses/manifest/load.js +49 -0
  539. package/dist/harnesses/manifest/load.js.map +1 -0
  540. package/dist/harnesses/manifest/types.d.ts +75 -0
  541. package/dist/harnesses/manifest/types.js +8 -0
  542. package/dist/harnesses/manifest/types.js.map +1 -0
  543. package/dist/harnesses/manifest/verify.d.ts +15 -0
  544. package/dist/harnesses/manifest/verify.js +53 -0
  545. package/dist/harnesses/manifest/verify.js.map +1 -0
  546. package/dist/harnesses/types.d.ts +263 -0
  547. package/dist/{restorer → harnesses}/types.js +3 -3
  548. package/dist/harnesses/types.js.map +1 -0
  549. package/dist/index.d.ts +1 -1
  550. package/dist/main.d.ts +5 -2
  551. package/dist/main.js +793 -96
  552. package/dist/main.js.map +1 -1
  553. package/dist/mcp/acquire-artifact.d.ts +39 -0
  554. package/dist/mcp/acquire-artifact.js +163 -0
  555. package/dist/mcp/acquire-artifact.js.map +1 -0
  556. package/dist/mcp/operator-server.d.ts +21 -4
  557. package/dist/mcp/operator-server.js +505 -30
  558. package/dist/mcp/operator-server.js.map +1 -1
  559. package/dist/mcp/search-artifacts.d.ts +31 -0
  560. package/dist/mcp/search-artifacts.js +40 -0
  561. package/dist/mcp/search-artifacts.js.map +1 -0
  562. package/dist/mcp/server.d.ts +4 -4
  563. package/dist/mcp/server.js +110 -64
  564. package/dist/mcp/server.js.map +1 -1
  565. package/dist/observability/emit-event.d.ts +2 -2
  566. package/dist/observability/emit-event.js +2 -2
  567. package/dist/observability/emit-event.js.map +1 -1
  568. package/dist/operator-errors.js +4 -5
  569. package/dist/operator-errors.js.map +1 -1
  570. package/dist/plugins/digest.d.ts +1 -0
  571. package/dist/plugins/digest.js +28 -0
  572. package/dist/plugins/digest.js.map +1 -0
  573. package/dist/plugins/index.d.ts +6 -0
  574. package/dist/plugins/index.js +6 -0
  575. package/dist/plugins/index.js.map +1 -0
  576. package/dist/plugins/manifest.d.ts +7 -0
  577. package/dist/plugins/manifest.js +22 -0
  578. package/dist/plugins/manifest.js.map +1 -0
  579. package/dist/plugins/registry.d.ts +9 -0
  580. package/dist/plugins/registry.js +24 -0
  581. package/dist/plugins/registry.js.map +1 -0
  582. package/dist/plugins/resolvers.d.ts +2 -0
  583. package/dist/plugins/resolvers.js +87 -0
  584. package/dist/plugins/resolvers.js.map +1 -0
  585. package/dist/plugins/types.d.ts +39 -0
  586. package/dist/plugins/types.js +2 -0
  587. package/dist/plugins/types.js.map +1 -0
  588. package/dist/plugins/validator.d.ts +3 -0
  589. package/dist/plugins/validator.js +44 -0
  590. package/dist/plugins/validator.js.map +1 -0
  591. package/dist/preflight/claude-auth.d.ts +11 -11
  592. package/dist/preflight/claude-auth.js +18 -32
  593. package/dist/preflight/claude-auth.js.map +1 -1
  594. package/dist/runner/claude.d.ts +3 -3
  595. package/dist/runner/claude.js +62 -26
  596. package/dist/runner/claude.js.map +1 -1
  597. package/dist/runner/runner.d.ts +29 -2
  598. package/dist/runner/simple.d.ts +2 -2
  599. package/dist/runner/simple.js +2 -2
  600. package/dist/runner/simple.js.map +1 -1
  601. package/dist/scripts/fix-node-pty.mjs +62 -0
  602. package/dist/setup-mode.d.ts +34 -0
  603. package/dist/setup-mode.js +49 -0
  604. package/dist/setup-mode.js.map +1 -0
  605. package/dist/solver-nets/registry.d.ts +33 -0
  606. package/dist/solver-nets/registry.js +66 -0
  607. package/dist/solver-nets/registry.js.map +1 -0
  608. package/dist/solver-types/constants.js.map +1 -0
  609. package/dist/solver-types/index.d.ts +38 -0
  610. package/dist/solver-types/index.js +57 -0
  611. package/dist/solver-types/index.js.map +1 -0
  612. package/dist/solver-types/learner-loop-test.d.ts +2 -0
  613. package/dist/solver-types/learner-loop-test.js +39 -0
  614. package/dist/solver-types/learner-loop-test.js.map +1 -0
  615. package/dist/solver-types/portfolio-v0.d.ts +2 -0
  616. package/dist/solver-types/portfolio-v0.js +13 -0
  617. package/dist/solver-types/portfolio-v0.js.map +1 -0
  618. package/dist/solver-types/prediction-apy-v0-auto.d.ts +21 -0
  619. package/dist/solver-types/prediction-apy-v0-auto.js +80 -0
  620. package/dist/solver-types/prediction-apy-v0-auto.js.map +1 -0
  621. package/dist/{intents → solver-types}/prediction-apy-v0-template.d.ts +2 -2
  622. package/dist/{intents → solver-types}/prediction-apy-v0-template.js +2 -2
  623. package/dist/solver-types/prediction-apy-v0-template.js.map +1 -0
  624. package/dist/solver-types/prediction-apy-v0.d.ts +3 -0
  625. package/dist/solver-types/prediction-apy-v0.js +25 -0
  626. package/dist/solver-types/prediction-apy-v0.js.map +1 -0
  627. package/dist/{intents → solver-types}/prediction-v0-auto.d.ts +17 -7
  628. package/dist/{intents → solver-types}/prediction-v0-auto.js +41 -8
  629. package/dist/solver-types/prediction-v0-auto.js.map +1 -0
  630. package/dist/{intents → solver-types}/prediction-v0-template.d.ts +9 -9
  631. package/dist/{intents → solver-types}/prediction-v0-template.js +10 -10
  632. package/dist/solver-types/prediction-v0-template.js.map +1 -0
  633. package/dist/solver-types/prediction-v0.d.ts +3 -0
  634. package/dist/{intents/kinds → solver-types}/prediction-v0.js +11 -6
  635. package/dist/solver-types/prediction-v0.js.map +1 -0
  636. package/dist/solver-types/solver-type.d.ts +55 -0
  637. package/dist/solver-types/solver-type.js +6 -0
  638. package/dist/solver-types/solver-type.js.map +1 -0
  639. package/dist/store/store.d.ts +97 -21
  640. package/dist/store/store.js +228 -45
  641. package/dist/store/store.js.map +1 -1
  642. package/dist/tasks/posting-service.d.ts +22 -0
  643. package/dist/tasks/posting-service.js +143 -0
  644. package/dist/tasks/posting-service.js.map +1 -0
  645. package/dist/tasks/signing.d.ts +4 -0
  646. package/dist/tasks/signing.js +18 -0
  647. package/dist/tasks/signing.js.map +1 -0
  648. package/dist/tasks/sources.d.ts +46 -0
  649. package/dist/tasks/sources.js +42 -0
  650. package/dist/tasks/sources.js.map +1 -0
  651. package/dist/templates/harnesses/alternative-harness/README.md.tmpl +44 -0
  652. package/dist/templates/harnesses/alternative-harness/gitignore.tmpl +3 -0
  653. package/dist/templates/harnesses/alternative-harness/jinn.manifest.json.tmpl +22 -0
  654. package/dist/templates/harnesses/alternative-harness/package.json.tmpl +26 -0
  655. package/dist/templates/harnesses/alternative-harness/src/coordinator.ts.tmpl +50 -0
  656. package/dist/templates/harnesses/alternative-harness/src/harness.ts.tmpl +31 -0
  657. package/dist/templates/harnesses/alternative-harness/src/index.ts.tmpl +44 -0
  658. package/dist/templates/harnesses/alternative-harness/src/mock-harness.ts.tmpl +41 -0
  659. package/dist/templates/harnesses/alternative-harness/src/phases/debrief.ts.tmpl +28 -0
  660. package/dist/templates/harnesses/alternative-harness/src/phases/execute.ts.tmpl +33 -0
  661. package/dist/templates/harnesses/alternative-harness/src/phases/improve.ts.tmpl +31 -0
  662. package/dist/templates/harnesses/alternative-harness/src/phases/memory.ts.tmpl +31 -0
  663. package/dist/templates/harnesses/alternative-harness/src/phases/orient.ts.tmpl +21 -0
  664. package/dist/templates/harnesses/alternative-harness/src/phases/plan.ts.tmpl +25 -0
  665. package/dist/templates/harnesses/alternative-harness/src/phases/strategize.ts.tmpl +29 -0
  666. package/dist/templates/harnesses/alternative-harness/test/coordinator.test.ts.tmpl +53 -0
  667. package/dist/templates/harnesses/alternative-harness/test/unit.test.ts.tmpl +55 -0
  668. package/dist/templates/harnesses/alternative-harness/tsconfig.json.tmpl +16 -0
  669. package/dist/templates/harnesses/evaluator/README.md.tmpl +36 -0
  670. package/dist/templates/harnesses/evaluator/gitignore.tmpl +3 -0
  671. package/dist/templates/harnesses/evaluator/jinn.manifest.json.tmpl +22 -0
  672. package/dist/templates/harnesses/evaluator/package.json.tmpl +26 -0
  673. package/dist/templates/harnesses/evaluator/src/index.ts.tmpl +35 -0
  674. package/dist/templates/harnesses/evaluator/test/unit.test.ts.tmpl +49 -0
  675. package/dist/templates/harnesses/evaluator/tsconfig.json.tmpl +16 -0
  676. package/dist/templates/harnesses/forecaster/README.md.tmpl +25 -0
  677. package/dist/templates/harnesses/forecaster/gitignore.tmpl +5 -0
  678. package/dist/templates/harnesses/forecaster/jinn.manifest.json.tmpl +22 -0
  679. package/dist/templates/harnesses/forecaster/package.json.tmpl +26 -0
  680. package/dist/templates/harnesses/forecaster/src/index.ts.tmpl +33 -0
  681. package/dist/templates/harnesses/forecaster/test/unit.test.ts.tmpl +42 -0
  682. package/dist/templates/harnesses/forecaster/tsconfig.json.tmpl +16 -0
  683. package/dist/trajectory/collector.d.ts +49 -0
  684. package/dist/trajectory/collector.js +86 -0
  685. package/dist/trajectory/collector.js.map +1 -0
  686. package/dist/trajectory/emit.d.ts +27 -0
  687. package/dist/trajectory/emit.js +40 -0
  688. package/dist/trajectory/emit.js.map +1 -0
  689. package/dist/trajectory/hash-chain.d.ts +18 -0
  690. package/dist/trajectory/hash-chain.js +23 -0
  691. package/dist/trajectory/hash-chain.js.map +1 -0
  692. package/dist/trajectory/index.d.ts +22 -0
  693. package/dist/trajectory/index.js +23 -0
  694. package/dist/trajectory/index.js.map +1 -0
  695. package/dist/trajectory/schema.d.ts +14 -14
  696. package/dist/trajectory/secret-scrub.d.ts +32 -0
  697. package/dist/trajectory/secret-scrub.js +51 -0
  698. package/dist/trajectory/secret-scrub.js.map +1 -0
  699. package/dist/trajectory/span-profile.d.ts +27 -0
  700. package/dist/trajectory/span-profile.js +51 -0
  701. package/dist/trajectory/span-profile.js.map +1 -0
  702. package/dist/trajectory/wrappers/http.d.ts +37 -0
  703. package/dist/trajectory/wrappers/http.js +85 -0
  704. package/dist/trajectory/wrappers/http.js.map +1 -0
  705. package/dist/trajectory/wrappers/mcp.d.ts +17 -0
  706. package/dist/trajectory/wrappers/mcp.js +58 -0
  707. package/dist/trajectory/wrappers/mcp.js.map +1 -0
  708. package/dist/trajectory/wrappers/subprocess.d.ts +32 -0
  709. package/dist/trajectory/wrappers/subprocess.js +70 -0
  710. package/dist/trajectory/wrappers/subprocess.js.map +1 -0
  711. package/dist/tx-retry.js +23 -9
  712. package/dist/tx-retry.js.map +1 -1
  713. package/dist/types/envelope.d.ts +1619 -0
  714. package/dist/types/envelope.js +121 -0
  715. package/dist/types/envelope.js.map +1 -0
  716. package/dist/types/index.d.ts +4 -4
  717. package/dist/types/index.js +4 -4
  718. package/dist/types/index.js.map +1 -1
  719. package/dist/types/payloads/index.d.ts +11 -0
  720. package/dist/types/payloads/index.js +46 -0
  721. package/dist/types/payloads/index.js.map +1 -0
  722. package/dist/types/payloads/portfolio-v0.d.ts +481 -0
  723. package/dist/types/payloads/portfolio-v0.js +94 -0
  724. package/dist/types/payloads/portfolio-v0.js.map +1 -0
  725. package/dist/types/payloads/prediction-apy-v0.d.ts +231 -0
  726. package/dist/types/payloads/prediction-apy-v0.js +63 -0
  727. package/dist/types/payloads/prediction-apy-v0.js.map +1 -0
  728. package/dist/types/payloads/prediction-v0.d.ts +262 -0
  729. package/dist/types/payloads/prediction-v0.js +73 -0
  730. package/dist/types/payloads/prediction-v0.js.map +1 -0
  731. package/dist/types/portfolio.d.ts +31 -698
  732. package/dist/types/portfolio.js +20 -110
  733. package/dist/types/portfolio.js.map +1 -1
  734. package/dist/types/prediction-apy.d.ts +26 -366
  735. package/dist/types/prediction-apy.js +12 -68
  736. package/dist/types/prediction-apy.js.map +1 -1
  737. package/dist/types/prediction.d.ts +40 -416
  738. package/dist/types/prediction.js +9 -83
  739. package/dist/types/prediction.js.map +1 -1
  740. package/dist/types/task-document.d.ts +498 -0
  741. package/dist/types/task-document.js +69 -0
  742. package/dist/types/task-document.js.map +1 -0
  743. package/dist/types/task.d.ts +455 -0
  744. package/dist/types/task.js +58 -0
  745. package/dist/types/task.js.map +1 -0
  746. package/dist/types/window.d.ts +12 -0
  747. package/dist/types/window.js +6 -0
  748. package/dist/types/window.js.map +1 -0
  749. package/dist/util/path-safety.d.ts +21 -0
  750. package/dist/util/path-safety.js +28 -0
  751. package/dist/util/path-safety.js.map +1 -0
  752. package/dist/util/redact-rpc-urls.d.ts +5 -0
  753. package/dist/util/redact-rpc-urls.js +9 -0
  754. package/dist/util/redact-rpc-urls.js.map +1 -0
  755. package/dist/venues/hyperliquid/account-value.d.ts +1 -1
  756. package/dist/venues/hyperliquid/account-value.js +1 -1
  757. package/dist/x402/acquire.d.ts +14 -3
  758. package/dist/x402/acquire.js +28 -11
  759. package/dist/x402/acquire.js.map +1 -1
  760. package/dist/x402/handler.d.ts +15 -3
  761. package/dist/x402/handler.js +67 -24
  762. package/dist/x402/handler.js.map +1 -1
  763. package/package.json +38 -13
  764. package/plugins/claude-code-learner/.claude-plugin/plugin.json +9 -0
  765. package/plugins/claude-code-learner/AGENTS.md +30 -0
  766. package/plugins/claude-code-learner/CLAUDE.md +31 -0
  767. package/plugins/claude-code-learner/README.md +58 -0
  768. package/plugins/claude-code-learner/agents/analyst.md +69 -0
  769. package/plugins/claude-code-learner/agents/consolidator.md +95 -0
  770. package/plugins/claude-code-learner/agents/explorer.md +54 -0
  771. package/plugins/claude-code-learner/agents/planner.md +88 -0
  772. package/plugins/claude-code-learner/agents/promoter.md +114 -0
  773. package/plugins/claude-code-learner/agents/step-worker.md +48 -0
  774. package/plugins/claude-code-learner/agents/strategist.md +86 -0
  775. package/plugins/claude-code-learner/hooks/hooks.json +16 -0
  776. package/plugins/claude-code-learner/hooks/session-start +38 -0
  777. package/plugins/claude-code-learner/skills/coordinator/SKILL.md +111 -0
  778. package/plugins/claude-code-learner/skills/debrief/SKILL.md +63 -0
  779. package/plugins/claude-code-learner/skills/execute/SKILL.md +87 -0
  780. package/plugins/claude-code-learner/skills/improve/SKILL.md +53 -0
  781. package/plugins/claude-code-learner/skills/memory-consolidation/SKILL.md +49 -0
  782. package/plugins/claude-code-learner/skills/orient/SKILL.md +71 -0
  783. package/plugins/claude-code-learner/skills/plan/SKILL.md +50 -0
  784. package/plugins/claude-code-learner/skills/strategize/SKILL.md +53 -0
  785. package/plugins/jinn-prediction-plugin/.claude-plugin/plugin.json +89 -0
  786. package/plugins/jinn-prediction-plugin/mcp/polymarket-server.mjs +2 -0
  787. package/plugins/jinn-prediction-plugin/schemas/prediction-v0-solution.schema.json +12 -0
  788. package/plugins/jinn-prediction-plugin/schemas/prediction-v0-task.schema.json +25 -0
  789. package/plugins/jinn-prediction-plugin/schemas/prediction-v0-verdict.schema.json +11 -0
  790. package/plugins/jinn-prediction-plugin/skills/base-rate-forecasting/SKILL.md +3 -0
  791. package/plugins/jinn-prediction-plugin/skills/calibration/SKILL.md +3 -0
  792. package/skills/jinn-operator/SKILL.md +120 -101
  793. package/templates/harnesses/alternative-harness/README.md.tmpl +44 -0
  794. package/templates/harnesses/alternative-harness/gitignore.tmpl +3 -0
  795. package/templates/harnesses/alternative-harness/jinn.manifest.json.tmpl +22 -0
  796. package/templates/harnesses/alternative-harness/package.json.tmpl +26 -0
  797. package/templates/harnesses/alternative-harness/src/coordinator.ts.tmpl +50 -0
  798. package/templates/harnesses/alternative-harness/src/harness.ts.tmpl +31 -0
  799. package/templates/harnesses/alternative-harness/src/index.ts.tmpl +44 -0
  800. package/templates/harnesses/alternative-harness/src/mock-harness.ts.tmpl +41 -0
  801. package/templates/harnesses/alternative-harness/src/phases/debrief.ts.tmpl +28 -0
  802. package/templates/harnesses/alternative-harness/src/phases/execute.ts.tmpl +33 -0
  803. package/templates/harnesses/alternative-harness/src/phases/improve.ts.tmpl +31 -0
  804. package/templates/harnesses/alternative-harness/src/phases/memory.ts.tmpl +31 -0
  805. package/templates/harnesses/alternative-harness/src/phases/orient.ts.tmpl +21 -0
  806. package/templates/harnesses/alternative-harness/src/phases/plan.ts.tmpl +25 -0
  807. package/templates/harnesses/alternative-harness/src/phases/strategize.ts.tmpl +29 -0
  808. package/templates/harnesses/alternative-harness/test/coordinator.test.ts.tmpl +53 -0
  809. package/templates/harnesses/alternative-harness/test/unit.test.ts.tmpl +55 -0
  810. package/templates/harnesses/alternative-harness/tsconfig.json.tmpl +16 -0
  811. package/templates/harnesses/evaluator/README.md.tmpl +36 -0
  812. package/templates/harnesses/evaluator/gitignore.tmpl +3 -0
  813. package/templates/harnesses/evaluator/jinn.manifest.json.tmpl +22 -0
  814. package/templates/harnesses/evaluator/package.json.tmpl +26 -0
  815. package/templates/harnesses/evaluator/src/index.ts.tmpl +35 -0
  816. package/templates/harnesses/evaluator/test/unit.test.ts.tmpl +49 -0
  817. package/templates/harnesses/evaluator/tsconfig.json.tmpl +16 -0
  818. package/templates/harnesses/forecaster/README.md.tmpl +25 -0
  819. package/templates/harnesses/forecaster/gitignore.tmpl +5 -0
  820. package/templates/harnesses/forecaster/jinn.manifest.json.tmpl +22 -0
  821. package/templates/harnesses/forecaster/package.json.tmpl +26 -0
  822. package/templates/harnesses/forecaster/src/index.ts.tmpl +33 -0
  823. package/templates/harnesses/forecaster/test/unit.test.ts.tmpl +42 -0
  824. package/templates/harnesses/forecaster/tsconfig.json.tmpl +16 -0
  825. package/dist/bin/jinn-mcp.d.ts +0 -2
  826. package/dist/bin/jinn-mcp.js +0 -10
  827. package/dist/bin/jinn-mcp.js.map +0 -1
  828. package/dist/cli/commands/intents.d.ts +0 -17
  829. package/dist/cli/commands/intents.js +0 -489
  830. package/dist/cli/commands/intents.js.map +0 -1
  831. package/dist/cli/commands/plugin-install.js.map +0 -1
  832. package/dist/cli/commands/submit-intent.js +0 -245
  833. package/dist/cli/commands/submit-intent.js.map +0 -1
  834. package/dist/cli/intent-registry-access.d.ts +0 -62
  835. package/dist/cli/intent-registry-access.js +0 -165
  836. package/dist/cli/intent-registry-access.js.map +0 -1
  837. package/dist/discovery/registry.d.ts +0 -97
  838. package/dist/discovery/registry.js +0 -177
  839. package/dist/discovery/registry.js.map +0 -1
  840. package/dist/discovery/subgraph.d.ts +0 -37
  841. package/dist/discovery/subgraph.js +0 -87
  842. package/dist/discovery/subgraph.js.map +0 -1
  843. package/dist/intents/kinds/constants.js.map +0 -1
  844. package/dist/intents/kinds/index.d.ts +0 -28
  845. package/dist/intents/kinds/index.js +0 -50
  846. package/dist/intents/kinds/index.js.map +0 -1
  847. package/dist/intents/kinds/portfolio-v0.d.ts +0 -2
  848. package/dist/intents/kinds/portfolio-v0.js +0 -13
  849. package/dist/intents/kinds/portfolio-v0.js.map +0 -1
  850. package/dist/intents/kinds/prediction-apy-v0.d.ts +0 -3
  851. package/dist/intents/kinds/prediction-apy-v0.js +0 -21
  852. package/dist/intents/kinds/prediction-apy-v0.js.map +0 -1
  853. package/dist/intents/kinds/prediction-v0.d.ts +0 -3
  854. package/dist/intents/kinds/prediction-v0.js.map +0 -1
  855. package/dist/intents/kinds/spec-kind.d.ts +0 -38
  856. package/dist/intents/kinds/spec-kind.js +0 -6
  857. package/dist/intents/kinds/spec-kind.js.map +0 -1
  858. package/dist/intents/posting-service.d.ts +0 -26
  859. package/dist/intents/posting-service.js +0 -218
  860. package/dist/intents/posting-service.js.map +0 -1
  861. package/dist/intents/prediction-apy-v0-auto.d.ts +0 -11
  862. package/dist/intents/prediction-apy-v0-auto.js +0 -46
  863. package/dist/intents/prediction-apy-v0-auto.js.map +0 -1
  864. package/dist/intents/prediction-apy-v0-template.js.map +0 -1
  865. package/dist/intents/prediction-v0-auto.js.map +0 -1
  866. package/dist/intents/prediction-v0-template.js.map +0 -1
  867. package/dist/intents/sources.d.ts +0 -39
  868. package/dist/intents/sources.js +0 -42
  869. package/dist/intents/sources.js.map +0 -1
  870. package/dist/restorer/engine/canonical-json.d.ts +0 -18
  871. package/dist/restorer/engine/canonical-json.js +0 -59
  872. package/dist/restorer/engine/canonical-json.js.map +0 -1
  873. package/dist/restorer/engine/claim.js.map +0 -1
  874. package/dist/restorer/engine/delivery.js.map +0 -1
  875. package/dist/restorer/engine/engine.d.ts +0 -213
  876. package/dist/restorer/engine/engine.js +0 -769
  877. package/dist/restorer/engine/engine.js.map +0 -1
  878. package/dist/restorer/engine/manifest-assembly.d.ts +0 -67
  879. package/dist/restorer/engine/manifest-assembly.js +0 -79
  880. package/dist/restorer/engine/manifest-assembly.js.map +0 -1
  881. package/dist/restorer/engine/packaging.d.ts +0 -87
  882. package/dist/restorer/engine/packaging.js.map +0 -1
  883. package/dist/restorer/engine/persistence.d.ts +0 -170
  884. package/dist/restorer/engine/persistence.js.map +0 -1
  885. package/dist/restorer/engine/recovery.d.ts +0 -22
  886. package/dist/restorer/engine/recovery.js.map +0 -1
  887. package/dist/restorer/engine/registry.d.ts +0 -62
  888. package/dist/restorer/engine/registry.js +0 -73
  889. package/dist/restorer/engine/registry.js.map +0 -1
  890. package/dist/restorer/engine/signing.js.map +0 -1
  891. package/dist/restorer/engine/state.js.map +0 -1
  892. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js.map +0 -1
  893. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js.map +0 -1
  894. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js.map +0 -1
  895. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js.map +0 -1
  896. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +0 -1
  897. package/dist/restorer/impls/claude-mcp-prediction/index.js.map +0 -1
  898. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js.map +0 -1
  899. package/dist/restorer/impls/claude-mcp-prediction/prompt.js.map +0 -1
  900. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js.map +0 -1
  901. package/dist/restorer/impls/claude-mcp-prediction/types.js +0 -6
  902. package/dist/restorer/impls/claude-mcp-prediction/types.js.map +0 -1
  903. package/dist/restorer/impls/claude-mcp-prediction-apy/index.d.ts +0 -34
  904. package/dist/restorer/impls/claude-mcp-prediction-apy/index.js.map +0 -1
  905. package/dist/restorer/impls/claude-mcp-prediction-apy/mcp-tools.js.map +0 -1
  906. package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.d.ts +0 -7
  907. package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.js.map +0 -1
  908. package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js +0 -128
  909. package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js.map +0 -1
  910. package/dist/restorer/impls/claude-mcp-prediction-apy/types.js +0 -6
  911. package/dist/restorer/impls/claude-mcp-prediction-apy/types.js.map +0 -1
  912. package/dist/restorer/impls/evaluation-context.d.ts +0 -16
  913. package/dist/restorer/impls/evaluation-context.js +0 -18
  914. package/dist/restorer/impls/evaluation-context.js.map +0 -1
  915. package/dist/restorer/impls/index.d.ts +0 -46
  916. package/dist/restorer/impls/index.js.map +0 -1
  917. package/dist/restorer/impls/legacy-claude/index.d.ts +0 -52
  918. package/dist/restorer/impls/legacy-claude/index.js.map +0 -1
  919. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js.map +0 -1
  920. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js.map +0 -1
  921. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js.map +0 -1
  922. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js.map +0 -1
  923. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js.map +0 -1
  924. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js.map +0 -1
  925. package/dist/restorer/impls/portfolio-v0-evaluator/index.d.ts +0 -44
  926. package/dist/restorer/impls/portfolio-v0-evaluator/index.js.map +0 -1
  927. package/dist/restorer/impls/portfolio-v0-evaluator/score.js.map +0 -1
  928. package/dist/restorer/impls/portfolio-v0-evaluator/types.js.map +0 -1
  929. package/dist/restorer/impls/prediction-apy-v0-baseline/index.js.map +0 -1
  930. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js.map +0 -1
  931. package/dist/restorer/impls/prediction-apy-v0-baseline/types.js.map +0 -1
  932. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +0 -6
  933. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js +0 -11
  934. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +0 -1
  935. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js +0 -208
  936. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js.map +0 -1
  937. package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.d.ts +0 -7
  938. package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js +0 -29
  939. package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js.map +0 -1
  940. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js.map +0 -1
  941. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js.map +0 -1
  942. package/dist/restorer/impls/prediction-v0-baseline/index.d.ts +0 -31
  943. package/dist/restorer/impls/prediction-v0-baseline/index.js.map +0 -1
  944. package/dist/restorer/impls/prediction-v0-baseline/strategy.js.map +0 -1
  945. package/dist/restorer/impls/prediction-v0-baseline/types.d.ts +0 -7
  946. package/dist/restorer/impls/prediction-v0-baseline/types.js.map +0 -1
  947. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js.map +0 -1
  948. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js.map +0 -1
  949. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js.map +0 -1
  950. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.d.ts +0 -13
  951. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js.map +0 -1
  952. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js.map +0 -1
  953. package/dist/restorer/impls/prediction-v0-evaluator/index.js +0 -234
  954. package/dist/restorer/impls/prediction-v0-evaluator/index.js.map +0 -1
  955. package/dist/restorer/impls/prediction-v0-evaluator/score.js.map +0 -1
  956. package/dist/restorer/impls/prediction-v0-evaluator/types.js.map +0 -1
  957. package/dist/restorer/types.d.ts +0 -194
  958. package/dist/restorer/types.js.map +0 -1
  959. package/dist/types/desired-state.d.ts +0 -94
  960. package/dist/types/desired-state.js +0 -36
  961. package/dist/types/desired-state.js.map +0 -1
  962. /package/dist/cli/commands/{plugin-install.d.ts → solver-nets.d.ts} +0 -0
  963. /package/dist/cli/commands/{submit-intent.d.ts → tasks.d.ts} +0 -0
  964. /package/dist/{restorer/impls/prediction-apy-v0-baseline → harnesses/impls/claude-code-learner}/types.js +0 -0
  965. /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/api-wallet.js +0 -0
  966. /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/mcp-tools.d.ts +0 -0
  967. /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/mcp-tools.js +0 -0
  968. /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/safety-rails.d.ts +0 -0
  969. /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/safety-rails.js +0 -0
  970. /package/dist/{restorer → harnesses}/impls/claude-mcp-prediction/mcp-tools.d.ts +0 -0
  971. /package/dist/{restorer → harnesses}/impls/claude-mcp-prediction-apy/mcp-tools.d.ts +0 -0
  972. /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/availability.d.ts +0 -0
  973. /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/availability.js +0 -0
  974. /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/score.d.ts +0 -0
  975. /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/score.js +0 -0
  976. /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/types.js +0 -0
  977. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-baseline/strategy.d.ts +0 -0
  978. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-baseline/strategy.js +0 -0
  979. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-baseline/types.d.ts +0 -0
  980. /package/dist/{restorer/impls/prediction-apy-v0-evaluator → harnesses/impls/prediction-apy-v0-baseline}/types.js +0 -0
  981. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-evaluator/score.d.ts +0 -0
  982. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-evaluator/score.js +0 -0
  983. /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-evaluator/types.d.ts +0 -0
  984. /package/dist/{restorer/impls/prediction-v0-baseline → harnesses/impls/prediction-apy-v0-evaluator}/types.js +0 -0
  985. /package/dist/{restorer/impls/prediction-v0-evaluator → harnesses/impls/prediction-v0-baseline}/types.js +0 -0
  986. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/canonical-metrics.js +0 -0
  987. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/availability.d.ts +0 -0
  988. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/availability.js +0 -0
  989. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/eligibility.js +0 -0
  990. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/spec.js +0 -0
  991. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/score.d.ts +0 -0
  992. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/score.js +0 -0
  993. /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/types.d.ts +0 -0
  994. /package/dist/{intents/kinds → solver-types}/constants.d.ts +0 -0
  995. /package/dist/{intents/kinds → solver-types}/constants.js +0 -0
package/dist/main.js CHANGED
@@ -10,63 +10,147 @@
10
10
  * 2. Config file (~/.jinn-client/config.json or --config <path>)
11
11
  * 3. Built-in defaults
12
12
  *
13
- * JINN_PASSWORD (env-only) is required for keystore encryption.
13
+ * Keystore password (used to encrypt the wallet at rest) resolves in this
14
+ * order: JINN_PASSWORD env var → ~/.jinn-client/keystore-password file →
15
+ * auto-generated random value (persisted mode 0600 to that same file). A
16
+ * brand-new operator can run `jinn run` with no env var and no input.
14
17
  *
15
18
  * Canonical operator command:
16
19
  * jinn run
17
20
  */
18
21
  import { config as dotenvConfig } from 'dotenv';
22
+ import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync as writeFileSyncMain } from 'node:fs';
23
+ import { homedir } from 'node:os';
24
+ import { randomBytes as cryptoRandomBytes } from 'node:crypto';
19
25
  import { dirname, join } from 'node:path';
20
26
  import { fileURLToPath } from 'node:url';
21
27
  import { loadConfig, getConfigPathFromArgs } from './config.js';
22
- import { emitEnvelope } from './errors/envelope.js';
28
+ import { Store } from './store/store.js';
29
+ import { startApiServer } from './api/server.js';
30
+ import { ensureUiToken } from './api/ui-token.js';
31
+ import { attachAgentWs } from './agent/agent-ws.js';
32
+ import { createSetupModeController } from './setup-mode.js';
33
+ import { buildEnvelope, emitEnvelope } from './errors/envelope.js';
34
+ import { clearBootstrapError, persistBootstrapError, } from './errors/persisted-bootstrap-error.js';
35
+ import { emitStructured } from './events/emitter.js';
23
36
  import { checkClaudeBinary } from './preflight/claude-binary.js';
24
37
  import { emitClaudeBinaryPreflightFailure } from './preflight/claude-invocation-envelope.js';
25
38
  import { detectAuthContext, probeClaudeAuth } from './preflight/claude-auth.js';
26
39
  import { FleetBootstrapper } from './earning/bootstrap.js';
27
- import { getChainConfig } from './earning/contracts.js';
40
+ import { DEFAULT_TESTNET_ARTIFACTS, applyChainGasOverrides, getChainConfig, loadJinnMviConfig } from './earning/contracts.js';
41
+ import { runLegacyAgentIdMigration } from './earning/migrate-agent-id.js';
28
42
  import { FleetStateStore } from './earning/store.js';
43
+ import { isOperationalServiceStep, } from './earning/types.js';
29
44
  import { decryptMnemonic, deriveMasterSigner, walletPrivateKeyAtIndex } from './earning/wallet.js';
30
45
  import { MechAdapter } from './adapters/mech/adapter.js';
31
46
  import { ClaudeRunner } from './runner/claude.js';
32
47
  import { Daemon } from './daemon/daemon.js';
33
- import { createJinnPublicClient, createJinnWalletClient } from './earning/viem-clients.js';
34
- import { RestorerImplRegistry } from './restorer/engine/registry.js';
35
- import { buildRestorerImpls } from './restorer/impls/index.js';
48
+ import { createJinnPublicClient, createJinnWalletClient, createJinnL1PublicClient, createJinnL1WalletClient } from './earning/viem-clients.js';
49
+ import { privateKeyToAccount } from 'viem/accounts';
50
+ import { HarnessRegistry } from './harnesses/engine/registry.js';
51
+ import { buildHarnesses } from './harnesses/impls/index.js';
52
+ import { loadExternalImpl } from './harnesses/external-impls/index.js';
36
53
  import { ClaimRegistryClient } from './adapters/claim-registry/client.js';
37
54
  import { createClients } from './adapters/mech/safe.js';
38
- import { collectTestnetAutoIntentGenerators } from './intents/kinds/index.js';
55
+ import { collectTestnetAutoTaskGenerators } from './solver-types/index.js';
56
+ import { loadSolverNets } from './solver-nets/registry.js';
57
+ import { createCorpus } from './corpus/index.js';
39
58
  import { BASE_FEEDS } from './venues/chainlink/feeds.js';
40
- import { GeneratedIntentSource, StaticConfiguredIntentSource } from './intents/sources.js';
59
+ import { GeneratedTaskSource, StaticConfiguredTaskSource } from './tasks/sources.js';
41
60
  import { checkRpcNetwork, logRpcLocalDevToStderr, rpcNetworkFailureHint } from './preflight/rpc-network.js';
42
61
  import { apiPortFailureMessage, checkApiPortAvailable } from './preflight/api-port.js';
62
+ import { openBrowser } from './cli/open-browser.js';
43
63
  dotenvConfig({ path: join(dirname(fileURLToPath(import.meta.url)), '..', '.env') });
44
- // ── Password (env-only never in config files) ────────────────────────────
45
- const PASSWORD = (() => {
46
- const p = process.env['JINN_PASSWORD'];
47
- if (!p) {
48
- console.error('Fatal: JINN_PASSWORD environment variable is required.');
49
- console.error('This password encrypts your agent keystore.');
50
- process.exit(1);
51
- }
52
- return p;
53
- })();
64
+ // ── Password (env > file > auto-generated) ─────────────────────────────────
65
+ //
66
+ // Resolution order:
67
+ // 1. JINN_PASSWORD env var (explicit operator-set, never in config files)
68
+ // 2. ~/.jinn-client/keystore-password (file from a previous auto-gen)
69
+ // 3. Auto-generate a 32-byte hex string, persist mode 0600, and reuse next run
70
+ //
71
+ // Auto-generation matches what `jinn quickstart` used to do so a brand-new
72
+ // operator can run `jinn run` with no env var, no setup, no input. The
73
+ // known security trade-off is documented in client/src/cli/password.ts:
74
+ // plaintext on disk + encrypted keystore on the same disk only defends
75
+ // against casual snooping. Treat the wallet as hot until rotated.
76
+ function resolveOrGenerateKeystorePassword() {
77
+ const envPw = process.env['JINN_PASSWORD'];
78
+ if (envPw && envPw.length > 0) {
79
+ return { password: envPw, source: 'env' };
80
+ }
81
+ const home = process.env['HOME'] ?? homedir();
82
+ const pwFilePath = join(home, '.jinn-client', 'keystore-password');
83
+ if (existsSync(pwFilePath)) {
84
+ const fromDisk = readFileSync(pwFilePath, 'utf-8').trim();
85
+ if (fromDisk.length > 0) {
86
+ return { password: fromDisk, source: 'file', filePath: pwFilePath };
87
+ }
88
+ }
89
+ const generated = cryptoRandomBytes(32).toString('hex');
90
+ mkdirSync(dirname(pwFilePath), { recursive: true, mode: 0o700 });
91
+ writeFileSyncMain(pwFilePath, generated + '\n', { mode: 0o600 });
92
+ return { password: generated, source: 'generated', filePath: pwFilePath };
93
+ }
94
+ const passwordResolution = resolveOrGenerateKeystorePassword();
95
+ const PASSWORD = passwordResolution.password;
96
+ // Sub-commands (e.g. the embedded `init` invocation below) read JINN_PASSWORD
97
+ // from env. Mirror our resolved value so they don't have to redo this dance.
98
+ process.env['JINN_PASSWORD'] = PASSWORD;
99
+ if (passwordResolution.source === 'generated') {
100
+ console.log('━'.repeat(64));
101
+ console.log('A keystore password was auto-generated for you.');
102
+ console.log(` Stored at: ${passwordResolution.filePath}`);
103
+ console.log(' Mode 0600. Treat the wallet as hot until you rotate the password.');
104
+ console.log(' To rotate: JINN_NEW_PASSWORD=<new> jinn keys change-password');
105
+ console.log('━'.repeat(64));
106
+ }
54
107
  // ── Load config ─────────────────────────────────────────────────────────────
55
- const config = loadConfig(getConfigPathFromArgs());
108
+ const CONFIG_PATH = getConfigPathFromArgs();
109
+ const config = loadConfig(CONFIG_PATH);
56
110
  const NETWORK_CHAIN = config.network === 'testnet' ? 'base-sepolia' : 'base';
57
- const CHAIN_CONFIG = getChainConfig(NETWORK_CHAIN, {
111
+ const CHAIN_CONFIG = applyChainGasOverrides(getChainConfig(NETWORK_CHAIN, {
58
112
  testnetL2DeploymentPath: config.testnetL2DeploymentPath,
59
113
  testnetL2TokenDeploymentPath: config.testnetL2TokenDeploymentPath,
60
114
  testnetMechDeploymentPath: config.testnetMechDeploymentPath,
61
115
  testnetStolasDeploymentPath: config.testnetStolasDeploymentPath,
62
116
  testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
117
+ }), {
118
+ minEoaGasWei: config.minEoaGasWei,
119
+ minSafeEthWei: config.minSafeEthWei,
63
120
  });
121
+ const MESSENGER_MODE_EXPLICIT = process.env['JINN_MESSENGER_MODE'] !== undefined ||
122
+ configFileHasTopLevelKey(CONFIG_PATH, 'jinnMessengerMode');
123
+ const JINN_MVI_CONFIG = loadJinnMviConfig({
124
+ l1ArtifactPath: config.jinnMviL1DeploymentPath ??
125
+ (config.network === 'testnet' ? DEFAULT_TESTNET_ARTIFACTS.jinnMviL1 : undefined),
126
+ l2ArtifactPath: config.jinnMviL2DeploymentPath ??
127
+ (config.network === 'testnet' ? DEFAULT_TESTNET_ARTIFACTS.jinnMviL2 : undefined),
128
+ distributorAddress: config.jinnDistributorAddress,
129
+ messengerAddress: config.jinnMessengerAddress,
130
+ claimEmitterAddress: config.jinnClaimEmitterAddress,
131
+ messengerMode: MESSENGER_MODE_EXPLICIT ? config.jinnMessengerMode : undefined,
132
+ });
133
+ const JINN_CLAIM_MESSENGER_MODE = JINN_MVI_CONFIG.messengerMode ?? config.jinnMessengerMode;
64
134
  const MARKETPLACE_ADDRESS = CHAIN_CONFIG.mechMarketplace;
65
135
  const ROUTER_ADDRESS = (CHAIN_CONFIG.jinnRouter ?? '0xfFa7118A3D820cd4E820010837D65FAfF463181B');
136
+ function configFileHasTopLevelKey(configPath, key) {
137
+ const filePath = configPath ?? join(process.env['HOME'] ?? '', '.jinn-client', 'config.json');
138
+ if (!filePath || !existsSync(filePath))
139
+ return false;
140
+ try {
141
+ const raw = JSON.parse(readFileSync(filePath, 'utf8'));
142
+ return !!raw && typeof raw === 'object' && Object.prototype.hasOwnProperty.call(raw, key);
143
+ }
144
+ catch {
145
+ return false;
146
+ }
147
+ }
66
148
  const STANDARD_SERVICE_PROGRESSION = [
67
149
  'awaiting_stake',
68
150
  'staked',
69
151
  'mech_deployed',
152
+ 'agent_registered',
153
+ 'safe_binding_pending',
70
154
  'complete',
71
155
  ];
72
156
  const SELF_BOND_SERVICE_PROGRESSION = [
@@ -77,6 +161,8 @@ const SELF_BOND_SERVICE_PROGRESSION = [
77
161
  'service_deployed',
78
162
  'service_staked',
79
163
  'mech_deployed',
164
+ 'agent_registered',
165
+ 'safe_binding_pending',
80
166
  'complete',
81
167
  ];
82
168
  /** §6.2 `bootstrap_incomplete` — `{ currentStep, nextStep }` from persisted fleet state. */
@@ -85,13 +171,14 @@ function bootstrapIncompleteSteps(state) {
85
171
  ? SELF_BOND_SERVICE_PROGRESSION
86
172
  : STANDARD_SERVICE_PROGRESSION;
87
173
  const byIndex = [...state.services].sort((a, b) => a.index - b.index);
88
- const focus = byIndex.find(s => s.step === 'complete' && !s.safe_address) ??
89
- byIndex.find(s => s.step !== 'complete') ??
174
+ const focus = byIndex.find(s => isOperationalServiceStep(s.step) && !s.safe_address) ??
175
+ byIndex.find(s => !isOperationalServiceStep(s.step)) ??
176
+ byIndex.find(s => s.step === 'safe_binding_pending') ??
90
177
  byIndex[0];
91
178
  if (!focus) {
92
179
  return { currentStep: 'awaiting_service', nextStep: 'awaiting_stake' };
93
180
  }
94
- if (focus.step === 'complete' && !focus.safe_address) {
181
+ if (isOperationalServiceStep(focus.step) && !focus.safe_address) {
95
182
  return { currentStep: 'complete', nextStep: 'bootstrap' };
96
183
  }
97
184
  const i = progression.indexOf(focus.step);
@@ -106,6 +193,21 @@ function bootstrapIncompleteSteps(state) {
106
193
  // ── Bootstrap ───────────────────────────────────────────────────────────────
107
194
  async function bootstrap() {
108
195
  console.log('[main] Running fleet bootstrap...');
196
+ // A fresh bootstrap attempt clears any stale error breadcrumb. If this run
197
+ // hits the same failure, it'll be re-persisted below; if it succeeds (or
198
+ // proceeds past the previously-failed step), the panel returns to a clean
199
+ // state on the next /v1/bootstrap poll.
200
+ clearBootstrapError(config.earningDir);
201
+ // Persist the envelope to disk before emitEnvelope's process.exit fires,
202
+ // so /v1/bootstrap can surface it to the panel after the daemon has
203
+ // exited (operator restart → panel reload → error visible).
204
+ function failBootstrap(input) {
205
+ const envelope = buildEnvelope(input);
206
+ persistBootstrapError(envelope, config.earningDir);
207
+ emitEnvelope(input);
208
+ // Unreachable in production (emitEnvelope exits); satisfies `never`.
209
+ throw new Error('unreachable');
210
+ }
109
211
  const bootstrapper = new FleetBootstrapper({
110
212
  earningDir: config.earningDir,
111
213
  chain: NETWORK_CHAIN,
@@ -119,37 +221,160 @@ async function bootstrap() {
119
221
  testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
120
222
  debug: config.debug,
121
223
  masterEthDailyEstimateWei: config.masterEthDailyEstimateWei,
224
+ minEoaGasWei: config.minEoaGasWei,
225
+ minSafeEthWei: config.minSafeEthWei,
122
226
  pollIntervalMs: config.pollIntervalMs,
227
+ autoTestnetFaucet: process.env['JINN_AUTO_TESTNET_FAUCET'] === '1',
123
228
  });
124
- const result = await bootstrapper.bootstrap(PASSWORD);
125
- if (result.funding) {
126
- emitEnvelope({
127
- code: 'funding_required',
128
- message: result.message,
129
- hint: 'Fund the listed address and re-run this command.',
130
- exampleCli: 'jinn fund-requirements --json',
131
- details: {
132
- role: 'master',
133
- address: result.funding.master_address,
134
- asset: 'native',
135
- needWei: result.funding.eth_required,
136
- haveWei: result.funding.eth_balance,
137
- },
138
- });
229
+ // Funding poll: stay up while waiting for the operator to fund the wallet.
230
+ // The setup-mode API server is already running; the panel renders the
231
+ // funding card and auto-advances when funds land. Daemon-side, we poll
232
+ // bootstrap on a 15s tick and only escalate (exit) if a non-funding error
233
+ // occurs or the configured timeout elapses. Each tick re-runs the full
234
+ // bootstrap state machine completed steps are no-ops, so this is safe.
235
+ // Testnet faucet funding is panel-driven: bootstrap reports the funding gate,
236
+ // and the operator clicks the funding action before this loop can advance.
237
+ const FUNDING_POLL_INTERVAL_MS = 15_000;
238
+ const fundingTimeoutMs = (() => {
239
+ const raw = process.env['JINN_FUNDING_TIMEOUT_MS'];
240
+ if (!raw)
241
+ return Number.POSITIVE_INFINITY;
242
+ const n = Number.parseInt(raw, 10);
243
+ return Number.isFinite(n) && n > 0 ? n : Number.POSITIVE_INFINITY;
244
+ })();
245
+ emitProgress({
246
+ type: 'progress',
247
+ phase: 'bootstrap',
248
+ step: 'advance_state_machine',
249
+ estimatedWaitMs: 60_000,
250
+ });
251
+ const fundingStartedAt = Date.now();
252
+ let result;
253
+ let lastFundingMessage = '';
254
+ const fundingGatePath = join(config.earningDir, 'bootstrap-funding.json');
255
+ const persistFundingGate = (funding) => {
256
+ mkdirSync(config.earningDir, { recursive: true, mode: 0o700 });
257
+ writeFileSyncMain(fundingGatePath, `${JSON.stringify({
258
+ schemaVersion: 1,
259
+ generatedAt: new Date().toISOString(),
260
+ ...funding,
261
+ }, null, 2)}\n`, { mode: 0o600 });
262
+ };
263
+ const clearFundingGate = () => {
264
+ try {
265
+ unlinkSync(fundingGatePath);
266
+ }
267
+ catch {
268
+ // best-effort: absent/stale funding gate should not affect bootstrap
269
+ }
270
+ };
271
+ // eslint-disable-next-line no-constant-condition
272
+ while (true) {
273
+ result = await bootstrapper.bootstrap(PASSWORD);
274
+ if (!result.funding) {
275
+ clearFundingGate();
276
+ break;
277
+ }
278
+ persistFundingGate(result.funding);
279
+ // Emit a structured event so the panel's Visibility region shows the gate.
280
+ // Dedupe by message to avoid spamming the ring buffer on each poll.
281
+ const fundingMsg = result.message ?? 'awaiting funding';
282
+ if (fundingMsg !== lastFundingMessage) {
283
+ emitStructured({
284
+ kind: 'fleet',
285
+ message: fundingMsg,
286
+ details: {
287
+ phase: 'awaiting_funding',
288
+ role: 'master',
289
+ address: result.funding.master_address,
290
+ asset: 'native',
291
+ needWei: result.funding.eth_required,
292
+ haveWei: result.funding.eth_balance,
293
+ },
294
+ });
295
+ // Mirror the structured event to NDJSON progress for --json-progress
296
+ // consumers (CI, agents). Same dedup gate so we don't spam stdout.
297
+ emitProgress({
298
+ type: 'progress',
299
+ phase: 'bootstrap',
300
+ step: 'awaiting_funding',
301
+ blocking: true,
302
+ nextAction: 'Fund the address shown in addresses.fundingAddress, then wait for automatic retry.',
303
+ addresses: { fundingAddress: result.funding.master_address },
304
+ estimatedWaitMs: 1_800_000,
305
+ });
306
+ lastFundingMessage = fundingMsg;
307
+ }
308
+ const elapsed = Date.now() - fundingStartedAt;
309
+ if (elapsed >= fundingTimeoutMs) {
310
+ failBootstrap({
311
+ code: 'funding_required',
312
+ message: `${result.message} (timeout after ${Math.round(elapsed / 1000)}s)`,
313
+ hint: 'Fund the listed address and re-run this command.',
314
+ exampleCli: 'jinn fund-requirements --json',
315
+ details: {
316
+ role: 'master',
317
+ address: result.funding.master_address,
318
+ asset: 'native',
319
+ needWei: result.funding.eth_required,
320
+ haveWei: result.funding.eth_balance,
321
+ },
322
+ });
323
+ }
324
+ console.log(`[main] Awaiting funding... (${Math.round(elapsed / 1000)}s elapsed; ` +
325
+ `will retry in ${FUNDING_POLL_INTERVAL_MS / 1000}s)`);
326
+ await new Promise((r) => setTimeout(r, FUNDING_POLL_INTERVAL_MS));
139
327
  }
140
328
  if (!result.ok) {
141
- emitEnvelope({
329
+ failBootstrap({
142
330
  code: 'fatal',
143
331
  message: result.message,
144
332
  hint: 'Bootstrap failed before the fleet reached a runnable state.',
145
333
  details: { cause: result.message },
146
334
  });
147
335
  }
148
- // Use the first complete service for the daemon
149
- const state = result.fleet_state;
150
- const firstComplete = state.services.find(s => s.step === 'complete');
336
+ // Legacy migration (jinn-mono-jgp): backfill `agent_id` on `complete`
337
+ // services that pre-date j07. Idempotent + per-service failure-isolated;
338
+ // a failure here does not abort daemon startup, but we surface counts so
339
+ // operators notice. Disabled via `runLegacyMigrations: false` /
340
+ // JINN_RUN_LEGACY_MIGRATIONS=0 — operators can run `jinn migrate-agent-id`
341
+ // explicitly instead.
342
+ let state = result.fleet_state;
343
+ if (config.runLegacyMigrations) {
344
+ try {
345
+ const migration = await runLegacyAgentIdMigration({
346
+ earningDir: config.earningDir,
347
+ network: NETWORK_CHAIN,
348
+ rpcUrl: config.rpcUrl,
349
+ password: PASSWORD,
350
+ testnetL2DeploymentPath: config.testnetL2DeploymentPath,
351
+ testnetL2TokenDeploymentPath: config.testnetL2TokenDeploymentPath,
352
+ testnetMechDeploymentPath: config.testnetMechDeploymentPath,
353
+ testnetStolasDeploymentPath: config.testnetStolasDeploymentPath,
354
+ testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
355
+ });
356
+ if (migration.migrated.length > 0 || migration.failed.length > 0) {
357
+ console.log(`[main] Legacy agent_id migration: migrated=${migration.migrated.length} ` +
358
+ `skipped=${migration.skipped.length} failed=${migration.failed.length}`);
359
+ for (const f of migration.failed) {
360
+ console.log(`[main] service ${f.service.index} (agent ${f.service.agent_address}): ${f.error}`);
361
+ }
362
+ // Reload state so downstream wiring (agent_id, identityRegistry)
363
+ // sees the migrated rows.
364
+ state = await new FleetStateStore(config.earningDir).load(NETWORK_CHAIN);
365
+ }
366
+ }
367
+ catch (err) {
368
+ const message = err instanceof Error ? err.message : String(err);
369
+ console.error(`[main] Legacy agent_id migration failed (non-fatal): ${message}`);
370
+ }
371
+ }
372
+ // Use the first operational service for the daemon. `safe_binding_pending`
373
+ // means staking/mech are live; only the ERC-8004 Safe→agent metadata bind
374
+ // is still retrying.
375
+ const firstComplete = state.services.find(s => isOperationalServiceStep(s.step));
151
376
  if (!firstComplete || !firstComplete.safe_address) {
152
- emitEnvelope({
377
+ failBootstrap({
153
378
  code: 'bootstrap_incomplete',
154
379
  message: 'Bootstrap completed but no service is ready.',
155
380
  hint: 'Re-run to continue the state machine toward a running fleet.',
@@ -163,7 +388,7 @@ async function bootstrap() {
163
388
  const agentPrivateKey = walletPrivateKeyAtIndex(mnemonic, firstComplete.index);
164
389
  console.log(`[main] Fleet bootstrap complete.`);
165
390
  console.log(` Master: ${state.master_address}`);
166
- console.log(` Services: ${state.services.filter(s => s.step === 'complete').length}/${config.targetServices}`);
391
+ console.log(` Services: ${state.services.filter(s => isOperationalServiceStep(s.step)).length}/${config.targetServices}`);
167
392
  console.log(` Active: service ${firstComplete.service_id} (agent ${firstComplete.agent_address})`);
168
393
  if (firstComplete.mech_address) {
169
394
  console.log(` Mech: ${firstComplete.mech_address}`);
@@ -172,14 +397,54 @@ async function bootstrap() {
172
397
  masterAddress: state.master_address,
173
398
  serviceIndex: firstComplete.index,
174
399
  serviceId: firstComplete.service_id ?? null,
400
+ stakingAddress: firstComplete.staking_address ? firstComplete.staking_address : null,
175
401
  agentPrivateKey: agentPrivateKey,
176
402
  safeAddress: firstComplete.safe_address,
177
403
  mechAddress: firstComplete.mech_address ? firstComplete.mech_address : undefined,
404
+ agentId: firstComplete.agent_id ?? null,
405
+ identityRegistryAddress: firstComplete.identity_registry_address
406
+ ? firstComplete.identity_registry_address
407
+ : null,
178
408
  };
179
409
  }
180
410
  // ── Main ────────────────────────────────────────────────────────────────────
411
+ /**
412
+ * --json-progress: emit NDJSON progress envelopes on stdout during long
413
+ * phases (init, bootstrap, daemon startup). The `jinn run --json-progress`
414
+ * flag flips JINN_JSON_PROGRESS=1 in run.ts before calling main(); when
415
+ * unset this is a no-op so tests / non-flag invocations stay silent on
416
+ * stdout.
417
+ */
418
+ function progressEnabled() {
419
+ return process.env['JINN_JSON_PROGRESS'] === '1';
420
+ }
421
+ function emitProgress(envelope) {
422
+ if (progressEnabled()) {
423
+ process.stdout.write(JSON.stringify(envelope) + '\n');
424
+ }
425
+ }
181
426
  export async function main() {
182
427
  console.log(`[main] jinn-client starting on ${NETWORK_CHAIN}`);
428
+ // ── Daemon API bearer token (jinn-mono-pr64 hardening) ───────────────────
429
+ //
430
+ // Cost-mutating API routes (`POST /v1/artifacts/acquire`, `POST /artifacts`)
431
+ // require an `Authorization: Bearer <token>` header. Read from env when
432
+ // operators want a stable token (e.g. multi-process tools); otherwise
433
+ // generate a fresh one per daemon process. Logged only as an 8-char prefix.
434
+ // The token is forwarded to the MCP subprocess via `DAEMON_API_TOKEN` env
435
+ // so `acquire_artifact` and `submit_restoration_result` can authenticate
436
+ // their calls back to the daemon.
437
+ const envToken = process.env['DAEMON_API_TOKEN']?.trim();
438
+ const apiToken = envToken && envToken.length > 0
439
+ ? envToken
440
+ : cryptoRandomBytes(32).toString('hex');
441
+ if (!envToken) {
442
+ console.log(`[main] Generated DAEMON_API_TOKEN (prefix=${apiToken.slice(0, 8)}...)`);
443
+ }
444
+ // The keystore-presence probe happens twice: once now (to decide initial
445
+ // setup-mode) and once after we run init below (to flip the controller).
446
+ const masterKeystorePath = join(config.earningDir, 'master_keystore.json');
447
+ const legacyKeystorePath = join(config.earningDir, 'agent_keystore.json');
183
448
  const rpcPreflight = await checkRpcNetwork(config);
184
449
  if (!rpcPreflight.ok) {
185
450
  emitEnvelope({
@@ -214,7 +479,197 @@ export async function main() {
214
479
  },
215
480
  });
216
481
  }
217
- const { agentPrivateKey, masterAddress, safeAddress, mechAddress, serviceIndex, serviceId } = await bootstrap();
482
+ // ── Setup-mode API server ────────────────────────────────────────────────
483
+ // Start the operator-facing API early so the SPA can show bootstrap
484
+ // progress while we may still be waiting on funding. The daemon loops are
485
+ // gated until bootstrap completes — we just bring up the API + handshake +
486
+ // /v1/bootstrap + /v1/events + /v1/status here. The same Store instance is
487
+ // later passed into Daemon so we don't double-open the SQLite file.
488
+ const sharedStore = new Store(config.dbPath);
489
+ const earningStateStore = new FleetStateStore(config.earningDir);
490
+ const initialFleet = await earningStateStore.tryLoadExisting();
491
+ const initialServices = initialFleet?.services ?? [];
492
+ const initialAllComplete = initialServices.length > 0 && initialServices.every((s) => isOperationalServiceStep(s.step));
493
+ const setupController = createSetupModeController({
494
+ keystoreExists: existsSync(masterKeystorePath),
495
+ allComplete: initialAllComplete,
496
+ });
497
+ const uiToken = ensureUiToken();
498
+ const handshakeKey = cryptoRandomBytes(16).toString('hex');
499
+ const apiBindHost = process.env['JINN_API_BIND_HOST'] ?? '127.0.0.1';
500
+ let corpusForApi;
501
+ let setupApiServer;
502
+ try {
503
+ setupApiServer = await startApiServer({
504
+ port: config.apiPort,
505
+ store: sharedStore,
506
+ apiToken,
507
+ bindHost: apiBindHost,
508
+ corpus: config.subgraphUrl?.trim() ? () => corpusForApi : undefined,
509
+ ui: { token: uiToken, handshakeKey },
510
+ admin: {
511
+ onRestartRequested: () => {
512
+ console.log('[main] Restart requested via operator MCP. Exiting...');
513
+ process.exit(0);
514
+ },
515
+ },
516
+ bootstrap: { earningDir: config.earningDir },
517
+ setup: {
518
+ earningDir: config.earningDir,
519
+ chain: NETWORK_CHAIN,
520
+ rpcUrl: config.rpcUrl,
521
+ minEoaGasWei: (CHAIN_CONFIG.minEoaGasEth * 2n).toString(),
522
+ },
523
+ status: {
524
+ earningDir: config.earningDir,
525
+ rpcUrl: config.rpcUrl,
526
+ network: config.network,
527
+ pollIntervalMs: config.pollIntervalMs,
528
+ masterEthDailyEstimateWei: config.masterEthDailyEstimateWei,
529
+ rewardClaimIntervalMs: config.rewardClaimIntervalMs,
530
+ testnetL2DeploymentPath: config.testnetL2DeploymentPath,
531
+ testnetL2TokenDeploymentPath: config.testnetL2TokenDeploymentPath,
532
+ testnetMechDeploymentPath: config.testnetMechDeploymentPath,
533
+ testnetStolasDeploymentPath: config.testnetStolasDeploymentPath,
534
+ testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
535
+ engine: config.engine,
536
+ },
537
+ });
538
+ }
539
+ catch (error) {
540
+ sharedStore.close();
541
+ const err = error;
542
+ if (err?.code === 'EADDRINUSE') {
543
+ emitEnvelope({
544
+ code: 'invalid_invocation',
545
+ message: `Port ${config.apiPort} is already in use. Stop the other daemon or set JINN_API_PORT / apiPort to another port.`,
546
+ hint: 'Set JINN_API_PORT to a free port, or stop the process currently listening on the dashboard/API port.',
547
+ exampleCli: 'JINN_API_PORT=7332 jinn run',
548
+ details: {
549
+ field: 'apiPort',
550
+ port: config.apiPort,
551
+ reason: 'EADDRINUSE',
552
+ },
553
+ });
554
+ }
555
+ throw error;
556
+ }
557
+ process.env['JINN_UI_HANDSHAKE_URL'] =
558
+ `http://127.0.0.1:${setupApiServer.port}/?k=${handshakeKey}`;
559
+ // Auto-open the operator panel as soon as the setup-mode API is up so the
560
+ // operator can watch bootstrap progress (including the funding wait, which
561
+ // is the whole point of starting the API early). Suppressed by setting
562
+ // JINN_NO_UI=1 — `jinn run --no-ui` translates the flag into this env var.
563
+ if (process.env['JINN_NO_UI'] !== '1') {
564
+ openBrowser(process.env['JINN_UI_HANDSHAKE_URL']);
565
+ }
566
+ console.log(`[main] Setup-mode API up (mode=${setupController.mode()}). ` +
567
+ `Dashboard: http://127.0.0.1:${setupApiServer.port}`);
568
+ // ── Operator agent WebSocket bridge ──────────────────────────────────────
569
+ // Mount /api/agent/ws on the same HTTP server so the SPA's xterm.js panel
570
+ // can attach to a long-lived embedded `claude` subprocess. The embedded
571
+ // session reads MCP config we materialise to disk so it can reach the
572
+ // operator MCP server (`jinn mcp`) for tool calls.
573
+ const operatorMcpConfigPath = join(homedir(), '.jinn-client', 'operator-mcp-config.json');
574
+ try {
575
+ mkdirSync(dirname(operatorMcpConfigPath), { recursive: true });
576
+ writeFileSyncMain(operatorMcpConfigPath, JSON.stringify({
577
+ mcpServers: {
578
+ 'jinn-operator': {
579
+ command: 'jinn',
580
+ args: ['mcp'],
581
+ },
582
+ },
583
+ }, null, 2));
584
+ }
585
+ catch (err) {
586
+ console.warn(`[main] Failed to write operator MCP config at ${operatorMcpConfigPath}: ` +
587
+ (err instanceof Error ? err.message : String(err)));
588
+ }
589
+ attachAgentWs({
590
+ httpServer: setupApiServer.server,
591
+ uiToken,
592
+ claudePath: config.claudePath ?? 'claude',
593
+ cwd: process.cwd(),
594
+ mcpConfigPath: operatorMcpConfigPath,
595
+ });
596
+ console.log(`[main] Agent WS bridge mounted at ws://127.0.0.1:${setupApiServer.port}/api/agent/ws`);
597
+ // ── Init-if-missing ──────────────────────────────────────────────────────
598
+ // If the keystore is missing but we have a password, run `jinn init` now so
599
+ // bootstrap has something to decrypt. Idempotent: init is a no-op when the
600
+ // keystore already exists. This makes `jinn run` work first-time on a fresh
601
+ // host. We run AFTER startApiServer so the operator's panel can already
602
+ // render the loading screen / setup steps while init does its work — the
603
+ // /v1/bootstrap endpoint reports `mode:'uninitialized'` until init writes
604
+ // earning_state.json, then the panel transitions on the next 3s poll.
605
+ if (!existsSync(masterKeystorePath) && !existsSync(legacyKeystorePath)) {
606
+ emitProgress({
607
+ type: 'progress',
608
+ phase: 'init',
609
+ step: 'creating_wallet',
610
+ estimatedWaitMs: 2000,
611
+ });
612
+ emitStructured({ kind: 'system', message: 'creating wallet keystore' });
613
+ console.log('[main] No keystore found — initializing wallet from password.');
614
+ const initCmd = (await import('./cli/commands/init.js')).default;
615
+ let initExitCode = 0;
616
+ await initCmd.run({
617
+ argv: ['--json'],
618
+ stdoutIsTty: false,
619
+ writer: { write: (_s) => true }, // discard init's structured output
620
+ exit: (code) => {
621
+ initExitCode = code;
622
+ },
623
+ env: { ...process.env, JINN_PASSWORD: PASSWORD },
624
+ });
625
+ if (initExitCode !== 0) {
626
+ console.error('[main] init failed; cannot continue.');
627
+ await setupApiServer.close().catch(() => undefined);
628
+ sharedStore.close();
629
+ process.exit(initExitCode);
630
+ }
631
+ emitStructured({ kind: 'system', message: 'wallet keystore ready' });
632
+ // Refresh the controller so the panel's loading screen knows the
633
+ // keystore is on disk and we're transitioning into bootstrap.
634
+ setupController.refresh({ keystoreExists: true, allComplete: false });
635
+ }
636
+ let bootstrapResult;
637
+ try {
638
+ bootstrapResult = await bootstrap();
639
+ }
640
+ catch (err) {
641
+ // If bootstrap throws (vs. emitEnvelope-exits), tear down the API we
642
+ // just started so we don't leave a dangling listener on the port.
643
+ await setupApiServer.close().catch(() => undefined);
644
+ sharedStore.close();
645
+ throw err;
646
+ }
647
+ // Bootstrap completed — flip the controller into 'running' so any waiters
648
+ // (future loops gated on this) unblock.
649
+ setupController.refresh({ keystoreExists: true, allComplete: true });
650
+ // ── --no-daemon: exit cleanly after bootstrap completes ──────────────────
651
+ // `jinn run --no-daemon` flips JINN_NO_DAEMON=1 in run.ts. Emit a JSON
652
+ // summary on stdout and exit 0 so CI / agent flows can stop after the
653
+ // bootstrap state machine reaches 'complete' without paying for the
654
+ // long-lived daemon.
655
+ // We close the setup-mode API server here because its listening socket
656
+ // would otherwise hold the event loop open and prevent process exit.
657
+ if (process.env['JINN_NO_DAEMON'] === '1') {
658
+ console.log('[main] --no-daemon: bootstrap complete, exiting before daemon loops.');
659
+ await setupApiServer.close().catch(() => undefined);
660
+ sharedStore.close();
661
+ const summary = {
662
+ schemaVersion: 1,
663
+ generatedAt: new Date().toISOString(),
664
+ verb: 'run',
665
+ status: 'ready',
666
+ masterAddress: bootstrapResult.masterAddress,
667
+ dashboardUrl: `http://127.0.0.1:${config.apiPort}`,
668
+ };
669
+ process.stdout.write(JSON.stringify(summary) + '\n');
670
+ process.exit(0);
671
+ }
672
+ const { agentPrivateKey, masterAddress, safeAddress, mechAddress, serviceIndex, serviceId, stakingAddress, agentId, identityRegistryAddress, } = bootstrapResult;
218
673
  if (!mechAddress) {
219
674
  emitEnvelope({
220
675
  code: 'fatal',
@@ -227,19 +682,6 @@ export async function main() {
227
682
  },
228
683
  });
229
684
  }
230
- const adapter = new MechAdapter({
231
- rpcUrl: config.rpcUrl,
232
- mechMarketplaceAddress: MARKETPLACE_ADDRESS,
233
- routerAddress: ROUTER_ADDRESS,
234
- mechContractAddress: mechAddress,
235
- safeAddress,
236
- agentEoaPrivateKey: agentPrivateKey,
237
- ipfsRegistryUrl: config.ipfsRegistryUrl,
238
- ipfsGatewayUrl: config.ipfsGatewayUrl,
239
- pollIntervalMs: config.pollIntervalMs,
240
- chainId: config.network === 'testnet' ? 84532 : 8453,
241
- routerClaimDeliveryVariant: CHAIN_CONFIG.routerClaimDeliveryVersion,
242
- });
243
685
  const preflight = await checkClaudeBinary(config.claudePath);
244
686
  if (!preflight.ok) {
245
687
  emitClaudeBinaryPreflightFailure(preflight.detail, config.claudePath);
@@ -268,27 +710,123 @@ export async function main() {
268
710
  const masterAccount = deriveMasterSigner(mnemonicForMaster);
269
711
  const publicClient = createJinnPublicClient(config.rpcUrl, NETWORK_CHAIN);
270
712
  const masterWallet = createJinnWalletClient(config.rpcUrl, NETWORK_CHAIN, masterAccount);
271
- // ── RestorationEngine wiring ─────────────────────────────────────────────────
713
+ const evictionRecovery = config.stakingMode === 'standard' &&
714
+ serviceId !== null &&
715
+ stakingAddress &&
716
+ CHAIN_CONFIG.distributorAddress
717
+ ? {
718
+ serviceId,
719
+ stakingProxyAddress: stakingAddress,
720
+ distributorAddress: CHAIN_CONFIG.distributorAddress,
721
+ masterWalletClient: masterWallet,
722
+ }
723
+ : undefined;
724
+ const adapter = new MechAdapter({
725
+ rpcUrl: config.rpcUrl,
726
+ mechMarketplaceAddress: MARKETPLACE_ADDRESS,
727
+ routerAddress: ROUTER_ADDRESS,
728
+ mechContractAddress: mechAddress,
729
+ safeAddress,
730
+ agentEoaPrivateKey: agentPrivateKey,
731
+ ipfsRegistryUrl: config.ipfsRegistryUrl,
732
+ ipfsGatewayUrl: config.ipfsGatewayUrl,
733
+ pollIntervalMs: config.pollIntervalMs,
734
+ chainId: config.network === 'testnet' ? 84532 : 8453,
735
+ routerClaimDeliveryVariant: CHAIN_CONFIG.routerClaimDeliveryVersion,
736
+ evictionRecovery,
737
+ });
738
+ // ── TaskEngine wiring ─────────────────────────────────────────────────
272
739
  // Build agent viem clients (same creds as MechAdapter uses internally).
740
+ const viemChains = await import('viem/chains');
273
741
  const agentChain = config.network === 'testnet'
274
- ? (await import('viem/chains')).baseSepolia
275
- : (await import('viem/chains')).base;
742
+ ? viemChains.baseSepolia
743
+ : viemChains.base;
744
+ const l1Chain = config.jinnL1Network === 'sepolia' ? viemChains.sepolia : viemChains.mainnet;
745
+ const agentChainContracts = agentChain.contracts;
746
+ const optimismPortalAddress = agentChainContracts?.portal?.[l1Chain.id]?.address;
747
+ const disputeGameFactoryAddress = agentChainContracts?.disputeGameFactory?.[l1Chain.id]?.address;
748
+ const l2ProofClient = config.l2ProofRpcUrl
749
+ ? createJinnPublicClient(config.l2ProofRpcUrl, NETWORK_CHAIN)
750
+ : undefined;
276
751
  const agentClients = createClients(config.rpcUrl, agentPrivateKey, agentChain);
277
- // ── Impl registry ────────────────────────────────────────────────────────────
278
- // Default-disable impls with external dependencies the operator must opt
279
- // into (see cli/intent-registry-access.ts). The user's
280
- // `config.restorers.disabled[]` fully overrides this default when present,
281
- // so `jinn intents enable <kind>` persists the opt-in by writing to that
282
- // list in ~/.jinn-client/config.json.
283
- const { DEFAULT_DISABLED_IMPLS, DEFAULT_BY_KIND } = await import('./cli/intent-registry-access.js');
284
- const implRegistry = new RestorerImplRegistry({
285
- byKind: { ...DEFAULT_BY_KIND },
286
- default: 'legacy-claude',
287
- disabled: [...DEFAULT_DISABLED_IMPLS],
288
- ...(config.restorers ?? {}),
752
+ // ── L1 (Sepolia / Ethereum mainnet) clients for cross-chain JINN claim loop ──
753
+ // Uses the agent EOA because MockMessenger.owner is the agent on testnet.
754
+ // Same key as L2; only the chain differs.
755
+ const l1ClientsForJinnClaim = JINN_MVI_CONFIG.distributor && config.ethereumRpcUrl
756
+ ? {
757
+ public: createJinnL1PublicClient(config.ethereumRpcUrl, config.jinnL1Network),
758
+ wallet: createJinnL1WalletClient(config.ethereumRpcUrl, config.jinnL1Network, privateKeyToAccount(agentPrivateKey)),
759
+ }
760
+ : undefined;
761
+ if (l1ClientsForJinnClaim) {
762
+ console.log(`[main] JinnClaimLoop: enabled (mode=${JINN_CLAIM_MESSENGER_MODE}, ` +
763
+ `interval=${config.jinnClaimLoopIntervalMs}ms, distributor=${JINN_MVI_CONFIG.distributor}, ` +
764
+ `emitter=${JINN_MVI_CONFIG.claimEmitter})`);
765
+ }
766
+ else {
767
+ console.log(`[main] JinnClaimLoop: disabled (JinnDistributor artifact/override or JINN_ETHEREUM_RPC_URL not set)`);
768
+ }
769
+ // ── Harness registry ─────────────────────────────────────────────────────────
770
+ const solverNetRegistry = await loadSolverNets(config);
771
+ for (const net of solverNetRegistry.list()) {
772
+ const plugins = [net.canonicalPlugin, ...net.plugins]
773
+ .map((plugin) => `${plugin.name}@${plugin.version}`)
774
+ .join(', ');
775
+ console.log(`[main] Loaded SolverNet: ${net.name} solverType=${net.solverType} harness=${net.harness} plugins=${plugins}`);
776
+ }
777
+ // Default-disable Harnesses with external dependencies the operator must opt into.
778
+ const DEFAULT_DISABLED_HARNESSES = ['claude-mcp-hyperliquid'];
779
+ const DEFAULT_HARNESS = 'claude-code-learner';
780
+ const implRegistry = new HarnessRegistry({
781
+ solverTypeHarnesses: solverNetRegistry.harnessSelections(),
782
+ default: config.harnesses?.default ?? DEFAULT_HARNESS,
783
+ disabled: config.harnesses?.disabled ?? [...DEFAULT_DISABLED_HARNESSES],
289
784
  });
290
- // legacy-claude: wraps ClaudeRunner; handles spec=undefined (health-check) intents
291
- for (const impl of buildRestorerImpls({
785
+ // Load operator-supplied external harness impls (Path 2 plug-in surface).
786
+ // Each entry in `config.harnesses.externalImpls` is verified against
787
+ // `config.trustedImplSigners` before its factory is invoked. Failed loads
788
+ // are logged + skipped — they don't bring down the daemon.
789
+ const externalImpls = [];
790
+ const trustedSigners = config.trustedImplSigners ?? [];
791
+ const externalEntries = config.harnesses?.externalImpls ?? [];
792
+ if (externalEntries.length > 0) {
793
+ for (const entry of externalEntries) {
794
+ const result = await loadExternalImpl({
795
+ entry: {
796
+ name: entry.name,
797
+ entry: entry.entry,
798
+ package: entry.package,
799
+ version: entry.version,
800
+ },
801
+ trustedSigners,
802
+ env: {
803
+ implName: entry.name,
804
+ implVersion: '0.0.0', // overridden by manifest validation below
805
+ network: config.network,
806
+ implStateDir: join(config.engine.implStateDirRoot, entry.name),
807
+ secrets: Object.freeze({}),
808
+ log: ({ level, msg, data }) => console.log(`[external-impl:${entry.name}] [${level}] ${msg}`, data ?? ''),
809
+ stub: false,
810
+ },
811
+ });
812
+ if (result.kind === 'ok') {
813
+ externalImpls.push(result.impl);
814
+ console.log(`[main] Loaded external impl: ${result.impl.name}@${result.impl.version}`);
815
+ }
816
+ else {
817
+ console.warn(`[main] Failed to load external impl ${entry.name}: ${result.reason}` +
818
+ (result.detail ? ` (${result.detail})` : ''));
819
+ }
820
+ }
821
+ }
822
+ // legacy-claude: wraps ClaudeRunner; handles spec=undefined (health-check) tasks
823
+ const corpusEnv = config.subgraphUrl?.trim()
824
+ ? {
825
+ subgraphUrl: config.subgraphUrl,
826
+ ipfsGatewayUrl: config.ipfsGatewayUrl,
827
+ }
828
+ : undefined;
829
+ for (const impl of buildHarnesses({
292
830
  rpcUrl: config.rpcUrl,
293
831
  archiveRpcUrl: config.archiveRpcUrl,
294
832
  claudePath: config.claudePath,
@@ -298,18 +836,44 @@ export async function main() {
298
836
  runner,
299
837
  storePath: config.dbPath,
300
838
  daemonApiUrl: `http://127.0.0.1:${config.apiPort}`,
839
+ daemonApiToken: apiToken,
301
840
  implStateDirRoot: config.engine.implStateDirRoot,
841
+ externalImpls,
842
+ disabledNames: config.harnesses?.disabled,
843
+ corpusEnv,
302
844
  })) {
303
845
  implRegistry.register(impl);
304
846
  }
305
- console.log(`[main] RestorerImplRegistry: ${implRegistry.list().map(i => i.name).join(', ')}`);
847
+ console.log(`[main] HarnessRegistry: ${implRegistry.list().map(i => i.name).join(', ')}`);
306
848
  // ── Engine deps ───────────────────────────────────────────────────────────────
307
- // Packaging deps: IPFS upload + optional artifact registration (wired in daemon via registerArtifact)
849
+ // Packaging deps: artifact bytes are written to served_artifacts (operator-local
850
+ // SQLite) and served via the operator's HTTP server with x402 gating per
851
+ // spec/2026-04-30-phase-a-umbrella.md §1. IPFS only holds the manifest envelope.
852
+ // The `store` field is filled by Daemon (which owns the SQLite handle); here
853
+ // we just configure the endpoint + price defaults from `config.operator`
854
+ // (Phase 3, jinn-mono-vy37.1.3). Operators who don't declare an operator
855
+ // block fall back to the daemon's local API port so dev/test runs still work
856
+ // — but the resulting envelopes won't be reachable from outside the host.
857
+ const operatorPublicEndpoint = config.operator?.publicEndpoint ?? `http://localhost:${config.apiPort}`;
858
+ const operatorDefaultPrice = config.operator?.defaultPriceUsdc ?? '0';
859
+ const operatorPerTypePrice = config.operator?.perArtifactTypePrice ?? {};
860
+ if (!config.operator?.publicEndpoint) {
861
+ console.warn('[main] config.operator.publicEndpoint not set; defaulting to local API port. ' +
862
+ 'External evaluators will not be able to fetch artifacts from this operator. ' +
863
+ 'Set operator.publicEndpoint (or JINN_OPERATOR_PUBLIC_ENDPOINT) before going live.');
864
+ }
308
865
  const packagingDeps = {
309
- ipfsRegistryUrl: config.ipfsRegistryUrl,
866
+ operatorEndpoint: operatorPublicEndpoint,
867
+ defaultPriceUsdc: operatorDefaultPrice,
868
+ perArtifactTypePrice: operatorPerTypePrice,
310
869
  };
311
- // Manifest assembly deps: sign manifests with agent EOA private key
312
- const manifestDeps = {
870
+ const operatorConfig = {
871
+ publicEndpoint: operatorPublicEndpoint,
872
+ defaultPriceUsdc: operatorDefaultPrice,
873
+ perArtifactTypePrice: operatorPerTypePrice,
874
+ };
875
+ // Envelope assembly deps: sign envelopes with agent EOA private key
876
+ const envelopeDeps = {
313
877
  ipfsRegistryUrl: config.ipfsRegistryUrl,
314
878
  agentEoaPrivateKey: agentPrivateKey,
315
879
  safeAddress,
@@ -322,6 +886,7 @@ export async function main() {
322
886
  mechContractAddress: mechAddress,
323
887
  routerAddress: ROUTER_ADDRESS,
324
888
  claimDeliveryVariant: CHAIN_CONFIG.routerClaimDeliveryVersion,
889
+ evictionRecovery,
325
890
  };
326
891
  // Claim deps: use the network default when bundled, with env override for
327
892
  // emergency redeploys or custom test deployments.
@@ -340,35 +905,134 @@ export async function main() {
340
905
  else {
341
906
  console.log('[main] ClaimRegistry: not configured (claim step will use NotImplementedError fallback)');
342
907
  }
343
- // ── Auto-intent generators (testnet only, opt-out via env) ─────────────────
344
- const autoIntentsDisabled = process.env['JINN_DISABLE_AUTO_INTENTS'] === '1';
345
- const { generators: autoIntentGenerators, logLines: autoIntentLogLines } = collectTestnetAutoIntentGenerators({
908
+ // ── IdentityPublisher (jinn-mono-3zk) ───────────────────────────────────────
909
+ //
910
+ // When the bootstrap has minted an ERC-8004 IdentityRegistry NFT for the
911
+ // active service (agent_id non-null) AND we know the registry address, wire
912
+ // an IdentityPublisher so the engine anchors each envelope under the
913
+ // operator's agent NFT via setMetadata. Otherwise log a warning — publishing
914
+ // is disabled until bootstrap completes that step (jinn-mono-j07).
915
+ let identityPublisher;
916
+ if (agentId && identityRegistryAddress) {
917
+ const { IdentityPublisher } = await import('./erc8004/index.js');
918
+ identityPublisher = new IdentityPublisher({
919
+ identityRegistryAddress,
920
+ agentId: BigInt(agentId),
921
+ walletClient: agentClients.walletClient,
922
+ publicClient: agentClients.publicClient,
923
+ });
924
+ console.log(`[main] IdentityPublisher: agentId=${agentId} registry=${identityRegistryAddress}`);
925
+ }
926
+ else {
927
+ console.log('[main] IdentityPublisher: disabled (no agent_id on active service — re-run bootstrap to mint the operator agent NFT)');
928
+ }
929
+ // ── Reputation feedback hook (jinn-mono-yg4) ──────────────────────────────
930
+ //
931
+ // After the evaluator's claimDelivery succeeds, the engine fires
932
+ // `ReputationRegistry.giveFeedback(harnessAgentId, …)` so the harness's
933
+ // agent NFT accrues a rating (DR §4.3). This requires:
934
+ //
935
+ // 1. A `ReputationRegistryClient` for the active chain. We use the
936
+ // canonical 0x8004… deployment; writes route through the operator's
937
+ // Safe so `msg.sender` matches the OLAS staking + 8004 IdentityRegistry
938
+ // identity.
939
+ // 2. An agentId resolver — looks up the harness's agentId from the
940
+ // parent manifest's evidenceHash via the subgraph. When `subgraphUrl`
941
+ // is unconfigured the resolver returns null cleanly and the hook
942
+ // becomes a no-op (defensive: feedback is non-fatal).
943
+ //
944
+ // Skipped when the operator hasn't minted an agent NFT yet (matches the
945
+ // IdentityPublisher gating above).
946
+ let reputationFeedback;
947
+ if (agentId) {
948
+ const { getReputationRegistryAddress, ReputationRegistryClient } = await import('./erc8004/index.js');
949
+ const chainId = config.network === 'testnet' ? 84532 : 8453;
950
+ const reputationRegistryAddress = getReputationRegistryAddress(chainId);
951
+ if (reputationRegistryAddress) {
952
+ const reputationClient = new ReputationRegistryClient({
953
+ reputationRegistryAddress,
954
+ publicClient: agentClients.publicClient,
955
+ walletClient: agentClients.walletClient,
956
+ safeAddress,
957
+ });
958
+ const { resolveAgentIdForManifest } = await import('./erc8004/index.js');
959
+ const subgraphUrl = config.subgraphUrl;
960
+ reputationFeedback = {
961
+ client: reputationClient,
962
+ resolveAgentId: (manifestHash) => resolveAgentIdForManifest({ manifestHash, subgraphUrl }),
963
+ };
964
+ console.log(`[main] ReputationFeedback: registry=${reputationRegistryAddress}${subgraphUrl ? ` subgraph=${subgraphUrl}` : ' (no subgraph configured — resolver always null)'}`);
965
+ }
966
+ else {
967
+ console.log(`[main] ReputationFeedback: disabled (no canonical ReputationRegistry deployed on chainId=${chainId})`);
968
+ }
969
+ }
970
+ else {
971
+ console.log('[main] ReputationFeedback: disabled (no agent_id on active service — same gating as IdentityPublisher)');
972
+ }
973
+ // ── Auto Task generators (testnet only, opt-out via env) ─────────────────
974
+ const autoTasksDisabled = process.env['JINN_DISABLE_AUTO_TASKS'] === '1';
975
+ const { privateKeyToAccount: _pkToAccount } = await import('viem/accounts');
976
+ const agentEoaAddress = _pkToAccount(agentPrivateKey).address;
977
+ const { generators: autoTaskGenerators, logLines: autoTaskLogLines } = collectTestnetAutoTaskGenerators({
346
978
  network: config.network,
347
979
  rpcUrl: config.rpcUrl,
348
- autoIntentsDisabled,
980
+ autoTasksDisabled,
349
981
  env: process.env,
982
+ agentEoa: agentEoaAddress,
983
+ safeAddress,
984
+ agentPrivateKey,
985
+ predictionV0WindowMs: config.predictionV0WindowMs,
986
+ predictionV0ResolveGapMs: config.predictionV0ResolveGapMs,
350
987
  });
351
- for (const line of autoIntentLogLines) {
988
+ for (const line of autoTaskLogLines) {
352
989
  console.log(line);
353
990
  }
354
- if (config.network === 'mainnet' && !autoIntentsDisabled && BASE_FEEDS['ETH / USD']) {
355
- // Mainnet auto-intent opt-in only; default is OFF. Reserved for a future flag.
991
+ if (config.network === 'mainnet' && !autoTasksDisabled && BASE_FEEDS['ETH / USD']) {
992
+ // Mainnet auto-task opt-in only; default is OFF. Reserved for a future flag.
356
993
  }
357
- const intentSources = [
358
- new StaticConfiguredIntentSource(config.desiredStates),
359
- ...autoIntentGenerators.map(({ kind, generator }) => new GeneratedIntentSource(`generated:${kind}`, generator)),
994
+ const taskSources = [
995
+ new StaticConfiguredTaskSource(config.tasks),
996
+ ...autoTaskGenerators
997
+ .filter(({ solverType }) => solverNetRegistry.forSolverType(solverType)?.taskGenerator.enabled)
998
+ .map(({ solverType, generator }) => new GeneratedTaskSource(`generated:${solverType}`, generator)),
360
999
  ];
1000
+ // ── Corpus (daemon-side, jinn-mono-vy37.1.6) ─────────────────────────────
1001
+ //
1002
+ // Built once per daemon lifetime; the agent EOA private key stays in this
1003
+ // process's memory and never crosses into the MCP subprocess. The MCP
1004
+ // tool `acquire_artifact` proxies to `POST /v1/artifacts/acquire` instead.
1005
+ // Disabled when subgraphUrl is unset — the API route is then absent and
1006
+ // MCP falls back to local-only behaviour with a warning.
1007
+ const corpusFactory = config.subgraphUrl?.trim()
1008
+ ? (store) => (corpusForApi = createCorpus({
1009
+ subgraphUrl: config.subgraphUrl,
1010
+ ipfsGatewayUrl: config.ipfsGatewayUrl,
1011
+ store,
1012
+ signer: { privateKey: agentPrivateKey },
1013
+ selfSafeAddress: safeAddress,
1014
+ }))
1015
+ : undefined;
1016
+ if (!corpusFactory) {
1017
+ console.warn('[main] Corpus disabled (config.subgraphUrl not set); ' +
1018
+ 'MCP acquire_artifact / search_artifacts network branches will be unavailable.');
1019
+ }
361
1020
  const daemon = new Daemon({
362
1021
  adapter,
363
1022
  runner,
364
- intentSources,
1023
+ taskSources,
365
1024
  dbPath: config.dbPath,
1025
+ store: sharedStore,
1026
+ apiServer: setupApiServer,
366
1027
  pollIntervalMs: config.pollIntervalMs,
367
1028
  apiPort: config.apiPort,
1029
+ apiBindHost,
1030
+ apiToken,
368
1031
  peers: config.peers.length > 0 ? config.peers : undefined,
369
1032
  subgraphUrl: config.subgraphUrl,
370
1033
  nodeEndpoint: config.nodeEndpoint,
371
1034
  creatorSafeAddress: safeAddress,
1035
+ corpusFactory,
372
1036
  status: {
373
1037
  earningDir: config.earningDir,
374
1038
  rpcUrl: config.rpcUrl,
@@ -393,19 +1057,42 @@ export async function main() {
393
1057
  distributorAddress: CHAIN_CONFIG.distributorAddress,
394
1058
  }
395
1059
  : undefined,
1060
+ jinnClaim: l1ClientsForJinnClaim &&
1061
+ JINN_MVI_CONFIG.claimEmitter &&
1062
+ JINN_MVI_CONFIG.messenger &&
1063
+ JINN_MVI_CONFIG.distributor &&
1064
+ config.jinnClaimLoopIntervalMs > 0
1065
+ ? {
1066
+ intervalMs: config.jinnClaimLoopIntervalMs,
1067
+ l2Client: agentClients.publicClient,
1068
+ l2ProofClient,
1069
+ l2Wallet: agentClients.walletClient,
1070
+ l1Client: l1ClientsForJinnClaim.public,
1071
+ l1Wallet: l1ClientsForJinnClaim.wallet,
1072
+ store: earningStore,
1073
+ chain: NETWORK_CHAIN,
1074
+ claimEmitterAddress: JINN_MVI_CONFIG.claimEmitter,
1075
+ distributorAddress: JINN_MVI_CONFIG.distributor,
1076
+ messengerAddress: JINN_MVI_CONFIG.messenger,
1077
+ messengerMode: JINN_CLAIM_MESSENGER_MODE,
1078
+ optimismPortalAddress,
1079
+ disputeGameFactoryAddress,
1080
+ }
1081
+ : undefined,
396
1082
  restorationEngine: {
397
- // TODO(jinn-mono-cy4): RestorationEngineOptions has redundant registry+implRegistry
398
- // fields. Engine refactor should consolidate to one. Locked in this PR.
399
- registry: implRegistry,
400
1083
  paths: {
401
1084
  workingDirRoot: config.engine.workingDirRoot,
402
1085
  implStateDirRoot: config.engine.implStateDirRoot,
403
1086
  },
404
1087
  claimDeps,
405
1088
  packagingDeps,
406
- manifestDeps,
1089
+ envelopeDeps,
407
1090
  deliveryDeps,
408
1091
  implRegistry,
1092
+ solverNetRegistry,
1093
+ identityPublisher,
1094
+ reputationFeedback,
1095
+ operatorConfig,
409
1096
  },
410
1097
  balanceTopup: config.balanceTopupIntervalMs > 0
411
1098
  ? {
@@ -421,10 +1108,14 @@ export async function main() {
421
1108
  }
422
1109
  : undefined,
423
1110
  });
424
- // Graceful shutdown
1111
+ // Graceful shutdown — Daemon doesn't own the API server or Store in this
1112
+ // flow (they were created in setup-mode before bootstrap), so we close
1113
+ // them explicitly after Daemon.stop() completes.
425
1114
  const shutdown = async (signal) => {
426
1115
  console.log(`\n[main] Received ${signal}, shutting down...`);
427
1116
  await daemon.stop();
1117
+ await setupApiServer.close().catch(() => undefined);
1118
+ sharedStore.close();
428
1119
  console.log('[main] Shutdown complete.');
429
1120
  process.exit(0);
430
1121
  };
@@ -443,6 +1134,12 @@ export async function main() {
443
1134
  }
444
1135
  };
445
1136
  process.on('exit', removePidfile);
1137
+ emitProgress({
1138
+ type: 'progress',
1139
+ phase: 'daemon',
1140
+ step: 'starting',
1141
+ estimatedWaitMs: 5000,
1142
+ });
446
1143
  try {
447
1144
  await daemon.start();
448
1145
  }