import type { DemandPayload } from "../protocol/index.ts"; import { type DiversityReport, type RegisteredWorker, type VocabResolver } from "../vocab/index.ts"; import { type TaskDefinitionLeaf } from "./taskdef.ts"; /** The SLO grade — same three-level scale as the S3 diversity SLO. */ export type SloStatus = "green" | "amber" | "red"; /** One demanded routing token and the live supply against it. */ export interface TokenDemand { /** The demanded routing token (a `taskDefinition` leaf's type). */ readonly token: string; /** How many registered workers currently serve this token. */ readonly supply: number; /** The instances serving it, sorted — provenance for the cockpit drill-in. */ readonly instances: readonly string[]; /** False when no registered worker serves it — a missing agent type. */ readonly satisfied: boolean; } /** The demand×supply picture for one network prefix. */ export interface NetworkDemand { /** The network prefix bucket (`network` segment, or a bare token's own name). */ readonly network: string; /** Every demanded token in the bucket, sorted by token. */ readonly tokens: readonly TokenDemand[]; /** The demanded tokens in this bucket with zero supply, sorted. */ readonly missing: readonly string[]; } /** The full demand×supply report. */ export interface DemandSupplyReport { /** Per-network demand×supply, sorted by network. */ readonly networks: readonly NetworkDemand[]; /** Every missing agent type across all networks, sorted and de-duplicated. */ readonly missing: readonly string[]; /** The S3 diversity SLO over the correlated live registry. */ readonly diversity: DiversityReport; /** The overall SLO state: worst of the missing-agent signal and diversity. */ readonly status: SloStatus; /** * Deployed `taskDefinition` types that carry NO `linkName="prompt"` linked * resource — ordinary (non-agentic) in-process C8 jobs the engine also runs * (e.g. the deterministic `pr.*` workers). Classification is by the prompt * signal, not the token string, so a prompt-less type is `nonAgentic` even when * it happens to parse as a routing token. Surfaced (not silently dropped) so an * operator can spot a mis-modelled task, but excluded from the agentic * demand×supply accounting. */ readonly nonAgentic: readonly string[]; } /** Input to {@link computeDemandSupply}. */ export interface DemandSupplyInput { /** Demand: the deployed `taskDefinition` leaves (order-insensitive). */ readonly taskDefinitions: readonly TaskDefinitionLeaf[]; /** Supply: the live S2 registry rows. */ readonly workers: readonly RegisteredWorker[]; /** The S3 resolver over the resolved vocabulary artifact. */ readonly resolver: VocabResolver; } /** * Compute the demand×supply model from deployed demand and live supply. * * Pure and deterministic: the same demand + registry + vocab always yields the * same report, with every list sorted, so it is safe to diff frame-to-frame and * to render straight into the cockpit. */ export declare function computeDemandSupply(input: DemandSupplyInput): DemandSupplyReport; /** * Project the report onto the S0 `demand` message family — one {@link DemandPayload} * per network carrying its missing agent types, so the gap can cross the agentic * channel's control/facts lane. Emits an entry for every network (missing may be * empty), sorted by network, so a consumer sees a cleared network flip from a * non-empty `missing` back to `[]`. */ export declare function toDemandPayloads(report: DemandSupplyReport): DemandPayload[];