import { type SpendMeter } from "../../brain/spend-meter.js";
import type { SpendAccount } from "../spend-account.js";
import type { CacheRetention } from "../../internal/llm.js";
import type { Brain } from "../types.js";
import type { Context } from "../../internal/llm.js";
/** The deployment's retention word as `field` carries it: absent ⇒ `undefined`, a word ⇒ the word, anything else refused
 *  (`config.invalid_argument`, `detail.field`) — the construction door's screen and every read of the Brain seat ask here. */
export declare function receiveCacheRetention(value: unknown, field: string): CacheRetention | undefined;
/**
 * The deps bag one run reads its model lane from: `deps` itself, with the run's meter riding it — every call of the run that
 * reads `modelLaneBrainOf` over this bag (or a bag spread from it) has each real request (each hop of a walk) admitted by the
 * run's spend account first (`brain/spend-meter.ts`). The deployment's bag is untouched; the budget-excluded passes (prompt
 * suggestions, memory consolidation) read the deployment's bag.
 *
 * The meter is built here, not by the run: what rides the bag is the run's account node and a read of this bag's own price
 * tables, nothing of the run itself. A seat that outlives the run may keep the bag it was handed (a session's drain reads the
 * deployment's seats off it), and a closure minted inside the run would keep the whole run reachable through it.
 */
export declare function meteredDepsOf<D extends {
    readonly brain: Brain;
    readonly pricing?: ReturnType<SpendMeter["pricing"]>;
}>(deps: D, account: SpendAccount): D;
/** The deployment's own bag behind a run's bag (itself for a bag that is no run's): the identity a once-per-deployment side
 *  table keys on — a run's metered bag is a fresh object per run, and keying on it would say "once per deployment" once per run. */
export declare function deploymentBagOf(deps: object): object;
/** Carry `from`'s deployment identity (`DEPLOYMENT_BAG`) onto a shallow copy minted before {@link meteredDepsOf} (e.g.
 *  role-map normalisation), so once-per-deployment side tables still key on the deployment's own bag. */
export declare function keepDeploymentOf<D extends object>(from: object, copy: D): D;
/** A value staged with the request context it describes and kept (`commit`) only when the deployment's Brain is handed that
 *  very context ({@link modelLaneBrainOf}'s `dispatched`): a request refused before dispatch (the spend gate, a refused route)
 *  keeps the previous value, and a call the lane did not stage (a summary request on the same lane) commits nothing. */
export declare function stagedDispatch<T>(commit: (value: T) => void): {
    stage(context: Context, value: T): void;
    dispatched(context: Context): void;
};
/** The meter a run's bag carries, if it is one. */
export declare function meterOf(deps: object): SpendMeter | undefined;
/** The model lane over a deps bag's Brain seat and its fallback policy (`RunnerDeps.modelFallback`; absent ⇒ the default gate),
 *  writing the bag's retention word (`RunnerDeps.cacheRetention`) on every call when it sets one. A run's bag
 *  ({@link meteredDepsOf}) walks the lane over the run's meter, so every hop is admitted on its own. `dispatched` (the main loop's
 *  {@link stagedDispatch}) is told each context the deployment's Brain is handed — inside the spend gate and the route walk. */
export declare function modelLaneBrainOf(deps: {
    readonly brain: Brain;
    readonly modelFallback?: unknown;
    readonly cacheRetention?: unknown;
}, dispatched?: (context: Context) => void): Brain;
/**
 * The session's prompt-cache key — minted here, once per leg, and nowhere else (`StreamOptions.promptCacheKey`):
 * `base64url(HMAC-SHA256(salt, label + scope))` over the session's own hash salt (16 random bytes kept only in its store, the same
 * across its runs, Runners and processes) and the task's isolation scope (`scopeKeyOf`). One session in one scope derives one key;
 * two sessions never share one (two random salts); a session carried into another scope (a fork, an import) derives another; a
 * reader holding the principal and the session id but not the store cannot compute it. A salt that holds for this leg only (the
 * store could not read or keep it) derives none: a key that changed every leg would move the session to another routing group
 * each leg, which is worse than sending none.
 */
export declare function legPromptCacheKey(salt: {
    readonly salt: Uint8Array;
    readonly scope: string;
}, scope: string): string | undefined;
/**
 * A leg's main-loop carrier over its seat lane — the one place the main loop's own marks are written, on `stream` only (a
 * compaction pass, the fork, the classifier, the advisor and side queries read their own Brain): the deployment's history cache
 * mark (`RunnerDeps.historyCacheMark`) and the session's prompt-cache key ({@link legPromptCacheKey}, over any value the call
 * brought). Neither ⇒ the seat's own object. The key's minted value rides back beside the carrier: the leg's reuse-form summaries
 * carry the same one (`ForkRequestControls.promptCacheKey`), and the lane under the seat hands it on only to a hop that declares it.
 */
export declare function mainLoopLane(seat: Brain, leg: {
    readonly historyCacheMark: boolean;
    readonly salt: {
        readonly salt: Uint8Array;
        readonly scope: string;
    };
    readonly scope: string;
}): {
    readonly brain: Brain;
    readonly cacheKey: string | undefined;
};
