import type { GitHubSearchKind } from "@bytetrue/protocol/messages"; export declare const GITHUB_POLL_FAST_INTERVAL_MS = 20000; export declare const GITHUB_POLL_SLOW_INTERVAL_MS = 120000; export declare const GITHUB_POLL_ERROR_BACKOFF_CAP_MS = 300000; export interface GitHubCommandRunnerOptions { cwd: string; envOverlay?: Record; } export interface GitHubCommandResult { stdout: string; stderr: string; } export type GitHubCommandRunner = (args: string[], options: GitHubCommandRunnerOptions) => Promise; export interface GitHubPullRequestSummary { number: number; title: string; url: string; state: string; body: string | null; baseRefName: string; headRefName: string; labels: string[]; updatedAt: string; } export interface GitHubPullRequestCheckoutTarget { number: number; baseRefName: string; headRefName: string; headOwnerLogin: string | null; headRepositorySshUrl: string | null; headRepositoryUrl: string | null; isCrossRepository: boolean; } export interface GitHubIssueSummary { number: number; title: string; url: string; state: string; body: string | null; labels: string[]; updatedAt: string; } export type PullRequestCheckStatus = "pending" | "success" | "failure" | "cancelled" | "skipped"; export interface PullRequestCheck { name: string; status: PullRequestCheckStatus; url: string | null; workflow?: string; duration?: string; checkRunId?: number; workflowRunId?: number; } export type PullRequestChecksStatus = "none" | "pending" | "success" | "failure"; export type PullRequestReviewDecision = "approved" | "changes_requested" | "pending" | null; export type PullRequestMergeable = "MERGEABLE" | "CONFLICTING" | "UNKNOWN"; export interface GitHubPullRequestStatusFacts { mergeStateStatus: string | null; autoMergeRequest: { enabledAt: string | null; mergeMethod: string | null; enabledBy: string | null; } | null; viewerCanEnableAutoMerge: boolean; viewerCanDisableAutoMerge: boolean; viewerCanMergeAsAdmin: boolean; viewerCanUpdateBranch: boolean; repository: { autoMergeAllowed: boolean; mergeCommitAllowed: boolean; squashMergeAllowed: boolean; rebaseMergeAllowed: boolean; viewerDefaultMergeMethod: string | null; }; isMergeQueueEnabled: boolean; isInMergeQueue: boolean; } export interface GitHubCurrentPullRequestStatus { number?: number; repoOwner?: string; repoName?: string; url: string; title: string; state: string; baseRefName: string; headRefName: string; isMerged: boolean; isDraft?: boolean; mergeable: PullRequestMergeable; checks: PullRequestCheck[]; checksStatus: PullRequestChecksStatus; reviewDecision: PullRequestReviewDecision; github?: GitHubPullRequestStatusFacts; } export type PullRequestTimelineReviewState = "approved" | "changes_requested" | "commented"; interface PullRequestTimelineItemBase { id: string; author: string; authorUrl: string | null; avatarUrl: string | null; body: string; createdAt: number; url: string; } export type PullRequestTimelineItem = (PullRequestTimelineItemBase & { kind: "review"; reviewState: PullRequestTimelineReviewState; }) | (PullRequestTimelineItemBase & { kind: "comment"; reviewId?: string; location?: PullRequestTimelineCommentLocation; }); export interface PullRequestTimelineCommentLocation { path: string; line?: number; startLine?: number; threadId?: string; isResolved?: boolean; isOutdated?: boolean; } export type GitHubPullRequestTimelineErrorKind = "not_found" | "forbidden" | "unknown"; export interface GitHubPullRequestTimelineError { kind: GitHubPullRequestTimelineErrorKind; message: string; } export interface GitHubPullRequestTimeline { prNumber: number; repoOwner: string; repoName: string; items: PullRequestTimelineItem[]; truncated: boolean; error: GitHubPullRequestTimelineError | null; } export interface GitHubPullRequestCreateResult { url: string; number: number; } export type GitHubPullRequestMergeMethod = "merge" | "squash" | "rebase"; export interface GitHubPullRequestCommandStatus { mergeable?: PullRequestMergeable; github?: GitHubPullRequestStatusFacts; } export interface MergeGitHubPullRequestOptions { cwd: string; prNumber: number; mergeMethod: GitHubPullRequestMergeMethod; status?: GitHubPullRequestCommandStatus | null; } export interface EnableGitHubPullRequestAutoMergeOptions { cwd: string; prNumber: number; mergeMethod: GitHubPullRequestMergeMethod; status?: GitHubPullRequestCommandStatus | null; } export interface DisableGitHubPullRequestAutoMergeOptions { cwd: string; prNumber: number; status?: GitHubPullRequestCommandStatus | null; } export interface GitHubPullRequestMergeResult { success: true; } export interface GitHubPullRequestAutoMergeResult { success: true; } export type GitHubReadOptions = { force?: false; reason?: string; } | { force: true; reason: string; }; export type ListGitHubPullRequestsOptions = { cwd: string; query?: string; limit?: number; } & GitHubReadOptions; export type ListGitHubIssuesOptions = { cwd: string; query?: string; limit?: number; } & GitHubReadOptions; export type GetGitHubPullRequestOptions = { cwd: string; number: number; } & GitHubReadOptions; export type GetGitHubPullRequestTimelineOptions = { cwd: string; prNumber: number; repoOwner: string; repoName: string; } & GitHubReadOptions; export type GetGitHubCheckDetailsOptions = { cwd: string; repoOwner: string; repoName: string; checkRunId: number; workflowRunId?: number; } & GitHubReadOptions; export interface GitHubCheckAnnotation { path?: string; startLine?: number; endLine?: number; annotationLevel?: string; message?: string; title?: string; rawDetails?: string; } export interface GitHubCheckFailedJob { jobId: number; name: string; status?: string | null; conclusion?: string | null; url?: string | null; completedAt?: string; logTail?: string; logTruncated?: boolean; } export interface GitHubCheckDetails { checkRunId: number; workflowRunId?: number | null; name: string; status?: string | null; conclusion?: string | null; url?: string | null; detailsUrl?: string | null; output?: { title?: string | null; summary?: string | null; text?: string | null; } | null; annotations: GitHubCheckAnnotation[]; failedJobs: GitHubCheckFailedJob[]; truncated: boolean; } export interface GitHubSearchResult { items: Array<{ kind: "issue" | "pr"; number: number; title: string; url: string; state: string; body: string | null; labels: string[]; baseRefName?: string | null; headRefName?: string | null; updatedAt?: string; }>; githubFeaturesEnabled: boolean; } export type SearchGitHubIssuesAndPrsOptions = { cwd: string; query: string; limit?: number; kinds?: GitHubSearchKind[]; } & GitHubReadOptions; export interface CreateGitHubPullRequestOptions { cwd: string; repo: string; title: string; head: string; base: string; body?: string; } export interface GitHubService { listPullRequests(options: ListGitHubPullRequestsOptions): Promise; listIssues(options: ListGitHubIssuesOptions): Promise; getPullRequest(options: GetGitHubPullRequestOptions): Promise; getPullRequestHeadRef(options: GetGitHubPullRequestOptions): Promise; getPullRequestCheckoutTarget?(options: GetGitHubPullRequestOptions): Promise; getCurrentPullRequestStatus(options: { cwd: string; headRef: string; headRepositoryOwner?: string; } & GitHubReadOptions): Promise; getPullRequestTimeline(options: GetGitHubPullRequestTimelineOptions): Promise; getGitHubCheckDetails(options: GetGitHubCheckDetailsOptions): Promise; searchIssuesAndPrs(options: SearchGitHubIssuesAndPrsOptions): Promise; createPullRequest(options: CreateGitHubPullRequestOptions): Promise; mergePullRequest(options: MergeGitHubPullRequestOptions): Promise; enablePullRequestAutoMerge(options: EnableGitHubPullRequestAutoMergeOptions): Promise; disablePullRequestAutoMerge(options: DisableGitHubPullRequestAutoMergeOptions): Promise; isAuthenticated(options: { cwd: string; } & GitHubReadOptions): Promise; retainCurrentPullRequestStatusPoll?(options: { cwd: string; headRef: string; headRepositoryOwner?: string; onStatus?: (status: GitHubCurrentPullRequestStatus | null) => void; onError?: (error: unknown) => void; }): { unsubscribe: () => void; }; invalidate(options: { cwd: string; }): void; dispose?(): void; } export declare class GitHubCliMissingError extends Error { readonly kind = "missing-cli"; constructor(); } export declare class GitHubAuthenticationError extends Error { readonly kind = "auth-failure"; readonly stderr: string; constructor(params: { stderr: string; }); } export declare class GitHubCommandError extends Error { readonly kind = "command-error"; readonly args: string[]; readonly cwd: string; readonly exitCode: number | null; readonly stderr: string; constructor(params: { args: string[]; cwd: string; exitCode: number | null; stderr: string; }); } interface CreateGitHubServiceOptions { ttlMs?: number; runner?: GitHubCommandRunner; resolveGhPath?: () => Promise; now?: () => number; } export declare function createGitHubService(options?: CreateGitHubServiceOptions): GitHubService; export declare function assertPullRequestAutoMergeEnableReady(input: Pick): void; export declare function assertPullRequestAutoMergeDisableReady(input: Pick): void; export declare function isPullRequestMergeMethodAllowed(repository: GitHubPullRequestStatusFacts["repository"], method: GitHubPullRequestMergeMethod): boolean; export declare function computeGithubNextInterval(status: GitHubCurrentPullRequestStatus | null, consecutiveErrors: number): number; export declare function parseStatusCheckRollup(value: unknown): PullRequestCheck[]; export declare function resolveGitHubRepo(cwd: string): Promise; export {}; //# sourceMappingURL=github-service.d.ts.map