alita-sdk 0.3.175__py3-none-any.whl → 0.3.177__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 (44) hide show
  1. alita_sdk/community/__init__.py +7 -17
  2. alita_sdk/tools/carrier/api_wrapper.py +6 -0
  3. alita_sdk/tools/carrier/backend_tests_tool.py +308 -7
  4. alita_sdk/tools/carrier/carrier_sdk.py +18 -0
  5. alita_sdk/tools/carrier/create_ui_test_tool.py +90 -109
  6. alita_sdk/tools/carrier/run_ui_test_tool.py +311 -184
  7. alita_sdk/tools/carrier/tools.py +2 -1
  8. alita_sdk/tools/confluence/api_wrapper.py +1 -0
  9. {alita_sdk-0.3.175.dist-info → alita_sdk-0.3.177.dist-info}/METADATA +2 -2
  10. {alita_sdk-0.3.175.dist-info → alita_sdk-0.3.177.dist-info}/RECORD +13 -44
  11. alita_sdk/community/browseruse/__init__.py +0 -73
  12. alita_sdk/community/browseruse/api_wrapper.py +0 -288
  13. alita_sdk/community/deep_researcher/__init__.py +0 -70
  14. alita_sdk/community/deep_researcher/agents/__init__.py +0 -1
  15. alita_sdk/community/deep_researcher/agents/baseclass.py +0 -182
  16. alita_sdk/community/deep_researcher/agents/knowledge_gap_agent.py +0 -74
  17. alita_sdk/community/deep_researcher/agents/long_writer_agent.py +0 -251
  18. alita_sdk/community/deep_researcher/agents/planner_agent.py +0 -124
  19. alita_sdk/community/deep_researcher/agents/proofreader_agent.py +0 -80
  20. alita_sdk/community/deep_researcher/agents/thinking_agent.py +0 -64
  21. alita_sdk/community/deep_researcher/agents/tool_agents/__init__.py +0 -20
  22. alita_sdk/community/deep_researcher/agents/tool_agents/crawl_agent.py +0 -87
  23. alita_sdk/community/deep_researcher/agents/tool_agents/search_agent.py +0 -96
  24. alita_sdk/community/deep_researcher/agents/tool_selector_agent.py +0 -83
  25. alita_sdk/community/deep_researcher/agents/utils/__init__.py +0 -0
  26. alita_sdk/community/deep_researcher/agents/utils/parse_output.py +0 -148
  27. alita_sdk/community/deep_researcher/agents/writer_agent.py +0 -63
  28. alita_sdk/community/deep_researcher/api_wrapper.py +0 -116
  29. alita_sdk/community/deep_researcher/deep_research.py +0 -185
  30. alita_sdk/community/deep_researcher/examples/deep_example.py +0 -30
  31. alita_sdk/community/deep_researcher/examples/iterative_example.py +0 -34
  32. alita_sdk/community/deep_researcher/examples/report_plan_example.py +0 -27
  33. alita_sdk/community/deep_researcher/iterative_research.py +0 -419
  34. alita_sdk/community/deep_researcher/llm_config.py +0 -87
  35. alita_sdk/community/deep_researcher/main.py +0 -67
  36. alita_sdk/community/deep_researcher/tools/__init__.py +0 -2
  37. alita_sdk/community/deep_researcher/tools/crawl_website.py +0 -109
  38. alita_sdk/community/deep_researcher/tools/web_search.py +0 -294
  39. alita_sdk/community/deep_researcher/utils/__init__.py +0 -0
  40. alita_sdk/community/deep_researcher/utils/md_to_pdf.py +0 -8
  41. alita_sdk/community/deep_researcher/utils/os.py +0 -21
  42. {alita_sdk-0.3.175.dist-info → alita_sdk-0.3.177.dist-info}/WHEEL +0 -0
  43. {alita_sdk-0.3.175.dist-info → alita_sdk-0.3.177.dist-info}/licenses/LICENSE +0 -0
  44. {alita_sdk-0.3.175.dist-info → alita_sdk-0.3.177.dist-info}/top_level.txt +0 -0
@@ -6,6 +6,7 @@ from langchain_core.tools import BaseTool, ToolException
6
6
  from pydantic.fields import Field
