import { resolvePersona, resolveRefToContent } from './resource-resolver.js';
import { normalizeProviderReference } from './workflowStepNormalizer.js';
function normalizeLoopMonitorJudge(raw, workflowDir, sections, context) {
    const { personaSpec, personaPath } = resolvePersona(raw.persona, sections, workflowDir, context);
    const normalizedProvider = normalizeProviderReference(raw.provider, raw.model, undefined);
    return {
        persona: personaSpec,
        personaPath,
        provider: normalizedProvider.provider,
        model: normalizedProvider.model,
        providerOptions: normalizedProvider.providerOptions,
        instruction: raw.instruction
            ? resolveRefToContent(raw.instruction, sections.resolvedInstructionsWithSource ?? sections.resolvedInstructions, workflowDir, 'instructions', context)
            : undefined,
        rules: raw.rules.map((rule) => ({ condition: rule.condition, next: rule.next })),
    };
}
export function normalizeLoopMonitors(raw, workflowDir, sections, context) {
    if (!raw || raw.length === 0) {
        return undefined;
    }
    return raw.map((monitor) => ({
        cycle: monitor.cycle,
        threshold: monitor.threshold,
        judge: normalizeLoopMonitorJudge(monitor.judge, workflowDir, sections, context),
    }));
}
//# sourceMappingURL=workflowLoopMonitorNormalizer.js.map