import { type ModelCatalog, type ModelResolutionAttempt, type ModelRoutingConfig, type ModelTarget } from "./model-routing.js"; export interface OpenCodeChatMessageInput { sessionID: string; agent?: string; model?: { providerID: string; modelID: string; }; messageID?: string; } export interface OpenCodeChatMessageOutput { message: { agent?: string; model: { providerID: string; modelID: string; variant?: string; }; [key: string]: unknown; }; parts: unknown[]; } export type OpenCodeChatMessageHook = (input: OpenCodeChatMessageInput, output: OpenCodeChatMessageOutput, options?: { readonly skipPreferred?: boolean; readonly terminalRescueTarget?: ModelTarget; }) => Promise; export interface ModelRoutingHookConfiguration { readonly local?: ModelRoutingConfig; readonly global?: ModelRoutingConfig; readonly catalog: ModelCatalog; readonly dedicated?: ModelTarget; readonly freeTierFallbackModels: readonly string[]; } /** The narrow OpenCode SDK surface used to discover models configured on the current host. */ export interface OpenCodeModelAvailabilityClient { readonly v2?: { readonly model?: { readonly list?: () => Promise; }; }; readonly config?: { readonly providers?: () => Promise; }; readonly provider?: { readonly list?: () => Promise; }; } export declare class ModelRoutingDeniedError extends Error { readonly reason = "unresolved-role"; readonly role: string; readonly attempts: readonly ModelResolutionAttempt[]; constructor(role: string, attempts: readonly ModelResolutionAttempt[]); } export declare class InvalidModelTargetError extends Error { readonly reason = "invalid-model-target"; constructor(); } /** Split a `/` target into the pair every OpenCode host call expects. */ export declare function openCodeModel(model: string): { providerID: string; modelID: string; } | undefined; export declare function readHostModels(client: OpenCodeModelAvailabilityClient | undefined): Promise | undefined>; /** Resolve package policy first, then fail open when the host proves that target is unavailable. */ export declare function createModelRoutingHook(config: ModelRoutingHookConfiguration, client?: OpenCodeModelAvailabilityClient): OpenCodeChatMessageHook;