@oracle-agent/oracle 0.14.0 → 0.15.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 (447) hide show
  1. package/README.md +2 -2
  2. package/SETUP.md +4 -4
  3. package/dist/action-receipts.mjs +1 -0
  4. package/dist/action-semantics.mjs +1 -0
  5. package/dist/address-book.mjs +2 -0
  6. package/dist/bin/desk-server.mjs +59 -0
  7. package/dist/bin/oracle-data-mcp.mjs +8 -0
  8. package/dist/bin/oracle-equities.mjs +20 -0
  9. package/dist/bin/oracle-init.mjs +24 -0
  10. package/dist/bin/oracle-public-server.mjs +5 -0
  11. package/dist/bin/oracle-route.mjs +22 -0
  12. package/dist/bin/oracle-scan.mjs +18 -0
  13. package/dist/bin/oracle-upgrade.mjs +21 -0
  14. package/dist/bin/oracle.mjs +61 -0
  15. package/dist/chains.mjs +1 -0
  16. package/dist/cli/commands/auth.mjs +16 -0
  17. package/dist/cli/commands/bootstrap.mjs +18 -0
  18. package/dist/cli/commands/chain.mjs +21 -0
  19. package/dist/cli/commands/chat.mjs +45 -0
  20. package/dist/cli/commands/credential.mjs +1 -0
  21. package/dist/cli/commands/data-mcp.mjs +2 -0
  22. package/dist/cli/commands/data.mjs +12 -0
  23. package/dist/cli/commands/doctor.mjs +5 -0
  24. package/dist/cli/commands/equities.mjs +15 -0
  25. package/dist/cli/commands/farm.mjs +59 -0
  26. package/dist/cli/commands/fees.mjs +10 -0
  27. package/dist/cli/commands/follow.mjs +28 -0
  28. package/dist/cli/commands/harness.mjs +15 -0
  29. package/dist/cli/commands/help.mjs +1 -0
  30. package/dist/cli/commands/init.mjs +3 -0
  31. package/dist/cli/commands/mcp.mjs +36 -0
  32. package/dist/cli/commands/model.mjs +54 -0
  33. package/dist/cli/commands/plugins.mjs +43 -0
  34. package/dist/cli/commands/prepare.mjs +2 -0
  35. package/dist/cli/commands/public.mjs +3 -0
  36. package/dist/cli/commands/resolve.mjs +23 -0
  37. package/dist/cli/commands/route.mjs +2 -0
  38. package/dist/cli/commands/runner.mjs +1 -0
  39. package/dist/cli/commands/scan.mjs +2 -0
  40. package/dist/cli/commands/setup.mjs +34 -0
  41. package/dist/cli/commands/sign.mjs +4 -0
  42. package/dist/cli/commands/signer.mjs +1 -0
  43. package/dist/cli/commands/swap.mjs +36 -0
  44. package/dist/cli/commands/upgrade.mjs +2 -0
  45. package/dist/cli/commands/vault.mjs +1 -0
  46. package/dist/cli/commands/version.mjs +2 -0
  47. package/dist/data/desk-data.mjs +55 -0
  48. package/dist/data/names.mjs +2 -0
  49. package/dist/data/providers/farming.mjs +2 -0
  50. package/dist/equities/index.mjs +1 -0
  51. package/dist/index.mjs +60 -0
  52. package/dist/nft-gas-war-guard.mjs +1 -0
  53. package/dist/onboarding/harness-configs.mjs +4 -0
  54. package/dist/portfolio-risk.mjs +1 -0
  55. package/dist/prepare-envelope.mjs +1 -0
  56. package/dist/public-api/agent-grants.mjs +3 -0
  57. package/dist/public-control/policy-schema.mjs +1 -0
  58. package/dist/router/index.mjs +2 -0
  59. package/dist/scanner/index.mjs +4 -0
  60. package/dist/signals/index.mjs +1 -0
  61. package/dist/watch-preferences.mjs +1 -0
  62. package/package.json +32 -78
  63. package/public/oracle-splash/_variants/ice.html +5 -18
  64. package/public/oracle-splash/_variants/ivory.html +5 -18
  65. package/public/oracle-splash/index.html +114 -34
  66. package/CONTRIBUTING.md +0 -99
  67. package/bin/desk-server.mjs +0 -473
  68. package/bin/oracle-data-mcp.mjs +0 -1252
  69. package/bin/oracle-equities.mjs +0 -168
  70. package/bin/oracle-init.mjs +0 -525
  71. package/bin/oracle-public-server.mjs +0 -36
  72. package/bin/oracle-route.mjs +0 -254
  73. package/bin/oracle-scan.mjs +0 -192
  74. package/bin/oracle-upgrade.mjs +0 -42
  75. package/bin/oracle.mjs +0 -34
  76. package/docs/adding-a-chain.md +0 -229
  77. package/docs/architecture.md +0 -139
  78. package/docs/buzz-integration.md +0 -115
  79. package/docs/cli.md +0 -143
  80. package/docs/connectors.md +0 -13
  81. package/docs/hyperliquid-builder-code.md +0 -50
  82. package/docs/locals-only-fee-waiver.md +0 -34
  83. package/docs/oracle-pack-standard.md +0 -29
  84. package/docs/profiles.md +0 -151
  85. package/docs/public-surface.md +0 -206
  86. package/examples/add-a-chain.mjs +0 -65
  87. package/examples/oracle-pack-template.mjs +0 -38
  88. package/examples/research-a-token.mjs +0 -70
  89. package/plugins/oracle-owner-gate/__init__.py +0 -288
  90. package/plugins/oracle-owner-gate/plugin.yaml +0 -9
  91. package/protocols/templates/safe-erc20/SECURITY.md +0 -16
  92. package/protocols/templates/safe-erc20/foundry.toml +0 -12
  93. package/protocols/templates/safe-erc20/remappings.txt +0 -2
  94. package/protocols/templates/safe-erc20/src/SafeERC20.sol +0 -53
  95. package/protocols/templates/safe-erc20/test/SafeERC20.t.sol +0 -72
  96. package/scripts/adversarial-bench.mjs +0 -114
  97. package/scripts/build-dist.mjs +0 -119
  98. package/scripts/build-inscription.py +0 -230
  99. package/scripts/check-doc-drift.mjs +0 -123
  100. package/scripts/check-test-count.mjs +0 -105
  101. package/scripts/e2e-hl-markets.mjs +0 -21
  102. package/scripts/e2e-hl-perps.mjs +0 -48
  103. package/scripts/e2e-hypercore-staking.mjs +0 -128
  104. package/scripts/e2e-solana-bitcoin.mjs +0 -183
  105. package/scripts/guard-publish.mjs +0 -22
  106. package/scripts/protocol-template-gate.mjs +0 -15
  107. package/scripts/public-api-scan.mjs +0 -23
  108. package/scripts/publish-dist.mjs +0 -67
  109. package/scripts/record-hero-cli.sh +0 -80
  110. package/scripts/secret-scan.mjs +0 -168
  111. package/scripts/smoke-dist-bins.mjs +0 -89
  112. package/scripts/verify-dist.mjs +0 -29
  113. package/scripts/verify-v3-venues.mjs +0 -233
  114. package/skins/oracle.yaml +0 -56
  115. package/src/action-receipts.mjs +0 -265
  116. package/src/action-semantics.mjs +0 -62
  117. package/src/address-book.mjs +0 -208
  118. package/src/agent-auth.mjs +0 -206
  119. package/src/approval-guard.mjs +0 -282
  120. package/src/attestation-secret.mjs +0 -94
  121. package/src/audit-log.mjs +0 -196
  122. package/src/auth/oauth.mjs +0 -672
  123. package/src/auto-slippage.mjs +0 -378
  124. package/src/capability-posture.mjs +0 -125
  125. package/src/cards.mjs +0 -422
  126. package/src/chains.mjs +0 -62
  127. package/src/cli/chain-catalog.mjs +0 -215
  128. package/src/cli/chain-state.mjs +0 -74
  129. package/src/cli/commands/auth.mjs +0 -193
  130. package/src/cli/commands/bootstrap.mjs +0 -87
  131. package/src/cli/commands/chain.mjs +0 -143
  132. package/src/cli/commands/chat.mjs +0 -465
  133. package/src/cli/commands/credential.mjs +0 -9
  134. package/src/cli/commands/data-mcp.mjs +0 -18
  135. package/src/cli/commands/data.mjs +0 -75
  136. package/src/cli/commands/doctor.mjs +0 -136
  137. package/src/cli/commands/equities.mjs +0 -41
  138. package/src/cli/commands/farm.mjs +0 -129
  139. package/src/cli/commands/fees.mjs +0 -109
  140. package/src/cli/commands/follow.mjs +0 -130
  141. package/src/cli/commands/harness.mjs +0 -63
  142. package/src/cli/commands/help.mjs +0 -7
  143. package/src/cli/commands/init.mjs +0 -27
  144. package/src/cli/commands/mcp.mjs +0 -154
  145. package/src/cli/commands/model.mjs +0 -106
  146. package/src/cli/commands/plugins.mjs +0 -241
  147. package/src/cli/commands/prepare.mjs +0 -12
  148. package/src/cli/commands/public.mjs +0 -20
  149. package/src/cli/commands/resolve.mjs +0 -64
  150. package/src/cli/commands/route.mjs +0 -12
  151. package/src/cli/commands/runner.mjs +0 -9
  152. package/src/cli/commands/scan.mjs +0 -12
  153. package/src/cli/commands/setup.mjs +0 -294
  154. package/src/cli/commands/sign.mjs +0 -21
  155. package/src/cli/commands/signer.mjs +0 -9
  156. package/src/cli/commands/swap.mjs +0 -102
  157. package/src/cli/commands/upgrade.mjs +0 -12
  158. package/src/cli/commands/vault.mjs +0 -9
  159. package/src/cli/commands/version.mjs +0 -22
  160. package/src/cli/first-run.mjs +0 -23
  161. package/src/cli/kernel.mjs +0 -262
  162. package/src/cli/mcp-targets/chatgpt.mjs +0 -51
  163. package/src/cli/mcp-targets/claude-code.mjs +0 -39
  164. package/src/cli/mcp-targets/claude-desktop.mjs +0 -24
  165. package/src/cli/mcp-targets/codex.mjs +0 -41
  166. package/src/cli/mcp-targets/cursor.mjs +0 -32
  167. package/src/cli/mcp-targets/shared.mjs +0 -71
  168. package/src/cli/mcp-targets/vscode.mjs +0 -39
  169. package/src/cli/messaging-platforms.mjs +0 -217
  170. package/src/cli/model-config.mjs +0 -78
  171. package/src/cli/operator-dispatch.mjs +0 -257
  172. package/src/cli/oracle-harness.py +0 -415
  173. package/src/cli/paths.mjs +0 -107
  174. package/src/cli/runtime.mjs +0 -351
  175. package/src/cli/setup-state.mjs +0 -168
  176. package/src/cli/spawn-child.mjs +0 -43
  177. package/src/data/catalog.mjs +0 -858
  178. package/src/data/desk-data.mjs +0 -877
  179. package/src/data/http.mjs +0 -253
  180. package/src/data/names.mjs +0 -188
  181. package/src/data/provider-endpoint.mjs +0 -94
  182. package/src/data/providers/aave-v3.mjs +0 -139
  183. package/src/data/providers/across-bridge.mjs +0 -41
  184. package/src/data/providers/aerodrome.mjs +0 -245
  185. package/src/data/providers/aevo.mjs +0 -33
  186. package/src/data/providers/approval-indexer.mjs +0 -133
  187. package/src/data/providers/approvals.mjs +0 -594
  188. package/src/data/providers/babylon-staking.mjs +0 -149
  189. package/src/data/providers/balancer.mjs +0 -209
  190. package/src/data/providers/beefy-yields.mjs +0 -45
  191. package/src/data/providers/birdeye-tokens.mjs +0 -33
  192. package/src/data/providers/bisq-markets.mjs +0 -145
  193. package/src/data/providers/bitcoin-esplora.mjs +0 -216
  194. package/src/data/providers/bitcoin-meta.mjs +0 -378
  195. package/src/data/providers/blockscout.mjs +0 -14
  196. package/src/data/providers/bob-rootstock.mjs +0 -198
  197. package/src/data/providers/braiins-insights.mjs +0 -103
  198. package/src/data/providers/bridge-aggregator.mjs +0 -259
  199. package/src/data/providers/bridges.mjs +0 -242
  200. package/src/data/providers/bungee.mjs +0 -29
  201. package/src/data/providers/celestia-da.mjs +0 -38
  202. package/src/data/providers/changenow.mjs +0 -135
  203. package/src/data/providers/compound.mjs +0 -32
  204. package/src/data/providers/connext.mjs +0 -28
  205. package/src/data/providers/convex.mjs +0 -30
  206. package/src/data/providers/cow-protocol.mjs +0 -110
  207. package/src/data/providers/cowswap.mjs +0 -415
  208. package/src/data/providers/curve.mjs +0 -201
  209. package/src/data/providers/das-assets.mjs +0 -59
  210. package/src/data/providers/debridge.mjs +0 -109
  211. package/src/data/providers/defillama.mjs +0 -88
  212. package/src/data/providers/dexscreener.mjs +0 -43
  213. package/src/data/providers/drift.mjs +0 -32
  214. package/src/data/providers/dydx.mjs +0 -41
  215. package/src/data/providers/evm-rpc.mjs +0 -225
  216. package/src/data/providers/farming.mjs +0 -291
  217. package/src/data/providers/geckoterminal.mjs +0 -34
  218. package/src/data/providers/gmx.mjs +0 -496
  219. package/src/data/providers/hiro-stacks.mjs +0 -150
  220. package/src/data/providers/hl-assets.mjs +0 -165
  221. package/src/data/providers/hl-info.mjs +0 -108
  222. package/src/data/providers/hl-markets.mjs +0 -210
  223. package/src/data/providers/hl-outcome.mjs +0 -61
  224. package/src/data/providers/hl-perps.mjs +0 -419
  225. package/src/data/providers/hl-staking.mjs +0 -353
  226. package/src/data/providers/hl-ws.mjs +0 -119
  227. package/src/data/providers/hyperevm-dex.mjs +0 -49
  228. package/src/data/providers/jito-mev.mjs +0 -117
  229. package/src/data/providers/jupiter-venues.mjs +0 -119
  230. package/src/data/providers/jupiter.mjs +0 -315
  231. package/src/data/providers/kamino-strategies.mjs +0 -143
  232. package/src/data/providers/l2beat-tvl.mjs +0 -42
  233. package/src/data/providers/lifi.mjs +0 -166
  234. package/src/data/providers/liquid-esplora.mjs +0 -152
  235. package/src/data/providers/magiceden-ordinals.mjs +0 -141
  236. package/src/data/providers/magiceden-sol.mjs +0 -406
  237. package/src/data/providers/mempool-lightning.mjs +0 -144
  238. package/src/data/providers/mempool-mining.mjs +0 -142
  239. package/src/data/providers/meteora-dlmm.mjs +0 -168
  240. package/src/data/providers/morpho.mjs +0 -177
  241. package/src/data/providers/nft-gallery.mjs +0 -163
  242. package/src/data/providers/nft-portfolio.mjs +0 -494
  243. package/src/data/providers/odos.mjs +0 -156
  244. package/src/data/providers/ondo.mjs +0 -31
  245. package/src/data/providers/oneinch.mjs +0 -174
  246. package/src/data/providers/opensea-multichain.mjs +0 -136
  247. package/src/data/providers/opensea-nft.mjs +0 -371
  248. package/src/data/providers/orca.mjs +0 -29
  249. package/src/data/providers/ordinals-runes.mjs +0 -180
  250. package/src/data/providers/pancakeswap.mjs +0 -28
  251. package/src/data/providers/paraswap.mjs +0 -125
  252. package/src/data/providers/pendle.mjs +0 -188
  253. package/src/data/providers/poly-clob.mjs +0 -283
  254. package/src/data/providers/poly-public.mjs +0 -96
  255. package/src/data/providers/poly-ws.mjs +0 -103
  256. package/src/data/providers/polygon-staking.mjs +0 -227
  257. package/src/data/providers/portfolio-history.mjs +0 -394
  258. package/src/data/providers/portfolio.mjs +0 -600
  259. package/src/data/providers/pyth-price-feeds.mjs +0 -172
  260. package/src/data/providers/raydium.mjs +0 -35
  261. package/src/data/providers/relayscan-mev.mjs +0 -72
  262. package/src/data/providers/rfq.mjs +0 -15
  263. package/src/data/providers/rh-agent.mjs +0 -59
  264. package/src/data/providers/sanctum-lst.mjs +0 -180
  265. package/src/data/providers/satflow.mjs +0 -341
  266. package/src/data/providers/signed-material-guard.mjs +0 -108
  267. package/src/data/providers/solana-rpc.mjs +0 -197
  268. package/src/data/providers/solend-lending.mjs +0 -166
  269. package/src/data/providers/spark-lend.mjs +0 -42
  270. package/src/data/providers/squid-router.mjs +0 -29
  271. package/src/data/providers/stargate.mjs +0 -29
  272. package/src/data/providers/sushiswap.mjs +0 -30
  273. package/src/data/providers/symbiotic-restaking.mjs +0 -41
  274. package/src/data/providers/thorchain.mjs +0 -36
  275. package/src/data/providers/traderjoe.mjs +0 -28
  276. package/src/data/providers/twap.mjs +0 -152
  277. package/src/data/providers/uniswap-v3.mjs +0 -457
  278. package/src/data/providers/uniswap-v4.mjs +0 -414
  279. package/src/data/providers/vertex.mjs +0 -41
  280. package/src/data/providers/wallet-watch.mjs +0 -264
  281. package/src/data/providers/wormhole.mjs +0 -28
  282. package/src/data/providers/yearn.mjs +0 -31
  283. package/src/data/providers/zerox.mjs +0 -167
  284. package/src/data/public-api-scan.mjs +0 -61
  285. package/src/data/quote-placeholder.mjs +0 -31
  286. package/src/desk/swap-prepare.mjs +0 -194
  287. package/src/equities/bridge.mjs +0 -388
  288. package/src/equities/fixtures/bridge_routes.json +0 -159
  289. package/src/equities/fixtures/dst_transitions.json +0 -29
  290. package/src/equities/fixtures/equity_dex_pools.json +0 -154
  291. package/src/equities/fixtures/hip3_l2books.json +0 -2711
  292. package/src/equities/fixtures/nyse_holidays.json +0 -1
  293. package/src/equities/fixtures/oracles.json +0 -100
  294. package/src/equities/fixtures/rh_pool_state.json +0 -244
  295. package/src/equities/fixtures/solana_xstocks.json +0 -704
  296. package/src/equities/fixtures/ton_xstocks.json +0 -35
  297. package/src/equities/fixtures/universe.json +0 -411
  298. package/src/equities/fixtures/venues.json +0 -3542
  299. package/src/equities/fixtures.mjs +0 -405
  300. package/src/equities/funding.mjs +0 -142
  301. package/src/equities/index.mjs +0 -166
  302. package/src/equities/liveness.mjs +0 -148
  303. package/src/equities/marketHours.mjs +0 -249
  304. package/src/equities/normalize.mjs +0 -295
  305. package/src/equities/num.mjs +0 -146
  306. package/src/equities/prepare.mjs +0 -95
  307. package/src/equities/rank.mjs +0 -260
  308. package/src/equities/sourceNum.mjs +0 -69
  309. package/src/equities/types.mjs +0 -220
  310. package/src/equities/venues/arcus-perp.mjs +0 -84
  311. package/src/equities/venues/arcus-spot.mjs +0 -105
  312. package/src/equities/venues/hyperliquid-hip3.mjs +0 -224
  313. package/src/equities/venues/rh-uniswap.mjs +0 -216
  314. package/src/equities/venues/solana-xstocks.mjs +0 -139
  315. package/src/equities/venues/ton-stonfi.mjs +0 -139
  316. package/src/exact-integer.mjs +0 -72
  317. package/src/exec-policy.mjs +0 -419
  318. package/src/flags.mjs +0 -15
  319. package/src/fresh-window.mjs +0 -76
  320. package/src/gmx-attestation.mjs +0 -176
  321. package/src/index.mjs +0 -107
  322. package/src/licensing/locals-only.mjs +0 -25
  323. package/src/nft-gas-war-guard.mjs +0 -139
  324. package/src/onboarding/agent-keys.mjs +0 -161
  325. package/src/onboarding/harness-configs.mjs +0 -102
  326. package/src/onboarding/index.mjs +0 -18
  327. package/src/onboarding/tiers.mjs +0 -139
  328. package/src/oracle-env.mjs +0 -55
  329. package/src/package-manifest.mjs +0 -42
  330. package/src/plugins/agent-plugin-loader.mjs +0 -225
  331. package/src/portfolio-risk.mjs +0 -170
  332. package/src/prepare-envelope.mjs +0 -204
  333. package/src/profile-upgrade.mjs +0 -277
  334. package/src/protocol-execution.mjs +0 -84
  335. package/src/protocol-templates/gate.mjs +0 -179
  336. package/src/protocol-templates/prepare-deploy.mjs +0 -81
  337. package/src/public-api/agent-grants.mjs +0 -57
  338. package/src/public-api/buzz-integration.mjs +0 -267
  339. package/src/public-api/connect-agent.mjs +0 -424
  340. package/src/public-api/grants.mjs +0 -142
  341. package/src/public-api/http.mjs +0 -707
  342. package/src/public-api/metering.mjs +0 -111
  343. package/src/public-control/aa-adapter.mjs +0 -402
  344. package/src/public-control/build-registry.mjs +0 -227
  345. package/src/public-control/bundler-client.mjs +0 -357
  346. package/src/public-control/grant-indexer.mjs +0 -296
  347. package/src/public-control/policy-render.mjs +0 -69
  348. package/src/public-control/policy-schema.mjs +0 -322
  349. package/src/public-control/runtime-config.mjs +0 -275
  350. package/src/public-control/session-key-model.mjs +0 -379
  351. package/src/public-control/session-orchestrator.mjs +0 -418
  352. package/src/rfq/intent.mjs +0 -180
  353. package/src/rfq/sources.mjs +0 -181
  354. package/src/route-attestation.mjs +0 -132
  355. package/src/router/best-execution.mjs +0 -326
  356. package/src/router/index.mjs +0 -250
  357. package/src/router/integrator-fee.mjs +0 -135
  358. package/src/router/prepare-bridge.mjs +0 -293
  359. package/src/router/prepare-route.mjs +0 -398
  360. package/src/router/proposal.mjs +0 -311
  361. package/src/router/risk-classifier.mjs +0 -119
  362. package/src/router/route-sources.mjs +0 -364
  363. package/src/scanner/chains.config.mjs +0 -543
  364. package/src/scanner/contract.mjs +0 -270
  365. package/src/scanner/evm-scanner.mjs +0 -394
  366. package/src/scanner/index.mjs +0 -9
  367. package/src/scanner/v2-venue.mjs +0 -351
  368. package/src/scanner/v3-venue.mjs +0 -308
  369. package/src/scopes.mjs +0 -44
  370. package/src/sell-simulation.mjs +0 -167
  371. package/src/signals/engine.mjs +0 -146
  372. package/src/signals/index.mjs +0 -1
  373. package/src/token-transfer-guard.mjs +0 -188
  374. package/src/tui/app.mjs +0 -438
  375. package/src/tui/backend.mjs +0 -215
  376. package/src/tui/format.mjs +0 -272
  377. package/src/tui/gateway-client.mjs +0 -177
  378. package/src/tui/input.mjs +0 -501
  379. package/src/tui/memory.mjs +0 -105
  380. package/src/tui/meta-learn.mjs +0 -85
  381. package/src/tui/renderer.mjs +0 -443
  382. package/src/tui/scheduler.mjs +0 -205
  383. package/src/tui/skills-loader.mjs +0 -140
  384. package/src/tui/standalone-client.mjs +0 -752
  385. package/src/tui/theme.mjs +0 -81
  386. package/src/vault-attestation.mjs +0 -146
  387. package/src/venues.mjs +0 -206
  388. package/src/watch-preferences.mjs +0 -85
  389. /package/{profiles → dist/assets/profiles}/_template/SOUL.md +0 -0
  390. /package/{profiles → dist/assets/profiles}/_template/profile.json +0 -0
  391. /package/{profiles → dist/assets/profiles}/bitcoin-agent/SOUL.md +0 -0
  392. /package/{profiles → dist/assets/profiles}/bitcoin-agent/profile.json +0 -0
  393. /package/{profiles → dist/assets/profiles}/hyperliquid-agent/SOUL.md +0 -0
  394. /package/{profiles → dist/assets/profiles}/hyperliquid-agent/profile.json +0 -0
  395. /package/{profiles → dist/assets/profiles}/oracle/SOUL.md +0 -0
  396. /package/{profiles → dist/assets/profiles}/oracle/profile.json +0 -0
  397. /package/{profiles → dist/assets/profiles}/polymarket-agent/SOUL.md +0 -0
  398. /package/{profiles → dist/assets/profiles}/polymarket-agent/profile.json +0 -0
  399. /package/{profiles → dist/assets/profiles}/profile.schema.json +0 -0
  400. /package/{profiles → dist/assets/profiles}/protocol-builder/SOUL.md +0 -0
  401. /package/{profiles → dist/assets/profiles}/protocol-builder/profile.json +0 -0
  402. /package/{profiles → dist/assets/profiles}/robinhood-agent/SOUL.md +0 -0
  403. /package/{profiles → dist/assets/profiles}/robinhood-agent/profile.json +0 -0
  404. /package/{profiles → dist/assets/profiles}/solana-agent/SOUL.md +0 -0
  405. /package/{profiles → dist/assets/profiles}/solana-agent/profile.json +0 -0
  406. /package/{profiles → dist/assets/profiles}/stable-agent/SOUL.md +0 -0
  407. /package/{profiles → dist/assets/profiles}/stable-agent/profile.json +0 -0
  408. /package/{skills → dist/assets/skills}/balance/SKILL.md +0 -0
  409. /package/{skills → dist/assets/skills}/bitcoin-l1.md +0 -0
  410. /package/{skills → dist/assets/skills}/chain-defi-ecosystem-profiling.md +0 -0
  411. /package/{skills → dist/assets/skills}/evm-contract-research.md +0 -0
  412. /package/{skills → dist/assets/skills}/hyperliquid.md +0 -0
  413. /package/{skills → dist/assets/skills}/multichain-exec-desk.md +0 -0
  414. /package/{skills → dist/assets/skills}/oracle-action-semantics/SKILL.md +0 -0
  415. /package/{skills → dist/assets/skills}/oracle-best-execution/SKILL.md +0 -0
  416. /package/{skills → dist/assets/skills}/oracle-best-execution.md +0 -0
  417. /package/{skills → dist/assets/skills}/oracle-bitcoin/SKILL.md +0 -0
  418. /package/{skills → dist/assets/skills}/oracle-chain-graphs-telegram-cards/SKILL.md +0 -0
  419. /package/{skills → dist/assets/skills}/oracle-chat/SKILL.md +0 -0
  420. /package/{skills → dist/assets/skills}/oracle-chat/chain.SKILL.md +0 -0
  421. /package/{skills → dist/assets/skills}/oracle-chat/setup.SKILL.md +0 -0
  422. /package/{skills → dist/assets/skills}/oracle-circuit-breaker/SKILL.md +0 -0
  423. /package/{skills → dist/assets/skills}/oracle-contract-research/SKILL.md +0 -0
  424. /package/{skills → dist/assets/skills}/oracle-desk/SKILL.md +0 -0
  425. /package/{skills → dist/assets/skills}/oracle-desk.md +0 -0
  426. /package/{skills → dist/assets/skills}/oracle-dex-launch/SKILL.md +0 -0
  427. /package/{skills → dist/assets/skills}/oracle-equities/SKILL.md +0 -0
  428. /package/{skills → dist/assets/skills}/oracle-grants/SKILL.md +0 -0
  429. /package/{skills → dist/assets/skills}/oracle-hypercore-staking/SKILL.md +0 -0
  430. /package/{skills → dist/assets/skills}/oracle-hyperliquid/SKILL.md +0 -0
  431. /package/{skills → dist/assets/skills}/oracle-meme-token-sniper/SKILL.md +0 -0
  432. /package/{skills → dist/assets/skills}/oracle-multichain-nft-launch/SKILL.md +0 -0
  433. /package/{skills → dist/assets/skills}/oracle-multichain-token-launch/SKILL.md +0 -0
  434. /package/{skills → dist/assets/skills}/oracle-nft-gacha-launch/SKILL.md +0 -0
  435. /package/{skills → dist/assets/skills}/oracle-nft-mint-gas-war/SKILL.md +0 -0
  436. /package/{skills → dist/assets/skills}/oracle-polymarket/SKILL.md +0 -0
  437. /package/{skills → dist/assets/skills}/oracle-protocol-builder/SKILL.md +0 -0
  438. /package/{skills → dist/assets/skills}/oracle-protocol-security/SKILL.md +0 -0
  439. /package/{skills → dist/assets/skills}/oracle-public-product/SKILL.md +0 -0
  440. /package/{skills → dist/assets/skills}/oracle-receipts/SKILL.md +0 -0
  441. /package/{skills → dist/assets/skills}/oracle-receipts.md +0 -0
  442. /package/{skills → dist/assets/skills}/oracle-rfq-tokenized-assets/SKILL.md +0 -0
  443. /package/{skills → dist/assets/skills}/oracle-smart-wallet-scanner/SKILL.md +0 -0
  444. /package/{skills → dist/assets/skills}/oracle-solana/SKILL.md +0 -0
  445. /package/{skills → dist/assets/skills}/oracle-solana-nft/SKILL.md +0 -0
  446. /package/{skills → dist/assets/skills}/oracle-token-research/SKILL.md +0 -0
  447. /package/{skills → dist/assets/skills}/solana.md +0 -0
