import type { CodeHitDTO, CommentResult, CommitFileResult, CommitFilesFileInput, DispatchResult, FileContentsDTO, IssueDTO, ListOrganizationRepositoriesInput, ListOrganizationRepositoriesResult, MergeResult, PullRequestDTO, PullRequestDetailDTO, BranchDTO, RepositoryDTO, ReviewCommentInput, ReviewResult, UpdateRepositoryInput, EnsureOrganizationRepositoryInput } from "./types.js"; /** Aggregate CI state of a PR's head commit. */ export type ChecksState = "green" | "pending" | "failing"; /** * The slice of GitHub the tasks need. Impls depend on this port so they can be * unit-tested with a fake; the default implementation wraps Octokit. */ export interface GitHubPort { listIssues(owner: string, repo: string, sinceISO: string | undefined, limit: number): Promise; addLabels(owner: string, repo: string, issueNumber: number, labels: string[]): Promise; openPR(owner: string, repo: string, input: { title: string; head: string; base: string; body?: string; draft?: boolean; }): Promise; reviewPR(owner: string, repo: string, number: number, event: "APPROVE" | "REQUEST_CHANGES" | "COMMENT", body: string | undefined, comments: ReviewCommentInput[] | undefined): Promise; getPRChecksState(owner: string, repo: string, number: number): Promise; mergePR(owner: string, repo: string, number: number, method: "merge" | "squash" | "rebase"): Promise; dispatchWorkflow(owner: string, repo: string, workflowId: string, ref: string, inputs: Record | undefined): Promise; searchCode(query: string, limit: number): Promise; searchRepositories(query: string, limit: number): Promise; createIssue(owner: string, repo: string, input: { title: string; body?: string; labels?: string[]; assignees?: string[]; }): Promise; getIssue(owner: string, repo: string, number: number): Promise; commentOnIssue(owner: string, repo: string, number: number, body: string): Promise; updateIssue(owner: string, repo: string, number: number, patch: { state?: "open" | "closed"; body?: string; assignees?: string[]; labels?: string[]; }): Promise; getPR(owner: string, repo: string, number: number): Promise; getFileContents(owner: string, repo: string, path: string, ref: string | undefined): Promise; commitFile(owner: string, repo: string, input: { path: string; content: string; message: string; branch?: string; sha?: string; }): Promise; getRepository(owner: string, repo: string): Promise; createOrganizationRepository(org: string, input: Omit): Promise; updateRepository(owner: string, repo: string, input: Omit): Promise; deleteRepository(owner: string, repo: string): Promise<{ alreadyMissing: boolean; }>; listOrganizationRepositories(org: string, input: Omit): Promise; getBranch(owner: string, repo: string, branch: string): Promise; getRef(owner: string, repo: string, branch: string): Promise<{ sha: string; treeSha: string; }>; createRef(owner: string, repo: string, branch: string, sha: string): Promise<{ created: boolean; }>; deleteRef(owner: string, repo: string, branch: string): Promise<{ alreadyMissing: boolean; }>; listPRs(owner: string, repo: string, input: { head?: string; base?: string; state?: "open" | "closed" | "all"; limit?: number; }): Promise; createBlob(owner: string, repo: string, input: Pick): Promise<{ sha: string; }>; createTree(owner: string, repo: string, input: { baseTree: string; tree: Array<{ path: string; mode: "100644" | "100755"; type: "blob"; sha: string; }>; }): Promise<{ sha: string; }>; createCommit(owner: string, repo: string, input: { message: string; treeSha: string; parentSha: string; }): Promise<{ sha: string; }>; updateRef(owner: string, repo: string, branch: string, sha: string): Promise; listTree(owner: string, repo: string, ref: string | undefined, recursive: boolean): Promise<{ paths: string[]; truncated: boolean; }>; } export interface GitHubDeps { github: GitHubPort; } /** Parse "owner/name" into its parts. Throws on anything malformed. */ export declare function parseRepo(repo: string): { owner: string; repo: string; }; /** The GitHub issues endpoint also returns PRs; this filters them out. */ export declare function isPullRequest(raw: { pull_request?: unknown; }): boolean; export interface RawIssue { number: number; title: string; body?: string | null; html_url: string; created_at: string; user?: { login: string; } | null; labels: Array; pull_request?: unknown; } /** Flatten an Octokit issue into our JSON-serializable DTO. */ export declare function toIssueDTO(raw: RawIssue): IssueDTO; export interface RawPullRequest { number: number; title?: string; html_url: string; state: string; merged?: boolean; merged_at?: string | null; merged_by?: { login: string; } | null; mergeable?: boolean | null; draft?: boolean; additions?: number; deletions?: number; comments?: number; user?: { login: string; } | null; head: { ref: string; }; base: { ref: string; }; } /** Flatten an Octokit pull request into our review- and analytics-relevant DTO. */ export declare function toPullRequestDetailDTO(raw: RawPullRequest): PullRequestDetailDTO; export interface RawFileContent { path: string; /** File contents, base64-encoded (GitHub's `encoding: "base64"`). */ content: string; sha: string; encoding: string; } /** * Decode an Octokit file-content blob into our DTO. GitHub returns file bodies * base64-encoded; we decode to UTF-8 so callers get plain text, and report the * resulting encoding as "utf-8". */ export declare function toFileContentsDTO(raw: RawFileContent): FileContentsDTO; export interface RawRepository { id: number; node_id?: string; name: string; full_name: string; owner?: { login?: string; } | null; html_url: string; clone_url?: string; ssh_url?: string; default_branch?: string; visibility?: string; private?: boolean; is_template?: boolean; archived?: boolean; disabled?: boolean; created_at?: string | null; updated_at?: string | null; pushed_at?: string | null; stargazers_count?: number; forks_count?: number; fork?: boolean; language?: string | null; topics?: string[]; open_issues_count?: number; } export declare function toRepositoryDTO(raw: RawRepository): RepositoryDTO; export declare function toBranchDTO(raw: { name: string; commit: { sha: string; }; protected?: boolean; }): BranchDTO; /** * Walk paginated issue responses and collect up to `limit` real issues. * * The GitHub issues endpoint returns issues AND pull requests interleaved, so we * must accumulate across pages — a single page of `limit` items can contain * fewer than `limit` actual issues (or none), which would otherwise silently * shrink or empty the result. Extracted as a pure function so the accumulation * logic is unit-testable without Octokit. */ export declare function collectIssues(pages: AsyncIterable<{ data: RawIssue[]; }>, limit: number): Promise; /** * Reduce a PR head's check runs + combined commit status into a single state. * * A run that hasn't completed → pending; any failing conclusion → failing; a * reported commit status of failure/error → failing, pending → pending. * Everything else → green. Extracted as a pure function so the merge-gate logic * is unit-testable without Octokit. `status.total` guards the common case where * the combined-status API reports "pending" simply because no legacy statuses * exist (a PR gated only by check runs), which would otherwise never go green. */ export declare function combineChecksState(checkRuns: Array<{ status: string; conclusion: string | null; }>, status: { state: string; total: number; }): ChecksState; /** * Default GitHub port backed by Octokit. The client is constructed lazily on * first use, so importing the package never requires a GITHUB_TOKEN (reads on * public repos work unauthenticated, subject to rate limits). Search is the * exception: `search.code` and `search.repos` require a token even for public * repos, so those two methods rethrow a clearer error on 401. */ export declare function octokitPort(): GitHubPort; /** Default deps used by the wrapped tasks in production. */ export declare const defaultDeps: GitHubDeps; //# sourceMappingURL=client.d.ts.map