@sentry/junior-linear 0.301.0 → 0.303.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 CHANGED
@@ -1 +1,3 @@
1
- export { linearPlugin } from "./plugin.js";
1
+ import { PluginRegistration } from "@sentry/junior-plugin-api";
2
+ /** Register Linear's hosted MCP provider and conversation-link side effects. */
3
+ export declare function linearPlugin(): PluginRegistration;
package/dist/index.js CHANGED
@@ -1,359 +1,334 @@
1
- // src/plugin.ts
2
- import {
3
- defineJuniorPlugin
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
- import {
9
- eventMatchFieldsSchema
10
- } from "@sentry/junior-plugin-api";
11
- var LINEAR_ISSUE_EVENTS = ["issue.created"];
12
- var LINEAR_ISSUE_MATCH_FIELDS = eventMatchFieldsSchema.parse({
13
- issueIdentifier: {
14
- kind: "string",
15
- case: "upper",
16
- description: "uppercase Linear issue identifier, such as SRE-123",
17
- events: [...LINEAR_ISSUE_EVENTS]
18
- },
19
- teamKey: {
20
- kind: "string",
21
- case: "upper",
22
- description: "uppercase Linear team key for the issue, such as SRE",
23
- events: [...LINEAR_ISSUE_EVENTS]
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
- const identifier = input.identifier.toUpperCase();
28
- return {
29
- identifier,
30
- label: `Linear issue ${identifier}`,
31
- namespace: "linear"
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
- const teamKey = input.teamKey.toUpperCase();
36
- return {
37
- identifier: teamKey,
38
- label: `Linear team ${teamKey}`,
39
- namespace: "linear"
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
- import * as z from "zod";
48
- var issueWebhookSchema = z.object({
49
- action: z.string(),
50
- createdAt: z.string().optional(),
51
- data: z.object({
52
- assignee: z.object({ name: z.string().optional() }).passthrough().optional().nullable(),
53
- description: z.string().optional().nullable(),
54
- id: z.string().min(1),
55
- identifier: z.string().trim().min(1),
56
- labels: z.array(z.object({ name: z.string().min(1) }).passthrough()).optional(),
57
- priorityLabel: z.string().optional(),
58
- project: z.object({ name: z.string().optional() }).passthrough().optional().nullable(),
59
- state: z.object({ name: z.string().optional() }).passthrough().optional().nullable(),
60
- team: z.object({ key: z.string().trim().min(1) }).passthrough().optional(),
61
- teamKey: z.string().trim().min(1).optional(),
62
- title: z.string().optional(),
63
- url: z.url()
64
- }).passthrough(),
65
- type: z.string(),
66
- url: z.url().optional(),
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
- const labels = issue.labels?.map((label) => label.name).join(", ");
71
- const parts = [
72
- issue.title ? `Title: ${issue.title}` : void 0,
73
- issue.description ? `Description: ${issue.description}` : void 0,
74
- issue.state?.name ? `State: ${issue.state.name}` : void 0,
75
- issue.priorityLabel ? `Priority: ${issue.priorityLabel}` : void 0,
76
- issue.project?.name ? `Project: ${issue.project.name}` : void 0,
77
- labels ? `Labels: ${labels}` : void 0,
78
- issue.assignee?.name ? `Assignee: ${issue.assignee.name}` : void 0,
79
- `URL: ${issue.url}`
80
- ].filter((part) => part !== void 0);
81
- return parts.length > 0 ? parts.join("\n") : void 0;
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
- var issueEventDataSchema = z.object({
84
- issueId: z.string().min(1),
85
- issueIdentifier: z.string().min(1).toUpperCase(),
86
- teamKey: z.string().min(1).toUpperCase(),
87
- url: z.url()
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
- const createdAt = input.createdAt ? Date.parse(input.createdAt) : Number.NaN;
91
- if (Number.isFinite(createdAt)) return createdAt;
92
- if (Number.isFinite(input.webhookTimestamp)) return input.webhookTimestamp;
93
- return Date.now();
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
- 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") {
99
- return [];
100
- }
101
- const issue = parsed.data.data;
102
- const teamKey = issue.team?.key ?? issue.teamKey;
103
- if (!teamKey) return [];
104
- const issueResource = linearIssueResource({ identifier: issue.identifier });
105
- const teamResource = linearTeamResource({ teamKey });
106
- const eventType = "issue.created";
107
- const event = {
108
- eventKey: `linear:${issue.id}:${eventType}`,
109
- eventType,
110
- occurredAtMs: occurredAtMs(parsed.data),
111
- trustedSummary: `${issueResource.label} was created.`,
112
- data: issueEventDataSchema.parse({
113
- issueId: issue.id,
114
- issueIdentifier: issue.identifier,
115
- teamKey,
116
- url: issue.url
117
- }),
118
- untrustedText: issueText(issue)
119
- };
120
- return [
121
- { ...event, identifier: issueResource.identifier },
122
- { ...event, identifier: teamResource.identifier }
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
- if (!secret || !/^[0-9a-f]{64}$/i.test(signature)) return false;
129
- const actual = Buffer.from(signature.toLowerCase());
130
- const expected = Buffer.from(
131
- createHmac("sha256", secret).update(body).digest("hex")
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
- try {
137
- return JSON.parse(body);
138
- } catch {
139
- return void 0;
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
- return {
144
- method: "POST",
145
- path: "/api/webhooks/linear",
146
- async handler(request) {
147
- const rawBody = await request.text();
148
- const signature = request.headers.get("linear-signature") ?? "";
149
- if (!verifyLinearSignature(rawBody, signature, args.webhookSecret())) {
150
- return new Response("Unauthorized", { status: 401 });
151
- }
152
- const body = parseJson(rawBody);
153
- if (body === void 0) {
154
- return new Response("Malformed Linear webhook", { status: 400 });
155
- }
156
- const delivery = request.headers.get("linear-delivery")?.trim();
157
- const linearEvent = request.headers.get("linear-event")?.trim();
158
- if (!delivery || !linearEvent) {
159
- return new Response("Malformed Linear webhook headers", {
160
- status: 400
161
- });
162
- }
163
- const events = normalizeLinearEvents({ body, linearEvent });
164
- for (const event of events) {
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
- return process.env.LINEAR_WEBHOOK_SECRET?.trim() || void 0;
168
+ return process.env["LINEAR_WEBHOOK_SECRET"]?.trim() || void 0;
177
169
  }
178
-
179
170
  // src/plugin.ts
180
- var namedFact = z2.union([z2.string(), z2.object({ name: z2.string() })]).nullish();
181
- var short = (value) => {
182
- const text = value?.trim();
183
- return text ? text.length > 64 ? `${text.slice(0, 63)}\u2026` : text : void 0;
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
- var factName = (value) => short(typeof value === "string" ? value : value?.name);
186
- var issueIdentifier = z2.string().trim().regex(/^[a-z][a-z0-9]*-\d+$/i);
187
- var savedIssueSchema = z2.object({
188
- identifier: issueIdentifier.optional(),
189
- id: z2.string().optional(),
190
- url: z2.url(),
191
- title: z2.string().optional(),
192
- description: z2.string().nullish(),
193
- status: z2.string().optional(),
194
- assignee: namedFact,
195
- priority: z2.union([z2.string(), z2.number(), z2.object({ name: z2.string() })]).nullish(),
196
- project: namedFact,
197
- cycle: namedFact,
198
- labels: z2.array(namedFact).nullish(),
199
- dueDate: z2.iso.date().nullish(),
200
- updatedAt: z2.iso.datetime({ offset: true }).nullish()
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
- const identifier = issueIdentifier.safeParse(issue.identifier ?? issue.id);
203
- if (!identifier.success) {
204
- ctx.addIssue({ code: "custom", message: "Missing issue identifier" });
205
- return z2.NEVER;
206
- }
207
- return { ...issue, identifier: identifier.data.toUpperCase() };
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
- var LINEAR_SERVICE_ACCOUNT_TOOLS = [
210
- "extract_images",
211
- "get_attachment",
212
- "get_document",
213
- "get_issue",
214
- "get_issue_status",
215
- "get_milestone",
216
- "get_project",
217
- "get_team",
218
- "get_user",
219
- "list_comments",
220
- "list_cycles",
221
- "list_documents",
222
- "list_issue_labels",
223
- "list_issue_statuses",
224
- "list_issues",
225
- "list_milestones",
226
- "list_project_labels",
227
- "list_projects",
228
- "list_teams",
229
- "list_users",
230
- "search_documentation"
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
- var saveIssueResultSchema = z2.union([
233
- savedIssueSchema,
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
- if (result.structuredContent !== void 0) {
238
- return saveIssueResultSchema.safeParse(result.structuredContent);
239
- }
240
- for (const part of result.content ?? []) {
241
- if (part.type !== "text") continue;
242
- let value;
243
- try {
244
- value = JSON.parse(part.text);
245
- } catch (error) {
246
- if (error instanceof SyntaxError) continue;
247
- throw error;
248
- }
249
- const parsed = saveIssueResultSchema.safeParse(value);
250
- if (parsed.success) return parsed;
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
- if (ctx.tool.name !== "save_issue") {
256
- return;
257
- }
258
- if (!ctx.annotations) {
259
- return;
260
- }
261
- const result = readSavedIssue(ctx.result);
262
- if (!result.success) {
263
- ctx.log.warn("linear.issue_annotation.skipped", {
264
- "app.reason": "unexpected_save_response"
265
- });
266
- return;
267
- }
268
- const issue = result.data;
269
- const identifier = issue.identifier;
270
- return {
271
- objectAnnotations: [
272
- {
273
- kind: "object",
274
- objectType: "task",
275
- key: identifier,
276
- label: identifier,
277
- title: (issue.title || identifier).slice(0, 512),
278
- description: issue.description?.slice(0, 4e3),
279
- url: issue.url,
280
- status: issue.status,
281
- displayType: "Issue",
282
- sourceUpdatedAt: issue.updatedAt ?? void 0,
283
- facts: {
284
- type: "task",
285
- assignees: issue.assignee === void 0 ? void 0 : factName(issue.assignee) ? [factName(issue.assignee)] : [],
286
- priority: typeof issue.priority === "number" ? ["No priority", "Urgent", "High", "Normal", "Low"][issue.priority] : factName(issue.priority),
287
- project: factName(issue.project),
288
- cycle: factName(issue.cycle),
289
- dueDate: issue.dueDate ?? void 0,
290
- labels: issue.labels?.slice(0, 5).map((label) => factName(label)).filter(Boolean)
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
- return defineJuniorPlugin({
298
- packageName: "@sentry/junior-linear",
299
- events: {
300
- resourceTypes: [
301
- {
302
- type: "issue",
303
- supportedEvents: [...LINEAR_ISSUE_EVENTS],
304
- suggestedEvents: [...LINEAR_ISSUE_EVENTS],
305
- matchFields: LINEAR_ISSUE_MATCH_FIELDS
306
- },
307
- {
308
- type: "team",
309
- supportedEvents: [...LINEAR_ISSUE_EVENTS],
310
- suggestedEvents: [...LINEAR_ISSUE_EVENTS],
311
- matchFields: LINEAR_ISSUE_MATCH_FIELDS
312
- }
313
- ],
314
- // An issue carries its title and description, and a team can be
315
- // private. So a trigger with no identifier must name its team or one
316
- // issue.
317
- events: Object.fromEntries(
318
- LINEAR_ISSUE_EVENTS.map((eventType) => [
319
- eventType,
320
- { reach: { anyOf: ["teamKey", "issueIdentifier"] } }
321
- ])
322
- ),
323
- isEnabled: () => Boolean(linearWebhookSecret()),
324
- normalizeIdentifier: (identifier) => identifier.toUpperCase()
325
- },
326
- manifest: {
327
- // Optional shared read account. It has no effect until an admin
328
- // connects it on the dashboard Admin page.
329
- accounts: {
330
- serviceAccount: { tools: [...LINEAR_SERVICE_ACCOUNT_TOOLS] }
331
- },
332
- configKeys: ["team", "project"],
333
- description: "Linear issue tracking via hosted MCP server and issue webhooks",
334
- displayName: "Linear",
335
- envVars: {
336
- LINEAR_WEBHOOK_SECRET: {}
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.301.0",
3
+ "version": "0.303.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
- "zod": "^4.6.7",
26
- "@sentry/junior-plugin-api": "0.301.0"
25
+ "@sentry/junior-plugin-api": "0.303.0",
26
+ "zod": "^4.6.7"
27
27
  },
28
28
  "devDependencies": {
29
- "@oxlint/plugins": "1.79.0",
30
- "@types/node": "^25.9.1",
31
- "oxlint": "^1.79.0",
32
- "tsup": "^8.5.1",
33
- "typescript": "^7.0.2",
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": "tsup && tsc -p tsconfig.build.json --emitDeclarationOnly",
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
  }
@@ -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,3 +0,0 @@
1
- import { type PluginRegistration } from "@sentry/junior-plugin-api";
2
- /** Register Linear's hosted MCP provider and conversation-link side effects. */
3
- export declare function linearPlugin(): PluginRegistration;
@@ -1,6 +0,0 @@
1
- import type { EventInput } from "@sentry/junior-plugin-api";
2
- /** Normalize one verified Linear webhook into issue- and team-scoped events. */
3
- export declare function normalizeLinearEvents(input: {
4
- body: unknown;
5
- linearEvent: string;
6
- }): EventInput[];
@@ -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;
@@ -1,2 +0,0 @@
1
- /** Read the secret used to verify Linear webhook deliveries. */
2
- export declare function linearWebhookSecret(): string | undefined;