import type { AbstractAgent } from "@ag-ui/client"; import type { ThreadMessage } from "@copilotkit/channels-ui"; import type { ConversationStore, AgentSession } from "@copilotkit/channels-core"; import type { ReplyTarget } from "./types.js"; import type { AgentContentPart } from "./download-files.js"; /** * Telegram conversation store with stable threadIds. * * Unlike Slack (which rebuilds history from the platform API and mints a fresh * threadId per turn), Telegram's Bot API cannot read chat history. This store * therefore: * - assigns each conversation a **stable** threadId (`tg-thread-`) so the * agent's own persistence layer can accumulate state across turns; and * - maintains an in-memory message log (lost on restart, capped at 200 entries) * that callers can use for lightweight within-session context. */ export declare class TelegramConversationStore implements ConversationStore { readonly seedsInboundTurn = true; private readonly sessions; private readonly history; /** * Per-conversation queue of user messages awaiting delivery to the agent. * * The listener enqueues each turn's user message (text, or text + file * parts) BEFORE invoking the bot handler that calls `runAgent` → * {@link getOrCreate}, which drains the queue into the cached agent. This is * how Telegram delivers the user's turn to the agent: unlike Slack, the Bot * API cannot read chat history, so `Thread.run()` (which only injects a * message when `extra.prompt` is set) would otherwise never see the input. */ private readonly pending; private threadIdFor; /** * Enqueue a user message to be delivered to the agent on the next * {@link getOrCreate} for `conversationKey`. Content is either a plain text * string or an array of AG-UI content parts (text + media). */ enqueueUserMessage(conversationKey: string, content: string | AgentContentPart[]): void; /** * Return the cached AgentSession for `conversationKey`, or create one. * * On first call for a key `makeAgent` is invoked exactly once with the * stable threadId; subsequent calls return the same cached session without * invoking `makeAgent` again. */ getOrCreate(conversationKey: string, _replyTarget: ReplyTarget, makeAgent: (threadId: string) => AbstractAgent): Promise; /** * Append `msg` to the in-memory history for `conversationKey`. * Drops the oldest entry when the list exceeds {@link MAX_HISTORY}. */ recordMessage(conversationKey: string, msg: ThreadMessage): void; /** Return the recorded message history for `conversationKey` (or `[]`). */ getMessages(conversationKey: string): ThreadMessage[]; /** Whether a session exists for `conversationKey`. */ has(conversationKey: string): boolean; } //# sourceMappingURL=conversation-store.d.ts.map