@onecraft/wallet 0.0.0-stage → 0.1.145

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 (248) hide show
  1. package/.claude-plugin/marketplace.json +20 -0
  2. package/.openclaw/AGENTS.md +100 -0
  3. package/.openclaw/extensions/agent-wallet/README.md +195 -0
  4. package/.openclaw/extensions/agent-wallet/dist/index.js +2198 -0
  5. package/.openclaw/extensions/agent-wallet/index.ts +2198 -0
  6. package/.openclaw/extensions/agent-wallet/openclaw.plugin.json +251 -0
  7. package/.openclaw/extensions/agent-wallet/package.json +49 -0
  8. package/.openclaw/extensions/agent-wallet/skills/cards/SKILL.md +211 -0
  9. package/.openclaw/extensions/agent-wallet/skills/wallet-operator/SKILL.md +30 -0
  10. package/CHANGELOG.md +1232 -0
  11. package/LICENSE +104 -0
  12. package/README.md +193 -2
  13. package/VERSION +1 -0
  14. package/agent-wallet/.env.example +63 -0
  15. package/agent-wallet/AGENTS.md +130 -0
  16. package/agent-wallet/CARD_VAULT.md +640 -0
  17. package/agent-wallet/README.md +615 -0
  18. package/agent-wallet/UPGRADE_COMPATIBILITY.md +66 -0
  19. package/agent-wallet/agent_wallet/__init__.py +16 -0
  20. package/agent-wallet/agent_wallet/approval.py +165 -0
  21. package/agent-wallet/agent_wallet/autonomous_permissions.py +281 -0
  22. package/agent-wallet/agent_wallet/autonomous_policy.py +305 -0
  23. package/agent-wallet/agent_wallet/autonomous_session.py +236 -0
  24. package/agent-wallet/agent_wallet/boot_key_migration.py +155 -0
  25. package/agent-wallet/agent_wallet/boot_key_recovery.py +57 -0
  26. package/agent-wallet/agent_wallet/bootstrap.py +194 -0
  27. package/agent-wallet/agent_wallet/card_catalog.py +243 -0
  28. package/agent-wallet/agent_wallet/card_runtime_secrets.py +108 -0
  29. package/agent-wallet/agent_wallet/card_vault.py +331 -0
  30. package/agent-wallet/agent_wallet/card_vault_cli.py +174 -0
  31. package/agent-wallet/agent_wallet/card_vault_import.py +65 -0
  32. package/agent-wallet/agent_wallet/card_vault_keychain.py +239 -0
  33. package/agent-wallet/agent_wallet/config.py +719 -0
  34. package/agent-wallet/agent_wallet/connector_cli.py +198 -0
  35. package/agent-wallet/agent_wallet/connectors/__init__.py +28 -0
  36. package/agent-wallet/agent_wallet/connectors/catalog.py +68 -0
  37. package/agent-wallet/agent_wallet/connectors/client.py +308 -0
  38. package/agent-wallet/agent_wallet/connectors/intent_policy.py +243 -0
  39. package/agent-wallet/agent_wallet/connectors/manifest.py +192 -0
  40. package/agent-wallet/agent_wallet/connectors/registry.py +341 -0
  41. package/agent-wallet/agent_wallet/encrypted_storage.py +314 -0
  42. package/agent-wallet/agent_wallet/evm_user_wallets.py +910 -0
  43. package/agent-wallet/agent_wallet/exceptions.py +10 -0
  44. package/agent-wallet/agent_wallet/file_ops.py +34 -0
  45. package/agent-wallet/agent_wallet/http_client.py +25 -0
  46. package/agent-wallet/agent_wallet/kernel_browser.py +479 -0
  47. package/agent-wallet/agent_wallet/kernel_cli.py +57 -0
  48. package/agent-wallet/agent_wallet/kernel_gateway.py +95 -0
  49. package/agent-wallet/agent_wallet/keystore.py +503 -0
  50. package/agent-wallet/agent_wallet/laso_card_vault.py +246 -0
  51. package/agent-wallet/agent_wallet/models.py +66 -0
  52. package/agent-wallet/agent_wallet/morpho_monitor.py +298 -0
  53. package/agent-wallet/agent_wallet/nonce_registry.py +59 -0
  54. package/agent-wallet/agent_wallet/openclaw_adapter.py +9129 -0
  55. package/agent-wallet/agent_wallet/openclaw_cli.py +658 -0
  56. package/agent-wallet/agent_wallet/openclaw_runtime.py +194 -0
  57. package/agent-wallet/agent_wallet/plugin_bundle.py +44 -0
  58. package/agent-wallet/agent_wallet/providers/__init__.py +1 -0
  59. package/agent-wallet/agent_wallet/providers/bags.py +202 -0
  60. package/agent-wallet/agent_wallet/providers/dexscreener.py +147 -0
  61. package/agent-wallet/agent_wallet/providers/evm_activity.py +257 -0
  62. package/agent-wallet/agent_wallet/providers/evm_portfolio.py +459 -0
  63. package/agent-wallet/agent_wallet/providers/imd.py +720 -0
  64. package/agent-wallet/agent_wallet/providers/jupiter.py +519 -0
  65. package/agent-wallet/agent_wallet/providers/kamino.py +404 -0
  66. package/agent-wallet/agent_wallet/providers/lifi.py +302 -0
  67. package/agent-wallet/agent_wallet/providers/solana_rpc.py +447 -0
  68. package/agent-wallet/agent_wallet/providers/tokenized_stocks.py +189 -0
  69. package/agent-wallet/agent_wallet/providers/wdk_evm_local.py +346 -0
  70. package/agent-wallet/agent_wallet/providers/x402.py +1972 -0
  71. package/agent-wallet/agent_wallet/sealed_keys.py +118 -0
  72. package/agent-wallet/agent_wallet/solana_stake.py +103 -0
  73. package/agent-wallet/agent_wallet/solana_tx.py +93 -0
  74. package/agent-wallet/agent_wallet/spending_limits.py +119 -0
  75. package/agent-wallet/agent_wallet/telemetry.py +481 -0
  76. package/agent-wallet/agent_wallet/transaction_policy.py +573 -0
  77. package/agent-wallet/agent_wallet/update_check.py +190 -0
  78. package/agent-wallet/agent_wallet/user_wallets.py +573 -0
  79. package/agent-wallet/agent_wallet/validation.py +31 -0
  80. package/agent-wallet/agent_wallet/vault_executor.py +456 -0
  81. package/agent-wallet/agent_wallet/wallet_layer/__init__.py +1 -0
  82. package/agent-wallet/agent_wallet/wallet_layer/base.py +1204 -0
  83. package/agent-wallet/agent_wallet/wallet_layer/base58.py +44 -0
  84. package/agent-wallet/agent_wallet/wallet_layer/factory.py +117 -0
  85. package/agent-wallet/agent_wallet/wallet_layer/solana.py +5246 -0
  86. package/agent-wallet/agent_wallet/wallet_layer/wdk_evm.py +2705 -0
  87. package/agent-wallet/examples/bootstrap_wallet.py +21 -0
  88. package/agent-wallet/examples/openclaw_runtime_onboarding.py +28 -0
  89. package/agent-wallet/examples/openclaw_user_wallet_example.py +31 -0
  90. package/agent-wallet/examples/openclaw_wallet_adapter_example.py +33 -0
  91. package/agent-wallet/openclaw.plugin.json +118 -0
  92. package/agent-wallet/pyproject.toml +36 -0
  93. package/agent-wallet/scripts/bootstrap_openclaw_evm.py +312 -0
  94. package/agent-wallet/scripts/build_release_bundle.py +210 -0
  95. package/agent-wallet/scripts/finalize_openclaw_local_wallet_config.py +121 -0
  96. package/agent-wallet/scripts/install_agent_wallet.py +1357 -0
  97. package/agent-wallet/scripts/install_openclaw_local_config.py +421 -0
  98. package/agent-wallet/scripts/install_openclaw_sealed_keys.py +117 -0
  99. package/agent-wallet/scripts/manage_openclaw_evm_wallet.py +333 -0
  100. package/agent-wallet/scripts/security_utils.py +37 -0
  101. package/agent-wallet/scripts/setup_evm_wallet.sh +140 -0
  102. package/agent-wallet/scripts/switch_openclaw_wallet_network.py +109 -0
  103. package/agent-wallet/skills/wallet-operator/SKILL.md +157 -0
  104. package/bin/lib/boot-key.mjs +184 -0
  105. package/bin/lib/evm-daemon.mjs +389 -0
  106. package/bin/lib/host-detection.mjs +259 -0
  107. package/bin/lib/integrations.mjs +578 -0
  108. package/bin/lib/release-python.mjs +9 -0
  109. package/bin/lib/update-transaction.mjs +235 -0
  110. package/bin/openclaw-agent-wallet.mjs +3354 -0
  111. package/claude-code/plugins/agent-wallet/.claude-plugin/plugin.json +19 -0
  112. package/claude-code/plugins/agent-wallet/.mcp.json +14 -0
  113. package/claude-code/plugins/agent-wallet/AGENTLAYER_AGENT_GUIDE.md +282 -0
  114. package/claude-code/plugins/agent-wallet/README.md +134 -0
  115. package/claude-code/plugins/agent-wallet/commands/agentlayer-autonomous-approve.md +39 -0
  116. package/claude-code/plugins/agent-wallet/commands/agentlayer-autonomous-revoke.md +17 -0
  117. package/claude-code/plugins/agent-wallet/commands/cards.md +129 -0
  118. package/claude-code/plugins/agent-wallet/commands/guide.md +40 -0
  119. package/claude-code/plugins/agent-wallet/commands/imd.md +125 -0
  120. package/claude-code/plugins/agent-wallet/commands/wallet-base.md +60 -0
  121. package/claude-code/plugins/agent-wallet/commands/wallet-ethereum.md +37 -0
  122. package/claude-code/plugins/agent-wallet/commands/wallet-evm.md +39 -0
  123. package/claude-code/plugins/agent-wallet/commands/wallet-setup.md +25 -0
  124. package/claude-code/plugins/agent-wallet/commands/wallet-sol.md +51 -0
  125. package/claude-code/plugins/agent-wallet/commands/wallet-statusline.md +34 -0
  126. package/claude-code/plugins/agent-wallet/commands/x402.md +121 -0
  127. package/claude-code/plugins/agent-wallet/commands/yield.md +62 -0
  128. package/claude-code/plugins/agent-wallet/hooks/hooks.json +16 -0
  129. package/claude-code/plugins/agent-wallet/scripts/bootstrap_backend.sh +136 -0
  130. package/claude-code/plugins/agent-wallet/scripts/enable_statusline.py +52 -0
  131. package/claude-code/plugins/agent-wallet/scripts/resolve_wallet_addresses.py +69 -0
  132. package/claude-code/plugins/agent-wallet/scripts/run_mcp.sh +66 -0
  133. package/claude-code/plugins/agent-wallet/scripts/wallet_statusline.py +130 -0
  134. package/claude-code/plugins/agent-wallet/scripts/wallet_statusline_setup.sh +40 -0
  135. package/claude-code/plugins/agent-wallet/skills/wallet-operator/SKILL.md +21 -0
  136. package/codex/plugins/agent-wallet/.codex-plugin/plugin.json +37 -0
  137. package/codex/plugins/agent-wallet/.mcp.json +15 -0
  138. package/codex/plugins/agent-wallet/README.md +158 -0
  139. package/codex/plugins/agent-wallet/scripts/run_mcp.sh +47 -0
  140. package/codex/plugins/agent-wallet/server.py +1797 -0
  141. package/codex/plugins/agent-wallet/skills/cards/SKILL.md +225 -0
  142. package/codex/plugins/agent-wallet/skills/imd/SKILL.md +145 -0
  143. package/codex/plugins/agent-wallet/skills/wallet-base/SKILL.md +56 -0
  144. package/codex/plugins/agent-wallet/skills/wallet-operator/SKILL.md +85 -0
  145. package/codex/plugins/agent-wallet/skills/wallet-sol/SKILL.md +29 -0
  146. package/codex/plugins/agent-wallet/skills/x402/SKILL.md +159 -0
  147. package/codex/plugins/agent-wallet/skills/yield/SKILL.md +65 -0
  148. package/connectors/AGENTS.md +37 -0
  149. package/connectors/DEVELOPER_GUIDE.md +131 -0
  150. package/connectors/README.md +139 -0
  151. package/connectors/READ_ONLY_BETA.md +54 -0
  152. package/connectors/RELEASING.md +48 -0
  153. package/connectors/conformance/README.md +31 -0
  154. package/connectors/conformance/package.json +54 -0
  155. package/connectors/conformance/scripts/sync-license.mjs +3 -0
  156. package/connectors/conformance/scripts/sync-spec.mjs +16 -0
  157. package/connectors/conformance/src/cli.ts +43 -0
  158. package/connectors/conformance/src/index.ts +7 -0
  159. package/connectors/conformance/src/runner.ts +314 -0
  160. package/connectors/conformance/src/types.ts +27 -0
  161. package/connectors/conformance/test/fixtures/invalid-response-identity.json +14 -0
  162. package/connectors/conformance/test/fixtures/missing-tool-fixture.json +4 -0
  163. package/connectors/conformance/test/runner.test.mjs +151 -0
  164. package/connectors/conformance/tsconfig.json +17 -0
  165. package/connectors/examples/reference-crypto-data/Dockerfile +21 -0
  166. package/connectors/examples/reference-crypto-data/README.md +51 -0
  167. package/connectors/examples/reference-crypto-data/conformance.json +11 -0
  168. package/connectors/examples/reference-crypto-data/connector.json +95 -0
  169. package/connectors/examples/reference-crypto-data/package.json +21 -0
  170. package/connectors/examples/reference-crypto-data/railway.toml +9 -0
  171. package/connectors/examples/reference-crypto-data/src/connector.ts +137 -0
  172. package/connectors/examples/reference-crypto-data/src/server.ts +13 -0
  173. package/connectors/examples/reference-crypto-data/test/connector.test.mjs +97 -0
  174. package/connectors/examples/reference-crypto-data/tsconfig.json +17 -0
  175. package/connectors/package-lock.json +561 -0
  176. package/connectors/package.json +19 -0
  177. package/connectors/scripts/smoke-packed-packages.mjs +121 -0
  178. package/connectors/sdk-typescript/README.md +47 -0
  179. package/connectors/sdk-typescript/package.json +49 -0
  180. package/connectors/sdk-typescript/scripts/sync-license.mjs +3 -0
  181. package/connectors/sdk-typescript/src/connector.ts +204 -0
  182. package/connectors/sdk-typescript/src/errors.ts +11 -0
  183. package/connectors/sdk-typescript/src/http.ts +116 -0
  184. package/connectors/sdk-typescript/src/index.ts +26 -0
  185. package/connectors/sdk-typescript/src/types.ts +101 -0
  186. package/connectors/sdk-typescript/test/sdk.test.mjs +181 -0
  187. package/connectors/sdk-typescript/tsconfig.json +21 -0
  188. package/connectors/spec/connector-manifest.schema.json +340 -0
  189. package/connectors/spec/connector-protocol.md +159 -0
  190. package/connectors/spec/transaction-intent.schema.json +281 -0
  191. package/connectors/templates/read-only/.env.example +1 -0
  192. package/connectors/templates/read-only/Dockerfile +11 -0
  193. package/connectors/templates/read-only/README.md +33 -0
  194. package/connectors/templates/read-only/conformance.json +11 -0
  195. package/connectors/templates/read-only/connector.json +64 -0
  196. package/connectors/templates/read-only/package.json +21 -0
  197. package/connectors/templates/read-only/railway.toml +9 -0
  198. package/connectors/templates/read-only/src/connector.ts +61 -0
  199. package/connectors/templates/read-only/src/server.ts +14 -0
  200. package/connectors/templates/read-only/test/connector.test.mjs +62 -0
  201. package/connectors/templates/read-only/tsconfig.json +17 -0
  202. package/cursor/plugins/agent-wallet/.cursor-plugin/plugin.json +14 -0
  203. package/cursor/plugins/agent-wallet/README.md +62 -0
  204. package/cursor/plugins/agent-wallet/mcp.json +16 -0
  205. package/cursor/plugins/agent-wallet/scripts/run_mcp.sh +33 -0
  206. package/cursor/plugins/agent-wallet/server.py +33 -0
  207. package/cursor/plugins/agent-wallet/skills/cards/SKILL.md +210 -0
  208. package/cursor/plugins/agent-wallet/skills/wallet-base/SKILL.md +56 -0
  209. package/cursor/plugins/agent-wallet/skills/wallet-operator/SKILL.md +23 -0
  210. package/cursor/plugins/agent-wallet/skills/wallet-sol/SKILL.md +29 -0
  211. package/cursor/plugins/agent-wallet/skills/x402/SKILL.md +130 -0
  212. package/hermes/plugins/agent_wallet/README.md +54 -0
  213. package/hermes/plugins/agent_wallet/__init__.py +55 -0
  214. package/hermes/plugins/agent_wallet/plugin.yaml +9 -0
  215. package/hermes/plugins/agent_wallet/schemas.py +211 -0
  216. package/hermes/plugins/agent_wallet/tools.py +622 -0
  217. package/install-from-github.sh +139 -0
  218. package/integrations/hedera/treasury-guard/README.md +92 -0
  219. package/integrations/hedera/treasury-guard/examples/treasury-policy.example.json +9 -0
  220. package/integrations/hedera/treasury-guard/package-lock.json +880 -0
  221. package/integrations/hedera/treasury-guard/package.json +8 -0
  222. package/integrations/hedera/treasury-guard/skills/onecraft-hedera-treasury/SKILL.md +22 -0
  223. package/integrations/hedera/treasury-guard/src/hedera-mirror-client.mjs +106 -0
  224. package/integrations/hedera/treasury-guard/src/hedera-signer.mjs +120 -0
  225. package/integrations/hedera/treasury-guard/src/treasury-cli.mjs +177 -0
  226. package/integrations/hedera/treasury-guard/src/treasury-policy.mjs +155 -0
  227. package/mcp/README.md +39 -0
  228. package/mcp/scripts/run_mcp.sh +37 -0
  229. package/mcp/server.py +33 -0
  230. package/package.json +106 -4
  231. package/scripts/check_release_version.mjs +72 -0
  232. package/scripts/version_targets.mjs +60 -0
  233. package/setup.sh +87 -0
  234. package/wdk-evm-wallet/.env.example +38 -0
  235. package/wdk-evm-wallet/README.md +254 -0
  236. package/wdk-evm-wallet/bootstrap.sh +8 -0
  237. package/wdk-evm-wallet/package-lock.json +2359 -0
  238. package/wdk-evm-wallet/package.json +43 -0
  239. package/wdk-evm-wallet/run-local.sh +12 -0
  240. package/wdk-evm-wallet/src/config.js +461 -0
  241. package/wdk-evm-wallet/src/imd.js +231 -0
  242. package/wdk-evm-wallet/src/json.js +35 -0
  243. package/wdk-evm-wallet/src/local_vault.js +407 -0
  244. package/wdk-evm-wallet/src/network_state.js +96 -0
  245. package/wdk-evm-wallet/src/pending_transactions.js +148 -0
  246. package/wdk-evm-wallet/src/server.js +849 -0
  247. package/wdk-evm-wallet/src/shutdown.js +63 -0
  248. package/wdk-evm-wallet/src/wdk_evm_wallet.js +10036 -0
