@oakagentkit/core 0.3.3 → 0.3.5

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 (302) hide show
  1. package/build/dist/api/canonical.js +1 -1
  2. package/build/dist/api/history.d.ts +0 -3
  3. package/build/dist/api/history.js +1 -1
  4. package/build/dist/api/merkle.d.ts +1 -27
  5. package/build/dist/api/merkle.js +1 -1
  6. package/build/dist/api/modules/borro/actions.js +1 -1
  7. package/build/dist/api/modules/borro/checks.js +1 -1
  8. package/build/dist/api/modules/borro/index.js +1 -1
  9. package/build/dist/api/modules/borro/liquidity.js +1 -1
  10. package/build/dist/api/modules/borro/positions.js +1 -1
  11. package/build/dist/api/modules/borro/reader.js +1 -1
  12. package/build/dist/api/modules/chop/actions.d.ts +13 -1
  13. package/build/dist/api/modules/chop/actions.js +1 -1
  14. package/build/dist/api/modules/chop/checks.js +1 -1
  15. package/build/dist/api/modules/chop/copy.d.ts +2 -1
  16. package/build/dist/api/modules/chop/copy.js +1 -1
  17. package/build/dist/api/modules/chop/display.d.ts +36 -0
  18. package/build/dist/api/modules/chop/display.js +1 -0
  19. package/build/dist/api/modules/chop/guard.js +1 -1
  20. package/build/dist/api/modules/chop/index.js +1 -1
  21. package/build/dist/api/modules/chop/pins.d.ts +6 -0
  22. package/build/dist/api/modules/chop/pins.js +1 -1
  23. package/build/dist/api/modules/chop/positions.js +1 -1
  24. package/build/dist/api/modules/chop/reader.d.ts +6 -1
  25. package/build/dist/api/modules/chop/reader.js +1 -1
  26. package/build/dist/api/modules/chop/types.d.ts +7 -0
  27. package/build/dist/api/modules/chop/unfarm.d.ts +16 -0
  28. package/build/dist/api/modules/chop/unfarm.js +1 -0
  29. package/build/dist/api/modules/clanker/index.js +1 -1
  30. package/build/dist/api/modules/earn/index.js +1 -1
  31. package/build/dist/api/modules/erc8004/index.js +1 -1
  32. package/build/dist/api/modules/factor/actions.js +1 -1
  33. package/build/dist/api/modules/factor/api.js +1 -1
  34. package/build/dist/api/modules/factor/checks.js +1 -1
  35. package/build/dist/api/modules/factor/copy.d.ts +11 -11
  36. package/build/dist/api/modules/factor/copy.js +1 -1
  37. package/build/dist/api/modules/factor/guard.js +1 -1
  38. package/build/dist/api/modules/factor/index.js +1 -1
  39. package/build/dist/api/modules/factor/reader.js +1 -1
  40. package/build/dist/api/modules/fobo/client.d.ts +5 -0
  41. package/build/dist/api/modules/fobo/client.js +1 -1
  42. package/build/dist/api/modules/fobo/health.d.ts +4 -0
  43. package/build/dist/api/modules/fobo/health.js +1 -0
  44. package/build/dist/api/modules/fobo/index.js +1 -1
  45. package/build/dist/api/modules/fobo/referral.d.ts +2 -0
  46. package/build/dist/api/modules/fobo/referral.js +1 -0
  47. package/build/dist/api/modules/fobo/steps.js +1 -1
  48. package/build/dist/api/modules/gloam/index.js +1 -1
  49. package/build/dist/api/modules/grove/index.js +1 -1
  50. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  51. package/build/dist/api/modules/heyresearch/index.js +1 -1
  52. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  53. package/build/dist/api/modules/heyresearch/scan.js +1 -1
  54. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  55. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  56. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  57. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  58. package/build/dist/api/modules/hoodlock/index.js +1 -1
  59. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  60. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  61. package/build/dist/api/modules/hoodlock/public.js +1 -1
  62. package/build/dist/api/modules/hookr/actions.js +1 -1
  63. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  64. package/build/dist/api/modules/hookr/discovery.js +1 -1
  65. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  66. package/build/dist/api/modules/hookr/index.js +1 -1
  67. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  68. package/build/dist/api/modules/hookr/launch.js +1 -1
  69. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  70. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  71. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  72. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  73. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  74. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  75. package/build/dist/api/modules/hookr/relay.js +1 -1
  76. package/build/dist/api/modules/layerbank/actions.js +1 -1
  77. package/build/dist/api/modules/layerbank/index.js +1 -1
  78. package/build/dist/api/modules/layerbank/reader.js +1 -1
  79. package/build/dist/api/modules/longbow/administration.js +1 -1
  80. package/build/dist/api/modules/longbow/fixed.js +1 -1
  81. package/build/dist/api/modules/longbow/index.js +1 -1
  82. package/build/dist/api/modules/meridian/index.js +1 -1
  83. package/build/dist/api/modules/meridian/predict-read.js +1 -1
  84. package/build/dist/api/modules/merkl/discovery.js +1 -1
  85. package/build/dist/api/modules/merkl/index.js +1 -1
  86. package/build/dist/api/modules/merkl/manage.js +1 -1
  87. package/build/dist/api/modules/morpho/bundles.js +1 -1
  88. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  89. package/build/dist/api/modules/morpho/index.js +1 -1
  90. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  91. package/build/dist/api/modules/morpho/midnight.js +1 -1
  92. package/build/dist/api/modules/morpho/protocol.js +1 -1
  93. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  94. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  95. package/build/dist/api/modules/netnet/card-read.js +1 -1
  96. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  97. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  98. package/build/dist/api/modules/netnet/financial.js +1 -1
  99. package/build/dist/api/modules/netnet/index.js +1 -1
  100. package/build/dist/api/modules/pendle/index.js +1 -1
  101. package/build/dist/api/modules/pendle/reader.js +1 -1
  102. package/build/dist/api/modules/pons/index.js +1 -1
  103. package/build/dist/api/modules/priors/coverage.js +1 -1
  104. package/build/dist/api/modules/priors/discovery.js +1 -1
  105. package/build/dist/api/modules/priors/index.js +1 -1
  106. package/build/dist/api/modules/priors/integration.js +1 -1
  107. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  108. package/build/dist/api/modules/raeto/authorization.js +1 -1
  109. package/build/dist/api/modules/raeto/copy.js +1 -1
  110. package/build/dist/api/modules/raeto/errors.js +1 -1
  111. package/build/dist/api/modules/raeto/estimate.js +1 -1
  112. package/build/dist/api/modules/raeto/index.js +1 -1
  113. package/build/dist/api/modules/raeto/terms.js +1 -1
  114. package/build/dist/api/modules/relay/index.js +1 -1
  115. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  116. package/build/dist/api/modules/spark/index.js +1 -1
  117. package/build/dist/api/modules/steakhouse/index.js +1 -1
  118. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  119. package/build/dist/api/modules/steakhouse/management.js +1 -1
  120. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  121. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  122. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  123. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  124. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  125. package/build/dist/api/modules/tickerspring/index.js +1 -1
  126. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  127. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  128. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  129. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  130. package/build/dist/api/modules/tickerspring/research.js +1 -1
  131. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  132. package/build/dist/api/modules/transfer/stocks.d.ts +18 -0
  133. package/build/dist/api/modules/transfer/stocks.js +1 -0
  134. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  135. package/build/dist/api/modules/uniswap/auction.js +1 -1
  136. package/build/dist/api/modules/uniswap/batch.js +1 -1
  137. package/build/dist/api/modules/uniswap/common.js +1 -1
  138. package/build/dist/api/modules/uniswap/fees.js +1 -1
  139. package/build/dist/api/modules/uniswap/index.js +1 -1
  140. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  141. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  142. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  143. package/build/dist/api/modules/uniswap/pools.js +1 -1
  144. package/build/dist/api/modules/uniswap/position.js +1 -1
  145. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  146. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  147. package/build/dist/api/modules/uniswap/stock-prices.d.ts +9 -0
  148. package/build/dist/api/modules/uniswap/stock-prices.js +1 -0
  149. package/build/dist/api/modules/uniswap/stocks.d.ts +17 -0
  150. package/build/dist/api/modules/uniswap/stocks.js +1 -0
  151. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  152. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  153. package/build/dist/api/modules/uniswap/trade.js +1 -1
  154. package/build/dist/api/modules/uniswap/v2.js +1 -1
  155. package/build/dist/api/modules/uniswap/v3.js +1 -1
  156. package/build/dist/api/modules/uniswap/v4.js +1 -1
  157. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  158. package/build/dist/api/modules/upoch/index.js +1 -1
  159. package/build/dist/api/modules/upoch/reads.js +1 -1
  160. package/build/dist/api/modules/wormhole/index.js +1 -1
  161. package/build/dist/api/prices.d.ts +13 -11
  162. package/build/dist/api/prices.js +1 -1
  163. package/build/dist/api/pricing.d.ts +0 -6
  164. package/build/dist/api/pricing.js +1 -1
  165. package/build/dist/api/send.js +1 -1
  166. package/build/dist/api/signing-registry.js +1 -1
  167. package/build/dist/api/stocks.d.ts +6 -0
  168. package/build/dist/api/stocks.js +1 -0
  169. package/build/dist/api/tokens.d.ts +23 -1
  170. package/build/dist/api/tokens.js +1 -1
  171. package/build/dist/api/tool-policy.js +1 -1
  172. package/build/dist/api/types.d.ts +0 -26
  173. package/build/dist/api/usd-estimate.d.ts +2 -0
  174. package/build/dist/api/usd-estimate.js +1 -1
  175. package/build/dist/chunks/{ODV3XT5U.js → 2FOI2625.js} +1 -1
  176. package/build/dist/chunks/{73BZPPRS.js → 2I7XHRTI.js} +1 -1
  177. package/build/dist/chunks/{257N7343.js → 2PS4GCOZ.js} +1 -1
  178. package/build/dist/chunks/{RA7DOR7F.js → 3BQ5XHDJ.js} +1 -1
  179. package/build/dist/chunks/{5UAXLWJ2.js → 3UC42OJX.js} +1 -1
  180. package/build/dist/chunks/{KVVBT43U.js → 3YH5B5NQ.js} +1 -1
  181. package/build/dist/chunks/{VVJO6OYK.js → 4CEV4FDG.js} +1 -1
  182. package/build/dist/chunks/{RUSXMQSJ.js → 4HQEJHCD.js} +1 -1
  183. package/build/dist/chunks/{HIG7JY3J.js → 4IOHSX3Z.js} +1 -1
  184. package/build/dist/chunks/4UOVKEV4.js +1 -0
  185. package/build/dist/chunks/5H7NVE6O.js +1 -0
  186. package/build/dist/chunks/{JJGZ7W3V.js → 6AS3TGOX.js} +1 -1
  187. package/build/dist/chunks/{AWV24X7F.js → 6CKCZJ3F.js} +1 -1
  188. package/build/dist/chunks/{35LXCSHY.js → 6LVHN33V.js} +1 -1
  189. package/build/dist/chunks/7OOCAZBE.js +1 -0
  190. package/build/dist/chunks/{75SULXNT.js → 7TRO6MBQ.js} +1 -1
  191. package/build/dist/chunks/{EHGH646D.js → A4FLWHLP.js} +1 -1
  192. package/build/dist/chunks/{XVOW6UCI.js → A4K5GXVO.js} +1 -1
  193. package/build/dist/chunks/AL6UXNGH.js +6 -0
  194. package/build/dist/chunks/BJ2U2VXJ.js +1 -0
  195. package/build/dist/chunks/{4TTDAF4B.js → C4XK764N.js} +1 -1
  196. package/build/dist/chunks/{3BMM3V4P.js → C57DITTF.js} +1 -1
  197. package/build/dist/chunks/CFPJDLTZ.js +1 -0
  198. package/build/dist/chunks/{CXH46MHJ.js → CNDIAF3P.js} +1 -1
  199. package/build/dist/chunks/{K4GUZ5QS.js → CW37EGPL.js} +1 -1
  200. package/build/dist/chunks/{22TU5PFT.js → E47UYYK4.js} +1 -1
  201. package/build/dist/chunks/EPOIAXCV.js +3 -0
  202. package/build/dist/chunks/{RXP7ZUPY.js → FCVH4FYH.js} +1 -1
  203. package/build/dist/chunks/{ZSVAGOF2.js → FHB7QYJO.js} +1 -1
  204. package/build/dist/chunks/FRT6AC6M.js +1 -0
  205. package/build/dist/chunks/{NUERUFH7.js → FRVCSDKU.js} +1 -1
  206. package/build/dist/chunks/{LEV5SNNC.js → FUP53K6G.js} +1 -1
  207. package/build/dist/chunks/{5DPJQCKJ.js → FWOGOWUM.js} +2 -2
  208. package/build/dist/chunks/{5CPB33XA.js → G5AMH4IP.js} +1 -1
  209. package/build/dist/chunks/{JDSSYT6R.js → GBPB7JIB.js} +1 -1
  210. package/build/dist/chunks/{MGVX5EUH.js → GDUKZYE2.js} +1 -1
  211. package/build/dist/chunks/{47HSRR7G.js → GKUPC4DO.js} +1 -1
  212. package/build/dist/chunks/{K7HTDKAT.js → GMMTHTCP.js} +1 -1
  213. package/build/dist/chunks/{27PVS6BU.js → HDBZZOHJ.js} +1 -1
  214. package/build/dist/chunks/{FHTNMGFR.js → HKHCN4A2.js} +1 -1
  215. package/build/dist/chunks/{VC5ZCQYZ.js → HPS4KOU4.js} +1 -1
  216. package/build/dist/chunks/IZP3EKKS.js +1 -0
  217. package/build/dist/chunks/{VFM2BICB.js → J7OZLXSG.js} +1 -1
  218. package/build/dist/chunks/{6D3XNCOX.js → JDHPMS7X.js} +1 -1
  219. package/build/dist/chunks/JFC2QCMW.js +1 -0
  220. package/build/dist/chunks/{OFWTO4N6.js → JJSCDDQO.js} +1 -1
  221. package/build/dist/chunks/{EFESPGA2.js → KCZUJ57H.js} +1 -1
  222. package/build/dist/chunks/KHOUBQJK.js +1 -0
  223. package/build/dist/chunks/{UEHN2IDF.js → KKTOBXIT.js} +1 -1
  224. package/build/dist/chunks/KNROSKUG.js +1 -0
  225. package/build/dist/chunks/{SO6O7JK2.js → KO7ANIKY.js} +1 -1
  226. package/build/dist/chunks/{DLNA5272.js → LKUZAJPZ.js} +1 -1
  227. package/build/dist/chunks/{5GQJVKVY.js → LZM3DO5Q.js} +1 -1
  228. package/build/dist/chunks/M267JEDO.js +1 -0
  229. package/build/dist/chunks/M6JNGU4E.js +1 -0
  230. package/build/dist/chunks/{SNCV6HV7.js → M7OVMIIE.js} +1 -1
  231. package/build/dist/chunks/{VDJPDIBV.js → MJGEGNDU.js} +1 -1
  232. package/build/dist/chunks/{XKLXVTSE.js → MQXSCNUL.js} +1 -1
  233. package/build/dist/chunks/N624NR7Y.js +1 -0
  234. package/build/dist/chunks/{M4AGEGWW.js → N65J3L2H.js} +1 -1
  235. package/build/dist/chunks/{3UQXTZ5R.js → N742W5KX.js} +1 -1
  236. package/build/dist/chunks/NIWAVMDR.js +1 -0
  237. package/build/dist/chunks/O2QBSINK.js +1 -0
  238. package/build/dist/chunks/{7TSIF3F4.js → O4P5IQCP.js} +1 -1
  239. package/build/dist/chunks/{HUKDISRE.js → OB3YMTDI.js} +1 -1
  240. package/build/dist/chunks/{GGMVT5A6.js → PV7FEVBD.js} +1 -1
  241. package/build/dist/chunks/{PDGYM2WG.js → Q3Q3YHEX.js} +1 -1
  242. package/build/dist/chunks/QA6Z2CYP.js +2 -0
  243. package/build/dist/chunks/{HPY2ONAS.js → QBNASL3T.js} +1 -1
  244. package/build/dist/chunks/{AHUCYDBC.js → QKIQ7ZKD.js} +1 -1
  245. package/build/dist/chunks/{O3CC5SRM.js → QMIH6HXH.js} +1 -1
  246. package/build/dist/chunks/{3FU6XP6S.js → QQD4PV64.js} +1 -1
  247. package/build/dist/chunks/{VOJULRNU.js → R66NSNNQ.js} +1 -1
  248. package/build/dist/chunks/{SMKO7GKX.js → RP5VCG54.js} +1 -1
  249. package/build/dist/chunks/{7FZXSYFD.js → RUHNLNVX.js} +1 -1
  250. package/build/dist/chunks/{QN45T4N3.js → S37D7HOK.js} +1 -1
  251. package/build/dist/chunks/S47M3IPR.js +1 -0
  252. package/build/dist/chunks/S65KXMZ7.js +3 -0
  253. package/build/dist/chunks/{UBI3HBXD.js → SX5YNFHG.js} +1 -1
  254. package/build/dist/chunks/{SOJHYMD7.js → TGXEKBLV.js} +1 -1
  255. package/build/dist/chunks/{H64QC4QR.js → TJU644I7.js} +1 -1
  256. package/build/dist/chunks/{FSYYD3OM.js → TOIKOIY6.js} +1 -1
  257. package/build/dist/chunks/{I3ZBOSSH.js → TZ7S5KRB.js} +1 -1
  258. package/build/dist/chunks/{XEPCDGN2.js → UCFVPTE2.js} +1 -1
  259. package/build/dist/chunks/UEOS6SHR.js +1 -0
  260. package/build/dist/chunks/{BZPFPQ2I.js → USGMGKAG.js} +1 -1
  261. package/build/dist/chunks/{PKYQ3XVA.js → UUF4Z6K6.js} +1 -1
  262. package/build/dist/chunks/{PMFR47H3.js → VREGY7E6.js} +1 -1
  263. package/build/dist/chunks/{Y7HBFQYG.js → W7BFM6CK.js} +1 -1
  264. package/build/dist/chunks/{72EV7TGI.js → WQ2XTDHO.js} +1 -1
  265. package/build/dist/chunks/WRA3ZC6W.js +1 -0
  266. package/build/dist/chunks/WWYAAIE2.js +1 -0
  267. package/build/dist/chunks/{WCI3FHWT.js → XADHV2DT.js} +1 -1
  268. package/build/dist/chunks/{LVFI74ST.js → XNJ6NDQQ.js} +1 -1
  269. package/build/dist/chunks/{7FIEBJOZ.js → XTXXWRN2.js} +1 -1
  270. package/build/dist/chunks/{PWJVC2FV.js → XWC6IC5E.js} +1 -1
  271. package/build/dist/chunks/{THL4TMQW.js → Y76VZQ26.js} +232 -17
  272. package/build/dist/chunks/{IJ4HZIDG.js → YWVPK3DV.js} +1 -1
  273. package/build/dist/chunks/{WNWRF4HE.js → YZHJ4BAP.js} +1 -1
  274. package/build/dist/chunks/{ZDCCFEVL.js → ZKBOPZH5.js} +1 -1
  275. package/build/dist/chunks/{UCHJYWGU.js → ZQPC54J5.js} +1 -1
  276. package/build/dist/chunks/{6GWXPQZ6.js → ZVY7GGSP.js} +1 -1
  277. package/build/dist/chunks/{LQSPWRHN.js → ZX43P4BK.js} +1 -1
  278. package/build/dist/chunks/{YAVWSW3G.js → ZXFJKW6H.js} +1 -1
  279. package/build/dist/chunks/{QPY6UTLU.js → ZXRIJG6H.js} +1 -1
  280. package/package.json +1 -1
  281. package/build/dist/abi/IOakSubscription.json +0 -1
  282. package/build/dist/api/grandfather.d.ts +0 -56
  283. package/build/dist/api/grandfather.js +0 -1
  284. package/build/dist/chunks/43BG2JRB.js +0 -1
  285. package/build/dist/chunks/5CAAFU7R.js +0 -1
  286. package/build/dist/chunks/7EACRKFV.js +0 -1
  287. package/build/dist/chunks/BGVC5NI6.js +0 -3
  288. package/build/dist/chunks/BJK75C7G.js +0 -1
  289. package/build/dist/chunks/CM4DP2EZ.js +0 -1
  290. package/build/dist/chunks/CU4PWGMJ.js +0 -6
  291. package/build/dist/chunks/DGCJZ3HO.js +0 -1
  292. package/build/dist/chunks/ETMD747Y.js +0 -2
  293. package/build/dist/chunks/KLEJ3W4T.js +0 -1
  294. package/build/dist/chunks/KOKLM63Q.js +0 -3
  295. package/build/dist/chunks/KXX7ZBFY.js +0 -1
  296. package/build/dist/chunks/L2AE32SL.js +0 -1
  297. package/build/dist/chunks/LTDF2LNP.js +0 -1
  298. package/build/dist/chunks/NV6FDIYT.js +0 -1
  299. package/build/dist/chunks/OOPMZIG7.js +0 -1
  300. package/build/dist/chunks/UNJJRQIU.js +0 -1
  301. package/build/dist/chunks/W7QNSNOH.js +0 -1
  302. package/build/dist/chunks/ZOLHVZDK.js +0 -1
