intentkit 0.7.5.dev23__py3-none-any.whl → 0.7.5.dev25__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/models/llm.py CHANGED
@@ -7,6 +7,7 @@ from enum import Enum
7
7
  from pathlib import Path
8
8
  from typing import Annotated, Any, Optional
9
9
 
10
+ from intentkit.config.config import config
10
11
  from intentkit.models.app_setting import AppSetting
11
12
  from intentkit.models.base import Base
12
13
  from intentkit.models.db import get_session
@@ -346,7 +347,7 @@ class LLMModel(BaseModel):
346
347
  return model_info
347
348
 
348
349
  # This will be implemented by subclasses to return the appropriate LLM instance
349
- async def create_instance(self, config: Any) -> BaseChatModel:
350
+ async def create_instance(self, params: dict[str, Any] = {}) -> BaseChatModel:
350
351
  """Create and return the LLM instance based on the configuration."""
351
352
  raise NotImplementedError("Subclasses must implement create_instance")
352
353
 
@@ -364,7 +365,7 @@ class LLMModel(BaseModel):
364
365
  class OpenAILLM(LLMModel):
365
366
  """OpenAI LLM configuration."""
366
367
 
367
- async def create_instance(self, config: Any) -> BaseChatModel:
368
+ async def create_instance(self, params: dict[str, Any] = {}) -> BaseChatModel:
368
369
  """Create and return a ChatOpenAI instance."""
369
370
  from langchain_openai import ChatOpenAI
370
371
 
@@ -394,6 +395,9 @@ class OpenAILLM(LLMModel):
394
395
  elif self.model_name == "gpt-5":
395
396
  kwargs["reasoning_effort"] = "low"
396
397
 
398
+ # Update kwargs with params to allow overriding
399
+ kwargs.update(params)
400
+
397
401
  logger.debug(f"Creating ChatOpenAI instance with kwargs: {kwargs}")
398
402
 
399
403
  return ChatOpenAI(**kwargs)
@@ -402,7 +406,7 @@ class OpenAILLM(LLMModel):
402
406
  class DeepseekLLM(LLMModel):
403
407
  """Deepseek LLM configuration."""
404
408
 
405
- async def create_instance(self, config: Any) -> BaseChatModel:
409
+ async def create_instance(self, params: dict[str, Any] = {}) -> BaseChatModel:
406
410
  """Create and return a ChatDeepseek instance."""
407
411
 
408
412
  from langchain_deepseek import ChatDeepSeek
@@ -429,13 +433,16 @@ class DeepseekLLM(LLMModel):
429
433
  if info.api_base:
430
434
  kwargs["api_base"] = info.api_base
431
435
 
436
+ # Update kwargs with params to allow overriding
437
+ kwargs.update(params)
438
+
432
439
  return ChatDeepSeek(**kwargs)
433
440
 
434
441
 
435
442
  class XAILLM(LLMModel):
436
443
  """XAI (Grok) LLM configuration."""
437
444
 
438
- async def create_instance(self, config: Any) -> BaseChatModel:
445
+ async def create_instance(self, params: dict[str, Any] = {}) -> BaseChatModel:
439
446
  """Create and return a ChatXAI instance."""
440
447
 
441
448
  from langchain_xai import ChatXAI
@@ -458,8 +465,8 @@ class XAILLM(LLMModel):
458
465
  if info.supports_presence_penalty:
459
466
  kwargs["presence_penalty"] = self.presence_penalty
460
467
 
461
- if self.model_name in ["grok-3", "grok-3-mini"]:
462
- kwargs["search_parameters"] = {"mode": "auto"}
468
+ # Update kwargs with params to allow overriding
469
+ kwargs.update(params)
463
470
 
464
471
  return ChatXAI(**kwargs)
465
472
 
@@ -467,7 +474,7 @@ class XAILLM(LLMModel):
467
474
  class GatewayzLLM(LLMModel):
