feat: add terminal input hook for extensions

This commit is contained in:
Sam Fold 2026-02-05 17:12:26 +00:00 committed by Mario Zechner
parent 6da488a5aa
commit 30fd99bd82
7 changed files with 47 additions and 0 deletions

View file

@ -123,6 +123,7 @@ export type {
SetLabelHandler,
SetModelHandler,
SetThinkingLevelHandler,
TerminalInputHandler,
// Events - Tool
ToolCallEvent,
ToolCallEventResult,

View file

@ -170,6 +170,7 @@ const noOpUIContext: ExtensionUIContext = {
confirm: async () => false,
input: async () => undefined,
notify: () => {},
onTerminalInput: () => () => {},
setStatus: () => {},
setWorkingMessage: () => {},
setWidget: () => {},

View file

@ -97,6 +97,9 @@ export interface ExtensionWidgetOptions {
placement?: WidgetPlacement;
}
/** Raw terminal input listener for extensions. */
export type TerminalInputHandler = (data: string) => { consume?: boolean; data?: string } | undefined;
/**
* UI context for extensions to request interactive UI.
* Each mode (interactive, RPC, print) provides its own implementation.
@ -114,6 +117,9 @@ export interface ExtensionUIContext {
/** Show a notification to the user. */
notify(message: string, type?: "info" | "warning" | "error"): void;
/** Listen to raw terminal input (interactive mode only). Returns an unsubscribe function. */
onTerminalInput(handler: TerminalInputHandler): () => void;
/** Set status text in the footer/status bar. Pass undefined to clear. */
setStatus(key: string, text: string | undefined): void;