/** * Keyboard enhancement protocol (Codex `keyboard_modes` parity) and the * kitty CSI-u normalization layer. * * The TUI pushes the kitty keyboard protocol with DISAMBIGUATE_ESCAPE_CODES * and REPORT_ALTERNATE_KEYS (flags 1|4 = `\x1b[>5u`). Event types are * deliberately NOT requested: Ink 5's parser cannot decode the * `:event-type` suffix, and repeat/release reporting buys this surface * nothing. * * Ink 5 also cannot parse most CSI-u forms at all — they fall through its * regex as unnamed sequences and get INSERTED AS DRAFT TEXT. The composer's * stdin read patch therefore rewrites every CSI-u form it can decode back * to the legacy byte or canonical sequence the existing key handling * already understands, before Ink ever parses the chunk. * @module @deepseek-ai/dsh-code/keyboard */ /** Push keyboard enhancement (modifyOtherKeys off, kitty flags 1|4). */ export declare const KEYBOARD_ENHANCE_ENABLE = "\u001B[>4;0m\u001B[>5u"; /** Pop the enhancement stack and reset modifyOtherKeys (exit path). */ export declare const KEYBOARD_ENHANCE_DISABLE = "\u001B[4;0m"; /** Explicit environment overrides for terminal keyboard enhancement. */ export declare const DSH_DISABLE_KEYBOARD_ENHANCEMENT = "DSH_DISABLE_KEYBOARD_ENHANCEMENT"; export declare const DSH_ENABLE_KEYBOARD_ENHANCEMENT = "DSH_ENABLE_KEYBOARD_ENHANCEMENT"; /** True when the process is running inside the VS Code integrated terminal. */ export declare function isVsCodeTerminalEnv(env?: NodeJS.ProcessEnv): boolean; /** Whether to push Kitty keyboard enhancement for the current terminal. */ export declare function shouldEnableKeyboardEnhancement(env?: NodeJS.ProcessEnv): boolean; /** Enable bracketed paste reporting. */ export declare const BRACKETED_PASTE_ENABLE = "\u001B[?2004h"; /** Disable bracketed paste reporting. */ export declare const BRACKETED_PASTE_DISABLE = "\u001B[?2004l"; /** Enable terminal focus-in/focus-out reporting (xterm focus protocol). */ export declare const TERMINAL_FOCUS_REPORT_ENABLE = "\u001B[?1004h"; /** Disable terminal focus-in/focus-out reporting. */ export declare const TERMINAL_FOCUS_REPORT_DISABLE = "\u001B[?1004l"; /** * Remove xterm focus reports from one input chunk and update the caller's * focus state. Focus reports are terminal protocol, not composer text. */ export declare function stripTerminalFocusEvents(chunk: string, onFocus: (focused: boolean) => void): string; /** Bracketed paste markers as Ink delivers them (it strips the leading ESC). */ export declare const PASTE_START_MARKER = "[200~"; export declare const PASTE_END_MARKER = "[201~"; /** * How long an unterminated bracketed-paste block may hold buffered bytes * before the input splitter strips its start marker and releases them: a * terminal that loses the end marker must never take the whole keyboard * hostage (Esc/Ctrl+C included). Shared by the splitter and the composer's * lost-paste safety net so both use one window. */ export declare const PASTE_BRACKET_TIMEOUT_MS = 1000; /** * Remove bracketed paste markers from one input chunk. Panel drafts accept raw * `input` text, where an unhandled paste would otherwise persist the literal * "[200~"/"[201~" markers Ink leaves after stripping the ESC byte. */ export declare function stripPasteMarkers(text: string): string; /** * Rewrite every decodable kitty CSI-u sequence in one stdin chunk to the * legacy form the input layer already handles. Undecodable or non-key * sequences pass through untouched, so terminals without the protocol are * unaffected. */ export declare function normalizeKeyboardChunk(chunk: string): string; /** Editor actions Ink cannot distinguish reliably when terminal bytes batch. */ export type RawEditorToken = { readonly kind: 'text'; readonly text: string; } | { readonly kind: 'home' | 'end' | 'delete-backward' | 'delete-word-backward' | 'delete-forward' | 'delete-word-forward'; }; /** * Tokenize a stdin chunk containing at least one editor-only key. Ink calls * `useInput` once for a pasted/batched chunk, so preserving each action here * prevents repeated Backspace/Home/End/Delete presses from collapsing into * one blurred key event. Unknown escape sequences return undefined and stay * under Ink's ownership. */ export declare function tokenizeRawEditorChunk(chunk: string): readonly RawEditorToken[] | undefined;