@sentry/junior-github 0.275.0 → 0.277.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-EALXNZGU.js → chunk-IR7D5MR7.js} +45 -19
- package/dist/events/resource-url.d.ts +5 -0
- package/dist/github-status.d.ts +16 -0
- package/dist/index.js +743 -476
- package/dist/pull-request-outcomes/store.d.ts +7 -2
- package/dist/testing.js +1 -1
- package/dist/tools/clone-repository.d.ts +1 -1
- package/dist/tools/create-issue.d.ts +4 -4
- package/dist/tools/create-pull-request.d.ts +12 -4
- package/dist/tools/get-deployment.d.ts +19 -19
- package/dist/tools/get-pull-request.d.ts +6 -6
- package/dist/tools/get-release.d.ts +14 -14
- package/dist/tools/get-repository.d.ts +8 -8
- package/dist/tools/get-status.d.ts +137 -0
- package/dist/tools/resolve-pull-request-review-thread.d.ts +3 -3
- package/dist/tools/stack-pull-request.d.ts +42 -0
- package/dist/tools/submit-pull-request-review.d.ts +4 -4
- package/dist/tools/update-issue.d.ts +4 -4
- package/dist/tools/update-pull-request-feedback.d.ts +6 -6
- package/dist/tools/update-pull-request.d.ts +4 -4
- package/dist/webhooks/check-suite.d.ts +6 -0
- package/dist/webhooks/handler.d.ts +3 -0
- package/package.json +2 -2
- package/skills/github-code/SKILL.md +5 -5
- package/skills/github-code/SPEC.md +1 -0
- package/skills/github-code/references/api-surface.md +1 -1
- package/skills/github-code/references/troubleshooting-workarounds.md +15 -1
- package/skills/github-code/references/workflow.md +5 -3
- package/skills/github-issues/references/troubleshooting-workarounds.md +1 -1
package/dist/index.js
CHANGED
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
readGrantPermissions,
|
|
60
60
|
requireEnv,
|
|
61
61
|
resolveUserAccount
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-IR7D5MR7.js";
|
|
63
63
|
|
|
64
64
|
// src/tool-support/attribution.ts
|
|
65
65
|
var GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
|
|
@@ -202,7 +202,7 @@ var inputSchema = z.object({
|
|
|
202
202
|
).describe(
|
|
203
203
|
"Optional destination directory under the sandbox root. Defaults to repos/{name}."
|
|
204
204
|
).optional(),
|
|
205
|
-
|
|
205
|
+
allow_ad_hoc: z.boolean().optional().describe(
|
|
206
206
|
"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."
|
|
207
207
|
)
|
|
208
208
|
}).strict();
|
|
@@ -230,11 +230,11 @@ function workspaceRequiredError(repoId, workspaces) {
|
|
|
230
230
|
const names = quotedNames(workspaces);
|
|
231
231
|
if (workspaces.length === 1) {
|
|
232
232
|
return new PluginToolInputError(
|
|
233
|
-
`Repository ${repoId} is part of Workspace ${names}. Call switchWorkspace with that name; the checkout is already present after the switch. Pass
|
|
233
|
+
`Repository ${repoId} is part of Workspace ${names}. Call switchWorkspace with that name; the checkout is already present after the switch. Pass allow_ad_hoc=true only for an intentional ad-hoc checkout.`
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
236
|
return new PluginToolInputError(
|
|
237
|
-
`Repository ${repoId} is part of Workspaces ${names}. Call switchWorkspace with one of those names; the checkout is already present after the switch. Pass
|
|
237
|
+
`Repository ${repoId} is part of Workspaces ${names}. Call switchWorkspace with one of those names; the checkout is already present after the switch. Pass allow_ad_hoc=true only for an intentional ad-hoc checkout.`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
function workspaceAvailableNote(repoId, active, workspaces) {
|
|
@@ -281,10 +281,10 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
281
281
|
openWorldHint: true,
|
|
282
282
|
readOnlyHint: true
|
|
283
283
|
},
|
|
284
|
-
description: "Clone a GitHub repository into the sandbox as an ad-hoc checkout. The destination must not already exist. In the default Sandbox, a matching Workspace is a tool input error: call switchWorkspace instead, or pass
|
|
284
|
+
description: "Clone a GitHub repository into the sandbox as an ad-hoc checkout. The destination must not already exist. In the default Sandbox, a matching Workspace is a tool input error: call switchWorkspace instead, or pass allow_ad_hoc=true for an intentional ad-hoc checkout. Inside a Workspace, the clone proceeds and the result notes matching Workspaces.",
|
|
285
285
|
describeProposal(input) {
|
|
286
286
|
const directory = typeof input.directory === "string" && input.directory.length > 0 ? input.directory : void 0;
|
|
287
|
-
const adHoc = input.
|
|
287
|
+
const adHoc = input.allow_ad_hoc === true ? " as an intentional ad-hoc checkout" : "";
|
|
288
288
|
return directory ? `Shallow-clone ${input.repo} into the local sandbox at ${directory}${adHoc} for inspection (no GitHub mutation).` : `Shallow-clone ${input.repo} into the local sandbox${adHoc} for inspection (no GitHub mutation).`;
|
|
289
289
|
},
|
|
290
290
|
executionMode: "sequential",
|
|
@@ -309,7 +309,7 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
309
309
|
error: error instanceof Error ? error.message : String(error)
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
|
-
if (workspaces.length > 0 && !active && input.
|
|
312
|
+
if (workspaces.length > 0 && !active && input.allow_ad_hoc !== true) {
|
|
313
313
|
throw workspaceRequiredError(repoId, workspaces);
|
|
314
314
|
}
|
|
315
315
|
const otherWorkspaces = workspaces.filter(
|
|
@@ -984,7 +984,7 @@ import { z as z4 } from "zod";
|
|
|
984
984
|
var commitShaSchema = z4.string().regex(/^[0-9a-f]{40}$/i);
|
|
985
985
|
var inputSchema2 = z4.object({
|
|
986
986
|
repo: z4.string().describe('Repository in "owner/name" format.'),
|
|
987
|
-
|
|
987
|
+
commit_sha: commitShaSchema.describe(
|
|
988
988
|
"Full 40-character Git commit SHA recorded by the deployment."
|
|
989
989
|
),
|
|
990
990
|
environment: z4.string().trim().min(1).describe(
|
|
@@ -992,28 +992,28 @@ var inputSchema2 = z4.object({
|
|
|
992
992
|
).optional()
|
|
993
993
|
}).strict();
|
|
994
994
|
var statusSchema = z4.object({
|
|
995
|
-
|
|
995
|
+
created_at: z4.string(),
|
|
996
996
|
creator: z4.string().nullable(),
|
|
997
997
|
description: z4.string().nullable(),
|
|
998
|
-
|
|
998
|
+
environment_url: z4.string().nullable(),
|
|
999
999
|
id: z4.number(),
|
|
1000
|
-
|
|
1000
|
+
log_url: z4.string().nullable(),
|
|
1001
1001
|
state: z4.string()
|
|
1002
1002
|
}).strict();
|
|
1003
1003
|
var deploymentSchema = z4.object({
|
|
1004
|
-
|
|
1004
|
+
created_at: z4.string(),
|
|
1005
1005
|
creator: z4.string().nullable(),
|
|
1006
1006
|
description: z4.string().nullable(),
|
|
1007
1007
|
environment: z4.string(),
|
|
1008
1008
|
id: z4.number(),
|
|
1009
|
-
|
|
1009
|
+
latest_status: statusSchema.nullable(),
|
|
1010
1010
|
ref: z4.string(),
|
|
1011
1011
|
sha: commitShaSchema,
|
|
1012
|
-
|
|
1012
|
+
updated_at: z4.string(),
|
|
1013
1013
|
url: z4.string()
|
|
1014
1014
|
}).strict();
|
|
1015
1015
|
var deploymentSourceSchema = z4.object({
|
|
1016
|
-
|
|
1016
|
+
commit_sha: commitShaSchema,
|
|
1017
1017
|
deployment: deploymentSchema.nullable(),
|
|
1018
1018
|
environment: z4.string().nullable(),
|
|
1019
1019
|
repo: z4.string(),
|
|
@@ -1084,7 +1084,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1084
1084
|
outputSchema: outputSchema2,
|
|
1085
1085
|
async execute(input) {
|
|
1086
1086
|
const repo = parseRepo3(input.repo);
|
|
1087
|
-
const commitSha = input.
|
|
1087
|
+
const commitSha = input.commit_sha.toLowerCase();
|
|
1088
1088
|
const deploymentsUrl = new URL(repositoryUrl(repo, "deployments"));
|
|
1089
1089
|
deploymentsUrl.searchParams.set("sha", commitSha);
|
|
1090
1090
|
if (input.environment) {
|
|
@@ -1135,23 +1135,23 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1135
1135
|
}
|
|
1136
1136
|
const providerStatus = z4.array(providerStatusSchema).parse(statusesBody)[0];
|
|
1137
1137
|
deployment = {
|
|
1138
|
-
|
|
1138
|
+
created_at: providerDeployment.created_at,
|
|
1139
1139
|
creator: providerDeployment.creator?.login ?? null,
|
|
1140
1140
|
description: providerDeployment.description,
|
|
1141
1141
|
environment: providerDeployment.environment,
|
|
1142
1142
|
id: providerDeployment.id,
|
|
1143
|
-
|
|
1144
|
-
|
|
1143
|
+
latest_status: providerStatus ? {
|
|
1144
|
+
created_at: providerStatus.created_at,
|
|
1145
1145
|
creator: providerStatus.creator?.login ?? null,
|
|
1146
1146
|
description: providerStatus.description ?? null,
|
|
1147
|
-
|
|
1147
|
+
environment_url: providerStatus.environment_url ?? null,
|
|
1148
1148
|
id: providerStatus.id,
|
|
1149
|
-
|
|
1149
|
+
log_url: providerStatus.log_url ?? null,
|
|
1150
1150
|
state: providerStatus.state
|
|
1151
1151
|
} : null,
|
|
1152
1152
|
ref: providerDeployment.ref,
|
|
1153
1153
|
sha: providerDeployment.sha.toLowerCase(),
|
|
1154
|
-
|
|
1154
|
+
updated_at: providerDeployment.updated_at,
|
|
1155
1155
|
url: `https://github.com/${repo.ref}/deployments`
|
|
1156
1156
|
};
|
|
1157
1157
|
}
|
|
@@ -1162,7 +1162,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1162
1162
|
repo: repo.ref
|
|
1163
1163
|
});
|
|
1164
1164
|
const data = {
|
|
1165
|
-
commitSha,
|
|
1165
|
+
commit_sha: commitSha,
|
|
1166
1166
|
deployment,
|
|
1167
1167
|
environment: input.environment ?? null,
|
|
1168
1168
|
repo: repo.ref,
|
|
@@ -1188,7 +1188,7 @@ import {
|
|
|
1188
1188
|
} from "@sentry/junior-plugin-api";
|
|
1189
1189
|
import { Type as Type2 } from "@sinclair/typebox";
|
|
1190
1190
|
import { Value as Value2 } from "@sinclair/typebox/value";
|
|
1191
|
-
import { z as
|
|
1191
|
+
import { z as z7 } from "zod";
|
|
1192
1192
|
|
|
1193
1193
|
// src/pull-request-requesters/store.ts
|
|
1194
1194
|
import { and, asc, eq, inArray, lt } from "drizzle-orm";
|
|
@@ -1374,6 +1374,120 @@ async function listGitHubPullRequestOpeners(db, input) {
|
|
|
1374
1374
|
return openers;
|
|
1375
1375
|
}
|
|
1376
1376
|
|
|
1377
|
+
// src/tools/stack-pull-request.ts
|
|
1378
|
+
import { z as z6 } from "zod";
|
|
1379
|
+
var MAX_STACK_DEPTH = 10;
|
|
1380
|
+
var GITHUB_HEADERS = {
|
|
1381
|
+
Accept: "application/vnd.github+json",
|
|
1382
|
+
"X-GitHub-Api-Version": "2026-03-10"
|
|
1383
|
+
};
|
|
1384
|
+
var stackTargetSchema = z6.object({
|
|
1385
|
+
number: z6.number().int().positive(),
|
|
1386
|
+
head: z6.object({
|
|
1387
|
+
repo: z6.object({ full_name: z6.string().min(1) }).nullable()
|
|
1388
|
+
}),
|
|
1389
|
+
base: z6.object({
|
|
1390
|
+
ref: z6.string().min(1),
|
|
1391
|
+
repo: z6.object({
|
|
1392
|
+
default_branch: z6.string().min(1),
|
|
1393
|
+
full_name: z6.string().min(1)
|
|
1394
|
+
})
|
|
1395
|
+
})
|
|
1396
|
+
});
|
|
1397
|
+
var openPullRequestsSchema = z6.array(
|
|
1398
|
+
z6.object({
|
|
1399
|
+
number: z6.number().int().positive(),
|
|
1400
|
+
base: z6.object({ ref: z6.string().min(1) })
|
|
1401
|
+
})
|
|
1402
|
+
);
|
|
1403
|
+
var stackSchema = z6.object({
|
|
1404
|
+
number: z6.number().int().positive(),
|
|
1405
|
+
pull_requests: z6.array(z6.object({ number: z6.number().int().positive() }))
|
|
1406
|
+
});
|
|
1407
|
+
async function stackGitHubPullRequest(ctx, target) {
|
|
1408
|
+
const repo = target.base.repo.full_name;
|
|
1409
|
+
if (target.base.ref === target.base.repo.default_branch || target.head.repo?.full_name !== repo) {
|
|
1410
|
+
return void 0;
|
|
1411
|
+
}
|
|
1412
|
+
const [owner, name] = repo.split("/");
|
|
1413
|
+
const api = `https://api.github.com/repos/${encodeURIComponent(owner)}/${encodeURIComponent(name)}`;
|
|
1414
|
+
const github = async (operation, url, schema, body) => {
|
|
1415
|
+
const response = await ctx.egress.fetch({
|
|
1416
|
+
provider: "github",
|
|
1417
|
+
operation,
|
|
1418
|
+
request: new Request(url, {
|
|
1419
|
+
method: body === void 0 ? "GET" : "POST",
|
|
1420
|
+
headers: body === void 0 ? GITHUB_HEADERS : { ...GITHUB_HEADERS, "Content-Type": "application/json" },
|
|
1421
|
+
...body === void 0 ? void 0 : { body: JSON.stringify(body) }
|
|
1422
|
+
})
|
|
1423
|
+
});
|
|
1424
|
+
if (!response.ok) {
|
|
1425
|
+
ctx.log.warn("github.pull_request.stack_after_create.rejected", {
|
|
1426
|
+
number: target.number,
|
|
1427
|
+
operation,
|
|
1428
|
+
repo,
|
|
1429
|
+
status: response.status
|
|
1430
|
+
});
|
|
1431
|
+
return void 0;
|
|
1432
|
+
}
|
|
1433
|
+
return schema.parse(await response.json());
|
|
1434
|
+
};
|
|
1435
|
+
const result = (stack) => ({
|
|
1436
|
+
number: stack.number,
|
|
1437
|
+
pull_requests: stack.pull_requests.map((pullRequest) => pullRequest.number)
|
|
1438
|
+
});
|
|
1439
|
+
try {
|
|
1440
|
+
const chain = [target.number];
|
|
1441
|
+
let branch = target.base.ref;
|
|
1442
|
+
for (let depth = 0; depth < MAX_STACK_DEPTH; depth += 1) {
|
|
1443
|
+
const parents = await github(
|
|
1444
|
+
"github.pull.list",
|
|
1445
|
+
`${api}/pulls?state=open&per_page=2&head=${encodeURIComponent(`${owner}:${branch}`)}`,
|
|
1446
|
+
openPullRequestsSchema
|
|
1447
|
+
);
|
|
1448
|
+
if (!parents) return void 0;
|
|
1449
|
+
if (parents.length !== 1) break;
|
|
1450
|
+
const parent = parents[0];
|
|
1451
|
+
const stacks = await github(
|
|
1452
|
+
"github.stack.read",
|
|
1453
|
+
`${api}/stacks?pull_request=${parent.number}`,
|
|
1454
|
+
z6.array(stackSchema)
|
|
1455
|
+
);
|
|
1456
|
+
if (!stacks) return void 0;
|
|
1457
|
+
const stack = stacks[0];
|
|
1458
|
+
if (stack) {
|
|
1459
|
+
if (stack.pull_requests.at(-1)?.number !== parent.number) {
|
|
1460
|
+
return void 0;
|
|
1461
|
+
}
|
|
1462
|
+
const added = await github(
|
|
1463
|
+
"github.stack.add",
|
|
1464
|
+
`${api}/stacks/${stack.number}/add`,
|
|
1465
|
+
stackSchema,
|
|
1466
|
+
{ pull_requests: chain }
|
|
1467
|
+
);
|
|
1468
|
+
return added && result(added);
|
|
1469
|
+
}
|
|
1470
|
+
chain.unshift(parent.number);
|
|
1471
|
+
branch = parent.base.ref;
|
|
1472
|
+
}
|
|
1473
|
+
if (chain.length < 2) return void 0;
|
|
1474
|
+
const created = await github(
|
|
1475
|
+
"github.stack.create",
|
|
1476
|
+
`${api}/stacks`,
|
|
1477
|
+
stackSchema,
|
|
1478
|
+
{ pull_requests: chain }
|
|
1479
|
+
);
|
|
1480
|
+
return created && result(created);
|
|
1481
|
+
} catch (error) {
|
|
1482
|
+
ctx.log.warn("github.pull_request.stack_after_create.failed", {
|
|
1483
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1484
|
+
number: target.number,
|
|
1485
|
+
repo
|
|
1486
|
+
});
|
|
1487
|
+
return void 0;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1377
1491
|
// src/tools/create-pull-request.ts
|
|
1378
1492
|
var GITHUB_PULL_REQUEST_CREATE_IDEMPOTENCY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
1379
1493
|
var GITHUB_PULL_REQUEST_CREATE_LOCK_TTL_MS = 6e4;
|
|
@@ -1412,15 +1526,15 @@ var createPullRequestInputSchema = Type2.Object(
|
|
|
1412
1526
|
},
|
|
1413
1527
|
{ additionalProperties: false }
|
|
1414
1528
|
);
|
|
1415
|
-
var createPullRequestToolInputSchema =
|
|
1416
|
-
repo:
|
|
1417
|
-
title:
|
|
1418
|
-
head:
|
|
1419
|
-
base:
|
|
1420
|
-
body:
|
|
1529
|
+
var createPullRequestToolInputSchema = z7.object({
|
|
1530
|
+
repo: z7.string().describe('Repository in "owner/name" format.'),
|
|
1531
|
+
title: z7.string().describe("Pull request title."),
|
|
1532
|
+
head: z7.string().describe("Head branch or owner:branch ref."),
|
|
1533
|
+
base: z7.string().describe("Base branch."),
|
|
1534
|
+
body: z7.string().describe(
|
|
1421
1535
|
"Pull request body. The runtime appends the conversation footer."
|
|
1422
1536
|
).optional(),
|
|
1423
|
-
draft:
|
|
1537
|
+
draft: z7.boolean().describe("Whether to open the pull request as a draft.").optional()
|
|
1424
1538
|
}).strict();
|
|
1425
1539
|
var createPullRequestStateSchema = Type2.Union([
|
|
1426
1540
|
Type2.Object(
|
|
@@ -1445,15 +1559,16 @@ var createPullRequestStateSchema = Type2.Union([
|
|
|
1445
1559
|
{ additionalProperties: false }
|
|
1446
1560
|
)
|
|
1447
1561
|
]);
|
|
1448
|
-
var gitHubPullRequestDataSchema =
|
|
1449
|
-
number:
|
|
1450
|
-
url:
|
|
1562
|
+
var gitHubPullRequestDataSchema = z7.object({
|
|
1563
|
+
number: z7.number(),
|
|
1564
|
+
url: z7.string(),
|
|
1565
|
+
stack: z7.object({ number: z7.number(), pull_requests: z7.array(z7.number()) }).optional(),
|
|
1451
1566
|
subscribable: subscribableResourceSchema3.optional(),
|
|
1452
1567
|
subscription: watchResultSchema.optional()
|
|
1453
1568
|
});
|
|
1454
1569
|
var gitHubPullRequestOutputSchema = pluginToolOutputSchema4.merge(
|
|
1455
1570
|
gitHubPullRequestDataSchema.extend({
|
|
1456
|
-
target:
|
|
1571
|
+
target: z7.literal("createPullRequest")
|
|
1457
1572
|
})
|
|
1458
1573
|
);
|
|
1459
1574
|
function parseCreatePullRequestInput(input) {
|
|
@@ -1599,10 +1714,14 @@ async function createGitHubPullRequest(ctx, request) {
|
|
|
1599
1714
|
"GitHub pull request creation returned an invalid response."
|
|
1600
1715
|
);
|
|
1601
1716
|
}
|
|
1717
|
+
const stackTarget = stackTargetSchema.safeParse(parsed);
|
|
1602
1718
|
return {
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1719
|
+
result: {
|
|
1720
|
+
...githubObjectFacts("code_change", parsed),
|
|
1721
|
+
number: pullRequest.number,
|
|
1722
|
+
url: pullRequest.html_url
|
|
1723
|
+
},
|
|
1724
|
+
...stackTarget.success ? { stackTarget: stackTarget.data } : void 0
|
|
1606
1725
|
};
|
|
1607
1726
|
}
|
|
1608
1727
|
async function recordOpener(ctx, input, state, requester) {
|
|
@@ -1667,7 +1786,7 @@ function gitHubPullRequestToolResult(input, result, canSubscribe, omitSuggestedE
|
|
|
1667
1786
|
...subscribable ? { subscribable } : void 0
|
|
1668
1787
|
};
|
|
1669
1788
|
}
|
|
1670
|
-
async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptionConfig) {
|
|
1789
|
+
async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptionConfig, stack) {
|
|
1671
1790
|
const base = gitHubPullRequestToolResult(
|
|
1672
1791
|
input,
|
|
1673
1792
|
result,
|
|
@@ -1690,7 +1809,8 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
|
|
|
1690
1809
|
return {
|
|
1691
1810
|
objectAnnotations,
|
|
1692
1811
|
target: "createPullRequest",
|
|
1693
|
-
...base
|
|
1812
|
+
...base,
|
|
1813
|
+
...stack ? { stack } : void 0
|
|
1694
1814
|
};
|
|
1695
1815
|
}
|
|
1696
1816
|
const watch = gitHubPullRequestCreateWatch(subscriptionConfig);
|
|
@@ -1709,6 +1829,7 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
|
|
|
1709
1829
|
objectAnnotations,
|
|
1710
1830
|
target: "createPullRequest",
|
|
1711
1831
|
...data,
|
|
1832
|
+
...stack ? { stack } : void 0,
|
|
1712
1833
|
subscription
|
|
1713
1834
|
};
|
|
1714
1835
|
} catch (error) {
|
|
@@ -1720,7 +1841,8 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
|
|
|
1720
1841
|
return {
|
|
1721
1842
|
objectAnnotations,
|
|
1722
1843
|
target: "createPullRequest",
|
|
1723
|
-
...base
|
|
1844
|
+
...base,
|
|
1845
|
+
...stack ? { stack } : void 0
|
|
1724
1846
|
};
|
|
1725
1847
|
}
|
|
1726
1848
|
}
|
|
@@ -1794,8 +1916,12 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
1794
1916
|
GITHUB_PULL_REQUEST_CREATE_IDEMPOTENCY_TTL_MS
|
|
1795
1917
|
);
|
|
1796
1918
|
let result;
|
|
1919
|
+
let stackTarget;
|
|
1797
1920
|
try {
|
|
1798
|
-
result = await createGitHubPullRequest(
|
|
1921
|
+
({ result, stackTarget } = await createGitHubPullRequest(
|
|
1922
|
+
ctx,
|
|
1923
|
+
request
|
|
1924
|
+
));
|
|
1799
1925
|
} catch (error) {
|
|
1800
1926
|
if (isEgressAuthRequired2(error) || isDefinitiveGitHubPullRequestCreateRejection(error)) {
|
|
1801
1927
|
await ctx.state.delete(key);
|
|
@@ -1824,11 +1950,13 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
1824
1950
|
identityId
|
|
1825
1951
|
});
|
|
1826
1952
|
await assignPullRequestRequester(ctx, parsedInput, result, requester);
|
|
1953
|
+
const stack = stackTarget ? await stackGitHubPullRequest(ctx, stackTarget) : void 0;
|
|
1827
1954
|
return await gitHubPullRequestStructuredResult(
|
|
1828
1955
|
ctx,
|
|
1829
1956
|
parsedInput,
|
|
1830
1957
|
result,
|
|
1831
|
-
subscriptionConfig
|
|
1958
|
+
subscriptionConfig,
|
|
1959
|
+
stack
|
|
1832
1960
|
);
|
|
1833
1961
|
}
|
|
1834
1962
|
);
|
|
@@ -1842,28 +1970,28 @@ import {
|
|
|
1842
1970
|
PluginToolInputError as PluginToolInputError6,
|
|
1843
1971
|
pluginToolOutputSchema as pluginToolOutputSchema5
|
|
1844
1972
|
} from "@sentry/junior-plugin-api";
|
|
1845
|
-
import { z as
|
|
1973
|
+
import { z as z8 } from "zod";
|
|
1846
1974
|
import { subscribableResourceSchema as subscribableResourceSchema4 } from "@sentry/junior-plugin-api";
|
|
1847
|
-
var commitShaSchema2 =
|
|
1848
|
-
var inputSchema3 =
|
|
1849
|
-
repo:
|
|
1850
|
-
number:
|
|
1975
|
+
var commitShaSchema2 = z8.string().regex(/^[0-9a-f]{40}$/i);
|
|
1976
|
+
var inputSchema3 = z8.object({
|
|
1977
|
+
repo: z8.string().describe('Repository in "owner/name" format.'),
|
|
1978
|
+
number: z8.number().int().positive().describe("Pull request number.")
|
|
1851
1979
|
}).strict();
|
|
1852
|
-
var pullRequestSchema =
|
|
1853
|
-
base:
|
|
1854
|
-
draft:
|
|
1855
|
-
head:
|
|
1856
|
-
|
|
1857
|
-
merged:
|
|
1858
|
-
number:
|
|
1859
|
-
state:
|
|
1980
|
+
var pullRequestSchema = z8.object({
|
|
1981
|
+
base: z8.string(),
|
|
1982
|
+
draft: z8.boolean(),
|
|
1983
|
+
head: z8.string(),
|
|
1984
|
+
head_sha: commitShaSchema2,
|
|
1985
|
+
merged: z8.boolean(),
|
|
1986
|
+
number: z8.number(),
|
|
1987
|
+
state: z8.string(),
|
|
1860
1988
|
subscribable: subscribableResourceSchema4.optional(),
|
|
1861
|
-
title:
|
|
1862
|
-
url:
|
|
1989
|
+
title: z8.string(),
|
|
1990
|
+
url: z8.string()
|
|
1863
1991
|
});
|
|
1864
1992
|
var outputSchema3 = pluginToolOutputSchema5.merge(
|
|
1865
1993
|
pullRequestSchema.extend({
|
|
1866
|
-
target:
|
|
1994
|
+
target: z8.literal("getPullRequest")
|
|
1867
1995
|
})
|
|
1868
1996
|
);
|
|
1869
1997
|
function parseRepo5(value) {
|
|
@@ -1916,15 +2044,15 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
1916
2044
|
}
|
|
1917
2045
|
throw new Error(message);
|
|
1918
2046
|
}
|
|
1919
|
-
const providerResult =
|
|
1920
|
-
base:
|
|
1921
|
-
draft:
|
|
1922
|
-
head:
|
|
1923
|
-
html_url:
|
|
1924
|
-
merged:
|
|
1925
|
-
number:
|
|
1926
|
-
state:
|
|
1927
|
-
title:
|
|
2047
|
+
const providerResult = z8.object({
|
|
2048
|
+
base: z8.object({ ref: z8.string() }),
|
|
2049
|
+
draft: z8.boolean(),
|
|
2050
|
+
head: z8.object({ ref: z8.string(), sha: commitShaSchema2 }),
|
|
2051
|
+
html_url: z8.string(),
|
|
2052
|
+
merged: z8.boolean().optional().default(false),
|
|
2053
|
+
number: z8.number(),
|
|
2054
|
+
state: z8.string(),
|
|
2055
|
+
title: z8.string()
|
|
1928
2056
|
}).parse(parsed);
|
|
1929
2057
|
const subscribable = gitHubPullRequestSubscribable({
|
|
1930
2058
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -1935,7 +2063,7 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
1935
2063
|
base: providerResult.base.ref,
|
|
1936
2064
|
draft: providerResult.draft,
|
|
1937
2065
|
head: providerResult.head.ref,
|
|
1938
|
-
|
|
2066
|
+
head_sha: providerResult.head.sha.toLowerCase(),
|
|
1939
2067
|
merged: providerResult.merged,
|
|
1940
2068
|
number: providerResult.number,
|
|
1941
2069
|
state: providerResult.state,
|
|
@@ -1969,45 +2097,45 @@ import {
|
|
|
1969
2097
|
pluginToolOutputSchema as pluginToolOutputSchema6,
|
|
1970
2098
|
subscribableResourceSchema as subscribableResourceSchema5
|
|
1971
2099
|
} from "@sentry/junior-plugin-api";
|
|
1972
|
-
import { z as
|
|
1973
|
-
var inputSchema4 =
|
|
1974
|
-
repo:
|
|
1975
|
-
tag:
|
|
2100
|
+
import { z as z9 } from "zod";
|
|
2101
|
+
var inputSchema4 = z9.object({
|
|
2102
|
+
repo: z9.string().describe('Repository in "owner/name" format.'),
|
|
2103
|
+
tag: z9.string().trim().min(1).describe(
|
|
1976
2104
|
"Optional release tag name. Omit to inspect and watch every published release in the repository."
|
|
1977
2105
|
).optional()
|
|
1978
2106
|
}).strict();
|
|
1979
|
-
var releaseSchema =
|
|
1980
|
-
|
|
1981
|
-
draft:
|
|
1982
|
-
|
|
1983
|
-
id:
|
|
1984
|
-
name:
|
|
1985
|
-
prerelease:
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
2107
|
+
var releaseSchema = z9.object({
|
|
2108
|
+
created_at: z9.string(),
|
|
2109
|
+
draft: z9.boolean(),
|
|
2110
|
+
html_url: z9.string(),
|
|
2111
|
+
id: z9.number(),
|
|
2112
|
+
name: z9.string().nullable(),
|
|
2113
|
+
prerelease: z9.boolean(),
|
|
2114
|
+
published_at: z9.string().nullable(),
|
|
2115
|
+
tag_name: z9.string(),
|
|
2116
|
+
target_commitish: z9.string()
|
|
1989
2117
|
}).strict();
|
|
1990
|
-
var releaseSourceSchema =
|
|
2118
|
+
var releaseSourceSchema = z9.object({
|
|
1991
2119
|
release: releaseSchema.nullable(),
|
|
1992
|
-
repo:
|
|
2120
|
+
repo: z9.string(),
|
|
1993
2121
|
subscribable: subscribableResourceSchema5.optional(),
|
|
1994
|
-
tag:
|
|
2122
|
+
tag: z9.string().nullable()
|
|
1995
2123
|
}).strict();
|
|
1996
2124
|
var outputSchema4 = pluginToolOutputSchema6.merge(
|
|
1997
2125
|
releaseSourceSchema.extend({
|
|
1998
|
-
target:
|
|
2126
|
+
target: z9.literal("getRelease")
|
|
1999
2127
|
})
|
|
2000
2128
|
);
|
|
2001
|
-
var providerReleaseSchema =
|
|
2002
|
-
created_at:
|
|
2003
|
-
draft:
|
|
2004
|
-
html_url:
|
|
2005
|
-
id:
|
|
2006
|
-
name:
|
|
2007
|
-
prerelease:
|
|
2008
|
-
published_at:
|
|
2009
|
-
tag_name:
|
|
2010
|
-
target_commitish:
|
|
2129
|
+
var providerReleaseSchema = z9.object({
|
|
2130
|
+
created_at: z9.string(),
|
|
2131
|
+
draft: z9.boolean(),
|
|
2132
|
+
html_url: z9.string(),
|
|
2133
|
+
id: z9.number(),
|
|
2134
|
+
name: z9.string().nullable(),
|
|
2135
|
+
prerelease: z9.boolean(),
|
|
2136
|
+
published_at: z9.string().nullable(),
|
|
2137
|
+
tag_name: z9.string(),
|
|
2138
|
+
target_commitish: z9.string()
|
|
2011
2139
|
}).passthrough();
|
|
2012
2140
|
function parseRepo6(value) {
|
|
2013
2141
|
const parts = value.split("/").map((part) => part.trim());
|
|
@@ -2030,15 +2158,15 @@ function repositoryUrl2(repo, path) {
|
|
|
2030
2158
|
}
|
|
2031
2159
|
function mapRelease(providerRelease) {
|
|
2032
2160
|
return {
|
|
2033
|
-
|
|
2161
|
+
created_at: providerRelease.created_at,
|
|
2034
2162
|
draft: providerRelease.draft,
|
|
2035
|
-
|
|
2163
|
+
html_url: providerRelease.html_url,
|
|
2036
2164
|
id: providerRelease.id,
|
|
2037
2165
|
name: providerRelease.name,
|
|
2038
2166
|
prerelease: providerRelease.prerelease,
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2167
|
+
published_at: providerRelease.published_at,
|
|
2168
|
+
tag_name: providerRelease.tag_name,
|
|
2169
|
+
target_commitish: providerRelease.target_commitish
|
|
2042
2170
|
};
|
|
2043
2171
|
}
|
|
2044
2172
|
function createGitHubGetReleaseTool(ctx) {
|
|
@@ -2126,21 +2254,21 @@ import {
|
|
|
2126
2254
|
pluginToolOutputSchema as pluginToolOutputSchema7,
|
|
2127
2255
|
subscribableResourceSchema as subscribableResourceSchema6
|
|
2128
2256
|
} from "@sentry/junior-plugin-api";
|
|
2129
|
-
import { z as
|
|
2130
|
-
var inputSchema5 =
|
|
2131
|
-
repo:
|
|
2257
|
+
import { z as z10 } from "zod";
|
|
2258
|
+
var inputSchema5 = z10.object({
|
|
2259
|
+
repo: z10.string().describe('Repository in "owner/name" format.')
|
|
2132
2260
|
}).strict();
|
|
2133
|
-
var repositorySchema =
|
|
2134
|
-
|
|
2135
|
-
description:
|
|
2136
|
-
|
|
2137
|
-
private:
|
|
2261
|
+
var repositorySchema = z10.object({
|
|
2262
|
+
default_branch: z10.string(),
|
|
2263
|
+
description: z10.string().nullable(),
|
|
2264
|
+
full_name: z10.string(),
|
|
2265
|
+
private: z10.boolean(),
|
|
2138
2266
|
subscribable: subscribableResourceSchema6.optional(),
|
|
2139
|
-
url:
|
|
2267
|
+
url: z10.string()
|
|
2140
2268
|
});
|
|
2141
2269
|
var outputSchema5 = pluginToolOutputSchema7.merge(
|
|
2142
2270
|
repositorySchema.extend({
|
|
2143
|
-
target:
|
|
2271
|
+
target: z10.literal("getRepository")
|
|
2144
2272
|
})
|
|
2145
2273
|
);
|
|
2146
2274
|
function parseRepo7(value) {
|
|
@@ -2191,21 +2319,21 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2191
2319
|
`GitHub repository lookup failed with HTTP ${response.status}`
|
|
2192
2320
|
);
|
|
2193
2321
|
}
|
|
2194
|
-
const providerResult =
|
|
2195
|
-
default_branch:
|
|
2196
|
-
description:
|
|
2197
|
-
full_name:
|
|
2198
|
-
html_url:
|
|
2199
|
-
private:
|
|
2322
|
+
const providerResult = z10.object({
|
|
2323
|
+
default_branch: z10.string(),
|
|
2324
|
+
description: z10.string().nullable(),
|
|
2325
|
+
full_name: z10.string(),
|
|
2326
|
+
html_url: z10.string(),
|
|
2327
|
+
private: z10.boolean()
|
|
2200
2328
|
}).parse(parsed);
|
|
2201
2329
|
const subscribable = gitHubRepositorySubscribable({
|
|
2202
2330
|
canSubscribe: ctx.events.canSubscribe,
|
|
2203
2331
|
repo: providerResult.full_name
|
|
2204
2332
|
});
|
|
2205
2333
|
const data = {
|
|
2206
|
-
|
|
2334
|
+
default_branch: providerResult.default_branch,
|
|
2207
2335
|
description: providerResult.description,
|
|
2208
|
-
|
|
2336
|
+
full_name: providerResult.full_name,
|
|
2209
2337
|
private: providerResult.private,
|
|
2210
2338
|
...subscribable ? { subscribable } : void 0,
|
|
2211
2339
|
url: providerResult.html_url
|
|
@@ -2218,37 +2346,146 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2218
2346
|
});
|
|
2219
2347
|
}
|
|
2220
2348
|
|
|
2221
|
-
// src/tools/
|
|
2349
|
+
// src/tools/get-status.ts
|
|
2222
2350
|
import {
|
|
2223
2351
|
definePluginTool as definePluginTool8,
|
|
2352
|
+
pluginToolOutputSchema as pluginToolOutputSchema8
|
|
2353
|
+
} from "@sentry/junior-plugin-api";
|
|
2354
|
+
import { z as z12 } from "zod";
|
|
2355
|
+
|
|
2356
|
+
// src/github-status.ts
|
|
2357
|
+
import { z as z11 } from "zod";
|
|
2358
|
+
var GITHUB_STATUS_INCIDENTS_URL = "https://www.githubstatus.com/api/v2/incidents.json";
|
|
2359
|
+
var GITHUB_STATUS_TTL_MS = 60 * 1e3;
|
|
2360
|
+
var GITHUB_STATUS_TIMEOUT_MS = 5e3;
|
|
2361
|
+
var incidentsResponseSchema = z11.object({
|
|
2362
|
+
incidents: z11.array(
|
|
2363
|
+
z11.object({
|
|
2364
|
+
components: z11.array(z11.object({ name: z11.string() })).default([]),
|
|
2365
|
+
created_at: z11.string(),
|
|
2366
|
+
impact: z11.string(),
|
|
2367
|
+
name: z11.string(),
|
|
2368
|
+
resolved_at: z11.string().nullable(),
|
|
2369
|
+
shortlink: z11.string(),
|
|
2370
|
+
started_at: z11.string().nullable().optional(),
|
|
2371
|
+
status: z11.string()
|
|
2372
|
+
})
|
|
2373
|
+
)
|
|
2374
|
+
});
|
|
2375
|
+
async function fetchGitHubStatusIncidents() {
|
|
2376
|
+
const response = await fetch(GITHUB_STATUS_INCIDENTS_URL, {
|
|
2377
|
+
headers: { Accept: "application/json" },
|
|
2378
|
+
signal: AbortSignal.timeout(GITHUB_STATUS_TIMEOUT_MS)
|
|
2379
|
+
});
|
|
2380
|
+
if (!response.ok) {
|
|
2381
|
+
throw new Error(`githubstatus.com returned HTTP ${response.status}`);
|
|
2382
|
+
}
|
|
2383
|
+
const parsed = incidentsResponseSchema.parse(await response.json());
|
|
2384
|
+
return parsed.incidents.map((incident) => {
|
|
2385
|
+
const result = {
|
|
2386
|
+
components: incident.components.map((component) => component.name),
|
|
2387
|
+
impact: incident.impact,
|
|
2388
|
+
name: incident.name,
|
|
2389
|
+
startedAt: incident.started_at ?? incident.created_at,
|
|
2390
|
+
status: incident.status,
|
|
2391
|
+
url: incident.shortlink
|
|
2392
|
+
};
|
|
2393
|
+
if (incident.resolved_at) result.resolvedAt = incident.resolved_at;
|
|
2394
|
+
return result;
|
|
2395
|
+
});
|
|
2396
|
+
}
|
|
2397
|
+
async function loadGitHubStatusIncidents(cache, withinMs) {
|
|
2398
|
+
const incidents = await cache.getOrLoad(
|
|
2399
|
+
"githubstatus:incidents",
|
|
2400
|
+
async () => ({
|
|
2401
|
+
ttlMs: GITHUB_STATUS_TTL_MS,
|
|
2402
|
+
value: await fetchGitHubStatusIncidents()
|
|
2403
|
+
})
|
|
2404
|
+
);
|
|
2405
|
+
const since = Date.now() - withinMs;
|
|
2406
|
+
return incidents.filter(
|
|
2407
|
+
(incident) => !incident.resolvedAt || Date.parse(incident.resolvedAt) >= since
|
|
2408
|
+
);
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
// src/tools/get-status.ts
|
|
2412
|
+
var RECENT_INCIDENT_MS = 24 * 60 * 60 * 1e3;
|
|
2413
|
+
var inputSchema6 = z12.object({}).strict();
|
|
2414
|
+
var incidentSchema = z12.object({
|
|
2415
|
+
components: z12.array(z12.string()),
|
|
2416
|
+
impact: z12.string(),
|
|
2417
|
+
name: z12.string(),
|
|
2418
|
+
resolved_at: z12.string().optional(),
|
|
2419
|
+
started_at: z12.string(),
|
|
2420
|
+
status: z12.string(),
|
|
2421
|
+
url: z12.string()
|
|
2422
|
+
});
|
|
2423
|
+
var outputSchema6 = pluginToolOutputSchema8.extend({
|
|
2424
|
+
target: z12.literal("getStatus"),
|
|
2425
|
+
incidents: z12.array(incidentSchema)
|
|
2426
|
+
});
|
|
2427
|
+
function createGitHubGetStatusTool(ctx) {
|
|
2428
|
+
return definePluginTool8({
|
|
2429
|
+
annotations: {
|
|
2430
|
+
destructiveHint: false,
|
|
2431
|
+
idempotentHint: true,
|
|
2432
|
+
openWorldHint: true,
|
|
2433
|
+
readOnlyHint: true
|
|
2434
|
+
},
|
|
2435
|
+
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.",
|
|
2436
|
+
inputSchema: inputSchema6,
|
|
2437
|
+
outputSchema: outputSchema6,
|
|
2438
|
+
async execute() {
|
|
2439
|
+
const incidents = await loadGitHubStatusIncidents(
|
|
2440
|
+
ctx.cache,
|
|
2441
|
+
RECENT_INCIDENT_MS
|
|
2442
|
+
);
|
|
2443
|
+
return {
|
|
2444
|
+
target: "getStatus",
|
|
2445
|
+
incidents: incidents.map(({ resolvedAt, startedAt, ...incident }) => {
|
|
2446
|
+
const result = {
|
|
2447
|
+
...incident,
|
|
2448
|
+
started_at: startedAt
|
|
2449
|
+
};
|
|
2450
|
+
if (resolvedAt) result.resolved_at = resolvedAt;
|
|
2451
|
+
return result;
|
|
2452
|
+
})
|
|
2453
|
+
};
|
|
2454
|
+
}
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
// src/tools/update-issue.ts
|
|
2459
|
+
import {
|
|
2460
|
+
definePluginTool as definePluginTool9,
|
|
2224
2461
|
PluginToolInputError as PluginToolInputError9,
|
|
2225
|
-
pluginToolOutputSchema as
|
|
2462
|
+
pluginToolOutputSchema as pluginToolOutputSchema9,
|
|
2226
2463
|
subscribableResourceSchema as subscribableResourceSchema7
|
|
2227
2464
|
} from "@sentry/junior-plugin-api";
|
|
2228
|
-
import { z as
|
|
2229
|
-
var
|
|
2230
|
-
repo:
|
|
2231
|
-
number:
|
|
2232
|
-
title:
|
|
2233
|
-
body:
|
|
2465
|
+
import { z as z13 } from "zod";
|
|
2466
|
+
var inputSchema7 = z13.object({
|
|
2467
|
+
repo: z13.string().describe('Repository in "owner/name" format.'),
|
|
2468
|
+
number: z13.number().int().positive().describe("Issue number."),
|
|
2469
|
+
title: z13.string().trim().min(1).optional().describe("Replacement issue title."),
|
|
2470
|
+
body: z13.string().optional().describe(
|
|
2234
2471
|
"Replacement issue body. The runtime appends requester attribution and the conversation footer."
|
|
2235
2472
|
),
|
|
2236
|
-
state:
|
|
2473
|
+
state: z13.enum(["open", "closed"]).optional().describe("Replacement issue state.")
|
|
2237
2474
|
}).strict().refine(
|
|
2238
2475
|
({ title, body, state }) => title !== void 0 || body !== void 0 || state !== void 0,
|
|
2239
2476
|
{ message: "At least one issue field must be provided." }
|
|
2240
2477
|
);
|
|
2241
|
-
var issueSchema =
|
|
2242
|
-
body:
|
|
2243
|
-
number:
|
|
2244
|
-
state:
|
|
2478
|
+
var issueSchema = z13.object({
|
|
2479
|
+
body: z13.string().nullable(),
|
|
2480
|
+
number: z13.number(),
|
|
2481
|
+
state: z13.string(),
|
|
2245
2482
|
subscribable: subscribableResourceSchema7.optional(),
|
|
2246
|
-
title:
|
|
2247
|
-
url:
|
|
2483
|
+
title: z13.string(),
|
|
2484
|
+
url: z13.string()
|
|
2248
2485
|
});
|
|
2249
|
-
var
|
|
2486
|
+
var outputSchema7 = pluginToolOutputSchema9.merge(
|
|
2250
2487
|
issueSchema.extend({
|
|
2251
|
-
target:
|
|
2488
|
+
target: z13.literal("updateIssue")
|
|
2252
2489
|
})
|
|
2253
2490
|
);
|
|
2254
2491
|
function nonEmptyString4(value, name) {
|
|
@@ -2280,7 +2517,7 @@ function githubApiErrorMessage3(payload) {
|
|
|
2280
2517
|
return "GitHub request failed";
|
|
2281
2518
|
}
|
|
2282
2519
|
function createGitHubUpdateIssueTool(ctx) {
|
|
2283
|
-
return
|
|
2520
|
+
return definePluginTool9({
|
|
2284
2521
|
annotations: {
|
|
2285
2522
|
destructiveHint: true,
|
|
2286
2523
|
idempotentHint: true,
|
|
@@ -2288,10 +2525,10 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2288
2525
|
readOnlyHint: false
|
|
2289
2526
|
},
|
|
2290
2527
|
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.",
|
|
2291
|
-
inputSchema:
|
|
2292
|
-
outputSchema:
|
|
2528
|
+
inputSchema: inputSchema7,
|
|
2529
|
+
outputSchema: outputSchema7,
|
|
2293
2530
|
async execute(input) {
|
|
2294
|
-
const parsedInput =
|
|
2531
|
+
const parsedInput = inputSchema7.safeParse(input);
|
|
2295
2532
|
if (!parsedInput.success) {
|
|
2296
2533
|
throw new PluginToolInputError9("Invalid GitHub updateIssue input.", {
|
|
2297
2534
|
cause: parsedInput.error
|
|
@@ -2336,12 +2573,12 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2336
2573
|
`GitHub issue update failed with HTTP ${response.status}: ${githubApiErrorMessage3(parsed)}`
|
|
2337
2574
|
);
|
|
2338
2575
|
}
|
|
2339
|
-
const providerResult =
|
|
2340
|
-
body:
|
|
2341
|
-
html_url:
|
|
2342
|
-
number:
|
|
2343
|
-
state:
|
|
2344
|
-
title:
|
|
2576
|
+
const providerResult = z13.object({
|
|
2577
|
+
body: z13.string().nullable().optional().default(null),
|
|
2578
|
+
html_url: z13.string(),
|
|
2579
|
+
number: z13.number(),
|
|
2580
|
+
state: z13.string(),
|
|
2581
|
+
title: z13.string()
|
|
2345
2582
|
}).parse(parsed);
|
|
2346
2583
|
const subscribable = gitHubIssueSubscribable({
|
|
2347
2584
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -2374,22 +2611,22 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2374
2611
|
|
|
2375
2612
|
// src/tools/update-pull-request.ts
|
|
2376
2613
|
import {
|
|
2377
|
-
definePluginTool as
|
|
2614
|
+
definePluginTool as definePluginTool10,
|
|
2378
2615
|
PluginToolInputError as PluginToolInputError10,
|
|
2379
|
-
pluginToolOutputSchema as
|
|
2616
|
+
pluginToolOutputSchema as pluginToolOutputSchema10
|
|
2380
2617
|
} from "@sentry/junior-plugin-api";
|
|
2381
|
-
import { z as
|
|
2618
|
+
import { z as z14 } from "zod";
|
|
2382
2619
|
import { subscribableResourceSchema as subscribableResourceSchema8 } from "@sentry/junior-plugin-api";
|
|
2383
|
-
var
|
|
2384
|
-
repo:
|
|
2385
|
-
number:
|
|
2386
|
-
title:
|
|
2387
|
-
body:
|
|
2620
|
+
var inputSchema8 = z14.object({
|
|
2621
|
+
repo: z14.string().describe('Repository in "owner/name" format.'),
|
|
2622
|
+
number: z14.number().int().positive().describe("Pull request number."),
|
|
2623
|
+
title: z14.string().trim().min(1).optional().describe("Replacement pull request title."),
|
|
2624
|
+
body: z14.string().optional().describe(
|
|
2388
2625
|
"Replacement pull request body. The runtime appends requester attribution and the conversation footer."
|
|
2389
2626
|
),
|
|
2390
|
-
base:
|
|
2391
|
-
state:
|
|
2392
|
-
draft:
|
|
2627
|
+
base: z14.string().trim().min(1).optional().describe("Replacement base branch."),
|
|
2628
|
+
state: z14.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
|
|
2629
|
+
draft: z14.boolean().optional().describe(
|
|
2393
2630
|
"Set false to mark a draft pull request ready for review, or true to convert it back to a draft."
|
|
2394
2631
|
)
|
|
2395
2632
|
}).strict().refine(
|
|
@@ -2404,27 +2641,27 @@ var CONVERT_TO_DRAFT = {
|
|
|
2404
2641
|
operationName: "ConvertPullRequestToDraft",
|
|
2405
2642
|
query: "mutation ConvertPullRequestToDraft($id: ID!) { result: convertPullRequestToDraft(input: {pullRequestId: $id}) { pullRequest { isDraft } } }"
|
|
2406
2643
|
};
|
|
2407
|
-
var draftMutationResponseSchema =
|
|
2408
|
-
data:
|
|
2409
|
-
result:
|
|
2644
|
+
var draftMutationResponseSchema = z14.object({
|
|
2645
|
+
data: z14.object({
|
|
2646
|
+
result: z14.object({ pullRequest: z14.object({ isDraft: z14.boolean() }) })
|
|
2410
2647
|
})
|
|
2411
2648
|
});
|
|
2412
|
-
var graphqlErrorsSchema =
|
|
2413
|
-
errors:
|
|
2649
|
+
var graphqlErrorsSchema = z14.object({
|
|
2650
|
+
errors: z14.array(z14.object({ message: z14.string() })).min(1)
|
|
2414
2651
|
});
|
|
2415
|
-
var pullRequestSchema2 =
|
|
2416
|
-
base:
|
|
2417
|
-
body:
|
|
2418
|
-
draft:
|
|
2419
|
-
number:
|
|
2420
|
-
state:
|
|
2652
|
+
var pullRequestSchema2 = z14.object({
|
|
2653
|
+
base: z14.string(),
|
|
2654
|
+
body: z14.string().nullable(),
|
|
2655
|
+
draft: z14.boolean(),
|
|
2656
|
+
number: z14.number(),
|
|
2657
|
+
state: z14.string(),
|
|
2421
2658
|
subscribable: subscribableResourceSchema8.optional(),
|
|
2422
|
-
title:
|
|
2423
|
-
url:
|
|
2659
|
+
title: z14.string(),
|
|
2660
|
+
url: z14.string()
|
|
2424
2661
|
});
|
|
2425
|
-
var
|
|
2662
|
+
var outputSchema8 = pluginToolOutputSchema10.merge(
|
|
2426
2663
|
pullRequestSchema2.extend({
|
|
2427
|
-
target:
|
|
2664
|
+
target: z14.literal("updatePullRequest")
|
|
2428
2665
|
})
|
|
2429
2666
|
);
|
|
2430
2667
|
function nonEmptyString5(value, name) {
|
|
@@ -2486,7 +2723,7 @@ function githubGraphqlErrorMessage(payload) {
|
|
|
2486
2723
|
return result.success ? result.data.errors.map((error) => error.message).join("; ") : githubApiErrorMessage4(payload);
|
|
2487
2724
|
}
|
|
2488
2725
|
function createGitHubUpdatePullRequestTool(ctx) {
|
|
2489
|
-
return
|
|
2726
|
+
return definePluginTool10({
|
|
2490
2727
|
annotations: {
|
|
2491
2728
|
destructiveHint: true,
|
|
2492
2729
|
idempotentHint: true,
|
|
@@ -2494,10 +2731,10 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2494
2731
|
readOnlyHint: false
|
|
2495
2732
|
},
|
|
2496
2733
|
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.",
|
|
2497
|
-
inputSchema:
|
|
2498
|
-
outputSchema:
|
|
2734
|
+
inputSchema: inputSchema8,
|
|
2735
|
+
outputSchema: outputSchema8,
|
|
2499
2736
|
async execute(input) {
|
|
2500
|
-
const parsedInput =
|
|
2737
|
+
const parsedInput = inputSchema8.safeParse(input);
|
|
2501
2738
|
if (!parsedInput.success) {
|
|
2502
2739
|
throw new PluginToolInputError10(
|
|
2503
2740
|
"Invalid GitHub updatePullRequest input.",
|
|
@@ -2540,16 +2777,16 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2540
2777
|
`GitHub pull request update failed with HTTP ${response.status}: ${githubApiErrorMessage4(parsed)}`
|
|
2541
2778
|
);
|
|
2542
2779
|
}
|
|
2543
|
-
const providerResult =
|
|
2544
|
-
base:
|
|
2545
|
-
body:
|
|
2546
|
-
draft:
|
|
2547
|
-
html_url:
|
|
2548
|
-
merged:
|
|
2549
|
-
node_id:
|
|
2550
|
-
number:
|
|
2551
|
-
state:
|
|
2552
|
-
title:
|
|
2780
|
+
const providerResult = z14.object({
|
|
2781
|
+
base: z14.object({ ref: z14.string() }),
|
|
2782
|
+
body: z14.string().nullable().optional().default(null),
|
|
2783
|
+
draft: z14.boolean(),
|
|
2784
|
+
html_url: z14.string(),
|
|
2785
|
+
merged: z14.boolean(),
|
|
2786
|
+
node_id: z14.string().optional(),
|
|
2787
|
+
number: z14.number(),
|
|
2788
|
+
state: z14.string(),
|
|
2789
|
+
title: z14.string()
|
|
2553
2790
|
}).parse(parsed);
|
|
2554
2791
|
if (update.draft !== void 0 && update.draft !== providerResult.draft) {
|
|
2555
2792
|
if (!providerResult.node_id) {
|
|
@@ -2610,11 +2847,11 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2610
2847
|
|
|
2611
2848
|
// src/tools/update-pull-request-feedback.ts
|
|
2612
2849
|
import {
|
|
2613
|
-
definePluginTool as
|
|
2850
|
+
definePluginTool as definePluginTool11,
|
|
2614
2851
|
PluginToolInputError as PluginToolInputError11,
|
|
2615
|
-
pluginToolOutputSchema as
|
|
2852
|
+
pluginToolOutputSchema as pluginToolOutputSchema11
|
|
2616
2853
|
} from "@sentry/junior-plugin-api";
|
|
2617
|
-
import { z as
|
|
2854
|
+
import { z as z15 } from "zod";
|
|
2618
2855
|
var STATUS_TO_REACTION_CONTENT = {
|
|
2619
2856
|
reviewing: "eyes",
|
|
2620
2857
|
addressed: "+1",
|
|
@@ -2623,24 +2860,24 @@ var STATUS_TO_REACTION_CONTENT = {
|
|
|
2623
2860
|
var FEEDBACK_REACTION_CONTENTS = new Set(
|
|
2624
2861
|
Object.values(STATUS_TO_REACTION_CONTENT)
|
|
2625
2862
|
);
|
|
2626
|
-
var
|
|
2627
|
-
repo:
|
|
2628
|
-
|
|
2863
|
+
var inputSchema9 = z15.object({
|
|
2864
|
+
repo: z15.string().describe('Repository in "owner/name" format.'),
|
|
2865
|
+
comment_kind: z15.enum(["conversation", "review"]).describe(
|
|
2629
2866
|
'Comment kind: "conversation" for a pull request conversation comment, "review" for an inline review comment.'
|
|
2630
2867
|
),
|
|
2631
|
-
|
|
2868
|
+
comment_id: z15.number().int().positive().describe(
|
|
2632
2869
|
"GitHub comment id (conversation comment id or inline review comment id)."
|
|
2633
2870
|
),
|
|
2634
|
-
status:
|
|
2871
|
+
status: z15.enum(["addressed", "declined"]).describe(
|
|
2635
2872
|
"Feedback outcome. Maps to a reaction: addressed -> +1, declined -> -1."
|
|
2636
2873
|
)
|
|
2637
2874
|
}).strict();
|
|
2638
|
-
var
|
|
2639
|
-
target:
|
|
2640
|
-
repo:
|
|
2641
|
-
|
|
2642
|
-
status:
|
|
2643
|
-
|
|
2875
|
+
var outputSchema9 = pluginToolOutputSchema11.extend({
|
|
2876
|
+
target: z15.literal("updatePullRequestFeedback"),
|
|
2877
|
+
repo: z15.string(),
|
|
2878
|
+
comment_id: z15.number(),
|
|
2879
|
+
status: z15.enum(["addressed", "declined"]),
|
|
2880
|
+
reaction_id: z15.number()
|
|
2644
2881
|
});
|
|
2645
2882
|
function parseRepo10(value) {
|
|
2646
2883
|
const parts = value.split("/").map((part) => part.trim());
|
|
@@ -2675,10 +2912,10 @@ function githubError(payload) {
|
|
|
2675
2912
|
}
|
|
2676
2913
|
return "GitHub request failed";
|
|
2677
2914
|
}
|
|
2678
|
-
var reactionSchema =
|
|
2679
|
-
id:
|
|
2680
|
-
content:
|
|
2681
|
-
user:
|
|
2915
|
+
var reactionSchema = z15.object({
|
|
2916
|
+
id: z15.number(),
|
|
2917
|
+
content: z15.string(),
|
|
2918
|
+
user: z15.object({ id: z15.number() }).nullable()
|
|
2682
2919
|
});
|
|
2683
2920
|
async function assertBotAuthoredPullRequest(egress, input) {
|
|
2684
2921
|
const headers = {
|
|
@@ -2699,9 +2936,9 @@ async function assertBotAuthoredPullRequest(egress, input) {
|
|
|
2699
2936
|
if (commentResponse.status === 404) throw new PluginToolInputError11(message);
|
|
2700
2937
|
throw new Error(message);
|
|
2701
2938
|
}
|
|
2702
|
-
const comment =
|
|
2703
|
-
issue_url:
|
|
2704
|
-
pull_request_url:
|
|
2939
|
+
const comment = z15.object({
|
|
2940
|
+
issue_url: z15.string().optional(),
|
|
2941
|
+
pull_request_url: z15.string().optional()
|
|
2705
2942
|
}).safeParse(commentPayload);
|
|
2706
2943
|
const parentUrl = comment.success ? input.commentKind === "conversation" ? comment.data.issue_url : comment.data.pull_request_url : void 0;
|
|
2707
2944
|
const number = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
|
|
@@ -2722,7 +2959,7 @@ async function assertBotAuthoredPullRequest(egress, input) {
|
|
|
2722
2959
|
`GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${githubError(pullPayload)}`
|
|
2723
2960
|
);
|
|
2724
2961
|
}
|
|
2725
|
-
const pull =
|
|
2962
|
+
const pull = z15.object({ user: z15.object({ id: z15.number() }).nullable() }).safeParse(pullPayload);
|
|
2726
2963
|
if (!pullResponse.ok || !pull.success || pull.data.user?.id !== input.botUserId) {
|
|
2727
2964
|
throw new PluginToolInputError11(
|
|
2728
2965
|
"This bot can only set feedback status on comments on pull requests it authored."
|
|
@@ -2730,7 +2967,7 @@ async function assertBotAuthoredPullRequest(egress, input) {
|
|
|
2730
2967
|
}
|
|
2731
2968
|
}
|
|
2732
2969
|
function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
2733
|
-
return
|
|
2970
|
+
return definePluginTool11({
|
|
2734
2971
|
// No action review: the tool checks in code that the bot authored the pull
|
|
2735
2972
|
// request, and it changes only the bot's own reaction, which is reversible.
|
|
2736
2973
|
approvalMode: "approve",
|
|
@@ -2740,19 +2977,23 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2740
2977
|
openWorldHint: true,
|
|
2741
2978
|
readOnlyHint: false
|
|
2742
2979
|
},
|
|
2743
|
-
description: "Set your outcome reaction on GitHub pull request feedback: addressed (+1) or declined (-1). Use the
|
|
2980
|
+
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.",
|
|
2744
2981
|
exposure: "direct",
|
|
2745
|
-
inputSchema:
|
|
2746
|
-
outputSchema:
|
|
2982
|
+
inputSchema: inputSchema9,
|
|
2983
|
+
outputSchema: outputSchema9,
|
|
2747
2984
|
async execute(input) {
|
|
2748
|
-
const parsedInput =
|
|
2985
|
+
const parsedInput = inputSchema9.safeParse(input);
|
|
2749
2986
|
if (!parsedInput.success) {
|
|
2750
2987
|
throw new PluginToolInputError11(
|
|
2751
2988
|
"Invalid GitHub updatePullRequestFeedback input.",
|
|
2752
2989
|
{ cause: parsedInput.error }
|
|
2753
2990
|
);
|
|
2754
2991
|
}
|
|
2755
|
-
const {
|
|
2992
|
+
const {
|
|
2993
|
+
comment_id: commentId,
|
|
2994
|
+
comment_kind: commentKind,
|
|
2995
|
+
status
|
|
2996
|
+
} = parsedInput.data;
|
|
2756
2997
|
const repo = parseRepo10(parsedInput.data.repo);
|
|
2757
2998
|
const botUserId = botUserIdFromEmail(botEmail);
|
|
2758
2999
|
if (botUserId === void 0) {
|
|
@@ -2785,7 +3026,7 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2785
3026
|
`GitHub reaction lookup failed with HTTP ${listResponse.status}: ${githubError(listPayload)}`
|
|
2786
3027
|
);
|
|
2787
3028
|
}
|
|
2788
|
-
const botReactions =
|
|
3029
|
+
const botReactions = z15.array(reactionSchema).parse(listPayload).filter(
|
|
2789
3030
|
(reaction) => reaction.user?.id === botUserId && FEEDBACK_REACTION_CONTENTS.has(reaction.content)
|
|
2790
3031
|
);
|
|
2791
3032
|
const existing = botReactions.find(
|
|
@@ -2811,9 +3052,9 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2811
3052
|
return {
|
|
2812
3053
|
target: "updatePullRequestFeedback",
|
|
2813
3054
|
repo: repo.ref,
|
|
2814
|
-
commentId,
|
|
3055
|
+
comment_id: commentId,
|
|
2815
3056
|
status,
|
|
2816
|
-
|
|
3057
|
+
reaction_id: existing.id
|
|
2817
3058
|
};
|
|
2818
3059
|
}
|
|
2819
3060
|
const createResponse = await ctx.egress.fetch({
|
|
@@ -2838,9 +3079,9 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2838
3079
|
return {
|
|
2839
3080
|
target: "updatePullRequestFeedback",
|
|
2840
3081
|
repo: repo.ref,
|
|
2841
|
-
commentId,
|
|
3082
|
+
comment_id: commentId,
|
|
2842
3083
|
status,
|
|
2843
|
-
|
|
3084
|
+
reaction_id: created.id
|
|
2844
3085
|
};
|
|
2845
3086
|
}
|
|
2846
3087
|
});
|
|
@@ -2848,25 +3089,25 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2848
3089
|
|
|
2849
3090
|
// src/tools/resolve-pull-request-review-thread.ts
|
|
2850
3091
|
import {
|
|
2851
|
-
definePluginTool as
|
|
3092
|
+
definePluginTool as definePluginTool12,
|
|
2852
3093
|
PluginToolInputError as PluginToolInputError12,
|
|
2853
|
-
pluginToolOutputSchema as
|
|
3094
|
+
pluginToolOutputSchema as pluginToolOutputSchema12
|
|
2854
3095
|
} from "@sentry/junior-plugin-api";
|
|
2855
|
-
import { z as
|
|
2856
|
-
var
|
|
2857
|
-
repo:
|
|
3096
|
+
import { z as z16 } from "zod";
|
|
3097
|
+
var inputSchema10 = z16.object({
|
|
3098
|
+
repo: z16.string().describe(
|
|
2858
3099
|
'Repository in "owner/name" format. Required because GraphQL has no repo path.'
|
|
2859
3100
|
),
|
|
2860
|
-
|
|
2861
|
-
"GitHub pull request review thread node ID (the
|
|
3101
|
+
thread_id: z16.string().trim().min(1).describe(
|
|
3102
|
+
"GitHub pull request review thread node ID (the `threadId` / `id` variable used by `gh api graphql` resolveReviewThread)."
|
|
2862
3103
|
)
|
|
2863
3104
|
}).strict();
|
|
2864
|
-
var
|
|
2865
|
-
target:
|
|
2866
|
-
repo:
|
|
2867
|
-
number:
|
|
2868
|
-
|
|
2869
|
-
resolved:
|
|
3105
|
+
var outputSchema10 = pluginToolOutputSchema12.extend({
|
|
3106
|
+
target: z16.literal("resolvePullRequestReviewThread"),
|
|
3107
|
+
repo: z16.string(),
|
|
3108
|
+
number: z16.number(),
|
|
3109
|
+
thread_id: z16.string(),
|
|
3110
|
+
resolved: z16.boolean()
|
|
2870
3111
|
});
|
|
2871
3112
|
function parseRepo11(value) {
|
|
2872
3113
|
const parts = value.split("/").map((part) => part.trim());
|
|
@@ -2892,7 +3133,7 @@ function githubError2(payload) {
|
|
|
2892
3133
|
return "GitHub request failed";
|
|
2893
3134
|
}
|
|
2894
3135
|
function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
2895
|
-
return
|
|
3136
|
+
return definePluginTool12({
|
|
2896
3137
|
// No action review: the tool checks in code that the bot authored the pull
|
|
2897
3138
|
// request, and it changes only the thread's resolved state, which is
|
|
2898
3139
|
// reversible.
|
|
@@ -2905,10 +3146,10 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
2905
3146
|
},
|
|
2906
3147
|
description: "Resolve a GitHub pull request review thread after acting on its feedback. Only works on pull requests the bot authored.",
|
|
2907
3148
|
exposure: "direct",
|
|
2908
|
-
inputSchema:
|
|
2909
|
-
outputSchema:
|
|
3149
|
+
inputSchema: inputSchema10,
|
|
3150
|
+
outputSchema: outputSchema10,
|
|
2910
3151
|
async execute(input) {
|
|
2911
|
-
const parsedInput =
|
|
3152
|
+
const parsedInput = inputSchema10.safeParse(input);
|
|
2912
3153
|
if (!parsedInput.success) {
|
|
2913
3154
|
throw new PluginToolInputError12(
|
|
2914
3155
|
"Invalid GitHub resolvePullRequestReviewThread input.",
|
|
@@ -2942,7 +3183,7 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
2942
3183
|
body: JSON.stringify({
|
|
2943
3184
|
operationName: "ReviewThreadOwnership",
|
|
2944
3185
|
query,
|
|
2945
|
-
variables: { threadId: parsedInput.data.
|
|
3186
|
+
variables: { threadId: parsedInput.data.thread_id }
|
|
2946
3187
|
})
|
|
2947
3188
|
})
|
|
2948
3189
|
});
|
|
@@ -2952,18 +3193,18 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
2952
3193
|
`GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubError2(lookupPayload)}`
|
|
2953
3194
|
);
|
|
2954
3195
|
}
|
|
2955
|
-
const threadNodeSchema =
|
|
2956
|
-
id:
|
|
2957
|
-
isResolved:
|
|
2958
|
-
pullRequest:
|
|
2959
|
-
author:
|
|
2960
|
-
number:
|
|
2961
|
-
repository:
|
|
3196
|
+
const threadNodeSchema = z16.object({
|
|
3197
|
+
id: z16.string(),
|
|
3198
|
+
isResolved: z16.boolean(),
|
|
3199
|
+
pullRequest: z16.object({
|
|
3200
|
+
author: z16.object({ databaseId: z16.number().optional() }).passthrough().nullable(),
|
|
3201
|
+
number: z16.number(),
|
|
3202
|
+
repository: z16.object({ nameWithOwner: z16.string() }).passthrough()
|
|
2962
3203
|
}).passthrough()
|
|
2963
3204
|
}).passthrough();
|
|
2964
|
-
const lookupResultSchema =
|
|
2965
|
-
data:
|
|
2966
|
-
node:
|
|
3205
|
+
const lookupResultSchema = z16.object({
|
|
3206
|
+
data: z16.object({
|
|
3207
|
+
node: z16.unknown().nullable().optional()
|
|
2967
3208
|
}).passthrough()
|
|
2968
3209
|
}).passthrough();
|
|
2969
3210
|
const lookupResult = lookupResultSchema.safeParse(lookupPayload);
|
|
@@ -2985,7 +3226,7 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
2985
3226
|
target: "resolvePullRequestReviewThread",
|
|
2986
3227
|
repo: repo.ref,
|
|
2987
3228
|
number: pullRequest.number,
|
|
2988
|
-
|
|
3229
|
+
thread_id: thread.id,
|
|
2989
3230
|
resolved: true
|
|
2990
3231
|
};
|
|
2991
3232
|
}
|
|
@@ -3013,10 +3254,10 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3013
3254
|
`GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubError2(resolvePayload)}`
|
|
3014
3255
|
);
|
|
3015
3256
|
}
|
|
3016
|
-
const resolveResultSchema =
|
|
3017
|
-
data:
|
|
3018
|
-
resolveReviewThread:
|
|
3019
|
-
thread:
|
|
3257
|
+
const resolveResultSchema = z16.object({
|
|
3258
|
+
data: z16.object({
|
|
3259
|
+
resolveReviewThread: z16.object({
|
|
3260
|
+
thread: z16.object({ id: z16.string(), isResolved: z16.boolean() }).passthrough()
|
|
3020
3261
|
}).passthrough()
|
|
3021
3262
|
}).passthrough()
|
|
3022
3263
|
}).passthrough();
|
|
@@ -3035,7 +3276,7 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3035
3276
|
target: "resolvePullRequestReviewThread",
|
|
3036
3277
|
repo: repo.ref,
|
|
3037
3278
|
number: pullRequest.number,
|
|
3038
|
-
|
|
3279
|
+
thread_id: resolved.id,
|
|
3039
3280
|
resolved: true
|
|
3040
3281
|
};
|
|
3041
3282
|
}
|
|
@@ -3044,36 +3285,36 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3044
3285
|
|
|
3045
3286
|
// src/tools/submit-pull-request-review.ts
|
|
3046
3287
|
import {
|
|
3047
|
-
definePluginTool as
|
|
3288
|
+
definePluginTool as definePluginTool13,
|
|
3048
3289
|
PluginToolInputError as PluginToolInputError13,
|
|
3049
|
-
pluginToolOutputSchema as
|
|
3290
|
+
pluginToolOutputSchema as pluginToolOutputSchema13
|
|
3050
3291
|
} from "@sentry/junior-plugin-api";
|
|
3051
|
-
import { z as
|
|
3052
|
-
var reviewCommentSchema =
|
|
3053
|
-
path:
|
|
3054
|
-
body:
|
|
3055
|
-
line:
|
|
3056
|
-
side:
|
|
3057
|
-
|
|
3058
|
-
|
|
3292
|
+
import { z as z17 } from "zod";
|
|
3293
|
+
var reviewCommentSchema = z17.object({
|
|
3294
|
+
path: z17.string().trim().min(1).describe("File path in the pull request."),
|
|
3295
|
+
body: z17.string().trim().min(1).describe("Inline review comment."),
|
|
3296
|
+
line: z17.number().int().positive().describe("Line in the pull request diff."),
|
|
3297
|
+
side: z17.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
|
|
3298
|
+
start_line: z17.number().int().positive().optional().describe("First line of a multi-line comment."),
|
|
3299
|
+
start_side: z17.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
|
|
3059
3300
|
}).strict().refine(
|
|
3060
|
-
({
|
|
3061
|
-
{ message: "
|
|
3301
|
+
({ start_line, start_side }) => start_line === void 0 === (start_side === void 0),
|
|
3302
|
+
{ message: "start_line and start_side must be provided together." }
|
|
3062
3303
|
);
|
|
3063
|
-
var
|
|
3064
|
-
repo:
|
|
3065
|
-
number:
|
|
3066
|
-
event:
|
|
3067
|
-
body:
|
|
3068
|
-
comments:
|
|
3304
|
+
var inputSchema11 = z17.object({
|
|
3305
|
+
repo: z17.string().describe('Repository in "owner/name" format.'),
|
|
3306
|
+
number: z17.number().int().positive().describe("Pull request number."),
|
|
3307
|
+
event: z17.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
|
|
3308
|
+
body: z17.string().trim().min(1).describe("Review summary."),
|
|
3309
|
+
comments: z17.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
|
|
3069
3310
|
}).strict();
|
|
3070
|
-
var
|
|
3071
|
-
target:
|
|
3072
|
-
repo:
|
|
3073
|
-
number:
|
|
3074
|
-
|
|
3075
|
-
state:
|
|
3076
|
-
url:
|
|
3311
|
+
var outputSchema11 = pluginToolOutputSchema13.extend({
|
|
3312
|
+
target: z17.literal("submitPullRequestReview"),
|
|
3313
|
+
repo: z17.string(),
|
|
3314
|
+
number: z17.number(),
|
|
3315
|
+
review_id: z17.number(),
|
|
3316
|
+
state: z17.string(),
|
|
3317
|
+
url: z17.string()
|
|
3077
3318
|
});
|
|
3078
3319
|
function parseRepo12(value) {
|
|
3079
3320
|
const parts = value.split("/").map((part) => part.trim());
|
|
@@ -3107,7 +3348,7 @@ function throwReviewError(status, body) {
|
|
|
3107
3348
|
throw new Error(message);
|
|
3108
3349
|
}
|
|
3109
3350
|
function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
3110
|
-
return
|
|
3351
|
+
return definePluginTool13({
|
|
3111
3352
|
annotations: {
|
|
3112
3353
|
destructiveHint: true,
|
|
3113
3354
|
idempotentHint: false,
|
|
@@ -3116,8 +3357,8 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3116
3357
|
},
|
|
3117
3358
|
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.",
|
|
3118
3359
|
exposure: "direct",
|
|
3119
|
-
inputSchema:
|
|
3120
|
-
outputSchema:
|
|
3360
|
+
inputSchema: inputSchema11,
|
|
3361
|
+
outputSchema: outputSchema11,
|
|
3121
3362
|
async execute(review) {
|
|
3122
3363
|
const repo = parseRepo12(review.repo);
|
|
3123
3364
|
const comments = review.comments?.map((comment) => ({
|
|
@@ -3125,8 +3366,8 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3125
3366
|
body: comment.body,
|
|
3126
3367
|
line: comment.line,
|
|
3127
3368
|
side: comment.side,
|
|
3128
|
-
...comment.
|
|
3129
|
-
...comment.
|
|
3369
|
+
...comment.start_line !== void 0 ? { start_line: comment.start_line } : void 0,
|
|
3370
|
+
...comment.start_side !== void 0 ? { start_side: comment.start_side } : void 0
|
|
3130
3371
|
}));
|
|
3131
3372
|
const response = await egress.fetch({
|
|
3132
3373
|
provider: "github",
|
|
@@ -3152,12 +3393,12 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3152
3393
|
if (!response.ok) {
|
|
3153
3394
|
throwReviewError(response.status, parsed);
|
|
3154
3395
|
}
|
|
3155
|
-
const providerResult =
|
|
3396
|
+
const providerResult = z17.object({ id: z17.number(), html_url: z17.string(), state: z17.string() }).parse(parsed);
|
|
3156
3397
|
return {
|
|
3157
3398
|
target: "submitPullRequestReview",
|
|
3158
3399
|
repo: repo.ref,
|
|
3159
3400
|
number: review.number,
|
|
3160
|
-
|
|
3401
|
+
review_id: providerResult.id,
|
|
3161
3402
|
state: providerResult.state,
|
|
3162
3403
|
url: providerResult.html_url
|
|
3163
3404
|
};
|
|
@@ -3178,6 +3419,7 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
3178
3419
|
getPullRequest: createGitHubGetPullRequestTool(ctx),
|
|
3179
3420
|
getRelease: createGitHubGetReleaseTool(ctx),
|
|
3180
3421
|
getRepository: createGitHubGetRepositoryTool(ctx),
|
|
3422
|
+
getStatus: createGitHubGetStatusTool(ctx),
|
|
3181
3423
|
resolvePullRequestReviewThread: createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail),
|
|
3182
3424
|
submitPullRequestReview: createGitHubSubmitPullRequestReviewTool(
|
|
3183
3425
|
ctx.egress
|
|
@@ -3193,26 +3435,26 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
3193
3435
|
|
|
3194
3436
|
// src/webhooks/handler.ts
|
|
3195
3437
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
3196
|
-
import { z as
|
|
3438
|
+
import { z as z27 } from "zod";
|
|
3197
3439
|
|
|
3198
3440
|
// src/issue-outcomes/store.ts
|
|
3199
3441
|
import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
|
|
3200
|
-
import { z as
|
|
3201
|
-
var githubIssueOutcomeInputSchema =
|
|
3202
|
-
candidateOwned:
|
|
3203
|
-
closedAt:
|
|
3204
|
-
issueId:
|
|
3205
|
-
number:
|
|
3206
|
-
openedAt:
|
|
3207
|
-
repositoryFullName:
|
|
3208
|
-
repositoryId:
|
|
3442
|
+
import { z as z18 } from "zod";
|
|
3443
|
+
var githubIssueOutcomeInputSchema = z18.object({
|
|
3444
|
+
candidateOwned: z18.boolean(),
|
|
3445
|
+
closedAt: z18.date().optional(),
|
|
3446
|
+
issueId: z18.string().min(1),
|
|
3447
|
+
number: z18.number().int().positive(),
|
|
3448
|
+
openedAt: z18.date(),
|
|
3449
|
+
repositoryFullName: z18.string().min(1),
|
|
3450
|
+
repositoryId: z18.string().min(1),
|
|
3209
3451
|
state: githubIssueStateSchema,
|
|
3210
3452
|
stateReason: githubIssueStateReasonSchema.optional(),
|
|
3211
|
-
updatedAt:
|
|
3453
|
+
updatedAt: z18.date()
|
|
3212
3454
|
}).strict();
|
|
3213
|
-
var githubIssueConversationsInputSchema =
|
|
3214
|
-
conversationIds:
|
|
3215
|
-
issueId:
|
|
3455
|
+
var githubIssueConversationsInputSchema = z18.object({
|
|
3456
|
+
conversationIds: z18.array(z18.string().min(1)).min(1),
|
|
3457
|
+
issueId: z18.string().min(1)
|
|
3216
3458
|
}).strict();
|
|
3217
3459
|
function projectionValues(input) {
|
|
3218
3460
|
return {
|
|
@@ -3276,33 +3518,33 @@ async function recordGitHubIssueConversations(db, input) {
|
|
|
3276
3518
|
|
|
3277
3519
|
// src/pull-request-outcomes/store.ts
|
|
3278
3520
|
import { and as and3, eq as eq3, lte as lte2, ne, sql as sql3 } from "drizzle-orm";
|
|
3279
|
-
import { z as
|
|
3280
|
-
var githubPullRequestOutcomeInputSchema =
|
|
3281
|
-
candidateOwned:
|
|
3282
|
-
closedAt:
|
|
3521
|
+
import { z as z19 } from "zod";
|
|
3522
|
+
var githubPullRequestOutcomeInputSchema = z19.object({
|
|
3523
|
+
candidateOwned: z19.boolean(),
|
|
3524
|
+
closedAt: z19.date().optional(),
|
|
3283
3525
|
commitComposition: githubPullRequestCommitCompositionSchema.optional(),
|
|
3284
|
-
mergedAt:
|
|
3285
|
-
number:
|
|
3286
|
-
openedAt:
|
|
3287
|
-
pullRequestId:
|
|
3288
|
-
repositoryFullName:
|
|
3289
|
-
repositoryId:
|
|
3526
|
+
mergedAt: z19.date().optional(),
|
|
3527
|
+
number: z19.number().int().positive(),
|
|
3528
|
+
openedAt: z19.date(),
|
|
3529
|
+
pullRequestId: z19.string().min(1),
|
|
3530
|
+
repositoryFullName: z19.string().min(1),
|
|
3531
|
+
repositoryId: z19.string().min(1),
|
|
3290
3532
|
state: githubPullRequestStateSchema,
|
|
3291
|
-
title:
|
|
3292
|
-
updatedAt:
|
|
3533
|
+
title: z19.string().min(1).optional(),
|
|
3534
|
+
updatedAt: z19.date()
|
|
3293
3535
|
}).strict();
|
|
3294
|
-
var githubPullRequestConversationsInputSchema =
|
|
3295
|
-
conversationIds:
|
|
3296
|
-
pullRequestId:
|
|
3536
|
+
var githubPullRequestConversationsInputSchema = z19.object({
|
|
3537
|
+
conversationIds: z19.array(z19.string().min(1)).min(1),
|
|
3538
|
+
pullRequestId: z19.string().min(1)
|
|
3297
3539
|
}).strict();
|
|
3298
|
-
var githubPullRequestLinkedIssuesInputSchema =
|
|
3299
|
-
linkedIssues:
|
|
3300
|
-
|
|
3301
|
-
number:
|
|
3302
|
-
repositoryFullName:
|
|
3540
|
+
var githubPullRequestLinkedIssuesInputSchema = z19.object({
|
|
3541
|
+
linkedIssues: z19.array(
|
|
3542
|
+
z19.object({
|
|
3543
|
+
number: z19.number().int().positive(),
|
|
3544
|
+
repositoryFullName: z19.string().min(1)
|
|
3303
3545
|
}).strict()
|
|
3304
3546
|
).min(1),
|
|
3305
|
-
pullRequestId:
|
|
3547
|
+
pullRequestId: z19.string().min(1)
|
|
3306
3548
|
}).strict();
|
|
3307
3549
|
function projectionValues2(input) {
|
|
3308
3550
|
return {
|
|
@@ -3370,7 +3612,7 @@ async function listGitHubUnfinishedWork(db, conversationIds) {
|
|
|
3370
3612
|
);
|
|
3371
3613
|
const rows = await db.select({ conversationIds: juniorGitHubPullRequests.conversationIds }).from(juniorGitHubPullRequests).where(
|
|
3372
3614
|
and3(
|
|
3373
|
-
|
|
3615
|
+
eq3(juniorGitHubPullRequests.state, "open"),
|
|
3374
3616
|
sql3`${juniorGitHubPullRequests.conversationIds} && ARRAY[${values}]::text[]`
|
|
3375
3617
|
)
|
|
3376
3618
|
);
|
|
@@ -3383,23 +3625,25 @@ async function listGitHubFinishedWork(db, conversationIds) {
|
|
|
3383
3625
|
sql3`, `
|
|
3384
3626
|
);
|
|
3385
3627
|
const rows = await db.select({
|
|
3628
|
+
closedAt: juniorGitHubPullRequests.closedAt,
|
|
3386
3629
|
conversationIds: juniorGitHubPullRequests.conversationIds,
|
|
3387
3630
|
mergedAt: juniorGitHubPullRequests.mergedAt
|
|
3388
3631
|
}).from(juniorGitHubPullRequests).where(
|
|
3389
3632
|
and3(
|
|
3390
|
-
|
|
3633
|
+
ne(juniorGitHubPullRequests.state, "open"),
|
|
3391
3634
|
sql3`${juniorGitHubPullRequests.conversationIds} && ARRAY[${values}]::text[]`
|
|
3392
3635
|
)
|
|
3393
3636
|
);
|
|
3394
3637
|
const candidates = new Set(conversationIds);
|
|
3395
3638
|
const finishedAtById = /* @__PURE__ */ new Map();
|
|
3396
3639
|
for (const row of rows) {
|
|
3397
|
-
|
|
3640
|
+
const finishedAt = row.mergedAt ?? row.closedAt;
|
|
3641
|
+
if (!finishedAt) continue;
|
|
3398
3642
|
for (const conversationId of row.conversationIds) {
|
|
3399
3643
|
if (!candidates.has(conversationId)) continue;
|
|
3400
3644
|
const current = finishedAtById.get(conversationId);
|
|
3401
|
-
if (!current ||
|
|
3402
|
-
finishedAtById.set(conversationId,
|
|
3645
|
+
if (!current || finishedAt > current) {
|
|
3646
|
+
finishedAtById.set(conversationId, finishedAt);
|
|
3403
3647
|
}
|
|
3404
3648
|
}
|
|
3405
3649
|
}
|
|
@@ -3505,39 +3749,39 @@ async function releaseGitHubPullRequestReadySync(db, target, claim) {
|
|
|
3505
3749
|
}
|
|
3506
3750
|
|
|
3507
3751
|
// src/webhooks/issue-outcome.ts
|
|
3508
|
-
import { z as
|
|
3509
|
-
var canonicalIssueOutcomeSchema =
|
|
3510
|
-
action:
|
|
3511
|
-
issue:
|
|
3512
|
-
body:
|
|
3513
|
-
closed_at:
|
|
3514
|
-
created_at:
|
|
3515
|
-
id:
|
|
3516
|
-
number:
|
|
3752
|
+
import { z as z20 } from "zod";
|
|
3753
|
+
var canonicalIssueOutcomeSchema = z20.object({
|
|
3754
|
+
action: z20.enum(["opened", "closed", "reopened"]),
|
|
3755
|
+
issue: z20.object({
|
|
3756
|
+
body: z20.string().nullable().optional(),
|
|
3757
|
+
closed_at: z20.string().nullable().optional(),
|
|
3758
|
+
created_at: z20.string(),
|
|
3759
|
+
id: z20.number().int().positive(),
|
|
3760
|
+
number: z20.number().int().positive(),
|
|
3517
3761
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3518
|
-
updated_at:
|
|
3519
|
-
user:
|
|
3762
|
+
updated_at: z20.string(),
|
|
3763
|
+
user: z20.object({ login: z20.string().min(1) }).strict()
|
|
3520
3764
|
}).strict(),
|
|
3521
|
-
repository:
|
|
3522
|
-
full_name:
|
|
3523
|
-
id:
|
|
3765
|
+
repository: z20.object({
|
|
3766
|
+
full_name: z20.string().min(1),
|
|
3767
|
+
id: z20.number().int().positive()
|
|
3524
3768
|
}).strict()
|
|
3525
3769
|
}).strict();
|
|
3526
|
-
var issueOutcomeSchema =
|
|
3527
|
-
action:
|
|
3528
|
-
issue:
|
|
3529
|
-
body:
|
|
3530
|
-
closed_at:
|
|
3531
|
-
created_at:
|
|
3532
|
-
id:
|
|
3533
|
-
number:
|
|
3770
|
+
var issueOutcomeSchema = z20.object({
|
|
3771
|
+
action: z20.enum(["opened", "closed", "reopened"]),
|
|
3772
|
+
issue: z20.object({
|
|
3773
|
+
body: z20.string().nullable().optional(),
|
|
3774
|
+
closed_at: z20.string().nullable().optional(),
|
|
3775
|
+
created_at: z20.string(),
|
|
3776
|
+
id: z20.number().int().positive(),
|
|
3777
|
+
number: z20.number().int().positive(),
|
|
3534
3778
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3535
|
-
updated_at:
|
|
3536
|
-
user:
|
|
3779
|
+
updated_at: z20.string(),
|
|
3780
|
+
user: z20.object({ login: z20.string().min(1) }).passthrough()
|
|
3537
3781
|
}).passthrough(),
|
|
3538
|
-
repository:
|
|
3539
|
-
full_name:
|
|
3540
|
-
id:
|
|
3782
|
+
repository: z20.object({
|
|
3783
|
+
full_name: z20.string().min(1),
|
|
3784
|
+
id: z20.number().int().positive()
|
|
3541
3785
|
}).passthrough()
|
|
3542
3786
|
}).passthrough().transform(
|
|
3543
3787
|
(provider) => canonicalIssueOutcomeSchema.parse({
|
|
@@ -3558,7 +3802,7 @@ var issueOutcomeSchema = z17.object({
|
|
|
3558
3802
|
}
|
|
3559
3803
|
})
|
|
3560
3804
|
);
|
|
3561
|
-
var issueLifecycleActionSchema =
|
|
3805
|
+
var issueLifecycleActionSchema = z20.object({ action: z20.string() }).passthrough();
|
|
3562
3806
|
function timestamp2(value) {
|
|
3563
3807
|
if (!value) return void 0;
|
|
3564
3808
|
const parsed = new Date(value);
|
|
@@ -3602,21 +3846,21 @@ function normalizeGitHubIssueOutcome(args) {
|
|
|
3602
3846
|
updatedAt
|
|
3603
3847
|
};
|
|
3604
3848
|
}
|
|
3605
|
-
var canonicalIssueConversationSchema =
|
|
3606
|
-
issue:
|
|
3607
|
-
body:
|
|
3608
|
-
id:
|
|
3609
|
-
user:
|
|
3849
|
+
var canonicalIssueConversationSchema = z20.object({
|
|
3850
|
+
issue: z20.object({
|
|
3851
|
+
body: z20.string().nullable().optional(),
|
|
3852
|
+
id: z20.number().int().positive(),
|
|
3853
|
+
user: z20.object({ login: z20.string().min(1) }).strict()
|
|
3610
3854
|
}).strict(),
|
|
3611
|
-
sender:
|
|
3855
|
+
sender: z20.object({ login: z20.string().min(1) }).strict().optional()
|
|
3612
3856
|
}).strict();
|
|
3613
|
-
var issueConversationSchema =
|
|
3614
|
-
issue:
|
|
3615
|
-
body:
|
|
3616
|
-
id:
|
|
3617
|
-
user:
|
|
3857
|
+
var issueConversationSchema = z20.object({
|
|
3858
|
+
issue: z20.object({
|
|
3859
|
+
body: z20.string().nullable().optional(),
|
|
3860
|
+
id: z20.number().int().positive(),
|
|
3861
|
+
user: z20.object({ login: z20.string().min(1) }).passthrough()
|
|
3618
3862
|
}).passthrough(),
|
|
3619
|
-
sender:
|
|
3863
|
+
sender: z20.object({ login: z20.string().min(1) }).passthrough().optional()
|
|
3620
3864
|
}).passthrough().transform(
|
|
3621
3865
|
(provider) => canonicalIssueConversationSchema.parse({
|
|
3622
3866
|
issue: {
|
|
@@ -3643,43 +3887,43 @@ function normalizeGitHubIssueConversations(args) {
|
|
|
3643
3887
|
}
|
|
3644
3888
|
|
|
3645
3889
|
// src/webhooks/pull-request-outcome.ts
|
|
3646
|
-
import { z as
|
|
3647
|
-
var canonicalPullRequestOutcomeSchema =
|
|
3648
|
-
action:
|
|
3649
|
-
pull_request:
|
|
3650
|
-
body:
|
|
3651
|
-
closed_at:
|
|
3652
|
-
created_at:
|
|
3653
|
-
id:
|
|
3654
|
-
merged:
|
|
3655
|
-
merged_at:
|
|
3656
|
-
number:
|
|
3657
|
-
title:
|
|
3658
|
-
updated_at:
|
|
3659
|
-
user:
|
|
3890
|
+
import { z as z21 } from "zod";
|
|
3891
|
+
var canonicalPullRequestOutcomeSchema = z21.object({
|
|
3892
|
+
action: z21.enum(["opened", "closed", "reopened"]),
|
|
3893
|
+
pull_request: z21.object({
|
|
3894
|
+
body: z21.string().nullable().optional(),
|
|
3895
|
+
closed_at: z21.string().nullable().optional(),
|
|
3896
|
+
created_at: z21.string(),
|
|
3897
|
+
id: z21.number().int().positive(),
|
|
3898
|
+
merged: z21.boolean(),
|
|
3899
|
+
merged_at: z21.string().nullable().optional(),
|
|
3900
|
+
number: z21.number().int().positive(),
|
|
3901
|
+
title: z21.string().min(1).optional(),
|
|
3902
|
+
updated_at: z21.string(),
|
|
3903
|
+
user: z21.object({ login: z21.string().min(1) }).strict()
|
|
3660
3904
|
}).strict(),
|
|
3661
|
-
repository:
|
|
3662
|
-
full_name:
|
|
3663
|
-
id:
|
|
3905
|
+
repository: z21.object({
|
|
3906
|
+
full_name: z21.string().min(1),
|
|
3907
|
+
id: z21.number().int().positive()
|
|
3664
3908
|
}).strict()
|
|
3665
3909
|
}).strict();
|
|
3666
|
-
var pullRequestOutcomeSchema =
|
|
3667
|
-
action:
|
|
3668
|
-
pull_request:
|
|
3669
|
-
body:
|
|
3670
|
-
closed_at:
|
|
3671
|
-
created_at:
|
|
3672
|
-
id:
|
|
3673
|
-
merged:
|
|
3674
|
-
merged_at:
|
|
3675
|
-
number:
|
|
3676
|
-
title:
|
|
3677
|
-
updated_at:
|
|
3678
|
-
user:
|
|
3910
|
+
var pullRequestOutcomeSchema = z21.object({
|
|
3911
|
+
action: z21.enum(["opened", "closed", "reopened"]),
|
|
3912
|
+
pull_request: z21.object({
|
|
3913
|
+
body: z21.string().nullable().optional(),
|
|
3914
|
+
closed_at: z21.string().nullable().optional(),
|
|
3915
|
+
created_at: z21.string(),
|
|
3916
|
+
id: z21.number().int().positive(),
|
|
3917
|
+
merged: z21.boolean(),
|
|
3918
|
+
merged_at: z21.string().nullable().optional(),
|
|
3919
|
+
number: z21.number().int().positive(),
|
|
3920
|
+
title: z21.string().min(1).optional(),
|
|
3921
|
+
updated_at: z21.string(),
|
|
3922
|
+
user: z21.object({ login: z21.string().min(1) }).passthrough()
|
|
3679
3923
|
}).passthrough(),
|
|
3680
|
-
repository:
|
|
3681
|
-
full_name:
|
|
3682
|
-
id:
|
|
3924
|
+
repository: z21.object({
|
|
3925
|
+
full_name: z21.string().min(1),
|
|
3926
|
+
id: z21.number().int().positive()
|
|
3683
3927
|
}).passthrough()
|
|
3684
3928
|
}).passthrough().transform(
|
|
3685
3929
|
(provider) => canonicalPullRequestOutcomeSchema.parse({
|
|
@@ -3702,24 +3946,24 @@ var pullRequestOutcomeSchema = z18.object({
|
|
|
3702
3946
|
}
|
|
3703
3947
|
})
|
|
3704
3948
|
);
|
|
3705
|
-
var pullRequestLifecycleActionSchema =
|
|
3706
|
-
var canonicalPullRequestConversationSchema =
|
|
3707
|
-
pull_request:
|
|
3708
|
-
body:
|
|
3709
|
-
id:
|
|
3710
|
-
user:
|
|
3949
|
+
var pullRequestLifecycleActionSchema = z21.object({ action: z21.string() }).passthrough();
|
|
3950
|
+
var canonicalPullRequestConversationSchema = z21.object({
|
|
3951
|
+
pull_request: z21.object({
|
|
3952
|
+
body: z21.string().nullable().optional(),
|
|
3953
|
+
id: z21.number().int().positive(),
|
|
3954
|
+
user: z21.object({ login: z21.string().min(1) }).strict()
|
|
3711
3955
|
}).strict(),
|
|
3712
|
-
repository:
|
|
3713
|
-
sender:
|
|
3956
|
+
repository: z21.object({ full_name: z21.string().min(1) }).strict(),
|
|
3957
|
+
sender: z21.object({ login: z21.string().min(1) }).strict()
|
|
3714
3958
|
}).strict();
|
|
3715
|
-
var pullRequestConversationSchema =
|
|
3716
|
-
pull_request:
|
|
3717
|
-
body:
|
|
3718
|
-
id:
|
|
3719
|
-
user:
|
|
3959
|
+
var pullRequestConversationSchema = z21.object({
|
|
3960
|
+
pull_request: z21.object({
|
|
3961
|
+
body: z21.string().nullable().optional(),
|
|
3962
|
+
id: z21.number().int().positive(),
|
|
3963
|
+
user: z21.object({ login: z21.string().min(1) }).passthrough()
|
|
3720
3964
|
}).passthrough(),
|
|
3721
|
-
repository:
|
|
3722
|
-
sender:
|
|
3965
|
+
repository: z21.object({ full_name: z21.string().min(1) }).passthrough(),
|
|
3966
|
+
sender: z21.object({ login: z21.string().min(1) }).passthrough()
|
|
3723
3967
|
}).passthrough().transform(
|
|
3724
3968
|
(provider) => canonicalPullRequestConversationSchema.parse({
|
|
3725
3969
|
pull_request: {
|
|
@@ -3806,20 +4050,20 @@ function normalizeGitHubPullRequestLinkedIssues(args) {
|
|
|
3806
4050
|
}
|
|
3807
4051
|
|
|
3808
4052
|
// src/webhooks/merge-conflict.ts
|
|
3809
|
-
import { z as
|
|
4053
|
+
import { z as z22 } from "zod";
|
|
3810
4054
|
var EVENT_TYPE = "pull_request.merge_conflict";
|
|
3811
4055
|
var CLOSED_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
3812
4056
|
"pull_request.closed_unmerged",
|
|
3813
4057
|
"pull_request.merged"
|
|
3814
4058
|
]);
|
|
3815
|
-
var pullRequestSchema3 =
|
|
3816
|
-
base:
|
|
3817
|
-
number:
|
|
3818
|
-
head:
|
|
3819
|
-
html_url:
|
|
3820
|
-
mergeable:
|
|
3821
|
-
mergeable_state:
|
|
3822
|
-
state:
|
|
4059
|
+
var pullRequestSchema3 = z22.object({
|
|
4060
|
+
base: z22.object({ ref: z22.string().min(1) }),
|
|
4061
|
+
number: z22.number().int().positive().optional(),
|
|
4062
|
+
head: z22.object({ sha: z22.string().min(1) }),
|
|
4063
|
+
html_url: z22.string().min(1).optional(),
|
|
4064
|
+
mergeable: z22.boolean().nullable().optional(),
|
|
4065
|
+
mergeable_state: z22.string().optional(),
|
|
4066
|
+
state: z22.string()
|
|
3823
4067
|
});
|
|
3824
4068
|
function gitHubMergeConflictEvents(input) {
|
|
3825
4069
|
const { conflict } = input;
|
|
@@ -3859,7 +4103,7 @@ async function hasMatch(hasMatchEvent, ref) {
|
|
|
3859
4103
|
return false;
|
|
3860
4104
|
}
|
|
3861
4105
|
function deliveredPullRequest(payload, ref) {
|
|
3862
|
-
const parsed =
|
|
4106
|
+
const parsed = z22.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
|
|
3863
4107
|
const pullRequest = parsed.success ? parsed.data.pull_request : void 0;
|
|
3864
4108
|
return pullRequest?.number === ref.number && typeof pullRequest.mergeable === "boolean" ? pullRequest : void 0;
|
|
3865
4109
|
}
|
|
@@ -3897,10 +4141,10 @@ async function loadGitHubMergeConflictEvents(args) {
|
|
|
3897
4141
|
}
|
|
3898
4142
|
|
|
3899
4143
|
// src/webhooks/pull-request-ready.ts
|
|
3900
|
-
import { z as
|
|
4144
|
+
import { z as z24 } from "zod";
|
|
3901
4145
|
|
|
3902
4146
|
// src/webhooks/installation-requests.ts
|
|
3903
|
-
import { z as
|
|
4147
|
+
import { z as z23 } from "zod";
|
|
3904
4148
|
function splitRepository(fullName, label) {
|
|
3905
4149
|
const [owner, name, ...extra] = fullName.split("/");
|
|
3906
4150
|
if (!owner || !name || extra.length > 0) {
|
|
@@ -3961,9 +4205,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
3961
4205
|
}
|
|
3962
4206
|
);
|
|
3963
4207
|
}
|
|
3964
|
-
var repositoryPermissionSchema =
|
|
3965
|
-
permission:
|
|
3966
|
-
role_name:
|
|
4208
|
+
var repositoryPermissionSchema = z23.object({
|
|
4209
|
+
permission: z23.string().min(1),
|
|
4210
|
+
role_name: z23.string().optional()
|
|
3967
4211
|
});
|
|
3968
4212
|
var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
|
|
3969
4213
|
async function loadRepositoryRole(env, cache, target) {
|
|
@@ -3993,18 +4237,18 @@ async function loadRepositoryRole(env, cache, target) {
|
|
|
3993
4237
|
}
|
|
3994
4238
|
);
|
|
3995
4239
|
}
|
|
3996
|
-
var pullRequestSchema4 =
|
|
3997
|
-
draft:
|
|
3998
|
-
html_url:
|
|
3999
|
-
mergeable_state:
|
|
4000
|
-
merged:
|
|
4001
|
-
state:
|
|
4002
|
-
title:
|
|
4240
|
+
var pullRequestSchema4 = z23.object({
|
|
4241
|
+
draft: z23.boolean().optional(),
|
|
4242
|
+
html_url: z23.string().url(),
|
|
4243
|
+
mergeable_state: z23.string().nullable().optional(),
|
|
4244
|
+
merged: z23.boolean(),
|
|
4245
|
+
state: z23.enum(["open", "closed"]),
|
|
4246
|
+
title: z23.string()
|
|
4003
4247
|
});
|
|
4004
|
-
var reviewsSchema =
|
|
4005
|
-
|
|
4006
|
-
state:
|
|
4007
|
-
user:
|
|
4248
|
+
var reviewsSchema = z23.array(
|
|
4249
|
+
z23.object({
|
|
4250
|
+
state: z23.string(),
|
|
4251
|
+
user: z23.object({ login: z23.string() }).nullable()
|
|
4008
4252
|
})
|
|
4009
4253
|
);
|
|
4010
4254
|
async function loadPullRequestMergeState(env, pullRequest) {
|
|
@@ -4069,10 +4313,10 @@ var READY_ACTIONS = {
|
|
|
4069
4313
|
]),
|
|
4070
4314
|
pull_request_review: /* @__PURE__ */ new Set(["dismissed", "submitted"])
|
|
4071
4315
|
};
|
|
4072
|
-
var pullRequestWebhookSchema =
|
|
4073
|
-
action:
|
|
4074
|
-
pull_request:
|
|
4075
|
-
repository:
|
|
4316
|
+
var pullRequestWebhookSchema = z24.object({
|
|
4317
|
+
action: z24.string(),
|
|
4318
|
+
pull_request: z24.object({ number: z24.number().int().positive() }),
|
|
4319
|
+
repository: z24.object({ full_name: z24.string().min(1) })
|
|
4076
4320
|
});
|
|
4077
4321
|
function pullRequestReadyTargets(eventName, body) {
|
|
4078
4322
|
if (eventName === "check_suite") return checkSuitePullRequests(body);
|
|
@@ -4167,7 +4411,7 @@ async function syncGitHubPullRequestReadyNotices(args) {
|
|
|
4167
4411
|
}
|
|
4168
4412
|
|
|
4169
4413
|
// src/webhooks/pull-request-match-data.ts
|
|
4170
|
-
import { z as
|
|
4414
|
+
import { z as z25 } from "zod";
|
|
4171
4415
|
var LOOKUPS_BY_MATCH_KEY = {
|
|
4172
4416
|
authors: ["authors"],
|
|
4173
4417
|
openerEmail: ["opener"],
|
|
@@ -4175,16 +4419,16 @@ var LOOKUPS_BY_MATCH_KEY = {
|
|
|
4175
4419
|
openerUsername: ["opener"]
|
|
4176
4420
|
};
|
|
4177
4421
|
var ALL_LOOKUPS = ["authors", "opener", "openerRole"];
|
|
4178
|
-
var lookupDataSchema =
|
|
4179
|
-
authors:
|
|
4180
|
-
openerRole:
|
|
4181
|
-
openerUsername:
|
|
4422
|
+
var lookupDataSchema = z25.object({
|
|
4423
|
+
authors: z25.array(z25.string().min(1)).min(1).optional(),
|
|
4424
|
+
openerRole: z25.string().min(1).optional(),
|
|
4425
|
+
openerUsername: z25.string().min(1).optional()
|
|
4182
4426
|
}).strict();
|
|
4183
4427
|
function lookupData(input) {
|
|
4184
4428
|
return lookupDataSchema.parse(definedValues(input));
|
|
4185
4429
|
}
|
|
4186
|
-
var webhookSchema =
|
|
4187
|
-
repository:
|
|
4430
|
+
var webhookSchema = z25.object({
|
|
4431
|
+
repository: z25.object({ full_name: z25.string().min(1) })
|
|
4188
4432
|
});
|
|
4189
4433
|
function pullRequestNumbers(events) {
|
|
4190
4434
|
const numbers = /* @__PURE__ */ new Map();
|
|
@@ -4327,7 +4571,7 @@ async function withGitHubPullRequestMatchData(args) {
|
|
|
4327
4571
|
}
|
|
4328
4572
|
|
|
4329
4573
|
// src/webhooks/pull-request-people.ts
|
|
4330
|
-
import { z as
|
|
4574
|
+
import { z as z26 } from "zod";
|
|
4331
4575
|
var PEOPLE_EVENTS = /* @__PURE__ */ new Set([
|
|
4332
4576
|
"pull_request.review.approved",
|
|
4333
4577
|
"pull_request.merged"
|
|
@@ -4337,18 +4581,18 @@ var PAGE_SIZE = 100;
|
|
|
4337
4581
|
var MAX_PAGES = 3;
|
|
4338
4582
|
var CO_AUTHOR_TRAILER = /^co-authored-by:[^<\n]*<([^>\s]+@[^>\s]+)>\s*$/gim;
|
|
4339
4583
|
var GITHUB_NOREPLY_EMAIL = /^(?:\d+\+)?(?<login>[^@+]+)@users\.noreply\.github\.com$/i;
|
|
4340
|
-
var webhookSchema2 =
|
|
4341
|
-
pull_request:
|
|
4342
|
-
assignees:
|
|
4343
|
-
number:
|
|
4344
|
-
user:
|
|
4584
|
+
var webhookSchema2 = z26.object({
|
|
4585
|
+
pull_request: z26.object({
|
|
4586
|
+
assignees: z26.array(z26.object({ login: z26.string().min(1) })).nullish(),
|
|
4587
|
+
number: z26.number(),
|
|
4588
|
+
user: z26.object({ login: z26.string().min(1) }).nullish()
|
|
4345
4589
|
}),
|
|
4346
|
-
repository:
|
|
4590
|
+
repository: z26.object({ full_name: z26.string().min(1) })
|
|
4347
4591
|
});
|
|
4348
|
-
var commitPageSchema =
|
|
4349
|
-
|
|
4350
|
-
author:
|
|
4351
|
-
commit:
|
|
4592
|
+
var commitPageSchema = z26.array(
|
|
4593
|
+
z26.object({
|
|
4594
|
+
author: z26.object({ login: z26.string().min(1) }).nullish(),
|
|
4595
|
+
commit: z26.object({ message: z26.string() })
|
|
4352
4596
|
})
|
|
4353
4597
|
);
|
|
4354
4598
|
function shareCommitPages(load) {
|
|
@@ -4493,10 +4737,10 @@ function webhookInstallationId(body) {
|
|
|
4493
4737
|
}
|
|
4494
4738
|
return parseInstallationId(installation.id);
|
|
4495
4739
|
}
|
|
4496
|
-
var feedbackTargetSchema =
|
|
4497
|
-
commentId:
|
|
4498
|
-
commentKind:
|
|
4499
|
-
repo:
|
|
4740
|
+
var feedbackTargetSchema = z27.object({
|
|
4741
|
+
commentId: z27.number(),
|
|
4742
|
+
commentKind: z27.enum(["conversation", "review"]),
|
|
4743
|
+
repo: z27.string().min(1)
|
|
4500
4744
|
});
|
|
4501
4745
|
function pullRequestFeedbackTarget(events) {
|
|
4502
4746
|
const event = events.find(
|
|
@@ -4649,6 +4893,7 @@ function createGitHubWebhookRoute(args) {
|
|
|
4649
4893
|
appIdEnv: args.appIdEnv,
|
|
4650
4894
|
body,
|
|
4651
4895
|
installationIdEnv: args.installationIdEnv,
|
|
4896
|
+
...args.loadGitHubIncidents ? { loadGitHubIncidents: args.loadGitHubIncidents } : void 0,
|
|
4652
4897
|
loadPullRequestFacts: needsCheckSuitePullRequestFacts(checkSuiteMatchKeys),
|
|
4653
4898
|
log: args.log,
|
|
4654
4899
|
privateKeyEnv: args.privateKeyEnv
|
|
@@ -4761,19 +5006,35 @@ function gitHubEventDeclarations(pullRequestGuidance) {
|
|
|
4761
5006
|
return declarations;
|
|
4762
5007
|
}
|
|
4763
5008
|
|
|
5009
|
+
// src/events/resource-url.ts
|
|
5010
|
+
function gitHubResourceUrl(input) {
|
|
5011
|
+
if (input.resourceType === "repository") {
|
|
5012
|
+
return `https://github.com/${input.identifier}`;
|
|
5013
|
+
}
|
|
5014
|
+
const [repo, number] = input.identifier.split("#");
|
|
5015
|
+
if (!repo || !number) return void 0;
|
|
5016
|
+
if (input.resourceType === "pull_request") {
|
|
5017
|
+
return `https://github.com/${repo}/pull/${number}`;
|
|
5018
|
+
}
|
|
5019
|
+
if (input.resourceType === "issue") {
|
|
5020
|
+
return `https://github.com/${repo}/issues/${number}`;
|
|
5021
|
+
}
|
|
5022
|
+
return void 0;
|
|
5023
|
+
}
|
|
5024
|
+
|
|
4764
5025
|
// src/pull-request-outcomes/commit-composition.ts
|
|
4765
|
-
import { z as
|
|
4766
|
-
var canonicalCommitSchema =
|
|
4767
|
-
authorEmail:
|
|
4768
|
-
authorLogin:
|
|
5026
|
+
import { z as z28 } from "zod";
|
|
5027
|
+
var canonicalCommitSchema = z28.object({
|
|
5028
|
+
authorEmail: z28.string().nullable(),
|
|
5029
|
+
authorLogin: z28.string().nullable()
|
|
4769
5030
|
}).strict();
|
|
4770
|
-
var providerCommitSchema =
|
|
4771
|
-
author:
|
|
4772
|
-
commit:
|
|
4773
|
-
author:
|
|
5031
|
+
var providerCommitSchema = z28.object({
|
|
5032
|
+
author: z28.object({ login: z28.string() }).passthrough().nullable(),
|
|
5033
|
+
commit: z28.object({
|
|
5034
|
+
author: z28.object({ email: z28.string() }).passthrough().nullable()
|
|
4774
5035
|
}).passthrough()
|
|
4775
5036
|
}).passthrough();
|
|
4776
|
-
var commitPageSchema2 =
|
|
5037
|
+
var commitPageSchema2 = z28.array(providerCommitSchema).transform(
|
|
4777
5038
|
(commits) => commits.map(
|
|
4778
5039
|
(commit) => canonicalCommitSchema.parse({
|
|
4779
5040
|
authorEmail: commit.commit.author?.email ?? null,
|
|
@@ -6081,6 +6342,7 @@ async function githubGrantForEgress(ctx) {
|
|
|
6081
6342
|
}
|
|
6082
6343
|
|
|
6083
6344
|
// src/plugin.ts
|
|
6345
|
+
var CHECK_SUITE_INCIDENT_WINDOW_MS = 60 * 60 * 1e3;
|
|
6084
6346
|
function githubPlugin(options = {}) {
|
|
6085
6347
|
const botNameEnv = options.botNameEnv ?? "GITHUB_APP_BOT_NAME";
|
|
6086
6348
|
const botEmailEnv = options.botEmailEnv ?? "GITHUB_APP_BOT_EMAIL";
|
|
@@ -6142,7 +6404,8 @@ function githubPlugin(options = {}) {
|
|
|
6142
6404
|
gitHubPullRequestEventGuidance(options.pullRequestEvents?.guidance)
|
|
6143
6405
|
),
|
|
6144
6406
|
isEnabled: () => Boolean(readEnv("GITHUB_WEBHOOK_SECRET")),
|
|
6145
|
-
normalizeIdentifier: (identifier) => identifier.toLowerCase()
|
|
6407
|
+
normalizeIdentifier: (identifier) => identifier.toLowerCase(),
|
|
6408
|
+
resourceUrl: gitHubResourceUrl
|
|
6146
6409
|
},
|
|
6147
6410
|
manifest: {
|
|
6148
6411
|
name: "github",
|
|
@@ -6284,6 +6547,10 @@ function githubPlugin(options = {}) {
|
|
|
6284
6547
|
codeChanges: ctx.codeChanges,
|
|
6285
6548
|
db: ctx.db,
|
|
6286
6549
|
installationId: () => readEnv(installationIdEnv),
|
|
6550
|
+
loadGitHubIncidents: async () => await loadGitHubStatusIncidents(
|
|
6551
|
+
ctx.cache,
|
|
6552
|
+
CHECK_SUITE_INCIDENT_WINDOW_MS
|
|
6553
|
+
),
|
|
6287
6554
|
installationIdEnv,
|
|
6288
6555
|
loadRepositoryRole: async (target) => await loadRepositoryRole(installationEnv, ctx.cache, target),
|
|
6289
6556
|
loadGitHubLogin: async (identityId) => linkedGitHubLogin(
|