@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,421 @@
|
|
|
1
|
+
"""Patch an OpenClaw config file for the OneCraft OpenClaw plugins."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import secrets
|
|
9
|
+
import sys
|
|
10
|
+
from datetime import datetime, timezone
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
14
|
+
|
|
15
|
+
from agent_wallet.file_ops import atomic_write_text, chmod_if_exists
|
|
16
|
+
from agent_wallet.config import (
|
|
17
|
+
is_legacy_evm_service_url,
|
|
18
|
+
normalize_evm_network,
|
|
19
|
+
normalize_solana_network,
|
|
20
|
+
resolve_boot_key,
|
|
21
|
+
)
|
|
22
|
+
from agent_wallet.sealed_keys import resolve_sealed_keys_path, seal_keys, unseal_keys
|
|
23
|
+
from security_utils import write_redacted_backup
|
|
24
|
+
|
|
25
|
+
LEGACY_ALLOWLIST_TOOLS = [
|
|
26
|
+
"get_wallet_capabilities",
|
|
27
|
+
"get_wallet_address",
|
|
28
|
+
"get_wallet_balance",
|
|
29
|
+
"get_active_wallet_backend",
|
|
30
|
+
"set_wallet_backend",
|
|
31
|
+
"get_wallet_portfolio",
|
|
32
|
+
"get_solana_token_prices",
|
|
33
|
+
"get_kamino_portfolio",
|
|
34
|
+
"get_kamino_vaults",
|
|
35
|
+
"get_kamino_earn_positions",
|
|
36
|
+
"get_kamino_liquidity_positions",
|
|
37
|
+
"get_kamino_lend_markets",
|
|
38
|
+
"get_kamino_lend_market_reserves",
|
|
39
|
+
"get_kamino_lend_user_obligations",
|
|
40
|
+
"get_kamino_lend_user_rewards",
|
|
41
|
+
"kamino_lend_deposit",
|
|
42
|
+
"kamino_lend_withdraw",
|
|
43
|
+
"kamino_lend_borrow",
|
|
44
|
+
"kamino_lend_repay",
|
|
45
|
+
"kamino_earn_deposit",
|
|
46
|
+
"kamino_earn_withdraw",
|
|
47
|
+
"sign_wallet_message",
|
|
48
|
+
"transfer_sol",
|
|
49
|
+
"transfer_spl_token",
|
|
50
|
+
"swap_solana_tokens",
|
|
51
|
+
"close_empty_token_accounts",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
X402_TOOLS = [
|
|
55
|
+
"x402_search_services",
|
|
56
|
+
"x402_get_service_details",
|
|
57
|
+
"x402_preview_request",
|
|
58
|
+
"x402_pay_request",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _extract_tool_allowlist_from_manifest(manifest_path: Path) -> list[str]:
|
|
63
|
+
try:
|
|
64
|
+
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
65
|
+
except (FileNotFoundError, json.JSONDecodeError):
|
|
66
|
+
return []
|
|
67
|
+
|
|
68
|
+
tools = manifest.get("contracts", {}).get("tools", [])
|
|
69
|
+
if not isinstance(tools, list):
|
|
70
|
+
return []
|
|
71
|
+
|
|
72
|
+
allowlist: list[str] = []
|
|
73
|
+
for item in tools:
|
|
74
|
+
tool_name = str(item).strip()
|
|
75
|
+
if tool_name and tool_name not in allowlist:
|
|
76
|
+
allowlist.append(tool_name)
|
|
77
|
+
return allowlist
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _load_extension_tool_allowlist(extension_path: Path) -> list[str]:
|
|
81
|
+
manifest_candidates = [
|
|
82
|
+
extension_path / "openclaw.plugin.json",
|
|
83
|
+
_repo_root() / ".openclaw" / "extensions" / "agent-wallet" / "openclaw.plugin.json",
|
|
84
|
+
]
|
|
85
|
+
for manifest_path in manifest_candidates:
|
|
86
|
+
allowlist = _extract_tool_allowlist_from_manifest(manifest_path)
|
|
87
|
+
if allowlist:
|
|
88
|
+
return allowlist
|
|
89
|
+
return LEGACY_ALLOWLIST_TOOLS + X402_TOOLS
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _is_agent_wallet_extension_path(value: object) -> bool:
|
|
93
|
+
return "extensions/agent-wallet" in str(value).replace("\\", "/")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _normalize_load_paths(paths: list[object], extension_path_text: str) -> list[str]:
|
|
97
|
+
normalized: list[str] = []
|
|
98
|
+
seen: set[str] = set()
|
|
99
|
+
|
|
100
|
+
for item in paths:
|
|
101
|
+
item_text = str(item).strip()
|
|
102
|
+
if not item_text:
|
|
103
|
+
continue
|
|
104
|
+
if "extensions/pay-bridge" in item_text:
|
|
105
|
+
continue
|
|
106
|
+
if _is_agent_wallet_extension_path(item_text) and item_text != extension_path_text:
|
|
107
|
+
continue
|
|
108
|
+
if item_text in seen:
|
|
109
|
+
continue
|
|
110
|
+
normalized.append(item_text)
|
|
111
|
+
seen.add(item_text)
|
|
112
|
+
|
|
113
|
+
if extension_path_text not in seen:
|
|
114
|
+
normalized.append(extension_path_text)
|
|
115
|
+
return normalized
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _default_config_path() -> Path:
|
|
119
|
+
return Path(os.path.expanduser("~/.openclaw/openclaw.json"))
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _resolve_openclaw_home() -> Path:
|
|
123
|
+
return Path(os.path.expanduser(os.getenv("OPENCLAW_HOME", "~/.openclaw")))
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _default_runtime_root() -> Path:
|
|
127
|
+
explicit_target = os.getenv("OPENCLAW_INSTALL_TARGET", "").strip()
|
|
128
|
+
if explicit_target:
|
|
129
|
+
return Path(explicit_target).expanduser()
|
|
130
|
+
explicit_root = os.getenv("OPENCLAW_INSTALL_ROOT", "").strip()
|
|
131
|
+
if explicit_root:
|
|
132
|
+
return Path(explicit_root).expanduser() / "current"
|
|
133
|
+
return _resolve_openclaw_home() / "agent-wallet-runtime" / "current"
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _canonical_runtime_path(path_value: str) -> Path:
|
|
137
|
+
"""Keep host config pinned to runtime/current instead of releases/<version>.
|
|
138
|
+
|
|
139
|
+
The updater flips ``agent-wallet-runtime/current`` on every release. Host
|
|
140
|
+
configs that store resolved release paths silently pin themselves to stale
|
|
141
|
+
code after the next update, so rewrite any release-local path back through
|
|
142
|
+
``current`` while preserving its relative suffix.
|
|
143
|
+
"""
|
|
144
|
+
candidate = Path(path_value).expanduser().resolve()
|
|
145
|
+
releases_root = (_resolve_openclaw_home() / "agent-wallet-runtime" / "releases").resolve()
|
|
146
|
+
try:
|
|
147
|
+
relative = candidate.relative_to(releases_root)
|
|
148
|
+
except ValueError:
|
|
149
|
+
return candidate
|
|
150
|
+
parts = relative.parts
|
|
151
|
+
if len(parts) < 2:
|
|
152
|
+
return candidate
|
|
153
|
+
return _default_runtime_root() / Path(*parts[1:])
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _repo_root() -> Path:
|
|
157
|
+
return Path(__file__).resolve().parents[2]
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _trusted_runtime_root() -> Path | None:
|
|
161
|
+
runtime_root = _default_runtime_root().resolve()
|
|
162
|
+
plugin_manifest = runtime_root / ".openclaw" / "extensions" / "agent-wallet" / "openclaw.plugin.json"
|
|
163
|
+
package_root = runtime_root / "agent-wallet"
|
|
164
|
+
if plugin_manifest.exists() and package_root.exists():
|
|
165
|
+
return runtime_root
|
|
166
|
+
return None
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _default_extension_path() -> Path:
|
|
170
|
+
runtime_root = _trusted_runtime_root()
|
|
171
|
+
if runtime_root is not None:
|
|
172
|
+
return runtime_root / ".openclaw" / "extensions" / "agent-wallet"
|
|
173
|
+
return _repo_root() / ".openclaw" / "extensions" / "agent-wallet"
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def _default_package_root() -> Path:
|
|
177
|
+
runtime_root = _trusted_runtime_root()
|
|
178
|
+
if runtime_root is not None:
|
|
179
|
+
return runtime_root / "agent-wallet"
|
|
180
|
+
return Path(__file__).resolve().parents[1]
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def _default_python_bin() -> str:
|
|
184
|
+
explicit = os.getenv("OPENCLAW_AGENT_WALLET_PYTHON", "").strip()
|
|
185
|
+
if explicit:
|
|
186
|
+
return explicit
|
|
187
|
+
runtime_root = _trusted_runtime_root()
|
|
188
|
+
if runtime_root is not None:
|
|
189
|
+
wrapper = runtime_root / "agent-wallet" / ".runtime-venv" / "bin" / "openclaw-agent-wallet-python"
|
|
190
|
+
if wrapper.exists():
|
|
191
|
+
return str(wrapper)
|
|
192
|
+
runtime_python = runtime_root / "agent-wallet" / ".runtime-venv" / "bin" / "python"
|
|
193
|
+
if runtime_python.exists():
|
|
194
|
+
return str(runtime_python)
|
|
195
|
+
return sys.executable
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def _default_user_id() -> str:
|
|
199
|
+
return f"{os.getenv('USER', 'openclaw-user')}-local"
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def _normalize_network(backend: str, network: str) -> str:
|
|
203
|
+
backend_name = backend.strip().lower()
|
|
204
|
+
normalized = network.strip().lower()
|
|
205
|
+
if backend_name in {"wdk_evm_local", "wdk-evm-local", "evm_local", "evm-local"}:
|
|
206
|
+
return normalize_evm_network(normalized or "ethereum")
|
|
207
|
+
return normalize_solana_network(normalized or "mainnet")
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
211
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
212
|
+
parser.add_argument("--config-path", default=str(_default_config_path()))
|
|
213
|
+
parser.add_argument("--plugin-id", default="agent-wallet")
|
|
214
|
+
parser.add_argument("--user-id", default="")
|
|
215
|
+
parser.add_argument("--backend", default="solana_local")
|
|
216
|
+
parser.add_argument("--network", default="mainnet")
|
|
217
|
+
parser.add_argument("--rpc-url", default="")
|
|
218
|
+
parser.add_argument("--rpc-urls", default="")
|
|
219
|
+
parser.add_argument("--wdk-evm-service-url", default="")
|
|
220
|
+
parser.add_argument("--wdk-evm-wallet-id", default="")
|
|
221
|
+
parser.add_argument("--wdk-evm-account-index", type=int, default=0)
|
|
222
|
+
parser.add_argument("--sign-only", action=argparse.BooleanOptionalAction, default=False)
|
|
223
|
+
parser.add_argument("--encrypt-user-wallets", action=argparse.BooleanOptionalAction, default=True)
|
|
224
|
+
parser.add_argument(
|
|
225
|
+
"--migrate-plaintext-user-wallets",
|
|
226
|
+
action=argparse.BooleanOptionalAction,
|
|
227
|
+
default=True,
|
|
228
|
+
)
|
|
229
|
+
parser.add_argument("--extension-path", default=str(_default_extension_path()))
|
|
230
|
+
parser.add_argument("--package-root", default=str(_default_package_root()))
|
|
231
|
+
parser.add_argument("--python-bin", default=_default_python_bin())
|
|
232
|
+
parser.add_argument("--write-master-key", action=argparse.BooleanOptionalAction, default=False)
|
|
233
|
+
return parser
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def _collect_sealed_secret_updates() -> dict[str, str]:
|
|
237
|
+
updates: dict[str, str] = {}
|
|
238
|
+
master_key = os.getenv("AGENT_WALLET_MASTER_KEY", "").strip()
|
|
239
|
+
approval_secret = os.getenv("AGENT_WALLET_APPROVAL_SECRET", "").strip()
|
|
240
|
+
private_key = os.getenv("SOLANA_AGENT_PRIVATE_KEY", "").strip()
|
|
241
|
+
evm_wallet_password = os.getenv("WDK_EVM_WALLET_PASSWORD", "").strip()
|
|
242
|
+
if master_key:
|
|
243
|
+
updates["master_key"] = master_key
|
|
244
|
+
if approval_secret:
|
|
245
|
+
updates["approval_secret"] = approval_secret
|
|
246
|
+
if private_key:
|
|
247
|
+
updates["private_key"] = private_key
|
|
248
|
+
if evm_wallet_password:
|
|
249
|
+
updates["wdk_evm_wallet_password"] = evm_wallet_password
|
|
250
|
+
return updates
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def _maybe_install_sealed_keys() -> str | None:
|
|
254
|
+
boot_key = os.getenv("AGENT_WALLET_BOOT_KEY", "").strip()
|
|
255
|
+
if not boot_key:
|
|
256
|
+
return None
|
|
257
|
+
updates = _collect_sealed_secret_updates()
|
|
258
|
+
sealed_path = resolve_sealed_keys_path()
|
|
259
|
+
existing = unseal_keys(boot_key) if sealed_path.exists() else {}
|
|
260
|
+
if "wdk_evm_wallet_password" not in existing and "wdk_evm_wallet_password" not in updates:
|
|
261
|
+
updates["wdk_evm_wallet_password"] = secrets.token_urlsafe(24)
|
|
262
|
+
if not updates:
|
|
263
|
+
return None
|
|
264
|
+
merged = {**existing, **updates}
|
|
265
|
+
if merged == existing:
|
|
266
|
+
return str(sealed_path)
|
|
267
|
+
return str(seal_keys(boot_key, merged))
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def _require_hardened_runtime_secrets(backend: str) -> str | None:
|
|
271
|
+
if backend.strip().lower() in {"", "none"}:
|
|
272
|
+
return None
|
|
273
|
+
|
|
274
|
+
boot_key = resolve_boot_key().strip()
|
|
275
|
+
if not boot_key:
|
|
276
|
+
raise SystemExit(
|
|
277
|
+
"A boot key is required to unlock sealed_keys.json. Resolve it via "
|
|
278
|
+
"AGENT_WALLET_BOOT_KEY, the OS keystore, or AGENT_WALLET_BOOT_KEY_FILE."
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
sealed_path = resolve_sealed_keys_path()
|
|
282
|
+
if not sealed_path.exists():
|
|
283
|
+
raise SystemExit(
|
|
284
|
+
"sealed_keys.json was not created. Provide AGENT_WALLET_MASTER_KEY and "
|
|
285
|
+
"AGENT_WALLET_APPROVAL_SECRET during install so the installer can seal them."
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
secrets = unseal_keys(boot_key)
|
|
289
|
+
missing = [name for name in ("master_key", "approval_secret") if not str(secrets.get(name) or "").strip()]
|
|
290
|
+
if missing:
|
|
291
|
+
raise SystemExit(
|
|
292
|
+
"sealed_keys.json is missing required runtime secrets: "
|
|
293
|
+
+ ", ".join(missing)
|
|
294
|
+
+ "."
|
|
295
|
+
)
|
|
296
|
+
return str(sealed_path)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def _drop_legacy_evm_service_url(plugin_config: dict) -> None:
|
|
300
|
+
# The runtime already reads this legacy default as unset; removing it on a
|
|
301
|
+
# host (re)install just keeps the stored config honest.
|
|
302
|
+
if is_legacy_evm_service_url(plugin_config.get("wdkEvmServiceUrl")):
|
|
303
|
+
plugin_config.pop("wdkEvmServiceUrl", None)
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def main() -> None:
|
|
307
|
+
args = build_parser().parse_args()
|
|
308
|
+
config_path = Path(args.config_path).expanduser()
|
|
309
|
+
data = json.loads(config_path.read_text(encoding="utf-8"))
|
|
310
|
+
|
|
311
|
+
backup_path = config_path.with_name(
|
|
312
|
+
f"{config_path.name}.bak.agent-wallet.{datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')}"
|
|
313
|
+
)
|
|
314
|
+
write_redacted_backup(backup_path, data)
|
|
315
|
+
|
|
316
|
+
plugins = data.setdefault("plugins", {})
|
|
317
|
+
plugins["enabled"] = True
|
|
318
|
+
allow = plugins.setdefault("allow", [])
|
|
319
|
+
if args.plugin_id not in allow:
|
|
320
|
+
allow.append(args.plugin_id)
|
|
321
|
+
allow[:] = [item for item in allow if item != "pay-bridge"]
|
|
322
|
+
|
|
323
|
+
load = plugins.setdefault("load", {})
|
|
324
|
+
paths = load.setdefault("paths", [])
|
|
325
|
+
extension_path_text = str(_canonical_runtime_path(args.extension_path))
|
|
326
|
+
paths[:] = _normalize_load_paths(list(paths), extension_path_text)
|
|
327
|
+
|
|
328
|
+
entries = plugins.setdefault("entries", {})
|
|
329
|
+
effective_network = _normalize_network(args.backend, args.network)
|
|
330
|
+
existing_entry = entries.get(args.plugin_id) if isinstance(entries.get(args.plugin_id), dict) else {}
|
|
331
|
+
existing_config = (
|
|
332
|
+
dict(existing_entry.get("config"))
|
|
333
|
+
if isinstance(existing_entry.get("config"), dict)
|
|
334
|
+
else {}
|
|
335
|
+
)
|
|
336
|
+
resolved_user_id = (
|
|
337
|
+
args.user_id.strip()
|
|
338
|
+
or str(existing_config.get("userId") or "").strip()
|
|
339
|
+
or _default_user_id()
|
|
340
|
+
)
|
|
341
|
+
python_bin_text = args.python_bin
|
|
342
|
+
python_bin_candidate = Path(python_bin_text).expanduser()
|
|
343
|
+
if python_bin_text.startswith("~") or python_bin_candidate.is_absolute():
|
|
344
|
+
python_bin_text = str(_canonical_runtime_path(python_bin_text))
|
|
345
|
+
|
|
346
|
+
plugin_config = {
|
|
347
|
+
**existing_config,
|
|
348
|
+
"userId": resolved_user_id,
|
|
349
|
+
"backend": args.backend,
|
|
350
|
+
"network": effective_network,
|
|
351
|
+
"signOnly": args.sign_only,
|
|
352
|
+
"encryptUserWallets": args.encrypt_user_wallets,
|
|
353
|
+
"migratePlaintextUserWallets": args.migrate_plaintext_user_wallets,
|
|
354
|
+
"packageRoot": str(_canonical_runtime_path(args.package_root)),
|
|
355
|
+
"pythonBin": python_bin_text,
|
|
356
|
+
}
|
|
357
|
+
if args.rpc_url.strip():
|
|
358
|
+
plugin_config["rpcUrl"] = args.rpc_url.strip()
|
|
359
|
+
if args.rpc_urls.strip():
|
|
360
|
+
plugin_config["rpcUrls"] = [
|
|
361
|
+
item.strip() for item in args.rpc_urls.split(",") if item.strip()
|
|
362
|
+
]
|
|
363
|
+
for key in ("wdkBtcServiceUrl", "wdkBtcWalletId", "wdkBtcAccountIndex"):
|
|
364
|
+
plugin_config.pop(key, None)
|
|
365
|
+
_drop_legacy_evm_service_url(plugin_config)
|
|
366
|
+
if args.wdk_evm_service_url.strip():
|
|
367
|
+
plugin_config["wdkEvmServiceUrl"] = args.wdk_evm_service_url.strip()
|
|
368
|
+
if args.wdk_evm_wallet_id.strip():
|
|
369
|
+
plugin_config["wdkEvmWalletId"] = args.wdk_evm_wallet_id.strip()
|
|
370
|
+
if args.wdk_evm_account_index is not None:
|
|
371
|
+
plugin_config["wdkEvmAccountIndex"] = int(args.wdk_evm_account_index)
|
|
372
|
+
if args.write_master_key:
|
|
373
|
+
raise SystemExit(
|
|
374
|
+
"Refusing to write masterKey into config. Runtime secrets must live in sealed_keys.json."
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
entries[args.plugin_id] = {
|
|
378
|
+
"enabled": True,
|
|
379
|
+
"config": plugin_config,
|
|
380
|
+
}
|
|
381
|
+
entries.pop("pay-bridge", None)
|
|
382
|
+
|
|
383
|
+
tools = data.setdefault("tools", {})
|
|
384
|
+
also_allow = tools.setdefault("alsoAllow", [])
|
|
385
|
+
removed_pay_tools = {
|
|
386
|
+
"pay_status",
|
|
387
|
+
"pay_wallet_info",
|
|
388
|
+
"pay_search_services",
|
|
389
|
+
"pay_get_service_endpoints",
|
|
390
|
+
"pay_api_request",
|
|
391
|
+
}
|
|
392
|
+
also_allow[:] = [tool_name for tool_name in also_allow if tool_name not in removed_pay_tools]
|
|
393
|
+
for tool_name in _load_extension_tool_allowlist(Path(extension_path_text)):
|
|
394
|
+
if tool_name not in also_allow:
|
|
395
|
+
also_allow.append(tool_name)
|
|
396
|
+
|
|
397
|
+
atomic_write_text(config_path, json.dumps(data, indent=2) + "\n", mode=0o600)
|
|
398
|
+
chmod_if_exists(config_path, 0o600)
|
|
399
|
+
_maybe_install_sealed_keys()
|
|
400
|
+
sealed_keys_path = _require_hardened_runtime_secrets(args.backend)
|
|
401
|
+
|
|
402
|
+
print(
|
|
403
|
+
json.dumps(
|
|
404
|
+
{
|
|
405
|
+
"ok": True,
|
|
406
|
+
"config_path": str(config_path),
|
|
407
|
+
"backup_path": str(backup_path),
|
|
408
|
+
"extension_path": extension_path_text,
|
|
409
|
+
"python_bin": python_bin_text,
|
|
410
|
+
"package_root": plugin_config["packageRoot"],
|
|
411
|
+
"plugin_id": args.plugin_id,
|
|
412
|
+
"user_id": resolved_user_id,
|
|
413
|
+
"sealed_keys_path": sealed_keys_path,
|
|
414
|
+
},
|
|
415
|
+
indent=2,
|
|
416
|
+
)
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
if __name__ == "__main__":
|
|
421
|
+
main()
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Create or update the encrypted sealed_keys.json secret bundle."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import secrets as py_secrets
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
13
|
+
|
|
14
|
+
from agent_wallet.sealed_keys import resolve_sealed_keys_path, seal_keys, unseal_keys
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
18
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
19
|
+
parser.add_argument(
|
|
20
|
+
"--replace",
|
|
21
|
+
action=argparse.BooleanOptionalAction,
|
|
22
|
+
default=False,
|
|
23
|
+
help="Replace the sealed bundle instead of merging with existing entries.",
|
|
24
|
+
)
|
|
25
|
+
parser.add_argument(
|
|
26
|
+
"--boot-key",
|
|
27
|
+
default="",
|
|
28
|
+
help="Deprecated insecure path. Use AGENT_WALLET_BOOT_KEY env instead.",
|
|
29
|
+
)
|
|
30
|
+
parser.add_argument(
|
|
31
|
+
"--master-key",
|
|
32
|
+
default="",
|
|
33
|
+
help="Deprecated insecure path. Use AGENT_WALLET_MASTER_KEY env instead.",
|
|
34
|
+
)
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
"--approval-secret",
|
|
37
|
+
default="",
|
|
38
|
+
help="Deprecated insecure path. Use AGENT_WALLET_APPROVAL_SECRET env instead.",
|
|
39
|
+
)
|
|
40
|
+
parser.add_argument(
|
|
41
|
+
"--private-key",
|
|
42
|
+
default="",
|
|
43
|
+
help="Deprecated insecure path. Use SOLANA_AGENT_PRIVATE_KEY env instead.",
|
|
44
|
+
)
|
|
45
|
+
return parser
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _collect_secret_updates() -> dict[str, str]:
|
|
49
|
+
updates: dict[str, str] = {}
|
|
50
|
+
master_key = os.getenv("AGENT_WALLET_MASTER_KEY", "").strip()
|
|
51
|
+
approval_secret = os.getenv("AGENT_WALLET_APPROVAL_SECRET", "").strip()
|
|
52
|
+
private_key = os.getenv("SOLANA_AGENT_PRIVATE_KEY", "").strip()
|
|
53
|
+
evm_wallet_password = os.getenv("WDK_EVM_WALLET_PASSWORD", "").strip()
|
|
54
|
+
if master_key:
|
|
55
|
+
updates["master_key"] = master_key
|
|
56
|
+
if approval_secret:
|
|
57
|
+
updates["approval_secret"] = approval_secret
|
|
58
|
+
if private_key:
|
|
59
|
+
updates["private_key"] = private_key
|
|
60
|
+
if evm_wallet_password:
|
|
61
|
+
updates["wdk_evm_wallet_password"] = evm_wallet_password
|
|
62
|
+
return updates
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def main() -> None:
|
|
66
|
+
args = build_parser().parse_args()
|
|
67
|
+
if (
|
|
68
|
+
args.boot_key.strip()
|
|
69
|
+
or args.master_key.strip()
|
|
70
|
+
or args.approval_secret.strip()
|
|
71
|
+
or args.private_key.strip()
|
|
72
|
+
):
|
|
73
|
+
raise SystemExit(
|
|
74
|
+
"Passing secrets via command-line arguments is insecure. "
|
|
75
|
+
"Use AGENT_WALLET_BOOT_KEY / AGENT_WALLET_MASTER_KEY / "
|
|
76
|
+
"AGENT_WALLET_APPROVAL_SECRET / SOLANA_AGENT_PRIVATE_KEY environment variables instead."
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
boot_key = os.getenv("AGENT_WALLET_BOOT_KEY", "").strip()
|
|
80
|
+
if not boot_key:
|
|
81
|
+
raise SystemExit("AGENT_WALLET_BOOT_KEY is required.")
|
|
82
|
+
|
|
83
|
+
updates = _collect_secret_updates()
|
|
84
|
+
sealed_path = resolve_sealed_keys_path()
|
|
85
|
+
existing = unseal_keys(boot_key) if sealed_path.exists() and not args.replace else {}
|
|
86
|
+
secrets = {**existing, **updates}
|
|
87
|
+
generated_keys: list[str] = []
|
|
88
|
+
if "wdk_evm_wallet_password" not in secrets:
|
|
89
|
+
secrets["wdk_evm_wallet_password"] = py_secrets.token_urlsafe(24)
|
|
90
|
+
generated_keys.append("wdk_evm_wallet_password")
|
|
91
|
+
if not secrets:
|
|
92
|
+
raise SystemExit(
|
|
93
|
+
"No secrets provided. Set AGENT_WALLET_MASTER_KEY, AGENT_WALLET_APPROVAL_SECRET, "
|
|
94
|
+
"and/or SOLANA_AGENT_PRIVATE_KEY in the environment."
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
changed = not sealed_path.exists() or secrets != existing
|
|
98
|
+
path = seal_keys(boot_key, secrets) if changed else sealed_path
|
|
99
|
+
print(
|
|
100
|
+
json.dumps(
|
|
101
|
+
{
|
|
102
|
+
"ok": True,
|
|
103
|
+
"path": str(path),
|
|
104
|
+
"stored_keys": sorted(secrets.keys()),
|
|
105
|
+
"updated_keys": (
|
|
106
|
+
sorted(set(updates.keys()) | set(generated_keys)) if changed else []
|
|
107
|
+
),
|
|
108
|
+
"replaced": bool(args.replace),
|
|
109
|
+
"changed": changed,
|
|
110
|
+
},
|
|
111
|
+
indent=2,
|
|
112
|
+
)
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if __name__ == "__main__":
|
|
117
|
+
main()
|