/** * Enum representing the various event types emitted during the execution of runnables. * These events provide real-time information about the progress and state of different components. * * @enum {string} */ export enum GraphEvents { /* Custom Events */ /** [Custom] Agent update event in multi-agent graph/workflow */ ON_AGENT_UPDATE = 'on_agent_update', /** [Custom] Subagent lifecycle event (start, run_step, message_delta, stop, error) */ ON_SUBAGENT_UPDATE = 'on_subagent_update', /** [Custom] Delta event for run steps (message creation and tool calls) */ ON_RUN_STEP = 'on_run_step', /** [Custom] Delta event for run steps (tool calls) */ ON_RUN_STEP_DELTA = 'on_run_step_delta', /** [Custom] Completed event for run steps (tool calls) */ ON_RUN_STEP_COMPLETED = 'on_run_step_completed', /** [Custom] Delta events for messages */ ON_MESSAGE_DELTA = 'on_message_delta', /** [Custom] Reasoning Delta events for messages */ ON_REASONING_DELTA = 'on_reasoning_delta', /** [Custom] Context analytics event for traces */ ON_CONTEXT_ANALYTICS = 'on_context_analytics', /** [Custom] Structured output event - emitted when agent returns structured JSON */ ON_STRUCTURED_OUTPUT = 'on_structured_output', /** [Custom] Request to execute tools - dispatched by ToolNode, handled by host */ ON_TOOL_EXECUTE = 'on_tool_execute', /** [Custom] Context pressure event for monitoring compaction triggers */ ON_CONTEXT_PRESSURE = 'on_context_pressure', /** [Custom] Tool requires human approval before execution - dispatched by ToolNode HITL */ ON_TOOL_APPROVAL_REQUIRED = 'on_tool_approval_required', /** [Custom] Agent transition event — dispatched when control passes between agents */ ON_AGENT_TRANSITION = 'on_agent_transition', /** [Custom] Approval gate interrupt — dispatched by ApprovalGateNode before interrupt() */ ON_APPROVAL_GATE = 'on_approval_gate', /* Official Events */ /** Custom event, emitted by system */ ON_CUSTOM_EVENT = 'on_custom_event', /** Emitted when a chat model starts processing. */ CHAT_MODEL_START = 'on_chat_model_start', /** Emitted when a chat model streams a chunk of its response. */ CHAT_MODEL_STREAM = 'on_chat_model_stream', /** Emitted when a chat model completes its processing. */ CHAT_MODEL_END = 'on_chat_model_end', /** Emitted when a language model starts processing. */ LLM_START = 'on_llm_start', /** Emitted when a language model streams a chunk of its response. */ LLM_STREAM = 'on_llm_stream', /** Emitted when a language model completes its processing. */ LLM_END = 'on_llm_end', /** Emitted when a chain starts processing. */ CHAIN_START = 'on_chain_start', /** Emitted when a chain streams a chunk of its output. */ CHAIN_STREAM = 'on_chain_stream', /** Emitted when a chain completes its processing. */ CHAIN_END = 'on_chain_end', /** Emitted when a tool starts its operation. */ TOOL_START = 'on_tool_start', /** Emitted when a tool completes its operation. */ TOOL_END = 'on_tool_end', /** Emitted when a retriever starts its operation. */ RETRIEVER_START = 'on_retriever_start', /** Emitted when a retriever completes its operation. */ RETRIEVER_END = 'on_retriever_end', /** Emitted when a prompt starts processing. */ PROMPT_START = 'on_prompt_start', /** Emitted when a prompt completes its processing. */ PROMPT_END = 'on_prompt_end', } export enum Providers { OPENAI = 'openAI', VERTEXAI = 'vertexai', BEDROCK = 'bedrock', ANTHROPIC = 'anthropic', MISTRALAI = 'mistralai', MISTRAL = 'mistral', GOOGLE = 'google', AZURE = 'azureOpenAI', DEEPSEEK = 'deepseek', OPENROUTER = 'openrouter', XAI = 'xai', MOONSHOT = 'moonshot', } export enum EdgeType { /** * Upstream-aligned handoff: one-way routing where the parent agent exits * via a `lc_transfer_to_` tool call, the child takes over, * and the child responds directly to the user. Replaces what used to be * called "TRANSFER" in earlier Ranger versions; the parent-calls-child * supervisor pattern (formerly `EdgeType.HANDOFF`) is gone — use the * Subagent primitive (Tier 5) for deep delegation instead. */ HANDOFF = 'handoff', /** * Fixed graph edges for automatic transitions. Naming matches upstream. * Ranger keeps its enriched wiring on top of this edge type: * fan-in with prompt + {results}, parallel groups, ApprovalGateNode * insertion, and the `excludeResults` agentMessages channel. */ DIRECT = 'direct', } export enum GraphNodeKeys { TOOLS = 'tools=', AGENT = 'agent=', ROUTER = 'router', PRE_TOOLS = 'pre_tools', POST_TOOLS = 'post_tools', } export enum GraphNodeActions { TOOL_NODE = 'tool_node', CALL_MODEL = 'call_model', ROUTE_MESSAGE = 'route_message', } export enum CommonEvents { LANGGRAPH = 'LangGraph', } export enum StepTypes { TOOL_CALLS = 'tool_calls', MESSAGE_CREATION = 'message_creation', } export enum ContentTypes { TEXT = 'text', ERROR = 'error', THINK = 'think', TOOL_CALL = 'tool_call', IMAGE_URL = 'image_url', IMAGE_FILE = 'image_file', /** Anthropic */ THINKING = 'thinking', /** Vertex AI / Google Common */ REASONING = 'reasoning', /** Multi-Agent Switch */ AGENT_UPDATE = 'agent_update', /** Bedrock */ REASONING_CONTENT = 'reasoning_content', } export enum ToolCallTypes { FUNCTION = 'function', RETRIEVAL = 'retrieval', FILE_SEARCH = 'file_search', CODE_INTERPRETER = 'code_interpreter', /* Agents Tool Call */ TOOL_CALL = 'tool_call', } export enum Callback { TOOL_ERROR = 'handleToolError', TOOL_START = 'handleToolStart', TOOL_END = 'handleToolEnd', CUSTOM_EVENT = 'handleCustomEvent', /* LLM_START = 'handleLLMStart', LLM_NEW_TOKEN = 'handleLLMNewToken', LLM_ERROR = 'handleLLMError', LLM_END = 'handleLLMEnd', CHAT_MODEL_START = 'handleChatModelStart', CHAIN_START = 'handleChainStart', CHAIN_ERROR = 'handleChainError', CHAIN_END = 'handleChainEnd', TEXT = 'handleText', AGENT_ACTION = 'handleAgentAction', AGENT_END = 'handleAgentEnd', RETRIEVER_START = 'handleRetrieverStart', RETRIEVER_END = 'handleRetrieverEnd', RETRIEVER_ERROR = 'handleRetrieverError', */ } export enum Constants { OFFICIAL_CODE_BASEURL = 'https://api.illuma.ai/v1', EXECUTE_CODE = 'execute_code', /** Tool name for the bash execution primitive (upstream Tier 3). */ BASH_TOOL = 'execute_bash', /** Tool name for the bash programmatic-tool-calling variant (upstream Tier 3). */ BASH_PROGRAMMATIC_TOOL_CALLING = 'run_tools_with_bash', /** Tool name for the read-file primitive (upstream Tier 3). */ READ_FILE = 'read_file', /** Tool name for the SkillTool primitive (upstream Tier 2). */ SKILL_TOOL = 'skill', /** Tool name for the Subagent primitive (upstream Tier 5). */ SUBAGENT = 'subagent', TOOL_SEARCH = 'tool_search', PROGRAMMATIC_TOOL_CALLING = 'run_tools_with_code', WEB_SEARCH = 'web_search', CONTENT_AND_ARTIFACT = 'content_and_artifact', /** Prefix for handoff tool names (parent-exits routing): lc_transfer_to_{agentId}. */ LC_TRANSFER_TO_ = 'lc_transfer_to_', /** Tool name for the AskUser structured question tool */ ASK_USER = 'ask_user', /** Delimiter for MCP tools: toolName_mcp_serverName */ MCP_DELIMITER = '_mcp_', /** Prefix for Anthropic-hosted server tool ids (web_search, code_execution). * These are issued by Anthropic, not by us, and should be ignored by * orphan-repair sweeps that don't have ground truth for them. */ ANTHROPIC_SERVER_TOOL_PREFIX = 'srvtoolu_', } export enum TitleMethod { STRUCTURED = 'structured', FUNCTIONS = 'functions', COMPLETION = 'completion', } export enum EnvVar { CODE_API_KEY = 'CODE_EXECUTOR_API_KEY', CODE_BASEURL = 'CODE_EXECUTOR_BASEURL', } /** * Normalized LLM finish/stop reasons across providers. * Used by toolCallContinuation to detect max_tokens truncation. */ export enum FinishReasons { /** Anthropic / Bedrock stop reason for token limit */ MAX_TOKENS = 'max_tokens', /** OpenAI / Azure finish reason for token limit */ LENGTH = 'length', /** Normal completion */ STOP = 'stop', /** Anthropic / Bedrock stop reason for normal completion */ END_TURN = 'end_turn', /** Model chose to call tools */ TOOL_USE = 'tool_use', /** OpenAI finish reason for tool calls */ TOOL_CALLS = 'tool_calls', } /** * Message type identifiers used by LangChain's BaseMessage.getType(). * Use these constants instead of instanceof checks to avoid module mismatch issues * when different copies of @langchain/core/messages are loaded. */ export enum MessageTypes { HUMAN = 'human', AI = 'ai', SYSTEM = 'system', TOOL = 'tool', FUNCTION = 'function', GENERIC = 'generic', DEVELOPER = 'developer', REMOVE = 'remove', } /** * Tool names that use the code execution environment (shared session, file * tracking). Used by ToolNode to inject session context + file refs into * `invokeParams` before tool execution. Upstream-aligned constant. */ export const CODE_EXECUTION_TOOLS: ReadonlySet = new Set([ Constants.EXECUTE_CODE, Constants.BASH_TOOL, Constants.PROGRAMMATIC_TOOL_CALLING, Constants.BASH_PROGRAMMATIC_TOOL_CALLING, ]);