@jinn-network/client 0.1.1 → 0.1.2-canary.6237288d

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 (424) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/CONTRIBUTING.md +123 -0
  3. package/README.md +213 -37
  4. package/deployments/deployment-claim-registry-baseSepolia.json +13 -0
  5. package/deployments/deployment-jinn-testnet-faucet-baseSepolia-fast.json +15 -0
  6. package/dist/adapters/adapter.d.ts +7 -0
  7. package/dist/adapters/claim-registry/abi.d.ts +127 -0
  8. package/dist/adapters/claim-registry/abi.js +93 -0
  9. package/dist/adapters/claim-registry/abi.js.map +1 -0
  10. package/dist/adapters/claim-registry/client.d.ts +89 -0
  11. package/dist/adapters/claim-registry/client.js +205 -0
  12. package/dist/adapters/claim-registry/client.js.map +1 -0
  13. package/dist/adapters/mech/adapter.d.ts +5 -0
  14. package/dist/adapters/mech/adapter.js +211 -56
  15. package/dist/adapters/mech/adapter.js.map +1 -1
  16. package/dist/adapters/mech/contracts.d.ts +19 -1
  17. package/dist/adapters/mech/contracts.js +112 -8
  18. package/dist/adapters/mech/contracts.js.map +1 -1
  19. package/dist/adapters/mech/ipfs.d.ts +38 -5
  20. package/dist/adapters/mech/ipfs.js +174 -17
  21. package/dist/adapters/mech/ipfs.js.map +1 -1
  22. package/dist/adapters/mech/safe.js +8 -6
  23. package/dist/adapters/mech/safe.js.map +1 -1
  24. package/dist/adapters/mech/types.d.ts +22 -46
  25. package/dist/adapters/mech/types.js +16 -35
  26. package/dist/adapters/mech/types.js.map +1 -1
  27. package/dist/api/balance-build.js +3 -3
  28. package/dist/api/balance-build.js.map +1 -1
  29. package/dist/api/fleet-build.js +35 -40
  30. package/dist/api/fleet-build.js.map +1 -1
  31. package/dist/api/gather-status.d.ts +6 -0
  32. package/dist/api/gather-status.js +187 -4
  33. package/dist/api/gather-status.js.map +1 -1
  34. package/dist/api/history-build.d.ts +5 -1
  35. package/dist/api/history-build.js +51 -26
  36. package/dist/api/history-build.js.map +1 -1
  37. package/dist/api/portfolio-v0-build.d.ts +83 -0
  38. package/dist/api/portfolio-v0-build.js +143 -0
  39. package/dist/api/portfolio-v0-build.js.map +1 -0
  40. package/dist/api/portfolio-v0-doctor.d.ts +37 -0
  41. package/dist/api/portfolio-v0-doctor.js +123 -0
  42. package/dist/api/portfolio-v0-doctor.js.map +1 -0
  43. package/dist/api/rewards-build.js +30 -14
  44. package/dist/api/rewards-build.js.map +1 -1
  45. package/dist/api/status-build.d.ts +39 -6
  46. package/dist/api/status-build.js +3 -1
  47. package/dist/api/status-build.js.map +1 -1
  48. package/dist/api/status-rollup-build.d.ts +2 -0
  49. package/dist/api/status-rollup-build.js +30 -3
  50. package/dist/api/status-rollup-build.js.map +1 -1
  51. package/dist/bin/jinn-mcp.d.ts +0 -12
  52. package/dist/bin/jinn-mcp.js +5 -14
  53. package/dist/bin/jinn-mcp.js.map +1 -1
  54. package/dist/build-meta.json +1 -1
  55. package/dist/cli/commands/auth.js +137 -25
  56. package/dist/cli/commands/auth.js.map +1 -1
  57. package/dist/cli/commands/balance.js +8 -1
  58. package/dist/cli/commands/balance.js.map +1 -1
  59. package/dist/cli/commands/bootstrap.js +23 -0
  60. package/dist/cli/commands/bootstrap.js.map +1 -1
  61. package/dist/cli/commands/doctor.js +160 -14
  62. package/dist/cli/commands/doctor.js.map +1 -1
  63. package/dist/cli/commands/fleet-scale.js +1 -0
  64. package/dist/cli/commands/fleet-scale.js.map +1 -1
  65. package/dist/cli/commands/fleet.js +10 -1
  66. package/dist/cli/commands/fleet.js.map +1 -1
  67. package/dist/cli/commands/fund-requirements.js +2 -0
  68. package/dist/cli/commands/fund-requirements.js.map +1 -1
  69. package/dist/cli/commands/history.js +25 -6
  70. package/dist/cli/commands/history.js.map +1 -1
  71. package/dist/cli/commands/intents.d.ts +17 -0
  72. package/dist/cli/commands/intents.js +489 -0
  73. package/dist/cli/commands/intents.js.map +1 -0
  74. package/dist/cli/commands/keys-backup.js +13 -11
  75. package/dist/cli/commands/keys-backup.js.map +1 -1
  76. package/dist/cli/commands/logs.js +35 -11
  77. package/dist/cli/commands/logs.js.map +1 -1
  78. package/dist/cli/commands/mcp.d.ts +3 -0
  79. package/dist/cli/commands/mcp.js +19 -0
  80. package/dist/cli/commands/mcp.js.map +1 -0
  81. package/dist/cli/commands/plugin-install.js +8 -4
  82. package/dist/cli/commands/plugin-install.js.map +1 -1
  83. package/dist/cli/commands/quickstart.js +99 -5
  84. package/dist/cli/commands/quickstart.js.map +1 -1
  85. package/dist/cli/commands/rewards.js +27 -1
  86. package/dist/cli/commands/rewards.js.map +1 -1
  87. package/dist/cli/commands/run.js +38 -0
  88. package/dist/cli/commands/run.js.map +1 -1
  89. package/dist/cli/commands/status.js +11 -1
  90. package/dist/cli/commands/status.js.map +1 -1
  91. package/dist/cli/commands/submit-intent.js +110 -44
  92. package/dist/cli/commands/submit-intent.js.map +1 -1
  93. package/dist/cli/commands/version.js +1 -0
  94. package/dist/cli/commands/version.js.map +1 -1
  95. package/dist/cli/deployment-digest.js +5 -0
  96. package/dist/cli/deployment-digest.js.map +1 -1
  97. package/dist/cli/execution-context.js +1 -0
  98. package/dist/cli/execution-context.js.map +1 -1
  99. package/dist/cli/index.js +4 -0
  100. package/dist/cli/index.js.map +1 -1
  101. package/dist/cli/intent-registry-access.d.ts +62 -0
  102. package/dist/cli/intent-registry-access.js +165 -0
  103. package/dist/cli/intent-registry-access.js.map +1 -0
  104. package/dist/cli/introspection-context.js +12 -8
  105. package/dist/cli/introspection-context.js.map +1 -1
  106. package/dist/cli/password.d.ts +21 -9
  107. package/dist/cli/password.js +45 -24
  108. package/dist/cli/password.js.map +1 -1
  109. package/dist/config.d.ts +137 -8
  110. package/dist/config.js +70 -12
  111. package/dist/config.js.map +1 -1
  112. package/dist/daemon/balance-topup-loop.js +32 -4
  113. package/dist/daemon/balance-topup-loop.js.map +1 -1
  114. package/dist/daemon/creator.d.ts +7 -4
  115. package/dist/daemon/creator.js +55 -26
  116. package/dist/daemon/creator.js.map +1 -1
  117. package/dist/daemon/daemon.d.ts +35 -3
  118. package/dist/daemon/daemon.js +99 -7
  119. package/dist/daemon/daemon.js.map +1 -1
  120. package/dist/daemon/delivery-watcher.d.ts +3 -1
  121. package/dist/daemon/delivery-watcher.js +19 -1
  122. package/dist/daemon/delivery-watcher.js.map +1 -1
  123. package/dist/daemon/reward-claim-loop.js +38 -1
  124. package/dist/daemon/reward-claim-loop.js.map +1 -1
  125. package/dist/dashboard/index.html +71 -496
  126. package/dist/discovery/registry.d.ts +54 -0
  127. package/dist/discovery/registry.js +73 -0
  128. package/dist/discovery/registry.js.map +1 -1
  129. package/dist/earning/bootstrap.d.ts +2 -1
  130. package/dist/earning/bootstrap.js +71 -33
  131. package/dist/earning/bootstrap.js.map +1 -1
  132. package/dist/earning/contracts.d.ts +10 -0
  133. package/dist/earning/contracts.js +24 -0
  134. package/dist/earning/contracts.js.map +1 -1
  135. package/dist/earning/jinn-rewards.d.ts +9 -0
  136. package/dist/earning/jinn-rewards.js +7 -0
  137. package/dist/earning/jinn-rewards.js.map +1 -1
  138. package/dist/earning/stolas-claim.d.ts +6 -0
  139. package/dist/earning/stolas-claim.js +7 -0
  140. package/dist/earning/stolas-claim.js.map +1 -1
  141. package/dist/intents/kinds/constants.d.ts +5 -0
  142. package/dist/intents/kinds/constants.js +6 -0
  143. package/dist/intents/kinds/constants.js.map +1 -0
  144. package/dist/intents/kinds/index.d.ts +28 -0
  145. package/dist/intents/kinds/index.js +50 -0
  146. package/dist/intents/kinds/index.js.map +1 -0
  147. package/dist/intents/kinds/portfolio-v0.d.ts +2 -0
  148. package/dist/intents/kinds/portfolio-v0.js +13 -0
  149. package/dist/intents/kinds/portfolio-v0.js.map +1 -0
  150. package/dist/intents/kinds/prediction-apy-v0.d.ts +3 -0
  151. package/dist/intents/kinds/prediction-apy-v0.js +21 -0
  152. package/dist/intents/kinds/prediction-apy-v0.js.map +1 -0
  153. package/dist/intents/kinds/prediction-v0.d.ts +3 -0
  154. package/dist/intents/kinds/prediction-v0.js +32 -0
  155. package/dist/intents/kinds/prediction-v0.js.map +1 -0
  156. package/dist/intents/kinds/spec-kind.d.ts +38 -0
  157. package/dist/intents/kinds/spec-kind.js +6 -0
  158. package/dist/intents/kinds/spec-kind.js.map +1 -0
  159. package/dist/intents/posting-service.d.ts +26 -0
  160. package/dist/intents/posting-service.js +218 -0
  161. package/dist/intents/posting-service.js.map +1 -0
  162. package/dist/intents/prediction-apy-v0-auto.d.ts +11 -0
  163. package/dist/intents/prediction-apy-v0-auto.js +46 -0
  164. package/dist/intents/prediction-apy-v0-auto.js.map +1 -0
  165. package/dist/intents/prediction-apy-v0-template.d.ts +8 -0
  166. package/dist/intents/prediction-apy-v0-template.js +22 -0
  167. package/dist/intents/prediction-apy-v0-template.js.map +1 -0
  168. package/dist/intents/prediction-v0-auto.d.ts +53 -0
  169. package/dist/intents/prediction-v0-auto.js +84 -0
  170. package/dist/intents/prediction-v0-auto.js.map +1 -0
  171. package/dist/intents/prediction-v0-template.d.ts +70 -0
  172. package/dist/intents/prediction-v0-template.js +145 -0
  173. package/dist/intents/prediction-v0-template.js.map +1 -0
  174. package/dist/intents/sources.d.ts +39 -0
  175. package/dist/intents/sources.js +42 -0
  176. package/dist/intents/sources.js.map +1 -0
  177. package/dist/main.js +175 -3
  178. package/dist/main.js.map +1 -1
  179. package/dist/mcp/operator-server.d.ts +1 -1
  180. package/dist/mcp/operator-server.js +1 -1
  181. package/dist/mcp/server.js +8 -4
  182. package/dist/mcp/server.js.map +1 -1
  183. package/dist/observability/emit-event.d.ts +12 -0
  184. package/dist/observability/emit-event.js +27 -0
  185. package/dist/observability/emit-event.js.map +1 -0
  186. package/dist/preflight/api-port.d.ts +13 -0
  187. package/dist/preflight/api-port.js +32 -0
  188. package/dist/preflight/api-port.js.map +1 -0
  189. package/dist/preflight/claude-auth.d.ts +12 -1
  190. package/dist/preflight/claude-auth.js +21 -3
  191. package/dist/preflight/claude-auth.js.map +1 -1
  192. package/dist/preflight/rpc-network.d.ts +44 -0
  193. package/dist/preflight/rpc-network.js +121 -0
  194. package/dist/preflight/rpc-network.js.map +1 -0
  195. package/dist/restorer/engine/canonical-json.d.ts +18 -0
  196. package/dist/restorer/engine/canonical-json.js +59 -0
  197. package/dist/restorer/engine/canonical-json.js.map +1 -0
  198. package/dist/restorer/engine/claim.d.ts +69 -0
  199. package/dist/restorer/engine/claim.js +104 -0
  200. package/dist/restorer/engine/claim.js.map +1 -0
  201. package/dist/restorer/engine/delivery.d.ts +52 -0
  202. package/dist/restorer/engine/delivery.js +63 -0
  203. package/dist/restorer/engine/delivery.js.map +1 -0
  204. package/dist/restorer/engine/engine.d.ts +213 -0
  205. package/dist/restorer/engine/engine.js +769 -0
  206. package/dist/restorer/engine/engine.js.map +1 -0
  207. package/dist/restorer/engine/manifest-assembly.d.ts +67 -0
  208. package/dist/restorer/engine/manifest-assembly.js +79 -0
  209. package/dist/restorer/engine/manifest-assembly.js.map +1 -0
  210. package/dist/restorer/engine/packaging.d.ts +87 -0
  211. package/dist/restorer/engine/packaging.js +350 -0
  212. package/dist/restorer/engine/packaging.js.map +1 -0
  213. package/dist/restorer/engine/persistence.d.ts +170 -0
  214. package/dist/restorer/engine/persistence.js +381 -0
  215. package/dist/restorer/engine/persistence.js.map +1 -0
  216. package/dist/restorer/engine/recovery.d.ts +22 -0
  217. package/dist/restorer/engine/recovery.js +24 -0
  218. package/dist/restorer/engine/recovery.js.map +1 -0
  219. package/dist/restorer/engine/registry.d.ts +62 -0
  220. package/dist/restorer/engine/registry.js +73 -0
  221. package/dist/restorer/engine/registry.js.map +1 -0
  222. package/dist/restorer/engine/signing.d.ts +30 -0
  223. package/dist/restorer/engine/signing.js +39 -0
  224. package/dist/restorer/engine/signing.js.map +1 -0
  225. package/dist/restorer/engine/state.d.ts +42 -0
  226. package/dist/restorer/engine/state.js +87 -0
  227. package/dist/restorer/engine/state.js.map +1 -0
  228. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.d.ts +64 -0
  229. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js +96 -0
  230. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js.map +1 -0
  231. package/dist/restorer/impls/claude-mcp-hyperliquid/index.d.ts +104 -0
  232. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js +721 -0
  233. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js.map +1 -0
  234. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.d.ts +137 -0
  235. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js +865 -0
  236. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js.map +1 -0
  237. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.d.ts +74 -0
  238. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js +74 -0
  239. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js.map +1 -0
  240. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +97 -0
  241. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js +226 -0
  242. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +1 -0
  243. package/dist/restorer/impls/claude-mcp-prediction/index.d.ts +44 -0
  244. package/dist/restorer/impls/claude-mcp-prediction/index.js +239 -0
  245. package/dist/restorer/impls/claude-mcp-prediction/index.js.map +1 -0
  246. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.d.ts +38 -0
  247. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js +135 -0
  248. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js.map +1 -0
  249. package/dist/restorer/impls/claude-mcp-prediction/prompt.d.ts +8 -0
  250. package/dist/restorer/impls/claude-mcp-prediction/prompt.js +54 -0
  251. package/dist/restorer/impls/claude-mcp-prediction/prompt.js.map +1 -0
  252. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.d.ts +36 -0
  253. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js +137 -0
  254. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js.map +1 -0
  255. package/dist/restorer/impls/claude-mcp-prediction/types.d.ts +84 -0
  256. package/dist/restorer/impls/claude-mcp-prediction/types.js +6 -0
  257. package/dist/restorer/impls/claude-mcp-prediction/types.js.map +1 -0
  258. package/dist/restorer/impls/claude-mcp-prediction-apy/index.d.ts +34 -0
  259. package/dist/restorer/impls/claude-mcp-prediction-apy/index.js +233 -0
  260. package/dist/restorer/impls/claude-mcp-prediction-apy/index.js.map +1 -0
  261. package/dist/restorer/impls/claude-mcp-prediction-apy/mcp-tools.d.ts +18 -0
  262. package/dist/restorer/impls/claude-mcp-prediction-apy/mcp-tools.js +136 -0
  263. package/dist/restorer/impls/claude-mcp-prediction-apy/mcp-tools.js.map +1 -0
  264. package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.d.ts +7 -0
  265. package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.js +46 -0
  266. package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.js.map +1 -0
  267. package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.d.ts +27 -0
  268. package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js +128 -0
  269. package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js.map +1 -0
  270. package/dist/restorer/impls/claude-mcp-prediction-apy/types.d.ts +64 -0
  271. package/dist/restorer/impls/claude-mcp-prediction-apy/types.js +6 -0
  272. package/dist/restorer/impls/claude-mcp-prediction-apy/types.js.map +1 -0
  273. package/dist/restorer/impls/evaluation-context.d.ts +16 -0
  274. package/dist/restorer/impls/evaluation-context.js +18 -0
  275. package/dist/restorer/impls/evaluation-context.js.map +1 -0
  276. package/dist/restorer/impls/index.d.ts +46 -0
  277. package/dist/restorer/impls/index.js +88 -0
  278. package/dist/restorer/impls/index.js.map +1 -0
  279. package/dist/restorer/impls/legacy-claude/index.d.ts +52 -0
  280. package/dist/restorer/impls/legacy-claude/index.js +140 -0
  281. package/dist/restorer/impls/legacy-claude/index.js.map +1 -0
  282. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +68 -0
  283. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js +117 -0
  284. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js.map +1 -0
  285. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.d.ts +49 -0
  286. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js +91 -0
  287. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js.map +1 -0
  288. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.d.ts +78 -0
  289. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js +274 -0
  290. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js.map +1 -0
  291. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +23 -0
  292. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js +49 -0
  293. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js.map +1 -0
  294. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.d.ts +25 -0
  295. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js +44 -0
  296. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js.map +1 -0
  297. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.d.ts +17 -0
  298. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js +43 -0
  299. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js.map +1 -0
  300. package/dist/restorer/impls/portfolio-v0-evaluator/index.d.ts +44 -0
  301. package/dist/restorer/impls/portfolio-v0-evaluator/index.js +440 -0
  302. package/dist/restorer/impls/portfolio-v0-evaluator/index.js.map +1 -0
  303. package/dist/restorer/impls/portfolio-v0-evaluator/score.d.ts +21 -0
  304. package/dist/restorer/impls/portfolio-v0-evaluator/score.js +32 -0
  305. package/dist/restorer/impls/portfolio-v0-evaluator/score.js.map +1 -0
  306. package/dist/restorer/impls/portfolio-v0-evaluator/types.d.ts +34 -0
  307. package/dist/restorer/impls/portfolio-v0-evaluator/types.js +8 -0
  308. package/dist/restorer/impls/portfolio-v0-evaluator/types.js.map +1 -0
  309. package/dist/restorer/impls/prediction-apy-v0-baseline/index.d.ts +40 -0
  310. package/dist/restorer/impls/prediction-apy-v0-baseline/index.js +107 -0
  311. package/dist/restorer/impls/prediction-apy-v0-baseline/index.js.map +1 -0
  312. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.d.ts +2 -0
  313. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js +7 -0
  314. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js.map +1 -0
  315. package/dist/restorer/impls/prediction-apy-v0-baseline/types.d.ts +4 -0
  316. package/dist/restorer/impls/prediction-apy-v0-baseline/types.js +2 -0
  317. package/dist/restorer/impls/prediction-apy-v0-baseline/types.js.map +1 -0
  318. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +6 -0
  319. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js +11 -0
  320. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +1 -0
  321. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.d.ts +42 -0
  322. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js +208 -0
  323. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js.map +1 -0
  324. package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.d.ts +7 -0
  325. package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js +29 -0
  326. package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js.map +1 -0
  327. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.d.ts +9 -0
  328. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js +20 -0
  329. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js.map +1 -0
  330. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.d.ts +7 -0
  331. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js +2 -0
  332. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js.map +1 -0
  333. package/dist/restorer/impls/prediction-v0-baseline/index.d.ts +31 -0
  334. package/dist/restorer/impls/prediction-v0-baseline/index.js +100 -0
  335. package/dist/restorer/impls/prediction-v0-baseline/index.js.map +1 -0
  336. package/dist/restorer/impls/prediction-v0-baseline/strategy.d.ts +8 -0
  337. package/dist/restorer/impls/prediction-v0-baseline/strategy.js +41 -0
  338. package/dist/restorer/impls/prediction-v0-baseline/strategy.js.map +1 -0
  339. package/dist/restorer/impls/prediction-v0-baseline/types.d.ts +7 -0
  340. package/dist/restorer/impls/prediction-v0-baseline/types.js +2 -0
  341. package/dist/restorer/impls/prediction-v0-baseline/types.js.map +1 -0
  342. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.d.ts +20 -0
  343. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js +66 -0
  344. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js.map +1 -0
  345. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.d.ts +9 -0
  346. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js +23 -0
  347. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js.map +1 -0
  348. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.d.ts +3 -0
  349. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js +13 -0
  350. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js.map +1 -0
  351. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.d.ts +13 -0
  352. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js +111 -0
  353. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js.map +1 -0
  354. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.d.ts +5 -0
  355. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js +20 -0
  356. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js.map +1 -0
  357. package/dist/restorer/impls/prediction-v0-evaluator/index.d.ts +36 -0
  358. package/dist/restorer/impls/prediction-v0-evaluator/index.js +234 -0
  359. package/dist/restorer/impls/prediction-v0-evaluator/index.js.map +1 -0
  360. package/dist/restorer/impls/prediction-v0-evaluator/score.d.ts +8 -0
  361. package/dist/restorer/impls/prediction-v0-evaluator/score.js +15 -0
  362. package/dist/restorer/impls/prediction-v0-evaluator/score.js.map +1 -0
  363. package/dist/restorer/impls/prediction-v0-evaluator/types.d.ts +7 -0
  364. package/dist/restorer/impls/prediction-v0-evaluator/types.js +2 -0
  365. package/dist/restorer/impls/prediction-v0-evaluator/types.js.map +1 -0
  366. package/dist/restorer/types.d.ts +194 -0
  367. package/dist/restorer/types.js +28 -0
  368. package/dist/restorer/types.js.map +1 -0
  369. package/dist/rpc-error-context.d.ts +10 -0
  370. package/dist/rpc-error-context.js +26 -0
  371. package/dist/rpc-error-context.js.map +1 -0
  372. package/dist/store/store.d.ts +101 -1
  373. package/dist/store/store.js +334 -4
  374. package/dist/store/store.js.map +1 -1
  375. package/dist/trajectory/schema.d.ts +510 -0
  376. package/dist/trajectory/schema.js +74 -0
  377. package/dist/trajectory/schema.js.map +1 -0
  378. package/dist/types/desired-state.d.ts +53 -0
  379. package/dist/types/desired-state.js +20 -0
  380. package/dist/types/desired-state.js.map +1 -1
  381. package/dist/types/index.d.ts +4 -1
  382. package/dist/types/index.js +4 -1
  383. package/dist/types/index.js.map +1 -1
  384. package/dist/types/portfolio.d.ts +1000 -0
  385. package/dist/types/portfolio.js +168 -0
  386. package/dist/types/portfolio.js.map +1 -0
  387. package/dist/types/prediction-apy.d.ts +930 -0
  388. package/dist/types/prediction-apy.js +133 -0
  389. package/dist/types/prediction-apy.js.map +1 -0
  390. package/dist/types/prediction.d.ts +926 -0
  391. package/dist/types/prediction.js +141 -0
  392. package/dist/types/prediction.js.map +1 -0
  393. package/dist/venues/aave-v3/addresses.d.ts +6 -0
  394. package/dist/venues/aave-v3/addresses.js +19 -0
  395. package/dist/venues/aave-v3/addresses.js.map +1 -0
  396. package/dist/venues/aave-v3/client.d.ts +85 -0
  397. package/dist/venues/aave-v3/client.js +106 -0
  398. package/dist/venues/aave-v3/client.js.map +1 -0
  399. package/dist/venues/chainlink/client.d.ts +99 -0
  400. package/dist/venues/chainlink/client.js +130 -0
  401. package/dist/venues/chainlink/client.js.map +1 -0
  402. package/dist/venues/chainlink/feeds.d.ts +8 -0
  403. package/dist/venues/chainlink/feeds.js +9 -0
  404. package/dist/venues/chainlink/feeds.js.map +1 -0
  405. package/dist/venues/hyperliquid/account-value.d.ts +30 -0
  406. package/dist/venues/hyperliquid/account-value.js +30 -0
  407. package/dist/venues/hyperliquid/account-value.js.map +1 -0
  408. package/dist/venues/hyperliquid/client.d.ts +63 -0
  409. package/dist/venues/hyperliquid/client.js +135 -0
  410. package/dist/venues/hyperliquid/client.js.map +1 -0
  411. package/dist/venues/hyperliquid/grid.d.ts +36 -0
  412. package/dist/venues/hyperliquid/grid.js +61 -0
  413. package/dist/venues/hyperliquid/grid.js.map +1 -0
  414. package/dist/venues/hyperliquid/types.d.ts +81 -0
  415. package/dist/venues/hyperliquid/types.js +8 -0
  416. package/dist/venues/hyperliquid/types.js.map +1 -0
  417. package/dist/withdraw/run-withdraw-plan.js +2 -0
  418. package/dist/withdraw/run-withdraw-plan.js.map +1 -1
  419. package/docker-compose.yml +44 -0
  420. package/package.json +15 -3
  421. package/skills/jinn-operator/SKILL.md +85 -0
  422. package/dist/daemon/restorer.d.ts +0 -19
  423. package/dist/daemon/restorer.js +0 -82
  424. package/dist/daemon/restorer.js.map +0 -1
