// Safe-error shapes for the Quality Intelligence dispatcher (Epic #270, Issue #279).
//
// Errors that escape the dispatcher MUST NOT carry secrets, raw prompts, deployment endpoints,
// or untrusted-evidence text. Each error is a discriminated union member carrying only the
// minimum reason metadata callers need to branch on. The `message` field is a short,
// statically-derived phrase — never templated with a value from the request.
//
// The QI namespace deliberately uses a flat, code-prefixed error taxonomy ("qi/*")
// so downstream audit and BFF code can route safely without parsing.
// Thin throwable wrapper so call sites can `throw` while preserving the safe shape.
// Instances of this class carry ONLY the safe payload — never raw inputs.
export class QualityIntelligenceSafeErrorException extends Error {
    safe;
    constructor(safe) {
        super(safe.message);
        this.name = "QualityIntelligenceSafeErrorException";
        this.safe = safe;
    }
}
export function makeCapabilityMismatchError(profileId, missingCapabilities) {
    return Object.freeze({
        code: "qi/capability-mismatch",
        message: "Model does not satisfy the Quality Intelligence task profile capabilities.",
        profileId,
        missingCapabilities: Object.freeze([...missingCapabilities]),
    });
}
export function makeBudgetExhaustedError(profileId) {
    return Object.freeze({
        code: "qi/budget-exhausted",
        message: "Token budget exhausted for the Quality Intelligence run.",
        profileId,
    });
}
export function makeTimeoutError(profileId, timeoutMs) {
    return Object.freeze({
        code: "qi/timeout",
        message: "Quality Intelligence model call exceeded the profile timeout.",
        profileId,
        timeoutMs,
    });
}
export function makeCancelledError(profileId) {
    return Object.freeze({
        code: "qi/cancelled",
        message: "Quality Intelligence model call was cancelled.",
        profileId,
    });
}
export function makeProviderError(profileId) {
    return Object.freeze({
        code: "qi/provider-error",
        message: "Quality Intelligence provider returned an error.",
        profileId,
    });
}
export function makeRedactionFailedError(profileId) {
    return Object.freeze({
        code: "qi/redaction-failed",
        message: "Quality Intelligence evidence redaction failed.",
        profileId,
    });
}
