@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,107 @@
1
+ import { writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { createPublicClient, http } from 'viem';
4
+ import { base, baseSepolia, mainnet } from 'viem/chains';
5
+ import { REQUIRES_LIVE_DAEMON_READINESS } from '../../types.js';
6
+ import { PredictionApyV0IntentSchema } from '../../../types/prediction-apy.js';
7
+ import { twApyBpsOverWindow } from '../../../venues/aave-v3/client.js';
8
+ import { persistencePredict } from './strategy.js';
9
+ function chainForVenue(venue) {
10
+ if (venue === 'aave-v3-base-sepolia')
11
+ return { chain: baseSepolia, chainId: 84532 };
12
+ if (venue === 'aave-v3-mainnet')
13
+ return { chain: mainnet, chainId: 1 };
14
+ return { chain: base, chainId: 8453 };
15
+ }
16
+ export class PredictionApyV0BaselineImpl {
17
+ config;
18
+ name = 'prediction-apy-v0-baseline';
19
+ version = '1.0.0';
20
+ constructor(config = {}) {
21
+ this.config = config;
22
+ }
23
+ supports(ctx) {
24
+ return ctx.kind === 'prediction.apy.v0' && ctx.type !== 'evaluation';
25
+ }
26
+ async isReady() {
27
+ if (this.config.stub)
28
+ return { ...REQUIRES_LIVE_DAEMON_READINESS };
29
+ return { ready: true };
30
+ }
31
+ enableMetadata() {
32
+ return {
33
+ description: 'prediction.apy.v0 — submit APY prediction in bps from Aave v3 reserve data.',
34
+ };
35
+ }
36
+ async onEnable(_args) {
37
+ return { status: 'ready' };
38
+ }
39
+ async canAttempt(intent) {
40
+ const parsed = PredictionApyV0IntentSchema.safeParse(intent);
41
+ if (!parsed.success)
42
+ return { ok: false, reason: `Invalid prediction.apy.v0 intent: ${parsed.error.message}` };
43
+ if (Date.now() > parsed.data.window.endTs)
44
+ return { ok: false, reason: 'window already closed' };
45
+ return { ok: true };
46
+ }
47
+ async run(ctx) {
48
+ if (this.config.stub) {
49
+ throw new Error('prediction-apy-v0-baseline: stub registry cannot run (requires live daemon)');
50
+ }
51
+ const parsed = PredictionApyV0IntentSchema.parse(ctx.intent);
52
+ const { venue, pool, reserve } = parsed.spec.oracle;
53
+ const { chain, chainId } = chainForVenue(venue);
54
+ const rpcUrl = this.config.archiveRpcUrl ?? this.config.rpcUrl;
55
+ // At submission time, resolveTs is usually in the future — cap the TWA
56
+ // window end at "now" so we only sample historical state (persistence baseline).
57
+ const windowEndForTwa = Math.min(parsed.spec.question.resolveTs, Date.now());
58
+ let twApyBps;
59
+ let sampleCount;
60
+ if (this.config._testDeps?.twApyBpsOverWindow) {
61
+ const result = await this.config._testDeps.twApyBpsOverWindow({
62
+ pool: pool,
63
+ reserve: reserve,
64
+ windowEndTs: windowEndForTwa,
65
+ twaWindowSeconds: parsed.spec.metric.twaWindowSeconds,
66
+ sampleCount: parsed.spec.metric.sampleCount,
67
+ });
68
+ twApyBps = result.twApyBps;
69
+ sampleCount = result.sampleCount;
70
+ }
71
+ else {
72
+ const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
73
+ const actual = await publicClient.getChainId();
74
+ if (actual !== chainId) {
75
+ throw new Error(`oracle venue mismatch: ${venue} expects chain ${chainId}, got ${actual}`);
76
+ }
77
+ const result = await twApyBpsOverWindow({
78
+ publicClient,
79
+ pool: pool,
80
+ reserve: reserve,
81
+ windowEndTs: windowEndForTwa,
82
+ twaWindowSeconds: parsed.spec.metric.twaWindowSeconds,
83
+ sampleCount: parsed.spec.metric.sampleCount,
84
+ });
85
+ twApyBps = result.twApyBps;
86
+ sampleCount = result.sampleCount;
87
+ }
88
+ const prediction = persistencePredict(twApyBps);
89
+ const submittedAt = Date.now();
90
+ writeFileSync(join(ctx.workingDir, 'prediction-apy.json'), JSON.stringify({ ...prediction, submittedAt, twApyBps }, null, 2));
91
+ return {
92
+ venueRef: { name: 'aave-v3' },
93
+ gating: {
94
+ predictedBps: prediction.predictedBps,
95
+ submittedAt: String(submittedAt),
96
+ modelId: prediction.modelId,
97
+ },
98
+ informational: {
99
+ twApyBps,
100
+ sampleCount,
101
+ },
102
+ artifacts: [{ path: 'prediction-apy.json', role: 'prediction_submission' }],
103
+ };
104
+ }
105
+ }
106
+ export default PredictionApyV0BaselineImpl;
107
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+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;gBACrD,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW;aAC5C,CAAC,CAAC;YACH,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;YAC3B,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACnC,CAAC;QAED,MAAM,UAAU,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC/B,aAAa,CACX,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAC3C,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAClE,CAAC;QACF,OAAO;YACL,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;YAC7B,MAAM,EAAE;gBACN,YAAY,EAAE,UAAU,CAAC,YAAY;gBACrC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;gBAChC,OAAO,EAAE,UAAU,CAAC,OAAO;aAC5B;YACD,aAAa,EAAE;gBACb,QAAQ;gBACR,WAAW;aACZ;YACD,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC;SAC5E,CAAC;IACJ,CAAC;CACF;AAED,eAAe,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { StrategyPrediction } from './types.js';
2
+ export declare function persistencePredict(twApyBps: number): StrategyPrediction;
@@ -0,0 +1,7 @@
1
+ export function persistencePredict(twApyBps) {
2
+ return {
3
+ predictedBps: String(Math.round(twApyBps)),
4
+ modelId: 'apy-persistence.v1',
5
+ };
6
+ }
7
+ //# sourceMappingURL=strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-baseline/strategy.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC1C,OAAO,EAAE,oBAAoB;KAC9B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export interface StrategyPrediction {
2
+ predictedBps: string;
3
+ modelId: string;
4
+ }
@@ -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-apy-v0-baseline/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { PredictionApyV0Intent } from '../../../types/prediction-apy.js';
2
+ /**
3
+ * Shell for future metric kinds: today `twApyBps` is already integer-rounded
4
+ * from the Aave client; this keeps a single hook if we add more `metric.type`s.
5
+ */
6
+ export declare function deriveGroundTruthBps(intent: PredictionApyV0Intent, twApyBps: number): string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Shell for future metric kinds: today `twApyBps` is already integer-rounded
3
+ * from the Aave client; this keeps a single hook if we add more `metric.type`s.
4
+ */
5
+ export function deriveGroundTruthBps(intent, twApyBps) {
6
+ if (intent.spec.metric.type !== 'supply-apy-twa-bps') {
7
+ throw new Error(`unsupported metric: ${intent.spec.metric.type}`);
8
+ }
9
+ return String(Math.round(twApyBps));
10
+ }
11
+ //# sourceMappingURL=canonical-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-metrics.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAA6B,EAAE,QAAgB;IAClF,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { RestorerImpl, RestorationContext, RestorationOutput, ReadyStatus } from '../../types.js';
2
+ import type { DesiredState } from '../../../types/desired-state.js';
3
+ export interface PredictionApyV0EvaluatorConfig {
4
+ stub?: boolean;
5
+ evaluatorPk?: `0x${string}`;
6
+ evaluatorSafeAddress?: `0x${string}`;
7
+ rpcUrl?: string;
8
+ archiveRpcUrl?: string;
9
+ _testDeps?: {
10
+ twApyBpsOverWindow?: (args: {
11
+ windowEndTs: number;
12
+ twaWindowSeconds: number;
13
+ sampleCount: number;
14
+ pool: `0x${string}`;
15
+ reserve: `0x${string}`;
16
+ }) => Promise<{
17
+ twApyBps: number;
18
+ sampleCount: number;
19
+ }>;
20
+ expectedIntentCid?: string;
21
+ };
22
+ }
23
+ export declare class PredictionApyV0Evaluator implements RestorerImpl {
24
+ private readonly config;
25
+ readonly name = "prediction-apy-v0-evaluator";
26
+ readonly version = "1.0.0";
27
+ constructor(config: PredictionApyV0EvaluatorConfig);
28
+ supports(ctx: {
29
+ kind: string;
30
+ type?: 'restoration' | 'evaluation';
31
+ }): boolean;
32
+ isReady(): Promise<ReadyStatus>;
33
+ canAttempt(intent: DesiredState): Promise<{
34
+ ok: true;
35
+ } | {
36
+ ok: false;
37
+ reason: string;
38
+ }>;
39
+ run(ctx: RestorationContext): Promise<RestorationOutput>;
40
+ }
41
+ export { parsePredictionApySubmissionManifest } from './parse-submission.js';
42
+ export default PredictionApyV0Evaluator;
@@ -0,0 +1,208 @@
1
+ import { writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { createPublicClient, http, keccak256, stringToHex } from 'viem';
4
+ import { base, baseSepolia, mainnet } from 'viem/chains';
5
+ import { privateKeyToAccount } from 'viem/accounts';
6
+ import { REQUIRES_LIVE_DAEMON_READINESS } from '../../types.js';
7
+ import { PredictionApyV0IntentSchema } from '../../../types/prediction-apy.js';
8
+ import { twApyBpsOverWindow } from '../../../venues/aave-v3/client.js';
9
+ import { checkIntentRef, checkIntentRefMissingExpected, checkManifestSignature, recomputeTopLevelSignatureHash, } from '../prediction-v0-evaluator/checks/integrity.js';
10
+ import { resolveExpectedRestorationIntentCid } from '../evaluation-context.js';
11
+ import { deriveGroundTruthBps } from './canonical-metrics.js';
12
+ import { parsePredictionApySubmissionManifest } from './parse-submission.js';
13
+ import { computeScore } from './score.js';
14
+ function chainForVenue(venue) {
15
+ if (venue === 'aave-v3-base-sepolia')
16
+ return { chain: baseSepolia, chainId: 84532 };
17
+ if (venue === 'aave-v3-mainnet')
18
+ return { chain: mainnet, chainId: 1 };
19
+ return { chain: base, chainId: 8453 };
20
+ }
21
+ export class PredictionApyV0Evaluator {
22
+ config;
23
+ name = 'prediction-apy-v0-evaluator';
24
+ version = '1.0.0';
25
+ constructor(config) {
26
+ this.config = config;
27
+ }
28
+ supports(ctx) {
29
+ return ctx.kind === 'prediction.apy.v0' && ctx.type === 'evaluation';
30
+ }
31
+ async isReady() {
32
+ if (this.config.stub)
33
+ return { ...REQUIRES_LIVE_DAEMON_READINESS };
34
+ return { ready: true };
35
+ }
36
+ async canAttempt(intent) {
37
+ if (intent.spec?.kind !== 'prediction.apy.v0')
38
+ return { ok: false, reason: 'spec.kind is not prediction.apy.v0' };
39
+ if (intent.type !== 'evaluation')
40
+ return { ok: false, reason: 'type is not evaluation' };
41
+ if (typeof intent.context?.['restorationResult'] !== 'string') {
42
+ return { ok: false, reason: 'context.restorationResult required' };
43
+ }
44
+ return { ok: true };
45
+ }
46
+ async run(ctx) {
47
+ if (this.config.stub) {
48
+ throw new Error('prediction-apy-v0-evaluator: stub registry cannot run evaluation (requires live daemon)');
49
+ }
50
+ if (!this.config.evaluatorPk || !this.config.evaluatorSafeAddress) {
51
+ throw new Error('prediction-apy-v0-evaluator: evaluatorPk and evaluatorSafeAddress are required');
52
+ }
53
+ const testDeps = ctx._testDeps
54
+ ?? this.config._testDeps;
55
+ const expectedRef = resolveExpectedRestorationIntentCid(ctx.intent, testDeps);
56
+ const intent = PredictionApyV0IntentSchema.parse(ctx.intent);
57
+ const manifestJson = ctx.intent.context['restorationResult'];
58
+ const rawPayload = JSON.parse(manifestJson);
59
+ const submission = parsePredictionApySubmissionManifest(manifestJson);
60
+ const checks = [];
61
+ const { venue, pool, reserve } = intent.spec.oracle;
62
+ const { chain, chainId } = chainForVenue(venue);
63
+ let twApyBps;
64
+ let sampleCount;
65
+ try {
66
+ if (testDeps?.twApyBpsOverWindow) {
67
+ const result = await testDeps.twApyBpsOverWindow({
68
+ pool: pool,
69
+ reserve: reserve,
70
+ windowEndTs: intent.spec.question.resolveTs,
71
+ twaWindowSeconds: intent.spec.metric.twaWindowSeconds,
72
+ sampleCount: intent.spec.metric.sampleCount,
73
+ });
74
+ twApyBps = result.twApyBps;
75
+ sampleCount = result.sampleCount;
76
+ }
77
+ else {
78
+ const rpcUrl = this.config.archiveRpcUrl ?? this.config.rpcUrl;
79
+ const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
80
+ const actual = await publicClient.getChainId();
81
+ if (actual !== chainId) {
82
+ throw new Error(`oracle venue mismatch: ${venue} expects chain ${chainId}, got ${actual}`);
83
+ }
84
+ const result = await twApyBpsOverWindow({
85
+ publicClient,
86
+ pool: pool,
87
+ reserve: reserve,
88
+ windowEndTs: intent.spec.question.resolveTs,
89
+ twaWindowSeconds: intent.spec.metric.twaWindowSeconds,
90
+ sampleCount: intent.spec.metric.sampleCount,
91
+ });
92
+ twApyBps = result.twApyBps;
93
+ sampleCount = result.sampleCount;
94
+ }
95
+ checks.push({ name: 'availability.aave_readable', status: 'PASS' });
96
+ }
97
+ catch (error) {
98
+ checks.push({ name: 'availability.aave_readable', status: 'FAIL', detail: String(error) });
99
+ twApyBps = 0;
100
+ sampleCount = 0;
101
+ }
102
+ {
103
+ const sa = submission.prediction.submittedAt;
104
+ const w = intent.window;
105
+ const within = sa >= w.startTs && sa < w.endTs;
106
+ checks.push({
107
+ name: 'eligibility.submission_within_window',
108
+ status: within ? 'PASS' : 'FAIL',
109
+ detail: within ? undefined : { submittedAt: sa, startTs: w.startTs, endTs: w.endTs },
110
+ });
111
+ }
112
+ {
113
+ const sa = submission.prediction.submittedAt;
114
+ const w = intent.window;
115
+ const maxDelay = intent.eligibility.maxSubmissionDelayMs;
116
+ const within = sa <= w.startTs + maxDelay;
117
+ checks.push({
118
+ name: 'eligibility.submission_within_max_delay',
119
+ status: within ? 'PASS' : 'FAIL',
120
+ detail: within
121
+ ? undefined
122
+ : { submittedAt: sa, startTs: w.startTs, maxSubmissionDelayMs: maxDelay },
123
+ });
124
+ }
125
+ {
126
+ const recomputed = recomputeTopLevelSignatureHash(rawPayload);
127
+ checks.push(await checkManifestSignature(recomputed, submission.signature));
128
+ }
129
+ if (expectedRef.kind === 'missing') {
130
+ checks.push(checkIntentRefMissingExpected());
131
+ }
132
+ else {
133
+ checks.push(checkIntentRef(submission.intent.cid, expectedRef.cid));
134
+ }
135
+ if (intent.spec.metric.toleranceBps > 0) {
136
+ checks.push({ name: 'spec.tolerance_positive', status: 'PASS' });
137
+ }
138
+ else {
139
+ checks.push({ name: 'spec.tolerance_positive', status: 'FAIL' });
140
+ }
141
+ const verdict = deriveVerdict(checks);
142
+ const groundTruthBps = deriveGroundTruthBps(intent, twApyBps);
143
+ const scored = computeScore(verdict, submission.prediction.predictedBps, groundTruthBps, intent.spec.metric.toleranceBps);
144
+ const evaluatorAccount = privateKeyToAccount(this.config.evaluatorPk);
145
+ const baseManifest = {
146
+ schemaVersion: 'prediction.apy.v0.verdict.v1',
147
+ generatedAt: Date.now(),
148
+ intent: submission.intent,
149
+ evaluator: { safeAddress: this.config.evaluatorSafeAddress, agentEoa: evaluatorAccount.address },
150
+ window: intent.window,
151
+ verdict,
152
+ score: scored.score,
153
+ scoreBasis: scored.scoreBasis,
154
+ scoreVersion: scored.scoreVersion,
155
+ oracleReading: {
156
+ pool: pool,
157
+ reserve: reserve,
158
+ sampleCount,
159
+ twaWindowSeconds: intent.spec.metric.twaWindowSeconds,
160
+ resolveTs: intent.spec.question.resolveTs,
161
+ },
162
+ claimed: {
163
+ predictedBps: submission.prediction.predictedBps,
164
+ submittedAt: submission.prediction.submittedAt,
165
+ modelId: submission.prediction.modelId,
166
+ },
167
+ groundTruth: {
168
+ twApyBps: groundTruthBps,
169
+ errorBps: scored.errorBps,
170
+ },
171
+ checks,
172
+ };
173
+ const hash = keccak256(stringToHex(JSON.stringify(baseManifest)));
174
+ const sig = await evaluatorAccount.sign({ hash });
175
+ const verdictManifest = {
176
+ ...baseManifest,
177
+ signature: { algo: 'secp256k1', signer: evaluatorAccount.address, hash, sig },
178
+ };
179
+ writeFileSync(join(ctx.workingDir, 'verdict.json'), JSON.stringify(verdictManifest, null, 2));
180
+ return {
181
+ venueRef: { name: 'aave-v3' },
182
+ gating: {
183
+ verdict,
184
+ score: scored.score,
185
+ groundTruthBps,
186
+ errorBps: scored.errorBps,
187
+ },
188
+ informational: {
189
+ predictedBps: submission.prediction.predictedBps,
190
+ },
191
+ artifacts: [{ path: 'verdict.json', role: 'evaluation_verdict' }],
192
+ };
193
+ }
194
+ }
195
+ function deriveVerdict(checks) {
196
+ if (checks.some((c) => c.name.startsWith('availability.') && c.status !== 'PASS'))
197
+ return 'INDETERMINATE';
198
+ if (checks.some((c) => c.name.startsWith('integrity.') && c.status === 'INDETERMINATE'))
199
+ return 'INDETERMINATE';
200
+ if (checks.some((c) => c.name.startsWith('eligibility.') && c.status === 'FAIL'))
201
+ return 'REJECTED';
202
+ if (checks.some((c) => (c.name.startsWith('integrity.') || c.name.startsWith('spec.')) && c.status === 'FAIL'))
203
+ return 'FAIL';
204
+ return 'PASS';
205
+ }
206
+ export { parsePredictionApySubmissionManifest } from './parse-submission.js';
207
+ export default PredictionApyV0Evaluator;
208
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-evaluator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,2BAA2B,EAAqC,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EACL,cAAc,EACd,6BAA6B,EAC7B,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,mCAAmC,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oCAAoC,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAqB1C,SAAS,aAAa,CAAC,KAAkE;IACvF,IAAI,KAAK,KAAK,sBAAsB;QAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACpF,IAAI,KAAK,KAAK,iBAAiB;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACvE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACxC,CAAC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uB,CAAC;AAC7E,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type PredictionApySubmissionManifest } from '../../../types/prediction-apy.js';
2
+ /**
3
+ * Parse a restoration submission for prediction.apy.v0. Engine-wrapped jobs store
4
+ * the prediction under `gating` (see manifest assembly); direct IPFS manifests
5
+ * use `prediction` per schema.
6
+ */
7
+ export declare function parsePredictionApySubmissionManifest(manifestJson: string): PredictionApySubmissionManifest;
@@ -0,0 +1,29 @@
1
+ import { PredictionApySubmissionManifestSchema, } from '../../../types/prediction-apy.js';
2
+ /**
3
+ * Parse a restoration submission for prediction.apy.v0. Engine-wrapped jobs store
4
+ * the prediction under `gating` (see manifest assembly); direct IPFS manifests
5
+ * use `prediction` per schema.
6
+ */
7
+ export function parsePredictionApySubmissionManifest(manifestJson) {
8
+ const raw = JSON.parse(manifestJson);
9
+ const gating = raw['gating'];
10
+ const gatingBps = gating?.['predictedBps'];
11
+ if (gating && (typeof gatingBps === 'string' || typeof gatingBps === 'number')) {
12
+ const normalized = {
13
+ schemaVersion: 'prediction.apy.v0.submission.v1',
14
+ generatedAt: raw['generatedAt'] ?? Date.now(),
15
+ intent: raw['intent'],
16
+ restorer: raw['restorer'],
17
+ window: raw['window'],
18
+ prediction: {
19
+ predictedBps: String(gatingBps),
20
+ submittedAt: Number(gating['submittedAt'] ?? 0),
21
+ modelId: String(gating['modelId'] ?? ''),
22
+ },
23
+ signature: raw['signature'],
24
+ };
25
+ return PredictionApySubmissionManifestSchema.parse(normalized);
26
+ }
27
+ return PredictionApySubmissionManifestSchema.parse(raw);
28
+ }
29
+ //# sourceMappingURL=parse-submission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-submission.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-evaluator/parse-submission.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,GAEtC,MAAM,kCAAkC,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,oCAAoC,CAAC,YAAoB;IACvE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAA4B,CAAC;IAChE,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAwC,CAAC;IACpE,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,cAAc,CAAC,CAAC;IAC3C,IAAI,MAAM,IAAI,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,QAAQ,CAAC,EAAE,CAAC;QAC/E,MAAM,UAAU,GAAG;YACjB,aAAa,EAAE,iCAAiC;YAChD,WAAW,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE;YAC7C,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC;YACrB,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC;YACzB,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC;YACrB,UAAU,EAAE;gBACV,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC;gBAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;gBAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;aACzC;YACD,SAAS,EAAE,GAAG,CAAC,WAAW,CAAC;SAC5B,CAAC;QACF,OAAO,qCAAqC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,qCAAqC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Verdict } from './types.js';
2
+ export declare const SCORE_BASIS: "absolute-error-linear.v1";
3
+ export declare const SCORE_VERSION: "1";
4
+ export declare function computeScore(verdict: Verdict, predictedBps: string, groundTruthBps: string, toleranceBps: number): {
5
+ score: string;
6
+ scoreBasis: typeof SCORE_BASIS;
7
+ scoreVersion: typeof SCORE_VERSION;
8
+ errorBps: string;
9
+ };
@@ -0,0 +1,20 @@
1
+ export const SCORE_BASIS = 'absolute-error-linear.v1';
2
+ export const SCORE_VERSION = '1';
3
+ const SCALE = 1000000000000000000n;
4
+ export function computeScore(verdict, predictedBps, groundTruthBps, toleranceBps) {
5
+ const p = BigInt(predictedBps);
6
+ const g = BigInt(groundTruthBps);
7
+ const err = p > g ? p - g : g - p;
8
+ if (verdict !== 'PASS') {
9
+ return { score: '0', scoreBasis: SCORE_BASIS, scoreVersion: SCORE_VERSION, errorBps: err.toString() };
10
+ }
11
+ const tol = BigInt(toleranceBps);
12
+ if (tol <= 0n)
13
+ throw new Error('toleranceBps must be positive');
14
+ if (err >= tol) {
15
+ return { score: '0', scoreBasis: SCORE_BASIS, scoreVersion: SCORE_VERSION, errorBps: err.toString() };
16
+ }
17
+ const score = ((tol - err) * SCALE) / tol;
18
+ return { score: score.toString(), scoreBasis: SCORE_BASIS, scoreVersion: SCORE_VERSION, errorBps: err.toString() };
19
+ }
20
+ //# sourceMappingURL=score.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-apy-v0-evaluator/score.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG,0BAAmC,CAAC;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG,GAAY,CAAC;AAC1C,MAAM,KAAK,GAAG,oBAA0B,CAAC;AAEzC,MAAM,UAAU,YAAY,CAC1B,OAAgB,EAChB,YAAoB,EACpB,cAAsB,EACtB,YAAoB;IAEpB,MAAM,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IAC/B,MAAM,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;IACxG,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IACjC,IAAI,GAAG,IAAI,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAChE,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;IACxG,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC;IAC1C,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;AACrH,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-apy-v0-evaluator/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import type { RestorerImpl, RestorationContext, RestorationOutput, ReadyStatus, EnableResult, IntentEnableMetadata } from '../../types.js';
2
+ import { type RoundReading } from '../../../venues/chainlink/client.js';
3
+ export interface PredictionV0BaselineConfig {
4
+ rpcUrl?: string;
5
+ /** CLI registries that cannot execute intents without the daemon. */
6
+ stub?: boolean;
7
+ _testDeps?: {
8
+ readChainlink?: (feed: `0x${string}`) => Promise<RoundReading>;
9
+ };
10
+ }
11
+ export declare class PredictionV0BaselineImpl implements RestorerImpl {
12
+ private readonly config;
13
+ readonly name = "prediction-v0-baseline";
14
+ readonly version = "1.0.0";
15
+ constructor(config?: PredictionV0BaselineConfig);
16
+ supports(ctx: {
17
+ kind: string;
18
+ type?: 'restoration' | 'evaluation';
19
+ }): boolean;
20
+ isReady(): Promise<ReadyStatus>;
21
+ enableMetadata(): IntentEnableMetadata;
22
+ onEnable(_args: Record<string, string | undefined>): Promise<EnableResult>;
23
+ canAttempt(intent: import('../../../types/desired-state.js').DesiredState): Promise<{
24
+ ok: true;
25
+ } | {
26
+ ok: false;
27
+ reason: string;
28
+ }>;
29
+ run(ctx: RestorationContext): Promise<RestorationOutput>;
30
+ }
31
+ export default PredictionV0BaselineImpl;