intentkit 0.6.0.dev17__py3-none-any.whl → 0.6.0.dev18__py3-none-any.whl

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.

Potentially problematic release.


This version of intentkit might be problematic. Click here for more details.

intentkit/__init__.py CHANGED
@@ -3,7 +3,7 @@
3
3
  A powerful platform for building AI agents with blockchain and cryptocurrency capabilities.
4
4
  """
5
5
 
6
- __version__ = "0.6.0-dev.17"
6
+ __version__ = "0.6.0-dev.18"
7
7
  __author__ = "hyacinthus"
8
8
  __email__ = "hyacinthus@gmail.com"
9
9
 
@@ -114,10 +114,8 @@ async def get_skills(
114
114
  for skill in available_skills:
115
115
  if skill == "get_balance":
116
116
  # Get the account object for the custom GetBalance skill
117
- account = await cdp_client.get_account()
118
117
  tools.append(
119
118
  GetBalance(
120
- account=account,
121
119
  agent_id=agent_id,
122
120
  skill_store=store,
123
121
  )
@@ -1,4 +1,4 @@
1
- from typing import Type
1
+ from typing import Optional, Type
2
2
 
3
3
  from cdp import EvmServerAccount
4
4
  from pydantic import BaseModel, Field
@@ -11,8 +11,9 @@ from intentkit.skills.cdp.base import CDPBaseTool
11
11
  class GetBalanceInput(BaseModel):
12
12
  """Input for GetBalance tool."""
13
13
 
14
- asset_id: str = Field(
15
- description="The asset ID to get the balance for (e.g., 'eth', 'usdc', or a valid contract address)"
14
+ asset_id: Optional[str] = Field(
15
+ default=None,
16
+ description="The asset ID to get the balance for (e.g., 'eth', 'usdc', or a valid contract address). If not provided, returns all token balances.",
16
17
  )
17
18
 
18
19
 
@@ -29,69 +30,92 @@ class GetBalance(CDPBaseTool):
29
30
 
30
31
  agent_id: str
31
32
  skill_store: SkillStoreABC
32
- account: EvmServerAccount | None = None
33
33
 
34
34
  name: str = "cdp_get_balance"
35
35
  description: str = (
36
- "This tool will get the balance of all the addresses in the wallet for a given asset. It takes the asset ID as input."
36
+ "This tool will get the balance of all the addresses in the wallet. If asset_id is provided, it returns the balance for that specific asset. "
37
+ "If no asset_id is provided, it returns all token balances. "
37
38
  "Always use 'eth' for the native asset ETH and 'usdc' for USDC. "
38
39
  "Other valid asset IDs are: weth,dai,reth,brett,w,cbeth,axl,iotx,prime,aero,rsr,mog,tbtc,npc,yfi"
39
40
  )
40
41
  args_schema: Type[BaseModel] = GetBalanceInput
41
42
 
42
- async def _arun(self, asset_id: str) -> str:
43
+ async def _arun(self, asset_id: Optional[str] = None) -> str:
43
44
  """Async implementation of the tool to get balance.
44
45
 
45
46
  Args:
46
- asset_id (str): The asset ID to get the balance for.
47
+ asset_id (Optional[str]): The asset ID to get the balance for. If None, returns all token balances.
47
48
 
48
49
  Returns:
49
50
  str: A message containing the balance information or error message.
