-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathcreate_issue.ts
More file actions
127 lines (118 loc) · 3.55 KB
/
Copy pathcreate_issue.ts
File metadata and controls
127 lines (118 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import type { GitLabCreateIssueParams, GitLabCreateIssueResponse } from '@/tools/gitlab/types'
import { getGitLabApiBase } from '@/tools/gitlab/utils'
import type { ToolConfig } from '@/tools/types'
export const gitlabCreateIssueTool: ToolConfig<GitLabCreateIssueParams, GitLabCreateIssueResponse> =
{
id: 'gitlab_create_issue',
name: 'GitLab Create Issue',
description: 'Create a new issue in a GitLab project',
version: '1.0.0',
params: {
accessToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'GitLab Personal Access Token',
},
host: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Self-managed GitLab host (e.g. gitlab.example.com). Defaults to gitlab.com.',
},
projectId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Project ID or path (e.g. mygroup/myproject)',
},
title: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Issue title',
},
description: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Issue description (Markdown supported)',
},
labels: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Comma-separated list of label names',
},
assigneeIds: {
type: 'array',
required: false,
visibility: 'user-or-llm',
description: 'Array of user IDs to assign',
},
milestoneId: {
type: 'number',
required: false,
visibility: 'user-or-llm',
description: 'Milestone ID to assign',
},
dueDate: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Due date in YYYY-MM-DD format',
},
confidential: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Whether the issue is confidential',
},
},
request: {
url: (params) => {
const encodedId = encodeURIComponent(String(params.projectId).trim())
return `${getGitLabApiBase(params.host)}/projects/${encodedId}/issues`
},
method: 'POST',
headers: (params) => ({
'Content-Type': 'application/json',
'PRIVATE-TOKEN': params.accessToken,
}),
body: (params) => {
const body: Record<string, any> = {
title: params.title,
}
if (params.description) body.description = params.description
if (params.labels) body.labels = params.labels
if (params.assigneeIds) body.assignee_ids = params.assigneeIds
if (params.milestoneId) body.milestone_id = params.milestoneId
if (params.dueDate) body.due_date = params.dueDate
if (params.confidential !== undefined) body.confidential = params.confidential
return body
},
},
transformResponse: async (response) => {
if (!response.ok) {
const errorText = await response.text()
return {
success: false,
error: `GitLab API error: ${response.status} ${errorText}`,
output: {},
}
}
const issue = await response.json()
return {
success: true,
output: {
issue,
},
}
},
outputs: {
issue: {
type: 'object',
description: 'The created GitLab issue',
},
},
}