@agentlayer.tech/wallet 0.1.48 → 0.1.49

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.
@@ -220,6 +220,35 @@ async def _run_issue_approval(
220
220
  }
221
221
 
222
222
 
223
+ def _run_autonomous_permission(action: str, scope: str) -> dict[str, Any]:
224
+ from agent_wallet import autonomous_permissions
225
+
226
+ normalized_scope = str(scope or "").strip()
227
+ if normalized_scope != autonomous_permissions.BASE_SWAP_SCOPE:
228
+ raise WalletBackendError("Only scope=base_swaps is currently supported.")
229
+
230
+ normalized_action = str(action or "").strip().lower()
231
+ if normalized_action == "approve":
232
+ return {
233
+ "ok": True,
234
+ "action": normalized_action,
235
+ "data": autonomous_permissions.approve_base_swaps(approved_by="openclaw_cli"),
236
+ }
237
+ if normalized_action == "revoke":
238
+ return {
239
+ "ok": True,
240
+ "action": normalized_action,
241
+ "data": autonomous_permissions.revoke_base_swaps(),
242
+ }
243
+ if normalized_action == "status":
244
+ return {
245
+ "ok": True,
246
+ "action": normalized_action,
247
+ "data": autonomous_permissions.status(),
248
+ }
249
+ raise WalletBackendError("action must be approve, revoke, or status.")
250
+
251
+
223
252
  async def _run_btc_wallet_get(user_id: str, config: dict[str, Any]) -> dict[str, Any]:
224
253
  from agent_wallet.btc_user_wallets import get_user_btc_wallet_binding
225
254
 
@@ -433,6 +462,11 @@ def main() -> int:
433
462
  approval_parser.add_argument("--ttl-seconds", type=int)
434
463
  approval_parser.add_argument("--config-json", default="{}")
435
464
 
465
+ autonomous_permission_parser = subparsers.add_parser("autonomous-permission")
466
+ autonomous_permission_parser.add_argument("--action", choices=["approve", "revoke", "status"], required=True)
467
+ autonomous_permission_parser.add_argument("--scope", choices=["base_swaps"], required=True)
468
+ autonomous_permission_parser.add_argument("--config-json", default="{}")
469
+
436
470
  btc_get_parser = subparsers.add_parser("btc-wallet-get")
437
471
  btc_get_parser.add_argument("--user-id", required=True)
438
472
  btc_get_parser.add_argument("--config-json", default="{}")
@@ -506,6 +540,8 @@ def main() -> int:
506
540
  ttl_seconds=args.ttl_seconds,
507
541
  )
508
542
  )
543
+ elif args.command == "autonomous-permission":
544
+ payload = _run_autonomous_permission(args.action, args.scope)
509
545
  elif args.command == "btc-wallet-get":
510
546
  payload = asyncio.run(_run_btc_wallet_get(args.user_id, config))
511
547
  elif args.command == "btc-wallet-create":
@@ -15,6 +15,7 @@ from __future__ import annotations
15
15
 
16
16
  import threading
17
17
  import time
18
+ from collections.abc import Callable
18
19
  from dataclasses import dataclass
19
20
 
20
21
  from agent_wallet.wallet_layer.base import WalletBackendError
@@ -38,9 +39,20 @@ class SpendingConfig:
38
39
  class SpendingLedger:
39
40
  """Records executed spends and rejects operations that exceed limits."""
40
41
 
41
- def __init__(self, config: SpendingConfig) -> None:
42
+ def __init__(
43
+ self,
44
+ config: SpendingConfig,
45
+ *,
46
+ clock: Callable[[], float] = time.monotonic,
47
+ entries: list[tuple[float, int]] | None = None,
48
+ ) -> None:
42
49
  self.config = config
