Files
notebook-ai-extension/src/types.ts
T

59 lines
1.3 KiB
TypeScript

/**
* 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;
finalSource: string;
sessionId: string;
notebookPath: string;
}
export interface OpenCodeFailure {
ok: false;
error: string;
}
export type OpenCodeResponse = OpenCodeSuccess | OpenCodeFailure;
/** Response from GET /opencode-bridge/providers. */
export interface OpenCodeProvider {
id: string;
models: { id: string; [k: string]: unknown }[];
}
export interface OpenCodeProvidersResponse {
providers: OpenCodeProvider[];
}