import { type AgentCapabilityFlags, type AgentClient, type AgentCreateSessionOptions, type AgentFeature, type AgentLaunchContext, type AgentMode, type AgentModelDefinition, type AgentPersistenceHandle, type AgentPermissionRequest, type AgentPermissionResponse, type AgentPermissionResult, type AgentPromptContentBlock, type AgentPromptInput, type AgentRunOptions, type AgentRunResult, type AgentRuntimeInfo, type AgentSession, type AgentSessionConfig, type AgentSlashCommand, type AgentStreamEvent, type AgentTimelineItem, type ToolCallTimelineItem, type AgentUsage, type ListModelsOptions, type ListPersistedAgentsOptions, type PersistedAgentDescriptor } from "../agent-sdk-types.js";
import type { Logger } from "pino";
import type { ChildProcessWithoutNullStreams } from "node:child_process";
import { type ProviderRuntimeSettings } from "../provider-launch-config.js";
import { type CodexThreadForkParams, type CodexThreadForkResponse, type CodexThreadRollbackParams, type CodexThreadRollbackResponse, type CodexAppServerTraceContext } from "./codex/app-server-transport.js";
import type { WorkspaceGitService } from "../../workspace-git-service.js";
declare const CODEX_PROVIDER: "codex";
interface CodexAppServerClientLike {
    request(method: string, params?: unknown): Promise<unknown>;
    forkThread?(params: CodexThreadForkParams): Promise<CodexThreadForkResponse>;
    rollbackThread?(params: CodexThreadRollbackParams): Promise<CodexThreadRollbackResponse>;
    notify(method: string, params?: unknown): void;
    dispose(): Promise<void>;
}
interface CodexAppServerAgentDeps {
    workspaceGitService?: Pick<WorkspaceGitService, "resolveRepoRoot">;
    customProvider?: {
        id: string;
        label: string;
        extends: string;
    };
    customCodexConfig?: Record<string, unknown> | null;
    _createCodexClient?: (child: ChildProcessWithoutNullStreams, logger: Logger, getTraceContext: () => CodexAppServerTraceContext) => CodexAppServerClientLike;
}
export declare function normalizeCodexOutputSchema(schema: unknown): Record<string, unknown>;
export declare function findCodexMicrosoftStoreBinary(): Promise<string | null>;
export declare function findDefaultCodexBinary(): Promise<string | null>;
export declare function listCodexSkills(cwd: string, workspaceGitService?: Pick<WorkspaceGitService, "resolveRepoRoot">): Promise<AgentSlashCommand[]>;
export declare function toAgentUsage(tokenUsage: unknown): AgentUsage | undefined;
export declare function planStepsToMarkdown(steps: Array<{
    step: string;
    status: string;
}>): string;
export declare function mapCodexPlanToToolCall(params: {
    callId: string;
    text: string;
}): ToolCallTimelineItem | null;
interface CodexQuestionOption {
    label: string;
    description?: string;
}
interface CodexQuestionPrompt {
    id: string;
    header: string;
    question: string;
    options: CodexQuestionOption[];
    multiSelect?: boolean;
    isOther?: boolean;
    isSecret?: boolean;
}
export declare function normalizeCodexQuestionPrompts(raw: unknown): CodexQuestionPrompt[];
export declare function formatCodexQuestionPrompts(questions: CodexQuestionPrompt[]): string;
export declare function mapCodexQuestionRequestToToolCall(params: {
    callId: string;
    questions: CodexQuestionPrompt[];
    status: ToolCallTimelineItem["status"];
    answers?: Record<string, string[]>;
    error?: unknown;
}): ToolCallTimelineItem;
export declare function mapCodexPatchNotificationToToolCall(params: {
    callId?: string | null;
    changes: unknown;
    cwd?: string | null;
    stdout?: string | null;
    stderr?: string | null;
    success?: boolean | null;
    running: boolean;
}): ToolCallTimelineItem | null;
export declare function threadItemToTimeline(item: unknown, options?: {
    includeUserMessage?: boolean;
    cwd?: string | null;
}): AgentTimelineItem | null;
export declare function forkCodexThread(client: CodexAppServerClientLike, params: CodexThreadForkParams): Promise<CodexThreadForkResponse>;
export declare function rollbackCodexThread(client: CodexAppServerClientLike, params: CodexThreadRollbackParams): Promise<CodexThreadRollbackResponse>;
interface CodexSkillPromptBlock {
    type: "skill";
    name: string;
    path: string;
}
type CodexPromptContentBlock = AgentPromptContentBlock | CodexSkillPromptBlock;
type CodexPromptInput = string | CodexPromptContentBlock[];
interface CodexTextElement {
    byteRange: {
        start: number;
        end: number;
    };
    placeholder: string | null;
}
type CodexAppServerUserInput = {
    type: "text";
    text: string;
    text_elements: CodexTextElement[];
} | {
    type: "localImage";
    path: string;
} | CodexSkillPromptBlock;
export declare function codexAppServerTurnInputFromPrompt(prompt: CodexPromptInput, logger: Logger): Promise<CodexAppServerUserInput[]>;
export declare function buildCodexAppServerEnv(runtimeSettings?: ProviderRuntimeSettings, launchEnv?: Record<string, string>): NodeJS.ProcessEnv;
export declare class CodexAppServerAgentSession implements AgentSession {
    private readonly resumeHandle;
    private readonly spawnAppServer;
    private readonly deps;
    private readonly ephemeral;
    private readonly goalsEnabled;
    private readonly autoReviewEnabled;
    private readonly agentId?;
    readonly provider: "codex";
    readonly capabilities: AgentCapabilityFlags;
    private readonly logger;
    private readonly config;
    private currentMode;
    private currentThreadId;
    private currentTurnId;
    private client;
    private readonly subscribers;
    private nextTurnOrdinal;
    private activeForegroundTurnId;
    private cachedRuntimeInfo;
    private serviceTier;
    private planModeEnabled;
    private historyPending;
    private persistedHistory;
    private pendingPermissions;
    private pendingPermissionHandlers;
    private resolvedPermissionRequests;
    private pendingAgentMessages;
    private pendingReasoning;
    private pendingCommandOutputDeltas;
    private pendingFileChangeOutputDeltas;
    private pendingAssistantMessageBoundary;
    private terminalCommandByProcessId;
    private pendingUnlabeledTerminalInteractions;
    private emittedTerminalInteractionKeys;
    private emittedExecCommandStartedCallIds;
    private emittedExecCommandCompletedCallIds;
    private emittedItemStartedIds;
    private emittedItemCompletedIds;
    private subAgentCallsByCallId;
    private subAgentCallIdByChildThreadId;
    private warnedUnknownNotificationMethods;
    private warnedInvalidNotificationPayloads;
    private warnedIncompleteEditToolCallIds;
    private latestUsage;
    private latestPlanResult;
    private readonly userMessageTurnIndexes;
    private readonly userMessageTurnIds;
    private pendingManualCompactionStarts;
    private compactionTriggerByItemId;
    private unpairedCompactionNotificationCompletions;
    private unpairedCompactionItemCompletions;
    private connected;
    private collaborationModes;
    private resolvedCollaborationMode;
    private cachedSkills;
    constructor(config: AgentSessionConfig, resumeHandle: {
        sessionId: string;
        metadata?: Record<string, unknown>;
    } | null, logger: Logger, spawnAppServer: () => Promise<ChildProcessWithoutNullStreams>, deps?: CodexAppServerAgentDeps, ephemeral?: boolean, goalsEnabled?: boolean, autoReviewEnabled?: boolean, agentId?: string | undefined);
    get id(): string | null;
    get features(): AgentFeature[];
    connect(): Promise<void>;
    private traceContext;
    private loadCollaborationModes;
    private loadSkills;
    private findCollaborationMode;
    private hasPlanCollaborationMode;
    private resolveCollaborationMode;
    private refreshResolvedCollaborationMode;
    private applyFeatureValue;
    private rememberPlanResult;
    private emitSyntheticPlanApprovalRequest;
    /**
     * Prepare the session for plan implementation by disabling plan mode
     * and returning the implementation prompt. The caller is responsible for
     * starting the turn through the normal streamAgent path.
     */
    private preparePlanImplementation;
    private registerRequestHandlers;
    private loadPersistedHistory;
    private ensureThreadLoaded;
    private parseSlashCommandInput;
    private resolveSlashCommandInvocation;
    private buildCommandPromptInput;
    private buildTurnStartParams;
    private logTurnStartSummary;
    run(prompt: AgentPromptInput, options?: AgentRunOptions): Promise<AgentRunResult>;
    startTurn(prompt: AgentPromptInput, options?: AgentRunOptions): Promise<{
        turnId: string;
    }>;
    private rememberCodexUserMessageTurn;
    private resetCodexUserMessageTurns;
    private truncateCodexUserMessageTurns;
    private codexUserMessageTurns;
    subscribe(callback: (event: AgentStreamEvent) => void): () => void;
    streamHistory(): AsyncGenerator<AgentStreamEvent>;
    getRuntimeInfo(): Promise<AgentRuntimeInfo>;
    getAvailableModes(): Promise<AgentMode[]>;
    getCurrentMode(): Promise<string | null>;
    setMode(modeId: string): Promise<void>;
    setModel(modelId: string | null): Promise<void>;
    setThinkingOption(thinkingOptionId: string | null): Promise<void>;
    setFeature(featureId: string, value: unknown): Promise<void>;
    getPendingPermissions(): AgentPermissionRequest[];
    respondToPermission(requestId: string, response: AgentPermissionResponse): Promise<AgentPermissionResult | void>;
    private handlePlanPermissionResponse;
    private emitDeniedToolCallTimelineEvent;
    describePersistence(): {
        provider: typeof CODEX_PROVIDER;
        sessionId: string;
        nativeHandle: string;
        metadata: Record<string, unknown>;
    } | null;
    revertConversation(input: {
        messageId: string;
    }): Promise<void>;
    interrupt(): Promise<void>;
    close(): Promise<void>;
    listCommands(): Promise<AgentSlashCommand[]>;
    tryHandleOutOfBand(prompt: AgentPromptInput): {
        run(ctx: {
            emit: (event: AgentStreamEvent) => void;
        }): Promise<void>;
    } | null;
    private executeCompactCommand;
    private executeGoalSubcommand;
    private resolveModelAndThinking;
    private ensureThread;
    private buildCodexInnerConfig;
    private buildUserInput;
    private emitEvent;
    private notifySubscribers;
    private createTurnId;
    private handleNotification;
    private handleThreadStateNotification;
    private traceParsedNotification;
    private getSubAgentCallIdForThread;
    private registerSubAgentToolCall;
    private upsertSubAgentChildItem;
    private getSubAgentChildTimeline;
    private emitSubAgentActivityUpdate;
    private handleSubAgentChildItemCompleted;
    private shouldSkipCompletedThreadItem;
    private handleCodexDeltaNotification;
    private handleThreadStartedNotification;
    private handleTurnStartedNotification;
    private handleTurnCompletedNotification;
    private resetTurnTrackingState;
    private handlePlanUpdatedNotification;
    private handleTokenUsageUpdatedNotification;
    private resolveContextCompactionTrigger;
    private createContextCompactionTimelineItem;
    private isContextCompactionItem;
    private isUserMessageItem;
    private handleThreadRolledBackNotification;
    private handleContextCompactedNotification;
    private handleExecCommandStartedNotification;
    private handleExecCommandCompletedNotification;
    private handleTerminalInteractionNotification;
    private handlePatchApplyStartedNotification;
    private handlePatchApplyCompletedNotification;
    private handleItemCompletedNotification;
    private consumeStreamedTextCompletion;
    private emitMissingFinalTextSuffix;
    private applyBufferedDeltaTextToTimelineItem;
    private handleItemStartedNotification;
    private handleUserMessageItem;
    private warnUnknownNotificationMethod;
    private warnInvalidNotificationPayload;
    private appendOutputDeltaChunk;
    private consumeOutputDelta;
    private rememberTerminalProcessForCommand;
    private shouldEmitTerminalInteractionKey;
    private warnOnIncompleteEditToolCall;
    private handleCommandApprovalRequest;
    private handleFileChangeApprovalRequest;
    private handleToolApprovalRequest;
}
export declare class CodexAppServerAgentClient implements AgentClient {
    private readonly logger;
    private readonly runtimeSettings?;
    private readonly deps;
    readonly provider: "codex";
    readonly capabilities: AgentCapabilityFlags;
    private goalsEnabledPromise;
    private autoReviewEnabledPromise;
    constructor(logger: Logger, runtimeSettings?: ProviderRuntimeSettings | undefined, deps?: CodexAppServerAgentDeps);
    private sessionDeps;
    private resolveGoalsEnabled;
    private resolveAutoReviewEnabled;
    private spawnAppServer;
    createSession(config: AgentSessionConfig, launchContext?: AgentLaunchContext, options?: AgentCreateSessionOptions): Promise<AgentSession>;
    resumeSession(handle: {
        sessionId: string;
        metadata?: Record<string, unknown>;
    }, overrides?: Partial<AgentSessionConfig>, launchContext?: AgentLaunchContext): Promise<AgentSession>;
    listPersistedAgents(options?: ListPersistedAgentsOptions): Promise<PersistedAgentDescriptor[]>;
    listModels(_options: ListModelsOptions): Promise<AgentModelDefinition[]>;
    archiveNativeSession(handle: AgentPersistenceHandle): Promise<void>;
    isAvailable(): Promise<boolean>;
    getDiagnostic(): Promise<{
        diagnostic: string;
    }>;
}
export {};
//# sourceMappingURL=codex-app-server-agent.d.ts.map