agentrun-inner-test 0.0.46__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 (135) hide show
  1. agentrun/__init__.py +325 -0
  2. agentrun/agent_runtime/__client_async_template.py +466 -0
  3. agentrun/agent_runtime/__endpoint_async_template.py +345 -0
  4. agentrun/agent_runtime/__init__.py +53 -0
  5. agentrun/agent_runtime/__runtime_async_template.py +477 -0
  6. agentrun/agent_runtime/api/__data_async_template.py +58 -0
  7. agentrun/agent_runtime/api/__init__.py +6 -0
  8. agentrun/agent_runtime/api/control.py +1362 -0
  9. agentrun/agent_runtime/api/data.py +98 -0
  10. agentrun/agent_runtime/client.py +868 -0
  11. agentrun/agent_runtime/endpoint.py +649 -0
  12. agentrun/agent_runtime/model.py +362 -0
  13. agentrun/agent_runtime/runtime.py +904 -0
  14. agentrun/credential/__client_async_template.py +177 -0
  15. agentrun/credential/__credential_async_template.py +216 -0
  16. agentrun/credential/__init__.py +28 -0
  17. agentrun/credential/api/__init__.py +5 -0
  18. agentrun/credential/api/control.py +606 -0
  19. agentrun/credential/client.py +319 -0
  20. agentrun/credential/credential.py +381 -0
  21. agentrun/credential/model.py +248 -0
  22. agentrun/integration/__init__.py +21 -0
  23. agentrun/integration/agentscope/__init__.py +12 -0
  24. agentrun/integration/agentscope/adapter.py +17 -0
  25. agentrun/integration/agentscope/builtin.py +65 -0
  26. agentrun/integration/agentscope/message_adapter.py +185 -0
  27. agentrun/integration/agentscope/model_adapter.py +60 -0
  28. agentrun/integration/agentscope/tool_adapter.py +59 -0
  29. agentrun/integration/builtin/__init__.py +16 -0
  30. agentrun/integration/builtin/model.py +93 -0
  31. agentrun/integration/builtin/sandbox.py +1234 -0
  32. agentrun/integration/builtin/toolset.py +47 -0
  33. agentrun/integration/crewai/__init__.py +12 -0
  34. agentrun/integration/crewai/adapter.py +9 -0
  35. agentrun/integration/crewai/builtin.py +65 -0
  36. agentrun/integration/crewai/model_adapter.py +31 -0
  37. agentrun/integration/crewai/tool_adapter.py +26 -0
  38. agentrun/integration/google_adk/__init__.py +12 -0
  39. agentrun/integration/google_adk/adapter.py +15 -0
  40. agentrun/integration/google_adk/builtin.py +65 -0
  41. agentrun/integration/google_adk/message_adapter.py +144 -0
  42. agentrun/integration/google_adk/model_adapter.py +46 -0
  43. agentrun/integration/google_adk/tool_adapter.py +235 -0
  44. agentrun/integration/langchain/__init__.py +30 -0
  45. agentrun/integration/langchain/adapter.py +15 -0
  46. agentrun/integration/langchain/builtin.py +71 -0
  47. agentrun/integration/langchain/message_adapter.py +141 -0
  48. agentrun/integration/langchain/model_adapter.py +37 -0
  49. agentrun/integration/langchain/tool_adapter.py +50 -0
  50. agentrun/integration/langgraph/__init__.py +35 -0
  51. agentrun/integration/langgraph/adapter.py +20 -0
  52. agentrun/integration/langgraph/agent_converter.py +1073 -0
  53. agentrun/integration/langgraph/builtin.py +65 -0
  54. agentrun/integration/pydantic_ai/__init__.py +12 -0
  55. agentrun/integration/pydantic_ai/adapter.py +13 -0
  56. agentrun/integration/pydantic_ai/builtin.py +65 -0
  57. agentrun/integration/pydantic_ai/model_adapter.py +44 -0
  58. agentrun/integration/pydantic_ai/tool_adapter.py +19 -0
  59. agentrun/integration/utils/__init__.py +112 -0
  60. agentrun/integration/utils/adapter.py +560 -0
  61. agentrun/integration/utils/canonical.py +164 -0
  62. agentrun/integration/utils/converter.py +134 -0
  63. agentrun/integration/utils/model.py +110 -0
  64. agentrun/integration/utils/tool.py +1759 -0
  65. agentrun/model/__client_async_template.py +357 -0
  66. agentrun/model/__init__.py +57 -0
  67. agentrun/model/__model_proxy_async_template.py +270 -0
  68. agentrun/model/__model_service_async_template.py +267 -0
  69. agentrun/model/api/__init__.py +6 -0
  70. agentrun/model/api/control.py +1173 -0
  71. agentrun/model/api/data.py +196 -0
  72. agentrun/model/client.py +674 -0
  73. agentrun/model/model.py +235 -0
  74. agentrun/model/model_proxy.py +439 -0
  75. agentrun/model/model_service.py +438 -0
  76. agentrun/sandbox/__aio_sandbox_async_template.py +523 -0
  77. agentrun/sandbox/__browser_sandbox_async_template.py +110 -0
  78. agentrun/sandbox/__client_async_template.py +491 -0
  79. agentrun/sandbox/__code_interpreter_sandbox_async_template.py +463 -0
  80. agentrun/sandbox/__init__.py +69 -0
  81. agentrun/sandbox/__sandbox_async_template.py +463 -0
  82. agentrun/sandbox/__template_async_template.py +152 -0
  83. agentrun/sandbox/aio_sandbox.py +905 -0
  84. agentrun/sandbox/api/__aio_data_async_template.py +335 -0
  85. agentrun/sandbox/api/__browser_data_async_template.py +140 -0
  86. agentrun/sandbox/api/__code_interpreter_data_async_template.py +206 -0
  87. agentrun/sandbox/api/__init__.py +19 -0
  88. agentrun/sandbox/api/__sandbox_data_async_template.py +107 -0
  89. agentrun/sandbox/api/aio_data.py +551 -0
  90. agentrun/sandbox/api/browser_data.py +172 -0
  91. agentrun/sandbox/api/code_interpreter_data.py +396 -0
  92. agentrun/sandbox/api/control.py +1051 -0
  93. agentrun/sandbox/api/playwright_async.py +492 -0
  94. agentrun/sandbox/api/playwright_sync.py +492 -0
  95. agentrun/sandbox/api/sandbox_data.py +154 -0
  96. agentrun/sandbox/browser_sandbox.py +185 -0
  97. agentrun/sandbox/client.py +925 -0
  98. agentrun/sandbox/code_interpreter_sandbox.py +823 -0
  99. agentrun/sandbox/model.py +397 -0
  100. agentrun/sandbox/sandbox.py +848 -0
  101. agentrun/sandbox/template.py +217 -0
  102. agentrun/server/__init__.py +191 -0
  103. agentrun/server/agui_normalizer.py +180 -0
  104. agentrun/server/agui_protocol.py +797 -0
  105. agentrun/server/invoker.py +309 -0
  106. agentrun/server/model.py +427 -0
  107. agentrun/server/openai_protocol.py +535 -0
  108. agentrun/server/protocol.py +140 -0
  109. agentrun/server/server.py +208 -0
  110. agentrun/toolset/__client_async_template.py +62 -0
  111. agentrun/toolset/__init__.py +51 -0
  112. agentrun/toolset/__toolset_async_template.py +204 -0
  113. agentrun/toolset/api/__init__.py +17 -0
  114. agentrun/toolset/api/control.py +262 -0
  115. agentrun/toolset/api/mcp.py +100 -0
  116. agentrun/toolset/api/openapi.py +1251 -0
  117. agentrun/toolset/client.py +102 -0
  118. agentrun/toolset/model.py +321 -0
  119. agentrun/toolset/toolset.py +270 -0
  120. agentrun/utils/__data_api_async_template.py +720 -0
  121. agentrun/utils/__init__.py +5 -0
  122. agentrun/utils/__resource_async_template.py +158 -0
  123. agentrun/utils/config.py +258 -0
  124. agentrun/utils/control_api.py +78 -0
  125. agentrun/utils/data_api.py +1120 -0
  126. agentrun/utils/exception.py +151 -0
  127. agentrun/utils/helper.py +108 -0
  128. agentrun/utils/log.py +77 -0
  129. agentrun/utils/model.py +168 -0
  130. agentrun/utils/resource.py +291 -0
  131. agentrun_inner_test-0.0.46.dist-info/METADATA +263 -0
  132. agentrun_inner_test-0.0.46.dist-info/RECORD +135 -0
  133. agentrun_inner_test-0.0.46.dist-info/WHEEL +5 -0
  134. agentrun_inner_test-0.0.46.dist-info/licenses/LICENSE +201 -0
  135. agentrun_inner_test-0.0.46.dist-info/top_level.txt +1 -0