50
51
  """
51
52
  try:
52
- if not self.account:
53
- return "Failed to get account."
54
-
55
53
  # Get network information from CDP client
56
54
  cdp_client = await get_cdp_client(self.agent_id, self.skill_store)
55
+ provider = await cdp_client.get_wallet_provider()
56
+ account: EvmServerAccount = provider._account
57
57
  provider_config = await cdp_client.get_provider_config()
58
58
  network_id = provider_config.network_id
59
59
 
60
60
  # Map network_id to the format expected by the API
61
61
  network_mapping = {
62
62
  "base-mainnet": "base",
63
- "base-sepolia": "base-sepolia",
64
- "ethereum": "ethereum",
65
63
  "ethereum-mainnet": "ethereum",
66
64
  }
67
65
  api_network = network_mapping.get(network_id, network_id)
68
66
 
67
+ # If no asset_id provided, return all token balances
68
+ if asset_id is None:
69
+ try:
70
+ # Get native ETH balance
71
+ balance_wei = provider.get_balance()
72
+ balance_eth = balance_wei / (10**18) # Convert from wei to ETH
73
+
74
+ # Get all token balances
75
+ token_balances = await account.list_token_balances(api_network)
76
+
77
+ result = [f"ETH balance: {balance_eth} ETH"]
78
+
79
+ for balance in token_balances.balances:
80
+ result.append(
81
+ f"{balance.token.symbol} balance: {balance.amount.decimals} {balance.token.name}"
82
+ )
83
+
84
+ return f"All balances for account {account.address}:\n" + "\n".join(
85
+ result
86
+ )
87
+
88
+ except Exception as e:
89
+ return f"Error getting all balances: {e!s}"
90
+
69
91
  # For native ETH balance, use the account's balance directly
70
92
  if asset_id.lower() == "eth":
71
93
  try:
72
94
  # Get native balance using Web3
73
- balance_wei = await self.account.get_balance()
95
+ balance_wei = provider.get_balance()
74
96
  balance_eth = balance_wei / (10**18) # Convert from wei to ETH
75
- return f"ETH balance for account {self.account.address}: {balance_eth} ETH"
97
+ return (
98
+ f"ETH balance for account {account.address}: {balance_eth} ETH"
99
+ )
76
100
  except Exception as e:
77
101
  return f"Error getting ETH balance: {e!s}"
78
102
 
79
103
  # For other tokens, try the list_token_balances API
80
104
  try:
81
105
  # list_token_balances returns all token balances for the account
82
- token_balances = await self.account.list_token_balances(api_network)
106
+ token_balances = await account.list_token_balances(api_network)
83
107
 
84
108
  # Find the balance for the specific asset
85
109
  target_balance = None
86
- for balance in token_balances:
87
- if balance.asset_id.lower() == asset_id.lower():
110
+ for balance in token_balances.balances:
111
+ if balance.token.symbol.lower() == asset_id.lower():
88
112
  target_balance = balance
89
113
  break
90
114
 
91
115
  if target_balance:
92
- return f"Balance for {asset_id} in account {self.account.address}: {target_balance.amount} {target_balance.asset_id}"
116
+ return f"Balance for {asset_id} in account {account.address}: {target_balance.amount.decimals} {target_balance.token.name}"
93
117
  else:
94
- return f"No balance found for asset {asset_id} in account {self.account.address}"
118
+ return f"No balance found for asset {asset_id} in account {account.address}"
95
119
 
96
120
  except Exception as e:
97
121
  return f"Error getting balance for account: {e!s}"
@@ -99,7 +123,7 @@ class GetBalance(CDPBaseTool):
99
123
  except Exception as e:
100
124
  return f"Error getting balance: {str(e)}"
101
125
 
102
- def _run(self, asset_id: str) -> str:
126
+ def _run(self, asset_id: Optional[str] = None) -> str:
103
127
  """Sync implementation of the tool.
104
128
 
105
129
  This method is deprecated since we now have native async implementation in _arun.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: intentkit
3
- Version: 0.6.0.dev17
3
+ Version: 0.6.0.dev18
4
4
  Summary: Intent-based AI Agent Platform - Core Package
5
5
  Project-URL: Homepage, https://github.com/crestal-network/intentkit
6
6
  Project-URL: Repository, https://github.com/crestal-network/intentkit
@@ -1,4 +1,4 @@
1
- intentkit/__init__.py,sha256=oMztmHNzrAOrgpnkdinwmAhTrI5tdiQ98QZm6WfZWGA,385
1
+ intentkit/__init__.py,sha256=IyGegFUuu3eVl1hNwwS8XT0f62Iz4DMDQmvX6OjejFM,385
2
2
  intentkit/abstracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  intentkit/abstracts/agent.py,sha256=108gb5W8Q1Sy4G55F2_ZFv2-_CnY76qrBtpIr0Oxxqk,1489
4
4
  intentkit/abstracts/api.py,sha256=ZUc24vaQvQVbbjznx7bV0lbbQxdQPfEV8ZxM2R6wZWo,166
