tinybird 0.0.1.dev265__tar.gz → 0.0.1.dev266__tar.gz

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 tinybird might be problematic. Click here for more details.

Files changed (145) hide show
  1. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/PKG-INFO +1 -1
  2. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/__cli__.py +2 -2
  3. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/client.py +15 -3
  4. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/agent.py +32 -16
  5. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/models.py +8 -0
  6. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/token.py +33 -12
  7. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird.egg-info/PKG-INFO +1 -1
  8. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/setup.cfg +0 -0
  9. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/__cli__.py +0 -0
  10. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/ch_utils/constants.py +0 -0
  11. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/ch_utils/engine.py +0 -0
  12. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/check_pypi.py +0 -0
  13. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/client.py +0 -0
  14. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/config.py +0 -0
  15. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/connectors.py +0 -0
  16. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/context.py +0 -0
  17. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/datafile/common.py +0 -0
  18. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/datafile/exceptions.py +0 -0
  19. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/datafile/parse_connection.py +0 -0
  20. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/datafile/parse_datasource.py +0 -0
  21. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/datafile/parse_pipe.py +0 -0
  22. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/datatypes.py +0 -0
  23. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/feedback_manager.py +0 -0
  24. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/git_settings.py +0 -0
  25. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/prompts.py +0 -0
  26. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/sql.py +0 -0
  27. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/sql_template.py +0 -0
  28. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/sql_template_fmt.py +0 -0
  29. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/sql_toolset.py +0 -0
  30. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/syncasync.py +0 -0
  31. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/check_pypi.py +0 -0
  32. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/cli.py +0 -0
  33. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/config.py +0 -0
  34. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/__init__.py +0 -0
  35. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/animations.py +0 -0
  36. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/banner.py +0 -0
  37. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/command_agent.py +0 -0
  38. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/memory.py +0 -0
  39. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/prompts.py +0 -0
  40. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/testing_agent.py +0 -0
  41. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/__init__.py +0 -0
  42. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/analyze.py +0 -0
  43. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/append.py +0 -0
  44. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/build.py +0 -0
  45. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/create_datafile.py +0 -0
  46. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/deploy.py +0 -0
  47. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/deploy_check.py +0 -0
  48. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/diff_resource.py +0 -0
  49. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/execute_query.py +0 -0
  50. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/explore.py +0 -0
  51. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/get_endpoint_stats.py +0 -0
  52. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/get_openapi_definition.py +0 -0
  53. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/mock.py +0 -0
  54. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/plan.py +0 -0
  55. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/preview_datafile.py +0 -0
  56. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/request_endpoint.py +0 -0
  57. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/run_command.py +0 -0
  58. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/tools/test.py +0 -0
  59. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/agent/utils.py +0 -0
  60. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/build.py +0 -0
  61. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/build_common.py +0 -0
  62. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/cicd.py +0 -0
  63. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/cli.py +0 -0
  64. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/common.py +0 -0
  65. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/config.py +0 -0
  66. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/connection.py +0 -0
  67. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/copy.py +0 -0
  68. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/create.py +0 -0
  69. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/build.py +0 -0
  70. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/build_common.py +0 -0
  71. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/build_datasource.py +0 -0
  72. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/build_pipe.py +0 -0
  73. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/diff.py +0 -0
  74. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/fixture.py +0 -0
  75. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/format_common.py +0 -0
  76. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/format_datasource.py +0 -0
  77. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/format_pipe.py +0 -0
  78. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/pipe_checker.py +0 -0
  79. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/playground.py +0 -0
  80. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datafile/pull.py +0 -0
  81. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/datasource.py +0 -0
  82. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/deployment.py +0 -0
  83. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/deployment_common.py +0 -0
  84. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/deprecations.py +0 -0
  85. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/dev_server.py +0 -0
  86. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/endpoint.py +0 -0
  87. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/exceptions.py +0 -0
  88. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/feedback_manager.py +0 -0
  89. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/info.py +0 -0
  90. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/infra.py +0 -0
  91. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/job.py +0 -0
  92. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/llm.py +0 -0
  93. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/llm_utils.py +0 -0
  94. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/local.py +0 -0
  95. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/local_common.py +0 -0
  96. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/login.py +0 -0
  97. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/login_common.py +0 -0
  98. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/logout.py +0 -0
  99. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/materialization.py +0 -0
  100. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/mock.py +0 -0
  101. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/mock_common.py +0 -0
  102. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/open.py +0 -0
  103. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/pipe.py +0 -0
  104. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/project.py +0 -0
  105. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/regions.py +0 -0
  106. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/secret.py +0 -0
  107. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/secret_common.py +0 -0
  108. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/shell.py +0 -0
  109. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/sink.py +0 -0
  110. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/table.py +0 -0
  111. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/telemetry.py +0 -0
  112. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/test.py +0 -0
  113. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/test_common.py +0 -0
  114. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/tinyunit/tinyunit.py +0 -0
  115. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/tinyunit/tinyunit_lib.py +0 -0
  116. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/watch.py +0 -0
  117. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/workspace.py +0 -0
  118. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb/modules/workspace_members.py +0 -0
  119. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli.py +0 -0
  120. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/auth.py +0 -0
  121. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/branch.py +0 -0
  122. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/cicd.py +0 -0
  123. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/cli.py +0 -0
  124. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/common.py +0 -0
  125. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/config.py +0 -0
  126. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/connection.py +0 -0
  127. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/datasource.py +0 -0
  128. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/exceptions.py +0 -0
  129. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/fmt.py +0 -0
  130. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/job.py +0 -0
  131. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/pipe.py +0 -0
  132. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/regions.py +0 -0
  133. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/tag.py +0 -0
  134. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/telemetry.py +0 -0
  135. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/test.py +0 -0
  136. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
  137. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
  138. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/workspace.py +0 -0
  139. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tb_cli_modules/workspace_members.py +0 -0
  140. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird/tornado_template.py +0 -0
  141. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird.egg-info/SOURCES.txt +0 -0
  142. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird.egg-info/dependency_links.txt +0 -0
  143. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird.egg-info/entry_points.txt +0 -0
  144. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird.egg-info/requires.txt +0 -0
  145. {tinybird-0.0.1.dev265 → tinybird-0.0.1.dev266}/tinybird.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev265
