import type { Channel } from "../types.js"; export interface BaseMessage { id?: string; role: "user" | "assistant" | "system" | "tool"; content: string; name?: string; tool_call_id?: string; tool_calls?: Array<{ id: string; name: string; args: Record; }>; /** Arbitrary metadata */ metadata?: Record; } export type Message = BaseMessage & { id: string; }; export declare class RemoveMessage { readonly id: string; readonly __type: "RemoveMessage"; constructor(id: string); } export declare class UpdateMessage { readonly id: string; readonly patch: Partial; readonly __type: "UpdateMessage"; constructor(id: string, patch: Partial); } export type MessageUpdate = BaseMessage | RemoveMessage | UpdateMessage; /** * Smart reducer for message arrays. * - Appending new messages: deduplicates by ID * - RemoveMessage: removes message with matching ID * - UpdateMessage: patches message with matching ID */ export declare function messagesReducer(current: Message[], update: MessageUpdate | MessageUpdate[]): Message[]; /** * A channel that uses the smart addMessages reducer. * * @example * const graph = new StateGraph({ * channels: { * messages: messagesChannel(), * } * }); */ export declare function messagesChannel(): Channel; export type MessagesState = { messages: Message[]; }; export declare const messagesStateChannels: { messages: Channel; }; export declare function humanMessage(content: string, id?: string): Message; export declare function aiMessage(content: string, opts?: { id?: string; tool_calls?: Message["tool_calls"]; }): Message; export declare function systemMessage(content: string, id?: string): Message; export declare function toolMessage(content: string, tool_call_id: string, id?: string): Message; export declare function getMessageById(messages: Message[], id: string): Message | undefined; export declare function filterByRole(messages: Message[], role: Message["role"]): Message[]; /** Trim message history to last N messages (keeps system message at index 0) */ export declare function trimMessages(messages: Message[], maxMessages: number): Message[]; //# sourceMappingURL=index.d.ts.map