43
- self._entries: list[tuple[float, int]] = [] # (monotonic-ts, lamports)
50
+ # (timestamp, lamports) pairs in the unit returned by ``clock``.
51
+ # Defaults to ``time.monotonic`` for in-process use; pass
52
+ # ``time.time`` (wall-clock) when entries must be persisted and
53
+ # reloaded across processes.
54
+ self._clock = clock
55
+ self._entries: list[tuple[float, int]] = list(entries or [])
44
56
  self._lock = threading.Lock()
45
57
 
46
58
  # -- public API ----------------------------------------------------------
@@ -51,7 +63,7 @@ class SpendingLedger:
51
63
  Raises ``WalletBackendError`` if any limit would be exceeded.
52
64
  """
53
65
  with self._lock:
54
- now = time.monotonic()
66
+ now = self._clock()
55
67
  self._cleanup(now)
56
68
 
57
69
  # Per-transaction cap
@@ -94,6 +106,12 @@ class SpendingLedger:
94
106
 
95
107
  self._entries.append((now, lamports))
96
108
 
109
+ def export(self) -> list[tuple[float, int]]:
110
+ """Return a copy of the (timestamp, lamports) entries for persistence."""
111
+ with self._lock:
112
+ self._cleanup(self._clock())
113
+ return list(self._entries)
114
+
97
115
  # -- internal ------------------------------------------------------------
98
116
 
99
117
  def _cleanup(self, now: float) -> None:
@@ -2,7 +2,7 @@
2
2
  "id": "agent-wallet",
3
3
  "name": "Agent Wallet",
4
4
  "description": "Plugin-friendly wallet backend for OpenClaw agents with safe wallet tools and runtime instructions across Solana, local BTC, and local EVM.",
5
- "version": "0.1.48",
5
+ "version": "0.1.49",
6
6
  "skills": ["skills/wallet-operator"],
7
7
  "configSchema": {
8
8
  "type": "object",
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "openclaw-agent-wallet"
7
- version = "0.1.48"
7
+ version = "0.1.49"
8
8
  description = "Plugin-friendly wallet backend for OpenClaw agents"
9
9
  requires-python = ">=3.10"
10
10
  dependencies = [
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-wallet",
3
3
  "displayName": "Agent Wallet",
4
- "version": "0.1.48",
4
+ "version": "0.1.49",
5
5
  "description": "Claude Code bridge for the existing AgentLayer wallet runtime. Connects to Solana, Bitcoin, and EVM wallets without creating a new one.",
6
6
  "author": {
7
7
  "name": "AgentLayer"
@@ -51,6 +51,11 @@ no-op once the backend is healthy.
51
51
  - `/wallet-setup` — install (or repair) the backend explicitly instead of
52
52
  waiting for the hook (requires `/reload-plugins` first so the command is
53
53
  registered).
54
+ - `/agentlayer-autonomous-approve` — enable high-trust autonomous Base swaps
55
+ (`swap_evm_tokens` / `swap_evm_uniswap_tokens` on Base only) without
56
+ per-transaction approvals.
57
+ - `/agentlayer-autonomous-revoke` — disable that autonomous Base swap
58
+ permission.
54
59
  - `AGENT_WALLET_AUTO_BOOTSTRAP=0` — opt out of the auto-install: the
55
60
  `SessionStart` hook then only reminds you to run `/wallet-setup` instead of
56
61
  installing the backend itself.
@@ -0,0 +1,24 @@
1
+ ---
2
+ description: Enable AgentLayer autonomous Base swaps without per-transaction approvals.
3
+ allowed-tools: mcp__agent_wallet__agentlayer_autonomous_approve, mcp__agent_wallet__agentlayer_autonomous_status
4
+ ---
5
+
6
+ Enable high-trust autonomous Base swaps for AgentLayer.
7
+
8
+ Call `agentlayer_autonomous_approve` with:
9
+
10
+ ```json
11
+ {
12
+ "scope": "base_swaps",
13
+ "purpose": "User requested autonomous Base swaps from Claude Code.",
14
+ "user_intent": true
15
+ }
16
+ ```
17
+
18
+ Then call `agentlayer_autonomous_status` and report whether `base_swaps` is enabled.
19
+
20
+ Be explicit in the response:
21
+
22
+ - This only removes per-transaction approvals for Base Velora/Uniswap swap execute calls.
23
+ - It does not authorize transfers, withdrawals, lending, staking, bridges, Solana swaps, or non-Base networks.
24
+ - The user can run `/agentlayer-autonomous-revoke` to disable it.
@@ -0,0 +1,16 @@
1
+ ---
2
+ description: Disable AgentLayer autonomous Base swaps.
3
+ allowed-tools: mcp__agent_wallet__agentlayer_autonomous_revoke, mcp__agent_wallet__agentlayer_autonomous_status
4
+ ---
5
+
6
+ Disable high-trust autonomous Base swaps for AgentLayer.
7
+
8
+ Call `agentlayer_autonomous_revoke` with:
9
+
10
+ ```json
11
+ {
12
+ "scope": "base_swaps"
13
+ }
14
+ ```
15
+
16
+ Then call `agentlayer_autonomous_status` and report whether `base_swaps` is disabled.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-wallet",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "description": "Codex plugin bridge for the AgentLayer wallet runtime.",
5
5
  "author": {
6
6
  "name": "AgentLayer"
@@ -59,6 +59,7 @@ PREVIEW_BOUND_SWAP_TOOLS = {
59
59
  "flash_trade_open_position",
60
60
  "flash_trade_close_position",
61
61
  }
62
+ AUTONOMOUS_BASE_SWAP_TOOLS = {"swap_evm_tokens", "swap_evm_uniswap_tokens"}
62
63
  APPROVAL_PREVIEW_TOOL_ALIASES = {
63
64
  "x402_pay_request": "x402_preview_request",
64
65
  }
@@ -642,6 +643,21 @@ def _requires_approved_preview_payload(tool_name: str, params: dict[str, Any]) -
642
643
  return tool_name in PREVIEW_BOUND_SWAP_TOOLS
643
644
 
644
645
 
646
+ def _should_let_backend_authorize_autonomous_base_swap(
647
+ tool_name: str,
648
+ params: dict[str, Any],
649
+ config: dict[str, Any],
650
+ ) -> bool:
651
+ if tool_name not in AUTONOMOUS_BASE_SWAP_TOOLS:
652
+ return False
653
+ if str(params.get("mode") or "") != "execute":
654
+ return False
655
+ if str(params.get("approval_token") or "").strip():
656
+ return False
657
+ network = str(params.get("network") or config.get("network") or selected_evm_network or "").strip().lower()
658
+ return network == "base"
659
+
660
+
645
661
  def _looks_like_approval_context_error(message: str) -> bool:
646
662
  text = str(message or "").lower()
647
663
  return any(
@@ -696,6 +712,8 @@ def _attach_approval_for_execute(
696
712
  effective_params["_approved_preview"] = cached_preview
697
713
  if effective_params.get("approval_token"):
698
714
  return None
715
+ if _should_let_backend_authorize_autonomous_base_swap(tool_name, effective_params, config):
716
+ return None
699
717
  raise RuntimeError(APPROVAL_CONTEXT_MISSING_MESSAGE)
700
718
 
701
719
 
@@ -1,5 +1,5 @@
1
1
  name: agent-wallet
2
- version: 0.1.48
2
+ version: 0.1.49
3
3
  description: Thin Hermes Agent bridge to the existing AgentLayer/OpenClaw wallet backend
4
4
  provides_tools:
5
5
  - agent_wallet_tools
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentlayer.tech/wallet",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "description": "NPM installer for the OpenClaw Agent Wallet local runtime.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdk-btc-wallet",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "Separate BTC-only wallet service built on Tether WDK.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdk-evm-wallet",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "Separate EVM wallet service built on Tether WDK.",