agentkit-sdk-python 0.1.5__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 (120) hide show
  1. agentkit/__init__.py +23 -0
  2. agentkit/apps/__init__.py +58 -0
  3. agentkit/apps/a2a_app/__init__.py +13 -0
  4. agentkit/apps/a2a_app/a2a_app.py +134 -0
  5. agentkit/apps/a2a_app/telemetry.py +119 -0
  6. agentkit/apps/agent_server_app/__init__.py +13 -0
  7. agentkit/apps/agent_server_app/agent_server_app.py +85 -0
  8. agentkit/apps/base_app.py +20 -0
  9. agentkit/apps/mcp_app/__init__.py +13 -0
  10. agentkit/apps/mcp_app/mcp_app.py +150 -0
  11. agentkit/apps/mcp_app/telemetry.py +115 -0
  12. agentkit/apps/simple_app/__init__.py +13 -0
  13. agentkit/apps/simple_app/simple_app.py +94 -0
  14. agentkit/apps/simple_app/simple_app_handlers.py +325 -0
  15. agentkit/apps/simple_app/telemetry.py +124 -0
  16. agentkit/apps/utils.py +45 -0
  17. agentkit/client/__init__.py +26 -0
  18. agentkit/client/base_client.py +219 -0
  19. agentkit/identity/__init__.py +13 -0
  20. agentkit/identity/auth.py +70 -0
  21. agentkit/knowledge/__init__.py +47 -0
  22. agentkit/knowledge/knowledge.py +203 -0
  23. agentkit/knowledge/knowledge_all_types.py +191 -0
  24. agentkit/mcp/__init__.py +79 -0
  25. agentkit/mcp/mcp.py +294 -0
  26. agentkit/mcp/mcp_all_types.py +1212 -0
  27. agentkit/memory/__init__.py +71 -0
  28. agentkit/memory/memory.py +236 -0
  29. agentkit/memory/memory_all_types.py +358 -0
  30. agentkit/runtime/__init__.py +13 -0
  31. agentkit/runtime/runtime.py +191 -0
  32. agentkit/runtime/runtime_all_types.py +624 -0
  33. agentkit/runtime/runtime_v1.py +178 -0
  34. agentkit/runtime/types.py +188 -0
  35. agentkit/toolkit/__init__.py +13 -0
  36. agentkit/toolkit/cli/__init__.py +13 -0
  37. agentkit/toolkit/cli/__main__.py +7 -0
  38. agentkit/toolkit/cli/cli.py +97 -0
  39. agentkit/toolkit/cli/cli_build.py +53 -0
  40. agentkit/toolkit/cli/cli_config.py +170 -0
  41. agentkit/toolkit/cli/cli_deploy.py +52 -0
  42. agentkit/toolkit/cli/cli_destroy.py +53 -0
  43. agentkit/toolkit/cli/cli_init.py +364 -0
  44. agentkit/toolkit/cli/cli_invoke.py +168 -0
  45. agentkit/toolkit/cli/cli_launch.py +34 -0
  46. agentkit/toolkit/cli/cli_status.py +53 -0
  47. agentkit/toolkit/cli/cli_version.py +87 -0
  48. agentkit/toolkit/cli/utils.py +47 -0
  49. agentkit/toolkit/config/__init__.py +52 -0
  50. agentkit/toolkit/config/auto_prompt.py +752 -0
  51. agentkit/toolkit/config/build_config.py +28 -0
  52. agentkit/toolkit/config/common_config.py +18 -0
  53. agentkit/toolkit/config/config.py +306 -0
  54. agentkit/toolkit/config/config_handler.py +331 -0
  55. agentkit/toolkit/config/config_manager.py +48 -0
  56. agentkit/toolkit/config/config_validator.py +121 -0
  57. agentkit/toolkit/config/constants.py +18 -0
  58. agentkit/toolkit/config/dataclass_utils.py +153 -0
  59. agentkit/toolkit/config/deploy_config.py +1 -0
  60. agentkit/toolkit/config/utils.py +57 -0
  61. agentkit/toolkit/config/workflow_configs.py +149 -0
  62. agentkit/toolkit/consts.py +1 -0
  63. agentkit/toolkit/core/__init__.py +13 -0
  64. agentkit/toolkit/core/build/__init__.py +13 -0
  65. agentkit/toolkit/core/build/base_builder.py +6 -0
  66. agentkit/toolkit/core/build/cloud_builder.py +0 -0
  67. agentkit/toolkit/core/build/local_builder.py +0 -0
  68. agentkit/toolkit/core/deploy/__init__.py +13 -0
  69. agentkit/toolkit/core/deploy/base_deployer.py +6 -0
  70. agentkit/toolkit/core/deploy/cloud_deployer.py +0 -0
  71. agentkit/toolkit/core/deploy/local_deployer.py +0 -0
  72. agentkit/toolkit/integrations/__init__.py +17 -0
  73. agentkit/toolkit/integrations/builder/__init__.py +23 -0
  74. agentkit/toolkit/integrations/builder/base.py +59 -0
  75. agentkit/toolkit/integrations/builder/local_docker_builder.py +163 -0
  76. agentkit/toolkit/integrations/builder/ve_core_pipeline_builder.py +853 -0
  77. agentkit/toolkit/integrations/container.py +843 -0
  78. agentkit/toolkit/integrations/runner/__init__.py +26 -0
  79. agentkit/toolkit/integrations/runner/base.py +222 -0
  80. agentkit/toolkit/integrations/runner/local_docker_runner.py +407 -0
  81. agentkit/toolkit/integrations/runner/ve_agentkit_runner.py +665 -0
  82. agentkit/toolkit/integrations/services/__init__.py +26 -0
  83. agentkit/toolkit/integrations/services/cr_service.py +449 -0
  84. agentkit/toolkit/integrations/services/tos_service.py +291 -0
  85. agentkit/toolkit/integrations/utils/__init__.py +21 -0
  86. agentkit/toolkit/integrations/utils/project_archiver.py +276 -0
  87. agentkit/toolkit/integrations/ve_code_pipeline.py +643 -0
  88. agentkit/toolkit/integrations/ve_cr.py +385 -0
  89. agentkit/toolkit/integrations/ve_iam.py +210 -0
  90. agentkit/toolkit/resources/samples/basic.py +79 -0
  91. agentkit/toolkit/resources/samples/basic_stream.py +100 -0
  92. agentkit/toolkit/resources/samples/customer_support_assistant.py +3 -0
  93. agentkit/toolkit/resources/samples/financial_analyst.py +140 -0
  94. agentkit/toolkit/resources/samples/simple_a2a_veadk.py +32 -0
  95. agentkit/toolkit/resources/samples/simple_app_veadk.py +55 -0
  96. agentkit/toolkit/resources/samples/simple_mcp_veadk.py +50 -0
  97. agentkit/toolkit/resources/templates/Dockerfile.j2 +27 -0
  98. agentkit/toolkit/resources/templates/code-pipeline-tos-cr-step.j2 +52 -0
  99. agentkit/toolkit/workflows/__init__.py +27 -0
  100. agentkit/toolkit/workflows/base.py +87 -0
  101. agentkit/toolkit/workflows/hybird_local_ve_workflow_v1.py +381 -0
  102. agentkit/toolkit/workflows/local_workflow_v1.py +262 -0
  103. agentkit/toolkit/workflows/ve_agentkit_workflow.py +369 -0
  104. agentkit/tools/__init__.py +17 -0
  105. agentkit/tools/tools.py +106 -0
  106. agentkit/tools/tools_all_types.py +337 -0
  107. agentkit/utils/__init__.py +41 -0
  108. agentkit/utils/credential.py +44 -0
  109. agentkit/utils/logging_config.py +366 -0
  110. agentkit/utils/misc.py +70 -0
  111. agentkit/utils/request.py +59 -0
  112. agentkit/utils/template_utils.py +256 -0
  113. agentkit/utils/ve_sign.py +247 -0
  114. agentkit/version.py +15 -0
  115. agentkit_sdk_python-0.1.5.dist-info/METADATA +262 -0
  116. agentkit_sdk_python-0.1.5.dist-info/RECORD +120 -0
  117. agentkit_sdk_python-0.1.5.dist-info/WHEEL +5 -0
  118. agentkit_sdk_python-0.1.5.dist-info/entry_points.txt +2 -0
  119. agentkit_sdk_python-0.1.5.dist-info/licenses/LICENSE +201 -0
  120. agentkit_sdk_python-0.1.5.dist-info/top_level.txt +1 -0
