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