@librechat/agents 4.2.11 → 4.2.13
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/graphs/Graph.cjs +15 -3
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/langfuse.cjs +63 -35
- package/dist/cjs/langfuse.cjs.map +1 -1
- package/dist/cjs/langfuseConfig.cjs +6 -0
- package/dist/cjs/langfuseConfig.cjs.map +1 -1
- package/dist/cjs/langfuseToolOutputTracing.cjs +1 -1
- package/dist/cjs/langfuseToolOutputTracing.cjs.map +1 -1
- package/dist/cjs/langfuseTraceShaping.cjs +18 -8
- package/dist/cjs/langfuseTraceShaping.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/index.cjs +4 -3
- package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/container.cjs +37 -0
- package/dist/cjs/llm/anthropic/utils/container.cjs.map +1 -0
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +25 -23
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +15 -21
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/stream_events.cjs +16 -14
- package/dist/cjs/llm/anthropic/utils/stream_events.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/index.cjs +1 -1
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/toolCache.cjs +1 -1
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs +19 -13
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/google/utils/common.cjs +59 -13
- package/dist/cjs/llm/google/utils/common.cjs.map +1 -1
- package/dist/cjs/llm/init.cjs +12 -2
- package/dist/cjs/llm/init.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +15 -2
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/responseToolArguments.cjs +62 -0
- package/dist/cjs/llm/openai/responseToolArguments.cjs.map +1 -0
- package/dist/cjs/llm/openrouter/index.cjs +11 -2
- package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
- package/dist/cjs/llm/openrouter/toolCache.cjs +1 -1
- package/dist/cjs/llm/prepareProviderRequest.cjs +35 -7
- package/dist/cjs/llm/prepareProviderRequest.cjs.map +1 -1
- package/dist/cjs/main.cjs +9 -3
- package/dist/cjs/messages/alternation.cjs +1 -1
- package/dist/cjs/messages/anthropicServerTools.cjs +20 -0
- package/dist/cjs/messages/anthropicServerTools.cjs.map +1 -0
- package/dist/cjs/messages/budget.cjs +1 -1
- package/dist/cjs/messages/cache.cjs +14 -1
- package/dist/cjs/messages/cache.cjs.map +1 -1
- package/dist/cjs/messages/core.cjs +4 -3
- package/dist/cjs/messages/core.cjs.map +1 -1
- package/dist/cjs/messages/format.cjs +3 -3
- package/dist/cjs/messages/index.cjs +1 -1
- package/dist/cjs/messages/prune.cjs +1 -1
- package/dist/cjs/messages/recency.cjs +1 -1
- package/dist/cjs/messages/toolResultTypes.cjs +21 -45
- package/dist/cjs/messages/toolResultTypes.cjs.map +1 -1
- package/dist/cjs/protection/providerText.cjs +4 -0
- package/dist/cjs/protection/providerText.cjs.map +1 -1
- package/dist/cjs/protection/toolResult.cjs +119 -0
- package/dist/cjs/protection/toolResult.cjs.map +1 -0
- package/dist/cjs/run.cjs +31 -13
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/runtime/admission.cjs +1 -1
- package/dist/cjs/runtime/client.cjs +3 -0
- package/dist/cjs/runtime/client.cjs.map +1 -1
- package/dist/cjs/stream.cjs +2 -1
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/summarization/node.cjs +9 -4
- package/dist/cjs/summarization/node.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +1 -1
- package/dist/cjs/tools/ToolNode.cjs +47 -14
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/local/CompileCheckTool.cjs +1 -1
- package/dist/cjs/tools/local/LocalCodingTools.cjs +1 -1
- package/dist/cjs/tools/search/content.cjs +163 -42
- package/dist/cjs/tools/search/content.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +8 -0
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/utils/events.cjs +2 -2
- package/dist/cjs/utils/events.cjs.map +1 -1
- package/dist/cjs/utils/tokens.cjs +7 -2
- package/dist/cjs/utils/tokens.cjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +15 -3
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/langfuse.mjs +63 -35
- package/dist/esm/langfuse.mjs.map +1 -1
- package/dist/esm/langfuseConfig.mjs +6 -1
- package/dist/esm/langfuseConfig.mjs.map +1 -1
- package/dist/esm/langfuseToolOutputTracing.mjs +2 -2
- package/dist/esm/langfuseToolOutputTracing.mjs.map +1 -1
- package/dist/esm/langfuseTraceShaping.mjs +18 -9
- package/dist/esm/langfuseTraceShaping.mjs.map +1 -1
- package/dist/esm/llm/anthropic/index.mjs +4 -3
- package/dist/esm/llm/anthropic/index.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/container.mjs +37 -0
- package/dist/esm/llm/anthropic/utils/container.mjs.map +1 -0
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs +25 -23
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs +15 -21
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/stream_events.mjs +16 -14
- package/dist/esm/llm/anthropic/utils/stream_events.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 +1 -1
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs +19 -14
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/google/utils/common.mjs +59 -13
- package/dist/esm/llm/google/utils/common.mjs.map +1 -1
- package/dist/esm/llm/init.mjs +12 -2
- package/dist/esm/llm/init.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +16 -3
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/llm/openai/responseToolArguments.mjs +62 -0
- package/dist/esm/llm/openai/responseToolArguments.mjs.map +1 -0
- package/dist/esm/llm/openrouter/index.mjs +11 -2
- package/dist/esm/llm/openrouter/index.mjs.map +1 -1
- package/dist/esm/llm/openrouter/toolCache.mjs +1 -1
- package/dist/esm/llm/prepareProviderRequest.mjs +35 -7
- package/dist/esm/llm/prepareProviderRequest.mjs.map +1 -1
- package/dist/esm/main.mjs +5 -4
- package/dist/esm/messages/alternation.mjs +1 -1
- package/dist/esm/messages/anthropicServerTools.mjs +18 -0
- package/dist/esm/messages/anthropicServerTools.mjs.map +1 -0
- package/dist/esm/messages/budget.mjs +1 -1
- package/dist/esm/messages/cache.mjs +12 -2
- package/dist/esm/messages/cache.mjs.map +1 -1
- package/dist/esm/messages/core.mjs +4 -3
- package/dist/esm/messages/core.mjs.map +1 -1
- package/dist/esm/messages/format.mjs +3 -3
- package/dist/esm/messages/index.mjs +1 -1
- package/dist/esm/messages/prune.mjs +1 -1
- package/dist/esm/messages/recency.mjs +1 -1
- package/dist/esm/messages/toolResultTypes.mjs +21 -45
- package/dist/esm/messages/toolResultTypes.mjs.map +1 -1
- package/dist/esm/protection/providerText.mjs +4 -1
- package/dist/esm/protection/providerText.mjs.map +1 -1
- package/dist/esm/protection/toolResult.mjs +114 -0
- package/dist/esm/protection/toolResult.mjs.map +1 -0
- package/dist/esm/run.mjs +32 -14
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/runtime/admission.mjs +1 -1
- package/dist/esm/runtime/client.mjs +3 -0
- package/dist/esm/runtime/client.mjs.map +1 -1
- package/dist/esm/stream.mjs +2 -1
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/summarization/node.mjs +9 -4
- package/dist/esm/summarization/node.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +1 -1
- package/dist/esm/tools/ToolNode.mjs +47 -14
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/local/CompileCheckTool.mjs +1 -1
- package/dist/esm/tools/local/LocalCodingTools.mjs +1 -1
- package/dist/esm/tools/search/content.mjs +163 -42
- package/dist/esm/tools/search/content.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +8 -0
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/utils/events.mjs +2 -2
- package/dist/esm/utils/events.mjs.map +1 -1
- package/dist/esm/utils/tokens.mjs +7 -2
- package/dist/esm/utils/tokens.mjs.map +1 -1
- package/dist/types/common/index.d.ts +2 -2
- package/dist/types/decisions/breaker.d.ts +2 -2
- package/dist/types/decisions/core.d.ts +13 -13
- package/dist/types/decisions/dialect.d.ts +1 -1
- package/dist/types/decisions/http.d.ts +2 -2
- package/dist/types/decisions/index.d.ts +5 -5
- package/dist/types/decisions/node.d.ts +2 -2
- package/dist/types/decisions/presets.d.ts +2 -2
- package/dist/types/decisions/probe.d.ts +1 -1
- package/dist/types/decisions/questions.d.ts +1 -1
- package/dist/types/decisions/structuredChat.d.ts +2 -2
- package/dist/types/decisions/transport.d.ts +1 -1
- package/dist/types/eventActor/EventActorExecutor.d.ts +1 -1
- package/dist/types/eventActor/index.d.ts +2 -2
- package/dist/types/graphs/Graph.d.ts +6 -2
- package/dist/types/graphs/MultiAgentGraph.d.ts +1 -1
- package/dist/types/graphs/applyGraphRuntimeConfig.d.ts +1 -1
- package/dist/types/graphs/graphFactory.d.ts +1 -1
- package/dist/types/graphs/index.d.ts +5 -5
- package/dist/types/harness/fileBindings.d.ts +2 -2
- package/dist/types/harness/fileService.d.ts +2 -2
- package/dist/types/harness/fileStream.d.ts +1 -1
- package/dist/types/harness/index.d.ts +15 -15
- package/dist/types/harness/model.d.ts +1 -1
- package/dist/types/harness/modelService.d.ts +2 -2
- package/dist/types/harness/modelStreamCallbacks.d.ts +1 -1
- package/dist/types/harness/providerText.d.ts +1 -1
- package/dist/types/hitl/index.d.ts +3 -3
- package/dist/types/hooks/HookRegistry.d.ts +1 -1
- package/dist/types/hooks/createToolPolicyHook.d.ts +1 -1
- package/dist/types/hooks/createWorkspacePolicyHook.d.ts +1 -1
- package/dist/types/hooks/executeHooks.d.ts +2 -2
- package/dist/types/hooks/index.d.ts +11 -11
- package/dist/types/index.d.ts +62 -60
- package/dist/types/langchain/index.d.ts +8 -8
- package/dist/types/langfuse.d.ts +7 -4
- package/dist/types/langfuseConfig.d.ts +5 -0
- package/dist/types/langfuseTraceShaping.d.ts +5 -0
- package/dist/types/llm/anthropic/utils/container.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/stream_events.d.ts +1 -1
- package/dist/types/llm/bedrock/index.d.ts +2 -3
- package/dist/types/llm/bedrock/utils/harmony.d.ts +1 -1
- package/dist/types/llm/bedrock/utils/index.d.ts +2 -2
- package/dist/types/llm/bedrock/utils/message_inputs.d.ts +3 -12
- package/dist/types/llm/bedrock/utils/message_outputs.d.ts +1 -1
- package/dist/types/llm/google/index.d.ts +2 -2
- package/dist/types/llm/google/utils/common.d.ts +1 -1
- package/dist/types/llm/google/utils/tools.d.ts +1 -1
- package/dist/types/llm/openai/index.d.ts +2 -1
- package/dist/types/llm/openai/responseToolArguments.d.ts +7 -0
- package/dist/types/llm/openrouter/index.d.ts +1 -0
- package/dist/types/llm/prepareProviderRequest.d.ts +4 -1
- package/dist/types/llm/providerRegistry.d.ts +1 -1
- package/dist/types/llm/providers.d.ts +1 -1
- package/dist/types/messages/anthropicServerTools.d.ts +13 -0
- package/dist/types/messages/cache.d.ts +13 -0
- package/dist/types/messages/contextPruning.d.ts +1 -1
- package/dist/types/messages/core.d.ts +4 -4
- package/dist/types/messages/format.d.ts +1 -1
- package/dist/types/messages/index.d.ts +21 -21
- package/dist/types/messages/prune.d.ts +1 -1
- package/dist/types/openai/index.d.ts +2 -2
- package/dist/types/openai/toolProjection.d.ts +1 -1
- package/dist/types/prompts/index.d.ts +2 -2
- package/dist/types/protection/providerText.d.ts +3 -1
- package/dist/types/protection/toolResult.d.ts +69 -0
- package/dist/types/provider-registration.d.ts +1 -1
- package/dist/types/rerank/bm25.d.ts +1 -1
- package/dist/types/rerank/core.d.ts +17 -17
- package/dist/types/rerank/crossEncoder.d.ts +3 -3
- package/dist/types/rerank/fallback.d.ts +1 -1
- package/dist/types/rerank/index.d.ts +2 -2
- package/dist/types/rerank/outcome.d.ts +2 -2
- package/dist/types/rerank/pin.d.ts +2 -2
- package/dist/types/rerank/search.d.ts +1 -1
- package/dist/types/rerank/systemone.d.ts +4 -4
- package/dist/types/rerank/types.d.ts +1 -1
- package/dist/types/run.d.ts +2 -0
- package/dist/types/runtime/admission.d.ts +1 -1
- package/dist/types/runtime/checkpoint.d.ts +1 -1
- package/dist/types/runtime/client.d.ts +2 -2
- package/dist/types/runtime/files.d.ts +4 -4
- package/dist/types/runtime/hostTools.d.ts +2 -2
- package/dist/types/runtime/index.d.ts +12 -12
- package/dist/types/runtime/model.d.ts +5 -5
- package/dist/types/runtime/policy.d.ts +3 -3
- package/dist/types/runtime/recovery/client.d.ts +3 -3
- package/dist/types/runtime/recovery/log.d.ts +2 -2
- package/dist/types/runtime/recovery/redis.d.ts +1 -1
- package/dist/types/runtime/recovery/server.d.ts +3 -3
- package/dist/types/runtime/resume.d.ts +1 -1
- package/dist/types/runtime/server.d.ts +3 -3
- package/dist/types/runtime/snapshot.d.ts +1 -1
- package/dist/types/runtime/types.d.ts +2 -2
- package/dist/types/session/AgentSession.d.ts +2 -2
- package/dist/types/session/JsonlSessionStore.d.ts +1 -1
- package/dist/types/session/deriveMessages.d.ts +1 -1
- package/dist/types/session/handlers.d.ts +1 -1
- package/dist/types/session/index.d.ts +7 -7
- package/dist/types/session/messageSerialization.d.ts +1 -1
- package/dist/types/session/sessionProjection.d.ts +3 -3
- package/dist/types/summarization/index.d.ts +2 -2
- package/dist/types/summarization/node.d.ts +2 -0
- package/dist/types/tools/BashProgrammaticToolCalling.d.ts +1 -1
- package/dist/types/tools/GitHubCompare.d.ts +6 -6
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +1 -1
- package/dist/types/tools/ReadFile.d.ts +6 -6
- package/dist/types/tools/SkillTool.d.ts +6 -6
- package/dist/types/tools/ToolNode.d.ts +5 -1
- package/dist/types/tools/cloudflare/index.d.ts +4 -4
- package/dist/types/tools/local/FileCheckpointer.d.ts +1 -1
- package/dist/types/tools/local/LocalExecutionEngine.d.ts +1 -1
- package/dist/types/tools/local/attachments.d.ts +1 -1
- package/dist/types/tools/local/index.d.ts +12 -12
- package/dist/types/tools/search/anthropic.d.ts +1 -1
- package/dist/types/tools/search/content.d.ts +38 -1
- package/dist/types/tools/search/crw-scraper.d.ts +1 -1
- package/dist/types/tools/search/crw-search.d.ts +1 -1
- package/dist/types/tools/search/firecrawl.d.ts +1 -1
- package/dist/types/tools/search/format.d.ts +1 -1
- package/dist/types/tools/search/highlights.d.ts +1 -1
- package/dist/types/tools/search/index.d.ts +3 -3
- package/dist/types/tools/search/keenable-scraper.d.ts +1 -1
- package/dist/types/tools/search/keenable-search.d.ts +1 -1
- package/dist/types/tools/search/metrics.d.ts +1 -1
- package/dist/types/tools/search/rerankers.d.ts +1 -1
- package/dist/types/tools/search/schema.d.ts +6 -6
- package/dist/types/tools/search/search.d.ts +1 -1
- package/dist/types/tools/search/serper-scraper.d.ts +1 -1
- package/dist/types/tools/search/tavily-scraper.d.ts +1 -1
- package/dist/types/tools/search/tavily-search.d.ts +1 -1
- package/dist/types/tools/search/tool.d.ts +3 -3
- package/dist/types/tools/search/types.d.ts +2 -2
- package/dist/types/tools/search/utils.d.ts +3 -3
- package/dist/types/tools/subagent/SubagentExecutionRegistry.d.ts +1 -1
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +9 -3
- package/dist/types/tools/subagent/diagnostics.d.ts +1 -1
- package/dist/types/tools/subagent/index.d.ts +7 -7
- package/dist/types/types/attachments.d.ts +25 -0
- package/dist/types/types/graph.d.ts +15 -0
- package/dist/types/types/index.d.ts +14 -13
- package/dist/types/types/llm.d.ts +2 -2
- package/dist/types/types/run.d.ts +7 -2
- package/dist/types/types/subagentTasks.d.ts +2 -2
- package/dist/types/types/tools.d.ts +6 -3
- package/dist/types/utils/events.d.ts +2 -1
- package/dist/types/utils/index.d.ts +10 -10
- package/dist/types/utils/tokens.d.ts +1 -0
- package/package.json +14 -12
- package/src/graphs/Graph.ts +32 -1
- package/src/index.ts +8 -0
- package/src/langfuse.ts +129 -41
- package/src/langfuseConfig.ts +14 -0
- package/src/langfuseToolOutputTracing.ts +5 -4
- package/src/langfuseTraceShaping.ts +49 -12
- package/src/llm/anthropic/index.ts +11 -3
- package/src/llm/anthropic/utils/container.ts +63 -0
- package/src/llm/anthropic/utils/message_inputs.ts +57 -51
- package/src/llm/anthropic/utils/message_outputs.ts +12 -39
- package/src/llm/anthropic/utils/stream_events.ts +17 -12
- package/src/llm/bedrock/index.ts +7 -5
- package/src/llm/bedrock/utils/message_inputs.ts +28 -35
- package/src/llm/google/utils/common.ts +88 -36
- package/src/llm/init.ts +35 -3
- package/src/llm/openai/index.ts +17 -2
- package/src/llm/openai/responseToolArguments.ts +104 -0
- package/src/llm/openrouter/index.ts +13 -0
- package/src/llm/prepareProviderRequest.ts +75 -13
- package/src/messages/anthropicServerTools.ts +24 -0
- package/src/messages/cache.ts +25 -5
- package/src/messages/core.ts +12 -11
- package/src/messages/toolResultTypes.ts +80 -88
- package/src/protection/providerText.ts +127 -40
- package/src/protection/toolResult.ts +272 -0
- package/src/run.ts +112 -47
- package/src/runtime/client.ts +7 -0
- package/src/stream.ts +7 -1
- package/src/summarization/node.ts +17 -4
- package/src/tools/ToolNode.ts +114 -18
- package/src/tools/search/content.ts +282 -62
- package/src/tools/subagent/SubagentExecutor.ts +12 -0
- package/src/types/attachments.ts +31 -0
- package/src/types/graph.ts +12 -0
- package/src/types/index.ts +1 -0
- package/src/types/run.ts +8 -1
- package/src/types/tools.ts +3 -0
- package/src/utils/events.ts +9 -2
- package/src/utils/tokens.ts +28 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { DEFAULT_SUBAGENT_DESCRIPTION, SubagentExecutor, filterSubagentResult, filterGraphSubagentResult, isGraphSubagentConfig, normalizeSubagentConfigs, normalizeSubagentConfigEntries, resolveSubagentConfigs, resolveSubagentConfigEntries, buildChildInputs, summarizeEvent, } from './SubagentExecutor';
|
|
2
|
-
export type { SubagentExecuteParams, SubagentExecuteResult, SubagentExecutorOptions, ChildGraphFactory, } from './SubagentExecutor';
|
|
3
|
-
export { InMemorySubagentTaskStore } from './InMemorySubagentTaskStore';
|
|
4
|
-
export type { InMemorySubagentTaskStoreOptions } from './InMemorySubagentTaskStore';
|
|
5
|
-
export { SubagentResolutionError, SubagentHostArgumentError, getSubagentResolutionFailureMessage, getSubagentHostArgumentFailureMessage, } from './diagnostics';
|
|
6
|
-
export { SUBAGENT_HOST_ARG_LIMITS, SELF_SUBAGENT_HOST_ARGS_SUPPORTED, buildSubagentHostArgProperties, resolveSubagentHostArgs, } from './hostArgs';
|
|
7
|
-
export type { SubagentHostArgumentFailure, SubagentHostArgumentRejection, SubagentResolutionPhase, SubagentResolutionCause, SubagentResolutionContext, SubagentResolutionDiagnostic, SubagentResolutionFailureHandler, } from './diagnostics';
|
|
1
|
+
export { DEFAULT_SUBAGENT_DESCRIPTION, SubagentExecutor, filterSubagentResult, filterGraphSubagentResult, isGraphSubagentConfig, normalizeSubagentConfigs, normalizeSubagentConfigEntries, resolveSubagentConfigs, resolveSubagentConfigEntries, buildChildInputs, summarizeEvent, } from './SubagentExecutor.js';
|
|
2
|
+
export type { SubagentExecuteParams, SubagentExecuteResult, SubagentExecutorOptions, ChildGraphFactory, } from './SubagentExecutor.js';
|
|
3
|
+
export { InMemorySubagentTaskStore } from './InMemorySubagentTaskStore.js';
|
|
4
|
+
export type { InMemorySubagentTaskStoreOptions } from './InMemorySubagentTaskStore.js';
|
|
5
|
+
export { SubagentResolutionError, SubagentHostArgumentError, getSubagentResolutionFailureMessage, getSubagentHostArgumentFailureMessage, } from './diagnostics.js';
|
|
6
|
+
export { SUBAGENT_HOST_ARG_LIMITS, SELF_SUBAGENT_HOST_ARGS_SUPPORTED, buildSubagentHostArgProperties, resolveSubagentHostArgs, } from './hostArgs.js';
|
|
7
|
+
export type { SubagentHostArgumentFailure, SubagentHostArgumentRejection, SubagentResolutionPhase, SubagentResolutionCause, SubagentResolutionContext, SubagentResolutionDiagnostic, SubagentResolutionFailureHandler, } from './diagnostics.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Data, MessageContentComplex } from '@langchain/core/messages';
|
|
2
|
+
import type { ProviderMessageProjectionMode } from '../llm/prepareProviderRequest.js';
|
|
3
|
+
import type { ProviderName } from './llm.js';
|
|
4
|
+
/** An attachment a message carries by reference: LangChain's `source_type: 'id'` data block. */
|
|
5
|
+
export type AttachmentReference = Data.IDContentBlock;
|
|
6
|
+
/** The provider request a reference is being resolved for. */
|
|
7
|
+
export interface AttachmentTarget {
|
|
8
|
+
provider: ProviderName;
|
|
9
|
+
modelId?: string;
|
|
10
|
+
projectionMode: ProviderMessageProjectionMode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Supplies the content a referenced attachment stands for, as the block the
|
|
14
|
+
* target provider accepts. Called for each reference while a provider request
|
|
15
|
+
* is prepared. The result goes into that request only, so graph state and
|
|
16
|
+
* checkpoints keep the reference and never hold the attachment's bytes.
|
|
17
|
+
*
|
|
18
|
+
* - `undefined`: not this host's reference (a provider-side file id); the block is left as it is.
|
|
19
|
+
* - `null`: nothing to send to this provider; the block is dropped.
|
|
20
|
+
* - a block: replaces the reference as returned, without further projection.
|
|
21
|
+
*
|
|
22
|
+
* Synchronous and repeatable: one model call can prepare its request more than
|
|
23
|
+
* once (a fallback provider, an overflow retry), each for its own target.
|
|
24
|
+
*/
|
|
25
|
+
export type AttachmentResolver = (reference: AttachmentReference, target: AttachmentTarget) => MessageContentComplex | null | undefined;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ProviderTextProtection } from '../protection/providerText.js';
|
|
2
|
+
import type { ToolResultProtection } from '../protection/toolResult.js';
|
|
3
|
+
import type { AttachmentResolver } from './attachments.js';
|
|
2
4
|
import type { BaseMessage, AIMessageChunk, SystemMessage, UsageMetadata } from '@langchain/core/messages';
|
|
3
5
|
import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
|
|
4
6
|
import type { START, StateGraph, StateGraphArgs } from '@langchain/langgraph';
|
|
@@ -289,6 +291,10 @@ export type ModelEndData = (StreamEventData & {
|
|
|
289
291
|
export type GraphTools = GenericTool[] | BindToolsInput[] | GoogleAIToolType[];
|
|
290
292
|
export type StandardGraphInput = {
|
|
291
293
|
providerTextProtection?: ProviderTextProtection;
|
|
294
|
+
/** Host inspection of selected tools' result text, for every graph of the run. */
|
|
295
|
+
toolResultProtection?: ToolResultProtection;
|
|
296
|
+
/** Resolves attachments that messages carry by reference; see {@link AttachmentResolver}. */
|
|
297
|
+
resolveAttachment?: AttachmentResolver;
|
|
292
298
|
runId?: string;
|
|
293
299
|
signal?: AbortSignal;
|
|
294
300
|
agents: AgentInputs[];
|
|
@@ -802,6 +808,15 @@ export interface LangfuseConfig {
|
|
|
802
808
|
* from the run/message id, without a trace lookup. Default: random ids.
|
|
803
809
|
*/
|
|
804
810
|
deterministicTraceId?: boolean;
|
|
811
|
+
/**
|
|
812
|
+
* Skills the agent can load with the `skill` tool, reported to Langfuse on
|
|
813
|
+
* the observations its run starts. `name` matches the tool's `skillName`;
|
|
814
|
+
* `version` is the skill's Langfuse version, when it has one.
|
|
815
|
+
*/
|
|
816
|
+
skillsAvailable?: {
|
|
817
|
+
name: string;
|
|
818
|
+
version?: number;
|
|
819
|
+
}[];
|
|
805
820
|
}
|
|
806
821
|
interface AgentInputFields {
|
|
807
822
|
agentId: string;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
1
|
+
export * from './attachments.js';
|
|
2
|
+
export * from './graph.js';
|
|
3
|
+
export * from './hitl.js';
|
|
4
|
+
export * from './llm.js';
|
|
5
|
+
export * from './messages.js';
|
|
6
|
+
export * from './run.js';
|
|
7
|
+
export * from './skill.js';
|
|
8
|
+
export * from './stream.js';
|
|
9
|
+
export * from './subagentTasks.js';
|
|
10
|
+
export * from './tools.js';
|
|
11
|
+
export * from './summarize.js';
|
|
12
|
+
export * from './activityLabel.js';
|
|
13
|
+
export * from './assistantPhase.js';
|
|
14
|
+
export * from './reasoningLabel.js';
|
|
@@ -12,7 +12,7 @@ import type { AnthropicInput } from '@langchain/anthropic';
|
|
|
12
12
|
import type { Runnable } from '@langchain/core/runnables';
|
|
13
13
|
import type { OpenAI as OpenAIClient } from 'openai';
|
|
14
14
|
import type { ChatXAIInput } from '@langchain/xai';
|
|
15
|
-
import type { CustomProviderOptionsMap } from '../provider-registration';
|
|
15
|
+
import type { CustomProviderOptionsMap } from '../provider-registration.js';
|
|
16
16
|
import type { ChatOpenRouterCallOptions } from '../llm/openrouter/index.js';
|
|
17
17
|
import type { PromptCacheTtl } from '../messages/cache.js';
|
|
18
18
|
import { AzureChatOpenAI, ChatDeepSeek, ChatMoonshot, ChatOpenAI, ChatXAI } from '../llm/openai/index.js';
|
|
@@ -221,4 +221,4 @@ export type ChatModelInstance = BaseChatModel;
|
|
|
221
221
|
export type ModelWithTools = BaseChatModel & {
|
|
222
222
|
bindTools(tools: CommonToolType[]): Runnable;
|
|
223
223
|
};
|
|
224
|
-
export type { CustomProviderOptionsMap } from '../provider-registration';
|
|
224
|
+
export type { CustomProviderOptionsMap } from '../provider-registration.js';
|
|
@@ -25,8 +25,9 @@ export type LegacyGraphConfig = BaseGraphConfig & {
|
|
|
25
25
|
/** `streamLimits` is excluded because legacy graphs receive limits only
|
|
26
26
|
* via the top-level `RunConfig.streamLimits`; accepting the field here
|
|
27
27
|
* would type-check but be silently ignored by `createLegacyGraph`.
|
|
28
|
-
* Required provider-text protection also belongs only to RunConfig
|
|
29
|
-
|
|
28
|
+
* Required provider-text protection also belongs only to RunConfig, as
|
|
29
|
+
* does the attachment resolver. */
|
|
30
|
+
'provider' | 'clientOptions' | 'agents' | 'streamLimits' | 'providerTextProtection' | 'toolResultProtection' | 'resolveAttachment'> & Omit<g.AgentInputs, 'provider' | 'clientOptions' | 'agentId'>;
|
|
30
31
|
export type SupervisedGraphConfig = BaseGraphConfig & {
|
|
31
32
|
type: 'supervised';
|
|
32
33
|
/** Enable supervised router; when false, fall back to standard loop */
|
|
@@ -319,6 +320,10 @@ export type RunConfig = {
|
|
|
319
320
|
* opt-in. See {@link StreamLimits}.
|
|
320
321
|
*/
|
|
321
322
|
providerTextProtection?: g.StandardGraphInput['providerTextProtection'];
|
|
323
|
+
/** Host inspection of selected tools' result text. Default off. */
|
|
324
|
+
toolResultProtection?: g.StandardGraphInput['toolResultProtection'];
|
|
325
|
+
/** Resolves attachments that messages carry by reference, for every graph of the run. */
|
|
326
|
+
resolveAttachment?: g.StandardGraphInput['resolveAttachment'];
|
|
322
327
|
streamLimits?: StreamLimits;
|
|
323
328
|
returnContent?: boolean;
|
|
324
329
|
tokenCounter?: TokenCounter;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
-
import type { SubagentUpdateEvent } from './graph';
|
|
3
|
-
import type { InjectedMessage } from './tools';
|
|
2
|
+
import type { SubagentUpdateEvent } from './graph.js';
|
|
3
|
+
import type { InjectedMessage } from './tools.js';
|
|
4
4
|
/** Terminal and in-flight states for a detached subagent task. */
|
|
5
5
|
export type SubagentTaskStatus = 'running' | 'completed' | 'error' | 'cancelled';
|
|
6
6
|
/** Where a pending parent message may enter the child run. */
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { RunnableConfig, RunnableToolLike } from '@langchain/core/runnables';
|
|
2
2
|
import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
3
3
|
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
4
|
-
import type { MessageContentComplex, RunStepResumeState, ToolErrorData } from './stream';
|
|
4
|
+
import type { MessageContentComplex, RunStepResumeState, ToolErrorData } from './stream.js';
|
|
5
5
|
import type { ToolOutputReferenceRegistry } from '../tools/toolOutputReferences.js';
|
|
6
|
-
import type { LangfuseConfig, SubagentExecutionContext } from './graph';
|
|
6
|
+
import type { LangfuseConfig, SubagentExecutionContext } from './graph.js';
|
|
7
|
+
import type { ToolResultProtection } from '../protection/toolResult.js';
|
|
7
8
|
import type { PreparedSubagents } from '../tools/preparedSubagents.js';
|
|
8
9
|
import type { RunBreakerScope } from '../llm/streamLimits.js';
|
|
9
10
|
import type { HandoffRouting } from '../graphs/handoff.js';
|
|
10
|
-
import type { HumanInTheLoopConfig } from './hitl';
|
|
11
|
+
import type { HumanInTheLoopConfig } from './hitl.js';
|
|
11
12
|
import type { HookRegistry } from '../hooks/index.js';
|
|
12
13
|
/** Replacement type for `import type { ToolCall } from '@langchain/core/messages/tool'` in order to have stringified args typed */
|
|
13
14
|
export type CustomToolCall = {
|
|
@@ -254,6 +255,8 @@ export type ToolNodeOptions = {
|
|
|
254
255
|
* precedence over `toolOutputReferences` when both are set.
|
|
255
256
|
*/
|
|
256
257
|
toolOutputRegistry?: ToolOutputReferenceRegistry;
|
|
258
|
+
/** Host inspection of selected tools' result text; see {@link ToolResultProtection}. */
|
|
259
|
+
toolResultProtection?: ToolResultProtection;
|
|
257
260
|
/**
|
|
258
261
|
* Selects where built-in code execution tools run. Defaults to the
|
|
259
262
|
* remote LibreChat Code API sandbox; `local` swaps those same tool names
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
2
|
+
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
2
3
|
import type { ToolCallsDispatchedEvent } from '../types/stream.js';
|
|
3
4
|
import type { ToolExecuteBatchRequest } from '../types/tools.js';
|
|
4
5
|
import type { AgentLogEvent } from '../types/graph.js';
|
|
@@ -6,7 +7,7 @@ import type { AgentLogEvent } from '../types/graph.js';
|
|
|
6
7
|
* Safely dispatches a custom event and properly awaits it to avoid
|
|
7
8
|
* race conditions where events are dispatched after run cleanup.
|
|
8
9
|
*/
|
|
9
|
-
export declare function safeDispatchCustomEvent(event: string, payload: unknown, config?: RunnableConfig): Promise<boolean | void>;
|
|
10
|
+
export declare function safeDispatchCustomEvent(event: string, payload: unknown, config?: RunnableConfig, originalToolCalls?: readonly ToolCall[]): Promise<boolean | void>;
|
|
10
11
|
/** Builds an argument-free snapshot once per handoff, not once per result. */
|
|
11
12
|
export declare function createToolCallsDispatchedEvent(config: RunnableConfig, calls: readonly Pick<ToolExecuteBatchRequest['toolCalls'][number], 'id' | 'name' | 'stepId'>[]): ToolCallsDispatchedEvent;
|
|
12
13
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from './graph';
|
|
2
|
-
export * from './llm';
|
|
3
|
-
export * from './misc';
|
|
4
|
-
export * from './proxy';
|
|
5
|
-
export * from './handlers';
|
|
6
|
-
export * from './run';
|
|
7
|
-
export * from './tokens';
|
|
8
|
-
export * from './schema';
|
|
9
|
-
export * from './truncation';
|
|
10
|
-
export * from './errors';
|
|
1
|
+
export * from './graph.js';
|
|
2
|
+
export * from './llm.js';
|
|
3
|
+
export * from './misc.js';
|
|
4
|
+
export * from './proxy.js';
|
|
5
|
+
export * from './handlers.js';
|
|
6
|
+
export * from './run.js';
|
|
7
|
+
export * from './tokens.js';
|
|
8
|
+
export * from './schema.js';
|
|
9
|
+
export * from './truncation.js';
|
|
10
|
+
export * from './errors.js';
|
|
@@ -38,6 +38,7 @@ export declare function estimateImageBlockTokens(block: Record<string, unknown>,
|
|
|
38
38
|
*
|
|
39
39
|
* - Plain text: tokenized directly via `getTokenCount`.
|
|
40
40
|
* - Base64 PDF: page count estimated from base64 length × per-page cost.
|
|
41
|
+
* - Other base64 documents: decoded text, or decoded size when binary.
|
|
41
42
|
* - URL reference: conservative flat estimate.
|
|
42
43
|
*/
|
|
43
44
|
export declare function estimateDocumentBlockTokens(block: Record<string, unknown>, encoding: EncodingName, getTokenCount: (text: string) => number): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@librechat/agents",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.13",
|
|
4
4
|
"reova": {
|
|
5
5
|
"enabled": true,
|
|
6
6
|
"endpoint": "https://telemetry.reo.dev/data"
|
|
@@ -313,7 +313,8 @@
|
|
|
313
313
|
"label:eval": "tsx -r dotenv/config ./src/scripts/activity-labels/run.ts",
|
|
314
314
|
"label:rescore": "node ./src/scripts/activity-labels/rescore.cjs",
|
|
315
315
|
"test:runtime-package": "node --test config/runtime-package.test.mjs",
|
|
316
|
-
"
|
|
316
|
+
"test:declaration-extensions": "node --test scripts/fix-dts-extensions.test.mjs",
|
|
317
|
+
"build:types": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node scripts/fix-dts-extensions.mjs dist/types"
|
|
317
318
|
},
|
|
318
319
|
"overrides": {
|
|
319
320
|
"@langchain/openai": "$@langchain/openai",
|
|
@@ -324,7 +325,7 @@
|
|
|
324
325
|
"uuid": "$uuid",
|
|
325
326
|
"zod": "$zod",
|
|
326
327
|
"ajv": "6.14.0",
|
|
327
|
-
"@opentelemetry/core": "^2.
|
|
328
|
+
"@opentelemetry/core": "^2.12.1",
|
|
328
329
|
"js-yaml": "^4.3.1",
|
|
329
330
|
"glob": "^14.0.6",
|
|
330
331
|
"minimatch": "^11.0.8",
|
|
@@ -350,15 +351,16 @@
|
|
|
350
351
|
"@langchain/openai": "1.5.8",
|
|
351
352
|
"@langchain/textsplitters": "^1.0.1",
|
|
352
353
|
"@langchain/xai": "^1.4.3",
|
|
353
|
-
"@langfuse/core": "^
|
|
354
|
-
"@langfuse/langchain": "^
|
|
355
|
-
"@langfuse/otel": "^
|
|
356
|
-
"@langfuse/tracing": "^
|
|
357
|
-
"@opentelemetry/api": "
|
|
358
|
-
"@opentelemetry/context-async-hooks": "^2.
|
|
359
|
-
"@opentelemetry/exporter-trace-otlp-http": "0.
|
|
360
|
-
"@opentelemetry/otlp-exporter-base": "0.
|
|
361
|
-
"@opentelemetry/sdk-node": "^0.
|
|
354
|
+
"@langfuse/core": "^6.1.1",
|
|
355
|
+
"@langfuse/langchain": "^6.1.1",
|
|
356
|
+
"@langfuse/otel": "^6.1.1",
|
|
357
|
+
"@langfuse/tracing": "^6.1.1",
|
|
358
|
+
"@opentelemetry/api": "~1.9.0",
|
|
359
|
+
"@opentelemetry/context-async-hooks": "^2.12.1",
|
|
360
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.223.2",
|
|
361
|
+
"@opentelemetry/otlp-exporter-base": "^0.223.2",
|
|
362
|
+
"@opentelemetry/sdk-node": "^0.223.2",
|
|
363
|
+
"@opentelemetry/sdk-trace-base": "^2.12.1",
|
|
362
364
|
"@types/diff": "^7.0.2",
|
|
363
365
|
"@types/ws": "^8.18.1",
|
|
364
366
|
"ai-tokenizer": "^1.0.6",
|
package/src/graphs/Graph.ts
CHANGED
|
@@ -163,6 +163,10 @@ import {
|
|
|
163
163
|
getToolContentCharLength,
|
|
164
164
|
serializeToolContentBounded,
|
|
165
165
|
} from '@/utils/toolContent';
|
|
166
|
+
import {
|
|
167
|
+
createToolResultGate,
|
|
168
|
+
ToolResultProtectionError,
|
|
169
|
+
} from '@/protection/toolResult';
|
|
166
170
|
import {
|
|
167
171
|
appendCallbacks,
|
|
168
172
|
findCallback,
|
|
@@ -1174,7 +1178,10 @@ export abstract class Graph<
|
|
|
1174
1178
|
}
|
|
1175
1179
|
const savedStateKeys = new Set<string>();
|
|
1176
1180
|
const toolNodeStatesByKey = new Map<string, SubagentToolNodeResumeState>();
|
|
1177
|
-
const legacyNodeStatesByKey = new Map<
|
|
1181
|
+
const legacyNodeStatesByKey = new Map<
|
|
1182
|
+
string,
|
|
1183
|
+
SubagentToolNodeResumeState
|
|
1184
|
+
>();
|
|
1178
1185
|
for (const nodeState of state.toolNodes) {
|
|
1179
1186
|
const identity = parseSubagentToolNodeStateKey(nodeState.stateKey);
|
|
1180
1187
|
if (identity == null) {
|
|
@@ -1437,6 +1444,10 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1437
1444
|
streamLimits: ResolvedStreamLimits;
|
|
1438
1445
|
/** Default-off mandatory provider prose release. */
|
|
1439
1446
|
providerTextProtection?: t.StandardGraphInput['providerTextProtection'];
|
|
1447
|
+
/** Default-off host inspection of selected tools' result text. */
|
|
1448
|
+
toolResultProtection?: t.StandardGraphInput['toolResultProtection'];
|
|
1449
|
+
/** Host lookup for attachments carried by reference; read while a provider request is prepared. */
|
|
1450
|
+
resolveAttachment?: t.StandardGraphInput['resolveAttachment'];
|
|
1440
1451
|
/**
|
|
1441
1452
|
* Cumulative streamed argument bytes per in-flight tool call, keyed by
|
|
1442
1453
|
* generation key + chunk index (see `resolveGenerationKey`). Per-run
|
|
@@ -1617,6 +1628,8 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1617
1628
|
preemption,
|
|
1618
1629
|
streamLimits,
|
|
1619
1630
|
providerTextProtection,
|
|
1631
|
+
toolResultProtection,
|
|
1632
|
+
resolveAttachment,
|
|
1620
1633
|
toolExecution,
|
|
1621
1634
|
clientDelegatedToolNames,
|
|
1622
1635
|
}: t.StandardGraphInput,
|
|
@@ -1649,6 +1662,12 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1649
1662
|
if (providerTextProtection != null)
|
|
1650
1663
|
validateProviderTextProtection(providerTextProtection);
|
|
1651
1664
|
this.providerTextProtection = providerTextProtection;
|
|
1665
|
+
const toolResultGate =
|
|
1666
|
+
toolResultProtection == null
|
|
1667
|
+
? undefined
|
|
1668
|
+
: createToolResultGate(toolResultProtection);
|
|
1669
|
+
this.toolResultProtection = toolResultProtection;
|
|
1670
|
+
this.resolveAttachment = resolveAttachment;
|
|
1652
1671
|
this.toolExecution = toolExecution;
|
|
1653
1672
|
if (
|
|
1654
1673
|
clientDelegatedToolNames != null &&
|
|
@@ -1660,6 +1679,13 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1660
1679
|
if (clientDelegatedToolNames.some((name) => !name.trim())) {
|
|
1661
1680
|
throw new Error('Client delegated tool names must be nonempty');
|
|
1662
1681
|
}
|
|
1682
|
+
if (
|
|
1683
|
+
clientDelegatedToolNames.some(
|
|
1684
|
+
(name) => toolResultGate?.toolNames.has(name) === true
|
|
1685
|
+
)
|
|
1686
|
+
) {
|
|
1687
|
+
throw new ToolResultProtectionError('unsupported');
|
|
1688
|
+
}
|
|
1663
1689
|
this.clientDelegatedToolNames = new Set(clientDelegatedToolNames);
|
|
1664
1690
|
}
|
|
1665
1691
|
|
|
@@ -3024,6 +3050,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
3024
3050
|
maxContextTokens: agentContext?.maxContextTokens,
|
|
3025
3051
|
maxToolResultChars: agentContext?.maxToolResultChars,
|
|
3026
3052
|
toolOutputRegistry: this.getOrCreateToolOutputRegistry(),
|
|
3053
|
+
toolResultProtection: this.toolResultProtection,
|
|
3027
3054
|
fileCheckpointer: this.getOrCreateFileCheckpointer(),
|
|
3028
3055
|
getBreakerSignal: (): AbortSignal => this.breakerAbort.signal,
|
|
3029
3056
|
getRunScope: (): RunBreakerScope => this.runScope,
|
|
@@ -3107,6 +3134,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
3107
3134
|
maxContextTokens: agentContext?.maxContextTokens,
|
|
3108
3135
|
maxToolResultChars: agentContext?.maxToolResultChars,
|
|
3109
3136
|
toolOutputRegistry: this.getOrCreateToolOutputRegistry(),
|
|
3137
|
+
toolResultProtection: this.toolResultProtection,
|
|
3110
3138
|
fileCheckpointer: this.getOrCreateFileCheckpointer(),
|
|
3111
3139
|
getBreakerSignal: (): AbortSignal => this.breakerAbort.signal,
|
|
3112
3140
|
getRunScope: (): RunBreakerScope => this.runScope,
|
|
@@ -5442,6 +5470,8 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
5442
5470
|
onResolutionFailure: this.onSubagentResolutionFailure,
|
|
5443
5471
|
streamLimits: this.streamLimits,
|
|
5444
5472
|
providerTextProtection: this.providerTextProtection,
|
|
5473
|
+
toolResultProtection: this.toolResultProtection,
|
|
5474
|
+
resolveAttachment: this.resolveAttachment,
|
|
5445
5475
|
humanInTheLoop: this.humanInTheLoop,
|
|
5446
5476
|
checkpointer: this.compileOptions?.checkpointer,
|
|
5447
5477
|
maxDepth: effectiveSubagentDepth,
|
|
@@ -5757,6 +5787,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
5757
5787
|
return getConfig();
|
|
5758
5788
|
},
|
|
5759
5789
|
runId: this.runId,
|
|
5790
|
+
resolveAttachment: this.resolveAttachment,
|
|
5760
5791
|
isMultiAgent: this.isMultiAgentGraph(),
|
|
5761
5792
|
getSubagentExecutionContext: () => this.subagentExecutionContext,
|
|
5762
5793
|
hookRegistry: this.hookRegistry,
|
package/src/index.ts
CHANGED
|
@@ -135,6 +135,14 @@ export type {
|
|
|
135
135
|
ProviderTextProtectionErrorCode,
|
|
136
136
|
ProviderTextProtectionFailure,
|
|
137
137
|
} from './protection/providerText';
|
|
138
|
+
export {
|
|
139
|
+
TOOL_RESULT_PROTECTION_VERSION,
|
|
140
|
+
ToolResultProtectionError,
|
|
141
|
+
} from './protection/toolResult';
|
|
142
|
+
export type {
|
|
143
|
+
ToolResultProtection,
|
|
144
|
+
ToolResultProtectionResult,
|
|
145
|
+
} from './protection/toolResult';
|
|
138
146
|
|
|
139
147
|
export {
|
|
140
148
|
GEMINI_PARTS,
|
package/src/langfuse.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { tool } from '@langchain/core/tools';
|
|
2
1
|
import { CallbackHandler } from '@langfuse/langchain';
|
|
3
2
|
import { LangfuseOtelContextKeys } from '@langfuse/core';
|
|
3
|
+
import { CallbackManager } from '@langchain/core/callbacks/manager';
|
|
4
4
|
import { isGraphInterrupt, isParentCommand } from '@langchain/langgraph';
|
|
5
5
|
import { context as otelContext, trace as otelTrace } from '@opentelemetry/api';
|
|
6
6
|
import {
|
|
@@ -25,6 +25,7 @@ import type {
|
|
|
25
25
|
import type { PropagateAttributesParams } from '@langfuse/tracing';
|
|
26
26
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
27
27
|
import type { Context, SpanContext } from '@opentelemetry/api';
|
|
28
|
+
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
28
29
|
import type { ResolvedLangfuseToolOutputTracingConfig } from '@/langfuseRuntimeContext';
|
|
29
30
|
import type * as t from '@/types';
|
|
30
31
|
import {
|
|
@@ -55,6 +56,7 @@ import {
|
|
|
55
56
|
} from '@/llm/preempt';
|
|
56
57
|
import { filterCallbacks, findCallback } from '@/utils/callbacks';
|
|
57
58
|
import { isPresent, parseBooleanEnv } from '@/utils/misc';
|
|
59
|
+
import { Constants } from '@/common';
|
|
58
60
|
|
|
59
61
|
export {
|
|
60
62
|
hasLangfuseConfigCredentials,
|
|
@@ -69,6 +71,71 @@ const GRAPH_INTERRUPT_TOOL_OUTPUT = JSON.stringify(
|
|
|
69
71
|
GRAPH_INTERRUPT_CONTROL_FLOW
|
|
70
72
|
);
|
|
71
73
|
|
|
74
|
+
/**
|
|
75
|
+
* A LangGraph control-flow error that escapes the root graph is a failure.
|
|
76
|
+
* Nested `GraphInterrupt` and `ParentCommand` errors end their observations
|
|
77
|
+
* successfully in `handleChainError`, and a real pause ends the root run
|
|
78
|
+
* normally, so one that reaches a root callback has nowhere to go: for
|
|
79
|
+
* example, a `ParentCommand` with no parent graph. `@langfuse/langchain`
|
|
80
|
+
* records `is_bubble_up` errors as control flow, so the root reports a plain
|
|
81
|
+
* error with the same name and message.
|
|
82
|
+
*/
|
|
83
|
+
function toRootFailure(error: unknown): unknown {
|
|
84
|
+
if (
|
|
85
|
+
!(error instanceof Error) ||
|
|
86
|
+
(error as { is_bubble_up?: unknown }).is_bubble_up !== true
|
|
87
|
+
) {
|
|
88
|
+
return error;
|
|
89
|
+
}
|
|
90
|
+
const failure = new Error(error.message);
|
|
91
|
+
failure.name = error.name;
|
|
92
|
+
return failure;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Reports the agent's available skills on the observations `action` starts. */
|
|
96
|
+
function withSkillsAvailable<T>(
|
|
97
|
+
langfuse: t.LangfuseConfig | undefined,
|
|
98
|
+
action: () => T
|
|
99
|
+
): T {
|
|
100
|
+
const skillsAvailable = langfuse?.skillsAvailable;
|
|
101
|
+
return skillsAvailable == null
|
|
102
|
+
? action()
|
|
103
|
+
: propagateAttributes({ skillsAvailable }, action);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type SkillToolArgs = { name?: unknown; skillName?: unknown };
|
|
107
|
+
|
|
108
|
+
/** Returns the arguments of a tool input, which can be a whole tool call. */
|
|
109
|
+
function getSkillToolArgs(input: unknown): SkillToolArgs | undefined {
|
|
110
|
+
const args =
|
|
111
|
+
(input as { type?: unknown } | null)?.type === 'tool_call'
|
|
112
|
+
? (input as { args?: unknown }).args
|
|
113
|
+
: input;
|
|
114
|
+
return args != null && typeof args === 'object' && !Array.isArray(args)
|
|
115
|
+
? (args as SkillToolArgs)
|
|
116
|
+
: undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Langfuse reads a `skill` tool's skill from the top-level `name` input
|
|
121
|
+
* field. The tool's argument is `skillName`, and the traced input of a tool
|
|
122
|
+
* call wraps the arguments, so the traced input is the arguments plus `name`.
|
|
123
|
+
*/
|
|
124
|
+
function toTracedToolInput(toolName: unknown, input: string): string {
|
|
125
|
+
if (toolName !== Constants.SKILL_TOOL) {
|
|
126
|
+
return input;
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const args = getSkillToolArgs(JSON.parse(input));
|
|
130
|
+
if (args == null || 'name' in args || typeof args.skillName !== 'string') {
|
|
131
|
+
return input;
|
|
132
|
+
}
|
|
133
|
+
return JSON.stringify({ name: args.skillName, ...args });
|
|
134
|
+
} catch {
|
|
135
|
+
return input;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
72
139
|
export type LangfuseTraceMetadata = Record<string, string>;
|
|
73
140
|
export type LangfuseTraceAttributes = Record<string, string | number | boolean>;
|
|
74
141
|
|
|
@@ -528,7 +595,7 @@ class ScopedLangfuseCallbackHandler extends CallbackHandler {
|
|
|
528
595
|
runId: scopeRunId ?? this.runId,
|
|
529
596
|
agentId: scopeAgentId ?? this.agentId,
|
|
530
597
|
},
|
|
531
|
-
action
|
|
598
|
+
() => withSkillsAvailable(langfuse, action)
|
|
532
599
|
);
|
|
533
600
|
return activeContext === currentContext
|
|
534
601
|
? scoped()
|
|
@@ -563,7 +630,7 @@ class ScopedLangfuseCallbackHandler extends CallbackHandler {
|
|
|
563
630
|
this.toolOutputTracing ??
|
|
564
631
|
resolveToolOutputTracingConfig(this.langfuse),
|
|
565
632
|
},
|
|
566
|
-
action,
|
|
633
|
+
() => withSkillsAvailable(this.langfuse, action),
|
|
567
634
|
{ replace: true }
|
|
568
635
|
);
|
|
569
636
|
const { userId, sessionId, tags, metadata, traceName } = this.identity;
|
|
@@ -632,6 +699,13 @@ class ScopedLangfuseCallbackHandler extends CallbackHandler {
|
|
|
632
699
|
parentRunId
|
|
633
700
|
);
|
|
634
701
|
}
|
|
702
|
+
if (error != null && parentRunId == null) {
|
|
703
|
+
const rootArgs = [...args] as Parameters<
|
|
704
|
+
CallbackHandler['handleChainError']
|
|
705
|
+
>;
|
|
706
|
+
rootArgs[0] = toRootFailure(error);
|
|
707
|
+
return super.handleChainError(...rootArgs);
|
|
708
|
+
}
|
|
635
709
|
return super.handleChainError(...args);
|
|
636
710
|
}
|
|
637
711
|
|
|
@@ -699,7 +773,11 @@ class ScopedLangfuseCallbackHandler extends CallbackHandler {
|
|
|
699
773
|
this.deferredRootStarted = false;
|
|
700
774
|
this.deferredRootOutcome = undefined;
|
|
701
775
|
if (outcome.type === 'error') {
|
|
702
|
-
await super.handleChainError(
|
|
776
|
+
await super.handleChainError(
|
|
777
|
+
toRootFailure(outcome.error),
|
|
778
|
+
runId,
|
|
779
|
+
outcome.parentRunId
|
|
780
|
+
);
|
|
703
781
|
return;
|
|
704
782
|
}
|
|
705
783
|
await super.handleChainEnd(outcome.output, runId, outcome.parentRunId);
|
|
@@ -819,8 +897,13 @@ class ScopedLangfuseCallbackHandler extends CallbackHandler {
|
|
|
819
897
|
override handleToolStart(
|
|
820
898
|
...args: Parameters<CallbackHandler['handleToolStart']>
|
|
821
899
|
): ReturnType<CallbackHandler['handleToolStart']> {
|
|
900
|
+
const [tool, input, , , , , name] = args;
|
|
901
|
+
const toolArgs = [...args] as Parameters<
|
|
902
|
+
CallbackHandler['handleToolStart']
|
|
903
|
+
>;
|
|
904
|
+
toolArgs[1] = toTracedToolInput(name ?? tool.id.at(-1), input);
|
|
822
905
|
return this.withRuntimeContext(
|
|
823
|
-
() => super.handleToolStart(...
|
|
906
|
+
() => super.handleToolStart(...toolArgs),
|
|
824
907
|
this.startsDetachedRun(args[2], args[3]),
|
|
825
908
|
args[5]
|
|
826
909
|
);
|
|
@@ -1144,58 +1227,63 @@ export function isLangfuseCallbackHandler(value: unknown): boolean {
|
|
|
1144
1227
|
return value instanceof CallbackHandler;
|
|
1145
1228
|
}
|
|
1146
1229
|
|
|
1147
|
-
/**
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1230
|
+
/** Records host results using model-authored arguments, never substituted
|
|
1231
|
+
* tool outputs, and reserved metadata.
|
|
1232
|
+
* Host results have passed host output filters, so rows, errors, and
|
|
1233
|
+
* attachments are not recorded. These completion observations do not measure
|
|
1234
|
+
* tool latency; execution timing belongs in the metadata. */
|
|
1150
1235
|
export async function traceHostToolResults(
|
|
1151
1236
|
request: t.ToolExecuteBatchRequest,
|
|
1152
1237
|
results: t.ToolExecuteResult[],
|
|
1153
|
-
config?: RunnableConfig
|
|
1238
|
+
config?: RunnableConfig,
|
|
1239
|
+
originalToolCalls?: readonly ToolCall[]
|
|
1154
1240
|
): Promise<void> {
|
|
1155
1241
|
if (findCallback(config?.callbacks, isLangfuseCallbackHandler) == null) {
|
|
1156
1242
|
return;
|
|
1157
1243
|
}
|
|
1158
|
-
const callbacks =
|
|
1159
|
-
config?.callbacks,
|
|
1160
|
-
|
|
1244
|
+
const callbacks = CallbackManager.configure(
|
|
1245
|
+
filterCallbacks(config?.callbacks, isLangfuseCallbackHandler),
|
|
1246
|
+
undefined,
|
|
1247
|
+
config?.tags,
|
|
1248
|
+
undefined,
|
|
1249
|
+
config?.metadata
|
|
1161
1250
|
);
|
|
1251
|
+
if (callbacks == null) {
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1162
1254
|
const callsById = new Map(request.toolCalls.map((call) => [call.id, call]));
|
|
1255
|
+
const originalArgsById = new Map(
|
|
1256
|
+
originalToolCalls?.map((call) => [call.id, call.args])
|
|
1257
|
+
);
|
|
1163
1258
|
for (const result of results) {
|
|
1164
|
-
const metadata = getToolObservationMetadata(result.artifact);
|
|
1165
1259
|
const call = callsById.get(result.toolCallId);
|
|
1166
|
-
if (call == null
|
|
1260
|
+
if (call == null) {
|
|
1167
1261
|
continue;
|
|
1168
1262
|
}
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
throw failure;
|
|
1177
|
-
}
|
|
1178
|
-
return LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT;
|
|
1263
|
+
const observation = new CallbackManager(callbacks.getParentRunId(), {
|
|
1264
|
+
handlers: callbacks.handlers,
|
|
1265
|
+
tags: callbacks.tags,
|
|
1266
|
+
metadata: {
|
|
1267
|
+
...callbacks.metadata,
|
|
1268
|
+
...getToolObservationMetadata(result.artifact),
|
|
1269
|
+
...request.metadata,
|
|
1179
1270
|
},
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1271
|
+
});
|
|
1272
|
+
const run = await observation.handleToolStart(
|
|
1273
|
+
{ lc: 1, type: 'not_implemented', id: [call.name] },
|
|
1274
|
+
JSON.stringify(originalArgsById.get(call.id) ?? {}),
|
|
1275
|
+
undefined,
|
|
1276
|
+
undefined,
|
|
1277
|
+
undefined,
|
|
1278
|
+
undefined,
|
|
1279
|
+
call.name,
|
|
1280
|
+
call.id
|
|
1185
1281
|
);
|
|
1186
|
-
|
|
1187
|
-
await
|
|
1188
|
-
|
|
1189
|
-
{
|
|
1190
|
-
callbacks,
|
|
1191
|
-
metadata: { ...metadata, ...request.metadata },
|
|
1192
|
-
}
|
|
1193
|
-
);
|
|
1194
|
-
} catch (error) {
|
|
1195
|
-
if (failure == null || error !== failure) {
|
|
1196
|
-
throw error;
|
|
1197
|
-
}
|
|
1282
|
+
if (result.status === 'error') {
|
|
1283
|
+
await run.handleToolError(new Error('Host tool execution failed'));
|
|
1284
|
+
continue;
|
|
1198
1285
|
}
|
|
1286
|
+
await run.handleToolEnd(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
1199
1287
|
}
|
|
1200
1288
|
}
|
|
1201
1289
|
|