import {AIMessage, HumanMessage, ToolMessage} from '@langchain/core/messages'; import {RunnableToolLike} from '@langchain/core/runnables'; import {StructuredToolInterface} from '@langchain/core/tools'; import {LangGraphRunnableConfig} from '@langchain/langgraph'; import {AnyObject, Command} from '@loopback/repository'; import {LLMStreamEvent} from './event.types'; export type {LangGraphRunnableConfig} from '@langchain/langgraph'; export type RunnableConfig = LangGraphRunnableConfig & { writer?: (event: LLMStreamEvent) => void; }; export interface IGraphNode { execute: (state: T, config: RunnableConfig) => Promise | Command>; } export type SavedMessage = HumanMessage | AIMessage | ToolMessage; export interface IGraphTool { key: string; build( config: LangGraphRunnableConfig, ): Promise; getValue?(result: Record): string; getMetadata?(result: Record): AnyObject; needsReview?: boolean; } export type IGraphDirectEdge = { from: string; to: string; }; export type IGraphConditionalEdge = { from: string; toList: string[]; branchingFunction(state: T): string; }; export type IGraphEdge = | IGraphDirectEdge | IGraphConditionalEdge; export enum ToolStatus { Running = 'running', Completed = 'completed', Failed = 'failed', }