@sentry/junior-github 0.297.0 → 0.298.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -282,13 +282,81 @@ import {
|
|
|
282
282
|
mergeEventMatchFields
|
|
283
283
|
} from "@sentry/junior-plugin-api";
|
|
284
284
|
|
|
285
|
-
// src/tools/
|
|
285
|
+
// src/tools/react-to-issue.ts
|
|
286
286
|
import {
|
|
287
287
|
definePluginTool,
|
|
288
288
|
PluginToolInputError as PluginToolInputError2,
|
|
289
289
|
pluginToolOutputSchema
|
|
290
290
|
} from "@sentry/junior-plugin-api";
|
|
291
291
|
import * as z2 from "zod";
|
|
292
|
+
var REACTION_CONTENTS = [
|
|
293
|
+
"+1",
|
|
294
|
+
"-1",
|
|
295
|
+
"laugh",
|
|
296
|
+
"confused",
|
|
297
|
+
"heart",
|
|
298
|
+
"hooray",
|
|
299
|
+
"rocket",
|
|
300
|
+
"eyes"
|
|
301
|
+
];
|
|
302
|
+
var inputSchema = z2.object({
|
|
303
|
+
repo: z2.string().describe('Repository in "owner/name" format.'),
|
|
304
|
+
number: z2.number().int().positive().describe("Issue or pull request number."),
|
|
305
|
+
content: z2.enum(REACTION_CONTENTS).describe("Reaction to add.")
|
|
306
|
+
}).strict();
|
|
307
|
+
var outputSchema = pluginToolOutputSchema.extend({
|
|
308
|
+
target: z2.literal("reactToIssue"),
|
|
309
|
+
repo: z2.string(),
|
|
310
|
+
number: z2.number(),
|
|
311
|
+
content: z2.enum(REACTION_CONTENTS),
|
|
312
|
+
reaction_id: z2.number()
|
|
313
|
+
});
|
|
314
|
+
function createGitHubReactToIssueTool(egress) {
|
|
315
|
+
return definePluginTool({
|
|
316
|
+
annotations: {
|
|
317
|
+
destructiveHint: false,
|
|
318
|
+
// GitHub returns the existing reaction when the bot already added it.
|
|
319
|
+
idempotentHint: true,
|
|
320
|
+
openWorldHint: true,
|
|
321
|
+
readOnlyHint: false
|
|
322
|
+
},
|
|
323
|
+
description: "React with an emoji to a GitHub issue or pull request itself, for example to show that you started work on it. Reacting again with the same content changes nothing.",
|
|
324
|
+
inputSchema,
|
|
325
|
+
outputSchema,
|
|
326
|
+
async execute(input) {
|
|
327
|
+
const repo = parseRepo(input.repo);
|
|
328
|
+
const response = await githubApi(egress, {
|
|
329
|
+
operation: "github.issue.reaction.create",
|
|
330
|
+
method: "POST",
|
|
331
|
+
path: `${repoPath(repo)}/issues/${input.number}/reactions`,
|
|
332
|
+
body: { content: input.content }
|
|
333
|
+
});
|
|
334
|
+
if (!response.ok) {
|
|
335
|
+
const message = `GitHub issue reaction failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
336
|
+
if (response.status === 404 || response.status === 422) {
|
|
337
|
+
throw new PluginToolInputError2(message);
|
|
338
|
+
}
|
|
339
|
+
throw new Error(message);
|
|
340
|
+
}
|
|
341
|
+
const reaction = z2.object({ id: z2.number() }).parse(response.body);
|
|
342
|
+
return {
|
|
343
|
+
target: "reactToIssue",
|
|
344
|
+
repo: repo.ref,
|
|
345
|
+
number: input.number,
|
|
346
|
+
content: input.content,
|
|
347
|
+
reaction_id: reaction.id
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// src/tools/clone-repository.ts
|
|
354
|
+
import {
|
|
355
|
+
definePluginTool as definePluginTool2,
|
|
356
|
+
PluginToolInputError as PluginToolInputError3,
|
|
357
|
+
pluginToolOutputSchema as pluginToolOutputSchema2
|
|
358
|
+
} from "@sentry/junior-plugin-api";
|
|
359
|
+
import * as z3 from "zod";
|
|
292
360
|
|
|
293
361
|
// src/sandbox-paths.ts
|
|
294
362
|
var RESERVED_SANDBOX_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
@@ -301,9 +369,9 @@ function isReservedSandboxDirectory(path) {
|
|
|
301
369
|
}
|
|
302
370
|
|
|
303
371
|
// src/tools/clone-repository.ts
|
|
304
|
-
var
|
|
305
|
-
repo:
|
|
306
|
-
directory:
|
|
372
|
+
var inputSchema2 = z3.object({
|
|
373
|
+
repo: z3.string().describe('Repository in "owner/name" format.'),
|
|
374
|
+
directory: z3.string().regex(/^(?:[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*)$/).refine(
|
|
307
375
|
(value) => !value.split("/").some((part) => part === "." || part === ".."),
|
|
308
376
|
{
|
|
309
377
|
message: "Directory must be a relative path without . or .. segments."
|
|
@@ -311,24 +379,24 @@ var inputSchema = z2.object({
|
|
|
311
379
|
).describe(
|
|
312
380
|
"Optional destination directory under the sandbox root. Defaults to repos/{name}."
|
|
313
381
|
).optional(),
|
|
314
|
-
allow_ad_hoc:
|
|
382
|
+
allow_ad_hoc: z3.boolean().optional().describe(
|
|
315
383
|
"Set true in the default Sandbox to keep an intentional ad-hoc checkout when matching Workspaces exist. Prefer switchWorkspace; the checkout is already present after a successful switch."
|
|
316
384
|
)
|
|
317
385
|
}).strict();
|
|
318
|
-
var cloneSchema =
|
|
319
|
-
path:
|
|
320
|
-
repo:
|
|
321
|
-
note:
|
|
386
|
+
var cloneSchema = z3.object({
|
|
387
|
+
path: z3.string(),
|
|
388
|
+
repo: z3.string(),
|
|
389
|
+
note: z3.string().optional()
|
|
322
390
|
});
|
|
323
|
-
var
|
|
391
|
+
var outputSchema2 = pluginToolOutputSchema2.merge(
|
|
324
392
|
cloneSchema.extend({
|
|
325
|
-
target:
|
|
393
|
+
target: z3.literal("cloneRepository")
|
|
326
394
|
})
|
|
327
395
|
);
|
|
328
396
|
function parseRepo2(value) {
|
|
329
397
|
const parts = value.split("/").map((part) => part.trim());
|
|
330
398
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
331
|
-
throw new
|
|
399
|
+
throw new PluginToolInputError3('repo must use "owner/name" format');
|
|
332
400
|
}
|
|
333
401
|
return { owner: parts[0], name: parts[1] };
|
|
334
402
|
}
|
|
@@ -338,11 +406,11 @@ function quotedNames(workspaces) {
|
|
|
338
406
|
function workspaceRequiredError(repoId, workspaces) {
|
|
339
407
|
const names = quotedNames(workspaces);
|
|
340
408
|
if (workspaces.length === 1) {
|
|
341
|
-
return new
|
|
409
|
+
return new PluginToolInputError3(
|
|
342
410
|
`Repository ${repoId} is part of Workspace ${names}. Call switchWorkspace with that name; the checkout is already present after the switch. Pass allow_ad_hoc=true only for an intentional ad-hoc checkout.`
|
|
343
411
|
);
|
|
344
412
|
}
|
|
345
|
-
return new
|
|
413
|
+
return new PluginToolInputError3(
|
|
346
414
|
`Repository ${repoId} is part of Workspaces ${names}. Call switchWorkspace with one of those names; the checkout is already present after the switch. Pass allow_ad_hoc=true only for an intentional ad-hoc checkout.`
|
|
347
415
|
);
|
|
348
416
|
}
|
|
@@ -380,7 +448,7 @@ async function removePartialClone(ctx, path) {
|
|
|
380
448
|
}
|
|
381
449
|
}
|
|
382
450
|
function createGitHubCloneRepositoryTool(ctx) {
|
|
383
|
-
return
|
|
451
|
+
return definePluginTool2({
|
|
384
452
|
annotations: {
|
|
385
453
|
// Remote GitHub effect is contents-read only. Sandbox checkout creation is
|
|
386
454
|
// the same class of ephemeral local materialization as webFetch artifacts,
|
|
@@ -397,8 +465,8 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
397
465
|
return directory ? `Shallow-clone ${input.repo} into the local sandbox at ${directory}${adHoc} for inspection (no GitHub mutation).` : `Shallow-clone ${input.repo} into the local sandbox${adHoc} for inspection (no GitHub mutation).`;
|
|
398
466
|
},
|
|
399
467
|
executionMode: "sequential",
|
|
400
|
-
inputSchema,
|
|
401
|
-
outputSchema,
|
|
468
|
+
inputSchema: inputSchema2,
|
|
469
|
+
outputSchema: outputSchema2,
|
|
402
470
|
async execute(input, options) {
|
|
403
471
|
const repo = parseRepo2(input.repo);
|
|
404
472
|
const repoId = `${repo.owner}/${repo.name}`;
|
|
@@ -428,7 +496,7 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
428
496
|
const directory = input.directory ?? defaultDirectory(repo.name);
|
|
429
497
|
const rootSegment = directory.split("/")[0] ?? directory;
|
|
430
498
|
if (isReservedSandboxDirectory(rootSegment)) {
|
|
431
|
-
throw new
|
|
499
|
+
throw new PluginToolInputError3(
|
|
432
500
|
`Directory conflicts with a reserved sandbox path: ${directory}`
|
|
433
501
|
);
|
|
434
502
|
}
|
|
@@ -442,7 +510,7 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
442
510
|
signal: commandSignal(options.signal, 3e4)
|
|
443
511
|
});
|
|
444
512
|
if (mkdir.exitCode !== 0) {
|
|
445
|
-
throw new
|
|
513
|
+
throw new PluginToolInputError3(
|
|
446
514
|
`Failed to create clone parent directory: ${parentDirectory}`
|
|
447
515
|
);
|
|
448
516
|
}
|
|
@@ -454,7 +522,7 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
454
522
|
signal: commandSignal(options.signal, 3e4)
|
|
455
523
|
});
|
|
456
524
|
if (exists.exitCode === 0) {
|
|
457
|
-
throw new
|
|
525
|
+
throw new PluginToolInputError3(`destination already exists: ${path}`);
|
|
458
526
|
}
|
|
459
527
|
let clone;
|
|
460
528
|
try {
|
|
@@ -477,7 +545,7 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
477
545
|
}
|
|
478
546
|
if (clone.exitCode !== 0) {
|
|
479
547
|
await removePartialClone(ctx, path);
|
|
480
|
-
throw new
|
|
548
|
+
throw new PluginToolInputError3(
|
|
481
549
|
`GitHub repository clone failed: ${clone.stderr.trim() || `exit ${clone.exitCode}`}`
|
|
482
550
|
);
|
|
483
551
|
}
|
|
@@ -493,25 +561,25 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
493
561
|
|
|
494
562
|
// src/tools/comment-on-issue.ts
|
|
495
563
|
import {
|
|
496
|
-
definePluginTool as
|
|
497
|
-
PluginToolInputError as
|
|
498
|
-
pluginToolOutputSchema as
|
|
564
|
+
definePluginTool as definePluginTool3,
|
|
565
|
+
PluginToolInputError as PluginToolInputError4,
|
|
566
|
+
pluginToolOutputSchema as pluginToolOutputSchema3
|
|
499
567
|
} from "@sentry/junior-plugin-api";
|
|
500
|
-
import * as
|
|
501
|
-
var
|
|
502
|
-
repo:
|
|
503
|
-
number:
|
|
504
|
-
body:
|
|
568
|
+
import * as z4 from "zod";
|
|
569
|
+
var inputSchema3 = z4.object({
|
|
570
|
+
repo: z4.string().describe('Repository in "owner/name" format.'),
|
|
571
|
+
number: z4.number().int().positive().describe("Issue number."),
|
|
572
|
+
body: z4.string().trim().min(1).describe("Comment text.")
|
|
505
573
|
}).strict();
|
|
506
|
-
var
|
|
507
|
-
target:
|
|
508
|
-
repo:
|
|
509
|
-
number:
|
|
510
|
-
comment_id:
|
|
511
|
-
url:
|
|
574
|
+
var outputSchema3 = pluginToolOutputSchema3.extend({
|
|
575
|
+
target: z4.literal("commentOnIssue"),
|
|
576
|
+
repo: z4.string(),
|
|
577
|
+
number: z4.number(),
|
|
578
|
+
comment_id: z4.number(),
|
|
579
|
+
url: z4.string()
|
|
512
580
|
});
|
|
513
581
|
function createGitHubCommentOnIssueTool(egress) {
|
|
514
|
-
return
|
|
582
|
+
return definePluginTool3({
|
|
515
583
|
annotations: {
|
|
516
584
|
destructiveHint: false,
|
|
517
585
|
idempotentHint: false,
|
|
@@ -519,8 +587,8 @@ function createGitHubCommentOnIssueTool(egress) {
|
|
|
519
587
|
readOnlyHint: false
|
|
520
588
|
},
|
|
521
589
|
description: "Post a comment on a GitHub issue. Returns the comment id and URL.",
|
|
522
|
-
inputSchema:
|
|
523
|
-
outputSchema:
|
|
590
|
+
inputSchema: inputSchema3,
|
|
591
|
+
outputSchema: outputSchema3,
|
|
524
592
|
async execute(input) {
|
|
525
593
|
const repo = parseRepo(input.repo);
|
|
526
594
|
const response = await githubApi(egress, {
|
|
@@ -532,11 +600,11 @@ function createGitHubCommentOnIssueTool(egress) {
|
|
|
532
600
|
if (!response.ok) {
|
|
533
601
|
const message = `GitHub issue comment failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
534
602
|
if (response.status === 404 || response.status === 422) {
|
|
535
|
-
throw new
|
|
603
|
+
throw new PluginToolInputError4(message);
|
|
536
604
|
}
|
|
537
605
|
throw new Error(message);
|
|
538
606
|
}
|
|
539
|
-
const comment =
|
|
607
|
+
const comment = z4.object({ id: z4.number(), html_url: z4.string() }).parse(response.body);
|
|
540
608
|
return {
|
|
541
609
|
target: "commentOnIssue",
|
|
542
610
|
repo: repo.ref,
|
|
@@ -550,25 +618,25 @@ function createGitHubCommentOnIssueTool(egress) {
|
|
|
550
618
|
|
|
551
619
|
// src/tools/comment-on-pull-request.ts
|
|
552
620
|
import {
|
|
553
|
-
definePluginTool as
|
|
554
|
-
PluginToolInputError as
|
|
555
|
-
pluginToolOutputSchema as
|
|
621
|
+
definePluginTool as definePluginTool4,
|
|
622
|
+
PluginToolInputError as PluginToolInputError5,
|
|
623
|
+
pluginToolOutputSchema as pluginToolOutputSchema4
|
|
556
624
|
} from "@sentry/junior-plugin-api";
|
|
557
|
-
import * as
|
|
558
|
-
var
|
|
559
|
-
repo:
|
|
560
|
-
number:
|
|
561
|
-
body:
|
|
562
|
-
in_reply_to:
|
|
625
|
+
import * as z5 from "zod";
|
|
626
|
+
var inputSchema4 = z5.object({
|
|
627
|
+
repo: z5.string().describe('Repository in "owner/name" format.'),
|
|
628
|
+
number: z5.number().int().positive().describe("Pull request number."),
|
|
629
|
+
body: z5.string().trim().min(1).describe("Comment text."),
|
|
630
|
+
in_reply_to: z5.number().int().positive().optional().describe(
|
|
563
631
|
"Inline review comment id. Set it to reply in that comment's thread. Omit it to comment on the pull request."
|
|
564
632
|
)
|
|
565
633
|
}).strict();
|
|
566
|
-
var
|
|
567
|
-
target:
|
|
568
|
-
repo:
|
|
569
|
-
number:
|
|
570
|
-
comment_id:
|
|
571
|
-
url:
|
|
634
|
+
var outputSchema4 = pluginToolOutputSchema4.extend({
|
|
635
|
+
target: z5.literal("commentOnPullRequest"),
|
|
636
|
+
repo: z5.string(),
|
|
637
|
+
number: z5.number(),
|
|
638
|
+
comment_id: z5.number(),
|
|
639
|
+
url: z5.string()
|
|
572
640
|
});
|
|
573
641
|
async function threadRootId(egress, prefix, commentId) {
|
|
574
642
|
const response = await githubApi(egress, {
|
|
@@ -577,14 +645,14 @@ async function threadRootId(egress, prefix, commentId) {
|
|
|
577
645
|
});
|
|
578
646
|
if (!response.ok) {
|
|
579
647
|
const message = `GitHub review comment lookup failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
580
|
-
if (response.status === 404) throw new
|
|
648
|
+
if (response.status === 404) throw new PluginToolInputError5(message);
|
|
581
649
|
throw new Error(message);
|
|
582
650
|
}
|
|
583
|
-
const comment =
|
|
651
|
+
const comment = z5.object({ in_reply_to_id: z5.number().nullish() }).parse(response.body);
|
|
584
652
|
return comment.in_reply_to_id ?? commentId;
|
|
585
653
|
}
|
|
586
654
|
function createGitHubCommentOnPullRequestTool(egress) {
|
|
587
|
-
return
|
|
655
|
+
return definePluginTool4({
|
|
588
656
|
annotations: {
|
|
589
657
|
destructiveHint: false,
|
|
590
658
|
idempotentHint: false,
|
|
@@ -592,8 +660,8 @@ function createGitHubCommentOnPullRequestTool(egress) {
|
|
|
592
660
|
readOnlyHint: false
|
|
593
661
|
},
|
|
594
662
|
description: "Post a conversation comment on a GitHub pull request, or reply in an inline review thread with in_reply_to. For issues, use github_commentOnIssue. Use it to answer a question asked in a pull request review or comment. Returns the comment id and URL.",
|
|
595
|
-
inputSchema:
|
|
596
|
-
outputSchema:
|
|
663
|
+
inputSchema: inputSchema4,
|
|
664
|
+
outputSchema: outputSchema4,
|
|
597
665
|
async execute(input) {
|
|
598
666
|
const repo = parseRepo(input.repo);
|
|
599
667
|
const prefix = repoPath(repo);
|
|
@@ -607,11 +675,11 @@ function createGitHubCommentOnPullRequestTool(egress) {
|
|
|
607
675
|
if (!response.ok) {
|
|
608
676
|
const message = `GitHub pull request comment failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
609
677
|
if (response.status === 404 || response.status === 422) {
|
|
610
|
-
throw new
|
|
678
|
+
throw new PluginToolInputError5(message);
|
|
611
679
|
}
|
|
612
680
|
throw new Error(message);
|
|
613
681
|
}
|
|
614
|
-
const comment =
|
|
682
|
+
const comment = z5.object({ id: z5.number(), html_url: z5.string() }).parse(response.body);
|
|
615
683
|
return {
|
|
616
684
|
target: "commentOnPullRequest",
|
|
617
685
|
repo: repo.ref,
|
|
@@ -625,21 +693,21 @@ function createGitHubCommentOnPullRequestTool(egress) {
|
|
|
625
693
|
}
|
|
626
694
|
|
|
627
695
|
// src/object-facts.ts
|
|
628
|
-
import * as
|
|
629
|
-
var person =
|
|
630
|
-
var responseSchema =
|
|
631
|
-
body:
|
|
696
|
+
import * as z6 from "zod";
|
|
697
|
+
var person = z6.object({ login: z6.string() });
|
|
698
|
+
var responseSchema = z6.object({
|
|
699
|
+
body: z6.string().nullable().optional(),
|
|
632
700
|
user: person.nullable().optional(),
|
|
633
|
-
requested_reviewers:
|
|
634
|
-
assignees:
|
|
635
|
-
labels:
|
|
636
|
-
head:
|
|
637
|
-
base:
|
|
638
|
-
mergeable:
|
|
639
|
-
changed_files:
|
|
640
|
-
additions:
|
|
641
|
-
deletions:
|
|
642
|
-
updated_at:
|
|
701
|
+
requested_reviewers: z6.array(person).optional(),
|
|
702
|
+
assignees: z6.array(person).optional(),
|
|
703
|
+
labels: z6.array(z6.union([z6.string(), z6.object({ name: z6.string() })])).optional(),
|
|
704
|
+
head: z6.object({ ref: z6.string() }).optional(),
|
|
705
|
+
base: z6.object({ ref: z6.string() }).optional(),
|
|
706
|
+
mergeable: z6.boolean().nullable().optional(),
|
|
707
|
+
changed_files: z6.number().int().nonnegative().optional(),
|
|
708
|
+
additions: z6.number().int().nonnegative().optional(),
|
|
709
|
+
deletions: z6.number().int().nonnegative().optional(),
|
|
710
|
+
updated_at: z6.iso.datetime({ offset: true }).optional()
|
|
643
711
|
});
|
|
644
712
|
var short = (value) => {
|
|
645
713
|
const text2 = value?.trim();
|
|
@@ -787,24 +855,24 @@ async function updateGitHubAnnotations(args) {
|
|
|
787
855
|
// src/tools/create-issue.ts
|
|
788
856
|
import {
|
|
789
857
|
objectFactsSchema,
|
|
790
|
-
definePluginTool as
|
|
858
|
+
definePluginTool as definePluginTool5,
|
|
791
859
|
EgressAuthRequired,
|
|
792
|
-
PluginToolInputError as
|
|
860
|
+
PluginToolInputError as PluginToolInputError7,
|
|
793
861
|
subscribableResourceSchema,
|
|
794
|
-
pluginToolOutputSchema as
|
|
862
|
+
pluginToolOutputSchema as pluginToolOutputSchema5
|
|
795
863
|
} from "@sentry/junior-plugin-api";
|
|
796
864
|
import { Type } from "@sinclair/typebox";
|
|
797
865
|
import { Value } from "@sinclair/typebox/value";
|
|
798
|
-
import * as
|
|
866
|
+
import * as z7 from "zod";
|
|
799
867
|
|
|
800
868
|
// src/tools/footer.ts
|
|
801
|
-
import { PluginToolInputError as
|
|
869
|
+
import { PluginToolInputError as PluginToolInputError6 } from "@sentry/junior-plugin-api";
|
|
802
870
|
var GITHUB_SESSION_FOOTER_START = "<!-- junior-session-footer:start -->";
|
|
803
871
|
var GITHUB_SESSION_FOOTER_END = "<!-- junior-session-footer:end -->";
|
|
804
872
|
var GITHUB_CONVERSATION_ID_MARKER = "junior-conversation-id:";
|
|
805
873
|
function nonEmptyString(value, name) {
|
|
806
874
|
if (!value?.trim()) {
|
|
807
|
-
throw new
|
|
875
|
+
throw new PluginToolInputError6(`${name} is required`);
|
|
808
876
|
}
|
|
809
877
|
return value.trim();
|
|
810
878
|
}
|
|
@@ -881,11 +949,11 @@ function githubLinkedIssues(body, repositoryFullName) {
|
|
|
881
949
|
if (!body) return [];
|
|
882
950
|
const references = /* @__PURE__ */ new Map();
|
|
883
951
|
const add = (linkedRepository, rawNumber) => {
|
|
884
|
-
const
|
|
885
|
-
if (!Number.isInteger(
|
|
952
|
+
const number31 = Number.parseInt(rawNumber, 10);
|
|
953
|
+
if (!Number.isInteger(number31) || number31 <= 0) return;
|
|
886
954
|
const normalizedRepository = linkedRepository.toLowerCase();
|
|
887
|
-
references.set(`${normalizedRepository}#${
|
|
888
|
-
number:
|
|
955
|
+
references.set(`${normalizedRepository}#${number31}`, {
|
|
956
|
+
number: number31,
|
|
889
957
|
repositoryFullName: linkedRepository
|
|
890
958
|
});
|
|
891
959
|
};
|
|
@@ -948,11 +1016,11 @@ var createIssueInputSchema = Type.Object(
|
|
|
948
1016
|
},
|
|
949
1017
|
{ additionalProperties: false }
|
|
950
1018
|
);
|
|
951
|
-
var createIssueToolInputSchema =
|
|
952
|
-
repo:
|
|
953
|
-
title:
|
|
954
|
-
body:
|
|
955
|
-
labels:
|
|
1019
|
+
var createIssueToolInputSchema = z7.object({
|
|
1020
|
+
repo: z7.string().describe('Repository in "owner/name" format.'),
|
|
1021
|
+
title: z7.string().describe("Issue title."),
|
|
1022
|
+
body: z7.string().describe("Issue body. The runtime appends the conversation footer.").optional(),
|
|
1023
|
+
labels: z7.array(z7.string()).describe("Labels to apply to the issue.").optional()
|
|
956
1024
|
}).strict();
|
|
957
1025
|
var createIssueStateSchema = Type.Union([
|
|
958
1026
|
Type.Object(
|
|
@@ -977,14 +1045,14 @@ var createIssueStateSchema = Type.Union([
|
|
|
977
1045
|
{ additionalProperties: false }
|
|
978
1046
|
)
|
|
979
1047
|
]);
|
|
980
|
-
var gitHubIssueDataSchema =
|
|
981
|
-
number:
|
|
1048
|
+
var gitHubIssueDataSchema = z7.object({
|
|
1049
|
+
number: z7.number(),
|
|
982
1050
|
subscribable: subscribableResourceSchema.optional(),
|
|
983
|
-
url:
|
|
1051
|
+
url: z7.string()
|
|
984
1052
|
});
|
|
985
|
-
var gitHubIssueOutputSchema =
|
|
1053
|
+
var gitHubIssueOutputSchema = pluginToolOutputSchema5.merge(
|
|
986
1054
|
gitHubIssueDataSchema.extend({
|
|
987
|
-
target:
|
|
1055
|
+
target: z7.literal("createIssue")
|
|
988
1056
|
})
|
|
989
1057
|
);
|
|
990
1058
|
function gitHubIssueToolResult(input, result, canSubscribe) {
|
|
@@ -1021,14 +1089,14 @@ function parseCreateIssueInput(input) {
|
|
|
1021
1089
|
try {
|
|
1022
1090
|
return Value.Parse(createIssueInputSchema, input);
|
|
1023
1091
|
} catch (error) {
|
|
1024
|
-
throw new
|
|
1092
|
+
throw new PluginToolInputError7("Invalid GitHub createIssue input.", {
|
|
1025
1093
|
cause: error
|
|
1026
1094
|
});
|
|
1027
1095
|
}
|
|
1028
1096
|
}
|
|
1029
1097
|
function nonEmptyString2(value, name) {
|
|
1030
1098
|
if (!value?.trim()) {
|
|
1031
|
-
throw new
|
|
1099
|
+
throw new PluginToolInputError7(`${name} is required`);
|
|
1032
1100
|
}
|
|
1033
1101
|
return value.trim();
|
|
1034
1102
|
}
|
|
@@ -1102,7 +1170,7 @@ async function createGitHubIssue(ctx, request) {
|
|
|
1102
1170
|
};
|
|
1103
1171
|
}
|
|
1104
1172
|
function createGitHubIssueTool(ctx) {
|
|
1105
|
-
return
|
|
1173
|
+
return definePluginTool5({
|
|
1106
1174
|
annotations: {
|
|
1107
1175
|
destructiveHint: false,
|
|
1108
1176
|
idempotentHint: true,
|
|
@@ -1195,85 +1263,85 @@ function createGitHubIssueTool(ctx) {
|
|
|
1195
1263
|
|
|
1196
1264
|
// src/tools/get-deployment.ts
|
|
1197
1265
|
import {
|
|
1198
|
-
definePluginTool as
|
|
1199
|
-
PluginToolInputError as
|
|
1200
|
-
pluginToolOutputSchema as
|
|
1266
|
+
definePluginTool as definePluginTool6,
|
|
1267
|
+
PluginToolInputError as PluginToolInputError8,
|
|
1268
|
+
pluginToolOutputSchema as pluginToolOutputSchema6,
|
|
1201
1269
|
subscribableResourceSchema as subscribableResourceSchema2
|
|
1202
1270
|
} from "@sentry/junior-plugin-api";
|
|
1203
|
-
import * as
|
|
1204
|
-
var commitShaSchema =
|
|
1205
|
-
var
|
|
1206
|
-
repo:
|
|
1271
|
+
import * as z8 from "zod";
|
|
1272
|
+
var commitShaSchema = z8.string().regex(/^[0-9a-f]{40}$/i);
|
|
1273
|
+
var inputSchema5 = z8.object({
|
|
1274
|
+
repo: z8.string().describe('Repository in "owner/name" format.'),
|
|
1207
1275
|
commit_sha: commitShaSchema.describe(
|
|
1208
1276
|
"Full 40-character Git commit SHA recorded by the deployment."
|
|
1209
1277
|
),
|
|
1210
|
-
environment:
|
|
1278
|
+
environment: z8.string().trim().min(1).describe(
|
|
1211
1279
|
'Optional GitHub deployment environment, such as "Production". Omit to inspect and watch deployments for the commit across environments.'
|
|
1212
1280
|
).optional()
|
|
1213
1281
|
}).strict();
|
|
1214
|
-
var statusSchema =
|
|
1215
|
-
created_at:
|
|
1216
|
-
creator:
|
|
1217
|
-
description:
|
|
1218
|
-
environment_url:
|
|
1219
|
-
id:
|
|
1220
|
-
log_url:
|
|
1221
|
-
state:
|
|
1282
|
+
var statusSchema = z8.object({
|
|
1283
|
+
created_at: z8.string(),
|
|
1284
|
+
creator: z8.string().nullable(),
|
|
1285
|
+
description: z8.string().nullable(),
|
|
1286
|
+
environment_url: z8.string().nullable(),
|
|
1287
|
+
id: z8.number(),
|
|
1288
|
+
log_url: z8.string().nullable(),
|
|
1289
|
+
state: z8.string()
|
|
1222
1290
|
}).strict();
|
|
1223
|
-
var deploymentSchema =
|
|
1224
|
-
created_at:
|
|
1225
|
-
creator:
|
|
1226
|
-
description:
|
|
1227
|
-
environment:
|
|
1228
|
-
id:
|
|
1291
|
+
var deploymentSchema = z8.object({
|
|
1292
|
+
created_at: z8.string(),
|
|
1293
|
+
creator: z8.string().nullable(),
|
|
1294
|
+
description: z8.string().nullable(),
|
|
1295
|
+
environment: z8.string(),
|
|
1296
|
+
id: z8.number(),
|
|
1229
1297
|
latest_status: statusSchema.nullable(),
|
|
1230
|
-
ref:
|
|
1298
|
+
ref: z8.string(),
|
|
1231
1299
|
sha: commitShaSchema,
|
|
1232
|
-
updated_at:
|
|
1233
|
-
url:
|
|
1300
|
+
updated_at: z8.string(),
|
|
1301
|
+
url: z8.string()
|
|
1234
1302
|
}).strict();
|
|
1235
|
-
var deploymentSourceSchema =
|
|
1303
|
+
var deploymentSourceSchema = z8.object({
|
|
1236
1304
|
commit_sha: commitShaSchema,
|
|
1237
1305
|
deployment: deploymentSchema.nullable(),
|
|
1238
|
-
environment:
|
|
1239
|
-
repo:
|
|
1306
|
+
environment: z8.string().nullable(),
|
|
1307
|
+
repo: z8.string(),
|
|
1240
1308
|
subscribable: subscribableResourceSchema2.optional()
|
|
1241
1309
|
}).strict();
|
|
1242
|
-
var
|
|
1310
|
+
var outputSchema5 = pluginToolOutputSchema6.merge(
|
|
1243
1311
|
deploymentSourceSchema.extend({
|
|
1244
|
-
target:
|
|
1312
|
+
target: z8.literal("getDeployment")
|
|
1245
1313
|
})
|
|
1246
1314
|
);
|
|
1247
|
-
var providerCreatorSchema =
|
|
1248
|
-
var providerDeploymentSchema =
|
|
1249
|
-
created_at:
|
|
1315
|
+
var providerCreatorSchema = z8.object({ login: z8.string() }).passthrough().nullable();
|
|
1316
|
+
var providerDeploymentSchema = z8.object({
|
|
1317
|
+
created_at: z8.string(),
|
|
1250
1318
|
creator: providerCreatorSchema,
|
|
1251
|
-
description:
|
|
1252
|
-
environment:
|
|
1253
|
-
id:
|
|
1254
|
-
ref:
|
|
1319
|
+
description: z8.string().nullable(),
|
|
1320
|
+
environment: z8.string(),
|
|
1321
|
+
id: z8.number(),
|
|
1322
|
+
ref: z8.string(),
|
|
1255
1323
|
sha: commitShaSchema,
|
|
1256
|
-
updated_at:
|
|
1324
|
+
updated_at: z8.string()
|
|
1257
1325
|
}).passthrough();
|
|
1258
|
-
var providerStatusSchema =
|
|
1259
|
-
created_at:
|
|
1326
|
+
var providerStatusSchema = z8.object({
|
|
1327
|
+
created_at: z8.string(),
|
|
1260
1328
|
creator: providerCreatorSchema,
|
|
1261
|
-
description:
|
|
1262
|
-
environment_url:
|
|
1263
|
-
id:
|
|
1264
|
-
log_url:
|
|
1265
|
-
state:
|
|
1329
|
+
description: z8.string().nullable().optional(),
|
|
1330
|
+
environment_url: z8.string().nullable().optional(),
|
|
1331
|
+
id: z8.number(),
|
|
1332
|
+
log_url: z8.string().nullable().optional(),
|
|
1333
|
+
state: z8.string()
|
|
1266
1334
|
}).passthrough();
|
|
1267
1335
|
function throwLookupError(target, status, body) {
|
|
1268
1336
|
const message = `GitHub ${target} lookup failed with HTTP ${status}`;
|
|
1269
1337
|
const hasValidationErrors = body !== null && typeof body === "object" && !Array.isArray(body) && Array.isArray(body.errors) && body.errors.length > 0;
|
|
1270
1338
|
if (target === "deployment" && (status === 404 || status === 422 && hasValidationErrors)) {
|
|
1271
|
-
throw new
|
|
1339
|
+
throw new PluginToolInputError8(message);
|
|
1272
1340
|
}
|
|
1273
1341
|
throw new Error(message);
|
|
1274
1342
|
}
|
|
1275
1343
|
function createGitHubGetDeploymentTool(ctx) {
|
|
1276
|
-
return
|
|
1344
|
+
return definePluginTool6({
|
|
1277
1345
|
annotations: {
|
|
1278
1346
|
destructiveHint: false,
|
|
1279
1347
|
idempotentHint: true,
|
|
@@ -1281,8 +1349,8 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1281
1349
|
readOnlyHint: true
|
|
1282
1350
|
},
|
|
1283
1351
|
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.",
|
|
1284
|
-
inputSchema:
|
|
1285
|
-
outputSchema:
|
|
1352
|
+
inputSchema: inputSchema5,
|
|
1353
|
+
outputSchema: outputSchema5,
|
|
1286
1354
|
async execute(input) {
|
|
1287
1355
|
const repo = parseRepo(input.repo);
|
|
1288
1356
|
const commitSha = input.commit_sha.toLowerCase();
|
|
@@ -1298,7 +1366,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1298
1366
|
if (!deployments.ok) {
|
|
1299
1367
|
throwLookupError("deployment", deployments.status, deployments.body);
|
|
1300
1368
|
}
|
|
1301
|
-
const providerDeployment =
|
|
1369
|
+
const providerDeployment = z8.array(providerDeploymentSchema).parse(deployments.body)[0];
|
|
1302
1370
|
let deployment = null;
|
|
1303
1371
|
if (providerDeployment) {
|
|
1304
1372
|
const statuses = await githubApi(ctx.egress, {
|
|
@@ -1308,7 +1376,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1308
1376
|
if (!statuses.ok) {
|
|
1309
1377
|
throwLookupError("deployment status", statuses.status, statuses.body);
|
|
1310
1378
|
}
|
|
1311
|
-
const providerStatus =
|
|
1379
|
+
const providerStatus = z8.array(providerStatusSchema).parse(statuses.body)[0];
|
|
1312
1380
|
deployment = {
|
|
1313
1381
|
created_at: providerDeployment.created_at,
|
|
1314
1382
|
creator: providerDeployment.creator?.login ?? null,
|
|
@@ -1353,47 +1421,47 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1353
1421
|
|
|
1354
1422
|
// src/tools/get-issue.ts
|
|
1355
1423
|
import {
|
|
1356
|
-
definePluginTool as
|
|
1357
|
-
PluginToolInputError as
|
|
1358
|
-
pluginToolOutputSchema as
|
|
1424
|
+
definePluginTool as definePluginTool7,
|
|
1425
|
+
PluginToolInputError as PluginToolInputError9,
|
|
1426
|
+
pluginToolOutputSchema as pluginToolOutputSchema7,
|
|
1359
1427
|
subscribableResourceSchema as subscribableResourceSchema3
|
|
1360
1428
|
} from "@sentry/junior-plugin-api";
|
|
1361
|
-
import * as
|
|
1429
|
+
import * as z9 from "zod";
|
|
1362
1430
|
var CLAIM_NOTE = "If you start work on this issue, first claim it with github_updateIssue and assign_requester: true.";
|
|
1363
|
-
var
|
|
1364
|
-
repo:
|
|
1365
|
-
number:
|
|
1431
|
+
var inputSchema6 = z9.object({
|
|
1432
|
+
repo: z9.string().describe('Repository in "owner/name" format.'),
|
|
1433
|
+
number: z9.number().int().positive().describe("Issue number.")
|
|
1366
1434
|
}).strict();
|
|
1367
|
-
var issueSchema =
|
|
1368
|
-
assignees:
|
|
1369
|
-
author:
|
|
1370
|
-
body:
|
|
1371
|
-
comments:
|
|
1372
|
-
labels:
|
|
1373
|
-
note:
|
|
1374
|
-
number:
|
|
1375
|
-
state:
|
|
1435
|
+
var issueSchema = z9.object({
|
|
1436
|
+
assignees: z9.array(z9.string()),
|
|
1437
|
+
author: z9.string().optional(),
|
|
1438
|
+
body: z9.string().nullable(),
|
|
1439
|
+
comments: z9.number(),
|
|
1440
|
+
labels: z9.array(z9.string()),
|
|
1441
|
+
note: z9.string().optional(),
|
|
1442
|
+
number: z9.number(),
|
|
1443
|
+
state: z9.string(),
|
|
1376
1444
|
subscribable: subscribableResourceSchema3.optional(),
|
|
1377
|
-
title:
|
|
1378
|
-
url:
|
|
1445
|
+
title: z9.string(),
|
|
1446
|
+
url: z9.string()
|
|
1379
1447
|
});
|
|
1380
|
-
var
|
|
1381
|
-
issueSchema.extend({ target:
|
|
1448
|
+
var outputSchema6 = pluginToolOutputSchema7.merge(
|
|
1449
|
+
issueSchema.extend({ target: z9.literal("getIssue") })
|
|
1382
1450
|
);
|
|
1383
|
-
var providerIssueSchema =
|
|
1384
|
-
assignees:
|
|
1385
|
-
body:
|
|
1386
|
-
comments:
|
|
1387
|
-
html_url:
|
|
1388
|
-
labels:
|
|
1389
|
-
number:
|
|
1390
|
-
repository_url:
|
|
1391
|
-
state:
|
|
1392
|
-
title:
|
|
1393
|
-
user:
|
|
1451
|
+
var providerIssueSchema = z9.object({
|
|
1452
|
+
assignees: z9.array(z9.object({ login: z9.string() })).nullish().transform((assignees) => assignees?.map(({ login: login2 }) => login2) ?? []),
|
|
1453
|
+
body: z9.string().nullable().optional().default(null),
|
|
1454
|
+
comments: z9.number().optional().default(0),
|
|
1455
|
+
html_url: z9.string(),
|
|
1456
|
+
labels: z9.array(z9.object({ name: z9.string() })).optional().default([]).transform((labels) => labels.map(({ name }) => name)),
|
|
1457
|
+
number: z9.number(),
|
|
1458
|
+
repository_url: z9.string().optional(),
|
|
1459
|
+
state: z9.string(),
|
|
1460
|
+
title: z9.string(),
|
|
1461
|
+
user: z9.object({ login: z9.string() }).nullish()
|
|
1394
1462
|
});
|
|
1395
1463
|
function createGitHubGetIssueTool(ctx) {
|
|
1396
|
-
return
|
|
1464
|
+
return definePluginTool7({
|
|
1397
1465
|
annotations: {
|
|
1398
1466
|
destructiveHint: false,
|
|
1399
1467
|
idempotentHint: true,
|
|
@@ -1401,8 +1469,8 @@ function createGitHubGetIssueTool(ctx) {
|
|
|
1401
1469
|
readOnlyHint: true
|
|
1402
1470
|
},
|
|
1403
1471
|
description: "Get a GitHub issue. Read its comments with gh api repos/OWNER/REPO/issues/NUMBER/comments.",
|
|
1404
|
-
inputSchema:
|
|
1405
|
-
outputSchema:
|
|
1472
|
+
inputSchema: inputSchema6,
|
|
1473
|
+
outputSchema: outputSchema6,
|
|
1406
1474
|
async execute(input) {
|
|
1407
1475
|
const repo = parseRepo(input.repo);
|
|
1408
1476
|
const [response, requester] = await Promise.all([
|
|
@@ -1416,7 +1484,7 @@ function createGitHubGetIssueTool(ctx) {
|
|
|
1416
1484
|
if (!response.ok) {
|
|
1417
1485
|
const message = `GitHub issue lookup failed with HTTP ${response.status}`;
|
|
1418
1486
|
if (response.status === 404) {
|
|
1419
|
-
throw new
|
|
1487
|
+
throw new PluginToolInputError9(message);
|
|
1420
1488
|
}
|
|
1421
1489
|
throw new Error(message);
|
|
1422
1490
|
}
|
|
@@ -1467,16 +1535,16 @@ function issueRepoRef(repositoryUrl) {
|
|
|
1467
1535
|
// src/tools/create-pull-request.ts
|
|
1468
1536
|
import {
|
|
1469
1537
|
objectFactsSchema as objectFactsSchema2,
|
|
1470
|
-
definePluginTool as
|
|
1538
|
+
definePluginTool as definePluginTool8,
|
|
1471
1539
|
EgressAuthRequired as EgressAuthRequired2,
|
|
1472
|
-
PluginToolInputError as
|
|
1473
|
-
pluginToolOutputSchema as
|
|
1540
|
+
PluginToolInputError as PluginToolInputError10,
|
|
1541
|
+
pluginToolOutputSchema as pluginToolOutputSchema8,
|
|
1474
1542
|
watchResultSchema,
|
|
1475
1543
|
subscribableResourceSchema as subscribableResourceSchema4
|
|
1476
1544
|
} from "@sentry/junior-plugin-api";
|
|
1477
1545
|
import { Type as Type2 } from "@sinclair/typebox";
|
|
1478
1546
|
import { Value as Value2 } from "@sinclair/typebox/value";
|
|
1479
|
-
import * as
|
|
1547
|
+
import * as z12 from "zod";
|
|
1480
1548
|
|
|
1481
1549
|
// src/pull-request-requesters/store.ts
|
|
1482
1550
|
import { and, asc, eq, inArray, lt } from "drizzle-orm";
|
|
@@ -1491,18 +1559,18 @@ import {
|
|
|
1491
1559
|
text,
|
|
1492
1560
|
timestamp
|
|
1493
1561
|
} from "drizzle-orm/pg-core";
|
|
1494
|
-
import * as
|
|
1495
|
-
var githubPullRequestStateSchema =
|
|
1562
|
+
import * as z10 from "zod";
|
|
1563
|
+
var githubPullRequestStateSchema = z10.enum([
|
|
1496
1564
|
"closed_unmerged",
|
|
1497
1565
|
"merged",
|
|
1498
1566
|
"open"
|
|
1499
1567
|
]);
|
|
1500
|
-
var githubPullRequestCommitCompositionSchema =
|
|
1568
|
+
var githubPullRequestCommitCompositionSchema = z10.enum([
|
|
1501
1569
|
"junior_only",
|
|
1502
1570
|
"mixed"
|
|
1503
1571
|
]);
|
|
1504
|
-
var githubIssueStateSchema =
|
|
1505
|
-
var githubIssueStateReasonSchema =
|
|
1572
|
+
var githubIssueStateSchema = z10.enum(["closed", "open"]);
|
|
1573
|
+
var githubIssueStateReasonSchema = z10.enum([
|
|
1506
1574
|
"completed",
|
|
1507
1575
|
"duplicate",
|
|
1508
1576
|
"not_planned",
|
|
@@ -1663,32 +1731,32 @@ async function listGitHubPullRequestOpeners(db, input) {
|
|
|
1663
1731
|
}
|
|
1664
1732
|
|
|
1665
1733
|
// src/tools/stack-pull-request.ts
|
|
1666
|
-
import * as
|
|
1734
|
+
import * as z11 from "zod";
|
|
1667
1735
|
var MAX_STACK_DEPTH = 10;
|
|
1668
1736
|
var GITHUB_STACKS_API_VERSION = "2026-03-10";
|
|
1669
|
-
var stackTargetSchema =
|
|
1670
|
-
number:
|
|
1671
|
-
head:
|
|
1672
|
-
ref:
|
|
1673
|
-
repo:
|
|
1737
|
+
var stackTargetSchema = z11.object({
|
|
1738
|
+
number: z11.number().int().positive(),
|
|
1739
|
+
head: z11.object({
|
|
1740
|
+
ref: z11.string().min(1),
|
|
1741
|
+
repo: z11.object({ full_name: z11.string().min(1) }).nullable()
|
|
1674
1742
|
}),
|
|
1675
|
-
base:
|
|
1676
|
-
ref:
|
|
1677
|
-
repo:
|
|
1678
|
-
default_branch:
|
|
1679
|
-
full_name:
|
|
1743
|
+
base: z11.object({
|
|
1744
|
+
ref: z11.string().min(1),
|
|
1745
|
+
repo: z11.object({
|
|
1746
|
+
default_branch: z11.string().min(1),
|
|
1747
|
+
full_name: z11.string().min(1)
|
|
1680
1748
|
})
|
|
1681
1749
|
})
|
|
1682
1750
|
});
|
|
1683
|
-
var openPullRequestsSchema =
|
|
1684
|
-
|
|
1685
|
-
number:
|
|
1686
|
-
base:
|
|
1751
|
+
var openPullRequestsSchema = z11.array(
|
|
1752
|
+
z11.object({
|
|
1753
|
+
number: z11.number().int().positive(),
|
|
1754
|
+
base: z11.object({ ref: z11.string().min(1) })
|
|
1687
1755
|
})
|
|
1688
1756
|
);
|
|
1689
|
-
var stackSchema =
|
|
1690
|
-
number:
|
|
1691
|
-
pull_requests:
|
|
1757
|
+
var stackSchema = z11.object({
|
|
1758
|
+
number: z11.number().int().positive(),
|
|
1759
|
+
pull_requests: z11.array(z11.object({ number: z11.number().int().positive() }))
|
|
1692
1760
|
});
|
|
1693
1761
|
async function stackGitHubPullRequest(ctx, target) {
|
|
1694
1762
|
const repo = target.base.repo.full_name;
|
|
@@ -1736,7 +1804,7 @@ async function stackGitHubPullRequest(ctx, target) {
|
|
|
1736
1804
|
const stacks = await github(
|
|
1737
1805
|
"github.stack.read",
|
|
1738
1806
|
`${api}/stacks?pull_request=${parent.number}`,
|
|
1739
|
-
|
|
1807
|
+
z11.array(stackSchema)
|
|
1740
1808
|
);
|
|
1741
1809
|
if (!stacks) return void 0;
|
|
1742
1810
|
const stack = stacks[0];
|
|
@@ -1811,15 +1879,15 @@ var createPullRequestInputSchema = Type2.Object(
|
|
|
1811
1879
|
},
|
|
1812
1880
|
{ additionalProperties: false }
|
|
1813
1881
|
);
|
|
1814
|
-
var createPullRequestToolInputSchema =
|
|
1815
|
-
repo:
|
|
1816
|
-
title:
|
|
1817
|
-
head:
|
|
1818
|
-
base:
|
|
1819
|
-
body:
|
|
1882
|
+
var createPullRequestToolInputSchema = z12.object({
|
|
1883
|
+
repo: z12.string().describe('Repository in "owner/name" format.'),
|
|
1884
|
+
title: z12.string().describe("Pull request title."),
|
|
1885
|
+
head: z12.string().describe("Head branch or owner:branch ref."),
|
|
1886
|
+
base: z12.string().describe("Base branch."),
|
|
1887
|
+
body: z12.string().describe(
|
|
1820
1888
|
"Pull request body. The runtime appends the conversation footer."
|
|
1821
1889
|
).optional(),
|
|
1822
|
-
draft:
|
|
1890
|
+
draft: z12.boolean().describe("Whether to open the pull request as a draft.").optional()
|
|
1823
1891
|
}).strict();
|
|
1824
1892
|
var createPullRequestStateSchema = Type2.Union([
|
|
1825
1893
|
Type2.Object(
|
|
@@ -1844,30 +1912,30 @@ var createPullRequestStateSchema = Type2.Union([
|
|
|
1844
1912
|
{ additionalProperties: false }
|
|
1845
1913
|
)
|
|
1846
1914
|
]);
|
|
1847
|
-
var gitHubPullRequestDataSchema =
|
|
1848
|
-
number:
|
|
1849
|
-
url:
|
|
1850
|
-
stack:
|
|
1915
|
+
var gitHubPullRequestDataSchema = z12.object({
|
|
1916
|
+
number: z12.number(),
|
|
1917
|
+
url: z12.string(),
|
|
1918
|
+
stack: z12.object({ number: z12.number(), pull_requests: z12.array(z12.number()) }).optional(),
|
|
1851
1919
|
subscribable: subscribableResourceSchema4.optional(),
|
|
1852
1920
|
subscription: watchResultSchema.optional()
|
|
1853
1921
|
});
|
|
1854
|
-
var gitHubPullRequestOutputSchema =
|
|
1922
|
+
var gitHubPullRequestOutputSchema = pluginToolOutputSchema8.merge(
|
|
1855
1923
|
gitHubPullRequestDataSchema.extend({
|
|
1856
|
-
target:
|
|
1924
|
+
target: z12.literal("createPullRequest")
|
|
1857
1925
|
})
|
|
1858
1926
|
);
|
|
1859
1927
|
function parseCreatePullRequestInput(input) {
|
|
1860
1928
|
try {
|
|
1861
1929
|
return Value2.Parse(createPullRequestInputSchema, input);
|
|
1862
1930
|
} catch (error) {
|
|
1863
|
-
throw new
|
|
1931
|
+
throw new PluginToolInputError10("Invalid GitHub createPullRequest input.", {
|
|
1864
1932
|
cause: error
|
|
1865
1933
|
});
|
|
1866
1934
|
}
|
|
1867
1935
|
}
|
|
1868
1936
|
function nonEmptyString3(value, name) {
|
|
1869
1937
|
if (!value?.trim()) {
|
|
1870
|
-
throw new
|
|
1938
|
+
throw new PluginToolInputError10(`${name} is required`);
|
|
1871
1939
|
}
|
|
1872
1940
|
return value.trim();
|
|
1873
1941
|
}
|
|
@@ -2056,7 +2124,7 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
|
|
|
2056
2124
|
}
|
|
2057
2125
|
}
|
|
2058
2126
|
function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
2059
|
-
return
|
|
2127
|
+
return definePluginTool8({
|
|
2060
2128
|
annotations: {
|
|
2061
2129
|
destructiveHint: false,
|
|
2062
2130
|
idempotentHint: true,
|
|
@@ -2175,36 +2243,36 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
2175
2243
|
|
|
2176
2244
|
// src/tools/get-pull-request.ts
|
|
2177
2245
|
import {
|
|
2178
|
-
definePluginTool as
|
|
2179
|
-
PluginToolInputError as
|
|
2180
|
-
pluginToolOutputSchema as
|
|
2246
|
+
definePluginTool as definePluginTool9,
|
|
2247
|
+
PluginToolInputError as PluginToolInputError11,
|
|
2248
|
+
pluginToolOutputSchema as pluginToolOutputSchema9
|
|
2181
2249
|
} from "@sentry/junior-plugin-api";
|
|
2182
|
-
import * as
|
|
2250
|
+
import * as z13 from "zod";
|
|
2183
2251
|
import { subscribableResourceSchema as subscribableResourceSchema5 } from "@sentry/junior-plugin-api";
|
|
2184
|
-
var commitShaSchema2 =
|
|
2185
|
-
var
|
|
2186
|
-
repo:
|
|
2187
|
-
number:
|
|
2252
|
+
var commitShaSchema2 = z13.string().regex(/^[0-9a-f]{40}$/i);
|
|
2253
|
+
var inputSchema7 = z13.object({
|
|
2254
|
+
repo: z13.string().describe('Repository in "owner/name" format.'),
|
|
2255
|
+
number: z13.number().int().positive().describe("Pull request number.")
|
|
2188
2256
|
}).strict();
|
|
2189
|
-
var pullRequestSchema =
|
|
2190
|
-
base:
|
|
2191
|
-
draft:
|
|
2192
|
-
head:
|
|
2257
|
+
var pullRequestSchema = z13.object({
|
|
2258
|
+
base: z13.string(),
|
|
2259
|
+
draft: z13.boolean(),
|
|
2260
|
+
head: z13.string(),
|
|
2193
2261
|
head_sha: commitShaSchema2,
|
|
2194
|
-
merged:
|
|
2195
|
-
number:
|
|
2196
|
-
state:
|
|
2262
|
+
merged: z13.boolean(),
|
|
2263
|
+
number: z13.number(),
|
|
2264
|
+
state: z13.string(),
|
|
2197
2265
|
subscribable: subscribableResourceSchema5.optional(),
|
|
2198
|
-
title:
|
|
2199
|
-
url:
|
|
2266
|
+
title: z13.string(),
|
|
2267
|
+
url: z13.string()
|
|
2200
2268
|
});
|
|
2201
|
-
var
|
|
2269
|
+
var outputSchema7 = pluginToolOutputSchema9.merge(
|
|
2202
2270
|
pullRequestSchema.extend({
|
|
2203
|
-
target:
|
|
2271
|
+
target: z13.literal("getPullRequest")
|
|
2204
2272
|
})
|
|
2205
2273
|
);
|
|
2206
2274
|
function createGitHubGetPullRequestTool(ctx) {
|
|
2207
|
-
return
|
|
2275
|
+
return definePluginTool9({
|
|
2208
2276
|
annotations: {
|
|
2209
2277
|
destructiveHint: false,
|
|
2210
2278
|
idempotentHint: true,
|
|
@@ -2212,8 +2280,8 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2212
2280
|
readOnlyHint: true
|
|
2213
2281
|
},
|
|
2214
2282
|
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.",
|
|
2215
|
-
inputSchema:
|
|
2216
|
-
outputSchema:
|
|
2283
|
+
inputSchema: inputSchema7,
|
|
2284
|
+
outputSchema: outputSchema7,
|
|
2217
2285
|
async execute(input) {
|
|
2218
2286
|
const repo = parseRepo(input.repo);
|
|
2219
2287
|
const response = await githubApi(ctx.egress, {
|
|
@@ -2223,19 +2291,19 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2223
2291
|
if (!response.ok) {
|
|
2224
2292
|
const message = `GitHub pull request lookup failed with HTTP ${response.status}`;
|
|
2225
2293
|
if (response.status === 404) {
|
|
2226
|
-
throw new
|
|
2294
|
+
throw new PluginToolInputError11(message);
|
|
2227
2295
|
}
|
|
2228
2296
|
throw new Error(message);
|
|
2229
2297
|
}
|
|
2230
|
-
const providerResult =
|
|
2231
|
-
base:
|
|
2232
|
-
draft:
|
|
2233
|
-
head:
|
|
2234
|
-
html_url:
|
|
2235
|
-
merged:
|
|
2236
|
-
number:
|
|
2237
|
-
state:
|
|
2238
|
-
title:
|
|
2298
|
+
const providerResult = z13.object({
|
|
2299
|
+
base: z13.object({ ref: z13.string() }),
|
|
2300
|
+
draft: z13.boolean(),
|
|
2301
|
+
head: z13.object({ ref: z13.string(), sha: commitShaSchema2 }),
|
|
2302
|
+
html_url: z13.string(),
|
|
2303
|
+
merged: z13.boolean().optional().default(false),
|
|
2304
|
+
number: z13.number(),
|
|
2305
|
+
state: z13.string(),
|
|
2306
|
+
title: z13.string()
|
|
2239
2307
|
}).parse(response.body);
|
|
2240
2308
|
const subscribable = gitHubPullRequestSubscribable({
|
|
2241
2309
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -2275,49 +2343,49 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2275
2343
|
|
|
2276
2344
|
// src/tools/get-release.ts
|
|
2277
2345
|
import {
|
|
2278
|
-
definePluginTool as
|
|
2279
|
-
pluginToolOutputSchema as
|
|
2346
|
+
definePluginTool as definePluginTool10,
|
|
2347
|
+
pluginToolOutputSchema as pluginToolOutputSchema10,
|
|
2280
2348
|
subscribableResourceSchema as subscribableResourceSchema6
|
|
2281
2349
|
} from "@sentry/junior-plugin-api";
|
|
2282
|
-
import * as
|
|
2283
|
-
var
|
|
2284
|
-
repo:
|
|
2285
|
-
tag:
|
|
2350
|
+
import * as z14 from "zod";
|
|
2351
|
+
var inputSchema8 = z14.object({
|
|
2352
|
+
repo: z14.string().describe('Repository in "owner/name" format.'),
|
|
2353
|
+
tag: z14.string().trim().min(1).describe(
|
|
2286
2354
|
"Optional release tag name. Omit to inspect and watch every published release in the repository."
|
|
2287
2355
|
).optional()
|
|
2288
2356
|
}).strict();
|
|
2289
|
-
var releaseSchema =
|
|
2290
|
-
created_at:
|
|
2291
|
-
draft:
|
|
2292
|
-
html_url:
|
|
2293
|
-
id:
|
|
2294
|
-
name:
|
|
2295
|
-
prerelease:
|
|
2296
|
-
published_at:
|
|
2297
|
-
tag_name:
|
|
2298
|
-
target_commitish:
|
|
2357
|
+
var releaseSchema = z14.object({
|
|
2358
|
+
created_at: z14.string(),
|
|
2359
|
+
draft: z14.boolean(),
|
|
2360
|
+
html_url: z14.string(),
|
|
2361
|
+
id: z14.number(),
|
|
2362
|
+
name: z14.string().nullable(),
|
|
2363
|
+
prerelease: z14.boolean(),
|
|
2364
|
+
published_at: z14.string().nullable(),
|
|
2365
|
+
tag_name: z14.string(),
|
|
2366
|
+
target_commitish: z14.string()
|
|
2299
2367
|
}).strict();
|
|
2300
|
-
var releaseSourceSchema =
|
|
2368
|
+
var releaseSourceSchema = z14.object({
|
|
2301
2369
|
release: releaseSchema.nullable(),
|
|
2302
|
-
repo:
|
|
2370
|
+
repo: z14.string(),
|
|
2303
2371
|
subscribable: subscribableResourceSchema6.optional(),
|
|
2304
|
-
tag:
|
|
2372
|
+
tag: z14.string().nullable()
|
|
2305
2373
|
}).strict();
|
|
2306
|
-
var
|
|
2374
|
+
var outputSchema8 = pluginToolOutputSchema10.merge(
|
|
2307
2375
|
releaseSourceSchema.extend({
|
|
2308
|
-
target:
|
|
2376
|
+
target: z14.literal("getRelease")
|
|
2309
2377
|
})
|
|
2310
2378
|
);
|
|
2311
|
-
var providerReleaseSchema =
|
|
2312
|
-
created_at:
|
|
2313
|
-
draft:
|
|
2314
|
-
html_url:
|
|
2315
|
-
id:
|
|
2316
|
-
name:
|
|
2317
|
-
prerelease:
|
|
2318
|
-
published_at:
|
|
2319
|
-
tag_name:
|
|
2320
|
-
target_commitish:
|
|
2379
|
+
var providerReleaseSchema = z14.object({
|
|
2380
|
+
created_at: z14.string(),
|
|
2381
|
+
draft: z14.boolean(),
|
|
2382
|
+
html_url: z14.string(),
|
|
2383
|
+
id: z14.number(),
|
|
2384
|
+
name: z14.string().nullable(),
|
|
2385
|
+
prerelease: z14.boolean(),
|
|
2386
|
+
published_at: z14.string().nullable(),
|
|
2387
|
+
tag_name: z14.string(),
|
|
2388
|
+
target_commitish: z14.string()
|
|
2321
2389
|
}).passthrough();
|
|
2322
2390
|
function mapRelease(providerRelease) {
|
|
2323
2391
|
return {
|
|
@@ -2333,7 +2401,7 @@ function mapRelease(providerRelease) {
|
|
|
2333
2401
|
};
|
|
2334
2402
|
}
|
|
2335
2403
|
function createGitHubGetReleaseTool(ctx) {
|
|
2336
|
-
return
|
|
2404
|
+
return definePluginTool10({
|
|
2337
2405
|
annotations: {
|
|
2338
2406
|
destructiveHint: false,
|
|
2339
2407
|
idempotentHint: true,
|
|
@@ -2341,8 +2409,8 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2341
2409
|
readOnlyHint: true
|
|
2342
2410
|
},
|
|
2343
2411
|
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.",
|
|
2344
|
-
inputSchema:
|
|
2345
|
-
outputSchema:
|
|
2412
|
+
inputSchema: inputSchema8,
|
|
2413
|
+
outputSchema: outputSchema8,
|
|
2346
2414
|
async execute(input) {
|
|
2347
2415
|
const repo = parseRepo(input.repo);
|
|
2348
2416
|
const tag = input.tag?.trim() || void 0;
|
|
@@ -2395,30 +2463,30 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2395
2463
|
|
|
2396
2464
|
// src/tools/get-repository.ts
|
|
2397
2465
|
import {
|
|
2398
|
-
definePluginTool as
|
|
2399
|
-
PluginToolInputError as
|
|
2400
|
-
pluginToolOutputSchema as
|
|
2466
|
+
definePluginTool as definePluginTool11,
|
|
2467
|
+
PluginToolInputError as PluginToolInputError12,
|
|
2468
|
+
pluginToolOutputSchema as pluginToolOutputSchema11,
|
|
2401
2469
|
subscribableResourceSchema as subscribableResourceSchema7
|
|
2402
2470
|
} from "@sentry/junior-plugin-api";
|
|
2403
|
-
import * as
|
|
2404
|
-
var
|
|
2405
|
-
repo:
|
|
2471
|
+
import * as z15 from "zod";
|
|
2472
|
+
var inputSchema9 = z15.object({
|
|
2473
|
+
repo: z15.string().describe('Repository in "owner/name" format.')
|
|
2406
2474
|
}).strict();
|
|
2407
|
-
var repositorySchema =
|
|
2408
|
-
default_branch:
|
|
2409
|
-
description:
|
|
2410
|
-
full_name:
|
|
2411
|
-
private:
|
|
2475
|
+
var repositorySchema = z15.object({
|
|
2476
|
+
default_branch: z15.string(),
|
|
2477
|
+
description: z15.string().nullable(),
|
|
2478
|
+
full_name: z15.string(),
|
|
2479
|
+
private: z15.boolean(),
|
|
2412
2480
|
subscribable: subscribableResourceSchema7.optional(),
|
|
2413
|
-
url:
|
|
2481
|
+
url: z15.string()
|
|
2414
2482
|
});
|
|
2415
|
-
var
|
|
2483
|
+
var outputSchema9 = pluginToolOutputSchema11.merge(
|
|
2416
2484
|
repositorySchema.extend({
|
|
2417
|
-
target:
|
|
2485
|
+
target: z15.literal("getRepository")
|
|
2418
2486
|
})
|
|
2419
2487
|
);
|
|
2420
2488
|
function createGitHubGetRepositoryTool(ctx) {
|
|
2421
|
-
return
|
|
2489
|
+
return definePluginTool11({
|
|
2422
2490
|
annotations: {
|
|
2423
2491
|
destructiveHint: false,
|
|
2424
2492
|
idempotentHint: true,
|
|
@@ -2426,8 +2494,8 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2426
2494
|
readOnlyHint: true
|
|
2427
2495
|
},
|
|
2428
2496
|
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.",
|
|
2429
|
-
inputSchema:
|
|
2430
|
-
outputSchema:
|
|
2497
|
+
inputSchema: inputSchema9,
|
|
2498
|
+
outputSchema: outputSchema9,
|
|
2431
2499
|
async execute(input) {
|
|
2432
2500
|
const repo = parseRepo(input.repo);
|
|
2433
2501
|
const response = await githubApi(ctx.egress, {
|
|
@@ -2435,16 +2503,16 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2435
2503
|
path: repoPath(repo)
|
|
2436
2504
|
});
|
|
2437
2505
|
if (!response.ok) {
|
|
2438
|
-
throw new
|
|
2506
|
+
throw new PluginToolInputError12(
|
|
2439
2507
|
`GitHub repository lookup failed with HTTP ${response.status}`
|
|
2440
2508
|
);
|
|
2441
2509
|
}
|
|
2442
|
-
const providerResult =
|
|
2443
|
-
default_branch:
|
|
2444
|
-
description:
|
|
2445
|
-
full_name:
|
|
2446
|
-
html_url:
|
|
2447
|
-
private:
|
|
2510
|
+
const providerResult = z15.object({
|
|
2511
|
+
default_branch: z15.string(),
|
|
2512
|
+
description: z15.string().nullable(),
|
|
2513
|
+
full_name: z15.string(),
|
|
2514
|
+
html_url: z15.string(),
|
|
2515
|
+
private: z15.boolean()
|
|
2448
2516
|
}).parse(response.body);
|
|
2449
2517
|
const subscribable = gitHubRepositorySubscribable({
|
|
2450
2518
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -2468,27 +2536,27 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2468
2536
|
|
|
2469
2537
|
// src/tools/get-status.ts
|
|
2470
2538
|
import {
|
|
2471
|
-
definePluginTool as
|
|
2472
|
-
pluginToolOutputSchema as
|
|
2539
|
+
definePluginTool as definePluginTool12,
|
|
2540
|
+
pluginToolOutputSchema as pluginToolOutputSchema12
|
|
2473
2541
|
} from "@sentry/junior-plugin-api";
|
|
2474
|
-
import * as
|
|
2542
|
+
import * as z17 from "zod";
|
|
2475
2543
|
|
|
2476
2544
|
// src/github-status.ts
|
|
2477
|
-
import * as
|
|
2545
|
+
import * as z16 from "zod";
|
|
2478
2546
|
var GITHUB_STATUS_INCIDENTS_URL = "https://www.githubstatus.com/api/v2/incidents.json";
|
|
2479
2547
|
var GITHUB_STATUS_TTL_MS = 60 * 1e3;
|
|
2480
2548
|
var GITHUB_STATUS_TIMEOUT_MS = 5e3;
|
|
2481
|
-
var incidentsResponseSchema =
|
|
2482
|
-
incidents:
|
|
2483
|
-
|
|
2484
|
-
components:
|
|
2485
|
-
created_at:
|
|
2486
|
-
impact:
|
|
2487
|
-
name:
|
|
2488
|
-
resolved_at:
|
|
2489
|
-
shortlink:
|
|
2490
|
-
started_at:
|
|
2491
|
-
status:
|
|
2549
|
+
var incidentsResponseSchema = z16.object({
|
|
2550
|
+
incidents: z16.array(
|
|
2551
|
+
z16.object({
|
|
2552
|
+
components: z16.array(z16.object({ name: z16.string() })).default([]),
|
|
2553
|
+
created_at: z16.string(),
|
|
2554
|
+
impact: z16.string(),
|
|
2555
|
+
name: z16.string(),
|
|
2556
|
+
resolved_at: z16.string().nullable(),
|
|
2557
|
+
shortlink: z16.string(),
|
|
2558
|
+
started_at: z16.string().nullable().optional(),
|
|
2559
|
+
status: z16.string()
|
|
2492
2560
|
})
|
|
2493
2561
|
)
|
|
2494
2562
|
});
|
|
@@ -2530,22 +2598,22 @@ async function loadGitHubStatusIncidents(cache, withinMs) {
|
|
|
2530
2598
|
|
|
2531
2599
|
// src/tools/get-status.ts
|
|
2532
2600
|
var RECENT_INCIDENT_MS = 24 * 60 * 60 * 1e3;
|
|
2533
|
-
var
|
|
2534
|
-
var incidentSchema =
|
|
2535
|
-
components:
|
|
2536
|
-
impact:
|
|
2537
|
-
name:
|
|
2538
|
-
resolved_at:
|
|
2539
|
-
started_at:
|
|
2540
|
-
status:
|
|
2541
|
-
url:
|
|
2601
|
+
var inputSchema10 = z17.object({}).strict();
|
|
2602
|
+
var incidentSchema = z17.object({
|
|
2603
|
+
components: z17.array(z17.string()),
|
|
2604
|
+
impact: z17.string(),
|
|
2605
|
+
name: z17.string(),
|
|
2606
|
+
resolved_at: z17.string().optional(),
|
|
2607
|
+
started_at: z17.string(),
|
|
2608
|
+
status: z17.string(),
|
|
2609
|
+
url: z17.string()
|
|
2542
2610
|
});
|
|
2543
|
-
var
|
|
2544
|
-
target:
|
|
2545
|
-
incidents:
|
|
2611
|
+
var outputSchema10 = pluginToolOutputSchema12.extend({
|
|
2612
|
+
target: z17.literal("getStatus"),
|
|
2613
|
+
incidents: z17.array(incidentSchema)
|
|
2546
2614
|
});
|
|
2547
2615
|
function createGitHubGetStatusTool(ctx) {
|
|
2548
|
-
return
|
|
2616
|
+
return definePluginTool12({
|
|
2549
2617
|
annotations: {
|
|
2550
2618
|
destructiveHint: false,
|
|
2551
2619
|
idempotentHint: true,
|
|
@@ -2553,8 +2621,8 @@ function createGitHubGetStatusTool(ctx) {
|
|
|
2553
2621
|
readOnlyHint: true
|
|
2554
2622
|
},
|
|
2555
2623
|
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.",
|
|
2556
|
-
inputSchema:
|
|
2557
|
-
outputSchema:
|
|
2624
|
+
inputSchema: inputSchema10,
|
|
2625
|
+
outputSchema: outputSchema10,
|
|
2558
2626
|
async execute() {
|
|
2559
2627
|
const incidents = await loadGitHubStatusIncidents(
|
|
2560
2628
|
ctx.cache,
|
|
@@ -2577,55 +2645,55 @@ function createGitHubGetStatusTool(ctx) {
|
|
|
2577
2645
|
|
|
2578
2646
|
// src/tools/update-issue.ts
|
|
2579
2647
|
import {
|
|
2580
|
-
definePluginTool as
|
|
2581
|
-
PluginToolInputError as
|
|
2582
|
-
pluginToolOutputSchema as
|
|
2648
|
+
definePluginTool as definePluginTool13,
|
|
2649
|
+
PluginToolInputError as PluginToolInputError13,
|
|
2650
|
+
pluginToolOutputSchema as pluginToolOutputSchema13,
|
|
2583
2651
|
subscribableResourceSchema as subscribableResourceSchema8
|
|
2584
2652
|
} from "@sentry/junior-plugin-api";
|
|
2585
|
-
import * as
|
|
2586
|
-
var
|
|
2587
|
-
repo:
|
|
2588
|
-
number:
|
|
2589
|
-
title:
|
|
2590
|
-
body:
|
|
2653
|
+
import * as z18 from "zod";
|
|
2654
|
+
var inputSchema11 = z18.object({
|
|
2655
|
+
repo: z18.string().describe('Repository in "owner/name" format.'),
|
|
2656
|
+
number: z18.number().int().positive().describe("Issue number."),
|
|
2657
|
+
title: z18.string().trim().min(1).optional().describe("Replacement issue title."),
|
|
2658
|
+
body: z18.string().optional().describe(
|
|
2591
2659
|
"Replacement issue body. The runtime appends requester attribution and the conversation footer."
|
|
2592
2660
|
),
|
|
2593
|
-
state:
|
|
2594
|
-
assign_requester:
|
|
2661
|
+
state: z18.enum(["open", "closed"]).optional().describe("Replacement issue state."),
|
|
2662
|
+
assign_requester: z18.boolean().optional().describe(
|
|
2595
2663
|
"Set true to add the requester's linked GitHub account as an assignee. Other assignees stay."
|
|
2596
2664
|
)
|
|
2597
2665
|
}).strict().refine(
|
|
2598
2666
|
({ title, body, state, assign_requester }) => title !== void 0 || body !== void 0 || state !== void 0 || assign_requester === true,
|
|
2599
2667
|
{ message: "At least one issue field must be provided." }
|
|
2600
2668
|
);
|
|
2601
|
-
var issueSchema2 =
|
|
2602
|
-
assignees:
|
|
2603
|
-
body:
|
|
2604
|
-
number:
|
|
2605
|
-
state:
|
|
2669
|
+
var issueSchema2 = z18.object({
|
|
2670
|
+
assignees: z18.array(z18.string()),
|
|
2671
|
+
body: z18.string().nullable(),
|
|
2672
|
+
number: z18.number(),
|
|
2673
|
+
state: z18.string(),
|
|
2606
2674
|
subscribable: subscribableResourceSchema8.optional(),
|
|
2607
|
-
title:
|
|
2608
|
-
url:
|
|
2675
|
+
title: z18.string(),
|
|
2676
|
+
url: z18.string()
|
|
2609
2677
|
});
|
|
2610
|
-
var
|
|
2678
|
+
var outputSchema11 = pluginToolOutputSchema13.merge(
|
|
2611
2679
|
issueSchema2.extend({
|
|
2612
|
-
target:
|
|
2680
|
+
target: z18.literal("updateIssue")
|
|
2613
2681
|
})
|
|
2614
2682
|
);
|
|
2615
|
-
var providerIssueSchema2 =
|
|
2616
|
-
assignees:
|
|
2617
|
-
body:
|
|
2618
|
-
html_url:
|
|
2619
|
-
number:
|
|
2620
|
-
state:
|
|
2621
|
-
title:
|
|
2683
|
+
var providerIssueSchema2 = z18.object({
|
|
2684
|
+
assignees: z18.array(z18.object({ login: z18.string() })).nullish().transform((assignees) => assignees?.map(({ login: login2 }) => login2) ?? []),
|
|
2685
|
+
body: z18.string().nullable().optional().default(null),
|
|
2686
|
+
html_url: z18.string(),
|
|
2687
|
+
number: z18.number(),
|
|
2688
|
+
state: z18.string(),
|
|
2689
|
+
title: z18.string()
|
|
2622
2690
|
});
|
|
2623
2691
|
function nonEmptyString4(value, name) {
|
|
2624
|
-
if (!value?.trim()) throw new
|
|
2692
|
+
if (!value?.trim()) throw new PluginToolInputError13(`${name} is required`);
|
|
2625
2693
|
return value.trim();
|
|
2626
2694
|
}
|
|
2627
2695
|
function createGitHubUpdateIssueTool(ctx) {
|
|
2628
|
-
return
|
|
2696
|
+
return definePluginTool13({
|
|
2629
2697
|
annotations: {
|
|
2630
2698
|
destructiveHint: true,
|
|
2631
2699
|
idempotentHint: true,
|
|
@@ -2633,12 +2701,12 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2633
2701
|
readOnlyHint: false
|
|
2634
2702
|
},
|
|
2635
2703
|
description: "Update an existing GitHub issue's title, body, or open/closed state, or assign it to the requester. Use this instead of raw GitHub API calls when changing issue metadata.",
|
|
2636
|
-
inputSchema:
|
|
2637
|
-
outputSchema:
|
|
2704
|
+
inputSchema: inputSchema11,
|
|
2705
|
+
outputSchema: outputSchema11,
|
|
2638
2706
|
async execute(input) {
|
|
2639
|
-
const parsedInput =
|
|
2707
|
+
const parsedInput = inputSchema11.safeParse(input);
|
|
2640
2708
|
if (!parsedInput.success) {
|
|
2641
|
-
throw new
|
|
2709
|
+
throw new PluginToolInputError13("Invalid GitHub updateIssue input.", {
|
|
2642
2710
|
cause: parsedInput.error
|
|
2643
2711
|
});
|
|
2644
2712
|
}
|
|
@@ -2647,7 +2715,7 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2647
2715
|
const requester = update.body !== void 0 || update.assign_requester ? await resolveGitHubRequester(ctx) : void 0;
|
|
2648
2716
|
const assignee = update.assign_requester ? linkedGitHubLogin(requester?.user) : void 0;
|
|
2649
2717
|
if (update.assign_requester && !assignee) {
|
|
2650
|
-
throw new
|
|
2718
|
+
throw new PluginToolInputError13(
|
|
2651
2719
|
"The requester has no linked GitHub account, so Junior cannot assign the issue to them."
|
|
2652
2720
|
);
|
|
2653
2721
|
}
|
|
@@ -2697,7 +2765,7 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2697
2765
|
if (!response.ok) {
|
|
2698
2766
|
const message = `GitHub issue assignment failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`;
|
|
2699
2767
|
if (response.status === 404 || response.status === 422) {
|
|
2700
|
-
throw new
|
|
2768
|
+
throw new PluginToolInputError13(message);
|
|
2701
2769
|
}
|
|
2702
2770
|
throw new Error(message);
|
|
2703
2771
|
}
|
|
@@ -2706,7 +2774,7 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2706
2774
|
if (assignee && !providerResult.assignees.some(
|
|
2707
2775
|
(login2) => login2.toLowerCase() === assignee.toLowerCase()
|
|
2708
2776
|
)) {
|
|
2709
|
-
throw new
|
|
2777
|
+
throw new PluginToolInputError13(
|
|
2710
2778
|
`GitHub did not assign @${assignee} to the issue. They may not have access to ${repo.ref}.`
|
|
2711
2779
|
);
|
|
2712
2780
|
}
|
|
@@ -2740,24 +2808,99 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2740
2808
|
});
|
|
2741
2809
|
}
|
|
2742
2810
|
|
|
2811
|
+
// src/tools/update-issue-comment.ts
|
|
2812
|
+
import {
|
|
2813
|
+
definePluginTool as definePluginTool14,
|
|
2814
|
+
PluginToolInputError as PluginToolInputError14,
|
|
2815
|
+
pluginToolOutputSchema as pluginToolOutputSchema14
|
|
2816
|
+
} from "@sentry/junior-plugin-api";
|
|
2817
|
+
import * as z19 from "zod";
|
|
2818
|
+
var inputSchema12 = z19.object({
|
|
2819
|
+
repo: z19.string().describe('Repository in "owner/name" format.'),
|
|
2820
|
+
comment_id: z19.number().int().positive().describe("Issue comment id, as returned by github_commentOnIssue."),
|
|
2821
|
+
body: z19.string().trim().min(1).describe("Replacement comment text.")
|
|
2822
|
+
}).strict();
|
|
2823
|
+
var outputSchema12 = pluginToolOutputSchema14.extend({
|
|
2824
|
+
target: z19.literal("updateIssueComment"),
|
|
2825
|
+
repo: z19.string(),
|
|
2826
|
+
comment_id: z19.number(),
|
|
2827
|
+
url: z19.string()
|
|
2828
|
+
});
|
|
2829
|
+
function createGitHubUpdateIssueCommentTool(egress, botEmail) {
|
|
2830
|
+
return definePluginTool14({
|
|
2831
|
+
annotations: {
|
|
2832
|
+
destructiveHint: true,
|
|
2833
|
+
idempotentHint: true,
|
|
2834
|
+
openWorldHint: true,
|
|
2835
|
+
readOnlyHint: false
|
|
2836
|
+
},
|
|
2837
|
+
description: "Replace the text of a GitHub issue or pull request conversation comment that you posted, for example to update a progress comment. Only works on your own comments.",
|
|
2838
|
+
inputSchema: inputSchema12,
|
|
2839
|
+
outputSchema: outputSchema12,
|
|
2840
|
+
async execute(input) {
|
|
2841
|
+
const repo = parseRepo(input.repo);
|
|
2842
|
+
const botUserId = botUserIdFromEmail(botEmail);
|
|
2843
|
+
if (botUserId === void 0) {
|
|
2844
|
+
throw new Error("GitHub App bot identity is not configured.");
|
|
2845
|
+
}
|
|
2846
|
+
const path = `${repoPath(repo)}/issues/comments/${input.comment_id}`;
|
|
2847
|
+
const lookup = await githubApi(egress, {
|
|
2848
|
+
operation: "github.issue.comment.get",
|
|
2849
|
+
path
|
|
2850
|
+
});
|
|
2851
|
+
if (!lookup.ok) {
|
|
2852
|
+
const message = `GitHub issue comment lookup failed with HTTP ${lookup.status}: ${githubErrorMessage(lookup.body)}`;
|
|
2853
|
+
if (lookup.status === 404) throw new PluginToolInputError14(message);
|
|
2854
|
+
throw new Error(message);
|
|
2855
|
+
}
|
|
2856
|
+
const author = z19.object({ user: z19.object({ id: z19.number() }).nullable() }).safeParse(lookup.body);
|
|
2857
|
+
if (!author.success || author.data.user?.id !== botUserId) {
|
|
2858
|
+
throw new PluginToolInputError14(
|
|
2859
|
+
"This bot can only edit issue comments it posted."
|
|
2860
|
+
);
|
|
2861
|
+
}
|
|
2862
|
+
const response = await githubApi(egress, {
|
|
2863
|
+
operation: "github.issue.comment.update",
|
|
2864
|
+
method: "PATCH",
|
|
2865
|
+
path,
|
|
2866
|
+
body: { body: input.body }
|
|
2867
|
+
});
|
|
2868
|
+
if (!response.ok) {
|
|
2869
|
+
const message = `GitHub issue comment update failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
2870
|
+
if (response.status === 404 || response.status === 422) {
|
|
2871
|
+
throw new PluginToolInputError14(message);
|
|
2872
|
+
}
|
|
2873
|
+
throw new Error(message);
|
|
2874
|
+
}
|
|
2875
|
+
const comment = z19.object({ id: z19.number(), html_url: z19.string() }).parse(response.body);
|
|
2876
|
+
return {
|
|
2877
|
+
target: "updateIssueComment",
|
|
2878
|
+
repo: repo.ref,
|
|
2879
|
+
comment_id: comment.id,
|
|
2880
|
+
url: comment.html_url
|
|
2881
|
+
};
|
|
2882
|
+
}
|
|
2883
|
+
});
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2743
2886
|
// src/tools/update-pull-request.ts
|
|
2744
2887
|
import {
|
|
2745
|
-
definePluginTool as
|
|
2746
|
-
PluginToolInputError as
|
|
2747
|
-
pluginToolOutputSchema as
|
|
2888
|
+
definePluginTool as definePluginTool15,
|
|
2889
|
+
PluginToolInputError as PluginToolInputError15,
|
|
2890
|
+
pluginToolOutputSchema as pluginToolOutputSchema15
|
|
2748
2891
|
} from "@sentry/junior-plugin-api";
|
|
2749
|
-
import * as
|
|
2892
|
+
import * as z20 from "zod";
|
|
2750
2893
|
import { subscribableResourceSchema as subscribableResourceSchema9 } from "@sentry/junior-plugin-api";
|
|
2751
|
-
var
|
|
2752
|
-
repo:
|
|
2753
|
-
number:
|
|
2754
|
-
title:
|
|
2755
|
-
body:
|
|
2894
|
+
var inputSchema13 = z20.object({
|
|
2895
|
+
repo: z20.string().describe('Repository in "owner/name" format.'),
|
|
2896
|
+
number: z20.number().int().positive().describe("Pull request number."),
|
|
2897
|
+
title: z20.string().trim().min(1).optional().describe("Replacement pull request title."),
|
|
2898
|
+
body: z20.string().optional().describe(
|
|
2756
2899
|
"Replacement pull request body. The runtime appends requester attribution and the conversation footer."
|
|
2757
2900
|
),
|
|
2758
|
-
base:
|
|
2759
|
-
state:
|
|
2760
|
-
draft:
|
|
2901
|
+
base: z20.string().trim().min(1).optional().describe("Replacement base branch."),
|
|
2902
|
+
state: z20.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
|
|
2903
|
+
draft: z20.boolean().optional().describe(
|
|
2761
2904
|
"Set false to mark a draft pull request ready for review, or true to convert it back to a draft."
|
|
2762
2905
|
)
|
|
2763
2906
|
}).strict().refine(
|
|
@@ -2772,29 +2915,29 @@ var CONVERT_TO_DRAFT = {
|
|
|
2772
2915
|
operationName: "ConvertPullRequestToDraft",
|
|
2773
2916
|
query: "mutation ConvertPullRequestToDraft($id: ID!) { result: convertPullRequestToDraft(input: {pullRequestId: $id}) { pullRequest { isDraft } } }"
|
|
2774
2917
|
};
|
|
2775
|
-
var draftMutationResponseSchema =
|
|
2776
|
-
data:
|
|
2777
|
-
result:
|
|
2918
|
+
var draftMutationResponseSchema = z20.object({
|
|
2919
|
+
data: z20.object({
|
|
2920
|
+
result: z20.object({ pullRequest: z20.object({ isDraft: z20.boolean() }) })
|
|
2778
2921
|
})
|
|
2779
2922
|
});
|
|
2780
|
-
var pullRequestSchema2 =
|
|
2781
|
-
base:
|
|
2782
|
-
body:
|
|
2783
|
-
draft:
|
|
2784
|
-
number:
|
|
2785
|
-
state:
|
|
2923
|
+
var pullRequestSchema2 = z20.object({
|
|
2924
|
+
base: z20.string(),
|
|
2925
|
+
body: z20.string().nullable(),
|
|
2926
|
+
draft: z20.boolean(),
|
|
2927
|
+
number: z20.number(),
|
|
2928
|
+
state: z20.string(),
|
|
2786
2929
|
subscribable: subscribableResourceSchema9.optional(),
|
|
2787
|
-
title:
|
|
2788
|
-
url:
|
|
2930
|
+
title: z20.string(),
|
|
2931
|
+
url: z20.string()
|
|
2789
2932
|
});
|
|
2790
|
-
var
|
|
2933
|
+
var outputSchema13 = pluginToolOutputSchema15.merge(
|
|
2791
2934
|
pullRequestSchema2.extend({
|
|
2792
|
-
target:
|
|
2935
|
+
target: z20.literal("updatePullRequest")
|
|
2793
2936
|
})
|
|
2794
2937
|
);
|
|
2795
2938
|
function nonEmptyString5(value, name) {
|
|
2796
2939
|
if (!value?.trim()) {
|
|
2797
|
-
throw new
|
|
2940
|
+
throw new PluginToolInputError15(`${name} is required`);
|
|
2798
2941
|
}
|
|
2799
2942
|
return value.trim();
|
|
2800
2943
|
}
|
|
@@ -2820,7 +2963,7 @@ async function setPullRequestDraft(input) {
|
|
|
2820
2963
|
return isDraft;
|
|
2821
2964
|
}
|
|
2822
2965
|
function createGitHubUpdatePullRequestTool(ctx) {
|
|
2823
|
-
return
|
|
2966
|
+
return definePluginTool15({
|
|
2824
2967
|
annotations: {
|
|
2825
2968
|
destructiveHint: true,
|
|
2826
2969
|
idempotentHint: true,
|
|
@@ -2828,12 +2971,12 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2828
2971
|
readOnlyHint: false
|
|
2829
2972
|
},
|
|
2830
2973
|
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.",
|
|
2831
|
-
inputSchema:
|
|
2832
|
-
outputSchema:
|
|
2974
|
+
inputSchema: inputSchema13,
|
|
2975
|
+
outputSchema: outputSchema13,
|
|
2833
2976
|
async execute(input) {
|
|
2834
|
-
const parsedInput =
|
|
2977
|
+
const parsedInput = inputSchema13.safeParse(input);
|
|
2835
2978
|
if (!parsedInput.success) {
|
|
2836
|
-
throw new
|
|
2979
|
+
throw new PluginToolInputError15(
|
|
2837
2980
|
"Invalid GitHub updatePullRequest input.",
|
|
2838
2981
|
{ cause: parsedInput.error }
|
|
2839
2982
|
);
|
|
@@ -2874,16 +3017,16 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2874
3017
|
`GitHub pull request update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`
|
|
2875
3018
|
);
|
|
2876
3019
|
}
|
|
2877
|
-
const providerResult =
|
|
2878
|
-
base:
|
|
2879
|
-
body:
|
|
2880
|
-
draft:
|
|
2881
|
-
html_url:
|
|
2882
|
-
merged:
|
|
2883
|
-
node_id:
|
|
2884
|
-
number:
|
|
2885
|
-
state:
|
|
2886
|
-
title:
|
|
3020
|
+
const providerResult = z20.object({
|
|
3021
|
+
base: z20.object({ ref: z20.string() }),
|
|
3022
|
+
body: z20.string().nullable().optional().default(null),
|
|
3023
|
+
draft: z20.boolean(),
|
|
3024
|
+
html_url: z20.string(),
|
|
3025
|
+
merged: z20.boolean(),
|
|
3026
|
+
node_id: z20.string().optional(),
|
|
3027
|
+
number: z20.number(),
|
|
3028
|
+
state: z20.string(),
|
|
3029
|
+
title: z20.string()
|
|
2887
3030
|
}).parse(parsed);
|
|
2888
3031
|
if (update.draft !== void 0 && update.draft !== providerResult.draft) {
|
|
2889
3032
|
if (!providerResult.node_id) {
|
|
@@ -2944,11 +3087,11 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2944
3087
|
|
|
2945
3088
|
// src/tools/update-pull-request-feedback.ts
|
|
2946
3089
|
import {
|
|
2947
|
-
definePluginTool as
|
|
2948
|
-
PluginToolInputError as
|
|
2949
|
-
pluginToolOutputSchema as
|
|
3090
|
+
definePluginTool as definePluginTool16,
|
|
3091
|
+
PluginToolInputError as PluginToolInputError16,
|
|
3092
|
+
pluginToolOutputSchema as pluginToolOutputSchema16
|
|
2950
3093
|
} from "@sentry/junior-plugin-api";
|
|
2951
|
-
import * as
|
|
3094
|
+
import * as z21 from "zod";
|
|
2952
3095
|
var STATUS_TO_REACTION_CONTENT = {
|
|
2953
3096
|
reviewing: "eyes",
|
|
2954
3097
|
addressed: "+1",
|
|
@@ -2968,24 +3111,24 @@ var REST_REACTION_CONTENT = new Map(
|
|
|
2968
3111
|
rest
|
|
2969
3112
|
])
|
|
2970
3113
|
);
|
|
2971
|
-
var
|
|
2972
|
-
repo:
|
|
2973
|
-
comment_kind:
|
|
3114
|
+
var inputSchema14 = z21.object({
|
|
3115
|
+
repo: z21.string().describe('Repository in "owner/name" format.'),
|
|
3116
|
+
comment_kind: z21.enum(["conversation", "review", "review_body"]).describe(
|
|
2974
3117
|
'Comment kind: "conversation" for a pull request conversation comment, "review" for an inline review comment, "review_body" for the body of a submitted review.'
|
|
2975
3118
|
),
|
|
2976
|
-
comment_id:
|
|
3119
|
+
comment_id: z21.number().int().positive().describe(
|
|
2977
3120
|
"GitHub comment id (conversation comment id, inline review comment id, or review id)."
|
|
2978
3121
|
),
|
|
2979
|
-
pull_request:
|
|
2980
|
-
status:
|
|
3122
|
+
pull_request: z21.number().int().positive().describe("Pull request number that the comment is on."),
|
|
3123
|
+
status: z21.enum(["addressed", "declined"]).describe(
|
|
2981
3124
|
"Feedback outcome. Maps to a reaction: addressed -> +1, declined -> -1."
|
|
2982
3125
|
)
|
|
2983
3126
|
}).strict();
|
|
2984
|
-
var
|
|
2985
|
-
target:
|
|
2986
|
-
repo:
|
|
2987
|
-
comment_id:
|
|
2988
|
-
status:
|
|
3127
|
+
var outputSchema14 = pluginToolOutputSchema16.extend({
|
|
3128
|
+
target: z21.literal("updatePullRequestFeedback"),
|
|
3129
|
+
repo: z21.string(),
|
|
3130
|
+
comment_id: z21.number(),
|
|
3131
|
+
status: z21.enum(["addressed", "declined"])
|
|
2989
3132
|
});
|
|
2990
3133
|
function pullRequestCommentPath(input) {
|
|
2991
3134
|
const segment = input.commentKind === "conversation" ? "issues" : "pulls";
|
|
@@ -2997,10 +3140,10 @@ function pullRequestCommentReactionsPath(input) {
|
|
|
2997
3140
|
function pullRequestFeedbackReactionContent(status) {
|
|
2998
3141
|
return STATUS_TO_REACTION_CONTENT[status];
|
|
2999
3142
|
}
|
|
3000
|
-
var reactionSchema =
|
|
3001
|
-
id:
|
|
3002
|
-
content:
|
|
3003
|
-
user:
|
|
3143
|
+
var reactionSchema = z21.object({
|
|
3144
|
+
id: z21.number(),
|
|
3145
|
+
content: z21.string(),
|
|
3146
|
+
user: z21.object({ id: z21.number() }).nullable()
|
|
3004
3147
|
});
|
|
3005
3148
|
async function commentParentNumber(egress, input) {
|
|
3006
3149
|
const commentResponse = await githubApi(egress, {
|
|
@@ -3010,25 +3153,25 @@ async function commentParentNumber(egress, input) {
|
|
|
3010
3153
|
const commentPayload = commentResponse.body;
|
|
3011
3154
|
if (!commentResponse.ok) {
|
|
3012
3155
|
const message = `GitHub comment lookup failed with HTTP ${commentResponse.status}: ${githubErrorMessage(commentPayload)}`;
|
|
3013
|
-
if (commentResponse.status === 404) throw new
|
|
3156
|
+
if (commentResponse.status === 404) throw new PluginToolInputError16(message);
|
|
3014
3157
|
throw new Error(message);
|
|
3015
3158
|
}
|
|
3016
|
-
const comment =
|
|
3017
|
-
issue_url:
|
|
3018
|
-
pull_request_url:
|
|
3159
|
+
const comment = z21.object({
|
|
3160
|
+
issue_url: z21.string().optional(),
|
|
3161
|
+
pull_request_url: z21.string().optional()
|
|
3019
3162
|
}).safeParse(commentPayload);
|
|
3020
3163
|
const parentUrl = comment.success ? input.commentKind === "conversation" ? comment.data.issue_url : comment.data.pull_request_url : void 0;
|
|
3021
|
-
const
|
|
3022
|
-
if (!
|
|
3164
|
+
const number31 = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
|
|
3165
|
+
if (!number31) {
|
|
3023
3166
|
throw new Error("GitHub comment did not name its issue or pull request.");
|
|
3024
3167
|
}
|
|
3025
|
-
return
|
|
3168
|
+
return number31;
|
|
3026
3169
|
}
|
|
3027
3170
|
async function assertBotAuthoredPullRequest(egress, input) {
|
|
3028
|
-
const { number:
|
|
3171
|
+
const { number: number31 } = input;
|
|
3029
3172
|
const pullResponse = await githubApi(egress, {
|
|
3030
3173
|
operation: "github.pull.get",
|
|
3031
|
-
path: `${repoPath(input)}/pulls/${
|
|
3174
|
+
path: `${repoPath(input)}/pulls/${number31}`
|
|
3032
3175
|
});
|
|
3033
3176
|
const pullPayload = pullResponse.body;
|
|
3034
3177
|
if (!pullResponse.ok && pullResponse.status !== 404) {
|
|
@@ -3036,9 +3179,9 @@ async function assertBotAuthoredPullRequest(egress, input) {
|
|
|
3036
3179
|
`GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${githubErrorMessage(pullPayload)}`
|
|
3037
3180
|
);
|
|
3038
3181
|
}
|
|
3039
|
-
const pull =
|
|
3182
|
+
const pull = z21.object({ user: z21.object({ id: z21.number() }).nullable() }).safeParse(pullPayload);
|
|
3040
3183
|
if (!pullResponse.ok || !pull.success || pull.data.user?.id !== input.botUserId) {
|
|
3041
|
-
throw new
|
|
3184
|
+
throw new PluginToolInputError16(
|
|
3042
3185
|
"This bot can only set feedback status on comments on pull requests it authored."
|
|
3043
3186
|
);
|
|
3044
3187
|
}
|
|
@@ -3069,14 +3212,14 @@ var REVIEW_REACTIONS_QUERY = `query ReviewReactions($subjectId: ID!) {
|
|
|
3069
3212
|
}
|
|
3070
3213
|
}
|
|
3071
3214
|
}`;
|
|
3072
|
-
var reviewReactionsSchema =
|
|
3073
|
-
data:
|
|
3074
|
-
node:
|
|
3075
|
-
reactionGroups:
|
|
3076
|
-
|
|
3077
|
-
content:
|
|
3078
|
-
reactors:
|
|
3079
|
-
nodes:
|
|
3215
|
+
var reviewReactionsSchema = z21.object({
|
|
3216
|
+
data: z21.object({
|
|
3217
|
+
node: z21.object({
|
|
3218
|
+
reactionGroups: z21.array(
|
|
3219
|
+
z21.object({
|
|
3220
|
+
content: z21.string(),
|
|
3221
|
+
reactors: z21.object({
|
|
3222
|
+
nodes: z21.array(z21.object({ databaseId: z21.number().optional() }))
|
|
3080
3223
|
})
|
|
3081
3224
|
})
|
|
3082
3225
|
)
|
|
@@ -3086,7 +3229,7 @@ var reviewReactionsSchema = z19.object({
|
|
|
3086
3229
|
async function commentReactions(egress, input) {
|
|
3087
3230
|
const parentNumber = await commentParentNumber(egress, input);
|
|
3088
3231
|
if (parentNumber !== String(input.pullRequest)) {
|
|
3089
|
-
throw new
|
|
3232
|
+
throw new PluginToolInputError16(
|
|
3090
3233
|
`GitHub comment ${input.commentId} is not on pull request ${input.pullRequest}.`
|
|
3091
3234
|
);
|
|
3092
3235
|
}
|
|
@@ -3096,7 +3239,7 @@ async function commentReactions(egress, input) {
|
|
|
3096
3239
|
operation: "github.pull.comment-reaction.list",
|
|
3097
3240
|
path: `${path}?per_page=100`
|
|
3098
3241
|
}),
|
|
3099
|
-
botReactions: (body) =>
|
|
3242
|
+
botReactions: (body) => z21.array(reactionSchema).parse(body).filter((reaction) => reaction.user?.id === input.botUserId),
|
|
3100
3243
|
remove: (reaction) => githubApi(egress, {
|
|
3101
3244
|
operation: "github.pull.comment-reaction.delete",
|
|
3102
3245
|
method: "DELETE",
|
|
@@ -3117,10 +3260,10 @@ async function reviewBodyReactions(egress, input) {
|
|
|
3117
3260
|
});
|
|
3118
3261
|
if (!reviewResponse.ok) {
|
|
3119
3262
|
const message = `GitHub review lookup failed with HTTP ${reviewResponse.status}: ${githubErrorMessage(reviewResponse.body)}`;
|
|
3120
|
-
if (reviewResponse.status === 404) throw new
|
|
3263
|
+
if (reviewResponse.status === 404) throw new PluginToolInputError16(message);
|
|
3121
3264
|
throw new Error(message);
|
|
3122
3265
|
}
|
|
3123
|
-
const subjectId =
|
|
3266
|
+
const subjectId = z21.object({ node_id: z21.string().min(1) }).parse(reviewResponse.body).node_id;
|
|
3124
3267
|
const graphql = (operation, operationName, query, variables) => githubApi(egress, {
|
|
3125
3268
|
operation,
|
|
3126
3269
|
method: "POST",
|
|
@@ -3157,7 +3300,7 @@ function failed(response) {
|
|
|
3157
3300
|
return !response.ok || Array.isArray(errors) && errors.length > 0;
|
|
3158
3301
|
}
|
|
3159
3302
|
function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
3160
|
-
return
|
|
3303
|
+
return definePluginTool16({
|
|
3161
3304
|
// No action review: the tool checks in code that the bot authored the pull
|
|
3162
3305
|
// request, and it changes only the bot's own reaction, which is reversible.
|
|
3163
3306
|
approvalMode: "approve",
|
|
@@ -3169,12 +3312,12 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
3169
3312
|
},
|
|
3170
3313
|
description: "Set your outcome reaction on GitHub pull request feedback: addressed (+1) or declined (-1). Use the pull_request, 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.",
|
|
3171
3314
|
exposure: "direct",
|
|
3172
|
-
inputSchema:
|
|
3173
|
-
outputSchema:
|
|
3315
|
+
inputSchema: inputSchema14,
|
|
3316
|
+
outputSchema: outputSchema14,
|
|
3174
3317
|
async execute(input) {
|
|
3175
|
-
const parsedInput =
|
|
3318
|
+
const parsedInput = inputSchema14.safeParse(input);
|
|
3176
3319
|
if (!parsedInput.success) {
|
|
3177
|
-
throw new
|
|
3320
|
+
throw new PluginToolInputError16(
|
|
3178
3321
|
"Invalid GitHub updatePullRequestFeedback input.",
|
|
3179
3322
|
{ cause: parsedInput.error }
|
|
3180
3323
|
);
|
|
@@ -3249,28 +3392,28 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
3249
3392
|
|
|
3250
3393
|
// src/tools/resolve-pull-request-review-thread.ts
|
|
3251
3394
|
import {
|
|
3252
|
-
definePluginTool as
|
|
3253
|
-
PluginToolInputError as
|
|
3254
|
-
pluginToolOutputSchema as
|
|
3395
|
+
definePluginTool as definePluginTool17,
|
|
3396
|
+
PluginToolInputError as PluginToolInputError17,
|
|
3397
|
+
pluginToolOutputSchema as pluginToolOutputSchema17
|
|
3255
3398
|
} from "@sentry/junior-plugin-api";
|
|
3256
|
-
import * as
|
|
3257
|
-
var
|
|
3258
|
-
repo:
|
|
3399
|
+
import * as z22 from "zod";
|
|
3400
|
+
var inputSchema15 = z22.object({
|
|
3401
|
+
repo: z22.string().describe(
|
|
3259
3402
|
'Repository in "owner/name" format. Required because GraphQL has no repo path.'
|
|
3260
3403
|
),
|
|
3261
|
-
thread_id:
|
|
3404
|
+
thread_id: z22.string().trim().min(1).describe(
|
|
3262
3405
|
"GitHub pull request review thread node ID (the `threadId` / `id` variable used by `gh api graphql` resolveReviewThread)."
|
|
3263
3406
|
)
|
|
3264
3407
|
}).strict();
|
|
3265
|
-
var
|
|
3266
|
-
target:
|
|
3267
|
-
repo:
|
|
3268
|
-
number:
|
|
3269
|
-
thread_id:
|
|
3270
|
-
resolved:
|
|
3408
|
+
var outputSchema15 = pluginToolOutputSchema17.extend({
|
|
3409
|
+
target: z22.literal("resolvePullRequestReviewThread"),
|
|
3410
|
+
repo: z22.string(),
|
|
3411
|
+
number: z22.number(),
|
|
3412
|
+
thread_id: z22.string(),
|
|
3413
|
+
resolved: z22.boolean()
|
|
3271
3414
|
});
|
|
3272
3415
|
function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
3273
|
-
return
|
|
3416
|
+
return definePluginTool17({
|
|
3274
3417
|
// No action review: the tool checks in code that the bot authored the pull
|
|
3275
3418
|
// request, and it changes only the thread's resolved state, which is
|
|
3276
3419
|
// reversible.
|
|
@@ -3283,12 +3426,12 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3283
3426
|
},
|
|
3284
3427
|
description: "Resolve a GitHub pull request review thread after acting on its feedback. Only works on pull requests the bot authored.",
|
|
3285
3428
|
exposure: "direct",
|
|
3286
|
-
inputSchema:
|
|
3287
|
-
outputSchema:
|
|
3429
|
+
inputSchema: inputSchema15,
|
|
3430
|
+
outputSchema: outputSchema15,
|
|
3288
3431
|
async execute(input) {
|
|
3289
|
-
const parsedInput =
|
|
3432
|
+
const parsedInput = inputSchema15.safeParse(input);
|
|
3290
3433
|
if (!parsedInput.success) {
|
|
3291
|
-
throw new
|
|
3434
|
+
throw new PluginToolInputError17(
|
|
3292
3435
|
"Invalid GitHub resolvePullRequestReviewThread input.",
|
|
3293
3436
|
{ cause: parsedInput.error }
|
|
3294
3437
|
);
|
|
@@ -3327,31 +3470,31 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3327
3470
|
`GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubErrorMessage(lookupPayload)}`
|
|
3328
3471
|
);
|
|
3329
3472
|
}
|
|
3330
|
-
const threadNodeSchema =
|
|
3331
|
-
id:
|
|
3332
|
-
isResolved:
|
|
3333
|
-
pullRequest:
|
|
3334
|
-
author:
|
|
3335
|
-
number:
|
|
3336
|
-
repository:
|
|
3473
|
+
const threadNodeSchema = z22.object({
|
|
3474
|
+
id: z22.string(),
|
|
3475
|
+
isResolved: z22.boolean(),
|
|
3476
|
+
pullRequest: z22.object({
|
|
3477
|
+
author: z22.object({ databaseId: z22.number().optional() }).passthrough().nullable(),
|
|
3478
|
+
number: z22.number(),
|
|
3479
|
+
repository: z22.object({ nameWithOwner: z22.string() }).passthrough()
|
|
3337
3480
|
}).passthrough()
|
|
3338
3481
|
}).passthrough();
|
|
3339
|
-
const lookupResultSchema =
|
|
3340
|
-
data:
|
|
3341
|
-
node:
|
|
3482
|
+
const lookupResultSchema = z22.object({
|
|
3483
|
+
data: z22.object({
|
|
3484
|
+
node: z22.unknown().nullable().optional()
|
|
3342
3485
|
}).passthrough()
|
|
3343
3486
|
}).passthrough();
|
|
3344
3487
|
const lookupResult = lookupResultSchema.safeParse(lookupPayload);
|
|
3345
3488
|
const rawNode = lookupResult.success ? lookupResult.data.data.node : void 0;
|
|
3346
3489
|
const parsedNode = rawNode == null ? void 0 : threadNodeSchema.safeParse(rawNode);
|
|
3347
3490
|
if (!parsedNode?.success) {
|
|
3348
|
-
throw new
|
|
3491
|
+
throw new PluginToolInputError17("GitHub review thread was not found.");
|
|
3349
3492
|
}
|
|
3350
3493
|
const thread = parsedNode.data;
|
|
3351
3494
|
const pullRequest = thread.pullRequest;
|
|
3352
3495
|
const ownsPullRequest = pullRequest.repository.nameWithOwner.toLowerCase() === repo.ref.toLowerCase() && pullRequest.author?.databaseId === botUserId;
|
|
3353
3496
|
if (!ownsPullRequest) {
|
|
3354
|
-
throw new
|
|
3497
|
+
throw new PluginToolInputError17(
|
|
3355
3498
|
"This bot can only resolve review threads on pull requests it authored."
|
|
3356
3499
|
);
|
|
3357
3500
|
}
|
|
@@ -3385,10 +3528,10 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3385
3528
|
`GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubErrorMessage(resolvePayload)}`
|
|
3386
3529
|
);
|
|
3387
3530
|
}
|
|
3388
|
-
const resolveResultSchema =
|
|
3389
|
-
data:
|
|
3390
|
-
resolveReviewThread:
|
|
3391
|
-
thread:
|
|
3531
|
+
const resolveResultSchema = z22.object({
|
|
3532
|
+
data: z22.object({
|
|
3533
|
+
resolveReviewThread: z22.object({
|
|
3534
|
+
thread: z22.object({ id: z22.string(), isResolved: z22.boolean() }).passthrough()
|
|
3392
3535
|
}).passthrough()
|
|
3393
3536
|
}).passthrough()
|
|
3394
3537
|
}).passthrough();
|
|
@@ -3416,46 +3559,46 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3416
3559
|
|
|
3417
3560
|
// src/tools/submit-pull-request-review.ts
|
|
3418
3561
|
import {
|
|
3419
|
-
definePluginTool as
|
|
3420
|
-
PluginToolInputError as
|
|
3421
|
-
pluginToolOutputSchema as
|
|
3562
|
+
definePluginTool as definePluginTool18,
|
|
3563
|
+
PluginToolInputError as PluginToolInputError18,
|
|
3564
|
+
pluginToolOutputSchema as pluginToolOutputSchema18
|
|
3422
3565
|
} from "@sentry/junior-plugin-api";
|
|
3423
|
-
import * as
|
|
3424
|
-
var reviewCommentSchema =
|
|
3425
|
-
path:
|
|
3426
|
-
body:
|
|
3427
|
-
line:
|
|
3428
|
-
side:
|
|
3429
|
-
start_line:
|
|
3430
|
-
start_side:
|
|
3566
|
+
import * as z23 from "zod";
|
|
3567
|
+
var reviewCommentSchema = z23.object({
|
|
3568
|
+
path: z23.string().trim().min(1).describe("File path in the pull request."),
|
|
3569
|
+
body: z23.string().trim().min(1).describe("Inline review comment."),
|
|
3570
|
+
line: z23.number().int().positive().describe("Line in the pull request diff."),
|
|
3571
|
+
side: z23.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
|
|
3572
|
+
start_line: z23.number().int().positive().optional().describe("First line of a multi-line comment."),
|
|
3573
|
+
start_side: z23.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
|
|
3431
3574
|
}).strict().refine(
|
|
3432
3575
|
({ start_line, start_side }) => start_line === void 0 === (start_side === void 0),
|
|
3433
3576
|
{ message: "start_line and start_side must be provided together." }
|
|
3434
3577
|
);
|
|
3435
|
-
var
|
|
3436
|
-
repo:
|
|
3437
|
-
number:
|
|
3438
|
-
event:
|
|
3439
|
-
body:
|
|
3440
|
-
comments:
|
|
3578
|
+
var inputSchema16 = z23.object({
|
|
3579
|
+
repo: z23.string().describe('Repository in "owner/name" format.'),
|
|
3580
|
+
number: z23.number().int().positive().describe("Pull request number."),
|
|
3581
|
+
event: z23.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
|
|
3582
|
+
body: z23.string().trim().min(1).describe("Review summary."),
|
|
3583
|
+
comments: z23.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
|
|
3441
3584
|
}).strict();
|
|
3442
|
-
var
|
|
3443
|
-
target:
|
|
3444
|
-
repo:
|
|
3445
|
-
number:
|
|
3446
|
-
review_id:
|
|
3447
|
-
state:
|
|
3448
|
-
url:
|
|
3585
|
+
var outputSchema16 = pluginToolOutputSchema18.extend({
|
|
3586
|
+
target: z23.literal("submitPullRequestReview"),
|
|
3587
|
+
repo: z23.string(),
|
|
3588
|
+
number: z23.number(),
|
|
3589
|
+
review_id: z23.number(),
|
|
3590
|
+
state: z23.string(),
|
|
3591
|
+
url: z23.string()
|
|
3449
3592
|
});
|
|
3450
3593
|
function throwReviewError(status, body) {
|
|
3451
3594
|
const message = `GitHub pull request review failed with HTTP ${status}: ${githubErrorMessage(body)}`;
|
|
3452
3595
|
if (status === 404 || status === 422) {
|
|
3453
|
-
throw new
|
|
3596
|
+
throw new PluginToolInputError18(message);
|
|
3454
3597
|
}
|
|
3455
3598
|
throw new Error(message);
|
|
3456
3599
|
}
|
|
3457
3600
|
function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
3458
|
-
return
|
|
3601
|
+
return definePluginTool18({
|
|
3459
3602
|
annotations: {
|
|
3460
3603
|
destructiveHint: true,
|
|
3461
3604
|
idempotentHint: false,
|
|
@@ -3463,8 +3606,8 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3463
3606
|
readOnlyHint: false
|
|
3464
3607
|
},
|
|
3465
3608
|
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.",
|
|
3466
|
-
inputSchema:
|
|
3467
|
-
outputSchema:
|
|
3609
|
+
inputSchema: inputSchema16,
|
|
3610
|
+
outputSchema: outputSchema16,
|
|
3468
3611
|
async execute(review) {
|
|
3469
3612
|
const repo = parseRepo(review.repo);
|
|
3470
3613
|
const comments = review.comments?.map((comment) => ({
|
|
@@ -3488,7 +3631,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3488
3631
|
if (!response.ok) {
|
|
3489
3632
|
throwReviewError(response.status, response.body);
|
|
3490
3633
|
}
|
|
3491
|
-
const providerResult =
|
|
3634
|
+
const providerResult = z23.object({ id: z23.number(), html_url: z23.string(), state: z23.string() }).parse(response.body);
|
|
3492
3635
|
return {
|
|
3493
3636
|
target: "submitPullRequestReview",
|
|
3494
3637
|
repo: repo.ref,
|
|
@@ -3505,6 +3648,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3505
3648
|
// src/tools.ts
|
|
3506
3649
|
function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
3507
3650
|
return {
|
|
3651
|
+
reactToIssue: createGitHubReactToIssueTool(ctx.egress),
|
|
3508
3652
|
cloneRepository: createGitHubCloneRepositoryTool(ctx),
|
|
3509
3653
|
commentOnIssue: createGitHubCommentOnIssueTool(ctx.egress),
|
|
3510
3654
|
commentOnPullRequest: createGitHubCommentOnPullRequestTool(ctx.egress),
|
|
@@ -3524,6 +3668,10 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
3524
3668
|
ctx.egress
|
|
3525
3669
|
),
|
|
3526
3670
|
updateIssue: createGitHubUpdateIssueTool(ctx),
|
|
3671
|
+
updateIssueComment: createGitHubUpdateIssueCommentTool(
|
|
3672
|
+
ctx.egress,
|
|
3673
|
+
botEmail
|
|
3674
|
+
),
|
|
3527
3675
|
updatePullRequest: createGitHubUpdatePullRequestTool(ctx),
|
|
3528
3676
|
updatePullRequestFeedback: createGitHubUpdatePullRequestFeedbackTool(
|
|
3529
3677
|
ctx,
|
|
@@ -3534,26 +3682,26 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
3534
3682
|
|
|
3535
3683
|
// src/webhooks/handler.ts
|
|
3536
3684
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
3537
|
-
import * as
|
|
3685
|
+
import * as z37 from "zod";
|
|
3538
3686
|
|
|
3539
3687
|
// src/issue-outcomes/store.ts
|
|
3540
3688
|
import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
|
|
3541
|
-
import * as
|
|
3542
|
-
var githubIssueOutcomeInputSchema =
|
|
3543
|
-
candidateOwned:
|
|
3544
|
-
closedAt:
|
|
3545
|
-
issueId:
|
|
3546
|
-
number:
|
|
3547
|
-
openedAt:
|
|
3548
|
-
repositoryFullName:
|
|
3549
|
-
repositoryId:
|
|
3689
|
+
import * as z24 from "zod";
|
|
3690
|
+
var githubIssueOutcomeInputSchema = z24.object({
|
|
3691
|
+
candidateOwned: z24.boolean(),
|
|
3692
|
+
closedAt: z24.date().optional(),
|
|
3693
|
+
issueId: z24.string().min(1),
|
|
3694
|
+
number: z24.number().int().positive(),
|
|
3695
|
+
openedAt: z24.date(),
|
|
3696
|
+
repositoryFullName: z24.string().min(1),
|
|
3697
|
+
repositoryId: z24.string().min(1),
|
|
3550
3698
|
state: githubIssueStateSchema,
|
|
3551
3699
|
stateReason: githubIssueStateReasonSchema.optional(),
|
|
3552
|
-
updatedAt:
|
|
3700
|
+
updatedAt: z24.date()
|
|
3553
3701
|
}).strict();
|
|
3554
|
-
var githubIssueConversationsInputSchema =
|
|
3555
|
-
conversationIds:
|
|
3556
|
-
issueId:
|
|
3702
|
+
var githubIssueConversationsInputSchema = z24.object({
|
|
3703
|
+
conversationIds: z24.array(z24.string().min(1)).min(1),
|
|
3704
|
+
issueId: z24.string().min(1)
|
|
3557
3705
|
}).strict();
|
|
3558
3706
|
function projectionValues(input) {
|
|
3559
3707
|
return {
|
|
@@ -3617,33 +3765,33 @@ async function recordGitHubIssueConversations(db, input) {
|
|
|
3617
3765
|
|
|
3618
3766
|
// src/pull-request-outcomes/store.ts
|
|
3619
3767
|
import { and as and3, eq as eq3, lt as lt2, lte as lte2, ne, sql as sql3 } from "drizzle-orm";
|
|
3620
|
-
import * as
|
|
3621
|
-
var githubPullRequestOutcomeInputSchema =
|
|
3622
|
-
candidateOwned:
|
|
3623
|
-
closedAt:
|
|
3768
|
+
import * as z25 from "zod";
|
|
3769
|
+
var githubPullRequestOutcomeInputSchema = z25.object({
|
|
3770
|
+
candidateOwned: z25.boolean(),
|
|
3771
|
+
closedAt: z25.date().optional(),
|
|
3624
3772
|
commitComposition: githubPullRequestCommitCompositionSchema.optional(),
|
|
3625
|
-
mergedAt:
|
|
3626
|
-
number:
|
|
3627
|
-
openedAt:
|
|
3628
|
-
pullRequestId:
|
|
3629
|
-
repositoryFullName:
|
|
3630
|
-
repositoryId:
|
|
3773
|
+
mergedAt: z25.date().optional(),
|
|
3774
|
+
number: z25.number().int().positive(),
|
|
3775
|
+
openedAt: z25.date(),
|
|
3776
|
+
pullRequestId: z25.string().min(1),
|
|
3777
|
+
repositoryFullName: z25.string().min(1),
|
|
3778
|
+
repositoryId: z25.string().min(1),
|
|
3631
3779
|
state: githubPullRequestStateSchema,
|
|
3632
|
-
title:
|
|
3633
|
-
updatedAt:
|
|
3780
|
+
title: z25.string().min(1).optional(),
|
|
3781
|
+
updatedAt: z25.date()
|
|
3634
3782
|
}).strict();
|
|
3635
|
-
var githubPullRequestConversationsInputSchema =
|
|
3636
|
-
conversationIds:
|
|
3637
|
-
pullRequestId:
|
|
3783
|
+
var githubPullRequestConversationsInputSchema = z25.object({
|
|
3784
|
+
conversationIds: z25.array(z25.string().min(1)).min(1),
|
|
3785
|
+
pullRequestId: z25.string().min(1)
|
|
3638
3786
|
}).strict();
|
|
3639
|
-
var githubPullRequestLinkedIssuesInputSchema =
|
|
3640
|
-
linkedIssues:
|
|
3641
|
-
|
|
3642
|
-
number:
|
|
3643
|
-
repositoryFullName:
|
|
3787
|
+
var githubPullRequestLinkedIssuesInputSchema = z25.object({
|
|
3788
|
+
linkedIssues: z25.array(
|
|
3789
|
+
z25.object({
|
|
3790
|
+
number: z25.number().int().positive(),
|
|
3791
|
+
repositoryFullName: z25.string().min(1)
|
|
3644
3792
|
}).strict()
|
|
3645
3793
|
).min(1),
|
|
3646
|
-
pullRequestId:
|
|
3794
|
+
pullRequestId: z25.string().min(1)
|
|
3647
3795
|
}).strict();
|
|
3648
3796
|
function projectionValues2(input) {
|
|
3649
3797
|
return {
|
|
@@ -3895,39 +4043,39 @@ async function applyGitHubPullRequestOutcome(args) {
|
|
|
3895
4043
|
}
|
|
3896
4044
|
|
|
3897
4045
|
// src/webhooks/issue-outcome.ts
|
|
3898
|
-
import * as
|
|
3899
|
-
var canonicalIssueOutcomeSchema =
|
|
3900
|
-
action:
|
|
3901
|
-
issue:
|
|
3902
|
-
body:
|
|
3903
|
-
closed_at:
|
|
3904
|
-
created_at:
|
|
3905
|
-
id:
|
|
3906
|
-
number:
|
|
4046
|
+
import * as z26 from "zod";
|
|
4047
|
+
var canonicalIssueOutcomeSchema = z26.object({
|
|
4048
|
+
action: z26.enum(["opened", "closed", "reopened"]),
|
|
4049
|
+
issue: z26.object({
|
|
4050
|
+
body: z26.string().nullable().optional(),
|
|
4051
|
+
closed_at: z26.string().nullable().optional(),
|
|
4052
|
+
created_at: z26.string(),
|
|
4053
|
+
id: z26.number().int().positive(),
|
|
4054
|
+
number: z26.number().int().positive(),
|
|
3907
4055
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3908
|
-
updated_at:
|
|
3909
|
-
user:
|
|
4056
|
+
updated_at: z26.string(),
|
|
4057
|
+
user: z26.object({ login: z26.string().min(1) }).strict()
|
|
3910
4058
|
}).strict(),
|
|
3911
|
-
repository:
|
|
3912
|
-
full_name:
|
|
3913
|
-
id:
|
|
4059
|
+
repository: z26.object({
|
|
4060
|
+
full_name: z26.string().min(1),
|
|
4061
|
+
id: z26.number().int().positive()
|
|
3914
4062
|
}).strict()
|
|
3915
4063
|
}).strict();
|
|
3916
|
-
var issueOutcomeSchema =
|
|
3917
|
-
action:
|
|
3918
|
-
issue:
|
|
3919
|
-
body:
|
|
3920
|
-
closed_at:
|
|
3921
|
-
created_at:
|
|
3922
|
-
id:
|
|
3923
|
-
number:
|
|
4064
|
+
var issueOutcomeSchema = z26.object({
|
|
4065
|
+
action: z26.enum(["opened", "closed", "reopened"]),
|
|
4066
|
+
issue: z26.object({
|
|
4067
|
+
body: z26.string().nullable().optional(),
|
|
4068
|
+
closed_at: z26.string().nullable().optional(),
|
|
4069
|
+
created_at: z26.string(),
|
|
4070
|
+
id: z26.number().int().positive(),
|
|
4071
|
+
number: z26.number().int().positive(),
|
|
3924
4072
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3925
|
-
updated_at:
|
|
3926
|
-
user:
|
|
4073
|
+
updated_at: z26.string(),
|
|
4074
|
+
user: z26.object({ login: z26.string().min(1) }).passthrough()
|
|
3927
4075
|
}).passthrough(),
|
|
3928
|
-
repository:
|
|
3929
|
-
full_name:
|
|
3930
|
-
id:
|
|
4076
|
+
repository: z26.object({
|
|
4077
|
+
full_name: z26.string().min(1),
|
|
4078
|
+
id: z26.number().int().positive()
|
|
3931
4079
|
}).passthrough()
|
|
3932
4080
|
}).passthrough().transform(
|
|
3933
4081
|
(provider) => canonicalIssueOutcomeSchema.parse({
|
|
@@ -3948,7 +4096,7 @@ var issueOutcomeSchema = z24.object({
|
|
|
3948
4096
|
}
|
|
3949
4097
|
})
|
|
3950
4098
|
);
|
|
3951
|
-
var issueLifecycleActionSchema =
|
|
4099
|
+
var issueLifecycleActionSchema = z26.object({ action: z26.string() }).passthrough();
|
|
3952
4100
|
function timestamp2(value) {
|
|
3953
4101
|
if (!value) return void 0;
|
|
3954
4102
|
const parsed = new Date(value);
|
|
@@ -3992,21 +4140,21 @@ function normalizeGitHubIssueOutcome(args) {
|
|
|
3992
4140
|
updatedAt
|
|
3993
4141
|
};
|
|
3994
4142
|
}
|
|
3995
|
-
var canonicalIssueConversationSchema =
|
|
3996
|
-
issue:
|
|
3997
|
-
body:
|
|
3998
|
-
id:
|
|
3999
|
-
user:
|
|
4143
|
+
var canonicalIssueConversationSchema = z26.object({
|
|
4144
|
+
issue: z26.object({
|
|
4145
|
+
body: z26.string().nullable().optional(),
|
|
4146
|
+
id: z26.number().int().positive(),
|
|
4147
|
+
user: z26.object({ login: z26.string().min(1) }).strict()
|
|
4000
4148
|
}).strict(),
|
|
4001
|
-
sender:
|
|
4149
|
+
sender: z26.object({ login: z26.string().min(1) }).strict().optional()
|
|
4002
4150
|
}).strict();
|
|
4003
|
-
var issueConversationSchema =
|
|
4004
|
-
issue:
|
|
4005
|
-
body:
|
|
4006
|
-
id:
|
|
4007
|
-
user:
|
|
4151
|
+
var issueConversationSchema = z26.object({
|
|
4152
|
+
issue: z26.object({
|
|
4153
|
+
body: z26.string().nullable().optional(),
|
|
4154
|
+
id: z26.number().int().positive(),
|
|
4155
|
+
user: z26.object({ login: z26.string().min(1) }).passthrough()
|
|
4008
4156
|
}).passthrough(),
|
|
4009
|
-
sender:
|
|
4157
|
+
sender: z26.object({ login: z26.string().min(1) }).passthrough().optional()
|
|
4010
4158
|
}).passthrough().transform(
|
|
4011
4159
|
(provider) => canonicalIssueConversationSchema.parse({
|
|
4012
4160
|
issue: {
|
|
@@ -4033,43 +4181,43 @@ function normalizeGitHubIssueConversations(args) {
|
|
|
4033
4181
|
}
|
|
4034
4182
|
|
|
4035
4183
|
// src/webhooks/pull-request-outcome.ts
|
|
4036
|
-
import * as
|
|
4037
|
-
var canonicalPullRequestOutcomeSchema =
|
|
4038
|
-
action:
|
|
4039
|
-
pull_request:
|
|
4040
|
-
body:
|
|
4041
|
-
closed_at:
|
|
4042
|
-
created_at:
|
|
4043
|
-
id:
|
|
4044
|
-
merged:
|
|
4045
|
-
merged_at:
|
|
4046
|
-
number:
|
|
4047
|
-
title:
|
|
4048
|
-
updated_at:
|
|
4049
|
-
user:
|
|
4184
|
+
import * as z27 from "zod";
|
|
4185
|
+
var canonicalPullRequestOutcomeSchema = z27.object({
|
|
4186
|
+
action: z27.enum(["opened", "closed", "reopened"]),
|
|
4187
|
+
pull_request: z27.object({
|
|
4188
|
+
body: z27.string().nullable().optional(),
|
|
4189
|
+
closed_at: z27.string().nullable().optional(),
|
|
4190
|
+
created_at: z27.string(),
|
|
4191
|
+
id: z27.number().int().positive(),
|
|
4192
|
+
merged: z27.boolean(),
|
|
4193
|
+
merged_at: z27.string().nullable().optional(),
|
|
4194
|
+
number: z27.number().int().positive(),
|
|
4195
|
+
title: z27.string().min(1).optional(),
|
|
4196
|
+
updated_at: z27.string(),
|
|
4197
|
+
user: z27.object({ login: z27.string().min(1) }).strict()
|
|
4050
4198
|
}).strict(),
|
|
4051
|
-
repository:
|
|
4052
|
-
full_name:
|
|
4053
|
-
id:
|
|
4199
|
+
repository: z27.object({
|
|
4200
|
+
full_name: z27.string().min(1),
|
|
4201
|
+
id: z27.number().int().positive()
|
|
4054
4202
|
}).strict()
|
|
4055
4203
|
}).strict();
|
|
4056
|
-
var pullRequestOutcomeSchema =
|
|
4057
|
-
action:
|
|
4058
|
-
pull_request:
|
|
4059
|
-
body:
|
|
4060
|
-
closed_at:
|
|
4061
|
-
created_at:
|
|
4062
|
-
id:
|
|
4063
|
-
merged:
|
|
4064
|
-
merged_at:
|
|
4065
|
-
number:
|
|
4066
|
-
title:
|
|
4067
|
-
updated_at:
|
|
4068
|
-
user:
|
|
4204
|
+
var pullRequestOutcomeSchema = z27.object({
|
|
4205
|
+
action: z27.enum(["opened", "closed", "reopened"]),
|
|
4206
|
+
pull_request: z27.object({
|
|
4207
|
+
body: z27.string().nullable().optional(),
|
|
4208
|
+
closed_at: z27.string().nullable().optional(),
|
|
4209
|
+
created_at: z27.string(),
|
|
4210
|
+
id: z27.number().int().positive(),
|
|
4211
|
+
merged: z27.boolean(),
|
|
4212
|
+
merged_at: z27.string().nullable().optional(),
|
|
4213
|
+
number: z27.number().int().positive(),
|
|
4214
|
+
title: z27.string().min(1).optional(),
|
|
4215
|
+
updated_at: z27.string(),
|
|
4216
|
+
user: z27.object({ login: z27.string().min(1) }).passthrough()
|
|
4069
4217
|
}).passthrough(),
|
|
4070
|
-
repository:
|
|
4071
|
-
full_name:
|
|
4072
|
-
id:
|
|
4218
|
+
repository: z27.object({
|
|
4219
|
+
full_name: z27.string().min(1),
|
|
4220
|
+
id: z27.number().int().positive()
|
|
4073
4221
|
}).passthrough()
|
|
4074
4222
|
}).passthrough().transform(
|
|
4075
4223
|
(provider) => canonicalPullRequestOutcomeSchema.parse({
|
|
@@ -4092,24 +4240,24 @@ var pullRequestOutcomeSchema = z25.object({
|
|
|
4092
4240
|
}
|
|
4093
4241
|
})
|
|
4094
4242
|
);
|
|
4095
|
-
var pullRequestLifecycleActionSchema =
|
|
4096
|
-
var canonicalPullRequestConversationSchema =
|
|
4097
|
-
pull_request:
|
|
4098
|
-
body:
|
|
4099
|
-
id:
|
|
4100
|
-
user:
|
|
4243
|
+
var pullRequestLifecycleActionSchema = z27.object({ action: z27.string() }).passthrough();
|
|
4244
|
+
var canonicalPullRequestConversationSchema = z27.object({
|
|
4245
|
+
pull_request: z27.object({
|
|
4246
|
+
body: z27.string().nullable().optional(),
|
|
4247
|
+
id: z27.number().int().positive(),
|
|
4248
|
+
user: z27.object({ login: z27.string().min(1) }).strict()
|
|
4101
4249
|
}).strict(),
|
|
4102
|
-
repository:
|
|
4103
|
-
sender:
|
|
4250
|
+
repository: z27.object({ full_name: z27.string().min(1) }).strict(),
|
|
4251
|
+
sender: z27.object({ login: z27.string().min(1) }).strict()
|
|
4104
4252
|
}).strict();
|
|
4105
|
-
var pullRequestConversationSchema =
|
|
4106
|
-
pull_request:
|
|
4107
|
-
body:
|
|
4108
|
-
id:
|
|
4109
|
-
user:
|
|
4253
|
+
var pullRequestConversationSchema = z27.object({
|
|
4254
|
+
pull_request: z27.object({
|
|
4255
|
+
body: z27.string().nullable().optional(),
|
|
4256
|
+
id: z27.number().int().positive(),
|
|
4257
|
+
user: z27.object({ login: z27.string().min(1) }).passthrough()
|
|
4110
4258
|
}).passthrough(),
|
|
4111
|
-
repository:
|
|
4112
|
-
sender:
|
|
4259
|
+
repository: z27.object({ full_name: z27.string().min(1) }).passthrough(),
|
|
4260
|
+
sender: z27.object({ login: z27.string().min(1) }).passthrough()
|
|
4113
4261
|
}).passthrough().transform(
|
|
4114
4262
|
(provider) => canonicalPullRequestConversationSchema.parse({
|
|
4115
4263
|
pull_request: {
|
|
@@ -4194,17 +4342,17 @@ function normalizeGitHubPullRequestLinkedIssues(args) {
|
|
|
4194
4342
|
}
|
|
4195
4343
|
|
|
4196
4344
|
// src/webhooks/pull-request-activity.ts
|
|
4197
|
-
import * as
|
|
4198
|
-
var timestampSchema =
|
|
4199
|
-
var numberSchema =
|
|
4200
|
-
var repositorySchema2 =
|
|
4201
|
-
var senderSchema =
|
|
4345
|
+
import * as z28 from "zod";
|
|
4346
|
+
var timestampSchema = z28.iso.datetime({ offset: true });
|
|
4347
|
+
var numberSchema = z28.number().int().positive();
|
|
4348
|
+
var repositorySchema2 = z28.object({ id: numberSchema });
|
|
4349
|
+
var senderSchema = z28.object({ type: z28.string() });
|
|
4202
4350
|
var activitySchemas = {
|
|
4203
|
-
issue_comment:
|
|
4204
|
-
action:
|
|
4205
|
-
comment:
|
|
4351
|
+
issue_comment: z28.object({
|
|
4352
|
+
action: z28.literal("created"),
|
|
4353
|
+
comment: z28.object({ created_at: timestampSchema }),
|
|
4206
4354
|
// Only comments on a pull request carry `issue.pull_request`.
|
|
4207
|
-
issue:
|
|
4355
|
+
issue: z28.object({ number: numberSchema, pull_request: z28.object({}) }),
|
|
4208
4356
|
repository: repositorySchema2,
|
|
4209
4357
|
sender: senderSchema
|
|
4210
4358
|
}).transform((event) => ({
|
|
@@ -4213,9 +4361,9 @@ var activitySchemas = {
|
|
|
4213
4361
|
repositoryProviderId: String(event.repository.id),
|
|
4214
4362
|
senderType: event.sender.type
|
|
4215
4363
|
})),
|
|
4216
|
-
pull_request:
|
|
4217
|
-
action:
|
|
4218
|
-
pull_request:
|
|
4364
|
+
pull_request: z28.object({
|
|
4365
|
+
action: z28.literal("synchronize"),
|
|
4366
|
+
pull_request: z28.object({
|
|
4219
4367
|
number: numberSchema,
|
|
4220
4368
|
updated_at: timestampSchema
|
|
4221
4369
|
}),
|
|
@@ -4227,11 +4375,11 @@ var activitySchemas = {
|
|
|
4227
4375
|
repositoryProviderId: String(event.repository.id),
|
|
4228
4376
|
senderType: event.sender.type
|
|
4229
4377
|
})),
|
|
4230
|
-
pull_request_review:
|
|
4231
|
-
action:
|
|
4232
|
-
pull_request:
|
|
4378
|
+
pull_request_review: z28.object({
|
|
4379
|
+
action: z28.literal("submitted"),
|
|
4380
|
+
pull_request: z28.object({ number: numberSchema }),
|
|
4233
4381
|
repository: repositorySchema2,
|
|
4234
|
-
review:
|
|
4382
|
+
review: z28.object({ submitted_at: timestampSchema }),
|
|
4235
4383
|
sender: senderSchema
|
|
4236
4384
|
}).transform((event) => ({
|
|
4237
4385
|
at: new Date(event.review.submitted_at),
|
|
@@ -4239,10 +4387,10 @@ var activitySchemas = {
|
|
|
4239
4387
|
repositoryProviderId: String(event.repository.id),
|
|
4240
4388
|
senderType: event.sender.type
|
|
4241
4389
|
})),
|
|
4242
|
-
pull_request_review_comment:
|
|
4243
|
-
action:
|
|
4244
|
-
comment:
|
|
4245
|
-
pull_request:
|
|
4390
|
+
pull_request_review_comment: z28.object({
|
|
4391
|
+
action: z28.literal("created"),
|
|
4392
|
+
comment: z28.object({ created_at: timestampSchema }),
|
|
4393
|
+
pull_request: z28.object({ number: numberSchema }),
|
|
4246
4394
|
repository: repositorySchema2,
|
|
4247
4395
|
sender: senderSchema
|
|
4248
4396
|
}).transform((event) => ({
|
|
@@ -4261,20 +4409,20 @@ function normalizeGitHubPullRequestActivity(input) {
|
|
|
4261
4409
|
}
|
|
4262
4410
|
|
|
4263
4411
|
// src/webhooks/merge-conflict.ts
|
|
4264
|
-
import * as
|
|
4412
|
+
import * as z29 from "zod";
|
|
4265
4413
|
var EVENT_TYPE = "pull_request.merge_conflict";
|
|
4266
4414
|
var CLOSED_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
4267
4415
|
"pull_request.closed_unmerged",
|
|
4268
4416
|
"pull_request.merged"
|
|
4269
4417
|
]);
|
|
4270
|
-
var pullRequestSchema3 =
|
|
4271
|
-
base:
|
|
4272
|
-
number:
|
|
4273
|
-
head:
|
|
4274
|
-
html_url:
|
|
4275
|
-
mergeable:
|
|
4276
|
-
mergeable_state:
|
|
4277
|
-
state:
|
|
4418
|
+
var pullRequestSchema3 = z29.object({
|
|
4419
|
+
base: z29.object({ ref: z29.string().min(1) }),
|
|
4420
|
+
number: z29.number().int().positive().optional(),
|
|
4421
|
+
head: z29.object({ sha: z29.string().min(1) }),
|
|
4422
|
+
html_url: z29.string().min(1).optional(),
|
|
4423
|
+
mergeable: z29.boolean().nullable().optional(),
|
|
4424
|
+
mergeable_state: z29.string().optional(),
|
|
4425
|
+
state: z29.string()
|
|
4278
4426
|
});
|
|
4279
4427
|
function gitHubMergeConflictEvents(input) {
|
|
4280
4428
|
const { conflict } = input;
|
|
@@ -4308,7 +4456,7 @@ function pullRequestRefs(events) {
|
|
|
4308
4456
|
return [...refs.values()];
|
|
4309
4457
|
}
|
|
4310
4458
|
function deliveredPullRequest(payload, ref) {
|
|
4311
|
-
const parsed =
|
|
4459
|
+
const parsed = z29.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
|
|
4312
4460
|
const pullRequest = parsed.success ? parsed.data.pull_request : void 0;
|
|
4313
4461
|
return pullRequest?.number === ref.number && typeof pullRequest.mergeable === "boolean" ? pullRequest : void 0;
|
|
4314
4462
|
}
|
|
@@ -4346,16 +4494,16 @@ async function loadGitHubMergeConflictEvents(args) {
|
|
|
4346
4494
|
}
|
|
4347
4495
|
|
|
4348
4496
|
// src/merge-conflict-checks/webhooks.ts
|
|
4349
|
-
import * as
|
|
4497
|
+
import * as z31 from "zod";
|
|
4350
4498
|
|
|
4351
4499
|
// src/merge-conflict-checks/store.ts
|
|
4352
4500
|
import { and as and4, eq as eq4 } from "drizzle-orm";
|
|
4353
|
-
import * as
|
|
4501
|
+
import * as z30 from "zod";
|
|
4354
4502
|
var CHECK_TTL_MS = 30 * 6e4;
|
|
4355
|
-
var repeatSchema =
|
|
4503
|
+
var repeatSchema = z30.object({
|
|
4356
4504
|
/** Checks since the last push that ended with an unknown answer. */
|
|
4357
|
-
attempts:
|
|
4358
|
-
dueAtMs:
|
|
4505
|
+
attempts: z30.number().int().positive(),
|
|
4506
|
+
dueAtMs: z30.number()
|
|
4359
4507
|
});
|
|
4360
4508
|
function pushKey(repositoryFullName) {
|
|
4361
4509
|
return `merge-conflict-check:push:${repositoryFullName}`;
|
|
@@ -4423,12 +4571,12 @@ async function settleGitHubConflictCheck(state, check, retryAtMs) {
|
|
|
4423
4571
|
|
|
4424
4572
|
// src/merge-conflict-checks/webhooks.ts
|
|
4425
4573
|
var CONFLICT_CHECK_DELAY_MS = 2 * 6e4;
|
|
4426
|
-
var pushSchema =
|
|
4427
|
-
deleted:
|
|
4428
|
-
ref:
|
|
4429
|
-
repository:
|
|
4430
|
-
default_branch:
|
|
4431
|
-
full_name:
|
|
4574
|
+
var pushSchema = z31.object({
|
|
4575
|
+
deleted: z31.boolean().optional(),
|
|
4576
|
+
ref: z31.string(),
|
|
4577
|
+
repository: z31.object({
|
|
4578
|
+
default_branch: z31.string().min(1),
|
|
4579
|
+
full_name: z31.string().min(1)
|
|
4432
4580
|
})
|
|
4433
4581
|
});
|
|
4434
4582
|
async function scheduleGitHubPushConflictCheck(args) {
|
|
@@ -4445,10 +4593,10 @@ async function scheduleGitHubPushConflictCheck(args) {
|
|
|
4445
4593
|
}
|
|
4446
4594
|
|
|
4447
4595
|
// src/webhooks/pull-request-ready.ts
|
|
4448
|
-
import * as
|
|
4596
|
+
import * as z33 from "zod";
|
|
4449
4597
|
|
|
4450
4598
|
// src/webhooks/installation-requests.ts
|
|
4451
|
-
import * as
|
|
4599
|
+
import * as z32 from "zod";
|
|
4452
4600
|
function splitRepository(fullName, label) {
|
|
4453
4601
|
const [owner, name, ...extra] = fullName.split("/");
|
|
4454
4602
|
if (!owner || !name || extra.length > 0) {
|
|
@@ -4509,7 +4657,7 @@ async function loadPullRequestLifecycles(env, input) {
|
|
|
4509
4657
|
name,
|
|
4510
4658
|
owner,
|
|
4511
4659
|
...Object.fromEntries(
|
|
4512
|
-
input.numbers.map((
|
|
4660
|
+
input.numbers.map((number31, index2) => [`n${index2}`, number31])
|
|
4513
4661
|
)
|
|
4514
4662
|
}
|
|
4515
4663
|
},
|
|
@@ -4547,7 +4695,7 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
4547
4695
|
});
|
|
4548
4696
|
const content = pullRequestFeedbackReactionContent("reviewing");
|
|
4549
4697
|
if (target.commentKind === "review_body") {
|
|
4550
|
-
const review =
|
|
4698
|
+
const review = z32.object({ node_id: z32.string().min(1) }).parse(
|
|
4551
4699
|
await githubRequest(
|
|
4552
4700
|
"https://api.github.com",
|
|
4553
4701
|
pullRequestReviewPath({
|
|
@@ -4559,7 +4707,7 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
4559
4707
|
{ token: token.token }
|
|
4560
4708
|
)
|
|
4561
4709
|
);
|
|
4562
|
-
const result =
|
|
4710
|
+
const result = z32.object({ errors: z32.array(z32.unknown()).optional() }).parse(
|
|
4563
4711
|
await githubRequest("https://api.github.com", "/graphql", {
|
|
4564
4712
|
body: {
|
|
4565
4713
|
operationName: "AddReviewReaction",
|
|
@@ -4595,9 +4743,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
4595
4743
|
}
|
|
4596
4744
|
);
|
|
4597
4745
|
}
|
|
4598
|
-
var repositoryPermissionSchema =
|
|
4599
|
-
permission:
|
|
4600
|
-
role_name:
|
|
4746
|
+
var repositoryPermissionSchema = z32.object({
|
|
4747
|
+
permission: z32.string().min(1),
|
|
4748
|
+
role_name: z32.string().optional()
|
|
4601
4749
|
});
|
|
4602
4750
|
var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
|
|
4603
4751
|
async function loadRepositoryRole(env, cache, target) {
|
|
@@ -4627,19 +4775,19 @@ async function loadRepositoryRole(env, cache, target) {
|
|
|
4627
4775
|
}
|
|
4628
4776
|
);
|
|
4629
4777
|
}
|
|
4630
|
-
var pullRequestSchema4 =
|
|
4631
|
-
auto_merge:
|
|
4632
|
-
draft:
|
|
4633
|
-
html_url:
|
|
4634
|
-
mergeable_state:
|
|
4635
|
-
merged:
|
|
4636
|
-
state:
|
|
4637
|
-
title:
|
|
4778
|
+
var pullRequestSchema4 = z32.object({
|
|
4779
|
+
auto_merge: z32.object({}).nullable().optional(),
|
|
4780
|
+
draft: z32.boolean().optional(),
|
|
4781
|
+
html_url: z32.string().url(),
|
|
4782
|
+
mergeable_state: z32.string().nullable().optional(),
|
|
4783
|
+
merged: z32.boolean(),
|
|
4784
|
+
state: z32.enum(["open", "closed"]),
|
|
4785
|
+
title: z32.string()
|
|
4638
4786
|
});
|
|
4639
|
-
var reviewsSchema =
|
|
4640
|
-
|
|
4641
|
-
state:
|
|
4642
|
-
user:
|
|
4787
|
+
var reviewsSchema = z32.array(
|
|
4788
|
+
z32.object({
|
|
4789
|
+
state: z32.string(),
|
|
4790
|
+
user: z32.object({ login: z32.string() }).nullable()
|
|
4643
4791
|
})
|
|
4644
4792
|
);
|
|
4645
4793
|
async function loadPullRequestMergeState(env, pullRequest) {
|
|
@@ -4707,10 +4855,10 @@ var READY_ACTIONS = {
|
|
|
4707
4855
|
]),
|
|
4708
4856
|
pull_request_review: /* @__PURE__ */ new Set(["dismissed", "submitted"])
|
|
4709
4857
|
};
|
|
4710
|
-
var pullRequestWebhookSchema =
|
|
4711
|
-
action:
|
|
4712
|
-
pull_request:
|
|
4713
|
-
repository:
|
|
4858
|
+
var pullRequestWebhookSchema = z33.object({
|
|
4859
|
+
action: z33.string(),
|
|
4860
|
+
pull_request: z33.object({ number: z33.number().int().positive() }),
|
|
4861
|
+
repository: z33.object({ full_name: z33.string().min(1) })
|
|
4714
4862
|
});
|
|
4715
4863
|
function pullRequestReadyTargets(eventName, body) {
|
|
4716
4864
|
if (eventName === "check_suite") return checkSuitePullRequests(body);
|
|
@@ -4809,32 +4957,32 @@ async function syncGitHubPullRequestReadyNotices(args) {
|
|
|
4809
4957
|
}
|
|
4810
4958
|
|
|
4811
4959
|
// src/webhooks/pull-request-review-request.ts
|
|
4812
|
-
import * as
|
|
4813
|
-
var login =
|
|
4814
|
-
var pullRequestEventSchema =
|
|
4815
|
-
action:
|
|
4960
|
+
import * as z34 from "zod";
|
|
4961
|
+
var login = z34.object({ login: z34.string().min(1) });
|
|
4962
|
+
var pullRequestEventSchema = z34.object({
|
|
4963
|
+
action: z34.enum([
|
|
4816
4964
|
"closed",
|
|
4817
4965
|
"reopened",
|
|
4818
4966
|
"review_request_removed",
|
|
4819
4967
|
"review_requested"
|
|
4820
4968
|
]),
|
|
4821
|
-
pull_request:
|
|
4822
|
-
html_url:
|
|
4823
|
-
merged:
|
|
4824
|
-
number:
|
|
4969
|
+
pull_request: z34.object({
|
|
4970
|
+
html_url: z34.string().url(),
|
|
4971
|
+
merged: z34.boolean().optional(),
|
|
4972
|
+
number: z34.number().int().positive(),
|
|
4825
4973
|
// The people whose review is still requested. Teams are listed apart.
|
|
4826
|
-
requested_reviewers:
|
|
4827
|
-
title:
|
|
4974
|
+
requested_reviewers: z34.array(login).optional(),
|
|
4975
|
+
title: z34.string()
|
|
4828
4976
|
}),
|
|
4829
|
-
repository:
|
|
4977
|
+
repository: z34.object({ full_name: z34.string().min(1) }),
|
|
4830
4978
|
// A team request has `requested_team` instead.
|
|
4831
4979
|
requested_reviewer: login.optional()
|
|
4832
4980
|
});
|
|
4833
|
-
var reviewEventSchema =
|
|
4834
|
-
action:
|
|
4835
|
-
pull_request:
|
|
4836
|
-
repository:
|
|
4837
|
-
review:
|
|
4981
|
+
var reviewEventSchema = z34.object({
|
|
4982
|
+
action: z34.literal("submitted"),
|
|
4983
|
+
pull_request: z34.object({ number: z34.number().int().positive() }),
|
|
4984
|
+
repository: z34.object({ full_name: z34.string().min(1) }),
|
|
4985
|
+
review: z34.object({ user: login })
|
|
4838
4986
|
});
|
|
4839
4987
|
function reviewRequestChange(eventName, body) {
|
|
4840
4988
|
if (eventName === "pull_request_review") {
|
|
@@ -4915,14 +5063,14 @@ function sameLogin(left, right) {
|
|
|
4915
5063
|
async function syncGitHubPullRequestReviewRequest(args) {
|
|
4916
5064
|
const parsed = reviewRequestChange(args.eventName, args.body);
|
|
4917
5065
|
if (!parsed) return;
|
|
4918
|
-
const { change, number:
|
|
5066
|
+
const { change, number: number31, repository: repository2 } = parsed;
|
|
4919
5067
|
try {
|
|
4920
5068
|
const opener = (await listGitHubPullRequestOpeners(args.db, {
|
|
4921
|
-
numbers: [
|
|
5069
|
+
numbers: [number31],
|
|
4922
5070
|
repositoryFullName: repository2
|
|
4923
|
-
})).get(
|
|
5071
|
+
})).get(number31);
|
|
4924
5072
|
if (!opener?.conversationId) return;
|
|
4925
|
-
const name = `${repository2}#${
|
|
5073
|
+
const name = `${repository2}#${number31}`;
|
|
4926
5074
|
const dedupeKey = `pull-request-review-requested:${name.toLowerCase()}`;
|
|
4927
5075
|
const items = args.reviewItems.forConversation(opener.conversationId);
|
|
4928
5076
|
const reviewers = change.kind === "requested" ? change.reviewers : change.reviewer === void 0 ? void 0 : [change.reviewer];
|
|
@@ -4945,21 +5093,21 @@ async function syncGitHubPullRequestReviewRequest(args) {
|
|
|
4945
5093
|
body: `GitHub asks you to review **${change.title}**: ${change.url}`,
|
|
4946
5094
|
dedupeKey,
|
|
4947
5095
|
subject: { id: change.url, title: name, url: change.url },
|
|
4948
|
-
title: `Review requested \xB7 #${
|
|
5096
|
+
title: `Review requested \xB7 #${number31}`,
|
|
4949
5097
|
waitsOnAssignees: true
|
|
4950
5098
|
});
|
|
4951
5099
|
} catch (error) {
|
|
4952
5100
|
args.log?.error("GitHub pull request review request failed", {
|
|
4953
5101
|
deliveryId: args.deliveryId,
|
|
4954
5102
|
errorType: error instanceof Error ? error.name : "UnknownError",
|
|
4955
|
-
number:
|
|
5103
|
+
number: number31,
|
|
4956
5104
|
repository: repository2
|
|
4957
5105
|
});
|
|
4958
5106
|
}
|
|
4959
5107
|
}
|
|
4960
5108
|
|
|
4961
5109
|
// src/webhooks/pull-request-match-data.ts
|
|
4962
|
-
import * as
|
|
5110
|
+
import * as z35 from "zod";
|
|
4963
5111
|
var LOOKUPS_BY_MATCH_KEY = {
|
|
4964
5112
|
authors: ["authors"],
|
|
4965
5113
|
openerEmail: ["opener"],
|
|
@@ -4967,22 +5115,22 @@ var LOOKUPS_BY_MATCH_KEY = {
|
|
|
4967
5115
|
openerUsername: ["opener"]
|
|
4968
5116
|
};
|
|
4969
5117
|
var ALL_LOOKUPS = ["authors", "opener", "openerRole"];
|
|
4970
|
-
var lookupDataSchema =
|
|
4971
|
-
authors:
|
|
4972
|
-
openerRole:
|
|
4973
|
-
openerUsername:
|
|
5118
|
+
var lookupDataSchema = z35.object({
|
|
5119
|
+
authors: z35.array(z35.string().min(1)).min(1).optional(),
|
|
5120
|
+
openerRole: z35.string().min(1).optional(),
|
|
5121
|
+
openerUsername: z35.string().min(1).optional()
|
|
4974
5122
|
}).strict();
|
|
4975
5123
|
function lookupData(input) {
|
|
4976
5124
|
return lookupDataSchema.parse(definedValues(input));
|
|
4977
5125
|
}
|
|
4978
|
-
var webhookSchema =
|
|
4979
|
-
repository:
|
|
5126
|
+
var webhookSchema = z35.object({
|
|
5127
|
+
repository: z35.object({ full_name: z35.string().min(1) })
|
|
4980
5128
|
});
|
|
4981
5129
|
function pullRequestNumbers(events) {
|
|
4982
5130
|
const numbers = /* @__PURE__ */ new Map();
|
|
4983
5131
|
for (const event of events) {
|
|
4984
|
-
const
|
|
4985
|
-
if (typeof
|
|
5132
|
+
const number31 = event.data?.pullRequest;
|
|
5133
|
+
if (typeof number31 === "number") numbers.set(event.eventKey, number31);
|
|
4986
5134
|
}
|
|
4987
5135
|
return numbers;
|
|
4988
5136
|
}
|
|
@@ -4996,8 +5144,8 @@ function logFailure(context, lookup, error) {
|
|
|
4996
5144
|
}
|
|
4997
5145
|
async function withJuniorOpeners(context, events) {
|
|
4998
5146
|
const botNumber = (event) => {
|
|
4999
|
-
const
|
|
5000
|
-
return
|
|
5147
|
+
const number31 = context.numbers.get(event.eventKey);
|
|
5148
|
+
return number31 !== void 0 && isBotLogin(event.data?.openerUsername, context.botEmail) ? number31 : void 0;
|
|
5001
5149
|
};
|
|
5002
5150
|
const numbers = events.flatMap((event) => botNumber(event) ?? []);
|
|
5003
5151
|
if (numbers.length === 0) return events;
|
|
@@ -5016,9 +5164,9 @@ async function withJuniorOpeners(context, events) {
|
|
|
5016
5164
|
}
|
|
5017
5165
|
}
|
|
5018
5166
|
return events.map((event) => {
|
|
5019
|
-
const
|
|
5020
|
-
if (
|
|
5021
|
-
const identityId = openers.get(
|
|
5167
|
+
const number31 = botNumber(event);
|
|
5168
|
+
if (number31 === void 0) return event;
|
|
5169
|
+
const identityId = openers.get(number31)?.identityId;
|
|
5022
5170
|
const login2 = identityId ? logins.get(identityId) : void 0;
|
|
5023
5171
|
const {
|
|
5024
5172
|
openerEmail: _email,
|
|
@@ -5040,8 +5188,8 @@ async function withRolesAndAuthors(context, events, lookups) {
|
|
|
5040
5188
|
if (!loadRole && !loadAuthors) return events;
|
|
5041
5189
|
return await Promise.all(
|
|
5042
5190
|
events.map(async (event) => {
|
|
5043
|
-
const
|
|
5044
|
-
if (
|
|
5191
|
+
const number31 = context.numbers.get(event.eventKey);
|
|
5192
|
+
if (number31 === void 0) return event;
|
|
5045
5193
|
const login2 = event.data?.openerUsername;
|
|
5046
5194
|
if (loadRole && typeof login2 === "string" && !roles.has(login2)) {
|
|
5047
5195
|
roles.set(
|
|
@@ -5051,16 +5199,16 @@ async function withRolesAndAuthors(context, events, lookups) {
|
|
|
5051
5199
|
)
|
|
5052
5200
|
);
|
|
5053
5201
|
}
|
|
5054
|
-
if (loadAuthors && !authors.has(
|
|
5202
|
+
if (loadAuthors && !authors.has(number31)) {
|
|
5055
5203
|
authors.set(
|
|
5056
|
-
|
|
5057
|
-
loadAuthors({ number:
|
|
5204
|
+
number31,
|
|
5205
|
+
loadAuthors({ number: number31, repositoryFullName }).catch(
|
|
5058
5206
|
(error) => logFailure(context, "authors", error)
|
|
5059
5207
|
)
|
|
5060
5208
|
);
|
|
5061
5209
|
}
|
|
5062
5210
|
const role = loadRole && typeof login2 === "string" ? await roles.get(login2) : void 0;
|
|
5063
|
-
const logins = loadAuthors ? await authors.get(
|
|
5211
|
+
const logins = loadAuthors ? await authors.get(number31) : void 0;
|
|
5064
5212
|
if (!role && !logins?.length) return event;
|
|
5065
5213
|
return {
|
|
5066
5214
|
...event,
|
|
@@ -5117,7 +5265,7 @@ async function withGitHubPullRequestMatchData(args) {
|
|
|
5117
5265
|
}
|
|
5118
5266
|
|
|
5119
5267
|
// src/webhooks/pull-request-people.ts
|
|
5120
|
-
import * as
|
|
5268
|
+
import * as z36 from "zod";
|
|
5121
5269
|
var PEOPLE_EVENTS = /* @__PURE__ */ new Set([
|
|
5122
5270
|
"pull_request.review.approved",
|
|
5123
5271
|
"pull_request.merged"
|
|
@@ -5127,18 +5275,18 @@ var PAGE_SIZE = 100;
|
|
|
5127
5275
|
var MAX_PAGES = 3;
|
|
5128
5276
|
var CO_AUTHOR_TRAILER = /^co-authored-by:[^<\n]*<([^>\s]+@[^>\s]+)>\s*$/gim;
|
|
5129
5277
|
var GITHUB_NOREPLY_EMAIL = /^(?:\d+\+)?(?<login>[^@+]+)@users\.noreply\.github\.com$/i;
|
|
5130
|
-
var webhookSchema2 =
|
|
5131
|
-
pull_request:
|
|
5132
|
-
assignees:
|
|
5133
|
-
number:
|
|
5134
|
-
user:
|
|
5278
|
+
var webhookSchema2 = z36.object({
|
|
5279
|
+
pull_request: z36.object({
|
|
5280
|
+
assignees: z36.array(z36.object({ login: z36.string().min(1) })).nullish(),
|
|
5281
|
+
number: z36.number(),
|
|
5282
|
+
user: z36.object({ login: z36.string().min(1) }).nullish()
|
|
5135
5283
|
}),
|
|
5136
|
-
repository:
|
|
5284
|
+
repository: z36.object({ full_name: z36.string().min(1) })
|
|
5137
5285
|
});
|
|
5138
|
-
var commitPageSchema =
|
|
5139
|
-
|
|
5140
|
-
author:
|
|
5141
|
-
commit:
|
|
5286
|
+
var commitPageSchema = z36.array(
|
|
5287
|
+
z36.object({
|
|
5288
|
+
author: z36.object({ login: z36.string().min(1) }).nullish(),
|
|
5289
|
+
commit: z36.object({ message: z36.string() })
|
|
5142
5290
|
})
|
|
5143
5291
|
);
|
|
5144
5292
|
function shareCommitPages(load) {
|
|
@@ -5280,11 +5428,11 @@ function webhookInstallationId(body) {
|
|
|
5280
5428
|
}
|
|
5281
5429
|
return parseInstallationId(installation.id);
|
|
5282
5430
|
}
|
|
5283
|
-
var feedbackTargetSchema =
|
|
5284
|
-
commentId:
|
|
5285
|
-
commentKind:
|
|
5286
|
-
pullRequest:
|
|
5287
|
-
repo:
|
|
5431
|
+
var feedbackTargetSchema = z37.object({
|
|
5432
|
+
commentId: z37.number(),
|
|
5433
|
+
commentKind: z37.enum(["conversation", "review", "review_body"]),
|
|
5434
|
+
pullRequest: z37.number(),
|
|
5435
|
+
repo: z37.string().min(1)
|
|
5288
5436
|
});
|
|
5289
5437
|
function pullRequestFeedbackTarget(events) {
|
|
5290
5438
|
for (const event of events) {
|
|
@@ -5516,30 +5664,30 @@ function createGitHubWebhookRoute(args) {
|
|
|
5516
5664
|
}
|
|
5517
5665
|
|
|
5518
5666
|
// src/merge-conflict-checks/heartbeat.ts
|
|
5519
|
-
import * as
|
|
5667
|
+
import * as z38 from "zod";
|
|
5520
5668
|
var CHECK_LIMIT = 10;
|
|
5521
5669
|
var MAX_PAGES2 = 5;
|
|
5522
5670
|
var CLAIM_MS = 5 * 6e4;
|
|
5523
5671
|
var UNKNOWN_RETRY_MS = 6e4;
|
|
5524
5672
|
var MAX_ATTEMPTS = 5;
|
|
5525
|
-
var searchNodeSchema =
|
|
5526
|
-
|
|
5527
|
-
baseRefName:
|
|
5528
|
-
headRefOid:
|
|
5529
|
-
mergeable:
|
|
5530
|
-
number:
|
|
5531
|
-
state:
|
|
5532
|
-
url:
|
|
5673
|
+
var searchNodeSchema = z38.union([
|
|
5674
|
+
z38.object({
|
|
5675
|
+
baseRefName: z38.string().min(1),
|
|
5676
|
+
headRefOid: z38.string().min(1),
|
|
5677
|
+
mergeable: z38.enum(["CONFLICTING", "MERGEABLE", "UNKNOWN"]),
|
|
5678
|
+
number: z38.number().int().positive(),
|
|
5679
|
+
state: z38.string(),
|
|
5680
|
+
url: z38.string().min(1)
|
|
5533
5681
|
}),
|
|
5534
|
-
|
|
5682
|
+
z38.object({}).strict()
|
|
5535
5683
|
]);
|
|
5536
|
-
var searchResponseSchema =
|
|
5537
|
-
data:
|
|
5538
|
-
search:
|
|
5539
|
-
nodes:
|
|
5540
|
-
pageInfo:
|
|
5541
|
-
endCursor:
|
|
5542
|
-
hasNextPage:
|
|
5684
|
+
var searchResponseSchema = z38.object({
|
|
5685
|
+
data: z38.object({
|
|
5686
|
+
search: z38.object({
|
|
5687
|
+
nodes: z38.array(searchNodeSchema.nullable()),
|
|
5688
|
+
pageInfo: z38.object({
|
|
5689
|
+
endCursor: z38.string().nullable(),
|
|
5690
|
+
hasNextPage: z38.boolean()
|
|
5543
5691
|
})
|
|
5544
5692
|
})
|
|
5545
5693
|
})
|
|
@@ -5613,33 +5761,33 @@ async function runGitHubConflictChecks(args) {
|
|
|
5613
5761
|
}
|
|
5614
5762
|
|
|
5615
5763
|
// src/pull-request-outcomes/reconcile.ts
|
|
5616
|
-
import * as
|
|
5764
|
+
import * as z39 from "zod";
|
|
5617
5765
|
var RECONCILE_MS = 24 * 60 * 6e4;
|
|
5618
5766
|
var REPOSITORY_LIMIT = 1;
|
|
5619
5767
|
var PULL_REQUESTS_PER_QUERY = 100;
|
|
5620
|
-
var lifecycleSchema =
|
|
5621
|
-
assignees:
|
|
5622
|
-
nodes:
|
|
5768
|
+
var lifecycleSchema = z39.object({
|
|
5769
|
+
assignees: z39.object({
|
|
5770
|
+
nodes: z39.array(z39.object({ login: z39.string().min(1) }).nullable())
|
|
5623
5771
|
}),
|
|
5624
5772
|
// GraphQL omits the `[bot]` suffix that REST and webhooks give an app.
|
|
5625
|
-
author:
|
|
5626
|
-
closedAt:
|
|
5627
|
-
createdAt:
|
|
5628
|
-
databaseId:
|
|
5629
|
-
headRefName:
|
|
5630
|
-
isDraft:
|
|
5631
|
-
merged:
|
|
5632
|
-
mergedAt:
|
|
5633
|
-
number:
|
|
5634
|
-
state:
|
|
5635
|
-
title:
|
|
5636
|
-
updatedAt:
|
|
5773
|
+
author: z39.object({ __typename: z39.string(), login: z39.string().min(1) }).nullable(),
|
|
5774
|
+
closedAt: z39.string().nullable(),
|
|
5775
|
+
createdAt: z39.string(),
|
|
5776
|
+
databaseId: z39.number().int().positive(),
|
|
5777
|
+
headRefName: z39.string(),
|
|
5778
|
+
isDraft: z39.boolean(),
|
|
5779
|
+
merged: z39.boolean(),
|
|
5780
|
+
mergedAt: z39.string().nullable(),
|
|
5781
|
+
number: z39.number().int().positive(),
|
|
5782
|
+
state: z39.enum(["OPEN", "CLOSED", "MERGED"]),
|
|
5783
|
+
title: z39.string(),
|
|
5784
|
+
updatedAt: z39.string()
|
|
5637
5785
|
});
|
|
5638
|
-
var lifecyclesResponseSchema =
|
|
5639
|
-
data:
|
|
5640
|
-
repository:
|
|
5641
|
-
databaseId:
|
|
5642
|
-
nameWithOwner:
|
|
5786
|
+
var lifecyclesResponseSchema = z39.object({
|
|
5787
|
+
data: z39.object({
|
|
5788
|
+
repository: z39.object({
|
|
5789
|
+
databaseId: z39.number().int().positive(),
|
|
5790
|
+
nameWithOwner: z39.string().min(1)
|
|
5643
5791
|
}).catchall(lifecycleSchema.nullable())
|
|
5644
5792
|
})
|
|
5645
5793
|
});
|
|
@@ -5769,30 +5917,30 @@ function gitHubResourceUrl(input) {
|
|
|
5769
5917
|
if (input.resourceType === "repository") {
|
|
5770
5918
|
return `https://github.com/${input.identifier}`;
|
|
5771
5919
|
}
|
|
5772
|
-
const [repo,
|
|
5773
|
-
if (!repo || !
|
|
5920
|
+
const [repo, number31] = input.identifier.split("#");
|
|
5921
|
+
if (!repo || !number31) return void 0;
|
|
5774
5922
|
if (input.resourceType === "pull_request") {
|
|
5775
|
-
return `https://github.com/${repo}/pull/${
|
|
5923
|
+
return `https://github.com/${repo}/pull/${number31}`;
|
|
5776
5924
|
}
|
|
5777
5925
|
if (input.resourceType === "issue") {
|
|
5778
|
-
return `https://github.com/${repo}/issues/${
|
|
5926
|
+
return `https://github.com/${repo}/issues/${number31}`;
|
|
5779
5927
|
}
|
|
5780
5928
|
return void 0;
|
|
5781
5929
|
}
|
|
5782
5930
|
|
|
5783
5931
|
// src/pull-request-outcomes/commit-composition.ts
|
|
5784
|
-
import * as
|
|
5785
|
-
var canonicalCommitSchema =
|
|
5786
|
-
authorEmail:
|
|
5787
|
-
authorLogin:
|
|
5932
|
+
import * as z40 from "zod";
|
|
5933
|
+
var canonicalCommitSchema = z40.object({
|
|
5934
|
+
authorEmail: z40.string().nullable(),
|
|
5935
|
+
authorLogin: z40.string().nullable()
|
|
5788
5936
|
}).strict();
|
|
5789
|
-
var providerCommitSchema =
|
|
5790
|
-
author:
|
|
5791
|
-
commit:
|
|
5792
|
-
author:
|
|
5937
|
+
var providerCommitSchema = z40.object({
|
|
5938
|
+
author: z40.object({ login: z40.string() }).passthrough().nullable(),
|
|
5939
|
+
commit: z40.object({
|
|
5940
|
+
author: z40.object({ email: z40.string() }).passthrough().nullable()
|
|
5793
5941
|
}).passthrough()
|
|
5794
5942
|
}).passthrough();
|
|
5795
|
-
var commitPageSchema2 =
|
|
5943
|
+
var commitPageSchema2 = z40.array(providerCommitSchema).transform(
|
|
5796
5944
|
(commits) => commits.map(
|
|
5797
5945
|
(commit) => canonicalCommitSchema.parse({
|
|
5798
5946
|
authorEmail: commit.commit.author?.email ?? null,
|
|
@@ -6299,8 +6447,8 @@ function linkifyLine(line) {
|
|
|
6299
6447
|
if (isReferenceBoundary(index2 === 0 ? void 0 : line[index2 - 1])) {
|
|
6300
6448
|
const match = GITHUB_ISSUE_REFERENCE_PATTERN.exec(line.slice(index2));
|
|
6301
6449
|
if (match) {
|
|
6302
|
-
const [reference, owner, repository2,
|
|
6303
|
-
output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${
|
|
6450
|
+
const [reference, owner, repository2, number31] = match;
|
|
6451
|
+
output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${number31})`;
|
|
6304
6452
|
index2 += reference.length;
|
|
6305
6453
|
continue;
|
|
6306
6454
|
}
|
|
@@ -6442,9 +6590,9 @@ function parseGitHubReferences(text2, config) {
|
|
|
6442
6590
|
}
|
|
6443
6591
|
return [...references.values()];
|
|
6444
6592
|
}
|
|
6445
|
-
function objectTitle(kind,
|
|
6446
|
-
if (!isRecord(
|
|
6447
|
-
const raw = kind === "commit" ? isRecord(
|
|
6593
|
+
function objectTitle(kind, object41) {
|
|
6594
|
+
if (!isRecord(object41)) return void 0;
|
|
6595
|
+
const raw = kind === "commit" ? isRecord(object41.commit) && typeof object41.commit.message === "string" ? object41.commit.message.split("\n")[0] : void 0 : typeof object41.title === "string" ? object41.title : void 0;
|
|
6448
6596
|
return raw?.replace(/\s+/g, " ").trim() || void 0;
|
|
6449
6597
|
}
|
|
6450
6598
|
async function loadGitHubConversationTitleContext(args) {
|
|
@@ -6723,9 +6871,9 @@ import {
|
|
|
6723
6871
|
} from "@sentry/junior-plugin-api";
|
|
6724
6872
|
|
|
6725
6873
|
// src/default-branch.ts
|
|
6726
|
-
import * as
|
|
6874
|
+
import * as z41 from "zod";
|
|
6727
6875
|
var DEFAULT_BRANCH_TTL_MS = 10 * 60 * 1e3;
|
|
6728
|
-
var repositorySchema3 =
|
|
6876
|
+
var repositorySchema3 = z41.object({ default_branch: z41.string().min(1) });
|
|
6729
6877
|
async function loadDefaultBranch(env, cache, repository2) {
|
|
6730
6878
|
const { owner, name } = repository2;
|
|
6731
6879
|
return await cache.getOrLoad(
|
|
@@ -6948,6 +7096,27 @@ function isGitHubIssueRead(input) {
|
|
|
6948
7096
|
return isGitHubApiUrl(input.upstreamUrl) && HTTP_READ_METHODS.has(input.method) && ISSUE_PATH.test(input.upstreamUrl.pathname.toLowerCase());
|
|
6949
7097
|
}
|
|
6950
7098
|
var PULL_REQUEST_COMMENT_REACTIONS_PATH = /^\/repos\/[^/]+\/[^/]+\/(issues|pulls)\/comments\/[^/]+\/reactions(?:\/[^/]+)?$/;
|
|
7099
|
+
var TOOL_ONLY_REST_WRITES = [
|
|
7100
|
+
{
|
|
7101
|
+
denialMessage: "GitHub issue comment edits must use the github_updateIssueComment tool, which only edits comments the bot posted.",
|
|
7102
|
+
method: "PATCH",
|
|
7103
|
+
operation: "github.issue.comment.update",
|
|
7104
|
+
restPath: /^\/repos\/[^/]+\/[^/]+\/issues\/comments\/\d+$/
|
|
7105
|
+
},
|
|
7106
|
+
{
|
|
7107
|
+
denialMessage: "Reactions on a GitHub issue or pull request must use the github_reactToIssue tool.",
|
|
7108
|
+
method: "POST",
|
|
7109
|
+
operation: "github.issue.reaction.create",
|
|
7110
|
+
restPath: /^\/repos\/[^/]+\/[^/]+\/issues\/\d+\/reactions$/
|
|
7111
|
+
}
|
|
7112
|
+
];
|
|
7113
|
+
function toolOnlyRestWrite(method, upstreamUrl) {
|
|
7114
|
+
if (!isGitHubApiUrl(upstreamUrl)) return void 0;
|
|
7115
|
+
const pathname = upstreamUrl.pathname.toLowerCase();
|
|
7116
|
+
return TOOL_ONLY_REST_WRITES.find(
|
|
7117
|
+
(write) => write.method === method && write.restPath.test(pathname)
|
|
7118
|
+
);
|
|
7119
|
+
}
|
|
6951
7120
|
var GITHUB_BODY_WRITES = [
|
|
6952
7121
|
{
|
|
6953
7122
|
denialMessage: `GitHub issue creation must use the github_createIssue tool, which owns idempotency and the conversation footer. ${CREATE_TOOL_ROUTING_GUIDANCE}`,
|
|
@@ -7042,6 +7211,9 @@ function githubApiWriteGrantName(method, upstreamUrl) {
|
|
|
7042
7211
|
if ((method === "POST" || method === "DELETE") && PULL_REQUEST_COMMENT_REACTIONS_PATH.test(pathname)) {
|
|
7043
7212
|
return "installation-write";
|
|
7044
7213
|
}
|
|
7214
|
+
if (toolOnlyRestWrite(method, upstreamUrl)) {
|
|
7215
|
+
return "installation-write";
|
|
7216
|
+
}
|
|
7045
7217
|
return void 0;
|
|
7046
7218
|
}
|
|
7047
7219
|
var HOST_GRAPHQL_MUTATIONS = [
|
|
@@ -7105,6 +7277,13 @@ function applyGitHubEgressPolicy(input) {
|
|
|
7105
7277
|
denialMessage: "GitHub pull request feedback reactions must use the github_updatePullRequestFeedback tool."
|
|
7106
7278
|
});
|
|
7107
7279
|
}
|
|
7280
|
+
const toolOnlyWrite = toolOnlyRestWrite(input.method, input.upstreamUrl);
|
|
7281
|
+
if (toolOnlyWrite) {
|
|
7282
|
+
enforceEgressPolicy({
|
|
7283
|
+
allowed: input.operation === toolOnlyWrite.operation,
|
|
7284
|
+
denialMessage: toolOnlyWrite.denialMessage
|
|
7285
|
+
});
|
|
7286
|
+
}
|
|
7108
7287
|
if (isGitHubIssueRead(input)) {
|
|
7109
7288
|
enforceEgressPolicy({
|
|
7110
7289
|
allowed: input.operation === "github.issue.get",
|