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,23 @@
|
|
|
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 .base import Builder
|
|
17
|
+
from .local_docker_builder import LocalDockerBuilder, LocalDockerBuilderConfig
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
'Builder',
|
|
21
|
+
'LocalDockerBuilder',
|
|
22
|
+
'LocalDockerBuilderConfig'
|
|
23
|
+
]
|
|
@@ -0,0 +1,59 @@
|
|
|
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 abc import ABC, abstractmethod
|
|
16
|
+
from dataclasses import dataclass, field
|
|
17
|
+
from typing import Dict, Any, Optional, Tuple
|
|
18
|
+
import logging
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from agentkit.toolkit.config.config import get_global_config_file_path
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Builder(ABC):
|
|
26
|
+
|
|
27
|
+
def __init__(self):
|
|
28
|
+
self.logger = logging.getLogger(f"{__name__}.{self.__class__.__name__}")
|
|
29
|
+
# 设置工作目录:根据GLOBAL_CONFIG_FILE_PATH解析
|
|
30
|
+
self.workdir = self._get_workdir_from_config()
|
|
31
|
+
|
|
32
|
+
def _get_workdir_from_config(self) -> Path:
|
|
33
|
+
"""从全局配置文件路径解析工作目录"""
|
|
34
|
+
config_path = get_global_config_file_path()
|
|
35
|
+
|
|
36
|
+
if config_path:
|
|
37
|
+
# 提取GLOBAL_CONFIG_FILE_PATH的文件夹路径
|
|
38
|
+
path_obj = Path(config_path).expanduser()
|
|
39
|
+
if path_obj.is_file():
|
|
40
|
+
# 如果是文件路径,提取父目录
|
|
41
|
+
return path_obj.parent
|
|
42
|
+
else:
|
|
43
|
+
# 如果是目录路径,直接使用
|
|
44
|
+
return path_obj
|
|
45
|
+
else:
|
|
46
|
+
# 如果GLOBAL_CONFIG_FILE_PATH为空,使用当前工作目录
|
|
47
|
+
return Path.cwd()
|
|
48
|
+
|
|
49
|
+
@abstractmethod
|
|
50
|
+
def build(self, config: Dict[str, Any]) -> Tuple[bool, Dict[str, Any]]:
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
@abstractmethod
|
|
54
|
+
def check_artifact_exists(self, config: Dict[str, Any]) -> bool:
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
@abstractmethod
|
|
58
|
+
def remove_artifact(self, config: Dict[str, Any]) -> bool:
|
|
59
|
+
pass
|
|
@@ -0,0 +1,163 @@
|
|
|
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
|
+
Docker builder implementation
|
|
17
|
+
Provides local Docker environment build functionality
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
import logging
|
|
21
|
+
import os
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from typing import Dict, Any, Optional, Tuple, List
|
|
24
|
+
from dataclasses import dataclass, field
|
|
25
|
+
from datetime import datetime
|
|
26
|
+
from agentkit.toolkit.config import CommonConfig
|
|
27
|
+
from agentkit.toolkit.config.dataclass_utils import AutoSerializableMixin
|
|
28
|
+
from .base import Builder
|
|
29
|
+
from ..container import DockerManager, DockerfileRenderer
|
|
30
|
+
|
|
31
|
+
logger = logging.getLogger(__name__)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass
|
|
35
|
+
class LocalDockerBuilderConfig(AutoSerializableMixin):
|
|
36
|
+
"""Docker builder configuration"""
|
|
37
|
+
common_config: Optional[CommonConfig] = field(default=None, metadata={"system": True, "description": "Common configuration"})
|
|
38
|
+
image_name: str = field(default="", metadata={"description": "Image name"})
|
|
39
|
+
image_tag: str = field(default="latest", metadata={"description": "Image tag"})
|
|
40
|
+
dockerfile_path: str = field(default=".", metadata={"description": "Dockerfile directory path"})
|
|
41
|
+
dockerfile_name: str = field(default="Dockerfile", metadata={"description": "Dockerfile filename"})
|
|
42
|
+
template_dir: Optional[str] = field(default=None, metadata={"description": "Dockerfile template directory"})
|
|
43
|
+
template_name: str = field(default="Dockerfile.j2", metadata={"description": "Dockerfile template filename"})
|
|
44
|
+
|
|
45
|
+
@dataclass
|
|
46
|
+
class LocalDockerBuilderResult(AutoSerializableMixin):
|
|
47
|
+
"""Docker builder result"""
|
|
48
|
+
success: bool = field(default=False, metadata={"description": "Build success status"})
|
|
49
|
+
image_id: Optional[str] = field(default=None, metadata={"description": "Built image ID"})
|
|
50
|
+
build_logs: Optional[List[str]] = field(default=None, metadata={"description": "Build logs"})
|
|
51
|
+
build_timestamp: Optional[str] = field(default=None, metadata={"description": "Build timestamp"})
|
|
52
|
+
full_image_name: Optional[str] = field(default=None, metadata={"description": "Full image name"})
|
|
53
|
+
|
|
54
|
+
class LocalDockerBuilder(Builder):
|
|
55
|
+
"""Docker builder implementation"""
|
|
56
|
+
|
|
57
|
+
def __init__(self):
|
|
58
|
+
super().__init__()
|
|
59
|
+
self.docker_manager = DockerManager()
|
|
60
|
+
self.dockerfile_renderer = None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def build(self, config: Dict[str, Any]) -> Tuple[bool, Dict[str, Any]]:
|
|
64
|
+
"""Build Docker image"""
|
|
65
|
+
docker_config = LocalDockerBuilderConfig.from_dict(config)
|
|
66
|
+
|
|
67
|
+
common_config = None
|
|
68
|
+
if docker_config.common_config is not None:
|
|
69
|
+
common_config = CommonConfig.from_dict(docker_config.common_config)
|
|
70
|
+
|
|
71
|
+
if common_config is None:
|
|
72
|
+
return False, LocalDockerBuilderResult(success=False, build_logs=["Missing common configuration"]).to_dict()
|
|
73
|
+
|
|
74
|
+
# Check if Docker is available before attempting to build
|
|
75
|
+
docker_available, docker_message = self.docker_manager.is_docker_available()
|
|
76
|
+
if not docker_available:
|
|
77
|
+
logger.error(f"Docker availability check failed")
|
|
78
|
+
# Split multi-line error message into list for better display
|
|
79
|
+
error_lines = docker_message.split('\n')
|
|
80
|
+
return False, LocalDockerBuilderResult(
|
|
81
|
+
success=False,
|
|
82
|
+
build_logs=error_lines
|
|
83
|
+
).to_dict()
|
|
84
|
+
|
|
85
|
+
try:
|
|
86
|
+
template_dir = os.path.join(os.path.dirname(__file__), "..", "..", "resources", "templates")
|
|
87
|
+
try:
|
|
88
|
+
from agentkit.toolkit.integrations.container import DockerfileRenderer, DockerManager
|
|
89
|
+
except ImportError:
|
|
90
|
+
return False, LocalDockerBuilderResult(success=False, build_logs=["Missing Docker dependencies"]).to_dict()
|
|
91
|
+
|
|
92
|
+
renderer = DockerfileRenderer(template_dir)
|
|
93
|
+
context = {
|
|
94
|
+
"agent_module_path": os.path.splitext(common_config.entry_point)[0],
|
|
95
|
+
"python_version": common_config.python_version,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if common_config.dependencies_file:
|
|
99
|
+
# 确保dependencies_file存在,使用相对于构建上下文的路径
|
|
100
|
+
dependencies_file_path = self.workdir / common_config.dependencies_file
|
|
101
|
+
if not dependencies_file_path.exists():
|
|
102
|
+
dependencies_file_path.write_text("")
|
|
103
|
+
# 在Docker构建上下文中使用相对路径
|
|
104
|
+
context["dependencies_file"] = common_config.dependencies_file
|
|
105
|
+
|
|
106
|
+
# 使用父类的workdir作为基础路径
|
|
107
|
+
dockerfile_path = self.workdir / docker_config.dockerfile_name
|
|
108
|
+
renderer.render_dockerfile(
|
|
109
|
+
context=context,
|
|
110
|
+
template_name=docker_config.template_name,
|
|
111
|
+
output_path=str(dockerfile_path)
|
|
112
|
+
)
|
|
113
|
+
image_name = f"{docker_config.image_name or 'agentkit-app'}"
|
|
114
|
+
image_tag = f"{docker_config.image_tag or 'latest'}"
|
|
115
|
+
|
|
116
|
+
success, build_logs, image_id = self.docker_manager.build_image(
|
|
117
|
+
dockerfile_path=str(self.workdir),
|
|
118
|
+
image_name=image_name,
|
|
119
|
+
image_tag=image_tag,
|
|
120
|
+
build_args={}
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
if success:
|
|
124
|
+
return True, LocalDockerBuilderResult(
|
|
125
|
+
success=True,
|
|
126
|
+
image_id=image_id,
|
|
127
|
+
full_image_name=f"{image_name}:{image_tag}",
|
|
128
|
+
build_timestamp=datetime.now().isoformat(),
|
|
129
|
+
build_logs=build_logs,
|
|
130
|
+
).to_dict()
|
|
131
|
+
else:
|
|
132
|
+
return False, LocalDockerBuilderResult(
|
|
133
|
+
success=False,
|
|
134
|
+
build_logs=build_logs,
|
|
135
|
+
build_timestamp=datetime.now().isoformat()
|
|
136
|
+
).to_dict()
|
|
137
|
+
|
|
138
|
+
except Exception as e:
|
|
139
|
+
return False, LocalDockerBuilderResult(
|
|
140
|
+
success=False,
|
|
141
|
+
build_logs=[str(e)],
|
|
142
|
+
build_timestamp=datetime.now().isoformat()
|
|
143
|
+
).to_dict()
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def check_artifact_exists(self, config: Dict[str, Any]) -> bool:
|
|
147
|
+
"""Check if build artifact exists"""
|
|
148
|
+
try:
|
|
149
|
+
exists, image_info, actual_image_id = self.docker_manager.check_image_exists(
|
|
150
|
+
config['full_image_name'], None
|
|
151
|
+
)
|
|
152
|
+
return exists
|
|
153
|
+
except Exception as e:
|
|
154
|
+
self.logger.error(f"Error checking image existence: {str(e)}")
|
|
155
|
+
return False
|
|
156
|
+
|
|
157
|
+
def remove_artifact(self, config: Dict[str, Any]) -> bool:
|
|
158
|
+
"""Remove Docker image"""
|
|
159
|
+
try:
|
|
160
|
+
return self.docker_manager.remove_image(config['full_image_name'], force=True)
|
|
161
|
+
except Exception as e:
|
|
162
|
+
self.logger.error(f"Error removing image: {str(e)}")
|
|
163
|
+
return False
|