@oracle-agent/oracle 0.13.0 → 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 (629) hide show
  1. package/CONTRIBUTING.md +99 -0
  2. package/README.md +531 -13
  3. package/SECURITY.md +112 -0
  4. package/SETUP.md +317 -0
  5. package/artifacts/inscription/oracle-was-here-preview.png +0 -0
  6. package/artifacts/inscription/oracle-was-here.svg +1 -0
  7. package/artifacts/specialist-packs/oracle-full-crypto.json +298 -0
  8. package/bin/desk-server.mjs +473 -0
  9. package/bin/oracle-data-mcp.mjs +1252 -0
  10. package/bin/oracle-equities.mjs +168 -0
  11. package/bin/oracle-init.mjs +525 -0
  12. package/bin/oracle-public-server.mjs +36 -0
  13. package/bin/oracle-route.mjs +254 -0
  14. package/bin/oracle-scan.mjs +192 -0
  15. package/bin/oracle-upgrade.mjs +42 -0
  16. package/bin/oracle.mjs +28 -19
  17. package/docs/adding-a-chain.md +229 -0
  18. package/docs/architecture.md +139 -0
  19. package/docs/buzz-integration.md +115 -0
  20. package/docs/cli.md +143 -0
  21. package/docs/connectors.md +13 -0
  22. package/docs/hyperliquid-builder-code.md +50 -0
  23. package/docs/locals-only-fee-waiver.md +34 -0
  24. package/docs/oracle-pack-standard.md +29 -0
  25. package/docs/profiles.md +151 -0
  26. package/docs/public-surface.md +206 -0
  27. package/examples/add-a-chain.mjs +65 -0
  28. package/examples/oracle-pack-template.mjs +38 -0
  29. package/examples/research-a-token.mjs +70 -0
  30. package/package.json +110 -14
  31. package/plugins/oracle-owner-gate/__init__.py +288 -0
  32. package/plugins/oracle-owner-gate/plugin.yaml +9 -0
  33. package/profiles/_template/SOUL.md +54 -0
  34. package/profiles/_template/profile.json +22 -0
  35. package/profiles/bitcoin-agent/SOUL.md +31 -0
  36. package/profiles/bitcoin-agent/profile.json +32 -0
  37. package/profiles/hyperliquid-agent/SOUL.md +34 -0
  38. package/profiles/hyperliquid-agent/profile.json +38 -0
  39. package/profiles/oracle/SOUL.md +120 -0
  40. package/profiles/oracle/profile.json +40 -0
  41. package/profiles/polymarket-agent/SOUL.md +35 -0
  42. package/profiles/polymarket-agent/profile.json +34 -0
  43. package/profiles/profile.schema.json +90 -0
  44. package/profiles/protocol-builder/SOUL.md +57 -0
  45. package/profiles/protocol-builder/profile.json +39 -0
  46. package/profiles/robinhood-agent/SOUL.md +53 -0
  47. package/profiles/robinhood-agent/profile.json +41 -0
  48. package/profiles/solana-agent/SOUL.md +37 -0
  49. package/profiles/solana-agent/profile.json +38 -0
  50. package/profiles/stable-agent/SOUL.md +43 -0
  51. package/profiles/stable-agent/profile.json +38 -0
  52. package/protocols/templates/safe-erc20/SECURITY.md +16 -0
  53. package/protocols/templates/safe-erc20/foundry.toml +12 -0
  54. package/protocols/templates/safe-erc20/remappings.txt +2 -0
  55. package/protocols/templates/safe-erc20/src/SafeERC20.sol +53 -0
  56. package/protocols/templates/safe-erc20/test/SafeERC20.t.sol +72 -0
  57. package/public/agent-connect/app.js +84 -0
  58. package/public/agent-connect/index.html +83 -0
  59. package/public/agent-connect/styles.css +70 -0
  60. package/public/index.html +12 -0
  61. package/public/oracle-console/app.js +272 -0
  62. package/public/oracle-console/bitcoin-wallets.js +206 -0
  63. package/public/oracle-console/index.html +91 -0
  64. package/public/oracle-console/styles.css +239 -0
  65. package/public/oracle-splash/_variants/ice.html +2073 -0
  66. package/public/oracle-splash/_variants/ivory.html +2075 -0
  67. package/public/oracle-splash/assets/agents/claude.png +0 -0
  68. package/public/oracle-splash/assets/agents/codex.png +0 -0
  69. package/public/oracle-splash/assets/cli-chain-hyperliquid.jpg +0 -0
  70. package/public/oracle-splash/assets/desktop-app.jpg +0 -0
  71. package/public/oracle-splash/assets/hero/cli-session-poster.jpg +0 -0
  72. package/public/oracle-splash/assets/hero/cli-session.mp4 +0 -0
  73. package/public/oracle-splash/assets/hero/cli-session.webm +0 -0
  74. package/public/oracle-splash/assets/hero/orb-poster.jpg +0 -0
  75. package/public/oracle-splash/assets/hero/orb.avif +0 -0
  76. package/public/oracle-splash/assets/hero/orb.webm +0 -0
  77. package/public/oracle-splash/assets/hero/risk-session-poster.jpg +0 -0
  78. package/public/oracle-splash/assets/hero/risk-session.mp4 +0 -0
  79. package/public/oracle-splash/assets/hero/risk-session.webm +0 -0
  80. package/public/oracle-splash/assets/hero/route-session-poster.jpg +0 -0
  81. package/public/oracle-splash/assets/hero/route-session.mp4 +0 -0
  82. package/public/oracle-splash/assets/hero/route-session.webm +0 -0
  83. package/public/oracle-splash/assets/llms/claude.svg +1 -0
  84. package/public/oracle-splash/assets/llms/codex-icon.svg +1 -0
  85. package/public/oracle-splash/assets/llms/codex.svg +1 -0
  86. package/public/oracle-splash/assets/llms/cursor-icon.svg +12 -0
  87. package/public/oracle-splash/assets/llms/cursor.svg +17 -0
  88. package/public/oracle-splash/assets/llms/deepseek.svg +1 -0
  89. package/public/oracle-splash/assets/llms/gemini-icon.svg +1 -0
  90. package/public/oracle-splash/assets/llms/gemini.svg +1 -0
  91. package/public/oracle-splash/assets/llms/grok.svg +8 -0
  92. package/public/oracle-splash/assets/llms/hermes.png +0 -0
  93. package/public/oracle-splash/assets/llms/kimi-icon.svg +1 -0
  94. package/public/oracle-splash/assets/llms/kimi.svg +1 -0
  95. package/public/oracle-splash/assets/llms/manus.svg +18 -0
  96. package/public/oracle-splash/assets/llms/openclaw.svg +22 -0
  97. package/public/oracle-splash/assets/llms/perplexity.svg +1 -0
  98. package/public/oracle-splash/assets/llms/qwen.svg +1 -0
  99. package/public/oracle-splash/assets/llms/windsurf.svg +1 -0
  100. package/public/oracle-splash/assets/protocols/abcdex.png +0 -0
  101. package/public/oracle-splash/assets/protocols/across.png +0 -0
  102. package/public/oracle-splash/assets/protocols/aerodrome.png +0 -0
  103. package/public/oracle-splash/assets/protocols/balancer.png +0 -0
  104. package/public/oracle-splash/assets/protocols/cowswap.png +0 -0
  105. package/public/oracle-splash/assets/protocols/curve.png +0 -0
  106. package/public/oracle-splash/assets/protocols/dreamcash.png +0 -0
  107. package/public/oracle-splash/assets/protocols/felix.png +0 -0
  108. package/public/oracle-splash/assets/protocols/gmx.png +0 -0
  109. package/public/oracle-splash/assets/protocols/hyena.png +0 -0
  110. package/public/oracle-splash/assets/protocols/hyperbeat.png +0 -0
  111. package/public/oracle-splash/assets/protocols/hyperliquid.png +0 -0
  112. package/public/oracle-splash/assets/protocols/hyperswap.png +0 -0
  113. package/public/oracle-splash/assets/protocols/jupiter.png +0 -0
  114. package/public/oracle-splash/assets/protocols/kinetiq.png +0 -0
  115. package/public/oracle-splash/assets/protocols/lfj.png +0 -0
  116. package/public/oracle-splash/assets/protocols/lifi.png +0 -0
  117. package/public/oracle-splash/assets/protocols/magic-eden.png +0 -0
  118. package/public/oracle-splash/assets/protocols/morpho.png +0 -0
  119. package/public/oracle-splash/assets/protocols/odos.png +0 -0
  120. package/public/oracle-splash/assets/protocols/oneinch.png +0 -0
  121. package/public/oracle-splash/assets/protocols/opensea.png +0 -0
  122. package/public/oracle-splash/assets/protocols/pancakeswap.png +0 -0
  123. package/public/oracle-splash/assets/protocols/paragon.png +0 -0
  124. package/public/oracle-splash/assets/protocols/paraswap.png +0 -0
  125. package/public/oracle-splash/assets/protocols/pendle.png +0 -0
  126. package/public/oracle-splash/assets/protocols/polymarket.png +0 -0
  127. package/public/oracle-splash/assets/protocols/quickswap.png +0 -0
  128. package/public/oracle-splash/assets/protocols/relay.png +0 -0
  129. package/public/oracle-splash/assets/protocols/stargate.png +0 -0
  130. package/public/oracle-splash/assets/protocols/tradexyz.png +0 -0
  131. package/public/oracle-splash/assets/protocols/uniswap.png +0 -0
  132. package/public/oracle-splash/assets/protocols/velodrome.png +0 -0
  133. package/public/oracle-splash/assets/protocols/ventuals.png +0 -0
  134. package/public/oracle-splash/assets/wordmarks/across-icon.webp +0 -0
  135. package/public/oracle-splash/assets/wordmarks/across.svg +4 -0
  136. package/public/oracle-splash/assets/wordmarks/aerodrome.svg +23 -0
  137. package/public/oracle-splash/assets/wordmarks/balancer.svg +3 -0
  138. package/public/oracle-splash/assets/wordmarks/cowswap.svg +1 -0
  139. package/public/oracle-splash/assets/wordmarks/curve.png +0 -0
  140. package/public/oracle-splash/assets/wordmarks/gmx.svg +13 -0
  141. package/public/oracle-splash/assets/wordmarks/hop-icon.webp +0 -0
  142. package/public/oracle-splash/assets/wordmarks/hyena.svg +7 -0
  143. package/public/oracle-splash/assets/wordmarks/hyperliquid.svg +21 -0
  144. package/public/oracle-splash/assets/wordmarks/hyperswap.svg +13 -0
  145. package/public/oracle-splash/assets/wordmarks/jupiter.svg +35 -0
  146. package/public/oracle-splash/assets/wordmarks/kinetiq.svg +1 -0
  147. package/public/oracle-splash/assets/wordmarks/lfj.webp +0 -0
  148. package/public/oracle-splash/assets/wordmarks/lifi.png +0 -0
  149. package/public/oracle-splash/assets/wordmarks/magic-eden.svg +1 -0
  150. package/public/oracle-splash/assets/wordmarks/markets.svg +1 -0
  151. package/public/oracle-splash/assets/wordmarks/morpho.svg +1 -0
  152. package/public/oracle-splash/assets/wordmarks/odos.svg +3 -0
  153. package/public/oracle-splash/assets/wordmarks/oneinch-icon.webp +0 -0
  154. package/public/oracle-splash/assets/wordmarks/oneinch.svg +6 -0
  155. package/public/oracle-splash/assets/wordmarks/opensea-icon.svg +17 -0
  156. package/public/oracle-splash/assets/wordmarks/opensea.svg +1 -0
  157. package/public/oracle-splash/assets/wordmarks/outcome.svg +16 -0
  158. package/public/oracle-splash/assets/wordmarks/pancakeswap.svg +18 -0
  159. package/public/oracle-splash/assets/wordmarks/paragon.svg +9 -0
  160. package/public/oracle-splash/assets/wordmarks/paraswap.svg +16 -0
  161. package/public/oracle-splash/assets/wordmarks/pendle.png +0 -0
  162. package/public/oracle-splash/assets/wordmarks/polymarket.png +0 -0
  163. package/public/oracle-splash/assets/wordmarks/quickswap.png +0 -0
  164. package/public/oracle-splash/assets/wordmarks/relay.svg +8 -0
  165. package/public/oracle-splash/assets/wordmarks/satflow-icon.png +0 -0
  166. package/public/oracle-splash/assets/wordmarks/stargate-icon.webp +0 -0
  167. package/public/oracle-splash/assets/wordmarks/stargate.svg +15 -0
  168. package/public/oracle-splash/assets/wordmarks/uniswap.svg +18 -0
  169. package/public/oracle-splash/assets/wordmarks/velodrome.svg +84 -0
  170. package/public/oracle-splash/assets/wordmarks/xyz.svg +12 -0
  171. package/public/oracle-splash/assets/wordmarks/zerox-icon.webp +0 -0
  172. package/public/oracle-splash/brand/aave.webp +0 -0
  173. package/public/oracle-splash/brand/aavev2.webp +0 -0
  174. package/public/oracle-splash/brand/aborean.webp +0 -0
  175. package/public/oracle-splash/brand/across.webp +0 -0
  176. package/public/oracle-splash/brand/aerodrome.webp +0 -0
  177. package/public/oracle-splash/brand/afi.webp +0 -0
  178. package/public/oracle-splash/brand/arcus.webp +0 -0
  179. package/public/oracle-splash/brand/aster.webp +0 -0
  180. package/public/oracle-splash/brand/avant.webp +0 -0
  181. package/public/oracle-splash/brand/balancer.webp +0 -0
  182. package/public/oracle-splash/brand/beefy.webp +0 -0
  183. package/public/oracle-splash/brand/benqi.webp +0 -0
  184. package/public/oracle-splash/brand/bestinslot.ico +0 -0
  185. package/public/oracle-splash/brand/bitfi.webp +0 -0
  186. package/public/oracle-splash/brand/bonkswap.webp +0 -0
  187. package/public/oracle-splash/brand/bouncebit.webp +0 -0
  188. package/public/oracle-splash/brand/camelot.webp +0 -0
  189. package/public/oracle-splash/brand/compound.webp +0 -0
  190. package/public/oracle-splash/brand/concrete.webp +0 -0
  191. package/public/oracle-splash/brand/cow.webp +0 -0
  192. package/public/oracle-splash/brand/curve.webp +0 -0
  193. package/public/oracle-splash/brand/derive.webp +0 -0
  194. package/public/oracle-splash/brand/dolomite.webp +0 -0
  195. package/public/oracle-splash/brand/eigenlayer.webp +0 -0
  196. package/public/oracle-splash/brand/ekubo.webp +0 -0
  197. package/public/oracle-splash/brand/ethena.webp +0 -0
  198. package/public/oracle-splash/brand/etherfi.webp +0 -0
  199. package/public/oracle-splash/brand/etherfiborrow.webp +0 -0
  200. package/public/oracle-splash/brand/felix.webp +0 -0
  201. package/public/oracle-splash/brand/fluid.webp +0 -0
  202. package/public/oracle-splash/brand/fluxbeam.webp +0 -0
  203. package/public/oracle-splash/brand/folks.webp +0 -0
  204. package/public/oracle-splash/brand/fortyacres.webp +0 -0
  205. package/public/oracle-splash/brand/gainsnetwork.webp +0 -0
  206. package/public/oracle-splash/brand/gassss.webp +0 -0
  207. package/public/oracle-splash/brand/gmx.webp +0 -0
  208. package/public/oracle-splash/brand/harmonix.webp +0 -0
  209. package/public/oracle-splash/brand/hlorderbook.webp +0 -0
  210. package/public/oracle-splash/brand/hlp.webp +0 -0
  211. package/public/oracle-splash/brand/hop.webp +0 -0
  212. package/public/oracle-splash/brand/hyperbeat.webp +0 -0
  213. package/public/oracle-splash/brand/hyperlend.webp +0 -0
  214. package/public/oracle-splash/brand/hyperliquid.webp +0 -0
  215. package/public/oracle-splash/brand/hyperliquidhpl.webp +0 -0
  216. package/public/oracle-splash/brand/hyperliquidspot.webp +0 -0
  217. package/public/oracle-splash/brand/hyperswap.webp +0 -0
  218. package/public/oracle-splash/brand/hypha.webp +0 -0
  219. package/public/oracle-splash/brand/joedex.webp +0 -0
  220. package/public/oracle-splash/brand/jupiter.webp +0 -0
  221. package/public/oracle-splash/brand/kelp.webp +0 -0
  222. package/public/oracle-splash/brand/kinetiq.webp +0 -0
  223. package/public/oracle-splash/brand/kmhype.webp +0 -0
  224. package/public/oracle-splash/brand/kona.webp +0 -0
  225. package/public/oracle-splash/brand/konalend.webp +0 -0
  226. package/public/oracle-splash/brand/lfj.webp +0 -0
  227. package/public/oracle-splash/brand/lido.webp +0 -0
  228. package/public/oracle-splash/brand/lifi.webp +0 -0
  229. package/public/oracle-splash/brand/lighter.webp +0 -0
  230. package/public/oracle-splash/brand/lista.webp +0 -0
  231. package/public/oracle-splash/brand/loopedhype.webp +0 -0
  232. package/public/oracle-splash/brand/lorenzo.webp +0 -0
  233. package/public/oracle-splash/brand/magic-eden.webp +0 -0
  234. package/public/oracle-splash/brand/magiceden.webp +0 -0
  235. package/public/oracle-splash/brand/mempool.png +0 -0
  236. package/public/oracle-splash/brand/meteora.webp +0 -0
  237. package/public/oracle-splash/brand/morpho.webp +0 -0
  238. package/public/oracle-splash/brand/myriad.webp +0 -0
  239. package/public/oracle-splash/brand/noxa.webp +0 -0
  240. package/public/oracle-splash/brand/odos.webp +0 -0
  241. package/public/oracle-splash/brand/oneinch.webp +0 -0
  242. package/public/oracle-splash/brand/openbook.webp +0 -0
  243. package/public/oracle-splash/brand/opensea.webp +0 -0
  244. package/public/oracle-splash/brand/orca.webp +0 -0
  245. package/public/oracle-splash/brand/ordinals.png +0 -0
  246. package/public/oracle-splash/brand/ostium.webp +0 -0
  247. package/public/oracle-splash/brand/pancakeswap.webp +0 -0
  248. package/public/oracle-splash/brand/pendle.webp +0 -0
  249. package/public/oracle-splash/brand/perena.webp +0 -0
  250. package/public/oracle-splash/brand/pharaoh.webp +0 -0
  251. package/public/oracle-splash/brand/phoenix.webp +0 -0
  252. package/public/oracle-splash/brand/polymarket.webp +0 -0
  253. package/public/oracle-splash/brand/polynomial.webp +0 -0
  254. package/public/oracle-splash/brand/projectx.webp +0 -0
  255. package/public/oracle-splash/brand/pumpfun.webp +0 -0
  256. package/public/oracle-splash/brand/quickswap.webp +0 -0
  257. package/public/oracle-splash/brand/rain.webp +0 -0
  258. package/public/oracle-splash/brand/raydium.webp +0 -0
  259. package/public/oracle-splash/brand/relay.webp +0 -0
  260. package/public/oracle-splash/brand/rocketpool.webp +0 -0
  261. package/public/oracle-splash/brand/saber.webp +0 -0
  262. package/public/oracle-splash/brand/sakuraswap.webp +0 -0
  263. package/public/oracle-splash/brand/sanctum.webp +0 -0
  264. package/public/oracle-splash/brand/satflow.png +0 -0
  265. package/public/oracle-splash/brand/sierra.webp +0 -0
  266. package/public/oracle-splash/brand/sky.webp +0 -0
  267. package/public/oracle-splash/brand/solv.webp +0 -0
  268. package/public/oracle-splash/brand/spark.webp +0 -0
  269. package/public/oracle-splash/brand/sparksavings.webp +0 -0
  270. package/public/oracle-splash/brand/sphere.webp +0 -0
  271. package/public/oracle-splash/brand/ssv.webp +0 -0
  272. package/public/oracle-splash/brand/stabble.webp +0 -0
  273. package/public/oracle-splash/brand/stableswap.webp +0 -0
  274. package/public/oracle-splash/brand/stakewise.webp +0 -0
  275. package/public/oracle-splash/brand/stargate.webp +0 -0
  276. package/public/oracle-splash/brand/sthype.webp +0 -0
  277. package/public/oracle-splash/brand/sushiswap.webp +0 -0
  278. package/public/oracle-splash/brand/unisat.png +0 -0
  279. package/public/oracle-splash/brand/uniswap.webp +0 -0
  280. package/public/oracle-splash/brand/uniswapv2.webp +0 -0
  281. package/public/oracle-splash/brand/uniswapv4.webp +0 -0
  282. package/public/oracle-splash/brand/unit.webp +0 -0
  283. package/public/oracle-splash/brand/velodrome.webp +0 -0
  284. package/public/oracle-splash/brand/velora.webp +0 -0
  285. package/public/oracle-splash/brand/venus.webp +0 -0
  286. package/public/oracle-splash/brand/wbeth.webp +0 -0
  287. package/public/oracle-splash/brand/xsy.webp +0 -0
  288. package/public/oracle-splash/brand/yieldyak.webp +0 -0
  289. package/public/oracle-splash/brand/zerobase.webp +0 -0
  290. package/public/oracle-splash/brand/zerox.webp +0 -0
  291. package/public/oracle-splash/downloads/index.html +52 -0
  292. package/public/oracle-splash/favicon.ico +0 -0
  293. package/public/oracle-splash/favicon.svg +6 -0
  294. package/public/oracle-splash/index.html +2537 -0
  295. package/public/oracle-splash/mesh-graph.png +0 -0
  296. package/public/oracle-splash/mesh-graph.svg +216 -0
  297. package/scripts/adversarial-bench.mjs +114 -0
  298. package/scripts/build-dist.mjs +119 -0
  299. package/scripts/build-inscription.py +230 -0
  300. package/scripts/check-doc-drift.mjs +123 -0
  301. package/scripts/check-test-count.mjs +105 -0
  302. package/scripts/e2e-hl-markets.mjs +21 -0
  303. package/scripts/e2e-hl-perps.mjs +48 -0
  304. package/scripts/e2e-hypercore-staking.mjs +128 -0
  305. package/scripts/e2e-solana-bitcoin.mjs +183 -0
  306. package/scripts/guard-publish.mjs +22 -0
  307. package/scripts/protocol-template-gate.mjs +15 -0
  308. package/scripts/public-api-scan.mjs +23 -0
  309. package/scripts/publish-dist.mjs +67 -0
  310. package/scripts/record-hero-cli.sh +80 -0
  311. package/scripts/secret-scan.mjs +168 -0
  312. package/scripts/smoke-dist-bins.mjs +89 -0
  313. package/scripts/verify-dist.mjs +29 -0
  314. package/scripts/verify-v3-venues.mjs +233 -0
  315. package/skills/balance/SKILL.md +176 -0
  316. package/skills/bitcoin-l1.md +33 -0
  317. package/skills/chain-defi-ecosystem-profiling.md +27 -0
  318. package/skills/evm-contract-research.md +27 -0
  319. package/skills/hyperliquid.md +26 -0
  320. package/skills/multichain-exec-desk.md +33 -0
  321. package/skills/oracle-action-semantics/SKILL.md +40 -0
  322. package/skills/oracle-best-execution/SKILL.md +127 -0
  323. package/skills/oracle-best-execution.md +27 -0
  324. package/skills/oracle-bitcoin/SKILL.md +53 -0
  325. package/skills/oracle-chain-graphs-telegram-cards/SKILL.md +59 -0
  326. package/skills/oracle-chat/SKILL.md +61 -0
  327. package/skills/oracle-chat/chain.SKILL.md +31 -0
  328. package/skills/oracle-chat/setup.SKILL.md +37 -0
  329. package/skills/oracle-circuit-breaker/SKILL.md +51 -0
  330. package/skills/oracle-contract-research/SKILL.md +55 -0
  331. package/skills/oracle-desk/SKILL.md +58 -0
  332. package/skills/oracle-desk.md +27 -0
  333. package/skills/oracle-dex-launch/SKILL.md +38 -0
  334. package/skills/oracle-equities/SKILL.md +62 -0
  335. package/skills/oracle-grants/SKILL.md +69 -0
  336. package/skills/oracle-hypercore-staking/SKILL.md +57 -0
  337. package/skills/oracle-hyperliquid/SKILL.md +56 -0
  338. package/skills/oracle-meme-token-sniper/SKILL.md +73 -0
  339. package/skills/oracle-multichain-nft-launch/SKILL.md +338 -0
  340. package/skills/oracle-multichain-token-launch/SKILL.md +300 -0
  341. package/skills/oracle-nft-gacha-launch/SKILL.md +48 -0
  342. package/skills/oracle-nft-mint-gas-war/SKILL.md +63 -0
  343. package/skills/oracle-polymarket/SKILL.md +60 -0
  344. package/skills/oracle-protocol-builder/SKILL.md +59 -0
  345. package/skills/oracle-protocol-security/SKILL.md +60 -0
  346. package/skills/oracle-public-product/SKILL.md +44 -0
  347. package/skills/oracle-receipts/SKILL.md +52 -0
  348. package/skills/oracle-receipts.md +29 -0
  349. package/skills/oracle-rfq-tokenized-assets/SKILL.md +69 -0
  350. package/skills/oracle-smart-wallet-scanner/SKILL.md +49 -0
  351. package/skills/oracle-solana/SKILL.md +65 -0
  352. package/skills/oracle-solana-nft/SKILL.md +54 -0
  353. package/skills/oracle-token-research/SKILL.md +67 -0
  354. package/skills/solana.md +22 -0
  355. package/skins/oracle.yaml +56 -0
  356. package/src/action-receipts.mjs +265 -0
  357. package/src/action-semantics.mjs +62 -0
  358. package/src/address-book.mjs +208 -0
  359. package/src/agent-auth.mjs +206 -0
  360. package/src/approval-guard.mjs +282 -0
  361. package/src/attestation-secret.mjs +94 -0
  362. package/src/audit-log.mjs +196 -0
  363. package/src/auth/oauth.mjs +672 -0
  364. package/src/auto-slippage.mjs +378 -0
  365. package/src/capability-posture.mjs +125 -0
  366. package/src/cards.mjs +422 -0
  367. package/src/chains.mjs +62 -0
  368. package/src/cli/chain-catalog.mjs +215 -0
  369. package/src/cli/chain-state.mjs +74 -0
  370. package/src/cli/commands/auth.mjs +193 -0
  371. package/src/cli/commands/bootstrap.mjs +87 -0
  372. package/src/cli/commands/chain.mjs +143 -0
  373. package/src/cli/commands/chat.mjs +465 -0
  374. package/src/cli/commands/credential.mjs +9 -0
  375. package/src/cli/commands/data-mcp.mjs +18 -0
  376. package/src/cli/commands/data.mjs +75 -0
  377. package/src/cli/commands/doctor.mjs +136 -0
  378. package/src/cli/commands/equities.mjs +41 -0
  379. package/src/cli/commands/farm.mjs +129 -0
  380. package/src/cli/commands/fees.mjs +109 -0
  381. package/src/cli/commands/follow.mjs +130 -0
  382. package/src/cli/commands/harness.mjs +63 -0
  383. package/src/cli/commands/help.mjs +7 -0
  384. package/src/cli/commands/init.mjs +27 -0
  385. package/src/cli/commands/mcp.mjs +154 -0
  386. package/src/cli/commands/model.mjs +106 -0
  387. package/src/cli/commands/plugins.mjs +241 -0
  388. package/src/cli/commands/prepare.mjs +12 -0
  389. package/src/cli/commands/public.mjs +20 -0
  390. package/src/cli/commands/resolve.mjs +64 -0
  391. package/src/cli/commands/route.mjs +12 -0
  392. package/src/cli/commands/runner.mjs +9 -0
  393. package/src/cli/commands/scan.mjs +12 -0
  394. package/src/cli/commands/setup.mjs +294 -0
  395. package/src/cli/commands/sign.mjs +21 -0
  396. package/src/cli/commands/signer.mjs +9 -0
  397. package/src/cli/commands/swap.mjs +102 -0
  398. package/src/cli/commands/upgrade.mjs +12 -0
  399. package/src/cli/commands/vault.mjs +9 -0
  400. package/src/cli/commands/version.mjs +22 -0
  401. package/src/cli/first-run.mjs +23 -0
  402. package/src/cli/kernel.mjs +262 -0
  403. package/src/cli/mcp-targets/chatgpt.mjs +51 -0
  404. package/src/cli/mcp-targets/claude-code.mjs +39 -0
  405. package/src/cli/mcp-targets/claude-desktop.mjs +24 -0
  406. package/src/cli/mcp-targets/codex.mjs +41 -0
  407. package/src/cli/mcp-targets/cursor.mjs +32 -0
  408. package/src/cli/mcp-targets/shared.mjs +71 -0
  409. package/src/cli/mcp-targets/vscode.mjs +39 -0
  410. package/src/cli/messaging-platforms.mjs +217 -0
  411. package/src/cli/model-config.mjs +78 -0
  412. package/src/cli/operator-dispatch.mjs +257 -0
  413. package/src/cli/oracle-harness.py +415 -0
  414. package/src/cli/paths.mjs +107 -0
  415. package/src/cli/runtime.mjs +351 -0
  416. package/src/cli/setup-state.mjs +168 -0
  417. package/src/cli/spawn-child.mjs +43 -0
  418. package/src/data/catalog.mjs +858 -0
  419. package/src/data/desk-data.mjs +877 -0
  420. package/src/data/http.mjs +253 -0
  421. package/src/data/names.mjs +188 -0
  422. package/src/data/provider-endpoint.mjs +94 -0
  423. package/src/data/providers/aave-v3.mjs +139 -0
  424. package/src/data/providers/across-bridge.mjs +41 -0
  425. package/src/data/providers/aerodrome.mjs +245 -0
  426. package/src/data/providers/aevo.mjs +33 -0
  427. package/src/data/providers/approval-indexer.mjs +133 -0
  428. package/src/data/providers/approvals.mjs +594 -0
  429. package/src/data/providers/babylon-staking.mjs +149 -0
  430. package/src/data/providers/balancer.mjs +209 -0
  431. package/src/data/providers/beefy-yields.mjs +45 -0
  432. package/src/data/providers/birdeye-tokens.mjs +33 -0
  433. package/src/data/providers/bisq-markets.mjs +145 -0
  434. package/src/data/providers/bitcoin-esplora.mjs +216 -0
  435. package/src/data/providers/bitcoin-meta.mjs +378 -0
  436. package/src/data/providers/blockscout.mjs +14 -0
  437. package/src/data/providers/bob-rootstock.mjs +198 -0
  438. package/src/data/providers/braiins-insights.mjs +103 -0
  439. package/src/data/providers/bridge-aggregator.mjs +259 -0
  440. package/src/data/providers/bridges.mjs +242 -0
  441. package/src/data/providers/bungee.mjs +29 -0
  442. package/src/data/providers/celestia-da.mjs +38 -0
  443. package/src/data/providers/changenow.mjs +135 -0
  444. package/src/data/providers/compound.mjs +32 -0
  445. package/src/data/providers/connext.mjs +28 -0
  446. package/src/data/providers/convex.mjs +30 -0
  447. package/src/data/providers/cow-protocol.mjs +110 -0
  448. package/src/data/providers/cowswap.mjs +415 -0
  449. package/src/data/providers/curve.mjs +201 -0
  450. package/src/data/providers/das-assets.mjs +59 -0
  451. package/src/data/providers/debridge.mjs +109 -0
  452. package/src/data/providers/defillama.mjs +88 -0
  453. package/src/data/providers/dexscreener.mjs +43 -0
  454. package/src/data/providers/drift.mjs +32 -0
  455. package/src/data/providers/dydx.mjs +41 -0
  456. package/src/data/providers/evm-rpc.mjs +225 -0
  457. package/src/data/providers/farming.mjs +291 -0
  458. package/src/data/providers/geckoterminal.mjs +34 -0
  459. package/src/data/providers/gmx.mjs +496 -0
  460. package/src/data/providers/hiro-stacks.mjs +150 -0
  461. package/src/data/providers/hl-assets.mjs +165 -0
  462. package/src/data/providers/hl-info.mjs +108 -0
  463. package/src/data/providers/hl-markets.mjs +210 -0
  464. package/src/data/providers/hl-outcome.mjs +61 -0
  465. package/src/data/providers/hl-perps.mjs +419 -0
  466. package/src/data/providers/hl-staking.mjs +353 -0
  467. package/src/data/providers/hl-ws.mjs +119 -0
  468. package/src/data/providers/hyperevm-dex.mjs +49 -0
  469. package/src/data/providers/jito-mev.mjs +117 -0
  470. package/src/data/providers/jupiter-venues.mjs +119 -0
  471. package/src/data/providers/jupiter.mjs +315 -0
  472. package/src/data/providers/kamino-strategies.mjs +143 -0
  473. package/src/data/providers/l2beat-tvl.mjs +42 -0
  474. package/src/data/providers/lifi.mjs +166 -0
  475. package/src/data/providers/liquid-esplora.mjs +152 -0
  476. package/src/data/providers/magiceden-ordinals.mjs +141 -0
  477. package/src/data/providers/magiceden-sol.mjs +406 -0
  478. package/src/data/providers/mempool-lightning.mjs +144 -0
  479. package/src/data/providers/mempool-mining.mjs +142 -0
  480. package/src/data/providers/meteora-dlmm.mjs +168 -0
  481. package/src/data/providers/morpho.mjs +177 -0
  482. package/src/data/providers/nft-gallery.mjs +163 -0
  483. package/src/data/providers/nft-portfolio.mjs +494 -0
  484. package/src/data/providers/odos.mjs +156 -0
  485. package/src/data/providers/ondo.mjs +31 -0
  486. package/src/data/providers/oneinch.mjs +174 -0
  487. package/src/data/providers/opensea-multichain.mjs +136 -0
  488. package/src/data/providers/opensea-nft.mjs +371 -0
  489. package/src/data/providers/orca.mjs +29 -0
  490. package/src/data/providers/ordinals-runes.mjs +180 -0
  491. package/src/data/providers/pancakeswap.mjs +28 -0
  492. package/src/data/providers/paraswap.mjs +125 -0
  493. package/src/data/providers/pendle.mjs +188 -0
  494. package/src/data/providers/poly-clob.mjs +283 -0
  495. package/src/data/providers/poly-public.mjs +96 -0
  496. package/src/data/providers/poly-ws.mjs +103 -0
  497. package/src/data/providers/polygon-staking.mjs +227 -0
  498. package/src/data/providers/portfolio-history.mjs +394 -0
  499. package/src/data/providers/portfolio.mjs +600 -0
  500. package/src/data/providers/pyth-price-feeds.mjs +172 -0
  501. package/src/data/providers/raydium.mjs +35 -0
  502. package/src/data/providers/relayscan-mev.mjs +72 -0
  503. package/src/data/providers/rfq.mjs +15 -0
  504. package/src/data/providers/rh-agent.mjs +59 -0
  505. package/src/data/providers/sanctum-lst.mjs +180 -0
  506. package/src/data/providers/satflow.mjs +341 -0
  507. package/src/data/providers/signed-material-guard.mjs +108 -0
  508. package/src/data/providers/solana-rpc.mjs +197 -0
  509. package/src/data/providers/solend-lending.mjs +166 -0
  510. package/src/data/providers/spark-lend.mjs +42 -0
  511. package/src/data/providers/squid-router.mjs +29 -0
  512. package/src/data/providers/stargate.mjs +29 -0
  513. package/src/data/providers/sushiswap.mjs +30 -0
  514. package/src/data/providers/symbiotic-restaking.mjs +41 -0
  515. package/src/data/providers/thorchain.mjs +36 -0
  516. package/src/data/providers/traderjoe.mjs +28 -0
  517. package/src/data/providers/twap.mjs +152 -0
  518. package/src/data/providers/uniswap-v3.mjs +457 -0
  519. package/src/data/providers/uniswap-v4.mjs +414 -0
  520. package/src/data/providers/vertex.mjs +41 -0
  521. package/src/data/providers/wallet-watch.mjs +264 -0
  522. package/src/data/providers/wormhole.mjs +28 -0
  523. package/src/data/providers/yearn.mjs +31 -0
  524. package/src/data/providers/zerox.mjs +167 -0
  525. package/src/data/public-api-scan.mjs +61 -0
  526. package/src/data/quote-placeholder.mjs +31 -0
  527. package/src/desk/swap-prepare.mjs +194 -0
  528. package/src/equities/bridge.mjs +388 -0
  529. package/src/equities/fixtures/bridge_routes.json +159 -0
  530. package/src/equities/fixtures/dst_transitions.json +29 -0
  531. package/src/equities/fixtures/equity_dex_pools.json +154 -0
  532. package/src/equities/fixtures/hip3_l2books.json +2711 -0
  533. package/src/equities/fixtures/nyse_holidays.json +1 -0
  534. package/src/equities/fixtures/oracles.json +100 -0
  535. package/src/equities/fixtures/rh_pool_state.json +244 -0
  536. package/src/equities/fixtures/solana_xstocks.json +704 -0
  537. package/src/equities/fixtures/ton_xstocks.json +35 -0
  538. package/src/equities/fixtures/universe.json +411 -0
  539. package/src/equities/fixtures/venues.json +3542 -0
  540. package/src/equities/fixtures.mjs +405 -0
  541. package/src/equities/funding.mjs +142 -0
  542. package/src/equities/index.mjs +166 -0
  543. package/src/equities/liveness.mjs +148 -0
  544. package/src/equities/marketHours.mjs +249 -0
  545. package/src/equities/normalize.mjs +295 -0
  546. package/src/equities/num.mjs +146 -0
  547. package/src/equities/prepare.mjs +95 -0
  548. package/src/equities/rank.mjs +260 -0
  549. package/src/equities/sourceNum.mjs +69 -0
  550. package/src/equities/types.mjs +220 -0
  551. package/src/equities/venues/arcus-perp.mjs +84 -0
  552. package/src/equities/venues/arcus-spot.mjs +105 -0
  553. package/src/equities/venues/hyperliquid-hip3.mjs +224 -0
  554. package/src/equities/venues/rh-uniswap.mjs +216 -0
  555. package/src/equities/venues/solana-xstocks.mjs +139 -0
  556. package/src/equities/venues/ton-stonfi.mjs +139 -0
  557. package/src/exact-integer.mjs +72 -0
  558. package/src/exec-policy.mjs +419 -0
  559. package/src/flags.mjs +15 -0
  560. package/src/fresh-window.mjs +76 -0
  561. package/src/gmx-attestation.mjs +176 -0
  562. package/src/index.mjs +107 -0
  563. package/src/licensing/locals-only.mjs +25 -0
  564. package/src/nft-gas-war-guard.mjs +139 -0
  565. package/src/onboarding/agent-keys.mjs +161 -0
  566. package/src/onboarding/harness-configs.mjs +102 -0
  567. package/src/onboarding/index.mjs +18 -0
  568. package/src/onboarding/tiers.mjs +139 -0
  569. package/src/oracle-env.mjs +55 -0
  570. package/src/package-manifest.mjs +42 -0
  571. package/src/plugins/agent-plugin-loader.mjs +225 -0
  572. package/src/portfolio-risk.mjs +170 -0
  573. package/src/prepare-envelope.mjs +204 -0
  574. package/src/profile-upgrade.mjs +277 -0
  575. package/src/protocol-execution.mjs +84 -0
  576. package/src/protocol-templates/gate.mjs +179 -0
  577. package/src/protocol-templates/prepare-deploy.mjs +81 -0
  578. package/src/public-api/agent-grants.mjs +57 -0
  579. package/src/public-api/buzz-integration.mjs +267 -0
  580. package/src/public-api/connect-agent.mjs +424 -0
  581. package/src/public-api/grants.mjs +142 -0
  582. package/src/public-api/http.mjs +707 -0
  583. package/src/public-api/metering.mjs +111 -0
  584. package/src/public-control/aa-adapter.mjs +402 -0
  585. package/src/public-control/build-registry.mjs +227 -0
  586. package/src/public-control/bundler-client.mjs +357 -0
  587. package/src/public-control/grant-indexer.mjs +296 -0
  588. package/src/public-control/policy-render.mjs +69 -0
  589. package/src/public-control/policy-schema.mjs +322 -0
  590. package/src/public-control/runtime-config.mjs +275 -0
  591. package/src/public-control/session-key-model.mjs +379 -0
  592. package/src/public-control/session-orchestrator.mjs +418 -0
  593. package/src/rfq/intent.mjs +180 -0
  594. package/src/rfq/sources.mjs +181 -0
  595. package/src/route-attestation.mjs +132 -0
  596. package/src/router/best-execution.mjs +326 -0
  597. package/src/router/index.mjs +250 -0
  598. package/src/router/integrator-fee.mjs +135 -0
  599. package/src/router/prepare-bridge.mjs +293 -0
  600. package/src/router/prepare-route.mjs +398 -0
  601. package/src/router/proposal.mjs +311 -0
  602. package/src/router/risk-classifier.mjs +119 -0
  603. package/src/router/route-sources.mjs +364 -0
  604. package/src/scanner/chains.config.mjs +543 -0
  605. package/src/scanner/contract.mjs +270 -0
  606. package/src/scanner/evm-scanner.mjs +394 -0
  607. package/src/scanner/index.mjs +9 -0
  608. package/src/scanner/v2-venue.mjs +351 -0
  609. package/src/scanner/v3-venue.mjs +308 -0
  610. package/src/scopes.mjs +44 -0
  611. package/src/sell-simulation.mjs +167 -0
  612. package/src/signals/engine.mjs +146 -0
  613. package/src/signals/index.mjs +1 -0
  614. package/src/token-transfer-guard.mjs +188 -0
  615. package/src/tui/app.mjs +438 -0
  616. package/src/tui/backend.mjs +215 -0
  617. package/src/tui/format.mjs +272 -0
  618. package/src/tui/gateway-client.mjs +177 -0
  619. package/src/tui/input.mjs +501 -0
  620. package/src/tui/memory.mjs +105 -0
  621. package/src/tui/meta-learn.mjs +85 -0
  622. package/src/tui/renderer.mjs +443 -0
  623. package/src/tui/scheduler.mjs +205 -0
  624. package/src/tui/skills-loader.mjs +140 -0
  625. package/src/tui/standalone-client.mjs +752 -0
  626. package/src/tui/theme.mjs +81 -0
  627. package/src/vault-attestation.mjs +146 -0
  628. package/src/venues.mjs +206 -0
  629. package/src/watch-preferences.mjs +85 -0
