@oracle-agent/oracle 0.13.1 → 0.14.0

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 (449) hide show
  1. package/CONTRIBUTING.md +99 -0
  2. package/README.md +20 -14
  3. package/SECURITY.md +6 -8
  4. package/SETUP.md +25 -27
  5. package/bin/desk-server.mjs +473 -0
  6. package/bin/oracle-data-mcp.mjs +1252 -0
  7. package/bin/oracle-equities.mjs +168 -0
  8. package/bin/oracle-init.mjs +525 -0
  9. package/bin/oracle-public-server.mjs +36 -0
  10. package/bin/oracle-route.mjs +254 -0
  11. package/bin/oracle-scan.mjs +192 -0
  12. package/bin/oracle-upgrade.mjs +42 -0
  13. package/bin/oracle.mjs +34 -0
  14. package/docs/adding-a-chain.md +229 -0
  15. package/docs/architecture.md +139 -0
  16. package/docs/buzz-integration.md +115 -0
  17. package/docs/cli.md +143 -0
  18. package/docs/connectors.md +13 -0
  19. package/docs/hyperliquid-builder-code.md +50 -0
  20. package/docs/locals-only-fee-waiver.md +34 -0
  21. package/docs/oracle-pack-standard.md +29 -0
  22. package/docs/profiles.md +151 -0
  23. package/docs/public-surface.md +206 -0
  24. package/examples/add-a-chain.mjs +65 -0
  25. package/examples/oracle-pack-template.mjs +38 -0
  26. package/examples/research-a-token.mjs +70 -0
  27. package/package.json +78 -32
  28. package/plugins/oracle-owner-gate/__init__.py +288 -0
  29. package/plugins/oracle-owner-gate/plugin.yaml +9 -0
  30. package/{dist/assets/profiles → profiles}/oracle/SOUL.md +0 -14
  31. package/protocols/templates/safe-erc20/SECURITY.md +16 -0
  32. package/protocols/templates/safe-erc20/foundry.toml +12 -0
  33. package/protocols/templates/safe-erc20/remappings.txt +2 -0
  34. package/protocols/templates/safe-erc20/src/SafeERC20.sol +53 -0
  35. package/protocols/templates/safe-erc20/test/SafeERC20.t.sol +72 -0
  36. package/public/oracle-splash/_variants/ice.html +3 -3
  37. package/public/oracle-splash/_variants/ivory.html +3 -3
  38. package/public/oracle-splash/downloads/index.html +34 -223
  39. package/public/oracle-splash/index.html +11 -11
  40. package/scripts/adversarial-bench.mjs +114 -0
  41. package/scripts/build-dist.mjs +119 -0
  42. package/scripts/build-inscription.py +230 -0
  43. package/scripts/check-doc-drift.mjs +123 -0
  44. package/scripts/check-test-count.mjs +105 -0
  45. package/scripts/e2e-hl-markets.mjs +21 -0
  46. package/scripts/e2e-hl-perps.mjs +48 -0
  47. package/scripts/e2e-hypercore-staking.mjs +128 -0
  48. package/scripts/e2e-solana-bitcoin.mjs +183 -0
  49. package/scripts/guard-publish.mjs +22 -0
  50. package/scripts/protocol-template-gate.mjs +15 -0
  51. package/scripts/public-api-scan.mjs +23 -0
  52. package/scripts/publish-dist.mjs +67 -0
  53. package/scripts/record-hero-cli.sh +80 -0
  54. package/scripts/secret-scan.mjs +168 -0
  55. package/scripts/smoke-dist-bins.mjs +89 -0
  56. package/scripts/verify-dist.mjs +29 -0
  57. package/scripts/verify-v3-venues.mjs +233 -0
  58. package/skins/oracle.yaml +56 -0
  59. package/src/action-receipts.mjs +265 -0
  60. package/src/action-semantics.mjs +62 -0
  61. package/src/address-book.mjs +208 -0
  62. package/src/agent-auth.mjs +206 -0
  63. package/src/approval-guard.mjs +282 -0
  64. package/src/attestation-secret.mjs +94 -0
  65. package/src/audit-log.mjs +196 -0
  66. package/src/auth/oauth.mjs +672 -0
  67. package/src/auto-slippage.mjs +378 -0
  68. package/src/capability-posture.mjs +125 -0
  69. package/src/cards.mjs +422 -0
  70. package/src/chains.mjs +62 -0
  71. package/src/cli/chain-catalog.mjs +215 -0
  72. package/src/cli/chain-state.mjs +74 -0
  73. package/src/cli/commands/auth.mjs +193 -0
  74. package/src/cli/commands/bootstrap.mjs +87 -0
  75. package/src/cli/commands/chain.mjs +143 -0
  76. package/src/cli/commands/chat.mjs +465 -0
  77. package/src/cli/commands/credential.mjs +9 -0
  78. package/src/cli/commands/data-mcp.mjs +18 -0
  79. package/src/cli/commands/data.mjs +75 -0
  80. package/src/cli/commands/doctor.mjs +136 -0
  81. package/src/cli/commands/equities.mjs +41 -0
  82. package/src/cli/commands/farm.mjs +129 -0
  83. package/src/cli/commands/fees.mjs +109 -0
  84. package/src/cli/commands/follow.mjs +130 -0
  85. package/src/cli/commands/harness.mjs +63 -0
  86. package/src/cli/commands/help.mjs +7 -0
  87. package/src/cli/commands/init.mjs +27 -0
  88. package/src/cli/commands/mcp.mjs +154 -0
  89. package/src/cli/commands/model.mjs +106 -0
  90. package/src/cli/commands/plugins.mjs +241 -0
  91. package/src/cli/commands/prepare.mjs +12 -0
  92. package/src/cli/commands/public.mjs +20 -0
  93. package/src/cli/commands/resolve.mjs +64 -0
  94. package/src/cli/commands/route.mjs +12 -0
  95. package/src/cli/commands/runner.mjs +9 -0
  96. package/src/cli/commands/scan.mjs +12 -0
  97. package/src/cli/commands/setup.mjs +294 -0
  98. package/src/cli/commands/sign.mjs +21 -0
  99. package/src/cli/commands/signer.mjs +9 -0
  100. package/src/cli/commands/swap.mjs +102 -0
  101. package/src/cli/commands/upgrade.mjs +12 -0
  102. package/src/cli/commands/vault.mjs +9 -0
  103. package/src/cli/commands/version.mjs +22 -0
  104. package/src/cli/first-run.mjs +23 -0
  105. package/src/cli/kernel.mjs +262 -0
  106. package/src/cli/mcp-targets/chatgpt.mjs +51 -0
  107. package/src/cli/mcp-targets/claude-code.mjs +39 -0
  108. package/src/cli/mcp-targets/claude-desktop.mjs +24 -0
  109. package/src/cli/mcp-targets/codex.mjs +41 -0
  110. package/src/cli/mcp-targets/cursor.mjs +32 -0
  111. package/src/cli/mcp-targets/shared.mjs +71 -0
  112. package/src/cli/mcp-targets/vscode.mjs +39 -0
  113. package/src/cli/messaging-platforms.mjs +217 -0
  114. package/src/cli/model-config.mjs +78 -0
  115. package/src/cli/operator-dispatch.mjs +257 -0
  116. package/src/cli/oracle-harness.py +415 -0
  117. package/src/cli/paths.mjs +107 -0
  118. package/src/cli/runtime.mjs +351 -0
  119. package/src/cli/setup-state.mjs +168 -0
  120. package/src/cli/spawn-child.mjs +43 -0
  121. package/src/data/catalog.mjs +858 -0
  122. package/src/data/desk-data.mjs +877 -0
  123. package/src/data/http.mjs +253 -0
  124. package/src/data/names.mjs +188 -0
  125. package/src/data/provider-endpoint.mjs +94 -0
  126. package/src/data/providers/aave-v3.mjs +139 -0
  127. package/src/data/providers/across-bridge.mjs +41 -0
  128. package/src/data/providers/aerodrome.mjs +245 -0
  129. package/src/data/providers/aevo.mjs +33 -0
  130. package/src/data/providers/approval-indexer.mjs +133 -0
  131. package/src/data/providers/approvals.mjs +594 -0
  132. package/src/data/providers/babylon-staking.mjs +149 -0
  133. package/src/data/providers/balancer.mjs +209 -0
  134. package/src/data/providers/beefy-yields.mjs +45 -0
  135. package/src/data/providers/birdeye-tokens.mjs +33 -0
  136. package/src/data/providers/bisq-markets.mjs +145 -0
  137. package/src/data/providers/bitcoin-esplora.mjs +216 -0
  138. package/src/data/providers/bitcoin-meta.mjs +378 -0
  139. package/src/data/providers/blockscout.mjs +14 -0
  140. package/src/data/providers/bob-rootstock.mjs +198 -0
  141. package/src/data/providers/braiins-insights.mjs +103 -0
  142. package/src/data/providers/bridge-aggregator.mjs +259 -0
  143. package/src/data/providers/bridges.mjs +242 -0
  144. package/src/data/providers/bungee.mjs +29 -0
  145. package/src/data/providers/celestia-da.mjs +38 -0
  146. package/src/data/providers/changenow.mjs +135 -0
  147. package/src/data/providers/compound.mjs +32 -0
  148. package/src/data/providers/connext.mjs +28 -0
  149. package/src/data/providers/convex.mjs +30 -0
  150. package/src/data/providers/cow-protocol.mjs +110 -0
  151. package/src/data/providers/cowswap.mjs +415 -0
  152. package/src/data/providers/curve.mjs +201 -0
  153. package/src/data/providers/das-assets.mjs +59 -0
  154. package/src/data/providers/debridge.mjs +109 -0
  155. package/src/data/providers/defillama.mjs +88 -0
  156. package/src/data/providers/dexscreener.mjs +43 -0
  157. package/src/data/providers/drift.mjs +32 -0
  158. package/src/data/providers/dydx.mjs +41 -0
  159. package/src/data/providers/evm-rpc.mjs +225 -0
  160. package/src/data/providers/farming.mjs +291 -0
  161. package/src/data/providers/geckoterminal.mjs +34 -0
  162. package/src/data/providers/gmx.mjs +496 -0
  163. package/src/data/providers/hiro-stacks.mjs +150 -0
  164. package/src/data/providers/hl-assets.mjs +165 -0
  165. package/src/data/providers/hl-info.mjs +108 -0
  166. package/src/data/providers/hl-markets.mjs +210 -0
  167. package/src/data/providers/hl-outcome.mjs +61 -0
  168. package/src/data/providers/hl-perps.mjs +419 -0
  169. package/src/data/providers/hl-staking.mjs +353 -0
  170. package/src/data/providers/hl-ws.mjs +119 -0
  171. package/src/data/providers/hyperevm-dex.mjs +49 -0
  172. package/src/data/providers/jito-mev.mjs +117 -0
  173. package/src/data/providers/jupiter-venues.mjs +119 -0
  174. package/src/data/providers/jupiter.mjs +315 -0
  175. package/src/data/providers/kamino-strategies.mjs +143 -0
  176. package/src/data/providers/l2beat-tvl.mjs +42 -0
  177. package/src/data/providers/lifi.mjs +166 -0
  178. package/src/data/providers/liquid-esplora.mjs +152 -0
  179. package/src/data/providers/magiceden-ordinals.mjs +141 -0
  180. package/src/data/providers/magiceden-sol.mjs +406 -0
  181. package/src/data/providers/mempool-lightning.mjs +144 -0
  182. package/src/data/providers/mempool-mining.mjs +142 -0
  183. package/src/data/providers/meteora-dlmm.mjs +168 -0
  184. package/src/data/providers/morpho.mjs +177 -0
  185. package/src/data/providers/nft-gallery.mjs +163 -0
  186. package/src/data/providers/nft-portfolio.mjs +494 -0
  187. package/src/data/providers/odos.mjs +156 -0
  188. package/src/data/providers/ondo.mjs +31 -0
  189. package/src/data/providers/oneinch.mjs +174 -0
  190. package/src/data/providers/opensea-multichain.mjs +136 -0
  191. package/src/data/providers/opensea-nft.mjs +371 -0
  192. package/src/data/providers/orca.mjs +29 -0
  193. package/src/data/providers/ordinals-runes.mjs +180 -0
  194. package/src/data/providers/pancakeswap.mjs +28 -0
  195. package/src/data/providers/paraswap.mjs +125 -0
  196. package/src/data/providers/pendle.mjs +188 -0
  197. package/src/data/providers/poly-clob.mjs +283 -0
  198. package/src/data/providers/poly-public.mjs +96 -0
  199. package/src/data/providers/poly-ws.mjs +103 -0
  200. package/src/data/providers/polygon-staking.mjs +227 -0
  201. package/src/data/providers/portfolio-history.mjs +394 -0
  202. package/src/data/providers/portfolio.mjs +600 -0
  203. package/src/data/providers/pyth-price-feeds.mjs +172 -0
  204. package/src/data/providers/raydium.mjs +35 -0
  205. package/src/data/providers/relayscan-mev.mjs +72 -0
  206. package/src/data/providers/rfq.mjs +15 -0
  207. package/src/data/providers/rh-agent.mjs +59 -0
  208. package/src/data/providers/sanctum-lst.mjs +180 -0
  209. package/src/data/providers/satflow.mjs +341 -0
  210. package/src/data/providers/signed-material-guard.mjs +108 -0
  211. package/src/data/providers/solana-rpc.mjs +197 -0
  212. package/src/data/providers/solend-lending.mjs +166 -0
  213. package/src/data/providers/spark-lend.mjs +42 -0
  214. package/src/data/providers/squid-router.mjs +29 -0
  215. package/src/data/providers/stargate.mjs +29 -0
  216. package/src/data/providers/sushiswap.mjs +30 -0
  217. package/src/data/providers/symbiotic-restaking.mjs +41 -0
  218. package/src/data/providers/thorchain.mjs +36 -0
  219. package/src/data/providers/traderjoe.mjs +28 -0
  220. package/src/data/providers/twap.mjs +152 -0
  221. package/src/data/providers/uniswap-v3.mjs +457 -0
  222. package/src/data/providers/uniswap-v4.mjs +414 -0
  223. package/src/data/providers/vertex.mjs +41 -0
  224. package/src/data/providers/wallet-watch.mjs +264 -0
  225. package/src/data/providers/wormhole.mjs +28 -0
  226. package/src/data/providers/yearn.mjs +31 -0
  227. package/src/data/providers/zerox.mjs +167 -0
  228. package/src/data/public-api-scan.mjs +61 -0
  229. package/src/data/quote-placeholder.mjs +31 -0
  230. package/src/desk/swap-prepare.mjs +194 -0
  231. package/src/equities/bridge.mjs +388 -0
  232. package/src/equities/fixtures/bridge_routes.json +159 -0
  233. package/src/equities/fixtures/dst_transitions.json +29 -0
  234. package/src/equities/fixtures/equity_dex_pools.json +154 -0
  235. package/src/equities/fixtures/hip3_l2books.json +2711 -0
  236. package/src/equities/fixtures/nyse_holidays.json +1 -0
  237. package/src/equities/fixtures/oracles.json +100 -0
  238. package/src/equities/fixtures/rh_pool_state.json +244 -0
  239. package/src/equities/fixtures/solana_xstocks.json +704 -0
  240. package/src/equities/fixtures/ton_xstocks.json +35 -0
  241. package/src/equities/fixtures/universe.json +411 -0
  242. package/src/equities/fixtures/venues.json +3542 -0
  243. package/src/equities/fixtures.mjs +405 -0
  244. package/src/equities/funding.mjs +142 -0
  245. package/src/equities/index.mjs +166 -0
  246. package/src/equities/liveness.mjs +148 -0
  247. package/src/equities/marketHours.mjs +249 -0
  248. package/src/equities/normalize.mjs +295 -0
  249. package/src/equities/num.mjs +146 -0
  250. package/src/equities/prepare.mjs +95 -0
  251. package/src/equities/rank.mjs +260 -0
  252. package/src/equities/sourceNum.mjs +69 -0
  253. package/src/equities/types.mjs +220 -0
  254. package/src/equities/venues/arcus-perp.mjs +84 -0
  255. package/src/equities/venues/arcus-spot.mjs +105 -0
  256. package/src/equities/venues/hyperliquid-hip3.mjs +224 -0
  257. package/src/equities/venues/rh-uniswap.mjs +216 -0
  258. package/src/equities/venues/solana-xstocks.mjs +139 -0
  259. package/src/equities/venues/ton-stonfi.mjs +139 -0
  260. package/src/exact-integer.mjs +72 -0
  261. package/src/exec-policy.mjs +419 -0
  262. package/src/flags.mjs +15 -0
  263. package/src/fresh-window.mjs +76 -0
  264. package/src/gmx-attestation.mjs +176 -0
  265. package/src/index.mjs +107 -0
  266. package/src/licensing/locals-only.mjs +25 -0
  267. package/src/nft-gas-war-guard.mjs +139 -0
  268. package/src/onboarding/agent-keys.mjs +161 -0
  269. package/src/onboarding/harness-configs.mjs +102 -0
  270. package/src/onboarding/index.mjs +18 -0
  271. package/src/onboarding/tiers.mjs +139 -0
  272. package/src/oracle-env.mjs +55 -0
  273. package/src/package-manifest.mjs +42 -0
  274. package/src/plugins/agent-plugin-loader.mjs +225 -0
  275. package/src/portfolio-risk.mjs +170 -0
  276. package/src/prepare-envelope.mjs +204 -0
  277. package/src/profile-upgrade.mjs +277 -0
  278. package/src/protocol-execution.mjs +84 -0
  279. package/src/protocol-templates/gate.mjs +179 -0
  280. package/src/protocol-templates/prepare-deploy.mjs +81 -0
  281. package/src/public-api/agent-grants.mjs +57 -0
  282. package/src/public-api/buzz-integration.mjs +267 -0
  283. package/src/public-api/connect-agent.mjs +424 -0
  284. package/src/public-api/grants.mjs +142 -0
  285. package/src/public-api/http.mjs +707 -0
  286. package/src/public-api/metering.mjs +111 -0
  287. package/src/public-control/aa-adapter.mjs +402 -0
  288. package/src/public-control/build-registry.mjs +227 -0
  289. package/src/public-control/bundler-client.mjs +357 -0
  290. package/src/public-control/grant-indexer.mjs +296 -0
  291. package/src/public-control/policy-render.mjs +69 -0
  292. package/src/public-control/policy-schema.mjs +322 -0
  293. package/src/public-control/runtime-config.mjs +275 -0
  294. package/src/public-control/session-key-model.mjs +379 -0
  295. package/src/public-control/session-orchestrator.mjs +418 -0
  296. package/src/rfq/intent.mjs +180 -0
  297. package/src/rfq/sources.mjs +181 -0
  298. package/src/route-attestation.mjs +132 -0
  299. package/src/router/best-execution.mjs +326 -0
  300. package/src/router/index.mjs +250 -0
  301. package/src/router/integrator-fee.mjs +135 -0
  302. package/src/router/prepare-bridge.mjs +293 -0
  303. package/src/router/prepare-route.mjs +398 -0
  304. package/src/router/proposal.mjs +311 -0
  305. package/src/router/risk-classifier.mjs +119 -0
  306. package/src/router/route-sources.mjs +364 -0
  307. package/src/scanner/chains.config.mjs +543 -0
  308. package/src/scanner/contract.mjs +270 -0
  309. package/src/scanner/evm-scanner.mjs +394 -0
  310. package/src/scanner/index.mjs +9 -0
  311. package/src/scanner/v2-venue.mjs +351 -0
  312. package/src/scanner/v3-venue.mjs +308 -0
  313. package/src/scopes.mjs +44 -0
  314. package/src/sell-simulation.mjs +167 -0
  315. package/src/signals/engine.mjs +146 -0
  316. package/src/signals/index.mjs +1 -0
  317. package/src/token-transfer-guard.mjs +188 -0
  318. package/src/tui/app.mjs +438 -0
  319. package/src/tui/backend.mjs +215 -0
  320. package/src/tui/format.mjs +272 -0
  321. package/src/tui/gateway-client.mjs +177 -0
  322. package/src/tui/input.mjs +501 -0
  323. package/src/tui/memory.mjs +105 -0
  324. package/src/tui/meta-learn.mjs +85 -0
  325. package/src/tui/renderer.mjs +443 -0
  326. package/src/tui/scheduler.mjs +205 -0
  327. package/src/tui/skills-loader.mjs +140 -0
  328. package/src/tui/standalone-client.mjs +752 -0
  329. package/src/tui/theme.mjs +81 -0
  330. package/src/vault-attestation.mjs +146 -0
  331. package/src/venues.mjs +206 -0
  332. package/src/watch-preferences.mjs +85 -0
  333. package/dist/action-receipts.mjs +0 -1
  334. package/dist/action-semantics.mjs +0 -1
  335. package/dist/address-book.mjs +0 -2
  336. package/dist/bin/desk-server.mjs +0 -59
  337. package/dist/bin/oracle-data-mcp.mjs +0 -8
  338. package/dist/bin/oracle-equities.mjs +0 -20
  339. package/dist/bin/oracle-init.mjs +0 -24
  340. package/dist/bin/oracle-public-server.mjs +0 -5
  341. package/dist/bin/oracle-route.mjs +0 -22
  342. package/dist/bin/oracle-scan.mjs +0 -18
  343. package/dist/bin/oracle-upgrade.mjs +0 -21
  344. package/dist/bin/oracle.mjs +0 -76
  345. package/dist/chains.mjs +0 -1
  346. package/dist/cli/commands/auth.mjs +0 -16
  347. package/dist/cli/commands/bootstrap.mjs +0 -18
  348. package/dist/cli/commands/chain.mjs +0 -21
  349. package/dist/cli/commands/chat.mjs +0 -45
  350. package/dist/cli/commands/credential.mjs +0 -1
  351. package/dist/cli/commands/data-mcp.mjs +0 -2
  352. package/dist/cli/commands/data.mjs +0 -12
  353. package/dist/cli/commands/doctor.mjs +0 -5
  354. package/dist/cli/commands/equities.mjs +0 -15
  355. package/dist/cli/commands/farm.mjs +0 -59
  356. package/dist/cli/commands/follow.mjs +0 -28
  357. package/dist/cli/commands/gate.mjs +0 -13
  358. package/dist/cli/commands/harness.mjs +0 -15
  359. package/dist/cli/commands/help.mjs +0 -1
  360. package/dist/cli/commands/init.mjs +0 -3
  361. package/dist/cli/commands/mcp.mjs +0 -60
  362. package/dist/cli/commands/model.mjs +0 -54
  363. package/dist/cli/commands/plugins.mjs +0 -38
  364. package/dist/cli/commands/prepare.mjs +0 -2
  365. package/dist/cli/commands/public.mjs +0 -3
  366. package/dist/cli/commands/resolve.mjs +0 -23
  367. package/dist/cli/commands/route.mjs +0 -2
  368. package/dist/cli/commands/runner.mjs +0 -1
  369. package/dist/cli/commands/scan.mjs +0 -2
  370. package/dist/cli/commands/setup.mjs +0 -34
  371. package/dist/cli/commands/sign.mjs +0 -21
  372. package/dist/cli/commands/signer.mjs +0 -1
  373. package/dist/cli/commands/swap.mjs +0 -36
  374. package/dist/cli/commands/upgrade.mjs +0 -2
  375. package/dist/cli/commands/vault.mjs +0 -1
  376. package/dist/cli/commands/version.mjs +0 -2
  377. package/dist/data/desk-data.mjs +0 -55
  378. package/dist/data/names.mjs +0 -2
  379. package/dist/data/providers/farming.mjs +0 -2
  380. package/dist/equities/index.mjs +0 -1
  381. package/dist/index.mjs +0 -60
  382. package/dist/nft-gas-war-guard.mjs +0 -1
  383. package/dist/onboarding/harness-configs.mjs +0 -4
  384. package/dist/portfolio-risk.mjs +0 -1
  385. package/dist/prepare-envelope.mjs +0 -1
  386. package/dist/public-api/agent-grants.mjs +0 -3
  387. package/dist/public-control/policy-schema.mjs +0 -1
  388. package/dist/router/index.mjs +0 -2
  389. package/dist/scanner/index.mjs +0 -4
  390. package/dist/signals/index.mjs +0 -1
  391. package/dist/watch-preferences.mjs +0 -1
  392. /package/{dist/assets/profiles → profiles}/_template/SOUL.md +0 -0
  393. /package/{dist/assets/profiles → profiles}/_template/profile.json +0 -0
  394. /package/{dist/assets/profiles → profiles}/bitcoin-agent/SOUL.md +0 -0
  395. /package/{dist/assets/profiles → profiles}/bitcoin-agent/profile.json +0 -0
  396. /package/{dist/assets/profiles → profiles}/hyperliquid-agent/SOUL.md +0 -0
  397. /package/{dist/assets/profiles → profiles}/hyperliquid-agent/profile.json +0 -0
  398. /package/{dist/assets/profiles → profiles}/oracle/profile.json +0 -0
  399. /package/{dist/assets/profiles → profiles}/polymarket-agent/SOUL.md +0 -0
  400. /package/{dist/assets/profiles → profiles}/polymarket-agent/profile.json +0 -0
  401. /package/{dist/assets/profiles → profiles}/profile.schema.json +0 -0
  402. /package/{dist/assets/profiles → profiles}/protocol-builder/SOUL.md +0 -0
  403. /package/{dist/assets/profiles → profiles}/protocol-builder/profile.json +0 -0
  404. /package/{dist/assets/profiles → profiles}/robinhood-agent/SOUL.md +0 -0
  405. /package/{dist/assets/profiles → profiles}/robinhood-agent/profile.json +0 -0
  406. /package/{dist/assets/profiles → profiles}/solana-agent/SOUL.md +0 -0
  407. /package/{dist/assets/profiles → profiles}/solana-agent/profile.json +0 -0
  408. /package/{dist/assets/profiles → profiles}/stable-agent/SOUL.md +0 -0
  409. /package/{dist/assets/profiles → profiles}/stable-agent/profile.json +0 -0
  410. /package/{dist/assets/skills → skills}/balance/SKILL.md +0 -0
  411. /package/{dist/assets/skills → skills}/bitcoin-l1.md +0 -0
  412. /package/{dist/assets/skills → skills}/chain-defi-ecosystem-profiling.md +0 -0
  413. /package/{dist/assets/skills → skills}/evm-contract-research.md +0 -0
  414. /package/{dist/assets/skills → skills}/hyperliquid.md +0 -0
  415. /package/{dist/assets/skills → skills}/multichain-exec-desk.md +0 -0
  416. /package/{dist/assets/skills → skills}/oracle-action-semantics/SKILL.md +0 -0
  417. /package/{dist/assets/skills → skills}/oracle-best-execution/SKILL.md +0 -0
  418. /package/{dist/assets/skills → skills}/oracle-best-execution.md +0 -0
  419. /package/{dist/assets/skills → skills}/oracle-bitcoin/SKILL.md +0 -0
  420. /package/{dist/assets/skills → skills}/oracle-chain-graphs-telegram-cards/SKILL.md +0 -0
  421. /package/{dist/assets/skills → skills}/oracle-chat/SKILL.md +0 -0
  422. /package/{dist/assets/skills → skills}/oracle-chat/chain.SKILL.md +0 -0
  423. /package/{dist/assets/skills → skills}/oracle-chat/setup.SKILL.md +0 -0
  424. /package/{dist/assets/skills → skills}/oracle-circuit-breaker/SKILL.md +0 -0
  425. /package/{dist/assets/skills → skills}/oracle-contract-research/SKILL.md +0 -0
  426. /package/{dist/assets/skills → skills}/oracle-desk/SKILL.md +0 -0
  427. /package/{dist/assets/skills → skills}/oracle-desk.md +0 -0
  428. /package/{dist/assets/skills → skills}/oracle-dex-launch/SKILL.md +0 -0
  429. /package/{dist/assets/skills → skills}/oracle-equities/SKILL.md +0 -0
  430. /package/{dist/assets/skills → skills}/oracle-grants/SKILL.md +0 -0
  431. /package/{dist/assets/skills → skills}/oracle-hypercore-staking/SKILL.md +0 -0
  432. /package/{dist/assets/skills → skills}/oracle-hyperliquid/SKILL.md +0 -0
  433. /package/{dist/assets/skills → skills}/oracle-meme-token-sniper/SKILL.md +0 -0
  434. /package/{dist/assets/skills → skills}/oracle-multichain-nft-launch/SKILL.md +0 -0
  435. /package/{dist/assets/skills → skills}/oracle-multichain-token-launch/SKILL.md +0 -0
  436. /package/{dist/assets/skills → skills}/oracle-nft-gacha-launch/SKILL.md +0 -0
  437. /package/{dist/assets/skills → skills}/oracle-nft-mint-gas-war/SKILL.md +0 -0
  438. /package/{dist/assets/skills → skills}/oracle-polymarket/SKILL.md +0 -0
  439. /package/{dist/assets/skills → skills}/oracle-protocol-builder/SKILL.md +0 -0
  440. /package/{dist/assets/skills → skills}/oracle-protocol-security/SKILL.md +0 -0
  441. /package/{dist/assets/skills → skills}/oracle-public-product/SKILL.md +0 -0
  442. /package/{dist/assets/skills → skills}/oracle-receipts/SKILL.md +0 -0
  443. /package/{dist/assets/skills → skills}/oracle-receipts.md +0 -0
  444. /package/{dist/assets/skills → skills}/oracle-rfq-tokenized-assets/SKILL.md +0 -0
  445. /package/{dist/assets/skills → skills}/oracle-smart-wallet-scanner/SKILL.md +0 -0
  446. /package/{dist/assets/skills → skills}/oracle-solana/SKILL.md +0 -0
  447. /package/{dist/assets/skills → skills}/oracle-solana-nft/SKILL.md +0 -0
  448. /package/{dist/assets/skills → skills}/oracle-token-research/SKILL.md +0 -0
  449. /package/{dist/assets/skills → skills}/solana.md +0 -0
