/** * Auto-setup of models & providers for forge agents/subagents. * * Philosophy (mirrors oh-my-opencode's model-requirements approach): * 1. Determine which providers the user has access to — either from the * interactive `setup-models install` CLI (user answers yes/no to each * subscription) or from the opencode server's `/provider` response * at plugin startup (`connected` list). * 2. For each agent, walk its prioritized chain (`AGENT_CHAINS`) and pick * the FIRST chain entry whose provider set intersects the user's * providers AND whose model name is present in that provider's catalog. * Subsequent matches form the `fallback_models` array. * 3. Persist the resulting mapping to `forge-config.jsonc` under * `agents..{model, fallback_models}`. * * Model-name matching is prefix-based (case-insensitive) so that a chain * entry like `claude-opus-4` transparently picks up `claude-opus-4-5`, * `claude-opus-4-7`, etc. as providers publish newer versions. */ import type { PluginConfig, Logger } from '../types'; import { type ChainEntry, type SupportedProvider } from './model-requirements'; /** Minimal provider catalog used by the resolver. */ export interface ProviderCatalog { /** provider id → set of available model ids. */ models: Map>; /** Providers the opencode server says are authenticated/reachable. */ connected: Set; } /** * Loose client shape — the SDK overloads are awkward to match structurally. * We only rely on `provider.list` returning `{ data?, error? }`. */ export type AutoSetupClient = { provider: { list: (...args: any[]) => any; }; }; export interface AgentAssignment { agent: string; model: string; fallback_models: string[]; profileRationale: string; } export declare function fetchProviderCatalog(client: AutoSetupClient, directory: string | undefined): Promise; /** * Pick the best concrete `providerID/modelID` for a single chain entry given * the user's available providers and the catalog of published models. */ export declare function resolveChainEntry(entry: ChainEntry, availableProviders: Set, catalog: ProviderCatalog | null): { provider: string; modelId: string; full: string; } | null; export declare function resolveAgentChain(agent: string, availableProviders: Set, catalog: ProviderCatalog | null): { primary: string; fallbacks: string[]; rationale: string; } | null; export declare function computeAgentAssignments(availableProviders: Set, pluginConfig: PluginConfig, catalog: ProviderCatalog | null, opts?: { overwrite?: boolean; maxFallbacks?: number; }): AgentAssignment[]; export declare function mergeAssignmentsIntoConfig(pluginConfig: PluginConfig, assignments: AgentAssignment[]): PluginConfig; export declare function persistAgentAssignments(assignments: AgentAssignment[], logger: Pick): { written: boolean; reason?: string; }; export declare function runAutoModelSetup(client: AutoSetupClient, directory: string | undefined, pluginConfig: PluginConfig, logger: Pick, opts?: { overwrite?: boolean; persist?: boolean; }): Promise; export type { SupportedProvider }; //# sourceMappingURL=auto-model-setup.d.ts.map