@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,52 @@
1
+ /**
2
+ * legacy-claude — RestorerImpl fallback for spec=undefined (health-check) intents.
3
+ *
4
+ * Wraps the existing ClaudeRunner so that intents with no spec.kind continue to
5
+ * work via the RestorationEngine. Registered as the default fallback in the impl
6
+ * registry (supports spec.kind === '').
7
+ *
8
+ * The engine calls findFor({ kind: '' }) for legacy intents because
9
+ * PersistedIntent.specKind is null → coerced to '' in runImpl().
10
+ */
11
+ import { type Runner } from '../../../runner/runner.js';
12
+ import type { RestorerImpl, RestorationContext, RestorationOutput, ReadyStatus, EnableResult, IntentEnableMetadata } from '../../types.js';
13
+ export interface LegacyClaudeConfig {
14
+ runner: Runner;
15
+ /** Passed to RunnerContext. Defaults to /tmp */
16
+ workingDirectory?: string;
17
+ /** Timeout in ms passed to runner. Defaults to 300000 */
18
+ timeoutMs?: number;
19
+ /** Passed to runner for artifact storage */
20
+ storePath?: string;
21
+ /** Daemon API URL for MCP server */
22
+ daemonApiUrl?: string;
23
+ /**
24
+ * When true (e.g. synthetic registry), `isReady` reports the daemon is required.
25
+ * Production daemon should omit.
26
+ */
27
+ stub?: boolean;
28
+ }
29
+ export declare class LegacyClaudeImpl implements RestorerImpl {
30
+ private readonly config;
31
+ readonly name = "legacy-claude";
32
+ readonly version = "1.0.0";
33
+ constructor(config: LegacyClaudeConfig);
34
+ /**
35
+ * Supports the empty-string kind produced by the engine for intents with no spec.
36
+ * Legacy release-acceptance jobs use no spec for both restoration and evaluation,
37
+ * so both phases route through the Claude runner.
38
+ */
39
+ supports(ctx: {
40
+ kind: string;
41
+ type?: 'restoration' | 'evaluation';
42
+ }): boolean;
43
+ canAttempt(): Promise<{
44
+ ok: true;
45
+ }>;
46
+ isReady(): Promise<ReadyStatus>;
47
+ enableMetadata(): IntentEnableMetadata;
48
+ onEnable(_args: Record<string, string | undefined>): Promise<EnableResult>;
49
+ run(ctx: RestorationContext): Promise<RestorationOutput>;
50
+ private recoverPublishedArtifact;
51
+ }
52
+ export default LegacyClaudeImpl;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * legacy-claude — RestorerImpl fallback for spec=undefined (health-check) intents.
3
+ *
4
+ * Wraps the existing ClaudeRunner so that intents with no spec.kind continue to
5
+ * work via the RestorationEngine. Registered as the default fallback in the impl
6
+ * registry (supports spec.kind === '').
7
+ *
8
+ * The engine calls findFor({ kind: '' }) for legacy intents because
9
+ * PersistedIntent.specKind is null → coerced to '' in runImpl().
10
+ */
11
+ import { REQUIRES_LIVE_DAEMON_READINESS, SkippableError } from '../../types.js';
12
+ import { Store } from '../../../store/store.js';
13
+ // ── Impl ──────────────────────────────────────────────────────────────────────
14
+ export class LegacyClaudeImpl {
15
+ config;
16
+ name = 'legacy-claude';
17
+ version = '1.0.0';
18
+ constructor(config) {
19
+ this.config = config;
20
+ }
21
+ /**
22
+ * Supports the empty-string kind produced by the engine for intents with no spec.
23
+ * Legacy release-acceptance jobs use no spec for both restoration and evaluation,
24
+ * so both phases route through the Claude runner.
25
+ */
26
+ supports(ctx) {
27
+ return ctx.kind === '' || ctx.kind === 'legacy';
28
+ }
29
+ async canAttempt() {
30
+ return { ok: true };
31
+ }
32
+ async isReady() {
33
+ if (this.config.stub)
34
+ return { ...REQUIRES_LIVE_DAEMON_READINESS };
35
+ return { ready: true };
36
+ }
37
+ enableMetadata() {
38
+ return {
39
+ description: 'legacy-claude — handles health-check intents (no spec.kind). Always enabled.',
40
+ };
41
+ }
42
+ async onEnable(_args) {
43
+ return { status: 'ready' };
44
+ }
45
+ async run(ctx) {
46
+ const { intent, workingDir, log } = ctx;
47
+ log({ level: 'info', msg: 'legacy-claude: starting', data: { requestId: intent.id } });
48
+ const runnerCtx = {
49
+ requestId: intent.id,
50
+ workingDirectory: workingDir ?? this.config.workingDirectory ?? '/tmp',
51
+ timeoutMs: this.config.timeoutMs ?? 300_000,
52
+ storePath: this.config.storePath,
53
+ daemonApiUrl: this.config.daemonApiUrl,
54
+ };
55
+ let result;
56
+ try {
57
+ result = await this.config.runner.run(intent, runnerCtx);
58
+ }
59
+ catch (err) {
60
+ if (isClaudeUnavailableError(err)) {
61
+ const detail = err instanceof Error ? err.message : String(err);
62
+ throw new SkippableError('claude_unavailable', detail);
63
+ }
64
+ throw err;
65
+ }
66
+ const resultTag = intent.type === 'evaluation' ? 'evaluation-verdict' : 'restoration-result';
67
+ const recoveredData = result.data || await this.recoverPublishedArtifact(intent.id, resultTag);
68
+ const artifactCount = result.artifacts?.length ?? (recoveredData ? 1 : 0);
69
+ log({ level: 'info', msg: 'legacy-claude: runner completed', data: { hasData: !!recoveredData } });
70
+ const output = {
71
+ venueRef: { name: 'legacy' },
72
+ gating: {
73
+ result: recoveredData,
74
+ },
75
+ informational: {
76
+ runnerResult: recoveredData,
77
+ artifactCount,
78
+ },
79
+ artifacts: [],
80
+ };
81
+ return output;
82
+ }
83
+ async recoverPublishedArtifact(desiredStateId, tag) {
84
+ if (!this.config.storePath)
85
+ return '';
86
+ for (let attempt = 0; attempt < 5; attempt += 1) {
87
+ const store = new Store(this.config.storePath);
88
+ try {
89
+ const [artifact] = store.searchArtifacts({
90
+ desiredStateId,
91
+ tags: [tag],
92
+ limit: 1,
93
+ });
94
+ if (artifact?.content)
95
+ return artifact.content;
96
+ }
97
+ finally {
98
+ store.close();
99
+ }
100
+ await new Promise((resolve) => setTimeout(resolve, 100));
101
+ }
102
+ return '';
103
+ }
104
+ }
105
+ export default LegacyClaudeImpl;
106
+ /**
107
+ * Narrow heuristic: only match phrases that unambiguously indicate the Claude
108
+ * CLI is unavailable (not logged in, quota exhausted, API key rejected).
109
+ * Mirrors the former engine-level check (jinn-mono-7ee.4).
110
+ */
111
+ function isClaudeUnavailableError(err) {
112
+ const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();
113
+ const claudeSpecificPhrases = [
114
+ 'claude auth',
115
+ 'claude not authenticated',
116
+ 'claude cli not found',
117
+ 'claude: command not found',
118
+ 'claude quota',
119
+ 'claude rate limit',
120
+ 'claude credit',
121
+ 'anthropic api key',
122
+ ];
123
+ if (claudeSpecificPhrases.some((p) => msg.includes(p)))
124
+ return true;
125
+ if (msg.includes('claude')) {
126
+ const availabilityPhrases = [
127
+ 'not logged in',
128
+ 'please login',
129
+ 'please log in',
130
+ 'quota exhausted',
131
+ 'quota exceeded',
132
+ 'credit limit',
133
+ 'invalid api key',
134
+ 'api key not found',
135
+ ];
136
+ return availabilityPhrases.some((p) => msg.includes(p));
137
+ }
138
+ return false;
139
+ }
140
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/restorer/impls/legacy-claude/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Canonical metric computation for portfolio.v0 — §7.6.
3
+ *
4
+ * Single source of truth shared by both the restorer and evaluator.
5
+ * Pure functions; no I/O.
6
+ */
7
+ import type { HlFill } from '../../../venues/hyperliquid/types.js';
8
+ /** A single point on the equity curve: [timestamp_ms, accountValue_as_number]. */
9
+ export interface EquityPoint {
10
+ ts: number;
11
+ value: number;
12
+ }
13
+ /**
14
+ * Build an equity curve from the pre/post snapshot values and fills.
15
+ *
16
+ * Per §7.6: the curve is sampled at:
17
+ * - preSnapshot.capturedAt (value = preSnapshot accountValue)
18
+ * - every fill.time (value = inline equity; see note below)
19
+ * - postSnapshot.capturedAt (value = postSnapshot accountValue)
20
+ *
21
+ * Note: HL does not return per-fill equity. The evaluator uses the
22
+ * pre/post accountValues and the fill timestamps as curve shape anchors.
23
+ * For drawdown calculation purposes the curve is:
24
+ * pre-equity → (fills sorted by time but using pre/post values interpolated
25
+ * between them) → post-equity.
26
+ *
27
+ * Actually §7.6 says "sampled at preSnapshot.capturedAt + every fill.time +
28
+ * postSnapshot.capturedAt". Since HL only provides point-in-time equity at
29
+ * pre/post (not at each fill), the canonical approach is to use linear
30
+ * interpolation between the pre and post equity values at each fill timestamp.
31
+ * This matches what the restorer can compute and is deterministic.
32
+ */
33
+ export declare function equityCurve(preTs: number, preValue: number, postTs: number, postValue: number, fillTimes: number[]): EquityPoint[];
34
+ /**
35
+ * Compute max drawdown percentage over an equity curve.
36
+ *
37
+ * Per §7.6:
38
+ * Drawdown at P = 100 * (peak_so_far - equity_P) / peak_so_far
39
+ * maxDrawdownPct = max over all P
40
+ *
41
+ * Returns 0 if the curve has fewer than 2 points or no drawdown.
42
+ */
43
+ export declare function maxDrawdownPct(curve: EquityPoint[]): number;
44
+ /**
45
+ * Compute equity return percentage.
46
+ *
47
+ * Per §7.6: 100 * (postValue - preValue) / preValue
48
+ *
49
+ * Returns 0 if preValue is 0.
50
+ */
51
+ export declare function equityReturnPct(preValue: number, postValue: number): number;
52
+ /**
53
+ * Count fills where closedPnl is non-zero.
54
+ *
55
+ * Per §7.6: count of fills where closedPnl != 0
56
+ *
57
+ * Parses as float to handle "0", "0.0", "0.00", "-0.0", "+0.0" etc.
58
+ * NaN (non-numeric input) and empty string are treated as not-closed (excluded).
59
+ */
60
+ export declare function closedTradesCount(fills: HlFill[]): number;
61
+ /**
62
+ * Compute traded notional multiple.
63
+ *
64
+ * Per §7.6: sum_i(|sz_i * px_i|) / preValue
65
+ *
66
+ * Returns 0 if preValue is 0.
67
+ */
68
+ export declare function tradedNotionalMultiple(fills: HlFill[], preValue: number): number;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Canonical metric computation for portfolio.v0 — §7.6.
3
+ *
4
+ * Single source of truth shared by both the restorer and evaluator.
5
+ * Pure functions; no I/O.
6
+ */
7
+ /**
8
+ * Build an equity curve from the pre/post snapshot values and fills.
9
+ *
10
+ * Per §7.6: the curve is sampled at:
11
+ * - preSnapshot.capturedAt (value = preSnapshot accountValue)
12
+ * - every fill.time (value = inline equity; see note below)
13
+ * - postSnapshot.capturedAt (value = postSnapshot accountValue)
14
+ *
15
+ * Note: HL does not return per-fill equity. The evaluator uses the
16
+ * pre/post accountValues and the fill timestamps as curve shape anchors.
17
+ * For drawdown calculation purposes the curve is:
18
+ * pre-equity → (fills sorted by time but using pre/post values interpolated
19
+ * between them) → post-equity.
20
+ *
21
+ * Actually §7.6 says "sampled at preSnapshot.capturedAt + every fill.time +
22
+ * postSnapshot.capturedAt". Since HL only provides point-in-time equity at
23
+ * pre/post (not at each fill), the canonical approach is to use linear
24
+ * interpolation between the pre and post equity values at each fill timestamp.
25
+ * This matches what the restorer can compute and is deterministic.
26
+ */
27
+ export function equityCurve(preTs, preValue, postTs, postValue, fillTimes) {
28
+ const points = [];
29
+ // Pre snapshot
30
+ points.push({ ts: preTs, value: preValue });
31
+ // Fill time points — linear interpolation between pre and post
32
+ const duration = postTs - preTs;
33
+ const sorted = [...fillTimes].sort((a, b) => a - b);
34
+ for (const ts of sorted) {
35
+ const clampedTs = Math.max(preTs, Math.min(postTs, ts));
36
+ const frac = duration > 0 ? (clampedTs - preTs) / duration : 0;
37
+ const value = preValue + frac * (postValue - preValue);
38
+ points.push({ ts: clampedTs, value });
39
+ }
40
+ // Post snapshot
41
+ points.push({ ts: postTs, value: postValue });
42
+ return points;
43
+ }
44
+ // ── maxDrawdownPct ────────────────────────────────────────────────────────────
45
+ /**
46
+ * Compute max drawdown percentage over an equity curve.
47
+ *
48
+ * Per §7.6:
49
+ * Drawdown at P = 100 * (peak_so_far - equity_P) / peak_so_far
50
+ * maxDrawdownPct = max over all P
51
+ *
52
+ * Returns 0 if the curve has fewer than 2 points or no drawdown.
53
+ */
54
+ export function maxDrawdownPct(curve) {
55
+ if (curve.length < 2)
56
+ return 0;
57
+ let peakSoFar = curve[0].value;
58
+ let maxDd = 0;
59
+ for (const point of curve) {
60
+ if (point.value > peakSoFar) {
61
+ peakSoFar = point.value;
62
+ }
63
+ if (peakSoFar > 0) {
64
+ const dd = (100 * (peakSoFar - point.value)) / peakSoFar;
65
+ if (dd > maxDd)
66
+ maxDd = dd;
67
+ }
68
+ }
69
+ return maxDd;
70
+ }
71
+ // ── equityReturnPct ───────────────────────────────────────────────────────────
72
+ /**
73
+ * Compute equity return percentage.
74
+ *
75
+ * Per §7.6: 100 * (postValue - preValue) / preValue
76
+ *
77
+ * Returns 0 if preValue is 0.
78
+ */
79
+ export function equityReturnPct(preValue, postValue) {
80
+ if (preValue === 0)
81
+ return 0;
82
+ return (100 * (postValue - preValue)) / preValue;
83
+ }
84
+ // ── closedTradesCount ─────────────────────────────────────────────────────────
85
+ /**
86
+ * Count fills where closedPnl is non-zero.
87
+ *
88
+ * Per §7.6: count of fills where closedPnl != 0
89
+ *
90
+ * Parses as float to handle "0", "0.0", "0.00", "-0.0", "+0.0" etc.
91
+ * NaN (non-numeric input) and empty string are treated as not-closed (excluded).
92
+ */
93
+ export function closedTradesCount(fills) {
94
+ return fills.filter((f) => {
95
+ const v = parseFloat(f.closedPnl);
96
+ return !isNaN(v) && v !== 0;
97
+ }).length;
98
+ }
99
+ // ── tradedNotionalMultiple ────────────────────────────────────────────────────
100
+ /**
101
+ * Compute traded notional multiple.
102
+ *
103
+ * Per §7.6: sum_i(|sz_i * px_i|) / preValue
104
+ *
105
+ * Returns 0 if preValue is 0.
106
+ */
107
+ export function tradedNotionalMultiple(fills, preValue) {
108
+ if (preValue === 0)
109
+ return 0;
110
+ const total = fills.reduce((acc, f) => {
111
+ const sz = parseFloat(f.sz);
112
+ const px = parseFloat(f.px);
113
+ return acc + Math.abs(sz * px);
114
+ }, 0);
115
+ return total / preValue;
116
+ }
117
+ //# sourceMappingURL=canonical-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-metrics.js","sourceRoot":"","sources":["../../../../src/restorer/impls/portfolio-v0-evaluator/canonical-metrics.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Availability checks for portfolio.v0.eval — §7.4.
3
+ *
4
+ * availability.hyperliquid_reachable
5
+ * availability.hl_pre_snapshot_rederivable
6
+ * availability.hl_fills_rederivable
7
+ *
8
+ * FAIL in any of these → verdict INDETERMINATE per §7.3.
9
+ */
10
+ import type { HlGridPoint } from '../../../../venues/hyperliquid/types.js';
11
+ import type { Check } from '../types.js';
12
+ /**
13
+ * Wraps a HL API call that should succeed if HL is reachable.
14
+ *
15
+ * Returns PASS if the call completes without throwing, FAIL otherwise.
16
+ */
17
+ export declare function checkHlReachable(reachable: boolean, errorMsg?: string): Check;
18
+ /**
19
+ * Check whether the pre-snapshot equity can be rederived from the portfolio
20
+ * grid. A bracket must exist around preTs.
21
+ *
22
+ * Returns PASS if a bracket is found, FAIL if the grid has no bracket.
23
+ */
24
+ export declare function checkPreSnapshotRederivable(grid: HlGridPoint[], preTs: number): Check;
25
+ /**
26
+ * Check whether fills could be fetched without clamping.
27
+ *
28
+ * If startTimeClamped is true, HL silently moved the retention horizon and
29
+ * fills are incomplete — FAIL.
30
+ */
31
+ export declare function checkFillsRederivable(startTimeClamped: boolean): Check;
32
+ /**
33
+ * Check whether the post-snapshot is rederivable (no funding accrual issue).
34
+ *
35
+ * Per §7.5: if postSnapshot.capturedAt > endTs + 60s, emit SKIP and
36
+ * downstream consistency checks should be skipped → INDETERMINATE.
37
+ *
38
+ * This check is named availability.hl_post_snapshot_rederivable and uses
39
+ * SKIP status to propagate INDETERMINATE via the derivation rule (SKIP ≠ FAIL
40
+ * for availability — a FAIL would cause INDETERMINATE, but SKIP means we
41
+ * surface it separately).
42
+ *
43
+ * However, per §7.3 the derivation rule is:
44
+ * if any "availability.*" FAIL → INDETERMINATE
45
+ *
46
+ * A SKIP doesn't trigger INDETERMINATE via the rule, so the eval impl must
47
+ * handle this edge case explicitly by checking for SKIP in downstream checks.
48
+ */
49
+ export declare function checkPostSnapshotFundingAccrual(postCapturedAt: number, endTs: number): Check;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Availability checks for portfolio.v0.eval — §7.4.
3
+ *
4
+ * availability.hyperliquid_reachable
5
+ * availability.hl_pre_snapshot_rederivable
6
+ * availability.hl_fills_rederivable
7
+ *
8
+ * FAIL in any of these → verdict INDETERMINATE per §7.3.
9
+ */
10
+ import { bracketGridPoints } from '../../../../venues/hyperliquid/grid.js';
11
+ // ── hyperliquid_reachable ─────────────────────────────────────────────────────
12
+ /**
13
+ * Wraps a HL API call that should succeed if HL is reachable.
14
+ *
15
+ * Returns PASS if the call completes without throwing, FAIL otherwise.
16
+ */
17
+ export function checkHlReachable(reachable, errorMsg) {
18
+ if (reachable) {
19
+ return { name: 'availability.hyperliquid_reachable', status: 'PASS' };
20
+ }
21
+ return {
22
+ name: 'availability.hyperliquid_reachable',
23
+ status: 'FAIL',
24
+ detail: errorMsg ?? 'Hyperliquid API is unreachable',
25
+ };
26
+ }
27
+ // ── hl_pre_snapshot_rederivable ───────────────────────────────────────────────
28
+ /**
29
+ * Check whether the pre-snapshot equity can be rederived from the portfolio
30
+ * grid. A bracket must exist around preTs.
31
+ *
32
+ * Returns PASS if a bracket is found, FAIL if the grid has no bracket.
33
+ */
34
+ export function checkPreSnapshotRederivable(grid, preTs) {
35
+ const bracket = bracketGridPoints(grid, preTs);
36
+ if (bracket !== null) {
37
+ return { name: 'availability.hl_pre_snapshot_rederivable', status: 'PASS' };
38
+ }
39
+ return {
40
+ name: 'availability.hl_pre_snapshot_rederivable',
41
+ status: 'FAIL',
42
+ detail: `No grid bracket found for preTs=${preTs}`,
43
+ };
44
+ }
45
+ // ── hl_fills_rederivable ──────────────────────────────────────────────────────
46
+ /**
47
+ * Check whether fills could be fetched without clamping.
48
+ *
49
+ * If startTimeClamped is true, HL silently moved the retention horizon and
50
+ * fills are incomplete — FAIL.
51
+ */
52
+ export function checkFillsRederivable(startTimeClamped) {
53
+ if (!startTimeClamped) {
54
+ return { name: 'availability.hl_fills_rederivable', status: 'PASS' };
55
+ }
56
+ return {
57
+ name: 'availability.hl_fills_rederivable',
58
+ status: 'FAIL',
59
+ detail: 'HL userFillsByTime startTime was clamped to retention horizon — fills are incomplete',
60
+ };
61
+ }
62
+ // ── Post-snapshot funding-accrual edge case ───────────────────────────────────
63
+ /**
64
+ * Check whether the post-snapshot is rederivable (no funding accrual issue).
65
+ *
66
+ * Per §7.5: if postSnapshot.capturedAt > endTs + 60s, emit SKIP and
67
+ * downstream consistency checks should be skipped → INDETERMINATE.
68
+ *
69
+ * This check is named availability.hl_post_snapshot_rederivable and uses
70
+ * SKIP status to propagate INDETERMINATE via the derivation rule (SKIP ≠ FAIL
71
+ * for availability — a FAIL would cause INDETERMINATE, but SKIP means we
72
+ * surface it separately).
73
+ *
74
+ * However, per §7.3 the derivation rule is:
75
+ * if any "availability.*" FAIL → INDETERMINATE
76
+ *
77
+ * A SKIP doesn't trigger INDETERMINATE via the rule, so the eval impl must
78
+ * handle this edge case explicitly by checking for SKIP in downstream checks.
79
+ */
80
+ export function checkPostSnapshotFundingAccrual(postCapturedAt, endTs) {
81
+ const threshold = endTs + 60_000; // 60 seconds
82
+ if (postCapturedAt > threshold) {
83
+ return {
84
+ name: 'availability.hl_post_snapshot_rederivable',
85
+ status: 'SKIP',
86
+ detail: `postSnapshot.capturedAt (${postCapturedAt}) > endTs+60s (${threshold}) — funding may have accrued`,
87
+ };
88
+ }
89
+ return { name: 'availability.hl_post_snapshot_rederivable', status: 'PASS' };
90
+ }
91
+ //# sourceMappingURL=availability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"availability.js","sourceRoot":"","sources":["../../../../../src/restorer/impls/portfolio-v0-evaluator/checks/availability.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAG3E,iFAAiF;AAEjF;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAkB,EAAE,QAAiB;IACpE,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,EAAE,IAAI,EAAE,oCAAoC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACxE,CAAC;IACD,OAAO;QACL,IAAI,EAAE,oCAAoC;QAC1C,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,QAAQ,IAAI,gCAAgC;KACrD,CAAC;AACJ,CAAC;AAED,iFAAiF;AAEjF;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,IAAmB,EACnB,KAAa;IAEb,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,OAAO,EAAE,IAAI,EAAE,0CAA0C,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC;IACD,OAAO;QACL,IAAI,EAAE,0CAA0C;QAChD,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,mCAAmC,KAAK,EAAE;KACnD,CAAC;AACJ,CAAC;AAED,iFAAiF;AAEjF;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,gBAAyB;IAC7D,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,mCAAmC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACvE,CAAC;IACD,OAAO;QACL,IAAI,EAAE,mCAAmC;QACzC,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,sFAAsF;KAC/F,CAAC;AACJ,CAAC;AAED,iFAAiF;AAEjF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,+BAA+B,CAC7C,cAAsB,EACtB,KAAa;IAEb,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC,aAAa;IAC/C,IAAI,cAAc,GAAG,SAAS,EAAE,CAAC;QAC/B,OAAO;YACL,IAAI,EAAE,2CAA2C;YACjD,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,4BAA4B,cAAc,kBAAkB,SAAS,8BAA8B;SAC5G,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,2CAA2C,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Consistency checks for portfolio.v0.eval — §7.4.
3
+ *
4
+ * consistency.pre_snapshot
5
+ * consistency.post_snapshot
6
+ * consistency.fills (set match by tid; per-fill fields exact)
7
+ * consistency.gating.equity_return
8
+ * consistency.gating.max_drawdown
9
+ * consistency.gating.closed_trades
10
+ * consistency.gating.traded_notional
11
+ *
12
+ * FAIL in any consistency.* check → verdict FAIL per §7.3.
13
+ *
14
+ * Tolerance rules per §7.5:
15
+ * Snapshot decimal fields: 0.01% relative OR 0.0001 USD absolute (whichever greater)
16
+ * Per-fill HL fields: exact
17
+ * Fills set membership (by tid): exact
18
+ * equityReturnPct, maxDrawdownPct: 0.05% absolute
19
+ * closedTradesCount: exact
20
+ * tradedNotionalMultiple: 0.05% relative
21
+ */
22
+ import type { HlFill } from '../../../../venues/hyperliquid/types.js';
23
+ import type { Check } from '../types.js';
24
+ /**
25
+ * Extract the canonical accountValue from a snapshot payload.
26
+ *
27
+ * Supports two shapes:
28
+ * 1. Legacy: `{ marginSummary: { accountValue } }` (HL's raw clearinghouseState).
29
+ * 2. Unified (current restorer): `{ accountValue, clearinghouseState, spotClearinghouseState, ... }`
30
+ * — top-level `accountValue` is perps margin + spot USDC, matching HL's
31
+ * `portfolio` endpoint unified equity.
32
+ */
33
+ export declare function extractAccountValue(payload: unknown): number | null;
34
+ /**
35
+ * Check pre-snapshot consistency.
36
+ *
37
+ * Compares accountValue between claimed and rederived pre-snapshot.
38
+ * If either snapshot lacks a parseable accountValue, SKIP (not enough data).
39
+ */
40
+ export declare function checkPreSnapshot(claimedPayload: unknown, rederived: {
41
+ capturedAt: number;
42
+ payload: unknown;
43
+ } | null): Check;
44
+ /**
45
+ * Check post-snapshot consistency.
46
+ *
47
+ * Compares accountValue between claimed and rederived post-snapshot.
48
+ * If postSnapshot rederivation was skipped (funding accrual), SKIP.
49
+ */
50
+ export declare function checkPostSnapshot(claimedPayload: unknown, rederived: {
51
+ capturedAt: number;
52
+ payload: unknown;
53
+ } | null): Check;
54
+ /**
55
+ * Check fills consistency: set membership by tid (exact), and per-fill field
56
+ * equality for px, sz, time, fee, closedPnl.
57
+ */
58
+ export declare function checkFills(claimedFills: unknown[], rederived: HlFill[]): Check;
59
+ /**
60
+ * Check consistency of equityReturnPct (claimed vs rederived).
61
+ * Tolerance: 0.05% absolute.
62
+ */
63
+ export declare function checkGatingEquityReturn(claimed: string, rederived: number): Check;
64
+ /**
65
+ * Check consistency of maxDrawdownPct (claimed vs rederived).
66
+ * Tolerance: 0.05% absolute.
67
+ */
68
+ export declare function checkGatingMaxDrawdown(claimed: string, rederived: number): Check;
69
+ /**
70
+ * Check consistency of closedTradesCount (claimed vs rederived).
71
+ * Tolerance: exact.
72
+ */
73
+ export declare function checkGatingClosedTrades(claimed: number, rederived: number): Check;
74
+ /**
75
+ * Check consistency of tradedNotionalMultiple (claimed vs rederived).
76
+ * Tolerance: 0.05% relative.
77
+ */
78
+ export declare function checkGatingTradedNotional(claimed: string, rederived: number): Check;