@vercel/factory 0.0.21 → 0.0.23

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.
@@ -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\";\nimport type { OpenPullRequest } from \"./pull-requests/contracts\";\nimport { repositorySlugSchema, type RepositorySlug } from \"./schema/repository\";\n\nexport {\n mintGitHubAppInstallationToken,\n type GitHubAppFactoryInput,\n type GitHubAppInstallationToken,\n type GitHubAppLike,\n type GitHubAppPermissions,\n type MintGitHubAppInstallationTokenInput,\n} from \"./github-app\";\nexport {\n checkoutGitHubRepository,\n createGitHubPublicationClient,\n factorySessionBranch,\n factoryTaskBranch,\n GitHubCheckoutConflictError,\n GitHubPublicationApiError,\n isSafeGitRef,\n readCommittedGitChange,\n runSandboxGit,\n type CheckoutGitHubRepositoryInput,\n type CommittedGitChange,\n type CreatedGitHubPublicationPullRequest,\n type CreateGitHubBranchInput,\n type CreateGitHubCommitInput,\n type CreateGitHubPublicationPullRequestInput,\n type CreateGitHubTreeInput,\n type GitHubCommit,\n type GitHubPublicationClient,\n type GitHubPublicationClientOptions,\n type GitHubPublicationLimits,\n type GitHubPublicationPullRequest,\n type GitHubTreeDeletion,\n type GitHubTreeEntry,\n type GitHubTreeUpsert,\n type MarkGitHubPullRequestReadyInput,\n type ListGitHubPublicationPullRequestsInput,\n type ReadCommittedGitChangeInput,\n type ReadGitHubBranchHeadInput,\n type ReadGitHubCommitInput,\n type ReadGitHubPullRequestInput,\n type RunSandboxGitInput,\n type SandboxGit,\n type SandboxGitCommandInput,\n type SandboxGitCommandResult,\n type UpdateGitHubBranchInput,\n} from \"./github-publication\";\n\nexport type {\n FetchGitHubBundleInput,\n FetchGitHubRefsInput,\n GitHubGitTransport,\n GitHubRefMapping,\n GitHubRepositoryBundle,\n GitTransferSandbox,\n ReadGitTransferFileInput,\n PushGitHubBundleInput,\n PushGitHubHeadInput,\n WithSandboxGitBundleInput,\n WriteGitTransferFileInput,\n} from \"./github-transfer\";\n\nconst gitHubApiUrl = \"https://api.github.com\";\nconst gitHubRepositorySlugSchema = z\n .string()\n .min(1)\n .transform((value) => value.toLowerCase())\n .pipe(repositorySlugSchema);\n\nconst factoryReviewCommentEventSchema = z.looseObject({\n action: z.literal(\"created\"),\n comment: z.looseObject({\n id: z.number().int().positive(),\n body: z.string(),\n html_url: z.url(),\n in_reply_to_id: z.number().int().positive().nullish(),\n }),\n pull_request: z.looseObject({\n number: z.number().int().positive(),\n html_url: z.url(),\n user: z.looseObject({ login: z.string().min(1) }),\n }),\n repository: z.looseObject({ full_name: gitHubRepositorySlugSchema }),\n});\n\nconst factoryQuestionReplyEventSchema = z.looseObject({\n action: z.literal(\"created\"),\n comment: z.looseObject({\n body: z.string(),\n html_url: z.url(),\n id: z.number().int().positive(),\n }),\n issue: z.looseObject({\n number: z.number().int().positive(),\n pull_request: z.unknown().optional(),\n }),\n repository: z.looseObject({ full_name: gitHubRepositorySlugSchema }),\n sender: z.looseObject({ login: z.string().min(1), type: z.string().min(1) }),\n});\n\nconst defaultReviewMentions = [\"factory\"] as const;\nconst defaultQuestionMentions = [\"agent-factory\", \"agent-factory[bot]\", \"factory\"] as const;\n\n/** Custom mention names accepted by Factory's GitHub comment normalizers. */\nexport interface FactoryMentionOptions {\n mentions?: readonly string[];\n}\n\n/** Provider event and optional mentions accepted by Factory comment normalizers. */\nexport interface NormalizeFactoryCommentInput extends FactoryMentionOptions {\n event: string;\n payload: unknown;\n}\n\n/** Select addressed comments and optionally reply candidates whose ownership the caller must verify. */\nexport interface NormalizeFactoryReviewCommentInput extends NormalizeFactoryCommentInput {\n includeReplies?: boolean;\n}\n\n/** Configured repositories and provider observations used to select one trusted repository. */\nexport interface ConfiguredEventRepositoryInput {\n configuredSlugs: readonly RepositorySlug[];\n eventSlugs: readonly (RepositorySlug | null)[];\n}\n\nfunction stripMention(body: string, mentions: readonly string[]): string | null {\n const trimmed = body.trimStart();\n for (const mention of mentions) {\n const prefix = `@${mention.trim()}`;\n if (prefix === \"@\" || trimmed.slice(0, prefix.length).toLowerCase() !== prefix.toLowerCase()) {\n continue;\n }\n const remainder = trimmed.slice(prefix.length);\n if (!/^[\\s,:-]/u.test(remainder)) continue;\n return remainder.replace(/^[\\s,:-]*/u, \"\").trim();\n }\n return null;\n}\n\n/** Routing metadata extracted from an addressed inline comment or an opt-in reply candidate. */\nexport interface FactoryReviewComment {\n repositorySlug: RepositorySlug;\n pullRequestNumber: number;\n pullRequestUrl: string;\n pullRequestAuthor: string;\n commentId: number;\n commentUrl: string;\n}\n\n/** Human answer extracted from a mentioned GitHub issue comment. */\nexport interface FactoryQuestionReply {\n repositorySlug: RepositorySlug;\n replyAddress: string;\n author: string;\n answer: string;\n commentId: number;\n issueNumber: number;\n commentUrl: string;\n}\n\n/** Select the one configured repository consistently identified by a provider delivery. */\nexport function configuredEventRepositorySlug(\n input: ConfiguredEventRepositoryInput,\n): RepositorySlug | null {\n const { configuredSlugs, eventSlugs } = input;\n const distinctEventSlugs = [\n ...new Set(eventSlugs.filter((slug): slug is RepositorySlug => slug !== null)),\n ];\n const eventSlug = distinctEventSlugs[0];\n return distinctEventSlugs.length === 1 &&\n eventSlug !== undefined &&\n configuredSlugs.includes(eventSlug)\n ? eventSlug\n : null;\n}\n\n/** Normalize addressed inline comments or opt-in reply candidates; callers must authenticate them. */\nexport function normalizeFactoryReviewComment(\n input: NormalizeFactoryReviewCommentInput,\n): FactoryReviewComment | null {\n if (input.event !== \"pull_request_review_comment\") return null;\n const parsed = factoryReviewCommentEventSchema.safeParse(input.payload);\n if (\n !parsed.success ||\n (stripMention(parsed.data.comment.body, input.mentions ?? defaultReviewMentions) === null &&\n !(input.includeReplies && parsed.data.comment.in_reply_to_id != null))\n ) {\n return null;\n }\n return {\n repositorySlug: parsed.data.repository.full_name,\n pullRequestNumber: parsed.data.pull_request.number,\n pullRequestUrl: parsed.data.pull_request.html_url,\n pullRequestAuthor: parsed.data.pull_request.user.login,\n commentId: parsed.data.comment.id,\n commentUrl: parsed.data.comment.html_url,\n };\n}\n\n/**\n * Strip the Factory mention from an issue comment body, returning null when the\n * comment does not address Factory. Exported so a caller reconciling a delivery\n * against GitHub's own copy of the comment applies the same rule the normalizer\n * applied to the payload.\n */\nexport function stripFactoryQuestionMention(\n body: string,\n options: FactoryMentionOptions = {},\n): string | null {\n return stripMention(body, options.mentions ?? defaultQuestionMentions);\n}\n\n/** Normalize a mentioned issue comment that can answer a persisted Factory QuestionTask. */\nexport function normalizeFactoryQuestionReply(\n input: NormalizeFactoryCommentInput,\n): FactoryQuestionReply | null {\n if (input.event !== \"issue_comment\") return null;\n const parsed = factoryQuestionReplyEventSchema.safeParse(input.payload);\n if (!parsed.success || parsed.data.sender.type.toLowerCase() === \"bot\") return null;\n const answer = stripMention(parsed.data.comment.body, input.mentions ?? defaultQuestionMentions);\n if (answer === null || answer === \"\") return null;\n if (parsed.data.issue.pull_request !== undefined) return null;\n const repositorySlug = parsed.data.repository.full_name;\n return {\n repositorySlug,\n replyAddress: `${repositorySlug}#${parsed.data.issue.number}`,\n author: parsed.data.sender.login,\n answer,\n commentId: parsed.data.comment.id,\n issueNumber: parsed.data.issue.number,\n commentUrl: parsed.data.comment.html_url,\n };\n}\n\n/** Credentials and transport for a repository-scoped GitHub REST request. */\nexport interface GitHubRepositoryRequest {\n repository: RepositorySlug;\n token: string;\n fetch?: typeof globalThis.fetch;\n}\n\n/** Repository-scoped identity of one pull request accepted by GitHub operations. */\nexport interface GitHubPullRequestTarget extends GitHubRepositoryRequest {\n pullRequestNumber: number;\n}\n\n/** Provider-owned number and URL that identify one GitHub pull request. */\nexport interface GitHubPullRequestReference {\n pullRequestNumber: number;\n pullRequestUrl: string;\n}\n\n/** Repository request that identifies the GitHub actor whose access must be checked. */\nexport interface GitHubRepositoryAuthorRequest extends GitHubRepositoryRequest {\n author: string;\n}\n\n/** Repository-scoped fields required to open a pull request from an existing branch. */\nexport interface CreatePullRequestInput extends GitHubRepositoryRequest {\n title: string;\n head: string;\n base: string;\n body?: string;\n draft?: boolean;\n}\n\n/** Provider identity returned after GitHub creates a pull request. */\nexport type CreatedGitHubPullRequest = GitHubPullRequestReference;\n\n/** Trust threshold applied before Factory consumes an inline review comment. */\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\n/** Pull request, comment identity, and author policy used to read an inline review comment. */\nexport interface ReadReviewCommentInput extends GitHubPullRequestTarget, ReviewCommentTrustInput {\n commentId: number;\n}\n\n/** Normalized inline review comment, with a null author when GitHub no longer exposes it. */\nexport interface GitHubReviewComment {\n id: number;\n pullRequestNumber: number;\n body: string;\n url: string;\n author: string | null;\n /** GitHub account type when available, used to distinguish human requests from bot activity. */\n authorType: string | null;\n inReplyToId: number | null;\n reviewId: number | null;\n}\n\n/** Trusted inline comment and reply content used to post a threaded answer. */\nexport interface AnswerReviewCommentInput extends GitHubPullRequestTarget, ReviewCommentTrustInput {\n commentId: number;\n body: string;\n}\n\n/** Current branch, commit, and source repository of a pull request head. */\nexport interface GitHubPullRequestHead {\n branch: string;\n sha: string;\n repository: RepositorySlug;\n}\n\n/** Provider-owned identity, author, and lifecycle state of a pull request. */\nexport interface GitHubPullRequest extends GitHubPullRequestReference {\n author: string;\n /** GitHub account type of the author, e.g. \"User\" or \"Bot\", when reported. */\n authorType?: string;\n state: \"open\" | \"closed\";\n /** Whether GitHub currently treats the open pull request as a draft. */\n draft: boolean;\n /** Whether a closed pull request was merged. */\n merged: boolean;\n /** GitHub actor that merged the pull request, when reported. */\n mergedBy?: string;\n /** Merge commit recorded by GitHub, when reported. */\n mergeCommitSha?: string;\n}\n\n/** GitHub review action submitted with a pull-request review. */\nexport type PullRequestReviewEvent = \"APPROVE\" | \"REQUEST_CHANGES\" | \"COMMENT\";\n\n/** One inline finding attached to a submitted pull-request review. */\nexport interface PullRequestReviewComment {\n path: string;\n startLine?: number;\n line: number;\n body: string;\n}\n\n/** Commit-fenced summary and inline findings submitted as one review. */\nexport interface SubmitPullRequestReviewInput extends GitHubPullRequestTarget {\n commitId: string;\n event: PullRequestReviewEvent;\n body: string;\n comments?: readonly PullRequestReviewComment[];\n}\n\n/** Provider identity and state returned for a submitted pull-request review. */\nexport interface SubmittedPullRequestReview {\n id: number;\n url: string;\n state: string;\n}\n\n/** Issue-style PR comment, with null author metadata when GitHub no longer exposes it. */\nexport interface GitHubIssueComment {\n id: number;\n body: string;\n url: string;\n author: string | null;\n authorType: \"Bot\" | \"User\" | \"Organization\" | null;\n}\n\n/** Inline discussion entry with its review and source location, including replies. */\nexport interface GitHubPullRequestDiscussionComment extends GitHubReviewComment {\n path: string;\n line: number | null;\n}\n\n/** Existing PR verdict, retaining null author or commit metadata when unavailable on GitHub. */\nexport interface GitHubPullRequestDiscussionReview extends SubmittedPullRequestReview {\n author: string | null;\n body: string;\n commitId: string | null;\n}\n\n/** One bounded page of untrusted PR conversation, inline comments, and prior verdicts. */\nexport interface GitHubPullRequestDiscussionPage {\n comments: readonly GitHubIssueComment[];\n reviewComments: readonly GitHubPullRequestDiscussionComment[];\n reviews: readonly GitHubPullRequestDiscussionReview[];\n nextPage: number | null;\n}\n\n/** Pull request and one-based discussion page to read; each collection returns up to 50 entries. */\nexport interface ListPullRequestDiscussionInput extends GitHubPullRequestTarget {\n page?: number;\n}\n\n/** Repository and pull request whose issue-style comments should be listed. */\nexport type ListPullRequestCommentsInput = GitHubPullRequestTarget;\n\n/** Pull-request conversation and body for a new issue-style comment. */\nexport interface CreatePullRequestCommentInput extends ListPullRequestCommentsInput {\n body: string;\n}\n\n/** Existing issue-style comment and replacement body to persist. */\nexport interface UpdatePullRequestCommentInput extends GitHubRepositoryRequest {\n commentId: number;\n body: string;\n}\n\n/** Pull request and label targeted by a metadata-only label operation. */\nexport interface PullRequestLabelInput extends GitHubPullRequestTarget {\n label: string;\n}\n\n/** Repository label to create when absent, retaining any existing color and description. */\nexport interface EnsureGitHubLabelInput extends GitHubRepositoryRequest {\n name: string;\n color: string;\n description: string;\n}\n\n/** Open Factory-authored pull request GitHub currently reports as conflicted. */\nexport interface ConflictedGitHubPullRequest extends GitHubPullRequestReference {\n headBranch: string;\n headSha: string;\n baseBranch: string;\n baseSha: string;\n}\n\n/** Repository scope used to discover conflicted Factory-authored pull requests. */\nexport type ListConflictedPullRequestsInput = GitHubRepositoryRequest;\n\n/** Repository scope used to enumerate open pull requests. */\nexport type ListOpenPullRequestsInput = GitHubRepositoryRequest;\n\n/** Nonterminal lifecycle states Factory may write to a GitHub check run. */\nexport type CheckRunProgressStatus = \"queued\" | \"in_progress\";\n/** Lifecycle states GitHub may report when observing a check run. */\nexport type ObservedCheckRunStatus =\n | CheckRunProgressStatus\n | \"completed\"\n | \"waiting\"\n | \"requested\"\n | \"pending\";\n/** Terminal result GitHub records for a completed check run. */\nexport type CheckRunConclusion =\n | \"action_required\"\n | \"cancelled\"\n | \"failure\"\n | \"neutral\"\n | \"skipped\"\n | \"success\"\n | \"timed_out\";\n/** Severity GitHub displays for a check-run annotation. */\nexport type CheckRunAnnotationLevel = \"notice\" | \"warning\" | \"failure\";\n\n/** One source location and message rendered in a check run. */\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\n/** Human-readable summary and optional annotations attached to a check run. */\nexport interface CheckRunOutput {\n title: string;\n summary: string;\n text?: string;\n annotations?: readonly CheckRunAnnotation[];\n}\n\ninterface CheckRunPresentationFields {\n detailsUrl?: string;\n externalId?: string;\n startedAt?: string;\n output?: CheckRunOutput;\n}\n\n/** Writable fields for a queued, running, or presentation-only check-run update. */\nexport interface IncompleteCheckRunFields extends CheckRunPresentationFields {\n status?: CheckRunProgressStatus;\n conclusion?: never;\n completedAt?: never;\n}\n\n/** Writable fields for a terminal check run, which always requires its conclusion. */\nexport interface CompletedCheckRunFields extends CheckRunPresentationFields {\n status: \"completed\";\n conclusion: CheckRunConclusion;\n completedAt?: string;\n}\n\n/** Lifecycle-correlated fields accepted when creating or updating a check run. */\nexport type CheckRunFields = IncompleteCheckRunFields | CompletedCheckRunFields;\n\n/** Commit identity and presentation fields for a new check run. */\nexport type CreateCheckRunInput = GitHubRepositoryRequest &\n CheckRunFields & {\n name: string;\n headSha: string;\n };\n\n/** Check-run identity and fields to update on GitHub. */\nexport type UpdateCheckRunInput = GitHubRepositoryRequest &\n CheckRunFields & {\n checkRunId: number;\n name?: string;\n };\n\n/** Git reference and optional name filter used to discover existing check runs. */\nexport interface ListCheckRunsForRefInput extends GitHubRepositoryRequest {\n ref: string;\n checkName?: string;\n}\n\n/** Normalized identity, lifecycle, and links for a GitHub check run. */\nexport interface GitHubCheckRun {\n id: number;\n name: string;\n headSha: string;\n status: ObservedCheckRunStatus;\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 readablePullRequestSchema = pullRequestSchema.extend({\n state: z.enum([\"open\", \"closed\"]),\n draft: z.boolean().default(false),\n merged: z.boolean().default(false),\n merged_by: z\n .object({ login: z.string().min(1) })\n .nullable()\n .optional(),\n merge_commit_sha: z\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .nullable()\n .optional(),\n user: z.object({ login: z.string().min(1), type: z.string().optional() }),\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: gitHubRepositorySlugSchema }),\n }),\n});\n\nconst reviewCommentSchema = z.object({\n id: z.number().int().positive(),\n body: z.string(),\n html_url: z.url(),\n pull_request_url: z.url(),\n user: z.object({ login: z.string().min(1), type: z.string().optional() }).nullable(),\n in_reply_to_id: z.number().int().positive().nullish(),\n pull_request_review_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\n .object({\n login: z.string().min(1),\n type: z.enum([\"Bot\", \"User\", \"Organization\"]),\n })\n .nullable(),\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({\n ref: z.string().min(1),\n repo: z.object({ full_name: gitHubRepositorySlugSchema }),\n }),\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 openPullRequestSummarySchema = z.object({\n number: z.number().int().positive(),\n html_url: z.url(),\n title: z.string().min(1),\n user: z.object({ login: z.string().min(1) }),\n head: z.object({ ref: z.string().min(1) }),\n draft: z.boolean(),\n});\nconst collaboratorPermissionSchema = z.object({\n permission: z.enum([\"admin\", \"maintain\", \"write\", \"triage\", \"read\", \"none\"]),\n});\nconst writePermissions = new Set([\"admin\", \"maintain\", \"write\"]);\n\n/** Refusal raised when an inline review-comment author lacks repository write access. */\nexport class GitHubReviewCommentAuthorError extends Error {\n readonly author: string | null;\n\n constructor(author: string | null) {\n super(\n author === null\n ? \"GitHub review comment has no author to verify for repository write access\"\n : `GitHub user ${author} does not have write access to the repository`,\n );\n this.name = \"GitHubReviewCommentAuthorError\";\n this.author = author;\n }\n}\n\n/**\n * The pull request advanced past the commit a review or fix was prepared\n * against. Callers that reviewed a task keyed to a specific commit (for\n * example `record_post_review`) can use `expectedSha`/`actualSha` to resolve\n * the task as superseded instead of leaving it running for the stall\n * watchdog to eventually -- and misleadingly -- report as \"stalled\".\n */\nexport class StalePullRequestHeadError extends Error {\n readonly expectedSha: string;\n readonly actualSha: string;\n\n constructor(expectedSha: string, actualSha: string) {\n super(`pull request changed after review: expected ${expectedSha}, found ${actualSha}`);\n this.name = \"StalePullRequestHeadError\";\n this.expectedSha = expectedSha;\n this.actualSha = actualSha;\n }\n}\n\n/** Whether a GitHub user may make repository-scoped Factory decisions. */\nexport async function hasGitHubRepositoryWriteAccess(\n input: GitHubRepositoryAuthorRequest,\n): Promise<boolean> {\n const { permission } = collaboratorPermissionSchema.parse(\n await gitHubRequest(input, `/collaborators/${encodeURIComponent(input.author)}/permission`),\n );\n return writePermissions.has(permission);\n}\n\n/** Create a pull request from an existing head branch. */\nexport async function createPullRequest(\n input: CreatePullRequestInput,\n): Promise<CreatedGitHubPullRequest> {\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 { pullRequestNumber: pull.number, pullRequestUrl: 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 assertCheckRunFields(input);\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 assertCheckRunFields(input);\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(\n input: ListCheckRunsForRefInput,\n): Promise<readonly 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(\n input,\n `/commits/${encodeURIComponent(input.ref)}/check-runs?${query.toString()}`,\n ),\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<readonly GitHubIssueComment[]> {\n const comments: GitHubIssueComment[] = [];\n for (let page = 1; ; page += 1) {\n const response = z\n .array(issueCommentSchema)\n .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/** Read a page of all PR discussion types without treating any author's text as authorization. */\nexport async function listPullRequestDiscussion(\n input: ListPullRequestDiscussionInput,\n): Promise<GitHubPullRequestDiscussionPage> {\n const page = z\n .number()\n .int()\n .positive()\n .parse(input.page ?? 1);\n const number = positiveInteger(input.pullRequestNumber, \"pullRequestNumber\");\n const query = `per_page=50&page=${page}`;\n const [comments, reviewComments, reviews] = await Promise.all([\n gitHubRequest(input, `/issues/${number}/comments?${query}`).then((value) =>\n z.array(issueCommentSchema).max(50).parse(value).map(parseIssueComment),\n ),\n gitHubRequest(input, `/pulls/${number}/comments?${query}`).then((value) =>\n z\n .array(\n reviewCommentSchema.extend({\n pull_request_review_id: z.number().int().positive().nullable(),\n path: z.string().min(1),\n line: z.number().int().positive().nullish(),\n }),\n )\n .max(50)\n .parse(value)\n .map((entry) => {\n const comment = parseReviewComment(entry);\n assertReviewCommentPullRequest(input, comment);\n return {\n ...comment,\n reviewId: entry.pull_request_review_id,\n path: entry.path,\n line: entry.line ?? null,\n };\n }),\n ),\n gitHubRequest(input, `/pulls/${number}/reviews?${query}`).then((value) =>\n z\n .array(\n submittedReviewSchema.extend({\n user: z.object({ login: z.string().min(1) }).nullable(),\n body: z.string(),\n commit_id: z\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .nullable(),\n }),\n )\n .max(50)\n .parse(value)\n .map((review) => ({\n id: review.id,\n url: review.html_url,\n state: review.state,\n author: review.user?.login ?? null,\n body: review.body,\n commitId: review.commit_id,\n })),\n ),\n ]);\n return {\n comments,\n reviewComments,\n reviews,\n nextPage: [comments, reviewComments, reviews].some((entries) => entries.length === 50)\n ? page + 1\n : null,\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(\n input,\n `/issues/comments/${positiveInteger(input.commentId, \"commentId\")}`,\n {\n method: \"PATCH\",\n body: JSON.stringify({ body: input.body }),\n },\n ),\n );\n}\n\nconst readIssueCommentSchema = issueCommentSchema.extend({\n issue_url: z.string().min(1),\n});\n\n/** One issue comment as GitHub reports it, with the issue it belongs to. */\nexport interface GitHubIssueCommentRecord extends GitHubIssueComment {\n issueNumber: number;\n}\n\n/**\n * Read one issue comment from GitHub. A delivery authenticated as a workload\n * rather than by body signature can name any author and any text, so the\n * comment it refers to has to be read back before either is believed.\n */\nexport async function readIssueComment(\n input: GitHubRepositoryRequest & { commentId: number },\n): Promise<GitHubIssueCommentRecord> {\n const comment = readIssueCommentSchema.parse(\n await gitHubRequest(input, `/issues/comments/${positiveInteger(input.commentId, \"commentId\")}`),\n );\n const issueNumber = Number(comment.issue_url.split(\"/\").pop());\n if (!Number.isSafeInteger(issueNumber) || issueNumber < 1) {\n throw new Error(\"GitHub returned an issue comment without a usable issue reference.\");\n }\n return {\n id: comment.id,\n url: comment.html_url,\n author: comment.user?.login ?? null,\n authorType: comment.user?.type ?? null,\n body: comment.body,\n issueNumber,\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 assertReviewCommentPullRequest(input, comment);\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 const comment = await readReviewComment(input);\n const rootId = comment.inReplyToId ?? comment.id;\n if (rootId !== comment.id) {\n await readReviewComment({ ...input, commentId: rootId, authorPolicy: \"any\" });\n }\n const reply = parseReviewComment(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/comments/${positiveInteger(rootId, \"commentId\")}/replies`,\n { method: \"POST\", body: JSON.stringify({ body: input.body }) },\n ),\n );\n assertReviewCommentPullRequest(input, reply);\n return reply;\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\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .parse(input.commitId);\n const comments = (input.comments ?? []).map((comment) => {\n const line = positiveInteger(comment.line, \"comment line\");\n const startLine =\n comment.startLine === undefined\n ? undefined\n : positiveInteger(comment.startLine, \"comment startLine\");\n if (startLine !== undefined && startLine >= line) {\n throw new Error(\"comment startLine must precede line; omit it for a single-line finding\");\n }\n return {\n path: comment.path,\n line,\n side: \"RIGHT\",\n ...(startLine === undefined ? {} : { start_line: startLine, start_side: \"RIGHT\" }),\n body: comment.body,\n };\n });\n const head = await readPullRequestHead(input);\n if (head.sha !== commitId) {\n throw new StalePullRequestHeadError(commitId, 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,\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: GitHubPullRequestTarget,\n): Promise<GitHubPullRequestHead> {\n const pull = pullRequestHeadSchema.parse(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}`,\n ),\n );\n return {\n branch: pull.head.ref,\n sha: pull.head.sha,\n repository: pull.head.repo.full_name,\n };\n}\n\n/** Read the provider-owned identity and lifecycle of one pull request. */\nexport async function readPullRequest(input: GitHubPullRequestTarget): Promise<GitHubPullRequest> {\n const pull = readablePullRequestSchema.parse(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}`,\n ),\n );\n return {\n pullRequestNumber: pull.number,\n pullRequestUrl: pull.html_url,\n author: pull.user.login,\n authorType: pull.user.type,\n state: pull.state,\n draft: pull.draft,\n merged: pull.merged,\n ...(pull.merged_by ? { mergedBy: pull.merged_by.login } : {}),\n ...(pull.merge_commit_sha ? { mergeCommitSha: pull.merge_commit_sha } : {}),\n };\n}\n\n/** Close an open pull request without merging it. */\nexport async function closePullRequest(input: GitHubPullRequestTarget): Promise<GitHubPullRequest> {\n const pull = readablePullRequestSchema.parse(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}`,\n { method: \"PATCH\", body: JSON.stringify({ state: \"closed\" }) },\n ),\n );\n return {\n pullRequestNumber: pull.number,\n pullRequestUrl: pull.html_url,\n author: pull.user.login,\n authorType: pull.user.type,\n state: pull.state,\n draft: pull.draft,\n merged: pull.merged,\n ...(pull.merged_by ? { mergedBy: pull.merged_by.login } : {}),\n ...(pull.merge_commit_sha ? { mergeCommitSha: pull.merge_commit_sha } : {}),\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<readonly ConflictedGitHubPullRequest[]> {\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: ConflictedGitHubPullRequest[] = [];\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 pullRequestNumber: pull.number,\n pullRequestUrl: 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/** List all open PRs newest first; fail rather than return a partial inventory at the ten-page bound. */\nexport async function listOpenPullRequests(\n input: ListOpenPullRequestsInput,\n): Promise<readonly OpenPullRequest[]> {\n const pulls = new Map<number, OpenPullRequest>();\n for (let page = 1; page <= 10; page++) {\n const batch = z\n .array(openPullRequestSummarySchema)\n .parse(\n await gitHubRequest(\n input,\n `/pulls?state=open&per_page=100&sort=created&direction=desc&page=${page}`,\n ),\n );\n for (const pull of batch)\n pulls.set(pull.number, {\n prNumber: pull.number,\n prUrl: pull.html_url,\n title: pull.title,\n author: pull.user.login,\n headBranch: pull.head.ref,\n draft: pull.draft,\n });\n if (batch.length < 100) return [...pulls.values()];\n }\n throw new Error(\n \"Open pull request lookup is incomplete after ten pages; do not conclude that no duplicate exists. Inspect targeted repository work before admitting a new change.\",\n );\n}\n\n/** Ensure a repository label exists, including when another publisher creates it concurrently. */\nexport async function ensureGitHubLabel(input: EnsureGitHubLabelInput): Promise<void> {\n const label = z\n .object({\n name: z.string().trim().min(1).max(50),\n color: z.string().regex(/^[a-fA-F0-9]{6}$/u),\n description: z.string().max(100),\n })\n .parse(input);\n const path = `/labels/${encodeURIComponent(label.name)}`;\n const read = async () => {\n const existing = z.object({ name: z.string() }).parse(await gitHubRequest(input, path));\n if (existing.name.toLowerCase() !== label.name.toLowerCase())\n throw new Error(\"GitHub returned a different repository label\");\n };\n try {\n await read();\n return;\n } catch (error) {\n if (!(error instanceof GitHubRequestError) || error.status !== 404) throw error;\n }\n try {\n await gitHubRequest(input, \"/labels\", { method: \"POST\", body: JSON.stringify(label) });\n } catch (error) {\n if (!(error instanceof GitHubRequestError) || error.status !== 422) throw error;\n // GitHub uses 422 for both a concurrent creation and unrelated validation failures.\n await read();\n }\n}\n\n/** Add one label to a pull request. */\nexport async function addLabel(input: PullRequestLabelInput): Promise<readonly 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<readonly 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\nclass GitHubRequestError extends Error {\n constructor(\n readonly status: number,\n message: string,\n ) {\n super(`GitHub API request failed (${status}): ${message}`);\n }\n}\n\nasync function gitHubRequest(\n input: GitHubRepositoryRequest,\n path: string,\n init: RequestInit = {},\n): Promise<unknown> {\n const repository = repositorySlugSchema.parse(input.repository);\n const response = await (input.fetch ?? globalThis.fetch)(\n `${gitHubApiUrl}/repos/${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 GitHubRequestError(\n response.status,\n 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 const pullRequestMatch = /\\/pulls\\/([1-9]\\d*)\\/?$/.exec(\n new URL(comment.pull_request_url).pathname,\n );\n if (pullRequestMatch?.[1] === undefined) {\n throw new Error(\"GitHub review comment has an invalid pull request URL\");\n }\n return {\n id: comment.id,\n pullRequestNumber: positiveInteger(Number(pullRequestMatch[1]), \"pullRequestNumber\"),\n body: comment.body,\n url: comment.html_url,\n author: comment.user?.login ?? null,\n authorType: comment.user?.type ?? null,\n inReplyToId: comment.in_reply_to_id ?? null,\n reviewId: comment.pull_request_review_id ?? null,\n };\n}\n\nfunction assertReviewCommentPullRequest(\n input: GitHubPullRequestTarget,\n comment: GitHubReviewComment,\n): void {\n const expected = positiveInteger(input.pullRequestNumber, \"pullRequestNumber\");\n if (comment.pullRequestNumber !== expected) {\n throw new Error(\n `GitHub review comment ${comment.id} does not belong to pull request ${expected}`,\n );\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 ?? null,\n authorType: comment.user?.type ?? 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 assertCheckRunFields(input: CheckRunFields): void {\n if (input.status === \"completed\") {\n if (input.conclusion === undefined) {\n throw new Error(\"completed check runs require a conclusion\");\n }\n return;\n }\n if (input.conclusion !== undefined) {\n throw new Error(\"a check run conclusion requires completed status\");\n }\n if (input.completedAt !== undefined) {\n throw new Error(\"a check run completion time requires completed status\");\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(\n annotation.endLine ?? annotation.startLine,\n \"annotation endLine\",\n ),\n ...(annotation.startColumn === undefined\n ? {}\n : {\n start_column: positiveInteger(annotation.startColumn, \"annotation startColumn\"),\n }),\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 | null,\n): Promise<void> {\n if (input.authorPolicy === \"any\") {\n return;\n }\n if (author === null || !(await hasGitHubRepositoryWriteAccess({ ...input, author }))) {\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\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .parse(value);\n}\n\n/** Raw payload, shared secret, and provider signature used for webhook verification. */\nexport interface VerifyGitHubSignatureInput {\n secret: string;\n payload: string;\n signature: string | null;\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: VerifyGitHubSignatureInput): 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: gitHubRepositorySlugSchema,\n }),\n});\n\n/** Normalized observation that a repository's configured default branch advanced. */\nexport interface GitHubDefaultBranchPush {\n source: \"github_default_branch_push\";\n deliveryId: string;\n repositorySlug: RepositorySlug;\n defaultBranch: string;\n}\n\n/** Normalize a push to a repository's default branch for deterministic reconciliation. */\nexport function normalizeGitHubDefaultBranchPush(\n options: WebhookEvent,\n): GitHubDefaultBranchPush | null {\n if (options.event !== \"push\") return null;\n const parsed = pushEventSchema.safeParse(options.payload);\n if (\n !parsed.success ||\n parsed.data.ref !== `refs/heads/${parsed.data.repository.default_branch}`\n ) {\n return null;\n }\n return {\n source: \"github_default_branch_push\",\n deliveryId: options.deliveryId,\n repositorySlug: parsed.data.repository.full_name,\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: gitHubRepositorySlugSchema }),\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: gitHubRepositorySlugSchema }),\n sender: z.looseObject({ login: z.string().min(1) }),\n});\n\nconst reviewablePullRequestActions = new Set([\n \"opened\",\n \"reopened\",\n \"ready_for_review\",\n \"synchronize\",\n]);\n\n/** Reviewable pull-request webhook normalized for Factory intake. */\nexport interface GitHubPullRequestSignal extends NormalizedSignal<\"github_pr\"> {\n repositorySlug: RepositorySlug;\n pullRequest: {\n pullRequestNumber: number;\n pullRequestUrl: string;\n author: string;\n draft: boolean;\n headSha: string;\n headBranch: string;\n headRepositorySlug: RepositorySlug;\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;\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 pullRequestNumber: parsed.data.number,\n pullRequestUrl: 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,\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: gitHubRepositorySlugSchema,\n }),\n});\n\n/** Opened GitHub issue normalized for Factory intake. */\nexport interface GitHubIssueSignal extends NormalizedSignal<\"github_issue\"> {\n repositorySlug: RepositorySlug;\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: gitHubRepositorySlugSchema,\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: gitHubRepositorySlugSchema,\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\n/** Unsuccessful GitHub Actions run normalized for Factory intake. */\nexport interface GitHubCiFailureSignal extends NormalizedSignal<\"github_ci_failure\"> {\n repositoryDefaultBranch: string;\n repositorySlug: RepositorySlug;\n workflowRun: {\n id: number;\n name: string;\n trigger: string;\n branch: string | null;\n headRepositorySlug: RepositorySlug | 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;\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\n .looseObject({ login: z.string().min(1) })\n .nullable()\n .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: gitHubRepositorySlugSchema,\n }),\n sender: z.looseObject({ login: z.string().min(1) }),\n});\n\n/** Normalized provider observation that a pull request was merged or closed. */\nexport interface GitHubPullRequestClosed extends GitHubPullRequestReference {\n source: \"github_pull_request_closed\";\n deliveryId: string;\n repositorySlug: RepositorySlug;\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,\n pullRequestNumber: pr.number,\n pullRequestUrl: 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;\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 ?? 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":";;;;;;AAkEA,MAAM,eAAe;AACrB,MAAM,6BAA6B,EAChC,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,WAAW,UAAU,MAAM,YAAY,CAAC,CAAC,CACzC,KAAK,oBAAoB;AAE5B,MAAM,kCAAkC,EAAE,YAAY;CACpD,QAAQ,EAAE,QAAQ,SAAS;CAC3B,SAAS,EAAE,YAAY;EACrB,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;EAC9B,MAAM,EAAE,OAAO;EACf,UAAU,EAAE,IAAI;EAChB,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ;CACtD,CAAC;CACD,cAAc,EAAE,YAAY;EAC1B,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;EAClC,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;CAClD,CAAC;CACD,YAAY,EAAE,YAAY,EAAE,WAAW,2BAA2B,CAAC;AACrE,CAAC;AAED,MAAM,kCAAkC,EAAE,YAAY;CACpD,QAAQ,EAAE,QAAQ,SAAS;CAC3B,SAAS,EAAE,YAAY;EACrB,MAAM,EAAE,OAAO;EACf,UAAU,EAAE,IAAI;EAChB,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CAChC,CAA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AClC,OAAO;EACL,QAAQ;EACR,YAAY,QAAQ;EACpB,gBAAgB,OAAO,KAAK,WAAW;EACvC,mBAAmB,GAAG;EACtB,gBAAgB,GAAG;EACnB,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;CACpC,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,aAAa;GACtD,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\";\nimport type { OpenPullRequest } from \"./pull-requests/contracts\";\nimport { repositorySlugSchema, type RepositorySlug } from \"./schema/repository\";\n\nexport {\n mintGitHubAppInstallationToken,\n type GitHubAppFactoryInput,\n type GitHubAppInstallationToken,\n type GitHubAppLike,\n type GitHubAppPermissions,\n type MintGitHubAppInstallationTokenInput,\n} from \"./github-app\";\nexport {\n checkoutGitHubRepository,\n createGitHubPublicationClient,\n factorySessionBranch,\n factoryTaskBranch,\n GitHubCheckoutConflictError,\n GitHubPublicationApiError,\n isSafeGitRef,\n readCommittedGitChange,\n runSandboxGit,\n type CheckoutGitHubRepositoryInput,\n type CommittedGitChange,\n type CreatedGitHubPublicationPullRequest,\n type CreateGitHubBranchInput,\n type CreateGitHubCommitInput,\n type CreateGitHubPublicationPullRequestInput,\n type CreateGitHubTreeInput,\n type GitHubCommit,\n type GitHubPublicationClient,\n type GitHubPublicationClientOptions,\n type GitHubPublicationLimits,\n type GitHubPublicationPullRequest,\n type GitHubTreeDeletion,\n type GitHubTreeEntry,\n type GitHubTreeUpsert,\n type MarkGitHubPullRequestReadyInput,\n type ListGitHubPublicationPullRequestsInput,\n type ReadCommittedGitChangeInput,\n type ReadGitHubBranchHeadInput,\n type ReadGitHubCommitInput,\n type ReadGitHubPullRequestInput,\n type RunSandboxGitInput,\n type SandboxGit,\n type SandboxGitCommandInput,\n type SandboxGitCommandResult,\n type UpdateGitHubBranchInput,\n} from \"./github-publication\";\n\nexport type {\n FetchGitHubBundleInput,\n FetchGitHubRefsInput,\n GitHubGitTransport,\n GitHubRefMapping,\n GitHubRepositoryBundle,\n GitTransferSandbox,\n ReadGitTransferFileInput,\n PushGitHubBundleInput,\n PushGitHubHeadInput,\n WithSandboxGitBundleInput,\n WriteGitTransferFileInput,\n} from \"./github-transfer\";\n\nconst gitHubApiUrl = \"https://api.github.com\";\nconst gitHubRepositorySlugSchema = z\n .string()\n .min(1)\n .transform((value) => value.toLowerCase())\n .pipe(repositorySlugSchema);\n\nconst factoryReviewCommentEventSchema = z.looseObject({\n action: z.literal(\"created\"),\n comment: z.looseObject({\n id: z.number().int().positive(),\n body: z.string(),\n html_url: z.url(),\n in_reply_to_id: z.number().int().positive().nullish(),\n }),\n pull_request: z.looseObject({\n number: z.number().int().positive(),\n html_url: z.url(),\n user: z.looseObject({ login: z.string().min(1) }),\n }),\n repository: z.looseObject({ full_name: gitHubRepositorySlugSchema }),\n});\n\nconst factoryQuestionReplyEventSchema = z.looseObject({\n action: z.literal(\"created\"),\n comment: z.looseObject({\n body: z.string(),\n html_url: z.url(),\n id: z.number().int().positive(),\n }),\n issue: z.looseObject({\n number: z.number().int().positive(),\n pull_request: z.unknown().optional(),\n }),\n repository: z.looseObject({ full_name: gitHubRepositorySlugSchema }),\n sender: z.looseObject({ login: z.string().min(1), type: z.string().min(1) }),\n});\n\nconst defaultReviewMentions = [\"factory\"] as const;\nconst defaultQuestionMentions = [\"agent-factory\", \"agent-factory[bot]\", \"factory\"] as const;\n\n/** Custom mention names accepted by Factory's GitHub comment normalizers. */\nexport interface FactoryMentionOptions {\n mentions?: readonly string[];\n}\n\n/** Provider event and optional mentions accepted by Factory comment normalizers. */\nexport interface NormalizeFactoryCommentInput extends FactoryMentionOptions {\n event: string;\n payload: unknown;\n}\n\n/** Select addressed comments and optionally reply candidates whose ownership the caller must verify. */\nexport interface NormalizeFactoryReviewCommentInput extends NormalizeFactoryCommentInput {\n includeReplies?: boolean;\n}\n\n/** Configured repositories and provider observations used to select one trusted repository. */\nexport interface ConfiguredEventRepositoryInput {\n configuredSlugs: readonly RepositorySlug[];\n eventSlugs: readonly (RepositorySlug | null)[];\n}\n\nfunction stripMention(body: string, mentions: readonly string[]): string | null {\n const trimmed = body.trimStart();\n for (const mention of mentions) {\n const prefix = `@${mention.trim()}`;\n if (prefix === \"@\" || trimmed.slice(0, prefix.length).toLowerCase() !== prefix.toLowerCase()) {\n continue;\n }\n const remainder = trimmed.slice(prefix.length);\n if (!/^[\\s,:-]/u.test(remainder)) continue;\n return remainder.replace(/^[\\s,:-]*/u, \"\").trim();\n }\n return null;\n}\n\n/** Routing metadata extracted from an addressed inline comment or an opt-in reply candidate. */\nexport interface FactoryReviewComment {\n repositorySlug: RepositorySlug;\n pullRequestNumber: number;\n pullRequestUrl: string;\n pullRequestAuthor: string;\n commentId: number;\n commentUrl: string;\n}\n\n/** Human answer extracted from a mentioned GitHub issue comment. */\nexport interface FactoryQuestionReply {\n repositorySlug: RepositorySlug;\n replyAddress: string;\n author: string;\n answer: string;\n commentId: number;\n issueNumber: number;\n commentUrl: string;\n}\n\n/** Select the one configured repository consistently identified by a provider delivery. */\nexport function configuredEventRepositorySlug(\n input: ConfiguredEventRepositoryInput,\n): RepositorySlug | null {\n const { configuredSlugs, eventSlugs } = input;\n const distinctEventSlugs = [\n ...new Set(eventSlugs.filter((slug): slug is RepositorySlug => slug !== null)),\n ];\n const eventSlug = distinctEventSlugs[0];\n return distinctEventSlugs.length === 1 &&\n eventSlug !== undefined &&\n configuredSlugs.includes(eventSlug)\n ? eventSlug\n : null;\n}\n\n/** Normalize addressed inline comments or opt-in reply candidates; callers must authenticate them. */\nexport function normalizeFactoryReviewComment(\n input: NormalizeFactoryReviewCommentInput,\n): FactoryReviewComment | null {\n if (input.event !== \"pull_request_review_comment\") return null;\n const parsed = factoryReviewCommentEventSchema.safeParse(input.payload);\n if (\n !parsed.success ||\n (stripMention(parsed.data.comment.body, input.mentions ?? defaultReviewMentions) === null &&\n !(input.includeReplies && parsed.data.comment.in_reply_to_id != null))\n ) {\n return null;\n }\n return {\n repositorySlug: parsed.data.repository.full_name,\n pullRequestNumber: parsed.data.pull_request.number,\n pullRequestUrl: parsed.data.pull_request.html_url,\n pullRequestAuthor: parsed.data.pull_request.user.login,\n commentId: parsed.data.comment.id,\n commentUrl: parsed.data.comment.html_url,\n };\n}\n\n/**\n * Strip the Factory mention from an issue comment body, returning null when the\n * comment does not address Factory. Exported so a caller reconciling a delivery\n * against GitHub's own copy of the comment applies the same rule the normalizer\n * applied to the payload.\n */\nexport function stripFactoryQuestionMention(\n body: string,\n options: FactoryMentionOptions = {},\n): string | null {\n return stripMention(body, options.mentions ?? defaultQuestionMentions);\n}\n\n/** Normalize a mentioned issue comment that can answer a persisted Factory QuestionTask. */\nexport function normalizeFactoryQuestionReply(\n input: NormalizeFactoryCommentInput,\n): FactoryQuestionReply | null {\n if (input.event !== \"issue_comment\") return null;\n const parsed = factoryQuestionReplyEventSchema.safeParse(input.payload);\n if (!parsed.success || parsed.data.sender.type.toLowerCase() === \"bot\") return null;\n const answer = stripMention(parsed.data.comment.body, input.mentions ?? defaultQuestionMentions);\n if (answer === null || answer === \"\") return null;\n if (parsed.data.issue.pull_request !== undefined) return null;\n const repositorySlug = parsed.data.repository.full_name;\n return {\n repositorySlug,\n replyAddress: `${repositorySlug}#${parsed.data.issue.number}`,\n author: parsed.data.sender.login,\n answer,\n commentId: parsed.data.comment.id,\n issueNumber: parsed.data.issue.number,\n commentUrl: parsed.data.comment.html_url,\n };\n}\n\n/** Credentials and transport for a repository-scoped GitHub REST request. */\nexport interface GitHubRepositoryRequest {\n repository: RepositorySlug;\n token: string;\n fetch?: typeof globalThis.fetch;\n}\n\n/** Repository-scoped identity of one pull request accepted by GitHub operations. */\nexport interface GitHubPullRequestTarget extends GitHubRepositoryRequest {\n pullRequestNumber: number;\n}\n\n/** Repository-scoped identity of one GitHub issue. */\nexport interface GitHubIssueTarget extends GitHubRepositoryRequest {\n issueNumber: number;\n}\n\n/** Provider-owned number and URL that identify one GitHub pull request. */\nexport interface GitHubPullRequestReference {\n pullRequestNumber: number;\n pullRequestUrl: string;\n}\n\n/** Repository request that identifies the GitHub actor whose access must be checked. */\nexport interface GitHubRepositoryAuthorRequest extends GitHubRepositoryRequest {\n author: string;\n}\n\n/** Repository-scoped fields required to open a pull request from an existing branch. */\nexport interface CreatePullRequestInput extends GitHubRepositoryRequest {\n title: string;\n head: string;\n base: string;\n body?: string;\n draft?: boolean;\n}\n\n/** Provider identity returned after GitHub creates a pull request. */\nexport type CreatedGitHubPullRequest = GitHubPullRequestReference;\n\n/** Trust threshold applied before Factory consumes an inline review comment. */\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\n/** Pull request, comment identity, and author policy used to read an inline review comment. */\nexport interface ReadReviewCommentInput extends GitHubPullRequestTarget, ReviewCommentTrustInput {\n commentId: number;\n}\n\n/** Normalized inline review comment, with a null author when GitHub no longer exposes it. */\nexport interface GitHubReviewComment {\n id: number;\n pullRequestNumber: number;\n body: string;\n url: string;\n author: string | null;\n /** GitHub account type when available, used to distinguish human requests from bot activity. */\n authorType: string | null;\n inReplyToId: number | null;\n reviewId: number | null;\n}\n\n/** Trusted inline comment and reply content used to post a threaded answer. */\nexport interface AnswerReviewCommentInput extends GitHubPullRequestTarget, ReviewCommentTrustInput {\n commentId: number;\n body: string;\n}\n\n/** Current branch, commit, and source repository of a pull request head. */\nexport interface GitHubPullRequestHead {\n branch: string;\n sha: string;\n repository: RepositorySlug;\n}\n\n/** Provider-owned identity, author, and lifecycle state of a pull request. */\nexport interface GitHubPullRequest extends GitHubPullRequestReference {\n author: string;\n /** GitHub account type of the author, e.g. \"User\" or \"Bot\", when reported. */\n authorType?: string;\n state: \"open\" | \"closed\";\n /** Whether GitHub currently treats the open pull request as a draft. */\n draft: boolean;\n /** Whether a closed pull request was merged. */\n merged: boolean;\n /** GitHub actor that merged the pull request, when reported. */\n mergedBy?: string;\n /** Merge commit recorded by GitHub, when reported. */\n mergeCommitSha?: string;\n}\n\n/** GitHub review action submitted with a pull-request review. */\nexport type PullRequestReviewEvent = \"APPROVE\" | \"REQUEST_CHANGES\" | \"COMMENT\";\n\n/** One inline finding attached to a submitted pull-request review. */\nexport interface PullRequestReviewComment {\n path: string;\n startLine?: number;\n line: number;\n body: string;\n}\n\n/** Commit-fenced summary and inline findings submitted as one review. */\nexport interface SubmitPullRequestReviewInput extends GitHubPullRequestTarget {\n commitId: string;\n event: PullRequestReviewEvent;\n body: string;\n comments?: readonly PullRequestReviewComment[];\n}\n\n/** Provider identity and state returned for a submitted pull-request review. */\nexport interface SubmittedPullRequestReview {\n id: number;\n url: string;\n state: string;\n}\n\n/** Issue-style PR comment, with null author metadata when GitHub no longer exposes it. */\nexport interface GitHubIssueComment {\n id: number;\n body: string;\n url: string;\n author: string | null;\n authorType: \"Bot\" | \"User\" | \"Organization\" | null;\n}\n\n/** Inline discussion entry with its review and source location, including replies. */\nexport interface GitHubPullRequestDiscussionComment extends GitHubReviewComment {\n path: string;\n line: number | null;\n}\n\n/** Existing PR verdict, retaining null author or commit metadata when unavailable on GitHub. */\nexport interface GitHubPullRequestDiscussionReview extends SubmittedPullRequestReview {\n author: string | null;\n body: string;\n commitId: string | null;\n}\n\n/** One bounded page of untrusted PR conversation, inline comments, and prior verdicts. */\nexport interface GitHubPullRequestDiscussionPage {\n comments: readonly GitHubIssueComment[];\n reviewComments: readonly GitHubPullRequestDiscussionComment[];\n reviews: readonly GitHubPullRequestDiscussionReview[];\n nextPage: number | null;\n}\n\n/** Pull request and one-based discussion page to read; each collection returns up to 50 entries. */\nexport interface ListPullRequestDiscussionInput extends GitHubPullRequestTarget {\n page?: number;\n}\n\n/** Repository and pull request whose issue-style comments should be listed. */\nexport type ListPullRequestCommentsInput = GitHubPullRequestTarget;\n\n/** Pull-request conversation and body for a new issue-style comment. */\nexport interface CreatePullRequestCommentInput extends ListPullRequestCommentsInput {\n body: string;\n}\n\n/** Repository issue whose comments should be listed. */\nexport type ListIssueCommentsInput = GitHubIssueTarget;\n\n/** Repository issue and body for a new comment. */\nexport interface CreateIssueCommentInput extends GitHubIssueTarget {\n body: string;\n}\n\n/** Existing issue-style comment and replacement body to persist. */\nexport interface UpdatePullRequestCommentInput extends GitHubRepositoryRequest {\n commentId: number;\n body: string;\n}\n\n/** Pull request and label targeted by a metadata-only label operation. */\nexport interface PullRequestLabelInput extends GitHubPullRequestTarget {\n label: string;\n}\n\n/** Repository issue and label targeted by a metadata-only label operation. */\nexport interface IssueLabelInput extends GitHubIssueTarget {\n label: string;\n}\n\n/** Repository label to create when absent, retaining any existing color and description. */\nexport interface EnsureGitHubLabelInput extends GitHubRepositoryRequest {\n name: string;\n color: string;\n description: string;\n}\n\n/** Open Factory-authored pull request GitHub currently reports as conflicted. */\nexport interface ConflictedGitHubPullRequest extends GitHubPullRequestReference {\n headBranch: string;\n headSha: string;\n baseBranch: string;\n baseSha: string;\n}\n\n/** Repository scope used to discover conflicted Factory-authored pull requests. */\nexport type ListConflictedPullRequestsInput = GitHubRepositoryRequest;\n\n/** Repository scope used to enumerate open pull requests. */\nexport type ListOpenPullRequestsInput = GitHubRepositoryRequest;\n\n/** Nonterminal lifecycle states Factory may write to a GitHub check run. */\nexport type CheckRunProgressStatus = \"queued\" | \"in_progress\";\n/** Lifecycle states GitHub may report when observing a check run. */\nexport type ObservedCheckRunStatus =\n | CheckRunProgressStatus\n | \"completed\"\n | \"waiting\"\n | \"requested\"\n | \"pending\";\n/** Terminal result GitHub records for a completed check run. */\nexport type CheckRunConclusion =\n | \"action_required\"\n | \"cancelled\"\n | \"failure\"\n | \"neutral\"\n | \"skipped\"\n | \"success\"\n | \"timed_out\";\n/** Severity GitHub displays for a check-run annotation. */\nexport type CheckRunAnnotationLevel = \"notice\" | \"warning\" | \"failure\";\n\n/** One source location and message rendered in a check run. */\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\n/** Human-readable summary and optional annotations attached to a check run. */\nexport interface CheckRunOutput {\n title: string;\n summary: string;\n text?: string;\n annotations?: readonly CheckRunAnnotation[];\n}\n\ninterface CheckRunPresentationFields {\n detailsUrl?: string;\n externalId?: string;\n startedAt?: string;\n output?: CheckRunOutput;\n}\n\n/** Writable fields for a queued, running, or presentation-only check-run update. */\nexport interface IncompleteCheckRunFields extends CheckRunPresentationFields {\n status?: CheckRunProgressStatus;\n conclusion?: never;\n completedAt?: never;\n}\n\n/** Writable fields for a terminal check run, which always requires its conclusion. */\nexport interface CompletedCheckRunFields extends CheckRunPresentationFields {\n status: \"completed\";\n conclusion: CheckRunConclusion;\n completedAt?: string;\n}\n\n/** Lifecycle-correlated fields accepted when creating or updating a check run. */\nexport type CheckRunFields = IncompleteCheckRunFields | CompletedCheckRunFields;\n\n/** Commit identity and presentation fields for a new check run. */\nexport type CreateCheckRunInput = GitHubRepositoryRequest &\n CheckRunFields & {\n name: string;\n headSha: string;\n };\n\n/** Check-run identity and fields to update on GitHub. */\nexport type UpdateCheckRunInput = GitHubRepositoryRequest &\n CheckRunFields & {\n checkRunId: number;\n name?: string;\n };\n\n/** Git reference and optional name filter used to discover existing check runs. */\nexport interface ListCheckRunsForRefInput extends GitHubRepositoryRequest {\n ref: string;\n checkName?: string;\n}\n\n/** Normalized identity, lifecycle, and links for a GitHub check run. */\nexport interface GitHubCheckRun {\n id: number;\n name: string;\n headSha: string;\n status: ObservedCheckRunStatus;\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 readablePullRequestSchema = pullRequestSchema.extend({\n state: z.enum([\"open\", \"closed\"]),\n draft: z.boolean().default(false),\n merged: z.boolean().default(false),\n merged_by: z\n .object({ login: z.string().min(1) })\n .nullable()\n .optional(),\n merge_commit_sha: z\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .nullable()\n .optional(),\n user: z.object({ login: z.string().min(1), type: z.string().optional() }),\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: gitHubRepositorySlugSchema }),\n }),\n});\n\nconst reviewCommentSchema = z.object({\n id: z.number().int().positive(),\n body: z.string(),\n html_url: z.url(),\n pull_request_url: z.url(),\n user: z.object({ login: z.string().min(1), type: z.string().optional() }).nullable(),\n in_reply_to_id: z.number().int().positive().nullish(),\n pull_request_review_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\n .object({\n login: z.string().min(1),\n type: z.enum([\"Bot\", \"User\", \"Organization\"]),\n })\n .nullable(),\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({\n ref: z.string().min(1),\n repo: z.object({ full_name: gitHubRepositorySlugSchema }),\n }),\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 openPullRequestSummarySchema = z.object({\n number: z.number().int().positive(),\n html_url: z.url(),\n title: z.string().min(1),\n user: z.object({ login: z.string().min(1) }),\n head: z.object({ ref: z.string().min(1) }),\n draft: z.boolean(),\n});\nconst collaboratorPermissionSchema = z.object({\n permission: z.enum([\"admin\", \"maintain\", \"write\", \"triage\", \"read\", \"none\"]),\n});\nconst writePermissions = new Set([\"admin\", \"maintain\", \"write\"]);\n\n/** Refusal raised when an inline review-comment author lacks repository write access. */\nexport class GitHubReviewCommentAuthorError extends Error {\n readonly author: string | null;\n\n constructor(author: string | null) {\n super(\n author === null\n ? \"GitHub review comment has no author to verify for repository write access\"\n : `GitHub user ${author} does not have write access to the repository`,\n );\n this.name = \"GitHubReviewCommentAuthorError\";\n this.author = author;\n }\n}\n\n/**\n * The pull request advanced past the commit a review or fix was prepared\n * against. Callers that reviewed a task keyed to a specific commit (for\n * example `record_post_review`) can use `expectedSha`/`actualSha` to resolve\n * the task as superseded instead of leaving it running for the stall\n * watchdog to eventually -- and misleadingly -- report as \"stalled\".\n */\nexport class StalePullRequestHeadError extends Error {\n readonly expectedSha: string;\n readonly actualSha: string;\n\n constructor(expectedSha: string, actualSha: string) {\n super(`pull request changed after review: expected ${expectedSha}, found ${actualSha}`);\n this.name = \"StalePullRequestHeadError\";\n this.expectedSha = expectedSha;\n this.actualSha = actualSha;\n }\n}\n\n/** Whether a GitHub user may make repository-scoped Factory decisions. */\nexport async function hasGitHubRepositoryWriteAccess(\n input: GitHubRepositoryAuthorRequest,\n): Promise<boolean> {\n const { permission } = collaboratorPermissionSchema.parse(\n await gitHubRequest(input, `/collaborators/${encodeURIComponent(input.author)}/permission`),\n );\n return writePermissions.has(permission);\n}\n\n/** Create a pull request from an existing head branch. */\nexport async function createPullRequest(\n input: CreatePullRequestInput,\n): Promise<CreatedGitHubPullRequest> {\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 { pullRequestNumber: pull.number, pullRequestUrl: 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 assertCheckRunFields(input);\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 assertCheckRunFields(input);\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(\n input: ListCheckRunsForRefInput,\n): Promise<readonly 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(\n input,\n `/commits/${encodeURIComponent(input.ref)}/check-runs?${query.toString()}`,\n ),\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<readonly GitHubIssueComment[]> {\n const comments: GitHubIssueComment[] = [];\n for (let page = 1; ; page += 1) {\n const response = z\n .array(issueCommentSchema)\n .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/** List issue comments with a ten-page bound so reconciliation never scans without limit. */\nexport async function listIssueComments(\n input: ListIssueCommentsInput,\n): Promise<readonly GitHubIssueComment[]> {\n const comments: GitHubIssueComment[] = [];\n for (let page = 1; page <= 10; page += 1) {\n const response = z\n .array(issueCommentSchema)\n .max(100)\n .parse(\n await gitHubRequest(\n input,\n `/issues/${positiveInteger(input.issueNumber, \"issueNumber\")}/comments?per_page=100&page=${page}`,\n ),\n );\n comments.push(...response.map(parseIssueComment));\n if (response.length < 100) return comments;\n }\n throw new Error(\"Issue comment lookup is incomplete after ten pages\");\n}\n\n/** Read a page of all PR discussion types without treating any author's text as authorization. */\nexport async function listPullRequestDiscussion(\n input: ListPullRequestDiscussionInput,\n): Promise<GitHubPullRequestDiscussionPage> {\n const page = z\n .number()\n .int()\n .positive()\n .parse(input.page ?? 1);\n const number = positiveInteger(input.pullRequestNumber, \"pullRequestNumber\");\n const query = `per_page=50&page=${page}`;\n const [comments, reviewComments, reviews] = await Promise.all([\n gitHubRequest(input, `/issues/${number}/comments?${query}`).then((value) =>\n z.array(issueCommentSchema).max(50).parse(value).map(parseIssueComment),\n ),\n gitHubRequest(input, `/pulls/${number}/comments?${query}`).then((value) =>\n z\n .array(\n reviewCommentSchema.extend({\n pull_request_review_id: z.number().int().positive().nullable(),\n path: z.string().min(1),\n line: z.number().int().positive().nullish(),\n }),\n )\n .max(50)\n .parse(value)\n .map((entry) => {\n const comment = parseReviewComment(entry);\n assertReviewCommentPullRequest(input, comment);\n return {\n ...comment,\n reviewId: entry.pull_request_review_id,\n path: entry.path,\n line: entry.line ?? null,\n };\n }),\n ),\n gitHubRequest(input, `/pulls/${number}/reviews?${query}`).then((value) =>\n z\n .array(\n submittedReviewSchema.extend({\n user: z.object({ login: z.string().min(1) }).nullable(),\n body: z.string(),\n commit_id: z\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .nullable(),\n }),\n )\n .max(50)\n .parse(value)\n .map((review) => ({\n id: review.id,\n url: review.html_url,\n state: review.state,\n author: review.user?.login ?? null,\n body: review.body,\n commitId: review.commit_id,\n })),\n ),\n ]);\n return {\n comments,\n reviewComments,\n reviews,\n nextPage: [comments, reviewComments, reviews].some((entries) => entries.length === 50)\n ? page + 1\n : null,\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/** Add one issue comment and return GitHub's persisted identity. */\nexport async function createIssueComment(\n input: CreateIssueCommentInput,\n): Promise<GitHubIssueComment> {\n return parseIssueComment(\n await gitHubRequest(\n input,\n `/issues/${positiveInteger(input.issueNumber, \"issueNumber\")}/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(\n input,\n `/issues/comments/${positiveInteger(input.commentId, \"commentId\")}`,\n {\n method: \"PATCH\",\n body: JSON.stringify({ body: input.body }),\n },\n ),\n );\n}\n\nconst readIssueCommentSchema = issueCommentSchema.extend({\n issue_url: z.string().min(1),\n});\n\n/** One issue comment as GitHub reports it, with the issue it belongs to. */\nexport interface GitHubIssueCommentRecord extends GitHubIssueComment {\n issueNumber: number;\n}\n\n/**\n * Read one issue comment from GitHub. A delivery authenticated as a workload\n * rather than by body signature can name any author and any text, so the\n * comment it refers to has to be read back before either is believed.\n */\nexport async function readIssueComment(\n input: GitHubRepositoryRequest & { commentId: number },\n): Promise<GitHubIssueCommentRecord> {\n const comment = readIssueCommentSchema.parse(\n await gitHubRequest(input, `/issues/comments/${positiveInteger(input.commentId, \"commentId\")}`),\n );\n const issueNumber = Number(comment.issue_url.split(\"/\").pop());\n if (!Number.isSafeInteger(issueNumber) || issueNumber < 1) {\n throw new Error(\"GitHub returned an issue comment without a usable issue reference.\");\n }\n return {\n id: comment.id,\n url: comment.html_url,\n author: comment.user?.login ?? null,\n authorType: comment.user?.type ?? null,\n body: comment.body,\n issueNumber,\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 assertReviewCommentPullRequest(input, comment);\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 const comment = await readReviewComment(input);\n const rootId = comment.inReplyToId ?? comment.id;\n if (rootId !== comment.id) {\n await readReviewComment({ ...input, commentId: rootId, authorPolicy: \"any\" });\n }\n const reply = parseReviewComment(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/comments/${positiveInteger(rootId, \"commentId\")}/replies`,\n { method: \"POST\", body: JSON.stringify({ body: input.body }) },\n ),\n );\n assertReviewCommentPullRequest(input, reply);\n return reply;\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\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .parse(input.commitId);\n const comments = (input.comments ?? []).map((comment) => {\n const line = positiveInteger(comment.line, \"comment line\");\n const startLine =\n comment.startLine === undefined\n ? undefined\n : positiveInteger(comment.startLine, \"comment startLine\");\n if (startLine !== undefined && startLine >= line) {\n throw new Error(\"comment startLine must precede line; omit it for a single-line finding\");\n }\n return {\n path: comment.path,\n line,\n side: \"RIGHT\",\n ...(startLine === undefined ? {} : { start_line: startLine, start_side: \"RIGHT\" }),\n body: comment.body,\n };\n });\n const head = await readPullRequestHead(input);\n if (head.sha !== commitId) {\n throw new StalePullRequestHeadError(commitId, 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,\n }),\n },\n ),\n );\n return { id: review.id, url: review.html_url, state: review.state };\n}\n\n/** Input for reading one text file from a repository branch, tag, or commit. */\nexport interface ReadGitHubRepositoryFileInput extends GitHubRepositoryRequest {\n /** Repository-relative file path, such as `.factory/config.yml`. */\n path: string;\n /** Branch, tag, or commit to read. Defaults to the repository's default branch. */\n ref?: string;\n /** Largest accepted file size in bytes. Default: 65,536. */\n maxBytes?: number;\n}\n\n/** One text file read from a repository, with the blob SHA GitHub reports for it. */\nexport interface GitHubRepositoryFile {\n sha: string;\n text: string;\n}\n\nconst repositoryFileSchema = z.object({\n type: z.literal(\"file\"),\n sha: z.string().min(1),\n size: z.number().int().nonnegative(),\n encoding: z.literal(\"base64\"),\n content: z.string(),\n});\n\n/** Read one text file from a repository ref, or return null when the path does not exist. */\nexport async function readGitHubRepositoryFile(\n input: ReadGitHubRepositoryFileInput,\n): Promise<GitHubRepositoryFile | null> {\n const path = repositoryContentsPath(input.path, input.ref);\n const maxBytes = positiveInteger(input.maxBytes ?? 65_536, \"maxBytes\");\n const body = await readRepositoryContents(input, path);\n if (body === null) return null;\n const file = repositoryFileSchema.parse(body);\n if (file.size > maxBytes) {\n throw new Error(`${input.path} is ${file.size} bytes, above the ${maxBytes}-byte limit`);\n }\n return { sha: file.sha, text: Buffer.from(file.content, \"base64\").toString(\"utf8\") };\n}\n\n/** Input for listing the entries directly inside one repository directory. */\nexport interface ListGitHubRepositoryDirectoryInput extends GitHubRepositoryRequest {\n /** Repository-relative directory path, such as `.factory/flows`. */\n path: string;\n /** Branch, tag, or commit to read. Defaults to the repository's default branch. */\n ref?: string;\n}\n\n/** One entry directly inside a repository directory. */\nexport interface GitHubRepositoryDirectoryEntry {\n name: string;\n path: string;\n type: \"file\" | \"dir\" | \"symlink\" | \"submodule\";\n sha: string;\n size: number;\n}\n\nconst repositoryDirectorySchema = z.array(\n z.object({\n name: z.string().min(1),\n path: z.string().min(1),\n type: z.enum([\"file\", \"dir\", \"symlink\", \"submodule\"]),\n sha: z.string().min(1),\n size: z.number().int().nonnegative(),\n }),\n);\n\nfunction repositoryContentsPath(path: string, ref: string | undefined): string {\n const segments = path.split(\"/\");\n if (segments.some((segment) => segment === \"\" || segment === \".\" || segment === \"..\")) {\n throw new Error(\"path must be a repository-relative file path\");\n }\n const query = ref === undefined ? \"\" : `?ref=${encodeURIComponent(ref)}`;\n return `/contents/${segments.map(encodeURIComponent).join(\"/\")}${query}`;\n}\n\nasync function readRepositoryContents(\n input: GitHubRepositoryRequest,\n path: string,\n): Promise<unknown | null> {\n try {\n return await gitHubRequest(input, path);\n } catch (error) {\n if (error instanceof GitHubRequestError && error.status === 404) return null;\n throw error;\n }\n}\n\n/** List the entries directly inside one repository directory, or return null when it does not exist. */\nexport async function listGitHubRepositoryDirectory(\n input: ListGitHubRepositoryDirectoryInput,\n): Promise<GitHubRepositoryDirectoryEntry[] | null> {\n const body = await readRepositoryContents(input, repositoryContentsPath(input.path, input.ref));\n return body === null ? null : repositoryDirectorySchema.parse(body);\n}\n\n/** Read the current head branch and commit of a pull request. */\nexport async function readPullRequestHead(\n input: GitHubPullRequestTarget,\n): Promise<GitHubPullRequestHead> {\n const pull = pullRequestHeadSchema.parse(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}`,\n ),\n );\n return {\n branch: pull.head.ref,\n sha: pull.head.sha,\n repository: pull.head.repo.full_name,\n };\n}\n\n/** Read the provider-owned identity and lifecycle of one pull request. */\nexport async function readPullRequest(input: GitHubPullRequestTarget): Promise<GitHubPullRequest> {\n const pull = readablePullRequestSchema.parse(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}`,\n ),\n );\n return {\n pullRequestNumber: pull.number,\n pullRequestUrl: pull.html_url,\n author: pull.user.login,\n authorType: pull.user.type,\n state: pull.state,\n draft: pull.draft,\n merged: pull.merged,\n ...(pull.merged_by ? { mergedBy: pull.merged_by.login } : {}),\n ...(pull.merge_commit_sha ? { mergeCommitSha: pull.merge_commit_sha } : {}),\n };\n}\n\n/** Close an open pull request without merging it. */\nexport async function closePullRequest(input: GitHubPullRequestTarget): Promise<GitHubPullRequest> {\n const pull = readablePullRequestSchema.parse(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}`,\n { method: \"PATCH\", body: JSON.stringify({ state: \"closed\" }) },\n ),\n );\n return {\n pullRequestNumber: pull.number,\n pullRequestUrl: pull.html_url,\n author: pull.user.login,\n authorType: pull.user.type,\n state: pull.state,\n draft: pull.draft,\n merged: pull.merged,\n ...(pull.merged_by ? { mergedBy: pull.merged_by.login } : {}),\n ...(pull.merge_commit_sha ? { mergeCommitSha: pull.merge_commit_sha } : {}),\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<readonly ConflictedGitHubPullRequest[]> {\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: ConflictedGitHubPullRequest[] = [];\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 pullRequestNumber: pull.number,\n pullRequestUrl: 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/** List all open PRs newest first; fail rather than return a partial inventory at the ten-page bound. */\nexport async function listOpenPullRequests(\n input: ListOpenPullRequestsInput,\n): Promise<readonly OpenPullRequest[]> {\n const pulls = new Map<number, OpenPullRequest>();\n for (let page = 1; page <= 10; page++) {\n const batch = z\n .array(openPullRequestSummarySchema)\n .parse(\n await gitHubRequest(\n input,\n `/pulls?state=open&per_page=100&sort=created&direction=desc&page=${page}`,\n ),\n );\n for (const pull of batch)\n pulls.set(pull.number, {\n prNumber: pull.number,\n prUrl: pull.html_url,\n title: pull.title,\n author: pull.user.login,\n headBranch: pull.head.ref,\n draft: pull.draft,\n });\n if (batch.length < 100) return [...pulls.values()];\n }\n throw new Error(\n \"Open pull request lookup is incomplete after ten pages; do not conclude that no duplicate exists. Inspect targeted repository work before admitting a new change.\",\n );\n}\n\n/** Ensure a repository label exists, including when another publisher creates it concurrently. */\nexport async function ensureGitHubLabel(input: EnsureGitHubLabelInput): Promise<void> {\n const label = z\n .object({\n name: z.string().trim().min(1).max(50),\n color: z.string().regex(/^[a-fA-F0-9]{6}$/u),\n description: z.string().max(100),\n })\n .parse(input);\n const path = `/labels/${encodeURIComponent(label.name)}`;\n const read = async () => {\n const existing = z.object({ name: z.string() }).parse(await gitHubRequest(input, path));\n if (existing.name.toLowerCase() !== label.name.toLowerCase())\n throw new Error(\"GitHub returned a different repository label\");\n };\n try {\n await read();\n return;\n } catch (error) {\n if (!(error instanceof GitHubRequestError) || error.status !== 404) throw error;\n }\n try {\n await gitHubRequest(input, \"/labels\", { method: \"POST\", body: JSON.stringify(label) });\n } catch (error) {\n if (!(error instanceof GitHubRequestError) || error.status !== 422) throw error;\n // GitHub uses 422 for both a concurrent creation and unrelated validation failures.\n await read();\n }\n}\n\n/** Add one label to a pull request. */\nexport async function addLabel(input: PullRequestLabelInput): Promise<readonly 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/** Add one existing repository label to an issue. */\nexport async function addIssueLabel(input: IssueLabelInput): Promise<readonly string[]> {\n return parseLabels(\n await gitHubRequest(\n input,\n `/issues/${positiveInteger(input.issueNumber, \"issueNumber\")}/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<readonly 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\nclass GitHubRequestError extends Error {\n constructor(\n readonly status: number,\n message: string,\n ) {\n super(`GitHub API request failed (${status}): ${message}`);\n }\n}\n\nasync function gitHubRequest(\n input: GitHubRepositoryRequest,\n path: string,\n init: RequestInit = {},\n): Promise<unknown> {\n const repository = repositorySlugSchema.parse(input.repository);\n const response = await (input.fetch ?? globalThis.fetch)(\n `${gitHubApiUrl}/repos/${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 GitHubRequestError(\n response.status,\n 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 const pullRequestMatch = /\\/pulls\\/([1-9]\\d*)\\/?$/.exec(\n new URL(comment.pull_request_url).pathname,\n );\n if (pullRequestMatch?.[1] === undefined) {\n throw new Error(\"GitHub review comment has an invalid pull request URL\");\n }\n return {\n id: comment.id,\n pullRequestNumber: positiveInteger(Number(pullRequestMatch[1]), \"pullRequestNumber\"),\n body: comment.body,\n url: comment.html_url,\n author: comment.user?.login ?? null,\n authorType: comment.user?.type ?? null,\n inReplyToId: comment.in_reply_to_id ?? null,\n reviewId: comment.pull_request_review_id ?? null,\n };\n}\n\nfunction assertReviewCommentPullRequest(\n input: GitHubPullRequestTarget,\n comment: GitHubReviewComment,\n): void {\n const expected = positiveInteger(input.pullRequestNumber, \"pullRequestNumber\");\n if (comment.pullRequestNumber !== expected) {\n throw new Error(\n `GitHub review comment ${comment.id} does not belong to pull request ${expected}`,\n );\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 ?? null,\n authorType: comment.user?.type ?? 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 assertCheckRunFields(input: CheckRunFields): void {\n if (input.status === \"completed\") {\n if (input.conclusion === undefined) {\n throw new Error(\"completed check runs require a conclusion\");\n }\n return;\n }\n if (input.conclusion !== undefined) {\n throw new Error(\"a check run conclusion requires completed status\");\n }\n if (input.completedAt !== undefined) {\n throw new Error(\"a check run completion time requires completed status\");\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(\n annotation.endLine ?? annotation.startLine,\n \"annotation endLine\",\n ),\n ...(annotation.startColumn === undefined\n ? {}\n : {\n start_column: positiveInteger(annotation.startColumn, \"annotation startColumn\"),\n }),\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 | null,\n): Promise<void> {\n if (input.authorPolicy === \"any\") {\n return;\n }\n if (author === null || !(await hasGitHubRepositoryWriteAccess({ ...input, author }))) {\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\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .parse(value);\n}\n\n/** Raw payload, shared secret, and provider signature used for webhook verification. */\nexport interface VerifyGitHubSignatureInput {\n secret: string;\n payload: string;\n signature: string | null;\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: VerifyGitHubSignatureInput): 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: gitHubRepositorySlugSchema,\n }),\n});\n\n/** Normalized observation that a repository's configured default branch advanced. */\nexport interface GitHubDefaultBranchPush {\n source: \"github_default_branch_push\";\n deliveryId: string;\n repositorySlug: RepositorySlug;\n defaultBranch: string;\n}\n\n/** Normalize a push to a repository's default branch for deterministic reconciliation. */\nexport function normalizeGitHubDefaultBranchPush(\n options: WebhookEvent,\n): GitHubDefaultBranchPush | null {\n if (options.event !== \"push\") return null;\n const parsed = pushEventSchema.safeParse(options.payload);\n if (\n !parsed.success ||\n parsed.data.ref !== `refs/heads/${parsed.data.repository.default_branch}`\n ) {\n return null;\n }\n return {\n source: \"github_default_branch_push\",\n deliveryId: options.deliveryId,\n repositorySlug: parsed.data.repository.full_name,\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: gitHubRepositorySlugSchema }),\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: gitHubRepositorySlugSchema }),\n sender: z.looseObject({ login: z.string().min(1) }),\n});\n\nconst reviewablePullRequestActions = new Set([\n \"opened\",\n \"reopened\",\n \"ready_for_review\",\n \"synchronize\",\n]);\n\n/** Reviewable pull-request webhook normalized for Factory intake. */\nexport interface GitHubPullRequestSignal extends NormalizedSignal<\"github_pr\"> {\n repositorySlug: RepositorySlug;\n pullRequest: {\n pullRequestNumber: number;\n pullRequestUrl: string;\n author: string;\n draft: boolean;\n headSha: string;\n headBranch: string;\n headRepositorySlug: RepositorySlug;\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;\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 pullRequestNumber: parsed.data.number,\n pullRequestUrl: 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,\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: gitHubRepositorySlugSchema,\n }),\n});\n\n/** Opened GitHub issue normalized for Factory intake. */\nexport interface GitHubIssueSignal extends NormalizedSignal<\"github_issue\"> {\n repositorySlug: RepositorySlug;\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: gitHubRepositorySlugSchema,\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: gitHubRepositorySlugSchema,\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\n/** Unsuccessful GitHub Actions run normalized for Factory intake. */\nexport interface GitHubCiFailureSignal extends NormalizedSignal<\"github_ci_failure\"> {\n repositoryDefaultBranch: string;\n repositorySlug: RepositorySlug;\n workflowRun: {\n id: number;\n name: string;\n trigger: string;\n branch: string | null;\n headRepositorySlug: RepositorySlug | 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;\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\n .looseObject({ login: z.string().min(1) })\n .nullable()\n .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: gitHubRepositorySlugSchema,\n }),\n sender: z.looseObject({ login: z.string().min(1) }),\n});\n\n/** Normalized provider observation that a pull request was merged or closed. */\nexport interface GitHubPullRequestClosed extends GitHubPullRequestReference {\n source: \"github_pull_request_closed\";\n deliveryId: string;\n repositorySlug: RepositorySlug;\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,\n pullRequestNumber: pr.number,\n pullRequestUrl: 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;\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 ?? 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":";;;;;;AAkEA,MAAM,eAAe;AACrB,MAAM,6BAA6B,EAChC,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,WAAW,UAAU,MAAM,YAAY,CAAC,CAAC,CACzC,KAAK,oBAAoB;AAE5B,MAAM,kCAAkC,EAAE,YAAY;CACpD,QAAQ,EAAE,QAAQ,SAAS;CAC3B,SAAS,EAAE,YAAY;EACrB,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;EAC9B,MAAM,EAAE,OAAO;EACf,UAAU,EAAE,IAAI;EAChB,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ;CACtD,CAAC;CACD,cAAc,EAAE,YAAY;EAC1B,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;EAClC,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;CAClD,CAAC;CACD,YAAY,EAAE,YAAY,EAAE,WAAW,2BAA2B,CAAC;AACrE,CAAC;AAED,MAAM,kCAAkC,EAAE,YAAY;CACpD,QAAQ,EAAE,QAAQ,SAAS;CAC3B,SAAS,EAAE,YAAY;EACrB,MAAM,EAAE,OAAO;EACf,UAAU,EAAE,IAAI;EAChB,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CAChC,CAAC;CACD,OAAO,EA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,OAAO;EACL,QAAQ;EACR,YAAY,QAAQ;EACpB,gBAAgB,OAAO,KAAK,WAAW;EACvC,mBAAmB,GAAG;EACtB,gBAAgB,GAAG;EACnB,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;CACpC,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,aAAa;GACtD,SAAS,IAAI;GACb,KAAK,IAAI;GACT;GACA,SAAS,IAAI;EACf;EACA,SAAS,QAAQ;CACnB;AACF"}
@@ -3,11 +3,12 @@ import { z } from "zod";
3
3
  //#region src/intake-contracts.d.ts
