import type { createOpencodeClient as createOpencodeClientV2, Event as TuiEvent } from "@opencode-ai/sdk/v2" import type { CliRenderer, ParsedKey, Plugin as CorePlugin } from "@opentui/core" import type { Plugin as ServerPlugin, PluginOptions } from "./index" export type { CliRenderer, SlotMode } from "@opentui/core" type HexColor = `#${string}` type RefName = string type Variant = { dark: HexColor | RefName | number light: HexColor | RefName | number } type ThemeColorValue = HexColor | RefName | number | Variant export type ThemeJson = { $schema?: string defs?: Record theme: Record & { selectedListItemText?: ThemeColorValue backgroundMenu?: ThemeColorValue thinkingOpacity?: number } } export type TuiRouteCurrent = | { name: "home" } | { name: "session" params: { sessionID: string initialPrompt?: unknown } } | { name: string params?: Record } export type TuiRouteDefinition = { name: string render: (input: { params?: Record }) => Node } export type TuiCommand = { title: string value: string description?: string category?: string keybind?: string suggested?: boolean hidden?: boolean enabled?: boolean slash?: { name: string aliases?: string[] } onSelect?: () => void } export type TuiKeybind = { name: string ctrl: boolean meta: boolean shift: boolean super?: boolean leader: boolean } export type TuiDialogProps = { size?: "medium" | "large" onClose: () => void children?: Node } export type TuiDialogAlertProps = { title: string message: string onConfirm?: () => void } export type TuiDialogConfirmProps = { title: string message: string onConfirm?: () => void onCancel?: () => void } export type TuiDialogPromptProps = { title: string description?: () => Node placeholder?: string value?: string onConfirm?: (value: string) => void onCancel?: () => void } export type TuiDialogSelectOption = { title: string value: Value description?: string footer?: Node | string category?: string disabled?: boolean onSelect?: () => void } export type TuiDialogSelectProps = { title: string placeholder?: string options: TuiDialogSelectOption[] flat?: boolean onMove?: (option: TuiDialogSelectOption) => void onFilter?: (query: string) => void onSelect?: (option: TuiDialogSelectOption) => void skipFilter?: boolean current?: Value } export type TuiToast = { variant?: "info" | "success" | "warning" | "error" title?: string message: string duration?: number } export type TuiApi = { command: { register: (cb: () => TuiCommand[]) => void trigger: (value: string) => void } route: { register: (routes: TuiRouteDefinition[]) => () => void navigate: (name: string, params?: Record) => void readonly current: TuiRouteCurrent } ui: { Dialog: (props: TuiDialogProps) => Node DialogAlert: (props: TuiDialogAlertProps) => Node DialogConfirm: (props: TuiDialogConfirmProps) => Node DialogPrompt: (props: TuiDialogPromptProps) => Node DialogSelect: (props: TuiDialogSelectProps) => Node toast: (input: TuiToast) => void } keybind: { parse: (evt: ParsedKey) => TuiKeybind match: (key: string, evt: ParsedKey) => boolean print: (key: string) => string } theme: { readonly current: Record } } export type TuiSlotMap = { app: {} home_logo: {} sidebar_top: { session_id: string } } export type TuiSlotContext = {} export type TuiSlotPlugin = CorePlugin export type TuiSlots = { register: (plugin: TuiSlotPlugin) => () => void } export type TuiEventBus = { on: ( type: Type, handler: (event: Extract) => void, ) => () => void } export type TuiPluginInput = { client: ReturnType event: TuiEventBus renderer: Renderer slots: TuiSlots api: TuiApi } export type TuiPlugin = ( input: TuiPluginInput, options?: PluginOptions, ) => Promise export type TuiPluginModule = { server?: ServerPlugin tui?: TuiPlugin slots?: TuiSlotPlugin themes?: Record }