@@ -0,0 +1,172 @@
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/__browser_data_async_template.py
10
+
11
+ 浏览器沙箱数据API模板 / Browser Sandbox Data API Template
12
+
13
+ 此模板用于生成浏览器沙箱数据API代码。
14
+ This template is used to generate browser sandbox data API code.
15
+ """
16
+
17
+ from typing import Optional
18
+ from urllib.parse import parse_qs, urlencode, urlparse
19
+
20
+ from agentrun.utils.config import Config
21
+
22
+ from .sandbox_data import SandboxDataAPI
23
+
24
+
25
+ class BrowserDataAPI(SandboxDataAPI):
26
+
27
+ def __init__(
28
+ self,
29
+ sandbox_id: str,
30
+ config: Optional[Config] = None,
31
+ ):
32
+ self.sandbox_id = sandbox_id
33
+ super().__init__(
34
+ sandbox_id=sandbox_id,
35
+ config=config,
36
+ )
37
+
38
+ def get_cdp_url(self, record: Optional[bool] = False):
39
+ """
40
+ Generate the WebSocket URL for Chrome DevTools Protocol (CDP) connection.
41
+
42
+ This method constructs a WebSocket URL by:
43
+ 1. Converting the HTTP endpoint to WebSocket protocol (ws://)
44
+ 2. Parsing the existing URL and query parameters
45
+ 3. Adding the session ID to the query parameters
46
+ 4. Reconstructing the complete WebSocket URL
47
+
48
+ Returns:
49
+ str: The complete WebSocket URL for CDP automation connection,
50
+ including the session ID in the query parameters.
51
+
52
+ Example:
53
+ >>> api = BrowserDataAPI("browser123", "session456")
54
+ >>> api.get_cdp_url()
55
+ 'ws://example.com/ws/automation?sessionId=session456'
56
+ """
57
+ cdp_url = self.with_path("/ws/automation").replace("http", "ws")
58
+ u = urlparse(cdp_url)
59
+ query_dict = parse_qs(u.query)
60
+ query_dict["tenantId"] = [self.config.get_account_id()]
61
+ if record:
62
+ query_dict["recording"] = ["true"]
63
+ new_query = urlencode(query_dict, doseq=True)
64
+ new_u = u._replace(query=new_query)
65
+ return new_u.geturl()
66
+
67
+ def get_vnc_url(self, record: Optional[bool] = False):
68
+ """
69
+ Generate the WebSocket URL for VNC (Virtual Network Computing) live view connection.
70
+
71
+ This method constructs a WebSocket URL for real-time browser viewing by:
72
+ 1. Converting the HTTP endpoint to WebSocket protocol (ws://)
73
+ 2. Parsing the existing URL and query parameters
74
+ 3. Adding the session ID to the query parameters
75
+ 4. Reconstructing the complete WebSocket URL
76
+
77
+ Returns:
78
+ str: The complete WebSocket URL for VNC live view connection,
79
+ including the session ID in the query parameters.
80
+
81
+ Example:
82
+ >>> api = BrowserDataAPI("browser123", "session456")
83
+ >>> api.get_vnc_url()
84
+ 'ws://example.com/ws/liveview?sessionId=session456'
85
+ """
86
+ vnc_url = self.with_path("/ws/liveview").replace("http", "ws")
87
+ u = urlparse(vnc_url)
88
+ query_dict = parse_qs(u.query)
89
+ query_dict["tenantId"] = [self.config.get_account_id()]
90
+ if record:
91
+ query_dict["recording"] = ["true"]
92
+ new_query = urlencode(query_dict, doseq=True)
93
+ new_u = u._replace(query=new_query)
94
+ return new_u.geturl()
95
+
96
+ def sync_playwright(
97
+ self,
98
+ browser_type: str = "chrome",
99
+ record: Optional[bool] = False,
100
+ config: Optional[Config] = None,
101
+ ):
102
+ from .playwright_sync import BrowserPlaywrightSync
103
+
104
+ cfg = Config.with_configs(self.config, config)
105
+ _, headers, _ = self.auth(headers=cfg.get_headers(), config=cfg)
106
+ return BrowserPlaywrightSync(
107
+ self.get_cdp_url(record=record),
108
+ browser_type=browser_type,
109
+ headers=headers,
110
+ )
111
+
112
+ def async_playwright(
113
+ self,
114
+ browser_type: str = "chrome",
115
+ record: Optional[bool] = False,
116
+ config: Optional[Config] = None,
117
+ ):
118
+ from .playwright_async import BrowserPlaywrightAsync
119
+
120
+ cfg = Config.with_configs(self.config, config)
121
+ _, headers, _ = self.auth(headers=cfg.get_headers(), config=cfg)
122
+ return BrowserPlaywrightAsync(
123
+ self.get_cdp_url(record=record),
124
+ browser_type=browser_type,
125
+ headers=headers,
126
+ )
127
+
128
+ async def list_recordings_async(self):
129
+ return await self.get_async("/recordings")
130
+
131
+ def list_recordings(self):
132
+ return self.get("/recordings")
133
+
134
+ async def delete_recording_async(self, filename: str):
135
+ return await self.delete_async(f"/recordings/{filename}")
136
+
137
+ def delete_recording(self, filename: str):
138
+ return self.delete(f"/recordings/{filename}")
139
+
140
+ async def download_recording_async(self, filename: str, save_path: str):
141
+ """
142
+ Asynchronously download a recording video file and save it to local path.
143
+
144
+ Args:
145
+ filename: The name of the recording file to download
146
+ save_path: Local file path to save the downloaded video file (.mkv)
147
+
148
+ Returns:
149
+ Dictionary with 'saved_path' and 'size' keys
150
+
151
+ Examples:
152
+ >>> await api.download_recording_async("recording.mp4", "/local/video.mkv")
153
+ """
154
+ return await self.get_video_async(
155
+ f"/recordings/{filename}", save_path=save_path
156
+ )
157
+
158
+ def download_recording(self, filename: str, save_path: str):
159
+ """
160
+ Synchronously download a recording video file and save it to local path.
161
+
162
+ Args:
163
+ filename: The name of the recording file to download
164
+ save_path: Local file path to save the downloaded video file (.mkv)
165
+
166
+ Returns:
167
+ Dictionary with 'saved_path' and 'size' keys
168
+
169
+ Examples:
170
+ >>> api.download_recording("recording.mp4", "/local/video.mkv")
171
+ """
172
+ return self.get_video(f"/recordings/{filename}", save_path=save_path)
@@ -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}")