devops-mcp-server-extension 1.0.0

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 (102) hide show
  1. package/LICENSE +218 -0
  2. package/README.md +527 -0
  3. package/README.zh-cn.md +503 -0
  4. package/dist/common/errors.js +77 -0
  5. package/dist/common/modularTemplates.js +483 -0
  6. package/dist/common/pipelineTemplates.js +19 -0
  7. package/dist/common/toolsetManager.js +123 -0
  8. package/dist/common/toolsets.js +23 -0
  9. package/dist/common/types.js +60 -0
  10. package/dist/common/utils.js +381 -0
  11. package/dist/common/version.js +1 -0
  12. package/dist/index.js +225 -0
  13. package/dist/operations/appstack/appOrchestrations.js +260 -0
  14. package/dist/operations/appstack/appTags.js +168 -0
  15. package/dist/operations/appstack/appTemplates.js +72 -0
  16. package/dist/operations/appstack/applications.js +171 -0
  17. package/dist/operations/appstack/changeOrders.js +320 -0
  18. package/dist/operations/appstack/changeRequests.js +288 -0
  19. package/dist/operations/appstack/deploymentResources.js +286 -0
  20. package/dist/operations/appstack/globalVars.js +221 -0
  21. package/dist/operations/appstack/releaseWorkflows.js +695 -0
  22. package/dist/operations/appstack/variableGroups.js +245 -0
  23. package/dist/operations/codeup/branches.js +157 -0
  24. package/dist/operations/codeup/changeRequestComments.js +140 -0
  25. package/dist/operations/codeup/changeRequests.js +230 -0
  26. package/dist/operations/codeup/commits.js +121 -0
  27. package/dist/operations/codeup/compare.js +30 -0
  28. package/dist/operations/codeup/files.js +249 -0
  29. package/dist/operations/codeup/repositories.js +71 -0
  30. package/dist/operations/codeup/types.js +414 -0
  31. package/dist/operations/flow/hostGroup.js +52 -0
  32. package/dist/operations/flow/pipeline.js +609 -0
  33. package/dist/operations/flow/pipelineJob.js +126 -0
  34. package/dist/operations/flow/resourceMember.js +137 -0
  35. package/dist/operations/flow/serviceConnection.js +27 -0
  36. package/dist/operations/flow/tag.js +191 -0
  37. package/dist/operations/flow/types.js +523 -0
  38. package/dist/operations/flow/vmDeployOrder.js +171 -0
  39. package/dist/operations/organization/members.js +106 -0
  40. package/dist/operations/organization/organization.js +110 -0
  41. package/dist/operations/organization/types.js +111 -0
  42. package/dist/operations/packages/artifacts.js +71 -0
  43. package/dist/operations/packages/repositories.js +39 -0
  44. package/dist/operations/packages/types.js +56 -0
  45. package/dist/operations/projex/effort.js +122 -0
  46. package/dist/operations/projex/project.js +243 -0
  47. package/dist/operations/projex/sprint.js +103 -0
  48. package/dist/operations/projex/types.js +618 -0
  49. package/dist/operations/projex/workitem.js +826 -0
  50. package/dist/operations/testhub/testcases.js +240 -0
  51. package/dist/operations/testhub/testplans.js +128 -0
  52. package/dist/tool-handlers/appstack-app-release-workflows.js +103 -0
  53. package/dist/tool-handlers/appstack-change-orders.js +55 -0
  54. package/dist/tool-handlers/appstack-change-requests.js +49 -0
  55. package/dist/tool-handlers/appstack-deployment-resources.js +31 -0
  56. package/dist/tool-handlers/appstack-global-vars.js +37 -0
  57. package/dist/tool-handlers/appstack-orchestrations.js +49 -0
  58. package/dist/tool-handlers/appstack-release-workflows.js +37 -0
  59. package/dist/tool-handlers/appstack-tags.js +37 -0
  60. package/dist/tool-handlers/appstack-templates.js +19 -0
  61. package/dist/tool-handlers/appstack-variable-groups.js +55 -0
  62. package/dist/tool-handlers/appstack.js +37 -0
  63. package/dist/tool-handlers/base.js +25 -0
  64. package/dist/tool-handlers/code-management.js +150 -0
  65. package/dist/tool-handlers/commit.js +31 -0
  66. package/dist/tool-handlers/effort.js +103 -0
  67. package/dist/tool-handlers/index.js +119 -0
  68. package/dist/tool-handlers/organization.js +72 -0
  69. package/dist/tool-handlers/packages.js +32 -0
  70. package/dist/tool-handlers/pipeline.js +289 -0
  71. package/dist/tool-handlers/project-management.js +201 -0
  72. package/dist/tool-handlers/resourceMember.js +43 -0
  73. package/dist/tool-handlers/service-connections.js +16 -0
  74. package/dist/tool-handlers/tag.js +64 -0
  75. package/dist/tool-handlers/test-management.js +74 -0
  76. package/dist/tool-handlers/vmDeployOrder.js +50 -0
  77. package/dist/tool-registry/appstack-app-release-workflows.js +80 -0
  78. package/dist/tool-registry/appstack-change-orders.js +40 -0
  79. package/dist/tool-registry/appstack-change-requests.js +35 -0
  80. package/dist/tool-registry/appstack-deployment-resources.js +20 -0
  81. package/dist/tool-registry/appstack-global-vars.js +25 -0
  82. package/dist/tool-registry/appstack-orchestrations.js +35 -0
  83. package/dist/tool-registry/appstack-release-workflows.js +25 -0
  84. package/dist/tool-registry/appstack-tags.js +25 -0
  85. package/dist/tool-registry/appstack-templates.js +10 -0
  86. package/dist/tool-registry/appstack-variable-groups.js +40 -0
  87. package/dist/tool-registry/appstack.js +25 -0
  88. package/dist/tool-registry/base.js +19 -0
  89. package/dist/tool-registry/code-management.js +109 -0
  90. package/dist/tool-registry/commit.js +20 -0
  91. package/dist/tool-registry/effort.js +39 -0
  92. package/dist/tool-registry/index.js +7 -0
  93. package/dist/tool-registry/organization.js +65 -0
  94. package/dist/tool-registry/packages.js +21 -0
  95. package/dist/tool-registry/pipeline.js +190 -0
  96. package/dist/tool-registry/project-management.js +143 -0
  97. package/dist/tool-registry/resourceMember.js +29 -0
  98. package/dist/tool-registry/service-connections.js +10 -0
  99. package/dist/tool-registry/tag.js +44 -0
  100. package/dist/tool-registry/test-management.js +59 -0
  101. package/dist/tool-registry/vmDeployOrder.js +34 -0
  102. package/package.json +52 -0
