managed-agent-sdk 0.0.1__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.
@@ -0,0 +1,325 @@
1
+ """Managed Agent SDK(Python)。
2
+
3
+ 控制面走腾讯云 API,数据面走 ACP 协议,两段凭证由 SDK 内部缝合。
4
+ API 与 Node 版 ``@tencent-ai/managed-agent-sdk`` 保持一致。
5
+
6
+ Example:
7
+ >>> import asyncio
8
+ >>> from managed_agent_sdk import (
9
+ ... CreateAgentOpts, CreateSessionOpts, CreateVersionOpts,
10
+ ... ManagedAgentClient, ManifestBuilder,
11
+ ... )
12
+ >>>
13
+ >>> async def main():
14
+ ... async with ManagedAgentClient() as client:
15
+ ... agent = await client.agents.create(
16
+ ... CreateAgentOpts(
17
+ ... agent_name="日志分析助手",
18
+ ... model="deepseek-v3",
19
+ ... manifest=ManifestBuilder()
20
+ ... .system_prompt("你是日志分析专家")
21
+ ... .build(),
22
+ ... )
23
+ ... )
24
+ ... version = await agent.versions.create(CreateVersionOpts())
25
+ ... session = await agent.sessions.create(
26
+ ... CreateSessionOpts(version_id=version.version_id)
27
+ ... )
28
+ ... res = await session.prompt("分析这份日志")
29
+ ... print(res.stop_reason)
30
+ ... await session.disconnect()
31
+ >>>
32
+ >>> asyncio.run(main()) # doctest: +SKIP
33
+
34
+ 两条与出参有关的约定(与 Node 版一致):
35
+
36
+ 1. **入参 snake_case,出参 PascalCase** —— 出参原样透传云 API 字段名,
37
+ 便于对照官方文档排查。
38
+ 2. **不做控制面自动重试** —— ``Create*`` 类接口非幂等且无 ``ClientToken``,
39
+ 重试 ``sessions.create()`` 会重复拉起沙箱并产生真实费用。
40
+ """
41
+
42
+ from __future__ import annotations
43
+
44
+ from ._version import __version__
45
+ from .acp.client import AcpConnectionState, NotificationListener
46
+ from .acp_types import (
47
+ AudioContent,
48
+ ContentBlock,
49
+ EmbeddedResource,
50
+ ImageContent,
51
+ PromptResponse,
52
+ ResourceLink,
53
+ SessionNotification,
54
+ TextContent,
55
+ )
56
+ from .agent import (
57
+ Agent,
58
+ AgentA2A,
59
+ AgentSessions,
60
+ AgentVersions,
61
+ CreateSessionOpts,
62
+ UpdateA2AOpts,
63
+ UpdateAgentOpts,
64
+ )
65
+ from .auth import ChatCredentialProvider, OneIdCredentialProvider
66
+
67
+ # CapiClient / resolve_credentials 不对外导出:SDK 不提供调用未封装接口的透传能力
68
+ # (与 Node 侧 index.ts 一致)。内部联调脚本(e2e)直接从 .capi 引入。
69
+ from .catalog import (
70
+ ConnectorRegistry,
71
+ ExpertPage,
72
+ ExpertRegistry,
73
+ ListConnectorsOpts,
74
+ ListExpertsOpts,
75
+ ListSkillsOpts,
76
+ SkillPage,
77
+ SkillRegistry,
78
+ )
79
+ from .client import CreateAgentOpts, ManagedAgentClient
80
+ from .errors import (
81
+ AcpAuthError,
82
+ AcpNetworkError,
83
+ AcpProtocolError,
84
+ AuthError,
85
+ CapiError,
86
+ CapiErrorType,
87
+ CloudAgentError,
88
+ ConflictError,
89
+ InvalidRequestError,
90
+ NetworkError,
91
+ NotFoundError,
92
+ PermissionDeniedError,
93
+ RateLimitError,
94
+ ServerError,
95
+ ServiceUnavailableError,
96
+ TimeoutError,
97
+ ValidationError,
98
+ )
99
+ from .external_agent import (
100
+ A2ASkill,
101
+ AgentExternalAgents,
102
+ BindExternalAgentOpts,
103
+ BindResult,
104
+ ExternalAgentBound,
105
+ ListExternalAgentsOpts,
106
+ UnbindExternalAgentOpts,
107
+ UnbindResult,
108
+ is_bound,
109
+ )
110
+ from .manifest import (
111
+ MANIFEST_VERSION,
112
+ ExpertRefInput,
113
+ ManifestBuilder,
114
+ ManifestExpertRef,
115
+ ManifestRefType,
116
+ ManifestSkillRef,
117
+ SkillRefInput,
118
+ )
119
+ from .opts import (
120
+ DEFAULT_API_VERSION,
121
+ DEFAULT_ENDPOINT,
122
+ DEFAULT_REGION,
123
+ DEFAULT_TIMEOUT_MS,
124
+ MAX_PAGE_LIMIT,
125
+ AgentListOpts,
126
+ AgentSortBy,
127
+ ClientOpts,
128
+ ConnectOpts,
129
+ Credentials,
130
+ Filter,
131
+ Language,
132
+ Logger,
133
+ LogLevel,
134
+ Page,
135
+ PageOpts,
136
+ RequestOpts,
137
+ SessionListOpts,
138
+ SessionSortBy,
139
+ SortDirection,
140
+ )
141
+ from .session import MessageListOpts, PromptOpts, Session
142
+ from .types import (
143
+ A2AConfig,
144
+ A2ASkillItem,
145
+ A2AStatus,
146
+ AgentInfo,
147
+ AgentListItem,
148
+ AgentVersionItem,
149
+ BuiltinModel,
150
+ ChatEndpointItem,
151
+ ConnectorAuthMode,
152
+ ConnectorItem,
153
+ ConnectorSource,
154
+ ConnectorStatus,
155
+ ConnectorType,
156
+ EnabledStatus,
157
+ ExpertCounts,
158
+ ExpertItem,
159
+ ExpertSource,
160
+ ExternalAgentInfo,
161
+ Message,
162
+ MessageEvent,
163
+ MessageEventType,
164
+ PublishStatus,
165
+ RoutingItem,
166
+ SessionInfo,
167
+ SessionItem,
168
+ SessionSource,
169
+ SessionStatus,
170
+ SkillCounts,
171
+ SkillItem,
172
+ SkillSource,
173
+ TokenUsage,
174
+ ToolCall,
175
+ ToolCallStatus,
176
+ VersionInfo,
177
+ VersionStatus,
178
+ VersionType,
179
+ )
180
+ from .version import (
181
+ CreateVersionFromSourceOpts,
182
+ CreateVersionOpts,
183
+ UpdateVersionOpts,
184
+ Version,
185
+ )
186
+
187
+ __all__ = [
188
+ "__version__",
189
+ # ── ACP 协议类型(数据面)────────────────────────────────
190
+ "ContentBlock",
191
+ "TextContent",
192
+ "ImageContent",
193
+ "AudioContent",
194
+ "ResourceLink",
195
+ "EmbeddedResource",
196
+ "PromptResponse",
197
+ "SessionNotification",
198
+ "AcpConnectionState",
199
+ "NotificationListener",
200
+ # session.connect() 的入参(Node 版叫 ConnectOpts)
201
+ "ConnectOpts",
202
+ # ── 入口 ────────────────────────────────
203
+ "ManagedAgentClient",
204
+ # ── 领域对象 ────────────────────────────────
205
+ "Agent",
206
+ "AgentVersions",
207
+ "AgentSessions",
208
+ "AgentA2A",
209
+ "AgentExternalAgents",
210
+ "is_bound",
211
+ "ConnectorRegistry",
212
+ "SkillRegistry",
213
+ "ExpertRegistry",
214
+ "Session",
215
+ "Version",
216
+ "ManifestBuilder",
217
+ "OneIdCredentialProvider",
218
+ "ChatCredentialProvider",
219
+ # ── 入参 ────────────────────────────────
220
+ "CreateAgentOpts",
221
+ "UpdateAgentOpts",
222
+ "CreateSessionOpts",
223
+ "UpdateA2AOpts",
224
+ "CreateVersionOpts",
225
+ "CreateVersionFromSourceOpts",
226
+ "UpdateVersionOpts",
227
+ "MessageListOpts",
228
+ "PromptOpts",
229
+ "A2ASkill",
230
+ "ListConnectorsOpts",
231
+ "ListSkillsOpts",
232
+ "ListExpertsOpts",
233
+ "ManifestSkillRef",
234
+ "ManifestExpertRef",
235
+ "ManifestRefType",
236
+ "SkillRefInput",
237
+ "ExpertRefInput",
238
+ # ── 出参 ────────────────────────────────
239
+ "AgentInfo",
240
+ "AgentListItem",
241
+ "BuiltinModel",
242
+ "VersionInfo",
243
+ "AgentVersionItem",
244
+ "SessionInfo",
245
+ "ChatEndpointItem",
246
+ "SessionItem",
247
+ "MessageEvent",
248
+ "Message",
249
+ "ToolCall",
250
+ "TokenUsage",
251
+ "ExternalAgentInfo",
252
+ "A2ASkillItem",
253
+ "A2AConfig",
254
+ "RoutingItem",
255
+ "BindResult",
256
+ "UnbindResult",
257
+ "ExternalAgentBound",
258
+ "ListExternalAgentsOpts",
259
+ "BindExternalAgentOpts",
260
+ "UnbindExternalAgentOpts",
261
+ # 目录资源出参
262
+ "ConnectorItem",
263
+ "SkillItem",
264
+ "SkillCounts",
265
+ "SkillPage",
266
+ "ExpertItem",
267
+ "ExpertCounts",
268
+ "ExpertPage",
269
+ # ── 枚举 ────────────────────────────────
270
+ "VersionType",
271
+ "VersionStatus",
272
+ "SessionStatus",
273
+ "SessionSource",
274
+ "A2AStatus",
275
+ "MessageEventType",
276
+ "ToolCallStatus",
277
+ "CapiErrorType",
278
+ "AgentSortBy",
279
+ "SessionSortBy",
280
+ "SortDirection",
281
+ "SkillSource",
282
+ "ExpertSource",
283
+ "PublishStatus",
284
+ "EnabledStatus",
285
+ "ConnectorStatus",
286
+ "ConnectorSource",
287
+ "ConnectorType",
288
+ "ConnectorAuthMode",
289
+ # ── 配置 ────────────────────────────────
290
+ "ClientOpts",
291
+ "RequestOpts",
292
+ "PageOpts",
293
+ "AgentListOpts",
294
+ "SessionListOpts",
295
+ "Page",
296
+ "Filter",
297
+ "Credentials",
298
+ "Logger",
299
+ "LogLevel",
300
+ "Language",
301
+ # ── 错误 ────────────────────────────────
302
+ "CloudAgentError",
303
+ "ValidationError",
304
+ "TimeoutError",
305
+ "CapiError",
306
+ "InvalidRequestError",
307
+ "AuthError",
308
+ "PermissionDeniedError",
309
+ "NotFoundError",
310
+ "ConflictError",
311
+ "RateLimitError",
312
+ "ServerError",
313
+ "ServiceUnavailableError",
314
+ "NetworkError",
315
+ "AcpAuthError",
316
+ "AcpNetworkError",
317
+ "AcpProtocolError",
318
+ # ── 常量与工具 ────────────────────────────────
319
+ "DEFAULT_ENDPOINT",
320
+ "DEFAULT_API_VERSION",
321
+ "DEFAULT_REGION",
322
+ "DEFAULT_TIMEOUT_MS",
323
+ "MAX_PAGE_LIMIT",
324
+ "MANIFEST_VERSION",
325
+ ]
@@ -0,0 +1,8 @@
1
+ """由 scripts/codegen.py 从 spec/ 生成。请勿手改 —— 改 spec/ 后跑 `pnpm codegen`。"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .actions import * # noqa: F403
6
+ from .defaults import * # noqa: F403
7
+ from .enums import * # noqa: F403
8
+ from .types import * # noqa: F403