@sentry/junior-linear 0.302.0 → 0.304.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.
- package/dist/index.d.ts +3 -1
- package/dist/index.js +298 -323
- package/package.json +9 -12
- package/dist/events/issue.d.ts +0 -22
- package/dist/plugin.d.ts +0 -3
- package/dist/webhooks/events.d.ts +0 -6
- package/dist/webhooks/handler.d.ts +0 -6
- package/dist/webhooks/secret.d.ts +0 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,359 +1,334 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
} from "@sentry/junior-plugin-api";
|
|
5
|
-
import * as z2 from "zod";
|
|
6
|
-
|
|
1
|
+
import { defineJuniorPlugin, eventMatchFieldsSchema } from "@sentry/junior-plugin-api";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
7
4
|
// src/events/issue.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
const LINEAR_ISSUE_EVENTS = ["issue.created"];
|
|
6
|
+
/**
|
|
7
|
+
* Exact values that every Linear issue event sets. `issueIdentifier` and
|
|
8
|
+
* `teamKey` are uppercase, the same form as identifiers.
|
|
9
|
+
*/
|
|
10
|
+
const LINEAR_ISSUE_MATCH_FIELDS = eventMatchFieldsSchema.parse({
|
|
11
|
+
issueIdentifier: {
|
|
12
|
+
kind: "string",
|
|
13
|
+
case: "upper",
|
|
14
|
+
description: "uppercase Linear issue identifier, such as SRE-123",
|
|
15
|
+
events: [...LINEAR_ISSUE_EVENTS]
|
|
16
|
+
},
|
|
17
|
+
teamKey: {
|
|
18
|
+
kind: "string",
|
|
19
|
+
case: "upper",
|
|
20
|
+
description: "uppercase Linear team key for the issue, such as SRE",
|
|
21
|
+
events: [...LINEAR_ISSUE_EVENTS]
|
|
22
|
+
}
|
|
25
23
|
});
|
|
24
|
+
/** Build the stable Linear issue identity shared by tools and webhooks. */
|
|
26
25
|
function linearIssueResource(input) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const identifier = input.identifier.toUpperCase();
|
|
27
|
+
return {
|
|
28
|
+
identifier,
|
|
29
|
+
label: `Linear issue ${identifier}`,
|
|
30
|
+
namespace: "linear"
|
|
31
|
+
};
|
|
33
32
|
}
|
|
33
|
+
/** Build the stable Linear team identity used for team-scoped events. */
|
|
34
34
|
function linearTeamResource(input) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
const teamKey = input.teamKey.toUpperCase();
|
|
36
|
+
return {
|
|
37
|
+
identifier: teamKey,
|
|
38
|
+
label: `Linear team ${teamKey}`,
|
|
39
|
+
namespace: "linear"
|
|
40
|
+
};
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
// src/webhooks/handler.ts
|
|
44
|
-
import { createHmac, timingSafeEqual } from "crypto";
|
|
45
|
-
|
|
46
42
|
// src/webhooks/events.ts
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
webhookTimestamp: z.number().finite().optional()
|
|
43
|
+
const issueWebhookSchema = z.object({
|
|
44
|
+
action: z.string(),
|
|
45
|
+
createdAt: z.string().optional(),
|
|
46
|
+
data: z.object({
|
|
47
|
+
assignee: z.object({ name: z.string().optional() }).passthrough().optional().nullable(),
|
|
48
|
+
description: z.string().optional().nullable(),
|
|
49
|
+
id: z.string().min(1),
|
|
50
|
+
identifier: z.string().trim().min(1),
|
|
51
|
+
labels: z.array(z.object({ name: z.string().min(1) }).passthrough()).optional(),
|
|
52
|
+
priorityLabel: z.string().optional(),
|
|
53
|
+
project: z.object({ name: z.string().optional() }).passthrough().optional().nullable(),
|
|
54
|
+
state: z.object({ name: z.string().optional() }).passthrough().optional().nullable(),
|
|
55
|
+
team: z.object({ key: z.string().trim().min(1) }).passthrough().optional(),
|
|
56
|
+
teamKey: z.string().trim().min(1).optional(),
|
|
57
|
+
title: z.string().optional(),
|
|
58
|
+
url: z.url()
|
|
59
|
+
}).passthrough(),
|
|
60
|
+
type: z.string(),
|
|
61
|
+
url: z.url().optional(),
|
|
62
|
+
webhookTimestamp: z.number().finite().optional()
|
|
68
63
|
}).passthrough();
|
|
69
64
|
function issueText(issue) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
65
|
+
const labels = issue.labels?.map((label) => label.name).join(", ");
|
|
66
|
+
const parts = [
|
|
67
|
+
issue.title ? `Title: ${issue.title}` : void 0,
|
|
68
|
+
issue.description ? `Description: ${issue.description}` : void 0,
|
|
69
|
+
issue.state?.name ? `State: ${issue.state.name}` : void 0,
|
|
70
|
+
issue.priorityLabel ? `Priority: ${issue.priorityLabel}` : void 0,
|
|
71
|
+
issue.project?.name ? `Project: ${issue.project.name}` : void 0,
|
|
72
|
+
labels ? `Labels: ${labels}` : void 0,
|
|
73
|
+
issue.assignee?.name ? `Assignee: ${issue.assignee.name}` : void 0,
|
|
74
|
+
`URL: ${issue.url}`
|
|
75
|
+
].filter((part) => part !== void 0);
|
|
76
|
+
return parts.length > 0 ? parts.join("\n") : void 0;
|
|
82
77
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Trusted data on every issue event. `issueIdentifier` and `teamKey` are
|
|
80
|
+
* uppercase, the same form as identifiers.
|
|
81
|
+
*/
|
|
82
|
+
const issueEventDataSchema = z.object({
|
|
83
|
+
issueId: z.string().min(1),
|
|
84
|
+
issueIdentifier: z.string().min(1).toUpperCase(),
|
|
85
|
+
teamKey: z.string().min(1).toUpperCase(),
|
|
86
|
+
url: z.url()
|
|
88
87
|
}).strict();
|
|
89
88
|
function occurredAtMs(input) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
const createdAt = input.createdAt ? Date.parse(input.createdAt) : NaN;
|
|
90
|
+
if (Number.isFinite(createdAt)) return createdAt;
|
|
91
|
+
if (Number.isFinite(input.webhookTimestamp)) return input.webhookTimestamp;
|
|
92
|
+
return Date.now();
|
|
94
93
|
}
|
|
94
|
+
/** Normalize one verified Linear webhook into issue- and team-scoped events. */
|
|
95
95
|
function normalizeLinearEvents(input) {
|
|
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
|
-
|
|
96
|
+
if (input.linearEvent.toLowerCase() !== "issue") return [];
|
|
97
|
+
const parsed = issueWebhookSchema.safeParse(input.body);
|
|
98
|
+
if (!parsed.success || parsed.data.action !== "create" || parsed.data.type.toLowerCase() !== "issue") return [];
|
|
99
|
+
const issue = parsed.data.data;
|
|
100
|
+
const teamKey = issue.team?.key ?? issue.teamKey;
|
|
101
|
+
if (!teamKey) return [];
|
|
102
|
+
const issueResource = linearIssueResource({ identifier: issue.identifier });
|
|
103
|
+
const teamResource = linearTeamResource({ teamKey });
|
|
104
|
+
const eventType = "issue.created";
|
|
105
|
+
const event = {
|
|
106
|
+
eventKey: `linear:${issue.id}:${eventType}`,
|
|
107
|
+
eventType,
|
|
108
|
+
occurredAtMs: occurredAtMs(parsed.data),
|
|
109
|
+
trustedSummary: `${issueResource.label} was created.`,
|
|
110
|
+
data: issueEventDataSchema.parse({
|
|
111
|
+
issueId: issue.id,
|
|
112
|
+
issueIdentifier: issue.identifier,
|
|
113
|
+
teamKey,
|
|
114
|
+
url: issue.url
|
|
115
|
+
}),
|
|
116
|
+
untrustedText: issueText(issue)
|
|
117
|
+
};
|
|
118
|
+
return [{
|
|
119
|
+
...event,
|
|
120
|
+
identifier: issueResource.identifier
|
|
121
|
+
}, {
|
|
122
|
+
...event,
|
|
123
|
+
identifier: teamResource.identifier
|
|
124
|
+
}];
|
|
124
125
|
}
|
|
125
|
-
|
|
126
126
|
// src/webhooks/handler.ts
|
|
127
127
|
function verifyLinearSignature(body, signature, secret) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
);
|
|
133
|
-
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
128
|
+
if (!secret || !/^[0-9a-f]{64}$/i.test(signature)) return false;
|
|
129
|
+
const actual = Buffer.from(signature.toLowerCase());
|
|
130
|
+
const expected = Buffer.from(createHmac("sha256", secret).update(body).digest("hex"));
|
|
131
|
+
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
134
132
|
}
|
|
135
133
|
function parseJson(body) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
134
|
+
try {
|
|
135
|
+
return JSON.parse(body);
|
|
136
|
+
} catch {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
141
139
|
}
|
|
140
|
+
/** Create the public, signed Linear event webhook route. */
|
|
142
141
|
function createLinearWebhookRoute(args) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
await args.events.publish({ ...event, objectType: "task" });
|
|
166
|
-
}
|
|
167
|
-
return new Response(events.length ? "Accepted" : "Ignored", {
|
|
168
|
-
status: 200
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
};
|
|
142
|
+
return {
|
|
143
|
+
method: "POST",
|
|
144
|
+
path: "/api/webhooks/linear",
|
|
145
|
+
async handler(request) {
|
|
146
|
+
const rawBody = await request.text();
|
|
147
|
+
if (!verifyLinearSignature(rawBody, request.headers.get("linear-signature") ?? "", args.webhookSecret())) return new Response("Unauthorized", { status: 401 });
|
|
148
|
+
const body = parseJson(rawBody);
|
|
149
|
+
if (body === void 0) return new Response("Malformed Linear webhook", { status: 400 });
|
|
150
|
+
const delivery = request.headers.get("linear-delivery")?.trim();
|
|
151
|
+
const linearEvent = request.headers.get("linear-event")?.trim();
|
|
152
|
+
if (!delivery || !linearEvent) return new Response("Malformed Linear webhook headers", { status: 400 });
|
|
153
|
+
const events = normalizeLinearEvents({
|
|
154
|
+
body,
|
|
155
|
+
linearEvent
|
|
156
|
+
});
|
|
157
|
+
for (const event of events) await args.events.publish({
|
|
158
|
+
...event,
|
|
159
|
+
objectType: "task"
|
|
160
|
+
});
|
|
161
|
+
return new Response(events.length ? "Accepted" : "Ignored", { status: 200 });
|
|
162
|
+
}
|
|
163
|
+
};
|
|
172
164
|
}
|
|
173
|
-
|
|
174
165
|
// src/webhooks/secret.ts
|
|
166
|
+
/** Read the secret used to verify Linear webhook deliveries. */
|
|
175
167
|
function linearWebhookSecret() {
|
|
176
|
-
|
|
168
|
+
return process.env["LINEAR_WEBHOOK_SECRET"]?.trim() || void 0;
|
|
177
169
|
}
|
|
178
|
-
|
|
179
170
|
// src/plugin.ts
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
171
|
+
const namedFact = z.union([z.string(), z.object({ name: z.string() })]).nullish();
|
|
172
|
+
const short = (value) => {
|
|
173
|
+
const text = value?.trim();
|
|
174
|
+
return text ? text.length > 64 ? `${text.slice(0, 63)}…` : text : void 0;
|
|
184
175
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
176
|
+
const factName = (value) => short(typeof value === "string" ? value : value?.name);
|
|
177
|
+
const issueIdentifier = z.string().trim().regex(/^[a-z][a-z0-9]*-\d+$/i);
|
|
178
|
+
const savedIssueSchema = z.object({
|
|
179
|
+
identifier: issueIdentifier.optional(),
|
|
180
|
+
id: z.string().optional(),
|
|
181
|
+
url: z.url(),
|
|
182
|
+
title: z.string().optional(),
|
|
183
|
+
description: z.string().nullish(),
|
|
184
|
+
status: z.string().optional(),
|
|
185
|
+
assignee: namedFact,
|
|
186
|
+
priority: z.union([
|
|
187
|
+
z.string(),
|
|
188
|
+
z.number(),
|
|
189
|
+
z.object({ name: z.string() })
|
|
190
|
+
]).nullish(),
|
|
191
|
+
project: namedFact,
|
|
192
|
+
cycle: namedFact,
|
|
193
|
+
labels: z.array(namedFact).nullish(),
|
|
194
|
+
dueDate: z.iso.date().nullish(),
|
|
195
|
+
updatedAt: z.iso.datetime({ offset: true }).nullish()
|
|
201
196
|
}).transform((issue, ctx) => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
197
|
+
const identifier = issueIdentifier.safeParse(issue.identifier ?? issue.id);
|
|
198
|
+
if (!identifier.success) {
|
|
199
|
+
ctx.addIssue({
|
|
200
|
+
code: "custom",
|
|
201
|
+
message: "Missing issue identifier"
|
|
202
|
+
});
|
|
203
|
+
return z.NEVER;
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
...issue,
|
|
207
|
+
identifier: identifier.data.toUpperCase()
|
|
208
|
+
};
|
|
208
209
|
});
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
210
|
+
/** Read-only Linear MCP tools that the optional service account may call. */
|
|
211
|
+
const LINEAR_SERVICE_ACCOUNT_TOOLS = [
|
|
212
|
+
"extract_images",
|
|
213
|
+
"get_attachment",
|
|
214
|
+
"get_document",
|
|
215
|
+
"get_issue",
|
|
216
|
+
"get_issue_status",
|
|
217
|
+
"get_milestone",
|
|
218
|
+
"get_project",
|
|
219
|
+
"get_team",
|
|
220
|
+
"get_user",
|
|
221
|
+
"list_comments",
|
|
222
|
+
"list_cycles",
|
|
223
|
+
"list_documents",
|
|
224
|
+
"list_issue_labels",
|
|
225
|
+
"list_issue_statuses",
|
|
226
|
+
"list_issues",
|
|
227
|
+
"list_milestones",
|
|
228
|
+
"list_project_labels",
|
|
229
|
+
"list_projects",
|
|
230
|
+
"list_teams",
|
|
231
|
+
"list_users",
|
|
232
|
+
"search_documentation"
|
|
231
233
|
];
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
z2.object({ issue: savedIssueSchema }).transform(({ issue }) => issue)
|
|
235
|
-
]);
|
|
234
|
+
const saveIssueResultSchema = z.union([savedIssueSchema, z.object({ issue: savedIssueSchema }).transform(({ issue }) => issue)]);
|
|
235
|
+
/** Read Linear's JSON result without inferring issue facts from prose. */
|
|
236
236
|
function readSavedIssue(result) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
return saveIssueResultSchema.safeParse(void 0);
|
|
237
|
+
if (result.structuredContent !== void 0) return saveIssueResultSchema.safeParse(result.structuredContent);
|
|
238
|
+
for (const part of result.content ?? []) {
|
|
239
|
+
if (part.type !== "text") continue;
|
|
240
|
+
let value;
|
|
241
|
+
try {
|
|
242
|
+
value = JSON.parse(part.text);
|
|
243
|
+
} catch (error) {
|
|
244
|
+
if (error instanceof SyntaxError) continue;
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
const parsed = saveIssueResultSchema.safeParse(value);
|
|
248
|
+
if (parsed.success) return parsed;
|
|
249
|
+
}
|
|
250
|
+
return saveIssueResultSchema.safeParse(void 0);
|
|
253
251
|
}
|
|
252
|
+
/** Link created and updated Linear issues to the current Junior conversation. */
|
|
254
253
|
async function annotateSavedIssue(ctx) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
]
|
|
294
|
-
};
|
|
254
|
+
if (ctx.tool.name !== "save_issue") return;
|
|
255
|
+
if (!ctx.annotations) return;
|
|
256
|
+
const result = readSavedIssue(ctx.result);
|
|
257
|
+
if (!result.success) {
|
|
258
|
+
ctx.log.warn("linear.issue_annotation.skipped", { "app.reason": "unexpected_save_response" });
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const issue = result.data;
|
|
262
|
+
const identifier = issue.identifier;
|
|
263
|
+
return { objectAnnotations: [{
|
|
264
|
+
kind: "object",
|
|
265
|
+
objectType: "task",
|
|
266
|
+
key: identifier,
|
|
267
|
+
label: identifier,
|
|
268
|
+
title: (issue.title || identifier).slice(0, 512),
|
|
269
|
+
description: issue.description?.slice(0, 4e3),
|
|
270
|
+
url: issue.url,
|
|
271
|
+
status: issue.status,
|
|
272
|
+
displayType: "Issue",
|
|
273
|
+
sourceUpdatedAt: issue.updatedAt ?? void 0,
|
|
274
|
+
facts: {
|
|
275
|
+
type: "task",
|
|
276
|
+
assignees: issue.assignee === void 0 ? void 0 : factName(issue.assignee) ? [factName(issue.assignee)] : [],
|
|
277
|
+
priority: typeof issue.priority === "number" ? [
|
|
278
|
+
"No priority",
|
|
279
|
+
"Urgent",
|
|
280
|
+
"High",
|
|
281
|
+
"Normal",
|
|
282
|
+
"Low"
|
|
283
|
+
][issue.priority] : factName(issue.priority),
|
|
284
|
+
project: factName(issue.project),
|
|
285
|
+
cycle: factName(issue.cycle),
|
|
286
|
+
dueDate: issue.dueDate ?? void 0,
|
|
287
|
+
labels: issue.labels?.slice(0, 5).map((label) => factName(label)).filter(Boolean)
|
|
288
|
+
}
|
|
289
|
+
}] };
|
|
295
290
|
}
|
|
291
|
+
/** Register Linear's hosted MCP provider and conversation-link side effects. */
|
|
296
292
|
function linearPlugin() {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
},
|
|
338
|
-
mcp: {
|
|
339
|
-
transport: "http",
|
|
340
|
-
url: "https://mcp.linear.app/mcp"
|
|
341
|
-
},
|
|
342
|
-
name: "linear"
|
|
343
|
-
},
|
|
344
|
-
hooks: {
|
|
345
|
-
afterMcpTool: annotateSavedIssue,
|
|
346
|
-
routes(ctx) {
|
|
347
|
-
return [
|
|
348
|
-
createLinearWebhookRoute({
|
|
349
|
-
events: ctx.events,
|
|
350
|
-
webhookSecret: linearWebhookSecret
|
|
351
|
-
})
|
|
352
|
-
];
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
});
|
|
293
|
+
return defineJuniorPlugin({
|
|
294
|
+
packageName: "@sentry/junior-linear",
|
|
295
|
+
events: {
|
|
296
|
+
resourceTypes: [{
|
|
297
|
+
type: "issue",
|
|
298
|
+
supportedEvents: [...LINEAR_ISSUE_EVENTS],
|
|
299
|
+
suggestedEvents: [...LINEAR_ISSUE_EVENTS],
|
|
300
|
+
matchFields: LINEAR_ISSUE_MATCH_FIELDS
|
|
301
|
+
}, {
|
|
302
|
+
type: "team",
|
|
303
|
+
supportedEvents: [...LINEAR_ISSUE_EVENTS],
|
|
304
|
+
suggestedEvents: [...LINEAR_ISSUE_EVENTS],
|
|
305
|
+
matchFields: LINEAR_ISSUE_MATCH_FIELDS
|
|
306
|
+
}],
|
|
307
|
+
events: Object.fromEntries(LINEAR_ISSUE_EVENTS.map((eventType) => [eventType, { reach: { anyOf: ["teamKey", "issueIdentifier"] } }])),
|
|
308
|
+
isEnabled: () => Boolean(linearWebhookSecret()),
|
|
309
|
+
normalizeIdentifier: (identifier) => identifier.toUpperCase()
|
|
310
|
+
},
|
|
311
|
+
manifest: {
|
|
312
|
+
accounts: { serviceAccount: { tools: [...LINEAR_SERVICE_ACCOUNT_TOOLS] } },
|
|
313
|
+
configKeys: ["team", "project"],
|
|
314
|
+
description: "Linear issue tracking via hosted MCP server and issue webhooks",
|
|
315
|
+
displayName: "Linear",
|
|
316
|
+
envVars: { LINEAR_WEBHOOK_SECRET: {} },
|
|
317
|
+
mcp: {
|
|
318
|
+
transport: "http",
|
|
319
|
+
url: "https://mcp.linear.app/mcp"
|
|
320
|
+
},
|
|
321
|
+
name: "linear"
|
|
322
|
+
},
|
|
323
|
+
hooks: {
|
|
324
|
+
afterMcpTool: annotateSavedIssue,
|
|
325
|
+
routes(ctx) {
|
|
326
|
+
return [createLinearWebhookRoute({
|
|
327
|
+
events: ctx.events,
|
|
328
|
+
webhookSecret: linearWebhookSecret
|
|
329
|
+
})];
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
356
333
|
}
|
|
357
|
-
export {
|
|
358
|
-
linearPlugin
|
|
359
|
-
};
|
|
334
|
+
export { linearPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-linear",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.304.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,21 +22,18 @@
|
|
|
22
22
|
"skills"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"@sentry/junior-plugin-api": "0.304.0",
|
|
26
|
+
"zod": "^4.6.7"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@types/node": "^
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"vitest": "^4.1.12",
|
|
35
|
-
"@sentry/junior-testing": "0.0.0"
|
|
29
|
+
"@sentry/junior-testing": "0.0.0",
|
|
30
|
+
"@types/node": "^24.19.2",
|
|
31
|
+
"tsdown": "0.23.7",
|
|
32
|
+
"typescript": "7.0.2",
|
|
33
|
+
"vitest": "^4.1.12"
|
|
36
34
|
},
|
|
37
35
|
"scripts": {
|
|
38
|
-
"build": "
|
|
39
|
-
"lint": "oxlint --config ../junior/.oxlintrc.json --deny-warnings src tests tsup.config.ts vitest.config.ts",
|
|
36
|
+
"build": "tsdown",
|
|
40
37
|
"test": "vitest run",
|
|
41
38
|
"typecheck": "tsc --noEmit"
|
|
42
39
|
}
|
package/dist/events/issue.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type SubscribableResource } from "@sentry/junior-plugin-api";
|
|
2
|
-
export declare const LINEAR_ISSUE_EVENTS: readonly ["issue.created"];
|
|
3
|
-
/**
|
|
4
|
-
* Exact values that every Linear issue event sets. `issueIdentifier` and
|
|
5
|
-
* `teamKey` are uppercase, the same form as identifiers.
|
|
6
|
-
*/
|
|
7
|
-
export declare const LINEAR_ISSUE_MATCH_FIELDS: Record<string, {
|
|
8
|
-
kind: "boolean" | "number" | "string";
|
|
9
|
-
description: string;
|
|
10
|
-
enum?: string[] | undefined;
|
|
11
|
-
list?: true | undefined;
|
|
12
|
-
case?: "lower" | "upper" | undefined;
|
|
13
|
-
events?: string[] | undefined;
|
|
14
|
-
}>;
|
|
15
|
-
/** Build the stable Linear issue identity shared by tools and webhooks. */
|
|
16
|
-
export declare function linearIssueResource(input: {
|
|
17
|
-
identifier: string;
|
|
18
|
-
}): Pick<SubscribableResource, "identifier" | "label" | "namespace">;
|
|
19
|
-
/** Build the stable Linear team identity used for team-scoped events. */
|
|
20
|
-
export declare function linearTeamResource(input: {
|
|
21
|
-
teamKey: string;
|
|
22
|
-
}): Pick<SubscribableResource, "identifier" | "label" | "namespace">;
|
package/dist/plugin.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { PluginRoute, EventPublisher } from "@sentry/junior-plugin-api";
|
|
2
|
-
/** Create the public, signed Linear event webhook route. */
|
|
3
|
-
export declare function createLinearWebhookRoute(args: {
|
|
4
|
-
events: EventPublisher;
|
|
5
|
-
webhookSecret(): string | undefined;
|
|
6
|
-
}): PluginRoute;
|