import { BaseMessage } from '@langchain/core/messages'; import { Annotation, END } from '@langchain/langgraph'; import { Document } from 'langchain/document'; /** * State interface for the agent supervisor workflow */ export const AgentState = Annotation.Root({ messages: Annotation({ reducer: (x, y) => x.concat(y), default: () => [], }), query: Annotation({ reducer: (x, y) => y ?? x, default: () => '', }), relevantDocuments: Annotation({ reducer: (x, y) => x.concat(y), default: () => [], }), bannedSummaryUrls: Annotation({ reducer: (x, y) => x.concat(y), default: () => [], }), bannedPreviewUrls: Annotation({ reducer: (x, y) => x.concat(y), default: () => [], }), searchInstructionHistory: Annotation({ reducer: (x, y) => x.concat(y), default: () => [], }), searchInstructions: Annotation({ reducer: (x, y) => y ?? x, default: () => '', }), next: Annotation({ reducer: (x, y) => y ?? x ?? END, default: () => END, }), analysis: Annotation({ reducer: (x, y) => y ?? x, default: () => '', }), fullAnalysisAttempts: Annotation({ reducer: (x, y) => (y ?? 0) + x, default: () => 0, }), tasks: Annotation({ reducer: (x, y) => y ?? x, default: () => [], }), currentTaskIndex: Annotation({ reducer: (x, y) => y ?? x, default: () => 0, }), originalQuery: Annotation({ reducer: (x, y) => y ?? x, default: () => '', }), fileIds: Annotation({ reducer: (x, y) => y ?? x, default: () => [], }), focusMode: Annotation({ reducer: (x, y) => y ?? x, default: () => 'webSearch', }), urlsToSummarize: Annotation({ reducer: (x, y) => y ?? x, default: () => [], }), summarizationIntent: Annotation({ reducer: (x, y) => y ?? x, default: () => '', }), recursionLimitReached: Annotation({ reducer: (x, y) => y ?? x, default: () => false, }), });