/**
 * Runtime-side credit halt. The host performs the primary user-facing credit
 * check; this gate is a defense-in-depth read at submit time that refuses only
 * after a cached balance says the user has no credits.
 *
 * The gate is session-scoped and post-run only: updates happen in the
 * background after `agent_end`, the active run is never interrupted, and
 * subagents inherit the parent run's accepted credit decision.
 */
/** Outcome returned by the credit-balance fetcher. `null` = fetch failed. */
export interface CreditBalanceOutcome {
    /** True iff the user has remaining credits OR is on an unlimited plan. */
    readonly hasCredits: boolean;
}
/** Inputs the gate consults at update time to decide whether to fetch. */
export interface CreditGateUpdateOptions {
    /** Skip the gate entirely for service-account runs. */
    readonly isServiceAccount?: boolean;
    /** Skip the gate entirely for benchmark runs. */
    readonly isBenchmark?: boolean;
    /** Skip the gate entirely when model inference is customer-paid. */
    readonly skipModelCreditGate?: boolean;
    /**
     * Skip the gate entirely for BYOK teams.
     *
     * BYOK customers don't consume Shortcut's credit pool. Hosts should prefer
     * `skipModelCreditGate` for new customer-paid inference modes.
     */
    readonly isByok?: boolean;
}
/** Host-supplied dependencies. Tests stub these; production wires HTTP fetchers. */
export interface CreditGateDeps {
    /**
     * Optional host-seeded balance. Lets browser hosts use an already-fetched
     * credit status for the first synchronous submit read while a background
     * refresh confirms the current server state.
     */
    initialCreditBalance?: CreditBalanceOutcome | null;
    /**
     * Fetch the current credit balance. Must not throw; return `null` on any
     * error so the gate can fail open.
     */
    fetchCreditBalance(): Promise<CreditBalanceOutcome | null>;
}
/**
 * Run-scoped credit gate.
 *
 * Lifecycle:
 *   1. Construct once per session.
 *   2. (Optional) Call `update()` at session start to seed the disposition
 *      before the first submit. If you skip this, the first submit will
 *      proceed unconditionally — same as backend where `credit_check_node`
 *      runs in parallel with the first call.
 *   3. On every `agent_end` (success or error), call `update()` to
 *      re-fetch in the background. The next `submit()` will see the
 *      updated disposition.
 *   4. Call `shouldHaltNextSubmit()` synchronously inside `submit()` to read
 *      the disposition. Returns `true` only when the gate has resolved AND
 *      the user has 0 / negative credits.
 *
 * The gate never blocks a submit on a fetch. If `update()` is in flight when
 * `shouldHaltNextSubmit()` is called, the read returns whatever was cached
 * from the previous resolution (or `false` if nothing has resolved yet — the
 * fail-open default).
 */
export declare class EmbeddedAgentCreditGate {
    private readonly deps;
    /** Resolved disposition. `false` until the first fetch completes. */
    private resolvedShouldHalt;
    /** True once the first fetch has completed (success, failure, or skip). */
    private hasResolved;
    /**
     * Set when update() is called with a skip flag. Once skipped for a session,
     * all subsequent reads return `false`
     * and `update()` is a no-op. The host re-builds the gate if a session's
     * identity changes (rare; not a normal flow).
     */
    private skipped;
    /** Tracks the in-flight update so concurrent callers collapse correctly. */
    private inFlight;
    constructor(deps: CreditGateDeps);
    /**
     * Background-update the cached disposition. At session start, callers pass
     * skip flags here; after run boundaries, callers usually omit options.
     * Idempotent: if a fetch is already in flight, returns the existing promise.
     */
    update(options?: CreditGateUpdateOptions): Promise<void>;
    private _runUpdate;
    /**
     * Synchronous read for `submit()` — returns `true` if the upcoming submit
     * should be refused (user is out of credits), `false` otherwise.
     *
     * Pure read of resolved state. Never blocks. Never throws.
     */
    shouldHaltNextSubmit(): boolean;
    /** Test/debug accessor — true iff the first fetch has completed. */
    get isResolved(): boolean;
    /**
     * Wait for any in-flight update to complete. Tests call this to
     * deterministically observe the resolved disposition. Production code
     * should not need this.
     */
    whenIdle(): Promise<void>;
}
//# sourceMappingURL=credit-gate.d.ts.map