@@ -0,0 +1,369 @@
1
+ # Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import json
16
+
17
+ from agentkit.toolkit.workflows import Workflow
18
+ from typing import Dict, Any, Tuple
19
+ from datetime import datetime
20
+ from agentkit.toolkit.config import (
21
+ AUTO_CREATE_VE,
22
+ get_config,
23
+ VeAgentkitConfig
24
+ )
25
+ from agentkit.toolkit.integrations.runner import VeAgentkitRuntimeRunner
26
+ from agentkit.utils.misc import generate_runtime_name
27
+ from agentkit.toolkit.integrations.services.cr_service import CRService
28
+ from rich.console import Console
29
+ from agentkit.toolkit.integrations.services.tos_service import TOSService
30
+
31
+ console = Console()
32
+
33
+ class VeAgentkitWorkflow(Workflow):
34
+ """VeAgentkit工作流实现 - 使用VeCPCRBuilder进行云上构建"""
35
+
36
+ def __init__(self):
37
+ super().__init__()
38
+ self.console = Console()
39
+
40
+ def prompt_for_config(self, current_config: Dict[str, Any] = None) -> Dict[str, Any]:
41
+ """生成交互式配置"""
42
+ from agentkit.toolkit.config.auto_prompt import generate_config_from_dataclass
43
+
44
+ if current_config is None:
45
+ current_config = {}
46
+
47
+ agent_config = get_config()
48
+ common_config = agent_config.get_common_config()
49
+ timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
50
+ # 兼容旧字段名
51
+ if current_config.get("cr_instance_name") is None or current_config["cr_instance_name"] == AUTO_CREATE_VE or current_config["cr_instance_name"] == "":
52
+ # 也检查旧字段名
53
+ if current_config.get("ve_cr_instance_name"):
54
+ current_config["cr_instance_name"] = current_config["ve_cr_instance_name"]
55
+ else:
56
+ current_config["cr_instance_name"] = CRService.default_cr_instance_name_template()
57
+ if current_config.get("cr_repo_name") is None or current_config["cr_repo_name"] == AUTO_CREATE_VE or current_config["cr_repo_name"] == "":
58
+ if current_config.get("ve_cr_repo_name"):
59
+ current_config["cr_repo_name"] = current_config["ve_cr_repo_name"]
60
+ else:
61
+ current_config["cr_repo_name"] = common_config.agent_name
62
+
63
+ #桶名称
64
+ if current_config.get("tos_bucket") is None or current_config["tos_bucket"] == AUTO_CREATE_VE or current_config["tos_bucket"] == "":
65
+ current_config["tos_bucket"] = TOSService.default_bucket_name_template()
66
+
67
+ return generate_config_from_dataclass(VeAgentkitConfig, current_config)
68
+
69
+ def build(self, config: Dict[str, Any]) -> bool:
70
+ """构建代理镜像使用VeCPCRBuilder"""
71
+ try:
72
+ from agentkit.toolkit.integrations.builder.ve_core_pipeline_builder import (
73
+ VeCPCRBuilder, VeCPCRBuilderConfig, VeCPCRBuilderResult
74
+ )
75
+ except ImportError as e:
76
+ console.print(f"[red]错误: 缺少VeCPCRBuilder依赖 - {e}[/red]")
77
+ return False
78
+
79
+ try:
80
+ console.print("[green]🔨 开始构建Agent镜像...[/green]")
81
+
82
+ # 解析配置
83
+ ve_config = VeAgentkitConfig.from_dict(config)
84
+ agent_config = get_config()
85
+ common_config = agent_config.get_common_config()
86
+
87
+ # 特殊规则,CP名称必须和runtime名称一致
88
+ # 1. 如果runtime名称未配置,生成一个runtime名称
89
+ if ve_config.runtime_name == AUTO_CREATE_VE or ve_config.runtime_name == "":
90
+ ve_config.runtime_name = generate_runtime_name(common_config.agent_name)
91
+ # 2. 强制CP名称和runtime名称一致
92
+ ve_config.cp_pipeline_name = ve_config.runtime_name
93
+
94
+
95
+
96
+ # 构建VeCPCRBuilder配置
97
+ builder_config = VeCPCRBuilderConfig(
98
+ common_config=common_config,
99
+ tos_bucket=ve_config.tos_bucket,
100
+ tos_region=ve_config.tos_region,
101
+ tos_prefix=ve_config.tos_prefix,
102
+ cr_instance_name=ve_config.cr_instance_name,
103
+ cr_namespace_name=ve_config.cr_namespace_name,
104
+ cr_repo_name=ve_config.cr_repo_name,
105
+ cr_region=ve_config.cr_region,
106
+ cp_workspace_name=ve_config.cp_workspace_name,
107
+ cp_pipeline_name=ve_config.cp_pipeline_name,
108
+ cp_pipeline_id=ve_config.cp_pipeline_id,
109
+ image_tag=ve_config.image_tag,
110
+ build_timeout=ve_config.build_timeout
111
+ ).to_dict()
112
+
113
+ # 执行构建
114
+ builder = VeCPCRBuilder()
115
+ success, build_result = builder.build(builder_config)
116
+
117
+ if success:
118
+ result = VeCPCRBuilderResult.from_dict(build_result)
119
+
120
+ # 更新配置
121
+ ve_config.cr_image_full_url = result.image_url
122
+ ve_config.cr_instance_name = result.cr_instance_name or ve_config.cr_instance_name
123
+ ve_config.cr_namespace_name = result.cr_namespace_name or ve_config.cr_namespace_name
124
+ ve_config.cr_repo_name = result.cr_repo_name or ve_config.cr_repo_name
125
+ ve_config.cp_pipeline_id = result.cp_pipeline_id or ve_config.cp_pipeline_id
126
+ ve_config.build_timestamp = result.build_timestamp or ve_config.build_timestamp
127
+
128
+
129
+ # 回写TOS资源信息
130
+ if result.resources:
131
+ ve_config.tos_object_key = result.resources.get('tos_object_key', ve_config.tos_object_key)
132
+ ve_config.tos_object_url = result.resources.get('tos_url', ve_config.tos_object_url)
133
+ ve_config.tos_bucket = result.resources.get('tos_bucket', ve_config.tos_bucket)
134
+
135
+ # 回写Pipeline名称(如果VeCPCRBuilder更新了它)
136
+ if result.resources and result.resources.get('pipeline_name'):
137
+ ve_config.cp_pipeline_name = result.resources.get('pipeline_name')
138
+
139
+ agent_config.update_workflow_config("cloud", ve_config.to_persist_dict())
140
+ return True
141
+ else:
142
+ result = VeCPCRBuilderResult.from_dict(build_result)
143
+ error_msg = result.error_message or "构建失败"
144
+
145
+ # 构建失败时仍然回写已创建的资源信息
146
+ if result.resources:
147
+ ve_config.tos_object_key = result.resources.get('tos_object_key', ve_config.tos_object_key)
148
+ ve_config.tos_object_url = result.resources.get('tos_url', ve_config.tos_object_url)
149
+ agent_config.update_workflow_config("cloud", ve_config.to_persist_dict())
150
+
151
+ console.print(f"[red]❌ 构建失败: {error_msg}[/red]")
152
+ return False
153
+
154
+ except Exception as e:
155
+ console.print(f"[red]构建错误: {str(e)}[/red]")
156
+ return False
157
+
158
+ def deploy(self, config: Dict[str, Any]) -> bool:
159
+ """部署代理到云上环境 - 使用VeAgentkitRuntimeRunner"""
160
+ try:
161
+ console.print("[green]🚀 开始部署Agent...[/green]")
162
+
163
+ # 解析配置
164
+ ve_config = VeAgentkitConfig.from_dict(config)
165
+
166
+ # 检查镜像URL
167
+ if not ve_config.cr_image_full_url:
168
+ console.print("[yellow]⚠️ 未找到镜像URL,请先执行构建[/yellow]")
169
+ return False
170
+
171
+ # 获取公共配置
172
+ agent_config = get_config()
173
+ common_config = agent_config.get_common_config()
174
+
175
+ # 合并应用级和 Workflow 级环境变量
176
+ from agentkit.toolkit.config import merge_runtime_envs
177
+ merged_envs = merge_runtime_envs(common_config, ve_config.to_dict())
178
+
179
+ # 创建Runner配置
180
+ runner_config = {
181
+ "common_config": common_config.to_dict(),
182
+ "runtime_id": ve_config.runtime_id or AUTO_CREATE_VE,
183
+ "runtime_name": ve_config.runtime_name,
184
+ "runtime_role_name": ve_config.runtime_role_name,
185
+ "runtime_apikey": ve_config.runtime_apikey,
186
+ "runtime_apikey_name": ve_config.runtime_apikey_name,
187
+ "runtime_endpoint": ve_config.runtime_endpoint,
188
+ "runtime_envs": merged_envs,
189
+ "image_url": ve_config.cr_image_full_url
190
+ }
191
+
192
+ # 使用Runner部署
193
+ runner = VeAgentkitRuntimeRunner()
194
+ success, result = runner.deploy(runner_config)
195
+
196
+ if success:
197
+ # 更新部署时间戳
198
+ ve_config.runtime_id = result.get("runtime_id", ve_config.runtime_id)
199
+ ve_config.runtime_name = result.get("runtime_name", ve_config.runtime_name)
200
+ ve_config.runtime_endpoint = result.get("runtime_endpoint", ve_config.runtime_endpoint)
201
+ ve_config.runtime_apikey = result.get("runtime_apikey", ve_config.runtime_apikey)
202
+ ve_config.runtime_apikey_name = result.get("runtime_apikey_name", ve_config.runtime_apikey_name)
203
+ ve_config.runtime_role_name = result.get("runtime_role_name", ve_config.runtime_role_name)
204
+ ve_config.deploy_timestamp = datetime.now().isoformat()
205
+ agent_config.update_workflow_config("cloud", ve_config.to_persist_dict())
206
+ console.print(f"[green]✅ 部署完成: {ve_config.cr_image_full_url}[/green]")
207
+ console.print(f"[green]✅ Runtime ID: {ve_config.runtime_id}[/green]")
208
+ console.print(f"[green]✅ Runtime Endpoint: {ve_config.runtime_endpoint}[/green]")
209
+ return True
210
+ else:
211
+ console.print(f"[red]❌ 部署失败: {result.get('error', '未知错误')}[/red]")
212
+ return False
213
+
214
+ except Exception as e:
215
+ console.print(f"[red]❌ 部署失败: {str(e)}[/red]")
216
+ return False
217
+
218
+ def invoke(self, config: Dict[str, Any] = None, args: Dict[str, Any] = None) -> Tuple[bool, Any]:
219
+ """调用云上Runtime - 使用VeAgentkitRuntimeRunner"""
220
+ # 解析配置
221
+ ve_config = VeAgentkitConfig.from_dict(config)
222
+
223
+ # 检查配置
224
+ if not ve_config.runtime_id:
225
+ console.print(f"[red]❌ 未配置Runtime ID,请先执行deploy步骤[/red]")
226
+ return False, {"error": "未配置Runtime ID"}
227
+
228
+ try:
229
+ # 创建Runner配置
230
+ runner_config = {
231
+ "common_config": {},
232
+ "runtime_id": ve_config.runtime_id,
233
+ "runtime_endpoint": ve_config.runtime_endpoint,
234
+ "runtime_apikey": ve_config.runtime_apikey
235
+ }
236
+ payload = args.get("payload", {"prompt": "北京天气怎么样"})
237
+ if isinstance(payload, str):
238
+ payload = json.loads(payload)
239
+ headers = args.get("headers", {"user_id": "agentkit_user", "session_id": "agentkit_sample_session"})
240
+ if isinstance(headers, str):
241
+ headers = json.loads(headers)
242
+ # 使用Runner调用
243
+ runner = VeAgentkitRuntimeRunner()
244
+ success, result = runner.invoke(runner_config, payload, headers)
245
+
246
+ if success:
247
+ return True, result
248
+ else:
249
+ console.print(f"[red]❌ 云上调用失败: {result}[/red]")
250
+ return False, {"error": result}
251
+
252
+ except Exception as e:
253
+ console.print(f"[red]❌ 云上调用异常: {str(e)}[/red]")
254
+ return False, {"error": str(e)}
255
+
256
+
257
+ def status(self, config: VeAgentkitConfig) -> Dict[str, Any]:
258
+ """获取云上Runtime状态 - 使用VeAgentkitRuntimeRunner"""
259
+ # 解析配置
260
+ ve_config = VeAgentkitConfig.from_dict(config)
261
+
262
+ # 检查配置
263
+ if not ve_config.runtime_id:
264
+ console.print(f"[yellow]⚠️ 未配置Runtime ID[/yellow]")
265
+ return {"status": "not_deployed", "message": "未配置Runtime ID"}
266
+
267
+ console.print(f"[green]✅ Runtime ID: {ve_config.runtime_id}[/green]")
268
+
269
+ try:
270
+ # 创建Runner配置
271
+ runner_config = {
272
+ "common_config": {},
273
+ "runtime_id": ve_config.runtime_id,
274
+ "runtime_endpoint": ve_config.runtime_endpoint,
275
+ "runtime_apikey": ve_config.runtime_apikey
276
+ }
277
+
278
+ # 使用Runner获取状态
279
+ runner = VeAgentkitRuntimeRunner()
280
+ status_info = runner.status(runner_config)
281
+
282
+ # 控制台输出
283
+ if status_info.get("status") == "Ready":
284
+ console.print(f"[green]✅ Runtime状态为Ready, Endpoint: {status_info.get('endpoint')}[/green]")
285
+ else:
286
+ console.print(f"[yellow]当前Runtime状态: {status_info.get('status')},状态异常[/yellow]")
287
+
288
+ return status_info
289
+
290
+ except Exception as e:
291
+ console.print(f"[red]❌ 获取Runtime状态失败: {str(e)}[/red]")
292
+ return {"status": "error", "message": str(e)}
293
+
294
+ def stop(self, config: Dict[str, Any] = None) -> bool:
295
+ """停止工作流 - 使用VeAgentkitRuntimeRunner"""
296
+ if config is None:
297
+ config = get_config().get_workflow_config("cloud")
298
+ ve_config = VeAgentkitConfig.from_dict(config)
299
+
300
+ if not ve_config.runtime_id:
301
+ console.print("[yellow]⚠️ 未配置Runtime ID,无需停止[/yellow]")
302
+ return True
303
+
304
+ try:
305
+ console.print("[yellow]🛑 停止VeAgentkit Runtime...[/yellow]")
306
+
307
+ # 创建Runner配置
308
+ runner_config = {
309
+ "common_config": {},
310
+ "runtime_id": ve_config.runtime_id,
311
+ }
312
+
313
+ # 使用Runner停止
314
+ runner = VeAgentkitRuntimeRunner()
315
+ success = runner.stop(runner_config)
316
+
317
+ if success:
318
+ console.print("[green]✅ Runtime停止成功[/green]")
319
+ else:
320
+ console.print("[red]❌ Runtime停止失败[/red]")
321
+
322
+ return success
323
+
324
+ except Exception as e:
325
+ console.print(f"[red]❌ Runtime停止异常: {str(e)}[/red]")
326
+ return False
327
+
328
+ def destroy(self, config: Dict[str, Any] = None) -> bool:
329
+ """销毁工作流资源 - 使用VeAgentkitRuntimeRunner"""
330
+ try:
331
+ console.print("[red]🗑️ 销毁AgentKit相关资源...[/red]")
332
+
333
+ agent_config = get_config()
334
+ if config is None:
335
+ config = agent_config.get_workflow_config("cloud")
336
+
337
+ ve_config = VeAgentkitConfig.from_dict(config)
338
+
339
+ # 销毁Runtime
340
+ if ve_config.runtime_id:
341
+ try:
342
+ runner_config = {
343
+ "common_config": {},
344
+ "runtime_id": ve_config.runtime_id
345
+ }
346
+ runner = VeAgentkitRuntimeRunner()
347
+ runner.destroy(runner_config)
348
+ except Exception as e:
349
+ console.print(f"[yellow]⚠️ Runtime销毁失败: {str(e)}[/yellow]")
350
+
351
+ # 重置配置
352
+ ve_config.cr_image_full_url = None
353
+ ve_config.cp_pipeline_id = None
354
+ ve_config.build_timestamp = None
355
+ ve_config.deploy_timestamp = None
356
+ ve_config.tos_object_key = None
357
+ ve_config.tos_object_url = None
358
+ ve_config.runtime_id = ""
359
+ ve_config.runtime_endpoint = ""
360
+ ve_config.runtime_apikey = ""
361
+
362
+ agent_config.update_workflow_config("cloud", ve_config.to_persist_dict())
363
+
364
+ console.print("[green]✅ 资源已销毁[/green]")
365
+ return True
366
+
367
+ except Exception as e:
368
+ console.print(f"[red]❌ 销毁失败: {str(e)}[/red]")
369
+ return False
@@ -0,0 +1,17 @@
1
+ # Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from agentkit.tools.tools import AgentkitTools
16
+
17
+ __all__ = ["AgentkitTools"]
@@ -0,0 +1,106 @@
1
+ # Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from typing import Dict
16
+
17
+ from agentkit.client import BaseAgentkitClient
18
+
19
+ # 导入自动生成的类型
20
+ from agentkit.tools.tools_all_types import (
21
+ CreateToolRequest,
22
+ CreateToolResponse,
23
+ GetToolRequest,
24
+ GetToolResponse,
25
+ UpdateToolRequest,
26
+ UpdateToolResponse,
27
+ DeleteToolRequest,
28
+ DeleteToolResponse,
29
+ ListToolsRequest,
30
+ ListToolsResponse,
31
+ )
32
+
33
+
34
+ class AgentkitTools(BaseAgentkitClient):
35
+ """AgentKit Tools Management Service"""
36
+
37
+ # Define all API actions for this service
38
+ API_ACTIONS: Dict[str, str] = {
39
+ "CreateTool": "CreateTool",
40
+ "GetTool": "GetTool",
41
+ "UpdateTool": "UpdateTool",
42
+ "DeleteTool": "DeleteTool",
43
+ "ListTools": "ListTools",
44
+ }
45
+
46
+ def __init__(
47
+ self,
48
+ access_key: str = "",
49
+ secret_key: str = "",
50
+ region: str = "",
51
+ session_token: str = "",
52
+ ) -> None:
53
+ super().__init__(
54
+ access_key=access_key,
55
+ secret_key=secret_key,
56
+ region=region,
57
+ session_token=session_token,
58
+ service_name="tools",
59
+ )
60
+
61
+ def create(self, request: CreateToolRequest) -> CreateToolResponse:
62
+ """Create a new Tool on Volcengine."""
63
+ return self._invoke_api(
64
+ api_action="CreateTool",
65
+ request=request,
66
+ response_type=CreateToolResponse,
67
+ )
68
+
69
+ def get(self, request: GetToolRequest) -> GetToolResponse:
70
+ """Get details of a specific Tool from Volcengine."""
71
+ return self._invoke_api(
72
+ api_action="GetTool",
73
+ request=request,
74
+ response_type=GetToolResponse,
75
+ )
76
+
77
+ def update(self, request: UpdateToolRequest) -> UpdateToolResponse:
78
+ """Update an existing Tool on Volcengine."""
79
+ return self._invoke_api(
80
+ api_action="UpdateTool",
81
+ request=request,
82
+ response_type=UpdateToolResponse,
83
+ )
84
+
85
+ def delete(self, request: DeleteToolRequest) -> DeleteToolResponse:
86
+ """Delete a Tool on Volcengine."""
87
+ return self._invoke_api(
88
+ api_action="DeleteTool",
89
+ request=request,
90
+ response_type=DeleteToolResponse,
91
+ )
92
+
93
+ def list(self, request: ListToolsRequest) -> ListToolsResponse:
94
+ """List all Tools from Volcengine."""
95
+ return self._invoke_api(
96
+ api_action="ListTools",
97
+ request=request,
98
+ response_type=ListToolsResponse,
99
+ )
100
+
101
+
102
+ if __name__ == "__main__":
103
+ tool = AgentkitTools()
104
+ list_res = tool.list(ListToolsRequest())
105
+ for tool in list_res.tools:
106
+ print(tool)