import { type ReadPrWalkthroughBundleRequest } from "./walkthrough-analysis-bundle.js";
import { type WalkthroughStorePayload } from "./walkthrough-store.js";
import { type WalkthroughParsedDiffForYamlMapping } from "./walkthrough-yaml-schema.js";
import { WalkthroughAgentStore, type PrWalkthroughJobError, type PrWalkthroughJobRecord, type PrWalkthroughTarget, type PrWalkthroughValidationSummary, type WalkthroughWarning } from "./walkthrough-agent-store.js";
type RpcLike = {
    prompt?: (text: string, images?: any) => Promise<unknown> | unknown;
    onEvent?: (handler: (event: unknown) => void) => (() => void);
};
type SessionLike = {
    id: string;
    title?: string;
    cwd?: string;
    worktreePath?: string;
    status?: string;
    archived?: boolean;
    projectId?: string;
    sandboxed?: boolean;
    rpcClient?: RpcLike;
    allowedTools?: string[];
};
type PersistedSessionLike = {
    id: string;
    cwd?: string;
    worktreePath?: string;
    status?: string;
    archived?: boolean;
    projectId?: string;
    sandboxed?: boolean;
    modelProvider?: string;
    modelId?: string;
};
export type WalkthroughSessionManagerLike = {
    createSession: (cwd: string, agentArgs?: string[], goalId?: string, assistantType?: string, opts?: any) => Promise<SessionLike>;
    getSession?: (sessionId: string) => SessionLike | undefined;
    getPersistedSession?: (sessionId: string) => PersistedSessionLike | undefined;
    updateSessionMeta?: (sessionId: string, updates: Record<string, unknown>) => boolean;
    setTitle?: (sessionId: string, title: string, opts?: Record<string, unknown>) => void;
    enqueuePrompt?: (sessionId: string, text: string, opts?: Record<string, unknown>) => Promise<unknown> | unknown;
};
export type WalkthroughAgentManagerDeps = {
    stateDir?: string;
    defaultCwd: string;
    sessionManager?: WalkthroughSessionManagerLike;
    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>;
    store?: WalkthroughAgentStore;
    preferencesStore?: {
        get(key: string): unknown;
    };
    broadcast?: (event: Record<string, unknown>) => void;
    preflightGithubLaunch?: boolean | ((job: PrWalkthroughJobRecord) => Promise<void> | void);
    validateYaml?: (yamlText: string, job: PrWalkthroughJobRecord) => Promise<WalkthroughYamlValidationResult> | WalkthroughYamlValidationResult;
    mapYamlToPayload?: (document: Record<string, unknown>, job: PrWalkthroughJobRecord) => Promise<WalkthroughStorePayload> | WalkthroughStorePayload;
    resolveDiffForYamlMapping?: (document: Record<string, unknown>, job: PrWalkthroughJobRecord) => Promise<WalkthroughParsedDiffForYamlMapping> | WalkthroughParsedDiffForYamlMapping;
};
export type LaunchWalkthroughRequest = {
    sessionId?: string;
    parentSessionId?: string;
    prUrl?: string;
    prNumber?: string | number;
    owner?: string;
    repo?: string;
    baseSha?: string;
    headSha?: string;
    cwd?: string;
    projectId?: string;
};
export type LaunchWalkthroughResponse = {
    jobId: string;
    childSessionId: string;
    changesetId: string;
    tabId: string;
    status: PrWalkthroughJobRecord["status"];
    title: string;
    created: boolean;
    job: PrWalkthroughJobRecord;
};
export type SubmitWalkthroughYamlRequest = {
    sessionId: string;
    jobId: string;
    yaml: string;
    submissionProof?: string;
};
export type SubmitWalkthroughYamlResponse = {
    ok: true;
    status: "ready";
    job: PrWalkthroughJobRecord;
    changesetId: string;
    message: string;
    warnings: WalkthroughWarning[];
} | {
    ok: false;
    status: "validation_failed";
    job: PrWalkthroughJobRecord;
    retryable: true;
    validation: PrWalkthroughValidationSummary;
};
export type WalkthroughYamlValidationResult = {
    ok: true;
    document: Record<string, unknown>;
    warnings?: WalkthroughWarning[];
    payload?: WalkthroughStorePayload;
} | {
    ok: false;
    summary: PrWalkthroughValidationSummary;
};
export declare const WALKTHROUGH_ALLOWED_TOOLS: string[];
export declare class WalkthroughAgentManager {
    private readonly deps;
    private readonly stateDir;
    private readonly store;
    private readonly bundleStore;
    private readonly reminderUnsubscribers;
    private readonly launchInFlight;
    constructor(deps: WalkthroughAgentManagerDeps);
    launch(input: LaunchWalkthroughRequest): Promise<LaunchWalkthroughResponse>;
    private launchNew;
    getJob(jobId: string): PrWalkthroughJobRecord | null;
    getJobForSession(childSessionId: string): PrWalkthroughJobRecord | null;
    readBundle(input: ReadPrWalkthroughBundleRequest): Record<string, unknown>;
    submitYaml(input: SubmitWalkthroughYamlRequest): Promise<SubmitWalkthroughYamlResponse>;
    restore(): void;
    private resolveAndPersistLaunchBundle;
    private resolveLaunchDiffForBundle;
    private validateYaml;
    private mapYamlToPayload;
    private resolveDiffForYamlMapping;
    private getSession;
    private assertLaunchableParent;
    private resolveCwd;
    private getManagedTrustedHosts;
    /**
     * Synchronous host trust check run BEFORE any job/child session is created, so an
     * untrusted host aborts the launch cleanly (no stale walkthrough tab). The HTTP
     * response carries { code: "untrusted_github_host", host } so the UI can prompt to
     * add the host and retry.
     */
    private assertTrustedGithubTarget;
    private resolveLaunchTarget;
    private resolveParentInitialModel;
    private shouldReuse;
    private applySessionMetadata;
    private attachRuntimeListeners;
    private markRuntimeFailure;
    private remindIfNeeded;
    private notifyChildOfError;
    private broadcastJob;
}
export declare function canonicalizeTarget(input: LaunchWalkthroughRequest): PrWalkthroughTarget;
/**
 * Pure transform (no git) shared by the number-only launch path: applies the
 * inferred owner/repo/host to the target and host-qualifies the canonical key
 * for non-github.com hosts, mirroring canonicalizeTarget. Exported for testing.
 */
export declare function numberOnlyTargetFromInferred(target: PrWalkthroughTarget, inferred: {
    owner: string;
    repo: string;
    host?: string;
}): PrWalkthroughTarget;
declare function changesetIdForTarget(target: PrWalkthroughTarget): string;
export declare const changesetIdForTargetForTesting: typeof changesetIdForTarget;
export declare function classifyDiffResolutionError(error: unknown): PrWalkthroughJobError;
export {};
//# sourceMappingURL=walkthrough-agent-manager.d.ts.map