/**
 * Structured errors raised by the Issues subsystem.
 *
 * Carrying typed errors (rather than `new Error("…")`) lets the HTTP layer
 * convert them into rich `ErrorEnvelope` payloads with stable `error_code`s
 * and structured hints, so MCP clients and CLI users see the same recovery
 * guidance without parsing free-form messages.
 */
export class IssueValidationError extends Error {
    code;
    required_fields;
    acceptable_field_groups;
    hint;
    extra;
    constructor(details) {
        super(details.message);
        this.name = "IssueValidationError";
        this.code = details.code;
        this.required_fields = details.required_fields;
        this.acceptable_field_groups = details.acceptable_field_groups;
        this.hint = details.hint;
        this.extra = details.extra;
    }
    toErrorEnvelopeDetails() {
        const out = {};
        if (this.required_fields)
            out.required_fields = this.required_fields;
        if (this.acceptable_field_groups)
            out.acceptable_field_groups = this.acceptable_field_groups;
        if (this.hint)
            out.hint = this.hint;
        if (this.extra)
            out.extra = this.extra;
        return out;
    }
}
export class IssueTransportError extends Error {
    code;
    status;
    hint;
    extra;
    constructor(details) {
        super(details.message);
        this.name = "IssueTransportError";
        this.code = details.code;
        this.status = details.status ?? 502;
        this.hint = details.hint;
        this.extra = details.extra;
    }
    toErrorEnvelopeDetails() {
        const out = {};
        if (this.hint)
            out.hint = this.hint;
        if (this.extra)
            out.extra = this.extra;
        return out;
    }
}
/**
 * Type guard for the HTTP error catch path.
 */
export function isIssueValidationError(value) {
    return value instanceof IssueValidationError;
}
export function isIssueTransportError(value) {
    return value instanceof IssueTransportError;
}
//# sourceMappingURL=errors.js.map