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
agentrun/__init__.py ADDED
@@ -0,0 +1,325 @@
1
+ """AgentRun Python SDK / AgentRun Python SDK
2
+
3
+ AgentRun Python SDK 是阿里云 AgentRun 服务的 Python 客户端库。
4
+ AgentRun Python SDK is the Python client library for Alibaba Cloud AgentRun service.
5
+
6
+ 提供简洁易用的 API 来管理 AI Agent 运行时环境、模型服务、沙箱环境等。
7
+ Provides simple and easy-to-use APIs for managing AI Agent runtime environments, model services, sandbox environments, etc.
8
+
9
+ 主要功能 / Main Features:
10
+ - Agent Runtime: Agent 运行时管理 / Agent runtime management
11
+ - Model Service: 模型服务管理 / Model service management
12
+ - Sandbox: 沙箱环境管理 / Sandbox environment management
13
+ - ToolSet: 工具集管理 / Toolset management
14
+ - Credential: 凭证管理 / Credential management
15
+ - Server: HTTP 服务器 / HTTP server
16
+ - Integration: 框架集成 / Framework integration
17
+ """
18
+
19
+ from typing import TYPE_CHECKING
20
+
21
+ __version__ = "0.0.46"
22
+
23
+ # Agent Runtime
24
+ from agentrun.agent_runtime import (
25
+ AgentRuntime,
26
+ AgentRuntimeArtifact,
27
+ AgentRuntimeClient,
28
+ AgentRuntimeCode,
29
+ AgentRuntimeContainer,
30
+ AgentRuntimeControlAPI,
31
+ AgentRuntimeCreateInput,
32
+ AgentRuntimeEndpoint,
33
+ AgentRuntimeEndpointCreateInput,
34
+ AgentRuntimeEndpointListInput,
35
+ AgentRuntimeEndpointRoutingConfig,
36
+ AgentRuntimeEndpointRoutingWeight,
37
+ AgentRuntimeEndpointUpdateInput,
38
+ AgentRuntimeHealthCheckConfig,
39
+ AgentRuntimeLanguage,
40
+ AgentRuntimeListInput,
41
+ AgentRuntimeLogConfig,
42
+ AgentRuntimeProtocolConfig,
43
+ AgentRuntimeProtocolType,
44
+ AgentRuntimeUpdateInput,
45
+ )
46
+ # Credential
47
+ from agentrun.credential import (
48
+ Credential,
49
+ CredentialBasicAuth,
50
+ CredentialClient,
51
+ CredentialConfig,
52
+ CredentialControlAPI,
53
+ CredentialCreateInput,
54
+ CredentialListInput,
55
+ CredentialUpdateInput,
56
+ RelatedResource,
57
+ )
58
+ # Model Service
59
+ from agentrun.model import (
60
+ BackendType,
61
+ ModelClient,
62
+ ModelCompletionAPI,
63
+ ModelControlAPI,
64
+ ModelDataAPI,
65
+ ModelFeatures,
66
+ ModelInfoConfig,
67
+ ModelParameterRule,
68
+ ModelProperties,
69
+ ModelProxy,
70
+ ModelProxyCreateInput,
71
+ ModelProxyListInput,
72
+ ModelProxyUpdateInput,
73
+ ModelService,
74
+ ModelServiceCreateInput,
75
+ ModelServiceListInput,
76
+ ModelServiceUpdateInput,
77
+ ModelType,
78
+ Provider,
79
+ ProviderSettings,
80
+ ProxyConfig,
81
+ ProxyConfigEndpoint,
82
+ ProxyConfigFallback,
83
+ ProxyConfigPolicies,
84
+ )
85
+ # Sandbox
86
+ from agentrun.sandbox import (
87
+ BrowserSandbox,
88
+ CodeInterpreterSandbox,
89
+ SandboxClient,
90
+ Template,
91
+ )
92
+ # ToolSet
93
+ from agentrun.toolset import ToolSet, ToolSetClient
94
+ from agentrun.utils.config import Config
95
+ from agentrun.utils.exception import (
96
+ ResourceAlreadyExistError,
97
+ ResourceNotExistError,
98
+ )
99
+ from agentrun.utils.model import Status
100
+
101
+ # Server - 延迟导入以避免可选依赖问题
102
+ # Type hints for IDE and type checkers
103
+ if TYPE_CHECKING:
104
+ from agentrun.server import (
105
+ AgentEvent,
106
+ AgentEventItem,
107
+ AgentRequest,
108
+ AgentResult,
109
+ AgentResultItem,
110
+ AgentReturnType,
111
+ AgentRunServer,
112
+ AguiEventNormalizer,
113
+ AGUIProtocolConfig,
114
+ AGUIProtocolHandler,
115
+ AsyncAgentEventGenerator,
116
+ AsyncAgentResultGenerator,
117
+ AsyncInvokeAgentHandler,
118
+ BaseProtocolHandler,
119
+ EventType,
120
+ InvokeAgentHandler,
121
+ MergeOptions,
122
+ Message,
123
+ MessageRole,
124
+ OpenAIProtocolConfig,
125
+ OpenAIProtocolHandler,
126
+ ProtocolConfig,
127
+ ProtocolHandler,
128
+ ServerConfig,
129
+ SyncAgentEventGenerator,
130
+ SyncAgentResultGenerator,
131
+ SyncInvokeAgentHandler,
132
+ Tool,
133
+ ToolCall,
134
+ )
135
+
136
+ __all__ = [
137
+ ######## Agent Runtime ########
138
+ # base
139
+ "AgentRuntime",
140
+ "AgentRuntimeEndpoint",
141
+ "AgentRuntimeClient",
142
+ "AgentRuntimeControlAPI",
143
+ # enum
144
+ "AgentRuntimeArtifact",
145
+ "AgentRuntimeLanguage",
146
+ "AgentRuntimeProtocolType",
147
+ "Status",
148
+ # inner model
149
+ "AgentRuntimeCode",
150
+ "AgentRuntimeContainer",
151
+ "AgentRuntimeHealthCheckConfig",
152
+ "AgentRuntimeLogConfig",
153
+ "AgentRuntimeProtocolConfig",
154
+ "AgentRuntimeEndpointRoutingConfig",
155
+ "AgentRuntimeEndpointRoutingWeight",
156
+ # api model
157
+ "AgentRuntimeCreateInput",
158
+ "AgentRuntimeUpdateInput",
159
+ "AgentRuntimeListInput",
160
+ "AgentRuntimeEndpointCreateInput",
161
+ "AgentRuntimeEndpointUpdateInput",
162
+ "AgentRuntimeEndpointListInput",
163
+ ######## Credential ########
164
+ # base
165
+ "Credential",
166
+ "CredentialClient",
167
+ "CredentialControlAPI",
168
+ # inner model
169
+ "CredentialBasicAuth",
170
+ "RelatedResource",
171
+ "CredentialConfig",
172
+ # api model
173
+ "CredentialCreateInput",
174
+ "CredentialUpdateInput",
175
+ "CredentialListInput",
176
+ ######## Model ########
177
+ # base
178
+ "ModelClient",
179
+ "ModelService",
180
+ "ModelProxy",
181
+ "ModelControlAPI",
182
+ "ModelCompletionAPI",
183
+ "ModelDataAPI",
184
+ # enum
185
+ "BackendType",
186
+ "ModelType",
187
+ "Provider",
188
+ # inner model
189
+ "ProviderSettings",
190
+ "ModelFeatures",
191
+ "ModelProperties",
192
+ "ModelParameterRule",
193
+ "ModelInfoConfig",
194
+ "ProxyConfigEndpoint",
195
+ "ProxyConfigFallback",
196
+ "ProxyConfigPolicies",
197
+ "ProxyConfig",
198
+ # api model
199
+ "ModelServiceCreateInput",
200
+ "ModelServiceUpdateInput",
201
+ "ModelServiceListInput",
202
+ "ModelProxyCreateInput",
203
+ "ModelProxyUpdateInput",
204
+ "ModelProxyListInput",
205
+ ######## Sandbox ########
206
+ "SandboxClient",
207
+ "BrowserSandbox",
208
+ "CodeInterpreterSandbox",
209
+ "Template",
210
+ ######## ToolSet ########
211
+ "ToolSetClient",
212
+ "ToolSet",
213
+ ######## Server (延迟加载) ########
214
+ # Server
215
+ "AgentRunServer",
216
+ # Config
217
+ "ServerConfig",
218
+ "ProtocolConfig",
219
+ "OpenAIProtocolConfig",
220
+ "AGUIProtocolConfig",
221
+ # Request/Response Models
222
+ "AgentRequest",
223
+ "AgentEvent",
224
+ "AgentResult",
225
+ "Message",
226
+ "MessageRole",
227
+ "Tool",
228
+ "ToolCall",
229
+ # Event Types
230
+ "EventType",
231
+ # Type Aliases
232
+ "AgentEventItem",
233
+ "AgentResultItem",
234
+ "AgentReturnType",
235
+ "SyncAgentEventGenerator",
236
+ "SyncAgentResultGenerator",
237
+ "AsyncAgentEventGenerator",
238
+ "AsyncAgentResultGenerator",
239
+ "InvokeAgentHandler",
240
+ "AsyncInvokeAgentHandler",
241
+ "SyncInvokeAgentHandler",
242
+ # Protocol Base
243
+ "ProtocolHandler",
244
+ "BaseProtocolHandler",
245
+ # Protocol - OpenAI
246
+ "OpenAIProtocolHandler",
247
+ # Protocol - AG-UI
248
+ "AGUIProtocolHandler",
249
+ # Event Normalizer
250
+ "AguiEventNormalizer",
251
+ # Helpers
252
+ "MergeOptions",
253
+ ######## Others ########
254
+ "ResourceNotExistError",
255
+ "ResourceAlreadyExistError",
256
+ "Config",
257
+ ]
258
+
259
+ # Server 模块的所有导出
260
+ _SERVER_EXPORTS = {
261
+ "AgentRunServer",
262
+ "ServerConfig",
263
+ "ProtocolConfig",
264
+ "OpenAIProtocolConfig",
265
+ "AGUIProtocolConfig",
266
+ "AgentRequest",
267
+ "AgentEvent",
268
+ "AgentResult",
269
+ "Message",
270
+ "MessageRole",
271
+ "Tool",
272
+ "ToolCall",
273
+ "EventType",
274
+ "AgentEventItem",
275
+ "AgentResultItem",
276
+ "AgentReturnType",
277
+ "SyncAgentEventGenerator",
278
+ "SyncAgentResultGenerator",
279
+ "AsyncAgentEventGenerator",
280
+ "AsyncAgentResultGenerator",
281
+ "InvokeAgentHandler",
282
+ "AsyncInvokeAgentHandler",
283
+ "SyncInvokeAgentHandler",
284
+ "ProtocolHandler",
285
+ "BaseProtocolHandler",
286
+ "OpenAIProtocolHandler",
287
+ "AGUIProtocolHandler",
288
+ "AguiEventNormalizer",
289
+ "MergeOptions",
290
+ }
291
+
292
+ # 可选依赖包映射:安装命令 -> 导入错误的包名列表
293
+ # Optional dependency mapping: installation command -> list of import error package names
294
+ # 将使用相同安装命令的包合并到一起 / Group packages with the same installation command
295
+ _OPTIONAL_PACKAGES = {
296
+ "agentrun-sdk[server]": ["fastapi", "uvicorn", "ag_ui"],
297
+ }
298
+
299
+
300
+ def __getattr__(name: str):
301
+ """延迟加载 server 模块的导出,避免可选依赖导致导入失败
302
+
303
+ 当用户访问 server 相关的类时,才尝试导入 server 模块。
304
+ 如果 server 可选依赖未安装,会抛出清晰的错误提示。
305
+ """
306
+ if name in _SERVER_EXPORTS:
307
+ try:
308
+ from agentrun import server
309
+
310
+ return getattr(server, name)
311
+ except ImportError as e:
312
+ # 检查是否是缺少可选依赖导致的错误
313
+ error_str = str(e)
314
+ for install_cmd, package_names in _OPTIONAL_PACKAGES.items():
315
+ for package_name in package_names:
316
+ if package_name in error_str:
317
+ raise ImportError(
318
+ f"'{name}' requires the 'server' optional"
319
+ " dependencies. Install with: pip install"
320
+ f" {install_cmd}\nOriginal error: {e}"
321
+ ) from e
322
+ # 其他导入错误继续抛出
323
+ raise
324
+
325
+ raise AttributeError(f"module '{__name__}' has no attribute '{name}'")