import type { IncomingMessage, ServerResponse } from "node:http"; import type { ConfigReloadAttemptResult } from "../config-reload.js"; import { type Config } from "../config.js"; import type { ModelCatalog } from "../catalog.js"; import type { PingLoop } from "../ping/cadence.js"; import type { MetadataLogger } from "../log.js"; import type { CircuitBreaker } from "../circuit-breaker.js"; import { type AccountingRecorder } from "../accounting.js"; import { type LaneExecutionBrokerPort } from "../lane-execution-broker.js"; export interface AdminHandlers { catalog: ModelCatalog; pingLoop?: PingLoop; logger: MetadataLogger; breaker: CircuitBreaker; /** Package version loaded by this daemon process; absent only for an unversioned embed. */ relayVersion?: string; /** * The server's accounting ledger when it has one, narrowed to the same in-memory window read * the availability producer and G2's cap evaluator take. Optional because a bare programmatic * proxy has no store; its `/candidates` then reports no reached caps (unknown ⇒ no refusal). * The writer-health half is optional for the same reason: `/telemetry` reports * `accounting: null` without a ledger rather than a fabricated state. */ accountingReader?: Pick & Partial>; /** * The server's accounting ledger writer, narrowed to the recorder the request path writes * through. Required (unlike the reader): `POST /dispatch/telemetry` records the estimated * dispatch envelope for `cli` lanes, and a bare programmatic proxy without a store passes * the shared no-op recorder — the same default `createProxy` uses. */ accountingRecorder: AccountingRecorder; /** D1 Phase 1: injected execution broker; absent means the route fails closed with 503. */ laneExecutionBroker?: LaneExecutionBrokerPort; /** D2 atomic config transaction; absent means this embed cannot reload and answers 503. */ reloadConfig?: () => ConfigReloadAttemptResult; /** Optional shutdown callback — called by POST /stop after responding 202. A bare programmatic proxy with no onStop answers 503. */ onStop?: () => void; /** True the first time GET /telemetry observes the loaded config changed on disk, false on * every call after — so the daemon logs the fact exactly once (see config.ts `configStaleness`). */ claimConfigStalenessLogOnce: () => boolean; } /** The reason an operator pin carries onto the ladder view. Fixed text, never caller prose. */ export declare const OPERATOR_PIN_REASON = "pinned by the operator"; /** * Announces what an operator pin/unpin did, on the `POST /dispatch` response that carries the * resulting ladder view: `pinned ` / `unpinned `, plus `(replaced a live pin)` when * one existed. A lane id from config, never caller prose. */ export declare const LANE_PIN_HEADER = "x-llm-relay-lane-pin"; /** * Handles control-plane administrative endpoints. * Returns true if the request was an admin route and has been handled, false otherwise. */ export declare function handleAdminRoutes(req: IncomingMessage, res: ServerResponse, pathname: string, path: string, started: number, reqJson: unknown, cfg: Config, h: AdminHandlers): Promise;