4
4
  /** Validates the operator projection of intake, excluding the untrusted provider payload. */
5
5
  declare const intakeViewSchema: z.ZodObject<{
6
+ deliveryId: z.ZodString;
7
+ reason: z.ZodOptional<z.ZodString>;
6
8
  id: z.ZodType<`sig_${string}`, string, z.core.$ZodTypeInternals<`sig_${string}`, string>>;
7
9
  schemaVersion: z.ZodLiteral<1>;
8
10
  repositoryId: z.ZodType<`repo_${string}`, string, z.core.$ZodTypeInternals<`repo_${string}`, string>>;
9
11
  source: z.ZodType<SignalSource, unknown, z.core.$ZodTypeInternals<SignalSource, unknown>>;
10
- deliveryId: z.ZodString;
11
12
  replyTo: z.ZodObject<{
12
13
  channel: z.ZodString;
13
14
  address: z.ZodString;
@@ -41,7 +42,6 @@ declare const intakeViewSchema: z.ZodObject<{
41
42
  }>>;
42
43
  }, z.core.$strict>>;
43
44
  detail: z.ZodOptional<z.ZodString>;
44
- reason: z.ZodOptional<z.ZodString>;
45
45
  decidedAt: z.ZodOptional<z.ZodISODateTime>;
46
46
  repository: z.ZodString;
47
47
  taskIds: z.ZodArray<z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>>;
@@ -1,7 +1,7 @@
1
1
  import { GitHubAppFactoryInput, GitHubAppInstallationToken, GitHubAppLike, GitHubAppPermissions, MintGitHubAppInstallationTokenInput, mintGitHubAppInstallationToken } from "../github-app.mjs";
2
2
  import { FetchGitHubBundleInput, FetchGitHubRefsInput, GitHubGitTransport, GitHubRefMapping, GitHubRepositoryBundle, GitTransferSandbox, PushGitHubBundleInput, PushGitHubHeadInput, ReadGitTransferFileInput, WithSandboxGitBundleInput, WriteGitTransferFileInput } from "../github-transfer.mjs";
3
3
  import { CheckoutGitHubRepositoryInput, CommittedGitChange, CreateGitHubBranchInput, CreateGitHubCommitInput, CreateGitHubPublicationPullRequestInput, CreateGitHubTreeInput, CreatedGitHubPublicationPullRequest, GitHubCheckoutConflictError, GitHubCommit, GitHubPublicationApiError, GitHubPublicationClient, GitHubPublicationClientOptions, GitHubPublicationLimits, GitHubPublicationPullRequest, GitHubTreeDeletion, GitHubTreeEntry, GitHubTreeUpsert, ListGitHubPublicationPullRequestsInput, MarkGitHubPullRequestReadyInput, ReadCommittedGitChangeInput, ReadGitHubBranchHeadInput, ReadGitHubCommitInput, ReadGitHubPullRequestInput, RunSandboxGitInput, SandboxGit, SandboxGitCommandInput, SandboxGitCommandResult, UpdateGitHubBranchInput, checkoutGitHubRepository, createGitHubPublicationClient, factorySessionBranch, factoryTaskBranch, isSafeGitRef, readCommittedGitChange, runSandboxGit } from "../github-publication.mjs";
4
- import { AnswerReviewCommentInput, CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunFields, CheckRunOutput, CheckRunProgressStatus, CompletedCheckRunFields, ConfiguredEventRepositoryInput, ConflictedGitHubPullRequest, CreateCheckRunInput, CreatePullRequestCommentInput, CreatePullRequestInput, CreatedGitHubPullRequest, EnsureGitHubLabelInput, FactoryMentionOptions, FactoryQuestionReply, FactoryReviewComment, GitHubCheckRun, GitHubCiFailureSignal, GitHubDefaultBranchPush, GitHubIssueComment, GitHubIssueCommentRecord, GitHubIssueSignal, GitHubPullRequest, GitHubPullRequestClosed, GitHubPullRequestDiscussionComment, GitHubPullRequestDiscussionPage, GitHubPullRequestDiscussionReview, GitHubPullRequestHead, GitHubPullRequestReference, GitHubPullRequestSignal, GitHubPullRequestTarget, GitHubRepositoryAuthorRequest, GitHubRepositoryRequest, GitHubReviewComment, GitHubReviewCommentAuthorError, IncompleteCheckRunFields, ListCheckRunsForRefInput, ListConflictedPullRequestsInput, ListOpenPullRequestsInput, ListPullRequestCommentsInput, ListPullRequestDiscussionInput, NormalizeFactoryCommentInput, NormalizeFactoryReviewCommentInput, ObservedCheckRunStatus, PullRequestLabelInput, PullRequestReviewComment, PullRequestReviewEvent, ReadReviewCommentInput, ReviewCommentAuthorPolicy, StalePullRequestHeadError, SubmitPullRequestReviewInput, SubmittedPullRequestReview, UpdateCheckRunInput, UpdatePullRequestCommentInput, VerifyGitHubSignatureInput, addLabel, answerReviewComment, closePullRequest, configuredEventRepositorySlug, createCheckRun, createPullRequest, createPullRequestComment, ensureGitHubLabel, hasGitHubRepositoryWriteAccess, listCheckRunsForRef, listConflictedPullRequests, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature } from "../github.mjs";
4
+ import { AnswerReviewCommentInput, CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunFields, CheckRunOutput, CheckRunProgressStatus, CompletedCheckRunFields, ConfiguredEventRepositoryInput, ConflictedGitHubPullRequest, CreateCheckRunInput, CreateIssueCommentInput, CreatePullRequestCommentInput, CreatePullRequestInput, CreatedGitHubPullRequest, EnsureGitHubLabelInput, FactoryMentionOptions, FactoryQuestionReply, FactoryReviewComment, GitHubCheckRun, GitHubCiFailureSignal, GitHubDefaultBranchPush, GitHubIssueComment, GitHubIssueCommentRecord, GitHubIssueSignal, GitHubIssueTarget, GitHubPullRequest, GitHubPullRequestClosed, GitHubPullRequestDiscussionComment, GitHubPullRequestDiscussionPage, GitHubPullRequestDiscussionReview, GitHubPullRequestHead, GitHubPullRequestReference, GitHubPullRequestSignal, GitHubPullRequestTarget, GitHubRepositoryAuthorRequest, GitHubRepositoryDirectoryEntry, GitHubRepositoryFile, GitHubRepositoryRequest, GitHubReviewComment, GitHubReviewCommentAuthorError, IncompleteCheckRunFields, IssueLabelInput, ListCheckRunsForRefInput, ListConflictedPullRequestsInput, ListGitHubRepositoryDirectoryInput, ListIssueCommentsInput, ListOpenPullRequestsInput, ListPullRequestCommentsInput, ListPullRequestDiscussionInput, NormalizeFactoryCommentInput, NormalizeFactoryReviewCommentInput, ObservedCheckRunStatus, PullRequestLabelInput, PullRequestReviewComment, PullRequestReviewEvent, ReadGitHubRepositoryFileInput, ReadReviewCommentInput, ReviewCommentAuthorPolicy, StalePullRequestHeadError, SubmitPullRequestReviewInput, SubmittedPullRequestReview, UpdateCheckRunInput, UpdatePullRequestCommentInput, VerifyGitHubSignatureInput, addIssueLabel, addLabel, answerReviewComment, closePullRequest, configuredEventRepositorySlug, createCheckRun, createIssueComment, createPullRequest, createPullRequestComment, ensureGitHubLabel, hasGitHubRepositoryWriteAccess, listCheckRunsForRef, listConflictedPullRequests, listGitHubRepositoryDirectory, listIssueComments, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readGitHubRepositoryFile, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature } from "../github.mjs";
5
5
  import { PublishedGitHubReview } from "../code-review/github-contracts.mjs";
6
6
  import { GitHubCommunicationAdapterOptions, GitHubReplyTarget, createGitHubCommunicationAdapter, parseGitHubReplyAddress, renderGitHubCommunicationEvent } from "../connectors/github.mjs";
7
7
  import { GitHubReviewReporter, GitHubReviewReporterOptions, ReconcileReviewChecksInput, ReconcileReviewChecksOptions, ReconcileReviewChecksResult, createGitHubReviewReporter } from "../code-review/github-reporter.mjs";
@@ -9,4 +9,4 @@ import { GitHubPullRequestPublicationGate, GitHubPullRequestPublicationGateOptio
9
9
  import { GitHubPullRequestLabelManager, GitHubPullRequestLabelManagerOptions, ManageGitHubPullRequestLabelInput, createGitHubPullRequestLabelManager } from "../pull-requests/github-label-manager.mjs";
10
10
  import { GitHubOpenPullRequestLister, GitHubOpenPullRequestListerOptions, createGitHubOpenPullRequestLister } from "../work-triage/github.mjs";
11
11
  import { GitHubIssuePublication, GitHubIssuePublisherOptions, PublishGitHubIssueOptions, PublishGitHubIssueResult, createGitHubIssuePublisher, readGitHubIssuePublication } from "./github-issues.mjs";
12
- export { type AnswerReviewCommentInput, type CheckRunAnnotation, type CheckRunAnnotationLevel, type CheckRunConclusion, type CheckRunFields, type CheckRunOutput, type CheckRunProgressStatus, type CheckoutGitHubRepositoryInput, type CommittedGitChange, type CompletedCheckRunFields, type ConfiguredEventRepositoryInput, type ConflictedGitHubPullRequest, type CreateCheckRunInput, type CreateGitHubBranchInput, type CreateGitHubCommitInput, type CreateGitHubPublicationPullRequestInput, type CreateGitHubTreeInput, type CreatePullRequestCommentInput, type CreatePullRequestInput, type CreatedGitHubPublicationPullRequest, type CreatedGitHubPullRequest, type EnsureGitHubLabelInput, type FactoryMentionOptions, type FactoryQuestionReply, type FactoryReviewComment, type FetchGitHubBundleInput, type FetchGitHubRefsInput, type GitHubAppFactoryInput, type GitHubAppInstallationToken, type GitHubAppLike, type GitHubAppPermissions, type GitHubCheckRun, GitHubCheckoutConflictError, type GitHubCiFailureSignal, type GitHubCommit, type GitHubCommunicationAdapterOptions, type GitHubDefaultBranchPush, type GitHubGitTransport, type GitHubIssueComment, type GitHubIssueCommentRecord, type GitHubIssuePublication, type GitHubIssuePublisherOptions, type GitHubIssueSignal, type GitHubOpenPullRequestLister, type GitHubOpenPullRequestListerOptions, GitHubPublicationApiError, type GitHubPublicationClient, type GitHubPublicationClientOptions, type GitHubPublicationLimits, type GitHubPublicationPullRequest, type GitHubPullRequest, type GitHubPullRequestClosed, type GitHubPullRequestDiscussionComment, type GitHubPullRequestDiscussionPage, type GitHubPullRequestDiscussionReview, type GitHubPullRequestHead, type GitHubPullRequestLabelManager, type GitHubPullRequestLabelManagerOptions, type GitHubPullRequestPublicationGate, type GitHubPullRequestPublicationGateOptions, type GitHubPullRequestPublisher, type GitHubPullRequestPublisherOptions, type GitHubPullRequestReference, type GitHubPullRequestSignal, type GitHubPullRequestTarget, type GitHubRefMapping, type GitHubReplyTarget, type GitHubRepositoryAuthorRequest, type GitHubRepositoryBundle, type GitHubRepositoryRequest, type GitHubReviewComment, GitHubReviewCommentAuthorError, type GitHubReviewReporter, type GitHubReviewReporterOptions, type GitHubTreeDeletion, type GitHubTreeEntry, type GitHubTreeUpsert, type GitTransferSandbox, type IncompleteCheckRunFields, type ListCheckRunsForRefInput, type ListConflictedPullRequestsInput, type ListGitHubPublicationPullRequestsInput, type ListOpenPullRequestsInput, type ListPullRequestCommentsInput, type ListPullRequestDiscussionInput, type ManageGitHubPullRequestLabelInput, type MarkGitHubPullRequestReadyInput, type MintGitHubAppInstallationTokenInput, type NormalizeFactoryCommentInput, type NormalizeFactoryReviewCommentInput, type ObservedCheckRunStatus, type PublishGitHubIssueOptions, type PublishGitHubIssueResult, type PublishGitHubPullRequestInput, type PublishedGitHubReview, type PullRequestLabelInput, type PullRequestReviewComment, type PullRequestReviewEvent, type PushGitHubBundleInput, type PushGitHubCheckpointInput, type PushGitHubHeadInput, type ReadCommittedGitChangeInput, type ReadGitHubBranchHeadInput, type ReadGitHubCommitInput, type ReadGitHubPullRequestInput, type ReadGitTransferFileInput, type ReadReviewCommentInput, type ReconcileReviewChecksInput, type ReconcileReviewChecksOptions, type ReconcileReviewChecksResult, type RequireTaskPullRequestInput, type ReviewCommentAuthorPolicy, type RunSandboxGitInput, type SandboxGit, type SandboxGitCommandInput, type SandboxGitCommandResult, StalePullRequestHeadError, type SubmitPullRequestReviewInput, type SubmittedPullRequestReview, type UpdateCheckRunInput, type UpdateGitHubBranchInput, type UpdatePullRequestCommentInput, type VerifyGitHubSignatureInput, type WithSandboxGitBundleInput, type WriteGitTransferFileInput, addLabel, answerReviewComment, checkoutGitHubRepository, closePullRequest, configuredEventRepositorySlug, createCheckRun, createGitHubCommunicationAdapter, createGitHubIssuePublisher, createGitHubOpenPullRequestLister, createGitHubPublicationClient, createGitHubPullRequestLabelManager, createGitHubPullRequestPublicationGate, createGitHubPullRequestPublisher, createGitHubReviewReporter, createPullRequest, createPullRequestComment, ensureGitHubLabel, factorySessionBranch, factoryTaskBranch, hasGitHubRepositoryWriteAccess, isSafeGitRef, listCheckRunsForRef, listConflictedPullRequests, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, mintGitHubAppInstallationToken, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, parseGitHubReplyAddress, readCommittedGitChange, readGitHubIssuePublication, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, renderGitHubCommunicationEvent, runSandboxGit, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };
12
+ export { type AnswerReviewCommentInput, type CheckRunAnnotation, type CheckRunAnnotationLevel, type CheckRunConclusion, type CheckRunFields, type CheckRunOutput, type CheckRunProgressStatus, type CheckoutGitHubRepositoryInput, type CommittedGitChange, type CompletedCheckRunFields, type ConfiguredEventRepositoryInput, type ConflictedGitHubPullRequest, type CreateCheckRunInput, type CreateGitHubBranchInput, type CreateGitHubCommitInput, type CreateGitHubPublicationPullRequestInput, type CreateGitHubTreeInput, type CreateIssueCommentInput, type CreatePullRequestCommentInput, type CreatePullRequestInput, type CreatedGitHubPublicationPullRequest, type CreatedGitHubPullRequest, type EnsureGitHubLabelInput, type FactoryMentionOptions, type FactoryQuestionReply, type FactoryReviewComment, type FetchGitHubBundleInput, type FetchGitHubRefsInput, type GitHubAppFactoryInput, type GitHubAppInstallationToken, type GitHubAppLike, type GitHubAppPermissions, type GitHubCheckRun, GitHubCheckoutConflictError, type GitHubCiFailureSignal, type GitHubCommit, type GitHubCommunicationAdapterOptions, type GitHubDefaultBranchPush, type GitHubGitTransport, type GitHubIssueComment, type GitHubIssueCommentRecord, type GitHubIssuePublication, type GitHubIssuePublisherOptions, type GitHubIssueSignal, type GitHubIssueTarget, type GitHubOpenPullRequestLister, type GitHubOpenPullRequestListerOptions, GitHubPublicationApiError, type GitHubPublicationClient, type GitHubPublicationClientOptions, type GitHubPublicationLimits, type GitHubPublicationPullRequest, type GitHubPullRequest, type GitHubPullRequestClosed, type GitHubPullRequestDiscussionComment, type GitHubPullRequestDiscussionPage, type GitHubPullRequestDiscussionReview, type GitHubPullRequestHead, type GitHubPullRequestLabelManager, type GitHubPullRequestLabelManagerOptions, type GitHubPullRequestPublicationGate, type GitHubPullRequestPublicationGateOptions, type GitHubPullRequestPublisher, type GitHubPullRequestPublisherOptions, type GitHubPullRequestReference, type GitHubPullRequestSignal, type GitHubPullRequestTarget, type GitHubRefMapping, type GitHubReplyTarget, type GitHubRepositoryAuthorRequest, type GitHubRepositoryBundle, type GitHubRepositoryDirectoryEntry, type GitHubRepositoryFile, type GitHubRepositoryRequest, type GitHubReviewComment, GitHubReviewCommentAuthorError, type GitHubReviewReporter, type GitHubReviewReporterOptions, type GitHubTreeDeletion, type GitHubTreeEntry, type GitHubTreeUpsert, type GitTransferSandbox, type IncompleteCheckRunFields, type IssueLabelInput, type ListCheckRunsForRefInput, type ListConflictedPullRequestsInput, type ListGitHubPublicationPullRequestsInput, type ListGitHubRepositoryDirectoryInput, type ListIssueCommentsInput, type ListOpenPullRequestsInput, type ListPullRequestCommentsInput, type ListPullRequestDiscussionInput, type ManageGitHubPullRequestLabelInput, type MarkGitHubPullRequestReadyInput, type MintGitHubAppInstallationTokenInput, type NormalizeFactoryCommentInput, type NormalizeFactoryReviewCommentInput, type ObservedCheckRunStatus, type PublishGitHubIssueOptions, type PublishGitHubIssueResult, type PublishGitHubPullRequestInput, type PublishedGitHubReview, type PullRequestLabelInput, type PullRequestReviewComment, type PullRequestReviewEvent, type PushGitHubBundleInput, type PushGitHubCheckpointInput, type PushGitHubHeadInput, type ReadCommittedGitChangeInput, type ReadGitHubBranchHeadInput, type ReadGitHubCommitInput, type ReadGitHubPullRequestInput, type ReadGitHubRepositoryFileInput, type ReadGitTransferFileInput, type ReadReviewCommentInput, type ReconcileReviewChecksInput, type ReconcileReviewChecksOptions, type ReconcileReviewChecksResult, type RequireTaskPullRequestInput, type ReviewCommentAuthorPolicy, type RunSandboxGitInput, type SandboxGit, type SandboxGitCommandInput, type SandboxGitCommandResult, StalePullRequestHeadError, type SubmitPullRequestReviewInput, type SubmittedPullRequestReview, type UpdateCheckRunInput, type UpdateGitHubBranchInput, type UpdatePullRequestCommentInput, type VerifyGitHubSignatureInput, type WithSandboxGitBundleInput, type WriteGitTransferFileInput, addIssueLabel, addLabel, answerReviewComment, checkoutGitHubRepository, closePullRequest, configuredEventRepositorySlug, createCheckRun, createGitHubCommunicationAdapter, createGitHubIssuePublisher, createGitHubOpenPullRequestLister, createGitHubPublicationClient, createGitHubPullRequestLabelManager, createGitHubPullRequestPublicationGate, createGitHubPullRequestPublisher, createGitHubReviewReporter, createIssueComment, createPullRequest, createPullRequestComment, ensureGitHubLabel, factorySessionBranch, factoryTaskBranch, hasGitHubRepositoryWriteAccess, isSafeGitRef, listCheckRunsForRef, listConflictedPullRequests, listGitHubRepositoryDirectory, listIssueComments, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, mintGitHubAppInstallationToken, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, parseGitHubReplyAddress, readCommittedGitChange, readGitHubIssuePublication, readGitHubRepositoryFile, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, renderGitHubCommunicationEvent, runSandboxGit, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };
@@ -1,10 +1,10 @@
1
1
  import { mintGitHubAppInstallationToken } from "../github-app.mjs";
2
2
  import { GitHubCheckoutConflictError, GitHubPublicationApiError, checkoutGitHubRepository, createGitHubPublicationClient, factorySessionBranch, factoryTaskBranch, isSafeGitRef, readCommittedGitChange, runSandboxGit } from "../github-publication.mjs";
3
- import { GitHubReviewCommentAuthorError, StalePullRequestHeadError, addLabel, answerReviewComment, closePullRequest, configuredEventRepositorySlug, createCheckRun, createPullRequest, createPullRequestComment, ensureGitHubLabel, hasGitHubRepositoryWriteAccess, listCheckRunsForRef, listConflictedPullRequests, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature } from "../github.mjs";
3
+ import { GitHubReviewCommentAuthorError, StalePullRequestHeadError, addIssueLabel, addLabel, answerReviewComment, closePullRequest, configuredEventRepositorySlug, createCheckRun, createIssueComment, createPullRequest, createPullRequestComment, ensureGitHubLabel, hasGitHubRepositoryWriteAccess, listCheckRunsForRef, listConflictedPullRequests, listGitHubRepositoryDirectory, listIssueComments, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readGitHubRepositoryFile, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature } from "../github.mjs";
4
4
  import { createGitHubCommunicationAdapter, parseGitHubReplyAddress, renderGitHubCommunicationEvent } from "../connectors/github.mjs";
5
5
  import { createGitHubReviewReporter } from "../code-review/github-reporter.mjs";
6
6
  import { createGitHubPullRequestPublicationGate, createGitHubPullRequestPublisher } from "../pull-requests/github-publisher.mjs";
7
7
  import { createGitHubPullRequestLabelManager } from "../pull-requests/github-label-manager.mjs";
8
8
  import { createGitHubOpenPullRequestLister } from "../work-triage/github.mjs";
9
9
  import { createGitHubIssuePublisher, readGitHubIssuePublication } from "./github-issues.mjs";
10
- export { GitHubCheckoutConflictError, GitHubPublicationApiError, GitHubReviewCommentAuthorError, StalePullRequestHeadError, addLabel, answerReviewComment, checkoutGitHubRepository, closePullRequest, configuredEventRepositorySlug, createCheckRun, createGitHubCommunicationAdapter, createGitHubIssuePublisher, createGitHubOpenPullRequestLister, createGitHubPublicationClient, createGitHubPullRequestLabelManager, createGitHubPullRequestPublicationGate, createGitHubPullRequestPublisher, createGitHubReviewReporter, createPullRequest, createPullRequestComment, ensureGitHubLabel, factorySessionBranch, factoryTaskBranch, hasGitHubRepositoryWriteAccess, isSafeGitRef, listCheckRunsForRef, listConflictedPullRequests, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, mintGitHubAppInstallationToken, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, parseGitHubReplyAddress, readCommittedGitChange, readGitHubIssuePublication, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, renderGitHubCommunicationEvent, runSandboxGit, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };
10
+ export { GitHubCheckoutConflictError, GitHubPublicationApiError, GitHubReviewCommentAuthorError, StalePullRequestHeadError, addIssueLabel, addLabel, answerReviewComment, checkoutGitHubRepository, closePullRequest, configuredEventRepositorySlug, createCheckRun, createGitHubCommunicationAdapter, createGitHubIssuePublisher, createGitHubOpenPullRequestLister, createGitHubPublicationClient, createGitHubPullRequestLabelManager, createGitHubPullRequestPublicationGate, createGitHubPullRequestPublisher, createGitHubReviewReporter, createIssueComment, createPullRequest, createPullRequestComment, ensureGitHubLabel, factorySessionBranch, factoryTaskBranch, hasGitHubRepositoryWriteAccess, isSafeGitRef, listCheckRunsForRef, listConflictedPullRequests, listGitHubRepositoryDirectory, listIssueComments, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, mintGitHubAppInstallationToken, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, parseGitHubReplyAddress, readCommittedGitChange, readGitHubIssuePublication, readGitHubRepositoryFile, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, renderGitHubCommunicationEvent, runSandboxGit, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };