intentkit 0.7.5.dev3__py3-none-any.whl → 0.8.34.dev7__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.
Files changed (393) hide show
  1. intentkit/MANIFEST.in +14 -0
  2. intentkit/README.md +88 -0
  3. intentkit/__init__.py +6 -4
  4. intentkit/abstracts/agent.py +4 -5
  5. intentkit/abstracts/engine.py +5 -5
  6. intentkit/abstracts/graph.py +15 -8
  7. intentkit/abstracts/skill.py +6 -144
  8. intentkit/abstracts/twitter.py +4 -5
  9. intentkit/clients/__init__.py +9 -2
  10. intentkit/clients/cdp.py +129 -153
  11. intentkit/{utils → clients}/s3.py +109 -34
  12. intentkit/clients/twitter.py +83 -62
  13. intentkit/clients/web3.py +4 -7
  14. intentkit/config/config.py +123 -90
  15. intentkit/core/account_checking.py +802 -0
  16. intentkit/core/agent.py +313 -498
  17. intentkit/core/asset.py +267 -0
  18. intentkit/core/chat.py +5 -3
  19. intentkit/core/client.py +1 -1
  20. intentkit/core/credit.py +49 -41
  21. intentkit/core/draft.py +201 -0
  22. intentkit/core/draft_chat.py +118 -0
  23. intentkit/core/engine.py +378 -287
  24. intentkit/core/manager/__init__.py +25 -0
  25. intentkit/core/manager/engine.py +220 -0
  26. intentkit/core/manager/service.py +172 -0
  27. intentkit/core/manager/skills.py +178 -0
  28. intentkit/core/middleware.py +231 -0
  29. intentkit/core/prompt.py +74 -114
  30. intentkit/core/scheduler.py +143 -0
  31. intentkit/core/statistics.py +168 -0
  32. intentkit/models/agent.py +931 -518
  33. intentkit/models/agent_data.py +165 -106
  34. intentkit/models/agent_schema.json +38 -251
  35. intentkit/models/app_setting.py +15 -13
  36. intentkit/models/chat.py +86 -140
  37. intentkit/models/credit.py +182 -162
  38. intentkit/models/db.py +42 -23
  39. intentkit/models/db_mig.py +120 -3
  40. intentkit/models/draft.py +222 -0
  41. intentkit/models/llm.csv +31 -0
  42. intentkit/models/llm.py +262 -370
  43. intentkit/models/redis.py +6 -4
  44. intentkit/models/skill.py +222 -101
  45. intentkit/models/skills.csv +173 -0
  46. intentkit/models/team.py +189 -0
  47. intentkit/models/user.py +103 -31
  48. intentkit/skills/acolyt/__init__.py +2 -9
  49. intentkit/skills/acolyt/ask.py +3 -4
  50. intentkit/skills/acolyt/base.py +4 -9
  51. intentkit/skills/acolyt/schema.json +4 -3
  52. intentkit/skills/aixbt/__init__.py +2 -13
  53. intentkit/skills/aixbt/base.py +1 -7
  54. intentkit/skills/aixbt/projects.py +14 -15
  55. intentkit/skills/aixbt/schema.json +4 -4
  56. intentkit/skills/allora/__init__.py +2 -9
  57. intentkit/skills/allora/base.py +4 -9
  58. intentkit/skills/allora/price.py +3 -4
  59. intentkit/skills/allora/schema.json +3 -2
  60. intentkit/skills/base.py +241 -41
  61. intentkit/skills/basename/__init__.py +51 -0
  62. intentkit/skills/basename/base.py +11 -0
  63. intentkit/skills/basename/basename.svg +11 -0
  64. intentkit/skills/basename/schema.json +58 -0
  65. intentkit/skills/carv/__init__.py +115 -121
  66. intentkit/skills/carv/base.py +184 -185
  67. intentkit/skills/carv/fetch_news.py +3 -3
  68. intentkit/skills/carv/onchain_query.py +4 -4
  69. intentkit/skills/carv/schema.json +134 -137
  70. intentkit/skills/carv/token_info_and_price.py +6 -6
  71. intentkit/skills/casino/__init__.py +4 -15
  72. intentkit/skills/casino/base.py +1 -7
  73. intentkit/skills/casino/deck_draw.py +5 -8
  74. intentkit/skills/casino/deck_shuffle.py +6 -6
  75. intentkit/skills/casino/dice_roll.py +2 -4
  76. intentkit/skills/casino/schema.json +0 -1
  77. intentkit/skills/cdp/__init__.py +22 -84
  78. intentkit/skills/cdp/base.py +1 -7
  79. intentkit/skills/cdp/schema.json +11 -314
  80. intentkit/skills/chainlist/__init__.py +2 -7
  81. intentkit/skills/chainlist/base.py +1 -7
  82. intentkit/skills/chainlist/chain_lookup.py +18 -18
  83. intentkit/skills/chainlist/schema.json +3 -5
  84. intentkit/skills/common/__init__.py +2 -9
  85. intentkit/skills/common/base.py +1 -7
  86. intentkit/skills/common/current_time.py +1 -2
  87. intentkit/skills/common/schema.json +2 -2
  88. intentkit/skills/cookiefun/__init__.py +6 -9
  89. intentkit/skills/cookiefun/base.py +2 -7
  90. intentkit/skills/cookiefun/get_account_details.py +7 -7
  91. intentkit/skills/cookiefun/get_account_feed.py +19 -19
  92. intentkit/skills/cookiefun/get_account_smart_followers.py +7 -7
  93. intentkit/skills/cookiefun/get_sectors.py +3 -3
  94. intentkit/skills/cookiefun/schema.json +1 -3
  95. intentkit/skills/cookiefun/search_accounts.py +9 -9
  96. intentkit/skills/cryptocompare/__init__.py +7 -24
  97. intentkit/skills/cryptocompare/api.py +2 -3
  98. intentkit/skills/cryptocompare/base.py +10 -24
  99. intentkit/skills/cryptocompare/fetch_news.py +4 -5
  100. intentkit/skills/cryptocompare/fetch_price.py +6 -7
  101. intentkit/skills/cryptocompare/fetch_top_exchanges.py +4 -5
  102. intentkit/skills/cryptocompare/fetch_top_market_cap.py +4 -5
  103. intentkit/skills/cryptocompare/fetch_top_volume.py +4 -5
  104. intentkit/skills/cryptocompare/fetch_trading_signals.py +5 -6
  105. intentkit/skills/cryptocompare/schema.json +3 -3
  106. intentkit/skills/cryptopanic/__init__.py +7 -10
  107. intentkit/skills/cryptopanic/base.py +51 -55
  108. intentkit/skills/cryptopanic/fetch_crypto_news.py +4 -8
  109. intentkit/skills/cryptopanic/fetch_crypto_sentiment.py +5 -7
  110. intentkit/skills/cryptopanic/schema.json +105 -103
  111. intentkit/skills/dapplooker/__init__.py +2 -9
  112. intentkit/skills/dapplooker/base.py +4 -9
  113. intentkit/skills/dapplooker/dapplooker_token_data.py +7 -7
  114. intentkit/skills/dapplooker/schema.json +3 -5
  115. intentkit/skills/defillama/__init__.py +24 -74
  116. intentkit/skills/defillama/api.py +6 -9
  117. intentkit/skills/defillama/base.py +8 -19
  118. intentkit/skills/defillama/coins/fetch_batch_historical_prices.py +8 -10
  119. intentkit/skills/defillama/coins/fetch_block.py +6 -8
  120. intentkit/skills/defillama/coins/fetch_current_prices.py +8 -10
  121. intentkit/skills/defillama/coins/fetch_first_price.py +7 -9
  122. intentkit/skills/defillama/coins/fetch_historical_prices.py +9 -11
  123. intentkit/skills/defillama/coins/fetch_price_chart.py +9 -11
  124. intentkit/skills/defillama/coins/fetch_price_percentage.py +7 -9
  125. intentkit/skills/defillama/config/chains.py +1 -3
  126. intentkit/skills/defillama/fees/fetch_fees_overview.py +24 -26
  127. intentkit/skills/defillama/schema.json +5 -1
  128. intentkit/skills/defillama/stablecoins/fetch_stablecoin_chains.py +16 -18
  129. intentkit/skills/defillama/stablecoins/fetch_stablecoin_charts.py +8 -10
  130. intentkit/skills/defillama/stablecoins/fetch_stablecoin_prices.py +5 -7
  131. intentkit/skills/defillama/stablecoins/fetch_stablecoins.py +7 -9
  132. intentkit/skills/defillama/tests/api_integration.test.py +1 -1
  133. intentkit/skills/defillama/tvl/fetch_chain_historical_tvl.py +4 -6
  134. intentkit/skills/defillama/tvl/fetch_chains.py +9 -11
  135. intentkit/skills/defillama/tvl/fetch_historical_tvl.py +4 -6
  136. intentkit/skills/defillama/tvl/fetch_protocol.py +32 -38
  137. intentkit/skills/defillama/tvl/fetch_protocol_current_tvl.py +3 -5
  138. intentkit/skills/defillama/tvl/fetch_protocols.py +37 -45
  139. intentkit/skills/defillama/volumes/fetch_dex_overview.py +42 -48
  140. intentkit/skills/defillama/volumes/fetch_dex_summary.py +35 -37
  141. intentkit/skills/defillama/volumes/fetch_options_overview.py +24 -28
  142. intentkit/skills/defillama/yields/fetch_pool_chart.py +10 -12
  143. intentkit/skills/defillama/yields/fetch_pools.py +26 -30
  144. intentkit/skills/dexscreener/__init__.py +97 -102
  145. intentkit/skills/dexscreener/base.py +125 -130
  146. intentkit/skills/dexscreener/get_pair_info.py +4 -5
  147. intentkit/skills/dexscreener/get_token_pairs.py +4 -5
  148. intentkit/skills/dexscreener/get_tokens_info.py +7 -8
  149. intentkit/skills/dexscreener/model/search_token_response.py +80 -82
  150. intentkit/skills/dexscreener/schema.json +91 -93
  151. intentkit/skills/dexscreener/search_token.py +182 -184
  152. intentkit/skills/dexscreener/utils.py +15 -14
  153. intentkit/skills/dune_analytics/__init__.py +7 -9
  154. intentkit/skills/dune_analytics/base.py +48 -52
  155. intentkit/skills/dune_analytics/fetch_kol_buys.py +5 -7
  156. intentkit/skills/dune_analytics/fetch_nation_metrics.py +6 -8
  157. intentkit/skills/dune_analytics/schema.json +104 -99
  158. intentkit/skills/elfa/__init__.py +5 -18
  159. intentkit/skills/elfa/base.py +10 -14
  160. intentkit/skills/elfa/mention.py +19 -21
  161. intentkit/skills/elfa/schema.json +3 -2
  162. intentkit/skills/elfa/stats.py +4 -4
  163. intentkit/skills/elfa/tokens.py +12 -12
  164. intentkit/skills/elfa/utils.py +26 -28
  165. intentkit/skills/enso/__init__.py +11 -31
  166. intentkit/skills/enso/base.py +54 -35
  167. intentkit/skills/enso/best_yield.py +16 -24
  168. intentkit/skills/enso/networks.py +6 -11
  169. intentkit/skills/enso/prices.py +11 -13
  170. intentkit/skills/enso/route.py +34 -38
  171. intentkit/skills/enso/schema.json +3 -2
  172. intentkit/skills/enso/tokens.py +29 -38
  173. intentkit/skills/enso/wallet.py +76 -191
  174. intentkit/skills/erc20/__init__.py +50 -0
  175. intentkit/skills/erc20/base.py +11 -0
  176. intentkit/skills/erc20/erc20.svg +5 -0
  177. intentkit/skills/erc20/schema.json +74 -0
  178. intentkit/skills/erc721/__init__.py +53 -0
  179. intentkit/skills/erc721/base.py +11 -0
  180. intentkit/skills/erc721/erc721.svg +5 -0
  181. intentkit/skills/erc721/schema.json +90 -0
  182. intentkit/skills/firecrawl/__init__.py +5 -18
  183. intentkit/skills/firecrawl/base.py +4 -9
  184. intentkit/skills/firecrawl/clear.py +4 -8
  185. intentkit/skills/firecrawl/crawl.py +19 -19
  186. intentkit/skills/firecrawl/query.py +4 -3
  187. intentkit/skills/firecrawl/schema.json +2 -6
  188. intentkit/skills/firecrawl/scrape.py +17 -22
  189. intentkit/skills/firecrawl/utils.py +50 -42
  190. intentkit/skills/github/__init__.py +2 -7
  191. intentkit/skills/github/base.py +1 -7
  192. intentkit/skills/github/github_search.py +1 -2
  193. intentkit/skills/github/schema.json +3 -4
  194. intentkit/skills/heurist/__init__.py +8 -27
  195. intentkit/skills/heurist/base.py +4 -9
  196. intentkit/skills/heurist/image_generation_animagine_xl.py +13 -15
  197. intentkit/skills/heurist/image_generation_arthemy_comics.py +13 -15
  198. intentkit/skills/heurist/image_generation_arthemy_real.py +13 -15
  199. intentkit/skills/heurist/image_generation_braindance.py +13 -15
  200. intentkit/skills/heurist/image_generation_cyber_realistic_xl.py +13 -15
  201. intentkit/skills/heurist/image_generation_flux_1_dev.py +13 -15
  202. intentkit/skills/heurist/image_generation_sdxl.py +13 -15
  203. intentkit/skills/heurist/schema.json +2 -2
  204. intentkit/skills/http/__init__.py +4 -15
  205. intentkit/skills/http/base.py +1 -7
  206. intentkit/skills/http/get.py +21 -16
  207. intentkit/skills/http/post.py +23 -18
  208. intentkit/skills/http/put.py +23 -18
  209. intentkit/skills/http/schema.json +4 -5
  210. intentkit/skills/lifi/__init__.py +8 -13
  211. intentkit/skills/lifi/base.py +3 -9
  212. intentkit/skills/lifi/schema.json +17 -8
  213. intentkit/skills/lifi/token_execute.py +150 -60
  214. intentkit/skills/lifi/token_quote.py +8 -10
  215. intentkit/skills/lifi/utils.py +104 -51
  216. intentkit/skills/moralis/__init__.py +6 -10
  217. intentkit/skills/moralis/api.py +6 -7
  218. intentkit/skills/moralis/base.py +5 -10
  219. intentkit/skills/moralis/fetch_chain_portfolio.py +10 -11
  220. intentkit/skills/moralis/fetch_nft_portfolio.py +22 -22
  221. intentkit/skills/moralis/fetch_solana_portfolio.py +11 -12
  222. intentkit/skills/moralis/fetch_wallet_portfolio.py +8 -9
  223. intentkit/skills/moralis/schema.json +7 -2
  224. intentkit/skills/morpho/__init__.py +52 -0
  225. intentkit/skills/morpho/base.py +11 -0
  226. intentkit/skills/morpho/morpho.svg +12 -0
  227. intentkit/skills/morpho/schema.json +73 -0
  228. intentkit/skills/nation/__init__.py +4 -9
  229. intentkit/skills/nation/base.py +5 -10
  230. intentkit/skills/nation/nft_check.py +3 -4
  231. intentkit/skills/nation/schema.json +4 -3
  232. intentkit/skills/onchain.py +30 -0
  233. intentkit/skills/openai/__init__.py +17 -18
  234. intentkit/skills/openai/base.py +10 -14
  235. intentkit/skills/openai/dalle_image_generation.py +4 -9
  236. intentkit/skills/openai/gpt_avatar_generator.py +102 -0
  237. intentkit/skills/openai/gpt_image_generation.py +5 -9
  238. intentkit/skills/openai/gpt_image_mini_generator.py +92 -0
  239. intentkit/skills/openai/gpt_image_to_image.py +5 -9
  240. intentkit/skills/openai/image_to_text.py +3 -7
  241. intentkit/skills/openai/schema.json +34 -3
  242. intentkit/skills/portfolio/__init__.py +11 -35
  243. intentkit/skills/portfolio/base.py +33 -19
  244. intentkit/skills/portfolio/schema.json +3 -5
  245. intentkit/skills/portfolio/token_balances.py +21 -21
  246. intentkit/skills/portfolio/wallet_approvals.py +17 -18
  247. intentkit/skills/portfolio/wallet_defi_positions.py +3 -3
  248. intentkit/skills/portfolio/wallet_history.py +31 -31
  249. intentkit/skills/portfolio/wallet_net_worth.py +13 -13
  250. intentkit/skills/portfolio/wallet_nfts.py +19 -19
  251. intentkit/skills/portfolio/wallet_profitability.py +18 -18
  252. intentkit/skills/portfolio/wallet_profitability_summary.py +5 -5
  253. intentkit/skills/portfolio/wallet_stats.py +3 -3
  254. intentkit/skills/portfolio/wallet_swaps.py +19 -19
  255. intentkit/skills/pyth/__init__.py +50 -0
  256. intentkit/skills/pyth/base.py +11 -0
  257. intentkit/skills/pyth/pyth.svg +6 -0
  258. intentkit/skills/pyth/schema.json +75 -0
  259. intentkit/skills/skills.toml +36 -0
  260. intentkit/skills/slack/__init__.py +5 -17
  261. intentkit/skills/slack/base.py +3 -9
  262. intentkit/skills/slack/get_channel.py +8 -8
  263. intentkit/skills/slack/get_message.py +9 -9
  264. intentkit/skills/slack/schedule_message.py +5 -5
  265. intentkit/skills/slack/schema.json +2 -2
  266. intentkit/skills/slack/send_message.py +3 -5
  267. intentkit/skills/supabase/__init__.py +7 -23
  268. intentkit/skills/supabase/base.py +1 -7
  269. intentkit/skills/supabase/delete_data.py +4 -4
  270. intentkit/skills/supabase/fetch_data.py +12 -12
  271. intentkit/skills/supabase/insert_data.py +4 -4
  272. intentkit/skills/supabase/invoke_function.py +6 -6
  273. intentkit/skills/supabase/schema.json +2 -3
  274. intentkit/skills/supabase/update_data.py +6 -6
  275. intentkit/skills/supabase/upsert_data.py +4 -4
  276. intentkit/skills/superfluid/__init__.py +53 -0
  277. intentkit/skills/superfluid/base.py +11 -0
  278. intentkit/skills/superfluid/schema.json +89 -0
  279. intentkit/skills/superfluid/superfluid.svg +6 -0
  280. intentkit/skills/system/__init__.py +7 -24
  281. intentkit/skills/system/add_autonomous_task.py +10 -12
  282. intentkit/skills/system/delete_autonomous_task.py +2 -2
  283. intentkit/skills/system/edit_autonomous_task.py +14 -18
  284. intentkit/skills/system/list_autonomous_tasks.py +3 -5
  285. intentkit/skills/system/read_agent_api_key.py +6 -4
  286. intentkit/skills/system/regenerate_agent_api_key.py +6 -4
  287. intentkit/skills/system/schema.json +6 -8
  288. intentkit/skills/tavily/__init__.py +3 -12
  289. intentkit/skills/tavily/base.py +4 -9
  290. intentkit/skills/tavily/schema.json +3 -5
  291. intentkit/skills/tavily/tavily_extract.py +2 -4
  292. intentkit/skills/tavily/tavily_search.py +4 -6
  293. intentkit/skills/token/__init__.py +5 -10
  294. intentkit/skills/token/base.py +7 -11
  295. intentkit/skills/token/erc20_transfers.py +19 -19
  296. intentkit/skills/token/schema.json +3 -6
  297. intentkit/skills/token/token_analytics.py +3 -3
  298. intentkit/skills/token/token_price.py +13 -13
  299. intentkit/skills/token/token_search.py +9 -9
  300. intentkit/skills/twitter/__init__.py +11 -35
  301. intentkit/skills/twitter/base.py +22 -34
  302. intentkit/skills/twitter/follow_user.py +2 -6
  303. intentkit/skills/twitter/get_mentions.py +5 -12
  304. intentkit/skills/twitter/get_timeline.py +4 -12
  305. intentkit/skills/twitter/get_user_by_username.py +2 -6
  306. intentkit/skills/twitter/get_user_tweets.py +5 -13
  307. intentkit/skills/twitter/like_tweet.py +2 -6
  308. intentkit/skills/twitter/post_tweet.py +6 -9
  309. intentkit/skills/twitter/reply_tweet.py +6 -9
  310. intentkit/skills/twitter/retweet.py +2 -6
  311. intentkit/skills/twitter/schema.json +1 -0
  312. intentkit/skills/twitter/search_tweets.py +4 -12
  313. intentkit/skills/unrealspeech/__init__.py +2 -7
  314. intentkit/skills/unrealspeech/base.py +2 -8
  315. intentkit/skills/unrealspeech/schema.json +2 -5
  316. intentkit/skills/unrealspeech/text_to_speech.py +8 -8
  317. intentkit/skills/venice_audio/__init__.py +98 -106
  318. intentkit/skills/venice_audio/base.py +117 -121
  319. intentkit/skills/venice_audio/input.py +41 -41
  320. intentkit/skills/venice_audio/schema.json +151 -152
  321. intentkit/skills/venice_audio/venice_audio.py +38 -21
  322. intentkit/skills/venice_image/__init__.py +147 -154
  323. intentkit/skills/venice_image/api.py +138 -138
  324. intentkit/skills/venice_image/base.py +185 -192
  325. intentkit/skills/venice_image/config.py +33 -35
  326. intentkit/skills/venice_image/image_enhance/image_enhance.py +2 -3
  327. intentkit/skills/venice_image/image_enhance/image_enhance_base.py +21 -23
  328. intentkit/skills/venice_image/image_enhance/image_enhance_input.py +38 -40
  329. intentkit/skills/venice_image/image_generation/image_generation_base.py +11 -10
  330. intentkit/skills/venice_image/image_generation/image_generation_fluently_xl.py +26 -26
  331. intentkit/skills/venice_image/image_generation/image_generation_flux_dev.py +27 -27
  332. intentkit/skills/venice_image/image_generation/image_generation_flux_dev_uncensored.py +26 -26
  333. intentkit/skills/venice_image/image_generation/image_generation_input.py +158 -158
  334. intentkit/skills/venice_image/image_generation/image_generation_lustify_sdxl.py +26 -26
  335. intentkit/skills/venice_image/image_generation/image_generation_pony_realism.py +26 -26
  336. intentkit/skills/venice_image/image_generation/image_generation_stable_diffusion_3_5.py +28 -28
  337. intentkit/skills/venice_image/image_generation/image_generation_venice_sd35.py +28 -28
  338. intentkit/skills/venice_image/image_upscale/image_upscale.py +3 -3
  339. intentkit/skills/venice_image/image_upscale/image_upscale_base.py +21 -23
  340. intentkit/skills/venice_image/image_upscale/image_upscale_input.py +22 -22
  341. intentkit/skills/venice_image/image_vision/image_vision.py +2 -2
  342. intentkit/skills/venice_image/image_vision/image_vision_base.py +17 -17
  343. intentkit/skills/venice_image/image_vision/image_vision_input.py +9 -9
  344. intentkit/skills/venice_image/schema.json +267 -267
  345. intentkit/skills/venice_image/utils.py +77 -78
  346. intentkit/skills/web_scraper/__init__.py +5 -18
  347. intentkit/skills/web_scraper/base.py +21 -7
  348. intentkit/skills/web_scraper/document_indexer.py +7 -6
  349. intentkit/skills/web_scraper/schema.json +2 -6
  350. intentkit/skills/web_scraper/scrape_and_index.py +15 -15
  351. intentkit/skills/web_scraper/utils.py +62 -63
  352. intentkit/skills/web_scraper/website_indexer.py +17 -19
  353. intentkit/skills/weth/__init__.py +49 -0
  354. intentkit/skills/weth/base.py +11 -0
  355. intentkit/skills/weth/schema.json +58 -0
  356. intentkit/skills/weth/weth.svg +6 -0
  357. intentkit/skills/wow/__init__.py +51 -0
  358. intentkit/skills/wow/base.py +11 -0
  359. intentkit/skills/wow/schema.json +89 -0
  360. intentkit/skills/wow/wow.svg +7 -0
  361. intentkit/skills/x402/__init__.py +58 -0
  362. intentkit/skills/x402/base.py +99 -0
  363. intentkit/skills/x402/http_request.py +117 -0
  364. intentkit/skills/x402/schema.json +40 -0
  365. intentkit/skills/x402/x402.webp +0 -0
  366. intentkit/skills/xmtp/__init__.py +4 -15
  367. intentkit/skills/xmtp/base.py +5 -5
  368. intentkit/skills/xmtp/price.py +7 -6
  369. intentkit/skills/xmtp/schema.json +69 -71
  370. intentkit/skills/xmtp/swap.py +6 -8
  371. intentkit/skills/xmtp/transfer.py +4 -6
  372. intentkit/utils/__init__.py +4 -0
  373. intentkit/utils/chain.py +198 -96
  374. intentkit/utils/ens.py +135 -0
  375. intentkit/utils/error.py +5 -2
  376. intentkit/utils/logging.py +9 -11
  377. intentkit/utils/schema.py +100 -0
  378. intentkit/utils/slack_alert.py +8 -8
  379. intentkit/utils/tx.py +16 -8
  380. intentkit/uv.lock +3377 -0
  381. {intentkit-0.7.5.dev3.dist-info → intentkit-0.8.34.dev7.dist-info}/METADATA +13 -15
  382. intentkit-0.8.34.dev7.dist-info/RECORD +478 -0
  383. intentkit-0.8.34.dev7.dist-info/licenses/LICENSE +21 -0
  384. intentkit/core/node.py +0 -215
  385. intentkit/models/conversation.py +0 -286
  386. intentkit/models/generator.py +0 -347
  387. intentkit/skills/cdp/get_balance.py +0 -110
  388. intentkit/skills/cdp/swap.py +0 -121
  389. intentkit/skills/moralis/tests/__init__.py +0 -0
  390. intentkit/skills/moralis/tests/test_wallet.py +0 -511
  391. intentkit-0.7.5.dev3.dist-info/RECORD +0 -424
  392. {intentkit-0.7.5.dev3.dist-info/licenses → intentkit}/LICENSE +0 -0
  393. {intentkit-0.7.5.dev3.dist-info → intentkit-0.8.34.dev7.dist-info}/WHEEL +0 -0
