@vercel/factory 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +362 -0
- package/README.md +49 -261
- package/dist/agent-routes.d.mts +47 -3
- package/dist/agent-routes.mjs +28 -1
- package/dist/agent-routes.mjs.map +1 -1
- package/dist/api-contracts.d.mts +20 -1
- package/dist/api-contracts.mjs +2 -1
- package/dist/api-contracts.mjs.map +1 -1
- package/dist/api.d.mts +45 -2
- package/dist/api.mjs +199 -10
- package/dist/api.mjs.map +1 -1
- package/dist/approval-contracts.d.mts +6 -0
- package/dist/blob/index.d.mts +51 -14
- package/dist/blob/index.mjs +26 -10
- package/dist/blob/index.mjs.map +1 -1
- package/dist/budget.d.mts +7 -0
- package/dist/budget.mjs +6 -0
- package/dist/budget.mjs.map +1 -1
- package/dist/build-factory.d.mts +1 -0
- package/dist/change-verification/dispatch.d.mts +16 -3
- package/dist/change-verification/dispatch.mjs +45 -7
- package/dist/change-verification/dispatch.mjs.map +1 -1
- package/dist/change-verification/eve-tool.d.mts +2 -1
- package/dist/change-verification/eve-tool.mjs +35 -47
- package/dist/change-verification/eve-tool.mjs.map +1 -1
- package/dist/change-verification/result.mjs +130 -0
- package/dist/change-verification/result.mjs.map +1 -0
- package/dist/changes/eve-record-change.d.mts +2 -2
- package/dist/changes/eve-record-change.mjs +43 -9
- package/dist/changes/eve-record-change.mjs.map +1 -1
- package/dist/changes.d.mts +4 -3
- package/dist/changes.mjs +2 -2
- package/dist/changes.mjs.map +1 -1
- package/dist/client-events.d.mts +10 -3
- package/dist/client-events.mjs +6 -2
- package/dist/client-events.mjs.map +1 -1
- package/dist/client-stream.mjs +8 -2
- package/dist/client-stream.mjs.map +1 -1
- package/dist/client-transcript.mjs +5 -1
- package/dist/client-transcript.mjs.map +1 -1
- package/dist/client.d.mts +121 -12
- package/dist/client.mjs +117 -9
- package/dist/client.mjs.map +1 -1
- package/dist/code-review/contracts.d.mts +1 -0
- package/dist/code-review/eve-post-review.d.mts +4 -4
- package/dist/code-review/eve-post-review.mjs +29 -17
- package/dist/code-review/eve-post-review.mjs.map +1 -1
- package/dist/code-review/eve-review-comments.d.mts +13 -2
- package/dist/code-review/eve-review-comments.mjs +45 -11
- package/dist/code-review/eve-review-comments.mjs.map +1 -1
- package/dist/code-review/github-reporter.d.mts +2 -0
- package/dist/code-review/github-reporter.mjs +7 -5
- package/dist/code-review/github-reporter.mjs.map +1 -1
- package/dist/code-review.d.mts +3 -2
- package/dist/deepsec/eve-tool.mjs +3 -1
- package/dist/deepsec/eve-tool.mjs.map +1 -1
- package/dist/dispatch.d.mts +79 -8
- package/dist/dispatch.mjs +68 -9
- package/dist/dispatch.mjs.map +1 -1
- package/dist/eve/index.d.mts +70 -10
- package/dist/eve/index.mjs +93 -22
- package/dist/eve/index.mjs.map +1 -1
- package/dist/eve/invoke.mjs +24 -11
- package/dist/eve/invoke.mjs.map +1 -1
- package/dist/eve/session-client.d.mts +122 -4
- package/dist/eve/session-client.mjs +127 -13
- package/dist/eve/session-client.mjs.map +1 -1
- package/dist/eve/task-execution.d.mts +380 -0
- package/dist/eve/task-execution.mjs +57 -2
- package/dist/eve/task-execution.mjs.map +1 -1
- package/dist/eve/task-session.d.mts +44 -2
- package/dist/eve/task-session.mjs +44 -2
- package/dist/eve/task-session.mjs.map +1 -1
- package/dist/eve/transcript.mjs +5 -1
- package/dist/eve/transcript.mjs.map +1 -1
- package/dist/execution.d.mts +117 -9
- package/dist/execution.mjs +76 -6
- package/dist/execution.mjs.map +1 -1
- package/dist/finding-remediation/admission.d.mts +2 -0
- package/dist/finding-remediation/admission.mjs +4 -1
- package/dist/finding-remediation/admission.mjs.map +1 -1
- package/dist/findings.d.mts +1 -0
- package/dist/github-publication.d.mts +1 -0
- package/dist/github-publication.mjs +97 -84
- package/dist/github-publication.mjs.map +1 -1
- package/dist/github-transfer.d.mts +15 -6
- package/dist/github-transfer.mjs +214 -66
- package/dist/github-transfer.mjs.map +1 -1
- package/dist/github.d.mts +51 -11
- package/dist/github.mjs +126 -24
- package/dist/github.mjs.map +1 -1
- package/dist/inbox-activity.d.mts +53 -0
- package/dist/inbox-activity.mjs +41 -0
- package/dist/inbox-activity.mjs.map +1 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +3 -2
- package/dist/intake-contracts.d.mts +0 -1
- package/dist/integrations/deepsec.d.mts +1 -0
- package/dist/integrations/github.d.mts +2 -2
- package/dist/integrations/github.mjs +2 -2
- package/dist/integrations/slack.d.mts +3 -1
- package/dist/integrations/slack.mjs +3 -1
- package/dist/integrations/vercel.d.mts +4 -2
- package/dist/integrations/vercel.mjs +3 -2
- package/dist/merge-resolution/eve-tools.d.mts +1 -0
- package/dist/merge-resolution/eve-tools.mjs +7 -2
- package/dist/merge-resolution/eve-tools.mjs.map +1 -1
- package/dist/model-settings.d.mts +41 -0
- package/dist/model-settings.mjs +35 -0
- package/dist/model-settings.mjs.map +1 -0
- package/dist/planning/reconcile.mjs +6 -0
- package/dist/planning/reconcile.mjs.map +1 -1
- package/dist/postgres/index.d.mts +43 -2
- package/dist/postgres/index.mjs +40 -2
- package/dist/postgres/index.mjs.map +1 -1
- package/dist/presets/software-development/dispatch.d.mts +4 -1
- package/dist/presets/software-development/dispatch.mjs +2 -1
- package/dist/presets/software-development/dispatch.mjs.map +1 -1
- package/dist/presets/software-development/task-communication.d.mts +1 -0
- package/dist/presets/software-development/task-communication.mjs +48 -11
- package/dist/presets/software-development/task-communication.mjs.map +1 -1
- package/dist/presets/software-development.d.mts +1 -0
- package/dist/pull-requests/github-publisher.d.mts +15 -1
- package/dist/pull-requests/github-publisher.mjs +61 -1
- package/dist/pull-requests/github-publisher.mjs.map +1 -1
- package/dist/pull-requests.d.mts +1 -0
- package/dist/sandbox/index.d.mts +1 -0
- package/dist/schema/agent-route.d.mts +19 -1
- package/dist/schema/agent-route.mjs +19 -1
- package/dist/schema/agent-route.mjs.map +1 -1
- package/dist/schema/factory-config.d.mts +27 -0
- package/dist/schema/factory-config.mjs +33 -3
- package/dist/schema/factory-config.mjs.map +1 -1
- package/dist/schema/repository.d.mts +4 -0
- package/dist/schema/repository.mjs +5 -1
- package/dist/schema/repository.mjs.map +1 -1
- package/dist/schema/session.d.mts +1 -0
- package/dist/schema/session.mjs +1 -0
- package/dist/schema/session.mjs.map +1 -1
- package/dist/schema/slack-pr-notifications.d.mts +12 -0
- package/dist/schema/slack-pr-notifications.mjs +11 -0
- package/dist/schema/slack-pr-notifications.mjs.map +1 -0
- package/dist/schema/task-graph.d.mts +39 -0
- package/dist/schema/task.d.mts +1 -0
- package/dist/schema/task.mjs +2 -1
- package/dist/schema/task.mjs.map +1 -1
- package/dist/schema/transcript.d.mts +6 -0
- package/dist/schema/transcript.mjs +2 -1
- package/dist/schema/transcript.mjs.map +1 -1
- package/dist/schema/work.d.mts +52 -3
- package/dist/schema/work.mjs.map +1 -1
- package/dist/session-previews.d.mts +76 -0
- package/dist/session-previews.mjs +55 -0
- package/dist/session-previews.mjs.map +1 -0
- package/dist/session-review.d.mts +120 -0
- package/dist/session-review.mjs +79 -0
- package/dist/session-review.mjs.map +1 -0
- package/dist/signal-triage.mjs +1 -1
- package/dist/signals.d.mts +1 -0
- package/dist/stall.d.mts +4 -1
- package/dist/stall.mjs +6 -2
- package/dist/stall.mjs.map +1 -1
- package/dist/store/driver.d.mts +1 -1
- package/dist/store/driver.mjs.map +1 -1
- package/dist/store/engine.d.mts +206 -8
- package/dist/store/engine.mjs +147 -13
- package/dist/store/engine.mjs.map +1 -1
- package/dist/store/memory.d.mts +18 -1
- package/dist/store/memory.mjs +18 -1
- package/dist/store/memory.mjs.map +1 -1
- package/dist/store/slack-pr-notifications.d.mts +44 -0
- package/dist/store/slack-pr-notifications.mjs +121 -0
- package/dist/store/slack-pr-notifications.mjs.map +1 -0
- package/dist/store/task-work.d.mts +121 -6
- package/dist/store/task-work.mjs +7 -4
- package/dist/store/task-work.mjs.map +1 -1
- package/dist/sweep.d.mts +28 -6
- package/dist/sweep.mjs +34 -6
- package/dist/sweep.mjs.map +1 -1
- package/dist/task-graph-view.d.mts +3 -0
- package/dist/tasks.d.mts +3 -3
- package/dist/tasks.mjs +3 -3
- package/dist/vercel-git.d.mts +35 -3
- package/dist/vercel-git.mjs +265 -33
- package/dist/vercel-git.mjs.map +1 -1
- package/dist/vercel-github-api.d.mts +103 -0
- package/dist/vercel-github-api.mjs +363 -0
- package/dist/vercel-github-api.mjs.map +1 -0
- package/dist/vercel.d.mts +3 -2
- package/dist/vercel.mjs +3 -2
- package/dist/vercel.mjs.map +1 -1
- package/dist/work-triage.d.mts +1 -0
- package/dist/workflows.d.mts +102 -4
- package/dist/workflows.mjs +55 -2
- package/dist/workflows.mjs.map +1 -1
- package/dist/workspace-files-git.d.mts +15 -0
- package/dist/workspace-files-git.mjs +61 -0
- package/dist/workspace-files-git.mjs.map +1 -0
- package/dist/workspace-files.d.mts +107 -0
- package/dist/workspace-files.mjs +74 -0
- package/dist/workspace-files.mjs.map +1 -0
- package/docs/getting-started.md +104 -0
- package/docs/index.md +100 -0
- package/docs/recipes/cancellation.md +215 -0
- package/docs/recipes/custom-workflow.md +153 -0
- package/docs/recipes/dependent-tasks.md +207 -0
- package/docs/recipes/eve-agent.md +277 -0
- package/docs/recipes/human-input.md +204 -0
- package/docs/recipes/persistence-recovery.md +268 -0
- package/docs/recipes/retry-recovery.md +241 -0
- package/docs/recipes/task-messaging.md +215 -0
- package/docs/recipes/typed-eve-result.md +161 -0
- package/docs/runtime-integration.md +137 -0
- package/package.json +20 -6
package/dist/github.mjs.map
CHANGED
|
@@ -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 }),\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/** 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 explicitly addressed pull-request review comment. */\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 an explicitly addressed inline review comment into trusted routing fields. */\nexport function normalizeFactoryReviewComment(\n input: NormalizeFactoryCommentInput,\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 ) {\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 returned by GitHub. */\nexport interface GitHubReviewComment {\n id: number;\n pullRequestNumber: number;\n body: string;\n url: string;\n author: string;\n inReplyToId: 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}\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 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/** Normalized issue-style comment from a pull-request conversation. */\nexport interface GitHubIssueComment {\n id: number;\n body: string;\n url: string;\n author: string;\n authorType: \"Bot\" | \"User\" | \"Organization\";\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/** 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 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) }),\n in_reply_to_id: z.number().int().positive().nullish(),\n});\n\nconst submittedReviewSchema = z.object({\n id: z.number().int().positive(),\n html_url: z.url(),\n state: z.string().min(1),\n});\n\nconst issueCommentSchema = z.object({\n id: z.number().int().positive(),\n body: z.string(),\n html_url: z.url(),\n user: z.object({\n login: z.string().min(1),\n type: z.enum([\"Bot\", \"User\", \"Organization\"]),\n }),\n});\n\nconst checkRunSchema = z.object({\n id: z.number().int().positive(),\n name: z.string().min(1),\n head_sha: z.string().regex(/^[0-9a-f]{40}$/),\n status: z.enum([\"queued\", \"in_progress\", \"completed\", \"waiting\", \"requested\", \"pending\"]),\n conclusion: z\n .enum([\n \"action_required\",\n \"cancelled\",\n \"failure\",\n \"neutral\",\n \"skipped\",\n \"success\",\n \"timed_out\",\n \"stale\",\n \"startup_failure\",\n ])\n .nullable(),\n html_url: z.url().nullable(),\n details_url: z.url().nullable(),\n external_id: z.string().nullable(),\n started_at: z.string().nullable(),\n completed_at: z.string().nullable(),\n});\n\nconst checkRunsSchema = z.object({ check_runs: z.array(checkRunSchema) });\nconst labelsSchema = z.array(z.object({ name: z.string().min(1) }));\nconst pullRequestCandidateSchema = z.object({\n number: z.number().int().positive(),\n user: z.object({ type: z.string().min(1) }),\n head: z.object({\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;\n\n constructor(author: string) {\n super(`GitHub user ${author} does not have write access to the repository`);\n this.name = \"GitHubReviewCommentAuthorError\";\n this.author = author;\n }\n}\n\n/**\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/** 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,\n authorType: comment.user.type,\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 await readReviewComment(input);\n const reply = parseReviewComment(\n await gitHubRequest(\n input,\n `/pulls/${positiveInteger(input.pullRequestNumber, \"pullRequestNumber\")}/comments/${positiveInteger(input.commentId, \"commentId\")}/replies`,\n { method: \"POST\", body: JSON.stringify({ body: input.body }) },\n ),\n );\n 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 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: (input.comments ?? []).map((comment) => ({\n path: comment.path,\n line: positiveInteger(comment.line, \"comment line\"),\n side: \"RIGHT\",\n body: comment.body,\n })),\n }),\n },\n ),\n );\n return { id: review.id, url: review.html_url, state: review.state };\n}\n\n/** Read the current head branch and commit of a pull request. */\nexport async function readPullRequestHead(\n input: 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 };\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 };\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 open pull requests in a repository, newest first, to check for existing work before triage. */\nexport async function listOpenPullRequests(\n input: ListOpenPullRequestsInput,\n): Promise<readonly OpenPullRequest[]> {\n const pulls = z\n .array(openPullRequestSummarySchema)\n .parse(\n await gitHubRequest(input, `/pulls?state=open&per_page=100&sort=created&direction=desc`),\n );\n return pulls.map((pull) => ({\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}\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\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 Error(\n `GitHub API request failed (${response.status}): ${message.success ? message.data.message : response.statusText}`,\n );\n }\n return body;\n}\n\nfunction parseReviewComment(value: unknown): GitHubReviewComment {\n const comment = reviewCommentSchema.parse(value);\n 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,\n inReplyToId: comment.in_reply_to_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,\n authorType: comment.user.type,\n };\n}\n\nfunction parseLabels(value: unknown): string[] {\n return labelsSchema.parse(value).map(({ name }) => name);\n}\n\nfunction parseCheckRun(value: unknown): GitHubCheckRun {\n const checkRun = checkRunSchema.parse(value);\n return {\n id: checkRun.id,\n name: checkRun.name,\n headSha: checkRun.head_sha,\n status: checkRun.status,\n conclusion: checkRun.conclusion,\n url: checkRun.html_url,\n detailsUrl: checkRun.details_url,\n externalId: checkRun.external_id,\n startedAt: checkRun.started_at,\n completedAt: checkRun.completed_at,\n };\n}\n\nfunction checkRunFields(input: CheckRunFields): Record<string, unknown> {\n return {\n ...(input.status === undefined ? {} : { status: input.status }),\n ...(input.conclusion === undefined ? {} : { conclusion: input.conclusion }),\n ...(input.detailsUrl === undefined ? {} : { details_url: input.detailsUrl }),\n ...(input.externalId === undefined ? {} : { external_id: input.externalId }),\n ...(input.startedAt === undefined ? {} : { started_at: input.startedAt }),\n ...(input.completedAt === undefined ? {} : { completed_at: input.completedAt }),\n ...(input.output === undefined ? {} : { output: checkRunOutput(input.output) }),\n };\n}\n\nfunction 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,\n): Promise<void> {\n if (input.authorPolicy === \"any\") {\n return;\n }\n if (!(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,YAA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Q,UAAU,gBACpB,OAAO;CAET,MAAM,SAAS,wBAAwB,UAAU,QAAQ,OAAO;CAChE,IAAI,CAAC,OAAO,WAAW,OAAO,KAAK,WAAW,UAC5C,OAAO;CAET,MAAM,KAAK,OAAO,KAAK;CACvB,MAAM,SAAS,OAAO,KAAK,OAAO;CAClC,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/** 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}\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 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 };\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 };\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 open pull requests in a repository, newest first, to check for existing work before triage. */\nexport async function listOpenPullRequests(\n input: ListOpenPullRequestsInput,\n): Promise<readonly OpenPullRequest[]> {\n const pulls = z\n .array(openPullRequestSummarySchema)\n .parse(\n await gitHubRequest(input, `/pulls?state=open&per_page=100&sort=created&direction=desc`),\n );\n return pulls.map((pull) => ({\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}\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;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Q;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"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/inbox-activity.d.ts
|
|
3
|
+
/** Validates one application-owned attention item, independent of a Factory session. */
|
|
4
|
+
declare const inboxActivityItemSchema: z.ZodObject<{
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
repository: z.ZodType<`${string}/${string}`, string, z.core.$ZodTypeInternals<`${string}/${string}`, string>>;
|
|
7
|
+
source: z.ZodString;
|
|
8
|
+
title: z.ZodString;
|
|
9
|
+
category: z.ZodString;
|
|
10
|
+
label: z.ZodString;
|
|
11
|
+
summary: z.ZodString;
|
|
12
|
+
url: z.ZodURL;
|
|
13
|
+
updatedAt: z.ZodISODateTime;
|
|
14
|
+
revision: z.ZodNullable<z.ZodString>;
|
|
15
|
+
details: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
16
|
+
text: z.ZodString;
|
|
17
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
18
|
+
}, z.core.$strict>>>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
/** Validates an optional, bounded external attention projection. */
|
|
21
|
+
declare const inboxActivitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
22
|
+
state: z.ZodLiteral<"ready">;
|
|
23
|
+
capturedAt: z.ZodISODateTime;
|
|
24
|
+
items: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
repository: z.ZodType<`${string}/${string}`, string, z.core.$ZodTypeInternals<`${string}/${string}`, string>>;
|
|
27
|
+
source: z.ZodString;
|
|
28
|
+
title: z.ZodString;
|
|
29
|
+
category: z.ZodString;
|
|
30
|
+
label: z.ZodString;
|
|
31
|
+
summary: z.ZodString;
|
|
32
|
+
url: z.ZodURL;
|
|
33
|
+
updatedAt: z.ZodISODateTime;
|
|
34
|
+
revision: z.ZodNullable<z.ZodString>;
|
|
35
|
+
details: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
36
|
+
text: z.ZodString;
|
|
37
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
38
|
+
}, z.core.$strict>>>;
|
|
39
|
+
}, z.core.$strict>>>;
|
|
40
|
+
limitations: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
41
|
+
truncated: z.ZodBoolean;
|
|
42
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
43
|
+
state: z.ZodLiteral<"unavailable">;
|
|
44
|
+
capturedAt: z.ZodISODateTime;
|
|
45
|
+
reason: z.ZodString;
|
|
46
|
+
}, z.core.$strict>], "state">;
|
|
47
|
+
/** One application-owned attention item and its evidence. */
|
|
48
|
+
type InboxActivityItem = z.infer<typeof inboxActivityItemSchema>;
|
|
49
|
+
/** Read-only activity supplied by an optional application reader. */
|
|
50
|
+
type InboxActivity = z.infer<typeof inboxActivitySchema>;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { InboxActivity, InboxActivityItem, inboxActivityItemSchema, inboxActivitySchema };
|
|
53
|
+
//# sourceMappingURL=inbox-activity.d.mts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { repositorySlugSchema } from "./schema/repository.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/inbox-activity.ts
|
|
4
|
+
const text = z.string().trim().min(1);
|
|
5
|
+
const link = z.url().refine((value) => {
|
|
6
|
+
const url = new URL(value);
|
|
7
|
+
return ["https:", "http:"].includes(url.protocol) && !url.username && !url.password;
|
|
8
|
+
}, "Use an HTTP(S) URL without credentials");
|
|
9
|
+
/** Validates one application-owned attention item, independent of a Factory session. */
|
|
10
|
+
const inboxActivityItemSchema = z.strictObject({
|
|
11
|
+
id: text.describe("Stable identity, unique across this reader's sources."),
|
|
12
|
+
repository: repositorySlugSchema.describe("Configured repository owning this item."),
|
|
13
|
+
source: text.describe("Name of the external activity source."),
|
|
14
|
+
title: text.describe("Work requiring operator attention."),
|
|
15
|
+
category: text.describe("Application-owned grouping key."),
|
|
16
|
+
label: text.describe("Human-readable attention category."),
|
|
17
|
+
summary: text.describe("Why this item needs attention."),
|
|
18
|
+
url: link.describe("Source page where the operator can inspect or act."),
|
|
19
|
+
updatedAt: z.iso.datetime().describe("Last update reported by the source."),
|
|
20
|
+
revision: text.nullable().describe("Exact code revision, or null when unknown."),
|
|
21
|
+
details: z.array(z.strictObject({
|
|
22
|
+
text: text.describe("Check, reviewer, or feedback detail."),
|
|
23
|
+
url: link.optional().describe("Optional source link for this detail.")
|
|
24
|
+
})).readonly().describe("Bounded details supplied by the source.")
|
|
25
|
+
});
|
|
26
|
+
/** Validates an optional, bounded external attention projection. */
|
|
27
|
+
const inboxActivitySchema = z.discriminatedUnion("state", [z.strictObject({
|
|
28
|
+
state: z.literal("ready").describe("The reader completed, possibly with partial results."),
|
|
29
|
+
capturedAt: z.iso.datetime().describe("When the source was read; caches preserve this time."),
|
|
30
|
+
items: z.array(inboxActivityItemSchema).readonly().describe("Items requiring attention."),
|
|
31
|
+
limitations: z.array(text).readonly().describe("Unavailable sources or incomplete evidence."),
|
|
32
|
+
truncated: z.boolean().describe("Whether configured limits or failures omitted information.")
|
|
33
|
+
}), z.strictObject({
|
|
34
|
+
state: z.literal("unavailable").describe("No external activity projection is available."),
|
|
35
|
+
capturedAt: z.iso.datetime().describe("When availability was checked."),
|
|
36
|
+
reason: text.describe("Why the activity could not be read.")
|
|
37
|
+
})]);
|
|
38
|
+
//#endregion
|
|
39
|
+
export { inboxActivityItemSchema, inboxActivitySchema };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=inbox-activity.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox-activity.mjs","names":[],"sources":["../src/inbox-activity.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { repositorySlugSchema } from \"./schema/repository\";\n\nconst text = z.string().trim().min(1);\nconst link = z.url().refine((value) => {\n const url = new URL(value);\n return [\"https:\", \"http:\"].includes(url.protocol) && !url.username && !url.password;\n}, \"Use an HTTP(S) URL without credentials\");\n\n/** Validates one application-owned attention item, independent of a Factory session. */\nexport const inboxActivityItemSchema = z.strictObject({\n id: text.describe(\"Stable identity, unique across this reader's sources.\"),\n repository: repositorySlugSchema.describe(\"Configured repository owning this item.\"),\n source: text.describe(\"Name of the external activity source.\"),\n title: text.describe(\"Work requiring operator attention.\"),\n category: text.describe(\"Application-owned grouping key.\"),\n label: text.describe(\"Human-readable attention category.\"),\n summary: text.describe(\"Why this item needs attention.\"),\n url: link.describe(\"Source page where the operator can inspect or act.\"),\n updatedAt: z.iso.datetime().describe(\"Last update reported by the source.\"),\n revision: text.nullable().describe(\"Exact code revision, or null when unknown.\"),\n details: z\n .array(\n z.strictObject({\n text: text.describe(\"Check, reviewer, or feedback detail.\"),\n url: link.optional().describe(\"Optional source link for this detail.\"),\n }),\n )\n .readonly()\n .describe(\"Bounded details supplied by the source.\"),\n});\n\n/** Validates an optional, bounded external attention projection. */\nexport const inboxActivitySchema = z.discriminatedUnion(\"state\", [\n z.strictObject({\n state: z.literal(\"ready\").describe(\"The reader completed, possibly with partial results.\"),\n capturedAt: z.iso.datetime().describe(\"When the source was read; caches preserve this time.\"),\n items: z.array(inboxActivityItemSchema).readonly().describe(\"Items requiring attention.\"),\n limitations: z.array(text).readonly().describe(\"Unavailable sources or incomplete evidence.\"),\n truncated: z.boolean().describe(\"Whether configured limits or failures omitted information.\"),\n }),\n z.strictObject({\n state: z.literal(\"unavailable\").describe(\"No external activity projection is available.\"),\n capturedAt: z.iso.datetime().describe(\"When availability was checked.\"),\n reason: text.describe(\"Why the activity could not be read.\"),\n }),\n]);\n\n/** One application-owned attention item and its evidence. */\nexport type InboxActivityItem = z.infer<typeof inboxActivityItemSchema>;\n/** Read-only activity supplied by an optional application reader. */\nexport type InboxActivity = z.infer<typeof inboxActivitySchema>;\n"],"mappings":";;;AAGA,MAAM,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;AACpC,MAAM,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ,UAAU;CACrC,MAAM,MAAM,IAAI,IAAI,KAAK;CACzB,OAAO,CAAC,UAAU,OAAO,CAAC,CAAC,SAAS,IAAI,QAAQ,KAAK,CAAC,IAAI,YAAY,CAAC,IAAI;AAC7E,GAAG,wCAAwC;;AAG3C,MAAa,0BAA0B,EAAE,aAAa;CACpD,IAAI,KAAK,SAAS,uDAAuD;CACzE,YAAY,qBAAqB,SAAS,yCAAyC;CACnF,QAAQ,KAAK,SAAS,uCAAuC;CAC7D,OAAO,KAAK,SAAS,oCAAoC;CACzD,UAAU,KAAK,SAAS,iCAAiC;CACzD,OAAO,KAAK,SAAS,oCAAoC;CACzD,SAAS,KAAK,SAAS,gCAAgC;CACvD,KAAK,KAAK,SAAS,oDAAoD;CACvE,WAAW,EAAE,IAAI,SAAS,CAAC,CAAC,SAAS,qCAAqC;CAC1E,UAAU,KAAK,SAAS,CAAC,CAAC,SAAS,4CAA4C;CAC/E,SAAS,EACN,MACC,EAAE,aAAa;EACb,MAAM,KAAK,SAAS,sCAAsC;EAC1D,KAAK,KAAK,SAAS,CAAC,CAAC,SAAS,uCAAuC;CACvE,CAAC,CACH,CAAC,CACA,SAAS,CAAC,CACV,SAAS,yCAAyC;AACvD,CAAC;;AAGD,MAAa,sBAAsB,EAAE,mBAAmB,SAAS,CAC/D,EAAE,aAAa;CACb,OAAO,EAAE,QAAQ,OAAO,CAAC,CAAC,SAAS,sDAAsD;CACzF,YAAY,EAAE,IAAI,SAAS,CAAC,CAAC,SAAS,sDAAsD;CAC5F,OAAO,EAAE,MAAM,uBAAuB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,4BAA4B;CACxF,aAAa,EAAE,MAAM,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,6CAA6C;CAC5F,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS,4DAA4D;AAC9F,CAAC,GACD,EAAE,aAAa;CACb,OAAO,EAAE,QAAQ,aAAa,CAAC,CAAC,SAAS,+CAA+C;CACxF,YAAY,EAAE,IAAI,SAAS,CAAC,CAAC,SAAS,gCAAgC;CACtE,QAAQ,KAAK,SAAS,qCAAqC;AAC7D,CAAC,CACH,CAAC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { FactoryId, RepositoryId, RepositoryIds, factoryIdSchema, repositoryIdSchema, repositoryIdsSchema, repositoryScope } from "./schema/id.mjs";
|
|
2
3
|
import { Repository, RepositorySlug, repositorySchema, repositorySlugSchema } from "./schema/repository.mjs";
|
|
3
4
|
import { DateClock, IsoDateTimeClock, MaybePromise, MillisecondClock, SCHEMA_VERSION, isoDateTimeSchema, schemaVersionSchema, usdSchema, vocabularySchema } from "./schema/common.mjs";
|
|
4
5
|
import { InvalidTransitionError, Transition, TransitionActor, TransitionInput, assertTransition, isTransitionAllowed, legalNextStates, terminalStates } from "./schema/transitions.mjs";
|
|
5
6
|
import { deriveFactoryId } from "./budget.mjs";
|
|
6
7
|
import { ExecutionPolicy, FactoryConfig, FactoryConfigInput, FactoryConfigRepository, FactoryConfigRepositoryInput, defaultExecutionPolicy, defineFactory, executionPolicySchema, factoryConfigRepositorySchema, factoryConfigSchema } from "./schema/factory-config.mjs";
|
|
8
|
+
import { requireTaskExecution } from "./eve/task-execution.mjs";
|
|
7
9
|
import { EnsureConfiguredRepositoryInput, ensureConfiguredRepository, repositoryIdForSlug } from "./repositories.mjs";
|
|
8
10
|
import { RedactedErrorDetails, redactedErrorDetails, redactedErrorMessage } from "./errors.mjs";
|
|
9
11
|
import { EveTranscriptMaterializer, EveTranscriptMaterializerOptions, EveTranscriptRequestScope, TranscriptMaterializationInput, createEveTranscriptMaterializer } from "./eve/transcript.mjs";
|
|
@@ -11,4 +13,4 @@ import { ConversationBinding, FactoryConversationSessionBinding, conversationBin
|
|
|
11
13
|
import { CancelEveSessionOptions, EveSessionEvent, EveSessionStream, EveSessionStreamInput, ForwardEveSessionRequestOptions, ReadCompletedEveTurnOptions, StartEveSessionOptions, cancelEveSession, forwardEveSessionRequest, readCompletedEveTurn, startEveSession } from "./eve/session-client.mjs";
|
|
12
14
|
import { DelegateAgentLaunchInput, DelegateAgentTool, DelegateAgentToolInput, DelegateAgentToolOptions, DelegateAgentToolStores, DelegateWorkflowInput, DelegateWorkflowPolicy, DelegateWorkflowResult, InvokeAgentTool, InvokeAgentToolInput, InvokeAgentToolOptions, InvokeAgentToolResult, InvokeAgentToolStores, createDelegateAgentTool, createInvokeAgentTool } from "./eve/invoke.mjs";
|
|
13
15
|
import { AnswerQuestionTool, AnswerQuestionToolInput, AppendReceiptTool, AppendReceiptToolInput, ConversationCompletionResult, DecideSignalTool, DecideSignalToolInput, FactoryHooks, FactoryHooksOptions, FactoryHooksStores, FinishTaskRefusal, FinishTaskSuccess, FinishTaskTool, FinishTaskToolInput, FinishTaskToolResult, GetTaskTool, GetTaskToolInput, GetTaskToolResult, HumanInputQuestion, PresentQuestion, RequestHumanInputTool, RequestHumanInputToolInput, TaskNotFoundResult, TaskTools, TaskToolsOptions, TaskToolsStores, TranscriptSnapshotHook, createFactoryHooks, createTaskTools, createTranscriptSnapshotHook } from "./eve/index.mjs";
|
|
14
|
-
export { type AnswerQuestionTool, type AnswerQuestionToolInput, type AppendReceiptTool, type AppendReceiptToolInput, type CancelEveSessionOptions, type ConversationBinding, type ConversationCompletionResult, type DateClock, type DecideSignalTool, type DecideSignalToolInput, type DelegateAgentLaunchInput, type DelegateAgentTool, type DelegateAgentToolInput, type DelegateAgentToolOptions, type DelegateAgentToolStores, type DelegateWorkflowInput, type DelegateWorkflowPolicy, type DelegateWorkflowResult, type EnsureConfiguredRepositoryInput, type EveSessionEvent, type EveSessionStream, type EveSessionStreamInput, type EveTranscriptMaterializer, type EveTranscriptMaterializerOptions, type EveTranscriptRequestScope, type ExecutionPolicy, type FactoryConfig, type FactoryConfigInput, type FactoryConfigRepository, type FactoryConfigRepositoryInput, type FactoryConversationSessionBinding, type FactoryHooks, type FactoryHooksOptions, type FactoryHooksStores, type FactoryId, type FinishTaskRefusal, type FinishTaskSuccess, type FinishTaskTool, type FinishTaskToolInput, type FinishTaskToolResult, type ForwardEveSessionRequestOptions, type GetTaskTool, type GetTaskToolInput, type GetTaskToolResult, type HumanInputQuestion, InvalidTransitionError, type InvokeAgentTool, type InvokeAgentToolInput, type InvokeAgentToolOptions, type InvokeAgentToolResult, type InvokeAgentToolStores, type IsoDateTimeClock, type MaybePromise, type MillisecondClock, type PresentQuestion, type ReadCompletedEveTurnOptions, type RedactedErrorDetails, type Repository, type RepositoryId, type RepositoryIds, type RepositorySlug, type RequestHumanInputTool, type RequestHumanInputToolInput, SCHEMA_VERSION, type StartEveSessionOptions, type TaskNotFoundResult, type TaskTools, type TaskToolsOptions, type TaskToolsStores, type TranscriptMaterializationInput, type TranscriptSnapshotHook, type Transition, type TransitionActor, type TransitionInput, assertTransition, cancelEveSession, conversationBinding, conversationBindingForSession, conversationHeaders, createDelegateAgentTool, createEveTranscriptMaterializer, createFactoryHooks, createInvokeAgentTool, createTaskTools, createTranscriptSnapshotHook, defaultExecutionPolicy, defineFactory, deriveFactoryId, ensureConfiguredRepository, executionPolicySchema, factoryConfigRepositorySchema, factoryConfigSchema, factoryIdSchema, factoryReplyAddressAttribute, factoryReplyAddressHeader, factoryReplyChannelAttribute, factoryReplyChannelHeader, factoryRepositoryIdsAttribute, factoryRepositoryIdsHeader, factoryTaskAttemptAttribute, factoryTaskAttemptHeader, factoryTaskAttribute, factoryTaskHeader, forwardEveSessionRequest, hasFactoryTaskBinding, isTransitionAllowed, isoDateTimeSchema, legalNextStates, optionalTaskIdForSession, readCompletedEveTurn, redactedErrorDetails, redactedErrorMessage, replyToForSession, repositoryIdForSlug, repositoryIdSchema, repositoryIdsForSession, repositoryIdsSchema, repositorySchema, repositoryScope, repositorySlugSchema, requireTaskIdForSession, schemaVersionSchema, startEveSession, taskBindingForSession, taskHeaders, taskSessionAuth, terminalStates, usdSchema, vocabularySchema, withFactoryTask, withOptionalFactoryTask };
|
|
16
|
+
export { type AnswerQuestionTool, type AnswerQuestionToolInput, type AppendReceiptTool, type AppendReceiptToolInput, type CancelEveSessionOptions, type ConversationBinding, type ConversationCompletionResult, type DateClock, type DecideSignalTool, type DecideSignalToolInput, type DelegateAgentLaunchInput, type DelegateAgentTool, type DelegateAgentToolInput, type DelegateAgentToolOptions, type DelegateAgentToolStores, type DelegateWorkflowInput, type DelegateWorkflowPolicy, type DelegateWorkflowResult, type EnsureConfiguredRepositoryInput, type EveSessionEvent, type EveSessionStream, type EveSessionStreamInput, type EveTranscriptMaterializer, type EveTranscriptMaterializerOptions, type EveTranscriptRequestScope, type ExecutionPolicy, type FactoryConfig, type FactoryConfigInput, type FactoryConfigRepository, type FactoryConfigRepositoryInput, type FactoryConversationSessionBinding, type FactoryHooks, type FactoryHooksOptions, type FactoryHooksStores, type FactoryId, type FinishTaskRefusal, type FinishTaskSuccess, type FinishTaskTool, type FinishTaskToolInput, type FinishTaskToolResult, type ForwardEveSessionRequestOptions, type GetTaskTool, type GetTaskToolInput, type GetTaskToolResult, type HumanInputQuestion, InvalidTransitionError, type InvokeAgentTool, type InvokeAgentToolInput, type InvokeAgentToolOptions, type InvokeAgentToolResult, type InvokeAgentToolStores, type IsoDateTimeClock, type MaybePromise, type MillisecondClock, type PresentQuestion, type ReadCompletedEveTurnOptions, type RedactedErrorDetails, type Repository, type RepositoryId, type RepositoryIds, type RepositorySlug, type RequestHumanInputTool, type RequestHumanInputToolInput, SCHEMA_VERSION, type StartEveSessionOptions, type TaskNotFoundResult, type TaskTools, type TaskToolsOptions, type TaskToolsStores, type TranscriptMaterializationInput, type TranscriptSnapshotHook, type Transition, type TransitionActor, type TransitionInput, assertTransition, cancelEveSession, conversationBinding, conversationBindingForSession, conversationHeaders, createDelegateAgentTool, createEveTranscriptMaterializer, createFactoryHooks, createInvokeAgentTool, createTaskTools, createTranscriptSnapshotHook, defaultExecutionPolicy, defineFactory, deriveFactoryId, ensureConfiguredRepository, executionPolicySchema, factoryConfigRepositorySchema, factoryConfigSchema, factoryIdSchema, factoryReplyAddressAttribute, factoryReplyAddressHeader, factoryReplyChannelAttribute, factoryReplyChannelHeader, factoryRepositoryIdsAttribute, factoryRepositoryIdsHeader, factoryTaskAttemptAttribute, factoryTaskAttemptHeader, factoryTaskAttribute, factoryTaskHeader, forwardEveSessionRequest, hasFactoryTaskBinding, isTransitionAllowed, isoDateTimeSchema, legalNextStates, optionalTaskIdForSession, readCompletedEveTurn, redactedErrorDetails, redactedErrorMessage, replyToForSession, repositoryIdForSlug, repositoryIdSchema, repositoryIdsForSession, repositoryIdsSchema, repositorySchema, repositoryScope, repositorySlugSchema, requireTaskExecution, requireTaskIdForSession, schemaVersionSchema, startEveSession, taskBindingForSession, taskHeaders, taskSessionAuth, terminalStates, usdSchema, vocabularySchema, withFactoryTask, withOptionalFactoryTask };
|
package/dist/index.mjs
CHANGED
|
@@ -2,13 +2,14 @@ import { factoryIdSchema, repositoryIdSchema, repositoryIdsSchema, repositorySco
|
|
|
2
2
|
import { SCHEMA_VERSION, isoDateTimeSchema, schemaVersionSchema, usdSchema, vocabularySchema } from "./schema/common.mjs";
|
|
3
3
|
import { repositorySchema, repositorySlugSchema } from "./schema/repository.mjs";
|
|
4
4
|
import { deriveFactoryId } from "./budget.mjs";
|
|
5
|
+
import { conversationBinding, conversationBindingForSession, conversationHeaders, factoryReplyAddressAttribute, factoryReplyAddressHeader, factoryReplyChannelAttribute, factoryReplyChannelHeader, factoryRepositoryIdsAttribute, factoryRepositoryIdsHeader, factoryTaskAttemptAttribute, factoryTaskAttemptHeader, factoryTaskAttribute, factoryTaskHeader, hasFactoryTaskBinding, optionalTaskIdForSession, replyToForSession, repositoryIdsForSession, requireTaskIdForSession, taskBindingForSession, taskHeaders, taskSessionAuth, withFactoryTask, withOptionalFactoryTask } from "./eve/task-session.mjs";
|
|
6
|
+
import { requireTaskExecution } from "./eve/task-execution.mjs";
|
|
5
7
|
import { ensureConfiguredRepository, repositoryIdForSlug } from "./repositories.mjs";
|
|
6
8
|
import { defaultExecutionPolicy, defineFactory, executionPolicySchema, factoryConfigRepositorySchema, factoryConfigSchema } from "./schema/factory-config.mjs";
|
|
7
9
|
import { InvalidTransitionError, assertTransition, isTransitionAllowed, legalNextStates, terminalStates } from "./schema/transitions.mjs";
|
|
8
10
|
import { redactedErrorDetails, redactedErrorMessage } from "./errors.mjs";
|
|
9
|
-
import { conversationBinding, conversationBindingForSession, conversationHeaders, factoryReplyAddressAttribute, factoryReplyAddressHeader, factoryReplyChannelAttribute, factoryReplyChannelHeader, factoryRepositoryIdsAttribute, factoryRepositoryIdsHeader, factoryTaskAttemptAttribute, factoryTaskAttemptHeader, factoryTaskAttribute, factoryTaskHeader, hasFactoryTaskBinding, optionalTaskIdForSession, replyToForSession, repositoryIdsForSession, requireTaskIdForSession, taskBindingForSession, taskHeaders, taskSessionAuth, withFactoryTask, withOptionalFactoryTask } from "./eve/task-session.mjs";
|
|
10
11
|
import { createEveTranscriptMaterializer } from "./eve/transcript.mjs";
|
|
11
12
|
import { cancelEveSession, forwardEveSessionRequest, readCompletedEveTurn, startEveSession } from "./eve/session-client.mjs";
|
|
12
13
|
import { createDelegateAgentTool, createInvokeAgentTool } from "./eve/invoke.mjs";
|
|
13
14
|
import { createFactoryHooks, createTaskTools, createTranscriptSnapshotHook } from "./eve/index.mjs";
|
|
14
|
-
export { InvalidTransitionError, SCHEMA_VERSION, assertTransition, cancelEveSession, conversationBinding, conversationBindingForSession, conversationHeaders, createDelegateAgentTool, createEveTranscriptMaterializer, createFactoryHooks, createInvokeAgentTool, createTaskTools, createTranscriptSnapshotHook, defaultExecutionPolicy, defineFactory, deriveFactoryId, ensureConfiguredRepository, executionPolicySchema, factoryConfigRepositorySchema, factoryConfigSchema, factoryIdSchema, factoryReplyAddressAttribute, factoryReplyAddressHeader, factoryReplyChannelAttribute, factoryReplyChannelHeader, factoryRepositoryIdsAttribute, factoryRepositoryIdsHeader, factoryTaskAttemptAttribute, factoryTaskAttemptHeader, factoryTaskAttribute, factoryTaskHeader, forwardEveSessionRequest, hasFactoryTaskBinding, isTransitionAllowed, isoDateTimeSchema, legalNextStates, optionalTaskIdForSession, readCompletedEveTurn, redactedErrorDetails, redactedErrorMessage, replyToForSession, repositoryIdForSlug, repositoryIdSchema, repositoryIdsForSession, repositoryIdsSchema, repositorySchema, repositoryScope, repositorySlugSchema, requireTaskIdForSession, schemaVersionSchema, startEveSession, taskBindingForSession, taskHeaders, taskSessionAuth, terminalStates, usdSchema, vocabularySchema, withFactoryTask, withOptionalFactoryTask };
|
|
15
|
+
export { InvalidTransitionError, SCHEMA_VERSION, assertTransition, cancelEveSession, conversationBinding, conversationBindingForSession, conversationHeaders, createDelegateAgentTool, createEveTranscriptMaterializer, createFactoryHooks, createInvokeAgentTool, createTaskTools, createTranscriptSnapshotHook, defaultExecutionPolicy, defineFactory, deriveFactoryId, ensureConfiguredRepository, executionPolicySchema, factoryConfigRepositorySchema, factoryConfigSchema, factoryIdSchema, factoryReplyAddressAttribute, factoryReplyAddressHeader, factoryReplyChannelAttribute, factoryReplyChannelHeader, factoryRepositoryIdsAttribute, factoryRepositoryIdsHeader, factoryTaskAttemptAttribute, factoryTaskAttemptHeader, factoryTaskAttribute, factoryTaskHeader, forwardEveSessionRequest, hasFactoryTaskBinding, isTransitionAllowed, isoDateTimeSchema, legalNextStates, optionalTaskIdForSession, readCompletedEveTurn, redactedErrorDetails, redactedErrorMessage, replyToForSession, repositoryIdForSlug, repositoryIdSchema, repositoryIdsForSession, repositoryIdsSchema, repositorySchema, repositoryScope, repositorySlugSchema, requireTaskExecution, requireTaskIdForSession, schemaVersionSchema, startEveSession, taskBindingForSession, taskHeaders, taskSessionAuth, terminalStates, usdSchema, vocabularySchema, withFactoryTask, withOptionalFactoryTask };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { DeepsecExport, DeepsecExportInput, DeepsecFinding, DeepsecFindingInput, deepsecExportSchema, deepsecFindingSchema, findingFromDeepsec } from "../deepsec/finding.mjs";
|
|
2
3
|
import { DeepsecAgent, DeepsecCommandResult, DeepsecCredentialCommandInput, DeepsecScanFailure, DeepsecScanFailureCode, DeepsecScanFinding, DeepsecScanInput, DeepsecScanResult, DeepsecScanSuccess, DeepsecScanTool, DeepsecScanToolOptions, DeepsecScanToolStores, DeepsecThinkingLevel, createDeepsecScanTool, deepsecScanInputSchema } from "../deepsec/eve-tool.mjs";
|
|
3
4
|
import "../deepsec.mjs";
|
|
@@ -1,11 +1,11 @@
|
|
|
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, FactoryMentionOptions, FactoryQuestionReply, FactoryReviewComment, GitHubCheckRun, GitHubCiFailureSignal, GitHubDefaultBranchPush, GitHubIssueComment, GitHubIssueCommentRecord, GitHubIssueSignal, GitHubPullRequest, GitHubPullRequestClosed, GitHubPullRequestHead, GitHubPullRequestReference, GitHubPullRequestSignal, GitHubPullRequestTarget, GitHubRepositoryAuthorRequest, GitHubRepositoryRequest, GitHubReviewComment, GitHubReviewCommentAuthorError, IncompleteCheckRunFields, ListCheckRunsForRefInput, ListConflictedPullRequestsInput, ListOpenPullRequestsInput, ListPullRequestCommentsInput, NormalizeFactoryCommentInput, ObservedCheckRunStatus, PullRequestLabelInput, PullRequestReviewComment, PullRequestReviewEvent, ReadReviewCommentInput, ReviewCommentAuthorPolicy, StalePullRequestHeadError, SubmitPullRequestReviewInput, SubmittedPullRequestReview, UpdateCheckRunInput, UpdatePullRequestCommentInput, VerifyGitHubSignatureInput, addLabel, answerReviewComment, closePullRequest, configuredEventRepositorySlug, createCheckRun, createPullRequest, createPullRequestComment, hasGitHubRepositoryWriteAccess, listCheckRunsForRef, listConflictedPullRequests, listOpenPullRequests, listPullRequestComments, 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, 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";
|
|
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";
|
|
8
8
|
import { GitHubPullRequestPublicationGate, GitHubPullRequestPublicationGateOptions, GitHubPullRequestPublisher, GitHubPullRequestPublisherOptions, PublishGitHubPullRequestInput, PushGitHubCheckpointInput, RequireTaskPullRequestInput, createGitHubPullRequestPublicationGate, createGitHubPullRequestPublisher } from "../pull-requests/github-publisher.mjs";
|
|
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
|
-
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 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 GitHubIssueSignal, type GitHubOpenPullRequestLister, type GitHubOpenPullRequestListerOptions, GitHubPublicationApiError, type GitHubPublicationClient, type GitHubPublicationClientOptions, type GitHubPublicationLimits, type GitHubPublicationPullRequest, type GitHubPullRequest, type GitHubPullRequestClosed, 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 ManageGitHubPullRequestLabelInput, type MarkGitHubPullRequestReadyInput, type MintGitHubAppInstallationTokenInput, type NormalizeFactoryCommentInput, type ObservedCheckRunStatus, 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, createGitHubOpenPullRequestLister, createGitHubPublicationClient, createGitHubPullRequestLabelManager, createGitHubPullRequestPublicationGate, createGitHubPullRequestPublisher, createGitHubReviewReporter, createPullRequest, createPullRequestComment, factorySessionBranch, factoryTaskBranch, hasGitHubRepositoryWriteAccess, isSafeGitRef, listCheckRunsForRef, listConflictedPullRequests, listOpenPullRequests, listPullRequestComments, mintGitHubAppInstallationToken, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, parseGitHubReplyAddress, readCommittedGitChange, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, renderGitHubCommunicationEvent, runSandboxGit, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };
|
|
11
|
+
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 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 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, 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, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, renderGitHubCommunicationEvent, runSandboxGit, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };
|