import { BaseListChatMessageHistory } from "@langchain/core/chat_history"; import { type BaseMessage } from "@langchain/core/messages"; import type { FlairClient } from "@tpsdev-ai/flair-client"; /** * LangChain `BaseListChatMessageHistory` adapter backed by Flair memory. * * Each chat message is stored as a single Flair memory: * - content: JSON.stringify(StoredMessage) * - subject: the composed chat-session subject * - tags: ["n8n-chat", `role:`] * - type: "session" * - durability: "ephemeral" * * `getMessages()` reads memories filtered by subject and reconstructs the * BaseMessage[] in createdAt-ascending order. Order is computed client-side * from the createdAt timestamp because Memory.list does not yet expose a * server-side sort param (tracked as the `order` extension in q3qf ยง6). * * The `windowK` constructor argument bounds the number of memories fetched * per `getMessages()` call: each turn is two messages (user + AI), so we * fetch up to `windowK * 2` to cover a windowing wrapper that keeps the * last K turns. */ export declare class FlairChatMessageHistory extends BaseListChatMessageHistory { private readonly client; private readonly subject; private readonly windowK; lc_namespace: string[]; constructor(client: FlairClient, subject: string, windowK?: number); getMessages(): Promise; addMessage(message: BaseMessage): Promise; addMessages(messages: BaseMessage[]): Promise; clear(): Promise; }