@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.
- package/README.md +2 -2
- package/SETUP.md +4 -4
- package/dist/action-receipts.mjs +1 -0
- package/dist/action-semantics.mjs +1 -0
- package/dist/address-book.mjs +2 -0
- package/dist/bin/desk-server.mjs +59 -0
- package/dist/bin/oracle-data-mcp.mjs +8 -0
- package/dist/bin/oracle-equities.mjs +20 -0
- package/dist/bin/oracle-init.mjs +24 -0
- package/dist/bin/oracle-public-server.mjs +5 -0
- package/dist/bin/oracle-route.mjs +22 -0
- package/dist/bin/oracle-scan.mjs +18 -0
- package/dist/bin/oracle-upgrade.mjs +21 -0
- package/dist/bin/oracle.mjs +61 -0
- package/dist/chains.mjs +1 -0
- package/dist/cli/commands/auth.mjs +16 -0
- package/dist/cli/commands/bootstrap.mjs +18 -0
- package/dist/cli/commands/chain.mjs +21 -0
- package/dist/cli/commands/chat.mjs +45 -0
- package/dist/cli/commands/credential.mjs +1 -0
- package/dist/cli/commands/data-mcp.mjs +2 -0
- package/dist/cli/commands/data.mjs +12 -0
- package/dist/cli/commands/doctor.mjs +5 -0
- package/dist/cli/commands/equities.mjs +15 -0
- package/dist/cli/commands/farm.mjs +59 -0
- package/dist/cli/commands/fees.mjs +10 -0
- package/dist/cli/commands/follow.mjs +28 -0
- package/dist/cli/commands/harness.mjs +15 -0
- package/dist/cli/commands/help.mjs +1 -0
- package/dist/cli/commands/init.mjs +3 -0
- package/dist/cli/commands/mcp.mjs +36 -0
- package/dist/cli/commands/model.mjs +54 -0
- package/dist/cli/commands/plugins.mjs +43 -0
- package/dist/cli/commands/prepare.mjs +2 -0
- package/dist/cli/commands/public.mjs +3 -0
- package/dist/cli/commands/resolve.mjs +23 -0
- package/dist/cli/commands/route.mjs +2 -0
- package/dist/cli/commands/runner.mjs +1 -0
- package/dist/cli/commands/scan.mjs +2 -0
- package/dist/cli/commands/setup.mjs +34 -0
- package/dist/cli/commands/sign.mjs +4 -0
- package/dist/cli/commands/signer.mjs +1 -0
- package/dist/cli/commands/swap.mjs +36 -0
- package/dist/cli/commands/upgrade.mjs +2 -0
- package/dist/cli/commands/vault.mjs +1 -0
- package/dist/cli/commands/version.mjs +2 -0
- package/dist/data/desk-data.mjs +55 -0
- package/dist/data/names.mjs +2 -0
- package/dist/data/providers/farming.mjs +2 -0
- package/dist/equities/index.mjs +1 -0
- package/dist/index.mjs +60 -0
- package/dist/nft-gas-war-guard.mjs +1 -0
- package/dist/onboarding/harness-configs.mjs +4 -0
- package/dist/portfolio-risk.mjs +1 -0
- package/dist/prepare-envelope.mjs +1 -0
- package/dist/public-api/agent-grants.mjs +3 -0
- package/dist/public-control/policy-schema.mjs +1 -0
- package/dist/router/index.mjs +2 -0
- package/dist/scanner/index.mjs +4 -0
- package/dist/signals/index.mjs +1 -0
- package/dist/watch-preferences.mjs +1 -0
- package/package.json +32 -78
- package/public/oracle-splash/_variants/ice.html +5 -18
- package/public/oracle-splash/_variants/ivory.html +5 -18
- package/public/oracle-splash/index.html +114 -34
- package/CONTRIBUTING.md +0 -99
- package/bin/desk-server.mjs +0 -473
- package/bin/oracle-data-mcp.mjs +0 -1252
- package/bin/oracle-equities.mjs +0 -168
- package/bin/oracle-init.mjs +0 -525
- package/bin/oracle-public-server.mjs +0 -36
- package/bin/oracle-route.mjs +0 -254
- package/bin/oracle-scan.mjs +0 -192
- package/bin/oracle-upgrade.mjs +0 -42
- package/bin/oracle.mjs +0 -34
- package/docs/adding-a-chain.md +0 -229
- package/docs/architecture.md +0 -139
- package/docs/buzz-integration.md +0 -115
- package/docs/cli.md +0 -143
- package/docs/connectors.md +0 -13
- package/docs/hyperliquid-builder-code.md +0 -50
- package/docs/locals-only-fee-waiver.md +0 -34
- package/docs/oracle-pack-standard.md +0 -29
- package/docs/profiles.md +0 -151
- package/docs/public-surface.md +0 -206
- package/examples/add-a-chain.mjs +0 -65
- package/examples/oracle-pack-template.mjs +0 -38
- package/examples/research-a-token.mjs +0 -70
- package/plugins/oracle-owner-gate/__init__.py +0 -288
- package/plugins/oracle-owner-gate/plugin.yaml +0 -9
- package/protocols/templates/safe-erc20/SECURITY.md +0 -16
- package/protocols/templates/safe-erc20/foundry.toml +0 -12
- package/protocols/templates/safe-erc20/remappings.txt +0 -2
- package/protocols/templates/safe-erc20/src/SafeERC20.sol +0 -53
- package/protocols/templates/safe-erc20/test/SafeERC20.t.sol +0 -72
- package/scripts/adversarial-bench.mjs +0 -114
- package/scripts/build-dist.mjs +0 -119
- package/scripts/build-inscription.py +0 -230
- package/scripts/check-doc-drift.mjs +0 -123
- package/scripts/check-test-count.mjs +0 -105
- package/scripts/e2e-hl-markets.mjs +0 -21
- package/scripts/e2e-hl-perps.mjs +0 -48
- package/scripts/e2e-hypercore-staking.mjs +0 -128
- package/scripts/e2e-solana-bitcoin.mjs +0 -183
- package/scripts/guard-publish.mjs +0 -22
- package/scripts/protocol-template-gate.mjs +0 -15
- package/scripts/public-api-scan.mjs +0 -23
- package/scripts/publish-dist.mjs +0 -67
- package/scripts/record-hero-cli.sh +0 -80
- package/scripts/secret-scan.mjs +0 -168
- package/scripts/smoke-dist-bins.mjs +0 -89
- package/scripts/verify-dist.mjs +0 -29
- package/scripts/verify-v3-venues.mjs +0 -233
- package/skins/oracle.yaml +0 -56
- package/src/action-receipts.mjs +0 -265
- package/src/action-semantics.mjs +0 -62
- package/src/address-book.mjs +0 -208
- package/src/agent-auth.mjs +0 -206
- package/src/approval-guard.mjs +0 -282
- package/src/attestation-secret.mjs +0 -94
- package/src/audit-log.mjs +0 -196
- package/src/auth/oauth.mjs +0 -672
- package/src/auto-slippage.mjs +0 -378
- package/src/capability-posture.mjs +0 -125
- package/src/cards.mjs +0 -422
- package/src/chains.mjs +0 -62
- package/src/cli/chain-catalog.mjs +0 -215
- package/src/cli/chain-state.mjs +0 -74
- package/src/cli/commands/auth.mjs +0 -193
- package/src/cli/commands/bootstrap.mjs +0 -87
- package/src/cli/commands/chain.mjs +0 -143
- package/src/cli/commands/chat.mjs +0 -465
- package/src/cli/commands/credential.mjs +0 -9
- package/src/cli/commands/data-mcp.mjs +0 -18
- package/src/cli/commands/data.mjs +0 -75
- package/src/cli/commands/doctor.mjs +0 -136
- package/src/cli/commands/equities.mjs +0 -41
- package/src/cli/commands/farm.mjs +0 -129
- package/src/cli/commands/fees.mjs +0 -109
- package/src/cli/commands/follow.mjs +0 -130
- package/src/cli/commands/harness.mjs +0 -63
- package/src/cli/commands/help.mjs +0 -7
- package/src/cli/commands/init.mjs +0 -27
- package/src/cli/commands/mcp.mjs +0 -154
- package/src/cli/commands/model.mjs +0 -106
- package/src/cli/commands/plugins.mjs +0 -241
- package/src/cli/commands/prepare.mjs +0 -12
- package/src/cli/commands/public.mjs +0 -20
- package/src/cli/commands/resolve.mjs +0 -64
- package/src/cli/commands/route.mjs +0 -12
- package/src/cli/commands/runner.mjs +0 -9
- package/src/cli/commands/scan.mjs +0 -12
- package/src/cli/commands/setup.mjs +0 -294
- package/src/cli/commands/sign.mjs +0 -21
- package/src/cli/commands/signer.mjs +0 -9
- package/src/cli/commands/swap.mjs +0 -102
- package/src/cli/commands/upgrade.mjs +0 -12
- package/src/cli/commands/vault.mjs +0 -9
- package/src/cli/commands/version.mjs +0 -22
- package/src/cli/first-run.mjs +0 -23
- package/src/cli/kernel.mjs +0 -262
- package/src/cli/mcp-targets/chatgpt.mjs +0 -51
- package/src/cli/mcp-targets/claude-code.mjs +0 -39
- package/src/cli/mcp-targets/claude-desktop.mjs +0 -24
- package/src/cli/mcp-targets/codex.mjs +0 -41
- package/src/cli/mcp-targets/cursor.mjs +0 -32
- package/src/cli/mcp-targets/shared.mjs +0 -71
- package/src/cli/mcp-targets/vscode.mjs +0 -39
- package/src/cli/messaging-platforms.mjs +0 -217
- package/src/cli/model-config.mjs +0 -78
- package/src/cli/operator-dispatch.mjs +0 -257
- package/src/cli/oracle-harness.py +0 -415
- package/src/cli/paths.mjs +0 -107
- package/src/cli/runtime.mjs +0 -351
- package/src/cli/setup-state.mjs +0 -168
- package/src/cli/spawn-child.mjs +0 -43
- package/src/data/catalog.mjs +0 -858
- package/src/data/desk-data.mjs +0 -877
- package/src/data/http.mjs +0 -253
- package/src/data/names.mjs +0 -188
- package/src/data/provider-endpoint.mjs +0 -94
- package/src/data/providers/aave-v3.mjs +0 -139
- package/src/data/providers/across-bridge.mjs +0 -41
- package/src/data/providers/aerodrome.mjs +0 -245
- package/src/data/providers/aevo.mjs +0 -33
- package/src/data/providers/approval-indexer.mjs +0 -133
- package/src/data/providers/approvals.mjs +0 -594
- package/src/data/providers/babylon-staking.mjs +0 -149
- package/src/data/providers/balancer.mjs +0 -209
- package/src/data/providers/beefy-yields.mjs +0 -45
- package/src/data/providers/birdeye-tokens.mjs +0 -33
- package/src/data/providers/bisq-markets.mjs +0 -145
- package/src/data/providers/bitcoin-esplora.mjs +0 -216
- package/src/data/providers/bitcoin-meta.mjs +0 -378
- package/src/data/providers/blockscout.mjs +0 -14
- package/src/data/providers/bob-rootstock.mjs +0 -198
- package/src/data/providers/braiins-insights.mjs +0 -103
- package/src/data/providers/bridge-aggregator.mjs +0 -259
- package/src/data/providers/bridges.mjs +0 -242
- package/src/data/providers/bungee.mjs +0 -29
- package/src/data/providers/celestia-da.mjs +0 -38
- package/src/data/providers/changenow.mjs +0 -135
- package/src/data/providers/compound.mjs +0 -32
- package/src/data/providers/connext.mjs +0 -28
- package/src/data/providers/convex.mjs +0 -30
- package/src/data/providers/cow-protocol.mjs +0 -110
- package/src/data/providers/cowswap.mjs +0 -415
- package/src/data/providers/curve.mjs +0 -201
- package/src/data/providers/das-assets.mjs +0 -59
- package/src/data/providers/debridge.mjs +0 -109
- package/src/data/providers/defillama.mjs +0 -88
- package/src/data/providers/dexscreener.mjs +0 -43
- package/src/data/providers/drift.mjs +0 -32
- package/src/data/providers/dydx.mjs +0 -41
- package/src/data/providers/evm-rpc.mjs +0 -225
- package/src/data/providers/farming.mjs +0 -291
- package/src/data/providers/geckoterminal.mjs +0 -34
- package/src/data/providers/gmx.mjs +0 -496
- package/src/data/providers/hiro-stacks.mjs +0 -150
- package/src/data/providers/hl-assets.mjs +0 -165
- package/src/data/providers/hl-info.mjs +0 -108
- package/src/data/providers/hl-markets.mjs +0 -210
- package/src/data/providers/hl-outcome.mjs +0 -61
- package/src/data/providers/hl-perps.mjs +0 -419
- package/src/data/providers/hl-staking.mjs +0 -353
- package/src/data/providers/hl-ws.mjs +0 -119
- package/src/data/providers/hyperevm-dex.mjs +0 -49
- package/src/data/providers/jito-mev.mjs +0 -117
- package/src/data/providers/jupiter-venues.mjs +0 -119
- package/src/data/providers/jupiter.mjs +0 -315
- package/src/data/providers/kamino-strategies.mjs +0 -143
- package/src/data/providers/l2beat-tvl.mjs +0 -42
- package/src/data/providers/lifi.mjs +0 -166
- package/src/data/providers/liquid-esplora.mjs +0 -152
- package/src/data/providers/magiceden-ordinals.mjs +0 -141
- package/src/data/providers/magiceden-sol.mjs +0 -406
- package/src/data/providers/mempool-lightning.mjs +0 -144
- package/src/data/providers/mempool-mining.mjs +0 -142
- package/src/data/providers/meteora-dlmm.mjs +0 -168
- package/src/data/providers/morpho.mjs +0 -177
- package/src/data/providers/nft-gallery.mjs +0 -163
- package/src/data/providers/nft-portfolio.mjs +0 -494
- package/src/data/providers/odos.mjs +0 -156
- package/src/data/providers/ondo.mjs +0 -31
- package/src/data/providers/oneinch.mjs +0 -174
- package/src/data/providers/opensea-multichain.mjs +0 -136
- package/src/data/providers/opensea-nft.mjs +0 -371
- package/src/data/providers/orca.mjs +0 -29
- package/src/data/providers/ordinals-runes.mjs +0 -180
- package/src/data/providers/pancakeswap.mjs +0 -28
- package/src/data/providers/paraswap.mjs +0 -125
- package/src/data/providers/pendle.mjs +0 -188
- package/src/data/providers/poly-clob.mjs +0 -283
- package/src/data/providers/poly-public.mjs +0 -96
- package/src/data/providers/poly-ws.mjs +0 -103
- package/src/data/providers/polygon-staking.mjs +0 -227
- package/src/data/providers/portfolio-history.mjs +0 -394
- package/src/data/providers/portfolio.mjs +0 -600
- package/src/data/providers/pyth-price-feeds.mjs +0 -172
- package/src/data/providers/raydium.mjs +0 -35
- package/src/data/providers/relayscan-mev.mjs +0 -72
- package/src/data/providers/rfq.mjs +0 -15
- package/src/data/providers/rh-agent.mjs +0 -59
- package/src/data/providers/sanctum-lst.mjs +0 -180
- package/src/data/providers/satflow.mjs +0 -341
- package/src/data/providers/signed-material-guard.mjs +0 -108
- package/src/data/providers/solana-rpc.mjs +0 -197
- package/src/data/providers/solend-lending.mjs +0 -166
- package/src/data/providers/spark-lend.mjs +0 -42
- package/src/data/providers/squid-router.mjs +0 -29
- package/src/data/providers/stargate.mjs +0 -29
- package/src/data/providers/sushiswap.mjs +0 -30
- package/src/data/providers/symbiotic-restaking.mjs +0 -41
- package/src/data/providers/thorchain.mjs +0 -36
- package/src/data/providers/traderjoe.mjs +0 -28
- package/src/data/providers/twap.mjs +0 -152
- package/src/data/providers/uniswap-v3.mjs +0 -457
- package/src/data/providers/uniswap-v4.mjs +0 -414
- package/src/data/providers/vertex.mjs +0 -41
- package/src/data/providers/wallet-watch.mjs +0 -264
- package/src/data/providers/wormhole.mjs +0 -28
- package/src/data/providers/yearn.mjs +0 -31
- package/src/data/providers/zerox.mjs +0 -167
- package/src/data/public-api-scan.mjs +0 -61
- package/src/data/quote-placeholder.mjs +0 -31
- package/src/desk/swap-prepare.mjs +0 -194
- package/src/equities/bridge.mjs +0 -388
- package/src/equities/fixtures/bridge_routes.json +0 -159
- package/src/equities/fixtures/dst_transitions.json +0 -29
- package/src/equities/fixtures/equity_dex_pools.json +0 -154
- package/src/equities/fixtures/hip3_l2books.json +0 -2711
- package/src/equities/fixtures/nyse_holidays.json +0 -1
- package/src/equities/fixtures/oracles.json +0 -100
- package/src/equities/fixtures/rh_pool_state.json +0 -244
- package/src/equities/fixtures/solana_xstocks.json +0 -704
- package/src/equities/fixtures/ton_xstocks.json +0 -35
- package/src/equities/fixtures/universe.json +0 -411
- package/src/equities/fixtures/venues.json +0 -3542
- package/src/equities/fixtures.mjs +0 -405
- package/src/equities/funding.mjs +0 -142
- package/src/equities/index.mjs +0 -166
- package/src/equities/liveness.mjs +0 -148
- package/src/equities/marketHours.mjs +0 -249
- package/src/equities/normalize.mjs +0 -295
- package/src/equities/num.mjs +0 -146
- package/src/equities/prepare.mjs +0 -95
- package/src/equities/rank.mjs +0 -260
- package/src/equities/sourceNum.mjs +0 -69
- package/src/equities/types.mjs +0 -220
- package/src/equities/venues/arcus-perp.mjs +0 -84
- package/src/equities/venues/arcus-spot.mjs +0 -105
- package/src/equities/venues/hyperliquid-hip3.mjs +0 -224
- package/src/equities/venues/rh-uniswap.mjs +0 -216
- package/src/equities/venues/solana-xstocks.mjs +0 -139
- package/src/equities/venues/ton-stonfi.mjs +0 -139
- package/src/exact-integer.mjs +0 -72
- package/src/exec-policy.mjs +0 -419
- package/src/flags.mjs +0 -15
- package/src/fresh-window.mjs +0 -76
- package/src/gmx-attestation.mjs +0 -176
- package/src/index.mjs +0 -107
- package/src/licensing/locals-only.mjs +0 -25
- package/src/nft-gas-war-guard.mjs +0 -139
- package/src/onboarding/agent-keys.mjs +0 -161
- package/src/onboarding/harness-configs.mjs +0 -102
- package/src/onboarding/index.mjs +0 -18
- package/src/onboarding/tiers.mjs +0 -139
- package/src/oracle-env.mjs +0 -55
- package/src/package-manifest.mjs +0 -42
- package/src/plugins/agent-plugin-loader.mjs +0 -225
- package/src/portfolio-risk.mjs +0 -170
- package/src/prepare-envelope.mjs +0 -204
- package/src/profile-upgrade.mjs +0 -277
- package/src/protocol-execution.mjs +0 -84
- package/src/protocol-templates/gate.mjs +0 -179
- package/src/protocol-templates/prepare-deploy.mjs +0 -81
- package/src/public-api/agent-grants.mjs +0 -57
- package/src/public-api/buzz-integration.mjs +0 -267
- package/src/public-api/connect-agent.mjs +0 -424
- package/src/public-api/grants.mjs +0 -142
- package/src/public-api/http.mjs +0 -707
- package/src/public-api/metering.mjs +0 -111
- package/src/public-control/aa-adapter.mjs +0 -402
- package/src/public-control/build-registry.mjs +0 -227
- package/src/public-control/bundler-client.mjs +0 -357
- package/src/public-control/grant-indexer.mjs +0 -296
- package/src/public-control/policy-render.mjs +0 -69
- package/src/public-control/policy-schema.mjs +0 -322
- package/src/public-control/runtime-config.mjs +0 -275
- package/src/public-control/session-key-model.mjs +0 -379
- package/src/public-control/session-orchestrator.mjs +0 -418
- package/src/rfq/intent.mjs +0 -180
- package/src/rfq/sources.mjs +0 -181
- package/src/route-attestation.mjs +0 -132
- package/src/router/best-execution.mjs +0 -326
- package/src/router/index.mjs +0 -250
- package/src/router/integrator-fee.mjs +0 -135
- package/src/router/prepare-bridge.mjs +0 -293
- package/src/router/prepare-route.mjs +0 -398
- package/src/router/proposal.mjs +0 -311
- package/src/router/risk-classifier.mjs +0 -119
- package/src/router/route-sources.mjs +0 -364
- package/src/scanner/chains.config.mjs +0 -543
- package/src/scanner/contract.mjs +0 -270
- package/src/scanner/evm-scanner.mjs +0 -394
- package/src/scanner/index.mjs +0 -9
- package/src/scanner/v2-venue.mjs +0 -351
- package/src/scanner/v3-venue.mjs +0 -308
- package/src/scopes.mjs +0 -44
- package/src/sell-simulation.mjs +0 -167
- package/src/signals/engine.mjs +0 -146
- package/src/signals/index.mjs +0 -1
- package/src/token-transfer-guard.mjs +0 -188
- package/src/tui/app.mjs +0 -438
- package/src/tui/backend.mjs +0 -215
- package/src/tui/format.mjs +0 -272
- package/src/tui/gateway-client.mjs +0 -177
- package/src/tui/input.mjs +0 -501
- package/src/tui/memory.mjs +0 -105
- package/src/tui/meta-learn.mjs +0 -85
- package/src/tui/renderer.mjs +0 -443
- package/src/tui/scheduler.mjs +0 -205
- package/src/tui/skills-loader.mjs +0 -140
- package/src/tui/standalone-client.mjs +0 -752
- package/src/tui/theme.mjs +0 -81
- package/src/vault-attestation.mjs +0 -146
- package/src/venues.mjs +0 -206
- package/src/watch-preferences.mjs +0 -85
- /package/{profiles → dist/assets/profiles}/_template/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/_template/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/bitcoin-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/bitcoin-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/hyperliquid-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/hyperliquid-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/oracle/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/oracle/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/polymarket-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/polymarket-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/profile.schema.json +0 -0
- /package/{profiles → dist/assets/profiles}/protocol-builder/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/protocol-builder/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/robinhood-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/robinhood-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/solana-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/solana-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/stable-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/stable-agent/profile.json +0 -0
- /package/{skills → dist/assets/skills}/balance/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/bitcoin-l1.md +0 -0
- /package/{skills → dist/assets/skills}/chain-defi-ecosystem-profiling.md +0 -0
- /package/{skills → dist/assets/skills}/evm-contract-research.md +0 -0
- /package/{skills → dist/assets/skills}/hyperliquid.md +0 -0
- /package/{skills → dist/assets/skills}/multichain-exec-desk.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-action-semantics/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-best-execution/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-best-execution.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-bitcoin/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chain-graphs-telegram-cards/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chat/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chat/chain.SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chat/setup.SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-circuit-breaker/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-contract-research/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-desk/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-desk.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-dex-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-equities/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-grants/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-hypercore-staking/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-hyperliquid/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-meme-token-sniper/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-multichain-nft-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-multichain-token-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-nft-gacha-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-nft-mint-gas-war/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-polymarket/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-protocol-builder/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-protocol-security/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-public-product/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-receipts/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-receipts.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-rfq-tokenized-assets/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-smart-wallet-scanner/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-solana/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-solana-nft/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-token-research/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/solana.md +0 -0
package/src/action-receipts.mjs
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
// Deterministic, public-only receipts for prepared and executed actions.
|
|
2
|
-
//
|
|
3
|
-
// This module deliberately has no authority and no I/O: it does not authorize,
|
|
4
|
-
// sign, broadcast, or fetch. It only records facts supplied by its caller.
|
|
5
|
-
|
|
6
|
-
import { createHash } from "node:crypto";
|
|
7
|
-
import { wordlists } from "ethers";
|
|
8
|
-
|
|
9
|
-
export const ACTION_RECEIPT_VERSION = 1;
|
|
10
|
-
|
|
11
|
-
// Key-name matching was exact-ish and only covered five words, so every wallet
|
|
12
|
-
// export alias (secretKey, seedPhrase, wif, keyMaterial, privKey, xprv, seed,
|
|
13
|
-
// keystore) sailed through. There was also NO value-shape rule, so a raw key or
|
|
14
|
-
// a BIP-39 phrase pasted into a benign field like `memo` was recorded verbatim.
|
|
15
|
-
//
|
|
16
|
-
// Both concerns were already solved in src/address-book.mjs; this module simply
|
|
17
|
-
// did not use the hardened list. Found by the opus lane of the 2026-08-03
|
|
18
|
-
// four-model review, and verified to PERSIST: unknown top-level props are
|
|
19
|
-
// dropped by the schema whitelist, but a secret nested inside a RETAINED field
|
|
20
|
-
// (intent, route, decodedAction) survives into the frozen receipt.
|
|
21
|
-
const SECRET_KEYS = new Set([
|
|
22
|
-
"privatekey",
|
|
23
|
-
"privkey",
|
|
24
|
-
"secretkey",
|
|
25
|
-
"seedphrase",
|
|
26
|
-
"seed",
|
|
27
|
-
"mnemonic",
|
|
28
|
-
"passphrase",
|
|
29
|
-
"password",
|
|
30
|
-
"keystore",
|
|
31
|
-
"keymaterial",
|
|
32
|
-
"wif",
|
|
33
|
-
"xprv",
|
|
34
|
-
"xpriv",
|
|
35
|
-
"bearer",
|
|
36
|
-
"authorization",
|
|
37
|
-
"signature",
|
|
38
|
-
"apikey",
|
|
39
|
-
"credential",
|
|
40
|
-
]);
|
|
41
|
-
|
|
42
|
-
// Unambiguous key shapes: WIF, extended private key, BIP-39 word run. These are
|
|
43
|
-
// refused wherever they appear.
|
|
44
|
-
//
|
|
45
|
-
// A bare 64-hex string is deliberately NOT in this list. A raw EVM private key
|
|
46
|
-
// and a bytes32 tx hash are byte-identical, and receipts legitimately carry
|
|
47
|
-
// txHash / orderHash / salt / merkleRoot / nonce. Blanket-refusing 64-hex would
|
|
48
|
-
// break real receipts — an over-tight filter is its own bug. It is instead
|
|
49
|
-
// gated on the field name below.
|
|
50
|
-
const KEY_SHAPED_VALUE = [
|
|
51
|
-
/\b[5KL][1-9A-HJ-NP-Za-km-z]{50,51}\b/,
|
|
52
|
-
/\bxprv[0-9A-Za-z]{50,}\b/,
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
const BIP39_WORD_COUNTS = new Set([12, 15, 18, 21, 24]);
|
|
56
|
-
|
|
57
|
-
function isBip39EnglishPhrase(value) {
|
|
58
|
-
const words = String(value).trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
59
|
-
return BIP39_WORD_COUNTS.has(words.length) && words.every((word) => wordlists.en.getWordIndex(word) >= 0);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const BARE_32_BYTE_HEX = /^\s*(?:0x)?[0-9a-fA-F]{64}\s*$/;
|
|
63
|
-
|
|
64
|
-
// Field names whose whole value is EXPECTED to be a 32-byte digest.
|
|
65
|
-
//
|
|
66
|
-
// The trailing `(?:e?s)?` matters: `publicValue` scans array leaves using the
|
|
67
|
-
// PARENT key, so a batched route's `orderHashes` / `proofs` / `commitments`
|
|
68
|
-
// arrives here in its plural form (English pluralizes `hash` as `hashes`).
|
|
69
|
-
// Without it a digest LIST is refused while the exact same digest in singular
|
|
70
|
-
// form is accepted — an over-tight filter that breaks real receipts and blocks
|
|
71
|
-
// no secret (key-SHAPED values are refused by KEY_SHAPED_VALUE / BIP-39
|
|
72
|
-
// regardless of field name).
|
|
73
|
-
const DIGEST_FIELD = /(hash|digest|root|salt|nonce|proof|commitment|sig|id)(?:e?s)?$/i;
|
|
74
|
-
const PROTOCOL_HEX_FIELDS = new Set([
|
|
75
|
-
"calldata",
|
|
76
|
-
"data",
|
|
77
|
-
"publickey",
|
|
78
|
-
"pubkey",
|
|
79
|
-
"message",
|
|
80
|
-
"payload",
|
|
81
|
-
"input",
|
|
82
|
-
"extradata",
|
|
83
|
-
]);
|
|
84
|
-
|
|
85
|
-
function allows32ByteHex(key) {
|
|
86
|
-
const normalized = normalizedKey(key);
|
|
87
|
-
return PROTOCOL_HEX_FIELDS.has(normalized) || DIGEST_FIELD.test(normalized);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export class ActionReceiptSecretError extends Error {
|
|
91
|
-
constructor(path) {
|
|
92
|
-
super(`action receipt refused: secret-bearing field at ${path}`);
|
|
93
|
-
this.name = "ActionReceiptSecretError";
|
|
94
|
-
this.code = "ACTION_RECEIPT_SECRET";
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function normalizedKey(key) {
|
|
99
|
-
return String(key).replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function isSecretKey(key) {
|
|
103
|
-
const normalized = normalizedKey(key);
|
|
104
|
-
return [...SECRET_KEYS].some((secret) => normalized.includes(secret));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Refuse a key-material-shaped VALUE, so a secret pasted into a benign field
|
|
109
|
-
* name (memo, note, label) cannot be recorded verbatim.
|
|
110
|
-
*
|
|
111
|
-
* Bare 64-hex is only refused when the field name is NOT digest-shaped: a raw
|
|
112
|
-
* EVM private key and a bytes32 hash are byte-identical, and receipts carry
|
|
113
|
-
* txHash / orderHash / salt / nonce legitimately.
|
|
114
|
-
*/
|
|
115
|
-
function assertNoSecretValue(key, value, path) {
|
|
116
|
-
if (typeof value !== "string") return;
|
|
117
|
-
if (KEY_SHAPED_VALUE.some((re) => re.test(value)) || isBip39EnglishPhrase(value)) {
|
|
118
|
-
throw new ActionReceiptSecretError(path);
|
|
119
|
-
}
|
|
120
|
-
if (BARE_32_BYTE_HEX.test(value) && !allows32ByteHex(key)) {
|
|
121
|
-
throw new ActionReceiptSecretError(path);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function publicValue(value, path = "$", key = "") {
|
|
126
|
-
if (value == null || typeof value === "boolean") return value;
|
|
127
|
-
if (typeof value === "string") {
|
|
128
|
-
assertNoSecretValue(key, value, path);
|
|
129
|
-
return value;
|
|
130
|
-
}
|
|
131
|
-
if (typeof value === "number") {
|
|
132
|
-
if (!Number.isFinite(value)) throw new TypeError(`action receipt: non-finite number at ${path}`);
|
|
133
|
-
return value;
|
|
134
|
-
}
|
|
135
|
-
if (typeof value === "bigint") return value.toString();
|
|
136
|
-
if (Array.isArray(value)) return value.map((item, index) => publicValue(item, `${path}[${index}]`, key));
|
|
137
|
-
if (typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
|
|
138
|
-
throw new TypeError(`action receipt: JSON-like value required at ${path}`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const out = {};
|
|
142
|
-
for (const childKey of Object.keys(value).sort()) {
|
|
143
|
-
const childPath = `${path}.${childKey}`;
|
|
144
|
-
if (isSecretKey(childKey)) throw new ActionReceiptSecretError(childPath);
|
|
145
|
-
if (value[childKey] !== undefined) out[childKey] = publicValue(value[childKey], childPath, childKey);
|
|
146
|
-
}
|
|
147
|
-
return out;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/** Recursively reject secret-bearing fields and return a detached public copy. */
|
|
151
|
-
export function assertNoReceiptSecrets(value) {
|
|
152
|
-
return publicValue(value);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function canonicalPublicJson(value) {
|
|
156
|
-
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
157
|
-
if (Array.isArray(value)) return `[${value.map(canonicalPublicJson).join(",")}]`;
|
|
158
|
-
return `{${Object.keys(value).map((key) => `${JSON.stringify(key)}:${canonicalPublicJson(value[key])}`).join(",")}}`;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/** Canonical JSON with recursively sorted object keys. */
|
|
162
|
-
export function canonicalReceiptJson(value) {
|
|
163
|
-
return canonicalPublicJson(publicValue(value));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/** Hash exactly the public receipt fields, excluding the self-referential id. */
|
|
167
|
-
export function computeReceiptId(receipt) {
|
|
168
|
-
if (!receipt || typeof receipt !== "object" || Array.isArray(receipt)) {
|
|
169
|
-
throw new TypeError("action receipt: object required");
|
|
170
|
-
}
|
|
171
|
-
const { receiptId: _ignored, summary: _derived, ...publicFields } = receipt;
|
|
172
|
-
return createHash("sha256").update(canonicalReceiptJson(publicFields)).digest("hex");
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function supplied(input, ...keys) {
|
|
176
|
-
for (const key of keys) if (input[key] !== undefined) return input[key];
|
|
177
|
-
return undefined;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function required(input, keys, label) {
|
|
181
|
-
const value = supplied(input, ...keys);
|
|
182
|
-
if (value === undefined || value === null) throw new TypeError(`action receipt: ${label} required`);
|
|
183
|
-
return value;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function balanceFields(input) {
|
|
187
|
-
const balances = supplied(input, "balances", "balanceChanges");
|
|
188
|
-
const before = supplied(input, "beforeBalances", "balancesBefore", "before");
|
|
189
|
-
const after = supplied(input, "afterBalances", "balancesAfter", "after");
|
|
190
|
-
if (balances !== undefined) return { balances };
|
|
191
|
-
if (before === undefined && after === undefined) return {};
|
|
192
|
-
return { balances: { ...(before === undefined ? {} : { before }), ...(after === undefined ? {} : { after }) } };
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Normalize caller-supplied prepare/execute facts into the versioned schema.
|
|
197
|
-
* Unknown input fields are intentionally omitted from the receipt.
|
|
198
|
-
*/
|
|
199
|
-
export function normalizeActionReceipt(input = {}) {
|
|
200
|
-
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
201
|
-
throw new TypeError("action receipt: input object required");
|
|
202
|
-
}
|
|
203
|
-
// Scan the complete input before selecting fields so a secret cannot be
|
|
204
|
-
// hidden in an otherwise unknown property and accidentally appear later.
|
|
205
|
-
publicValue(input);
|
|
206
|
-
|
|
207
|
-
const txHash = supplied(input, "txHash", "transactionHash");
|
|
208
|
-
const phase = supplied(input, "phase", "stage", "resultType") ?? (txHash == null ? "prepare" : "execute");
|
|
209
|
-
if (phase !== "prepare" && phase !== "execute") {
|
|
210
|
-
throw new TypeError('action receipt: phase must be "prepare" or "execute"');
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const fields = {
|
|
214
|
-
receiptVersion: ACTION_RECEIPT_VERSION,
|
|
215
|
-
phase,
|
|
216
|
-
intent: required(input, ["intent"], "intent"),
|
|
217
|
-
route: required(input, ["route"], "route"),
|
|
218
|
-
decodedAction: required(input, ["decodedAction", "action"], "decodedAction"),
|
|
219
|
-
policyChecks: required(input, ["policyChecks", "checks"], "policyChecks"),
|
|
220
|
-
allowlistHits: required(input, ["allowlistHits", "allowlistMatches"], "allowlistHits"),
|
|
221
|
-
prepareHash: required(input, ["prepareHash"], "prepareHash"),
|
|
222
|
-
...(txHash == null ? {} : { txHash }),
|
|
223
|
-
...balanceFields(input),
|
|
224
|
-
};
|
|
225
|
-
const receipt = publicValue(fields);
|
|
226
|
-
return Object.freeze({ ...receipt, receiptId: computeReceiptId(receipt) });
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export const createActionReceipt = normalizeActionReceipt;
|
|
230
|
-
|
|
231
|
-
function label(value, preferred = []) {
|
|
232
|
-
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
233
|
-
for (const key of preferred) if (value?.[key] != null) return String(value[key]);
|
|
234
|
-
return "recorded";
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function checkResult(check) {
|
|
238
|
-
if (typeof check === "boolean") return check;
|
|
239
|
-
if (check && typeof check === "object") {
|
|
240
|
-
if (typeof check.ok === "boolean") return check.ok;
|
|
241
|
-
if (typeof check.allowed === "boolean") return check.allowed;
|
|
242
|
-
if (typeof check.passed === "boolean") return check.passed;
|
|
243
|
-
}
|
|
244
|
-
return null;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/** Produce a compact human-readable statement without changing the receipt. */
|
|
248
|
-
export function summarizeActionReceipt(receipt) {
|
|
249
|
-
if (!receipt || typeof receipt !== "object") throw new TypeError("action receipt: object required");
|
|
250
|
-
const action = label(receipt.decodedAction, ["type", "action", "method", "name"]);
|
|
251
|
-
const route = label(receipt.route, ["name", "provider", "venue", "id"]);
|
|
252
|
-
const checks = Array.isArray(receipt.policyChecks)
|
|
253
|
-
? receipt.policyChecks
|
|
254
|
-
: Object.values(receipt.policyChecks || {});
|
|
255
|
-
const passed = checks.filter((check) => checkResult(check) === true).length;
|
|
256
|
-
const failed = checks.filter((check) => checkResult(check) === false).length;
|
|
257
|
-
const hits = Array.isArray(receipt.allowlistHits)
|
|
258
|
-
? receipt.allowlistHits.length
|
|
259
|
-
: Object.keys(receipt.allowlistHits || {}).length;
|
|
260
|
-
const tx = receipt.txHash == null ? "no transaction hash" : `tx ${receipt.txHash}`;
|
|
261
|
-
const balances = receipt.balances == null ? "balances not provided" : "before/after balances recorded";
|
|
262
|
-
return `${receipt.phase} ${action} via ${route}; policy ${passed} passed, ${failed} failed; ${hits} allowlist hit${hits === 1 ? "" : "s"}; ${tx}; ${balances}; receipt ${receipt.receiptId}`;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export const formatActionReceipt = summarizeActionReceipt;
|
package/src/action-semantics.mjs
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export const ACTION_MODES = Object.freeze({
|
|
2
|
-
ALERT_ONLY: "alert_only",
|
|
3
|
-
EXECUTE: "execute",
|
|
4
|
-
});
|
|
5
|
-
|
|
6
|
-
const ALERT_VERBS = new Set(["watch", "watch this", "ping", "ping me", "alert", "notify"]);
|
|
7
|
-
const ACTIVE_LEGACY_WATCH_STATUSES = new Set(["watching", "armed"]);
|
|
8
|
-
|
|
9
|
-
export function actionModeForVerb(verb) {
|
|
10
|
-
if (typeof verb !== "string" || !verb.trim()) {
|
|
11
|
-
throw new TypeError("explicit action verb required");
|
|
12
|
-
}
|
|
13
|
-
const normalized = verb.trim().toLowerCase().replace(/\s+/g, " ");
|
|
14
|
-
if (ALERT_VERBS.has(normalized)) return ACTION_MODES.ALERT_ONLY;
|
|
15
|
-
if (normalized === "arm") return ACTION_MODES.EXECUTE;
|
|
16
|
-
throw new TypeError(`unsupported action verb: ${normalized}`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function createActionRecord(input = {}) {
|
|
20
|
-
const { verb, ...fields } = input;
|
|
21
|
-
return {
|
|
22
|
-
...fields,
|
|
23
|
-
active: true,
|
|
24
|
-
actionMode: actionModeForVerb(verb),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function assertActionRecord(record) {
|
|
29
|
-
if (!record || typeof record !== "object" || typeof record.active !== "boolean") {
|
|
30
|
-
throw new TypeError("active must be boolean");
|
|
31
|
-
}
|
|
32
|
-
if (!Object.values(ACTION_MODES).includes(record.actionMode)) {
|
|
33
|
-
throw new TypeError("actionMode must be alert_only or execute");
|
|
34
|
-
}
|
|
35
|
-
return record;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function isActiveAlert(record) {
|
|
39
|
-
return record?.active === true && record?.actionMode === ACTION_MODES.ALERT_ONLY;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function isActiveExecution(record) {
|
|
43
|
-
return record?.active === true && record?.actionMode === ACTION_MODES.EXECUTE;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function migrateLegacyWatchRecord(record = {}) {
|
|
47
|
-
if (
|
|
48
|
-
record.actionMode !== undefined &&
|
|
49
|
-
record.actionMode !== ACTION_MODES.ALERT_ONLY
|
|
50
|
-
) {
|
|
51
|
-
throw new TypeError("non-alert record cannot enter alert-only watch migration");
|
|
52
|
-
}
|
|
53
|
-
const active =
|
|
54
|
-
typeof record.active === "boolean"
|
|
55
|
-
? record.active
|
|
56
|
-
: ACTIVE_LEGACY_WATCH_STATUSES.has(String(record.status || "").toLowerCase());
|
|
57
|
-
return {
|
|
58
|
-
...record,
|
|
59
|
-
active,
|
|
60
|
-
actionMode: ACTION_MODES.ALERT_ONLY,
|
|
61
|
-
};
|
|
62
|
-
}
|
package/src/address-book.mjs
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Durable labeled address book for owner/agent/counterparty wallets.
|
|
3
|
-
*
|
|
4
|
-
* On by default: remembering who an address belongs to is a read/annotate
|
|
5
|
-
* concern, not an execution one. Nothing here signs, and no private key,
|
|
6
|
-
* passphrase, or seed is ever accepted or stored.
|
|
7
|
-
*/
|
|
8
|
-
import fs from "node:fs";
|
|
9
|
-
import path from "node:path";
|
|
10
|
-
import { ORACLE_CONFIG_DIR, env } from "./oracle-env.mjs";
|
|
11
|
-
|
|
12
|
-
const ADDR_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
13
|
-
const FORBIDDEN_KEYS = new Set([
|
|
14
|
-
"privatekey", "private_key", "secret", "seed", "mnemonic", "passphrase", "signature", "keystore",
|
|
15
|
-
]);
|
|
16
|
-
|
|
17
|
-
// Exact-name matching missed obvious aliases (secretKey, seedPhrase, wif,
|
|
18
|
-
// keyMaterial, xprv...). Match on a normalized key instead: strip separators,
|
|
19
|
-
// lowercase, then look for any secret-ish token as a substring. A label store
|
|
20
|
-
// has no legitimate field containing these words.
|
|
21
|
-
const FORBIDDEN_TOKENS = [
|
|
22
|
-
"privatekey", "privkey", "secretkey", "secret", "seedphrase", "seed", "mnemonic",
|
|
23
|
-
"passphrase", "password", "keystore", "keymaterial", "signature", "wif",
|
|
24
|
-
"xprv", "xpriv", "apikey", "bearer", "credential",
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
// Key-shaped values must not be persisted even in a free-text field. WIF, xprv,
|
|
28
|
-
// and BIP39 shapes are unambiguous. A bare 64-hex string is NOT — a raw EVM
|
|
29
|
-
// private key and a bytes32 tx hash are byte-identical — so that rule matches
|
|
30
|
-
// only when the WHOLE field is the hex blob. "paid via tx 0xabc..." is a note,
|
|
31
|
-
// not a leaked key.
|
|
32
|
-
const KEY_SHAPED_VALUE = [
|
|
33
|
-
/\b[5KL][1-9A-HJ-NP-Za-km-z]{50,51}\b/,
|
|
34
|
-
/\bxprv[0-9A-Za-z]{50,}\b/,
|
|
35
|
-
/\b(?:[a-z]{3,8}\s+){11,}[a-z]{3,8}\b/i,
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
const BARE_32_BYTE_HEX = /^\s*(?:0x)?[0-9a-fA-F]{64}\s*$/;
|
|
39
|
-
|
|
40
|
-
function normalizeKeyName(key) {
|
|
41
|
-
return String(key).toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function assertNoSecretKeyName(key, path) {
|
|
45
|
-
const normalized = normalizeKeyName(key);
|
|
46
|
-
if (FORBIDDEN_KEYS.has(String(key).toLowerCase()) || FORBIDDEN_TOKENS.some((t) => normalized.includes(t))) {
|
|
47
|
-
throw new Error(`address-book: ${path} is forbidden; the book stores labels, never key material`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function assertNoSecretValue(value, path) {
|
|
52
|
-
if (typeof value !== "string") return;
|
|
53
|
-
if (KEY_SHAPED_VALUE.some((re) => re.test(value)) || BARE_32_BYTE_HEX.test(value)) {
|
|
54
|
-
throw new Error(`address-book: ${path} looks like key material; the book stores labels, never key material`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function addressBookPath() {
|
|
59
|
-
const override = env("ORACLE_ADDRESS_BOOK", "MAD_ADDRESS_BOOK", "");
|
|
60
|
-
if (override) return path.resolve(override);
|
|
61
|
-
const dir = env("ORACLE_CONFIG_DIR", "MAD_CONFIG_DIR", ORACLE_CONFIG_DIR);
|
|
62
|
-
return path.join(dir, "address-book.json");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function assertNoSecrets(input, path = "field") {
|
|
66
|
-
if (Array.isArray(input)) {
|
|
67
|
-
input.forEach((item, i) => assertNoSecrets(item, `${path}[${i}]`));
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!input || typeof input !== "object") {
|
|
71
|
-
assertNoSecretValue(input, path);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
for (const [key, value] of Object.entries(input)) {
|
|
75
|
-
assertNoSecretKeyName(key, key);
|
|
76
|
-
assertNoSecrets(value, key);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function normalizeAddress(value) {
|
|
81
|
-
const address = String(value || "").trim();
|
|
82
|
-
if (!ADDR_RE.test(address)) throw new Error("address-book: address must be 0x + 40 hex characters");
|
|
83
|
-
return address.toLowerCase();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function text(value, max) {
|
|
87
|
-
if (value == null || value === "") return null;
|
|
88
|
-
return String(value).slice(0, max);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function emptyBook() {
|
|
92
|
-
return { version: 1, updatedAt: null, entries: [] };
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function normalizeEntry(entry) {
|
|
96
|
-
return {
|
|
97
|
-
address: String(entry.address).toLowerCase(),
|
|
98
|
-
label: text(entry.label, 80) || "unknown",
|
|
99
|
-
who: text(entry.who, 120),
|
|
100
|
-
role: text(entry.role, 40),
|
|
101
|
-
chainIds: Array.isArray(entry.chainIds) ? entry.chainIds.map(Number).filter(Number.isFinite) : [],
|
|
102
|
-
notes: text(entry.notes, 500),
|
|
103
|
-
source: text(entry.source, 80),
|
|
104
|
-
firstSeenAt: entry.firstSeenAt || null,
|
|
105
|
-
lastSeenAt: entry.lastSeenAt || null,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function readAddressBook() {
|
|
110
|
-
try {
|
|
111
|
-
const raw = JSON.parse(fs.readFileSync(addressBookPath(), "utf8"));
|
|
112
|
-
if (!raw || typeof raw !== "object") return emptyBook();
|
|
113
|
-
const entries = Array.isArray(raw.entries) ? raw.entries : [];
|
|
114
|
-
return {
|
|
115
|
-
version: 1,
|
|
116
|
-
updatedAt: raw.updatedAt || null,
|
|
117
|
-
entries: entries
|
|
118
|
-
.filter((entry) => entry && typeof entry === "object" && ADDR_RE.test(String(entry.address || "")))
|
|
119
|
-
.map(normalizeEntry),
|
|
120
|
-
};
|
|
121
|
-
} catch {
|
|
122
|
-
return emptyBook();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function writeBook(book) {
|
|
127
|
-
const file = addressBookPath();
|
|
128
|
-
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
129
|
-
const payload = { ...book, version: 1, updatedAt: new Date().toISOString() };
|
|
130
|
-
const tmp = path.join(path.dirname(file), `.address-book.${process.pid}.tmp`);
|
|
131
|
-
fs.writeFileSync(tmp, `${JSON.stringify(payload, null, 2)}\n`, { mode: 0o600 });
|
|
132
|
-
fs.renameSync(tmp, file);
|
|
133
|
-
try {
|
|
134
|
-
fs.chmodSync(file, 0o600);
|
|
135
|
-
} catch {
|
|
136
|
-
/* best effort on platforms without chmod semantics */
|
|
137
|
-
}
|
|
138
|
-
return payload;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export function listAddresses(filter = {}) {
|
|
142
|
-
const book = readAddressBook();
|
|
143
|
-
let entries = book.entries;
|
|
144
|
-
if (filter.role) entries = entries.filter((entry) => entry.role === String(filter.role));
|
|
145
|
-
if (filter.who) {
|
|
146
|
-
const query = String(filter.who).toLowerCase();
|
|
147
|
-
entries = entries.filter(
|
|
148
|
-
(entry) => (entry.who || "").toLowerCase().includes(query) || (entry.label || "").toLowerCase().includes(query),
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
if (filter.q) {
|
|
152
|
-
const query = String(filter.q).toLowerCase();
|
|
153
|
-
entries = entries.filter(
|
|
154
|
-
(entry) =>
|
|
155
|
-
entry.address.includes(query) ||
|
|
156
|
-
(entry.label || "").toLowerCase().includes(query) ||
|
|
157
|
-
(entry.who || "").toLowerCase().includes(query) ||
|
|
158
|
-
(entry.notes || "").toLowerCase().includes(query),
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
return { updatedAt: book.updatedAt, count: entries.length, entries };
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function lookupAddress(address) {
|
|
165
|
-
const normalized = normalizeAddress(address);
|
|
166
|
-
const entries = readAddressBook().entries.filter((entry) => entry.address === normalized);
|
|
167
|
-
return { address: normalized, found: entries.length > 0, entries };
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export function rememberAddress(input = {}) {
|
|
171
|
-
assertNoSecrets(input);
|
|
172
|
-
const address = normalizeAddress(input.address);
|
|
173
|
-
const label = text(input.label ?? input.role, 80) || "wallet";
|
|
174
|
-
const now = new Date().toISOString();
|
|
175
|
-
const book = readAddressBook();
|
|
176
|
-
const index = book.entries.findIndex((entry) => entry.address === address && entry.label === label);
|
|
177
|
-
const entry = normalizeEntry({
|
|
178
|
-
address,
|
|
179
|
-
label,
|
|
180
|
-
who: input.who,
|
|
181
|
-
role: input.role,
|
|
182
|
-
chainIds: input.chainIds,
|
|
183
|
-
notes: input.notes,
|
|
184
|
-
source: input.source || "agent",
|
|
185
|
-
firstSeenAt: index >= 0 ? book.entries[index].firstSeenAt || now : now,
|
|
186
|
-
lastSeenAt: now,
|
|
187
|
-
});
|
|
188
|
-
if (index >= 0) book.entries[index] = entry;
|
|
189
|
-
else book.entries.push(entry);
|
|
190
|
-
const rank = (role) => (role === "agent" ? 0 : role === "owner" ? 1 : 2);
|
|
191
|
-
book.entries.sort(
|
|
192
|
-
(a, b) => rank(a.role) - rank(b.role) || a.label.localeCompare(b.label) || a.address.localeCompare(b.address),
|
|
193
|
-
);
|
|
194
|
-
const saved = writeBook(book);
|
|
195
|
-
return { ok: true, entry, count: saved.entries.length };
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export function forgetAddress(address, label = null) {
|
|
199
|
-
const normalized = normalizeAddress(address);
|
|
200
|
-
const book = readAddressBook();
|
|
201
|
-
const before = book.entries.length;
|
|
202
|
-
book.entries = book.entries.filter((entry) => {
|
|
203
|
-
if (entry.address !== normalized) return true;
|
|
204
|
-
return label == null ? false : entry.label !== String(label);
|
|
205
|
-
});
|
|
206
|
-
writeBook(book);
|
|
207
|
-
return { ok: true, removed: before - book.entries.length, count: book.entries.length };
|
|
208
|
-
}
|