@sentry/junior-github 0.280.0 → 0.282.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.js CHANGED
@@ -59,7 +59,77 @@ import {
59
59
  readGrantPermissions,
60
60
  requireEnv,
61
61
  resolveUserAccount
62
- } from "./chunk-NSAVG2P3.js";
62
+ } from "./chunk-XOE6HDSA.js";
63
+
64
+ // src/tool-support/attribution.ts
65
+ import * as z from "zod";
66
+
67
+ // src/tool-support/github-api.ts
68
+ import {
69
+ PluginToolInputError
70
+ } from "@sentry/junior-plugin-api";
71
+ var GITHUB_API_BASE = "https://api.github.com";
72
+ async function githubApi(egress, input) {
73
+ const headers = {
74
+ Accept: "application/vnd.github+json",
75
+ "X-GitHub-Api-Version": input.apiVersion ?? "2022-11-28"
76
+ };
77
+ if (input.body !== void 0) headers["Content-Type"] = "application/json";
78
+ const response = await egress.fetch({
79
+ provider: "github",
80
+ operation: input.operation,
81
+ request: new Request(`${GITHUB_API_BASE}${input.path}`, {
82
+ method: input.method ?? "GET",
83
+ headers,
84
+ signal: input.signal,
85
+ ...input.body !== void 0 ? { body: JSON.stringify(input.body) } : void 0
86
+ })
87
+ });
88
+ return {
89
+ body: await readBody(response),
90
+ ok: response.ok,
91
+ status: response.status
92
+ };
93
+ }
94
+ async function readBody(response) {
95
+ const text2 = await response.text();
96
+ if (!text2) return void 0;
97
+ try {
98
+ return JSON.parse(text2);
99
+ } catch {
100
+ return text2;
101
+ }
102
+ }
103
+ function repoPath(repo) {
104
+ return `/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}`;
105
+ }
106
+ function parseRepo(value) {
107
+ const parts = value.split("/").map((part) => part.trim());
108
+ if (parts.length !== 2 || !parts[0] || !parts[1]) {
109
+ throw new PluginToolInputError('repo must use "owner/name" format');
110
+ }
111
+ return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
112
+ }
113
+ function githubErrorMessage(body) {
114
+ if (typeof body === "string" && body.trim()) return body.trim();
115
+ if (!isRecord2(body)) return "GitHub request failed";
116
+ const errors = Array.isArray(body.errors) ? body.errors.filter(isRecord2) : [];
117
+ if (typeof body.message === "string" && body.message.trim()) {
118
+ const details = errors.map(
119
+ (error) => ["resource", "field", "code", "message"].map((name) => {
120
+ const value = error[name];
121
+ return typeof value === "string" && value.trim() ? `${name}=${value.trim()}` : void 0;
122
+ }).filter(Boolean).join(" ")
123
+ ).filter(Boolean).join("; ");
124
+ const message = body.message.trim();
125
+ return details ? `${message}: ${details}` : message;
126
+ }
127
+ const graphqlMessages = errors.map((error) => error.message).filter((message) => typeof message === "string" && message.trim());
128
+ return graphqlMessages.length ? graphqlMessages.join("; ") : "GitHub request failed";
129
+ }
130
+ function isRecord2(value) {
131
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
132
+ }
63
133
 
64
134
  // src/tool-support/attribution.ts
65
135
  var GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
@@ -124,17 +194,25 @@ function formatAttributionBlock(labels) {
124
194
  via ${labels.join(", ")}.
125
195
  ${GITHUB_REQUEST_ATTRIBUTION_END}`;
126
196
  }
127
- function applyAttribution(body, label) {
197
+ var ATTRIBUTION_BLOCK = new RegExp(
198
+ `${GITHUB_REQUEST_ATTRIBUTION_START}([\\s\\S]*?)${GITHUB_REQUEST_ATTRIBUTION_END}`
199
+ );
200
+ function blockLabels(body) {
201
+ const contents = body?.match(ATTRIBUTION_BLOCK)?.[1];
202
+ return contents === void 0 ? [] : parseExistingLabels(contents);
203
+ }
204
+ function applyAttribution(body, label, currentBody) {
128
205
  const normalizedBody = body.trimEnd();
129
- const existing = new RegExp(
130
- `${GITHUB_REQUEST_ATTRIBUTION_START}([\\s\\S]*?)${GITHUB_REQUEST_ATTRIBUTION_END}`
131
- );
132
- const existingMatch = normalizedBody.match(existing);
133
- const existingLabels = existingMatch?.[1] !== void 0 ? parseExistingLabels(existingMatch[1]) : [];
134
- const labels = label && !existingLabels.includes(label) ? [...existingLabels, label] : existingLabels;
206
+ const labels = [
207
+ .../* @__PURE__ */ new Set([
208
+ ...blockLabels(currentBody),
209
+ ...blockLabels(normalizedBody),
210
+ ...label ? [label] : []
211
+ ])
212
+ ];
135
213
  const attribution = labels.length ? formatAttributionBlock(labels) : void 0;
136
- if (existingMatch) {
137
- return attribution ? normalizedBody.replace(existing, attribution) : normalizedBody.replace(existing, "").trimEnd();
214
+ if (ATTRIBUTION_BLOCK.test(normalizedBody)) {
215
+ return attribution ? normalizedBody.replace(ATTRIBUTION_BLOCK, attribution) : normalizedBody.replace(ATTRIBUTION_BLOCK, "").trimEnd();
138
216
  }
139
217
  if (!attribution) {
140
218
  return normalizedBody;
@@ -143,6 +221,15 @@ function applyAttribution(body, label) {
143
221
 
144
222
  ${attribution}` : attribution;
145
223
  }
