@jinn-network/client 0.1.1 → 0.1.2-canary.66834251

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