468
475
  """Gatewayz AI LLM configuration."""
469
476
 
470
- async def create_instance(self, config: Any) -> BaseChatModel:
477
+ async def create_instance(self, params: dict[str, Any] = {}) -> BaseChatModel:
471
478
  """Create and return a ChatOpenAI instance configured for Eternal AI."""
472
479
  from langchain_openai import ChatOpenAI
473
480
 
@@ -478,6 +485,7 @@ class GatewayzLLM(LLMModel):
478
485
  "api_key": config.gatewayz_api_key,
479
486
  "base_url": info.api_base,
480
487
  "timeout": info.timeout,
488
+ "max_completion_tokens": 999,
481
489
  }
482
490
 
483
491
  # Add optional parameters based on model support
@@ -490,13 +498,16 @@ class GatewayzLLM(LLMModel):
490
498
  if info.supports_presence_penalty:
491
499
  kwargs["presence_penalty"] = self.presence_penalty
492
500
 
501
+ # Update kwargs with params to allow overriding
502
+ kwargs.update(params)
503
+
493
504
  return ChatOpenAI(**kwargs)
494
505
 
495
506
 
496
507
  class EternalLLM(LLMModel):
497
508
  """Eternal AI LLM configuration."""
498
509
 
499
- async def create_instance(self, config: Any) -> BaseChatModel:
510
+ async def create_instance(self, params: dict[str, Any] = {}) -> BaseChatModel:
500
511
  """Create and return a ChatOpenAI instance configured for Eternal AI."""
501
512
  from langchain_openai import ChatOpenAI
502
513
 
@@ -522,13 +533,16 @@ class EternalLLM(LLMModel):
522
533
  if info.supports_presence_penalty:
523
534
  kwargs["presence_penalty"] = self.presence_penalty
524
535
 
536
+ # Update kwargs with params to allow overriding
537
+ kwargs.update(params)
538
+
525
539
  return ChatOpenAI(**kwargs)
526
540
 
527
541
 
528
542
  class ReigentLLM(LLMModel):
529
543
  """Reigent LLM configuration."""
530
544
 
531
- async def create_instance(self, config: Any) -> BaseChatModel:
545
+ async def create_instance(self, params: dict[str, Any] = {}) -> BaseChatModel:
532
546
  """Create and return a ChatOpenAI instance configured for Reigent."""
533
547
  from langchain_openai import ChatOpenAI
534
548
 
@@ -544,13 +558,16 @@ class ReigentLLM(LLMModel):
544
558
  },
545
559
  }
546
560
 
561
+ # Update kwargs with params to allow overriding
562
+ kwargs.update(params)
563
+
547
564
  return ChatOpenAI(**kwargs)
548
565
 
549
566
 
550
567
  class VeniceLLM(LLMModel):
551
568
  """Venice LLM configuration."""
552
569
 
553
- async def create_instance(self, config: Any) -> BaseChatModel:
570
+ async def create_instance(self, params: dict[str, Any] = {}) -> BaseChatModel:
554
571
  """Create and return a ChatOpenAI instance configured for Venice."""
555
572
  from langchain_openai import ChatOpenAI
556
573
 
@@ -562,6 +579,9 @@ class VeniceLLM(LLMModel):
562
579
  "timeout": info.timeout,
563
580
  }
564
581
 
582
+ # Update kwargs with params to allow overriding
583
+ kwargs.update(params)
584
+
565
585
  return ChatOpenAI(**kwargs)
566
586
 
567
587
 
intentkit/skills/base.py CHANGED
@@ -1,6 +1,16 @@
1
1
  import logging
2
2
  from collections.abc import Sequence
3
- from typing import Any, Callable, Dict, Literal, NotRequired, Optional, TypedDict, Union
3
+ from typing import (
4
+ TYPE_CHECKING,
5
+ Any,
6
+ Callable,
7
+ Dict,
8
+ Literal,
9
+ NotRequired,
10
+ Optional,
11
+ TypedDict,
12
+ Union,
13
+ )
4
14
 
