agentcore-sdk-agentrun-compat-core 0.1.0__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.
- agentcore/__init__.py +381 -0
- agentcore/agent_runtime/__init__.py +65 -0
- agentcore/agent_runtime/api/__init__.py +13 -0
- agentcore/agent_runtime/client.py +953 -0
- agentcore/agent_runtime/endpoint.py +145 -0
- agentcore/agent_runtime/model.py +514 -0
- agentcore/agent_runtime/runtime.py +436 -0
- agentcore/api/__init__.py +5 -0
- agentcore/api/actions.py +105 -0
- agentcore/api/client.py +452 -0
- agentcore/api/signer.py +167 -0
- agentcore/api/spec_actions.py +136 -0
- agentcore/conversation_service/__init__.py +31 -0
- agentcore/conversation_service/adapters/__init__.py +20 -0
- agentcore/credential/__init__.py +40 -0
- agentcore/credential/api/__init__.py +5 -0
- agentcore/credential/client.py +253 -0
- agentcore/credential/credential.py +162 -0
- agentcore/credential/model.py +206 -0
- agentcore/credential/secret.py +119 -0
- agentcore/integration/__init__.py +36 -0
- agentcore/integration/agentscope/__init__.py +8 -0
- agentcore/integration/builtin/__init__.py +62 -0
- agentcore/integration/builtin/knowledgebase.py +112 -0
- agentcore/integration/builtin/model.py +96 -0
- agentcore/integration/builtin/skill.py +16 -0
- agentcore/integration/builtin/tool_resource.py +48 -0
- agentcore/integration/builtin/toolset.py +47 -0
- agentcore/integration/crewai/__init__.py +8 -0
- agentcore/integration/google_adk/__init__.py +8 -0
- agentcore/integration/langchain/__init__.py +9 -0
- agentcore/integration/langgraph/__init__.py +9 -0
- agentcore/integration/pydantic_ai/__init__.py +8 -0
- agentcore/integration/utils/__init__.py +112 -0
- agentcore/integration/utils/adapter.py +560 -0
- agentcore/integration/utils/canonical.py +164 -0
- agentcore/integration/utils/converter.py +134 -0
- agentcore/integration/utils/model.py +110 -0
- agentcore/integration/utils/skill_loader.py +809 -0
- agentcore/integration/utils/tool.py +2169 -0
- agentcore/knowledgebase/__init__.py +34 -0
- agentcore/knowledgebase/_mcp_adapter.py +433 -0
- agentcore/knowledgebase/api/__init__.py +16 -0
- agentcore/knowledgebase/api/control.py +59 -0
- agentcore/knowledgebase/api/data.py +118 -0
- agentcore/knowledgebase/client.py +70 -0
- agentcore/knowledgebase/knowledgebase.py +231 -0
- agentcore/knowledgebase/model.py +246 -0
- agentcore/mcp/__init__.py +465 -0
- agentcore/memory_collection/__init__.py +33 -0
- agentcore/memory_collection/api/__init__.py +11 -0
- agentcore/model/__init__.py +82 -0
- agentcore/model/api/__init__.py +5 -0
- agentcore/model/client.py +332 -0
- agentcore/model/model.py +279 -0
- agentcore/model/model_proxy.py +136 -0
- agentcore/model/model_service.py +151 -0
- agentcore/sandbox/__init__.py +344 -0
- agentcore/sandbox/api/__init__.py +17 -0
- agentcore/sandbox/model.py +218 -0
- agentcore/server/__init__.py +203 -0
- agentcore/server/agui_normalizer.py +182 -0
- agentcore/server/agui_protocol.py +921 -0
- agentcore/server/invoker.py +362 -0
- agentcore/server/model.py +458 -0
- agentcore/server/openai_protocol.py +578 -0
- agentcore/server/protocol.py +142 -0
- agentcore/server/server.py +232 -0
- agentcore/service_endpoint/__init__.py +44 -0
- agentcore/service_endpoint/client.py +211 -0
- agentcore/service_endpoint/model.py +179 -0
- agentcore/skill/__init__.py +324 -0
- agentcore/super_agent/__init__.py +447 -0
- agentcore/super_agent/api/__init__.py +11 -0
- agentcore/super_agent/model.py +161 -0
- agentcore/tool/__init__.py +647 -0
- agentcore/tool/_managed_mcp.py +310 -0
- agentcore/tool/api/__init__.py +3 -0
- agentcore/tool/api/control.py +6 -0
- agentcore/tool/api/mcp.py +6 -0
- agentcore/tool/api/openapi.py +6 -0
- agentcore/tool/client.py +6 -0
- agentcore/tool/model.py +349 -0
- agentcore/tool/tool.py +6 -0
- agentcore/toolset/__init__.py +147 -0
- agentcore/toolset/api/__init__.py +13 -0
- agentcore/toolset/api/control.py +6 -0
- agentcore/toolset/api/mcp.py +6 -0
- agentcore/toolset/api/openapi.py +6 -0
- agentcore/toolset/client.py +6 -0
- agentcore/toolset/model.py +236 -0
- agentcore/toolset/toolset.py +6 -0
- agentcore/utils/__init__.py +21 -0
- agentcore/utils/compat.py +42 -0
- agentcore/utils/config.py +504 -0
- agentcore/utils/control_api.py +30 -0
- agentcore/utils/credential_context.py +180 -0
- agentcore/utils/credential_providers.py +104 -0
- agentcore/utils/data_api.py +41 -0
- agentcore/utils/exception.py +287 -0
- agentcore/utils/helper.py +102 -0
- agentcore/utils/log.py +77 -0
- agentcore/utils/model.py +217 -0
- agentcore/utils/openapi_gap.py +181 -0
- agentcore/utils/ram_signature/__init__.py +11 -0
- agentcore/utils/reasoning.py +154 -0
- agentcore/utils/resource.py +276 -0
- agentcore/utils/runtime_identity.py +313 -0
- agentcore/utils/stub.py +156 -0
- agentcore_sdk_agentrun_compat_core-0.1.0.dist-info/METADATA +91 -0
- agentcore_sdk_agentrun_compat_core-0.1.0.dist-info/RECORD +115 -0
- agentcore_sdk_agentrun_compat_core-0.1.0.dist-info/WHEEL +5 -0
- agentcore_sdk_agentrun_compat_core-0.1.0.dist-info/licenses/LICENSES/Apache-2.0.txt +202 -0
- agentcore_sdk_agentrun_compat_core-0.1.0.dist-info/licenses/THIRD_PARTY_NOTICES.md +9 -0
- agentcore_sdk_agentrun_compat_core-0.1.0.dist-info/top_level.txt +1 -0
agentcore/__init__.py
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
"""AgentCore Python SDK
|
|
2
|
+
|
|
3
|
+
对标 AgentRun SDK (`agentrun-sdk`) 的 Python 客户端库,基于 AgentCore
|
|
4
|
+
CloudSpec(2026-08-04,14 资源 148 API)构建。
|
|
5
|
+
|
|
6
|
+
Drop-in Replacement 用法:
|
|
7
|
+
# 改前
|
|
8
|
+
from agentrun.agent_runtime import AgentRuntimeClient
|
|
9
|
+
from agentrun.agent_runtime.model import AgentRuntimeCreateInput, AgentRuntimeCode, AgentRuntimeLanguage
|
|
10
|
+
|
|
11
|
+
# 改后(仅替换 package 名)
|
|
12
|
+
from agentcore.agent_runtime import AgentRuntimeClient
|
|
13
|
+
from agentcore.agent_runtime.model import AgentRuntimeCreateInput, AgentRuntimeCode, AgentRuntimeLanguage
|
|
14
|
+
|
|
15
|
+
主要功能:
|
|
16
|
+
- agent_runtime: Agent Runtime 管理(对标 AgentRun 的 agent_runtime)
|
|
17
|
+
- credential: 凭证管理
|
|
18
|
+
- model: 模型服务管理(ModelService → ModelConnection + Model)
|
|
19
|
+
- mcp: MCP Server 管理(对标 AgentRun 的 MCP 能力)
|
|
20
|
+
- skill: 技能管理(Draft/发布)
|
|
21
|
+
- tool / toolset: 工具发现与工具集声明(工具来自 MCP)
|
|
22
|
+
- sandbox: 沙箱(兼容层,AgentCore 无公开沙箱 API,操作抛 NotImplementedError + 缺口编号)
|
|
23
|
+
- server: AgentRun 兼容的本地 OpenAI / AG-UI HTTP 服务
|
|
24
|
+
- integration: 框架集成(桩模块)
|
|
25
|
+
|
|
26
|
+
安装:
|
|
27
|
+
pip install agentcore-sdk-agentrun-compat
|
|
28
|
+
|
|
29
|
+
环境变量(按最小透出定义:有行业标准的用标准,没标准且必需的才自己定):
|
|
30
|
+
AGENTCORE_WORKSPACE_ID — 工作空间 ID(拼进请求路径)
|
|
31
|
+
AGENTCORE_ENDPOINT — 服务端点(默认按 region 拼 https://agentcore.{region}.aliyuncs.com)
|
|
32
|
+
AGENTCORE_REGION_ID — 控制面 region(默认从 FC_REGION / ALIBABA_CLOUD_REGION_ID 解析,回落 cn-hangzhou)
|
|
33
|
+
AGENTCORE_API_VERSION — OpenAPI 版本
|
|
34
|
+
AGENTCORE_SDK_DEBUG=1 — 开启调试日志
|
|
35
|
+
ALIBABA_CLOUD_ACCESS_KEY_ID — Access Key ID(阿里云标准)
|
|
36
|
+
ALIBABA_CLOUD_ACCESS_KEY_SECRET — Access Key Secret(阿里云标准)
|
|
37
|
+
ALIBABA_CLOUD_SECURITY_TOKEN — STS Token(阿里云标准)
|
|
38
|
+
|
|
39
|
+
迁移期兼容:凭证与调试开关同时接受 AGENTRUN_* 旧名(会抛 DeprecationWarning)。
|
|
40
|
+
目标形态下此行为由独立迁移包提供,与主线包生命周期解耦,
|
|
41
|
+
详见 docs/COMPATIBILITY.md 第 3 节。
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
from typing import TYPE_CHECKING
|
|
45
|
+
|
|
46
|
+
__version__ = "0.1.0"
|
|
47
|
+
|
|
48
|
+
# Config
|
|
49
|
+
from agentcore.utils.config import Config
|
|
50
|
+
|
|
51
|
+
# Agent Runtime
|
|
52
|
+
from agentcore.agent_runtime import (
|
|
53
|
+
AgentRuntimeClient,
|
|
54
|
+
AgentRuntime,
|
|
55
|
+
AgentRuntimeEndpoint,
|
|
56
|
+
AgentRuntimeArtifact,
|
|
57
|
+
AgentRuntimeCode,
|
|
58
|
+
AgentRuntimeContainer,
|
|
59
|
+
AgentRuntimeCreateInput,
|
|
60
|
+
AgentRuntimeUpdateInput,
|
|
61
|
+
AgentRuntimeListInput,
|
|
62
|
+
AgentRuntimeLanguage,
|
|
63
|
+
AgentRuntimeProtocolType,
|
|
64
|
+
AgentRuntimeHealthCheckConfig,
|
|
65
|
+
AgentRuntimeLogConfig,
|
|
66
|
+
AgentRuntimeProtocolConfig,
|
|
67
|
+
AgentRuntimeEndpointCreateInput,
|
|
68
|
+
AgentRuntimeEndpointUpdateInput,
|
|
69
|
+
AgentRuntimeEndpointListInput,
|
|
70
|
+
AgentRuntimeEndpointRoutingConfig,
|
|
71
|
+
AgentRuntimeEndpointRoutingWeight,
|
|
72
|
+
Status,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Credential
|
|
76
|
+
from agentcore.credential import (
|
|
77
|
+
CredentialClient,
|
|
78
|
+
Credential,
|
|
79
|
+
CredentialBasicAuth,
|
|
80
|
+
CredentialConfig,
|
|
81
|
+
CredentialCreateInput,
|
|
82
|
+
CredentialUpdateInput,
|
|
83
|
+
CredentialListInput,
|
|
84
|
+
RelatedResource,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# Model
|
|
88
|
+
from agentcore.model import (
|
|
89
|
+
ModelClient,
|
|
90
|
+
ModelService,
|
|
91
|
+
ModelProxy,
|
|
92
|
+
BackendType,
|
|
93
|
+
ModelType,
|
|
94
|
+
Provider,
|
|
95
|
+
ProviderSettings,
|
|
96
|
+
ModelFeatures,
|
|
97
|
+
ModelProperties,
|
|
98
|
+
ModelParameterRule,
|
|
99
|
+
ModelInfoConfig,
|
|
100
|
+
ProxyConfig,
|
|
101
|
+
ProxyConfigEndpoint,
|
|
102
|
+
ProxyConfigFallback,
|
|
103
|
+
ProxyConfigPolicies,
|
|
104
|
+
ModelServiceCreateInput,
|
|
105
|
+
ModelServiceUpdateInput,
|
|
106
|
+
ModelServiceListInput,
|
|
107
|
+
ModelProxyCreateInput,
|
|
108
|
+
ModelProxyUpdateInput,
|
|
109
|
+
ModelProxyListInput,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# Exceptions
|
|
113
|
+
from agentcore.utils.exception import (
|
|
114
|
+
AgentCoreError,
|
|
115
|
+
HTTPError,
|
|
116
|
+
ResourceAlreadyExistError,
|
|
117
|
+
ResourceNotExistError,
|
|
118
|
+
ValidationError,
|
|
119
|
+
ConfigError,
|
|
120
|
+
CompatibilityWarning,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
# MCP
|
|
124
|
+
from agentcore.mcp import (
|
|
125
|
+
McpClient,
|
|
126
|
+
McpServer,
|
|
127
|
+
McpTool,
|
|
128
|
+
McpCreateInput,
|
|
129
|
+
McpUpdateInput,
|
|
130
|
+
McpAddress,
|
|
131
|
+
McpType,
|
|
132
|
+
McpProtocol,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Skill
|
|
136
|
+
from agentcore.skill import SkillClient, Skill, SkillCreateInput, SkillUpdateInput
|
|
137
|
+
|
|
138
|
+
# Tool / Toolset
|
|
139
|
+
from agentcore.tool import ToolClient, Tool
|
|
140
|
+
from agentcore.toolset import ToolsetClient, Toolset, ToolsetCreateInput
|
|
141
|
+
|
|
142
|
+
# SuperAgent(组合实现:ManagedAgent.subAgents[])
|
|
143
|
+
from agentcore.super_agent import (
|
|
144
|
+
SuperAgent,
|
|
145
|
+
SuperAgentClient,
|
|
146
|
+
SuperAgentCreateInput,
|
|
147
|
+
SuperAgentUpdateInput,
|
|
148
|
+
SuperAgentListInput,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Sandbox(兼容层,操作抛 NotImplementedError + OpenAPI 缺口编号 GAP-4)
|
|
152
|
+
from agentcore.sandbox import (
|
|
153
|
+
SandboxClient,
|
|
154
|
+
Sandbox,
|
|
155
|
+
Template,
|
|
156
|
+
CodeInterpreterSandbox,
|
|
157
|
+
BrowserSandbox,
|
|
158
|
+
AioSandbox,
|
|
159
|
+
CustomSandbox,
|
|
160
|
+
SandboxInput,
|
|
161
|
+
TemplateInput,
|
|
162
|
+
TemplateType,
|
|
163
|
+
TemplateNetworkMode,
|
|
164
|
+
CodeLanguage,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# Server 在根包做延迟导出,避免基础包 import 时强制加载
|
|
168
|
+
# fastapi / uvicorn / ag-ui-protocol;安装 [server] 后对象仍来自同一实现模块。
|
|
169
|
+
if TYPE_CHECKING:
|
|
170
|
+
from agentcore.server import (
|
|
171
|
+
AGUIProtocolConfig,
|
|
172
|
+
AGUIProtocolHandler,
|
|
173
|
+
AgentEvent,
|
|
174
|
+
AgentEventItem,
|
|
175
|
+
AgentRequest,
|
|
176
|
+
AgentResult,
|
|
177
|
+
AgentResultItem,
|
|
178
|
+
AgentReturnType,
|
|
179
|
+
AgentRunServer,
|
|
180
|
+
AguiEventNormalizer,
|
|
181
|
+
AsyncAgentEventGenerator,
|
|
182
|
+
AsyncAgentResultGenerator,
|
|
183
|
+
AsyncInvokeAgentHandler,
|
|
184
|
+
BaseProtocolHandler,
|
|
185
|
+
EventType,
|
|
186
|
+
InvokeAgentHandler,
|
|
187
|
+
Message,
|
|
188
|
+
MessageRole,
|
|
189
|
+
OpenAIProtocolConfig,
|
|
190
|
+
OpenAIProtocolHandler,
|
|
191
|
+
ProtocolConfig,
|
|
192
|
+
ProtocolHandler,
|
|
193
|
+
ServerConfig,
|
|
194
|
+
SyncAgentEventGenerator,
|
|
195
|
+
SyncAgentResultGenerator,
|
|
196
|
+
SyncInvokeAgentHandler,
|
|
197
|
+
ToolCall,
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
# ── 官方根包导出面的补齐 ──────────────────────────────────────
|
|
201
|
+
# 官方 `agentrun/__init__.py` 的 `__all__` 有 123 个符号,客户最常写的就是
|
|
202
|
+
# `from agentrun import X`。此前本包根命名空间缺 59 个——这是最致命的一面,
|
|
203
|
+
# 却也是符号闸门的盲区(闸门只扫子包 `__init__.py`,不扫根包),现已纳入快照。
|
|
204
|
+
#
|
|
205
|
+
# 官方部分名字做了重命名导出(`super_agent.Message` → `SuperAgentMessage`、
|
|
206
|
+
# `tool.Tool` → `ToolResource`),照抄别名,不改。
|
|
207
|
+
from agentcore.agent_runtime import AgentRuntimeControlAPI
|
|
208
|
+
from agentcore.credential import CredentialControlAPI
|
|
209
|
+
from agentcore.model import ModelCompletionAPI, ModelControlAPI, ModelDataAPI
|
|
210
|
+
from agentcore.super_agent import (
|
|
211
|
+
ConversationInfo,
|
|
212
|
+
InvokeResponseData,
|
|
213
|
+
InvokeStream,
|
|
214
|
+
SSEEvent,
|
|
215
|
+
)
|
|
216
|
+
from agentcore.super_agent import Message as SuperAgentMessage
|
|
217
|
+
from agentcore.tool import Tool as ToolResource
|
|
218
|
+
from agentcore.tool import ToolClient as ToolResourceClient
|
|
219
|
+
from agentcore.tool import ToolControlAPI as ToolResourceControlAPI
|
|
220
|
+
from agentcore.toolset import ToolSet, ToolSetClient
|
|
221
|
+
from agentcore.utils.credential_context import (
|
|
222
|
+
StsCredential,
|
|
223
|
+
use_sts_credentials,
|
|
224
|
+
use_sts_from_headers,
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
# `MergeOptions` 官方是从 `agentrun.server` 转出来的;本 SDK 取 `utils.helper` 的实现
|
|
228
|
+
# (同名同语义、且是纯本地类型),不让它跟着 server 桩一起报错。
|
|
229
|
+
from agentcore.utils.helper import MergeOptions
|
|
230
|
+
|
|
231
|
+
# ── 桩包符号:惰性解析 ────────────────────────────────────────
|
|
232
|
+
# 不能在这里 eager import:桩包用模块级 `__getattr__` 抛 NotImplementedError,
|
|
233
|
+
# 顶层导入会让 `import agentcore` 直接崩。改成访问时才解析——`import` 成功、
|
|
234
|
+
# 取用时抛带指引的错误,与桩包本身的约定一致。
|
|
235
|
+
_STUB_EXPORTS = {
|
|
236
|
+
# agentcore.memory_collection(GAP-3)
|
|
237
|
+
"EmbedderConfig": "agentcore.memory_collection",
|
|
238
|
+
"EmbedderConfigConfig": "agentcore.memory_collection",
|
|
239
|
+
"LLMConfig": "agentcore.memory_collection",
|
|
240
|
+
"LLMConfigConfig": "agentcore.memory_collection",
|
|
241
|
+
"MemoryCollection": "agentcore.memory_collection",
|
|
242
|
+
"MemoryCollectionClient": "agentcore.memory_collection",
|
|
243
|
+
"MemoryCollectionCreateInput": "agentcore.memory_collection",
|
|
244
|
+
"MemoryCollectionListInput": "agentcore.memory_collection",
|
|
245
|
+
"MemoryCollectionListOutput": "agentcore.memory_collection",
|
|
246
|
+
"MemoryCollectionUpdateInput": "agentcore.memory_collection",
|
|
247
|
+
"NetworkConfiguration": "agentcore.memory_collection",
|
|
248
|
+
"VectorStoreConfig": "agentcore.memory_collection",
|
|
249
|
+
"VectorStoreConfigConfig": "agentcore.memory_collection",
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
_SERVER_EXPORTS = {
|
|
253
|
+
"AgentRunServer",
|
|
254
|
+
"ServerConfig",
|
|
255
|
+
"ProtocolConfig",
|
|
256
|
+
"OpenAIProtocolConfig",
|
|
257
|
+
"AGUIProtocolConfig",
|
|
258
|
+
"AgentRequest",
|
|
259
|
+
"AgentEvent",
|
|
260
|
+
"AgentResult",
|
|
261
|
+
"Message",
|
|
262
|
+
"MessageRole",
|
|
263
|
+
"ToolCall",
|
|
264
|
+
"EventType",
|
|
265
|
+
"AgentEventItem",
|
|
266
|
+
"AgentResultItem",
|
|
267
|
+
"AgentReturnType",
|
|
268
|
+
"SyncAgentEventGenerator",
|
|
269
|
+
"SyncAgentResultGenerator",
|
|
270
|
+
"AsyncAgentEventGenerator",
|
|
271
|
+
"AsyncAgentResultGenerator",
|
|
272
|
+
"InvokeAgentHandler",
|
|
273
|
+
"AsyncInvokeAgentHandler",
|
|
274
|
+
"SyncInvokeAgentHandler",
|
|
275
|
+
"ProtocolHandler",
|
|
276
|
+
"BaseProtocolHandler",
|
|
277
|
+
"OpenAIProtocolHandler",
|
|
278
|
+
"AGUIProtocolHandler",
|
|
279
|
+
"AguiEventNormalizer",
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
_OPTIONAL_PACKAGES = {
|
|
283
|
+
"agentcore-sdk-agentrun-compat[server]": (
|
|
284
|
+
"fastapi",
|
|
285
|
+
"uvicorn",
|
|
286
|
+
"ag_ui",
|
|
287
|
+
"starlette",
|
|
288
|
+
),
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def __getattr__(name: str):
|
|
293
|
+
"""根包的惰性符号解析:桩包符号访问即抛带指引的 NotImplementedError。"""
|
|
294
|
+
if name in _SERVER_EXPORTS:
|
|
295
|
+
try:
|
|
296
|
+
from agentcore import server
|
|
297
|
+
|
|
298
|
+
return getattr(server, name)
|
|
299
|
+
except ImportError as exc:
|
|
300
|
+
error_text = str(exc)
|
|
301
|
+
for install_command, package_names in _OPTIONAL_PACKAGES.items():
|
|
302
|
+
if any(package_name in error_text for package_name in package_names):
|
|
303
|
+
raise ImportError(
|
|
304
|
+
f"'{name}' requires the 'server' optional dependencies. "
|
|
305
|
+
f"Install with: pip install {install_command}\n"
|
|
306
|
+
f"Original error: {exc}"
|
|
307
|
+
) from exc
|
|
308
|
+
raise
|
|
309
|
+
|
|
310
|
+
target = _STUB_EXPORTS.get(name)
|
|
311
|
+
if target is None:
|
|
312
|
+
raise AttributeError(f"module 'agentcore' has no attribute {name!r}")
|
|
313
|
+
import importlib
|
|
314
|
+
|
|
315
|
+
return getattr(importlib.import_module(target), name)
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def __dir__() -> list[str]:
|
|
319
|
+
"""让 `dir(agentcore)` / 补全能看到桩符号——否则它们像不存在。"""
|
|
320
|
+
return sorted(set(globals()) | set(_STUB_EXPORTS) | _SERVER_EXPORTS)
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
__all__ = [
|
|
324
|
+
"__version__",
|
|
325
|
+
"Config",
|
|
326
|
+
# Agent Runtime
|
|
327
|
+
"AgentRuntimeClient", "AgentRuntime", "AgentRuntimeEndpoint",
|
|
328
|
+
"AgentRuntimeArtifact", "AgentRuntimeCode", "AgentRuntimeContainer",
|
|
329
|
+
"AgentRuntimeCreateInput", "AgentRuntimeUpdateInput", "AgentRuntimeListInput",
|
|
330
|
+
"AgentRuntimeLanguage", "AgentRuntimeProtocolType",
|
|
331
|
+
"AgentRuntimeHealthCheckConfig", "AgentRuntimeLogConfig", "AgentRuntimeProtocolConfig",
|
|
332
|
+
"AgentRuntimeEndpointCreateInput", "AgentRuntimeEndpointUpdateInput", "AgentRuntimeEndpointListInput",
|
|
333
|
+
"AgentRuntimeEndpointRoutingConfig", "AgentRuntimeEndpointRoutingWeight",
|
|
334
|
+
"Status",
|
|
335
|
+
# Credential
|
|
336
|
+
"CredentialClient", "Credential", "CredentialBasicAuth", "CredentialConfig",
|
|
337
|
+
"CredentialCreateInput", "CredentialUpdateInput", "CredentialListInput", "RelatedResource",
|
|
338
|
+
# Model
|
|
339
|
+
"ModelClient", "ModelService", "ModelProxy",
|
|
340
|
+
"BackendType", "ModelType", "Provider",
|
|
341
|
+
"ProviderSettings", "ModelFeatures", "ModelProperties", "ModelParameterRule", "ModelInfoConfig",
|
|
342
|
+
"ProxyConfig", "ProxyConfigEndpoint", "ProxyConfigFallback", "ProxyConfigPolicies",
|
|
343
|
+
"ModelServiceCreateInput", "ModelServiceUpdateInput", "ModelServiceListInput",
|
|
344
|
+
"ModelProxyCreateInput", "ModelProxyUpdateInput", "ModelProxyListInput",
|
|
345
|
+
# Exceptions
|
|
346
|
+
"AgentCoreError", "HTTPError", "ResourceAlreadyExistError",
|
|
347
|
+
"ResourceNotExistError", "ValidationError", "ConfigError", "CompatibilityWarning",
|
|
348
|
+
# MCP
|
|
349
|
+
"McpClient", "McpServer", "McpTool", "McpCreateInput", "McpUpdateInput",
|
|
350
|
+
"McpAddress", "McpType", "McpProtocol",
|
|
351
|
+
# Skill
|
|
352
|
+
"SkillClient", "Skill", "SkillCreateInput", "SkillUpdateInput",
|
|
353
|
+
# Tool / Toolset
|
|
354
|
+
"ToolClient", "Tool", "ToolsetClient", "Toolset", "ToolsetCreateInput",
|
|
355
|
+
# SuperAgent
|
|
356
|
+
"SuperAgent", "SuperAgentClient",
|
|
357
|
+
"SuperAgentCreateInput", "SuperAgentUpdateInput", "SuperAgentListInput",
|
|
358
|
+
# Sandbox
|
|
359
|
+
"SandboxClient", "Sandbox", "Template",
|
|
360
|
+
"CodeInterpreterSandbox", "BrowserSandbox", "AioSandbox", "CustomSandbox",
|
|
361
|
+
"SandboxInput", "TemplateInput", "TemplateType", "TemplateNetworkMode", "CodeLanguage",
|
|
362
|
+
# 官方根包导出面(重命名别名照抄官方)
|
|
363
|
+
"AgentRuntimeControlAPI", "CredentialControlAPI",
|
|
364
|
+
"ModelCompletionAPI", "ModelControlAPI", "ModelDataAPI",
|
|
365
|
+
"ConversationInfo", "InvokeResponseData", "InvokeStream", "SSEEvent", "SuperAgentMessage",
|
|
366
|
+
"ToolResource", "ToolResourceClient", "ToolResourceControlAPI",
|
|
367
|
+
"ToolSet", "ToolSetClient",
|
|
368
|
+
"MergeOptions", "StsCredential", "use_sts_credentials", "use_sts_from_headers",
|
|
369
|
+
# Server
|
|
370
|
+
"AgentRunServer", "ServerConfig", "ProtocolConfig",
|
|
371
|
+
"OpenAIProtocolConfig", "AGUIProtocolConfig", "AgentRequest", "AgentEvent",
|
|
372
|
+
"AgentResult", "Message", "MessageRole", "ToolCall", "EventType",
|
|
373
|
+
"AgentEventItem", "AgentResultItem", "AgentReturnType",
|
|
374
|
+
"SyncAgentEventGenerator", "SyncAgentResultGenerator",
|
|
375
|
+
"AsyncAgentEventGenerator", "AsyncAgentResultGenerator",
|
|
376
|
+
"InvokeAgentHandler", "AsyncInvokeAgentHandler", "SyncInvokeAgentHandler",
|
|
377
|
+
"ProtocolHandler", "BaseProtocolHandler", "OpenAIProtocolHandler",
|
|
378
|
+
"AGUIProtocolHandler", "AguiEventNormalizer",
|
|
379
|
+
# 桩包符号(惰性解析,取用即抛带指引的错误)
|
|
380
|
+
*sorted(_STUB_EXPORTS),
|
|
381
|
+
]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Agent Runtime 模块 / Agent Runtime Module
|
|
2
|
+
|
|
3
|
+
对标 AgentRun SDK 的 `agentrun.agent_runtime`。
|
|
4
|
+
|
|
5
|
+
`AgentRuntimeControlAPI` 是 AgentRun 的内部控制面 API 层,本 SDK 统一走
|
|
6
|
+
`agentcore.api.AgentCoreAPI`;名字以桩保留(import 不报错、构造即报错并给指引)。
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from agentcore.utils.control_api import LEGACY_API_GUIDANCE
|
|
10
|
+
from agentcore.utils.stub import make_stub_class
|
|
11
|
+
|
|
12
|
+
from .client import AgentRuntimeClient
|
|
13
|
+
from .endpoint import AgentRuntimeEndpoint
|
|
14
|
+
from .model import (
|
|
15
|
+
AgentRuntimeArtifact,
|
|
16
|
+
AgentRuntimeCode,
|
|
17
|
+
AgentRuntimeContainer,
|
|
18
|
+
AgentRuntimeCreateInput,
|
|
19
|
+
AgentRuntimeEndpointCreateInput,
|
|
20
|
+
AgentRuntimeEndpointListInput,
|
|
21
|
+
AgentRuntimeEndpointRoutingConfig,
|
|
22
|
+
AgentRuntimeEndpointRoutingWeight,
|
|
23
|
+
AgentRuntimeEndpointUpdateInput,
|
|
24
|
+
AgentRuntimeHealthCheckConfig,
|
|
25
|
+
AgentRuntimeLanguage,
|
|
26
|
+
AgentRuntimeListInput,
|
|
27
|
+
AgentRuntimeLogConfig,
|
|
28
|
+
AgentRuntimeProtocolConfig,
|
|
29
|
+
AgentRuntimeProtocolType,
|
|
30
|
+
AgentRuntimeUpdateInput,
|
|
31
|
+
Status,
|
|
32
|
+
)
|
|
33
|
+
from .runtime import AgentRuntime
|
|
34
|
+
|
|
35
|
+
AgentRuntimeControlAPI = make_stub_class(
|
|
36
|
+
"agentcore.agent_runtime.AgentRuntimeControlAPI", LEGACY_API_GUIDANCE
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
"AgentRuntimeControlAPI",
|
|
41
|
+
# base
|
|
42
|
+
"AgentRuntime",
|
|
43
|
+
"AgentRuntimeEndpoint",
|
|
44
|
+
"AgentRuntimeClient",
|
|
45
|
+
# enum
|
|
46
|
+
"AgentRuntimeArtifact",
|
|
47
|
+
"AgentRuntimeLanguage",
|
|
48
|
+
"AgentRuntimeProtocolType",
|
|
49
|
+
"Status",
|
|
50
|
+
# inner model
|
|
51
|
+
"AgentRuntimeCode",
|
|
52
|
+
"AgentRuntimeContainer",
|
|
53
|
+
"AgentRuntimeHealthCheckConfig",
|
|
54
|
+
"AgentRuntimeLogConfig",
|
|
55
|
+
"AgentRuntimeProtocolConfig",
|
|
56
|
+
"AgentRuntimeEndpointRoutingConfig",
|
|
57
|
+
"AgentRuntimeEndpointRoutingWeight",
|
|
58
|
+
# api model
|
|
59
|
+
"AgentRuntimeCreateInput",
|
|
60
|
+
"AgentRuntimeUpdateInput",
|
|
61
|
+
"AgentRuntimeListInput",
|
|
62
|
+
"AgentRuntimeEndpointCreateInput",
|
|
63
|
+
"AgentRuntimeEndpointUpdateInput",
|
|
64
|
+
"AgentRuntimeEndpointListInput",
|
|
65
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Agent Runtime API compatibility surface."""
|
|
2
|
+
|
|
3
|
+
from agentcore.agent_runtime import AgentRuntimeControlAPI
|
|
4
|
+
from agentcore.utils.openapi_gap import gap_guidance
|
|
5
|
+
from agentcore.utils.stub import make_stub_class
|
|
6
|
+
|
|
7
|
+
_GUIDANCE = gap_guidance("GAP-5", "AgentCore 尚未公开 Agent 调用数据面。")
|
|
8
|
+
AgentRuntimeDataAPI = make_stub_class(
|
|
9
|
+
"agentcore.agent_runtime.api.AgentRuntimeDataAPI", _GUIDANCE
|
|
10
|
+
)
|
|
11
|
+
InvokeArgs = make_stub_class("agentcore.agent_runtime.api.InvokeArgs", _GUIDANCE)
|
|
12
|
+
|
|
13
|
+
__all__ = ["AgentRuntimeControlAPI", "AgentRuntimeDataAPI", "InvokeArgs"]
|