import type { AgentPart, OpencodeClient, Event, FilePart, LspStatus, McpStatus, Todo, Message, Part, Provider, PermissionRequest, QuestionRequest, Session, SessionStatus, TextPart, Config as SdkConfig } from "@opencode-ai/sdk/v2"; import type { CliRenderer, KeyEvent, RGBA, Renderable, SlotMode } from "@opentui/core"; import type { Binding, Keymap } from "@opentui/keymap"; import { type BindingConfig, type CreateBindingLookupOptions, type KeySequenceFormatPart, type SequenceBindingLike } from "@opentui/keymap/extras"; import type { JSX, SolidPlugin } from "@opentui/solid"; import type { Config as PluginConfig, PluginOptions } from "./index.js"; export type { CliRenderer, KeyEvent, Renderable, SlotMode } from "@opentui/core"; export { stringifyKeySequence, stringifyKeyStroke } from "@opentui/keymap"; export type { Binding, KeyLike, KeySequencePart, KeyStringifyInput, StringifyOptions } from "@opentui/keymap"; export { formatCommandBindings, formatKeySequence } from "@opentui/keymap/extras"; export type { BindingConfig, BindingLookup, BindingValue, CreateBindingLookupOptions, FormatCommandBindingsOptions, FormatKeySequenceOptions, KeySequenceFormatPart, SequenceBindingLike, } from "@opentui/keymap/extras"; export declare function createBindingLookup(config: BindingConfig | undefined, options?: CreateBindingLookupOptions): import("@opentui/keymap/extras").BindingLookup; export type TuiRouteCurrent = { name: "home"; } | { name: "session"; params: { sessionID: string; prompt?: unknown; }; } | { name: string; params?: Record; }; export type TuiRouteDefinition = { name: string; render: (input: { params?: Record; }) => JSX.Element; }; export type TuiKeys = { formatSequence: (parts: readonly KeySequenceFormatPart[] | undefined) => string; formatBindings: (bindings: readonly SequenceBindingLike[] | undefined) => string | undefined; }; export type TuiKeymap = Keymap; export type TuiModeApi = { current: () => string; push: (mode: string) => () => void; }; /** * Legacy `api.command` shape kept so v1 plugins can initialize. Remove in v2. * * @deprecated Use `api.keymap.registerLayer({ commands, bindings })` instead. */ 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?: (dialog?: TuiDialogStack) => void | Promise; }; /** * Legacy `api.command` API kept so v1 plugins can initialize. Remove in v2. * * @deprecated Use `api.keymap.registerLayer`, `api.keymap.dispatchCommand`, and * `api.keymap.dispatchCommand("command.palette.show")` instead. */ export type TuiCommandApi = { /** @deprecated Use `api.keymap.registerLayer({ commands, bindings })` instead. */ register: (cb: () => TuiCommand[]) => () => void; /** @deprecated Use `api.keymap.dispatchCommand(name)` instead. */ trigger: (value: string) => void; /** @deprecated Use `api.keymap.dispatchCommand("command.palette.show")` instead. */ show: () => void; }; export type TuiDialogProps = { size?: "medium" | "large" | "xlarge"; onClose: () => void; children?: JSX.Element; }; export type TuiDialogStack = { replace: (render: () => JSX.Element, onClose?: () => void) => void; clear: () => void; setSize: (size: "medium" | "large" | "xlarge") => void; readonly size: "medium" | "large" | "xlarge"; readonly depth: number; readonly open: boolean; }; 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?: () => JSX.Element; placeholder?: string; value?: string; busy?: boolean; busyText?: string; onConfirm?: (value: string) => void; onCancel?: () => void; }; export type TuiDialogSelectOption = { title: string; value: Value; description?: string; footer?: JSX.Element | 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 TuiPromptInfo = { input: string; mode?: "normal" | "shell"; parts: (Omit | Omit | (Omit & { source?: { text: { start: number; end: number; value: string; }; }; }))[]; }; export type TuiPromptRef = { focused: boolean; current: TuiPromptInfo; set(prompt: TuiPromptInfo): void; reset(): void; blur(): void; focus(): void; submit(): void; }; export type TuiPromptProps = { sessionID?: string; visible?: boolean; disabled?: boolean; onSubmit?: () => void; ref?: (ref: TuiPromptRef | undefined) => void; hint?: JSX.Element; right?: JSX.Element; showPlaceholder?: boolean; placeholders?: { normal?: string[]; shell?: string[]; }; }; export type TuiToast = { variant?: "info" | "success" | "warning" | "error"; title?: string; message: string; duration?: number; }; export type TuiAttentionWhen = "always" | "focused" | "blurred"; export declare const TuiAttentionSoundNames: readonly ["default", "question", "permission", "error", "done", "subagent_done"]; export type TuiAttentionSoundName = (typeof TuiAttentionSoundNames)[number]; export type TuiAttentionSound = boolean | { name?: TuiAttentionSoundName; volume?: number; when?: TuiAttentionWhen; }; export type TuiAttentionNotification = boolean | { when?: TuiAttentionWhen; }; export type TuiAttentionSoundPack = { id: string; name?: string; sounds: Partial>; }; export type TuiAttentionSoundPackInfo = { id: string; name?: string; active: boolean; builtin: boolean; }; export type TuiAttentionSoundboardActivateOptions = { persist?: boolean; }; export type TuiAttentionSoundboard = { registerPack(pack: TuiAttentionSoundPack): () => void; activate(id: string, options?: TuiAttentionSoundboardActivateOptions): boolean; current(): string; list(): ReadonlyArray; }; export type TuiAttentionNotifyInput = { title?: string; message: string; notification?: TuiAttentionNotification; sound?: TuiAttentionSound; }; export type TuiAttentionNotifySkipReason = "attention_disabled" | "empty_message" | "blurred" | "focused" | "focus_unknown" | "renderer_destroyed"; export type TuiAttentionNotifyResult = { ok: boolean; notification: boolean; sound: boolean; skipped?: TuiAttentionNotifySkipReason; }; export type TuiAttention = { notify(input: TuiAttentionNotifyInput): Promise; soundboard: TuiAttentionSoundboard; }; export type TuiThemeCurrent = { readonly primary: RGBA; readonly secondary: RGBA; readonly accent: RGBA; readonly error: RGBA; readonly warning: RGBA; readonly success: RGBA; readonly info: RGBA; readonly text: RGBA; readonly textMuted: RGBA; readonly selectedListItemText: RGBA; readonly background: RGBA; readonly backgroundPanel: RGBA; readonly backgroundElement: RGBA; readonly backgroundMenu: RGBA; readonly border: RGBA; readonly borderActive: RGBA; readonly borderSubtle: RGBA; readonly diffAdded: RGBA; readonly diffRemoved: RGBA; readonly diffContext: RGBA; readonly diffHunkHeader: RGBA; readonly diffHighlightAdded: RGBA; readonly diffHighlightRemoved: RGBA; readonly diffAddedBg: RGBA; readonly diffRemovedBg: RGBA; readonly diffContextBg: RGBA; readonly diffLineNumber: RGBA; readonly diffAddedLineNumberBg: RGBA; readonly diffRemovedLineNumberBg: RGBA; readonly markdownText: RGBA; readonly markdownHeading: RGBA; readonly markdownLink: RGBA; readonly markdownLinkText: RGBA; readonly markdownCode: RGBA; readonly markdownBlockQuote: RGBA; readonly markdownEmph: RGBA; readonly markdownStrong: RGBA; readonly markdownHorizontalRule: RGBA; readonly markdownListItem: RGBA; readonly markdownListEnumeration: RGBA; readonly markdownImage: RGBA; readonly markdownImageText: RGBA; readonly markdownCodeBlock: RGBA; readonly syntaxComment: RGBA; readonly syntaxKeyword: RGBA; readonly syntaxFunction: RGBA; readonly syntaxVariable: RGBA; readonly syntaxString: RGBA; readonly syntaxNumber: RGBA; readonly syntaxType: RGBA; readonly syntaxOperator: RGBA; readonly syntaxPunctuation: RGBA; readonly thinkingOpacity: number; }; export type TuiTheme = { readonly current: TuiThemeCurrent; readonly selected: string; has: (name: string) => boolean; set: (name: string) => boolean; install: (jsonPath: string) => Promise; mode: () => "dark" | "light"; readonly ready: boolean; }; export type TuiKV = { get: (key: string, fallback?: Value) => Value; set: (key: string, value: unknown) => void; readonly ready: boolean; }; export type TuiState = { readonly ready: boolean; readonly config: SdkConfig; readonly provider: ReadonlyArray; readonly path: { state: string; config: string; worktree: string; directory: string; }; readonly vcs: { branch?: string; } | undefined; session: { count: () => number; get: (sessionID: string) => Session | undefined; diff: (sessionID: string) => ReadonlyArray; todo: (sessionID: string) => ReadonlyArray; messages: (sessionID: string) => ReadonlyArray; status: (sessionID: string) => SessionStatus | undefined; permission: (sessionID: string) => ReadonlyArray; question: (sessionID: string) => ReadonlyArray; }; part: (messageID: string) => ReadonlyArray; lsp: () => ReadonlyArray; mcp: () => ReadonlyArray; }; type TuiBindingLookupView = { readonly bindings: ReadonlyArray>; get: (command: string) => ReadonlyArray>; has: (command: string) => boolean; gather: (name: string, commands: readonly string[]) => ReadonlyArray>; pick: (name: string, commands: readonly string[]) => Binding[]; omit: (name: string, commands: readonly string[]) => Binding[]; }; type TuiAttentionConfigView = { enabled: boolean; notifications: boolean; sound: boolean; volume: number; sound_pack: string; sounds: Partial>; }; type TuiConfigView = Pick & NonNullable & { leader_timeout: number; attention: TuiAttentionConfigView; plugin_enabled?: Record; keybinds: TuiBindingLookupView; }; export type TuiApp = { readonly version: string; }; type Frozen = Value extends (...args: never[]) => unknown ? Value : Value extends ReadonlyArray ? ReadonlyArray> : Value extends object ? { readonly [Key in keyof Value]: Frozen; } : Value; export type TuiSidebarMcpItem = { name: string; status: McpStatus["status"]; error?: string; }; export type TuiSidebarLspItem = Pick; export type TuiSidebarTodoItem = Pick; export type TuiSidebarFileItem = { file: string; additions: number; deletions: number; }; export type TuiHostSlotMap = { app: {}; app_bottom: {}; home_logo: {}; home_prompt: { ref?: (ref: TuiPromptRef | undefined) => void; }; home_prompt_right: {}; session_prompt: { session_id: string; visible?: boolean; disabled?: boolean; on_submit?: () => void; ref?: (ref: TuiPromptRef | undefined) => void; }; session_prompt_right: { session_id: string; }; home_bottom: {}; home_footer: {}; sidebar_title: { session_id: string; title: string; share_url?: string; }; sidebar_content: { session_id: string; }; sidebar_footer: { session_id: string; }; }; export type TuiSlotMap = {}> = TuiHostSlotMap & Slots; type TuiSlotShape> = Name extends keyof TuiHostSlotMap ? TuiHostSlotMap[Name] : Name extends keyof Slots ? Slots[Name] : Record; export type TuiSlotProps = {}> = { name: Name; mode?: SlotMode; children?: JSX.Element; } & TuiSlotShape; export type TuiSlotContext = { theme: TuiTheme; }; type SlotCore = {}> = SolidPlugin, TuiSlotContext>; export type TuiSlotPlugin = {}> = Omit, "id"> & { id?: never; }; export type TuiSlots = { register: { (plugin: TuiSlotPlugin): string; >(plugin: TuiSlotPlugin): string; }; }; export type TuiEventBus = { on: (type: Type, handler: (event: Extract) => void) => () => void; }; export type TuiDispose = () => void | Promise; export type TuiLifecycle = { readonly signal: AbortSignal; onDispose: (fn: TuiDispose) => () => void; }; export type TuiPluginState = "first" | "updated" | "same"; export type TuiPluginEntry = { id: string; source: "file" | "npm" | "internal"; spec: string; target: string; requested?: string; version?: string; modified?: number; first_time: number; last_time: number; time_changed: number; load_count: number; fingerprint: string; }; export type TuiPluginMeta = TuiPluginEntry & { state: TuiPluginState; }; export type TuiPluginStatus = { id: string; source: TuiPluginEntry["source"]; spec: string; target: string; enabled: boolean; active: boolean; }; export type TuiPluginInstallOptions = { global?: boolean; }; export type TuiPluginInstallResult = { ok: true; dir: string; tui: boolean; } | { ok: false; message: string; missing?: boolean; }; export type TuiWorkspace = { current: () => string | undefined; set: (workspaceID?: string) => void; }; export type TuiPluginApi = { app: TuiApp; attention: TuiAttention; /** * Legacy `api.command` API kept so v1 plugins can initialize. Remove in v2. * * @deprecated Use `api.keymap.registerLayer`, `api.keymap.dispatchCommand`, and * `api.keymap.dispatchCommand("command.palette.show")` instead. */ command?: TuiCommandApi; keys: TuiKeys; keymap: TuiKeymap; mode: TuiModeApi; route: { register: (routes: TuiRouteDefinition[]) => () => void; navigate: (name: string, params?: Record) => void; readonly current: TuiRouteCurrent; }; ui: { Dialog: (props: TuiDialogProps) => JSX.Element; DialogAlert: (props: TuiDialogAlertProps) => JSX.Element; DialogConfirm: (props: TuiDialogConfirmProps) => JSX.Element; DialogPrompt: (props: TuiDialogPromptProps) => JSX.Element; DialogSelect: (props: TuiDialogSelectProps) => JSX.Element; Slot: (props: TuiSlotProps) => JSX.Element | null; Prompt: (props: TuiPromptProps) => JSX.Element; toast: (input: TuiToast) => void; dialog: TuiDialogStack; }; readonly tuiConfig: Frozen; kv: TuiKV; state: TuiState; theme: TuiTheme; client: OpencodeClient; event: TuiEventBus; renderer: CliRenderer; slots: TuiSlots; plugins: { list: () => ReadonlyArray; activate: (id: string) => Promise; deactivate: (id: string) => Promise; add: (spec: string) => Promise; install: (spec: string, options?: TuiPluginInstallOptions) => Promise; }; lifecycle: TuiLifecycle; }; export type TuiPlugin = (api: TuiPluginApi, options: PluginOptions | undefined, meta: TuiPluginMeta) => Promise; export type TuiPluginModule = { id?: string; tui: TuiPlugin; server?: never; };