-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathadd_assignees.ts
More file actions
151 lines (142 loc) · 4.75 KB
/
Copy pathadd_assignees.ts
File metadata and controls
151 lines (142 loc) · 4.75 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import type { AddAssigneesParams, IssueResponse } from '@/tools/github/types'
import type { ToolConfig } from '@/tools/types'
export const addAssigneesTool: ToolConfig<AddAssigneesParams, IssueResponse> = {
id: 'github_add_assignees',
name: 'GitHub Add Assignees',
description: 'Add assignees to an issue in a GitHub repository',
version: '1.0.0',
params: {
owner: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Repository owner',
},
repo: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Repository name',
},
issue_number: {
type: 'number',
required: true,
visibility: 'user-or-llm',
description: 'Issue number',
},
assignees: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Comma-separated list of usernames to assign to the issue',
},
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'GitHub API token',
},
},
request: {
url: (params) =>
`https://api.github.com/repos/${params.owner}/${params.repo}/issues/${params.issue_number}/assignees`,
method: 'POST',
headers: (params) => ({
Accept: 'application/vnd.github.v3+json',
Authorization: `Bearer ${params.apiKey}`,
'X-GitHub-Api-Version': '2022-11-28',
}),
body: (params) => {
const assigneesArray = params.assignees
.split(',')
.map((a) => a.trim())
.filter((a) => a)
return {
assignees: assigneesArray,
}
},
},
transformResponse: async (response) => {
const issue = await response.json()
const labels = issue.labels?.map((label: any) => label.name) || []
const assignees = issue.assignees?.map((assignee: any) => assignee.login) || []
const content = `Assignees added to issue #${issue.number}: "${issue.title}"
All assignees: ${assignees.join(', ')}
URL: ${issue.html_url}`
return {
success: true,
output: {
content,
metadata: {
number: issue.number,
title: issue.title,
state: issue.state,
html_url: issue.html_url,
labels,
assignees,
created_at: issue.created_at,
updated_at: issue.updated_at,
body: issue.body,
},
},
}
},
outputs: {
content: { type: 'string', description: 'Human-readable assignees confirmation' },
metadata: {
type: 'object',
description: 'Updated issue metadata with assignees',
properties: {
number: { type: 'number', description: 'Issue number' },
title: { type: 'string', description: 'Issue title' },
state: { type: 'string', description: 'Issue state (open/closed)' },
html_url: { type: 'string', description: 'GitHub web URL' },
labels: { type: 'array', description: 'Array of label names' },
assignees: { type: 'array', description: 'All assignees on the issue' },
created_at: { type: 'string', description: 'Creation timestamp' },
updated_at: { type: 'string', description: 'Last update timestamp' },
body: { type: 'string', description: 'Issue body/description' },
},
},
},
}
export const addAssigneesV2Tool: ToolConfig<AddAssigneesParams, any> = {
id: 'github_add_assignees_v2',
name: addAssigneesTool.name,
description: addAssigneesTool.description,
version: '2.0.0',
params: addAssigneesTool.params,
request: addAssigneesTool.request,
transformResponse: async (response: Response) => {
const issue = await response.json()
return {
success: true,
output: {
id: issue.id,
number: issue.number,
title: issue.title,
state: issue.state,
html_url: issue.html_url,
body: issue.body ?? null,
user: issue.user,
labels: issue.labels ?? [],
assignees: issue.assignees ?? [],
created_at: issue.created_at,
updated_at: issue.updated_at,
},
}
},
outputs: {
id: { type: 'number', description: 'Issue ID' },
number: { type: 'number', description: 'Issue number' },
title: { type: 'string', description: 'Issue title' },
state: { type: 'string', description: 'Issue state' },
html_url: { type: 'string', description: 'GitHub web URL' },
body: { type: 'string', description: 'Issue body', optional: true },
user: { type: 'json', description: 'Issue creator' },
labels: { type: 'array', description: 'Array of label objects' },
assignees: { type: 'array', description: 'Array of assignee objects' },
created_at: { type: 'string', description: 'Creation timestamp' },
updated_at: { type: 'string', description: 'Last update timestamp' },
},
}