import { BestAgentError } from "@best-agent/foundation";
export class ProviderTurnBudget {
    #used;
    enabled;
    max;
    constructor(input) {
        this.enabled = input.enabled;
        this.max = input.max;
        this.#used = input.used;
    }
    consume(reason) {
        if (!this.enabled) {
            return this.#used;
        }
        const next = this.#used + 1;
        if (next > this.max) {
            throw new BestAgentError("PROVIDER_TURN_BUDGET_EXCEEDED", `Provider exceeded the maximum ordinary turn decision budget of ${this.max}. reason=${reason}`);
        }
        this.#used = next;
        return this.#used;
    }
    get used() {
        return this.#used;
    }
    snapshot() {
        return {
            enabled: this.enabled,
            max: this.max,
            used: this.#used,
        };
    }
}
//# sourceMappingURL=provider-turn-budget.js.map