@sentry/junior-github 0.280.0 → 0.282.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-NSAVG2P3.js → chunk-XOE6HDSA.js} +2 -1
- package/dist/index.js +943 -741
- package/dist/testing.js +1 -1
- package/dist/tool-support/attribution.d.ts +11 -2
- package/dist/tools/get-issue.d.ts +172 -0
- package/dist/tools/update-issue.d.ts +3 -0
- package/dist/webhooks/installation-requests.d.ts +3 -1
- package/dist/webhooks/pull-request-ready.d.ts +2 -1
- package/package.json +2 -2
- package/skills/github-code/references/api-surface.md +2 -1
- package/skills/github-issues/SKILL.md +2 -2
- package/skills/github-issues/references/api-surface.md +17 -17
- package/skills/github-issues/references/troubleshooting-workarounds.md +1 -1
package/dist/index.js
CHANGED
|
@@ -59,7 +59,77 @@ import {
|
|
|
59
59
|
readGrantPermissions,
|
|
60
60
|
requireEnv,
|
|
61
61
|
resolveUserAccount
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-XOE6HDSA.js";
|
|
63
|
+
|
|
64
|
+
// src/tool-support/attribution.ts
|
|
65
|
+
import * as z from "zod";
|
|
66
|
+
|
|
67
|
+
// src/tool-support/github-api.ts
|
|
68
|
+
import {
|
|
69
|
+
PluginToolInputError
|
|
70
|
+
} from "@sentry/junior-plugin-api";
|
|
71
|
+
var GITHUB_API_BASE = "https://api.github.com";
|
|
72
|
+
async function githubApi(egress, input) {
|
|
73
|
+
const headers = {
|
|
74
|
+
Accept: "application/vnd.github+json",
|
|
75
|
+
"X-GitHub-Api-Version": input.apiVersion ?? "2022-11-28"
|
|
76
|
+
};
|
|
77
|
+
if (input.body !== void 0) headers["Content-Type"] = "application/json";
|
|
78
|
+
const response = await egress.fetch({
|
|
79
|
+
provider: "github",
|
|
80
|
+
operation: input.operation,
|
|
81
|
+
request: new Request(`${GITHUB_API_BASE}${input.path}`, {
|
|
82
|
+
method: input.method ?? "GET",
|
|
83
|
+
headers,
|
|
84
|
+
signal: input.signal,
|
|
85
|
+
...input.body !== void 0 ? { body: JSON.stringify(input.body) } : void 0
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
89
|
+
body: await readBody(response),
|
|
90
|
+
ok: response.ok,
|
|
91
|
+
status: response.status
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
async function readBody(response) {
|
|
95
|
+
const text2 = await response.text();
|
|
96
|
+
if (!text2) return void 0;
|
|
97
|
+
try {
|
|
98
|
+
return JSON.parse(text2);
|
|
99
|
+
} catch {
|
|
100
|
+
return text2;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function repoPath(repo) {
|
|
104
|
+
return `/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}`;
|
|
105
|
+
}
|
|
106
|
+
function parseRepo(value) {
|
|
107
|
+
const parts = value.split("/").map((part) => part.trim());
|
|
108
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
109
|
+
throw new PluginToolInputError('repo must use "owner/name" format');
|
|
110
|
+
}
|
|
111
|
+
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
112
|
+
}
|
|
113
|
+
function githubErrorMessage(body) {
|
|
114
|
+
if (typeof body === "string" && body.trim()) return body.trim();
|
|
115
|
+
if (!isRecord2(body)) return "GitHub request failed";
|
|
116
|
+
const errors = Array.isArray(body.errors) ? body.errors.filter(isRecord2) : [];
|
|
117
|
+
if (typeof body.message === "string" && body.message.trim()) {
|
|
118
|
+
const details = errors.map(
|
|
119
|
+
(error) => ["resource", "field", "code", "message"].map((name) => {
|
|
120
|
+
const value = error[name];
|
|
121
|
+
return typeof value === "string" && value.trim() ? `${name}=${value.trim()}` : void 0;
|
|
122
|
+
}).filter(Boolean).join(" ")
|
|
123
|
+
).filter(Boolean).join("; ");
|
|
124
|
+
const message = body.message.trim();
|
|
125
|
+
return details ? `${message}: ${details}` : message;
|
|
126
|
+
}
|
|
127
|
+
const graphqlMessages = errors.map((error) => error.message).filter((message) => typeof message === "string" && message.trim());
|
|
128
|
+
return graphqlMessages.length ? graphqlMessages.join("; ") : "GitHub request failed";
|
|
129
|
+
}
|
|
130
|
+
function isRecord2(value) {
|
|
131
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
132
|
+
}
|
|
63
133
|
|
|
64
134
|
// src/tool-support/attribution.ts
|
|
65
135
|
var GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
|
|
@@ -124,17 +194,25 @@ function formatAttributionBlock(labels) {
|
|
|
124
194
|
via ${labels.join(", ")}.
|
|
125
195
|
${GITHUB_REQUEST_ATTRIBUTION_END}`;
|
|
126
196
|
}
|
|
127
|
-
|
|
197
|
+
var ATTRIBUTION_BLOCK = new RegExp(
|
|
198
|
+
`${GITHUB_REQUEST_ATTRIBUTION_START}([\\s\\S]*?)${GITHUB_REQUEST_ATTRIBUTION_END}`
|
|
199
|
+
);
|
|
200
|
+
function blockLabels(body) {
|
|
201
|
+
const contents = body?.match(ATTRIBUTION_BLOCK)?.[1];
|
|
202
|
+
return contents === void 0 ? [] : parseExistingLabels(contents);
|
|
203
|
+
}
|
|
204
|
+
function applyAttribution(body, label, currentBody) {
|
|
128
205
|
const normalizedBody = body.trimEnd();
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
206
|
+
const labels = [
|
|
207
|
+
.../* @__PURE__ */ new Set([
|
|
208
|
+
...blockLabels(currentBody),
|
|
209
|
+
...blockLabels(normalizedBody),
|
|
210
|
+
...label ? [label] : []
|
|
211
|
+
])
|
|
212
|
+
];
|
|
135
213
|
const attribution = labels.length ? formatAttributionBlock(labels) : void 0;
|
|
136
|
-
if (
|
|
137
|
-
return attribution ? normalizedBody.replace(
|
|
214
|
+
if (ATTRIBUTION_BLOCK.test(normalizedBody)) {
|
|
215
|
+
return attribution ? normalizedBody.replace(ATTRIBUTION_BLOCK, attribution) : normalizedBody.replace(ATTRIBUTION_BLOCK, "").trimEnd();
|
|
138
216
|
}
|
|
139
217
|
if (!attribution) {
|
|
140
218
|
return normalizedBody;
|
|
@@ -143,6 +221,15 @@ function applyAttribution(body, label) {
|
|
|
143
221
|
|
|
144
222
|
${attribution}` : attribution;
|
|
145
223
|
}
|
|
224
|
+
async function readGitHubBody(egress, input) {
|
|
225
|
+
const response = await githubApi(egress, input);
|
|
226
|
+
if (!response.ok) {
|
|
227
|
+
throw new Error(
|
|
228
|
+
`GitHub read before update failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
return z.object({ body: z.string().nullable().optional() }).parse(response.body).body ?? void 0;
|
|
232
|
+
}
|
|
146
233
|
async function resolveGitHubRequester(ctx) {
|
|
147
234
|
if (!ctx.actor || ctx.actor.platform === "system") return void 0;
|
|
148
235
|
try {
|
|
@@ -154,7 +241,7 @@ async function resolveGitHubRequester(ctx) {
|
|
|
154
241
|
return void 0;
|
|
155
242
|
}
|
|
156
243
|
}
|
|
157
|
-
function appendGitHubRequesterAttribution(body, ctx, requester) {
|
|
244
|
+
function appendGitHubRequesterAttribution(body, ctx, requester, currentBody) {
|
|
158
245
|
return applyAttribution(
|
|
159
246
|
body,
|
|
160
247
|
requesterLabel({
|
|
@@ -163,77 +250,11 @@ function appendGitHubRequesterAttribution(body, ctx, requester) {
|
|
|
163
250
|
identity: requester?.identity,
|
|
164
251
|
source: ctx.source,
|
|
165
252
|
user: requester?.user
|
|
166
|
-
})
|
|
253
|
+
}),
|
|
254
|
+
currentBody
|
|
167
255
|
);
|
|
168
256
|
}
|
|
169
257
|
|
|
170
|
-
// src/tool-support/github-api.ts
|
|
171
|
-
import {
|
|
172
|
-
PluginToolInputError
|
|
173
|
-
} from "@sentry/junior-plugin-api";
|
|
174
|
-
var GITHUB_API_BASE = "https://api.github.com";
|
|
175
|
-
async function githubApi(egress, input) {
|
|
176
|
-
const headers = {
|
|
177
|
-
Accept: "application/vnd.github+json",
|
|
178
|
-
"X-GitHub-Api-Version": input.apiVersion ?? "2022-11-28"
|
|
179
|
-
};
|
|
180
|
-
if (input.body !== void 0) headers["Content-Type"] = "application/json";
|
|
181
|
-
const response = await egress.fetch({
|
|
182
|
-
provider: "github",
|
|
183
|
-
operation: input.operation,
|
|
184
|
-
request: new Request(`${GITHUB_API_BASE}${input.path}`, {
|
|
185
|
-
method: input.method ?? "GET",
|
|
186
|
-
headers,
|
|
187
|
-
signal: input.signal,
|
|
188
|
-
...input.body !== void 0 ? { body: JSON.stringify(input.body) } : void 0
|
|
189
|
-
})
|
|
190
|
-
});
|
|
191
|
-
return {
|
|
192
|
-
body: await readBody(response),
|
|
193
|
-
ok: response.ok,
|
|
194
|
-
status: response.status
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
async function readBody(response) {
|
|
198
|
-
const text2 = await response.text();
|
|
199
|
-
if (!text2) return void 0;
|
|
200
|
-
try {
|
|
201
|
-
return JSON.parse(text2);
|
|
202
|
-
} catch {
|
|
203
|
-
return text2;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
function repoPath(repo) {
|
|
207
|
-
return `/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}`;
|
|
208
|
-
}
|
|
209
|
-
function parseRepo(value) {
|
|
210
|
-
const parts = value.split("/").map((part) => part.trim());
|
|
211
|
-
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
212
|
-
throw new PluginToolInputError('repo must use "owner/name" format');
|
|
213
|
-
}
|
|
214
|
-
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
215
|
-
}
|
|
216
|
-
function githubErrorMessage(body) {
|
|
217
|
-
if (typeof body === "string" && body.trim()) return body.trim();
|
|
218
|
-
if (!isRecord2(body)) return "GitHub request failed";
|
|
219
|
-
const errors = Array.isArray(body.errors) ? body.errors.filter(isRecord2) : [];
|
|
220
|
-
if (typeof body.message === "string" && body.message.trim()) {
|
|
221
|
-
const details = errors.map(
|
|
222
|
-
(error) => ["resource", "field", "code", "message"].map((name) => {
|
|
223
|
-
const value = error[name];
|
|
224
|
-
return typeof value === "string" && value.trim() ? `${name}=${value.trim()}` : void 0;
|
|
225
|
-
}).filter(Boolean).join(" ")
|
|
226
|
-
).filter(Boolean).join("; ");
|
|
227
|
-
const message = body.message.trim();
|
|
228
|
-
return details ? `${message}: ${details}` : message;
|
|
229
|
-
}
|
|
230
|
-
const graphqlMessages = errors.map((error) => error.message).filter((message) => typeof message === "string" && message.trim());
|
|
231
|
-
return graphqlMessages.length ? graphqlMessages.join("; ") : "GitHub request failed";
|
|
232
|
-
}
|
|
233
|
-
function isRecord2(value) {
|
|
234
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
258
|
// src/plugin.ts
|
|
238
259
|
import {
|
|
239
260
|
defineJuniorPlugin,
|
|
@@ -246,7 +267,7 @@ import {
|
|
|
246
267
|
PluginToolInputError as PluginToolInputError2,
|
|
247
268
|
pluginToolOutputSchema
|
|
248
269
|
} from "@sentry/junior-plugin-api";
|
|
249
|
-
import * as
|
|
270
|
+
import * as z2 from "zod";
|
|
250
271
|
|
|
251
272
|
// src/sandbox-paths.ts
|
|
252
273
|
var RESERVED_SANDBOX_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
@@ -259,9 +280,9 @@ function isReservedSandboxDirectory(path) {
|
|
|
259
280
|
}
|
|
260
281
|
|
|
261
282
|
// src/tools/clone-repository.ts
|
|
262
|
-
var inputSchema =
|
|
263
|
-
repo:
|
|
264
|
-
directory:
|
|
283
|
+
var inputSchema = z2.object({
|
|
284
|
+
repo: z2.string().describe('Repository in "owner/name" format.'),
|
|
285
|
+
directory: z2.string().regex(/^(?:[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*)$/).refine(
|
|
265
286
|
(value) => !value.split("/").some((part) => part === "." || part === ".."),
|
|
266
287
|
{
|
|
267
288
|
message: "Directory must be a relative path without . or .. segments."
|
|
@@ -269,18 +290,18 @@ var inputSchema = z.object({
|
|
|
269
290
|
).describe(
|
|
270
291
|
"Optional destination directory under the sandbox root. Defaults to repos/{name}."
|
|
271
292
|
).optional(),
|
|
272
|
-
allow_ad_hoc:
|
|
293
|
+
allow_ad_hoc: z2.boolean().optional().describe(
|
|
273
294
|
"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."
|
|
274
295
|
)
|
|
275
296
|
}).strict();
|
|
276
|
-
var cloneSchema =
|
|
277
|
-
path:
|
|
278
|
-
repo:
|
|
279
|
-
note:
|
|
297
|
+
var cloneSchema = z2.object({
|
|
298
|
+
path: z2.string(),
|
|
299
|
+
repo: z2.string(),
|
|
300
|
+
note: z2.string().optional()
|
|
280
301
|
});
|
|
281
302
|
var outputSchema = pluginToolOutputSchema.merge(
|
|
282
303
|
cloneSchema.extend({
|
|
283
|
-
target:
|
|
304
|
+
target: z2.literal("cloneRepository")
|
|
284
305
|
})
|
|
285
306
|
);
|
|
286
307
|
function parseRepo2(value) {
|
|
@@ -455,21 +476,21 @@ import {
|
|
|
455
476
|
PluginToolInputError as PluginToolInputError3,
|
|
456
477
|
pluginToolOutputSchema as pluginToolOutputSchema2
|
|
457
478
|
} from "@sentry/junior-plugin-api";
|
|
458
|
-
import * as
|
|
459
|
-
var inputSchema2 =
|
|
460
|
-
repo:
|
|
461
|
-
number:
|
|
462
|
-
body:
|
|
463
|
-
in_reply_to:
|
|
479
|
+
import * as z3 from "zod";
|
|
480
|
+
var inputSchema2 = z3.object({
|
|
481
|
+
repo: z3.string().describe('Repository in "owner/name" format.'),
|
|
482
|
+
number: z3.number().int().positive().describe("Pull request number."),
|
|
483
|
+
body: z3.string().trim().min(1).describe("Comment text."),
|
|
484
|
+
in_reply_to: z3.number().int().positive().optional().describe(
|
|
464
485
|
"Inline review comment id. Set it to reply in that comment's thread. Omit it to comment on the pull request."
|
|
465
486
|
)
|
|
466
487
|
}).strict();
|
|
467
488
|
var outputSchema2 = pluginToolOutputSchema2.extend({
|
|
468
|
-
target:
|
|
469
|
-
repo:
|
|
470
|
-
number:
|
|
471
|
-
comment_id:
|
|
472
|
-
url:
|
|
489
|
+
target: z3.literal("commentOnPullRequest"),
|
|
490
|
+
repo: z3.string(),
|
|
491
|
+
number: z3.number(),
|
|
492
|
+
comment_id: z3.number(),
|
|
493
|
+
url: z3.string()
|
|
473
494
|
});
|
|
474
495
|
async function threadRootId(egress, prefix, commentId) {
|
|
475
496
|
const response = await githubApi(egress, {
|
|
@@ -481,7 +502,7 @@ async function threadRootId(egress, prefix, commentId) {
|
|
|
481
502
|
if (response.status === 404) throw new PluginToolInputError3(message);
|
|
482
503
|
throw new Error(message);
|
|
483
504
|
}
|
|
484
|
-
const comment =
|
|
505
|
+
const comment = z3.object({ in_reply_to_id: z3.number().nullish() }).parse(response.body);
|
|
485
506
|
return comment.in_reply_to_id ?? commentId;
|
|
486
507
|
}
|
|
487
508
|
function createGitHubCommentOnPullRequestTool(egress) {
|
|
@@ -513,7 +534,7 @@ function createGitHubCommentOnPullRequestTool(egress) {
|
|
|
513
534
|
}
|
|
514
535
|
throw new Error(message);
|
|
515
536
|
}
|
|
516
|
-
const comment =
|
|
537
|
+
const comment = z3.object({ id: z3.number(), html_url: z3.string() }).parse(response.body);
|
|
517
538
|
return {
|
|
518
539
|
target: "commentOnPullRequest",
|
|
519
540
|
repo: repo.ref,
|
|
@@ -526,21 +547,21 @@ function createGitHubCommentOnPullRequestTool(egress) {
|
|
|
526
547
|
}
|
|
527
548
|
|
|
528
549
|
// src/object-facts.ts
|
|
529
|
-
import * as
|
|
530
|
-
var person =
|
|
531
|
-
var responseSchema =
|
|
532
|
-
body:
|
|
550
|
+
import * as z4 from "zod";
|
|
551
|
+
var person = z4.object({ login: z4.string() });
|
|
552
|
+
var responseSchema = z4.object({
|
|
553
|
+
body: z4.string().nullable().optional(),
|
|
533
554
|
user: person.nullable().optional(),
|
|
534
|
-
requested_reviewers:
|
|
535
|
-
assignees:
|
|
536
|
-
labels:
|
|
537
|
-
head:
|
|
538
|
-
base:
|
|
539
|
-
mergeable:
|
|
540
|
-
changed_files:
|
|
541
|
-
additions:
|
|
542
|
-
deletions:
|
|
543
|
-
updated_at:
|
|
555
|
+
requested_reviewers: z4.array(person).optional(),
|
|
556
|
+
assignees: z4.array(person).optional(),
|
|
557
|
+
labels: z4.array(z4.union([z4.string(), z4.object({ name: z4.string() })])).optional(),
|
|
558
|
+
head: z4.object({ ref: z4.string() }).optional(),
|
|
559
|
+
base: z4.object({ ref: z4.string() }).optional(),
|
|
560
|
+
mergeable: z4.boolean().nullable().optional(),
|
|
561
|
+
changed_files: z4.number().int().nonnegative().optional(),
|
|
562
|
+
additions: z4.number().int().nonnegative().optional(),
|
|
563
|
+
deletions: z4.number().int().nonnegative().optional(),
|
|
564
|
+
updated_at: z4.iso.datetime({ offset: true }).optional()
|
|
544
565
|
});
|
|
545
566
|
var short = (value) => {
|
|
546
567
|
const text2 = value?.trim();
|
|
@@ -671,7 +692,7 @@ import {
|
|
|
671
692
|
} from "@sentry/junior-plugin-api";
|
|
672
693
|
import { Type } from "@sinclair/typebox";
|
|
673
694
|
import { Value } from "@sinclair/typebox/value";
|
|
674
|
-
import * as
|
|
695
|
+
import * as z5 from "zod";
|
|
675
696
|
|
|
676
697
|
// src/tools/footer.ts
|
|
677
698
|
import { PluginToolInputError as PluginToolInputError4 } from "@sentry/junior-plugin-api";
|
|
@@ -757,11 +778,11 @@ function githubLinkedIssues(body, repositoryFullName) {
|
|
|
757
778
|
if (!body) return [];
|
|
758
779
|
const references = /* @__PURE__ */ new Map();
|
|
759
780
|
const add = (linkedRepository, rawNumber) => {
|
|
760
|
-
const
|
|
761
|
-
if (!Number.isInteger(
|
|
781
|
+
const number23 = Number.parseInt(rawNumber, 10);
|
|
782
|
+
if (!Number.isInteger(number23) || number23 <= 0) return;
|
|
762
783
|
const normalizedRepository = linkedRepository.toLowerCase();
|
|
763
|
-
references.set(`${normalizedRepository}#${
|
|
764
|
-
number:
|
|
784
|
+
references.set(`${normalizedRepository}#${number23}`, {
|
|
785
|
+
number: number23,
|
|
765
786
|
repositoryFullName: linkedRepository
|
|
766
787
|
});
|
|
767
788
|
};
|
|
@@ -824,11 +845,11 @@ var createIssueInputSchema = Type.Object(
|
|
|
824
845
|
},
|
|
825
846
|
{ additionalProperties: false }
|
|
826
847
|
);
|
|
827
|
-
var createIssueToolInputSchema =
|
|
828
|
-
repo:
|
|
829
|
-
title:
|
|
830
|
-
body:
|
|
831
|
-
labels:
|
|
848
|
+
var createIssueToolInputSchema = z5.object({
|
|
849
|
+
repo: z5.string().describe('Repository in "owner/name" format.'),
|
|
850
|
+
title: z5.string().describe("Issue title."),
|
|
851
|
+
body: z5.string().describe("Issue body. The runtime appends the conversation footer.").optional(),
|
|
852
|
+
labels: z5.array(z5.string()).describe("Labels to apply to the issue.").optional()
|
|
832
853
|
}).strict();
|
|
833
854
|
var createIssueStateSchema = Type.Union([
|
|
834
855
|
Type.Object(
|
|
@@ -853,14 +874,14 @@ var createIssueStateSchema = Type.Union([
|
|
|
853
874
|
{ additionalProperties: false }
|
|
854
875
|
)
|
|
855
876
|
]);
|
|
856
|
-
var gitHubIssueDataSchema =
|
|
857
|
-
number:
|
|
877
|
+
var gitHubIssueDataSchema = z5.object({
|
|
878
|
+
number: z5.number(),
|
|
858
879
|
subscribable: subscribableResourceSchema.optional(),
|
|
859
|
-
url:
|
|
880
|
+
url: z5.string()
|
|
860
881
|
});
|
|
861
882
|
var gitHubIssueOutputSchema = pluginToolOutputSchema3.merge(
|
|
862
883
|
gitHubIssueDataSchema.extend({
|
|
863
|
-
target:
|
|
884
|
+
target: z5.literal("createIssue")
|
|
864
885
|
})
|
|
865
886
|
);
|
|
866
887
|
function gitHubIssueToolResult(input, result, canSubscribe) {
|
|
@@ -1076,69 +1097,69 @@ import {
|
|
|
1076
1097
|
pluginToolOutputSchema as pluginToolOutputSchema4,
|
|
1077
1098
|
subscribableResourceSchema as subscribableResourceSchema2
|
|
1078
1099
|
} from "@sentry/junior-plugin-api";
|
|
1079
|
-
import * as
|
|
1080
|
-
var commitShaSchema =
|
|
1081
|
-
var inputSchema3 =
|
|
1082
|
-
repo:
|
|
1100
|
+
import * as z6 from "zod";
|
|
1101
|
+
var commitShaSchema = z6.string().regex(/^[0-9a-f]{40}$/i);
|
|
1102
|
+
var inputSchema3 = z6.object({
|
|
1103
|
+
repo: z6.string().describe('Repository in "owner/name" format.'),
|
|
1083
1104
|
commit_sha: commitShaSchema.describe(
|
|
1084
1105
|
"Full 40-character Git commit SHA recorded by the deployment."
|
|
1085
1106
|
),
|
|
1086
|
-
environment:
|
|
1107
|
+
environment: z6.string().trim().min(1).describe(
|
|
1087
1108
|
'Optional GitHub deployment environment, such as "Production". Omit to inspect and watch deployments for the commit across environments.'
|
|
1088
1109
|
).optional()
|
|
1089
1110
|
}).strict();
|
|
1090
|
-
var statusSchema =
|
|
1091
|
-
created_at:
|
|
1092
|
-
creator:
|
|
1093
|
-
description:
|
|
1094
|
-
environment_url:
|
|
1095
|
-
id:
|
|
1096
|
-
log_url:
|
|
1097
|
-
state:
|
|
1111
|
+
var statusSchema = z6.object({
|
|
1112
|
+
created_at: z6.string(),
|
|
1113
|
+
creator: z6.string().nullable(),
|
|
1114
|
+
description: z6.string().nullable(),
|
|
1115
|
+
environment_url: z6.string().nullable(),
|
|
1116
|
+
id: z6.number(),
|
|
1117
|
+
log_url: z6.string().nullable(),
|
|
1118
|
+
state: z6.string()
|
|
1098
1119
|
}).strict();
|
|
1099
|
-
var deploymentSchema =
|
|
1100
|
-
created_at:
|
|
1101
|
-
creator:
|
|
1102
|
-
description:
|
|
1103
|
-
environment:
|
|
1104
|
-
id:
|
|
1120
|
+
var deploymentSchema = z6.object({
|
|
1121
|
+
created_at: z6.string(),
|
|
1122
|
+
creator: z6.string().nullable(),
|
|
1123
|
+
description: z6.string().nullable(),
|
|
1124
|
+
environment: z6.string(),
|
|
1125
|
+
id: z6.number(),
|
|
1105
1126
|
latest_status: statusSchema.nullable(),
|
|
1106
|
-
ref:
|
|
1127
|
+
ref: z6.string(),
|
|
1107
1128
|
sha: commitShaSchema,
|
|
1108
|
-
updated_at:
|
|
1109
|
-
url:
|
|
1129
|
+
updated_at: z6.string(),
|
|
1130
|
+
url: z6.string()
|
|
1110
1131
|
}).strict();
|
|
1111
|
-
var deploymentSourceSchema =
|
|
1132
|
+
var deploymentSourceSchema = z6.object({
|
|
1112
1133
|
commit_sha: commitShaSchema,
|
|
1113
1134
|
deployment: deploymentSchema.nullable(),
|
|
1114
|
-
environment:
|
|
1115
|
-
repo:
|
|
1135
|
+
environment: z6.string().nullable(),
|
|
1136
|
+
repo: z6.string(),
|
|
1116
1137
|
subscribable: subscribableResourceSchema2.optional()
|
|
1117
1138
|
}).strict();
|
|
1118
1139
|
var outputSchema3 = pluginToolOutputSchema4.merge(
|
|
1119
1140
|
deploymentSourceSchema.extend({
|
|
1120
|
-
target:
|
|
1141
|
+
target: z6.literal("getDeployment")
|
|
1121
1142
|
})
|
|
1122
1143
|
);
|
|
1123
|
-
var providerCreatorSchema =
|
|
1124
|
-
var providerDeploymentSchema =
|
|
1125
|
-
created_at:
|
|
1144
|
+
var providerCreatorSchema = z6.object({ login: z6.string() }).passthrough().nullable();
|
|
1145
|
+
var providerDeploymentSchema = z6.object({
|
|
1146
|
+
created_at: z6.string(),
|
|
1126
1147
|
creator: providerCreatorSchema,
|
|
1127
|
-
description:
|
|
1128
|
-
environment:
|
|
1129
|
-
id:
|
|
1130
|
-
ref:
|
|
1148
|
+
description: z6.string().nullable(),
|
|
1149
|
+
environment: z6.string(),
|
|
1150
|
+
id: z6.number(),
|
|
1151
|
+
ref: z6.string(),
|
|
1131
1152
|
sha: commitShaSchema,
|
|
1132
|
-
updated_at:
|
|
1153
|
+
updated_at: z6.string()
|
|
1133
1154
|
}).passthrough();
|
|
1134
|
-
var providerStatusSchema =
|
|
1135
|
-
created_at:
|
|
1155
|
+
var providerStatusSchema = z6.object({
|
|
1156
|
+
created_at: z6.string(),
|
|
1136
1157
|
creator: providerCreatorSchema,
|
|
1137
|
-
description:
|
|
1138
|
-
environment_url:
|
|
1139
|
-
id:
|
|
1140
|
-
log_url:
|
|
1141
|
-
state:
|
|
1158
|
+
description: z6.string().nullable().optional(),
|
|
1159
|
+
environment_url: z6.string().nullable().optional(),
|
|
1160
|
+
id: z6.number(),
|
|
1161
|
+
log_url: z6.string().nullable().optional(),
|
|
1162
|
+
state: z6.string()
|
|
1142
1163
|
}).passthrough();
|
|
1143
1164
|
function throwLookupError(target, status, body) {
|
|
1144
1165
|
const message = `GitHub ${target} lookup failed with HTTP ${status}`;
|
|
@@ -1174,7 +1195,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1174
1195
|
if (!deployments.ok) {
|
|
1175
1196
|
throwLookupError("deployment", deployments.status, deployments.body);
|
|
1176
1197
|
}
|
|
1177
|
-
const providerDeployment =
|
|
1198
|
+
const providerDeployment = z6.array(providerDeploymentSchema).parse(deployments.body)[0];
|
|
1178
1199
|
let deployment = null;
|
|
1179
1200
|
if (providerDeployment) {
|
|
1180
1201
|
const statuses = await githubApi(ctx.egress, {
|
|
@@ -1184,7 +1205,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1184
1205
|
if (!statuses.ok) {
|
|
1185
1206
|
throwLookupError("deployment status", statuses.status, statuses.body);
|
|
1186
1207
|
}
|
|
1187
|
-
const providerStatus =
|
|
1208
|
+
const providerStatus = z6.array(providerStatusSchema).parse(statuses.body)[0];
|
|
1188
1209
|
deployment = {
|
|
1189
1210
|
created_at: providerDeployment.created_at,
|
|
1190
1211
|
creator: providerDeployment.creator?.login ?? null,
|
|
@@ -1227,19 +1248,123 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1227
1248
|
});
|
|
1228
1249
|
}
|
|
1229
1250
|
|
|
1230
|
-
// src/tools/
|
|
1251
|
+
// src/tools/get-issue.ts
|
|
1231
1252
|
import {
|
|
1232
|
-
objectFactsSchema as objectFactsSchema2,
|
|
1233
1253
|
definePluginTool as definePluginTool5,
|
|
1234
|
-
EgressAuthRequired as EgressAuthRequired2,
|
|
1235
1254
|
PluginToolInputError as PluginToolInputError7,
|
|
1236
1255
|
pluginToolOutputSchema as pluginToolOutputSchema5,
|
|
1237
|
-
watchResultSchema,
|
|
1238
1256
|
subscribableResourceSchema as subscribableResourceSchema3
|
|
1239
1257
|
} from "@sentry/junior-plugin-api";
|
|
1258
|
+
import * as z7 from "zod";
|
|
1259
|
+
var CLAIM_NOTE = "If you start work on this issue, first claim it with github_updateIssue and assign_requester: true.";
|
|
1260
|
+
var inputSchema4 = z7.object({
|
|
1261
|
+
repo: z7.string().describe('Repository in "owner/name" format.'),
|
|
1262
|
+
number: z7.number().int().positive().describe("Issue number.")
|
|
1263
|
+
}).strict();
|
|
1264
|
+
var issueSchema = z7.object({
|
|
1265
|
+
assignees: z7.array(z7.string()),
|
|
1266
|
+
author: z7.string().optional(),
|
|
1267
|
+
body: z7.string().nullable(),
|
|
1268
|
+
comments: z7.number(),
|
|
1269
|
+
labels: z7.array(z7.string()),
|
|
1270
|
+
note: z7.string().optional(),
|
|
1271
|
+
number: z7.number(),
|
|
1272
|
+
state: z7.string(),
|
|
1273
|
+
subscribable: subscribableResourceSchema3.optional(),
|
|
1274
|
+
title: z7.string(),
|
|
1275
|
+
url: z7.string()
|
|
1276
|
+
});
|
|
1277
|
+
var outputSchema4 = pluginToolOutputSchema5.merge(
|
|
1278
|
+
issueSchema.extend({ target: z7.literal("getIssue") })
|
|
1279
|
+
);
|
|
1280
|
+
var providerIssueSchema = z7.object({
|
|
1281
|
+
assignees: z7.array(z7.object({ login: z7.string() })).nullish().transform((assignees) => assignees?.map(({ login }) => login) ?? []),
|
|
1282
|
+
body: z7.string().nullable().optional().default(null),
|
|
1283
|
+
comments: z7.number().optional().default(0),
|
|
1284
|
+
html_url: z7.string(),
|
|
1285
|
+
labels: z7.array(z7.object({ name: z7.string() })).optional().default([]).transform((labels) => labels.map(({ name }) => name)),
|
|
1286
|
+
number: z7.number(),
|
|
1287
|
+
state: z7.string(),
|
|
1288
|
+
title: z7.string(),
|
|
1289
|
+
user: z7.object({ login: z7.string() }).nullish()
|
|
1290
|
+
});
|
|
1291
|
+
function createGitHubGetIssueTool(ctx) {
|
|
1292
|
+
return definePluginTool5({
|
|
1293
|
+
annotations: {
|
|
1294
|
+
destructiveHint: false,
|
|
1295
|
+
idempotentHint: true,
|
|
1296
|
+
openWorldHint: true,
|
|
1297
|
+
readOnlyHint: true
|
|
1298
|
+
},
|
|
1299
|
+
description: "Get a GitHub issue. Read its comments with gh api repos/OWNER/REPO/issues/NUMBER/comments.",
|
|
1300
|
+
inputSchema: inputSchema4,
|
|
1301
|
+
outputSchema: outputSchema4,
|
|
1302
|
+
async execute(input) {
|
|
1303
|
+
const repo = parseRepo(input.repo);
|
|
1304
|
+
const [response, requester] = await Promise.all([
|
|
1305
|
+
githubApi(ctx.egress, {
|
|
1306
|
+
operation: "github.issue.get",
|
|
1307
|
+
path: `${repoPath(repo)}/issues/${input.number}`
|
|
1308
|
+
}),
|
|
1309
|
+
resolveGitHubRequester(ctx)
|
|
1310
|
+
]);
|
|
1311
|
+
if (!response.ok) {
|
|
1312
|
+
const message = `GitHub issue lookup failed with HTTP ${response.status}`;
|
|
1313
|
+
if (response.status === 404) {
|
|
1314
|
+
throw new PluginToolInputError7(message);
|
|
1315
|
+
}
|
|
1316
|
+
throw new Error(message);
|
|
1317
|
+
}
|
|
1318
|
+
const issue = providerIssueSchema.parse(response.body);
|
|
1319
|
+
const login = linkedGitHubLogin(requester?.user)?.toLowerCase();
|
|
1320
|
+
const needsClaim = login !== void 0 && issue.state === "open" && !issue.assignees.some((assignee) => assignee.toLowerCase() === login);
|
|
1321
|
+
const subscribable = gitHubIssueSubscribable({
|
|
1322
|
+
canSubscribe: ctx.events.canSubscribe,
|
|
1323
|
+
number: issue.number,
|
|
1324
|
+
repo: repo.ref
|
|
1325
|
+
});
|
|
1326
|
+
return {
|
|
1327
|
+
objectAnnotations: [
|
|
1328
|
+
githubObjectAnnotation({
|
|
1329
|
+
...githubObjectFacts("task", response.body),
|
|
1330
|
+
repo: repo.ref,
|
|
1331
|
+
number: issue.number,
|
|
1332
|
+
title: issue.title,
|
|
1333
|
+
url: issue.html_url,
|
|
1334
|
+
objectType: "task",
|
|
1335
|
+
status: issue.state
|
|
1336
|
+
})
|
|
1337
|
+
],
|
|
1338
|
+
target: "getIssue",
|
|
1339
|
+
assignees: issue.assignees,
|
|
1340
|
+
...issue.user ? { author: issue.user.login } : void 0,
|
|
1341
|
+
body: issue.body,
|
|
1342
|
+
comments: issue.comments,
|
|
1343
|
+
labels: issue.labels,
|
|
1344
|
+
...needsClaim ? { note: CLAIM_NOTE } : void 0,
|
|
1345
|
+
number: issue.number,
|
|
1346
|
+
state: issue.state,
|
|
1347
|
+
...subscribable ? { subscribable } : void 0,
|
|
1348
|
+
title: issue.title,
|
|
1349
|
+
url: issue.html_url
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
// src/tools/create-pull-request.ts
|
|
1356
|
+
import {
|
|
1357
|
+
objectFactsSchema as objectFactsSchema2,
|
|
1358
|
+
definePluginTool as definePluginTool6,
|
|
1359
|
+
EgressAuthRequired as EgressAuthRequired2,
|
|
1360
|
+
PluginToolInputError as PluginToolInputError8,
|
|
1361
|
+
pluginToolOutputSchema as pluginToolOutputSchema6,
|
|
1362
|
+
watchResultSchema,
|
|
1363
|
+
subscribableResourceSchema as subscribableResourceSchema4
|
|
1364
|
+
} from "@sentry/junior-plugin-api";
|
|
1240
1365
|
import { Type as Type2 } from "@sinclair/typebox";
|
|
1241
1366
|
import { Value as Value2 } from "@sinclair/typebox/value";
|
|
1242
|
-
import * as
|
|
1367
|
+
import * as z10 from "zod";
|
|
1243
1368
|
|
|
1244
1369
|
// src/pull-request-requesters/store.ts
|
|
1245
1370
|
import { and, asc, eq, inArray, lt } from "drizzle-orm";
|
|
@@ -1254,18 +1379,18 @@ import {
|
|
|
1254
1379
|
text,
|
|
1255
1380
|
timestamp
|
|
1256
1381
|
} from "drizzle-orm/pg-core";
|
|
1257
|
-
import * as
|
|
1258
|
-
var githubPullRequestStateSchema =
|
|
1382
|
+
import * as z8 from "zod";
|
|
1383
|
+
var githubPullRequestStateSchema = z8.enum([
|
|
1259
1384
|
"closed_unmerged",
|
|
1260
1385
|
"merged",
|
|
1261
1386
|
"open"
|
|
1262
1387
|
]);
|
|
1263
|
-
var githubPullRequestCommitCompositionSchema =
|
|
1388
|
+
var githubPullRequestCommitCompositionSchema = z8.enum([
|
|
1264
1389
|
"junior_only",
|
|
1265
1390
|
"mixed"
|
|
1266
1391
|
]);
|
|
1267
|
-
var githubIssueStateSchema =
|
|
1268
|
-
var githubIssueStateReasonSchema =
|
|
1392
|
+
var githubIssueStateSchema = z8.enum(["closed", "open"]);
|
|
1393
|
+
var githubIssueStateReasonSchema = z8.enum([
|
|
1269
1394
|
"completed",
|
|
1270
1395
|
"duplicate",
|
|
1271
1396
|
"not_planned",
|
|
@@ -1426,31 +1551,31 @@ async function listGitHubPullRequestOpeners(db, input) {
|
|
|
1426
1551
|
}
|
|
1427
1552
|
|
|
1428
1553
|
// src/tools/stack-pull-request.ts
|
|
1429
|
-
import * as
|
|
1554
|
+
import * as z9 from "zod";
|
|
1430
1555
|
var MAX_STACK_DEPTH = 10;
|
|
1431
1556
|
var GITHUB_STACKS_API_VERSION = "2026-03-10";
|
|
1432
|
-
var stackTargetSchema =
|
|
1433
|
-
number:
|
|
1434
|
-
head:
|
|
1435
|
-
repo:
|
|
1557
|
+
var stackTargetSchema = z9.object({
|
|
1558
|
+
number: z9.number().int().positive(),
|
|
1559
|
+
head: z9.object({
|
|
1560
|
+
repo: z9.object({ full_name: z9.string().min(1) }).nullable()
|
|
1436
1561
|
}),
|
|
1437
|
-
base:
|
|
1438
|
-
ref:
|
|
1439
|
-
repo:
|
|
1440
|
-
default_branch:
|
|
1441
|
-
full_name:
|
|
1562
|
+
base: z9.object({
|
|
1563
|
+
ref: z9.string().min(1),
|
|
1564
|
+
repo: z9.object({
|
|
1565
|
+
default_branch: z9.string().min(1),
|
|
1566
|
+
full_name: z9.string().min(1)
|
|
1442
1567
|
})
|
|
1443
1568
|
})
|
|
1444
1569
|
});
|
|
1445
|
-
var openPullRequestsSchema =
|
|
1446
|
-
|
|
1447
|
-
number:
|
|
1448
|
-
base:
|
|
1570
|
+
var openPullRequestsSchema = z9.array(
|
|
1571
|
+
z9.object({
|
|
1572
|
+
number: z9.number().int().positive(),
|
|
1573
|
+
base: z9.object({ ref: z9.string().min(1) })
|
|
1449
1574
|
})
|
|
1450
1575
|
);
|
|
1451
|
-
var stackSchema =
|
|
1452
|
-
number:
|
|
1453
|
-
pull_requests:
|
|
1576
|
+
var stackSchema = z9.object({
|
|
1577
|
+
number: z9.number().int().positive(),
|
|
1578
|
+
pull_requests: z9.array(z9.object({ number: z9.number().int().positive() }))
|
|
1454
1579
|
});
|
|
1455
1580
|
async function stackGitHubPullRequest(ctx, target) {
|
|
1456
1581
|
const repo = target.base.repo.full_name;
|
|
@@ -1496,7 +1621,7 @@ async function stackGitHubPullRequest(ctx, target) {
|
|
|
1496
1621
|
const stacks = await github(
|
|
1497
1622
|
"github.stack.read",
|
|
1498
1623
|
`${api}/stacks?pull_request=${parent.number}`,
|
|
1499
|
-
|
|
1624
|
+
z9.array(stackSchema)
|
|
1500
1625
|
);
|
|
1501
1626
|
if (!stacks) return void 0;
|
|
1502
1627
|
const stack = stacks[0];
|
|
@@ -1571,15 +1696,15 @@ var createPullRequestInputSchema = Type2.Object(
|
|
|
1571
1696
|
},
|
|
1572
1697
|
{ additionalProperties: false }
|
|
1573
1698
|
);
|
|
1574
|
-
var createPullRequestToolInputSchema =
|
|
1575
|
-
repo:
|
|
1576
|
-
title:
|
|
1577
|
-
head:
|
|
1578
|
-
base:
|
|
1579
|
-
body:
|
|
1699
|
+
var createPullRequestToolInputSchema = z10.object({
|
|
1700
|
+
repo: z10.string().describe('Repository in "owner/name" format.'),
|
|
1701
|
+
title: z10.string().describe("Pull request title."),
|
|
1702
|
+
head: z10.string().describe("Head branch or owner:branch ref."),
|
|
1703
|
+
base: z10.string().describe("Base branch."),
|
|
1704
|
+
body: z10.string().describe(
|
|
1580
1705
|
"Pull request body. The runtime appends the conversation footer."
|
|
1581
1706
|
).optional(),
|
|
1582
|
-
draft:
|
|
1707
|
+
draft: z10.boolean().describe("Whether to open the pull request as a draft.").optional()
|
|
1583
1708
|
}).strict();
|
|
1584
1709
|
var createPullRequestStateSchema = Type2.Union([
|
|
1585
1710
|
Type2.Object(
|
|
@@ -1604,30 +1729,30 @@ var createPullRequestStateSchema = Type2.Union([
|
|
|
1604
1729
|
{ additionalProperties: false }
|
|
1605
1730
|
)
|
|
1606
1731
|
]);
|
|
1607
|
-
var gitHubPullRequestDataSchema =
|
|
1608
|
-
number:
|
|
1609
|
-
url:
|
|
1610
|
-
stack:
|
|
1611
|
-
subscribable:
|
|
1732
|
+
var gitHubPullRequestDataSchema = z10.object({
|
|
1733
|
+
number: z10.number(),
|
|
1734
|
+
url: z10.string(),
|
|
1735
|
+
stack: z10.object({ number: z10.number(), pull_requests: z10.array(z10.number()) }).optional(),
|
|
1736
|
+
subscribable: subscribableResourceSchema4.optional(),
|
|
1612
1737
|
subscription: watchResultSchema.optional()
|
|
1613
1738
|
});
|
|
1614
|
-
var gitHubPullRequestOutputSchema =
|
|
1739
|
+
var gitHubPullRequestOutputSchema = pluginToolOutputSchema6.merge(
|
|
1615
1740
|
gitHubPullRequestDataSchema.extend({
|
|
1616
|
-
target:
|
|
1741
|
+
target: z10.literal("createPullRequest")
|
|
1617
1742
|
})
|
|
1618
1743
|
);
|
|
1619
1744
|
function parseCreatePullRequestInput(input) {
|
|
1620
1745
|
try {
|
|
1621
1746
|
return Value2.Parse(createPullRequestInputSchema, input);
|
|
1622
1747
|
} catch (error) {
|
|
1623
|
-
throw new
|
|
1748
|
+
throw new PluginToolInputError8("Invalid GitHub createPullRequest input.", {
|
|
1624
1749
|
cause: error
|
|
1625
1750
|
});
|
|
1626
1751
|
}
|
|
1627
1752
|
}
|
|
1628
1753
|
function nonEmptyString3(value, name) {
|
|
1629
1754
|
if (!value?.trim()) {
|
|
1630
|
-
throw new
|
|
1755
|
+
throw new PluginToolInputError8(`${name} is required`);
|
|
1631
1756
|
}
|
|
1632
1757
|
return value.trim();
|
|
1633
1758
|
}
|
|
@@ -1816,7 +1941,7 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
|
|
|
1816
1941
|
}
|
|
1817
1942
|
}
|
|
1818
1943
|
function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
1819
|
-
return
|
|
1944
|
+
return definePluginTool6({
|
|
1820
1945
|
annotations: {
|
|
1821
1946
|
destructiveHint: false,
|
|
1822
1947
|
idempotentHint: true,
|
|
@@ -1935,36 +2060,36 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
1935
2060
|
|
|
1936
2061
|
// src/tools/get-pull-request.ts
|
|
1937
2062
|
import {
|
|
1938
|
-
definePluginTool as
|
|
1939
|
-
PluginToolInputError as
|
|
1940
|
-
pluginToolOutputSchema as
|
|
2063
|
+
definePluginTool as definePluginTool7,
|
|
2064
|
+
PluginToolInputError as PluginToolInputError9,
|
|
2065
|
+
pluginToolOutputSchema as pluginToolOutputSchema7
|
|
1941
2066
|
} from "@sentry/junior-plugin-api";
|
|
1942
|
-
import * as
|
|
1943
|
-
import { subscribableResourceSchema as
|
|
1944
|
-
var commitShaSchema2 =
|
|
1945
|
-
var
|
|
1946
|
-
repo:
|
|
1947
|
-
number:
|
|
2067
|
+
import * as z11 from "zod";
|
|
2068
|
+
import { subscribableResourceSchema as subscribableResourceSchema5 } from "@sentry/junior-plugin-api";
|
|
2069
|
+
var commitShaSchema2 = z11.string().regex(/^[0-9a-f]{40}$/i);
|
|
2070
|
+
var inputSchema5 = z11.object({
|
|
2071
|
+
repo: z11.string().describe('Repository in "owner/name" format.'),
|
|
2072
|
+
number: z11.number().int().positive().describe("Pull request number.")
|
|
1948
2073
|
}).strict();
|
|
1949
|
-
var pullRequestSchema =
|
|
1950
|
-
base:
|
|
1951
|
-
draft:
|
|
1952
|
-
head:
|
|
2074
|
+
var pullRequestSchema = z11.object({
|
|
2075
|
+
base: z11.string(),
|
|
2076
|
+
draft: z11.boolean(),
|
|
2077
|
+
head: z11.string(),
|
|
1953
2078
|
head_sha: commitShaSchema2,
|
|
1954
|
-
merged:
|
|
1955
|
-
number:
|
|
1956
|
-
state:
|
|
1957
|
-
subscribable:
|
|
1958
|
-
title:
|
|
1959
|
-
url:
|
|
2079
|
+
merged: z11.boolean(),
|
|
2080
|
+
number: z11.number(),
|
|
2081
|
+
state: z11.string(),
|
|
2082
|
+
subscribable: subscribableResourceSchema5.optional(),
|
|
2083
|
+
title: z11.string(),
|
|
2084
|
+
url: z11.string()
|
|
1960
2085
|
});
|
|
1961
|
-
var
|
|
2086
|
+
var outputSchema5 = pluginToolOutputSchema7.merge(
|
|
1962
2087
|
pullRequestSchema.extend({
|
|
1963
|
-
target:
|
|
2088
|
+
target: z11.literal("getPullRequest")
|
|
1964
2089
|
})
|
|
1965
2090
|
);
|
|
1966
2091
|
function createGitHubGetPullRequestTool(ctx) {
|
|
1967
|
-
return
|
|
2092
|
+
return definePluginTool7({
|
|
1968
2093
|
annotations: {
|
|
1969
2094
|
destructiveHint: false,
|
|
1970
2095
|
idempotentHint: true,
|
|
@@ -1972,8 +2097,8 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
1972
2097
|
readOnlyHint: true
|
|
1973
2098
|
},
|
|
1974
2099
|
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.",
|
|
1975
|
-
inputSchema:
|
|
1976
|
-
outputSchema:
|
|
2100
|
+
inputSchema: inputSchema5,
|
|
2101
|
+
outputSchema: outputSchema5,
|
|
1977
2102
|
async execute(input) {
|
|
1978
2103
|
const repo = parseRepo(input.repo);
|
|
1979
2104
|
const response = await githubApi(ctx.egress, {
|
|
@@ -1983,19 +2108,19 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
1983
2108
|
if (!response.ok) {
|
|
1984
2109
|
const message = `GitHub pull request lookup failed with HTTP ${response.status}`;
|
|
1985
2110
|
if (response.status === 404) {
|
|
1986
|
-
throw new
|
|
2111
|
+
throw new PluginToolInputError9(message);
|
|
1987
2112
|
}
|
|
1988
2113
|
throw new Error(message);
|
|
1989
2114
|
}
|
|
1990
|
-
const providerResult =
|
|
1991
|
-
base:
|
|
1992
|
-
draft:
|
|
1993
|
-
head:
|
|
1994
|
-
html_url:
|
|
1995
|
-
merged:
|
|
1996
|
-
number:
|
|
1997
|
-
state:
|
|
1998
|
-
title:
|
|
2115
|
+
const providerResult = z11.object({
|
|
2116
|
+
base: z11.object({ ref: z11.string() }),
|
|
2117
|
+
draft: z11.boolean(),
|
|
2118
|
+
head: z11.object({ ref: z11.string(), sha: commitShaSchema2 }),
|
|
2119
|
+
html_url: z11.string(),
|
|
2120
|
+
merged: z11.boolean().optional().default(false),
|
|
2121
|
+
number: z11.number(),
|
|
2122
|
+
state: z11.string(),
|
|
2123
|
+
title: z11.string()
|
|
1999
2124
|
}).parse(response.body);
|
|
2000
2125
|
const subscribable = gitHubPullRequestSubscribable({
|
|
2001
2126
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -2035,49 +2160,49 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2035
2160
|
|
|
2036
2161
|
// src/tools/get-release.ts
|
|
2037
2162
|
import {
|
|
2038
|
-
definePluginTool as
|
|
2039
|
-
pluginToolOutputSchema as
|
|
2040
|
-
subscribableResourceSchema as
|
|
2163
|
+
definePluginTool as definePluginTool8,
|
|
2164
|
+
pluginToolOutputSchema as pluginToolOutputSchema8,
|
|
2165
|
+
subscribableResourceSchema as subscribableResourceSchema6
|
|
2041
2166
|
} from "@sentry/junior-plugin-api";
|
|
2042
|
-
import * as
|
|
2043
|
-
var
|
|
2044
|
-
repo:
|
|
2045
|
-
tag:
|
|
2167
|
+
import * as z12 from "zod";
|
|
2168
|
+
var inputSchema6 = z12.object({
|
|
2169
|
+
repo: z12.string().describe('Repository in "owner/name" format.'),
|
|
2170
|
+
tag: z12.string().trim().min(1).describe(
|
|
2046
2171
|
"Optional release tag name. Omit to inspect and watch every published release in the repository."
|
|
2047
2172
|
).optional()
|
|
2048
2173
|
}).strict();
|
|
2049
|
-
var releaseSchema =
|
|
2050
|
-
created_at:
|
|
2051
|
-
draft:
|
|
2052
|
-
html_url:
|
|
2053
|
-
id:
|
|
2054
|
-
name:
|
|
2055
|
-
prerelease:
|
|
2056
|
-
published_at:
|
|
2057
|
-
tag_name:
|
|
2058
|
-
target_commitish:
|
|
2174
|
+
var releaseSchema = z12.object({
|
|
2175
|
+
created_at: z12.string(),
|
|
2176
|
+
draft: z12.boolean(),
|
|
2177
|
+
html_url: z12.string(),
|
|
2178
|
+
id: z12.number(),
|
|
2179
|
+
name: z12.string().nullable(),
|
|
2180
|
+
prerelease: z12.boolean(),
|
|
2181
|
+
published_at: z12.string().nullable(),
|
|
2182
|
+
tag_name: z12.string(),
|
|
2183
|
+
target_commitish: z12.string()
|
|
2059
2184
|
}).strict();
|
|
2060
|
-
var releaseSourceSchema =
|
|
2185
|
+
var releaseSourceSchema = z12.object({
|
|
2061
2186
|
release: releaseSchema.nullable(),
|
|
2062
|
-
repo:
|
|
2063
|
-
subscribable:
|
|
2064
|
-
tag:
|
|
2187
|
+
repo: z12.string(),
|
|
2188
|
+
subscribable: subscribableResourceSchema6.optional(),
|
|
2189
|
+
tag: z12.string().nullable()
|
|
2065
2190
|
}).strict();
|
|
2066
|
-
var
|
|
2191
|
+
var outputSchema6 = pluginToolOutputSchema8.merge(
|
|
2067
2192
|
releaseSourceSchema.extend({
|
|
2068
|
-
target:
|
|
2193
|
+
target: z12.literal("getRelease")
|
|
2069
2194
|
})
|
|
2070
2195
|
);
|
|
2071
|
-
var providerReleaseSchema =
|
|
2072
|
-
created_at:
|
|
2073
|
-
draft:
|
|
2074
|
-
html_url:
|
|
2075
|
-
id:
|
|
2076
|
-
name:
|
|
2077
|
-
prerelease:
|
|
2078
|
-
published_at:
|
|
2079
|
-
tag_name:
|
|
2080
|
-
target_commitish:
|
|
2196
|
+
var providerReleaseSchema = z12.object({
|
|
2197
|
+
created_at: z12.string(),
|
|
2198
|
+
draft: z12.boolean(),
|
|
2199
|
+
html_url: z12.string(),
|
|
2200
|
+
id: z12.number(),
|
|
2201
|
+
name: z12.string().nullable(),
|
|
2202
|
+
prerelease: z12.boolean(),
|
|
2203
|
+
published_at: z12.string().nullable(),
|
|
2204
|
+
tag_name: z12.string(),
|
|
2205
|
+
target_commitish: z12.string()
|
|
2081
2206
|
}).passthrough();
|
|
2082
2207
|
function mapRelease(providerRelease) {
|
|
2083
2208
|
return {
|
|
@@ -2093,7 +2218,7 @@ function mapRelease(providerRelease) {
|
|
|
2093
2218
|
};
|
|
2094
2219
|
}
|
|
2095
2220
|
function createGitHubGetReleaseTool(ctx) {
|
|
2096
|
-
return
|
|
2221
|
+
return definePluginTool8({
|
|
2097
2222
|
annotations: {
|
|
2098
2223
|
destructiveHint: false,
|
|
2099
2224
|
idempotentHint: true,
|
|
@@ -2101,8 +2226,8 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2101
2226
|
readOnlyHint: true
|
|
2102
2227
|
},
|
|
2103
2228
|
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.",
|
|
2104
|
-
inputSchema:
|
|
2105
|
-
outputSchema:
|
|
2229
|
+
inputSchema: inputSchema6,
|
|
2230
|
+
outputSchema: outputSchema6,
|
|
2106
2231
|
async execute(input) {
|
|
2107
2232
|
const repo = parseRepo(input.repo);
|
|
2108
2233
|
const tag = input.tag?.trim() || void 0;
|
|
@@ -2155,30 +2280,30 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2155
2280
|
|
|
2156
2281
|
// src/tools/get-repository.ts
|
|
2157
2282
|
import {
|
|
2158
|
-
definePluginTool as
|
|
2159
|
-
PluginToolInputError as
|
|
2160
|
-
pluginToolOutputSchema as
|
|
2161
|
-
subscribableResourceSchema as
|
|
2283
|
+
definePluginTool as definePluginTool9,
|
|
2284
|
+
PluginToolInputError as PluginToolInputError10,
|
|
2285
|
+
pluginToolOutputSchema as pluginToolOutputSchema9,
|
|
2286
|
+
subscribableResourceSchema as subscribableResourceSchema7
|
|
2162
2287
|
} from "@sentry/junior-plugin-api";
|
|
2163
|
-
import * as
|
|
2164
|
-
var
|
|
2165
|
-
repo:
|
|
2288
|
+
import * as z13 from "zod";
|
|
2289
|
+
var inputSchema7 = z13.object({
|
|
2290
|
+
repo: z13.string().describe('Repository in "owner/name" format.')
|
|
2166
2291
|
}).strict();
|
|
2167
|
-
var repositorySchema =
|
|
2168
|
-
default_branch:
|
|
2169
|
-
description:
|
|
2170
|
-
full_name:
|
|
2171
|
-
private:
|
|
2172
|
-
subscribable:
|
|
2173
|
-
url:
|
|
2292
|
+
var repositorySchema = z13.object({
|
|
2293
|
+
default_branch: z13.string(),
|
|
2294
|
+
description: z13.string().nullable(),
|
|
2295
|
+
full_name: z13.string(),
|
|
2296
|
+
private: z13.boolean(),
|
|
2297
|
+
subscribable: subscribableResourceSchema7.optional(),
|
|
2298
|
+
url: z13.string()
|
|
2174
2299
|
});
|
|
2175
|
-
var
|
|
2300
|
+
var outputSchema7 = pluginToolOutputSchema9.merge(
|
|
2176
2301
|
repositorySchema.extend({
|
|
2177
|
-
target:
|
|
2302
|
+
target: z13.literal("getRepository")
|
|
2178
2303
|
})
|
|
2179
2304
|
);
|
|
2180
2305
|
function createGitHubGetRepositoryTool(ctx) {
|
|
2181
|
-
return
|
|
2306
|
+
return definePluginTool9({
|
|
2182
2307
|
annotations: {
|
|
2183
2308
|
destructiveHint: false,
|
|
2184
2309
|
idempotentHint: true,
|
|
@@ -2186,8 +2311,8 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2186
2311
|
readOnlyHint: true
|
|
2187
2312
|
},
|
|
2188
2313
|
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.",
|
|
2189
|
-
inputSchema:
|
|
2190
|
-
outputSchema:
|
|
2314
|
+
inputSchema: inputSchema7,
|
|
2315
|
+
outputSchema: outputSchema7,
|
|
2191
2316
|
async execute(input) {
|
|
2192
2317
|
const repo = parseRepo(input.repo);
|
|
2193
2318
|
const response = await githubApi(ctx.egress, {
|
|
@@ -2195,16 +2320,16 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2195
2320
|
path: repoPath(repo)
|
|
2196
2321
|
});
|
|
2197
2322
|
if (!response.ok) {
|
|
2198
|
-
throw new
|
|
2323
|
+
throw new PluginToolInputError10(
|
|
2199
2324
|
`GitHub repository lookup failed with HTTP ${response.status}`
|
|
2200
2325
|
);
|
|
2201
2326
|
}
|
|
2202
|
-
const providerResult =
|
|
2203
|
-
default_branch:
|
|
2204
|
-
description:
|
|
2205
|
-
full_name:
|
|
2206
|
-
html_url:
|
|
2207
|
-
private:
|
|
2327
|
+
const providerResult = z13.object({
|
|
2328
|
+
default_branch: z13.string(),
|
|
2329
|
+
description: z13.string().nullable(),
|
|
2330
|
+
full_name: z13.string(),
|
|
2331
|
+
html_url: z13.string(),
|
|
2332
|
+
private: z13.boolean()
|
|
2208
2333
|
}).parse(response.body);
|
|
2209
2334
|
const subscribable = gitHubRepositorySubscribable({
|
|
2210
2335
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -2228,27 +2353,27 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2228
2353
|
|
|
2229
2354
|
// src/tools/get-status.ts
|
|
2230
2355
|
import {
|
|
2231
|
-
definePluginTool as
|
|
2232
|
-
pluginToolOutputSchema as
|
|
2356
|
+
definePluginTool as definePluginTool10,
|
|
2357
|
+
pluginToolOutputSchema as pluginToolOutputSchema10
|
|
2233
2358
|
} from "@sentry/junior-plugin-api";
|
|
2234
|
-
import * as
|
|
2359
|
+
import * as z15 from "zod";
|
|
2235
2360
|
|
|
2236
2361
|
// src/github-status.ts
|
|
2237
|
-
import * as
|
|
2362
|
+
import * as z14 from "zod";
|
|
2238
2363
|
var GITHUB_STATUS_INCIDENTS_URL = "https://www.githubstatus.com/api/v2/incidents.json";
|
|
2239
2364
|
var GITHUB_STATUS_TTL_MS = 60 * 1e3;
|
|
2240
2365
|
var GITHUB_STATUS_TIMEOUT_MS = 5e3;
|
|
2241
|
-
var incidentsResponseSchema =
|
|
2242
|
-
incidents:
|
|
2243
|
-
|
|
2244
|
-
components:
|
|
2245
|
-
created_at:
|
|
2246
|
-
impact:
|
|
2247
|
-
name:
|
|
2248
|
-
resolved_at:
|
|
2249
|
-
shortlink:
|
|
2250
|
-
started_at:
|
|
2251
|
-
status:
|
|
2366
|
+
var incidentsResponseSchema = z14.object({
|
|
2367
|
+
incidents: z14.array(
|
|
2368
|
+
z14.object({
|
|
2369
|
+
components: z14.array(z14.object({ name: z14.string() })).default([]),
|
|
2370
|
+
created_at: z14.string(),
|
|
2371
|
+
impact: z14.string(),
|
|
2372
|
+
name: z14.string(),
|
|
2373
|
+
resolved_at: z14.string().nullable(),
|
|
2374
|
+
shortlink: z14.string(),
|
|
2375
|
+
started_at: z14.string().nullable().optional(),
|
|
2376
|
+
status: z14.string()
|
|
2252
2377
|
})
|
|
2253
2378
|
)
|
|
2254
2379
|
});
|
|
@@ -2290,22 +2415,22 @@ async function loadGitHubStatusIncidents(cache, withinMs) {
|
|
|
2290
2415
|
|
|
2291
2416
|
// src/tools/get-status.ts
|
|
2292
2417
|
var RECENT_INCIDENT_MS = 24 * 60 * 60 * 1e3;
|
|
2293
|
-
var
|
|
2294
|
-
var incidentSchema =
|
|
2295
|
-
components:
|
|
2296
|
-
impact:
|
|
2297
|
-
name:
|
|
2298
|
-
resolved_at:
|
|
2299
|
-
started_at:
|
|
2300
|
-
status:
|
|
2301
|
-
url:
|
|
2418
|
+
var inputSchema8 = z15.object({}).strict();
|
|
2419
|
+
var incidentSchema = z15.object({
|
|
2420
|
+
components: z15.array(z15.string()),
|
|
2421
|
+
impact: z15.string(),
|
|
2422
|
+
name: z15.string(),
|
|
2423
|
+
resolved_at: z15.string().optional(),
|
|
2424
|
+
started_at: z15.string(),
|
|
2425
|
+
status: z15.string(),
|
|
2426
|
+
url: z15.string()
|
|
2302
2427
|
});
|
|
2303
|
-
var
|
|
2304
|
-
target:
|
|
2305
|
-
incidents:
|
|
2428
|
+
var outputSchema8 = pluginToolOutputSchema10.extend({
|
|
2429
|
+
target: z15.literal("getStatus"),
|
|
2430
|
+
incidents: z15.array(incidentSchema)
|
|
2306
2431
|
});
|
|
2307
2432
|
function createGitHubGetStatusTool(ctx) {
|
|
2308
|
-
return
|
|
2433
|
+
return definePluginTool10({
|
|
2309
2434
|
annotations: {
|
|
2310
2435
|
destructiveHint: false,
|
|
2311
2436
|
idempotentHint: true,
|
|
@@ -2313,8 +2438,8 @@ function createGitHubGetStatusTool(ctx) {
|
|
|
2313
2438
|
readOnlyHint: true
|
|
2314
2439
|
},
|
|
2315
2440
|
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.",
|
|
2316
|
-
inputSchema:
|
|
2317
|
-
outputSchema:
|
|
2441
|
+
inputSchema: inputSchema8,
|
|
2442
|
+
outputSchema: outputSchema8,
|
|
2318
2443
|
async execute() {
|
|
2319
2444
|
const incidents = await loadGitHubStatusIncidents(
|
|
2320
2445
|
ctx.cache,
|
|
@@ -2337,61 +2462,84 @@ function createGitHubGetStatusTool(ctx) {
|
|
|
2337
2462
|
|
|
2338
2463
|
// src/tools/update-issue.ts
|
|
2339
2464
|
import {
|
|
2340
|
-
definePluginTool as
|
|
2341
|
-
PluginToolInputError as
|
|
2342
|
-
pluginToolOutputSchema as
|
|
2343
|
-
subscribableResourceSchema as
|
|
2465
|
+
definePluginTool as definePluginTool11,
|
|
2466
|
+
PluginToolInputError as PluginToolInputError11,
|
|
2467
|
+
pluginToolOutputSchema as pluginToolOutputSchema11,
|
|
2468
|
+
subscribableResourceSchema as subscribableResourceSchema8
|
|
2344
2469
|
} from "@sentry/junior-plugin-api";
|
|
2345
|
-
import * as
|
|
2346
|
-
var
|
|
2347
|
-
repo:
|
|
2348
|
-
number:
|
|
2349
|
-
title:
|
|
2350
|
-
body:
|
|
2470
|
+
import * as z16 from "zod";
|
|
2471
|
+
var inputSchema9 = z16.object({
|
|
2472
|
+
repo: z16.string().describe('Repository in "owner/name" format.'),
|
|
2473
|
+
number: z16.number().int().positive().describe("Issue number."),
|
|
2474
|
+
title: z16.string().trim().min(1).optional().describe("Replacement issue title."),
|
|
2475
|
+
body: z16.string().optional().describe(
|
|
2351
2476
|
"Replacement issue body. The runtime appends requester attribution and the conversation footer."
|
|
2352
2477
|
),
|
|
2353
|
-
state:
|
|
2478
|
+
state: z16.enum(["open", "closed"]).optional().describe("Replacement issue state."),
|
|
2479
|
+
assign_requester: z16.boolean().optional().describe(
|
|
2480
|
+
"Set true to add the requester's linked GitHub account as an assignee. Other assignees stay."
|
|
2481
|
+
)
|
|
2354
2482
|
}).strict().refine(
|
|
2355
|
-
({ title, body, state }) => title !== void 0 || body !== void 0 || state !== void 0,
|
|
2483
|
+
({ title, body, state, assign_requester }) => title !== void 0 || body !== void 0 || state !== void 0 || assign_requester === true,
|
|
2356
2484
|
{ message: "At least one issue field must be provided." }
|
|
2357
2485
|
);
|
|
2358
|
-
var
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2486
|
+
var issueSchema2 = z16.object({
|
|
2487
|
+
assignees: z16.array(z16.string()),
|
|
2488
|
+
body: z16.string().nullable(),
|
|
2489
|
+
number: z16.number(),
|
|
2490
|
+
state: z16.string(),
|
|
2491
|
+
subscribable: subscribableResourceSchema8.optional(),
|
|
2492
|
+
title: z16.string(),
|
|
2493
|
+
url: z16.string()
|
|
2365
2494
|
});
|
|
2366
|
-
var
|
|
2367
|
-
|
|
2368
|
-
target:
|
|
2495
|
+
var outputSchema9 = pluginToolOutputSchema11.merge(
|
|
2496
|
+
issueSchema2.extend({
|
|
2497
|
+
target: z16.literal("updateIssue")
|
|
2369
2498
|
})
|
|
2370
2499
|
);
|
|
2500
|
+
var providerIssueSchema2 = z16.object({
|
|
2501
|
+
assignees: z16.array(z16.object({ login: z16.string() })).nullish().transform((assignees) => assignees?.map(({ login }) => login) ?? []),
|
|
2502
|
+
body: z16.string().nullable().optional().default(null),
|
|
2503
|
+
html_url: z16.string(),
|
|
2504
|
+
number: z16.number(),
|
|
2505
|
+
state: z16.string(),
|
|
2506
|
+
title: z16.string()
|
|
2507
|
+
});
|
|
2371
2508
|
function nonEmptyString4(value, name) {
|
|
2372
|
-
if (!value?.trim()) throw new
|
|
2509
|
+
if (!value?.trim()) throw new PluginToolInputError11(`${name} is required`);
|
|
2373
2510
|
return value.trim();
|
|
2374
2511
|
}
|
|
2375
2512
|
function createGitHubUpdateIssueTool(ctx) {
|
|
2376
|
-
return
|
|
2513
|
+
return definePluginTool11({
|
|
2377
2514
|
annotations: {
|
|
2378
2515
|
destructiveHint: true,
|
|
2379
2516
|
idempotentHint: true,
|
|
2380
2517
|
openWorldHint: true,
|
|
2381
2518
|
readOnlyHint: false
|
|
2382
2519
|
},
|
|
2383
|
-
description: "Update an existing GitHub issue's title, body, or open/closed state. Use this instead of raw GitHub API calls when changing issue metadata.",
|
|
2384
|
-
inputSchema:
|
|
2385
|
-
outputSchema:
|
|
2520
|
+
description: "Update an existing GitHub issue's title, body, or open/closed state, or assign it to the requester. Use this instead of raw GitHub API calls when changing issue metadata.",
|
|
2521
|
+
inputSchema: inputSchema9,
|
|
2522
|
+
outputSchema: outputSchema9,
|
|
2386
2523
|
async execute(input) {
|
|
2387
|
-
const parsedInput =
|
|
2524
|
+
const parsedInput = inputSchema9.safeParse(input);
|
|
2388
2525
|
if (!parsedInput.success) {
|
|
2389
|
-
throw new
|
|
2526
|
+
throw new PluginToolInputError11("Invalid GitHub updateIssue input.", {
|
|
2390
2527
|
cause: parsedInput.error
|
|
2391
2528
|
});
|
|
2392
2529
|
}
|
|
2393
2530
|
const update = parsedInput.data;
|
|
2394
2531
|
const repo = parseRepo(update.repo);
|
|
2532
|
+
const requester = update.body !== void 0 || update.assign_requester ? await resolveGitHubRequester(ctx) : void 0;
|
|
2533
|
+
const assignee = update.assign_requester ? linkedGitHubLogin(requester?.user) : void 0;
|
|
2534
|
+
if (update.assign_requester && !assignee) {
|
|
2535
|
+
throw new PluginToolInputError11(
|
|
2536
|
+
"The requester has no linked GitHub account, so Junior cannot assign the issue to them."
|
|
2537
|
+
);
|
|
2538
|
+
}
|
|
2539
|
+
const currentBody = update.body !== void 0 ? await readGitHubBody(ctx.egress, {
|
|
2540
|
+
operation: "github.issue.get",
|
|
2541
|
+
path: `${repoPath(repo)}/issues/${update.number}`
|
|
2542
|
+
}) : void 0;
|
|
2395
2543
|
const payload = {
|
|
2396
2544
|
...update.title !== void 0 ? { title: update.title } : void 0,
|
|
2397
2545
|
...update.body !== void 0 ? {
|
|
@@ -2399,7 +2547,8 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2399
2547
|
appendGitHubRequesterAttribution(
|
|
2400
2548
|
update.body,
|
|
2401
2549
|
ctx,
|
|
2402
|
-
|
|
2550
|
+
requester,
|
|
2551
|
+
currentBody
|
|
2403
2552
|
),
|
|
2404
2553
|
nonEmptyString4(ctx.conversationId, "conversationId"),
|
|
2405
2554
|
ctx.slack?.conversationLink?.url
|
|
@@ -2407,25 +2556,45 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2407
2556
|
} : void 0,
|
|
2408
2557
|
...update.state !== void 0 ? { state: update.state } : void 0
|
|
2409
2558
|
};
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2559
|
+
let parsed;
|
|
2560
|
+
if (Object.keys(payload).length > 0) {
|
|
2561
|
+
const response = await githubApi(ctx.egress, {
|
|
2562
|
+
operation: "github.issue.update",
|
|
2563
|
+
method: "PATCH",
|
|
2564
|
+
path: `${repoPath(repo)}/issues/${update.number}`,
|
|
2565
|
+
body: payload
|
|
2566
|
+
});
|
|
2567
|
+
parsed = response.body;
|
|
2568
|
+
if (!response.ok) {
|
|
2569
|
+
throw new Error(
|
|
2570
|
+
`GitHub issue update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`
|
|
2571
|
+
);
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
if (assignee) {
|
|
2575
|
+
const response = await githubApi(ctx.egress, {
|
|
2576
|
+
operation: "github.issue.assign",
|
|
2577
|
+
method: "POST",
|
|
2578
|
+
path: `${repoPath(repo)}/issues/${update.number}/assignees`,
|
|
2579
|
+
body: { assignees: [assignee] }
|
|
2580
|
+
});
|
|
2581
|
+
parsed = response.body;
|
|
2582
|
+
if (!response.ok) {
|
|
2583
|
+
const message = `GitHub issue assignment failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`;
|
|
2584
|
+
if (response.status === 404 || response.status === 422) {
|
|
2585
|
+
throw new PluginToolInputError11(message);
|
|
2586
|
+
}
|
|
2587
|
+
throw new Error(message);
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
const providerResult = providerIssueSchema2.parse(parsed);
|
|
2591
|
+
if (assignee && !providerResult.assignees.some(
|
|
2592
|
+
(login) => login.toLowerCase() === assignee.toLowerCase()
|
|
2593
|
+
)) {
|
|
2594
|
+
throw new PluginToolInputError11(
|
|
2595
|
+
`GitHub did not assign @${assignee} to the issue. They may not have access to ${repo.ref}.`
|
|
2420
2596
|
);
|
|
2421
2597
|
}
|
|
2422
|
-
const providerResult = z14.object({
|
|
2423
|
-
body: z14.string().nullable().optional().default(null),
|
|
2424
|
-
html_url: z14.string(),
|
|
2425
|
-
number: z14.number(),
|
|
2426
|
-
state: z14.string(),
|
|
2427
|
-
title: z14.string()
|
|
2428
|
-
}).parse(parsed);
|
|
2429
2598
|
const subscribable = gitHubIssueSubscribable({
|
|
2430
2599
|
canSubscribe: ctx.events.canSubscribe,
|
|
2431
2600
|
number: providerResult.number,
|
|
@@ -2444,6 +2613,7 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2444
2613
|
})
|
|
2445
2614
|
],
|
|
2446
2615
|
target: "updateIssue",
|
|
2616
|
+
assignees: providerResult.assignees,
|
|
2447
2617
|
body: providerResult.body,
|
|
2448
2618
|
number: providerResult.number,
|
|
2449
2619
|
state: providerResult.state,
|
|
@@ -2457,22 +2627,22 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2457
2627
|
|
|
2458
2628
|
// src/tools/update-pull-request.ts
|
|
2459
2629
|
import {
|
|
2460
|
-
definePluginTool as
|
|
2461
|
-
PluginToolInputError as
|
|
2462
|
-
pluginToolOutputSchema as
|
|
2630
|
+
definePluginTool as definePluginTool12,
|
|
2631
|
+
PluginToolInputError as PluginToolInputError12,
|
|
2632
|
+
pluginToolOutputSchema as pluginToolOutputSchema12
|
|
2463
2633
|
} from "@sentry/junior-plugin-api";
|
|
2464
|
-
import * as
|
|
2465
|
-
import { subscribableResourceSchema as
|
|
2466
|
-
var
|
|
2467
|
-
repo:
|
|
2468
|
-
number:
|
|
2469
|
-
title:
|
|
2470
|
-
body:
|
|
2634
|
+
import * as z17 from "zod";
|
|
2635
|
+
import { subscribableResourceSchema as subscribableResourceSchema9 } from "@sentry/junior-plugin-api";
|
|
2636
|
+
var inputSchema10 = z17.object({
|
|
2637
|
+
repo: z17.string().describe('Repository in "owner/name" format.'),
|
|
2638
|
+
number: z17.number().int().positive().describe("Pull request number."),
|
|
2639
|
+
title: z17.string().trim().min(1).optional().describe("Replacement pull request title."),
|
|
2640
|
+
body: z17.string().optional().describe(
|
|
2471
2641
|
"Replacement pull request body. The runtime appends requester attribution and the conversation footer."
|
|
2472
2642
|
),
|
|
2473
|
-
base:
|
|
2474
|
-
state:
|
|
2475
|
-
draft:
|
|
2643
|
+
base: z17.string().trim().min(1).optional().describe("Replacement base branch."),
|
|
2644
|
+
state: z17.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
|
|
2645
|
+
draft: z17.boolean().optional().describe(
|
|
2476
2646
|
"Set false to mark a draft pull request ready for review, or true to convert it back to a draft."
|
|
2477
2647
|
)
|
|
2478
2648
|
}).strict().refine(
|
|
@@ -2487,29 +2657,29 @@ var CONVERT_TO_DRAFT = {
|
|
|
2487
2657
|
operationName: "ConvertPullRequestToDraft",
|
|
2488
2658
|
query: "mutation ConvertPullRequestToDraft($id: ID!) { result: convertPullRequestToDraft(input: {pullRequestId: $id}) { pullRequest { isDraft } } }"
|
|
2489
2659
|
};
|
|
2490
|
-
var draftMutationResponseSchema =
|
|
2491
|
-
data:
|
|
2492
|
-
result:
|
|
2660
|
+
var draftMutationResponseSchema = z17.object({
|
|
2661
|
+
data: z17.object({
|
|
2662
|
+
result: z17.object({ pullRequest: z17.object({ isDraft: z17.boolean() }) })
|
|
2493
2663
|
})
|
|
2494
2664
|
});
|
|
2495
|
-
var pullRequestSchema2 =
|
|
2496
|
-
base:
|
|
2497
|
-
body:
|
|
2498
|
-
draft:
|
|
2499
|
-
number:
|
|
2500
|
-
state:
|
|
2501
|
-
subscribable:
|
|
2502
|
-
title:
|
|
2503
|
-
url:
|
|
2665
|
+
var pullRequestSchema2 = z17.object({
|
|
2666
|
+
base: z17.string(),
|
|
2667
|
+
body: z17.string().nullable(),
|
|
2668
|
+
draft: z17.boolean(),
|
|
2669
|
+
number: z17.number(),
|
|
2670
|
+
state: z17.string(),
|
|
2671
|
+
subscribable: subscribableResourceSchema9.optional(),
|
|
2672
|
+
title: z17.string(),
|
|
2673
|
+
url: z17.string()
|
|
2504
2674
|
});
|
|
2505
|
-
var
|
|
2675
|
+
var outputSchema10 = pluginToolOutputSchema12.merge(
|
|
2506
2676
|
pullRequestSchema2.extend({
|
|
2507
|
-
target:
|
|
2677
|
+
target: z17.literal("updatePullRequest")
|
|
2508
2678
|
})
|
|
2509
2679
|
);
|
|
2510
2680
|
function nonEmptyString5(value, name) {
|
|
2511
2681
|
if (!value?.trim()) {
|
|
2512
|
-
throw new
|
|
2682
|
+
throw new PluginToolInputError12(`${name} is required`);
|
|
2513
2683
|
}
|
|
2514
2684
|
return value.trim();
|
|
2515
2685
|
}
|
|
@@ -2535,7 +2705,7 @@ async function setPullRequestDraft(input) {
|
|
|
2535
2705
|
return isDraft;
|
|
2536
2706
|
}
|
|
2537
2707
|
function createGitHubUpdatePullRequestTool(ctx) {
|
|
2538
|
-
return
|
|
2708
|
+
return definePluginTool12({
|
|
2539
2709
|
annotations: {
|
|
2540
2710
|
destructiveHint: true,
|
|
2541
2711
|
idempotentHint: true,
|
|
@@ -2543,12 +2713,12 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2543
2713
|
readOnlyHint: false
|
|
2544
2714
|
},
|
|
2545
2715
|
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.",
|
|
2546
|
-
inputSchema:
|
|
2547
|
-
outputSchema:
|
|
2716
|
+
inputSchema: inputSchema10,
|
|
2717
|
+
outputSchema: outputSchema10,
|
|
2548
2718
|
async execute(input) {
|
|
2549
|
-
const parsedInput =
|
|
2719
|
+
const parsedInput = inputSchema10.safeParse(input);
|
|
2550
2720
|
if (!parsedInput.success) {
|
|
2551
|
-
throw new
|
|
2721
|
+
throw new PluginToolInputError12(
|
|
2552
2722
|
"Invalid GitHub updatePullRequest input.",
|
|
2553
2723
|
{ cause: parsedInput.error }
|
|
2554
2724
|
);
|
|
@@ -2556,11 +2726,20 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2556
2726
|
const update = parsedInput.data;
|
|
2557
2727
|
const repo = parseRepo(update.repo);
|
|
2558
2728
|
const requester = await resolveGitHubRequester(ctx);
|
|
2729
|
+
const currentBody = update.body !== void 0 ? await readGitHubBody(ctx.egress, {
|
|
2730
|
+
operation: "github.pull.get",
|
|
2731
|
+
path: `${repoPath(repo)}/pulls/${update.number}`
|
|
2732
|
+
}) : void 0;
|
|
2559
2733
|
const payload = {
|
|
2560
2734
|
...update.title !== void 0 ? { title: update.title } : void 0,
|
|
2561
2735
|
...update.body !== void 0 ? {
|
|
2562
2736
|
body: appendGitHubFooter(
|
|
2563
|
-
appendGitHubRequesterAttribution(
|
|
2737
|
+
appendGitHubRequesterAttribution(
|
|
2738
|
+
update.body,
|
|
2739
|
+
ctx,
|
|
2740
|
+
requester,
|
|
2741
|
+
currentBody
|
|
2742
|
+
),
|
|
2564
2743
|
nonEmptyString5(ctx.conversationId, "conversationId"),
|
|
2565
2744
|
ctx.slack?.conversationLink?.url
|
|
2566
2745
|
)
|
|
@@ -2580,16 +2759,16 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2580
2759
|
`GitHub pull request update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`
|
|
2581
2760
|
);
|
|
2582
2761
|
}
|
|
2583
|
-
const providerResult =
|
|
2584
|
-
base:
|
|
2585
|
-
body:
|
|
2586
|
-
draft:
|
|
2587
|
-
html_url:
|
|
2588
|
-
merged:
|
|
2589
|
-
node_id:
|
|
2590
|
-
number:
|
|
2591
|
-
state:
|
|
2592
|
-
title:
|
|
2762
|
+
const providerResult = z17.object({
|
|
2763
|
+
base: z17.object({ ref: z17.string() }),
|
|
2764
|
+
body: z17.string().nullable().optional().default(null),
|
|
2765
|
+
draft: z17.boolean(),
|
|
2766
|
+
html_url: z17.string(),
|
|
2767
|
+
merged: z17.boolean(),
|
|
2768
|
+
node_id: z17.string().optional(),
|
|
2769
|
+
number: z17.number(),
|
|
2770
|
+
state: z17.string(),
|
|
2771
|
+
title: z17.string()
|
|
2593
2772
|
}).parse(parsed);
|
|
2594
2773
|
if (update.draft !== void 0 && update.draft !== providerResult.draft) {
|
|
2595
2774
|
if (!providerResult.node_id) {
|
|
@@ -2650,11 +2829,11 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2650
2829
|
|
|
2651
2830
|
// src/tools/update-pull-request-feedback.ts
|
|
2652
2831
|
import {
|
|
2653
|
-
definePluginTool as
|
|
2654
|
-
PluginToolInputError as
|
|
2655
|
-
pluginToolOutputSchema as
|
|
2832
|
+
definePluginTool as definePluginTool13,
|
|
2833
|
+
PluginToolInputError as PluginToolInputError13,
|
|
2834
|
+
pluginToolOutputSchema as pluginToolOutputSchema13
|
|
2656
2835
|
} from "@sentry/junior-plugin-api";
|
|
2657
|
-
import * as
|
|
2836
|
+
import * as z18 from "zod";
|
|
2658
2837
|
var STATUS_TO_REACTION_CONTENT = {
|
|
2659
2838
|
reviewing: "eyes",
|
|
2660
2839
|
addressed: "+1",
|
|
@@ -2663,24 +2842,24 @@ var STATUS_TO_REACTION_CONTENT = {
|
|
|
2663
2842
|
var FEEDBACK_REACTION_CONTENTS = new Set(
|
|
2664
2843
|
Object.values(STATUS_TO_REACTION_CONTENT)
|
|
2665
2844
|
);
|
|
2666
|
-
var
|
|
2667
|
-
repo:
|
|
2668
|
-
comment_kind:
|
|
2845
|
+
var inputSchema11 = z18.object({
|
|
2846
|
+
repo: z18.string().describe('Repository in "owner/name" format.'),
|
|
2847
|
+
comment_kind: z18.enum(["conversation", "review"]).describe(
|
|
2669
2848
|
'Comment kind: "conversation" for a pull request conversation comment, "review" for an inline review comment.'
|
|
2670
2849
|
),
|
|
2671
|
-
comment_id:
|
|
2850
|
+
comment_id: z18.number().int().positive().describe(
|
|
2672
2851
|
"GitHub comment id (conversation comment id or inline review comment id)."
|
|
2673
2852
|
),
|
|
2674
|
-
status:
|
|
2853
|
+
status: z18.enum(["addressed", "declined"]).describe(
|
|
2675
2854
|
"Feedback outcome. Maps to a reaction: addressed -> +1, declined -> -1."
|
|
2676
2855
|
)
|
|
2677
2856
|
}).strict();
|
|
2678
|
-
var
|
|
2679
|
-
target:
|
|
2680
|
-
repo:
|
|
2681
|
-
comment_id:
|
|
2682
|
-
status:
|
|
2683
|
-
reaction_id:
|
|
2857
|
+
var outputSchema11 = pluginToolOutputSchema13.extend({
|
|
2858
|
+
target: z18.literal("updatePullRequestFeedback"),
|
|
2859
|
+
repo: z18.string(),
|
|
2860
|
+
comment_id: z18.number(),
|
|
2861
|
+
status: z18.enum(["addressed", "declined"]),
|
|
2862
|
+
reaction_id: z18.number()
|
|
2684
2863
|
});
|
|
2685
2864
|
function pullRequestCommentPath(input) {
|
|
2686
2865
|
const segment = input.commentKind === "conversation" ? "issues" : "pulls";
|
|
@@ -2692,10 +2871,10 @@ function pullRequestCommentReactionsPath(input) {
|
|
|
2692
2871
|
function pullRequestFeedbackReactionContent(status) {
|
|
2693
2872
|
return STATUS_TO_REACTION_CONTENT[status];
|
|
2694
2873
|
}
|
|
2695
|
-
var reactionSchema =
|
|
2696
|
-
id:
|
|
2697
|
-
content:
|
|
2698
|
-
user:
|
|
2874
|
+
var reactionSchema = z18.object({
|
|
2875
|
+
id: z18.number(),
|
|
2876
|
+
content: z18.string(),
|
|
2877
|
+
user: z18.object({ id: z18.number() }).nullable()
|
|
2699
2878
|
});
|
|
2700
2879
|
async function assertBotAuthoredPullRequest(egress, input) {
|
|
2701
2880
|
const commentResponse = await githubApi(egress, {
|
|
@@ -2705,21 +2884,21 @@ async function assertBotAuthoredPullRequest(egress, input) {
|
|
|
2705
2884
|
const commentPayload = commentResponse.body;
|
|
2706
2885
|
if (!commentResponse.ok) {
|
|
2707
2886
|
const message = `GitHub comment lookup failed with HTTP ${commentResponse.status}: ${githubErrorMessage(commentPayload)}`;
|
|
2708
|
-
if (commentResponse.status === 404) throw new
|
|
2887
|
+
if (commentResponse.status === 404) throw new PluginToolInputError13(message);
|
|
2709
2888
|
throw new Error(message);
|
|
2710
2889
|
}
|
|
2711
|
-
const comment =
|
|
2712
|
-
issue_url:
|
|
2713
|
-
pull_request_url:
|
|
2890
|
+
const comment = z18.object({
|
|
2891
|
+
issue_url: z18.string().optional(),
|
|
2892
|
+
pull_request_url: z18.string().optional()
|
|
2714
2893
|
}).safeParse(commentPayload);
|
|
2715
2894
|
const parentUrl = comment.success ? input.commentKind === "conversation" ? comment.data.issue_url : comment.data.pull_request_url : void 0;
|
|
2716
|
-
const
|
|
2717
|
-
if (!
|
|
2895
|
+
const number23 = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
|
|
2896
|
+
if (!number23) {
|
|
2718
2897
|
throw new Error("GitHub comment did not name its issue or pull request.");
|
|
2719
2898
|
}
|
|
2720
2899
|
const pullResponse = await githubApi(egress, {
|
|
2721
2900
|
operation: "github.pull.get",
|
|
2722
|
-
path: `${repoPath(input)}/pulls/${
|
|
2901
|
+
path: `${repoPath(input)}/pulls/${number23}`
|
|
2723
2902
|
});
|
|
2724
2903
|
const pullPayload = pullResponse.body;
|
|
2725
2904
|
if (!pullResponse.ok && pullResponse.status !== 404) {
|
|
@@ -2727,15 +2906,15 @@ async function assertBotAuthoredPullRequest(egress, input) {
|
|
|
2727
2906
|
`GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${githubErrorMessage(pullPayload)}`
|
|
2728
2907
|
);
|
|
2729
2908
|
}
|
|
2730
|
-
const pull =
|
|
2909
|
+
const pull = z18.object({ user: z18.object({ id: z18.number() }).nullable() }).safeParse(pullPayload);
|
|
2731
2910
|
if (!pullResponse.ok || !pull.success || pull.data.user?.id !== input.botUserId) {
|
|
2732
|
-
throw new
|
|
2911
|
+
throw new PluginToolInputError13(
|
|
2733
2912
|
"This bot can only set feedback status on comments on pull requests it authored."
|
|
2734
2913
|
);
|
|
2735
2914
|
}
|
|
2736
2915
|
}
|
|
2737
2916
|
function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
2738
|
-
return
|
|
2917
|
+
return definePluginTool13({
|
|
2739
2918
|
// No action review: the tool checks in code that the bot authored the pull
|
|
2740
2919
|
// request, and it changes only the bot's own reaction, which is reversible.
|
|
2741
2920
|
approvalMode: "approve",
|
|
@@ -2747,12 +2926,12 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2747
2926
|
},
|
|
2748
2927
|
description: "Set your outcome reaction on GitHub pull request feedback: addressed (+1) or declined (-1). Use the comment_id and comment_kind from the event after acting on the feedback. Replaces only your prior status reaction on that comment. Only works on pull requests the bot authored.",
|
|
2749
2928
|
exposure: "direct",
|
|
2750
|
-
inputSchema:
|
|
2751
|
-
outputSchema:
|
|
2929
|
+
inputSchema: inputSchema11,
|
|
2930
|
+
outputSchema: outputSchema11,
|
|
2752
2931
|
async execute(input) {
|
|
2753
|
-
const parsedInput =
|
|
2932
|
+
const parsedInput = inputSchema11.safeParse(input);
|
|
2754
2933
|
if (!parsedInput.success) {
|
|
2755
|
-
throw new
|
|
2934
|
+
throw new PluginToolInputError13(
|
|
2756
2935
|
"Invalid GitHub updatePullRequestFeedback input.",
|
|
2757
2936
|
{ cause: parsedInput.error }
|
|
2758
2937
|
);
|
|
@@ -2791,7 +2970,7 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2791
2970
|
`GitHub reaction lookup failed with HTTP ${listResponse.status}: ${githubErrorMessage(listPayload)}`
|
|
2792
2971
|
);
|
|
2793
2972
|
}
|
|
2794
|
-
const botReactions =
|
|
2973
|
+
const botReactions = z18.array(reactionSchema).parse(listPayload).filter(
|
|
2795
2974
|
(reaction) => reaction.user?.id === botUserId && FEEDBACK_REACTION_CONTENTS.has(reaction.content)
|
|
2796
2975
|
);
|
|
2797
2976
|
const existing = botReactions.find(
|
|
@@ -2845,28 +3024,28 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2845
3024
|
|
|
2846
3025
|
// src/tools/resolve-pull-request-review-thread.ts
|
|
2847
3026
|
import {
|
|
2848
|
-
definePluginTool as
|
|
2849
|
-
PluginToolInputError as
|
|
2850
|
-
pluginToolOutputSchema as
|
|
3027
|
+
definePluginTool as definePluginTool14,
|
|
3028
|
+
PluginToolInputError as PluginToolInputError14,
|
|
3029
|
+
pluginToolOutputSchema as pluginToolOutputSchema14
|
|
2851
3030
|
} from "@sentry/junior-plugin-api";
|
|
2852
|
-
import * as
|
|
2853
|
-
var
|
|
2854
|
-
repo:
|
|
3031
|
+
import * as z19 from "zod";
|
|
3032
|
+
var inputSchema12 = z19.object({
|
|
3033
|
+
repo: z19.string().describe(
|
|
2855
3034
|
'Repository in "owner/name" format. Required because GraphQL has no repo path.'
|
|
2856
3035
|
),
|
|
2857
|
-
thread_id:
|
|
3036
|
+
thread_id: z19.string().trim().min(1).describe(
|
|
2858
3037
|
"GitHub pull request review thread node ID (the `threadId` / `id` variable used by `gh api graphql` resolveReviewThread)."
|
|
2859
3038
|
)
|
|
2860
3039
|
}).strict();
|
|
2861
|
-
var
|
|
2862
|
-
target:
|
|
2863
|
-
repo:
|
|
2864
|
-
number:
|
|
2865
|
-
thread_id:
|
|
2866
|
-
resolved:
|
|
3040
|
+
var outputSchema12 = pluginToolOutputSchema14.extend({
|
|
3041
|
+
target: z19.literal("resolvePullRequestReviewThread"),
|
|
3042
|
+
repo: z19.string(),
|
|
3043
|
+
number: z19.number(),
|
|
3044
|
+
thread_id: z19.string(),
|
|
3045
|
+
resolved: z19.boolean()
|
|
2867
3046
|
});
|
|
2868
3047
|
function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
2869
|
-
return
|
|
3048
|
+
return definePluginTool14({
|
|
2870
3049
|
// No action review: the tool checks in code that the bot authored the pull
|
|
2871
3050
|
// request, and it changes only the thread's resolved state, which is
|
|
2872
3051
|
// reversible.
|
|
@@ -2879,12 +3058,12 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
2879
3058
|
},
|
|
2880
3059
|
description: "Resolve a GitHub pull request review thread after acting on its feedback. Only works on pull requests the bot authored.",
|
|
2881
3060
|
exposure: "direct",
|
|
2882
|
-
inputSchema:
|
|
2883
|
-
outputSchema:
|
|
3061
|
+
inputSchema: inputSchema12,
|
|
3062
|
+
outputSchema: outputSchema12,
|
|
2884
3063
|
async execute(input) {
|
|
2885
|
-
const parsedInput =
|
|
3064
|
+
const parsedInput = inputSchema12.safeParse(input);
|
|
2886
3065
|
if (!parsedInput.success) {
|
|
2887
|
-
throw new
|
|
3066
|
+
throw new PluginToolInputError14(
|
|
2888
3067
|
"Invalid GitHub resolvePullRequestReviewThread input.",
|
|
2889
3068
|
{ cause: parsedInput.error }
|
|
2890
3069
|
);
|
|
@@ -2923,31 +3102,31 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
2923
3102
|
`GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubErrorMessage(lookupPayload)}`
|
|
2924
3103
|
);
|
|
2925
3104
|
}
|
|
2926
|
-
const threadNodeSchema =
|
|
2927
|
-
id:
|
|
2928
|
-
isResolved:
|
|
2929
|
-
pullRequest:
|
|
2930
|
-
author:
|
|
2931
|
-
number:
|
|
2932
|
-
repository:
|
|
3105
|
+
const threadNodeSchema = z19.object({
|
|
3106
|
+
id: z19.string(),
|
|
3107
|
+
isResolved: z19.boolean(),
|
|
3108
|
+
pullRequest: z19.object({
|
|
3109
|
+
author: z19.object({ databaseId: z19.number().optional() }).passthrough().nullable(),
|
|
3110
|
+
number: z19.number(),
|
|
3111
|
+
repository: z19.object({ nameWithOwner: z19.string() }).passthrough()
|
|
2933
3112
|
}).passthrough()
|
|
2934
3113
|
}).passthrough();
|
|
2935
|
-
const lookupResultSchema =
|
|
2936
|
-
data:
|
|
2937
|
-
node:
|
|
3114
|
+
const lookupResultSchema = z19.object({
|
|
3115
|
+
data: z19.object({
|
|
3116
|
+
node: z19.unknown().nullable().optional()
|
|
2938
3117
|
}).passthrough()
|
|
2939
3118
|
}).passthrough();
|
|
2940
3119
|
const lookupResult = lookupResultSchema.safeParse(lookupPayload);
|
|
2941
3120
|
const rawNode = lookupResult.success ? lookupResult.data.data.node : void 0;
|
|
2942
3121
|
const parsedNode = rawNode == null ? void 0 : threadNodeSchema.safeParse(rawNode);
|
|
2943
3122
|
if (!parsedNode?.success) {
|
|
2944
|
-
throw new
|
|
3123
|
+
throw new PluginToolInputError14("GitHub review thread was not found.");
|
|
2945
3124
|
}
|
|
2946
3125
|
const thread = parsedNode.data;
|
|
2947
3126
|
const pullRequest = thread.pullRequest;
|
|
2948
3127
|
const ownsPullRequest = pullRequest.repository.nameWithOwner.toLowerCase() === repo.ref.toLowerCase() && pullRequest.author?.databaseId === botUserId;
|
|
2949
3128
|
if (!ownsPullRequest) {
|
|
2950
|
-
throw new
|
|
3129
|
+
throw new PluginToolInputError14(
|
|
2951
3130
|
"This bot can only resolve review threads on pull requests it authored."
|
|
2952
3131
|
);
|
|
2953
3132
|
}
|
|
@@ -2981,10 +3160,10 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
2981
3160
|
`GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubErrorMessage(resolvePayload)}`
|
|
2982
3161
|
);
|
|
2983
3162
|
}
|
|
2984
|
-
const resolveResultSchema =
|
|
2985
|
-
data:
|
|
2986
|
-
resolveReviewThread:
|
|
2987
|
-
thread:
|
|
3163
|
+
const resolveResultSchema = z19.object({
|
|
3164
|
+
data: z19.object({
|
|
3165
|
+
resolveReviewThread: z19.object({
|
|
3166
|
+
thread: z19.object({ id: z19.string(), isResolved: z19.boolean() }).passthrough()
|
|
2988
3167
|
}).passthrough()
|
|
2989
3168
|
}).passthrough()
|
|
2990
3169
|
}).passthrough();
|
|
@@ -3012,46 +3191,46 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3012
3191
|
|
|
3013
3192
|
// src/tools/submit-pull-request-review.ts
|
|
3014
3193
|
import {
|
|
3015
|
-
definePluginTool as
|
|
3016
|
-
PluginToolInputError as
|
|
3017
|
-
pluginToolOutputSchema as
|
|
3194
|
+
definePluginTool as definePluginTool15,
|
|
3195
|
+
PluginToolInputError as PluginToolInputError15,
|
|
3196
|
+
pluginToolOutputSchema as pluginToolOutputSchema15
|
|
3018
3197
|
} from "@sentry/junior-plugin-api";
|
|
3019
|
-
import * as
|
|
3020
|
-
var reviewCommentSchema =
|
|
3021
|
-
path:
|
|
3022
|
-
body:
|
|
3023
|
-
line:
|
|
3024
|
-
side:
|
|
3025
|
-
start_line:
|
|
3026
|
-
start_side:
|
|
3198
|
+
import * as z20 from "zod";
|
|
3199
|
+
var reviewCommentSchema = z20.object({
|
|
3200
|
+
path: z20.string().trim().min(1).describe("File path in the pull request."),
|
|
3201
|
+
body: z20.string().trim().min(1).describe("Inline review comment."),
|
|
3202
|
+
line: z20.number().int().positive().describe("Line in the pull request diff."),
|
|
3203
|
+
side: z20.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
|
|
3204
|
+
start_line: z20.number().int().positive().optional().describe("First line of a multi-line comment."),
|
|
3205
|
+
start_side: z20.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
|
|
3027
3206
|
}).strict().refine(
|
|
3028
3207
|
({ start_line, start_side }) => start_line === void 0 === (start_side === void 0),
|
|
3029
3208
|
{ message: "start_line and start_side must be provided together." }
|
|
3030
3209
|
);
|
|
3031
|
-
var
|
|
3032
|
-
repo:
|
|
3033
|
-
number:
|
|
3034
|
-
event:
|
|
3035
|
-
body:
|
|
3036
|
-
comments:
|
|
3210
|
+
var inputSchema13 = z20.object({
|
|
3211
|
+
repo: z20.string().describe('Repository in "owner/name" format.'),
|
|
3212
|
+
number: z20.number().int().positive().describe("Pull request number."),
|
|
3213
|
+
event: z20.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
|
|
3214
|
+
body: z20.string().trim().min(1).describe("Review summary."),
|
|
3215
|
+
comments: z20.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
|
|
3037
3216
|
}).strict();
|
|
3038
|
-
var
|
|
3039
|
-
target:
|
|
3040
|
-
repo:
|
|
3041
|
-
number:
|
|
3042
|
-
review_id:
|
|
3043
|
-
state:
|
|
3044
|
-
url:
|
|
3217
|
+
var outputSchema13 = pluginToolOutputSchema15.extend({
|
|
3218
|
+
target: z20.literal("submitPullRequestReview"),
|
|
3219
|
+
repo: z20.string(),
|
|
3220
|
+
number: z20.number(),
|
|
3221
|
+
review_id: z20.number(),
|
|
3222
|
+
state: z20.string(),
|
|
3223
|
+
url: z20.string()
|
|
3045
3224
|
});
|
|
3046
3225
|
function throwReviewError(status, body) {
|
|
3047
3226
|
const message = `GitHub pull request review failed with HTTP ${status}: ${githubErrorMessage(body)}`;
|
|
3048
3227
|
if (status === 404 || status === 422) {
|
|
3049
|
-
throw new
|
|
3228
|
+
throw new PluginToolInputError15(message);
|
|
3050
3229
|
}
|
|
3051
3230
|
throw new Error(message);
|
|
3052
3231
|
}
|
|
3053
3232
|
function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
3054
|
-
return
|
|
3233
|
+
return definePluginTool15({
|
|
3055
3234
|
annotations: {
|
|
3056
3235
|
destructiveHint: true,
|
|
3057
3236
|
idempotentHint: false,
|
|
@@ -3060,8 +3239,8 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3060
3239
|
},
|
|
3061
3240
|
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.",
|
|
3062
3241
|
exposure: "direct",
|
|
3063
|
-
inputSchema:
|
|
3064
|
-
outputSchema:
|
|
3242
|
+
inputSchema: inputSchema13,
|
|
3243
|
+
outputSchema: outputSchema13,
|
|
3065
3244
|
async execute(review) {
|
|
3066
3245
|
const repo = parseRepo(review.repo);
|
|
3067
3246
|
const comments = review.comments?.map((comment) => ({
|
|
@@ -3085,7 +3264,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3085
3264
|
if (!response.ok) {
|
|
3086
3265
|
throwReviewError(response.status, response.body);
|
|
3087
3266
|
}
|
|
3088
|
-
const providerResult =
|
|
3267
|
+
const providerResult = z20.object({ id: z20.number(), html_url: z20.string(), state: z20.string() }).parse(response.body);
|
|
3089
3268
|
return {
|
|
3090
3269
|
target: "submitPullRequestReview",
|
|
3091
3270
|
repo: repo.ref,
|
|
@@ -3109,6 +3288,7 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
3109
3288
|
pullRequestSubscription
|
|
3110
3289
|
),
|
|
3111
3290
|
getDeployment: createGitHubGetDeploymentTool(ctx),
|
|
3291
|
+
getIssue: createGitHubGetIssueTool(ctx),
|
|
3112
3292
|
getPullRequest: createGitHubGetPullRequestTool(ctx),
|
|
3113
3293
|
getRelease: createGitHubGetReleaseTool(ctx),
|
|
3114
3294
|
getRepository: createGitHubGetRepositoryTool(ctx),
|
|
@@ -3128,26 +3308,26 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
3128
3308
|
|
|
3129
3309
|
// src/webhooks/handler.ts
|
|
3130
3310
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
3131
|
-
import * as
|
|
3311
|
+
import * as z30 from "zod";
|
|
3132
3312
|
|
|
3133
3313
|
// src/issue-outcomes/store.ts
|
|
3134
3314
|
import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
|
|
3135
|
-
import * as
|
|
3136
|
-
var githubIssueOutcomeInputSchema =
|
|
3137
|
-
candidateOwned:
|
|
3138
|
-
closedAt:
|
|
3139
|
-
issueId:
|
|
3140
|
-
number:
|
|
3141
|
-
openedAt:
|
|
3142
|
-
repositoryFullName:
|
|
3143
|
-
repositoryId:
|
|
3315
|
+
import * as z21 from "zod";
|
|
3316
|
+
var githubIssueOutcomeInputSchema = z21.object({
|
|
3317
|
+
candidateOwned: z21.boolean(),
|
|
3318
|
+
closedAt: z21.date().optional(),
|
|
3319
|
+
issueId: z21.string().min(1),
|
|
3320
|
+
number: z21.number().int().positive(),
|
|
3321
|
+
openedAt: z21.date(),
|
|
3322
|
+
repositoryFullName: z21.string().min(1),
|
|
3323
|
+
repositoryId: z21.string().min(1),
|
|
3144
3324
|
state: githubIssueStateSchema,
|
|
3145
3325
|
stateReason: githubIssueStateReasonSchema.optional(),
|
|
3146
|
-
updatedAt:
|
|
3326
|
+
updatedAt: z21.date()
|
|
3147
3327
|
}).strict();
|
|
3148
|
-
var githubIssueConversationsInputSchema =
|
|
3149
|
-
conversationIds:
|
|
3150
|
-
issueId:
|
|
3328
|
+
var githubIssueConversationsInputSchema = z21.object({
|
|
3329
|
+
conversationIds: z21.array(z21.string().min(1)).min(1),
|
|
3330
|
+
issueId: z21.string().min(1)
|
|
3151
3331
|
}).strict();
|
|
3152
3332
|
function projectionValues(input) {
|
|
3153
3333
|
return {
|
|
@@ -3211,33 +3391,33 @@ async function recordGitHubIssueConversations(db, input) {
|
|
|
3211
3391
|
|
|
3212
3392
|
// src/pull-request-outcomes/store.ts
|
|
3213
3393
|
import { and as and3, eq as eq3, lte as lte2, ne, sql as sql3 } from "drizzle-orm";
|
|
3214
|
-
import * as
|
|
3215
|
-
var githubPullRequestOutcomeInputSchema =
|
|
3216
|
-
candidateOwned:
|
|
3217
|
-
closedAt:
|
|
3394
|
+
import * as z22 from "zod";
|
|
3395
|
+
var githubPullRequestOutcomeInputSchema = z22.object({
|
|
3396
|
+
candidateOwned: z22.boolean(),
|
|
3397
|
+
closedAt: z22.date().optional(),
|
|
3218
3398
|
commitComposition: githubPullRequestCommitCompositionSchema.optional(),
|
|
3219
|
-
mergedAt:
|
|
3220
|
-
number:
|
|
3221
|
-
openedAt:
|
|
3222
|
-
pullRequestId:
|
|
3223
|
-
repositoryFullName:
|
|
3224
|
-
repositoryId:
|
|
3399
|
+
mergedAt: z22.date().optional(),
|
|
3400
|
+
number: z22.number().int().positive(),
|
|
3401
|
+
openedAt: z22.date(),
|
|
3402
|
+
pullRequestId: z22.string().min(1),
|
|
3403
|
+
repositoryFullName: z22.string().min(1),
|
|
3404
|
+
repositoryId: z22.string().min(1),
|
|
3225
3405
|
state: githubPullRequestStateSchema,
|
|
3226
|
-
title:
|
|
3227
|
-
updatedAt:
|
|
3406
|
+
title: z22.string().min(1).optional(),
|
|
3407
|
+
updatedAt: z22.date()
|
|
3228
3408
|
}).strict();
|
|
3229
|
-
var githubPullRequestConversationsInputSchema =
|
|
3230
|
-
conversationIds:
|
|
3231
|
-
pullRequestId:
|
|
3409
|
+
var githubPullRequestConversationsInputSchema = z22.object({
|
|
3410
|
+
conversationIds: z22.array(z22.string().min(1)).min(1),
|
|
3411
|
+
pullRequestId: z22.string().min(1)
|
|
3232
3412
|
}).strict();
|
|
3233
|
-
var githubPullRequestLinkedIssuesInputSchema =
|
|
3234
|
-
linkedIssues:
|
|
3235
|
-
|
|
3236
|
-
number:
|
|
3237
|
-
repositoryFullName:
|
|
3413
|
+
var githubPullRequestLinkedIssuesInputSchema = z22.object({
|
|
3414
|
+
linkedIssues: z22.array(
|
|
3415
|
+
z22.object({
|
|
3416
|
+
number: z22.number().int().positive(),
|
|
3417
|
+
repositoryFullName: z22.string().min(1)
|
|
3238
3418
|
}).strict()
|
|
3239
3419
|
).min(1),
|
|
3240
|
-
pullRequestId:
|
|
3420
|
+
pullRequestId: z22.string().min(1)
|
|
3241
3421
|
}).strict();
|
|
3242
3422
|
function projectionValues2(input) {
|
|
3243
3423
|
return {
|
|
@@ -3442,39 +3622,39 @@ async function releaseGitHubPullRequestReadySync(db, target, claim) {
|
|
|
3442
3622
|
}
|
|
3443
3623
|
|
|
3444
3624
|
// src/webhooks/issue-outcome.ts
|
|
3445
|
-
import * as
|
|
3446
|
-
var canonicalIssueOutcomeSchema =
|
|
3447
|
-
action:
|
|
3448
|
-
issue:
|
|
3449
|
-
body:
|
|
3450
|
-
closed_at:
|
|
3451
|
-
created_at:
|
|
3452
|
-
id:
|
|
3453
|
-
number:
|
|
3625
|
+
import * as z23 from "zod";
|
|
3626
|
+
var canonicalIssueOutcomeSchema = z23.object({
|
|
3627
|
+
action: z23.enum(["opened", "closed", "reopened"]),
|
|
3628
|
+
issue: z23.object({
|
|
3629
|
+
body: z23.string().nullable().optional(),
|
|
3630
|
+
closed_at: z23.string().nullable().optional(),
|
|
3631
|
+
created_at: z23.string(),
|
|
3632
|
+
id: z23.number().int().positive(),
|
|
3633
|
+
number: z23.number().int().positive(),
|
|
3454
3634
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3455
|
-
updated_at:
|
|
3456
|
-
user:
|
|
3635
|
+
updated_at: z23.string(),
|
|
3636
|
+
user: z23.object({ login: z23.string().min(1) }).strict()
|
|
3457
3637
|
}).strict(),
|
|
3458
|
-
repository:
|
|
3459
|
-
full_name:
|
|
3460
|
-
id:
|
|
3638
|
+
repository: z23.object({
|
|
3639
|
+
full_name: z23.string().min(1),
|
|
3640
|
+
id: z23.number().int().positive()
|
|
3461
3641
|
}).strict()
|
|
3462
3642
|
}).strict();
|
|
3463
|
-
var issueOutcomeSchema =
|
|
3464
|
-
action:
|
|
3465
|
-
issue:
|
|
3466
|
-
body:
|
|
3467
|
-
closed_at:
|
|
3468
|
-
created_at:
|
|
3469
|
-
id:
|
|
3470
|
-
number:
|
|
3643
|
+
var issueOutcomeSchema = z23.object({
|
|
3644
|
+
action: z23.enum(["opened", "closed", "reopened"]),
|
|
3645
|
+
issue: z23.object({
|
|
3646
|
+
body: z23.string().nullable().optional(),
|
|
3647
|
+
closed_at: z23.string().nullable().optional(),
|
|
3648
|
+
created_at: z23.string(),
|
|
3649
|
+
id: z23.number().int().positive(),
|
|
3650
|
+
number: z23.number().int().positive(),
|
|
3471
3651
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3472
|
-
updated_at:
|
|
3473
|
-
user:
|
|
3652
|
+
updated_at: z23.string(),
|
|
3653
|
+
user: z23.object({ login: z23.string().min(1) }).passthrough()
|
|
3474
3654
|
}).passthrough(),
|
|
3475
|
-
repository:
|
|
3476
|
-
full_name:
|
|
3477
|
-
id:
|
|
3655
|
+
repository: z23.object({
|
|
3656
|
+
full_name: z23.string().min(1),
|
|
3657
|
+
id: z23.number().int().positive()
|
|
3478
3658
|
}).passthrough()
|
|
3479
3659
|
}).passthrough().transform(
|
|
3480
3660
|
(provider) => canonicalIssueOutcomeSchema.parse({
|
|
@@ -3495,7 +3675,7 @@ var issueOutcomeSchema = z21.object({
|
|
|
3495
3675
|
}
|
|
3496
3676
|
})
|
|
3497
3677
|
);
|
|
3498
|
-
var issueLifecycleActionSchema =
|
|
3678
|
+
var issueLifecycleActionSchema = z23.object({ action: z23.string() }).passthrough();
|
|
3499
3679
|
function timestamp2(value) {
|
|
3500
3680
|
if (!value) return void 0;
|
|
3501
3681
|
const parsed = new Date(value);
|
|
@@ -3539,21 +3719,21 @@ function normalizeGitHubIssueOutcome(args) {
|
|
|
3539
3719
|
updatedAt
|
|
3540
3720
|
};
|
|
3541
3721
|
}
|
|
3542
|
-
var canonicalIssueConversationSchema =
|
|
3543
|
-
issue:
|
|
3544
|
-
body:
|
|
3545
|
-
id:
|
|
3546
|
-
user:
|
|
3722
|
+
var canonicalIssueConversationSchema = z23.object({
|
|
3723
|
+
issue: z23.object({
|
|
3724
|
+
body: z23.string().nullable().optional(),
|
|
3725
|
+
id: z23.number().int().positive(),
|
|
3726
|
+
user: z23.object({ login: z23.string().min(1) }).strict()
|
|
3547
3727
|
}).strict(),
|
|
3548
|
-
sender:
|
|
3728
|
+
sender: z23.object({ login: z23.string().min(1) }).strict().optional()
|
|
3549
3729
|
}).strict();
|
|
3550
|
-
var issueConversationSchema =
|
|
3551
|
-
issue:
|
|
3552
|
-
body:
|
|
3553
|
-
id:
|
|
3554
|
-
user:
|
|
3730
|
+
var issueConversationSchema = z23.object({
|
|
3731
|
+
issue: z23.object({
|
|
3732
|
+
body: z23.string().nullable().optional(),
|
|
3733
|
+
id: z23.number().int().positive(),
|
|
3734
|
+
user: z23.object({ login: z23.string().min(1) }).passthrough()
|
|
3555
3735
|
}).passthrough(),
|
|
3556
|
-
sender:
|
|
3736
|
+
sender: z23.object({ login: z23.string().min(1) }).passthrough().optional()
|
|
3557
3737
|
}).passthrough().transform(
|
|
3558
3738
|
(provider) => canonicalIssueConversationSchema.parse({
|
|
3559
3739
|
issue: {
|
|
@@ -3580,43 +3760,43 @@ function normalizeGitHubIssueConversations(args) {
|
|
|
3580
3760
|
}
|
|
3581
3761
|
|
|
3582
3762
|
// src/webhooks/pull-request-outcome.ts
|
|
3583
|
-
import * as
|
|
3584
|
-
var canonicalPullRequestOutcomeSchema =
|
|
3585
|
-
action:
|
|
3586
|
-
pull_request:
|
|
3587
|
-
body:
|
|
3588
|
-
closed_at:
|
|
3589
|
-
created_at:
|
|
3590
|
-
id:
|
|
3591
|
-
merged:
|
|
3592
|
-
merged_at:
|
|
3593
|
-
number:
|
|
3594
|
-
title:
|
|
3595
|
-
updated_at:
|
|
3596
|
-
user:
|
|
3763
|
+
import * as z24 from "zod";
|
|
3764
|
+
var canonicalPullRequestOutcomeSchema = z24.object({
|
|
3765
|
+
action: z24.enum(["opened", "closed", "reopened"]),
|
|
3766
|
+
pull_request: z24.object({
|
|
3767
|
+
body: z24.string().nullable().optional(),
|
|
3768
|
+
closed_at: z24.string().nullable().optional(),
|
|
3769
|
+
created_at: z24.string(),
|
|
3770
|
+
id: z24.number().int().positive(),
|
|
3771
|
+
merged: z24.boolean(),
|
|
3772
|
+
merged_at: z24.string().nullable().optional(),
|
|
3773
|
+
number: z24.number().int().positive(),
|
|
3774
|
+
title: z24.string().min(1).optional(),
|
|
3775
|
+
updated_at: z24.string(),
|
|
3776
|
+
user: z24.object({ login: z24.string().min(1) }).strict()
|
|
3597
3777
|
}).strict(),
|
|
3598
|
-
repository:
|
|
3599
|
-
full_name:
|
|
3600
|
-
id:
|
|
3778
|
+
repository: z24.object({
|
|
3779
|
+
full_name: z24.string().min(1),
|
|
3780
|
+
id: z24.number().int().positive()
|
|
3601
3781
|
}).strict()
|
|
3602
3782
|
}).strict();
|
|
3603
|
-
var pullRequestOutcomeSchema =
|
|
3604
|
-
action:
|
|
3605
|
-
pull_request:
|
|
3606
|
-
body:
|
|
3607
|
-
closed_at:
|
|
3608
|
-
created_at:
|
|
3609
|
-
id:
|
|
3610
|
-
merged:
|
|
3611
|
-
merged_at:
|
|
3612
|
-
number:
|
|
3613
|
-
title:
|
|
3614
|
-
updated_at:
|
|
3615
|
-
user:
|
|
3783
|
+
var pullRequestOutcomeSchema = z24.object({
|
|
3784
|
+
action: z24.enum(["opened", "closed", "reopened"]),
|
|
3785
|
+
pull_request: z24.object({
|
|
3786
|
+
body: z24.string().nullable().optional(),
|
|
3787
|
+
closed_at: z24.string().nullable().optional(),
|
|
3788
|
+
created_at: z24.string(),
|
|
3789
|
+
id: z24.number().int().positive(),
|
|
3790
|
+
merged: z24.boolean(),
|
|
3791
|
+
merged_at: z24.string().nullable().optional(),
|
|
3792
|
+
number: z24.number().int().positive(),
|
|
3793
|
+
title: z24.string().min(1).optional(),
|
|
3794
|
+
updated_at: z24.string(),
|
|
3795
|
+
user: z24.object({ login: z24.string().min(1) }).passthrough()
|
|
3616
3796
|
}).passthrough(),
|
|
3617
|
-
repository:
|
|
3618
|
-
full_name:
|
|
3619
|
-
id:
|
|
3797
|
+
repository: z24.object({
|
|
3798
|
+
full_name: z24.string().min(1),
|
|
3799
|
+
id: z24.number().int().positive()
|
|
3620
3800
|
}).passthrough()
|
|
3621
3801
|
}).passthrough().transform(
|
|
3622
3802
|
(provider) => canonicalPullRequestOutcomeSchema.parse({
|
|
@@ -3639,24 +3819,24 @@ var pullRequestOutcomeSchema = z22.object({
|
|
|
3639
3819
|
}
|
|
3640
3820
|
})
|
|
3641
3821
|
);
|
|
3642
|
-
var pullRequestLifecycleActionSchema =
|
|
3643
|
-
var canonicalPullRequestConversationSchema =
|
|
3644
|
-
pull_request:
|
|
3645
|
-
body:
|
|
3646
|
-
id:
|
|
3647
|
-
user:
|
|
3822
|
+
var pullRequestLifecycleActionSchema = z24.object({ action: z24.string() }).passthrough();
|
|
3823
|
+
var canonicalPullRequestConversationSchema = z24.object({
|
|
3824
|
+
pull_request: z24.object({
|
|
3825
|
+
body: z24.string().nullable().optional(),
|
|
3826
|
+
id: z24.number().int().positive(),
|
|
3827
|
+
user: z24.object({ login: z24.string().min(1) }).strict()
|
|
3648
3828
|
}).strict(),
|
|
3649
|
-
repository:
|
|
3650
|
-
sender:
|
|
3829
|
+
repository: z24.object({ full_name: z24.string().min(1) }).strict(),
|
|
3830
|
+
sender: z24.object({ login: z24.string().min(1) }).strict()
|
|
3651
3831
|
}).strict();
|
|
3652
|
-
var pullRequestConversationSchema =
|
|
3653
|
-
pull_request:
|
|
3654
|
-
body:
|
|
3655
|
-
id:
|
|
3656
|
-
user:
|
|
3832
|
+
var pullRequestConversationSchema = z24.object({
|
|
3833
|
+
pull_request: z24.object({
|
|
3834
|
+
body: z24.string().nullable().optional(),
|
|
3835
|
+
id: z24.number().int().positive(),
|
|
3836
|
+
user: z24.object({ login: z24.string().min(1) }).passthrough()
|
|
3657
3837
|
}).passthrough(),
|
|
3658
|
-
repository:
|
|
3659
|
-
sender:
|
|
3838
|
+
repository: z24.object({ full_name: z24.string().min(1) }).passthrough(),
|
|
3839
|
+
sender: z24.object({ login: z24.string().min(1) }).passthrough()
|
|
3660
3840
|
}).passthrough().transform(
|
|
3661
3841
|
(provider) => canonicalPullRequestConversationSchema.parse({
|
|
3662
3842
|
pull_request: {
|
|
@@ -3743,20 +3923,20 @@ function normalizeGitHubPullRequestLinkedIssues(args) {
|
|
|
3743
3923
|
}
|
|
3744
3924
|
|
|
3745
3925
|
// src/webhooks/merge-conflict.ts
|
|
3746
|
-
import * as
|
|
3926
|
+
import * as z25 from "zod";
|
|
3747
3927
|
var EVENT_TYPE = "pull_request.merge_conflict";
|
|
3748
3928
|
var CLOSED_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
3749
3929
|
"pull_request.closed_unmerged",
|
|
3750
3930
|
"pull_request.merged"
|
|
3751
3931
|
]);
|
|
3752
|
-
var pullRequestSchema3 =
|
|
3753
|
-
base:
|
|
3754
|
-
number:
|
|
3755
|
-
head:
|
|
3756
|
-
html_url:
|
|
3757
|
-
mergeable:
|
|
3758
|
-
mergeable_state:
|
|
3759
|
-
state:
|
|
3932
|
+
var pullRequestSchema3 = z25.object({
|
|
3933
|
+
base: z25.object({ ref: z25.string().min(1) }),
|
|
3934
|
+
number: z25.number().int().positive().optional(),
|
|
3935
|
+
head: z25.object({ sha: z25.string().min(1) }),
|
|
3936
|
+
html_url: z25.string().min(1).optional(),
|
|
3937
|
+
mergeable: z25.boolean().nullable().optional(),
|
|
3938
|
+
mergeable_state: z25.string().optional(),
|
|
3939
|
+
state: z25.string()
|
|
3760
3940
|
});
|
|
3761
3941
|
function gitHubMergeConflictEvents(input) {
|
|
3762
3942
|
const { conflict } = input;
|
|
@@ -3796,7 +3976,7 @@ async function hasMatch(hasMatchEvent, ref) {
|
|
|
3796
3976
|
return false;
|
|
3797
3977
|
}
|
|
3798
3978
|
function deliveredPullRequest(payload, ref) {
|
|
3799
|
-
const parsed =
|
|
3979
|
+
const parsed = z25.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
|
|
3800
3980
|
const pullRequest = parsed.success ? parsed.data.pull_request : void 0;
|
|
3801
3981
|
return pullRequest?.number === ref.number && typeof pullRequest.mergeable === "boolean" ? pullRequest : void 0;
|
|
3802
3982
|
}
|
|
@@ -3834,10 +4014,10 @@ async function loadGitHubMergeConflictEvents(args) {
|
|
|
3834
4014
|
}
|
|
3835
4015
|
|
|
3836
4016
|
// src/webhooks/pull-request-ready.ts
|
|
3837
|
-
import * as
|
|
4017
|
+
import * as z27 from "zod";
|
|
3838
4018
|
|
|
3839
4019
|
// src/webhooks/installation-requests.ts
|
|
3840
|
-
import * as
|
|
4020
|
+
import * as z26 from "zod";
|
|
3841
4021
|
function splitRepository(fullName, label) {
|
|
3842
4022
|
const [owner, name, ...extra] = fullName.split("/");
|
|
3843
4023
|
if (!owner || !name || extra.length > 0) {
|
|
@@ -3898,9 +4078,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
3898
4078
|
}
|
|
3899
4079
|
);
|
|
3900
4080
|
}
|
|
3901
|
-
var repositoryPermissionSchema =
|
|
3902
|
-
permission:
|
|
3903
|
-
role_name:
|
|
4081
|
+
var repositoryPermissionSchema = z26.object({
|
|
4082
|
+
permission: z26.string().min(1),
|
|
4083
|
+
role_name: z26.string().optional()
|
|
3904
4084
|
});
|
|
3905
4085
|
var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
|
|
3906
4086
|
async function loadRepositoryRole(env, cache, target) {
|
|
@@ -3930,18 +4110,19 @@ async function loadRepositoryRole(env, cache, target) {
|
|
|
3930
4110
|
}
|
|
3931
4111
|
);
|
|
3932
4112
|
}
|
|
3933
|
-
var pullRequestSchema4 =
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
4113
|
+
var pullRequestSchema4 = z26.object({
|
|
4114
|
+
auto_merge: z26.object({}).nullable().optional(),
|
|
4115
|
+
draft: z26.boolean().optional(),
|
|
4116
|
+
html_url: z26.string().url(),
|
|
4117
|
+
mergeable_state: z26.string().nullable().optional(),
|
|
4118
|
+
merged: z26.boolean(),
|
|
4119
|
+
state: z26.enum(["open", "closed"]),
|
|
4120
|
+
title: z26.string()
|
|
3940
4121
|
});
|
|
3941
|
-
var reviewsSchema =
|
|
3942
|
-
|
|
3943
|
-
state:
|
|
3944
|
-
user:
|
|
4122
|
+
var reviewsSchema = z26.array(
|
|
4123
|
+
z26.object({
|
|
4124
|
+
state: z26.string(),
|
|
4125
|
+
user: z26.object({ login: z26.string() }).nullable()
|
|
3945
4126
|
})
|
|
3946
4127
|
);
|
|
3947
4128
|
async function loadPullRequestMergeState(env, pullRequest) {
|
|
@@ -3964,6 +4145,7 @@ async function loadPullRequestMergeState(env, pullRequest) {
|
|
|
3964
4145
|
const mergeableState = pull.mergeable_state && pull.mergeable_state !== "unknown" ? pull.mergeable_state : void 0;
|
|
3965
4146
|
return {
|
|
3966
4147
|
approved: false,
|
|
4148
|
+
autoMerge: Boolean(pull.auto_merge),
|
|
3967
4149
|
draft: pull.draft === true,
|
|
3968
4150
|
...mergeableState ? { mergeableState } : void 0,
|
|
3969
4151
|
state: pull.merged ? "merged" : pull.state,
|
|
@@ -3972,7 +4154,7 @@ async function loadPullRequestMergeState(env, pullRequest) {
|
|
|
3972
4154
|
};
|
|
3973
4155
|
};
|
|
3974
4156
|
let state = await readPull();
|
|
3975
|
-
if (state.state !== "open" || state.draft) return state;
|
|
4157
|
+
if (state.state !== "open" || state.draft || state.autoMerge) return state;
|
|
3976
4158
|
if (!state.mergeableState) state = await readPull();
|
|
3977
4159
|
if (state.mergeableState !== "clean") return state;
|
|
3978
4160
|
const reviews = [];
|
|
@@ -3998,6 +4180,8 @@ async function loadPullRequestMergeState(env, pullRequest) {
|
|
|
3998
4180
|
var READY_SYNC_STALE_MS = 6e4;
|
|
3999
4181
|
var READY_ACTIONS = {
|
|
4000
4182
|
pull_request: /* @__PURE__ */ new Set([
|
|
4183
|
+
"auto_merge_disabled",
|
|
4184
|
+
"auto_merge_enabled",
|
|
4001
4185
|
"closed",
|
|
4002
4186
|
"converted_to_draft",
|
|
4003
4187
|
"ready_for_review",
|
|
@@ -4006,10 +4190,10 @@ var READY_ACTIONS = {
|
|
|
4006
4190
|
]),
|
|
4007
4191
|
pull_request_review: /* @__PURE__ */ new Set(["dismissed", "submitted"])
|
|
4008
4192
|
};
|
|
4009
|
-
var pullRequestWebhookSchema =
|
|
4010
|
-
action:
|
|
4011
|
-
pull_request:
|
|
4012
|
-
repository:
|
|
4193
|
+
var pullRequestWebhookSchema = z27.object({
|
|
4194
|
+
action: z27.string(),
|
|
4195
|
+
pull_request: z27.object({ number: z27.number().int().positive() }),
|
|
4196
|
+
repository: z27.object({ full_name: z27.string().min(1) })
|
|
4013
4197
|
});
|
|
4014
4198
|
function pullRequestReadyTargets(eventName, body) {
|
|
4015
4199
|
if (eventName === "check_suite") return checkSuitePullRequests(body);
|
|
@@ -4035,6 +4219,9 @@ function closeReason(state) {
|
|
|
4035
4219
|
status: "dismissed"
|
|
4036
4220
|
};
|
|
4037
4221
|
}
|
|
4222
|
+
if (state.autoMerge) {
|
|
4223
|
+
return { reason: "Auto-merge is on.", status: "dismissed" };
|
|
4224
|
+
}
|
|
4038
4225
|
return {
|
|
4039
4226
|
reason: "The pull request is no longer ready to merge.",
|
|
4040
4227
|
status: "dismissed"
|
|
@@ -4062,8 +4249,8 @@ async function syncOne(args, target) {
|
|
|
4062
4249
|
try {
|
|
4063
4250
|
const state = await loadPullRequestMergeState(args.env, target);
|
|
4064
4251
|
const open = state.state === "open" && !state.draft;
|
|
4065
|
-
const ready = open && state.mergeableState === "clean" && state.approved;
|
|
4066
|
-
if ((!open || state.mergeableState) && ready !== saved) {
|
|
4252
|
+
const ready = open && !state.autoMerge && state.mergeableState === "clean" && state.approved;
|
|
4253
|
+
if ((!open || state.autoMerge || state.mergeableState) && ready !== saved) {
|
|
4067
4254
|
if (ready) {
|
|
4068
4255
|
await items.upsert({
|
|
4069
4256
|
assigneeIdentityIds: [opener.identityId],
|
|
@@ -4104,7 +4291,7 @@ async function syncGitHubPullRequestReadyNotices(args) {
|
|
|
4104
4291
|
}
|
|
4105
4292
|
|
|
4106
4293
|
// src/webhooks/pull-request-match-data.ts
|
|
4107
|
-
import * as
|
|
4294
|
+
import * as z28 from "zod";
|
|
4108
4295
|
var LOOKUPS_BY_MATCH_KEY = {
|
|
4109
4296
|
authors: ["authors"],
|
|
4110
4297
|
openerEmail: ["opener"],
|
|
@@ -4112,22 +4299,22 @@ var LOOKUPS_BY_MATCH_KEY = {
|
|
|
4112
4299
|
openerUsername: ["opener"]
|
|
4113
4300
|
};
|
|
4114
4301
|
var ALL_LOOKUPS = ["authors", "opener", "openerRole"];
|
|
4115
|
-
var lookupDataSchema =
|
|
4116
|
-
authors:
|
|
4117
|
-
openerRole:
|
|
4118
|
-
openerUsername:
|
|
4302
|
+
var lookupDataSchema = z28.object({
|
|
4303
|
+
authors: z28.array(z28.string().min(1)).min(1).optional(),
|
|
4304
|
+
openerRole: z28.string().min(1).optional(),
|
|
4305
|
+
openerUsername: z28.string().min(1).optional()
|
|
4119
4306
|
}).strict();
|
|
4120
4307
|
function lookupData(input) {
|
|
4121
4308
|
return lookupDataSchema.parse(definedValues(input));
|
|
4122
4309
|
}
|
|
4123
|
-
var webhookSchema =
|
|
4124
|
-
repository:
|
|
4310
|
+
var webhookSchema = z28.object({
|
|
4311
|
+
repository: z28.object({ full_name: z28.string().min(1) })
|
|
4125
4312
|
});
|
|
4126
4313
|
function pullRequestNumbers(events) {
|
|
4127
4314
|
const numbers = /* @__PURE__ */ new Map();
|
|
4128
4315
|
for (const event of events) {
|
|
4129
|
-
const
|
|
4130
|
-
if (typeof
|
|
4316
|
+
const number23 = event.data?.pullRequest;
|
|
4317
|
+
if (typeof number23 === "number") numbers.set(event.eventKey, number23);
|
|
4131
4318
|
}
|
|
4132
4319
|
return numbers;
|
|
4133
4320
|
}
|
|
@@ -4141,8 +4328,8 @@ function logFailure(context, lookup, error) {
|
|
|
4141
4328
|
}
|
|
4142
4329
|
async function withJuniorOpeners(context, events) {
|
|
4143
4330
|
const botNumber = (event) => {
|
|
4144
|
-
const
|
|
4145
|
-
return
|
|
4331
|
+
const number23 = context.numbers.get(event.eventKey);
|
|
4332
|
+
return number23 !== void 0 && isBotLogin(event.data?.openerUsername, context.botEmail) ? number23 : void 0;
|
|
4146
4333
|
};
|
|
4147
4334
|
const numbers = events.flatMap((event) => botNumber(event) ?? []);
|
|
4148
4335
|
if (numbers.length === 0) return events;
|
|
@@ -4161,9 +4348,9 @@ async function withJuniorOpeners(context, events) {
|
|
|
4161
4348
|
}
|
|
4162
4349
|
}
|
|
4163
4350
|
return events.map((event) => {
|
|
4164
|
-
const
|
|
4165
|
-
if (
|
|
4166
|
-
const identityId = openers.get(
|
|
4351
|
+
const number23 = botNumber(event);
|
|
4352
|
+
if (number23 === void 0) return event;
|
|
4353
|
+
const identityId = openers.get(number23)?.identityId;
|
|
4167
4354
|
const login = identityId ? logins.get(identityId) : void 0;
|
|
4168
4355
|
const {
|
|
4169
4356
|
openerEmail: _email,
|
|
@@ -4185,8 +4372,8 @@ async function withRolesAndAuthors(context, events, lookups) {
|
|
|
4185
4372
|
if (!loadRole && !loadAuthors) return events;
|
|
4186
4373
|
return await Promise.all(
|
|
4187
4374
|
events.map(async (event) => {
|
|
4188
|
-
const
|
|
4189
|
-
if (
|
|
4375
|
+
const number23 = context.numbers.get(event.eventKey);
|
|
4376
|
+
if (number23 === void 0) return event;
|
|
4190
4377
|
const login = event.data?.openerUsername;
|
|
4191
4378
|
if (loadRole && typeof login === "string" && !roles.has(login)) {
|
|
4192
4379
|
roles.set(
|
|
@@ -4196,16 +4383,16 @@ async function withRolesAndAuthors(context, events, lookups) {
|
|
|
4196
4383
|
)
|
|
4197
4384
|
);
|
|
4198
4385
|
}
|
|
4199
|
-
if (loadAuthors && !authors.has(
|
|
4386
|
+
if (loadAuthors && !authors.has(number23)) {
|
|
4200
4387
|
authors.set(
|
|
4201
|
-
|
|
4202
|
-
loadAuthors({ number:
|
|
4388
|
+
number23,
|
|
4389
|
+
loadAuthors({ number: number23, repositoryFullName }).catch(
|
|
4203
4390
|
(error) => logFailure(context, "authors", error)
|
|
4204
4391
|
)
|
|
4205
4392
|
);
|
|
4206
4393
|
}
|
|
4207
4394
|
const role = loadRole && typeof login === "string" ? await roles.get(login) : void 0;
|
|
4208
|
-
const logins = loadAuthors ? await authors.get(
|
|
4395
|
+
const logins = loadAuthors ? await authors.get(number23) : void 0;
|
|
4209
4396
|
if (!role && !logins?.length) return event;
|
|
4210
4397
|
return {
|
|
4211
4398
|
...event,
|
|
@@ -4264,7 +4451,7 @@ async function withGitHubPullRequestMatchData(args) {
|
|
|
4264
4451
|
}
|
|
4265
4452
|
|
|
4266
4453
|
// src/webhooks/pull-request-people.ts
|
|
4267
|
-
import * as
|
|
4454
|
+
import * as z29 from "zod";
|
|
4268
4455
|
var PEOPLE_EVENTS = /* @__PURE__ */ new Set([
|
|
4269
4456
|
"pull_request.review.approved",
|
|
4270
4457
|
"pull_request.merged"
|
|
@@ -4274,18 +4461,18 @@ var PAGE_SIZE = 100;
|
|
|
4274
4461
|
var MAX_PAGES = 3;
|
|
4275
4462
|
var CO_AUTHOR_TRAILER = /^co-authored-by:[^<\n]*<([^>\s]+@[^>\s]+)>\s*$/gim;
|
|
4276
4463
|
var GITHUB_NOREPLY_EMAIL = /^(?:\d+\+)?(?<login>[^@+]+)@users\.noreply\.github\.com$/i;
|
|
4277
|
-
var webhookSchema2 =
|
|
4278
|
-
pull_request:
|
|
4279
|
-
assignees:
|
|
4280
|
-
number:
|
|
4281
|
-
user:
|
|
4464
|
+
var webhookSchema2 = z29.object({
|
|
4465
|
+
pull_request: z29.object({
|
|
4466
|
+
assignees: z29.array(z29.object({ login: z29.string().min(1) })).nullish(),
|
|
4467
|
+
number: z29.number(),
|
|
4468
|
+
user: z29.object({ login: z29.string().min(1) }).nullish()
|
|
4282
4469
|
}),
|
|
4283
|
-
repository:
|
|
4470
|
+
repository: z29.object({ full_name: z29.string().min(1) })
|
|
4284
4471
|
});
|
|
4285
|
-
var commitPageSchema =
|
|
4286
|
-
|
|
4287
|
-
author:
|
|
4288
|
-
commit:
|
|
4472
|
+
var commitPageSchema = z29.array(
|
|
4473
|
+
z29.object({
|
|
4474
|
+
author: z29.object({ login: z29.string().min(1) }).nullish(),
|
|
4475
|
+
commit: z29.object({ message: z29.string() })
|
|
4289
4476
|
})
|
|
4290
4477
|
);
|
|
4291
4478
|
function shareCommitPages(load) {
|
|
@@ -4430,10 +4617,10 @@ function webhookInstallationId(body) {
|
|
|
4430
4617
|
}
|
|
4431
4618
|
return parseInstallationId(installation.id);
|
|
4432
4619
|
}
|
|
4433
|
-
var feedbackTargetSchema =
|
|
4434
|
-
commentId:
|
|
4435
|
-
commentKind:
|
|
4436
|
-
repo:
|
|
4620
|
+
var feedbackTargetSchema = z30.object({
|
|
4621
|
+
commentId: z30.number(),
|
|
4622
|
+
commentKind: z30.enum(["conversation", "review"]),
|
|
4623
|
+
repo: z30.string().min(1)
|
|
4437
4624
|
});
|
|
4438
4625
|
function pullRequestFeedbackTarget(events) {
|
|
4439
4626
|
const event = events.find(
|
|
@@ -4704,30 +4891,30 @@ function gitHubResourceUrl(input) {
|
|
|
4704
4891
|
if (input.resourceType === "repository") {
|
|
4705
4892
|
return `https://github.com/${input.identifier}`;
|
|
4706
4893
|
}
|
|
4707
|
-
const [repo,
|
|
4708
|
-
if (!repo || !
|
|
4894
|
+
const [repo, number23] = input.identifier.split("#");
|
|
4895
|
+
if (!repo || !number23) return void 0;
|
|
4709
4896
|
if (input.resourceType === "pull_request") {
|
|
4710
|
-
return `https://github.com/${repo}/pull/${
|
|
4897
|
+
return `https://github.com/${repo}/pull/${number23}`;
|
|
4711
4898
|
}
|
|
4712
4899
|
if (input.resourceType === "issue") {
|
|
4713
|
-
return `https://github.com/${repo}/issues/${
|
|
4900
|
+
return `https://github.com/${repo}/issues/${number23}`;
|
|
4714
4901
|
}
|
|
4715
4902
|
return void 0;
|
|
4716
4903
|
}
|
|
4717
4904
|
|
|
4718
4905
|
// src/pull-request-outcomes/commit-composition.ts
|
|
4719
|
-
import * as
|
|
4720
|
-
var canonicalCommitSchema =
|
|
4721
|
-
authorEmail:
|
|
4722
|
-
authorLogin:
|
|
4906
|
+
import * as z31 from "zod";
|
|
4907
|
+
var canonicalCommitSchema = z31.object({
|
|
4908
|
+
authorEmail: z31.string().nullable(),
|
|
4909
|
+
authorLogin: z31.string().nullable()
|
|
4723
4910
|
}).strict();
|
|
4724
|
-
var providerCommitSchema =
|
|
4725
|
-
author:
|
|
4726
|
-
commit:
|
|
4727
|
-
author:
|
|
4911
|
+
var providerCommitSchema = z31.object({
|
|
4912
|
+
author: z31.object({ login: z31.string() }).passthrough().nullable(),
|
|
4913
|
+
commit: z31.object({
|
|
4914
|
+
author: z31.object({ email: z31.string() }).passthrough().nullable()
|
|
4728
4915
|
}).passthrough()
|
|
4729
4916
|
}).passthrough();
|
|
4730
|
-
var commitPageSchema2 =
|
|
4917
|
+
var commitPageSchema2 = z31.array(providerCommitSchema).transform(
|
|
4731
4918
|
(commits) => commits.map(
|
|
4732
4919
|
(commit) => canonicalCommitSchema.parse({
|
|
4733
4920
|
authorEmail: commit.commit.author?.email ?? null,
|
|
@@ -5234,8 +5421,8 @@ function linkifyLine(line) {
|
|
|
5234
5421
|
if (isReferenceBoundary(index2 === 0 ? void 0 : line[index2 - 1])) {
|
|
5235
5422
|
const match = GITHUB_ISSUE_REFERENCE_PATTERN.exec(line.slice(index2));
|
|
5236
5423
|
if (match) {
|
|
5237
|
-
const [reference, owner, repository2,
|
|
5238
|
-
output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${
|
|
5424
|
+
const [reference, owner, repository2, number23] = match;
|
|
5425
|
+
output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${number23})`;
|
|
5239
5426
|
index2 += reference.length;
|
|
5240
5427
|
continue;
|
|
5241
5428
|
}
|
|
@@ -5377,9 +5564,9 @@ function parseGitHubReferences(text2, config) {
|
|
|
5377
5564
|
}
|
|
5378
5565
|
return [...references.values()];
|
|
5379
5566
|
}
|
|
5380
|
-
function objectTitle(kind,
|
|
5381
|
-
if (!isRecord(
|
|
5382
|
-
const raw = kind === "commit" ? isRecord(
|
|
5567
|
+
function objectTitle(kind, object31) {
|
|
5568
|
+
if (!isRecord(object31)) return void 0;
|
|
5569
|
+
const raw = kind === "commit" ? isRecord(object31.commit) && typeof object31.commit.message === "string" ? object31.commit.message.split("\n")[0] : void 0 : typeof object31.title === "string" ? object31.title : void 0;
|
|
5383
5570
|
return raw?.replace(/\s+/g, " ").trim() || void 0;
|
|
5384
5571
|
}
|
|
5385
5572
|
async function loadGitHubConversationTitleContext(args) {
|
|
@@ -5848,6 +6035,15 @@ async function githubPermissionDeniedMessage(ctx) {
|
|
|
5848
6035
|
);
|
|
5849
6036
|
return bodyText ? githubGraphqlPermissionDeniedMessage(bodyText) : void 0;
|
|
5850
6037
|
}
|
|
6038
|
+
var ISSUE_PATH = /^\/repos\/[^/]+\/[^/]+\/issues\/\d+$/;
|
|
6039
|
+
var ISSUE_READ_DENIAL = `Use github_getIssue to read a GitHub issue, not gh issue view or gh api. Read comments with gh api repos/OWNER/REPO/issues/NUMBER/comments. ${CREATE_TOOL_ROUTING_GUIDANCE}`;
|
|
6040
|
+
function isGitHubIssueRead(input) {
|
|
6041
|
+
if (isGitHubGraphqlUrl(input.upstreamUrl)) {
|
|
6042
|
+
const parsed = parseGitHubGraphqlRequest(input.bodyText);
|
|
6043
|
+
return input.method === "POST" && parsed !== void 0 && /\b(?:issue|issueOrPullRequest)\s*\(/.test(parsed.normalized);
|
|
6044
|
+
}
|
|
6045
|
+
return isGitHubApiUrl(input.upstreamUrl) && HTTP_READ_METHODS.has(input.method) && ISSUE_PATH.test(input.upstreamUrl.pathname.toLowerCase());
|
|
6046
|
+
}
|
|
5851
6047
|
var PULL_REQUEST_COMMENT_REACTIONS_PATH = /^\/repos\/[^/]+\/[^/]+\/(issues|pulls)\/comments\/[^/]+\/reactions(?:\/[^/]+)?$/;
|
|
5852
6048
|
var GITHUB_BODY_WRITES = [
|
|
5853
6049
|
{
|
|
@@ -5998,6 +6194,12 @@ function applyGitHubEgressPolicy(input) {
|
|
|
5998
6194
|
denialMessage: "GitHub pull request feedback reactions must use the github_updatePullRequestFeedback tool."
|
|
5999
6195
|
});
|
|
6000
6196
|
}
|
|
6197
|
+
if (isGitHubIssueRead(input)) {
|
|
6198
|
+
enforceEgressPolicy({
|
|
6199
|
+
allowed: input.operation === "github.issue.get",
|
|
6200
|
+
denialMessage: ISSUE_READ_DENIAL
|
|
6201
|
+
});
|
|
6202
|
+
}
|
|
6001
6203
|
assertGitHubPullRequestApprovalDenied({
|
|
6002
6204
|
...input.bodyText !== void 0 ? { bodyText: input.bodyText } : void 0,
|
|
6003
6205
|
method: input.method,
|