intentkit 0.8.3.dev1__py3-none-any.whl → 0.8.4.dev1__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.8.3-dev1"
6
+ __version__ = "0.8.4-dev1"
7
7
  __author__ = "hyacinthus"
8
8
  __email__ = "hyacinthus@gmail.com"
9
9
 
@@ -14,12 +14,16 @@ from tweepy.asynchronous import AsyncClient
14
14
  from intentkit.abstracts.skill import SkillStoreABC
15
15
  from intentkit.abstracts.twitter import TwitterABC
16
16
  from intentkit.models.agent_data import AgentData
17
+ from intentkit.models.redis import get_redis
17
18
 
18
19
  logger = logging.getLogger(__name__)
19
20
 
20
21
  _clients_linked: Dict[str, "TwitterClient"] = {}
21
22
  _clients_self_key: Dict[str, "TwitterClient"] = {}
22
23
 
24
+ _VERIFIER_KEY = "intentkit:twitter:code_verifier"
25
+ _CHALLENGE_KEY = "intentkit:twitter:code_challenge"
26
+
23
27
 
24
28
  class TwitterMedia(BaseModel):
25
29
  """Model representing Twitter media from the API response."""
@@ -460,17 +464,33 @@ class OAuth2UserHandler(OAuth2Session):
460
464
  self.auth = HTTPBasicAuth(client_id, client_secret)
461
465
  else:
462
466
  self.auth = None
463
- self.code_challenge = self._client.create_code_challenge(
464
- self._client.create_code_verifier(128), "S256"
465
- )
467
+ self.code_verifier = None
468
+ self.code_challenge = None
466
469
 
467
- def get_authorization_url(self, agent_id: str, redirect_uri: str):
470
+ async def get_authorization_url(self, agent_id: str, redirect_uri: str):
468
471
  """Get the authorization URL to redirect the user to
469
472
 
470
473
  Args:
471
474
  agent_id: ID of the agent to authenticate
472
475
  redirect_uri: URI to redirect to after authorization
473
476
  """
477
+ if not self.code_challenge:
478
+ try:
479
+ kv = await get_redis()
480
+ self.code_verifier = await kv.get(_VERIFIER_KEY)
481
+ self.code_challenge = await kv.get(_CHALLENGE_KEY)
482
+ if not self.code_verifier or not self.code_challenge:
483
+ self.code_verifier = self._client.create_code_verifier(128)
484
+ self.code_challenge = self._client.create_code_challenge(
485
+ self.code_verifier, "S256"
486
+ )
487
+ await kv.set(_VERIFIER_KEY, self.code_verifier)
488
+ await kv.set(_CHALLENGE_KEY, self.code_challenge)
489
+ except Exception:
490
+ self.code_verifier = self._client.create_code_verifier(128)
491
+ self.code_challenge = self._client.create_code_challenge(
492
+ self.code_verifier, "S256"
493
+ )
474
494
  state_params = {"agent_id": agent_id, "redirect_uri": redirect_uri}
475
495
  authorization_url, _ = self.authorization_url(
476
496
  "https://x.com/i/oauth2/authorize",
@@ -484,12 +504,14 @@ class OAuth2UserHandler(OAuth2Session):
484
504
  """After user has authorized the app, fetch access token with
485
505
  authorization response URL
486
506
  """
507
+ if not self.code_verifier or not self.code_challenge:
508
+ raise ValueError("Code verifier or challenge not init")
487
509
  return super().fetch_token(
488
510
  "https://api.x.com/2/oauth2/token",
489
511
  authorization_response=authorization_response,
490
512
  auth=self.auth,
491
513
  include_client_id=True,
492
- code_verifier=self._client.code_verifier,
514
+ code_verifier=self.code_verifier,
493
515
  )
494
516
 
495
517
  def refresh(self, refresh_token: str):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: intentkit
3
- Version: 0.8.3.dev1
3
+ Version: 0.8.4.dev1
4
4
  Summary: Intent-based AI Agent Platform - Core Package
5
5
  Project-URL: Homepage, https://github.com/crestalnetwork/intentkit
6
6
  Project-URL: Repository, https://github.com/crestalnetwork/intentkit
@@ -1,4 +1,4 @@
1
- intentkit/__init__.py,sha256=X3lzpQ9Ui-DnUm-ZaFAwV218O0GxVL1s-uAfKkfWrx8,383
1
+ intentkit/__init__.py,sha256=H3JaJdipEXP0-g9i1fDZCm6H9kLUaOrD8cup28qRNEU,383
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
@@ -8,7 +8,7 @@ intentkit/abstracts/skill.py,sha256=cIJ6BkASD31U1IEkE8rdAawq99w_xsg0lt3oalqa1ZA,
8
8
  intentkit/abstracts/twitter.py,sha256=cEtP7ygR_b-pHdc9i8kBuyooz1cPoGUGwsBHDpowJyY,1262
9
9
  intentkit/clients/__init__.py,sha256=YmXSif963E5rUfkfHaI6JdWRFU5yNa_yJwafs2KEIVo,406
10
10
  intentkit/clients/cdp.py,sha256=eUsy8r9zSHzogATyHLcm5pOn771gUI4gH3Mt0Jq-shQ,5392
11
- intentkit/clients/twitter.py,sha256=Lfa7srHOFnY96SXcElW0jfg7XKS_WliWnXjPZEe6SQc,18976
11
+ intentkit/clients/twitter.py,sha256=2g2XGbTISGOcQYk5K7J5BzPdwqCfhts9YZmGhJAeOLY,20094
12
12
  intentkit/clients/web3.py,sha256=iFjjingL9Aqh3kwUUKN8Tw5N66o2SE_bfo6OhqI-6SU,890
13
13
  intentkit/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  intentkit/config/config.py,sha256=kw9F-uLsJd-knCKmYNb-hqR7x7HUXUkNg5FZCgOPH54,8868
@@ -451,7 +451,7 @@ intentkit/utils/random.py,sha256=DymMxu9g0kuQLgJUqalvgksnIeLdS-v0aRk5nQU0mLI,452
451
451
  intentkit/utils/s3.py,sha256=A8Nsx5QJyLsxhj9g7oHNy2-m24tjQUhC9URm8Qb1jFw,10057
452
452
  intentkit/utils/slack_alert.py,sha256=s7UpRgyzLW7Pbmt8cKzTJgMA9bm4EP-1rQ5KXayHu6E,2264
453
453
  intentkit/utils/tx.py,sha256=2yLLGuhvfBEY5n_GJ8wmIWLCzn0FsYKv5kRNzw_sLUI,1454
454
- intentkit-0.8.3.dev1.dist-info/METADATA,sha256=qLfgW3gQU-2Hd-SYATFdxAh5Syvh8-iwN_X8ILB8Ro8,6315
455
- intentkit-0.8.3.dev1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
456
- intentkit-0.8.3.dev1.dist-info/licenses/LICENSE,sha256=Bln6DhK-LtcO4aXy-PBcdZv2f24MlJFm_qn222biJtE,1071
457
- intentkit-0.8.3.dev1.dist-info/RECORD,,
454
+ intentkit-0.8.4.dev1.dist-info/METADATA,sha256=7Z8AFR59QiXFEek8GCxgW6ua22J0LvelZomL_2Yx1V8,6315
455
+ intentkit-0.8.4.dev1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
456
+ intentkit-0.8.4.dev1.dist-info/licenses/LICENSE,sha256=Bln6DhK-LtcO4aXy-PBcdZv2f24MlJFm_qn222biJtE,1071
457
+ intentkit-0.8.4.dev1.dist-info/RECORD,,