5
15
  from coinbase_agentkit import (
6
16
  Action,
@@ -21,10 +31,13 @@ from web3 import Web3
21
31
 
22
32
  from intentkit.abstracts.graph import AgentContext
23
33
  from intentkit.abstracts.skill import SkillStoreABC
24
- from intentkit.clients import CdpClient, get_cdp_client
34
+ from intentkit.clients import get_wallet_provider
25
35
  from intentkit.clients.web3 import get_web3_client
26
36
  from intentkit.models.redis import get_redis
27
- from intentkit.utils.error import RateLimitExceeded
37
+ from intentkit.utils.error import IntentKitAPIError, RateLimitExceeded
38
+
39
+ if TYPE_CHECKING:
40
+ from intentkit.models.agent import Agent
28
41
 
29
42
  SkillState = Literal["disabled", "public", "private"]
30
43
  SkillOwnerState = Literal["disabled", "private"]
@@ -175,13 +188,32 @@ class IntentKitSkill(BaseTool):
175
188
 
176
189
  async def get_agentkit_actions(
177
190
  agent_id: str,
178
- store: SkillStoreABC,
191
+ _store: SkillStoreABC,
179
192
  provider_factories: Sequence[Callable[[], object]],
193
+ *,
194
+ agent: Optional["Agent"] = None,
180
195
  ) -> list[Action]:
181
196
  """Build an AgentKit instance and return its actions."""
182
197
 
183
- cdp_client: CdpClient = await get_cdp_client(agent_id, store)
184
- wallet_provider: CdpEvmWalletProvider = await cdp_client.get_wallet_provider()
198
+ if agent is None:
199
+ try:
200
+ context = IntentKitSkill.get_context()
201
+ except ValueError as exc: # pragma: no cover - defensive guard
202
+ raise IntentKitAPIError(
203
+ 500,
204
+ "AgentContextMissing",
205
+ "Agent context is required to initialize AgentKit actions.",
206
+ ) from exc
207
+ agent = context.agent
208
+
209
+ if agent.id != agent_id:
210
+ raise IntentKitAPIError(
211
+ 400,
212
+ "AgentMismatch",
213
+ "The requested agent does not match the active context agent.",
214
+ )
215
+
216
+ wallet_provider: CdpEvmWalletProvider = await get_wallet_provider(agent)
185
217
 
186
218
  agent_kit = AgentKit(
187
219
  AgentKitConfig(
@@ -1,6 +1,6 @@
1
1
  """Basename AgentKit skills."""
2
2
 
3
- from typing import TypedDict
3
+ from typing import TYPE_CHECKING, Optional, TypedDict
4
4
 
5
5
  from coinbase_agentkit import basename_action_provider
6
6
 
@@ -13,6 +13,9 @@ from intentkit.skills.base import (
13
13
  )
14
14
  from intentkit.skills.basename.base import BasenameBaseTool
15
15
 
16
+ if TYPE_CHECKING:
17
+ from intentkit.models.agent import Agent
18
+
16
19
 
17
20
  class SkillStates(TypedDict):
18
21
  BasenameActionProvider_register_basename: SkillState
@@ -29,6 +32,7 @@ async def get_skills(
29
32
  is_private: bool,
30
33
  store: SkillStoreABC,
31
34
  agent_id: str,
35
+ agent: Optional["Agent"] = None,
32
36
  **_,
33
37
  ) -> list[BasenameBaseTool]:
34
38
  """Get all Basename skills."""
@@ -40,7 +44,9 @@ async def get_skills(
40
44
  if state == "public" or (state == "private" and is_private):
41
45
  available_skills.append(skill_name)
42
46
 
43
- actions = await get_agentkit_actions(agent_id, store, [basename_action_provider])
47
+ actions = await get_agentkit_actions(
48
+ agent_id, store, [basename_action_provider], agent=agent
49
+ )
44
50
  tools: list[BasenameBaseTool] = []
45
51
  for skill in available_skills:
46
52
  for action in actions:
@@ -1,6 +1,6 @@
1
1
  """CDP wallet interaction skills."""
2
2
 
3
- from typing import TypedDict
3
+ from typing import TYPE_CHECKING, Optional, TypedDict
4
4
 
5
5
  from coinbase_agentkit import (
6
6
  cdp_api_action_provider,
@@ -17,6 +17,9 @@ from intentkit.skills.base import (
17
17
  )
18
18
  from intentkit.skills.cdp.base import CDPBaseTool
19
19
 
20
+ if TYPE_CHECKING:
21
+ from intentkit.models.agent import Agent
22
+
20
23
 
21
24
  class SkillStates(TypedDict):
22
25
  WalletActionProvider_get_balance: SkillState
@@ -40,6 +43,7 @@ async def get_skills(
40
43
  is_private: bool,
41
44
  store: SkillStoreABC,
42
45
  agent_id: str,
46
+ agent: Optional["Agent"] = None,
43
47
  **_,
44
48
  ) -> list[CDPBaseTool]:
45
49
  """Get all CDP skills.
@@ -71,6 +75,7 @@ async def get_skills(
71
75
  cdp_api_action_provider,
72
76
  cdp_evm_wallet_action_provider,
73
77
  ],
78
+ agent=agent,
74
79
  )
75
80
  tools = []
76
81
  for skill in available_skills:
@@ -7,7 +7,7 @@ from pydantic import BaseModel, Field
7
7
 
8
8
  from intentkit.abstracts.graph import AgentContext
9
9
  from intentkit.abstracts.skill import SkillStoreABC
10
- from intentkit.clients import CdpClient, get_cdp_client
10
+ from intentkit.clients import get_wallet_provider as get_agent_wallet_provider
11
11
  from intentkit.skills.base import IntentKitSkill
12
12
  from intentkit.utils.chain import ChainProvider, Network, network_to_id
13
13
 
@@ -24,9 +24,7 @@ class EnsoBaseTool(IntentKitSkill):
24
24
  description="The skill store for persisting data"
25
25
  )
26
26
 
27
- async def get_wallet_provider(
28
- self, context: AgentContext
29
- ) -> Optional[CdpEvmWalletProvider]:
27
+ async def get_wallet_provider(self, context: AgentContext) -> CdpEvmWalletProvider:
30
28
  """Get the wallet provider from the CDP client.
31
29
 
32
30
  Args:
@@ -35,15 +33,11 @@ class EnsoBaseTool(IntentKitSkill):
35
33
  Returns:
36
34
  Optional[CdpEvmWalletProvider]: The wallet provider if available.
37
35
  """
38
- client: CdpClient = await get_cdp_client(context.agent.id, self.skill_store)
39
- return await client.get_wallet_provider()
36
+ return await get_agent_wallet_provider(context.agent)
40
37
 
41
38
  async def get_wallet_address(self, context: AgentContext) -> str:
42
- client: CdpClient = await get_cdp_client(context.agent.id, self.skill_store)
43
- provider_config = await client.get_provider_config()
44
- if not provider_config.address:
45
- raise ToolException("wallet address not found for agent")
46
- return provider_config.address
39
+ provider: CdpEvmWalletProvider = await self.get_wallet_provider(context)
40
+ return provider.get_address()
47
41
 
48
42
  def get_chain_provider(self, context: AgentContext) -> Optional[ChainProvider]:
49
43
  return self.skill_store.get_system_config("chain_provider")
@@ -184,7 +184,9 @@ class EnsoRouteShortcut(EnsoBaseTool):
184
184
  agent_id = context.agent_id
185
185
  resolved_chain_id = self.resolve_chain_id(context, chainId)
186
186
  api_token = self.get_api_token(context)
187
- wallet_address = await self.get_wallet_address(context)
187
+ # Use the wallet provider to send the transaction
188
+ wallet_provider = await self.get_wallet_provider(context)
189
+ wallet_address = wallet_provider.get_address()
188
190
 
189
191
  async with httpx.AsyncClient() as client:
190
192
  try:
@@ -266,9 +268,6 @@ class EnsoRouteShortcut(EnsoBaseTool):
266
268
  res.amountOut = amount_out
267
269
 
268
270
  if broadcast_requested:
269
- # Use the wallet provider to send the transaction
270
- wallet_provider = await self.get_wallet_provider(context)
271
-
272
271
  # Extract transaction data from the Enso API response
273
272
  tx_data = json_dict.get("tx", {})
274
273
  if tx_data:
@@ -277,7 +276,6 @@ class EnsoRouteShortcut(EnsoBaseTool):
277
276
  "to": tx_data.get("to"),
278
277
  "data": tx_data.get("data", "0x"),
279
278
  "value": tx_data.get("value", 0),
280
- "from": wallet_address,
281
279
  }
282
280
  tx_hash = wallet_provider.send_transaction(tx_params)
283
281
 
@@ -1,6 +1,6 @@
1
1
  """ERC20 AgentKit skills."""
2
2
 
3
- from typing import TypedDict
3
+ from typing import TYPE_CHECKING, Optional, TypedDict
4
4
 
5
5
  from coinbase_agentkit import erc20_action_provider
6
6
 
@@ -13,6 +13,9 @@ from intentkit.skills.base import (
13
13
  )
14
14
  from intentkit.skills.erc20.base import ERC20BaseTool
15
15
 
16
+ if TYPE_CHECKING:
17
+ from intentkit.models.agent import Agent
18
+
16
19
 
17
20
  class SkillStates(TypedDict):
18
21
  ERC20ActionProvider_get_balance: SkillState
@@ -30,6 +33,7 @@ async def get_skills(
30
33
  is_private: bool,
31
34
  store: SkillStoreABC,
32
35
  agent_id: str,
36
+ agent: Optional["Agent"] = None,
33
37
  **_,
34
38
  ) -> list[ERC20BaseTool]:
35
39
  """Get all ERC20 skills."""
@@ -41,7 +45,9 @@ async def get_skills(
41
45
  if state == "public" or (state == "private" and is_private):
42
46
  available_skills.append(skill_name)
43
47
 
44
- actions = await get_agentkit_actions(agent_id, store, [erc20_action_provider])
48
+ actions = await get_agentkit_actions(
49
+ agent_id, store, [erc20_action_provider], agent=agent
50
+ )
45
51
  tools: list[ERC20BaseTool] = []
46
52
  for skill in available_skills:
47
53
  for action in actions:
@@ -1,6 +1,6 @@
1
1
  """ERC721 AgentKit skills."""
2
2
 
3
- from typing import TypedDict
3
+ from typing import TYPE_CHECKING, Optional, TypedDict
4
4
 
5
5
  from coinbase_agentkit import erc721_action_provider
6
6
 
@@ -13,6 +13,9 @@ from intentkit.skills.base import (
13
13
  )
14
14
  from intentkit.skills.erc721.base import ERC721BaseTool
15
15
 
16
+ if TYPE_CHECKING:
17
+ from intentkit.models.agent import Agent
18
+
16
19
 
17
20
  class SkillStates(TypedDict):
18
21
  Erc721ActionProvider_get_balance: SkillState
@@ -31,6 +34,7 @@ async def get_skills(
31
34
  is_private: bool,
32
35
  store: SkillStoreABC,
33
36
  agent_id: str,
37
+ agent: Optional["Agent"] = None,
34
38
  **_,
35
39
  ) -> list[ERC721BaseTool]:
36
40
  """Get all ERC721 skills."""
@@ -42,7 +46,9 @@ async def get_skills(
42
46
  if state == "public" or (state == "private" and is_private):
43
47
  available_skills.append(skill_name)
44
48
 
45
- actions = await get_agentkit_actions(agent_id, store, [erc721_action_provider])
49
+ actions = await get_agentkit_actions(
50
+ agent_id, store, [erc721_action_provider], agent=agent
51
+ )
46
52
  tools: list[ERC721BaseTool] = []
47
53
  for skill in available_skills:
48
54
  for action in actions:
@@ -7,7 +7,8 @@ from pydantic import BaseModel, Field
7
7
  from web3 import Web3
8
8
 
9
9
  from intentkit.abstracts.skill import SkillStoreABC
10
- from intentkit.clients import CdpClient, get_cdp_client
10
+ from intentkit.clients import get_wallet_provider as get_agent_wallet_provider
11
+ from intentkit.models.agent import Agent
11
12
  from intentkit.skills.lifi.base import LiFiBaseTool
12
13
  from intentkit.skills.lifi.token_quote import TokenQuote
13
14
  from intentkit.skills.lifi.utils import (
@@ -130,14 +131,14 @@ class TokenExecute(LiFiBaseTool):
130
131
 
131
132
  # Get agent context for CDP wallet
132
133
  context = self.get_context()
133
- agent_id = context.agent_id
134
+ agent = context.agent
134
135
 
135
136
  self.logger.info(
136
137
  f"Executing LiFi transfer: {from_amount} {from_token} on {from_chain} -> {to_token} on {to_chain}"
137
138
  )
138
139
 
139
140
  # Get CDP wallet provider
140
- cdp_wallet_provider = await self._get_cdp_wallet_provider(agent_id)
141
+ cdp_wallet_provider = await self._get_cdp_wallet_provider(agent)
141
142
  if isinstance(cdp_wallet_provider, str): # Error message
142
143
  return cdp_wallet_provider
143
144
 
@@ -186,15 +187,11 @@ class TokenExecute(LiFiBaseTool):
186
187
  return f"An unexpected error occurred: {str(e)}"
187
188
 
188
189
  async def _get_cdp_wallet_provider(
189
- self, agent_id: str
190
+ self, agent: Agent
190
191
  ) -> CdpEvmWalletProvider | str:
191
192
  """Get CDP wallet provider with error handling."""
192
193
  try:
193
- cdp_client: CdpClient = await get_cdp_client(agent_id, self.skill_store)
194
- if not cdp_client:
195
- return "CDP client not available. Please ensure your agent has CDP wallet configuration."
196
-
197
- cdp_wallet_provider = await cdp_client.get_wallet_provider()
194
+ cdp_wallet_provider = await get_agent_wallet_provider(agent)
198
195
  if not cdp_wallet_provider:
199
196
  return "CDP wallet provider not configured. Please set up your agent's CDP wallet first."
200
197
 
@@ -1,6 +1,6 @@
1
1
  """Morpho AgentKit skills."""
2
2
 
3
- from typing import TypedDict
3
+ from typing import TYPE_CHECKING, Optional, TypedDict
4
4
 
5
5
  from coinbase_agentkit import morpho_action_provider
6
6
 
@@ -13,6 +13,9 @@ from intentkit.skills.base import (
13
13
  )
14
14
  from intentkit.skills.morpho.base import MorphoBaseTool
15
15
 
16
+ if TYPE_CHECKING:
17
+ from intentkit.models.agent import Agent
18
+
16
19
 
17
20
  class SkillStates(TypedDict):
18
21
  MorphoActionProvider_deposit: SkillState
@@ -30,6 +33,7 @@ async def get_skills(
30
33
  is_private: bool,
31
34
  store: SkillStoreABC,
32
35
  agent_id: str,
36
+ agent: Optional["Agent"] = None,
33
37
  **_,
34
38
  ) -> list[MorphoBaseTool]:
35
39
  """Get all Morpho skills."""
@@ -41,7 +45,9 @@ async def get_skills(
41
45
  if state == "public" or (state == "private" and is_private):
42
46
  available_skills.append(skill_name)
43
47
 
44
- actions = await get_agentkit_actions(agent_id, store, [morpho_action_provider])
48
+ actions = await get_agentkit_actions(
49
+ agent_id, store, [morpho_action_provider], agent=agent
50
+ )
45
51
  tools: list[MorphoBaseTool] = []
46
52
  for skill in available_skills:
47
53
  for action in actions:
@@ -1,6 +1,6 @@
1
1
  """Pyth AgentKit skills."""
2
2
 
3
- from typing import TypedDict
3
+ from typing import TYPE_CHECKING, Optional, TypedDict
4
4
 
5
5
  from coinbase_agentkit import pyth_action_provider
6
6
 
@@ -13,6 +13,9 @@ from intentkit.skills.base import (
13
13
  )
14
14
  from intentkit.skills.pyth.base import PythBaseTool
15
15
 
16
+ if TYPE_CHECKING:
17
+ from intentkit.models.agent import Agent
18
+
16
19
 
17
20
  class SkillStates(TypedDict):
18
21
  PythActionProvider_fetch_price: SkillState
@@ -30,6 +33,7 @@ async def get_skills(
30
33
  is_private: bool,
31
34
  store: SkillStoreABC,
32
35
  agent_id: str,
36
+ agent: Optional["Agent"] = None,
33
37
  **_,
34
38
  ) -> list[PythBaseTool]:
35
39
  """Get all Pyth skills."""
@@ -41,7 +45,9 @@ async def get_skills(
41
45
  if state == "public" or (state == "private" and is_private):
42
46
  available_skills.append(skill_name)
43
47
 
44
- actions = await get_agentkit_actions(agent_id, store, [pyth_action_provider])
48
+ actions = await get_agentkit_actions(
49
+ agent_id, store, [pyth_action_provider], agent=agent
50
+ )
45
51
  tools: list[PythBaseTool] = []
46
52
  for skill in available_skills:
47
53
  for action in actions:
@@ -1,6 +1,6 @@
1
1
  """Superfluid AgentKit skills."""
2
2
 
3
- from typing import TypedDict
3
+ from typing import TYPE_CHECKING, Optional, TypedDict
4
4
 
5
5
  from coinbase_agentkit import superfluid_action_provider
6
6
 
@@ -13,6 +13,9 @@ from intentkit.skills.base import (
13
13
  )
14
14
  from intentkit.skills.superfluid.base import SuperfluidBaseTool
15
15
 
16
+ if TYPE_CHECKING:
17
+ from intentkit.models.agent import Agent
18
+
16
19
 
17
20
  class SkillStates(TypedDict):
18
21
  SuperfluidActionProvider_create_flow: SkillState
@@ -31,6 +34,7 @@ async def get_skills(
31
34
  is_private: bool,
32
35
  store: SkillStoreABC,
33
36
  agent_id: str,
37
+ agent: Optional["Agent"] = None,
34
38
  **_,
35
39
  ) -> list[SuperfluidBaseTool]:
36
40
  """Get all Superfluid skills."""
@@ -42,7 +46,9 @@ async def get_skills(
42
46
  if state == "public" or (state == "private" and is_private):
43
47
  available_skills.append(skill_name)
44
48
 
45
- actions = await get_agentkit_actions(agent_id, store, [superfluid_action_provider])
49
+ actions = await get_agentkit_actions(
50
+ agent_id, store, [superfluid_action_provider], agent=agent
51
+ )
46
52
  tools: list[SuperfluidBaseTool] = []
47
53
  for skill in available_skills:
48
54
  for action in actions:
@@ -1,6 +1,6 @@
1
1
  """WETH AgentKit skills."""
2
2
 
3
- from typing import TypedDict
3
+ from typing import TYPE_CHECKING, Optional, TypedDict
4
4
 
5
5
  from coinbase_agentkit import weth_action_provider
6
6
 
@@ -13,6 +13,9 @@ from intentkit.skills.base import (
13
13
  )
14
14
  from intentkit.skills.weth.base import WethBaseTool
15
15
 
16
+ if TYPE_CHECKING:
17
+ from intentkit.models.agent import Agent
18
+
16
19
 
17
20
  class SkillStates(TypedDict):
18
21
  WethActionProvider_wrap_eth: SkillState
@@ -29,6 +32,7 @@ async def get_skills(
29
32
  is_private: bool,
30
33
  store: SkillStoreABC,
31
34
  agent_id: str,
35
+ agent: Optional["Agent"] = None,
32
36
  **_,
33
37
  ) -> list[WethBaseTool]:
34
38
  """Get all WETH skills."""
@@ -40,7 +44,9 @@ async def get_skills(
40
44
  if state == "public" or (state == "private" and is_private):
41
45
  available_skills.append(skill_name)
42
46
 
43
- actions = await get_agentkit_actions(agent_id, store, [weth_action_provider])
47
+ actions = await get_agentkit_actions(
48
+ agent_id, store, [weth_action_provider], agent=agent
49
+ )
44
50
  tools: list[WethBaseTool] = []
45
51
  for skill in available_skills:
46
52
  for action in actions:
@@ -1,6 +1,6 @@
1
1
  """WOW AgentKit skills."""
2
2
 
3
- from typing import TypedDict
3
+ from typing import TYPE_CHECKING, Optional, TypedDict
4
4
 
5
5
  from coinbase_agentkit import wow_action_provider
6
6
 
@@ -13,6 +13,9 @@ from intentkit.skills.base import (
13
13
  )
14
14
  from intentkit.skills.wow.base import WowBaseTool
15
15
 
16
+ if TYPE_CHECKING:
17
+ from intentkit.models.agent import Agent
18
+
16
19
 
17
20
  class SkillStates(TypedDict):
18
21
  WowActionProvider_buy_token: SkillState
@@ -31,6 +34,7 @@ async def get_skills(
31
34
  is_private: bool,
32
35
  store: SkillStoreABC,
33
36
  agent_id: str,
37
+ agent: Optional["Agent"] = None,
34
38
  **_,
35
39
  ) -> list[WowBaseTool]:
36
40
  """Get all WOW skills."""
@@ -42,7 +46,9 @@ async def get_skills(
42
46
  if state == "public" or (state == "private" and is_private):
43
47
  available_skills.append(skill_name)
44
48
 
45
- actions = await get_agentkit_actions(agent_id, store, [wow_action_provider])
49
+ actions = await get_agentkit_actions(
50
+ agent_id, store, [wow_action_provider], agent=agent
51
+ )
46
52
  tools: list[WowBaseTool] = []
47
53
  for skill in available_skills:
48
54
  for action in actions:
@@ -1,5 +1,6 @@
1
1
  from typing import Literal, Type
2
2
 
3
+ from langchain.tools.base import ToolException
3
4
  from pydantic import BaseModel, Field
4
5
 
5
6
  from intentkit.clients.cdp import get_origin_cdp_client
@@ -43,13 +44,13 @@ class XmtpGetSwapPrice(XmtpBaseTool):
43
44
  "optimism-mainnet",
44
45
  ]
45
46
  if agent.network_id not in supported_networks:
46
- raise ValueError(
47
+ raise ToolException(
47
48
  f"Swap price only supported on {', '.join(supported_networks)}. Current: {agent.network_id}"
48
49
  )
49
50
 
50
51
  network_for_cdp = self.get_cdp_network(agent.network_id)
51
52
 
52
- cdp_client = get_origin_cdp_client(self.skill_store)
53
+ cdp_client = get_origin_cdp_client()
53
54
  # Note: Don't use async with context manager as get_origin_cdp_client returns a managed global client
54
55
  price = await cdp_client.evm.get_swap_price(
55
56
  from_token=from_token,