@vercel/factory 0.0.12 → 0.0.13

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.
Files changed (33) hide show
  1. package/dist/approval-CwhTP1XB.mjs +269 -0
  2. package/dist/approval-CwhTP1XB.mjs.map +1 -0
  3. package/dist/blob/index.d.mts +1 -1
  4. package/dist/build-factory.d.mts +1 -1
  5. package/dist/build-factory.mjs +1 -1
  6. package/dist/change-CzEAoFVE.mjs +620 -0
  7. package/dist/change-CzEAoFVE.mjs.map +1 -0
  8. package/dist/connectors/slack.d.mts +4 -4
  9. package/dist/connectors/slack.mjs +81 -30
  10. package/dist/connectors/slack.mjs.map +1 -1
  11. package/dist/{approval-CIXB8IF8.d.mts → dispatch-B77cuPxh.d.mts} +290 -99
  12. package/dist/{driver-CrZsy7sm.d.mts → driver-BJutB0PE.d.mts} +2 -2
  13. package/dist/driver-Bbd25rNM.mjs.map +1 -1
  14. package/dist/eve/index.d.mts +546 -120
  15. package/dist/eve/index.mjs +358 -82
  16. package/dist/eve/index.mjs.map +1 -1
  17. package/dist/{factory-config-ifd3JxiU.mjs → factory-config-BJcjsPKl.mjs} +42 -5
  18. package/dist/factory-config-BJcjsPKl.mjs.map +1 -0
  19. package/dist/{factory-config-Bu4mklm9.d.mts → factory-config-D2yU3G0c.d.mts} +21 -2
  20. package/dist/{github-wThBfbm-.d.mts → github-DXsxboUL.d.mts} +25 -2
  21. package/dist/github.d.mts +2 -2
  22. package/dist/github.mjs +47 -1
  23. package/dist/github.mjs.map +1 -1
  24. package/dist/index.d.mts +119 -59
  25. package/dist/index.mjs +289 -330
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/postgres/index.d.mts +1 -1
  28. package/package.json +1 -1
  29. package/dist/approval-DdvEKLiE.mjs +0 -132
  30. package/dist/approval-DdvEKLiE.mjs.map +0 -1
  31. package/dist/change-CFNGXVqD.mjs +0 -230
  32. package/dist/change-CFNGXVqD.mjs.map +0 -1
  33. package/dist/factory-config-ifd3JxiU.mjs.map +0 -1
@@ -4,6 +4,13 @@ declare const factoryConfigRepositorySchema: z.ZodObject<{
4
4
  slug: z.ZodString;
5
5
  dependsOn: z.ZodDefault<z.ZodArray<z.ZodString>>;
6
6
  }, z.core.$strict>;