@@ -0,0 +1,234 @@
1
+ /**
2
+ * prediction-v0-evaluator — deterministic verifier for prediction.v0.
3
+ *
4
+ * §6 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ *
6
+ * Pipeline: availability → eligibility → integrity → spec → verdict.
7
+ * Score: brier.v1 scaled to 1e18 fixed-point.
8
+ */
9
+ import { writeFileSync } from 'node:fs';
10
+ import { join } from 'node:path';
11
+ import { createPublicClient, http, keccak256, stringToHex } from 'viem';
12
+ import { baseSepolia, base } from 'viem/chains';
13
+ import { privateKeyToAccount } from 'viem/accounts';
14
+ import { REQUIRES_LIVE_DAEMON_READINESS } from '../../types.js';
15
+ import { PredictionV0IntentSchema, PredictionSubmissionManifestSchema, } from '../../../types/prediction.js';
16
+ import { oraclePriceAtResolveTs, scaleToDecimal, } from '../../../venues/chainlink/client.js';
17
+ import { resolveGroundTruth } from './canonical-metrics.js';
18
+ import { computeScore } from './score.js';
19
+ import { checkOracleReachable, checkOracleRoundCoversResolveTs } from './checks/availability.js';
20
+ import { checkSubmissionWithinWindow } from './checks/eligibility.js';
21
+ import { checkWindowBounds, checkManifestFieldsPresent, checkManifestSignature, checkIntentRef, checkIntentRefMissingExpected, recomputeTopLevelSignatureHash, } from './checks/integrity.js';
22
+ import { resolveExpectedRestorationIntentCid } from '../evaluation-context.js';
23
+ import { checkQuestionKindSupported } from './checks/spec.js';
24
+ function parseRestorationSubmissionManifest(manifestJson) {
25
+ const raw = JSON.parse(manifestJson);
26
+ const direct = PredictionSubmissionManifestSchema.safeParse(raw);
27
+ if (direct.success)
28
+ return direct.data;
29
+ if (raw['schemaVersion'] !== 'portfolio.v0.manifest.v1') {
30
+ return PredictionSubmissionManifestSchema.parse(raw);
31
+ }
32
+ const gating = raw['gating'];
33
+ const informational = raw['informational'];
34
+ const oracleSnapshot = informational?.['oracleSnapshot'];
35
+ const normalized = {
36
+ schemaVersion: 'prediction.v0.submission.v1',
37
+ generatedAt: raw['generatedAt'],
38
+ intent: raw['intent'],
39
+ restorer: raw['restorer'],
40
+ window: raw['window'],
41
+ prediction: {
42
+ probability: String(gating?.['probability'] ?? ''),
43
+ submittedAt: Number(gating?.['submittedAt']),
44
+ modelId: String(gating?.['modelId'] ?? ''),
45
+ },
46
+ ...(oracleSnapshot && typeof oracleSnapshot === 'object'
47
+ ? { oracleSnapshot }
48
+ : {}),
49
+ signature: raw['signature'],
50
+ };
51
+ return PredictionSubmissionManifestSchema.parse(normalized);
52
+ }
53
+ export class PredictionV0Evaluator {
54
+ config;
55
+ name = 'prediction-v0-evaluator';
56
+ version = '1.0.0';
57
+ constructor(config) {
58
+ this.config = config;
59
+ }
60
+ supports(ctx) {
61
+ return ctx.kind === 'prediction.v0' && ctx.type === 'evaluation';
62
+ }
63
+ async isReady() {
64
+ if (this.config.stub)
65
+ return { ...REQUIRES_LIVE_DAEMON_READINESS };
66
+ return { ready: true };
67
+ }
68
+ async canAttempt(intent) {
69
+ if (intent.spec?.kind !== 'prediction.v0')
70
+ return { ok: false, reason: 'spec.kind is not prediction.v0' };
71
+ if (intent.type !== 'evaluation')
72
+ return { ok: false, reason: 'type is not evaluation' };
73
+ if (!intent.restorationRequestId)
74
+ return { ok: false, reason: 'restorationRequestId is required' };
75
+ if (typeof intent.context?.['restorationResult'] !== 'string') {
76
+ return { ok: false, reason: 'context.restorationResult required' };
77
+ }
78
+ return { ok: true };
79
+ }
80
+ async run(ctx) {
81
+ if (this.config.stub) {
82
+ throw new Error('prediction-v0-evaluator: stub registry cannot run evaluation (requires live daemon)');
83
+ }
84
+ if (!this.config.evaluatorPk || !this.config.evaluatorSafeAddress) {
85
+ throw new Error('prediction-v0-evaluator: evaluatorPk and evaluatorSafeAddress are required');
86
+ }
87
+ const { intent, workingDir, log } = ctx;
88
+ // Support _testDeps injection from ctx (test) or config (constructor).
89
+ const testDeps = ctx._testDeps ?? this.config._testDeps;
90
+ const expectedRef = resolveExpectedRestorationIntentCid(intent, testDeps);
91
+ // 1. Parse intent — same spec the restorer ran under
92
+ const predictionIntent = PredictionV0IntentSchema.parse(intent);
93
+ const { feed, venue } = predictionIntent.spec.oracle;
94
+ // 2. Parse restorer's manifest from inlined context
95
+ const manifestJson = intent.context['restorationResult'];
96
+ const rawPayload = JSON.parse(manifestJson);
97
+ const manifest = parseRestorationSubmissionManifest(manifestJson);
98
+ // 3. Fetch Chainlink spanning round
99
+ let spanning;
100
+ if (testDeps?.oraclePriceAtResolveTs) {
101
+ spanning = await testDeps.oraclePriceAtResolveTs(feed, predictionIntent.spec.question.resolveTs);
102
+ }
103
+ else {
104
+ const expectedChainId = venue === 'chainlink-base' ? 8453 : 84532;
105
+ const chain = venue === 'chainlink-base' ? base : baseSepolia;
106
+ const publicClient = createPublicClient({
107
+ chain,
108
+ transport: http(this.config.rpcUrl),
109
+ });
110
+ const actualChainId = await publicClient.getChainId();
111
+ if (actualChainId !== expectedChainId) {
112
+ throw new Error(`oracle venue mismatch: spec says ${venue} (chainId ${expectedChainId}) but RPC chainId is ${actualChainId}`);
113
+ }
114
+ spanning = await oraclePriceAtResolveTs(feed, predictionIntent.spec.question.resolveTs, publicClient);
115
+ }
116
+ // 4. Run checks (order matters: availability → eligibility → integrity → spec)
117
+ const checks = [];
118
+ // availability — oracle reachable (already fetched above; re-wrap to surface errors)
119
+ checks.push(await checkOracleReachable(async () => spanning));
120
+ checks.push(checkOracleRoundCoversResolveTs(spanning));
121
+ // eligibility
122
+ checks.push(checkSubmissionWithinWindow(manifest.prediction.submittedAt, predictionIntent.window));
123
+ // integrity
124
+ checks.push(checkWindowBounds(predictionIntent));
125
+ checks.push(checkManifestFieldsPresent(manifest.prediction));
126
+ {
127
+ const recomputed = recomputeTopLevelSignatureHash(rawPayload);
128
+ checks.push(await checkManifestSignature(recomputed, manifest.signature));
129
+ }
130
+ if (expectedRef.kind === 'missing') {
131
+ checks.push(checkIntentRefMissingExpected());
132
+ }
133
+ else {
134
+ checks.push(checkIntentRef(manifest.intent.cid, expectedRef.cid));
135
+ }
136
+ // spec
137
+ checks.push(checkQuestionKindSupported(predictionIntent.spec.question));
138
+ // 5. Derive verdict
139
+ const verdict = deriveVerdict(checks);
140
+ // 6. Derive ground truth + score
141
+ const priceAtResolve = scaleToDecimal(spanning.round.answer, spanning.round.decimals);
142
+ const groundTruth = resolveGroundTruth(predictionIntent.spec.question, priceAtResolve);
143
+ const { score, scoreBasis, scoreVersion } = computeScore(verdict, manifest.prediction.probability, groundTruth);
144
+ // 7. Assemble + sign verdict manifest
145
+ const evaluatorAccount = privateKeyToAccount(this.config.evaluatorPk);
146
+ const verdictManifestBase = {
147
+ schemaVersion: 'prediction.v0.verdict.v1',
148
+ generatedAt: Date.now(),
149
+ intent: manifest.intent,
150
+ evaluator: { safeAddress: this.config.evaluatorSafeAddress, agentEoa: evaluatorAccount.address },
151
+ window: predictionIntent.window,
152
+ verdict,
153
+ score,
154
+ scoreBasis,
155
+ scoreVersion,
156
+ oracleReading: {
157
+ feed: feed,
158
+ roundId: String(spanning.round.roundId),
159
+ answer: String(spanning.round.answer),
160
+ updatedAt: spanning.round.updatedAt,
161
+ ...(spanning.nextRound ? { nextRoundUpdatedAt: spanning.nextRound.updatedAt } : {}),
162
+ },
163
+ claimed: {
164
+ probability: manifest.prediction.probability,
165
+ submittedAt: manifest.prediction.submittedAt,
166
+ modelId: manifest.prediction.modelId,
167
+ // Omitted when no IPFS submission CID is available (inline / dev).
168
+ },
169
+ groundTruth,
170
+ checks,
171
+ };
172
+ const canonical = JSON.stringify(verdictManifestBase);
173
+ const hash = keccak256(stringToHex(canonical));
174
+ // Raw ECDSA — no EIP-191 prefix. recoverAddress (not recoverMessageAddress) on verify.
175
+ const sig = await evaluatorAccount.sign({ hash });
176
+ const verdictManifest = {
177
+ ...verdictManifestBase,
178
+ signature: { algo: 'secp256k1', signer: evaluatorAccount.address, hash, sig },
179
+ };
180
+ writeFileSync(join(workingDir, 'verdict.json'), JSON.stringify(verdictManifest, null, 2));
181
+ log({ level: 'info', msg: 'prediction-v0-evaluator: verdict', data: { verdict, score, groundTruth } });
182
+ return {
183
+ venueRef: { name: 'chainlink' },
184
+ gating: {
185
+ verdict,
186
+ score,
187
+ scoreBasis,
188
+ groundTruth,
189
+ checkCount: checks.length,
190
+ passCount: checks.filter(c => c.status === 'PASS').length,
191
+ failCount: checks.filter(c => c.status === 'FAIL').length,
192
+ skipCount: checks.filter(c => c.status === 'SKIP').length,
193
+ },
194
+ informational: {
195
+ claimedProbability: manifest.prediction.probability,
196
+ oracleReading: verdictManifestBase.oracleReading,
197
+ },
198
+ artifacts: [
199
+ {
200
+ path: 'verdict.json',
201
+ role: 'evaluation_verdict',
202
+ metadata: { verdict, score, schemaVersion: 'prediction.v0.verdict.v1' },
203
+ access: { kind: 'open' },
204
+ },
205
+ ],
206
+ };
207
+ }
208
+ }
209
+ /**
210
+ * Derive verdict from check statuses.
211
+ * Order matters: data-availability failures precede attempt-quality failures.
212
+ */
213
+ function deriveVerdict(checks) {
214
+ // Any availability FAIL → INDETERMINATE (oracle unreachable, data gaps)
215
+ if (checks.some(c => c.name.startsWith('availability.') && c.status === 'FAIL'))
216
+ return 'INDETERMINATE';
217
+ // Any availability SKIP → INDETERMINATE (oracle not yet spanning)
218
+ if (checks.some(c => c.name.startsWith('availability.') && c.status === 'SKIP'))
219
+ return 'INDETERMINATE';
220
+ // Missing trust anchor for intent CID (e.g. legacy eval payload) → INDETERMINATE
221
+ if (checks.some(c => c.name.startsWith('integrity.') && c.status === 'INDETERMINATE'))
222
+ return 'INDETERMINATE';
223
+ // Any eligibility FAIL → REJECTED
224
+ if (checks.some(c => c.name.startsWith('eligibility.') && c.status === 'FAIL'))
225
+ return 'REJECTED';
226
+ // Any integrity or spec FAIL → FAIL
227
+ if (checks.some(c => c.name.startsWith('integrity.') && c.status === 'FAIL') ||
228
+ checks.some(c => c.name.startsWith('spec.') && c.status === 'FAIL')) {
229
+ return 'FAIL';
230
+ }
231
+ return 'PASS';
232
+ }
233
+ export default PredictionV0Evaluator;
234
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-evaluator/index.ts"],"names":[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AK,eAAe,CAAC;QAAE,OAAO,eAAe,CAAC;IAC9G,kCAAkC;IAClC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;QAAE,OAAO,UAAU,CAAC;IAClG,oCAAoC;IACpC,IACE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;QACxE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,EACnE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const SCORE_BASIS: "brier.v1";
2
+ export declare const SCORE_VERSION: "1";
3
+ export type Verdict = 'PASS' | 'FAIL' | 'REJECTED' | 'INDETERMINATE';
4
+ export declare function computeScore(verdict: Verdict, probability: string, groundTruth: 'YES' | 'NO'): {
5
+ score: string;
6
+ scoreBasis: typeof SCORE_BASIS;
7
+ scoreVersion: typeof SCORE_VERSION;
8
+ };
@@ -0,0 +1,15 @@
1
+ import { brierScore } from './canonical-metrics.js';
2
+ export const SCORE_BASIS = 'brier.v1';
3
+ export const SCORE_VERSION = '1';
4
+ export function computeScore(verdict, probability, groundTruth) {
5
+ if (verdict !== 'PASS') {
6
+ return { score: '0', scoreBasis: SCORE_BASIS, scoreVersion: SCORE_VERSION };
7
+ }
8
+ const outcome = groundTruth === 'YES' ? 1 : 0;
9
+ return {
10
+ score: brierScore(probability, outcome),
11
+ scoreBasis: SCORE_BASIS,
12
+ scoreVersion: SCORE_VERSION,
13
+ };
14
+ }
15
+ //# sourceMappingURL=score.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-evaluator/score.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,UAAmB,CAAC;AAC/C,MAAM,CAAC,MAAM,aAAa,GAAG,GAAY,CAAC;AAI1C,MAAM,UAAU,YAAY,CAC1B,OAAgB,EAChB,WAAmB,EACnB,WAAyB;IAEzB,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;IAC9E,CAAC;IACD,MAAM,OAAO,GAAG,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,OAAO;QACL,KAAK,EAAE,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC;QACvC,UAAU,EAAE,WAAW;QACvB,YAAY,EAAE,aAAa;KAC5B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type CheckStatus = 'PASS' | 'FAIL' | 'SKIP' | 'INDETERMINATE';
2
+ export interface Check {
3
+ name: string;
4
+ status: CheckStatus;
5
+ detail?: string | Record<string, unknown>;
6
+ }
7
+ export type Verdict = 'PASS' | 'FAIL' | 'REJECTED' | 'INDETERMINATE';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-evaluator/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Restorer-impl interface — §6.7 of the portfolio.v0 design spec.
3
+ *
4
+ * Pure type definitions; no runtime side effects.
5
+ */
6
+ import type { DesiredState } from '../types/desired-state.js';
7
+ import type { OutputArtifact, RationaleEntry, Snapshot } from '../types/portfolio.js';
8
+ export interface RestorationContext {
9
+ intent: DesiredState;
10
+ /**
11
+ * IPFS CID of this job's desired state (from Marketplace / observe).
12
+ * Restorers' submission manifests should reference the same CID; evaluators
13
+ * compare it via integrity.intent_ref. May be an empty string when
14
+ * provenance is missing (dev / legacy).
15
+ */
16
+ intentCid?: string;
17
+ /** Persistent directory for impl-specific state. */
18
+ implStateDir: string;
19
+ /** Ephemeral working directory (cleared between attempts). */
20
+ workingDir: string;
21
+ log: (event: {
22
+ level: 'info' | 'warn' | 'error';
23
+ msg: string;
24
+ data?: unknown;
25
+ }) => void;
26
+ /** Fires at window.endTs. */
27
+ abort: AbortSignal;
28
+ msUntilEndTs: () => number;
29
+ }
30
+ export interface RestorationOutput {
31
+ venueRef: {
32
+ name: string;
33
+ };
34
+ /** Optional — evaluator impls that do not operate on a venue leave these undefined. */
35
+ preSnapshot?: Snapshot;
36
+ postSnapshot?: Snapshot;
37
+ fills?: unknown[];
38
+ /** Shape is per spec.kind convention. */
39
+ gating: Record<string, unknown>;
40
+ informational?: Record<string, unknown>;
41
+ artifacts?: OutputArtifact[];
42
+ rationale?: RationaleEntry[];
43
+ }
44
+ /**
45
+ * Context-free readiness probe. "Are this impl's external dependencies
46
+ * satisfied right now, regardless of any specific intent?" Used by
47
+ * `jinn intents list|status` and by the claim-policy gate that refuses
48
+ * to spend gas claiming an intent whose impl cannot execute.
49
+ */
50
+ export interface ReadyStatus {
51
+ ready: boolean;
52
+ reason?: string;
53
+ /** Optional hint for the operator/agent on how to become ready. */
54
+ nextStep?: {
55
+ description: string;
56
+ cli?: string;
57
+ url?: string;
58
+ };
59
+ }
60
+ /** Use when an impl is built in CLI `stub` mode (no live fleet / signer). */
61
+ export declare const REQUIRES_LIVE_DAEMON_READINESS: ReadyStatus;
62
+ /**
63
+ * Argument a kind-specific enable flow wants from the operator, surfaced
64
+ * via `enableMetadata()`. The generic `jinn intents enable <kind>` verb
65
+ * parses these from `--key=value` flags without caring what they mean.
66
+ */
67
+ export interface EnableArgDef {
68
+ name: string;
69
+ description: string;
70
+ required: boolean;
71
+ }
72
+ /**
73
+ * Metadata that `jinn intents list` uses to teach the operator (or agent)
74
+ * what's needed to enable a kind. Returned without running the flow.
75
+ */
76
+ export interface IntentEnableMetadata {
77
+ /** Human-readable summary of what opting in to this kind entails. */
78
+ description: string;
79
+ requiredArgs?: EnableArgDef[];
80
+ /** External URLs the operator/agent will need (e.g. exchange UI). */
81
+ externalResources?: Array<{
82
+ name: string;
83
+ url: string;
84
+ }>;
85
+ }
86
+ /**
87
+ * Outcome of a single `jinn intents enable <kind>` invocation.
88
+ *
89
+ * The flow is idempotent: the agent reruns the same command until
90
+ * `status === 'ready'`. Each intermediate state carries enough info for
91
+ * the agent to know what to do next (show a URL, collect more args,
92
+ * surface an error).
93
+ */
94
+ export type EnableResult = {
95
+ status: 'ready';
96
+ /** Anything the impl wants to surface (e.g. master address, wallet address). */
97
+ details?: Record<string, unknown>;
98
+ } | {
99
+ status: 'waiting_for_external_action';
100
+ /** What the operator has to do out-of-band (e.g. approve an api-wallet). */
101
+ action: {
102
+ description: string;
103
+ url?: string;
104
+ };
105
+ details?: Record<string, unknown>;
106
+ /** The exact CLI the agent should re-run once the action is done. */
107
+ nextInvocation: {
108
+ cli: string;
109
+ purpose: string;
110
+ };
111
+ } | {
112
+ status: 'missing_args';
113
+ required: EnableArgDef[];
114
+ example: {
115
+ cli: string;
116
+ };
117
+ } | {
118
+ status: 'error';
119
+ message: string;
120
+ details?: Record<string, unknown>;
121
+ };
122
+ /**
123
+ * Thrown by a {@link RestorerImpl} when the attempt should be recorded as a
124
+ * deliberate skip (no failure / no claim retry), e.g. Claude CLI unavailable.
125
+ */
126
+ export declare class SkippableError extends Error {
127
+ readonly reason: string;
128
+ constructor(reason: string, message?: string);
129
+ }
130
+ export interface RestorerImpl {
131
+ name: string;
132
+ /** semver */
133
+ version: string;
134
+ /**
135
+ * Return true if this impl should handle the given (kind, type) pair.
136
+ *
137
+ * `type` reflects DesiredState.type:
138
+ * - 'restoration' (or undefined — legacy default): the impl runs a restoration attempt
139
+ * - 'evaluation': the impl runs as an evaluator producing a verdict
140
+ *
141
+ * A restorer impl for kind=X should return true for type !== 'evaluation'.
142
+ * An evaluator impl for kind=X should return true for type === 'evaluation'.
143
+ */
144
+ supports(ctx: {
145
+ kind: string;
146
+ type?: 'restoration' | 'evaluation';
147
+ }): boolean;
148
+ canAttempt?(intent: DesiredState): Promise<{
149
+ ok: true;
150
+ } | {
151
+ ok: false;
152
+ reason: string;
153
+ }>;
154
+ run(ctx: RestorationContext): Promise<RestorationOutput>;
155
+ /**
156
+ * Context-free readiness probe. Zero-dep impls can omit this (treated
157
+ * as `{ ready: true }`). Impls with external deps (credentials, files,
158
+ * exchange approvals) report current readiness plus a `nextStep` hint.
159
+ */
160
+ isReady?(): Promise<ReadyStatus>;
161
+ /**
162
+ * Describes what `onEnable` wants from the caller. Consumed by
163
+ * `jinn intents list` so the agent can tell the operator what a
164
+ * specific kind's enable flow needs without triggering it first.
165
+ */
166
+ enableMetadata?(): IntentEnableMetadata;
167
+ /**
168
+ * Idempotent enable-state machine. Called by `jinn intents enable <kind>`.
169
+ *
170
+ * Contract:
171
+ * - Zero-dep impls return `{ status: 'ready' }` on every call.
172
+ * - Impls with external deps advance as far as they can without
173
+ * blocking, then return a `waiting_for_external_action` envelope
174
+ * the agent surfaces to the operator.
175
+ * - Subsequent invocations pick up where the previous left off.
176
+ * - Calling after already-enabled is a no-op that returns `ready`.
177
+ *
178
+ * `args` is the raw `--key=value` map parsed from the CLI. Impls
179
+ * validate and coerce as needed; missing required args should return
180
+ * `{ status: 'missing_args', required: [...], example: {...} }`.
181
+ *
182
+ * Impls that omit this method cannot be enabled by the generic CLI;
183
+ * they are either always-on (zero-dep) or require manual config.
184
+ */
185
+ onEnable?(args: Record<string, string | undefined>): Promise<EnableResult>;
186
+ /**
187
+ * Optional inverse of `onEnable`. Invoked when the operator runs
188
+ * `jinn intents disable <kind>`. Should NOT destroy unrecoverable
189
+ * state (generated key material, on-chain registrations); reserve
190
+ * that for explicit `jinn intents purge` or similar (out of scope
191
+ * for this interface).
192
+ */
193
+ onDisable?(): Promise<void>;
194
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Restorer-impl interface — §6.7 of the portfolio.v0 design spec.
3
+ *
4
+ * Pure type definitions; no runtime side effects.
5
+ */
6
+ /** Use when an impl is built in CLI `stub` mode (no live fleet / signer). */
7
+ export const REQUIRES_LIVE_DAEMON_READINESS = {
8
+ ready: false,
9
+ reason: 'requires live daemon',
10
+ nextStep: {
11
+ description: 'Run the daemon with a configured fleet and wallet',
12
+ cli: 'jinn run',
13
+ },
14
+ };
15
+ // ── Sentinel errors (impl → engine) ───────────────────────────────────────────
16
+ /**
17
+ * Thrown by a {@link RestorerImpl} when the attempt should be recorded as a
18
+ * deliberate skip (no failure / no claim retry), e.g. Claude CLI unavailable.
19
+ */
20
+ export class SkippableError extends Error {
21
+ reason;
22
+ constructor(reason, message) {
23
+ super(message ?? reason);
24
+ this.name = 'SkippableError';
25
+ this.reason = reason;
26
+ }
27
+ }
28
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/restorer/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2DH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,8BAA8B,GAAgB;IACzD,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,sBAAsB;IAC9B,QAAQ,EAAE;QACR,WAAW,EAAE,mDAAmD;QAChE,GAAG,EAAE,UAAU;KAChB;CACF,CAAC;AA0DF,iFAAiF;AAEjF;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,MAAM,CAAS;IAExB,YAAY,MAAc,EAAE,OAAgB;QAC1C,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ export interface RpcErrorContext {
2
+ operation: string;
3
+ rpcUrl?: string;
4
+ chain?: 'base' | 'base-sepolia' | string;
5
+ address?: string;
6
+ contract?: string;
7
+ fromBlock?: bigint | number | string;
8
+ toBlock?: bigint | number | string;
9
+ }
10
+ export declare function formatRpcError(error: unknown, context: RpcErrorContext): string;
@@ -0,0 +1,26 @@
1
+ import { flattenErrorMessage } from './tx-retry.js';
2
+ import { rpcHostForDisplay } from './preflight/rpc-network.js';
3
+ function blockValue(value) {
4
+ if (value === undefined)
5
+ return undefined;
6
+ return String(value);
7
+ }
8
+ export function formatRpcError(error, context) {
9
+ const parts = [`operation=${context.operation}`];
10
+ if (context.chain)
11
+ parts.push(`chain=${context.chain}`);
12
+ if (context.rpcUrl)
13
+ parts.push(`rpc=${rpcHostForDisplay(context.rpcUrl)}`);
14
+ if (context.contract)
15
+ parts.push(`contract=${context.contract}`);
16
+ if (context.address)
17
+ parts.push(`address=${context.address}`);
18
+ const from = blockValue(context.fromBlock);
19
+ const to = blockValue(context.toBlock);
20
+ if (from !== undefined || to !== undefined) {
21
+ parts.push(`blocks=${from ?? '?'}..${to ?? '?'}`);
22
+ }
23
+ parts.push(`cause=${flattenErrorMessage(error)}`);
24
+ return parts.join(' ');
25
+ }
26
+ //# sourceMappingURL=rpc-error-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-error-context.js","sourceRoot":"","sources":["../src/rpc-error-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAY/D,SAAS,UAAU,CAAC,KAA2C;IAC7D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO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