@agentlayer.tech/wallet 0.1.52 → 0.1.53

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.
@@ -347,7 +347,7 @@ class OpenClawWalletAdapter:
347
347
  approval_ttl_seconds=_int(args.get("approval_ttl_seconds"), "approval_ttl_seconds") or 120,
348
348
  )
349
349
 
350
- async def _authorize_base_swap_permission(
350
+ async def _authorize_autonomous_permission(
351
351
  self,
352
352
  *,
353
353
  active_backend: AgentWalletBackend,
@@ -355,21 +355,36 @@ class OpenClawWalletAdapter:
355
355
  action_label: str,
356
356
  preview_kwargs: dict[str, Any],
357
357
  preview_method: Any,
358
+ scope: str,
358
359
  ) -> tuple[str, dict[str, Any]]:
359
- """Authorize one Base swap through the high-trust permission toggle."""
360
+ """Authorize one operation through a high-trust permission toggle."""
360
361
  from agent_wallet import autonomous_permissions
361
362
 
362
363
  network = str(getattr(active_backend, "network", "unknown")).strip().lower()
363
- if network != autonomous_permissions.BASE_SWAP_NETWORK:
364
- raise WalletBackendError(
365
- "Autonomous Base swap permission only applies on network=base. "
366
- "Use set_evm_network or the network parameter to select Base."
367
- )
368
- if not autonomous_permissions.is_base_swap_approved():
369
- raise WalletBackendError(
370
- "Autonomous Base swap permission is not enabled. Ask the user to run "
371
- "agentlayer_autonomous_approve with scope=base_swaps first."
372
- )
364
+ if scope == autonomous_permissions.BASE_SWAP_SCOPE:
365
+ if network != autonomous_permissions.BASE_SWAP_NETWORK:
366
+ raise WalletBackendError(
367
+ "Autonomous Base swap permission only applies on network=base. "
368
+ "Use set_evm_network or the network parameter to select Base."
369
+ )
370
+ if not autonomous_permissions.is_base_swap_approved():
371
+ raise WalletBackendError(
372
+ "Autonomous execution is not enabled. Ask the user to run "
373
+ "agentlayer_autonomous_approve first."
374
+ )
375
+ elif scope == autonomous_permissions.DEFI_TOOLS_SCOPE:
376
+ if network not in autonomous_permissions.DEFI_TOOLS_NETWORKS:
377
+ raise WalletBackendError(
378
+ "Autonomous DeFi permission only applies on ethereum or base. "
379
+ "Use set_evm_network or the network parameter to select a supported network."
380
+ )
381
+ if not autonomous_permissions.is_defi_tools_approved():
382
+ raise WalletBackendError(
383
+ "Autonomous execution is not enabled. Ask the user to run "
384
+ "agentlayer_autonomous_approve first."
385
+ )
386
+ else:
387
+ raise WalletBackendError("Unsupported autonomous permission scope.")
373
388
 
374
389
  preview = await preview_method(**preview_kwargs)
375
390
  annotated_preview = self._annotate_sensitive_payload(
@@ -379,13 +394,62 @@ class OpenClawWalletAdapter:
379
394
  )
380
395
  summary = dict(annotated_preview.get("confirmation_summary") or {})
381
396
  if not summary:
382
- raise WalletBackendError("Autonomous Base swap preview did not produce a confirmation_summary.")
383
- token = autonomous_permissions.authorize_base_swap(
397
+ raise WalletBackendError("Autonomous preview did not produce a confirmation_summary.")
398
+ if scope == autonomous_permissions.BASE_SWAP_SCOPE:
399
+ token = autonomous_permissions.authorize_base_swap(
400
+ tool_name=tool_name,
401
+ network=network,
402
+ summary=summary,
403
+ )
404
+ else:
405
+ token = autonomous_permissions.authorize_defi_tool(
406
+ tool_name=tool_name,
407
+ network=network,
408
+ summary=summary,
409
+ )
410
+ return token, summary
411
+
412
+ async def _authorize_base_swap_permission(
413
+ self,
414
+ *,
415
+ active_backend: AgentWalletBackend,
416
+ tool_name: str,
417
+ action_label: str,
418
+ preview_kwargs: dict[str, Any],
419
+ preview_method: Any,
420
+ ) -> tuple[str, dict[str, Any]]:
421
+ """Authorize one Base swap through the high-trust permission toggle."""
422
+ from agent_wallet import autonomous_permissions
423
+
424
+ return await self._authorize_autonomous_permission(
425
+ active_backend=active_backend,
384
426
  tool_name=tool_name,
385
- network=network,
386
- summary=summary,
427
+ action_label=action_label,
428
+ preview_kwargs=preview_kwargs,
429
+ preview_method=preview_method,
430
+ scope=autonomous_permissions.BASE_SWAP_SCOPE,
431
+ )
432
+
433
+ async def _authorize_defi_permission(
434
+ self,
435
+ *,
436
+ active_backend: AgentWalletBackend,
437
+ tool_name: str,
438
+ action_label: str,
439
+ preview_kwargs: dict[str, Any],
440
+ preview_method: Any,
441
+ ) -> tuple[str, dict[str, Any]]:
442
+ """Authorize one EVM DeFi operation through the high-trust permission toggle."""
443
+ from agent_wallet import autonomous_permissions
444
+
445
+ return await self._authorize_autonomous_permission(
446
+ active_backend=active_backend,
447
+ tool_name=tool_name,
448
+ action_label=action_label,
449
+ preview_kwargs=preview_kwargs,
450
+ preview_method=preview_method,
451
+ scope=autonomous_permissions.DEFI_TOOLS_SCOPE,
387
452
  )
388
- return token, summary
389
453
 
390
454
  def _require_execute_approval(
391
455
  self,
@@ -1953,7 +2017,7 @@ class OpenClawWalletAdapter:
1953
2017
  description=(
1954
2018
  "Preview, prepare, or execute an ERC-20 or native ETH swap through Velora on supported EVM mainnet networks. "
1955
2019
  "Prepare returns an execution plan only, and execute requires a host-issued approval token bound to the previewed operation "
1956
- "unless high-trust autonomous Base swaps are enabled with scope=base_swaps."
2020
+ "unless the high-trust autonomous permission group is enabled."
1957
2021
  ),
1958
2022
  input_schema={
1959
2023
  "type": "object",
@@ -2109,7 +2173,7 @@ class OpenClawWalletAdapter:
2109
2173
  "Preview, prepare, or execute an ERC-20 or native ETH swap through the Uniswap Trading API "
2110
2174
  "(CLASSIC routing) on ethereum or base. ERC-20 inputs use Permit2 EIP-712 signing automatically. "
2111
2175
  "Prepare returns an execution plan only. Execute requires a host-issued approval token bound to the previewed operation "
2112
- "unless high-trust autonomous Base swaps are enabled with scope=base_swaps."
2176
+ "unless the high-trust autonomous permission group is enabled."
2113
2177
  ),
2114
2178
  input_schema={
2115
2179
  "type": "object",
@@ -3528,7 +3592,7 @@ class OpenClawWalletAdapter:
3528
3592
  name="agentlayer_autonomous_status",
3529
3593
  description=(
3530
3594
  "Return AgentLayer high-trust autonomous permission status. "
3531
- "Currently supports only scope=base_swaps."
3595
+ "The autonomous permission group contains base_swaps and defi_tools."
3532
3596
  ),
3533
3597
  input_schema={
3534
3598
  "type": "object",
@@ -3543,18 +3607,18 @@ class OpenClawWalletAdapter:
3543
3607
  AgentToolSpec(
3544
3608
  name="agentlayer_autonomous_approve",
3545
3609
  description=(
3546
- "Enable high-trust autonomous execution for a narrow scope. "
3547
- "Currently scope=base_swaps lets Base Velora/Uniswap swap execute calls run "
3548
- "without per-transaction human approval until revoked. This does not cover "
3549
- "transfers, withdrawals, lending, staking, bridges, Solana swaps, or non-Base networks."
3610
+ "Enable the high-trust autonomous permission group. The scope parameter is kept "
3611
+ "for compatibility; choosing base_swaps or defi_tools enables both Base swaps and "
3612
+ "supported EVM DeFi management tools until revoked. This does not cover transfers, "
3613
+ "bridges, Solana swaps, or generic contract calls."
3550
3614
  ),
3551
3615
  input_schema={
3552
3616
  "type": "object",
3553
3617
  "properties": {
3554
3618
  "scope": {
3555
3619
  "type": "string",
3556
- "enum": ["base_swaps"],
3557
- "description": "Only base_swaps is currently supported.",
3620
+ "enum": ["base_swaps", "defi_tools"],
3621
+ "description": "Compatibility scope; either value enables the full autonomous permission group.",
3558
3622
  },
3559
3623
  "purpose": {
3560
3624
  "type": "string",
@@ -3576,16 +3640,16 @@ class OpenClawWalletAdapter:
3576
3640
  AgentToolSpec(
3577
3641
  name="agentlayer_autonomous_revoke",
3578
3642
  description=(
3579
- "Disable high-trust autonomous execution for a scope. "
3580
- "Currently supports only scope=base_swaps."
3643
+ "Disable the full high-trust autonomous permission group. "
3644
+ "The scope parameter is kept for compatibility; either value revokes all autonomous permissions."
3581
3645
  ),
3582
3646
  input_schema={
3583
3647
  "type": "object",
3584
3648
  "properties": {
3585
3649
  "scope": {
3586
3650
  "type": "string",
3587
- "enum": ["base_swaps"],
3588
- "description": "Only base_swaps is currently supported.",
3651
+ "enum": ["base_swaps", "defi_tools"],
3652
+ "description": "Compatibility scope; either value revokes the full autonomous permission group.",
3589
3653
  }
3590
3654
  },
3591
3655
  "required": ["scope"],
@@ -3610,7 +3674,7 @@ class OpenClawWalletAdapter:
3610
3674
  name="agentlayer_autonomous_status",
3611
3675
  description=(
3612
3676
  "Return AgentLayer high-trust autonomous permission status. "
3613
- "Currently supports only scope=base_swaps."
3677
+ "The autonomous permission group contains base_swaps and defi_tools."
3614
3678
  ),
3615
3679
  input_schema={
3616
3680
  "type": "object",
@@ -3623,18 +3687,18 @@ class OpenClawWalletAdapter:
3623
3687
  AgentToolSpec(
3624
3688
  name="agentlayer_autonomous_approve",
3625
3689
  description=(
3626
- "Enable high-trust autonomous execution for a narrow scope. "
3627
- "Currently scope=base_swaps lets Base Velora/Uniswap swap execute calls run "
3628
- "without per-transaction human approval until revoked. This does not cover "
3629
- "transfers, withdrawals, lending, staking, bridges, Solana swaps, or non-Base networks."
3690
+ "Enable the high-trust autonomous permission group. The scope parameter is kept "
3691
+ "for compatibility; choosing base_swaps or defi_tools enables both Base swaps and "
3692
+ "supported EVM DeFi management tools until revoked. This does not cover transfers, "
3693
+ "bridges, Solana swaps, or generic contract calls."
3630
3694
  ),
3631
3695
  input_schema={
3632
3696
  "type": "object",
3633
3697
  "properties": {
3634
3698
  "scope": {
3635
3699
  "type": "string",
3636
- "enum": ["base_swaps"],
3637
- "description": "Only base_swaps is currently supported.",
3700
+ "enum": ["base_swaps", "defi_tools"],
3701
+ "description": "Compatibility scope; either value enables the full autonomous permission group.",
3638
3702
  },
3639
3703
  "purpose": {
3640
3704
  "type": "string",
@@ -3654,16 +3718,16 @@ class OpenClawWalletAdapter:
3654
3718
  AgentToolSpec(
3655
3719
  name="agentlayer_autonomous_revoke",
3656
3720
  description=(
3657
- "Disable high-trust autonomous execution for a scope. "
3658
- "Currently supports only scope=base_swaps."
3721
+ "Disable the full high-trust autonomous permission group. "
3722
+ "The scope parameter is kept for compatibility; either value revokes all autonomous permissions."
3659
3723
  ),
3660
3724
  input_schema={
3661
3725
  "type": "object",
3662
3726
  "properties": {
3663
3727
  "scope": {
3664
3728
  "type": "string",
3665
- "enum": ["base_swaps"],
3666
- "description": "Only base_swaps is currently supported.",
3729
+ "enum": ["base_swaps", "defi_tools"],
3730
+ "description": "Compatibility scope; either value revokes the full autonomous permission group.",
3667
3731
  }
3668
3732
  },
3669
3733
  "required": ["scope"],
@@ -3700,30 +3764,33 @@ class OpenClawWalletAdapter:
3700
3764
 
3701
3765
  scope = str(args.get("scope") or "").strip()
3702
3766
  purpose = args.get("purpose")
3703
- if scope != autonomous_permissions.BASE_SWAP_SCOPE:
3704
- raise WalletBackendError("Only scope=base_swaps is currently supported.")
3767
+ if scope not in autonomous_permissions.SUPPORTED_SCOPES:
3768
+ raise WalletBackendError("scope must be one of: base_swaps, defi_tools.")
3705
3769
  if not isinstance(purpose, str) or not purpose.strip():
3706
3770
  raise WalletBackendError("purpose is required.")
3707
3771
  if args.get("user_intent") is not True:
3708
3772
  raise WalletBackendError(
3709
3773
  "agentlayer_autonomous_approve requires user_intent=true after the user explicitly asks for this permission."
3710
3774
  )
3775
+ data = autonomous_permissions.approve_all(
3776
+ approved_by="agentlayer_autonomous_approve"
3777
+ )
3711
3778
  return AgentToolResult(
3712
3779
  tool=tool_name,
3713
3780
  ok=True,
3714
- data=autonomous_permissions.approve_base_swaps(approved_by="agentlayer_autonomous_approve"),
3781
+ data=data,
3715
3782
  )
3716
3783
 
3717
3784
  if tool_name == "agentlayer_autonomous_revoke":
3718
3785
  from agent_wallet import autonomous_permissions
3719
3786
 
3720
3787
  scope = str(args.get("scope") or "").strip()
3721
- if scope != autonomous_permissions.BASE_SWAP_SCOPE:
3722
- raise WalletBackendError("Only scope=base_swaps is currently supported.")
3788
+ if scope not in autonomous_permissions.SUPPORTED_SCOPES:
3789
+ raise WalletBackendError("scope must be one of: base_swaps, defi_tools.")
3723
3790
  return AgentToolResult(
3724
3791
  tool=tool_name,
3725
3792
  ok=True,
3726
- data=autonomous_permissions.revoke_base_swaps(),
3793
+ data=autonomous_permissions.revoke_all(),
3727
3794
  )
3728
3795
 
3729
3796
  if tool_name == "start_autonomous_session":
@@ -4108,16 +4175,26 @@ class OpenClawWalletAdapter:
4108
4175
  ),
4109
4176
  )
4110
4177
 
4111
- approval_payload = inspect_approval_token(
4112
- approval_token,
4113
- tool_name=tool_name,
4114
- network=str(getattr(active_backend, "network", "unknown")),
4115
- require_mainnet_confirmation=self._is_mainnet_for_backend(active_backend),
4116
- )
4117
- approval_summary = approval_payload.get("binding", {}).get("summary")
4118
- if not isinstance(approval_summary, dict):
4119
- raise WalletBackendError(
4120
- "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4178
+ if isinstance(approval_token, str) and approval_token.strip():
4179
+ approval_payload = inspect_approval_token(
4180
+ approval_token,
4181
+ tool_name=tool_name,
4182
+ network=str(getattr(active_backend, "network", "unknown")),
4183
+ require_mainnet_confirmation=self._is_mainnet_for_backend(active_backend),
4184
+ )
4185
+ approval_summary = approval_payload.get("binding", {}).get("summary")
4186
+ if not isinstance(approval_summary, dict):
4187
+ raise WalletBackendError(
4188
+ "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4189
+ )
4190
+ approval_summary_copy = dict(approval_summary)
4191
+ else:
4192
+ approval_token, approval_summary_copy = await self._authorize_defi_permission(
4193
+ active_backend=active_backend,
4194
+ tool_name=tool_name,
4195
+ action_label="EVM Aave V3 operation",
4196
+ preview_kwargs=preview_kwargs,
4197
+ preview_method=active_backend.preview_evm_aave_operation,
4121
4198
  )
4122
4199
  expected_summary = {
4123
4200
  "operation": "EVM Aave V3 operation",
@@ -4127,12 +4204,11 @@ class OpenClawWalletAdapter:
4127
4204
  "amount_raw": amount_raw.strip(),
4128
4205
  }
4129
4206
  for key, expected_value in expected_summary.items():
4130
- if approval_summary.get(key) != expected_value:
4207
+ if approval_summary_copy.get(key) != expected_value:
4131
4208
  raise WalletBackendError(
4132
4209
  "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4133
4210
  )
4134
4211
 
4135
- approval_summary_copy = dict(approval_summary)
4136
4212
  self._require_execute_approval(
4137
4213
  approval_token=approval_token,
4138
4214
  tool_name=tool_name,
@@ -4220,16 +4296,26 @@ class OpenClawWalletAdapter:
4220
4296
  ),
4221
4297
  )
4222
4298
 
4223
- approval_payload = inspect_approval_token(
4224
- approval_token,
4225
- tool_name=tool_name,
4226
- network=str(getattr(active_backend, "network", "unknown")),
4227
- require_mainnet_confirmation=self._is_mainnet_for_backend(active_backend),
4228
- )
4229
- approval_summary = approval_payload.get("binding", {}).get("summary")
4230
- if not isinstance(approval_summary, dict):
4231
- raise WalletBackendError(
4232
- "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4299
+ if isinstance(approval_token, str) and approval_token.strip():
4300
+ approval_payload = inspect_approval_token(
4301
+ approval_token,
4302
+ tool_name=tool_name,
4303
+ network=str(getattr(active_backend, "network", "unknown")),
4304
+ require_mainnet_confirmation=self._is_mainnet_for_backend(active_backend),
4305
+ )
4306
+ approval_summary = approval_payload.get("binding", {}).get("summary")
4307
+ if not isinstance(approval_summary, dict):
4308
+ raise WalletBackendError(
4309
+ "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4310
+ )
4311
+ approval_summary_copy = dict(approval_summary)
4312
+ else:
4313
+ approval_token, approval_summary_copy = await self._authorize_defi_permission(
4314
+ active_backend=active_backend,
4315
+ tool_name=tool_name,
4316
+ action_label="EVM Lido operation",
4317
+ preview_kwargs=preview_kwargs,
4318
+ preview_method=active_backend.preview_evm_lido_operation,
4233
4319
  )
4234
4320
  expected_summary = {
4235
4321
  "operation": "EVM Lido operation",
@@ -4238,12 +4324,11 @@ class OpenClawWalletAdapter:
4238
4324
  "amount_raw": amount_raw.strip(),
4239
4325
  }
4240
4326
  for key, expected_value in expected_summary.items():
4241
- if approval_summary.get(key) != expected_value:
4327
+ if approval_summary_copy.get(key) != expected_value:
4242
4328
  raise WalletBackendError(
4243
4329
  "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4244
4330
  )
4245
4331
 
4246
- approval_summary_copy = dict(approval_summary)
4247
4332
  self._require_execute_approval(
4248
4333
  approval_token=approval_token,
4249
4334
  tool_name=tool_name,
@@ -4347,16 +4432,26 @@ class OpenClawWalletAdapter:
4347
4432
  ),
4348
4433
  )
4349
4434
 
4350
- approval_payload = inspect_approval_token(
4351
- approval_token,
4352
- tool_name=tool_name,
4353
- network=str(getattr(active_backend, "network", "unknown")),
4354
- require_mainnet_confirmation=self._is_mainnet_for_backend(active_backend),
4355
- )
4356
- approval_summary = approval_payload.get("binding", {}).get("summary")
4357
- if not isinstance(approval_summary, dict):
4358
- raise WalletBackendError(
4359
- "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4435
+ if isinstance(approval_token, str) and approval_token.strip():
4436
+ approval_payload = inspect_approval_token(
4437
+ approval_token,
4438
+ tool_name=tool_name,
4439
+ network=str(getattr(active_backend, "network", "unknown")),
4440
+ require_mainnet_confirmation=self._is_mainnet_for_backend(active_backend),
4441
+ )
4442
+ approval_summary = approval_payload.get("binding", {}).get("summary")
4443
+ if not isinstance(approval_summary, dict):
4444
+ raise WalletBackendError(
4445
+ "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4446
+ )
4447
+ approval_summary_copy = dict(approval_summary)
4448
+ else:
4449
+ approval_token, approval_summary_copy = await self._authorize_defi_permission(
4450
+ active_backend=active_backend,
4451
+ tool_name=tool_name,
4452
+ action_label="EVM Lido withdrawal",
4453
+ preview_kwargs=preview_kwargs,
4454
+ preview_method=active_backend.preview_evm_lido_withdrawal,
4360
4455
  )
4361
4456
  expected_summary = {
4362
4457
  "operation": "EVM Lido withdrawal",
@@ -4368,12 +4463,11 @@ class OpenClawWalletAdapter:
4368
4463
  else:
4369
4464
  expected_summary["amount_raw"] = amount_raw.strip()
4370
4465
  for key, expected_value in expected_summary.items():
4371
- if approval_summary.get(key) != expected_value:
4466
+ if approval_summary_copy.get(key) != expected_value:
4372
4467
  raise WalletBackendError(
4373
4468
  "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4374
4469
  )
4375
4470
 
4376
- approval_summary_copy = dict(approval_summary)
4377
4471
  self._require_execute_approval(
4378
4472
  approval_token=approval_token,
4379
4473
  tool_name=tool_name,
@@ -4549,16 +4643,26 @@ class OpenClawWalletAdapter:
4549
4643
  ),
4550
4644
  )
4551
4645
 
4552
- approval_payload = inspect_approval_token(
4553
- approval_token,
4554
- tool_name=tool_name,
4555
- network=str(getattr(active_backend, "network", "unknown")),
4556
- require_mainnet_confirmation=self._is_mainnet_for_backend(active_backend),
4557
- )
4558
- approval_summary = approval_payload.get("binding", {}).get("summary")
4559
- if not isinstance(approval_summary, dict):
4560
- raise WalletBackendError(
4561
- "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4646
+ if isinstance(approval_token, str) and approval_token.strip():
4647
+ approval_payload = inspect_approval_token(
4648
+ approval_token,
4649
+ tool_name=tool_name,
4650
+ network=str(getattr(active_backend, "network", "unknown")),
4651
+ require_mainnet_confirmation=self._is_mainnet_for_backend(active_backend),
4652
+ )
4653
+ approval_summary = approval_payload.get("binding", {}).get("summary")
4654
+ if not isinstance(approval_summary, dict):
4655
+ raise WalletBackendError(
4656
+ "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4657
+ )
4658
+ approval_summary_copy = dict(approval_summary)
4659
+ else:
4660
+ approval_token, approval_summary_copy = await self._authorize_defi_permission(
4661
+ active_backend=active_backend,
4662
+ tool_name=tool_name,
4663
+ action_label="EVM Morpho vault operation",
4664
+ preview_kwargs=preview_kwargs,
4665
+ preview_method=active_backend.preview_evm_morpho_vault_operation,
4562
4666
  )
4563
4667
  expected_summary = {
4564
4668
  "operation": "EVM Morpho vault operation",
@@ -4571,7 +4675,7 @@ class OpenClawWalletAdapter:
4571
4675
  expected_summary["amount_raw"] = amount_raw.strip()
4572
4676
  if isinstance(native_amount_raw, str) and native_amount_raw.strip():
4573
4677
  expected_summary["native_amount_raw"] = native_amount_raw.strip()
4574
- target = approval_summary.get("target")
4678
+ target = approval_summary_copy.get("target")
4575
4679
  if not isinstance(target, dict):
4576
4680
  raise WalletBackendError(
4577
4681
  "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
@@ -4579,7 +4683,7 @@ class OpenClawWalletAdapter:
4579
4683
  expected_target_key = "vaultAddress" if vault_address else "vaultPreset"
4580
4684
  expected_target_value = vault_address.strip() if vault_address else vault_preset.strip()
4581
4685
  for key, expected_value in expected_summary.items():
4582
- if approval_summary.get(key) != expected_value:
4686
+ if approval_summary_copy.get(key) != expected_value:
4583
4687
  raise WalletBackendError(
4584
4688
  "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4585
4689
  )
@@ -4598,7 +4702,6 @@ class OpenClawWalletAdapter:
4598
4702
  "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4599
4703
  )
4600
4704
 
4601
- approval_summary_copy = dict(approval_summary)
4602
4705
  self._require_execute_approval(
4603
4706
  approval_token=approval_token,
4604
4707
  tool_name=tool_name,
@@ -4713,16 +4816,26 @@ class OpenClawWalletAdapter:
4713
4816
  ),
4714
4817
  )
4715
4818
 
4716
- approval_payload = inspect_approval_token(
4717
- approval_token,
4718
- tool_name=tool_name,
4719
- network=str(getattr(active_backend, "network", "unknown")),
4720
- require_mainnet_confirmation=self._is_mainnet_for_backend(active_backend),
4721
- )
4722
- approval_summary = approval_payload.get("binding", {}).get("summary")
4723
- if not isinstance(approval_summary, dict):
4724
- raise WalletBackendError(
4725
- "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4819
+ if isinstance(approval_token, str) and approval_token.strip():
4820
+ approval_payload = inspect_approval_token(
4821
+ approval_token,
4822
+ tool_name=tool_name,
4823
+ network=str(getattr(active_backend, "network", "unknown")),
4824
+ require_mainnet_confirmation=self._is_mainnet_for_backend(active_backend),
4825
+ )
4826
+ approval_summary = approval_payload.get("binding", {}).get("summary")
4827
+ if not isinstance(approval_summary, dict):
4828
+ raise WalletBackendError(
4829
+ "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4830
+ )
4831
+ approval_summary_copy = dict(approval_summary)
4832
+ else:
4833
+ approval_token, approval_summary_copy = await self._authorize_defi_permission(
4834
+ active_backend=active_backend,
4835
+ tool_name=tool_name,
4836
+ action_label="EVM Morpho market operation",
4837
+ preview_kwargs=preview_kwargs,
4838
+ preview_method=active_backend.preview_evm_morpho_market_operation,
4726
4839
  )
4727
4840
  expected_summary = {
4728
4841
  "operation": "EVM Morpho market operation",
@@ -4735,7 +4848,7 @@ class OpenClawWalletAdapter:
4735
4848
  expected_summary["amount_raw"] = amount_raw.strip()
4736
4849
  if isinstance(native_amount_raw, str) and native_amount_raw.strip():
4737
4850
  expected_summary["native_amount_raw"] = native_amount_raw.strip()
4738
- target = approval_summary.get("target")
4851
+ target = approval_summary_copy.get("target")
4739
4852
  if not isinstance(target, dict):
4740
4853
  raise WalletBackendError(
4741
4854
  "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
@@ -4743,7 +4856,7 @@ class OpenClawWalletAdapter:
4743
4856
  expected_target_key = "marketId" if market_id else "marketPreset"
4744
4857
  expected_target_value = market_id.strip() if market_id else market_preset.strip()
4745
4858
  for key, expected_value in expected_summary.items():
4746
- if approval_summary.get(key) != expected_value:
4859
+ if approval_summary_copy.get(key) != expected_value:
4747
4860
  raise WalletBackendError(
4748
4861
  "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4749
4862
  )
@@ -4762,7 +4875,6 @@ class OpenClawWalletAdapter:
4762
4875
  "approval_token does not match the requested operation. Generate a new approval after previewing the exact action."
4763
4876
  )
4764
4877
 
4765
- approval_summary_copy = dict(approval_summary)
4766
4878
  self._require_execute_approval(
4767
4879
  approval_token=approval_token,
4768
4880
  tool_name=tool_name,
@@ -224,21 +224,22 @@ def _run_autonomous_permission(action: str, scope: str) -> dict[str, Any]:
224
224
  from agent_wallet import autonomous_permissions
225
225
 
226
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.")
227
+ if normalized_scope not in autonomous_permissions.SUPPORTED_SCOPES:
228
+ raise WalletBackendError("scope must be one of: base_swaps, defi_tools.")
229
229
 
230
230
  normalized_action = str(action or "").strip().lower()
231
231
  if normalized_action == "approve":
232
+ data = autonomous_permissions.approve_all(approved_by="openclaw_cli")
232
233
  return {
233
234
  "ok": True,
234
235
  "action": normalized_action,
235
- "data": autonomous_permissions.approve_base_swaps(approved_by="openclaw_cli"),
236
+ "data": data,
236
237
  }
237
238
  if normalized_action == "revoke":
238
239
  return {
239
240
  "ok": True,
240
241
  "action": normalized_action,
241
- "data": autonomous_permissions.revoke_base_swaps(),
242
+ "data": autonomous_permissions.revoke_all(),
242
243
  }
243
244
  if normalized_action == "status":
244
245
  return {
@@ -464,7 +465,7 @@ def main() -> int:
464
465
 
465
466
  autonomous_permission_parser = subparsers.add_parser("autonomous-permission")
466
467
  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("--scope", choices=["base_swaps", "defi_tools"], required=True)
468
469
  autonomous_permission_parser.add_argument("--config-json", default="{}")
469
470
 
470
471
  btc_get_parser = subparsers.add_parser("btc-wallet-get")
@@ -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.52",
5
+ "version": "0.1.53",
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.52"
7
+ version = "0.1.53"
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.52",
4
+ "version": "0.1.53",
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"