@@ -1,19 +1,15 @@
1
1
  import logging
2
- from datetime import datetime, timezone
2
+ from datetime import UTC, datetime
3
3
  from decimal import ROUND_HALF_UP, Decimal
4
4
  from enum import Enum
5
- from typing import Annotated, Any, Dict, List, Optional, Tuple
5
+ from typing import Annotated, Any
6
6
 
7
7
  from epyxid import XID
8
8
  from fastapi import HTTPException
9
- from intentkit.models.app_setting import AppSetting
10
- from intentkit.models.base import Base
11
- from intentkit.models.db import get_session
12
9
  from pydantic import BaseModel, ConfigDict, Field, field_validator
13
10
  from sqlalchemy import (
14
11
  ARRAY,
15
12
  JSON,
16
- Column,
17
13
  DateTime,
18
14
  Index,
19
15
  Numeric,
@@ -23,6 +19,12 @@ from sqlalchemy import (
23
19
  update,
24
20
  )
25
21
  from sqlalchemy.ext.asyncio import AsyncSession
22
+ from sqlalchemy.orm import Mapped, mapped_column
23
+
24
+ from intentkit.models.app_setting import AppSetting
25
+ from intentkit.models.base import Base
26
+ from intentkit.models.db import get_session
27
+ from intentkit.utils.error import IntentKitAPIError
26
28
 
27
29
  logger = logging.getLogger(__name__)
28
30
 
@@ -43,6 +45,7 @@ class OwnerType(str, Enum):
43
45
 
44
46
  USER = "user"
45
47
  AGENT = "agent"
48
+ TEAM = "team"
46
49
  PLATFORM = "platform"
47
50
 
48
51
 
@@ -69,106 +72,106 @@ class CreditAccountTable(Base):
69
72
  __tablename__ = "credit_accounts"
70
73
  __table_args__ = (Index("ix_credit_accounts_owner", "owner_type", "owner_id"),)
71
74
 
72
- id = Column(
75
+ id: Mapped[str] = mapped_column(
73
76
  String,
74
77
  primary_key=True,
75
78
  )
76
- owner_type = Column(
79
+ owner_type: Mapped[str] = mapped_column(
77
80
  String,
78
81
  nullable=False,
79
82
  )
80
- owner_id = Column(
83
+ owner_id: Mapped[str] = mapped_column(
81
84
  String,
82
85
  nullable=False,
83
86
  )
84
- free_quota = Column(
87
+ free_quota: Mapped[Decimal] = mapped_column(
85
88
  Numeric(22, 4),
86
89
  default=0,
87
90
  nullable=False,
88
91
  )
89
- refill_amount = Column(
92
+ refill_amount: Mapped[Decimal] = mapped_column(
90
93
  Numeric(22, 4),
91
94
  default=0,
92
95
  nullable=False,
93
96
  )
94
- free_credits = Column(
97
+ free_credits: Mapped[Decimal] = mapped_column(
95
98
  Numeric(22, 4),
96
99
  default=0,
97
100
  nullable=False,
98
101
  )
99
- reward_credits = Column(
102
+ reward_credits: Mapped[Decimal] = mapped_column(
100
103
  Numeric(22, 4),
101
104
  default=0,
102
105
  nullable=False,
103
106
  )
104
- credits = Column(
107
+ credits: Mapped[Decimal] = mapped_column(
105
108
  Numeric(22, 4),
106
109
  default=0,
107
110
  nullable=False,
108
111
  )
109
- income_at = Column(
112
+ income_at: Mapped[datetime | None] = mapped_column(
110
113
  DateTime(timezone=True),
111
114
  nullable=True,
112
115
  )
113
- expense_at = Column(
116
+ expense_at: Mapped[datetime | None] = mapped_column(
114
117
  DateTime(timezone=True),
115
118
  nullable=True,
116
119
  )
117
- last_event_id = Column(
120
+ last_event_id: Mapped[str | None] = mapped_column(
118
121
  String,
119
122
  nullable=True,
120
123
  )
121
124
  # Total statistics fields
122
- total_income = Column(
125
+ total_income: Mapped[Decimal] = mapped_column(
123
126
  Numeric(22, 4),
124
127
  default=0,
125
128
  nullable=False,
126
129
  )
127
- total_free_income = Column(
130
+ total_free_income: Mapped[Decimal] = mapped_column(
128
131
  Numeric(22, 4),
129
132
  default=0,
130
133
  nullable=False,
131
134
  )
132
- total_reward_income = Column(
135
+ total_reward_income: Mapped[Decimal] = mapped_column(
133
136
  Numeric(22, 4),
134
137
  default=0,
135
138
  nullable=False,
136
139
  )
137
- total_permanent_income = Column(
140
+ total_permanent_income: Mapped[Decimal] = mapped_column(
138
141
  Numeric(22, 4),
139
142
  default=0,
140
143
  nullable=False,
141
144
  )
142
- total_expense = Column(
145
+ total_expense: Mapped[Decimal] = mapped_column(
143
146
  Numeric(22, 4),
144
147
  default=0,
145
148
  nullable=False,
146
149
  )
147
- total_free_expense = Column(
150
+ total_free_expense: Mapped[Decimal] = mapped_column(
148
151
  Numeric(22, 4),
149
152
  default=0,
150
153
  nullable=False,
151
154
  )
152
- total_reward_expense = Column(
155
+ total_reward_expense: Mapped[Decimal] = mapped_column(
153
156
  Numeric(22, 4),
154
157
  default=0,
155
158
  nullable=False,
156
159
  )
157
- total_permanent_expense = Column(
160
+ total_permanent_expense: Mapped[Decimal] = mapped_column(
158
161
  Numeric(22, 4),
159
162
  default=0,
160
163
  nullable=False,
161
164
  )
162
- created_at = Column(
165
+ created_at: Mapped[datetime] = mapped_column(
163
166
  DateTime(timezone=True),
164
167
  nullable=False,
165
168
  server_default=func.now(),
166
169
  )
167
- updated_at = Column(
170
+ updated_at: Mapped[datetime] = mapped_column(
168
171
  DateTime(timezone=True),
169
172
  nullable=False,
170
173
  server_default=func.now(),
171
- onupdate=lambda: datetime.now(timezone.utc),
174
+ onupdate=lambda: datetime.now(UTC),
172
175
  )
173
176
 
174
177
 
@@ -220,15 +223,15 @@ class CreditAccount(BaseModel):
220
223
  Field(default=Decimal("0"), description="Credits added through top-ups"),
221
224
  ]
222
225
  income_at: Annotated[
223
- Optional[datetime],
226
+ datetime | None,
224
227
  Field(None, description="Timestamp of the last income transaction"),
225
228
  ]
226
229
  expense_at: Annotated[
227
- Optional[datetime],
230
+ datetime | None,
228
231
  Field(None, description="Timestamp of the last expense transaction"),
229
232
  ]
230
233
  last_event_id: Annotated[
231
- Optional[str],
234
+ str | None,
232
235
  Field(None, description="ID of the last event that modified this account"),
233
236
  ]
234
237
  # Total statistics fields
@@ -315,7 +318,7 @@ class CreditAccount(BaseModel):
315
318
  """Round decimal values to 4 decimal places."""
316
319
  if isinstance(v, Decimal):
317
320
  return v.quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
318
- elif isinstance(v, (int, float)):
321
+ elif isinstance(v, int | float):
319
322
  return Decimal(str(v)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
320
323
  return v
321
324
 
@@ -347,7 +350,11 @@ class CreditAccount(BaseModel):
347
350
  )
348
351
  result = await session.scalar(stmt)
349
352
  if not result:
350
- raise HTTPException(status_code=404, detail="Credit account not found")
353
+ raise IntentKitAPIError(
354
+ status_code=404,
355
+ key="CreditAccountNotFound",
356
+ message="Credit account not found",
357
+ )
351
358
  return cls.model_validate(result)
352
359
 
353
360
  @classmethod
@@ -408,7 +415,7 @@ class CreditAccount(BaseModel):
408
415
  owner_id: str,
409
416
  credit_type: CreditType,
410
417
  amount: Decimal,
411
- event_id: Optional[str] = None,
418
+ event_id: str | None = None,
412
419
  ) -> "CreditAccount":
413
420
  """Deduct credits from an account. Not checking balance"""
414
421
  # check first, create if not exists
@@ -419,7 +426,7 @@ class CreditAccount(BaseModel):
419
426
  values_dict = {
420
427
  credit_type.value: getattr(CreditAccountTable, credit_type.value)
421
428
  - quantized_amount,
422
- "expense_at": datetime.now(timezone.utc),
429
+ "expense_at": datetime.now(UTC),
423
430
  # Update total expense statistics
424
431
  "total_expense": CreditAccountTable.total_expense + quantized_amount,
425
432
  }
@@ -451,7 +458,11 @@ class CreditAccount(BaseModel):
451
458
  )
452
459
  res = await session.scalar(stmt)
453
460
  if not res:
454
- raise HTTPException(status_code=500, detail="Failed to expense credits")
461
+ raise IntentKitAPIError(
462
+ status_code=500,
463
+ key="CreditExpenseFailed",
464
+ message="Failed to expense credits",
465
+ )
455
466
  return cls.model_validate(res)
456
467
 
457
468
  @classmethod
@@ -461,8 +472,8 @@ class CreditAccount(BaseModel):
461
472
  owner_type: OwnerType,
462
473
  owner_id: str,
463
474
  amount: Decimal,
464
- event_id: Optional[str] = None,
465
- ) -> Tuple["CreditAccount", Dict[CreditType, Decimal]]:
475
+ event_id: str | None = None,
476
+ ) -> tuple["CreditAccount", dict[CreditType, Decimal]]:
466
477
  """Expense credits and return account and credit type.
467
478
  We are not checking balance here, since a conversation may have
468
479
  multiple expenses, we can't interrupt the conversation.
@@ -497,7 +508,7 @@ class CreditAccount(BaseModel):
497
508
 
498
509
  # Create values dict based on what's in details, defaulting to 0 for missing keys
499
510
  values_dict = {
500
- "expense_at": datetime.now(timezone.utc),
511
+ "expense_at": datetime.now(UTC),
501
512
  }
502
513
  if event_id:
503
514
  values_dict["last_event_id"] = event_id
@@ -548,7 +559,11 @@ class CreditAccount(BaseModel):
548
559
  )
549
560
  res = await session.scalar(stmt)
550
561
  if not res:
551
- raise HTTPException(status_code=500, detail="Failed to expense credits")
562
+ raise IntentKitAPIError(
563
+ status_code=500,
564
+ key="CreditExpenseFailed",
565
+ message="Failed to expense credits",
566
+ )
552
567
  return cls.model_validate(res), details
553
568
 
554
569
  def has_sufficient_credits(self, amount: Decimal) -> bool:
@@ -568,14 +583,14 @@ class CreditAccount(BaseModel):
568
583
  session: AsyncSession,
569
584
  owner_type: OwnerType,
570
585
  owner_id: str,
571
- amount_details: Dict[CreditType, Decimal],
572
- event_id: Optional[str] = None,
586
+ amount_details: dict[CreditType, Decimal],
587
+ event_id: str | None = None,
573
588
  ) -> "CreditAccount":
574
589
  # check first, create if not exists
575
590
  await cls.get_or_create_in_session(session, owner_type, owner_id)
576
591
  # income
577
592
  values_dict = {
578
- "income_at": datetime.now(timezone.utc),
593
+ "income_at": datetime.now(UTC),
579
594
  }
580
595
  if event_id:
581
596
  values_dict["last_event_id"] = event_id
@@ -633,8 +648,8 @@ class CreditAccount(BaseModel):
633
648
  session: AsyncSession,
634
649
  owner_type: OwnerType,
635
650
  owner_id: str,
636
- free_quota: Optional[Decimal] = None,
637
- refill_amount: Optional[Decimal] = None,
651
+ free_quota: Decimal | None = None,
652
+ refill_amount: Decimal | None = None,
638
653
  ) -> "CreditAccount":
639
654
  """Get an existing credit account or create a new one if it doesn't exist.
640
655
 
@@ -674,7 +689,7 @@ class CreditAccount(BaseModel):
674
689
  free_credits=free_quota,
675
690
  reward_credits=0.0,
676
691
  credits=0.0,
677
- income_at=datetime.now(timezone.utc),
692
+ income_at=datetime.now(UTC),
678
693
  expense_at=None,
679
694
  last_event_id=event_id if owner_type == OwnerType.USER else None,
680
695
  # Initialize new statistics fields
@@ -768,8 +783,8 @@ class CreditAccount(BaseModel):
768
783
  cls,
769
784
  session: AsyncSession,
770
785
  user_id: str,
771
- free_quota: Optional[Decimal] = None,
772
- refill_amount: Optional[Decimal] = None,
786
+ free_quota: Decimal | None = None,
787
+ refill_amount: Decimal | None = None,
773
788
  upstream_tx_id: str = "",
774
789
  note: str = "",
775
790
  ) -> "CreditAccount":
@@ -912,199 +927,203 @@ class CreditEventTable(Base):
912
927
  Index("ix_credit_events_created_at", "created_at"),
913
928
  )
914
929
 
915
- id = Column(
930
+ id: Mapped[str] = mapped_column(
916
931
  String,
917
932
  primary_key=True,
918
933
  )
919
- account_id = Column(
934
+ account_id: Mapped[str] = mapped_column(
920
935
  String,
921
936
  nullable=False,
922
937
  )
923
- event_type = Column(
938
+ event_type: Mapped[str] = mapped_column(
924
939
  String,
925
940
  nullable=False,
926
941
  )
927
- user_id = Column(
942
+ user_id: Mapped[str | None] = mapped_column(
928
943
  String,
929
944
  nullable=True,
930
945
  )
931
- upstream_type = Column(
946
+ team_id: Mapped[str | None] = mapped_column(
947
+ String,
948
+ nullable=True,
949
+ )
950
+ upstream_type: Mapped[str] = mapped_column(
932
951
  String,
933
952
  nullable=False,
934
953
  )
935
- upstream_tx_id = Column(
954
+ upstream_tx_id: Mapped[str] = mapped_column(
936
955
  String,
937
956
  nullable=False,
938
957
  )
939
- agent_id = Column(
958
+ agent_id: Mapped[str | None] = mapped_column(
940
959
  String,
941
960
  nullable=True,
942
961
  )
943
- agent_wallet_address = Column(
962
+ agent_wallet_address: Mapped[str | None] = mapped_column(
944
963
  String,
945
964
  nullable=True,
946
965
  )
947
- start_message_id = Column(
966
+ start_message_id: Mapped[str | None] = mapped_column(
948
967
  String,
949
968
  nullable=True,
950
969
  )
951
- message_id = Column(
970
+ message_id: Mapped[str | None] = mapped_column(
952
971
  String,
953
972
  nullable=True,
954
973
  )
955
- model = Column(
974
+ model: Mapped[str | None] = mapped_column(
956
975
  String,
957
976
  nullable=True,
958
977
  )
959
- skill_call_id = Column(
978
+ skill_call_id: Mapped[str | None] = mapped_column(
960
979
  String,
961
980
  nullable=True,
962
981
  )
963
- skill_name = Column(
982
+ skill_name: Mapped[str | None] = mapped_column(
964
983
  String,
965
984
  nullable=True,
966
985
  )
967
- direction = Column(
986
+ direction: Mapped[str] = mapped_column(
968
987
  String,
969
988
  nullable=False,
970
989
  )
971
- total_amount = Column(
990
+ total_amount: Mapped[Decimal] = mapped_column(
972
991
  Numeric(22, 4),
973
992
  default=0,
974
993
  nullable=False,
975
994
  )
976
- credit_type = Column(
995
+ credit_type: Mapped[str] = mapped_column(
977
996
  String,
978
997
  nullable=False,
979
998
  )
980
- credit_types = Column(
999
+ credit_types: Mapped[list[str] | None] = mapped_column(
981
1000
  JSON().with_variant(ARRAY(String), "postgresql"),
982
1001
  nullable=True,
983
1002
  )
984
- balance_after = Column(
1003
+ balance_after: Mapped[Decimal | None] = mapped_column(
985
1004
  Numeric(22, 4),
986
1005
  nullable=True,
987
1006
  default=None,
988
1007
  )
989
- base_amount = Column(
1008
+ base_amount: Mapped[Decimal] = mapped_column(
990
1009
  Numeric(22, 4),
991
1010
  default=0,
992
1011
  nullable=False,
993
1012
  )
994
- base_discount_amount = Column(
1013
+ base_discount_amount: Mapped[Decimal | None] = mapped_column(
995
1014
  Numeric(22, 4),
996
1015
  default=0,
997
1016
  nullable=True,
998
1017
  )
999
- base_original_amount = Column(
1018
+ base_original_amount: Mapped[Decimal | None] = mapped_column(
1000
1019
  Numeric(22, 4),
1001
1020
  default=0,
1002
1021
  nullable=True,
1003
1022
  )
1004
- base_llm_amount = Column(
1023
+ base_llm_amount: Mapped[Decimal | None] = mapped_column(
1005
1024
  Numeric(22, 4),
1006
1025
  default=0,
1007
1026
  nullable=True,
1008
1027
  )
1009
- base_skill_amount = Column(
1028
+ base_skill_amount: Mapped[Decimal | None] = mapped_column(
1010
1029
  Numeric(22, 4),
1011
1030
  default=0,
1012
1031
  nullable=True,
1013
1032
  )
1014
- base_free_amount = Column(
1033
+ base_free_amount: Mapped[Decimal | None] = mapped_column(
1015
1034
  Numeric(22, 4),
1016
1035
  default=0,
1017
1036
  nullable=True,
1018
1037
  )
1019
- base_reward_amount = Column(
1038
+ base_reward_amount: Mapped[Decimal | None] = mapped_column(
1020
1039
  Numeric(22, 4),
1021
1040
  default=0,
1022
1041
  nullable=True,
1023
1042
  )
1024
- base_permanent_amount = Column(
1043
+ base_permanent_amount: Mapped[Decimal | None] = mapped_column(
1025
1044
  Numeric(22, 4),
1026
1045
  default=0,
1027
1046
  nullable=True,
1028
1047
  )
1029
- fee_platform_amount = Column(
1048
+ fee_platform_amount: Mapped[Decimal | None] = mapped_column(
1030
1049
  Numeric(22, 4),
1031
1050
  default=0,
1032
1051
  nullable=True,
1033
1052
  )
1034
- fee_platform_free_amount = Column(
1053
+ fee_platform_free_amount: Mapped[Decimal | None] = mapped_column(
1035
1054
  Numeric(22, 4),
1036
1055
  nullable=True,
1037
1056
  )
1038
- fee_platform_reward_amount = Column(
1057
+ fee_platform_reward_amount: Mapped[Decimal | None] = mapped_column(
1039
1058
  Numeric(22, 4),
1040
1059
  nullable=True,
1041
1060
  )
1042
- fee_platform_permanent_amount = Column(
1061
+ fee_platform_permanent_amount: Mapped[Decimal | None] = mapped_column(
1043
1062
  Numeric(22, 4),
1044
1063
  nullable=True,
1045
1064
  )
1046
- fee_dev_account = Column(
1065
+ fee_dev_account: Mapped[str | None] = mapped_column(
1047
1066
  String,
1048
1067
  nullable=True,
1049
1068
  )
1050
- fee_dev_amount = Column(
1069
+ fee_dev_amount: Mapped[Decimal | None] = mapped_column(
1051
1070
  Numeric(22, 4),
1052
1071
  default=0,
1053
1072
  nullable=True,
1054
1073
  )
1055
- fee_dev_free_amount = Column(
1074
+ fee_dev_free_amount: Mapped[Decimal | None] = mapped_column(
1056
1075
  Numeric(22, 4),
1057
1076
  nullable=True,
1058
1077
  )
1059
- fee_dev_reward_amount = Column(
1078
+ fee_dev_reward_amount: Mapped[Decimal | None] = mapped_column(
1060
1079
  Numeric(22, 4),
1061
1080
  nullable=True,
1062
1081
  )
1063
- fee_dev_permanent_amount = Column(
1082
+ fee_dev_permanent_amount: Mapped[Decimal | None] = mapped_column(
1064
1083
  Numeric(22, 4),
1065
1084
  nullable=True,
1066
1085
  )
1067
- fee_agent_account = Column(
1086
+ fee_agent_account: Mapped[str | None] = mapped_column(
1068
1087
  String,
1069
1088
  nullable=True,
1070
1089
  )
1071
- fee_agent_amount = Column(
1090
+ fee_agent_amount: Mapped[Decimal | None] = mapped_column(
1072
1091
  Numeric(22, 4),
1073
1092
  default=0,
1074
1093
  nullable=True,
1075
1094
  )
1076
- fee_agent_free_amount = Column(
1095
+ fee_agent_free_amount: Mapped[Decimal | None] = mapped_column(
1077
1096
  Numeric(22, 4),
1078
1097
  nullable=True,
1079
1098
  )
1080
- fee_agent_reward_amount = Column(
1099
+ fee_agent_reward_amount: Mapped[Decimal | None] = mapped_column(
1081
1100
  Numeric(22, 4),
1082
1101
  nullable=True,
1083
1102
  )
1084
- fee_agent_permanent_amount = Column(
1103
+ fee_agent_permanent_amount: Mapped[Decimal | None] = mapped_column(
1085
1104
  Numeric(22, 4),
1086
1105
  nullable=True,
1087
1106
  )
1088
- free_amount = Column(
1107
+ free_amount: Mapped[Decimal | None] = mapped_column(
1089
1108
  Numeric(22, 4),
1090
1109
  default=0,
1091
1110
  nullable=True,
1092
1111
  )
1093
- reward_amount = Column(
1112
+ reward_amount: Mapped[Decimal | None] = mapped_column(
1094
1113
  Numeric(22, 4),
1095
1114
  default=0,
1096
1115
  nullable=True,
1097
1116
  )
1098
- permanent_amount = Column(
1117
+ permanent_amount: Mapped[Decimal | None] = mapped_column(
1099
1118
  Numeric(22, 4),
1100
1119
  default=0,
1101
1120
  nullable=True,
1102
1121
  )
1103
- note = Column(
1122
+ note: Mapped[str | None] = mapped_column(
1104
1123
  String,
1105
1124
  nullable=True,
1106
1125
  )
1107
- created_at = Column(
1126
+ created_at: Mapped[datetime] = mapped_column(
1108
1127
  DateTime(timezone=True),
1109
1128
  nullable=False,
1110
1129
  server_default=func.now(),
@@ -1134,34 +1153,37 @@ class CreditEvent(BaseModel):
1134
1153
  ]
1135
1154
  event_type: Annotated[EventType, Field(description="Type of the event")]
1136
1155
  user_id: Annotated[
1137
- Optional[str], Field(None, description="ID of the user if applicable")
1156
+ str | None, Field(None, description="ID of the user if applicable")
1157
+ ]
1158
+ team_id: Annotated[
1159
+ str | None, Field(None, description="ID of the team if applicable")
1138
1160
  ]
1139
1161
  upstream_type: Annotated[
1140
1162
  UpstreamType, Field(description="Type of upstream transaction")
1141
1163
  ]
1142
1164
  upstream_tx_id: Annotated[str, Field(description="Upstream transaction ID if any")]
1143
1165
  agent_id: Annotated[
1144
- Optional[str], Field(None, description="ID of the agent if applicable")
1166
+ str | None, Field(None, description="ID of the agent if applicable")
1145
1167
  ]
1146
1168
  agent_wallet_address: Annotated[
1147
- Optional[str],
1169
+ str | None,
1148
1170
  Field(None, description="Wallet address of the agent if applicable"),
1149
1171
  ]
1150
1172
  start_message_id: Annotated[
1151
- Optional[str],
1173
+ str | None,
1152
1174
  Field(None, description="ID of the starting message if applicable"),
1153
1175
  ]
1154
1176
  message_id: Annotated[
1155
- Optional[str], Field(None, description="ID of the message if applicable")
1177
+ str | None, Field(None, description="ID of the message if applicable")
1156
1178
  ]
1157
1179
  model: Annotated[
1158
- Optional[str], Field(None, description="LLM model used if applicable")
1180
+ str | None, Field(None, description="LLM model used if applicable")
1159
1181
  ]
1160
1182
  skill_call_id: Annotated[
1161
- Optional[str], Field(None, description="ID of the skill call if applicable")
1183
+ str | None, Field(None, description="ID of the skill call if applicable")
1162
1184
  ]
1163
1185
  skill_name: Annotated[
1164
- Optional[str], Field(None, description="Name of the skill if applicable")
1186
+ str | None, Field(None, description="Name of the skill if applicable")
1165
1187
  ]
1166
1188
  direction: Annotated[Direction, Field(description="Direction of the credit flow")]
1167
1189
  total_amount: Annotated[
@@ -1173,11 +1195,11 @@ class CreditEvent(BaseModel):
1173
1195
  ]
1174
1196
  credit_type: Annotated[CreditType, Field(description="Type of credits involved")]
1175
1197
  credit_types: Annotated[
1176
- Optional[List[CreditType]],
1198
+ list[CreditType] | None,
1177
1199
  Field(default=None, description="Array of credit types involved"),
1178
1200
  ]
1179
1201
  balance_after: Annotated[
1180
- Optional[Decimal],
1202
+ Decimal | None,
1181
1203
  Field(None, description="Account total balance after the transaction"),
1182
1204
  ]
1183
1205
  base_amount: Annotated[
@@ -1185,115 +1207,115 @@ class CreditEvent(BaseModel):
1185
1207
  Field(default=Decimal("0"), description="Base amount of credits involved"),
1186
1208
  ]
1187
1209
  base_discount_amount: Annotated[
1188
- Optional[Decimal],
1210
+ Decimal | None,
1189
1211
  Field(default=Decimal("0"), description="Base discount amount"),
1190
1212
  ]
1191
1213
  base_original_amount: Annotated[
1192
- Optional[Decimal],
1214
+ Decimal | None,
1193
1215
  Field(default=Decimal("0"), description="Base original amount"),
1194
1216
  ]
1195
1217
  base_llm_amount: Annotated[
1196
- Optional[Decimal],
1218
+ Decimal | None,
1197
1219
  Field(default=Decimal("0"), description="Base LLM cost amount"),
1198
1220
  ]
1199
1221
  base_skill_amount: Annotated[
1200
- Optional[Decimal],
1222
+ Decimal | None,
1201
1223
  Field(default=Decimal("0"), description="Base skill cost amount"),
1202
1224
  ]
1203
1225
  base_free_amount: Annotated[
1204
- Optional[Decimal],
1226
+ Decimal | None,
1205
1227
  Field(default=Decimal("0"), description="Base free credit amount"),
1206
1228
  ]
1207
1229
  base_reward_amount: Annotated[
1208
- Optional[Decimal],
1230
+ Decimal | None,
1209
1231
  Field(default=Decimal("0"), description="Base reward credit amount"),
1210
1232
  ]
1211
1233
  base_permanent_amount: Annotated[
1212
- Optional[Decimal],
1234
+ Decimal | None,
1213
1235
  Field(default=Decimal("0"), description="Base permanent credit amount"),
1214
1236
  ]
1215
1237
  fee_platform_amount: Annotated[
1216
- Optional[Decimal],
1238
+ Decimal | None,
1217
1239
  Field(default=Decimal("0"), description="Platform fee amount"),
1218
1240
  ]
1219
1241
  fee_platform_free_amount: Annotated[
1220
- Optional[Decimal],
1242
+ Decimal | None,
1221
1243
  Field(
1222
1244
  default=Decimal("0"), description="Platform fee amount from free credits"
1223
1245
  ),
1224
1246
  ]
1225
1247
  fee_platform_reward_amount: Annotated[
1226
- Optional[Decimal],
1248
+ Decimal | None,
1227
1249
  Field(
1228
1250
  default=Decimal("0"), description="Platform fee amount from reward credits"
1229
1251
  ),
1230
1252
  ]
1231
1253
  fee_platform_permanent_amount: Annotated[
1232
- Optional[Decimal],
1254
+ Decimal | None,
1233
1255
  Field(
1234
1256
  default=Decimal("0"),
1235
1257
  description="Platform fee amount from permanent credits",
1236
1258
  ),
1237
1259
  ]
1238
1260
  fee_dev_account: Annotated[
1239
- Optional[str], Field(None, description="Developer account ID receiving fee")
1261
+ str | None, Field(None, description="Developer account ID receiving fee")
1240
1262
  ]
1241
1263
  fee_dev_amount: Annotated[
1242
- Optional[Decimal],
1264
+ Decimal | None,
1243
1265
  Field(default=Decimal("0"), description="Developer fee amount"),
1244
1266
  ]
1245
1267
  fee_dev_free_amount: Annotated[
1246
- Optional[Decimal],
1268
+ Decimal | None,
1247
1269
  Field(
1248
1270
  default=Decimal("0"), description="Developer fee amount from free credits"
1249
1271
  ),
1250
1272
  ]
1251
1273
  fee_dev_reward_amount: Annotated[
1252
- Optional[Decimal],
1274
+ Decimal | None,
1253
1275
  Field(
1254
1276
  default=Decimal("0"), description="Developer fee amount from reward credits"
1255
1277
  ),
1256
1278
  ]
1257
1279
  fee_dev_permanent_amount: Annotated[
1258
- Optional[Decimal],
1280
+ Decimal | None,
1259
1281
  Field(
1260
1282
  default=Decimal("0"),
1261
1283
  description="Developer fee amount from permanent credits",
1262
1284
  ),
1263
1285
  ]
1264
1286
  fee_agent_account: Annotated[
1265
- Optional[str], Field(None, description="Agent account ID receiving fee")
1287
+ str | None, Field(None, description="Agent account ID receiving fee")
1266
1288
  ]
1267
1289
  fee_agent_amount: Annotated[
1268
- Optional[Decimal], Field(default=Decimal("0"), description="Agent fee amount")
1290
+ Decimal | None, Field(default=Decimal("0"), description="Agent fee amount")
1269
1291
  ]
1270
1292
  fee_agent_free_amount: Annotated[
1271
- Optional[Decimal],
1293
+ Decimal | None,
1272
1294
  Field(default=Decimal("0"), description="Agent fee amount from free credits"),
1273
1295
  ]
1274
1296
  fee_agent_reward_amount: Annotated[
1275
- Optional[Decimal],
1297
+ Decimal | None,
1276
1298
  Field(default=Decimal("0"), description="Agent fee amount from reward credits"),
1277
1299
  ]
1278
1300
  fee_agent_permanent_amount: Annotated[
1279
- Optional[Decimal],
1301
+ Decimal | None,
1280
1302
  Field(
1281
1303
  default=Decimal("0"), description="Agent fee amount from permanent credits"
1282
1304
  ),
1283
1305
  ]
1284
1306
  free_amount: Annotated[
1285
- Optional[Decimal],
1307
+ Decimal | None,
1286
1308
  Field(default=Decimal("0"), description="Free credit amount involved"),
1287
1309
  ]
1288
1310
  reward_amount: Annotated[
1289
- Optional[Decimal],
1311
+ Decimal | None,
1290
1312
  Field(default=Decimal("0"), description="Reward credit amount involved"),
1291
1313
  ]
1292
1314
  permanent_amount: Annotated[
1293
- Optional[Decimal],
1315
+ Decimal | None,
1294
1316
  Field(default=Decimal("0"), description="Permanent credit amount involved"),
1295
1317
  ]
1296
- note: Annotated[Optional[str], Field(None, description="Additional notes")]
1318
+ note: Annotated[str | None, Field(None, description="Additional notes")]
1297
1319
  created_at: Annotated[
1298
1320
  datetime, Field(description="Timestamp when this event was created")
1299
1321
  ]
@@ -1326,13 +1348,13 @@ class CreditEvent(BaseModel):
1326
1348
  "permanent_amount",
1327
1349
  )
1328
1350
  @classmethod
1329
- def round_decimal(cls, v: Any) -> Optional[Decimal]:
1351
+ def round_decimal(cls, v: Any) -> Decimal | None:
1330
1352
  """Round decimal values to 4 decimal places."""
1331
1353
  if v is None:
1332
1354
  return None
1333
1355
  if isinstance(v, Decimal):
1334
1356
  return v.quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
1335
- elif isinstance(v, (int, float)):
1357
+ elif isinstance(v, int | float):
1336
1358
  return Decimal(str(v)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
1337
1359
  return v
1338
1360
 
@@ -1406,51 +1428,51 @@ class CreditTransactionTable(Base):
1406
1428
  Index("ix_credit_transactions_event_id", "event_id"),
1407
1429
  )
1408
1430
 
1409
- id = Column(
1431
+ id: Mapped[str] = mapped_column(
1410
1432
  String,
1411
1433
  primary_key=True,
1412
1434
  )
1413
- account_id = Column(
1435
+ account_id: Mapped[str] = mapped_column(
1414
1436
  String,
1415
1437
  nullable=False,
1416
1438
  )
1417
- event_id = Column(
1439
+ event_id: Mapped[str] = mapped_column(
1418
1440
  String,
1419
1441
  nullable=False,
1420
1442
  )
1421
- tx_type = Column(
1443
+ tx_type: Mapped[str] = mapped_column(
1422
1444
  String,
1423
1445
  nullable=False,
1424
1446
  )
1425
- credit_debit = Column(
1447
+ credit_debit: Mapped[str] = mapped_column(
1426
1448
  String,
1427
1449
  nullable=False,
1428
1450
  )
1429
- change_amount = Column(
1451
+ change_amount: Mapped[Decimal] = mapped_column(
1430
1452
  Numeric(22, 4),
1431
1453
  default=0,
1432
1454
  nullable=False,
1433
1455
  )
1434
- free_amount = Column(
1456
+ free_amount: Mapped[Decimal] = mapped_column(
1435
1457
  Numeric(22, 4),
1436
1458
  default=0,
1437
1459
  nullable=False,
1438
1460
  )
1439
- reward_amount = Column(
1461
+ reward_amount: Mapped[Decimal] = mapped_column(
1440
1462
  Numeric(22, 4),
1441
1463
  default=0,
1442
1464
  nullable=False,
1443
1465
  )
1444
- permanent_amount = Column(
1466
+ permanent_amount: Mapped[Decimal] = mapped_column(
1445
1467
  Numeric(22, 4),
1446
1468
  default=0,
1447
1469
  nullable=False,
1448
1470
  )
1449
- credit_type = Column(
1471
+ credit_type: Mapped[str] = mapped_column(
1450
1472
  String,
1451
1473
  nullable=False,
1452
1474
  )
1453
- created_at = Column(
1475
+ created_at: Mapped[datetime] = mapped_column(
1454
1476
  DateTime(timezone=True),
1455
1477
  nullable=False,
1456
1478
  server_default=func.now(),
@@ -1507,7 +1529,7 @@ class CreditTransaction(BaseModel):
1507
1529
  """Round decimal values to 4 decimal places."""
1508
1530
  if isinstance(v, Decimal):
1509
1531
  return v.quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
1510
- elif isinstance(v, (int, float)):
1532
+ elif isinstance(v, int | float):
1511
1533
  return Decimal(str(v)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
1512
1534
  return v
1513
1535
 
@@ -1542,37 +1564,37 @@ class CreditPriceTable(Base):
1542
1564
 
1543
1565
  __tablename__ = "credit_prices"
1544
1566
 
1545
- id = Column(
1567
+ id: Mapped[str] = mapped_column(
1546
1568
  String,
1547
1569
  primary_key=True,
1548
1570
  )
1549
- price_entity = Column(
1571
+ price_entity: Mapped[str] = mapped_column(
1550
1572
  String,
1551
1573
  nullable=False,
1552
1574
  )
1553
- price_entity_id = Column(
1575
+ price_entity_id: Mapped[str] = mapped_column(
1554
1576
  String,
1555
1577
  nullable=False,
1556
1578
  )
1557
- discount_type = Column(
1579
+ discount_type: Mapped[str] = mapped_column(
1558
1580
  String,
1559
1581
  nullable=False,
1560
1582
  )
1561
- price = Column(
1583
+ price: Mapped[Decimal] = mapped_column(
1562
1584
  Numeric(22, 4),
1563
1585
  default=0,
1564
1586
  nullable=False,
1565
1587
  )
1566
- created_at = Column(
1588
+ created_at: Mapped[datetime] = mapped_column(
1567
1589
  DateTime(timezone=True),
1568
1590
  nullable=False,
1569
1591
  server_default=func.now(),
1570
1592
  )
1571
- updated_at = Column(
1593
+ updated_at: Mapped[datetime] = mapped_column(
1572
1594
  DateTime(timezone=True),
1573
1595
  nullable=False,
1574
1596
  server_default=func.now(),
1575
- onupdate=lambda: datetime.now(timezone.utc),
1597
+ onupdate=lambda: datetime.now(UTC),
1576
1598
  )
1577
1599
 
1578
1600
 
@@ -1610,7 +1632,7 @@ class CreditPrice(BaseModel):
1610
1632
  """Round decimal values to 4 decimal places."""
1611
1633
  if isinstance(v, Decimal):
1612
1634
  return v.quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
1613
- elif isinstance(v, (int, float)):
1635
+ elif isinstance(v, int | float):
1614
1636
  return Decimal(str(v)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
1615
1637
  return v
1616
1638
 
@@ -1630,31 +1652,31 @@ class CreditPriceLogTable(Base):
1630
1652
 
1631
1653
  __tablename__ = "credit_price_logs"
1632
1654
 
1633
- id = Column(
1655
+ id: Mapped[str] = mapped_column(
1634
1656
  String,
1635
1657
  primary_key=True,
1636
1658
  )
1637
- price_id = Column(
1659
+ price_id: Mapped[str] = mapped_column(
1638
1660
  String,
1639
1661
  nullable=False,
1640
1662
  )
1641
- old_price = Column(
1663
+ old_price: Mapped[Decimal] = mapped_column(
1642
1664
  Numeric(22, 4),
1643
1665
  nullable=False,
1644
1666
  )
1645
- new_price = Column(
1667
+ new_price: Mapped[Decimal] = mapped_column(
1646
1668
  Numeric(22, 4),
1647
1669
  nullable=False,
1648
1670
  )
1649
- note = Column(
1671
+ note: Mapped[str | None] = mapped_column(
1650
1672
  String,
1651
1673
  nullable=True,
1652
1674
  )
1653
- modified_by = Column(
1675
+ modified_by: Mapped[str] = mapped_column(
1654
1676
  String,
1655
1677
  nullable=False,
1656
1678
  )
1657
- modified_at = Column(
1679
+ modified_at: Mapped[datetime] = mapped_column(
1658
1680
  DateTime(timezone=True),
1659
1681
  nullable=False,
1660
1682
  server_default=func.now(),
@@ -1687,13 +1709,11 @@ class CreditPriceLog(BaseModel):
1687
1709
  """Round decimal values to 4 decimal places."""
1688
1710
  if isinstance(v, Decimal):
1689
1711
  return v.quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
1690
- elif isinstance(v, (int, float)):
1712
+ elif isinstance(v, int | float):
1691
1713
  return Decimal(str(v)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)
1692
1714
  return v
1693
1715
 
1694
- note: Annotated[
1695
- Optional[str], Field(None, description="Note about the modification")
1696
- ]
1716
+ note: Annotated[str | None, Field(None, description="Note about the modification")]
1697
1717
  modified_by: Annotated[
1698
1718
  str, Field(description="ID of the user who made the modification")
1699
1719
  ]