/** * Web channel adapter for dsh-connect: mirrors Feishu conversations to DSH Web GUI. * This adapter monitors BindingStore for webMirrorSessionId changes and exposes * those sessions to the Web GUI through the standard ChannelAdapter interface. * @module dsh-connect/channels/web/adapter */ import type { ChannelAdapter, ChoicePrompt, ChoiceResult, InboundMessage, OutboundTarget, SummaryCard } from "../../types.js"; import type { BindingStore } from "../../binding.js"; /** * WebAdapter provides a bridge between dsh-connect's mirror sessions and the * DSH Web GUI. It monitors the BindingStore for chats that have been mirrored * (have webMirrorSessionId set) so the GUI can open the shared session. * * Honest limitations (documented in README): * - The Web GUI reads mirrored sessions directly from DSH's session store; it * never sends inbound messages through this adapter. The mirror "lock" * (lockOwner) is therefore enforced only on the Feishu side — the Web side * is write-always and cannot be fixed from this repository. * - Outbound methods (sendText / sendCard / streamText / promptChoice / * closeMenu) are no-ops by design: the agent writes events into the shared * session store, and the GUI renders them. They exist only to satisfy the * ChannelAdapter contract. */ export declare class WebAdapter implements ChannelAdapter { private readonly logger?; readonly id = "web"; /** No inbound face of its own: a prompt here could never be answered. */ readonly supportsChoices = false; private handler?; private readonly bindings; private readonly pollIntervalMs; private pollTimer?; private unsubscribe?; private readonly knownMirrors; /** * Create a WebAdapter instance. * @param bindings - The BindingStore to monitor for mirror sessions * @param options - Optional configuration */ constructor(bindings: BindingStore, options?: { pollIntervalMs?: number; }, logger?: { warn?: (...args: unknown[]) => void; } | undefined); onInbound(handler: (msg: InboundMessage) => void | Promise): void; /** * Start monitoring for mirror sessions. * Uses event-driven detection with fallback polling. */ start(): Promise; /** * Stop monitoring and clean up resources. */ stop(): Promise; /** * Record a newly-detected mirror session. Mirror tracking is purely * bookkeeping: the mirror is visible in DSH Web through the session store * itself, and synthesizing an inbound "mirror created" message here would * spin up a spurious web runner and burn a real agent turn — so we do NOT * route anything through the handler. */ private recordMirror; /** * Scan BindingStore for chats with webMirrorSessionId set and record any * new mirrors. */ private scanForMirrors; /** * Check if a session is mirrored and available for Web access. * @param sessionId - The session ID to check */ isSessionMirrored(sessionId: string): boolean; /** * Get the source chat key for a mirrored session. * @param sessionId - The session ID * @returns The original channel:chatKey or undefined if not mirrored */ getMirrorSource(sessionId: string): string | undefined; /** * Send text message to Web GUI. * No-op: the Web GUI pulls content from DSH session events, not from adapter * calls. Kept only to satisfy the ChannelAdapter contract. */ sendText(_target: OutboundTarget, _text: string): Promise; /** * Send summary card to Web GUI. No-op — see {@link sendText}. */ sendCard(_target: OutboundTarget, _card: SummaryCard): Promise; /** * Stream text chunks to Web GUI. * The agent already writes chunks into the session; consume the iterable so * the producer never stalls on backpressure. */ streamText(_target: OutboundTarget, chunks: AsyncIterable): Promise; /** * Present interactive choice prompt. * No-op: the Web GUI renders choices through its own interaction system. */ promptChoice(_target: OutboundTarget, _prompt: ChoicePrompt, updateMessageId?: string, _signal?: AbortSignal): Promise; /** * Close a menu/card in Web GUI. No-op — see {@link sendText}. */ closeMenu(_messageId: string, _summary: string): Promise; } //# sourceMappingURL=adapter.d.ts.map