/**
 * Codex provider implementation
 */
import { callCodex, callCodexCustom } from '../codex/index.js';
import { resolveOpenaiApiKey, resolveCodexCliPath } from '../config/index.js';
function toCodexOptions(options) {
    return {
        cwd: options.cwd,
        abortSignal: options.abortSignal,
        sessionId: options.sessionId,
        model: options.model,
        reasoningEffort: options.providerOptions?.codex?.reasoningEffort,
        permissionMode: options.permissionMode,
        networkAccess: options.providerOptions?.codex?.networkAccess,
        onStream: options.onStream,
        openaiApiKey: options.openaiApiKey ?? resolveOpenaiApiKey(),
        codexPathOverride: resolveCodexCliPath(),
        outputSchema: options.outputSchema,
    };
}
/** Codex provider — delegates to OpenAI Codex SDK */
export class CodexProvider {
    supportsStructuredOutput = true;
    setup(config) {
        const { name, systemPrompt } = config;
        if (systemPrompt) {
            return {
                call: async (prompt, options) => {
                    return callCodexCustom(name, prompt, systemPrompt, toCodexOptions(options));
                },
            };
        }
        return {
            call: async (prompt, options) => {
                return callCodex(name, prompt, toCodexOptions(options));
            },
        };
    }
}
//# sourceMappingURL=codex.js.map