@sentry/junior-github 0.281.0 → 0.283.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -59,7 +59,7 @@ import {
59
59
  readGrantPermissions,
60
60
  requireEnv,
61
61
  resolveUserAccount
62
- } from "./chunk-NSAVG2P3.js";
62
+ } from "./chunk-XOE6HDSA.js";
63
63
 
64
64
  // src/tool-support/attribution.ts
65
65
  import * as z from "zod";
@@ -778,11 +778,11 @@ function githubLinkedIssues(body, repositoryFullName) {
778
778
  if (!body) return [];
779
779
  const references = /* @__PURE__ */ new Map();
780
780
  const add = (linkedRepository, rawNumber) => {
781
- const number22 = Number.parseInt(rawNumber, 10);
782
- if (!Number.isInteger(number22) || number22 <= 0) return;
781
+ const number23 = Number.parseInt(rawNumber, 10);
782
+ if (!Number.isInteger(number23) || number23 <= 0) return;
783
783
  const normalizedRepository = linkedRepository.toLowerCase();
784
- references.set(`${normalizedRepository}#${number22}`, {
785
- number: number22,
784
+ references.set(`${normalizedRepository}#${number23}`, {
785
+ number: number23,
786
786
  repositoryFullName: linkedRepository
787
787
  });
788
788
  };
@@ -1248,19 +1248,123 @@ function createGitHubGetDeploymentTool(ctx) {
1248
1248
  });
1249
1249
  }
1250
1250
 
1251
- // src/tools/create-pull-request.ts
1251
+ // src/tools/get-issue.ts
1252
1252
  import {
1253
- objectFactsSchema as objectFactsSchema2,
1254
1253
  definePluginTool as definePluginTool5,
1255
- EgressAuthRequired as EgressAuthRequired2,
1256
1254
  PluginToolInputError as PluginToolInputError7,
1257
1255
  pluginToolOutputSchema as pluginToolOutputSchema5,
1258
- watchResultSchema,
1259
1256
  subscribableResourceSchema as subscribableResourceSchema3
1260
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";
1261
1365
  import { Type as Type2 } from "@sinclair/typebox";
1262
1366
  import { Value as Value2 } from "@sinclair/typebox/value";
1263
- import * as z9 from "zod";
1367
+ import * as z10 from "zod";
1264
1368
 
1265
1369
  // src/pull-request-requesters/store.ts
1266
1370
  import { and, asc, eq, inArray, lt } from "drizzle-orm";
@@ -1275,18 +1379,18 @@ import {
1275
1379
  text,
1276
1380
  timestamp
1277
1381
  } from "drizzle-orm/pg-core";
1278
- import * as z7 from "zod";
1279
- var githubPullRequestStateSchema = z7.enum([
1382
+ import * as z8 from "zod";
1383
+ var githubPullRequestStateSchema = z8.enum([
1280
1384
  "closed_unmerged",
1281
1385
  "merged",
1282
1386
  "open"
1283
1387
  ]);
1284
- var githubPullRequestCommitCompositionSchema = z7.enum([
1388
+ var githubPullRequestCommitCompositionSchema = z8.enum([
1285
1389
  "junior_only",
1286
1390
  "mixed"
1287
1391
  ]);
1288
- var githubIssueStateSchema = z7.enum(["closed", "open"]);
1289
- var githubIssueStateReasonSchema = z7.enum([
1392
+ var githubIssueStateSchema = z8.enum(["closed", "open"]);
1393
+ var githubIssueStateReasonSchema = z8.enum([
1290
1394
  "completed",
1291
1395
  "duplicate",
1292
1396
  "not_planned",
@@ -1447,31 +1551,31 @@ async function listGitHubPullRequestOpeners(db, input) {
1447
1551
  }
1448
1552
 
1449
1553
  // src/tools/stack-pull-request.ts
1450
- import * as z8 from "zod";
1554
+ import * as z9 from "zod";
1451
1555
  var MAX_STACK_DEPTH = 10;
1452
1556
  var GITHUB_STACKS_API_VERSION = "2026-03-10";
1453
- var stackTargetSchema = z8.object({
1454
- number: z8.number().int().positive(),
1455
- head: z8.object({
1456
- repo: z8.object({ full_name: z8.string().min(1) }).nullable()
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()
1457
1561
  }),
1458
- base: z8.object({
1459
- ref: z8.string().min(1),
1460
- repo: z8.object({
1461
- default_branch: z8.string().min(1),
1462
- full_name: z8.string().min(1)
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)
1463
1567
  })
1464
1568
  })
1465
1569
  });
1466
- var openPullRequestsSchema = z8.array(
1467
- z8.object({
1468
- number: z8.number().int().positive(),
1469
- base: z8.object({ ref: z8.string().min(1) })
1570
+ var openPullRequestsSchema = z9.array(
1571
+ z9.object({
1572
+ number: z9.number().int().positive(),
1573
+ base: z9.object({ ref: z9.string().min(1) })
1470
1574
  })
1471
1575
  );
1472
- var stackSchema = z8.object({
1473
- number: z8.number().int().positive(),
1474
- pull_requests: z8.array(z8.object({ number: z8.number().int().positive() }))
1576
+ var stackSchema = z9.object({
1577
+ number: z9.number().int().positive(),
1578
+ pull_requests: z9.array(z9.object({ number: z9.number().int().positive() }))
1475
1579
  });
1476
1580
  async function stackGitHubPullRequest(ctx, target) {
1477
1581
  const repo = target.base.repo.full_name;
@@ -1517,7 +1621,7 @@ async function stackGitHubPullRequest(ctx, target) {
1517
1621
  const stacks = await github(
1518
1622
  "github.stack.read",
1519
1623
  `${api}/stacks?pull_request=${parent.number}`,
1520
- z8.array(stackSchema)
1624
+ z9.array(stackSchema)
1521
1625
  );
1522
1626
  if (!stacks) return void 0;
1523
1627
  const stack = stacks[0];
@@ -1592,15 +1696,15 @@ var createPullRequestInputSchema = Type2.Object(
1592
1696
  },
1593
1697
  { additionalProperties: false }
1594
1698
  );
1595
- var createPullRequestToolInputSchema = z9.object({
1596
- repo: z9.string().describe('Repository in "owner/name" format.'),
1597
- title: z9.string().describe("Pull request title."),
1598
- head: z9.string().describe("Head branch or owner:branch ref."),
1599
- base: z9.string().describe("Base branch."),
1600
- body: z9.string().describe(
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(
1601
1705
  "Pull request body. The runtime appends the conversation footer."
1602
1706
  ).optional(),
1603
- draft: z9.boolean().describe("Whether to open the pull request as a draft.").optional()
1707
+ draft: z10.boolean().describe("Whether to open the pull request as a draft.").optional()
1604
1708
  }).strict();
1605
1709
  var createPullRequestStateSchema = Type2.Union([
1606
1710
  Type2.Object(
@@ -1625,30 +1729,30 @@ var createPullRequestStateSchema = Type2.Union([
1625
1729
  { additionalProperties: false }
1626
1730
  )
1627
1731
  ]);
1628
- var gitHubPullRequestDataSchema = z9.object({
1629
- number: z9.number(),
1630
- url: z9.string(),
1631
- stack: z9.object({ number: z9.number(), pull_requests: z9.array(z9.number()) }).optional(),
1632
- subscribable: subscribableResourceSchema3.optional(),
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(),
1633
1737
  subscription: watchResultSchema.optional()
1634
1738
  });
1635
- var gitHubPullRequestOutputSchema = pluginToolOutputSchema5.merge(
1739
+ var gitHubPullRequestOutputSchema = pluginToolOutputSchema6.merge(
1636
1740
  gitHubPullRequestDataSchema.extend({
1637
- target: z9.literal("createPullRequest")
1741
+ target: z10.literal("createPullRequest")
1638
1742
  })
1639
1743
  );
1640
1744
  function parseCreatePullRequestInput(input) {
1641
1745
  try {
1642
1746
  return Value2.Parse(createPullRequestInputSchema, input);
1643
1747
  } catch (error) {
1644
- throw new PluginToolInputError7("Invalid GitHub createPullRequest input.", {
1748
+ throw new PluginToolInputError8("Invalid GitHub createPullRequest input.", {
1645
1749
  cause: error
1646
1750
  });
1647
1751
  }
1648
1752
  }
1649
1753
  function nonEmptyString3(value, name) {
1650
1754
  if (!value?.trim()) {
1651
- throw new PluginToolInputError7(`${name} is required`);
1755
+ throw new PluginToolInputError8(`${name} is required`);
1652
1756
  }
1653
1757
  return value.trim();
1654
1758
  }
@@ -1837,7 +1941,7 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
1837
1941
  }
1838
1942
  }
1839
1943
  function createGitHubPullRequestTool(ctx, subscriptionConfig) {
1840
- return definePluginTool5({
1944
+ return definePluginTool6({
1841
1945
  annotations: {
1842
1946
  destructiveHint: false,
1843
1947
  idempotentHint: true,
@@ -1956,36 +2060,36 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
1956
2060
 
1957
2061
  // src/tools/get-pull-request.ts
1958
2062
  import {
1959
- definePluginTool as definePluginTool6,
1960
- PluginToolInputError as PluginToolInputError8,
1961
- pluginToolOutputSchema as pluginToolOutputSchema6
2063
+ definePluginTool as definePluginTool7,
2064
+ PluginToolInputError as PluginToolInputError9,
2065
+ pluginToolOutputSchema as pluginToolOutputSchema7
1962
2066
  } from "@sentry/junior-plugin-api";
1963
- import * as z10 from "zod";
1964
- import { subscribableResourceSchema as subscribableResourceSchema4 } from "@sentry/junior-plugin-api";
1965
- var commitShaSchema2 = z10.string().regex(/^[0-9a-f]{40}$/i);
1966
- var inputSchema4 = z10.object({
1967
- repo: z10.string().describe('Repository in "owner/name" format.'),
1968
- number: z10.number().int().positive().describe("Pull request 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.")
1969
2073
  }).strict();
1970
- var pullRequestSchema = z10.object({
1971
- base: z10.string(),
1972
- draft: z10.boolean(),
1973
- head: z10.string(),
2074
+ var pullRequestSchema = z11.object({
2075
+ base: z11.string(),
2076
+ draft: z11.boolean(),
2077
+ head: z11.string(),
1974
2078
  head_sha: commitShaSchema2,
1975
- merged: z10.boolean(),
1976
- number: z10.number(),
1977
- state: z10.string(),
1978
- subscribable: subscribableResourceSchema4.optional(),
1979
- title: z10.string(),
1980
- url: z10.string()
2079
+ merged: z11.boolean(),
2080
+ number: z11.number(),
2081
+ state: z11.string(),
2082
+ subscribable: subscribableResourceSchema5.optional(),
2083
+ title: z11.string(),
2084
+ url: z11.string()
1981
2085
  });
1982
- var outputSchema4 = pluginToolOutputSchema6.merge(
2086
+ var outputSchema5 = pluginToolOutputSchema7.merge(
1983
2087
  pullRequestSchema.extend({
1984
- target: z10.literal("getPullRequest")
2088
+ target: z11.literal("getPullRequest")
1985
2089
  })
1986
2090
  );
1987
2091
  function createGitHubGetPullRequestTool(ctx) {
1988
- return definePluginTool6({
2092
+ return definePluginTool7({
1989
2093
  annotations: {
1990
2094
  destructiveHint: false,
1991
2095
  idempotentHint: true,
@@ -1993,8 +2097,8 @@ function createGitHubGetPullRequestTool(ctx) {
1993
2097
  readOnlyHint: true
1994
2098
  },
1995
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.",
1996
- inputSchema: inputSchema4,
1997
- outputSchema: outputSchema4,
2100
+ inputSchema: inputSchema5,
2101
+ outputSchema: outputSchema5,
1998
2102
  async execute(input) {
1999
2103
  const repo = parseRepo(input.repo);
2000
2104
  const response = await githubApi(ctx.egress, {
@@ -2004,19 +2108,19 @@ function createGitHubGetPullRequestTool(ctx) {
2004
2108
  if (!response.ok) {
2005
2109
  const message = `GitHub pull request lookup failed with HTTP ${response.status}`;
2006
2110
  if (response.status === 404) {
2007
- throw new PluginToolInputError8(message);
2111
+ throw new PluginToolInputError9(message);
2008
2112
  }
2009
2113
  throw new Error(message);
2010
2114
  }
2011
- const providerResult = z10.object({
2012
- base: z10.object({ ref: z10.string() }),
2013
- draft: z10.boolean(),
2014
- head: z10.object({ ref: z10.string(), sha: commitShaSchema2 }),
2015
- html_url: z10.string(),
2016
- merged: z10.boolean().optional().default(false),
2017
- number: z10.number(),
2018
- state: z10.string(),
2019
- title: z10.string()
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()
2020
2124
  }).parse(response.body);
2021
2125
  const subscribable = gitHubPullRequestSubscribable({
2022
2126
  canSubscribe: ctx.events.canSubscribe,
@@ -2056,49 +2160,49 @@ function createGitHubGetPullRequestTool(ctx) {
2056
2160
 
2057
2161
  // src/tools/get-release.ts
2058
2162
  import {
2059
- definePluginTool as definePluginTool7,
2060
- pluginToolOutputSchema as pluginToolOutputSchema7,
2061
- subscribableResourceSchema as subscribableResourceSchema5
2163
+ definePluginTool as definePluginTool8,
2164
+ pluginToolOutputSchema as pluginToolOutputSchema8,
2165
+ subscribableResourceSchema as subscribableResourceSchema6
2062
2166
  } from "@sentry/junior-plugin-api";
2063
- import * as z11 from "zod";
2064
- var inputSchema5 = z11.object({
2065
- repo: z11.string().describe('Repository in "owner/name" format.'),
2066
- tag: z11.string().trim().min(1).describe(
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(
2067
2171
  "Optional release tag name. Omit to inspect and watch every published release in the repository."
2068
2172
  ).optional()
2069
2173
  }).strict();
2070
- var releaseSchema = z11.object({
2071
- created_at: z11.string(),
2072
- draft: z11.boolean(),
2073
- html_url: z11.string(),
2074
- id: z11.number(),
2075
- name: z11.string().nullable(),
2076
- prerelease: z11.boolean(),
2077
- published_at: z11.string().nullable(),
2078
- tag_name: z11.string(),
2079
- target_commitish: z11.string()
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()
2080
2184
  }).strict();
2081
- var releaseSourceSchema = z11.object({
2185
+ var releaseSourceSchema = z12.object({
2082
2186
  release: releaseSchema.nullable(),
2083
- repo: z11.string(),
2084
- subscribable: subscribableResourceSchema5.optional(),
2085
- tag: z11.string().nullable()
2187
+ repo: z12.string(),
2188
+ subscribable: subscribableResourceSchema6.optional(),
2189
+ tag: z12.string().nullable()
2086
2190
  }).strict();
2087
- var outputSchema5 = pluginToolOutputSchema7.merge(
2191
+ var outputSchema6 = pluginToolOutputSchema8.merge(
2088
2192
  releaseSourceSchema.extend({
2089
- target: z11.literal("getRelease")
2193
+ target: z12.literal("getRelease")
2090
2194
  })
2091
2195
  );
2092
- var providerReleaseSchema = z11.object({
2093
- created_at: z11.string(),
2094
- draft: z11.boolean(),
2095
- html_url: z11.string(),
2096
- id: z11.number(),
2097
- name: z11.string().nullable(),
2098
- prerelease: z11.boolean(),
2099
- published_at: z11.string().nullable(),
2100
- tag_name: z11.string(),
2101
- target_commitish: z11.string()
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()
2102
2206
  }).passthrough();
2103
2207
  function mapRelease(providerRelease) {
2104
2208
  return {
@@ -2114,7 +2218,7 @@ function mapRelease(providerRelease) {
2114
2218
  };
2115
2219
  }
2116
2220
  function createGitHubGetReleaseTool(ctx) {
2117
- return definePluginTool7({
2221
+ return definePluginTool8({
2118
2222
  annotations: {
2119
2223
  destructiveHint: false,
2120
2224
  idempotentHint: true,
@@ -2122,8 +2226,8 @@ function createGitHubGetReleaseTool(ctx) {
2122
2226
  readOnlyHint: true
2123
2227
  },
2124
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.",
2125
- inputSchema: inputSchema5,
2126
- outputSchema: outputSchema5,
2229
+ inputSchema: inputSchema6,
2230
+ outputSchema: outputSchema6,
2127
2231
  async execute(input) {
2128
2232
  const repo = parseRepo(input.repo);
2129
2233
  const tag = input.tag?.trim() || void 0;
@@ -2176,30 +2280,30 @@ function createGitHubGetReleaseTool(ctx) {
2176
2280
 
2177
2281
  // src/tools/get-repository.ts
2178
2282
  import {
2179
- definePluginTool as definePluginTool8,
2180
- PluginToolInputError as PluginToolInputError9,
2181
- pluginToolOutputSchema as pluginToolOutputSchema8,
2182
- subscribableResourceSchema as subscribableResourceSchema6
2283
+ definePluginTool as definePluginTool9,
2284
+ PluginToolInputError as PluginToolInputError10,
2285
+ pluginToolOutputSchema as pluginToolOutputSchema9,
2286
+ subscribableResourceSchema as subscribableResourceSchema7
2183
2287
  } from "@sentry/junior-plugin-api";
2184
- import * as z12 from "zod";
2185
- var inputSchema6 = z12.object({
2186
- repo: z12.string().describe('Repository in "owner/name" format.')
2288
+ import * as z13 from "zod";
2289
+ var inputSchema7 = z13.object({
2290
+ repo: z13.string().describe('Repository in "owner/name" format.')
2187
2291
  }).strict();
2188
- var repositorySchema = z12.object({
2189
- default_branch: z12.string(),
2190
- description: z12.string().nullable(),
2191
- full_name: z12.string(),
2192
- private: z12.boolean(),
2193
- subscribable: subscribableResourceSchema6.optional(),
2194
- url: z12.string()
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()
2195
2299
  });
2196
- var outputSchema6 = pluginToolOutputSchema8.merge(
2300
+ var outputSchema7 = pluginToolOutputSchema9.merge(
2197
2301
  repositorySchema.extend({
2198
- target: z12.literal("getRepository")
2302
+ target: z13.literal("getRepository")
2199
2303
  })
2200
2304
  );
2201
2305
  function createGitHubGetRepositoryTool(ctx) {
2202
- return definePluginTool8({
2306
+ return definePluginTool9({
2203
2307
  annotations: {
2204
2308
  destructiveHint: false,
2205
2309
  idempotentHint: true,
@@ -2207,8 +2311,8 @@ function createGitHubGetRepositoryTool(ctx) {
2207
2311
  readOnlyHint: true
2208
2312
  },
2209
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.",
2210
- inputSchema: inputSchema6,
2211
- outputSchema: outputSchema6,
2314
+ inputSchema: inputSchema7,
2315
+ outputSchema: outputSchema7,
2212
2316
  async execute(input) {
2213
2317
  const repo = parseRepo(input.repo);
2214
2318
  const response = await githubApi(ctx.egress, {
@@ -2216,16 +2320,16 @@ function createGitHubGetRepositoryTool(ctx) {
2216
2320
  path: repoPath(repo)
2217
2321
  });
2218
2322
  if (!response.ok) {
2219
- throw new PluginToolInputError9(
2323
+ throw new PluginToolInputError10(
2220
2324
  `GitHub repository lookup failed with HTTP ${response.status}`
2221
2325
  );
2222
2326
  }
2223
- const providerResult = z12.object({
2224
- default_branch: z12.string(),
2225
- description: z12.string().nullable(),
2226
- full_name: z12.string(),
2227
- html_url: z12.string(),
2228
- private: z12.boolean()
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()
2229
2333
  }).parse(response.body);
2230
2334
  const subscribable = gitHubRepositorySubscribable({
2231
2335
  canSubscribe: ctx.events.canSubscribe,
@@ -2249,27 +2353,27 @@ function createGitHubGetRepositoryTool(ctx) {
2249
2353
 
2250
2354
  // src/tools/get-status.ts
2251
2355
  import {
2252
- definePluginTool as definePluginTool9,
2253
- pluginToolOutputSchema as pluginToolOutputSchema9
2356
+ definePluginTool as definePluginTool10,
2357
+ pluginToolOutputSchema as pluginToolOutputSchema10
2254
2358
  } from "@sentry/junior-plugin-api";
2255
- import * as z14 from "zod";
2359
+ import * as z15 from "zod";
2256
2360
 
2257
2361
  // src/github-status.ts
2258
- import * as z13 from "zod";
2362
+ import * as z14 from "zod";
2259
2363
  var GITHUB_STATUS_INCIDENTS_URL = "https://www.githubstatus.com/api/v2/incidents.json";
2260
2364
  var GITHUB_STATUS_TTL_MS = 60 * 1e3;
2261
2365
  var GITHUB_STATUS_TIMEOUT_MS = 5e3;
2262
- var incidentsResponseSchema = z13.object({
2263
- incidents: z13.array(
2264
- z13.object({
2265
- components: z13.array(z13.object({ name: z13.string() })).default([]),
2266
- created_at: z13.string(),
2267
- impact: z13.string(),
2268
- name: z13.string(),
2269
- resolved_at: z13.string().nullable(),
2270
- shortlink: z13.string(),
2271
- started_at: z13.string().nullable().optional(),
2272
- status: z13.string()
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()
2273
2377
  })
2274
2378
  )
2275
2379
  });
@@ -2311,22 +2415,22 @@ async function loadGitHubStatusIncidents(cache, withinMs) {
2311
2415
 
2312
2416
  // src/tools/get-status.ts
2313
2417
  var RECENT_INCIDENT_MS = 24 * 60 * 60 * 1e3;
2314
- var inputSchema7 = z14.object({}).strict();
2315
- var incidentSchema = z14.object({
2316
- components: z14.array(z14.string()),
2317
- impact: z14.string(),
2318
- name: z14.string(),
2319
- resolved_at: z14.string().optional(),
2320
- started_at: z14.string(),
2321
- status: z14.string(),
2322
- url: z14.string()
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()
2323
2427
  });
2324
- var outputSchema7 = pluginToolOutputSchema9.extend({
2325
- target: z14.literal("getStatus"),
2326
- incidents: z14.array(incidentSchema)
2428
+ var outputSchema8 = pluginToolOutputSchema10.extend({
2429
+ target: z15.literal("getStatus"),
2430
+ incidents: z15.array(incidentSchema)
2327
2431
  });
2328
2432
  function createGitHubGetStatusTool(ctx) {
2329
- return definePluginTool9({
2433
+ return definePluginTool10({
2330
2434
  annotations: {
2331
2435
  destructiveHint: false,
2332
2436
  idempotentHint: true,
@@ -2334,8 +2438,8 @@ function createGitHubGetStatusTool(ctx) {
2334
2438
  readOnlyHint: true
2335
2439
  },
2336
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.",
2337
- inputSchema: inputSchema7,
2338
- outputSchema: outputSchema7,
2441
+ inputSchema: inputSchema8,
2442
+ outputSchema: outputSchema8,
2339
2443
  async execute() {
2340
2444
  const incidents = await loadGitHubStatusIncidents(
2341
2445
  ctx.cache,
@@ -2358,61 +2462,80 @@ function createGitHubGetStatusTool(ctx) {
2358
2462
 
2359
2463
  // src/tools/update-issue.ts
2360
2464
  import {
2361
- definePluginTool as definePluginTool10,
2362
- PluginToolInputError as PluginToolInputError10,
2363
- pluginToolOutputSchema as pluginToolOutputSchema10,
2364
- subscribableResourceSchema as subscribableResourceSchema7
2465
+ definePluginTool as definePluginTool11,
2466
+ PluginToolInputError as PluginToolInputError11,
2467
+ pluginToolOutputSchema as pluginToolOutputSchema11,
2468
+ subscribableResourceSchema as subscribableResourceSchema8
2365
2469
  } from "@sentry/junior-plugin-api";
2366
- import * as z15 from "zod";
2367
- var inputSchema8 = z15.object({
2368
- repo: z15.string().describe('Repository in "owner/name" format.'),
2369
- number: z15.number().int().positive().describe("Issue number."),
2370
- title: z15.string().trim().min(1).optional().describe("Replacement issue title."),
2371
- body: z15.string().optional().describe(
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(
2372
2476
  "Replacement issue body. The runtime appends requester attribution and the conversation footer."
2373
2477
  ),
2374
- state: z15.enum(["open", "closed"]).optional().describe("Replacement issue 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
+ )
2375
2482
  }).strict().refine(
2376
- ({ 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,
2377
2484
  { message: "At least one issue field must be provided." }
2378
2485
  );
2379
- var issueSchema = z15.object({
2380
- body: z15.string().nullable(),
2381
- number: z15.number(),
2382
- state: z15.string(),
2383
- subscribable: subscribableResourceSchema7.optional(),
2384
- title: z15.string(),
2385
- url: z15.string()
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()
2386
2494
  });
2387
- var outputSchema8 = pluginToolOutputSchema10.merge(
2388
- issueSchema.extend({
2389
- target: z15.literal("updateIssue")
2495
+ var outputSchema9 = pluginToolOutputSchema11.merge(
2496
+ issueSchema2.extend({
2497
+ target: z16.literal("updateIssue")
2390
2498
  })
2391
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
+ });
2392
2508
  function nonEmptyString4(value, name) {
2393
- if (!value?.trim()) throw new PluginToolInputError10(`${name} is required`);
2509
+ if (!value?.trim()) throw new PluginToolInputError11(`${name} is required`);
2394
2510
  return value.trim();
2395
2511
  }
2396
2512
  function createGitHubUpdateIssueTool(ctx) {
2397
- return definePluginTool10({
2513
+ return definePluginTool11({
2398
2514
  annotations: {
2399
2515
  destructiveHint: true,
2400
2516
  idempotentHint: true,
2401
2517
  openWorldHint: true,
2402
2518
  readOnlyHint: false
2403
2519
  },
2404
- 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.",
2405
- inputSchema: inputSchema8,
2406
- outputSchema: outputSchema8,
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,
2407
2523
  async execute(input) {
2408
- const parsedInput = inputSchema8.safeParse(input);
2524
+ const parsedInput = inputSchema9.safeParse(input);
2409
2525
  if (!parsedInput.success) {
2410
- throw new PluginToolInputError10("Invalid GitHub updateIssue input.", {
2526
+ throw new PluginToolInputError11("Invalid GitHub updateIssue input.", {
2411
2527
  cause: parsedInput.error
2412
2528
  });
2413
2529
  }
2414
2530
  const update = parsedInput.data;
2415
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
+ }
2416
2539
  const currentBody = update.body !== void 0 ? await readGitHubBody(ctx.egress, {
2417
2540
  operation: "github.issue.get",
2418
2541
  path: `${repoPath(repo)}/issues/${update.number}`
@@ -2424,7 +2547,7 @@ function createGitHubUpdateIssueTool(ctx) {
2424
2547
  appendGitHubRequesterAttribution(
2425
2548
  update.body,
2426
2549
  ctx,
2427
- await resolveGitHubRequester(ctx),
2550
+ requester,
2428
2551
  currentBody
2429
2552
  ),
2430
2553
  nonEmptyString4(ctx.conversationId, "conversationId"),
@@ -2433,25 +2556,45 @@ function createGitHubUpdateIssueTool(ctx) {
2433
2556
  } : void 0,
2434
2557
  ...update.state !== void 0 ? { state: update.state } : void 0
2435
2558
  };
2436
- const response = await githubApi(ctx.egress, {
2437
- operation: "github.issue.update",
2438
- method: "PATCH",
2439
- path: `${repoPath(repo)}/issues/${update.number}`,
2440
- body: payload
2441
- });
2442
- const parsed = response.body;
2443
- if (!response.ok) {
2444
- throw new Error(
2445
- `GitHub issue update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`
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}.`
2446
2596
  );
2447
2597
  }
2448
- const providerResult = z15.object({
2449
- body: z15.string().nullable().optional().default(null),
2450
- html_url: z15.string(),
2451
- number: z15.number(),
2452
- state: z15.string(),
2453
- title: z15.string()
2454
- }).parse(parsed);
2455
2598
  const subscribable = gitHubIssueSubscribable({
2456
2599
  canSubscribe: ctx.events.canSubscribe,
2457
2600
  number: providerResult.number,
@@ -2470,6 +2613,7 @@ function createGitHubUpdateIssueTool(ctx) {
2470
2613
  })
2471
2614
  ],
2472
2615
  target: "updateIssue",
2616
+ assignees: providerResult.assignees,
2473
2617
  body: providerResult.body,
2474
2618
  number: providerResult.number,
2475
2619
  state: providerResult.state,
@@ -2483,22 +2627,22 @@ function createGitHubUpdateIssueTool(ctx) {
2483
2627
 
2484
2628
  // src/tools/update-pull-request.ts
2485
2629
  import {
2486
- definePluginTool as definePluginTool11,
2487
- PluginToolInputError as PluginToolInputError11,
2488
- pluginToolOutputSchema as pluginToolOutputSchema11
2630
+ definePluginTool as definePluginTool12,
2631
+ PluginToolInputError as PluginToolInputError12,
2632
+ pluginToolOutputSchema as pluginToolOutputSchema12
2489
2633
  } from "@sentry/junior-plugin-api";
2490
- import * as z16 from "zod";
2491
- import { subscribableResourceSchema as subscribableResourceSchema8 } from "@sentry/junior-plugin-api";
2492
- var inputSchema9 = z16.object({
2493
- repo: z16.string().describe('Repository in "owner/name" format.'),
2494
- number: z16.number().int().positive().describe("Pull request number."),
2495
- title: z16.string().trim().min(1).optional().describe("Replacement pull request title."),
2496
- body: z16.string().optional().describe(
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(
2497
2641
  "Replacement pull request body. The runtime appends requester attribution and the conversation footer."
2498
2642
  ),
2499
- base: z16.string().trim().min(1).optional().describe("Replacement base branch."),
2500
- state: z16.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
2501
- draft: z16.boolean().optional().describe(
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(
2502
2646
  "Set false to mark a draft pull request ready for review, or true to convert it back to a draft."
2503
2647
  )
2504
2648
  }).strict().refine(
@@ -2513,29 +2657,29 @@ var CONVERT_TO_DRAFT = {
2513
2657
  operationName: "ConvertPullRequestToDraft",
2514
2658
  query: "mutation ConvertPullRequestToDraft($id: ID!) { result: convertPullRequestToDraft(input: {pullRequestId: $id}) { pullRequest { isDraft } } }"
2515
2659
  };
2516
- var draftMutationResponseSchema = z16.object({
2517
- data: z16.object({
2518
- result: z16.object({ pullRequest: z16.object({ isDraft: z16.boolean() }) })
2660
+ var draftMutationResponseSchema = z17.object({
2661
+ data: z17.object({
2662
+ result: z17.object({ pullRequest: z17.object({ isDraft: z17.boolean() }) })
2519
2663
  })
2520
2664
  });
2521
- var pullRequestSchema2 = z16.object({
2522
- base: z16.string(),
2523
- body: z16.string().nullable(),
2524
- draft: z16.boolean(),
2525
- number: z16.number(),
2526
- state: z16.string(),
2527
- subscribable: subscribableResourceSchema8.optional(),
2528
- title: z16.string(),
2529
- url: z16.string()
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()
2530
2674
  });
2531
- var outputSchema9 = pluginToolOutputSchema11.merge(
2675
+ var outputSchema10 = pluginToolOutputSchema12.merge(
2532
2676
  pullRequestSchema2.extend({
2533
- target: z16.literal("updatePullRequest")
2677
+ target: z17.literal("updatePullRequest")
2534
2678
  })
2535
2679
  );
2536
2680
  function nonEmptyString5(value, name) {
2537
2681
  if (!value?.trim()) {
2538
- throw new PluginToolInputError11(`${name} is required`);
2682
+ throw new PluginToolInputError12(`${name} is required`);
2539
2683
  }
2540
2684
  return value.trim();
2541
2685
  }
@@ -2561,7 +2705,7 @@ async function setPullRequestDraft(input) {
2561
2705
  return isDraft;
2562
2706
  }
2563
2707
  function createGitHubUpdatePullRequestTool(ctx) {
2564
- return definePluginTool11({
2708
+ return definePluginTool12({
2565
2709
  annotations: {
2566
2710
  destructiveHint: true,
2567
2711
  idempotentHint: true,
@@ -2569,12 +2713,12 @@ function createGitHubUpdatePullRequestTool(ctx) {
2569
2713
  readOnlyHint: false
2570
2714
  },
2571
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.",
2572
- inputSchema: inputSchema9,
2573
- outputSchema: outputSchema9,
2716
+ inputSchema: inputSchema10,
2717
+ outputSchema: outputSchema10,
2574
2718
  async execute(input) {
2575
- const parsedInput = inputSchema9.safeParse(input);
2719
+ const parsedInput = inputSchema10.safeParse(input);
2576
2720
  if (!parsedInput.success) {
2577
- throw new PluginToolInputError11(
2721
+ throw new PluginToolInputError12(
2578
2722
  "Invalid GitHub updatePullRequest input.",
2579
2723
  { cause: parsedInput.error }
2580
2724
  );
@@ -2615,16 +2759,16 @@ function createGitHubUpdatePullRequestTool(ctx) {
2615
2759
  `GitHub pull request update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`
2616
2760
  );
2617
2761
  }
2618
- const providerResult = z16.object({
2619
- base: z16.object({ ref: z16.string() }),
2620
- body: z16.string().nullable().optional().default(null),
2621
- draft: z16.boolean(),
2622
- html_url: z16.string(),
2623
- merged: z16.boolean(),
2624
- node_id: z16.string().optional(),
2625
- number: z16.number(),
2626
- state: z16.string(),
2627
- title: z16.string()
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()
2628
2772
  }).parse(parsed);
2629
2773
  if (update.draft !== void 0 && update.draft !== providerResult.draft) {
2630
2774
  if (!providerResult.node_id) {
@@ -2685,11 +2829,11 @@ function createGitHubUpdatePullRequestTool(ctx) {
2685
2829
 
2686
2830
  // src/tools/update-pull-request-feedback.ts
2687
2831
  import {
2688
- definePluginTool as definePluginTool12,
2689
- PluginToolInputError as PluginToolInputError12,
2690
- pluginToolOutputSchema as pluginToolOutputSchema12
2832
+ definePluginTool as definePluginTool13,
2833
+ PluginToolInputError as PluginToolInputError13,
2834
+ pluginToolOutputSchema as pluginToolOutputSchema13
2691
2835
  } from "@sentry/junior-plugin-api";
2692
- import * as z17 from "zod";
2836
+ import * as z18 from "zod";
2693
2837
  var STATUS_TO_REACTION_CONTENT = {
2694
2838
  reviewing: "eyes",
2695
2839
  addressed: "+1",
@@ -2698,24 +2842,24 @@ var STATUS_TO_REACTION_CONTENT = {
2698
2842
  var FEEDBACK_REACTION_CONTENTS = new Set(
2699
2843
  Object.values(STATUS_TO_REACTION_CONTENT)
2700
2844
  );
2701
- var inputSchema10 = z17.object({
2702
- repo: z17.string().describe('Repository in "owner/name" format.'),
2703
- comment_kind: z17.enum(["conversation", "review"]).describe(
2845
+ var inputSchema11 = z18.object({
2846
+ repo: z18.string().describe('Repository in "owner/name" format.'),
2847
+ comment_kind: z18.enum(["conversation", "review"]).describe(
2704
2848
  'Comment kind: "conversation" for a pull request conversation comment, "review" for an inline review comment.'
2705
2849
  ),
2706
- comment_id: z17.number().int().positive().describe(
2850
+ comment_id: z18.number().int().positive().describe(
2707
2851
  "GitHub comment id (conversation comment id or inline review comment id)."
2708
2852
  ),
2709
- status: z17.enum(["addressed", "declined"]).describe(
2853
+ status: z18.enum(["addressed", "declined"]).describe(
2710
2854
  "Feedback outcome. Maps to a reaction: addressed -> +1, declined -> -1."
2711
2855
  )
2712
2856
  }).strict();
2713
- var outputSchema10 = pluginToolOutputSchema12.extend({
2714
- target: z17.literal("updatePullRequestFeedback"),
2715
- repo: z17.string(),
2716
- comment_id: z17.number(),
2717
- status: z17.enum(["addressed", "declined"]),
2718
- reaction_id: z17.number()
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()
2719
2863
  });
2720
2864
  function pullRequestCommentPath(input) {
2721
2865
  const segment = input.commentKind === "conversation" ? "issues" : "pulls";
@@ -2727,10 +2871,10 @@ function pullRequestCommentReactionsPath(input) {
2727
2871
  function pullRequestFeedbackReactionContent(status) {
2728
2872
  return STATUS_TO_REACTION_CONTENT[status];
2729
2873
  }
2730
- var reactionSchema = z17.object({
2731
- id: z17.number(),
2732
- content: z17.string(),
2733
- user: z17.object({ id: z17.number() }).nullable()
2874
+ var reactionSchema = z18.object({
2875
+ id: z18.number(),
2876
+ content: z18.string(),
2877
+ user: z18.object({ id: z18.number() }).nullable()
2734
2878
  });
2735
2879
  async function assertBotAuthoredPullRequest(egress, input) {
2736
2880
  const commentResponse = await githubApi(egress, {
@@ -2740,21 +2884,21 @@ async function assertBotAuthoredPullRequest(egress, input) {
2740
2884
  const commentPayload = commentResponse.body;
2741
2885
  if (!commentResponse.ok) {
2742
2886
  const message = `GitHub comment lookup failed with HTTP ${commentResponse.status}: ${githubErrorMessage(commentPayload)}`;
2743
- if (commentResponse.status === 404) throw new PluginToolInputError12(message);
2887
+ if (commentResponse.status === 404) throw new PluginToolInputError13(message);
2744
2888
  throw new Error(message);
2745
2889
  }
2746
- const comment = z17.object({
2747
- issue_url: z17.string().optional(),
2748
- pull_request_url: z17.string().optional()
2890
+ const comment = z18.object({
2891
+ issue_url: z18.string().optional(),
2892
+ pull_request_url: z18.string().optional()
2749
2893
  }).safeParse(commentPayload);
2750
2894
  const parentUrl = comment.success ? input.commentKind === "conversation" ? comment.data.issue_url : comment.data.pull_request_url : void 0;
2751
- const number22 = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
2752
- if (!number22) {
2895
+ const number23 = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
2896
+ if (!number23) {
2753
2897
  throw new Error("GitHub comment did not name its issue or pull request.");
2754
2898
  }
2755
2899
  const pullResponse = await githubApi(egress, {
2756
2900
  operation: "github.pull.get",
2757
- path: `${repoPath(input)}/pulls/${number22}`
2901
+ path: `${repoPath(input)}/pulls/${number23}`
2758
2902
  });
2759
2903
  const pullPayload = pullResponse.body;
2760
2904
  if (!pullResponse.ok && pullResponse.status !== 404) {
@@ -2762,15 +2906,15 @@ async function assertBotAuthoredPullRequest(egress, input) {
2762
2906
  `GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${githubErrorMessage(pullPayload)}`
2763
2907
  );
2764
2908
  }
2765
- const pull = z17.object({ user: z17.object({ id: z17.number() }).nullable() }).safeParse(pullPayload);
2909
+ const pull = z18.object({ user: z18.object({ id: z18.number() }).nullable() }).safeParse(pullPayload);
2766
2910
  if (!pullResponse.ok || !pull.success || pull.data.user?.id !== input.botUserId) {
2767
- throw new PluginToolInputError12(
2911
+ throw new PluginToolInputError13(
2768
2912
  "This bot can only set feedback status on comments on pull requests it authored."
2769
2913
  );
2770
2914
  }
2771
2915
  }
2772
2916
  function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2773
- return definePluginTool12({
2917
+ return definePluginTool13({
2774
2918
  // No action review: the tool checks in code that the bot authored the pull
2775
2919
  // request, and it changes only the bot's own reaction, which is reversible.
2776
2920
  approvalMode: "approve",
@@ -2782,12 +2926,12 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2782
2926
  },
2783
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.",
2784
2928
  exposure: "direct",
2785
- inputSchema: inputSchema10,
2786
- outputSchema: outputSchema10,
2929
+ inputSchema: inputSchema11,
2930
+ outputSchema: outputSchema11,
2787
2931
  async execute(input) {
2788
- const parsedInput = inputSchema10.safeParse(input);
2932
+ const parsedInput = inputSchema11.safeParse(input);
2789
2933
  if (!parsedInput.success) {
2790
- throw new PluginToolInputError12(
2934
+ throw new PluginToolInputError13(
2791
2935
  "Invalid GitHub updatePullRequestFeedback input.",
2792
2936
  { cause: parsedInput.error }
2793
2937
  );
@@ -2826,7 +2970,7 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2826
2970
  `GitHub reaction lookup failed with HTTP ${listResponse.status}: ${githubErrorMessage(listPayload)}`
2827
2971
  );
2828
2972
  }
2829
- const botReactions = z17.array(reactionSchema).parse(listPayload).filter(
2973
+ const botReactions = z18.array(reactionSchema).parse(listPayload).filter(
2830
2974
  (reaction) => reaction.user?.id === botUserId && FEEDBACK_REACTION_CONTENTS.has(reaction.content)
2831
2975
  );
2832
2976
  const existing = botReactions.find(
@@ -2880,28 +3024,28 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
2880
3024
 
2881
3025
  // src/tools/resolve-pull-request-review-thread.ts
2882
3026
  import {
2883
- definePluginTool as definePluginTool13,
2884
- PluginToolInputError as PluginToolInputError13,
2885
- pluginToolOutputSchema as pluginToolOutputSchema13
3027
+ definePluginTool as definePluginTool14,
3028
+ PluginToolInputError as PluginToolInputError14,
3029
+ pluginToolOutputSchema as pluginToolOutputSchema14
2886
3030
  } from "@sentry/junior-plugin-api";
2887
- import * as z18 from "zod";
2888
- var inputSchema11 = z18.object({
2889
- repo: z18.string().describe(
3031
+ import * as z19 from "zod";
3032
+ var inputSchema12 = z19.object({
3033
+ repo: z19.string().describe(
2890
3034
  'Repository in "owner/name" format. Required because GraphQL has no repo path.'
2891
3035
  ),
2892
- thread_id: z18.string().trim().min(1).describe(
3036
+ thread_id: z19.string().trim().min(1).describe(
2893
3037
  "GitHub pull request review thread node ID (the `threadId` / `id` variable used by `gh api graphql` resolveReviewThread)."
2894
3038
  )
2895
3039
  }).strict();
2896
- var outputSchema11 = pluginToolOutputSchema13.extend({
2897
- target: z18.literal("resolvePullRequestReviewThread"),
2898
- repo: z18.string(),
2899
- number: z18.number(),
2900
- thread_id: z18.string(),
2901
- resolved: z18.boolean()
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()
2902
3046
  });
2903
3047
  function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
2904
- return definePluginTool13({
3048
+ return definePluginTool14({
2905
3049
  // No action review: the tool checks in code that the bot authored the pull
2906
3050
  // request, and it changes only the thread's resolved state, which is
2907
3051
  // reversible.
@@ -2914,12 +3058,12 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
2914
3058
  },
2915
3059
  description: "Resolve a GitHub pull request review thread after acting on its feedback. Only works on pull requests the bot authored.",
2916
3060
  exposure: "direct",
2917
- inputSchema: inputSchema11,
2918
- outputSchema: outputSchema11,
3061
+ inputSchema: inputSchema12,
3062
+ outputSchema: outputSchema12,
2919
3063
  async execute(input) {
2920
- const parsedInput = inputSchema11.safeParse(input);
3064
+ const parsedInput = inputSchema12.safeParse(input);
2921
3065
  if (!parsedInput.success) {
2922
- throw new PluginToolInputError13(
3066
+ throw new PluginToolInputError14(
2923
3067
  "Invalid GitHub resolvePullRequestReviewThread input.",
2924
3068
  { cause: parsedInput.error }
2925
3069
  );
@@ -2958,31 +3102,31 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
2958
3102
  `GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubErrorMessage(lookupPayload)}`
2959
3103
  );
2960
3104
  }
2961
- const threadNodeSchema = z18.object({
2962
- id: z18.string(),
2963
- isResolved: z18.boolean(),
2964
- pullRequest: z18.object({
2965
- author: z18.object({ databaseId: z18.number().optional() }).passthrough().nullable(),
2966
- number: z18.number(),
2967
- repository: z18.object({ nameWithOwner: z18.string() }).passthrough()
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()
2968
3112
  }).passthrough()
2969
3113
  }).passthrough();
2970
- const lookupResultSchema = z18.object({
2971
- data: z18.object({
2972
- node: z18.unknown().nullable().optional()
3114
+ const lookupResultSchema = z19.object({
3115
+ data: z19.object({
3116
+ node: z19.unknown().nullable().optional()
2973
3117
  }).passthrough()
2974
3118
  }).passthrough();
2975
3119
  const lookupResult = lookupResultSchema.safeParse(lookupPayload);
2976
3120
  const rawNode = lookupResult.success ? lookupResult.data.data.node : void 0;
2977
3121
  const parsedNode = rawNode == null ? void 0 : threadNodeSchema.safeParse(rawNode);
2978
3122
  if (!parsedNode?.success) {
2979
- throw new PluginToolInputError13("GitHub review thread was not found.");
3123
+ throw new PluginToolInputError14("GitHub review thread was not found.");
2980
3124
  }
2981
3125
  const thread = parsedNode.data;
2982
3126
  const pullRequest = thread.pullRequest;
2983
3127
  const ownsPullRequest = pullRequest.repository.nameWithOwner.toLowerCase() === repo.ref.toLowerCase() && pullRequest.author?.databaseId === botUserId;
2984
3128
  if (!ownsPullRequest) {
2985
- throw new PluginToolInputError13(
3129
+ throw new PluginToolInputError14(
2986
3130
  "This bot can only resolve review threads on pull requests it authored."
2987
3131
  );
2988
3132
  }
@@ -3016,10 +3160,10 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
3016
3160
  `GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubErrorMessage(resolvePayload)}`
3017
3161
  );
3018
3162
  }
3019
- const resolveResultSchema = z18.object({
3020
- data: z18.object({
3021
- resolveReviewThread: z18.object({
3022
- thread: z18.object({ id: z18.string(), isResolved: z18.boolean() }).passthrough()
3163
+ const resolveResultSchema = z19.object({
3164
+ data: z19.object({
3165
+ resolveReviewThread: z19.object({
3166
+ thread: z19.object({ id: z19.string(), isResolved: z19.boolean() }).passthrough()
3023
3167
  }).passthrough()
3024
3168
  }).passthrough()
3025
3169
  }).passthrough();
@@ -3047,46 +3191,46 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
3047
3191
 
3048
3192
  // src/tools/submit-pull-request-review.ts
3049
3193
  import {
3050
- definePluginTool as definePluginTool14,
3051
- PluginToolInputError as PluginToolInputError14,
3052
- pluginToolOutputSchema as pluginToolOutputSchema14
3194
+ definePluginTool as definePluginTool15,
3195
+ PluginToolInputError as PluginToolInputError15,
3196
+ pluginToolOutputSchema as pluginToolOutputSchema15
3053
3197
  } from "@sentry/junior-plugin-api";
3054
- import * as z19 from "zod";
3055
- var reviewCommentSchema = z19.object({
3056
- path: z19.string().trim().min(1).describe("File path in the pull request."),
3057
- body: z19.string().trim().min(1).describe("Inline review comment."),
3058
- line: z19.number().int().positive().describe("Line in the pull request diff."),
3059
- side: z19.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
3060
- start_line: z19.number().int().positive().optional().describe("First line of a multi-line comment."),
3061
- start_side: z19.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
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.")
3062
3206
  }).strict().refine(
3063
3207
  ({ start_line, start_side }) => start_line === void 0 === (start_side === void 0),
3064
3208
  { message: "start_line and start_side must be provided together." }
3065
3209
  );
3066
- var inputSchema12 = z19.object({
3067
- repo: z19.string().describe('Repository in "owner/name" format.'),
3068
- number: z19.number().int().positive().describe("Pull request number."),
3069
- event: z19.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
3070
- body: z19.string().trim().min(1).describe("Review summary."),
3071
- comments: z19.array(reviewCommentSchema).optional().describe("Optional inline review 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.")
3072
3216
  }).strict();
3073
- var outputSchema12 = pluginToolOutputSchema14.extend({
3074
- target: z19.literal("submitPullRequestReview"),
3075
- repo: z19.string(),
3076
- number: z19.number(),
3077
- review_id: z19.number(),
3078
- state: z19.string(),
3079
- url: z19.string()
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()
3080
3224
  });
3081
3225
  function throwReviewError(status, body) {
3082
3226
  const message = `GitHub pull request review failed with HTTP ${status}: ${githubErrorMessage(body)}`;
3083
3227
  if (status === 404 || status === 422) {
3084
- throw new PluginToolInputError14(message);
3228
+ throw new PluginToolInputError15(message);
3085
3229
  }
3086
3230
  throw new Error(message);
3087
3231
  }
3088
3232
  function createGitHubSubmitPullRequestReviewTool(egress) {
3089
- return definePluginTool14({
3233
+ return definePluginTool15({
3090
3234
  annotations: {
3091
3235
  destructiveHint: true,
3092
3236
  idempotentHint: false,
@@ -3095,8 +3239,8 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
3095
3239
  },
3096
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.",
3097
3241
  exposure: "direct",
3098
- inputSchema: inputSchema12,
3099
- outputSchema: outputSchema12,
3242
+ inputSchema: inputSchema13,
3243
+ outputSchema: outputSchema13,
3100
3244
  async execute(review) {
3101
3245
  const repo = parseRepo(review.repo);
3102
3246
  const comments = review.comments?.map((comment) => ({
@@ -3120,7 +3264,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
3120
3264
  if (!response.ok) {
3121
3265
  throwReviewError(response.status, response.body);
3122
3266
  }
3123
- const providerResult = z19.object({ id: z19.number(), html_url: z19.string(), state: z19.string() }).parse(response.body);
3267
+ const providerResult = z20.object({ id: z20.number(), html_url: z20.string(), state: z20.string() }).parse(response.body);
3124
3268
  return {
3125
3269
  target: "submitPullRequestReview",
3126
3270
  repo: repo.ref,
@@ -3144,6 +3288,7 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
3144
3288
  pullRequestSubscription
3145
3289
  ),
3146
3290
  getDeployment: createGitHubGetDeploymentTool(ctx),
3291
+ getIssue: createGitHubGetIssueTool(ctx),
3147
3292
  getPullRequest: createGitHubGetPullRequestTool(ctx),
3148
3293
  getRelease: createGitHubGetReleaseTool(ctx),
3149
3294
  getRepository: createGitHubGetRepositoryTool(ctx),
@@ -3163,26 +3308,26 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
3163
3308
 
3164
3309
  // src/webhooks/handler.ts
3165
3310
  import { createHmac, timingSafeEqual } from "crypto";
3166
- import * as z29 from "zod";
3311
+ import * as z30 from "zod";
3167
3312
 
3168
3313
  // src/issue-outcomes/store.ts
3169
3314
  import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
3170
- import * as z20 from "zod";
3171
- var githubIssueOutcomeInputSchema = z20.object({
3172
- candidateOwned: z20.boolean(),
3173
- closedAt: z20.date().optional(),
3174
- issueId: z20.string().min(1),
3175
- number: z20.number().int().positive(),
3176
- openedAt: z20.date(),
3177
- repositoryFullName: z20.string().min(1),
3178
- repositoryId: z20.string().min(1),
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),
3179
3324
  state: githubIssueStateSchema,
3180
3325
  stateReason: githubIssueStateReasonSchema.optional(),
3181
- updatedAt: z20.date()
3326
+ updatedAt: z21.date()
3182
3327
  }).strict();
3183
- var githubIssueConversationsInputSchema = z20.object({
3184
- conversationIds: z20.array(z20.string().min(1)).min(1),
3185
- issueId: z20.string().min(1)
3328
+ var githubIssueConversationsInputSchema = z21.object({
3329
+ conversationIds: z21.array(z21.string().min(1)).min(1),
3330
+ issueId: z21.string().min(1)
3186
3331
  }).strict();
3187
3332
  function projectionValues(input) {
3188
3333
  return {
@@ -3246,33 +3391,33 @@ async function recordGitHubIssueConversations(db, input) {
3246
3391
 
3247
3392
  // src/pull-request-outcomes/store.ts
3248
3393
  import { and as and3, eq as eq3, lte as lte2, ne, sql as sql3 } from "drizzle-orm";
3249
- import * as z21 from "zod";
3250
- var githubPullRequestOutcomeInputSchema = z21.object({
3251
- candidateOwned: z21.boolean(),
3252
- closedAt: z21.date().optional(),
3394
+ import * as z22 from "zod";
3395
+ var githubPullRequestOutcomeInputSchema = z22.object({
3396
+ candidateOwned: z22.boolean(),
3397
+ closedAt: z22.date().optional(),
3253
3398
  commitComposition: githubPullRequestCommitCompositionSchema.optional(),
3254
- mergedAt: z21.date().optional(),
3255
- number: z21.number().int().positive(),
3256
- openedAt: z21.date(),
3257
- pullRequestId: z21.string().min(1),
3258
- repositoryFullName: z21.string().min(1),
3259
- repositoryId: z21.string().min(1),
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),
3260
3405
  state: githubPullRequestStateSchema,
3261
- title: z21.string().min(1).optional(),
3262
- updatedAt: z21.date()
3406
+ title: z22.string().min(1).optional(),
3407
+ updatedAt: z22.date()
3263
3408
  }).strict();
3264
- var githubPullRequestConversationsInputSchema = z21.object({
3265
- conversationIds: z21.array(z21.string().min(1)).min(1),
3266
- pullRequestId: z21.string().min(1)
3409
+ var githubPullRequestConversationsInputSchema = z22.object({
3410
+ conversationIds: z22.array(z22.string().min(1)).min(1),
3411
+ pullRequestId: z22.string().min(1)
3267
3412
  }).strict();
3268
- var githubPullRequestLinkedIssuesInputSchema = z21.object({
3269
- linkedIssues: z21.array(
3270
- z21.object({
3271
- number: z21.number().int().positive(),
3272
- repositoryFullName: z21.string().min(1)
3413
+ var githubPullRequestLinkedIssuesInputSchema = z22.object({
3414
+ linkedIssues: z22.array(
3415
+ z22.object({
3416
+ number: z22.number().int().positive(),
3417
+ repositoryFullName: z22.string().min(1)
3273
3418
  }).strict()
3274
3419
  ).min(1),
3275
- pullRequestId: z21.string().min(1)
3420
+ pullRequestId: z22.string().min(1)
3276
3421
  }).strict();
3277
3422
  function projectionValues2(input) {
3278
3423
  return {
@@ -3477,39 +3622,39 @@ async function releaseGitHubPullRequestReadySync(db, target, claim) {
3477
3622
  }
3478
3623
 
3479
3624
  // src/webhooks/issue-outcome.ts
3480
- import * as z22 from "zod";
3481
- var canonicalIssueOutcomeSchema = z22.object({
3482
- action: z22.enum(["opened", "closed", "reopened"]),
3483
- issue: z22.object({
3484
- body: z22.string().nullable().optional(),
3485
- closed_at: z22.string().nullable().optional(),
3486
- created_at: z22.string(),
3487
- id: z22.number().int().positive(),
3488
- number: z22.number().int().positive(),
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(),
3489
3634
  state_reason: githubIssueStateReasonSchema.nullable().optional(),
3490
- updated_at: z22.string(),
3491
- user: z22.object({ login: z22.string().min(1) }).strict()
3635
+ updated_at: z23.string(),
3636
+ user: z23.object({ login: z23.string().min(1) }).strict()
3492
3637
  }).strict(),
3493
- repository: z22.object({
3494
- full_name: z22.string().min(1),
3495
- id: z22.number().int().positive()
3638
+ repository: z23.object({
3639
+ full_name: z23.string().min(1),
3640
+ id: z23.number().int().positive()
3496
3641
  }).strict()
3497
3642
  }).strict();
3498
- var issueOutcomeSchema = z22.object({
3499
- action: z22.enum(["opened", "closed", "reopened"]),
3500
- issue: z22.object({
3501
- body: z22.string().nullable().optional(),
3502
- closed_at: z22.string().nullable().optional(),
3503
- created_at: z22.string(),
3504
- id: z22.number().int().positive(),
3505
- number: z22.number().int().positive(),
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(),
3506
3651
  state_reason: githubIssueStateReasonSchema.nullable().optional(),
3507
- updated_at: z22.string(),
3508
- user: z22.object({ login: z22.string().min(1) }).passthrough()
3652
+ updated_at: z23.string(),
3653
+ user: z23.object({ login: z23.string().min(1) }).passthrough()
3509
3654
  }).passthrough(),
3510
- repository: z22.object({
3511
- full_name: z22.string().min(1),
3512
- id: z22.number().int().positive()
3655
+ repository: z23.object({
3656
+ full_name: z23.string().min(1),
3657
+ id: z23.number().int().positive()
3513
3658
  }).passthrough()
3514
3659
  }).passthrough().transform(
3515
3660
  (provider) => canonicalIssueOutcomeSchema.parse({
@@ -3530,7 +3675,7 @@ var issueOutcomeSchema = z22.object({
3530
3675
  }
3531
3676
  })
3532
3677
  );
3533
- var issueLifecycleActionSchema = z22.object({ action: z22.string() }).passthrough();
3678
+ var issueLifecycleActionSchema = z23.object({ action: z23.string() }).passthrough();
3534
3679
  function timestamp2(value) {
3535
3680
  if (!value) return void 0;
3536
3681
  const parsed = new Date(value);
@@ -3574,21 +3719,21 @@ function normalizeGitHubIssueOutcome(args) {
3574
3719
  updatedAt
3575
3720
  };
3576
3721
  }
3577
- var canonicalIssueConversationSchema = z22.object({
3578
- issue: z22.object({
3579
- body: z22.string().nullable().optional(),
3580
- id: z22.number().int().positive(),
3581
- user: z22.object({ login: z22.string().min(1) }).strict()
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()
3582
3727
  }).strict(),
3583
- sender: z22.object({ login: z22.string().min(1) }).strict().optional()
3728
+ sender: z23.object({ login: z23.string().min(1) }).strict().optional()
3584
3729
  }).strict();
3585
- var issueConversationSchema = z22.object({
3586
- issue: z22.object({
3587
- body: z22.string().nullable().optional(),
3588
- id: z22.number().int().positive(),
3589
- user: z22.object({ login: z22.string().min(1) }).passthrough()
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()
3590
3735
  }).passthrough(),
3591
- sender: z22.object({ login: z22.string().min(1) }).passthrough().optional()
3736
+ sender: z23.object({ login: z23.string().min(1) }).passthrough().optional()
3592
3737
  }).passthrough().transform(
3593
3738
  (provider) => canonicalIssueConversationSchema.parse({
3594
3739
  issue: {
@@ -3615,43 +3760,43 @@ function normalizeGitHubIssueConversations(args) {
3615
3760
  }
3616
3761
 
3617
3762
  // src/webhooks/pull-request-outcome.ts
3618
- import * as z23 from "zod";
3619
- var canonicalPullRequestOutcomeSchema = z23.object({
3620
- action: z23.enum(["opened", "closed", "reopened"]),
3621
- pull_request: z23.object({
3622
- body: z23.string().nullable().optional(),
3623
- closed_at: z23.string().nullable().optional(),
3624
- created_at: z23.string(),
3625
- id: z23.number().int().positive(),
3626
- merged: z23.boolean(),
3627
- merged_at: z23.string().nullable().optional(),
3628
- number: z23.number().int().positive(),
3629
- title: z23.string().min(1).optional(),
3630
- updated_at: z23.string(),
3631
- user: z23.object({ login: z23.string().min(1) }).strict()
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()
3632
3777
  }).strict(),
3633
- repository: z23.object({
3634
- full_name: z23.string().min(1),
3635
- id: z23.number().int().positive()
3778
+ repository: z24.object({
3779
+ full_name: z24.string().min(1),
3780
+ id: z24.number().int().positive()
3636
3781
  }).strict()
3637
3782
  }).strict();
3638
- var pullRequestOutcomeSchema = z23.object({
3639
- action: z23.enum(["opened", "closed", "reopened"]),
3640
- pull_request: z23.object({
3641
- body: z23.string().nullable().optional(),
3642
- closed_at: z23.string().nullable().optional(),
3643
- created_at: z23.string(),
3644
- id: z23.number().int().positive(),
3645
- merged: z23.boolean(),
3646
- merged_at: z23.string().nullable().optional(),
3647
- number: z23.number().int().positive(),
3648
- title: z23.string().min(1).optional(),
3649
- updated_at: z23.string(),
3650
- user: z23.object({ login: z23.string().min(1) }).passthrough()
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()
3651
3796
  }).passthrough(),
3652
- repository: z23.object({
3653
- full_name: z23.string().min(1),
3654
- id: z23.number().int().positive()
3797
+ repository: z24.object({
3798
+ full_name: z24.string().min(1),
3799
+ id: z24.number().int().positive()
3655
3800
  }).passthrough()
3656
3801
  }).passthrough().transform(
3657
3802
  (provider) => canonicalPullRequestOutcomeSchema.parse({
@@ -3674,24 +3819,24 @@ var pullRequestOutcomeSchema = z23.object({
3674
3819
  }
3675
3820
  })
3676
3821
  );
3677
- var pullRequestLifecycleActionSchema = z23.object({ action: z23.string() }).passthrough();
3678
- var canonicalPullRequestConversationSchema = z23.object({
3679
- pull_request: z23.object({
3680
- body: z23.string().nullable().optional(),
3681
- id: z23.number().int().positive(),
3682
- user: z23.object({ login: z23.string().min(1) }).strict()
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()
3683
3828
  }).strict(),
3684
- repository: z23.object({ full_name: z23.string().min(1) }).strict(),
3685
- sender: z23.object({ login: z23.string().min(1) }).strict()
3829
+ repository: z24.object({ full_name: z24.string().min(1) }).strict(),
3830
+ sender: z24.object({ login: z24.string().min(1) }).strict()
3686
3831
  }).strict();
3687
- var pullRequestConversationSchema = z23.object({
3688
- pull_request: z23.object({
3689
- body: z23.string().nullable().optional(),
3690
- id: z23.number().int().positive(),
3691
- user: z23.object({ login: z23.string().min(1) }).passthrough()
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()
3692
3837
  }).passthrough(),
3693
- repository: z23.object({ full_name: z23.string().min(1) }).passthrough(),
3694
- sender: z23.object({ login: z23.string().min(1) }).passthrough()
3838
+ repository: z24.object({ full_name: z24.string().min(1) }).passthrough(),
3839
+ sender: z24.object({ login: z24.string().min(1) }).passthrough()
3695
3840
  }).passthrough().transform(
3696
3841
  (provider) => canonicalPullRequestConversationSchema.parse({
3697
3842
  pull_request: {
@@ -3778,20 +3923,20 @@ function normalizeGitHubPullRequestLinkedIssues(args) {
3778
3923
  }
3779
3924
 
3780
3925
  // src/webhooks/merge-conflict.ts
3781
- import * as z24 from "zod";
3926
+ import * as z25 from "zod";
3782
3927
  var EVENT_TYPE = "pull_request.merge_conflict";
3783
3928
  var CLOSED_EVENT_TYPES = /* @__PURE__ */ new Set([
3784
3929
  "pull_request.closed_unmerged",
3785
3930
  "pull_request.merged"
3786
3931
  ]);
3787
- var pullRequestSchema3 = z24.object({
3788
- base: z24.object({ ref: z24.string().min(1) }),
3789
- number: z24.number().int().positive().optional(),
3790
- head: z24.object({ sha: z24.string().min(1) }),
3791
- html_url: z24.string().min(1).optional(),
3792
- mergeable: z24.boolean().nullable().optional(),
3793
- mergeable_state: z24.string().optional(),
3794
- state: z24.string()
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()
3795
3940
  });
3796
3941
  function gitHubMergeConflictEvents(input) {
3797
3942
  const { conflict } = input;
@@ -3831,7 +3976,7 @@ async function hasMatch(hasMatchEvent, ref) {
3831
3976
  return false;
3832
3977
  }
3833
3978
  function deliveredPullRequest(payload, ref) {
3834
- const parsed = z24.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
3979
+ const parsed = z25.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
3835
3980
  const pullRequest = parsed.success ? parsed.data.pull_request : void 0;
3836
3981
  return pullRequest?.number === ref.number && typeof pullRequest.mergeable === "boolean" ? pullRequest : void 0;
3837
3982
  }
@@ -3869,10 +4014,10 @@ async function loadGitHubMergeConflictEvents(args) {
3869
4014
  }
3870
4015
 
3871
4016
  // src/webhooks/pull-request-ready.ts
3872
- import * as z26 from "zod";
4017
+ import * as z27 from "zod";
3873
4018
 
3874
4019
  // src/webhooks/installation-requests.ts
3875
- import * as z25 from "zod";
4020
+ import * as z26 from "zod";
3876
4021
  function splitRepository(fullName, label) {
3877
4022
  const [owner, name, ...extra] = fullName.split("/");
3878
4023
  if (!owner || !name || extra.length > 0) {
@@ -3933,9 +4078,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
3933
4078
  }
3934
4079
  );
3935
4080
  }
3936
- var repositoryPermissionSchema = z25.object({
3937
- permission: z25.string().min(1),
3938
- role_name: z25.string().optional()
4081
+ var repositoryPermissionSchema = z26.object({
4082
+ permission: z26.string().min(1),
4083
+ role_name: z26.string().optional()
3939
4084
  });
3940
4085
  var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
3941
4086
  async function loadRepositoryRole(env, cache, target) {
@@ -3965,18 +4110,19 @@ async function loadRepositoryRole(env, cache, target) {
3965
4110
  }
3966
4111
  );
3967
4112
  }
3968
- var pullRequestSchema4 = z25.object({
3969
- draft: z25.boolean().optional(),
3970
- html_url: z25.string().url(),
3971
- mergeable_state: z25.string().nullable().optional(),
3972
- merged: z25.boolean(),
3973
- state: z25.enum(["open", "closed"]),
3974
- title: z25.string()
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()
3975
4121
  });
3976
- var reviewsSchema = z25.array(
3977
- z25.object({
3978
- state: z25.string(),
3979
- user: z25.object({ login: z25.string() }).nullable()
4122
+ var reviewsSchema = z26.array(
4123
+ z26.object({
4124
+ state: z26.string(),
4125
+ user: z26.object({ login: z26.string() }).nullable()
3980
4126
  })
3981
4127
  );
3982
4128
  async function loadPullRequestMergeState(env, pullRequest) {
@@ -3999,6 +4145,7 @@ async function loadPullRequestMergeState(env, pullRequest) {
3999
4145
  const mergeableState = pull.mergeable_state && pull.mergeable_state !== "unknown" ? pull.mergeable_state : void 0;
4000
4146
  return {
4001
4147
  approved: false,
4148
+ autoMerge: Boolean(pull.auto_merge),
4002
4149
  draft: pull.draft === true,
4003
4150
  ...mergeableState ? { mergeableState } : void 0,
4004
4151
  state: pull.merged ? "merged" : pull.state,
@@ -4007,7 +4154,7 @@ async function loadPullRequestMergeState(env, pullRequest) {
4007
4154
  };
4008
4155
  };
4009
4156
  let state = await readPull();
4010
- if (state.state !== "open" || state.draft) return state;
4157
+ if (state.state !== "open" || state.draft || state.autoMerge) return state;
4011
4158
  if (!state.mergeableState) state = await readPull();
4012
4159
  if (state.mergeableState !== "clean") return state;
4013
4160
  const reviews = [];
@@ -4033,6 +4180,8 @@ async function loadPullRequestMergeState(env, pullRequest) {
4033
4180
  var READY_SYNC_STALE_MS = 6e4;
4034
4181
  var READY_ACTIONS = {
4035
4182
  pull_request: /* @__PURE__ */ new Set([
4183
+ "auto_merge_disabled",
4184
+ "auto_merge_enabled",
4036
4185
  "closed",
4037
4186
  "converted_to_draft",
4038
4187
  "ready_for_review",
@@ -4041,10 +4190,10 @@ var READY_ACTIONS = {
4041
4190
  ]),
4042
4191
  pull_request_review: /* @__PURE__ */ new Set(["dismissed", "submitted"])
4043
4192
  };
4044
- var pullRequestWebhookSchema = z26.object({
4045
- action: z26.string(),
4046
- pull_request: z26.object({ number: z26.number().int().positive() }),
4047
- repository: z26.object({ full_name: z26.string().min(1) })
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) })
4048
4197
  });
4049
4198
  function pullRequestReadyTargets(eventName, body) {
4050
4199
  if (eventName === "check_suite") return checkSuitePullRequests(body);
@@ -4070,6 +4219,9 @@ function closeReason(state) {
4070
4219
  status: "dismissed"
4071
4220
  };
4072
4221
  }
4222
+ if (state.autoMerge) {
4223
+ return { reason: "Auto-merge is on.", status: "dismissed" };
4224
+ }
4073
4225
  return {
4074
4226
  reason: "The pull request is no longer ready to merge.",
4075
4227
  status: "dismissed"
@@ -4097,8 +4249,8 @@ async function syncOne(args, target) {
4097
4249
  try {
4098
4250
  const state = await loadPullRequestMergeState(args.env, target);
4099
4251
  const open = state.state === "open" && !state.draft;
4100
- const ready = open && state.mergeableState === "clean" && state.approved;
4101
- 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) {
4102
4254
  if (ready) {
4103
4255
  await items.upsert({
4104
4256
  assigneeIdentityIds: [opener.identityId],
@@ -4139,7 +4291,7 @@ async function syncGitHubPullRequestReadyNotices(args) {
4139
4291
  }
4140
4292
 
4141
4293
  // src/webhooks/pull-request-match-data.ts
4142
- import * as z27 from "zod";
4294
+ import * as z28 from "zod";
4143
4295
  var LOOKUPS_BY_MATCH_KEY = {
4144
4296
  authors: ["authors"],
4145
4297
  openerEmail: ["opener"],
@@ -4147,22 +4299,22 @@ var LOOKUPS_BY_MATCH_KEY = {
4147
4299
  openerUsername: ["opener"]
4148
4300
  };
4149
4301
  var ALL_LOOKUPS = ["authors", "opener", "openerRole"];
4150
- var lookupDataSchema = z27.object({
4151
- authors: z27.array(z27.string().min(1)).min(1).optional(),
4152
- openerRole: z27.string().min(1).optional(),
4153
- openerUsername: z27.string().min(1).optional()
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()
4154
4306
  }).strict();
4155
4307
  function lookupData(input) {
4156
4308
  return lookupDataSchema.parse(definedValues(input));
4157
4309
  }
4158
- var webhookSchema = z27.object({
4159
- repository: z27.object({ full_name: z27.string().min(1) })
4310
+ var webhookSchema = z28.object({
4311
+ repository: z28.object({ full_name: z28.string().min(1) })
4160
4312
  });
4161
4313
  function pullRequestNumbers(events) {
4162
4314
  const numbers = /* @__PURE__ */ new Map();
4163
4315
  for (const event of events) {
4164
- const number22 = event.data?.pullRequest;
4165
- if (typeof number22 === "number") numbers.set(event.eventKey, number22);
4316
+ const number23 = event.data?.pullRequest;
4317
+ if (typeof number23 === "number") numbers.set(event.eventKey, number23);
4166
4318
  }
4167
4319
  return numbers;
4168
4320
  }
@@ -4176,8 +4328,8 @@ function logFailure(context, lookup, error) {
4176
4328
  }
4177
4329
  async function withJuniorOpeners(context, events) {
4178
4330
  const botNumber = (event) => {
4179
- const number22 = context.numbers.get(event.eventKey);
4180
- return number22 !== void 0 && isBotLogin(event.data?.openerUsername, context.botEmail) ? number22 : void 0;
4331
+ const number23 = context.numbers.get(event.eventKey);
4332
+ return number23 !== void 0 && isBotLogin(event.data?.openerUsername, context.botEmail) ? number23 : void 0;
4181
4333
  };
4182
4334
  const numbers = events.flatMap((event) => botNumber(event) ?? []);
4183
4335
  if (numbers.length === 0) return events;
@@ -4196,9 +4348,9 @@ async function withJuniorOpeners(context, events) {
4196
4348
  }
4197
4349
  }
4198
4350
  return events.map((event) => {
4199
- const number22 = botNumber(event);
4200
- if (number22 === void 0) return event;
4201
- const identityId = openers.get(number22)?.identityId;
4351
+ const number23 = botNumber(event);
4352
+ if (number23 === void 0) return event;
4353
+ const identityId = openers.get(number23)?.identityId;
4202
4354
  const login = identityId ? logins.get(identityId) : void 0;
4203
4355
  const {
4204
4356
  openerEmail: _email,
@@ -4220,8 +4372,8 @@ async function withRolesAndAuthors(context, events, lookups) {
4220
4372
  if (!loadRole && !loadAuthors) return events;
4221
4373
  return await Promise.all(
4222
4374
  events.map(async (event) => {
4223
- const number22 = context.numbers.get(event.eventKey);
4224
- if (number22 === void 0) return event;
4375
+ const number23 = context.numbers.get(event.eventKey);
4376
+ if (number23 === void 0) return event;
4225
4377
  const login = event.data?.openerUsername;
4226
4378
  if (loadRole && typeof login === "string" && !roles.has(login)) {
4227
4379
  roles.set(
@@ -4231,16 +4383,16 @@ async function withRolesAndAuthors(context, events, lookups) {
4231
4383
  )
4232
4384
  );
4233
4385
  }
4234
- if (loadAuthors && !authors.has(number22)) {
4386
+ if (loadAuthors && !authors.has(number23)) {
4235
4387
  authors.set(
4236
- number22,
4237
- loadAuthors({ number: number22, repositoryFullName }).catch(
4388
+ number23,
4389
+ loadAuthors({ number: number23, repositoryFullName }).catch(
4238
4390
  (error) => logFailure(context, "authors", error)
4239
4391
  )
4240
4392
  );
4241
4393
  }
4242
4394
  const role = loadRole && typeof login === "string" ? await roles.get(login) : void 0;
4243
- const logins = loadAuthors ? await authors.get(number22) : void 0;
4395
+ const logins = loadAuthors ? await authors.get(number23) : void 0;
4244
4396
  if (!role && !logins?.length) return event;
4245
4397
  return {
4246
4398
  ...event,
@@ -4299,7 +4451,7 @@ async function withGitHubPullRequestMatchData(args) {
4299
4451
  }
4300
4452
 
4301
4453
  // src/webhooks/pull-request-people.ts
4302
- import * as z28 from "zod";
4454
+ import * as z29 from "zod";
4303
4455
  var PEOPLE_EVENTS = /* @__PURE__ */ new Set([
4304
4456
  "pull_request.review.approved",
4305
4457
  "pull_request.merged"
@@ -4309,18 +4461,18 @@ var PAGE_SIZE = 100;
4309
4461
  var MAX_PAGES = 3;
4310
4462
  var CO_AUTHOR_TRAILER = /^co-authored-by:[^<\n]*<([^>\s]+@[^>\s]+)>\s*$/gim;
4311
4463
  var GITHUB_NOREPLY_EMAIL = /^(?:\d+\+)?(?<login>[^@+]+)@users\.noreply\.github\.com$/i;
4312
- var webhookSchema2 = z28.object({
4313
- pull_request: z28.object({
4314
- assignees: z28.array(z28.object({ login: z28.string().min(1) })).nullish(),
4315
- number: z28.number(),
4316
- user: z28.object({ login: z28.string().min(1) }).nullish()
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()
4317
4469
  }),
4318
- repository: z28.object({ full_name: z28.string().min(1) })
4470
+ repository: z29.object({ full_name: z29.string().min(1) })
4319
4471
  });
4320
- var commitPageSchema = z28.array(
4321
- z28.object({
4322
- author: z28.object({ login: z28.string().min(1) }).nullish(),
4323
- commit: z28.object({ message: z28.string() })
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() })
4324
4476
  })
4325
4477
  );
4326
4478
  function shareCommitPages(load) {
@@ -4465,10 +4617,10 @@ function webhookInstallationId(body) {
4465
4617
  }
4466
4618
  return parseInstallationId(installation.id);
4467
4619
  }
4468
- var feedbackTargetSchema = z29.object({
4469
- commentId: z29.number(),
4470
- commentKind: z29.enum(["conversation", "review"]),
4471
- repo: z29.string().min(1)
4620
+ var feedbackTargetSchema = z30.object({
4621
+ commentId: z30.number(),
4622
+ commentKind: z30.enum(["conversation", "review"]),
4623
+ repo: z30.string().min(1)
4472
4624
  });
4473
4625
  function pullRequestFeedbackTarget(events) {
4474
4626
  const event = events.find(
@@ -4739,30 +4891,30 @@ function gitHubResourceUrl(input) {
4739
4891
  if (input.resourceType === "repository") {
4740
4892
  return `https://github.com/${input.identifier}`;
4741
4893
  }
4742
- const [repo, number22] = input.identifier.split("#");
4743
- if (!repo || !number22) return void 0;
4894
+ const [repo, number23] = input.identifier.split("#");
4895
+ if (!repo || !number23) return void 0;
4744
4896
  if (input.resourceType === "pull_request") {
4745
- return `https://github.com/${repo}/pull/${number22}`;
4897
+ return `https://github.com/${repo}/pull/${number23}`;
4746
4898
  }
4747
4899
  if (input.resourceType === "issue") {
4748
- return `https://github.com/${repo}/issues/${number22}`;
4900
+ return `https://github.com/${repo}/issues/${number23}`;
4749
4901
  }
4750
4902
  return void 0;
4751
4903
  }
4752
4904
 
4753
4905
  // src/pull-request-outcomes/commit-composition.ts
4754
- import * as z30 from "zod";
4755
- var canonicalCommitSchema = z30.object({
4756
- authorEmail: z30.string().nullable(),
4757
- authorLogin: z30.string().nullable()
4906
+ import * as z31 from "zod";
4907
+ var canonicalCommitSchema = z31.object({
4908
+ authorEmail: z31.string().nullable(),
4909
+ authorLogin: z31.string().nullable()
4758
4910
  }).strict();
4759
- var providerCommitSchema = z30.object({
4760
- author: z30.object({ login: z30.string() }).passthrough().nullable(),
4761
- commit: z30.object({
4762
- author: z30.object({ email: z30.string() }).passthrough().nullable()
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()
4763
4915
  }).passthrough()
4764
4916
  }).passthrough();
4765
- var commitPageSchema2 = z30.array(providerCommitSchema).transform(
4917
+ var commitPageSchema2 = z31.array(providerCommitSchema).transform(
4766
4918
  (commits) => commits.map(
4767
4919
  (commit) => canonicalCommitSchema.parse({
4768
4920
  authorEmail: commit.commit.author?.email ?? null,
@@ -5269,8 +5421,8 @@ function linkifyLine(line) {
5269
5421
  if (isReferenceBoundary(index2 === 0 ? void 0 : line[index2 - 1])) {
5270
5422
  const match = GITHUB_ISSUE_REFERENCE_PATTERN.exec(line.slice(index2));
5271
5423
  if (match) {
5272
- const [reference, owner, repository2, number22] = match;
5273
- output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${number22})`;
5424
+ const [reference, owner, repository2, number23] = match;
5425
+ output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${number23})`;
5274
5426
  index2 += reference.length;
5275
5427
  continue;
5276
5428
  }
@@ -5412,9 +5564,9 @@ function parseGitHubReferences(text2, config) {
5412
5564
  }
5413
5565
  return [...references.values()];
5414
5566
  }
5415
- function objectTitle(kind, object30) {
5416
- if (!isRecord(object30)) return void 0;
5417
- const raw = kind === "commit" ? isRecord(object30.commit) && typeof object30.commit.message === "string" ? object30.commit.message.split("\n")[0] : void 0 : typeof object30.title === "string" ? object30.title : void 0;
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;
5418
5570
  return raw?.replace(/\s+/g, " ").trim() || void 0;
5419
5571
  }
5420
5572
  async function loadGitHubConversationTitleContext(args) {
@@ -5883,6 +6035,15 @@ async function githubPermissionDeniedMessage(ctx) {
5883
6035
  );
5884
6036
  return bodyText ? githubGraphqlPermissionDeniedMessage(bodyText) : void 0;
5885
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
+ }
5886
6047
  var PULL_REQUEST_COMMENT_REACTIONS_PATH = /^\/repos\/[^/]+\/[^/]+\/(issues|pulls)\/comments\/[^/]+\/reactions(?:\/[^/]+)?$/;
5887
6048
  var GITHUB_BODY_WRITES = [
5888
6049
  {
@@ -6033,6 +6194,12 @@ function applyGitHubEgressPolicy(input) {
6033
6194
  denialMessage: "GitHub pull request feedback reactions must use the github_updatePullRequestFeedback tool."
6034
6195
  });
6035
6196
  }
6197
+ if (isGitHubIssueRead(input)) {
6198
+ enforceEgressPolicy({
6199
+ allowed: input.operation === "github.issue.get",
6200
+ denialMessage: ISSUE_READ_DENIAL
6201
+ });
6202
+ }
6036
6203
  assertGitHubPullRequestApprovalDenied({
6037
6204
  ...input.bodyText !== void 0 ? { bodyText: input.bodyText } : void 0,
6038
6205
  method: input.method,