import { type NativeModule } from "./native-lib.cjs"; export type { NativeModule }; export interface TerminalSpan { text: string; fg: string | null; bg: string | null; flags: number; width: number; } export interface TerminalLine { spans: TerminalSpan[]; } export interface TerminalData { cols: number; rows: number; cursor: [number, number]; cursorVisible: boolean; cursorStyle: "default" | "block" | "bar" | "underline" | "block_hollow"; offset: number; totalLines: number; lines: TerminalLine[]; } export interface PtyToJsonOptions { cols?: number; rows?: number; offset?: number; limit?: number; } export declare function ptyToJson(input: Buffer | Uint8Array | string, options?: PtyToJsonOptions): TerminalData; export interface PtyToTextOptions { cols?: number; rows?: number; } /** * Strips ANSI escape codes from input and returns plain text. * Uses the terminal emulator to properly process escape sequences, * then outputs only the visible text content. * * Useful for cleaning terminal output before sending to LLMs or other text processors. */ export declare function ptyToText(input: Buffer | Uint8Array | string, options?: PtyToTextOptions): string; export interface PtyToHtmlOptions { cols?: number; rows?: number; } /** * Converts terminal output with ANSI escape codes to styled HTML. * Uses the terminal emulator to properly process escape sequences, * then outputs HTML with inline styles for colors and text attributes. * * Useful for rendering terminal output in web pages or HTML documents. */ export declare function ptyToHtml(input: Buffer | Uint8Array | string, options?: PtyToHtmlOptions): string; export declare const StyleFlags: { readonly BOLD: 1; readonly ITALIC: 2; readonly UNDERLINE: 4; readonly STRIKETHROUGH: 8; readonly INVERSE: 16; readonly FAINT: 32; }; /** * Check if native persistent terminal API is available */ export declare function hasPersistentTerminalSupport(): boolean; export interface PersistentTerminalOptions { cols?: number; rows?: number; } /** * A persistent terminal instance that maintains state across multiple feed operations. * Much more efficient than ptyToJson for streaming use cases. */ export declare class PersistentTerminal { private readonly _id; private _cols; private _rows; private _destroyed; private _streamDecoder; constructor(options?: PersistentTerminalOptions); /** The unique identifier for this terminal */ get id(): number; /** Current number of columns */ get cols(): number; /** Current number of rows */ get rows(): number; /** Whether this terminal has been destroyed */ get destroyed(): boolean; /** * Feed data to the terminal. Can be called multiple times for streaming. * The terminal maintains state (cursor position, colors, etc.) between calls. */ feed(data: Buffer | Uint8Array | string): void; /** * Resize the terminal. Existing content will be reflowed if possible. */ resize(cols: number, rows: number): void; /** * Reset the terminal to its initial state. * Clears all content and resets cursor to origin. */ reset(): void; /** * Get the current terminal content as TerminalData. */ getJson(options?: { offset?: number; limit?: number; }): TerminalData; /** * Get the current terminal content as plain text. */ getText(): string; /** * Get the current cursor position as [x, y]. */ getCursor(): [number, number]; /** * Check if the terminal is ready for reading. * Returns true if the parser is in ground state, meaning all escape * sequences have been fully processed. * * Use this after feed() to ensure you're not reading partial state. */ isReady(): boolean; /** * Destroy the terminal and free resources. * The terminal cannot be used after this call. */ destroy(): void; private assertNotDestroyed; } //# sourceMappingURL=ffi.d.ts.map