@sentry/junior-github 0.280.0 → 0.281.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
@@ -61,6 +61,76 @@ import {
61
61
  resolveUserAccount
62
62
  } from "./chunk-NSAVG2P3.js";
63
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
+ }
133
+
64
134
  // src/tool-support/attribution.ts
65
135
  var GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
66
136
  var GITHUB_REQUEST_ATTRIBUTION_END = "<!-- junior-request-attribution:end -->";
@@ -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";
@@ -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,
@@ -1239,7 +1260,7 @@ import {
1239
1260
  } from "@sentry/junior-plugin-api";
1240
1261
  import { Type as Type2 } from "@sinclair/typebox";
1241
1262
  import { Value as Value2 } from "@sinclair/typebox/value";
1242
- import * as z8 from "zod";
1263
+ import * as z9 from "zod";
1243
1264
 
1244
1265
  // src/pull-request-requesters/store.ts
1245
1266
  import { and, asc, eq, inArray, lt } from "drizzle-orm";
@@ -1254,18 +1275,18 @@ import {
1254
1275
  text,
1255
1276
  timestamp
1256
1277
  } from "drizzle-orm/pg-core";
1257
- import * as z6 from "zod";
1258
- var githubPullRequestStateSchema = z6.enum([
1278
+ import * as z7 from "zod";
1279
+ var githubPullRequestStateSchema = z7.enum([
1259
1280
  "closed_unmerged",
1260
1281
  "merged",
1261
1282
  "open"
1262
1283
  ]);
1263
- var githubPullRequestCommitCompositionSchema = z6.enum([
1284
+ var githubPullRequestCommitCompositionSchema = z7.enum([
1264
1285
  "junior_only",
1265
1286
  "mixed"
1266
1287
  ]);
1267
- var githubIssueStateSchema = z6.enum(["closed", "open"]);
1268
- var githubIssueStateReasonSchema = z6.enum([
1288
+ var githubIssueStateSchema = z7.enum(["closed", "open"]);
1289
+ var githubIssueStateReasonSchema = z7.enum([
1269
1290
  "completed",
1270
1291
  "duplicate",
1271
1292
  "not_planned",
@@ -1426,31 +1447,31 @@ async function listGitHubPullRequestOpeners(db, input) {
1426
1447
  }
1427
1448
 
1428
1449
  // src/tools/stack-pull-request.ts
1429
- import * as z7 from "zod";
1450
+ import * as z8 from "zod";
1430
1451
  var MAX_STACK_DEPTH = 10;
1431
1452
  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()
1453
+ var stackTargetSchema = z8.object({
1454
+ number: z8.number().int().positive(),
1455
+ head: z8.object({
1456
+ repo: z8.object({ full_name: z8.string().min(1) }).nullable()
1436
1457
  }),
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)
1458
+ base: z8.object({
1459
+ ref: z8.string().min(1),
1460
+ repo: z8.object({
1461
+ default_branch: z8.string().min(1),
1462
+ full_name: z8.string().min(1)
1442
1463
  })
1443
1464
  })
1444
1465
  });
1445
- var openPullRequestsSchema = z7.array(
1446
- z7.object({
1447
- number: z7.number().int().positive(),
1448
- base: z7.object({ ref: z7.string().min(1) })
1466
+ var openPullRequestsSchema = z8.array(
1467
+ z8.object({
1468
+ number: z8.number().int().positive(),
1469
+ base: z8.object({ ref: z8.string().min(1) })
1449
1470
  })
1450
1471
  );
1451
- var stackSchema = z7.object({
1452
- number: z7.number().int().positive(),
1453
- pull_requests: z7.array(z7.object({ number: z7.number().int().positive() }))
1472
+ var stackSchema = z8.object({
1473
+ number: z8.number().int().positive(),
1474
+ pull_requests: z8.array(z8.object({ number: z8.number().int().positive() }))
1454
1475
  });
1455
1476
  async function stackGitHubPullRequest(ctx, target) {
1456
1477
  const repo = target.base.repo.full_name;
@@ -1496,7 +1517,7 @@ async function stackGitHubPullRequest(ctx, target) {
1496
1517
  const stacks = await github(
1497
1518
  "github.stack.read",
1498
1519
  `${api}/stacks?pull_request=${parent.number}`,
1499
- z7.array(stackSchema)
1520
+ z8.array(stackSchema)
1500
1521
  );
1501
1522
  if (!stacks) return void 0;
1502
1523
  const stack = stacks[0];
@@ -1571,15 +1592,15 @@ var createPullRequestInputSchema = Type2.Object(
1571
1592
  },
1572
1593
  { additionalProperties: false }
1573
1594
  );
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(
1595
+ var createPullRequestToolInputSchema = z9.object({
1596
+ repo: z9.string().describe('Repository in "owner/name" format.'),
1597
+ title: z9.string().describe("Pull request title."),
1598
+ head: z9.string().describe("Head branch or owner:branch ref."),
1599
+ base: z9.string().describe("Base branch."),
1600
+ body: z9.string().describe(
1580
1601
  "Pull request body. The runtime appends the conversation footer."
1581
1602
  ).optional(),
1582
- draft: z8.boolean().describe("Whether to open the pull request as a draft.").optional()
1603
+ draft: z9.boolean().describe("Whether to open the pull request as a draft.").optional()
1583
1604
  }).strict();
1584
1605
  var createPullRequestStateSchema = Type2.Union([
1585
1606
  Type2.Object(
@@ -1604,16 +1625,16 @@ var createPullRequestStateSchema = Type2.Union([
1604
1625
  { additionalProperties: false }
1605
1626
  )
1606
1627
  ]);
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(),
1628
+ var gitHubPullRequestDataSchema = z9.object({
1629
+ number: z9.number(),
1630
+ url: z9.string(),
1631
+ stack: z9.object({ number: z9.number(), pull_requests: z9.array(z9.number()) }).optional(),
1611
1632
  subscribable: subscribableResourceSchema3.optional(),
1612
1633
  subscription: watchResultSchema.optional()
1613
1634
  });
1614
1635
  var gitHubPullRequestOutputSchema = pluginToolOutputSchema5.merge(
1615
1636
  gitHubPullRequestDataSchema.extend({
1616
- target: z8.literal("createPullRequest")
1637
+ target: z9.literal("createPullRequest")
1617
1638
  })
1618
1639
  );
1619
1640
  function parseCreatePullRequestInput(input) {
@@ -1939,28 +1960,28 @@ import {
1939
1960
  PluginToolInputError as PluginToolInputError8,
1940
1961
  pluginToolOutputSchema as pluginToolOutputSchema6
1941
1962
  } from "@sentry/junior-plugin-api";
1942
- import * as z9 from "zod";
1963
+ import * as z10 from "zod";
1943
1964
  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.")
1965
+ var commitShaSchema2 = z10.string().regex(/^[0-9a-f]{40}$/i);
1966
+ var inputSchema4 = z10.object({
1967
+ repo: z10.string().describe('Repository in "owner/name" format.'),
1968
+ number: z10.number().int().positive().describe("Pull request number.")
1948
1969
  }).strict();
1949
- var pullRequestSchema = z9.object({
1950
- base: z9.string(),
1951
- draft: z9.boolean(),
1952
- head: z9.string(),
1970
+ var pullRequestSchema = z10.object({
1971
+ base: z10.string(),
1972
+ draft: z10.boolean(),
1973
+ head: z10.string(),
1953
1974
  head_sha: commitShaSchema2,
1954
- merged: z9.boolean(),
1955
- number: z9.number(),
1956
- state: z9.string(),
1975
+ merged: z10.boolean(),
1976
+ number: z10.number(),
1977
+ state: z10.string(),
1957
1978
  subscribable: subscribableResourceSchema4.optional(),
1958
- title: z9.string(),
1959
- url: z9.string()
1979
+ title: z10.string(),
1980
+ url: z10.string()
1960
1981
  });
1961
1982
  var outputSchema4 = pluginToolOutputSchema6.merge(
1962
1983
  pullRequestSchema.extend({
1963
- target: z9.literal("getPullRequest")
1984
+ target: z10.literal("getPullRequest")
1964
1985
  })
1965
1986
  );
1966
1987
  function createGitHubGetPullRequestTool(ctx) {
@@ -1987,15 +2008,15 @@ function createGitHubGetPullRequestTool(ctx) {
1987
2008
  }
1988
2009
  throw new Error(message);
1989
2010
  }
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()
2011
+ const providerResult = z10.object({
2012
+ base: z10.object({ ref: z10.string() }),
2013
+ draft: z10.boolean(),
2014
+ head: z10.object({ ref: z10.string(), sha: commitShaSchema2 }),
2015
+ html_url: z10.string(),
2016
+ merged: z10.boolean().optional().default(false),
2017
+ number: z10.number(),
2018
+ state: z10.string(),
2019
+ title: z10.string()
1999
2020
  }).parse(response.body);
2000
2021
  const subscribable = gitHubPullRequestSubscribable({
2001
2022
  canSubscribe: ctx.events.canSubscribe,
@@ -2039,45 +2060,45 @@ import {
2039
2060
  pluginToolOutputSchema as pluginToolOutputSchema7,
2040
2061
  subscribableResourceSchema as subscribableResourceSchema5
2041
2062
  } 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(
2063
+ import * as z11 from "zod";
2064
+ var inputSchema5 = z11.object({
2065
+ repo: z11.string().describe('Repository in "owner/name" format.'),
2066
+ tag: z11.string().trim().min(1).describe(
2046
2067
  "Optional release tag name. Omit to inspect and watch every published release in the repository."
2047
2068
  ).optional()
2048
2069
  }).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()
2070
+ var releaseSchema = z11.object({
2071
+ created_at: z11.string(),
2072
+ draft: z11.boolean(),
2073
+ html_url: z11.string(),
2074
+ id: z11.number(),
2075
+ name: z11.string().nullable(),
2076
+ prerelease: z11.boolean(),
2077
+ published_at: z11.string().nullable(),
2078
+ tag_name: z11.string(),
2079
+ target_commitish: z11.string()
2059
2080
  }).strict();
2060
- var releaseSourceSchema = z10.object({
2081
+ var releaseSourceSchema = z11.object({
2061
2082
  release: releaseSchema.nullable(),
2062
- repo: z10.string(),
2083
+ repo: z11.string(),
2063
2084
  subscribable: subscribableResourceSchema5.optional(),
2064
- tag: z10.string().nullable()
2085
+ tag: z11.string().nullable()
2065
2086
  }).strict();
2066
2087
  var outputSchema5 = pluginToolOutputSchema7.merge(
2067
2088
  releaseSourceSchema.extend({
2068
- target: z10.literal("getRelease")
2089
+ target: z11.literal("getRelease")
2069
2090
  })
2070
2091
  );
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()
2092
+ var providerReleaseSchema = z11.object({
2093
+ created_at: z11.string(),
2094
+ draft: z11.boolean(),
2095
+ html_url: z11.string(),
2096
+ id: z11.number(),
2097
+ name: z11.string().nullable(),
2098
+ prerelease: z11.boolean(),
2099
+ published_at: z11.string().nullable(),
2100
+ tag_name: z11.string(),
2101
+ target_commitish: z11.string()
2081
2102
  }).passthrough();
2082
2103
  function mapRelease(providerRelease) {
2083
2104
  return {
@@ -2160,21 +2181,21 @@ import {
2160
2181
  pluginToolOutputSchema as pluginToolOutputSchema8,
2161
2182
  subscribableResourceSchema as subscribableResourceSchema6
2162
2183
  } 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.')
2184
+ import * as z12 from "zod";
2185
+ var inputSchema6 = z12.object({
2186
+ repo: z12.string().describe('Repository in "owner/name" format.')
2166
2187
  }).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(),
2188
+ var repositorySchema = z12.object({
2189
+ default_branch: z12.string(),
2190
+ description: z12.string().nullable(),
2191
+ full_name: z12.string(),
2192
+ private: z12.boolean(),
2172
2193
  subscribable: subscribableResourceSchema6.optional(),
2173
- url: z11.string()
2194
+ url: z12.string()
2174
2195
  });
2175
2196
  var outputSchema6 = pluginToolOutputSchema8.merge(
2176
2197
  repositorySchema.extend({
2177
- target: z11.literal("getRepository")
2198
+ target: z12.literal("getRepository")
2178
2199
  })
2179
2200
  );
2180
2201
  function createGitHubGetRepositoryTool(ctx) {
@@ -2199,12 +2220,12 @@ function createGitHubGetRepositoryTool(ctx) {
2199
2220
  `GitHub repository lookup failed with HTTP ${response.status}`
2200
2221
  );
2201
2222
  }
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()
2223
+ const providerResult = z12.object({
2224
+ default_branch: z12.string(),
2225
+ description: z12.string().nullable(),
2226
+ full_name: z12.string(),
2227
+ html_url: z12.string(),
2228
+ private: z12.boolean()
2208
2229
  }).parse(response.body);
2209
2230
  const subscribable = gitHubRepositorySubscribable({
2210
2231
  canSubscribe: ctx.events.canSubscribe,
@@ -2231,24 +2252,24 @@ import {
2231
2252
  definePluginTool as definePluginTool9,
2232
2253
  pluginToolOutputSchema as pluginToolOutputSchema9
2233
2254
  } from "@sentry/junior-plugin-api";
2234
- import * as z13 from "zod";
2255
+ import * as z14 from "zod";
2235
2256
 
2236
2257
  // src/github-status.ts
2237
- import * as z12 from "zod";
2258
+ import * as z13 from "zod";
2238
2259
  var GITHUB_STATUS_INCIDENTS_URL = "https://www.githubstatus.com/api/v2/incidents.json";
2239
2260
  var GITHUB_STATUS_TTL_MS = 60 * 1e3;
2240
2261
  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()
2262
+ var incidentsResponseSchema = z13.object({
2263
+ incidents: z13.array(
2264
+ z13.object({
2265
+ components: z13.array(z13.object({ name: z13.string() })).default([]),
2266
+ created_at: z13.string(),
2267
+ impact: z13.string(),
2268
+ name: z13.string(),
2269
+ resolved_at: z13.string().nullable(),
2270
+ shortlink: z13.string(),
2271
+ started_at: z13.string().nullable().optional(),
2272
+ status: z13.string()
2252
2273
  })
2253
2274
  )
2254
2275
  });
@@ -2290,19 +2311,19 @@ async function loadGitHubStatusIncidents(cache, withinMs) {
2290
2311
 
2291
2312
  // src/tools/get-status.ts
2292
2313
  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()
2314
+ var inputSchema7 = z14.object({}).strict();
2315
+ var incidentSchema = z14.object({
2316
+ components: z14.array(z14.string()),
2317
+ impact: z14.string(),
2318
+ name: z14.string(),
2319
+ resolved_at: z14.string().optional(),
2320
+ started_at: z14.string(),
2321
+ status: z14.string(),
2322
+ url: z14.string()
2302
2323
  });
2303
2324
  var outputSchema7 = pluginToolOutputSchema9.extend({
2304
- target: z13.literal("getStatus"),
2305
- incidents: z13.array(incidentSchema)
2325
+ target: z14.literal("getStatus"),
2326
+ incidents: z14.array(incidentSchema)
2306
2327
  });
2307
2328
  function createGitHubGetStatusTool(ctx) {
2308
2329
  return definePluginTool9({
@@ -2342,30 +2363,30 @@ import {
2342
2363
  pluginToolOutputSchema as pluginToolOutputSchema10,
2343
2364
  subscribableResourceSchema as subscribableResourceSchema7
2344
2365
  } 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(
2366
+ import * as z15 from "zod";
2367
+ var inputSchema8 = z15.object({
2368
+ repo: z15.string().describe('Repository in "owner/name" format.'),
2369
+ number: z15.number().int().positive().describe("Issue number."),
2370
+ title: z15.string().trim().min(1).optional().describe("Replacement issue title."),
2371
+ body: z15.string().optional().describe(
2351
2372
  "Replacement issue body. The runtime appends requester attribution and the conversation footer."
2352
2373
  ),
2353
- state: z14.enum(["open", "closed"]).optional().describe("Replacement issue state.")
2374
+ state: z15.enum(["open", "closed"]).optional().describe("Replacement issue state.")
2354
2375
  }).strict().refine(
2355
2376
  ({ title, body, state }) => title !== void 0 || body !== void 0 || state !== void 0,
2356
2377
  { message: "At least one issue field must be provided." }
2357
2378
  );
2358
- var issueSchema = z14.object({
2359
- body: z14.string().nullable(),
2360
- number: z14.number(),
2361
- state: z14.string(),
2379
+ var issueSchema = z15.object({
2380
+ body: z15.string().nullable(),
2381
+ number: z15.number(),
2382
+ state: z15.string(),
2362
2383
  subscribable: subscribableResourceSchema7.optional(),
2363
- title: z14.string(),
2364
- url: z14.string()
2384
+ title: z15.string(),
2385
+ url: z15.string()
2365
2386
  });
2366
2387
  var outputSchema8 = pluginToolOutputSchema10.merge(
2367
2388
  issueSchema.extend({
2368
- target: z14.literal("updateIssue")
2389
+ target: z15.literal("updateIssue")
2369
2390
  })
2370
2391
  );
2371
2392
  function nonEmptyString4(value, name) {
@@ -2392,6 +2413,10 @@ function createGitHubUpdateIssueTool(ctx) {
2392
2413
  }
2393
2414
  const update = parsedInput.data;
2394
2415
  const repo = parseRepo(update.repo);
2416
+ const currentBody = update.body !== void 0 ? await readGitHubBody(ctx.egress, {
2417
+ operation: "github.issue.get",
2418
+ path: `${repoPath(repo)}/issues/${update.number}`
2419
+ }) : void 0;
2395
2420
  const payload = {
2396
2421
  ...update.title !== void 0 ? { title: update.title } : void 0,
2397
2422
  ...update.body !== void 0 ? {
@@ -2399,7 +2424,8 @@ function createGitHubUpdateIssueTool(ctx) {
2399
2424
  appendGitHubRequesterAttribution(
2400
2425
  update.body,
2401
2426
  ctx,
2402
- await resolveGitHubRequester(ctx)
2427
+ await resolveGitHubRequester(ctx),
2428
+ currentBody
2403
2429
  ),
2404
2430
  nonEmptyString4(ctx.conversationId, "conversationId"),
2405
2431
  ctx.slack?.conversationLink?.url
@@ -2419,12 +2445,12 @@ function createGitHubUpdateIssueTool(ctx) {
2419
2445
  `GitHub issue update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`
2420
2446
  );
2421
2447
  }
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()
2448
+ const providerResult = z15.object({
2449
+ body: z15.string().nullable().optional().default(null),
2450
+ html_url: z15.string(),
2451
+ number: z15.number(),
2452
+ state: z15.string(),
2453
+ title: z15.string()
2428
2454
  }).parse(parsed);
2429
2455
  const subscribable = gitHubIssueSubscribable({
2430
2456
  canSubscribe: ctx.events.canSubscribe,
@@ -2461,18 +2487,18 @@ import {
2461
2487
  PluginToolInputError as PluginToolInputError11,
2462
2488
  pluginToolOutputSchema as pluginToolOutputSchema11
2463
2489
  } from "@sentry/junior-plugin-api";
2464
- import * as z15 from "zod";
2490
+ import * as z16 from "zod";
2465
2491
  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(
2492
+ var inputSchema9 = z16.object({
2493
+ repo: z16.string().describe('Repository in "owner/name" format.'),
2494
+ number: z16.number().int().positive().describe("Pull request number."),
2495
+ title: z16.string().trim().min(1).optional().describe("Replacement pull request title."),
2496
+ body: z16.string().optional().describe(
2471
2497
  "Replacement pull request body. The runtime appends requester attribution and the conversation footer."
2472
2498
  ),
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(
2499
+ base: z16.string().trim().min(1).optional().describe("Replacement base branch."),
2500
+ state: z16.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
2501
+ draft: z16.boolean().optional().describe(
2476
2502
  "Set false to mark a draft pull request ready for review, or true to convert it back to a draft."
2477
2503
  )
2478
2504
  }).strict().refine(
@@ -2487,24 +2513,24 @@ var CONVERT_TO_DRAFT = {
2487
2513
  operationName: "ConvertPullRequestToDraft",
2488
2514
  query: "mutation ConvertPullRequestToDraft($id: ID!) { result: convertPullRequestToDraft(input: {pullRequestId: $id}) { pullRequest { isDraft } } }"
2489
2515
  };
2490
- var draftMutationResponseSchema = z15.object({
2491
- data: z15.object({
2492
- result: z15.object({ pullRequest: z15.object({ isDraft: z15.boolean() }) })
2516
+ var draftMutationResponseSchema = z16.object({
2517
+ data: z16.object({
2518
+ result: z16.object({ pullRequest: z16.object({ isDraft: z16.boolean() }) })
2493
2519
  })
2494
2520
  });
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(),
2521
+ var pullRequestSchema2 = z16.object({
2522
+ base: z16.string(),
2523
+ body: z16.string().nullable(),
2524
+ draft: z16.boolean(),
2525
+ number: z16.number(),
2526
+ state: z16.string(),
2501
2527
  subscribable: subscribableResourceSchema8.optional(),
2502
- title: z15.string(),
2503
- url: z15.string()
2528
+ title: z16.string(),
2529
+ url: z16.string()
2504
2530
  });
2505
2531
  var outputSchema9 = pluginToolOutputSchema11.merge(
2506
2532
  pullRequestSchema2.extend({
2507
- target: z15.literal("updatePullRequest")
2533
+ target: z16.literal("updatePullRequest")
2508
2534
  })
2509
2535
  );
2510
2536
  function nonEmptyString5(value, name) {
@@ -2556,11 +2582,20 @@ function createGitHubUpdatePullRequestTool(ctx) {
2556
2582
  const update = parsedInput.data;
2557
2583
  const repo = parseRepo(update.repo);
2558
2584
  const requester = await resolveGitHubRequester(ctx);
2585
+ const currentBody = update.body !== void 0 ? await readGitHubBody(ctx.egress, {
2586
+ operation: "github.pull.get",
2587
+ path: `${repoPath(repo)}/pulls/${update.number}`
2588
+ }) : void 0;
2559
2589
  const payload = {
2560
2590
  ...update.title !== void 0 ? { title: update.title } : void 0,
2561
2591
  ...update.body !== void 0 ? {
2562
2592
  body: appendGitHubFooter(
2563
- appendGitHubRequesterAttribution(update.body, ctx, requester),
2593
+ appendGitHubRequesterAttribution(
2594
+ update.body,
2595
+ ctx,
2596
+ requester,
2597
+ currentBody
2598
+ ),
2564
2599
  nonEmptyString5(ctx.conversationId, "conversationId"),
2565
2600
  ctx.slack?.conversationLink?.url
2566
2601
  )
@@ -2580,16 +2615,16 @@ function createGitHubUpdatePullRequestTool(ctx) {
2580
2615
  `GitHub pull request update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`
2581
2616
  );
2582
2617
  }
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()
2618
+ const providerResult = z16.object({
2619
+ base: z16.object({ ref: z16.string() }),
2620
+ body: z16.string().nullable().optional().default(null),
2621
+ draft: z16.boolean(),
2622
+ html_url: z16.string(),
2623
+ merged: z16.boolean(),
2624
+ node_id: z16.string().optional(),
2625
+ number: z16.number(),
2626
+ state: z16.string(),
2627
+ title: z16.string()
2593
2628
  }).parse(parsed);
2594
2629
  if (update.draft !== void 0 && update.draft !== providerResult.draft) {
2595
2630
  if (!providerResult.node_id) {
@@ -2654,7 +2689,7 @@ import {
2654
2689
  PluginToolInputError as PluginToolInputError12,
2655
2690
  pluginToolOutputSchema as pluginToolOutputSchema12
2656
2691
  } from "@sentry/junior-plugin-api";
2657
- import * as z16 from "zod";
2692
+ import * as z17 from "zod";
2658
2693
  var STATUS_TO_REACTION_CONTENT = {
2659
2694
  reviewing: "eyes",
2660
2695
  addressed: "+1",
@@ -2663,24 +2698,24 @@ var STATUS_TO_REACTION_CONTENT = {
2663
2698
  var FEEDBACK_REACTION_CONTENTS = new Set(
2664
2699
  Object.values(STATUS_TO_REACTION_CONTENT)
2665
2700
  );
2666
- var inputSchema10 = z16.object({
2667
- repo: z16.string().describe('Repository in "owner/name" format.'),
2668
- comment_kind: z16.enum(["conversation", "review"]).describe(
2701
+ var inputSchema10 = z17.object({
2702
+ repo: z17.string().describe('Repository in "owner/name" format.'),
2703
+ comment_kind: z17.enum(["conversation", "review"]).describe(
2669
2704
  'Comment kind: "conversation" for a pull request conversation comment, "review" for an inline review comment.'
2670
2705
  ),
2671
- comment_id: z16.number().int().positive().describe(
2706
+ comment_id: z17.number().int().positive().describe(
2672
2707
  "GitHub comment id (conversation comment id or inline review comment id)."
2673
2708
  ),
2674
- status: z16.enum(["addressed", "declined"]).describe(
2709
+ status: z17.enum(["addressed", "declined"]).describe(
2675
2710
  "Feedback outcome. Maps to a reaction: addressed -> +1, declined -> -1."
2676
2711
  )
2677
2712
  }).strict();
2678
2713
  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()
2714
+ target: z17.literal("updatePullRequestFeedback"),
2715
+ repo: z17.string(),
2716
+ comment_id: z17.number(),
2717
+ status: z17.enum(["addressed", "declined"]),
2718
+ reaction_id: z17.number()
2684
2719
  });
2685
2720
  function pullRequestCommentPath(input) {
2686
2721
  const segment = input.commentKind === "conversation" ? "issues" : "pulls";
@@ -2692,10 +2727,10 @@ function pullRequestCommentReactionsPath(input) {
2692
2727
  function pullRequestFeedbackReactionContent(status) {
2693
2728
  return STATUS_TO_REACTION_CONTENT[status];
2694
2729
  }
2695
- var reactionSchema = z16.object({
2696
- id: z16.number(),
2697
- content: z16.string(),
2698
- user: z16.object({ id: z16.number() }).nullable()
2730
+ var reactionSchema = z17.object({
2731
+ id: z17.number(),
2732
+ content: z17.string(),
2733
+ user: z17.object({ id: z17.number() }).nullable()
2699
2734
  });
2700
2735
  async function assertBotAuthoredPullRequest(egress, input) {
2701
2736
  const commentResponse = await githubApi(egress, {
@@ -2708,9 +2743,9 @@ async function assertBotAuthoredPullRequest(egress, input) {
2708
2743
  if (commentResponse.status === 404) throw new PluginToolInputError12(message);
2709
2744
  throw new Error(message);
2710
2745
  }
2711
- const comment = z16.object({
2712
- issue_url: z16.string().optional(),
2713
- pull_request_url: z16.string().optional()
2746
+ const comment = z17.object({
2747
+ issue_url: z17.string().optional(),
2748
+ pull_request_url: z17.string().optional()
2714
2749
  }).safeParse(commentPayload);
2715
2750
  const parentUrl = comment.success ? input.commentKind === "conversation" ? comment.data.issue_url : comment.data.pull_request_url : void 0;
2716
2751
  const number22 = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
@@ -2727,7 +2762,7 @@ async function assertBotAuthoredPullRequest(egress, input) {
2727
2762
  `GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${githubErrorMessage(pullPayload)}`
2728
2763
  );
2729
2764
  }
2730
- const pull = z16.object({ user: z16.object({ id: z16.number() }).nullable() }).safeParse(pullPayload);
2765
+ const pull = z17.object({ user: z17.object({ id: z17.number() }).nullable() }).safeParse(pullPayload);
2731
2766
  if (!pullResponse.ok || !pull.success || pull.data.user?.id !== input.botUserId) {
2732
2767
  throw new PluginToolInputError12(
2733
2768
  "This bot can only set feedback status on comments on pull requests it authored."
@@ -2791,7 +2826,7 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2791
2826
  `GitHub reaction lookup failed with HTTP ${listResponse.status}: ${githubErrorMessage(listPayload)}`
2792
2827
  );
2793
2828
  }
2794
- const botReactions = z16.array(reactionSchema).parse(listPayload).filter(
2829
+ const botReactions = z17.array(reactionSchema).parse(listPayload).filter(
2795
2830
  (reaction) => reaction.user?.id === botUserId && FEEDBACK_REACTION_CONTENTS.has(reaction.content)
2796
2831
  );
2797
2832
  const existing = botReactions.find(
@@ -2849,21 +2884,21 @@ import {
2849
2884
  PluginToolInputError as PluginToolInputError13,
2850
2885
  pluginToolOutputSchema as pluginToolOutputSchema13
2851
2886
  } from "@sentry/junior-plugin-api";
2852
- import * as z17 from "zod";
2853
- var inputSchema11 = z17.object({
2854
- repo: z17.string().describe(
2887
+ import * as z18 from "zod";
2888
+ var inputSchema11 = z18.object({
2889
+ repo: z18.string().describe(
2855
2890
  'Repository in "owner/name" format. Required because GraphQL has no repo path.'
2856
2891
  ),
2857
- thread_id: z17.string().trim().min(1).describe(
2892
+ thread_id: z18.string().trim().min(1).describe(
2858
2893
  "GitHub pull request review thread node ID (the `threadId` / `id` variable used by `gh api graphql` resolveReviewThread)."
2859
2894
  )
2860
2895
  }).strict();
2861
2896
  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()
2897
+ target: z18.literal("resolvePullRequestReviewThread"),
2898
+ repo: z18.string(),
2899
+ number: z18.number(),
2900
+ thread_id: z18.string(),
2901
+ resolved: z18.boolean()
2867
2902
  });
2868
2903
  function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
2869
2904
  return definePluginTool13({
@@ -2923,18 +2958,18 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
2923
2958
  `GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubErrorMessage(lookupPayload)}`
2924
2959
  );
2925
2960
  }
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()
2961
+ const threadNodeSchema = z18.object({
2962
+ id: z18.string(),
2963
+ isResolved: z18.boolean(),
2964
+ pullRequest: z18.object({
2965
+ author: z18.object({ databaseId: z18.number().optional() }).passthrough().nullable(),
2966
+ number: z18.number(),
2967
+ repository: z18.object({ nameWithOwner: z18.string() }).passthrough()
2933
2968
  }).passthrough()
2934
2969
  }).passthrough();
2935
- const lookupResultSchema = z17.object({
2936
- data: z17.object({
2937
- node: z17.unknown().nullable().optional()
2970
+ const lookupResultSchema = z18.object({
2971
+ data: z18.object({
2972
+ node: z18.unknown().nullable().optional()
2938
2973
  }).passthrough()
2939
2974
  }).passthrough();
2940
2975
  const lookupResult = lookupResultSchema.safeParse(lookupPayload);
@@ -2981,10 +3016,10 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
2981
3016
  `GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubErrorMessage(resolvePayload)}`
2982
3017
  );
2983
3018
  }
2984
- const resolveResultSchema = z17.object({
2985
- data: z17.object({
2986
- resolveReviewThread: z17.object({
2987
- thread: z17.object({ id: z17.string(), isResolved: z17.boolean() }).passthrough()
3019
+ const resolveResultSchema = z18.object({
3020
+ data: z18.object({
3021
+ resolveReviewThread: z18.object({
3022
+ thread: z18.object({ id: z18.string(), isResolved: z18.boolean() }).passthrough()
2988
3023
  }).passthrough()
2989
3024
  }).passthrough()
2990
3025
  }).passthrough();
@@ -3016,32 +3051,32 @@ import {
3016
3051
  PluginToolInputError as PluginToolInputError14,
3017
3052
  pluginToolOutputSchema as pluginToolOutputSchema14
3018
3053
  } 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.")
3054
+ import * as z19 from "zod";
3055
+ var reviewCommentSchema = z19.object({
3056
+ path: z19.string().trim().min(1).describe("File path in the pull request."),
3057
+ body: z19.string().trim().min(1).describe("Inline review comment."),
3058
+ line: z19.number().int().positive().describe("Line in the pull request diff."),
3059
+ side: z19.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
3060
+ start_line: z19.number().int().positive().optional().describe("First line of a multi-line comment."),
3061
+ start_side: z19.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
3027
3062
  }).strict().refine(
3028
3063
  ({ start_line, start_side }) => start_line === void 0 === (start_side === void 0),
3029
3064
  { message: "start_line and start_side must be provided together." }
3030
3065
  );
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.")
3066
+ var inputSchema12 = z19.object({
3067
+ repo: z19.string().describe('Repository in "owner/name" format.'),
3068
+ number: z19.number().int().positive().describe("Pull request number."),
3069
+ event: z19.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
3070
+ body: z19.string().trim().min(1).describe("Review summary."),
3071
+ comments: z19.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
3037
3072
  }).strict();
3038
3073
  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()
3074
+ target: z19.literal("submitPullRequestReview"),
3075
+ repo: z19.string(),
3076
+ number: z19.number(),
3077
+ review_id: z19.number(),
3078
+ state: z19.string(),
3079
+ url: z19.string()
3045
3080
  });
3046
3081
  function throwReviewError(status, body) {
3047
3082
  const message = `GitHub pull request review failed with HTTP ${status}: ${githubErrorMessage(body)}`;
@@ -3085,7 +3120,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
3085
3120
  if (!response.ok) {
3086
3121
  throwReviewError(response.status, response.body);
3087
3122
  }
3088
- const providerResult = z18.object({ id: z18.number(), html_url: z18.string(), state: z18.string() }).parse(response.body);
3123
+ const providerResult = z19.object({ id: z19.number(), html_url: z19.string(), state: z19.string() }).parse(response.body);
3089
3124
  return {
3090
3125
  target: "submitPullRequestReview",
3091
3126
  repo: repo.ref,
@@ -3128,26 +3163,26 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
3128
3163
 
3129
3164
  // src/webhooks/handler.ts
3130
3165
  import { createHmac, timingSafeEqual } from "crypto";
3131
- import * as z28 from "zod";
3166
+ import * as z29 from "zod";
3132
3167
 
3133
3168
  // src/issue-outcomes/store.ts
3134
3169
  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),
3170
+ import * as z20 from "zod";
3171
+ var githubIssueOutcomeInputSchema = z20.object({
3172
+ candidateOwned: z20.boolean(),
3173
+ closedAt: z20.date().optional(),
3174
+ issueId: z20.string().min(1),
3175
+ number: z20.number().int().positive(),
3176
+ openedAt: z20.date(),
3177
+ repositoryFullName: z20.string().min(1),
3178
+ repositoryId: z20.string().min(1),
3144
3179
  state: githubIssueStateSchema,
3145
3180
  stateReason: githubIssueStateReasonSchema.optional(),
3146
- updatedAt: z19.date()
3181
+ updatedAt: z20.date()
3147
3182
  }).strict();
3148
- var githubIssueConversationsInputSchema = z19.object({
3149
- conversationIds: z19.array(z19.string().min(1)).min(1),
3150
- issueId: z19.string().min(1)
3183
+ var githubIssueConversationsInputSchema = z20.object({
3184
+ conversationIds: z20.array(z20.string().min(1)).min(1),
3185
+ issueId: z20.string().min(1)
3151
3186
  }).strict();
3152
3187
  function projectionValues(input) {
3153
3188
  return {
@@ -3211,33 +3246,33 @@ async function recordGitHubIssueConversations(db, input) {
3211
3246
 
3212
3247
  // src/pull-request-outcomes/store.ts
3213
3248
  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(),
3249
+ import * as z21 from "zod";
3250
+ var githubPullRequestOutcomeInputSchema = z21.object({
3251
+ candidateOwned: z21.boolean(),
3252
+ closedAt: z21.date().optional(),
3218
3253
  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),
3254
+ mergedAt: z21.date().optional(),
3255
+ number: z21.number().int().positive(),
3256
+ openedAt: z21.date(),
3257
+ pullRequestId: z21.string().min(1),
3258
+ repositoryFullName: z21.string().min(1),
3259
+ repositoryId: z21.string().min(1),
3225
3260
  state: githubPullRequestStateSchema,
3226
- title: z20.string().min(1).optional(),
3227
- updatedAt: z20.date()
3261
+ title: z21.string().min(1).optional(),
3262
+ updatedAt: z21.date()
3228
3263
  }).strict();
3229
- var githubPullRequestConversationsInputSchema = z20.object({
3230
- conversationIds: z20.array(z20.string().min(1)).min(1),
3231
- pullRequestId: z20.string().min(1)
3264
+ var githubPullRequestConversationsInputSchema = z21.object({
3265
+ conversationIds: z21.array(z21.string().min(1)).min(1),
3266
+ pullRequestId: z21.string().min(1)
3232
3267
  }).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)
3268
+ var githubPullRequestLinkedIssuesInputSchema = z21.object({
3269
+ linkedIssues: z21.array(
3270
+ z21.object({
3271
+ number: z21.number().int().positive(),
3272
+ repositoryFullName: z21.string().min(1)
3238
3273
  }).strict()
3239
3274
  ).min(1),
3240
- pullRequestId: z20.string().min(1)
3275
+ pullRequestId: z21.string().min(1)
3241
3276
  }).strict();
3242
3277
  function projectionValues2(input) {
3243
3278
  return {
@@ -3442,39 +3477,39 @@ async function releaseGitHubPullRequestReadySync(db, target, claim) {
3442
3477
  }
3443
3478
 
3444
3479
  // 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(),
3480
+ import * as z22 from "zod";
3481
+ var canonicalIssueOutcomeSchema = z22.object({
3482
+ action: z22.enum(["opened", "closed", "reopened"]),
3483
+ issue: z22.object({
3484
+ body: z22.string().nullable().optional(),
3485
+ closed_at: z22.string().nullable().optional(),
3486
+ created_at: z22.string(),
3487
+ id: z22.number().int().positive(),
3488
+ number: z22.number().int().positive(),
3454
3489
  state_reason: githubIssueStateReasonSchema.nullable().optional(),
3455
- updated_at: z21.string(),
3456
- user: z21.object({ login: z21.string().min(1) }).strict()
3490
+ updated_at: z22.string(),
3491
+ user: z22.object({ login: z22.string().min(1) }).strict()
3457
3492
  }).strict(),
3458
- repository: z21.object({
3459
- full_name: z21.string().min(1),
3460
- id: z21.number().int().positive()
3493
+ repository: z22.object({
3494
+ full_name: z22.string().min(1),
3495
+ id: z22.number().int().positive()
3461
3496
  }).strict()
3462
3497
  }).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(),
3498
+ var issueOutcomeSchema = z22.object({
3499
+ action: z22.enum(["opened", "closed", "reopened"]),
3500
+ issue: z22.object({
3501
+ body: z22.string().nullable().optional(),
3502
+ closed_at: z22.string().nullable().optional(),
3503
+ created_at: z22.string(),
3504
+ id: z22.number().int().positive(),
3505
+ number: z22.number().int().positive(),
3471
3506
  state_reason: githubIssueStateReasonSchema.nullable().optional(),
3472
- updated_at: z21.string(),
3473
- user: z21.object({ login: z21.string().min(1) }).passthrough()
3507
+ updated_at: z22.string(),
3508
+ user: z22.object({ login: z22.string().min(1) }).passthrough()
3474
3509
  }).passthrough(),
3475
- repository: z21.object({
3476
- full_name: z21.string().min(1),
3477
- id: z21.number().int().positive()
3510
+ repository: z22.object({
3511
+ full_name: z22.string().min(1),
3512
+ id: z22.number().int().positive()
3478
3513
  }).passthrough()
3479
3514
  }).passthrough().transform(
3480
3515
  (provider) => canonicalIssueOutcomeSchema.parse({
@@ -3495,7 +3530,7 @@ var issueOutcomeSchema = z21.object({
3495
3530
  }
3496
3531
  })
3497
3532
  );
3498
- var issueLifecycleActionSchema = z21.object({ action: z21.string() }).passthrough();
3533
+ var issueLifecycleActionSchema = z22.object({ action: z22.string() }).passthrough();
3499
3534
  function timestamp2(value) {
3500
3535
  if (!value) return void 0;
3501
3536
  const parsed = new Date(value);
@@ -3539,21 +3574,21 @@ function normalizeGitHubIssueOutcome(args) {
3539
3574
  updatedAt
3540
3575
  };
3541
3576
  }
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()
3577
+ var canonicalIssueConversationSchema = z22.object({
3578
+ issue: z22.object({
3579
+ body: z22.string().nullable().optional(),
3580
+ id: z22.number().int().positive(),
3581
+ user: z22.object({ login: z22.string().min(1) }).strict()
3547
3582
  }).strict(),
3548
- sender: z21.object({ login: z21.string().min(1) }).strict().optional()
3583
+ sender: z22.object({ login: z22.string().min(1) }).strict().optional()
3549
3584
  }).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()
3585
+ var issueConversationSchema = z22.object({
3586
+ issue: z22.object({
3587
+ body: z22.string().nullable().optional(),
3588
+ id: z22.number().int().positive(),
3589
+ user: z22.object({ login: z22.string().min(1) }).passthrough()
3555
3590
  }).passthrough(),
3556
- sender: z21.object({ login: z21.string().min(1) }).passthrough().optional()
3591
+ sender: z22.object({ login: z22.string().min(1) }).passthrough().optional()
3557
3592
  }).passthrough().transform(
3558
3593
  (provider) => canonicalIssueConversationSchema.parse({
3559
3594
  issue: {
@@ -3580,43 +3615,43 @@ function normalizeGitHubIssueConversations(args) {
3580
3615
  }
3581
3616
 
3582
3617
  // 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()
3618
+ import * as z23 from "zod";
3619
+ var canonicalPullRequestOutcomeSchema = z23.object({
3620
+ action: z23.enum(["opened", "closed", "reopened"]),
3621
+ pull_request: z23.object({
3622
+ body: z23.string().nullable().optional(),
3623
+ closed_at: z23.string().nullable().optional(),
3624
+ created_at: z23.string(),
3625
+ id: z23.number().int().positive(),
3626
+ merged: z23.boolean(),
3627
+ merged_at: z23.string().nullable().optional(),
3628
+ number: z23.number().int().positive(),
3629
+ title: z23.string().min(1).optional(),
3630
+ updated_at: z23.string(),
3631
+ user: z23.object({ login: z23.string().min(1) }).strict()
3597
3632
  }).strict(),
3598
- repository: z22.object({
3599
- full_name: z22.string().min(1),
3600
- id: z22.number().int().positive()
3633
+ repository: z23.object({
3634
+ full_name: z23.string().min(1),
3635
+ id: z23.number().int().positive()
3601
3636
  }).strict()
3602
3637
  }).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()
3638
+ var pullRequestOutcomeSchema = z23.object({
3639
+ action: z23.enum(["opened", "closed", "reopened"]),
3640
+ pull_request: z23.object({
3641
+ body: z23.string().nullable().optional(),
3642
+ closed_at: z23.string().nullable().optional(),
3643
+ created_at: z23.string(),
3644
+ id: z23.number().int().positive(),
3645
+ merged: z23.boolean(),
3646
+ merged_at: z23.string().nullable().optional(),
3647
+ number: z23.number().int().positive(),
3648
+ title: z23.string().min(1).optional(),
3649
+ updated_at: z23.string(),
3650
+ user: z23.object({ login: z23.string().min(1) }).passthrough()
3616
3651
  }).passthrough(),
3617
- repository: z22.object({
3618
- full_name: z22.string().min(1),
3619
- id: z22.number().int().positive()
3652
+ repository: z23.object({
3653
+ full_name: z23.string().min(1),
3654
+ id: z23.number().int().positive()
3620
3655
  }).passthrough()
3621
3656
  }).passthrough().transform(
3622
3657
  (provider) => canonicalPullRequestOutcomeSchema.parse({
@@ -3639,24 +3674,24 @@ var pullRequestOutcomeSchema = z22.object({
3639
3674
  }
3640
3675
  })
3641
3676
  );
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()
3677
+ var pullRequestLifecycleActionSchema = z23.object({ action: z23.string() }).passthrough();
3678
+ var canonicalPullRequestConversationSchema = z23.object({
3679
+ pull_request: z23.object({
3680
+ body: z23.string().nullable().optional(),
3681
+ id: z23.number().int().positive(),
3682
+ user: z23.object({ login: z23.string().min(1) }).strict()
3648
3683
  }).strict(),
3649
- repository: z22.object({ full_name: z22.string().min(1) }).strict(),
3650
- sender: z22.object({ login: z22.string().min(1) }).strict()
3684
+ repository: z23.object({ full_name: z23.string().min(1) }).strict(),
3685
+ sender: z23.object({ login: z23.string().min(1) }).strict()
3651
3686
  }).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()
3687
+ var pullRequestConversationSchema = z23.object({
3688
+ pull_request: z23.object({
3689
+ body: z23.string().nullable().optional(),
3690
+ id: z23.number().int().positive(),
3691
+ user: z23.object({ login: z23.string().min(1) }).passthrough()
3657
3692
  }).passthrough(),
3658
- repository: z22.object({ full_name: z22.string().min(1) }).passthrough(),
3659
- sender: z22.object({ login: z22.string().min(1) }).passthrough()
3693
+ repository: z23.object({ full_name: z23.string().min(1) }).passthrough(),
3694
+ sender: z23.object({ login: z23.string().min(1) }).passthrough()
3660
3695
  }).passthrough().transform(
3661
3696
  (provider) => canonicalPullRequestConversationSchema.parse({
3662
3697
  pull_request: {
@@ -3743,20 +3778,20 @@ function normalizeGitHubPullRequestLinkedIssues(args) {
3743
3778
  }
3744
3779
 
3745
3780
  // src/webhooks/merge-conflict.ts
3746
- import * as z23 from "zod";
3781
+ import * as z24 from "zod";
3747
3782
  var EVENT_TYPE = "pull_request.merge_conflict";
3748
3783
  var CLOSED_EVENT_TYPES = /* @__PURE__ */ new Set([
3749
3784
  "pull_request.closed_unmerged",
3750
3785
  "pull_request.merged"
3751
3786
  ]);
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()
3787
+ var pullRequestSchema3 = z24.object({
3788
+ base: z24.object({ ref: z24.string().min(1) }),
3789
+ number: z24.number().int().positive().optional(),
3790
+ head: z24.object({ sha: z24.string().min(1) }),
3791
+ html_url: z24.string().min(1).optional(),
3792
+ mergeable: z24.boolean().nullable().optional(),
3793
+ mergeable_state: z24.string().optional(),
3794
+ state: z24.string()
3760
3795
  });
3761
3796
  function gitHubMergeConflictEvents(input) {
3762
3797
  const { conflict } = input;
@@ -3796,7 +3831,7 @@ async function hasMatch(hasMatchEvent, ref) {
3796
3831
  return false;
3797
3832
  }
3798
3833
  function deliveredPullRequest(payload, ref) {
3799
- const parsed = z23.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
3834
+ const parsed = z24.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
3800
3835
  const pullRequest = parsed.success ? parsed.data.pull_request : void 0;
3801
3836
  return pullRequest?.number === ref.number && typeof pullRequest.mergeable === "boolean" ? pullRequest : void 0;
3802
3837
  }
@@ -3834,10 +3869,10 @@ async function loadGitHubMergeConflictEvents(args) {
3834
3869
  }
3835
3870
 
3836
3871
  // src/webhooks/pull-request-ready.ts
3837
- import * as z25 from "zod";
3872
+ import * as z26 from "zod";
3838
3873
 
3839
3874
  // src/webhooks/installation-requests.ts
3840
- import * as z24 from "zod";
3875
+ import * as z25 from "zod";
3841
3876
  function splitRepository(fullName, label) {
3842
3877
  const [owner, name, ...extra] = fullName.split("/");
3843
3878
  if (!owner || !name || extra.length > 0) {
@@ -3898,9 +3933,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
3898
3933
  }
3899
3934
  );
3900
3935
  }
3901
- var repositoryPermissionSchema = z24.object({
3902
- permission: z24.string().min(1),
3903
- role_name: z24.string().optional()
3936
+ var repositoryPermissionSchema = z25.object({
3937
+ permission: z25.string().min(1),
3938
+ role_name: z25.string().optional()
3904
3939
  });
3905
3940
  var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
3906
3941
  async function loadRepositoryRole(env, cache, target) {
@@ -3930,18 +3965,18 @@ async function loadRepositoryRole(env, cache, target) {
3930
3965
  }
3931
3966
  );
3932
3967
  }
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()
3968
+ var pullRequestSchema4 = z25.object({
3969
+ draft: z25.boolean().optional(),
3970
+ html_url: z25.string().url(),
3971
+ mergeable_state: z25.string().nullable().optional(),
3972
+ merged: z25.boolean(),
3973
+ state: z25.enum(["open", "closed"]),
3974
+ title: z25.string()
3940
3975
  });
3941
- var reviewsSchema = z24.array(
3942
- z24.object({
3943
- state: z24.string(),
3944
- user: z24.object({ login: z24.string() }).nullable()
3976
+ var reviewsSchema = z25.array(
3977
+ z25.object({
3978
+ state: z25.string(),
3979
+ user: z25.object({ login: z25.string() }).nullable()
3945
3980
  })
3946
3981
  );
3947
3982
  async function loadPullRequestMergeState(env, pullRequest) {
@@ -4006,10 +4041,10 @@ var READY_ACTIONS = {
4006
4041
  ]),
4007
4042
  pull_request_review: /* @__PURE__ */ new Set(["dismissed", "submitted"])
4008
4043
  };
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) })
4044
+ var pullRequestWebhookSchema = z26.object({
4045
+ action: z26.string(),
4046
+ pull_request: z26.object({ number: z26.number().int().positive() }),
4047
+ repository: z26.object({ full_name: z26.string().min(1) })
4013
4048
  });
4014
4049
  function pullRequestReadyTargets(eventName, body) {
4015
4050
  if (eventName === "check_suite") return checkSuitePullRequests(body);
@@ -4104,7 +4139,7 @@ async function syncGitHubPullRequestReadyNotices(args) {
4104
4139
  }
4105
4140
 
4106
4141
  // src/webhooks/pull-request-match-data.ts
4107
- import * as z26 from "zod";
4142
+ import * as z27 from "zod";
4108
4143
  var LOOKUPS_BY_MATCH_KEY = {
4109
4144
  authors: ["authors"],
4110
4145
  openerEmail: ["opener"],
@@ -4112,16 +4147,16 @@ var LOOKUPS_BY_MATCH_KEY = {
4112
4147
  openerUsername: ["opener"]
4113
4148
  };
4114
4149
  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()
4150
+ var lookupDataSchema = z27.object({
4151
+ authors: z27.array(z27.string().min(1)).min(1).optional(),
4152
+ openerRole: z27.string().min(1).optional(),
4153
+ openerUsername: z27.string().min(1).optional()
4119
4154
  }).strict();
4120
4155
  function lookupData(input) {
4121
4156
  return lookupDataSchema.parse(definedValues(input));
4122
4157
  }
4123
- var webhookSchema = z26.object({
4124
- repository: z26.object({ full_name: z26.string().min(1) })
4158
+ var webhookSchema = z27.object({
4159
+ repository: z27.object({ full_name: z27.string().min(1) })
4125
4160
  });
4126
4161
  function pullRequestNumbers(events) {
4127
4162
  const numbers = /* @__PURE__ */ new Map();
@@ -4264,7 +4299,7 @@ async function withGitHubPullRequestMatchData(args) {
4264
4299
  }
4265
4300
 
4266
4301
  // src/webhooks/pull-request-people.ts
4267
- import * as z27 from "zod";
4302
+ import * as z28 from "zod";
4268
4303
  var PEOPLE_EVENTS = /* @__PURE__ */ new Set([
4269
4304
  "pull_request.review.approved",
4270
4305
  "pull_request.merged"
@@ -4274,18 +4309,18 @@ var PAGE_SIZE = 100;
4274
4309
  var MAX_PAGES = 3;
4275
4310
  var CO_AUTHOR_TRAILER = /^co-authored-by:[^<\n]*<([^>\s]+@[^>\s]+)>\s*$/gim;
4276
4311
  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()
4312
+ var webhookSchema2 = z28.object({
4313
+ pull_request: z28.object({
4314
+ assignees: z28.array(z28.object({ login: z28.string().min(1) })).nullish(),
4315
+ number: z28.number(),
4316
+ user: z28.object({ login: z28.string().min(1) }).nullish()
4282
4317
  }),
4283
- repository: z27.object({ full_name: z27.string().min(1) })
4318
+ repository: z28.object({ full_name: z28.string().min(1) })
4284
4319
  });
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() })
4320
+ var commitPageSchema = z28.array(
4321
+ z28.object({
4322
+ author: z28.object({ login: z28.string().min(1) }).nullish(),
4323
+ commit: z28.object({ message: z28.string() })
4289
4324
  })
4290
4325
  );
4291
4326
  function shareCommitPages(load) {
@@ -4430,10 +4465,10 @@ function webhookInstallationId(body) {
4430
4465
  }
4431
4466
  return parseInstallationId(installation.id);
4432
4467
  }
4433
- var feedbackTargetSchema = z28.object({
4434
- commentId: z28.number(),
4435
- commentKind: z28.enum(["conversation", "review"]),
4436
- repo: z28.string().min(1)
4468
+ var feedbackTargetSchema = z29.object({
4469
+ commentId: z29.number(),
4470
+ commentKind: z29.enum(["conversation", "review"]),
4471
+ repo: z29.string().min(1)
4437
4472
  });
4438
4473
  function pullRequestFeedbackTarget(events) {
4439
4474
  const event = events.find(
@@ -4716,18 +4751,18 @@ function gitHubResourceUrl(input) {
4716
4751
  }
4717
4752
 
4718
4753
  // 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()
4754
+ import * as z30 from "zod";
4755
+ var canonicalCommitSchema = z30.object({
4756
+ authorEmail: z30.string().nullable(),
4757
+ authorLogin: z30.string().nullable()
4723
4758
  }).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()
4759
+ var providerCommitSchema = z30.object({
4760
+ author: z30.object({ login: z30.string() }).passthrough().nullable(),
4761
+ commit: z30.object({
4762
+ author: z30.object({ email: z30.string() }).passthrough().nullable()
4728
4763
  }).passthrough()
4729
4764
  }).passthrough();
4730
- var commitPageSchema2 = z29.array(providerCommitSchema).transform(
4765
+ var commitPageSchema2 = z30.array(providerCommitSchema).transform(
4731
4766
  (commits) => commits.map(
4732
4767
  (commit) => canonicalCommitSchema.parse({
4733
4768
  authorEmail: commit.commit.author?.email ?? null,
@@ -5377,9 +5412,9 @@ function parseGitHubReferences(text2, config) {
5377
5412
  }
5378
5413
  return [...references.values()];
5379
5414
  }
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;
5415
+ function objectTitle(kind, object30) {
5416
+ if (!isRecord(object30)) return void 0;
5417
+ const raw = kind === "commit" ? isRecord(object30.commit) && typeof object30.commit.message === "string" ? object30.commit.message.split("\n")[0] : void 0 : typeof object30.title === "string" ? object30.title : void 0;
5383
5418
  return raw?.replace(/\s+/g, " ").trim() || void 0;
5384
5419
  }
5385
5420
  async function loadGitHubConversationTitleContext(args) {