import { BaseMessage } from "@langchain/core/messages"; import { BaseCheckpointSaver } from "@langchain/langgraph"; import type { ToolScopeType } from "../shared/agent/tool.scope.js"; import type { ChatStreamEvent } from "./chat-streaming.types.js"; /** * Top-level streaming service for Chat Graph events. * * Uses `graph.stream()` with `streamMode: ["custom", "updates"]` so that * the agent's `config.writer()` calls arrive as `"custom"` chunks (text * tokens and tool-activity events) and the final state update arrives as * an `"updates"` chunk. */ export declare class ChatStreamer { private loadSessionContext; private createStreamingGraph; constructor(loadSessionContext: (sessionId: string, maxMessages: number) => Promise, createStreamingGraph: (checkpointer?: BaseCheckpointSaver) => any); /** * Streams chat events with full session context. * Loads previous conversation history and optionally uses a checkpointer * for state persistence. * * @param input - Configuration for context-aware streaming * @param checkpointer - Optional checkpointer for state persistence * @yields ChatStreamEvent objects */ streamChatEventsWithContext(input: { userId: string; message: string; sessionId: string; maxContextMessages?: number; /** @deprecated Use scopeType/scopeId. Kept for REST/session edge compatibility. */ networkId?: string; scopeType?: ToolScopeType; scopeId?: string; prefillMessages?: Array<{ role: "assistant" | "user"; content: string; }>; /** Per-run identifier used to form a composite LangGraph thread_id (sessionId:runId). * When provided, prevents stale checkpoint state from a prior run being resumed. * Defaults to sessionId alone when absent (backward compatible). */ runId?: string; }, checkpointer?: BaseCheckpointSaver, signal?: AbortSignal): AsyncGenerator; /** * Streams chat events from the graph execution. * * Uses `graph.stream()` with `streamMode: ["custom", "updates"]`: * - `"custom"` chunks carry {@link AgentStreamEvent} objects emitted by * `ChatAgent.streamRun()` via `config.writer()` * - `"updates"` chunks carry the final state update from `agentLoopNode` * * @param input - The input state for the graph (userId and messages) * @param sessionId - The session ID for event attribution * @param checkpointer - Optional checkpointer for persistence * @yields ChatStreamEvent objects */ streamChatEvents(input: { userId: string; messages: BaseMessage[]; networkId?: string; scopeType?: ToolScopeType; scopeId?: string; }, sessionId: string, checkpointer?: BaseCheckpointSaver, signal?: AbortSignal, threadId?: string): AsyncGenerator; }