import { type Component, type AutocompleteItem, type AutocompleteProvider, type KeybindingsManager, type OverlayHandle, type OverlayOptions, type TUI } from '@earendil-works/pi-tui'; import type { ExtensionRegistryImpl } from '../../extensions/loader.js'; import type { TuiAutocompleteSuggestion, TuiCompactOptions, TuiCompactResult, TuiEditorFactory, TuiForkOptions, TuiModelRegistry, TuiNavigateTreeOptions, TuiNewSessionOptions, TuiReasoningLevel, TuiReplacedSessionContext, TuiReplacementResult, TuiReadonlySessionManager, TuiSlashCommandContext, TuiShortcutHandler, TuiSlashCommandHandler, TuiSwitchSessionOptions, TuiSystemPromptOptions, TuiTerminalInputHandler, TuiSetThemeResult, TuiTheme, TuiThemeInfo, TuiThinkingLevel, TuiVerboseLevel, TuiWorkingIndicatorOptions } from '../../extensions/types/tui.js'; import type { ChatLog } from '../components/chat-log.js'; import type { TuiHeader } from '../components/tui-header.js'; import type { TuiBottomBar } from '../components/tui-bottom-bar.js'; import type { TuiState } from '../tui-types.js'; import { TuiExtensionSurface } from './surface.js'; export interface TuiExtensionSlashCommand { originalName: string; name: string; description: string; handler: TuiSlashCommandHandler; getContext: () => TuiSlashCommandContext; } export interface TuiExtensionShortcut { key: string; description: string; handler: TuiShortcutHandler; getContext: () => TuiSlashCommandContext; } export interface TuiExtensionRuntime { surface: TuiExtensionSurface; slashCommands: TuiExtensionSlashCommand[]; shortcuts: TuiExtensionShortcut[]; autocompleteProvider: AutocompleteProvider; handleShortcut(data: string): boolean; activate(): Promise; dispose(): void; } export interface CreateTuiExtensionRuntimeOptions { registry?: ExtensionRegistryImpl; tui: TUI; chatLog: ChatLog; header: TuiHeader; bottomBar: TuiBottomBar; getState: () => TuiState; baseSlashCommands: Array<{ name: string; description: string; }>; additionalSlashCommands?: Array<{ originalName?: string; name: string; description: string; }>; keybindings?: KeybindingsManager; addInputListener?: (handler: TuiTerminalInputHandler) => () => void; setTitle?: (title: string) => void; pasteToEditor?: (text: string) => void; setEditorText?: (text: string) => void; getEditorText?: () => string; setEditorComponent?: (factory: TuiEditorFactory | undefined) => void; getEditorComponent?: () => TuiEditorFactory | undefined; getThemeObject?: () => TuiTheme; getAllThemes?: () => TuiThemeInfo[]; getTheme?: (name: string) => TuiTheme | undefined; setTheme?: (theme: string) => TuiSetThemeResult; getToolsExpanded?: () => boolean; setToolsExpanded?: (expanded: boolean) => void; getAvailableProviderCount?: () => number; getActiveSignal?: () => AbortSignal | undefined; isProjectTrusted?: () => boolean; getSessionManager?: () => TuiReadonlySessionManager; getModelRegistry?: () => TuiModelRegistry; getSystemPrompt?: () => string; getSystemPromptOptions?: () => TuiSystemPromptOptions; waitForIdle?: () => Promise; newSession?: (options?: TuiNewSessionOptions) => Promise; forkSession?: (entryId: string, options?: TuiForkOptions) => Promise; navigateTree?: (targetId: string, options?: TuiNavigateTreeOptions) => Promise; switchSession?: (sessionPath: string, options?: TuiSwitchSessionOptions) => Promise; reload?: () => Promise; sendUserMessage?: TuiReplacedSessionContext['sendUserMessage']; sendMessage?: TuiReplacedSessionContext['sendMessage']; searchWorkspaceFiles?: (sessionKey: string, query: string, options?: { limit?: number; }) => Promise>; cwd: string; fdPath: string | null; openOverlay: (component: Component, options?: OverlayOptions) => OverlayHandle | void; closeOverlay: () => void; onInvalidate: () => void; abortActive?: () => void | Promise; requestExit?: () => void; compactSession?: (options?: TuiCompactOptions) => void | Promise; setModel?: (modelRef: string) => void | Promise; setThinkingLevel?: (level: TuiThinkingLevel) => void | Promise; setReasoningLevel?: (level: TuiReasoningLevel) => void | Promise; setVerboseLevel?: (level: TuiVerboseLevel) => void | Promise; setWorkingMessage?: (message?: string) => void; setWorkingVisible?: (visible: boolean) => void; setWorkingIndicator?: (options?: TuiWorkingIndicatorOptions) => void; } declare function suggestionsToAutocompleteItems(suggestions: TuiAutocompleteSuggestion[]): AutocompleteItem[]; export declare function createTuiExtensionRuntime(opts: CreateTuiExtensionRuntimeOptions): TuiExtensionRuntime; /** Exported for tests */ export { suggestionsToAutocompleteItems };