224
+ async function readGitHubBody(egress, input) {
225
+ const response = await githubApi(egress, input);
226
+ if (!response.ok) {
227
+ throw new Error(
228
+ `GitHub read before update failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`
229
+ );
230
+ }
231
+ return z.object({ body: z.string().nullable().optional() }).parse(response.body).body ?? void 0;
232
+ }
146
233
  async function resolveGitHubRequester(ctx) {
147
234
  if (!ctx.actor || ctx.actor.platform === "system") return void 0;
148
235
  try {
@@ -154,7 +241,7 @@ async function resolveGitHubRequester(ctx) {
154
241
  return void 0;
155
242
  }
156
243
  }
157
- function appendGitHubRequesterAttribution(body, ctx, requester) {
244
+ function appendGitHubRequesterAttribution(body, ctx, requester, currentBody) {
158
245
  return applyAttribution(
159
246
  body,
160
247
  requesterLabel({
@@ -163,77 +250,11 @@ function appendGitHubRequesterAttribution(body, ctx, requester) {
163
250
  identity: requester?.identity,
164
251
  source: ctx.source,
165
252
  user: requester?.user
166
- })
253
+ }),
254
+ currentBody
167
255
  );
168
256
  }
169
257
 
170
- // src/tool-support/github-api.ts
171
- import {
172
- PluginToolInputError
173
- } from "@sentry/junior-plugin-api";
174
- var GITHUB_API_BASE = "https://api.github.com";
175
- async function githubApi(egress, input) {
176
- const headers = {
177
- Accept: "application/vnd.github+json",
178
- "X-GitHub-Api-Version": input.apiVersion ?? "2022-11-28"
179
- };
180
- if (input.body !== void 0) headers["Content-Type"] = "application/json";
181
- const response = await egress.fetch({
182
- provider: "github",
183
- operation: input.operation,
184
- request: new Request(`${GITHUB_API_BASE}${input.path}`, {
185
- method: input.method ?? "GET",
186
- headers,
187
- signal: input.signal,
188
- ...input.body !== void 0 ? { body: JSON.stringify(input.body) } : void 0
189
- })
190
- });
191
- return {
192
- body: await readBody(response),
193
- ok: response.ok,
194
- status: response.status
195
- };
196
- }
197
- async function readBody(response) {
198
- const text2 = await response.text();
199
- if (!text2) return void 0;
200
- try {
201
- return JSON.parse(text2);
202
- } catch {
203
- return text2;
204
- }
205
- }
206
- function repoPath(repo) {
207
- return `/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}`;
208
- }
209
- function parseRepo(value) {
210
- const parts = value.split("/").map((part) => part.trim());
211
- if (parts.length !== 2 || !parts[0] || !parts[1]) {
212
- throw new PluginToolInputError('repo must use "owner/name" format');
213
- }
214
- return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
215
- }
216
- function githubErrorMessage(body) {
217
- if (typeof body === "string" && body.trim()) return body.trim();
218
- if (!isRecord2(body)) return "GitHub request failed";
219
- const errors = Array.isArray(body.errors) ? body.errors.filter(isRecord2) : [];
220
- if (typeof body.message === "string" && body.message.trim()) {
221
- const details = errors.map(
222
- (error) => ["resource", "field", "code", "message"].map((name) => {
223
- const value = error[name];
224
- return typeof value === "string" && value.trim() ? `${name}=${value.trim()}` : void 0;
225
- }).filter(Boolean).join(" ")
226
- ).filter(Boolean).join("; ");
227
- const message = body.message.trim();
228
- return details ? `${message}: ${details}` : message;
229
- }
230
- const graphqlMessages = errors.map((error) => error.message).filter((message) => typeof message === "string" && message.trim());
231
- return graphqlMessages.length ? graphqlMessages.join("; ") : "GitHub request failed";
232
- }
233
- function isRecord2(value) {
234
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
235
- }
236
-
237
258
  // src/plugin.ts
238
259
  import {
239
260
  defineJuniorPlugin,
@@ -246,7 +267,7 @@ import {
246
267
  PluginToolInputError as PluginToolInputError2,
247
268
  pluginToolOutputSchema
248
269
  } from "@sentry/junior-plugin-api";
249
- import * as z from "zod";
270
+ import * as z2 from "zod";
250
271
 
251
272
  // src/sandbox-paths.ts
252
273
  var RESERVED_SANDBOX_DIRECTORIES = /* @__PURE__ */ new Set([
@@ -259,9 +280,9 @@ function isReservedSandboxDirectory(path) {
259
280
  }
260
281
 
261
282
  // src/tools/clone-repository.ts
262
- var inputSchema = z.object({
263
- repo: z.string().describe('Repository in "owner/name" format.'),
264
- directory: z.string().regex(/^(?:[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*)$/).refine(
283
+ var inputSchema = z2.object({
284
+ repo: z2.string().describe('Repository in "owner/name" format.'),
285
+ directory: z2.string().regex(/^(?:[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*)$/).refine(
265
286
  (value) => !value.split("/").some((part) => part === "." || part === ".."),
266
287
  {
267
288
  message: "Directory must be a relative path without . or .. segments."
@@ -269,18 +290,18 @@ var inputSchema = z.object({
269
290
  ).describe(
270
291
  "Optional destination directory under the sandbox root. Defaults to repos/{name}."
271
292
  ).optional(),
272
- allow_ad_hoc: z.boolean().optional().describe(
293
+ allow_ad_hoc: z2.boolean().optional().describe(
273
294
  "Set true in the default Sandbox to keep an intentional ad-hoc checkout when matching Workspaces exist. Prefer switchWorkspace; the checkout is already present after a successful switch."
274
295
  )
275
296
  }).strict();
276
- var cloneSchema = z.object({
277
- path: z.string(),
278
- repo: z.string(),
279
- note: z.string().optional()
297
+ var cloneSchema = z2.object({
298
+ path: z2.string(),
299
+ repo: z2.string(),
300
+ note: z2.string().optional()
280
301
  });
281
302
  var outputSchema = pluginToolOutputSchema.merge(
282
303
  cloneSchema.extend({
283
- target: z.literal("cloneRepository")
304
+ target: z2.literal("cloneRepository")
284
305
  })
285
306
  );
286
307
  function parseRepo2(value) {
@@ -455,21 +476,21 @@ import {
455
476
  PluginToolInputError as PluginToolInputError3,
456
477
  pluginToolOutputSchema as pluginToolOutputSchema2
457
478
  } from "@sentry/junior-plugin-api";
458
- import * as z2 from "zod";
459
- var inputSchema2 = z2.object({
460
- repo: z2.string().describe('Repository in "owner/name" format.'),
461
- number: z2.number().int().positive().describe("Pull request number."),
462
- body: z2.string().trim().min(1).describe("Comment text."),
463
- in_reply_to: z2.number().int().positive().optional().describe(
479
+ import * as z3 from "zod";
480
+ var inputSchema2 = z3.object({
481
+ repo: z3.string().describe('Repository in "owner/name" format.'),
482
+ number: z3.number().int().positive().describe("Pull request number."),
483
+ body: z3.string().trim().min(1).describe("Comment text."),
484
+ in_reply_to: z3.number().int().positive().optional().describe(
464
485
  "Inline review comment id. Set it to reply in that comment's thread. Omit it to comment on the pull request."
465
486
  )
466
487
  }).strict();
467
488
  var outputSchema2 = pluginToolOutputSchema2.extend({
468
- target: z2.literal("commentOnPullRequest"),
469
- repo: z2.string(),
470
- number: z2.number(),
471
- comment_id: z2.number(),
472
- url: z2.string()
489
+ target: z3.literal("commentOnPullRequest"),
490
+ repo: z3.string(),
491
+ number: z3.number(),
492
+ comment_id: z3.number(),
493
+ url: z3.string()
473
494
  });
474
495
  async function threadRootId(egress, prefix, commentId) {
475
496
  const response = await githubApi(egress, {
@@ -481,7 +502,7 @@ async function threadRootId(egress, prefix, commentId) {
481
502
  if (response.status === 404) throw new PluginToolInputError3(message);
482
503
  throw new Error(message);
483
504
  }
484
- const comment = z2.object({ in_reply_to_id: z2.number().nullish() }).parse(response.body);
505
+ const comment = z3.object({ in_reply_to_id: z3.number().nullish() }).parse(response.body);
485
506
  return comment.in_reply_to_id ?? commentId;
486
507
  }
487
508
  function createGitHubCommentOnPullRequestTool(egress) {
@@ -513,7 +534,7 @@ function createGitHubCommentOnPullRequestTool(egress) {
513
534
  }
514
535
  throw new Error(message);
515
536
  }
516
- const comment = z2.object({ id: z2.number(), html_url: z2.string() }).parse(response.body);
537
+ const comment = z3.object({ id: z3.number(), html_url: z3.string() }).parse(response.body);
517
538
  return {
518
539
  target: "commentOnPullRequest",
519
540
  repo: repo.ref,
@@ -526,21 +547,21 @@ function createGitHubCommentOnPullRequestTool(egress) {
526
547
  }
527
548
 
528
549
  // src/object-facts.ts
529
- import * as z3 from "zod";
530
- var person = z3.object({ login: z3.string() });
531
- var responseSchema = z3.object({
532
- body: z3.string().nullable().optional(),
550
+ import * as z4 from "zod";
551
+ var person = z4.object({ login: z4.string() });
552
+ var responseSchema = z4.object({
553
+ body: z4.string().nullable().optional(),
533
554
  user: person.nullable().optional(),
534
- requested_reviewers: z3.array(person).optional(),
535
- assignees: z3.array(person).optional(),
536
- labels: z3.array(z3.union([z3.string(), z3.object({ name: z3.string() })])).optional(),
537
- head: z3.object({ ref: z3.string() }).optional(),
538
- base: z3.object({ ref: z3.string() }).optional(),
539
- mergeable: z3.boolean().nullable().optional(),
540
- changed_files: z3.number().int().nonnegative().optional(),
541
- additions: z3.number().int().nonnegative().optional(),
542
- deletions: z3.number().int().nonnegative().optional(),
543
- updated_at: z3.iso.datetime({ offset: true }).optional()
555
+ requested_reviewers: z4.array(person).optional(),
556
+ assignees: z4.array(person).optional(),
557
+ labels: z4.array(z4.union([z4.string(), z4.object({ name: z4.string() })])).optional(),
558
+ head: z4.object({ ref: z4.string() }).optional(),
559
+ base: z4.object({ ref: z4.string() }).optional(),
560
+ mergeable: z4.boolean().nullable().optional(),
561
+ changed_files: z4.number().int().nonnegative().optional(),
562
+ additions: z4.number().int().nonnegative().optional(),
563
+ deletions: z4.number().int().nonnegative().optional(),
564
+ updated_at: z4.iso.datetime({ offset: true }).optional()
544
565
  });
545
566
  var short = (value) => {
546
567
  const text2 = value?.trim();
@@ -671,7 +692,7 @@ import {
671
692
  } from "@sentry/junior-plugin-api";
672
693
  import { Type } from "@sinclair/typebox";
673
694
  import { Value } from "@sinclair/typebox/value";
674
- import * as z4 from "zod";
695
+ import * as z5 from "zod";
675
696
 
676
697
  // src/tools/footer.ts
677
698
  import { PluginToolInputError as PluginToolInputError4 } from "@sentry/junior-plugin-api";
@@ -757,11 +778,11 @@ function githubLinkedIssues(body, repositoryFullName) {
757
778
  if (!body) return [];
758
779
  const references = /* @__PURE__ */ new Map();
759
780
  const add = (linkedRepository, rawNumber) => {
760
- const number22 = Number.parseInt(rawNumber, 10);
761
- if (!Number.isInteger(number22) || number22 <= 0) return;
781
+ const number23 = Number.parseInt(rawNumber, 10);
782
+ if (!Number.isInteger(number23) || number23 <= 0) return;
762
783
  const normalizedRepository = linkedRepository.toLowerCase();
763
- references.set(`${normalizedRepository}#${number22}`, {
764
- number: number22,
784
+ references.set(`${normalizedRepository}#${number23}`, {
785
+ number: number23,
765
786
  repositoryFullName: linkedRepository
766
787
  });
767
788
  };
@@ -824,11 +845,11 @@ var createIssueInputSchema = Type.Object(
824
845
  },
825
846
  { additionalProperties: false }
826
847
  );
827
- var createIssueToolInputSchema = z4.object({
828
- repo: z4.string().describe('Repository in "owner/name" format.'),
829
- title: z4.string().describe("Issue title."),
830
- body: z4.string().describe("Issue body. The runtime appends the conversation footer.").optional(),
831
- labels: z4.array(z4.string()).describe("Labels to apply to the issue.").optional()
848
+ var createIssueToolInputSchema = z5.object({
849
+ repo: z5.string().describe('Repository in "owner/name" format.'),
850
+ title: z5.string().describe("Issue title."),
851
+ body: z5.string().describe("Issue body. The runtime appends the conversation footer.").optional(),
852
+ labels: z5.array(z5.string()).describe("Labels to apply to the issue.").optional()
832
853
  }).strict();
833
854
  var createIssueStateSchema = Type.Union([
834
855
  Type.Object(
@@ -853,14 +874,14 @@ var createIssueStateSchema = Type.Union([
853
874
  { additionalProperties: false }
854
875
  )
855
876
  ]);
856
- var gitHubIssueDataSchema = z4.object({
857
- number: z4.number(),
877
+ var gitHubIssueDataSchema = z5.object({
878
+ number: z5.number(),
858
879
  subscribable: subscribableResourceSchema.optional(),
859
- url: z4.string()
880
+ url: z5.string()
860
881
  });
861
882
  var gitHubIssueOutputSchema = pluginToolOutputSchema3.merge(
862
883
  gitHubIssueDataSchema.extend({
863
- target: z4.literal("createIssue")
884
+ target: z5.literal("createIssue")
864
885
  })
865
886
  );
866
887
  function gitHubIssueToolResult(input, result, canSubscribe) {
@@ -1076,69 +1097,69 @@ import {
1076
1097
  pluginToolOutputSchema as pluginToolOutputSchema4,
1077
1098
  subscribableResourceSchema as subscribableResourceSchema2
1078
1099
  } from "@sentry/junior-plugin-api";
1079
- import * as z5 from "zod";
1080
- var commitShaSchema = z5.string().regex(/^[0-9a-f]{40}$/i);
1081
- var inputSchema3 = z5.object({
1082
- repo: z5.string().describe('Repository in "owner/name" format.'),
1100
+ import * as z6 from "zod";
1101
+ var commitShaSchema = z6.string().regex(/^[0-9a-f]{40}$/i);
1102
+ var inputSchema3 = z6.object({
1103
+ repo: z6.string().describe('Repository in "owner/name" format.'),
1083
1104
  commit_sha: commitShaSchema.describe(
1084
1105
  "Full 40-character Git commit SHA recorded by the deployment."
1085
1106
  ),
1086
- environment: z5.string().trim().min(1).describe(
1107
+ environment: z6.string().trim().min(1).describe(
1087
1108
  'Optional GitHub deployment environment, such as "Production". Omit to inspect and watch deployments for the commit across environments.'
1088
1109
  ).optional()
1089
1110
  }).strict();
1090
- var statusSchema = z5.object({
1091
- created_at: z5.string(),
1092
- creator: z5.string().nullable(),
1093
- description: z5.string().nullable(),
1094
- environment_url: z5.string().nullable(),
1095
- id: z5.number(),
1096
- log_url: z5.string().nullable(),
1097
- state: z5.string()
1111
+ var statusSchema = z6.object({
1112
+ created_at: z6.string(),
1113
+ creator: z6.string().nullable(),
1114
+ description: z6.string().nullable(),
1115
+ environment_url: z6.string().nullable(),
1116
+ id: z6.number(),
1117
+ log_url: z6.string().nullable(),
1118
+ state: z6.string()
1098
1119
  }).strict();
1099
- var deploymentSchema = z5.object({
1100
- created_at: z5.string(),
1101
- creator: z5.string().nullable(),
1102
- description: z5.string().nullable(),
1103
- environment: z5.string(),
1104
- id: z5.number(),
1120
+ var deploymentSchema = z6.object({
1121
+ created_at: z6.string(),
1122
+ creator: z6.string().nullable(),
1123
+ description: z6.string().nullable(),
1124
+ environment: z6.string(),
1125
+ id: z6.number(),
1105
1126
  latest_status: statusSchema.nullable(),
1106
- ref: z5.string(),
1127
+ ref: z6.string(),
1107
1128
  sha: commitShaSchema,
1108
- updated_at: z5.string(),
1109
- url: z5.string()
1129
+ updated_at: z6.string(),
1130
+ url: z6.string()
1110
1131
  }).strict();
1111
- var deploymentSourceSchema = z5.object({
1132
+ var deploymentSourceSchema = z6.object({
1112
1133
  commit_sha: commitShaSchema,
1113
1134
  deployment: deploymentSchema.nullable(),
1114
- environment: z5.string().nullable(),
1115
- repo: z5.string(),
1135
+ environment: z6.string().nullable(),
1136
+ repo: z6.string(),
1116
1137
  subscribable: subscribableResourceSchema2.optional()
1117
1138
  }).strict();
1118
1139
  var outputSchema3 = pluginToolOutputSchema4.merge(
1119
1140
  deploymentSourceSchema.extend({
1120
- target: z5.literal("getDeployment")
1141
+ target: z6.literal("getDeployment")
1121
1142
  })
1122
1143
  );
1123
- var providerCreatorSchema = z5.object({ login: z5.string() }).passthrough().nullable();
1124
- var providerDeploymentSchema = z5.object({
1125
- created_at: z5.string(),
1144
+ var providerCreatorSchema = z6.object({ login: z6.string() }).passthrough().nullable();
1145
+ var providerDeploymentSchema = z6.object({
1146
+ created_at: z6.string(),
1126
1147
  creator: providerCreatorSchema,
1127
- description: z5.string().nullable(),
1128
- environment: z5.string(),
1129
- id: z5.number(),
1130
- ref: z5.string(),
1148
+ description: z6.string().nullable(),
1149
+ environment: z6.string(),
1150
+ id: z6.number(),
1151
+ ref: z6.string(),
1131
1152
  sha: commitShaSchema,
1132
- updated_at: z5.string()
1153
+ updated_at: z6.string()
1133
1154
  }).passthrough();
1134
- var providerStatusSchema = z5.object({
1135
- created_at: z5.string(),
1155
+ var providerStatusSchema = z6.object({
1156
+ created_at: z6.string(),
1136
1157
  creator: providerCreatorSchema,
1137
- description: z5.string().nullable().optional(),
1138
- environment_url: z5.string().nullable().optional(),
1139
- id: z5.number(),
1140
- log_url: z5.string().nullable().optional(),
1141
- state: z5.string()
1158
+ description: z6.string().nullable().optional(),
1159
+ environment_url: z6.string().nullable().optional(),
1160
+ id: z6.number(),
1161
+ log_url: z6.string().nullable().optional(),
1162
+ state: z6.string()
1142
1163
  }).passthrough();
1143
1164
  function throwLookupError(target, status, body) {
1144
1165
  const message = `GitHub ${target} lookup failed with HTTP ${status}`;
@@ -1174,7 +1195,7 @@ function createGitHubGetDeploymentTool(ctx) {
1174
1195
  if (!deployments.ok) {
1175
1196
  throwLookupError("deployment", deployments.status, deployments.body);
1176
1197
  }
1177
- const providerDeployment = z5.array(providerDeploymentSchema).parse(deployments.body)[0];
1198
+ const providerDeployment = z6.array(providerDeploymentSchema).parse(deployments.body)[0];
1178
1199
  let deployment = null;
1179
1200
  if (providerDeployment) {
1180
1201
  const statuses = await githubApi(ctx.egress, {
@@ -1184,7 +1205,7 @@ function createGitHubGetDeploymentTool(ctx) {
1184
1205
  if (!statuses.ok) {
1185
1206
  throwLookupError("deployment status", statuses.status, statuses.body);
1186
1207
  }
1187
- const providerStatus = z5.array(providerStatusSchema).parse(statuses.body)[0];
1208
+ const providerStatus = z6.array(providerStatusSchema).parse(statuses.body)[0];
1188
1209
  deployment = {
1189
1210
  created_at: providerDeployment.created_at,
1190
1211
  creator: providerDeployment.creator?.login ?? null,
@@ -1227,19 +1248,123 @@ function createGitHubGetDeploymentTool(ctx) {
1227
1248
  });
1228
1249
  }
1229
1250
 
1230
- // src/tools/create-pull-request.ts
1251
+ // src/tools/get-issue.ts
1231
1252
  import {
1232
- objectFactsSchema as objectFactsSchema2,
1233
1253
  definePluginTool as definePluginTool5,
1234
- EgressAuthRequired as EgressAuthRequired2,
1235
1254
  PluginToolInputError as PluginToolInputError7,
1236
1255
  pluginToolOutputSchema as pluginToolOutputSchema5,
1237
- watchResultSchema,
1238
1256
  subscribableResourceSchema as subscribableResourceSchema3
1239
1257
  } from "@sentry/junior-plugin-api";
1258
+ import * as z7 from "zod";
1259
+ var CLAIM_NOTE = "If you start work on this issue, first claim it with github_updateIssue and assign_requester: true.";
1260
+ var inputSchema4 = z7.object({
1261
+ repo: z7.string().describe('Repository in "owner/name" format.'),
1262
+ number: z7.number().int().positive().describe("Issue number.")
1263
+ }).strict();
1264
+ var issueSchema = z7.object({
1265
+ assignees: z7.array(z7.string()),
1266
+ author: z7.string().optional(),
1267
+ body: z7.string().nullable(),
1268
+ comments: z7.number(),
1269
+ labels: z7.array(z7.string()),
1270
+ note: z7.string().optional(),
1271
+ number: z7.number(),
1272
+ state: z7.string(),
1273
+ subscribable: subscribableResourceSchema3.optional(),
1274
+ title: z7.string(),
1275
+ url: z7.string()
1276
+ });
1277
+ var outputSchema4 = pluginToolOutputSchema5.merge(
1278
+ issueSchema.extend({ target: z7.literal("getIssue") })
1279
+ );
1280
+ var providerIssueSchema = z7.object({
1281
+ assignees: z7.array(z7.object({ login: z7.string() })).nullish().transform((assignees) => assignees?.map(({ login }) => login) ?? []),
1282
+ body: z7.string().nullable().optional().default(null),
1283
+ comments: z7.number().optional().default(0),
1284
+ html_url: z7.string(),
1285
+ labels: z7.array(z7.object({ name: z7.string() })).optional().default([]).transform((labels) => labels.map(({ name }) => name)),
1286
+ number: z7.number(),
1287
+ state: z7.string(),
1288
+ title: z7.string(),
1289
+ user: z7.object({ login: z7.string() }).nullish()
1290
+ });
1291
+ function createGitHubGetIssueTool(ctx) {
1292
+ return definePluginTool5({
1293
+ annotations: {
1294
+ destructiveHint: false,
1295
+ idempotentHint: true,
1296
+ openWorldHint: true,
1297
+ readOnlyHint: true
1298
+ },
1299
+ description: "Get a GitHub issue. Read its comments with gh api repos/OWNER/REPO/issues/NUMBER/comments.",
1300
+ inputSchema: inputSchema4,
1301
+ outputSchema: outputSchema4,
1302
+ async execute(input) {
1303
+ const repo = parseRepo(input.repo);
1304
+ const [response, requester] = await Promise.all([
1305
+ githubApi(ctx.egress, {
1306
+ operation: "github.issue.get",
1307
+ path: `${repoPath(repo)}/issues/${input.number}`
1308
+ }),
1309
+ resolveGitHubRequester(ctx)
1310
+ ]);
1311
+ if (!response.ok) {
1312
+ const message = `GitHub issue lookup failed with HTTP ${response.status}`;
1313
+ if (response.status === 404) {
1314
+ throw new PluginToolInputError7(message);
1315
+ }
1316
+ throw new Error(message);
1317
+ }
1318
+ const issue = providerIssueSchema.parse(response.body);
1319
+ const login = linkedGitHubLogin(requester?.user)?.toLowerCase();
1320
+ const needsClaim = login !== void 0 && issue.state === "open" && !issue.assignees.some((assignee) => assignee.toLowerCase() === login);
1321
+ const subscribable = gitHubIssueSubscribable({
1322
+ canSubscribe: ctx.events.canSubscribe,
1323
+ number: issue.number,
1324
+ repo: repo.ref
1325
+ });
1326
+ return {
1327
+ objectAnnotations: [
1328
+ githubObjectAnnotation({
1329
+ ...githubObjectFacts("task", response.body),
1330
+ repo: repo.ref,
1331
+ number: issue.number,
1332
+ title: issue.title,
1333
+ url: issue.html_url,
1334
+ objectType: "task",
1335
+ status: issue.state
1336
+ })
1337
+ ],
1338
+ target: "getIssue",
1339
+ assignees: issue.assignees,
1340
+ ...issue.user ? { author: issue.user.login } : void 0,
1341
+ body: issue.body,
1342
+ comments: issue.comments,
1343
+ labels: issue.labels,
1344
+ ...needsClaim ? { note: CLAIM_NOTE } : void 0,
1345
+ number: issue.number,
1346
+ state: issue.state,
1347
+ ...subscribable ? { subscribable } : void 0,
1348
+ title: issue.title,
1349
+ url: issue.html_url
1350
+ };
1351
+ }
1352
+ });
1353
+ }
1354
+
1355
+ // src/tools/create-pull-request.ts
1356
+ import {
1357
+ objectFactsSchema as objectFactsSchema2,
1358
+ definePluginTool as definePluginTool6,
1359
+ EgressAuthRequired as EgressAuthRequired2,
1360
+ PluginToolInputError as PluginToolInputError8,
1361
+ pluginToolOutputSchema as pluginToolOutputSchema6,
1362
+ watchResultSchema,
1363
+ subscribableResourceSchema as subscribableResourceSchema4
1364
+ } from "@sentry/junior-plugin-api";
1240
1365
  import { Type as Type2 } from "@sinclair/typebox";
1241
1366
  import { Value as Value2 } from "@sinclair/typebox/value";
1242
- import * as z8 from "zod";
1367
+ import * as z10 from "zod";
1243
1368
 
1244
1369
  // src/pull-request-requesters/store.ts
1245
1370
  import { and, asc, eq, inArray, lt } from "drizzle-orm";
@@ -1254,18 +1379,18 @@ import {
1254
1379
  text,
1255
1380
  timestamp
1256
1381
  } from "drizzle-orm/pg-core";
1257
- import * as z6 from "zod";
1258
- var githubPullRequestStateSchema = z6.enum([
1382
+ import * as z8 from "zod";
1383
+ var githubPullRequestStateSchema = z8.enum([
1259
1384
  "closed_unmerged",
1260
1385
  "merged",
1261
1386
  "open"
1262
1387
  ]);
1263
- var githubPullRequestCommitCompositionSchema = z6.enum([
1388
+ var githubPullRequestCommitCompositionSchema = z8.enum([
1264
1389
  "junior_only",
1265
1390
  "mixed"
1266
1391
  ]);
1267
- var githubIssueStateSchema = z6.enum(["closed", "open"]);
1268
- var githubIssueStateReasonSchema = z6.enum([
1392
+ var githubIssueStateSchema = z8.enum(["closed", "open"]);
1393
+ var githubIssueStateReasonSchema = z8.enum([
1269
1394
  "completed",
1270
1395
  "duplicate",
1271
1396
  "not_planned",
@@ -1426,31 +1551,31 @@ async function listGitHubPullRequestOpeners(db, input) {
1426
1551
  }
1427
1552
 
1428
1553
  // src/tools/stack-pull-request.ts
1429
- import * as z7 from "zod";
1554
+ import * as z9 from "zod";
1430
1555
  var MAX_STACK_DEPTH = 10;
1431
1556
  var GITHUB_STACKS_API_VERSION = "2026-03-10";
1432
- var stackTargetSchema = z7.object({
1433
- number: z7.number().int().positive(),
1434
- head: z7.object({
1435
- repo: z7.object({ full_name: z7.string().min(1) }).nullable()
1557
+ var stackTargetSchema = z9.object({
1558
+ number: z9.number().int().positive(),
1559
+ head: z9.object({
1560
+ repo: z9.object({ full_name: z9.string().min(1) }).nullable()
1436
1561
  }),
1437
- base: z7.object({
1438
- ref: z7.string().min(1),
1439
- repo: z7.object({
1440
- default_branch: z7.string().min(1),
1441
- full_name: z7.string().min(1)
1562
+ base: z9.object({
1563
+ ref: z9.string().min(1),
1564
+ repo: z9.object({
1565
+ default_branch: z9.string().min(1),
1566
+ full_name: z9.string().min(1)
1442
1567
  })
1443
1568
  })
1444
1569
  });
1445
- var openPullRequestsSchema = z7.array(
1446
- z7.object({
1447
- number: z7.number().int().positive(),
1448
- base: z7.object({ ref: z7.string().min(1) })
1570
+ var openPullRequestsSchema = z9.array(
1571
+ z9.object({
1572
+ number: z9.number().int().positive(),
1573
+ base: z9.object({ ref: z9.string().min(1) })
1449
1574
  })
1450
1575
  );
1451
- var stackSchema = z7.object({
1452
- number: z7.number().int().positive(),
1453
- pull_requests: z7.array(z7.object({ number: z7.number().int().positive() }))
1576
+ var stackSchema = z9.object({
1577
+ number: z9.number().int().positive(),
1578
+ pull_requests: z9.array(z9.object({ number: z9.number().int().positive() }))
1454
1579
  });
1455
1580
  async function stackGitHubPullRequest(ctx, target) {
1456
1581
  const repo = target.base.repo.full_name;
@@ -1496,7 +1621,7 @@ async function stackGitHubPullRequest(ctx, target) {
1496
1621
  const stacks = await github(
1497
1622
  "github.stack.read",
1498
1623
  `${api}/stacks?pull_request=${parent.number}`,
1499
- z7.array(stackSchema)
1624
+ z9.array(stackSchema)
1500
1625
  );
1501
1626
  if (!stacks) return void 0;
1502
1627
  const stack = stacks[0];
@@ -1571,15 +1696,15 @@ var createPullRequestInputSchema = Type2.Object(
1571
1696
  },
1572
1697
  { additionalProperties: false }
1573
1698
  );
1574
- var createPullRequestToolInputSchema = z8.object({
1575
- repo: z8.string().describe('Repository in "owner/name" format.'),
1576
- title: z8.string().describe("Pull request title."),
1577
- head: z8.string().describe("Head branch or owner:branch ref."),
1578
- base: z8.string().describe("Base branch."),
1579
- body: z8.string().describe(
1699
+ var createPullRequestToolInputSchema = z10.object({
1700
+ repo: z10.string().describe('Repository in "owner/name" format.'),
1701
+ title: z10.string().describe("Pull request title."),
1702
+ head: z10.string().describe("Head branch or owner:branch ref."),
1703
+ base: z10.string().describe("Base branch."),
1704
+ body: z10.string().describe(
1580
1705
  "Pull request body. The runtime appends the conversation footer."
1581
1706
  ).optional(),
1582
- draft: z8.boolean().describe("Whether to open the pull request as a draft.").optional()
1707
+ draft: z10.boolean().describe("Whether to open the pull request as a draft.").optional()
1583
1708
  }).strict();
1584
1709
  var createPullRequestStateSchema = Type2.Union([
1585
1710
  Type2.Object(
@@ -1604,30 +1729,30 @@ var createPullRequestStateSchema = Type2.Union([
1604
1729
  { additionalProperties: false }
1605
1730
  )
1606
1731
  ]);
1607
- var gitHubPullRequestDataSchema = z8.object({
1608
- number: z8.number(),
1609
- url: z8.string(),
1610
- stack: z8.object({ number: z8.number(), pull_requests: z8.array(z8.number()) }).optional(),
1611
- subscribable: subscribableResourceSchema3.optional(),
1732
+ var gitHubPullRequestDataSchema = z10.object({
1733
+ number: z10.number(),
1734
+ url: z10.string(),
1735
+ stack: z10.object({ number: z10.number(), pull_requests: z10.array(z10.number()) }).optional(),
1736
+ subscribable: subscribableResourceSchema4.optional(),
1612
1737
  subscription: watchResultSchema.optional()
1613
1738
  });
1614
- var gitHubPullRequestOutputSchema = pluginToolOutputSchema5.merge(
1739
+ var gitHubPullRequestOutputSchema = pluginToolOutputSchema6.merge(
1615
1740
  gitHubPullRequestDataSchema.extend({
1616
- target: z8.literal("createPullRequest")
1741
+ target: z10.literal("createPullRequest")
1617
1742
  })
1618
1743
  );
1619
1744
  function parseCreatePullRequestInput(input) {
1620
1745
  try {
1621
1746
  return Value2.Parse(createPullRequestInputSchema, input);
1622
1747
  } catch (error) {
1623
- throw new PluginToolInputError7("Invalid GitHub createPullRequest input.", {
1748
+ throw new PluginToolInputError8("Invalid GitHub createPullRequest input.", {
1624
1749
  cause: error
1625
1750
  });
1626
1751
  }
1627
1752
  }
1628
1753
  function nonEmptyString3(value, name) {
1629
1754
  if (!value?.trim()) {
1630
- throw new PluginToolInputError7(`${name} is required`);
1755
+ throw new PluginToolInputError8(`${name} is required`);
1631
1756
  }
1632
1757
  return value.trim();
1633
1758
  }
@@ -1816,7 +1941,7 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
1816
1941
  }
1817
1942
  }
1818
1943
  function createGitHubPullRequestTool(ctx, subscriptionConfig) {
1819
- return definePluginTool5({
1944
+ return definePluginTool6({
1820
1945
  annotations: {
1821
1946
  destructiveHint: false,
1822
1947
  idempotentHint: true,
@@ -1935,36 +2060,36 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
1935
2060
 
1936
2061
  // src/tools/get-pull-request.ts
1937
2062
  import {
1938
- definePluginTool as definePluginTool6,
1939
- PluginToolInputError as PluginToolInputError8,
1940
- pluginToolOutputSchema as pluginToolOutputSchema6
2063
+ definePluginTool as definePluginTool7,
2064
+ PluginToolInputError as PluginToolInputError9,
2065
+ pluginToolOutputSchema as pluginToolOutputSchema7
1941
2066
  } from "@sentry/junior-plugin-api";
1942
- import * as z9 from "zod";
1943
- import { subscribableResourceSchema as subscribableResourceSchema4 } from "@sentry/junior-plugin-api";
1944
- var commitShaSchema2 = z9.string().regex(/^[0-9a-f]{40}$/i);
1945
- var inputSchema4 = z9.object({
1946
- repo: z9.string().describe('Repository in "owner/name" format.'),
1947
- number: z9.number().int().positive().describe("Pull request number.")
2067
+ import * as z11 from "zod";
2068
+ import { subscribableResourceSchema as subscribableResourceSchema5 } from "@sentry/junior-plugin-api";
2069
+ var commitShaSchema2 = z11.string().regex(/^[0-9a-f]{40}$/i);
2070
+ var inputSchema5 = z11.object({
2071
+ repo: z11.string().describe('Repository in "owner/name" format.'),
2072
+ number: z11.number().int().positive().describe("Pull request number.")
1948
2073
  }).strict();
1949
- var pullRequestSchema = z9.object({
1950
- base: z9.string(),
1951
- draft: z9.boolean(),
1952
- head: z9.string(),
2074
+ var pullRequestSchema = z11.object({
2075
+ base: z11.string(),
2076
+ draft: z11.boolean(),
2077
+ head: z11.string(),
1953
2078
  head_sha: commitShaSchema2,
1954
- merged: z9.boolean(),
1955
- number: z9.number(),
1956
- state: z9.string(),
1957
- subscribable: subscribableResourceSchema4.optional(),
1958
- title: z9.string(),
1959
- url: z9.string()
2079
+ merged: z11.boolean(),
2080
+ number: z11.number(),
2081
+ state: z11.string(),
2082
+ subscribable: subscribableResourceSchema5.optional(),
2083
+ title: z11.string(),
2084
+ url: z11.string()
1960
2085
  });
1961
- var outputSchema4 = pluginToolOutputSchema6.merge(
2086
+ var outputSchema5 = pluginToolOutputSchema7.merge(
1962
2087
  pullRequestSchema.extend({
1963
- target: z9.literal("getPullRequest")
2088
+ target: z11.literal("getPullRequest")
1964
2089
  })
1965
2090
  );
1966
2091
  function createGitHubGetPullRequestTool(ctx) {
1967
- return definePluginTool6({
2092
+ return definePluginTool7({
1968
2093
  annotations: {
1969
2094
  destructiveHint: false,
1970
2095
  idempotentHint: true,
@@ -1972,8 +2097,8 @@ function createGitHubGetPullRequestTool(ctx) {
1972
2097
  readOnlyHint: true
1973
2098
  },
1974
2099
  description: "Get a GitHub pull request. Use this when an existing PR may need event monitoring; the result includes a subscribable hint when GitHub webhooks are configured.",
1975
- inputSchema: inputSchema4,
1976
- outputSchema: outputSchema4,
2100
+ inputSchema: inputSchema5,
2101
+ outputSchema: outputSchema5,
1977
2102
  async execute(input) {
1978
2103
  const repo = parseRepo(input.repo);
1979
2104
  const response = await githubApi(ctx.egress, {
@@ -1983,19 +2108,19 @@ function createGitHubGetPullRequestTool(ctx) {
1983
2108
  if (!response.ok) {
1984
2109
  const message = `GitHub pull request lookup failed with HTTP ${response.status}`;
1985
2110
  if (response.status === 404) {
1986
- throw new PluginToolInputError8(message);
2111
+ throw new PluginToolInputError9(message);
1987
2112
  }
1988
2113
  throw new Error(message);
1989
2114
  }
1990
- const providerResult = z9.object({
1991
- base: z9.object({ ref: z9.string() }),
1992
- draft: z9.boolean(),
1993
- head: z9.object({ ref: z9.string(), sha: commitShaSchema2 }),
1994
- html_url: z9.string(),
1995
- merged: z9.boolean().optional().default(false),
1996
- number: z9.number(),
1997
- state: z9.string(),
1998
- title: z9.string()
2115
+ const providerResult = z11.object({
2116
+ base: z11.object({ ref: z11.string() }),
2117
+ draft: z11.boolean(),
2118
+ head: z11.object({ ref: z11.string(), sha: commitShaSchema2 }),
2119
+ html_url: z11.string(),
2120
+ merged: z11.boolean().optional().default(false),
2121
+ number: z11.number(),
2122
+ state: z11.string(),
2123
+ title: z11.string()
1999
2124
  }).parse(response.body);
2000
2125
  const subscribable = gitHubPullRequestSubscribable({
2001
2126
  canSubscribe: ctx.events.canSubscribe,
@@ -2035,49 +2160,49 @@ function createGitHubGetPullRequestTool(ctx) {
2035
2160
 
2036
2161
  // src/tools/get-release.ts
2037
2162
  import {
2038
- definePluginTool as definePluginTool7,
2039
- pluginToolOutputSchema as pluginToolOutputSchema7,
2040
- subscribableResourceSchema as subscribableResourceSchema5
2163
+ definePluginTool as definePluginTool8,
2164
+ pluginToolOutputSchema as pluginToolOutputSchema8,
2165
+ subscribableResourceSchema as subscribableResourceSchema6
2041
2166
  } from "@sentry/junior-plugin-api";
2042
- import * as z10 from "zod";
2043
- var inputSchema5 = z10.object({
2044
- repo: z10.string().describe('Repository in "owner/name" format.'),
2045
- tag: z10.string().trim().min(1).describe(
2167
+ import * as z12 from "zod";
2168
+ var inputSchema6 = z12.object({
2169
+ repo: z12.string().describe('Repository in "owner/name" format.'),
2170
+ tag: z12.string().trim().min(1).describe(
2046
2171
  "Optional release tag name. Omit to inspect and watch every published release in the repository."
2047
2172
  ).optional()
2048
2173
  }).strict();
2049
- var releaseSchema = z10.object({
2050
- created_at: z10.string(),
2051
- draft: z10.boolean(),
2052
- html_url: z10.string(),
2053
- id: z10.number(),
2054
- name: z10.string().nullable(),
2055
- prerelease: z10.boolean(),
2056
- published_at: z10.string().nullable(),
2057
- tag_name: z10.string(),
2058
- target_commitish: z10.string()
2174
+ var releaseSchema = z12.object({
2175
+ created_at: z12.string(),
2176
+ draft: z12.boolean(),
2177
+ html_url: z12.string(),
2178
+ id: z12.number(),
2179
+ name: z12.string().nullable(),
2180
+ prerelease: z12.boolean(),
2181
+ published_at: z12.string().nullable(),
2182
+ tag_name: z12.string(),
2183
+ target_commitish: z12.string()
2059
2184
  }).strict();
2060
- var releaseSourceSchema = z10.object({
2185
+ var releaseSourceSchema = z12.object({
2061
2186
  release: releaseSchema.nullable(),
2062
- repo: z10.string(),
2063
- subscribable: subscribableResourceSchema5.optional(),
2064
- tag: z10.string().nullable()
2187
+ repo: z12.string(),
2188
+ subscribable: subscribableResourceSchema6.optional(),
2189
+ tag: z12.string().nullable()
2065
2190
  }).strict();
2066
- var outputSchema5 = pluginToolOutputSchema7.merge(
2191
+ var outputSchema6 = pluginToolOutputSchema8.merge(
2067
2192
  releaseSourceSchema.extend({
2068
- target: z10.literal("getRelease")
2193
+ target: z12.literal("getRelease")
2069
2194
  })
2070
2195
  );
2071
- var providerReleaseSchema = z10.object({
2072
- created_at: z10.string(),
2073
- draft: z10.boolean(),
2074
- html_url: z10.string(),
2075
- id: z10.number(),
2076
- name: z10.string().nullable(),
2077
- prerelease: z10.boolean(),
2078
- published_at: z10.string().nullable(),
2079
- tag_name: z10.string(),
2080
- target_commitish: z10.string()
2196
+ var providerReleaseSchema = z12.object({
2197
+ created_at: z12.string(),
2198
+ draft: z12.boolean(),
2199
+ html_url: z12.string(),
2200
+ id: z12.number(),
2201
+ name: z12.string().nullable(),
2202
+ prerelease: z12.boolean(),
2203
+ published_at: z12.string().nullable(),
2204
+ tag_name: z12.string(),
2205
+ target_commitish: z12.string()
2081
2206
  }).passthrough();
2082
2207
  function mapRelease(providerRelease) {
2083
2208
  return {
@@ -2093,7 +2218,7 @@ function mapRelease(providerRelease) {
2093
2218
  };
2094
2219
  }
2095
2220
  function createGitHubGetReleaseTool(ctx) {
2096
- return definePluginTool7({
2221
+ return definePluginTool8({
2097
2222
  annotations: {
2098
2223
  destructiveHint: false,
2099
2224
  idempotentHint: true,
@@ -2101,8 +2226,8 @@ function createGitHubGetReleaseTool(ctx) {
2101
2226
  readOnlyHint: true
2102
2227
  },
2103
2228
  description: "Get a GitHub release for an exact repository, optionally limited to one tag. The result remains subscribable when no release exists yet, so use it before waiting for a published release. Omit the tag to watch every published release in the repository.",
2104
- inputSchema: inputSchema5,
2105
- outputSchema: outputSchema5,
2229
+ inputSchema: inputSchema6,
2230
+ outputSchema: outputSchema6,
2106
2231
  async execute(input) {
2107
2232
  const repo = parseRepo(input.repo);
2108
2233
  const tag = input.tag?.trim() || void 0;
@@ -2155,30 +2280,30 @@ function createGitHubGetReleaseTool(ctx) {
2155
2280
 
2156
2281
  // src/tools/get-repository.ts
2157
2282
  import {
2158
- definePluginTool as definePluginTool8,
2159
- PluginToolInputError as PluginToolInputError9,
2160
- pluginToolOutputSchema as pluginToolOutputSchema8,
2161
- subscribableResourceSchema as subscribableResourceSchema6
2283
+ definePluginTool as definePluginTool9,
2284
+ PluginToolInputError as PluginToolInputError10,
2285
+ pluginToolOutputSchema as pluginToolOutputSchema9,
2286
+ subscribableResourceSchema as subscribableResourceSchema7
2162
2287
  } from "@sentry/junior-plugin-api";
2163
- import * as z11 from "zod";
2164
- var inputSchema6 = z11.object({
2165
- repo: z11.string().describe('Repository in "owner/name" format.')
2288
+ import * as z13 from "zod";
2289
+ var inputSchema7 = z13.object({
2290
+ repo: z13.string().describe('Repository in "owner/name" format.')
2166
2291
  }).strict();
2167
- var repositorySchema = z11.object({
2168
- default_branch: z11.string(),
2169
- description: z11.string().nullable(),
2170
- full_name: z11.string(),
2171
- private: z11.boolean(),
2172
- subscribable: subscribableResourceSchema6.optional(),
2173
- url: z11.string()
2292
+ var repositorySchema = z13.object({
2293
+ default_branch: z13.string(),
2294
+ description: z13.string().nullable(),
2295
+ full_name: z13.string(),
2296
+ private: z13.boolean(),
2297
+ subscribable: subscribableResourceSchema7.optional(),
2298
+ url: z13.string()
2174
2299
  });
2175
- var outputSchema6 = pluginToolOutputSchema8.merge(
2300
+ var outputSchema7 = pluginToolOutputSchema9.merge(
2176
2301
  repositorySchema.extend({
2177
- target: z11.literal("getRepository")
2302
+ target: z13.literal("getRepository")
2178
2303
  })
2179
2304
  );
2180
2305
  function createGitHubGetRepositoryTool(ctx) {
2181
- return definePluginTool8({
2306
+ return definePluginTool9({
2182
2307
  annotations: {
2183
2308
  destructiveHint: false,
2184
2309
  idempotentHint: true,
@@ -2186,8 +2311,8 @@ function createGitHubGetRepositoryTool(ctx) {
2186
2311
  readOnlyHint: true
2187
2312
  },
2188
2313
  description: "Get a GitHub repository. Use this when repository-wide issue activity may need event monitoring; the result includes a subscribable hint when GitHub webhooks are configured.",
2189
- inputSchema: inputSchema6,
2190
- outputSchema: outputSchema6,
2314
+ inputSchema: inputSchema7,
2315
+ outputSchema: outputSchema7,
2191
2316
  async execute(input) {
2192
2317
  const repo = parseRepo(input.repo);
2193
2318
  const response = await githubApi(ctx.egress, {
@@ -2195,16 +2320,16 @@ function createGitHubGetRepositoryTool(ctx) {
2195
2320
  path: repoPath(repo)
2196
2321
  });
2197
2322
  if (!response.ok) {
2198
- throw new PluginToolInputError9(
2323
+ throw new PluginToolInputError10(
2199
2324
  `GitHub repository lookup failed with HTTP ${response.status}`
2200
2325
  );
2201
2326
  }
2202
- const providerResult = z11.object({
2203
- default_branch: z11.string(),
2204
- description: z11.string().nullable(),
2205
- full_name: z11.string(),
2206
- html_url: z11.string(),
2207
- private: z11.boolean()
2327
+ const providerResult = z13.object({
2328
+ default_branch: z13.string(),
2329
+ description: z13.string().nullable(),
2330
+ full_name: z13.string(),
2331
+ html_url: z13.string(),
2332
+ private: z13.boolean()
2208
2333
  }).parse(response.body);
2209
2334
  const subscribable = gitHubRepositorySubscribable({
2210
2335
  canSubscribe: ctx.events.canSubscribe,
@@ -2228,27 +2353,27 @@ function createGitHubGetRepositoryTool(ctx) {
2228
2353
 
2229
2354
  // src/tools/get-status.ts
2230
2355
  import {
2231
- definePluginTool as definePluginTool9,
2232
- pluginToolOutputSchema as pluginToolOutputSchema9
2356
+ definePluginTool as definePluginTool10,
2357
+ pluginToolOutputSchema as pluginToolOutputSchema10
2233
2358
  } from "@sentry/junior-plugin-api";
2234
- import * as z13 from "zod";
2359
+ import * as z15 from "zod";
2235
2360
 
2236
2361
  // src/github-status.ts
2237
- import * as z12 from "zod";
2362
+ import * as z14 from "zod";
2238
2363
  var GITHUB_STATUS_INCIDENTS_URL = "https://www.githubstatus.com/api/v2/incidents.json";
2239
2364
  var GITHUB_STATUS_TTL_MS = 60 * 1e3;
2240
2365
  var GITHUB_STATUS_TIMEOUT_MS = 5e3;
2241
- var incidentsResponseSchema = z12.object({
2242
- incidents: z12.array(
2243
- z12.object({
2244
- components: z12.array(z12.object({ name: z12.string() })).default([]),
2245
- created_at: z12.string(),
2246
- impact: z12.string(),
2247
- name: z12.string(),
2248
- resolved_at: z12.string().nullable(),
2249
- shortlink: z12.string(),
2250
- started_at: z12.string().nullable().optional(),
2251
- status: z12.string()
2366
+ var incidentsResponseSchema = z14.object({
2367
+ incidents: z14.array(
2368
+ z14.object({
2369
+ components: z14.array(z14.object({ name: z14.string() })).default([]),
2370
+ created_at: z14.string(),
2371
+ impact: z14.string(),
2372
+ name: z14.string(),
2373
+ resolved_at: z14.string().nullable(),
2374
+ shortlink: z14.string(),
2375
+ started_at: z14.string().nullable().optional(),
2376
+ status: z14.string()
2252
2377
  })
2253
2378
  )
2254
2379
  });
@@ -2290,22 +2415,22 @@ async function loadGitHubStatusIncidents(cache, withinMs) {
2290
2415
 
2291
2416
  // src/tools/get-status.ts
2292
2417
  var RECENT_INCIDENT_MS = 24 * 60 * 60 * 1e3;
2293
- var inputSchema7 = z13.object({}).strict();
2294
- var incidentSchema = z13.object({
2295
- components: z13.array(z13.string()),
2296
- impact: z13.string(),
2297
- name: z13.string(),
2298
- resolved_at: z13.string().optional(),
2299
- started_at: z13.string(),
2300
- status: z13.string(),
2301
- url: z13.string()
2418
+ var inputSchema8 = z15.object({}).strict();
2419
+ var incidentSchema = z15.object({
2420
+ components: z15.array(z15.string()),
2421
+ impact: z15.string(),
2422
+ name: z15.string(),
2423
+ resolved_at: z15.string().optional(),
2424
+ started_at: z15.string(),
2425
+ status: z15.string(),
2426
+ url: z15.string()
2302
2427
  });
2303
- var outputSchema7 = pluginToolOutputSchema9.extend({
2304
- target: z13.literal("getStatus"),
2305
- incidents: z13.array(incidentSchema)
2428
+ var outputSchema8 = pluginToolOutputSchema10.extend({
2429
+ target: z15.literal("getStatus"),
2430
+ incidents: z15.array(incidentSchema)
2306
2431
  });
2307
2432
  function createGitHubGetStatusTool(ctx) {
2308
- return definePluginTool9({
2433
+ return definePluginTool10({
2309
2434
  annotations: {
2310
2435
  destructiveHint: false,
2311
2436
  idempotentHint: true,
@@ -2313,8 +2438,8 @@ function createGitHubGetStatusTool(ctx) {
2313
2438
  readOnlyHint: true
2314
2439
  },
2315
2440
  description: "List GitHub incidents from githubstatus.com that are open or were resolved in the last 24 hours, with their affected components. Use when a GitHub request fails with a 5xx, a timeout, or a dropped connection, or when checks stay queued or fail with no cause in the logs.",
2316
- inputSchema: inputSchema7,
2317
- outputSchema: outputSchema7,
2441
+ inputSchema: inputSchema8,
2442
+ outputSchema: outputSchema8,
2318
2443
  async execute() {
2319
2444
  const incidents = await loadGitHubStatusIncidents(
2320
2445
  ctx.cache,
@@ -2337,61 +2462,84 @@ function createGitHubGetStatusTool(ctx) {
2337
2462
 
2338
2463
  // src/tools/update-issue.ts
2339
2464
  import {
2340
- definePluginTool as definePluginTool10,
2341
- PluginToolInputError as PluginToolInputError10,
2342
- pluginToolOutputSchema as pluginToolOutputSchema10,
2343
- subscribableResourceSchema as subscribableResourceSchema7
2465
+ definePluginTool as definePluginTool11,
2466
+ PluginToolInputError as PluginToolInputError11,
2467
+ pluginToolOutputSchema as pluginToolOutputSchema11,
2468
+ subscribableResourceSchema as subscribableResourceSchema8
2344
2469
  } from "@sentry/junior-plugin-api";
2345
- import * as z14 from "zod";
2346
- var inputSchema8 = z14.object({
2347
- repo: z14.string().describe('Repository in "owner/name" format.'),
2348
- number: z14.number().int().positive().describe("Issue number."),
2349
- title: z14.string().trim().min(1).optional().describe("Replacement issue title."),
2350
- body: z14.string().optional().describe(
2470
+ import * as z16 from "zod";
2471
+ var inputSchema9 = z16.object({
2472
+ repo: z16.string().describe('Repository in "owner/name" format.'),
2473
+ number: z16.number().int().positive().describe("Issue number."),
2474
+ title: z16.string().trim().min(1).optional().describe("Replacement issue title."),
2475
+ body: z16.string().optional().describe(
2351
2476
  "Replacement issue body. The runtime appends requester attribution and the conversation footer."
2352
2477
  ),
2353
- state: z14.enum(["open", "closed"]).optional().describe("Replacement issue state.")
2478
+ state: z16.enum(["open", "closed"]).optional().describe("Replacement issue state."),
2479
+ assign_requester: z16.boolean().optional().describe(
2480
+ "Set true to add the requester's linked GitHub account as an assignee. Other assignees stay."
2481
+ )
2354
2482
  }).strict().refine(
2355
- ({ title, body, state }) => title !== void 0 || body !== void 0 || state !== void 0,
2483
+ ({ title, body, state, assign_requester }) => title !== void 0 || body !== void 0 || state !== void 0 || assign_requester === true,
2356
2484
  { message: "At least one issue field must be provided." }
2357
2485
  );
2358
- var issueSchema = z14.object({
2359
- body: z14.string().nullable(),
2360
- number: z14.number(),
2361
- state: z14.string(),
2362
- subscribable: subscribableResourceSchema7.optional(),
2363
- title: z14.string(),
2364
- url: z14.string()
2486
+ var issueSchema2 = z16.object({
2487
+ assignees: z16.array(z16.string()),
2488
+ body: z16.string().nullable(),
2489
+ number: z16.number(),
2490
+ state: z16.string(),
2491
+ subscribable: subscribableResourceSchema8.optional(),
2492
+ title: z16.string(),
2493
+ url: z16.string()
2365
2494
  });
2366
- var outputSchema8 = pluginToolOutputSchema10.merge(
2367
- issueSchema.extend({
2368
- target: z14.literal("updateIssue")
2495
+ var outputSchema9 = pluginToolOutputSchema11.merge(
2496
+ issueSchema2.extend({
2497
+ target: z16.literal("updateIssue")
2369
2498
  })
2370
2499
  );
2500
+ var providerIssueSchema2 = z16.object({
2501
+ assignees: z16.array(z16.object({ login: z16.string() })).nullish().transform((assignees) => assignees?.map(({ login }) => login) ?? []),
2502
+ body: z16.string().nullable().optional().default(null),
2503
+ html_url: z16.string(),
2504
+ number: z16.number(),
2505
+ state: z16.string(),
2506
+ title: z16.string()
2507
+ });
2371
2508
  function nonEmptyString4(value, name) {
2372
- if (!value?.trim()) throw new PluginToolInputError10(`${name} is required`);
2509
+ if (!value?.trim()) throw new PluginToolInputError11(`${name} is required`);
2373
2510
  return value.trim();
2374
2511
  }
2375
2512
  function createGitHubUpdateIssueTool(ctx) {
2376
- return definePluginTool10({
2513
+ return definePluginTool11({
2377
2514
  annotations: {
2378
2515
  destructiveHint: true,
2379
2516
  idempotentHint: true,
2380
2517
  openWorldHint: true,
2381
2518
  readOnlyHint: false
2382
2519
  },
2383
- description: "Update an existing GitHub issue's title, body, or open/closed state. Use this instead of raw GitHub API calls when changing issue metadata.",
2384
- inputSchema: inputSchema8,
2385
- outputSchema: outputSchema8,
2520
+ description: "Update an existing GitHub issue's title, body, or open/closed state, or assign it to the requester. Use this instead of raw GitHub API calls when changing issue metadata.",
2521
+ inputSchema: inputSchema9,
2522
+ outputSchema: outputSchema9,
2386
2523
  async execute(input) {
2387
- const parsedInput = inputSchema8.safeParse(input);
2524
+ const parsedInput = inputSchema9.safeParse(input);
2388
2525
  if (!parsedInput.success) {
2389
- throw new PluginToolInputError10("Invalid GitHub updateIssue input.", {
2526
+ throw new PluginToolInputError11("Invalid GitHub updateIssue input.", {
2390
2527
  cause: parsedInput.error
2391
2528
  });
2392
2529
  }
2393
2530
  const update = parsedInput.data;
2394
2531
  const repo = parseRepo(update.repo);
2532
+ const requester = update.body !== void 0 || update.assign_requester ? await resolveGitHubRequester(ctx) : void 0;
2533
+ const assignee = update.assign_requester ? linkedGitHubLogin(requester?.user) : void 0;
2534
+ if (update.assign_requester && !assignee) {
2535
+ throw new PluginToolInputError11(
2536
+ "The requester has no linked GitHub account, so Junior cannot assign the issue to them."
2537
+ );
2538
+ }
2539
+ const currentBody = update.body !== void 0 ? await readGitHubBody(ctx.egress, {
2540
+ operation: "github.issue.get",
2541
+ path: `${repoPath(repo)}/issues/${update.number}`
2542
+ }) : void 0;
2395
2543
  const payload = {
2396
2544
  ...update.title !== void 0 ? { title: update.title } : void 0,
2397
2545
  ...update.body !== void 0 ? {
@@ -2399,7 +2547,8 @@ function createGitHubUpdateIssueTool(ctx) {
2399
2547
  appendGitHubRequesterAttribution(
2400
2548
  update.body,
2401
2549
  ctx,
2402
- await resolveGitHubRequester(ctx)
2550
+ requester,
2551
+ currentBody
2403
2552
  ),
2404
2553
  nonEmptyString4(ctx.conversationId, "conversationId"),
2405
2554
  ctx.slack?.conversationLink?.url
@@ -2407,25 +2556,45 @@ function createGitHubUpdateIssueTool(ctx) {
2407
2556
  } : void 0,
2408
2557
  ...update.state !== void 0 ? { state: update.state } : void 0
2409
2558
  };
2410
- const response = await githubApi(ctx.egress, {
2411
- operation: "github.issue.update",
2412
- method: "PATCH",
2413
- path: `${repoPath(repo)}/issues/${update.number}`,
2414
- body: payload
2415
- });
2416
- const parsed = response.body;
2417
- if (!response.ok) {
2418
- throw new Error(
2419
- `GitHub issue update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`
2559
+ let parsed;
2560
+ if (Object.keys(payload).length > 0) {
2561
+ const response = await githubApi(ctx.egress, {
2562
+ operation: "github.issue.update",
2563
+ method: "PATCH",
2564
+ path: `${repoPath(repo)}/issues/${update.number}`,
2565
+ body: payload
2566
+ });
2567
+ parsed = response.body;
2568
+ if (!response.ok) {
2569
+ throw new Error(
2570
+ `GitHub issue update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`
2571
+ );
2572
+ }
2573
+ }
2574
+ if (assignee) {
2575
+ const response = await githubApi(ctx.egress, {
2576
+ operation: "github.issue.assign",
2577
+ method: "POST",
2578
+ path: `${repoPath(repo)}/issues/${update.number}/assignees`,
2579
+ body: { assignees: [assignee] }
2580
+ });
2581
+ parsed = response.body;
2582
+ if (!response.ok) {
2583
+ const message = `GitHub issue assignment failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`;
2584
+ if (response.status === 404 || response.status === 422) {
2585
+ throw new PluginToolInputError11(message);
2586
+ }
2587
+ throw new Error(message);
2588
+ }
2589
+ }
2590
+ const providerResult = providerIssueSchema2.parse(parsed);
2591
+ if (assignee && !providerResult.assignees.some(
2592
+ (login) => login.toLowerCase() === assignee.toLowerCase()
2593
+ )) {
2594
+ throw new PluginToolInputError11(
2595
+ `GitHub did not assign @${assignee} to the issue. They may not have access to ${repo.ref}.`
2420
2596
  );
2421
2597
  }
2422
- const providerResult = z14.object({
2423
- body: z14.string().nullable().optional().default(null),
2424
- html_url: z14.string(),
2425
- number: z14.number(),
2426
- state: z14.string(),
2427
- title: z14.string()
2428
- }).parse(parsed);
2429
2598
  const subscribable = gitHubIssueSubscribable({
2430
2599
  canSubscribe: ctx.events.canSubscribe,
2431
2600
  number: providerResult.number,
@@ -2444,6 +2613,7 @@ function createGitHubUpdateIssueTool(ctx) {
2444
2613
  })
2445
2614
  ],
2446
2615
  target: "updateIssue",
2616
+ assignees: providerResult.assignees,
2447
2617
  body: providerResult.body,
2448
2618
  number: providerResult.number,
2449
2619
  state: providerResult.state,
@@ -2457,22 +2627,22 @@ function createGitHubUpdateIssueTool(ctx) {
2457
2627
 
2458
2628
  // src/tools/update-pull-request.ts
2459
2629
  import {
2460
- definePluginTool as definePluginTool11,
2461
- PluginToolInputError as PluginToolInputError11,
2462
- pluginToolOutputSchema as pluginToolOutputSchema11
2630
+ definePluginTool as definePluginTool12,
2631
+ PluginToolInputError as PluginToolInputError12,
2632
+ pluginToolOutputSchema as pluginToolOutputSchema12
2463
2633
  } from "@sentry/junior-plugin-api";
2464
- import * as z15 from "zod";
2465
- import { subscribableResourceSchema as subscribableResourceSchema8 } from "@sentry/junior-plugin-api";
2466
- var inputSchema9 = z15.object({
2467
- repo: z15.string().describe('Repository in "owner/name" format.'),
2468
- number: z15.number().int().positive().describe("Pull request number."),
2469
- title: z15.string().trim().min(1).optional().describe("Replacement pull request title."),
2470
- body: z15.string().optional().describe(
2634
+ import * as z17 from "zod";
2635
+ import { subscribableResourceSchema as subscribableResourceSchema9 } from "@sentry/junior-plugin-api";
2636
+ var inputSchema10 = z17.object({
2637
+ repo: z17.string().describe('Repository in "owner/name" format.'),
2638
+ number: z17.number().int().positive().describe("Pull request number."),
2639
+ title: z17.string().trim().min(1).optional().describe("Replacement pull request title."),
2640
+ body: z17.string().optional().describe(
2471
2641
  "Replacement pull request body. The runtime appends requester attribution and the conversation footer."
2472
2642
  ),
2473
- base: z15.string().trim().min(1).optional().describe("Replacement base branch."),
2474
- state: z15.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
2475
- draft: z15.boolean().optional().describe(
2643
+ base: z17.string().trim().min(1).optional().describe("Replacement base branch."),
2644
+ state: z17.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
2645
+ draft: z17.boolean().optional().describe(
2476
2646
  "Set false to mark a draft pull request ready for review, or true to convert it back to a draft."
2477
2647
  )
2478
2648
  }).strict().refine(
@@ -2487,29 +2657,29 @@ var CONVERT_TO_DRAFT = {
2487
2657
  operationName: "ConvertPullRequestToDraft",
2488
2658
  query: "mutation ConvertPullRequestToDraft($id: ID!) { result: convertPullRequestToDraft(input: {pullRequestId: $id}) { pullRequest { isDraft } } }"
2489
2659
  };
2490
- var draftMutationResponseSchema = z15.object({
2491
- data: z15.object({
2492
- result: z15.object({ pullRequest: z15.object({ isDraft: z15.boolean() }) })
2660
+ var draftMutationResponseSchema = z17.object({
2661
+ data: z17.object({
2662
+ result: z17.object({ pullRequest: z17.object({ isDraft: z17.boolean() }) })
2493
2663
  })
2494
2664
  });
2495
- var pullRequestSchema2 = z15.object({
2496
- base: z15.string(),
2497
- body: z15.string().nullable(),
2498
- draft: z15.boolean(),
2499
- number: z15.number(),
2500
- state: z15.string(),
2501
- subscribable: subscribableResourceSchema8.optional(),
2502
- title: z15.string(),
2503
- url: z15.string()
2665
+ var pullRequestSchema2 = z17.object({
2666
+ base: z17.string(),
2667
+ body: z17.string().nullable(),
2668
+ draft: z17.boolean(),
2669
+ number: z17.number(),
2670
+ state: z17.string(),
2671
+ subscribable: subscribableResourceSchema9.optional(),
2672
+ title: z17.string(),
2673
+ url: z17.string()
2504
2674
  });
2505
- var outputSchema9 = pluginToolOutputSchema11.merge(
2675
+ var outputSchema10 = pluginToolOutputSchema12.merge(
2506
2676
  pullRequestSchema2.extend({
2507
- target: z15.literal("updatePullRequest")
2677
+ target: z17.literal("updatePullRequest")
2508
2678
  })
2509
2679
  );
2510
2680
  function nonEmptyString5(value, name) {
2511
2681
  if (!value?.trim()) {
2512
- throw new PluginToolInputError11(`${name} is required`);
2682
+ throw new PluginToolInputError12(`${name} is required`);
2513
2683
  }
2514
2684
  return value.trim();
2515
2685
  }
@@ -2535,7 +2705,7 @@ async function setPullRequestDraft(input) {
2535
2705
  return isDraft;
2536
2706
  }
2537
2707
  function createGitHubUpdatePullRequestTool(ctx) {
2538
- return definePluginTool11({
2708
+ return definePluginTool12({
2539
2709
  annotations: {
2540
2710
  destructiveHint: true,
2541
2711
  idempotentHint: true,
@@ -2543,12 +2713,12 @@ function createGitHubUpdatePullRequestTool(ctx) {
2543
2713
  readOnlyHint: false
2544
2714
  },
2545
2715
  description: "Update an existing GitHub pull request's title, body, base branch, open/closed state, or draft state. Use this instead of raw GitHub API calls when changing PR metadata or marking a PR ready for review.",
2546
- inputSchema: inputSchema9,
2547
- outputSchema: outputSchema9,
2716
+ inputSchema: inputSchema10,
2717
+ outputSchema: outputSchema10,
2548
2718
  async execute(input) {
2549
- const parsedInput = inputSchema9.safeParse(input);
2719
+ const parsedInput = inputSchema10.safeParse(input);
2550
2720
  if (!parsedInput.success) {
2551
- throw new PluginToolInputError11(
2721
+ throw new PluginToolInputError12(
2552
2722
  "Invalid GitHub updatePullRequest input.",
2553
2723
  { cause: parsedInput.error }
2554
2724
  );
@@ -2556,11 +2726,20 @@ function createGitHubUpdatePullRequestTool(ctx) {
2556
2726
  const update = parsedInput.data;
2557
2727
  const repo = parseRepo(update.repo);
2558
2728
  const requester = await resolveGitHubRequester(ctx);
2729
+ const currentBody = update.body !== void 0 ? await readGitHubBody(ctx.egress, {
2730
+ operation: "github.pull.get",
2731
+ path: `${repoPath(repo)}/pulls/${update.number}`
2732
+ }) : void 0;
2559
2733
  const payload = {
2560
2734
  ...update.title !== void 0 ? { title: update.title } : void 0,
2561
2735
  ...update.body !== void 0 ? {
2562
2736
  body: appendGitHubFooter(
2563
- appendGitHubRequesterAttribution(update.body, ctx, requester),
2737
+ appendGitHubRequesterAttribution(
2738
+ update.body,
2739
+ ctx,
2740
+ requester,
2741
+ currentBody
2742
+ ),
2564
2743
  nonEmptyString5(ctx.conversationId, "conversationId"),
2565
2744
  ctx.slack?.conversationLink?.url
2566
2745
  )
@@ -2580,16 +2759,16 @@ function createGitHubUpdatePullRequestTool(ctx) {
2580
2759
  `GitHub pull request update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`
2581
2760
  );
2582
2761
  }
2583
- const providerResult = z15.object({
2584
- base: z15.object({ ref: z15.string() }),
2585
- body: z15.string().nullable().optional().default(null),
2586
- draft: z15.boolean(),
2587
- html_url: z15.string(),
2588
- merged: z15.boolean(),
2589
- node_id: z15.string().optional(),
2590
- number: z15.number(),
2591
- state: z15.string(),
2592
- title: z15.string()
2762
+ const providerResult = z17.object({
2763
+ base: z17.object({ ref: z17.string() }),
2764
+ body: z17.string().nullable().optional().default(null),
2765
+ draft: z17.boolean(),
2766
+ html_url: z17.string(),
2767
+ merged: z17.boolean(),
2768
+ node_id: z17.string().optional(),
2769
+ number: z17.number(),
2770
+ state: z17.string(),
2771
+ title: z17.string()
2593
2772
  }).parse(parsed);
2594
2773
  if (update.draft !== void 0 && update.draft !== providerResult.draft) {
2595
2774
  if (!providerResult.node_id) {
@@ -2650,11 +2829,11 @@ function createGitHubUpdatePullRequestTool(ctx) {
2650
2829
 
2651
2830
  // src/tools/update-pull-request-feedback.ts
2652
2831
  import {
2653
- definePluginTool as definePluginTool12,
2654
- PluginToolInputError as PluginToolInputError12,
2655
- pluginToolOutputSchema as pluginToolOutputSchema12
2832
+ definePluginTool as definePluginTool13,
2833
+ PluginToolInputError as PluginToolInputError13,
2834
+ pluginToolOutputSchema as pluginToolOutputSchema13
2656
2835
  } from "@sentry/junior-plugin-api";
2657
- import * as z16 from "zod";
2836
+ import * as z18 from "zod";
2658
2837
  var STATUS_TO_REACTION_CONTENT = {
2659
2838
  reviewing: "eyes",
2660
2839
  addressed: "+1",
@@ -2663,24 +2842,24 @@ var STATUS_TO_REACTION_CONTENT = {
2663
2842
  var FEEDBACK_REACTION_CONTENTS = new Set(
2664
2843
  Object.values(STATUS_TO_REACTION_CONTENT)
2665
2844
  );
2666
- var inputSchema10 = z16.object({
2667
- repo: z16.string().describe('Repository in "owner/name" format.'),
2668
- comment_kind: z16.enum(["conversation", "review"]).describe(
2845
+ var inputSchema11 = z18.object({
2846
+ repo: z18.string().describe('Repository in "owner/name" format.'),
2847
+ comment_kind: z18.enum(["conversation", "review"]).describe(
2669
2848
  'Comment kind: "conversation" for a pull request conversation comment, "review" for an inline review comment.'
2670
2849
  ),
2671
- comment_id: z16.number().int().positive().describe(
2850
+ comment_id: z18.number().int().positive().describe(
2672
2851
  "GitHub comment id (conversation comment id or inline review comment id)."
2673
2852
  ),
2674
- status: z16.enum(["addressed", "declined"]).describe(
2853
+ status: z18.enum(["addressed", "declined"]).describe(
2675
2854
  "Feedback outcome. Maps to a reaction: addressed -> +1, declined -> -1."
2676
2855
  )
2677
2856
  }).strict();
2678
- var outputSchema10 = pluginToolOutputSchema12.extend({
2679
- target: z16.literal("updatePullRequestFeedback"),
2680
- repo: z16.string(),
2681
- comment_id: z16.number(),
2682
- status: z16.enum(["addressed", "declined"]),
2683
- reaction_id: z16.number()
2857
+ var outputSchema11 = pluginToolOutputSchema13.extend({
2858
+ target: z18.literal("updatePullRequestFeedback"),
2859
+ repo: z18.string(),
2860
+ comment_id: z18.number(),
2861
+ status: z18.enum(["addressed", "declined"]),
2862
+ reaction_id: z18.number()
2684
2863
  });
2685
2864
  function pullRequestCommentPath(input) {
2686
2865
  const segment = input.commentKind === "conversation" ? "issues" : "pulls";
@@ -2692,10 +2871,10 @@ function pullRequestCommentReactionsPath(input) {
2692
2871
  function pullRequestFeedbackReactionContent(status) {
2693
2872
  return STATUS_TO_REACTION_CONTENT[status];
2694
2873
  }
2695
- var reactionSchema = z16.object({
2696
- id: z16.number(),
2697
- content: z16.string(),
2698
- user: z16.object({ id: z16.number() }).nullable()
2874
+ var reactionSchema = z18.object({
2875
+ id: z18.number(),
2876
+ content: z18.string(),
2877
+ user: z18.object({ id: z18.number() }).nullable()
2699
2878
  });
2700
2879
  async function assertBotAuthoredPullRequest(egress, input) {
2701
2880
  const commentResponse = await githubApi(egress, {
@@ -2705,21 +2884,21 @@ async function assertBotAuthoredPullRequest(egress, input) {
2705
2884
  const commentPayload = commentResponse.body;
2706
2885
  if (!commentResponse.ok) {
2707
2886
  const message = `GitHub comment lookup failed with HTTP ${commentResponse.status}: ${githubErrorMessage(commentPayload)}`;
2708
- if (commentResponse.status === 404) throw new PluginToolInputError12(message);
2887
+ if (commentResponse.status === 404) throw new PluginToolInputError13(message);
2709
2888
  throw new Error(message);
2710
2889
  }
2711
- const comment = z16.object({
2712
- issue_url: z16.string().optional(),
2713
- pull_request_url: z16.string().optional()
2890
+ const comment = z18.object({
2891
+ issue_url: z18.string().optional(),
2892
+ pull_request_url: z18.string().optional()
2714
2893
  }).safeParse(commentPayload);
2715
2894
  const parentUrl = comment.success ? input.commentKind === "conversation" ? comment.data.issue_url : comment.data.pull_request_url : void 0;
2716
- const number22 = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
2717
- if (!number22) {
2895
+ const number23 = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
2896
+ if (!number23) {
2718
2897
  throw new Error("GitHub comment did not name its issue or pull request.");
2719
2898
  }
2720
2899
  const pullResponse = await githubApi(egress, {
2721
2900
  operation: "github.pull.get",
2722
- path: `${repoPath(input)}/pulls/${number22}`
2901
+ path: `${repoPath(input)}/pulls/${number23}`
2723
2902
  });
2724
2903
  const pullPayload = pullResponse.body;
2725
2904
  if (!pullResponse.ok && pullResponse.status !== 404) {
@@ -2727,15 +2906,15 @@ async function assertBotAuthoredPullRequest(egress, input) {
2727
2906
  `GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${githubErrorMessage(pullPayload)}`
2728
2907
  );
2729
2908
  }
2730
- const pull = z16.object({ user: z16.object({ id: z16.number() }).nullable() }).safeParse(pullPayload);
2909
+ const pull = z18.object({ user: z18.object({ id: z18.number() }).nullable() }).safeParse(pullPayload);
2731
2910
  if (!pullResponse.ok || !pull.success || pull.data.user?.id !== input.botUserId) {
2732
- throw new PluginToolInputError12(
2911
+ throw new PluginToolInputError13(
2733
2912
  "This bot can only set feedback status on comments on pull requests it authored."
2734
2913
  );
2735
2914
  }
2736
2915
  }
2737
2916
  function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2738
- return definePluginTool12({
2917
+ return definePluginTool13({
2739
2918
  // No action review: the tool checks in code that the bot authored the pull
2740
2919
  // request, and it changes only the bot's own reaction, which is reversible.
2741
2920
  approvalMode: "approve",
@@ -2747,12 +2926,12 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2747
2926
  },
2748
2927
  description: "Set your outcome reaction on GitHub pull request feedback: addressed (+1) or declined (-1). Use the comment_id and comment_kind from the event after acting on the feedback. Replaces only your prior status reaction on that comment. Only works on pull requests the bot authored.",
2749
2928
  exposure: "direct",
2750
- inputSchema: inputSchema10,
2751
- outputSchema: outputSchema10,
2929
+ inputSchema: inputSchema11,
2930
+ outputSchema: outputSchema11,
2752
2931
  async execute(input) {
2753
- const parsedInput = inputSchema10.safeParse(input);
2932
+ const parsedInput = inputSchema11.safeParse(input);
2754
2933
  if (!parsedInput.success) {
2755
- throw new PluginToolInputError12(
2934
+ throw new PluginToolInputError13(
2756
2935
  "Invalid GitHub updatePullRequestFeedback input.",
2757
2936
  { cause: parsedInput.error }
2758
2937
  );
@@ -2791,7 +2970,7 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2791
2970
  `GitHub reaction lookup failed with HTTP ${listResponse.status}: ${githubErrorMessage(listPayload)}`
2792
2971
  );
2793
2972
  }
2794
- const botReactions = z16.array(reactionSchema).parse(listPayload).filter(
2973
+ const botReactions = z18.array(reactionSchema).parse(listPayload).filter(
2795
2974
  (reaction) => reaction.user?.id === botUserId && FEEDBACK_REACTION_CONTENTS.has(reaction.content)
2796
2975
  );
2797
2976
  const existing = botReactions.find(
@@ -2845,28 +3024,28 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2845
3024
 
2846
3025
  // src/tools/resolve-pull-request-review-thread.ts
2847
3026
  import {
2848
- definePluginTool as definePluginTool13,
2849
- PluginToolInputError as PluginToolInputError13,
2850
- pluginToolOutputSchema as pluginToolOutputSchema13
3027
+ definePluginTool as definePluginTool14,
3028
+ PluginToolInputError as PluginToolInputError14,
3029
+ pluginToolOutputSchema as pluginToolOutputSchema14
2851
3030
  } from "@sentry/junior-plugin-api";
2852
- import * as z17 from "zod";
2853
- var inputSchema11 = z17.object({
2854
- repo: z17.string().describe(
3031
+ import * as z19 from "zod";
3032
+ var inputSchema12 = z19.object({
3033
+ repo: z19.string().describe(
2855
3034
  'Repository in "owner/name" format. Required because GraphQL has no repo path.'
2856
3035
  ),
2857
- thread_id: z17.string().trim().min(1).describe(
3036
+ thread_id: z19.string().trim().min(1).describe(
2858
3037
  "GitHub pull request review thread node ID (the `threadId` / `id` variable used by `gh api graphql` resolveReviewThread)."
2859
3038
  )
2860
3039
  }).strict();
2861
- var outputSchema11 = pluginToolOutputSchema13.extend({
2862
- target: z17.literal("resolvePullRequestReviewThread"),
2863
- repo: z17.string(),
2864
- number: z17.number(),
2865
- thread_id: z17.string(),
2866
- resolved: z17.boolean()
3040
+ var outputSchema12 = pluginToolOutputSchema14.extend({
3041
+ target: z19.literal("resolvePullRequestReviewThread"),
3042
+ repo: z19.string(),
3043
+ number: z19.number(),
3044
+ thread_id: z19.string(),
3045
+ resolved: z19.boolean()
2867
3046
  });
2868
3047
  function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
2869
- return definePluginTool13({
3048
+ return definePluginTool14({
2870
3049
  // No action review: the tool checks in code that the bot authored the pull
2871
3050
  // request, and it changes only the thread's resolved state, which is
2872
3051
  // reversible.
@@ -2879,12 +3058,12 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
2879
3058
  },
2880
3059
  description: "Resolve a GitHub pull request review thread after acting on its feedback. Only works on pull requests the bot authored.",
2881
3060
  exposure: "direct",
2882
- inputSchema: inputSchema11,
2883
- outputSchema: outputSchema11,
3061
+ inputSchema: inputSchema12,
3062
+ outputSchema: outputSchema12,
2884
3063
  async execute(input) {
2885
- const parsedInput = inputSchema11.safeParse(input);
3064
+ const parsedInput = inputSchema12.safeParse(input);
2886
3065
  if (!parsedInput.success) {
2887
- throw new PluginToolInputError13(
3066
+ throw new PluginToolInputError14(
2888
3067
  "Invalid GitHub resolvePullRequestReviewThread input.",
2889
3068
  { cause: parsedInput.error }
2890
3069
  );
@@ -2923,31 +3102,31 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
2923
3102
  `GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubErrorMessage(lookupPayload)}`
2924
3103
  );
2925
3104
  }
2926
- const threadNodeSchema = z17.object({
2927
- id: z17.string(),
2928
- isResolved: z17.boolean(),
2929
- pullRequest: z17.object({
2930
- author: z17.object({ databaseId: z17.number().optional() }).passthrough().nullable(),
2931
- number: z17.number(),
2932
- repository: z17.object({ nameWithOwner: z17.string() }).passthrough()
3105
+ const threadNodeSchema = z19.object({
3106
+ id: z19.string(),
3107
+ isResolved: z19.boolean(),
3108
+ pullRequest: z19.object({
3109
+ author: z19.object({ databaseId: z19.number().optional() }).passthrough().nullable(),
3110
+ number: z19.number(),
3111
+ repository: z19.object({ nameWithOwner: z19.string() }).passthrough()
2933
3112
  }).passthrough()
2934
3113
  }).passthrough();
2935
- const lookupResultSchema = z17.object({
2936
- data: z17.object({
2937
- node: z17.unknown().nullable().optional()
3114
+ const lookupResultSchema = z19.object({
3115
+ data: z19.object({
3116
+ node: z19.unknown().nullable().optional()
2938
3117
  }).passthrough()
2939
3118
  }).passthrough();
2940
3119
  const lookupResult = lookupResultSchema.safeParse(lookupPayload);
2941
3120
  const rawNode = lookupResult.success ? lookupResult.data.data.node : void 0;
2942
3121
  const parsedNode = rawNode == null ? void 0 : threadNodeSchema.safeParse(rawNode);
2943
3122
  if (!parsedNode?.success) {
2944
- throw new PluginToolInputError13("GitHub review thread was not found.");
3123
+ throw new PluginToolInputError14("GitHub review thread was not found.");
2945
3124
  }
2946
3125
  const thread = parsedNode.data;
2947
3126
  const pullRequest = thread.pullRequest;
2948
3127
  const ownsPullRequest = pullRequest.repository.nameWithOwner.toLowerCase() === repo.ref.toLowerCase() && pullRequest.author?.databaseId === botUserId;
2949
3128
  if (!ownsPullRequest) {
2950
- throw new PluginToolInputError13(
3129
+ throw new PluginToolInputError14(
2951
3130
  "This bot can only resolve review threads on pull requests it authored."
2952
3131
  );
2953
3132
  }
@@ -2981,10 +3160,10 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
2981
3160
  `GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubErrorMessage(resolvePayload)}`
2982
3161
  );
2983
3162
  }
2984
- const resolveResultSchema = z17.object({
2985
- data: z17.object({
2986
- resolveReviewThread: z17.object({
2987
- thread: z17.object({ id: z17.string(), isResolved: z17.boolean() }).passthrough()
3163
+ const resolveResultSchema = z19.object({
3164
+ data: z19.object({
3165
+ resolveReviewThread: z19.object({
3166
+ thread: z19.object({ id: z19.string(), isResolved: z19.boolean() }).passthrough()
2988
3167
  }).passthrough()
2989
3168
  }).passthrough()
2990
3169
  }).passthrough();
@@ -3012,46 +3191,46 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
3012
3191
 
3013
3192
  // src/tools/submit-pull-request-review.ts
3014
3193
  import {
3015
- definePluginTool as definePluginTool14,
3016
- PluginToolInputError as PluginToolInputError14,
3017
- pluginToolOutputSchema as pluginToolOutputSchema14
3194
+ definePluginTool as definePluginTool15,
3195
+ PluginToolInputError as PluginToolInputError15,
3196
+ pluginToolOutputSchema as pluginToolOutputSchema15
3018
3197
  } from "@sentry/junior-plugin-api";
3019
- import * as z18 from "zod";
3020
- var reviewCommentSchema = z18.object({
3021
- path: z18.string().trim().min(1).describe("File path in the pull request."),
3022
- body: z18.string().trim().min(1).describe("Inline review comment."),
3023
- line: z18.number().int().positive().describe("Line in the pull request diff."),
3024
- side: z18.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
3025
- start_line: z18.number().int().positive().optional().describe("First line of a multi-line comment."),
3026
- start_side: z18.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
3198
+ import * as z20 from "zod";
3199
+ var reviewCommentSchema = z20.object({
3200
+ path: z20.string().trim().min(1).describe("File path in the pull request."),
3201
+ body: z20.string().trim().min(1).describe("Inline review comment."),
3202
+ line: z20.number().int().positive().describe("Line in the pull request diff."),
3203
+ side: z20.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
3204
+ start_line: z20.number().int().positive().optional().describe("First line of a multi-line comment."),
3205
+ start_side: z20.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
3027
3206
  }).strict().refine(
3028
3207
  ({ start_line, start_side }) => start_line === void 0 === (start_side === void 0),
3029
3208
  { message: "start_line and start_side must be provided together." }
3030
3209
  );
3031
- var inputSchema12 = z18.object({
3032
- repo: z18.string().describe('Repository in "owner/name" format.'),
3033
- number: z18.number().int().positive().describe("Pull request number."),
3034
- event: z18.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
3035
- body: z18.string().trim().min(1).describe("Review summary."),
3036
- comments: z18.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
3210
+ var inputSchema13 = z20.object({
3211
+ repo: z20.string().describe('Repository in "owner/name" format.'),
3212
+ number: z20.number().int().positive().describe("Pull request number."),
3213
+ event: z20.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
3214
+ body: z20.string().trim().min(1).describe("Review summary."),
3215
+ comments: z20.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
3037
3216
  }).strict();
3038
- var outputSchema12 = pluginToolOutputSchema14.extend({
3039
- target: z18.literal("submitPullRequestReview"),
3040
- repo: z18.string(),
3041
- number: z18.number(),
3042
- review_id: z18.number(),
3043
- state: z18.string(),
3044
- url: z18.string()
3217
+ var outputSchema13 = pluginToolOutputSchema15.extend({
3218
+ target: z20.literal("submitPullRequestReview"),
3219
+ repo: z20.string(),
3220
+ number: z20.number(),
3221
+ review_id: z20.number(),
3222
+ state: z20.string(),
3223
+ url: z20.string()
3045
3224
  });
3046
3225
  function throwReviewError(status, body) {
3047
3226
  const message = `GitHub pull request review failed with HTTP ${status}: ${githubErrorMessage(body)}`;
3048
3227
  if (status === 404 || status === 422) {
3049
- throw new PluginToolInputError14(message);
3228
+ throw new PluginToolInputError15(message);
3050
3229
  }
3051
3230
  throw new Error(message);
3052
3231
  }
3053
3232
  function createGitHubSubmitPullRequestReviewTool(egress) {
3054
- return definePluginTool14({
3233
+ return definePluginTool15({
3055
3234
  annotations: {
3056
3235
  destructiveHint: true,
3057
3236
  idempotentHint: false,
@@ -3060,8 +3239,8 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
3060
3239
  },
3061
3240
  description: "Submit a GitHub pull request review as a comment or change request. Use this instead of `gh pr review`, GraphQL, or direct REST calls. You cannot approve pull requests.",
3062
3241
  exposure: "direct",
3063
- inputSchema: inputSchema12,
3064
- outputSchema: outputSchema12,
3242
+ inputSchema: inputSchema13,
3243
+ outputSchema: outputSchema13,
3065
3244
  async execute(review) {
3066
3245
  const repo = parseRepo(review.repo);
3067
3246
  const comments = review.comments?.map((comment) => ({
@@ -3085,7 +3264,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
3085
3264
  if (!response.ok) {
3086
3265
  throwReviewError(response.status, response.body);
3087
3266
  }
3088
- const providerResult = z18.object({ id: z18.number(), html_url: z18.string(), state: z18.string() }).parse(response.body);
3267
+ const providerResult = z20.object({ id: z20.number(), html_url: z20.string(), state: z20.string() }).parse(response.body);
3089
3268
  return {
3090
3269
  target: "submitPullRequestReview",
3091
3270
  repo: repo.ref,
@@ -3109,6 +3288,7 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
3109
3288
  pullRequestSubscription
3110
3289
  ),
3111
3290
  getDeployment: createGitHubGetDeploymentTool(ctx),
3291
+ getIssue: createGitHubGetIssueTool(ctx),
3112
3292
  getPullRequest: createGitHubGetPullRequestTool(ctx),
3113
3293
  getRelease: createGitHubGetReleaseTool(ctx),
3114
3294
  getRepository: createGitHubGetRepositoryTool(ctx),
@@ -3128,26 +3308,26 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
3128
3308
 
3129
3309
  // src/webhooks/handler.ts
3130
3310
  import { createHmac, timingSafeEqual } from "crypto";
3131
- import * as z28 from "zod";
3311
+ import * as z30 from "zod";
3132
3312
 
3133
3313
  // src/issue-outcomes/store.ts
3134
3314
  import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
3135
- import * as z19 from "zod";
3136
- var githubIssueOutcomeInputSchema = z19.object({
3137
- candidateOwned: z19.boolean(),
3138
- closedAt: z19.date().optional(),
3139
- issueId: z19.string().min(1),
3140
- number: z19.number().int().positive(),
3141
- openedAt: z19.date(),
3142
- repositoryFullName: z19.string().min(1),
3143
- repositoryId: z19.string().min(1),
3315
+ import * as z21 from "zod";
3316
+ var githubIssueOutcomeInputSchema = z21.object({
3317
+ candidateOwned: z21.boolean(),
3318
+ closedAt: z21.date().optional(),
3319
+ issueId: z21.string().min(1),
3320
+ number: z21.number().int().positive(),
3321
+ openedAt: z21.date(),
3322
+ repositoryFullName: z21.string().min(1),
3323
+ repositoryId: z21.string().min(1),
3144
3324
  state: githubIssueStateSchema,
3145
3325
  stateReason: githubIssueStateReasonSchema.optional(),
3146
- updatedAt: z19.date()
3326
+ updatedAt: z21.date()
3147
3327
  }).strict();
3148
- var githubIssueConversationsInputSchema = z19.object({
3149
- conversationIds: z19.array(z19.string().min(1)).min(1),
3150
- issueId: z19.string().min(1)
3328
+ var githubIssueConversationsInputSchema = z21.object({
3329
+ conversationIds: z21.array(z21.string().min(1)).min(1),
3330
+ issueId: z21.string().min(1)
3151
3331
  }).strict();
3152
3332
  function projectionValues(input) {
3153
3333
  return {
@@ -3211,33 +3391,33 @@ async function recordGitHubIssueConversations(db, input) {
3211
3391
 
3212
3392
  // src/pull-request-outcomes/store.ts
3213
3393
  import { and as and3, eq as eq3, lte as lte2, ne, sql as sql3 } from "drizzle-orm";
3214
- import * as z20 from "zod";
3215
- var githubPullRequestOutcomeInputSchema = z20.object({
3216
- candidateOwned: z20.boolean(),
3217
- closedAt: z20.date().optional(),
3394
+ import * as z22 from "zod";
3395
+ var githubPullRequestOutcomeInputSchema = z22.object({
3396
+ candidateOwned: z22.boolean(),
3397
+ closedAt: z22.date().optional(),
3218
3398
  commitComposition: githubPullRequestCommitCompositionSchema.optional(),
3219
- mergedAt: z20.date().optional(),
3220
- number: z20.number().int().positive(),
3221
- openedAt: z20.date(),
3222
- pullRequestId: z20.string().min(1),
3223
- repositoryFullName: z20.string().min(1),
3224
- repositoryId: z20.string().min(1),
3399
+ mergedAt: z22.date().optional(),
3400
+ number: z22.number().int().positive(),
3401
+ openedAt: z22.date(),
3402
+ pullRequestId: z22.string().min(1),
3403
+ repositoryFullName: z22.string().min(1),
3404
+ repositoryId: z22.string().min(1),
3225
3405
  state: githubPullRequestStateSchema,
3226
- title: z20.string().min(1).optional(),
3227
- updatedAt: z20.date()
3406
+ title: z22.string().min(1).optional(),
3407
+ updatedAt: z22.date()
3228
3408
  }).strict();
3229
- var githubPullRequestConversationsInputSchema = z20.object({
3230
- conversationIds: z20.array(z20.string().min(1)).min(1),
3231
- pullRequestId: z20.string().min(1)
3409
+ var githubPullRequestConversationsInputSchema = z22.object({
3410
+ conversationIds: z22.array(z22.string().min(1)).min(1),
3411
+ pullRequestId: z22.string().min(1)
3232
3412
  }).strict();
3233
- var githubPullRequestLinkedIssuesInputSchema = z20.object({
3234
- linkedIssues: z20.array(
3235
- z20.object({
3236
- number: z20.number().int().positive(),
3237
- repositoryFullName: z20.string().min(1)
3413
+ var githubPullRequestLinkedIssuesInputSchema = z22.object({
3414
+ linkedIssues: z22.array(
3415
+ z22.object({
3416
+ number: z22.number().int().positive(),
3417
+ repositoryFullName: z22.string().min(1)
3238
3418
  }).strict()
3239
3419
  ).min(1),
3240
- pullRequestId: z20.string().min(1)
3420
+ pullRequestId: z22.string().min(1)
3241
3421
  }).strict();
3242
3422
  function projectionValues2(input) {
3243
3423
  return {
@@ -3442,39 +3622,39 @@ async function releaseGitHubPullRequestReadySync(db, target, claim) {
3442
3622
  }
3443
3623
 
3444
3624
  // src/webhooks/issue-outcome.ts
3445
- import * as z21 from "zod";
3446
- var canonicalIssueOutcomeSchema = z21.object({
3447
- action: z21.enum(["opened", "closed", "reopened"]),
3448
- issue: z21.object({
3449
- body: z21.string().nullable().optional(),
3450
- closed_at: z21.string().nullable().optional(),
3451
- created_at: z21.string(),
3452
- id: z21.number().int().positive(),
3453
- number: z21.number().int().positive(),
3625
+ import * as z23 from "zod";
3626
+ var canonicalIssueOutcomeSchema = z23.object({
3627
+ action: z23.enum(["opened", "closed", "reopened"]),
3628
+ issue: z23.object({
3629
+ body: z23.string().nullable().optional(),
3630
+ closed_at: z23.string().nullable().optional(),
3631
+ created_at: z23.string(),
3632
+ id: z23.number().int().positive(),
3633
+ number: z23.number().int().positive(),
3454
3634
  state_reason: githubIssueStateReasonSchema.nullable().optional(),
3455
- updated_at: z21.string(),
3456
- user: z21.object({ login: z21.string().min(1) }).strict()
3635
+ updated_at: z23.string(),
3636
+ user: z23.object({ login: z23.string().min(1) }).strict()
3457
3637
  }).strict(),
3458
- repository: z21.object({
3459
- full_name: z21.string().min(1),
3460
- id: z21.number().int().positive()
3638
+ repository: z23.object({
3639
+ full_name: z23.string().min(1),
3640
+ id: z23.number().int().positive()
3461
3641
  }).strict()
3462
3642
  }).strict();
3463
- var issueOutcomeSchema = z21.object({
3464
- action: z21.enum(["opened", "closed", "reopened"]),
3465
- issue: z21.object({
3466
- body: z21.string().nullable().optional(),
3467
- closed_at: z21.string().nullable().optional(),
3468
- created_at: z21.string(),
3469
- id: z21.number().int().positive(),
3470
- number: z21.number().int().positive(),
3643
+ var issueOutcomeSchema = z23.object({
3644
+ action: z23.enum(["opened", "closed", "reopened"]),
3645
+ issue: z23.object({
3646
+ body: z23.string().nullable().optional(),
3647
+ closed_at: z23.string().nullable().optional(),
3648
+ created_at: z23.string(),
3649
+ id: z23.number().int().positive(),
3650
+ number: z23.number().int().positive(),
3471
3651
  state_reason: githubIssueStateReasonSchema.nullable().optional(),
3472
- updated_at: z21.string(),
3473
- user: z21.object({ login: z21.string().min(1) }).passthrough()
3652
+ updated_at: z23.string(),
3653
+ user: z23.object({ login: z23.string().min(1) }).passthrough()
3474
3654
  }).passthrough(),
3475
- repository: z21.object({
3476
- full_name: z21.string().min(1),
3477
- id: z21.number().int().positive()
3655
+ repository: z23.object({
3656
+ full_name: z23.string().min(1),
3657
+ id: z23.number().int().positive()
3478
3658
  }).passthrough()
3479
3659
  }).passthrough().transform(
3480
3660
  (provider) => canonicalIssueOutcomeSchema.parse({
@@ -3495,7 +3675,7 @@ var issueOutcomeSchema = z21.object({
3495
3675
  }
3496
3676
  })
3497
3677
  );
3498
- var issueLifecycleActionSchema = z21.object({ action: z21.string() }).passthrough();
3678
+ var issueLifecycleActionSchema = z23.object({ action: z23.string() }).passthrough();
3499
3679
  function timestamp2(value) {
3500
3680
  if (!value) return void 0;
3501
3681
  const parsed = new Date(value);
@@ -3539,21 +3719,21 @@ function normalizeGitHubIssueOutcome(args) {
3539
3719
  updatedAt
3540
3720
  };
3541
3721
  }
3542
- var canonicalIssueConversationSchema = z21.object({
3543
- issue: z21.object({
3544
- body: z21.string().nullable().optional(),
3545
- id: z21.number().int().positive(),
3546
- user: z21.object({ login: z21.string().min(1) }).strict()
3722
+ var canonicalIssueConversationSchema = z23.object({
3723
+ issue: z23.object({
3724
+ body: z23.string().nullable().optional(),
3725
+ id: z23.number().int().positive(),
3726
+ user: z23.object({ login: z23.string().min(1) }).strict()
3547
3727
  }).strict(),
3548
- sender: z21.object({ login: z21.string().min(1) }).strict().optional()
3728
+ sender: z23.object({ login: z23.string().min(1) }).strict().optional()
3549
3729
  }).strict();
3550
- var issueConversationSchema = z21.object({
3551
- issue: z21.object({
3552
- body: z21.string().nullable().optional(),
3553
- id: z21.number().int().positive(),
3554
- user: z21.object({ login: z21.string().min(1) }).passthrough()
3730
+ var issueConversationSchema = z23.object({
3731
+ issue: z23.object({
3732
+ body: z23.string().nullable().optional(),
3733
+ id: z23.number().int().positive(),
3734
+ user: z23.object({ login: z23.string().min(1) }).passthrough()
3555
3735
  }).passthrough(),
3556
- sender: z21.object({ login: z21.string().min(1) }).passthrough().optional()
3736
+ sender: z23.object({ login: z23.string().min(1) }).passthrough().optional()
3557
3737
  }).passthrough().transform(
3558
3738
  (provider) => canonicalIssueConversationSchema.parse({
3559
3739
  issue: {
@@ -3580,43 +3760,43 @@ function normalizeGitHubIssueConversations(args) {
3580
3760
  }
3581
3761
 
3582
3762
  // src/webhooks/pull-request-outcome.ts
3583
- import * as z22 from "zod";
3584
- var canonicalPullRequestOutcomeSchema = z22.object({
3585
- action: z22.enum(["opened", "closed", "reopened"]),
3586
- pull_request: z22.object({
3587
- body: z22.string().nullable().optional(),
3588
- closed_at: z22.string().nullable().optional(),
3589
- created_at: z22.string(),
3590
- id: z22.number().int().positive(),
3591
- merged: z22.boolean(),
3592
- merged_at: z22.string().nullable().optional(),
3593
- number: z22.number().int().positive(),
3594
- title: z22.string().min(1).optional(),
3595
- updated_at: z22.string(),
3596
- user: z22.object({ login: z22.string().min(1) }).strict()
3763
+ import * as z24 from "zod";
3764
+ var canonicalPullRequestOutcomeSchema = z24.object({
3765
+ action: z24.enum(["opened", "closed", "reopened"]),
3766
+ pull_request: z24.object({
3767
+ body: z24.string().nullable().optional(),
3768
+ closed_at: z24.string().nullable().optional(),
3769
+ created_at: z24.string(),
3770
+ id: z24.number().int().positive(),
3771
+ merged: z24.boolean(),
3772
+ merged_at: z24.string().nullable().optional(),
3773
+ number: z24.number().int().positive(),
3774
+ title: z24.string().min(1).optional(),
3775
+ updated_at: z24.string(),
3776
+ user: z24.object({ login: z24.string().min(1) }).strict()
3597
3777
  }).strict(),
3598
- repository: z22.object({
3599
- full_name: z22.string().min(1),
3600
- id: z22.number().int().positive()
3778
+ repository: z24.object({
3779
+ full_name: z24.string().min(1),
3780
+ id: z24.number().int().positive()
3601
3781
  }).strict()
3602
3782
  }).strict();
3603
- var pullRequestOutcomeSchema = z22.object({
3604
- action: z22.enum(["opened", "closed", "reopened"]),
3605
- pull_request: z22.object({
3606
- body: z22.string().nullable().optional(),
3607
- closed_at: z22.string().nullable().optional(),
3608
- created_at: z22.string(),
3609
- id: z22.number().int().positive(),
3610
- merged: z22.boolean(),
3611
- merged_at: z22.string().nullable().optional(),
3612
- number: z22.number().int().positive(),
3613
- title: z22.string().min(1).optional(),
3614
- updated_at: z22.string(),
3615
- user: z22.object({ login: z22.string().min(1) }).passthrough()
3783
+ var pullRequestOutcomeSchema = z24.object({
3784
+ action: z24.enum(["opened", "closed", "reopened"]),
3785
+ pull_request: z24.object({
3786
+ body: z24.string().nullable().optional(),
3787
+ closed_at: z24.string().nullable().optional(),
3788
+ created_at: z24.string(),
3789
+ id: z24.number().int().positive(),
3790
+ merged: z24.boolean(),
3791
+ merged_at: z24.string().nullable().optional(),
3792
+ number: z24.number().int().positive(),
3793
+ title: z24.string().min(1).optional(),
3794
+ updated_at: z24.string(),
3795
+ user: z24.object({ login: z24.string().min(1) }).passthrough()
3616
3796
  }).passthrough(),
3617
- repository: z22.object({
3618
- full_name: z22.string().min(1),
3619
- id: z22.number().int().positive()
3797
+ repository: z24.object({
3798
+ full_name: z24.string().min(1),
3799
+ id: z24.number().int().positive()
3620
3800
  }).passthrough()
3621
3801
  }).passthrough().transform(
3622
3802
  (provider) => canonicalPullRequestOutcomeSchema.parse({
@@ -3639,24 +3819,24 @@ var pullRequestOutcomeSchema = z22.object({
3639
3819
  }
3640
3820
  })
3641
3821
  );
3642
- var pullRequestLifecycleActionSchema = z22.object({ action: z22.string() }).passthrough();
3643
- var canonicalPullRequestConversationSchema = z22.object({
3644
- pull_request: z22.object({
3645
- body: z22.string().nullable().optional(),
3646
- id: z22.number().int().positive(),
3647
- user: z22.object({ login: z22.string().min(1) }).strict()
3822
+ var pullRequestLifecycleActionSchema = z24.object({ action: z24.string() }).passthrough();
3823
+ var canonicalPullRequestConversationSchema = z24.object({
3824
+ pull_request: z24.object({
3825
+ body: z24.string().nullable().optional(),
3826
+ id: z24.number().int().positive(),
3827
+ user: z24.object({ login: z24.string().min(1) }).strict()
3648
3828
  }).strict(),
3649
- repository: z22.object({ full_name: z22.string().min(1) }).strict(),
3650
- sender: z22.object({ login: z22.string().min(1) }).strict()
3829
+ repository: z24.object({ full_name: z24.string().min(1) }).strict(),
3830
+ sender: z24.object({ login: z24.string().min(1) }).strict()
3651
3831
  }).strict();
3652
- var pullRequestConversationSchema = z22.object({
3653
- pull_request: z22.object({
3654
- body: z22.string().nullable().optional(),
3655
- id: z22.number().int().positive(),
3656
- user: z22.object({ login: z22.string().min(1) }).passthrough()
3832
+ var pullRequestConversationSchema = z24.object({
3833
+ pull_request: z24.object({
3834
+ body: z24.string().nullable().optional(),
3835
+ id: z24.number().int().positive(),
3836
+ user: z24.object({ login: z24.string().min(1) }).passthrough()
3657
3837
  }).passthrough(),
3658
- repository: z22.object({ full_name: z22.string().min(1) }).passthrough(),
3659
- sender: z22.object({ login: z22.string().min(1) }).passthrough()
3838
+ repository: z24.object({ full_name: z24.string().min(1) }).passthrough(),
3839
+ sender: z24.object({ login: z24.string().min(1) }).passthrough()
3660
3840
  }).passthrough().transform(
3661
3841
  (provider) => canonicalPullRequestConversationSchema.parse({
3662
3842
  pull_request: {
@@ -3743,20 +3923,20 @@ function normalizeGitHubPullRequestLinkedIssues(args) {
3743
3923
  }
3744
3924
 
3745
3925
  // src/webhooks/merge-conflict.ts
3746
- import * as z23 from "zod";
3926
+ import * as z25 from "zod";
3747
3927
  var EVENT_TYPE = "pull_request.merge_conflict";
3748
3928
  var CLOSED_EVENT_TYPES = /* @__PURE__ */ new Set([
3749
3929
  "pull_request.closed_unmerged",
3750
3930
  "pull_request.merged"
3751
3931
  ]);
3752
- var pullRequestSchema3 = z23.object({
3753
- base: z23.object({ ref: z23.string().min(1) }),
3754
- number: z23.number().int().positive().optional(),
3755
- head: z23.object({ sha: z23.string().min(1) }),
3756
- html_url: z23.string().min(1).optional(),
3757
- mergeable: z23.boolean().nullable().optional(),
3758
- mergeable_state: z23.string().optional(),
3759
- state: z23.string()
3932
+ var pullRequestSchema3 = z25.object({
3933
+ base: z25.object({ ref: z25.string().min(1) }),
3934
+ number: z25.number().int().positive().optional(),
3935
+ head: z25.object({ sha: z25.string().min(1) }),
3936
+ html_url: z25.string().min(1).optional(),
3937
+ mergeable: z25.boolean().nullable().optional(),
3938
+ mergeable_state: z25.string().optional(),
3939
+ state: z25.string()
3760
3940
  });
3761
3941
  function gitHubMergeConflictEvents(input) {
3762
3942
  const { conflict } = input;
@@ -3796,7 +3976,7 @@ async function hasMatch(hasMatchEvent, ref) {
3796
3976
  return false;
3797
3977
  }
3798
3978
  function deliveredPullRequest(payload, ref) {
3799
- const parsed = z23.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
3979
+ const parsed = z25.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
3800
3980
  const pullRequest = parsed.success ? parsed.data.pull_request : void 0;
3801
3981
  return pullRequest?.number === ref.number && typeof pullRequest.mergeable === "boolean" ? pullRequest : void 0;
3802
3982
  }
@@ -3834,10 +4014,10 @@ async function loadGitHubMergeConflictEvents(args) {
3834
4014
  }
3835
4015
 
3836
4016
  // src/webhooks/pull-request-ready.ts
3837
- import * as z25 from "zod";
4017
+ import * as z27 from "zod";
3838
4018
 
3839
4019
  // src/webhooks/installation-requests.ts
3840
- import * as z24 from "zod";
4020
+ import * as z26 from "zod";
3841
4021
  function splitRepository(fullName, label) {
3842
4022
  const [owner, name, ...extra] = fullName.split("/");
3843
4023
  if (!owner || !name || extra.length > 0) {
@@ -3898,9 +4078,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
3898
4078
  }
3899
4079
  );
3900
4080
  }
3901
- var repositoryPermissionSchema = z24.object({
3902
- permission: z24.string().min(1),
3903
- role_name: z24.string().optional()
4081
+ var repositoryPermissionSchema = z26.object({
4082
+ permission: z26.string().min(1),
4083
+ role_name: z26.string().optional()
3904
4084
  });
3905
4085
  var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
3906
4086
  async function loadRepositoryRole(env, cache, target) {
@@ -3930,18 +4110,19 @@ async function loadRepositoryRole(env, cache, target) {
3930
4110
  }
3931
4111
  );
3932
4112
  }
3933
- var pullRequestSchema4 = z24.object({
3934
- draft: z24.boolean().optional(),
3935
- html_url: z24.string().url(),
3936
- mergeable_state: z24.string().nullable().optional(),
3937
- merged: z24.boolean(),
3938
- state: z24.enum(["open", "closed"]),
3939
- title: z24.string()
4113
+ var pullRequestSchema4 = z26.object({
4114
+ auto_merge: z26.object({}).nullable().optional(),
4115
+ draft: z26.boolean().optional(),
4116
+ html_url: z26.string().url(),
4117
+ mergeable_state: z26.string().nullable().optional(),
4118
+ merged: z26.boolean(),
4119
+ state: z26.enum(["open", "closed"]),
4120
+ title: z26.string()
3940
4121
  });
3941
- var reviewsSchema = z24.array(
3942
- z24.object({
3943
- state: z24.string(),
3944
- user: z24.object({ login: z24.string() }).nullable()
4122
+ var reviewsSchema = z26.array(
4123
+ z26.object({
4124
+ state: z26.string(),
4125
+ user: z26.object({ login: z26.string() }).nullable()
3945
4126
  })
3946
4127
  );
3947
4128
  async function loadPullRequestMergeState(env, pullRequest) {
@@ -3964,6 +4145,7 @@ async function loadPullRequestMergeState(env, pullRequest) {
3964
4145
  const mergeableState = pull.mergeable_state && pull.mergeable_state !== "unknown" ? pull.mergeable_state : void 0;
3965
4146
  return {
3966
4147
  approved: false,
4148
+ autoMerge: Boolean(pull.auto_merge),
3967
4149
  draft: pull.draft === true,
3968
4150
  ...mergeableState ? { mergeableState } : void 0,
3969
4151
  state: pull.merged ? "merged" : pull.state,
@@ -3972,7 +4154,7 @@ async function loadPullRequestMergeState(env, pullRequest) {
3972
4154
  };
3973
4155
  };
3974
4156
  let state = await readPull();
3975
- if (state.state !== "open" || state.draft) return state;
4157
+ if (state.state !== "open" || state.draft || state.autoMerge) return state;
3976
4158
  if (!state.mergeableState) state = await readPull();
3977
4159
  if (state.mergeableState !== "clean") return state;
3978
4160
  const reviews = [];
@@ -3998,6 +4180,8 @@ async function loadPullRequestMergeState(env, pullRequest) {
3998
4180
  var READY_SYNC_STALE_MS = 6e4;
3999
4181
  var READY_ACTIONS = {
4000
4182
  pull_request: /* @__PURE__ */ new Set([
4183
+ "auto_merge_disabled",
4184
+ "auto_merge_enabled",
4001
4185
  "closed",
4002
4186
  "converted_to_draft",
4003
4187
  "ready_for_review",
@@ -4006,10 +4190,10 @@ var READY_ACTIONS = {
4006
4190
  ]),
4007
4191
  pull_request_review: /* @__PURE__ */ new Set(["dismissed", "submitted"])
4008
4192
  };
4009
- var pullRequestWebhookSchema = z25.object({
4010
- action: z25.string(),
4011
- pull_request: z25.object({ number: z25.number().int().positive() }),
4012
- repository: z25.object({ full_name: z25.string().min(1) })
4193
+ var pullRequestWebhookSchema = z27.object({
4194
+ action: z27.string(),
4195
+ pull_request: z27.object({ number: z27.number().int().positive() }),
4196
+ repository: z27.object({ full_name: z27.string().min(1) })
4013
4197
  });
4014
4198
  function pullRequestReadyTargets(eventName, body) {
4015
4199
  if (eventName === "check_suite") return checkSuitePullRequests(body);
@@ -4035,6 +4219,9 @@ function closeReason(state) {
4035
4219
  status: "dismissed"
4036
4220
  };
4037
4221
  }
4222
+ if (state.autoMerge) {
4223
+ return { reason: "Auto-merge is on.", status: "dismissed" };
4224
+ }
4038
4225
  return {
4039
4226
  reason: "The pull request is no longer ready to merge.",
4040
4227
  status: "dismissed"
@@ -4062,8 +4249,8 @@ async function syncOne(args, target) {
4062
4249
  try {
4063
4250
  const state = await loadPullRequestMergeState(args.env, target);
4064
4251
  const open = state.state === "open" && !state.draft;
4065
- const ready = open && state.mergeableState === "clean" && state.approved;
4066
- if ((!open || state.mergeableState) && ready !== saved) {
4252
+ const ready = open && !state.autoMerge && state.mergeableState === "clean" && state.approved;
4253
+ if ((!open || state.autoMerge || state.mergeableState) && ready !== saved) {
4067
4254
  if (ready) {
4068
4255
  await items.upsert({
4069
4256
  assigneeIdentityIds: [opener.identityId],
@@ -4104,7 +4291,7 @@ async function syncGitHubPullRequestReadyNotices(args) {
4104
4291
  }
4105
4292
 
4106
4293
  // src/webhooks/pull-request-match-data.ts
4107
- import * as z26 from "zod";
4294
+ import * as z28 from "zod";
4108
4295
  var LOOKUPS_BY_MATCH_KEY = {
4109
4296
  authors: ["authors"],
4110
4297
  openerEmail: ["opener"],
@@ -4112,22 +4299,22 @@ var LOOKUPS_BY_MATCH_KEY = {
4112
4299
  openerUsername: ["opener"]
4113
4300
  };
4114
4301
  var ALL_LOOKUPS = ["authors", "opener", "openerRole"];
4115
- var lookupDataSchema = z26.object({
4116
- authors: z26.array(z26.string().min(1)).min(1).optional(),
4117
- openerRole: z26.string().min(1).optional(),
4118
- openerUsername: z26.string().min(1).optional()
4302
+ var lookupDataSchema = z28.object({
4303
+ authors: z28.array(z28.string().min(1)).min(1).optional(),
4304
+ openerRole: z28.string().min(1).optional(),
4305
+ openerUsername: z28.string().min(1).optional()
4119
4306
  }).strict();
4120
4307
  function lookupData(input) {
4121
4308
  return lookupDataSchema.parse(definedValues(input));
4122
4309
  }
4123
- var webhookSchema = z26.object({
4124
- repository: z26.object({ full_name: z26.string().min(1) })
4310
+ var webhookSchema = z28.object({
4311
+ repository: z28.object({ full_name: z28.string().min(1) })
4125
4312
  });
4126
4313
  function pullRequestNumbers(events) {
4127
4314
  const numbers = /* @__PURE__ */ new Map();
4128
4315
  for (const event of events) {
4129
- const number22 = event.data?.pullRequest;
4130
- if (typeof number22 === "number") numbers.set(event.eventKey, number22);
4316
+ const number23 = event.data?.pullRequest;
4317
+ if (typeof number23 === "number") numbers.set(event.eventKey, number23);
4131
4318
  }
4132
4319
  return numbers;
4133
4320
  }
@@ -4141,8 +4328,8 @@ function logFailure(context, lookup, error) {
4141
4328
  }
4142
4329
  async function withJuniorOpeners(context, events) {
4143
4330
  const botNumber = (event) => {
4144
- const number22 = context.numbers.get(event.eventKey);
4145
- return number22 !== void 0 && isBotLogin(event.data?.openerUsername, context.botEmail) ? number22 : void 0;
4331
+ const number23 = context.numbers.get(event.eventKey);
4332
+ return number23 !== void 0 && isBotLogin(event.data?.openerUsername, context.botEmail) ? number23 : void 0;
4146
4333
  };
4147
4334
  const numbers = events.flatMap((event) => botNumber(event) ?? []);
4148
4335
  if (numbers.length === 0) return events;
@@ -4161,9 +4348,9 @@ async function withJuniorOpeners(context, events) {
4161
4348
  }
4162
4349
  }
4163
4350
  return events.map((event) => {
4164
- const number22 = botNumber(event);
4165
- if (number22 === void 0) return event;
4166
- const identityId = openers.get(number22)?.identityId;
4351
+ const number23 = botNumber(event);
4352
+ if (number23 === void 0) return event;
4353
+ const identityId = openers.get(number23)?.identityId;
4167
4354
  const login = identityId ? logins.get(identityId) : void 0;
4168
4355
  const {
4169
4356
  openerEmail: _email,
@@ -4185,8 +4372,8 @@ async function withRolesAndAuthors(context, events, lookups) {
4185
4372
  if (!loadRole && !loadAuthors) return events;
4186
4373
  return await Promise.all(
4187
4374
  events.map(async (event) => {
4188
- const number22 = context.numbers.get(event.eventKey);
4189
- if (number22 === void 0) return event;
4375
+ const number23 = context.numbers.get(event.eventKey);
4376
+ if (number23 === void 0) return event;
4190
4377
  const login = event.data?.openerUsername;
4191
4378
  if (loadRole && typeof login === "string" && !roles.has(login)) {
4192
4379
  roles.set(
@@ -4196,16 +4383,16 @@ async function withRolesAndAuthors(context, events, lookups) {
4196
4383
  )
4197
4384
  );
4198
4385
  }
4199
- if (loadAuthors && !authors.has(number22)) {
4386
+ if (loadAuthors && !authors.has(number23)) {
4200
4387
  authors.set(
4201
- number22,
4202
- loadAuthors({ number: number22, repositoryFullName }).catch(
4388
+ number23,
4389
+ loadAuthors({ number: number23, repositoryFullName }).catch(
4203
4390
  (error) => logFailure(context, "authors", error)
4204
4391
  )
4205
4392
  );
4206
4393
  }
4207
4394
  const role = loadRole && typeof login === "string" ? await roles.get(login) : void 0;
4208
- const logins = loadAuthors ? await authors.get(number22) : void 0;
4395
+ const logins = loadAuthors ? await authors.get(number23) : void 0;
4209
4396
  if (!role && !logins?.length) return event;
4210
4397
  return {
4211
4398
  ...event,
@@ -4264,7 +4451,7 @@ async function withGitHubPullRequestMatchData(args) {
4264
4451
  }
4265
4452
 
4266
4453
  // src/webhooks/pull-request-people.ts
4267
- import * as z27 from "zod";
4454
+ import * as z29 from "zod";
4268
4455
  var PEOPLE_EVENTS = /* @__PURE__ */ new Set([
4269
4456
  "pull_request.review.approved",
4270
4457
  "pull_request.merged"
@@ -4274,18 +4461,18 @@ var PAGE_SIZE = 100;
4274
4461
  var MAX_PAGES = 3;
4275
4462
  var CO_AUTHOR_TRAILER = /^co-authored-by:[^<\n]*<([^>\s]+@[^>\s]+)>\s*$/gim;
4276
4463
  var GITHUB_NOREPLY_EMAIL = /^(?:\d+\+)?(?<login>[^@+]+)@users\.noreply\.github\.com$/i;
4277
- var webhookSchema2 = z27.object({
4278
- pull_request: z27.object({
4279
- assignees: z27.array(z27.object({ login: z27.string().min(1) })).nullish(),
4280
- number: z27.number(),
4281
- user: z27.object({ login: z27.string().min(1) }).nullish()
4464
+ var webhookSchema2 = z29.object({
4465
+ pull_request: z29.object({
4466
+ assignees: z29.array(z29.object({ login: z29.string().min(1) })).nullish(),
4467
+ number: z29.number(),
4468
+ user: z29.object({ login: z29.string().min(1) }).nullish()
4282
4469
  }),
4283
- repository: z27.object({ full_name: z27.string().min(1) })
4470
+ repository: z29.object({ full_name: z29.string().min(1) })
4284
4471
  });
4285
- var commitPageSchema = z27.array(
4286
- z27.object({
4287
- author: z27.object({ login: z27.string().min(1) }).nullish(),
4288
- commit: z27.object({ message: z27.string() })
4472
+ var commitPageSchema = z29.array(
4473
+ z29.object({
4474
+ author: z29.object({ login: z29.string().min(1) }).nullish(),
4475
+ commit: z29.object({ message: z29.string() })
4289
4476
  })
4290
4477
  );
4291
4478
  function shareCommitPages(load) {
@@ -4430,10 +4617,10 @@ function webhookInstallationId(body) {
4430
4617
  }
4431
4618
  return parseInstallationId(installation.id);
4432
4619
  }
4433
- var feedbackTargetSchema = z28.object({
4434
- commentId: z28.number(),
4435
- commentKind: z28.enum(["conversation", "review"]),
4436
- repo: z28.string().min(1)
4620
+ var feedbackTargetSchema = z30.object({
4621
+ commentId: z30.number(),
4622
+ commentKind: z30.enum(["conversation", "review"]),
4623
+ repo: z30.string().min(1)
4437
4624
  });
4438
4625
  function pullRequestFeedbackTarget(events) {
4439
4626
  const event = events.find(
@@ -4704,30 +4891,30 @@ function gitHubResourceUrl(input) {
4704
4891
  if (input.resourceType === "repository") {
4705
4892
  return `https://github.com/${input.identifier}`;
4706
4893
  }
4707
- const [repo, number22] = input.identifier.split("#");
4708
- if (!repo || !number22) return void 0;
4894
+ const [repo, number23] = input.identifier.split("#");
4895
+ if (!repo || !number23) return void 0;
4709
4896
  if (input.resourceType === "pull_request") {
4710
- return `https://github.com/${repo}/pull/${number22}`;
4897
+ return `https://github.com/${repo}/pull/${number23}`;
4711
4898
  }
4712
4899
  if (input.resourceType === "issue") {
4713
- return `https://github.com/${repo}/issues/${number22}`;
4900
+ return `https://github.com/${repo}/issues/${number23}`;
4714
4901
  }
4715
4902
  return void 0;
4716
4903
  }
4717
4904
 
4718
4905
  // src/pull-request-outcomes/commit-composition.ts
4719
- import * as z29 from "zod";
4720
- var canonicalCommitSchema = z29.object({
4721
- authorEmail: z29.string().nullable(),
4722
- authorLogin: z29.string().nullable()
4906
+ import * as z31 from "zod";
4907
+ var canonicalCommitSchema = z31.object({
4908
+ authorEmail: z31.string().nullable(),
4909
+ authorLogin: z31.string().nullable()
4723
4910
  }).strict();
4724
- var providerCommitSchema = z29.object({
4725
- author: z29.object({ login: z29.string() }).passthrough().nullable(),
4726
- commit: z29.object({
4727
- author: z29.object({ email: z29.string() }).passthrough().nullable()
4911
+ var providerCommitSchema = z31.object({
4912
+ author: z31.object({ login: z31.string() }).passthrough().nullable(),
4913
+ commit: z31.object({
4914
+ author: z31.object({ email: z31.string() }).passthrough().nullable()
4728
4915
  }).passthrough()
4729
4916
  }).passthrough();
4730
- var commitPageSchema2 = z29.array(providerCommitSchema).transform(
4917
+ var commitPageSchema2 = z31.array(providerCommitSchema).transform(
4731
4918
  (commits) => commits.map(
4732
4919
  (commit) => canonicalCommitSchema.parse({
4733
4920
  authorEmail: commit.commit.author?.email ?? null,
@@ -5234,8 +5421,8 @@ function linkifyLine(line) {
5234
5421
  if (isReferenceBoundary(index2 === 0 ? void 0 : line[index2 - 1])) {
5235
5422
  const match = GITHUB_ISSUE_REFERENCE_PATTERN.exec(line.slice(index2));
5236
5423
  if (match) {
5237
- const [reference, owner, repository2, number22] = match;
5238
- output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${number22})`;
5424
+ const [reference, owner, repository2, number23] = match;
5425
+ output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${number23})`;
5239
5426
  index2 += reference.length;
5240
5427
  continue;
5241
5428
  }
@@ -5377,9 +5564,9 @@ function parseGitHubReferences(text2, config) {
5377
5564
  }
5378
5565
  return [...references.values()];
5379
5566
  }
5380
- function objectTitle(kind, object29) {
5381
- if (!isRecord(object29)) return void 0;
5382
- const raw = kind === "commit" ? isRecord(object29.commit) && typeof object29.commit.message === "string" ? object29.commit.message.split("\n")[0] : void 0 : typeof object29.title === "string" ? object29.title : void 0;
5567
+ function objectTitle(kind, object31) {
5568
+ if (!isRecord(object31)) return void 0;
5569
+ const raw = kind === "commit" ? isRecord(object31.commit) && typeof object31.commit.message === "string" ? object31.commit.message.split("\n")[0] : void 0 : typeof object31.title === "string" ? object31.title : void 0;
5383
5570
  return raw?.replace(/\s+/g, " ").trim() || void 0;
5384
5571
  }
5385
5572
  async function loadGitHubConversationTitleContext(args) {
@@ -5848,6 +6035,15 @@ async function githubPermissionDeniedMessage(ctx) {
5848
6035
  );
5849
6036
  return bodyText ? githubGraphqlPermissionDeniedMessage(bodyText) : void 0;
5850
6037
  }
6038
+ var ISSUE_PATH = /^\/repos\/[^/]+\/[^/]+\/issues\/\d+$/;
6039
+ var ISSUE_READ_DENIAL = `Use github_getIssue to read a GitHub issue, not gh issue view or gh api. Read comments with gh api repos/OWNER/REPO/issues/NUMBER/comments. ${CREATE_TOOL_ROUTING_GUIDANCE}`;
6040
+ function isGitHubIssueRead(input) {
6041
+ if (isGitHubGraphqlUrl(input.upstreamUrl)) {
6042
+ const parsed = parseGitHubGraphqlRequest(input.bodyText);
6043
+ return input.method === "POST" && parsed !== void 0 && /\b(?:issue|issueOrPullRequest)\s*\(/.test(parsed.normalized);
6044
+ }
6045
+ return isGitHubApiUrl(input.upstreamUrl) && HTTP_READ_METHODS.has(input.method) && ISSUE_PATH.test(input.upstreamUrl.pathname.toLowerCase());
6046
+ }
5851
6047
  var PULL_REQUEST_COMMENT_REACTIONS_PATH = /^\/repos\/[^/]+\/[^/]+\/(issues|pulls)\/comments\/[^/]+\/reactions(?:\/[^/]+)?$/;
5852
6048
  var GITHUB_BODY_WRITES = [
5853
6049
  {
@@ -5998,6 +6194,12 @@ function applyGitHubEgressPolicy(input) {
5998
6194
  denialMessage: "GitHub pull request feedback reactions must use the github_updatePullRequestFeedback tool."
5999
6195
  });
6000
6196
  }
6197
+ if (isGitHubIssueRead(input)) {
6198
+ enforceEgressPolicy({
6199
+ allowed: input.operation === "github.issue.get",
6200
+ denialMessage: ISSUE_READ_DENIAL
6201
+ });
6202
+ }
6001
6203
  assertGitHubPullRequestApprovalDenied({
6002
6204
  ...input.bodyText !== void 0 ? { bodyText: input.bodyText } : void 0,
6003
6205
  method: input.method,