@librechat/agents 3.2.21 → 3.2.32
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 +3 -2
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/events.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +200 -54
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/hooks/createWorkspacePolicyHook.cjs +13 -7
- package/dist/cjs/hooks/createWorkspacePolicyHook.cjs.map +1 -1
- package/dist/cjs/hooks/executeHooks.cjs.map +1 -1
- package/dist/cjs/hooks/types.cjs.map +1 -1
- package/dist/cjs/instrumentation.cjs +2 -2
- package/dist/cjs/instrumentation.cjs.map +1 -1
- package/dist/cjs/langfuse.cjs +17 -1
- package/dist/cjs/langfuse.cjs.map +1 -1
- package/dist/cjs/langfuseToolOutputTracing.cjs +2 -2
- package/dist/cjs/langfuseToolOutputTracing.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/index.cjs +1 -1
- package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +38 -3
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +6 -2
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/index.cjs +2 -2
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/toolCache.cjs +8 -5
- package/dist/cjs/llm/bedrock/toolCache.cjs.map +1 -1
- package/dist/cjs/llm/fake.cjs +16 -14
- package/dist/cjs/llm/fake.cjs.map +1 -1
- package/dist/cjs/llm/google/index.cjs +22 -0
- package/dist/cjs/llm/google/index.cjs.map +1 -1
- package/dist/cjs/llm/google/utils/common.cjs +88 -27
- package/dist/cjs/llm/google/utils/common.cjs.map +1 -1
- package/dist/cjs/llm/init.cjs +2 -2
- package/dist/cjs/llm/invoke.cjs +108 -11
- package/dist/cjs/llm/invoke.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +1 -1
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/utils/index.cjs +1 -1
- package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
- package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
- package/dist/cjs/llm/vertexai/index.cjs.map +1 -1
- package/dist/cjs/main.cjs +1 -0
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/messages/cache.cjs +29 -8
- package/dist/cjs/messages/cache.cjs.map +1 -1
- package/dist/cjs/messages/content.cjs.map +1 -1
- package/dist/cjs/messages/contextPruning.cjs.map +1 -1
- package/dist/cjs/messages/format.cjs +129 -17
- package/dist/cjs/messages/format.cjs.map +1 -1
- package/dist/cjs/messages/prune.cjs.map +1 -1
- package/dist/cjs/messages/reducer.cjs +1 -1
- package/dist/cjs/messages/reducer.cjs.map +1 -1
- package/dist/cjs/messages/tools.cjs +1 -1
- package/dist/cjs/messages/tools.cjs.map +1 -1
- package/dist/cjs/openai/index.cjs.map +1 -1
- package/dist/cjs/responses/index.cjs.map +1 -1
- package/dist/cjs/run.cjs +41 -20
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/session/AgentSession.cjs +4 -4
- package/dist/cjs/session/AgentSession.cjs.map +1 -1
- package/dist/cjs/session/JsonlSessionStore.cjs +2 -2
- package/dist/cjs/session/JsonlSessionStore.cjs.map +1 -1
- package/dist/cjs/session/handlers.cjs +2 -2
- package/dist/cjs/session/handlers.cjs.map +1 -1
- package/dist/cjs/stream.cjs +248 -25
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/summarization/node.cjs.map +1 -1
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +1 -1
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/Calculator.cjs +1 -1
- package/dist/cjs/tools/Calculator.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/SubagentTool.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +37 -18
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/ToolSearch.cjs +1 -1
- package/dist/cjs/tools/ToolSearch.cjs.map +1 -1
- package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs +7 -4
- package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs.map +1 -1
- package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs +4 -4
- package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs.map +1 -1
- package/dist/cjs/tools/handlers.cjs +2 -1
- package/dist/cjs/tools/handlers.cjs.map +1 -1
- package/dist/cjs/tools/local/CompileCheckTool.cjs.map +1 -1
- package/dist/cjs/tools/local/FileCheckpointer.cjs +2 -1
- package/dist/cjs/tools/local/FileCheckpointer.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalCodingTools.cjs +45 -19
- package/dist/cjs/tools/local/LocalCodingTools.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalExecutionEngine.cjs +3 -3
- package/dist/cjs/tools/local/LocalExecutionEngine.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalExecutionTools.cjs +2 -2
- package/dist/cjs/tools/local/LocalExecutionTools.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +4 -3
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/local/attachments.cjs +0 -5
- package/dist/cjs/tools/local/attachments.cjs.map +1 -1
- package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs +4 -4
- package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -1
- package/dist/cjs/tools/search/firecrawl.cjs +1 -1
- package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
- package/dist/cjs/tools/search/rerankers.cjs +7 -3
- package/dist/cjs/tools/search/rerankers.cjs.map +1 -1
- package/dist/cjs/tools/search/tavily-search.cjs +1 -1
- package/dist/cjs/tools/search/tavily-search.cjs.map +1 -1
- package/dist/cjs/tools/search/utils.cjs +76 -8
- package/dist/cjs/tools/search/utils.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/utils/handlers.cjs +1 -1
- package/dist/cjs/utils/handlers.cjs.map +1 -1
- package/dist/cjs/utils/run.cjs +1 -1
- package/dist/cjs/utils/run.cjs.map +1 -1
- package/dist/esm/agents/AgentContext.mjs +3 -2
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/events.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +200 -54
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/hooks/createWorkspacePolicyHook.mjs +13 -7
- package/dist/esm/hooks/createWorkspacePolicyHook.mjs.map +1 -1
- package/dist/esm/hooks/executeHooks.mjs.map +1 -1
- package/dist/esm/hooks/types.mjs.map +1 -1
- package/dist/esm/instrumentation.mjs +2 -2
- package/dist/esm/instrumentation.mjs.map +1 -1
- package/dist/esm/langfuse.mjs +17 -2
- package/dist/esm/langfuse.mjs.map +1 -1
- package/dist/esm/langfuseToolOutputTracing.mjs +2 -2
- package/dist/esm/langfuseToolOutputTracing.mjs.map +1 -1
- package/dist/esm/llm/anthropic/index.mjs +1 -1
- package/dist/esm/llm/anthropic/index.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs +38 -3
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs +6 -2
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
- package/dist/esm/llm/bedrock/index.mjs +2 -2
- package/dist/esm/llm/bedrock/index.mjs.map +1 -1
- package/dist/esm/llm/bedrock/toolCache.mjs +8 -5
- package/dist/esm/llm/bedrock/toolCache.mjs.map +1 -1
- package/dist/esm/llm/fake.mjs +16 -14
- package/dist/esm/llm/fake.mjs.map +1 -1
- package/dist/esm/llm/google/index.mjs +23 -1
- package/dist/esm/llm/google/index.mjs.map +1 -1
- package/dist/esm/llm/google/utils/common.mjs +88 -27
- package/dist/esm/llm/google/utils/common.mjs.map +1 -1
- package/dist/esm/llm/init.mjs +2 -2
- package/dist/esm/llm/invoke.mjs +104 -7
- package/dist/esm/llm/invoke.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +1 -1
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/llm/openai/utils/index.mjs +1 -1
- package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
- package/dist/esm/llm/openrouter/index.mjs.map +1 -1
- package/dist/esm/llm/vertexai/index.mjs.map +1 -1
- package/dist/esm/main.mjs +1 -1
- package/dist/esm/messages/cache.mjs +29 -8
- package/dist/esm/messages/cache.mjs.map +1 -1
- package/dist/esm/messages/content.mjs.map +1 -1
- package/dist/esm/messages/contextPruning.mjs.map +1 -1
- package/dist/esm/messages/format.mjs +129 -18
- package/dist/esm/messages/format.mjs.map +1 -1
- package/dist/esm/messages/prune.mjs.map +1 -1
- package/dist/esm/messages/reducer.mjs +1 -1
- package/dist/esm/messages/reducer.mjs.map +1 -1
- package/dist/esm/messages/tools.mjs +1 -1
- package/dist/esm/messages/tools.mjs.map +1 -1
- package/dist/esm/openai/index.mjs.map +1 -1
- package/dist/esm/responses/index.mjs.map +1 -1
- package/dist/esm/run.mjs +41 -20
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/session/AgentSession.mjs +4 -4
- package/dist/esm/session/AgentSession.mjs.map +1 -1
- package/dist/esm/session/JsonlSessionStore.mjs +2 -2
- package/dist/esm/session/JsonlSessionStore.mjs.map +1 -1
- package/dist/esm/session/handlers.mjs +2 -2
- package/dist/esm/session/handlers.mjs.map +1 -1
- package/dist/esm/stream.mjs +248 -25
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/summarization/node.mjs.map +1 -1
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs +1 -1
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/Calculator.mjs +1 -1
- package/dist/esm/tools/Calculator.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +1 -1
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/SubagentTool.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +37 -18
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/ToolSearch.mjs +1 -1
- package/dist/esm/tools/ToolSearch.mjs.map +1 -1
- package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs +7 -4
- package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs.map +1 -1
- package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs +4 -4
- package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs.map +1 -1
- package/dist/esm/tools/handlers.mjs +2 -1
- package/dist/esm/tools/handlers.mjs.map +1 -1
- package/dist/esm/tools/local/CompileCheckTool.mjs.map +1 -1
- package/dist/esm/tools/local/FileCheckpointer.mjs +2 -1
- package/dist/esm/tools/local/FileCheckpointer.mjs.map +1 -1
- package/dist/esm/tools/local/LocalCodingTools.mjs +45 -19
- package/dist/esm/tools/local/LocalCodingTools.mjs.map +1 -1
- package/dist/esm/tools/local/LocalExecutionEngine.mjs +3 -3
- package/dist/esm/tools/local/LocalExecutionEngine.mjs.map +1 -1
- package/dist/esm/tools/local/LocalExecutionTools.mjs +2 -2
- package/dist/esm/tools/local/LocalExecutionTools.mjs.map +1 -1
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +4 -3
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/local/attachments.mjs +0 -5
- package/dist/esm/tools/local/attachments.mjs.map +1 -1
- package/dist/esm/tools/local/resolveLocalExecutionTools.mjs +4 -4
- package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -1
- package/dist/esm/tools/search/firecrawl.mjs +1 -1
- package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
- package/dist/esm/tools/search/rerankers.mjs +8 -4
- package/dist/esm/tools/search/rerankers.mjs.map +1 -1
- package/dist/esm/tools/search/tavily-search.mjs +1 -1
- package/dist/esm/tools/search/tavily-search.mjs.map +1 -1
- package/dist/esm/tools/search/utils.mjs +76 -9
- package/dist/esm/tools/search/utils.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +1 -1
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/utils/handlers.mjs +1 -1
- package/dist/esm/utils/handlers.mjs.map +1 -1
- package/dist/esm/utils/run.mjs +1 -1
- package/dist/esm/utils/run.mjs.map +1 -1
- package/dist/types/agents/__tests__/promptCacheLiveHelpers.d.ts +1 -1
- package/dist/types/events.d.ts +1 -1
- package/dist/types/graphs/Graph.d.ts +7 -1
- package/dist/types/hooks/executeHooks.d.ts +1 -1
- package/dist/types/hooks/types.d.ts +5 -0
- package/dist/types/langfuse.d.ts +4 -0
- package/dist/types/llm/anthropic/utils/message_inputs.d.ts +1 -1
- package/dist/types/llm/anthropic/utils/message_outputs.d.ts +1 -1
- package/dist/types/llm/anthropic/utils/output_parsers.d.ts +2 -2
- package/dist/types/llm/bedrock/index.d.ts +2 -2
- package/dist/types/llm/fake.d.ts +3 -3
- package/dist/types/llm/google/index.d.ts +1 -0
- package/dist/types/llm/google/types.d.ts +1 -1
- package/dist/types/llm/google/utils/common.d.ts +2 -2
- package/dist/types/llm/google/utils/tools.d.ts +1 -1
- package/dist/types/llm/google/utils/zod_to_genai_parameters.d.ts +1 -1
- package/dist/types/llm/openai/index.d.ts +2 -2
- package/dist/types/llm/openai/utils/index.d.ts +1 -1
- package/dist/types/llm/openrouter/index.d.ts +4 -4
- package/dist/types/messages/contextPruning.d.ts +1 -1
- package/dist/types/messages/format.d.ts +14 -4
- package/dist/types/messages/prune.d.ts +1 -1
- package/dist/types/session/JsonlSessionStore.d.ts +1 -1
- package/dist/types/session/handlers.d.ts +1 -1
- package/dist/types/session/types.d.ts +1 -1
- package/dist/types/summarization/node.d.ts +1 -1
- package/dist/types/tools/SubagentTool.d.ts +2 -2
- package/dist/types/tools/ToolNode.d.ts +9 -2
- package/dist/types/tools/cloudflare/CloudflareSandboxExecutionEngine.d.ts +1 -1
- package/dist/types/tools/search/types.d.ts +1 -1
- package/dist/types/tools/search/utils.d.ts +11 -0
- package/dist/types/types/graph.d.ts +4 -4
- package/dist/types/types/llm.d.ts +4 -3
- package/dist/types/types/messages.d.ts +1 -1
- package/dist/types/types/run.d.ts +6 -6
- package/dist/types/types/stream.d.ts +2 -2
- package/dist/types/types/tools.d.ts +5 -1
- package/dist/types/utils/handlers.d.ts +2 -2
- package/dist/types/utils/run.d.ts +1 -1
- package/package.json +13 -10
- package/src/__tests__/stream.eagerEventExecution.test.ts +543 -6
- package/src/agents/AgentContext.ts +2 -2
- package/src/agents/__tests__/AgentContext.test.ts +3 -3
- package/src/agents/__tests__/promptCacheLiveHelpers.ts +1 -1
- package/src/events.ts +1 -1
- package/src/graphs/Graph.ts +329 -72
- package/src/graphs/MultiAgentGraph.ts +1 -1
- package/src/graphs/__tests__/Graph.reasoning.test.ts +919 -6
- package/src/graphs/__tests__/MultiAgentGraph.test.ts +1 -1
- package/src/graphs/__tests__/composition.smoke.test.ts +1 -1
- package/src/hooks/__tests__/HookRegistry.test.ts +1 -1
- package/src/hooks/__tests__/compactHooks.test.ts +8 -8
- package/src/hooks/__tests__/createWorkspacePolicyHook.test.ts +34 -22
- package/src/hooks/__tests__/executeHooks.test.ts +3 -3
- package/src/hooks/__tests__/integration.test.ts +3 -3
- package/src/hooks/__tests__/toolHooks.test.ts +10 -10
- package/src/hooks/createWorkspacePolicyHook.ts +17 -14
- package/src/hooks/executeHooks.ts +1 -1
- package/src/hooks/types.ts +5 -0
- package/src/instrumentation.ts +11 -11
- package/src/langfuse.ts +35 -1
- package/src/langfuseToolOutputTracing.ts +2 -2
- package/src/llm/anthropic/index.ts +1 -1
- package/src/llm/anthropic/llm.spec.ts +36 -0
- package/src/llm/anthropic/utils/message_inputs.ts +46 -4
- package/src/llm/anthropic/utils/message_outputs.ts +9 -7
- package/src/llm/anthropic/utils/output_parsers.ts +5 -5
- package/src/llm/anthropic/utils/streaming-tool-input.test.ts +186 -0
- package/src/llm/bedrock/index.ts +4 -4
- package/src/llm/bedrock/toolCache.test.ts +48 -9
- package/src/llm/bedrock/toolCache.ts +11 -6
- package/src/llm/fake.ts +30 -25
- package/src/llm/google/index.ts +43 -1
- package/src/llm/google/llm.spec.ts +173 -1
- package/src/llm/google/types.ts +1 -1
- package/src/llm/google/utils/common.ts +154 -45
- package/src/llm/google/utils/tools.ts +8 -8
- package/src/llm/google/utils/zod_to_genai_parameters.ts +4 -4
- package/src/llm/invoke.test.ts +3 -3
- package/src/llm/invoke.ts +170 -10
- package/src/llm/openai/index.ts +4 -4
- package/src/llm/openai/utils/index.ts +14 -14
- package/src/llm/openrouter/index.ts +4 -4
- package/src/llm/openrouter/reasoning.test.ts +2 -2
- package/src/llm/vertexai/fixThoughtSignatures.test.ts +1 -1
- package/src/llm/vertexai/index.ts +1 -1
- package/src/messages/cache.test.ts +144 -0
- package/src/messages/cache.ts +50 -13
- package/src/messages/content.ts +1 -1
- package/src/messages/contextPruning.ts +1 -1
- package/src/messages/format.ts +236 -43
- package/src/messages/formatAgentMessages.skills.test.ts +205 -26
- package/src/messages/formatAgentMessages.test.ts +841 -10
- package/src/messages/labelContentByAgent.test.ts +2 -2
- package/src/messages/prune.ts +1 -1
- package/src/messages/reducer.ts +1 -1
- package/src/messages/tools.ts +1 -1
- package/src/openai/__tests__/openai.test.ts +2 -2
- package/src/openai/index.ts +1 -1
- package/src/responses/__tests__/responses.test.ts +2 -2
- package/src/responses/index.ts +1 -1
- package/src/run.ts +68 -41
- package/src/session/AgentSession.ts +6 -6
- package/src/session/JsonlSessionStore.ts +3 -3
- package/src/session/__tests__/JsonlSessionStore.test.ts +5 -5
- package/src/session/__tests__/handlers.test.ts +2 -2
- package/src/session/handlers.ts +5 -5
- package/src/session/types.ts +1 -1
- package/src/specs/agent-handoffs.test.ts +1 -1
- package/src/specs/langfuse-callbacks.test.ts +2 -2
- package/src/specs/langfuse-metadata.test.ts +39 -0
- package/src/specs/langfuse-tool-output-tracing.test.ts +1 -1
- package/src/specs/multi-agent-summarization.test.ts +4 -4
- package/src/specs/subagent.test.ts +3 -3
- package/src/specs/summarization-unit.test.ts +1 -1
- package/src/specs/thinking-handoff.test.ts +1 -1
- package/src/splitStream.test.ts +48 -0
- package/src/stream.test.ts +53 -3
- package/src/stream.ts +450 -39
- package/src/summarization/__tests__/aggregator.test.ts +2 -2
- package/src/summarization/__tests__/node.test.ts +2 -2
- package/src/summarization/node.ts +1 -1
- package/src/tools/BashProgrammaticToolCalling.ts +5 -5
- package/src/tools/Calculator.ts +1 -1
- package/src/tools/CodeExecutor.ts +2 -4
- package/src/tools/SubagentTool.ts +2 -2
- package/src/tools/ToolNode.ts +37 -16
- package/src/tools/ToolSearch.ts +1 -1
- package/src/tools/__tests__/CloudflareSandboxExecution.test.ts +4 -4
- package/src/tools/__tests__/CodeApiAuthHeaders.test.ts +12 -12
- package/src/tools/__tests__/LocalExecutionTools.test.ts +125 -93
- package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +29 -5
- package/src/tools/__tests__/ReadFile.test.ts +1 -1
- package/src/tools/__tests__/SkillTool.test.ts +4 -4
- package/src/tools/__tests__/SubagentExecutor.test.ts +17 -13
- package/src/tools/__tests__/SubagentTool.test.ts +2 -2
- package/src/tools/__tests__/ToolNode.eagerEventExecution.test.ts +1 -1
- package/src/tools/__tests__/ToolNode.outputReferences.test.ts +2 -5
- package/src/tools/__tests__/ToolNode.session.test.ts +1 -1
- package/src/tools/__tests__/ToolSearch.test.ts +1 -1
- package/src/tools/__tests__/annotateMessagesForLLM.test.ts +1 -1
- package/src/tools/__tests__/directToolHITLResumeScope.test.ts +35 -32
- package/src/tools/__tests__/directToolHooks.test.ts +41 -0
- package/src/tools/__tests__/handlers.test.ts +2 -2
- package/src/tools/__tests__/hitl.test.ts +11 -11
- package/src/tools/__tests__/localToolNames.test.ts +8 -6
- package/src/tools/__tests__/skillCatalog.test.ts +1 -1
- package/src/tools/__tests__/subagentHooks.test.ts +20 -10
- package/src/tools/__tests__/workspaceSeam.test.ts +20 -7
- package/src/tools/cloudflare/CloudflareSandboxExecutionEngine.ts +9 -6
- package/src/tools/cloudflare/CloudflareSandboxTools.ts +19 -19
- package/src/tools/handlers.ts +5 -5
- package/src/tools/local/CompileCheckTool.ts +4 -7
- package/src/tools/local/FileCheckpointer.ts +6 -5
- package/src/tools/local/LocalCodingTools.ts +100 -45
- package/src/tools/local/LocalExecutionEngine.ts +5 -5
- package/src/tools/local/LocalExecutionTools.ts +9 -9
- package/src/tools/local/LocalProgrammaticToolCalling.ts +5 -4
- package/src/tools/local/attachments.ts +0 -6
- package/src/tools/local/resolveLocalExecutionTools.ts +15 -15
- package/src/tools/search/firecrawl.ts +1 -1
- package/src/tools/search/jina-reranker.test.ts +148 -37
- package/src/tools/search/rerankers.ts +14 -4
- package/src/tools/search/tavily-search.ts +2 -2
- package/src/tools/search/types.ts +1 -1
- package/src/tools/search/utils.ts +99 -9
- package/src/tools/subagent/SubagentExecutor.ts +12 -6
- package/src/types/graph.ts +12 -12
- package/src/types/llm.ts +7 -6
- package/src/types/messages.ts +1 -1
- package/src/types/run.ts +7 -7
- package/src/types/stream.ts +2 -2
- package/src/types/tools.ts +5 -1
- package/src/utils/handlers.ts +2 -2
- package/src/utils/llmConfig.ts +1 -1
- package/src/utils/logging.ts +20 -10
- package/src/utils/run.ts +2 -2
|
@@ -1,18 +1,72 @@
|
|
|
1
|
-
import
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
import { createReranker, JinaReranker } from './rerankers';
|
|
2
4
|
import { createDefaultLogger } from './utils';
|
|
3
5
|
|
|
6
|
+
type AxiosErrorFixture = Error & {
|
|
7
|
+
isAxiosError: true;
|
|
8
|
+
code: string;
|
|
9
|
+
config: {
|
|
10
|
+
data: string;
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: string;
|
|
13
|
+
};
|
|
14
|
+
method: string;
|
|
15
|
+
url: string;
|
|
16
|
+
};
|
|
17
|
+
response: {
|
|
18
|
+
data: {
|
|
19
|
+
details?: string;
|
|
20
|
+
message: string;
|
|
21
|
+
};
|
|
22
|
+
status: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const getApiUrl = (reranker: JinaReranker): string => {
|
|
27
|
+
const descriptor = Object.getOwnPropertyDescriptor(reranker, 'apiUrl');
|
|
28
|
+
if (typeof descriptor?.value === 'string') {
|
|
29
|
+
return descriptor.value;
|
|
30
|
+
}
|
|
31
|
+
throw new Error('Expected JinaReranker apiUrl to be initialized.');
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const createAxiosErrorFixture = (
|
|
35
|
+
url: string,
|
|
36
|
+
responseData: AxiosErrorFixture['response']['data']
|
|
37
|
+
): AxiosErrorFixture =>
|
|
38
|
+
Object.assign(new Error('Request failed with status code 500'), {
|
|
39
|
+
isAxiosError: true as const,
|
|
40
|
+
code: 'ERR_BAD_RESPONSE',
|
|
41
|
+
config: {
|
|
42
|
+
data: JSON.stringify({ documents: ['document1', 'document2'] }),
|
|
43
|
+
headers: {
|
|
44
|
+
Authorization: 'Bearer test-key',
|
|
45
|
+
},
|
|
46
|
+
method: 'post',
|
|
47
|
+
url,
|
|
48
|
+
},
|
|
49
|
+
response: {
|
|
50
|
+
data: responseData,
|
|
51
|
+
status: 500,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
4
55
|
describe('JinaReranker', () => {
|
|
5
56
|
const mockLogger = createDefaultLogger();
|
|
6
|
-
|
|
57
|
+
|
|
58
|
+
afterEach(() => {
|
|
59
|
+
jest.restoreAllMocks();
|
|
60
|
+
});
|
|
61
|
+
|
|
7
62
|
describe('constructor', () => {
|
|
8
63
|
it('should use default API URL when no apiUrl is provided', () => {
|
|
9
64
|
const reranker = new JinaReranker({
|
|
10
65
|
apiKey: 'test-key',
|
|
11
66
|
logger: mockLogger,
|
|
12
67
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const apiUrl = (reranker as any).apiUrl;
|
|
68
|
+
|
|
69
|
+
const apiUrl = getApiUrl(reranker);
|
|
16
70
|
expect(apiUrl).toBe('https://api.jina.ai/v1/rerank');
|
|
17
71
|
});
|
|
18
72
|
|
|
@@ -23,25 +77,24 @@ describe('JinaReranker', () => {
|
|
|
23
77
|
apiUrl: customUrl,
|
|
24
78
|
logger: mockLogger,
|
|
25
79
|
});
|
|
26
|
-
|
|
27
|
-
const apiUrl = (reranker
|
|
80
|
+
|
|
81
|
+
const apiUrl = getApiUrl(reranker);
|
|
28
82
|
expect(apiUrl).toBe(customUrl);
|
|
29
83
|
});
|
|
30
84
|
|
|
31
85
|
it('should use environment variable JINA_API_URL when available', () => {
|
|
32
86
|
const originalEnv = process.env.JINA_API_URL;
|
|
33
87
|
process.env.JINA_API_URL = 'https://env-jina-endpoint.com/v1/rerank';
|
|
34
|
-
|
|
88
|
+
|
|
35
89
|
const reranker = new JinaReranker({
|
|
36
90
|
apiKey: 'test-key',
|
|
37
91
|
logger: mockLogger,
|
|
38
92
|
});
|
|
39
|
-
|
|
40
|
-
const apiUrl = (reranker
|
|
93
|
+
|
|
94
|
+
const apiUrl = getApiUrl(reranker);
|
|
41
95
|
expect(apiUrl).toBe('https://env-jina-endpoint.com/v1/rerank');
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (originalEnv) {
|
|
96
|
+
|
|
97
|
+
if (typeof originalEnv === 'string') {
|
|
45
98
|
process.env.JINA_API_URL = originalEnv;
|
|
46
99
|
} else {
|
|
47
100
|
delete process.env.JINA_API_URL;
|
|
@@ -51,19 +104,18 @@ describe('JinaReranker', () => {
|
|
|
51
104
|
it('should prioritize explicit apiUrl over environment variable', () => {
|
|
52
105
|
const originalEnv = process.env.JINA_API_URL;
|
|
53
106
|
process.env.JINA_API_URL = 'https://env-jina-endpoint.com/v1/rerank';
|
|
54
|
-
|
|
107
|
+
|
|
55
108
|
const customUrl = 'https://explicit-jina-endpoint.com/v1/rerank';
|
|
56
109
|
const reranker = new JinaReranker({
|
|
57
110
|
apiKey: 'test-key',
|
|
58
111
|
apiUrl: customUrl,
|
|
59
112
|
logger: mockLogger,
|
|
60
113
|
});
|
|
61
|
-
|
|
62
|
-
const apiUrl = (reranker
|
|
114
|
+
|
|
115
|
+
const apiUrl = getApiUrl(reranker);
|
|
63
116
|
expect(apiUrl).toBe(customUrl);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (originalEnv) {
|
|
117
|
+
|
|
118
|
+
if (typeof originalEnv === 'string') {
|
|
67
119
|
process.env.JINA_API_URL = originalEnv;
|
|
68
120
|
} else {
|
|
69
121
|
delete process.env.JINA_API_URL;
|
|
@@ -79,27 +131,80 @@ describe('JinaReranker', () => {
|
|
|
79
131
|
apiUrl: customUrl,
|
|
80
132
|
logger: mockLogger,
|
|
81
133
|
});
|
|
82
|
-
|
|
83
|
-
const logSpy = jest
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
134
|
+
|
|
135
|
+
const logSpy = jest
|
|
136
|
+
.spyOn(mockLogger, 'debug')
|
|
137
|
+
.mockImplementation(() => mockLogger);
|
|
138
|
+
jest.spyOn(mockLogger, 'error').mockImplementation(() => mockLogger);
|
|
139
|
+
jest
|
|
140
|
+
.spyOn(axios, 'post')
|
|
141
|
+
.mockRejectedValueOnce(new Error('Network error'));
|
|
142
|
+
|
|
143
|
+
await reranker.rerank('test query', ['document1', 'document2'], 2);
|
|
144
|
+
|
|
91
145
|
expect(logSpy).toHaveBeenCalledWith(
|
|
92
|
-
expect.stringContaining(
|
|
146
|
+
expect.stringContaining(
|
|
147
|
+
`Reranking 2 chunks with Jina using API URL: ${customUrl}`
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should log compact Axios errors without request internals', async () => {
|
|
153
|
+
const customUrl = 'https://test-jina-endpoint.com/v1/rerank?api_key=hidden';
|
|
154
|
+
const reranker = new JinaReranker({
|
|
155
|
+
apiKey: 'test-key',
|
|
156
|
+
apiUrl: customUrl,
|
|
157
|
+
logger: mockLogger,
|
|
158
|
+
});
|
|
159
|
+
const errorSpy = jest
|
|
160
|
+
.spyOn(mockLogger, 'error')
|
|
161
|
+
.mockImplementation(() => mockLogger);
|
|
162
|
+
jest.spyOn(mockLogger, 'debug').mockImplementation(() => mockLogger);
|
|
163
|
+
jest.spyOn(axios, 'isAxiosError').mockReturnValue(true);
|
|
164
|
+
jest.spyOn(axios, 'post').mockRejectedValueOnce(
|
|
165
|
+
createAxiosErrorFixture(customUrl, {
|
|
166
|
+
message: 'upstream failed',
|
|
167
|
+
details: 'x'.repeat(5000),
|
|
168
|
+
})
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const result = await reranker.rerank(
|
|
172
|
+
'test query',
|
|
173
|
+
['document1', 'document2'],
|
|
174
|
+
2
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
expect(result).toEqual([
|
|
178
|
+
{ text: 'document1', score: 0 },
|
|
179
|
+
{ text: 'document2', score: 0 },
|
|
180
|
+
]);
|
|
181
|
+
expect(errorSpy).toHaveBeenCalledWith(
|
|
182
|
+
'Error using Jina reranker',
|
|
183
|
+
expect.objectContaining({
|
|
184
|
+
code: 'ERR_BAD_RESPONSE',
|
|
185
|
+
message: 'Request failed with status code 500',
|
|
186
|
+
method: 'POST',
|
|
187
|
+
name: 'Error',
|
|
188
|
+
responseDataSummary: 'object(2)',
|
|
189
|
+
status: 500,
|
|
190
|
+
url: 'https://test-jina-endpoint.com/v1/rerank',
|
|
191
|
+
})
|
|
93
192
|
);
|
|
94
|
-
|
|
95
|
-
|
|
193
|
+
|
|
194
|
+
const metadata = errorSpy.mock.calls.flat()[1];
|
|
195
|
+
const serializedMetadata = JSON.stringify(metadata);
|
|
196
|
+
|
|
197
|
+
expect(serializedMetadata).not.toContain('upstream failed');
|
|
198
|
+
expect(serializedMetadata).not.toContain('Authorization');
|
|
199
|
+
expect(serializedMetadata).not.toContain('api_key');
|
|
200
|
+
expect(serializedMetadata).not.toContain('document1');
|
|
201
|
+
expect(serializedMetadata).not.toContain('test-key');
|
|
202
|
+
expect(serializedMetadata.length).toBeLessThan(500);
|
|
96
203
|
});
|
|
97
204
|
});
|
|
98
205
|
});
|
|
99
206
|
|
|
100
207
|
describe('createReranker', () => {
|
|
101
|
-
const { createReranker } = require('./rerankers');
|
|
102
|
-
|
|
103
208
|
it('should create JinaReranker with jinaApiUrl when provided', () => {
|
|
104
209
|
const customUrl = 'https://custom-jina-endpoint.com/v1/rerank';
|
|
105
210
|
const reranker = createReranker({
|
|
@@ -107,9 +212,12 @@ describe('createReranker', () => {
|
|
|
107
212
|
jinaApiKey: 'test-key',
|
|
108
213
|
jinaApiUrl: customUrl,
|
|
109
214
|
});
|
|
110
|
-
|
|
215
|
+
|
|
111
216
|
expect(reranker).toBeInstanceOf(JinaReranker);
|
|
112
|
-
|
|
217
|
+
if (!(reranker instanceof JinaReranker)) {
|
|
218
|
+
throw new Error('Expected createReranker to return a JinaReranker.');
|
|
219
|
+
}
|
|
220
|
+
const apiUrl = getApiUrl(reranker);
|
|
113
221
|
expect(apiUrl).toBe(customUrl);
|
|
114
222
|
});
|
|
115
223
|
|
|
@@ -118,9 +226,12 @@ describe('createReranker', () => {
|
|
|
118
226
|
rerankerType: 'jina',
|
|
119
227
|
jinaApiKey: 'test-key',
|
|
120
228
|
});
|
|
121
|
-
|
|
229
|
+
|
|
122
230
|
expect(reranker).toBeInstanceOf(JinaReranker);
|
|
123
|
-
|
|
231
|
+
if (!(reranker instanceof JinaReranker)) {
|
|
232
|
+
throw new Error('Expected createReranker to return a JinaReranker.');
|
|
233
|
+
}
|
|
234
|
+
const apiUrl = getApiUrl(reranker);
|
|
124
235
|
expect(apiUrl).toBe('https://api.jina.ai/v1/rerank');
|
|
125
236
|
});
|
|
126
237
|
});
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import type * as t from './types';
|
|
3
|
-
import { createDefaultLogger } from './utils';
|
|
3
|
+
import { createDefaultLogger, formatErrorForLog } from './utils';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_JINA_API_URL = 'https://api.jina.ai/v1/rerank';
|
|
6
|
+
|
|
7
|
+
const getDefaultJinaApiUrl = (): string =>
|
|
8
|
+
process.env.JINA_API_URL != null && process.env.JINA_API_URL !== ''
|
|
9
|
+
? process.env.JINA_API_URL
|
|
10
|
+
: DEFAULT_JINA_API_URL;
|
|
4
11
|
|
|
5
12
|
export abstract class BaseReranker {
|
|
6
13
|
protected apiKey: string | undefined;
|
|
@@ -32,7 +39,7 @@ export class JinaReranker extends BaseReranker {
|
|
|
32
39
|
|
|
33
40
|
constructor({
|
|
34
41
|
apiKey = process.env.JINA_API_KEY,
|
|
35
|
-
apiUrl =
|
|
42
|
+
apiUrl = getDefaultJinaApiUrl(),
|
|
36
43
|
logger,
|
|
37
44
|
}: {
|
|
38
45
|
apiKey?: string;
|
|
@@ -107,7 +114,7 @@ export class JinaReranker extends BaseReranker {
|
|
|
107
114
|
return this.getDefaultRanking(documents, topK);
|
|
108
115
|
}
|
|
109
116
|
} catch (error) {
|
|
110
|
-
this.logger.error('Error using Jina reranker
|
|
117
|
+
this.logger.error('Error using Jina reranker', formatErrorForLog(error));
|
|
111
118
|
// Fallback to default ranking on error
|
|
112
119
|
return this.getDefaultRanking(documents, topK);
|
|
113
120
|
}
|
|
@@ -174,7 +181,10 @@ export class CohereReranker extends BaseReranker {
|
|
|
174
181
|
return this.getDefaultRanking(documents, topK);
|
|
175
182
|
}
|
|
176
183
|
} catch (error) {
|
|
177
|
-
this.logger.error(
|
|
184
|
+
this.logger.error(
|
|
185
|
+
'Error using Cohere reranker',
|
|
186
|
+
formatErrorForLog(error)
|
|
187
|
+
);
|
|
178
188
|
// Fallback to default ranking on error
|
|
179
189
|
return this.getDefaultRanking(documents, topK);
|
|
180
190
|
}
|
|
@@ -3,7 +3,7 @@ import type * as t from './types';
|
|
|
3
3
|
|
|
4
4
|
const DEFAULT_TAVILY_TIMEOUT = 15000;
|
|
5
5
|
|
|
6
|
-
const TAVILY_COUNTRY_ALIASES: Record<string, string
|
|
6
|
+
const TAVILY_COUNTRY_ALIASES: Partial<Record<string, string>> = {
|
|
7
7
|
ba: 'bosnia and herzegovina',
|
|
8
8
|
cg: 'congo',
|
|
9
9
|
cz: 'czech republic',
|
|
@@ -319,7 +319,7 @@ export const createTavilyAPI = (
|
|
|
319
319
|
if (tavilyCountry != null) {
|
|
320
320
|
payload.country = tavilyCountry;
|
|
321
321
|
}
|
|
322
|
-
if (type === 'images' || options?.includeImages) {
|
|
322
|
+
if (type === 'images' || options?.includeImages === true) {
|
|
323
323
|
payload.include_images = true;
|
|
324
324
|
}
|
|
325
325
|
if (options?.includeAnswer != null) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Logger as WinstonLogger } from 'winston';
|
|
2
1
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
2
|
+
import type { Logger as WinstonLogger } from 'winston';
|
|
3
3
|
import type { BaseReranker } from './rerankers';
|
|
4
4
|
import { DATE_RANGE } from './schema';
|
|
5
5
|
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
|
|
3
|
+
import { isAxiosError } from 'axios';
|
|
4
|
+
|
|
5
|
+
import type { AxiosError } from 'axios';
|
|
3
6
|
import type * as t from './types';
|
|
4
7
|
|
|
8
|
+
const LOG_VALUE_MAX_LENGTH = 2048;
|
|
9
|
+
|
|
10
|
+
export interface SafeErrorLog {
|
|
11
|
+
message: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
code?: string;
|
|
14
|
+
status?: number;
|
|
15
|
+
method?: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
responseDataSummary?: string;
|
|
18
|
+
value?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
5
21
|
/**
|
|
6
22
|
* Singleton instance of the default logger
|
|
7
23
|
*/
|
|
@@ -24,6 +40,83 @@ export const createDefaultLogger = (): t.Logger => {
|
|
|
24
40
|
return defaultLoggerInstance;
|
|
25
41
|
};
|
|
26
42
|
|
|
43
|
+
const truncateLogValue = (value: string): string =>
|
|
44
|
+
value.length <= LOG_VALUE_MAX_LENGTH
|
|
45
|
+
? value
|
|
46
|
+
: `${value.slice(0, LOG_VALUE_MAX_LENGTH)}... [truncated]`;
|
|
47
|
+
|
|
48
|
+
const summarizeLogValue = (value: unknown): string => {
|
|
49
|
+
if (value === null) {
|
|
50
|
+
return 'null';
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(value)) {
|
|
53
|
+
return `array(${value.length})`;
|
|
54
|
+
}
|
|
55
|
+
if (typeof value === 'string') {
|
|
56
|
+
return `string(${value.length})`;
|
|
57
|
+
}
|
|
58
|
+
if (typeof value === 'object') {
|
|
59
|
+
return `object(${Object.keys(value).length})`;
|
|
60
|
+
}
|
|
61
|
+
return typeof value;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const sanitizeUrlForLog = (url: string): string => {
|
|
65
|
+
try {
|
|
66
|
+
const parsed = new URL(url);
|
|
67
|
+
return truncateLogValue(`${parsed.origin}${parsed.pathname}`);
|
|
68
|
+
} catch {
|
|
69
|
+
return truncateLogValue(url.split('?')[0].split('#')[0]);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const formatAxiosErrorForLog = (
|
|
74
|
+
error: AxiosError<unknown, unknown>
|
|
75
|
+
): SafeErrorLog => {
|
|
76
|
+
const log: SafeErrorLog = {
|
|
77
|
+
message: error.message,
|
|
78
|
+
name: error.name,
|
|
79
|
+
};
|
|
80
|
+
const { code, config, response, status } = error;
|
|
81
|
+
const responseStatus = response?.status ?? status;
|
|
82
|
+
const method = config?.method;
|
|
83
|
+
const url = config?.url;
|
|
84
|
+
|
|
85
|
+
if (typeof code === 'string' && code !== '') {
|
|
86
|
+
log.code = code;
|
|
87
|
+
}
|
|
88
|
+
if (responseStatus != null) {
|
|
89
|
+
log.status = responseStatus;
|
|
90
|
+
}
|
|
91
|
+
if (typeof method === 'string' && method !== '') {
|
|
92
|
+
log.method = method.toUpperCase();
|
|
93
|
+
}
|
|
94
|
+
if (typeof url === 'string' && url !== '') {
|
|
95
|
+
log.url = sanitizeUrlForLog(url);
|
|
96
|
+
}
|
|
97
|
+
if (typeof response?.data !== 'undefined') {
|
|
98
|
+
log.responseDataSummary = summarizeLogValue(response.data);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return log;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const formatErrorForLog = (error: unknown): SafeErrorLog => {
|
|
105
|
+
if (isAxiosError<unknown, unknown>(error)) {
|
|
106
|
+
return formatAxiosErrorForLog(error);
|
|
107
|
+
}
|
|
108
|
+
if (error instanceof Error) {
|
|
109
|
+
return {
|
|
110
|
+
message: error.message,
|
|
111
|
+
name: error.name,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
message: String(error),
|
|
116
|
+
value: summarizeLogValue(error),
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
27
120
|
export const fileExtRegex =
|
|
28
121
|
/\.(pdf|jpe?g|png|gif|svg|webp|bmp|ico|tiff?|avif|heic|doc[xm]?|xls[xm]?|ppt[xm]?|zip|rar|mp[34]|mov|avi|wav)(?:\?.*)?$/i;
|
|
29
122
|
|
|
@@ -33,16 +126,13 @@ export const getDomainName = (
|
|
|
33
126
|
logger?: t.Logger
|
|
34
127
|
): string | undefined => {
|
|
35
128
|
try {
|
|
36
|
-
const sourceUrl =
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
typeof
|
|
40
|
-
|
|
41
|
-
: typeof metadataUrl === 'string'
|
|
42
|
-
? metadataUrl
|
|
43
|
-
: link || '';
|
|
129
|
+
const sourceUrl =
|
|
130
|
+
typeof metadata?.sourceURL === 'string' ? metadata.sourceURL : undefined;
|
|
131
|
+
const metadataUrl =
|
|
132
|
+
typeof metadata?.url === 'string' ? metadata.url : undefined;
|
|
133
|
+
const url = sourceUrl ?? metadataUrl ?? link;
|
|
44
134
|
const domain = new URL(url).hostname.replace(/^www\./, '');
|
|
45
|
-
if (domain) {
|
|
135
|
+
if (domain !== '') {
|
|
46
136
|
return domain;
|
|
47
137
|
}
|
|
48
138
|
} catch (e) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { nanoid } from 'nanoid';
|
|
2
|
-
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
3
2
|
import { HumanMessage } from '@langchain/core/messages';
|
|
4
|
-
import
|
|
3
|
+
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
5
4
|
import type { Callbacks } from '@langchain/core/callbacks/manager';
|
|
5
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
6
6
|
import type {
|
|
7
7
|
AgentInputs,
|
|
8
8
|
MessageDeltaEvent,
|
|
@@ -23,8 +23,8 @@ import type {
|
|
|
23
23
|
import type { AggregatedHookResult, HookRegistry } from '@/hooks';
|
|
24
24
|
import type { AgentContext } from '@/agents/AgentContext';
|
|
25
25
|
import type { StandardGraph } from '@/graphs/Graph';
|
|
26
|
-
import { GraphEvents, Callback, StepTypes } from '@/common';
|
|
27
26
|
import type { HandlerRegistry } from '@/events';
|
|
27
|
+
import { GraphEvents, Callback, StepTypes } from '@/common';
|
|
28
28
|
import { executeHooks } from '@/hooks';
|
|
29
29
|
|
|
30
30
|
const DEFAULT_MAX_TURNS = 25;
|
|
@@ -797,7 +797,9 @@ function sanitizeToolCallForUpdate(
|
|
|
797
797
|
return sanitized;
|
|
798
798
|
}
|
|
799
799
|
|
|
800
|
-
function sanitizeRunStepUpdateData(
|
|
800
|
+
function sanitizeRunStepUpdateData(
|
|
801
|
+
data: unknown
|
|
802
|
+
): SanitizedRunStep | undefined {
|
|
801
803
|
if (!isObjectLike(data)) {
|
|
802
804
|
return undefined;
|
|
803
805
|
}
|
|
@@ -879,7 +881,9 @@ function sanitizeReasoningDeltaUpdateData(
|
|
|
879
881
|
return sanitized;
|
|
880
882
|
}
|
|
881
883
|
|
|
882
|
-
function sanitizeStepDetails(
|
|
884
|
+
function sanitizeStepDetails(
|
|
885
|
+
stepDetails: unknown
|
|
886
|
+
): SanitizedStepDetails | undefined {
|
|
883
887
|
if (!isObjectLike(stepDetails)) {
|
|
884
888
|
return undefined;
|
|
885
889
|
}
|
|
@@ -929,7 +933,9 @@ function sanitizeToolCallDelta(
|
|
|
929
933
|
return sanitized;
|
|
930
934
|
}
|
|
931
935
|
|
|
932
|
-
function sanitizeStepCompleted(
|
|
936
|
+
function sanitizeStepCompleted(
|
|
937
|
+
data: unknown
|
|
938
|
+
): SanitizedStepCompleted | undefined {
|
|
933
939
|
if (!isObjectLike(data)) {
|
|
934
940
|
return undefined;
|
|
935
941
|
}
|
package/src/types/graph.ts
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
// src/types/graph.ts
|
|
2
|
-
import type { START, StateGraph, StateGraphArgs } from '@langchain/langgraph';
|
|
3
|
-
import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
|
|
4
2
|
import type {
|
|
5
3
|
BaseMessage,
|
|
6
4
|
AIMessageChunk,
|
|
7
5
|
SystemMessage,
|
|
8
6
|
} from '@langchain/core/messages';
|
|
7
|
+
import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
|
|
8
|
+
import type { START, StateGraph, StateGraphArgs } from '@langchain/langgraph';
|
|
9
9
|
import type { RunnableConfig, Runnable } from '@langchain/core/runnables';
|
|
10
10
|
import type { ChatGenerationChunk } from '@langchain/core/outputs';
|
|
11
11
|
import type { GoogleAIToolType } from '@langchain/google-common';
|
|
12
|
-
import type {
|
|
13
|
-
ToolMap,
|
|
14
|
-
ToolEndEvent,
|
|
15
|
-
GenericTool,
|
|
16
|
-
LCTool,
|
|
17
|
-
ToolExecuteBatchRequest,
|
|
18
|
-
} from '@/types/tools';
|
|
19
|
-
import type { Providers, Callback, GraphNodeKeys } from '@/common';
|
|
20
|
-
import type { StandardGraph, MultiAgentGraph } from '@/graphs';
|
|
21
|
-
import type { ClientOptions } from '@/types/llm';
|
|
22
12
|
import type {
|
|
23
13
|
SummarizationNodeInput,
|
|
24
14
|
SummarizeCompleteEvent,
|
|
@@ -26,12 +16,22 @@ import type {
|
|
|
26
16
|
SummarizeStartEvent,
|
|
27
17
|
SummarizeDeltaEvent,
|
|
28
18
|
} from '@/types/summarize';
|
|
19
|
+
import type {
|
|
20
|
+
ToolMap,
|
|
21
|
+
ToolEndEvent,
|
|
22
|
+
GenericTool,
|
|
23
|
+
LCTool,
|
|
24
|
+
ToolExecuteBatchRequest,
|
|
25
|
+
} from '@/types/tools';
|
|
29
26
|
import type {
|
|
30
27
|
RunStep,
|
|
31
28
|
RunStepDeltaEvent,
|
|
32
29
|
MessageDeltaEvent,
|
|
33
30
|
ReasoningDeltaEvent,
|
|
34
31
|
} from '@/types/stream';
|
|
32
|
+
import type { Providers, Callback, GraphNodeKeys } from '@/common';
|
|
33
|
+
import type { StandardGraph, MultiAgentGraph } from '@/graphs';
|
|
34
|
+
import type { ClientOptions } from '@/types/llm';
|
|
35
35
|
import type { TokenCounter } from '@/types/run';
|
|
36
36
|
|
|
37
37
|
/** Interface for bound model with stream and invoke methods */
|
package/src/types/llm.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
// src/types/llm.ts
|
|
2
2
|
import { ChatMistralAI } from '@langchain/mistralai';
|
|
3
|
-
import type {
|
|
4
|
-
BindToolsInput,
|
|
5
|
-
BaseChatModelParams,
|
|
6
|
-
} from '@langchain/core/language_models/chat_models';
|
|
7
3
|
import type {
|
|
8
4
|
OpenAIChatInput,
|
|
9
5
|
ChatOpenAIFields,
|
|
10
6
|
AzureOpenAIInput,
|
|
11
7
|
ClientOptions as OAIClientOptions,
|
|
12
8
|
} from '@langchain/openai';
|
|
9
|
+
import type {
|
|
10
|
+
BindToolsInput,
|
|
11
|
+
BaseChatModelParams,
|
|
12
|
+
} from '@langchain/core/language_models/chat_models';
|
|
13
13
|
import type { GoogleGenerativeAIChatInput } from '@langchain/google-genai';
|
|
14
14
|
import type { ChatVertexAIInput } from '@langchain/google-vertexai';
|
|
15
|
-
import type { ChatDeepSeekInput } from '@langchain/deepseek';
|
|
16
|
-
import type { ChatOpenRouterCallOptions } from '@/llm/openrouter';
|
|
17
15
|
import type { ChatBedrockConverseInput } from '@langchain/aws';
|
|
18
16
|
import type { ChatMistralAIInput } from '@langchain/mistralai';
|
|
17
|
+
import type { ChatDeepSeekInput } from '@langchain/deepseek';
|
|
19
18
|
import type { RequestOptions } from '@google/generative-ai';
|
|
20
19
|
import type { StructuredTool } from '@langchain/core/tools';
|
|
21
20
|
import type { AnthropicInput } from '@langchain/anthropic';
|
|
22
21
|
import type { Runnable } from '@langchain/core/runnables';
|
|
23
22
|
import type { OpenAI as OpenAIClient } from 'openai';
|
|
24
23
|
import type { ChatXAIInput } from '@langchain/xai';
|
|
24
|
+
import type { ChatOpenRouterCallOptions } from '@/llm/openrouter';
|
|
25
25
|
import {
|
|
26
26
|
AzureChatOpenAI,
|
|
27
27
|
ChatDeepSeek,
|
|
@@ -92,6 +92,7 @@ export type BedrockAnthropicClientOptions = BedrockAnthropicInput;
|
|
|
92
92
|
export type GoogleClientOptions = GoogleGenerativeAIChatInput & {
|
|
93
93
|
customHeaders?: RequestOptions['customHeaders'];
|
|
94
94
|
thinkingConfig?: GoogleThinkingConfig;
|
|
95
|
+
includeServerSideToolInvocations?: boolean;
|
|
95
96
|
};
|
|
96
97
|
export type DeepSeekClientOptions = Partial<ChatDeepSeekInput>;
|
|
97
98
|
export type XAIClientOptions = ChatXAIInput;
|
package/src/types/messages.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type Anthropic from '@anthropic-ai/sdk';
|
|
2
1
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import type Anthropic from '@anthropic-ai/sdk';
|
|
3
3
|
export type AnthropicMessages = Array<AnthropicMessage | BaseMessage>;
|
|
4
4
|
export type AnthropicMessage = Anthropic.MessageParam;
|
|
5
5
|
|
package/src/types/run.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
// src/types/run.ts
|
|
2
|
-
import type
|
|
2
|
+
import type { Callbacks } from '@langchain/core/callbacks/manager';
|
|
3
|
+
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
3
4
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
4
5
|
import type { StructuredTool } from '@langchain/core/tools';
|
|
5
|
-
import type
|
|
6
|
-
import type { Callbacks } from '@langchain/core/callbacks/manager';
|
|
7
|
-
import type * as s from '@/types/stream';
|
|
8
|
-
import type * as e from '@/common/enum';
|
|
9
|
-
import type * as g from '@/types/graph';
|
|
10
|
-
import type * as l from '@/types/llm';
|
|
6
|
+
import type * as z from 'zod';
|
|
11
7
|
import type {
|
|
12
8
|
ToolSessionMap,
|
|
13
9
|
ToolExecutionConfig,
|
|
@@ -16,6 +12,10 @@ import type {
|
|
|
16
12
|
} from '@/types/tools';
|
|
17
13
|
import type { HumanInTheLoopConfig } from '@/types/hitl';
|
|
18
14
|
import type { HookRegistry } from '@/hooks';
|
|
15
|
+
import type * as s from '@/types/stream';
|
|
16
|
+
import type * as e from '@/common/enum';
|
|
17
|
+
import type * as g from '@/types/graph';
|
|
18
|
+
import type * as l from '@/types/llm';
|
|
19
19
|
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
21
|
export type ZodObjectAny = z.ZodObject<any, any, any, any>;
|
package/src/types/stream.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/types/stream.ts
|
|
2
|
-
import type OpenAITypes from 'openai';
|
|
3
2
|
import type {
|
|
4
3
|
MessageContentImageUrl,
|
|
5
4
|
MessageContentText,
|
|
@@ -8,8 +7,9 @@ import type {
|
|
|
8
7
|
} from '@langchain/core/messages';
|
|
9
8
|
import type { ToolCall, ToolCallChunk } from '@langchain/core/messages/tool';
|
|
10
9
|
import type { LLMResult, Generation } from '@langchain/core/outputs';
|
|
11
|
-
import type { AnthropicContentBlock } from '@/llm/anthropic/types';
|
|
12
10
|
import type { Command } from '@langchain/langgraph';
|
|
11
|
+
import type OpenAITypes from 'openai';
|
|
12
|
+
import type { AnthropicContentBlock } from '@/llm/anthropic/types';
|
|
13
13
|
import type { SummarizeCompleteEvent } from '@/types/summarize';
|
|
14
14
|
import type { ToolEndEvent } from '@/types/tools';
|
|
15
15
|
import { StepTypes, ContentTypes, GraphEvents } from '@/common/enum';
|