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

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 (317) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CONTRIBUTING.md +123 -0
  3. package/README.md +210 -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 +1 -0
  13. package/dist/adapters/mech/adapter.js +75 -41
  14. package/dist/adapters/mech/adapter.js.map +1 -1
  15. package/dist/adapters/mech/contracts.d.ts +2 -0
  16. package/dist/adapters/mech/contracts.js +57 -7
  17. package/dist/adapters/mech/contracts.js.map +1 -1
  18. package/dist/adapters/mech/ipfs.d.ts +8 -0
  19. package/dist/adapters/mech/ipfs.js +12 -0
  20. package/dist/adapters/mech/ipfs.js.map +1 -1
  21. package/dist/adapters/mech/types.d.ts +20 -46
  22. package/dist/adapters/mech/types.js +16 -35
  23. package/dist/adapters/mech/types.js.map +1 -1
  24. package/dist/api/gather-status.d.ts +1 -0
  25. package/dist/api/gather-status.js +33 -1
  26. package/dist/api/gather-status.js.map +1 -1
  27. package/dist/api/portfolio-v0-build.d.ts +81 -0
  28. package/dist/api/portfolio-v0-build.js +141 -0
  29. package/dist/api/portfolio-v0-build.js.map +1 -0
  30. package/dist/api/portfolio-v0-doctor.d.ts +37 -0
  31. package/dist/api/portfolio-v0-doctor.js +123 -0
  32. package/dist/api/portfolio-v0-doctor.js.map +1 -0
  33. package/dist/api/rewards-build.js +1 -1
  34. package/dist/api/rewards-build.js.map +1 -1
  35. package/dist/api/status-build.d.ts +7 -0
  36. package/dist/api/status-build.js +1 -0
  37. package/dist/api/status-build.js.map +1 -1
  38. package/dist/bin/jinn-mcp.d.ts +0 -12
  39. package/dist/bin/jinn-mcp.js +5 -14
  40. package/dist/bin/jinn-mcp.js.map +1 -1
  41. package/dist/build-meta.json +1 -1
  42. package/dist/cli/commands/auth.js +115 -25
  43. package/dist/cli/commands/auth.js.map +1 -1
  44. package/dist/cli/commands/bootstrap.js +1 -0
  45. package/dist/cli/commands/bootstrap.js.map +1 -1
  46. package/dist/cli/commands/doctor.js +130 -14
  47. package/dist/cli/commands/doctor.js.map +1 -1
  48. package/dist/cli/commands/fleet-scale.js +1 -0
  49. package/dist/cli/commands/fleet-scale.js.map +1 -1
  50. package/dist/cli/commands/fund-requirements.js +2 -0
  51. package/dist/cli/commands/fund-requirements.js.map +1 -1
  52. package/dist/cli/commands/intents.d.ts +17 -0
  53. package/dist/cli/commands/intents.js +489 -0
  54. package/dist/cli/commands/intents.js.map +1 -0
  55. package/dist/cli/commands/keys-backup.js +13 -11
  56. package/dist/cli/commands/keys-backup.js.map +1 -1
  57. package/dist/cli/commands/mcp.d.ts +3 -0
  58. package/dist/cli/commands/mcp.js +19 -0
  59. package/dist/cli/commands/mcp.js.map +1 -0
  60. package/dist/cli/commands/plugin-install.js +8 -4
  61. package/dist/cli/commands/plugin-install.js.map +1 -1
  62. package/dist/cli/commands/quickstart.js +60 -4
  63. package/dist/cli/commands/quickstart.js.map +1 -1
  64. package/dist/cli/commands/rewards.js +27 -1
  65. package/dist/cli/commands/rewards.js.map +1 -1
  66. package/dist/cli/commands/submit-intent.js +108 -5
  67. package/dist/cli/commands/submit-intent.js.map +1 -1
  68. package/dist/cli/commands/version.js +1 -0
  69. package/dist/cli/commands/version.js.map +1 -1
  70. package/dist/cli/deployment-digest.js +5 -0
  71. package/dist/cli/deployment-digest.js.map +1 -1
  72. package/dist/cli/execution-context.js +1 -0
  73. package/dist/cli/execution-context.js.map +1 -1
  74. package/dist/cli/index.js +4 -0
  75. package/dist/cli/index.js.map +1 -1
  76. package/dist/cli/intent-registry-access.d.ts +64 -0
  77. package/dist/cli/intent-registry-access.js +187 -0
  78. package/dist/cli/intent-registry-access.js.map +1 -0
  79. package/dist/cli/introspection-context.js +1 -0
  80. package/dist/cli/introspection-context.js.map +1 -1
  81. package/dist/cli/password.d.ts +21 -9
  82. package/dist/cli/password.js +45 -24
  83. package/dist/cli/password.js.map +1 -1
  84. package/dist/config.d.ts +110 -8
  85. package/dist/config.js +41 -12
  86. package/dist/config.js.map +1 -1
  87. package/dist/daemon/creator.d.ts +7 -1
  88. package/dist/daemon/creator.js +38 -3
  89. package/dist/daemon/creator.js.map +1 -1
  90. package/dist/daemon/daemon.d.ts +43 -0
  91. package/dist/daemon/daemon.js +87 -2
  92. package/dist/daemon/daemon.js.map +1 -1
  93. package/dist/earning/bootstrap.d.ts +2 -1
  94. package/dist/earning/bootstrap.js +72 -4
  95. package/dist/earning/bootstrap.js.map +1 -1
  96. package/dist/earning/contracts.d.ts +10 -0
  97. package/dist/earning/contracts.js +24 -0
  98. package/dist/earning/contracts.js.map +1 -1
  99. package/dist/earning/jinn-rewards.d.ts +9 -0
  100. package/dist/earning/jinn-rewards.js +7 -0
  101. package/dist/earning/jinn-rewards.js.map +1 -1
  102. package/dist/intents/prediction-apy-v0-auto.d.ts +11 -0
  103. package/dist/intents/prediction-apy-v0-auto.js +46 -0
  104. package/dist/intents/prediction-apy-v0-auto.js.map +1 -0
  105. package/dist/intents/prediction-apy-v0-template.d.ts +8 -0
  106. package/dist/intents/prediction-apy-v0-template.js +22 -0
  107. package/dist/intents/prediction-apy-v0-template.js.map +1 -0
  108. package/dist/intents/prediction-v0-auto.d.ts +53 -0
  109. package/dist/intents/prediction-v0-auto.js +84 -0
  110. package/dist/intents/prediction-v0-auto.js.map +1 -0
  111. package/dist/intents/prediction-v0-template.d.ts +65 -0
  112. package/dist/intents/prediction-v0-template.js +125 -0
  113. package/dist/intents/prediction-v0-template.js.map +1 -0
  114. package/dist/main.js +149 -1
  115. package/dist/main.js.map +1 -1
  116. package/dist/mcp/operator-server.d.ts +1 -1
  117. package/dist/mcp/operator-server.js +1 -1
  118. package/dist/preflight/claude-auth.d.ts +12 -1
  119. package/dist/preflight/claude-auth.js +21 -3
  120. package/dist/preflight/claude-auth.js.map +1 -1
  121. package/dist/restorer/engine/canonical-json.d.ts +18 -0
  122. package/dist/restorer/engine/canonical-json.js +59 -0
  123. package/dist/restorer/engine/canonical-json.js.map +1 -0
  124. package/dist/restorer/engine/claim.d.ts +69 -0
  125. package/dist/restorer/engine/claim.js +104 -0
  126. package/dist/restorer/engine/claim.js.map +1 -0
  127. package/dist/restorer/engine/delivery.d.ts +52 -0
  128. package/dist/restorer/engine/delivery.js +63 -0
  129. package/dist/restorer/engine/delivery.js.map +1 -0
  130. package/dist/restorer/engine/engine.d.ts +203 -0
  131. package/dist/restorer/engine/engine.js +753 -0
  132. package/dist/restorer/engine/engine.js.map +1 -0
  133. package/dist/restorer/engine/manifest-assembly.d.ts +67 -0
  134. package/dist/restorer/engine/manifest-assembly.js +79 -0
  135. package/dist/restorer/engine/manifest-assembly.js.map +1 -0
  136. package/dist/restorer/engine/packaging.d.ts +87 -0
  137. package/dist/restorer/engine/packaging.js +350 -0
  138. package/dist/restorer/engine/packaging.js.map +1 -0
  139. package/dist/restorer/engine/persistence.d.ts +170 -0
  140. package/dist/restorer/engine/persistence.js +381 -0
  141. package/dist/restorer/engine/persistence.js.map +1 -0
  142. package/dist/restorer/engine/recovery.d.ts +22 -0
  143. package/dist/restorer/engine/recovery.js +24 -0
  144. package/dist/restorer/engine/recovery.js.map +1 -0
  145. package/dist/restorer/engine/registry.d.ts +62 -0
  146. package/dist/restorer/engine/registry.js +73 -0
  147. package/dist/restorer/engine/registry.js.map +1 -0
  148. package/dist/restorer/engine/signing.d.ts +30 -0
  149. package/dist/restorer/engine/signing.js +39 -0
  150. package/dist/restorer/engine/signing.js.map +1 -0
  151. package/dist/restorer/engine/state.d.ts +42 -0
  152. package/dist/restorer/engine/state.js +87 -0
  153. package/dist/restorer/engine/state.js.map +1 -0
  154. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.d.ts +64 -0
  155. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js +96 -0
  156. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js.map +1 -0
  157. package/dist/restorer/impls/claude-mcp-hyperliquid/index.d.ts +101 -0
  158. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js +710 -0
  159. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js.map +1 -0
  160. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.d.ts +137 -0
  161. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js +865 -0
  162. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js.map +1 -0
  163. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.d.ts +74 -0
  164. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js +74 -0
  165. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js.map +1 -0
  166. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +97 -0
  167. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js +226 -0
  168. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +1 -0
  169. package/dist/restorer/impls/claude-mcp-prediction/index.d.ts +43 -0
  170. package/dist/restorer/impls/claude-mcp-prediction/index.js +230 -0
  171. package/dist/restorer/impls/claude-mcp-prediction/index.js.map +1 -0
  172. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.d.ts +38 -0
  173. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js +135 -0
  174. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js.map +1 -0
  175. package/dist/restorer/impls/claude-mcp-prediction/prompt.d.ts +8 -0
  176. package/dist/restorer/impls/claude-mcp-prediction/prompt.js +54 -0
  177. package/dist/restorer/impls/claude-mcp-prediction/prompt.js.map +1 -0
  178. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.d.ts +36 -0
  179. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js +137 -0
  180. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js.map +1 -0
  181. package/dist/restorer/impls/claude-mcp-prediction/types.d.ts +82 -0
  182. package/dist/restorer/impls/claude-mcp-prediction/types.js +6 -0
  183. package/dist/restorer/impls/claude-mcp-prediction/types.js.map +1 -0
  184. package/dist/restorer/impls/legacy-claude/index.d.ts +45 -0
  185. package/dist/restorer/impls/legacy-claude/index.js +71 -0
  186. package/dist/restorer/impls/legacy-claude/index.js.map +1 -0
  187. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +68 -0
  188. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js +117 -0
  189. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js.map +1 -0
  190. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.d.ts +49 -0
  191. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js +91 -0
  192. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js.map +1 -0
  193. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.d.ts +78 -0
  194. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js +274 -0
  195. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js.map +1 -0
  196. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +23 -0
  197. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js +49 -0
  198. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js.map +1 -0
  199. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.d.ts +25 -0
  200. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js +44 -0
  201. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js.map +1 -0
  202. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.d.ts +17 -0
  203. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js +43 -0
  204. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js.map +1 -0
  205. package/dist/restorer/impls/portfolio-v0-evaluator/index.d.ts +43 -0
  206. package/dist/restorer/impls/portfolio-v0-evaluator/index.js +431 -0
  207. package/dist/restorer/impls/portfolio-v0-evaluator/index.js.map +1 -0
  208. package/dist/restorer/impls/portfolio-v0-evaluator/score.d.ts +21 -0
  209. package/dist/restorer/impls/portfolio-v0-evaluator/score.js +32 -0
  210. package/dist/restorer/impls/portfolio-v0-evaluator/score.js.map +1 -0
  211. package/dist/restorer/impls/portfolio-v0-evaluator/types.d.ts +32 -0
  212. package/dist/restorer/impls/portfolio-v0-evaluator/types.js +8 -0
  213. package/dist/restorer/impls/portfolio-v0-evaluator/types.js.map +1 -0
  214. package/dist/restorer/impls/prediction-apy-v0-baseline/index.d.ts +39 -0
  215. package/dist/restorer/impls/prediction-apy-v0-baseline/index.js +98 -0
  216. package/dist/restorer/impls/prediction-apy-v0-baseline/index.js.map +1 -0
  217. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.d.ts +2 -0
  218. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js +7 -0
  219. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js.map +1 -0
  220. package/dist/restorer/impls/prediction-apy-v0-baseline/types.d.ts +4 -0
  221. package/dist/restorer/impls/prediction-apy-v0-baseline/types.js +2 -0
  222. package/dist/restorer/impls/prediction-apy-v0-baseline/types.js.map +1 -0
  223. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +2 -0
  224. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js +7 -0
  225. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +1 -0
  226. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.d.ts +39 -0
  227. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js +186 -0
  228. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js.map +1 -0
  229. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.d.ts +9 -0
  230. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js +20 -0
  231. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js.map +1 -0
  232. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.d.ts +7 -0
  233. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js +2 -0
  234. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js.map +1 -0
  235. package/dist/restorer/impls/prediction-v0-baseline/index.d.ts +29 -0
  236. package/dist/restorer/impls/prediction-v0-baseline/index.js +94 -0
  237. package/dist/restorer/impls/prediction-v0-baseline/index.js.map +1 -0
  238. package/dist/restorer/impls/prediction-v0-baseline/strategy.d.ts +8 -0
  239. package/dist/restorer/impls/prediction-v0-baseline/strategy.js +41 -0
  240. package/dist/restorer/impls/prediction-v0-baseline/strategy.js.map +1 -0
  241. package/dist/restorer/impls/prediction-v0-baseline/types.d.ts +7 -0
  242. package/dist/restorer/impls/prediction-v0-baseline/types.js +2 -0
  243. package/dist/restorer/impls/prediction-v0-baseline/types.js.map +1 -0
  244. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.d.ts +20 -0
  245. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js +66 -0
  246. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js.map +1 -0
  247. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.d.ts +9 -0
  248. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js +23 -0
  249. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js.map +1 -0
  250. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.d.ts +3 -0
  251. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js +13 -0
  252. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js.map +1 -0
  253. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.d.ts +7 -0
  254. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js +93 -0
  255. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js.map +1 -0
  256. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.d.ts +5 -0
  257. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js +20 -0
  258. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js.map +1 -0
  259. package/dist/restorer/impls/prediction-v0-evaluator/index.d.ts +33 -0
  260. package/dist/restorer/impls/prediction-v0-evaluator/index.js +208 -0
  261. package/dist/restorer/impls/prediction-v0-evaluator/index.js.map +1 -0
  262. package/dist/restorer/impls/prediction-v0-evaluator/score.d.ts +8 -0
  263. package/dist/restorer/impls/prediction-v0-evaluator/score.js +15 -0
  264. package/dist/restorer/impls/prediction-v0-evaluator/score.js.map +1 -0
  265. package/dist/restorer/impls/prediction-v0-evaluator/types.d.ts +7 -0
  266. package/dist/restorer/impls/prediction-v0-evaluator/types.js +2 -0
  267. package/dist/restorer/impls/prediction-v0-evaluator/types.js.map +1 -0
  268. package/dist/restorer/types.d.ts +177 -0
  269. package/dist/restorer/types.js +7 -0
  270. package/dist/restorer/types.js.map +1 -0
  271. package/dist/store/store.d.ts +3 -1
  272. package/dist/store/store.js +3 -0
  273. package/dist/store/store.js.map +1 -1
  274. package/dist/types/desired-state.d.ts +53 -0
  275. package/dist/types/desired-state.js +20 -0
  276. package/dist/types/desired-state.js.map +1 -1
  277. package/dist/types/index.d.ts +4 -1
  278. package/dist/types/index.js +4 -1
  279. package/dist/types/index.js.map +1 -1
  280. package/dist/types/portfolio.d.ts +1000 -0
  281. package/dist/types/portfolio.js +168 -0
  282. package/dist/types/portfolio.js.map +1 -0
  283. package/dist/types/prediction-apy.d.ts +919 -0
  284. package/dist/types/prediction-apy.js +121 -0
  285. package/dist/types/prediction-apy.js.map +1 -0
  286. package/dist/types/prediction.d.ts +925 -0
  287. package/dist/types/prediction.js +140 -0
  288. package/dist/types/prediction.js.map +1 -0
  289. package/dist/venues/aave-v3/addresses.d.ts +6 -0
  290. package/dist/venues/aave-v3/addresses.js +19 -0
  291. package/dist/venues/aave-v3/addresses.js.map +1 -0
  292. package/dist/venues/aave-v3/client.d.ts +81 -0
  293. package/dist/venues/aave-v3/client.js +97 -0
  294. package/dist/venues/aave-v3/client.js.map +1 -0
  295. package/dist/venues/chainlink/client.d.ts +99 -0
  296. package/dist/venues/chainlink/client.js +130 -0
  297. package/dist/venues/chainlink/client.js.map +1 -0
  298. package/dist/venues/chainlink/feeds.d.ts +8 -0
  299. package/dist/venues/chainlink/feeds.js +9 -0
  300. package/dist/venues/chainlink/feeds.js.map +1 -0
  301. package/dist/venues/hyperliquid/account-value.d.ts +30 -0
  302. package/dist/venues/hyperliquid/account-value.js +30 -0
  303. package/dist/venues/hyperliquid/account-value.js.map +1 -0
  304. package/dist/venues/hyperliquid/client.d.ts +63 -0
  305. package/dist/venues/hyperliquid/client.js +135 -0
  306. package/dist/venues/hyperliquid/client.js.map +1 -0
  307. package/dist/venues/hyperliquid/grid.d.ts +36 -0
  308. package/dist/venues/hyperliquid/grid.js +61 -0
  309. package/dist/venues/hyperliquid/grid.js.map +1 -0
  310. package/dist/venues/hyperliquid/types.d.ts +81 -0
  311. package/dist/venues/hyperliquid/types.js +8 -0
  312. package/dist/venues/hyperliquid/types.js.map +1 -0
  313. package/dist/withdraw/run-withdraw-plan.js +2 -0
  314. package/dist/withdraw/run-withdraw-plan.js.map +1 -1
  315. package/docker-compose.yml +44 -0
  316. package/package.json +12 -1
  317. package/skills/jinn-operator/SKILL.md +85 -0
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Typed ABI fragments for ClaimRegistry.
3
+ *
4
+ * Mirrors the Solidity interface in contracts/src/claiming/ClaimRegistry.sol.
5
+ * Use these instead of the inline fragment in adapters/mech/types.ts when
6
+ * constructing a ClaimRegistryClient — they include the full event set.
7
+ */
8
+ export const CLAIM_REGISTRY_ABI = [
9
+ // ── Write functions ──────────────────────────────────────────────────────────
10
+ {
11
+ name: 'claimJob',
12
+ type: 'function',
13
+ stateMutability: 'nonpayable',
14
+ inputs: [{ name: 'requestId', type: 'bytes32' }],
15
+ outputs: [],
16
+ },
17
+ {
18
+ name: 'releaseClaim',
19
+ type: 'function',
20
+ stateMutability: 'nonpayable',
21
+ inputs: [{ name: 'requestId', type: 'bytes32' }],
22
+ outputs: [],
23
+ },
24
+ {
25
+ name: 'expireClaim',
26
+ type: 'function',
27
+ stateMutability: 'nonpayable',
28
+ inputs: [{ name: 'requestId', type: 'bytes32' }],
29
+ outputs: [],
30
+ },
31
+ // ── Read functions ───────────────────────────────────────────────────────────
32
+ {
33
+ name: 'getJobClaim',
34
+ type: 'function',
35
+ stateMutability: 'view',
36
+ inputs: [{ name: 'requestId', type: 'bytes32' }],
37
+ outputs: [
38
+ { name: 'claimer', type: 'address' },
39
+ { name: 'expiresAt', type: 'uint256' },
40
+ ],
41
+ },
42
+ {
43
+ name: 'claims',
44
+ type: 'function',
45
+ stateMutability: 'view',
46
+ inputs: [{ name: '', type: 'bytes32' }],
47
+ outputs: [
48
+ { name: 'claimer', type: 'address' },
49
+ { name: 'expiresAt', type: 'uint256' },
50
+ ],
51
+ },
52
+ {
53
+ name: 'claimTTL',
54
+ type: 'function',
55
+ stateMutability: 'view',
56
+ inputs: [],
57
+ outputs: [{ name: '', type: 'uint256' }],
58
+ },
59
+ {
60
+ name: 'expiredClaimCount',
61
+ type: 'function',
62
+ stateMutability: 'view',
63
+ inputs: [{ name: '', type: 'address' }],
64
+ outputs: [{ name: '', type: 'uint256' }],
65
+ },
66
+ // ── Events ───────────────────────────────────────────────────────────────────
67
+ {
68
+ name: 'JobClaimed',
69
+ type: 'event',
70
+ inputs: [
71
+ { name: 'requestId', type: 'bytes32', indexed: true },
72
+ { name: 'claimer', type: 'address', indexed: true },
73
+ { name: 'expiresAt', type: 'uint256', indexed: false },
74
+ ],
75
+ },
76
+ {
77
+ name: 'ClaimExpired',
78
+ type: 'event',
79
+ inputs: [
80
+ { name: 'requestId', type: 'bytes32', indexed: true },
81
+ { name: 'previousClaimer', type: 'address', indexed: true },
82
+ ],
83
+ },
84
+ {
85
+ name: 'ClaimReleased',
86
+ type: 'event',
87
+ inputs: [
88
+ { name: 'requestId', type: 'bytes32', indexed: true },
89
+ { name: 'claimer', type: 'address', indexed: true },
90
+ ],
91
+ },
92
+ ];
93
+ //# sourceMappingURL=abi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi.js","sourceRoot":"","sources":["../../../src/adapters/claim-registry/abi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,gFAAgF;IAEhF;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAChD,OAAO,EAAE,EAAE;KACZ;IACD;QACE,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAChD,OAAO,EAAE,EAAE;KACZ;IACD;QACE,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAChD,OAAO,EAAE,EAAE;KACZ;IAED,gFAAgF;IAEhF;QACE,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,MAA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AE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;SACvD;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,OAAO;QACb,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;YACrD,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;SAC5D;KACF;IACD;QACE,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,OAAO;QACb,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;YACrD,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;SACpD;KACF;CACO,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * ClaimRegistryClient — typed wrapper for the ClaimRegistry contract.
3
+ *
4
+ * Wraps the read/write surfaces of ClaimRegistry with proper types and
5
+ * idiomatic async interfaces.
6
+ *
7
+ * Write operations (claimJob, releaseClaim) go through the Safe multisig via
8
+ * executeSafeTransaction. This is required so that the on-chain claimer address
9
+ * matches the Safe — our canonical OLAS/staking identity. Using the raw EOA
10
+ * would cause a mismatch: OnChainClaimPolicy already claims through the Safe,
11
+ * so `weAlreadyClaimed()` would return false even when the Safe holds the claim,
12
+ * triggering a redundant on-chain write that reverts as JobAlreadyClaimed.
13
+ *
14
+ * expireClaim() is permissionless (anyone can GC others' expired claims) and
15
+ * is kept as a direct EOA call — the gas payer does not affect claim ownership.
16
+ */
17
+ import { type Address, type Hex, type PublicClient, type WalletClient } from 'viem';
18
+ export declare const ZERO_ADDRESS: Address;
19
+ export interface JobClaimInfo {
20
+ claimer: Address;
21
+ /** Unix timestamp (seconds) when the claim expires. 0 if no active claim. */
22
+ expiresAt: bigint;
23
+ /** True if claimer !== ZERO_ADDRESS and expiresAt > 0 (claim is still active per contract). */
24
+ isActive: boolean;
25
+ }
26
+ export interface ClaimJobResult {
27
+ /** Transaction hash. Empty string when skipped (already ours or failed). */
28
+ txHash: string;
29
+ /** True if we now hold the claim (new or pre-existing). */
30
+ claimed: boolean;
31
+ }
32
+ export declare class ClaimRegistryClient {
33
+ private readonly publicClient;
34
+ private readonly walletClient;
35
+ private readonly contractAddress;
36
+ /**
37
+ * The Safe multisig address — used as the canonical claimer identity.
38
+ * claimJob/releaseClaim are routed through Safe so that msg.sender on-chain
39
+ * is the Safe address, matching the OLAS staking identity.
40
+ */
41
+ private readonly safeAddress;
42
+ constructor(publicClient: PublicClient, walletClient: WalletClient, contractAddress: Address,
43
+ /**
44
+ * The Safe multisig address — used as the canonical claimer identity.
45
+ * claimJob/releaseClaim are routed through Safe so that msg.sender on-chain
46
+ * is the Safe address, matching the OLAS staking identity.
47
+ */
48
+ safeAddress: Address);
49
+ /**
50
+ * Read the active claim for a request.
51
+ * Returns `(ZERO_ADDRESS, 0, false)` if no active claim (contract returns
52
+ * (address(0), 0) for expired/non-existent claims).
53
+ */
54
+ getJobClaim(requestId: Hex): Promise<JobClaimInfo>;
55
+ /**
56
+ * Check whether the Safe already holds an active claim for this request.
57
+ * Used for idempotency on resume.
58
+ */
59
+ weAlreadyClaimed(requestId: Hex): Promise<boolean>;
60
+ /**
61
+ * Claim a marketplace request through the Safe multisig.
62
+ *
63
+ * Idempotent: if the Safe already holds an active claim, returns
64
+ * `{ txHash: '', claimed: true }` without submitting a transaction.
65
+ *
66
+ * Returns `{ txHash: '', claimed: false }` when:
67
+ * - Another address holds an active claim
68
+ * - The eligibility check fails (IneligibleToClaim)
69
+ * - The tx reverts for any other handled reason
70
+ *
71
+ * Throws on unrecognised RPC errors.
72
+ */
73
+ claimJob(requestId: Hex): Promise<ClaimJobResult>;
74
+ /**
75
+ * Voluntarily release a claim through the Safe multisig (no punishment).
76
+ * Should only be called when the Safe holds the claim.
77
+ * No-op (returns false) if the Safe doesn't hold the claim.
78
+ */
79
+ releaseClaim(requestId: Hex): Promise<boolean>;
80
+ /**
81
+ * Garbage-collect a stale (expired) claim.
82
+ *
83
+ * expireClaim is permissionless — anyone can call it to GC others' expired
84
+ * claims. The caller gets no reward; the previous claimer gets an
85
+ * expiredClaimCount increment. Since the gas payer doesn't affect claim
86
+ * ownership, this is sent directly from the EOA (cheaper than a Safe tx).
87
+ */
88
+ expireClaim(requestId: Hex): Promise<boolean>;
89
+ }
@@ -0,0 +1,205 @@
1
+ /**
2
+ * ClaimRegistryClient — typed wrapper for the ClaimRegistry contract.
3
+ *
4
+ * Wraps the read/write surfaces of ClaimRegistry with proper types and
5
+ * idiomatic async interfaces.
6
+ *
7
+ * Write operations (claimJob, releaseClaim) go through the Safe multisig via
8
+ * executeSafeTransaction. This is required so that the on-chain claimer address
9
+ * matches the Safe — our canonical OLAS/staking identity. Using the raw EOA
10
+ * would cause a mismatch: OnChainClaimPolicy already claims through the Safe,
11
+ * so `weAlreadyClaimed()` would return false even when the Safe holds the claim,
12
+ * triggering a redundant on-chain write that reverts as JobAlreadyClaimed.
13
+ *
14
+ * expireClaim() is permissionless (anyone can GC others' expired claims) and
15
+ * is kept as a direct EOA call — the gas payer does not affect claim ownership.
16
+ */
17
+ import { encodeFunctionData, } from 'viem';
18
+ import { CLAIM_REGISTRY_ABI } from './abi.js';
19
+ import { executeSafeTransaction } from '../mech/safe.js';
20
+ import { waitForTransactionReceiptWithRetry } from '../../tx-retry.js';
21
+ export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
22
+ // ── ClaimRegistryClient ───────────────────────────────────────────────────────
23
+ export class ClaimRegistryClient {
24
+ publicClient;
25
+ walletClient;
26
+ contractAddress;
27
+ safeAddress;
28
+ constructor(publicClient, walletClient, contractAddress,
29
+ /**
30
+ * The Safe multisig address — used as the canonical claimer identity.
31
+ * claimJob/releaseClaim are routed through Safe so that msg.sender on-chain
32
+ * is the Safe address, matching the OLAS staking identity.
33
+ */
34
+ safeAddress) {
35
+ this.publicClient = publicClient;
36
+ this.walletClient = walletClient;
37
+ this.contractAddress = contractAddress;
38
+ this.safeAddress = safeAddress;
39
+ }
40
+ // ── Read methods ─────────────────────────────────────────────────────────────
41
+ /**
42
+ * Read the active claim for a request.
43
+ * Returns `(ZERO_ADDRESS, 0, false)` if no active claim (contract returns
44
+ * (address(0), 0) for expired/non-existent claims).
45
+ */
46
+ async getJobClaim(requestId) {
47
+ const result = await this.publicClient.readContract({
48
+ address: this.contractAddress,
49
+ abi: CLAIM_REGISTRY_ABI,
50
+ functionName: 'getJobClaim',
51
+ args: [requestId],
52
+ });
53
+ const claimer = result[0];
54
+ const expiresAt = result[1];
55
+ return {
56
+ claimer,
57
+ expiresAt,
58
+ isActive: claimer !== ZERO_ADDRESS && expiresAt > 0n,
59
+ };
60
+ }
61
+ /**
62
+ * Check whether the Safe already holds an active claim for this request.
63
+ * Used for idempotency on resume.
64
+ */
65
+ async weAlreadyClaimed(requestId) {
66
+ const info = await this.getJobClaim(requestId);
67
+ return (info.isActive &&
68
+ info.claimer.toLowerCase() === this.safeAddress.toLowerCase());
69
+ }
70
+ // ── Write methods ─────────────────────────────────────────────────────────────
71
+ /**
72
+ * Claim a marketplace request through the Safe multisig.
73
+ *
74
+ * Idempotent: if the Safe already holds an active claim, returns
75
+ * `{ txHash: '', claimed: true }` without submitting a transaction.
76
+ *
77
+ * Returns `{ txHash: '', claimed: false }` when:
78
+ * - Another address holds an active claim
79
+ * - The eligibility check fails (IneligibleToClaim)
80
+ * - The tx reverts for any other handled reason
81
+ *
82
+ * Throws on unrecognised RPC errors.
83
+ */
84
+ async claimJob(requestId) {
85
+ // Idempotency: already claimed by our Safe
86
+ const existing = await this.getJobClaim(requestId);
87
+ if (existing.isActive) {
88
+ if (existing.claimer.toLowerCase() === this.safeAddress.toLowerCase()) {
89
+ return { txHash: '', claimed: true };
90
+ }
91
+ // Someone else has an active claim
92
+ return { txHash: '', claimed: false };
93
+ }
94
+ const data = encodeFunctionData({
95
+ abi: CLAIM_REGISTRY_ABI,
96
+ functionName: 'claimJob',
97
+ args: [requestId],
98
+ });
99
+ try {
100
+ const txHash = await executeSafeTransaction(this.publicClient, this.walletClient, {
101
+ safeAddress: this.safeAddress,
102
+ to: this.contractAddress,
103
+ value: 0n,
104
+ data,
105
+ });
106
+ // executeSafeTransaction waits for the receipt internally, but does not
107
+ // inspect its status. Wait again with full retry and throw if reverted so
108
+ // callers don't see a false-positive claimed=true on a reverted claim.
109
+ const receipt = await waitForTransactionReceiptWithRetry(this.publicClient, txHash, {
110
+ onRetry: ({ attempt, message }) => {
111
+ console.error(`[claim-registry] wait claimJob receipt retry ${attempt}: ${message}`);
112
+ },
113
+ });
114
+ if (receipt.status !== 'success') {
115
+ throw new Error(`claimJob transaction reverted (status=${receipt.status}, txHash=${txHash})`);
116
+ }
117
+ return { txHash, claimed: true };
118
+ }
119
+ catch (err) {
120
+ const message = err instanceof Error ? err.message : String(err);
121
+ if (message.includes('JobAlreadyClaimed') ||
122
+ message.includes('IneligibleToClaim') ||
123
+ message.includes('execution reverted')) {
124
+ return { txHash: '', claimed: false };
125
+ }
126
+ throw err;
127
+ }
128
+ }
129
+ /**
130
+ * Voluntarily release a claim through the Safe multisig (no punishment).
131
+ * Should only be called when the Safe holds the claim.
132
+ * No-op (returns false) if the Safe doesn't hold the claim.
133
+ */
134
+ async releaseClaim(requestId) {
135
+ // Verify the Safe holds the claim before sending a tx that would revert
136
+ const existing = await this.getJobClaim(requestId);
137
+ if (!existing.isActive ||
138
+ existing.claimer.toLowerCase() !== this.safeAddress.toLowerCase()) {
139
+ return false;
140
+ }
141
+ const data = encodeFunctionData({
142
+ abi: CLAIM_REGISTRY_ABI,
143
+ functionName: 'releaseClaim',
144
+ args: [requestId],
145
+ });
146
+ try {
147
+ await executeSafeTransaction(this.publicClient, this.walletClient, {
148
+ safeAddress: this.safeAddress,
149
+ to: this.contractAddress,
150
+ value: 0n,
151
+ data,
152
+ });
153
+ return true;
154
+ }
155
+ catch (err) {
156
+ const message = err instanceof Error ? err.message : String(err);
157
+ // NotClaimOwner or NoClaimExists — claim was already gone
158
+ if (message.includes('NotClaimOwner') || message.includes('NoClaimExists')) {
159
+ return false;
160
+ }
161
+ throw err;
162
+ }
163
+ }
164
+ /**
165
+ * Garbage-collect a stale (expired) claim.
166
+ *
167
+ * expireClaim is permissionless — anyone can call it to GC others' expired
168
+ * claims. The caller gets no reward; the previous claimer gets an
169
+ * expiredClaimCount increment. Since the gas payer doesn't affect claim
170
+ * ownership, this is sent directly from the EOA (cheaper than a Safe tx).
171
+ */
172
+ async expireClaim(requestId) {
173
+ const account = this.walletClient.account;
174
+ if (!account)
175
+ throw new Error('[ClaimRegistryClient] walletClient has no account');
176
+ const data = encodeFunctionData({
177
+ abi: CLAIM_REGISTRY_ABI,
178
+ functionName: 'expireClaim',
179
+ args: [requestId],
180
+ });
181
+ try {
182
+ const txHash = await this.walletClient.sendTransaction({
183
+ account,
184
+ chain: null,
185
+ to: this.contractAddress,
186
+ data,
187
+ value: 0n,
188
+ });
189
+ await waitForTransactionReceiptWithRetry(this.publicClient, txHash, {
190
+ onRetry: ({ attempt, message }) => {
191
+ console.error(`[claim-registry] wait expireClaim receipt retry ${attempt}: ${message}`);
192
+ },
193
+ });
194
+ return true;
195
+ }
196
+ catch (err) {
197
+ const message = err instanceof Error ? err.message : String(err);
198
+ if (message.includes('NoClaimExists') || message.includes('ClaimNotExpired')) {
199
+ return false;
200
+ }
201
+ throw err;
202
+ }
203
+ }
204
+ }
205
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/adapters/claim-registry/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,kBAAkB,GAKnB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9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AAC;QACd,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,IAAI,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBAC7E,OAAO,KAAK,CAAC;YACf,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
@@ -13,6 +13,7 @@ export declare class MechAdapter implements ExecutionAdapter {
13
13
  private pendingEvaluations;
14
14
  private pendingEvaluationClaims;
15
15
  private claimedButNotEvaluated;
16
+ private pendingEvaluationResults;
16
17
  private originalStates;
17
18
  private store?;
18
19
  private claimPolicy;
@@ -20,6 +20,9 @@ export class MechAdapter {
20
20
  // Restoration requests where claimDelivery succeeded but evaluation creation failed.
21
21
  // Swept on each poll cycle so they don't require a new Deliver event.
22
22
  claimedButNotEvaluated = new Set();
23
+ // Restoration result content cached across evaluation-job retries so a transient
24
+ // Safe/router failure does not silently strip evaluator context on the next poll.
25
+ pendingEvaluationResults = new Map();
23
26
  // Original desired states keyed by request ID (restoration and evaluation)
24
27
  // so we can yield accurate desiredState in DeliveredResult
25
28
  originalStates = new Map();
@@ -143,15 +146,27 @@ export class MechAdapter {
143
146
  });
144
147
  this.requestBlockCursor = currentBlock;
145
148
  const decoded = decodeMarketplaceRequestLogs(logs);
146
- for (const { requestId, requestDataHex, priorityMech } of decoded) {
149
+ for (const { requestId, requestDataHex, priorityMech, transactionHash, blockNumber } of decoded) {
147
150
  if (!this.claimPolicy.shouldAccept({ requestId, requestDataHex, priorityMech })) {
148
151
  continue;
149
152
  }
150
153
  try {
151
154
  const digest = requestDataHex.startsWith('0x') ? requestDataHex.slice(2) : requestDataHex;
152
- const payload = await fetchFromIpfs(this.config.ipfsGatewayUrl, `f01551220${digest}`);
155
+ // CIDv1 hex with raw codec (0x55) + sha2-256 (0x12) + 32-byte length (0x20).
156
+ // The Autonolas registry returns raw-codec CIDs when uploading files with
157
+ // cid-version=1 (Kubo default for files). This is confirmed by the existing
158
+ // IPFS_GATEWAY_PREFIX constant (f01551220) which has worked in production.
159
+ // If the gateway ever switches to dag-pb (0x70) the prefix would be f01701220.
160
+ const intentCid = `f01551220${digest}`;
161
+ const payload = await fetchFromIpfs(this.config.ipfsGatewayUrl, intentCid);
153
162
  const desiredState = parseDesiredStateFromPayload(payload);
154
- yield { requestId, desiredState };
163
+ yield {
164
+ requestId,
165
+ desiredState,
166
+ intentCid,
167
+ onchainCreationTx: transactionHash,
168
+ onchainCreationBlock: blockNumber,
169
+ };
155
170
  }
156
171
  catch (err) {
157
172
  console.error(`[mech] Failed to parse request ${requestId}:`, err);
@@ -195,45 +210,59 @@ export class MechAdapter {
195
210
  this.deliveryBlockCursor = currentBlock;
196
211
  const decoded = decodeDeliverLogs(logs);
197
212
  for (const { requestId, deliveryDataHex, mechAddress } of decoded) {
198
- // Only claim deliveries for requests this client created
199
- const isOurs = this.pendingEvaluations.has(requestId) || this.pendingEvaluationClaims.has(requestId);
200
- if (!isOurs)
213
+ // Two concerns, independent:
214
+ // (a) Did this Safe DELIVER this? → claim it (counter credit goes to msg.sender)
215
+ // The Deliver event's mechAddress is mechServiceMultisig (the Safe that owns
216
+ // the mech), so we compare against this.config.safeAddress.
217
+ // (b) Did this Safe CREATE the underlying request? → act on the delivery
218
+ // (trigger eval creation for restoration deliveries; clean up for eval deliveries)
219
+ const iDelivered = mechAddress.toLowerCase() === this.config.safeAddress.toLowerCase();
220
+ const iCreatedRestoration = this.pendingEvaluations.has(requestId);
221
+ const iCreatedEvaluation = this.pendingEvaluationClaims.has(requestId);
222
+ if (!iDelivered && !iCreatedRestoration && !iCreatedEvaluation)
201
223
  continue;
202
- try {
203
- const variant = this.config.routerClaimDeliveryVariant;
204
- let evidenceHash;
205
- if (variant === 'v2' && this.pendingEvaluations.has(requestId)) {
206
- try {
207
- const checkpoint = {
208
- version: 1,
209
- desiredStateHash: requestId,
210
- toolCalls: [],
211
- externalInteractions: [],
212
- outcome: 'success',
213
- };
214
- evidenceHash = computeEvidenceSimHash(checkpoint);
215
- }
216
- catch (err) {
217
- console.error(`[mech] Failed to compute evidence SimHash for ${requestId}:`, err);
224
+ // (a) If I delivered, claim delivery → msg.sender = my Safe → correct role credit.
225
+ if (iDelivered) {
226
+ try {
227
+ const variant = this.config.routerClaimDeliveryVariant;
228
+ let evidenceHash;
229
+ if (variant === 'v2') {
230
+ try {
231
+ const checkpoint = {
232
+ version: 1,
233
+ desiredStateHash: requestId,
234
+ toolCalls: [],
235
+ externalInteractions: [],
236
+ outcome: 'success',
237
+ };
238
+ evidenceHash = computeEvidenceSimHash(checkpoint);
239
+ }
240
+ catch (err) {
241
+ console.error(`[mech] Failed to compute evidence SimHash for ${requestId}:`, err);
242
+ }
218
243
  }
244
+ await claimDelivery(this.publicClient, this.walletClient, this.config.safeAddress, this.config.routerAddress, requestId, { variant, evidenceHash });
219
245
  }
220
- await claimDelivery(this.publicClient, this.walletClient, this.config.safeAddress, this.config.routerAddress, requestId, {
221
- variant,
222
- evidenceHash,
223
- });
224
- }
225
- catch (err) {
226
- const message = err instanceof Error ? err.message : String(err);
227
- if (message.includes('RequestNotFound')) {
228
- console.error(`[mech] claimDelivery skipped (not a router request): ${requestId}`);
229
- continue;
246
+ catch (err) {
247
+ const message = err instanceof Error ? err.message : String(err);
248
+ if (message.includes('RequestNotFound')) {
249
+ console.error(`[mech] claimDelivery skipped (not a router request): ${requestId}`);
250
+ // fall through — creator actions below don't depend on our claim specifically
251
+ }
252
+ else if (/already.*claimed|alreadyClaimed/i.test(message)) {
253
+ // Idempotent: someone else raced us, fine.
254
+ }
255
+ else {
256
+ console.error(`[mech] claimDelivery failed for ${requestId}:`, err);
257
+ // Don't continue — may retry next poll via unchanged tracking
258
+ continue;
259
+ }
230
260
  }
231
- console.error(`[mech] claimDelivery failed for ${requestId}:`, err);
232
- // Don't remove from pending — will retry next poll
233
- continue;
234
261
  }
235
- // If this was a restoration delivery, fetch result and post the evaluation job
236
- if (this.pendingEvaluations.has(requestId)) {
262
+ // (b) If I created the restoration, post the eval job once the claim is on-chain.
263
+ // The deliverer (someone else, or us if we also delivered) must have claimed first.
264
+ // tryCreateEvaluationJob calls verifyRestorationClaimed() which polls for the claim.
265
+ if (iCreatedRestoration) {
237
266
  let restorationResultData;
238
267
  try {
239
268
  const digest = deliveryDataHex.startsWith('0x') ? deliveryDataHex.slice(2) : deliveryDataHex;
@@ -245,11 +274,11 @@ export class MechAdapter {
245
274
  }
246
275
  await this.tryCreateEvaluationJob(requestId, restorationResultData);
247
276
  }
248
- // If this was an evaluation delivery, just clear the tracking
249
- if (this.pendingEvaluationClaims.has(requestId)) {
277
+ // (c) If I created the evaluation, clean up tracking once delivered.
278
+ if (iCreatedEvaluation) {
250
279
  this.pendingEvaluationClaims.delete(requestId);
251
280
  }
252
- // Parse and yield the delivery result
281
+ // (d) Yield the delivery result.
253
282
  try {
254
283
  const deliveryDigest = deliveryDataHex.startsWith('0x') ? deliveryDataHex.slice(2) : deliveryDataHex;
255
284
  const resultPayload = await fetchFromIpfs(this.config.ipfsGatewayUrl, `f01551220${deliveryDigest}`);
@@ -291,6 +320,10 @@ export class MechAdapter {
291
320
  if (!this.pendingEvaluations.has(requestId))
292
321
  return;
293
322
  const originalState = this.pendingEvaluations.get(requestId);
323
+ if (restorationResultData) {
324
+ this.pendingEvaluationResults.set(requestId, restorationResultData);
325
+ }
326
+ const cachedRestorationResultData = restorationResultData ?? this.pendingEvaluationResults.get(requestId);
294
327
  try {
295
328
  const evaluationState = {
296
329
  ...originalState,
@@ -298,7 +331,7 @@ export class MechAdapter {
298
331
  restorationRequestId: requestId,
299
332
  context: {
300
333
  ...originalState.context,
301
- ...(restorationResultData ? { restorationResult: restorationResultData } : {}),
334
+ ...(cachedRestorationResultData ? { restorationResult: cachedRestorationResultData } : {}),
302
335
  },
303
336
  };
304
337
  const evaluationPayload = buildDesiredStatePayload(evaluationState);
@@ -328,6 +361,7 @@ export class MechAdapter {
328
361
  // Success — clean up both tracking sets
329
362
  this.pendingEvaluations.delete(requestId);
330
363
  this.claimedButNotEvaluated.delete(requestId);
364
+ this.pendingEvaluationResults.delete(requestId);
331
365
  }
332
366
  catch (err) {
333
367
  console.error(`[mech] Failed to create evaluation job for ${requestId}:`, err);