/** * OpenKernel — Coder rotation engine * * Turns a dispatch request into an *ordered chain* of concrete backend configs. * The four strategies are not alternatives you pick between — they compose: * * 1. task-type routing / policy tier → choose WHICH profiles and their order * 2. round-robin → choose WHERE in that set to start * 3. fallback → the returned order IS the retry chain * * The caller runs the head; if it fails, it walks to the next entry. Because an * uninstalled backend simply reports "not available" (a failure), availability * filtering falls out of fallback for free — no need to know remote state here. */ import type { BackendId } from './types.js'; import type { CoderConfig, CoderPolicy, RotationStrategy } from './profiles.js'; /** What the orchestrator asks for. All fields optional — defaults come from config. */ export interface SelectRequest { /** Force a strategy; otherwise config.strategy (default 'auto'). */ strategy?: RotationStrategy; /** Pin an explicit profile by name (still yields config fallbacks behind it). */ profile?: string; /** Pin an explicit backend (legacy path — no rotation, exact behaviour as before). */ backend?: BackendId; /** Model override applied to the chain head. */ model?: string; /** Task-type key for routing (e.g. 'refactor', 'docs'). */ taskType?: string; /** Policy tier for ordering when strategy is policy/auto. */ policy?: CoderPolicy; } /** A concrete, directly-runnable backend selection. */ export interface ResolvedBackend { backend: BackendId; model?: string; args?: string[]; env?: Record; profileName?: string; } /** Per-node round-robin cursor, keyed by candidate-set signature. */ export declare class RotationState { private cursors; /** Advance and return the starting offset for a candidate set of length `len`. */ next(key: string, len: number): number; } /** * Build the ordered backend chain for a request. The head is what to run; the * remainder is the fallback order. Always returns at least one entry (falls back * to the config default profile, then any profile, then a bare 'claude'). */ export declare function selectChain(cfg: CoderConfig, req: SelectRequest, state: RotationState): ResolvedBackend[];