import type { AgentCapabilityFlags, AgentClient, AgentCreateSessionOptions, AgentFeature, AgentLaunchContext, AgentMode, AgentModelDefinition, AgentPersistenceHandle, AgentPermissionRequest, AgentPermissionResponse, AgentPermissionResult, AgentPromptContentBlock, AgentPromptInput, AgentRunOptions, AgentRunResult, AgentRuntimeInfo, AgentSession, AgentSessionConfig, AgentSlashCommand, AgentStreamEvent, AgentTimelineItem, ToolCallTimelineItem, AgentUsage, ListModelsOptions, ListPersistedAgentsOptions, 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 { codexModelSupportsFastMode } from "./codex-feature-definitions.js";
import type { WorkspaceGitService } from "../../workspace-git-service.js";
declare const CODEX_PROVIDER: "codex";
interface CodexAppServerClientLike {
    request(method: string, params?: unknown): Promise<unknown>;
    notify(method: string, params?: unknown): void;
    dispose(): Promise<void>;
}
interface CodexAppServerAgentDeps {
    workspaceGitService?: Pick<WorkspaceGitService, "resolveRepoRoot">;
    _createCodexClient?: (child: ChildProcessWithoutNullStreams, logger: Logger) => CodexAppServerClientLike;
}
declare function normalizeCodexOutputSchema(schema: unknown): Record<string, unknown>;
declare function listCodexSkills(cwd: string, workspaceGitService?: Pick<WorkspaceGitService, "resolveRepoRoot">): Promise<AgentSlashCommand[]>;
type RequestHandler = (params: unknown) => unknown;
type NotificationHandler = (method: string, params: unknown) => void;
declare class CodexAppServerClient {
    private readonly child;
    private readonly logger;
    private readonly rl;
    private readonly pending;
    private readonly requestHandlers;
    private notificationHandler;
    private nextId;
    private disposed;
    private stderrBuffer;
    constructor(child: ChildProcessWithoutNullStreams, logger: Logger);
    setNotificationHandler(handler: NotificationHandler): void;
    setRequestHandler(method: string, handler: RequestHandler): void;
    request(method: string, params?: unknown, timeoutMs?: number): Promise<unknown>;
    notify(method: string, params?: unknown): void;
    private writeJsonRpcResponse;
    dispose(): Promise<void>;
    private handleLine;
}
declare function toAgentUsage(tokenUsage: unknown): AgentUsage | undefined;
declare function planStepsToMarkdown(steps: Array<{
    step: string;
    status: string;
}>): string;
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;
}
declare function normalizeCodexQuestionPrompts(raw: unknown): CodexQuestionPrompt[];
declare function formatCodexQuestionPrompts(questions: CodexQuestionPrompt[]): string;
declare function mapCodexQuestionRequestToToolCall(params: {
    callId: string;
    questions: CodexQuestionPrompt[];
    status: ToolCallTimelineItem["status"];
    answers?: Record<string, string[]>;
    error?: unknown;
}): ToolCallTimelineItem;
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;
declare function threadItemToTimeline(item: unknown, options?: {
    includeUserMessage?: boolean;
    cwd?: string | null;
}): AgentTimelineItem | null;
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[]>;
declare function buildCodexAppServerEnv(runtimeSettings?: ProviderRuntimeSettings, launchEnv?: Record<string, string>): NodeJS.ProcessEnv;
declare class CodexAppServerAgentSession implements AgentSession {
    private readonly resumeHandle;
    private readonly spawnAppServer;
    private readonly deps;
    private readonly ephemeral;
    private readonly goalsEnabled;
    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 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);
    get id(): string | null;
    get features(): AgentFeature[];
    connect(): Promise<void>;
    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;
    run(prompt: AgentPromptInput, options?: AgentRunOptions): Promise<AgentRunResult>;
    startTurn(prompt: AgentPromptInput, options?: AgentRunOptions): Promise<{
        turnId: string;
    }>;
    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;
    interrupt(): Promise<void>;
    close(): Promise<void>;
    listCommands(): Promise<AgentSlashCommand[]>;
    tryHandleOutOfBand(prompt: AgentPromptInput): {
        run(ctx: {
            emit: (event: AgentStreamEvent) => void;
        }): Promise<void>;
    } | null;
    private executeGoalSubcommand;
    private resolveModelAndThinking;
    private ensureThread;
    private buildCodexInnerConfig;
    private buildUserInput;
    private emitEvent;
    private notifySubscribers;
    private createTurnId;
    private handleNotification;
    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 handleExecCommandStartedNotification;
    private handleExecCommandCompletedNotification;
    private handleTerminalInteractionNotification;
    private handlePatchApplyStartedNotification;
    private handlePatchApplyCompletedNotification;
    private handleItemCompletedNotification;
    private consumeStreamedTextCompletion;
    private emitMissingFinalTextSuffix;
    private applyBufferedDeltaTextToTimelineItem;
    private handleItemStartedNotification;
    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;
    constructor(logger: Logger, runtimeSettings?: ProviderRuntimeSettings | undefined, deps?: CodexAppServerAgentDeps);
    private resolveGoalsEnabled;
    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 declare const __codexAppServerInternals: {
    buildCodexAppServerEnv: typeof buildCodexAppServerEnv;
    CodexAppServerClient: typeof CodexAppServerClient;
    codexModelSupportsFastMode: typeof codexModelSupportsFastMode;
    CodexAppServerAgentSession: typeof CodexAppServerAgentSession;
    formatCodexQuestionPrompts: typeof formatCodexQuestionPrompts;
    mapCodexQuestionRequestToToolCall: typeof mapCodexQuestionRequestToToolCall;
    mapCodexPatchNotificationToToolCall: typeof mapCodexPatchNotificationToToolCall;
    planStepsToMarkdown: typeof planStepsToMarkdown;
    mapCodexPlanToToolCall: typeof mapCodexPlanToToolCall;
    listCodexSkills: typeof listCodexSkills;
    normalizeCodexOutputSchema: typeof normalizeCodexOutputSchema;
    normalizeCodexQuestionPrompts: typeof normalizeCodexQuestionPrompts;
    toAgentUsage: typeof toAgentUsage;
    threadItemToTimeline: typeof threadItemToTimeline;
};
export {};
//# sourceMappingURL=codex-app-server-agent.d.ts.map