import { callClaude, callClaudeCustom } from '../claude/client.js';
import { resolveAnthropicApiKey, resolveClaudeCliPath } from '../config/index.js';
import { validateClaudeEffortCompatibility } from '../../core/workflow/claude-effort-compatibility.js';
function toClaudeOptions(options) {
    const claudeSandbox = options.providerOptions?.claude?.sandbox;
    const effort = options.providerOptions?.claude?.effort;
    validateClaudeEffortCompatibility(options.model, effort);
    return {
        cwd: options.cwd,
        abortSignal: options.abortSignal,
        sessionId: options.sessionId,
        allowedTools: options.allowedTools,
        mcpServers: options.mcpServers,
        model: options.model,
        effort,
        maxTurns: options.maxTurns,
        permissionMode: options.permissionMode,
        onStream: options.onStream,
        onPermissionRequest: options.onPermissionRequest,
        onAskUserQuestion: options.onAskUserQuestion,
        bypassPermissions: options.bypassPermissions,
        anthropicApiKey: options.anthropicApiKey ?? resolveAnthropicApiKey(),
        outputSchema: options.outputSchema,
        sandbox: claudeSandbox ? {
            allowUnsandboxedCommands: claudeSandbox.allowUnsandboxedCommands,
            excludedCommands: claudeSandbox.excludedCommands,
        } : undefined,
        pathToClaudeCodeExecutable: resolveClaudeCliPath(),
    };
}
export class ClaudeProvider {
    supportsStructuredOutput = true;
    setup(config) {
        const { name, systemPrompt } = config;
        if (systemPrompt) {
            return {
                call: (prompt, options) => callClaudeCustom(name, prompt, systemPrompt, toClaudeOptions(options)),
            };
        }
        return {
            call: (prompt, options) => callClaude(name, prompt, toClaudeOptions(options)),
        };
    }
}
//# sourceMappingURL=claude.js.map