@@ -0,0 +1,119 @@
1
+ import { handleCodeManagementTools } from './code-management.js';
2
+ import { handleOrganizationTools } from './organization.js';
3
+ import { handleProjectManagementTools } from './project-management.js';
4
+ import { handlePipelineTools } from './pipeline.js';
5
+ import { handlePackageManagementTools } from './packages.js';
6
+ import { handleServiceConnectionTools } from './service-connections.js';
7
+ import { handleAppStackTools } from './appstack.js';
8
+ import { handleAppStackTagTools } from './appstack-tags.js';
9
+ import { handleAppStackTemplateTools } from './appstack-templates.js';
10
+ import { handleAppStackGlobalVarTools } from './appstack-global-vars.js';
11
+ import { handleAppStackVariableGroupTools } from './appstack-variable-groups.js';
12
+ import { handleAppStackOrchestrationTools } from './appstack-orchestrations.js';
13
+ import { handleAppStackChangeRequestTools } from './appstack-change-requests.js';
14
+ import { handleAppStackDeploymentResourceTools } from './appstack-deployment-resources.js';
15
+ import { handleAppStackChangeOrderTools } from './appstack-change-orders.js';
16
+ import { handleAppStackAppReleaseWorkflowTools } from './appstack-app-release-workflows.js';
17
+ import { handleEffortTools } from './effort.js';
18
+ import { handleResourceMemberTools } from './resourceMember.js';
19
+ import { handleVMDeployOrderTools } from './vmDeployOrder.js';
20
+ import { handleCommitTools } from './commit.js';
21
+ import { handleBaseTools } from './base.js';
22
+ import { handleTestManagementTools } from './test-management.js';
23
+ import { Toolset } from '../common/toolsets.js';
24
+ // 定义处理函数映射
25
+ const HANDLER_MAP = {
26
+ [Toolset.BASE]: handleBaseTools,
27
+ [Toolset.CODE_MANAGEMENT]: handleCodeManagementTools,
28
+ [Toolset.ORGANIZATION_MANAGEMENT]: handleOrganizationTools,
29
+ [Toolset.PROJECT_MANAGEMENT]: handleProjectManagementTools,
30
+ [Toolset.PIPELINE_MANAGEMENT]: handlePipelineTools,
31
+ [Toolset.PACKAGES_MANAGEMENT]: handlePackageManagementTools,
32
+ [Toolset.APPLICATION_DELIVERY]: handleAppStackTools, // 注意:这里只使用了主处理函数,其他AppStack处理函数在内部处理
33
+ [Toolset.TEST_MANAGEMENT]: handleTestManagementTools,
34
+ };
35
+ // 保持向后兼容的接口
36
+ export const handleToolRequest = async (request) => {
37
+ // Try each handler in sequence until one returns a result
38
+ const handlers = [
39
+ handleBaseTools,
40
+ handleCodeManagementTools,
41
+ handleOrganizationTools,
42
+ handleProjectManagementTools,
43
+ handlePipelineTools,
44
+ handlePackageManagementTools,
45
+ handleServiceConnectionTools,
46
+ handleAppStackTools,
47
+ handleAppStackTagTools,
48
+ handleAppStackTemplateTools,
49
+ handleAppStackGlobalVarTools,
50
+ handleAppStackVariableGroupTools,
51
+ handleAppStackOrchestrationTools,
52
+ handleAppStackChangeRequestTools,
53
+ handleAppStackDeploymentResourceTools,
54
+ handleAppStackChangeOrderTools,
55
+ handleAppStackAppReleaseWorkflowTools,
56
+ handleEffortTools,
57
+ handleResourceMemberTools,
58
+ handleVMDeployOrderTools,
59
+ handleCommitTools,
60
+ handleTestManagementTools
61
+ ];
62
+ for (const handler of handlers) {
63
+ const result = await handler(request);
64
+ if (result !== null) {
65
+ return result;
66
+ }
67
+ }
68
+ // If no handler matched, throw an error
69
+ throw new Error(`Unknown tool: ${request.params.name}`);
70
+ };
71
+ // 新增按工具集处理工具请求的接口
72
+ export const handleToolRequestByToolset = async (request, toolsetName) => {
73
+ const handler = HANDLER_MAP[toolsetName];
74
+ if (!handler) {
75
+ throw new Error(`Unknown toolset: ${toolsetName}`);
76
+ }
77
+ return await handler(request);
78
+ };
79
+ // 新增处理启用工具集的接口
80
+ export const handleEnabledToolRequest = async (request, enabledToolsets) => {
81
+ // 总是先尝试处理基础工具集
82
+ try {
83
+ const baseResult = await handleToolRequestByToolset(request, Toolset.BASE);
84
+ if (baseResult !== null) {
85
+ return baseResult;
86
+ }
87
+ }
88
+ catch (error) {
89
+ // 如果工具不在基础工具集中,继续尝试其他工具集
90
+ // 如果是其他错误,重新抛出
91
+ if (!(error instanceof Error && error.message.includes("Unknown tool"))) {
92
+ throw error;
93
+ }
94
+ }
95
+ // 如果没有指定启用的工具集,则处理所有工具集(除了基础工具集,因为已经处理过了)
96
+ const toolsets = enabledToolsets.length > 0 ? enabledToolsets : Object.values(Toolset).filter(t => t !== Toolset.BASE);
97
+ // 按顺序尝试每个启用的工具集
98
+ for (const toolset of toolsets) {
99
+ // 跳过基础工具集,因为我们已经处理过了
100
+ if (toolset === Toolset.BASE) {
101
+ continue;
102
+ }
103
+ try {
104
+ const result = await handleToolRequestByToolset(request, toolset);
105
+ if (result !== null) {
106
+ return result;
107
+ }
108
+ }
109
+ catch (error) {
110
+ // 如果工具不在当前工具集中,继续尝试下一个工具集
111
+ // 如果是其他错误,重新抛出
112
+ if (!(error instanceof Error && error.message.includes("Unknown tool"))) {
113
+ throw error;
114
+ }
115
+ }
116
+ }
117
+ // 如果没有处理函数匹配,抛出错误
118
+ throw new Error(`Unknown tool: ${request.params.name}`);
119
+ };
@@ -0,0 +1,72 @@
1
+ import * as organization from '../operations/organization/organization.js';
2
+ import * as members from '../operations/organization/members.js';
3
+ import * as types from '../common/types.js';
4
+ export const handleOrganizationTools = async (request) => {
5
+ switch (request.params.name) {
6
+ case "list_organization_departments": {
7
+ const args = types.GetOrganizationDepartmentsSchema.parse(request.params.arguments);
8
+ const departments = await organization.getOrganizationDepartmentsFunc(args.organizationId, args.parentId ?? undefined);
9
+ return {
10
+ content: [{ type: "text", text: JSON.stringify(departments, null, 2) }],
11
+ };
12
+ }
13
+ case "get_organization_department_info": {
14
+ const args = types.GetOrganizationDepartmentInfoSchema.parse(request.params.arguments);
15
+ const departmentInfo = await organization.getOrganizationDepartmentInfoFunc(args.organizationId, args.id);
16
+ return {
17
+ content: [{ type: "text", text: JSON.stringify(departmentInfo, null, 2) }],
18
+ };
19
+ }
20
+ case "get_organization_department_ancestors": {
21
+ const args = types.GetOrganizationDepartmentAncestorsSchema.parse(request.params.arguments);
22
+ const ancestors = await organization.getOrganizationDepartmentAncestorsFunc(args.organizationId, args.id);
23
+ return {
24
+ content: [{ type: "text", text: JSON.stringify(ancestors, null, 2) }],
25
+ };
26
+ }
27
+ case "list_organization_members": {
28
+ const args = types.GetOrganizationMembersSchema.parse(request.params.arguments);
29
+ const orgMembers = await members.getOrganizationMembersFunc(args.organizationId, args.page ?? 1, args.perPage ?? 100);
30
+ return {
31
+ content: [{ type: "text", text: JSON.stringify(orgMembers, null, 2) }]
32
+ };
33
+ }
34
+ case "get_organization_member_info": {
35
+ const args = types.GetOrganizationMemberInfoSchema.parse(request.params.arguments);
36
+ const memberInfo = await members.getOrganizationMemberInfoFunc(args.organizationId, args.memberId);
37
+ return {
38
+ content: [{ type: "text", text: JSON.stringify(memberInfo, null, 2) }]
39
+ };
40
+ }
41
+ case "get_organization_member_info_by_user_id": {
42
+ const args = types.GetOrganizationMemberByUserIdInfoSchema.parse(request.params.arguments);
43
+ const memberInfo = await members.getOrganizationMemberByUserIdInfoFunc(args.organizationId, args.userId);
44
+ return {
45
+ content: [{ type: "text", text: JSON.stringify(memberInfo, null, 2) }]
46
+ };
47
+ }
48
+ case "search_organization_members": {
49
+ const args = types.SearchOrganizationMembersSchema.parse(request.params.arguments);
50
+ const membersResult = await members.searchOrganizationMembersFunc(args.organizationId, args.includeChildren ?? false, args.page ?? 1, args.perPage ?? 100, args.deptIds ?? undefined, args.nextToken ?? undefined, args.query ?? undefined, args.roleIds ?? undefined, args.statuses ?? undefined);
51
+ return {
52
+ content: [{ type: "text", text: JSON.stringify(membersResult, null, 2) }]
53
+ };
54
+ }
55
+ case "list_organization_roles": {
56
+ const args = types.ListOrganizationRolesSchema.parse(request.params.arguments);
57
+ const roles = await organization.listOrganizationRolesFunc(args.organizationId);
58
+ return {
59
+ content: [{ type: "text", text: JSON.stringify(roles, null, 2) }]
60
+ };
61
+ }
62
+ case "get_organization_role": {
63
+ const args = types.GetOrganizationRoleSchema.parse(request.params.arguments);
64
+ const role = await organization.getOrganizationRoleFunc(args.organizationId, args.roleId);
65
+ return {
66
+ content: [{ type: "text", text: JSON.stringify(role, null, 2) }]
67
+ };
68
+ }
69
+ default:
70
+ return null;
71
+ }
72
+ };
@@ -0,0 +1,32 @@
1
+ import * as packageRepositories from '../operations/packages/repositories.js';
2
+ import * as artifacts from '../operations/packages/artifacts.js';
3
+ import * as types from '../common/types.js';
4
+ export const handlePackageManagementTools = async (request) => {
5
+ switch (request.params.name) {
6
+ // Package Repository Operations
7
+ case "list_package_repositories": {
8
+ const args = types.ListPackageRepositoriesSchema.parse(request.params.arguments);
9
+ const packageRepoList = await packageRepositories.listPackageRepositoriesFunc(args.organizationId, args.repoTypes ?? undefined, args.repoCategories ?? undefined, args.perPage, args.page);
10
+ return {
11
+ content: [{ type: "text", text: JSON.stringify(packageRepoList, null, 2) }],
12
+ };
13
+ }
14
+ // Package Artifact Operations
15
+ case "list_artifacts": {
16
+ const args = types.ListArtifactsSchema.parse(request.params.arguments);
17
+ const artifactsList = await artifacts.listArtifactsFunc(args.organizationId, args.repoId, args.repoType, args.page, args.perPage, args.search ?? undefined, args.orderBy, args.sort);
18
+ return {
19
+ content: [{ type: "text", text: JSON.stringify(artifactsList, null, 2) }],
20
+ };
21
+ }
22
+ case "get_artifact": {
23
+ const args = types.GetArtifactSchema.parse(request.params.arguments);
24
+ const artifact = await artifacts.getArtifactFunc(args.organizationId, args.repoId, args.id, args.repoType);
25
+ return {
26
+ content: [{ type: "text", text: JSON.stringify(artifact, null, 2) }],
27
+ };
28
+ }
29
+ default:
30
+ return null;
31
+ }
32
+ };
@@ -0,0 +1,289 @@
1
+ import * as pipeline from '../operations/flow/pipeline.js';
2
+ import * as pipelineJob from '../operations/flow/pipelineJob.js';
3
+ import * as types from '../common/types.js';
4
+ import { z } from 'zod';
5
+ export const handlePipelineTools = async (request) => {
6
+ switch (request.params.name) {
7
+ case "get_pipeline": {
8
+ const args = types.GetPipelineSchema.parse(request.params.arguments);
9
+ const pipelineInfo = await pipeline.getPipelineFunc(args.organizationId, args.pipelineId);
10
+ return {
11
+ content: [{ type: "text", text: JSON.stringify(pipelineInfo, null, 2) }],
12
+ };
13
+ }
14
+ case "list_pipelines": {
15
+ const args = types.ListPipelinesSchema.parse(request.params.arguments);
16
+ const pipelines = await pipeline.listPipelinesFunc(args.organizationId, {
17
+ createStartTime: args.createStartTime,
18
+ createEndTime: args.createEndTime,
19
+ executeStartTime: args.executeStartTime,
20
+ executeEndTime: args.executeEndTime,
21
+ pipelineName: args.pipelineName,
22
+ statusList: args.statusList,
23
+ perPage: args.perPage,
24
+ page: args.page
25
+ });
26
+ return {
27
+ content: [{ type: "text", text: JSON.stringify(pipelines, null, 2) }],
28
+ };
29
+ }
30
+ case "generate_pipeline_yaml": {
31
+ try {
32
+ const args = types.CreatePipelineFromDescriptionSchema.parse(request.params.arguments);
33
+ // 检查必需的参数
34
+ if (!args.buildLanguage) {
35
+ throw new Error("The build language parameter is missing.");
36
+ }
37
+ if (!args.buildTool) {
38
+ throw new Error("The build tool parameter is missing.");
39
+ }
40
+ const yamlContent = await pipeline.generatePipelineYamlFunc({
41
+ buildLanguage: args.buildLanguage,
42
+ buildTool: args.buildTool,
43
+ deployTarget: args.deployTarget,
44
+ // Repository configuration
45
+ repoUrl: args.repoUrl,
46
+ branch: args.branch,
47
+ serviceName: args.serviceName,
48
+ serviceConnectionId: args.serviceConnectionId,
49
+ // Version configuration
50
+ jdkVersion: args.jdkVersion,
51
+ mavenVersion: args.mavenVersion,
52
+ nodeVersion: args.nodeVersion,
53
+ pythonVersion: args.pythonVersion,
54
+ goVersion: args.goVersion,
55
+ // Build configuration
56
+ buildCommand: args.buildCommand,
57
+ testCommand: args.testCommand,
58
+ // Artifact upload configuration
59
+ uploadType: args.uploadType,
60
+ packagesServiceConnection: args.packagesServiceConnection,
61
+ artifactName: args.artifactName,
62
+ artifactVersion: args.artifactVersion,
63
+ packagesRepoId: args.packagesRepoId,
64
+ includePathInArtifact: args.includePathInArtifact,
65
+ // VM deployment configuration
66
+ machineGroupId: args.machineGroupId,
67
+ executeUser: args.executeUser,
68
+ artifactDownloadPath: args.artifactDownloadPath,
69
+ deployCommand: args.deployCommand,
70
+ pauseStrategy: args.pauseStrategy,
71
+ batchNumber: args.batchNumber,
72
+ // Kubernetes deployment configuration
73
+ kubernetesClusterId: args.kubernetesClusterId,
74
+ kubectlVersion: args.kubectlVersion,
75
+ namespace: args.namespace,
76
+ yamlPath: args.yamlPath,
77
+ dockerImage: args.dockerImage,
78
+ });
79
+ return {
80
+ content: [{ type: "text", text: yamlContent }],
81
+ };
82
+ }
83
+ catch (error) {
84
+ if (error instanceof Error && error.message.includes("build language parameter is missing")) {
85
+ throw error; // 重新抛出我们自定义的错误
86
+ }
87
+ if (error instanceof Error && error.message.includes("build tool parameter is missing")) {
88
+ throw error; // 重新抛出我们自定义的错误
89
+ }
90
+ // 处理YAML生成过程中的错误
91
+ if (error instanceof Error) {
92
+ throw new Error(`YAML generation failed: ${error.message}`);
93
+ }
94
+ throw error;
95
+ }
96
+ }
97
+ case "create_pipeline_from_description": {
98
+ try {
99
+ const args = types.CreatePipelineFromDescriptionSchema.parse(request.params.arguments);
100
+ // 检查必需的参数
101
+ if (!args.name) {
102
+ throw new Error("The Pipeline name cannot be empty.");
103
+ }
104
+ if (!args.buildLanguage) {
105
+ throw new Error("The build language parameter is missing.");
106
+ }
107
+ if (!args.buildTool) {
108
+ throw new Error("The build tool parameter is missing.");
109
+ }
110
+ const result = await pipeline.createPipelineWithOptionsFunc(args.organizationId, {
111
+ name: args.name,
112
+ repoUrl: args.repoUrl,
113
+ branch: args.branch,
114
+ serviceConnectionId: args.serviceConnectionId,
115
+ // 技术栈参数
116
+ buildLanguage: args.buildLanguage,
117
+ buildTool: args.buildTool,
118
+ deployTarget: args.deployTarget,
119
+ // 版本相关参数
120
+ jdkVersion: args.jdkVersion,
121
+ mavenVersion: args.mavenVersion,
122
+ nodeVersion: args.nodeVersion,
123
+ pythonVersion: args.pythonVersion,
124
+ goVersion: args.goVersion,
125
+ kubectlVersion: args.kubectlVersion,
126
+ // 构建物上传相关参数
127
+ uploadType: args.uploadType,
128
+ artifactName: args.artifactName,
129
+ artifactVersion: args.artifactVersion,
130
+ packagesServiceConnection: args.packagesServiceConnection,
131
+ packagesRepoId: args.packagesRepoId,
132
+ includePathInArtifact: args.includePathInArtifact,
133
+ // 部署相关参数
134
+ executeUser: args.executeUser,
135
+ artifactDownloadPath: args.artifactDownloadPath,
136
+ machineGroupId: args.machineGroupId,
137
+ pauseStrategy: args.pauseStrategy,
138
+ batchNumber: args.batchNumber,
139
+ kubernetesClusterId: args.kubernetesClusterId,
140
+ yamlPath: args.yamlPath,
141
+ namespace: args.namespace,
142
+ dockerImage: args.dockerImage,
143
+ // 自定义命令
144
+ buildCommand: args.buildCommand,
145
+ testCommand: args.testCommand,
146
+ deployCommand: args.deployCommand,
147
+ });
148
+ return {
149
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
150
+ };
151
+ }
152
+ catch (error) {
153
+ if (error instanceof Error && error.message.includes("Pipeline name cannot be empty")) {
154
+ throw error;
155
+ }
156
+ if (error instanceof Error && error.message.includes("build language parameter is missing")) {
157
+ throw error;
158
+ }
159
+ if (error instanceof Error && error.message.includes("build language tool is missing")) {
160
+ throw error;
161
+ }
162
+ // 处理流水线创建过程中的其他错误
163
+ if (error instanceof Error) {
164
+ throw new Error(`Create pipeline failed: ${error.message}\n Suggestion: Please check whether the organization ID, repository configuration, or other parameters are correct, and if generated YAML to check whether YAML content is invalid.`);
165
+ }
166
+ throw error;
167
+ }
168
+ }
169
+ case "smart_list_pipelines": {
170
+ // Parse arguments using the schema defined in the tool registration
171
+ const args = z.object({
172
+ organizationId: z.string(),
173
+ timeReference: z.string().optional(),
174
+ pipelineName: z.string().optional(),
175
+ statusList: z.string().optional(),
176
+ perPage: z.number().int().optional(),
177
+ page: z.number().int().optional()
178
+ }).parse(request.params.arguments);
179
+ // Call the smart list function
180
+ const pipelines = await pipeline.smartListPipelinesFunc(args.organizationId, args.timeReference, {
181
+ pipelineName: args.pipelineName,
182
+ statusList: args.statusList,
183
+ perPage: args.perPage,
184
+ page: args.page
185
+ });
186
+ return {
187
+ content: [{ type: "text", text: JSON.stringify(pipelines, null, 2) }],
188
+ };
189
+ }
190
+ case "create_pipeline_run": {
191
+ const args = types.CreatePipelineRunSchema.parse(request.params.arguments);
192
+ // 调试日志:查看AI传递的原始参数
193
+ console.log('[DEBUG] Handler - Raw request.params.arguments:', JSON.stringify(request.params.arguments, null, 2));
194
+ console.log('[DEBUG] Handler - Parsed args:', JSON.stringify({
195
+ organizationId: args.organizationId,
196
+ pipelineId: args.pipelineId,
197
+ params: args.params,
198
+ branch: args.branch,
199
+ tag: args.tag,
200
+ branches: args.branches,
201
+ repositories: args.repositories
202
+ }, null, 2));
203
+ const runId = await pipeline.createPipelineRunFunc(args.organizationId, args.pipelineId, {
204
+ params: args.params,
205
+ branch: args.branch,
206
+ tag: args.tag,
207
+ branches: args.branches,
208
+ branchMode: args.branchMode,
209
+ repositories: args.repositories,
210
+ environmentVariables: args.environmentVariables,
211
+ pipelineArtifacts: args.pipelineArtifacts,
212
+ acrArtifacts: args.acrArtifacts,
213
+ packagesArtifacts: args.packagesArtifacts,
214
+ releaseBranch: args.releaseBranch,
215
+ createReleaseBranch: args.createReleaseBranch,
216
+ comment: args.comment,
217
+ description: args.description
218
+ });
219
+ return {
220
+ content: [{ type: "text", text: JSON.stringify(runId, null, 2) }],
221
+ };
222
+ }
223
+ case "get_latest_pipeline_run": {
224
+ const args = types.GetLatestPipelineRunSchema.parse(request.params.arguments);
225
+ const pipelineRun = await pipeline.getLatestPipelineRunFunc(args.organizationId, args.pipelineId);
226
+ return {
227
+ content: [{ type: "text", text: JSON.stringify(pipelineRun, null, 2) }],
228
+ };
229
+ }
230
+ case "get_pipeline_run": {
231
+ const args = types.GetPipelineRunSchema.parse(request.params.arguments);
232
+ const pipelineRun = await pipeline.getPipelineRunFunc(args.organizationId, args.pipelineId, args.pipelineRunId);
233
+ return {
234
+ content: [{ type: "text", text: JSON.stringify(pipelineRun, null, 2) }],
235
+ };
236
+ }
237
+ case "list_pipeline_runs": {
238
+ const args = types.ListPipelineRunsSchema.parse(request.params.arguments);
239
+ const pipelineRuns = await pipeline.listPipelineRunsFunc(args.organizationId, args.pipelineId, {
240
+ perPage: args.perPage,
241
+ page: args.page,
242
+ startTime: args.startTime,
243
+ endTime: args.endTime,
244
+ status: args.status,
245
+ triggerMode: args.triggerMode
246
+ });
247
+ return {
248
+ content: [{ type: "text", text: JSON.stringify(pipelineRuns, null, 2) }],
249
+ };
250
+ }
251
+ case "list_pipeline_jobs_by_category": {
252
+ const args = types.ListPipelineJobsByCategorySchema.parse(request.params.arguments);
253
+ const jobs = await pipelineJob.listPipelineJobsByCategoryFunc(args.organizationId, args.pipelineId, args.category);
254
+ return {
255
+ content: [{ type: "text", text: JSON.stringify(jobs, null, 2) }],
256
+ };
257
+ }
258
+ case "list_pipeline_job_historys": {
259
+ const args = types.ListPipelineJobHistorysSchema.parse(request.params.arguments);
260
+ const jobHistorys = await pipelineJob.listPipelineJobHistorysFunc(args.organizationId, args.pipelineId, args.category, args.identifier, args.page, args.perPage);
261
+ return {
262
+ content: [{ type: "text", text: JSON.stringify(jobHistorys, null, 2) }],
263
+ };
264
+ }
265
+ case "execute_pipeline_job_run": {
266
+ const args = types.ExecutePipelineJobRunSchema.parse(request.params.arguments);
267
+ const result = await pipelineJob.executePipelineJobRunFunc(args.organizationId, args.pipelineId, args.pipelineRunId, args.jobId);
268
+ return {
269
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
270
+ };
271
+ }
272
+ case "get_pipeline_job_run_log": {
273
+ const args = types.GetPipelineJobRunLogSchema.parse(request.params.arguments);
274
+ const log = await pipelineJob.getPipelineJobRunLogFunc(args.organizationId, args.pipelineId, args.pipelineRunId, args.jobId);
275
+ return {
276
+ content: [{ type: "text", text: JSON.stringify(log, null, 2) }],
277
+ };
278
+ }
279
+ case "update_pipeline": {
280
+ const args = types.UpdatePipelineSchema.parse(request.params.arguments);
281
+ const result = await pipeline.updatePipelineFunc(args.organizationId, args.pipelineId, args.name, args.content);
282
+ return {
283
+ content: [{ type: "text", text: JSON.stringify({ success: result }) }]
284
+ };
285
+ }
286
+ default:
287
+ return null;
288
+ }
289
+ };