import type { Provider, ProviderConfig } from "../providers/ProviderTypes.js"; import type { CodaliGatewayAgentAssignment } from "./AgentTierResolver.js"; /** * Builds a `Provider` from a resolved mcoda agent so the gateway can run * in-process from the CLI, without a round trip through mswarm. * * mswarm keeps its own cloud path; both should end up sharing this factory so * local and cloud behaviour cannot drift. */ export interface LocalProviderOptions { timeoutMs?: number; apiKey?: string; /** Scheduling priority; lower runs sooner. Defaults to CODALI_MSWARM_PRIORITY. */ priority?: number; /** * Who this run is for, as mswarm knows them — a tenant slug such as `wodo`. * * mswarm lets a node be reached two ways: the caller owns it, or the caller's * identity appears in the node's `client_allowlist`. The second route is how * a tenant reaches a node someone else operates, and it is what the * self-hosted setup console configures. It requires the caller to say who it * is. `DocdexClient` already did; model calls did not, so a tenant could * reach an allowlisted repository and never an allowlisted model. */ clientIdentity?: string; clientProduct?: string; } /** * Scheduling priority Codali asks mswarm for. * * mswarm sorts ascending, so a lower number runs sooner, and its nodes reserve * capacity for priority <= -1. Codali runs are interactive — someone is waiting * at a terminal or in a chat window — so they should not queue behind batch * work. -10 sits comfortably inside the reserved band without claiming the * extreme of the -100..100 range, leaving room for anything genuinely more * urgent. */ export declare const CODALI_MSWARM_PRIORITY = -10; /** * mcoda adapter -> Codali provider. Adapters not listed fall through to the * OpenAI-compatible provider, which is the correct default for local runners * (llama.cpp, vLLM, LocalAI) and most hosted endpoints. */ export declare const providerNameForAdapter: (adapter: string | undefined) => string; export declare const createProviderForName: (name: string, config: ProviderConfig) => Provider; export declare const resolveMswarmApiKey: () => string | undefined; /** * The key for a self-hosted agent that is not behind the mswarm relay. * * mcoda stores agent secrets encrypted (`agent_auth.encrypted_secret`) and * `agent list --json` reports only whether one is configured, so an agent * registered with `authMode: bearer` and a direct base URL arrives here with no * key at all. The provider then threw before making any request, which surfaced * as a worker failing in 0ms on every call while the run still reported * success — the finalizer answered without evidence rather than the run * stopping on a configuration error. * * Codali therefore takes the key from the operator's own environment, matching * how the mswarm key is read from local trusted config. The per-agent form wins * so several self-hosted models can be used at once. */ export declare const localAgentApiKeyEnvVar: (slug: string) => string; /** * Creates a provider for an assigned agent. The raw inventory entry carries the * transport details (base URL, runner kind, auth mode) that the tier resolver * does not model, so it is read here. */ export declare const createProviderForAssignment: (assignment: CodaliGatewayAgentAssignment, options?: LocalProviderOptions) => Provider; /** * Routes each gateway role to its own provider. * * Codali's whole premise is that a small model does the errands and a large one * writes the answer. A single shared provider would silently collapse that: the * planner and the synthesizer would run on the same model and the cost/quality * split would be lost. So role dispatch is explicit, with a declared fallback * rather than an accidental one. */ export declare class RoleRoutingProvider implements Provider { private readonly providers; private readonly fallback; private readonly resolveRole; readonly name = "codali-role-router"; constructor(providers: Record, fallback: Provider, resolveRole?: () => string | undefined); providerForRole(role: string | undefined): Provider; generate(request: Parameters[0]): ReturnType; } //# sourceMappingURL=LocalGatewayProvider.d.ts.map