/** * Shared types for the opencode-bridge frontend. * * These mirror the Python server's `CellContext` / `OpenCodeRequest` / `OpenCodeResponse` * shapes in `opencode_bridge/routes.py`. Keep them in sync. * * v3-final: the JupyterLab plugin settings have been removed entirely. * All connection config lives in startup environment variables (see * `opencode_bridge/config.py`); the inline model picker is fully dynamic. */ export interface ErrorOutput { ename: string; evalue: string; traceback: string[]; } export interface CellContext { notebookPath: string; cellId: string; language: string; cellIndex: number; totalCells: number; source: string; previousCode: string | null; error: ErrorOutput | null; } export interface OpenCodeRequest { prompt: string; context: CellContext; providerId?: string; modelId?: string; } export interface OpenCodeSuccess { ok: true; /** The AI's reply as markdown (code in ```fences```, optional explanation). * Render with marked. The cell source is NOT replaced. */ markdown: string; sessionId: string; notebookPath: string; } export interface OpenCodeFailure { ok: false; error: string; } export type OpenCodeResponse = OpenCodeSuccess | OpenCodeFailure; /** Response from GET /opencode-bridge/session-messages?notebook=... . * Projected from OpenCode's {info, parts}[] by the server into a * frontend-friendly {role, content}[]. */ export interface OpenCodeMessage { role: "user" | "assistant"; content: string; } export interface OpenCodeMessagesResponse { messages: OpenCodeMessage[]; } /** Response from GET /opencode-bridge/providers (proxies OpenCode /config/providers). * Each Provider.models is a Record keyed by modelID (NOT an array). */ export interface OpenCodeModel { id: string; name?: string; [k: string]: unknown; } export interface OpenCodeProvider { id: string; name?: string; source?: string; models: { [modelID: string]: OpenCodeModel }; } export interface OpenCodeProvidersResponse { providers: OpenCodeProvider[]; default?: { [providerID: string]: string }; }