-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Expand file tree
/
Copy pathcreate_project_link.ts
More file actions
123 lines (112 loc) · 2.81 KB
/
create_project_link.ts
File metadata and controls
123 lines (112 loc) · 2.81 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
import type {
LinearCreateProjectLinkParams,
LinearCreateProjectLinkResponse,
} from '@/tools/linear/types'
import type { ToolConfig } from '@/tools/types'
export const linearCreateProjectLinkTool: ToolConfig<
LinearCreateProjectLinkParams,
LinearCreateProjectLinkResponse
> = {
id: 'linear_create_project_link',
name: 'Linear Create Project Link',
description: 'Add an external link to a project in Linear',
version: '1.0.0',
oauth: {
required: true,
provider: 'linear',
},
params: {
projectId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Project ID to add link to',
},
url: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'URL of the external link',
},
label: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Link label/title',
},
},
request: {
url: 'https://api.linear.app/graphql',
method: 'POST',
headers: (params) => {
if (!params.accessToken) {
throw new Error('Missing access token for Linear API request')
}
return {
'Content-Type': 'application/json',
Authorization: `Bearer ${params.accessToken}`,
}
},
body: (params) => {
const input: Record<string, any> = {
projectId: params.projectId,
url: params.url,
}
if (params.label != null && params.label !== '') input.label = params.label
return {
query: `
mutation CreateProjectLink($input: ProjectLinkCreateInput!) {
projectLinkCreate(input: $input) {
success
projectLink {
id
url
label
createdAt
}
}
}
`,
variables: {
input,
},
}
},
},
transformResponse: async (response) => {
const data = await response.json()
if (data.errors) {
return {
success: false,
error: data.errors[0]?.message || 'Failed to create project link',
output: {},
}
}
const result = data.data.projectLinkCreate
if (!result.success) {
return {
success: false,
error: 'Project link creation was not successful',
output: {},
}
}
return {
success: true,
output: {
link: result.projectLink,
},
}
},
outputs: {
link: {
type: 'object',
description: 'The created project link',
properties: {
id: { type: 'string', description: 'Link ID' },
url: { type: 'string', description: 'Link URL' },
label: { type: 'string', description: 'Link label' },
createdAt: { type: 'string', description: 'Creation timestamp' },
},
},
},
}