@sema-agent/core
Version:
Stateless, task-oriented AI agent core
37 lines (36 loc) • 3.48 kB
TypeScript
/**
* The FAST-TIER DOOR: a Model whose entry serves fast mode (`fastModeUnavailableFor` answers nothing in its way: `fastMode: true` on
* the Anthropic Messages wire) and whose price table EXISTS (`priceTableOf`: the deployment's entry for its id, else its own `cost`)
* is judged on the fast tier that table declares, where it is received, before any call: the catalog door at `new Runner` and
* `swapDeps` (every entry, against the deployment's `pricing`), and at a task's prepare every Model object the task or the deployment
* writes at a seat (the role maps, `TaskSpec.model`, `TaskSpec.limits.degrade.to`, and `compactSession`'s
* `model`). A tier the table judge refuses (a column missing, not a number, negative, not finite, `null` — `{}` included) is a bad value
* and is refused. A tier left out is a lawful answer — the deployment priced the standard speed only — so it is not refused: the seat
* tells the deployment once (`RunnerDeps.onError`, `phase: "config"`, {@link FAST_TIER_UNPRICED}) that a call served at fast speed has
* no price there, and such a call is booked as unpriced spend (`callRatesOf`). A host's pre-check (`catalogOfDeps`,
* `modelFaceResolvable`) answers as the door does and tells nothing. A model with no price table at all is unpriced already and is not
* judged here.
*/
import type { Model } from "../internal/llm.js";
import { type ModelPricing } from "./pricing.js";
import type { ModelRoles } from "./model-seat.js";
import type { RunnerDeps } from "./runner-deps.js";
/** The `classification` the door's notice carries on `RunnerDeps.onError` (`phase: "config"`). */
export declare const FAST_TIER_UNPRICED = "fast-tier-unpriced";
/** Where a seat tells the door's notice: the notice, and what it is about (the model and the table member it lacks) — the identity a
* seat that tells once per Runner keys on, whatever door name the entry was received under. */
export type FastTierTell = (notice: Error, about: string) => void;
/** One notice a door held to tell later (the Runner's catalog doors tell once the generation is written). */
export interface FastTierNotice {
readonly notice: Error;
readonly about: string;
}
/** A seat's tell over the deployment's operator sink: each notice once per call of the door (a task's prepare tells per task). */
export declare function fastTierNoticeTo(onError: RunnerDeps["onError"], sessionId: string): FastTierTell;
/** Judge `model` at `seat`: a bad fast tier is refused (thrown); a missing one is told to `tell` (none: a pre-check, which tells nothing). */
export declare function assertFastTierPriced(model: Model, pricing: Record<string, ModelPricing> | undefined, seat: string, tell?: FastTierTell): void;
/** The catalog door's leg: every entry of a received generation, under its key (`field` names the door, as its refusals do). */
export declare function assertFastTiersPriced(catalog: Record<string, Model> | undefined, pricing: Record<string, ModelPricing> | undefined, field: string, tell?: FastTierTell): void;
/** The role maps' leg: every Model object a received role map binds (`screenRoleMap`), at the seat it was written — the entry
* itself, or its record's `model`. A word names a catalog entry, judged at the catalog door. */
export declare function assertRoleMapFastTiersPriced(roles: ModelRoles | undefined, pricing: Record<string, ModelPricing> | undefined, field: "RunnerDeps.roles" | "TaskSpec.roles", tell?: FastTierTell): void;