/** * The endpoint that answers before the call is sent. * * **Loopback only, and the address is not a flag.** A cost oracle listening on * a network interface is an attack surface with a very small upside: it holds * a company's spend, its model mix and its budgets, and it answers anybody who * asks. `checkedEndpoint` has guarded Trazum's *outbound* requests since 1.14 * on the principle that a caller selects an endpoint rather than naming one; * this is the inbound counterpart, and it is enforced the same way — by there * being no way to say otherwise. `127.0.0.1` is compiled in. A Unix socket is * offered for callers that would rather not use a port at all. * * **No auth, on purpose.** Anything reachable only from the machine it runs on * is already behind the operating system's own boundary, and a token checked * over loopback is theatre: whoever can reach the socket can read the token * out of the process that holds it. The honest posture is a surface small * enough not to need one. * * **It degrades rather than failing.** With no store and no budget the * endpoint still prices the call from the bundled catalogue and says the * budget half is unknown. Offline is a mode, not an error, and an oracle that * refuses to speak when half its inputs are missing is an oracle nobody wires * into a hot path. */ import type { Server } from 'node:http'; import type { LimitsConfig, MeasuredPosition, PricingCatalogue, WaiveEntry } from '@trazum/core'; /** Compiled in. See the module note: this is the inbound SSRF posture. */ export declare const BIND_HOST = "127.0.0.1"; export declare const DEFAULT_PORT = 7317; /** * Bodies larger than this are refused unread. * * A prompt is text and text is unbounded; a hot-path oracle that will buffer * whatever it is handed is a memory exhaustion away from taking the caller * down with it — and the caller was asking how to spend *less*. */ export declare const MAX_BODY_BYTES = 1000000; export interface ServeContext { catalogue: PricingCatalogue; /** * Measured spend and the budget it is judged against, read once at start * and refreshed by the caller. * * Read once because the whole promise here is single-digit milliseconds, * and a file read in the request path cannot make that promise. The staleness * is a real cost, so the answer carries the window its measurement covers * rather than implying it is current to the second. */ position: () => { consumedUsd?: number; limitUsd?: number; window?: { fromMs: number; toMs: number; } | null; }; /** The `limits` block, when the config carries one. */ limits?: LimitsConfig; /** * The measured position for one call's scopes — from an index built once * at start, same staleness posture as `position`. */ measured?: (call: { label?: string; session?: string; }) => MeasuredPosition; /** The config's `waive` list — a silenced limit answers within, on the record. */ waivers?: readonly WaiveEntry[]; } export declare function buildServer(context: ServeContext): Server; export interface ListenTarget { /** A Unix socket path, when the caller would rather not use a port. */ socket?: string; port?: number; } export declare function listen(server: Server, target: ListenTarget): Promise; //# sourceMappingURL=serve.d.ts.map