@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.
- package/.claude-plugin/marketplace.json +20 -0
- package/.openclaw/AGENTS.md +100 -0
- package/.openclaw/extensions/agent-wallet/README.md +195 -0
- package/.openclaw/extensions/agent-wallet/dist/index.js +2198 -0
- package/.openclaw/extensions/agent-wallet/index.ts +2198 -0
- package/.openclaw/extensions/agent-wallet/openclaw.plugin.json +251 -0
- package/.openclaw/extensions/agent-wallet/package.json +49 -0
- package/.openclaw/extensions/agent-wallet/skills/cards/SKILL.md +211 -0
- package/.openclaw/extensions/agent-wallet/skills/wallet-operator/SKILL.md +30 -0
- package/CHANGELOG.md +1232 -0
- package/LICENSE +104 -0
- package/README.md +193 -2
- package/VERSION +1 -0
- package/agent-wallet/.env.example +63 -0
- package/agent-wallet/AGENTS.md +130 -0
- package/agent-wallet/CARD_VAULT.md +640 -0
- package/agent-wallet/README.md +615 -0
- package/agent-wallet/UPGRADE_COMPATIBILITY.md +66 -0
- package/agent-wallet/agent_wallet/__init__.py +16 -0
- package/agent-wallet/agent_wallet/approval.py +165 -0
- package/agent-wallet/agent_wallet/autonomous_permissions.py +281 -0
- package/agent-wallet/agent_wallet/autonomous_policy.py +305 -0
- package/agent-wallet/agent_wallet/autonomous_session.py +236 -0
- package/agent-wallet/agent_wallet/boot_key_migration.py +155 -0
- package/agent-wallet/agent_wallet/boot_key_recovery.py +57 -0
- package/agent-wallet/agent_wallet/bootstrap.py +194 -0
- package/agent-wallet/agent_wallet/card_catalog.py +243 -0
- package/agent-wallet/agent_wallet/card_runtime_secrets.py +108 -0
- package/agent-wallet/agent_wallet/card_vault.py +331 -0
- package/agent-wallet/agent_wallet/card_vault_cli.py +174 -0
- package/agent-wallet/agent_wallet/card_vault_import.py +65 -0
- package/agent-wallet/agent_wallet/card_vault_keychain.py +239 -0
- package/agent-wallet/agent_wallet/config.py +719 -0
- package/agent-wallet/agent_wallet/connector_cli.py +198 -0
- package/agent-wallet/agent_wallet/connectors/__init__.py +28 -0
- package/agent-wallet/agent_wallet/connectors/catalog.py +68 -0
- package/agent-wallet/agent_wallet/connectors/client.py +308 -0
- package/agent-wallet/agent_wallet/connectors/intent_policy.py +243 -0
- package/agent-wallet/agent_wallet/connectors/manifest.py +192 -0
- package/agent-wallet/agent_wallet/connectors/registry.py +341 -0
- package/agent-wallet/agent_wallet/encrypted_storage.py +314 -0
- package/agent-wallet/agent_wallet/evm_user_wallets.py +910 -0
- package/agent-wallet/agent_wallet/exceptions.py +10 -0
- package/agent-wallet/agent_wallet/file_ops.py +34 -0
- package/agent-wallet/agent_wallet/http_client.py +25 -0
- package/agent-wallet/agent_wallet/kernel_browser.py +479 -0
- package/agent-wallet/agent_wallet/kernel_cli.py +57 -0
- package/agent-wallet/agent_wallet/kernel_gateway.py +95 -0
- package/agent-wallet/agent_wallet/keystore.py +503 -0
- package/agent-wallet/agent_wallet/laso_card_vault.py +246 -0
- package/agent-wallet/agent_wallet/models.py +66 -0
- package/agent-wallet/agent_wallet/morpho_monitor.py +298 -0
- package/agent-wallet/agent_wallet/nonce_registry.py +59 -0
- package/agent-wallet/agent_wallet/openclaw_adapter.py +9129 -0
- package/agent-wallet/agent_wallet/openclaw_cli.py +658 -0
- package/agent-wallet/agent_wallet/openclaw_runtime.py +194 -0
- package/agent-wallet/agent_wallet/plugin_bundle.py +44 -0
- package/agent-wallet/agent_wallet/providers/__init__.py +1 -0
- package/agent-wallet/agent_wallet/providers/bags.py +202 -0
- package/agent-wallet/agent_wallet/providers/dexscreener.py +147 -0
- package/agent-wallet/agent_wallet/providers/evm_activity.py +257 -0
- package/agent-wallet/agent_wallet/providers/evm_portfolio.py +459 -0
- package/agent-wallet/agent_wallet/providers/imd.py +720 -0
- package/agent-wallet/agent_wallet/providers/jupiter.py +519 -0
- package/agent-wallet/agent_wallet/providers/kamino.py +404 -0
- package/agent-wallet/agent_wallet/providers/lifi.py +302 -0
- package/agent-wallet/agent_wallet/providers/solana_rpc.py +447 -0
- package/agent-wallet/agent_wallet/providers/tokenized_stocks.py +189 -0
- package/agent-wallet/agent_wallet/providers/wdk_evm_local.py +346 -0
- package/agent-wallet/agent_wallet/providers/x402.py +1972 -0
- package/agent-wallet/agent_wallet/sealed_keys.py +118 -0
- package/agent-wallet/agent_wallet/solana_stake.py +103 -0
- package/agent-wallet/agent_wallet/solana_tx.py +93 -0
- package/agent-wallet/agent_wallet/spending_limits.py +119 -0
- package/agent-wallet/agent_wallet/telemetry.py +481 -0
- package/agent-wallet/agent_wallet/transaction_policy.py +573 -0
- package/agent-wallet/agent_wallet/update_check.py +190 -0
- package/agent-wallet/agent_wallet/user_wallets.py +573 -0
- package/agent-wallet/agent_wallet/validation.py +31 -0
- package/agent-wallet/agent_wallet/vault_executor.py +456 -0
- package/agent-wallet/agent_wallet/wallet_layer/__init__.py +1 -0
- package/agent-wallet/agent_wallet/wallet_layer/base.py +1204 -0
- package/agent-wallet/agent_wallet/wallet_layer/base58.py +44 -0
- package/agent-wallet/agent_wallet/wallet_layer/factory.py +117 -0
- package/agent-wallet/agent_wallet/wallet_layer/solana.py +5246 -0
- package/agent-wallet/agent_wallet/wallet_layer/wdk_evm.py +2705 -0
- package/agent-wallet/examples/bootstrap_wallet.py +21 -0
- package/agent-wallet/examples/openclaw_runtime_onboarding.py +28 -0
- package/agent-wallet/examples/openclaw_user_wallet_example.py +31 -0
- package/agent-wallet/examples/openclaw_wallet_adapter_example.py +33 -0
- package/agent-wallet/openclaw.plugin.json +118 -0
- package/agent-wallet/pyproject.toml +36 -0
- package/agent-wallet/scripts/bootstrap_openclaw_evm.py +312 -0
- package/agent-wallet/scripts/build_release_bundle.py +210 -0
- package/agent-wallet/scripts/finalize_openclaw_local_wallet_config.py +121 -0
- package/agent-wallet/scripts/install_agent_wallet.py +1357 -0
- package/agent-wallet/scripts/install_openclaw_local_config.py +421 -0
- package/agent-wallet/scripts/install_openclaw_sealed_keys.py +117 -0
- package/agent-wallet/scripts/manage_openclaw_evm_wallet.py +333 -0
- package/agent-wallet/scripts/security_utils.py +37 -0
- package/agent-wallet/scripts/setup_evm_wallet.sh +140 -0
- package/agent-wallet/scripts/switch_openclaw_wallet_network.py +109 -0
- package/agent-wallet/skills/wallet-operator/SKILL.md +157 -0
- package/bin/lib/boot-key.mjs +184 -0
- package/bin/lib/evm-daemon.mjs +389 -0
- package/bin/lib/host-detection.mjs +259 -0
- package/bin/lib/integrations.mjs +578 -0
- package/bin/lib/release-python.mjs +9 -0
- package/bin/lib/update-transaction.mjs +235 -0
- package/bin/openclaw-agent-wallet.mjs +3354 -0
- package/claude-code/plugins/agent-wallet/.claude-plugin/plugin.json +19 -0
- package/claude-code/plugins/agent-wallet/.mcp.json +14 -0
- package/claude-code/plugins/agent-wallet/AGENTLAYER_AGENT_GUIDE.md +282 -0
- package/claude-code/plugins/agent-wallet/README.md +134 -0
- package/claude-code/plugins/agent-wallet/commands/agentlayer-autonomous-approve.md +39 -0
- package/claude-code/plugins/agent-wallet/commands/agentlayer-autonomous-revoke.md +17 -0
- package/claude-code/plugins/agent-wallet/commands/cards.md +129 -0
- package/claude-code/plugins/agent-wallet/commands/guide.md +40 -0
- package/claude-code/plugins/agent-wallet/commands/imd.md +125 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-base.md +60 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-ethereum.md +37 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-evm.md +39 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-setup.md +25 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-sol.md +51 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-statusline.md +34 -0
- package/claude-code/plugins/agent-wallet/commands/x402.md +121 -0
- package/claude-code/plugins/agent-wallet/commands/yield.md +62 -0
- package/claude-code/plugins/agent-wallet/hooks/hooks.json +16 -0
- package/claude-code/plugins/agent-wallet/scripts/bootstrap_backend.sh +136 -0
- package/claude-code/plugins/agent-wallet/scripts/enable_statusline.py +52 -0
- package/claude-code/plugins/agent-wallet/scripts/resolve_wallet_addresses.py +69 -0
- package/claude-code/plugins/agent-wallet/scripts/run_mcp.sh +66 -0
- package/claude-code/plugins/agent-wallet/scripts/wallet_statusline.py +130 -0
- package/claude-code/plugins/agent-wallet/scripts/wallet_statusline_setup.sh +40 -0
- package/claude-code/plugins/agent-wallet/skills/wallet-operator/SKILL.md +21 -0
- package/codex/plugins/agent-wallet/.codex-plugin/plugin.json +37 -0
- package/codex/plugins/agent-wallet/.mcp.json +15 -0
- package/codex/plugins/agent-wallet/README.md +158 -0
- package/codex/plugins/agent-wallet/scripts/run_mcp.sh +47 -0
- package/codex/plugins/agent-wallet/server.py +1797 -0
- package/codex/plugins/agent-wallet/skills/cards/SKILL.md +225 -0
- package/codex/plugins/agent-wallet/skills/imd/SKILL.md +145 -0
- package/codex/plugins/agent-wallet/skills/wallet-base/SKILL.md +56 -0
- package/codex/plugins/agent-wallet/skills/wallet-operator/SKILL.md +85 -0
- package/codex/plugins/agent-wallet/skills/wallet-sol/SKILL.md +29 -0
- package/codex/plugins/agent-wallet/skills/x402/SKILL.md +159 -0
- package/codex/plugins/agent-wallet/skills/yield/SKILL.md +65 -0
- package/connectors/AGENTS.md +37 -0
- package/connectors/DEVELOPER_GUIDE.md +131 -0
- package/connectors/README.md +139 -0
- package/connectors/READ_ONLY_BETA.md +54 -0
- package/connectors/RELEASING.md +48 -0
- package/connectors/conformance/README.md +31 -0
- package/connectors/conformance/package.json +54 -0
- package/connectors/conformance/scripts/sync-license.mjs +3 -0
- package/connectors/conformance/scripts/sync-spec.mjs +16 -0
- package/connectors/conformance/src/cli.ts +43 -0
- package/connectors/conformance/src/index.ts +7 -0
- package/connectors/conformance/src/runner.ts +314 -0
- package/connectors/conformance/src/types.ts +27 -0
- package/connectors/conformance/test/fixtures/invalid-response-identity.json +14 -0
- package/connectors/conformance/test/fixtures/missing-tool-fixture.json +4 -0
- package/connectors/conformance/test/runner.test.mjs +151 -0
- package/connectors/conformance/tsconfig.json +17 -0
- package/connectors/examples/reference-crypto-data/Dockerfile +21 -0
- package/connectors/examples/reference-crypto-data/README.md +51 -0
- package/connectors/examples/reference-crypto-data/conformance.json +11 -0
- package/connectors/examples/reference-crypto-data/connector.json +95 -0
- package/connectors/examples/reference-crypto-data/package.json +21 -0
- package/connectors/examples/reference-crypto-data/railway.toml +9 -0
- package/connectors/examples/reference-crypto-data/src/connector.ts +137 -0
- package/connectors/examples/reference-crypto-data/src/server.ts +13 -0
- package/connectors/examples/reference-crypto-data/test/connector.test.mjs +97 -0
- package/connectors/examples/reference-crypto-data/tsconfig.json +17 -0
- package/connectors/package-lock.json +561 -0
- package/connectors/package.json +19 -0
- package/connectors/scripts/smoke-packed-packages.mjs +121 -0
- package/connectors/sdk-typescript/README.md +47 -0
- package/connectors/sdk-typescript/package.json +49 -0
- package/connectors/sdk-typescript/scripts/sync-license.mjs +3 -0
- package/connectors/sdk-typescript/src/connector.ts +204 -0
- package/connectors/sdk-typescript/src/errors.ts +11 -0
- package/connectors/sdk-typescript/src/http.ts +116 -0
- package/connectors/sdk-typescript/src/index.ts +26 -0
- package/connectors/sdk-typescript/src/types.ts +101 -0
- package/connectors/sdk-typescript/test/sdk.test.mjs +181 -0
- package/connectors/sdk-typescript/tsconfig.json +21 -0
- package/connectors/spec/connector-manifest.schema.json +340 -0
- package/connectors/spec/connector-protocol.md +159 -0
- package/connectors/spec/transaction-intent.schema.json +281 -0
- package/connectors/templates/read-only/.env.example +1 -0
- package/connectors/templates/read-only/Dockerfile +11 -0
- package/connectors/templates/read-only/README.md +33 -0
- package/connectors/templates/read-only/conformance.json +11 -0
- package/connectors/templates/read-only/connector.json +64 -0
- package/connectors/templates/read-only/package.json +21 -0
- package/connectors/templates/read-only/railway.toml +9 -0
- package/connectors/templates/read-only/src/connector.ts +61 -0
- package/connectors/templates/read-only/src/server.ts +14 -0
- package/connectors/templates/read-only/test/connector.test.mjs +62 -0
- package/connectors/templates/read-only/tsconfig.json +17 -0
- package/cursor/plugins/agent-wallet/.cursor-plugin/plugin.json +14 -0
- package/cursor/plugins/agent-wallet/README.md +62 -0
- package/cursor/plugins/agent-wallet/mcp.json +16 -0
- package/cursor/plugins/agent-wallet/scripts/run_mcp.sh +33 -0
- package/cursor/plugins/agent-wallet/server.py +33 -0
- package/cursor/plugins/agent-wallet/skills/cards/SKILL.md +210 -0
- package/cursor/plugins/agent-wallet/skills/wallet-base/SKILL.md +56 -0
- package/cursor/plugins/agent-wallet/skills/wallet-operator/SKILL.md +23 -0
- package/cursor/plugins/agent-wallet/skills/wallet-sol/SKILL.md +29 -0
- package/cursor/plugins/agent-wallet/skills/x402/SKILL.md +130 -0
- package/hermes/plugins/agent_wallet/README.md +54 -0
- package/hermes/plugins/agent_wallet/__init__.py +55 -0
- package/hermes/plugins/agent_wallet/plugin.yaml +9 -0
- package/hermes/plugins/agent_wallet/schemas.py +211 -0
- package/hermes/plugins/agent_wallet/tools.py +622 -0
- package/install-from-github.sh +139 -0
- package/integrations/hedera/treasury-guard/README.md +92 -0
- package/integrations/hedera/treasury-guard/examples/treasury-policy.example.json +9 -0
- package/integrations/hedera/treasury-guard/package-lock.json +880 -0
- package/integrations/hedera/treasury-guard/package.json +8 -0
- package/integrations/hedera/treasury-guard/skills/onecraft-hedera-treasury/SKILL.md +22 -0
- package/integrations/hedera/treasury-guard/src/hedera-mirror-client.mjs +106 -0
- package/integrations/hedera/treasury-guard/src/hedera-signer.mjs +120 -0
- package/integrations/hedera/treasury-guard/src/treasury-cli.mjs +177 -0
- package/integrations/hedera/treasury-guard/src/treasury-policy.mjs +155 -0
- package/mcp/README.md +39 -0
- package/mcp/scripts/run_mcp.sh +37 -0
- package/mcp/server.py +33 -0
- package/package.json +106 -4
- package/scripts/check_release_version.mjs +72 -0
- package/scripts/version_targets.mjs +60 -0
- package/setup.sh +87 -0
- package/wdk-evm-wallet/.env.example +38 -0
- package/wdk-evm-wallet/README.md +254 -0
- package/wdk-evm-wallet/bootstrap.sh +8 -0
- package/wdk-evm-wallet/package-lock.json +2359 -0
- package/wdk-evm-wallet/package.json +43 -0
- package/wdk-evm-wallet/run-local.sh +12 -0
- package/wdk-evm-wallet/src/config.js +461 -0
- package/wdk-evm-wallet/src/imd.js +231 -0
- package/wdk-evm-wallet/src/json.js +35 -0
- package/wdk-evm-wallet/src/local_vault.js +407 -0
- package/wdk-evm-wallet/src/network_state.js +96 -0
- package/wdk-evm-wallet/src/pending_transactions.js +148 -0
- package/wdk-evm-wallet/src/server.js +849 -0
- package/wdk-evm-wallet/src/shutdown.js +63 -0
- package/wdk-evm-wallet/src/wdk_evm_wallet.js +10036 -0
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
"""CLI bridge for the official OpenClaw TypeScript plugin."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import asyncio
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
import sys
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from agent_wallet.wallet_layer.base import WalletBackendError
|
|
13
|
+
|
|
14
|
+
try: # telemetry is optional and must never break the CLI
|
|
15
|
+
from agent_wallet.telemetry import record_cli_invoke as _telemetry_record_cli_invoke
|
|
16
|
+
from agent_wallet.telemetry import record_x402_lifecycle as _telemetry_record_x402_lifecycle
|
|
17
|
+
except Exception: # pragma: no cover - defensive
|
|
18
|
+
def _telemetry_record_cli_invoke(*_args: Any, **_kwargs: Any) -> None:
|
|
19
|
+
return None
|
|
20
|
+
|
|
21
|
+
def _telemetry_record_x402_lifecycle(*_args: Any, **_kwargs: Any) -> None:
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _parse_bool(value: Any) -> str:
|
|
26
|
+
if value is None:
|
|
27
|
+
return ""
|
|
28
|
+
return "true" if value is True else "false"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _parse_csv(value: Any) -> str:
|
|
32
|
+
if value is None:
|
|
33
|
+
return ""
|
|
34
|
+
if isinstance(value, list):
|
|
35
|
+
return ",".join(str(item).strip() for item in value if str(item).strip())
|
|
36
|
+
return str(value).strip()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
SECRET_CONFIG_KEYS = {"privateKey", "masterKey", "approvalSecret"}
|
|
40
|
+
# Always-allowed floor kept for compatibility; the live gate is the dynamic
|
|
41
|
+
# set of adapter-declared read-only tools (_read_only_tool_names).
|
|
42
|
+
READ_ONLY_WORKER_TOOLS = frozenset(
|
|
43
|
+
{
|
|
44
|
+
"get_wallet_balance",
|
|
45
|
+
"get_wallet_portfolio",
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _read_only_tool_names(context: Any) -> frozenset[str]:
|
|
51
|
+
"""All tools the resident read worker may serve: the adapter's read-only
|
|
52
|
+
specs for this backend, plus the legacy floor."""
|
|
53
|
+
names = set(READ_ONLY_WORKER_TOOLS)
|
|
54
|
+
try:
|
|
55
|
+
for tool in context.adapter.list_tools():
|
|
56
|
+
spec = tool.model_dump() if hasattr(tool, "model_dump") else dict(tool)
|
|
57
|
+
if spec.get("read_only") is True and str(spec.get("name") or "").strip():
|
|
58
|
+
names.add(str(spec["name"]))
|
|
59
|
+
except Exception:
|
|
60
|
+
pass
|
|
61
|
+
return frozenset(names)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _reject_secret_config_json(config: dict[str, Any]) -> None:
|
|
65
|
+
present = sorted(key for key in SECRET_CONFIG_KEYS if str(config.get(key) or "").strip())
|
|
66
|
+
if present:
|
|
67
|
+
joined = ", ".join(present)
|
|
68
|
+
raise WalletBackendError(
|
|
69
|
+
f"Sensitive keys are not allowed in --config-json: {joined}. "
|
|
70
|
+
"Pass secrets via protected environment injection instead."
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _apply_config_overrides(config: dict[str, Any]) -> None:
|
|
75
|
+
_reject_secret_config_json(config)
|
|
76
|
+
from agent_wallet.config import is_legacy_evm_service_url
|
|
77
|
+
|
|
78
|
+
# Every EVM path below reads wdkEvmServiceUrl from this same dict, so
|
|
79
|
+
# dropping the legacy TCP default here moves them all to the socket.
|
|
80
|
+
if is_legacy_evm_service_url(config.get("wdkEvmServiceUrl")):
|
|
81
|
+
config.pop("wdkEvmServiceUrl", None)
|
|
82
|
+
rpc_env_locked = bool(os.getenv("SOLANA_RPC_URL", "").strip() or os.getenv("SOLANA_RPC_URLS", "").strip())
|
|
83
|
+
env_map: dict[str, tuple[str, Any, bool]] = {
|
|
84
|
+
"backend": ("AGENT_WALLET_BACKEND", config.get("backend"), True),
|
|
85
|
+
"signOnly": ("AGENT_WALLET_SIGN_ONLY", _parse_bool(config.get("signOnly")), True),
|
|
86
|
+
"network": ("SOLANA_NETWORK", config.get("network"), True),
|
|
87
|
+
# Deployment-owned RPC env must win over plugin config.
|
|
88
|
+
"rpcUrl": ("SOLANA_RPC_URL", config.get("rpcUrl"), False),
|
|
89
|
+
"rpcUrls": ("SOLANA_RPC_URLS", _parse_csv(config.get("rpcUrls")), False),
|
|
90
|
+
"rpcProviderMode": ("SOLANA_RPC_PROVIDER_MODE", config.get("rpcProviderMode"), True),
|
|
91
|
+
"providerGatewayUrl": ("PROVIDER_GATEWAY_URL", config.get("providerGatewayUrl"), True),
|
|
92
|
+
"providerGatewayRpcProvider": (
|
|
93
|
+
"PROVIDER_GATEWAY_RPC_PROVIDER",
|
|
94
|
+
config.get("providerGatewayRpcProvider"),
|
|
95
|
+
True,
|
|
96
|
+
),
|
|
97
|
+
"wdkEvmServiceUrl": ("WDK_EVM_SERVICE_URL", config.get("wdkEvmServiceUrl"), True),
|
|
98
|
+
"wdkEvmWalletId": ("WDK_EVM_WALLET_ID", config.get("wdkEvmWalletId"), True),
|
|
99
|
+
"wdkEvmAccountIndex": (
|
|
100
|
+
"WDK_EVM_ACCOUNT_INDEX",
|
|
101
|
+
config.get("wdkEvmAccountIndex"),
|
|
102
|
+
True,
|
|
103
|
+
),
|
|
104
|
+
"swapProvider": ("SOLANA_SWAP_PROVIDER", config.get("swapProvider"), True),
|
|
105
|
+
"heliusApiKey": ("HELIUS_API_KEY", config.get("heliusApiKey"), True),
|
|
106
|
+
"alchemyApiKey": ("ALCHEMY_API_KEY", config.get("alchemyApiKey"), True),
|
|
107
|
+
"publicKey": ("SOLANA_AGENT_PUBLIC_KEY", config.get("publicKey"), True),
|
|
108
|
+
"keypairPath": ("SOLANA_AGENT_KEYPAIR_PATH", config.get("keypairPath"), True),
|
|
109
|
+
"autoCreateWallet": ("SOLANA_AUTO_CREATE_WALLET", _parse_bool(config.get("autoCreateWallet")), True),
|
|
110
|
+
"encryptUserWallets": (
|
|
111
|
+
"AGENT_WALLET_ENCRYPT_USER_WALLETS",
|
|
112
|
+
_parse_bool(config.get("encryptUserWallets")),
|
|
113
|
+
True,
|
|
114
|
+
),
|
|
115
|
+
"migratePlaintextUserWallets": (
|
|
116
|
+
"AGENT_WALLET_MIGRATE_PLAINTEXT_USER_WALLETS",
|
|
117
|
+
_parse_bool(config.get("migratePlaintextUserWallets")),
|
|
118
|
+
True,
|
|
119
|
+
),
|
|
120
|
+
"refuseMainnetWalletRecreation": (
|
|
121
|
+
"AGENT_WALLET_REFUSE_MAINNET_WALLET_RECREATION",
|
|
122
|
+
_parse_bool(config.get("refuseMainnetWalletRecreation")),
|
|
123
|
+
True,
|
|
124
|
+
),
|
|
125
|
+
"openclawHome": ("OPENCLAW_HOME", config.get("openclawHome"), True),
|
|
126
|
+
"jupiterBaseUrl": ("JUPITER_API_BASE_URL", config.get("jupiterBaseUrl"), True),
|
|
127
|
+
"jupiterSwapV2BaseUrl": ("JUPITER_SWAP_V2_API_BASE_URL", config.get("jupiterSwapV2BaseUrl"), True),
|
|
128
|
+
"jupiterUltraBaseUrl": ("JUPITER_ULTRA_API_BASE_URL", config.get("jupiterUltraBaseUrl"), True),
|
|
129
|
+
"jupiterPriceBaseUrl": ("JUPITER_PRICE_API_BASE_URL", config.get("jupiterPriceBaseUrl"), True),
|
|
130
|
+
"jupiterApiKey": ("JUPITER_API_KEY", config.get("jupiterApiKey"), True),
|
|
131
|
+
"kaminoBaseUrl": ("KAMINO_API_BASE_URL", config.get("kaminoBaseUrl"), True),
|
|
132
|
+
"kaminoProgramId": ("KAMINO_PROGRAM_ID", config.get("kaminoProgramId"), True),
|
|
133
|
+
}
|
|
134
|
+
for _, (env_name, value, allow_override) in env_map.items():
|
|
135
|
+
if value is None:
|
|
136
|
+
continue
|
|
137
|
+
text = str(value).strip()
|
|
138
|
+
if not text:
|
|
139
|
+
continue
|
|
140
|
+
if env_name in {"SOLANA_RPC_URL", "SOLANA_RPC_URLS"} and rpc_env_locked:
|
|
141
|
+
continue
|
|
142
|
+
if not allow_override and os.getenv(env_name, "").strip():
|
|
143
|
+
continue
|
|
144
|
+
os.environ[env_name] = text
|
|
145
|
+
from agent_wallet.config import reload_settings
|
|
146
|
+
|
|
147
|
+
reload_settings()
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _load_json(raw: str | None, default: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
151
|
+
if not raw:
|
|
152
|
+
return {} if default is None else dict(default)
|
|
153
|
+
parsed = json.loads(raw)
|
|
154
|
+
if not isinstance(parsed, dict):
|
|
155
|
+
raise ValueError("Expected a JSON object.")
|
|
156
|
+
return parsed
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _read_stdin_secret(field_name: str) -> str:
|
|
160
|
+
value = sys.stdin.read().strip()
|
|
161
|
+
if not value:
|
|
162
|
+
raise WalletBackendError(f"{field_name} is required on stdin.")
|
|
163
|
+
return value
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
async def _run_onboard(user_id: str, config: dict[str, Any]) -> dict[str, Any]:
|
|
167
|
+
from agent_wallet.openclaw_runtime import onboard_openclaw_user_wallet
|
|
168
|
+
|
|
169
|
+
context = _build_runtime_context(user_id, config)
|
|
170
|
+
return context.serializable_bundle()
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def _build_runtime_context(
|
|
174
|
+
user_id: str,
|
|
175
|
+
config: dict[str, Any],
|
|
176
|
+
*,
|
|
177
|
+
read_only: bool = False,
|
|
178
|
+
) -> Any:
|
|
179
|
+
from agent_wallet.openclaw_runtime import onboard_openclaw_user_wallet
|
|
180
|
+
|
|
181
|
+
return onboard_openclaw_user_wallet(
|
|
182
|
+
user_id,
|
|
183
|
+
backend=config.get("backend"),
|
|
184
|
+
sign_only=config.get("signOnly"),
|
|
185
|
+
read_only=read_only,
|
|
186
|
+
network=config.get("network"),
|
|
187
|
+
rpc_url=config.get("rpcUrl"),
|
|
188
|
+
wdk_evm_service_url=config.get("wdkEvmServiceUrl"),
|
|
189
|
+
wdk_evm_wallet_id=config.get("wdkEvmWalletId"),
|
|
190
|
+
wdk_evm_account_index=config.get("wdkEvmAccountIndex"),
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
async def _run_invoke(
|
|
195
|
+
user_id: str,
|
|
196
|
+
tool_name: str,
|
|
197
|
+
arguments: dict[str, Any],
|
|
198
|
+
config: dict[str, Any],
|
|
199
|
+
*,
|
|
200
|
+
approval_summary: dict[str, Any] | None = None,
|
|
201
|
+
approval_mainnet_confirmed: bool = False,
|
|
202
|
+
approval_ttl_seconds: int | None = None,
|
|
203
|
+
) -> dict[str, Any]:
|
|
204
|
+
context = _build_runtime_context(user_id, config)
|
|
205
|
+
# Mint the approval token in-process when the host passed the confirmation
|
|
206
|
+
# summary along with the execute call: this replaces a second cold
|
|
207
|
+
# `issue-approval` subprocess (full interpreter boot + onboarding) with a
|
|
208
|
+
# local HMAC signature. A caller-provided token always wins.
|
|
209
|
+
if (
|
|
210
|
+
isinstance(approval_summary, dict)
|
|
211
|
+
and not str(arguments.get("approval_token") or "").strip()
|
|
212
|
+
):
|
|
213
|
+
arguments = dict(arguments)
|
|
214
|
+
arguments["approval_token"] = context.issue_execute_approval(
|
|
215
|
+
tool_name=tool_name,
|
|
216
|
+
confirmation_summary=approval_summary,
|
|
217
|
+
mainnet_confirmed=approval_mainnet_confirmed,
|
|
218
|
+
ttl_seconds=approval_ttl_seconds,
|
|
219
|
+
)
|
|
220
|
+
result = await context.adapter.invoke(tool_name, arguments)
|
|
221
|
+
return result.model_dump()
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
async def _run_issue_approval(
|
|
225
|
+
user_id: str,
|
|
226
|
+
tool_name: str,
|
|
227
|
+
summary: dict[str, Any],
|
|
228
|
+
config: dict[str, Any],
|
|
229
|
+
*,
|
|
230
|
+
mainnet_confirmed: bool = False,
|
|
231
|
+
ttl_seconds: int | None = None,
|
|
232
|
+
) -> dict[str, Any]:
|
|
233
|
+
context = _build_runtime_context(user_id, config)
|
|
234
|
+
token = context.issue_execute_approval(
|
|
235
|
+
tool_name=tool_name,
|
|
236
|
+
confirmation_summary=summary,
|
|
237
|
+
mainnet_confirmed=mainnet_confirmed,
|
|
238
|
+
ttl_seconds=ttl_seconds,
|
|
239
|
+
)
|
|
240
|
+
return {
|
|
241
|
+
"ok": True,
|
|
242
|
+
"tool": tool_name,
|
|
243
|
+
"network": str(getattr(context.backend, "network", "unknown")),
|
|
244
|
+
"approval_token": token,
|
|
245
|
+
"confirmation_summary": summary,
|
|
246
|
+
"mainnet_confirmed": bool(mainnet_confirmed),
|
|
247
|
+
"ttl_seconds": ttl_seconds,
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def _run_autonomous_permission(action: str, scope: str) -> dict[str, Any]:
|
|
252
|
+
from agent_wallet import autonomous_permissions
|
|
253
|
+
|
|
254
|
+
normalized_scope = str(scope or "").strip()
|
|
255
|
+
if normalized_scope not in autonomous_permissions.SUPPORTED_SCOPES:
|
|
256
|
+
raise WalletBackendError("scope must be one of: base_swaps, defi_tools.")
|
|
257
|
+
|
|
258
|
+
normalized_action = str(action or "").strip().lower()
|
|
259
|
+
if normalized_action == "approve":
|
|
260
|
+
data = autonomous_permissions.approve_all(approved_by="openclaw_cli")
|
|
261
|
+
return {
|
|
262
|
+
"ok": True,
|
|
263
|
+
"action": normalized_action,
|
|
264
|
+
"data": data,
|
|
265
|
+
}
|
|
266
|
+
if normalized_action == "revoke":
|
|
267
|
+
return {
|
|
268
|
+
"ok": True,
|
|
269
|
+
"action": normalized_action,
|
|
270
|
+
"data": autonomous_permissions.revoke_all(),
|
|
271
|
+
}
|
|
272
|
+
if normalized_action == "status":
|
|
273
|
+
return {
|
|
274
|
+
"ok": True,
|
|
275
|
+
"action": normalized_action,
|
|
276
|
+
"data": autonomous_permissions.status(),
|
|
277
|
+
}
|
|
278
|
+
raise WalletBackendError("action must be approve, revoke, or status.")
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def _error_payload_for_exception(exc: Exception) -> dict[str, Any]:
|
|
282
|
+
payload: dict[str, Any] = {"ok": False, "error": str(exc)}
|
|
283
|
+
if isinstance(exc, WalletBackendError):
|
|
284
|
+
if exc.code:
|
|
285
|
+
payload["code"] = exc.code
|
|
286
|
+
if exc.details is not None:
|
|
287
|
+
payload["details"] = exc.details
|
|
288
|
+
return payload
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
async def _run_read_worker_tool(
|
|
292
|
+
context: Any,
|
|
293
|
+
request: dict[str, Any],
|
|
294
|
+
allowed_tools: frozenset[str] | None = None,
|
|
295
|
+
) -> dict[str, Any]:
|
|
296
|
+
tool_name = str(request.get("tool") or "").strip()
|
|
297
|
+
effective_allowed = allowed_tools if allowed_tools is not None else READ_ONLY_WORKER_TOOLS
|
|
298
|
+
if tool_name not in effective_allowed:
|
|
299
|
+
raise WalletBackendError(
|
|
300
|
+
f"read-worker only allows read-only tools for this backend; '{tool_name}' is not one."
|
|
301
|
+
)
|
|
302
|
+
arguments = request.get("arguments") or {}
|
|
303
|
+
if not isinstance(arguments, dict):
|
|
304
|
+
raise WalletBackendError("read-worker request arguments must be a JSON object.")
|
|
305
|
+
result = await context.adapter.invoke(tool_name, arguments)
|
|
306
|
+
return result.model_dump()
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
async def _serve_read_worker(user_id: str, config: dict[str, Any]) -> int:
|
|
310
|
+
context = _build_runtime_context(user_id, config, read_only=True)
|
|
311
|
+
allowed_tools = _read_only_tool_names(context)
|
|
312
|
+
while True:
|
|
313
|
+
line = sys.stdin.readline()
|
|
314
|
+
if not line:
|
|
315
|
+
break
|
|
316
|
+
text = line.strip()
|
|
317
|
+
if not text:
|
|
318
|
+
continue
|
|
319
|
+
request_id: str | None = None
|
|
320
|
+
try:
|
|
321
|
+
request = _load_json(text)
|
|
322
|
+
request_id = str(request.get("id") or "").strip() or None
|
|
323
|
+
if request.get("op") == "shutdown":
|
|
324
|
+
print(json.dumps({"id": request_id, "ok": True, "stopped": True}), flush=True)
|
|
325
|
+
break
|
|
326
|
+
payload = await _run_read_worker_tool(context, request, allowed_tools)
|
|
327
|
+
print(
|
|
328
|
+
json.dumps(
|
|
329
|
+
{
|
|
330
|
+
"id": request_id,
|
|
331
|
+
"ok": True,
|
|
332
|
+
"payload": payload,
|
|
333
|
+
}
|
|
334
|
+
),
|
|
335
|
+
flush=True,
|
|
336
|
+
)
|
|
337
|
+
except Exception as exc:
|
|
338
|
+
print(
|
|
339
|
+
json.dumps(
|
|
340
|
+
{
|
|
341
|
+
"id": request_id,
|
|
342
|
+
**_error_payload_for_exception(exc),
|
|
343
|
+
}
|
|
344
|
+
),
|
|
345
|
+
flush=True,
|
|
346
|
+
)
|
|
347
|
+
return 0
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
async def _run_evm_wallet_get(user_id: str, config: dict[str, Any]) -> dict[str, Any]:
|
|
351
|
+
from agent_wallet.evm_user_wallets import resolve_user_evm_wallet_binding
|
|
352
|
+
|
|
353
|
+
return {
|
|
354
|
+
"ok": True,
|
|
355
|
+
"wallet": resolve_user_evm_wallet_binding(
|
|
356
|
+
user_id,
|
|
357
|
+
network=config.get("network"),
|
|
358
|
+
service_url=config.get("wdkEvmServiceUrl"),
|
|
359
|
+
wallet_id=config.get("wdkEvmWalletId"),
|
|
360
|
+
account_index=config.get("wdkEvmAccountIndex"),
|
|
361
|
+
),
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
async def _run_evm_wallet_create(
|
|
366
|
+
user_id: str,
|
|
367
|
+
config: dict[str, Any],
|
|
368
|
+
*,
|
|
369
|
+
label: str | None,
|
|
370
|
+
reveal_seed: bool,
|
|
371
|
+
password: str,
|
|
372
|
+
) -> dict[str, Any]:
|
|
373
|
+
from agent_wallet.evm_user_wallets import create_user_evm_wallet
|
|
374
|
+
|
|
375
|
+
return {
|
|
376
|
+
"ok": True,
|
|
377
|
+
"wallet": create_user_evm_wallet(
|
|
378
|
+
user_id,
|
|
379
|
+
password=password,
|
|
380
|
+
label=label,
|
|
381
|
+
network=config.get("network"),
|
|
382
|
+
service_url=config.get("wdkEvmServiceUrl"),
|
|
383
|
+
reveal_seed_phrase=reveal_seed,
|
|
384
|
+
account_index=config.get("wdkEvmAccountIndex"),
|
|
385
|
+
),
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
async def _run_evm_wallet_import(
|
|
390
|
+
user_id: str,
|
|
391
|
+
config: dict[str, Any],
|
|
392
|
+
*,
|
|
393
|
+
label: str | None,
|
|
394
|
+
password: str,
|
|
395
|
+
seed_phrase: str,
|
|
396
|
+
) -> dict[str, Any]:
|
|
397
|
+
from agent_wallet.evm_user_wallets import import_user_evm_wallet
|
|
398
|
+
|
|
399
|
+
return {
|
|
400
|
+
"ok": True,
|
|
401
|
+
"wallet": import_user_evm_wallet(
|
|
402
|
+
user_id,
|
|
403
|
+
password=password,
|
|
404
|
+
seed_phrase=seed_phrase,
|
|
405
|
+
label=label,
|
|
406
|
+
network=config.get("network"),
|
|
407
|
+
service_url=config.get("wdkEvmServiceUrl"),
|
|
408
|
+
account_index=config.get("wdkEvmAccountIndex"),
|
|
409
|
+
),
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
async def _run_evm_wallet_unlock(
|
|
414
|
+
user_id: str,
|
|
415
|
+
config: dict[str, Any],
|
|
416
|
+
*,
|
|
417
|
+
password: str,
|
|
418
|
+
) -> dict[str, Any]:
|
|
419
|
+
from agent_wallet.evm_user_wallets import unlock_user_evm_wallet
|
|
420
|
+
|
|
421
|
+
return {
|
|
422
|
+
"ok": True,
|
|
423
|
+
"wallet": unlock_user_evm_wallet(
|
|
424
|
+
user_id,
|
|
425
|
+
password=password,
|
|
426
|
+
network=config.get("network"),
|
|
427
|
+
service_url=config.get("wdkEvmServiceUrl"),
|
|
428
|
+
wallet_id=config.get("wdkEvmWalletId"),
|
|
429
|
+
account_index=config.get("wdkEvmAccountIndex"),
|
|
430
|
+
),
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
async def _run_evm_wallet_lock(user_id: str, config: dict[str, Any]) -> dict[str, Any]:
|
|
435
|
+
from agent_wallet.evm_user_wallets import lock_user_evm_wallet
|
|
436
|
+
|
|
437
|
+
return {
|
|
438
|
+
"ok": True,
|
|
439
|
+
"wallet": lock_user_evm_wallet(
|
|
440
|
+
user_id,
|
|
441
|
+
network=config.get("network"),
|
|
442
|
+
service_url=config.get("wdkEvmServiceUrl"),
|
|
443
|
+
wallet_id=config.get("wdkEvmWalletId"),
|
|
444
|
+
account_index=config.get("wdkEvmAccountIndex"),
|
|
445
|
+
),
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def main() -> int:
|
|
450
|
+
parser = argparse.ArgumentParser(description="OpenClaw wallet bridge CLI")
|
|
451
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
452
|
+
|
|
453
|
+
onboard_parser = subparsers.add_parser("onboard")
|
|
454
|
+
onboard_parser.add_argument("--user-id", required=True)
|
|
455
|
+
onboard_parser.add_argument("--config-json", default="{}")
|
|
456
|
+
|
|
457
|
+
invoke_parser = subparsers.add_parser("invoke")
|
|
458
|
+
invoke_parser.add_argument("--user-id", required=True)
|
|
459
|
+
invoke_parser.add_argument("--tool", required=True)
|
|
460
|
+
invoke_parser.add_argument("--arguments-json", default="{}")
|
|
461
|
+
invoke_parser.add_argument("--config-json", default="{}")
|
|
462
|
+
invoke_parser.add_argument(
|
|
463
|
+
"--approval-summary-json",
|
|
464
|
+
help=(
|
|
465
|
+
"Confirmation summary for execute calls; when provided, the approval "
|
|
466
|
+
"token is minted in this process instead of a separate issue-approval run."
|
|
467
|
+
),
|
|
468
|
+
)
|
|
469
|
+
invoke_parser.add_argument("--approval-mainnet-confirmed", action="store_true")
|
|
470
|
+
invoke_parser.add_argument("--approval-ttl-seconds", type=int)
|
|
471
|
+
|
|
472
|
+
approval_parser = subparsers.add_parser("issue-approval")
|
|
473
|
+
approval_parser.add_argument("--user-id", required=True)
|
|
474
|
+
approval_parser.add_argument("--tool", required=True)
|
|
475
|
+
approval_parser.add_argument("--summary-json", required=True)
|
|
476
|
+
approval_parser.add_argument("--mainnet-confirmed", action="store_true")
|
|
477
|
+
approval_parser.add_argument("--ttl-seconds", type=int)
|
|
478
|
+
approval_parser.add_argument("--config-json", default="{}")
|
|
479
|
+
|
|
480
|
+
autonomous_permission_parser = subparsers.add_parser("autonomous-permission")
|
|
481
|
+
autonomous_permission_parser.add_argument("--action", choices=["approve", "revoke", "status"], required=True)
|
|
482
|
+
autonomous_permission_parser.add_argument("--scope", choices=["base_swaps", "defi_tools"], required=True)
|
|
483
|
+
autonomous_permission_parser.add_argument("--config-json", default="{}")
|
|
484
|
+
|
|
485
|
+
evm_get_parser = subparsers.add_parser("evm-wallet-get")
|
|
486
|
+
evm_get_parser.add_argument("--user-id", required=True)
|
|
487
|
+
evm_get_parser.add_argument("--config-json", default="{}")
|
|
488
|
+
|
|
489
|
+
evm_create_parser = subparsers.add_parser("evm-wallet-create")
|
|
490
|
+
evm_create_parser.add_argument("--user-id", required=True)
|
|
491
|
+
evm_create_parser.add_argument("--label")
|
|
492
|
+
evm_create_parser.add_argument("--reveal-seed", action="store_true")
|
|
493
|
+
evm_create_parser.add_argument("--password-stdin", action="store_true")
|
|
494
|
+
evm_create_parser.add_argument("--config-json", default="{}")
|
|
495
|
+
|
|
496
|
+
evm_import_parser = subparsers.add_parser("evm-wallet-import")
|
|
497
|
+
evm_import_parser.add_argument("--user-id", required=True)
|
|
498
|
+
evm_import_parser.add_argument("--label")
|
|
499
|
+
evm_import_parser.add_argument("--password-stdin", action="store_true")
|
|
500
|
+
evm_import_parser.add_argument("--seed-stdin", action="store_true")
|
|
501
|
+
evm_import_parser.add_argument("--config-json", default="{}")
|
|
502
|
+
|
|
503
|
+
evm_unlock_parser = subparsers.add_parser("evm-wallet-unlock")
|
|
504
|
+
evm_unlock_parser.add_argument("--user-id", required=True)
|
|
505
|
+
evm_unlock_parser.add_argument("--password-stdin", action="store_true")
|
|
506
|
+
evm_unlock_parser.add_argument("--config-json", default="{}")
|
|
507
|
+
|
|
508
|
+
evm_lock_parser = subparsers.add_parser("evm-wallet-lock")
|
|
509
|
+
evm_lock_parser.add_argument("--user-id", required=True)
|
|
510
|
+
evm_lock_parser.add_argument("--config-json", default="{}")
|
|
511
|
+
|
|
512
|
+
read_worker_parser = subparsers.add_parser("read-worker")
|
|
513
|
+
read_worker_parser.add_argument("--user-id", required=True)
|
|
514
|
+
read_worker_parser.add_argument("--config-json", default="{}")
|
|
515
|
+
|
|
516
|
+
subparsers.add_parser("boot-key-export")
|
|
517
|
+
|
|
518
|
+
boot_key_import_parser = subparsers.add_parser("boot-key-import")
|
|
519
|
+
boot_key_import_parser.add_argument(
|
|
520
|
+
"--key-stdin",
|
|
521
|
+
action="store_true",
|
|
522
|
+
help="Read the boot key to import from stdin.",
|
|
523
|
+
)
|
|
524
|
+
|
|
525
|
+
args = parser.parse_args()
|
|
526
|
+
|
|
527
|
+
try:
|
|
528
|
+
config = _load_json(getattr(args, "config_json", "{}"))
|
|
529
|
+
_apply_config_overrides(config)
|
|
530
|
+
|
|
531
|
+
if args.command == "onboard":
|
|
532
|
+
payload = asyncio.run(_run_onboard(args.user_id, config))
|
|
533
|
+
elif args.command == "issue-approval":
|
|
534
|
+
payload = asyncio.run(
|
|
535
|
+
_run_issue_approval(
|
|
536
|
+
args.user_id,
|
|
537
|
+
args.tool,
|
|
538
|
+
_load_json(args.summary_json),
|
|
539
|
+
config,
|
|
540
|
+
mainnet_confirmed=bool(args.mainnet_confirmed),
|
|
541
|
+
ttl_seconds=args.ttl_seconds,
|
|
542
|
+
)
|
|
543
|
+
)
|
|
544
|
+
elif args.command == "autonomous-permission":
|
|
545
|
+
payload = _run_autonomous_permission(args.action, args.scope)
|
|
546
|
+
elif args.command == "evm-wallet-get":
|
|
547
|
+
payload = asyncio.run(_run_evm_wallet_get(args.user_id, config))
|
|
548
|
+
elif args.command == "evm-wallet-create":
|
|
549
|
+
if not args.password_stdin:
|
|
550
|
+
raise WalletBackendError("evm-wallet-create requires --password-stdin.")
|
|
551
|
+
payload = asyncio.run(
|
|
552
|
+
_run_evm_wallet_create(
|
|
553
|
+
args.user_id,
|
|
554
|
+
config,
|
|
555
|
+
label=args.label,
|
|
556
|
+
reveal_seed=bool(args.reveal_seed),
|
|
557
|
+
password=_read_stdin_secret("password"),
|
|
558
|
+
)
|
|
559
|
+
)
|
|
560
|
+
elif args.command == "evm-wallet-import":
|
|
561
|
+
if not args.password_stdin:
|
|
562
|
+
raise WalletBackendError("evm-wallet-import requires --password-stdin.")
|
|
563
|
+
if not args.seed_stdin:
|
|
564
|
+
raise WalletBackendError("evm-wallet-import requires --seed-stdin.")
|
|
565
|
+
raw = _read_stdin_secret("password and seed phrase payload")
|
|
566
|
+
lines = raw.splitlines()
|
|
567
|
+
if len(lines) < 2:
|
|
568
|
+
raise WalletBackendError(
|
|
569
|
+
"evm-wallet-import stdin must contain password on the first line and seed phrase on the remaining lines."
|
|
570
|
+
)
|
|
571
|
+
password = lines[0].strip()
|
|
572
|
+
seed_phrase = " ".join(line.strip() for line in lines[1:] if line.strip())
|
|
573
|
+
if not password or not seed_phrase:
|
|
574
|
+
raise WalletBackendError("evm-wallet-import requires both password and seed phrase on stdin.")
|
|
575
|
+
payload = asyncio.run(
|
|
576
|
+
_run_evm_wallet_import(
|
|
577
|
+
args.user_id,
|
|
578
|
+
config,
|
|
579
|
+
label=args.label,
|
|
580
|
+
password=password,
|
|
581
|
+
seed_phrase=seed_phrase,
|
|
582
|
+
)
|
|
583
|
+
)
|
|
584
|
+
elif args.command == "evm-wallet-unlock":
|
|
585
|
+
if not args.password_stdin:
|
|
586
|
+
raise WalletBackendError("evm-wallet-unlock requires --password-stdin.")
|
|
587
|
+
payload = asyncio.run(
|
|
588
|
+
_run_evm_wallet_unlock(
|
|
589
|
+
args.user_id,
|
|
590
|
+
config,
|
|
591
|
+
password=_read_stdin_secret("password"),
|
|
592
|
+
)
|
|
593
|
+
)
|
|
594
|
+
elif args.command == "evm-wallet-lock":
|
|
595
|
+
payload = asyncio.run(_run_evm_wallet_lock(args.user_id, config))
|
|
596
|
+
elif args.command == "read-worker":
|
|
597
|
+
return asyncio.run(_serve_read_worker(args.user_id, config))
|
|
598
|
+
elif args.command == "boot-key-export":
|
|
599
|
+
from agent_wallet.boot_key_recovery import export_boot_key, export_warning
|
|
600
|
+
|
|
601
|
+
print(export_warning(), file=sys.stderr)
|
|
602
|
+
payload = {"boot_key": export_boot_key()}
|
|
603
|
+
elif args.command == "boot-key-import":
|
|
604
|
+
if not args.key_stdin:
|
|
605
|
+
raise WalletBackendError("boot-key-import requires --key-stdin.")
|
|
606
|
+
from agent_wallet.boot_key_recovery import import_boot_key
|
|
607
|
+
|
|
608
|
+
payload = import_boot_key(_read_stdin_secret("boot key"))
|
|
609
|
+
else:
|
|
610
|
+
approval_summary = None
|
|
611
|
+
raw_summary = getattr(args, "approval_summary_json", None)
|
|
612
|
+
if raw_summary:
|
|
613
|
+
approval_summary = _load_json(raw_summary)
|
|
614
|
+
payload = asyncio.run(
|
|
615
|
+
_run_invoke(
|
|
616
|
+
args.user_id,
|
|
617
|
+
args.tool,
|
|
618
|
+
_load_json(args.arguments_json),
|
|
619
|
+
config,
|
|
620
|
+
approval_summary=approval_summary,
|
|
621
|
+
approval_mainnet_confirmed=bool(
|
|
622
|
+
getattr(args, "approval_mainnet_confirmed", False)
|
|
623
|
+
),
|
|
624
|
+
approval_ttl_seconds=getattr(args, "approval_ttl_seconds", None),
|
|
625
|
+
)
|
|
626
|
+
)
|
|
627
|
+
except Exception as exc:
|
|
628
|
+
# Anonymous adoption telemetry for tool invocations only (never for
|
|
629
|
+
# onboard/wallet-create/unlock/import — those touch secrets). Records
|
|
630
|
+
# just the tool name + backend family + failure flag; never raises.
|
|
631
|
+
if getattr(args, "command", "") == "invoke":
|
|
632
|
+
_telemetry_record_cli_invoke(
|
|
633
|
+
getattr(args, "tool", ""),
|
|
634
|
+
getattr(args, "arguments_json", None),
|
|
635
|
+
backend=str(locals().get("config", {}).get("backend", "") or ""),
|
|
636
|
+
payload=_error_payload_for_exception(exc),
|
|
637
|
+
)
|
|
638
|
+
print(json.dumps(_error_payload_for_exception(exc)), file=sys.stderr)
|
|
639
|
+
return 1
|
|
640
|
+
|
|
641
|
+
if getattr(args, "command", "") == "invoke":
|
|
642
|
+
# Adapter-level failures are returned as a normal JSON result, so the
|
|
643
|
+
# CLI process still exits successfully. Telemetry must reflect the tool
|
|
644
|
+
# result rather than the subprocess exit status.
|
|
645
|
+
_telemetry_record_cli_invoke(
|
|
646
|
+
getattr(args, "tool", ""),
|
|
647
|
+
getattr(args, "arguments_json", None),
|
|
648
|
+
backend=str(config.get("backend", "") or ""),
|
|
649
|
+
payload=payload,
|
|
650
|
+
)
|
|
651
|
+
_telemetry_record_x402_lifecycle(getattr(args, "tool", ""), payload)
|
|
652
|
+
|
|
653
|
+
print(json.dumps(payload))
|
|
654
|
+
return 0
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
if __name__ == "__main__":
|
|
658
|
+
raise SystemExit(main())
|