import type { PlatformAdapter } from '../../adapter.js'; import type { MessageRef, MessageContent, MessageContext, MessageEditContext, ActionContext, ModalSubmitContext, ModalDefinition, PlatformCapabilities, PlatformFileRef, DownloadedFile, Destination, PostMessageOpts, FileUploadOpts, ActionElement } from '../../types.js'; import type { OutputStream, OpenOutputStreamOpts } from '../../output-stream.js'; import { TuiConnection } from './tui-connection.js'; import type { TranscriptData, ConduitQueuePort } from './ports.js'; import type { EventBus } from '../../../events/index.js'; interface TuiHandshakeResult { sessionId: string; sessionName: string; projectId: string; isFresh: boolean; emitNotFoundError: boolean; transcript: TranscriptData | null; } interface TuiSwitchResult { sessionId: string; sessionName: string; projectId: string; isFresh: boolean; transcript: TranscriptData | null; } interface TuiSessionServiceHandle { resolveHandshake(opts: { conduitId: string; projectId: string; resumeSessionId?: string | null; }): Promise; switchSession(opts: { conduitId: string; projectId: string; sessionId?: string | null; }): Promise; } export interface TuiAdapterControls { setBus(bus: EventBus): void; setUiService(service: unknown): void; setSessionService(service: TuiSessionServiceHandle): void; setConduitQueue(queue: ConduitQueuePort): void; } export declare class TuiGatewayAdapter implements PlatformAdapter, TuiAdapterControls { readonly name = "tui"; readonly capabilities: PlatformCapabilities; private _wss; private _port; private _host; private _noopOutbound; private _connections; private _bus; private _uiService; private _sessionService; private _conduitQueue; private _busSubscriptions; private _messageHandler; private _editHandler; private _actionHandlers; private _modalHandlers; constructor(opts?: { port?: number; host?: string; }); setBus(bus: EventBus): void; setUiService(service: unknown): void; setSessionService(service: TuiSessionServiceHandle): void; setConduitQueue(queue: ConduitQueuePort): void; /** * Resolve in-memory session/project binding for a TUI conduit. Registered as a * conduit provider by app.ts so session lookups can resolve ephemeral TUI conduits. */ lookupConduit(conduitId: string): { sessionId: string; projectId: string; } | null; start(): Promise; stop(): Promise; onMessage(handler: (ctx: MessageContext) => Promise): void; onMessageEdit(handler: (ctx: MessageEditContext) => Promise): void; onAction(actionId: string, handler: (ctx: ActionContext) => Promise): void; onModalSubmit(callbackId: string, handler: (ctx: ModalSubmitContext) => Promise): void; postMessage(destination: Destination, content: MessageContent, opts?: PostMessageOpts): Promise; updateMessage(ref: MessageRef, content: MessageContent): Promise; deleteMessage(ref: MessageRef): Promise; postInteractive(destination: Destination, content: MessageContent & { actions: ActionElement[]; }, opts?: PostMessageOpts): Promise; openModal(triggerId: string, modal: ModalDefinition): Promise; markQueued(ref: MessageRef): Promise; uploadFile(destination: Destination, filePath: string, _opts?: FileUploadOpts): Promise; downloadFile(fileRef: PlatformFileRef, destDir: string): Promise; getPermalink(ref: MessageRef): Promise; openOutputStream(destination: Destination, opts?: OpenOutputStreamOpts): OutputStream; private _createNoopOutputStream; bindProjectConduit(projectId: string, conduitHint: string): Promise; unbindProjectConduit(projectId: string): Promise; getProjectConduits(): Promise>; resolveInboundProject(conduit: string): Promise; /** TUI conduits are `tui-` and triggerIds are `tui::`. */ ownsConduit(conduit: string): boolean; /** Expose connections for testing and notification routing. */ get connections(): Map; /** Expose noop flag for testing. */ get noopOutbound(): boolean; private _handleConnection; private _dispatchInboundFrame; private _handleHandshake; private _handleSessionSwitch; private _handleMsgUser; private _handleMsgEdit; private _handleActionClick; private _handleModalSubmit; private _handleUiQuery; private _handleUiMutate; private _handleUiSubscribe; private _forwardSubscriptionEvents; private _handleUiUnsubscribe; private _resolveTargetConnections; private _findConnectionBySessionId; private _resolveConnectionByTriggerId; private _cleanupConnection; } export {};