7
7
  from pydantic import create_model, BaseModel
8
8
  from .api_wrapper import CarrierAPIWrapper
9
+ from .carrier_sdk import CarrierAPIError
9
10
 
10
11
  logger = logging.getLogger(__name__)
11
12
 
@@ -16,39 +17,26 @@ class CreateUITestTool(BaseTool):
16
17
  description: str = "Create a new UI test in the Carrier platform."
17
18
  args_schema: Type[BaseModel] = create_model(
18
19
  "CreateUITestInput",
19
- **{
20
- "name": (str, Field(default="", description="Test name")),
21
- "test_type": (str, Field(default="", description="Test type")),
22
- "env_type": (str, Field(default="", description="Environment type")),
23
- "entrypoint": (str, Field(default="", description="Entry point file (e.g., my_test.js)")),
24
- "runner": (str, Field(default="", description="Test runner type")),
25
- "repo": (str, Field(default="", description="Git repository URL")),
26
- "branch": (str, Field(default="", description="Git branch name")),
27
- "username": (str, Field(default="", description="Git username")),
28
- "password": (str, Field(default="", description="Git password")),
29
- "cpu_quota": (int, Field(default=2, description="CPU quota (cores)")),
30
- "memory_quota": (int, Field(default=5, description="Memory quota (GB)")),
31
- "custom_cmd": (str, Field(default="", description="Optional custom command")),
32
- "parallel_runners": (int, Field(default=1, description="Number of parallel runners")),
33
- "loops": (int, Field(default=1, description="Number of loops")),
34
- "aggregation": (str, Field(default="max", description="Aggregation method (max, min, avg)")),
35
- }
20
+ message=(str, Field(description="User request message for creating UI test")),
21
+ name=(str, Field(description="Test name (e.g., 'My UI Test')")),
22
+ test_type=(str, Field(description="Test type (e.g., 'performance')")),
23
+ env_type=(str, Field(description="Environment type (e.g., 'staging')")),
24
+ entrypoint=(str, Field(description="Entry point file (e.g., 'my_test.js')")),
25
+ runner=(str, Field(description="Test runner type. Available runners: Lighthouse-NPM_V12, Lighthouse-Nodejs, Lighthouse-NPM, Lighthouse-NPM_V11, Sitespeed (Browsertime), Sitespeed (New Entrypoint BETA), Sitespeed (New Version BETA), Sitespeed V36")),
26
+ repo=(str, Field(description="Git repository URL (e.g., 'https://github.com/user/repo.git')")),
27
+ branch=(str, Field(description="Git branch name (e.g., 'main')")),
28
+ username=(str, Field(description="Git username")),
29
+ password=(str, Field(description="Git password")),
30
+ cpu_quota=(int, Field(description="CPU quota in cores (e.g., 2)")),
31
+ memory_quota=(int, Field(description="Memory quota in GB (e.g., 5)")),
32
+ parallel_runners=(int, Field(description="Number of parallel runners (e.g., 1)")),
33
+ loops=(int, Field(description="Number of loops (e.g., 1)")),
34
+ **{"custom_cmd": (str, Field(default="", description="Optional custom command (e.g., '--login=\"qwerty\"')"))}
36
35
  )
37
36
 
38
37
  def _run(self, **kwargs):
39
38
  try:
40
- # Check if all required parameters are provided
41
- required_params = ["name", "test_type", "env_type", "entrypoint", "runner", "repo", "branch", "username", "password"]
42
- missing_params = []
43
-
44
- for param in required_params:
45
- if not kwargs.get(param) or kwargs.get(param).strip() == "":
46
- missing_params.append(param)
47
-
48
- if missing_params:
49
- return self._missing_parameters_response(missing_params)
50
-
51
- # Create the UI test
39
+ # Create the UI test with provided parameters
52
40
  return self._create_ui_test(kwargs)
53
41
 
54
42
  except Exception:
@@ -56,71 +44,34 @@ class CreateUITestTool(BaseTool):
56
44
  logger.error(f"Error creating UI test: {stacktrace}")
57
45
  raise ToolException(stacktrace)
58
46
 
