alita-sdk 0.3.257__py3-none-any.whl → 0.3.584__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 alita-sdk might be problematic. Click here for more details.

Files changed (281) hide show
  1. alita_sdk/cli/__init__.py +10 -0
  2. alita_sdk/cli/__main__.py +17 -0
  3. alita_sdk/cli/agent/__init__.py +5 -0
  4. alita_sdk/cli/agent/default.py +258 -0
  5. alita_sdk/cli/agent_executor.py +155 -0
  6. alita_sdk/cli/agent_loader.py +215 -0
  7. alita_sdk/cli/agent_ui.py +228 -0
  8. alita_sdk/cli/agents.py +3794 -0
  9. alita_sdk/cli/callbacks.py +647 -0
  10. alita_sdk/cli/cli.py +168 -0
  11. alita_sdk/cli/config.py +306 -0
  12. alita_sdk/cli/context/__init__.py +30 -0
  13. alita_sdk/cli/context/cleanup.py +198 -0
  14. alita_sdk/cli/context/manager.py +731 -0
  15. alita_sdk/cli/context/message.py +285 -0
  16. alita_sdk/cli/context/strategies.py +289 -0
  17. alita_sdk/cli/context/token_estimation.py +127 -0
  18. alita_sdk/cli/formatting.py +182 -0
  19. alita_sdk/cli/input_handler.py +419 -0
  20. alita_sdk/cli/inventory.py +1073 -0
  21. alita_sdk/cli/mcp_loader.py +315 -0
  22. alita_sdk/cli/toolkit.py +327 -0
  23. alita_sdk/cli/toolkit_loader.py +85 -0
  24. alita_sdk/cli/tools/__init__.py +43 -0
  25. alita_sdk/cli/tools/approval.py +224 -0
  26. alita_sdk/cli/tools/filesystem.py +1751 -0
  27. alita_sdk/cli/tools/planning.py +389 -0
  28. alita_sdk/cli/tools/terminal.py +414 -0
  29. alita_sdk/community/__init__.py +72 -12
  30. alita_sdk/community/inventory/__init__.py +236 -0
  31. alita_sdk/community/inventory/config.py +257 -0
  32. alita_sdk/community/inventory/enrichment.py +2137 -0
  33. alita_sdk/community/inventory/extractors.py +1469 -0
  34. alita_sdk/community/inventory/ingestion.py +3172 -0
  35. alita_sdk/community/inventory/knowledge_graph.py +1457 -0
  36. alita_sdk/community/inventory/parsers/__init__.py +218 -0
  37. alita_sdk/community/inventory/parsers/base.py +295 -0
  38. alita_sdk/community/inventory/parsers/csharp_parser.py +907 -0
  39. alita_sdk/community/inventory/parsers/go_parser.py +851 -0
  40. alita_sdk/community/inventory/parsers/html_parser.py +389 -0
  41. alita_sdk/community/inventory/parsers/java_parser.py +593 -0
  42. alita_sdk/community/inventory/parsers/javascript_parser.py +629 -0
  43. alita_sdk/community/inventory/parsers/kotlin_parser.py +768 -0
  44. alita_sdk/community/inventory/parsers/markdown_parser.py +362 -0
  45. alita_sdk/community/inventory/parsers/python_parser.py +604 -0
  46. alita_sdk/community/inventory/parsers/rust_parser.py +858 -0
  47. alita_sdk/community/inventory/parsers/swift_parser.py +832 -0
  48. alita_sdk/community/inventory/parsers/text_parser.py +322 -0
  49. alita_sdk/community/inventory/parsers/yaml_parser.py +370 -0
  50. alita_sdk/community/inventory/patterns/__init__.py +61 -0
  51. alita_sdk/community/inventory/patterns/ast_adapter.py +380 -0
  52. alita_sdk/community/inventory/patterns/loader.py +348 -0
  53. alita_sdk/community/inventory/patterns/registry.py +198 -0
  54. alita_sdk/community/inventory/presets.py +535 -0
  55. alita_sdk/community/inventory/retrieval.py +1403 -0
  56. alita_sdk/community/inventory/toolkit.py +173 -0
  57. alita_sdk/community/inventory/toolkit_utils.py +176 -0
  58. alita_sdk/community/inventory/visualize.py +1370 -0
  59. alita_sdk/configurations/__init__.py +11 -0
  60. alita_sdk/configurations/ado.py +148 -2
  61. alita_sdk/configurations/azure_search.py +1 -1
  62. alita_sdk/configurations/bigquery.py +1 -1
  63. alita_sdk/configurations/bitbucket.py +94 -2
  64. alita_sdk/configurations/browser.py +18 -0
  65. alita_sdk/configurations/carrier.py +19 -0
  66. alita_sdk/configurations/confluence.py +130 -1
  67. alita_sdk/configurations/delta_lake.py +1 -1
  68. alita_sdk/configurations/figma.py +76 -5
  69. alita_sdk/configurations/github.py +65 -1
  70. alita_sdk/configurations/gitlab.py +81 -0
  71. alita_sdk/configurations/google_places.py +17 -0
  72. alita_sdk/configurations/jira.py +103 -0
  73. alita_sdk/configurations/openapi.py +323 -0
  74. alita_sdk/configurations/postman.py +1 -1
  75. alita_sdk/configurations/qtest.py +72 -3
  76. alita_sdk/configurations/report_portal.py +115 -0
  77. alita_sdk/configurations/salesforce.py +19 -0
  78. alita_sdk/configurations/service_now.py +1 -12
  79. alita_sdk/configurations/sharepoint.py +167 -0
  80. alita_sdk/configurations/sonar.py +18 -0
  81. alita_sdk/configurations/sql.py +20 -0
  82. alita_sdk/configurations/testio.py +101 -0
  83. alita_sdk/configurations/testrail.py +88 -0
  84. alita_sdk/configurations/xray.py +94 -1
  85. alita_sdk/configurations/zephyr_enterprise.py +94 -1
  86. alita_sdk/configurations/zephyr_essential.py +95 -0
  87. alita_sdk/runtime/clients/artifact.py +21 -4
  88. alita_sdk/runtime/clients/client.py +458 -67
  89. alita_sdk/runtime/clients/mcp_discovery.py +342 -0
  90. alita_sdk/runtime/clients/mcp_manager.py +262 -0
  91. alita_sdk/runtime/clients/sandbox_client.py +352 -0
  92. alita_sdk/runtime/langchain/_constants_bkup.py +1318 -0
  93. alita_sdk/runtime/langchain/assistant.py +183 -43
  94. alita_sdk/runtime/langchain/constants.py +647 -1
  95. alita_sdk/runtime/langchain/document_loaders/AlitaDocxMammothLoader.py +315 -3
  96. alita_sdk/runtime/langchain/document_loaders/AlitaExcelLoader.py +209 -31
  97. alita_sdk/runtime/langchain/document_loaders/AlitaImageLoader.py +1 -1
  98. alita_sdk/runtime/langchain/document_loaders/AlitaJSONLinesLoader.py +77 -0
  99. alita_sdk/runtime/langchain/document_loaders/AlitaJSONLoader.py +10 -3
  100. alita_sdk/runtime/langchain/document_loaders/AlitaMarkdownLoader.py +66 -0
  101. alita_sdk/runtime/langchain/document_loaders/AlitaPDFLoader.py +79 -10
  102. alita_sdk/runtime/langchain/document_loaders/AlitaPowerPointLoader.py +52 -15
  103. alita_sdk/runtime/langchain/document_loaders/AlitaPythonLoader.py +9 -0
  104. alita_sdk/runtime/langchain/document_loaders/AlitaTableLoader.py +1 -4
  105. alita_sdk/runtime/langchain/document_loaders/AlitaTextLoader.py +15 -2
  106. alita_sdk/runtime/langchain/document_loaders/ImageParser.py +30 -0
  107. alita_sdk/runtime/langchain/document_loaders/constants.py +189 -41
  108. alita_sdk/runtime/langchain/interfaces/llm_processor.py +4 -2
  109. alita_sdk/runtime/langchain/langraph_agent.py +493 -105
  110. alita_sdk/runtime/langchain/utils.py +118 -8
  111. alita_sdk/runtime/llms/preloaded.py +2 -6
  112. alita_sdk/runtime/models/mcp_models.py +61 -0
  113. alita_sdk/runtime/skills/__init__.py +91 -0
  114. alita_sdk/runtime/skills/callbacks.py +498 -0
  115. alita_sdk/runtime/skills/discovery.py +540 -0
  116. alita_sdk/runtime/skills/executor.py +610 -0
  117. alita_sdk/runtime/skills/input_builder.py +371 -0
  118. alita_sdk/runtime/skills/models.py +330 -0
  119. alita_sdk/runtime/skills/registry.py +355 -0
  120. alita_sdk/runtime/skills/skill_runner.py +330 -0
  121. alita_sdk/runtime/toolkits/__init__.py +28 -0
  122. alita_sdk/runtime/toolkits/application.py +14 -4
  123. alita_sdk/runtime/toolkits/artifact.py +25 -9
  124. alita_sdk/runtime/toolkits/datasource.py +13 -6
  125. alita_sdk/runtime/toolkits/mcp.py +782 -0
  126. alita_sdk/runtime/toolkits/planning.py +178 -0
  127. alita_sdk/runtime/toolkits/skill_router.py +238 -0
  128. alita_sdk/runtime/toolkits/subgraph.py +11 -6
  129. alita_sdk/runtime/toolkits/tools.py +314 -70
  130. alita_sdk/runtime/toolkits/vectorstore.py +11 -5
  131. alita_sdk/runtime/tools/__init__.py +24 -0
  132. alita_sdk/runtime/tools/application.py +16 -4
  133. alita_sdk/runtime/tools/artifact.py +367 -33
  134. alita_sdk/runtime/tools/data_analysis.py +183 -0
  135. alita_sdk/runtime/tools/function.py +100 -4
  136. alita_sdk/runtime/tools/graph.py +81 -0
  137. alita_sdk/runtime/tools/image_generation.py +218 -0
  138. alita_sdk/runtime/tools/llm.py +1032 -177
  139. alita_sdk/runtime/tools/loop.py +3 -1
  140. alita_sdk/runtime/tools/loop_output.py +3 -1
  141. alita_sdk/runtime/tools/mcp_inspect_tool.py +284 -0
  142. alita_sdk/runtime/tools/mcp_remote_tool.py +181 -0
  143. alita_sdk/runtime/tools/mcp_server_tool.py +3 -1
  144. alita_sdk/runtime/tools/planning/__init__.py +36 -0
  145. alita_sdk/runtime/tools/planning/models.py +246 -0
  146. alita_sdk/runtime/tools/planning/wrapper.py +607 -0
  147. alita_sdk/runtime/tools/router.py +2 -1
  148. alita_sdk/runtime/tools/sandbox.py +375 -0
  149. alita_sdk/runtime/tools/skill_router.py +776 -0
  150. alita_sdk/runtime/tools/tool.py +3 -1
  151. alita_sdk/runtime/tools/vectorstore.py +69 -65
  152. alita_sdk/runtime/tools/vectorstore_base.py +163 -90
  153. alita_sdk/runtime/utils/AlitaCallback.py +137 -21
  154. alita_sdk/runtime/utils/constants.py +5 -1
  155. alita_sdk/runtime/utils/mcp_client.py +492 -0
  156. alita_sdk/runtime/utils/mcp_oauth.py +361 -0
  157. alita_sdk/runtime/utils/mcp_sse_client.py +434 -0
  158. alita_sdk/runtime/utils/mcp_tools_discovery.py +124 -0
  159. alita_sdk/runtime/utils/streamlit.py +41 -14
  160. alita_sdk/runtime/utils/toolkit_utils.py +28 -9
  161. alita_sdk/runtime/utils/utils.py +48 -0
  162. alita_sdk/tools/__init__.py +135 -37
  163. alita_sdk/tools/ado/__init__.py +2 -2
  164. alita_sdk/tools/ado/repos/__init__.py +16 -19
  165. alita_sdk/tools/ado/repos/repos_wrapper.py +12 -20
  166. alita_sdk/tools/ado/test_plan/__init__.py +27 -8
  167. alita_sdk/tools/ado/test_plan/test_plan_wrapper.py +56 -28
  168. alita_sdk/tools/ado/wiki/__init__.py +28 -12
  169. alita_sdk/tools/ado/wiki/ado_wrapper.py +114 -40
  170. alita_sdk/tools/ado/work_item/__init__.py +28 -12
  171. alita_sdk/tools/ado/work_item/ado_wrapper.py +95 -11
  172. alita_sdk/tools/advanced_jira_mining/__init__.py +13 -8
  173. alita_sdk/tools/aws/delta_lake/__init__.py +15 -11
  174. alita_sdk/tools/aws/delta_lake/tool.py +5 -1
  175. alita_sdk/tools/azure_ai/search/__init__.py +14 -8
  176. alita_sdk/tools/base/tool.py +5 -1
  177. alita_sdk/tools/base_indexer_toolkit.py +454 -110
  178. alita_sdk/tools/bitbucket/__init__.py +28 -19
  179. alita_sdk/tools/bitbucket/api_wrapper.py +285 -27
  180. alita_sdk/tools/bitbucket/cloud_api_wrapper.py +5 -5
  181. alita_sdk/tools/browser/__init__.py +41 -16
  182. alita_sdk/tools/browser/crawler.py +3 -1
  183. alita_sdk/tools/browser/utils.py +15 -6
  184. alita_sdk/tools/carrier/__init__.py +18 -17
  185. alita_sdk/tools/carrier/backend_reports_tool.py +8 -4
  186. alita_sdk/tools/carrier/excel_reporter.py +8 -4
  187. alita_sdk/tools/chunkers/__init__.py +3 -1
  188. alita_sdk/tools/chunkers/code/codeparser.py +1 -1
  189. alita_sdk/tools/chunkers/sematic/json_chunker.py +2 -1
  190. alita_sdk/tools/chunkers/sematic/markdown_chunker.py +97 -6
  191. alita_sdk/tools/chunkers/sematic/proposal_chunker.py +1 -1
  192. alita_sdk/tools/chunkers/universal_chunker.py +270 -0
  193. alita_sdk/tools/cloud/aws/__init__.py +12 -7
  194. alita_sdk/tools/cloud/azure/__init__.py +12 -7
  195. alita_sdk/tools/cloud/gcp/__init__.py +12 -7
  196. alita_sdk/tools/cloud/k8s/__init__.py +12 -7
  197. alita_sdk/tools/code/linter/__init__.py +10 -8
  198. alita_sdk/tools/code/loaders/codesearcher.py +3 -2
  199. alita_sdk/tools/code/sonar/__init__.py +21 -13
  200. alita_sdk/tools/code_indexer_toolkit.py +199 -0
  201. alita_sdk/tools/confluence/__init__.py +22 -14
  202. alita_sdk/tools/confluence/api_wrapper.py +197 -58
  203. alita_sdk/tools/confluence/loader.py +14 -2
  204. alita_sdk/tools/custom_open_api/__init__.py +12 -5
  205. alita_sdk/tools/elastic/__init__.py +11 -8
  206. alita_sdk/tools/elitea_base.py +546 -64
  207. alita_sdk/tools/figma/__init__.py +60 -11
  208. alita_sdk/tools/figma/api_wrapper.py +1400 -167
  209. alita_sdk/tools/figma/figma_client.py +73 -0
  210. alita_sdk/tools/figma/toon_tools.py +2748 -0
  211. alita_sdk/tools/github/__init__.py +18 -17
  212. alita_sdk/tools/github/api_wrapper.py +9 -26
  213. alita_sdk/tools/github/github_client.py +81 -12
  214. alita_sdk/tools/github/schemas.py +2 -1
  215. alita_sdk/tools/github/tool.py +5 -1
  216. alita_sdk/tools/gitlab/__init__.py +19 -13
  217. alita_sdk/tools/gitlab/api_wrapper.py +256 -80
  218. alita_sdk/tools/gitlab_org/__init__.py +14 -10
  219. alita_sdk/tools/google/bigquery/__init__.py +14 -13
  220. alita_sdk/tools/google/bigquery/tool.py +5 -1
  221. alita_sdk/tools/google_places/__init__.py +21 -11
  222. alita_sdk/tools/jira/__init__.py +22 -11
  223. alita_sdk/tools/jira/api_wrapper.py +315 -168
  224. alita_sdk/tools/keycloak/__init__.py +11 -8
  225. alita_sdk/tools/localgit/__init__.py +9 -3
  226. alita_sdk/tools/localgit/local_git.py +62 -54
  227. alita_sdk/tools/localgit/tool.py +5 -1
  228. alita_sdk/tools/memory/__init__.py +38 -14
  229. alita_sdk/tools/non_code_indexer_toolkit.py +7 -2
  230. alita_sdk/tools/ocr/__init__.py +11 -8
  231. alita_sdk/tools/openapi/__init__.py +491 -106
  232. alita_sdk/tools/openapi/api_wrapper.py +1357 -0
  233. alita_sdk/tools/openapi/tool.py +20 -0
  234. alita_sdk/tools/pandas/__init__.py +20 -12
  235. alita_sdk/tools/pandas/api_wrapper.py +40 -45
  236. alita_sdk/tools/pandas/dataframe/generator/base.py +3 -1
  237. alita_sdk/tools/postman/__init__.py +11 -11
  238. alita_sdk/tools/postman/api_wrapper.py +19 -8
  239. alita_sdk/tools/postman/postman_analysis.py +8 -1
  240. alita_sdk/tools/pptx/__init__.py +11 -10
  241. alita_sdk/tools/qtest/__init__.py +22 -14
  242. alita_sdk/tools/qtest/api_wrapper.py +1784 -88
  243. alita_sdk/tools/rally/__init__.py +13 -10
  244. alita_sdk/tools/report_portal/__init__.py +23 -16
  245. alita_sdk/tools/salesforce/__init__.py +22 -16
  246. alita_sdk/tools/servicenow/__init__.py +21 -16
  247. alita_sdk/tools/servicenow/api_wrapper.py +1 -1
  248. alita_sdk/tools/sharepoint/__init__.py +17 -14
  249. alita_sdk/tools/sharepoint/api_wrapper.py +179 -39
  250. alita_sdk/tools/sharepoint/authorization_helper.py +191 -1
  251. alita_sdk/tools/sharepoint/utils.py +8 -2
  252. alita_sdk/tools/slack/__init__.py +13 -8
  253. alita_sdk/tools/sql/__init__.py +22 -19
  254. alita_sdk/tools/sql/api_wrapper.py +71 -23
  255. alita_sdk/tools/testio/__init__.py +21 -13
  256. alita_sdk/tools/testrail/__init__.py +13 -11
  257. alita_sdk/tools/testrail/api_wrapper.py +214 -46
  258. alita_sdk/tools/utils/__init__.py +28 -4
  259. alita_sdk/tools/utils/content_parser.py +241 -55
  260. alita_sdk/tools/utils/text_operations.py +254 -0
  261. alita_sdk/tools/vector_adapters/VectorStoreAdapter.py +83 -27
  262. alita_sdk/tools/xray/__init__.py +18 -14
  263. alita_sdk/tools/xray/api_wrapper.py +58 -113
  264. alita_sdk/tools/yagmail/__init__.py +9 -3
  265. alita_sdk/tools/zephyr/__init__.py +12 -7
  266. alita_sdk/tools/zephyr_enterprise/__init__.py +16 -9
  267. alita_sdk/tools/zephyr_enterprise/api_wrapper.py +30 -15
  268. alita_sdk/tools/zephyr_essential/__init__.py +16 -10
  269. alita_sdk/tools/zephyr_essential/api_wrapper.py +297 -54
  270. alita_sdk/tools/zephyr_essential/client.py +6 -4
  271. alita_sdk/tools/zephyr_scale/__init__.py +13 -8
  272. alita_sdk/tools/zephyr_scale/api_wrapper.py +39 -31
  273. alita_sdk/tools/zephyr_squad/__init__.py +12 -7
  274. {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.584.dist-info}/METADATA +184 -37
  275. alita_sdk-0.3.584.dist-info/RECORD +452 -0
  276. alita_sdk-0.3.584.dist-info/entry_points.txt +2 -0
  277. alita_sdk/tools/bitbucket/tools.py +0 -304
  278. alita_sdk-0.3.257.dist-info/RECORD +0 -343
  279. {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.584.dist-info}/WHEEL +0 -0
  280. {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.584.dist-info}/licenses/LICENSE +0 -0
  281. {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.584.dist-info}/top_level.txt +0 -0