@@ -0,0 +1,81 @@
1
+ export const THEME = Object.freeze({
2
+ accent: "#B8F0FF",
3
+ prompt: "#B8F0FF",
4
+ banner_title: "#B8F0FF",
5
+ banner_accent: "#91C2D7",
6
+ ui_label: "#A5D9EB",
7
+ banner_text: "#EAF2F8",
8
+ status_bar_strong: "#EAF2F8",
9
+ banner_border: "#455867",
10
+ input_rule: "#455867",
11
+ session_border: "#455867",
12
+ banner_dim: "#60717F",
13
+ status_bar_dim: "#60717F",
14
+ status_bar_bg: "#11161B",
15
+ status_bar_text: "#91A2B1",
16
+ ok: "#7EE7B5",
17
+ error: "#FF7B7B",
18
+ warn: "#F0C674",
19
+ bad: "#FF9B71",
20
+ selection_bg: "#23313B",
21
+ });
22
+
23
+ export function hexToRgb(hex) {
24
+ if (typeof hex !== "string") return null;
25
+ const value = hex.startsWith("#") ? hex.slice(1) : hex;
26
+ if (!/^(?:[\da-f]{3}|[\da-f]{6})$/i.test(value)) return null;
27
+ const expanded = value.length === 3
28
+ ? [...value].map((character) => character.repeat(2)).join("")
29
+ : value;
30
+ return {
31
+ r: Number.parseInt(expanded.slice(0, 2), 16),
32
+ g: Number.parseInt(expanded.slice(2, 4), 16),
33
+ b: Number.parseInt(expanded.slice(4, 6), 16),
34
+ };
35
+ }
36
+
37
+ function colorSequence(code, hex, text) {
38
+ const rgb = hexToRgb(hex);
39
+ if (!rgb) return String(text);
40
+ return `\u001B[${code};2;${rgb.r};${rgb.g};${rgb.b}m${String(text)}\u001B[0m`;
41
+ }
42
+
43
+ export function createPalette({ color = true } = {}) {
44
+ const enabled = color && !Object.hasOwn(process.env, "NO_COLOR");
45
+ if (!enabled) {
46
+ return Object.freeze({
47
+ fg: (_hex, text) => String(text),
48
+ bg: (_hex, text) => String(text),
49
+ bold: (text) => String(text),
50
+ dim: (text) => String(text),
51
+ });
52
+ }
53
+ return Object.freeze({
54
+ fg: (hex, text) => colorSequence(38, hex, text),
55
+ bg: (hex, text) => colorSequence(48, hex, text),
56
+ bold: (text) => `\u001B[1m${String(text)}\u001B[0m`,
57
+ dim: (text) => `\u001B[2m${String(text)}\u001B[0m`,
58
+ });
59
+ }
60
+
61
+ const defaultPalette = createPalette();
62
+
63
+ export function fg(hex, text) {
64
+ return defaultPalette.fg(hex, text);
65
+ }
66
+
67
+ export function bg(hex, text) {
68
+ return defaultPalette.bg(hex, text);
69
+ }
70
+
71
+ export function bold(text) {
72
+ return defaultPalette.bold(text);
73
+ }
74
+
75
+ export function dim(text) {
76
+ return defaultPalette.dim(text);
77
+ }
78
+
79
+ export function stripAnsi(text) {
80
+ return String(text).replace(/\u001B\[[0-9;]*m/g, "");
81
+ }
@@ -0,0 +1,146 @@
1
+ import { createHmac, timingSafeEqual } from "node:crypto";
2
+ import { Interface, isAddress } from "ethers";
3
+ import { routeCalldataHash } from "./route-attestation.mjs";
4
+ import { resolveAttestationSecret } from "./attestation-secret.mjs";
5
+ import { assertFreshWindow } from "./fresh-window.mjs";
6
+
7
+ const DEFAULT_VAULT_ATTESTATION_TTL_MS = 20_000;
8
+ const ERC20 = new Interface(["function approve(address spender,uint256 amount) returns (bool)"]);
9
+
10
+ function canonicalJson(value) {
11
+ if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
12
+ if (value && typeof value === "object") {
13
+ return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonicalJson(value[k])}`).join(",")}}`;
14
+ }
15
+ return JSON.stringify(value);
16
+ }
17
+
18
+ function normalAddress(value, label) {
19
+ const text = String(value || "").trim();
20
+ if (!isAddress(text)) throw new Error(`${label} must be an address`);
21
+ return text.toLowerCase();
22
+ }
23
+
24
+ function amountString(value, label = "vault amount") {
25
+ try {
26
+ const n = BigInt(String(value));
27
+ if (n <= 0n) throw new Error("nonpositive");
28
+ return n.toString();
29
+ } catch {
30
+ throw new Error(`${label} must be a positive integer string`);
31
+ }
32
+ }
33
+
34
+ function decodeApproveCalldata(data) {
35
+ const hex = String(data || "").toLowerCase();
36
+ if (!hex.startsWith("0x095ea7b3")) throw new Error("approval calldata required");
37
+ const [spender, amount] = ERC20.decodeFunctionData("approve", hex);
38
+ return { spender: normalAddress(spender, "approval spender"), amount: amountString(amount, "approval amount") };
39
+ }
40
+
41
+ function hmac(secret, payload) {
42
+ return `0x${createHmac("sha256", String(secret)).update(payload).digest("hex")}`;
43
+ }
44
+
45
+ function sameSignature(a, b) {
46
+ const left = Buffer.from(String(a || "").replace(/^0x/, ""), "hex");
47
+ const right = Buffer.from(String(b || "").replace(/^0x/, ""), "hex");
48
+ return left.length === right.length && left.length > 0 && timingSafeEqual(left, right);
49
+ }
50
+
51
+ function attestationSecret(secret) {
52
+ return resolveAttestationSecret(
53
+ secret,
54
+ "ORACLE_ROUTE_ATTESTATION_SECRET",
55
+ "MAD_ROUTE_ATTESTATION_SECRET",
56
+ );
57
+ }
58
+
59
+ function unsigned(attestation) {
60
+ const { signature: _signature, ...payload } = attestation;
61
+ return payload;
62
+ }
63
+
64
+ export function createVaultAttestation({
65
+ provider = "morpho",
66
+ chainId,
67
+ action,
68
+ vault,
69
+ asset,
70
+ owner,
71
+ receiver,
72
+ amount,
73
+ data,
74
+ calldataHash,
75
+ minSharesOut,
76
+ maxSharesIn,
77
+ totalAssetsUsd,
78
+ nowMs = Date.now(),
79
+ ttlMs = DEFAULT_VAULT_ATTESTATION_TTL_MS,
80
+ secret,
81
+ } = {}) {
82
+ const normalizedAction = String(action || "").trim().toLowerCase();
83
+ if (!["deposit", "withdraw"].includes(normalizedAction)) throw new Error("vault attestation action must be deposit or withdraw");
84
+ const attestation = {
85
+ mode: "vault-attestation",
86
+ version: 1,
87
+ provider: String(provider || "").trim() || "morpho",
88
+ chainId: Number(chainId),
89
+ action: normalizedAction,
90
+ vault: normalAddress(vault, "vault"),
91
+ asset: normalAddress(asset, "vault asset"),
92
+ owner: normalAddress(owner, "vault owner"),
93
+ receiver: normalAddress(receiver || owner, "vault receiver"),
94
+ amount: amountString(amount),
95
+ calldataHash: data ? routeCalldataHash(data) : calldataHash,
96
+ value: "0",
97
+ issuedAtMs: Number(nowMs),
98
+ expiresAtMs: Number(nowMs) + Number(ttlMs),
99
+ };
100
+ if (!Number.isFinite(attestation.chainId)) throw new Error("vault attestation chainId required");
101
+ if (minSharesOut != null) attestation.minSharesOut = amountString(minSharesOut, "minSharesOut");
102
+ if (maxSharesIn != null) attestation.maxSharesIn = amountString(maxSharesIn, "maxSharesIn");
103
+ if (totalAssetsUsd != null) attestation.totalAssetsUsd = Number(totalAssetsUsd);
104
+ const payload = canonicalJson(attestation);
105
+ return { ...attestation, signature: hmac(attestationSecret(secret), payload) };
106
+ }
107
+
108
+ export function assertVaultAttestation(attestation, tx = {}, { chainId, nowMs = Date.now(), secret } = {}) {
109
+ // Time is a security parameter: an unusable clock must fail CLOSED,
110
+ // otherwise NaN/null/-Infinity silently makes this attestation eternal.
111
+ assertFreshWindow(attestation || {}, nowMs, "vault attestation");
112
+ if (!attestation || attestation.mode !== "vault-attestation") throw new Error("vault attestation required");
113
+ if (Number(attestation.expiresAtMs) <= Number(nowMs)) throw new Error("vault attestation expired");
114
+ const txChainId = Number(chainId ?? tx.chainId);
115
+ if (Number(attestation.chainId) !== txChainId) throw new Error("vault attestation chain mismatch");
116
+ const to = normalAddress(tx.to, "vault tx.to");
117
+ if (normalAddress(attestation.vault, "vault") !== to) throw new Error("vault attestation destination mismatch");
118
+ if (tx.from && normalAddress(attestation.owner, "vault owner") !== normalAddress(tx.from, "vault tx.from")) {
119
+ throw new Error("vault attestation owner mismatch");
120
+ }
121
+ const value = tx.value == null ? "0" : String(BigInt(String(tx.value).startsWith("0x") ? String(tx.value) : String(tx.value)));
122
+ if (value !== "0") throw new Error("vault attestation value mismatch");
123
+ if (attestation.calldataHash !== routeCalldataHash(tx.data || "0x")) throw new Error("vault attestation calldata mismatch");
124
+ const expected = hmac(attestationSecret(secret), canonicalJson(unsigned(attestation)));
125
+ if (!sameSignature(attestation.signature, expected)) throw new Error("vault attestation signature mismatch");
126
+ return true;
127
+ }
128
+
129
+ export function assertVaultApprovalAttestation(attestation, tx = {}, guard = {}, { chainId, nowMs = Date.now(), secret } = {}) {
130
+ if (!attestation || attestation.mode !== "vault-attestation") throw new Error("vault attestation required");
131
+ if (String(attestation.action) !== "deposit") throw new Error("vault approval requires deposit attestation");
132
+ assertFreshWindow(attestation, nowMs, "vault approval attestation");
133
+ if (Number(attestation.expiresAtMs) <= Number(nowMs)) throw new Error("vault attestation expired");
134
+ const expected = hmac(attestationSecret(secret), canonicalJson(unsigned(attestation)));
135
+ if (!sameSignature(attestation.signature, expected)) throw new Error("vault attestation signature mismatch");
136
+ const txChainId = Number(tx.chainId ?? chainId);
137
+ if (Number(attestation.chainId) !== txChainId) throw new Error("vault attestation chain mismatch");
138
+ const decoded = decodeApproveCalldata(tx.data);
139
+ if (normalAddress(attestation.asset, "vault asset") !== normalAddress(tx.to, "approval token")) throw new Error("vault attestation asset mismatch");
140
+ if (normalAddress(attestation.vault, "vault") !== decoded.spender) throw new Error("vault attestation spender mismatch");
141
+ if (String(attestation.amount) !== decoded.amount || String(guard.amount) !== decoded.amount) {
142
+ throw new Error("vault attestation amount mismatch");
143
+ }
144
+ if (guard.provider && String(guard.provider) !== String(attestation.provider)) throw new Error("vault attestation provider mismatch");
145
+ return true;
146
+ }
package/src/venues.mjs ADDED
@@ -0,0 +1,206 @@
1
+ // Per-chain venue registry — the curated, code-reviewed set of contracts the
2
+ // agent wallet is allowed to transact with on each chain. This is how the dest
3
+ // allowlist "just works when you go to a new chain" WITHOUT the footgun of
4
+ // auto-trusting whatever address a tx points at: venues come from THIS vetted
5
+ // map, never from the transaction itself.
6
+ //
7
+ // The policy layer (exec-policy.mjs) unions three sources for the effective
8
+ // destination allowlist on a given chain:
9
+ // 1. MAD_DEST_ALLOWLIST (env; global, applies to every chain)
10
+ // 2. VENUES[chainId] (this file; per-chain known-good contracts)
11
+ // 3. CROSS_CHAIN_VENUES (this file; same address on all chains, e.g. Permit2)
12
+ //
13
+ // To enable trading on a new chain: add its router/quoter/venue addresses here
14
+ // in ONE reviewed edit. After that, trades on that chain pass the allowlist with
15
+ // no per-trade friction. Every address is lowercased; verify each before adding.
16
+
17
+ // Uniswap Permit2 — CREATE2-deployed to the SAME address on every EVM chain.
18
+ // Verified canonical. Safe as a cross-chain constant.
19
+ export const CROSS_CHAIN_VENUES = [
20
+ "0x000000000022d473030f116ddee9f6b43ac78ba3", // Permit2
21
+ ];
22
+
23
+ // Per-chain vetted venues. Only entries verified against a trusted source.
24
+ // Empty arrays are intentional: that chain has no approved venues yet, so a
25
+ // value/contract tx there is REFUSED until you add its real venues here.
26
+ export const VENUES = {
27
+ // Robinhood Chain — verified from rhbot server/swap.js SWAP_CONFIG (2026-07-22).
28
+ 4663: [
29
+ "0xcaf681a66d020601342297493863e78c959e5cb2", // router
30
+ "0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7", // quoter
31
+ "0x1f7d7550b1b028f7571e69a784071f0205fd2efa", // factory
32
+ "0x0bd7d308f8e1639fab988df18a8011f41eacad73", // weth
33
+ "0x5fc5360d0400a0fd4f2af552add042d716f1d168", // usdg
34
+ "0xb477751b76cf82d00a686a1232f5fcd772414af3", // LI.FI diamond on RH (verified via li.quest /chains diamondAddress, 2026-07-23)
35
+ "0xff5cb29241f002ffed2eaa224e3e996d24a6e8d1", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
36
+ ],
37
+
38
+ // Base (8453) — Uniswap v3. Verified 2026-07-22 against official Uniswap
39
+ // deployments docs (developers.uniswap.org) + on-chain eth_getCode.
40
+ 8453: [
41
+ "0x2626664c2603336e57b271c5c0b26f421741e481", // SwapRouter02
42
+ "0x6ff5693b99212da76ad316178a184ab56d299b43", // UniversalRouter
43
+ "0x3d4e44eb1374240ce5f1b871ab261cd16335b76a", // QuoterV2
44
+ "0x33128a8fc17869897dce68ed026d694621f6fdfd", // UniswapV3Factory
45
+ "0x4200000000000000000000000000000000000006", // WETH
46
+ "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", // USDC
47
+ "0xbe6d8f0d05cc4be24d5167a3ef062215be6d18a5", // Aerodrome Slipstream SwapRouter (slipstream README + eth_getCode + live quote, 2026-07-24)
48
+ "0x254cf9e1e6e233aa1ac962cb9b05b2cfeaae15b0", // Aerodrome Slipstream QuoterV2 (slipstream README + eth_getCode + live quote, 2026-07-24)
49
+ "0x5e7bb104d84c7cb9b682aac2f3d509f5f406809a", // Aerodrome Slipstream PoolFactory (slipstream README + eth_getCode, 2026-07-24)
50
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI canonical diamond (verified via li.quest /chains diamondAddress, 2026-07-23)
51
+ "0x888888888889758f76e7103c6cbf23abbf58f946", // Pendle Router (official deployments + eth_getCode, 2026-07-23)
52
+ "0x3f170631ed9821ca51a59d996ab095162438dc10", // Balancer v3 Router (official deployments + eth_getCode, 2026-07-23)
53
+ "0x4f37a9d177470499a2dd084621020b023fcffc1f", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
54
+ "0xc92e8bdf79f0507f65a392b0ab4667716bfe0110", // CoW VaultRelayer (CoW contracts networks.json v1.8.0, 2026-07-24)
55
+ ],
56
+
57
+ // Arbitrum One (42161) — Uniswap v3. Verified 2026-07-22 against arbiscan
58
+ // (Uniswap V3: Router 2 label) + swap-router-contracts release + on-chain code.
59
+ 42161: [
60
+ "0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45", // SwapRouter02
61
+ "0x61ffe014ba17989e743c5f6cb21bf9697530b21e", // QuoterV2
62
+ "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", // WETH
63
+ "0xaf88d065e77c8cc2239327c5edb3a432268e5831", // USDC (native)
64
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI canonical diamond (verified via li.quest, 2026-07-23) — Leg2 Arb->Stable bridge
65
+ "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9", // USDT0 on Arbitrum (ERC20 approve target for Leg2 bridge)
66
+ "0x888888888889758f76e7103c6cbf23abbf58f946", // Pendle Router (official deployments + eth_getCode, 2026-07-23)
67
+ "0xeaedc32a51c510d35ebc11088fd5ff2b47aacf2e", // Balancer v3 Router (official deployments + eth_getCode, 2026-07-23)
68
+ "0x2191718cd32d02b8e60badffea33e4b5dd9a0a0d", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
69
+ "0xc92e8bdf79f0507f65a392b0ab4667716bfe0110", // CoW VaultRelayer (CoW contracts networks.json v1.8.0, 2026-07-24)
70
+ "0x1c3fa76e6e1088bce750f23a5bfcffa1efef6a41", // GMX v2 ExchangeRouter (gmx-synthetics deployments/arbitrum, 2026-07-24)
71
+ "0x7452c558d45f8afc8c83dae62c3f8a5be19c71f6", // GMX v2 Router approval spender (gmx-synthetics deployments/arbitrum, 2026-07-24)
72
+ ],
73
+
74
+ // Add verified venues per chain before trading there. Left empty on purpose:
75
+ // an empty chain refuses non-allowlisted destinations (fail-closed by design).
76
+ 1: [
77
+ "0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45", // Uniswap SwapRouter02
78
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI canonical diamond (verified via li.quest, 2026-07-23) — ETH->Arb gas bridge
79
+ "0x4cd00e387622c35bddb9b4c962c136462338bc31", // Relay Depository (api.relay.link quote target + Etherscan label, 2026-07-23)
80
+ "0x6a000f20005980200259b80c5102003040001068", // ParaSwap/Velora Augustus V6.2 (Velora docs + priceRoute target, 2026-07-23)
81
+ "0xae563e3f8219521950555f5962419c8919758ea2", // Balancer v3 Router (official deployments + eth_getCode, 2026-07-23)
82
+ "0x45312ea0eff7e09c83cbe249fa1d7598c4c8cd4e", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
83
+ "0xc92e8bdf79f0507f65a392b0ab4667716bfe0110", // CoW VaultRelayer (CoW contracts networks.json v1.8.0, 2026-07-24)
84
+ ], // Ethereum
85
+ 137: [
86
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
87
+ "0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
88
+ ], // Polygon
89
+ 10: [
90
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
91
+ "0xe2fa4e1d17725e72dcdafe943ecf45df4b9e285b", // Balancer v3 Router (official deployments + eth_getCode, 2026-07-23)
92
+ "0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
93
+ ], // Optimism
94
+ 56: [
95
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
96
+ "0xa72c85c258a81761433b4e8da60505fe3dd551cc", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
97
+ ], // BSC
98
+ 43114: [
99
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
100
+ "0xf39ca6ede9bf7820a952b52f3c94af526bab9015", // Balancer v3 Router (official deployments + eth_getCode, 2026-07-23)
101
+ "0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
102
+ "0x8f550e53dfe96c055d5bdb267c21f268fcaf63b2", // GMX v2 ExchangeRouter (gmx-synthetics deployments/avalanche, 2026-07-24)
103
+ "0x820f5ffc5b525cd4d88cd91acf2c28f16530cc68", // GMX v2 Router approval spender (gmx-synthetics deployments/avalanche, 2026-07-24)
104
+ ], // Avalanche
105
+ 999: [
106
+ "0x0a0758d937d1059c356d4714e57f5df0239bce1a", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
107
+ "0xd2002373543ce3527023c75e7518c274a51ce712", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
108
+ ], // HyperEVM
109
+ 2741: [
110
+ "0x4f8c9056bb8a3616693a76922fa35d53c056e5b3", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
111
+ ], // Abstract
112
+ 988: [
113
+ "0x026f252016a7c47cdef1f05a3fc9e20c92a49c37", // LI.FI diamond (li.quest /chains + eth_getCode, 2026-07-23)
114
+ "0xff5cb29241f002ffed2eaa224e3e996d24a6e8d1", // Curve RouterNG (official docs + eth_getCode, 2026-07-24)
115
+ "0x817997ca8394e26cce3de3a076a4889b27dbf9de", // WgUSDT (wrapped native USDT0, WETH-style deposit/transfer)
116
+ "0x3dea4be5615974f31624404ef288ba3b36dfeb83", // FEFER/WgUSDT UniV2 pair (raw swap target, verified on-chain)
117
+ "0xeaf7ac0fdf150cdd89340fb762d83848de6a7b83", // FEFER token (approve/transfer for sell-back)
118
+ "0x779ded0c9e1022225f8e0630b35a9b54be713736", // USDT0 canonical (native mirror)
119
+ "0xbc6f7725f08232c151b528bdfcaaf89993ca86ee", // Atomic FEFER raw-pair buyer; deployed by executor, owner verified on-chain (2026-07-23)
120
+ ], // Stable
121
+ };
122
+
123
+ // Destinations that can move value according to a market quote. Calldata sent
124
+ // to these contracts must carry a fresh bounded auto-slippage guard through the
125
+ // signer boundary. Tokens, wrappers, quoters, factories, and Permit2 are
126
+ // intentionally excluded because approvals/deposits are not swaps.
127
+ export const SWAP_VENUES = {
128
+ 1: [
129
+ "0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45", // SwapRouter02
130
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
131
+ "0x4cd00e387622c35bddb9b4c962c136462338bc31", // Relay Depository
132
+ "0x6a000f20005980200259b80c5102003040001068", // ParaSwap/Velora Augustus V6.2
133
+ "0xae563e3f8219521950555f5962419c8919758ea2", // Balancer v3 Router
134
+ "0x45312ea0eff7e09c83cbe249fa1d7598c4c8cd4e", // Curve RouterNG
135
+ ],
136
+ 10: [
137
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
138
+ "0xe2fa4e1d17725e72dcdafe943ecf45df4b9e285b", // Balancer v3 Router
139
+ "0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG
140
+ ],
141
+ 56: [
142
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
143
+ "0xa72c85c258a81761433b4e8da60505fe3dd551cc", // Curve RouterNG
144
+ ],
145
+ 137: [
146
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
147
+ "0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG
148
+ ],
149
+ 988: [
150
+ "0x026f252016a7c47cdef1f05a3fc9e20c92a49c37", // LI.FI diamond
151
+ "0xff5cb29241f002ffed2eaa224e3e996d24a6e8d1", // Curve RouterNG
152
+ "0x3dea4be5615974f31624404ef288ba3b36dfeb83", // verified raw V2 pair
153
+ "0xbc6f7725f08232c151b528bdfcaaf89993ca86ee", // atomic raw-pair helper
154
+ ],
155
+ 999: [
156
+ "0x0a0758d937d1059c356d4714e57f5df0239bce1a", // LI.FI diamond
157
+ "0xd2002373543ce3527023c75e7518c274a51ce712", // Curve RouterNG
158
+ ],
159
+ 2741: [
160
+ "0x4f8c9056bb8a3616693a76922fa35d53c056e5b3", // LI.FI diamond
161
+ ],
162
+ 4663: [
163
+ "0xcaf681a66d020601342297493863e78c959e5cb2", // SwapRouter02
164
+ "0xb477751b76cf82d00a686a1232f5fcd772414af3", // LI.FI diamond
165
+ "0xff5cb29241f002ffed2eaa224e3e996d24a6e8d1", // Curve RouterNG
166
+ ],
167
+ 8453: [
168
+ "0x2626664c2603336e57b271c5c0b26f421741e481", // SwapRouter02
169
+ "0x6ff5693b99212da76ad316178a184ab56d299b43", // UniversalRouter
170
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
171
+ "0x888888888889758f76e7103c6cbf23abbf58f946", // Pendle Router
172
+ "0x3f170631ed9821ca51a59d996ab095162438dc10", // Balancer v3 Router
173
+ "0x4f37a9d177470499a2dd084621020b023fcffc1f", // Curve RouterNG
174
+ ],
175
+ 42161: [
176
+ "0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45", // SwapRouter02
177
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
178
+ "0x888888888889758f76e7103c6cbf23abbf58f946", // Pendle Router
179
+ "0xeaedc32a51c510d35ebc11088fd5ff2b47aacf2e", // Balancer v3 Router
180
+ "0x2191718cd32d02b8e60badffea33e4b5dd9a0a0d", // Curve RouterNG
181
+ ],
182
+ 43114: [
183
+ "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae", // LI.FI diamond
184
+ "0xf39ca6ede9bf7820a952b52f3c94af526bab9015", // Balancer v3 Router
185
+ "0x0dcded3545d565ba3b19e683431381007245d983", // Curve RouterNG
186
+ ],
187
+ };
188
+
189
+ export function isSwapVenue(chainId, address) {
190
+ const target = String(address || "").trim().toLowerCase();
191
+ if (!target) return false;
192
+ return (SWAP_VENUES[Number(chainId)] || []).includes(target);
193
+ }
194
+
195
+ /**
196
+ * Known-good destinations for a chain: the union of that chain's vetted venues
197
+ * and the cross-chain constants. Returns a Set of lowercased addresses.
198
+ * @param {number} chainId
199
+ * @returns {Set<string>}
200
+ */
201
+ export function venuesFor(chainId) {
202
+ const perChain = VENUES[Number(chainId)] || [];
203
+ return new Set(
204
+ [...perChain, ...CROSS_CHAIN_VENUES].map((a) => String(a).trim().toLowerCase()).filter(Boolean)
205
+ );
206
+ }
@@ -0,0 +1,85 @@
1
+ /** Notification classes supported by Oracle watches. */
2
+ export const WATCH_CATEGORIES = Object.freeze([
3
+ 'price',
4
+ 'wallet',
5
+ 'risk',
6
+ 'execution',
7
+ 'security',
8
+ 'nft',
9
+ 'governance',
10
+ 'system',
11
+ ]);
12
+
13
+ const CATEGORY_SET = new Set(WATCH_CATEGORIES);
14
+
15
+ function assertCategory(category) {
16
+ if (!CATEGORY_SET.has(category)) {
17
+ throw new TypeError(`Unknown watch category: ${String(category)}`);
18
+ }
19
+ return category;
20
+ }
21
+
22
+ function subscribedCategories(preferences = {}) {
23
+ const categories = preferences.subscribedCategories ?? [];
24
+ if (!Array.isArray(categories)) {
25
+ throw new TypeError('subscribedCategories must be an array');
26
+ }
27
+ return categories;
28
+ }
29
+
30
+ /** New users receive no category notifications until they explicitly opt in. */
31
+ export function defaultPreferences() {
32
+ return { subscribedCategories: [] };
33
+ }
34
+
35
+ /** Return a new preference value with exactly one notification class enabled. */
36
+ export function subscribe(preferences, category) {
37
+ assertCategory(category);
38
+ const current = subscribedCategories(preferences);
39
+ if (current.includes(category)) return { ...preferences, subscribedCategories: [...current] };
40
+ return { ...preferences, subscribedCategories: [...current, category] };
41
+ }
42
+
43
+ /** Return a new preference value with the requested notification class disabled. */
44
+ export function unsubscribe(preferences, category) {
45
+ assertCategory(category);
46
+ const current = subscribedCategories(preferences);
47
+ return {
48
+ ...preferences,
49
+ subscribedCategories: current.filter((candidate) => candidate !== category),
50
+ };
51
+ }
52
+
53
+ /** Create a direct watch. Notifications are opt-in independently for every watch. */
54
+ export function createWatch({ category, notify = false, ...watch } = {}) {
55
+ assertCategory(category);
56
+ if (typeof notify !== 'boolean') throw new TypeError('watch notify must be a boolean');
57
+ return { ...watch, category, notify };
58
+ }
59
+
60
+ function isMatchingNotifyingWatch(alert, watch) {
61
+ if (!watch || watch.notify !== true || watch.category !== alert.category) return false;
62
+ if (alert.watchId !== undefined && watch.id !== alert.watchId) return false;
63
+ return true;
64
+ }
65
+
66
+ /**
67
+ * Decide whether an alert may be delivered. This function only describes policy;
68
+ * it performs no scheduling or delivery.
69
+ */
70
+ export function evaluateAlert(alert, preferences = defaultPreferences(), watch) {
71
+ if (!alert || typeof alert !== 'object') throw new TypeError('alert must be an object');
72
+ assertCategory(alert.category);
73
+
74
+ if (subscribedCategories(preferences).includes(alert.category)) {
75
+ return { deliver: true, reason: 'category-subscribed' };
76
+ }
77
+ if (isMatchingNotifyingWatch(alert, watch)) {
78
+ return { deliver: true, reason: 'watch-opt-in' };
79
+ }
80
+ return { deliver: false, reason: 'not-subscribed' };
81
+ }
82
+
83
+ export function shouldDeliverAlert(alert, preferences, watch) {
84
+ return evaluateAlert(alert, preferences, watch).deliver;
85
+ }
@@ -1 +0,0 @@
1
- import{createHash as m}from"node:crypto";import{wordlists as g}from"ethers";var A=1,E=new Set(["privatekey","privkey","secretkey","seedphrase","seed","mnemonic","passphrase","password","keystore","keymaterial","wif","xprv","xpriv","bearer","authorization","signature","apikey","credential"]),x=[/\b[5KL][1-9A-HJ-NP-Za-km-z]{50,51}\b/,/\bxprv[0-9A-Za-z]{50,}\b/],$=new Set([12,15,18,21,24]);function S(e){let t=String(e).trim().toLowerCase().split(/\s+/).filter(Boolean);return $.has(t.length)&&t.every(r=>g.en.getWordIndex(r)>=0)}var H=/^\s*(?:0x)?[0-9a-fA-F]{64}\s*$/,O=/(hash|digest|root|salt|nonce|proof|commitment|sig|id)(?:e?s)?$/i,j=new Set(["calldata","data","publickey","pubkey","message","payload","input","extradata"]);function T(e){let t=b(e);return j.has(t)||O.test(t)}var f=class extends Error{constructor(t){super(`action receipt refused: secret-bearing field at ${t}`),this.name="ActionReceiptSecretError",this.code="ACTION_RECEIPT_SECRET"}};function b(e){return String(e).replace(/[^a-z0-9]/gi,"").toLowerCase()}function C(e){let t=b(e);return[...E].some(r=>t.includes(r))}function _(e,t,r){if(typeof t=="string"){if(x.some(o=>o.test(t))||S(t))throw new f(r);if(H.test(t)&&!T(e))throw new f(r)}}function a(e,t="$",r=""){if(e==null||typeof e=="boolean")return e;if(typeof e=="string")return _(r,e,t),e;if(typeof e=="number"){if(!Number.isFinite(e))throw new TypeError(`action receipt: non-finite number at ${t}`);return e}if(typeof e=="bigint")return e.toString();if(Array.isArray(e))return e.map((n,i)=>a(n,`${t}[${i}]`,r));if(typeof e!="object"||Object.getPrototypeOf(e)!==Object.prototype)throw new TypeError(`action receipt: JSON-like value required at ${t}`);let o={};for(let n of Object.keys(e).sort()){let i=`${t}.${n}`;if(C(n))throw new f(i);e[n]!==void 0&&(o[n]=a(e[n],i,n))}return o}function L(e){return a(e)}function d(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(d).join(",")}]`:`{${Object.keys(e).map(t=>`${JSON.stringify(t)}:${d(e[t])}`).join(",")}}`}function R(e){return d(a(e))}function k(e){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("action receipt: object required");let{receiptId:t,summary:r,...o}=e;return m("sha256").update(R(o)).digest("hex")}function c(e,...t){for(let r of t)if(e[r]!==void 0)return e[r]}function s(e,t,r){let o=c(e,...t);if(o==null)throw new TypeError(`action receipt: ${r} required`);return o}function I(e){let t=c(e,"balances","balanceChanges"),r=c(e,"beforeBalances","balancesBefore","before"),o=c(e,"afterBalances","balancesAfter","after");return t!==void 0?{balances:t}:r===void 0&&o===void 0?{}:{balances:{...r===void 0?{}:{before:r},...o===void 0?{}:{after:o}}}}function N(e={}){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("action receipt: input object required");a(e);let t=c(e,"txHash","transactionHash"),r=c(e,"phase","stage","resultType")??(t==null?"prepare":"execute");if(r!=="prepare"&&r!=="execute")throw new TypeError('action receipt: phase must be "prepare" or "execute"');let o={receiptVersion:A,phase:r,intent:s(e,["intent"],"intent"),route:s(e,["route"],"route"),decodedAction:s(e,["decodedAction","action"],"decodedAction"),policyChecks:s(e,["policyChecks","checks"],"policyChecks"),allowlistHits:s(e,["allowlistHits","allowlistMatches"],"allowlistHits"),prepareHash:s(e,["prepareHash"],"prepareHash"),...t==null?{}:{txHash:t},...I(e)},n=a(o);return Object.freeze({...n,receiptId:k(n)})}var q=N;function u(e,t=[]){if(typeof e=="string"||typeof e=="number")return String(e);for(let r of t)if(e?.[r]!=null)return String(e[r]);return"recorded"}function y(e){if(typeof e=="boolean")return e;if(e&&typeof e=="object"){if(typeof e.ok=="boolean")return e.ok;if(typeof e.allowed=="boolean")return e.allowed;if(typeof e.passed=="boolean")return e.passed}return null}function z(e){if(!e||typeof e!="object")throw new TypeError("action receipt: object required");let t=u(e.decodedAction,["type","action","method","name"]),r=u(e.route,["name","provider","venue","id"]),o=Array.isArray(e.policyChecks)?e.policyChecks:Object.values(e.policyChecks||{}),n=o.filter(l=>y(l)===!0).length,i=o.filter(l=>y(l)===!1).length,p=Array.isArray(e.allowlistHits)?e.allowlistHits.length:Object.keys(e.allowlistHits||{}).length,h=e.txHash==null?"no transaction hash":`tx ${e.txHash}`,w=e.balances==null?"balances not provided":"before/after balances recorded";return`${e.phase} ${t} via ${r}; policy ${n} passed, ${i} failed; ${p} allowlist hit${p===1?"":"s"}; ${h}; ${w}; receipt ${e.receiptId}`}var F=z;export{A as ACTION_RECEIPT_VERSION,f as ActionReceiptSecretError,L as assertNoReceiptSecrets,R as canonicalReceiptJson,k as computeReceiptId,q as createActionReceipt,F as formatActionReceipt,N as normalizeActionReceipt,z as summarizeActionReceipt};
@@ -1 +0,0 @@
1
- var o=Object.freeze({ALERT_ONLY:"alert_only",EXECUTE:"execute"}),i=new Set(["watch","watch this","ping","ping me","alert","notify"]),r=new Set(["watching","armed"]);function a(t){if(typeof t!="string"||!t.trim())throw new TypeError("explicit action verb required");let e=t.trim().toLowerCase().replace(/\s+/g," ");if(i.has(e))return o.ALERT_ONLY;if(e==="arm")return o.EXECUTE;throw new TypeError(`unsupported action verb: ${e}`)}function c(t={}){let{verb:e,...n}=t;return{...n,active:!0,actionMode:a(e)}}function u(t){if(!t||typeof t!="object"||typeof t.active!="boolean")throw new TypeError("active must be boolean");if(!Object.values(o).includes(t.actionMode))throw new TypeError("actionMode must be alert_only or execute");return t}function E(t){return t?.active===!0&&t?.actionMode===o.ALERT_ONLY}function s(t){return t?.active===!0&&t?.actionMode===o.EXECUTE}function p(t={}){if(t.actionMode!==void 0&&t.actionMode!==o.ALERT_ONLY)throw new TypeError("non-alert record cannot enter alert-only watch migration");let e=typeof t.active=="boolean"?t.active:r.has(String(t.status||"").toLowerCase());return{...t,active:e,actionMode:o.ALERT_ONLY}}export{o as ACTION_MODES,a as actionModeForVerb,u as assertActionRecord,c as createActionRecord,E as isActiveAlert,s as isActiveExecution,p as migrateLegacyWatchRecord};
@@ -1,2 +0,0 @@
1
- import c from"node:fs";import l from"node:path";import{homedir as m}from"node:os";import{join as p}from"node:path";var k=process.env.ORACLE_PUBLIC_DESKTOP==="1",S=k?process.env.ORACLE_CONFIG_DIR||p(m(),".config","oracle"):p(m(),".config","oracle"),z=k?S:p(m(),".config","mad-desk");function A(e,r,t=""){let o=process.env[e];if(o!=null&&String(o).trim()!=="")return o;let s=r?process.env[r]:void 0;return s!=null&&String(s).trim()!==""?s:t}var E=/^0x[0-9a-fA-F]{40}$/,x=new Set(["privatekey","private_key","secret","seed","mnemonic","passphrase","signature","keystore"]),D=["privatekey","privkey","secretkey","secret","seedphrase","seed","mnemonic","passphrase","password","keystore","keymaterial","signature","wif","xprv","xpriv","apikey","bearer","credential"],I=[/\b[5KL][1-9A-HJ-NP-Za-km-z]{50,51}\b/,/\bxprv[0-9A-Za-z]{50,}\b/,/\b(?:[a-z]{3,8}\s+){11,}[a-z]{3,8}\b/i],L=/^\s*(?:0x)?[0-9a-fA-F]{64}\s*$/;function y(e){return String(e).toLowerCase().replace(/[^a-z0-9]/g,"")}function R(e,r){let t=y(e);if(x.has(String(e).toLowerCase())||D.some(o=>t.includes(o)))throw new Error(`address-book: ${r} is forbidden; the book stores labels, never key material`)}function N(e,r){if(typeof e=="string"&&(I.some(t=>t.test(e))||L.test(e)))throw new Error(`address-book: ${r} looks like key material; the book stores labels, never key material`)}function C(){let e=A("ORACLE_ADDRESS_BOOK","MAD_ADDRESS_BOOK","");if(e)return l.resolve(e);let r=A("ORACLE_CONFIG_DIR","MAD_CONFIG_DIR",S);return l.join(r,"address-book.json")}function b(e,r="field"){if(Array.isArray(e)){e.forEach((t,o)=>b(t,`${r}[${o}]`));return}if(!e||typeof e!="object"){N(e,r);return}for(let[t,o]of Object.entries(e))R(t,t),b(o,t)}function h(e){let r=String(e||"").trim();if(!E.test(r))throw new Error("address-book: address must be 0x + 40 hex characters");return r.toLowerCase()}function a(e,r){return e==null||e===""?null:String(e).slice(0,r)}function g(){return{version:1,updatedAt:null,entries:[]}}function _(e){return{address:String(e.address).toLowerCase(),label:a(e.label,80)||"unknown",who:a(e.who,120),role:a(e.role,40),chainIds:Array.isArray(e.chainIds)?e.chainIds.map(Number).filter(Number.isFinite):[],notes:a(e.notes,500),source:a(e.source,80),firstSeenAt:e.firstSeenAt||null,lastSeenAt:e.lastSeenAt||null}}function d(){try{let e=JSON.parse(c.readFileSync(C(),"utf8"));if(!e||typeof e!="object")return g();let r=Array.isArray(e.entries)?e.entries:[];return{version:1,updatedAt:e.updatedAt||null,entries:r.filter(t=>t&&typeof t=="object"&&E.test(String(t.address||""))).map(_)}}catch{return g()}}function O(e){let r=C();c.mkdirSync(l.dirname(r),{recursive:!0,mode:448});let t={...e,version:1,updatedAt:new Date().toISOString()},o=l.join(l.dirname(r),`.address-book.${process.pid}.tmp`);c.writeFileSync(o,`${JSON.stringify(t,null,2)}
2
- `,{mode:384}),c.renameSync(o,r);try{c.chmodSync(r,384)}catch{}return t}function G(e={}){let r=d(),t=r.entries;if(e.role&&(t=t.filter(o=>o.role===String(e.role))),e.who){let o=String(e.who).toLowerCase();t=t.filter(s=>(s.who||"").toLowerCase().includes(o)||(s.label||"").toLowerCase().includes(o))}if(e.q){let o=String(e.q).toLowerCase();t=t.filter(s=>s.address.includes(o)||(s.label||"").toLowerCase().includes(o)||(s.who||"").toLowerCase().includes(o)||(s.notes||"").toLowerCase().includes(o))}return{updatedAt:r.updatedAt,count:t.length,entries:t}}function q(e){let r=h(e),t=d().entries.filter(o=>o.address===r);return{address:r,found:t.length>0,entries:t}}function T(e={}){b(e);let r=h(e.address),t=a(e.label??e.role,80)||"wallet",o=new Date().toISOString(),s=d(),i=s.entries.findIndex(n=>n.address===r&&n.label===t),u=_({address:r,label:t,who:e.who,role:e.role,chainIds:e.chainIds,notes:e.notes,source:e.source||"agent",firstSeenAt:i>=0&&s.entries[i].firstSeenAt||o,lastSeenAt:o});i>=0?s.entries[i]=u:s.entries.push(u);let w=n=>n==="agent"?0:n==="owner"?1:2;s.entries.sort((n,f)=>w(n.role)-w(f.role)||n.label.localeCompare(f.label)||n.address.localeCompare(f.address));let v=O(s);return{ok:!0,entry:u,count:v.entries.length}}function Y(e,r=null){let t=h(e),o=d(),s=o.entries.length;return o.entries=o.entries.filter(i=>i.address!==t?!0:r==null?!1:i.label!==String(r)),O(o),{ok:!0,removed:s-o.entries.length,count:o.entries.length}}export{C as addressBookPath,Y as forgetAddress,G as listAddresses,q as lookupAddress,d as readAddressBook,T as rememberAddress};