3
+ Version: 0.0.1.dev266
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
4
4
  __url__ = 'https://www.tinybird.co/docs/forward/commands'
5
5
  __author__ = 'Tinybird'
6
6
  __author_email__ = 'support@tinybird.co'
7
- __version__ = '0.0.1.dev265'
8
- __revision__ = 'b723917'
7
+ __version__ = '0.0.1.dev266'
8
+ __revision__ = 'b4193e9'
@@ -870,9 +870,15 @@ class TinyB:
870
870
  data={"operation": "change_role", "users": users, "new_role": role},
871
871
  )
872
872
 
873
- def workspace(self, workspace_id: str, with_token: bool = False):
874
- params = {"with_token": "true" if with_token else "false"}
875
- return self._req(f"/v0/workspaces/{workspace_id}?{urlencode(params)}")
873
+ def workspace(
874
+ self, workspace_id: str, with_token: bool = False, with_organization: bool = False, version: str = "v0"
875
+ ):
876
+ params = {}
877
+ if with_token:
878
+ params["with_token"] = "true"
879
+ if with_organization:
880
+ params["with_organization"] = "true"
881
+ return self._req(f"/{version}/workspaces/{workspace_id}?{urlencode(params)}")
876
882
 
877
883
  def workspace_info(self, version: str = "v0") -> Dict[str, Any]:
878
884
  return self._req(f"/{version}/workspace")
@@ -880,6 +886,12 @@ class TinyB:
880
886
  def organization(self, organization_id: str):
881
887
  return self._req(f"/v0/organizations/{organization_id}")
882
888
 
