-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathcreate_issue_note.ts
More file actions
96 lines (89 loc) · 2.47 KB
/
Copy pathcreate_issue_note.ts
File metadata and controls
96 lines (89 loc) · 2.47 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
import type { GitLabCreateIssueNoteParams, GitLabCreateNoteResponse } from '@/tools/gitlab/types'
import { getGitLabApiBase } from '@/tools/gitlab/utils'
import type { ToolConfig } from '@/tools/types'
export const gitlabCreateIssueNoteTool: ToolConfig<
GitLabCreateIssueNoteParams,
GitLabCreateNoteResponse
> = {
id: 'gitlab_create_issue_note',
name: 'GitLab Create Issue Comment',
description: 'Add a comment to a GitLab issue',
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)',
},
issueIid: {
type: 'number',
required: true,
visibility: 'user-or-llm',
description: 'Issue internal ID (IID)',
},
body: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Comment body (Markdown supported)',
},
internal: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Create the comment as an internal note visible only to project members',
},
},
request: {
url: (params) => {
const encodedId = encodeURIComponent(String(params.projectId).trim())
return `${getGitLabApiBase(params.host)}/projects/${encodedId}/issues/${params.issueIid}/notes`
},
method: 'POST',
headers: (params) => ({
'Content-Type': 'application/json',
'PRIVATE-TOKEN': params.accessToken,
}),
body: (params) => {
const body: Record<string, unknown> = { body: params.body }
if (params.internal !== undefined) body.internal = params.internal
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 note = await response.json()
return {
success: true,
output: {
note,
},
}
},
outputs: {
note: {
type: 'object',
description: 'The created comment',
},
},
}