@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,719 @@
1
+ """Configuration for agent wallet backends."""
2
+
3
+ import hashlib
4
+ import os
5
+ from pathlib import Path
6
+ from typing import Iterator
7
+
8
+ from pydantic_settings import BaseSettings
9
+
10
+ PACKAGE_ROOT = Path(__file__).resolve().parents[1]
11
+ DEFAULT_PROVIDER_GATEWAY_URL = "https://agent-layer-production.up.railway.app"
12
+
13
+
14
+ class Settings(BaseSettings):
15
+ agent_wallet_backend: str = "none"
16
+ agent_wallet_sign_only: bool = False
17
+ agent_wallet_boot_key: str = ""
18
+ agent_wallet_boot_key_file: str = ""
19
+ agent_wallet_approval_ttl_seconds: int = 600
20
+ agent_wallet_per_user_key_derivation: bool = True
21
+ agent_wallet_encrypt_user_wallets: bool = True
22
+ agent_wallet_migrate_plaintext_user_wallets: bool = True
23
+ agent_wallet_refuse_mainnet_wallet_recreation: bool = True
24
+ agent_wallet_require_encrypted_mainnet: bool = True
25
+ agent_wallet_max_per_tx_sol: float = 0
26
+ agent_wallet_max_hourly_sol: float = 0
27
+ agent_wallet_max_daily_sol: float = 0
28
+ agent_wallet_max_txs_per_minute: int = 0
29
+
30
+ solana_network: str = "mainnet"
31
+ solana_rpc_url: str = ""
32
+ solana_rpc_urls: str = ""
33
+ solana_rpc_provider_mode: str = "auto"
34
+ solana_commitment: str = "confirmed"
35
+ solana_auto_create_wallet: bool = False
36
+ solana_agent_public_key: str = ""
37
+ solana_agent_keypair_path: str = ""
38
+ provider_gateway_url: str = DEFAULT_PROVIDER_GATEWAY_URL
39
+ provider_gateway_bearer_token: str = ""
40
+ provider_gateway_rpc_provider: str = "auto"
41
+ solana_swap_provider: str = "auto"
42
+ wdk_evm_service_url: str = ""
43
+ wdk_evm_wallet_id: str = ""
44
+ wdk_evm_account_index: int = 0
45
+
46
+ jupiter_api_base_url: str = "https://lite-api.jup.ag/swap/v1"
47
+ jupiter_swap_v2_api_base_url: str = "https://api.jup.ag/swap/v2"
48
+ jupiter_ultra_api_base_url: str = "https://lite-api.jup.ag/ultra/v1"
49
+ jupiter_price_api_base_url: str = "https://lite-api.jup.ag/price/v3"
50
+ jupiter_token_search_api_base_url: str = "https://lite-api.jup.ag/tokens/v2"
51
+ jupiter_api_key: str = ""
52
+ lifi_api_base_url: str = "https://li.quest/v1"
53
+ lifi_api_key: str = ""
54
+ lifi_integrator: str = "agentlayer"
55
+ # OneCraft integrator fee as a fraction of fromAmount (0.0001 = 0.01%).
56
+ lifi_fee: float = 0.0001
57
+ lifi_default_deny_bridges: str = "mayan"
58
+ kamino_api_base_url: str = "https://api.kamino.finance"
59
+ kamino_program_id: str = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD"
60
+ alchemy_api_key: str = ""
61
+ helius_api_key: str = ""
62
+
63
+ http_timeout: float = 10.0
64
+
65
+ model_config = {
66
+ "env_file": str(PACKAGE_ROOT / ".env"),
67
+ "env_file_encoding": "utf-8",
68
+ "extra": "ignore",
69
+ }
70
+
71
+
72
+ settings = Settings()
73
+
74
+
75
+ def reload_settings() -> Settings:
76
+ """Reload settings from the current environment without changing object identity."""
77
+ refreshed = Settings()
78
+ for field_name in Settings.model_fields:
79
+ setattr(settings, field_name, getattr(refreshed, field_name))
80
+ clear_secret_caches()
81
+ return settings
82
+
83
+
84
+ def normalize_solana_network(network: str | None) -> str:
85
+ """Canonicalize supported Solana network names and reject test clusters."""
86
+ normalized = str(network or "").strip().lower() or "mainnet"
87
+ aliases = {
88
+ "mainnet-beta": "mainnet",
89
+ }
90
+ normalized = aliases.get(normalized, normalized)
91
+ if normalized in {"devnet", "testnet"}:
92
+ from agent_wallet.wallet_layer.base import WalletBackendError
93
+
94
+ raise WalletBackendError(
95
+ "Solana devnet/testnet are no longer supported by agent-wallet. "
96
+ "Use mainnet or remove the Solana network override."
97
+ )
98
+ if normalized != "mainnet":
99
+ from agent_wallet.wallet_layer.base import WalletBackendError
100
+
101
+ raise WalletBackendError(
102
+ f"Unsupported Solana network: {normalized}. Only mainnet is supported."
103
+ )
104
+ return "mainnet"
105
+
106
+
107
+ def normalize_evm_network(network: str | None) -> str:
108
+ """Canonicalize supported EVM network names and reject testnets."""
109
+ normalized = str(network or "").strip().lower() or "ethereum"
110
+ aliases = {
111
+ "mainnet": "ethereum",
112
+ "eth": "ethereum",
113
+ "eth-mainnet": "ethereum",
114
+ "base-mainnet": "base",
115
+ "arc-mainnet": "arc",
116
+ }
117
+ normalized = aliases.get(normalized, normalized)
118
+ if normalized in {"sepolia", "base-sepolia", "base_sepolia"}:
119
+ from agent_wallet.wallet_layer.base import WalletBackendError
120
+
121
+ raise WalletBackendError(
122
+ "EVM testnets are no longer supported by agent-wallet. Use ethereum, base, robinhood, or arc."
123
+ )
124
+ if normalized not in {"ethereum", "base", "robinhood", "arc"}:
125
+ from agent_wallet.wallet_layer.base import WalletBackendError
126
+
127
+ raise WalletBackendError(
128
+ f"Unsupported EVM network: {normalized}. Use ethereum, base, robinhood, or arc."
129
+ )
130
+ return normalized
131
+
132
+
133
+ def _normalize_provider_mode(value: str | None) -> str:
134
+ mode = (value or "").strip().lower()
135
+ if not mode:
136
+ return "auto"
137
+ aliases = {
138
+ "direct": "user_direct",
139
+ "proxy": "shared_proxy",
140
+ "shared": "shared_proxy",
141
+ }
142
+ mode = aliases.get(mode, mode)
143
+ if mode not in {"auto", "user_direct", "shared_proxy"}:
144
+ return "auto"
145
+ return mode
146
+
147
+
148
+ def _normalize_rpc_provider(value: str | None) -> str:
149
+ provider = (value or "").strip().lower()
150
+ if not provider:
151
+ return "auto"
152
+ if provider not in {"auto", "shared", "helius", "alchemy"}:
153
+ return "auto"
154
+ return provider
155
+
156
+
157
+ def _normalize_swap_provider(value: str | None) -> str:
158
+ provider = (value or "").strip().lower()
159
+ if not provider:
160
+ return "auto"
161
+ aliases = {
162
+ "proxy": "jupiter",
163
+ "shared": "jupiter",
164
+ "bags": "jupiter",
165
+ }
166
+ provider = aliases.get(provider, provider)
167
+ if provider not in {"auto", "jupiter"}:
168
+ return "auto"
169
+ return provider
170
+
171
+
172
+ def resolve_openclaw_home() -> Path:
173
+ """Resolve the default OpenClaw home directory for plugin state."""
174
+ raw = os.getenv("OPENCLAW_HOME", "~/.openclaw")
175
+ return Path(raw).expanduser()
176
+
177
+
178
+ def resolve_card_vault_user_id() -> str:
179
+ """Use the same default identity as the Codex wallet bridge for owner CLI access."""
180
+ import json
181
+
182
+ explicit = os.getenv("AGENT_WALLET_USER_ID") or os.getenv("OPENCLAW_AGENT_WALLET_USER_ID")
183
+ if explicit:
184
+ return explicit
185
+ try:
186
+ payload = json.loads((resolve_openclaw_home() / "openclaw.json").read_text(encoding="utf-8"))
187
+ configured = payload["plugins"]["entries"]["agent-wallet"]["config"].get("userId")
188
+ if isinstance(configured, str) and configured.strip():
189
+ return configured.strip()
190
+ except (OSError, ValueError, KeyError, TypeError, AttributeError):
191
+ pass
192
+ return os.getenv("USER") or "codex-local-user"
193
+
194
+
195
+ # Installers before the unix-socket transport persisted the then-default TCP
196
+ # address into openclaw.json as an explicit wdkEvmServiceUrl, and updates never
197
+ # rewrite that config. Treated literally it keeps those installs on the shared
198
+ # port, with a second daemon beside the socket one on the same data dir. Only
199
+ # this exact legacy default is read as "unset"; any other URL, or an explicit
200
+ # WDK_EVM_TRANSPORT=tcp opt-out, is a deliberate choice and is honored.
201
+ LEGACY_EVM_SERVICE_URLS = frozenset({"http://127.0.0.1:8081", "http://localhost:8081"})
202
+
203
+
204
+ def is_legacy_evm_service_url(value: object) -> bool:
205
+ if os.getenv("WDK_EVM_TRANSPORT", "").strip().lower() == "tcp":
206
+ return False
207
+ return str(value or "").strip().rstrip("/").lower() in LEGACY_EVM_SERVICE_URLS
208
+
209
+
210
+ def resolve_wdk_evm_service_url() -> str:
211
+ """Resolve the wdk-evm-wallet service URL, unix-socket by default.
212
+
213
+ An explicit WDK_EVM_SERVICE_URL/settings value always wins, whatever
214
+ transport it names (http:// for an explicit TCP deployment, unix:// for
215
+ a non-default socket path), except the legacy TCP default above. Otherwise
216
+ this is a per-OPENCLAW_HOME unix socket — see
217
+ docs/superpowers/specs/2026-08-30-evm-wallet-unix-socket-transport-design.md.
218
+ """
219
+ explicit = settings.wdk_evm_service_url.strip()
220
+ if explicit and not is_legacy_evm_service_url(explicit):
221
+ return explicit
222
+ return f"unix://{resolve_openclaw_home() / 'wdk-evm-wallet' / 'daemon.sock'}"
223
+
224
+
225
+ def default_solana_wallet_path(network: str) -> Path:
226
+ """Return the default keypair path for a Solana wallet."""
227
+ normalized_network = normalize_solana_network(network)
228
+ return resolve_openclaw_home() / "wallets" / f"solana-{normalized_network}-agent.json"
229
+
230
+
231
+ def resolve_solana_rpc_url(network: str, configured: str) -> str:
232
+ """Resolve the effective Solana RPC URL from network + optional override."""
233
+ normalized_network = normalize_solana_network(network)
234
+ if configured.strip():
235
+ return configured.strip()
236
+
237
+ mapping = {
238
+ "mainnet": "https://api.mainnet-beta.solana.com",
239
+ }
240
+ return mapping.get(normalized_network, mapping["mainnet"])
241
+
242
+
243
+ def resolve_solana_rpc_urls(
244
+ network: str,
245
+ configured: str,
246
+ configured_list: str = "",
247
+ ) -> list[str]:
248
+ """Resolve the ordered list of Solana RPC URLs to try."""
249
+ normalized_network = normalize_solana_network(network)
250
+ candidates: list[str] = []
251
+ for raw in (configured_list or "").split(","):
252
+ value = raw.strip()
253
+ if value and value not in candidates:
254
+ candidates.append(value)
255
+
256
+ primary = resolve_solana_rpc_url(normalized_network, configured)
257
+ if primary and primary not in candidates:
258
+ candidates.insert(0, primary)
259
+
260
+ official = resolve_solana_rpc_url(normalized_network, "")
261
+ if official and official not in candidates:
262
+ candidates.append(official)
263
+
264
+ return candidates
265
+
266
+
267
+ def _build_provider_gateway_rpc_url(base_url: str, provider: str, network: str) -> str:
268
+ normalized_network = normalize_solana_network(network)
269
+ return f"gateway::{provider}::{normalized_network}::{base_url.rstrip('/')}/v1/rpc"
270
+
271
+
272
+ def resolve_runtime_solana_rpc_config(
273
+ network: str,
274
+ configured: str,
275
+ configured_list: str = "",
276
+ ) -> dict[str, object]:
277
+ """Resolve Solana RPC transport config for one runtime invocation.
278
+
279
+ Preference order:
280
+ 1. explicit direct RPC env/config
281
+ 2. user-provided provider API keys
282
+ 3. shared proxy gateway
283
+ 4. public official fallback
284
+ """
285
+ normalized_network = normalize_solana_network(network)
286
+ mode = _normalize_provider_mode(
287
+ os.getenv("SOLANA_RPC_PROVIDER_MODE", settings.solana_rpc_provider_mode)
288
+ )
289
+ gateway_url = os.getenv("PROVIDER_GATEWAY_URL", settings.provider_gateway_url).strip()
290
+ gateway_provider = _normalize_rpc_provider(
291
+ os.getenv("PROVIDER_GATEWAY_RPC_PROVIDER", settings.provider_gateway_rpc_provider)
292
+ )
293
+
294
+ env_primary = os.getenv("SOLANA_RPC_URL", "").strip()
295
+ env_list = os.getenv("SOLANA_RPC_URLS", "").strip()
296
+ if env_primary:
297
+ return {
298
+ "mode": "user_direct",
299
+ "provider": "custom",
300
+ "transport": "direct",
301
+ "rpc_urls": resolve_solana_rpc_urls(normalized_network, env_primary, env_list),
302
+ }
303
+ if env_list:
304
+ official = resolve_solana_rpc_url(normalized_network, "")
305
+ candidates = [item.strip() for item in env_list.split(",") if item.strip()]
306
+ if official and official not in candidates:
307
+ candidates.append(official)
308
+ return {
309
+ "mode": "user_direct",
310
+ "provider": "custom",
311
+ "transport": "direct",
312
+ "rpc_urls": candidates,
313
+ }
314
+
315
+ alchemy_key = os.getenv("ALCHEMY_API_KEY", settings.alchemy_api_key).strip()
316
+ if alchemy_key:
317
+ alchemy_base_by_network = {
318
+ "mainnet": "https://solana-mainnet.g.alchemy.com/v2",
319
+ }
320
+ alchemy_base = alchemy_base_by_network.get(normalized_network)
321
+ if alchemy_base:
322
+ return {
323
+ "mode": "user_direct",
324
+ "provider": "alchemy",
325
+ "transport": "direct",
326
+ "rpc_urls": resolve_solana_rpc_urls(
327
+ normalized_network,
328
+ f"{alchemy_base}/{alchemy_key}",
329
+ "",
330
+ ),
331
+ }
332
+
333
+ helius_key = os.getenv("HELIUS_API_KEY", settings.helius_api_key).strip()
334
+ if helius_key:
335
+ helius_base_by_network = {
336
+ "mainnet": "https://mainnet.helius-rpc.com/",
337
+ }
338
+ helius_base = helius_base_by_network.get(normalized_network)
339
+ if helius_base:
340
+ return {
341
+ "mode": "user_direct",
342
+ "provider": "helius",
343
+ "transport": "direct",
344
+ "rpc_urls": resolve_solana_rpc_urls(
345
+ normalized_network,
346
+ f"{helius_base}?api-key={helius_key}",
347
+ "",
348
+ ),
349
+ }
350
+
351
+ if normalized_network == "mainnet" and (mode == "shared_proxy" or (mode == "auto" and gateway_url)):
352
+ if gateway_url:
353
+ return {
354
+ "mode": "shared_proxy",
355
+ "provider": gateway_provider,
356
+ "transport": "proxy",
357
+ "rpc_urls": [
358
+ _build_provider_gateway_rpc_url(
359
+ gateway_url,
360
+ gateway_provider,
361
+ normalized_network,
362
+ )
363
+ ],
364
+ }
365
+
366
+ return {
367
+ "mode": "public_fallback",
368
+ "provider": "official",
369
+ "transport": "direct",
370
+ "rpc_urls": resolve_solana_rpc_urls(normalized_network, configured, configured_list),
371
+ }
372
+
373
+
374
+ def resolve_runtime_solana_rpc_urls(
375
+ network: str,
376
+ configured: str,
377
+ configured_list: str = "",
378
+ ) -> list[str]:
379
+ """Resolve Solana RPC URLs with deployment env taking precedence over plugin config."""
380
+ payload = resolve_runtime_solana_rpc_config(network, configured, configured_list)
381
+ return list(payload["rpc_urls"])
382
+
383
+
384
+ def resolve_runtime_solana_swap_config(network: str) -> dict[str, str]:
385
+ """Resolve the effective Solana swap provider for one runtime invocation.
386
+
387
+ Preference order:
388
+ 1. explicit swap provider override
389
+ 2. direct Jupiter
390
+ """
391
+ requested = _normalize_swap_provider(
392
+ os.getenv("SOLANA_SWAP_PROVIDER", settings.solana_swap_provider)
393
+ )
394
+ normalize_solana_network(network)
395
+
396
+ if requested == "jupiter":
397
+ return {"provider": "jupiter", "transport": "direct"}
398
+
399
+ return {"provider": "jupiter", "transport": "direct"}
400
+
401
+
402
+ def _env_bool(name: str, default: bool) -> bool:
403
+ raw = os.getenv(name)
404
+ if raw is None:
405
+ return default
406
+ return raw.strip().lower() in {"1", "true", "yes", "on"}
407
+
408
+
409
+ def envelope_kdf_migration_enabled() -> bool:
410
+ """Whether an explicit read may migrate argon2id envelopes with backups.
411
+
412
+ Disabled by default so normal reads never change storage or break rollback
413
+ to a pre-HKDF runtime. Opt in with AGENT_WALLET_ENVELOPE_KDF_MIGRATION=1.
414
+ """
415
+ return _env_bool("AGENT_WALLET_ENVELOPE_KDF_MIGRATION", False)
416
+
417
+
418
+ _boot_key_keystore_cache: dict[tuple[str, str, str], str] = {}
419
+ _boot_key_validation_cache: dict[tuple[str, str, int, int], bool] = {}
420
+
421
+
422
+ def clear_secret_caches() -> None:
423
+ """Reset all process-local secret-resolution caches.
424
+
425
+ Covers the memoized keystore backend, the boot key read from the OS
426
+ keystore, unsealed secrets, and derived envelope keys. Wired into
427
+ ``reload_settings`` so config reloads always observe fresh state; call it
428
+ directly in tests that rotate keystore contents in-process.
429
+ """
430
+ _boot_key_keystore_cache.clear()
431
+ _boot_key_validation_cache.clear()
432
+ from agent_wallet.keystore import clear_keystore_cache
433
+
434
+ clear_keystore_cache()
435
+ from agent_wallet.sealed_keys import clear_unseal_cache
436
+
437
+ clear_unseal_cache()
438
+ from agent_wallet.encrypted_storage import clear_derived_key_cache
439
+
440
+ clear_derived_key_cache()
441
+
442
+
443
+ def read_boot_key_from_keystore() -> str:
444
+ """Read the boot key from the OS keystore. Never raises; '' on any failure.
445
+
446
+ Successful (non-empty) reads are memoized per keystore service for the
447
+ process lifetime — every uncached read costs a subprocess call.
448
+ """
449
+ try:
450
+ from agent_wallet.keystore import BOOT_KEY_ITEM, resolve_keystore
451
+
452
+ cache_key = (
453
+ os.getenv("AGENT_WALLET_KEYSTORE_BACKEND", "auto").strip().lower(),
454
+ os.getenv("AGENT_WALLET_KEYSTORE_SERVICE", "").strip(),
455
+ str(resolve_openclaw_home().resolve()),
456
+ )
457
+ cached = _boot_key_keystore_cache.get(cache_key)
458
+ if cached:
459
+ return cached
460
+ value = resolve_keystore().get(BOOT_KEY_ITEM)
461
+ text = value.strip() if isinstance(value, str) else ""
462
+ if text:
463
+ _boot_key_keystore_cache[cache_key] = text
464
+ return text
465
+ except Exception:
466
+ return ""
467
+
468
+
469
+ def read_boot_key_from_legacy_unscoped_keystore() -> str:
470
+ """Read the pre-home-scoping native service for compatibility only."""
471
+ sealed_path = resolve_openclaw_home() / "sealed_keys.json"
472
+ if not sealed_path.exists():
473
+ return ""
474
+ try:
475
+ from agent_wallet.keystore import read_legacy_unscoped_boot_key
476
+
477
+ return read_legacy_unscoped_boot_key()
478
+ except Exception:
479
+ return ""
480
+
481
+
482
+ def _read_boot_key_file(path_value: str) -> str:
483
+ if not path_value.strip():
484
+ return ""
485
+ try:
486
+ return Path(path_value).expanduser().read_text(encoding="utf-8").strip()
487
+ except OSError:
488
+ return ""
489
+
490
+
491
+ def _boot_key_candidates() -> Iterator[tuple[str, str]]:
492
+ seen: set[str] = set()
493
+
494
+ def candidate(source: str, value: str) -> tuple[str, str] | None:
495
+ if not value or value in seen:
496
+ return None
497
+ seen.add(value)
498
+ return source, value
499
+
500
+ for item in (
501
+ candidate("environment", os.getenv("AGENT_WALLET_BOOT_KEY", "").strip()),
502
+ candidate("runtime_env", settings.agent_wallet_boot_key.strip()),
503
+ ):
504
+ if item:
505
+ yield item
506
+
507
+ keystore_item = candidate("keystore", read_boot_key_from_keystore())
508
+ if keystore_item:
509
+ yield keystore_item
510
+
511
+ legacy_keystore_item = candidate(
512
+ "legacy_unscoped_keystore",
513
+ read_boot_key_from_legacy_unscoped_keystore(),
514
+ )
515
+ if legacy_keystore_item:
516
+ yield legacy_keystore_item
517
+
518
+ configured_file = os.getenv(
519
+ "AGENT_WALLET_BOOT_KEY_FILE", settings.agent_wallet_boot_key_file
520
+ ).strip()
521
+ configured_item = candidate("configured_file", _read_boot_key_file(configured_file))
522
+ if configured_item:
523
+ yield configured_item
524
+
525
+ default_file = resolve_openclaw_home() / "agent-wallet-runtime" / "boot-key"
526
+ if not configured_file or Path(configured_file).expanduser() != default_file:
527
+ default_item = candidate("default_file", _read_boot_key_file(str(default_file)))
528
+ if default_item:
529
+ yield default_item
530
+
531
+
532
+ def _boot_key_unlocks_sealed_file(boot_key: str) -> bool | None:
533
+ sealed_path = resolve_openclaw_home() / "sealed_keys.json"
534
+ try:
535
+ stat = sealed_path.stat()
536
+ except FileNotFoundError:
537
+ return None
538
+ except OSError:
539
+ return False
540
+
541
+ cache_key = (boot_key, str(sealed_path), stat.st_mtime_ns, stat.st_size)
542
+ cached = _boot_key_validation_cache.get(cache_key)
543
+ if cached is not None:
544
+ return cached
545
+ try:
546
+ from agent_wallet.sealed_keys import unseal_keys
547
+
548
+ unseal_keys(boot_key)
549
+ valid = True
550
+ except Exception:
551
+ valid = False
552
+ if len(_boot_key_validation_cache) >= 8:
553
+ _boot_key_validation_cache.clear()
554
+ _boot_key_validation_cache[cache_key] = valid
555
+ return valid
556
+
557
+
558
+ def _resolve_boot_key_candidate() -> tuple[str, str, bool, list[str], bool]:
559
+ rejected: list[str] = []
560
+ for source, value in _boot_key_candidates():
561
+ verified = _boot_key_unlocks_sealed_file(value)
562
+ if verified is not False:
563
+ return value, source, verified is True, rejected, bool(rejected)
564
+ rejected.append(source)
565
+ return "", "none", False, rejected, len(rejected) > 1
566
+
567
+
568
+ def resolve_boot_key() -> str:
569
+ """Resolve a boot key, verifying candidates against sealed secrets when present.
570
+
571
+ Precedence remains compatible with legacy installs:
572
+ 1. AGENT_WALLET_BOOT_KEY env / settings override
573
+ 2. OS keystore (the hardened path)
574
+ 3. AGENT_WALLET_BOOT_KEY_FILE / boot-key file (legacy)
575
+
576
+ A stale higher-priority candidate cannot mask a lower-priority key that
577
+ actually unlocks ``sealed_keys.json``.
578
+ """
579
+ return _resolve_boot_key_candidate()[0]
580
+
581
+
582
+ def resolve_boot_key_for_installer() -> str:
583
+ """Stable installer bridge; older runtimes lack this symbol and use JS fallback."""
584
+ return resolve_boot_key()
585
+
586
+
587
+ def boot_key_resolution_status() -> dict[str, object]:
588
+ """Return non-secret diagnostics for doctor/install reporting."""
589
+ from agent_wallet.keystore import keystore_backend_status
590
+
591
+ value, source, verified, rejected, conflict = _resolve_boot_key_candidate()
592
+ fingerprint = hashlib.sha256(value.encode("utf-8")).hexdigest()[:12] if value else None
593
+ return {
594
+ "available": bool(value),
595
+ "source": source,
596
+ "sealed_keys_verified": verified,
597
+ "conflict_detected": conflict,
598
+ "rejected_sources": rejected,
599
+ "fingerprint": fingerprint,
600
+ "keystore": keystore_backend_status(),
601
+ }
602
+
603
+
604
+ def _reject_legacy_runtime_secret_env(var_name: str) -> None:
605
+ raw = os.getenv(var_name, "").strip()
606
+ if not raw:
607
+ return
608
+ from agent_wallet.wallet_layer.base import WalletBackendError
609
+
610
+ raise WalletBackendError(
611
+ f"{var_name} is no longer supported for runtime secret loading. "
612
+ "Store runtime secrets in ~/.openclaw/sealed_keys.json and provide AGENT_WALLET_BOOT_KEY instead."
613
+ )
614
+
615
+
616
+ def _resolve_sealed_secret(*names: str) -> str:
617
+ boot_key = resolve_boot_key()
618
+ if not boot_key:
619
+ return ""
620
+ from agent_wallet.sealed_keys import unseal_keys
621
+
622
+ secrets = unseal_keys(boot_key)
623
+ for name in names:
624
+ value = secrets.get(name)
625
+ if isinstance(value, str) and value.strip():
626
+ return value.strip()
627
+ return ""
628
+
629
+
630
+ def resolve_kernel_api_key() -> str:
631
+ """Kernel credentials stay in the sealed runtime bundle, never host config."""
632
+ return _resolve_sealed_secret("kernel_api_key")
633
+
634
+
635
+ def resolve_kernel_gateway_url() -> str:
636
+ """Reuse the existing public gateway setting; no new install-time prompt."""
637
+ from urllib.parse import urlsplit
638
+
639
+ value = os.getenv("PROVIDER_GATEWAY_URL", settings.provider_gateway_url).strip().rstrip("/")
640
+ try:
641
+ parsed = urlsplit(value)
642
+ local = parsed.hostname in {"localhost", "127.0.0.1", "::1"}
643
+ if (not value.isascii() or any(ord(c) <= 32 for c in value) or "\\" in value
644
+ or not parsed.hostname or parsed.username is not None or parsed.password is not None
645
+ or parsed.query or parsed.fragment or "%" in parsed.path
646
+ or any(part in {".", ".."} for part in parsed.path.split("/"))
647
+ or (parsed.scheme != "https" and not (local and parsed.scheme == "http"))):
648
+ raise ValueError()
649
+ parsed.port
650
+ except ValueError:
651
+ raise RuntimeError("Shared browser gateway requires an HTTPS origin (HTTP is allowed only on localhost).") from None
652
+ return value
653
+
654
+
655
+ def resolve_wallet_master_key() -> str:
656
+ """Resolve the master key used for encrypting per-user wallet files."""
657
+ _reject_legacy_runtime_secret_env("AGENT_WALLET_MASTER_KEY")
658
+ return _resolve_sealed_secret("master_key", "masterKey")
659
+
660
+
661
+ def resolve_approval_secret() -> str:
662
+ """Resolve the secret used for host-issued approval tokens."""
663
+ _reject_legacy_runtime_secret_env("AGENT_WALLET_APPROVAL_SECRET")
664
+ return _resolve_sealed_secret("approval_secret", "approvalSecret")
665
+
666
+
667
+ def resolve_solana_private_key() -> str:
668
+ """Resolve the Solana signing key from env/config or the sealed secret store."""
669
+ _reject_legacy_runtime_secret_env("SOLANA_AGENT_PRIVATE_KEY")
670
+ return _resolve_sealed_secret(
671
+ "solana_agent_private_key",
672
+ "private_key",
673
+ "privateKey",
674
+ )
675
+
676
+
677
+ def resolve_evm_wallet_password() -> str:
678
+ """Resolve the local EVM vault password from env or the sealed secret store."""
679
+ direct = os.getenv("WDK_EVM_WALLET_PASSWORD", "").strip()
680
+ if direct:
681
+ return direct
682
+ return _resolve_sealed_secret(
683
+ "wdk_evm_wallet_password",
684
+ "evm_wallet_password",
685
+ )
686
+
687
+
688
+ def use_encrypted_user_wallets() -> bool:
689
+ """Per-user wallet files are always encrypted in the hardened runtime."""
690
+ return True
691
+
692
+
693
+ def allow_plaintext_user_wallet_migration() -> bool:
694
+ """Return whether legacy plaintext per-user wallets may be migrated in place."""
695
+ return _env_bool(
696
+ "AGENT_WALLET_MIGRATE_PLAINTEXT_USER_WALLETS",
697
+ settings.agent_wallet_migrate_plaintext_user_wallets,
698
+ )
699
+
700
+
701
+ def use_per_user_key_derivation() -> bool:
702
+ """Per-user wallet encryption keys are always derived from the master key."""
703
+ return True
704
+
705
+
706
+ def refuse_mainnet_wallet_recreation() -> bool:
707
+ """Return whether mainnet wallets may be recreated when a pinned address exists."""
708
+ return _env_bool(
709
+ "AGENT_WALLET_REFUSE_MAINNET_WALLET_RECREATION",
710
+ settings.agent_wallet_refuse_mainnet_wallet_recreation,
711
+ )
712
+
713
+
714
+ def require_encrypted_mainnet() -> bool:
715
+ """Return whether plaintext wallet creation is forbidden on mainnet."""
716
+ return _env_bool(
717
+ "AGENT_WALLET_REQUIRE_ENCRYPTED_MAINNET",
718
+ settings.agent_wallet_require_encrypted_mainnet,
719
+ )