'use server';
import { resolve } from '../../lib/server-container.js';
import { requireFeatureFlag } from '../../lib/feature-flags.js';
export async function listAgentQuestions(input) {
    if (!input.appId.trim()) {
        return { ok: false, error: 'appId is required' };
    }
    try {
        requireFeatureFlag('collaboration');
        const useCase = resolve('ListAgentQuestionsUseCase');
        const questions = await useCase.execute(input);
        return { ok: true, questions };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to list agent questions';
        return { ok: false, error: message };
    }
}
export async function answerAgentQuestion(input) {
    try {
        requireFeatureFlag('collaboration');
        const useCase = resolve('AnswerAgentQuestionUseCase');
        const result = await useCase.execute(input);
        if (!result.enabled) {
            return { ok: false, error: 'Collaboration feature flag is off' };
        }
        return { ok: true };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to answer agent question';
        return { ok: false, error: message };
    }
}
export async function cancelAgentQuestion(input) {
    try {
        requireFeatureFlag('collaboration');
        const useCase = resolve('CancelAgentQuestionUseCase');
        const result = await useCase.execute(input);
        if (!result.enabled) {
            return { ok: false, error: 'Collaboration feature flag is off' };
        }
        return { ok: true };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to cancel agent question';
        return { ok: false, error: message };
    }
}