59
- def _missing_parameters_response(self, missing_params=None):
60
- """Response when required parameters are missing."""
61
- available_runners = [
62
- "Lighthouse-NPM_V12",
63
- "Lighthouse-Nodejs",
64
- "Lighthouse-NPM",
65
- "Lighthouse-NPM_V11",
66
- "Sitespeed (Browsertime)",
67
- "Sitespeed (New Entrypoint BETA)",
68
- "Sitespeed (New Version BETA)",
69
- "Sitespeed V36"
70
- ]
71
-
72
- message = [
73
- "# 📝 Create UI Test - Required Parameters",
74
- "",
75
- "To create a new UI test, please provide the following parameters:",
76
- "",
77
- "## 🔴 Required Parameters:",
78
- "- **name**: Test name (e.g., 'My UI Test')",
79
- "- **test_type**: Test type (e.g., 'performance')",
80
- "- **env_type**: Environment type (e.g., 'staging')",
81
- "- **entrypoint**: Entry point file (e.g., 'my_test.js')",
82
- "- **runner**: Test runner (see available options below)",
83
- "- **repo**: Git repository URL (e.g., 'https://github.com/user/repo.git')",
84
- "- **branch**: Git branch name (e.g., 'main')",
85
- "- **username**: Git username",
86
- "- **password**: Git password",
87
- "",
88
- "## 🟡 Optional Parameters:",
89
- "- **cpu_quota**: CPU quota in cores (default: 2)",
90
- "- **memory_quota**: Memory quota in GB (default: 5)", "- **custom_cmd**: Optional custom command (e.g., '--login=\"qwerty\"')",
91
- "- **parallel_runners**: Number of parallel runners (default: 1)",
92
- "- **loops**: Number of loops (default: 1)",
93
- "",
94
- "## 🚀 Available Runners:",
95
- ]
96
-
97
- for runner in available_runners:
98
- message.append(f"- {runner}")
99
-
100
- message.extend([
101
- "",
102
- "## 💡 Example:",
103
- "```",
104
- "name: 'My Performance Test'",
105
- "test_type: 'performance'",
106
- "env_type: 'staging'",
107
- "entrypoint: 'lighthouse_test.js'",
108
- "runner: 'Lighthouse-NPM_V12'",
109
- "repo: 'https://github.com/mycompany/tests.git'", "branch: 'main'",
110
- "username: 'myusername'",
111
- "password: 'mypassword'",
112
- "```",
113
- "",
114
- "**Note:** Aggregation method is automatically set to 'max'."
115
- ])
116
-
117
- if missing_params:
118
- message.insert(2, f"❌ **Missing parameters:** {', '.join(missing_params)}")
119
- message.insert(3, "")
120
-
121
- return {
122
- "message": "\n".join(message)
123
- }
47
+ def _parse_validation_error(self, error_message: str) -> str:
48
+ """Parse validation error message and format it for user display."""
49
+ try:
50
+ # Try to extract JSON validation errors from the message
51
+ import re
52
+ json_match = re.search(r'\[.*\]', error_message)
53
+ if json_match:
54
+ json_str = json_match.group(0)
55
+ try:
56
+ validation_errors = json.loads(json_str)
57
+ if isinstance(validation_errors, list):
58
+ formatted_errors = []
59
+ for error in validation_errors:
60
+ if isinstance(error, dict):
61
+ field = error.get("loc", ["unknown"])[0] if error.get("loc") else "unknown"
62
+ message = error.get("msg", "Invalid value")
63
+ formatted_errors.append(f"- **{field}**: {message}")
64
+
65
+ if formatted_errors:
66
+ return "\n".join(formatted_errors)
67
+ except json.JSONDecodeError:
68
+ pass
69
+
70
+ # If we can't parse JSON, return the original message
71
+ return error_message
72
+
73
+ except Exception:
74
+ return error_message
124
75
 
125
76
  def _create_ui_test(self, params):
126
77
  """Create UI test using the provided parameters."""
@@ -139,25 +90,23 @@ class CreateUITestTool(BaseTool):
139
90
  "branch": params["branch"],
140
91
  "username": params["username"],
141
92
  "password": params["password"]
