@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,100 @@
1
+ /**
2
+ * prediction-v0-baseline — reference RestorerImpl for prediction.v0.
3
+ *
4
+ * §5 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ */
6
+ import { writeFileSync } from 'node:fs';
7
+ import { join } from 'node:path';
8
+ import { createPublicClient, http } from 'viem';
9
+ import { baseSepolia, base } from 'viem/chains';
10
+ import { REQUIRES_LIVE_DAEMON_READINESS } from '../../types.js';
11
+ import { PredictionV0IntentSchema } from '../../../types/prediction.js';
12
+ import { readChainlinkLatest, scaleToDecimal, } from '../../../venues/chainlink/client.js';
13
+ import { spotCarryPredict } from './strategy.js';
14
+ export class PredictionV0BaselineImpl {
15
+ config;
16
+ name = 'prediction-v0-baseline';
17
+ version = '1.0.0';
18
+ constructor(config = {}) {
19
+ this.config = config;
20
+ }
21
+ supports(ctx) {
22
+ return ctx.kind === 'prediction.v0' && ctx.type !== 'evaluation';
23
+ }
24
+ async isReady() {
25
+ if (this.config.stub)
26
+ return { ...REQUIRES_LIVE_DAEMON_READINESS };
27
+ // Zero external deps — prediction.v0 runs against on-chain oracles only.
28
+ return { ready: true };
29
+ }
30
+ enableMetadata() {
31
+ return {
32
+ description: 'prediction.v0 — submit probability predictions against on-chain price feeds. No external credentials required.',
33
+ };
34
+ }
35
+ async onEnable(_args) {
36
+ return { status: 'ready' };
37
+ }
38
+ async canAttempt(intent) {
39
+ const parsed = PredictionV0IntentSchema.safeParse(intent);
40
+ if (!parsed.success)
41
+ return { ok: false, reason: `Invalid prediction.v0 intent: ${parsed.error.message}` };
42
+ if (Date.now() > parsed.data.window.endTs) {
43
+ return { ok: false, reason: 'window already closed' };
44
+ }
45
+ return { ok: true };
46
+ }
47
+ async run(ctx) {
48
+ if (this.config.stub) {
49
+ throw new Error('prediction-v0-baseline: stub registry cannot run (requires live daemon)');
50
+ }
51
+ const { intent, workingDir, log } = ctx;
52
+ const parsed = PredictionV0IntentSchema.parse(intent);
53
+ const { feed, venue } = parsed.spec.oracle;
54
+ log({ level: 'info', msg: 'prediction-v0-baseline: starting', data: { feed, venue } });
55
+ // Read the feed (injection seam for tests)
56
+ const read = this.config._testDeps?.readChainlink;
57
+ let snapshot;
58
+ if (read) {
59
+ snapshot = await read(feed);
60
+ }
61
+ else {
62
+ const expectedChainId = venue === 'chainlink-base' ? 8453 : 84532;
63
+ const chain = venue === 'chainlink-base' ? base : baseSepolia;
64
+ const pc = createPublicClient({ chain, transport: http(this.config.rpcUrl) });
65
+ const actualChainId = await pc.getChainId();
66
+ if (actualChainId !== expectedChainId) {
67
+ throw new Error(`oracle venue mismatch: spec says ${venue} (chainId ${expectedChainId}) but RPC chainId is ${actualChainId}`);
68
+ }
69
+ snapshot = await readChainlinkLatest(feed, pc);
70
+ }
71
+ const currentPrice = scaleToDecimal(snapshot.answer, snapshot.decimals);
72
+ const { probability, modelId } = spotCarryPredict(parsed, currentPrice);
73
+ const submittedAt = Date.now();
74
+ const prediction = { probability, submittedAt, modelId };
75
+ writeFileSync(join(workingDir, 'prediction.json'), JSON.stringify(prediction, null, 2));
76
+ log({ level: 'info', msg: 'prediction-v0-baseline: submitted', data: { currentPrice, probability, modelId } });
77
+ return {
78
+ venueRef: { name: 'chainlink' },
79
+ gating: {
80
+ probability,
81
+ submittedAt: String(submittedAt),
82
+ modelId,
83
+ },
84
+ informational: {
85
+ oracleSnapshot: {
86
+ feed,
87
+ roundId: String(snapshot.roundId),
88
+ answer: String(snapshot.answer),
89
+ updatedAt: snapshot.updatedAt,
90
+ },
91
+ currentPrice,
92
+ },
93
+ artifacts: [
94
+ { path: 'prediction.json', role: 'prediction_submission' },
95
+ ],
96
+ };
97
+ }
98
+ }
99
+ export default PredictionV0BaselineImpl;
100
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-baseline/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,IA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C,QAAQ,CAAC,MAAM,CAAC;oBAC/B,SAAS,EAAE,QAAQ,CAAC,SAAS;iBAC9B;gBACD,YAAY;aACb;YACD,SAAS,EAAE;gBACT,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,uBAAuB,EAAE;aAC3D;SACF,CAAC;IACJ,CAAC;CACF;AAED,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Spot-carry baseline — "current state tends to persist."
3
+ *
4
+ * §5.3 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ */
6
+ import type { PredictionV0Intent } from '../../../types/prediction.js';
7
+ import type { StrategyPrediction } from './types.js';
8
+ export declare function spotCarryPredict(intent: PredictionV0Intent, currentPrice: string): StrategyPrediction;
@@ -0,0 +1,41 @@
1
+ /** Decimal comparison. Both inputs are non-negative decimal strings. */
2
+ function decCmp(a, b) {
3
+ const [ai, af = ''] = a.split('.');
4
+ const [bi, bf = ''] = b.split('.');
5
+ const aiN = ai.replace(/^0+/, '') || '0';
6
+ const biN = bi.replace(/^0+/, '') || '0';
7
+ if (aiN.length !== biN.length)
8
+ return aiN.length - biN.length;
9
+ if (aiN !== biN)
10
+ return aiN < biN ? -1 : 1;
11
+ const maxLen = Math.max(af.length, bf.length);
12
+ const afP = af.padEnd(maxLen, '0');
13
+ const bfP = bf.padEnd(maxLen, '0');
14
+ if (afP === bfP)
15
+ return 0;
16
+ return afP < bfP ? -1 : 1;
17
+ }
18
+ function evaluateQuestion(question, price) {
19
+ if (question.kind === 'threshold') {
20
+ const c = decCmp(price, question.threshold);
21
+ switch (question.operator) {
22
+ case 'GT': return c > 0;
23
+ case 'GTE': return c >= 0;
24
+ case 'LT': return c < 0;
25
+ case 'LTE': return c <= 0;
26
+ }
27
+ }
28
+ else {
29
+ const lowerCmp = decCmp(price, question.lowerBound);
30
+ const upperCmp = decCmp(price, question.upperBound);
31
+ return lowerCmp >= 0 && upperCmp < 0;
32
+ }
33
+ }
34
+ export function spotCarryPredict(intent, currentPrice) {
35
+ const currentlyYes = evaluateQuestion(intent.spec.question, currentPrice);
36
+ return {
37
+ probability: currentlyYes ? '0.55' : '0.45',
38
+ modelId: 'spot-carry.v1',
39
+ };
40
+ }
41
+ //# sourceMappingURL=strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-baseline/strategy.ts"],"names":[],"mappings":"AAQA,wEAAwE;AACxE,SAAS,MAAM,CAAC,CAAS,EAAE,CAAS;IAClC,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;IACzC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;IACzC,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM;QAAE,OAAO,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAC9D,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,IAAI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
3
+ modelId: string;
4
+ }
5
+ export interface Strategy {
6
+ predict(intent: import('../../../types/prediction.js').PredictionV0Intent, currentPrice: string): StrategyPrediction;
7
+ }
@@ -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-baseline/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Canonical metrics for prediction.v0 evaluator.
3
+ *
4
+ * §6 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ */
6
+ import type { PredictionV0Intent } from '../../../types/prediction.js';
7
+ /** Compare two non-negative decimal strings. Returns negative/zero/positive. */
8
+ export declare function decCmp(a: string, b: string): number;
9
+ export type GroundTruth = 'YES' | 'NO';
10
+ export declare function resolveGroundTruth(question: PredictionV0Intent['spec']['question'], price: string): GroundTruth;
11
+ /**
12
+ * Brier score scaled to 1e18 fixed-point.
13
+ *
14
+ * score = 1 - (probability - outcome)^2 ∈ [0,1]
15
+ * * probability: decimal string ∈ [0,1]
16
+ * * outcome: 0 | 1
17
+ *
18
+ * Returns: string representation of BigInt (score × 1e18), rounded to nearest.
19
+ */
20
+ export declare function brierScore(probability: string, outcome: 0 | 1): string;
@@ -0,0 +1,66 @@
1
+ /** Compare two non-negative decimal strings. Returns negative/zero/positive. */
2
+ export function decCmp(a, b) {
3
+ const [ai, af = ''] = a.split('.');
4
+ const [bi, bf = ''] = b.split('.');
5
+ const aiN = (ai || '0').replace(/^0+/, '') || '0';
6
+ const biN = (bi || '0').replace(/^0+/, '') || '0';
7
+ if (aiN.length !== biN.length)
8
+ return aiN.length - biN.length;
9
+ if (aiN !== biN)
10
+ return aiN < biN ? -1 : 1;
11
+ const maxLen = Math.max(af.length, bf.length);
12
+ const afP = af.padEnd(maxLen, '0');
13
+ const bfP = bf.padEnd(maxLen, '0');
14
+ if (afP === bfP)
15
+ return 0;
16
+ return afP < bfP ? -1 : 1;
17
+ }
18
+ export function resolveGroundTruth(question, price) {
19
+ if (question.kind === 'threshold') {
20
+ const c = decCmp(price, question.threshold);
21
+ switch (question.operator) {
22
+ case 'GT': return c > 0 ? 'YES' : 'NO';
23
+ case 'GTE': return c >= 0 ? 'YES' : 'NO';
24
+ case 'LT': return c < 0 ? 'YES' : 'NO';
25
+ case 'LTE': return c <= 0 ? 'YES' : 'NO';
26
+ }
27
+ }
28
+ const lo = decCmp(price, question.lowerBound);
29
+ const hi = decCmp(price, question.upperBound);
30
+ return (lo >= 0 && hi < 0) ? 'YES' : 'NO';
31
+ }
32
+ /**
33
+ * Brier score scaled to 1e18 fixed-point.
34
+ *
35
+ * score = 1 - (probability - outcome)^2 ∈ [0,1]
36
+ * * probability: decimal string ∈ [0,1]
37
+ * * outcome: 0 | 1
38
+ *
39
+ * Returns: string representation of BigInt (score × 1e18), rounded to nearest.
40
+ */
41
+ export function brierScore(probability, outcome) {
42
+ const p = Number(probability);
43
+ if (!Number.isFinite(p) || p < 0 || p > 1) {
44
+ throw new Error(`brierScore: probability must be in [0,1], got ${probability}`);
45
+ }
46
+ // Use integer arithmetic to avoid floating-point precision loss.
47
+ // Represent probability as a rational n/d where d = 10^decimalPlaces.
48
+ const dotIdx = probability.indexOf('.');
49
+ const decimals = dotIdx === -1 ? 0 : probability.length - dotIdx - 1;
50
+ const d = BigInt(10 ** decimals);
51
+ const n = BigInt(probability.replace('.', '')); // numerator: p = n/d
52
+ // outcome as BigInt
53
+ const o = BigInt(outcome); // 0 or 1
54
+ // score = 1 - (p - outcome)^2
55
+ // = 1 - ((n - o*d) / d)^2
56
+ // = (d^2 - (n - o*d)^2) / d^2
57
+ const diff = n - o * d; // (p - outcome) * d
58
+ const scoreNum = d * d - diff * diff; // score * d^2
59
+ const scoreDenom = d * d;
60
+ // scale to 1e18: result = scoreNum * 1e18 / scoreDenom (rounded to nearest)
61
+ const SCALE = BigInt('1000000000000000000'); // 1e18
62
+ // Round: (scoreNum * SCALE + scoreDenom/2) / scoreDenom
63
+ const scaled = (scoreNum * SCALE + scoreDenom / 2n) / scoreDenom;
64
+ return scaled.toString();
65
+ }
66
+ //# sourceMappingURL=canonical-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-metrics.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-evaluator/canonical-metrics.ts"],"names":[],"mappings":"AAOA,gFAAgF;AAChF,MAAM,UAAU,MAAM,CAAC,CAAS,EAAE,CAAS;IACzC,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;IAClD,MAAM,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;IAClD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM;QAAE,OAAO,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAC9D,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,C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C"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Availability checks for prediction.v0.
3
+ *
4
+ * §6.7 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ */
6
+ import type { Check } from '../types.js';
7
+ import type { SpanningResult } from '../../../../venues/chainlink/client.js';
8
+ export declare function checkOracleReachable<T>(fetch: () => Promise<T>): Promise<Check>;
9
+ export declare function checkOracleRoundCoversResolveTs(result: Pick<SpanningResult, 'spanning'>): Check;
@@ -0,0 +1,23 @@
1
+ export async function checkOracleReachable(fetch) {
2
+ try {
3
+ await fetch();
4
+ return { name: 'availability.oracle_reachable', status: 'PASS' };
5
+ }
6
+ catch (err) {
7
+ return {
8
+ name: 'availability.oracle_reachable',
9
+ status: 'FAIL',
10
+ detail: { message: err instanceof Error ? err.message : String(err) },
11
+ };
12
+ }
13
+ }
14
+ export function checkOracleRoundCoversResolveTs(result) {
15
+ return {
16
+ name: 'availability.oracle_round_covers_resolve_ts',
17
+ status: result.spanning ? 'PASS' : 'SKIP',
18
+ detail: result.spanning
19
+ ? undefined
20
+ : 'No Chainlink round with updatedAt > resolveTs yet; retry later.',
21
+ };
22
+ }
23
+ //# sourceMappingURL=availability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"availability.js","sourceRoot":"","sources":["../../../../../src/restorer/impls/prediction-v0-evaluator/checks/availability.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,KAAuB;IAEvB,IAAI,CAAC;QACH,MAAM,KAAK,EAAE,CAAC;QACd,OAAO,EAAE,IAAI,EAAE,+BAA+B,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACnE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,IAAI,EAAE,+BAA+B;YACrC,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;SACtE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,MAAwC;IAExC,OAAO;QACL,IAAI,EAAE,6CAA6C;QACnD,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QACzC,MAAM,EAAE,MAAM,CAAC,QAAQ;YACrB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,iEAAiE;KACtE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Check } from '../types.js';
2
+ import type { Window } from '../../../../types/desired-state.js';
3
+ export declare function checkSubmissionWithinWindow(submittedAt: number, window: Window): Check;
@@ -0,0 +1,13 @@
1
+ export function checkSubmissionWithinWindow(submittedAt, window) {
2
+ const within = submittedAt >= window.startTs && submittedAt <= window.endTs;
3
+ return {
4
+ name: 'eligibility.submission_within_window',
5
+ status: within ? 'PASS' : 'FAIL',
6
+ detail: within ? undefined : {
7
+ submittedAt,
8
+ startTs: window.startTs,
9
+ endTs: window.endTs,
10
+ },
11
+ };
12
+ }
13
+ //# sourceMappingURL=eligibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eligibility.js","sourceRoot":"","sources":["../../../../../src/restorer/impls/prediction-v0-evaluator/checks/eligibility.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,2BAA2B,CACzC,WAAmB,EACnB,MAAc;IAEd,MAAM,MAAM,GAAG,WAAW,IAAI,MAAM,CAAC,OAAO,IAAI,WAAW,IAAI,MAAM,CAAC,KAAK,CAAC;IAC5E,OAAO;QACL,IAAI,EAAE,sCAAsC;QAC5C,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QAChC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3B,WAAW;YACX,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Check } from '../types.js';
2
+ import type { PredictionV0Intent, PredictionSubmissionManifest } from '../../../../types/prediction.js';
3
+ export declare function checkWindowBounds(intent: PredictionV0Intent): Check;
4
+ export declare function checkManifestFieldsPresent(prediction: PredictionSubmissionManifest['prediction']): Check;
5
+ /**
6
+ * Recompute keccak256 over the canonical JSON of the top-level object after
7
+ * removing `signature` — the same pre-image the restorer `signCanonical` hashes.
8
+ */
9
+ export declare function recomputeTopLevelSignatureHash(manifest: Record<string, unknown>): `0x${string}`;
10
+ export declare function checkManifestSignature(canonicalHash: `0x${string}`, signature: PredictionSubmissionManifest['signature']): Promise<Check>;
11
+ /** Verify the restorer's claimed intent CID matches the on-chain request. */
12
+ export declare function checkIntentRef(manifestIntentCid: string, expectedIntentCid: string): Check;
13
+ export declare function checkIntentRefMissingExpected(): Check;
@@ -0,0 +1,111 @@
1
+ import { keccak256, recoverAddress } from 'viem';
2
+ import { canonicalJson } from '../../../engine/canonical-json.js';
3
+ /**
4
+ * Window-bounds integrity. We no longer pin an exact duration — the schema
5
+ * enforces sane min/max bounds (1min ≤ window ≤ 24h; 0 ≤ resolveGap ≤ 1h),
6
+ * so this check just re-verifies those invariants at eval time in case the
7
+ * manifest was built against an older schema version.
8
+ */
9
+ const MIN_WINDOW_MS = 60_000;
10
+ const MAX_WINDOW_MS = 86_400_000;
11
+ const MAX_RESOLVE_GAP_MS = 3_600_000;
12
+ export function checkWindowBounds(intent) {
13
+ const wDelta = intent.window.endTs - intent.window.startTs;
14
+ if (wDelta < MIN_WINDOW_MS || wDelta > MAX_WINDOW_MS) {
15
+ return {
16
+ name: 'integrity.window_bounds',
17
+ status: 'FAIL',
18
+ detail: {
19
+ reason: 'window out of bounds',
20
+ got: wDelta,
21
+ min: MIN_WINDOW_MS,
22
+ max: MAX_WINDOW_MS,
23
+ },
24
+ };
25
+ }
26
+ const rDelta = intent.spec.question.resolveTs - intent.window.endTs;
27
+ if (rDelta < 0 || rDelta > MAX_RESOLVE_GAP_MS) {
28
+ return {
29
+ name: 'integrity.window_bounds',
30
+ status: 'FAIL',
31
+ detail: {
32
+ reason: 'resolve gap out of bounds',
33
+ got: rDelta,
34
+ min: 0,
35
+ max: MAX_RESOLVE_GAP_MS,
36
+ },
37
+ };
38
+ }
39
+ return { name: 'integrity.window_bounds', status: 'PASS' };
40
+ }
41
+ export function checkManifestFieldsPresent(prediction) {
42
+ const p = Number(prediction.probability);
43
+ if (!Number.isFinite(p) || p < 0 || p > 1) {
44
+ return {
45
+ name: 'integrity.manifest_fields_present',
46
+ status: 'FAIL',
47
+ detail: { field: 'probability', got: prediction.probability },
48
+ };
49
+ }
50
+ if (!prediction.modelId || prediction.modelId.length === 0) {
51
+ return {
52
+ name: 'integrity.manifest_fields_present',
53
+ status: 'FAIL',
54
+ detail: { field: 'modelId' },
55
+ };
56
+ }
57
+ if (!Number.isInteger(prediction.submittedAt)) {
58
+ return {
59
+ name: 'integrity.manifest_fields_present',
60
+ status: 'FAIL',
61
+ detail: { field: 'submittedAt' },
62
+ };
63
+ }
64
+ return { name: 'integrity.manifest_fields_present', status: 'PASS' };
65
+ }
66
+ /**
67
+ * Recompute keccak256 over the canonical JSON of the top-level object after
68
+ * removing `signature` — the same pre-image the restorer `signCanonical` hashes.
69
+ */
70
+ export function recomputeTopLevelSignatureHash(manifest) {
71
+ const { signature: _sig, ...unsigned } = manifest;
72
+ return keccak256(new TextEncoder().encode(canonicalJson(unsigned)));
73
+ }
74
+ export async function checkManifestSignature(canonicalHash, signature) {
75
+ if (signature.algo !== 'secp256k1') {
76
+ return { name: 'integrity.manifest_signature', status: 'FAIL', detail: 'non-secp256k1 signature' };
77
+ }
78
+ if (signature.hash !== canonicalHash) {
79
+ return { name: 'integrity.manifest_signature', status: 'FAIL', detail: 'hash mismatch' };
80
+ }
81
+ try {
82
+ const recovered = await recoverAddress({ hash: canonicalHash, signature: signature.sig });
83
+ const ok = recovered.toLowerCase() === signature.signer.toLowerCase();
84
+ return {
85
+ name: 'integrity.manifest_signature',
86
+ status: ok ? 'PASS' : 'FAIL',
87
+ detail: ok ? undefined : { recovered, expected: signature.signer },
88
+ };
89
+ }
90
+ catch (err) {
91
+ return { name: 'integrity.manifest_signature', status: 'FAIL', detail: String(err) };
92
+ }
93
+ }
94
+ /** Verify the restorer's claimed intent CID matches the on-chain request. */
95
+ export function checkIntentRef(manifestIntentCid, expectedIntentCid) {
96
+ return {
97
+ name: 'integrity.intent_ref',
98
+ status: manifestIntentCid === expectedIntentCid ? 'PASS' : 'FAIL',
99
+ detail: manifestIntentCid === expectedIntentCid ? undefined : { manifestIntentCid, expectedIntentCid },
100
+ };
101
+ }
102
+ export function checkIntentRefMissingExpected() {
103
+ return {
104
+ name: 'integrity.intent_ref',
105
+ status: 'INDETERMINATE',
106
+ detail: {
107
+ reason: 'context.restorationIntentCid missing; cannot verify submission.intent.cid trustlessly',
108
+ },
109
+ };
110
+ }
111
+ //# sourceMappingURL=integrity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrity.js","sourceRoot":"","sources":["../../../../../src/restorer/impls/prediction-v0-evaluator/checks/integrity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAIlE;;;;;GAKG;AACH,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAErC,MAAM,UAAU,iBAAiB,CAAC,MAA0B;IAC1D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;IAC3D,IAAI,MAAM,GAAG,aAAa,IAAI,MAAM,GAAG,aAAa,EAAE,CAAC;QACrD,O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AAW,EAAE,CAAC;QACtE,OAAO;YACL,IAAI,EAAE,8BAA8B;YACpC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;YAC5B,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE;SACnE,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACvF,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAAC,iBAAyB,EAAE,iBAAyB;IACjF,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,MAAM,EAAE,iBAAiB,KAAK,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QACjE,MAAM,EAAE,iBAAiB,KAAK,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,EAAE;KACvG,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,MAAM,EAAE,eAAe;QACvB,MAAM,EAAE;YACN,MAAM,EACJ,uFAAuF;SAC1F;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Check } from '../types.js';
2
+ import type { PredictionV0Intent } from '../../../../types/prediction.js';
3
+ export declare function checkQuestionKindSupported(question: PredictionV0Intent['spec']['question'] | {
4
+ kind: string;
5
+ }): Check;
@@ -0,0 +1,20 @@
1
+ export function checkQuestionKindSupported(question) {
2
+ if (question.kind === 'threshold') {
3
+ const op = question.operator;
4
+ const supported = ['GT', 'GTE', 'LT', 'LTE'].includes(op);
5
+ return {
6
+ name: 'spec.question_kind_supported',
7
+ status: supported ? 'PASS' : 'FAIL',
8
+ detail: supported ? undefined : { operator: op },
9
+ };
10
+ }
11
+ if (question.kind === 'range') {
12
+ return { name: 'spec.question_kind_supported', status: 'PASS' };
13
+ }
14
+ return {
15
+ name: 'spec.question_kind_supported',
16
+ status: 'FAIL',
17
+ detail: { kind: question.kind },
18
+ };
19
+ }
20
+ //# sourceMappingURL=spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../../src/restorer/impls/prediction-v0-evaluator/checks/spec.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,0BAA0B,CACxC,QAAmE;IAEnE,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAClC,MAAM,EAAE,GAAI,QAAgB,CAAC,QAAQ,CAAC;QACtC,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC1D,OAAO;YACL,IAAI,EAAE,8BAA8B;YACpC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;YACnC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;SACjD,CAAC;IACJ,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAClE,CAAC;IACD,OAAO;QACL,IAAI,EAAE,8BAA8B;QACpC,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE;KAChC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { RestorerImpl, RestorationContext, RestorationOutput, ReadyStatus } from '../../types.js';
2
+ import type { DesiredState } from '../../../types/desired-state.js';
3
+ import { type SpanningResult } from '../../../venues/chainlink/client.js';
4
+ export interface PredictionV0EvaluatorConfig {
5
+ /** Set by {@link buildRestorerImpls} for CLI registries (no real signer). */
6
+ stub?: boolean;
7
+ /** Evaluator's private key — used to sign the verdict manifest. */
8
+ evaluatorPk?: `0x${string}`;
9
+ /** Evaluator's Safe multisig address — written into verdict.evaluator.safeAddress. */
10
+ evaluatorSafeAddress?: `0x${string}`;
11
+ rpcUrl?: string;
12
+ _testDeps?: {
13
+ oraclePriceAtResolveTs?: (feed: `0x${string}`, resolveTs: number) => Promise<SpanningResult>;
14
+ /** Override the intentCid we expect to match — bypasses on-chain derivation for tests. */
15
+ expectedIntentCid?: string;
16
+ };
17
+ }
18
+ export declare class PredictionV0Evaluator implements RestorerImpl {
19
+ private readonly config;
20
+ readonly name = "prediction-v0-evaluator";
21
+ readonly version = "1.0.0";
22
+ constructor(config: PredictionV0EvaluatorConfig);
23
+ supports(ctx: {
24
+ kind: string;
25
+ type?: 'restoration' | 'evaluation';
26
+ }): boolean;
27
+ isReady(): Promise<ReadyStatus>;
28
+ canAttempt(intent: DesiredState): Promise<{
29
+ ok: true;
30
+ } | {
31
+ ok: false;
32
+ reason: string;
33
+ }>;
34
+ run(ctx: RestorationContext): Promise<RestorationOutput>;
35
+ }
36
+ export default PredictionV0Evaluator;