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,48 @@
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
+ import yaml
18
+ from pydantic import BaseModel
19
+
20
+ from agentkit.toolkit.config.build_config import BuildConfig
21
+ from agentkit.toolkit.config.deploy_config import DeployConfig
22
+ from agentkit.toolkit.consts import DEFAULT_CONFIG_FILENAME
23
+
24
+
25
+ # class ConfigManager(BaseModel):
26
+ # """Config manager for AgentKit-related configurations."""
27
+
28
+ # build_config: BuildConfig
29
+
30
+ # deploy_config: DeployConfig
31
+
32
+ # def dump(self, filename: str = DEFAULT_CONFIG_FILENAME):
33
+ # """Dump self attributes to a `.yaml` file."""
34
+ # data = self.model_dump()
35
+ # yaml_str = yaml.dump(data=data)
36
+
37
+ # with open(filename, "w", encoding="utf-8") as f:
38
+ # f.write(yaml_str)
39
+
40
+ # @staticmethod
41
+ # def load(filename: str = DEFAULT_CONFIG_FILENAME) -> "ConfigManager":
42
+ # with open(filename, "r", encoding="utf-8") as f:
43
+ # data = f.read()
44
+
45
+ # if data:
46
+ # return ConfigManager(**json.loads(data))
47
+ # else:
48
+ # raise ValueError("Empty config file content!")
@@ -0,0 +1,121 @@
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
+ """Configuration validation utilities."""
16
+
17
+ import re
18
+ from typing import List, Any
19
+ from dataclasses import fields
20
+
21
+ from agentkit.toolkit.config.config import CommonConfig
22
+
23
+
24
+ class ConfigValidator:
25
+ """配置验证器"""
26
+
27
+ @staticmethod
28
+ def validate_common_config(config: CommonConfig) -> List[str]:
29
+ """验证通用配置,返回错误列表
30
+
31
+ Args:
32
+ config: CommonConfig 实例
33
+
34
+ Returns:
35
+ 错误消息列表,如果为空则验证通过
36
+ """
37
+ errors = []
38
+
39
+ # 遍历所有字段并应用验证规则
40
+ for field in fields(CommonConfig):
41
+ # 跳过内部字段
42
+ if field.name.startswith('_'):
43
+ continue
44
+
45
+ validation = field.metadata.get('validation', {})
46
+ value = getattr(config, field.name)
47
+
48
+ # 检查必填项
49
+ if validation.get('required') and (not value or (isinstance(value, str) and not value.strip())):
50
+ desc = field.metadata.get('description', field.name)
51
+ errors.append(f"{desc} 是必填项")
52
+ continue
53
+
54
+ # 检查正则表达式模式
55
+ pattern = validation.get('pattern')
56
+ if pattern and value and isinstance(value, str):
57
+ if not re.match(pattern, value):
58
+ desc = field.metadata.get('description', field.name)
59
+ msg = validation.get('message', '格式不正确')
60
+ errors.append(f"{desc}: {msg}")
61
+
62
+ # 检查选项约束
63
+ choices = field.metadata.get('choices')
64
+ if choices and value:
65
+ valid_values = []
66
+ if isinstance(choices, list):
67
+ if choices and isinstance(choices[0], dict):
68
+ valid_values = [c['value'] for c in choices]
69
+ else:
70
+ valid_values = choices
71
+
72
+ if valid_values and value not in valid_values:
73
+ desc = field.metadata.get('description', field.name)
74
+ errors.append(f"{desc} 的值必须是以下之一: {', '.join(map(str, valid_values))}")
75
+
76
+ return errors
77
+
78
+ @staticmethod
79
+ def validate_field_value(field_name: str, value: Any, field_metadata: dict) -> List[str]:
80
+ """验证单个字段的值
81
+
82
+ Args:
83
+ field_name: 字段名称
84
+ value: 字段值
85
+ field_metadata: 字段的元数据
86
+
87
+ Returns:
88
+ 错误消息列表
89
+ """
90
+ errors = []
91
+ validation = field_metadata.get('validation', {})
92
+
93
+ # 检查必填项
94
+ if validation.get('required') and (not value or (isinstance(value, str) and not value.strip())):
95
+ desc = field_metadata.get('description', field_name)
96
+ errors.append(f"{desc} 是必填项")
97
+ return errors
98
+
99
+ # 检查正则表达式模式
100
+ pattern = validation.get('pattern')
101
+ if pattern and value and isinstance(value, str):
102
+ if not re.match(pattern, value):
103
+ desc = field_metadata.get('description', field_name)
104
+ msg = validation.get('message', '格式不正确')
105
+ errors.append(f"{desc}: {msg}")
106
+
107
+ # 检查选项约束
108
+ choices = field_metadata.get('choices')
109
+ if choices and value:
110
+ valid_values = []
111
+ if isinstance(choices, list):
112
+ if choices and isinstance(choices[0], dict):
113
+ valid_values = [c['value'] for c in choices]
114
+ else:
115
+ valid_values = choices
116
+
117
+ if valid_values and value not in valid_values:
118
+ desc = field_metadata.get('description', field_name)
119
+ errors.append(f"{desc} 的值必须是以下之一: {', '.join(map(str, valid_values))}")
120
+
121
+ return errors
@@ -0,0 +1,18 @@
1
+ """
2
+ VeAgentkit 常量定义模块
3
+
4
+ 这个模块定义了在整个VeAgentkit项目中使用的通用常量,
5
+ 确保各个模块之间的一致性。
6
+ """
7
+
8
+ # 自动创建资源的标识符
9
+ AUTO_CREATE_VE = "Auto"
10
+ DEFAULT_WORKSPACE_NAME = "agentkit-cli-workspace"
11
+ DEFAULT_CR_NAMESPACE = "agentkit"
12
+
13
+ DEFAULT_IMAGE_TAG = "{{timestamp}}"
14
+
15
+
16
+ # 其他通用常量可以在这里添加
17
+ # DEFAULT_REGION = "cn-beijing"
18
+ # DEFAULT_TIMEOUT = 300
@@ -0,0 +1,153 @@
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 dataclasses import asdict, fields
17
+ from typing import Any, Dict, Type, TypeVar, get_type_hints
18
+
19
+ T = TypeVar('T')
20
+
21
+ class DataclassSerializer:
22
+
23
+ @staticmethod
24
+ def to_dict(obj: Any) -> Dict[str, Any]:
25
+ return asdict(obj)
26
+
27
+ @staticmethod
28
+ def from_dict(cls: Type[T], data: Dict[str, Any]) -> T:
29
+ from dataclasses import MISSING
30
+
31
+ if not hasattr(cls, '__dataclass_fields__'):
32
+ raise ValueError(f"{cls} must be a dataclass")
33
+
34
+ field_info = {}
35
+ for field in fields(cls):
36
+ field_info[field.name] = field
37
+
38
+ kwargs = {}
39
+ for field_name, field in field_info.items():
40
+ # 首先尝试使用新字段名
41
+ if field_name in data:
42
+ kwargs[field_name] = data[field_name]
43
+ else:
44
+ # 尝试从别名中查找(向后兼容)
45
+ found_in_alias = False
46
+ aliases = field.metadata.get('aliases', [])
47
+ for alias in aliases:
48
+ if alias in data:
49
+ kwargs[field_name] = data[alias]
50
+ found_in_alias = True
51
+ break
52
+
53
+ # 如果在别名中也没找到,使用默认值
54
+ if not found_in_alias:
55
+ if field.default_factory is not MISSING:
56
+ kwargs[field_name] = field.default_factory()
57
+ elif field.default is not MISSING:
58
+ kwargs[field_name] = field.default
59
+ else:
60
+ kwargs[field_name] = None
61
+
62
+ return cls(**kwargs)
63
+
64
+ def auto_to_dict(obj: Any) -> Dict[str, Any]:
65
+ return DataclassSerializer.to_dict(obj)
66
+
67
+ def auto_from_dict(cls: Type[T], data: Dict[str, Any]) -> T:
68
+ return DataclassSerializer.from_dict(cls, data)
69
+
70
+ class AutoSerializableMixin:
71
+ """可序列化的 Mixin 类,提供 to_dict/from_dict 和模板渲染功能"""
72
+
73
+ def to_dict(self) -> Dict[str, Any]:
74
+ return auto_to_dict(self)
75
+
76
+ @classmethod
77
+ def from_dict(cls: Type[T], data: Dict[str, Any]) -> T:
78
+ return auto_from_dict(cls, data)
79
+
80
+ def _render_template_fields(self):
81
+ """渲染所有标记了 render_template=True 的字段
82
+
83
+ 此方法会遍历 dataclass 的所有字段,对标记了 render_template=True 的字段
84
+ 进行模板变量渲染(如 {{account_id}}、{{timestamp}} 等)。
85
+
86
+ 在渲染前,会将原始模板值保存到 _template_originals 字典中,
87
+ 以便在持久化时能够恢复原始模板值。
88
+
89
+ 使用方法:
90
+ 在子类的 __post_init__ 中调用:
91
+
92
+ def __post_init__(self):
93
+ self._render_template_fields()
94
+ """
95
+ # 只在 dataclass 中使用
96
+ if not hasattr(self, '__dataclass_fields__'):
97
+ return
98
+
99
+ try:
100
+ from agentkit.utils.template_utils import render_template
101
+ from agentkit.toolkit.config import AUTO_CREATE_VE
102
+ import logging
103
+
104
+ logger = logging.getLogger(__name__)
105
+
106
+ # 初始化原始值存储
107
+ if not hasattr(self, '_template_originals'):
108
+ self._template_originals = {}
109
+
110
+ for field_info in fields(self):
111
+ # 检查字段是否标记了需要渲染
112
+ if field_info.metadata.get("render_template"):
113
+ field_value = getattr(self, field_info.name)
114
+
115
+ # 只渲染非空且非自动创建的值
116
+ if field_value and field_value != AUTO_CREATE_VE:
117
+ # 保存原始模板值(仅当包含模板变量时)
118
+ if '{{' in str(field_value) and '}}' in str(field_value):
119
+ self._template_originals[field_info.name] = field_value
120
+ logger.debug(f"保存原始模板值 {field_info.name}: '{field_value}'")
121
+
122
+ try:
123
+ rendered = render_template(field_value)
124
+ if rendered != field_value:
125
+ logger.debug(f"自动渲染配置字段 {field_info.name}: '{field_value}' -> '{rendered}'")
126
+ setattr(self, field_info.name, rendered)
127
+ except Exception as e:
128
+ logger.warning(f"渲染配置字段 {field_info.name} 失败,使用原始值: {e}")
129
+ except ImportError:
130
+ # 如果模板工具不可用,静默失败
131
+ pass
132
+
133
+ def to_persist_dict(self) -> Dict[str, Any]:
134
+ """转换为用于持久化的字典,保留模板字段的原始值
135
+
136
+ 对于标记了 render_template=True 的字段:
137
+ - 如果有保存的原始模板值(包含 {{}} 的值),使用原始值
138
+ - 否则使用当前值(可能是用户直接设置的非模板值,或运行时生成的值)
139
+
140
+ 这样可以确保配置文件中的模板值(如 '{{timestamp}}' 或 'dev-{{timestamp}}')
141
+ 在每次运行时都能被重新渲染,而不是固化为某次运行的具体值。
142
+
143
+ Returns:
144
+ 用于持久化的字典
145
+ """
146
+ result = self.to_dict()
147
+
148
+ # 如果有保存的原始模板值,恢复它们
149
+ if hasattr(self, '_template_originals'):
150
+ for field_name, original_value in self._template_originals.items():
151
+ result[field_name] = original_value
152
+
153
+ return result
@@ -0,0 +1 @@
1
+ class DeployConfig: ...
@@ -0,0 +1,57 @@
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
+ """Configuration utility functions."""
16
+
17
+ from typing import Dict, Any
18
+
19
+ from .constants import AUTO_CREATE_VE
20
+
21
+
22
+ def is_invalid_config(s: str) -> bool:
23
+ return s == None or s == "" or s == AUTO_CREATE_VE
24
+
25
+
26
+ def is_valid_config(s: str) -> bool:
27
+ return not is_invalid_config(s)
28
+
29
+
30
+ def merge_runtime_envs(common_config: Any, workflow_config: Dict[str, Any]) -> Dict[str, str]:
31
+ """合并应用级和 Workflow 级的环境变量
32
+
33
+ 合并规则:
34
+ 1. 先加载应用级环境变量(common_config.runtime_envs)
35
+ 2. 再加载 Workflow 级环境变量(workflow_config.runtime_envs)
36
+ 3. 同名变量:Workflow 级覆盖应用级
37
+
38
+ Args:
39
+ common_config: CommonConfig 实例
40
+ workflow_config: Workflow 配置字典
41
+
42
+ Returns:
43
+ 合并后的环境变量字典
44
+ """
45
+ merged_envs = {}
46
+
47
+ # 1. 加载应用级环境变量
48
+ app_level_envs = getattr(common_config, 'runtime_envs', {})
49
+ if isinstance(app_level_envs, dict):
50
+ merged_envs.update(app_level_envs)
51
+
52
+ # 2. 加载 Workflow 级环境变量(会覆盖同名的应用级变量)
53
+ workflow_level_envs = workflow_config.get('runtime_envs', {})
54
+ if isinstance(workflow_level_envs, dict):
55
+ merged_envs.update(workflow_level_envs)
56
+
57
+ return merged_envs
@@ -0,0 +1,149 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import Dict, List
3
+ from .dataclass_utils import AutoSerializableMixin
4
+ from .constants import AUTO_CREATE_VE, DEFAULT_CR_NAMESPACE, DEFAULT_IMAGE_TAG, DEFAULT_WORKSPACE_NAME
5
+
6
+
7
+ @dataclass
8
+ class LocalDockerConfig_v1(AutoSerializableMixin):
9
+ """Local Docker workflow configuration"""
10
+ # User configurable fields
11
+ image_tag: str = field(default="latest", metadata={"description": "Docker image tag", "icon": "🏷️"})
12
+ invoke_port: int = field(default=8000, metadata={"description": "Agent application invoke port, defaults to 8000", "icon": "🌐"})
13
+
14
+ # System internal fields (not visible to users)
15
+ container_name: str = field(default="", metadata={"system": True, "description": "Container name, uses agent_name if empty"})
16
+ ports: List[str] = field(default_factory=lambda: ["8000:8000"], metadata={"system": True, "description": "Port mappings in host:container format, comma-separated"})
17
+ volumes: List[str] = field(default_factory=list, metadata={"system": True, "description": "Volume mappings in host:container format, comma-separated"})
18
+ restart_policy: str = field(default="unless-stopped", metadata={"system": True, "description": "Restart policy"})
19
+ memory_limit: str = field(default="1g", metadata={"system": True, "description": "Memory limit"})
20
+ cpu_limit: str = field(default="1", metadata={"system": True, "description": "CPU limit"})
21
+ container_id: str = field(default="", metadata={"system": True})
22
+ image_id: str = field(default="", metadata={"system": True})
23
+ build_timestamp: str = field(default="", metadata={"system": True})
24
+ deploy_timestamp: str = field(default="", metadata={"system": True})
25
+ full_image_name: str = field(default="", metadata={"system": True})
26
+ runtime_envs: Dict[str, str] = field(
27
+ default_factory=dict,
28
+ metadata={
29
+ "system": True,
30
+ "description": "运行时环境变量 (输入 KEY=VALUE,空行结束,del KEY 删除,list 查看)",
31
+ "examples": "MODEL_AGENT_API_KEY=your_key_here, DEBUG=true",
32
+ "icon": "🔧"
33
+ }
34
+ )
35
+ _config_metadata = {
36
+ 'name': '本地运行配置',
37
+ 'welcome_message': ' 欢迎使用 AgentKit 本地运行模式 配置向导',
38
+ 'next_step_hint': '本向导将帮助您完成本地模式下应用部署运行相关配置,请根据提示输入相关信息,或直接按Enter键使用默认值。',
39
+ 'completion_message': '太棒了!部署运行配置已完成!',
40
+ 'next_action_hint': '可以使用agentkit launch命令一键启动应用了!'
41
+ }
42
+
43
+
44
+ @dataclass
45
+ class HybridVeAgentkitConfig_v1(AutoSerializableMixin):
46
+ """本地Docker工作流配置"""
47
+ # 用户可配置字段
48
+ image_tag: str = field(default=DEFAULT_IMAGE_TAG, metadata={"system": True, "description": "镜像标签", "icon": "🏷️", "render_template": True})
49
+ # 系统内部字段(用户不可见)
50
+ image_id: str = field(default="", metadata={"system": True})
51
+ build_timestamp: str = field(default="", metadata={"system": True})
52
+ full_image_name: str = field(default="", metadata={"system": True})
53
+
54
+ region: str = field(default="cn-beijing", metadata={"description": "火山引擎服务区域", "icon": "🌏", "aliases": ["ve_region"]})
55
+
56
+ # CR相关配置
57
+ cr_instance_name: str = field(default=AUTO_CREATE_VE, metadata={"description": "容器镜像服务实例名称", "icon": "📦", "render_template": True, "aliases": ["ve_cr_instance_name"]})
58
+ cr_namespace_name: str = field(default=DEFAULT_CR_NAMESPACE, metadata={"description": "容器镜像命名空间", "icon": "📁", "render_template": True, "aliases": ["ve_cr_namespace_name"]})
59
+ cr_repo_name: str = field(default="", metadata={"description": "容器镜像仓库名称", "icon": "📋", "aliases": ["ve_cr_repo_name"]})
60
+ cr_image_full_url: str = field(default="", metadata={"system": True, "aliases": ["ve_cr_image_full_url"]})
61
+
62
+ # runtime相关配置
63
+ runtime_role_name: str = field(default=AUTO_CREATE_VE, metadata={"system": True, "description": "Agentkit 授权角色", "icon": "🔐", "aliases": ["ve_runtime_role_name"]})
64
+ runtime_name: str = field(default=AUTO_CREATE_VE, metadata={"system": True, "description": "Agentkit Runtime名称", "icon": "⚙️", "aliases": ["ve_runtime_name"]})
65
+ runtime_id: str = field(default="", metadata={"system": True, "aliases": ["ve_runtime_id"]})
66
+ runtime_apikey: str = field(default="", metadata={"system": True, "aliases": ["ve_runtime_apikey"]})
67
+ runtime_apikey_name: str = field(default=AUTO_CREATE_VE, metadata={"system": True, "aliases": ["ve_runtime_apikey_name"]})
68
+ runtime_endpoint: str = field(default="", metadata={"system": True, "description": "Agentkit Runtime应用访问入口", "aliases": ["ve_runtime_endpoint"]})
69
+ runtime_envs: Dict[str, str] = field(
70
+ default_factory=dict,
71
+ metadata={
72
+ "system": True,
73
+ "description": "运行时环境变量 (输入 KEY=VALUE,空行结束,del KEY 删除,list 查看)",
74
+ "examples": "MODEL_AGENT_API_KEY=your_key_here, DEBUG=true",
75
+ "icon": "🔧"
76
+ }
77
+ )
78
+ _config_metadata = {
79
+ 'name': '混合部署运行模式配置',
80
+ 'welcome_message': ' 欢迎使用 AgentKit 混合部署运行模式 配置向导',
81
+ 'next_step_hint': '本向导将帮助您完成混合模式下应用部署运行相关配置,请根据提示输入相关信息,或直接按Enter键使用默认值。',
82
+ 'completion_message': '太棒了!部署运行配置已完成!',
83
+ 'next_action_hint': '可以使用agentkit launch命令一键启动应用了!'
84
+ }
85
+
86
+ def __post_init__(self):
87
+ """对象创建后自动渲染标记的字段"""
88
+ self._render_template_fields() # 调用基类方法
89
+
90
+
91
+
92
+ @dataclass
93
+ class VeAgentkitConfig(AutoSerializableMixin):
94
+ """VeAgentkit工作流配置"""
95
+ region: str = field(default="cn-beijing", metadata={"description": "服务使用的区域", "icon": "🌏"})
96
+
97
+ # TOS配置
98
+ tos_bucket: str = field(default=AUTO_CREATE_VE, metadata={"system": True, "description": "TOS存储桶名称", "icon": "🗂️", "render_template": True})
99
+ tos_prefix: str = field(default="agentkit-builds", metadata={"system": True, "description": "TOS对象前缀"})
100
+ tos_region: str = field(default="cn-beijing", metadata={"system": True, "description": "TOS区域"})
101
+ tos_object_key: str = field(default="", metadata={"system": True})
102
+ tos_object_url: str = field(default="", metadata={"system": True})
103
+
104
+ # CR配置
105
+ image_tag: str = field(default=DEFAULT_IMAGE_TAG, metadata={"system": True, "description": "镜像标签", "icon": "🏷️", "render_template": True})
106
+ cr_instance_name: str = field(default=AUTO_CREATE_VE, metadata={"description": "CR实例名称", "icon": "📦", "render_template": True, "aliases": ["ve_cr_instance_name"]})
107
+ cr_namespace_name: str = field(default=DEFAULT_CR_NAMESPACE, metadata={"description": "CR命名空间", "icon": "📁", "render_template": True, "aliases": ["ve_cr_namespace_name"]})
108
+ cr_repo_name: str = field(default="", metadata={"description": "CR仓库名称,默认使用AgentKit项目名", "icon": "📋", "aliases": ["ve_cr_repo_name"]})
109
+ cr_region: str = field(default="cn-beijing", metadata={"system": True, "description": "CR区域", "aliases": ["ve_cr_region"]})
110
+ cr_image_full_url: str = field(default="", metadata={"system": True, "aliases": ["ve_cr_image_full_url"]})
111
+ build_timeout: int = field(default=3600, metadata={"system": True, "description": "构建超时时间(秒)"})
112
+
113
+ cp_workspace_name: str = field(default=DEFAULT_WORKSPACE_NAME, metadata={"system": True, "description": "Code Pipeline工作区名称"})
114
+ cp_pipeline_name: str = field(default=AUTO_CREATE_VE, metadata={"system": True, "description": "Code Pipeline流水线名称"})
115
+ cp_pipeline_id: str = field(default="", metadata={"system": True})
116
+
117
+ # Runtime配置
118
+ runtime_id: str = field(default=AUTO_CREATE_VE, metadata={"system": True, "description": "运行时ID", "aliases": ["ve_runtime_id"]})
119
+ runtime_name: str = field(default=AUTO_CREATE_VE, metadata={"system": True, "description": "运行时名称", "aliases": ["ve_runtime_name"]})
120
+ runtime_role_name: str = field(default=AUTO_CREATE_VE, metadata={"system": True, "description": "运行时角色名称", "aliases": ["ve_runtime_role_name"]})
121
+ runtime_apikey: str = field(default=AUTO_CREATE_VE, metadata={"system": True,"description": "运行时API密钥", "aliases": ["ve_runtime_apikey"]})
122
+ runtime_apikey_name: str = field(default=AUTO_CREATE_VE, metadata={"system": True, "description": "运行时API密钥名称", "aliases": ["ve_runtime_apikey_name"]})
123
+ runtime_endpoint: str = field(default="", metadata={"system": True, "description": "运行时访问入口,自动获取", "aliases": ["ve_runtime_endpoint"]})
124
+ runtime_envs: Dict[str, str] = field(
125
+ default_factory=dict,
126
+ metadata={
127
+ "system": True,
128
+ "description": "运行时环境变量 (输入 KEY=VALUE,空行结束,del KEY 删除,list 查看)",
129
+ "examples": "MODEL_AGENT_API_KEY=your_key_here, DEBUG=true",
130
+ "icon": "🔧"
131
+ }
132
+ )
133
+
134
+ build_timestamp: str = field(default="", metadata={"system": True})
135
+ deploy_timestamp: str = field(default="", metadata={"system": True})
136
+
137
+ _config_metadata = {
138
+ 'name': '云构建与部署配置',
139
+ 'welcome_message': ' 欢迎使用 AgentKit 云构建与部署模式 配置向导',
140
+ 'next_step_hint': '本向导将帮助您完成云构建与部署模式下应用部署运行相关配置,请根据提示输入相关信息,或直接按Enter键使用默认值。',
141
+ 'completion_message': '太棒了!部署运行配置已完成!',
142
+ 'next_action_hint': '可以使用agentkit launch命令一键启动应用了!'
143
+ }
144
+
145
+ def __post_init__(self):
146
+ """对象创建后自动渲染标记的字段"""
147
+ self._render_template_fields() # 调用基类方法
148
+
149
+
@@ -0,0 +1 @@
1
+ DEFAULT_CONFIG_FILENAME = "agentkit.yaml"
@@ -0,0 +1,13 @@
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.
@@ -0,0 +1,13 @@
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.
@@ -0,0 +1,6 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+
4
+ class BaseBuilder(ABC):
5
+ @abstractmethod
6
+ def build(self): ...
File without changes
File without changes
@@ -0,0 +1,13 @@
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.
@@ -0,0 +1,6 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+
4
+ class BaseDeployer(ABC):
5
+ @abstractmethod
6
+ def deploy(self): ...
File without changes
File without changes
@@ -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 .services import CRService, CRServiceConfig, CRServiceResult, CRConfigCallback, DefaultCRConfigCallback
16
+
17
+ __all__ = ['CRService', 'CRServiceConfig', 'CRServiceResult', 'CRConfigCallback', 'DefaultCRConfigCallback']