'use server';
import { resolve } from '../../lib/server-container.js';
import { resetSettings, initializeSettings, } from '../../../../../packages/core/src/infrastructure/services/settings.service.js';
export async function updateAgentAndModel(agentType, model) {
    if (!agentType.trim()) {
        return { ok: false, error: 'agent type is required' };
    }
    try {
        const useCase = resolve('CompleteWebOnboardingUseCase');
        const updatedSettings = await useCase.execute({
            agentType: agentType.trim(),
            model,
        });
        resetSettings();
        initializeSettings(updatedSettings);
        return { ok: true };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to update agent and model';
        return { ok: false, error: message };
    }
}
