@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,210 @@
|
|
|
1
|
+
"""Build a release bundle tarball for the OpenClaw wallet/plugin runtime."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import io
|
|
7
|
+
import json
|
|
8
|
+
import subprocess
|
|
9
|
+
import tarfile
|
|
10
|
+
from datetime import datetime, timezone
|
|
11
|
+
from pathlib import Path, PurePosixPath
|
|
12
|
+
|
|
13
|
+
DEFAULT_BUNDLE_PREFIX = "openclaw-agent-wallet-bundle"
|
|
14
|
+
INCLUDED_ROOT_FILES = [
|
|
15
|
+
".env.example",
|
|
16
|
+
".gitignore",
|
|
17
|
+
"AGENTS.md",
|
|
18
|
+
"CHANGELOG.md",
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"README.md",
|
|
21
|
+
"VERSION",
|
|
22
|
+
"install-from-github.sh",
|
|
23
|
+
"package.json",
|
|
24
|
+
"requirements.txt",
|
|
25
|
+
"setup.sh",
|
|
26
|
+
]
|
|
27
|
+
# Must cover every setup.sh require_path and mirror the npm package `files`
|
|
28
|
+
# allowlist — the bundle is the same runtime users
|
|
29
|
+
# get from npx, just delivered as a GitHub Release asset.
|
|
30
|
+
INCLUDED_TOP_LEVEL_DIRS = [
|
|
31
|
+
".claude-plugin",
|
|
32
|
+
".openclaw",
|
|
33
|
+
"agent-wallet",
|
|
34
|
+
"bin",
|
|
35
|
+
"claude-code",
|
|
36
|
+
"codex",
|
|
37
|
+
"cursor",
|
|
38
|
+
"connectors",
|
|
39
|
+
"hermes",
|
|
40
|
+
"mcp",
|
|
41
|
+
"scripts",
|
|
42
|
+
"wdk-evm-wallet",
|
|
43
|
+
]
|
|
44
|
+
INCLUDED_COMPONENT_PATHS = [
|
|
45
|
+
"integrations/hedera/treasury-guard/README.md",
|
|
46
|
+
"integrations/hedera/treasury-guard/examples",
|
|
47
|
+
"integrations/hedera/treasury-guard/package.json",
|
|
48
|
+
"integrations/hedera/treasury-guard/package-lock.json",
|
|
49
|
+
"integrations/hedera/treasury-guard/skills",
|
|
50
|
+
"integrations/hedera/treasury-guard/src",
|
|
51
|
+
]
|
|
52
|
+
EXCLUDED_EXACT_RELATIVE_PATHS = {
|
|
53
|
+
".openclaw/extensions-local",
|
|
54
|
+
".openclaw/openclaw.local.example.json",
|
|
55
|
+
".openclaw/extensions/pay-bridge",
|
|
56
|
+
}
|
|
57
|
+
EXCLUDED_DIR_NAMES = {
|
|
58
|
+
".git",
|
|
59
|
+
".venv",
|
|
60
|
+
".pytest_cache",
|
|
61
|
+
".ruff_cache",
|
|
62
|
+
"extensions-local",
|
|
63
|
+
"graphify-out",
|
|
64
|
+
"__pycache__",
|
|
65
|
+
"dist",
|
|
66
|
+
"node_modules",
|
|
67
|
+
}
|
|
68
|
+
EXCLUDED_FILE_NAMES = {
|
|
69
|
+
".DS_Store",
|
|
70
|
+
}
|
|
71
|
+
EXCLUDED_SUFFIXES = {
|
|
72
|
+
".pyc",
|
|
73
|
+
".pyo",
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _repo_root() -> Path:
|
|
78
|
+
return Path(__file__).resolve().parents[2]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _default_output_dir() -> Path:
|
|
82
|
+
return _repo_root() / "dist"
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _git_version(root: Path) -> str:
|
|
86
|
+
try:
|
|
87
|
+
result = subprocess.run(
|
|
88
|
+
["git", "-C", str(root), "describe", "--tags", "--always", "--dirty"],
|
|
89
|
+
capture_output=True,
|
|
90
|
+
text=True,
|
|
91
|
+
check=True,
|
|
92
|
+
)
|
|
93
|
+
version = result.stdout.strip()
|
|
94
|
+
if version:
|
|
95
|
+
return version.replace("/", "-")
|
|
96
|
+
except Exception:
|
|
97
|
+
pass
|
|
98
|
+
return datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _bundle_root_name(version: str) -> str:
|
|
102
|
+
return f"{DEFAULT_BUNDLE_PREFIX}-{version}"
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _should_skip(path: Path, source_root: Path) -> bool:
|
|
106
|
+
relative = path.relative_to(source_root)
|
|
107
|
+
relative_text = relative.as_posix()
|
|
108
|
+
if relative_text in EXCLUDED_EXACT_RELATIVE_PATHS:
|
|
109
|
+
return True
|
|
110
|
+
for part in relative.parts:
|
|
111
|
+
if part in EXCLUDED_DIR_NAMES:
|
|
112
|
+
return True
|
|
113
|
+
if path.name in EXCLUDED_FILE_NAMES:
|
|
114
|
+
return True
|
|
115
|
+
return any(path.name.endswith(suffix) for suffix in EXCLUDED_SUFFIXES)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _iter_paths(base_path: Path, source_root: Path) -> list[Path]:
|
|
119
|
+
if not base_path.exists():
|
|
120
|
+
return []
|
|
121
|
+
if base_path.is_file():
|
|
122
|
+
return [] if _should_skip(base_path, source_root) else [base_path]
|
|
123
|
+
|
|
124
|
+
collected: list[Path] = []
|
|
125
|
+
for path in sorted(base_path.rglob("*")):
|
|
126
|
+
if _should_skip(path, source_root):
|
|
127
|
+
continue
|
|
128
|
+
collected.append(path)
|
|
129
|
+
return collected
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _normalize_tar_name(bundle_root: str, source_root: Path, path: Path) -> str:
|
|
133
|
+
relative = PurePosixPath(path.relative_to(source_root).as_posix())
|
|
134
|
+
return str(PurePosixPath(bundle_root) / relative)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _build_manifest(source_root: Path, version: str, bundle_root: str) -> bytes:
|
|
138
|
+
payload = {
|
|
139
|
+
"bundle_prefix": DEFAULT_BUNDLE_PREFIX,
|
|
140
|
+
"bundle_root": bundle_root,
|
|
141
|
+
"version": version,
|
|
142
|
+
"generated_at": datetime.now(timezone.utc).isoformat(),
|
|
143
|
+
"source_root": str(source_root),
|
|
144
|
+
"included_root_files": INCLUDED_ROOT_FILES,
|
|
145
|
+
"included_top_level_dirs": INCLUDED_TOP_LEVEL_DIRS,
|
|
146
|
+
"included_component_paths": INCLUDED_COMPONENT_PATHS,
|
|
147
|
+
"excluded_dir_names": sorted(EXCLUDED_DIR_NAMES),
|
|
148
|
+
"excluded_file_names": sorted(EXCLUDED_FILE_NAMES),
|
|
149
|
+
"excluded_suffixes": sorted(EXCLUDED_SUFFIXES),
|
|
150
|
+
"excluded_exact_relative_paths": sorted(EXCLUDED_EXACT_RELATIVE_PATHS),
|
|
151
|
+
}
|
|
152
|
+
return (json.dumps(payload, indent=2) + "\n").encode("utf-8")
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
156
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
157
|
+
parser.add_argument("--source-root", default=str(_repo_root()))
|
|
158
|
+
parser.add_argument("--output-dir", default=str(_default_output_dir()))
|
|
159
|
+
parser.add_argument("--output-file", default="")
|
|
160
|
+
parser.add_argument("--version", default="")
|
|
161
|
+
parser.add_argument("--bundle-root", default="")
|
|
162
|
+
return parser
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def main() -> None:
|
|
166
|
+
args = build_parser().parse_args()
|
|
167
|
+
source_root = Path(args.source_root).expanduser().resolve()
|
|
168
|
+
output_dir = Path(args.output_dir).expanduser().resolve()
|
|
169
|
+
version = args.version.strip() or _git_version(source_root)
|
|
170
|
+
bundle_root = args.bundle_root.strip() or _bundle_root_name(version)
|
|
171
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
172
|
+
output_path = (
|
|
173
|
+
Path(args.output_file).expanduser().resolve()
|
|
174
|
+
if args.output_file.strip()
|
|
175
|
+
else output_dir / f"{bundle_root}.tar.gz"
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
included_paths: list[Path] = []
|
|
179
|
+
for relative in INCLUDED_ROOT_FILES + INCLUDED_TOP_LEVEL_DIRS + INCLUDED_COMPONENT_PATHS:
|
|
180
|
+
included_paths.extend(_iter_paths(source_root / relative, source_root))
|
|
181
|
+
|
|
182
|
+
manifest_bytes = _build_manifest(source_root, version, bundle_root)
|
|
183
|
+
with tarfile.open(output_path, "w:gz") as archive:
|
|
184
|
+
for path in included_paths:
|
|
185
|
+
archive.add(path, arcname=_normalize_tar_name(bundle_root, source_root, path), recursive=False)
|
|
186
|
+
|
|
187
|
+
manifest_info = tarfile.TarInfo(name=f"{bundle_root}/bundle-manifest.json")
|
|
188
|
+
manifest_info.size = len(manifest_bytes)
|
|
189
|
+
manifest_info.mtime = int(datetime.now(timezone.utc).timestamp())
|
|
190
|
+
archive.addfile(manifest_info, io.BytesIO(manifest_bytes))
|
|
191
|
+
|
|
192
|
+
print(
|
|
193
|
+
json.dumps(
|
|
194
|
+
{
|
|
195
|
+
"ok": True,
|
|
196
|
+
"source_root": str(source_root),
|
|
197
|
+
"output_path": str(output_path),
|
|
198
|
+
"bundle_root": bundle_root,
|
|
199
|
+
"version": version,
|
|
200
|
+
"included_root_files": INCLUDED_ROOT_FILES,
|
|
201
|
+
"included_top_level_dirs": INCLUDED_TOP_LEVEL_DIRS,
|
|
202
|
+
"included_component_paths": INCLUDED_COMPONENT_PATHS,
|
|
203
|
+
},
|
|
204
|
+
indent=2,
|
|
205
|
+
)
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
if __name__ == "__main__":
|
|
210
|
+
main()
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""Finalize an OpenClaw agent-wallet config with a persistent master key."""
|
|
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.sealed_keys import resolve_sealed_keys_path, seal_keys, unseal_keys
|
|
17
|
+
from agent_wallet.user_wallets import resolve_user_wallet_path, rotate_user_wallet_encryption
|
|
18
|
+
from security_utils import write_redacted_backup
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _default_config_path() -> Path:
|
|
22
|
+
return Path(os.path.expanduser("~/.openclaw/openclaw.json"))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
26
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
27
|
+
parser.add_argument("--config-path", default=str(_default_config_path()))
|
|
28
|
+
parser.add_argument("--plugin-id", default="agent-wallet")
|
|
29
|
+
parser.add_argument("--user-id")
|
|
30
|
+
parser.add_argument("--network")
|
|
31
|
+
parser.add_argument(
|
|
32
|
+
"--current-master-key",
|
|
33
|
+
default="",
|
|
34
|
+
help="Deprecated insecure path. Use AGENT_WALLET_CURRENT_MASTER_KEY env instead.",
|
|
35
|
+
)
|
|
36
|
+
parser.add_argument(
|
|
37
|
+
"--new-master-key",
|
|
38
|
+
default="",
|
|
39
|
+
help="Deprecated insecure path. Use AGENT_WALLET_NEW_MASTER_KEY env instead.",
|
|
40
|
+
)
|
|
41
|
+
return parser
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def main() -> None:
|
|
45
|
+
args = build_parser().parse_args()
|
|
46
|
+
config_path = Path(args.config_path).expanduser()
|
|
47
|
+
data = json.loads(config_path.read_text(encoding="utf-8"))
|
|
48
|
+
plugin_config = data["plugins"]["entries"][args.plugin_id]["config"]
|
|
49
|
+
|
|
50
|
+
backup_path = config_path.with_name(
|
|
51
|
+
f"{config_path.name}.bak.agent-wallet-finalize.{datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')}"
|
|
52
|
+
)
|
|
53
|
+
write_redacted_backup(backup_path, data)
|
|
54
|
+
|
|
55
|
+
existing_master_key = str(plugin_config.get("masterKey") or "").strip()
|
|
56
|
+
if existing_master_key:
|
|
57
|
+
raise SystemExit(
|
|
58
|
+
"masterKey stored in config is no longer supported. Remove it and keep runtime secrets in sealed_keys.json."
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
boot_key = os.getenv("AGENT_WALLET_BOOT_KEY", "").strip()
|
|
62
|
+
if not boot_key:
|
|
63
|
+
raise SystemExit("AGENT_WALLET_BOOT_KEY is required.")
|
|
64
|
+
|
|
65
|
+
sealed_keys_path = resolve_sealed_keys_path()
|
|
66
|
+
sealed_secrets = unseal_keys(boot_key) if sealed_keys_path.exists() else {}
|
|
67
|
+
current_master_key = args.current_master_key.strip() or os.getenv("AGENT_WALLET_CURRENT_MASTER_KEY", "").strip()
|
|
68
|
+
if not current_master_key:
|
|
69
|
+
current_master_key = str(sealed_secrets.get("master_key") or "").strip()
|
|
70
|
+
new_master_key_arg = args.new_master_key.strip() or os.getenv("AGENT_WALLET_NEW_MASTER_KEY", "").strip()
|
|
71
|
+
if args.current_master_key.strip() or args.new_master_key.strip():
|
|
72
|
+
raise SystemExit(
|
|
73
|
+
"Passing master keys via command-line arguments is insecure. Use AGENT_WALLET_CURRENT_MASTER_KEY / AGENT_WALLET_NEW_MASTER_KEY environment variables instead."
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
user_id = args.user_id or str(plugin_config.get("userId") or "").strip()
|
|
77
|
+
if not user_id:
|
|
78
|
+
raise SystemExit("user_id is required either as an argument or in plugin config.")
|
|
79
|
+
|
|
80
|
+
network = args.network or str(plugin_config.get("network") or "mainnet").strip() or "mainnet"
|
|
81
|
+
wallet_path = resolve_user_wallet_path(user_id, network=network)
|
|
82
|
+
new_master_key = new_master_key_arg or secrets.token_hex(32)
|
|
83
|
+
|
|
84
|
+
rotated_wallet = False
|
|
85
|
+
if wallet_path.exists():
|
|
86
|
+
if not current_master_key:
|
|
87
|
+
raise SystemExit(
|
|
88
|
+
"AGENT_WALLET_CURRENT_MASTER_KEY is required to rotate an existing encrypted user wallet."
|
|
89
|
+
)
|
|
90
|
+
rotate_user_wallet_encryption(
|
|
91
|
+
user_id,
|
|
92
|
+
network=network,
|
|
93
|
+
current_master_key=current_master_key,
|
|
94
|
+
new_master_key=new_master_key,
|
|
95
|
+
)
|
|
96
|
+
rotated_wallet = True
|
|
97
|
+
|
|
98
|
+
plugin_config.pop("masterKey", None)
|
|
99
|
+
atomic_write_text(config_path, json.dumps(data, indent=2) + "\n", mode=0o600)
|
|
100
|
+
chmod_if_exists(config_path, 0o600)
|
|
101
|
+
seal_keys(boot_key, {**sealed_secrets, "master_key": new_master_key})
|
|
102
|
+
|
|
103
|
+
print(
|
|
104
|
+
json.dumps(
|
|
105
|
+
{
|
|
106
|
+
"ok": True,
|
|
107
|
+
"config_path": str(config_path),
|
|
108
|
+
"backup_path": str(backup_path),
|
|
109
|
+
"master_key_present": True,
|
|
110
|
+
"rotated_wallet": rotated_wallet,
|
|
111
|
+
"user_id": user_id,
|
|
112
|
+
"network": network,
|
|
113
|
+
"sealed_keys_path": str(resolve_sealed_keys_path()),
|
|
114
|
+
},
|
|
115
|
+
indent=2,
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
if __name__ == "__main__":
|
|
121
|
+
main()
|