import { type Agent, type AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { CompactionOutcome } from "@oh-my-pi/pi-agent-core/compaction"; import { type AssistantMessage, type ImageContent, type Message, type UsageReport } from "@oh-my-pi/pi-ai"; import type { Component, EditorTheme } from "@oh-my-pi/pi-tui"; import { Container, Loader, Spacer, Text, TUI } from "@oh-my-pi/pi-tui"; import { KeybindingsManager } from "../config/keybindings"; import { Settings } from "../config/settings"; import type { ExtensionUIContext, ExtensionUIDialogOptions, ExtensionWidgetContent, ExtensionWidgetOptions } from "../extensibility/extensions"; import type { CompactOptions } from "../extensibility/extensions/types"; import { type PlanApprovalDetails } from "../plan-mode/approved-plan"; import type { AgentSession, AgentSessionEvent } from "../session/agent-session"; import { HistoryStorage } from "../session/history-storage"; import type { SessionContext, SessionManager } from "../session/session-manager"; import type { LspStartupServerInfo } from "../tools"; import type { EventBus } from "../utils/event-bus"; import type { AssistantMessageComponent } from "./components/assistant-message"; import type { BashExecutionComponent } from "./components/bash-execution"; import { CustomEditor } from "./components/custom-editor"; import type { EvalExecutionComponent } from "./components/eval-execution"; import type { HookEditorComponent } from "./components/hook-editor"; import type { HookInputComponent } from "./components/hook-input"; import type { HookSelectorComponent } from "./components/hook-selector"; import { StatusLineComponent } from "./components/status-line"; import type { ToolExecutionHandle } from "./components/tool-execution"; import { type LoopLimitRuntime } from "./loop-limit"; import { OAuthManualInputManager } from "./oauth-manual-input"; import type { Theme } from "./theme/theme"; import type { CompactionQueuedMessage, InteractiveModeContext, SubmittedUserInput, TodoItem, TodoPhase } from "./types"; /** Options for creating an InteractiveMode instance (for future API use) */ export interface InteractiveModeOptions { /** Providers that were migrated during startup */ migratedProviders?: string[]; /** Warning message if model fallback occurred */ modelFallbackMessage?: string; /** Initial message to send */ initialMessage?: string; /** Initial images to include with the message */ initialImages?: ImageContent[]; /** Additional initial messages to queue */ initialMessages?: string[]; } export declare class InteractiveMode implements InteractiveModeContext { #private; session: AgentSession; sessionManager: SessionManager; settings: Settings; keybindings: KeybindingsManager; agent: Agent; historyStorage?: HistoryStorage; ui: TUI; chatContainer: Container; pendingMessagesContainer: Container; statusContainer: Container; todoContainer: Container; btwContainer: Container; editor: CustomEditor; editorContainer: Container; hookWidgetContainerAbove: Container; hookWidgetContainerBelow: Container; statusLine: StatusLineComponent; isInitialized: boolean; isBackgrounded: boolean; isBashMode: boolean; toolOutputExpanded: boolean; todoExpanded: boolean; planModeEnabled: boolean; planModePaused: boolean; goalModeEnabled: boolean; goalModePaused: boolean; planModePlanFilePath: string | undefined; loopModeEnabled: boolean; loopPrompt: string | undefined; loopLimit: LoopLimitRuntime | undefined; todoPhases: TodoPhase[]; hideThinkingBlock: boolean; pendingImages: ImageContent[]; compactionQueuedMessages: CompactionQueuedMessage[]; pendingTools: Map; pendingBashComponents: BashExecutionComponent[]; bashComponent: BashExecutionComponent | undefined; pendingPythonComponents: EvalExecutionComponent[]; pythonComponent: EvalExecutionComponent | undefined; isPythonMode: boolean; streamingComponent: AssistantMessageComponent | undefined; streamingMessage: AssistantMessage | undefined; loadingAnimation: Loader | undefined; autoCompactionLoader: Loader | undefined; retryLoader: Loader | undefined; autoCompactionEscapeHandler?: () => void; retryEscapeHandler?: () => void; unsubscribe?: () => void; onInputCallback?: (input: SubmittedUserInput) => void; optimisticUserMessageSignature: string | undefined; locallySubmittedUserSignatures: Set; lastSigintTime: number; lastEscapeTime: number; shutdownRequested: boolean; hookSelector: HookSelectorComponent | undefined; hookInput: HookInputComponent | undefined; hookEditor: HookEditorComponent | undefined; lastStatusSpacer: Spacer | undefined; lastStatusText: Text | undefined; fileSlashCommands: Set; skillCommands: Map; oauthManualInput: OAuthManualInputManager; readonly lspServers: LspStartupServerInfo[] | undefined; mcpManager?: import("../mcp").MCPManager; constructor(session: AgentSession, version: string, changelogMarkdown?: string | undefined, setToolUIContext?: (uiContext: ExtensionUIContext, hasUI: boolean) => void, lspServers?: LspStartupServerInfo[] | undefined, mcpManager?: import("../mcp").MCPManager, eventBus?: EventBus); init(): Promise; /** Reload slash commands and autocomplete for the provided working directory. */ refreshSlashCommandState(cwd?: string): Promise; getUserInput(): Promise; disableLoopMode(message?: string): void; /** * Pause the loop without exiting it: drops the captured prompt and any * pending auto-resubmit. Loop mode stays enabled — the next prompt the * user submits becomes the new loop prompt and resumes iteration. */ pauseLoop(): void; handleLoopCommand(args?: string): Promise; recordLocalSubmission(text: string, imageCount?: number): () => void; withLocalSubmission(text: string, fn: () => Promise, options?: { imageCount?: number; }): Promise; startPendingSubmission(input: { text: string; images?: ImageContent[]; customType?: string; display?: boolean; }): SubmittedUserInput; cancelPendingSubmission(): boolean; markPendingSubmissionStarted(input: SubmittedUserInput): boolean; finishPendingSubmission(input: SubmittedUserInput): void; updateEditorBorderColor(): void; updateEditorTopBorder(): void; rebuildChatFromMessages(): void; /** Apply any deferred model switch after the current stream ends. */ flushPendingModelSwitch(): Promise; handlePlanModeCommand(initialPrompt?: string): Promise; handleGoalModeCommand(rest?: string): Promise; handlePlanApproval(details: PlanApprovalDetails): Promise; stop(): void; shutdown(): Promise; checkShutdownRequested(): Promise; setToolUIContext(uiContext: ExtensionUIContext, hasUI: boolean): void; initializeHookRunner(uiContext: ExtensionUIContext, hasUI: boolean): void; createBackgroundUiContext(): ExtensionUIContext; setEditorComponent(factory: ((tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) => CustomEditor) | undefined): void; handleBackgroundEvent(event: AgentSessionEvent): Promise; showStatus(message: string, options?: { dim?: boolean; }): void; showError(message: string): void; showWarning(message: string): void; ensureLoadingAnimation(): void; setWorkingMessage(message?: string): void; applyPendingWorkingMessage(): void; showNewVersionNotification(newVersion: string): void; clearEditor(): void; updatePendingMessagesDisplay(): void; queueCompactionMessage(text: string, mode: "steer" | "followUp"): void; flushCompactionQueue(options?: { willRetry?: boolean; }): Promise; flushPendingBashComponents(): void; isKnownSlashCommand(text: string): boolean; addMessageToChat(message: AgentMessage, options?: { populateHistory?: boolean; }): Component[]; renderSessionContext(sessionContext: SessionContext, options?: { updateFooter?: boolean; populateHistory?: boolean; }): void; renderInitialMessages(prebuiltContext?: SessionContext): void; getUserMessageText(message: Message): string; findLastAssistantMessage(): AssistantMessage | undefined; extractAssistantText(message: AssistantMessage): string; handleExportCommand(text: string): Promise; handleDumpCommand(): void; handleDebugTranscriptCommand(): Promise; handleShareCommand(): Promise; handleCopyCommand(sub?: string): void; handleTodoCommand(args: string): Promise; handleSessionCommand(): Promise; handleJobsCommand(): Promise; handleUsageCommand(reports?: UsageReport[] | null): Promise; handleChangelogCommand(showFull?: boolean): Promise; handleHotkeysCommand(): void; handleToolsCommand(): void; handleContextCommand(): void; handleClearCommand(): Promise; handleDropCommand(): Promise; handleForkCommand(): Promise; handleMoveCommand(targetPath: string): Promise; handleRenameCommand(title: string): Promise; handleMemoryCommand(text: string): Promise; handleSTTToggle(): Promise; showDebugSelector(): void; showSessionObserver(): void; resetObserverRegistry(): void; handleBashCommand(command: string, excludeFromContext?: boolean): Promise; handlePythonCommand(code: string, excludeFromContext?: boolean): Promise; handleMCPCommand(text: string): Promise; handleSSHCommand(text: string): Promise; handleCompactCommand(customInstructions?: string): Promise; handleHandoffCommand(customInstructions?: string): Promise; executeCompaction(customInstructionsOrOptions?: string | CompactOptions, isAuto?: boolean): Promise; openInBrowser(urlOrPath: string): void; showSettingsSelector(): void; showHistorySearch(): void; showExtensionsDashboard(): void; showAgentsDashboard(): void; showModelSelector(options?: { temporaryOnly?: boolean; }): void; showPluginSelector(mode?: "install" | "uninstall"): void; showUserMessageSelector(): void; showTreeSelector(): void; showSessionSelector(): void; handleResumeSession(sessionPath: string): Promise; handleSessionDeleteCommand(): Promise; showOAuthSelector(mode: "login" | "logout", providerId?: string): Promise; showHookConfirm(title: string, message: string): Promise; handleCtrlC(): void; handleCtrlD(): void; handleCtrlZ(): void; handleDequeue(): void; handleBackgroundCommand(): void; handleImagePaste(): Promise; handleBtwCommand(question: string): Promise; hasActiveBtw(): boolean; handleBtwEscape(): boolean; cycleThinkingLevel(): void; cycleRoleModel(options?: { temporary?: boolean; }): Promise; toggleToolOutputExpansion(): void; setToolsExpanded(expanded: boolean): void; toggleThinkingBlockVisibility(): void; toggleTodoExpansion(): void; setTodos(todos: TodoItem[] | TodoPhase[]): void; reloadTodos(): Promise; openExternalEditor(): void; registerExtensionShortcuts(): void; initHooksAndCustomTools(): Promise; emitCustomToolSessionEvent(reason: "start" | "switch" | "branch" | "tree" | "shutdown", previousSessionFile?: string): Promise; setHookWidget(key: string, content: ExtensionWidgetContent, options?: ExtensionWidgetOptions): void; setHookStatus(key: string, text: string | undefined): void; showHookSelector(title: string, options: string[], dialogOptions?: ExtensionUIDialogOptions): Promise; hideHookSelector(): void; showHookInput(title: string, placeholder?: string): Promise; hideHookInput(): void; showHookEditor(title: string, prefill?: string, dialogOptions?: ExtensionUIDialogOptions, editorOptions?: { promptStyle?: boolean; }): Promise; hideHookEditor(): void; showHookNotify(message: string, type?: "info" | "warning" | "error"): void; showHookCustom(factory: (tui: TUI, theme: Theme, keybindings: KeybindingsManager, done: (result: T) => void) => (Component & { dispose?(): void; }) | Promise, options?: { overlay?: boolean; }): Promise; showExtensionError(extensionPath: string, error: string): void; showToolError(toolName: string, error: string): void; }