export type PtyProcessEntry = { tty: boolean; output: string; /** True only after the provider can no longer append output. */ outputClosed: boolean; exitCode: number | null; lastUsed: number; waiters: Set<() => void>; sendInput?: (chars: string) => Promise; terminate?: () => Promise; /** Carries partial UTF-8 sequences across chunk boundaries. */ decoder?: PtyTextDecoder; }; type PtyTextDecoder = { decode(input?: Uint8Array | ArrayBuffer, options?: { stream?: boolean; }): string; }; export type PtyWebSocket = { readyState?: number; binaryType?: string; send(data: string | Uint8Array | ArrayBuffer): void; close(): void; addEventListener?: (type: string, listener: (event: unknown) => void) => void; removeEventListener?: (type: string, listener: (event: unknown) => void) => void; on?: (type: string, listener: (...args: unknown[]) => void) => void; off?: (type: string, listener: (...args: unknown[]) => void) => void; removeListener?: (type: string, listener: (...args: unknown[]) => void) => void; }; export declare function createPtyProcessEntry(args: { tty?: boolean; sendInput?: (chars: string) => Promise; terminate?: () => Promise; }): PtyProcessEntry; export declare function appendPtyOutput(entry: PtyProcessEntry, chunk: string | Uint8Array | ArrayBuffer): void; export declare function closePtyOutput(entry: PtyProcessEntry, exitCode?: number | null): void; /** Observe a provider wait that settles after its output callbacks finish. */ export declare function watchPtyOutput(entry: PtyProcessEntry, waitForOutputClosed: () => Promise, exitCode: (result: unknown, error?: unknown) => number | null | undefined): void; export declare function openPtyWebSocket(args: { url: string; providerName: string; headers?: Record; headersUnsupportedUrl?: string; timeoutMs?: number; configure?: (socket: PtyWebSocket) => void | Promise; }): Promise; export declare function closePtyWebSocket(socket: PtyWebSocket): Promise; export declare function addPtyWebSocketListener(socket: PtyWebSocket, type: string, listener: (event: unknown) => void): () => void; export declare class PtyProcessRegistry { private readonly processes; register(entry: PtyProcessEntry): { sessionId: number; pruned?: PtyProcessEntry; }; get(sessionId: number): PtyProcessEntry | undefined; terminateAll(): Promise; finalize(sessionId: number, outputClosed: boolean): Promise<{ processId?: number; exitCode?: number | null; }>; private pruneIfNeeded; } export declare function collectPtyOutput(args: { entry: PtyProcessEntry; yieldTimeMs: number; maxOutputTokens?: number; }): Promise<{ text: string; originalTokenCount?: number; outputClosed: boolean; }>; export declare function writePtyStdin(args: { providerName: string; registry: PtyProcessRegistry; sessionId: number; chars?: string; yieldTimeMs?: number; maxOutputTokens?: number; }): Promise; export declare function formatPtyExecUpdate(args: { registry: PtyProcessRegistry; sessionId: number; entry: PtyProcessEntry; startTime: number; yieldTimeMs?: number; maxOutputTokens?: number; }): Promise; export declare function shellCommandForPty(args: { cmd: string; shell?: string; login?: boolean; }): string; export {};