/**
 * Chat gateway (T-CHAT-AS-TERMINAL CAT.1b) — thin outbound-dispatch +
 * lifecycle wrapper over the transport adapter map from `./factory.ts`.
 *
 * The legacy `src.legacy/chat/gateway.ts` carried a full inbound-dispatch fan
 * (`onMessage`) + a per-platform `ChatAdapter` abstraction. The new tree splits
 * those out: inbound is owned by the adapter's `subscribeTransport` →
 * `transport_inbox.routeAndWriteInbound` path (wired in the worker), so the
 * gateway's only jobs are (1) outbound `send` dispatch and (2) start/stop
 * fan-out. No inbound handler list lives here.
 *
 * The outbound `channel` string contract is LOAD-BEARING — it is the wire
 * format `src/mcp/chat-bridge-server.ts` + `src/runtime/agent_bridge/tools/
 * chat_send.ts` send over the daemon socket. `send()` parses it to an adapter
 * URI:
 *
 *   - `telegram:<chat_id>`                → telegram://<chat_id>
 *   - `telegram:<chat_id>:<thread_id>`    → telegram://<chat_id>/<thread_id>
 *   - explicit `threadId` arg overrides any thread suffix embedded in channel.
 *
 * Imports from: ./types. Imported by: ./daemon/{rpc_server,worker}.ts + tests.
 */
import type { ChannelAdapter } from './types.js';
import type { ChatPlatform } from './factory.js';
/** Telegram forum-topic creation seam (telegram-only `create_topic` RPC). */
export type CreateTopicFn = (args: {
    chatId: string;
    name: string;
    iconColor?: number;
    iconCustomEmojiId?: string;
}) => Promise<{
    message_thread_id: number;
    name: string;
}>;
export interface GatewayOpts {
    adapters: Map<ChatPlatform, ChannelAdapter>;
    /**
     * Optional telegram `createTopic` implementation (wired by the worker from
     * the telegram token). Absent ⇒ `create_topic` RPC fails cleanly.
     */
    createTopic?: CreateTopicFn;
}
export interface GatewaySendParams {
    /** `<platform>:<native_id>` or composite `telegram:<chat_id>:<thread_id>`. */
    channel: string;
    text: string;
    /** Echoed back by callers; the new telegram adapter has no reply-thread arg. */
    replyTo?: string;
    /** Explicit thread/topic id; overrides any suffix embedded in `channel`. */
    threadId?: string;
    /**
     * CAT.4 — ADDITIVE. Absolute path to a local image; when present the gateway
     * dispatches via the adapter's `sendPhoto` (text → caption) instead of the
     * text `send`. Telegram only; other platforms throw (no `sendPhoto` surface).
     */
    mediaPath?: string;
}
export interface GatewaySendResult {
    ok: true;
    platform: string;
    /** Native delivered-message id from the transport (telegram echoes
     *  `message_id`); empty string only when the transport reported none. */
    messageId: string;
    deliveredAt: Date;
}
export declare class GatewayError extends Error {
    constructor(message: string);
}
/** Parsed `channel` → (platform, adapter URI). */
interface ParsedChannel {
    platform: ChatPlatform;
    uri: string;
}
/**
 * Parse the wire `channel` (+ optional explicit `threadId`) into a platform +
 * adapter URI. Telegram supports a `chat:thread` composite; an explicit
 * `threadId` arg takes precedence over the embedded suffix.
 */
export declare function parseChannel(channel: string, threadId?: string): ParsedChannel;
export declare class ChatGateway {
    private readonly adapters;
    private readonly createTopicFn?;
    private started;
    constructor(opts: GatewayOpts);
    /** Start every adapter's long-poll loop (telegram is the only one wired). */
    start(): Promise<void>;
    /** Stop every adapter. Best-effort — errors are swallowed. */
    stop(): Promise<void>;
    /** Platforms currently activated (→ `list_channels` RPC). */
    activePlatforms(): ChatPlatform[];
    /** The active adapter for a platform, or undefined. */
    getAdapter(platform: ChatPlatform): ChannelAdapter | undefined;
    /** Dispatch an outbound message. Throws `GatewayError` on bad channel /
     *  missing adapter / adapter-reported send failure. */
    send(params: GatewaySendParams): Promise<GatewaySendResult>;
    /** Telegram `create_topic`. Throws when no createTopic seam is wired. */
    createTopic(args: {
        platform: 'telegram';
        chatId: string;
        name: string;
        iconColor?: number;
        iconCustomEmojiId?: string;
    }): Promise<{
        message_thread_id: number;
        name: string;
    }>;
}
export {};
//# sourceMappingURL=gateway.d.ts.map