@@ -1,304 +0,0 @@
1
- import logging
2
- import traceback
3
- from typing import Type, Optional, List
4
-
5
- from langchain_core.tools import BaseTool
6
- from pydantic import create_model, Field, BaseModel
7
- from .bitbucket_constants import create_pr_data
8
-
9
- from .api_wrapper import BitbucketAPIWrapper
10
- from ..elitea_base import LoaderSchema
11
-
12
- logger = logging.getLogger(__name__)
13
-
14
- branchInput = create_model(
15
- "BranchInput",
16
- branch_name=(str, Field(description="The name of the branch, e.g. `my_branch`.")))
17
-
18
-
19
- class CreateBitbucketBranchTool(BaseTool):
20
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
21
- name: str = "create_branch"
22
- description: str = """This tool is a wrapper for the Bitbucket API to create a new branch in the repository."""
23
- args_schema: Type[BaseModel] = branchInput
24
-
25
- def _run(self, branch_name: str):
26
- try:
27
- logger.info(f"Creating branch {branch_name} in the repository.")
28
- return self.api_wrapper.create_branch(branch_name)
29
- except Exception:
30
- stacktrace = traceback.format_exc()
31
- logger.error(f"Unable to create a branch: {stacktrace}")
32
- return f"Unable to create a branch: {stacktrace}"
33
-
34
-
35
- class CreatePRTool(BaseTool):
36
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
37
- name: str = "create_pull_request"
38
- description: str = """This tool is a wrapper for the Bitbucket API to create a new pull request in a GitLab repository.
39
- Strictly follow and provide input parameters based on context.
40
- """
41
- args_schema: Type[BaseModel] = create_model(
42
- "CreatePRInput",
43
- pr_json_data=(str, Field(description=create_pr_data)))
44
-
45
- def _run(self, pr_json_data: str):
46
- try:
47
- base_branch = self.api_wrapper.branch
48
- logger.info(f"Creating pull request using data: base_branch: {pr_json_data}")
49
- return self.api_wrapper.create_pull_request(pr_json_data)
50
- except Exception as e:
51
- stacktrace = traceback.format_exc()
52
- logger.error(f"Unable to create PR: {stacktrace}")
53
- return f"Unable to create PR: {stacktrace}"
54
-
55
-
56
- class CreateFileTool(BaseTool):
57
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
58
- name: str = "create_file"
59
- description: str = """This tool is a wrapper for the Bitbucket API, useful when you need to create a file in a Bitbucket repository.
60
- """
61
- args_schema: Type[BaseModel] = create_model(
62
- "CreateFileInput",
63
- file_path=(str, Field(
64
- description="File path of file to be created. e.g. `src/agents/developer/tools/git/bitbucket.py`. **IMPORTANT**: the path must not start with a slash")),
65
- file_contents=(str, Field(description="""
66
- Full file content to be created. It must be without any escapes, just raw content to CREATE in GIT.
67
- Generate full file content for this field without any additional texts, escapes, just raw code content.
68
- You MUST NOT ignore, skip or comment any details, PROVIDE FULL CONTENT including all content based on all best practices.
69
- """)),
70
- branch=(str, Field(
71
- description="branch - name of the branch file should be read from. e.g. `feature-1`. **IMPORTANT**: if branch not specified, try to determine from the chat history or clarify with user."))
72
- )
73
-
74
- def _run(self, file_path: str, file_contents: str, branch: str):
75
- logger.info(f"Create file in the repository {file_path} with content: {file_contents}")
76
- return self.api_wrapper.create_file(file_path, file_contents, branch)
77
-
78
-
79
- class UpdateFileTool(BaseTool):
80
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
81
- name: str = "update_file"
82
- description: str = """
83
- Updates a file with new content.
84
- Parameters:
85
- file_path (str): Path to the file to be updated
86
- branch (str): The name of the branch where update the file.
87
- update_query(str): Contains file contents.
88
- The old file contents is wrapped in OLD <<<< and >>>> OLD
89
- The new file contents is wrapped in NEW <<<< and >>>> NEW
90
- For example:
91
- /test/hello.txt
92
- OLD <<<<
93
- Hello Earth!
94
- >>>> OLD
95
- NEW <<<<
96
- Hello Mars!
97
- >>>> NEW
98
- """
99
- args_schema: Type[BaseModel] = create_model(
100
- "UpdateFileTool",
101
- file_path=(str, Field(
102
- description="File path of file to be updated. e.g. `src/agents/developer/tools/git/bitbucket.py`. **IMPORTANT**: the path must not start with a slash")),
103
- update_query=(str, Field(description="File path followed by the old and new contents")),
104
- branch=(str, Field(
105
- description="branch - the name of the branch where file that has to be updated is located. e.g. `feature-1`. **IMPORTANT**: if branch not specified, try to determine from the chat history or clarify with user."))
106
- )
107
-
108
- def _run(self, file_path: str, update_query: str, branch: str):
109
- logger.info(f"Update file in the repository {file_path} with content: {update_query} and branch {branch}")
110
- return self.api_wrapper.update_file(file_path, update_query, branch)
111
-
112
-
113
- class SetActiveBranchTool(BaseTool):
114
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
115
- name: str = "set_active_branch"
116
- description: str = """
117
- This tool is a wrapper for the Bitbucket API and set the active branch in the repository, similar to `git checkout <branch_name>` and `git switch -c <branch_name>`."""
118
- args_schema: Type[BaseModel] = branchInput
119
-
120
- def _run(self, branch_name: str):
121
- try:
122
- logger.info(f"Set active branch {branch_name} in the repository.")
123
- return self.api_wrapper.set_active_branch(branch=branch_name)
124
- except Exception as e:
125
- stacktrace = traceback.format_exc()
126
- logger.error(f"Unable to set active branch: {stacktrace}")
127
- return f"Unable to set active branch: {stacktrace}"
128
-
129
-
130
- class ListBranchesTool(BaseTool):
131
- """Tool for interacting with the Bitbucket API."""
132
-
133
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
134
- name: str = "list_branches_in_repo"
135
- description: str = """This tool is a wrapper for the Bitbucket API to fetch a list of all branches in the repository.
136
- It will return the name of each branch. No input parameters are required."""
137
- args_schema: Type[BaseModel] = create_model("NoInput")
138
-
139
- def _run(self):
140
- try:
141
- logger.debug("List branches in the repository.")
142
- return self.api_wrapper.list_branches_in_repo()
143
- except Exception as e:
144
- stacktrace = traceback.format_exc()
145
- logger.error(f"Unable to list branches: {stacktrace}")
146
- return f"Unable to list branches: {stacktrace}"
147
-
148
-
149
- class ReadFileTool(BaseTool):
150
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
151
- name: str = "read_file"
152
- description: str = """This tool is a wrapper for the GitLab API, useful when you need to read a file in a GitLab repository.
153
- Simply pass in the full
154
- file path of the file you would like to read. **IMPORTANT**: the path must not start with a slash"""
155
- args_schema: Type[BaseModel] = create_model(
156
- "ReadFileInput",
157
- file_path=(str, Field(
158
- description="File path of file to be read. e.g. `src/agents/developer/tools/git/github_tools.py`. **IMPORTANT**: the path must not start with a slash")),
159
- branch=(str, Field(
160
- description="branch - name of the branch file should be read from. e.g. `feature-1`. **IMPORTANT**: if branch not specified, try to determine from the chat history or clarify with user."))
161
- )
162
-
163
- def _run(self, file_path: str, branch: str):
164
- try:
165
- return self.api_wrapper._read_file(file_path, branch)
166
- except Exception:
167
- stacktrace = traceback.format_exc()
168
- logger.error(f"Unable to read file: {stacktrace}")
169
- return f"Unable to read file: {stacktrace}"
170
-
171
-
172
- class GetFilesListTool(BaseTool):
173
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
174
- name: str = "get_files"
175
- description: str = """
176
- This tool returns list of files.
177
- IMPORTANT: *User may leave it empty if he wants to read files from the root of the repository and using active branch.*
178
-
179
- Args:
180
- file_path (Optional[str], default: None): Package path to read files from. e.g. `src/agents/developer/tools/git/`. **IMPORTANT**: the path must not start with a slash.
181
- branch (Optional[str], default: None): branch - name of the branch file should be read from. e.g. `feature-1`. **IMPORTANT**: if branch not specified, try to determine from the chat history, leave it empty.
182
- """
183
- args_schema: Type[BaseModel] = create_model(
184
- "GetFilesListModel",
185
- file_path=(Optional[str], Field(
186
- description="Package path to read files from. e.g. `src/agents/developer/tools/git/`. Default: None. "
187
- "**IMPORTANT**: the path must not start with a slash",
188
- default=None)),
189
- branch=(Optional[str], Field(
190
- description="branch - name of the branch file should be read from. e.g. `feature-1`. Default: None. "
191
- "**IMPORTANT**: if branch not specified, try to determine from the chat history or use active branch.",
192
- default=None))
193
- )
194
-
195
- def _run(self, file_path: Optional[str] = None, branch: Optional[str] = None):
196
- try:
197
- return self.api_wrapper._get_files(file_path, branch)
198
- except Exception:
199
- stacktrace = traceback.format_exc()
200
- logger.error(f"Unable to read file: {stacktrace}")
201
- return f"Unable to read file: {stacktrace}"
202
-
203
-
204
- class LoaderTool(BaseTool):
205
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
206
- name: str = "loader"
207
- description: str = """This tool is a wrapper for the Bitbucket API, useful when you need to create a file in a Bitbucket repository.
208
- """
209
- args_schema: Type[BaseModel] = LoaderSchema
210
-
211
- def _run(self,
212
- branch: Optional[str] = None,
213
- whitelist: Optional[List[str]] = None,
214
- blacklist: Optional[List[str]] = None):
215
- return self.api_wrapper.loader(branch, whitelist, blacklist)
216
-
217
-
218
- class GetPullRequestsCommitsTool(BaseTool):
219
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
220
- name: str = "get_pull_requests_commits"
221
- description: str = """This tool is a wrapper for the Bitbucket API to get commits from pull requests."""
222
- args_schema: Type[BaseModel] = create_model(
223
- "GetPullRequestsCommitsInput",
224
- pr_id=(str, Field(description="The ID of the pull request to get commits from.")))
225
-
226
- def _run(self, pr_id: str):
227
- try:
228
- logger.debug(f"Get pull request commits for {pr_id}.")
229
- return self.api_wrapper.get_pull_requests_commits(pr_id)
230
- except Exception as e:
231
- stacktrace = traceback.format_exc()
232
- logger.error(f"Can't get commits from pull request `{pr_id}` due to error:\n{stacktrace}")
233
- return f"Can't get commits from pull request `{pr_id}` due to error:\n{stacktrace}"
234
-
235
- class GetPullRequestTool(BaseTool):
236
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
237
- name: str = "get_pull_request"
238
- description: str = """This tool is a wrapper for the Bitbucket API to get details of a pull request."""
239
- args_schema: Type[BaseModel] = create_model(
240
- "GetPullRequestInput",
241
- pr_id=(str, Field(description="The ID of the pull request to get details from.")))
242
-
243
- def _run(self, pr_id: str):
244
- try:
245
- logger.debug(f"Get pull request details for {pr_id}.")
246
- return self.api_wrapper.get_pull_request(pr_id)
247
- except Exception as e:
248
- stacktrace = traceback.format_exc()
249
- logger.error(f"Can't get pull request `{pr_id}` due to error:\n{stacktrace}")
250
- return f"Can't get pull request `{pr_id}` due to error:\n{stacktrace}"
251
-
252
- class GetPullRequestsChangesTool(BaseTool):
253
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
254
- name: str = "get_pull_requests_changes"
255
- description: str = """This tool is a wrapper for the Bitbucket API to get changes of a pull request."""
256
- args_schema: Type[BaseModel] = create_model(
257
- "GetPullRequestsChangesInput",
258
- pr_id=(str, Field(description="The ID of the pull request to get changes from.")))
259
-
260
- def _run(self, pr_id: str):
261
- try:
262
- logger.debug(f"Get pull request changes for {pr_id}.")
263
- return self.api_wrapper.get_pull_requests_changes(pr_id)
264
- except Exception as e:
265
- stacktrace = traceback.format_exc()
266
- logger.error(f"Can't get changes from pull request `{pr_id}` due to error:\n{stacktrace}")
267
- return f"Can't get changes from pull request `{pr_id}` due to error:\n{stacktrace}"
268
-
269
- class AddPullRequestCommentTool(BaseTool):
270
- api_wrapper: BitbucketAPIWrapper = Field(default_factory=BitbucketAPIWrapper)
271
- name: str = "add_pull_request_comment"
272
- description: str = """This tool is a wrapper for the Bitbucket API to add a comment to a pull request.
273
- Supports multiple content types and inline comments."""
274
- args_schema: Type[BaseModel] = create_model(
275
- "AddPullRequestCommentInput",
276
- pr_id=(str, Field(description="The ID of the pull request to add a comment to.")),
277
- content=(str, Field(description="The comment content. Can be a string (raw text) or a dict with keys 'raw', 'markup', 'html'.")),
278
- inline=(Optional[dict], Field(default=None, description="Inline comment details. Example: {'from': 57, 'to': 122, 'path': '<string>'}"))
279
- )
280
-
281
- def _run(self, pr_id: str, content: str, inline: Optional[dict] = None):
282
- try:
283
- logger.debug(f"Add comment to pull request {pr_id}.")
284
- return self.api_wrapper.add_pull_request_comment(pr_id, content, inline)
285
- except Exception as e:
286
- stacktrace = traceback.format_exc()
287
- logger.error(f"Can't add comment to pull request `{pr_id}` due to error:\n{stacktrace}")
288
- return f"Can't add comment to pull request `{pr_id}` due to error:\n{stacktrace}"
289
-
290
- __all__ = [
291
- {"name": "create_branch", "tool": CreateBitbucketBranchTool},
292
- {"name": "create_pull_request", "tool": CreatePRTool},
293
- {"name": "create_file", "tool": CreateFileTool},
294
- {"name": "set_active_branch", "tool": SetActiveBranchTool},
295
- {"name": "list_branches_in_repo", "tool": ListBranchesTool},
296
- {"name": "read_file", "tool": ReadFileTool},
297
- {"name": "get_files", "tool": GetFilesListTool},
298
- {"name": "update_file", "tool": UpdateFileTool},
299
- {"name": "loader", "tool": LoaderTool},
300
- {"name": "get_pull_requests_commits", "tool": GetPullRequestsCommitsTool},
301
- {"name": "get_pull_request", "tool": GetPullRequestTool},
302
- {"name": "get_pull_requests_changes", "tool": GetPullRequestsChangesTool},
303
- {"name": "add_pull_request_comment", "tool": AddPullRequestCommentTool}
304
- ]