@sentry/junior-github 0.117.0 → 0.118.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
@@ -1,7 +1,8 @@
1
1
  import {
2
+ gitHubDeploymentSourceSubscribable,
2
3
  gitHubPullRequestSubscribable,
3
4
  normalizeGitHubResourceEvents
4
- } from "./chunk-JDNXIBCQ.js";
5
+ } from "./chunk-EPYBKNXS.js";
5
6
 
6
7
  // src/plugin.ts
7
8
  import {
@@ -274,6 +275,7 @@ var createIssueStateSchema = Type.Union([
274
275
  Type.Object(
275
276
  {
276
277
  createdAtMs: Type.Number(),
278
+ input: Type.Optional(createIssueInputSchema),
277
279
  number: Type.Number(),
278
280
  status: Type.Literal("completed"),
279
281
  url: Type.String()
@@ -283,6 +285,7 @@ var createIssueStateSchema = Type.Union([
283
285
  Type.Object(
284
286
  {
285
287
  createdAtMs: Type.Number(),
288
+ input: Type.Optional(createIssueInputSchema),
286
289
  status: Type.Literal("pending")
287
290
  },
288
291
  { additionalProperties: false }
@@ -434,6 +437,16 @@ async function createGitHubIssue(ctx, request) {
434
437
  url: issue.html_url
435
438
  };
436
439
  }
440
+ async function annotateIssue(ctx, input, result) {
441
+ const repo = parseRepo(input.repo);
442
+ await ctx.annotations?.upsert({
443
+ kind: "resource_link",
444
+ key: `${repo.owner.toLowerCase()}/${repo.name.toLowerCase()}#${result.number}`,
445
+ label: `${repo.owner}/${repo.name}#${result.number}`,
446
+ url: result.url,
447
+ status: "open"
448
+ });
449
+ }
437
450
  function createGitHubIssueTool(ctx) {
438
451
  return definePluginTool({
439
452
  description: "Create a GitHub issue with a runtime-owned Junior conversation footer. Use this instead of shelling out to gh issue create when creating issues.",
@@ -453,10 +466,13 @@ function createGitHubIssueTool(ctx) {
453
466
  async () => {
454
467
  const state = createIssueState(await ctx.state.get(key));
455
468
  if (state?.status === "completed") {
456
- return gitHubIssueToolResult({
469
+ const completedInput = state.input ?? parsedInput;
470
+ const completedResult = {
457
471
  number: state.number,
458
472
  url: state.url
459
- });
473
+ };
474
+ await annotateIssue(ctx, completedInput, completedResult);
475
+ return gitHubIssueToolResult(completedResult);
460
476
  }
461
477
  if (state?.status === "pending") {
462
478
  throw new Error(
@@ -470,7 +486,8 @@ function createGitHubIssueTool(ctx) {
470
486
  );
471
487
  const pendingState = {
472
488
  status: "pending",
473
- createdAtMs: Date.now()
489
+ createdAtMs: Date.now(),
490
+ input: parsedInput
474
491
  };
475
492
  await ctx.state.set(
476
493
  key,
@@ -492,6 +509,7 @@ function createGitHubIssueTool(ctx) {
492
509
  { cause: error }
493
510
  );
494
511
  }
512
+ await annotateIssue(ctx, parsedInput, result);
495
513
  return gitHubIssueToolResult(result);
496
514
  } catch (error) {
497
515
  if (isEgressAuthRequired(error) || isDefinitiveGitHubIssueCreateRejection(error)) {
@@ -505,20 +523,216 @@ function createGitHubIssueTool(ctx) {
505
523
  });
506
524
  }
507
525
 
508
- // src/tools/create-pull-request.ts
526
+ // src/tools/get-deployment.ts
509
527
  import {
510
528
  definePluginTool as definePluginTool2,
511
- EgressAuthRequired as EgressAuthRequired2,
512
529
  PluginToolInputError as PluginToolInputError3,
513
- pluginToolResultSchema as pluginToolResultSchema2
530
+ pluginToolResultSchema as pluginToolResultSchema2,
531
+ subscribableResourceSchema
532
+ } from "@sentry/junior-plugin-api";
533
+ import { z as z2 } from "zod";
534
+ var commitShaSchema = z2.string().regex(/^[0-9a-f]{40}$/i);
535
+ var inputSchema = z2.object({
536
+ repo: z2.string().describe('Repository in "owner/name" format.'),
537
+ commitSha: commitShaSchema.describe(
538
+ "Full 40-character Git commit SHA recorded by the deployment."
539
+ ),
540
+ environment: z2.string().trim().min(1).describe('GitHub deployment environment, such as "Production".')
541
+ }).strict();
542
+ var statusSchema = z2.object({
543
+ createdAt: z2.string(),
544
+ creator: z2.string().nullable(),
545
+ description: z2.string().nullable(),
546
+ environmentUrl: z2.string().nullable(),
547
+ id: z2.number(),
548
+ logUrl: z2.string().nullable(),
549
+ state: z2.string()
550
+ }).strict();
551
+ var deploymentSchema = z2.object({
552
+ createdAt: z2.string(),
553
+ creator: z2.string().nullable(),
554
+ description: z2.string().nullable(),
555
+ environment: z2.string(),
556
+ id: z2.number(),
557
+ latestStatus: statusSchema.nullable(),
558
+ ref: z2.string(),
559
+ sha: commitShaSchema,
560
+ updatedAt: z2.string(),
561
+ url: z2.string()
562
+ }).strict();
563
+ var deploymentSourceSchema = z2.object({
564
+ commitSha: commitShaSchema,
565
+ deployment: deploymentSchema.nullable(),
566
+ environment: z2.string(),
567
+ repo: z2.string(),
568
+ subscribable: subscribableResourceSchema.optional()
569
+ }).strict();
570
+ var outputSchema = pluginToolResultSchema2.extend({
571
+ data: deploymentSourceSchema,
572
+ ok: z2.literal(true),
573
+ status: z2.literal("success"),
574
+ target: z2.literal("getDeployment"),
575
+ ...deploymentSourceSchema.shape
576
+ }).strict();
577
+ var providerCreatorSchema = z2.object({ login: z2.string() }).passthrough().nullable();
578
+ var providerDeploymentSchema = z2.object({
579
+ created_at: z2.string(),
580
+ creator: providerCreatorSchema,
581
+ description: z2.string().nullable(),
582
+ environment: z2.string(),
583
+ id: z2.number(),
584
+ ref: z2.string(),
585
+ sha: commitShaSchema,
586
+ updated_at: z2.string()
587
+ }).passthrough();
588
+ var providerStatusSchema = z2.object({
589
+ created_at: z2.string(),
590
+ creator: providerCreatorSchema,
591
+ description: z2.string().nullable().optional(),
592
+ environment_url: z2.string().nullable().optional(),
593
+ id: z2.number(),
594
+ log_url: z2.string().nullable().optional(),
595
+ state: z2.string()
596
+ }).passthrough();
597
+ function parseRepo2(value) {
598
+ const parts = value.split("/").map((part) => part.trim());
599
+ if (parts.length !== 2 || !parts[0] || !parts[1]) {
600
+ throw new PluginToolInputError3('repo must use "owner/name" format');
601
+ }
602
+ return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
603
+ }
604
+ async function readJson(response) {
605
+ const text2 = await response.text();
606
+ if (!text2) return void 0;
607
+ try {
608
+ return JSON.parse(text2);
609
+ } catch {
610
+ return text2;
611
+ }
612
+ }
613
+ function throwLookupError(target, status, body) {
614
+ const message = `GitHub ${target} lookup failed with HTTP ${status}`;
615
+ const hasValidationErrors = body !== null && typeof body === "object" && !Array.isArray(body) && Array.isArray(body.errors) && body.errors.length > 0;
616
+ if (target === "deployment" && (status === 404 || status === 422 && hasValidationErrors)) {
617
+ throw new PluginToolInputError3(message);
618
+ }
619
+ throw new Error(message);
620
+ }
621
+ function repositoryUrl(repo, path) {
622
+ return `https://api.github.com/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}/${path}`;
623
+ }
624
+ function createGitHubGetDeploymentTool(ctx) {
625
+ return definePluginTool2({
626
+ description: "Get the latest GitHub deployment and status for an exact repository, environment, and full commit SHA. The result remains subscribable when no deployment exists yet, so use it before waiting for a deployment outcome.",
627
+ inputSchema,
628
+ outputSchema,
629
+ async execute(input) {
630
+ const repo = parseRepo2(input.repo);
631
+ const commitSha = input.commitSha.toLowerCase();
632
+ const deploymentsUrl = new URL(repositoryUrl(repo, "deployments"));
633
+ deploymentsUrl.searchParams.set("sha", commitSha);
634
+ deploymentsUrl.searchParams.set("environment", input.environment);
635
+ deploymentsUrl.searchParams.set("per_page", "1");
636
+ const deploymentsResponse = await ctx.egress.fetch({
637
+ provider: "github",
638
+ operation: "github.deployment.list",
639
+ request: new Request(deploymentsUrl, {
640
+ headers: {
641
+ Accept: "application/vnd.github+json",
642
+ "X-GitHub-Api-Version": "2022-11-28"
643
+ }
644
+ })
645
+ });
646
+ const deploymentsBody = await readJson(deploymentsResponse);
647
+ if (!deploymentsResponse.ok) {
648
+ throwLookupError(
649
+ "deployment",
650
+ deploymentsResponse.status,
651
+ deploymentsBody
652
+ );
653
+ }
654
+ const providerDeployment = z2.array(providerDeploymentSchema).parse(deploymentsBody)[0];
655
+ let deployment = null;
656
+ if (providerDeployment) {
657
+ const statusesResponse = await ctx.egress.fetch({
658
+ provider: "github",
659
+ operation: "github.deployment-status.list",
660
+ request: new Request(
661
+ `${repositoryUrl(repo, `deployments/${providerDeployment.id}/statuses`)}?per_page=1`,
662
+ {
663
+ headers: {
664
+ Accept: "application/vnd.github+json",
665
+ "X-GitHub-Api-Version": "2022-11-28"
666
+ }
667
+ }
668
+ )
669
+ });
670
+ const statusesBody = await readJson(statusesResponse);
671
+ if (!statusesResponse.ok) {
672
+ throwLookupError(
673
+ "deployment status",
674
+ statusesResponse.status,
675
+ statusesBody
676
+ );
677
+ }
678
+ const providerStatus = z2.array(providerStatusSchema).parse(statusesBody)[0];
679
+ deployment = {
680
+ createdAt: providerDeployment.created_at,
681
+ creator: providerDeployment.creator?.login ?? null,
682
+ description: providerDeployment.description,
683
+ environment: providerDeployment.environment,
684
+ id: providerDeployment.id,
685
+ latestStatus: providerStatus ? {
686
+ createdAt: providerStatus.created_at,
687
+ creator: providerStatus.creator?.login ?? null,
688
+ description: providerStatus.description ?? null,
689
+ environmentUrl: providerStatus.environment_url ?? null,
690
+ id: providerStatus.id,
691
+ logUrl: providerStatus.log_url ?? null,
692
+ state: providerStatus.state
693
+ } : null,
694
+ ref: providerDeployment.ref,
695
+ sha: providerDeployment.sha.toLowerCase(),
696
+ updatedAt: providerDeployment.updated_at,
697
+ url: `https://github.com/${repo.ref}/deployments`
698
+ };
699
+ }
700
+ const subscribable = gitHubDeploymentSourceSubscribable({
701
+ commitSha,
702
+ environment: input.environment,
703
+ repo: repo.ref
704
+ });
705
+ const data = {
706
+ commitSha,
707
+ deployment,
708
+ environment: input.environment,
709
+ repo: repo.ref,
710
+ ...subscribable ? { subscribable } : {}
711
+ };
712
+ return {
713
+ data,
714
+ ok: true,
715
+ status: "success",
716
+ target: "getDeployment",
717
+ ...data
718
+ };
719
+ }
720
+ });
721
+ }
722
+
723
+ // src/tools/create-pull-request.ts
724
+ import {
725
+ definePluginTool as definePluginTool3,
726
+ EgressAuthRequired as EgressAuthRequired2,
727
+ PluginToolInputError as PluginToolInputError4,
728
+ pluginToolResultSchema as pluginToolResultSchema3
514
729
  } from "@sentry/junior-plugin-api";
515
730
  import { Type as Type2 } from "@sinclair/typebox";
516
731
  import { Value as Value2 } from "@sinclair/typebox/value";
517
- import { z as z2 } from "zod";
518
- import { subscribableResourceSchema } from "@sentry/junior-plugin-api";
732
+ import { z as z3 } from "zod";
733
+ import { subscribableResourceSchema as subscribableResourceSchema2 } from "@sentry/junior-plugin-api";
519
734
  var GITHUB_PULL_REQUEST_CREATE_IDEMPOTENCY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
520
735
  var GITHUB_PULL_REQUEST_CREATE_LOCK_TTL_MS = 6e4;
521
- var RESOURCE_LINK_LABEL_MAX_LENGTH = 256;
522
736
  var GitHubPullRequestCreateRejectedError = class extends Error {
523
737
  status;
524
738
  constructor(message, status) {
@@ -554,13 +768,13 @@ var createPullRequestInputSchema = Type2.Object(
554
768
  },
555
769
  { additionalProperties: false }
556
770
  );
557
- var createPullRequestToolInputSchema = z2.object({
558
- repo: z2.string().describe('Repository in "owner/name" format.'),
559
- title: z2.string().describe("Pull request title."),
560
- head: z2.string().describe("Head branch or owner:branch ref."),
561
- base: z2.string().describe("Base branch."),
562
- body: z2.string().describe("Pull request body. Junior appends the conversation footer.").optional(),
563
- draft: z2.boolean().describe("Whether to open the pull request as a draft.").optional()
771
+ var createPullRequestToolInputSchema = z3.object({
772
+ repo: z3.string().describe('Repository in "owner/name" format.'),
773
+ title: z3.string().describe("Pull request title."),
774
+ head: z3.string().describe("Head branch or owner:branch ref."),
775
+ base: z3.string().describe("Base branch."),
776
+ body: z3.string().describe("Pull request body. Junior appends the conversation footer.").optional(),
777
+ draft: z3.boolean().describe("Whether to open the pull request as a draft.").optional()
564
778
  }).strict();
565
779
  var createPullRequestStateSchema = Type2.Union([
566
780
  Type2.Object(
@@ -582,40 +796,40 @@ var createPullRequestStateSchema = Type2.Union([
582
796
  { additionalProperties: false }
583
797
  )
584
798
  ]);
585
- var gitHubPullRequestDataSchema = z2.object({
586
- number: z2.number(),
587
- url: z2.string(),
588
- subscribable: subscribableResourceSchema.optional()
799
+ var gitHubPullRequestDataSchema = z3.object({
800
+ number: z3.number(),
801
+ url: z3.string(),
802
+ subscribable: subscribableResourceSchema2.optional()
589
803
  });
590
- var gitHubPullRequestOutputSchema = pluginToolResultSchema2.extend({
591
- ok: z2.literal(true),
592
- status: z2.literal("success"),
593
- target: z2.literal("createPullRequest"),
804
+ var gitHubPullRequestOutputSchema = pluginToolResultSchema3.extend({
805
+ ok: z3.literal(true),
806
+ status: z3.literal("success"),
807
+ target: z3.literal("createPullRequest"),
594
808
  data: gitHubPullRequestDataSchema,
595
- number: z2.number(),
596
- url: z2.string(),
597
- subscribable: subscribableResourceSchema.optional()
809
+ number: z3.number(),
810
+ url: z3.string(),
811
+ subscribable: subscribableResourceSchema2.optional()
598
812
  });
599
813
  function parseCreatePullRequestInput(input) {
600
814
  try {
601
815
  return Value2.Parse(createPullRequestInputSchema, input);
602
816
  } catch (error) {
603
- throw new PluginToolInputError3("Invalid GitHub createPullRequest input.", {
817
+ throw new PluginToolInputError4("Invalid GitHub createPullRequest input.", {
604
818
  cause: error
605
819
  });
606
820
  }
607
821
  }
608
822
  function nonEmptyString3(value, name) {
609
823
  if (!value?.trim()) {
610
- throw new PluginToolInputError3(`${name} is required`);
824
+ throw new PluginToolInputError4(`${name} is required`);
611
825
  }
612
826
  return value.trim();
613
827
  }
614
- function parseRepo2(value) {
828
+ function parseRepo3(value) {
615
829
  const repo = nonEmptyString3(value, "repo");
616
830
  const parts = repo.split("/");
617
831
  if (parts.length !== 2 || !parts[0]?.trim() || !parts[1]?.trim()) {
618
- throw new PluginToolInputError3('repo must use "owner/name" format');
832
+ throw new PluginToolInputError4('repo must use "owner/name" format');
619
833
  }
620
834
  return {
621
835
  owner: parts[0].trim(),
@@ -685,7 +899,7 @@ function isDefinitiveGitHubPullRequestCreateRejection(error) {
685
899
  return [400, 401, 404, 410, 422].includes(error.status);
686
900
  }
687
901
  function createGitHubPullRequestRequest(conversationId, input, actor, dashboardUrl) {
688
- const repo = parseRepo2(input.repo);
902
+ const repo = parseRepo3(input.repo);
689
903
  const payload = {
690
904
  title: nonEmptyString3(input.title, "title"),
691
905
  head: nonEmptyString3(input.head, "head"),
@@ -744,7 +958,7 @@ async function createGitHubPullRequest(ctx, request) {
744
958
  };
745
959
  }
746
960
  function gitHubPullRequestToolResult(input, result) {
747
- const repo = parseRepo2(input.repo);
961
+ const repo = parseRepo3(input.repo);
748
962
  const subscribable = gitHubPullRequestSubscribable({
749
963
  number: result.number,
750
964
  repo: `${repo.owner}/${repo.name}`
@@ -752,15 +966,11 @@ function gitHubPullRequestToolResult(input, result) {
752
966
  return { ...result, ...subscribable ? { subscribable } : {} };
753
967
  }
754
968
  async function annotatePullRequest(ctx, input, result) {
755
- const repo = parseRepo2(input.repo);
756
- const label = `${repo.owner}/${repo.name} #${result.number}: ${nonEmptyString3(input.title, "title")}`.slice(
757
- 0,
758
- RESOURCE_LINK_LABEL_MAX_LENGTH
759
- );
969
+ const repo = parseRepo3(input.repo);
760
970
  await ctx.annotations?.upsert({
761
971
  kind: "resource_link",
762
972
  key: `${repo.owner.toLowerCase()}/${repo.name.toLowerCase()}#${result.number}`,
763
- label,
973
+ label: `${repo.owner}/${repo.name}#${result.number}`,
764
974
  url: result.url,
765
975
  status: input.draft ? "draft" : "open"
766
976
  });
@@ -776,7 +986,7 @@ function gitHubPullRequestStructuredResult(input, result) {
776
986
  };
777
987
  }
778
988
  function createGitHubPullRequestTool(ctx) {
779
- return definePluginTool2({
989
+ return definePluginTool3({
780
990
  description: "Create a GitHub pull request with a runtime-owned Junior conversation footer. Use this instead of shelling out to gh pr create when creating pull requests.",
781
991
  inputSchema: createPullRequestToolInputSchema,
782
992
  outputSchema: gitHubPullRequestOutputSchema,
@@ -857,42 +1067,42 @@ function createGitHubPullRequestTool(ctx) {
857
1067
 
858
1068
  // src/tools/get-pull-request.ts
859
1069
  import {
860
- definePluginTool as definePluginTool3,
861
- PluginToolInputError as PluginToolInputError4,
862
- pluginToolResultSchema as pluginToolResultSchema3
1070
+ definePluginTool as definePluginTool4,
1071
+ PluginToolInputError as PluginToolInputError5,
1072
+ pluginToolResultSchema as pluginToolResultSchema4
863
1073
  } from "@sentry/junior-plugin-api";
864
- import { z as z3 } from "zod";
865
- import { subscribableResourceSchema as subscribableResourceSchema2 } from "@sentry/junior-plugin-api";
866
- var inputSchema = z3.object({
867
- repo: z3.string().describe('Repository in "owner/name" format.'),
868
- number: z3.number().int().positive().describe("Pull request number.")
1074
+ import { z as z4 } from "zod";
1075
+ import { subscribableResourceSchema as subscribableResourceSchema3 } from "@sentry/junior-plugin-api";
1076
+ var inputSchema2 = z4.object({
1077
+ repo: z4.string().describe('Repository in "owner/name" format.'),
1078
+ number: z4.number().int().positive().describe("Pull request number.")
869
1079
  }).strict();
870
- var pullRequestSchema = z3.object({
871
- base: z3.string(),
872
- draft: z3.boolean(),
873
- head: z3.string(),
874
- merged: z3.boolean(),
875
- number: z3.number(),
876
- state: z3.string(),
877
- subscribable: subscribableResourceSchema2.optional(),
878
- title: z3.string(),
879
- url: z3.string()
1080
+ var pullRequestSchema = z4.object({
1081
+ base: z4.string(),
1082
+ draft: z4.boolean(),
1083
+ head: z4.string(),
1084
+ merged: z4.boolean(),
1085
+ number: z4.number(),
1086
+ state: z4.string(),
1087
+ subscribable: subscribableResourceSchema3.optional(),
1088
+ title: z4.string(),
1089
+ url: z4.string()
880
1090
  });
881
- var outputSchema = pluginToolResultSchema3.extend({
882
- ok: z3.literal(true),
883
- status: z3.literal("success"),
884
- target: z3.literal("getPullRequest"),
1091
+ var outputSchema2 = pluginToolResultSchema4.extend({
1092
+ ok: z4.literal(true),
1093
+ status: z4.literal("success"),
1094
+ target: z4.literal("getPullRequest"),
885
1095
  data: pullRequestSchema,
886
1096
  ...pullRequestSchema.shape
887
1097
  });
888
- function parseRepo3(value) {
1098
+ function parseRepo4(value) {
889
1099
  const parts = value.split("/").map((part) => part.trim());
890
1100
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
891
- throw new PluginToolInputError4('repo must use "owner/name" format');
1101
+ throw new PluginToolInputError5('repo must use "owner/name" format');
892
1102
  }
893
1103
  return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
894
1104
  }
895
- async function readJson(response) {
1105
+ async function readJson2(response) {
896
1106
  const text2 = await response.text();
897
1107
  if (!text2) return void 0;
898
1108
  try {
@@ -902,12 +1112,12 @@ async function readJson(response) {
902
1112
  }
903
1113
  }
904
1114
  function createGitHubGetPullRequestTool(ctx) {
905
- return definePluginTool3({
1115
+ return definePluginTool4({
906
1116
  description: "Get a GitHub pull request. Use this when an existing PR may need resource-event monitoring; the result includes a subscribable hint when GitHub webhooks are configured.",
907
- inputSchema,
908
- outputSchema,
1117
+ inputSchema: inputSchema2,
1118
+ outputSchema: outputSchema2,
909
1119
  async execute(input) {
910
- const repo = parseRepo3(input.repo);
1120
+ const repo = parseRepo4(input.repo);
911
1121
  const response = await ctx.egress.fetch({
912
1122
  provider: "github",
913
1123
  operation: "github.pull.get",
@@ -921,20 +1131,20 @@ function createGitHubGetPullRequestTool(ctx) {
921
1131
  }
922
1132
  )
923
1133
  });
924
- const parsed = await readJson(response);
1134
+ const parsed = await readJson2(response);
925
1135
  if (!response.ok)
926
1136
  throw new Error(
927
1137
  `GitHub pull request lookup failed with HTTP ${response.status}`
928
1138
  );
929
- const providerResult = z3.object({
930
- base: z3.object({ ref: z3.string() }),
931
- draft: z3.boolean(),
932
- head: z3.object({ ref: z3.string() }),
933
- html_url: z3.string(),
934
- merged: z3.boolean().optional().default(false),
935
- number: z3.number(),
936
- state: z3.string(),
937
- title: z3.string()
1139
+ const providerResult = z4.object({
1140
+ base: z4.object({ ref: z4.string() }),
1141
+ draft: z4.boolean(),
1142
+ head: z4.object({ ref: z4.string() }),
1143
+ html_url: z4.string(),
1144
+ merged: z4.boolean().optional().default(false),
1145
+ number: z4.number(),
1146
+ state: z4.string(),
1147
+ title: z4.string()
938
1148
  }).parse(parsed);
939
1149
  const subscribable = gitHubPullRequestSubscribable({
940
1150
  number: providerResult.number,
@@ -964,56 +1174,56 @@ function createGitHubGetPullRequestTool(ctx) {
964
1174
 
965
1175
  // src/tools/update-pull-request.ts
966
1176
  import {
967
- definePluginTool as definePluginTool4,
968
- PluginToolInputError as PluginToolInputError5,
969
- pluginToolResultSchema as pluginToolResultSchema4
1177
+ definePluginTool as definePluginTool5,
1178
+ PluginToolInputError as PluginToolInputError6,
1179
+ pluginToolResultSchema as pluginToolResultSchema5
970
1180
  } from "@sentry/junior-plugin-api";
971
- import { z as z4 } from "zod";
972
- import { subscribableResourceSchema as subscribableResourceSchema3 } from "@sentry/junior-plugin-api";
973
- var inputSchema2 = z4.object({
974
- repo: z4.string().describe('Repository in "owner/name" format.'),
975
- number: z4.number().int().positive().describe("Pull request number."),
976
- title: z4.string().trim().min(1).optional().describe("Replacement pull request title."),
977
- body: z4.string().optional().describe(
1181
+ import { z as z5 } from "zod";
1182
+ import { subscribableResourceSchema as subscribableResourceSchema4 } from "@sentry/junior-plugin-api";
1183
+ var inputSchema3 = z5.object({
1184
+ repo: z5.string().describe('Repository in "owner/name" format.'),
1185
+ number: z5.number().int().positive().describe("Pull request number."),
1186
+ title: z5.string().trim().min(1).optional().describe("Replacement pull request title."),
1187
+ body: z5.string().optional().describe(
978
1188
  "Replacement pull request body. Junior appends requester attribution and the conversation footer."
979
1189
  ),
980
- base: z4.string().trim().min(1).optional().describe("Replacement base branch."),
981
- state: z4.enum(["open", "closed"]).optional().describe("Replacement pull request state.")
1190
+ base: z5.string().trim().min(1).optional().describe("Replacement base branch."),
1191
+ state: z5.enum(["open", "closed"]).optional().describe("Replacement pull request state.")
982
1192
  }).strict().refine(
983
1193
  ({ title, body, base, state }) => title !== void 0 || body !== void 0 || base !== void 0 || state !== void 0,
984
1194
  { message: "At least one pull request field must be provided." }
985
1195
  );
986
- var pullRequestSchema2 = z4.object({
987
- base: z4.string(),
988
- body: z4.string().nullable(),
989
- draft: z4.boolean(),
990
- number: z4.number(),
991
- state: z4.string(),
992
- subscribable: subscribableResourceSchema3.optional(),
993
- title: z4.string(),
994
- url: z4.string()
1196
+ var pullRequestSchema2 = z5.object({
1197
+ base: z5.string(),
1198
+ body: z5.string().nullable(),
1199
+ draft: z5.boolean(),
1200
+ number: z5.number(),
1201
+ state: z5.string(),
1202
+ subscribable: subscribableResourceSchema4.optional(),
1203
+ title: z5.string(),
1204
+ url: z5.string()
995
1205
  });
996
- var outputSchema2 = pluginToolResultSchema4.extend({
997
- ok: z4.literal(true),
998
- status: z4.literal("success"),
999
- target: z4.literal("updatePullRequest"),
1206
+ var outputSchema3 = pluginToolResultSchema5.extend({
1207
+ ok: z5.literal(true),
1208
+ status: z5.literal("success"),
1209
+ target: z5.literal("updatePullRequest"),
1000
1210
  data: pullRequestSchema2,
1001
1211
  ...pullRequestSchema2.shape
1002
1212
  });
1003
1213
  function nonEmptyString4(value, name) {
1004
1214
  if (!value?.trim()) {
1005
- throw new PluginToolInputError5(`${name} is required`);
1215
+ throw new PluginToolInputError6(`${name} is required`);
1006
1216
  }
1007
1217
  return value.trim();
1008
1218
  }
1009
- function parseRepo4(value) {
1219
+ function parseRepo5(value) {
1010
1220
  const parts = value.split("/").map((part) => part.trim());
1011
1221
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
1012
- throw new PluginToolInputError5('repo must use "owner/name" format');
1222
+ throw new PluginToolInputError6('repo must use "owner/name" format');
1013
1223
  }
1014
1224
  return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
1015
1225
  }
1016
- async function readJson2(response) {
1226
+ async function readJson3(response) {
1017
1227
  const text2 = await response.text();
1018
1228
  if (!text2) return void 0;
1019
1229
  try {
@@ -1031,20 +1241,20 @@ function githubApiErrorMessage3(payload) {
1031
1241
  return "GitHub request failed";
1032
1242
  }
1033
1243
  function createGitHubUpdatePullRequestTool(ctx) {
1034
- return definePluginTool4({
1244
+ return definePluginTool5({
1035
1245
  description: "Update an existing GitHub pull request's title, body, base branch, or open/closed state. Use this instead of raw GitHub API calls when changing PR metadata.",
1036
- inputSchema: inputSchema2,
1037
- outputSchema: outputSchema2,
1246
+ inputSchema: inputSchema3,
1247
+ outputSchema: outputSchema3,
1038
1248
  async execute(input) {
1039
- const parsedInput = inputSchema2.safeParse(input);
1249
+ const parsedInput = inputSchema3.safeParse(input);
1040
1250
  if (!parsedInput.success) {
1041
- throw new PluginToolInputError5(
1251
+ throw new PluginToolInputError6(
1042
1252
  "Invalid GitHub updatePullRequest input.",
1043
1253
  { cause: parsedInput.error }
1044
1254
  );
1045
1255
  }
1046
1256
  const update = parsedInput.data;
1047
- const repo = parseRepo4(update.repo);
1257
+ const repo = parseRepo5(update.repo);
1048
1258
  const payload = {
1049
1259
  ...update.title !== void 0 ? { title: update.title } : {},
1050
1260
  ...update.body !== void 0 ? {
@@ -1073,20 +1283,20 @@ function createGitHubUpdatePullRequestTool(ctx) {
1073
1283
  }
1074
1284
  )
1075
1285
  });
1076
- const parsed = await readJson2(response);
1286
+ const parsed = await readJson3(response);
1077
1287
  if (!response.ok) {
1078
1288
  throw new Error(
1079
1289
  `GitHub pull request update failed with HTTP ${response.status}: ${githubApiErrorMessage3(parsed)}`
1080
1290
  );
1081
1291
  }
1082
- const providerResult = z4.object({
1083
- base: z4.object({ ref: z4.string() }),
1084
- body: z4.string().nullable().optional().default(null),
1085
- draft: z4.boolean(),
1086
- html_url: z4.string(),
1087
- number: z4.number(),
1088
- state: z4.string(),
1089
- title: z4.string()
1292
+ const providerResult = z5.object({
1293
+ base: z5.object({ ref: z5.string() }),
1294
+ body: z5.string().nullable().optional().default(null),
1295
+ draft: z5.boolean(),
1296
+ html_url: z5.string(),
1297
+ number: z5.number(),
1298
+ state: z5.string(),
1299
+ title: z5.string()
1090
1300
  }).parse(parsed);
1091
1301
  const subscribable = gitHubPullRequestSubscribable({
1092
1302
  number: providerResult.number,
@@ -1118,6 +1328,7 @@ function createGitHubTools(ctx) {
1118
1328
  return {
1119
1329
  createIssue: createGitHubIssueTool(ctx),
1120
1330
  createPullRequest: createGitHubPullRequestTool(ctx),
1331
+ getDeployment: createGitHubGetDeploymentTool(ctx),
1121
1332
  getPullRequest: createGitHubGetPullRequestTool(ctx),
1122
1333
  updatePullRequest: createGitHubUpdatePullRequestTool(ctx)
1123
1334
  };
@@ -1128,7 +1339,7 @@ import { createHmac, timingSafeEqual } from "crypto";
1128
1339
 
1129
1340
  // src/issue-outcomes/store.ts
1130
1341
  import { and, eq, lte, sql as sql2 } from "drizzle-orm";
1131
- import { z as z6 } from "zod";
1342
+ import { z as z7 } from "zod";
1132
1343
 
1133
1344
  // src/db/schema.ts
1134
1345
  import { sql } from "drizzle-orm";
@@ -1140,18 +1351,18 @@ import {
1140
1351
  text,
1141
1352
  timestamp
1142
1353
  } from "drizzle-orm/pg-core";
1143
- import { z as z5 } from "zod";
1144
- var githubPullRequestStateSchema = z5.enum([
1354
+ import { z as z6 } from "zod";
1355
+ var githubPullRequestStateSchema = z6.enum([
1145
1356
  "closed_unmerged",
1146
1357
  "merged",
1147
1358
  "open"
1148
1359
  ]);
1149
- var githubPullRequestCommitCompositionSchema = z5.enum([
1360
+ var githubPullRequestCommitCompositionSchema = z6.enum([
1150
1361
  "junior_only",
1151
1362
  "mixed"
1152
1363
  ]);
1153
- var githubIssueStateSchema = z5.enum(["closed", "open"]);
1154
- var githubIssueStateReasonSchema = z5.enum([
1364
+ var githubIssueStateSchema = z6.enum(["closed", "open"]);
1365
+ var githubIssueStateReasonSchema = z6.enum([
1155
1366
  "completed",
1156
1367
  "duplicate",
1157
1368
  "not_planned",
@@ -1220,21 +1431,21 @@ var juniorGitHubPullRequestIssues = pgTable(
1220
1431
  );
1221
1432
 
1222
1433
  // src/issue-outcomes/store.ts
1223
- var githubIssueOutcomeInputSchema = z6.object({
1224
- candidateOwned: z6.boolean(),
1225
- closedAt: z6.date().optional(),
1226
- issueId: z6.string().min(1),
1227
- number: z6.number().int().positive(),
1228
- openedAt: z6.date(),
1229
- repositoryFullName: z6.string().min(1),
1230
- repositoryId: z6.string().min(1),
1434
+ var githubIssueOutcomeInputSchema = z7.object({
1435
+ candidateOwned: z7.boolean(),
1436
+ closedAt: z7.date().optional(),
1437
+ issueId: z7.string().min(1),
1438
+ number: z7.number().int().positive(),
1439
+ openedAt: z7.date(),
1440
+ repositoryFullName: z7.string().min(1),
1441
+ repositoryId: z7.string().min(1),
1231
1442
  state: githubIssueStateSchema,
1232
1443
  stateReason: githubIssueStateReasonSchema.optional(),
1233
- updatedAt: z6.date()
1444
+ updatedAt: z7.date()
1234
1445
  }).strict();
1235
- var githubIssueConversationsInputSchema = z6.object({
1236
- conversationIds: z6.array(z6.string().min(1)).min(1),
1237
- issueId: z6.string().min(1)
1446
+ var githubIssueConversationsInputSchema = z7.object({
1447
+ conversationIds: z7.array(z7.string().min(1)).min(1),
1448
+ issueId: z7.string().min(1)
1238
1449
  }).strict();
1239
1450
  function projectionValues(input) {
1240
1451
  return {
@@ -1287,32 +1498,32 @@ async function recordGitHubIssueConversations(db, input) {
1287
1498
 
1288
1499
  // src/pull-request-outcomes/store.ts
1289
1500
  import { and as and2, eq as eq2, lte as lte2, sql as sql3 } from "drizzle-orm";
1290
- import { z as z7 } from "zod";
1291
- var githubPullRequestOutcomeInputSchema = z7.object({
1292
- candidateOwned: z7.boolean(),
1293
- closedAt: z7.date().optional(),
1501
+ import { z as z8 } from "zod";
1502
+ var githubPullRequestOutcomeInputSchema = z8.object({
1503
+ candidateOwned: z8.boolean(),
1504
+ closedAt: z8.date().optional(),
1294
1505
  commitComposition: githubPullRequestCommitCompositionSchema.optional(),
1295
- mergedAt: z7.date().optional(),
1296
- number: z7.number().int().positive(),
1297
- openedAt: z7.date(),
1298
- pullRequestId: z7.string().min(1),
1299
- repositoryFullName: z7.string().min(1),
1300
- repositoryId: z7.string().min(1),
1506
+ mergedAt: z8.date().optional(),
1507
+ number: z8.number().int().positive(),
1508
+ openedAt: z8.date(),
1509
+ pullRequestId: z8.string().min(1),
1510
+ repositoryFullName: z8.string().min(1),
1511
+ repositoryId: z8.string().min(1),
1301
1512
  state: githubPullRequestStateSchema,
1302
- updatedAt: z7.date()
1513
+ updatedAt: z8.date()
1303
1514
  }).strict();
1304
- var githubPullRequestConversationsInputSchema = z7.object({
1305
- conversationIds: z7.array(z7.string().min(1)).min(1),
1306
- pullRequestId: z7.string().min(1)
1515
+ var githubPullRequestConversationsInputSchema = z8.object({
1516
+ conversationIds: z8.array(z8.string().min(1)).min(1),
1517
+ pullRequestId: z8.string().min(1)
1307
1518
  }).strict();
1308
- var githubPullRequestLinkedIssuesInputSchema = z7.object({
1309
- linkedIssues: z7.array(
1310
- z7.object({
1311
- number: z7.number().int().positive(),
1312
- repositoryFullName: z7.string().min(1)
1519
+ var githubPullRequestLinkedIssuesInputSchema = z8.object({
1520
+ linkedIssues: z8.array(
1521
+ z8.object({
1522
+ number: z8.number().int().positive(),
1523
+ repositoryFullName: z8.string().min(1)
1313
1524
  }).strict()
1314
1525
  ).min(1),
1315
- pullRequestId: z7.string().min(1)
1526
+ pullRequestId: z8.string().min(1)
1316
1527
  }).strict();
1317
1528
  function projectionValues2(input) {
1318
1529
  return {
@@ -1402,7 +1613,7 @@ async function recordGitHubPullRequestLinkedIssues(db, input) {
1402
1613
  }
1403
1614
 
1404
1615
  // src/webhooks/issue-outcome.ts
1405
- import { z as z8 } from "zod";
1616
+ import { z as z9 } from "zod";
1406
1617
 
1407
1618
  // src/webhooks/ownership.ts
1408
1619
  var GITHUB_NOREPLY_DOMAIN = "users.noreply.github.com";
@@ -1419,38 +1630,38 @@ function botLoginFromEmail(value) {
1419
1630
  }
1420
1631
 
1421
1632
  // src/webhooks/issue-outcome.ts
1422
- var canonicalIssueOutcomeSchema = z8.object({
1423
- action: z8.enum(["opened", "closed", "reopened"]),
1424
- issue: z8.object({
1425
- body: z8.string().nullable().optional(),
1426
- closed_at: z8.string().nullable().optional(),
1427
- created_at: z8.string(),
1428
- id: z8.number().int().positive(),
1429
- number: z8.number().int().positive(),
1633
+ var canonicalIssueOutcomeSchema = z9.object({
1634
+ action: z9.enum(["opened", "closed", "reopened"]),
1635
+ issue: z9.object({
1636
+ body: z9.string().nullable().optional(),
1637
+ closed_at: z9.string().nullable().optional(),
1638
+ created_at: z9.string(),
1639
+ id: z9.number().int().positive(),
1640
+ number: z9.number().int().positive(),
1430
1641
  state_reason: githubIssueStateReasonSchema.nullable().optional(),
1431
- updated_at: z8.string(),
1432
- user: z8.object({ login: z8.string().min(1) }).strict()
1642
+ updated_at: z9.string(),
1643
+ user: z9.object({ login: z9.string().min(1) }).strict()
1433
1644
  }).strict(),
1434
- repository: z8.object({
1435
- full_name: z8.string().min(1),
1436
- id: z8.number().int().positive()
1645
+ repository: z9.object({
1646
+ full_name: z9.string().min(1),
1647
+ id: z9.number().int().positive()
1437
1648
  }).strict()
1438
1649
  }).strict();
1439
- var issueOutcomeSchema = z8.object({
1440
- action: z8.enum(["opened", "closed", "reopened"]),
1441
- issue: z8.object({
1442
- body: z8.string().nullable().optional(),
1443
- closed_at: z8.string().nullable().optional(),
1444
- created_at: z8.string(),
1445
- id: z8.number().int().positive(),
1446
- number: z8.number().int().positive(),
1650
+ var issueOutcomeSchema = z9.object({
1651
+ action: z9.enum(["opened", "closed", "reopened"]),
1652
+ issue: z9.object({
1653
+ body: z9.string().nullable().optional(),
1654
+ closed_at: z9.string().nullable().optional(),
1655
+ created_at: z9.string(),
1656
+ id: z9.number().int().positive(),
1657
+ number: z9.number().int().positive(),
1447
1658
  state_reason: githubIssueStateReasonSchema.nullable().optional(),
1448
- updated_at: z8.string(),
1449
- user: z8.object({ login: z8.string().min(1) }).passthrough()
1659
+ updated_at: z9.string(),
1660
+ user: z9.object({ login: z9.string().min(1) }).passthrough()
1450
1661
  }).passthrough(),
1451
- repository: z8.object({
1452
- full_name: z8.string().min(1),
1453
- id: z8.number().int().positive()
1662
+ repository: z9.object({
1663
+ full_name: z9.string().min(1),
1664
+ id: z9.number().int().positive()
1454
1665
  }).passthrough()
1455
1666
  }).passthrough().transform(
1456
1667
  (provider) => canonicalIssueOutcomeSchema.parse({
@@ -1471,7 +1682,7 @@ var issueOutcomeSchema = z8.object({
1471
1682
  }
1472
1683
  })
1473
1684
  );
1474
- var issueLifecycleActionSchema = z8.object({ action: z8.string() }).passthrough();
1685
+ var issueLifecycleActionSchema = z9.object({ action: z9.string() }).passthrough();
1475
1686
  function timestamp2(value) {
1476
1687
  if (!value) return void 0;
1477
1688
  const parsed = new Date(value);
@@ -1517,21 +1728,21 @@ function normalizeGitHubIssueOutcome(args) {
1517
1728
  updatedAt
1518
1729
  };
1519
1730
  }
1520
- var canonicalIssueConversationSchema = z8.object({
1521
- issue: z8.object({
1522
- body: z8.string().nullable().optional(),
1523
- id: z8.number().int().positive(),
1524
- user: z8.object({ login: z8.string().min(1) }).strict()
1731
+ var canonicalIssueConversationSchema = z9.object({
1732
+ issue: z9.object({
1733
+ body: z9.string().nullable().optional(),
1734
+ id: z9.number().int().positive(),
1735
+ user: z9.object({ login: z9.string().min(1) }).strict()
1525
1736
  }).strict(),
1526
- sender: z8.object({ login: z8.string().min(1) }).strict().optional()
1737
+ sender: z9.object({ login: z9.string().min(1) }).strict().optional()
1527
1738
  }).strict();
1528
- var issueConversationSchema = z8.object({
1529
- issue: z8.object({
1530
- body: z8.string().nullable().optional(),
1531
- id: z8.number().int().positive(),
1532
- user: z8.object({ login: z8.string().min(1) }).passthrough()
1739
+ var issueConversationSchema = z9.object({
1740
+ issue: z9.object({
1741
+ body: z9.string().nullable().optional(),
1742
+ id: z9.number().int().positive(),
1743
+ user: z9.object({ login: z9.string().min(1) }).passthrough()
1533
1744
  }).passthrough(),
1534
- sender: z8.object({ login: z8.string().min(1) }).passthrough().optional()
1745
+ sender: z9.object({ login: z9.string().min(1) }).passthrough().optional()
1535
1746
  }).passthrough().transform(
1536
1747
  (provider) => canonicalIssueConversationSchema.parse({
1537
1748
  issue: {
@@ -1558,41 +1769,41 @@ function normalizeGitHubIssueConversations(args) {
1558
1769
  }
1559
1770
 
1560
1771
  // src/webhooks/pull-request-outcome.ts
1561
- import { z as z9 } from "zod";
1562
- var canonicalPullRequestOutcomeSchema = z9.object({
1563
- action: z9.enum(["opened", "closed", "reopened"]),
1564
- pull_request: z9.object({
1565
- body: z9.string().nullable().optional(),
1566
- closed_at: z9.string().nullable().optional(),
1567
- created_at: z9.string(),
1568
- id: z9.number().int().positive(),
1569
- merged: z9.boolean(),
1570
- merged_at: z9.string().nullable().optional(),
1571
- number: z9.number().int().positive(),
1572
- updated_at: z9.string(),
1573
- user: z9.object({ login: z9.string().min(1) }).strict()
1772
+ import { z as z10 } from "zod";
1773
+ var canonicalPullRequestOutcomeSchema = z10.object({
1774
+ action: z10.enum(["opened", "closed", "reopened"]),
1775
+ pull_request: z10.object({
1776
+ body: z10.string().nullable().optional(),
1777
+ closed_at: z10.string().nullable().optional(),
1778
+ created_at: z10.string(),
1779
+ id: z10.number().int().positive(),
1780
+ merged: z10.boolean(),
1781
+ merged_at: z10.string().nullable().optional(),
1782
+ number: z10.number().int().positive(),
1783
+ updated_at: z10.string(),
1784
+ user: z10.object({ login: z10.string().min(1) }).strict()
1574
1785
  }).strict(),
1575
- repository: z9.object({
1576
- full_name: z9.string().min(1),
1577
- id: z9.number().int().positive()
1786
+ repository: z10.object({
1787
+ full_name: z10.string().min(1),
1788
+ id: z10.number().int().positive()
1578
1789
  }).strict()
1579
1790
  }).strict();
1580
- var pullRequestOutcomeSchema = z9.object({
1581
- action: z9.enum(["opened", "closed", "reopened"]),
1582
- pull_request: z9.object({
1583
- body: z9.string().nullable().optional(),
1584
- closed_at: z9.string().nullable().optional(),
1585
- created_at: z9.string(),
1586
- id: z9.number().int().positive(),
1587
- merged: z9.boolean(),
1588
- merged_at: z9.string().nullable().optional(),
1589
- number: z9.number().int().positive(),
1590
- updated_at: z9.string(),
1591
- user: z9.object({ login: z9.string().min(1) }).passthrough()
1791
+ var pullRequestOutcomeSchema = z10.object({
1792
+ action: z10.enum(["opened", "closed", "reopened"]),
1793
+ pull_request: z10.object({
1794
+ body: z10.string().nullable().optional(),
1795
+ closed_at: z10.string().nullable().optional(),
1796
+ created_at: z10.string(),
1797
+ id: z10.number().int().positive(),
1798
+ merged: z10.boolean(),
1799
+ merged_at: z10.string().nullable().optional(),
1800
+ number: z10.number().int().positive(),
1801
+ updated_at: z10.string(),
1802
+ user: z10.object({ login: z10.string().min(1) }).passthrough()
1592
1803
  }).passthrough(),
1593
- repository: z9.object({
1594
- full_name: z9.string().min(1),
1595
- id: z9.number().int().positive()
1804
+ repository: z10.object({
1805
+ full_name: z10.string().min(1),
1806
+ id: z10.number().int().positive()
1596
1807
  }).passthrough()
1597
1808
  }).passthrough().transform(
1598
1809
  (provider) => canonicalPullRequestOutcomeSchema.parse({
@@ -1614,24 +1825,24 @@ var pullRequestOutcomeSchema = z9.object({
1614
1825
  }
1615
1826
  })
1616
1827
  );
1617
- var pullRequestLifecycleActionSchema = z9.object({ action: z9.string() }).passthrough();
1618
- var canonicalPullRequestConversationSchema = z9.object({
1619
- pull_request: z9.object({
1620
- body: z9.string().nullable().optional(),
1621
- id: z9.number().int().positive(),
1622
- user: z9.object({ login: z9.string().min(1) }).strict()
1828
+ var pullRequestLifecycleActionSchema = z10.object({ action: z10.string() }).passthrough();
1829
+ var canonicalPullRequestConversationSchema = z10.object({
1830
+ pull_request: z10.object({
1831
+ body: z10.string().nullable().optional(),
1832
+ id: z10.number().int().positive(),
1833
+ user: z10.object({ login: z10.string().min(1) }).strict()
1623
1834
  }).strict(),
1624
- repository: z9.object({ full_name: z9.string().min(1) }).strict(),
1625
- sender: z9.object({ login: z9.string().min(1) }).strict()
1835
+ repository: z10.object({ full_name: z10.string().min(1) }).strict(),
1836
+ sender: z10.object({ login: z10.string().min(1) }).strict()
1626
1837
  }).strict();
1627
- var pullRequestConversationSchema = z9.object({
1628
- pull_request: z9.object({
1629
- body: z9.string().nullable().optional(),
1630
- id: z9.number().int().positive(),
1631
- user: z9.object({ login: z9.string().min(1) }).passthrough()
1838
+ var pullRequestConversationSchema = z10.object({
1839
+ pull_request: z10.object({
1840
+ body: z10.string().nullable().optional(),
1841
+ id: z10.number().int().positive(),
1842
+ user: z10.object({ login: z10.string().min(1) }).passthrough()
1632
1843
  }).passthrough(),
1633
- repository: z9.object({ full_name: z9.string().min(1) }).passthrough(),
1634
- sender: z9.object({ login: z9.string().min(1) }).passthrough()
1844
+ repository: z10.object({ full_name: z10.string().min(1) }).passthrough(),
1845
+ sender: z10.object({ login: z10.string().min(1) }).passthrough()
1635
1846
  }).passthrough().transform(
1636
1847
  (provider) => canonicalPullRequestConversationSchema.parse({
1637
1848
  pull_request: {
@@ -1816,18 +2027,18 @@ function createGitHubWebhookRoute(args) {
1816
2027
 
1817
2028
  // src/outcomes/report.ts
1818
2029
  import { sql as sql5 } from "drizzle-orm";
1819
- import { z as z11 } from "zod";
2030
+ import { z as z12 } from "zod";
1820
2031
 
1821
2032
  // src/outcomes/cost.ts
1822
2033
  import { sql as sql4 } from "drizzle-orm";
1823
- import { z as z10 } from "zod";
2034
+ import { z as z11 } from "zod";
1824
2035
  var DAY_MS = 24 * 60 * 60 * 1e3;
1825
- var costWindowSchema = z10.object({
1826
- days: z10.number().int().positive(),
1827
- issueCostUsd: z10.number().nonnegative().nullable(),
1828
- medianIssueCostUsd: z10.number().nonnegative().nullable(),
1829
- medianPullRequestCostUsd: z10.number().nonnegative().nullable(),
1830
- pullRequestCostUsd: z10.number().nonnegative().nullable()
2036
+ var costWindowSchema = z11.object({
2037
+ days: z11.number().int().positive(),
2038
+ issueCostUsd: z11.number().nonnegative().nullable(),
2039
+ medianIssueCostUsd: z11.number().nonnegative().nullable(),
2040
+ medianPullRequestCostUsd: z11.number().nonnegative().nullable(),
2041
+ pullRequestCostUsd: z11.number().nonnegative().nullable()
1831
2042
  }).strict().transform((row) => ({
1832
2043
  days: row.days,
1833
2044
  issueCostUsd: row.issueCostUsd ?? void 0,
@@ -1835,12 +2046,12 @@ var costWindowSchema = z10.object({
1835
2046
  medianPullRequestCostUsd: row.medianPullRequestCostUsd ?? void 0,
1836
2047
  pullRequestCostUsd: row.pullRequestCostUsd ?? void 0
1837
2048
  }));
1838
- var repositoryCostSchema = z10.object({
1839
- issueCostUsd: z10.number().nonnegative().nullable(),
1840
- medianIssueCostUsd: z10.number().nonnegative().nullable(),
1841
- medianPullRequestCostUsd: z10.number().nonnegative().nullable(),
1842
- pullRequestCostUsd: z10.number().nonnegative().nullable(),
1843
- repository: z10.string().min(1)
2049
+ var repositoryCostSchema = z11.object({
2050
+ issueCostUsd: z11.number().nonnegative().nullable(),
2051
+ medianIssueCostUsd: z11.number().nonnegative().nullable(),
2052
+ medianPullRequestCostUsd: z11.number().nonnegative().nullable(),
2053
+ pullRequestCostUsd: z11.number().nonnegative().nullable(),
2054
+ repository: z11.string().min(1)
1844
2055
  }).strict().transform((row) => ({
1845
2056
  issueCostUsd: row.issueCostUsd ?? void 0,
1846
2057
  medianIssueCostUsd: row.medianIssueCostUsd ?? void 0,
@@ -2045,7 +2256,7 @@ async function aggregateGitHubCostWindows(args) {
2045
2256
  INNER JOIN issue_window ON issue_window.days = pull_request_window.days
2046
2257
  ORDER BY pull_request_window.days
2047
2258
  `);
2048
- return z10.array(costWindowSchema).parse(queryRows(result));
2259
+ return z11.array(costWindowSchema).parse(queryRows(result));
2049
2260
  }
2050
2261
  async function aggregateGitHubRepositoryCosts(args) {
2051
2262
  if (!await hasConversationUsageTable(args.db)) {
@@ -2143,7 +2354,7 @@ async function aggregateGitHubRepositoryCosts(args) {
2143
2354
  ON issue_totals.repository = repositories.repository
2144
2355
  ORDER BY "repository" ASC
2145
2356
  `);
2146
- return z10.array(repositoryCostSchema).parse(queryRows(result));
2357
+ return z11.array(repositoryCostSchema).parse(queryRows(result));
2147
2358
  }
2148
2359
  function formatCostUsd(value) {
2149
2360
  if (value === void 0) return "\u2014";
@@ -2158,12 +2369,12 @@ function formatCostUsd(value) {
2158
2369
  // src/outcomes/report.ts
2159
2370
  var DAY_MS2 = 24 * 60 * 60 * 1e3;
2160
2371
  var WINDOWS = [7, 30, 90];
2161
- var pullRequestStatsSchema = z11.object({
2162
- closed: z11.number().int().nonnegative(),
2163
- created: z11.number().int().nonnegative(),
2164
- days: z11.number().int().positive(),
2165
- medianMergeTimeMs: z11.number().nonnegative().nullable(),
2166
- merged: z11.number().int().nonnegative()
2372
+ var pullRequestStatsSchema = z12.object({
2373
+ closed: z12.number().int().nonnegative(),
2374
+ created: z12.number().int().nonnegative(),
2375
+ days: z12.number().int().positive(),
2376
+ medianMergeTimeMs: z12.number().nonnegative().nullable(),
2377
+ merged: z12.number().int().nonnegative()
2167
2378
  }).strict().transform((row) => {
2168
2379
  const terminal = row.merged + row.closed;
2169
2380
  return {
@@ -2172,12 +2383,12 @@ var pullRequestStatsSchema = z11.object({
2172
2383
  mergeRate: terminal > 0 ? row.merged / terminal : void 0
2173
2384
  };
2174
2385
  });
2175
- var pullRequestRepositoryStatsSchema = z11.object({
2176
- closed: z11.number().int().nonnegative(),
2177
- created: z11.number().int().nonnegative(),
2178
- juniorOnly: z11.number().int().nonnegative(),
2179
- merged: z11.number().int().nonnegative(),
2180
- repository: z11.string().min(1)
2386
+ var pullRequestRepositoryStatsSchema = z12.object({
2387
+ closed: z12.number().int().nonnegative(),
2388
+ created: z12.number().int().nonnegative(),
2389
+ juniorOnly: z12.number().int().nonnegative(),
2390
+ merged: z12.number().int().nonnegative(),
2391
+ repository: z12.string().min(1)
2181
2392
  }).strict().transform((row) => {
2182
2393
  const terminal = row.merged + row.closed;
2183
2394
  return {
@@ -2185,33 +2396,33 @@ var pullRequestRepositoryStatsSchema = z11.object({
2185
2396
  mergeRate: terminal > 0 ? row.merged / terminal : void 0
2186
2397
  };
2187
2398
  });
2188
- var issueStatsSchema = z11.object({
2189
- closedCompleted: z11.number().int().nonnegative(),
2190
- closedDuplicate: z11.number().int().nonnegative(),
2191
- closedNotPlanned: z11.number().int().nonnegative(),
2192
- closedUnknown: z11.number().int().nonnegative(),
2193
- created: z11.number().int().nonnegative(),
2194
- days: z11.number().int().positive(),
2195
- medianCloseTimeMs: z11.number().nonnegative().nullable()
2399
+ var issueStatsSchema = z12.object({
2400
+ closedCompleted: z12.number().int().nonnegative(),
2401
+ closedDuplicate: z12.number().int().nonnegative(),
2402
+ closedNotPlanned: z12.number().int().nonnegative(),
2403
+ closedUnknown: z12.number().int().nonnegative(),
2404
+ created: z12.number().int().nonnegative(),
2405
+ days: z12.number().int().positive(),
2406
+ medianCloseTimeMs: z12.number().nonnegative().nullable()
2196
2407
  }).strict().transform((row) => ({
2197
2408
  ...row,
2198
2409
  medianCloseTimeMs: row.medianCloseTimeMs ?? void 0
2199
2410
  }));
2200
- var pullRequestDaySchema = z11.object({
2201
- created: z11.number().int().nonnegative(),
2202
- date: z11.string().date()
2411
+ var pullRequestDaySchema = z12.object({
2412
+ created: z12.number().int().nonnegative(),
2413
+ date: z12.string().date()
2203
2414
  }).strict();
2204
- var issueDaySchema = z11.object({
2205
- created: z11.number().int().nonnegative(),
2206
- date: z11.string().date()
2415
+ var issueDaySchema = z12.object({
2416
+ created: z12.number().int().nonnegative(),
2417
+ date: z12.string().date()
2207
2418
  }).strict();
2208
- var issueRepositoryStatsSchema = z11.object({
2209
- closedCompleted: z11.number().int().nonnegative(),
2210
- closedDuplicate: z11.number().int().nonnegative(),
2211
- closedNotPlanned: z11.number().int().nonnegative(),
2212
- closedUnknown: z11.number().int().nonnegative(),
2213
- created: z11.number().int().nonnegative(),
2214
- repository: z11.string().min(1)
2419
+ var issueRepositoryStatsSchema = z12.object({
2420
+ closedCompleted: z12.number().int().nonnegative(),
2421
+ closedDuplicate: z12.number().int().nonnegative(),
2422
+ closedNotPlanned: z12.number().int().nonnegative(),
2423
+ closedUnknown: z12.number().int().nonnegative(),
2424
+ created: z12.number().int().nonnegative(),
2425
+ repository: z12.string().min(1)
2215
2426
  }).strict();
2216
2427
  function queryRows2(result) {
2217
2428
  if (typeof result !== "object" || result === null || !("rows" in result) || !Array.isArray(result.rows)) {
@@ -2275,7 +2486,7 @@ async function aggregatePullRequestWindows(args) {
2275
2486
  GROUP BY windows.days
2276
2487
  ORDER BY windows.days
2277
2488
  `);
2278
- return z11.array(pullRequestStatsSchema).parse(queryRows2(result));
2489
+ return z12.array(pullRequestStatsSchema).parse(queryRows2(result));
2279
2490
  }
2280
2491
  async function aggregatePullRequestDays(args) {
2281
2492
  const end = new Date(args.nowMs);
@@ -2303,7 +2514,7 @@ async function aggregatePullRequestDays(args) {
2303
2514
  LEFT JOIN daily ON daily.day = days.day
2304
2515
  ORDER BY days.day
2305
2516
  `);
2306
- return z11.array(pullRequestDaySchema).parse(queryRows2(result));
2517
+ return z12.array(pullRequestDaySchema).parse(queryRows2(result));
2307
2518
  }
2308
2519
  async function aggregatePullRequestRepositories(args) {
2309
2520
  const start = new Date(args.nowMs - 30 * DAY_MS2);
@@ -2333,7 +2544,7 @@ async function aggregatePullRequestRepositories(args) {
2333
2544
  ORDER BY "merged" DESC, "created" DESC, "repository" ASC
2334
2545
  LIMIT 25
2335
2546
  `);
2336
- return z11.array(pullRequestRepositoryStatsSchema).parse(queryRows2(result));
2547
+ return z12.array(pullRequestRepositoryStatsSchema).parse(queryRows2(result));
2337
2548
  }
2338
2549
  async function aggregateIssueWindows(args) {
2339
2550
  const starts = WINDOWS.map(
@@ -2402,7 +2613,7 @@ async function aggregateIssueWindows(args) {
2402
2613
  GROUP BY windows.days
2403
2614
  ORDER BY windows.days
2404
2615
  `);
2405
- return z11.array(issueStatsSchema).parse(queryRows2(result));
2616
+ return z12.array(issueStatsSchema).parse(queryRows2(result));
2406
2617
  }
2407
2618
  async function aggregateIssueDays(args) {
2408
2619
  const end = new Date(args.nowMs);
@@ -2430,7 +2641,7 @@ async function aggregateIssueDays(args) {
2430
2641
  LEFT JOIN daily ON daily.day = days.day
2431
2642
  ORDER BY days.day
2432
2643
  `);
2433
- return z11.array(issueDaySchema).parse(queryRows2(result));
2644
+ return z12.array(issueDaySchema).parse(queryRows2(result));
2434
2645
  }
2435
2646
  async function aggregateIssueRepositories(args) {
2436
2647
  const start = new Date(args.nowMs - 30 * DAY_MS2);
@@ -2467,7 +2678,7 @@ async function aggregateIssueRepositories(args) {
2467
2678
  ORDER BY "created" DESC, "closedCompleted" DESC, "repository" ASC
2468
2679
  LIMIT 25
2469
2680
  `);
2470
- return z11.array(issueRepositoryStatsSchema).parse(queryRows2(result));
2681
+ return z12.array(issueRepositoryStatsSchema).parse(queryRows2(result));
2471
2682
  }
2472
2683
  function formatPercent(value) {
2473
2684
  return value === void 0 ? "\u2014" : `${Math.round(value * 100)}%`;
@@ -2631,18 +2842,18 @@ async function buildGitHubOutcomeReport(args) {
2631
2842
  }
2632
2843
 
2633
2844
  // src/pull-request-outcomes/commit-composition.ts
2634
- import { z as z12 } from "zod";
2635
- var canonicalCommitSchema = z12.object({
2636
- authorEmail: z12.string().nullable(),
2637
- authorLogin: z12.string().nullable()
2845
+ import { z as z13 } from "zod";
2846
+ var canonicalCommitSchema = z13.object({
2847
+ authorEmail: z13.string().nullable(),
2848
+ authorLogin: z13.string().nullable()
2638
2849
  }).strict();
2639
- var providerCommitSchema = z12.object({
2640
- author: z12.object({ login: z12.string() }).passthrough().nullable(),
2641
- commit: z12.object({
2642
- author: z12.object({ email: z12.string() }).passthrough().nullable()
2850
+ var providerCommitSchema = z13.object({
2851
+ author: z13.object({ login: z13.string() }).passthrough().nullable(),
2852
+ commit: z13.object({
2853
+ author: z13.object({ email: z13.string() }).passthrough().nullable()
2643
2854
  }).passthrough()
2644
2855
  }).passthrough();
2645
- var commitPageSchema = z12.array(providerCommitSchema).transform(
2856
+ var commitPageSchema = z13.array(providerCommitSchema).transform(
2646
2857
  (commits) => commits.map(
2647
2858
  (commit) => canonicalCommitSchema.parse({
2648
2859
  authorEmail: commit.commit.author?.email ?? null,
@@ -3843,7 +4054,7 @@ function githubPlugin(options = {}) {
3843
4054
  manifest: {
3844
4055
  name: "github",
3845
4056
  displayName: "GitHub",
3846
- description: "GitHub issue, pull request, and repository workflows via GitHub App",
4057
+ description: "GitHub deployment, issue, pull request, and repository workflows via GitHub App",
3847
4058
  configKeys: ["org", "repo"],
3848
4059
  domains: ["api.github.com", "github.com", "uploads.github.com"],
3849
4060
  envVars: {