'use server';
import { resolve } from '../../lib/server-container.js';
import { revalidatePath } from 'next/cache';
import { requireFeatureFlag } from '../../lib/feature-flags.js';
export async function saveAgentGraph(input) {
    try {
        requireFeatureFlag('collaboration');
        const useCase = resolve('UpsertAgentGraphOverrideUseCase');
        await useCase.execute({
            agentType: input.agentType,
            nodes: input.nodes,
            edges: input.edges,
        });
        revalidatePath(`/agents/${input.agentType}`);
        revalidatePath('/agents');
        return { ok: true };
    }
    catch (error) {
        return {
            ok: false,
            error: error instanceof Error ? error.message : 'Failed to save graph',
        };
    }
}
export async function resetAgentGraph(input) {
    try {
        requireFeatureFlag('collaboration');
        const useCase = resolve('DeleteAgentGraphOverrideUseCase');
        await useCase.execute(input);
        revalidatePath(`/agents/${input.agentType}`);
        revalidatePath('/agents');
        return { ok: true };
    }
    catch (error) {
        return {
            ok: false,
            error: error instanceof Error ? error.message : 'Failed to reset graph',
        };
    }
}
