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.
- agentkit/__init__.py +23 -0
- agentkit/apps/__init__.py +58 -0
- agentkit/apps/a2a_app/__init__.py +13 -0
- agentkit/apps/a2a_app/a2a_app.py +134 -0
- agentkit/apps/a2a_app/telemetry.py +119 -0
- agentkit/apps/agent_server_app/__init__.py +13 -0
- agentkit/apps/agent_server_app/agent_server_app.py +85 -0
- agentkit/apps/base_app.py +20 -0
- agentkit/apps/mcp_app/__init__.py +13 -0
- agentkit/apps/mcp_app/mcp_app.py +150 -0
- agentkit/apps/mcp_app/telemetry.py +115 -0
- agentkit/apps/simple_app/__init__.py +13 -0
- agentkit/apps/simple_app/simple_app.py +94 -0
- agentkit/apps/simple_app/simple_app_handlers.py +325 -0
- agentkit/apps/simple_app/telemetry.py +124 -0
- agentkit/apps/utils.py +45 -0
- agentkit/client/__init__.py +26 -0
- agentkit/client/base_client.py +219 -0
- agentkit/identity/__init__.py +13 -0
- agentkit/identity/auth.py +70 -0
- agentkit/knowledge/__init__.py +47 -0
- agentkit/knowledge/knowledge.py +203 -0
- agentkit/knowledge/knowledge_all_types.py +191 -0
- agentkit/mcp/__init__.py +79 -0
- agentkit/mcp/mcp.py +294 -0
- agentkit/mcp/mcp_all_types.py +1212 -0
- agentkit/memory/__init__.py +71 -0
- agentkit/memory/memory.py +236 -0
- agentkit/memory/memory_all_types.py +358 -0
- agentkit/runtime/__init__.py +13 -0
- agentkit/runtime/runtime.py +191 -0
- agentkit/runtime/runtime_all_types.py +624 -0
- agentkit/runtime/runtime_v1.py +178 -0
- agentkit/runtime/types.py +188 -0
- agentkit/toolkit/__init__.py +13 -0
- agentkit/toolkit/cli/__init__.py +13 -0
- agentkit/toolkit/cli/__main__.py +7 -0
- agentkit/toolkit/cli/cli.py +97 -0
- agentkit/toolkit/cli/cli_build.py +53 -0
- agentkit/toolkit/cli/cli_config.py +170 -0
- agentkit/toolkit/cli/cli_deploy.py +52 -0
- agentkit/toolkit/cli/cli_destroy.py +53 -0
- agentkit/toolkit/cli/cli_init.py +364 -0
- agentkit/toolkit/cli/cli_invoke.py +168 -0
- agentkit/toolkit/cli/cli_launch.py +34 -0
- agentkit/toolkit/cli/cli_status.py +53 -0
- agentkit/toolkit/cli/cli_version.py +87 -0
- agentkit/toolkit/cli/utils.py +47 -0
- agentkit/toolkit/config/__init__.py +52 -0
- agentkit/toolkit/config/auto_prompt.py +752 -0
- agentkit/toolkit/config/build_config.py +28 -0
- agentkit/toolkit/config/common_config.py +18 -0
- agentkit/toolkit/config/config.py +306 -0
- agentkit/toolkit/config/config_handler.py +331 -0
- agentkit/toolkit/config/config_manager.py +48 -0
- agentkit/toolkit/config/config_validator.py +121 -0
- agentkit/toolkit/config/constants.py +18 -0
- agentkit/toolkit/config/dataclass_utils.py +153 -0
- agentkit/toolkit/config/deploy_config.py +1 -0
- agentkit/toolkit/config/utils.py +57 -0
- agentkit/toolkit/config/workflow_configs.py +149 -0
- agentkit/toolkit/consts.py +1 -0
- agentkit/toolkit/core/__init__.py +13 -0
- agentkit/toolkit/core/build/__init__.py +13 -0
- agentkit/toolkit/core/build/base_builder.py +6 -0
- agentkit/toolkit/core/build/cloud_builder.py +0 -0
- agentkit/toolkit/core/build/local_builder.py +0 -0
- agentkit/toolkit/core/deploy/__init__.py +13 -0
- agentkit/toolkit/core/deploy/base_deployer.py +6 -0
- agentkit/toolkit/core/deploy/cloud_deployer.py +0 -0
- agentkit/toolkit/core/deploy/local_deployer.py +0 -0
- agentkit/toolkit/integrations/__init__.py +17 -0
- agentkit/toolkit/integrations/builder/__init__.py +23 -0
- agentkit/toolkit/integrations/builder/base.py +59 -0
- agentkit/toolkit/integrations/builder/local_docker_builder.py +163 -0
- agentkit/toolkit/integrations/builder/ve_core_pipeline_builder.py +853 -0
- agentkit/toolkit/integrations/container.py +843 -0
- agentkit/toolkit/integrations/runner/__init__.py +26 -0
- agentkit/toolkit/integrations/runner/base.py +222 -0
- agentkit/toolkit/integrations/runner/local_docker_runner.py +407 -0
- agentkit/toolkit/integrations/runner/ve_agentkit_runner.py +665 -0
- agentkit/toolkit/integrations/services/__init__.py +26 -0
- agentkit/toolkit/integrations/services/cr_service.py +449 -0
- agentkit/toolkit/integrations/services/tos_service.py +291 -0
- agentkit/toolkit/integrations/utils/__init__.py +21 -0
- agentkit/toolkit/integrations/utils/project_archiver.py +276 -0
- agentkit/toolkit/integrations/ve_code_pipeline.py +643 -0
- agentkit/toolkit/integrations/ve_cr.py +385 -0
- agentkit/toolkit/integrations/ve_iam.py +210 -0
- agentkit/toolkit/resources/samples/basic.py +79 -0
- agentkit/toolkit/resources/samples/basic_stream.py +100 -0
- agentkit/toolkit/resources/samples/customer_support_assistant.py +3 -0
- agentkit/toolkit/resources/samples/financial_analyst.py +140 -0
- agentkit/toolkit/resources/samples/simple_a2a_veadk.py +32 -0
- agentkit/toolkit/resources/samples/simple_app_veadk.py +55 -0
- agentkit/toolkit/resources/samples/simple_mcp_veadk.py +50 -0
- agentkit/toolkit/resources/templates/Dockerfile.j2 +27 -0
- agentkit/toolkit/resources/templates/code-pipeline-tos-cr-step.j2 +52 -0
- agentkit/toolkit/workflows/__init__.py +27 -0
- agentkit/toolkit/workflows/base.py +87 -0
- agentkit/toolkit/workflows/hybird_local_ve_workflow_v1.py +381 -0
- agentkit/toolkit/workflows/local_workflow_v1.py +262 -0
- agentkit/toolkit/workflows/ve_agentkit_workflow.py +369 -0
- agentkit/tools/__init__.py +17 -0
- agentkit/tools/tools.py +106 -0
- agentkit/tools/tools_all_types.py +337 -0
- agentkit/utils/__init__.py +41 -0
- agentkit/utils/credential.py +44 -0
- agentkit/utils/logging_config.py +366 -0
- agentkit/utils/misc.py +70 -0
- agentkit/utils/request.py +59 -0
- agentkit/utils/template_utils.py +256 -0
- agentkit/utils/ve_sign.py +247 -0
- agentkit/version.py +15 -0
- agentkit_sdk_python-0.1.5.dist-info/METADATA +262 -0
- agentkit_sdk_python-0.1.5.dist-info/RECORD +120 -0
- agentkit_sdk_python-0.1.5.dist-info/WHEEL +5 -0
- agentkit_sdk_python-0.1.5.dist-info/entry_points.txt +2 -0
- agentkit_sdk_python-0.1.5.dist-info/licenses/LICENSE +201 -0
- agentkit_sdk_python-0.1.5.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,168 @@
|
|
|
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
|
+
"""AgentKit CLI - Invoke command implementation."""
|
|
16
|
+
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Optional, Any
|
|
19
|
+
import json
|
|
20
|
+
import typer
|
|
21
|
+
from rich.console import Console
|
|
22
|
+
from agentkit.toolkit.config import get_config
|
|
23
|
+
|
|
24
|
+
# Note: 不要在文件开头导很重的包,不然会导致命令很卡(import包很慢)
|
|
25
|
+
|
|
26
|
+
console = Console()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def invoke_command(
|
|
30
|
+
config_file: Path = typer.Option("agentkit.yaml", help="Configuration file"),
|
|
31
|
+
message: str = typer.Argument(None, help="Simple message to send to agent"),
|
|
32
|
+
payload: str = typer.Option(
|
|
33
|
+
None, "--payload", "-p", help="JSON payload to send (advanced option)"
|
|
34
|
+
),
|
|
35
|
+
headers: str = typer.Option(
|
|
36
|
+
None, "--headers", "-h", help="JSON headers for request (advanced option)"
|
|
37
|
+
),
|
|
38
|
+
apikey: str = typer.Option(
|
|
39
|
+
None, "--apikey", "-ak", help="API key for authentication"
|
|
40
|
+
),
|
|
41
|
+
) -> Any:
|
|
42
|
+
"""Send a test request to deployed Agent.
|
|
43
|
+
|
|
44
|
+
Examples:
|
|
45
|
+
# Simple message
|
|
46
|
+
agentkit invoke "今天天气如何?"
|
|
47
|
+
|
|
48
|
+
# Custom payload
|
|
49
|
+
agentkit invoke --payload '{"prompt": "杭州天气?"}'
|
|
50
|
+
|
|
51
|
+
# With custom headers
|
|
52
|
+
agentkit invoke --payload '{"prompt": "杭州天气?"}' --headers '{"user_id": "test123"}'
|
|
53
|
+
"""
|
|
54
|
+
from agentkit.toolkit.workflows import WORKFLOW_REGISTRY, Workflow
|
|
55
|
+
console.print("[cyan]Invoking agent...[/cyan]")
|
|
56
|
+
|
|
57
|
+
# 验证参数:message和payload不能同时提供
|
|
58
|
+
if message and payload:
|
|
59
|
+
console.print("[red]Error: Cannot specify both message and payload. Use either message or --payload.[/red]")
|
|
60
|
+
raise typer.Exit(1)
|
|
61
|
+
|
|
62
|
+
# 验证参数:必须提供message或payload
|
|
63
|
+
if not message and not payload:
|
|
64
|
+
console.print("[red]Error: Must provide either a message or --payload option.[/red]")
|
|
65
|
+
raise typer.Exit(1)
|
|
66
|
+
|
|
67
|
+
# 处理payload
|
|
68
|
+
if message:
|
|
69
|
+
# 简单消息模式:自动组织为payload
|
|
70
|
+
final_payload = {"prompt": message}
|
|
71
|
+
console.print(f"[blue]Using simple message mode: {message}[/blue]")
|
|
72
|
+
else:
|
|
73
|
+
# 高级模式:使用用户提供的payload
|
|
74
|
+
try:
|
|
75
|
+
final_payload = json.loads(payload) if isinstance(payload, str) else payload
|
|
76
|
+
console.print(f"[blue]Using custom payload: {final_payload}[/blue]")
|
|
77
|
+
except json.JSONDecodeError as e:
|
|
78
|
+
console.print(f"[red]Error: Invalid JSON payload: {e}[/red]")
|
|
79
|
+
raise typer.Exit(1)
|
|
80
|
+
|
|
81
|
+
# 处理headers
|
|
82
|
+
final_headers = {"user_id": "agentkit_user", "session_id": "agentkit_sample_session"}
|
|
83
|
+
if headers:
|
|
84
|
+
try:
|
|
85
|
+
final_headers = json.loads(headers) if isinstance(headers, str) else headers
|
|
86
|
+
console.print(f"[blue]Using custom headers: {final_headers}[/blue]")
|
|
87
|
+
except json.JSONDecodeError as e:
|
|
88
|
+
console.print(f"[red]Error: Invalid JSON headers: {e}[/red]")
|
|
89
|
+
raise typer.Exit(1)
|
|
90
|
+
else:
|
|
91
|
+
console.print(f"[blue]Using default headers: {final_headers}[/blue]")
|
|
92
|
+
|
|
93
|
+
config = get_config(config_path=config_file)
|
|
94
|
+
common_config = config.get_common_config()
|
|
95
|
+
|
|
96
|
+
workflow_name = common_config.launch_type
|
|
97
|
+
if workflow_name not in WORKFLOW_REGISTRY:
|
|
98
|
+
console.print(f"[red]Error: Unknown workflow type '{workflow_name}'[/red]")
|
|
99
|
+
raise typer.Exit(1)
|
|
100
|
+
|
|
101
|
+
workflow_config = config.get_workflow_config(workflow_name)
|
|
102
|
+
|
|
103
|
+
workflow: Workflow = WORKFLOW_REGISTRY[workflow_name]()
|
|
104
|
+
success, response = workflow.invoke(workflow_config, {
|
|
105
|
+
"payload": final_payload,
|
|
106
|
+
"headers": final_headers,
|
|
107
|
+
"apikey": apikey
|
|
108
|
+
})
|
|
109
|
+
if not success:
|
|
110
|
+
raise typer.Exit(1)
|
|
111
|
+
|
|
112
|
+
console.print("[green]✅ Invocation successful[/green]")
|
|
113
|
+
|
|
114
|
+
# 处理流式响应(生成器)
|
|
115
|
+
if hasattr(response, '__iter__') and not isinstance(response, (dict, str, list)):
|
|
116
|
+
console.print("[cyan]📡 Streaming response detected...[/cyan]\n")
|
|
117
|
+
result_list = []
|
|
118
|
+
complete_text = []
|
|
119
|
+
|
|
120
|
+
for event in response:
|
|
121
|
+
result_list.append(event)
|
|
122
|
+
|
|
123
|
+
# 如果是字符串且以 "data: " 开头,尝试解析(fallback处理)
|
|
124
|
+
if isinstance(event, str):
|
|
125
|
+
if event.strip().startswith("data: "):
|
|
126
|
+
try:
|
|
127
|
+
json_str = event.strip()[6:].strip() # 移除 "data: " 前缀
|
|
128
|
+
event = json.loads(json_str)
|
|
129
|
+
except json.JSONDecodeError:
|
|
130
|
+
# 解析失败,跳过此事件
|
|
131
|
+
continue
|
|
132
|
+
else:
|
|
133
|
+
# 不是 SSE 格式的字符串,跳过
|
|
134
|
+
continue
|
|
135
|
+
|
|
136
|
+
# 解析事件内容
|
|
137
|
+
if isinstance(event, dict):
|
|
138
|
+
# 提取文本内容
|
|
139
|
+
content = event.get("content", {})
|
|
140
|
+
part = event.get("partial", False)
|
|
141
|
+
if part and isinstance(content, dict):
|
|
142
|
+
parts = content.get("parts", [])
|
|
143
|
+
for part in parts:
|
|
144
|
+
if isinstance(part, dict) and "text" in part:
|
|
145
|
+
text = part["text"]
|
|
146
|
+
complete_text.append(text)
|
|
147
|
+
console.print(text, end="", style="green")
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
# 显示错误信息
|
|
151
|
+
if "error" in event:
|
|
152
|
+
console.print(f"\n[red]Error: {event['error']}[/red]")
|
|
153
|
+
|
|
154
|
+
# 显示完整响应
|
|
155
|
+
if complete_text:
|
|
156
|
+
console.print("\n\n[cyan]━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[/cyan]")
|
|
157
|
+
console.print(f"[cyan]📝 Complete response:[/cyan] {''.join(complete_text)}")
|
|
158
|
+
|
|
159
|
+
return str(result_list)
|
|
160
|
+
|
|
161
|
+
# 处理非流式响应
|
|
162
|
+
console.print("[cyan]📝 Response:[/cyan]")
|
|
163
|
+
if isinstance(response, dict):
|
|
164
|
+
console.print(json.dumps(response, indent=2, ensure_ascii=False))
|
|
165
|
+
else:
|
|
166
|
+
console.print(response)
|
|
167
|
+
|
|
168
|
+
return str(response)
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
"""AgentKit CLI - Launch command implementation."""
|
|
16
|
+
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
import typer
|
|
19
|
+
from rich.console import Console
|
|
20
|
+
from agentkit.toolkit.cli.cli_build import build_command
|
|
21
|
+
from agentkit.toolkit.cli.cli_deploy import deploy_command
|
|
22
|
+
|
|
23
|
+
# Note: 不要在文件开头导很重的包,不然会导致命令很卡(import包很慢)
|
|
24
|
+
|
|
25
|
+
console = Console()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def launch_command(
|
|
29
|
+
config_file: Path = typer.Option("agentkit.yaml", help="Configuration file"),
|
|
30
|
+
):
|
|
31
|
+
"""Build and deploy in one command."""
|
|
32
|
+
console.print("[green]Launching agent...[/green]")
|
|
33
|
+
build_command(config_file=config_file)
|
|
34
|
+
deploy_command(config_file=config_file)
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
"""AgentKit CLI - Status command implementation."""
|
|
16
|
+
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
import typer
|
|
19
|
+
from rich.console import Console
|
|
20
|
+
from agentkit.toolkit.config import get_config
|
|
21
|
+
|
|
22
|
+
# Note: 不要在文件开头导很重的包,不然会导致命令很卡(import包很慢)
|
|
23
|
+
|
|
24
|
+
console = Console()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def status_command(
|
|
28
|
+
config_file: Path = typer.Option("agentkit.yaml", help="Configuration file"),
|
|
29
|
+
):
|
|
30
|
+
"""Show current status of the agent runtime."""
|
|
31
|
+
from agentkit.toolkit.workflows import WORKFLOW_REGISTRY
|
|
32
|
+
try:
|
|
33
|
+
config = get_config(config_path=config_file)
|
|
34
|
+
common_config = config.get_common_config()
|
|
35
|
+
workflow_type = common_config.launch_type
|
|
36
|
+
|
|
37
|
+
if workflow_type not in WORKFLOW_REGISTRY:
|
|
38
|
+
console.print(f"[red]Error: Unknown workflow type '{workflow_type}'[/red]")
|
|
39
|
+
raise typer.Exit(1)
|
|
40
|
+
|
|
41
|
+
workflow = WORKFLOW_REGISTRY[workflow_type]()
|
|
42
|
+
workflow_config = config.get_workflow_config(workflow_type)
|
|
43
|
+
status_result = workflow.status(workflow_config)
|
|
44
|
+
|
|
45
|
+
if isinstance(status_result, dict) and status_result.get('error'):
|
|
46
|
+
console.print(f"[red]Status query failed: {status_result['error']}[/red]")
|
|
47
|
+
raise typer.Exit(1)
|
|
48
|
+
|
|
49
|
+
console.print(status_result)
|
|
50
|
+
|
|
51
|
+
except Exception as e:
|
|
52
|
+
console.print(f"[red]Status query failed: {e}[/red]")
|
|
53
|
+
raise typer.Exit(1)
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
"""AgentKit CLI - Version command implementation."""
|
|
16
|
+
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from importlib.metadata import version as get_version, PackageNotFoundError
|
|
19
|
+
import sys
|
|
20
|
+
from rich.panel import Panel
|
|
21
|
+
from rich.console import Console
|
|
22
|
+
|
|
23
|
+
# Note: 不要在文件开头导很重的包,不然会导致命令很卡(import包很慢)
|
|
24
|
+
|
|
25
|
+
# Python 3.11+ has tomllib, older versions need tomli
|
|
26
|
+
if sys.version_info >= (3, 11):
|
|
27
|
+
import tomllib
|
|
28
|
+
else:
|
|
29
|
+
try:
|
|
30
|
+
import tomli as tomllib
|
|
31
|
+
except ImportError:
|
|
32
|
+
tomllib = None
|
|
33
|
+
|
|
34
|
+
console = Console()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def get_package_version() -> str:
|
|
38
|
+
"""Get package version from installed package or pyproject.toml."""
|
|
39
|
+
# Try to get version from installed package
|
|
40
|
+
try:
|
|
41
|
+
return get_version("agentkit-sdk-python")
|
|
42
|
+
except PackageNotFoundError:
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
# Fallback: read from pyproject.toml using toml parser
|
|
46
|
+
if tomllib is not None:
|
|
47
|
+
try:
|
|
48
|
+
# Find pyproject.toml in the package directory
|
|
49
|
+
current_file = Path(__file__)
|
|
50
|
+
# Go up from agentkit/toolkit/cli/cli.py to workspace root
|
|
51
|
+
pyproject_path = current_file.parent.parent.parent.parent / "pyproject.toml"
|
|
52
|
+
|
|
53
|
+
if pyproject_path.exists():
|
|
54
|
+
with open(pyproject_path, "rb") as f:
|
|
55
|
+
data = tomllib.load(f)
|
|
56
|
+
return data.get("project", {}).get("version", "unknown")
|
|
57
|
+
except Exception:
|
|
58
|
+
pass
|
|
59
|
+
|
|
60
|
+
# Last resort: parse pyproject.toml manually for version line
|
|
61
|
+
try:
|
|
62
|
+
current_file = Path(__file__)
|
|
63
|
+
pyproject_path = current_file.parent.parent.parent.parent / "pyproject.toml"
|
|
64
|
+
|
|
65
|
+
if pyproject_path.exists():
|
|
66
|
+
with open(pyproject_path, "r") as f:
|
|
67
|
+
for line in f:
|
|
68
|
+
if line.strip().startswith("version"):
|
|
69
|
+
# Parse line like: version = "0.0.7.34"
|
|
70
|
+
parts = line.split("=")
|
|
71
|
+
if len(parts) == 2:
|
|
72
|
+
version_str = parts[1].strip().strip('"').strip("'")
|
|
73
|
+
return version_str
|
|
74
|
+
except Exception:
|
|
75
|
+
pass
|
|
76
|
+
|
|
77
|
+
return "unknown"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def version_command():
|
|
81
|
+
"""Show AgentKit version information."""
|
|
82
|
+
pkg_version = get_package_version()
|
|
83
|
+
console.print(Panel(
|
|
84
|
+
f"[bold cyan]AgentKit SDK[/bold cyan]\n[green]Version: {pkg_version}[/green]",
|
|
85
|
+
title="📦 Version Info",
|
|
86
|
+
border_style="cyan"
|
|
87
|
+
))
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from typing import Literal, get_args, get_origin
|
|
2
|
+
|
|
3
|
+
from InquirerPy import resolver
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def prompt_base_model(model: type[BaseModel]) -> dict:
|
|
8
|
+
prompts = []
|
|
9
|
+
|
|
10
|
+
for field_name, model_field in model.model_fields.items():
|
|
11
|
+
if get_origin(model_field.annotation) == Literal:
|
|
12
|
+
prompts.append(
|
|
13
|
+
{
|
|
14
|
+
"type": "list",
|
|
15
|
+
"name": field_name,
|
|
16
|
+
"default": model_field.default if model_field.default else "",
|
|
17
|
+
"message": model_field.description
|
|
18
|
+
if model_field.description
|
|
19
|
+
else field_name,
|
|
20
|
+
"choices": list(get_args(model_field.annotation)),
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
elif model_field.annotation is bool:
|
|
24
|
+
prompts.append(
|
|
25
|
+
{
|
|
26
|
+
"type": "confirm",
|
|
27
|
+
"name": field_name,
|
|
28
|
+
"default": model_field.default if model_field.default else False,
|
|
29
|
+
"message": model_field.description
|
|
30
|
+
if model_field.description
|
|
31
|
+
else field_name,
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
else:
|
|
35
|
+
prompts.append(
|
|
36
|
+
{
|
|
37
|
+
"type": "input",
|
|
38
|
+
"name": field_name,
|
|
39
|
+
"default": str(model_field.default) if model_field.default else "",
|
|
40
|
+
"message": model_field.description
|
|
41
|
+
if model_field.description
|
|
42
|
+
else field_name,
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
responses = resolver.prompt(prompts)
|
|
47
|
+
return responses
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
|
|
16
|
+
from .config import (
|
|
17
|
+
AgentkitConfigManager,
|
|
18
|
+
CommonConfig,
|
|
19
|
+
ConfigUpdateResult,
|
|
20
|
+
get_config,
|
|
21
|
+
create_config_update_result,
|
|
22
|
+
set_global_config_file_path,
|
|
23
|
+
get_global_config_file_path,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
from .workflow_configs import (
|
|
27
|
+
LocalDockerConfig_v1,
|
|
28
|
+
HybridVeAgentkitConfig_v1,
|
|
29
|
+
VeAgentkitConfig,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
from .utils import is_valid_config, is_invalid_config, merge_runtime_envs
|
|
33
|
+
from .constants import *
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"AgentkitConfigManager",
|
|
37
|
+
"CommonConfig",
|
|
38
|
+
"ConfigUpdateResult",
|
|
39
|
+
"get_config",
|
|
40
|
+
"create_config_update_result",
|
|
41
|
+
"AUTO_CREATE_VE",
|
|
42
|
+
"DEFAULT_WORKSPACE_NAME",
|
|
43
|
+
"DEFAULT_CR_NAMESPACE",
|
|
44
|
+
"DEFAULT_IMAGE_TAG",
|
|
45
|
+
"is_valid_config",
|
|
46
|
+
"is_invalid_config",
|
|
47
|
+
"merge_runtime_envs",
|
|
48
|
+
# Workflow 配置类
|
|
49
|
+
"LocalDockerConfig_v1",
|
|
50
|
+
"HybridVeAgentkitConfig_v1",
|
|
51
|
+
"VeAgentkitConfig",
|
|
52
|
+
]
|