"use strict";
// SPDX-License-Identifier: AGPL-3.0-or-later
Object.defineProperty(exports, "__esModule", { value: true });
exports.DUAL_SURFACE_PROVIDER_TYPES = void 0;
exports.isAgentRuntimeKind = isAgentRuntimeKind;
exports.isDualSurfaceProviderType = isDualSurfaceProviderType;
exports.supportsAgentRuntimeType = supportsAgentRuntimeType;
exports.assertAgentRuntimeSupported = assertAgentRuntimeSupported;
exports.resolveProviderAgentRuntime = resolveProviderAgentRuntime;
exports.sharedKeyShouldUseClaudeAuthToken = sharedKeyShouldUseClaudeAuthToken;
exports.DUAL_SURFACE_PROVIDER_TYPES = [
    'deepseek',
    'glm',
    'qwen',
    'qwen_coding',
    'kimi_code',
    'kimi',
    'doubao',
    'minimax',
    'xiaomi',
    'tencent_token_plan',
    'tencent_coding_plan',
    'hunyuan',
    'qianfan',
    'stepfun',
    'siliconflow',
    'huawei',
];
const CLAUDE_RUNTIME_TYPES = [
    'anthropic',
    'bedrock',
    'vertex',
    ...exports.DUAL_SURFACE_PROVIDER_TYPES,
    'custom',
];
const OPENAI_RUNTIME_TYPES = [
    'openai',
    'ollama',
    ...exports.DUAL_SURFACE_PROVIDER_TYPES,
    'custom',
];
function isAgentRuntimeKind(value) {
    return value === 'claude-agent-sdk' || value === 'openai-agents-sdk';
}
function isDualSurfaceProviderType(type) {
    return exports.DUAL_SURFACE_PROVIDER_TYPES.includes(type);
}
function supportsAgentRuntimeType(type, runtime) {
    return runtime === 'openai-agents-sdk'
        ? OPENAI_RUNTIME_TYPES.includes(type)
        : CLAUDE_RUNTIME_TYPES.includes(type);
}
function assertAgentRuntimeSupported(type, runtime) {
    if (runtime === undefined || runtime === null)
        return;
    if (!isAgentRuntimeKind(runtime)) {
        throw new Error(`Invalid agent runtime: ${String(runtime)}`);
    }
    if (!supportsAgentRuntimeType(type, runtime)) {
        throw new Error(`Provider type "${type}" does not support ${runtime}`);
    }
}
function resolveProviderAgentRuntime(provider) {
    const explicitRuntime = provider?.connection.agentRuntime;
    assertAgentRuntimeSupported(provider?.type ?? 'custom', explicitRuntime);
    if (explicitRuntime)
        return explicitRuntime;
    switch (provider?.type) {
        case 'openai':
        case 'ollama':
            return 'openai-agents-sdk';
        case 'custom':
            if (provider?.connection.openaiProtocol ||
                provider?.connection.openaiBaseUrl ||
                provider?.connection.openaiApiKey) {
                const hasClaudeSurface = Boolean(provider.connection.claudeBaseUrl ||
                    provider.connection.claudeApiKey ||
                    provider.connection.claudeAuthToken);
                return hasClaudeSurface ? 'claude-agent-sdk' : 'openai-agents-sdk';
            }
            return 'claude-agent-sdk';
        case 'anthropic':
        case 'bedrock':
        case 'vertex':
        default:
            return 'claude-agent-sdk';
    }
}
function sharedKeyShouldUseClaudeAuthToken(type) {
    return [
        'deepseek',
        'qwen',
        'qwen_coding',
        'kimi',
        'doubao',
        'minimax',
        'tencent_token_plan',
        'tencent_coding_plan',
        'hunyuan',
        'qianfan',
        'stepfun',
        'huawei',
    ].includes(type);
}
//# sourceMappingURL=runtimeCapabilities.js.map