@librechat/agents 3.4.6 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/agents/AgentContext.cjs +0 -356
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/agents/projection.cjs +0 -9
- package/dist/cjs/agents/projection.cjs.map +1 -1
- package/dist/cjs/common/constants.cjs +0 -26
- package/dist/cjs/common/constants.cjs.map +1 -1
- package/dist/cjs/common/enum.cjs +0 -85
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/events.cjs +0 -14
- package/dist/cjs/events.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +1 -909
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +7 -272
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/graphs/applyGraphRuntimeConfig.cjs.map +1 -1
- package/dist/cjs/graphs/createGraph.cjs.map +1 -1
- package/dist/cjs/hitl/askUserQuestion.cjs +0 -53
- package/dist/cjs/hitl/askUserQuestion.cjs.map +1 -1
- package/dist/cjs/hitl/askUserQuestions.cjs +0 -20
- package/dist/cjs/hitl/askUserQuestions.cjs.map +1 -1
- package/dist/cjs/hitl/askUserQuestionsInterrupt.cjs +0 -6
- package/dist/cjs/hitl/askUserQuestionsInterrupt.cjs.map +1 -1
- package/dist/cjs/hooks/HookRegistry.cjs +0 -127
- package/dist/cjs/hooks/HookRegistry.cjs.map +1 -1
- package/dist/cjs/hooks/createToolPolicyHook.cjs +0 -38
- package/dist/cjs/hooks/createToolPolicyHook.cjs.map +1 -1
- package/dist/cjs/hooks/createWorkspacePolicyHook.cjs +0 -77
- package/dist/cjs/hooks/createWorkspacePolicyHook.cjs.map +1 -1
- package/dist/cjs/hooks/executeHooks.cjs +0 -79
- package/dist/cjs/hooks/executeHooks.cjs.map +1 -1
- package/dist/cjs/hooks/index.cjs +0 -16
- package/dist/cjs/hooks/index.cjs.map +1 -1
- package/dist/cjs/hooks/matchers.cjs +0 -104
- package/dist/cjs/hooks/matchers.cjs.map +1 -1
- package/dist/cjs/hooks/types.cjs +0 -8
- package/dist/cjs/hooks/types.cjs.map +1 -1
- package/dist/cjs/instrumentation.cjs +0 -14
- package/dist/cjs/instrumentation.cjs.map +1 -1
- package/dist/cjs/langfuse.cjs +0 -75
- package/dist/cjs/langfuse.cjs.map +1 -1
- package/dist/cjs/langfuseConfig.cjs.map +1 -1
- package/dist/cjs/langfuseRuntimeContext.cjs +0 -13
- package/dist/cjs/langfuseRuntimeContext.cjs.map +1 -1
- package/dist/cjs/langfuseRuntimeScope.cjs +0 -4
- package/dist/cjs/langfuseRuntimeScope.cjs.map +1 -1
- package/dist/cjs/langfuseSpanRegistry.cjs +0 -28
- package/dist/cjs/langfuseSpanRegistry.cjs.map +1 -1
- package/dist/cjs/langfuseToolOutputTracing.cjs +0 -3
- package/dist/cjs/langfuseToolOutputTracing.cjs.map +1 -1
- package/dist/cjs/langfuseTraceShaping.cjs +0 -74
- package/dist/cjs/langfuseTraceShaping.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/index.cjs +0 -3
- package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/types.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +1 -111
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +0 -1
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/stream_events.cjs +0 -8
- package/dist/cjs/llm/anthropic/utils/stream_events.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/tools.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/cachePoints.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/index.cjs +1 -95
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/toolCache.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs +0 -78
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/utils/message_outputs.cjs +0 -24
- package/dist/cjs/llm/bedrock/utils/message_outputs.cjs.map +1 -1
- package/dist/cjs/llm/contextOverflowRecovery.cjs +0 -62
- package/dist/cjs/llm/contextOverflowRecovery.cjs.map +1 -1
- package/dist/cjs/llm/fake.cjs.map +1 -1
- package/dist/cjs/llm/google/index.cjs +2 -21
- package/dist/cjs/llm/google/index.cjs.map +1 -1
- package/dist/cjs/llm/google/utils/common.cjs +5 -35
- package/dist/cjs/llm/google/utils/common.cjs.map +1 -1
- package/dist/cjs/llm/init.cjs +0 -9
- package/dist/cjs/llm/init.cjs.map +1 -1
- package/dist/cjs/llm/invoke.cjs +1 -270
- package/dist/cjs/llm/invoke.cjs.map +1 -1
- package/dist/cjs/llm/mistral/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +0 -99
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/streamMetadata.cjs +0 -21
- package/dist/cjs/llm/openai/streamMetadata.cjs.map +1 -1
- package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
- package/dist/cjs/llm/openrouter/index.cjs +0 -1
- package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
- package/dist/cjs/llm/openrouter/toolCache.cjs +0 -6
- package/dist/cjs/llm/openrouter/toolCache.cjs.map +1 -1
- package/dist/cjs/llm/preempt.cjs +0 -75
- package/dist/cjs/llm/preempt.cjs.map +1 -1
- package/dist/cjs/llm/providers.cjs.map +1 -1
- package/dist/cjs/llm/request.cjs +0 -10
- package/dist/cjs/llm/request.cjs.map +1 -1
- package/dist/cjs/llm/stream/chunkAdapters.cjs +0 -62
- package/dist/cjs/llm/stream/chunkAdapters.cjs.map +1 -1
- package/dist/cjs/llm/stream/smoother.cjs +0 -58
- package/dist/cjs/llm/stream/smoother.cjs.map +1 -1
- package/dist/cjs/llm/streamLimits.cjs +4 -293
- package/dist/cjs/llm/streamLimits.cjs.map +1 -1
- package/dist/cjs/llm/truncation.cjs +0 -36
- package/dist/cjs/llm/truncation.cjs.map +1 -1
- package/dist/cjs/llm/vertexai/index.cjs +0 -330
- package/dist/cjs/llm/vertexai/index.cjs.map +1 -1
- package/dist/cjs/messages/alternation.cjs +0 -43
- package/dist/cjs/messages/alternation.cjs.map +1 -1
- package/dist/cjs/messages/anthropicToolCache.cjs +0 -45
- package/dist/cjs/messages/anthropicToolCache.cjs.map +1 -1
- package/dist/cjs/messages/assistantPhase.cjs +0 -12
- package/dist/cjs/messages/assistantPhase.cjs.map +1 -1
- package/dist/cjs/messages/budget.cjs +0 -9
- package/dist/cjs/messages/budget.cjs.map +1 -1
- package/dist/cjs/messages/cache.cjs +0 -172
- package/dist/cjs/messages/cache.cjs.map +1 -1
- package/dist/cjs/messages/content.cjs +0 -9
- package/dist/cjs/messages/content.cjs.map +1 -1
- package/dist/cjs/messages/contextPruning.cjs +0 -15
- package/dist/cjs/messages/contextPruning.cjs.map +1 -1
- package/dist/cjs/messages/contextPruningSettings.cjs +0 -3
- package/dist/cjs/messages/contextPruningSettings.cjs.map +1 -1
- package/dist/cjs/messages/core.cjs +0 -48
- package/dist/cjs/messages/core.cjs.map +1 -1
- package/dist/cjs/messages/format.cjs +1 -345
- package/dist/cjs/messages/format.cjs.map +1 -1
- package/dist/cjs/messages/handoffCue.cjs +0 -36
- package/dist/cjs/messages/handoffCue.cjs.map +1 -1
- package/dist/cjs/messages/ids.cjs.map +1 -1
- package/dist/cjs/messages/injected.cjs +0 -33
- package/dist/cjs/messages/injected.cjs.map +1 -1
- package/dist/cjs/messages/langchain.cjs +0 -14
- package/dist/cjs/messages/langchain.cjs.map +1 -1
- package/dist/cjs/messages/prune.cjs +1 -184
- package/dist/cjs/messages/prune.cjs.map +1 -1
- package/dist/cjs/messages/recency.cjs +0 -32
- package/dist/cjs/messages/recency.cjs.map +1 -1
- package/dist/cjs/messages/reducer.cjs +0 -30
- package/dist/cjs/messages/reducer.cjs.map +1 -1
- package/dist/cjs/messages/tools.cjs +0 -14
- package/dist/cjs/messages/tools.cjs.map +1 -1
- package/dist/cjs/openai/index.cjs.map +1 -1
- package/dist/cjs/prompts/activityLabel.cjs +9 -79
- package/dist/cjs/prompts/activityLabel.cjs.map +1 -1
- package/dist/cjs/responses/index.cjs.map +1 -1
- package/dist/cjs/run.cjs +2 -538
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/session/AgentSession.cjs +1 -17
- package/dist/cjs/session/AgentSession.cjs.map +1 -1
- package/dist/cjs/session/JsonlSessionStore.cjs.map +1 -1
- package/dist/cjs/session/handlers.cjs +0 -7
- package/dist/cjs/session/handlers.cjs.map +1 -1
- package/dist/cjs/session/ids.cjs.map +1 -1
- package/dist/cjs/session/messageSerialization.cjs +0 -4
- package/dist/cjs/session/messageSerialization.cjs.map +1 -1
- package/dist/cjs/stream.cjs +1 -93
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/summarization/index.cjs +0 -27
- package/dist/cjs/summarization/index.cjs.map +1 -1
- package/dist/cjs/summarization/node.cjs +0 -273
- package/dist/cjs/summarization/node.cjs.map +1 -1
- package/dist/cjs/tools/BashExecutor.cjs +0 -35
- package/dist/cjs/tools/BashExecutor.cjs.map +1 -1
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +0 -24
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/Calculator.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +0 -13
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/CodeSessionFileSummary.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +0 -101
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ReadFile.cjs.map +1 -1
- package/dist/cjs/tools/SkillTool.cjs +0 -5
- package/dist/cjs/tools/SkillTool.cjs.map +1 -1
- package/dist/cjs/tools/SubagentTool.cjs +0 -10
- package/dist/cjs/tools/SubagentTool.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +6 -1038
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/ToolSearch.cjs +0 -179
- package/dist/cjs/tools/ToolSearch.cjs.map +1 -1
- package/dist/cjs/tools/cloudflare/CloudflareBridgeRuntime.cjs.map +1 -1
- package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs +0 -39
- package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs.map +1 -1
- package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs.map +1 -1
- package/dist/cjs/tools/eagerEventExecution.cjs +0 -6
- package/dist/cjs/tools/eagerEventExecution.cjs.map +1 -1
- package/dist/cjs/tools/handlers.cjs +1 -41
- package/dist/cjs/tools/handlers.cjs.map +1 -1
- package/dist/cjs/tools/intentArg.cjs +1 -132
- package/dist/cjs/tools/intentArg.cjs.map +1 -1
- package/dist/cjs/tools/local/CompileCheckTool.cjs +0 -25
- package/dist/cjs/tools/local/CompileCheckTool.cjs.map +1 -1
- package/dist/cjs/tools/local/FileCheckpointer.cjs +0 -23
- package/dist/cjs/tools/local/FileCheckpointer.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalCodingTools.cjs +0 -80
- package/dist/cjs/tools/local/LocalCodingTools.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalExecutionEngine.cjs +0 -126
- package/dist/cjs/tools/local/LocalExecutionEngine.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalExecutionTools.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +0 -12
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/local/attachments.cjs +0 -44
- package/dist/cjs/tools/local/attachments.cjs.map +1 -1
- package/dist/cjs/tools/local/bashAst.cjs +0 -16
- package/dist/cjs/tools/local/bashAst.cjs.map +1 -1
- package/dist/cjs/tools/local/editStrategies.cjs +0 -14
- package/dist/cjs/tools/local/editStrategies.cjs.map +1 -1
- package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -1
- package/dist/cjs/tools/local/syntaxCheck.cjs +0 -31
- package/dist/cjs/tools/local/syntaxCheck.cjs.map +1 -1
- package/dist/cjs/tools/local/textEncoding.cjs +0 -11
- package/dist/cjs/tools/local/textEncoding.cjs.map +1 -1
- package/dist/cjs/tools/local/workspaceFS.cjs +0 -33
- package/dist/cjs/tools/local/workspaceFS.cjs.map +1 -1
- package/dist/cjs/tools/ptcTimeout.cjs.map +1 -1
- package/dist/cjs/tools/schema.cjs +0 -8
- package/dist/cjs/tools/schema.cjs.map +1 -1
- package/dist/cjs/tools/search/anthropic.cjs +0 -9
- package/dist/cjs/tools/search/anthropic.cjs.map +1 -1
- package/dist/cjs/tools/search/content.cjs.map +1 -1
- package/dist/cjs/tools/search/crw-scraper.cjs +0 -33
- package/dist/cjs/tools/search/crw-scraper.cjs.map +1 -1
- package/dist/cjs/tools/search/crw-search.cjs +0 -2
- package/dist/cjs/tools/search/crw-search.cjs.map +1 -1
- package/dist/cjs/tools/search/firecrawl.cjs +0 -25
- package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
- package/dist/cjs/tools/search/format.cjs +0 -30
- package/dist/cjs/tools/search/format.cjs.map +1 -1
- package/dist/cjs/tools/search/highlights.cjs +0 -16
- package/dist/cjs/tools/search/highlights.cjs.map +1 -1
- package/dist/cjs/tools/search/keenable-scraper.cjs +0 -8
- package/dist/cjs/tools/search/keenable-scraper.cjs.map +1 -1
- package/dist/cjs/tools/search/keenable-search.cjs +0 -7
- package/dist/cjs/tools/search/keenable-search.cjs.map +1 -1
- package/dist/cjs/tools/search/rerankers.cjs +0 -35
- package/dist/cjs/tools/search/rerankers.cjs.map +1 -1
- package/dist/cjs/tools/search/schema.cjs +0 -1
- package/dist/cjs/tools/search/schema.cjs.map +1 -1
- package/dist/cjs/tools/search/search.cjs +1 -14
- package/dist/cjs/tools/search/search.cjs.map +1 -1
- package/dist/cjs/tools/search/serper-scraper.cjs +0 -46
- package/dist/cjs/tools/search/serper-scraper.cjs.map +1 -1
- package/dist/cjs/tools/search/tavily-scraper.cjs.map +1 -1
- package/dist/cjs/tools/search/tavily-search.cjs.map +1 -1
- package/dist/cjs/tools/search/tool.cjs +0 -25
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/cjs/tools/search/utils.cjs +0 -8
- package/dist/cjs/tools/search/utils.cjs.map +1 -1
- package/dist/cjs/tools/skillCatalog.cjs +0 -6
- package/dist/cjs/tools/skillCatalog.cjs.map +1 -1
- package/dist/cjs/tools/streamedToolCallSeals.cjs +0 -6
- package/dist/cjs/tools/streamedToolCallSeals.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs +0 -2
- package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +3 -213
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentReplay.cjs.map +1 -1
- package/dist/cjs/tools/subagent/childGraphConfig.cjs +0 -4
- package/dist/cjs/tools/subagent/childGraphConfig.cjs.map +1 -1
- package/dist/cjs/tools/subagent/runtimeLimits.cjs.map +1 -1
- package/dist/cjs/tools/toolOutputReferences.cjs +1 -322
- package/dist/cjs/tools/toolOutputReferences.cjs.map +1 -1
- package/dist/cjs/types/hitl.cjs +0 -5
- package/dist/cjs/types/hitl.cjs.map +1 -1
- package/dist/cjs/utils/callbacks.cjs.map +1 -1
- package/dist/cjs/utils/errors.cjs +14 -165
- package/dist/cjs/utils/errors.cjs.map +1 -1
- package/dist/cjs/utils/events.cjs +0 -10
- package/dist/cjs/utils/events.cjs.map +1 -1
- package/dist/cjs/utils/graph.cjs.map +1 -1
- package/dist/cjs/utils/handlers.cjs +0 -3
- package/dist/cjs/utils/handlers.cjs.map +1 -1
- package/dist/cjs/utils/llm.cjs +0 -1
- package/dist/cjs/utils/llm.cjs.map +1 -1
- package/dist/cjs/utils/misc.cjs +0 -16
- package/dist/cjs/utils/misc.cjs.map +1 -1
- package/dist/cjs/utils/proxy.cjs +0 -26
- package/dist/cjs/utils/proxy.cjs.map +1 -1
- package/dist/cjs/utils/run.cjs +0 -6
- package/dist/cjs/utils/run.cjs.map +1 -1
- package/dist/cjs/utils/schema.cjs +0 -5
- package/dist/cjs/utils/schema.cjs.map +1 -1
- package/dist/cjs/utils/title.cjs +0 -6
- package/dist/cjs/utils/title.cjs.map +1 -1
- package/dist/cjs/utils/tokens.cjs +0 -113
- package/dist/cjs/utils/tokens.cjs.map +1 -1
- package/dist/cjs/utils/toolContent.cjs +0 -41
- package/dist/cjs/utils/toolContent.cjs.map +1 -1
- package/dist/cjs/utils/truncation.cjs +0 -61
- package/dist/cjs/utils/truncation.cjs.map +1 -1
- package/dist/esm/agents/AgentContext.mjs +0 -356
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/agents/projection.mjs +0 -9
- package/dist/esm/agents/projection.mjs.map +1 -1
- package/dist/esm/common/constants.mjs +0 -26
- package/dist/esm/common/constants.mjs.map +1 -1
- package/dist/esm/common/enum.mjs +0 -85
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/events.mjs +0 -14
- package/dist/esm/events.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +1 -909
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +7 -272
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/graphs/applyGraphRuntimeConfig.mjs.map +1 -1
- package/dist/esm/graphs/createGraph.mjs.map +1 -1
- package/dist/esm/hitl/askUserQuestion.mjs +0 -53
- package/dist/esm/hitl/askUserQuestion.mjs.map +1 -1
- package/dist/esm/hitl/askUserQuestions.mjs +0 -20
- package/dist/esm/hitl/askUserQuestions.mjs.map +1 -1
- package/dist/esm/hitl/askUserQuestionsInterrupt.mjs +0 -6
- package/dist/esm/hitl/askUserQuestionsInterrupt.mjs.map +1 -1
- package/dist/esm/hooks/HookRegistry.mjs +0 -127
- package/dist/esm/hooks/HookRegistry.mjs.map +1 -1
- package/dist/esm/hooks/createToolPolicyHook.mjs +0 -38
- package/dist/esm/hooks/createToolPolicyHook.mjs.map +1 -1
- package/dist/esm/hooks/createWorkspacePolicyHook.mjs +0 -77
- package/dist/esm/hooks/createWorkspacePolicyHook.mjs.map +1 -1
- package/dist/esm/hooks/executeHooks.mjs +0 -79
- package/dist/esm/hooks/executeHooks.mjs.map +1 -1
- package/dist/esm/hooks/index.mjs +0 -16
- package/dist/esm/hooks/index.mjs.map +1 -1
- package/dist/esm/hooks/matchers.mjs +0 -104
- package/dist/esm/hooks/matchers.mjs.map +1 -1
- package/dist/esm/hooks/types.mjs +0 -8
- package/dist/esm/hooks/types.mjs.map +1 -1
- package/dist/esm/instrumentation.mjs +0 -14
- package/dist/esm/instrumentation.mjs.map +1 -1
- package/dist/esm/langfuse.mjs +0 -75
- package/dist/esm/langfuse.mjs.map +1 -1
- package/dist/esm/langfuseConfig.mjs.map +1 -1
- package/dist/esm/langfuseRuntimeContext.mjs +0 -13
- package/dist/esm/langfuseRuntimeContext.mjs.map +1 -1
- package/dist/esm/langfuseRuntimeScope.mjs +0 -4
- package/dist/esm/langfuseRuntimeScope.mjs.map +1 -1
- package/dist/esm/langfuseSpanRegistry.mjs +0 -28
- package/dist/esm/langfuseSpanRegistry.mjs.map +1 -1
- package/dist/esm/langfuseToolOutputTracing.mjs +0 -3
- package/dist/esm/langfuseToolOutputTracing.mjs.map +1 -1
- package/dist/esm/langfuseTraceShaping.mjs +0 -74
- package/dist/esm/langfuseTraceShaping.mjs.map +1 -1
- package/dist/esm/llm/anthropic/index.mjs +0 -3
- package/dist/esm/llm/anthropic/index.mjs.map +1 -1
- package/dist/esm/llm/anthropic/types.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs +1 -111
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs +0 -1
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/stream_events.mjs +0 -8
- package/dist/esm/llm/anthropic/utils/stream_events.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/tools.mjs.map +1 -1
- package/dist/esm/llm/bedrock/cachePoints.mjs.map +1 -1
- package/dist/esm/llm/bedrock/index.mjs +1 -95
- package/dist/esm/llm/bedrock/index.mjs.map +1 -1
- package/dist/esm/llm/bedrock/toolCache.mjs.map +1 -1
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs +0 -78
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/bedrock/utils/message_outputs.mjs +0 -24
- package/dist/esm/llm/bedrock/utils/message_outputs.mjs.map +1 -1
- package/dist/esm/llm/contextOverflowRecovery.mjs +0 -62
- package/dist/esm/llm/contextOverflowRecovery.mjs.map +1 -1
- package/dist/esm/llm/fake.mjs.map +1 -1
- package/dist/esm/llm/google/index.mjs +2 -21
- package/dist/esm/llm/google/index.mjs.map +1 -1
- package/dist/esm/llm/google/utils/common.mjs +5 -35
- package/dist/esm/llm/google/utils/common.mjs.map +1 -1
- package/dist/esm/llm/init.mjs +0 -9
- package/dist/esm/llm/init.mjs.map +1 -1
- package/dist/esm/llm/invoke.mjs +1 -270
- package/dist/esm/llm/invoke.mjs.map +1 -1
- package/dist/esm/llm/mistral/index.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +0 -99
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/llm/openai/streamMetadata.mjs +0 -21
- package/dist/esm/llm/openai/streamMetadata.mjs.map +1 -1
- package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
- package/dist/esm/llm/openrouter/index.mjs +0 -1
- package/dist/esm/llm/openrouter/index.mjs.map +1 -1
- package/dist/esm/llm/openrouter/toolCache.mjs +0 -6
- package/dist/esm/llm/openrouter/toolCache.mjs.map +1 -1
- package/dist/esm/llm/preempt.mjs +0 -75
- package/dist/esm/llm/preempt.mjs.map +1 -1
- package/dist/esm/llm/providers.mjs.map +1 -1
- package/dist/esm/llm/request.mjs +0 -10
- package/dist/esm/llm/request.mjs.map +1 -1
- package/dist/esm/llm/stream/chunkAdapters.mjs +0 -62
- package/dist/esm/llm/stream/chunkAdapters.mjs.map +1 -1
- package/dist/esm/llm/stream/smoother.mjs +0 -58
- package/dist/esm/llm/stream/smoother.mjs.map +1 -1
- package/dist/esm/llm/streamLimits.mjs +4 -293
- package/dist/esm/llm/streamLimits.mjs.map +1 -1
- package/dist/esm/llm/truncation.mjs +0 -36
- package/dist/esm/llm/truncation.mjs.map +1 -1
- package/dist/esm/llm/vertexai/index.mjs +0 -330
- package/dist/esm/llm/vertexai/index.mjs.map +1 -1
- package/dist/esm/messages/alternation.mjs +0 -43
- package/dist/esm/messages/alternation.mjs.map +1 -1
- package/dist/esm/messages/anthropicToolCache.mjs +0 -45
- package/dist/esm/messages/anthropicToolCache.mjs.map +1 -1
- package/dist/esm/messages/assistantPhase.mjs +0 -12
- package/dist/esm/messages/assistantPhase.mjs.map +1 -1
- package/dist/esm/messages/budget.mjs +0 -9
- package/dist/esm/messages/budget.mjs.map +1 -1
- package/dist/esm/messages/cache.mjs +0 -172
- package/dist/esm/messages/cache.mjs.map +1 -1
- package/dist/esm/messages/content.mjs +0 -9
- package/dist/esm/messages/content.mjs.map +1 -1
- package/dist/esm/messages/contextPruning.mjs +0 -15
- package/dist/esm/messages/contextPruning.mjs.map +1 -1
- package/dist/esm/messages/contextPruningSettings.mjs +0 -3
- package/dist/esm/messages/contextPruningSettings.mjs.map +1 -1
- package/dist/esm/messages/core.mjs +0 -48
- package/dist/esm/messages/core.mjs.map +1 -1
- package/dist/esm/messages/format.mjs +1 -345
- package/dist/esm/messages/format.mjs.map +1 -1
- package/dist/esm/messages/handoffCue.mjs +0 -36
- package/dist/esm/messages/handoffCue.mjs.map +1 -1
- package/dist/esm/messages/ids.mjs.map +1 -1
- package/dist/esm/messages/injected.mjs +0 -33
- package/dist/esm/messages/injected.mjs.map +1 -1
- package/dist/esm/messages/langchain.mjs +0 -14
- package/dist/esm/messages/langchain.mjs.map +1 -1
- package/dist/esm/messages/prune.mjs +1 -184
- package/dist/esm/messages/prune.mjs.map +1 -1
- package/dist/esm/messages/recency.mjs +0 -32
- package/dist/esm/messages/recency.mjs.map +1 -1
- package/dist/esm/messages/reducer.mjs +0 -30
- package/dist/esm/messages/reducer.mjs.map +1 -1
- package/dist/esm/messages/tools.mjs +0 -14
- package/dist/esm/messages/tools.mjs.map +1 -1
- package/dist/esm/openai/index.mjs.map +1 -1
- package/dist/esm/prompts/activityLabel.mjs +9 -79
- package/dist/esm/prompts/activityLabel.mjs.map +1 -1
- package/dist/esm/responses/index.mjs.map +1 -1
- package/dist/esm/run.mjs +2 -538
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/session/AgentSession.mjs +1 -17
- package/dist/esm/session/AgentSession.mjs.map +1 -1
- package/dist/esm/session/JsonlSessionStore.mjs.map +1 -1
- package/dist/esm/session/handlers.mjs +0 -7
- package/dist/esm/session/handlers.mjs.map +1 -1
- package/dist/esm/session/ids.mjs.map +1 -1
- package/dist/esm/session/messageSerialization.mjs +0 -4
- package/dist/esm/session/messageSerialization.mjs.map +1 -1
- package/dist/esm/stream.mjs +1 -93
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/summarization/index.mjs +0 -27
- package/dist/esm/summarization/index.mjs.map +1 -1
- package/dist/esm/summarization/node.mjs +0 -273
- package/dist/esm/summarization/node.mjs.map +1 -1
- package/dist/esm/tools/BashExecutor.mjs +0 -35
- package/dist/esm/tools/BashExecutor.mjs.map +1 -1
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs +0 -24
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/Calculator.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +0 -13
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/CodeSessionFileSummary.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +0 -101
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ReadFile.mjs.map +1 -1
- package/dist/esm/tools/SkillTool.mjs +0 -5
- package/dist/esm/tools/SkillTool.mjs.map +1 -1
- package/dist/esm/tools/SubagentTool.mjs +0 -10
- package/dist/esm/tools/SubagentTool.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +6 -1038
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/ToolSearch.mjs +0 -179
- package/dist/esm/tools/ToolSearch.mjs.map +1 -1
- package/dist/esm/tools/cloudflare/CloudflareBridgeRuntime.mjs.map +1 -1
- package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs +0 -39
- package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs.map +1 -1
- package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs.map +1 -1
- package/dist/esm/tools/eagerEventExecution.mjs +0 -6
- package/dist/esm/tools/eagerEventExecution.mjs.map +1 -1
- package/dist/esm/tools/handlers.mjs +1 -41
- package/dist/esm/tools/handlers.mjs.map +1 -1
- package/dist/esm/tools/intentArg.mjs +1 -132
- package/dist/esm/tools/intentArg.mjs.map +1 -1
- package/dist/esm/tools/local/CompileCheckTool.mjs +0 -25
- package/dist/esm/tools/local/CompileCheckTool.mjs.map +1 -1
- package/dist/esm/tools/local/FileCheckpointer.mjs +0 -23
- package/dist/esm/tools/local/FileCheckpointer.mjs.map +1 -1
- package/dist/esm/tools/local/LocalCodingTools.mjs +0 -80
- package/dist/esm/tools/local/LocalCodingTools.mjs.map +1 -1
- package/dist/esm/tools/local/LocalExecutionEngine.mjs +0 -126
- package/dist/esm/tools/local/LocalExecutionEngine.mjs.map +1 -1
- package/dist/esm/tools/local/LocalExecutionTools.mjs.map +1 -1
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +0 -12
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/local/attachments.mjs +0 -44
- package/dist/esm/tools/local/attachments.mjs.map +1 -1
- package/dist/esm/tools/local/bashAst.mjs +0 -16
- package/dist/esm/tools/local/bashAst.mjs.map +1 -1
- package/dist/esm/tools/local/editStrategies.mjs +0 -14
- package/dist/esm/tools/local/editStrategies.mjs.map +1 -1
- package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -1
- package/dist/esm/tools/local/syntaxCheck.mjs +0 -31
- package/dist/esm/tools/local/syntaxCheck.mjs.map +1 -1
- package/dist/esm/tools/local/textEncoding.mjs +0 -11
- package/dist/esm/tools/local/textEncoding.mjs.map +1 -1
- package/dist/esm/tools/local/workspaceFS.mjs +0 -33
- package/dist/esm/tools/local/workspaceFS.mjs.map +1 -1
- package/dist/esm/tools/ptcTimeout.mjs.map +1 -1
- package/dist/esm/tools/schema.mjs +0 -8
- package/dist/esm/tools/schema.mjs.map +1 -1
- package/dist/esm/tools/search/anthropic.mjs +0 -9
- package/dist/esm/tools/search/anthropic.mjs.map +1 -1
- package/dist/esm/tools/search/content.mjs.map +1 -1
- package/dist/esm/tools/search/crw-scraper.mjs +0 -33
- package/dist/esm/tools/search/crw-scraper.mjs.map +1 -1
- package/dist/esm/tools/search/crw-search.mjs +0 -2
- package/dist/esm/tools/search/crw-search.mjs.map +1 -1
- package/dist/esm/tools/search/firecrawl.mjs +0 -25
- package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
- package/dist/esm/tools/search/format.mjs +0 -30
- package/dist/esm/tools/search/format.mjs.map +1 -1
- package/dist/esm/tools/search/highlights.mjs +0 -16
- package/dist/esm/tools/search/highlights.mjs.map +1 -1
- package/dist/esm/tools/search/keenable-scraper.mjs +0 -8
- package/dist/esm/tools/search/keenable-scraper.mjs.map +1 -1
- package/dist/esm/tools/search/keenable-search.mjs +0 -7
- package/dist/esm/tools/search/keenable-search.mjs.map +1 -1
- package/dist/esm/tools/search/rerankers.mjs +0 -35
- package/dist/esm/tools/search/rerankers.mjs.map +1 -1
- package/dist/esm/tools/search/schema.mjs +0 -1
- package/dist/esm/tools/search/schema.mjs.map +1 -1
- package/dist/esm/tools/search/search.mjs +1 -14
- package/dist/esm/tools/search/search.mjs.map +1 -1
- package/dist/esm/tools/search/serper-scraper.mjs +0 -46
- package/dist/esm/tools/search/serper-scraper.mjs.map +1 -1
- package/dist/esm/tools/search/tavily-scraper.mjs.map +1 -1
- package/dist/esm/tools/search/tavily-search.mjs.map +1 -1
- package/dist/esm/tools/search/tool.mjs +0 -25
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/esm/tools/search/utils.mjs +0 -8
- package/dist/esm/tools/search/utils.mjs.map +1 -1
- package/dist/esm/tools/skillCatalog.mjs +0 -6
- package/dist/esm/tools/skillCatalog.mjs.map +1 -1
- package/dist/esm/tools/streamedToolCallSeals.mjs +0 -6
- package/dist/esm/tools/streamedToolCallSeals.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs +0 -2
- package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +3 -213
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentReplay.mjs.map +1 -1
- package/dist/esm/tools/subagent/childGraphConfig.mjs +0 -4
- package/dist/esm/tools/subagent/childGraphConfig.mjs.map +1 -1
- package/dist/esm/tools/subagent/runtimeLimits.mjs.map +1 -1
- package/dist/esm/tools/toolOutputReferences.mjs +1 -322
- package/dist/esm/tools/toolOutputReferences.mjs.map +1 -1
- package/dist/esm/types/hitl.mjs +0 -5
- package/dist/esm/types/hitl.mjs.map +1 -1
- package/dist/esm/utils/callbacks.mjs.map +1 -1
- package/dist/esm/utils/errors.mjs +14 -165
- package/dist/esm/utils/errors.mjs.map +1 -1
- package/dist/esm/utils/events.mjs +0 -10
- package/dist/esm/utils/events.mjs.map +1 -1
- package/dist/esm/utils/graph.mjs.map +1 -1
- package/dist/esm/utils/handlers.mjs +0 -3
- package/dist/esm/utils/handlers.mjs.map +1 -1
- package/dist/esm/utils/llm.mjs +0 -1
- package/dist/esm/utils/llm.mjs.map +1 -1
- package/dist/esm/utils/misc.mjs +0 -16
- package/dist/esm/utils/misc.mjs.map +1 -1
- package/dist/esm/utils/proxy.mjs +0 -26
- package/dist/esm/utils/proxy.mjs.map +1 -1
- package/dist/esm/utils/run.mjs +0 -6
- package/dist/esm/utils/run.mjs.map +1 -1
- package/dist/esm/utils/schema.mjs +0 -5
- package/dist/esm/utils/schema.mjs.map +1 -1
- package/dist/esm/utils/title.mjs +0 -6
- package/dist/esm/utils/title.mjs.map +1 -1
- package/dist/esm/utils/tokens.mjs +0 -113
- package/dist/esm/utils/tokens.mjs.map +1 -1
- package/dist/esm/utils/toolContent.mjs +0 -41
- package/dist/esm/utils/toolContent.mjs.map +1 -1
- package/dist/esm/utils/truncation.mjs +0 -61
- package/dist/esm/utils/truncation.mjs.map +1 -1
- package/dist/types/agents/AgentContext.d.ts +3 -3
- package/dist/types/agents/__tests__/promptCacheLiveHelpers.d.ts +3 -3
- package/dist/types/agents/projection.d.ts +1 -1
- package/dist/types/events.d.ts +2 -2
- package/dist/types/graphs/Graph.d.ts +11 -11
- package/dist/types/graphs/MultiAgentGraph.d.ts +2 -2
- package/dist/types/graphs/createGraph.d.ts +4 -4
- package/dist/types/graphs/graphFactory.d.ts +1 -1
- package/dist/types/hitl/askUserQuestion.d.ts +1 -1
- package/dist/types/hitl/askUserQuestions.d.ts +1 -1
- package/dist/types/hitl/askUserQuestionsInterrupt.d.ts +1 -1
- package/dist/types/hooks/types.d.ts +1 -1
- package/dist/types/instrumentation.d.ts +1 -1
- package/dist/types/langfuse.d.ts +3 -3
- package/dist/types/langfuseConfig.d.ts +2 -2
- package/dist/types/langfuseRuntimeContext.d.ts +1 -1
- package/dist/types/langfuseRuntimeScope.d.ts +2 -2
- package/dist/types/langfuseSpanRegistry.d.ts +1 -1
- package/dist/types/langfuseToolOutputTracing.d.ts +3 -3
- package/dist/types/llm/anthropic/index.d.ts +1 -1
- package/dist/types/llm/bedrock/index.d.ts +1 -1
- package/dist/types/llm/bedrock/toolCache.d.ts +2 -2
- package/dist/types/llm/contextOverflowRecovery.d.ts +2 -2
- package/dist/types/llm/google/index.d.ts +1 -1
- package/dist/types/llm/init.d.ts +2 -2
- package/dist/types/llm/invoke.d.ts +6 -6
- package/dist/types/llm/mistral/index.d.ts +1 -1
- package/dist/types/llm/openai/index.d.ts +2 -2
- package/dist/types/llm/openrouter/index.d.ts +2 -2
- package/dist/types/llm/openrouter/toolCache.d.ts +2 -2
- package/dist/types/llm/providers.d.ts +2 -2
- package/dist/types/llm/request.d.ts +2 -2
- package/dist/types/llm/stream/chunkAdapters.d.ts +1 -1
- package/dist/types/llm/streamLimits.d.ts +1 -1
- package/dist/types/llm/truncation.d.ts +1 -1
- package/dist/types/llm/vertexai/index.d.ts +1 -1
- package/dist/types/messages/alternation.d.ts +1 -1
- package/dist/types/messages/anthropicToolCache.d.ts +2 -2
- package/dist/types/messages/assistantPhase.d.ts +3 -3
- package/dist/types/messages/budget.d.ts +1 -1
- package/dist/types/messages/cache.d.ts +1 -1
- package/dist/types/messages/contextPruning.d.ts +2 -2
- package/dist/types/messages/core.d.ts +2 -2
- package/dist/types/messages/format.d.ts +2 -2
- package/dist/types/messages/ids.d.ts +2 -2
- package/dist/types/messages/injected.d.ts +1 -1
- package/dist/types/messages/langchain.d.ts +1 -1
- package/dist/types/messages/prune.d.ts +3 -3
- package/dist/types/openai/index.d.ts +1 -1
- package/dist/types/prompts/activityLabel.d.ts +2 -2
- package/dist/types/responses/index.d.ts +1 -1
- package/dist/types/run.d.ts +3 -3
- package/dist/types/session/handlers.d.ts +1 -1
- package/dist/types/session/types.d.ts +1 -1
- package/dist/types/stream.d.ts +4 -4
- package/dist/types/summarization/index.d.ts +1 -1
- package/dist/types/summarization/node.d.ts +6 -6
- package/dist/types/test/mockTools.d.ts +1 -1
- package/dist/types/tools/BashExecutor.d.ts +2 -2
- package/dist/types/tools/BashProgrammaticToolCalling.d.ts +2 -2
- package/dist/types/tools/CodeExecutor.d.ts +3 -3
- package/dist/types/tools/CodeSessionFileSummary.d.ts +1 -1
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +2 -2
- package/dist/types/tools/ReadFile.d.ts +1 -1
- package/dist/types/tools/SkillTool.d.ts +1 -1
- package/dist/types/tools/SubagentTool.d.ts +3 -3
- package/dist/types/tools/ToolNode.d.ts +5 -5
- package/dist/types/tools/ToolSearch.d.ts +2 -2
- package/dist/types/tools/cloudflare/CloudflareBridgeRuntime.d.ts +1 -1
- package/dist/types/tools/cloudflare/CloudflareProgrammaticToolCalling.d.ts +1 -1
- package/dist/types/tools/cloudflare/CloudflareSandboxExecutionEngine.d.ts +2 -2
- package/dist/types/tools/cloudflare/CloudflareSandboxTools.d.ts +1 -1
- package/dist/types/tools/eagerEventExecution.d.ts +1 -1
- package/dist/types/tools/handlers.d.ts +3 -3
- package/dist/types/tools/intentArg.d.ts +1 -1
- package/dist/types/tools/local/CompileCheckTool.d.ts +2 -2
- package/dist/types/tools/local/FileCheckpointer.d.ts +1 -1
- package/dist/types/tools/local/LocalCodingTools.d.ts +2 -2
- package/dist/types/tools/local/LocalExecutionEngine.d.ts +1 -1
- package/dist/types/tools/local/LocalExecutionTools.d.ts +1 -1
- package/dist/types/tools/local/LocalProgrammaticToolCalling.d.ts +1 -1
- package/dist/types/tools/local/bashAst.d.ts +1 -1
- package/dist/types/tools/local/resolveLocalExecutionTools.d.ts +1 -1
- package/dist/types/tools/local/syntaxCheck.d.ts +1 -1
- package/dist/types/tools/ptcTimeout.d.ts +1 -1
- package/dist/types/tools/schema.d.ts +1 -1
- package/dist/types/tools/search/anthropic.d.ts +1 -1
- package/dist/types/tools/skillCatalog.d.ts +1 -1
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +5 -5
- package/dist/types/tools/subagent/SubagentReplay.d.ts +3 -3
- package/dist/types/tools/subagent/childGraphConfig.d.ts +2 -2
- package/dist/types/types/activityLabel.d.ts +3 -3
- package/dist/types/types/graph.d.ts +7 -7
- package/dist/types/types/llm.d.ts +9 -9
- package/dist/types/types/run.d.ts +7 -7
- package/dist/types/types/stream.d.ts +5 -5
- package/dist/types/types/summarize.d.ts +2 -2
- package/dist/types/types/tools.d.ts +5 -5
- package/dist/types/utils/__tests__/fixtures/contextOverflowSignatures.d.ts +1 -1
- package/dist/types/utils/errors.d.ts +1 -1
- package/dist/types/utils/events.d.ts +1 -1
- package/dist/types/utils/handlers.d.ts +3 -3
- package/dist/types/utils/llm.d.ts +1 -1
- package/dist/types/utils/llmConfig.d.ts +1 -1
- package/dist/types/utils/title.d.ts +1 -1
- package/package.json +10 -3
- package/src/llm/google/utils/common.ts +6 -4
- package/src/__tests__/stream.eagerArgsDivergence.test.ts +0 -911
- package/src/__tests__/stream.eagerEventExecution.test.ts +0 -5046
- package/src/__tests__/stream.streamLimits.test.ts +0 -1982
- package/src/agents/__tests__/AgentContext.anthropic.live.test.ts +0 -448
- package/src/agents/__tests__/AgentContext.bedrock.live.test.ts +0 -655
- package/src/agents/__tests__/AgentContext.openrouter.live.test.ts +0 -128
- package/src/agents/__tests__/AgentContext.overflow.test.ts +0 -205
- package/src/agents/__tests__/AgentContext.test.ts +0 -2425
- package/src/agents/__tests__/projection.test.ts +0 -73
- package/src/agents/__tests__/promptCacheLiveHelpers.ts +0 -175
- package/src/aggregator.test.ts +0 -1214
- package/src/graphs/__tests__/Graph.breakerLifecycle.test.ts +0 -273
- package/src/graphs/__tests__/Graph.closeRunStep.test.ts +0 -385
- package/src/graphs/__tests__/Graph.contextOverflow.test.ts +0 -1766
- package/src/graphs/__tests__/Graph.preemptSignal.test.ts +0 -126
- package/src/graphs/__tests__/Graph.reasoning.test.ts +0 -1717
- package/src/graphs/__tests__/Graph.subagentResumeState.test.ts +0 -80
- package/src/graphs/__tests__/MultiAgentGraph.test.ts +0 -177
- package/src/graphs/__tests__/composition.smoke.test.ts +0 -509
- package/src/graphs/__tests__/createGraph.test.ts +0 -206
- package/src/hooks/__tests__/HookRegistry.test.ts +0 -334
- package/src/hooks/__tests__/compactHooks.test.ts +0 -250
- package/src/hooks/__tests__/createToolPolicyHook.test.ts +0 -268
- package/src/hooks/__tests__/createWorkspacePolicyHook.test.ts +0 -405
- package/src/hooks/__tests__/executeHooks.test.ts +0 -1294
- package/src/hooks/__tests__/integration.test.ts +0 -337
- package/src/hooks/__tests__/matchers.test.ts +0 -238
- package/src/hooks/__tests__/preemptBoundary.test.ts +0 -152
- package/src/hooks/__tests__/toolHooks.test.ts +0 -669
- package/src/llm/__tests__/contextOverflowRecovery.test.ts +0 -401
- package/src/llm/__tests__/fallbackOverflow.test.ts +0 -287
- package/src/llm/anthropic/Jacob_Lee_Resume_2023.pdf +0 -0
- package/src/llm/anthropic/inherited-content-utils.spec.ts +0 -249
- package/src/llm/anthropic/inherited-stream-events.spec.ts +0 -1259
- package/src/llm/anthropic/inherited-strict.spec.ts +0 -302
- package/src/llm/anthropic/llm.spec.ts +0 -3394
- package/src/llm/anthropic/utils/cross-provider-reasoning.test.ts +0 -383
- package/src/llm/anthropic/utils/cross-provider-server-tools.test.ts +0 -110
- package/src/llm/anthropic/utils/server-tool-inputs.test.ts +0 -508
- package/src/llm/anthropic/utils/streaming-tool-input.test.ts +0 -361
- package/src/llm/anthropic/utils/stripPrefillCache.test.ts +0 -111
- package/src/llm/anthropic/utils/tool-id-normalization.test.ts +0 -287
- package/src/llm/bedrock/inherited-cache.spec.ts +0 -144
- package/src/llm/bedrock/inherited.spec.ts +0 -724
- package/src/llm/bedrock/llm.spec.ts +0 -1533
- package/src/llm/bedrock/streamSealDispatch.test.ts +0 -331
- package/src/llm/bedrock/toolCache.test.ts +0 -194
- package/src/llm/bedrock/utils/cross-provider-reasoning.test.ts +0 -131
- package/src/llm/bedrock/utils/cross-provider-server-tools.test.ts +0 -122
- package/src/llm/bedrock/utils/message_inputs.test.ts +0 -650
- package/src/llm/bedrock/utils/message_outputs.test.ts +0 -85
- package/src/llm/bedrock/utils/toolResultCachePoint.test.ts +0 -118
- package/src/llm/custom-chat-models.smoke.test.ts +0 -1966
- package/src/llm/google/data/gettysburg10.wav +0 -0
- package/src/llm/google/data/hotdog.jpg +0 -0
- package/src/llm/google/inherited-stream-events.spec.ts +0 -350
- package/src/llm/google/llm.spec.ts +0 -1388
- package/src/llm/google/streamSmoothing.test.ts +0 -121
- package/src/llm/google/utils/common.test.ts +0 -185
- package/src/llm/invoke.alternation.test.ts +0 -87
- package/src/llm/invoke.handoffCue.test.ts +0 -112
- package/src/llm/invoke.streamLimits.test.ts +0 -142
- package/src/llm/invoke.test.ts +0 -1198
- package/src/llm/mistral/streamSmoothing.test.ts +0 -97
- package/src/llm/openai/cacheWriteTokens.test.ts +0 -112
- package/src/llm/openai/contentBlocks.test.ts +0 -381
- package/src/llm/openai/deepseek.test.ts +0 -747
- package/src/llm/openai/inherited-deepseek.spec.ts +0 -347
- package/src/llm/openai/inherited-xai.spec.ts +0 -416
- package/src/llm/openai/llm.spec.ts +0 -1774
- package/src/llm/openai/managedRequests.test.ts +0 -182
- package/src/llm/openai/sequentialToolCallSeals.test.ts +0 -199
- package/src/llm/openai/streamMetadata.spec.ts +0 -86
- package/src/llm/openai/streamMetadataDedup.spec.ts +0 -166
- package/src/llm/openai/utils/isReasoningModel.test.ts +0 -90
- package/src/llm/openai/utils/messages.test.ts +0 -488
- package/src/llm/openrouter/reasoning.test.ts +0 -561
- package/src/llm/openrouter/toolCache.test.ts +0 -134
- package/src/llm/preempt.test.ts +0 -323
- package/src/llm/stream/chunkAdapters.test.ts +0 -202
- package/src/llm/stream/reassembly.test.ts +0 -241
- package/src/llm/stream/smoother.bench.test.ts +0 -155
- package/src/llm/stream/smoother.test.ts +0 -519
- package/src/llm/streamLimits.test.ts +0 -450
- package/src/llm/truncation.test.ts +0 -242
- package/src/llm/vertexai/fixThoughtSignatures.test.ts +0 -154
- package/src/llm/vertexai/inherited-stream-events.spec.ts +0 -271
- package/src/llm/vertexai/llm.spec.ts +0 -159
- package/src/llm/vertexai/repairUsageMetadata.test.ts +0 -54
- package/src/llm/vertexai/sealStreamedToolCalls.test.ts +0 -88
- package/src/llm/vertexai/streamSealDispatch.test.ts +0 -148
- package/src/llm/vertexai/streamSmoothing.test.ts +0 -109
- package/src/messages/__tests__/anthropicToolCache.test.ts +0 -339
- package/src/messages/__tests__/observationMasking.test.ts +0 -312
- package/src/messages/__tests__/recency.test.ts +0 -267
- package/src/messages/__tests__/tools.test.ts +0 -473
- package/src/messages/alternation.test.ts +0 -212
- package/src/messages/assistantPhase.test.ts +0 -75
- package/src/messages/cache.tail.test.ts +0 -533
- package/src/messages/cache.test.ts +0 -2166
- package/src/messages/content.test.ts +0 -362
- package/src/messages/contextPruning.test.ts +0 -184
- package/src/messages/ensureThinkingBlock.test.ts +0 -1427
- package/src/messages/foldToollessToolBlocks.test.ts +0 -596
- package/src/messages/formatAgentMessages.reducer.test.ts +0 -162
- package/src/messages/formatAgentMessages.skills.test.ts +0 -513
- package/src/messages/formatAgentMessages.steer.test.ts +0 -598
- package/src/messages/formatAgentMessages.test.ts +0 -8111
- package/src/messages/formatAgentMessages.tools.test.ts +0 -522
- package/src/messages/formatMessage.test.ts +0 -693
- package/src/messages/handoffCue.test.ts +0 -96
- package/src/messages/injected.test.ts +0 -107
- package/src/messages/labelContentByAgent.test.ts +0 -962
- package/src/messages/reducer.spec.ts +0 -32
- package/src/messages/shiftIndexTokenCountMap.test.ts +0 -81
- package/src/messages/tailCacheConversion.test.ts +0 -161
- package/src/openai/__tests__/openai.test.ts +0 -337
- package/src/responses/__tests__/responses.test.ts +0 -652
- package/src/scripts/abort.ts +0 -157
- package/src/scripts/activity-labels/captured.json +0 -56
- package/src/scripts/activity-labels/checks.cjs +0 -205
- package/src/scripts/activity-labels/corpus.cjs +0 -473
- package/src/scripts/activity-labels/report.cjs +0 -203
- package/src/scripts/activity-labels/rescore.cjs +0 -102
- package/src/scripts/activity-labels/run.ts +0 -705
- package/src/scripts/activity-labels/variants.ts +0 -71
- package/src/scripts/ant_web_search.ts +0 -159
- package/src/scripts/ant_web_search_edge_case.ts +0 -163
- package/src/scripts/ant_web_search_error_edge_case.ts +0 -149
- package/src/scripts/args.ts +0 -48
- package/src/scripts/bedrock-cache-debug.ts +0 -250
- package/src/scripts/bedrock-content-aggregation-test.ts +0 -266
- package/src/scripts/bedrock-merge-test.ts +0 -107
- package/src/scripts/bedrock-parallel-tools-test.ts +0 -204
- package/src/scripts/bench-prompt-cache.ts +0 -479
- package/src/scripts/caching.ts +0 -132
- package/src/scripts/cli.ts +0 -172
- package/src/scripts/cli2.ts +0 -133
- package/src/scripts/cli3.ts +0 -184
- package/src/scripts/cli4.ts +0 -191
- package/src/scripts/cli5.ts +0 -191
- package/src/scripts/code_exec.ts +0 -214
- package/src/scripts/code_exec_files.ts +0 -237
- package/src/scripts/code_exec_multi_session.ts +0 -237
- package/src/scripts/code_exec_ptc.ts +0 -335
- package/src/scripts/code_exec_session.ts +0 -283
- package/src/scripts/code_exec_simple.ts +0 -148
- package/src/scripts/compare_pi_vs_ours.ts +0 -1259
- package/src/scripts/content.ts +0 -139
- package/src/scripts/context-overflow-probe.ts +0 -997
- package/src/scripts/empty_input.ts +0 -137
- package/src/scripts/handoff-test.ts +0 -134
- package/src/scripts/local_engine.ts +0 -166
- package/src/scripts/local_engine_checkpointer.ts +0 -205
- package/src/scripts/local_engine_compile.ts +0 -263
- package/src/scripts/local_engine_hooks.ts +0 -226
- package/src/scripts/local_engine_image.ts +0 -201
- package/src/scripts/local_engine_ptc.ts +0 -151
- package/src/scripts/local_engine_workspace.ts +0 -258
- package/src/scripts/memory.ts +0 -107
- package/src/scripts/multi-agent-chain.ts +0 -332
- package/src/scripts/multi-agent-conditional.ts +0 -222
- package/src/scripts/multi-agent-document-review-chain.ts +0 -198
- package/src/scripts/multi-agent-hybrid-flow.ts +0 -311
- package/src/scripts/multi-agent-parallel-start.ts +0 -265
- package/src/scripts/multi-agent-parallel.ts +0 -395
- package/src/scripts/multi-agent-sequence.ts +0 -217
- package/src/scripts/multi-agent-subagent.ts +0 -246
- package/src/scripts/multi-agent-supervisor.ts +0 -366
- package/src/scripts/multi-agent-test.ts +0 -187
- package/src/scripts/openrouter_prompt_cache_live.ts +0 -310
- package/src/scripts/parallel-asymmetric-tools-test.ts +0 -275
- package/src/scripts/parallel-full-metadata-test.ts +0 -241
- package/src/scripts/parallel-tools-test.ts +0 -341
- package/src/scripts/preempt-probe.ts +0 -330
- package/src/scripts/preempt-scenarios.ts +0 -388
- package/src/scripts/programmatic_exec.ts +0 -387
- package/src/scripts/programmatic_exec_agent.ts +0 -232
- package/src/scripts/search.ts +0 -147
- package/src/scripts/sequential-full-metadata-test.ts +0 -198
- package/src/scripts/session_live.ts +0 -548
- package/src/scripts/simple.ts +0 -226
- package/src/scripts/single-agent-metadata-test.ts +0 -196
- package/src/scripts/stream.ts +0 -141
- package/src/scripts/subagent-configurable-inheritance.ts +0 -252
- package/src/scripts/subagent-event-driven-debug.ts +0 -190
- package/src/scripts/subagent-tools-debug.ts +0 -160
- package/src/scripts/subagent-usage-sink.ts +0 -176
- package/src/scripts/summarization-recency.ts +0 -462
- package/src/scripts/test-custom-prompt-key.ts +0 -145
- package/src/scripts/test-handoff-input.ts +0 -170
- package/src/scripts/test-handoff-preamble.ts +0 -278
- package/src/scripts/test-handoff-steering.ts +0 -430
- package/src/scripts/test-multi-agent-list-handoff.ts +0 -418
- package/src/scripts/test-parallel-agent-labeling.ts +0 -327
- package/src/scripts/test-parallel-handoffs.ts +0 -292
- package/src/scripts/test-thinking-handoff-bedrock.ts +0 -154
- package/src/scripts/test-thinking-handoff.ts +0 -156
- package/src/scripts/test-thinking-to-thinking-handoff-bedrock.ts +0 -166
- package/src/scripts/test-tool-before-handoff-role-order.ts +0 -276
- package/src/scripts/test-tools-before-handoff.ts +0 -222
- package/src/scripts/test_code_api.ts +0 -354
- package/src/scripts/thinking-bedrock.ts +0 -160
- package/src/scripts/thinking-vertexai.ts +0 -168
- package/src/scripts/thinking.ts +0 -172
- package/src/scripts/tool_search.ts +0 -153
- package/src/scripts/tools.ts +0 -163
- package/src/session/__tests__/JsonlSessionStore.test.ts +0 -1463
- package/src/session/__tests__/handlers.test.ts +0 -161
- package/src/specs/activity-label-observability.live.test.ts +0 -262
- package/src/specs/activity-label-observability.test.ts +0 -167
- package/src/specs/activity-label-prompt.test.ts +0 -359
- package/src/specs/activity-label-trace-seed.test.ts +0 -47
- package/src/specs/activity-phase-label.test.ts +0 -306
- package/src/specs/agent-handoffs.live.test.ts +0 -140
- package/src/specs/agent-handoffs.test.ts +0 -2465
- package/src/specs/anthropic.simple.test.ts +0 -453
- package/src/specs/ask-user-question-batch.test.ts +0 -289
- package/src/specs/ask-user-questions.live.test.ts +0 -185
- package/src/specs/ask-user-questions.test.ts +0 -293
- package/src/specs/azure.simple.test.ts +0 -502
- package/src/specs/bedrock-toolless.live.test.ts +0 -123
- package/src/specs/bedrock-truncation.live.test.ts +0 -191
- package/src/specs/cache.simple.test.ts +0 -416
- package/src/specs/context-accuracy.live.test.ts +0 -409
- package/src/specs/context-overflow-recovery.live.test.ts +0 -213
- package/src/specs/context-usage-event.test.ts +0 -117
- package/src/specs/context-usage.live.test.ts +0 -297
- package/src/specs/custom-event-await.test.ts +0 -304
- package/src/specs/deepseek.simple.test.ts +0 -290
- package/src/specs/deterministic-trace-id.test.ts +0 -43
- package/src/specs/discovered-tools.test.ts +0 -217
- package/src/specs/durability-checkpoint.integration.test.ts +0 -243
- package/src/specs/graph-subagent.live.test.ts +0 -242
- package/src/specs/graph-subagent.test.ts +0 -322
- package/src/specs/handoffCue.test.ts +0 -165
- package/src/specs/langfuse-callbacks.test.ts +0 -1578
- package/src/specs/langfuse-config.test.ts +0 -247
- package/src/specs/langfuse-instrumentation.test.ts +0 -393
- package/src/specs/langfuse-metadata.test.ts +0 -245
- package/src/specs/langfuse-routing.integration.test.ts +0 -844
- package/src/specs/langfuse-runtime-context.test.ts +0 -92
- package/src/specs/langfuse-span-registry.test.ts +0 -87
- package/src/specs/langfuse-tool-output-tracing.test.ts +0 -1858
- package/src/specs/langfuse-trace-shaping.test.ts +0 -591
- package/src/specs/moonshot.simple.test.ts +0 -367
- package/src/specs/multi-agent-summarization.test.ts +0 -396
- package/src/specs/openai.simple.test.ts +0 -315
- package/src/specs/openrouter.simple.test.ts +0 -275
- package/src/specs/preemptSeal.test.ts +0 -678
- package/src/specs/prune.test.ts +0 -3741
- package/src/specs/reasoning.test.ts +0 -201
- package/src/specs/run-step-timestamps.test.ts +0 -414
- package/src/specs/spec.utils.ts +0 -15
- package/src/specs/subagent.test.ts +0 -864
- package/src/specs/summarization-unit.test.ts +0 -973
- package/src/specs/summarization.test.ts +0 -3823
- package/src/specs/summarize-prune.test.ts +0 -376
- package/src/specs/thinking-handoff.test.ts +0 -621
- package/src/specs/thinking-prune.test.ts +0 -827
- package/src/specs/token-accounting-e2e.test.ts +0 -1034
- package/src/specs/token-accounting-pipeline.test.ts +0 -1008
- package/src/specs/token-distribution-edge-case.test.ts +0 -315
- package/src/specs/token-memoization.test.ts +0 -40
- package/src/specs/tokens.test.ts +0 -1000
- package/src/specs/tool-error-resume.test.ts +0 -194
- package/src/specs/tool-error.test.ts +0 -198
- package/src/specs/vllm-reasoning-toolcalls.test.ts +0 -340
- package/src/stream.dispatch.test.ts +0 -63
- package/src/stream.test.ts +0 -144
- package/src/summarization/__tests__/aggregator.test.ts +0 -236
- package/src/summarization/__tests__/node.test.ts +0 -1996
- package/src/summarization/__tests__/trigger.test.ts +0 -149
- package/src/summarization/chunkHandler.test.ts +0 -196
- package/src/test/mockTools.ts +0 -386
- package/src/tools/Calculator.test.ts +0 -278
- package/src/tools/__tests__/BashExecutor.test.ts +0 -108
- package/src/tools/__tests__/CloudflareSandboxExecution.test.ts +0 -939
- package/src/tools/__tests__/CodeApiAuthHeaders.test.ts +0 -858
- package/src/tools/__tests__/CodeExecutor.stateful.test.ts +0 -124
- package/src/tools/__tests__/LocalExecutionRoots.test.ts +0 -8
- package/src/tools/__tests__/LocalExecutionTools.test.ts +0 -2733
- package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.ts +0 -318
- package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +0 -1557
- package/src/tools/__tests__/ReadFile.test.ts +0 -44
- package/src/tools/__tests__/SkillTool.test.ts +0 -442
- package/src/tools/__tests__/SubagentExecutor.test.ts +0 -3728
- package/src/tools/__tests__/SubagentReplay.test.ts +0 -329
- package/src/tools/__tests__/SubagentTool.test.ts +0 -149
- package/src/tools/__tests__/ToolNode.breakerSignal.test.ts +0 -595
- package/src/tools/__tests__/ToolNode.eagerEventExecution.test.ts +0 -1191
- package/src/tools/__tests__/ToolNode.invalidToolCalls.test.ts +0 -757
- package/src/tools/__tests__/ToolNode.langfuse.test.ts +0 -57
- package/src/tools/__tests__/ToolNode.onResultCompletion.test.ts +0 -736
- package/src/tools/__tests__/ToolNode.outputReferences.test.ts +0 -1710
- package/src/tools/__tests__/ToolNode.runtimeState.test.ts +0 -120
- package/src/tools/__tests__/ToolNode.session.test.ts +0 -1352
- package/src/tools/__tests__/ToolNode.streamLimits.test.ts +0 -69
- package/src/tools/__tests__/ToolSearch.integration.test.ts +0 -161
- package/src/tools/__tests__/ToolSearch.test.ts +0 -1227
- package/src/tools/__tests__/annotateMessagesForLLM.test.ts +0 -561
- package/src/tools/__tests__/directToolHITLResumeScope.test.ts +0 -980
- package/src/tools/__tests__/directToolHooks.test.ts +0 -700
- package/src/tools/__tests__/eagerEventExecution.session.test.ts +0 -92
- package/src/tools/__tests__/handlers.test.ts +0 -997
- package/src/tools/__tests__/hitl.test.ts +0 -4663
- package/src/tools/__tests__/intentArg.test.ts +0 -357
- package/src/tools/__tests__/intentCoverage.test.ts +0 -139
- package/src/tools/__tests__/localToolNames.test.ts +0 -75
- package/src/tools/__tests__/skillCatalog.test.ts +0 -161
- package/src/tools/__tests__/subagentHooks.test.ts +0 -1651
- package/src/tools/__tests__/toolOutputReferences.test.ts +0 -515
- package/src/tools/__tests__/workspaceSeam.test.ts +0 -147
- package/src/tools/local/__tests__/FileCheckpointer.test.ts +0 -162
- package/src/tools/local/__tests__/editStrategies.test.ts +0 -134
- package/src/tools/search/content.test.ts +0 -173
- package/src/tools/search/crw.test.ts +0 -836
- package/src/tools/search/format.test.ts +0 -242
- package/src/tools/search/http-agent.test.ts +0 -133
- package/src/tools/search/jina-reranker.test.ts +0 -306
- package/src/tools/search/keenable-scraper.test.ts +0 -153
- package/src/tools/search/keenable.test.ts +0 -183
- package/src/tools/search/outcome.test.ts +0 -90
- package/src/tools/search/output.md +0 -2775
- package/src/tools/search/rag-api-reranker.test.ts +0 -891
- package/src/tools/search/source-processing.test.ts +0 -516
- package/src/tools/search/tavily.test.ts +0 -965
- package/src/tools/search/test.html +0 -884
- package/src/tools/search/test.md +0 -643
- package/src/tools/subagent/__tests__/SubagentExecutionRegistry.test.ts +0 -637
- package/src/tools/subagent/__tests__/SubagentExecutor.lazy.test.ts +0 -3054
- package/src/tools/subagent/__tests__/childGraphConfig.test.ts +0 -521
- package/src/utils/__tests__/apportion.test.ts +0 -32
- package/src/utils/__tests__/errors.test.ts +0 -270
- package/src/utils/__tests__/fixtures/contextOverflowSignatures.ts +0 -336
- package/src/utils/__tests__/redactSecrets.test.ts +0 -56
- package/src/utils/__tests__/truncation.test.ts +0 -66
- package/src/utils/llm.test.ts +0 -18
- package/src/utils/proxy.test.ts +0 -176
- package/src/utils/toolContent.test.ts +0 -1432
package/dist/esm/run.mjs
CHANGED
|
@@ -70,11 +70,6 @@ function getStepScopedEventId(data) {
|
|
|
70
70
|
const candidate = data;
|
|
71
71
|
return typeof candidate.id === "string" ? candidate.id : void 0;
|
|
72
72
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Narrows an ON_RUN_STEP_COMPLETED payload (`{ result: ToolCompleteEvent }`)
|
|
75
|
-
* to the ids step closure needs. Returns undefined for malformed payloads and
|
|
76
|
-
* the resume race's empty step id.
|
|
77
|
-
*/
|
|
78
73
|
function getToolCompletion(data) {
|
|
79
74
|
if (data == null || typeof data !== "object") return;
|
|
80
75
|
const { result } = data;
|
|
@@ -138,29 +133,12 @@ var Run = class Run {
|
|
|
138
133
|
Graph;
|
|
139
134
|
returnContent = false;
|
|
140
135
|
skipCleanup = false;
|
|
141
|
-
/**
|
|
142
|
-
* Whether the compiled graph was built with a checkpointer (host-supplied
|
|
143
|
-
* or the HITL `MemorySaver` fallback). Captured at graph creation because
|
|
144
|
-
* the constructor can later overwrite `Graph.compileOptions` with the raw
|
|
145
|
-
* caller options, dropping the fallback checkpointer from that metadata.
|
|
146
|
-
*/
|
|
147
136
|
hasCheckpointer = false;
|
|
148
137
|
_streamResult;
|
|
149
|
-
/**
|
|
150
|
-
* Captured interrupt payload typed as `unknown` because the SDK
|
|
151
|
-
* does not validate the runtime shape — custom graph nodes can
|
|
152
|
-
* raise interrupts with arbitrary payloads (not just the SDK's
|
|
153
|
-
* `HumanInterruptPayload` union). The public `getInterrupt<T>()`
|
|
154
|
-
* lets callers assert the type they expect.
|
|
155
|
-
*/
|
|
156
138
|
_interrupt;
|
|
157
|
-
/** Per-run sequence for batch-unique activity-label trace-seed fallbacks. */
|
|
158
139
|
activityLabelSeq = 0;
|
|
159
|
-
/** Per-run sequence for parent activity-phase trace and invocation ids. */
|
|
160
140
|
activityPhaseLabelSeq = 0;
|
|
161
|
-
/** Latest user turn used to keep detached phase roots conversation-shaped. */
|
|
162
141
|
activityPhaseTraceInput;
|
|
163
|
-
/** Distinguishes sibling forks started from the same explicit checkpoint. */
|
|
164
142
|
checkpointForkSeq = 0;
|
|
165
143
|
_haltedReason;
|
|
166
144
|
constructor(config) {
|
|
@@ -185,12 +163,10 @@ var Run = class Run {
|
|
|
185
163
|
this.preemption = config.preemption;
|
|
186
164
|
this.streamLimits = config.streamLimits;
|
|
187
165
|
if (!config.graphConfig) throw new Error("Graph config not provided");
|
|
188
|
-
/** Handle different graph types */
|
|
189
166
|
if (config.graphConfig.type === "multi-agent") {
|
|
190
167
|
this.graphRunnable = this.createMultiAgentGraph(config.graphConfig);
|
|
191
168
|
if (this.Graph) this.Graph.handlerRegistry = handlerRegistry;
|
|
192
169
|
} else {
|
|
193
|
-
/** Default to legacy graph for 'standard' or undefined type */
|
|
194
170
|
this.graphRunnable = this.createLegacyGraph(config.graphConfig);
|
|
195
171
|
if (this.Graph) this.Graph.handlerRegistry = handlerRegistry;
|
|
196
172
|
}
|
|
@@ -201,13 +177,11 @@ var Run = class Run {
|
|
|
201
177
|
createLegacyGraph(config) {
|
|
202
178
|
let agentConfig;
|
|
203
179
|
let signal;
|
|
204
|
-
/** Check if this is a multi-agent style config (has agents array) */
|
|
205
180
|
if ("agents" in config && Array.isArray(config.agents)) {
|
|
206
181
|
if (config.agents.length === 0) throw new Error("At least one agent must be provided");
|
|
207
182
|
agentConfig = config.agents[0];
|
|
208
183
|
signal = config.signal;
|
|
209
184
|
} else {
|
|
210
|
-
/** Legacy path: build agent config from llmConfig */
|
|
211
185
|
const { type: _type, llmConfig, signal: legacySignal, tools = [], ...agentInputs } = config;
|
|
212
186
|
const { provider, ...clientOptions } = llmConfig;
|
|
213
187
|
agentConfig = {
|
|
@@ -234,7 +208,6 @@ var Run = class Run {
|
|
|
234
208
|
streamLimits: this.streamLimits
|
|
235
209
|
}
|
|
236
210
|
});
|
|
237
|
-
/** Propagate compile options from graph config */
|
|
238
211
|
standardGraph.compileOptions = this.applyHITLCheckpointerFallback(config.compileOptions);
|
|
239
212
|
this.hasCheckpointer = standardGraph.compileOptions?.checkpointer != null;
|
|
240
213
|
applyGraphRuntimeConfig(standardGraph, {
|
|
@@ -280,20 +253,6 @@ var Run = class Run {
|
|
|
280
253
|
this.Graph = multiAgentGraph;
|
|
281
254
|
return multiAgentGraph.createWorkflow();
|
|
282
255
|
}
|
|
283
|
-
/**
|
|
284
|
-
* When the host opted into HITL via `humanInTheLoop: { enabled: true }`
|
|
285
|
-
* and did not supply a checkpointer, install an in-memory `MemorySaver`
|
|
286
|
-
* so `interrupt()` can persist checkpoints and `Command({ resume })`
|
|
287
|
-
* can rebuild state. The fallback is intentionally process-local:
|
|
288
|
-
* production hosts that need durable resumption across processes /
|
|
289
|
-
* restarts must provide their own checkpointer (Redis, Postgres, etc.)
|
|
290
|
-
* on `compileOptions.checkpointer`.
|
|
291
|
-
*
|
|
292
|
-
* No-op when HITL is off (the default — omitted, or
|
|
293
|
-
* `{ enabled: false }`) or the host already supplied a checkpointer
|
|
294
|
-
* of their own. See `HumanInTheLoopConfig` JSDoc for the rationale
|
|
295
|
-
* behind the default-off stance.
|
|
296
|
-
*/
|
|
297
256
|
applyHITLCheckpointerFallback(compileOptions) {
|
|
298
257
|
if (this.humanInTheLoop?.enabled !== true) return compileOptions;
|
|
299
258
|
if (compileOptions?.checkpointer != null) return compileOptions;
|
|
@@ -302,50 +261,8 @@ var Run = class Run {
|
|
|
302
261
|
checkpointer: new MemorySaver()
|
|
303
262
|
};
|
|
304
263
|
}
|
|
305
|
-
/**
|
|
306
|
-
* Run RunStart + UserPromptSubmit hooks before the graph stream
|
|
307
|
-
* begins, accumulate any `additionalContext` strings into the input
|
|
308
|
-
* messages, and short-circuit when a hook signals the run should not
|
|
309
|
-
* proceed (deny / ask decision on the prompt, or `preventContinuation`
|
|
310
|
-
* on either hook).
|
|
311
|
-
*
|
|
312
|
-
* Returns `true` when the caller should bail with `undefined` (run
|
|
313
|
-
* was halted before any model call); returns `false` to proceed
|
|
314
|
-
* into the stream loop.
|
|
315
|
-
*
|
|
316
|
-
* ## Side effects
|
|
317
|
-
*
|
|
318
|
-
* On the success path:
|
|
319
|
-
* - Mutates `stateInputs.messages` in place to append a
|
|
320
|
-
* consolidated `HumanMessage` carrying any hook
|
|
321
|
-
* `additionalContext` strings. Safe because the host owns the
|
|
322
|
-
* array and `processStream` is the only consumer until LangGraph
|
|
323
|
-
* reads it.
|
|
324
|
-
*
|
|
325
|
-
* On the halt path (returning `true`):
|
|
326
|
-
* - Sets `this._haltedReason` so callers (and the eventual host)
|
|
327
|
-
* can distinguish a hook-driven halt from a natural completion.
|
|
328
|
-
* - Calls `registry.clearSession(this.id)` and
|
|
329
|
-
* `registry.clearHaltSignal(this.id)` because no resume is
|
|
330
|
-
* expected from a pre-stream halt — the run never entered the
|
|
331
|
-
* graph, so the session/halt state for this run would otherwise
|
|
332
|
-
* leak to the next `processStream` invocation on the same
|
|
333
|
-
* registry. Other concurrent runs on the same registry are
|
|
334
|
-
* untouched (halt signals are scoped per session id).
|
|
335
|
-
* - Sets `config.callbacks = undefined` to drop the callback
|
|
336
|
-
* references the caller built (langfuse handler, custom event
|
|
337
|
-
* handler, etc.) since they won't be exercised. Mirrors the
|
|
338
|
-
* equivalent cleanup the `processStream` `finally` block does
|
|
339
|
-
* on the natural-completion path.
|
|
340
|
-
*/
|
|
341
264
|
async runPreStreamHooks(stateInputs, threadId, config) {
|
|
342
265
|
const registry = this.hookRegistry;
|
|
343
|
-
/**
|
|
344
|
-
* Defensive guard: `processStream` already validated `this.Graph`
|
|
345
|
-
* before calling this helper, but TypeScript can't propagate that
|
|
346
|
-
* narrowing across method boundaries. The check keeps the body
|
|
347
|
-
* free of `this.Graph!` non-null assertions.
|
|
348
|
-
*/
|
|
349
266
|
if (registry == null || this.Graph == null) return false;
|
|
350
267
|
const preStreamContexts = [];
|
|
351
268
|
const runStartResult = await executeHooks({
|
|
@@ -360,13 +277,6 @@ var Run = class Run {
|
|
|
360
277
|
sessionId: this.id
|
|
361
278
|
});
|
|
362
279
|
for (const ctx of runStartResult.additionalContexts) preStreamContexts.push(ctx);
|
|
363
|
-
/**
|
|
364
|
-
* Honor `preventContinuation` from RunStart before the stream
|
|
365
|
-
* starts. Mid-flight halts (from tool/compact/subagent hooks)
|
|
366
|
-
* route through `HookRegistry.haltRun` and are polled by the
|
|
367
|
-
* stream loop in `processStream` — different mechanism, same
|
|
368
|
-
* intent.
|
|
369
|
-
*/
|
|
370
280
|
if (runStartResult.preventContinuation === true) {
|
|
371
281
|
this._haltedReason = runStartResult.stopReason ?? "preventContinuation";
|
|
372
282
|
registry.clearSession(this.id);
|
|
@@ -388,13 +298,6 @@ var Run = class Run {
|
|
|
388
298
|
sessionId: this.id
|
|
389
299
|
});
|
|
390
300
|
if (promptResult.decision === "deny" || promptResult.decision === "ask" || promptResult.preventContinuation === true) {
|
|
391
|
-
/**
|
|
392
|
-
* Always set `_haltedReason` so the host can call
|
|
393
|
-
* `getHaltReason()` and distinguish a hook-blocked prompt
|
|
394
|
-
* from a natural empty-output completion. Three signals can
|
|
395
|
-
* land here, each with its own canonical reason string when
|
|
396
|
-
* the hook didn't supply one.
|
|
397
|
-
*/
|
|
398
301
|
if (promptResult.preventContinuation === true) this._haltedReason = promptResult.stopReason ?? "preventContinuation";
|
|
399
302
|
else if (promptResult.decision === "deny") this._haltedReason = promptResult.reason ?? "prompt_denied";
|
|
400
303
|
else this._haltedReason = promptResult.reason ?? "prompt_requires_approval";
|
|
@@ -405,20 +308,7 @@ var Run = class Run {
|
|
|
405
308
|
}
|
|
406
309
|
for (const ctx of promptResult.additionalContexts) preStreamContexts.push(ctx);
|
|
407
310
|
}
|
|
408
|
-
if (preStreamContexts.length > 0)
|
|
409
|
-
/**
|
|
410
|
-
* Wraps the joined hook contexts as a `HumanMessage` even though
|
|
411
|
-
* the intent is system-level guidance. Using a `SystemMessage`
|
|
412
|
-
* mid-conversation is rejected by Anthropic and Google providers
|
|
413
|
-
* (system messages must be the leading entry), so the LangChain
|
|
414
|
-
* convention — also used by `ToolNode.convertInjectedMessages`
|
|
415
|
-
* — is `HumanMessage` carrying `additional_kwargs.role` as a
|
|
416
|
-
* marker for hosts inspecting state. The model still sees a
|
|
417
|
-
* user-role message; the `role: 'system'` field is metadata
|
|
418
|
-
* only. Hosts that want a true system message should compose
|
|
419
|
-
* it into the agent's `instructions` config instead.
|
|
420
|
-
*/
|
|
421
|
-
stateInputs.messages.push(new HumanMessage({
|
|
311
|
+
if (preStreamContexts.length > 0) stateInputs.messages.push(new HumanMessage({
|
|
422
312
|
content: preStreamContexts.join("\n\n"),
|
|
423
313
|
additional_kwargs: {
|
|
424
314
|
role: "system",
|
|
@@ -428,7 +318,6 @@ var Run = class Run {
|
|
|
428
318
|
return false;
|
|
429
319
|
}
|
|
430
320
|
static async create(config) {
|
|
431
|
-
/** Create tokenCounter if indexTokenCountMap is provided but tokenCounter is not */
|
|
432
321
|
if (config.indexTokenCountMap && !config.tokenCounter) {
|
|
433
322
|
const gc = config.graphConfig;
|
|
434
323
|
config.tokenCounter = await createTokenCounter(encodingForModel(("agents" in gc ? gc.agents[0]?.clientOptions : gc.clientOptions)?.model ?? ""));
|
|
@@ -442,33 +331,16 @@ var Run = class Run {
|
|
|
442
331
|
getChildCheckpointThreadIds() {
|
|
443
332
|
return this.Graph?.getChildCheckpointThreadIds() ?? [];
|
|
444
333
|
}
|
|
445
|
-
/**
|
|
446
|
-
* Returns a defensive snapshot of tools discovered by the current run.
|
|
447
|
-
* Pass an agent id for that context, or omit it for the ordered union across
|
|
448
|
-
* contexts. Interrupted state is available immediately for host persistence;
|
|
449
|
-
* completed runs retain their final snapshot through graph cleanup.
|
|
450
|
-
*/
|
|
451
334
|
getDiscoveredTools(agentId) {
|
|
452
335
|
if (!this.Graph) throw new Error("Graph not initialized. Make sure to use Run.create() to instantiate the Run.");
|
|
453
336
|
return this.Graph.getDiscoveredTools(agentId);
|
|
454
337
|
}
|
|
455
|
-
/**
|
|
456
|
-
* Returns the current calibration ratio (EMA of provider-vs-estimate token ratios).
|
|
457
|
-
* Hosts should persist this value and pass it back as `RunConfig.calibrationRatio`
|
|
458
|
-
* on the next run for the same conversation so the pruner starts with an accurate
|
|
459
|
-
* scaling factor instead of the default (1).
|
|
460
|
-
*/
|
|
461
338
|
getCalibrationRatio() {
|
|
462
339
|
return this.calibrationRatio;
|
|
463
340
|
}
|
|
464
341
|
getResolvedInstructionOverhead() {
|
|
465
342
|
return this.Graph?.getResolvedInstructionOverhead();
|
|
466
343
|
}
|
|
467
|
-
/**
|
|
468
|
-
* Cooperative-seal counters for this run. `emptyBoundaries` is the one to
|
|
469
|
-
* watch: it counts seals whose `PreemptBoundary` produced nothing to
|
|
470
|
-
* inject, which ends the turn early and leaves the answer unfinished.
|
|
471
|
-
*/
|
|
472
344
|
getPreemptStats() {
|
|
473
345
|
return this.Graph?.getPreemptStats() ?? {
|
|
474
346
|
seals: 0,
|
|
@@ -478,35 +350,17 @@ var Run = class Run {
|
|
|
478
350
|
getToolCount() {
|
|
479
351
|
return this.Graph?.getToolCount() ?? 0;
|
|
480
352
|
}
|
|
481
|
-
/**
|
|
482
|
-
* Creates a custom event callback handler that intercepts custom events
|
|
483
|
-
* and processes them through our handler registry instead of EventStreamCallbackHandler
|
|
484
|
-
*/
|
|
485
353
|
createCustomEventCallback() {
|
|
486
354
|
return async (eventName, data, runId, tags, metadata) => {
|
|
487
355
|
const stepScopedEventId = getStepScopedEventId(data);
|
|
488
356
|
if (DIRECT_DISPATCHED_STEP_EVENTS.has(eventName) && this.Graph != null && stepScopedEventId != null && this.Graph.hasHandlerDispatchedEvent(eventName, stepScopedEventId)) return;
|
|
489
357
|
const handler = this.handlerRegistry?.getHandler(eventName);
|
|
490
|
-
/**
|
|
491
|
-
* Tool completions arriving over the custom-event channel are the only
|
|
492
|
-
* signal ToolNode (which holds no graph reference) emits — observe them
|
|
493
|
-
* here to drive step closure. Runs in `finally`, independent of handler
|
|
494
|
-
* registration, so an absent or throwing host handler cannot lose the
|
|
495
|
-
* close; duplicate callback echoes are absorbed by the terminal-status
|
|
496
|
-
* guard in `closeRunStep`.
|
|
497
|
-
*/
|
|
498
358
|
try {
|
|
499
359
|
if (handler && this.Graph) return await handler.handle(eventName, data, metadata, this.Graph);
|
|
500
360
|
} finally {
|
|
501
361
|
if (eventName === "on_run_step_completed" && this.Graph != null) {
|
|
502
362
|
const completion = getToolCompletion(data);
|
|
503
|
-
if (completion != null)
|
|
504
|
-
/**
|
|
505
|
-
* The producer stamped `completed_at` before dispatch. Carrying it
|
|
506
|
-
* through keeps the recorded duration the tool's, not the host
|
|
507
|
-
* handler's — this runs after an arbitrarily slow handler resolves.
|
|
508
|
-
*/
|
|
509
|
-
await this.Graph.recordStepCompletion(completion.stepId, {
|
|
363
|
+
if (completion != null) await this.Graph.recordStepCompletion(completion.stepId, {
|
|
510
364
|
toolCallId: completion.toolCallId,
|
|
511
365
|
metadata,
|
|
512
366
|
at: completion.completedAt
|
|
@@ -521,13 +375,6 @@ var Run = class Run {
|
|
|
521
375
|
isAwaitingResume(streamThrew) {
|
|
522
376
|
return this._interrupt != null && this._haltedReason == null && !streamThrew;
|
|
523
377
|
}
|
|
524
|
-
/**
|
|
525
|
-
* Terminal status for steps still open at end-of-run: `cancelled` for
|
|
526
|
-
* intentional stops (caller abort, hook halt), `failed` for unexpected
|
|
527
|
-
* stream errors, `completed` for a natural finish. Reads `_haltedReason`
|
|
528
|
-
* behind a method boundary on purpose — it is assigned inside the
|
|
529
|
-
* `consumeStream` closure, which control-flow narrowing cannot see.
|
|
530
|
-
*/
|
|
531
378
|
resolveSweepStatus(streamThrew, streamAborted) {
|
|
532
379
|
if (streamThrew) return streamAborted ? "cancelled" : "failed";
|
|
533
380
|
if (this._haltedReason != null) return "cancelled";
|
|
@@ -574,24 +421,9 @@ var Run = class Run {
|
|
|
574
421
|
if (!this.Graph) throw new Error("Graph not initialized. Make sure to use Run.create() to instantiate the Run.");
|
|
575
422
|
const graphRunnable = this.graphRunnable;
|
|
576
423
|
const graph = this.Graph;
|
|
577
|
-
/**
|
|
578
|
-
* `Command` inputs (`Command({ resume, update?, goto? })`) are
|
|
579
|
-
* resume-mode invocations: LangGraph rebuilds graph state from the
|
|
580
|
-
* checkpointer, so we skip RunStart / UserPromptSubmit hooks (no
|
|
581
|
-
* new prompt to evaluate) and read run-state from the Graph wrapper
|
|
582
|
-
* instead of `inputs.messages`.
|
|
583
|
-
*/
|
|
584
424
|
const isResume = inputs instanceof Command;
|
|
585
425
|
const stateInputs = isResume ? void 0 : inputs;
|
|
586
426
|
if (stateInputs != null) this.activityPhaseTraceInput = findActivityPhaseTraceInput(stateInputs.messages);
|
|
587
|
-
/**
|
|
588
|
-
* Every honored seal costs one extra superstep, so a preemption-enabled
|
|
589
|
-
* run reserves headroom for its whole seal budget. Without it, a
|
|
590
|
-
* tool-heavy agent that gets preempted could hit `GraphRecursionError` —
|
|
591
|
-
* which surfaces as a thrown stream, setting `streamThrew`, firing
|
|
592
|
-
* `StopFailure`, and wiping via `clearHeavyState()` exactly the partial
|
|
593
|
-
* content the seal existed to preserve.
|
|
594
|
-
*/
|
|
595
427
|
const recursionLimit = (callerConfig.recursionLimit ?? 50) + (this.preemption != null ? resolveMaxSeals(this.preemption.maxSeals) : 0);
|
|
596
428
|
const config = {
|
|
597
429
|
...callerConfig,
|
|
@@ -602,30 +434,7 @@ var Run = class Run {
|
|
|
602
434
|
delete config.configurable?.[SUBAGENT_RESUME_ATTEMPT_CONFIG_KEY];
|
|
603
435
|
delete config.configurable?.[SUBAGENT_RESUME_MANIFEST_CONFIG_KEY];
|
|
604
436
|
}
|
|
605
|
-
/**
|
|
606
|
-
* Cancellation can arrive either at graph construction or per-call through
|
|
607
|
-
* `callerConfig.signal`, and boundary hooks need to observe both — for a
|
|
608
|
-
* multi-agent run the construction signal does not exist at all, since
|
|
609
|
-
* `MultiAgentGraphConfig` exposes none. Carried on its own field, assigned
|
|
610
|
-
* unconditionally: writing into `graph.signal` would leak this call's
|
|
611
|
-
* controller into later calls (model-call config and subagent
|
|
612
|
-
* parentSignal read that field, and `clearHeavyState()` is skipped on
|
|
613
|
-
* HITL interrupts), while a conditional write would keep observing a
|
|
614
|
-
* stale controller the host has since aborted. The boundary dispatch
|
|
615
|
-
* composes both channels; see `dispatchPreemptBoundary`.
|
|
616
|
-
*/
|
|
617
437
|
graph.callerSignal = callerConfig.signal;
|
|
618
|
-
/**
|
|
619
|
-
* Skip `resetValues` on resume — we're continuing an in-flight
|
|
620
|
-
* run, not starting a fresh one. Resetting would wipe the
|
|
621
|
-
* sidecars (`toolCallStepIds`, `stepKeyIds`, accumulated
|
|
622
|
-
* `messages`, etc.) the resumed `ToolNode` needs to dispatch
|
|
623
|
-
* tool completions with the correct step ids and re-resolve
|
|
624
|
-
* `{{tool<i>turn<n>}}` references. Pairs with the
|
|
625
|
-
* `awaitingResume` gate on `clearHeavyState` in the `finally`
|
|
626
|
-
* block so the sidecars survive both ends of the interrupt
|
|
627
|
-
* boundary.
|
|
628
|
-
*/
|
|
629
438
|
if (!isResume) {
|
|
630
439
|
const checkpointThreadId = typeof config.configurable?.thread_id === "string" ? config.configurable.thread_id : void 0;
|
|
631
440
|
const checkpointNamespace = typeof config.configurable?.checkpoint_ns === "string" ? config.configurable.checkpoint_ns : "";
|
|
@@ -641,7 +450,6 @@ var Run = class Run {
|
|
|
641
450
|
this._interrupt = void 0;
|
|
642
451
|
this._haltedReason = void 0;
|
|
643
452
|
this.hookRegistry?.clearHaltSignal(this.id);
|
|
644
|
-
/** Custom event callback to intercept and handle custom events */
|
|
645
453
|
const customEventCallback = this.createCustomEventCallback();
|
|
646
454
|
const streamCallbacks = streamOptions?.callbacks ? this.getCallbacks(streamOptions.callbacks) : void 0;
|
|
647
455
|
const customHandler = BaseCallbackHandler.fromMethods({ ["handleCustomEvent"]: customEventCallback });
|
|
@@ -683,84 +491,27 @@ var Run = class Run {
|
|
|
683
491
|
if (!this.id) throw new Error("Run ID not provided");
|
|
684
492
|
config.run_id = this.id;
|
|
685
493
|
config.configurable = Object.assign(config.configurable ?? {}, { run_id: this.id });
|
|
686
|
-
/**
|
|
687
|
-
* Default `durability: 'exit'` whenever a checkpointer is active so
|
|
688
|
-
* runs skip per-superstep checkpoint writes and persist only at the
|
|
689
|
-
* exit/interrupt boundary (all HITL/resume needs). An explicit caller
|
|
690
|
-
* value wins; no checkpointer leaves it unset (langgraph default).
|
|
691
|
-
*/
|
|
692
494
|
if (config.durability == null && this.hasCheckpointer) config.durability = "exit";
|
|
693
495
|
const threadId = config.configurable.thread_id;
|
|
694
496
|
if (this.hookRegistry != null && stateInputs != null) {
|
|
695
497
|
if (await this.runPreStreamHooks(stateInputs, threadId, config)) return;
|
|
696
498
|
}
|
|
697
|
-
/**
|
|
698
|
-
* Tracks whether the stream loop threw. Used by the `finally`
|
|
699
|
-
* block to decide whether to honor the interrupt-preservation
|
|
700
|
-
* guard for session hooks: a captured `_interrupt` is only
|
|
701
|
-
* meaningful if the stream completed cleanly. If the loop errored
|
|
702
|
-
* after stashing an interrupt (e.g. a downstream handler throws
|
|
703
|
-
* after the interrupt event landed), the interrupt is stale —
|
|
704
|
-
* preserving session hooks would leak them into the next run.
|
|
705
|
-
*/
|
|
706
499
|
let streamThrew = false;
|
|
707
500
|
let streamAborted = false;
|
|
708
|
-
/**
|
|
709
|
-
* When the stream itself ended — captured before the post-stream work in
|
|
710
|
-
* the `finally` (Stop/StopFailure hooks, Langfuse disposal, which can
|
|
711
|
-
* force-flush) so a slow hook cannot inflate the terminal stamps that the
|
|
712
|
-
* sweep writes onto steps that were still open.
|
|
713
|
-
*/
|
|
714
501
|
let terminalAt;
|
|
715
502
|
const consumeStream = async () => {
|
|
716
|
-
/**
|
|
717
|
-
* `streamEvents` accepts both state inputs and `Command` (resume) at
|
|
718
|
-
* runtime, but our `CompiledStateWorkflow` type narrows the first
|
|
719
|
-
* arg to `BaseGraphState`. Cast on the call so the resume path
|
|
720
|
-
* type-checks without widening the wrapper for every caller.
|
|
721
|
-
*/
|
|
722
503
|
const stream = graphRunnable.streamEvents(inputs, config, {
|
|
723
504
|
raiseError: true,
|
|
724
|
-
/**
|
|
725
|
-
* Prevent EventStreamCallbackHandler from processing custom events.
|
|
726
|
-
* Custom events are already handled via our createCustomEventCallback()
|
|
727
|
-
* which routes them through the handlerRegistry.
|
|
728
|
-
* Without this flag, EventStreamCallbackHandler throws errors when
|
|
729
|
-
* custom events are dispatched for run IDs not in its internal map
|
|
730
|
-
* (due to timing issues in parallel execution or after run cleanup).
|
|
731
|
-
*/
|
|
732
505
|
ignoreCustomEvent: true
|
|
733
506
|
});
|
|
734
507
|
for await (const event of stream) {
|
|
735
508
|
const { data, metadata, ...info } = event;
|
|
736
509
|
const eventName = info.event;
|
|
737
|
-
/** Skip custom events as they're handled by our callback */
|
|
738
510
|
if (CUSTOM_GRAPH_EVENTS.has(eventName)) continue;
|
|
739
|
-
/**
|
|
740
|
-
* Detect interrupts surfaced by LangGraph as a synthetic
|
|
741
|
-
* `__interrupt__` field on the streamed chunk and stash the
|
|
742
|
-
* first one for the host to read via `run.getInterrupt()`
|
|
743
|
-
* once the stream drains. Captured as `unknown` because the
|
|
744
|
-
* SDK does not validate the runtime payload shape — the
|
|
745
|
-
* built-in ToolNode raises a `HumanInterruptPayload`
|
|
746
|
-
* (`tool_approval` / `ask_user_question`), but custom nodes
|
|
747
|
-
* can pass any payload to `interrupt()`. Callers narrow with
|
|
748
|
-
* the `isToolApprovalInterrupt` / `isAskUserQuestionInterrupt`
|
|
749
|
-
* guards or assert via `getInterrupt<T>()`.
|
|
750
|
-
*/
|
|
751
511
|
if (this._interrupt == null && data.chunk != null && isInterrupted(data.chunk)) {
|
|
752
512
|
const interrupts = data.chunk[INTERRUPT];
|
|
753
513
|
if (interrupts.length > 0) {
|
|
754
514
|
const first = interrupts[0];
|
|
755
|
-
/**
|
|
756
|
-
* Capture the interrupt unconditionally — `interrupt(null)`
|
|
757
|
-
* and `interrupt(undefined)` are valid pauses (a custom
|
|
758
|
-
* node may want to pause without metadata) and the host
|
|
759
|
-
* still needs to know the run is awaiting resume. Gating
|
|
760
|
-
* on `payload != null` would silently downgrade a paused
|
|
761
|
-
* run to "completed" and let the `Stop` hook fire,
|
|
762
|
-
* breaking host resume handling.
|
|
763
|
-
*/
|
|
764
515
|
this._interrupt = {
|
|
765
516
|
interruptId: first.id ?? "",
|
|
766
517
|
threadId,
|
|
@@ -768,42 +519,10 @@ var Run = class Run {
|
|
|
768
519
|
};
|
|
769
520
|
}
|
|
770
521
|
}
|
|
771
|
-
/**
|
|
772
|
-
* Stamped before the handler runs: the close below happens after an
|
|
773
|
-
* arbitrarily slow host handler resolves, and the step's duration
|
|
774
|
-
* should end when the model did, not when the host finished with it.
|
|
775
|
-
*/
|
|
776
522
|
const modelEndAt = eventName === "on_chat_model_end" ? Date.now() : void 0;
|
|
777
523
|
const handler = this.handlerRegistry?.getHandler(eventName);
|
|
778
524
|
if (handler) await handler.handle(eventName, data, metadata, this.Graph);
|
|
779
|
-
/**
|
|
780
|
-
* A finished model call ends its lane's open message step. Placed
|
|
781
|
-
* here — not in `ModelEndHandler` — because hosts replace the
|
|
782
|
-
* CHAT_MODEL_END handler with their own instance, which would
|
|
783
|
-
* silently drop the close.
|
|
784
|
-
*/
|
|
785
525
|
if (eventName === "on_chat_model_end" && this.Graph != null) await this.Graph.closeOpenMessageStep(metadata, modelEndAt);
|
|
786
|
-
/**
|
|
787
|
-
* Mid-flight halt: any hook (PreToolUse, PostToolUse,
|
|
788
|
-
* PostToolBatch, SubagentStart/Stop, PreCompact, PostCompact)
|
|
789
|
-
* that returned `preventContinuation: true` raises a halt
|
|
790
|
-
* signal on the registry via `executeHooks`. We poll between
|
|
791
|
-
* stream events and break out as soon as one is set so the
|
|
792
|
-
* graph doesn't take another model turn after the halting
|
|
793
|
-
* operation completes.
|
|
794
|
-
*
|
|
795
|
-
* This `break` is NOT graceful, despite what a `continue: false`
|
|
796
|
-
* reading suggests. Leaving the `for await` calls the iterator's
|
|
797
|
-
* `return()`, which cancels the reader
|
|
798
|
-
* (`@langchain/core/utils/stream`), and langgraph's stream wrapper
|
|
799
|
-
* turns that cancel into `_abortController.abort()`
|
|
800
|
-
* (`pregel/stream.js`). The in-flight model call or tool batch is
|
|
801
|
-
* torn down where it stands — it does not finish first.
|
|
802
|
-
*
|
|
803
|
-
* A halt is therefore the wrong tool for "stop generating but keep
|
|
804
|
-
* what you have". That is what `RunConfig.preemption` is for: it
|
|
805
|
-
* seals the stream at a provider-safe boundary and keeps the run.
|
|
806
|
-
*/
|
|
807
526
|
const haltSignal = this.hookRegistry?.getHaltSignal(this.id);
|
|
808
527
|
if (haltSignal != null) {
|
|
809
528
|
this._haltedReason = haltSignal.reason;
|
|
@@ -812,13 +531,6 @@ var Run = class Run {
|
|
|
812
531
|
}
|
|
813
532
|
terminalAt = Date.now();
|
|
814
533
|
if (this._interrupt != null) await this.resolveInterruptResumeConfig(config);
|
|
815
|
-
/**
|
|
816
|
-
* Skip the Stop hook when the run paused on a HITL interrupt
|
|
817
|
-
* (still pending human input) or was halted by a hook (the host
|
|
818
|
-
* already chose to stop, so a Stop hook firing now would be
|
|
819
|
-
* misleading). The host fires Stop on the resumed-and-completed
|
|
820
|
-
* run instead.
|
|
821
|
-
*/
|
|
822
534
|
if (this._interrupt == null && this._haltedReason == null && this.hookRegistry?.hasHookFor("Stop", this.id) === true) await executeHooks({
|
|
823
535
|
registry: this.hookRegistry,
|
|
824
536
|
input: {
|
|
@@ -827,35 +539,11 @@ var Run = class Run {
|
|
|
827
539
|
threadId,
|
|
828
540
|
agentId: graph.defaultAgentId,
|
|
829
541
|
messages: graph.getRunMessages() ?? stateInputs?.messages ?? [],
|
|
830
|
-
/**
|
|
831
|
-
* A seal whose boundary ended the turn early must say so. The
|
|
832
|
-
* hook-supplied reason wins when a `PreemptBoundary` hook halted
|
|
833
|
-
* with one — a persistence/audit `Stop` hook should record the
|
|
834
|
-
* actual cause, not the generic label — and `preempt_incomplete`
|
|
835
|
-
* is reserved for the boundary that simply had nothing to inject.
|
|
836
|
-
*/
|
|
837
542
|
stopReason: graph.preemptHaltReason ?? (graph.preemptIncomplete ? "preempt_incomplete" : void 0),
|
|
838
543
|
stopHookActive: false
|
|
839
544
|
},
|
|
840
545
|
sessionId: this.id
|
|
841
546
|
}).catch(() => {});
|
|
842
|
-
/**
|
|
843
|
-
* A `PreemptBoundary` hook that returned `preventContinuation` has its
|
|
844
|
-
* registry halt cleared by the graph — that is what stops the halt from
|
|
845
|
-
* cancelling the stream before the sealed turn commits — so the reason
|
|
846
|
-
* is carried across on the graph instead. Surfaced here, AFTER the
|
|
847
|
-
* `Stop` dispatch above, so the host still receives a completion signal
|
|
848
|
-
* to persist the partial answer with while `getHaltReason()` correctly
|
|
849
|
-
* reports that a hook stopped the run rather than the model finishing.
|
|
850
|
-
*
|
|
851
|
-
* An empty boundary — sealed, but nothing to inject because the host's
|
|
852
|
-
* queue was drained or cancelled in the meantime — cut the answer short
|
|
853
|
-
* just as surely, only without a hook-supplied reason. It surfaces
|
|
854
|
-
* through the same channel under the same name the `Stop` dispatch
|
|
855
|
-
* already used for its `stopReason`, so terminal consumers
|
|
856
|
-
* (`AgentSession` emits `run.halted`, not `run.completed`) cannot
|
|
857
|
-
* finalize a truncated answer as a natural finish.
|
|
858
|
-
*/
|
|
859
547
|
if (this._haltedReason == null && graph.preemptHaltReason != null) this._haltedReason = graph.preemptHaltReason;
|
|
860
548
|
else if (this._haltedReason == null && graph.preemptIncomplete) this._haltedReason = "preempt_incomplete";
|
|
861
549
|
};
|
|
@@ -871,13 +559,6 @@ var Run = class Run {
|
|
|
871
559
|
} catch (err) {
|
|
872
560
|
terminalAt = Date.now();
|
|
873
561
|
streamThrew = true;
|
|
874
|
-
/**
|
|
875
|
-
* Corroborate cancellation against an actually-aborted signal. A
|
|
876
|
-
* provider SDK or host handler can reject with an `AbortError` while
|
|
877
|
-
* nothing was cancelled — that is an unexpected failure (it also fires
|
|
878
|
-
* `StopFailure`), and naming it `cancelled` would misreport abort
|
|
879
|
-
* forensics.
|
|
880
|
-
*/
|
|
881
562
|
streamAborted = config.signal?.aborted === true || this.Graph.signal?.aborted === true;
|
|
882
563
|
if (this.hookRegistry?.hasHookFor("StopFailure", this.id) === true) {
|
|
883
564
|
const runMessages = this.Graph.getRunMessages() ?? [];
|
|
@@ -896,55 +577,12 @@ var Run = class Run {
|
|
|
896
577
|
}
|
|
897
578
|
throw err;
|
|
898
579
|
} finally {
|
|
899
|
-
/**
|
|
900
|
-
* Preserve session-scoped hooks when the run paused on a HITL
|
|
901
|
-
* interrupt — the very next call will be `Run.resume()`, which
|
|
902
|
-
* needs the same policy hooks (e.g., the `PreToolUse` matcher
|
|
903
|
-
* that triggered the interrupt) to fire on the re-executed node
|
|
904
|
-
* and uphold the approval flow. Clearing here would leak the
|
|
905
|
-
* approval gate on resume. The session is cleared instead at
|
|
906
|
-
* natural completion, error (including errors that happen AFTER
|
|
907
|
-
* an interrupt was captured — those interrupts are stale), or
|
|
908
|
-
* hook-driven halt (including hooks that returned BOTH `ask`
|
|
909
|
-
* and `preventContinuation` — the halt wins, no resume is
|
|
910
|
-
* expected, sessions must drop). Every state where no resume
|
|
911
|
-
* is expected clears.
|
|
912
|
-
*/
|
|
913
580
|
if (this.shouldClearHookSession(streamThrew)) this.hookRegistry?.clearSession(this.id);
|
|
914
|
-
/**
|
|
915
|
-
* Drop any halt signal raised mid-stream for this run so a
|
|
916
|
-
* subsequent `processStream` / `resume` starts with clean state.
|
|
917
|
-
* The Run captured `_haltedReason` already; the registry entry
|
|
918
|
-
* for this `sessionId` would otherwise spuriously trip the next
|
|
919
|
-
* loop. Other concurrent runs sharing this registry are
|
|
920
|
-
* unaffected — their entries live under their own session ids.
|
|
921
|
-
*/
|
|
922
581
|
this.hookRegistry?.clearHaltSignal(this.id);
|
|
923
582
|
await disposeLangfuseHandler(langfuseHandler);
|
|
924
|
-
/**
|
|
925
|
-
* Terminal sweep: close every step that never reached a terminal
|
|
926
|
-
* status — `completed` on a natural end, `cancelled` on caller abort
|
|
927
|
-
* or hook halt, `failed` on an unexpected stream error. Skipped on a
|
|
928
|
-
* HITL pause, where the open steps continue after `resume()`.
|
|
929
|
-
*
|
|
930
|
-
* Runs BEFORE the callback teardown below, so a caller observing
|
|
931
|
-
* lifecycle events only through `RunnableConfig.callbacks` still
|
|
932
|
-
* receives these closures rather than being left with unmatched
|
|
933
|
-
* starts, and before `getContentParts()` so terminal stamps flow into
|
|
934
|
-
* content and session serialization.
|
|
935
|
-
*/
|
|
936
583
|
if (!this.isAwaitingResume(streamThrew)) try {
|
|
937
584
|
await this.Graph.closeUnfinishedRunSteps(this.resolveSweepStatus(streamThrew, streamAborted), terminalAt);
|
|
938
585
|
} catch {}
|
|
939
|
-
/**
|
|
940
|
-
* Break the reference chain that keeps heavy data alive via
|
|
941
|
-
* LangGraph's internal `__pregel_scratchpad.currentTaskInput` →
|
|
942
|
-
* `@langchain/core` `RunTree.extra[lc:child_config]` →
|
|
943
|
-
* Node.js `AsyncLocalStorage` context captured by timers/promises.
|
|
944
|
-
*
|
|
945
|
-
* Without this, base64-encoded images/PDFs in message content remain
|
|
946
|
-
* reachable from lingering `Timeout` handles until GC runs.
|
|
947
|
-
*/
|
|
948
586
|
if (!this.skipCleanup) {
|
|
949
587
|
if (config.configurable != null) {
|
|
950
588
|
for (const key of Object.getOwnPropertySymbols(config.configurable)) {
|
|
@@ -958,52 +596,12 @@ var Run = class Run {
|
|
|
958
596
|
}
|
|
959
597
|
const result = this.returnContent ? this.Graph.getContentParts() : void 0;
|
|
960
598
|
this.calibrationRatio = this.Graph.getCalibrationRatio();
|
|
961
|
-
/**
|
|
962
|
-
* Skip `clearHeavyState()` when the run paused on a clean HITL
|
|
963
|
-
* interrupt awaiting resume — `Run.resume()` re-enters the same
|
|
964
|
-
* `ToolNode` instance and needs the sidecars `clearHeavyState`
|
|
965
|
-
* would wipe (`toolCallStepIds` for completion-event step ids,
|
|
966
|
-
* the `_toolOutputRegistry` for `{{tool<i>turn<n>}}`
|
|
967
|
-
* substitutions, `sessions` for code-env continuity, plus the
|
|
968
|
-
* `hookRegistry` and `humanInTheLoop` config the interrupt
|
|
969
|
-
* branch itself relies on). Without preservation, the resumed
|
|
970
|
-
* tool completion would dispatch `ON_RUN_STEP_COMPLETED` with
|
|
971
|
-
* an empty step id and downstream stream consumers would drop
|
|
972
|
-
* the result.
|
|
973
|
-
*
|
|
974
|
-
* The natural-completion / error / hook-driven-halt paths still
|
|
975
|
-
* clean up — `_haltedReason != null` or `streamThrew` mean no
|
|
976
|
-
* resume is expected. Cross-process resume (host rebuilds the
|
|
977
|
-
* Run from scratch) is a separate concern; see
|
|
978
|
-
* `HumanInTheLoopConfig` JSDoc.
|
|
979
|
-
*/
|
|
980
599
|
const awaitingResume = this.isAwaitingResume(streamThrew);
|
|
981
600
|
if (!this.skipCleanup && !awaitingResume) this.Graph.clearHeavyState();
|
|
982
601
|
this._streamResult = result;
|
|
983
602
|
}
|
|
984
603
|
return this._streamResult;
|
|
985
604
|
}
|
|
986
|
-
/**
|
|
987
|
-
* Returns the pending interrupt captured during the most recent
|
|
988
|
-
* `processStream` (or `resume`) invocation. `undefined` when the run
|
|
989
|
-
* either has not been streamed yet or completed without pausing.
|
|
990
|
-
*
|
|
991
|
-
* Hosts call this immediately after `processStream` returns to decide
|
|
992
|
-
* whether the run is awaiting human input. Persist the returned
|
|
993
|
-
* descriptor (alongside `thread_id` and the agent run config) so a
|
|
994
|
-
* later `resume(decisions)` can rebuild the run.
|
|
995
|
-
*
|
|
996
|
-
* The default `TPayload` is the SDK's `HumanInterruptPayload` union
|
|
997
|
-
* (`tool_approval` / `ask_user_question`), suitable for the common
|
|
998
|
-
* case where interrupts come from the built-in ToolNode or
|
|
999
|
-
* `askUserQuestion()` helper. Hosts that raise custom interrupts
|
|
1000
|
-
* from custom graph nodes pass their own type — the SDK does not
|
|
1001
|
-
* validate the runtime shape, it just transports whatever the
|
|
1002
|
-
* `interrupt()` call carried. When in doubt, narrow with the
|
|
1003
|
-
* `isToolApprovalInterrupt` / `isAskUserQuestionInterrupt` type
|
|
1004
|
-
* guards (which accept `unknown`) before reading variant-specific
|
|
1005
|
-
* fields.
|
|
1006
|
-
*/
|
|
1007
605
|
getInterrupt() {
|
|
1008
606
|
if (this._interrupt == null) return;
|
|
1009
607
|
return {
|
|
@@ -1011,74 +609,16 @@ var Run = class Run {
|
|
|
1011
609
|
payload: stripSubagentResumeManifest(this._interrupt.payload)
|
|
1012
610
|
};
|
|
1013
611
|
}
|
|
1014
|
-
/**
|
|
1015
|
-
* Returns the reason a hook halted the run via
|
|
1016
|
-
* `preventContinuation: true`, or `undefined` if no hook halted.
|
|
1017
|
-
*
|
|
1018
|
-
* Hosts inspect this after `processStream` returns to distinguish a
|
|
1019
|
-
* natural completion (`undefined`) from a hook-driven halt (a
|
|
1020
|
-
* truthy string). Independent from `getInterrupt()` — a halted run
|
|
1021
|
-
* has no interrupt; an interrupted run has no halt reason.
|
|
1022
|
-
*/
|
|
1023
612
|
getHaltReason() {
|
|
1024
613
|
return this._haltedReason;
|
|
1025
614
|
}
|
|
1026
|
-
/**
|
|
1027
|
-
* Resume a paused HITL run with the value the user (or whatever
|
|
1028
|
-
* decided the interrupt) supplied. The default `TResume` covers the
|
|
1029
|
-
* `tool_approval` interrupt (the common case): an array of decisions
|
|
1030
|
-
* in `action_requests` order, or a record keyed by `tool_call_id`.
|
|
1031
|
-
*
|
|
1032
|
-
* For other interrupt types (e.g., `ask_user_question` →
|
|
1033
|
-
* `AskUserQuestionResolution`, or any custom interrupt a host raises
|
|
1034
|
-
* from a custom node), pass the type parameter and the SDK forwards
|
|
1035
|
-
* the value through unchanged. LangGraph delivers it as the return
|
|
1036
|
-
* value of the original `interrupt()` call inside the paused node.
|
|
1037
|
-
*
|
|
1038
|
-
* The host MUST construct this Run with the same `thread_id` and the
|
|
1039
|
-
* same checkpointer as the original paused run; LangGraph rebuilds
|
|
1040
|
-
* graph state from the checkpoint and re-enters the interrupted node
|
|
1041
|
-
* from the start.
|
|
1042
|
-
*/
|
|
1043
|
-
/**
|
|
1044
|
-
* Returns the per-Run file checkpointer when
|
|
1045
|
-
* `toolExecution.local.fileCheckpointing === true` was set on the
|
|
1046
|
-
* RunConfig. Hosts can capture extra paths or call `rewind()`
|
|
1047
|
-
* directly. Returns undefined when checkpointing is disabled.
|
|
1048
|
-
*
|
|
1049
|
-
* Construction-time invariant: the checkpointer is shared across
|
|
1050
|
-
* every ToolNode the graph compiles (single-agent and multi-agent),
|
|
1051
|
-
* so a `rewind()` call here unwinds writes made by ANY agent in the
|
|
1052
|
-
* run.
|
|
1053
|
-
*/
|
|
1054
615
|
getFileCheckpointer() {
|
|
1055
616
|
return this.Graph?.getOrCreateFileCheckpointer();
|
|
1056
617
|
}
|
|
1057
|
-
/**
|
|
1058
|
-
* Convenience wrapper that calls `rewind()` on the per-Run file
|
|
1059
|
-
* checkpointer. Restores every file the local engine snapshotted
|
|
1060
|
-
* during this Run to its pre-write content (and deletes any path
|
|
1061
|
-
* that didn't exist before being created). Returns the count of
|
|
1062
|
-
* paths processed; returns 0 when checkpointing is disabled.
|
|
1063
|
-
*/
|
|
1064
618
|
async rewindFiles() {
|
|
1065
619
|
const cp = this.getFileCheckpointer();
|
|
1066
620
|
return cp == null ? 0 : cp.rewind();
|
|
1067
621
|
}
|
|
1068
|
-
/**
|
|
1069
|
-
* Resume an interrupted run. `commandOptions` forwards langgraph 1.4.5
|
|
1070
|
-
* `Command` fields applied together with `resume` in one superstep:
|
|
1071
|
-
* - `update`: channel updates committed at the resume point. On a *rebuilt*
|
|
1072
|
-
* Run (new instance + durable checkpointer), `update.messages` are the first
|
|
1073
|
-
* write the fresh wrapper sees, so they seed the `getRunMessages()` /
|
|
1074
|
-
* `returnContent` baseline and are excluded from them (still committed to the
|
|
1075
|
-
* checkpoint). Hosts that rebuild + inject messages should persist them
|
|
1076
|
-
* directly or read from `getState`. Unreachable without a durable checkpointer.
|
|
1077
|
-
* - `goto`: a *dynamic* edge that does not cancel static `addEdge` routes. On
|
|
1078
|
-
* the built-in standard graph the fixed `toolNode -> agentNode/END` edge still
|
|
1079
|
-
* fires, so `goto` adds rather than replaces (e.g. `goto: END` will not stop a
|
|
1080
|
-
* tool-node resume). Intended for custom, Command-routed graphs.
|
|
1081
|
-
*/
|
|
1082
622
|
async resume(resumeValue, callerConfig, streamOptions, commandOptions) {
|
|
1083
623
|
const resumeConfig = await this.resolveInterruptResumeConfig(callerConfig, commandOptions?.update);
|
|
1084
624
|
const interruptId = this._interrupt?.interruptId;
|
|
@@ -1188,16 +728,7 @@ var Run = class Run {
|
|
|
1188
728
|
agentName: titleContext?.name
|
|
1189
729
|
});
|
|
1190
730
|
const titleRunName = getLangfuseTraceName(traceMetadata, "LibreChat Title");
|
|
1191
|
-
/** Scope identity carries an opaque per-execution component: public run
|
|
1192
|
-
* ids are unrestricted, so a purely derived id (`title-<runId>`) could
|
|
1193
|
-
* collide with an ordinary concurrent run literally named that way and
|
|
1194
|
-
* defeat foreign-scope rejection. */
|
|
1195
731
|
const titleScopeRunId = `title:${this.id}:${nanoid()}`;
|
|
1196
|
-
/** Seed policy mirrors `generateActivityLabel`:
|
|
1197
|
-
* `runWithLangfuseRuntimeContext` SPREADS the surrounding context, so an
|
|
1198
|
-
* absent seed INHERITS an active parent run's and collapses the title
|
|
1199
|
-
* into that run's trace. Seeded when determinism is opted into OR a
|
|
1200
|
-
* parent seed is live; otherwise unseeded, matching the other paths. */
|
|
1201
732
|
const inheritedTraceSeed = getTraceIdSeed();
|
|
1202
733
|
const titleRuntimeScope = resolveLangfuseRuntimeScope({
|
|
1203
734
|
runLangfuse: this.langfuse,
|
|
@@ -1244,7 +775,6 @@ var Run = class Run {
|
|
|
1244
775
|
skipLanguage
|
|
1245
776
|
}) }).withConfig({ runName: "PrepareTitleInput" });
|
|
1246
777
|
const titleChain = titleMethod === "completion" ? await createCompletionTitleRunnable(model, titlePrompt) : await createTitleRunnable(model, titlePrompt);
|
|
1247
|
-
/** Pipes `convoTemplate` -> `transformer` -> `titleChain` */
|
|
1248
778
|
const fullChain = convoTemplate.withConfig({ runName: "FormatConversation" }).pipe(convoToTitleInput).pipe(titleChain).withConfig({ runName: "GenerateConversationTitle" });
|
|
1249
779
|
const invokeConfig = Object.assign({}, chainOptions, {
|
|
1250
780
|
run_id: this.id,
|
|
@@ -1275,38 +805,17 @@ var Run = class Run {
|
|
|
1275
805
|
await disposeLangfuseHandler(titleLangfuseHandler);
|
|
1276
806
|
}
|
|
1277
807
|
}
|
|
1278
|
-
/**
|
|
1279
|
-
* Generates a short activity label for a completed tool/reasoning block
|
|
1280
|
-
* using a fast model. Mirrors `generateTitle`'s Langfuse wiring so the
|
|
1281
|
-
* call is traced under the conversation's session (sessionId from
|
|
1282
|
-
* `chainOptions.configurable.thread_id`) with its own tags — never as an
|
|
1283
|
-
* orphan trace. The payload contains no human messages by design: intent
|
|
1284
|
-
* comes from `lastAssistantText`, content from reasoning excerpts and
|
|
1285
|
-
* tool entries.
|
|
1286
|
-
*/
|
|
1287
808
|
async generateActivityLabel({ provider, clientOptions, entries, thinkingExcerpts, lastAssistantText, lastAssistantPhase, previousLabels, prompt, charLimit = 600, chainOptions, traceSeed, agentId }) {
|
|
1288
809
|
if (entries.length === 0 && !(thinkingExcerpts && thinkingExcerpts.length > 0)) return {};
|
|
1289
810
|
const labelSeq = ++this.activityLabelSeq;
|
|
1290
|
-
/** Resolve the LABELED agent's context: its Langfuse overlay carries the
|
|
1291
|
-
* trace metadata and the tool-output redaction policy that must govern
|
|
1292
|
-
* this label. */
|
|
1293
811
|
const requestedContext = this.Graph == null || agentId == null ? void 0 : this.Graph.agentContexts.get(agentId);
|
|
1294
|
-
/** Fail closed: an explicit but unknown/stale `agentId` must NOT silently
|
|
1295
|
-
* fall back to the default agent, whose redaction policy may be weaker
|
|
1296
|
-
* than the labeled agent's. Skip generation entirely instead. */
|
|
1297
812
|
if (agentId != null && requestedContext == null) return {};
|
|
1298
813
|
const labelContext = this.Graph == null ? void 0 : requestedContext ?? this.Graph.agentContexts.get(this.Graph.defaultAgentId);
|
|
1299
|
-
/** Shallow-cloned: activity labels run once per tool batch, and writing
|
|
1300
|
-
* the Langfuse handler back onto a host-reused `chainOptions` would
|
|
1301
|
-
* accumulate duplicate callbacks across batches. */
|
|
1302
814
|
const labelChainOptions = { ...chainOptions ?? {} };
|
|
1303
815
|
const labelUserId = typeof labelChainOptions.configurable?.user_id === "string" ? labelChainOptions.configurable.user_id : void 0;
|
|
1304
816
|
const labelSessionId = typeof labelChainOptions.configurable?.thread_id === "string" ? labelChainOptions.configurable.thread_id : void 0;
|
|
1305
817
|
const labelIndex = labelSeq - 1;
|
|
1306
818
|
const labelParentMessageId = labelChainOptions.configurable?.requestBody?.parentMessageId;
|
|
1307
|
-
/** An omitted `agentId` is attributable only when exactly one context
|
|
1308
|
-
* exists. Multi-agent callers remain unattributed instead of being
|
|
1309
|
-
* incorrectly assigned to the graph's default agent. */
|
|
1310
819
|
const labelAgentId = agentId ?? (this.Graph?.agentContexts.size === 1 ? this.Graph.defaultAgentId : void 0);
|
|
1311
820
|
const labelAgentName = labelAgentId == null ? void 0 : labelContext?.name;
|
|
1312
821
|
const labelMetadata = {
|
|
@@ -1332,19 +841,8 @@ var Run = class Run {
|
|
|
1332
841
|
const labelTags = ["librechat", "activity-label"];
|
|
1333
842
|
const labelLangfuseConfig = resolveLangfuseConfig(this.langfuse, labelContext?.langfuse);
|
|
1334
843
|
initializeLangfuseTracing(labelLangfuseConfig);
|
|
1335
|
-
/** Seed policy, threading two constraints:
|
|
1336
|
-
* 1. `runWithLangfuseRuntimeContext` SPREADS the surrounding context, so
|
|
1337
|
-
* an absent seed INHERITS the parent run's and collapses every label
|
|
1338
|
-
* into that trace. When a parent seed is active we must override it
|
|
1339
|
-
* with a per-label one.
|
|
1340
|
-
* 2. Without deterministic tracing there is no parent seed, and forcing
|
|
1341
|
-
* one here would make label trace ids deterministic when neither
|
|
1342
|
-
* `processStream` nor `generateTitle` are — so leave it unset.
|
|
1343
|
-
* Seeded when determinism is opted into OR a parent seed is live;
|
|
1344
|
-
* otherwise unseeded, matching the other generation paths. */
|
|
1345
844
|
const inheritedTraceSeed = getTraceIdSeed();
|
|
1346
845
|
const labelTraceSeed = labelLangfuseConfig?.deterministicTraceId === true || inheritedTraceSeed != null ? traceSeed ?? `activity-label-${this.id}-${labelSeq}` : void 0;
|
|
1347
|
-
/** Opaque per-execution component: see `titleScopeRunId`. */
|
|
1348
846
|
const labelScopeRunId = `activity-label:${this.id}:${labelSeq}:${nanoid()}`;
|
|
1349
847
|
const labelRuntimeScope = resolveLangfuseRuntimeScope({
|
|
1350
848
|
runLangfuse: this.langfuse,
|
|
@@ -1352,13 +850,6 @@ var Run = class Run {
|
|
|
1352
850
|
traceIdSeed: labelTraceSeed,
|
|
1353
851
|
runId: labelScopeRunId
|
|
1354
852
|
});
|
|
1355
|
-
/** Handler only when a session id resolved from
|
|
1356
|
-
* `chainOptions.configurable.thread_id`: without it the label call has
|
|
1357
|
-
* no conversation identity, and tracing it would create an orphan
|
|
1358
|
-
* trace outside any session — worse than not tracing at all. */
|
|
1359
|
-
/** Declared then conditionally assigned (title precedent): a ternary
|
|
1360
|
-
* around the object literal makes eslint's indent rule and prettier
|
|
1361
|
-
* disagree, and both gate CI. */
|
|
1362
853
|
let labelLangfuseHandler;
|
|
1363
854
|
if (labelSessionId != null) labelLangfuseHandler = createLangfuseHandler({
|
|
1364
855
|
langfuse: labelLangfuseConfig,
|
|
@@ -1372,14 +863,7 @@ var Run = class Run {
|
|
|
1372
863
|
traceName: labelRunName
|
|
1373
864
|
});
|
|
1374
865
|
if (labelLangfuseHandler != null) labelChainOptions.callbacks = appendCallbacks(labelChainOptions.callbacks, [labelLangfuseHandler]);
|
|
1375
|
-
/** The label prompt becomes Langfuse generation input, so the resolved
|
|
1376
|
-
* tool-output redaction policy (global disable / redactedToolNames)
|
|
1377
|
-
* applies to it exactly as to structured tool observations. */
|
|
1378
866
|
let redaction = hasToolOutputTracingConfig(this.langfuse, labelContext?.langfuse) ? resolveToolOutputTracingConfig(this.langfuse, labelContext?.langfuse) : void 0;
|
|
1379
|
-
/** Multi-agent graph with no `agentId`: the caller did not say WHICH
|
|
1380
|
-
* agent ran this batch, so resolving from the default agent could trace
|
|
1381
|
-
* raw output that a stricter sibling's policy forbids. Fold every
|
|
1382
|
-
* agent's policy into the strictest one instead of guessing. */
|
|
1383
867
|
const agentContexts = this.Graph?.agentContexts;
|
|
1384
868
|
if (agentId == null && agentContexts != null && agentContexts.size > 1) for (const context of agentContexts.values()) {
|
|
1385
869
|
if (!hasToolOutputTracingConfig(this.langfuse, context.langfuse)) continue;
|
|
@@ -1395,9 +879,6 @@ var Run = class Run {
|
|
|
1395
879
|
redactionText: redaction.redactionText
|
|
1396
880
|
};
|
|
1397
881
|
}
|
|
1398
|
-
/** An active redaction policy suppresses free-form reasoning/intent, so
|
|
1399
|
-
* a reasoning-only block has nothing describable left — skip the model
|
|
1400
|
-
* call rather than paying for a label built from the prompt alone. */
|
|
1401
882
|
const freeFormSuppressed = redaction != null && (redaction.enabled === false || redaction.redactedToolNames.size > 0);
|
|
1402
883
|
if (entries.length === 0 && freeFormSuppressed) return {};
|
|
1403
884
|
const userPrompt = buildActivityLabelPrompt({
|
|
@@ -1415,9 +896,6 @@ var Run = class Run {
|
|
|
1415
896
|
streaming: false
|
|
1416
897
|
}
|
|
1417
898
|
});
|
|
1418
|
-
/** Distinct run id per label call: callback/tracing integrations key
|
|
1419
|
-
* in-flight runs by it, so reusing the parent run's id would collide
|
|
1420
|
-
* across successive (or concurrent) label batches. */
|
|
1421
899
|
const labelRunId = `${this.id}-activity-${labelSeq}`;
|
|
1422
900
|
const invokeConfig = Object.assign({}, labelChainOptions, {
|
|
1423
901
|
run_id: labelRunId,
|
|
@@ -1442,10 +920,6 @@ var Run = class Run {
|
|
|
1442
920
|
let text = "";
|
|
1443
921
|
if (typeof content === "string") text = content;
|
|
1444
922
|
else if (Array.isArray(content)) text = content.map((block) => typeof block === "string" ? block : block.text ?? "").join("");
|
|
1445
|
-
/** Collapsed to one line at the source: a header renders as a single
|
|
1446
|
-
* row, and hosts feed committed labels back as continuity context —
|
|
1447
|
-
* so a multi-line result would carry its line breaks into every later
|
|
1448
|
-
* prompt in the run. */
|
|
1449
923
|
return text.replace(/\s+/g, " ").trim().replace(/^["']|["']$/g, "");
|
|
1450
924
|
};
|
|
1451
925
|
try {
|
|
@@ -1453,10 +927,6 @@ var Run = class Run {
|
|
|
1453
927
|
try {
|
|
1454
928
|
response = await withLangfuseRuntimeScope(labelRuntimeScope, () => invokeLabel(invokeConfig));
|
|
1455
929
|
} catch (error) {
|
|
1456
|
-
/** Retry ONLY recognized callback/tracer failures (the EventStream
|
|
1457
|
-
* tracer class of errors the stripped-callbacks fallback exists
|
|
1458
|
-
* for). Aborts and provider failures rethrow — retrying those
|
|
1459
|
-
* doubles traffic/cost and can restart cancelled requests. */
|
|
1460
930
|
const aborted = labelChainOptions.signal?.aborted === true || error?.name === "AbortError";
|
|
1461
931
|
const callbackFailure = /callback|tracer|event.?stream/i.test(String(error?.stack ?? error?.message ?? ""));
|
|
1462
932
|
if (aborted || !callbackFailure) throw error;
|
|
@@ -1471,12 +941,6 @@ var Run = class Run {
|
|
|
1471
941
|
await disposeLangfuseHandler(labelLangfuseHandler);
|
|
1472
942
|
}
|
|
1473
943
|
}
|
|
1474
|
-
/**
|
|
1475
|
-
* Generates one parent summary for two or more logical activities. The
|
|
1476
|
-
* summary model is traced as a dedicated activity-phase chain root in the
|
|
1477
|
-
* conversation session, with the model callback recorded as its generation
|
|
1478
|
-
* child. No session id means no phase trace, avoiding orphan observations.
|
|
1479
|
-
*/
|
|
1480
944
|
async generateActivityPhaseLabel({ provider, clientOptions, activities, totalActivityCount, assistantContext, closingTextPhase, prompt, charLimit = 600, chainOptions, traceSeed, sourceRunId, sourceTraceId, responseId, phaseIndex, status = "completed", agentIds }) {
|
|
1481
945
|
if (activities.length < 2) return {};
|
|
1482
946
|
const phaseSeq = ++this.activityPhaseLabelSeq;
|