@@ -63,10 +63,10 @@ intentkit/skills/carv/fetch_news.py,sha256=-xCWPvdVQxI0tEynR8mnjNEFpDkE4k4vNo1A-
63
63
  intentkit/skills/carv/onchain_query.py,sha256=EYV7N2Y-CisyhNVyUm2NbJhdikeFg0Y_a6lToJ5iqDM,6371
64
64
  intentkit/skills/carv/schema.json,sha256=oSReeG50ZJTOxSRniQBJW6KfilscZfp66PiBVOjphS4,5021
65
65
  intentkit/skills/carv/token_info_and_price.py,sha256=R7M5-nkjrauvxaNkORYtLcP9yOYj8PvYu1xRkOBT6lU,4275
66
- intentkit/skills/cdp/__init__.py,sha256=VTBCyycdxsrrUaM8OZIbJDkEXeLDVun5Lo5a8oBW6mg,4489
66
+ intentkit/skills/cdp/__init__.py,sha256=sBuRJdpCrqDQUY576GCph_VS2vnDTGeBnriSfSv7S3A,4399
67
67
  intentkit/skills/cdp/base.py,sha256=BcleKSXm0oNcHYky4uUPCJ3roXxMeTJs2OUS-8MkfMI,581
68
68
  intentkit/skills/cdp/cdp.png,sha256=dxPF6jPbKVfxJNMvbGTmBhXM-rSDvweF06txoX1cIM4,4425
69
- intentkit/skills/cdp/get_balance.py,sha256=IAsU7mQAPSQqCbYQsokkklsqESEVl82VxMt8dEDJ6cM,4211
69
+ intentkit/skills/cdp/get_balance.py,sha256=pNIOvS8oxl7g01H48bM5IOFwwPaE6htEGSskkXfvV_A,5408
70
70
  intentkit/skills/cdp/schema.json,sha256=3ULPR95TW_Fp2GzzHwmwhAqm8vlxs2tN7fG6WoPY87c,11774
71
71
  intentkit/skills/chainlist/README.md,sha256=FEVQObs2W_oL2kyV-vZpHNwZCCgqm5Kt0sv0GD_Xo1M,958
72
72
  intentkit/skills/chainlist/__init__.py,sha256=2aRC-jXW3WYiR_-RM-_Ls1lby_54ZemZ6qtggntGa-U,1502
@@ -390,7 +390,7 @@ intentkit/utils/random.py,sha256=DymMxu9g0kuQLgJUqalvgksnIeLdS-v0aRk5nQU0mLI,452
390
390
  intentkit/utils/s3.py,sha256=9trQNkKQ5VgxWsewVsV8Y0q_pXzGRvsCYP8xauyUYkg,8549
391
391
  intentkit/utils/slack_alert.py,sha256=s7UpRgyzLW7Pbmt8cKzTJgMA9bm4EP-1rQ5KXayHu6E,2264
392
392
  intentkit/utils/tx.py,sha256=2yLLGuhvfBEY5n_GJ8wmIWLCzn0FsYKv5kRNzw_sLUI,1454
393
- intentkit-0.6.0.dev17.dist-info/METADATA,sha256=ml-xJtWAndVheeiJIfeEz1QKhlerzjoBejx9CXcrK2w,7286
394
- intentkit-0.6.0.dev17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
395
- intentkit-0.6.0.dev17.dist-info/licenses/LICENSE,sha256=Bln6DhK-LtcO4aXy-PBcdZv2f24MlJFm_qn222biJtE,1071
396
- intentkit-0.6.0.dev17.dist-info/RECORD,,
393
+ intentkit-0.6.0.dev18.dist-info/METADATA,sha256=dD_D3EAa1oly7R5V91-hAl22oQqbkwJT-3zT7cht_bU,7286
394
+ intentkit-0.6.0.dev18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
395
+ intentkit-0.6.0.dev18.dist-info/licenses/LICENSE,sha256=Bln6DhK-LtcO4aXy-PBcdZv2f24MlJFm_qn222biJtE,1071
396
+ intentkit-0.6.0.dev18.dist-info/RECORD,,