@@ -0,0 +1,168 @@
1
+ #!/usr/bin/env node
2
+ // Crossbook product bin — separate Oracle product for on-chain equities best-ex.
3
+ // HIP-3 / Arcus / RH / Solana / TON. Offline fixtures by default. Never signs.
4
+
5
+ import { realpathSync } from 'node:fs';
6
+ import { fileURLToPath } from 'node:url';
7
+ import {
8
+ bestEquityRoute,
9
+ equityVenues,
10
+ prepareEquityRoute,
11
+ toJsonSafe,
12
+ } from '../src/equities/index.mjs';
13
+ import { toString } from '../src/equities/num.mjs';
14
+
15
+ function usage() {
16
+ return `oracle equities <command>
17
+
18
+ Commands:
19
+ venues inventory + tiers + liveness snapshot
20
+ quote <TICKER> [options] rank venues for a ticker (HIP-3, Arcus, RH, Solana, TON)
21
+ prepare <TICKER> --recipient 0x... prepare unsigned RH Uniswap artifact
22
+
23
+ Options:
24
+ --size <usd> notional size for impact model
25
+ --horizon <hours> enable funding-adjusted heterogeneous ranking
26
+ --json machine readable output
27
+ --fixtures offline mode (default in v1)
28
+ `;
29
+ }
30
+
31
+ function parseArgs(argv) {
32
+ const args = { _: [] };
33
+ for (let i = 0; i < argv.length; i += 1) {
34
+ const a = argv[i];
35
+ if (a === '--json') args.json = true;
36
+ else if (a === '--fixtures') args.fixtures = true;
37
+ else if (a === '--size') args.size = argv[++i];
38
+ else if (a === '--horizon') args.horizon = argv[++i];
39
+ else if (a === '--recipient') args.recipient = argv[++i];
40
+ else if (a.startsWith('--')) throw new Error(`unknown flag ${a}`);
41
+ else args._.push(a);
42
+ }
43
+ return args;
44
+ }
45
+
46
+ function printHumanRank(result) {
47
+ const lines = [];
48
+ lines.push(`oracle equities quote ${result.ticker}`);
49
+ if (result.darkWindow) {
50
+ lines.push(`WARNING: ${result.darkWindow.warning} (session=${result.darkWindow.session})`);
51
+ }
52
+ lines.push(`rankedOn=${result.rankedOn} mix=${result.instrumentMix}`);
53
+ lines.push(
54
+ `sources answered/tried=${result.sourcesAnswered}/${result.sourcesTried} excluded=${result.excluded?.length ?? 0} failed=${result.failed?.length ?? 0}`,
55
+ );
56
+ if (result.winner) {
57
+ lines.push(
58
+ `WINNER ${result.winner.venue} ${result.winner.instrument} tier=${result.winner.tier} net=${toString(result.winner.net)} costAccounted=${result.winner.costAccounted}`,
59
+ );
60
+ } else {
61
+ lines.push('WINNER (none)');
62
+ }
63
+ for (const r of (result.runnersUp || []).slice(0, 5)) {
64
+ lines.push(
65
+ ` runner ${r.venue} ${r.instrument} tier=${r.tier} net=${toString(r.net)} costAccounted=${r.costAccounted}`,
66
+ );
67
+ }
68
+ if (result.improvementBps !== null && result.improvementBps !== undefined) {
69
+ lines.push(`improvementBps=${result.improvementBps}`);
70
+ } else {
71
+ lines.push('improvementBps=null (no honest same-class costed comparison)');
72
+ }
73
+ if (result.bestPreparable) {
74
+ lines.push(
75
+ `bestPreparable ${result.bestPreparable.venue} net=${toString(result.bestPreparable.net)}`,
76
+ );
77
+ } else {
78
+ lines.push('bestPreparable (none)');
79
+ }
80
+ if (result.excluded?.length) {
81
+ const byReason = {};
82
+ for (const e of result.excluded) byReason[e.reason] = (byReason[e.reason] ?? 0) + 1;
83
+ lines.push(`excluded: ${JSON.stringify(byReason)}`);
84
+ }
85
+ return lines.join('\n');
86
+ }
87
+
88
+ function cmdVenues(args) {
89
+ const payload = equityVenues();
90
+ if (args.json) return JSON.stringify(payload, null, 2);
91
+ return [
92
+ 'oracle equities venues',
93
+ ...payload.inventory.map(
94
+ (v) => ` ${v.venue.padEnd(22)} tier=${v.tier.padEnd(11)} chain=${String(v.chain).padEnd(16)} n=${v.n}`,
95
+ ),
96
+ `liveness survivors=${payload.liveness.survivors} excluded=${payload.liveness.excluded} ${JSON.stringify(payload.liveness.byReason)}`,
97
+ ].join('\n');
98
+ }
99
+
100
+ function cmdQuote(args) {
101
+ const ticker = args._[1];
102
+ if (!ticker) throw new Error('usage: quote <TICKER>');
103
+ const result = bestEquityRoute({
104
+ ticker,
105
+ sizeUsd: args.size,
106
+ horizonHours: args.horizon,
107
+ });
108
+ if (args.json) return JSON.stringify(toJsonSafe(result), null, 2);
109
+ return printHumanRank(result);
110
+ }
111
+
112
+ function cmdPrepare(args) {
113
+ const ticker = args._[1];
114
+ if (!ticker) throw new Error('usage: prepare <TICKER> --recipient 0x...');
115
+ if (!args.recipient) throw new Error('--recipient is required');
116
+ const out = prepareEquityRoute({
117
+ ticker,
118
+ sizeUsd: args.size,
119
+ recipient: args.recipient,
120
+ });
121
+ if (args.json) return JSON.stringify(toJsonSafe(out), null, 2);
122
+ if (!out.ok) {
123
+ return `prepare ${ticker.toUpperCase()} FAILED (${out.failureKind}): ${out.error || out.note}`;
124
+ }
125
+ const art = out.artifact;
126
+ return [
127
+ `prepare ${ticker.toUpperCase()}`,
128
+ ` chainId=${art.chainId} to=${art.to}`,
129
+ ` requiresWalletSignature=${art.requiresWalletSignature} backendSigner=${art.backendSigner}`,
130
+ ` approval spender=${art.requiresApproval?.spender} token=${art.requiresApproval?.token}`,
131
+ ` quoteAgeMs=${art.quoteAgeMs}`,
132
+ ...(art.notes || []).map((n) => ` note: ${n}`),
133
+ ].join('\n');
134
+ }
135
+
136
+ export function main(argv = process.argv.slice(2)) {
137
+ if (argv.length === 0 || argv[0] === '-h' || argv[0] === '--help') {
138
+ process.stdout.write(usage());
139
+ return 0;
140
+ }
141
+ const args = parseArgs(argv);
142
+ const cmd = args._[0];
143
+ let out;
144
+ if (cmd === 'venues') out = cmdVenues(args);
145
+ else if (cmd === 'quote') out = cmdQuote(args);
146
+ else if (cmd === 'prepare') out = cmdPrepare(args);
147
+ else throw new Error(`unknown command ${cmd}\n${usage()}`);
148
+ process.stdout.write(out + '\n');
149
+ return 0;
150
+ }
151
+
152
+ function runningAsMain() {
153
+ if (!process.argv[1]) return false;
154
+ try {
155
+ return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
156
+ } catch {
157
+ return false;
158
+ }
159
+ }
160
+
161
+ if (runningAsMain()) {
162
+ try {
163
+ process.exit(main());
164
+ } catch (error) {
165
+ process.stderr.write(String(error.message || error) + '\n');
166
+ process.exit(1);
167
+ }
168
+ }
@@ -0,0 +1,525 @@
1
+ #!/usr/bin/env node
2
+ // oracle-init -- install Oracle's agent lanes into Hermes.
3
+ //
4
+ // Reads profiles/<lane>/profile.json, validates each against the shipped schema,
5
+ // then creates the Hermes profile, installs its SOUL.md, registers the repo's
6
+ // skills, and wires the oracle-data MCP server.
7
+ //
8
+ // Deliberate omissions:
9
+ // * No model or provider is written. Oracle makes no model calls; each lane
10
+ // inherits whatever the operator's Hermes already serves. profile.json carries
11
+ // a capability CLASS ("strong-reasoner"), never a model id, so this installer
12
+ // never pins a vendor.
13
+ // * No grant is armed. Every lane lands DISARMED. Arming is a signed, scoped,
14
+ // expiring act the user performs later.
15
+ //
16
+ // Default is a DRY RUN. Pass --apply to make changes.
17
+
18
+ import fs from "node:fs";
19
+ import path from "node:path";
20
+ import os from "node:os";
21
+ import { randomBytes } from "node:crypto";
22
+ import { execFileSync } from "node:child_process";
23
+ import { fileURLToPath } from "node:url";
24
+ import { packageAssetDir } from "../src/package-manifest.mjs";
25
+
26
+ // Sibling bins live next to this file in both layouts (bin/ in source,
27
+ // dist/bin/ in the published bundle), so resolve them from here, not the root.
28
+ const BIN_DIR = path.dirname(fileURLToPath(import.meta.url));
29
+ const PROFILES_DIR = packageAssetDir("profiles", import.meta.url);
30
+ const SKILLS_DIR = packageAssetDir("skills", import.meta.url);
31
+
32
+ const args = process.argv.slice(2);
33
+ const APPLY = args.includes("--apply");
34
+ const FORCE = args.includes("--force");
35
+ const JSON_OUT = args.includes("--json");
36
+ const only = (() => {
37
+ const i = args.indexOf("--only");
38
+ return i >= 0 ? args[i + 1] : null;
39
+ })();
40
+
41
+ const log = (...m) => {
42
+ if (!JSON_OUT) console.log(...m);
43
+ };
44
+
45
+ // ---------------------------------------------------------------- validation
46
+
47
+ function loadSchema() {
48
+ return JSON.parse(
49
+ fs.readFileSync(path.join(PROFILES_DIR, "profile.schema.json"), "utf8"),
50
+ );
51
+ }
52
+
53
+ // Focused validator for the fields we actually depend on. Not a general JSON
54
+ // Schema engine -- pulling one in for eight files would add a dependency to a
55
+ // zero-dependency installer.
56
+ function validateProfile(def, schema, skillNames) {
57
+ const errors = [];
58
+ const req = schema.required || [];
59
+ for (const k of req) {
60
+ if (def[k] === undefined) errors.push(`missing required field: ${k}`);
61
+ }
62
+ if (def.id && !/^[a-z_][a-z0-9-]*$/.test(def.id)) {
63
+ errors.push(`id "${def.id}" must be lowercase, no dots (Hermes rejects dots)`);
64
+ }
65
+ const roles = schema.properties.role.enum;
66
+ if (def.role && !roles.includes(def.role)) {
67
+ errors.push(`role "${def.role}" not one of ${roles.join(", ")}`);
68
+ }
69
+ const p = def.posture || {};
70
+ if (p.default !== "DISARMED") {
71
+ errors.push("posture.default must be DISARMED -- a lane that ships armed is a bug");
72
+ }
73
+ if (p.signing && !["none", "user-wallet"].includes(p.signing)) {
74
+ errors.push(`posture.signing "${p.signing}" invalid -- Oracle holds no keys`);
75
+ }
76
+ const allowedActions =
77
+ schema.properties.posture.properties.grantActions.items.enum;
78
+ for (const a of p.grantActions || []) {
79
+ if (!allowedActions.includes(a)) {
80
+ errors.push(`grantAction "${a}" not allowed (broadcast/sign actions are forbidden)`);
81
+ }
82
+ }
83
+ if (typeof p.rationale === "string" && p.rationale.length < 20) {
84
+ errors.push("posture.rationale too short -- justify the grant");
85
+ }
86
+ // Every named skill must actually exist. This is the check that would have
87
+ // caught the phantom-skill problem in the original pack manifest.
88
+ for (const s of def.skills || []) {
89
+ if (!skillNames.has(s)) errors.push(`skill "${s}" does not exist in skills/`);
90
+ }
91
+ return errors;
92
+ }
93
+
94
+ // ---------------------------------------------------------------- discovery
95
+
96
+ function discoverSkills() {
97
+ if (!fs.existsSync(SKILLS_DIR)) return new Map();
98
+ const out = new Map();
99
+ for (const e of fs.readdirSync(SKILLS_DIR, { withFileTypes: true })) {
100
+ if (!e.isDirectory()) continue;
101
+ const skillFile = path.join(SKILLS_DIR, e.name, "SKILL.md");
102
+ if (fs.existsSync(skillFile)) out.set(e.name, skillFile);
103
+ }
104
+ return out;
105
+ }
106
+
107
+ function discoverProfiles() {
108
+ if (!fs.existsSync(PROFILES_DIR)) return [];
109
+ const out = [];
110
+ for (const e of fs.readdirSync(PROFILES_DIR, { withFileTypes: true })) {
111
+ if (!e.isDirectory()) continue;
112
+ const f = path.join(PROFILES_DIR, e.name, "profile.json");
113
+ if (!fs.existsSync(f)) continue;
114
+ const def = JSON.parse(fs.readFileSync(f, "utf8"));
115
+ def.__dir = path.join(PROFILES_DIR, e.name);
116
+ out.push(def);
117
+ }
118
+ return out;
119
+ }
120
+
121
+ // ---------------------------------------------------------------- hermes glue
122
+
123
+ function hermesAvailable() {
124
+ try {
125
+ execFileSync("hermes", ["--version"], { stdio: "pipe", timeout: 20_000 });
126
+ return true;
127
+ } catch {
128
+ return false;
129
+ }
130
+ }
131
+
132
+ // Resolve the GLOBAL Hermes root, not a profile-scoped one.
133
+ //
134
+ // Trap worth knowing: when this runs inside an agent session that is itself
135
+ // profile-scoped, HERMES_HOME points at ~/.hermes/profiles/<name>, not ~/.hermes.
136
+ // Using it verbatim writes ~/.hermes/profiles/<name>/profiles/<lane>/SOUL.md --
137
+ // a nested path Hermes never reads, so the install silently does nothing.
138
+ // Detect that shape and walk back up to the real root.
139
+ function hermesRoot() {
140
+ const env = (process.env.HERMES_HOME || "").trim();
141
+ if (env) {
142
+ const parts = env.split(path.sep);
143
+ const i = parts.lastIndexOf("profiles");
144
+ // ".../profiles/<name>" -> strip the last two segments
145
+ if (i > 0 && i === parts.length - 2) {
146
+ return parts.slice(0, i).join(path.sep);
147
+ }
148
+ return env;
149
+ }
150
+ return path.join(os.homedir(), ".hermes");
151
+ }
152
+
153
+ function profileExists(id) {
154
+ try {
155
+ const out = execFileSync("hermes", ["profile", "list"], {
156
+ encoding: "utf8",
157
+ timeout: 30_000,
158
+ });
159
+ return new RegExp(`(^|\\s)${id}(\\s|$)`, "m").test(out);
160
+ } catch {
161
+ return false;
162
+ }
163
+ }
164
+
165
+ const actions = [];
166
+ const skipped = [];
167
+ const mcpManual = [];
168
+
169
+ function sameFile(a, b) {
170
+ try {
171
+ return fs.readFileSync(a, "utf8") === fs.readFileSync(b, "utf8");
172
+ } catch {
173
+ return false;
174
+ }
175
+ }
176
+
177
+ function record(kind, detail) {
178
+ actions.push({ kind, detail, applied: APPLY });
179
+ log(`${APPLY ? " ✔" : " ·"} ${kind}: ${detail}`);
180
+ }
181
+
182
+ // Write Hermes mcp_servers.oracle-data directly into the profile config.
183
+ // Prefer this over `hermes mcp add`: current Hermes takes --command and --args
184
+ // as separate tokens, prompts interactively for tool enablement, and the old
185
+ // installer form `--command "node <path>"` silently no-ops under execFileSync.
186
+ function yamlScalar(value) {
187
+ if (
188
+ value === "" ||
189
+ /[:#\[\]{},&*!|>'"%@`\s]/.test(value) ||
190
+ /^(?:null|true|false|\d+)$/i.test(value)
191
+ ) {
192
+ return JSON.stringify(value);
193
+ }
194
+ return value;
195
+ }
196
+
197
+ function mcpServerBlock(serverName, scriptPath) {
198
+ return [
199
+ ` ${serverName}:`,
200
+ " command: node",
201
+ " args:",
202
+ ` - ${yamlScalar(scriptPath)}`,
203
+ " enabled: true",
204
+ ].join("\n");
205
+ }
206
+
207
+ function wireMcpIntoConfig(configPath, serverName, scriptPath) {
208
+ const entry = mcpServerBlock(serverName, scriptPath);
209
+ if (!fs.existsSync(configPath)) {
210
+ fs.writeFileSync(configPath, `mcp_servers:\n${entry}\n`, "utf8");
211
+ return "created";
212
+ }
213
+
214
+ let txt = fs.readFileSync(configPath, "utf8");
215
+ if (
216
+ txt.includes(scriptPath) &&
217
+ new RegExp(`^\\s*${serverName}:\\s*$`, "m").test(txt)
218
+ ) {
219
+ return "present";
220
+ }
221
+
222
+ // Replace an existing server block of the same name (simple indented map).
223
+ const serverRe = new RegExp(
224
+ `^([ \\t]*)${serverName}:\\s*\\n(?:\\1[ \\t]+.*\\n)*`,
225
+ "m",
226
+ );
227
+ if (serverRe.test(txt)) {
228
+ txt = txt.replace(serverRe, `${entry}\n`);
229
+ fs.writeFileSync(configPath, txt, "utf8");
230
+ return "updated";
231
+ }
232
+
233
+ if (/^mcp_servers:\s*$/m.test(txt) || /^mcp_servers:\s*\n/m.test(txt)) {
234
+ txt = txt.replace(/^(mcp_servers:\s*\n)/m, `$1${entry}\n`);
235
+ } else if (/^_config_version:.*$/m.test(txt)) {
236
+ txt = txt.replace(
237
+ /^(_config_version:.*\n)/m,
238
+ `$1mcp_servers:\n${entry}\n`,
239
+ );
240
+ } else {
241
+ txt = `mcp_servers:\n${entry}\n${txt}`;
242
+ }
243
+ fs.writeFileSync(configPath, txt, "utf8");
244
+ return "wired";
245
+ }
246
+
247
+ // ---------------------------------------------------------------- main
248
+
249
+ const schema = loadSchema();
250
+ const skills = discoverSkills();
251
+ const skillNames = new Set(skills.keys());
252
+ let profiles = discoverProfiles();
253
+
254
+ // The template is documentation, not a lane to install.
255
+ profiles = profiles.filter((p) => !p.template);
256
+ if (only) profiles = profiles.filter((p) => p.id === only);
257
+
258
+ log(`oracle-init ${APPLY ? "(APPLY)" : "(dry run -- pass --apply to install)"}`);
259
+ log(` profiles: ${profiles.length} skills: ${skills.size}`);
260
+
261
+ // 1. validate everything BEFORE touching the system. A partial install across a
262
+ // profile mesh is worse than no install.
263
+ const invalid = [];
264
+ for (const def of profiles) {
265
+ const errs = validateProfile(def, schema, skillNames);
266
+ if (errs.length) invalid.push({ id: def.id, errors: errs });
267
+ }
268
+ if (invalid.length) {
269
+ if (JSON_OUT) {
270
+ process.stdout.write(`${JSON.stringify({ ok: false, invalid }, null, 2)}\n`);
271
+ } else {
272
+ console.error("\nvalidation failed:");
273
+ for (const v of invalid) {
274
+ console.error(` ${v.id}:`);
275
+ for (const e of v.errors) console.error(` - ${e}`);
276
+ }
277
+ }
278
+ process.exit(1);
279
+ }
280
+ log(" validation: ok");
281
+
282
+ // Ensure a route/slippage attestation secret exists for fresh installs.
283
+ // Without it, swap sign/broadcast fails closed (unsigned guards are refused).
284
+ // Never overwrite an existing secret.
285
+ {
286
+ const cfgDir = path.join(os.homedir(), ".config", "oracle");
287
+ const envPath = path.join(cfgDir, "exec.env");
288
+ let hasSecret = Boolean(
289
+ process.env.ORACLE_ROUTE_ATTESTATION_SECRET || process.env.MAD_ROUTE_ATTESTATION_SECRET
290
+ );
291
+ if (!hasSecret && fs.existsSync(envPath)) {
292
+ try {
293
+ const txt = fs.readFileSync(envPath, "utf8");
294
+ hasSecret = /^ORACLE_ROUTE_ATTESTATION_SECRET=.+$/m.test(txt) || /^MAD_ROUTE_ATTESTATION_SECRET=.+$/m.test(txt);
295
+ } catch {
296
+ /* treat as missing */
297
+ }
298
+ }
299
+ if (hasSecret) {
300
+ record("attestation secret", "present");
301
+ } else {
302
+ record("attestation secret", `generate -> ${path.relative(os.homedir(), envPath)}`);
303
+ if (APPLY) {
304
+ fs.mkdirSync(cfgDir, { recursive: true, mode: 0o700 });
305
+ try {
306
+ fs.chmodSync(cfgDir, 0o700);
307
+ } catch {
308
+ /* best-effort */
309
+ }
310
+ const secret = randomBytes(32).toString("hex");
311
+ const line = `ORACLE_ROUTE_ATTESTATION_SECRET=${secret}\n`;
312
+ if (fs.existsSync(envPath)) {
313
+ const prev = fs.readFileSync(envPath, "utf8");
314
+ if (!/ORACLE_ROUTE_ATTESTATION_SECRET=/.test(prev) && !/MAD_ROUTE_ATTESTATION_SECRET=/.test(prev)) {
315
+ fs.appendFileSync(envPath, prev.endsWith("\n") || prev.length === 0 ? line : `\n${line}`, { mode: 0o600 });
316
+ }
317
+ } else {
318
+ fs.writeFileSync(envPath, line, { mode: 0o600 });
319
+ }
320
+ try {
321
+ fs.chmodSync(envPath, 0o600);
322
+ } catch {
323
+ /* best-effort */
324
+ }
325
+ }
326
+ }
327
+ }
328
+
329
+ const hermes = hermesAvailable();
330
+ // The hermes CLI is a CONVENIENCE, not a requirement.
331
+ //
332
+ // Verified behaviour: Hermes discovers any profile directory under
333
+ // <root>/profiles/<name>/, so writing SOUL.md and skills/ is sufficient to create a
334
+ // working lane. `hermes profile create` only pre-seeds boilerplate, and
335
+ // `hermes mcp add` only edits that profile's config.
336
+ //
337
+ // Making the CLI mandatory would mean this installer -- and its tests -- could only
338
+ // run on a machine with Hermes already installed, which is both a worse contributor
339
+ // experience and untestable in CI. So: install files always, use the CLI when it is
340
+ // there, and say plainly what was skipped when it is not.
341
+ if (!hermes) {
342
+ log(
343
+ " hermes CLI: not found -- installing profile files directly.\n" +
344
+ " (Hermes discovers any directory under <root>/profiles/, so this works.\n" +
345
+ " MCP wiring is the one step that needs the CLI; instructions printed at the end.)",
346
+ );
347
+ } else {
348
+ log(" hermes CLI: found");
349
+ }
350
+
351
+ // 2. install
352
+ for (const def of profiles) {
353
+ log(`\n${def.label} (${def.id})`);
354
+
355
+ // Snapshot what exists BEFORE we create anything. This is the reliable signal
356
+ // for the no-clobber guard below.
357
+ //
358
+ // Why not just check for the file later: `hermes profile create` writes its own
359
+ // boilerplate SOUL.md, so after creation a SOUL.md always exists. Treating that
360
+ // as "the user's file" would make the guard refuse to install the lane persona,
361
+ // the install would silently no-op, and every lane would run generic Hermes.
362
+ // Only a file that predates our run can hold work worth protecting.
363
+ const laneDir = path.join(hermesRoot(), "profiles", def.id);
364
+ const soulDest = path.join(laneDir, "SOUL.md");
365
+ const soulExistedBefore = fs.existsSync(soulDest);
366
+ const skillExistedBefore = new Map(
367
+ (def.skills || []).map((s) => [
368
+ s,
369
+ fs.existsSync(path.join(laneDir, "skills", s, "SKILL.md")),
370
+ ]),
371
+ );
372
+
373
+ const preExisting = hermes ? profileExists(def.id) : fs.existsSync(laneDir);
374
+ if (preExisting) {
375
+ record("profile exists", def.id);
376
+ } else if (hermes) {
377
+ record("create profile", def.id);
378
+ if (APPLY) {
379
+ try {
380
+ execFileSync("hermes", ["profile", "create", def.id], {
381
+ stdio: "pipe",
382
+ timeout: 120_000,
383
+ });
384
+ } catch (err) {
385
+ // Not fatal: writing the directory below is what actually creates the lane.
386
+ record("create note", `hermes profile create failed for ${def.id}; writing files directly`);
387
+ }
388
+ }
389
+ } else {
390
+ record("create profile dir", def.id);
391
+ if (APPLY) fs.mkdirSync(laneDir, { recursive: true });
392
+ }
393
+
394
+ // SOUL.md -- never clobber a persona the user wrote.
395
+ const soulSrc = path.join(def.__dir, "SOUL.md");
396
+ if (fs.existsSync(soulSrc)) {
397
+ const collision = soulExistedBefore && !sameFile(soulSrc, soulDest);
398
+ if (collision && !FORCE) {
399
+ record(
400
+ "SKIP SOUL.md (exists)",
401
+ `${path.relative(os.homedir(), soulDest)} -- kept yours; --force to overwrite`,
402
+ );
403
+ skipped.push({ lane: def.id, file: "SOUL.md", reason: "already exists" });
404
+ } else {
405
+ record("install SOUL.md", path.relative(os.homedir(), soulDest));
406
+ if (APPLY) {
407
+ fs.mkdirSync(path.dirname(soulDest), { recursive: true });
408
+ if (collision) {
409
+ const bak = `${soulDest}.bak-oracle-init-${Date.now()}`;
410
+ fs.copyFileSync(soulDest, bak);
411
+ record("backed up", path.relative(os.homedir(), bak));
412
+ }
413
+ fs.copyFileSync(soulSrc, soulDest);
414
+ }
415
+ }
416
+ }
417
+
418
+ // skills -- same discipline
419
+ for (const s of def.skills || []) {
420
+ const dest = path.join(laneDir, "skills", s, "SKILL.md");
421
+ const collision = skillExistedBefore.get(s) && !sameFile(skills.get(s), dest);
422
+ if (collision && !FORCE) {
423
+ record("SKIP skill (exists)", `${s} -> ${def.id}`);
424
+ skipped.push({ lane: def.id, file: `skills/${s}`, reason: "already exists" });
425
+ continue;
426
+ }
427
+ record("install skill", `${s} -> ${def.id}`);
428
+ if (APPLY) {
429
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
430
+ fs.copyFileSync(skills.get(s), dest);
431
+ }
432
+ }
433
+
434
+ // MCP: write Hermes config directly. CLI is optional convenience only.
435
+ for (const m of def.mcp || []) {
436
+ const scriptPath = path.join(BIN_DIR, "oracle-data-mcp.mjs");
437
+ const configPath = path.join(laneDir, "config.yaml");
438
+ const manual = `hermes -p ${def.id} mcp add ${m} --command node --args ${scriptPath}`;
439
+
440
+ if (m !== "oracle-data") {
441
+ record("mcp manual", manual);
442
+ mcpManual.push({ lane: def.id, server: m, command: manual });
443
+ continue;
444
+ }
445
+
446
+ record(
447
+ "wire mcp",
448
+ `${m} (${def.id}) -> ${path.relative(os.homedir(), configPath)}`,
449
+ );
450
+ if (APPLY) {
451
+ try {
452
+ fs.mkdirSync(laneDir, { recursive: true });
453
+ const how = wireMcpIntoConfig(configPath, m, scriptPath);
454
+ record(
455
+ "mcp config",
456
+ `${how}: ${path.relative(os.homedir(), configPath)}`,
457
+ );
458
+ } catch (err) {
459
+ record("mcp note", `could not write ${configPath}: ${err.message}`);
460
+ mcpManual.push({ lane: def.id, server: m, command: manual });
461
+ }
462
+ }
463
+ }
464
+
465
+ record("posture", `DISARMED (${(def.posture.grantActions || []).join(", ")})`);
466
+ }
467
+
468
+ // ── Standalone agent skills ──
469
+ // Copy shipped skill .md files to ~/.config/oracle/skills/ so the
470
+ // standalone agent (skills-loader.mjs) finds them on first chat.
471
+ const standaloneSkillsDir = path.join(os.homedir(), ".config", "oracle", "skills");
472
+ const shippedSkillsDir = SKILLS_DIR;
473
+ if (APPLY && fs.existsSync(shippedSkillsDir)) {
474
+ fs.mkdirSync(standaloneSkillsDir, { recursive: true });
475
+ let copied = 0;
476
+ for (const entry of fs.readdirSync(shippedSkillsDir, { withFileTypes: true })) {
477
+ if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
478
+ const src = path.join(shippedSkillsDir, entry.name);
479
+ const dst = path.join(standaloneSkillsDir, entry.name);
480
+ if (!FORCE && fs.existsSync(dst)) {
481
+ skipped.push({ lane: "standalone", file: entry.name });
482
+ continue;
483
+ }
484
+ try {
485
+ fs.copyFileSync(src, dst);
486
+ copied++;
487
+ } catch (err) {
488
+ record("skill copy", `failed ${entry.name}: ${err.message}`);
489
+ }
490
+ }
491
+ if (copied) log(` standalone skills: ${copied} installed to ${standaloneSkillsDir}`);
492
+ }
493
+
494
+ const summary = {
495
+ ok: true,
496
+ applied: APPLY,
497
+ profiles: profiles.map((p) => p.id),
498
+ skills: [...skillNames],
499
+ actions: actions.length,
500
+ skipped,
501
+ mcpManual,
502
+ hermesDetected: hermes,
503
+ hermesRoot: hermesRoot(),
504
+ };
505
+
506
+ if (JSON_OUT) {
507
+ process.stdout.write(`${JSON.stringify(summary, null, 2)}\n`);
508
+ } else {
509
+ log(`\n${APPLY ? "installed" : "would install"} ${profiles.length} lanes.`);
510
+ if (skipped.length) {
511
+ log(`${skipped.length} file(s) already existed and were kept:`);
512
+ for (const s of skipped) log(` - ${s.lane}/${s.file}`);
513
+ log("pass --force to overwrite (a timestamped .bak is written first).");
514
+ }
515
+ if (mcpManual.length) {
516
+ log("\nMCP wiring needed a manual follow-up:");
517
+ for (const m of mcpManual) log(` ${m.command}`);
518
+ }
519
+ if (!APPLY) log("re-run with --apply to make changes.");
520
+ log("\nEvery lane is DISARMED. Start the read plane, then chat a lane:");
521
+ log(" npx oracle-data # 127.0.0.1:8787 — MCP tools need this");
522
+ log(" hermes -p oracle chat");
523
+ log("\nSet each lane's model in:");
524
+ log(` ${path.join(hermesRoot(), "profiles", "<lane>", "config.yaml")}`);
525
+ }