/** * IPCPTYTransport - IPTYTransport implementation for IPC connections * * Wraps an IPC connection to provide the IPTYTransport interface. * Used to manage proxy sessions from CLI connections. * * NOTE: Unlike the original, this does NOT depend on Electron. * The IMessageBus interface is abstracted - consumers provide their * own implementation for their IPC mechanism. */ import { EventEmitter } from 'events'; import type { IPTYTransport, TransportType } from '#types'; /** * Minimal message bus interface for sending messages to a connection. * Consumers implement this for their IPC mechanism. */ export interface IMessageBus { publish(connectionId: string, namespace: string, type: string, payload: unknown): void; } export interface IPCPTYTransportMetadata { version?: string; pid?: number; } export interface IPCPTYTransportOptions { /** * Rewrite output for line-mode CLI echo (strip focus-tracking sequences, * normalize newlines). Leave enabled for `avo`-style CLI sessions; disable * for byte-exact mirroring of full-screen TUIs, where any rewrite corrupts * cursor-addressed screens. Default: true (existing behavior). */ normalizeOutput?: boolean; } /** Hub → owner: ask the session host to spawn a session (`spawn:request`). */ export interface SpawnRequestPayload { requestId: string; command: string; args?: string[]; cwd?: string; /** Explicit env grants passed to the owner's spawn handler — never a full parent env. */ env?: Record; cols?: number; rows?: number; name?: string; } /** Owner → hub acknowledgment (`spawn:response`). The session itself arrives via `session:announce`. */ export interface SpawnResponsePayload { requestId: string; ok: boolean; sessionId?: string; error?: string; } export declare class IPCPTYTransport extends EventEmitter implements IPTYTransport { private _connectionId; private _messageBus; private _isConnected; private _metadata?; private _normalizeOutput; private _pendingSpawns; constructor(connectionId: string, messageBus: IMessageBus, metadata?: IPCPTYTransportMetadata, options?: IPCPTYTransportOptions); get transportId(): string; get transportType(): TransportType; get isReady(): boolean; get remoteVersion(): string | undefined; get remotePid(): number | undefined; disconnect(reason?: string): void; dispose(): void; /** * Handle incoming PTY session message from CLI */ handleMessage(type: string, payload: unknown): void; private handleSessionAnnounce; private handleOutput; private handleSpawnResponse; private normalizeOutput; private handleSessionEnd; private handleResize; private handleFocus; sendInput(sessionId: string, data: string | Buffer): void; sendResize(sessionId: string, cols: number, rows: number): void; sendKill(sessionId: string, signal?: string): void; sendFocus(sessionId: string, focused: boolean): void; /** * Ask the connected session host to spawn a session. Resolves with the * remote (un-namespaced) session id once the host acknowledges; the session * itself arrives through the usual `session:announce` flow, which the host * sends before the acknowledgment. */ requestSpawn(config: Omit, timeoutMs?: number): Promise<{ sessionId: string; }>; private rejectPendingSpawns; sendOutput(_sessionId: string, _data: Buffer, _targetDeviceId: string): void; sendResized(_sessionId: string, _cols: number, _rows: number, _targetDeviceId: string): void; sendSessionEnded(_sessionId: string, _exitCode: number, _targetDeviceId: string): void; sendFocusChanged(_sessionId: string, _focused: boolean, _targetDeviceId: string): void; /** Called when the underlying IPC connection is lost */ handleDisconnected(reason: string): void; } export declare function createIPCPTYTransport(connectionId: string, messageBus: IMessageBus, metadata?: IPCPTYTransportMetadata, options?: IPCPTYTransportOptions): IPCPTYTransport; //# sourceMappingURL=ipc-transport.d.ts.map