agentrun-sdk 0.0.4__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.
- agentrun/__init__.py +209 -0
- agentrun/agent_runtime/__client_async_template.py +466 -0
- agentrun/agent_runtime/__endpoint_async_template.py +345 -0
- agentrun/agent_runtime/__init__.py +53 -0
- agentrun/agent_runtime/__runtime_async_template.py +477 -0
- agentrun/agent_runtime/api/__data_async_template.py +58 -0
- agentrun/agent_runtime/api/__init__.py +6 -0
- agentrun/agent_runtime/api/control.py +1362 -0
- agentrun/agent_runtime/api/data.py +98 -0
- agentrun/agent_runtime/client.py +868 -0
- agentrun/agent_runtime/endpoint.py +649 -0
- agentrun/agent_runtime/model.py +362 -0
- agentrun/agent_runtime/runtime.py +904 -0
- agentrun/credential/__client_async_template.py +177 -0
- agentrun/credential/__credential_async_template.py +216 -0
- agentrun/credential/__init__.py +28 -0
- agentrun/credential/api/__init__.py +5 -0
- agentrun/credential/api/control.py +606 -0
- agentrun/credential/client.py +319 -0
- agentrun/credential/credential.py +381 -0
- agentrun/credential/model.py +248 -0
- agentrun/integration/__init__.py +21 -0
- agentrun/integration/agentscope/__init__.py +12 -0
- agentrun/integration/agentscope/adapter.py +17 -0
- agentrun/integration/agentscope/builtin.py +65 -0
- agentrun/integration/agentscope/message_adapter.py +185 -0
- agentrun/integration/agentscope/model_adapter.py +60 -0
- agentrun/integration/agentscope/tool_adapter.py +59 -0
- agentrun/integration/builtin/__init__.py +16 -0
- agentrun/integration/builtin/model.py +97 -0
- agentrun/integration/builtin/sandbox.py +276 -0
- agentrun/integration/builtin/toolset.py +47 -0
- agentrun/integration/crewai/__init__.py +12 -0
- agentrun/integration/crewai/adapter.py +9 -0
- agentrun/integration/crewai/builtin.py +65 -0
- agentrun/integration/crewai/model_adapter.py +27 -0
- agentrun/integration/crewai/tool_adapter.py +26 -0
- agentrun/integration/google_adk/__init__.py +12 -0
- agentrun/integration/google_adk/adapter.py +15 -0
- agentrun/integration/google_adk/builtin.py +65 -0
- agentrun/integration/google_adk/message_adapter.py +144 -0
- agentrun/integration/google_adk/model_adapter.py +43 -0
- agentrun/integration/google_adk/tool_adapter.py +25 -0
- agentrun/integration/langchain/__init__.py +9 -0
- agentrun/integration/langchain/adapter.py +15 -0
- agentrun/integration/langchain/builtin.py +71 -0
- agentrun/integration/langchain/message_adapter.py +141 -0
- agentrun/integration/langchain/model_adapter.py +37 -0
- agentrun/integration/langchain/tool_adapter.py +50 -0
- agentrun/integration/langgraph/__init__.py +13 -0
- agentrun/integration/langgraph/adapter.py +20 -0
- agentrun/integration/langgraph/builtin.py +65 -0
- agentrun/integration/pydantic_ai/__init__.py +12 -0
- agentrun/integration/pydantic_ai/adapter.py +13 -0
- agentrun/integration/pydantic_ai/builtin.py +65 -0
- agentrun/integration/pydantic_ai/model_adapter.py +44 -0
- agentrun/integration/pydantic_ai/tool_adapter.py +19 -0
- agentrun/integration/utils/__init__.py +112 -0
- agentrun/integration/utils/adapter.py +167 -0
- agentrun/integration/utils/canonical.py +157 -0
- agentrun/integration/utils/converter.py +134 -0
- agentrun/integration/utils/model.py +107 -0
- agentrun/integration/utils/tool.py +1714 -0
- agentrun/model/__client_async_template.py +357 -0
- agentrun/model/__init__.py +57 -0
- agentrun/model/__model_proxy_async_template.py +270 -0
- agentrun/model/__model_service_async_template.py +267 -0
- agentrun/model/api/__init__.py +6 -0
- agentrun/model/api/control.py +1173 -0
- agentrun/model/api/data.py +196 -0
- agentrun/model/client.py +674 -0
- agentrun/model/model.py +218 -0
- agentrun/model/model_proxy.py +439 -0
- agentrun/model/model_service.py +438 -0
- agentrun/sandbox/__browser_sandbox_async_template.py +113 -0
- agentrun/sandbox/__client_async_template.py +466 -0
- agentrun/sandbox/__code_interpreter_sandbox_async_template.py +466 -0
- agentrun/sandbox/__init__.py +54 -0
- agentrun/sandbox/__sandbox_async_template.py +398 -0
- agentrun/sandbox/__template_async_template.py +150 -0
- agentrun/sandbox/api/__browser_data_async_template.py +140 -0
- agentrun/sandbox/api/__code_interpreter_data_async_template.py +206 -0
- agentrun/sandbox/api/__init__.py +17 -0
- agentrun/sandbox/api/__sandbox_data_async_template.py +100 -0
- agentrun/sandbox/api/browser_data.py +172 -0
- agentrun/sandbox/api/code_interpreter_data.py +396 -0
- agentrun/sandbox/api/control.py +1051 -0
- agentrun/sandbox/api/playwright_async.py +492 -0
- agentrun/sandbox/api/playwright_sync.py +492 -0
- agentrun/sandbox/api/sandbox_data.py +140 -0
- agentrun/sandbox/browser_sandbox.py +191 -0
- agentrun/sandbox/client.py +878 -0
- agentrun/sandbox/code_interpreter_sandbox.py +829 -0
- agentrun/sandbox/model.py +269 -0
- agentrun/sandbox/sandbox.py +737 -0
- agentrun/sandbox/template.py +215 -0
- agentrun/server/__init__.py +82 -0
- agentrun/server/invoker.py +131 -0
- agentrun/server/model.py +225 -0
- agentrun/server/openai_protocol.py +798 -0
- agentrun/server/protocol.py +96 -0
- agentrun/server/server.py +192 -0
- agentrun/toolset/__client_async_template.py +62 -0
- agentrun/toolset/__init__.py +51 -0
- agentrun/toolset/__toolset_async_template.py +204 -0
- agentrun/toolset/api/__init__.py +17 -0
- agentrun/toolset/api/control.py +262 -0
- agentrun/toolset/api/mcp.py +100 -0
- agentrun/toolset/api/openapi.py +1184 -0
- agentrun/toolset/client.py +102 -0
- agentrun/toolset/model.py +160 -0
- agentrun/toolset/toolset.py +271 -0
- agentrun/utils/__data_api_async_template.py +715 -0
- agentrun/utils/__init__.py +5 -0
- agentrun/utils/__resource_async_template.py +158 -0
- agentrun/utils/config.py +258 -0
- agentrun/utils/control_api.py +78 -0
- agentrun/utils/data_api.py +1110 -0
- agentrun/utils/exception.py +149 -0
- agentrun/utils/helper.py +34 -0
- agentrun/utils/log.py +77 -0
- agentrun/utils/model.py +168 -0
- agentrun/utils/resource.py +291 -0
- agentrun_sdk-0.0.4.dist-info/METADATA +262 -0
- agentrun_sdk-0.0.4.dist-info/RECORD +128 -0
- agentrun_sdk-0.0.4.dist-info/WHEEL +5 -0
- agentrun_sdk-0.0.4.dist-info/licenses/LICENSE +201 -0
- agentrun_sdk-0.0.4.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This file is auto generated by the code generation script.
|
|
3
|
+
Do not modify this file manually.
|
|
4
|
+
Use the `make codegen` command to regenerate.
|
|
5
|
+
|
|
6
|
+
当前文件为自动生成的控制 API 客户端代码。请勿手动修改此文件。
|
|
7
|
+
使用 `make codegen` 命令重新生成。
|
|
8
|
+
|
|
9
|
+
source: agentrun/sandbox/api/__code_interpreter_data_async_template.py
|
|
10
|
+
|
|
11
|
+
代码解释器沙箱数据API模板 / Code Interpreter Sandbox Data API Template
|
|
12
|
+
|
|
13
|
+
此模板用于生成代码解释器沙箱数据API代码。
|
|
14
|
+
This template is used to generate code interpreter sandbox data API code.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from typing import Any, Dict, Optional
|
|
18
|
+
|
|
19
|
+
from agentrun.sandbox.model import CodeLanguage
|
|
20
|
+
from agentrun.utils.config import Config
|
|
21
|
+
|
|
22
|
+
from .sandbox_data import SandboxDataAPI
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CodeInterpreterDataAPI(SandboxDataAPI):
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
sandbox_id: str,
|
|
30
|
+
config: Optional[Config] = None,
|
|
31
|
+
):
|
|
32
|
+
|
|
33
|
+
super().__init__(
|
|
34
|
+
sandbox_id=sandbox_id,
|
|
35
|
+
config=config,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
async def list_directory_async(
|
|
39
|
+
self,
|
|
40
|
+
path: Optional[str] = None,
|
|
41
|
+
depth: Optional[int] = None,
|
|
42
|
+
):
|
|
43
|
+
query = {}
|
|
44
|
+
if path is not None:
|
|
45
|
+
query["path"] = path
|
|
46
|
+
if depth is not None:
|
|
47
|
+
query["depth"] = depth
|
|
48
|
+
|
|
49
|
+
return await self.get_async("/filesystem", query=query)
|
|
50
|
+
|
|
51
|
+
def list_directory(
|
|
52
|
+
self,
|
|
53
|
+
path: Optional[str] = None,
|
|
54
|
+
depth: Optional[int] = None,
|
|
55
|
+
):
|
|
56
|
+
query = {}
|
|
57
|
+
if path is not None:
|
|
58
|
+
query["path"] = path
|
|
59
|
+
if depth is not None:
|
|
60
|
+
query["depth"] = depth
|
|
61
|
+
|
|
62
|
+
return self.get("/filesystem", query=query)
|
|
63
|
+
|
|
64
|
+
async def stat_async(
|
|
65
|
+
self,
|
|
66
|
+
path: str,
|
|
67
|
+
):
|
|
68
|
+
query = {
|
|
69
|
+
"path": path,
|
|
70
|
+
}
|
|
71
|
+
return await self.get_async("/filesystem/stat", query=query)
|
|
72
|
+
|
|
73
|
+
def stat(
|
|
74
|
+
self,
|
|
75
|
+
path: str,
|
|
76
|
+
):
|
|
77
|
+
query = {
|
|
78
|
+
"path": path,
|
|
79
|
+
}
|
|
80
|
+
return self.get("/filesystem/stat", query=query)
|
|
81
|
+
|
|
82
|
+
async def mkdir_async(
|
|
83
|
+
self,
|
|
84
|
+
path: str,
|
|
85
|
+
parents: Optional[bool] = True,
|
|
86
|
+
mode: Optional[str] = "0755",
|
|
87
|
+
):
|
|
88
|
+
data = {
|
|
89
|
+
"path": path,
|
|
90
|
+
"parents": parents,
|
|
91
|
+
"mode": mode,
|
|
92
|
+
}
|
|
93
|
+
return await self.post_async("/filesystem/mkdir", data=data)
|
|
94
|
+
|
|
95
|
+
def mkdir(
|
|
96
|
+
self,
|
|
97
|
+
path: str,
|
|
98
|
+
parents: Optional[bool] = True,
|
|
99
|
+
mode: Optional[str] = "0755",
|
|
100
|
+
):
|
|
101
|
+
data = {
|
|
102
|
+
"path": path,
|
|
103
|
+
"parents": parents,
|
|
104
|
+
"mode": mode,
|
|
105
|
+
}
|
|
106
|
+
return self.post("/filesystem/mkdir", data=data)
|
|
107
|
+
|
|
108
|
+
async def move_file_async(
|
|
109
|
+
self,
|
|
110
|
+
source: str,
|
|
111
|
+
destination: str,
|
|
112
|
+
):
|
|
113
|
+
data = {
|
|
114
|
+
"source": source,
|
|
115
|
+
"destination": destination,
|
|
116
|
+
}
|
|
117
|
+
return await self.post_async("/filesystem/move", data=data)
|
|
118
|
+
|
|
119
|
+
def move_file(
|
|
120
|
+
self,
|
|
121
|
+
source: str,
|
|
122
|
+
destination: str,
|
|
123
|
+
):
|
|
124
|
+
data = {
|
|
125
|
+
"source": source,
|
|
126
|
+
"destination": destination,
|
|
127
|
+
}
|
|
128
|
+
return self.post("/filesystem/move", data=data)
|
|
129
|
+
|
|
130
|
+
async def remove_file_async(
|
|
131
|
+
self,
|
|
132
|
+
path: str,
|
|
133
|
+
):
|
|
134
|
+
data = {
|
|
135
|
+
"path": path,
|
|
136
|
+
}
|
|
137
|
+
return await self.post_async("/filesystem/remove", data=data)
|
|
138
|
+
|
|
139
|
+
def remove_file(
|
|
140
|
+
self,
|
|
141
|
+
path: str,
|
|
142
|
+
):
|
|
143
|
+
data = {
|
|
144
|
+
"path": path,
|
|
145
|
+
}
|
|
146
|
+
return self.post("/filesystem/remove", data=data)
|
|
147
|
+
|
|
148
|
+
async def list_contexts_async(self):
|
|
149
|
+
return await self.get_async("/contexts")
|
|
150
|
+
|
|
151
|
+
def list_contexts(self):
|
|
152
|
+
return self.get("/contexts")
|
|
153
|
+
|
|
154
|
+
async def create_context_async(
|
|
155
|
+
self,
|
|
156
|
+
language: Optional[CodeLanguage] = CodeLanguage.PYTHON,
|
|
157
|
+
cwd: str = "/home/user",
|
|
158
|
+
):
|
|
159
|
+
# Validate language parameter
|
|
160
|
+
if language not in ("python", "javascript"):
|
|
161
|
+
raise ValueError(
|
|
162
|
+
f"language must be 'python' or 'javascript', got: {language}"
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
data: Dict[str, Any] = {
|
|
166
|
+
"cwd": cwd,
|
|
167
|
+
"language": language,
|
|
168
|
+
}
|
|
169
|
+
return await self.post_async("/contexts", data=data)
|
|
170
|
+
|
|
171
|
+
def create_context(
|
|
172
|
+
self,
|
|
173
|
+
language: Optional[CodeLanguage] = CodeLanguage.PYTHON,
|
|
174
|
+
cwd: str = "/home/user",
|
|
175
|
+
):
|
|
176
|
+
# Validate language parameter
|
|
177
|
+
if language not in ("python", "javascript"):
|
|
178
|
+
raise ValueError(
|
|
179
|
+
f"language must be 'python' or 'javascript', got: {language}"
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
data: Dict[str, Any] = {
|
|
183
|
+
"cwd": cwd,
|
|
184
|
+
"language": language,
|
|
185
|
+
}
|
|
186
|
+
return self.post("/contexts", data=data)
|
|
187
|
+
|
|
188
|
+
async def get_context_async(
|
|
189
|
+
self,
|
|
190
|
+
context_id: str,
|
|
191
|
+
):
|
|
192
|
+
return await self.get_async(f"/contexts/{context_id}")
|
|
193
|
+
|
|
194
|
+
def get_context(
|
|
195
|
+
self,
|
|
196
|
+
context_id: str,
|
|
197
|
+
):
|
|
198
|
+
return self.get(f"/contexts/{context_id}")
|
|
199
|
+
|
|
200
|
+
async def execute_code_async(
|
|
201
|
+
self,
|
|
202
|
+
code: str,
|
|
203
|
+
context_id: Optional[str],
|
|
204
|
+
language: Optional[CodeLanguage] = None,
|
|
205
|
+
timeout: Optional[int] = 30,
|
|
206
|
+
):
|
|
207
|
+
if language and language not in ("python", "javascript"):
|
|
208
|
+
raise ValueError(
|
|
209
|
+
f"language must be 'python' or 'javascript', got: {language}"
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
data: Dict[str, Any] = {
|
|
213
|
+
"code": code,
|
|
214
|
+
}
|
|
215
|
+
if timeout is not None:
|
|
216
|
+
data["timeout"] = timeout
|
|
217
|
+
if language is not None:
|
|
218
|
+
data["language"] = language
|
|
219
|
+
if context_id is not None:
|
|
220
|
+
data["contextId"] = context_id
|
|
221
|
+
return await self.post_async(f"/contexts/execute", data=data)
|
|
222
|
+
|
|
223
|
+
def execute_code(
|
|
224
|
+
self,
|
|
225
|
+
code: str,
|
|
226
|
+
context_id: Optional[str],
|
|
227
|
+
language: Optional[CodeLanguage] = None,
|
|
228
|
+
timeout: Optional[int] = 30,
|
|
229
|
+
):
|
|
230
|
+
if language and language not in ("python", "javascript"):
|
|
231
|
+
raise ValueError(
|
|
232
|
+
f"language must be 'python' or 'javascript', got: {language}"
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
data: Dict[str, Any] = {
|
|
236
|
+
"code": code,
|
|
237
|
+
}
|
|
238
|
+
if timeout is not None:
|
|
239
|
+
data["timeout"] = timeout
|
|
240
|
+
if language is not None:
|
|
241
|
+
data["language"] = language
|
|
242
|
+
if context_id is not None:
|
|
243
|
+
data["contextId"] = context_id
|
|
244
|
+
return self.post(f"/contexts/execute", data=data)
|
|
245
|
+
|
|
246
|
+
async def delete_context_async(
|
|
247
|
+
self,
|
|
248
|
+
context_id: str,
|
|
249
|
+
):
|
|
250
|
+
return await self.delete_async(f"/contexts/{context_id}")
|
|
251
|
+
|
|
252
|
+
def delete_context(
|
|
253
|
+
self,
|
|
254
|
+
context_id: str,
|
|
255
|
+
):
|
|
256
|
+
return self.delete(f"/contexts/{context_id}")
|
|
257
|
+
|
|
258
|
+
async def read_file_async(
|
|
259
|
+
self,
|
|
260
|
+
path: str,
|
|
261
|
+
):
|
|
262
|
+
query = {
|
|
263
|
+
"path": path,
|
|
264
|
+
}
|
|
265
|
+
return await self.get_async("/files", query=query)
|
|
266
|
+
|
|
267
|
+
def read_file(
|
|
268
|
+
self,
|
|
269
|
+
path: str,
|
|
270
|
+
):
|
|
271
|
+
query = {
|
|
272
|
+
"path": path,
|
|
273
|
+
}
|
|
274
|
+
return self.get("/files", query=query)
|
|
275
|
+
|
|
276
|
+
async def write_file_async(
|
|
277
|
+
self,
|
|
278
|
+
path: str,
|
|
279
|
+
content: str,
|
|
280
|
+
mode: Optional[str] = "644",
|
|
281
|
+
encoding: Optional[str] = "utf-8",
|
|
282
|
+
create_dir: Optional[bool] = True,
|
|
283
|
+
):
|
|
284
|
+
data = {
|
|
285
|
+
"path": path,
|
|
286
|
+
"content": content,
|
|
287
|
+
"mode": mode,
|
|
288
|
+
"encoding": encoding,
|
|
289
|
+
"createDir": create_dir,
|
|
290
|
+
}
|
|
291
|
+
return await self.post_async("/files", data=data)
|
|
292
|
+
|
|
293
|
+
def write_file(
|
|
294
|
+
self,
|
|
295
|
+
path: str,
|
|
296
|
+
content: str,
|
|
297
|
+
mode: Optional[str] = "644",
|
|
298
|
+
encoding: Optional[str] = "utf-8",
|
|
299
|
+
create_dir: Optional[bool] = True,
|
|
300
|
+
):
|
|
301
|
+
data = {
|
|
302
|
+
"path": path,
|
|
303
|
+
"content": content,
|
|
304
|
+
"mode": mode,
|
|
305
|
+
"encoding": encoding,
|
|
306
|
+
"createDir": create_dir,
|
|
307
|
+
}
|
|
308
|
+
return self.post("/files", data=data)
|
|
309
|
+
|
|
310
|
+
async def upload_file_async(
|
|
311
|
+
self,
|
|
312
|
+
local_file_path: str,
|
|
313
|
+
target_file_path: str,
|
|
314
|
+
):
|
|
315
|
+
return await self.post_file_async(
|
|
316
|
+
path="/filesystem/upload",
|
|
317
|
+
local_file_path=local_file_path,
|
|
318
|
+
target_file_path=target_file_path,
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
def upload_file(
|
|
322
|
+
self,
|
|
323
|
+
local_file_path: str,
|
|
324
|
+
target_file_path: str,
|
|
325
|
+
):
|
|
326
|
+
return self.post_file(
|
|
327
|
+
path="/filesystem/upload",
|
|
328
|
+
local_file_path=local_file_path,
|
|
329
|
+
target_file_path=target_file_path,
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
async def download_file_async(
|
|
333
|
+
self,
|
|
334
|
+
path: str,
|
|
335
|
+
save_path: str,
|
|
336
|
+
):
|
|
337
|
+
query = {"path": path}
|
|
338
|
+
return await self.get_file_async(
|
|
339
|
+
path="/filesystem/download", save_path=save_path, query=query
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
def download_file(
|
|
343
|
+
self,
|
|
344
|
+
path: str,
|
|
345
|
+
save_path: str,
|
|
346
|
+
):
|
|
347
|
+
query = {"path": path}
|
|
348
|
+
return self.get_file(
|
|
349
|
+
path="/filesystem/download", save_path=save_path, query=query
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
async def cmd_async(
|
|
353
|
+
self,
|
|
354
|
+
command: str,
|
|
355
|
+
cwd: str,
|
|
356
|
+
timeout: Optional[int] = 30,
|
|
357
|
+
):
|
|
358
|
+
data: Dict[str, Any] = {
|
|
359
|
+
"command": command,
|
|
360
|
+
"cwd": cwd,
|
|
361
|
+
}
|
|
362
|
+
if timeout is not None:
|
|
363
|
+
data["timeout"] = timeout
|
|
364
|
+
return await self.post_async("/processes/cmd", data=data)
|
|
365
|
+
|
|
366
|
+
def cmd(
|
|
367
|
+
self,
|
|
368
|
+
command: str,
|
|
369
|
+
cwd: str,
|
|
370
|
+
timeout: Optional[int] = 30,
|
|
371
|
+
):
|
|
372
|
+
data: Dict[str, Any] = {
|
|
373
|
+
"command": command,
|
|
374
|
+
"cwd": cwd,
|
|
375
|
+
}
|
|
376
|
+
if timeout is not None:
|
|
377
|
+
data["timeout"] = timeout
|
|
378
|
+
return self.post("/processes/cmd", data=data)
|
|
379
|
+
|
|
380
|
+
async def list_processes_async(self):
|
|
381
|
+
return await self.get_async("/processes")
|
|
382
|
+
|
|
383
|
+
def list_processes(self):
|
|
384
|
+
return self.get("/processes")
|
|
385
|
+
|
|
386
|
+
async def get_process_async(self, pid: str):
|
|
387
|
+
return await self.get_async(f"/processes/{pid}")
|
|
388
|
+
|
|
389
|
+
def get_process(self, pid: str):
|
|
390
|
+
return self.get(f"/processes/{pid}")
|
|
391
|
+
|
|
392
|
+
async def kill_process_async(self, pid: str):
|
|
393
|
+
return await self.delete_async(f"/processes/{pid}")
|
|
394
|
+
|
|
395
|
+
def kill_process(self, pid: str):
|
|
396
|
+
return self.delete(f"/processes/{pid}")
|