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,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