import type { Message, PartialBy } from "../types.js"; /** * Statistics about the messages in the history. */ export interface HistoryStats { /** The number of messages in the history for the actor. */ count: number; /** The total number of characters in the messages. */ textCount: number; /** The percentage of messages that are from the actor. */ percentage: number; /** The percentage of characters in the messages that are from the actor. */ textPercentage: number; } /** * A conversation history. The history is shared between all actors in the * conversation, and is used to store information about the conversation. */ export declare class ConversationHistory { /** The messages in the history. */ readonly messages: Message[]; /** * Create a new conversation history. * @param messages The messages in the history. * @returns A new conversation history. */ constructor(messages?: Message[]); /** * Add a new message to the history. The message is shared between all actors * in the conversation, and is used to store information about the * conversation. * @param message The message to add. */ push(message: PartialBy): void; /** * Get the messages sent by an actor. The messages are shared between all * actors in the conversation, and are used to store information about the * conversation. * @param actor The name of the actor. * @returns The messages sent by the actor. */ getMessagesFor(actor: string): ReadonlyMap; /** * Get statistics about the messages in the history. * @returns Statistics about the messages in the history. */ getStats(): Record; /** * Remove ephemeral messages from the history. Ephemeral messages are * messages that are not part of the conversation, and are only added * for a single turn. */ cleanEphemeral(): void; /** * Add positive feedback to a message. * @param message The message to add feedback to. */ up(message: Message): void; /** * Add negative feedback to a message. * @param message The message to add feedback to. */ down(message: Message): void; /** * Get the first message in the history. */ first(): Message | undefined; /** * Get the last message in the history. */ last(): Message | undefined; /** * Transform the history into a JSON-serializable object. */ toJSON(): { messages: Message[]; }; /** * Clear the history. */ clear(): void; }