agentscope-runtime 0.2.0b2__py3-none-any.whl → 1.0.0b1__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.
- agentscope_runtime/adapters/__init__.py +0 -0
- agentscope_runtime/adapters/agentscope/__init__.py +0 -0
- agentscope_runtime/adapters/agentscope/long_term_memory/__init__.py +6 -0
- agentscope_runtime/adapters/agentscope/long_term_memory/_long_term_memory_adapter.py +258 -0
- agentscope_runtime/adapters/agentscope/memory/__init__.py +6 -0
- agentscope_runtime/adapters/agentscope/memory/_memory_adapter.py +152 -0
- agentscope_runtime/adapters/agentscope/message.py +535 -0
- agentscope_runtime/adapters/agentscope/stream.py +474 -0
- agentscope_runtime/adapters/agentscope/tool/__init__.py +9 -0
- agentscope_runtime/adapters/agentscope/tool/sandbox_tool.py +69 -0
- agentscope_runtime/adapters/agentscope/tool/tool.py +233 -0
- agentscope_runtime/adapters/autogen/__init__.py +0 -0
- agentscope_runtime/adapters/autogen/tool/__init__.py +7 -0
- agentscope_runtime/adapters/autogen/tool/tool.py +211 -0
- agentscope_runtime/adapters/text/__init__.py +0 -0
- agentscope_runtime/adapters/text/stream.py +29 -0
- agentscope_runtime/common/collections/redis_mapping.py +4 -1
- agentscope_runtime/common/container_clients/fc_client.py +855 -0
- agentscope_runtime/common/utils/__init__.py +0 -0
- agentscope_runtime/common/utils/lazy_loader.py +57 -0
- agentscope_runtime/engine/__init__.py +25 -18
- agentscope_runtime/engine/app/agent_app.py +161 -91
- agentscope_runtime/engine/app/base_app.py +4 -118
- agentscope_runtime/engine/constant.py +8 -0
- agentscope_runtime/engine/deployers/__init__.py +8 -0
- agentscope_runtime/engine/deployers/adapter/__init__.py +2 -0
- agentscope_runtime/engine/deployers/adapter/a2a/a2a_adapter_utils.py +0 -21
- agentscope_runtime/engine/deployers/adapter/a2a/a2a_protocol_adapter.py +28 -9
- agentscope_runtime/engine/deployers/adapter/responses/__init__.py +2 -0
- agentscope_runtime/engine/deployers/adapter/responses/response_api_adapter_utils.py +5 -2
- agentscope_runtime/engine/deployers/adapter/responses/response_api_protocol_adapter.py +1 -1
- agentscope_runtime/engine/deployers/agentrun_deployer.py +2541 -0
- agentscope_runtime/engine/deployers/cli_fc_deploy.py +1 -1
- agentscope_runtime/engine/deployers/kubernetes_deployer.py +9 -21
- agentscope_runtime/engine/deployers/local_deployer.py +47 -74
- agentscope_runtime/engine/deployers/modelstudio_deployer.py +216 -50
- agentscope_runtime/engine/deployers/utils/app_runner_utils.py +29 -0
- agentscope_runtime/engine/deployers/utils/detached_app.py +510 -0
- agentscope_runtime/engine/deployers/utils/docker_image_utils/__init__.py +1 -1
- agentscope_runtime/engine/deployers/utils/docker_image_utils/dockerfile_generator.py +1 -1
- agentscope_runtime/engine/deployers/utils/docker_image_utils/{runner_image_factory.py → image_factory.py} +121 -61
- agentscope_runtime/engine/deployers/utils/package.py +693 -0
- agentscope_runtime/engine/deployers/utils/service_utils/__init__.py +0 -5
- agentscope_runtime/engine/deployers/utils/service_utils/fastapi_factory.py +256 -282
- agentscope_runtime/engine/deployers/utils/service_utils/fastapi_templates.py +2 -4
- agentscope_runtime/engine/deployers/utils/service_utils/process_manager.py +23 -1
- agentscope_runtime/engine/deployers/utils/templates/app_main.py.j2 +84 -0
- agentscope_runtime/engine/deployers/utils/templates/runner_main.py.j2 +95 -0
- agentscope_runtime/engine/deployers/utils/{service_utils → templates}/standalone_main.py.j2 +0 -45
- agentscope_runtime/engine/deployers/utils/wheel_packager.py +119 -18
- agentscope_runtime/engine/helpers/runner.py +40 -0
- agentscope_runtime/engine/runner.py +170 -130
- agentscope_runtime/engine/schemas/agent_schemas.py +114 -3
- agentscope_runtime/engine/schemas/modelstudio_llm.py +4 -2
- agentscope_runtime/engine/schemas/oai_llm.py +23 -23
- agentscope_runtime/engine/schemas/response_api.py +65 -0
- agentscope_runtime/engine/schemas/session.py +24 -0
- agentscope_runtime/engine/services/__init__.py +0 -9
- agentscope_runtime/engine/services/agent_state/__init__.py +16 -0
- agentscope_runtime/engine/services/agent_state/redis_state_service.py +113 -0
- agentscope_runtime/engine/services/agent_state/state_service.py +179 -0
- agentscope_runtime/engine/services/memory/__init__.py +24 -0
- agentscope_runtime/engine/services/{mem0_memory_service.py → memory/mem0_memory_service.py} +17 -13
- agentscope_runtime/engine/services/{memory_service.py → memory/memory_service.py} +28 -7
- agentscope_runtime/engine/services/{redis_memory_service.py → memory/redis_memory_service.py} +1 -1
- agentscope_runtime/engine/services/{reme_personal_memory_service.py → memory/reme_personal_memory_service.py} +9 -6
- agentscope_runtime/engine/services/{reme_task_memory_service.py → memory/reme_task_memory_service.py} +2 -2
- agentscope_runtime/engine/services/{tablestore_memory_service.py → memory/tablestore_memory_service.py} +12 -18
- agentscope_runtime/engine/services/sandbox/__init__.py +13 -0
- agentscope_runtime/engine/services/{sandbox_service.py → sandbox/sandbox_service.py} +86 -71
- agentscope_runtime/engine/services/session_history/__init__.py +23 -0
- agentscope_runtime/engine/services/{redis_session_history_service.py → session_history/redis_session_history_service.py} +3 -2
- agentscope_runtime/engine/services/{session_history_service.py → session_history/session_history_service.py} +44 -34
- agentscope_runtime/engine/services/{tablestore_session_history_service.py → session_history/tablestore_session_history_service.py} +14 -19
- agentscope_runtime/engine/services/utils/tablestore_service_utils.py +2 -2
- agentscope_runtime/engine/tracing/base.py +10 -9
- agentscope_runtime/engine/tracing/message_util.py +1 -1
- agentscope_runtime/engine/tracing/tracing_util.py +7 -2
- agentscope_runtime/sandbox/__init__.py +10 -2
- agentscope_runtime/sandbox/box/agentbay/__init__.py +4 -0
- agentscope_runtime/sandbox/box/agentbay/agentbay_sandbox.py +559 -0
- agentscope_runtime/sandbox/box/base/base_sandbox.py +12 -0
- agentscope_runtime/sandbox/box/browser/browser_sandbox.py +115 -11
- agentscope_runtime/sandbox/box/cloud/__init__.py +4 -0
- agentscope_runtime/sandbox/box/cloud/cloud_sandbox.py +254 -0
- agentscope_runtime/sandbox/box/filesystem/filesystem_sandbox.py +66 -0
- agentscope_runtime/sandbox/box/gui/gui_sandbox.py +42 -0
- agentscope_runtime/sandbox/box/mobile/__init__.py +4 -0
- agentscope_runtime/sandbox/box/mobile/box/__init__.py +0 -0
- agentscope_runtime/sandbox/box/mobile/mobile_sandbox.py +216 -0
- agentscope_runtime/sandbox/box/training_box/training_box.py +2 -2
- agentscope_runtime/sandbox/client/http_client.py +1 -0
- agentscope_runtime/sandbox/enums.py +2 -0
- agentscope_runtime/sandbox/manager/sandbox_manager.py +18 -2
- agentscope_runtime/sandbox/manager/server/app.py +12 -0
- agentscope_runtime/sandbox/manager/server/config.py +19 -0
- agentscope_runtime/sandbox/model/manager_config.py +79 -2
- agentscope_runtime/sandbox/utils.py +0 -18
- agentscope_runtime/tools/RAGs/__init__.py +0 -0
- agentscope_runtime/tools/RAGs/modelstudio_rag.py +377 -0
- agentscope_runtime/tools/RAGs/modelstudio_rag_lite.py +219 -0
- agentscope_runtime/tools/__init__.py +119 -0
- agentscope_runtime/tools/_constants.py +18 -0
- agentscope_runtime/tools/alipay/__init__.py +4 -0
- agentscope_runtime/tools/alipay/base.py +334 -0
- agentscope_runtime/tools/alipay/payment.py +835 -0
- agentscope_runtime/tools/alipay/subscribe.py +551 -0
- agentscope_runtime/tools/base.py +264 -0
- agentscope_runtime/tools/cli/__init__.py +0 -0
- agentscope_runtime/tools/cli/modelstudio_mcp_server.py +78 -0
- agentscope_runtime/tools/generations/__init__.py +75 -0
- agentscope_runtime/tools/generations/async_image_to_video.py +350 -0
- agentscope_runtime/tools/generations/async_image_to_video_wan25.py +366 -0
- agentscope_runtime/tools/generations/async_speech_to_video.py +422 -0
- agentscope_runtime/tools/generations/async_text_to_video.py +320 -0
- agentscope_runtime/tools/generations/async_text_to_video_wan25.py +334 -0
- agentscope_runtime/tools/generations/image_edit.py +208 -0
- agentscope_runtime/tools/generations/image_edit_wan25.py +193 -0
- agentscope_runtime/tools/generations/image_generation.py +202 -0
- agentscope_runtime/tools/generations/image_generation_wan25.py +201 -0
- agentscope_runtime/tools/generations/image_style_repaint.py +208 -0
- agentscope_runtime/tools/generations/image_to_video.py +233 -0
- agentscope_runtime/tools/generations/qwen_image_edit.py +205 -0
- agentscope_runtime/tools/generations/qwen_image_generation.py +214 -0
- agentscope_runtime/tools/generations/qwen_text_to_speech.py +154 -0
- agentscope_runtime/tools/generations/speech_to_text.py +260 -0
- agentscope_runtime/tools/generations/speech_to_video.py +314 -0
- agentscope_runtime/tools/generations/text_to_video.py +221 -0
- agentscope_runtime/tools/mcp_wrapper.py +215 -0
- agentscope_runtime/tools/realtime_clients/__init__.py +13 -0
- agentscope_runtime/tools/realtime_clients/asr_client.py +27 -0
- agentscope_runtime/tools/realtime_clients/azure_asr_client.py +195 -0
- agentscope_runtime/tools/realtime_clients/azure_tts_client.py +383 -0
- agentscope_runtime/tools/realtime_clients/modelstudio_asr_client.py +151 -0
- agentscope_runtime/tools/realtime_clients/modelstudio_tts_client.py +199 -0
- agentscope_runtime/tools/realtime_clients/realtime_tool.py +55 -0
- agentscope_runtime/tools/realtime_clients/tts_client.py +33 -0
- agentscope_runtime/tools/searches/__init__.py +3 -0
- agentscope_runtime/tools/searches/modelstudio_search.py +877 -0
- agentscope_runtime/tools/searches/modelstudio_search_lite.py +310 -0
- agentscope_runtime/tools/utils/__init__.py +0 -0
- agentscope_runtime/tools/utils/api_key_util.py +45 -0
- agentscope_runtime/tools/utils/crypto_utils.py +99 -0
- agentscope_runtime/tools/utils/mcp_util.py +35 -0
- agentscope_runtime/version.py +1 -1
- {agentscope_runtime-0.2.0b2.dist-info → agentscope_runtime-1.0.0b1.dist-info}/METADATA +234 -165
- agentscope_runtime-1.0.0b1.dist-info/RECORD +240 -0
- {agentscope_runtime-0.2.0b2.dist-info → agentscope_runtime-1.0.0b1.dist-info}/entry_points.txt +1 -0
- agentscope_runtime/engine/agents/__init__.py +0 -2
- agentscope_runtime/engine/agents/agentscope_agent.py +0 -488
- agentscope_runtime/engine/agents/agno_agent.py +0 -220
- agentscope_runtime/engine/agents/autogen_agent.py +0 -250
- agentscope_runtime/engine/agents/base_agent.py +0 -29
- agentscope_runtime/engine/agents/langgraph_agent.py +0 -59
- agentscope_runtime/engine/agents/utils.py +0 -53
- agentscope_runtime/engine/deployers/utils/package_project_utils.py +0 -1163
- agentscope_runtime/engine/deployers/utils/service_utils/service_config.py +0 -75
- agentscope_runtime/engine/deployers/utils/service_utils/service_factory.py +0 -220
- agentscope_runtime/engine/helpers/helper.py +0 -179
- agentscope_runtime/engine/schemas/context.py +0 -54
- agentscope_runtime/engine/services/context_manager.py +0 -164
- agentscope_runtime/engine/services/environment_manager.py +0 -50
- agentscope_runtime/engine/services/manager.py +0 -174
- agentscope_runtime/engine/services/rag_service.py +0 -195
- agentscope_runtime/engine/services/tablestore_rag_service.py +0 -143
- agentscope_runtime/sandbox/tools/__init__.py +0 -12
- agentscope_runtime/sandbox/tools/base/__init__.py +0 -8
- agentscope_runtime/sandbox/tools/base/tool.py +0 -52
- agentscope_runtime/sandbox/tools/browser/__init__.py +0 -57
- agentscope_runtime/sandbox/tools/browser/tool.py +0 -597
- agentscope_runtime/sandbox/tools/filesystem/__init__.py +0 -32
- agentscope_runtime/sandbox/tools/filesystem/tool.py +0 -319
- agentscope_runtime/sandbox/tools/function_tool.py +0 -321
- agentscope_runtime/sandbox/tools/gui/__init__.py +0 -7
- agentscope_runtime/sandbox/tools/gui/tool.py +0 -77
- agentscope_runtime/sandbox/tools/mcp_tool.py +0 -195
- agentscope_runtime/sandbox/tools/sandbox_tool.py +0 -104
- agentscope_runtime/sandbox/tools/tool.py +0 -238
- agentscope_runtime/sandbox/tools/utils.py +0 -68
- agentscope_runtime-0.2.0b2.dist-info/RECORD +0 -183
- {agentscope_runtime-0.2.0b2.dist-info → agentscope_runtime-1.0.0b1.dist-info}/WHEEL +0 -0
- {agentscope_runtime-0.2.0b2.dist-info → agentscope_runtime-1.0.0b1.dist-info}/licenses/LICENSE +0 -0
- {agentscope_runtime-0.2.0b2.dist-info → agentscope_runtime-1.0.0b1.dist-info}/top_level.txt +0 -0
|
@@ -53,42 +53,80 @@ class BrowserSandbox(GUIMixin, BaseSandbox):
|
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
def browser_close(self):
|
|
56
|
+
"""Close the current browser page."""
|
|
56
57
|
return self.call_tool("browser_close", {})
|
|
57
58
|
|
|
58
59
|
def browser_resize(self, width: int, height: int):
|
|
60
|
+
"""Resize the browser window.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
width (int): Width of the browser window.
|
|
64
|
+
height (int): Height of the browser window.
|
|
65
|
+
"""
|
|
59
66
|
return self.call_tool(
|
|
60
67
|
"browser_resize",
|
|
61
68
|
{"width": width, "height": height},
|
|
62
69
|
)
|
|
63
70
|
|
|
64
71
|
def browser_console_messages(self):
|
|
72
|
+
"""Return all console messages from the browser."""
|
|
65
73
|
return self.call_tool("browser_console_messages", {})
|
|
66
74
|
|
|
67
75
|
def browser_handle_dialog(self, accept: bool, prompt_text: str = ""):
|
|
76
|
+
"""Handle a dialog popup.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
accept (bool): Whether to accept the dialog.
|
|
80
|
+
prompt_text (str, optional): Text to input if the dialog is a
|
|
81
|
+
prompt.
|
|
82
|
+
"""
|
|
68
83
|
return self.call_tool(
|
|
69
84
|
"browser_handle_dialog",
|
|
70
85
|
{"accept": accept, "promptText": prompt_text},
|
|
71
86
|
)
|
|
72
87
|
|
|
73
88
|
def browser_file_upload(self, paths: list):
|
|
89
|
+
"""Upload one or multiple files in the browser.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
paths (list[str]): Absolute paths to the files to upload.
|
|
93
|
+
"""
|
|
74
94
|
return self.call_tool("browser_file_upload", {"paths": paths})
|
|
75
95
|
|
|
76
96
|
def browser_press_key(self, key: str):
|
|
97
|
+
"""Press a key on the keyboard.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
key (str): Name of the key to press or a character to enter.
|
|
101
|
+
"""
|
|
77
102
|
return self.call_tool("browser_press_key", {"key": key})
|
|
78
103
|
|
|
79
104
|
def browser_navigate(self, url: str):
|
|
105
|
+
"""Navigate to a specified URL.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
url (str): The URL to load in the browser.
|
|
109
|
+
"""
|
|
80
110
|
return self.call_tool("browser_navigate", {"url": url})
|
|
81
111
|
|
|
82
112
|
def browser_navigate_back(self):
|
|
113
|
+
"""Go back to the previous page."""
|
|
83
114
|
return self.call_tool("browser_navigate_back", {})
|
|
84
115
|
|
|
85
116
|
def browser_navigate_forward(self):
|
|
117
|
+
"""Go forward to the next page."""
|
|
86
118
|
return self.call_tool("browser_navigate_forward", {})
|
|
87
119
|
|
|
88
120
|
def browser_network_requests(self):
|
|
121
|
+
"""Return all network requests since the page was loaded."""
|
|
89
122
|
return self.call_tool("browser_network_requests", {})
|
|
90
123
|
|
|
91
124
|
def browser_pdf_save(self, filename: str = ""):
|
|
125
|
+
"""Save the current page as a PDF.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
filename (str, optional): File name to save the PDF as.
|
|
129
|
+
"""
|
|
92
130
|
return self.call_tool("browser_pdf_save", {"filename": filename})
|
|
93
131
|
|
|
94
132
|
def browser_take_screenshot(
|
|
@@ -98,20 +136,33 @@ class BrowserSandbox(GUIMixin, BaseSandbox):
|
|
|
98
136
|
element: str = "",
|
|
99
137
|
ref: str = "",
|
|
100
138
|
):
|
|
139
|
+
"""Take a screenshot of the current page or of a specific element.
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
raw (bool, optional): If True, save in PNG without compression.
|
|
143
|
+
Defaults to False (JPEG).
|
|
144
|
+
filename (str, optional): File name for the screenshot.
|
|
145
|
+
element (str, optional): Human-readable element description to
|
|
146
|
+
screenshot.
|
|
147
|
+
ref (str, optional): Exact element reference from the page
|
|
148
|
+
snapshot.
|
|
149
|
+
"""
|
|
101
150
|
return self.call_tool(
|
|
102
151
|
"browser_take_screenshot",
|
|
103
|
-
{
|
|
104
|
-
"raw": raw,
|
|
105
|
-
"filename": filename,
|
|
106
|
-
"element": element,
|
|
107
|
-
"ref": ref,
|
|
108
|
-
},
|
|
152
|
+
{"raw": raw, "filename": filename, "element": element, "ref": ref},
|
|
109
153
|
)
|
|
110
154
|
|
|
111
155
|
def browser_snapshot(self):
|
|
156
|
+
"""Capture an accessibility snapshot of the current page."""
|
|
112
157
|
return self.call_tool("browser_snapshot", {})
|
|
113
158
|
|
|
114
159
|
def browser_click(self, element: str, ref: str):
|
|
160
|
+
"""Click on an element in the current page.
|
|
161
|
+
|
|
162
|
+
Args:
|
|
163
|
+
element (str): Human-readable element description to click.
|
|
164
|
+
ref (str): Exact element reference from the page snapshot.
|
|
165
|
+
"""
|
|
115
166
|
return self.call_tool(
|
|
116
167
|
"browser_click",
|
|
117
168
|
{"element": element, "ref": ref},
|
|
@@ -124,6 +175,14 @@ class BrowserSandbox(GUIMixin, BaseSandbox):
|
|
|
124
175
|
end_element: str,
|
|
125
176
|
end_ref: str,
|
|
126
177
|
):
|
|
178
|
+
"""Drag from one element and drop onto another.
|
|
179
|
+
|
|
180
|
+
Args:
|
|
181
|
+
start_element (str): Human-readable source element description.
|
|
182
|
+
start_ref (str): Exact source element reference.
|
|
183
|
+
end_element (str): Human-readable target element description.
|
|
184
|
+
end_ref (str): Exact target element reference.
|
|
185
|
+
"""
|
|
127
186
|
return self.call_tool(
|
|
128
187
|
"browser_drag",
|
|
129
188
|
{
|
|
@@ -135,6 +194,12 @@ class BrowserSandbox(GUIMixin, BaseSandbox):
|
|
|
135
194
|
)
|
|
136
195
|
|
|
137
196
|
def browser_hover(self, element: str, ref: str):
|
|
197
|
+
"""Hover over an element in the current page.
|
|
198
|
+
|
|
199
|
+
Args:
|
|
200
|
+
element (str): Human-readable element description.
|
|
201
|
+
ref (str): Exact element reference from the page snapshot.
|
|
202
|
+
"""
|
|
138
203
|
return self.call_tool(
|
|
139
204
|
"browser_hover",
|
|
140
205
|
{"element": element, "ref": ref},
|
|
@@ -148,6 +213,17 @@ class BrowserSandbox(GUIMixin, BaseSandbox):
|
|
|
148
213
|
submit: bool = False,
|
|
149
214
|
slowly: bool = False,
|
|
150
215
|
):
|
|
216
|
+
"""Type text into an editable element.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
element (str): Human-readable element description.
|
|
220
|
+
ref (str): Exact element reference.
|
|
221
|
+
text (str): Text to type into the element.
|
|
222
|
+
submit (bool, optional): Press Enter after typing. Defaults to
|
|
223
|
+
False.
|
|
224
|
+
slowly (bool, optional): Type one character at a time. Defaults
|
|
225
|
+
to False.
|
|
226
|
+
"""
|
|
151
227
|
return self.call_tool(
|
|
152
228
|
"browser_type",
|
|
153
229
|
{
|
|
@@ -160,25 +236,46 @@ class BrowserSandbox(GUIMixin, BaseSandbox):
|
|
|
160
236
|
)
|
|
161
237
|
|
|
162
238
|
def browser_select_option(self, element: str, ref: str, values: list):
|
|
239
|
+
"""Select options in a dropdown.
|
|
240
|
+
|
|
241
|
+
Args:
|
|
242
|
+
element (str): Human-readable element description.
|
|
243
|
+
ref (str): Exact element reference.
|
|
244
|
+
values (list[str]): Values to select.
|
|
245
|
+
"""
|
|
163
246
|
return self.call_tool(
|
|
164
247
|
"browser_select_option",
|
|
165
|
-
{
|
|
166
|
-
"element": element,
|
|
167
|
-
"ref": ref,
|
|
168
|
-
"values": values,
|
|
169
|
-
},
|
|
248
|
+
{"element": element, "ref": ref, "values": values},
|
|
170
249
|
)
|
|
171
250
|
|
|
172
251
|
def browser_tab_list(self):
|
|
252
|
+
"""List all browser tabs."""
|
|
173
253
|
return self.call_tool("browser_tab_list", {})
|
|
174
254
|
|
|
175
255
|
def browser_tab_new(self, url: str = ""):
|
|
256
|
+
"""Open a new browser tab.
|
|
257
|
+
|
|
258
|
+
Args:
|
|
259
|
+
url (str, optional): URL to open in the new tab. Blank if not
|
|
260
|
+
provided.
|
|
261
|
+
"""
|
|
176
262
|
return self.call_tool("browser_tab_new", {"url": url})
|
|
177
263
|
|
|
178
264
|
def browser_tab_select(self, index: int):
|
|
265
|
+
"""Select a browser tab by index.
|
|
266
|
+
|
|
267
|
+
Args:
|
|
268
|
+
index (int): Index of the tab to select.
|
|
269
|
+
"""
|
|
179
270
|
return self.call_tool("browser_tab_select", {"index": index})
|
|
180
271
|
|
|
181
272
|
def browser_tab_close(self, index: int = None):
|
|
273
|
+
"""Close a browser tab.
|
|
274
|
+
|
|
275
|
+
Args:
|
|
276
|
+
index (int, optional): Index of the tab to close.
|
|
277
|
+
Closes current tab if not provided.
|
|
278
|
+
"""
|
|
182
279
|
return self.call_tool("browser_tab_close", {"index": index})
|
|
183
280
|
|
|
184
281
|
def browser_wait_for(
|
|
@@ -187,6 +284,13 @@ class BrowserSandbox(GUIMixin, BaseSandbox):
|
|
|
187
284
|
text: str = None,
|
|
188
285
|
text_gone: str = None,
|
|
189
286
|
):
|
|
287
|
+
"""Wait for text to appear/disappear or for a specified time.
|
|
288
|
+
|
|
289
|
+
Args:
|
|
290
|
+
time (float, optional): Seconds to wait.
|
|
291
|
+
text (str, optional): Text to wait for.
|
|
292
|
+
text_gone (str, optional): Text to wait to disappear.
|
|
293
|
+
"""
|
|
190
294
|
return self.call_tool(
|
|
191
295
|
"browser_wait_for",
|
|
192
296
|
{
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
CloudSandbox base class for cloud-based sandbox implementations.
|
|
4
|
+
|
|
5
|
+
This module provides a base class for cloud sandbox implementations that
|
|
6
|
+
don't rely on local container management but instead communicate directly
|
|
7
|
+
with cloud APIs.
|
|
8
|
+
"""
|
|
9
|
+
import logging
|
|
10
|
+
from typing import Any, Dict, Optional
|
|
11
|
+
from abc import ABC, abstractmethod
|
|
12
|
+
|
|
13
|
+
from ...enums import SandboxType
|
|
14
|
+
from ...box.sandbox import Sandbox
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CloudSandbox(Sandbox, ABC):
|
|
20
|
+
"""
|
|
21
|
+
Base class for cloud-based sandbox implementations.
|
|
22
|
+
|
|
23
|
+
This class provides a unified interface for cloud sandbox services that
|
|
24
|
+
don't depend on local container management. Instead, they communicate
|
|
25
|
+
directly with cloud APIs to manage remote environments.
|
|
26
|
+
|
|
27
|
+
Key features:
|
|
28
|
+
- No local container dependency
|
|
29
|
+
- Direct cloud API communication
|
|
30
|
+
- Unified interface for cloud sandbox operations
|
|
31
|
+
- Support for different cloud providers
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
sandbox_id: Optional[str] = None,
|
|
37
|
+
timeout: int = 3000,
|
|
38
|
+
base_url: Optional[str] = None,
|
|
39
|
+
bearer_token: Optional[str] = None,
|
|
40
|
+
sandbox_type: SandboxType = SandboxType.AGENTBAY,
|
|
41
|
+
**kwargs,
|
|
42
|
+
):
|
|
43
|
+
"""
|
|
44
|
+
Initialize the cloud sandbox.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
sandbox_id: Optional sandbox ID for existing sessions
|
|
48
|
+
timeout: Timeout for operations in seconds
|
|
49
|
+
base_url: Base URL for cloud API (optional, may use default)
|
|
50
|
+
bearer_token: Authentication token for cloud API
|
|
51
|
+
sandbox_type: Type of sandbox (default: AGENTBAY)
|
|
52
|
+
**kwargs: Additional cloud-specific configuration
|
|
53
|
+
"""
|
|
54
|
+
# Initialize base attributes (similar to parent class but without
|
|
55
|
+
# SandboxManager)
|
|
56
|
+
# Note: We don't call super().__init__() because CloudSandbox uses a
|
|
57
|
+
# different architecture - it doesn't need SandboxManager, instead it
|
|
58
|
+
# communicates directly with cloud APIs through cloud_client.
|
|
59
|
+
self.base_url = base_url
|
|
60
|
+
self.embed_mode = False
|
|
61
|
+
self.manager_api = None
|
|
62
|
+
|
|
63
|
+
# Store cloud-specific configuration
|
|
64
|
+
self.cloud_config = kwargs
|
|
65
|
+
self.bearer_token = bearer_token
|
|
66
|
+
|
|
67
|
+
# Initialize cloud client
|
|
68
|
+
self.cloud_client = self._initialize_cloud_client()
|
|
69
|
+
|
|
70
|
+
# Initialize sandbox ID
|
|
71
|
+
if sandbox_id is None:
|
|
72
|
+
sandbox_id = self._create_cloud_sandbox()
|
|
73
|
+
if sandbox_id is None:
|
|
74
|
+
raise RuntimeError(
|
|
75
|
+
"Failed to create cloud sandbox. "
|
|
76
|
+
"Please check your cloud API credentials and "
|
|
77
|
+
"configuration.",
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
self._sandbox_id = sandbox_id
|
|
81
|
+
self.sandbox_type = sandbox_type
|
|
82
|
+
self.timeout = timeout
|
|
83
|
+
|
|
84
|
+
logger.info(f"Cloud sandbox initialized with ID: {self._sandbox_id}")
|
|
85
|
+
|
|
86
|
+
@abstractmethod
|
|
87
|
+
def _initialize_cloud_client(self):
|
|
88
|
+
"""
|
|
89
|
+
Initialize the cloud client for API communication.
|
|
90
|
+
|
|
91
|
+
This method should be implemented by subclasses to create
|
|
92
|
+
the appropriate cloud client (e.g., AgentBay client).
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
Cloud client instance
|
|
96
|
+
"""
|
|
97
|
+
# Abstract method - must be implemented by subclasses
|
|
98
|
+
|
|
99
|
+
@abstractmethod
|
|
100
|
+
def _create_cloud_sandbox(self) -> Optional[str]:
|
|
101
|
+
"""
|
|
102
|
+
Create a new cloud sandbox.
|
|
103
|
+
|
|
104
|
+
This method should be implemented by subclasses to create
|
|
105
|
+
a new sandbox using the cloud provider's API.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
Sandbox ID if successful, None otherwise
|
|
109
|
+
"""
|
|
110
|
+
# Abstract method - must be implemented by subclasses
|
|
111
|
+
|
|
112
|
+
@abstractmethod
|
|
113
|
+
def _delete_cloud_sandbox(self, sandbox_id: str) -> bool:
|
|
114
|
+
"""
|
|
115
|
+
Delete a cloud sandbox.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
sandbox_id: ID of the sandbox to delete
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
True if successful, False otherwise
|
|
122
|
+
"""
|
|
123
|
+
# Abstract method - must be implemented by subclasses
|
|
124
|
+
|
|
125
|
+
@abstractmethod
|
|
126
|
+
def _call_cloud_tool(
|
|
127
|
+
self,
|
|
128
|
+
tool_name: str,
|
|
129
|
+
arguments: Dict[str, Any],
|
|
130
|
+
) -> Any:
|
|
131
|
+
"""
|
|
132
|
+
Call a tool in the cloud environment.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
tool_name: Name of the tool to call
|
|
136
|
+
arguments: Arguments for the tool
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
Tool execution result
|
|
140
|
+
"""
|
|
141
|
+
# Abstract method - must be implemented by subclasses
|
|
142
|
+
|
|
143
|
+
def call_tool(
|
|
144
|
+
self,
|
|
145
|
+
name: str,
|
|
146
|
+
arguments: Optional[Dict[str, Any]] = None,
|
|
147
|
+
) -> Any:
|
|
148
|
+
"""
|
|
149
|
+
Call a tool in the cloud sandbox.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
name: Name of the tool to call
|
|
153
|
+
arguments: Arguments for the tool
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
Tool execution result
|
|
157
|
+
"""
|
|
158
|
+
if arguments is None:
|
|
159
|
+
arguments = {}
|
|
160
|
+
|
|
161
|
+
return self._call_cloud_tool(name, arguments)
|
|
162
|
+
|
|
163
|
+
def get_info(self) -> Dict[str, Any]:
|
|
164
|
+
"""
|
|
165
|
+
Get information about the cloud sandbox.
|
|
166
|
+
|
|
167
|
+
Returns:
|
|
168
|
+
Dictionary containing sandbox information
|
|
169
|
+
"""
|
|
170
|
+
return {
|
|
171
|
+
"sandbox_id": self._sandbox_id,
|
|
172
|
+
"sandbox_type": self.sandbox_type.value,
|
|
173
|
+
"cloud_provider": self._get_cloud_provider_name(),
|
|
174
|
+
"timeout": self.timeout,
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@abstractmethod
|
|
178
|
+
def _get_cloud_provider_name(self) -> str:
|
|
179
|
+
"""
|
|
180
|
+
Get the name of the cloud provider.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
Name of the cloud provider (e.g., "AgentBay")
|
|
184
|
+
"""
|
|
185
|
+
# Abstract method - must be implemented by subclasses
|
|
186
|
+
|
|
187
|
+
def list_tools(self, tool_type: Optional[str] = None) -> Dict[str, Any]:
|
|
188
|
+
"""
|
|
189
|
+
List available tools in the cloud sandbox.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
tool_type: Optional filter for tool type
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
Dictionary containing available tools
|
|
196
|
+
"""
|
|
197
|
+
# Default implementation - subclasses can override
|
|
198
|
+
return {
|
|
199
|
+
"tools": [],
|
|
200
|
+
"tool_type": tool_type,
|
|
201
|
+
"sandbox_id": self._sandbox_id,
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
def add_mcp_servers(
|
|
205
|
+
self,
|
|
206
|
+
server_configs: Dict[str, Any],
|
|
207
|
+
overwrite: bool = False,
|
|
208
|
+
) -> Dict[str, Any]:
|
|
209
|
+
"""
|
|
210
|
+
Add MCP servers to the cloud sandbox.
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
server_configs: Configuration for MCP servers
|
|
214
|
+
overwrite: Whether to overwrite existing configurations
|
|
215
|
+
|
|
216
|
+
Returns:
|
|
217
|
+
Result of the operation
|
|
218
|
+
"""
|
|
219
|
+
# Default implementation - subclasses can override
|
|
220
|
+
return {
|
|
221
|
+
"success": True,
|
|
222
|
+
"message": "MCP servers added successfully",
|
|
223
|
+
"overwrite": overwrite,
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
def _cleanup(self):
|
|
227
|
+
"""
|
|
228
|
+
Clean up cloud sandbox resources.
|
|
229
|
+
|
|
230
|
+
This method is called when the sandbox is being destroyed.
|
|
231
|
+
It ensures that cloud resources are properly released.
|
|
232
|
+
"""
|
|
233
|
+
try:
|
|
234
|
+
if self._sandbox_id:
|
|
235
|
+
success = self._delete_cloud_sandbox(self._sandbox_id)
|
|
236
|
+
if success:
|
|
237
|
+
logger.info(
|
|
238
|
+
f"Cloud session {self._sandbox_id} deleted "
|
|
239
|
+
f"successfully",
|
|
240
|
+
)
|
|
241
|
+
else:
|
|
242
|
+
logger.warning(
|
|
243
|
+
f"Failed to delete cloud session {self._sandbox_id}",
|
|
244
|
+
)
|
|
245
|
+
except Exception as e:
|
|
246
|
+
logger.error(f"Error during cloud sandbox cleanup: {e}")
|
|
247
|
+
|
|
248
|
+
def __enter__(self):
|
|
249
|
+
"""Context manager entry."""
|
|
250
|
+
return self
|
|
251
|
+
|
|
252
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
253
|
+
"""Context manager exit with cleanup."""
|
|
254
|
+
self._cleanup()
|
|
@@ -35,15 +35,41 @@ class FilesystemSandbox(GUIMixin, BaseSandbox):
|
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
def read_file(self, path: str):
|
|
38
|
+
"""Read the complete contents of a file.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
path (str): Path to the file to read.
|
|
42
|
+
"""
|
|
38
43
|
return self.call_tool("read_file", {"path": path})
|
|
39
44
|
|
|
40
45
|
def read_multiple_files(self, paths: list):
|
|
46
|
+
"""Read the contents of multiple files simultaneously.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
paths (list[str]): List of file paths to read.
|
|
50
|
+
"""
|
|
41
51
|
return self.call_tool("read_multiple_files", {"paths": paths})
|
|
42
52
|
|
|
43
53
|
def write_file(self, path: str, content: str):
|
|
54
|
+
"""Create a new file or overwrite an existing file with new content.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
path (str): Path to the file to write.
|
|
58
|
+
content (str): Content to write to the file.
|
|
59
|
+
"""
|
|
44
60
|
return self.call_tool("write_file", {"path": path, "content": content})
|
|
45
61
|
|
|
46
62
|
def edit_file(self, path: str, edits: list, dry_run: bool = False):
|
|
63
|
+
"""Make line-based edits to a text file.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
path (str): Path to the file to edit.
|
|
67
|
+
edits (list[dict]): List of edits to make. Each edit must contain:
|
|
68
|
+
oldText (str): Text to search for (exact match).
|
|
69
|
+
newText (str): Text to replace with.
|
|
70
|
+
dry_run (bool): If True, preview the changes using git-style
|
|
71
|
+
diff format.
|
|
72
|
+
"""
|
|
47
73
|
return self.call_tool(
|
|
48
74
|
"edit_file",
|
|
49
75
|
{
|
|
@@ -54,15 +80,39 @@ class FilesystemSandbox(GUIMixin, BaseSandbox):
|
|
|
54
80
|
)
|
|
55
81
|
|
|
56
82
|
def create_directory(self, path: str):
|
|
83
|
+
"""Create a new directory or ensure it exists.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
path (str): Path to the directory to create.
|
|
87
|
+
"""
|
|
57
88
|
return self.call_tool("create_directory", {"path": path})
|
|
58
89
|
|
|
59
90
|
def list_directory(self, path: str):
|
|
91
|
+
"""
|
|
92
|
+
Get a detailed listing of all files and directories in a specified
|
|
93
|
+
path.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
path (str): Path to list contents from.
|
|
97
|
+
"""
|
|
60
98
|
return self.call_tool("list_directory", {"path": path})
|
|
61
99
|
|
|
62
100
|
def directory_tree(self, path: str):
|
|
101
|
+
"""
|
|
102
|
+
Get a recursive tree view of files and directories as a JSON structure.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
path (str): Path to get tree structure from.
|
|
106
|
+
"""
|
|
63
107
|
return self.call_tool("directory_tree", {"path": path})
|
|
64
108
|
|
|
65
109
|
def move_file(self, source: str, destination: str):
|
|
110
|
+
"""Move or rename files and directories.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
source (str): Source path to move from.
|
|
114
|
+
destination (str): Destination path to move to.
|
|
115
|
+
"""
|
|
66
116
|
return self.call_tool(
|
|
67
117
|
"move_file",
|
|
68
118
|
{"source": source, "destination": destination},
|
|
@@ -74,6 +124,13 @@ class FilesystemSandbox(GUIMixin, BaseSandbox):
|
|
|
74
124
|
pattern: str,
|
|
75
125
|
exclude_patterns: list = [],
|
|
76
126
|
):
|
|
127
|
+
"""Recursively search for files and directories matching a pattern.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
path (str): Starting path for the search.
|
|
131
|
+
pattern (str): Pattern to match files/directories.
|
|
132
|
+
exclude_patterns (list[str]): Patterns to exclude from the search.
|
|
133
|
+
"""
|
|
77
134
|
return self.call_tool(
|
|
78
135
|
"search_files",
|
|
79
136
|
{
|
|
@@ -84,7 +141,16 @@ class FilesystemSandbox(GUIMixin, BaseSandbox):
|
|
|
84
141
|
)
|
|
85
142
|
|
|
86
143
|
def get_file_info(self, path: str):
|
|
144
|
+
"""
|
|
145
|
+
Retrieve detailed metadata about a file or directory.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
path (str): Path to the file or directory.
|
|
149
|
+
"""
|
|
87
150
|
return self.call_tool("get_file_info", {"path": path})
|
|
88
151
|
|
|
89
152
|
def list_allowed_directories(self):
|
|
153
|
+
"""
|
|
154
|
+
Returns the list of directories that this serveris allowed to access.
|
|
155
|
+
"""
|
|
90
156
|
return self.call_tool("list_allowed_directories", {})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
+
# flake8: noqa: E501
|
|
2
3
|
import logging
|
|
3
4
|
from typing import Optional, Union, Tuple, List
|
|
4
5
|
|
|
@@ -72,6 +73,47 @@ class GuiSandbox(GUIMixin, BaseSandbox):
|
|
|
72
73
|
coordinate: Optional[Union[List[float], Tuple[float, float]]] = None,
|
|
73
74
|
text: Optional[str] = None,
|
|
74
75
|
):
|
|
76
|
+
"""Use a mouse and keyboard to interact with a computer, and take screenshots.
|
|
77
|
+
|
|
78
|
+
This is an interface to a desktop GUI. You do not have access to a terminal or
|
|
79
|
+
applications menu. You must click on desktop icons to start applications.
|
|
80
|
+
|
|
81
|
+
Guidelines:
|
|
82
|
+
* Always prefer using keyboard shortcuts rather than clicking, where possible.
|
|
83
|
+
* If you see boxes with two letters in them, typing these letters will click
|
|
84
|
+
that element. Use this instead of other shortcuts or clicking, where possible.
|
|
85
|
+
* Some applications may take time to start or process actions, so you may
|
|
86
|
+
need to wait and take successive screenshots to see the results of your
|
|
87
|
+
actions. For example, if you click on Firefox and a window doesn't open,
|
|
88
|
+
try taking another screenshot.
|
|
89
|
+
* Whenever you intend to move the cursor to click on an element (like an icon),
|
|
90
|
+
consult a screenshot to determine the coordinates of the element before moving
|
|
91
|
+
the cursor.
|
|
92
|
+
* If clicking on a program or link fails to load, even after waiting, try adjusting
|
|
93
|
+
your cursor position so that the tip falls visually on the element you want to click.
|
|
94
|
+
* Make sure to click any buttons, links, icons, etc., with the cursor tip in the center
|
|
95
|
+
of the element. Don't click boxes on their edges unless asked.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
action (str): The action to perform. Options are:
|
|
99
|
+
* `key`: Press a key or key-combination on the keyboard.
|
|
100
|
+
* `type`: Type a string of text.
|
|
101
|
+
* `get_cursor_position`: Get the current (x, y) pixel coordinate of the cursor.
|
|
102
|
+
* `mouse_move`: Move the cursor to a specified (x, y) coordinate.
|
|
103
|
+
* `left_click`: Click the left mouse button.
|
|
104
|
+
* `left_click_drag`: Click and drag to a specified coordinate.
|
|
105
|
+
* `right_click`: Click the right mouse button.
|
|
106
|
+
* `middle_click`: Click the middle mouse button.
|
|
107
|
+
* `double_click`: Double-click the left mouse button.
|
|
108
|
+
* `get_screenshot`: Take a screenshot of the screen.
|
|
109
|
+
coordinate (list[float] | tuple[float, float], optional):
|
|
110
|
+
The (x, y) pixel coordinates.
|
|
111
|
+
x = pixels from the left edge, y = pixels from the top edge.
|
|
112
|
+
text (str, optional): Text to type or key command to execute.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
Any: Result of performing the specified computer action.
|
|
116
|
+
"""
|
|
75
117
|
payload = {"action": action}
|
|
76
118
|
if coordinate is not None:
|
|
77
119
|
payload["coordinate"] = coordinate
|
|
File without changes
|