889
+ def organization_limits(self, organization_id: str):
890
+ return self._req(f"/v1/billing/{organization_id}/limits")
891
+
892
+ def organization_subscription(self, organization_id: str):
893
+ return self._req(f"/v1/billing/{organization_id}/subscription")
894
+
883
895
  def create_organization(
884
896
  self,
885
897
  name: str,
@@ -3,6 +3,7 @@ import shlex
3
3
  import subprocess
4
4
  import sys
5
5
  import urllib.parse
6
+ import uuid
6
7
  from functools import partial
7
8
  from pathlib import Path
8
9
  from typing import Any, Optional
@@ -19,7 +20,7 @@ from tinybird.tb.modules.agent.animations import ThinkingAnimation
19
20
  from tinybird.tb.modules.agent.banner import display_banner
20
21
  from tinybird.tb.modules.agent.command_agent import CommandAgent
21
22
  from tinybird.tb.modules.agent.memory import clear_history, clear_messages, load_messages, save_messages
22
- from tinybird.tb.modules.agent.models import create_model, model_costs
23
+ from tinybird.tb.modules.agent.models import create_model
23
24
  from tinybird.tb.modules.agent.prompts import agent_system_prompt, load_custom_project_rules, resources_prompt
24
25
  from tinybird.tb.modules.agent.testing_agent import TestingAgent
25
26
  from tinybird.tb.modules.agent.tools.analyze import analyze_file, analyze_url
@@ -256,12 +257,12 @@ class TinybirdAgent:
256
257
  click.echo(result.output)
257
258
  self._echo_usage(config, result)
258
259
 
259
- async def run_iter(self, user_prompt: str, config: dict[str, Any]) -> None:
260
+ async def run_iter(self, user_prompt: str, config: dict[str, Any], model: Any) -> None:
260
261
  user_prompt = f"{user_prompt}\n\n{load_custom_project_rules(self.project.folder)}"
261
262
  self.thinking_animation.start()
262
263
  deps = self._build_agent_deps(config)
263
264
 
264
- async with self.agent.iter(user_prompt, deps=deps, message_history=self.messages) as agent_run:
265
+ async with self.agent.iter(user_prompt, deps=deps, message_history=self.messages, model=model) as agent_run:
265
266
  async for node in agent_run:
266
267
  if hasattr(node, "model_response"):
267
268
  for _i, part in enumerate(node.model_response.parts):
@@ -281,19 +282,32 @@ class TinybirdAgent:
281
282
  self._echo_usage(config, agent_run.result)
282
283
 
283
284
  def _echo_usage(self, config: dict[str, Any], result: AgentRunResult) -> None:
284
- if "@tinybird.co" in config.get("user_email", ""):
285
- usage = result.usage()
286
- request_tokens = usage.request_tokens or 0
287
- response_tokens = usage.response_tokens or 0
288
- total_tokens = usage.total_tokens or 0
289
- cost = (
290
- request_tokens * model_costs["input_cost_per_token"]
291
- + response_tokens * model_costs["output_cost_per_token"]
285
+ try:
286
+ client = _get_tb_client(config["user_token"], config["host"])
287
+ workspace_id = config.get("id", "")
288
+ workspace = client.workspace(workspace_id, with_organization=True, version="v1")
289
+ limits_data = client.organization_limits(workspace["organization"]["id"])
290
+ ai_requests_limits = limits_data.get("limits", {}).get("ai_requests", {})
291
+ current_ai_requests = ai_requests_limits.get("quantity", 0)
292
+ max_ai_requests = ai_requests_limits.get("max", 0)
293
+ if not max_ai_requests:
294
+ return
295
+ remaining_requests = max(max_ai_requests - current_ai_requests, 0)
296
+ warning_threshold = max_ai_requests * 0.8
297
+ if current_ai_requests >= warning_threshold:
298
+ message_color = FeedbackManager.warning
299
+ else:
300
+ message_color = FeedbackManager.gray
301
+
302
+ current_ai_requests = min(max_ai_requests, current_ai_requests)
303
+
304
+ click.echo(
305
+ message_color(
306
+ message=f"{remaining_requests} agent requests left ({current_ai_requests}/{max_ai_requests}). This message is informative. Limits will be enforced soon."
307
+ )
292
308
  )
293
- click.echo(f"Input tokens: {request_tokens}")
294
- click.echo(f"Output tokens: {response_tokens}")
295
- click.echo(f"Total tokens: {total_tokens}")
296
- click.echo(f"Cost: ${cost:.6f}")
309
+ except Exception:
310
+ pass
297
311
 
298
312
 
299
313
  def run_agent(
@@ -426,7 +440,9 @@ def run_agent(
426
440
  elif user_input.strip() == "":
427
441
  continue
428
442
  else:
429
- asyncio.run(agent.run_iter(user_input, config))
443
+ run_id = str(uuid.uuid4())
444
+ model = create_model(user_token, host, workspace_id, run_id=run_id)
445
+ asyncio.run(agent.run_iter(user_input, config, model))
430
446
  except AgentRunCancelled:
431
447
  click.echo(FeedbackManager.info(message="User cancelled the operation"))
432
448
  agent.add_message(
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from anthropic import AsyncAnthropic
2
4
  from httpx import AsyncClient
3
5
  from pydantic_ai.models.anthropic import AnthropicModel, AnthropicModelName
@@ -9,11 +11,17 @@ def create_model(
9
11
  base_url: str,
10
12
  workspace_id: str,
11
13
  model: AnthropicModelName = "claude-4-sonnet-20250514",
14
+ run_id: Optional[str] = None,
12
15
  ):
16
+ default_headers = {}
17
+ if run_id:
18
+ default_headers["X-Run-Id"] = run_id
19
+
13
20
  client = AsyncAnthropic(
14
21
  base_url=base_url,
15
22
  http_client=AsyncClient(params={"token": token, "workspace_id": workspace_id}),
16
23
  auth_token=token,
24
+ default_headers=default_headers,
17
25
  )
18
26
  return AnthropicModel(
19
27
  model_name=model,
@@ -163,7 +163,7 @@ def create(ctx: Context) -> None:
163
163
 
164
164
  * Static Tokens do not have a TTL and can have any valid scope (ADMIN, TOKENS, or ORG_DATASOURCES:READ).
165
165
 
166
- * JWT tokens have a TTL and can only have the PIPES:READ scope.Their main use case is allow your users to call your endpoints without exposing your API key.
166
+ * JWT tokens have a TTL and can have PIPES:READ and DATASOURCES:READ scopes. Their main use case is allow your users to call your endpoints or read datasources without exposing your API key.
167
167
 
168
168
 
169
169
  Examples:
@@ -173,6 +173,8 @@ def create(ctx: Context) -> None:
173
173
  tb token create static my_static_token --scope TOKENS
174
174
 
175
175
  tb token create jwt my_jwt_token --ttl 1h --scope PIPES:READ --resource my_pipe
176
+
177
+ tb token create jwt my_jwt_token --ttl 1h --scope DATASOURCES:READ --resource my_datasource --filter "column = 'value'"
176
178
  """
177
179
 
178
180
 
@@ -182,16 +184,21 @@ def create(ctx: Context) -> None:
182
184
  @click.option(
183
185
  "--scope",
184
186
  multiple=True,
185
- type=click.Choice(["PIPES:READ"]),
187
+ type=click.Choice(["PIPES:READ", "DATASOURCES:READ"]),
186
188
  required=True,
187
- help="Scope of the token (only PIPES:READ is allowed for JWT tokens)",
189
+ help="Scope of the token (only PIPES:READ and DATASOURCES:READ are allowed for JWT tokens)",
188
190
  )
189
191
  @click.option("--resource", multiple=True, required=True, help="Resource associated with the scope")
190
192
  @click.option(
191
193
  "--fixed-params", multiple=True, help="Fixed parameters in key=value format, multiple values separated by commas"
192
194
  )
195
+ @click.option(
196
+ "--filter",
197
+ multiple=True,
198
+ help="SQL filter to apply when reading a datasource (only applicable for DATASOURCES:READ scope)",
199
+ )
193
200
  @click.pass_context
194
- def create_jwt_token(ctx: Context, name: str, ttl: timedelta, scope, resource, fixed_params) -> None:
201
+ def create_jwt_token(ctx: Context, name: str, ttl: timedelta, scope, resource, fixed_params, filter) -> None:
195
202
  """Create a JWT token with a TTL specify."""
196
203
 
197
204
  obj: Dict[str, Any] = ctx.ensure_object(dict)
@@ -205,6 +212,10 @@ def create_jwt_token(ctx: Context, name: str, ttl: timedelta, scope, resource, f
205
212
  if fixed_params and len(fixed_params) > len(scope):
206
213
  raise CLITokenException(FeedbackManager.error_number_of_fixed_params_and_resources_mismatch())
207
214
 
215
+ # Ensure the number of filters does not exceed the number of scope/resource pairs
216
+ if filter and len(filter) > len(scope):
217
+ raise CLITokenException("The number of SQL filters must match the number of scopes")
218
+
208
219
  # Parse fixed params
209
220
  parsed_fixed_params = parse_fixed_params(fixed_params) if fixed_params else []
210
221
 
@@ -213,15 +224,24 @@ def create_jwt_token(ctx: Context, name: str, ttl: timedelta, scope, resource, f
213
224
  for i, params in enumerate(parsed_fixed_params):
214
225
  fixed_params_list[i] = params
215
226
 
227
+ # Create a list of filters for each scope/resource pair, defaulting to None if not provided
228
+ filters_list: List[Optional[str]] = [None] * len(scope)
229
+ for i, f in enumerate(filter):
230
+ filters_list[i] = f
231
+
216
232
  scopes = []
217
- for sc, res, fparams in zip(scope, resource, fixed_params_list):
218
- scopes.append(
219
- {
220
- "type": sc,
221
- "resource": res,
222
- "fixed_params": fparams,
223
- }
224
- )
233
+ for sc, res, fparams, filter in zip(scope, resource, fixed_params_list, filters_list):
234
+ scope_data = {
235
+ "type": sc,
236
+ "resource": res,
237
+ }
238
+
239
+ if sc == "PIPES:READ" and fparams:
240
+ scope_data["fixed_params"] = fparams
241
+ elif sc == "DATASOURCES:READ" and filter:
242
+ scope_data["filter"] = filter
243
+
244
+ scopes.append(scope_data)
225
245
 
226
246
  try:
227
247
  response = client.create_jwt_token(name, expiration_time, scopes)
@@ -258,6 +278,7 @@ class DynamicOptionsCommand(click.Command):
258
278
  # Options
259
279
  dynamic_options_help += "Options:\n"
260
280
  dynamic_options_help += f" --scope [{','.join(valid_scopes)}] Scope for the token [Required]\n"
281
+ dynamic_options_help += " --resource TEXT Resource you want to associate the scope with\n"
261
282
  dynamic_options_help += " -h, --help Show this message and exit.\n"
262
283
 
263
284
  return dynamic_options_help
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev265
3
+ Version: 0.0.1.dev266
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird