import { AcodeSdkAdapter } from './AcodeSdkAdapter.js';
import { ClaudeSdkAdapter } from './ClaudeSdkAdapter.js';
import { CodexSdkAdapter } from './CodexSdkAdapter.js';
import { OpencodeSdkAdapter } from './OpencodeSdkAdapter.js';
export const SDK_PROVIDER_DEFINITIONS = [
    {
        runtimeMode: 'acode',
        providerId: 'acode',
        displayName: 'ACode',
        defaultCommand: 'acode',
        commandMatchers: ['acode'],
        createAdapter: () => new AcodeSdkAdapter(),
    },
    {
        runtimeMode: 'claudecode',
        providerId: 'claude-code',
        displayName: 'Claude Code',
        defaultCommand: 'claude',
        commandMatchers: ['claude', 'claudecode', 'claude-code'],
        createAdapter: () => new ClaudeSdkAdapter(),
    },
    {
        runtimeMode: 'codex',
        providerId: 'codex',
        displayName: 'Codex',
        defaultCommand: 'codex',
        commandMatchers: ['codex'],
        createAdapter: () => new CodexSdkAdapter(),
    },
    {
        runtimeMode: 'opencode',
        providerId: 'opencode',
        displayName: 'OpenCode',
        defaultCommand: 'opencode',
        commandMatchers: ['opencode', 'open-code'],
        createAdapter: () => new OpencodeSdkAdapter(),
    },
];
export function resolveSdkProviderByCommand(command) {
    const normalizedCommand = String(command || 'acode').trim().toLowerCase();
    return (SDK_PROVIDER_DEFINITIONS.find((definition) => definition.commandMatchers.some((matcher) => normalizedCommand.includes(matcher))) || SDK_PROVIDER_DEFINITIONS[0]);
}
export function resolveSdkProviderIdByCommand(command) {
    return resolveSdkProviderByCommand(command).providerId;
}
export function registerSdkProviders(registry, wireAdapterEvents) {
    for (const definition of SDK_PROVIDER_DEFINITIONS) {
        if (registry.has(definition.providerId)) {
            continue;
        }
        const adapter = definition.createAdapter();
        wireAdapterEvents(adapter, definition);
        registry.register(adapter);
    }
}