@@ -1 +1 @@
1
- import{b as ne}from"./NUERUFH7.js";import{b as ee,e as te}from"./22TU5PFT.js";import{a as D,b as W,c as _,d as J,e as z,f as Y,g as Z}from"./QPY6UTLU.js";import{d as V,e as $,w as U}from"./KLEJ3W4T.js";import{a as H}from"./IOYRL6AY.js";import{a as E}from"./66F5ZH34.js";import{c as b,g as G}from"./NWNYJ26T.js";import{b as S,j as N}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as w,encodeFunctionData as oe,encodePacked as he,erc20Abi as be,getAddress as ce,parseAbi as T,parseAbiParameters as g,zeroAddress as v}from"viem";var ie=ce("0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7"),re=ce(N[4663].ponsTrade.quoter.address),xe=T(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),we=T(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),se=T(["function factory() view returns (address)","function quoteExactInput(bytes path,uint256 amountIn) returns (uint256,uint160[],uint32[],uint256)","function quoteExactOutput(bytes path,uint256 amountOut) returns (uint256,uint160[],uint32[],uint256)"]),F="(address intermediateCurrency,uint24 fee,int24 tickSpacing,address hooks,bytes hookData)",M="(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",ae=T([`function quoteExactInput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactOutput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactInputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`,`function quoteExactOutputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`]),ke=g(`(address exactCurrency,${F}[] path,uint256[] minHopPriceX36,uint128 amount,uint128 limit)`);function ve(u,t,r,l){let s=[],e=l?r:t,i=new Set([e]);for(let n of l?[...u].reverse():u){let c=n.currency0===e?n.currency1:n.currency1===e?n.currency0:void 0;if(!c||i.has(c))throw new o("V4 poolKeys must form a continuous route without repeated currencies.");s.push({intermediateCurrency:c,fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks,hookData:"0x"}),e=c,i.add(e)}if(e!==(l?t:r))throw new o("V4 route does not end at the requested currency.");return s}var ge=g(`(${M} poolKey,bool zeroForOne,uint128 amount,uint128 limit,uint256 minHopPriceX36,bytes hookData)`),Ae=g("address recipient,uint256 amount,uint256 limit,bytes path,bool payerIsUser,uint256[] minHopPriceX36"),Pe=g("address recipient,uint256 amount,uint256 limit,address[] path,bool payerIsUser,uint256[] minHopPriceX36"),ue=g("address,uint256"),Ie=g("bytes,bytes[]");function Se(u,t,r){let l=r?[...u].reverse():u,s=r?[...t].reverse():t,e=l[0];return s.forEach((i,n)=>{e=`${e}${he(["uint24","address"],[i,l[n+1]]).slice(2)}`}),e}var de={version:{description:'Uniswap version: "v2" for pairs, "v3" for concentrated liquidity or "v4" for PoolManager.',type:"string",enum:["v2","v3","v4"]},tokenIn:{...b,description:"Input token address; the zero address means native ETH for v4."},tokenOut:{...b,description:"Output token address; the zero address means native ETH for v4."},path:{description:"Two to six distinct ERC-20 token addresses in input-to-output order for v2 or v3.",type:"array",minItems:2,maxItems:6,items:b},fees:{type:"array",description:"One v3 pool fee per path hop, in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",items:{type:"integer",minimum:0,maximum:1e6}},poolKeys:{description:"One to five v4 pool keys in input-to-output route order, without repeated currencies.",type:"array",minItems:1,maxItems:5,items:{type:"object",required:["currency0","currency1","fee","tickSpacing","hooks"],properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},additionalProperties:!1}},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},allowHighFeePools:{description:"Allow pools above Oak's usual fee threshold; review the fee warning before confirming.",type:"boolean"},acceptValueLoss:{description:"Acknowledge the quoted value-loss warning; review the measured loss before confirming.",type:"boolean"},amountIn:E('Amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),amountOut:E('Amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),minAmountOut:E('Minimum amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),maxAmountIn:E('Maximum amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999}};async function Ee(u,t,r,l=!1){Z(t,Object.keys(de));let s=t.version;if(!["v2","v3","v4"].includes(String(s)))throw new o("Provide version v2, v3 or v4.");let e=t.amountOut!==void 0;if(t.amountIn!==void 0===e)throw new o("Provide exactly one of amountIn or amountOut.");if(e&&t.minAmountOut!==void 0||!e&&t.maxAmountIn!==void 0)throw new o("Use maxAmountIn for exact output, minAmountOut for exact input.");let i=D(e?t.amountOut:t.amountIn,e?"amountOut":"amountIn",s==="v4"?128:160),n=_(t.tokenIn),c=_(t.tokenOut);if(n===c)throw new o("Swap requires different input and output currencies.");let x=u.clientFor(S),p=await x.getBlock(),L=J(t.slippageBps),j,I,m,O,A,f,d,C;if(s==="v4"){if(t.path!==void 0||t.fees!==void 0)throw new o("V4 uses poolKey or poolKeys; omit path and fees.");if(t.poolKey===void 0==(t.poolKeys===void 0))throw new o("Provide poolKey or poolKeys, not both.");if(t.poolKeys!==void 0){if(!Array.isArray(t.poolKeys)||t.poolKeys.length<1||t.poolKeys.length>5)throw new o("Provide 1 to 5 v4 poolKeys.");let a=t.poolKeys.map(P=>U(P));j=a,I=ve(a,n,c,e),m=(await x.simulateContract({address:re,abi:ae,functionName:e?"quoteExactOutput":"quoteExactInput",args:[{exactCurrency:e?c:n,path:I,exactAmount:i}],account:r,gas:H,blockNumber:p.number})).result[0]}else{if(f=U(t.poolKey),![f.currency0,f.currency1].includes(n)||![f.currency0,f.currency1].includes(c))throw new o("PoolKey currencies differ from the requested swap.");m=(await x.simulateContract({address:re,abi:ae,functionName:e?"quoteExactOutputSingle":"quoteExactInputSingle",args:[{poolKey:f,zeroForOne:n===f.currency0,exactAmount:i,hookData:"0x"}],account:r,gas:H,blockNumber:p.number})).result[0]}A="0x10"}else{if(t.poolKey!==void 0||t.poolKeys!==void 0||n===v||c===v)throw new o("V2/v3 routes use ERC-20 tokens; wrap ETH to WETH first.");if(d=Array.isArray(t.path)?t.path.map(W):[n,c],d.length<2||d.length>6||d[0]!==n||d.at(-1)!==c||new Set(d).size!==d.length||d.includes(v))throw new o("Path must contain 2 to 6 distinct ERC-20 tokens in input-to-output order.");if(s==="v2"){if(t.fees!==void 0)throw new o("V2 fees are fixed by the pair; omit fees.");let a=await x.readContract({address:ee,abi:te,functionName:e?"getAmountsIn":"getAmountsOut",args:[i,d],blockNumber:p.number});m=e?a[0]:a.at(-1),A=e?"0x09":"0x08"}else{let a=t.fees;if(!Array.isArray(a)||a.length!==d.length-1||a.some(P=>typeof P!="number"||!Number.isInteger(P)||P<0||P>1e6))throw new o("Provide one integer pool fee in hundredths of a basis point (3000 = 0.3%) per v3 path hop.");if(!G(await x.readContract({address:ie,abi:se,functionName:"factory",blockNumber:p.number}),N[4663].uniswap.v3_factory.address))throw new o("V3 quoter is not configured for the pinned factory.");C=Se(d,a,e),m=(await x.simulateContract({address:ie,abi:se,functionName:e?"quoteExactOutput":"quoteExactInput",args:[C,i],account:r,gas:H,blockNumber:p.number})).result[0],A=e?"0x01":"0x00"}}if(m<=0n)throw new o("No positive Uniswap quote is available.");let k=await ne(x,{version:s,input:n,path:d,fees:t.fees,poolKeys:f?[f]:j,exactOutput:e,amount:i,quoted:m,blockNumber:p.number,allowHighFeePools:t.allowHighFeePools===!0,acceptValueLoss:t.acceptValueLoss===!0}),{confirmationWarnings:pe,...me}=k,R=e?t.maxAmountIn:t.minAmountOut;if(!l&&R===void 0)throw new o(`Provide ${e?"maxAmountIn":"minAmountOut"} from uniswap_quote to confirm the trade bound.`);let y=R===void 0?e?(m*BigInt(1e4+L)+9999n)/10000n:m*BigInt(1e4-L)/10000n:D(R,e?"maxAmountIn":"minAmountOut",s==="v4"?128:160);if(y<=0n||(e?y<m:y>m))throw new o("The fresh quote does not satisfy the confirmed swap bound.");let h=e?y:i;if(h>=1n<<160n||s==="v4"&&(h>=1n<<128n||y>=1n<<128n))throw new o("Swap bounds exceed the router amount range.");let[le,fe]=await Promise.all([z(u,n,p.number),z(u,c,p.number)]),X={...me,version:s,input:{token:le,amount:(e?m:i).toString()},output:{token:fe,amount:(e?i:m).toString()},[e?"maxAmountIn":"minAmountOut"]:y.toString(),blockNumber:p.number.toString(),expiresAt:(p.timestamp+60n).toString()};if(l)return{quote:X,...k.warnings?{warnings:k.warnings}:{},summary:"Read-only on-chain quote. Repeat the same route with the returned bound in uniswap_swap; execution gets a fresh quote and preview."};let q=p.timestamp+300n,K=[],B="Native ETH input; no token approvals.";if(n!==v){let a=await x.readContract({address:n,abi:be,functionName:"allowance",args:[r,V],blockNumber:p.number});a!==h&&K.push(u.approval(n,V,h.toString(),S)),B=`${a===h?"Reuse existing exact ERC-20 allowance of":"Set ERC-20 allowance to exactly"} ${h} input base units to Permit2; exact router permit.`,K.push(u.unsignedTx({to:V,data:oe({abi:we,functionName:"approve",args:[n,$,h,Number(q)]}),value:"0",chainId:S,description:`Permit exactly ${h} input base units to Universal Router until ${q}.`}))}if(s==="v4"){let a=I?w(ke,[{exactCurrency:e?c:n,path:I,minHopPriceX36:[],amount:i,limit:y}]):w(ge,[{poolKey:f,zeroForOne:n===f.currency0,amount:i,limit:y,minHopPriceX36:0n,hookData:"0x"}]);O=w(Ie,[I?e?"0x090c0f":"0x070c0f":e?"0x080c0f":"0x060c0f",[a,w(ue,[n,h]),w(ue,[c,e?i:y])]])}else s==="v2"?O=w(Pe,[r,i,y,d,!0,[]]):O=w(Ae,[r,i,y,C,!0,[]]);let Q=[O];return n===v&&e&&(A=`${A}04`,Q.push(w(g("address,address,uint256"),[v,r,0n]))),K.push(u.unsignedTx({to:$,data:oe({abi:xe,functionName:"execute",args:[A,Q,q]}),value:n===v?h.toString():"0",chainId:S,description:`Uniswap ${s} ${e?"exact output":"exact input"} swap; recipient ${r}; deadline ${q}.`})),{...k.warnings?{warnings:k.warnings}:{},confirmationWarnings:pe,...await Y(u,K,r,`${(k.warnings??[]).join(" ")}${k.warnings?.length?" ":""}Swap through Universal Router 2.1.2. ${B} Fixed output/input bound and five-minute on-chain deadline. Venue fees included; gas excluded.`),quote:X}}function Ue(u){return{tools:[!0,!1].map(t=>({name:t?"uniswap_quote":"uniswap_swap",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenIn","tokenOut"],properties:de},execute:(r,l)=>Ee(u,r,l,t)}))}}export{ie as a,re as b,xe as c,we as d,se as e,ae as f,ke as g,ve as h,ge as i,Ae as j,Pe as k,Se as l,Ee as m,Ue as n};
1
+ import{b as ne}from"./FRVCSDKU.js";import{b as ee,e as te}from"./E47UYYK4.js";import{a as D,b as W,c as _,d as J,e as z,f as Y,g as Z}from"./ZXRIJG6H.js";import{d as V,e as $,w as U}from"./FRT6AC6M.js";import{a as H}from"./IOYRL6AY.js";import{a as E}from"./66F5ZH34.js";import{c as b,g as G}from"./NWNYJ26T.js";import{b as S,j as N}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as w,encodeFunctionData as oe,encodePacked as he,erc20Abi as be,getAddress as ce,parseAbi as T,parseAbiParameters as g,zeroAddress as v}from"viem";var ie=ce("0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7"),re=ce(N[4663].ponsTrade.quoter.address),xe=T(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),we=T(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),se=T(["function factory() view returns (address)","function quoteExactInput(bytes path,uint256 amountIn) returns (uint256,uint160[],uint32[],uint256)","function quoteExactOutput(bytes path,uint256 amountOut) returns (uint256,uint160[],uint32[],uint256)"]),F="(address intermediateCurrency,uint24 fee,int24 tickSpacing,address hooks,bytes hookData)",M="(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",ae=T([`function quoteExactInput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactOutput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactInputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`,`function quoteExactOutputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`]),ke=g(`(address exactCurrency,${F}[] path,uint256[] minHopPriceX36,uint128 amount,uint128 limit)`);function ve(u,t,r,l){let s=[],e=l?r:t,i=new Set([e]);for(let n of l?[...u].reverse():u){let c=n.currency0===e?n.currency1:n.currency1===e?n.currency0:void 0;if(!c||i.has(c))throw new o("V4 poolKeys must form a continuous route without repeated currencies.");s.push({intermediateCurrency:c,fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks,hookData:"0x"}),e=c,i.add(e)}if(e!==(l?t:r))throw new o("V4 route does not end at the requested currency.");return s}var ge=g(`(${M} poolKey,bool zeroForOne,uint128 amount,uint128 limit,uint256 minHopPriceX36,bytes hookData)`),Ae=g("address recipient,uint256 amount,uint256 limit,bytes path,bool payerIsUser,uint256[] minHopPriceX36"),Pe=g("address recipient,uint256 amount,uint256 limit,address[] path,bool payerIsUser,uint256[] minHopPriceX36"),ue=g("address,uint256"),Ie=g("bytes,bytes[]");function Se(u,t,r){let l=r?[...u].reverse():u,s=r?[...t].reverse():t,e=l[0];return s.forEach((i,n)=>{e=`${e}${he(["uint24","address"],[i,l[n+1]]).slice(2)}`}),e}var de={version:{description:'Uniswap version: "v2" for pairs, "v3" for concentrated liquidity or "v4" for PoolManager.',type:"string",enum:["v2","v3","v4"]},tokenIn:{...b,description:"Input token address; the zero address means native ETH for v4."},tokenOut:{...b,description:"Output token address; the zero address means native ETH for v4."},path:{description:"Two to six distinct ERC-20 token addresses in input-to-output order for v2 or v3.",type:"array",minItems:2,maxItems:6,items:b},fees:{type:"array",description:"One v3 pool fee per path hop, in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",items:{type:"integer",minimum:0,maximum:1e6}},poolKeys:{description:"One to five v4 pool keys in input-to-output route order, without repeated currencies.",type:"array",minItems:1,maxItems:5,items:{type:"object",required:["currency0","currency1","fee","tickSpacing","hooks"],properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},additionalProperties:!1}},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},allowHighFeePools:{description:"Allow pools above Oak's usual fee threshold; review the fee warning before confirming.",type:"boolean"},acceptValueLoss:{description:"Acknowledge the quoted value-loss warning; review the measured loss before confirming.",type:"boolean"},amountIn:E('Amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),amountOut:E('Amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),minAmountOut:E('Minimum amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),maxAmountIn:E('Maximum amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999}};async function Ee(u,t,r,l=!1){Z(t,Object.keys(de));let s=t.version;if(!["v2","v3","v4"].includes(String(s)))throw new o("Provide version v2, v3 or v4.");let e=t.amountOut!==void 0;if(t.amountIn!==void 0===e)throw new o("Provide exactly one of amountIn or amountOut.");if(e&&t.minAmountOut!==void 0||!e&&t.maxAmountIn!==void 0)throw new o("Use maxAmountIn for exact output, minAmountOut for exact input.");let i=D(e?t.amountOut:t.amountIn,e?"amountOut":"amountIn",s==="v4"?128:160),n=_(t.tokenIn),c=_(t.tokenOut);if(n===c)throw new o("Swap requires different input and output currencies.");let x=u.clientFor(S),p=await x.getBlock(),L=J(t.slippageBps),j,I,m,O,A,f,d,C;if(s==="v4"){if(t.path!==void 0||t.fees!==void 0)throw new o("V4 uses poolKey or poolKeys; omit path and fees.");if(t.poolKey===void 0==(t.poolKeys===void 0))throw new o("Provide poolKey or poolKeys, not both.");if(t.poolKeys!==void 0){if(!Array.isArray(t.poolKeys)||t.poolKeys.length<1||t.poolKeys.length>5)throw new o("Provide 1 to 5 v4 poolKeys.");let a=t.poolKeys.map(P=>U(P));j=a,I=ve(a,n,c,e),m=(await x.simulateContract({address:re,abi:ae,functionName:e?"quoteExactOutput":"quoteExactInput",args:[{exactCurrency:e?c:n,path:I,exactAmount:i}],account:r,gas:H,blockNumber:p.number})).result[0]}else{if(f=U(t.poolKey),![f.currency0,f.currency1].includes(n)||![f.currency0,f.currency1].includes(c))throw new o("PoolKey currencies differ from the requested swap.");m=(await x.simulateContract({address:re,abi:ae,functionName:e?"quoteExactOutputSingle":"quoteExactInputSingle",args:[{poolKey:f,zeroForOne:n===f.currency0,exactAmount:i,hookData:"0x"}],account:r,gas:H,blockNumber:p.number})).result[0]}A="0x10"}else{if(t.poolKey!==void 0||t.poolKeys!==void 0||n===v||c===v)throw new o("V2/v3 routes use ERC-20 tokens; wrap ETH to WETH first.");if(d=Array.isArray(t.path)?t.path.map(W):[n,c],d.length<2||d.length>6||d[0]!==n||d.at(-1)!==c||new Set(d).size!==d.length||d.includes(v))throw new o("Path must contain 2 to 6 distinct ERC-20 tokens in input-to-output order.");if(s==="v2"){if(t.fees!==void 0)throw new o("V2 fees are fixed by the pair; omit fees.");let a=await x.readContract({address:ee,abi:te,functionName:e?"getAmountsIn":"getAmountsOut",args:[i,d],blockNumber:p.number});m=e?a[0]:a.at(-1),A=e?"0x09":"0x08"}else{let a=t.fees;if(!Array.isArray(a)||a.length!==d.length-1||a.some(P=>typeof P!="number"||!Number.isInteger(P)||P<0||P>1e6))throw new o("Provide one integer pool fee in hundredths of a basis point (3000 = 0.3%) per v3 path hop.");if(!G(await x.readContract({address:ie,abi:se,functionName:"factory",blockNumber:p.number}),N[4663].uniswap.v3_factory.address))throw new o("V3 quoter is not configured for the pinned factory.");C=Se(d,a,e),m=(await x.simulateContract({address:ie,abi:se,functionName:e?"quoteExactOutput":"quoteExactInput",args:[C,i],account:r,gas:H,blockNumber:p.number})).result[0],A=e?"0x01":"0x00"}}if(m<=0n)throw new o("No positive Uniswap quote is available.");let k=await ne(x,{version:s,input:n,path:d,fees:t.fees,poolKeys:f?[f]:j,exactOutput:e,amount:i,quoted:m,blockNumber:p.number,allowHighFeePools:t.allowHighFeePools===!0,acceptValueLoss:t.acceptValueLoss===!0}),{confirmationWarnings:pe,...me}=k,R=e?t.maxAmountIn:t.minAmountOut;if(!l&&R===void 0)throw new o(`Provide ${e?"maxAmountIn":"minAmountOut"} from uniswap_quote to confirm the trade bound.`);let y=R===void 0?e?(m*BigInt(1e4+L)+9999n)/10000n:m*BigInt(1e4-L)/10000n:D(R,e?"maxAmountIn":"minAmountOut",s==="v4"?128:160);if(y<=0n||(e?y<m:y>m))throw new o("The fresh quote does not satisfy the confirmed swap bound.");let h=e?y:i;if(h>=1n<<160n||s==="v4"&&(h>=1n<<128n||y>=1n<<128n))throw new o("Swap bounds exceed the router amount range.");let[le,fe]=await Promise.all([z(u,n,p.number),z(u,c,p.number)]),X={...me,version:s,input:{token:le,amount:(e?m:i).toString()},output:{token:fe,amount:(e?i:m).toString()},[e?"maxAmountIn":"minAmountOut"]:y.toString(),blockNumber:p.number.toString(),expiresAt:(p.timestamp+60n).toString()};if(l)return{quote:X,...k.warnings?{warnings:k.warnings}:{},summary:"Read-only on-chain quote. Repeat the same route with the returned bound in uniswap_swap; execution gets a fresh quote and preview."};let q=p.timestamp+300n,K=[],B="Native ETH input; no token approvals.";if(n!==v){let a=await x.readContract({address:n,abi:be,functionName:"allowance",args:[r,V],blockNumber:p.number});a!==h&&K.push(u.approval(n,V,h.toString(),S)),B=`${a===h?"Reuse existing exact ERC-20 allowance of":"Set ERC-20 allowance to exactly"} ${h} input base units to Permit2; exact router permit.`,K.push(u.unsignedTx({to:V,data:oe({abi:we,functionName:"approve",args:[n,$,h,Number(q)]}),value:"0",chainId:S,description:`Permit exactly ${h} input base units to Universal Router until ${q}.`}))}if(s==="v4"){let a=I?w(ke,[{exactCurrency:e?c:n,path:I,minHopPriceX36:[],amount:i,limit:y}]):w(ge,[{poolKey:f,zeroForOne:n===f.currency0,amount:i,limit:y,minHopPriceX36:0n,hookData:"0x"}]);O=w(Ie,[I?e?"0x090c0f":"0x070c0f":e?"0x080c0f":"0x060c0f",[a,w(ue,[n,h]),w(ue,[c,e?i:y])]])}else s==="v2"?O=w(Pe,[r,i,y,d,!0,[]]):O=w(Ae,[r,i,y,C,!0,[]]);let Q=[O];return n===v&&e&&(A=`${A}04`,Q.push(w(g("address,address,uint256"),[v,r,0n]))),K.push(u.unsignedTx({to:$,data:oe({abi:xe,functionName:"execute",args:[A,Q,q]}),value:n===v?h.toString():"0",chainId:S,description:`Uniswap ${s} ${e?"exact output":"exact input"} swap; recipient ${r}; deadline ${q}.`})),{...k.warnings?{warnings:k.warnings}:{},confirmationWarnings:pe,...await Y(u,K,r,`${(k.warnings??[]).join(" ")}${k.warnings?.length?" ":""}Swap through Universal Router 2.1.2. ${B} Fixed output/input bound and five-minute on-chain deadline. Venue fees included; gas excluded.`),quote:X}}function Ue(u){return{tools:[!0,!1].map(t=>({name:t?"uniswap_quote":"uniswap_swap",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenIn","tokenOut"],properties:de},execute:(r,l)=>Ee(u,r,l,t)}))}}export{ie as a,re as b,xe as c,we as d,se as e,ae as f,ke as g,ve as h,ge as i,Ae as j,Pe as k,Se as l,Ee as m,Ue as n};
@@ -0,0 +1 @@
1
+ import{m as J}from"./WSILNJS2.js";import{a as U,e as Z,h as ee,i as te,k as ne}from"./KHOUBQJK.js";import{c as N,e as Q}from"./JFC2QCMW.js";import{a as Y}from"./Y2QADJOB.js";import{b as re,e as O,q as ie}from"./N624NR7Y.js";import{a as g,b as C}from"./Z7FGEWO2.js";import{a as P}from"./LIUXNOLP.js";import{e as z,f as j}from"./S65KXMZ7.js";import{f as $,l as V}from"./CW37EGPL.js";import{a as X,c as A}from"./CFPJDLTZ.js";import{a as v}from"./VVAM3EAK.js";import{a as K}from"./SPJCSEKP.js";import{b as F}from"./SCG5HWMN.js";import{b as E}from"./IX3GZMTM.js";import{t as T}from"./MQ5F2VOK.js";import{b as m,c as l,d as G,e as k,j as h,k as q,l as W,q as B}from"./TI727O2H.js";import{a as c}from"./XSD5NL7J.js";import{a as D,b as R}from"./JXOEJPJ4.js";import{getAddress as p,isAddress as se,parseAbi as me,zeroAddress as oe}from"viem";var ae=[{inputs:[],name:"available",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"ethUsdE18",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"liquidityUsdgE6",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"phase",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"priceSigner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"signer",type:"address"}],name:"setPriceSigner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"spotOakPerEthE18",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"supplyNet",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"syncPhase",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"wallet",type:"address"},{internalType:"uint256",name:"oakPerEthE18",type:"uint256"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"bytes32",name:"nonce",type:"bytes32"}],internalType:"struct PriceNote",name:"n",type:"tuple"},{internalType:"bytes",name:"sig",type:"bytes"},{internalType:"address",name:"boundWallet",type:"address"}],name:"verifyNote",outputs:[{internalType:"uint256",name:"oakPerEthE18",type:"uint256"}],stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"signer",type:"address"}],name:"PriceSignerSet",type:"event"},{inputs:[],name:"NotReady",type:"error"},{inputs:[],name:"NoteBadSignature",type:"error"},{inputs:[],name:"NoteExpired",type:"error"},{inputs:[],name:"NoteNotYetValid",type:"error"},{inputs:[{internalType:"uint256",name:"spot",type:"uint256"},{internalType:"uint256",name:"note",type:"uint256"}],name:"NoteOutsideGuard",type:"error"},{inputs:[],name:"NoteWrongWallet",type:"error"},{inputs:[{internalType:"address",name:"source",type:"address"}],name:"OracleUnreadable",type:"error"}];function Qe(n){return"source"in n&&n.source==="pool-spot-estimate"?void 0:n}var M=300,Te="1000000000000000000",le=p(h[m].tokens.USDG.address),fe=p(h[l].deployments.test_USDG.address),_=p(h[m].tokens.WETH.address),L=p(h[l].deployments.test_WETH.address),I=p(X.chop);function pe(n){return n.chainId===m&&n.address.toLowerCase()===I.toLowerCase()}async function Ye(n,e,t,o){let s=o?.find(b=>b.measuredAtBlock===t.toString()&&[b.log.address,b.staking.address].some(y=>y.toLowerCase()===n.address.toLowerCase())),i=n.address;try{s||(i=p(await $(e,n.address,"INDEX_FUND",[],t)))}catch{}let a=s??await V(e,i,"read",t);if(a.drift.length)throw new c("Chop code changed; share backing cannot be estimated.");let r=10n**BigInt(n.decimals),d=n.address.toLowerCase()===a.log.address.toLowerCase(),u=n.address.toLowerCase()===a.staking.address.toLowerCase();if(!d&&!u||n.chainId!==m||n.decimals!==(d?a.log.decimals:a.staking.decimals))throw new c("Chop share identity does not match the verified log.");let f=d?[(await z(e,a,oe,r,t)).net]:(await j(e,a,oe,r,t)).assets;if(!f.length)throw new c("Chop LP reserves or net log backing could not be verified.");return{assets:f,isLog:d}}function be(n){let e=n.address.toLowerCase();return n.chainId===m?e===le.toLowerCase():n.chainId===l?e===fe.toLowerCase():!1}function ye(n){return n.chainId!==m&&n.chainId!==l?!1:C(n.address)===g}function we(n){let e=n.address.toLowerCase();return n.chainId===m?e===_.toLowerCase():n.chainId===l?e===L.toLowerCase():!1}function Se(n){return ye(n)||we(n)}var ge=-887272,he=887272,Pe=(1n<<256n)-1n,Ce=me(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives, uint160[] secondsPerLiquidityCumulativeX128s)","function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)"]),de=me(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),xe=1n<<192n;async function De(n,e){let t=p(A.stateView),o=A.poolId,[s,i]=await Promise.all([n.readContract({address:t,abi:de,functionName:"getSlot0",args:[o],blockNumber:e}),n.readContract({address:t,abi:de,functionName:"getLiquidity",args:[o],blockNumber:e})]),a=s[0],r=Number(s[1]);if(a<=0n||i<=0n||!Number.isInteger(r)||r<ge||r>he)throw new c("The pinned Uniswap v4 WETH/CHOP pool has no active liquidity, and the only other route is a near-empty pool.");return{numerator:xe,denominator:a*a}}function H(n,e){if(typeof n=="bigint")return n;if(typeof n=="number"){if(!Number.isSafeInteger(n))throw new c(`Invalid ${e} timestamp.`);return BigInt(n)}if(typeof n=="string"&&/^-?\d+$/.test(n.trim()))return BigInt(n.trim());throw new c(`Invalid ${e} timestamp.`)}function Je(n,e=BigInt(Math.floor(Date.now()/1e3)),t=M){try{return w(n,e,t),!0}catch{return!1}}function w(n,e=BigInt(Math.floor(Date.now()/1e3)),t=M){if(!Number.isInteger(t)||t<0)throw new c("Maximum price age must be a non-negative integer.");let o=H(n,"price"),s=H(e,"current");if(o<=0n)throw new c("Price timestamp must be positive.");if(o>s)throw new c("Price timestamp is in the future.");let i=s-o;if(i>BigInt(t))throw new c(`Price is stale: age ${i}s exceeds ${t}s.`);return o.toString()}function ke(n){if(!Number.isInteger(n)||n<ge||n>he)throw new c(`Tick ${n} is outside valid Uniswap bounds.`);let e=BigInt(n<0?-n:n),t=(e&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&0x2n)!==0n&&(t=t*0xfff97272373d413259a46990580e213an>>128n),(e&0x4n)!==0n&&(t=t*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&0x8n)!==0n&&(t=t*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&0x10n)!==0n&&(t=t*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&0x20n)!==0n&&(t=t*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&0x40n)!==0n&&(t=t*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&0x80n)!==0n&&(t=t*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&0x100n)!==0n&&(t=t*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&0x200n)!==0n&&(t=t*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&0x400n)!==0n&&(t=t*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&0x800n)!==0n&&(t=t*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&0x1000n)!==0n&&(t=t*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&0x2000n)!==0n&&(t=t*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&0x4000n)!==0n&&(t=t*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&0x8000n)!==0n&&(t=t*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&0x10000n)!==0n&&(t=t*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&0x20000n)!==0n&&(t=t*0x5d6af8dedb81196699c329225ee604n>>128n),(e&0x40000n)!==0n&&(t=t*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&0x80000n)!==0n&&(t=t*0x48a170391f7dc42444e8fa2n>>128n),n>0&&(t=Pe/t),(t>>32n)+(t%(1n<<32n)===0n?0n:1n)}async function ce(n,e,t,o){let s=async()=>{throw new c("Price identity resolution is read-only.")},i=K({network:e===l?"testnet":"mainnet",clientFor:r=>t.client??T(t.rpcUrl,r),http:t.http??F(),preview:s,quoteSwap:s,buildSwap:s}),a=await ie(n,{context:i,oakTokenAddress:t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS,officialStockTokens:t.officialStockTokens,tokenMetadata:o,blockNumber:t.blockNumber,readMetadata:async r=>{let d=t.client??T(t.rpcUrl,e),[u,f]=await Promise.all([v(d,e,r,"symbol",t.blockNumber),v(d,e,r,"decimals",t.blockNumber)]);return{address:r,symbol:u,decimals:f,chainId:e}}});return{address:a.address,symbol:a.kind==="erc20"&&o?o.symbol:a.symbol,decimals:a.decimals,chainId:a.chainId}}async function ve(n,e,t){if(typeof n=="object"&&n!==null){let r=n.chainId??e,d=C(n.address)===g?g:p(n.address),u={address:d,symbol:n.symbol,decimals:n.decimals,chainId:r};return be(u)?{address:d,symbol:"USDG",decimals:k,chainId:r}:ye(u)?{address:g,symbol:"ETH",decimals:18,chainId:r}:we(u)?{address:d,symbol:"WETH",decimals:18,chainId:r}:pe(u)?{address:d,symbol:"CHOP",decimals:18,chainId:r}:ce(u.address,r,t,u)}let o=n.trim(),s=o.toUpperCase(),i=o.toLowerCase();if(s==="ETH"||se(o,{strict:!1})&&C(o)===g)return{...re,chainId:e};if(s==="WETH"||e===m&&i===_.toLowerCase()||e===l&&i===L.toLowerCase()){if(e!==m&&e!==l)throw new c(`No canonical WETH address configured for chain ${e}.`);return{address:e===l?L:_,symbol:"WETH",decimals:18,chainId:e}}if(s==="USDG"||e===m&&i===q.toLowerCase()||e===l&&i===W.toLowerCase()){if(e!==m&&e!==l)throw new c(`No canonical USDG address configured for chain ${e}.`);return{address:e===l?fe:le,symbol:"USDG",decimals:k,chainId:e}}if(e===m&&(s==="USDE"||i===O.address.toLowerCase()))return{...O,chainId:e};if(e===m&&(s==="CHOP"||i===I.toLowerCase()))return{address:I,symbol:"CHOP",decimals:18,chainId:e};let a=t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS;if(s==="OAK"||a&&o.toLowerCase()===a.toLowerCase()){if(!a&&!se(o,{strict:!1}))throw new c("OAK token address is required to price OAK.");return{address:p(a??o),symbol:"OAK",decimals:G,chainId:e}}return ce(n,e,t)}async function x(n,e,t){if(e)return(await n.readContract({address:e,abi:ae,functionName:"ethUsdE18",blockNumber:t})).toString();let s=(await n.readContract({address:p(B),abi:Ce,functionName:"observe",args:[[U,0]],blockNumber:t}))[0];if(!s||s.length<2)throw new c("ETH/USDG pool observation returned insufficient tick cumulatives.");let i=ee(s[0],s[1],U),a=ke(i);return te(a)}async function S(n,e,t,o){if(n.timestamp!==void 0)return w(n.timestamp,t(),o);if(e&&typeof e.getBlock=="function"){let i=await P(e,n.blockNumber);return w(i.timestamp,t(),o)}let s=t();return w(s,s,o)}function ue(n){if(n.startsWith("untrusted "))try{let e=JSON.parse(n.slice(10));if(typeof e=="string"&&D(e)===n)return n}catch{}return D(n)}async function Ze(n,e={}){let t=e.chainId??m,o=e.maxAgeSeconds??M,s=()=>e.now!==void 0?H(e.now,"current"):BigInt(Math.floor(Date.now()/1e3)),i=await ve(n,t,e);if((R(i.symbol)||i.symbol.length>256)&&(i.symbol=ue(i.symbol)),e.trades){let r=await S(e,e.client,s,o),d=ne(e.trades,{now:s(),windowStart:e.windowStart,windowEnd:e.windowEnd});if(e.spotOakPerEthE18!==void 0&&!J(d,e.spotOakPerEthE18))throw new c("30-minute average is outside the 50% spot guard band.");let u=e.ethUsdE18!==void 0?e.ethUsdE18.toString():await x(e.client??T(e.rpcUrl,t),e.oracleAddress);return{token:i,usdE18:Z(u,d),timestamp:r}}if(e.usdE18!==void 0){let r=await S(e,e.client,s,o),d=E(e.usdE18.toString());if(d<=0n)throw new c("USD price must be positive.");return{token:i,usdE18:d.toString(),timestamp:r}}if(e.resolver){let r=await e.resolver(i),d=w(r.timestamp,s(),o),u=E(r.usdE18);if(u<=0n)throw new c("USD price must be positive.");return{token:i,usdE18:u.toString(),timestamp:d,...r.source==="pool-spot-estimate"?{source:r.source,sourceLabel:N}:{}}}let a=e.client??T(e.rpcUrl,t);if(be(i)){let r=await S(e,a,s,o);return{token:i,usdE18:Te,timestamp:r}}if(Se(i)){let r=await S(e,a,s,o),d=await x(a,e.oracleAddress,e.blockNumber);return{token:i,usdE18:d,timestamp:r}}if(pe(i)){let r=e.timestamp===void 0&&a&&typeof a.getBlock=="function"?await P(a,e.blockNumber):void 0,d=r?w(r.timestamp,s(),o):await S(e,a,s,o);if(r&&r.number===null)throw new c("CHOP reference requires a mined block.");let u=r?.number??e.blockNumber,[f,b]=await Promise.all([De(a,u),e.ethUsdE18!==void 0?Promise.resolve(e.ethUsdE18.toString()):x(a,e.oracleAddress,u)]),y=E(b)*f.numerator/f.denominator;if(y<=0n)throw new c("CHOP USD reference price must be positive.");return{token:i,usdE18:y.toString(),timestamp:d}}if(i.chainId===m)try{let r=await P(a,e.blockNumber),d=w(r.timestamp,s(),o);if(r.number===null)throw new c("Pons reference requires a mined block.");let u=await Q(i,a,r.number);if(u!==void 0&&u>0n)return{token:i,usdE18:u.toString(),timestamp:d,source:"pool-spot-estimate",sourceLabel:N};let[f,b]=await Promise.all([Y(i,a,r.number),x(a,e.oracleAddress,r.number)]),y=E(b)*f.numerator/f.denominator;if(y<=0n)throw new c("Pons USD reference price must be positive.");return{token:i,usdE18:y.toString(),timestamp:d}}catch{}throw new c(`Oak has no fresh on-chain trade price for ${ue(i.symbol)}, so it shows no price. balances and positions show a labeled estimate where one exists; an estimate is not a quote.`)}export{Qe as a,M as b,Te as c,pe as d,Ye as e,be as f,ye as g,we as h,Se as i,De as j,Je as k,w as l,ke as m,x as n,Ze as o};
@@ -1 +1 @@
1
- import{b as X}from"./ADIPEGNN.js";import{b as Z}from"./OB7BFDOV.js";import{i as ee}from"./ANIF3JMV.js";import{a as Y}from"./E76Z2TT4.js";import{b as z}from"./GBIBRYOV.js";import{c as Q}from"./SUNTJ6IU.js";import{a as D,b as k,c as R,d as N,g as V,h as I,k as _,l as x,n as B,p as W,r as $,s as U,t as q,v as E,x as J,y as G}from"./3A2IKFTV.js";import{a as y}from"./X5V2Z2NM.js";import{b as K}from"./SPJCSEKP.js";import{a as O}from"./43LI5NKJ.js";import{c as L,e as T,g as w}from"./NWNYJ26T.js";import{a as g,d as j}from"./XSD5NL7J.js";import{a as A}from"./JXOEJPJ4.js";import{Buffer as te}from"node:buffer";import{decodeEventLog as re,encodeFunctionData as H,getAddress as se,hexToString as de,parseAbiItem as ce,toEventSelector as ie}from"viem";var Ke={register:"erc8004_register"},ge="Oak now always adds the public oak.registrar marker when it registers an agent, so tag: false and --no-tag are no longer available. Remove the option and register again. To use an agent ID you already own without the marker, link it with oak setup link <agentId>.",fe="The registration went through, but Oak could not find its oak.registrar marker on Robinhood Chain. Nothing else was sent. Ask me to check the agent with erc8004_identity.",le="One transaction registers your agent and writes the public marker oak.registrar = oak. Anyone can see on Robinhood Chain that this agent was registered through Oak. The marker is self-reported, not proof of anything, and the transaction stays in the public history even if the marker is changed later. It needs gas.",F="https://eips.ethereum.org/EIPS/eip-8004#registration-v1",ue={type:"object",required:["type","name","description","image","services","x402Support","active","registrations"],properties:{type:{const:F,description:"ERC-8004 registration-v1 profile type URI."},name:{type:"string",minLength:1,description:"Short public name for the agent."},description:{type:"string",description:"Public text describing what the agent does; may be empty."},image:{type:"string",description:"Public HTTPS or IPFS image URI without credentials."},services:{type:"array",items:{type:"object",required:["name","endpoint"]},description:"Service endpoint objects with name and endpoint; use an empty list for none."},x402Support:{type:"boolean",description:"Whether the agent supports x402 payments."},active:{type:"boolean",description:"Whether this agent is active."},registrations:{type:"array",description:"Registry references with agentRegistry and agentId; leave empty before first registration."},tags:{type:"array",items:{type:"string"},description:"Optional public text labels for the agent."},supportedTrust:{type:"array",items:{type:"string"},description:"Optional trust mechanism labels supported by the agent."}}};function pe(e){if(typeof e!="string"||!e.trim())return!1;try{let t=new URL(e);return["https:","ipfs:"].includes(t.protocol)&&!!t.hostname&&!t.username&&!t.password}catch{return!1}}var me=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&t.trim()),he=e=>e.replace(/\.$/,"");function ye(e,t,a,n){let{registryId:d}=I(e);if(!T(t))throw new g("Provide a registration-v1 profile object.");if(a!==void 0&&typeof a!="boolean")throw new g("The tag option must be a boolean.");let o=[],r=(i,c)=>o.push(`${i}: ${c}`);t.type!==F&&r("type",`use "${F}"`),(typeof t.name!="string"||!t.name.trim())&&r("name",'a short name for your agent, such as "Oak Agent 1"'),typeof t.description!="string"&&r("description","a sentence about what your agent does (it may be empty text)"),pe(t.image)||r("image","an HTTPS or IPFS link to a picture, with no username or password in it"),typeof t.active!="boolean"&&r("active","true or false"),typeof t.x402Support!="boolean"&&r("x402Support","true or false"),Array.isArray(t.services)?t.services.forEach((i,c)=>{try{Z(i)}catch(p){if(!(p instanceof g))throw p;r(`services item ${c+1}`,he(p.message))}}):r("services","a list of endpoints, or [] for none");for(let i of["tags","supportedTrust"])t[i]!==void 0&&!me(t[i])&&r(i,"a list of nonempty text labels, or leave it out");if(Array.isArray(t.registrations)?t.registrations.forEach((i,c)=>{let p=`registrations item ${c+1}`;if(!T(i)||typeof i.agentRegistry!="string"||!/^eip155:[1-9][0-9]*:0x[0-9a-fA-F]{40}$/.test(i.agentRegistry))return r(p,"an agentRegistry such as eip155:4663:0x\u2026 and its agentId");let f=typeof i.agentId=="number"&&Number.isSafeInteger(i.agentId)?String(i.agentId):i.agentId,b;try{b=x(f)}catch{return r(p,'an agentId as a whole number, such as "1"')}w(i.agentRegistry,d)&&(n===void 0?r(p,"remove the entry for this registry; its ID comes from the mined Registered receipt, and erc8004_update adds it afterwards"):b!==n&&r(p,`the agentId does not match the agent being updated; use "${n}" or remove the entry`))}):r("registrations","a list, or [] before the first registration"),o.length)throw new g(`This profile needs: ${o.join("; ")}. Fix all of these and try again.`);let u=t.registrations.map(i=>({...i}));n!==void 0&&!u.some(i=>w(i.agentRegistry,d))&&u.push({agentId:n.toString(),agentRegistry:d});let s=[...new Set((t.tags??[]).filter(i=>i!==k))];a!==!1&&s.push(k);let m={...t,registrations:u,...s.length?{tags:s}:{}};s.length||delete m.tags;let l;try{if(l=JSON.stringify(m),te.byteLength(l)>65536)throw new Error;JSON.parse(l)}catch{throw new g("Profile must be JSON data no larger than 64 KiB.")}return`data:application/json;base64,${te.from(l,"utf8").toString("base64")}`}async function M(e,t){try{let{chainId:a,registry:n}=I(e),d=x(t),o=e.clientFor(a),r=await o.readContract({address:n,abi:y,functionName:"ownerOf",args:[d]}).catch(l=>{throw j(l)?new g(`Agent ${d} does not exist in this ERC-8004 registry: the owner lookup reverted. Check the agent ID.`):l});O(r);let[u,s,m]=await Promise.all([o.readContract({address:n,abi:y,functionName:"tokenURI",args:[d]}),o.readContract({address:n,abi:y,functionName:"getAgentWallet",args:[d]}),o.readContract({address:n,abi:y,functionName:"getMetadata",args:[d,k]})]);if(O(s),typeof u!="string"||typeof m!="string"||!/^0x([0-9a-fA-F]{2})*$/.test(m))throw new g("The registry returned invalid identity data.");return{agentId:d.toString(),chainId:a,registry:n,owner:r,uri:u,agentWallet:s,registrarMetadata:m,registryValidated:!1,summary:D}}catch(a){throw new g(e.plainError(a))}}async function De(e,t){let a=await M(e,t);return{...a,uri:A(a.uri)}}async function we(e,t,a,n,d,o){let{registry:r}=I(e),u=await E(e,t,a,d),s=o===void 0?"Registered":"URIUpdated",m=ie(o===void 0?"Registered(uint256,string,address)":"URIUpdated(uint256,string,address)"),l=u.logs.filter(v=>w(v.address,r)&&v.topics[0]===m&&!v.removed);if(l.length!==1)throw new g(`The receipt must contain one matching ${s} event.`);let i=l[0],c=re({abi:y,eventName:s,topics:i.topics,data:i.data,strict:!0}),p=c.args.agentId,f=c.eventName==="Registered"?c.args.agentURI:c.args.newURI,b=c.eventName==="Registered"?c.args.owner:c.args.updatedBy;if(o!==void 0&&p!==o||f!==n||!w(b,a))throw new g("The registry event does not match the expected agent, URI and wallet.");let h=await M(e,p.toString());if(h.uri!==n||o===void 0&&!w(h.owner,a))throw new g("The current agent owner or URI does not match the confirmed operation.");return h}function be(e,t){let{chainId:a,registry:n}=I(e);return e.unsignedTx({to:n,chainId:a,value:"0",data:H({abi:y,functionName:"setMetadata",args:[t,k,R]}),description:`Set mutable oak.registrar metadata to oak for agent ${t}.`})}async function ae(e,t,a,n){let{registry:d}=I(e),o=x(n.agentId),r=await E(e,t,a,H({abi:y,functionName:"setMetadata",args:[o,k,R]})),u=ie("MetadataSet(uint256,string,string,bytes)"),s=r.logs.filter(c=>w(c.address,d)&&c.topics[0]===u&&!c.removed);if(s.length!==1)throw new g("The receipt must contain one matching MetadataSet event.");let m=s[0],{args:l}=re({abi:y,eventName:"MetadataSet",topics:m.topics,data:m.data,strict:!0});if(l.agentId!==o||l.metadataKey!==k||l.metadataValue!==R)throw new g("The metadata event does not match this agent and registrar marker.");let i=await M(e,n.agentId);if(i.registrarMetadata!==R||i.uri!==n.uri||!w(i.owner,n.owner))throw new g("The current agent metadata, owner or URI does not match the confirmed operation.");return i}async function ke(e,t){let{chainId:a,registry:n}=I(e),d=e.clientFor(a),o=await d.readContract({address:n,abi:y,functionName:"balanceOf",args:[t]});if(o===0n)return;if(typeof o!="bigint"||o<0n)throw new g("Registry balance is unavailable; registration was not built.");let r=await d.getBlockNumber({cacheTime:0}),u=new Set;for(;;){let s=r>9999999n?r-9999999n:0n,m=await d.getLogs({address:n,event:ce("event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"),args:{to:t},fromBlock:s,toBlock:r,strict:!0});for(let l of m){let i=l.args.tokenId.toString();if(l.removed||u.has(i))continue;u.add(i);let c=await M(e,i);if(w(c.owner,t))return c}if(s===0n)throw new g("Owned identity could not be located; registration was not built. Run oak setup link <agentId>.");r=s-1n}}function Ie(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>15)throw new g("Provide at most 15 user metadata entries as { key, value } with value as 0x hex or text.");let t=new Set;return e.map(a=>{if(!T(a))throw new g("Provide each metadata entry as { key, value } or { key, text }.");let n=J(a.key);if(n===k)throw new g("The key oak.registrar is reserved for the registration marker. Remove that metadata entry.");if(t.has(n))throw new g(`Metadata key ${A(n)} is repeated.`);return t.add(n),{metadataKey:n,metadataValue:G(a)}})}function oe(e,t,a){let n=$(t);if(!n)return;let{registryId:d}=I(e);return Array.isArray(n.registrations)&&n.registrations.some(o=>T(o)&&typeof o.agentRegistry=="string"&&w(o.agentRegistry,d)&&String(o.agentId)===a.toString())}function ve(e,t,a){let n=oe(e,t.uri,BigInt(t.agentId));return n===!0?{...t,profileComplete:!0}:{...t,profileComplete:n===void 0?null:!1,nextStep:{tool:"erc8004_update",arguments:{agentId:t.agentId,profile:a??"a registration-v1 profile object"},why:"The minted profile does not list its own registry and agent ID yet (registrations is empty). erc8004_update appends it automatically. It is a normal action: it needs a verified identity link and an active subscription, so link with oak_setup first."}}}async function ne(e,t,a,n){let{chainId:d,registry:o}=I(e);O(n),B(e,a.chainId);let r=t?x(a.agentId):void 0;if(!t&&(a.tag===!1||a.noTag!==void 0||a["--no-tag"]!==void 0))throw new g(ge);if(a.tag!==void 0&&typeof a.tag!="boolean")throw new g("The tag option must be a boolean.");let s=!t&&a.profile===void 0?"":ye(e,a.profile,a.tag,r),m=t?[]:Ie(a.metadata),l=a.tag!==!1;if(t&&a.metadataTransactionHash!==void 0&&(!l||a.transactionHash===void 0))throw new g("A metadata transaction hash requires tagging and the profile transaction hash.");let i=r!==void 0?H({abi:y,functionName:"setAgentURI",args:[r,s]}):H({abi:y,functionName:"register",args:[s,[...m,{metadataKey:k,metadataValue:R}]]}),c=f=>r===void 0?ve(e,f,a.profile):f;if(a.transactionHash!==void 0){let f=await we(e,a.transactionHash,n,s,i,r);if(!t){if(!w(f.registrarMetadata,R))throw new g(fe);if(a.metadataTransactionHash!==void 0)throw new g("Registration already writes oak.registrar in one transaction. Omit metadataTransactionHash.");return c(f)}return l&&a.metadataTransactionHash!==void 0?c(await ae(e,a.metadataTransactionHash,n,f)):c(f)}if(!t){let f=await ke(e,n);if(f){let b={...f,registrationResumed:!0},h=$(f.uri),v=Array.isArray(h?.tags)&&h.tags.includes(k);if(a.metadataTransactionHash!==void 0){if(!v)throw new g("Only a legacy Oak profile can resume its registrar metadata. Link this agent with oak setup link <agentId>.");return c({...await ae(e,a.metadataTransactionHash,n,f),registrationResumed:!0})}if(!v||f.registrarMetadata!=="0x")return c(b);let S=await U(e,[be(e,x(f.agentId))],n,`Resume registrar metadata for legacy Oak agent ${f.agentId}; no new identity will be minted. Submit locally, then repeat these arguments with metadataTransactionHash to verify the marker receipt.`);return{...b,...S}}if(a.metadataTransactionHash!==void 0)throw new g("No owned legacy Oak identity was found; no metadata transaction was built.")}r!==void 0&&await q(e,r,n);let p=[e.unsignedTx({to:o,data:i,value:"0",chainId:d,description:r===void 0?"Register an ERC-8004 agent profile.":`Update ERC-8004 agent ${r} profile.`})];return t?U(e,p,n,"Submit locally, then repeat the original arguments with transactionHash to verify the profile receipt and URI. The tag option changes the profile tag only; existing onchain metadata is unchanged."):U(e,p,n,`${le} Submit locally, then repeat the original arguments with transactionHash to verify the registration receipt, URI and marker. Update the profile registrations with the mined ID afterward.`)}async function Re(e,t){let a=await M(e,t.agentId),{chainId:n,registry:d}=I(e),o=e.clientFor(n),r=BigInt(a.agentId),u=t.metadataKeys===void 0?[]:(()=>{if(!Array.isArray(t.metadataKeys)||t.metadataKeys.length>16)throw new g("Provide at most 16 metadata keys.");return t.metadataKeys.map(h=>W(h,"metadata key",128,!1))})(),s=t.operator===void 0?void 0:se(String(t.operator)),[m,l,...i]=await Promise.allSettled([o.readContract({address:d,abi:y,functionName:"getApproved",args:[r]}),s?o.readContract({address:d,abi:y,functionName:"isApprovedForAll",args:[a.owner,s]}):Promise.resolve(void 0),...u.map(h=>o.readContract({address:d,abi:y,functionName:"getMetadata",args:[r,h]}))]),c=h=>h.status==="fulfilled"?h.value:void 0,p=c(m),f=_(a.agentWallet)?"unset":w(a.agentWallet,a.owner)?"owner":"verified-other",b=oe(e,a.uri,r);return{...a,approved:typeof p=="string"&&_(p)?null:p??"unavailable",...s?{operator:s,operatorApproved:c(l)??"unavailable"}:{},walletState:f,walletNote:f==="unset"?"No verified payment wallet: it starts as the minting owner, and any NFT transfer or erc8004_unset_wallet clears it. Re-verify with erc8004_wallet_proof then erc8004_set_wallet.":f==="owner"?"The payment wallet is the current owner.":"The payment wallet was proven by a signature from that wallet and is not the owner.",profile:{selfRegistered:b??null,fetched:!1,note:b===void 0?"The URI is external or not decodable; Oak does not fetch it.":void 0},...u.length?{metadata:Object.fromEntries(u.map((h,v)=>{let S=c(i[v]),P=typeof S=="string"&&/^0x([0-9a-fA-F]{2})*$/.test(S)?S:void 0,C;if(P&&P!=="0x")try{C=A(de(P))}catch{C=void 0}return[A(h),{hex:P??"unavailable",...C?{text:C}:{}}]}))}:{}}}var Ae={type:"object",additionalProperties:!1,required:["key"],properties:{key:{type:"string",minLength:1,maxLength:128,description:"Metadata key; agentWallet and oak.registrar are reserved during registration."},value:{...V,description:"Metadata bytes as 0x-prefixed hex; provide value or text."},text:{type:"string",description:"Metadata as UTF-8 text; provide text or value."}}},Te=e=>{let t=(n,d,o)=>({name:n,inputSchema:d,execute:async(r,u)=>{try{let s=await o(r,u);return T(s)&&typeof s.uri=="string"?{...s,uri:A(s.uri)}:s}catch(s){throw new g(e.plainError(s))}}}),a=n=>({type:"object",additionalProperties:!1,required:n?["agentId","profile"]:[],properties:{profile:{...ue,description:n?"Registration-v1 profile object to publish for this agent.":"Omit for an empty URI; register(uri, metadata[]) still writes the public oak.registrar marker. Attach a profile later with erc8004_update."},tag:{type:"boolean",default:!0,description:n?"Set false to remove the profile tag. Profile updates leave existing onchain metadata unchanged.":"Accepted only as true. Oak always adds the oak.registrar marker when it registers."},transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:n?"Verify the exact profile transaction, event and URI.":"After local submission, verify exact registration calldata, event, URI and oak.registrar marker."},metadataTransactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:n?"Optional legacy metadata transaction hash, supplied with transactionHash to verify a previously sent two-transaction update.":"Only for a resumed legacy Oak profile: verify its separate metadata transaction without transactionHash."},...n?{agentId:N}:{noTag:{type:"boolean",description:"Removed option: omit it and register again."},"--no-tag":{type:"boolean",description:"Removed option: omit it and register again."},metadata:{type:"array",maxItems:15,items:Ae,description:"Up to 15 user entries plus the mandatory oak.registrar marker. The keys agentWallet and oak.registrar are reserved."}}}});return{tools:[t("erc8004_register",a(!1),(n,d)=>ne(e,!1,n,d)),t("erc8004_update",a(!0),(n,d)=>ne(e,!0,n,d)),t("erc8004_identity",{type:"object",additionalProperties:!1,required:["agentId"],properties:{agentId:N,metadataKeys:{type:"array",maxItems:16,items:{type:"string",minLength:1,maxLength:128},description:"Also read these onchain metadata keys."},operator:{...L,description:"Also report whether this address is approved for all of the owner's agents."}}},n=>Re(e,n))]}},Ve=e=>K("erc8004",[Te(e),Q(e),X(e),Y(e),z(e),ee(e)]);export{Ke as a,De as b,oe as c,Te as d,Ve as e};
1
+ import{c as Q}from"./SUNTJ6IU.js";import{b as X}from"./ADIPEGNN.js";import{b as Z}from"./OB7BFDOV.js";import{i as ee}from"./ANIF3JMV.js";import{a as Y}from"./E76Z2TT4.js";import{b as z}from"./GBIBRYOV.js";import{a as D,b as k,c as R,d as N,g as V,h as I,k as _,l as x,n as B,p as W,r as $,s as U,t as q,v as E,x as J,y as G}from"./3A2IKFTV.js";import{a as y}from"./X5V2Z2NM.js";import{b as K}from"./SPJCSEKP.js";import{a as O}from"./43LI5NKJ.js";import{c as L,e as T,g as w}from"./NWNYJ26T.js";import{a as g,d as j}from"./XSD5NL7J.js";import{a as A}from"./JXOEJPJ4.js";import{Buffer as te}from"node:buffer";import{decodeEventLog as re,encodeFunctionData as H,getAddress as se,hexToString as de,parseAbiItem as ce,toEventSelector as ie}from"viem";var Ke={register:"erc8004_register"},ge="Oak now always adds the public oak.registrar marker when it registers an agent, so tag: false and --no-tag are no longer available. Remove the option and register again. To use an agent ID you already own without the marker, link it with oak setup link <agentId>.",fe="The registration went through, but Oak could not find its oak.registrar marker on Robinhood Chain. Nothing else was sent. Ask me to check the agent with erc8004_identity.",le="One transaction registers your agent and writes the public marker oak.registrar = oak. Anyone can see on Robinhood Chain that this agent was registered through Oak. The marker is self-reported, not proof of anything, and the transaction stays in the public history even if the marker is changed later. It needs gas.",F="https://eips.ethereum.org/EIPS/eip-8004#registration-v1",ue={type:"object",required:["type","name","description","image","services","x402Support","active","registrations"],properties:{type:{const:F,description:"ERC-8004 registration-v1 profile type URI."},name:{type:"string",minLength:1,description:"Short public name for the agent."},description:{type:"string",description:"Public text describing what the agent does; may be empty."},image:{type:"string",description:"Public HTTPS or IPFS image URI without credentials."},services:{type:"array",items:{type:"object",required:["name","endpoint"]},description:"Service endpoint objects with name and endpoint; use an empty list for none."},x402Support:{type:"boolean",description:"Whether the agent supports x402 payments."},active:{type:"boolean",description:"Whether this agent is active."},registrations:{type:"array",description:"Registry references with agentRegistry and agentId; leave empty before first registration."},tags:{type:"array",items:{type:"string"},description:"Optional public text labels for the agent."},supportedTrust:{type:"array",items:{type:"string"},description:"Optional trust mechanism labels supported by the agent."}}};function pe(e){if(typeof e!="string"||!e.trim())return!1;try{let t=new URL(e);return["https:","ipfs:"].includes(t.protocol)&&!!t.hostname&&!t.username&&!t.password}catch{return!1}}var me=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&t.trim()),he=e=>e.replace(/\.$/,"");function ye(e,t,a,n){let{registryId:d}=I(e);if(!T(t))throw new g("Provide a registration-v1 profile object.");if(a!==void 0&&typeof a!="boolean")throw new g("The tag option must be a boolean.");let o=[],r=(i,c)=>o.push(`${i}: ${c}`);t.type!==F&&r("type",`use "${F}"`),(typeof t.name!="string"||!t.name.trim())&&r("name",'a short name for your agent, such as "Oak Agent 1"'),typeof t.description!="string"&&r("description","a sentence about what your agent does (it may be empty text)"),pe(t.image)||r("image","an HTTPS or IPFS link to a picture, with no username or password in it"),typeof t.active!="boolean"&&r("active","true or false"),typeof t.x402Support!="boolean"&&r("x402Support","true or false"),Array.isArray(t.services)?t.services.forEach((i,c)=>{try{Z(i)}catch(p){if(!(p instanceof g))throw p;r(`services item ${c+1}`,he(p.message))}}):r("services","a list of endpoints, or [] for none");for(let i of["tags","supportedTrust"])t[i]!==void 0&&!me(t[i])&&r(i,"a list of nonempty text labels, or leave it out");if(Array.isArray(t.registrations)?t.registrations.forEach((i,c)=>{let p=`registrations item ${c+1}`;if(!T(i)||typeof i.agentRegistry!="string"||!/^eip155:[1-9][0-9]*:0x[0-9a-fA-F]{40}$/.test(i.agentRegistry))return r(p,"an agentRegistry such as eip155:4663:0x\u2026 and its agentId");let f=typeof i.agentId=="number"&&Number.isSafeInteger(i.agentId)?String(i.agentId):i.agentId,b;try{b=x(f)}catch{return r(p,'an agentId as a whole number, such as "1"')}w(i.agentRegistry,d)&&(n===void 0?r(p,"remove the entry for this registry; its ID comes from the mined Registered receipt, and erc8004_update adds it afterwards"):b!==n&&r(p,`the agentId does not match the agent being updated; use "${n}" or remove the entry`))}):r("registrations","a list, or [] before the first registration"),o.length)throw new g(`This profile needs: ${o.join("; ")}. Fix all of these and try again.`);let u=t.registrations.map(i=>({...i}));n!==void 0&&!u.some(i=>w(i.agentRegistry,d))&&u.push({agentId:n.toString(),agentRegistry:d});let s=[...new Set((t.tags??[]).filter(i=>i!==k))];a!==!1&&s.push(k);let m={...t,registrations:u,...s.length?{tags:s}:{}};s.length||delete m.tags;let l;try{if(l=JSON.stringify(m),te.byteLength(l)>65536)throw new Error;JSON.parse(l)}catch{throw new g("Profile must be JSON data no larger than 64 KiB.")}return`data:application/json;base64,${te.from(l,"utf8").toString("base64")}`}async function M(e,t){try{let{chainId:a,registry:n}=I(e),d=x(t),o=e.clientFor(a),r=await o.readContract({address:n,abi:y,functionName:"ownerOf",args:[d]}).catch(l=>{throw j(l)?new g(`Agent ${d} does not exist in this ERC-8004 registry: the owner lookup reverted. Check the agent ID.`):l});O(r);let[u,s,m]=await Promise.all([o.readContract({address:n,abi:y,functionName:"tokenURI",args:[d]}),o.readContract({address:n,abi:y,functionName:"getAgentWallet",args:[d]}),o.readContract({address:n,abi:y,functionName:"getMetadata",args:[d,k]})]);if(O(s),typeof u!="string"||typeof m!="string"||!/^0x([0-9a-fA-F]{2})*$/.test(m))throw new g("The registry returned invalid identity data.");return{agentId:d.toString(),chainId:a,registry:n,owner:r,uri:u,agentWallet:s,registrarMetadata:m,registryValidated:!1,summary:D}}catch(a){throw new g(e.plainError(a))}}async function De(e,t){let a=await M(e,t);return{...a,uri:A(a.uri)}}async function we(e,t,a,n,d,o){let{registry:r}=I(e),u=await E(e,t,a,d),s=o===void 0?"Registered":"URIUpdated",m=ie(o===void 0?"Registered(uint256,string,address)":"URIUpdated(uint256,string,address)"),l=u.logs.filter(v=>w(v.address,r)&&v.topics[0]===m&&!v.removed);if(l.length!==1)throw new g(`The receipt must contain one matching ${s} event.`);let i=l[0],c=re({abi:y,eventName:s,topics:i.topics,data:i.data,strict:!0}),p=c.args.agentId,f=c.eventName==="Registered"?c.args.agentURI:c.args.newURI,b=c.eventName==="Registered"?c.args.owner:c.args.updatedBy;if(o!==void 0&&p!==o||f!==n||!w(b,a))throw new g("The registry event does not match the expected agent, URI and wallet.");let h=await M(e,p.toString());if(h.uri!==n||o===void 0&&!w(h.owner,a))throw new g("The current agent owner or URI does not match the confirmed operation.");return h}function be(e,t){let{chainId:a,registry:n}=I(e);return e.unsignedTx({to:n,chainId:a,value:"0",data:H({abi:y,functionName:"setMetadata",args:[t,k,R]}),description:`Set mutable oak.registrar metadata to oak for agent ${t}.`})}async function ae(e,t,a,n){let{registry:d}=I(e),o=x(n.agentId),r=await E(e,t,a,H({abi:y,functionName:"setMetadata",args:[o,k,R]})),u=ie("MetadataSet(uint256,string,string,bytes)"),s=r.logs.filter(c=>w(c.address,d)&&c.topics[0]===u&&!c.removed);if(s.length!==1)throw new g("The receipt must contain one matching MetadataSet event.");let m=s[0],{args:l}=re({abi:y,eventName:"MetadataSet",topics:m.topics,data:m.data,strict:!0});if(l.agentId!==o||l.metadataKey!==k||l.metadataValue!==R)throw new g("The metadata event does not match this agent and registrar marker.");let i=await M(e,n.agentId);if(i.registrarMetadata!==R||i.uri!==n.uri||!w(i.owner,n.owner))throw new g("The current agent metadata, owner or URI does not match the confirmed operation.");return i}async function ke(e,t){let{chainId:a,registry:n}=I(e),d=e.clientFor(a),o=await d.readContract({address:n,abi:y,functionName:"balanceOf",args:[t]});if(o===0n)return;if(typeof o!="bigint"||o<0n)throw new g("Registry balance is unavailable; registration was not built.");let r=await d.getBlockNumber({cacheTime:0}),u=new Set;for(;;){let s=r>9999999n?r-9999999n:0n,m=await d.getLogs({address:n,event:ce("event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"),args:{to:t},fromBlock:s,toBlock:r,strict:!0});for(let l of m){let i=l.args.tokenId.toString();if(l.removed||u.has(i))continue;u.add(i);let c=await M(e,i);if(w(c.owner,t))return c}if(s===0n)throw new g("Owned identity could not be located; registration was not built. Run oak setup link <agentId>.");r=s-1n}}function Ie(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>15)throw new g("Provide at most 15 user metadata entries as { key, value } with value as 0x hex or text.");let t=new Set;return e.map(a=>{if(!T(a))throw new g("Provide each metadata entry as { key, value } or { key, text }.");let n=J(a.key);if(n===k)throw new g("The key oak.registrar is reserved for the registration marker. Remove that metadata entry.");if(t.has(n))throw new g(`Metadata key ${A(n)} is repeated.`);return t.add(n),{metadataKey:n,metadataValue:G(a)}})}function oe(e,t,a){let n=$(t);if(!n)return;let{registryId:d}=I(e);return Array.isArray(n.registrations)&&n.registrations.some(o=>T(o)&&typeof o.agentRegistry=="string"&&w(o.agentRegistry,d)&&String(o.agentId)===a.toString())}function ve(e,t,a){let n=oe(e,t.uri,BigInt(t.agentId));return n===!0?{...t,profileComplete:!0}:{...t,profileComplete:n===void 0?null:!1,nextStep:{tool:"erc8004_update",arguments:{agentId:t.agentId,profile:a??"a registration-v1 profile object"},why:"The minted profile does not list its own registry and agent ID yet (registrations is empty). erc8004_update appends it automatically. It is a normal action: it needs a verified identity link and an active subscription, so link with oak_setup first."}}}async function ne(e,t,a,n){let{chainId:d,registry:o}=I(e);O(n),B(e,a.chainId);let r=t?x(a.agentId):void 0;if(!t&&(a.tag===!1||a.noTag!==void 0||a["--no-tag"]!==void 0))throw new g(ge);if(a.tag!==void 0&&typeof a.tag!="boolean")throw new g("The tag option must be a boolean.");let s=!t&&a.profile===void 0?"":ye(e,a.profile,a.tag,r),m=t?[]:Ie(a.metadata),l=a.tag!==!1;if(t&&a.metadataTransactionHash!==void 0&&(!l||a.transactionHash===void 0))throw new g("A metadata transaction hash requires tagging and the profile transaction hash.");let i=r!==void 0?H({abi:y,functionName:"setAgentURI",args:[r,s]}):H({abi:y,functionName:"register",args:[s,[...m,{metadataKey:k,metadataValue:R}]]}),c=f=>r===void 0?ve(e,f,a.profile):f;if(a.transactionHash!==void 0){let f=await we(e,a.transactionHash,n,s,i,r);if(!t){if(!w(f.registrarMetadata,R))throw new g(fe);if(a.metadataTransactionHash!==void 0)throw new g("Registration already writes oak.registrar in one transaction. Omit metadataTransactionHash.");return c(f)}return l&&a.metadataTransactionHash!==void 0?c(await ae(e,a.metadataTransactionHash,n,f)):c(f)}if(!t){let f=await ke(e,n);if(f){let b={...f,registrationResumed:!0},h=$(f.uri),v=Array.isArray(h?.tags)&&h.tags.includes(k);if(a.metadataTransactionHash!==void 0){if(!v)throw new g("Only a legacy Oak profile can resume its registrar metadata. Link this agent with oak setup link <agentId>.");return c({...await ae(e,a.metadataTransactionHash,n,f),registrationResumed:!0})}if(!v||f.registrarMetadata!=="0x")return c(b);let S=await U(e,[be(e,x(f.agentId))],n,`Resume registrar metadata for legacy Oak agent ${f.agentId}; no new identity will be minted. Submit locally, then repeat these arguments with metadataTransactionHash to verify the marker receipt.`);return{...b,...S}}if(a.metadataTransactionHash!==void 0)throw new g("No owned legacy Oak identity was found; no metadata transaction was built.")}r!==void 0&&await q(e,r,n);let p=[e.unsignedTx({to:o,data:i,value:"0",chainId:d,description:r===void 0?"Register an ERC-8004 agent profile.":`Update ERC-8004 agent ${r} profile.`})];return t?U(e,p,n,"Submit locally, then repeat the original arguments with transactionHash to verify the profile receipt and URI. The tag option changes the profile tag only; existing onchain metadata is unchanged."):U(e,p,n,`${le} Submit locally, then repeat the original arguments with transactionHash to verify the registration receipt, URI and marker. Update the profile registrations with the mined ID afterward.`)}async function Re(e,t){let a=await M(e,t.agentId),{chainId:n,registry:d}=I(e),o=e.clientFor(n),r=BigInt(a.agentId),u=t.metadataKeys===void 0?[]:(()=>{if(!Array.isArray(t.metadataKeys)||t.metadataKeys.length>16)throw new g("Provide at most 16 metadata keys.");return t.metadataKeys.map(h=>W(h,"metadata key",128,!1))})(),s=t.operator===void 0?void 0:se(String(t.operator)),[m,l,...i]=await Promise.allSettled([o.readContract({address:d,abi:y,functionName:"getApproved",args:[r]}),s?o.readContract({address:d,abi:y,functionName:"isApprovedForAll",args:[a.owner,s]}):Promise.resolve(void 0),...u.map(h=>o.readContract({address:d,abi:y,functionName:"getMetadata",args:[r,h]}))]),c=h=>h.status==="fulfilled"?h.value:void 0,p=c(m),f=_(a.agentWallet)?"unset":w(a.agentWallet,a.owner)?"owner":"verified-other",b=oe(e,a.uri,r);return{...a,approved:typeof p=="string"&&_(p)?null:p??"unavailable",...s?{operator:s,operatorApproved:c(l)??"unavailable"}:{},walletState:f,walletNote:f==="unset"?"No verified payment wallet: it starts as the minting owner, and any NFT transfer or erc8004_unset_wallet clears it. Re-verify with erc8004_wallet_proof then erc8004_set_wallet.":f==="owner"?"The payment wallet is the current owner.":"The payment wallet was proven by a signature from that wallet and is not the owner.",profile:{selfRegistered:b??null,fetched:!1,note:b===void 0?"The URI is external or not decodable; Oak does not fetch it.":void 0},...u.length?{metadata:Object.fromEntries(u.map((h,v)=>{let S=c(i[v]),P=typeof S=="string"&&/^0x([0-9a-fA-F]{2})*$/.test(S)?S:void 0,C;if(P&&P!=="0x")try{C=A(de(P))}catch{C=void 0}return[A(h),{hex:P??"unavailable",...C?{text:C}:{}}]}))}:{}}}var Ae={type:"object",additionalProperties:!1,required:["key"],properties:{key:{type:"string",minLength:1,maxLength:128,description:"Metadata key; agentWallet and oak.registrar are reserved during registration."},value:{...V,description:"Metadata bytes as 0x-prefixed hex; provide value or text."},text:{type:"string",description:"Metadata as UTF-8 text; provide text or value."}}},Te=e=>{let t=(n,d,o)=>({name:n,inputSchema:d,execute:async(r,u)=>{try{let s=await o(r,u);return T(s)&&typeof s.uri=="string"?{...s,uri:A(s.uri)}:s}catch(s){throw new g(e.plainError(s))}}}),a=n=>({type:"object",additionalProperties:!1,required:n?["agentId","profile"]:[],properties:{profile:{...ue,description:n?"Registration-v1 profile object to publish for this agent.":"Omit for an empty URI; register(uri, metadata[]) still writes the public oak.registrar marker. Attach a profile later with erc8004_update."},tag:{type:"boolean",default:!0,description:n?"Set false to remove the profile tag. Profile updates leave existing onchain metadata unchanged.":"Accepted only as true. Oak always adds the oak.registrar marker when it registers."},transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:n?"Verify the exact profile transaction, event and URI.":"After local submission, verify exact registration calldata, event, URI and oak.registrar marker."},metadataTransactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:n?"Optional legacy metadata transaction hash, supplied with transactionHash to verify a previously sent two-transaction update.":"Only for a resumed legacy Oak profile: verify its separate metadata transaction without transactionHash."},...n?{agentId:N}:{noTag:{type:"boolean",description:"Removed option: omit it and register again."},"--no-tag":{type:"boolean",description:"Removed option: omit it and register again."},metadata:{type:"array",maxItems:15,items:Ae,description:"Up to 15 user entries plus the mandatory oak.registrar marker. The keys agentWallet and oak.registrar are reserved."}}}});return{tools:[t("erc8004_register",a(!1),(n,d)=>ne(e,!1,n,d)),t("erc8004_update",a(!0),(n,d)=>ne(e,!0,n,d)),t("erc8004_identity",{type:"object",additionalProperties:!1,required:["agentId"],properties:{agentId:N,metadataKeys:{type:"array",maxItems:16,items:{type:"string",minLength:1,maxLength:128},description:"Also read these onchain metadata keys."},operator:{...L,description:"Also report whether this address is approved for all of the owner's agents."}}},n=>Re(e,n))]}},Ve=e=>K("erc8004",[Te(e),Q(e),X(e),Y(e),z(e),ee(e)]);export{Ke as a,De as b,oe as c,Te as d,Ve as e};