@librechat/agents 3.4.7 → 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 +0 -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 +0 -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/__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 -196
- 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
|
@@ -7,12 +7,6 @@ const require_message_inputs = require("../llm/anthropic/utils/message_inputs.cj
|
|
|
7
7
|
const require_events = require("../utils/events.cjs");
|
|
8
8
|
let _langchain_core_messages = require("@langchain/core/messages");
|
|
9
9
|
//#region src/messages/format.ts
|
|
10
|
-
/**
|
|
11
|
-
* Formats a message with media content (images, documents, videos, audios) to API payload format.
|
|
12
|
-
*
|
|
13
|
-
* @param params - The parameters for formatting.
|
|
14
|
-
* @returns - The formatted message.
|
|
15
|
-
*/
|
|
16
10
|
const formatMediaMessage = ({ message, endpoint, mediaParts }) => {
|
|
17
11
|
const result = {
|
|
18
12
|
...message,
|
|
@@ -42,12 +36,6 @@ function withMessageRole(message, role) {
|
|
|
42
36
|
});
|
|
43
37
|
return roleMessage;
|
|
44
38
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Formats a message to OpenAI payload format based on the provided options.
|
|
47
|
-
*
|
|
48
|
-
* @param params - The parameters for formatting.
|
|
49
|
-
* @returns - The formatted message.
|
|
50
|
-
*/
|
|
51
39
|
const formatMessage = ({ message, userName, endpoint, assistantName, langChain = false }) => {
|
|
52
40
|
let { role: _role, _name, sender, text, content: _content, lc_id } = message;
|
|
53
41
|
if (lc_id && lc_id[2] && !langChain) _role = {
|
|
@@ -90,13 +78,6 @@ const formatMessage = ({ message, userName, endpoint, assistantName, langChain =
|
|
|
90
78
|
else if (role === "assistant") return withMessageRole(new _langchain_core_messages.AIMessage(require_langchain.toLangChainMessageFields(formattedMessage)), "assistant");
|
|
91
79
|
else return withMessageRole(new _langchain_core_messages.SystemMessage(require_langchain.toLangChainMessageFields(formattedMessage)), "system");
|
|
92
80
|
};
|
|
93
|
-
/**
|
|
94
|
-
* Formats an array of messages for LangChain.
|
|
95
|
-
*
|
|
96
|
-
* @param messages - The array of messages to format.
|
|
97
|
-
* @param formatOptions - The options for formatting each message.
|
|
98
|
-
* @returns - The array of formatted LangChain messages.
|
|
99
|
-
*/
|
|
100
81
|
const formatLangChainMessages = (messages, formatOptions) => {
|
|
101
82
|
return messages.map((msg) => {
|
|
102
83
|
return formatMessage({
|
|
@@ -106,12 +87,6 @@ const formatLangChainMessages = (messages, formatOptions) => {
|
|
|
106
87
|
});
|
|
107
88
|
});
|
|
108
89
|
};
|
|
109
|
-
/**
|
|
110
|
-
* Formats a LangChain message object by merging properties from `lc_kwargs` or `kwargs` and `additional_kwargs`.
|
|
111
|
-
*
|
|
112
|
-
* @param message - The message object to format.
|
|
113
|
-
* @returns - The formatted LangChain message.
|
|
114
|
-
*/
|
|
115
90
|
const formatFromLangChain = (message) => {
|
|
116
91
|
const { additional_kwargs = {}, ...message_kwargs } = message.lc_kwargs ?? message.kwargs ?? {};
|
|
117
92
|
return {
|
|
@@ -181,25 +156,11 @@ function formatToolCallOutput(output) {
|
|
|
181
156
|
if (output == null) return "";
|
|
182
157
|
return require_toolContent.compactToolContent(output, require_truncation.HARD_MAX_TOOL_RESULT_CHARS).content;
|
|
183
158
|
}
|
|
184
|
-
/**
|
|
185
|
-
* Content for the synthetic assistant turn that separates a trailing steer
|
|
186
|
-
* from the next user turn. Non-empty by necessity — see the push site.
|
|
187
|
-
*/
|
|
188
159
|
const STEER_ANCHOR_PLACEHOLDER = "_";
|
|
189
|
-
/**
|
|
190
|
-
* True when an assistant message replayed as a steer and nothing followed it,
|
|
191
|
-
* so the emitted run ends on the steer's `HumanMessage`.
|
|
192
|
-
*/
|
|
193
160
|
function endsWithSteerMessage(formatted) {
|
|
194
161
|
if (formatted.length === 0) return false;
|
|
195
162
|
return formatted[formatted.length - 1].additional_kwargs.source === "steer";
|
|
196
163
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Helper function to format an assistant message
|
|
199
|
-
* @param message The message to format
|
|
200
|
-
* @param options Optional formatting options
|
|
201
|
-
* @returns Array of formatted messages
|
|
202
|
-
*/
|
|
203
164
|
function formatAssistantMessage(message, options) {
|
|
204
165
|
const formattedMessages = [];
|
|
205
166
|
const appendFormattedMessage = (formattedMessage) => {
|
|
@@ -355,13 +316,6 @@ function formatAssistantMessage(message, options) {
|
|
|
355
316
|
}
|
|
356
317
|
currentContent = [];
|
|
357
318
|
} else if (shouldPreserveReasoningContent && pendingReasoningContent) {
|
|
358
|
-
/**
|
|
359
|
-
* Reasoning directly preceding a steer has no `currentContent`
|
|
360
|
-
* flush to consume it and the anchor resets below — emit an anchor
|
|
361
|
-
* AIMessage now (createAIMessage folds the pending reasoning into
|
|
362
|
-
* `additional_kwargs.reasoning_content`) or the persisted
|
|
363
|
-
* assistant reasoning silently vanishes on replay.
|
|
364
|
-
*/
|
|
365
319
|
lastAIMessage = createAIMessage("");
|
|
366
320
|
appendFormattedMessage(lastAIMessage);
|
|
367
321
|
}
|
|
@@ -374,9 +328,6 @@ function formatAssistantMessage(message, options) {
|
|
|
374
328
|
}
|
|
375
329
|
}), "user"));
|
|
376
330
|
lastAIMessage = null;
|
|
377
|
-
/** The steer splits the assistant message: the post-steer segment
|
|
378
|
-
* starts with fresh reasoning state (pre-steer reasoning was either
|
|
379
|
-
* flushed above or intentionally dropped when not preserving). */
|
|
380
331
|
hasReasoning = false;
|
|
381
332
|
pendingReasoningContent = "";
|
|
382
333
|
} else if (part.type === "error" || part.type === "agent_update" || part.type === "summary" || part.type === "activity_label") continue;
|
|
@@ -407,13 +358,6 @@ function getSourceMessageId(message) {
|
|
|
407
358
|
const normalized = candidate.trim();
|
|
408
359
|
return normalized.length > 0 ? normalized : void 0;
|
|
409
360
|
}
|
|
410
|
-
/**
|
|
411
|
-
* Keeps the first formatted message backward-compatible with its persisted
|
|
412
|
-
* source id and preserves source correlation on every derived message.
|
|
413
|
-
* Derived ids remain unset so the reducer can assign collision-free identities
|
|
414
|
-
* during its existing pass. This also prevents invented provider-shaped ids
|
|
415
|
-
* from leaking into provider request payloads.
|
|
416
|
-
*/
|
|
417
361
|
function stampSourceMessageIdentity(message, sourceMessageId, derivedIndex = 0) {
|
|
418
362
|
if (sourceMessageId == null) return;
|
|
419
363
|
message.additional_kwargs.sourceMessageId = sourceMessageId;
|
|
@@ -421,10 +365,6 @@ function stampSourceMessageIdentity(message, sourceMessageId, derivedIndex = 0)
|
|
|
421
365
|
message.id = sourceMessageId;
|
|
422
366
|
message.lc_kwargs.id = sourceMessageId;
|
|
423
367
|
}
|
|
424
|
-
/**
|
|
425
|
-
* Labels all agent content for parallel patterns (fan-out/fan-in)
|
|
426
|
-
* Groups consecutive content by agent and wraps with clear labels
|
|
427
|
-
*/
|
|
428
368
|
function labelAllAgentContent(contentParts, agentIdMap, agentNames) {
|
|
429
369
|
const result = [];
|
|
430
370
|
let currentAgentId;
|
|
@@ -458,17 +398,11 @@ function labelAllAgentContent(contentParts, agentIdMap, agentNames) {
|
|
|
458
398
|
};
|
|
459
399
|
for (let i = 0; i < contentParts.length; i++) {
|
|
460
400
|
const part = contentParts[i];
|
|
461
|
-
/** UI-only progress headers are not agent content and must not disturb
|
|
462
|
-
* agent state: a label with no `agentIdMap` entry would otherwise read
|
|
463
|
-
* as an agent change and flush the buffer mid-agent, splitting one
|
|
464
|
-
* agent's contiguous content into two labeled blocks. Skipped before
|
|
465
|
-
* any state transition below (mirrors the transfer path). */
|
|
466
401
|
if (part.type === "activity_label") continue;
|
|
467
402
|
const agentId = agentIdMap[i];
|
|
468
403
|
if (agentId !== currentAgentId && currentAgentId !== void 0) flushAgentBuffer();
|
|
469
404
|
currentAgentId = agentId;
|
|
470
405
|
if (part.type === "steer") {
|
|
471
|
-
/** User speech is never agent content — see the transfer path above. */
|
|
472
406
|
flushAgentBuffer();
|
|
473
407
|
result.push(part);
|
|
474
408
|
continue;
|
|
@@ -478,17 +412,6 @@ function labelAllAgentContent(contentParts, agentIdMap, agentNames) {
|
|
|
478
412
|
flushAgentBuffer();
|
|
479
413
|
return result;
|
|
480
414
|
}
|
|
481
|
-
/**
|
|
482
|
-
* Groups content parts by agent and formats them with agent labels
|
|
483
|
-
* This preprocesses multi-agent content to prevent identity confusion
|
|
484
|
-
*
|
|
485
|
-
* @param contentParts - The content parts from a run
|
|
486
|
-
* @param agentIdMap - Map of content part index to agent ID
|
|
487
|
-
* @param agentNames - Optional map of agent ID to display name
|
|
488
|
-
* @param options - Configuration options
|
|
489
|
-
* @param options.labelNonTransferContent - If true, labels all agent transitions (for parallel patterns)
|
|
490
|
-
* @returns Modified content parts with agent labels where appropriate
|
|
491
|
-
*/
|
|
492
415
|
const labelContentByAgent = (contentParts, agentIdMap, agentNames, options) => {
|
|
493
416
|
if (!agentIdMap || Object.keys(agentIdMap).length === 0) return contentParts;
|
|
494
417
|
if (options?.labelNonTransferContent === true) return labelAllAgentContent(contentParts, agentIdMap, agentNames);
|
|
@@ -529,11 +452,6 @@ const labelContentByAgent = (contentParts, agentIdMap, agentNames, options) => {
|
|
|
529
452
|
};
|
|
530
453
|
for (let i = 0; i < contentParts.length; i++) {
|
|
531
454
|
const part = contentParts[i];
|
|
532
|
-
/** UI-only progress headers are not agent content and must not disturb
|
|
533
|
-
* agent state: a label with no `agentIdMap` entry would otherwise look
|
|
534
|
-
* like an agent change, flushing the buffer and resetting an open
|
|
535
|
-
* transfer capture so the transferred agent's following chunks lose
|
|
536
|
-
* their frame. Skipped before any state transition below. */
|
|
537
455
|
if (part.type === "activity_label") continue;
|
|
538
456
|
const agentId = agentIdMap[i];
|
|
539
457
|
const isTransferTool = (part.type === "tool_call" && part.tool_call?.name?.startsWith("lc_transfer_to_")) ?? false;
|
|
@@ -546,16 +464,6 @@ const labelContentByAgent = (contentParts, agentIdMap, agentNames, options) => {
|
|
|
546
464
|
transferToolCallId = part.tool_call?.id;
|
|
547
465
|
currentAgentId = void 0;
|
|
548
466
|
} else if (part.type === "steer") {
|
|
549
|
-
/**
|
|
550
|
-
* User speech is never agent content: flush the buffer in place and
|
|
551
|
-
* pass the steer through verbatim so `formatAssistantMessage` replays
|
|
552
|
-
* it as a user turn. Folding it into a labeled transfer summary would
|
|
553
|
-
* both drop the user's words and misattribute them to the agent.
|
|
554
|
-
* The steer also CLOSES any open transfer capture — `flushAgentBuffer`
|
|
555
|
-
* no-ops on an empty buffer, and leaving the capture live would fold
|
|
556
|
-
* post-steer agent content into the pre-steer transfer output,
|
|
557
|
-
* replaying it BEFORE the user's redirect.
|
|
558
|
-
*/
|
|
559
467
|
flushAgentBuffer();
|
|
560
468
|
transferToolCallIndex = void 0;
|
|
561
469
|
transferToolCallId = void 0;
|
|
@@ -566,13 +474,11 @@ const labelContentByAgent = (contentParts, agentIdMap, agentNames, options) => {
|
|
|
566
474
|
flushAgentBuffer();
|
|
567
475
|
return result;
|
|
568
476
|
};
|
|
569
|
-
/** Extracts tool names from a tool_search output JSON string. */
|
|
570
477
|
function extractToolNamesFromSearchOutput(output) {
|
|
571
478
|
try {
|
|
572
479
|
const parsed = JSON.parse(output);
|
|
573
480
|
if (typeof parsed === "object" && parsed !== null && Array.isArray(parsed.tools)) return parsed.tools.map((t) => t.name).filter((name) => typeof name === "string");
|
|
574
481
|
} catch {
|
|
575
|
-
/** Output may have warnings prepended, try to find JSON within it */
|
|
576
482
|
const jsonMatch = output.match(/\{[\s\S]*\}/);
|
|
577
483
|
if (jsonMatch) try {
|
|
578
484
|
const parsed = JSON.parse(jsonMatch[0]);
|
|
@@ -582,7 +488,6 @@ function extractToolNamesFromSearchOutput(output) {
|
|
|
582
488
|
return [];
|
|
583
489
|
}
|
|
584
490
|
function resolveCoverageIndex(coverage, indexBySourceId, summaryMessageIndex) {
|
|
585
|
-
/** Persisted JSON, so the declared string type is not a runtime guarantee. */
|
|
586
491
|
if (typeof coverage?.retainedFromMessageId !== "string") return;
|
|
587
492
|
const retainedFromMessageId = coverage.retainedFromMessageId.trim();
|
|
588
493
|
if (retainedFromMessageId === "") return;
|
|
@@ -591,8 +496,6 @@ function resolveCoverageIndex(coverage, indexBySourceId, summaryMessageIndex) {
|
|
|
591
496
|
}
|
|
592
497
|
function scanSummaryBlocks(payload) {
|
|
593
498
|
let boundary;
|
|
594
|
-
/** Filled as the scan advances, so a coverage lookup only ever resolves to a
|
|
595
|
-
* message already passed — no second pass over the payload. */
|
|
596
499
|
const indexBySourceId = /* @__PURE__ */ new Map();
|
|
597
500
|
for (let i = 0; i < payload.length; i++) {
|
|
598
501
|
const message = payload[i];
|
|
@@ -626,10 +529,6 @@ function scanSummaryBlocks(payload) {
|
|
|
626
529
|
}
|
|
627
530
|
function applySummaryBoundary(message, messageIndex, summaryBoundary) {
|
|
628
531
|
if (!summaryBoundary) return message;
|
|
629
|
-
/** The boundary names the first retained message, so it is exclusive: that
|
|
630
|
-
* message and everything after it — the recency tail included — stays
|
|
631
|
-
* verbatim, and only genuinely covered history is dropped. Summary parts on
|
|
632
|
-
* surviving messages are filtered later by `formatAssistantMessage`. */
|
|
633
532
|
if (summaryBoundary.mode === "coverage") return messageIndex < summaryBoundary.messageIndex ? null : message;
|
|
634
533
|
if (messageIndex < summaryBoundary.messageIndex) return null;
|
|
635
534
|
if (messageIndex !== summaryBoundary.messageIndex || !Array.isArray(message.content)) return message;
|
|
@@ -638,11 +537,6 @@ function applySummaryBoundary(message, messageIndex, summaryBoundary) {
|
|
|
638
537
|
content: message.content.slice(summaryBoundary.contentIndex + 1)
|
|
639
538
|
};
|
|
640
539
|
}
|
|
641
|
-
/**
|
|
642
|
-
* Whether `formatAssistantMessage` filters this part out of the emitted message.
|
|
643
|
-
* Such a part contributes no prompt tokens, so measuring it as zero characters
|
|
644
|
-
* is accurate — it must not be mistaken for content the heuristic cannot see.
|
|
645
|
-
*/
|
|
646
540
|
function isDroppedByFormatting(part) {
|
|
647
541
|
if (part == null) return true;
|
|
648
542
|
if (part.type === "summary" || part.type === "error" || part.type === "agent_update" || part.type === "activity_label") return true;
|
|
@@ -654,19 +548,6 @@ function measureValueChars(value) {
|
|
|
654
548
|
const measured = require_toolContent.serializeStructuredValueBounded(value, 0).originalChars;
|
|
655
549
|
return measured === Number.MAX_SAFE_INTEGER ? require_truncation.HARD_MAX_TOOL_RESULT_CHARS : Math.min(measured, require_truncation.HARD_MAX_TOOL_RESULT_CHARS);
|
|
656
550
|
}
|
|
657
|
-
/**
|
|
658
|
-
* Whether a retained part's whole prompt cost is the text the char heuristic
|
|
659
|
-
* reads, making it safe to represent in a character ratio.
|
|
660
|
-
*
|
|
661
|
-
* An allowlist, not a denylist. Media, resources, and tool calls carry cost that
|
|
662
|
-
* is unrelated to their serialized length — a short image URL nested in
|
|
663
|
-
* `tool_call.output` stands in for a fixed four-figure media charge — and
|
|
664
|
-
* rejecting those case by case has repeatedly missed a nesting level. Listing
|
|
665
|
-
* the two shapes whose characters `contentPartCharLength` actually reads makes
|
|
666
|
-
* every other shape, present or future, ineligible by default: the ratio is
|
|
667
|
-
* skipped and the entry keeps its original count, which prunes early rather than
|
|
668
|
-
* exceeding the window.
|
|
669
|
-
*/
|
|
670
551
|
function isCharRatioEligible(part) {
|
|
671
552
|
if (part == null) return false;
|
|
672
553
|
return part.type === "text" || part.type === "thinking";
|
|
@@ -677,8 +558,6 @@ function contentPartCharLength(part) {
|
|
|
677
558
|
if (typeof record.text === "string") len += record.text.length;
|
|
678
559
|
if (typeof record.thinking === "string") len += record.thinking.length;
|
|
679
560
|
len += measureValueChars(record.input);
|
|
680
|
-
/** Tool calls nest their payload a level down, so measuring only the
|
|
681
|
-
* top-level fields scores an entire tool turn as zero characters. */
|
|
682
561
|
const { tool_call: toolCall } = record;
|
|
683
562
|
if (toolCall != null && typeof toolCall === "object") {
|
|
684
563
|
const call = toolCall;
|
|
@@ -688,7 +567,6 @@ function contentPartCharLength(part) {
|
|
|
688
567
|
}
|
|
689
568
|
return len;
|
|
690
569
|
}
|
|
691
|
-
/** Extracts the skillName from a skill tool_call's args (string or object). */
|
|
692
570
|
function extractSkillName(args) {
|
|
693
571
|
let parsed;
|
|
694
572
|
if (typeof args === "string") try {
|
|
@@ -698,33 +576,9 @@ function extractSkillName(args) {
|
|
|
698
576
|
const name = parsed?.skillName;
|
|
699
577
|
return typeof name === "string" && name !== "" ? name : void 0;
|
|
700
578
|
}
|
|
701
|
-
/**
|
|
702
|
-
* Formats an array of messages for LangChain, handling tool calls and creating ToolMessage instances.
|
|
703
|
-
*
|
|
704
|
-
* @param payload - The array of messages to format.
|
|
705
|
-
* @param indexTokenCountMap - Optional map of message indices to token counts.
|
|
706
|
-
* @param tools - Optional set of tool names that are allowed in the request.
|
|
707
|
-
* @param skills - Optional map of skill name to body for reconstructing skill HumanMessages.
|
|
708
|
-
* @param options - Optional formatting options (provider, skipSkillBodyNames).
|
|
709
|
-
* @returns - Object containing formatted messages and updated indexTokenCountMap if provided.
|
|
710
|
-
*/
|
|
711
579
|
const formatAgentMessages = (payload, indexTokenCountMap, tools, skills, options) => {
|
|
712
580
|
const messages = [];
|
|
713
|
-
/**
|
|
714
|
-
* A steer ended the previous payload entry, so the next message emitted —
|
|
715
|
-
* whichever entry finally produces one — must be separated from it by an
|
|
716
|
-
* assistant turn. Held rather than emitted so an entry that produces
|
|
717
|
-
* nothing cannot leave the anchor stranded as the final turn.
|
|
718
|
-
*/
|
|
719
581
|
let pendingSteerAnchor = false;
|
|
720
|
-
/**
|
|
721
|
-
* Emits the deferred anchor ahead of `next` — the message about to be
|
|
722
|
-
* pushed. When that message is itself an assistant turn, it already IS the
|
|
723
|
-
* separation the anchor exists to synthesize, so the intent is simply
|
|
724
|
-
* discharged: emitting the placeholder anyway would put two assistant turns
|
|
725
|
-
* back to back, which strict-alternation providers can reject and nothing downstream
|
|
726
|
-
* repairs (`coalesceAdjacentUserTurns` merges user turns only).
|
|
727
|
-
*/
|
|
728
582
|
const flushSteerAnchor = (next) => {
|
|
729
583
|
if (!pendingSteerAnchor) return;
|
|
730
584
|
pendingSteerAnchor = false;
|
|
@@ -735,11 +589,6 @@ const formatAgentMessages = (payload, indexTokenCountMap, tools, skills, options
|
|
|
735
589
|
let boundaryTokenAdjustment;
|
|
736
590
|
const indexMapping = {};
|
|
737
591
|
const { boundary: summaryBoundary } = scanSummaryBlocks(payload);
|
|
738
|
-
/**
|
|
739
|
-
* Create a mutable copy of the tools set that can be expanded dynamically.
|
|
740
|
-
* When we encounter tool_search results, we add discovered tools to this set,
|
|
741
|
-
* making their subsequent tool calls valid.
|
|
742
|
-
*/
|
|
743
592
|
const discoveredTools = tools ? new Set(tools) : void 0;
|
|
744
593
|
for (let i = 0; i < payload.length; i++) {
|
|
745
594
|
const rawMessage = payload[i];
|
|
@@ -772,12 +621,6 @@ const formatAgentMessages = (payload, indexTokenCountMap, tools, skills, options
|
|
|
772
621
|
continue;
|
|
773
622
|
}
|
|
774
623
|
const startMessageIndex = messages.length;
|
|
775
|
-
/**
|
|
776
|
-
* If tools set is provided, process tool_calls:
|
|
777
|
-
* - Keep valid tool_calls (tools in the set or dynamically discovered)
|
|
778
|
-
* - Convert invalid tool_calls to string representation for context preservation
|
|
779
|
-
* - Dynamically expand the set when tool_search results are encountered
|
|
780
|
-
*/
|
|
781
624
|
let processedMessage = message;
|
|
782
625
|
let pendingSkillNames;
|
|
783
626
|
if (discoveredTools) {
|
|
@@ -791,16 +634,11 @@ const formatAgentMessages = (payload, indexTokenCountMap, tools, skills, options
|
|
|
791
634
|
filteredContent.push(part);
|
|
792
635
|
continue;
|
|
793
636
|
}
|
|
794
|
-
/** Skip malformed tool_call entries */
|
|
795
637
|
if (part.tool_call == null || part.tool_call.name == null || part.tool_call.name === "") {
|
|
796
638
|
if (typeof part.tool_call?.id === "string" && part.tool_call.id !== "") invalidToolCallIds.add(part.tool_call.id);
|
|
797
639
|
continue;
|
|
798
640
|
}
|
|
799
641
|
const toolName = part.tool_call.name;
|
|
800
|
-
/**
|
|
801
|
-
* If this is a tool_search result with output, extract discovered tool names
|
|
802
|
-
* and add them to the discoveredTools set for subsequent validation.
|
|
803
|
-
*/
|
|
804
642
|
if (toolName === "tool_search" && typeof part.tool_call.output === "string" && part.tool_call.output !== "") {
|
|
805
643
|
const extracted = extractToolNamesFromSearchOutput(part.tool_call.output);
|
|
806
644
|
for (const name of extracted) discoveredTools.add(name);
|
|
@@ -812,22 +650,18 @@ const formatAgentMessages = (payload, indexTokenCountMap, tools, skills, options
|
|
|
812
650
|
if (skillName) (pendingSkillNames ??= /* @__PURE__ */ new Set()).add(skillName);
|
|
813
651
|
}
|
|
814
652
|
} else {
|
|
815
|
-
/** Invalid tool - convert to string for context preservation */
|
|
816
653
|
if (typeof part.tool_call.id === "string" && part.tool_call.id !== "") invalidToolCallIds.add(part.tool_call.id);
|
|
817
654
|
const output = part.tool_call.output ?? "";
|
|
818
655
|
invalidToolStrings.push(`Tool: ${toolName}, ${output}`);
|
|
819
656
|
}
|
|
820
657
|
}
|
|
821
|
-
/** Remove tool_call_ids references to invalid tools from text parts */
|
|
822
658
|
if (invalidToolCallIds.size > 0) {
|
|
823
659
|
for (const part of filteredContent) if (part.type === "text" && Array.isArray(part.tool_call_ids)) {
|
|
824
660
|
part.tool_call_ids = part.tool_call_ids.filter((id) => !invalidToolCallIds.has(id));
|
|
825
661
|
if (part.tool_call_ids.length === 0) delete part.tool_call_ids;
|
|
826
662
|
}
|
|
827
663
|
}
|
|
828
|
-
/** Append invalid tool strings to the content for context preservation */
|
|
829
664
|
if (invalidToolStrings.length > 0) {
|
|
830
|
-
/** Find the last text part or create one */
|
|
831
665
|
let lastTextPartIndex = -1;
|
|
832
666
|
for (let j = filteredContent.length - 1; j >= 0; j--) if (filteredContent[j].type === "text") {
|
|
833
667
|
lastTextPartIndex = j;
|
|
@@ -841,21 +675,17 @@ const formatAgentMessages = (payload, indexTokenCountMap, tools, skills, options
|
|
|
841
675
|
...lastTextPart,
|
|
842
676
|
["text"]: existingText ? `${existingText}\n${invalidToolText}` : invalidToolText
|
|
843
677
|
};
|
|
844
|
-
} else
|
|
845
|
-
/** No text part exists, create one */
|
|
846
|
-
filteredContent.push({
|
|
678
|
+
} else filteredContent.push({
|
|
847
679
|
type: "text",
|
|
848
680
|
["text"]: invalidToolText
|
|
849
681
|
});
|
|
850
682
|
}
|
|
851
|
-
/** Use filtered content if we made any changes */
|
|
852
683
|
if (filteredContent.length !== content.length || invalidToolStrings.length > 0) processedMessage = {
|
|
853
684
|
...message,
|
|
854
685
|
content: filteredContent
|
|
855
686
|
};
|
|
856
687
|
}
|
|
857
688
|
}
|
|
858
|
-
/** When tools filtering is off, still detect skill tool_calls for body reconstruction */
|
|
859
689
|
if (!discoveredTools && skills?.size != null && skills.size > 0) {
|
|
860
690
|
const content = processedMessage.content;
|
|
861
691
|
if (Array.isArray(content)) for (const part of content) {
|
|
@@ -870,41 +700,6 @@ const formatAgentMessages = (payload, indexTokenCountMap, tools, skills, options
|
|
|
870
700
|
provider: options?.provider,
|
|
871
701
|
sourceMessageId
|
|
872
702
|
});
|
|
873
|
-
/**
|
|
874
|
-
* A steer that ends an assistant message leaves the replay on a
|
|
875
|
-
* `HumanMessage`. The next payload message is itself a user turn, so the
|
|
876
|
-
* sequence would reach the provider as two adjacent user turns — rejected
|
|
877
|
-
* by strict-alternation providers. Anchor it with a placeholder assistant
|
|
878
|
-
* turn.
|
|
879
|
-
*
|
|
880
|
-
* The placeholder must be NON-EMPTY. A string-content assistant message
|
|
881
|
-
* with no tool calls passes through `_convertMessagesToAnthropicPayload`
|
|
882
|
-
* verbatim — the empty-text repair there only covers array content and
|
|
883
|
-
* tool-call turns — so an empty anchor would reach Anthropic as
|
|
884
|
-
* `{role: 'assistant', content: ''}` and trade one invalid sequence for
|
|
885
|
-
* another. Same single-underscore convention the Anthropic converter
|
|
886
|
-
* already uses when it has to synthesize a non-empty block.
|
|
887
|
-
*
|
|
888
|
-
* Deferred rather than decided by lookahead. `i < payload.length - 1` only
|
|
889
|
-
* proves a later ENTRY exists, not that it EMITS: entries with empty
|
|
890
|
-
* content, and entries dropped by `applySummaryBoundary`, are skipped
|
|
891
|
-
* silently. A trailing steer followed only by those would get the anchor
|
|
892
|
-
* as the FINAL turn — an assistant prefill with no request after it, which
|
|
893
|
-
* the model may simply never answer. So the intent is recorded and flushed
|
|
894
|
-
* only when a message actually follows.
|
|
895
|
-
*
|
|
896
|
-
* Pushed AFTER source identity stamping above, deliberately. The anchor is
|
|
897
|
-
* synthetic rather than derived from the persisted assistant entry, so it
|
|
898
|
-
* must not claim that entry's source metadata. Left unstamped, it reaches
|
|
899
|
-
* the reducer with a null id and is assigned a fresh one.
|
|
900
|
-
* `endsWithSteerMessage` reads only `additional_kwargs.source`, so the
|
|
901
|
-
* deferral cannot change which messages get anchored.
|
|
902
|
-
*/
|
|
903
|
-
/**
|
|
904
|
-
* Guarded on emission: an assistant entry whose blocks all filtered away
|
|
905
|
-
* emits nothing, and flushing for it would strand the anchor as the final
|
|
906
|
-
* turn — the pending flag stays set for whichever entry emits next.
|
|
907
|
-
*/
|
|
908
703
|
if (formattedMessages.length > 0) flushSteerAnchor(formattedMessages[0]);
|
|
909
704
|
messages.push(...formattedMessages);
|
|
910
705
|
if (endsWithSteerMessage(formattedMessages)) pendingSteerAnchor = true;
|
|
@@ -933,52 +728,17 @@ const formatAgentMessages = (payload, indexTokenCountMap, tools, skills, options
|
|
|
933
728
|
const resultIndices = indexMapping[originalIndex] || [];
|
|
934
729
|
let tokenCount = indexTokenCountMap[originalIndex];
|
|
935
730
|
if (tokenCount === void 0) continue;
|
|
936
|
-
/**
|
|
937
|
-
* Coverage mode deliberately leaves the count alone, even though the entry
|
|
938
|
-
* holding the block is charged for summary text that `formatAssistantMessage`
|
|
939
|
-
* filters out and `summary.tokenCount` accounts separately.
|
|
940
|
-
*
|
|
941
|
-
* Discounting it needs the summary's cost in the same units as
|
|
942
|
-
* `indexTokenCountMap`, and that figure is not obtainable here: this
|
|
943
|
-
* function receives no tokenizer, and a count recorded at write time is in
|
|
944
|
-
* the writing run's units — `Run.create` derives its counter from the model
|
|
945
|
-
* in play, and a consumer may supply its own — so a conversation continued
|
|
946
|
-
* on a different model would subtract across encodings. Attempts to proxy
|
|
947
|
-
* it (character ratios, provider identity) all under-count some shape,
|
|
948
|
-
* which risks an over-context request; over-counting merely prunes early.
|
|
949
|
-
* Fixing it properly means passing the reader a tokenizer, which is a
|
|
950
|
-
* consumer-facing change and out of scope here.
|
|
951
|
-
*/
|
|
952
731
|
if (summaryBoundary?.mode === "positional" && originalIndex === summaryBoundary.messageIndex && Array.isArray(payload[originalIndex].content)) {
|
|
953
732
|
const content = payload[originalIndex].content;
|
|
954
733
|
const { contentIndex } = summaryBoundary;
|
|
955
734
|
if (contentIndex >= 0 && contentIndex < content.length - 1) {
|
|
956
735
|
let totalCharLen = 0;
|
|
957
736
|
let remainingCharLen = 0;
|
|
958
|
-
/**
|
|
959
|
-
* The ratio applies only when *every* part of the entry is one whose
|
|
960
|
-
* token cost tracks its character length. A single ineligible part
|
|
961
|
-
* cancels the discount, whichever side of the boundary it sits on.
|
|
962
|
-
*
|
|
963
|
-
* Both sides can break it, in opposite directions. A retained image has
|
|
964
|
-
* its fixed cost scaled away, collapsing the entry. A removed base64
|
|
965
|
-
* payload inflates the denominator — serializing to a huge length while
|
|
966
|
-
* the counter charges a fixed estimate — dragging retained text below
|
|
967
|
-
* its real cost. Either way the request can exceed the window.
|
|
968
|
-
*
|
|
969
|
-
* Telling a text-bearing tool payload from a media-bearing one means
|
|
970
|
-
* recursing into arbitrary nested output, which has already missed a
|
|
971
|
-
* level twice here. Cancelling instead keeps the original count: an
|
|
972
|
-
* over-count that prunes early rather than overflowing. Entries of
|
|
973
|
-
* plain text and reasoning — the common shape — still proportion.
|
|
974
|
-
*/
|
|
975
737
|
let everyRetainedPartMeasurable = true;
|
|
976
738
|
for (let p = 0; p < content.length; p++) {
|
|
977
739
|
const part = content[p];
|
|
978
740
|
const retained = p > contentIndex;
|
|
979
741
|
if (isDroppedByFormatting(part)) {
|
|
980
|
-
/** Removed summary text is real removed content: it is read as
|
|
981
|
-
* plain text and belongs in the denominator. */
|
|
982
742
|
if (!retained && part.type === "summary") totalCharLen += contentPartCharLength(part);
|
|
983
743
|
continue;
|
|
984
744
|
}
|
|
@@ -1060,14 +820,6 @@ const formatAgentMessages = (payload, indexTokenCountMap, tools, skills, options
|
|
|
1060
820
|
boundaryTokenAdjustment
|
|
1061
821
|
};
|
|
1062
822
|
};
|
|
1063
|
-
/**
|
|
1064
|
-
* Adds a value at key 0 for system messages and shifts all key indices by one in an indexTokenCountMap.
|
|
1065
|
-
* This is useful when adding a system message at the beginning of a conversation.
|
|
1066
|
-
*
|
|
1067
|
-
* @param indexTokenCountMap - The original map of message indices to token counts
|
|
1068
|
-
* @param instructionsTokenCount - The token count for the system message to add at index 0
|
|
1069
|
-
* @returns A new map with the system message at index 0 and all other indices shifted by 1
|
|
1070
|
-
*/
|
|
1071
823
|
function shiftIndexTokenCountMap(indexTokenCountMap, instructionsTokenCount) {
|
|
1072
824
|
const shiftedMap = {};
|
|
1073
825
|
shiftedMap[0] = instructionsTokenCount;
|
|
@@ -1077,7 +829,6 @@ function shiftIndexTokenCountMap(indexTokenCountMap, instructionsTokenCount) {
|
|
|
1077
829
|
}
|
|
1078
830
|
return shiftedMap;
|
|
1079
831
|
}
|
|
1080
|
-
/** Checks whether a BaseMessage is a tool-role message. */
|
|
1081
832
|
const isToolMessage = (m) => m instanceof _langchain_core_messages.ToolMessage || "role" in m && m.role === "tool";
|
|
1082
833
|
const PORTABLE_FOLDED_MEDIA_TYPES = new Set(["image", "image_url"]);
|
|
1083
834
|
const MAX_FOLDED_BLOCK_CHARS = 8e3;
|
|
@@ -1101,11 +852,6 @@ function readFoldedDataProperty(value, key) {
|
|
|
1101
852
|
return;
|
|
1102
853
|
}
|
|
1103
854
|
}
|
|
1104
|
-
/**
|
|
1105
|
-
* Adds one logical line without first concatenating caller-controlled strings.
|
|
1106
|
-
* The shared budget covers every synthetic message emitted by one transform,
|
|
1107
|
-
* so many individually bounded blocks cannot build an unbounded aggregate.
|
|
1108
|
-
*/
|
|
1109
855
|
function appendFoldedLine(textChunks, budget, pieces) {
|
|
1110
856
|
if (budget.remainingChars <= 0) {
|
|
1111
857
|
budget.truncated = true;
|
|
@@ -1162,15 +908,9 @@ function appendSyntheticProviderContextMessage(result, parts) {
|
|
|
1162
908
|
result.push(markSyntheticProviderContext(withMessageRole(new _langchain_core_messages.HumanMessage({ content: require_langchain.toLangChainContent(parts) }), "user")));
|
|
1163
909
|
return true;
|
|
1164
910
|
}
|
|
1165
|
-
/**
|
|
1166
|
-
* Identifies provider-context placeholders created by this module without
|
|
1167
|
-
* trusting user-controlled content prefixes or leaking marker metadata onto
|
|
1168
|
-
* the provider wire.
|
|
1169
|
-
*/
|
|
1170
911
|
function isSyntheticProviderContextMessage(message) {
|
|
1171
912
|
return syntheticProviderContextMessages.has(message);
|
|
1172
913
|
}
|
|
1173
|
-
/** Flushes accumulated text chunks into `parts` as a single text block. */
|
|
1174
914
|
function flushTextChunks(textChunks, parts) {
|
|
1175
915
|
if (textChunks.length === 0) return;
|
|
1176
916
|
parts.push({
|
|
@@ -1179,17 +919,6 @@ function flushTextChunks(textChunks, parts) {
|
|
|
1179
919
|
});
|
|
1180
920
|
textChunks.length = 0;
|
|
1181
921
|
}
|
|
1182
|
-
/**
|
|
1183
|
-
* Appends a single message's content to the running `textChunks` / `parts`
|
|
1184
|
-
* accumulators. Portable image blocks are shallow-copied into `parts` so
|
|
1185
|
-
* binary data never becomes text tokens. Provider-specific media/resource
|
|
1186
|
-
* blocks are retained as bounded text so a folded cross-provider history
|
|
1187
|
-
* cannot contain an unsupported native block or JSON-expand without limit.
|
|
1188
|
-
*
|
|
1189
|
-
* When `content` is an array containing tool_use blocks, `tool_calls` is NOT
|
|
1190
|
-
* additionally serialized (avoiding double output). `tool_calls` is used as
|
|
1191
|
-
* a fallback when `content` is a plain string or an array with no tool_use.
|
|
1192
|
-
*/
|
|
1193
922
|
function appendMessageContent(msg, role, textChunks, parts, budget) {
|
|
1194
923
|
const { content } = msg;
|
|
1195
924
|
if (typeof content === "string") {
|
|
@@ -1316,32 +1045,6 @@ function appendToolCalls(msg, role, textChunks, budget) {
|
|
|
1316
1045
|
]);
|
|
1317
1046
|
}
|
|
1318
1047
|
}
|
|
1319
|
-
/**
|
|
1320
|
-
* Ensures compatibility when switching from a non-thinking agent to a thinking-enabled agent.
|
|
1321
|
-
* Converts AI messages with tool calls (that lack thinking/reasoning blocks) into buffer strings,
|
|
1322
|
-
* avoiding the thinking block signature requirement.
|
|
1323
|
-
*
|
|
1324
|
-
* Recognizes the following as valid thinking/reasoning blocks:
|
|
1325
|
-
* - ContentTypes.THINKING (Anthropic)
|
|
1326
|
-
* - ContentTypes.REASONING_CONTENT (Bedrock)
|
|
1327
|
-
* - ContentTypes.REASONING (VertexAI / Google)
|
|
1328
|
-
* - 'redacted_thinking'
|
|
1329
|
-
*
|
|
1330
|
-
* @param messages - Array of messages to process
|
|
1331
|
-
* @param provider - The provider being used (unused but kept for future compatibility)
|
|
1332
|
-
* @param config - Optional RunnableConfig for structured agent logging
|
|
1333
|
-
* @param runStartIndex - Index in `messages` where the CURRENT run's own
|
|
1334
|
-
* appended AI/Tool messages begin (i.e. anything at this index or later
|
|
1335
|
-
* was just produced by this run's own iterations, not historical
|
|
1336
|
-
* context). When provided, AI messages at or after this index are
|
|
1337
|
-
* never converted to `[Previous agent context]` placeholders — Claude
|
|
1338
|
-
* can validly skip a thinking block before a tool_use (cf. PR #116),
|
|
1339
|
-
* so the agent's own in-run iterations must not be misclassified as
|
|
1340
|
-
* foreign history. Without the signal the function falls back to its
|
|
1341
|
-
* prior heuristic (`chainHasThinkingBlock`), preserving backward
|
|
1342
|
-
* compatibility for callers that don't yet pass the boundary.
|
|
1343
|
-
* @returns The messages array with tool sequences converted to buffer strings if necessary
|
|
1344
|
-
*/
|
|
1345
1048
|
function ensureThinkingBlockInMessages(messages, _provider, config, runStartIndex) {
|
|
1346
1049
|
if (messages.length === 0) return messages;
|
|
1347
1050
|
let lastHumanIndex = -1;
|
|
@@ -1406,15 +1109,6 @@ function ensureThinkingBlockInMessages(messages, _provider, config, runStartInde
|
|
|
1406
1109
|
}
|
|
1407
1110
|
return result;
|
|
1408
1111
|
}
|
|
1409
|
-
/** Whether a message carries tool content a tool-less agent cannot legally
|
|
1410
|
-
* send. Covers every representation a provider converter will serialize back
|
|
1411
|
-
* into a request: a ToolMessage, parsed `AIMessage.tool_calls`, raw
|
|
1412
|
-
* `additional_kwargs.tool_calls` (OpenAI keeps calls here when the parsed
|
|
1413
|
-
* array is empty), and `tool_use` / `tool_call` / `tool_result` content
|
|
1414
|
-
* blocks (`@langchain/aws` and the Anthropic converter map these to Converse
|
|
1415
|
-
* `toolUse` / `toolResult`). Missing the parent AI message is not just a
|
|
1416
|
-
* passthrough: folding its ToolMessage alone would leave an orphan
|
|
1417
|
-
* `assistant(tool_calls) -> user(...)` sequence. */
|
|
1418
1112
|
function messageHasToolContent(msg) {
|
|
1419
1113
|
if (isToolMessage(msg)) return true;
|
|
1420
1114
|
const aiMsg = msg;
|
|
@@ -1427,37 +1121,11 @@ function messageHasToolContent(msg) {
|
|
|
1427
1121
|
}
|
|
1428
1122
|
return false;
|
|
1429
1123
|
}
|
|
1430
|
-
/** Whether a message carries a tool RESULT: a ToolMessage, or a message whose
|
|
1431
|
-
* content includes a `tool_result` block (the shape when a call/result pair is
|
|
1432
|
-
* split as `AIMessage(tool_call)` + `HumanMessage(tool_result)`). Such a result
|
|
1433
|
-
* belongs with the preceding tool call, so it is absorbed into the same fold
|
|
1434
|
-
* and labelled as tool output. */
|
|
1435
1124
|
function isToolResultMessage(msg) {
|
|
1436
1125
|
if (isToolMessage(msg)) return true;
|
|
1437
1126
|
if (Array.isArray(msg.content)) return msg.content.some((block) => typeof block === "object" && readFoldedDataProperty(block, "type") === "tool_result");
|
|
1438
1127
|
return false;
|
|
1439
1128
|
}
|
|
1440
|
-
/**
|
|
1441
|
-
* Folds tool_use / tool_result content into plain text for an agent that binds
|
|
1442
|
-
* no tools.
|
|
1443
|
-
*
|
|
1444
|
-
* In a multi-agent graph, a tool-less destination still inherits the prior
|
|
1445
|
-
* agent's conversation history, which can contain toolUse/toolResult blocks.
|
|
1446
|
-
* Because it binds no tools, the model is invoked with no tool schema — and
|
|
1447
|
-
* Bedrock's Converse API rejects any request that carries toolUse/toolResult
|
|
1448
|
-
* blocks without a top-level toolConfig ("The toolConfig field must be defined
|
|
1449
|
-
* when using toolUse and toolResult content blocks"). Adding a dummy toolConfig
|
|
1450
|
-
* is not an option: AWS requires at least one tool, and it would expose a
|
|
1451
|
-
* capability the destination was intentionally denied.
|
|
1452
|
-
*
|
|
1453
|
-
* Each tool-call turn plus its trailing tool results (ToolMessages or
|
|
1454
|
-
* `tool_result` content blocks) is collapsed into a single `[Previous tool
|
|
1455
|
-
* interaction]` HumanMessage that preserves the tool name, arguments and result
|
|
1456
|
-
* as text (image blocks are kept as-is). Runs in a single pass: non-tool
|
|
1457
|
-
* messages pass through, `result` is allocated lazily on the first fold, and the
|
|
1458
|
-
* original array is returned unchanged when it holds no tool content (the common
|
|
1459
|
-
* fresh-tool-less-agent case).
|
|
1460
|
-
*/
|
|
1461
1129
|
function foldToolBlocksForToollessAgent(messages, config) {
|
|
1462
1130
|
let result = null;
|
|
1463
1131
|
let foldedCount = 0;
|
|
@@ -1470,7 +1138,6 @@ function foldToolBlocksForToollessAgent(messages, config) {
|
|
|
1470
1138
|
i++;
|
|
1471
1139
|
continue;
|
|
1472
1140
|
}
|
|
1473
|
-
/** First fold — copy the untouched prefix once, then append from here. */
|
|
1474
1141
|
if (result === null) result = messages.slice(0, i);
|
|
1475
1142
|
const parts = [];
|
|
1476
1143
|
const textChunks = [];
|
|
@@ -1491,17 +1158,6 @@ function foldToolBlocksForToollessAgent(messages, config) {
|
|
|
1491
1158
|
require_events.emitAgentLog(config, "warn", "format", `foldToolBlocksForToollessAgent: folded ${foldedCount} tool message(s) into text for a tool-less agent`);
|
|
1492
1159
|
return result;
|
|
1493
1160
|
}
|
|
1494
|
-
/**
|
|
1495
|
-
* Walks backwards from `currentIndex` through the message array to check
|
|
1496
|
-
* whether an earlier AI message in the same "chain" (no HumanMessage boundary)
|
|
1497
|
-
* contains a thinking/reasoning block.
|
|
1498
|
-
*
|
|
1499
|
-
* A "chain" is a contiguous sequence of AI + Tool messages with no intervening
|
|
1500
|
-
* HumanMessage. Bedrock reasoning models produce reasoning on the first AI
|
|
1501
|
-
* response, then issue follow-up tool calls with `content: ""` and no
|
|
1502
|
-
* reasoning block. These follow-ups are part of the same thinking-enabled
|
|
1503
|
-
* turn and should not be converted.
|
|
1504
|
-
*/
|
|
1505
1161
|
function chainHasThinkingBlock(messages, currentIndex) {
|
|
1506
1162
|
for (let k = currentIndex - 1; k >= 0; k--) {
|
|
1507
1163
|
const prev = messages[k];
|