7
+ declare const executionPolicySchema: z.ZodObject<{
8
+ maxAttempts: z.ZodNumber;
9
+ stallMinutes: z.ZodNumber;
10
+ stallMinutesByKind: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
11
+ }, z.core.$strict>;
12
+ type ExecutionPolicy = z.infer<typeof executionPolicySchema>;
13
+ declare const defaultExecutionPolicy: ExecutionPolicy;
7
14
  declare const factoryConfigSchema: z.ZodObject<{
8
15
  connectors: z.ZodDefault<z.ZodObject<{
9
16
  github: z.ZodArray<z.ZodObject<{
@@ -30,10 +37,22 @@ declare const factoryConfigSchema: z.ZodObject<{
30
37
  }>>>;
31
38
  require: z.ZodBoolean;
32
39
  }, z.core.$strict>>>;
40
+ budget: z.ZodDefault<z.ZodObject<{
41
+ totalUsd: z.ZodNumber;
42
+ investigationUsd: z.ZodNumber;
43
+ perTaskReservationUsd: z.ZodNumber;
44
+ warningPercent: z.ZodNumber;
45
+ perRepositoryUsd: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
46
+ }, z.core.$strict>>;
47
+ execution: z.ZodDefault<z.ZodObject<{
48
+ maxAttempts: z.ZodNumber;
49
+ stallMinutes: z.ZodNumber;
50
+ stallMinutesByKind: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
51
+ }, z.core.$strict>>;
33
52
  }, z.core.$strict>;
34
53
  type FactoryConfig = z.infer<typeof factoryConfigSchema>;
35
54
  type FactoryConfigInput = z.input<typeof factoryConfigSchema>;
36
55
  declare function defineFactory(config: FactoryConfigInput): FactoryConfig;
37
56
  //#endregion
38
- export { factoryConfigSchema as a, factoryConfigRepositorySchema as i, FactoryConfigInput as n, defineFactory as r, FactoryConfig as t };
39
- //# sourceMappingURL=factory-config-Bu4mklm9.d.mts.map
57
+ export { defineFactory as a, factoryConfigSchema as c, defaultExecutionPolicy as i, FactoryConfig as n, executionPolicySchema as o, FactoryConfigInput as r, factoryConfigRepositorySchema as s, ExecutionPolicy as t };
58
+ //# sourceMappingURL=factory-config-D2yU3G0c.d.mts.map
@@ -62,6 +62,23 @@ interface SubmittedPullRequestReview {
62
62
  url: string;
63
63
  state: string;
64
64
  }
65
+ interface GitHubIssueComment {
66
+ id: number;
67
+ body: string;
68
+ url: string;
69
+ author: string;
70
+ authorType: "Bot" | "User" | "Organization";
71
+ }
72
+ interface ListPullRequestCommentsInput extends GitHubRepositoryRequest {
73
+ pullRequestNumber: number;
74
+ }
75
+ interface CreatePullRequestCommentInput extends ListPullRequestCommentsInput {
76
+ body: string;
77
+ }
78
+ interface UpdatePullRequestCommentInput extends GitHubRepositoryRequest {
79
+ commentId: number;
80
+ body: string;
81
+ }
65
82
  interface PullRequestLabelInput extends GitHubRepositoryRequest {
66
83
  pullRequestNumber: number;
67
84
  label: string;
@@ -141,6 +158,12 @@ declare function createCheckRun(input: CreateCheckRunInput): Promise<GitHubCheck
141
158
  declare function updateCheckRun(input: UpdateCheckRunInput): Promise<GitHubCheckRun>;
142
159
  /** List check runs reported for a commit, branch, or tag. */
143
160
  declare function listCheckRunsForRef(input: ListCheckRunsForRefInput): Promise<GitHubCheckRun[]>;
161
+ /** List every issue-style comment in a pull request conversation. */
162
+ declare function listPullRequestComments(input: ListPullRequestCommentsInput): Promise<GitHubIssueComment[]>;
163
+ /** Add one issue-style comment to a pull request conversation. */
164
+ declare function createPullRequestComment(input: CreatePullRequestCommentInput): Promise<GitHubIssueComment>;
165
+ /** Edit one issue-style pull request comment. */
166
+ declare function updatePullRequestComment(input: UpdatePullRequestCommentInput): Promise<GitHubIssueComment>;
144
167
  /** Read one inline review comment after applying the author policy, which requires write access by default. */
145
168
  declare function readReviewComment(input: ReadReviewCommentInput): Promise<GitHubReviewComment>;
146
169
  /** Reply to an inline review comment after applying the author policy, which requires write access by default. */
@@ -244,5 +267,5 @@ declare function normalizeGitHubPullRequestClosed(options: WebhookEvent): GitHub
244
267
  /** Normalize a completed, unsuccessful GitHub Actions run into a CI failure signal. */
245
268
  declare function normalizeGitHubWorkflowRunFailure(options: WebhookEvent): GitHubCIFailureSignal | null;
246
269
  //#endregion
247
- export { SubmitPullRequestReviewInput as A, normalizeGitHubIssueOpened as B, ListConflictedPullRequestsInput as C, ReadPullRequestHeadInput as D, PullRequestReviewEvent as E, createCheckRun as F, readReviewComment as G, normalizeGitHubPullRequestClosed as H, createPullRequest as I, updateCheckRun as J, removeLabel as K, listCheckRunsForRef as L, UpdateCheckRunInput as M, addLabel as N, ReadReviewCommentInput as O, answerReviewComment as P, listConflictedPullRequests as R, ListCheckRunsForRefInput as S, PullRequestReviewComment as T, normalizeGitHubWorkflowRunFailure as U, normalizeGitHubPullRequest as V, readPullRequestHead as W, verifyGitHubSignature as Y, GitHubPullRequestHead as _, CheckRunOutput as a, GitHubReviewComment as b, CreateCheckRunInput as c, GitHubCIFailureSignal as d, GitHubCheckRun as f, GitHubPullRequestClosed as g, GitHubIssueSignal as h, CheckRunConclusion as i, SubmittedPullRequestReview as j, ReviewCommentAuthorPolicy as k, CreatePullRequestInput as l, GitHubDefaultBranchPush as m, CheckRunAnnotation as n, CheckRunStatus as o, GitHubCheckRunStatus as p, submitPullRequestReview as q, CheckRunAnnotationLevel as r, ConflictedPullRequest as s, AnswerReviewCommentInput as t, CreatedPullRequest as u, GitHubPullRequestSignal as v, PullRequestLabelInput as w, GitHubReviewCommentAuthorError as x, GitHubRepositoryRequest as y, normalizeGitHubDefaultBranchPush as z };
248
- //# sourceMappingURL=github-wThBfbm-.d.mts.map
270
+ export { submitPullRequestReview as $, ReadPullRequestHeadInput as A, createPullRequest as B, GitHubReviewCommentAuthorError as C, PullRequestLabelInput as D, ListPullRequestCommentsInput as E, UpdateCheckRunInput as F, normalizeGitHubDefaultBranchPush as G, listCheckRunsForRef as H, UpdatePullRequestCommentInput as I, normalizeGitHubPullRequestClosed as J, normalizeGitHubIssueOpened as K, addLabel as L, ReviewCommentAuthorPolicy as M, SubmitPullRequestReviewInput as N, PullRequestReviewComment as O, SubmittedPullRequestReview as P, removeLabel as Q, answerReviewComment as R, GitHubReviewComment as S, ListConflictedPullRequestsInput as T, listConflictedPullRequests as U, createPullRequestComment as V, listPullRequestComments as W, readPullRequestHead as X, normalizeGitHubWorkflowRunFailure as Y, readReviewComment as Z, GitHubIssueSignal as _, CheckRunOutput as a, GitHubPullRequestSignal as b, CreateCheckRunInput as c, CreatedPullRequest as d, updateCheckRun as et, GitHubCIFailureSignal as f, GitHubIssueComment as g, GitHubDefaultBranchPush as h, CheckRunConclusion as i, ReadReviewCommentInput as j, PullRequestReviewEvent as k, CreatePullRequestCommentInput as l, GitHubCheckRunStatus as m, CheckRunAnnotation as n, verifyGitHubSignature as nt, CheckRunStatus as o, GitHubCheckRun as p, normalizeGitHubPullRequest as q, CheckRunAnnotationLevel as r, ConflictedPullRequest as s, AnswerReviewCommentInput as t, updatePullRequestComment as tt, CreatePullRequestInput as u, GitHubPullRequestClosed as v, ListCheckRunsForRefInput as w, GitHubRepositoryRequest as x, GitHubPullRequestHead as y, createCheckRun as z };
271
+ //# sourceMappingURL=github-DXsxboUL.d.mts.map
package/dist/github.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as SubmitPullRequestReviewInput, B as normalizeGitHubIssueOpened, C as ListConflictedPullRequestsInput, D as ReadPullRequestHeadInput, E as PullRequestReviewEvent, F as createCheckRun, G as readReviewComment, H as normalizeGitHubPullRequestClosed, I as createPullRequest, J as updateCheckRun, K as removeLabel, L as listCheckRunsForRef, M as UpdateCheckRunInput, N as addLabel, O as ReadReviewCommentInput, P as answerReviewComment, R as listConflictedPullRequests, S as ListCheckRunsForRefInput, T as PullRequestReviewComment, U as normalizeGitHubWorkflowRunFailure, V as normalizeGitHubPullRequest, W as readPullRequestHead, Y as verifyGitHubSignature, _ as GitHubPullRequestHead, a as CheckRunOutput, b as GitHubReviewComment, c as CreateCheckRunInput, d as GitHubCIFailureSignal, f as GitHubCheckRun, g as GitHubPullRequestClosed, h as GitHubIssueSignal, i as CheckRunConclusion, j as SubmittedPullRequestReview, k as ReviewCommentAuthorPolicy, l as CreatePullRequestInput, m as GitHubDefaultBranchPush, n as CheckRunAnnotation, o as CheckRunStatus, p as GitHubCheckRunStatus, q as submitPullRequestReview, r as CheckRunAnnotationLevel, s as ConflictedPullRequest, t as AnswerReviewCommentInput, u as CreatedPullRequest, v as GitHubPullRequestSignal, w as PullRequestLabelInput, x as GitHubReviewCommentAuthorError, y as GitHubRepositoryRequest, z as normalizeGitHubDefaultBranchPush } from "./github-wThBfbm-.mjs";
2
- export { AnswerReviewCommentInput, CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunOutput, CheckRunStatus, ConflictedPullRequest, CreateCheckRunInput, CreatePullRequestInput, CreatedPullRequest, GitHubCIFailureSignal, GitHubCheckRun, GitHubCheckRunStatus, GitHubDefaultBranchPush, GitHubIssueSignal, GitHubPullRequestClosed, GitHubPullRequestHead, GitHubPullRequestSignal, GitHubRepositoryRequest, GitHubReviewComment, GitHubReviewCommentAuthorError, ListCheckRunsForRefInput, ListConflictedPullRequestsInput, PullRequestLabelInput, PullRequestReviewComment, PullRequestReviewEvent, ReadPullRequestHeadInput, ReadReviewCommentInput, ReviewCommentAuthorPolicy, SubmitPullRequestReviewInput, SubmittedPullRequestReview, UpdateCheckRunInput, addLabel, answerReviewComment, createCheckRun, createPullRequest, listCheckRunsForRef, listConflictedPullRequests, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readPullRequestHead, readReviewComment, removeLabel, submitPullRequestReview, updateCheckRun, verifyGitHubSignature };
1
+ import { $ as submitPullRequestReview, A as ReadPullRequestHeadInput, B as createPullRequest, C as GitHubReviewCommentAuthorError, D as PullRequestLabelInput, E as ListPullRequestCommentsInput, F as UpdateCheckRunInput, G as normalizeGitHubDefaultBranchPush, H as listCheckRunsForRef, I as UpdatePullRequestCommentInput, J as normalizeGitHubPullRequestClosed, K as normalizeGitHubIssueOpened, L as addLabel, M as ReviewCommentAuthorPolicy, N as SubmitPullRequestReviewInput, O as PullRequestReviewComment, P as SubmittedPullRequestReview, Q as removeLabel, R as answerReviewComment, S as GitHubReviewComment, T as ListConflictedPullRequestsInput, U as listConflictedPullRequests, V as createPullRequestComment, W as listPullRequestComments, X as readPullRequestHead, Y as normalizeGitHubWorkflowRunFailure, Z as readReviewComment, _ as GitHubIssueSignal, a as CheckRunOutput, b as GitHubPullRequestSignal, c as CreateCheckRunInput, d as CreatedPullRequest, et as updateCheckRun, f as GitHubCIFailureSignal, g as GitHubIssueComment, h as GitHubDefaultBranchPush, i as CheckRunConclusion, j as ReadReviewCommentInput, k as PullRequestReviewEvent, l as CreatePullRequestCommentInput, m as GitHubCheckRunStatus, n as CheckRunAnnotation, nt as verifyGitHubSignature, o as CheckRunStatus, p as GitHubCheckRun, q as normalizeGitHubPullRequest, r as CheckRunAnnotationLevel, s as ConflictedPullRequest, t as AnswerReviewCommentInput, tt as updatePullRequestComment, u as CreatePullRequestInput, v as GitHubPullRequestClosed, w as ListCheckRunsForRefInput, x as GitHubRepositoryRequest, y as GitHubPullRequestHead, z as createCheckRun } from "./github-DXsxboUL.mjs";
2
+ export { AnswerReviewCommentInput, CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunOutput, CheckRunStatus, ConflictedPullRequest, CreateCheckRunInput, CreatePullRequestCommentInput, CreatePullRequestInput, CreatedPullRequest, GitHubCIFailureSignal, GitHubCheckRun, GitHubCheckRunStatus, GitHubDefaultBranchPush, GitHubIssueComment, GitHubIssueSignal, GitHubPullRequestClosed, GitHubPullRequestHead, GitHubPullRequestSignal, GitHubRepositoryRequest, GitHubReviewComment, GitHubReviewCommentAuthorError, ListCheckRunsForRefInput, ListConflictedPullRequestsInput, ListPullRequestCommentsInput, PullRequestLabelInput, PullRequestReviewComment, PullRequestReviewEvent, ReadPullRequestHeadInput, ReadReviewCommentInput, ReviewCommentAuthorPolicy, SubmitPullRequestReviewInput, SubmittedPullRequestReview, UpdateCheckRunInput, UpdatePullRequestCommentInput, addLabel, answerReviewComment, createCheckRun, createPullRequest, createPullRequestComment, listCheckRunsForRef, listConflictedPullRequests, listPullRequestComments, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readPullRequestHead, readReviewComment, removeLabel, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };
package/dist/github.mjs CHANGED
@@ -24,6 +24,19 @@ const submittedReviewSchema = z.object({
24
24
  html_url: z.url(),
25
25
  state: z.string().min(1)
26
26
  });
27
+ const issueCommentSchema = z.object({
28
+ id: z.number().int().positive(),
29
+ body: z.string(),
30
+ html_url: z.url(),
31
+ user: z.object({
32
+ login: z.string().min(1),
33
+ type: z.enum([
34
+ "Bot",
35
+ "User",
36
+ "Organization"
37
+ ])
38
+ })
39
+ });
27
40
  const checkRunSchema = z.object({
28
41
  id: z.number().int().positive(),
29
42
  name: z.string().min(1),
@@ -142,6 +155,29 @@ async function listCheckRunsForRef(input) {
142
155
  if (input.checkName !== void 0) query.set("check_name", input.checkName);
143
156
  return checkRunsSchema.parse(await gitHubRequest(input, `/commits/${encodeURIComponent(input.ref)}/check-runs?${query.toString()}`)).check_runs.map(parseCheckRun);
144
157
  }
158
+ /** List every issue-style comment in a pull request conversation. */
159
+ async function listPullRequestComments(input) {
160
+ const comments = [];
161
+ for (let page = 1;; page += 1) {
162
+ const response = z.array(issueCommentSchema).parse(await gitHubRequest(input, `/issues/${positiveInteger(input.pullRequestNumber, "pullRequestNumber")}/comments?per_page=100&page=${page}`));
163
+ comments.push(...response.map(parseIssueComment));
164
+ if (response.length < 100) return comments;
165
+ }
166
+ }
167
+ /** Add one issue-style comment to a pull request conversation. */
168
+ async function createPullRequestComment(input) {
169
+ return parseIssueComment(await gitHubRequest(input, `/issues/${positiveInteger(input.pullRequestNumber, "pullRequestNumber")}/comments`, {
170
+ method: "POST",
171
+ body: JSON.stringify({ body: input.body })
172
+ }));
173
+ }
174
+ /** Edit one issue-style pull request comment. */
175
+ async function updatePullRequestComment(input) {
176
+ return parseIssueComment(await gitHubRequest(input, `/issues/comments/${positiveInteger(input.commentId, "commentId")}`, {
177
+ method: "PATCH",
178
+ body: JSON.stringify({ body: input.body })
179
+ }));
180
+ }
145
181
  /** Read one inline review comment after applying the author policy, which requires write access by default. */
146
182
  async function readReviewComment(input) {
147
183
  const comment = parseReviewComment(await gitHubRequest(input, `/pulls/comments/${positiveInteger(input.commentId, "commentId")}`));
@@ -247,6 +283,16 @@ function parseReviewComment(value) {
247
283
  inReplyToId: comment.in_reply_to_id ?? null
248
284
  };
249
285
  }
286
+ function parseIssueComment(value) {
287
+ const comment = issueCommentSchema.parse(value);
288
+ return {
289
+ id: comment.id,
290
+ body: comment.body,
291
+ url: comment.html_url,
292
+ author: comment.user.login,
293
+ authorType: comment.user.type
294
+ };
295
+ }
250
296
  function parseLabels(value) {
251
297
  return labelsSchema.parse(value).map(({ name }) => name);
252
298
  }
@@ -523,6 +569,6 @@ function normalizeGitHubWorkflowRunFailure(options) {
523
569
  };
524
570
  }
525
571
  //#endregion
526
- export { GitHubReviewCommentAuthorError, addLabel, answerReviewComment, createCheckRun, createPullRequest, listCheckRunsForRef, listConflictedPullRequests, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readPullRequestHead, readReviewComment, removeLabel, submitPullRequestReview, updateCheckRun, verifyGitHubSignature };
572
+ export { GitHubReviewCommentAuthorError, addLabel, answerReviewComment, createCheckRun, createPullRequest, createPullRequestComment, listCheckRunsForRef, listConflictedPullRequests, listPullRequestComments, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readPullRequestHead, readReviewComment, removeLabel, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };
527
573
 
528
574
  //# sourceMappingURL=github.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"github.mjs","names":[],"sources":["../src/github.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from \"node:crypto\";\nimport { z } from \"zod\";\nimport type { NormalizedSignal, WebhookEvent } from \"./connectors/index\";\n\nconst gitHubApiUrl = \"https://api.github.com\";\nconst repositorySlugPattern = /^[^/\\s]+\\/[^/\\s]+$/;\n\nexport interface GitHubRepositoryRequest {\n repository: string;\n token: string;\n fetch?: typeof globalThis.fetch;\n}\n\nexport interface CreatePullRequestInput extends GitHubRepositoryRequest {\n title: string;\n head: string;\n base: string;\n body?: string;\n draft?: boolean;\n}\n\nexport interface CreatedPullRequest {\n prNumber: number;\n prUrl: string;\n}\n\nexport type ReviewCommentAuthorPolicy = \"write\" | \"any\";\n\ninterface ReviewCommentTrustInput {\n /** Defaults to `write`. Use `any` only when untrusted review text is handled as data. */\n authorPolicy?: ReviewCommentAuthorPolicy;\n}\n\nexport interface ReadReviewCommentInput extends GitHubRepositoryRequest, ReviewCommentTrustInput {\n commentId: number;\n}\n\nexport interface GitHubReviewComment {\n id: number;\n body: string;\n url: string;\n author: string;\n inReplyToId: number | null;\n}\n\nexport interface AnswerReviewCommentInput\n extends GitHubRepositoryRequest,\n ReviewCommentTrustInput {\n pullRequestNumber: number;\n commentId: number;\n body: string;\n}\n\nexport interface ReadPullRequestHeadInput extends GitHubRepositoryRequest {\n pullRequestNumber: number;\n}\n\nexport interface GitHubPullRequestHead {\n branch: string;\n sha: string;\n repository: string;\n}\n\nexport type PullRequestReviewEvent = \"APPROVE\" | \"REQUEST_CHANGES\" | \"COMMENT\";\n\nexport interface PullRequestReviewComment {\n path: string;\n line: number;\n body: string;\n}\n\nexport interface SubmitPullRequestReviewInput extends GitHubRepositoryRequest {\n pullRequestNumber: number;\n commitId: string;\n event: PullRequestReviewEvent;\n body: string;\n comments?: readonly PullRequestReviewComment[];\n}\n\nexport interface SubmittedPullRequestReview {\n id: number;\n url: string;\n state: string;\n}\n\nexport interface PullRequestLabelInput extends GitHubRepositoryRequest {\n pullRequestNumber: number;\n label: string;\n}\n\nexport interface ConflictedPullRequest {\n prNumber: number;\n prUrl: string;\n headBranch: string;\n headSha: string;\n baseBranch: string;\n baseSha: string;\n}\n\nexport type ListConflictedPullRequestsInput = GitHubRepositoryRequest;\n\nexport type CheckRunStatus = \"queued\" | \"in_progress\" | \"completed\";\nexport type GitHubCheckRunStatus = CheckRunStatus | \"waiting\" | \"requested\" | \"pending\";\nexport type CheckRunConclusion =\n | \"action_required\"\n | \"cancelled\"\n | \"failure\"\n | \"neutral\"\n | \"skipped\"\n | \"success\"\n | \"timed_out\";\nexport type CheckRunAnnotationLevel = \"notice\" | \"warning\" | \"failure\";\n\nexport interface CheckRunAnnotation {\n path: string;\n startLine: number;\n endLine?: number;\n startColumn?: number;\n endColumn?: number;\n annotationLevel: CheckRunAnnotationLevel;\n message: string;\n title?: string;\n rawDetails?: string;\n}\n\nexport interface CheckRunOutput {\n title: string;\n summary: string;\n text?: string;\n annotations?: readonly CheckRunAnnotation[];\n}\n\ninterface CheckRunFields {\n status?: CheckRunStatus;\n conclusion?: CheckRunConclusion;\n detailsUrl?: string;\n externalId?: string;\n startedAt?: string;\n completedAt?: string;\n output?: CheckRunOutput;\n}\n\nexport interface CreateCheckRunInput extends GitHubRepositoryRequest, CheckRunFields {\n name: string;\n headSha: string;\n}\n\nexport interface UpdateCheckRunInput extends GitHubRepositoryRequest, CheckRunFields {\n checkRunId: number;\n name?: string;\n}\n\nexport interface ListCheckRunsForRefInput extends GitHubRepositoryRequest {\n ref: string;\n checkName?: string;\n}\n\nexport interface GitHubCheckRun {\n id: number;\n name: string;\n headSha: string;\n status: GitHubCheckRunStatus;\n conclusion: CheckRunConclusion | \"stale\" | \"startup_failure\" | null;\n url: string | null;\n detailsUrl: string | null;\n externalId: string | null;\n startedAt: string | null;\n completedAt: string | null;\n}\n\nconst pullRequestSchema = z.object({\n number: z.number().int().positive(),\n html_url: z.url(),\n});\n\nconst pullRequestHeadSchema = z.object({\n head: z.object({\n ref: z\n .string()\n .regex(/^[A-Za-z0-9][A-Za-z0-9._/-]*$/)\n .refine((value) => !value.includes(\"..\")),\n sha: z.string().regex(/^[0-9a-f]{40}$/),\n repo: z.object({ full_name: z.string().min(1) }),\n }),\n});\n\nconst reviewCommentSchema = z.object({\n id: z.number().int().positive(),\n body: z.string(),\n html_url: z.url(),\n user: z.object({ login: z.string().min(1) }),\n in_reply_to_id: z.number().int().positive().nullish(),\n});\n\nconst submittedReviewSchema = z.object({\n id: z.number().int().positive(),\n html_url: z.url(),\n state: z.string().min(1),\n});\n\nconst checkRunSchema = z.object({\n id: z.number().int().positive(),\n name: z.string().min(1),\n head_sha: z.string().regex(/^[0-9a-f]{40}$/),\n status: z.enum([\"queued\", \"in_progress\", \"completed\", \"waiting\", \"requested\", \"pending\"]),\n conclusion: z\n .enum([\n \"action_required\",\n \"cancelled\",\n \"failure\",\n \"neutral\",\n \"skipped\",\n \"success\",\n \"timed_out\",\n \"stale\",\n \"startup_failure\",\n ])\n .nullable(),\n html_url: z.url().nullable(),\n details_url: z.url().nullable(),\n external_id: z.string().nullable(),\n started_at: z.string().nullable(),\n completed_at: z.string().nullable(),\n});\n\nconst checkRunsSchema = z.object({ check_runs: z.array(checkRunSchema) });\nconst labelsSchema = z.array(z.object({ name: z.string().min(1) }));\nconst pullRequestCandidateSchema = z.object({\n number: z.number().int().positive(),\n user: z.object({ type: z.string().min(1) }),\n head: z.object({ ref: z.string().min(1), repo: z.object({ full_name: z.string().min(1) }) }),\n});\nconst openPullRequestsSchema = z.array(pullRequestCandidateSchema);\nconst pullRequestDetailSchema = pullRequestCandidateSchema.extend({\n html_url: z.url(),\n mergeable: z.boolean().nullable(),\n mergeable_state: z.string().min(1),\n head: pullRequestCandidateSchema.shape.head.extend({ sha: z.string().min(1) }),\n base: z.object({ ref: z.string().min(1), sha: z.string().min(1) }),\n});\nconst collaboratorPermissionSchema = z.object({\n permission: z.enum([\"admin\", \"maintain\", \"write\", \"triage\", \"read\", \"none\"]),\n});\nconst writePermissions = new Set([\"admin\", \"maintain\", \"write\"]);\n\nexport class GitHubReviewCommentAuthorError extends Error {\n readonly author: string;\n\n constructor(author: string) {\n super(`GitHub user ${author} does not have write access to the repository`);\n this.name = \"GitHubReviewCommentAuthorError\";\n this.author = author;\n }\n}\n\n/** Create a pull request from an existing head branch. */\nexport async function createPullRequest(input: CreatePullRequestInput): Promise<CreatedPullRequest> {\n const pull = pullRequestSchema.parse(\n await gitHubRequest(input, \"/pulls\", {\n method: \"POST\",\n body: JSON.stringify({\n title: input.title,\n head: input.head,\n base: input.base,\n ...(input.body === undefined ? {} : { body: input.body }),\n ...(input.draft === undefined ? {} : { draft: input.draft }),\n }),\n }),\n );\n return { prNumber: pull.number, prUrl: pull.html_url };\n}\n\n/** Create a check run for one commit. Requires a GitHub App token with checks:write. */\nexport async function createCheckRun(input: CreateCheckRunInput): Promise<GitHubCheckRun> {\n if (input.status === \"completed\" && input.conclusion === undefined) {\n throw new Error(\"completed check runs require a conclusion\");\n }\n if (input.status !== \"completed\" && input.conclusion !== undefined) {\n throw new Error(\"creating a check run with a conclusion requires completed status\");\n }\n return parseCheckRun(\n await gitHubRequest(input, \"/check-runs\", {\n method: \"POST\",\n body: JSON.stringify({\n name: input.name,\n head_sha: commitSha(input.headSha),\n ...checkRunFields(input),\n }),\n }),\n );\n}\n\n/** Update a check run previously created by the authenticated GitHub App. */\nexport async function updateCheckRun(input: UpdateCheckRunInput): Promise<GitHubCheckRun> {\n if (input.status !== undefined && input.status !== \"completed\" && input.conclusion !== undefined) {\n throw new Error(\"a check run conclusion conflicts with an incomplete status\");\n }\n return parseCheckRun(\n await gitHubRequest(input, `/check-runs/${positiveInteger(input.checkRunId, \"checkRunId\")}`, {\n method: \"PATCH\",\n body: JSON.stringify({\n ...(input.name === undefined ? {} : { name: input.name }),\n ...checkRunFields(input),\n }),\n }),\n );\n}\n\n/** List check runs reported for a commit, branch, or tag. */\nexport async function listCheckRunsForRef(input: ListCheckRunsForRefInput): Promise<GitHubCheckRun[]> {\n const query = new URLSearchParams({ per_page: \"100\" });\n if (input.checkName !== undefined) query.set(\"check_name\", input.checkName);\n const response = checkRunsSchema.parse(\n await gitHubRequest(input, `/commits/${encodeURIComponent(input.ref)}/check-runs?${query.toString()}`),\n );\n return response.check_runs.map(parseCheckRun);\n}\n\n/** Read one inline review comment after applying the author policy, which requires write access by default. */\nexport async function readReviewComment(\n input: ReadReviewCommentInput,\n): Promise<GitHubReviewComment> {\n const comment = parseReviewComment(\n await gitHubRequest(input, `/pulls/comments/${positiveInteger(input.commentId, \"commentId\")}`),\n );\n await assertReviewCommentAuthor(input, comment.author);\n return comment;\n}\n\n/** Reply to an inline review comment after applying the author policy, which requires write access by default. */\nexport async function answerReviewComment(\n input: AnswerReviewCommentInput,\n): Promise<GitHubReviewComment> {\n await readReviewComment(input);\n return parseReviewComment(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/comments/${positiveInteger(input.commentId, \"commentId\")}/replies`,\n { method: \"POST\", body: JSON.stringify({ body: input.body }) },\n ),\n );\n}\n\n/** Submit a summary and optional inline comments against a reviewed pull request commit. */\nexport async function submitPullRequestReview(\n input: SubmitPullRequestReviewInput,\n): Promise<SubmittedPullRequestReview> {\n const commitId = z.string().regex(/^[0-9a-f]{40}$/).parse(input.commitId);\n const head = await readPullRequestHead(input);\n if (head.sha !== commitId) {\n throw new Error(`pull request changed after review: expected ${commitId}, found ${head.sha}`);\n }\n const review = submittedReviewSchema.parse(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/reviews`,\n {\n method: \"POST\",\n body: JSON.stringify({\n commit_id: commitId,\n event: input.event,\n body: input.body,\n comments: (input.comments ?? []).map((comment) => ({\n path: comment.path,\n line: positiveInteger(comment.line, \"comment line\"),\n side: \"RIGHT\",\n body: comment.body,\n })),\n }),\n },\n ),\n );\n return { id: review.id, url: review.html_url, state: review.state };\n}\n\n/** Read the current head branch and commit of a pull request. */\nexport async function readPullRequestHead(\n input: ReadPullRequestHeadInput,\n): Promise<GitHubPullRequestHead> {\n const pull = pullRequestHeadSchema.parse(\n await gitHubRequest(input, `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}`),\n );\n return {\n branch: pull.head.ref,\n sha: pull.head.sha,\n repository: pull.head.repo.full_name.toLowerCase(),\n };\n}\n\n/** List open, same-repository pull requests by one author that GitHub reports as conflicting. */\nexport async function listConflictedPullRequests(\n input: ListConflictedPullRequestsInput,\n): Promise<ConflictedPullRequest[]> {\n const pulls = openPullRequestsSchema.parse(\n await gitHubRequest(input, `/pulls?state=open&per_page=100`),\n );\n const candidates = pulls.filter(\n (pull) =>\n pull.user.type === \"Bot\" &&\n pull.head.ref.startsWith(\"factory/\") &&\n pull.head.repo.full_name.toLowerCase() === input.repository.toLowerCase(),\n );\n const conflicted: ConflictedPullRequest[] = [];\n for (const candidate of candidates) {\n const pull = pullRequestDetailSchema.parse(\n await gitHubRequest(input, `/pulls/${candidate.number}`),\n );\n if (pull.mergeable === false || pull.mergeable_state === \"dirty\") {\n conflicted.push({\n prNumber: pull.number,\n prUrl: pull.html_url,\n headBranch: pull.head.ref,\n headSha: pull.head.sha,\n baseBranch: pull.base.ref,\n baseSha: pull.base.sha,\n });\n }\n }\n return conflicted;\n}\n\n/** Add one label to a pull request. */\nexport async function addLabel(input: PullRequestLabelInput): Promise<string[]> {\n return parseLabels(\n await gitHubRequest(\n input,\n `/issues/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/labels`,\n { method: \"POST\", body: JSON.stringify({ labels: [input.label] }) },\n ),\n );\n}\n\n/** Remove one label from a pull request. */\nexport async function removeLabel(input: PullRequestLabelInput): Promise<string[]> {\n return parseLabels(\n await gitHubRequest(\n input,\n `/issues/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/labels/${encodeURIComponent(input.label)}`,\n { method: \"DELETE\" },\n ),\n );\n}\n\nasync function gitHubRequest(\n input: GitHubRepositoryRequest,\n path: string,\n init: RequestInit = {},\n): Promise<unknown> {\n if (!repositorySlugPattern.test(input.repository)) {\n throw new Error(`invalid GitHub repository slug: ${input.repository}`);\n }\n const response = await (input.fetch ?? globalThis.fetch)(\n `${gitHubApiUrl}/repos/${input.repository}${path}`,\n {\n ...init,\n headers: {\n Accept: \"application/vnd.github+json\",\n Authorization: `Bearer ${input.token}`,\n \"Content-Type\": \"application/json\",\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n ...init.headers,\n },\n },\n );\n const body: unknown = await response.json();\n if (!response.ok) {\n const message = z.object({ message: z.string() }).safeParse(body);\n throw new Error(\n `GitHub API request failed (${response.status}): ${message.success ? message.data.message : response.statusText}`,\n );\n }\n return body;\n}\n\nfunction parseReviewComment(value: unknown): GitHubReviewComment {\n const comment = reviewCommentSchema.parse(value);\n return {\n id: comment.id,\n body: comment.body,\n url: comment.html_url,\n author: comment.user.login,\n inReplyToId: comment.in_reply_to_id ?? null,\n };\n}\n\nfunction parseLabels(value: unknown): string[] {\n return labelsSchema.parse(value).map(({ name }) => name);\n}\n\nfunction parseCheckRun(value: unknown): GitHubCheckRun {\n const checkRun = checkRunSchema.parse(value);\n return {\n id: checkRun.id,\n name: checkRun.name,\n headSha: checkRun.head_sha,\n status: checkRun.status,\n conclusion: checkRun.conclusion,\n url: checkRun.html_url,\n detailsUrl: checkRun.details_url,\n externalId: checkRun.external_id,\n startedAt: checkRun.started_at,\n completedAt: checkRun.completed_at,\n };\n}\n\nfunction checkRunFields(input: CheckRunFields): Record<string, unknown> {\n return {\n ...(input.status === undefined ? {} : { status: input.status }),\n ...(input.conclusion === undefined ? {} : { conclusion: input.conclusion }),\n ...(input.detailsUrl === undefined ? {} : { details_url: input.detailsUrl }),\n ...(input.externalId === undefined ? {} : { external_id: input.externalId }),\n ...(input.startedAt === undefined ? {} : { started_at: input.startedAt }),\n ...(input.completedAt === undefined ? {} : { completed_at: input.completedAt }),\n ...(input.output === undefined ? {} : { output: checkRunOutput(input.output) }),\n };\n}\n\nfunction checkRunOutput(output: CheckRunOutput): Record<string, unknown> {\n return {\n title: output.title,\n summary: output.summary,\n ...(output.text === undefined ? {} : { text: output.text }),\n ...(output.annotations === undefined\n ? {}\n : {\n annotations: output.annotations.map((annotation) => ({\n path: annotation.path,\n start_line: positiveInteger(annotation.startLine, \"annotation startLine\"),\n end_line: positiveInteger(annotation.endLine ?? annotation.startLine, \"annotation endLine\"),\n ...(annotation.startColumn === undefined\n ? {}\n : { start_column: positiveInteger(annotation.startColumn, \"annotation startColumn\") }),\n ...(annotation.endColumn === undefined\n ? {}\n : { end_column: positiveInteger(annotation.endColumn, \"annotation endColumn\") }),\n annotation_level: annotation.annotationLevel,\n message: annotation.message,\n ...(annotation.title === undefined ? {} : { title: annotation.title }),\n ...(annotation.rawDetails === undefined ? {} : { raw_details: annotation.rawDetails }),\n })),\n }),\n };\n}\n\nasync function assertReviewCommentAuthor(\n input: GitHubRepositoryRequest & ReviewCommentTrustInput,\n author: string,\n): Promise<void> {\n if (input.authorPolicy === \"any\") {\n return;\n }\n const { permission } = collaboratorPermissionSchema.parse(\n await gitHubRequest(input, `/collaborators/${encodeURIComponent(author)}/permission`),\n );\n if (!writePermissions.has(permission)) {\n throw new GitHubReviewCommentAuthorError(author);\n }\n}\n\nfunction positiveInteger(value: number, name: string): number {\n if (!Number.isInteger(value) || value < 1) {\n throw new Error(`${name} must be a positive integer`);\n }\n return value;\n}\n\nfunction commitSha(value: string): string {\n return z.string().regex(/^[0-9a-f]{40}$/).parse(value);\n}\n\n/**\n * Verify a GitHub webhook HMAC signature (the x-hub-signature-256 header)\n * against the raw request body. Returns false for missing or malformed\n * signatures instead of throwing.\n */\nexport function verifyGitHubSignature(options: {\n secret: string;\n payload: string;\n signature: string | null;\n}): boolean {\n const { secret, payload, signature } = options;\n if (signature === null || !signature.startsWith(\"sha256=\")) {\n return false;\n }\n const expected = createHmac(\"sha256\", secret).update(payload).digest(\"hex\");\n const provided = signature.slice(\"sha256=\".length);\n if (provided.length !== expected.length) {\n return false;\n }\n return timingSafeEqual(Buffer.from(provided, \"hex\"), Buffer.from(expected, \"hex\"));\n}\n\nconst pushEventSchema = z.looseObject({\n ref: z.string().min(1),\n repository: z.looseObject({\n default_branch: z.string().min(1),\n full_name: z.string().min(1),\n }),\n});\n\nexport interface GitHubDefaultBranchPush {\n source: \"github_default_branch_push\";\n deliveryId: string;\n repositorySlug: string;\n defaultBranch: string;\n}\n\n/** Normalize a push to a repository's default branch for deterministic reconciliation. */\nexport function normalizeGitHubDefaultBranchPush(options: {\n deliveryId: string;\n event: string;\n payload: unknown;\n}): GitHubDefaultBranchPush | null {\n if (options.event !== \"push\") return null;\n const parsed = pushEventSchema.safeParse(options.payload);\n if (!parsed.success || parsed.data.ref !== `refs/heads/${parsed.data.repository.default_branch}`) {\n return null;\n }\n return {\n source: \"github_default_branch_push\",\n deliveryId: options.deliveryId,\n repositorySlug: parsed.data.repository.full_name.toLowerCase(),\n defaultBranch: parsed.data.repository.default_branch,\n };\n}\n\nconst pullRequestEventSchema = z.looseObject({\n action: z.string(),\n number: z.number().int().positive(),\n pull_request: z.looseObject({\n html_url: z.url(),\n draft: z.boolean(),\n user: z.looseObject({ login: z.string().min(1) }),\n head: z.looseObject({\n sha: z.string().regex(/^[0-9a-f]{40}$/),\n ref: z.string().min(1),\n repo: z.looseObject({ full_name: z.string().min(1) }),\n }),\n base: z.looseObject({\n sha: z.string().regex(/^[0-9a-f]{40}$/),\n ref: z.string().min(1),\n }),\n }),\n repository: z.looseObject({ full_name: z.string().min(1) }),\n sender: z.looseObject({ login: z.string().min(1) }),\n});\n\nconst reviewablePullRequestActions = new Set([\"opened\", \"reopened\", \"ready_for_review\", \"synchronize\"]);\n\nexport interface GitHubPullRequestSignal extends NormalizedSignal<\"github_pr\"> {\n repositorySlug: string;\n pullRequest: {\n number: number;\n url: string;\n author: string;\n draft: boolean;\n headSha: string;\n headBranch: string;\n headRepositorySlug: string;\n baseSha: string;\n baseBranch: string;\n sender: string;\n };\n}\n\n/** Normalize a newly reviewable or updated pull request into a factory signal. */\nexport function normalizeGitHubPullRequest(options: WebhookEvent): GitHubPullRequestSignal | null {\n if (options.event !== \"pull_request\") return null;\n const parsed = pullRequestEventSchema.safeParse(options.payload);\n if (!parsed.success || !reviewablePullRequestActions.has(parsed.data.action)) return null;\n if (parsed.data.pull_request.draft && parsed.data.action !== \"ready_for_review\") return null;\n\n const slug = parsed.data.repository.full_name.toLowerCase();\n const pull = parsed.data.pull_request;\n return {\n source: \"github_pr\",\n deliveryId: options.deliveryId,\n repositorySlug: slug,\n replyTo: { channel: \"github\", address: `${slug}/pull/${parsed.data.number}` },\n pullRequest: {\n number: parsed.data.number,\n url: pull.html_url,\n author: pull.user.login,\n draft: pull.draft,\n headSha: pull.head.sha,\n headBranch: pull.head.ref,\n headRepositorySlug: pull.head.repo.full_name.toLowerCase(),\n baseSha: pull.base.sha,\n baseBranch: pull.base.ref,\n sender: parsed.data.sender.login,\n },\n payload: options.payload,\n };\n}\n\nconst issueEventSchema = z.looseObject({\n action: z.string(),\n issue: z.looseObject({\n number: z.number().int().min(1),\n title: z.string(),\n body: z.string().nullable(),\n }),\n repository: z.looseObject({\n full_name: z.string().min(1),\n }),\n});\n\nexport interface GitHubIssueSignal extends NormalizedSignal<\"github_issue\"> {\n repositorySlug: string;\n issue: { number: number; title: string; body: string | null };\n}\n\nconst failedWorkflowConclusions = new Set([\n \"action_required\",\n \"failure\",\n \"stale\",\n \"startup_failure\",\n \"timed_out\",\n]);\n\nconst workflowRunEventSchema = z.looseObject({\n action: z.string(),\n repository: z.looseObject({\n default_branch: z.string().min(1),\n full_name: z.string().min(1),\n }),\n workflow_run: z.looseObject({\n id: z.number().int().min(1),\n name: z.string().min(1),\n event: z.string().min(1),\n head_branch: z.string().min(1).nullable(),\n head_repository: z\n .looseObject({\n full_name: z.string().min(1),\n })\n .nullable(),\n head_sha: z.string().min(1),\n html_url: z.url(),\n conclusion: z.string().nullable(),\n run_attempt: z.number().int().min(1),\n }),\n});\n\nexport interface GitHubCIFailureSignal extends NormalizedSignal<\"github_ci_failure\"> {\n repositoryDefaultBranch: string;\n repositorySlug: string;\n workflowRun: {\n id: number;\n name: string;\n trigger: string;\n branch: string | null;\n headRepositorySlug: string | null;\n headSha: string;\n url: string;\n conclusion: string;\n attempt: number;\n };\n}\n\n/**\n * Normalize a GitHub issues webhook into the factory's signal shape. Returns\n * null for payloads that are not an opened issue. The caller supplies the\n * repository id; the payload stays untrusted data.\n */\nexport function normalizeGitHubIssueOpened(options: WebhookEvent): GitHubIssueSignal | null {\n if (options.event !== \"issues\") {\n return null;\n }\n const parsed = issueEventSchema.safeParse(options.payload);\n if (!parsed.success || parsed.data.action !== \"opened\") {\n return null;\n }\n const slug = parsed.data.repository.full_name.toLowerCase();\n const { number, title, body } = parsed.data.issue;\n return {\n source: \"github_issue\",\n deliveryId: options.deliveryId,\n repositorySlug: slug,\n replyTo: { channel: \"github\", address: `${slug}#${number}` },\n issue: { number, title, body },\n payload: options.payload,\n };\n}\n\nconst pullRequestClosedSchema = z.looseObject({\n action: z.string(),\n pull_request: z.looseObject({\n number: z.number().int().min(1),\n html_url: z.url(),\n merged: z.boolean(),\n merged_by: z.looseObject({ login: z.string().min(1) }).nullable().optional(),\n merge_commit_sha: z\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .nullable()\n .optional(),\n }),\n repository: z.looseObject({\n full_name: z.string().min(1),\n }),\n sender: z.looseObject({ login: z.string().min(1) }),\n});\n\nexport interface GitHubPullRequestClosed {\n source: \"github_pull_request_closed\";\n deliveryId: string;\n repositorySlug: string;\n prNumber: number;\n prUrl: string;\n merged: boolean;\n /** The merge commit on the base branch; null when closed without merging. */\n mergeCommitSha: string | null;\n /** The GitHub login that merged the pull request, or closed it without merging. */\n decidedBy: string;\n}\n\n/**\n * Normalize a closed pull_request webhook so the factory can observe what\n * happened to its change: merged records merged_by (the sender when GitHub\n * omits it), a close without merge records the sender.\n */\nexport function normalizeGitHubPullRequestClosed(\n options: WebhookEvent,\n): GitHubPullRequestClosed | null {\n if (options.event !== \"pull_request\") {\n return null;\n }\n const parsed = pullRequestClosedSchema.safeParse(options.payload);\n if (!parsed.success || parsed.data.action !== \"closed\") {\n return null;\n }\n const pr = parsed.data.pull_request;\n const sender = parsed.data.sender.login;\n return {\n source: \"github_pull_request_closed\",\n deliveryId: options.deliveryId,\n repositorySlug: parsed.data.repository.full_name.toLowerCase(),\n prNumber: pr.number,\n prUrl: pr.html_url,\n merged: pr.merged,\n mergeCommitSha: pr.merged ? (pr.merge_commit_sha ?? null) : null,\n decidedBy: pr.merged ? (pr.merged_by?.login ?? sender) : sender,\n };\n}\n\n/** Normalize a completed, unsuccessful GitHub Actions run into a CI failure signal. */\nexport function normalizeGitHubWorkflowRunFailure(\n options: WebhookEvent,\n): GitHubCIFailureSignal | null {\n if (options.event !== \"workflow_run\") {\n return null;\n }\n const parsed = workflowRunEventSchema.safeParse(options.payload);\n if (!parsed.success || parsed.data.action !== \"completed\") {\n return null;\n }\n\n const run = parsed.data.workflow_run;\n const conclusion = run.conclusion;\n if (conclusion === null || !failedWorkflowConclusions.has(conclusion)) {\n return null;\n }\n const slug = parsed.data.repository.full_name.toLowerCase();\n return {\n source: \"github_ci_failure\",\n deliveryId: options.deliveryId,\n repositoryDefaultBranch: parsed.data.repository.default_branch,\n repositorySlug: slug,\n replyTo: { channel: \"github\", address: `${slug}/actions/runs/${run.id}` },\n workflowRun: {\n id: run.id,\n name: run.name,\n trigger: run.event,\n branch: run.head_branch,\n headRepositorySlug: run.head_repository?.full_name.toLowerCase() ?? null,\n headSha: run.head_sha,\n url: run.html_url,\n conclusion,\n attempt: run.run_attempt,\n },\n payload: options.payload,\n };\n}\n"],"mappings":";;;AAIA,MAAM,eAAe;AACrB,MAAM,wBAAwB;AAqK9B,MAAM,oBAAoB,EAAE,OAAO;CACjC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CAClC,UAAU,EAAE,IAAI;AAClB,CAAC;AAED,MAAM,wBAAwB,EAAE,OAAO,EACrC,MAAM,EAAE,OAAO;CACb,KAAK,EACF,OAAO,CAAC,CACR,MAAM,+BAA+B,CAAC,CACtC,QAAQ,UAAU,CAAC,MAAM,SAAS,IAAI,CAAC;CAC1C,KAAK,EAAE,OAAO,CAAC,CAAC,MAAM,gBAAgB;CACtC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACjD,CAAC,EACH,CAAC;AAED,MAAM,sBAAsB,EAAE,OAAO;CACnC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CAC9B,MAAM,EAAE,OAAO;CACf,UAAU,EAAE,IAAI;CAChB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;CAC3C,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ;AACtD,CAAC;AAED,MAAM,wBAAwB,EAAE,OAAO;CACrC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CAC9B,UAAU,EAAE,IAAI;CAChB,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AACzB,CAAC;AAED,MAAM,iBAAiB,EAAE,OAAO;CAC9B,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CAC9B,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CA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AAM,KAAK,OAAO,KAAK;CACvB,MAAM,SAAS,OAAO,KAAK,OAAO;CAClC,OAAO;EACL,QAAQ;EACR,YAAY,QAAQ;EACpB,gBAAgB,OAAO,KAAK,WAAW,UAAU,YAAY;EAC7D,UAAU,GAAG;EACb,OAAO,GAAG;EACV,QAAQ,GAAG;EACX,gBAAgB,GAAG,SAAU,GAAG,oBAAoB,OAAQ;EAC5D,WAAW,GAAG,SAAU,GAAG,WAAW,SAAS,SAAU;CAC3D;AACF;;AAGA,SAAgB,kCACd,SAC8B;CAC9B,IAAI,QAAQ,UAAU,gBACpB,OAAO;CAET,MAAM,SAAS,uBAAuB,UAAU,QAAQ,OAAO;CAC/D,IAAI,CAAC,OAAO,WAAW,OAAO,KAAK,WAAW,aAC5C,OAAO;CAGT,MAAM,MAAM,OAAO,KAAK;CACxB,MAAM,aAAa,IAAI;CACvB,IAAI,eAAe,QAAQ,CAAC,0BAA0B,IAAI,UAAU,GAClE,OAAO;CAET,MAAM,OAAO,OAAO,KAAK,WAAW,UAAU,YAAY;CAC1D,OAAO;EACL,QAAQ;EACR,YAAY,QAAQ;EACpB,yBAAyB,OAAO,KAAK,WAAW;EAChD,gBAAgB;EAChB,SAAS;GAAE,SAAS;GAAU,SAAS,GAAG,KAAK,gBAAgB,IAAI;EAAK;EACxE,aAAa;GACX,IAAI,IAAI;GACR,MAAM,IAAI;GACV,SAAS,IAAI;GACb,QAAQ,IAAI;GACZ,oBAAoB,IAAI,iBAAiB,UAAU,YAAY,KAAK;GACpE,SAAS,IAAI;GACb,KAAK,IAAI;GACT;GACA,SAAS,IAAI;EACf;EACA,SAAS,QAAQ;CACnB;AACF"}
1
+ {"version":3,"file":"github.mjs","names":[],"sources":["../src/github.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from \"node:crypto\";\nimport { z } from \"zod\";\nimport type { NormalizedSignal, WebhookEvent } from \"./connectors/index\";\n\nconst gitHubApiUrl = \"https://api.github.com\";\nconst repositorySlugPattern = /^[^/\\s]+\\/[^/\\s]+$/;\n\nexport interface GitHubRepositoryRequest {\n repository: string;\n token: string;\n fetch?: typeof globalThis.fetch;\n}\n\nexport interface CreatePullRequestInput extends GitHubRepositoryRequest {\n title: string;\n head: string;\n base: string;\n body?: string;\n draft?: boolean;\n}\n\nexport interface CreatedPullRequest {\n prNumber: number;\n prUrl: string;\n}\n\nexport type ReviewCommentAuthorPolicy = \"write\" | \"any\";\n\ninterface ReviewCommentTrustInput {\n /** Defaults to `write`. Use `any` only when untrusted review text is handled as data. */\n authorPolicy?: ReviewCommentAuthorPolicy;\n}\n\nexport interface ReadReviewCommentInput extends GitHubRepositoryRequest, ReviewCommentTrustInput {\n commentId: number;\n}\n\nexport interface GitHubReviewComment {\n id: number;\n body: string;\n url: string;\n author: string;\n inReplyToId: number | null;\n}\n\nexport interface AnswerReviewCommentInput\n extends GitHubRepositoryRequest,\n ReviewCommentTrustInput {\n pullRequestNumber: number;\n commentId: number;\n body: string;\n}\n\nexport interface ReadPullRequestHeadInput extends GitHubRepositoryRequest {\n pullRequestNumber: number;\n}\n\nexport interface GitHubPullRequestHead {\n branch: string;\n sha: string;\n repository: string;\n}\n\nexport type PullRequestReviewEvent = \"APPROVE\" | \"REQUEST_CHANGES\" | \"COMMENT\";\n\nexport interface PullRequestReviewComment {\n path: string;\n line: number;\n body: string;\n}\n\nexport interface SubmitPullRequestReviewInput extends GitHubRepositoryRequest {\n pullRequestNumber: number;\n commitId: string;\n event: PullRequestReviewEvent;\n body: string;\n comments?: readonly PullRequestReviewComment[];\n}\n\nexport interface SubmittedPullRequestReview {\n id: number;\n url: string;\n state: string;\n}\n\nexport interface GitHubIssueComment {\n id: number;\n body: string;\n url: string;\n author: string;\n authorType: \"Bot\" | \"User\" | \"Organization\";\n}\n\nexport interface ListPullRequestCommentsInput extends GitHubRepositoryRequest {\n pullRequestNumber: number;\n}\n\nexport interface CreatePullRequestCommentInput extends ListPullRequestCommentsInput {\n body: string;\n}\n\nexport interface UpdatePullRequestCommentInput extends GitHubRepositoryRequest {\n commentId: number;\n body: string;\n}\n\nexport interface PullRequestLabelInput extends GitHubRepositoryRequest {\n pullRequestNumber: number;\n label: string;\n}\n\nexport interface ConflictedPullRequest {\n prNumber: number;\n prUrl: string;\n headBranch: string;\n headSha: string;\n baseBranch: string;\n baseSha: string;\n}\n\nexport type ListConflictedPullRequestsInput = GitHubRepositoryRequest;\n\nexport type CheckRunStatus = \"queued\" | \"in_progress\" | \"completed\";\nexport type GitHubCheckRunStatus = CheckRunStatus | \"waiting\" | \"requested\" | \"pending\";\nexport type CheckRunConclusion =\n | \"action_required\"\n | \"cancelled\"\n | \"failure\"\n | \"neutral\"\n | \"skipped\"\n | \"success\"\n | \"timed_out\";\nexport type CheckRunAnnotationLevel = \"notice\" | \"warning\" | \"failure\";\n\nexport interface CheckRunAnnotation {\n path: string;\n startLine: number;\n endLine?: number;\n startColumn?: number;\n endColumn?: number;\n annotationLevel: CheckRunAnnotationLevel;\n message: string;\n title?: string;\n rawDetails?: string;\n}\n\nexport interface CheckRunOutput {\n title: string;\n summary: string;\n text?: string;\n annotations?: readonly CheckRunAnnotation[];\n}\n\ninterface CheckRunFields {\n status?: CheckRunStatus;\n conclusion?: CheckRunConclusion;\n detailsUrl?: string;\n externalId?: string;\n startedAt?: string;\n completedAt?: string;\n output?: CheckRunOutput;\n}\n\nexport interface CreateCheckRunInput extends GitHubRepositoryRequest, CheckRunFields {\n name: string;\n headSha: string;\n}\n\nexport interface UpdateCheckRunInput extends GitHubRepositoryRequest, CheckRunFields {\n checkRunId: number;\n name?: string;\n}\n\nexport interface ListCheckRunsForRefInput extends GitHubRepositoryRequest {\n ref: string;\n checkName?: string;\n}\n\nexport interface GitHubCheckRun {\n id: number;\n name: string;\n headSha: string;\n status: GitHubCheckRunStatus;\n conclusion: CheckRunConclusion | \"stale\" | \"startup_failure\" | null;\n url: string | null;\n detailsUrl: string | null;\n externalId: string | null;\n startedAt: string | null;\n completedAt: string | null;\n}\n\nconst pullRequestSchema = z.object({\n number: z.number().int().positive(),\n html_url: z.url(),\n});\n\nconst pullRequestHeadSchema = z.object({\n head: z.object({\n ref: z\n .string()\n .regex(/^[A-Za-z0-9][A-Za-z0-9._/-]*$/)\n .refine((value) => !value.includes(\"..\")),\n sha: z.string().regex(/^[0-9a-f]{40}$/),\n repo: z.object({ full_name: z.string().min(1) }),\n }),\n});\n\nconst reviewCommentSchema = z.object({\n id: z.number().int().positive(),\n body: z.string(),\n html_url: z.url(),\n user: z.object({ login: z.string().min(1) }),\n in_reply_to_id: z.number().int().positive().nullish(),\n});\n\nconst submittedReviewSchema = z.object({\n id: z.number().int().positive(),\n html_url: z.url(),\n state: z.string().min(1),\n});\n\nconst issueCommentSchema = z.object({\n id: z.number().int().positive(),\n body: z.string(),\n html_url: z.url(),\n user: z.object({\n login: z.string().min(1),\n type: z.enum([\"Bot\", \"User\", \"Organization\"]),\n }),\n});\n\nconst checkRunSchema = z.object({\n id: z.number().int().positive(),\n name: z.string().min(1),\n head_sha: z.string().regex(/^[0-9a-f]{40}$/),\n status: z.enum([\"queued\", \"in_progress\", \"completed\", \"waiting\", \"requested\", \"pending\"]),\n conclusion: z\n .enum([\n \"action_required\",\n \"cancelled\",\n \"failure\",\n \"neutral\",\n \"skipped\",\n \"success\",\n \"timed_out\",\n \"stale\",\n \"startup_failure\",\n ])\n .nullable(),\n html_url: z.url().nullable(),\n details_url: z.url().nullable(),\n external_id: z.string().nullable(),\n started_at: z.string().nullable(),\n completed_at: z.string().nullable(),\n});\n\nconst checkRunsSchema = z.object({ check_runs: z.array(checkRunSchema) });\nconst labelsSchema = z.array(z.object({ name: z.string().min(1) }));\nconst pullRequestCandidateSchema = z.object({\n number: z.number().int().positive(),\n user: z.object({ type: z.string().min(1) }),\n head: z.object({ ref: z.string().min(1), repo: z.object({ full_name: z.string().min(1) }) }),\n});\nconst openPullRequestsSchema = z.array(pullRequestCandidateSchema);\nconst pullRequestDetailSchema = pullRequestCandidateSchema.extend({\n html_url: z.url(),\n mergeable: z.boolean().nullable(),\n mergeable_state: z.string().min(1),\n head: pullRequestCandidateSchema.shape.head.extend({ sha: z.string().min(1) }),\n base: z.object({ ref: z.string().min(1), sha: z.string().min(1) }),\n});\nconst collaboratorPermissionSchema = z.object({\n permission: z.enum([\"admin\", \"maintain\", \"write\", \"triage\", \"read\", \"none\"]),\n});\nconst writePermissions = new Set([\"admin\", \"maintain\", \"write\"]);\n\nexport class GitHubReviewCommentAuthorError extends Error {\n readonly author: string;\n\n constructor(author: string) {\n super(`GitHub user ${author} does not have write access to the repository`);\n this.name = \"GitHubReviewCommentAuthorError\";\n this.author = author;\n }\n}\n\n/** Create a pull request from an existing head branch. */\nexport async function createPullRequest(input: CreatePullRequestInput): Promise<CreatedPullRequest> {\n const pull = pullRequestSchema.parse(\n await gitHubRequest(input, \"/pulls\", {\n method: \"POST\",\n body: JSON.stringify({\n title: input.title,\n head: input.head,\n base: input.base,\n ...(input.body === undefined ? {} : { body: input.body }),\n ...(input.draft === undefined ? {} : { draft: input.draft }),\n }),\n }),\n );\n return { prNumber: pull.number, prUrl: pull.html_url };\n}\n\n/** Create a check run for one commit. Requires a GitHub App token with checks:write. */\nexport async function createCheckRun(input: CreateCheckRunInput): Promise<GitHubCheckRun> {\n if (input.status === \"completed\" && input.conclusion === undefined) {\n throw new Error(\"completed check runs require a conclusion\");\n }\n if (input.status !== \"completed\" && input.conclusion !== undefined) {\n throw new Error(\"creating a check run with a conclusion requires completed status\");\n }\n return parseCheckRun(\n await gitHubRequest(input, \"/check-runs\", {\n method: \"POST\",\n body: JSON.stringify({\n name: input.name,\n head_sha: commitSha(input.headSha),\n ...checkRunFields(input),\n }),\n }),\n );\n}\n\n/** Update a check run previously created by the authenticated GitHub App. */\nexport async function updateCheckRun(input: UpdateCheckRunInput): Promise<GitHubCheckRun> {\n if (input.status !== undefined && input.status !== \"completed\" && input.conclusion !== undefined) {\n throw new Error(\"a check run conclusion conflicts with an incomplete status\");\n }\n return parseCheckRun(\n await gitHubRequest(input, `/check-runs/${positiveInteger(input.checkRunId, \"checkRunId\")}`, {\n method: \"PATCH\",\n body: JSON.stringify({\n ...(input.name === undefined ? {} : { name: input.name }),\n ...checkRunFields(input),\n }),\n }),\n );\n}\n\n/** List check runs reported for a commit, branch, or tag. */\nexport async function listCheckRunsForRef(input: ListCheckRunsForRefInput): Promise<GitHubCheckRun[]> {\n const query = new URLSearchParams({ per_page: \"100\" });\n if (input.checkName !== undefined) query.set(\"check_name\", input.checkName);\n const response = checkRunsSchema.parse(\n await gitHubRequest(input, `/commits/${encodeURIComponent(input.ref)}/check-runs?${query.toString()}`),\n );\n return response.check_runs.map(parseCheckRun);\n}\n\n/** List every issue-style comment in a pull request conversation. */\nexport async function listPullRequestComments(\n input: ListPullRequestCommentsInput,\n): Promise<GitHubIssueComment[]> {\n const comments: GitHubIssueComment[] = [];\n for (let page = 1; ; page += 1) {\n const response = z.array(issueCommentSchema).parse(\n await gitHubRequest(\n input,\n `/issues/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/comments?per_page=100&page=${page}`,\n ),\n );\n comments.push(...response.map(parseIssueComment));\n if (response.length < 100) return comments;\n }\n}\n\n/** Add one issue-style comment to a pull request conversation. */\nexport async function createPullRequestComment(\n input: CreatePullRequestCommentInput,\n): Promise<GitHubIssueComment> {\n return parseIssueComment(\n await gitHubRequest(\n input,\n `/issues/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/comments`,\n { method: \"POST\", body: JSON.stringify({ body: input.body }) },\n ),\n );\n}\n\n/** Edit one issue-style pull request comment. */\nexport async function updatePullRequestComment(\n input: UpdatePullRequestCommentInput,\n): Promise<GitHubIssueComment> {\n return parseIssueComment(\n await gitHubRequest(input, `/issues/comments/${positiveInteger(input.commentId, \"commentId\")}`, {\n method: \"PATCH\",\n body: JSON.stringify({ body: input.body }),\n }),\n );\n}\n\n/** Read one inline review comment after applying the author policy, which requires write access by default. */\nexport async function readReviewComment(\n input: ReadReviewCommentInput,\n): Promise<GitHubReviewComment> {\n const comment = parseReviewComment(\n await gitHubRequest(input, `/pulls/comments/${positiveInteger(input.commentId, \"commentId\")}`),\n );\n await assertReviewCommentAuthor(input, comment.author);\n return comment;\n}\n\n/** Reply to an inline review comment after applying the author policy, which requires write access by default. */\nexport async function answerReviewComment(\n input: AnswerReviewCommentInput,\n): Promise<GitHubReviewComment> {\n await readReviewComment(input);\n return parseReviewComment(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/comments/${positiveInteger(input.commentId, \"commentId\")}/replies`,\n { method: \"POST\", body: JSON.stringify({ body: input.body }) },\n ),\n );\n}\n\n/** Submit a summary and optional inline comments against a reviewed pull request commit. */\nexport async function submitPullRequestReview(\n input: SubmitPullRequestReviewInput,\n): Promise<SubmittedPullRequestReview> {\n const commitId = z.string().regex(/^[0-9a-f]{40}$/).parse(input.commitId);\n const head = await readPullRequestHead(input);\n if (head.sha !== commitId) {\n throw new Error(`pull request changed after review: expected ${commitId}, found ${head.sha}`);\n }\n const review = submittedReviewSchema.parse(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/reviews`,\n {\n method: \"POST\",\n body: JSON.stringify({\n commit_id: commitId,\n event: input.event,\n body: input.body,\n comments: (input.comments ?? []).map((comment) => ({\n path: comment.path,\n line: positiveInteger(comment.line, \"comment line\"),\n side: \"RIGHT\",\n body: comment.body,\n })),\n }),\n },\n ),\n );\n return { id: review.id, url: review.html_url, state: review.state };\n}\n\n/** Read the current head branch and commit of a pull request. */\nexport async function readPullRequestHead(\n input: ReadPullRequestHeadInput,\n): Promise<GitHubPullRequestHead> {\n const pull = pullRequestHeadSchema.parse(\n await gitHubRequest(input, `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}`),\n );\n return {\n branch: pull.head.ref,\n sha: pull.head.sha,\n repository: pull.head.repo.full_name.toLowerCase(),\n };\n}\n\n/** List open, same-repository pull requests by one author that GitHub reports as conflicting. */\nexport async function listConflictedPullRequests(\n input: ListConflictedPullRequestsInput,\n): Promise<ConflictedPullRequest[]> {\n const pulls = openPullRequestsSchema.parse(\n await gitHubRequest(input, `/pulls?state=open&per_page=100`),\n );\n const candidates = pulls.filter(\n (pull) =>\n pull.user.type === \"Bot\" &&\n pull.head.ref.startsWith(\"factory/\") &&\n pull.head.repo.full_name.toLowerCase() === input.repository.toLowerCase(),\n );\n const conflicted: ConflictedPullRequest[] = [];\n for (const candidate of candidates) {\n const pull = pullRequestDetailSchema.parse(\n await gitHubRequest(input, `/pulls/${candidate.number}`),\n );\n if (pull.mergeable === false || pull.mergeable_state === \"dirty\") {\n conflicted.push({\n prNumber: pull.number,\n prUrl: pull.html_url,\n headBranch: pull.head.ref,\n headSha: pull.head.sha,\n baseBranch: pull.base.ref,\n baseSha: pull.base.sha,\n });\n }\n }\n return conflicted;\n}\n\n/** Add one label to a pull request. */\nexport async function addLabel(input: PullRequestLabelInput): Promise<string[]> {\n return parseLabels(\n await gitHubRequest(\n input,\n `/issues/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/labels`,\n { method: \"POST\", body: JSON.stringify({ labels: [input.label] }) },\n ),\n );\n}\n\n/** Remove one label from a pull request. */\nexport async function removeLabel(input: PullRequestLabelInput): Promise<string[]> {\n return parseLabels(\n await gitHubRequest(\n input,\n `/issues/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/labels/${encodeURIComponent(input.label)}`,\n { method: \"DELETE\" },\n ),\n );\n}\n\nasync function gitHubRequest(\n input: GitHubRepositoryRequest,\n path: string,\n init: RequestInit = {},\n): Promise<unknown> {\n if (!repositorySlugPattern.test(input.repository)) {\n throw new Error(`invalid GitHub repository slug: ${input.repository}`);\n }\n const response = await (input.fetch ?? globalThis.fetch)(\n `${gitHubApiUrl}/repos/${input.repository}${path}`,\n {\n ...init,\n headers: {\n Accept: \"application/vnd.github+json\",\n Authorization: `Bearer ${input.token}`,\n \"Content-Type\": \"application/json\",\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n ...init.headers,\n },\n },\n );\n const body: unknown = await response.json();\n if (!response.ok) {\n const message = z.object({ message: z.string() }).safeParse(body);\n throw new Error(\n `GitHub API request failed (${response.status}): ${message.success ? message.data.message : response.statusText}`,\n );\n }\n return body;\n}\n\nfunction parseReviewComment(value: unknown): GitHubReviewComment {\n const comment = reviewCommentSchema.parse(value);\n return {\n id: comment.id,\n body: comment.body,\n url: comment.html_url,\n author: comment.user.login,\n inReplyToId: comment.in_reply_to_id ?? null,\n };\n}\n\nfunction parseIssueComment(value: unknown): GitHubIssueComment {\n const comment = issueCommentSchema.parse(value);\n return {\n id: comment.id,\n body: comment.body,\n url: comment.html_url,\n author: comment.user.login,\n authorType: comment.user.type,\n };\n}\n\nfunction parseLabels(value: unknown): string[] {\n return labelsSchema.parse(value).map(({ name }) => name);\n}\n\nfunction parseCheckRun(value: unknown): GitHubCheckRun {\n const checkRun = checkRunSchema.parse(value);\n return {\n id: checkRun.id,\n name: checkRun.name,\n headSha: checkRun.head_sha,\n status: checkRun.status,\n conclusion: checkRun.conclusion,\n url: checkRun.html_url,\n detailsUrl: checkRun.details_url,\n externalId: checkRun.external_id,\n startedAt: checkRun.started_at,\n completedAt: checkRun.completed_at,\n };\n}\n\nfunction checkRunFields(input: CheckRunFields): Record<string, unknown> {\n return {\n ...(input.status === undefined ? {} : { status: input.status }),\n ...(input.conclusion === undefined ? {} : { conclusion: input.conclusion }),\n ...(input.detailsUrl === undefined ? {} : { details_url: input.detailsUrl }),\n ...(input.externalId === undefined ? {} : { external_id: input.externalId }),\n ...(input.startedAt === undefined ? {} : { started_at: input.startedAt }),\n ...(input.completedAt === undefined ? {} : { completed_at: input.completedAt }),\n ...(input.output === undefined ? {} : { output: checkRunOutput(input.output) }),\n };\n}\n\nfunction checkRunOutput(output: CheckRunOutput): Record<string, unknown> {\n return {\n title: output.title,\n summary: output.summary,\n ...(output.text === undefined ? {} : { text: output.text }),\n ...(output.annotations === undefined\n ? {}\n : {\n annotations: output.annotations.map((annotation) => ({\n path: annotation.path,\n start_line: positiveInteger(annotation.startLine, \"annotation startLine\"),\n end_line: positiveInteger(annotation.endLine ?? annotation.startLine, \"annotation endLine\"),\n ...(annotation.startColumn === undefined\n ? {}\n : { start_column: positiveInteger(annotation.startColumn, \"annotation startColumn\") }),\n ...(annotation.endColumn === undefined\n ? {}\n : { end_column: positiveInteger(annotation.endColumn, \"annotation endColumn\") }),\n annotation_level: annotation.annotationLevel,\n message: annotation.message,\n ...(annotation.title === undefined ? {} : { title: annotation.title }),\n ...(annotation.rawDetails === undefined ? {} : { raw_details: annotation.rawDetails }),\n })),\n }),\n };\n}\n\nasync function assertReviewCommentAuthor(\n input: GitHubRepositoryRequest & ReviewCommentTrustInput,\n author: string,\n): Promise<void> {\n if (input.authorPolicy === \"any\") {\n return;\n }\n const { permission } = collaboratorPermissionSchema.parse(\n await gitHubRequest(input, `/collaborators/${encodeURIComponent(author)}/permission`),\n );\n if (!writePermissions.has(permission)) {\n throw new GitHubReviewCommentAuthorError(author);\n }\n}\n\nfunction positiveInteger(value: number, name: string): number {\n if (!Number.isInteger(value) || value < 1) {\n throw new Error(`${name} must be a positive integer`);\n }\n return value;\n}\n\nfunction commitSha(value: string): string {\n return z.string().regex(/^[0-9a-f]{40}$/).parse(value);\n}\n\n/**\n * Verify a GitHub webhook HMAC signature (the x-hub-signature-256 header)\n * against the raw request body. Returns false for missing or malformed\n * signatures instead of throwing.\n */\nexport function verifyGitHubSignature(options: {\n secret: string;\n payload: string;\n signature: string | null;\n}): boolean {\n const { secret, payload, signature } = options;\n if (signature === null || !signature.startsWith(\"sha256=\")) {\n return false;\n }\n const expected = createHmac(\"sha256\", secret).update(payload).digest(\"hex\");\n const provided = signature.slice(\"sha256=\".length);\n if (provided.length !== expected.length) {\n return false;\n }\n return timingSafeEqual(Buffer.from(provided, \"hex\"), Buffer.from(expected, \"hex\"));\n}\n\nconst pushEventSchema = z.looseObject({\n ref: z.string().min(1),\n repository: z.looseObject({\n default_branch: z.string().min(1),\n full_name: z.string().min(1),\n }),\n});\n\nexport interface GitHubDefaultBranchPush {\n source: \"github_default_branch_push\";\n deliveryId: string;\n repositorySlug: string;\n defaultBranch: string;\n}\n\n/** Normalize a push to a repository's default branch for deterministic reconciliation. */\nexport function normalizeGitHubDefaultBranchPush(options: {\n deliveryId: string;\n event: string;\n payload: unknown;\n}): GitHubDefaultBranchPush | null {\n if (options.event !== \"push\") return null;\n const parsed = pushEventSchema.safeParse(options.payload);\n if (!parsed.success || parsed.data.ref !== `refs/heads/${parsed.data.repository.default_branch}`) {\n return null;\n }\n return {\n source: \"github_default_branch_push\",\n deliveryId: options.deliveryId,\n repositorySlug: parsed.data.repository.full_name.toLowerCase(),\n defaultBranch: parsed.data.repository.default_branch,\n };\n}\n\nconst pullRequestEventSchema = z.looseObject({\n action: z.string(),\n number: z.number().int().positive(),\n pull_request: z.looseObject({\n html_url: z.url(),\n draft: z.boolean(),\n user: z.looseObject({ login: z.string().min(1) }),\n head: z.looseObject({\n sha: z.string().regex(/^[0-9a-f]{40}$/),\n ref: z.string().min(1),\n repo: z.looseObject({ full_name: z.string().min(1) }),\n }),\n base: z.looseObject({\n sha: z.string().regex(/^[0-9a-f]{40}$/),\n ref: z.string().min(1),\n }),\n }),\n repository: z.looseObject({ full_name: z.string().min(1) }),\n sender: z.looseObject({ login: z.string().min(1) }),\n});\n\nconst reviewablePullRequestActions = new Set([\"opened\", \"reopened\", \"ready_for_review\", \"synchronize\"]);\n\nexport interface GitHubPullRequestSignal extends NormalizedSignal<\"github_pr\"> {\n repositorySlug: string;\n pullRequest: {\n number: number;\n url: string;\n author: string;\n draft: boolean;\n headSha: string;\n headBranch: string;\n headRepositorySlug: string;\n baseSha: string;\n baseBranch: string;\n sender: string;\n };\n}\n\n/** Normalize a newly reviewable or updated pull request into a factory signal. */\nexport function normalizeGitHubPullRequest(options: WebhookEvent): GitHubPullRequestSignal | null {\n if (options.event !== \"pull_request\") return null;\n const parsed = pullRequestEventSchema.safeParse(options.payload);\n if (!parsed.success || !reviewablePullRequestActions.has(parsed.data.action)) return null;\n if (parsed.data.pull_request.draft && parsed.data.action !== \"ready_for_review\") return null;\n\n const slug = parsed.data.repository.full_name.toLowerCase();\n const pull = parsed.data.pull_request;\n return {\n source: \"github_pr\",\n deliveryId: options.deliveryId,\n repositorySlug: slug,\n replyTo: { channel: \"github\", address: `${slug}/pull/${parsed.data.number}` },\n pullRequest: {\n number: parsed.data.number,\n url: pull.html_url,\n author: pull.user.login,\n draft: pull.draft,\n headSha: pull.head.sha,\n headBranch: pull.head.ref,\n headRepositorySlug: pull.head.repo.full_name.toLowerCase(),\n baseSha: pull.base.sha,\n baseBranch: pull.base.ref,\n sender: parsed.data.sender.login,\n },\n payload: options.payload,\n };\n}\n\nconst issueEventSchema = z.looseObject({\n action: z.string(),\n issue: z.looseObject({\n number: z.number().int().min(1),\n title: z.string(),\n body: z.string().nullable(),\n }),\n repository: z.looseObject({\n full_name: z.string().min(1),\n }),\n});\n\nexport interface GitHubIssueSignal extends NormalizedSignal<\"github_issue\"> {\n repositorySlug: string;\n issue: { number: number; title: string; body: string | null };\n}\n\nconst failedWorkflowConclusions = new Set([\n \"action_required\",\n \"failure\",\n \"stale\",\n \"startup_failure\",\n \"timed_out\",\n]);\n\nconst workflowRunEventSchema = z.looseObject({\n action: z.string(),\n repository: z.looseObject({\n default_branch: z.string().min(1),\n full_name: z.string().min(1),\n }),\n workflow_run: z.looseObject({\n id: z.number().int().min(1),\n name: z.string().min(1),\n event: z.string().min(1),\n head_branch: z.string().min(1).nullable(),\n head_repository: z\n .looseObject({\n full_name: z.string().min(1),\n })\n .nullable(),\n head_sha: z.string().min(1),\n html_url: z.url(),\n conclusion: z.string().nullable(),\n run_attempt: z.number().int().min(1),\n }),\n});\n\nexport interface GitHubCIFailureSignal extends NormalizedSignal<\"github_ci_failure\"> {\n repositoryDefaultBranch: string;\n repositorySlug: string;\n workflowRun: {\n id: number;\n name: string;\n trigger: string;\n branch: string | null;\n headRepositorySlug: string | null;\n headSha: string;\n url: string;\n conclusion: string;\n attempt: number;\n };\n}\n\n/**\n * Normalize a GitHub issues webhook into the factory's signal shape. Returns\n * null for payloads that are not an opened issue. The caller supplies the\n * repository id; the payload stays untrusted data.\n */\nexport function normalizeGitHubIssueOpened(options: WebhookEvent): GitHubIssueSignal | null {\n if (options.event !== \"issues\") {\n return null;\n }\n const parsed = issueEventSchema.safeParse(options.payload);\n if (!parsed.success || parsed.data.action !== \"opened\") {\n return null;\n }\n const slug = parsed.data.repository.full_name.toLowerCase();\n const { number, title, body } = parsed.data.issue;\n return {\n source: \"github_issue\",\n deliveryId: options.deliveryId,\n repositorySlug: slug,\n replyTo: { channel: \"github\", address: `${slug}#${number}` },\n issue: { number, title, body },\n payload: options.payload,\n };\n}\n\nconst pullRequestClosedSchema = z.looseObject({\n action: z.string(),\n pull_request: z.looseObject({\n number: z.number().int().min(1),\n html_url: z.url(),\n merged: z.boolean(),\n merged_by: z.looseObject({ login: z.string().min(1) }).nullable().optional(),\n merge_commit_sha: z\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .nullable()\n .optional(),\n }),\n repository: z.looseObject({\n full_name: z.string().min(1),\n }),\n sender: z.looseObject({ login: z.string().min(1) }),\n});\n\nexport interface GitHubPullRequestClosed {\n source: \"github_pull_request_closed\";\n deliveryId: string;\n repositorySlug: string;\n prNumber: number;\n prUrl: string;\n merged: boolean;\n /** The merge commit on the base branch; null when closed without merging. */\n mergeCommitSha: string | null;\n /** The GitHub login that merged the pull request, or closed it without merging. */\n decidedBy: string;\n}\n\n/**\n * Normalize a closed pull_request webhook so the factory can observe what\n * happened to its change: merged records merged_by (the sender when GitHub\n * omits it), a close without merge records the sender.\n */\nexport function normalizeGitHubPullRequestClosed(\n options: WebhookEvent,\n): GitHubPullRequestClosed | null {\n if (options.event !== \"pull_request\") {\n return null;\n }\n const parsed = pullRequestClosedSchema.safeParse(options.payload);\n if (!parsed.success || parsed.data.action !== \"closed\") {\n return null;\n }\n const pr = parsed.data.pull_request;\n const sender = parsed.data.sender.login;\n return {\n source: \"github_pull_request_closed\",\n deliveryId: options.deliveryId,\n repositorySlug: parsed.data.repository.full_name.toLowerCase(),\n prNumber: pr.number,\n prUrl: pr.html_url,\n merged: pr.merged,\n mergeCommitSha: pr.merged ? (pr.merge_commit_sha ?? null) : null,\n decidedBy: pr.merged ? (pr.merged_by?.login ?? sender) : sender,\n };\n}\n\n/** Normalize a completed, unsuccessful GitHub Actions run into a CI failure signal. */\nexport function normalizeGitHubWorkflowRunFailure(\n options: WebhookEvent,\n): GitHubCIFailureSignal | null {\n if (options.event !== \"workflow_run\") {\n return null;\n }\n const parsed = workflowRunEventSchema.safeParse(options.payload);\n if (!parsed.success || parsed.data.action !== \"completed\") {\n return null;\n }\n\n const run = parsed.data.workflow_run;\n const conclusion = run.conclusion;\n if (conclusion === null || !failedWorkflowConclusions.has(conclusion)) {\n return null;\n }\n const slug = parsed.data.repository.full_name.toLowerCase();\n return {\n source: \"github_ci_failure\",\n deliveryId: options.deliveryId,\n repositoryDefaultBranch: parsed.data.repository.default_branch,\n repositorySlug: slug,\n replyTo: { channel: \"github\", address: `${slug}/actions/runs/${run.id}` },\n workflowRun: {\n id: run.id,\n name: run.name,\n trigger: run.event,\n branch: run.head_branch,\n headRepositorySlug: run.head_repository?.full_name.toLowerCase() ?? null,\n headSha: run.head_sha,\n url: run.html_url,\n conclusion,\n attempt: run.run_attempt,\n },\n payload: options.payload,\n };\n}\n"],"mappings":";;;AAIA,MAAM,eAAe;AACrB,MAAM,wBAAwB;AA0L9B,MAAM,oBAAoB,EAAE,OAAO;CACjC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CAClC,UAAU,EAAE,IAAI;AAClB,CAAC;AAED,MAAM,wBAAwB,EAAE,OAAO,EACrC,MAAM,EAAE,OAAO;CACb,KAAK,EACF,OAAO,CAAC,CACR,MAAM,+BAA+B,CAAC,CACtC,QAAQ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