@sentry/junior-github 0.276.0 → 0.278.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,7 @@ import {
59
59
  readGrantPermissions,
60
60
  requireEnv,
61
61
  resolveUserAccount
62
- } from "./chunk-PCWKGWHE.js";
62
+ } from "./chunk-IR7D5MR7.js";
63
63
 
64
64
  // src/tool-support/attribution.ts
65
65
  var GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
@@ -382,22 +382,117 @@ function createGitHubCloneRepositoryTool(ctx) {
382
382
  });
383
383
  }
384
384
 
385
- // src/object-facts.ts
385
+ // src/tools/comment-on-pull-request.ts
386
+ import {
387
+ definePluginTool as definePluginTool2,
388
+ PluginToolInputError as PluginToolInputError2,
389
+ pluginToolOutputSchema as pluginToolOutputSchema2
390
+ } from "@sentry/junior-plugin-api";
386
391
  import { z as z2 } from "zod";
387
- var person = z2.object({ login: z2.string() });
388
- var responseSchema = z2.object({
389
- body: z2.string().nullable().optional(),
392
+ var inputSchema2 = z2.object({
393
+ repo: z2.string().describe('Repository in "owner/name" format.'),
394
+ number: z2.number().int().positive().describe("Pull request number."),
395
+ body: z2.string().trim().min(1).describe("Comment text."),
396
+ in_reply_to: z2.number().int().positive().optional().describe(
397
+ "Inline review comment id. Set it to reply in that comment's thread. Omit it to comment on the pull request."
398
+ )
399
+ }).strict();
400
+ var outputSchema2 = pluginToolOutputSchema2.extend({
401
+ target: z2.literal("commentOnPullRequest"),
402
+ repo: z2.string(),
403
+ number: z2.number(),
404
+ comment_id: z2.number(),
405
+ url: z2.string()
406
+ });
407
+ function parseRepo2(value) {
408
+ const parts = value.split("/").map((part) => part.trim());
409
+ if (parts.length !== 2 || !parts[0] || !parts[1]) {
410
+ throw new PluginToolInputError2('repo must use "owner/name" format');
411
+ }
412
+ return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
413
+ }
414
+ async function readJson(response) {
415
+ const text2 = await response.text();
416
+ if (!text2) return void 0;
417
+ try {
418
+ return JSON.parse(text2);
419
+ } catch {
420
+ return text2;
421
+ }
422
+ }
423
+ function githubError(body) {
424
+ if (body && typeof body === "object" && !Array.isArray(body)) {
425
+ const message = body.message;
426
+ if (typeof message === "string" && message.trim()) return message.trim();
427
+ }
428
+ if (typeof body === "string" && body.trim()) return body.trim();
429
+ return "GitHub request failed";
430
+ }
431
+ function createGitHubCommentOnPullRequestTool(egress) {
432
+ return definePluginTool2({
433
+ annotations: {
434
+ destructiveHint: false,
435
+ idempotentHint: false,
436
+ openWorldHint: true,
437
+ readOnlyHint: false
438
+ },
439
+ description: "Post a comment on a GitHub pull request, or reply in an inline review thread with in_reply_to. Use it to answer a question asked in a pull request review or comment. Returns the comment id and URL.",
440
+ exposure: "direct",
441
+ inputSchema: inputSchema2,
442
+ outputSchema: outputSchema2,
443
+ async execute(input) {
444
+ const repo = parseRepo2(input.repo);
445
+ const repoPath = `https://api.github.com/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}`;
446
+ const url = input.in_reply_to === void 0 ? `${repoPath}/issues/${input.number}/comments` : `${repoPath}/pulls/${input.number}/comments/${input.in_reply_to}/replies`;
447
+ const response = await egress.fetch({
448
+ provider: "github",
449
+ operation: "github.pull.comment.create",
450
+ request: new Request(url, {
451
+ method: "POST",
452
+ headers: {
453
+ Accept: "application/vnd.github+json",
454
+ "Content-Type": "application/json",
455
+ "X-GitHub-Api-Version": "2022-11-28"
456
+ },
457
+ body: JSON.stringify({ body: input.body })
458
+ })
459
+ });
460
+ const parsed = await readJson(response);
461
+ if (!response.ok) {
462
+ const message = `GitHub pull request comment failed with HTTP ${response.status}: ${githubError(parsed)}`;
463
+ if (response.status === 404 || response.status === 422) {
464
+ throw new PluginToolInputError2(message);
465
+ }
466
+ throw new Error(message);
467
+ }
468
+ const comment = z2.object({ id: z2.number(), html_url: z2.string() }).parse(parsed);
469
+ return {
470
+ target: "commentOnPullRequest",
471
+ repo: repo.ref,
472
+ number: input.number,
473
+ comment_id: comment.id,
474
+ url: comment.html_url
475
+ };
476
+ }
477
+ });
478
+ }
479
+
480
+ // src/object-facts.ts
481
+ import { z as z3 } from "zod";
482
+ var person = z3.object({ login: z3.string() });
483
+ var responseSchema = z3.object({
484
+ body: z3.string().nullable().optional(),
390
485
  user: person.nullable().optional(),
391
- requested_reviewers: z2.array(person).optional(),
392
- assignees: z2.array(person).optional(),
393
- labels: z2.array(z2.union([z2.string(), z2.object({ name: z2.string() })])).optional(),
394
- head: z2.object({ ref: z2.string() }).optional(),
395
- base: z2.object({ ref: z2.string() }).optional(),
396
- mergeable: z2.boolean().nullable().optional(),
397
- changed_files: z2.number().int().nonnegative().optional(),
398
- additions: z2.number().int().nonnegative().optional(),
399
- deletions: z2.number().int().nonnegative().optional(),
400
- updated_at: z2.iso.datetime({ offset: true }).optional()
486
+ requested_reviewers: z3.array(person).optional(),
487
+ assignees: z3.array(person).optional(),
488
+ labels: z3.array(z3.union([z3.string(), z3.object({ name: z3.string() })])).optional(),
489
+ head: z3.object({ ref: z3.string() }).optional(),
490
+ base: z3.object({ ref: z3.string() }).optional(),
491
+ mergeable: z3.boolean().nullable().optional(),
492
+ changed_files: z3.number().int().nonnegative().optional(),
493
+ additions: z3.number().int().nonnegative().optional(),
494
+ deletions: z3.number().int().nonnegative().optional(),
495
+ updated_at: z3.iso.datetime({ offset: true }).optional()
401
496
  });
402
497
  var short = (value) => {
403
498
  const text2 = value?.trim();
@@ -520,24 +615,24 @@ async function updateGitHubAnnotation(store, input) {
520
615
  // src/tools/create-issue.ts
521
616
  import {
522
617
  objectFactsSchema,
523
- definePluginTool as definePluginTool2,
618
+ definePluginTool as definePluginTool3,
524
619
  EgressAuthRequired,
525
- PluginToolInputError as PluginToolInputError3,
620
+ PluginToolInputError as PluginToolInputError4,
526
621
  subscribableResourceSchema,
527
- pluginToolOutputSchema as pluginToolOutputSchema2
622
+ pluginToolOutputSchema as pluginToolOutputSchema3
528
623
  } from "@sentry/junior-plugin-api";
529
624
  import { Type } from "@sinclair/typebox";
530
625
  import { Value } from "@sinclair/typebox/value";
531
- import { z as z3 } from "zod";
626
+ import { z as z4 } from "zod";
532
627
 
533
628
  // src/tools/footer.ts
534
- import { PluginToolInputError as PluginToolInputError2 } from "@sentry/junior-plugin-api";
629
+ import { PluginToolInputError as PluginToolInputError3 } from "@sentry/junior-plugin-api";
535
630
  var GITHUB_SESSION_FOOTER_START = "<!-- junior-session-footer:start -->";
536
631
  var GITHUB_SESSION_FOOTER_END = "<!-- junior-session-footer:end -->";
537
632
  var GITHUB_CONVERSATION_ID_MARKER = "junior-conversation-id:";
538
633
  function nonEmptyString(value, name) {
539
634
  if (!value?.trim()) {
540
- throw new PluginToolInputError2(`${name} is required`);
635
+ throw new PluginToolInputError3(`${name} is required`);
541
636
  }
542
637
  return value.trim();
543
638
  }
@@ -681,11 +776,11 @@ var createIssueInputSchema = Type.Object(
681
776
  },
682
777
  { additionalProperties: false }
683
778
  );
684
- var createIssueToolInputSchema = z3.object({
685
- repo: z3.string().describe('Repository in "owner/name" format.'),
686
- title: z3.string().describe("Issue title."),
687
- body: z3.string().describe("Issue body. The runtime appends the conversation footer.").optional(),
688
- labels: z3.array(z3.string()).describe("Labels to apply to the issue.").optional()
779
+ var createIssueToolInputSchema = z4.object({
780
+ repo: z4.string().describe('Repository in "owner/name" format.'),
781
+ title: z4.string().describe("Issue title."),
782
+ body: z4.string().describe("Issue body. The runtime appends the conversation footer.").optional(),
783
+ labels: z4.array(z4.string()).describe("Labels to apply to the issue.").optional()
689
784
  }).strict();
690
785
  var createIssueStateSchema = Type.Union([
691
786
  Type.Object(
@@ -710,18 +805,18 @@ var createIssueStateSchema = Type.Union([
710
805
  { additionalProperties: false }
711
806
  )
712
807
  ]);
713
- var gitHubIssueDataSchema = z3.object({
714
- number: z3.number(),
808
+ var gitHubIssueDataSchema = z4.object({
809
+ number: z4.number(),
715
810
  subscribable: subscribableResourceSchema.optional(),
716
- url: z3.string()
811
+ url: z4.string()
717
812
  });
718
- var gitHubIssueOutputSchema = pluginToolOutputSchema2.merge(
813
+ var gitHubIssueOutputSchema = pluginToolOutputSchema3.merge(
719
814
  gitHubIssueDataSchema.extend({
720
- target: z3.literal("createIssue")
815
+ target: z4.literal("createIssue")
721
816
  })
722
817
  );
723
818
  function gitHubIssueToolResult(input, result, canSubscribe) {
724
- const repo = parseRepo2(input.repo);
819
+ const repo = parseRepo3(input.repo);
725
820
  const subscribable = gitHubIssueSubscribable({
726
821
  canSubscribe,
727
822
  number: result.number,
@@ -754,22 +849,22 @@ function parseCreateIssueInput(input) {
754
849
  try {
755
850
  return Value.Parse(createIssueInputSchema, input);
756
851
  } catch (error) {
757
- throw new PluginToolInputError3("Invalid GitHub createIssue input.", {
852
+ throw new PluginToolInputError4("Invalid GitHub createIssue input.", {
758
853
  cause: error
759
854
  });
760
855
  }
761
856
  }
762
857
  function nonEmptyString2(value, name) {
763
858
  if (!value?.trim()) {
764
- throw new PluginToolInputError3(`${name} is required`);
859
+ throw new PluginToolInputError4(`${name} is required`);
765
860
  }
766
861
  return value.trim();
767
862
  }
768
- function parseRepo2(value) {
863
+ function parseRepo3(value) {
769
864
  const repo = nonEmptyString2(value, "repo");
770
865
  const parts = repo.split("/");
771
866
  if (parts.length !== 2 || !parts[0]?.trim() || !parts[1]?.trim()) {
772
- throw new PluginToolInputError3('repo must use "owner/name" format');
867
+ throw new PluginToolInputError4('repo must use "owner/name" format');
773
868
  }
774
869
  return {
775
870
  owner: parts[0].trim(),
@@ -821,7 +916,7 @@ function isDefinitiveGitHubIssueCreateRejection(error) {
821
916
  return [400, 401, 404, 410, 422].includes(error.status);
822
917
  }
823
918
  async function createGitHubIssueRequest(conversationId, input, ctx, dashboardUrl) {
824
- const repo = parseRepo2(input.repo);
919
+ const repo = parseRepo3(input.repo);
825
920
  const labels = input.labels?.map(
826
921
  (label) => nonEmptyString2(label, "labels entry")
827
922
  );
@@ -882,7 +977,7 @@ async function createGitHubIssue(ctx, request) {
882
977
  };
883
978
  }
884
979
  function createGitHubIssueTool(ctx) {
885
- return definePluginTool2({
980
+ return definePluginTool3({
886
981
  annotations: {
887
982
  destructiveHint: false,
888
983
  idempotentHint: true,
@@ -975,83 +1070,83 @@ function createGitHubIssueTool(ctx) {
975
1070
 
976
1071
  // src/tools/get-deployment.ts
977
1072
  import {
978
- definePluginTool as definePluginTool3,
979
- PluginToolInputError as PluginToolInputError4,
980
- pluginToolOutputSchema as pluginToolOutputSchema3,
1073
+ definePluginTool as definePluginTool4,
1074
+ PluginToolInputError as PluginToolInputError5,
1075
+ pluginToolOutputSchema as pluginToolOutputSchema4,
981
1076
  subscribableResourceSchema as subscribableResourceSchema2
982
1077
  } from "@sentry/junior-plugin-api";
983
- import { z as z4 } from "zod";
984
- var commitShaSchema = z4.string().regex(/^[0-9a-f]{40}$/i);
985
- var inputSchema2 = z4.object({
986
- repo: z4.string().describe('Repository in "owner/name" format.'),
1078
+ import { z as z5 } from "zod";
1079
+ var commitShaSchema = z5.string().regex(/^[0-9a-f]{40}$/i);
1080
+ var inputSchema3 = z5.object({
1081
+ repo: z5.string().describe('Repository in "owner/name" format.'),
987
1082
  commit_sha: commitShaSchema.describe(
988
1083
  "Full 40-character Git commit SHA recorded by the deployment."
989
1084
  ),
990
- environment: z4.string().trim().min(1).describe(
1085
+ environment: z5.string().trim().min(1).describe(
991
1086
  'Optional GitHub deployment environment, such as "Production". Omit to inspect and watch deployments for the commit across environments.'
992
1087
  ).optional()
993
1088
  }).strict();
994
- var statusSchema = z4.object({
995
- created_at: z4.string(),
996
- creator: z4.string().nullable(),
997
- description: z4.string().nullable(),
998
- environment_url: z4.string().nullable(),
999
- id: z4.number(),
1000
- log_url: z4.string().nullable(),
1001
- state: z4.string()
1089
+ var statusSchema = z5.object({
1090
+ created_at: z5.string(),
1091
+ creator: z5.string().nullable(),
1092
+ description: z5.string().nullable(),
1093
+ environment_url: z5.string().nullable(),
1094
+ id: z5.number(),
1095
+ log_url: z5.string().nullable(),
1096
+ state: z5.string()
1002
1097
  }).strict();
1003
- var deploymentSchema = z4.object({
1004
- created_at: z4.string(),
1005
- creator: z4.string().nullable(),
1006
- description: z4.string().nullable(),
1007
- environment: z4.string(),
1008
- id: z4.number(),
1098
+ var deploymentSchema = z5.object({
1099
+ created_at: z5.string(),
1100
+ creator: z5.string().nullable(),
1101
+ description: z5.string().nullable(),
1102
+ environment: z5.string(),
1103
+ id: z5.number(),
1009
1104
  latest_status: statusSchema.nullable(),
1010
- ref: z4.string(),
1105
+ ref: z5.string(),
1011
1106
  sha: commitShaSchema,
1012
- updated_at: z4.string(),
1013
- url: z4.string()
1107
+ updated_at: z5.string(),
1108
+ url: z5.string()
1014
1109
  }).strict();
1015
- var deploymentSourceSchema = z4.object({
1110
+ var deploymentSourceSchema = z5.object({
1016
1111
  commit_sha: commitShaSchema,
1017
1112
  deployment: deploymentSchema.nullable(),
1018
- environment: z4.string().nullable(),
1019
- repo: z4.string(),
1113
+ environment: z5.string().nullable(),
1114
+ repo: z5.string(),
1020
1115
  subscribable: subscribableResourceSchema2.optional()
1021
1116
  }).strict();
1022
- var outputSchema2 = pluginToolOutputSchema3.merge(
1117
+ var outputSchema3 = pluginToolOutputSchema4.merge(
1023
1118
  deploymentSourceSchema.extend({
1024
- target: z4.literal("getDeployment")
1119
+ target: z5.literal("getDeployment")
1025
1120
  })
1026
1121
  );
1027
- var providerCreatorSchema = z4.object({ login: z4.string() }).passthrough().nullable();
1028
- var providerDeploymentSchema = z4.object({
1029
- created_at: z4.string(),
1122
+ var providerCreatorSchema = z5.object({ login: z5.string() }).passthrough().nullable();
1123
+ var providerDeploymentSchema = z5.object({
1124
+ created_at: z5.string(),
1030
1125
  creator: providerCreatorSchema,
1031
- description: z4.string().nullable(),
1032
- environment: z4.string(),
1033
- id: z4.number(),
1034
- ref: z4.string(),
1126
+ description: z5.string().nullable(),
1127
+ environment: z5.string(),
1128
+ id: z5.number(),
1129
+ ref: z5.string(),
1035
1130
  sha: commitShaSchema,
1036
- updated_at: z4.string()
1131
+ updated_at: z5.string()
1037
1132
  }).passthrough();
1038
- var providerStatusSchema = z4.object({
1039
- created_at: z4.string(),
1133
+ var providerStatusSchema = z5.object({
1134
+ created_at: z5.string(),
1040
1135
  creator: providerCreatorSchema,
1041
- description: z4.string().nullable().optional(),
1042
- environment_url: z4.string().nullable().optional(),
1043
- id: z4.number(),
1044
- log_url: z4.string().nullable().optional(),
1045
- state: z4.string()
1136
+ description: z5.string().nullable().optional(),
1137
+ environment_url: z5.string().nullable().optional(),
1138
+ id: z5.number(),
1139
+ log_url: z5.string().nullable().optional(),
1140
+ state: z5.string()
1046
1141
  }).passthrough();
1047
- function parseRepo3(value) {
1142
+ function parseRepo4(value) {
1048
1143
  const parts = value.split("/").map((part) => part.trim());
1049
1144
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
1050
- throw new PluginToolInputError4('repo must use "owner/name" format');
1145
+ throw new PluginToolInputError5('repo must use "owner/name" format');
1051
1146
  }
1052
1147
  return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
1053
1148
  }
1054
- async function readJson(response) {
1149
+ async function readJson2(response) {
1055
1150
  const text2 = await response.text();
1056
1151
  if (!text2) return void 0;
1057
1152
  try {
@@ -1064,7 +1159,7 @@ function throwLookupError(target, status, body) {
1064
1159
  const message = `GitHub ${target} lookup failed with HTTP ${status}`;
1065
1160
  const hasValidationErrors = body !== null && typeof body === "object" && !Array.isArray(body) && Array.isArray(body.errors) && body.errors.length > 0;
1066
1161
  if (target === "deployment" && (status === 404 || status === 422 && hasValidationErrors)) {
1067
- throw new PluginToolInputError4(message);
1162
+ throw new PluginToolInputError5(message);
1068
1163
  }
1069
1164
  throw new Error(message);
1070
1165
  }
@@ -1072,7 +1167,7 @@ function repositoryUrl(repo, path) {
1072
1167
  return `https://api.github.com/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}/${path}`;
1073
1168
  }
1074
1169
  function createGitHubGetDeploymentTool(ctx) {
1075
- return definePluginTool3({
1170
+ return definePluginTool4({
1076
1171
  annotations: {
1077
1172
  destructiveHint: false,
1078
1173
  idempotentHint: true,
@@ -1080,10 +1175,10 @@ function createGitHubGetDeploymentTool(ctx) {
1080
1175
  readOnlyHint: true
1081
1176
  },
1082
1177
  description: "Get the latest GitHub deployment and status for an exact repository and full commit SHA, optionally limited to one environment. The result remains subscribable when no deployment exists yet, so use it before waiting for a deployment outcome.",
1083
- inputSchema: inputSchema2,
1084
- outputSchema: outputSchema2,
1178
+ inputSchema: inputSchema3,
1179
+ outputSchema: outputSchema3,
1085
1180
  async execute(input) {
1086
- const repo = parseRepo3(input.repo);
1181
+ const repo = parseRepo4(input.repo);
1087
1182
  const commitSha = input.commit_sha.toLowerCase();
1088
1183
  const deploymentsUrl = new URL(repositoryUrl(repo, "deployments"));
1089
1184
  deploymentsUrl.searchParams.set("sha", commitSha);
@@ -1101,7 +1196,7 @@ function createGitHubGetDeploymentTool(ctx) {
1101
1196
  }
1102
1197
  })
1103
1198
  });
1104
- const deploymentsBody = await readJson(deploymentsResponse);
1199
+ const deploymentsBody = await readJson2(deploymentsResponse);
1105
1200
  if (!deploymentsResponse.ok) {
1106
1201
  throwLookupError(
1107
1202
  "deployment",
@@ -1109,7 +1204,7 @@ function createGitHubGetDeploymentTool(ctx) {
1109
1204
  deploymentsBody
1110
1205
  );
1111
1206
  }
1112
- const providerDeployment = z4.array(providerDeploymentSchema).parse(deploymentsBody)[0];
1207
+ const providerDeployment = z5.array(providerDeploymentSchema).parse(deploymentsBody)[0];
1113
1208
  let deployment = null;
1114
1209
  if (providerDeployment) {
1115
1210
  const statusesResponse = await ctx.egress.fetch({
@@ -1125,7 +1220,7 @@ function createGitHubGetDeploymentTool(ctx) {
1125
1220
  }
1126
1221
  )
1127
1222
  });
1128
- const statusesBody = await readJson(statusesResponse);
1223
+ const statusesBody = await readJson2(statusesResponse);
1129
1224
  if (!statusesResponse.ok) {
1130
1225
  throwLookupError(
1131
1226
  "deployment status",
@@ -1133,7 +1228,7 @@ function createGitHubGetDeploymentTool(ctx) {
1133
1228
  statusesBody
1134
1229
  );
1135
1230
  }
1136
- const providerStatus = z4.array(providerStatusSchema).parse(statusesBody)[0];
1231
+ const providerStatus = z5.array(providerStatusSchema).parse(statusesBody)[0];
1137
1232
  deployment = {
1138
1233
  created_at: providerDeployment.created_at,
1139
1234
  creator: providerDeployment.creator?.login ?? null,
@@ -1179,16 +1274,16 @@ function createGitHubGetDeploymentTool(ctx) {
1179
1274
  // src/tools/create-pull-request.ts
1180
1275
  import {
1181
1276
  objectFactsSchema as objectFactsSchema2,
1182
- definePluginTool as definePluginTool4,
1277
+ definePluginTool as definePluginTool5,
1183
1278
  EgressAuthRequired as EgressAuthRequired2,
1184
- PluginToolInputError as PluginToolInputError5,
1185
- pluginToolOutputSchema as pluginToolOutputSchema4,
1279
+ PluginToolInputError as PluginToolInputError6,
1280
+ pluginToolOutputSchema as pluginToolOutputSchema5,
1186
1281
  watchResultSchema,
1187
1282
  subscribableResourceSchema as subscribableResourceSchema3
1188
1283
  } from "@sentry/junior-plugin-api";
1189
1284
  import { Type as Type2 } from "@sinclair/typebox";
1190
1285
  import { Value as Value2 } from "@sinclair/typebox/value";
1191
- import { z as z7 } from "zod";
1286
+ import { z as z8 } from "zod";
1192
1287
 
1193
1288
  // src/pull-request-requesters/store.ts
1194
1289
  import { and, asc, eq, inArray, lt } from "drizzle-orm";
@@ -1203,18 +1298,18 @@ import {
1203
1298
  text,
1204
1299
  timestamp
1205
1300
  } from "drizzle-orm/pg-core";
1206
- import { z as z5 } from "zod";
1207
- var githubPullRequestStateSchema = z5.enum([
1301
+ import { z as z6 } from "zod";
1302
+ var githubPullRequestStateSchema = z6.enum([
1208
1303
  "closed_unmerged",
1209
1304
  "merged",
1210
1305
  "open"
1211
1306
  ]);
1212
- var githubPullRequestCommitCompositionSchema = z5.enum([
1307
+ var githubPullRequestCommitCompositionSchema = z6.enum([
1213
1308
  "junior_only",
1214
1309
  "mixed"
1215
1310
  ]);
1216
- var githubIssueStateSchema = z5.enum(["closed", "open"]);
1217
- var githubIssueStateReasonSchema = z5.enum([
1311
+ var githubIssueStateSchema = z6.enum(["closed", "open"]);
1312
+ var githubIssueStateReasonSchema = z6.enum([
1218
1313
  "completed",
1219
1314
  "duplicate",
1220
1315
  "not_planned",
@@ -1375,34 +1470,34 @@ async function listGitHubPullRequestOpeners(db, input) {
1375
1470
  }
1376
1471
 
1377
1472
  // src/tools/stack-pull-request.ts
1378
- import { z as z6 } from "zod";
1473
+ import { z as z7 } from "zod";
1379
1474
  var MAX_STACK_DEPTH = 10;
1380
1475
  var GITHUB_HEADERS = {
1381
1476
  Accept: "application/vnd.github+json",
1382
1477
  "X-GitHub-Api-Version": "2026-03-10"
1383
1478
  };
1384
- var stackTargetSchema = z6.object({
1385
- number: z6.number().int().positive(),
1386
- head: z6.object({
1387
- repo: z6.object({ full_name: z6.string().min(1) }).nullable()
1479
+ var stackTargetSchema = z7.object({
1480
+ number: z7.number().int().positive(),
1481
+ head: z7.object({
1482
+ repo: z7.object({ full_name: z7.string().min(1) }).nullable()
1388
1483
  }),
1389
- base: z6.object({
1390
- ref: z6.string().min(1),
1391
- repo: z6.object({
1392
- default_branch: z6.string().min(1),
1393
- full_name: z6.string().min(1)
1484
+ base: z7.object({
1485
+ ref: z7.string().min(1),
1486
+ repo: z7.object({
1487
+ default_branch: z7.string().min(1),
1488
+ full_name: z7.string().min(1)
1394
1489
  })
1395
1490
  })
1396
1491
  });
1397
- var openPullRequestsSchema = z6.array(
1398
- z6.object({
1399
- number: z6.number().int().positive(),
1400
- base: z6.object({ ref: z6.string().min(1) })
1492
+ var openPullRequestsSchema = z7.array(
1493
+ z7.object({
1494
+ number: z7.number().int().positive(),
1495
+ base: z7.object({ ref: z7.string().min(1) })
1401
1496
  })
1402
1497
  );
1403
- var stackSchema = z6.object({
1404
- number: z6.number().int().positive(),
1405
- pull_requests: z6.array(z6.object({ number: z6.number().int().positive() }))
1498
+ var stackSchema = z7.object({
1499
+ number: z7.number().int().positive(),
1500
+ pull_requests: z7.array(z7.object({ number: z7.number().int().positive() }))
1406
1501
  });
1407
1502
  async function stackGitHubPullRequest(ctx, target) {
1408
1503
  const repo = target.base.repo.full_name;
@@ -1451,7 +1546,7 @@ async function stackGitHubPullRequest(ctx, target) {
1451
1546
  const stacks = await github(
1452
1547
  "github.stack.read",
1453
1548
  `${api}/stacks?pull_request=${parent.number}`,
1454
- z6.array(stackSchema)
1549
+ z7.array(stackSchema)
1455
1550
  );
1456
1551
  if (!stacks) return void 0;
1457
1552
  const stack = stacks[0];
@@ -1526,15 +1621,15 @@ var createPullRequestInputSchema = Type2.Object(
1526
1621
  },
1527
1622
  { additionalProperties: false }
1528
1623
  );
1529
- var createPullRequestToolInputSchema = z7.object({
1530
- repo: z7.string().describe('Repository in "owner/name" format.'),
1531
- title: z7.string().describe("Pull request title."),
1532
- head: z7.string().describe("Head branch or owner:branch ref."),
1533
- base: z7.string().describe("Base branch."),
1534
- body: z7.string().describe(
1624
+ var createPullRequestToolInputSchema = z8.object({
1625
+ repo: z8.string().describe('Repository in "owner/name" format.'),
1626
+ title: z8.string().describe("Pull request title."),
1627
+ head: z8.string().describe("Head branch or owner:branch ref."),
1628
+ base: z8.string().describe("Base branch."),
1629
+ body: z8.string().describe(
1535
1630
  "Pull request body. The runtime appends the conversation footer."
1536
1631
  ).optional(),
1537
- draft: z7.boolean().describe("Whether to open the pull request as a draft.").optional()
1632
+ draft: z8.boolean().describe("Whether to open the pull request as a draft.").optional()
1538
1633
  }).strict();
1539
1634
  var createPullRequestStateSchema = Type2.Union([
1540
1635
  Type2.Object(
@@ -1559,38 +1654,38 @@ var createPullRequestStateSchema = Type2.Union([
1559
1654
  { additionalProperties: false }
1560
1655
  )
1561
1656
  ]);
1562
- var gitHubPullRequestDataSchema = z7.object({
1563
- number: z7.number(),
1564
- url: z7.string(),
1565
- stack: z7.object({ number: z7.number(), pull_requests: z7.array(z7.number()) }).optional(),
1657
+ var gitHubPullRequestDataSchema = z8.object({
1658
+ number: z8.number(),
1659
+ url: z8.string(),
1660
+ stack: z8.object({ number: z8.number(), pull_requests: z8.array(z8.number()) }).optional(),
1566
1661
  subscribable: subscribableResourceSchema3.optional(),
1567
1662
  subscription: watchResultSchema.optional()
1568
1663
  });
1569
- var gitHubPullRequestOutputSchema = pluginToolOutputSchema4.merge(
1664
+ var gitHubPullRequestOutputSchema = pluginToolOutputSchema5.merge(
1570
1665
  gitHubPullRequestDataSchema.extend({
1571
- target: z7.literal("createPullRequest")
1666
+ target: z8.literal("createPullRequest")
1572
1667
  })
1573
1668
  );
1574
1669
  function parseCreatePullRequestInput(input) {
1575
1670
  try {
1576
1671
  return Value2.Parse(createPullRequestInputSchema, input);
1577
1672
  } catch (error) {
1578
- throw new PluginToolInputError5("Invalid GitHub createPullRequest input.", {
1673
+ throw new PluginToolInputError6("Invalid GitHub createPullRequest input.", {
1579
1674
  cause: error
1580
1675
  });
1581
1676
  }
1582
1677
  }
1583
1678
  function nonEmptyString3(value, name) {
1584
1679
  if (!value?.trim()) {
1585
- throw new PluginToolInputError5(`${name} is required`);
1680
+ throw new PluginToolInputError6(`${name} is required`);
1586
1681
  }
1587
1682
  return value.trim();
1588
1683
  }
1589
- function parseRepo4(value) {
1684
+ function parseRepo5(value) {
1590
1685
  const repo = nonEmptyString3(value, "repo");
1591
1686
  const parts = repo.split("/");
1592
1687
  if (parts.length !== 2 || !parts[0]?.trim() || !parts[1]?.trim()) {
1593
- throw new PluginToolInputError5('repo must use "owner/name" format');
1688
+ throw new PluginToolInputError6('repo must use "owner/name" format');
1594
1689
  }
1595
1690
  return {
1596
1691
  owner: parts[0].trim(),
@@ -1661,7 +1756,7 @@ function isDefinitiveGitHubPullRequestCreateRejection(error) {
1661
1756
  return [400, 401, 404, 410, 422].includes(error.status);
1662
1757
  }
1663
1758
  function createGitHubPullRequestRequest(conversationId, input, ctx, requester, dashboardUrl) {
1664
- const repo = parseRepo4(input.repo);
1759
+ const repo = parseRepo5(input.repo);
1665
1760
  const payload = {
1666
1761
  title: nonEmptyString3(input.title, "title"),
1667
1762
  head: nonEmptyString3(input.head, "head"),
@@ -1727,7 +1822,7 @@ async function createGitHubPullRequest(ctx, request) {
1727
1822
  async function recordOpener(ctx, input, state, requester) {
1728
1823
  const { conversationId, identityId } = requester;
1729
1824
  if (!identityId) return;
1730
- const repo = parseRepo4(input.repo);
1825
+ const repo = parseRepo5(input.repo);
1731
1826
  await recordGitHubPullRequestOpener(ctx.db, {
1732
1827
  conversationId,
1733
1828
  createdAt: new Date(state.createdAtMs),
@@ -1740,7 +1835,7 @@ async function assignPullRequestRequester(ctx, input, result, requester) {
1740
1835
  const assignee = linkedGitHubLogin(requester?.user);
1741
1836
  if (!assignee) return;
1742
1837
  try {
1743
- const repo = parseRepo4(input.repo);
1838
+ const repo = parseRepo5(input.repo);
1744
1839
  const response = await ctx.egress.fetch({
1745
1840
  provider: "github",
1746
1841
  operation: "github.pull.assign",
@@ -1773,7 +1868,7 @@ async function assignPullRequestRequester(ctx, input, result, requester) {
1773
1868
  }
1774
1869
  }
1775
1870
  function gitHubPullRequestToolResult(input, result, canSubscribe, omitSuggestedEvents) {
1776
- const repo = parseRepo4(input.repo);
1871
+ const repo = parseRepo5(input.repo);
1777
1872
  const subscribable = gitHubPullRequestSubscribable({
1778
1873
  canSubscribe,
1779
1874
  number: result.number,
@@ -1847,7 +1942,7 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
1847
1942
  }
1848
1943
  }
1849
1944
  function createGitHubPullRequestTool(ctx, subscriptionConfig) {
1850
- return definePluginTool4({
1945
+ return definePluginTool5({
1851
1946
  annotations: {
1852
1947
  destructiveHint: false,
1853
1948
  idempotentHint: true,
@@ -1966,42 +2061,42 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
1966
2061
 
1967
2062
  // src/tools/get-pull-request.ts
1968
2063
  import {
1969
- definePluginTool as definePluginTool5,
1970
- PluginToolInputError as PluginToolInputError6,
1971
- pluginToolOutputSchema as pluginToolOutputSchema5
2064
+ definePluginTool as definePluginTool6,
2065
+ PluginToolInputError as PluginToolInputError7,
2066
+ pluginToolOutputSchema as pluginToolOutputSchema6
1972
2067
  } from "@sentry/junior-plugin-api";
1973
- import { z as z8 } from "zod";
2068
+ import { z as z9 } from "zod";
1974
2069
  import { subscribableResourceSchema as subscribableResourceSchema4 } from "@sentry/junior-plugin-api";
1975
- var commitShaSchema2 = z8.string().regex(/^[0-9a-f]{40}$/i);
1976
- var inputSchema3 = z8.object({
1977
- repo: z8.string().describe('Repository in "owner/name" format.'),
1978
- number: z8.number().int().positive().describe("Pull request number.")
2070
+ var commitShaSchema2 = z9.string().regex(/^[0-9a-f]{40}$/i);
2071
+ var inputSchema4 = z9.object({
2072
+ repo: z9.string().describe('Repository in "owner/name" format.'),
2073
+ number: z9.number().int().positive().describe("Pull request number.")
1979
2074
  }).strict();
1980
- var pullRequestSchema = z8.object({
1981
- base: z8.string(),
1982
- draft: z8.boolean(),
1983
- head: z8.string(),
2075
+ var pullRequestSchema = z9.object({
2076
+ base: z9.string(),
2077
+ draft: z9.boolean(),
2078
+ head: z9.string(),
1984
2079
  head_sha: commitShaSchema2,
1985
- merged: z8.boolean(),
1986
- number: z8.number(),
1987
- state: z8.string(),
2080
+ merged: z9.boolean(),
2081
+ number: z9.number(),
2082
+ state: z9.string(),
1988
2083
  subscribable: subscribableResourceSchema4.optional(),
1989
- title: z8.string(),
1990
- url: z8.string()
2084
+ title: z9.string(),
2085
+ url: z9.string()
1991
2086
  });
1992
- var outputSchema3 = pluginToolOutputSchema5.merge(
2087
+ var outputSchema4 = pluginToolOutputSchema6.merge(
1993
2088
  pullRequestSchema.extend({
1994
- target: z8.literal("getPullRequest")
2089
+ target: z9.literal("getPullRequest")
1995
2090
  })
1996
2091
  );
1997
- function parseRepo5(value) {
2092
+ function parseRepo6(value) {
1998
2093
  const parts = value.split("/").map((part) => part.trim());
1999
2094
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
2000
- throw new PluginToolInputError6('repo must use "owner/name" format');
2095
+ throw new PluginToolInputError7('repo must use "owner/name" format');
2001
2096
  }
2002
2097
  return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
2003
2098
  }
2004
- async function readJson2(response) {
2099
+ async function readJson3(response) {
2005
2100
  const text2 = await response.text();
2006
2101
  if (!text2) return void 0;
2007
2102
  try {
@@ -2011,7 +2106,7 @@ async function readJson2(response) {
2011
2106
  }
2012
2107
  }
2013
2108
  function createGitHubGetPullRequestTool(ctx) {
2014
- return definePluginTool5({
2109
+ return definePluginTool6({
2015
2110
  annotations: {
2016
2111
  destructiveHint: false,
2017
2112
  idempotentHint: true,
@@ -2019,10 +2114,10 @@ function createGitHubGetPullRequestTool(ctx) {
2019
2114
  readOnlyHint: true
2020
2115
  },
2021
2116
  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.",
2022
- inputSchema: inputSchema3,
2023
- outputSchema: outputSchema3,
2117
+ inputSchema: inputSchema4,
2118
+ outputSchema: outputSchema4,
2024
2119
  async execute(input) {
2025
- const repo = parseRepo5(input.repo);
2120
+ const repo = parseRepo6(input.repo);
2026
2121
  const response = await ctx.egress.fetch({
2027
2122
  provider: "github",
2028
2123
  operation: "github.pull.get",
@@ -2036,23 +2131,23 @@ function createGitHubGetPullRequestTool(ctx) {
2036
2131
  }
2037
2132
  )
2038
2133
  });
2039
- const parsed = await readJson2(response);
2134
+ const parsed = await readJson3(response);
2040
2135
  if (!response.ok) {
2041
2136
  const message = `GitHub pull request lookup failed with HTTP ${response.status}`;
2042
2137
  if (response.status === 404) {
2043
- throw new PluginToolInputError6(message);
2138
+ throw new PluginToolInputError7(message);
2044
2139
  }
2045
2140
  throw new Error(message);
2046
2141
  }
2047
- const providerResult = z8.object({
2048
- base: z8.object({ ref: z8.string() }),
2049
- draft: z8.boolean(),
2050
- head: z8.object({ ref: z8.string(), sha: commitShaSchema2 }),
2051
- html_url: z8.string(),
2052
- merged: z8.boolean().optional().default(false),
2053
- number: z8.number(),
2054
- state: z8.string(),
2055
- title: z8.string()
2142
+ const providerResult = z9.object({
2143
+ base: z9.object({ ref: z9.string() }),
2144
+ draft: z9.boolean(),
2145
+ head: z9.object({ ref: z9.string(), sha: commitShaSchema2 }),
2146
+ html_url: z9.string(),
2147
+ merged: z9.boolean().optional().default(false),
2148
+ number: z9.number(),
2149
+ state: z9.string(),
2150
+ title: z9.string()
2056
2151
  }).parse(parsed);
2057
2152
  const subscribable = gitHubPullRequestSubscribable({
2058
2153
  canSubscribe: ctx.events.canSubscribe,
@@ -2092,59 +2187,59 @@ function createGitHubGetPullRequestTool(ctx) {
2092
2187
 
2093
2188
  // src/tools/get-release.ts
2094
2189
  import {
2095
- definePluginTool as definePluginTool6,
2096
- PluginToolInputError as PluginToolInputError7,
2097
- pluginToolOutputSchema as pluginToolOutputSchema6,
2190
+ definePluginTool as definePluginTool7,
2191
+ PluginToolInputError as PluginToolInputError8,
2192
+ pluginToolOutputSchema as pluginToolOutputSchema7,
2098
2193
  subscribableResourceSchema as subscribableResourceSchema5
2099
2194
  } from "@sentry/junior-plugin-api";
2100
- import { z as z9 } from "zod";
2101
- var inputSchema4 = z9.object({
2102
- repo: z9.string().describe('Repository in "owner/name" format.'),
2103
- tag: z9.string().trim().min(1).describe(
2195
+ import { z as z10 } from "zod";
2196
+ var inputSchema5 = z10.object({
2197
+ repo: z10.string().describe('Repository in "owner/name" format.'),
2198
+ tag: z10.string().trim().min(1).describe(
2104
2199
  "Optional release tag name. Omit to inspect and watch every published release in the repository."
2105
2200
  ).optional()
2106
2201
  }).strict();
2107
- var releaseSchema = z9.object({
2108
- created_at: z9.string(),
2109
- draft: z9.boolean(),
2110
- html_url: z9.string(),
2111
- id: z9.number(),
2112
- name: z9.string().nullable(),
2113
- prerelease: z9.boolean(),
2114
- published_at: z9.string().nullable(),
2115
- tag_name: z9.string(),
2116
- target_commitish: z9.string()
2202
+ var releaseSchema = z10.object({
2203
+ created_at: z10.string(),
2204
+ draft: z10.boolean(),
2205
+ html_url: z10.string(),
2206
+ id: z10.number(),
2207
+ name: z10.string().nullable(),
2208
+ prerelease: z10.boolean(),
2209
+ published_at: z10.string().nullable(),
2210
+ tag_name: z10.string(),
2211
+ target_commitish: z10.string()
2117
2212
  }).strict();
2118
- var releaseSourceSchema = z9.object({
2213
+ var releaseSourceSchema = z10.object({
2119
2214
  release: releaseSchema.nullable(),
2120
- repo: z9.string(),
2215
+ repo: z10.string(),
2121
2216
  subscribable: subscribableResourceSchema5.optional(),
2122
- tag: z9.string().nullable()
2217
+ tag: z10.string().nullable()
2123
2218
  }).strict();
2124
- var outputSchema4 = pluginToolOutputSchema6.merge(
2219
+ var outputSchema5 = pluginToolOutputSchema7.merge(
2125
2220
  releaseSourceSchema.extend({
2126
- target: z9.literal("getRelease")
2221
+ target: z10.literal("getRelease")
2127
2222
  })
2128
2223
  );
2129
- var providerReleaseSchema = z9.object({
2130
- created_at: z9.string(),
2131
- draft: z9.boolean(),
2132
- html_url: z9.string(),
2133
- id: z9.number(),
2134
- name: z9.string().nullable(),
2135
- prerelease: z9.boolean(),
2136
- published_at: z9.string().nullable(),
2137
- tag_name: z9.string(),
2138
- target_commitish: z9.string()
2224
+ var providerReleaseSchema = z10.object({
2225
+ created_at: z10.string(),
2226
+ draft: z10.boolean(),
2227
+ html_url: z10.string(),
2228
+ id: z10.number(),
2229
+ name: z10.string().nullable(),
2230
+ prerelease: z10.boolean(),
2231
+ published_at: z10.string().nullable(),
2232
+ tag_name: z10.string(),
2233
+ target_commitish: z10.string()
2139
2234
  }).passthrough();
2140
- function parseRepo6(value) {
2235
+ function parseRepo7(value) {
2141
2236
  const parts = value.split("/").map((part) => part.trim());
2142
2237
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
2143
- throw new PluginToolInputError7('repo must use "owner/name" format');
2238
+ throw new PluginToolInputError8('repo must use "owner/name" format');
2144
2239
  }
2145
2240
  return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
2146
2241
  }
2147
- async function readJson3(response) {
2242
+ async function readJson4(response) {
2148
2243
  const text2 = await response.text();
2149
2244
  if (!text2) return void 0;
2150
2245
  try {
@@ -2170,7 +2265,7 @@ function mapRelease(providerRelease) {
2170
2265
  };
2171
2266
  }
2172
2267
  function createGitHubGetReleaseTool(ctx) {
2173
- return definePluginTool6({
2268
+ return definePluginTool7({
2174
2269
  annotations: {
2175
2270
  destructiveHint: false,
2176
2271
  idempotentHint: true,
@@ -2178,10 +2273,10 @@ function createGitHubGetReleaseTool(ctx) {
2178
2273
  readOnlyHint: true
2179
2274
  },
2180
2275
  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.",
2181
- inputSchema: inputSchema4,
2182
- outputSchema: outputSchema4,
2276
+ inputSchema: inputSchema5,
2277
+ outputSchema: outputSchema5,
2183
2278
  async execute(input) {
2184
- const repo = parseRepo6(input.repo);
2279
+ const repo = parseRepo7(input.repo);
2185
2280
  const tag = input.tag?.trim() || void 0;
2186
2281
  let release = null;
2187
2282
  if (tag) {
@@ -2198,7 +2293,7 @@ function createGitHubGetReleaseTool(ctx) {
2198
2293
  }
2199
2294
  )
2200
2295
  });
2201
- const body = await readJson3(response);
2296
+ const body = await readJson4(response);
2202
2297
  if (response.ok) {
2203
2298
  release = mapRelease(providerReleaseSchema.parse(body));
2204
2299
  } else if (response.status !== 404) {
@@ -2217,7 +2312,7 @@ function createGitHubGetReleaseTool(ctx) {
2217
2312
  }
2218
2313
  })
2219
2314
  });
2220
- const body = await readJson3(response);
2315
+ const body = await readJson4(response);
2221
2316
  if (response.ok) {
2222
2317
  release = mapRelease(providerReleaseSchema.parse(body));
2223
2318
  } else if (response.status === 404) {
@@ -2249,36 +2344,36 @@ function createGitHubGetReleaseTool(ctx) {
2249
2344
 
2250
2345
  // src/tools/get-repository.ts
2251
2346
  import {
2252
- definePluginTool as definePluginTool7,
2253
- PluginToolInputError as PluginToolInputError8,
2254
- pluginToolOutputSchema as pluginToolOutputSchema7,
2347
+ definePluginTool as definePluginTool8,
2348
+ PluginToolInputError as PluginToolInputError9,
2349
+ pluginToolOutputSchema as pluginToolOutputSchema8,
2255
2350
  subscribableResourceSchema as subscribableResourceSchema6
2256
2351
  } from "@sentry/junior-plugin-api";
2257
- import { z as z10 } from "zod";
2258
- var inputSchema5 = z10.object({
2259
- repo: z10.string().describe('Repository in "owner/name" format.')
2352
+ import { z as z11 } from "zod";
2353
+ var inputSchema6 = z11.object({
2354
+ repo: z11.string().describe('Repository in "owner/name" format.')
2260
2355
  }).strict();
2261
- var repositorySchema = z10.object({
2262
- default_branch: z10.string(),
2263
- description: z10.string().nullable(),
2264
- full_name: z10.string(),
2265
- private: z10.boolean(),
2356
+ var repositorySchema = z11.object({
2357
+ default_branch: z11.string(),
2358
+ description: z11.string().nullable(),
2359
+ full_name: z11.string(),
2360
+ private: z11.boolean(),
2266
2361
  subscribable: subscribableResourceSchema6.optional(),
2267
- url: z10.string()
2362
+ url: z11.string()
2268
2363
  });
2269
- var outputSchema5 = pluginToolOutputSchema7.merge(
2364
+ var outputSchema6 = pluginToolOutputSchema8.merge(
2270
2365
  repositorySchema.extend({
2271
- target: z10.literal("getRepository")
2366
+ target: z11.literal("getRepository")
2272
2367
  })
2273
2368
  );
2274
- function parseRepo7(value) {
2369
+ function parseRepo8(value) {
2275
2370
  const parts = value.split("/").map((part) => part.trim());
2276
2371
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
2277
- throw new PluginToolInputError8('repo must use "owner/name" format');
2372
+ throw new PluginToolInputError9('repo must use "owner/name" format');
2278
2373
  }
2279
2374
  return { owner: parts[0], name: parts[1] };
2280
2375
  }
2281
- async function readJson4(response) {
2376
+ async function readJson5(response) {
2282
2377
  const text2 = await response.text();
2283
2378
  if (!text2) return void 0;
2284
2379
  try {
@@ -2288,7 +2383,7 @@ async function readJson4(response) {
2288
2383
  }
2289
2384
  }
2290
2385
  function createGitHubGetRepositoryTool(ctx) {
2291
- return definePluginTool7({
2386
+ return definePluginTool8({
2292
2387
  annotations: {
2293
2388
  destructiveHint: false,
2294
2389
  idempotentHint: true,
@@ -2296,10 +2391,10 @@ function createGitHubGetRepositoryTool(ctx) {
2296
2391
  readOnlyHint: true
2297
2392
  },
2298
2393
  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.",
2299
- inputSchema: inputSchema5,
2300
- outputSchema: outputSchema5,
2394
+ inputSchema: inputSchema6,
2395
+ outputSchema: outputSchema6,
2301
2396
  async execute(input) {
2302
- const repo = parseRepo7(input.repo);
2397
+ const repo = parseRepo8(input.repo);
2303
2398
  const response = await ctx.egress.fetch({
2304
2399
  provider: "github",
2305
2400
  operation: "github.repository.get",
@@ -2313,18 +2408,18 @@ function createGitHubGetRepositoryTool(ctx) {
2313
2408
  }
2314
2409
  )
2315
2410
  });
2316
- const parsed = await readJson4(response);
2411
+ const parsed = await readJson5(response);
2317
2412
  if (!response.ok) {
2318
- throw new PluginToolInputError8(
2413
+ throw new PluginToolInputError9(
2319
2414
  `GitHub repository lookup failed with HTTP ${response.status}`
2320
2415
  );
2321
2416
  }
2322
- const providerResult = z10.object({
2323
- default_branch: z10.string(),
2324
- description: z10.string().nullable(),
2325
- full_name: z10.string(),
2326
- html_url: z10.string(),
2327
- private: z10.boolean()
2417
+ const providerResult = z11.object({
2418
+ default_branch: z11.string(),
2419
+ description: z11.string().nullable(),
2420
+ full_name: z11.string(),
2421
+ html_url: z11.string(),
2422
+ private: z11.boolean()
2328
2423
  }).parse(parsed);
2329
2424
  const subscribable = gitHubRepositorySubscribable({
2330
2425
  canSubscribe: ctx.events.canSubscribe,
@@ -2346,51 +2441,160 @@ function createGitHubGetRepositoryTool(ctx) {
2346
2441
  });
2347
2442
  }
2348
2443
 
2444
+ // src/tools/get-status.ts
2445
+ import {
2446
+ definePluginTool as definePluginTool9,
2447
+ pluginToolOutputSchema as pluginToolOutputSchema9
2448
+ } from "@sentry/junior-plugin-api";
2449
+ import { z as z13 } from "zod";
2450
+
2451
+ // src/github-status.ts
2452
+ import { z as z12 } from "zod";
2453
+ var GITHUB_STATUS_INCIDENTS_URL = "https://www.githubstatus.com/api/v2/incidents.json";
2454
+ var GITHUB_STATUS_TTL_MS = 60 * 1e3;
2455
+ var GITHUB_STATUS_TIMEOUT_MS = 5e3;
2456
+ var incidentsResponseSchema = z12.object({
2457
+ incidents: z12.array(
2458
+ z12.object({
2459
+ components: z12.array(z12.object({ name: z12.string() })).default([]),
2460
+ created_at: z12.string(),
2461
+ impact: z12.string(),
2462
+ name: z12.string(),
2463
+ resolved_at: z12.string().nullable(),
2464
+ shortlink: z12.string(),
2465
+ started_at: z12.string().nullable().optional(),
2466
+ status: z12.string()
2467
+ })
2468
+ )
2469
+ });
2470
+ async function fetchGitHubStatusIncidents() {
2471
+ const response = await fetch(GITHUB_STATUS_INCIDENTS_URL, {
2472
+ headers: { Accept: "application/json" },
2473
+ signal: AbortSignal.timeout(GITHUB_STATUS_TIMEOUT_MS)
2474
+ });
2475
+ if (!response.ok) {
2476
+ throw new Error(`githubstatus.com returned HTTP ${response.status}`);
2477
+ }
2478
+ const parsed = incidentsResponseSchema.parse(await response.json());
2479
+ return parsed.incidents.map((incident) => {
2480
+ const result = {
2481
+ components: incident.components.map((component) => component.name),
2482
+ impact: incident.impact,
2483
+ name: incident.name,
2484
+ startedAt: incident.started_at ?? incident.created_at,
2485
+ status: incident.status,
2486
+ url: incident.shortlink
2487
+ };
2488
+ if (incident.resolved_at) result.resolvedAt = incident.resolved_at;
2489
+ return result;
2490
+ });
2491
+ }
2492
+ async function loadGitHubStatusIncidents(cache, withinMs) {
2493
+ const incidents = await cache.getOrLoad(
2494
+ "githubstatus:incidents",
2495
+ async () => ({
2496
+ ttlMs: GITHUB_STATUS_TTL_MS,
2497
+ value: await fetchGitHubStatusIncidents()
2498
+ })
2499
+ );
2500
+ const since = Date.now() - withinMs;
2501
+ return incidents.filter(
2502
+ (incident) => !incident.resolvedAt || Date.parse(incident.resolvedAt) >= since
2503
+ );
2504
+ }
2505
+
2506
+ // src/tools/get-status.ts
2507
+ var RECENT_INCIDENT_MS = 24 * 60 * 60 * 1e3;
2508
+ var inputSchema7 = z13.object({}).strict();
2509
+ var incidentSchema = z13.object({
2510
+ components: z13.array(z13.string()),
2511
+ impact: z13.string(),
2512
+ name: z13.string(),
2513
+ resolved_at: z13.string().optional(),
2514
+ started_at: z13.string(),
2515
+ status: z13.string(),
2516
+ url: z13.string()
2517
+ });
2518
+ var outputSchema7 = pluginToolOutputSchema9.extend({
2519
+ target: z13.literal("getStatus"),
2520
+ incidents: z13.array(incidentSchema)
2521
+ });
2522
+ function createGitHubGetStatusTool(ctx) {
2523
+ return definePluginTool9({
2524
+ annotations: {
2525
+ destructiveHint: false,
2526
+ idempotentHint: true,
2527
+ openWorldHint: true,
2528
+ readOnlyHint: true
2529
+ },
2530
+ 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.",
2531
+ inputSchema: inputSchema7,
2532
+ outputSchema: outputSchema7,
2533
+ async execute() {
2534
+ const incidents = await loadGitHubStatusIncidents(
2535
+ ctx.cache,
2536
+ RECENT_INCIDENT_MS
2537
+ );
2538
+ return {
2539
+ target: "getStatus",
2540
+ incidents: incidents.map(({ resolvedAt, startedAt, ...incident }) => {
2541
+ const result = {
2542
+ ...incident,
2543
+ started_at: startedAt
2544
+ };
2545
+ if (resolvedAt) result.resolved_at = resolvedAt;
2546
+ return result;
2547
+ })
2548
+ };
2549
+ }
2550
+ });
2551
+ }
2552
+
2349
2553
  // src/tools/update-issue.ts
2350
2554
  import {
2351
- definePluginTool as definePluginTool8,
2352
- PluginToolInputError as PluginToolInputError9,
2353
- pluginToolOutputSchema as pluginToolOutputSchema8,
2555
+ definePluginTool as definePluginTool10,
2556
+ PluginToolInputError as PluginToolInputError10,
2557
+ pluginToolOutputSchema as pluginToolOutputSchema10,
2354
2558
  subscribableResourceSchema as subscribableResourceSchema7
2355
2559
  } from "@sentry/junior-plugin-api";
2356
- import { z as z11 } from "zod";
2357
- var inputSchema6 = z11.object({
2358
- repo: z11.string().describe('Repository in "owner/name" format.'),
2359
- number: z11.number().int().positive().describe("Issue number."),
2360
- title: z11.string().trim().min(1).optional().describe("Replacement issue title."),
2361
- body: z11.string().optional().describe(
2560
+ import { z as z14 } from "zod";
2561
+ var inputSchema8 = z14.object({
2562
+ repo: z14.string().describe('Repository in "owner/name" format.'),
2563
+ number: z14.number().int().positive().describe("Issue number."),
2564
+ title: z14.string().trim().min(1).optional().describe("Replacement issue title."),
2565
+ body: z14.string().optional().describe(
2362
2566
  "Replacement issue body. The runtime appends requester attribution and the conversation footer."
2363
2567
  ),
2364
- state: z11.enum(["open", "closed"]).optional().describe("Replacement issue state.")
2568
+ state: z14.enum(["open", "closed"]).optional().describe("Replacement issue state.")
2365
2569
  }).strict().refine(
2366
2570
  ({ title, body, state }) => title !== void 0 || body !== void 0 || state !== void 0,
2367
2571
  { message: "At least one issue field must be provided." }
2368
2572
  );
2369
- var issueSchema = z11.object({
2370
- body: z11.string().nullable(),
2371
- number: z11.number(),
2372
- state: z11.string(),
2573
+ var issueSchema = z14.object({
2574
+ body: z14.string().nullable(),
2575
+ number: z14.number(),
2576
+ state: z14.string(),
2373
2577
  subscribable: subscribableResourceSchema7.optional(),
2374
- title: z11.string(),
2375
- url: z11.string()
2578
+ title: z14.string(),
2579
+ url: z14.string()
2376
2580
  });
2377
- var outputSchema6 = pluginToolOutputSchema8.merge(
2581
+ var outputSchema8 = pluginToolOutputSchema10.merge(
2378
2582
  issueSchema.extend({
2379
- target: z11.literal("updateIssue")
2583
+ target: z14.literal("updateIssue")
2380
2584
  })
2381
2585
  );
2382
2586
  function nonEmptyString4(value, name) {
2383
- if (!value?.trim()) throw new PluginToolInputError9(`${name} is required`);
2587
+ if (!value?.trim()) throw new PluginToolInputError10(`${name} is required`);
2384
2588
  return value.trim();
2385
2589
  }
2386
- function parseRepo8(value) {
2590
+ function parseRepo9(value) {
2387
2591
  const parts = value.split("/").map((part) => part.trim());
2388
2592
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
2389
- throw new PluginToolInputError9('repo must use "owner/name" format');
2593
+ throw new PluginToolInputError10('repo must use "owner/name" format');
2390
2594
  }
2391
2595
  return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
2392
2596
  }
2393
- async function readJson5(response) {
2597
+ async function readJson6(response) {
2394
2598
  const text2 = await response.text();
2395
2599
  if (!text2) return void 0;
2396
2600
  try {
@@ -2408,7 +2612,7 @@ function githubApiErrorMessage3(payload) {
2408
2612
  return "GitHub request failed";
2409
2613
  }
2410
2614
  function createGitHubUpdateIssueTool(ctx) {
2411
- return definePluginTool8({
2615
+ return definePluginTool10({
2412
2616
  annotations: {
2413
2617
  destructiveHint: true,
2414
2618
  idempotentHint: true,
@@ -2416,17 +2620,17 @@ function createGitHubUpdateIssueTool(ctx) {
2416
2620
  readOnlyHint: false
2417
2621
  },
2418
2622
  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.",
2419
- inputSchema: inputSchema6,
2420
- outputSchema: outputSchema6,
2623
+ inputSchema: inputSchema8,
2624
+ outputSchema: outputSchema8,
2421
2625
  async execute(input) {
2422
- const parsedInput = inputSchema6.safeParse(input);
2626
+ const parsedInput = inputSchema8.safeParse(input);
2423
2627
  if (!parsedInput.success) {
2424
- throw new PluginToolInputError9("Invalid GitHub updateIssue input.", {
2628
+ throw new PluginToolInputError10("Invalid GitHub updateIssue input.", {
2425
2629
  cause: parsedInput.error
2426
2630
  });
2427
2631
  }
2428
2632
  const update = parsedInput.data;
2429
- const repo = parseRepo8(update.repo);
2633
+ const repo = parseRepo9(update.repo);
2430
2634
  const payload = {
2431
2635
  ...update.title !== void 0 ? { title: update.title } : void 0,
2432
2636
  ...update.body !== void 0 ? {
@@ -2458,18 +2662,18 @@ function createGitHubUpdateIssueTool(ctx) {
2458
2662
  }
2459
2663
  )
2460
2664
  });
2461
- const parsed = await readJson5(response);
2665
+ const parsed = await readJson6(response);
2462
2666
  if (!response.ok) {
2463
2667
  throw new Error(
2464
2668
  `GitHub issue update failed with HTTP ${response.status}: ${githubApiErrorMessage3(parsed)}`
2465
2669
  );
2466
2670
  }
2467
- const providerResult = z11.object({
2468
- body: z11.string().nullable().optional().default(null),
2469
- html_url: z11.string(),
2470
- number: z11.number(),
2471
- state: z11.string(),
2472
- title: z11.string()
2671
+ const providerResult = z14.object({
2672
+ body: z14.string().nullable().optional().default(null),
2673
+ html_url: z14.string(),
2674
+ number: z14.number(),
2675
+ state: z14.string(),
2676
+ title: z14.string()
2473
2677
  }).parse(parsed);
2474
2678
  const subscribable = gitHubIssueSubscribable({
2475
2679
  canSubscribe: ctx.events.canSubscribe,
@@ -2502,22 +2706,22 @@ function createGitHubUpdateIssueTool(ctx) {
2502
2706
 
2503
2707
  // src/tools/update-pull-request.ts
2504
2708
  import {
2505
- definePluginTool as definePluginTool9,
2506
- PluginToolInputError as PluginToolInputError10,
2507
- pluginToolOutputSchema as pluginToolOutputSchema9
2709
+ definePluginTool as definePluginTool11,
2710
+ PluginToolInputError as PluginToolInputError11,
2711
+ pluginToolOutputSchema as pluginToolOutputSchema11
2508
2712
  } from "@sentry/junior-plugin-api";
2509
- import { z as z12 } from "zod";
2713
+ import { z as z15 } from "zod";
2510
2714
  import { subscribableResourceSchema as subscribableResourceSchema8 } from "@sentry/junior-plugin-api";
2511
- var inputSchema7 = z12.object({
2512
- repo: z12.string().describe('Repository in "owner/name" format.'),
2513
- number: z12.number().int().positive().describe("Pull request number."),
2514
- title: z12.string().trim().min(1).optional().describe("Replacement pull request title."),
2515
- body: z12.string().optional().describe(
2715
+ var inputSchema9 = z15.object({
2716
+ repo: z15.string().describe('Repository in "owner/name" format.'),
2717
+ number: z15.number().int().positive().describe("Pull request number."),
2718
+ title: z15.string().trim().min(1).optional().describe("Replacement pull request title."),
2719
+ body: z15.string().optional().describe(
2516
2720
  "Replacement pull request body. The runtime appends requester attribution and the conversation footer."
2517
2721
  ),
2518
- base: z12.string().trim().min(1).optional().describe("Replacement base branch."),
2519
- state: z12.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
2520
- draft: z12.boolean().optional().describe(
2722
+ base: z15.string().trim().min(1).optional().describe("Replacement base branch."),
2723
+ state: z15.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
2724
+ draft: z15.boolean().optional().describe(
2521
2725
  "Set false to mark a draft pull request ready for review, or true to convert it back to a draft."
2522
2726
  )
2523
2727
  }).strict().refine(
@@ -2532,43 +2736,43 @@ var CONVERT_TO_DRAFT = {
2532
2736
  operationName: "ConvertPullRequestToDraft",
2533
2737
  query: "mutation ConvertPullRequestToDraft($id: ID!) { result: convertPullRequestToDraft(input: {pullRequestId: $id}) { pullRequest { isDraft } } }"
2534
2738
  };
2535
- var draftMutationResponseSchema = z12.object({
2536
- data: z12.object({
2537
- result: z12.object({ pullRequest: z12.object({ isDraft: z12.boolean() }) })
2739
+ var draftMutationResponseSchema = z15.object({
2740
+ data: z15.object({
2741
+ result: z15.object({ pullRequest: z15.object({ isDraft: z15.boolean() }) })
2538
2742
  })
2539
2743
  });
2540
- var graphqlErrorsSchema = z12.object({
2541
- errors: z12.array(z12.object({ message: z12.string() })).min(1)
2744
+ var graphqlErrorsSchema = z15.object({
2745
+ errors: z15.array(z15.object({ message: z15.string() })).min(1)
2542
2746
  });
2543
- var pullRequestSchema2 = z12.object({
2544
- base: z12.string(),
2545
- body: z12.string().nullable(),
2546
- draft: z12.boolean(),
2547
- number: z12.number(),
2548
- state: z12.string(),
2747
+ var pullRequestSchema2 = z15.object({
2748
+ base: z15.string(),
2749
+ body: z15.string().nullable(),
2750
+ draft: z15.boolean(),
2751
+ number: z15.number(),
2752
+ state: z15.string(),
2549
2753
  subscribable: subscribableResourceSchema8.optional(),
2550
- title: z12.string(),
2551
- url: z12.string()
2754
+ title: z15.string(),
2755
+ url: z15.string()
2552
2756
  });
2553
- var outputSchema7 = pluginToolOutputSchema9.merge(
2757
+ var outputSchema9 = pluginToolOutputSchema11.merge(
2554
2758
  pullRequestSchema2.extend({
2555
- target: z12.literal("updatePullRequest")
2759
+ target: z15.literal("updatePullRequest")
2556
2760
  })
2557
2761
  );
2558
2762
  function nonEmptyString5(value, name) {
2559
2763
  if (!value?.trim()) {
2560
- throw new PluginToolInputError10(`${name} is required`);
2764
+ throw new PluginToolInputError11(`${name} is required`);
2561
2765
  }
2562
2766
  return value.trim();
2563
2767
  }
2564
- function parseRepo9(value) {
2768
+ function parseRepo10(value) {
2565
2769
  const parts = value.split("/").map((part) => part.trim());
2566
2770
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
2567
- throw new PluginToolInputError10('repo must use "owner/name" format');
2771
+ throw new PluginToolInputError11('repo must use "owner/name" format');
2568
2772
  }
2569
2773
  return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
2570
2774
  }
2571
- async function readJson6(response) {
2775
+ async function readJson7(response) {
2572
2776
  const text2 = await response.text();
2573
2777
  if (!text2) return void 0;
2574
2778
  try {
@@ -2600,7 +2804,7 @@ async function setPullRequestDraft(input) {
2600
2804
  })
2601
2805
  })
2602
2806
  });
2603
- const payload = await readJson6(response);
2807
+ const payload = await readJson7(response);
2604
2808
  const isDraft = draftMutationResponseSchema.safeParse(payload).data?.data.result.pullRequest.isDraft;
2605
2809
  if (!response.ok || isDraft !== input.draft) {
2606
2810
  throw new Error(
@@ -2614,7 +2818,7 @@ function githubGraphqlErrorMessage(payload) {
2614
2818
  return result.success ? result.data.errors.map((error) => error.message).join("; ") : githubApiErrorMessage4(payload);
2615
2819
  }
2616
2820
  function createGitHubUpdatePullRequestTool(ctx) {
2617
- return definePluginTool9({
2821
+ return definePluginTool11({
2618
2822
  annotations: {
2619
2823
  destructiveHint: true,
2620
2824
  idempotentHint: true,
@@ -2622,18 +2826,18 @@ function createGitHubUpdatePullRequestTool(ctx) {
2622
2826
  readOnlyHint: false
2623
2827
  },
2624
2828
  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.",
2625
- inputSchema: inputSchema7,
2626
- outputSchema: outputSchema7,
2829
+ inputSchema: inputSchema9,
2830
+ outputSchema: outputSchema9,
2627
2831
  async execute(input) {
2628
- const parsedInput = inputSchema7.safeParse(input);
2832
+ const parsedInput = inputSchema9.safeParse(input);
2629
2833
  if (!parsedInput.success) {
2630
- throw new PluginToolInputError10(
2834
+ throw new PluginToolInputError11(
2631
2835
  "Invalid GitHub updatePullRequest input.",
2632
2836
  { cause: parsedInput.error }
2633
2837
  );
2634
2838
  }
2635
2839
  const update = parsedInput.data;
2636
- const repo = parseRepo9(update.repo);
2840
+ const repo = parseRepo10(update.repo);
2637
2841
  const requester = await resolveGitHubRequester(ctx);
2638
2842
  const payload = {
2639
2843
  ...update.title !== void 0 ? { title: update.title } : void 0,
@@ -2662,22 +2866,22 @@ function createGitHubUpdatePullRequestTool(ctx) {
2662
2866
  ...hasRestUpdate ? { body: JSON.stringify(payload) } : void 0
2663
2867
  })
2664
2868
  });
2665
- const parsed = await readJson6(response);
2869
+ const parsed = await readJson7(response);
2666
2870
  if (!response.ok) {
2667
2871
  throw new Error(
2668
2872
  `GitHub pull request update failed with HTTP ${response.status}: ${githubApiErrorMessage4(parsed)}`
2669
2873
  );
2670
2874
  }
2671
- const providerResult = z12.object({
2672
- base: z12.object({ ref: z12.string() }),
2673
- body: z12.string().nullable().optional().default(null),
2674
- draft: z12.boolean(),
2675
- html_url: z12.string(),
2676
- merged: z12.boolean(),
2677
- node_id: z12.string().optional(),
2678
- number: z12.number(),
2679
- state: z12.string(),
2680
- title: z12.string()
2875
+ const providerResult = z15.object({
2876
+ base: z15.object({ ref: z15.string() }),
2877
+ body: z15.string().nullable().optional().default(null),
2878
+ draft: z15.boolean(),
2879
+ html_url: z15.string(),
2880
+ merged: z15.boolean(),
2881
+ node_id: z15.string().optional(),
2882
+ number: z15.number(),
2883
+ state: z15.string(),
2884
+ title: z15.string()
2681
2885
  }).parse(parsed);
2682
2886
  if (update.draft !== void 0 && update.draft !== providerResult.draft) {
2683
2887
  if (!providerResult.node_id) {
@@ -2738,11 +2942,11 @@ function createGitHubUpdatePullRequestTool(ctx) {
2738
2942
 
2739
2943
  // src/tools/update-pull-request-feedback.ts
2740
2944
  import {
2741
- definePluginTool as definePluginTool10,
2742
- PluginToolInputError as PluginToolInputError11,
2743
- pluginToolOutputSchema as pluginToolOutputSchema10
2945
+ definePluginTool as definePluginTool12,
2946
+ PluginToolInputError as PluginToolInputError12,
2947
+ pluginToolOutputSchema as pluginToolOutputSchema12
2744
2948
  } from "@sentry/junior-plugin-api";
2745
- import { z as z13 } from "zod";
2949
+ import { z as z16 } from "zod";
2746
2950
  var STATUS_TO_REACTION_CONTENT = {
2747
2951
  reviewing: "eyes",
2748
2952
  addressed: "+1",
@@ -2751,29 +2955,29 @@ var STATUS_TO_REACTION_CONTENT = {
2751
2955
  var FEEDBACK_REACTION_CONTENTS = new Set(
2752
2956
  Object.values(STATUS_TO_REACTION_CONTENT)
2753
2957
  );
2754
- var inputSchema8 = z13.object({
2755
- repo: z13.string().describe('Repository in "owner/name" format.'),
2756
- comment_kind: z13.enum(["conversation", "review"]).describe(
2958
+ var inputSchema10 = z16.object({
2959
+ repo: z16.string().describe('Repository in "owner/name" format.'),
2960
+ comment_kind: z16.enum(["conversation", "review"]).describe(
2757
2961
  'Comment kind: "conversation" for a pull request conversation comment, "review" for an inline review comment.'
2758
2962
  ),
2759
- comment_id: z13.number().int().positive().describe(
2963
+ comment_id: z16.number().int().positive().describe(
2760
2964
  "GitHub comment id (conversation comment id or inline review comment id)."
2761
2965
  ),
2762
- status: z13.enum(["addressed", "declined"]).describe(
2966
+ status: z16.enum(["addressed", "declined"]).describe(
2763
2967
  "Feedback outcome. Maps to a reaction: addressed -> +1, declined -> -1."
2764
2968
  )
2765
2969
  }).strict();
2766
- var outputSchema8 = pluginToolOutputSchema10.extend({
2767
- target: z13.literal("updatePullRequestFeedback"),
2768
- repo: z13.string(),
2769
- comment_id: z13.number(),
2770
- status: z13.enum(["addressed", "declined"]),
2771
- reaction_id: z13.number()
2970
+ var outputSchema10 = pluginToolOutputSchema12.extend({
2971
+ target: z16.literal("updatePullRequestFeedback"),
2972
+ repo: z16.string(),
2973
+ comment_id: z16.number(),
2974
+ status: z16.enum(["addressed", "declined"]),
2975
+ reaction_id: z16.number()
2772
2976
  });
2773
- function parseRepo10(value) {
2977
+ function parseRepo11(value) {
2774
2978
  const parts = value.split("/").map((part) => part.trim());
2775
2979
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
2776
- throw new PluginToolInputError11('repo must use "owner/name" format');
2980
+ throw new PluginToolInputError12('repo must use "owner/name" format');
2777
2981
  }
2778
2982
  return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
2779
2983
  }
@@ -2787,7 +2991,7 @@ function pullRequestCommentReactionsPath(input) {
2787
2991
  function pullRequestFeedbackReactionContent(status) {
2788
2992
  return STATUS_TO_REACTION_CONTENT[status];
2789
2993
  }
2790
- async function readJson7(response) {
2994
+ async function readJson8(response) {
2791
2995
  const text2 = await response.text();
2792
2996
  if (!text2) return void 0;
2793
2997
  try {
@@ -2796,17 +3000,17 @@ async function readJson7(response) {
2796
3000
  return text2;
2797
3001
  }
2798
3002
  }
2799
- function githubError(payload) {
3003
+ function githubError2(payload) {
2800
3004
  if (payload && typeof payload === "object" && !Array.isArray(payload)) {
2801
3005
  const message = payload.message;
2802
3006
  if (typeof message === "string" && message.trim()) return message.trim();
2803
3007
  }
2804
3008
  return "GitHub request failed";
2805
3009
  }
2806
- var reactionSchema = z13.object({
2807
- id: z13.number(),
2808
- content: z13.string(),
2809
- user: z13.object({ id: z13.number() }).nullable()
3010
+ var reactionSchema = z16.object({
3011
+ id: z16.number(),
3012
+ content: z16.string(),
3013
+ user: z16.object({ id: z16.number() }).nullable()
2810
3014
  });
2811
3015
  async function assertBotAuthoredPullRequest(egress, input) {
2812
3016
  const headers = {
@@ -2821,15 +3025,15 @@ async function assertBotAuthoredPullRequest(egress, input) {
2821
3025
  { headers }
2822
3026
  )
2823
3027
  });
2824
- const commentPayload = await readJson7(commentResponse);
3028
+ const commentPayload = await readJson8(commentResponse);
2825
3029
  if (!commentResponse.ok) {
2826
- const message = `GitHub comment lookup failed with HTTP ${commentResponse.status}: ${githubError(commentPayload)}`;
2827
- if (commentResponse.status === 404) throw new PluginToolInputError11(message);
3030
+ const message = `GitHub comment lookup failed with HTTP ${commentResponse.status}: ${githubError2(commentPayload)}`;
3031
+ if (commentResponse.status === 404) throw new PluginToolInputError12(message);
2828
3032
  throw new Error(message);
2829
3033
  }
2830
- const comment = z13.object({
2831
- issue_url: z13.string().optional(),
2832
- pull_request_url: z13.string().optional()
3034
+ const comment = z16.object({
3035
+ issue_url: z16.string().optional(),
3036
+ pull_request_url: z16.string().optional()
2833
3037
  }).safeParse(commentPayload);
2834
3038
  const parentUrl = comment.success ? input.commentKind === "conversation" ? comment.data.issue_url : comment.data.pull_request_url : void 0;
2835
3039
  const number = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
@@ -2844,21 +3048,21 @@ async function assertBotAuthoredPullRequest(egress, input) {
2844
3048
  { headers }
2845
3049
  )
2846
3050
  });
2847
- const pullPayload = await readJson7(pullResponse);
3051
+ const pullPayload = await readJson8(pullResponse);
2848
3052
  if (!pullResponse.ok && pullResponse.status !== 404) {
2849
3053
  throw new Error(
2850
- `GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${githubError(pullPayload)}`
3054
+ `GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${githubError2(pullPayload)}`
2851
3055
  );
2852
3056
  }
2853
- const pull = z13.object({ user: z13.object({ id: z13.number() }).nullable() }).safeParse(pullPayload);
3057
+ const pull = z16.object({ user: z16.object({ id: z16.number() }).nullable() }).safeParse(pullPayload);
2854
3058
  if (!pullResponse.ok || !pull.success || pull.data.user?.id !== input.botUserId) {
2855
- throw new PluginToolInputError11(
3059
+ throw new PluginToolInputError12(
2856
3060
  "This bot can only set feedback status on comments on pull requests it authored."
2857
3061
  );
2858
3062
  }
2859
3063
  }
2860
3064
  function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2861
- return definePluginTool10({
3065
+ return definePluginTool12({
2862
3066
  // No action review: the tool checks in code that the bot authored the pull
2863
3067
  // request, and it changes only the bot's own reaction, which is reversible.
2864
3068
  approvalMode: "approve",
@@ -2870,12 +3074,12 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2870
3074
  },
2871
3075
  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.",
2872
3076
  exposure: "direct",
2873
- inputSchema: inputSchema8,
2874
- outputSchema: outputSchema8,
3077
+ inputSchema: inputSchema10,
3078
+ outputSchema: outputSchema10,
2875
3079
  async execute(input) {
2876
- const parsedInput = inputSchema8.safeParse(input);
3080
+ const parsedInput = inputSchema10.safeParse(input);
2877
3081
  if (!parsedInput.success) {
2878
- throw new PluginToolInputError11(
3082
+ throw new PluginToolInputError12(
2879
3083
  "Invalid GitHub updatePullRequestFeedback input.",
2880
3084
  { cause: parsedInput.error }
2881
3085
  );
@@ -2885,7 +3089,7 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2885
3089
  comment_kind: commentKind,
2886
3090
  status
2887
3091
  } = parsedInput.data;
2888
- const repo = parseRepo10(parsedInput.data.repo);
3092
+ const repo = parseRepo11(parsedInput.data.repo);
2889
3093
  const botUserId = botUserIdFromEmail(botEmail);
2890
3094
  if (botUserId === void 0) {
2891
3095
  throw new Error("GitHub App bot identity is not configured.");
@@ -2911,13 +3115,13 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2911
3115
  headers: { Accept: "application/vnd.github+json" }
2912
3116
  })
2913
3117
  });
2914
- const listPayload = await readJson7(listResponse);
3118
+ const listPayload = await readJson8(listResponse);
2915
3119
  if (!listResponse.ok) {
2916
3120
  throw new Error(
2917
- `GitHub reaction lookup failed with HTTP ${listResponse.status}: ${githubError(listPayload)}`
3121
+ `GitHub reaction lookup failed with HTTP ${listResponse.status}: ${githubError2(listPayload)}`
2918
3122
  );
2919
3123
  }
2920
- const botReactions = z13.array(reactionSchema).parse(listPayload).filter(
3124
+ const botReactions = z16.array(reactionSchema).parse(listPayload).filter(
2921
3125
  (reaction) => reaction.user?.id === botUserId && FEEDBACK_REACTION_CONTENTS.has(reaction.content)
2922
3126
  );
2923
3127
  const existing = botReactions.find(
@@ -2933,9 +3137,9 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2933
3137
  })
2934
3138
  });
2935
3139
  if (!deleteResponse.ok && deleteResponse.status !== 404) {
2936
- const deletePayload = await readJson7(deleteResponse);
3140
+ const deletePayload = await readJson8(deleteResponse);
2937
3141
  throw new Error(
2938
- `GitHub reaction removal failed with HTTP ${deleteResponse.status}: ${githubError(deletePayload)}`
3142
+ `GitHub reaction removal failed with HTTP ${deleteResponse.status}: ${githubError2(deletePayload)}`
2939
3143
  );
2940
3144
  }
2941
3145
  }
@@ -2960,10 +3164,10 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2960
3164
  body: JSON.stringify({ content: targetContent })
2961
3165
  })
2962
3166
  });
2963
- const createPayload = await readJson7(createResponse);
3167
+ const createPayload = await readJson8(createResponse);
2964
3168
  if (!createResponse.ok) {
2965
3169
  throw new Error(
2966
- `GitHub reaction creation failed with HTTP ${createResponse.status}: ${githubError(createPayload)}`
3170
+ `GitHub reaction creation failed with HTTP ${createResponse.status}: ${githubError2(createPayload)}`
2967
3171
  );
2968
3172
  }
2969
3173
  const created = reactionSchema.parse(createPayload);
@@ -2980,34 +3184,34 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2980
3184
 
2981
3185
  // src/tools/resolve-pull-request-review-thread.ts
2982
3186
  import {
2983
- definePluginTool as definePluginTool11,
2984
- PluginToolInputError as PluginToolInputError12,
2985
- pluginToolOutputSchema as pluginToolOutputSchema11
3187
+ definePluginTool as definePluginTool13,
3188
+ PluginToolInputError as PluginToolInputError13,
3189
+ pluginToolOutputSchema as pluginToolOutputSchema13
2986
3190
  } from "@sentry/junior-plugin-api";
2987
- import { z as z14 } from "zod";
2988
- var inputSchema9 = z14.object({
2989
- repo: z14.string().describe(
3191
+ import { z as z17 } from "zod";
3192
+ var inputSchema11 = z17.object({
3193
+ repo: z17.string().describe(
2990
3194
  'Repository in "owner/name" format. Required because GraphQL has no repo path.'
2991
3195
  ),
2992
- thread_id: z14.string().trim().min(1).describe(
3196
+ thread_id: z17.string().trim().min(1).describe(
2993
3197
  "GitHub pull request review thread node ID (the `threadId` / `id` variable used by `gh api graphql` resolveReviewThread)."
2994
3198
  )
2995
3199
  }).strict();
2996
- var outputSchema9 = pluginToolOutputSchema11.extend({
2997
- target: z14.literal("resolvePullRequestReviewThread"),
2998
- repo: z14.string(),
2999
- number: z14.number(),
3000
- thread_id: z14.string(),
3001
- resolved: z14.boolean()
3200
+ var outputSchema11 = pluginToolOutputSchema13.extend({
3201
+ target: z17.literal("resolvePullRequestReviewThread"),
3202
+ repo: z17.string(),
3203
+ number: z17.number(),
3204
+ thread_id: z17.string(),
3205
+ resolved: z17.boolean()
3002
3206
  });
3003
- function parseRepo11(value) {
3207
+ function parseRepo12(value) {
3004
3208
  const parts = value.split("/").map((part) => part.trim());
3005
3209
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
3006
- throw new PluginToolInputError12('repo must use "owner/name" format');
3210
+ throw new PluginToolInputError13('repo must use "owner/name" format');
3007
3211
  }
3008
3212
  return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
3009
3213
  }
3010
- async function readJson8(response) {
3214
+ async function readJson9(response) {
3011
3215
  const text2 = await response.text();
3012
3216
  if (!text2) return void 0;
3013
3217
  try {
@@ -3016,7 +3220,7 @@ async function readJson8(response) {
3016
3220
  return text2;
3017
3221
  }
3018
3222
  }
3019
- function githubError2(payload) {
3223
+ function githubError3(payload) {
3020
3224
  if (payload && typeof payload === "object" && !Array.isArray(payload)) {
3021
3225
  const message = payload.message;
3022
3226
  if (typeof message === "string" && message.trim()) return message.trim();
@@ -3024,7 +3228,7 @@ function githubError2(payload) {
3024
3228
  return "GitHub request failed";
3025
3229
  }
3026
3230
  function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
3027
- return definePluginTool11({
3231
+ return definePluginTool13({
3028
3232
  // No action review: the tool checks in code that the bot authored the pull
3029
3233
  // request, and it changes only the thread's resolved state, which is
3030
3234
  // reversible.
@@ -3037,17 +3241,17 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
3037
3241
  },
3038
3242
  description: "Resolve a GitHub pull request review thread after acting on its feedback. Only works on pull requests the bot authored.",
3039
3243
  exposure: "direct",
3040
- inputSchema: inputSchema9,
3041
- outputSchema: outputSchema9,
3244
+ inputSchema: inputSchema11,
3245
+ outputSchema: outputSchema11,
3042
3246
  async execute(input) {
3043
- const parsedInput = inputSchema9.safeParse(input);
3247
+ const parsedInput = inputSchema11.safeParse(input);
3044
3248
  if (!parsedInput.success) {
3045
- throw new PluginToolInputError12(
3249
+ throw new PluginToolInputError13(
3046
3250
  "Invalid GitHub resolvePullRequestReviewThread input.",
3047
3251
  { cause: parsedInput.error }
3048
3252
  );
3049
3253
  }
3050
- const repo = parseRepo11(parsedInput.data.repo);
3254
+ const repo = parseRepo12(parsedInput.data.repo);
3051
3255
  const botUserId = botUserIdFromEmail(botEmail);
3052
3256
  if (botUserId === void 0) {
3053
3257
  throw new Error("GitHub App bot identity is not configured.");
@@ -3078,37 +3282,37 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
3078
3282
  })
3079
3283
  })
3080
3284
  });
3081
- const lookupPayload = await readJson8(lookupResponse);
3285
+ const lookupPayload = await readJson9(lookupResponse);
3082
3286
  if (!lookupResponse.ok) {
3083
3287
  throw new Error(
3084
- `GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubError2(lookupPayload)}`
3288
+ `GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubError3(lookupPayload)}`
3085
3289
  );
3086
3290
  }
3087
- const threadNodeSchema = z14.object({
3088
- id: z14.string(),
3089
- isResolved: z14.boolean(),
3090
- pullRequest: z14.object({
3091
- author: z14.object({ databaseId: z14.number().optional() }).passthrough().nullable(),
3092
- number: z14.number(),
3093
- repository: z14.object({ nameWithOwner: z14.string() }).passthrough()
3291
+ const threadNodeSchema = z17.object({
3292
+ id: z17.string(),
3293
+ isResolved: z17.boolean(),
3294
+ pullRequest: z17.object({
3295
+ author: z17.object({ databaseId: z17.number().optional() }).passthrough().nullable(),
3296
+ number: z17.number(),
3297
+ repository: z17.object({ nameWithOwner: z17.string() }).passthrough()
3094
3298
  }).passthrough()
3095
3299
  }).passthrough();
3096
- const lookupResultSchema = z14.object({
3097
- data: z14.object({
3098
- node: z14.unknown().nullable().optional()
3300
+ const lookupResultSchema = z17.object({
3301
+ data: z17.object({
3302
+ node: z17.unknown().nullable().optional()
3099
3303
  }).passthrough()
3100
3304
  }).passthrough();
3101
3305
  const lookupResult = lookupResultSchema.safeParse(lookupPayload);
3102
3306
  const rawNode = lookupResult.success ? lookupResult.data.data.node : void 0;
3103
3307
  const parsedNode = rawNode == null ? void 0 : threadNodeSchema.safeParse(rawNode);
3104
3308
  if (!parsedNode?.success) {
3105
- throw new PluginToolInputError12("GitHub review thread was not found.");
3309
+ throw new PluginToolInputError13("GitHub review thread was not found.");
3106
3310
  }
3107
3311
  const thread = parsedNode.data;
3108
3312
  const pullRequest = thread.pullRequest;
3109
3313
  const ownsPullRequest = pullRequest.repository.nameWithOwner.toLowerCase() === repo.ref.toLowerCase() && pullRequest.author?.databaseId === botUserId;
3110
3314
  if (!ownsPullRequest) {
3111
- throw new PluginToolInputError12(
3315
+ throw new PluginToolInputError13(
3112
3316
  "This bot can only resolve review threads on pull requests it authored."
3113
3317
  );
3114
3318
  }
@@ -3139,16 +3343,16 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
3139
3343
  })
3140
3344
  })
3141
3345
  });
3142
- const resolvePayload = await readJson8(resolveResponse);
3346
+ const resolvePayload = await readJson9(resolveResponse);
3143
3347
  if (!resolveResponse.ok) {
3144
3348
  throw new Error(
3145
- `GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubError2(resolvePayload)}`
3349
+ `GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubError3(resolvePayload)}`
3146
3350
  );
3147
3351
  }
3148
- const resolveResultSchema = z14.object({
3149
- data: z14.object({
3150
- resolveReviewThread: z14.object({
3151
- thread: z14.object({ id: z14.string(), isResolved: z14.boolean() }).passthrough()
3352
+ const resolveResultSchema = z17.object({
3353
+ data: z17.object({
3354
+ resolveReviewThread: z17.object({
3355
+ thread: z17.object({ id: z17.string(), isResolved: z17.boolean() }).passthrough()
3152
3356
  }).passthrough()
3153
3357
  }).passthrough()
3154
3358
  }).passthrough();
@@ -3176,45 +3380,45 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
3176
3380
 
3177
3381
  // src/tools/submit-pull-request-review.ts
3178
3382
  import {
3179
- definePluginTool as definePluginTool12,
3180
- PluginToolInputError as PluginToolInputError13,
3181
- pluginToolOutputSchema as pluginToolOutputSchema12
3383
+ definePluginTool as definePluginTool14,
3384
+ PluginToolInputError as PluginToolInputError14,
3385
+ pluginToolOutputSchema as pluginToolOutputSchema14
3182
3386
  } from "@sentry/junior-plugin-api";
3183
- import { z as z15 } from "zod";
3184
- var reviewCommentSchema = z15.object({
3185
- path: z15.string().trim().min(1).describe("File path in the pull request."),
3186
- body: z15.string().trim().min(1).describe("Inline review comment."),
3187
- line: z15.number().int().positive().describe("Line in the pull request diff."),
3188
- side: z15.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
3189
- start_line: z15.number().int().positive().optional().describe("First line of a multi-line comment."),
3190
- start_side: z15.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
3387
+ import { z as z18 } from "zod";
3388
+ var reviewCommentSchema = z18.object({
3389
+ path: z18.string().trim().min(1).describe("File path in the pull request."),
3390
+ body: z18.string().trim().min(1).describe("Inline review comment."),
3391
+ line: z18.number().int().positive().describe("Line in the pull request diff."),
3392
+ side: z18.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
3393
+ start_line: z18.number().int().positive().optional().describe("First line of a multi-line comment."),
3394
+ start_side: z18.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
3191
3395
  }).strict().refine(
3192
3396
  ({ start_line, start_side }) => start_line === void 0 === (start_side === void 0),
3193
3397
  { message: "start_line and start_side must be provided together." }
3194
3398
  );
3195
- var inputSchema10 = z15.object({
3196
- repo: z15.string().describe('Repository in "owner/name" format.'),
3197
- number: z15.number().int().positive().describe("Pull request number."),
3198
- event: z15.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
3199
- body: z15.string().trim().min(1).describe("Review summary."),
3200
- comments: z15.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
3399
+ var inputSchema12 = z18.object({
3400
+ repo: z18.string().describe('Repository in "owner/name" format.'),
3401
+ number: z18.number().int().positive().describe("Pull request number."),
3402
+ event: z18.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
3403
+ body: z18.string().trim().min(1).describe("Review summary."),
3404
+ comments: z18.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
3201
3405
  }).strict();
3202
- var outputSchema10 = pluginToolOutputSchema12.extend({
3203
- target: z15.literal("submitPullRequestReview"),
3204
- repo: z15.string(),
3205
- number: z15.number(),
3206
- review_id: z15.number(),
3207
- state: z15.string(),
3208
- url: z15.string()
3406
+ var outputSchema12 = pluginToolOutputSchema14.extend({
3407
+ target: z18.literal("submitPullRequestReview"),
3408
+ repo: z18.string(),
3409
+ number: z18.number(),
3410
+ review_id: z18.number(),
3411
+ state: z18.string(),
3412
+ url: z18.string()
3209
3413
  });
3210
- function parseRepo12(value) {
3414
+ function parseRepo13(value) {
3211
3415
  const parts = value.split("/").map((part) => part.trim());
3212
3416
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
3213
- throw new PluginToolInputError13('repo must use "owner/name" format');
3417
+ throw new PluginToolInputError14('repo must use "owner/name" format');
3214
3418
  }
3215
3419
  return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
3216
3420
  }
3217
- async function readJson9(response) {
3421
+ async function readJson10(response) {
3218
3422
  const text2 = await response.text();
3219
3423
  if (!text2) return void 0;
3220
3424
  try {
@@ -3223,7 +3427,7 @@ async function readJson9(response) {
3223
3427
  return text2;
3224
3428
  }
3225
3429
  }
3226
- function githubError3(body) {
3430
+ function githubError4(body) {
3227
3431
  if (body && typeof body === "object" && !Array.isArray(body)) {
3228
3432
  const message = body.message;
3229
3433
  if (typeof message === "string" && message.trim()) return message.trim();
@@ -3232,14 +3436,14 @@ function githubError3(body) {
3232
3436
  return "GitHub request failed";
3233
3437
  }
3234
3438
  function throwReviewError(status, body) {
3235
- const message = `GitHub pull request review failed with HTTP ${status}: ${githubError3(body)}`;
3439
+ const message = `GitHub pull request review failed with HTTP ${status}: ${githubError4(body)}`;
3236
3440
  if (status === 404 || status === 422) {
3237
- throw new PluginToolInputError13(message);
3441
+ throw new PluginToolInputError14(message);
3238
3442
  }
3239
3443
  throw new Error(message);
3240
3444
  }
3241
3445
  function createGitHubSubmitPullRequestReviewTool(egress) {
3242
- return definePluginTool12({
3446
+ return definePluginTool14({
3243
3447
  annotations: {
3244
3448
  destructiveHint: true,
3245
3449
  idempotentHint: false,
@@ -3248,10 +3452,10 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
3248
3452
  },
3249
3453
  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.",
3250
3454
  exposure: "direct",
3251
- inputSchema: inputSchema10,
3252
- outputSchema: outputSchema10,
3455
+ inputSchema: inputSchema12,
3456
+ outputSchema: outputSchema12,
3253
3457
  async execute(review) {
3254
- const repo = parseRepo12(review.repo);
3458
+ const repo = parseRepo13(review.repo);
3255
3459
  const comments = review.comments?.map((comment) => ({
3256
3460
  path: comment.path,
3257
3461
  body: comment.body,
@@ -3280,11 +3484,11 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
3280
3484
  }
3281
3485
  )
3282
3486
  });
3283
- const parsed = await readJson9(response);
3487
+ const parsed = await readJson10(response);
3284
3488
  if (!response.ok) {
3285
3489
  throwReviewError(response.status, parsed);
3286
3490
  }
3287
- const providerResult = z15.object({ id: z15.number(), html_url: z15.string(), state: z15.string() }).parse(parsed);
3491
+ const providerResult = z18.object({ id: z18.number(), html_url: z18.string(), state: z18.string() }).parse(parsed);
3288
3492
  return {
3289
3493
  target: "submitPullRequestReview",
3290
3494
  repo: repo.ref,
@@ -3301,6 +3505,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
3301
3505
  function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
3302
3506
  return {
3303
3507
  cloneRepository: createGitHubCloneRepositoryTool(ctx),
3508
+ commentOnPullRequest: createGitHubCommentOnPullRequestTool(ctx.egress),
3304
3509
  createIssue: createGitHubIssueTool(ctx),
3305
3510
  createPullRequest: createGitHubPullRequestTool(
3306
3511
  ctx,
@@ -3310,6 +3515,7 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
3310
3515
  getPullRequest: createGitHubGetPullRequestTool(ctx),
3311
3516
  getRelease: createGitHubGetReleaseTool(ctx),
3312
3517
  getRepository: createGitHubGetRepositoryTool(ctx),
3518
+ getStatus: createGitHubGetStatusTool(ctx),
3313
3519
  resolvePullRequestReviewThread: createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail),
3314
3520
  submitPullRequestReview: createGitHubSubmitPullRequestReviewTool(
3315
3521
  ctx.egress
@@ -3325,26 +3531,26 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
3325
3531
 
3326
3532
  // src/webhooks/handler.ts
3327
3533
  import { createHmac, timingSafeEqual } from "crypto";
3328
- import { z as z25 } from "zod";
3534
+ import { z as z28 } from "zod";
3329
3535
 
3330
3536
  // src/issue-outcomes/store.ts
3331
3537
  import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
3332
- import { z as z16 } from "zod";
3333
- var githubIssueOutcomeInputSchema = z16.object({
3334
- candidateOwned: z16.boolean(),
3335
- closedAt: z16.date().optional(),
3336
- issueId: z16.string().min(1),
3337
- number: z16.number().int().positive(),
3338
- openedAt: z16.date(),
3339
- repositoryFullName: z16.string().min(1),
3340
- repositoryId: z16.string().min(1),
3538
+ import { z as z19 } from "zod";
3539
+ var githubIssueOutcomeInputSchema = z19.object({
3540
+ candidateOwned: z19.boolean(),
3541
+ closedAt: z19.date().optional(),
3542
+ issueId: z19.string().min(1),
3543
+ number: z19.number().int().positive(),
3544
+ openedAt: z19.date(),
3545
+ repositoryFullName: z19.string().min(1),
3546
+ repositoryId: z19.string().min(1),
3341
3547
  state: githubIssueStateSchema,
3342
3548
  stateReason: githubIssueStateReasonSchema.optional(),
3343
- updatedAt: z16.date()
3549
+ updatedAt: z19.date()
3344
3550
  }).strict();
3345
- var githubIssueConversationsInputSchema = z16.object({
3346
- conversationIds: z16.array(z16.string().min(1)).min(1),
3347
- issueId: z16.string().min(1)
3551
+ var githubIssueConversationsInputSchema = z19.object({
3552
+ conversationIds: z19.array(z19.string().min(1)).min(1),
3553
+ issueId: z19.string().min(1)
3348
3554
  }).strict();
3349
3555
  function projectionValues(input) {
3350
3556
  return {
@@ -3408,33 +3614,33 @@ async function recordGitHubIssueConversations(db, input) {
3408
3614
 
3409
3615
  // src/pull-request-outcomes/store.ts
3410
3616
  import { and as and3, eq as eq3, lte as lte2, ne, sql as sql3 } from "drizzle-orm";
3411
- import { z as z17 } from "zod";
3412
- var githubPullRequestOutcomeInputSchema = z17.object({
3413
- candidateOwned: z17.boolean(),
3414
- closedAt: z17.date().optional(),
3617
+ import { z as z20 } from "zod";
3618
+ var githubPullRequestOutcomeInputSchema = z20.object({
3619
+ candidateOwned: z20.boolean(),
3620
+ closedAt: z20.date().optional(),
3415
3621
  commitComposition: githubPullRequestCommitCompositionSchema.optional(),
3416
- mergedAt: z17.date().optional(),
3417
- number: z17.number().int().positive(),
3418
- openedAt: z17.date(),
3419
- pullRequestId: z17.string().min(1),
3420
- repositoryFullName: z17.string().min(1),
3421
- repositoryId: z17.string().min(1),
3622
+ mergedAt: z20.date().optional(),
3623
+ number: z20.number().int().positive(),
3624
+ openedAt: z20.date(),
3625
+ pullRequestId: z20.string().min(1),
3626
+ repositoryFullName: z20.string().min(1),
3627
+ repositoryId: z20.string().min(1),
3422
3628
  state: githubPullRequestStateSchema,
3423
- title: z17.string().min(1).optional(),
3424
- updatedAt: z17.date()
3629
+ title: z20.string().min(1).optional(),
3630
+ updatedAt: z20.date()
3425
3631
  }).strict();
3426
- var githubPullRequestConversationsInputSchema = z17.object({
3427
- conversationIds: z17.array(z17.string().min(1)).min(1),
3428
- pullRequestId: z17.string().min(1)
3632
+ var githubPullRequestConversationsInputSchema = z20.object({
3633
+ conversationIds: z20.array(z20.string().min(1)).min(1),
3634
+ pullRequestId: z20.string().min(1)
3429
3635
  }).strict();
3430
- var githubPullRequestLinkedIssuesInputSchema = z17.object({
3431
- linkedIssues: z17.array(
3432
- z17.object({
3433
- number: z17.number().int().positive(),
3434
- repositoryFullName: z17.string().min(1)
3636
+ var githubPullRequestLinkedIssuesInputSchema = z20.object({
3637
+ linkedIssues: z20.array(
3638
+ z20.object({
3639
+ number: z20.number().int().positive(),
3640
+ repositoryFullName: z20.string().min(1)
3435
3641
  }).strict()
3436
3642
  ).min(1),
3437
- pullRequestId: z17.string().min(1)
3643
+ pullRequestId: z20.string().min(1)
3438
3644
  }).strict();
3439
3645
  function projectionValues2(input) {
3440
3646
  return {
@@ -3502,7 +3708,7 @@ async function listGitHubUnfinishedWork(db, conversationIds) {
3502
3708
  );
3503
3709
  const rows = await db.select({ conversationIds: juniorGitHubPullRequests.conversationIds }).from(juniorGitHubPullRequests).where(
3504
3710
  and3(
3505
- ne(juniorGitHubPullRequests.state, "merged"),
3711
+ eq3(juniorGitHubPullRequests.state, "open"),
3506
3712
  sql3`${juniorGitHubPullRequests.conversationIds} && ARRAY[${values}]::text[]`
3507
3713
  )
3508
3714
  );
@@ -3515,23 +3721,25 @@ async function listGitHubFinishedWork(db, conversationIds) {
3515
3721
  sql3`, `
3516
3722
  );
3517
3723
  const rows = await db.select({
3724
+ closedAt: juniorGitHubPullRequests.closedAt,
3518
3725
  conversationIds: juniorGitHubPullRequests.conversationIds,
3519
3726
  mergedAt: juniorGitHubPullRequests.mergedAt
3520
3727
  }).from(juniorGitHubPullRequests).where(
3521
3728
  and3(
3522
- eq3(juniorGitHubPullRequests.state, "merged"),
3729
+ ne(juniorGitHubPullRequests.state, "open"),
3523
3730
  sql3`${juniorGitHubPullRequests.conversationIds} && ARRAY[${values}]::text[]`
3524
3731
  )
3525
3732
  );
3526
3733
  const candidates = new Set(conversationIds);
3527
3734
  const finishedAtById = /* @__PURE__ */ new Map();
3528
3735
  for (const row of rows) {
3529
- if (!row.mergedAt) continue;
3736
+ const finishedAt = row.mergedAt ?? row.closedAt;
3737
+ if (!finishedAt) continue;
3530
3738
  for (const conversationId of row.conversationIds) {
3531
3739
  if (!candidates.has(conversationId)) continue;
3532
3740
  const current = finishedAtById.get(conversationId);
3533
- if (!current || row.mergedAt > current) {
3534
- finishedAtById.set(conversationId, row.mergedAt);
3741
+ if (!current || finishedAt > current) {
3742
+ finishedAtById.set(conversationId, finishedAt);
3535
3743
  }
3536
3744
  }
3537
3745
  }
@@ -3637,39 +3845,39 @@ async function releaseGitHubPullRequestReadySync(db, target, claim) {
3637
3845
  }
3638
3846
 
3639
3847
  // src/webhooks/issue-outcome.ts
3640
- import { z as z18 } from "zod";
3641
- var canonicalIssueOutcomeSchema = z18.object({
3642
- action: z18.enum(["opened", "closed", "reopened"]),
3643
- issue: z18.object({
3644
- body: z18.string().nullable().optional(),
3645
- closed_at: z18.string().nullable().optional(),
3646
- created_at: z18.string(),
3647
- id: z18.number().int().positive(),
3648
- number: z18.number().int().positive(),
3848
+ import { z as z21 } from "zod";
3849
+ var canonicalIssueOutcomeSchema = z21.object({
3850
+ action: z21.enum(["opened", "closed", "reopened"]),
3851
+ issue: z21.object({
3852
+ body: z21.string().nullable().optional(),
3853
+ closed_at: z21.string().nullable().optional(),
3854
+ created_at: z21.string(),
3855
+ id: z21.number().int().positive(),
3856
+ number: z21.number().int().positive(),
3649
3857
  state_reason: githubIssueStateReasonSchema.nullable().optional(),
3650
- updated_at: z18.string(),
3651
- user: z18.object({ login: z18.string().min(1) }).strict()
3858
+ updated_at: z21.string(),
3859
+ user: z21.object({ login: z21.string().min(1) }).strict()
3652
3860
  }).strict(),
3653
- repository: z18.object({
3654
- full_name: z18.string().min(1),
3655
- id: z18.number().int().positive()
3861
+ repository: z21.object({
3862
+ full_name: z21.string().min(1),
3863
+ id: z21.number().int().positive()
3656
3864
  }).strict()
3657
3865
  }).strict();
3658
- var issueOutcomeSchema = z18.object({
3659
- action: z18.enum(["opened", "closed", "reopened"]),
3660
- issue: z18.object({
3661
- body: z18.string().nullable().optional(),
3662
- closed_at: z18.string().nullable().optional(),
3663
- created_at: z18.string(),
3664
- id: z18.number().int().positive(),
3665
- number: z18.number().int().positive(),
3866
+ var issueOutcomeSchema = z21.object({
3867
+ action: z21.enum(["opened", "closed", "reopened"]),
3868
+ issue: z21.object({
3869
+ body: z21.string().nullable().optional(),
3870
+ closed_at: z21.string().nullable().optional(),
3871
+ created_at: z21.string(),
3872
+ id: z21.number().int().positive(),
3873
+ number: z21.number().int().positive(),
3666
3874
  state_reason: githubIssueStateReasonSchema.nullable().optional(),
3667
- updated_at: z18.string(),
3668
- user: z18.object({ login: z18.string().min(1) }).passthrough()
3875
+ updated_at: z21.string(),
3876
+ user: z21.object({ login: z21.string().min(1) }).passthrough()
3669
3877
  }).passthrough(),
3670
- repository: z18.object({
3671
- full_name: z18.string().min(1),
3672
- id: z18.number().int().positive()
3878
+ repository: z21.object({
3879
+ full_name: z21.string().min(1),
3880
+ id: z21.number().int().positive()
3673
3881
  }).passthrough()
3674
3882
  }).passthrough().transform(
3675
3883
  (provider) => canonicalIssueOutcomeSchema.parse({
@@ -3690,7 +3898,7 @@ var issueOutcomeSchema = z18.object({
3690
3898
  }
3691
3899
  })
3692
3900
  );
3693
- var issueLifecycleActionSchema = z18.object({ action: z18.string() }).passthrough();
3901
+ var issueLifecycleActionSchema = z21.object({ action: z21.string() }).passthrough();
3694
3902
  function timestamp2(value) {
3695
3903
  if (!value) return void 0;
3696
3904
  const parsed = new Date(value);
@@ -3734,21 +3942,21 @@ function normalizeGitHubIssueOutcome(args) {
3734
3942
  updatedAt
3735
3943
  };
3736
3944
  }
3737
- var canonicalIssueConversationSchema = z18.object({
3738
- issue: z18.object({
3739
- body: z18.string().nullable().optional(),
3740
- id: z18.number().int().positive(),
3741
- user: z18.object({ login: z18.string().min(1) }).strict()
3945
+ var canonicalIssueConversationSchema = z21.object({
3946
+ issue: z21.object({
3947
+ body: z21.string().nullable().optional(),
3948
+ id: z21.number().int().positive(),
3949
+ user: z21.object({ login: z21.string().min(1) }).strict()
3742
3950
  }).strict(),
3743
- sender: z18.object({ login: z18.string().min(1) }).strict().optional()
3951
+ sender: z21.object({ login: z21.string().min(1) }).strict().optional()
3744
3952
  }).strict();
3745
- var issueConversationSchema = z18.object({
3746
- issue: z18.object({
3747
- body: z18.string().nullable().optional(),
3748
- id: z18.number().int().positive(),
3749
- user: z18.object({ login: z18.string().min(1) }).passthrough()
3953
+ var issueConversationSchema = z21.object({
3954
+ issue: z21.object({
3955
+ body: z21.string().nullable().optional(),
3956
+ id: z21.number().int().positive(),
3957
+ user: z21.object({ login: z21.string().min(1) }).passthrough()
3750
3958
  }).passthrough(),
3751
- sender: z18.object({ login: z18.string().min(1) }).passthrough().optional()
3959
+ sender: z21.object({ login: z21.string().min(1) }).passthrough().optional()
3752
3960
  }).passthrough().transform(
3753
3961
  (provider) => canonicalIssueConversationSchema.parse({
3754
3962
  issue: {
@@ -3775,43 +3983,43 @@ function normalizeGitHubIssueConversations(args) {
3775
3983
  }
3776
3984
 
3777
3985
  // src/webhooks/pull-request-outcome.ts
3778
- import { z as z19 } from "zod";
3779
- var canonicalPullRequestOutcomeSchema = z19.object({
3780
- action: z19.enum(["opened", "closed", "reopened"]),
3781
- pull_request: z19.object({
3782
- body: z19.string().nullable().optional(),
3783
- closed_at: z19.string().nullable().optional(),
3784
- created_at: z19.string(),
3785
- id: z19.number().int().positive(),
3786
- merged: z19.boolean(),
3787
- merged_at: z19.string().nullable().optional(),
3788
- number: z19.number().int().positive(),
3789
- title: z19.string().min(1).optional(),
3790
- updated_at: z19.string(),
3791
- user: z19.object({ login: z19.string().min(1) }).strict()
3986
+ import { z as z22 } from "zod";
3987
+ var canonicalPullRequestOutcomeSchema = z22.object({
3988
+ action: z22.enum(["opened", "closed", "reopened"]),
3989
+ pull_request: z22.object({
3990
+ body: z22.string().nullable().optional(),
3991
+ closed_at: z22.string().nullable().optional(),
3992
+ created_at: z22.string(),
3993
+ id: z22.number().int().positive(),
3994
+ merged: z22.boolean(),
3995
+ merged_at: z22.string().nullable().optional(),
3996
+ number: z22.number().int().positive(),
3997
+ title: z22.string().min(1).optional(),
3998
+ updated_at: z22.string(),
3999
+ user: z22.object({ login: z22.string().min(1) }).strict()
3792
4000
  }).strict(),
3793
- repository: z19.object({
3794
- full_name: z19.string().min(1),
3795
- id: z19.number().int().positive()
4001
+ repository: z22.object({
4002
+ full_name: z22.string().min(1),
4003
+ id: z22.number().int().positive()
3796
4004
  }).strict()
3797
4005
  }).strict();
3798
- var pullRequestOutcomeSchema = z19.object({
3799
- action: z19.enum(["opened", "closed", "reopened"]),
3800
- pull_request: z19.object({
3801
- body: z19.string().nullable().optional(),
3802
- closed_at: z19.string().nullable().optional(),
3803
- created_at: z19.string(),
3804
- id: z19.number().int().positive(),
3805
- merged: z19.boolean(),
3806
- merged_at: z19.string().nullable().optional(),
3807
- number: z19.number().int().positive(),
3808
- title: z19.string().min(1).optional(),
3809
- updated_at: z19.string(),
3810
- user: z19.object({ login: z19.string().min(1) }).passthrough()
4006
+ var pullRequestOutcomeSchema = z22.object({
4007
+ action: z22.enum(["opened", "closed", "reopened"]),
4008
+ pull_request: z22.object({
4009
+ body: z22.string().nullable().optional(),
4010
+ closed_at: z22.string().nullable().optional(),
4011
+ created_at: z22.string(),
4012
+ id: z22.number().int().positive(),
4013
+ merged: z22.boolean(),
4014
+ merged_at: z22.string().nullable().optional(),
4015
+ number: z22.number().int().positive(),
4016
+ title: z22.string().min(1).optional(),
4017
+ updated_at: z22.string(),
4018
+ user: z22.object({ login: z22.string().min(1) }).passthrough()
3811
4019
  }).passthrough(),
3812
- repository: z19.object({
3813
- full_name: z19.string().min(1),
3814
- id: z19.number().int().positive()
4020
+ repository: z22.object({
4021
+ full_name: z22.string().min(1),
4022
+ id: z22.number().int().positive()
3815
4023
  }).passthrough()
3816
4024
  }).passthrough().transform(
3817
4025
  (provider) => canonicalPullRequestOutcomeSchema.parse({
@@ -3834,24 +4042,24 @@ var pullRequestOutcomeSchema = z19.object({
3834
4042
  }
3835
4043
  })
3836
4044
  );
3837
- var pullRequestLifecycleActionSchema = z19.object({ action: z19.string() }).passthrough();
3838
- var canonicalPullRequestConversationSchema = z19.object({
3839
- pull_request: z19.object({
3840
- body: z19.string().nullable().optional(),
3841
- id: z19.number().int().positive(),
3842
- user: z19.object({ login: z19.string().min(1) }).strict()
4045
+ var pullRequestLifecycleActionSchema = z22.object({ action: z22.string() }).passthrough();
4046
+ var canonicalPullRequestConversationSchema = z22.object({
4047
+ pull_request: z22.object({
4048
+ body: z22.string().nullable().optional(),
4049
+ id: z22.number().int().positive(),
4050
+ user: z22.object({ login: z22.string().min(1) }).strict()
3843
4051
  }).strict(),
3844
- repository: z19.object({ full_name: z19.string().min(1) }).strict(),
3845
- sender: z19.object({ login: z19.string().min(1) }).strict()
4052
+ repository: z22.object({ full_name: z22.string().min(1) }).strict(),
4053
+ sender: z22.object({ login: z22.string().min(1) }).strict()
3846
4054
  }).strict();
3847
- var pullRequestConversationSchema = z19.object({
3848
- pull_request: z19.object({
3849
- body: z19.string().nullable().optional(),
3850
- id: z19.number().int().positive(),
3851
- user: z19.object({ login: z19.string().min(1) }).passthrough()
4055
+ var pullRequestConversationSchema = z22.object({
4056
+ pull_request: z22.object({
4057
+ body: z22.string().nullable().optional(),
4058
+ id: z22.number().int().positive(),
4059
+ user: z22.object({ login: z22.string().min(1) }).passthrough()
3852
4060
  }).passthrough(),
3853
- repository: z19.object({ full_name: z19.string().min(1) }).passthrough(),
3854
- sender: z19.object({ login: z19.string().min(1) }).passthrough()
4061
+ repository: z22.object({ full_name: z22.string().min(1) }).passthrough(),
4062
+ sender: z22.object({ login: z22.string().min(1) }).passthrough()
3855
4063
  }).passthrough().transform(
3856
4064
  (provider) => canonicalPullRequestConversationSchema.parse({
3857
4065
  pull_request: {
@@ -3938,20 +4146,20 @@ function normalizeGitHubPullRequestLinkedIssues(args) {
3938
4146
  }
3939
4147
 
3940
4148
  // src/webhooks/merge-conflict.ts
3941
- import { z as z20 } from "zod";
4149
+ import { z as z23 } from "zod";
3942
4150
  var EVENT_TYPE = "pull_request.merge_conflict";
3943
4151
  var CLOSED_EVENT_TYPES = /* @__PURE__ */ new Set([
3944
4152
  "pull_request.closed_unmerged",
3945
4153
  "pull_request.merged"
3946
4154
  ]);
3947
- var pullRequestSchema3 = z20.object({
3948
- base: z20.object({ ref: z20.string().min(1) }),
3949
- number: z20.number().int().positive().optional(),
3950
- head: z20.object({ sha: z20.string().min(1) }),
3951
- html_url: z20.string().min(1).optional(),
3952
- mergeable: z20.boolean().nullable().optional(),
3953
- mergeable_state: z20.string().optional(),
3954
- state: z20.string()
4155
+ var pullRequestSchema3 = z23.object({
4156
+ base: z23.object({ ref: z23.string().min(1) }),
4157
+ number: z23.number().int().positive().optional(),
4158
+ head: z23.object({ sha: z23.string().min(1) }),
4159
+ html_url: z23.string().min(1).optional(),
4160
+ mergeable: z23.boolean().nullable().optional(),
4161
+ mergeable_state: z23.string().optional(),
4162
+ state: z23.string()
3955
4163
  });
3956
4164
  function gitHubMergeConflictEvents(input) {
3957
4165
  const { conflict } = input;
@@ -3991,7 +4199,7 @@ async function hasMatch(hasMatchEvent, ref) {
3991
4199
  return false;
3992
4200
  }
3993
4201
  function deliveredPullRequest(payload, ref) {
3994
- const parsed = z20.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
4202
+ const parsed = z23.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
3995
4203
  const pullRequest = parsed.success ? parsed.data.pull_request : void 0;
3996
4204
  return pullRequest?.number === ref.number && typeof pullRequest.mergeable === "boolean" ? pullRequest : void 0;
3997
4205
  }
@@ -4029,10 +4237,10 @@ async function loadGitHubMergeConflictEvents(args) {
4029
4237
  }
4030
4238
 
4031
4239
  // src/webhooks/pull-request-ready.ts
4032
- import { z as z22 } from "zod";
4240
+ import { z as z25 } from "zod";
4033
4241
 
4034
4242
  // src/webhooks/installation-requests.ts
4035
- import { z as z21 } from "zod";
4243
+ import { z as z24 } from "zod";
4036
4244
  function splitRepository(fullName, label) {
4037
4245
  const [owner, name, ...extra] = fullName.split("/");
4038
4246
  if (!owner || !name || extra.length > 0) {
@@ -4093,9 +4301,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
4093
4301
  }
4094
4302
  );
4095
4303
  }
4096
- var repositoryPermissionSchema = z21.object({
4097
- permission: z21.string().min(1),
4098
- role_name: z21.string().optional()
4304
+ var repositoryPermissionSchema = z24.object({
4305
+ permission: z24.string().min(1),
4306
+ role_name: z24.string().optional()
4099
4307
  });
4100
4308
  var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
4101
4309
  async function loadRepositoryRole(env, cache, target) {
@@ -4125,18 +4333,18 @@ async function loadRepositoryRole(env, cache, target) {
4125
4333
  }
4126
4334
  );
4127
4335
  }
4128
- var pullRequestSchema4 = z21.object({
4129
- draft: z21.boolean().optional(),
4130
- html_url: z21.string().url(),
4131
- mergeable_state: z21.string().nullable().optional(),
4132
- merged: z21.boolean(),
4133
- state: z21.enum(["open", "closed"]),
4134
- title: z21.string()
4336
+ var pullRequestSchema4 = z24.object({
4337
+ draft: z24.boolean().optional(),
4338
+ html_url: z24.string().url(),
4339
+ mergeable_state: z24.string().nullable().optional(),
4340
+ merged: z24.boolean(),
4341
+ state: z24.enum(["open", "closed"]),
4342
+ title: z24.string()
4135
4343
  });
4136
- var reviewsSchema = z21.array(
4137
- z21.object({
4138
- state: z21.string(),
4139
- user: z21.object({ login: z21.string() }).nullable()
4344
+ var reviewsSchema = z24.array(
4345
+ z24.object({
4346
+ state: z24.string(),
4347
+ user: z24.object({ login: z24.string() }).nullable()
4140
4348
  })
4141
4349
  );
4142
4350
  async function loadPullRequestMergeState(env, pullRequest) {
@@ -4201,10 +4409,10 @@ var READY_ACTIONS = {
4201
4409
  ]),
4202
4410
  pull_request_review: /* @__PURE__ */ new Set(["dismissed", "submitted"])
4203
4411
  };
4204
- var pullRequestWebhookSchema = z22.object({
4205
- action: z22.string(),
4206
- pull_request: z22.object({ number: z22.number().int().positive() }),
4207
- repository: z22.object({ full_name: z22.string().min(1) })
4412
+ var pullRequestWebhookSchema = z25.object({
4413
+ action: z25.string(),
4414
+ pull_request: z25.object({ number: z25.number().int().positive() }),
4415
+ repository: z25.object({ full_name: z25.string().min(1) })
4208
4416
  });
4209
4417
  function pullRequestReadyTargets(eventName, body) {
4210
4418
  if (eventName === "check_suite") return checkSuitePullRequests(body);
@@ -4299,7 +4507,7 @@ async function syncGitHubPullRequestReadyNotices(args) {
4299
4507
  }
4300
4508
 
4301
4509
  // src/webhooks/pull-request-match-data.ts
4302
- import { z as z23 } from "zod";
4510
+ import { z as z26 } from "zod";
4303
4511
  var LOOKUPS_BY_MATCH_KEY = {
4304
4512
  authors: ["authors"],
4305
4513
  openerEmail: ["opener"],
@@ -4307,16 +4515,16 @@ var LOOKUPS_BY_MATCH_KEY = {
4307
4515
  openerUsername: ["opener"]
4308
4516
  };
4309
4517
  var ALL_LOOKUPS = ["authors", "opener", "openerRole"];
4310
- var lookupDataSchema = z23.object({
4311
- authors: z23.array(z23.string().min(1)).min(1).optional(),
4312
- openerRole: z23.string().min(1).optional(),
4313
- openerUsername: z23.string().min(1).optional()
4518
+ var lookupDataSchema = z26.object({
4519
+ authors: z26.array(z26.string().min(1)).min(1).optional(),
4520
+ openerRole: z26.string().min(1).optional(),
4521
+ openerUsername: z26.string().min(1).optional()
4314
4522
  }).strict();
4315
4523
  function lookupData(input) {
4316
4524
  return lookupDataSchema.parse(definedValues(input));
4317
4525
  }
4318
- var webhookSchema = z23.object({
4319
- repository: z23.object({ full_name: z23.string().min(1) })
4526
+ var webhookSchema = z26.object({
4527
+ repository: z26.object({ full_name: z26.string().min(1) })
4320
4528
  });
4321
4529
  function pullRequestNumbers(events) {
4322
4530
  const numbers = /* @__PURE__ */ new Map();
@@ -4459,7 +4667,7 @@ async function withGitHubPullRequestMatchData(args) {
4459
4667
  }
4460
4668
 
4461
4669
  // src/webhooks/pull-request-people.ts
4462
- import { z as z24 } from "zod";
4670
+ import { z as z27 } from "zod";
4463
4671
  var PEOPLE_EVENTS = /* @__PURE__ */ new Set([
4464
4672
  "pull_request.review.approved",
4465
4673
  "pull_request.merged"
@@ -4469,18 +4677,18 @@ var PAGE_SIZE = 100;
4469
4677
  var MAX_PAGES = 3;
4470
4678
  var CO_AUTHOR_TRAILER = /^co-authored-by:[^<\n]*<([^>\s]+@[^>\s]+)>\s*$/gim;
4471
4679
  var GITHUB_NOREPLY_EMAIL = /^(?:\d+\+)?(?<login>[^@+]+)@users\.noreply\.github\.com$/i;
4472
- var webhookSchema2 = z24.object({
4473
- pull_request: z24.object({
4474
- assignees: z24.array(z24.object({ login: z24.string().min(1) })).nullish(),
4475
- number: z24.number(),
4476
- user: z24.object({ login: z24.string().min(1) }).nullish()
4680
+ var webhookSchema2 = z27.object({
4681
+ pull_request: z27.object({
4682
+ assignees: z27.array(z27.object({ login: z27.string().min(1) })).nullish(),
4683
+ number: z27.number(),
4684
+ user: z27.object({ login: z27.string().min(1) }).nullish()
4477
4685
  }),
4478
- repository: z24.object({ full_name: z24.string().min(1) })
4686
+ repository: z27.object({ full_name: z27.string().min(1) })
4479
4687
  });
4480
- var commitPageSchema = z24.array(
4481
- z24.object({
4482
- author: z24.object({ login: z24.string().min(1) }).nullish(),
4483
- commit: z24.object({ message: z24.string() })
4688
+ var commitPageSchema = z27.array(
4689
+ z27.object({
4690
+ author: z27.object({ login: z27.string().min(1) }).nullish(),
4691
+ commit: z27.object({ message: z27.string() })
4484
4692
  })
4485
4693
  );
4486
4694
  function shareCommitPages(load) {
@@ -4625,10 +4833,10 @@ function webhookInstallationId(body) {
4625
4833
  }
4626
4834
  return parseInstallationId(installation.id);
4627
4835
  }
4628
- var feedbackTargetSchema = z25.object({
4629
- commentId: z25.number(),
4630
- commentKind: z25.enum(["conversation", "review"]),
4631
- repo: z25.string().min(1)
4836
+ var feedbackTargetSchema = z28.object({
4837
+ commentId: z28.number(),
4838
+ commentKind: z28.enum(["conversation", "review"]),
4839
+ repo: z28.string().min(1)
4632
4840
  });
4633
4841
  function pullRequestFeedbackTarget(events) {
4634
4842
  const event = events.find(
@@ -4781,6 +4989,7 @@ function createGitHubWebhookRoute(args) {
4781
4989
  appIdEnv: args.appIdEnv,
4782
4990
  body,
4783
4991
  installationIdEnv: args.installationIdEnv,
4992
+ ...args.loadGitHubIncidents ? { loadGitHubIncidents: args.loadGitHubIncidents } : void 0,
4784
4993
  loadPullRequestFacts: needsCheckSuitePullRequestFacts(checkSuiteMatchKeys),
4785
4994
  log: args.log,
4786
4995
  privateKeyEnv: args.privateKeyEnv
@@ -4910,18 +5119,18 @@ function gitHubResourceUrl(input) {
4910
5119
  }
4911
5120
 
4912
5121
  // src/pull-request-outcomes/commit-composition.ts
4913
- import { z as z26 } from "zod";
4914
- var canonicalCommitSchema = z26.object({
4915
- authorEmail: z26.string().nullable(),
4916
- authorLogin: z26.string().nullable()
5122
+ import { z as z29 } from "zod";
5123
+ var canonicalCommitSchema = z29.object({
5124
+ authorEmail: z29.string().nullable(),
5125
+ authorLogin: z29.string().nullable()
4917
5126
  }).strict();
4918
- var providerCommitSchema = z26.object({
4919
- author: z26.object({ login: z26.string() }).passthrough().nullable(),
4920
- commit: z26.object({
4921
- author: z26.object({ email: z26.string() }).passthrough().nullable()
5127
+ var providerCommitSchema = z29.object({
5128
+ author: z29.object({ login: z29.string() }).passthrough().nullable(),
5129
+ commit: z29.object({
5130
+ author: z29.object({ email: z29.string() }).passthrough().nullable()
4922
5131
  }).passthrough()
4923
5132
  }).passthrough();
4924
- var commitPageSchema2 = z26.array(providerCommitSchema).transform(
5133
+ var commitPageSchema2 = z29.array(providerCommitSchema).transform(
4925
5134
  (commits) => commits.map(
4926
5135
  (commit) => canonicalCommitSchema.parse({
4927
5136
  authorEmail: commit.commit.author?.email ?? null,
@@ -5990,6 +6199,13 @@ var GITHUB_BODY_WRITES = [
5990
6199
  operation: "github.pull.review.create",
5991
6200
  restPath: /^\/repos\/[^/]+\/[^/]+\/pulls\/[^/]+\/reviews$/
5992
6201
  },
6202
+ {
6203
+ denialMessage: `GitHub review thread replies must use the github_commentOnPullRequest tool with in_reply_to. ${CREATE_TOOL_ROUTING_GUIDANCE}`,
6204
+ graphqlField: "addPullRequestReviewThreadReply",
6205
+ method: "POST",
6206
+ operation: "github.pull.comment.create",
6207
+ restPath: /^\/repos\/[^/]+\/[^/]+\/pulls\/[^/]+\/comments\/[^/]+\/replies$/
6208
+ },
5993
6209
  {
5994
6210
  denialMessage: `GitHub issue updates must use the github_updateIssue tool, which owns requester attribution and the conversation footer. ${CREATE_TOOL_ROUTING_GUIDANCE}`,
5995
6211
  graphqlField: "updateIssue",
@@ -6229,6 +6445,7 @@ async function githubGrantForEgress(ctx) {
6229
6445
  }
6230
6446
 
6231
6447
  // src/plugin.ts
6448
+ var CHECK_SUITE_INCIDENT_WINDOW_MS = 60 * 60 * 1e3;
6232
6449
  function githubPlugin(options = {}) {
6233
6450
  const botNameEnv = options.botNameEnv ?? "GITHUB_APP_BOT_NAME";
6234
6451
  const botEmailEnv = options.botEmailEnv ?? "GITHUB_APP_BOT_EMAIL";
@@ -6433,6 +6650,10 @@ function githubPlugin(options = {}) {
6433
6650
  codeChanges: ctx.codeChanges,
6434
6651
  db: ctx.db,
6435
6652
  installationId: () => readEnv(installationIdEnv),
6653
+ loadGitHubIncidents: async () => await loadGitHubStatusIncidents(
6654
+ ctx.cache,
6655
+ CHECK_SUITE_INCIDENT_WINDOW_MS
6656
+ ),
6436
6657
  installationIdEnv,
6437
6658
  loadRepositoryRole: async (target) => await loadRepositoryRole(installationEnv, ctx.cache, target),
6438
6659
  loadGitHubLogin: async (identityId) => linkedGitHubLogin(