@sentry/junior-github 0.285.0 → 0.287.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 +741 -683
- package/dist/tools/clone-repository.d.ts +8 -0
- package/dist/tools/comment-on-issue.d.ts +137 -0
- package/dist/tools/comment-on-pull-request.d.ts +8 -0
- package/dist/tools/create-issue.d.ts +8 -0
- package/dist/tools/create-pull-request.d.ts +8 -0
- package/dist/tools/get-deployment.d.ts +8 -0
- package/dist/tools/get-issue.d.ts +8 -0
- package/dist/tools/get-pull-request.d.ts +8 -0
- package/dist/tools/get-release.d.ts +8 -0
- package/dist/tools/get-repository.d.ts +8 -0
- package/dist/tools/get-status.d.ts +8 -0
- package/dist/tools/resolve-pull-request-review-thread.d.ts +8 -0
- package/dist/tools/submit-pull-request-review.d.ts +8 -0
- package/dist/tools/update-issue.d.ts +8 -0
- package/dist/tools/update-pull-request-feedback.d.ts +8 -0
- package/dist/tools/update-pull-request.d.ts +8 -0
- package/package.json +2 -2
- package/skills/github-issues/SKILL.md +3 -2
- package/skills/github-issues/references/api-surface.md +6 -6
- package/skills/github-issues/references/troubleshooting-workarounds.md +0 -1
package/dist/index.js
CHANGED
|
@@ -470,7 +470,7 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
470
470
|
});
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
-
// src/tools/comment-on-
|
|
473
|
+
// src/tools/comment-on-issue.ts
|
|
474
474
|
import {
|
|
475
475
|
definePluginTool as definePluginTool2,
|
|
476
476
|
PluginToolInputError as PluginToolInputError3,
|
|
@@ -479,19 +479,76 @@ import {
|
|
|
479
479
|
import * as z3 from "zod";
|
|
480
480
|
var inputSchema2 = z3.object({
|
|
481
481
|
repo: z3.string().describe('Repository in "owner/name" format.'),
|
|
482
|
-
number: z3.number().int().positive().describe("
|
|
483
|
-
body: z3.string().trim().min(1).describe("Comment text.")
|
|
484
|
-
in_reply_to: z3.number().int().positive().optional().describe(
|
|
485
|
-
"Inline review comment id. Set it to reply in that comment's thread. Omit it to comment on the pull request."
|
|
486
|
-
)
|
|
482
|
+
number: z3.number().int().positive().describe("Issue number."),
|
|
483
|
+
body: z3.string().trim().min(1).describe("Comment text.")
|
|
487
484
|
}).strict();
|
|
488
485
|
var outputSchema2 = pluginToolOutputSchema2.extend({
|
|
489
|
-
target: z3.literal("
|
|
486
|
+
target: z3.literal("commentOnIssue"),
|
|
490
487
|
repo: z3.string(),
|
|
491
488
|
number: z3.number(),
|
|
492
489
|
comment_id: z3.number(),
|
|
493
490
|
url: z3.string()
|
|
494
491
|
});
|
|
492
|
+
function createGitHubCommentOnIssueTool(egress) {
|
|
493
|
+
return definePluginTool2({
|
|
494
|
+
annotations: {
|
|
495
|
+
destructiveHint: false,
|
|
496
|
+
idempotentHint: false,
|
|
497
|
+
openWorldHint: true,
|
|
498
|
+
readOnlyHint: false
|
|
499
|
+
},
|
|
500
|
+
description: "Post a comment on a GitHub issue. Returns the comment id and URL.",
|
|
501
|
+
inputSchema: inputSchema2,
|
|
502
|
+
outputSchema: outputSchema2,
|
|
503
|
+
async execute(input) {
|
|
504
|
+
const repo = parseRepo(input.repo);
|
|
505
|
+
const response = await githubApi(egress, {
|
|
506
|
+
operation: "github.issue.comment.create",
|
|
507
|
+
method: "POST",
|
|
508
|
+
path: `${repoPath(repo)}/issues/${input.number}/comments`,
|
|
509
|
+
body: { body: input.body }
|
|
510
|
+
});
|
|
511
|
+
if (!response.ok) {
|
|
512
|
+
const message = `GitHub issue comment failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
513
|
+
if (response.status === 404 || response.status === 422) {
|
|
514
|
+
throw new PluginToolInputError3(message);
|
|
515
|
+
}
|
|
516
|
+
throw new Error(message);
|
|
517
|
+
}
|
|
518
|
+
const comment = z3.object({ id: z3.number(), html_url: z3.string() }).parse(response.body);
|
|
519
|
+
return {
|
|
520
|
+
target: "commentOnIssue",
|
|
521
|
+
repo: repo.ref,
|
|
522
|
+
number: input.number,
|
|
523
|
+
comment_id: comment.id,
|
|
524
|
+
url: comment.html_url
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// src/tools/comment-on-pull-request.ts
|
|
531
|
+
import {
|
|
532
|
+
definePluginTool as definePluginTool3,
|
|
533
|
+
PluginToolInputError as PluginToolInputError4,
|
|
534
|
+
pluginToolOutputSchema as pluginToolOutputSchema3
|
|
535
|
+
} from "@sentry/junior-plugin-api";
|
|
536
|
+
import * as z4 from "zod";
|
|
537
|
+
var inputSchema3 = z4.object({
|
|
538
|
+
repo: z4.string().describe('Repository in "owner/name" format.'),
|
|
539
|
+
number: z4.number().int().positive().describe("Pull request number."),
|
|
540
|
+
body: z4.string().trim().min(1).describe("Comment text."),
|
|
541
|
+
in_reply_to: z4.number().int().positive().optional().describe(
|
|
542
|
+
"Inline review comment id. Set it to reply in that comment's thread. Omit it to comment on the pull request."
|
|
543
|
+
)
|
|
544
|
+
}).strict();
|
|
545
|
+
var outputSchema3 = pluginToolOutputSchema3.extend({
|
|
546
|
+
target: z4.literal("commentOnPullRequest"),
|
|
547
|
+
repo: z4.string(),
|
|
548
|
+
number: z4.number(),
|
|
549
|
+
comment_id: z4.number(),
|
|
550
|
+
url: z4.string()
|
|
551
|
+
});
|
|
495
552
|
async function threadRootId(egress, prefix, commentId) {
|
|
496
553
|
const response = await githubApi(egress, {
|
|
497
554
|
operation: "github.pull.comment.get",
|
|
@@ -499,24 +556,23 @@ async function threadRootId(egress, prefix, commentId) {
|
|
|
499
556
|
});
|
|
500
557
|
if (!response.ok) {
|
|
501
558
|
const message = `GitHub review comment lookup failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
502
|
-
if (response.status === 404) throw new
|
|
559
|
+
if (response.status === 404) throw new PluginToolInputError4(message);
|
|
503
560
|
throw new Error(message);
|
|
504
561
|
}
|
|
505
|
-
const comment =
|
|
562
|
+
const comment = z4.object({ in_reply_to_id: z4.number().nullish() }).parse(response.body);
|
|
506
563
|
return comment.in_reply_to_id ?? commentId;
|
|
507
564
|
}
|
|
508
565
|
function createGitHubCommentOnPullRequestTool(egress) {
|
|
509
|
-
return
|
|
566
|
+
return definePluginTool3({
|
|
510
567
|
annotations: {
|
|
511
568
|
destructiveHint: false,
|
|
512
569
|
idempotentHint: false,
|
|
513
570
|
openWorldHint: true,
|
|
514
571
|
readOnlyHint: false
|
|
515
572
|
},
|
|
516
|
-
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.",
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
outputSchema: outputSchema2,
|
|
573
|
+
description: "Post a conversation comment on a GitHub pull request, or reply in an inline review thread with in_reply_to. For issues, use github_commentOnIssue. Use it to answer a question asked in a pull request review or comment. Returns the comment id and URL.",
|
|
574
|
+
inputSchema: inputSchema3,
|
|
575
|
+
outputSchema: outputSchema3,
|
|
520
576
|
async execute(input) {
|
|
521
577
|
const repo = parseRepo(input.repo);
|
|
522
578
|
const prefix = repoPath(repo);
|
|
@@ -530,16 +586,17 @@ function createGitHubCommentOnPullRequestTool(egress) {
|
|
|
530
586
|
if (!response.ok) {
|
|
531
587
|
const message = `GitHub pull request comment failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
532
588
|
if (response.status === 404 || response.status === 422) {
|
|
533
|
-
throw new
|
|
589
|
+
throw new PluginToolInputError4(message);
|
|
534
590
|
}
|
|
535
591
|
throw new Error(message);
|
|
536
592
|
}
|
|
537
|
-
const comment =
|
|
593
|
+
const comment = z4.object({ id: z4.number(), html_url: z4.string() }).parse(response.body);
|
|
538
594
|
return {
|
|
539
595
|
target: "commentOnPullRequest",
|
|
540
596
|
repo: repo.ref,
|
|
541
597
|
number: input.number,
|
|
542
598
|
comment_id: comment.id,
|
|
599
|
+
reply: { text: input.body, url: comment.html_url },
|
|
543
600
|
url: comment.html_url
|
|
544
601
|
};
|
|
545
602
|
}
|
|
@@ -547,21 +604,21 @@ function createGitHubCommentOnPullRequestTool(egress) {
|
|
|
547
604
|
}
|
|
548
605
|
|
|
549
606
|
// src/object-facts.ts
|
|
550
|
-
import * as
|
|
551
|
-
var person =
|
|
552
|
-
var responseSchema =
|
|
553
|
-
body:
|
|
607
|
+
import * as z5 from "zod";
|
|
608
|
+
var person = z5.object({ login: z5.string() });
|
|
609
|
+
var responseSchema = z5.object({
|
|
610
|
+
body: z5.string().nullable().optional(),
|
|
554
611
|
user: person.nullable().optional(),
|
|
555
|
-
requested_reviewers:
|
|
556
|
-
assignees:
|
|
557
|
-
labels:
|
|
558
|
-
head:
|
|
559
|
-
base:
|
|
560
|
-
mergeable:
|
|
561
|
-
changed_files:
|
|
562
|
-
additions:
|
|
563
|
-
deletions:
|
|
564
|
-
updated_at:
|
|
612
|
+
requested_reviewers: z5.array(person).optional(),
|
|
613
|
+
assignees: z5.array(person).optional(),
|
|
614
|
+
labels: z5.array(z5.union([z5.string(), z5.object({ name: z5.string() })])).optional(),
|
|
615
|
+
head: z5.object({ ref: z5.string() }).optional(),
|
|
616
|
+
base: z5.object({ ref: z5.string() }).optional(),
|
|
617
|
+
mergeable: z5.boolean().nullable().optional(),
|
|
618
|
+
changed_files: z5.number().int().nonnegative().optional(),
|
|
619
|
+
additions: z5.number().int().nonnegative().optional(),
|
|
620
|
+
deletions: z5.number().int().nonnegative().optional(),
|
|
621
|
+
updated_at: z5.iso.datetime({ offset: true }).optional()
|
|
565
622
|
});
|
|
566
623
|
var short = (value) => {
|
|
567
624
|
const text2 = value?.trim();
|
|
@@ -684,24 +741,24 @@ async function updateGitHubAnnotation(store, input) {
|
|
|
684
741
|
// src/tools/create-issue.ts
|
|
685
742
|
import {
|
|
686
743
|
objectFactsSchema,
|
|
687
|
-
definePluginTool as
|
|
744
|
+
definePluginTool as definePluginTool4,
|
|
688
745
|
EgressAuthRequired,
|
|
689
|
-
PluginToolInputError as
|
|
746
|
+
PluginToolInputError as PluginToolInputError6,
|
|
690
747
|
subscribableResourceSchema,
|
|
691
|
-
pluginToolOutputSchema as
|
|
748
|
+
pluginToolOutputSchema as pluginToolOutputSchema4
|
|
692
749
|
} from "@sentry/junior-plugin-api";
|
|
693
750
|
import { Type } from "@sinclair/typebox";
|
|
694
751
|
import { Value } from "@sinclair/typebox/value";
|
|
695
|
-
import * as
|
|
752
|
+
import * as z6 from "zod";
|
|
696
753
|
|
|
697
754
|
// src/tools/footer.ts
|
|
698
|
-
import { PluginToolInputError as
|
|
755
|
+
import { PluginToolInputError as PluginToolInputError5 } from "@sentry/junior-plugin-api";
|
|
699
756
|
var GITHUB_SESSION_FOOTER_START = "<!-- junior-session-footer:start -->";
|
|
700
757
|
var GITHUB_SESSION_FOOTER_END = "<!-- junior-session-footer:end -->";
|
|
701
758
|
var GITHUB_CONVERSATION_ID_MARKER = "junior-conversation-id:";
|
|
702
759
|
function nonEmptyString(value, name) {
|
|
703
760
|
if (!value?.trim()) {
|
|
704
|
-
throw new
|
|
761
|
+
throw new PluginToolInputError5(`${name} is required`);
|
|
705
762
|
}
|
|
706
763
|
return value.trim();
|
|
707
764
|
}
|
|
@@ -778,11 +835,11 @@ function githubLinkedIssues(body, repositoryFullName) {
|
|
|
778
835
|
if (!body) return [];
|
|
779
836
|
const references = /* @__PURE__ */ new Map();
|
|
780
837
|
const add = (linkedRepository, rawNumber) => {
|
|
781
|
-
const
|
|
782
|
-
if (!Number.isInteger(
|
|
838
|
+
const number24 = Number.parseInt(rawNumber, 10);
|
|
839
|
+
if (!Number.isInteger(number24) || number24 <= 0) return;
|
|
783
840
|
const normalizedRepository = linkedRepository.toLowerCase();
|
|
784
|
-
references.set(`${normalizedRepository}#${
|
|
785
|
-
number:
|
|
841
|
+
references.set(`${normalizedRepository}#${number24}`, {
|
|
842
|
+
number: number24,
|
|
786
843
|
repositoryFullName: linkedRepository
|
|
787
844
|
});
|
|
788
845
|
};
|
|
@@ -845,11 +902,11 @@ var createIssueInputSchema = Type.Object(
|
|
|
845
902
|
},
|
|
846
903
|
{ additionalProperties: false }
|
|
847
904
|
);
|
|
848
|
-
var createIssueToolInputSchema =
|
|
849
|
-
repo:
|
|
850
|
-
title:
|
|
851
|
-
body:
|
|
852
|
-
labels:
|
|
905
|
+
var createIssueToolInputSchema = z6.object({
|
|
906
|
+
repo: z6.string().describe('Repository in "owner/name" format.'),
|
|
907
|
+
title: z6.string().describe("Issue title."),
|
|
908
|
+
body: z6.string().describe("Issue body. The runtime appends the conversation footer.").optional(),
|
|
909
|
+
labels: z6.array(z6.string()).describe("Labels to apply to the issue.").optional()
|
|
853
910
|
}).strict();
|
|
854
911
|
var createIssueStateSchema = Type.Union([
|
|
855
912
|
Type.Object(
|
|
@@ -874,14 +931,14 @@ var createIssueStateSchema = Type.Union([
|
|
|
874
931
|
{ additionalProperties: false }
|
|
875
932
|
)
|
|
876
933
|
]);
|
|
877
|
-
var gitHubIssueDataSchema =
|
|
878
|
-
number:
|
|
934
|
+
var gitHubIssueDataSchema = z6.object({
|
|
935
|
+
number: z6.number(),
|
|
879
936
|
subscribable: subscribableResourceSchema.optional(),
|
|
880
|
-
url:
|
|
937
|
+
url: z6.string()
|
|
881
938
|
});
|
|
882
|
-
var gitHubIssueOutputSchema =
|
|
939
|
+
var gitHubIssueOutputSchema = pluginToolOutputSchema4.merge(
|
|
883
940
|
gitHubIssueDataSchema.extend({
|
|
884
|
-
target:
|
|
941
|
+
target: z6.literal("createIssue")
|
|
885
942
|
})
|
|
886
943
|
);
|
|
887
944
|
function gitHubIssueToolResult(input, result, canSubscribe) {
|
|
@@ -918,14 +975,14 @@ function parseCreateIssueInput(input) {
|
|
|
918
975
|
try {
|
|
919
976
|
return Value.Parse(createIssueInputSchema, input);
|
|
920
977
|
} catch (error) {
|
|
921
|
-
throw new
|
|
978
|
+
throw new PluginToolInputError6("Invalid GitHub createIssue input.", {
|
|
922
979
|
cause: error
|
|
923
980
|
});
|
|
924
981
|
}
|
|
925
982
|
}
|
|
926
983
|
function nonEmptyString2(value, name) {
|
|
927
984
|
if (!value?.trim()) {
|
|
928
|
-
throw new
|
|
985
|
+
throw new PluginToolInputError6(`${name} is required`);
|
|
929
986
|
}
|
|
930
987
|
return value.trim();
|
|
931
988
|
}
|
|
@@ -999,7 +1056,7 @@ async function createGitHubIssue(ctx, request) {
|
|
|
999
1056
|
};
|
|
1000
1057
|
}
|
|
1001
1058
|
function createGitHubIssueTool(ctx) {
|
|
1002
|
-
return
|
|
1059
|
+
return definePluginTool4({
|
|
1003
1060
|
annotations: {
|
|
1004
1061
|
destructiveHint: false,
|
|
1005
1062
|
idempotentHint: true,
|
|
@@ -1092,85 +1149,85 @@ function createGitHubIssueTool(ctx) {
|
|
|
1092
1149
|
|
|
1093
1150
|
// src/tools/get-deployment.ts
|
|
1094
1151
|
import {
|
|
1095
|
-
definePluginTool as
|
|
1096
|
-
PluginToolInputError as
|
|
1097
|
-
pluginToolOutputSchema as
|
|
1152
|
+
definePluginTool as definePluginTool5,
|
|
1153
|
+
PluginToolInputError as PluginToolInputError7,
|
|
1154
|
+
pluginToolOutputSchema as pluginToolOutputSchema5,
|
|
1098
1155
|
subscribableResourceSchema as subscribableResourceSchema2
|
|
1099
1156
|
} from "@sentry/junior-plugin-api";
|
|
1100
|
-
import * as
|
|
1101
|
-
var commitShaSchema =
|
|
1102
|
-
var
|
|
1103
|
-
repo:
|
|
1157
|
+
import * as z7 from "zod";
|
|
1158
|
+
var commitShaSchema = z7.string().regex(/^[0-9a-f]{40}$/i);
|
|
1159
|
+
var inputSchema4 = z7.object({
|
|
1160
|
+
repo: z7.string().describe('Repository in "owner/name" format.'),
|
|
1104
1161
|
commit_sha: commitShaSchema.describe(
|
|
1105
1162
|
"Full 40-character Git commit SHA recorded by the deployment."
|
|
1106
1163
|
),
|
|
1107
|
-
environment:
|
|
1164
|
+
environment: z7.string().trim().min(1).describe(
|
|
1108
1165
|
'Optional GitHub deployment environment, such as "Production". Omit to inspect and watch deployments for the commit across environments.'
|
|
1109
1166
|
).optional()
|
|
1110
1167
|
}).strict();
|
|
1111
|
-
var statusSchema =
|
|
1112
|
-
created_at:
|
|
1113
|
-
creator:
|
|
1114
|
-
description:
|
|
1115
|
-
environment_url:
|
|
1116
|
-
id:
|
|
1117
|
-
log_url:
|
|
1118
|
-
state:
|
|
1168
|
+
var statusSchema = z7.object({
|
|
1169
|
+
created_at: z7.string(),
|
|
1170
|
+
creator: z7.string().nullable(),
|
|
1171
|
+
description: z7.string().nullable(),
|
|
1172
|
+
environment_url: z7.string().nullable(),
|
|
1173
|
+
id: z7.number(),
|
|
1174
|
+
log_url: z7.string().nullable(),
|
|
1175
|
+
state: z7.string()
|
|
1119
1176
|
}).strict();
|
|
1120
|
-
var deploymentSchema =
|
|
1121
|
-
created_at:
|
|
1122
|
-
creator:
|
|
1123
|
-
description:
|
|
1124
|
-
environment:
|
|
1125
|
-
id:
|
|
1177
|
+
var deploymentSchema = z7.object({
|
|
1178
|
+
created_at: z7.string(),
|
|
1179
|
+
creator: z7.string().nullable(),
|
|
1180
|
+
description: z7.string().nullable(),
|
|
1181
|
+
environment: z7.string(),
|
|
1182
|
+
id: z7.number(),
|
|
1126
1183
|
latest_status: statusSchema.nullable(),
|
|
1127
|
-
ref:
|
|
1184
|
+
ref: z7.string(),
|
|
1128
1185
|
sha: commitShaSchema,
|
|
1129
|
-
updated_at:
|
|
1130
|
-
url:
|
|
1186
|
+
updated_at: z7.string(),
|
|
1187
|
+
url: z7.string()
|
|
1131
1188
|
}).strict();
|
|
1132
|
-
var deploymentSourceSchema =
|
|
1189
|
+
var deploymentSourceSchema = z7.object({
|
|
1133
1190
|
commit_sha: commitShaSchema,
|
|
1134
1191
|
deployment: deploymentSchema.nullable(),
|
|
1135
|
-
environment:
|
|
1136
|
-
repo:
|
|
1192
|
+
environment: z7.string().nullable(),
|
|
1193
|
+
repo: z7.string(),
|
|
1137
1194
|
subscribable: subscribableResourceSchema2.optional()
|
|
1138
1195
|
}).strict();
|
|
1139
|
-
var
|
|
1196
|
+
var outputSchema4 = pluginToolOutputSchema5.merge(
|
|
1140
1197
|
deploymentSourceSchema.extend({
|
|
1141
|
-
target:
|
|
1198
|
+
target: z7.literal("getDeployment")
|
|
1142
1199
|
})
|
|
1143
1200
|
);
|
|
1144
|
-
var providerCreatorSchema =
|
|
1145
|
-
var providerDeploymentSchema =
|
|
1146
|
-
created_at:
|
|
1201
|
+
var providerCreatorSchema = z7.object({ login: z7.string() }).passthrough().nullable();
|
|
1202
|
+
var providerDeploymentSchema = z7.object({
|
|
1203
|
+
created_at: z7.string(),
|
|
1147
1204
|
creator: providerCreatorSchema,
|
|
1148
|
-
description:
|
|
1149
|
-
environment:
|
|
1150
|
-
id:
|
|
1151
|
-
ref:
|
|
1205
|
+
description: z7.string().nullable(),
|
|
1206
|
+
environment: z7.string(),
|
|
1207
|
+
id: z7.number(),
|
|
1208
|
+
ref: z7.string(),
|
|
1152
1209
|
sha: commitShaSchema,
|
|
1153
|
-
updated_at:
|
|
1210
|
+
updated_at: z7.string()
|
|
1154
1211
|
}).passthrough();
|
|
1155
|
-
var providerStatusSchema =
|
|
1156
|
-
created_at:
|
|
1212
|
+
var providerStatusSchema = z7.object({
|
|
1213
|
+
created_at: z7.string(),
|
|
1157
1214
|
creator: providerCreatorSchema,
|
|
1158
|
-
description:
|
|
1159
|
-
environment_url:
|
|
1160
|
-
id:
|
|
1161
|
-
log_url:
|
|
1162
|
-
state:
|
|
1215
|
+
description: z7.string().nullable().optional(),
|
|
1216
|
+
environment_url: z7.string().nullable().optional(),
|
|
1217
|
+
id: z7.number(),
|
|
1218
|
+
log_url: z7.string().nullable().optional(),
|
|
1219
|
+
state: z7.string()
|
|
1163
1220
|
}).passthrough();
|
|
1164
1221
|
function throwLookupError(target, status, body) {
|
|
1165
1222
|
const message = `GitHub ${target} lookup failed with HTTP ${status}`;
|
|
1166
1223
|
const hasValidationErrors = body !== null && typeof body === "object" && !Array.isArray(body) && Array.isArray(body.errors) && body.errors.length > 0;
|
|
1167
1224
|
if (target === "deployment" && (status === 404 || status === 422 && hasValidationErrors)) {
|
|
1168
|
-
throw new
|
|
1225
|
+
throw new PluginToolInputError7(message);
|
|
1169
1226
|
}
|
|
1170
1227
|
throw new Error(message);
|
|
1171
1228
|
}
|
|
1172
1229
|
function createGitHubGetDeploymentTool(ctx) {
|
|
1173
|
-
return
|
|
1230
|
+
return definePluginTool5({
|
|
1174
1231
|
annotations: {
|
|
1175
1232
|
destructiveHint: false,
|
|
1176
1233
|
idempotentHint: true,
|
|
@@ -1178,8 +1235,8 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1178
1235
|
readOnlyHint: true
|
|
1179
1236
|
},
|
|
1180
1237
|
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.",
|
|
1181
|
-
inputSchema:
|
|
1182
|
-
outputSchema:
|
|
1238
|
+
inputSchema: inputSchema4,
|
|
1239
|
+
outputSchema: outputSchema4,
|
|
1183
1240
|
async execute(input) {
|
|
1184
1241
|
const repo = parseRepo(input.repo);
|
|
1185
1242
|
const commitSha = input.commit_sha.toLowerCase();
|
|
@@ -1195,7 +1252,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1195
1252
|
if (!deployments.ok) {
|
|
1196
1253
|
throwLookupError("deployment", deployments.status, deployments.body);
|
|
1197
1254
|
}
|
|
1198
|
-
const providerDeployment =
|
|
1255
|
+
const providerDeployment = z7.array(providerDeploymentSchema).parse(deployments.body)[0];
|
|
1199
1256
|
let deployment = null;
|
|
1200
1257
|
if (providerDeployment) {
|
|
1201
1258
|
const statuses = await githubApi(ctx.egress, {
|
|
@@ -1205,7 +1262,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1205
1262
|
if (!statuses.ok) {
|
|
1206
1263
|
throwLookupError("deployment status", statuses.status, statuses.body);
|
|
1207
1264
|
}
|
|
1208
|
-
const providerStatus =
|
|
1265
|
+
const providerStatus = z7.array(providerStatusSchema).parse(statuses.body)[0];
|
|
1209
1266
|
deployment = {
|
|
1210
1267
|
created_at: providerDeployment.created_at,
|
|
1211
1268
|
creator: providerDeployment.creator?.login ?? null,
|
|
@@ -1250,46 +1307,46 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1250
1307
|
|
|
1251
1308
|
// src/tools/get-issue.ts
|
|
1252
1309
|
import {
|
|
1253
|
-
definePluginTool as
|
|
1254
|
-
PluginToolInputError as
|
|
1255
|
-
pluginToolOutputSchema as
|
|
1310
|
+
definePluginTool as definePluginTool6,
|
|
1311
|
+
PluginToolInputError as PluginToolInputError8,
|
|
1312
|
+
pluginToolOutputSchema as pluginToolOutputSchema6,
|
|
1256
1313
|
subscribableResourceSchema as subscribableResourceSchema3
|
|
1257
1314
|
} from "@sentry/junior-plugin-api";
|
|
1258
|
-
import * as
|
|
1315
|
+
import * as z8 from "zod";
|
|
1259
1316
|
var CLAIM_NOTE = "If you start work on this issue, first claim it with github_updateIssue and assign_requester: true.";
|
|
1260
|
-
var
|
|
1261
|
-
repo:
|
|
1262
|
-
number:
|
|
1317
|
+
var inputSchema5 = z8.object({
|
|
1318
|
+
repo: z8.string().describe('Repository in "owner/name" format.'),
|
|
1319
|
+
number: z8.number().int().positive().describe("Issue number.")
|
|
1263
1320
|
}).strict();
|
|
1264
|
-
var issueSchema =
|
|
1265
|
-
assignees:
|
|
1266
|
-
author:
|
|
1267
|
-
body:
|
|
1268
|
-
comments:
|
|
1269
|
-
labels:
|
|
1270
|
-
note:
|
|
1271
|
-
number:
|
|
1272
|
-
state:
|
|
1321
|
+
var issueSchema = z8.object({
|
|
1322
|
+
assignees: z8.array(z8.string()),
|
|
1323
|
+
author: z8.string().optional(),
|
|
1324
|
+
body: z8.string().nullable(),
|
|
1325
|
+
comments: z8.number(),
|
|
1326
|
+
labels: z8.array(z8.string()),
|
|
1327
|
+
note: z8.string().optional(),
|
|
1328
|
+
number: z8.number(),
|
|
1329
|
+
state: z8.string(),
|
|
1273
1330
|
subscribable: subscribableResourceSchema3.optional(),
|
|
1274
|
-
title:
|
|
1275
|
-
url:
|
|
1331
|
+
title: z8.string(),
|
|
1332
|
+
url: z8.string()
|
|
1276
1333
|
});
|
|
1277
|
-
var
|
|
1278
|
-
issueSchema.extend({ target:
|
|
1334
|
+
var outputSchema5 = pluginToolOutputSchema6.merge(
|
|
1335
|
+
issueSchema.extend({ target: z8.literal("getIssue") })
|
|
1279
1336
|
);
|
|
1280
|
-
var providerIssueSchema =
|
|
1281
|
-
assignees:
|
|
1282
|
-
body:
|
|
1283
|
-
comments:
|
|
1284
|
-
html_url:
|
|
1285
|
-
labels:
|
|
1286
|
-
number:
|
|
1287
|
-
state:
|
|
1288
|
-
title:
|
|
1289
|
-
user:
|
|
1337
|
+
var providerIssueSchema = z8.object({
|
|
1338
|
+
assignees: z8.array(z8.object({ login: z8.string() })).nullish().transform((assignees) => assignees?.map(({ login }) => login) ?? []),
|
|
1339
|
+
body: z8.string().nullable().optional().default(null),
|
|
1340
|
+
comments: z8.number().optional().default(0),
|
|
1341
|
+
html_url: z8.string(),
|
|
1342
|
+
labels: z8.array(z8.object({ name: z8.string() })).optional().default([]).transform((labels) => labels.map(({ name }) => name)),
|
|
1343
|
+
number: z8.number(),
|
|
1344
|
+
state: z8.string(),
|
|
1345
|
+
title: z8.string(),
|
|
1346
|
+
user: z8.object({ login: z8.string() }).nullish()
|
|
1290
1347
|
});
|
|
1291
1348
|
function createGitHubGetIssueTool(ctx) {
|
|
1292
|
-
return
|
|
1349
|
+
return definePluginTool6({
|
|
1293
1350
|
annotations: {
|
|
1294
1351
|
destructiveHint: false,
|
|
1295
1352
|
idempotentHint: true,
|
|
@@ -1297,8 +1354,8 @@ function createGitHubGetIssueTool(ctx) {
|
|
|
1297
1354
|
readOnlyHint: true
|
|
1298
1355
|
},
|
|
1299
1356
|
description: "Get a GitHub issue. Read its comments with gh api repos/OWNER/REPO/issues/NUMBER/comments.",
|
|
1300
|
-
inputSchema:
|
|
1301
|
-
outputSchema:
|
|
1357
|
+
inputSchema: inputSchema5,
|
|
1358
|
+
outputSchema: outputSchema5,
|
|
1302
1359
|
async execute(input) {
|
|
1303
1360
|
const repo = parseRepo(input.repo);
|
|
1304
1361
|
const [response, requester] = await Promise.all([
|
|
@@ -1311,7 +1368,7 @@ function createGitHubGetIssueTool(ctx) {
|
|
|
1311
1368
|
if (!response.ok) {
|
|
1312
1369
|
const message = `GitHub issue lookup failed with HTTP ${response.status}`;
|
|
1313
1370
|
if (response.status === 404) {
|
|
1314
|
-
throw new
|
|
1371
|
+
throw new PluginToolInputError8(message);
|
|
1315
1372
|
}
|
|
1316
1373
|
throw new Error(message);
|
|
1317
1374
|
}
|
|
@@ -1355,16 +1412,16 @@ function createGitHubGetIssueTool(ctx) {
|
|
|
1355
1412
|
// src/tools/create-pull-request.ts
|
|
1356
1413
|
import {
|
|
1357
1414
|
objectFactsSchema as objectFactsSchema2,
|
|
1358
|
-
definePluginTool as
|
|
1415
|
+
definePluginTool as definePluginTool7,
|
|
1359
1416
|
EgressAuthRequired as EgressAuthRequired2,
|
|
1360
|
-
PluginToolInputError as
|
|
1361
|
-
pluginToolOutputSchema as
|
|
1417
|
+
PluginToolInputError as PluginToolInputError9,
|
|
1418
|
+
pluginToolOutputSchema as pluginToolOutputSchema7,
|
|
1362
1419
|
watchResultSchema,
|
|
1363
1420
|
subscribableResourceSchema as subscribableResourceSchema4
|
|
1364
1421
|
} from "@sentry/junior-plugin-api";
|
|
1365
1422
|
import { Type as Type2 } from "@sinclair/typebox";
|
|
1366
1423
|
import { Value as Value2 } from "@sinclair/typebox/value";
|
|
1367
|
-
import * as
|
|
1424
|
+
import * as z11 from "zod";
|
|
1368
1425
|
|
|
1369
1426
|
// src/pull-request-requesters/store.ts
|
|
1370
1427
|
import { and, asc, eq, inArray, lt } from "drizzle-orm";
|
|
@@ -1379,18 +1436,18 @@ import {
|
|
|
1379
1436
|
text,
|
|
1380
1437
|
timestamp
|
|
1381
1438
|
} from "drizzle-orm/pg-core";
|
|
1382
|
-
import * as
|
|
1383
|
-
var githubPullRequestStateSchema =
|
|
1439
|
+
import * as z9 from "zod";
|
|
1440
|
+
var githubPullRequestStateSchema = z9.enum([
|
|
1384
1441
|
"closed_unmerged",
|
|
1385
1442
|
"merged",
|
|
1386
1443
|
"open"
|
|
1387
1444
|
]);
|
|
1388
|
-
var githubPullRequestCommitCompositionSchema =
|
|
1445
|
+
var githubPullRequestCommitCompositionSchema = z9.enum([
|
|
1389
1446
|
"junior_only",
|
|
1390
1447
|
"mixed"
|
|
1391
1448
|
]);
|
|
1392
|
-
var githubIssueStateSchema =
|
|
1393
|
-
var githubIssueStateReasonSchema =
|
|
1449
|
+
var githubIssueStateSchema = z9.enum(["closed", "open"]);
|
|
1450
|
+
var githubIssueStateReasonSchema = z9.enum([
|
|
1394
1451
|
"completed",
|
|
1395
1452
|
"duplicate",
|
|
1396
1453
|
"not_planned",
|
|
@@ -1551,31 +1608,31 @@ async function listGitHubPullRequestOpeners(db, input) {
|
|
|
1551
1608
|
}
|
|
1552
1609
|
|
|
1553
1610
|
// src/tools/stack-pull-request.ts
|
|
1554
|
-
import * as
|
|
1611
|
+
import * as z10 from "zod";
|
|
1555
1612
|
var MAX_STACK_DEPTH = 10;
|
|
1556
1613
|
var GITHUB_STACKS_API_VERSION = "2026-03-10";
|
|
1557
|
-
var stackTargetSchema =
|
|
1558
|
-
number:
|
|
1559
|
-
head:
|
|
1560
|
-
repo:
|
|
1614
|
+
var stackTargetSchema = z10.object({
|
|
1615
|
+
number: z10.number().int().positive(),
|
|
1616
|
+
head: z10.object({
|
|
1617
|
+
repo: z10.object({ full_name: z10.string().min(1) }).nullable()
|
|
1561
1618
|
}),
|
|
1562
|
-
base:
|
|
1563
|
-
ref:
|
|
1564
|
-
repo:
|
|
1565
|
-
default_branch:
|
|
1566
|
-
full_name:
|
|
1619
|
+
base: z10.object({
|
|
1620
|
+
ref: z10.string().min(1),
|
|
1621
|
+
repo: z10.object({
|
|
1622
|
+
default_branch: z10.string().min(1),
|
|
1623
|
+
full_name: z10.string().min(1)
|
|
1567
1624
|
})
|
|
1568
1625
|
})
|
|
1569
1626
|
});
|
|
1570
|
-
var openPullRequestsSchema =
|
|
1571
|
-
|
|
1572
|
-
number:
|
|
1573
|
-
base:
|
|
1627
|
+
var openPullRequestsSchema = z10.array(
|
|
1628
|
+
z10.object({
|
|
1629
|
+
number: z10.number().int().positive(),
|
|
1630
|
+
base: z10.object({ ref: z10.string().min(1) })
|
|
1574
1631
|
})
|
|
1575
1632
|
);
|
|
1576
|
-
var stackSchema =
|
|
1577
|
-
number:
|
|
1578
|
-
pull_requests:
|
|
1633
|
+
var stackSchema = z10.object({
|
|
1634
|
+
number: z10.number().int().positive(),
|
|
1635
|
+
pull_requests: z10.array(z10.object({ number: z10.number().int().positive() }))
|
|
1579
1636
|
});
|
|
1580
1637
|
async function stackGitHubPullRequest(ctx, target) {
|
|
1581
1638
|
const repo = target.base.repo.full_name;
|
|
@@ -1621,7 +1678,7 @@ async function stackGitHubPullRequest(ctx, target) {
|
|
|
1621
1678
|
const stacks = await github(
|
|
1622
1679
|
"github.stack.read",
|
|
1623
1680
|
`${api}/stacks?pull_request=${parent.number}`,
|
|
1624
|
-
|
|
1681
|
+
z10.array(stackSchema)
|
|
1625
1682
|
);
|
|
1626
1683
|
if (!stacks) return void 0;
|
|
1627
1684
|
const stack = stacks[0];
|
|
@@ -1696,15 +1753,15 @@ var createPullRequestInputSchema = Type2.Object(
|
|
|
1696
1753
|
},
|
|
1697
1754
|
{ additionalProperties: false }
|
|
1698
1755
|
);
|
|
1699
|
-
var createPullRequestToolInputSchema =
|
|
1700
|
-
repo:
|
|
1701
|
-
title:
|
|
1702
|
-
head:
|
|
1703
|
-
base:
|
|
1704
|
-
body:
|
|
1756
|
+
var createPullRequestToolInputSchema = z11.object({
|
|
1757
|
+
repo: z11.string().describe('Repository in "owner/name" format.'),
|
|
1758
|
+
title: z11.string().describe("Pull request title."),
|
|
1759
|
+
head: z11.string().describe("Head branch or owner:branch ref."),
|
|
1760
|
+
base: z11.string().describe("Base branch."),
|
|
1761
|
+
body: z11.string().describe(
|
|
1705
1762
|
"Pull request body. The runtime appends the conversation footer."
|
|
1706
1763
|
).optional(),
|
|
1707
|
-
draft:
|
|
1764
|
+
draft: z11.boolean().describe("Whether to open the pull request as a draft.").optional()
|
|
1708
1765
|
}).strict();
|
|
1709
1766
|
var createPullRequestStateSchema = Type2.Union([
|
|
1710
1767
|
Type2.Object(
|
|
@@ -1729,30 +1786,30 @@ var createPullRequestStateSchema = Type2.Union([
|
|
|
1729
1786
|
{ additionalProperties: false }
|
|
1730
1787
|
)
|
|
1731
1788
|
]);
|
|
1732
|
-
var gitHubPullRequestDataSchema =
|
|
1733
|
-
number:
|
|
1734
|
-
url:
|
|
1735
|
-
stack:
|
|
1789
|
+
var gitHubPullRequestDataSchema = z11.object({
|
|
1790
|
+
number: z11.number(),
|
|
1791
|
+
url: z11.string(),
|
|
1792
|
+
stack: z11.object({ number: z11.number(), pull_requests: z11.array(z11.number()) }).optional(),
|
|
1736
1793
|
subscribable: subscribableResourceSchema4.optional(),
|
|
1737
1794
|
subscription: watchResultSchema.optional()
|
|
1738
1795
|
});
|
|
1739
|
-
var gitHubPullRequestOutputSchema =
|
|
1796
|
+
var gitHubPullRequestOutputSchema = pluginToolOutputSchema7.merge(
|
|
1740
1797
|
gitHubPullRequestDataSchema.extend({
|
|
1741
|
-
target:
|
|
1798
|
+
target: z11.literal("createPullRequest")
|
|
1742
1799
|
})
|
|
1743
1800
|
);
|
|
1744
1801
|
function parseCreatePullRequestInput(input) {
|
|
1745
1802
|
try {
|
|
1746
1803
|
return Value2.Parse(createPullRequestInputSchema, input);
|
|
1747
1804
|
} catch (error) {
|
|
1748
|
-
throw new
|
|
1805
|
+
throw new PluginToolInputError9("Invalid GitHub createPullRequest input.", {
|
|
1749
1806
|
cause: error
|
|
1750
1807
|
});
|
|
1751
1808
|
}
|
|
1752
1809
|
}
|
|
1753
1810
|
function nonEmptyString3(value, name) {
|
|
1754
1811
|
if (!value?.trim()) {
|
|
1755
|
-
throw new
|
|
1812
|
+
throw new PluginToolInputError9(`${name} is required`);
|
|
1756
1813
|
}
|
|
1757
1814
|
return value.trim();
|
|
1758
1815
|
}
|
|
@@ -1941,7 +1998,7 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
|
|
|
1941
1998
|
}
|
|
1942
1999
|
}
|
|
1943
2000
|
function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
1944
|
-
return
|
|
2001
|
+
return definePluginTool7({
|
|
1945
2002
|
annotations: {
|
|
1946
2003
|
destructiveHint: false,
|
|
1947
2004
|
idempotentHint: true,
|
|
@@ -2060,36 +2117,36 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
2060
2117
|
|
|
2061
2118
|
// src/tools/get-pull-request.ts
|
|
2062
2119
|
import {
|
|
2063
|
-
definePluginTool as
|
|
2064
|
-
PluginToolInputError as
|
|
2065
|
-
pluginToolOutputSchema as
|
|
2120
|
+
definePluginTool as definePluginTool8,
|
|
2121
|
+
PluginToolInputError as PluginToolInputError10,
|
|
2122
|
+
pluginToolOutputSchema as pluginToolOutputSchema8
|
|
2066
2123
|
} from "@sentry/junior-plugin-api";
|
|
2067
|
-
import * as
|
|
2124
|
+
import * as z12 from "zod";
|
|
2068
2125
|
import { subscribableResourceSchema as subscribableResourceSchema5 } from "@sentry/junior-plugin-api";
|
|
2069
|
-
var commitShaSchema2 =
|
|
2070
|
-
var
|
|
2071
|
-
repo:
|
|
2072
|
-
number:
|
|
2126
|
+
var commitShaSchema2 = z12.string().regex(/^[0-9a-f]{40}$/i);
|
|
2127
|
+
var inputSchema6 = z12.object({
|
|
2128
|
+
repo: z12.string().describe('Repository in "owner/name" format.'),
|
|
2129
|
+
number: z12.number().int().positive().describe("Pull request number.")
|
|
2073
2130
|
}).strict();
|
|
2074
|
-
var pullRequestSchema =
|
|
2075
|
-
base:
|
|
2076
|
-
draft:
|
|
2077
|
-
head:
|
|
2131
|
+
var pullRequestSchema = z12.object({
|
|
2132
|
+
base: z12.string(),
|
|
2133
|
+
draft: z12.boolean(),
|
|
2134
|
+
head: z12.string(),
|
|
2078
2135
|
head_sha: commitShaSchema2,
|
|
2079
|
-
merged:
|
|
2080
|
-
number:
|
|
2081
|
-
state:
|
|
2136
|
+
merged: z12.boolean(),
|
|
2137
|
+
number: z12.number(),
|
|
2138
|
+
state: z12.string(),
|
|
2082
2139
|
subscribable: subscribableResourceSchema5.optional(),
|
|
2083
|
-
title:
|
|
2084
|
-
url:
|
|
2140
|
+
title: z12.string(),
|
|
2141
|
+
url: z12.string()
|
|
2085
2142
|
});
|
|
2086
|
-
var
|
|
2143
|
+
var outputSchema6 = pluginToolOutputSchema8.merge(
|
|
2087
2144
|
pullRequestSchema.extend({
|
|
2088
|
-
target:
|
|
2145
|
+
target: z12.literal("getPullRequest")
|
|
2089
2146
|
})
|
|
2090
2147
|
);
|
|
2091
2148
|
function createGitHubGetPullRequestTool(ctx) {
|
|
2092
|
-
return
|
|
2149
|
+
return definePluginTool8({
|
|
2093
2150
|
annotations: {
|
|
2094
2151
|
destructiveHint: false,
|
|
2095
2152
|
idempotentHint: true,
|
|
@@ -2097,8 +2154,8 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2097
2154
|
readOnlyHint: true
|
|
2098
2155
|
},
|
|
2099
2156
|
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.",
|
|
2100
|
-
inputSchema:
|
|
2101
|
-
outputSchema:
|
|
2157
|
+
inputSchema: inputSchema6,
|
|
2158
|
+
outputSchema: outputSchema6,
|
|
2102
2159
|
async execute(input) {
|
|
2103
2160
|
const repo = parseRepo(input.repo);
|
|
2104
2161
|
const response = await githubApi(ctx.egress, {
|
|
@@ -2108,19 +2165,19 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2108
2165
|
if (!response.ok) {
|
|
2109
2166
|
const message = `GitHub pull request lookup failed with HTTP ${response.status}`;
|
|
2110
2167
|
if (response.status === 404) {
|
|
2111
|
-
throw new
|
|
2168
|
+
throw new PluginToolInputError10(message);
|
|
2112
2169
|
}
|
|
2113
2170
|
throw new Error(message);
|
|
2114
2171
|
}
|
|
2115
|
-
const providerResult =
|
|
2116
|
-
base:
|
|
2117
|
-
draft:
|
|
2118
|
-
head:
|
|
2119
|
-
html_url:
|
|
2120
|
-
merged:
|
|
2121
|
-
number:
|
|
2122
|
-
state:
|
|
2123
|
-
title:
|
|
2172
|
+
const providerResult = z12.object({
|
|
2173
|
+
base: z12.object({ ref: z12.string() }),
|
|
2174
|
+
draft: z12.boolean(),
|
|
2175
|
+
head: z12.object({ ref: z12.string(), sha: commitShaSchema2 }),
|
|
2176
|
+
html_url: z12.string(),
|
|
2177
|
+
merged: z12.boolean().optional().default(false),
|
|
2178
|
+
number: z12.number(),
|
|
2179
|
+
state: z12.string(),
|
|
2180
|
+
title: z12.string()
|
|
2124
2181
|
}).parse(response.body);
|
|
2125
2182
|
const subscribable = gitHubPullRequestSubscribable({
|
|
2126
2183
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -2160,49 +2217,49 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2160
2217
|
|
|
2161
2218
|
// src/tools/get-release.ts
|
|
2162
2219
|
import {
|
|
2163
|
-
definePluginTool as
|
|
2164
|
-
pluginToolOutputSchema as
|
|
2220
|
+
definePluginTool as definePluginTool9,
|
|
2221
|
+
pluginToolOutputSchema as pluginToolOutputSchema9,
|
|
2165
2222
|
subscribableResourceSchema as subscribableResourceSchema6
|
|
2166
2223
|
} from "@sentry/junior-plugin-api";
|
|
2167
|
-
import * as
|
|
2168
|
-
var
|
|
2169
|
-
repo:
|
|
2170
|
-
tag:
|
|
2224
|
+
import * as z13 from "zod";
|
|
2225
|
+
var inputSchema7 = z13.object({
|
|
2226
|
+
repo: z13.string().describe('Repository in "owner/name" format.'),
|
|
2227
|
+
tag: z13.string().trim().min(1).describe(
|
|
2171
2228
|
"Optional release tag name. Omit to inspect and watch every published release in the repository."
|
|
2172
2229
|
).optional()
|
|
2173
2230
|
}).strict();
|
|
2174
|
-
var releaseSchema =
|
|
2175
|
-
created_at:
|
|
2176
|
-
draft:
|
|
2177
|
-
html_url:
|
|
2178
|
-
id:
|
|
2179
|
-
name:
|
|
2180
|
-
prerelease:
|
|
2181
|
-
published_at:
|
|
2182
|
-
tag_name:
|
|
2183
|
-
target_commitish:
|
|
2231
|
+
var releaseSchema = z13.object({
|
|
2232
|
+
created_at: z13.string(),
|
|
2233
|
+
draft: z13.boolean(),
|
|
2234
|
+
html_url: z13.string(),
|
|
2235
|
+
id: z13.number(),
|
|
2236
|
+
name: z13.string().nullable(),
|
|
2237
|
+
prerelease: z13.boolean(),
|
|
2238
|
+
published_at: z13.string().nullable(),
|
|
2239
|
+
tag_name: z13.string(),
|
|
2240
|
+
target_commitish: z13.string()
|
|
2184
2241
|
}).strict();
|
|
2185
|
-
var releaseSourceSchema =
|
|
2242
|
+
var releaseSourceSchema = z13.object({
|
|
2186
2243
|
release: releaseSchema.nullable(),
|
|
2187
|
-
repo:
|
|
2244
|
+
repo: z13.string(),
|
|
2188
2245
|
subscribable: subscribableResourceSchema6.optional(),
|
|
2189
|
-
tag:
|
|
2246
|
+
tag: z13.string().nullable()
|
|
2190
2247
|
}).strict();
|
|
2191
|
-
var
|
|
2248
|
+
var outputSchema7 = pluginToolOutputSchema9.merge(
|
|
2192
2249
|
releaseSourceSchema.extend({
|
|
2193
|
-
target:
|
|
2250
|
+
target: z13.literal("getRelease")
|
|
2194
2251
|
})
|
|
2195
2252
|
);
|
|
2196
|
-
var providerReleaseSchema =
|
|
2197
|
-
created_at:
|
|
2198
|
-
draft:
|
|
2199
|
-
html_url:
|
|
2200
|
-
id:
|
|
2201
|
-
name:
|
|
2202
|
-
prerelease:
|
|
2203
|
-
published_at:
|
|
2204
|
-
tag_name:
|
|
2205
|
-
target_commitish:
|
|
2253
|
+
var providerReleaseSchema = z13.object({
|
|
2254
|
+
created_at: z13.string(),
|
|
2255
|
+
draft: z13.boolean(),
|
|
2256
|
+
html_url: z13.string(),
|
|
2257
|
+
id: z13.number(),
|
|
2258
|
+
name: z13.string().nullable(),
|
|
2259
|
+
prerelease: z13.boolean(),
|
|
2260
|
+
published_at: z13.string().nullable(),
|
|
2261
|
+
tag_name: z13.string(),
|
|
2262
|
+
target_commitish: z13.string()
|
|
2206
2263
|
}).passthrough();
|
|
2207
2264
|
function mapRelease(providerRelease) {
|
|
2208
2265
|
return {
|
|
@@ -2218,7 +2275,7 @@ function mapRelease(providerRelease) {
|
|
|
2218
2275
|
};
|
|
2219
2276
|
}
|
|
2220
2277
|
function createGitHubGetReleaseTool(ctx) {
|
|
2221
|
-
return
|
|
2278
|
+
return definePluginTool9({
|
|
2222
2279
|
annotations: {
|
|
2223
2280
|
destructiveHint: false,
|
|
2224
2281
|
idempotentHint: true,
|
|
@@ -2226,8 +2283,8 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2226
2283
|
readOnlyHint: true
|
|
2227
2284
|
},
|
|
2228
2285
|
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.",
|
|
2229
|
-
inputSchema:
|
|
2230
|
-
outputSchema:
|
|
2286
|
+
inputSchema: inputSchema7,
|
|
2287
|
+
outputSchema: outputSchema7,
|
|
2231
2288
|
async execute(input) {
|
|
2232
2289
|
const repo = parseRepo(input.repo);
|
|
2233
2290
|
const tag = input.tag?.trim() || void 0;
|
|
@@ -2280,30 +2337,30 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2280
2337
|
|
|
2281
2338
|
// src/tools/get-repository.ts
|
|
2282
2339
|
import {
|
|
2283
|
-
definePluginTool as
|
|
2284
|
-
PluginToolInputError as
|
|
2285
|
-
pluginToolOutputSchema as
|
|
2340
|
+
definePluginTool as definePluginTool10,
|
|
2341
|
+
PluginToolInputError as PluginToolInputError11,
|
|
2342
|
+
pluginToolOutputSchema as pluginToolOutputSchema10,
|
|
2286
2343
|
subscribableResourceSchema as subscribableResourceSchema7
|
|
2287
2344
|
} from "@sentry/junior-plugin-api";
|
|
2288
|
-
import * as
|
|
2289
|
-
var
|
|
2290
|
-
repo:
|
|
2345
|
+
import * as z14 from "zod";
|
|
2346
|
+
var inputSchema8 = z14.object({
|
|
2347
|
+
repo: z14.string().describe('Repository in "owner/name" format.')
|
|
2291
2348
|
}).strict();
|
|
2292
|
-
var repositorySchema =
|
|
2293
|
-
default_branch:
|
|
2294
|
-
description:
|
|
2295
|
-
full_name:
|
|
2296
|
-
private:
|
|
2349
|
+
var repositorySchema = z14.object({
|
|
2350
|
+
default_branch: z14.string(),
|
|
2351
|
+
description: z14.string().nullable(),
|
|
2352
|
+
full_name: z14.string(),
|
|
2353
|
+
private: z14.boolean(),
|
|
2297
2354
|
subscribable: subscribableResourceSchema7.optional(),
|
|
2298
|
-
url:
|
|
2355
|
+
url: z14.string()
|
|
2299
2356
|
});
|
|
2300
|
-
var
|
|
2357
|
+
var outputSchema8 = pluginToolOutputSchema10.merge(
|
|
2301
2358
|
repositorySchema.extend({
|
|
2302
|
-
target:
|
|
2359
|
+
target: z14.literal("getRepository")
|
|
2303
2360
|
})
|
|
2304
2361
|
);
|
|
2305
2362
|
function createGitHubGetRepositoryTool(ctx) {
|
|
2306
|
-
return
|
|
2363
|
+
return definePluginTool10({
|
|
2307
2364
|
annotations: {
|
|
2308
2365
|
destructiveHint: false,
|
|
2309
2366
|
idempotentHint: true,
|
|
@@ -2311,8 +2368,8 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2311
2368
|
readOnlyHint: true
|
|
2312
2369
|
},
|
|
2313
2370
|
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.",
|
|
2314
|
-
inputSchema:
|
|
2315
|
-
outputSchema:
|
|
2371
|
+
inputSchema: inputSchema8,
|
|
2372
|
+
outputSchema: outputSchema8,
|
|
2316
2373
|
async execute(input) {
|
|
2317
2374
|
const repo = parseRepo(input.repo);
|
|
2318
2375
|
const response = await githubApi(ctx.egress, {
|
|
@@ -2320,16 +2377,16 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2320
2377
|
path: repoPath(repo)
|
|
2321
2378
|
});
|
|
2322
2379
|
if (!response.ok) {
|
|
2323
|
-
throw new
|
|
2380
|
+
throw new PluginToolInputError11(
|
|
2324
2381
|
`GitHub repository lookup failed with HTTP ${response.status}`
|
|
2325
2382
|
);
|
|
2326
2383
|
}
|
|
2327
|
-
const providerResult =
|
|
2328
|
-
default_branch:
|
|
2329
|
-
description:
|
|
2330
|
-
full_name:
|
|
2331
|
-
html_url:
|
|
2332
|
-
private:
|
|
2384
|
+
const providerResult = z14.object({
|
|
2385
|
+
default_branch: z14.string(),
|
|
2386
|
+
description: z14.string().nullable(),
|
|
2387
|
+
full_name: z14.string(),
|
|
2388
|
+
html_url: z14.string(),
|
|
2389
|
+
private: z14.boolean()
|
|
2333
2390
|
}).parse(response.body);
|
|
2334
2391
|
const subscribable = gitHubRepositorySubscribable({
|
|
2335
2392
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -2353,27 +2410,27 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2353
2410
|
|
|
2354
2411
|
// src/tools/get-status.ts
|
|
2355
2412
|
import {
|
|
2356
|
-
definePluginTool as
|
|
2357
|
-
pluginToolOutputSchema as
|
|
2413
|
+
definePluginTool as definePluginTool11,
|
|
2414
|
+
pluginToolOutputSchema as pluginToolOutputSchema11
|
|
2358
2415
|
} from "@sentry/junior-plugin-api";
|
|
2359
|
-
import * as
|
|
2416
|
+
import * as z16 from "zod";
|
|
2360
2417
|
|
|
2361
2418
|
// src/github-status.ts
|
|
2362
|
-
import * as
|
|
2419
|
+
import * as z15 from "zod";
|
|
2363
2420
|
var GITHUB_STATUS_INCIDENTS_URL = "https://www.githubstatus.com/api/v2/incidents.json";
|
|
2364
2421
|
var GITHUB_STATUS_TTL_MS = 60 * 1e3;
|
|
2365
2422
|
var GITHUB_STATUS_TIMEOUT_MS = 5e3;
|
|
2366
|
-
var incidentsResponseSchema =
|
|
2367
|
-
incidents:
|
|
2368
|
-
|
|
2369
|
-
components:
|
|
2370
|
-
created_at:
|
|
2371
|
-
impact:
|
|
2372
|
-
name:
|
|
2373
|
-
resolved_at:
|
|
2374
|
-
shortlink:
|
|
2375
|
-
started_at:
|
|
2376
|
-
status:
|
|
2423
|
+
var incidentsResponseSchema = z15.object({
|
|
2424
|
+
incidents: z15.array(
|
|
2425
|
+
z15.object({
|
|
2426
|
+
components: z15.array(z15.object({ name: z15.string() })).default([]),
|
|
2427
|
+
created_at: z15.string(),
|
|
2428
|
+
impact: z15.string(),
|
|
2429
|
+
name: z15.string(),
|
|
2430
|
+
resolved_at: z15.string().nullable(),
|
|
2431
|
+
shortlink: z15.string(),
|
|
2432
|
+
started_at: z15.string().nullable().optional(),
|
|
2433
|
+
status: z15.string()
|
|
2377
2434
|
})
|
|
2378
2435
|
)
|
|
2379
2436
|
});
|
|
@@ -2415,22 +2472,22 @@ async function loadGitHubStatusIncidents(cache, withinMs) {
|
|
|
2415
2472
|
|
|
2416
2473
|
// src/tools/get-status.ts
|
|
2417
2474
|
var RECENT_INCIDENT_MS = 24 * 60 * 60 * 1e3;
|
|
2418
|
-
var
|
|
2419
|
-
var incidentSchema =
|
|
2420
|
-
components:
|
|
2421
|
-
impact:
|
|
2422
|
-
name:
|
|
2423
|
-
resolved_at:
|
|
2424
|
-
started_at:
|
|
2425
|
-
status:
|
|
2426
|
-
url:
|
|
2475
|
+
var inputSchema9 = z16.object({}).strict();
|
|
2476
|
+
var incidentSchema = z16.object({
|
|
2477
|
+
components: z16.array(z16.string()),
|
|
2478
|
+
impact: z16.string(),
|
|
2479
|
+
name: z16.string(),
|
|
2480
|
+
resolved_at: z16.string().optional(),
|
|
2481
|
+
started_at: z16.string(),
|
|
2482
|
+
status: z16.string(),
|
|
2483
|
+
url: z16.string()
|
|
2427
2484
|
});
|
|
2428
|
-
var
|
|
2429
|
-
target:
|
|
2430
|
-
incidents:
|
|
2485
|
+
var outputSchema9 = pluginToolOutputSchema11.extend({
|
|
2486
|
+
target: z16.literal("getStatus"),
|
|
2487
|
+
incidents: z16.array(incidentSchema)
|
|
2431
2488
|
});
|
|
2432
2489
|
function createGitHubGetStatusTool(ctx) {
|
|
2433
|
-
return
|
|
2490
|
+
return definePluginTool11({
|
|
2434
2491
|
annotations: {
|
|
2435
2492
|
destructiveHint: false,
|
|
2436
2493
|
idempotentHint: true,
|
|
@@ -2438,8 +2495,8 @@ function createGitHubGetStatusTool(ctx) {
|
|
|
2438
2495
|
readOnlyHint: true
|
|
2439
2496
|
},
|
|
2440
2497
|
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.",
|
|
2441
|
-
inputSchema:
|
|
2442
|
-
outputSchema:
|
|
2498
|
+
inputSchema: inputSchema9,
|
|
2499
|
+
outputSchema: outputSchema9,
|
|
2443
2500
|
async execute() {
|
|
2444
2501
|
const incidents = await loadGitHubStatusIncidents(
|
|
2445
2502
|
ctx.cache,
|
|
@@ -2462,55 +2519,55 @@ function createGitHubGetStatusTool(ctx) {
|
|
|
2462
2519
|
|
|
2463
2520
|
// src/tools/update-issue.ts
|
|
2464
2521
|
import {
|
|
2465
|
-
definePluginTool as
|
|
2466
|
-
PluginToolInputError as
|
|
2467
|
-
pluginToolOutputSchema as
|
|
2522
|
+
definePluginTool as definePluginTool12,
|
|
2523
|
+
PluginToolInputError as PluginToolInputError12,
|
|
2524
|
+
pluginToolOutputSchema as pluginToolOutputSchema12,
|
|
2468
2525
|
subscribableResourceSchema as subscribableResourceSchema8
|
|
2469
2526
|
} from "@sentry/junior-plugin-api";
|
|
2470
|
-
import * as
|
|
2471
|
-
var
|
|
2472
|
-
repo:
|
|
2473
|
-
number:
|
|
2474
|
-
title:
|
|
2475
|
-
body:
|
|
2527
|
+
import * as z17 from "zod";
|
|
2528
|
+
var inputSchema10 = z17.object({
|
|
2529
|
+
repo: z17.string().describe('Repository in "owner/name" format.'),
|
|
2530
|
+
number: z17.number().int().positive().describe("Issue number."),
|
|
2531
|
+
title: z17.string().trim().min(1).optional().describe("Replacement issue title."),
|
|
2532
|
+
body: z17.string().optional().describe(
|
|
2476
2533
|
"Replacement issue body. The runtime appends requester attribution and the conversation footer."
|
|
2477
2534
|
),
|
|
2478
|
-
state:
|
|
2479
|
-
assign_requester:
|
|
2535
|
+
state: z17.enum(["open", "closed"]).optional().describe("Replacement issue state."),
|
|
2536
|
+
assign_requester: z17.boolean().optional().describe(
|
|
2480
2537
|
"Set true to add the requester's linked GitHub account as an assignee. Other assignees stay."
|
|
2481
2538
|
)
|
|
2482
2539
|
}).strict().refine(
|
|
2483
2540
|
({ title, body, state, assign_requester }) => title !== void 0 || body !== void 0 || state !== void 0 || assign_requester === true,
|
|
2484
2541
|
{ message: "At least one issue field must be provided." }
|
|
2485
2542
|
);
|
|
2486
|
-
var issueSchema2 =
|
|
2487
|
-
assignees:
|
|
2488
|
-
body:
|
|
2489
|
-
number:
|
|
2490
|
-
state:
|
|
2543
|
+
var issueSchema2 = z17.object({
|
|
2544
|
+
assignees: z17.array(z17.string()),
|
|
2545
|
+
body: z17.string().nullable(),
|
|
2546
|
+
number: z17.number(),
|
|
2547
|
+
state: z17.string(),
|
|
2491
2548
|
subscribable: subscribableResourceSchema8.optional(),
|
|
2492
|
-
title:
|
|
2493
|
-
url:
|
|
2549
|
+
title: z17.string(),
|
|
2550
|
+
url: z17.string()
|
|
2494
2551
|
});
|
|
2495
|
-
var
|
|
2552
|
+
var outputSchema10 = pluginToolOutputSchema12.merge(
|
|
2496
2553
|
issueSchema2.extend({
|
|
2497
|
-
target:
|
|
2554
|
+
target: z17.literal("updateIssue")
|
|
2498
2555
|
})
|
|
2499
2556
|
);
|
|
2500
|
-
var providerIssueSchema2 =
|
|
2501
|
-
assignees:
|
|
2502
|
-
body:
|
|
2503
|
-
html_url:
|
|
2504
|
-
number:
|
|
2505
|
-
state:
|
|
2506
|
-
title:
|
|
2557
|
+
var providerIssueSchema2 = z17.object({
|
|
2558
|
+
assignees: z17.array(z17.object({ login: z17.string() })).nullish().transform((assignees) => assignees?.map(({ login }) => login) ?? []),
|
|
2559
|
+
body: z17.string().nullable().optional().default(null),
|
|
2560
|
+
html_url: z17.string(),
|
|
2561
|
+
number: z17.number(),
|
|
2562
|
+
state: z17.string(),
|
|
2563
|
+
title: z17.string()
|
|
2507
2564
|
});
|
|
2508
2565
|
function nonEmptyString4(value, name) {
|
|
2509
|
-
if (!value?.trim()) throw new
|
|
2566
|
+
if (!value?.trim()) throw new PluginToolInputError12(`${name} is required`);
|
|
2510
2567
|
return value.trim();
|
|
2511
2568
|
}
|
|
2512
2569
|
function createGitHubUpdateIssueTool(ctx) {
|
|
2513
|
-
return
|
|
2570
|
+
return definePluginTool12({
|
|
2514
2571
|
annotations: {
|
|
2515
2572
|
destructiveHint: true,
|
|
2516
2573
|
idempotentHint: true,
|
|
@@ -2518,12 +2575,12 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2518
2575
|
readOnlyHint: false
|
|
2519
2576
|
},
|
|
2520
2577
|
description: "Update an existing GitHub issue's title, body, or open/closed state, or assign it to the requester. Use this instead of raw GitHub API calls when changing issue metadata.",
|
|
2521
|
-
inputSchema:
|
|
2522
|
-
outputSchema:
|
|
2578
|
+
inputSchema: inputSchema10,
|
|
2579
|
+
outputSchema: outputSchema10,
|
|
2523
2580
|
async execute(input) {
|
|
2524
|
-
const parsedInput =
|
|
2581
|
+
const parsedInput = inputSchema10.safeParse(input);
|
|
2525
2582
|
if (!parsedInput.success) {
|
|
2526
|
-
throw new
|
|
2583
|
+
throw new PluginToolInputError12("Invalid GitHub updateIssue input.", {
|
|
2527
2584
|
cause: parsedInput.error
|
|
2528
2585
|
});
|
|
2529
2586
|
}
|
|
@@ -2532,7 +2589,7 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2532
2589
|
const requester = update.body !== void 0 || update.assign_requester ? await resolveGitHubRequester(ctx) : void 0;
|
|
2533
2590
|
const assignee = update.assign_requester ? linkedGitHubLogin(requester?.user) : void 0;
|
|
2534
2591
|
if (update.assign_requester && !assignee) {
|
|
2535
|
-
throw new
|
|
2592
|
+
throw new PluginToolInputError12(
|
|
2536
2593
|
"The requester has no linked GitHub account, so Junior cannot assign the issue to them."
|
|
2537
2594
|
);
|
|
2538
2595
|
}
|
|
@@ -2582,7 +2639,7 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2582
2639
|
if (!response.ok) {
|
|
2583
2640
|
const message = `GitHub issue assignment failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`;
|
|
2584
2641
|
if (response.status === 404 || response.status === 422) {
|
|
2585
|
-
throw new
|
|
2642
|
+
throw new PluginToolInputError12(message);
|
|
2586
2643
|
}
|
|
2587
2644
|
throw new Error(message);
|
|
2588
2645
|
}
|
|
@@ -2591,7 +2648,7 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2591
2648
|
if (assignee && !providerResult.assignees.some(
|
|
2592
2649
|
(login) => login.toLowerCase() === assignee.toLowerCase()
|
|
2593
2650
|
)) {
|
|
2594
|
-
throw new
|
|
2651
|
+
throw new PluginToolInputError12(
|
|
2595
2652
|
`GitHub did not assign @${assignee} to the issue. They may not have access to ${repo.ref}.`
|
|
2596
2653
|
);
|
|
2597
2654
|
}
|
|
@@ -2627,22 +2684,22 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2627
2684
|
|
|
2628
2685
|
// src/tools/update-pull-request.ts
|
|
2629
2686
|
import {
|
|
2630
|
-
definePluginTool as
|
|
2631
|
-
PluginToolInputError as
|
|
2632
|
-
pluginToolOutputSchema as
|
|
2687
|
+
definePluginTool as definePluginTool13,
|
|
2688
|
+
PluginToolInputError as PluginToolInputError13,
|
|
2689
|
+
pluginToolOutputSchema as pluginToolOutputSchema13
|
|
2633
2690
|
} from "@sentry/junior-plugin-api";
|
|
2634
|
-
import * as
|
|
2691
|
+
import * as z18 from "zod";
|
|
2635
2692
|
import { subscribableResourceSchema as subscribableResourceSchema9 } from "@sentry/junior-plugin-api";
|
|
2636
|
-
var
|
|
2637
|
-
repo:
|
|
2638
|
-
number:
|
|
2639
|
-
title:
|
|
2640
|
-
body:
|
|
2693
|
+
var inputSchema11 = z18.object({
|
|
2694
|
+
repo: z18.string().describe('Repository in "owner/name" format.'),
|
|
2695
|
+
number: z18.number().int().positive().describe("Pull request number."),
|
|
2696
|
+
title: z18.string().trim().min(1).optional().describe("Replacement pull request title."),
|
|
2697
|
+
body: z18.string().optional().describe(
|
|
2641
2698
|
"Replacement pull request body. The runtime appends requester attribution and the conversation footer."
|
|
2642
2699
|
),
|
|
2643
|
-
base:
|
|
2644
|
-
state:
|
|
2645
|
-
draft:
|
|
2700
|
+
base: z18.string().trim().min(1).optional().describe("Replacement base branch."),
|
|
2701
|
+
state: z18.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
|
|
2702
|
+
draft: z18.boolean().optional().describe(
|
|
2646
2703
|
"Set false to mark a draft pull request ready for review, or true to convert it back to a draft."
|
|
2647
2704
|
)
|
|
2648
2705
|
}).strict().refine(
|
|
@@ -2657,29 +2714,29 @@ var CONVERT_TO_DRAFT = {
|
|
|
2657
2714
|
operationName: "ConvertPullRequestToDraft",
|
|
2658
2715
|
query: "mutation ConvertPullRequestToDraft($id: ID!) { result: convertPullRequestToDraft(input: {pullRequestId: $id}) { pullRequest { isDraft } } }"
|
|
2659
2716
|
};
|
|
2660
|
-
var draftMutationResponseSchema =
|
|
2661
|
-
data:
|
|
2662
|
-
result:
|
|
2717
|
+
var draftMutationResponseSchema = z18.object({
|
|
2718
|
+
data: z18.object({
|
|
2719
|
+
result: z18.object({ pullRequest: z18.object({ isDraft: z18.boolean() }) })
|
|
2663
2720
|
})
|
|
2664
2721
|
});
|
|
2665
|
-
var pullRequestSchema2 =
|
|
2666
|
-
base:
|
|
2667
|
-
body:
|
|
2668
|
-
draft:
|
|
2669
|
-
number:
|
|
2670
|
-
state:
|
|
2722
|
+
var pullRequestSchema2 = z18.object({
|
|
2723
|
+
base: z18.string(),
|
|
2724
|
+
body: z18.string().nullable(),
|
|
2725
|
+
draft: z18.boolean(),
|
|
2726
|
+
number: z18.number(),
|
|
2727
|
+
state: z18.string(),
|
|
2671
2728
|
subscribable: subscribableResourceSchema9.optional(),
|
|
2672
|
-
title:
|
|
2673
|
-
url:
|
|
2729
|
+
title: z18.string(),
|
|
2730
|
+
url: z18.string()
|
|
2674
2731
|
});
|
|
2675
|
-
var
|
|
2732
|
+
var outputSchema11 = pluginToolOutputSchema13.merge(
|
|
2676
2733
|
pullRequestSchema2.extend({
|
|
2677
|
-
target:
|
|
2734
|
+
target: z18.literal("updatePullRequest")
|
|
2678
2735
|
})
|
|
2679
2736
|
);
|
|
2680
2737
|
function nonEmptyString5(value, name) {
|
|
2681
2738
|
if (!value?.trim()) {
|
|
2682
|
-
throw new
|
|
2739
|
+
throw new PluginToolInputError13(`${name} is required`);
|
|
2683
2740
|
}
|
|
2684
2741
|
return value.trim();
|
|
2685
2742
|
}
|
|
@@ -2705,7 +2762,7 @@ async function setPullRequestDraft(input) {
|
|
|
2705
2762
|
return isDraft;
|
|
2706
2763
|
}
|
|
2707
2764
|
function createGitHubUpdatePullRequestTool(ctx) {
|
|
2708
|
-
return
|
|
2765
|
+
return definePluginTool13({
|
|
2709
2766
|
annotations: {
|
|
2710
2767
|
destructiveHint: true,
|
|
2711
2768
|
idempotentHint: true,
|
|
@@ -2713,12 +2770,12 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2713
2770
|
readOnlyHint: false
|
|
2714
2771
|
},
|
|
2715
2772
|
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.",
|
|
2716
|
-
inputSchema:
|
|
2717
|
-
outputSchema:
|
|
2773
|
+
inputSchema: inputSchema11,
|
|
2774
|
+
outputSchema: outputSchema11,
|
|
2718
2775
|
async execute(input) {
|
|
2719
|
-
const parsedInput =
|
|
2776
|
+
const parsedInput = inputSchema11.safeParse(input);
|
|
2720
2777
|
if (!parsedInput.success) {
|
|
2721
|
-
throw new
|
|
2778
|
+
throw new PluginToolInputError13(
|
|
2722
2779
|
"Invalid GitHub updatePullRequest input.",
|
|
2723
2780
|
{ cause: parsedInput.error }
|
|
2724
2781
|
);
|
|
@@ -2759,16 +2816,16 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2759
2816
|
`GitHub pull request update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`
|
|
2760
2817
|
);
|
|
2761
2818
|
}
|
|
2762
|
-
const providerResult =
|
|
2763
|
-
base:
|
|
2764
|
-
body:
|
|
2765
|
-
draft:
|
|
2766
|
-
html_url:
|
|
2767
|
-
merged:
|
|
2768
|
-
node_id:
|
|
2769
|
-
number:
|
|
2770
|
-
state:
|
|
2771
|
-
title:
|
|
2819
|
+
const providerResult = z18.object({
|
|
2820
|
+
base: z18.object({ ref: z18.string() }),
|
|
2821
|
+
body: z18.string().nullable().optional().default(null),
|
|
2822
|
+
draft: z18.boolean(),
|
|
2823
|
+
html_url: z18.string(),
|
|
2824
|
+
merged: z18.boolean(),
|
|
2825
|
+
node_id: z18.string().optional(),
|
|
2826
|
+
number: z18.number(),
|
|
2827
|
+
state: z18.string(),
|
|
2828
|
+
title: z18.string()
|
|
2772
2829
|
}).parse(parsed);
|
|
2773
2830
|
if (update.draft !== void 0 && update.draft !== providerResult.draft) {
|
|
2774
2831
|
if (!providerResult.node_id) {
|
|
@@ -2829,11 +2886,11 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2829
2886
|
|
|
2830
2887
|
// src/tools/update-pull-request-feedback.ts
|
|
2831
2888
|
import {
|
|
2832
|
-
definePluginTool as
|
|
2833
|
-
PluginToolInputError as
|
|
2834
|
-
pluginToolOutputSchema as
|
|
2889
|
+
definePluginTool as definePluginTool14,
|
|
2890
|
+
PluginToolInputError as PluginToolInputError14,
|
|
2891
|
+
pluginToolOutputSchema as pluginToolOutputSchema14
|
|
2835
2892
|
} from "@sentry/junior-plugin-api";
|
|
2836
|
-
import * as
|
|
2893
|
+
import * as z19 from "zod";
|
|
2837
2894
|
var STATUS_TO_REACTION_CONTENT = {
|
|
2838
2895
|
reviewing: "eyes",
|
|
2839
2896
|
addressed: "+1",
|
|
@@ -2842,24 +2899,24 @@ var STATUS_TO_REACTION_CONTENT = {
|
|
|
2842
2899
|
var FEEDBACK_REACTION_CONTENTS = new Set(
|
|
2843
2900
|
Object.values(STATUS_TO_REACTION_CONTENT)
|
|
2844
2901
|
);
|
|
2845
|
-
var
|
|
2846
|
-
repo:
|
|
2847
|
-
comment_kind:
|
|
2902
|
+
var inputSchema12 = z19.object({
|
|
2903
|
+
repo: z19.string().describe('Repository in "owner/name" format.'),
|
|
2904
|
+
comment_kind: z19.enum(["conversation", "review"]).describe(
|
|
2848
2905
|
'Comment kind: "conversation" for a pull request conversation comment, "review" for an inline review comment.'
|
|
2849
2906
|
),
|
|
2850
|
-
comment_id:
|
|
2907
|
+
comment_id: z19.number().int().positive().describe(
|
|
2851
2908
|
"GitHub comment id (conversation comment id or inline review comment id)."
|
|
2852
2909
|
),
|
|
2853
|
-
status:
|
|
2910
|
+
status: z19.enum(["addressed", "declined"]).describe(
|
|
2854
2911
|
"Feedback outcome. Maps to a reaction: addressed -> +1, declined -> -1."
|
|
2855
2912
|
)
|
|
2856
2913
|
}).strict();
|
|
2857
|
-
var
|
|
2858
|
-
target:
|
|
2859
|
-
repo:
|
|
2860
|
-
comment_id:
|
|
2861
|
-
status:
|
|
2862
|
-
reaction_id:
|
|
2914
|
+
var outputSchema12 = pluginToolOutputSchema14.extend({
|
|
2915
|
+
target: z19.literal("updatePullRequestFeedback"),
|
|
2916
|
+
repo: z19.string(),
|
|
2917
|
+
comment_id: z19.number(),
|
|
2918
|
+
status: z19.enum(["addressed", "declined"]),
|
|
2919
|
+
reaction_id: z19.number()
|
|
2863
2920
|
});
|
|
2864
2921
|
function pullRequestCommentPath(input) {
|
|
2865
2922
|
const segment = input.commentKind === "conversation" ? "issues" : "pulls";
|
|
@@ -2871,10 +2928,10 @@ function pullRequestCommentReactionsPath(input) {
|
|
|
2871
2928
|
function pullRequestFeedbackReactionContent(status) {
|
|
2872
2929
|
return STATUS_TO_REACTION_CONTENT[status];
|
|
2873
2930
|
}
|
|
2874
|
-
var reactionSchema =
|
|
2875
|
-
id:
|
|
2876
|
-
content:
|
|
2877
|
-
user:
|
|
2931
|
+
var reactionSchema = z19.object({
|
|
2932
|
+
id: z19.number(),
|
|
2933
|
+
content: z19.string(),
|
|
2934
|
+
user: z19.object({ id: z19.number() }).nullable()
|
|
2878
2935
|
});
|
|
2879
2936
|
async function assertBotAuthoredPullRequest(egress, input) {
|
|
2880
2937
|
const commentResponse = await githubApi(egress, {
|
|
@@ -2884,21 +2941,21 @@ async function assertBotAuthoredPullRequest(egress, input) {
|
|
|
2884
2941
|
const commentPayload = commentResponse.body;
|
|
2885
2942
|
if (!commentResponse.ok) {
|
|
2886
2943
|
const message = `GitHub comment lookup failed with HTTP ${commentResponse.status}: ${githubErrorMessage(commentPayload)}`;
|
|
2887
|
-
if (commentResponse.status === 404) throw new
|
|
2944
|
+
if (commentResponse.status === 404) throw new PluginToolInputError14(message);
|
|
2888
2945
|
throw new Error(message);
|
|
2889
2946
|
}
|
|
2890
|
-
const comment =
|
|
2891
|
-
issue_url:
|
|
2892
|
-
pull_request_url:
|
|
2947
|
+
const comment = z19.object({
|
|
2948
|
+
issue_url: z19.string().optional(),
|
|
2949
|
+
pull_request_url: z19.string().optional()
|
|
2893
2950
|
}).safeParse(commentPayload);
|
|
2894
2951
|
const parentUrl = comment.success ? input.commentKind === "conversation" ? comment.data.issue_url : comment.data.pull_request_url : void 0;
|
|
2895
|
-
const
|
|
2896
|
-
if (!
|
|
2952
|
+
const number24 = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
|
|
2953
|
+
if (!number24) {
|
|
2897
2954
|
throw new Error("GitHub comment did not name its issue or pull request.");
|
|
2898
2955
|
}
|
|
2899
2956
|
const pullResponse = await githubApi(egress, {
|
|
2900
2957
|
operation: "github.pull.get",
|
|
2901
|
-
path: `${repoPath(input)}/pulls/${
|
|
2958
|
+
path: `${repoPath(input)}/pulls/${number24}`
|
|
2902
2959
|
});
|
|
2903
2960
|
const pullPayload = pullResponse.body;
|
|
2904
2961
|
if (!pullResponse.ok && pullResponse.status !== 404) {
|
|
@@ -2906,15 +2963,15 @@ async function assertBotAuthoredPullRequest(egress, input) {
|
|
|
2906
2963
|
`GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${githubErrorMessage(pullPayload)}`
|
|
2907
2964
|
);
|
|
2908
2965
|
}
|
|
2909
|
-
const pull =
|
|
2966
|
+
const pull = z19.object({ user: z19.object({ id: z19.number() }).nullable() }).safeParse(pullPayload);
|
|
2910
2967
|
if (!pullResponse.ok || !pull.success || pull.data.user?.id !== input.botUserId) {
|
|
2911
|
-
throw new
|
|
2968
|
+
throw new PluginToolInputError14(
|
|
2912
2969
|
"This bot can only set feedback status on comments on pull requests it authored."
|
|
2913
2970
|
);
|
|
2914
2971
|
}
|
|
2915
2972
|
}
|
|
2916
2973
|
function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
2917
|
-
return
|
|
2974
|
+
return definePluginTool14({
|
|
2918
2975
|
// No action review: the tool checks in code that the bot authored the pull
|
|
2919
2976
|
// request, and it changes only the bot's own reaction, which is reversible.
|
|
2920
2977
|
approvalMode: "approve",
|
|
@@ -2926,12 +2983,12 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2926
2983
|
},
|
|
2927
2984
|
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.",
|
|
2928
2985
|
exposure: "direct",
|
|
2929
|
-
inputSchema:
|
|
2930
|
-
outputSchema:
|
|
2986
|
+
inputSchema: inputSchema12,
|
|
2987
|
+
outputSchema: outputSchema12,
|
|
2931
2988
|
async execute(input) {
|
|
2932
|
-
const parsedInput =
|
|
2989
|
+
const parsedInput = inputSchema12.safeParse(input);
|
|
2933
2990
|
if (!parsedInput.success) {
|
|
2934
|
-
throw new
|
|
2991
|
+
throw new PluginToolInputError14(
|
|
2935
2992
|
"Invalid GitHub updatePullRequestFeedback input.",
|
|
2936
2993
|
{ cause: parsedInput.error }
|
|
2937
2994
|
);
|
|
@@ -2970,7 +3027,7 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2970
3027
|
`GitHub reaction lookup failed with HTTP ${listResponse.status}: ${githubErrorMessage(listPayload)}`
|
|
2971
3028
|
);
|
|
2972
3029
|
}
|
|
2973
|
-
const botReactions =
|
|
3030
|
+
const botReactions = z19.array(reactionSchema).parse(listPayload).filter(
|
|
2974
3031
|
(reaction) => reaction.user?.id === botUserId && FEEDBACK_REACTION_CONTENTS.has(reaction.content)
|
|
2975
3032
|
);
|
|
2976
3033
|
const existing = botReactions.find(
|
|
@@ -3024,28 +3081,28 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
3024
3081
|
|
|
3025
3082
|
// src/tools/resolve-pull-request-review-thread.ts
|
|
3026
3083
|
import {
|
|
3027
|
-
definePluginTool as
|
|
3028
|
-
PluginToolInputError as
|
|
3029
|
-
pluginToolOutputSchema as
|
|
3084
|
+
definePluginTool as definePluginTool15,
|
|
3085
|
+
PluginToolInputError as PluginToolInputError15,
|
|
3086
|
+
pluginToolOutputSchema as pluginToolOutputSchema15
|
|
3030
3087
|
} from "@sentry/junior-plugin-api";
|
|
3031
|
-
import * as
|
|
3032
|
-
var
|
|
3033
|
-
repo:
|
|
3088
|
+
import * as z20 from "zod";
|
|
3089
|
+
var inputSchema13 = z20.object({
|
|
3090
|
+
repo: z20.string().describe(
|
|
3034
3091
|
'Repository in "owner/name" format. Required because GraphQL has no repo path.'
|
|
3035
3092
|
),
|
|
3036
|
-
thread_id:
|
|
3093
|
+
thread_id: z20.string().trim().min(1).describe(
|
|
3037
3094
|
"GitHub pull request review thread node ID (the `threadId` / `id` variable used by `gh api graphql` resolveReviewThread)."
|
|
3038
3095
|
)
|
|
3039
3096
|
}).strict();
|
|
3040
|
-
var
|
|
3041
|
-
target:
|
|
3042
|
-
repo:
|
|
3043
|
-
number:
|
|
3044
|
-
thread_id:
|
|
3045
|
-
resolved:
|
|
3097
|
+
var outputSchema13 = pluginToolOutputSchema15.extend({
|
|
3098
|
+
target: z20.literal("resolvePullRequestReviewThread"),
|
|
3099
|
+
repo: z20.string(),
|
|
3100
|
+
number: z20.number(),
|
|
3101
|
+
thread_id: z20.string(),
|
|
3102
|
+
resolved: z20.boolean()
|
|
3046
3103
|
});
|
|
3047
3104
|
function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
3048
|
-
return
|
|
3105
|
+
return definePluginTool15({
|
|
3049
3106
|
// No action review: the tool checks in code that the bot authored the pull
|
|
3050
3107
|
// request, and it changes only the thread's resolved state, which is
|
|
3051
3108
|
// reversible.
|
|
@@ -3058,12 +3115,12 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3058
3115
|
},
|
|
3059
3116
|
description: "Resolve a GitHub pull request review thread after acting on its feedback. Only works on pull requests the bot authored.",
|
|
3060
3117
|
exposure: "direct",
|
|
3061
|
-
inputSchema:
|
|
3062
|
-
outputSchema:
|
|
3118
|
+
inputSchema: inputSchema13,
|
|
3119
|
+
outputSchema: outputSchema13,
|
|
3063
3120
|
async execute(input) {
|
|
3064
|
-
const parsedInput =
|
|
3121
|
+
const parsedInput = inputSchema13.safeParse(input);
|
|
3065
3122
|
if (!parsedInput.success) {
|
|
3066
|
-
throw new
|
|
3123
|
+
throw new PluginToolInputError15(
|
|
3067
3124
|
"Invalid GitHub resolvePullRequestReviewThread input.",
|
|
3068
3125
|
{ cause: parsedInput.error }
|
|
3069
3126
|
);
|
|
@@ -3102,31 +3159,31 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3102
3159
|
`GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubErrorMessage(lookupPayload)}`
|
|
3103
3160
|
);
|
|
3104
3161
|
}
|
|
3105
|
-
const threadNodeSchema =
|
|
3106
|
-
id:
|
|
3107
|
-
isResolved:
|
|
3108
|
-
pullRequest:
|
|
3109
|
-
author:
|
|
3110
|
-
number:
|
|
3111
|
-
repository:
|
|
3162
|
+
const threadNodeSchema = z20.object({
|
|
3163
|
+
id: z20.string(),
|
|
3164
|
+
isResolved: z20.boolean(),
|
|
3165
|
+
pullRequest: z20.object({
|
|
3166
|
+
author: z20.object({ databaseId: z20.number().optional() }).passthrough().nullable(),
|
|
3167
|
+
number: z20.number(),
|
|
3168
|
+
repository: z20.object({ nameWithOwner: z20.string() }).passthrough()
|
|
3112
3169
|
}).passthrough()
|
|
3113
3170
|
}).passthrough();
|
|
3114
|
-
const lookupResultSchema =
|
|
3115
|
-
data:
|
|
3116
|
-
node:
|
|
3171
|
+
const lookupResultSchema = z20.object({
|
|
3172
|
+
data: z20.object({
|
|
3173
|
+
node: z20.unknown().nullable().optional()
|
|
3117
3174
|
}).passthrough()
|
|
3118
3175
|
}).passthrough();
|
|
3119
3176
|
const lookupResult = lookupResultSchema.safeParse(lookupPayload);
|
|
3120
3177
|
const rawNode = lookupResult.success ? lookupResult.data.data.node : void 0;
|
|
3121
3178
|
const parsedNode = rawNode == null ? void 0 : threadNodeSchema.safeParse(rawNode);
|
|
3122
3179
|
if (!parsedNode?.success) {
|
|
3123
|
-
throw new
|
|
3180
|
+
throw new PluginToolInputError15("GitHub review thread was not found.");
|
|
3124
3181
|
}
|
|
3125
3182
|
const thread = parsedNode.data;
|
|
3126
3183
|
const pullRequest = thread.pullRequest;
|
|
3127
3184
|
const ownsPullRequest = pullRequest.repository.nameWithOwner.toLowerCase() === repo.ref.toLowerCase() && pullRequest.author?.databaseId === botUserId;
|
|
3128
3185
|
if (!ownsPullRequest) {
|
|
3129
|
-
throw new
|
|
3186
|
+
throw new PluginToolInputError15(
|
|
3130
3187
|
"This bot can only resolve review threads on pull requests it authored."
|
|
3131
3188
|
);
|
|
3132
3189
|
}
|
|
@@ -3160,10 +3217,10 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3160
3217
|
`GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubErrorMessage(resolvePayload)}`
|
|
3161
3218
|
);
|
|
3162
3219
|
}
|
|
3163
|
-
const resolveResultSchema =
|
|
3164
|
-
data:
|
|
3165
|
-
resolveReviewThread:
|
|
3166
|
-
thread:
|
|
3220
|
+
const resolveResultSchema = z20.object({
|
|
3221
|
+
data: z20.object({
|
|
3222
|
+
resolveReviewThread: z20.object({
|
|
3223
|
+
thread: z20.object({ id: z20.string(), isResolved: z20.boolean() }).passthrough()
|
|
3167
3224
|
}).passthrough()
|
|
3168
3225
|
}).passthrough()
|
|
3169
3226
|
}).passthrough();
|
|
@@ -3191,46 +3248,46 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3191
3248
|
|
|
3192
3249
|
// src/tools/submit-pull-request-review.ts
|
|
3193
3250
|
import {
|
|
3194
|
-
definePluginTool as
|
|
3195
|
-
PluginToolInputError as
|
|
3196
|
-
pluginToolOutputSchema as
|
|
3251
|
+
definePluginTool as definePluginTool16,
|
|
3252
|
+
PluginToolInputError as PluginToolInputError16,
|
|
3253
|
+
pluginToolOutputSchema as pluginToolOutputSchema16
|
|
3197
3254
|
} from "@sentry/junior-plugin-api";
|
|
3198
|
-
import * as
|
|
3199
|
-
var reviewCommentSchema =
|
|
3200
|
-
path:
|
|
3201
|
-
body:
|
|
3202
|
-
line:
|
|
3203
|
-
side:
|
|
3204
|
-
start_line:
|
|
3205
|
-
start_side:
|
|
3255
|
+
import * as z21 from "zod";
|
|
3256
|
+
var reviewCommentSchema = z21.object({
|
|
3257
|
+
path: z21.string().trim().min(1).describe("File path in the pull request."),
|
|
3258
|
+
body: z21.string().trim().min(1).describe("Inline review comment."),
|
|
3259
|
+
line: z21.number().int().positive().describe("Line in the pull request diff."),
|
|
3260
|
+
side: z21.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
|
|
3261
|
+
start_line: z21.number().int().positive().optional().describe("First line of a multi-line comment."),
|
|
3262
|
+
start_side: z21.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
|
|
3206
3263
|
}).strict().refine(
|
|
3207
3264
|
({ start_line, start_side }) => start_line === void 0 === (start_side === void 0),
|
|
3208
3265
|
{ message: "start_line and start_side must be provided together." }
|
|
3209
3266
|
);
|
|
3210
|
-
var
|
|
3211
|
-
repo:
|
|
3212
|
-
number:
|
|
3213
|
-
event:
|
|
3214
|
-
body:
|
|
3215
|
-
comments:
|
|
3267
|
+
var inputSchema14 = z21.object({
|
|
3268
|
+
repo: z21.string().describe('Repository in "owner/name" format.'),
|
|
3269
|
+
number: z21.number().int().positive().describe("Pull request number."),
|
|
3270
|
+
event: z21.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
|
|
3271
|
+
body: z21.string().trim().min(1).describe("Review summary."),
|
|
3272
|
+
comments: z21.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
|
|
3216
3273
|
}).strict();
|
|
3217
|
-
var
|
|
3218
|
-
target:
|
|
3219
|
-
repo:
|
|
3220
|
-
number:
|
|
3221
|
-
review_id:
|
|
3222
|
-
state:
|
|
3223
|
-
url:
|
|
3274
|
+
var outputSchema14 = pluginToolOutputSchema16.extend({
|
|
3275
|
+
target: z21.literal("submitPullRequestReview"),
|
|
3276
|
+
repo: z21.string(),
|
|
3277
|
+
number: z21.number(),
|
|
3278
|
+
review_id: z21.number(),
|
|
3279
|
+
state: z21.string(),
|
|
3280
|
+
url: z21.string()
|
|
3224
3281
|
});
|
|
3225
3282
|
function throwReviewError(status, body) {
|
|
3226
3283
|
const message = `GitHub pull request review failed with HTTP ${status}: ${githubErrorMessage(body)}`;
|
|
3227
3284
|
if (status === 404 || status === 422) {
|
|
3228
|
-
throw new
|
|
3285
|
+
throw new PluginToolInputError16(message);
|
|
3229
3286
|
}
|
|
3230
3287
|
throw new Error(message);
|
|
3231
3288
|
}
|
|
3232
3289
|
function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
3233
|
-
return
|
|
3290
|
+
return definePluginTool16({
|
|
3234
3291
|
annotations: {
|
|
3235
3292
|
destructiveHint: true,
|
|
3236
3293
|
idempotentHint: false,
|
|
@@ -3238,9 +3295,8 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3238
3295
|
readOnlyHint: false
|
|
3239
3296
|
},
|
|
3240
3297
|
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.",
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
outputSchema: outputSchema13,
|
|
3298
|
+
inputSchema: inputSchema14,
|
|
3299
|
+
outputSchema: outputSchema14,
|
|
3244
3300
|
async execute(review) {
|
|
3245
3301
|
const repo = parseRepo(review.repo);
|
|
3246
3302
|
const comments = review.comments?.map((comment) => ({
|
|
@@ -3264,11 +3320,12 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3264
3320
|
if (!response.ok) {
|
|
3265
3321
|
throwReviewError(response.status, response.body);
|
|
3266
3322
|
}
|
|
3267
|
-
const providerResult =
|
|
3323
|
+
const providerResult = z21.object({ id: z21.number(), html_url: z21.string(), state: z21.string() }).parse(response.body);
|
|
3268
3324
|
return {
|
|
3269
3325
|
target: "submitPullRequestReview",
|
|
3270
3326
|
repo: repo.ref,
|
|
3271
3327
|
number: review.number,
|
|
3328
|
+
reply: { text: review.body, url: providerResult.html_url },
|
|
3272
3329
|
review_id: providerResult.id,
|
|
3273
3330
|
state: providerResult.state,
|
|
3274
3331
|
url: providerResult.html_url
|
|
@@ -3281,6 +3338,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3281
3338
|
function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
3282
3339
|
return {
|
|
3283
3340
|
cloneRepository: createGitHubCloneRepositoryTool(ctx),
|
|
3341
|
+
commentOnIssue: createGitHubCommentOnIssueTool(ctx.egress),
|
|
3284
3342
|
commentOnPullRequest: createGitHubCommentOnPullRequestTool(ctx.egress),
|
|
3285
3343
|
createIssue: createGitHubIssueTool(ctx),
|
|
3286
3344
|
createPullRequest: createGitHubPullRequestTool(
|
|
@@ -3308,26 +3366,26 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
3308
3366
|
|
|
3309
3367
|
// src/webhooks/handler.ts
|
|
3310
3368
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
3311
|
-
import * as
|
|
3369
|
+
import * as z31 from "zod";
|
|
3312
3370
|
|
|
3313
3371
|
// src/issue-outcomes/store.ts
|
|
3314
3372
|
import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
|
|
3315
|
-
import * as
|
|
3316
|
-
var githubIssueOutcomeInputSchema =
|
|
3317
|
-
candidateOwned:
|
|
3318
|
-
closedAt:
|
|
3319
|
-
issueId:
|
|
3320
|
-
number:
|
|
3321
|
-
openedAt:
|
|
3322
|
-
repositoryFullName:
|
|
3323
|
-
repositoryId:
|
|
3373
|
+
import * as z22 from "zod";
|
|
3374
|
+
var githubIssueOutcomeInputSchema = z22.object({
|
|
3375
|
+
candidateOwned: z22.boolean(),
|
|
3376
|
+
closedAt: z22.date().optional(),
|
|
3377
|
+
issueId: z22.string().min(1),
|
|
3378
|
+
number: z22.number().int().positive(),
|
|
3379
|
+
openedAt: z22.date(),
|
|
3380
|
+
repositoryFullName: z22.string().min(1),
|
|
3381
|
+
repositoryId: z22.string().min(1),
|
|
3324
3382
|
state: githubIssueStateSchema,
|
|
3325
3383
|
stateReason: githubIssueStateReasonSchema.optional(),
|
|
3326
|
-
updatedAt:
|
|
3384
|
+
updatedAt: z22.date()
|
|
3327
3385
|
}).strict();
|
|
3328
|
-
var githubIssueConversationsInputSchema =
|
|
3329
|
-
conversationIds:
|
|
3330
|
-
issueId:
|
|
3386
|
+
var githubIssueConversationsInputSchema = z22.object({
|
|
3387
|
+
conversationIds: z22.array(z22.string().min(1)).min(1),
|
|
3388
|
+
issueId: z22.string().min(1)
|
|
3331
3389
|
}).strict();
|
|
3332
3390
|
function projectionValues(input) {
|
|
3333
3391
|
return {
|
|
@@ -3391,33 +3449,33 @@ async function recordGitHubIssueConversations(db, input) {
|
|
|
3391
3449
|
|
|
3392
3450
|
// src/pull-request-outcomes/store.ts
|
|
3393
3451
|
import { and as and3, eq as eq3, lte as lte2, ne, sql as sql3 } from "drizzle-orm";
|
|
3394
|
-
import * as
|
|
3395
|
-
var githubPullRequestOutcomeInputSchema =
|
|
3396
|
-
candidateOwned:
|
|
3397
|
-
closedAt:
|
|
3452
|
+
import * as z23 from "zod";
|
|
3453
|
+
var githubPullRequestOutcomeInputSchema = z23.object({
|
|
3454
|
+
candidateOwned: z23.boolean(),
|
|
3455
|
+
closedAt: z23.date().optional(),
|
|
3398
3456
|
commitComposition: githubPullRequestCommitCompositionSchema.optional(),
|
|
3399
|
-
mergedAt:
|
|
3400
|
-
number:
|
|
3401
|
-
openedAt:
|
|
3402
|
-
pullRequestId:
|
|
3403
|
-
repositoryFullName:
|
|
3404
|
-
repositoryId:
|
|
3457
|
+
mergedAt: z23.date().optional(),
|
|
3458
|
+
number: z23.number().int().positive(),
|
|
3459
|
+
openedAt: z23.date(),
|
|
3460
|
+
pullRequestId: z23.string().min(1),
|
|
3461
|
+
repositoryFullName: z23.string().min(1),
|
|
3462
|
+
repositoryId: z23.string().min(1),
|
|
3405
3463
|
state: githubPullRequestStateSchema,
|
|
3406
|
-
title:
|
|
3407
|
-
updatedAt:
|
|
3464
|
+
title: z23.string().min(1).optional(),
|
|
3465
|
+
updatedAt: z23.date()
|
|
3408
3466
|
}).strict();
|
|
3409
|
-
var githubPullRequestConversationsInputSchema =
|
|
3410
|
-
conversationIds:
|
|
3411
|
-
pullRequestId:
|
|
3467
|
+
var githubPullRequestConversationsInputSchema = z23.object({
|
|
3468
|
+
conversationIds: z23.array(z23.string().min(1)).min(1),
|
|
3469
|
+
pullRequestId: z23.string().min(1)
|
|
3412
3470
|
}).strict();
|
|
3413
|
-
var githubPullRequestLinkedIssuesInputSchema =
|
|
3414
|
-
linkedIssues:
|
|
3415
|
-
|
|
3416
|
-
number:
|
|
3417
|
-
repositoryFullName:
|
|
3471
|
+
var githubPullRequestLinkedIssuesInputSchema = z23.object({
|
|
3472
|
+
linkedIssues: z23.array(
|
|
3473
|
+
z23.object({
|
|
3474
|
+
number: z23.number().int().positive(),
|
|
3475
|
+
repositoryFullName: z23.string().min(1)
|
|
3418
3476
|
}).strict()
|
|
3419
3477
|
).min(1),
|
|
3420
|
-
pullRequestId:
|
|
3478
|
+
pullRequestId: z23.string().min(1)
|
|
3421
3479
|
}).strict();
|
|
3422
3480
|
function projectionValues2(input) {
|
|
3423
3481
|
return {
|
|
@@ -3622,39 +3680,39 @@ async function releaseGitHubPullRequestReadySync(db, target, claim) {
|
|
|
3622
3680
|
}
|
|
3623
3681
|
|
|
3624
3682
|
// src/webhooks/issue-outcome.ts
|
|
3625
|
-
import * as
|
|
3626
|
-
var canonicalIssueOutcomeSchema =
|
|
3627
|
-
action:
|
|
3628
|
-
issue:
|
|
3629
|
-
body:
|
|
3630
|
-
closed_at:
|
|
3631
|
-
created_at:
|
|
3632
|
-
id:
|
|
3633
|
-
number:
|
|
3683
|
+
import * as z24 from "zod";
|
|
3684
|
+
var canonicalIssueOutcomeSchema = z24.object({
|
|
3685
|
+
action: z24.enum(["opened", "closed", "reopened"]),
|
|
3686
|
+
issue: z24.object({
|
|
3687
|
+
body: z24.string().nullable().optional(),
|
|
3688
|
+
closed_at: z24.string().nullable().optional(),
|
|
3689
|
+
created_at: z24.string(),
|
|
3690
|
+
id: z24.number().int().positive(),
|
|
3691
|
+
number: z24.number().int().positive(),
|
|
3634
3692
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3635
|
-
updated_at:
|
|
3636
|
-
user:
|
|
3693
|
+
updated_at: z24.string(),
|
|
3694
|
+
user: z24.object({ login: z24.string().min(1) }).strict()
|
|
3637
3695
|
}).strict(),
|
|
3638
|
-
repository:
|
|
3639
|
-
full_name:
|
|
3640
|
-
id:
|
|
3696
|
+
repository: z24.object({
|
|
3697
|
+
full_name: z24.string().min(1),
|
|
3698
|
+
id: z24.number().int().positive()
|
|
3641
3699
|
}).strict()
|
|
3642
3700
|
}).strict();
|
|
3643
|
-
var issueOutcomeSchema =
|
|
3644
|
-
action:
|
|
3645
|
-
issue:
|
|
3646
|
-
body:
|
|
3647
|
-
closed_at:
|
|
3648
|
-
created_at:
|
|
3649
|
-
id:
|
|
3650
|
-
number:
|
|
3701
|
+
var issueOutcomeSchema = z24.object({
|
|
3702
|
+
action: z24.enum(["opened", "closed", "reopened"]),
|
|
3703
|
+
issue: z24.object({
|
|
3704
|
+
body: z24.string().nullable().optional(),
|
|
3705
|
+
closed_at: z24.string().nullable().optional(),
|
|
3706
|
+
created_at: z24.string(),
|
|
3707
|
+
id: z24.number().int().positive(),
|
|
3708
|
+
number: z24.number().int().positive(),
|
|
3651
3709
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3652
|
-
updated_at:
|
|
3653
|
-
user:
|
|
3710
|
+
updated_at: z24.string(),
|
|
3711
|
+
user: z24.object({ login: z24.string().min(1) }).passthrough()
|
|
3654
3712
|
}).passthrough(),
|
|
3655
|
-
repository:
|
|
3656
|
-
full_name:
|
|
3657
|
-
id:
|
|
3713
|
+
repository: z24.object({
|
|
3714
|
+
full_name: z24.string().min(1),
|
|
3715
|
+
id: z24.number().int().positive()
|
|
3658
3716
|
}).passthrough()
|
|
3659
3717
|
}).passthrough().transform(
|
|
3660
3718
|
(provider) => canonicalIssueOutcomeSchema.parse({
|
|
@@ -3675,7 +3733,7 @@ var issueOutcomeSchema = z23.object({
|
|
|
3675
3733
|
}
|
|
3676
3734
|
})
|
|
3677
3735
|
);
|
|
3678
|
-
var issueLifecycleActionSchema =
|
|
3736
|
+
var issueLifecycleActionSchema = z24.object({ action: z24.string() }).passthrough();
|
|
3679
3737
|
function timestamp2(value) {
|
|
3680
3738
|
if (!value) return void 0;
|
|
3681
3739
|
const parsed = new Date(value);
|
|
@@ -3719,21 +3777,21 @@ function normalizeGitHubIssueOutcome(args) {
|
|
|
3719
3777
|
updatedAt
|
|
3720
3778
|
};
|
|
3721
3779
|
}
|
|
3722
|
-
var canonicalIssueConversationSchema =
|
|
3723
|
-
issue:
|
|
3724
|
-
body:
|
|
3725
|
-
id:
|
|
3726
|
-
user:
|
|
3780
|
+
var canonicalIssueConversationSchema = z24.object({
|
|
3781
|
+
issue: z24.object({
|
|
3782
|
+
body: z24.string().nullable().optional(),
|
|
3783
|
+
id: z24.number().int().positive(),
|
|
3784
|
+
user: z24.object({ login: z24.string().min(1) }).strict()
|
|
3727
3785
|
}).strict(),
|
|
3728
|
-
sender:
|
|
3786
|
+
sender: z24.object({ login: z24.string().min(1) }).strict().optional()
|
|
3729
3787
|
}).strict();
|
|
3730
|
-
var issueConversationSchema =
|
|
3731
|
-
issue:
|
|
3732
|
-
body:
|
|
3733
|
-
id:
|
|
3734
|
-
user:
|
|
3788
|
+
var issueConversationSchema = z24.object({
|
|
3789
|
+
issue: z24.object({
|
|
3790
|
+
body: z24.string().nullable().optional(),
|
|
3791
|
+
id: z24.number().int().positive(),
|
|
3792
|
+
user: z24.object({ login: z24.string().min(1) }).passthrough()
|
|
3735
3793
|
}).passthrough(),
|
|
3736
|
-
sender:
|
|
3794
|
+
sender: z24.object({ login: z24.string().min(1) }).passthrough().optional()
|
|
3737
3795
|
}).passthrough().transform(
|
|
3738
3796
|
(provider) => canonicalIssueConversationSchema.parse({
|
|
3739
3797
|
issue: {
|
|
@@ -3760,43 +3818,43 @@ function normalizeGitHubIssueConversations(args) {
|
|
|
3760
3818
|
}
|
|
3761
3819
|
|
|
3762
3820
|
// src/webhooks/pull-request-outcome.ts
|
|
3763
|
-
import * as
|
|
3764
|
-
var canonicalPullRequestOutcomeSchema =
|
|
3765
|
-
action:
|
|
3766
|
-
pull_request:
|
|
3767
|
-
body:
|
|
3768
|
-
closed_at:
|
|
3769
|
-
created_at:
|
|
3770
|
-
id:
|
|
3771
|
-
merged:
|
|
3772
|
-
merged_at:
|
|
3773
|
-
number:
|
|
3774
|
-
title:
|
|
3775
|
-
updated_at:
|
|
3776
|
-
user:
|
|
3821
|
+
import * as z25 from "zod";
|
|
3822
|
+
var canonicalPullRequestOutcomeSchema = z25.object({
|
|
3823
|
+
action: z25.enum(["opened", "closed", "reopened"]),
|
|
3824
|
+
pull_request: z25.object({
|
|
3825
|
+
body: z25.string().nullable().optional(),
|
|
3826
|
+
closed_at: z25.string().nullable().optional(),
|
|
3827
|
+
created_at: z25.string(),
|
|
3828
|
+
id: z25.number().int().positive(),
|
|
3829
|
+
merged: z25.boolean(),
|
|
3830
|
+
merged_at: z25.string().nullable().optional(),
|
|
3831
|
+
number: z25.number().int().positive(),
|
|
3832
|
+
title: z25.string().min(1).optional(),
|
|
3833
|
+
updated_at: z25.string(),
|
|
3834
|
+
user: z25.object({ login: z25.string().min(1) }).strict()
|
|
3777
3835
|
}).strict(),
|
|
3778
|
-
repository:
|
|
3779
|
-
full_name:
|
|
3780
|
-
id:
|
|
3836
|
+
repository: z25.object({
|
|
3837
|
+
full_name: z25.string().min(1),
|
|
3838
|
+
id: z25.number().int().positive()
|
|
3781
3839
|
}).strict()
|
|
3782
3840
|
}).strict();
|
|
3783
|
-
var pullRequestOutcomeSchema =
|
|
3784
|
-
action:
|
|
3785
|
-
pull_request:
|
|
3786
|
-
body:
|
|
3787
|
-
closed_at:
|
|
3788
|
-
created_at:
|
|
3789
|
-
id:
|
|
3790
|
-
merged:
|
|
3791
|
-
merged_at:
|
|
3792
|
-
number:
|
|
3793
|
-
title:
|
|
3794
|
-
updated_at:
|
|
3795
|
-
user:
|
|
3841
|
+
var pullRequestOutcomeSchema = z25.object({
|
|
3842
|
+
action: z25.enum(["opened", "closed", "reopened"]),
|
|
3843
|
+
pull_request: z25.object({
|
|
3844
|
+
body: z25.string().nullable().optional(),
|
|
3845
|
+
closed_at: z25.string().nullable().optional(),
|
|
3846
|
+
created_at: z25.string(),
|
|
3847
|
+
id: z25.number().int().positive(),
|
|
3848
|
+
merged: z25.boolean(),
|
|
3849
|
+
merged_at: z25.string().nullable().optional(),
|
|
3850
|
+
number: z25.number().int().positive(),
|
|
3851
|
+
title: z25.string().min(1).optional(),
|
|
3852
|
+
updated_at: z25.string(),
|
|
3853
|
+
user: z25.object({ login: z25.string().min(1) }).passthrough()
|
|
3796
3854
|
}).passthrough(),
|
|
3797
|
-
repository:
|
|
3798
|
-
full_name:
|
|
3799
|
-
id:
|
|
3855
|
+
repository: z25.object({
|
|
3856
|
+
full_name: z25.string().min(1),
|
|
3857
|
+
id: z25.number().int().positive()
|
|
3800
3858
|
}).passthrough()
|
|
3801
3859
|
}).passthrough().transform(
|
|
3802
3860
|
(provider) => canonicalPullRequestOutcomeSchema.parse({
|
|
@@ -3819,24 +3877,24 @@ var pullRequestOutcomeSchema = z24.object({
|
|
|
3819
3877
|
}
|
|
3820
3878
|
})
|
|
3821
3879
|
);
|
|
3822
|
-
var pullRequestLifecycleActionSchema =
|
|
3823
|
-
var canonicalPullRequestConversationSchema =
|
|
3824
|
-
pull_request:
|
|
3825
|
-
body:
|
|
3826
|
-
id:
|
|
3827
|
-
user:
|
|
3880
|
+
var pullRequestLifecycleActionSchema = z25.object({ action: z25.string() }).passthrough();
|
|
3881
|
+
var canonicalPullRequestConversationSchema = z25.object({
|
|
3882
|
+
pull_request: z25.object({
|
|
3883
|
+
body: z25.string().nullable().optional(),
|
|
3884
|
+
id: z25.number().int().positive(),
|
|
3885
|
+
user: z25.object({ login: z25.string().min(1) }).strict()
|
|
3828
3886
|
}).strict(),
|
|
3829
|
-
repository:
|
|
3830
|
-
sender:
|
|
3887
|
+
repository: z25.object({ full_name: z25.string().min(1) }).strict(),
|
|
3888
|
+
sender: z25.object({ login: z25.string().min(1) }).strict()
|
|
3831
3889
|
}).strict();
|
|
3832
|
-
var pullRequestConversationSchema =
|
|
3833
|
-
pull_request:
|
|
3834
|
-
body:
|
|
3835
|
-
id:
|
|
3836
|
-
user:
|
|
3890
|
+
var pullRequestConversationSchema = z25.object({
|
|
3891
|
+
pull_request: z25.object({
|
|
3892
|
+
body: z25.string().nullable().optional(),
|
|
3893
|
+
id: z25.number().int().positive(),
|
|
3894
|
+
user: z25.object({ login: z25.string().min(1) }).passthrough()
|
|
3837
3895
|
}).passthrough(),
|
|
3838
|
-
repository:
|
|
3839
|
-
sender:
|
|
3896
|
+
repository: z25.object({ full_name: z25.string().min(1) }).passthrough(),
|
|
3897
|
+
sender: z25.object({ login: z25.string().min(1) }).passthrough()
|
|
3840
3898
|
}).passthrough().transform(
|
|
3841
3899
|
(provider) => canonicalPullRequestConversationSchema.parse({
|
|
3842
3900
|
pull_request: {
|
|
@@ -3923,20 +3981,20 @@ function normalizeGitHubPullRequestLinkedIssues(args) {
|
|
|
3923
3981
|
}
|
|
3924
3982
|
|
|
3925
3983
|
// src/webhooks/merge-conflict.ts
|
|
3926
|
-
import * as
|
|
3984
|
+
import * as z26 from "zod";
|
|
3927
3985
|
var EVENT_TYPE = "pull_request.merge_conflict";
|
|
3928
3986
|
var CLOSED_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
3929
3987
|
"pull_request.closed_unmerged",
|
|
3930
3988
|
"pull_request.merged"
|
|
3931
3989
|
]);
|
|
3932
|
-
var pullRequestSchema3 =
|
|
3933
|
-
base:
|
|
3934
|
-
number:
|
|
3935
|
-
head:
|
|
3936
|
-
html_url:
|
|
3937
|
-
mergeable:
|
|
3938
|
-
mergeable_state:
|
|
3939
|
-
state:
|
|
3990
|
+
var pullRequestSchema3 = z26.object({
|
|
3991
|
+
base: z26.object({ ref: z26.string().min(1) }),
|
|
3992
|
+
number: z26.number().int().positive().optional(),
|
|
3993
|
+
head: z26.object({ sha: z26.string().min(1) }),
|
|
3994
|
+
html_url: z26.string().min(1).optional(),
|
|
3995
|
+
mergeable: z26.boolean().nullable().optional(),
|
|
3996
|
+
mergeable_state: z26.string().optional(),
|
|
3997
|
+
state: z26.string()
|
|
3940
3998
|
});
|
|
3941
3999
|
function gitHubMergeConflictEvents(input) {
|
|
3942
4000
|
const { conflict } = input;
|
|
@@ -3976,7 +4034,7 @@ async function hasMatch(hasMatchEvent, ref) {
|
|
|
3976
4034
|
return false;
|
|
3977
4035
|
}
|
|
3978
4036
|
function deliveredPullRequest(payload, ref) {
|
|
3979
|
-
const parsed =
|
|
4037
|
+
const parsed = z26.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
|
|
3980
4038
|
const pullRequest = parsed.success ? parsed.data.pull_request : void 0;
|
|
3981
4039
|
return pullRequest?.number === ref.number && typeof pullRequest.mergeable === "boolean" ? pullRequest : void 0;
|
|
3982
4040
|
}
|
|
@@ -4014,10 +4072,10 @@ async function loadGitHubMergeConflictEvents(args) {
|
|
|
4014
4072
|
}
|
|
4015
4073
|
|
|
4016
4074
|
// src/webhooks/pull-request-ready.ts
|
|
4017
|
-
import * as
|
|
4075
|
+
import * as z28 from "zod";
|
|
4018
4076
|
|
|
4019
4077
|
// src/webhooks/installation-requests.ts
|
|
4020
|
-
import * as
|
|
4078
|
+
import * as z27 from "zod";
|
|
4021
4079
|
function splitRepository(fullName, label) {
|
|
4022
4080
|
const [owner, name, ...extra] = fullName.split("/");
|
|
4023
4081
|
if (!owner || !name || extra.length > 0) {
|
|
@@ -4078,9 +4136,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
4078
4136
|
}
|
|
4079
4137
|
);
|
|
4080
4138
|
}
|
|
4081
|
-
var repositoryPermissionSchema =
|
|
4082
|
-
permission:
|
|
4083
|
-
role_name:
|
|
4139
|
+
var repositoryPermissionSchema = z27.object({
|
|
4140
|
+
permission: z27.string().min(1),
|
|
4141
|
+
role_name: z27.string().optional()
|
|
4084
4142
|
});
|
|
4085
4143
|
var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
|
|
4086
4144
|
async function loadRepositoryRole(env, cache, target) {
|
|
@@ -4110,19 +4168,19 @@ async function loadRepositoryRole(env, cache, target) {
|
|
|
4110
4168
|
}
|
|
4111
4169
|
);
|
|
4112
4170
|
}
|
|
4113
|
-
var pullRequestSchema4 =
|
|
4114
|
-
auto_merge:
|
|
4115
|
-
draft:
|
|
4116
|
-
html_url:
|
|
4117
|
-
mergeable_state:
|
|
4118
|
-
merged:
|
|
4119
|
-
state:
|
|
4120
|
-
title:
|
|
4171
|
+
var pullRequestSchema4 = z27.object({
|
|
4172
|
+
auto_merge: z27.object({}).nullable().optional(),
|
|
4173
|
+
draft: z27.boolean().optional(),
|
|
4174
|
+
html_url: z27.string().url(),
|
|
4175
|
+
mergeable_state: z27.string().nullable().optional(),
|
|
4176
|
+
merged: z27.boolean(),
|
|
4177
|
+
state: z27.enum(["open", "closed"]),
|
|
4178
|
+
title: z27.string()
|
|
4121
4179
|
});
|
|
4122
|
-
var reviewsSchema =
|
|
4123
|
-
|
|
4124
|
-
state:
|
|
4125
|
-
user:
|
|
4180
|
+
var reviewsSchema = z27.array(
|
|
4181
|
+
z27.object({
|
|
4182
|
+
state: z27.string(),
|
|
4183
|
+
user: z27.object({ login: z27.string() }).nullable()
|
|
4126
4184
|
})
|
|
4127
4185
|
);
|
|
4128
4186
|
async function loadPullRequestMergeState(env, pullRequest) {
|
|
@@ -4190,10 +4248,10 @@ var READY_ACTIONS = {
|
|
|
4190
4248
|
]),
|
|
4191
4249
|
pull_request_review: /* @__PURE__ */ new Set(["dismissed", "submitted"])
|
|
4192
4250
|
};
|
|
4193
|
-
var pullRequestWebhookSchema =
|
|
4194
|
-
action:
|
|
4195
|
-
pull_request:
|
|
4196
|
-
repository:
|
|
4251
|
+
var pullRequestWebhookSchema = z28.object({
|
|
4252
|
+
action: z28.string(),
|
|
4253
|
+
pull_request: z28.object({ number: z28.number().int().positive() }),
|
|
4254
|
+
repository: z28.object({ full_name: z28.string().min(1) })
|
|
4197
4255
|
});
|
|
4198
4256
|
function pullRequestReadyTargets(eventName, body) {
|
|
4199
4257
|
if (eventName === "check_suite") return checkSuitePullRequests(body);
|
|
@@ -4291,7 +4349,7 @@ async function syncGitHubPullRequestReadyNotices(args) {
|
|
|
4291
4349
|
}
|
|
4292
4350
|
|
|
4293
4351
|
// src/webhooks/pull-request-match-data.ts
|
|
4294
|
-
import * as
|
|
4352
|
+
import * as z29 from "zod";
|
|
4295
4353
|
var LOOKUPS_BY_MATCH_KEY = {
|
|
4296
4354
|
authors: ["authors"],
|
|
4297
4355
|
openerEmail: ["opener"],
|
|
@@ -4299,22 +4357,22 @@ var LOOKUPS_BY_MATCH_KEY = {
|
|
|
4299
4357
|
openerUsername: ["opener"]
|
|
4300
4358
|
};
|
|
4301
4359
|
var ALL_LOOKUPS = ["authors", "opener", "openerRole"];
|
|
4302
|
-
var lookupDataSchema =
|
|
4303
|
-
authors:
|
|
4304
|
-
openerRole:
|
|
4305
|
-
openerUsername:
|
|
4360
|
+
var lookupDataSchema = z29.object({
|
|
4361
|
+
authors: z29.array(z29.string().min(1)).min(1).optional(),
|
|
4362
|
+
openerRole: z29.string().min(1).optional(),
|
|
4363
|
+
openerUsername: z29.string().min(1).optional()
|
|
4306
4364
|
}).strict();
|
|
4307
4365
|
function lookupData(input) {
|
|
4308
4366
|
return lookupDataSchema.parse(definedValues(input));
|
|
4309
4367
|
}
|
|
4310
|
-
var webhookSchema =
|
|
4311
|
-
repository:
|
|
4368
|
+
var webhookSchema = z29.object({
|
|
4369
|
+
repository: z29.object({ full_name: z29.string().min(1) })
|
|
4312
4370
|
});
|
|
4313
4371
|
function pullRequestNumbers(events) {
|
|
4314
4372
|
const numbers = /* @__PURE__ */ new Map();
|
|
4315
4373
|
for (const event of events) {
|
|
4316
|
-
const
|
|
4317
|
-
if (typeof
|
|
4374
|
+
const number24 = event.data?.pullRequest;
|
|
4375
|
+
if (typeof number24 === "number") numbers.set(event.eventKey, number24);
|
|
4318
4376
|
}
|
|
4319
4377
|
return numbers;
|
|
4320
4378
|
}
|
|
@@ -4328,8 +4386,8 @@ function logFailure(context, lookup, error) {
|
|
|
4328
4386
|
}
|
|
4329
4387
|
async function withJuniorOpeners(context, events) {
|
|
4330
4388
|
const botNumber = (event) => {
|
|
4331
|
-
const
|
|
4332
|
-
return
|
|
4389
|
+
const number24 = context.numbers.get(event.eventKey);
|
|
4390
|
+
return number24 !== void 0 && isBotLogin(event.data?.openerUsername, context.botEmail) ? number24 : void 0;
|
|
4333
4391
|
};
|
|
4334
4392
|
const numbers = events.flatMap((event) => botNumber(event) ?? []);
|
|
4335
4393
|
if (numbers.length === 0) return events;
|
|
@@ -4348,9 +4406,9 @@ async function withJuniorOpeners(context, events) {
|
|
|
4348
4406
|
}
|
|
4349
4407
|
}
|
|
4350
4408
|
return events.map((event) => {
|
|
4351
|
-
const
|
|
4352
|
-
if (
|
|
4353
|
-
const identityId = openers.get(
|
|
4409
|
+
const number24 = botNumber(event);
|
|
4410
|
+
if (number24 === void 0) return event;
|
|
4411
|
+
const identityId = openers.get(number24)?.identityId;
|
|
4354
4412
|
const login = identityId ? logins.get(identityId) : void 0;
|
|
4355
4413
|
const {
|
|
4356
4414
|
openerEmail: _email,
|
|
@@ -4372,8 +4430,8 @@ async function withRolesAndAuthors(context, events, lookups) {
|
|
|
4372
4430
|
if (!loadRole && !loadAuthors) return events;
|
|
4373
4431
|
return await Promise.all(
|
|
4374
4432
|
events.map(async (event) => {
|
|
4375
|
-
const
|
|
4376
|
-
if (
|
|
4433
|
+
const number24 = context.numbers.get(event.eventKey);
|
|
4434
|
+
if (number24 === void 0) return event;
|
|
4377
4435
|
const login = event.data?.openerUsername;
|
|
4378
4436
|
if (loadRole && typeof login === "string" && !roles.has(login)) {
|
|
4379
4437
|
roles.set(
|
|
@@ -4383,16 +4441,16 @@ async function withRolesAndAuthors(context, events, lookups) {
|
|
|
4383
4441
|
)
|
|
4384
4442
|
);
|
|
4385
4443
|
}
|
|
4386
|
-
if (loadAuthors && !authors.has(
|
|
4444
|
+
if (loadAuthors && !authors.has(number24)) {
|
|
4387
4445
|
authors.set(
|
|
4388
|
-
|
|
4389
|
-
loadAuthors({ number:
|
|
4446
|
+
number24,
|
|
4447
|
+
loadAuthors({ number: number24, repositoryFullName }).catch(
|
|
4390
4448
|
(error) => logFailure(context, "authors", error)
|
|
4391
4449
|
)
|
|
4392
4450
|
);
|
|
4393
4451
|
}
|
|
4394
4452
|
const role = loadRole && typeof login === "string" ? await roles.get(login) : void 0;
|
|
4395
|
-
const logins = loadAuthors ? await authors.get(
|
|
4453
|
+
const logins = loadAuthors ? await authors.get(number24) : void 0;
|
|
4396
4454
|
if (!role && !logins?.length) return event;
|
|
4397
4455
|
return {
|
|
4398
4456
|
...event,
|
|
@@ -4451,7 +4509,7 @@ async function withGitHubPullRequestMatchData(args) {
|
|
|
4451
4509
|
}
|
|
4452
4510
|
|
|
4453
4511
|
// src/webhooks/pull-request-people.ts
|
|
4454
|
-
import * as
|
|
4512
|
+
import * as z30 from "zod";
|
|
4455
4513
|
var PEOPLE_EVENTS = /* @__PURE__ */ new Set([
|
|
4456
4514
|
"pull_request.review.approved",
|
|
4457
4515
|
"pull_request.merged"
|
|
@@ -4461,18 +4519,18 @@ var PAGE_SIZE = 100;
|
|
|
4461
4519
|
var MAX_PAGES = 3;
|
|
4462
4520
|
var CO_AUTHOR_TRAILER = /^co-authored-by:[^<\n]*<([^>\s]+@[^>\s]+)>\s*$/gim;
|
|
4463
4521
|
var GITHUB_NOREPLY_EMAIL = /^(?:\d+\+)?(?<login>[^@+]+)@users\.noreply\.github\.com$/i;
|
|
4464
|
-
var webhookSchema2 =
|
|
4465
|
-
pull_request:
|
|
4466
|
-
assignees:
|
|
4467
|
-
number:
|
|
4468
|
-
user:
|
|
4522
|
+
var webhookSchema2 = z30.object({
|
|
4523
|
+
pull_request: z30.object({
|
|
4524
|
+
assignees: z30.array(z30.object({ login: z30.string().min(1) })).nullish(),
|
|
4525
|
+
number: z30.number(),
|
|
4526
|
+
user: z30.object({ login: z30.string().min(1) }).nullish()
|
|
4469
4527
|
}),
|
|
4470
|
-
repository:
|
|
4528
|
+
repository: z30.object({ full_name: z30.string().min(1) })
|
|
4471
4529
|
});
|
|
4472
|
-
var commitPageSchema =
|
|
4473
|
-
|
|
4474
|
-
author:
|
|
4475
|
-
commit:
|
|
4530
|
+
var commitPageSchema = z30.array(
|
|
4531
|
+
z30.object({
|
|
4532
|
+
author: z30.object({ login: z30.string().min(1) }).nullish(),
|
|
4533
|
+
commit: z30.object({ message: z30.string() })
|
|
4476
4534
|
})
|
|
4477
4535
|
);
|
|
4478
4536
|
function shareCommitPages(load) {
|
|
@@ -4617,10 +4675,10 @@ function webhookInstallationId(body) {
|
|
|
4617
4675
|
}
|
|
4618
4676
|
return parseInstallationId(installation.id);
|
|
4619
4677
|
}
|
|
4620
|
-
var feedbackTargetSchema =
|
|
4621
|
-
commentId:
|
|
4622
|
-
commentKind:
|
|
4623
|
-
repo:
|
|
4678
|
+
var feedbackTargetSchema = z31.object({
|
|
4679
|
+
commentId: z31.number(),
|
|
4680
|
+
commentKind: z31.enum(["conversation", "review"]),
|
|
4681
|
+
repo: z31.string().min(1)
|
|
4624
4682
|
});
|
|
4625
4683
|
function pullRequestFeedbackTarget(events) {
|
|
4626
4684
|
const event = events.find(
|
|
@@ -4891,30 +4949,30 @@ function gitHubResourceUrl(input) {
|
|
|
4891
4949
|
if (input.resourceType === "repository") {
|
|
4892
4950
|
return `https://github.com/${input.identifier}`;
|
|
4893
4951
|
}
|
|
4894
|
-
const [repo,
|
|
4895
|
-
if (!repo || !
|
|
4952
|
+
const [repo, number24] = input.identifier.split("#");
|
|
4953
|
+
if (!repo || !number24) return void 0;
|
|
4896
4954
|
if (input.resourceType === "pull_request") {
|
|
4897
|
-
return `https://github.com/${repo}/pull/${
|
|
4955
|
+
return `https://github.com/${repo}/pull/${number24}`;
|
|
4898
4956
|
}
|
|
4899
4957
|
if (input.resourceType === "issue") {
|
|
4900
|
-
return `https://github.com/${repo}/issues/${
|
|
4958
|
+
return `https://github.com/${repo}/issues/${number24}`;
|
|
4901
4959
|
}
|
|
4902
4960
|
return void 0;
|
|
4903
4961
|
}
|
|
4904
4962
|
|
|
4905
4963
|
// src/pull-request-outcomes/commit-composition.ts
|
|
4906
|
-
import * as
|
|
4907
|
-
var canonicalCommitSchema =
|
|
4908
|
-
authorEmail:
|
|
4909
|
-
authorLogin:
|
|
4964
|
+
import * as z32 from "zod";
|
|
4965
|
+
var canonicalCommitSchema = z32.object({
|
|
4966
|
+
authorEmail: z32.string().nullable(),
|
|
4967
|
+
authorLogin: z32.string().nullable()
|
|
4910
4968
|
}).strict();
|
|
4911
|
-
var providerCommitSchema =
|
|
4912
|
-
author:
|
|
4913
|
-
commit:
|
|
4914
|
-
author:
|
|
4969
|
+
var providerCommitSchema = z32.object({
|
|
4970
|
+
author: z32.object({ login: z32.string() }).passthrough().nullable(),
|
|
4971
|
+
commit: z32.object({
|
|
4972
|
+
author: z32.object({ email: z32.string() }).passthrough().nullable()
|
|
4915
4973
|
}).passthrough()
|
|
4916
4974
|
}).passthrough();
|
|
4917
|
-
var commitPageSchema2 =
|
|
4975
|
+
var commitPageSchema2 = z32.array(providerCommitSchema).transform(
|
|
4918
4976
|
(commits) => commits.map(
|
|
4919
4977
|
(commit) => canonicalCommitSchema.parse({
|
|
4920
4978
|
authorEmail: commit.commit.author?.email ?? null,
|
|
@@ -5421,8 +5479,8 @@ function linkifyLine(line) {
|
|
|
5421
5479
|
if (isReferenceBoundary(index2 === 0 ? void 0 : line[index2 - 1])) {
|
|
5422
5480
|
const match = GITHUB_ISSUE_REFERENCE_PATTERN.exec(line.slice(index2));
|
|
5423
5481
|
if (match) {
|
|
5424
|
-
const [reference, owner, repository2,
|
|
5425
|
-
output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${
|
|
5482
|
+
const [reference, owner, repository2, number24] = match;
|
|
5483
|
+
output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${number24})`;
|
|
5426
5484
|
index2 += reference.length;
|
|
5427
5485
|
continue;
|
|
5428
5486
|
}
|
|
@@ -5564,9 +5622,9 @@ function parseGitHubReferences(text2, config) {
|
|
|
5564
5622
|
}
|
|
5565
5623
|
return [...references.values()];
|
|
5566
5624
|
}
|
|
5567
|
-
function objectTitle(kind,
|
|
5568
|
-
if (!isRecord(
|
|
5569
|
-
const raw = kind === "commit" ? isRecord(
|
|
5625
|
+
function objectTitle(kind, object32) {
|
|
5626
|
+
if (!isRecord(object32)) return void 0;
|
|
5627
|
+
const raw = kind === "commit" ? isRecord(object32.commit) && typeof object32.commit.message === "string" ? object32.commit.message.split("\n")[0] : void 0 : typeof object32.title === "string" ? object32.title : void 0;
|
|
5570
5628
|
return raw?.replace(/\s+/g, " ").trim() || void 0;
|
|
5571
5629
|
}
|
|
5572
5630
|
async function loadGitHubConversationTitleContext(args) {
|