import http from "node:http";
import type { SandboxScope } from "../auth/sandbox-token.js";
import { completeModelText as defaultCompleteModelText } from "../agent/model-completion.js";
import { type ApiModel } from "../agent/model-registry.js";
import type { PrWalkthroughCardSection } from "../../shared/pr-walkthrough/types.js";
import { WalkthroughAgentManager, type WalkthroughAgentManagerDeps, type WalkthroughSessionManagerLike } from "./walkthrough-agent-manager.js";
type JsonReader = (req: http.IncomingMessage) => Promise<any>;
type WalkthroughWarning = {
    code: string;
    severity: "info" | "warning" | "error";
    message: string;
    filePath?: string;
};
type DiffLine = {
    id: string;
    side: "old" | "new" | "context";
    oldLine?: number;
    newLine?: number;
    text: string;
    kind: "context" | "add" | "del";
};
type DiffHunk = {
    id: string;
    header: string;
    lines: DiffLine[];
};
type DiffBlock = {
    id: string;
    filePath: string;
    oldPath?: string;
    status?: string;
    hunks: DiffHunk[];
    externalUrl?: string;
    blobUrl?: string;
    rawUrl?: string;
    contentsUrl?: string;
};
type WalkthroughCard = {
    id: string;
    phaseId: "orientation" | "design" | "significant" | "other" | "audit";
    title: string;
    summary: string;
    rationale?: string;
    diffBlocks: DiffBlock[];
    checklist?: string[];
    cardSuggestions?: string[];
    suggestedComments?: Array<{
        id: string;
        cardId: string;
        diffBlockId: string;
        lineId: string;
        body: string;
    }>;
    navLabel?: string;
    sections?: PrWalkthroughCardSection[];
};
type WalkthroughChangeset = {
    baseSha: string;
    headSha: string;
    provider?: string;
    externalUrl?: string;
    prUrl?: string;
    prNumber?: string | number;
    prTitle?: string;
    prBody?: string;
    title?: string;
    filesChanged?: number;
    additions?: number;
    deletions?: number;
};
type WalkthroughResolveResult = {
    changesetId: string;
    changeset: WalkthroughChangeset;
    cards: WalkthroughCard[];
    warnings: WalkthroughWarning[];
    limits?: Record<string, unknown>;
    export?: WalkthroughExportCapability;
};
type WalkthroughExportCapability = {
    provider?: string;
    available: boolean;
    reason?: string;
    previewOnly?: boolean;
    [key: string]: unknown;
};
export type PrWalkthroughRouteDeps = {
    defaultCwd: string;
    stateDir?: string;
    readBody: JsonReader;
    resolveSessionCwd?: (sessionId: string) => string | undefined | Promise<string | undefined>;
    resolveSessionModel?: (sessionId: string) => string | {
        provider?: string;
        id?: string;
        modelId?: string;
    } | undefined | Promise<string | {
        provider?: string;
        id?: string;
        modelId?: string;
    } | undefined>;
    preferencesStore?: {
        get(key: string): unknown;
    };
    getAvailableModels?: (preferencesStore: {
        get(key: string): unknown;
    }) => Promise<ApiModel[]>;
    completeModelText?: typeof defaultCompleteModelText;
    createSynthesisAdapter?: (context: WalkthroughSynthesisContext) => WalkthroughLlmAdapter | undefined | Promise<WalkthroughLlmAdapter | undefined>;
    sessionManager?: WalkthroughSessionManagerLike;
    broadcast?: (event: Record<string, unknown>) => void;
    walkthroughAgentManager?: WalkthroughAgentManager;
    preflightGithubLaunch?: WalkthroughAgentManagerDeps["preflightGithubLaunch"];
    sandboxScope?: SandboxScope;
};
type WalkthroughLlmAdapter = (input: Record<string, unknown>) => Promise<unknown> | unknown;
type WalkthroughSynthesisContext = {
    sessionId?: string;
    cwd: string;
    changeset?: WalkthroughChangeset;
};
export declare function setPrWalkthroughSynthesisAdapterForTesting(adapter: WalkthroughLlmAdapter | undefined): void;
export declare function handlePrWalkthroughApiRoute(url: URL, req: http.IncomingMessage, res: http.ServerResponse, deps: PrWalkthroughRouteDeps): Promise<boolean>;
declare function resolveWalkthrough(body: Record<string, unknown>, deps: PrWalkthroughRouteDeps, extraHosts?: string[]): Promise<WalkthroughResolveResult>;
export declare function normalizeGithubResolvedWalkthrough(resolved: any, deps?: Partial<PrWalkthroughRouteDeps>, context?: Partial<WalkthroughSynthesisContext>): Promise<WalkthroughResolveResult | undefined>;
export declare function createModelBackedSynthesisAdapter(deps: PrWalkthroughRouteDeps, context: WalkthroughSynthesisContext): Promise<WalkthroughLlmAdapter | undefined>;
declare function submitExport(changesetId: string, payload: WalkthroughResolveResult, body: any): Promise<Record<string, unknown>>;
export declare const submitExportForTesting: typeof submitExport;
declare function parseGithubRef(prUrl: string | undefined, prNumber: string | number | undefined, cwd: string, extraHosts?: string[]): {
    owner: string;
    repo: string;
    number: string | number;
    url: string;
    host: string;
} | undefined;
export declare const resolveWalkthroughForTesting: typeof resolveWalkthrough;
export declare const parseGithubRefForTesting: typeof parseGithubRef;
export {};
//# sourceMappingURL=routes.d.ts.map