import { BestAgentError } from "@best-agent/foundation";
import { buildPromptDeliverableRepairPrompt } from "../../prompt/runtime-prompts.js";
import { collectPromptDeliverableFailures } from "../artifact-obligations.js";
export async function assertReplayToolOutputDeliverables(input) {
    if (!input.requiresDeliverableAssertion) {
        return;
    }
    if ((input.payload.artifactObligations?.length ?? 0) > 0) {
        await input.runtime.assertArtifactObligationsSatisfied(input.turn, input.payload.artifactObligations ?? []);
        return;
    }
    const failures = collectPromptDeliverableFailures(input.repairMessages, input.runtime.cwd);
    if (failures.length > 0) {
        throw new BestAgentError("PROVIDER_DECISION_INVALID", buildPromptDeliverableRepairPrompt(failures));
    }
}
//# sourceMappingURL=provider-replay-artifact-assertion.js.map