import type { PluginInput } from "@opencode-ai/plugin"; import type { RuntimeFallbackConfig, OpenCodeCodexOrchConfig } from "../../config"; export interface FallbackState { originalModel: string; currentModel: string; fallbackIndex: number; failedModels: Map; attemptCount: number; pendingFallbackModel?: string; } export interface FallbackResult { success: boolean; newModel?: string; error?: string; maxAttemptsReached?: boolean; } export interface RuntimeFallbackOptions { config?: RuntimeFallbackConfig; pluginConfig?: OpenCodeCodexOrchConfig; session_timeout_ms?: number; } export interface RuntimeFallbackHook { event: (input: { event: { type: string; properties?: unknown; }; }) => Promise; "chat.message"?: (input: { sessionID: string; agent?: string; model?: { providerID: string; modelID: string; }; }, output: { message: { model?: { providerID: string; modelID: string; }; }; parts?: Array<{ type: string; text?: string; }>; }) => Promise; } export interface HookDeps { ctx: PluginInput; config: Required; options: RuntimeFallbackOptions | undefined; pluginConfig: OpenCodeCodexOrchConfig | undefined; sessionStates: Map; sessionLastAccess: Map; sessionRetryInFlight: Set; sessionAwaitingFallbackResult: Set; sessionFallbackTimeouts: Map>; }