import type { UsageStore } from "@pie-lab/storage";
import { type Message } from "discord.js";
import type { ChatAccountConfig, ChatConfig, ConfiguredChannel, DiscordAccountConfig, ResolvedConversation } from "./chat/core/config-types.ts";
import type { InboundMessageInput } from "./chat/core/runtime-types.ts";
import { type GatewayPlatformRegistry } from "./platform-registry.ts";
export interface GatewayCheckpoint {
    cursor?: string;
    messageId?: string;
}
export interface GatewayTransport {
    sendImmediate(text: string, replyToMessageId?: string): Promise<string>;
    send(text: string, attachmentPaths?: string[], signal?: AbortSignal, replyToMessageId?: string): Promise<string>;
    startTyping(): Promise<void>;
    stopTyping(): Promise<void>;
    /** True when the transport handles streaming deltas via sendImmediate and send() is used only for finalization (e.g. WebIPC). False for transports where send() posts a new message (Telegram, Discord). */
    readonly supportsStreaming?: boolean;
}
export interface GatewayConversationEndpoint {
    conversation: ResolvedConversation;
    setTransport(transport: GatewayTransport): void;
    getLastCheckpoint(): GatewayCheckpoint;
    onMessage(input: InboundMessageInput, checkpoint?: GatewayCheckpoint): Promise<void>;
    onCaughtUp(): Promise<void>;
    onError(error: Error): Promise<void>;
    onDisconnect?(): Promise<void>;
    /** Abort the currently in-flight LLM turn, if any. No-op when idle. */
    abortActive?(): void;
}
export interface GatewayAccountAdapterContext {
    usageStore?: UsageStore;
    getOrCreateEndpoint(accountId: string, account: ChatAccountConfig, channelKey: string, channel: ConfiguredChannel): Promise<GatewayConversationEndpoint>;
}
export interface GatewayAdapter {
    accountId: string;
    service: ChatAccountConfig["service"];
    disconnect(): Promise<void>;
    getHealth?(): GatewayAdapterHealth;
}
export interface GatewayAdapterHealth {
    accountId: string;
    service: ChatAccountConfig["service"];
    connected: boolean;
    startedAt: string;
    lastActivityAt?: string;
    errorCount: number;
    lastError?: string;
}
export declare function discordMessageMentionsBot(account: DiscordAccountConfig, message: Message): boolean;
export declare function registerBuiltInGatewayPlatforms(registry?: GatewayPlatformRegistry): GatewayPlatformRegistry;
export declare function startGatewayChatAdapters(config: ChatConfig, endpoints: GatewayConversationEndpoint[], context: GatewayAccountAdapterContext, registry?: GatewayPlatformRegistry): Promise<GatewayAdapter[]>;
//# sourceMappingURL=adapters.d.ts.map