'use server';
import { resolve } from '../../lib/server-container.js';
function toTechDecisionsData(artifact) {
    return {
        name: artifact.name,
        summary: artifact.summary,
        decisions: artifact.decisions,
        technologies: artifact.technologies,
    };
}
export async function getResearchArtifact(featureId) {
    if (!featureId.trim()) {
        return { error: 'Feature id is required' };
    }
    try {
        const useCase = resolve('GetResearchArtifactUseCase');
        const artifact = await useCase.execute(featureId);
        const techDecisions = toTechDecisionsData(artifact);
        return { techDecisions };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to load research artifact';
        return { error: message };
    }
}