@@ -0,0 +1,157 @@
1
+ ---
2
+ name: wallet-operator
3
+ description: Use whenever the user's own funds are involved, even if they never say "wallet": balances, portfolio, transfers, swaps, LI.FI cross-chain swaps, Jupiter swaps, Velora EVM swaps, BTC transfers, staking, Kamino lending, Bags launches, and wallet execution safety.
4
+ ---
5
+
6
+ # Wallet Operator
7
+
8
+ Use this skill before calling OpenClaw wallet tools. It is the routing guide for wallet commands, providers, units, and confirmation flow.
9
+
10
+ ## Core Rules
11
+
12
+ 1. Start with `get_wallet_capabilities` when the active chain, signing support, or available tools are unclear.
13
+ 2. Use `get_wallet_address` before asking for deposits or confirming a recipient/source wallet.
14
+ 3. Use `get_wallet_balance` before spending, swapping, bridging, staking, lending, or claiming.
15
+ 4. Treat `get_wallet_balance` as the default balance read for the active backend, not as a Solana-only helper. If `get_wallet_capabilities` says `can_get_balance=true`, prefer calling `get_wallet_balance` before assuming a backend lacks native balance support.
16
+ 5. Use `preview` first for every write action. For Solana Jupiter swaps, prefer `intent_preview` then `intent_execute` after explicit chat confirmation so execution can refresh the quote inside approved limits. Solana swap intents are normalized by the backend to at least 300 bps slippage, 120 seconds validity, and 3 fresh execution attempts; do not pass a hand-tightened `minimum_output_amount_raw` unless the user explicitly set that floor. Use `prepare` only after explicit user intent. In OpenClaw, use `execute` only after the user explicitly confirms the shown summary in chat; do not ask the user for `/approve`, buttons, popups, or a manual token.
17
+ 6. `prepare` returns an execution plan only; it must not return signed transaction bytes.
18
+ 7. On mainnet, restate the network and material terms before `execute`; the OpenClaw plugin handles the internal execution authorization after chat confirmation.
19
+ 8. If backend is `sign_only`, do not execute; use `prepare` and state that nothing was broadcast.
20
+ 9. Never claim a transfer, swap, bridge, stake, claim, deposit, borrow, repay, or withdrawal happened unless the tool result says it was broadcast/confirmed.
21
+ 10. Do not use Mayan. Direct Mayan paths were removed. Cross-chain swaps must go through LI.FI with Mayan denied.
22
+
23
+ ## Provider Map
24
+
25
+ - Solana same-chain swap: `swap_solana_tokens` via Jupiter.
26
+ - EVM same-chain swap: `swap_evm_tokens` via Velora, ERC-20 to ERC-20 on `ethereum` or `base`; `swap_evm_uniswap_tokens` via Uniswap Trading API on `ethereum`, `base`, or `robinhood`.
27
+ - Cross-chain Solana -> EVM: `swap_solana_lifi_cross_chain_tokens` via LI.FI.
28
+ - Cross-chain EVM -> EVM/Solana: `swap_evm_lifi_cross_chain_tokens` via LI.FI.
29
+ - SOL/SPL transfers: `transfer_sol`, `transfer_spl_token`.
30
+ - EVM transfers: `transfer_evm_native`, `transfer_evm_token`.
31
+ - Solana staking: `stake_sol_native`, `deactivate_solana_stake`, `withdraw_solana_stake`.
32
+ - Kamino: `get_kamino_portfolio`, `get_kamino_vaults`, `get_kamino_earn_positions`, `get_kamino_liquidity_positions`, `kamino_lend_deposit`, `kamino_lend_withdraw`, `kamino_lend_borrow`, `kamino_lend_repay`, `kamino_earn_deposit`, `kamino_earn_withdraw`.
33
+ - Bags: `launch_bags_token`.
34
+
35
+ ## Common Token IDs
36
+
37
+ - Native SOL for LI.FI: `sol`, `native`, or `11111111111111111111111111111111`.
38
+ - Native SOL mint for Jupiter swaps: `So11111111111111111111111111111111111111112`.
39
+ - Native ETH for LI.FI EVM destinations/sources: `eth`, `native`, or `0x0000000000000000000000000000000000000000`.
40
+ - EVM token addresses should be lowercase when possible. Checksummed addresses are accepted in current code and normalized for LI.FI.
41
+ - Solana USDC mint: `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`.
42
+ - Base USDC: `0x833589fcd6edb6e08f4c7c32d4f71b54bda02913`.
43
+ - LI.FI chain IDs: Ethereum `1`, Base `8453`, Solana `1151111081099710`.
44
+
45
+ ## Read Commands
46
+
47
+ - `get_wallet_capabilities`: available chain, backend, send/sign support.
48
+ - `get_wallet_address`: active wallet address.
49
+ - `get_wallet_balance`: primary balance/portfolio summary for the active backend.
50
+ - Solana: native SOL plus discovered SPL assets and USD values when available.
51
+ - EVM: native ETH balance plus discovered ERC-20 assets and USD values when available.
52
+ - If the user asks for an EVM wallet balance, try this first before falling back to token-specific reads.
53
+ - `get_wallet_portfolio`: detailed Solana portfolio holdings. Do not assume this works on every backend; `wdk_evm_local` may reject portfolio lookup even when `get_wallet_balance` works.
54
+ - `get_solana_token_prices`: prices by Solana mint.
55
+ - `get_lifi_supported_chains`: supported LI.FI subset.
56
+ - `get_lifi_quote`: read-only LI.FI quote/status surface; use when user asks for indicative cross-chain quote outside the write flow.
57
+ - `get_lifi_transfer_status`: check LI.FI bridge status after a cross-chain source transaction.
58
+ - `get_evm_network`: active EVM network and supported EVM swap networks.
59
+ - `get_evm_token_balance`: ERC-20 balance by `token_address`, optional `network`. This is not the native ETH balance reader; use it for a specific token contract such as USDC or WETH.
60
+ - `get_evm_token_metadata`: ERC-20 metadata by `token_address`, optional `network`.
61
+ - `get_evm_fee_rates`: EVM fee suggestions.
62
+ - `get_evm_transaction_receipt`: EVM receipt by `tx_hash`.
63
+ - `get_transaction_activity`: recent EVM transaction history (ethereum, base, robinhood). Pass `direction` (`outgoing`/`incoming`) when the user asks only about sent or received funds; it halves the provider reads. Page with the returned page keys only when the user wants older history.
64
+
65
+ ## Balance Routing
66
+
67
+ - Solana wallet balance request: use `get_wallet_balance`.
68
+ - EVM wallet balance request: use `get_wallet_balance` first for native ETH and discovered ERC-20 holdings.
69
+ - EVM specific token balance request: use `get_evm_token_balance` with a concrete ERC-20 `token_address`.
70
+ - EVM native transfer sizing: use `get_wallet_balance` for available ETH, then `get_evm_fee_rates` if the user needs fee context.
71
+ - If the tool descriptions and runtime capabilities seem inconsistent, prefer a direct read call over guessing from descriptions alone.
72
+ - Balance and position answers, on every network (Solana, Ethereum, Base, Robinhood, Arc) and for DeFi positions (Kamino, Morpho, Aave, Lido, Uniswap, staking): show a Markdown table `Asset | Amount | USD` with one row per asset or position, using human amounts (`amount_ui`/`balance_ui`, never raw base units) and `value_usd`, then the network and the total (`total_value_usd`, or the sum of the rows). An asset that has a symbol but no price stays in the table with `—` as its USD value. Hide assets that have neither a symbol nor a USD price (usually spam airdrops) and say how many were hidden. Slash commands that define their own format take precedence.
73
+
74
+ ## Transfer Commands
75
+
76
+ - SOL transfer: `transfer_sol`
77
+ - Params: `recipient`, `amount` in SOL UI units, `mode`, `purpose`, optional `user_intent`.
78
+ - SPL transfer: `transfer_spl_token`
79
+ - Params: `recipient`, `mint`, `amount` in UI units, optional `decimals`, `mode`, `purpose`.
80
+ - EVM native transfer: `transfer_evm_native`
81
+ - Params: `recipient`, `amount_wei` raw wei string, `mode`, `purpose`, optional `network`.
82
+ - EVM ERC-20 transfer: `transfer_evm_token`
83
+ - Params: `token_address`, `recipient`, `amount_raw` base-unit string, `mode`, `purpose`, optional `network`.
84
+
85
+ ## Swap Commands
86
+
87
+ - Solana same-chain Jupiter swap: `swap_solana_tokens`
88
+ - Params: `input_mint`, `output_mint`, `amount` in UI units, optional `slippage_bps`, `minimum_output_amount_raw`, `max_fee_lamports`, `valid_for_seconds`, `max_attempts`, `mode`, `purpose`.
89
+ - Prefer `mode=intent_preview`, show the intent limits to the user, then after chat confirmation call `mode=intent_execute` with the same semantic params. This confirms risk limits, not a stale quote fingerprint.
90
+ - Default Solana swap slippage is 300 bps (3%). The backend computes the approved minimum output from the indicative output and slippage, not from a strict RFQ threshold.
91
+ - The primary execution path uses Jupiter Swap API V2 `/order` + `/execute`; if a JupiterZ/RFQ route fails, the backend retries with a non-JupiterZ route when possible.
92
+ - Metis `/swap` fallback builds use Jupiter dynamic slippage and a bounded `veryHigh` priority fee instead of the old `"auto"` priority mode.
93
+ - Do not use legacy `execute` for Solana Jupiter swaps in OpenClaw; exact quote-bound approval is too fragile for active markets.
94
+ - Use for SOL<->SPL or SPL<->SPL on Solana. Do not use LI.FI for Solana-only swaps.
95
+ - EVM same-chain Velora swap: `swap_evm_tokens`
96
+ - Params: `token_in`, `token_out`, `amount_in_raw` base-unit string, `mode`, `purpose`, optional `network`.
97
+ - Current intended path is ERC-20 to ERC-20 on `ethereum` or `base`.
98
+ - EVM same-chain Uniswap swap: `swap_evm_uniswap_tokens`
99
+ - Params: `token_in`, `token_out`, `amount_in_raw` base-unit string, `mode`, `purpose`, optional `network`.
100
+ - Supported paths on `ethereum`, `base`, and `robinhood` are CLASSIC, UniswapX orders, and canonical ETH↔WETH wrap/unwrap; other routes fail closed before signing.
101
+ - EVM swap quote only: `get_evm_swap_quote`
102
+ - Params: `token_in`, `token_out`, `amount_in_raw`, optional `network`.
103
+
104
+ ## Tokenized Stocks (EVM)
105
+
106
+ - "Buy TSLA/NVDA/Apple stock on Base": call `get_evm_tokenized_stock` (`query` = ticker, company name, or ISIN) BEFORE any DEX search.
107
+ - On `base` it resolves through Coinbase's official registry (~300 Coinbase Tokenized Stocks, B20/ERC-20, symbol = ticker + `c`, e.g. `TSLAc`, 8 decimals) and returns the canonical `address`, top DEX venues with liquidity, `notices`, and `next_step`.
108
+ - Never choose a stock token by ticker from `search_uniswap_pairs`; there, pairs carry `canonical_tokenized_stock` true/false. SwarmX, Dinari, xStocks, or Robinhood-chain tokens are different products: offer one only if the user asks, and say it is a different issuer.
109
+ - If amount or funding asset is missing, ask once (default funding: USDC on Base, `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`). Amount `amount_in_raw` is in the funding token's base units.
110
+ - Quote with `get_evm_swap_quote` (Velora, aggregates Aerodrome + Uniswap pools — usually the deepest route), fallback `get_uniswap_swap_quote`. Show input, estimated and minimum TSLAc out, and price vs. the venue price.
111
+ - Surface the notices: not available to U.S. persons (Reg S); an exposure certificate, not a direct share; multiplier can change; DEX prices may drift outside U.S. market hours.
112
+ - Execute with `swap_evm_tokens` (preview → confirm → execute) for the quoted route.
113
+
114
+ ## Cross-Chain Commands
115
+
116
+ - Solana -> Ethereum/Base: `swap_solana_lifi_cross_chain_tokens`
117
+ - Source must be Solana mainnet.
118
+ - Params: `input_token`, `destination_chain` (`ethereum`, `base`, `1`, `8453`), `output_token`, `destination_address`, `amount_in_raw`, optional `slippage`, bridge lists, `mode`, `purpose`.
119
+ - Example SOL -> Base native ETH: `input_token=sol`, `destination_chain=base`, `output_token=native`, `amount_in_raw` in lamports.
120
+ - Execute confirms the Solana source tx. Use `get_lifi_transfer_status` to track final destination-chain completion.
121
+ - Ethereum/Base -> Ethereum/Base/Solana: `swap_evm_lifi_cross_chain_tokens`
122
+ - Source network is selected by active EVM network or optional `network`.
123
+ - Params: `token_in`, `destination_chain` (`ethereum`, `base`, `solana`, `1`, `8453`, `1151111081099710`), `output_token`, `destination_address`, `amount_in_raw`, optional `slippage`, bridge lists, `mode`, `purpose`, optional `network`.
124
+ - Native EVM input can be `native`, `eth`, or zero address.
125
+ - Solana output token should be a Solana mint such as USDC mint.
126
+
127
+ ## Staking And DeFi Commands
128
+
129
+ - `stake_sol_native`: `vote_account`, `amount` in SOL, `mode`, `purpose`.
130
+ - `deactivate_solana_stake`: `stake_account`, `mode`, `purpose`.
131
+ - `withdraw_solana_stake`: `stake_account`, `amount` in SOL, optional `recipient`, `mode`, `purpose`.
132
+ - Before Kamino lend writes, use `get_kamino_lend_markets`, `get_kamino_lend_market_reserves`, `get_kamino_lend_user_obligations`, and `get_kamino_lend_user_rewards`.
133
+ - For broader Kamino read coverage, prefer `get_kamino_portfolio` first, then drill into `get_kamino_vaults`, `get_kamino_earn_positions`, or `get_kamino_liquidity_positions` as needed.
134
+ - Kamino lend write params: `market`, `reserve`, `amount_ui` decimal string, `mode`, `purpose`.
135
+ - Kamino Earn write params: `kvault`, `amount_ui` decimal string, `mode`, `purpose`.
136
+ - `launch_bags_token`: `name`, `symbol`, `description`, `base_mint`, `claimers`, `basis_points`, `initial_buy_sol`, `mode`, `purpose`; optional socials/image/config type.
137
+ - `close_empty_token_accounts`: `limit`, `mode` (`preview` or `execute`), `purpose`.
138
+
139
+ ## Approval Flow Template
140
+
141
+ 1. Call the write tool with `mode=preview` and a concrete `purpose`.
142
+ 2. Show the user the important fields: chain, token, amount, destination, provider, estimated output/minimum output, fees, and route/tool when present.
143
+ 3. For `prepare`, call same tool with `mode=prepare`, same params, `user_intent=true`.
144
+ 4. For `execute`, use the same semantic params after the user's chat confirmation. Do not mutate amount, token, destination, network, slippage, or minimum output between preview and execute; do not ask the user for a token or out-of-chat approval action.
145
+ 5. For cross-chain swaps, after execute, offer `get_lifi_transfer_status` using the source tx hash and bridge/tool if returned.
146
+
147
+ ## Morpho Vault Monitoring
148
+
149
+ - `get_morpho_rebalance_report` scans the wallet's Morpho vault positions (V1 and V2) on Base and Ethereum for better vaults with the same asset on the same chain. It only reads; present its candidates and let the user decide. Migration gas in it is an estimate and never a reason to hide a candidate.
150
+ - To scan every 3 days, call `get_morpho_monitor_schedule` with the current host and follow the returned recipe only after the user asks for monitoring. On Hermes and OpenClaw create the job with the agent's own cron tool using the returned arguments. A scheduled run never moves funds.
151
+ - Any read-only wallet answer may carry `morpho_monitor_notice`: the wallet checked the Morpho positions on its own (at most every 3 days) and found better vaults that are new since the last check. Answer the user's request first, then mention the notice briefly with the rates; nothing was moved, and moving funds still needs the user's explicit confirmation.
152
+ - To move a position, use `rebalance_evm_morpho_vault_position`: `intent_preview`, then `intent_execute` with identical arguments only after the user explicitly confirms the previewed move. If it reports `status: partial`, the funds are in the wallet; say so and do not retry on your own.
153
+
154
+ ## Disabled Or Avoided Paths
155
+
156
+ - Do not invent generic calldata, arbitrary contract calls, token approvals, or non-listed bridge providers.
157
+ - If a requested tool is absent from `list_tools` or capabilities, say the wallet runtime does not expose it.
@@ -0,0 +1,184 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { spawnSync } from "node:child_process";
4
+
5
+ import { releaseCheckPython } from "./release-python.mjs";
6
+
7
+ function readEnv(pathname) {
8
+ try {
9
+ const result = {};
10
+ for (const line of fs.readFileSync(pathname, "utf8").split(/\r?\n/)) {
11
+ const match = line.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
12
+ if (match) result[match[1]] = match[2];
13
+ }
14
+ return result;
15
+ } catch (error) {
16
+ if (error?.code === "ENOENT") return {};
17
+ throw error;
18
+ }
19
+ }
20
+
21
+ function readText(pathname) {
22
+ try {
23
+ return fs.readFileSync(pathname, "utf8");
24
+ } catch (error) {
25
+ if (error?.code === "ENOENT") return "";
26
+ throw error;
27
+ }
28
+ }
29
+
30
+ function writeSecret(pathname, value) {
31
+ fs.mkdirSync(path.dirname(pathname), { recursive: true });
32
+ fs.writeFileSync(pathname, `${String(value || "").trim()}\n`, { mode: 0o600 });
33
+ try {
34
+ fs.chmodSync(pathname, 0o600);
35
+ } catch {
36
+ // Best effort on filesystems without POSIX modes.
37
+ }
38
+ }
39
+
40
+ export function createBootKeyManager({
41
+ runtimeBase,
42
+ openclawHome,
43
+ currentRuntimeRoot,
44
+ resolveVenvPython,
45
+ expandHome,
46
+ bridgeTimeoutMs,
47
+ env = process.env,
48
+ }) {
49
+ const defaultFile = path.join(runtimeBase, "boot-key");
50
+
51
+ function currentKey() {
52
+ const root = currentRuntimeRoot();
53
+ if (!root) return "";
54
+ return readEnv(path.join(root, "agent-wallet", ".env")).AGENT_WALLET_BOOT_KEY || "";
55
+ }
56
+
57
+ function configuredFileKey() {
58
+ const value = String(env.AGENT_WALLET_BOOT_KEY_FILE || "").trim();
59
+ return value ? readText(path.resolve(expandHome(value))).trim() : "";
60
+ }
61
+
62
+ function ensureFile() {
63
+ const configured = String(env.AGENT_WALLET_BOOT_KEY_FILE || "").trim();
64
+ const keyFile = configured ? path.resolve(expandHome(configured)) : defaultFile;
65
+ if (readText(keyFile).trim()) return { path: keyFile, status: "existing" };
66
+ const key = String(env.AGENT_WALLET_BOOT_KEY || "").trim() || configuredFileKey() || currentKey();
67
+ if (!key) return { path: keyFile, status: "missing" };
68
+ writeSecret(keyFile, key);
69
+ return { path: keyFile, status: "created" };
70
+ }
71
+
72
+ function readKeystore() {
73
+ const root = currentRuntimeRoot();
74
+ if (!root) return "";
75
+ const python = resolveVenvPython(root);
76
+ if (!python) return "";
77
+ try {
78
+ const result = spawnSync(
79
+ python,
80
+ ["-c", "from agent_wallet.config import read_boot_key_from_keystore as r; print(r())"],
81
+ {
82
+ cwd: path.join(root, "agent-wallet"),
83
+ encoding: "utf8",
84
+ timeout: bridgeTimeoutMs,
85
+ env: { ...env, OPENCLAW_HOME: openclawHome },
86
+ },
87
+ );
88
+ return result.status === 0 ? String(result.stdout || "").trim() : "";
89
+ } catch {
90
+ return "";
91
+ }
92
+ }
93
+
94
+ function resolveFromRuntime() {
95
+ const root = currentRuntimeRoot();
96
+ if (!root) return { supported: false, key: "" };
97
+ const python = resolveVenvPython(root);
98
+ if (!python) return { supported: false, key: "" };
99
+ try {
100
+ const result = spawnSync(
101
+ python,
102
+ ["-c", "from agent_wallet.config import resolve_boot_key_for_installer as r; print(r())"],
103
+ {
104
+ cwd: path.join(root, "agent-wallet"),
105
+ encoding: "utf8",
106
+ timeout: bridgeTimeoutMs,
107
+ env: { ...env, OPENCLAW_HOME: openclawHome },
108
+ },
109
+ );
110
+ return result.status === 0
111
+ ? { supported: true, key: String(result.stdout || "").trim() }
112
+ : { supported: false, key: "" };
113
+ } catch {
114
+ return { supported: false, key: "" };
115
+ }
116
+ }
117
+
118
+ function resolveLegacy() {
119
+ for (const [source, key] of [
120
+ ["legacy_keystore", readKeystore()],
121
+ ["current_runtime_env", currentKey()],
122
+ ["configured_file", configuredFileKey()],
123
+ ["default_file", readText(defaultFile).trim()],
124
+ ]) {
125
+ if (key) return { key, source };
126
+ }
127
+ return { key: "", source: "none" };
128
+ }
129
+
130
+ function provision(releaseRoot, bootKey) {
131
+ const key = String(bootKey || "").trim();
132
+ if (!key) return false;
133
+ const python = resolveVenvPython(releaseRoot);
134
+ if (!python) return false;
135
+ try {
136
+ const result = spawnSync(
137
+ python,
138
+ ["-m", "agent_wallet.openclaw_cli", "boot-key-import", "--key-stdin"],
139
+ {
140
+ cwd: path.join(releaseRoot, "agent-wallet"),
141
+ input: key,
142
+ encoding: "utf8",
143
+ timeout: bridgeTimeoutMs,
144
+ env: { ...env, OPENCLAW_HOME: openclawHome },
145
+ },
146
+ );
147
+ return result.status === 0;
148
+ } catch {
149
+ return false;
150
+ }
151
+ }
152
+
153
+ function verifyWithRuntime(releaseRoot) {
154
+ const sealedPath = path.join(openclawHome, "sealed_keys.json");
155
+ if (!fs.existsSync(sealedPath)) return { ok: true, required: false };
156
+ const key = String(env.AGENT_WALLET_BOOT_KEY || "").trim();
157
+ if (!key) return { ok: false, required: true, error: "no verified boot key is available" };
158
+ const python = releaseCheckPython(resolveVenvPython(releaseRoot), env);
159
+ if (!python) {
160
+ if (String(env.AGENT_WALLET_VERIFY_DISABLE || "") === "1") {
161
+ return { ok: true, required: true, skipped: true };
162
+ }
163
+ return { ok: false, required: true, error: "staged Python runtime is unavailable" };
164
+ }
165
+ const result = spawnSync(
166
+ python,
167
+ [
168
+ "-c",
169
+ "from agent_wallet.sealed_keys import unseal_keys; import os; unseal_keys(os.environ['AGENT_WALLET_BOOT_KEY']); print('ok')",
170
+ ],
171
+ {
172
+ cwd: path.join(releaseRoot, "agent-wallet"),
173
+ encoding: "utf8",
174
+ timeout: bridgeTimeoutMs,
175
+ env: { ...env, OPENCLAW_HOME: openclawHome },
176
+ },
177
+ );
178
+ return result.status === 0
179
+ ? { ok: true, required: true }
180
+ : { ok: false, required: true, error: "selected boot key does not unlock sealed wallet state" };
181
+ }
182
+
183
+ return { ensureFile, resolveFromRuntime, resolveLegacy, provision, verifyWithRuntime };
184
+ }