@@ -1,275 +0,0 @@
1
- // Oracle Control — public runtime config: chain/bundler/paymaster registry
2
- // (Slice K).
3
- //
4
- // This module is pure config parsing. It never makes a live network call and
5
- // never imports the private executor stack — its only job is to turn env
6
- // vars into a validated, in-memory registry of PUBLIC endpoints (chain
7
- // metadata, bundler URLs, paymaster URLs, and the public HTTP bind) that the
8
- // rest of Oracle Control (aa-adapter.mjs, bundler-client.mjs, http.mjs) can
9
- // read from.
10
- //
11
- // Hard boundaries for this file:
12
- // - Imports ONLY from ./aa-adapter.mjs (ENTRYPOINT_V07 — the single source
13
- // of truth for the deployed EntryPoint address this codebase targets)
14
- // and node builtins. NEVER from the private executor stack
15
- // (get-signer.mjs, keystore.mjs, exec-policy.mjs, local-signer/*,
16
- // adapters/*, mint-capability.mjs) — this module must never be wired to
17
- // private operator wallet, and holds no secrets of any kind.
18
- // - bundlerUrl/paymasterUrl are treated as PUBLIC endpoints (the same way a
19
- // public RPC URL is public) — but they are still scanned for anything
20
- // secret-SHAPED (a bearer token, an api-key-looking query param, a raw
21
- // private-key hex blob, a PEM block) and rejected outright if found.
22
- // Fail closed: a config that looks like it's carrying a credential in a
23
- // URL must never load.
24
- // - resolveChain() fails closed on any chainId not in the registry — no
25
- // silent fallback to a made-up chain.
26
- // - entryPoint is never read from env or invented; it is always pinned to
27
- // aa-adapter.mjs's ENTRYPOINT_V07 and asserted equal for every seeded
28
- // chain, so a typo/drift in this file can never point a chain at the
29
- // wrong EntryPoint deployment.
30
- // - redactedConfig() strips the query string (and any embedded userinfo)
31
- // off every bundler/paymaster URL before it is considered "safe to log"
32
- // — even though the full URL already passed the secret-shape scan at
33
- // load time, a log line is a wider blast radius than an in-memory
34
- // config object, so this view is deliberately more conservative.
35
-
36
- import { ENTRYPOINT_V07 } from "./aa-adapter.mjs";
37
-
38
- export class RuntimeConfigError extends Error {
39
- constructor(message) {
40
- super(`runtime-config: ${message}`);
41
- this.name = "RuntimeConfigError";
42
- }
43
- }
44
-
45
- function fail(message) {
46
- throw new RuntimeConfigError(message);
47
- }
48
-
49
- // ---------------------------------------------------------------------------
50
- // Secret-shape guard for public endpoint URLs (fail closed)
51
- // ---------------------------------------------------------------------------
52
-
53
- /** String-value shapes that must never appear in a bundler/paymaster URL.
54
- * Mirrors the posture of connect-agent.mjs's FORBIDDEN_VALUE_RULES /
55
- * bundler-client.mjs's SecretLeakError checks, scoped to what a URL could
56
- * plausibly carry (query-string credentials, embedded key material). */
57
- const SECRET_URL_RULES = Object.freeze([
58
- // 32-byte hex — the shape of a raw EVM private key / session secret.
59
- { rule: "raw-32-byte-hex-key", re: /0x[0-9a-fA-F]{64}/ },
60
- { rule: "bearer-token", re: /bearer\s+[A-Za-z0-9._~+/=-]+/i },
61
- { rule: "pem-private-key", re: /-----BEGIN[A-Z ]*PRIVATE KEY-----/ },
62
- { rule: "authorization-header", re: /authorization\s*:/i },
63
- // Credential-shaped query/path segment: ?api_key=..., ?token=..., ?secret=...,
64
- // ?password=..., ?auth=..., ?access_token=..., ?bearer=..., or userinfo
65
- // (user:pass@host) embedded in the URL itself.
66
- {
67
- rule: "credential-shaped-param",
68
- re: /[?&](api[_-]?key|apikey|key|token|access[_-]?token|secret|password|passwd|auth|bearer)=/i,
69
- },
70
- { rule: "embedded-userinfo", re: /^[a-z][a-z0-9+.-]*:\/\/[^/@\s]+:[^/@\s]+@/i },
71
- ]);
72
-
73
- function assertPublicUrlSafe(value, label) {
74
- if (typeof value !== "string" || value.trim() === "") {
75
- fail(`${label} must be a non-empty string URL`);
76
- }
77
- let parsed;
78
- try {
79
- parsed = new URL(value);
80
- } catch {
81
- fail(`${label} is not a valid URL: ${value}`);
82
- }
83
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
84
- fail(`${label} must be an http(s) URL, got scheme ${parsed.protocol}`);
85
- }
86
- for (const { rule, re } of SECRET_URL_RULES) {
87
- if (re.test(value)) {
88
- fail(`${label} looks like it carries secret material (rule: ${rule}) — refusing to load a credential-shaped public endpoint`);
89
- }
90
- }
91
- return value;
92
- }
93
-
94
- // ---------------------------------------------------------------------------
95
- // Chain registry seed
96
- // ---------------------------------------------------------------------------
97
-
98
- /** Base metadata for every chain Oracle Control's public runtime config
99
- * knows about out of the box. entryPoint is intentionally NOT stored here —
100
- * it is always ENTRYPOINT_V07, asserted below, so there is exactly one
101
- * place (aa-adapter.mjs) that can ever define it. */
102
- const CHAIN_SEEDS = Object.freeze([
103
- { chainId: 8453, name: "Base" },
104
- { chainId: 42161, name: "Arbitrum" },
105
- ]);
106
-
107
- export const DEFAULT_CHAIN_ID = 8453;
108
- export const DEFAULT_PUBLIC_HOST = "127.0.0.1";
109
- export const DEFAULT_PUBLIC_PORT = 8799;
110
- const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "::1"]);
111
-
112
- function buildChainEntry(seed, env) {
113
- const entry = {
114
- name: seed.name,
115
- entryPoint: ENTRYPOINT_V07,
116
- };
117
- // entryPoint must always equal aa-adapter's ENTRYPOINT_V07 for every
118
- // supported chain — asserted here (not just "set here") so a future edit
119
- // that tries to override it per-chain is caught immediately.
120
- if (entry.entryPoint !== ENTRYPOINT_V07) {
121
- fail(`chain ${seed.chainId} entryPoint drifted from aa-adapter ENTRYPOINT_V07`);
122
- }
123
-
124
- const bundlerVar = `ORACLE_BUNDLER_URL_${seed.chainId}`;
125
- const paymasterVar = `ORACLE_PAYMASTER_URL_${seed.chainId}`;
126
- const bundlerRaw = env[bundlerVar];
127
- const paymasterRaw = env[paymasterVar];
128
-
129
- if (bundlerRaw != null && String(bundlerRaw).trim() !== "") {
130
- entry.bundlerUrl = assertPublicUrlSafe(String(bundlerRaw), bundlerVar);
131
- }
132
- if (paymasterRaw != null && String(paymasterRaw).trim() !== "") {
133
- entry.paymasterUrl = assertPublicUrlSafe(String(paymasterRaw), paymasterVar);
134
- }
135
-
136
- return entry;
137
- }
138
-
139
- function parsePort(raw, label) {
140
- const n = Number(raw);
141
- if (!Number.isInteger(n) || n < 0 || n > 65535) {
142
- fail(`${label} must be an integer port 0-65535, got ${JSON.stringify(raw)}`);
143
- }
144
- return n;
145
- }
146
-
147
- function parsePublicHost(raw, label) {
148
- const host = String(raw).trim();
149
- const normalized = host.toLowerCase().replace(/^\[|\]$/g, "");
150
- if (!LOOPBACK_HOSTS.has(normalized)) {
151
- fail(`${label} must be a loopback host, got ${JSON.stringify(raw)}`);
152
- }
153
- return normalized === "::1" ? "::1" : host;
154
- }
155
-
156
- /**
157
- * Parse the public runtime config (chain/bundler/paymaster registry + public
158
- * HTTP bind) from an env-like object. Pure function, no I/O, no network.
159
- *
160
- * @param {object} [env] defaults to process.env; any plain object of
161
- * string-ish values works (this is what makes it deterministically
162
- * testable without touching real process.env).
163
- * @returns {{
164
- * chains: Record<string, {name:string, entryPoint:string, bundlerUrl?:string, paymasterUrl?:string}>,
165
- * defaultChainId: number,
166
- * publicHost: string,
167
- * publicPort: number,
168
- * }}
169
- */
170
- export function loadPublicConfig(env = process.env) {
171
- if (env == null || typeof env !== "object") {
172
- fail("env must be an object");
173
- }
174
-
175
- const chains = {};
176
- for (const seed of CHAIN_SEEDS) {
177
- chains[String(seed.chainId)] = buildChainEntry(seed, env);
178
- }
179
-
180
- const rawDefaultChainId = env.ORACLE_DEFAULT_CHAIN_ID;
181
- let defaultChainId = DEFAULT_CHAIN_ID;
182
- if (rawDefaultChainId != null && String(rawDefaultChainId).trim() !== "") {
183
- const n = Number(rawDefaultChainId);
184
- if (!Number.isInteger(n)) {
185
- fail(`ORACLE_DEFAULT_CHAIN_ID must be an integer chain id, got ${JSON.stringify(rawDefaultChainId)}`);
186
- }
187
- if (chains[String(n)] == null) {
188
- fail(`ORACLE_DEFAULT_CHAIN_ID ${n} is not a registered chain (known: ${Object.keys(chains).join(", ")})`);
189
- }
190
- defaultChainId = n;
191
- }
192
-
193
- const publicHost = (() => {
194
- const v = env.ORACLE_PUBLIC_HOST ?? env.MAD_PUBLIC_HOST;
195
- return v != null && String(v).trim() !== "" ? parsePublicHost(v, "ORACLE_PUBLIC_HOST") : DEFAULT_PUBLIC_HOST;
196
- })();
197
-
198
- const publicPort = (() => {
199
- const v = env.ORACLE_PUBLIC_PORT ?? env.MAD_PUBLIC_PORT;
200
- if (v == null || String(v).trim() === "") return DEFAULT_PUBLIC_PORT;
201
- return parsePort(v, "ORACLE_PUBLIC_PORT");
202
- })();
203
-
204
- return Object.freeze({
205
- chains: Object.freeze(chains),
206
- defaultChainId,
207
- publicHost,
208
- publicPort,
209
- });
210
- }
211
-
212
- /**
213
- * Resolve a single chain entry from a loaded config. Fails closed on any
214
- * chainId not present in the registry — never falls back to a guessed/
215
- * default chain.
216
- *
217
- * @param {ReturnType<typeof loadPublicConfig>} config
218
- * @param {number|string} chainId
219
- */
220
- export function resolveChain(config, chainId) {
221
- if (config == null || typeof config.chains !== "object") {
222
- fail("resolveChain: config must be a loadPublicConfig() result");
223
- }
224
- const key = String(chainId);
225
- const entry = config.chains[key];
226
- if (entry == null) {
227
- fail(`unsupported chainId ${key} (registered: ${Object.keys(config.chains).join(", ") || "none"})`);
228
- }
229
- return entry;
230
- }
231
-
232
- /** Drop the query string and any userinfo from a URL, keeping only
233
- * scheme://host:port/path — safe to write to a log line even though the
234
- * full URL already passed the load-time secret-shape scan. */
235
- function redactUrl(value) {
236
- try {
237
- const u = new URL(value);
238
- u.search = "";
239
- u.username = "";
240
- u.password = "";
241
- return u.toString();
242
- } catch {
243
- return "[unparseable-url-redacted]";
244
- }
245
- }
246
-
247
- /**
248
- * Safe-to-log view of a loaded config: chain names/entryPoints/host/port
249
- * pass through unchanged (none of that is secret-shaped), bundler/paymaster
250
- * URLs are stripped down to origin+path only.
251
- *
252
- * @param {ReturnType<typeof loadPublicConfig>} config
253
- */
254
- export function redactedConfig(config) {
255
- if (config == null || typeof config.chains !== "object") {
256
- fail("redactedConfig: config must be a loadPublicConfig() result");
257
- }
258
- const chains = {};
259
- for (const [chainId, entry] of Object.entries(config.chains)) {
260
- chains[chainId] = {
261
- name: entry.name,
262
- entryPoint: entry.entryPoint,
263
- ...(entry.bundlerUrl != null ? { bundlerUrl: redactUrl(entry.bundlerUrl) } : {}),
264
- ...(entry.paymasterUrl != null ? { paymasterUrl: redactUrl(entry.paymasterUrl) } : {}),
265
- };
266
- }
267
- return Object.freeze({
268
- chains: Object.freeze(chains),
269
- defaultChainId: config.defaultChainId,
270
- publicHost: config.publicHost,
271
- publicPort: config.publicPort,
272
- });
273
- }
274
-
275
- export const _internal = { assertPublicUrlSafe, SECRET_URL_RULES, CHAIN_SEEDS };
@@ -1,379 +0,0 @@
1
- // Oracle Control — provider-neutral account-abstraction session-key model.
2
- //
3
- // This is a design spike (Slice B / Phase 2 of the Oracle public release plan,
4
- // see artifacts/oracle-public-plan.md and docs/public-self-custody-aa.md).
5
- // It defines the SHAPE of a public self-custody session-key grant and the
6
- // deterministic policy checks that decide whether a proposed action is
7
- // authorized by that grant — independent of which account-abstraction stack
8
- // (Safe, Kernel/ZeroDev, Biconomy/Nexus, permissionless/viem) eventually
9
- // enforces it on-chain.
10
- //
11
- // Hard boundaries for this file:
12
- // - No wallet/AA SDK imports. No RPC calls. No live chain integration.
13
- // - No import from the private executor stack (get-signer.mjs, keystore.mjs,
14
- // exec-policy.mjs, local-signer/*, oracle-env.mjs, adapters/*). This model
15
- // must stand alone so it can never be wired to a private operator wallet.
16
- // - Deterministic, pure functions only — same input always produces the
17
- // same session id and the same authorization verdict.
18
- // - `owner` (the user's main wallet / smart-account) never signs a
19
- // transaction here. This module only decides whether an already-proposed
20
- // action fits inside an already-granted, bounded session.
21
- //
22
- // Terminology:
23
- // grant — the bounded permission the owner signed (chain, actions,
24
- // targets, value/gas caps, expiry). Provider-neutral; a real
25
- // integration maps this onto a Safe allowance module, a ZeroDev
26
- // session-key validator, a Biconomy Nexus session module, or a
27
- // permissionless/viem session account.
28
- // agent — the session key address the grant authorizes to act. Never the
29
- // owner's main key.
30
- // request — a single proposed action (action id, target, value, gas) that
31
- // is checked against a grant before anything is prepared/signed.
32
-
33
- import { createHash } from "node:crypto";
34
- import { exactBigInt } from "../exact-integer.mjs";
35
- import { isWindowOpen } from "../fresh-window.mjs";
36
-
37
- /** Account-abstraction stacks this model is written to be portable across.
38
- * Purely descriptive — no SDK behavior is implied or imported here. */
39
- export const PROVIDERS = Object.freeze({
40
- SAFE: "safe",
41
- KERNEL_ZERODEV: "kernel-zerodev",
42
- BICONOMY_NEXUS: "biconomy-nexus",
43
- PERMISSIONLESS_VIEM: "permissionless-viem",
44
- });
45
-
46
- export const PROVIDER_IDS = Object.freeze(Object.values(PROVIDERS));
47
-
48
- /** Session lifecycle states returned by sessionStatus(). */
49
- export const SESSION_STATUS = Object.freeze({
50
- ACTIVE: "active",
51
- EXPIRED: "expired",
52
- REVOKED: "revoked",
53
- });
54
-
55
- export const MAX_SESSION_TTL_MS = 24 * 60 * 60 * 1000;
56
-
57
- /** Action-id prefixes that never move funds or touch a target contract and
58
- * therefore never require a non-empty target allowlist. Matches the "empty
59
- * target allowlist only allowed for read/simulate scopes" rule in the Oracle
60
- * public policy schema (artifacts/oracle-public-plan.md Phase 1). */
61
- const READ_ONLY_ACTION_PREFIXES = ["read:", "simulate:"];
62
-
63
- const ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
64
- const HEX32_RE = /^0x[0-9a-fA-F]{64}$/;
65
-
66
- function isReadOnlyAction(action) {
67
- const a = String(action || "");
68
- return READ_ONLY_ACTION_PREFIXES.some((p) => a.startsWith(p));
69
- }
70
-
71
- function fail(message) {
72
- throw new Error(`session: ${message}`);
73
- }
74
-
75
- function normalAddress(value, label) {
76
- const text = String(value ?? "").trim().toLowerCase();
77
- if (!ADDRESS_RE.test(text)) fail(`${label} must be a 0x-prefixed 20-byte address`);
78
- return text;
79
- }
80
-
81
- function normalActionId(value) {
82
- const text = String(value ?? "").trim().toLowerCase();
83
- if (!text) fail("action ids must be non-empty strings");
84
- if (text.length > 128) fail("action id too long");
85
- return text;
86
- }
87
-
88
- function normalPositiveInt(value, label) {
89
- const n = Number(value);
90
- if (!Number.isFinite(n) || !Number.isInteger(n) || n <= 0) fail(`${label} must be a positive integer`);
91
- return n;
92
- }
93
-
94
- function normalBigString(value, label, { allowZero = true } = {}) {
95
- if (value == null || value === "") return "0";
96
- // Wei caps bound delegated spend. An unsafe JS number rounds UP here and
97
- // stores a looser cap than the owner wrote, so refuse rather than coerce.
98
- let n;
99
- try {
100
- n = exactBigInt(value, label);
101
- } catch (e) {
102
- fail(e.message);
103
- }
104
- if (n < 0n) fail(`${label} must not be negative`);
105
- if (!allowZero && n === 0n) fail(`${label} must be greater than zero`);
106
- return n.toString();
107
- }
108
-
109
- /** Deterministic JSON: object keys sorted recursively, matching the
110
- * canonicalJson convention already used by audit-log.mjs / vault-attestation.mjs
111
- * so the same fields hash identically everywhere. Self-contained here on
112
- * purpose (no cross-file import) to keep this design-spike file standalone. */
113
- export function canonicalJson(value) {
114
- if (value === null || value === undefined) return "null";
115
- if (typeof value !== "object") return JSON.stringify(value);
116
- if (Array.isArray(value)) return "[" + value.map(canonicalJson).join(",") + "]";
117
- const keys = Object.keys(value).sort();
118
- return "{" + keys.map((k) => JSON.stringify(k) + ":" + canonicalJson(value[k])).join(",") + "}";
119
- }
120
-
121
- /**
122
- * Deterministic session id: sha256 over the canonical JSON of the grant's
123
- * identity fields, prefixed 0x. Two grants with identical owner/agent/chain/
124
- * actions/targets/caps/expiry/nonce always produce the same id; changing any
125
- * field (including the ordering-insensitive actions/targets arrays, which are
126
- * sorted before hashing) changes the id.
127
- */
128
- export function computeSessionId(fields) {
129
- const h = createHash("sha256");
130
- h.update(canonicalJson(fields), "utf8");
131
- return `0x${h.digest("hex")}`;
132
- }
133
-
134
- /**
135
- * Build and validate a provider-neutral session grant. Throws on any
136
- * malformed/unsafe input (fail-closed). Returns a deep-frozen record.
137
- *
138
- * @param {object} input
139
- * @param {string} input.provider one of PROVIDERS (informational; which
140
- * AA stack is expected to enforce this)
141
- * @param {string} input.owner user's main wallet / smart-account address
142
- * @param {string} input.agent session key address (must differ from owner)
143
- * @param {number} input.chainId positive integer chain id
144
- * @param {string[]} input.actions non-empty list of action ids (e.g.
145
- * "erc20:transfer", "swap:exec", "read:balance")
146
- * @param {string[]} [input.targets] allowed destination addresses. May be
147
- * empty ONLY if every action is read/simulate.
148
- * @param {string|number|bigint} [input.maxValueWei] native-value cap (default "0")
149
- * @param {string|number|bigint} [input.maxGasWei] optional gas-fee cap (gasLimit*feePerGas)
150
- * @param {number} input.expiresAtMs epoch ms the grant stops being valid
151
- * @param {string|number} [input.nonce] uniqueness salt (default 0)
152
- * @param {number} [input.issuedAtMs] epoch ms issuance time (default Date.now())
153
- */
154
- export function createSessionGrant({
155
- provider,
156
- owner,
157
- agent,
158
- chainId,
159
- actions,
160
- targets = [],
161
- maxValueWei = "0",
162
- maxGasWei,
163
- expiresAtMs,
164
- nonce = 0,
165
- issuedAtMs = Date.now(),
166
- } = {}) {
167
- const normalizedProvider = String(provider ?? "").trim().toLowerCase();
168
- if (!PROVIDER_IDS.includes(normalizedProvider)) {
169
- fail(`provider must be one of ${PROVIDER_IDS.join(", ")}`);
170
- }
171
-
172
- const normalizedOwner = normalAddress(owner, "owner");
173
- const normalizedAgent = normalAddress(agent, "agent");
174
- if (normalizedOwner === normalizedAgent) fail("agent key must differ from owner wallet");
175
-
176
- const normalizedChainId = normalPositiveInt(chainId, "chainId");
177
-
178
- if (!Array.isArray(actions) || actions.length === 0) fail("actions must be a non-empty array");
179
- const normalizedActions = [...new Set(actions.map(normalActionId))].sort();
180
-
181
- if (!Array.isArray(targets)) fail("targets must be an array");
182
- const normalizedTargets = [...new Set(targets.map((t) => normalAddress(t, "target")))].sort();
183
-
184
- const allActionsReadOnly = normalizedActions.every(isReadOnlyAction);
185
- if (normalizedTargets.length === 0 && !allActionsReadOnly) {
186
- fail("empty target allowlist is only allowed when every action is read/simulate");
187
- }
188
-
189
- const normalizedMaxValueWei = normalBigString(maxValueWei, "maxValueWei");
190
- const normalizedMaxGasWei = maxGasWei == null ? null : normalBigString(maxGasWei, "maxGasWei");
191
-
192
- const normalizedIssuedAtMs = Number(issuedAtMs);
193
- if (!Number.isFinite(normalizedIssuedAtMs)) fail("issuedAtMs must be a finite number");
194
- const normalizedExpiresAtMs = Number(expiresAtMs);
195
- if (!Number.isFinite(normalizedExpiresAtMs)) fail("expiresAtMs must be a finite number");
196
- if (normalizedExpiresAtMs <= normalizedIssuedAtMs) fail("expiresAtMs must be after issuedAtMs");
197
- if (normalizedExpiresAtMs - normalizedIssuedAtMs > MAX_SESSION_TTL_MS) {
198
- fail(`session grant exceeds the hard 24-hour TTL (${MAX_SESSION_TTL_MS} ms)`);
199
- }
200
-
201
- const normalizedNonce = String(nonce ?? 0);
202
-
203
- const identity = {
204
- mode: "oracle-session-grant",
205
- version: 1,
206
- provider: normalizedProvider,
207
- owner: normalizedOwner,
208
- agent: normalizedAgent,
209
- chainId: normalizedChainId,
210
- actions: normalizedActions,
211
- targets: normalizedTargets,
212
- maxValueWei: normalizedMaxValueWei,
213
- maxGasWei: normalizedMaxGasWei,
214
- issuedAtMs: normalizedIssuedAtMs,
215
- expiresAtMs: normalizedExpiresAtMs,
216
- nonce: normalizedNonce,
217
- };
218
-
219
- const id = computeSessionId(identity);
220
- const grant = { id, ...identity };
221
- return Object.freeze(grant);
222
- }
223
-
224
- /** In-memory revocation registry. Deterministic, no chain dependency — a real
225
- * integration backs this with an on-chain revoke (Safe module disable,
226
- * ZeroDev/Biconomy session revoke) or an off-chain indexer; the interface
227
- * here is what Oracle Control's policy check consumes either way. */
228
- export function createRevocationRegistry() {
229
- const revoked = new Map(); // sessionId -> { revokedAtMs, reason }
230
- return {
231
- revoke(sessionId, { nowMs = Date.now(), reason = null } = {}) {
232
- if (!sessionId) fail("revoke requires a sessionId");
233
- if (!revoked.has(sessionId)) revoked.set(sessionId, { revokedAtMs: Number(nowMs), reason });
234
- return revoked.get(sessionId);
235
- },
236
- isRevoked(sessionId) {
237
- return revoked.has(sessionId);
238
- },
239
- revokedAt(sessionId) {
240
- return revoked.get(sessionId)?.revokedAtMs ?? null;
241
- },
242
- get size() {
243
- return revoked.size;
244
- },
245
- };
246
- }
247
-
248
- function isRevokedGrant(grant, revocation) {
249
- if (!revocation) return false;
250
- if (typeof revocation.isRevoked === "function") return revocation.isRevoked(grant.id);
251
- if (revocation instanceof Set) return revocation.has(grant.id);
252
- if (Array.isArray(revocation)) return revocation.includes(grant.id);
253
- return false;
254
- }
255
-
256
- /**
257
- * Compute a grant's current lifecycle status. Revocation takes precedence
258
- * over expiry (a revoked-then-expired grant still reports "revoked", which
259
- * matters for audit trails downstream).
260
- */
261
- export function sessionStatus(grant, { nowMs = Date.now(), revocation } = {}) {
262
- if (!grant || grant.mode !== "oracle-session-grant") fail("invalid session grant");
263
- if (isRevokedGrant(grant, revocation)) return SESSION_STATUS.REVOKED;
264
- // Fail CLOSED on an unusable clock. `Number(nowMs) >= expiresAtMs` is false
265
- // for NaN / null / "later" / -Infinity, so a long-dead grant reported ACTIVE
266
- // and authorized spending at its full cap. `null` is the sharp edge: it slips
267
- // past the `= Date.now()` default because it is a supplied value, and
268
- // Number(null) === 0.
269
- if (!isWindowOpen({ expiresAtMs: grant.expiresAtMs }, nowMs, { inclusive: true })) return SESSION_STATUS.EXPIRED;
270
- return SESSION_STATUS.ACTIVE;
271
- }
272
-
273
- export function isSessionActive(grant, opts = {}) {
274
- return sessionStatus(grant, opts) === SESSION_STATUS.ACTIVE;
275
- }
276
-
277
- /**
278
- * Authorize a single proposed action against a session grant. Throws a
279
- * "session: ..." Error on any violation (fail-closed); returns true only when
280
- * every check passes. This is a pure policy check — it does not sign,
281
- * prepare, or broadcast anything.
282
- *
283
- * @param {object} grant output of createSessionGrant()
284
- * @param {object} request
285
- * @param {string} request.action action id being attempted
286
- * @param {number} request.chainId chain the action targets
287
- * @param {string} [request.target] destination address (required unless read/simulate)
288
- * @param {string|number|bigint} [request.valueWei] native value moved (default 0)
289
- * @param {string|number|bigint} [request.gasWei] gasLimit*feePerGas estimate
290
- * @param {object} [opts]
291
- * @param {number} [opts.nowMs]
292
- * @param {object|Set|string[]} [opts.revocation] registry / set / array of revoked ids
293
- */
294
- export function assertSessionAuthorized(grant, request = {}, opts = {}) {
295
- if (!grant || grant.mode !== "oracle-session-grant") fail("invalid session grant");
296
-
297
- const status = sessionStatus(grant, opts);
298
- if (status === SESSION_STATUS.REVOKED) fail(`session ${grant.id} is revoked`);
299
- if (status === SESSION_STATUS.EXPIRED) fail(`session ${grant.id} expired at ${grant.expiresAtMs}`);
300
-
301
- const requestedChainId = normalPositiveInt(request.chainId, "request.chainId");
302
- if (requestedChainId !== grant.chainId) {
303
- fail(`chain mismatch: session is scoped to ${grant.chainId}, request is ${requestedChainId}`);
304
- }
305
-
306
- const action = normalActionId(request.action);
307
- if (!grant.actions.includes(action)) {
308
- fail(`action "${action}" not permitted by session ${grant.id}`);
309
- }
310
-
311
- const readOnly = isReadOnlyAction(action);
312
- if (!readOnly) {
313
- if (request.target == null || request.target === "") fail("target required for a non-read action");
314
- const target = normalAddress(request.target, "request.target");
315
- if (grant.targets.length === 0) fail(`session ${grant.id} has no granted targets (fail-closed)`);
316
- if (!grant.targets.includes(target)) {
317
- fail(`target ${target} not permitted by session ${grant.id}`);
318
- }
319
- }
320
-
321
- const valueWei = BigInt(normalBigString(request.valueWei ?? "0", "request.valueWei"));
322
- const maxValueWei = BigInt(grant.maxValueWei);
323
- if (valueWei > maxValueWei) {
324
- fail(`value ${valueWei} exceeds session cap ${maxValueWei}`);
325
- }
326
-
327
- // A gas ceiling on the grant is a promise the grant makes. Honouring it only
328
- // when the REQUEST volunteers a gasWei made it optional in practice: a
329
- // requester could omit the field and satisfy a grant whose explicit ceiling
330
- // would otherwise reject the transaction. If the grant bounds gas, the
331
- // request must state it.
332
- if (grant.maxGasWei != null) {
333
- if (request.gasWei == null) {
334
- fail("session grant bounds gas but the request omitted gasWei — refusing to authorize unbounded gas");
335
- }
336
- const gasWei = BigInt(normalBigString(request.gasWei, "request.gasWei"));
337
- const maxGasWei = BigInt(grant.maxGasWei);
338
- if (gasWei > maxGasWei) {
339
- fail(`gas fee ${gasWei} exceeds session cap ${maxGasWei}`);
340
- }
341
- }
342
-
343
- return true;
344
- }
345
-
346
- /** Convenience non-throwing wrapper: returns { ok, reason }. */
347
- export function checkSessionAuthorized(grant, request = {}, opts = {}) {
348
- try {
349
- assertSessionAuthorized(grant, request, opts);
350
- return { ok: true };
351
- } catch (e) {
352
- return { ok: false, reason: String(e?.message || e) };
353
- }
354
- }
355
-
356
- /** Redacted view safe to log/index — drops nothing secret today (this model
357
- * never carries key material) but exists so callers have one stable place to
358
- * serialize a grant for an audit trail without hand-picking fields. */
359
- export function toAuditRecord(grant) {
360
- if (!grant || grant.mode !== "oracle-session-grant") fail("invalid session grant");
361
- return {
362
- id: grant.id,
363
- provider: grant.provider,
364
- owner: grant.owner,
365
- agent: grant.agent,
366
- chainId: grant.chainId,
367
- actions: grant.actions,
368
- targets: grant.targets,
369
- maxValueWei: grant.maxValueWei,
370
- maxGasWei: grant.maxGasWei,
371
- issuedAtMs: grant.issuedAtMs,
372
- expiresAtMs: grant.expiresAtMs,
373
- nonce: grant.nonce,
374
- };
375
- }
376
-
377
- // Exported for tests / callers that want the raw address/hash validators
378
- // without re-implementing them.
379
- export const _internal = { ADDRESS_RE, HEX32_RE, isReadOnlyAction };