142
- },
143
- "env_vars": {
144
- "cpu_quota": params.get("cpu_quota", 2),
145
- "memory_quota": params.get("memory_quota", 5),
93
+ }, "env_vars": {
94
+ "cpu_quota": params["cpu_quota"],
95
+ "memory_quota": params["memory_quota"],
146
96
  "cloud_settings": {}
147
97
  },
148
- "parallel_runners": params.get("parallel_runners", 1),
98
+ "parallel_runners": params["parallel_runners"],
149
99
  "cc_env_vars": {},
150
100
  "location": "default",
151
- "loops": params.get("loops", 1),
152
- "aggregation": params.get("aggregation", "max")
101
+ "loops": params["loops"],
102
+ "aggregation": "max"
153
103
  },
154
104
  "test_parameters": [],
155
105
  "integrations": {},
156
106
  "schedules": [],
157
107
  "run_test": False
158
108
  }
159
-
160
- # Add custom_cmd if provided
109
+ # Add custom_cmd if provided
161
110
  if params.get("custom_cmd") and params["custom_cmd"].strip():
162
111
  post_body["common_params"]["env_vars"]["custom_cmd"] = params["custom_cmd"]
163
112
 
@@ -180,11 +129,11 @@ class CreateUITestTool(BaseTool):
180
129
  - **Entry Point:** `{params['entrypoint']}`
181
130
 
182
131
  ## Configuration:
183
- - **CPU Quota:** {params.get('cpu_quota', 2)} cores
184
- - **Memory Quota:** {params.get('memory_quota', 5)} GB
185
- - **Parallel Runners:** {params.get('parallel_runners', 1)}
186
- - **Loops:** {params.get('loops', 1)}
187
- - **Aggregation:** {params.get('aggregation', 'max')}
132
+ - **CPU Quota:** {params['cpu_quota']} cores
133
+ - **Memory Quota:** {params['memory_quota']} GB
134
+ - **Parallel Runners:** {params['parallel_runners']}
135
+ - **Loops:** {params['loops']}
136
+ - **Aggregation:** max
188
137
  {f"- **Custom Command:** `{params['custom_cmd']}`" if params.get('custom_cmd') else ""}
189
138
 
190
139
  ## 🎯 Next Steps:
@@ -194,6 +143,38 @@ class CreateUITestTool(BaseTool):
194
143
  else:
195
144
  return "❌ **Failed to create UI test. Please check your parameters and try again.**"
196
145
 
146
+ except CarrierAPIError as api_error:
147
+ # Handle API-specific errors with detailed validation messages
148
+ error_message = str(api_error)
149
+ logger.error(f"CarrierAPIError creating UI test: {error_message}")
150
+ # Try to extract validation details from the error message
151
+ if "400" in error_message:
152
+ parsed_errors = self._parse_validation_error(error_message)
153
+ return f"""# ❌ UI Test Creation Failed - Validation Error
154
+
155
+ ## 🚫 Invalid Input Parameters:
156
+ The Carrier platform rejected your request due to validation errors.
157
+
158
+ ## 📋 Validation Errors:
159
+ {parsed_errors}
160
+
161
+ ## 💡 Common Issues:
162
+ - **Test name**: Only letters, numbers, and "_" are allowed
163
+ - **Repository URL**: Must be a valid Git repository URL
164
+ - **Runner**: Must be one of the available runner types: Lighthouse-NPM_V12, Lighthouse-Nodejs, Lighthouse-NPM, Lighthouse-NPM_V11, Sitespeed (Browsertime), Sitespeed (New Entrypoint BETA), Sitespeed (New Version BETA), Sitespeed V36
165
+ - **Numeric values**: CPU quota, memory quota, parallel runners, and loops must be positive integers
166
+
167
+ ## 🔧 Please fix the validation errors above and try again."""
168
+ else:
169
+ return f"""# ❌ UI Test Creation Failed
170
+
171
+ ## 🚫 API Error:
172
+ ```
173
+ {error_message}
174
+ ```
175
+
176
+ ## 💡 Please check your parameters and try again."""
177
+
197
178
  except Exception as e:
198
179
  logger.error(f"Error creating UI test: {e}")
199
- raise ToolException(f"Failed to create UI test: {str(e)}")
180
+ raise ToolException(f"Failed to create UI test: {str(e)}")