@agentlayer.tech/wallet 0.1.0
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/.openclaw/AGENTS.md +98 -0
- package/.openclaw/extensions/agent-wallet/README.md +127 -0
- package/.openclaw/extensions/agent-wallet/index.ts +1520 -0
- package/.openclaw/extensions/agent-wallet/openclaw.plugin.json +184 -0
- package/.openclaw/extensions/agent-wallet/package.json +11 -0
- package/.openclaw/extensions/agent-wallet/skills/wallet-operator/SKILL.md +20 -0
- package/CHANGELOG.md +42 -0
- package/LICENSE +104 -0
- package/README.md +332 -0
- package/RELEASING.md +204 -0
- package/agent-wallet/.env.example +62 -0
- package/agent-wallet/AGENTS.md +129 -0
- package/agent-wallet/README.md +527 -0
- package/agent-wallet/agent_wallet/__init__.py +11 -0
- package/agent-wallet/agent_wallet/approval.py +161 -0
- package/agent-wallet/agent_wallet/bootstrap.py +178 -0
- package/agent-wallet/agent_wallet/btc_user_wallets.py +217 -0
- package/agent-wallet/agent_wallet/config.py +382 -0
- package/agent-wallet/agent_wallet/encrypted_storage.py +161 -0
- package/agent-wallet/agent_wallet/evm_user_wallets.py +370 -0
- package/agent-wallet/agent_wallet/exceptions.py +9 -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/models.py +66 -0
- package/agent-wallet/agent_wallet/nonce_registry.py +59 -0
- package/agent-wallet/agent_wallet/openclaw_adapter.py +5128 -0
- package/agent-wallet/agent_wallet/openclaw_cli.py +626 -0
- package/agent-wallet/agent_wallet/openclaw_runtime.py +272 -0
- package/agent-wallet/agent_wallet/plugin_bundle.py +42 -0
- package/agent-wallet/agent_wallet/providers/__init__.py +1 -0
- package/agent-wallet/agent_wallet/providers/bags.py +259 -0
- package/agent-wallet/agent_wallet/providers/evm_portfolio.py +470 -0
- package/agent-wallet/agent_wallet/providers/jupiter.py +567 -0
- package/agent-wallet/agent_wallet/providers/kamino.py +215 -0
- package/agent-wallet/agent_wallet/providers/lifi.py +277 -0
- package/agent-wallet/agent_wallet/providers/solana_rpc.py +470 -0
- package/agent-wallet/agent_wallet/providers/wdk_btc_local.py +114 -0
- package/agent-wallet/agent_wallet/providers/wdk_evm_local.py +205 -0
- package/agent-wallet/agent_wallet/sealed_keys.py +61 -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 +101 -0
- package/agent-wallet/agent_wallet/transaction_policy.py +518 -0
- package/agent-wallet/agent_wallet/user_wallets.py +355 -0
- package/agent-wallet/agent_wallet/validation.py +31 -0
- package/agent-wallet/agent_wallet/wallet_layer/__init__.py +1 -0
- package/agent-wallet/agent_wallet/wallet_layer/base.py +808 -0
- package/agent-wallet/agent_wallet/wallet_layer/base58.py +44 -0
- package/agent-wallet/agent_wallet/wallet_layer/factory.py +102 -0
- package/agent-wallet/agent_wallet/wallet_layer/solana.py +4252 -0
- package/agent-wallet/agent_wallet/wallet_layer/wdk_btc.py +272 -0
- package/agent-wallet/agent_wallet/wallet_layer/wdk_evm.py +1628 -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 +138 -0
- package/agent-wallet/pyproject.toml +31 -0
- package/agent-wallet/scripts/bootstrap_openclaw_btc.py +278 -0
- package/agent-wallet/scripts/build_release_bundle.py +188 -0
- package/agent-wallet/scripts/finalize_openclaw_local_wallet_config.py +121 -0
- package/agent-wallet/scripts/install_agent_wallet.py +505 -0
- package/agent-wallet/scripts/install_openclaw_local_config.py +226 -0
- package/agent-wallet/scripts/install_openclaw_sealed_keys.py +105 -0
- package/agent-wallet/scripts/manage_openclaw_btc_wallet.py +244 -0
- package/agent-wallet/scripts/reveal_btc_seed.sh +130 -0
- package/agent-wallet/scripts/security_utils.py +37 -0
- package/agent-wallet/scripts/setup_btc_wallet.sh +146 -0
- package/agent-wallet/scripts/switch_openclaw_wallet_network.py +106 -0
- package/agent-wallet/skills/wallet-operator/SKILL.md +128 -0
- package/bin/openclaw-agent-wallet.mjs +487 -0
- package/install-from-github.sh +134 -0
- package/package.json +61 -0
- package/setup.sh +40 -0
- package/wdk-btc-wallet/README.md +325 -0
- package/wdk-btc-wallet/bootstrap.sh +22 -0
- package/wdk-btc-wallet/package-lock.json +1839 -0
- package/wdk-btc-wallet/package.json +18 -0
- package/wdk-btc-wallet/run-local.sh +21 -0
- package/wdk-btc-wallet/src/config.js +160 -0
- package/wdk-btc-wallet/src/json.js +35 -0
- package/wdk-btc-wallet/src/local_vault.js +432 -0
- package/wdk-btc-wallet/src/network_state.js +84 -0
- package/wdk-btc-wallet/src/server.js +257 -0
- package/wdk-btc-wallet/src/wdk_btc_wallet.js +332 -0
- package/wdk-evm-wallet/README.md +183 -0
- package/wdk-evm-wallet/bootstrap.sh +8 -0
- package/wdk-evm-wallet/package-lock.json +2340 -0
- package/wdk-evm-wallet/package.json +23 -0
- package/wdk-evm-wallet/run-local.sh +12 -0
- package/wdk-evm-wallet/src/config.js +274 -0
- package/wdk-evm-wallet/src/json.js +35 -0
- package/wdk-evm-wallet/src/local_vault.js +430 -0
- package/wdk-evm-wallet/src/network_state.js +92 -0
- package/wdk-evm-wallet/src/server.js +575 -0
- package/wdk-evm-wallet/src/wdk_evm_wallet.js +4981 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
These instructions apply to the entire `.openclaw/` tree.
|
|
5
|
+
|
|
6
|
+
## Purpose
|
|
7
|
+
This tree contains local OpenClaw host-side workspace assets. In the current repo, its primary responsibility is the `agent-wallet` extension that bridges OpenClaw to the authoritative Python `agent-wallet` backend.
|
|
8
|
+
|
|
9
|
+
## Current structure
|
|
10
|
+
- `.openclaw/extensions/agent-wallet/index.ts` — TypeScript extension entrypoint registered by OpenClaw.
|
|
11
|
+
- `.openclaw/extensions/agent-wallet/openclaw.plugin.json` — plugin manifest and config schema.
|
|
12
|
+
- `.openclaw/extensions/agent-wallet/package.json` — extension package metadata.
|
|
13
|
+
- `.openclaw/extensions/agent-wallet/skills/wallet-operator/SKILL.md` — user-facing operational wallet safety guidance.
|
|
14
|
+
|
|
15
|
+
## Design intent
|
|
16
|
+
- Keep the TypeScript extension thin and host-oriented.
|
|
17
|
+
- Let Python own wallet logic, policy, approvals, signing rules, and Solana implementation details.
|
|
18
|
+
- Let the extension focus on:
|
|
19
|
+
- resolving config
|
|
20
|
+
- locating the Python package
|
|
21
|
+
- invoking `python -m agent_wallet.openclaw_cli`
|
|
22
|
+
- registering OpenClaw tools
|
|
23
|
+
- passing JSON in and out safely
|
|
24
|
+
- mapping OpenClaw tool schemas to the Python CLI contract
|
|
25
|
+
|
|
26
|
+
## Working rules
|
|
27
|
+
|
|
28
|
+
### Keep bridge logic thin
|
|
29
|
+
- Do not duplicate business logic from Python unless OpenClaw requires it at registration time.
|
|
30
|
+
- Do not reimplement approval validation, transaction policy, wallet derivation, or Solana-specific rules in TypeScript.
|
|
31
|
+
- Prefer forwarding config into the CLI bridge and letting Python decide runtime behavior.
|
|
32
|
+
- Treat this layer as a transport and schema bridge, not an execution authority.
|
|
33
|
+
|
|
34
|
+
### Keep schemas synchronized
|
|
35
|
+
- If you change extension config fields, also update the matching Python and docs surfaces:
|
|
36
|
+
- `.openclaw/extensions/agent-wallet/openclaw.plugin.json`
|
|
37
|
+
- `.openclaw/extensions/agent-wallet/index.ts`
|
|
38
|
+
- `agent-wallet/agent_wallet/openclaw_cli.py`
|
|
39
|
+
- `agent-wallet/README.md`
|
|
40
|
+
- If you add or remove tools, also update:
|
|
41
|
+
- `.openclaw/extensions/agent-wallet/index.ts`
|
|
42
|
+
- `agent-wallet/agent_wallet/openclaw_adapter.py`
|
|
43
|
+
- `agent-wallet/agent_wallet/plugin_bundle.py`
|
|
44
|
+
- `agent-wallet/tests/`
|
|
45
|
+
- If you change wallet safety semantics, update:
|
|
46
|
+
- `agent-wallet/agent_wallet/openclaw_adapter.py`
|
|
47
|
+
- `agent-wallet/agent_wallet/transaction_policy.py`
|
|
48
|
+
- `agent-wallet/agent_wallet/approval.py`
|
|
49
|
+
- the local OpenClaw skill docs in this tree
|
|
50
|
+
|
|
51
|
+
### Security rules
|
|
52
|
+
- Never add support for passing wallet secrets through OpenClaw config JSON as the preferred path.
|
|
53
|
+
- Keep deprecated sensitive config fields clearly marked as insecure/deprecated if retained for compatibility.
|
|
54
|
+
- Do not move approval, signing, or execution policy into the TypeScript layer.
|
|
55
|
+
- Preserve the separation between host approval issuance and tool execution.
|
|
56
|
+
- Keep the extension from becoming a secret store or key-derivation service.
|
|
57
|
+
|
|
58
|
+
### Path resolution expectations
|
|
59
|
+
- The extension currently resolves the Python package root from:
|
|
60
|
+
- explicit plugin config
|
|
61
|
+
- env overrides
|
|
62
|
+
- the repo-local sibling `agent-wallet/`
|
|
63
|
+
- Keep fallback resolution practical for local development.
|
|
64
|
+
- If changing path resolution, preserve a clear error when the package root cannot be found.
|
|
65
|
+
- Preserve deterministic resolution for workspace-relative installs and local dev shells.
|
|
66
|
+
|
|
67
|
+
## Editing guidance
|
|
68
|
+
- Favor small edits in `index.ts`; it is intentionally straightforward.
|
|
69
|
+
- Keep tool parameter schemas explicit and JSON-schema-like.
|
|
70
|
+
- Keep stdout payloads machine-readable because OpenClaw expects structured JSON text content.
|
|
71
|
+
- Keep descriptions aligned with actual Python behavior, especially for `preview`, `prepare`, `execute`, and `approval_token`.
|
|
72
|
+
- If OpenClaw-facing schemas change, keep the bridge names, descriptions, and required fields in lockstep with Python.
|
|
73
|
+
|
|
74
|
+
## Validation
|
|
75
|
+
- After extension changes, verify the matching Python CLI contract still lines up.
|
|
76
|
+
- Relevant Python-side tests live in `agent-wallet/tests/`, especially:
|
|
77
|
+
- `agent-wallet/tests/smoke_openclaw_cli.py`
|
|
78
|
+
- `agent-wallet/tests/smoke_openclaw_adapter.py`
|
|
79
|
+
- `agent-wallet/tests/smoke_openclaw_runtime.py`
|
|
80
|
+
- For wallet changes, also confirm the hidden operational surface stays disabled here unless the product decision changes.
|
|
81
|
+
|
|
82
|
+
## Common change patterns
|
|
83
|
+
|
|
84
|
+
### If changing tool registration
|
|
85
|
+
1. Update `index.ts`.
|
|
86
|
+
2. Sync the Python adapter/tool bundle.
|
|
87
|
+
3. Confirm names, required params, and safety wording match.
|
|
88
|
+
|
|
89
|
+
### If changing plugin config
|
|
90
|
+
1. Update `openclaw.plugin.json`.
|
|
91
|
+
2. Update TypeScript config consumption.
|
|
92
|
+
3. Update Python CLI env/config mapping.
|
|
93
|
+
4. Update docs/examples if behavior changed.
|
|
94
|
+
|
|
95
|
+
### If changing wallet policy
|
|
96
|
+
1. Update the Python backend first.
|
|
97
|
+
2. Update the OpenClaw bridge schemas and descriptions second.
|
|
98
|
+
3. Verify the extension still only forwards requests and never owns policy decisions.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Agent Wallet OpenClaw Extension
|
|
2
|
+
|
|
3
|
+
Workspace extension for the official OpenClaw agent.
|
|
4
|
+
|
|
5
|
+
This extension registers wallet tools through the official OpenClaw plugin API and forwards execution to the local Python `agent-wallet` backend.
|
|
6
|
+
|
|
7
|
+
It is designed so the OpenClaw agent sees a small operational wallet surface instead of raw key management.
|
|
8
|
+
In practice this means the agent works through explicit tools for:
|
|
9
|
+
|
|
10
|
+
- BTC balance, fee-rate, max-spendable, history, and transfer flows through the local `wdk-btc-wallet` backend
|
|
11
|
+
- EVM native balance, ERC-20 balance/metadata, fee-rate, receipt, Velora swap quote/execute, Aave V3 account/reserve/position flows, and transfer flows through the local `wdk-evm-wallet` backend
|
|
12
|
+
- wallet address, balances, and portfolio reads
|
|
13
|
+
- native SOL and SPL token transfers
|
|
14
|
+
- Jupiter swap and price lookup
|
|
15
|
+
- Jupiter Earn read/deposit/withdraw flows
|
|
16
|
+
- Kamino lending read/deposit/withdraw/borrow/repay flows
|
|
17
|
+
- native Solana staking, stake deactivation, and stake withdrawal
|
|
18
|
+
|
|
19
|
+
Expected local layout:
|
|
20
|
+
|
|
21
|
+
- this extension lives at `.openclaw/extensions/agent-wallet`
|
|
22
|
+
- the Python package lives at `agent-wallet/`
|
|
23
|
+
|
|
24
|
+
Recommended config:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"plugins": {
|
|
29
|
+
"allow": ["agent-wallet"],
|
|
30
|
+
"entries": {
|
|
31
|
+
"agent-wallet": {
|
|
32
|
+
"enabled": true,
|
|
33
|
+
"config": {
|
|
34
|
+
"userId": "openclaw-local-user",
|
|
35
|
+
"backend": "solana_local",
|
|
36
|
+
"network": "devnet",
|
|
37
|
+
"rpcUrls": [
|
|
38
|
+
"https://your-primary-rpc.example",
|
|
39
|
+
"https://api.devnet.solana.com"
|
|
40
|
+
],
|
|
41
|
+
"signOnly": false,
|
|
42
|
+
"encryptUserWallets": true,
|
|
43
|
+
"migratePlaintextUserWallets": true,
|
|
44
|
+
"refuseMainnetWalletRecreation": true,
|
|
45
|
+
"packageRoot": "/absolute/path/to/agent-wallet",
|
|
46
|
+
"pythonBin": "/absolute/path/to/python"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Recommended local installer entrypoint:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
sh ./setup.sh
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
That installs the Python backend, Node dependencies for the local BTC/EVM runtimes, and patches the OpenClaw plugin config. Wallet creation, unlock, and local service start stay as separate host-side steps.
|
|
61
|
+
|
|
62
|
+
For self-hosted installs, prefer `SOLANA_RPC_URL` / `SOLANA_RPC_URLS` in local env and treat the plugin `rpcUrl` / `rpcUrls` fields as fallback only. If the local runtime exposes `ALCHEMY_API_KEY` or `HELIUS_API_KEY`, the wallet can derive the Solana RPC URL automatically for `mainnet` or `devnet`. Local env always takes precedence over `openclaw.json`.
|
|
63
|
+
|
|
64
|
+
Provide only `AGENT_WALLET_BOOT_KEY` to the runtime. Provision `master_key`, `approval_secret`, and any signer `private_key` into `sealed_keys.json`, not `openclaw.json`.
|
|
65
|
+
|
|
66
|
+
Important:
|
|
67
|
+
|
|
68
|
+
- For a local official OpenClaw install, `userId` should represent the wallet owner for that agent install.
|
|
69
|
+
- The public OpenClaw plugin docs do not document a per-request end-user identifier in `registerTool(...).execute(...)`, so dynamic multi-user wallet selection is intentionally kept in the Python/runtime layer, not inside the TypeScript plugin itself.
|
|
70
|
+
- Helper scripts in `agent-wallet/scripts/` are generic patch/finalize utilities and no longer assume a specific local username, path, or temporary master key.
|
|
71
|
+
- The OpenClaw plugin API in this repo exposes tool registration, not host password prompts, so BTC and EVM wallet create/unlock remain host-shell or CLI flows outside the agent tool surface.
|
|
72
|
+
- For a one-command local BTC onboarding path, use `agent-wallet/scripts/bootstrap_openclaw_btc.py`, which both sets up the BTC wallet binding and patches local OpenClaw config for `backend=wdk_btc_local`.
|
|
73
|
+
- The BTC flow now only supports local service URLs (`127.0.0.1` / `localhost` / `::1`).
|
|
74
|
+
- The local BTC service is protected with a bearer token loaded from `~/.openclaw/wdk-btc-wallet/local-auth-token`, not from plugin config JSON.
|
|
75
|
+
- When the BTC service URL is local, that bootstrap script can also auto-start `wdk-btc-wallet` before patching OpenClaw config.
|
|
76
|
+
- The EVM flow also only supports local service URLs (`127.0.0.1` / `localhost` / `::1`) and uses a bearer token loaded from `~/.openclaw/wdk-evm-wallet/local-auth-token`.
|
|
77
|
+
- The EVM tool surface is intentionally narrow: Velora swap quote/execute, Aave V3 account/reserve/position flows, native transfers, ERC-20 transfers, fee quotes, and receipt lookup only. No arbitrary calldata, standalone approvals, or generic contract execution are exposed to the agent.
|
|
78
|
+
- Velora swap and Aave V3 support are currently limited to `ethereum` and `base`. Test carefully because the upstream WDK protocol packages are still beta.
|
|
79
|
+
- Agents can call `set_wallet_backend` to switch the active wallet for the current OpenClaw plugin session between Solana, EVM, and Bitcoin. This does not edit `openclaw.json`; plugin config remains the startup default.
|
|
80
|
+
- EVM read and write tools accept an optional per-call `network` override for `ethereum` or `base`.
|
|
81
|
+
- Agents can also call `set_evm_network` to select the active EVM network for the current OpenClaw plugin session. After that, EVM tools default to the selected network unless a specific call passes its own `network` value. Do not edit code, plugin config, or environment variables just to switch between Base and Ethereum.
|
|
82
|
+
- `get_wallet_balance` returns an enriched wallet overview for Solana and EVM: native balance, discovered token balances, per-asset USD values when pricing is available, and `total_value_usd`.
|
|
83
|
+
- Solana wallet overview uses Solana RPC only for balance and token-account discovery. Token prices come from Jupiter, not RPC, and internal transfer/staking checks continue to use native-only balance reads.
|
|
84
|
+
- If the user needs to recover the mnemonic later, host-side reveal stays outside the agent tool surface via `agent-wallet/scripts/manage_openclaw_btc_wallet.py reveal-seed`.
|
|
85
|
+
- Optional Jupiter overrides are available via `jupiterBaseUrl`, `jupiterUltraBaseUrl`, `jupiterPriceBaseUrl`, `jupiterPortfolioBaseUrl`, `jupiterLendBaseUrl`, and `jupiterApiKey`.
|
|
86
|
+
- Optional Kamino overrides are available via `kaminoBaseUrl` and `kaminoProgramId`.
|
|
87
|
+
- Jupiter `Portfolio` implementation remains in the backend, but those agent-facing tools are temporarily disabled for now.
|
|
88
|
+
- Mainnet wallets are pinned by address. If a pinned mainnet wallet file disappears, the runtime refuses to silently create a replacement wallet.
|
|
89
|
+
|
|
90
|
+
## OpenClaw UX
|
|
91
|
+
|
|
92
|
+
The intended user-facing flow inside OpenClaw is:
|
|
93
|
+
|
|
94
|
+
1. Read first:
|
|
95
|
+
use wallet address, balance, portfolio, validator list, or stake account inspection tools.
|
|
96
|
+
2. Preview next:
|
|
97
|
+
transfers, swaps, Aave position changes, staking, stake deactivation, and stake withdrawals should start in `preview`.
|
|
98
|
+
3. Prepare only with intent:
|
|
99
|
+
`prepare` is for explicit execution planning intent and returns no signed transaction bytes.
|
|
100
|
+
4. Execute only with approval:
|
|
101
|
+
`execute` requires a host-issued `approval_token` bound to the exact previewed operation. On `mainnet`, that token must include explicit mainnet confirmation.
|
|
102
|
+
5. On mainnet, restate the network, asset, amount, and destination, validator, or stake account before execute.
|
|
103
|
+
|
|
104
|
+
For staking specifically, the normal agent flow should be:
|
|
105
|
+
|
|
106
|
+
1. `get_solana_staking_validators`
|
|
107
|
+
2. `stake_sol_native` in `preview`
|
|
108
|
+
3. `stake_sol_native` in `execute`
|
|
109
|
+
4. `get_solana_stake_account`
|
|
110
|
+
5. later, `deactivate_solana_stake` and `withdraw_solana_stake`
|
|
111
|
+
|
|
112
|
+
## Switching networks
|
|
113
|
+
|
|
114
|
+
The extension is already network-aware:
|
|
115
|
+
|
|
116
|
+
- `plugins.entries.agent-wallet.config.network` selects `mainnet`, `devnet`, or `testnet`
|
|
117
|
+
- each network uses a separate wallet file for the same `userId`
|
|
118
|
+
- switching networks does not merge balances across clusters
|
|
119
|
+
|
|
120
|
+
Recommended local switch helper:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
python agent-wallet/scripts/switch_openclaw_wallet_network.py --network devnet
|
|
124
|
+
python agent-wallet/scripts/switch_openclaw_wallet_network.py --network mainnet
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Use `--show-only` first if you want to inspect the target wallet path before changing the config.
|