@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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Data, MessageContentComplex } from '@langchain/core/messages';
|
|
2
|
+
import type { ProviderMessageProjectionMode } from '@/llm/prepareProviderRequest';
|
|
3
|
+
import type { ProviderName } from './llm';
|
|
4
|
+
|
|
5
|
+
/** An attachment a message carries by reference: LangChain's `source_type: 'id'` data block. */
|
|
6
|
+
export type AttachmentReference = Data.IDContentBlock;
|
|
7
|
+
|
|
8
|
+
/** The provider request a reference is being resolved for. */
|
|
9
|
+
export interface AttachmentTarget {
|
|
10
|
+
provider: ProviderName;
|
|
11
|
+
modelId?: string;
|
|
12
|
+
projectionMode: ProviderMessageProjectionMode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Supplies the content a referenced attachment stands for, as the block the
|
|
17
|
+
* target provider accepts. Called for each reference while a provider request
|
|
18
|
+
* is prepared. The result goes into that request only, so graph state and
|
|
19
|
+
* checkpoints keep the reference and never hold the attachment's bytes.
|
|
20
|
+
*
|
|
21
|
+
* - `undefined`: not this host's reference (a provider-side file id); the block is left as it is.
|
|
22
|
+
* - `null`: nothing to send to this provider; the block is dropped.
|
|
23
|
+
* - a block: replaces the reference as returned, without further projection.
|
|
24
|
+
*
|
|
25
|
+
* Synchronous and repeatable: one model call can prepare its request more than
|
|
26
|
+
* once (a fallback provider, an overflow retry), each for its own target.
|
|
27
|
+
*/
|
|
28
|
+
export type AttachmentResolver = (
|
|
29
|
+
reference: AttachmentReference,
|
|
30
|
+
target: AttachmentTarget
|
|
31
|
+
) => MessageContentComplex | null | undefined;
|
package/src/types/graph.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ProviderTextProtection } from '@/protection/providerText';
|
|
2
|
+
import type { ToolResultProtection } from '@/protection/toolResult';
|
|
3
|
+
import type { AttachmentResolver } from './attachments';
|
|
2
4
|
// src/types/graph.ts
|
|
3
5
|
import type {
|
|
4
6
|
BaseMessage,
|
|
@@ -410,6 +412,10 @@ export type ModelEndData =
|
|
|
410
412
|
export type GraphTools = GenericTool[] | BindToolsInput[] | GoogleAIToolType[];
|
|
411
413
|
export type StandardGraphInput = {
|
|
412
414
|
providerTextProtection?: ProviderTextProtection;
|
|
415
|
+
/** Host inspection of selected tools' result text, for every graph of the run. */
|
|
416
|
+
toolResultProtection?: ToolResultProtection;
|
|
417
|
+
/** Resolves attachments that messages carry by reference; see {@link AttachmentResolver}. */
|
|
418
|
+
resolveAttachment?: AttachmentResolver;
|
|
413
419
|
runId?: string;
|
|
414
420
|
signal?: AbortSignal;
|
|
415
421
|
agents: AgentInputs[];
|
|
@@ -1001,6 +1007,12 @@ export interface LangfuseConfig {
|
|
|
1001
1007
|
* from the run/message id, without a trace lookup. Default: random ids.
|
|
1002
1008
|
*/
|
|
1003
1009
|
deterministicTraceId?: boolean;
|
|
1010
|
+
/**
|
|
1011
|
+
* Skills the agent can load with the `skill` tool, reported to Langfuse on
|
|
1012
|
+
* the observations its run starts. `name` matches the tool's `skillName`;
|
|
1013
|
+
* `version` is the skill's Langfuse version, when it has one.
|
|
1014
|
+
*/
|
|
1015
|
+
skillsAvailable?: { name: string; version?: number }[];
|
|
1004
1016
|
}
|
|
1005
1017
|
|
|
1006
1018
|
interface AgentInputFields {
|
package/src/types/index.ts
CHANGED
package/src/types/run.ts
CHANGED
|
@@ -33,12 +33,15 @@ export type LegacyGraphConfig = BaseGraphConfig & {
|
|
|
33
33
|
/** `streamLimits` is excluded because legacy graphs receive limits only
|
|
34
34
|
* via the top-level `RunConfig.streamLimits`; accepting the field here
|
|
35
35
|
* would type-check but be silently ignored by `createLegacyGraph`.
|
|
36
|
-
* Required provider-text protection also belongs only to RunConfig
|
|
36
|
+
* Required provider-text protection also belongs only to RunConfig, as
|
|
37
|
+
* does the attachment resolver. */
|
|
37
38
|
| 'provider'
|
|
38
39
|
| 'clientOptions'
|
|
39
40
|
| 'agents'
|
|
40
41
|
| 'streamLimits'
|
|
41
42
|
| 'providerTextProtection'
|
|
43
|
+
| 'toolResultProtection'
|
|
44
|
+
| 'resolveAttachment'
|
|
42
45
|
> &
|
|
43
46
|
Omit<g.AgentInputs, 'provider' | 'clientOptions' | 'agentId'>;
|
|
44
47
|
|
|
@@ -341,6 +344,10 @@ export type RunConfig = {
|
|
|
341
344
|
* opt-in. See {@link StreamLimits}.
|
|
342
345
|
*/
|
|
343
346
|
providerTextProtection?: g.StandardGraphInput['providerTextProtection'];
|
|
347
|
+
/** Host inspection of selected tools' result text. Default off. */
|
|
348
|
+
toolResultProtection?: g.StandardGraphInput['toolResultProtection'];
|
|
349
|
+
/** Resolves attachments that messages carry by reference, for every graph of the run. */
|
|
350
|
+
resolveAttachment?: g.StandardGraphInput['resolveAttachment'];
|
|
344
351
|
streamLimits?: StreamLimits;
|
|
345
352
|
returnContent?: boolean;
|
|
346
353
|
tokenCounter?: TokenCounter;
|
package/src/types/tools.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
} from './stream';
|
|
13
13
|
import type { ToolOutputReferenceRegistry } from '@/tools/toolOutputReferences';
|
|
14
14
|
import type { LangfuseConfig, SubagentExecutionContext } from './graph';
|
|
15
|
+
import type { ToolResultProtection } from '@/protection/toolResult';
|
|
15
16
|
import type { PreparedSubagents } from '@/tools/preparedSubagents';
|
|
16
17
|
import type { RunBreakerScope } from '@/llm/streamLimits';
|
|
17
18
|
import type { HandoffRouting } from '@/graphs/handoff';
|
|
@@ -271,6 +272,8 @@ export type ToolNodeOptions = {
|
|
|
271
272
|
* precedence over `toolOutputReferences` when both are set.
|
|
272
273
|
*/
|
|
273
274
|
toolOutputRegistry?: ToolOutputReferenceRegistry;
|
|
275
|
+
/** Host inspection of selected tools' result text; see {@link ToolResultProtection}. */
|
|
276
|
+
toolResultProtection?: ToolResultProtection;
|
|
274
277
|
/**
|
|
275
278
|
* Selects where built-in code execution tools run. Defaults to the
|
|
276
279
|
* remote LibreChat Code API sandbox; `local` swaps those same tool names
|
package/src/utils/events.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// src/utils/events.ts
|
|
3
3
|
import { dispatchCustomEvent } from '@langchain/core/callbacks/dispatch';
|
|
4
4
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
5
|
+
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
5
6
|
import type { ToolCallsDispatchedEvent } from '@/types/stream';
|
|
6
7
|
import type { ToolExecuteBatchRequest } from '@/types/tools';
|
|
7
8
|
import type { AgentLogEvent } from '@/types/graph';
|
|
@@ -15,7 +16,8 @@ import { GraphEvents } from '@/common';
|
|
|
15
16
|
export async function safeDispatchCustomEvent(
|
|
16
17
|
event: string,
|
|
17
18
|
payload: unknown,
|
|
18
|
-
config?: RunnableConfig
|
|
19
|
+
config?: RunnableConfig,
|
|
20
|
+
originalToolCalls?: readonly ToolCall[]
|
|
19
21
|
): Promise<boolean | void> {
|
|
20
22
|
try {
|
|
21
23
|
if (event === GraphEvents.ON_TOOL_EXECUTE) {
|
|
@@ -27,7 +29,12 @@ export async function safeDispatchCustomEvent(
|
|
|
27
29
|
): void => {
|
|
28
30
|
const receivedAt = Date.now();
|
|
29
31
|
const stamped = results.map((result) => ({ ...result, received_at: receivedAt }));
|
|
30
|
-
void traceHostToolResults(
|
|
32
|
+
void traceHostToolResults(
|
|
33
|
+
request,
|
|
34
|
+
results,
|
|
35
|
+
config,
|
|
36
|
+
originalToolCalls
|
|
37
|
+
).then(
|
|
31
38
|
() => request.resolve(stamped),
|
|
32
39
|
() => {
|
|
33
40
|
console.warn('Failed to record host tool execution metadata');
|
package/src/utils/tokens.ts
CHANGED
|
@@ -86,6 +86,8 @@ const _GEMINI_PDF_TOKENS_PER_PAGE = 258;
|
|
|
86
86
|
const BASE64_BYTES_PER_PDF_PAGE = 75_000;
|
|
87
87
|
/** Fallback token cost for URL-referenced documents without local data. */
|
|
88
88
|
const URL_DOCUMENT_FALLBACK_TOKENS = 2000;
|
|
89
|
+
/** Approximate decoded bytes per token for a binary (Office) document. */
|
|
90
|
+
const BINARY_DOCUMENT_BYTES_PER_TOKEN = 4;
|
|
89
91
|
|
|
90
92
|
/**
|
|
91
93
|
* Timed media (video/audio) is priced by DURATION, not size, and the content
|
|
@@ -275,6 +277,25 @@ export function estimateImageBlockTokens(
|
|
|
275
277
|
return estimateOpenAIImageTokens(dims.width, dims.height);
|
|
276
278
|
}
|
|
277
279
|
|
|
280
|
+
/**
|
|
281
|
+
* A base64 document that is neither a PDF nor an image reaches the model as
|
|
282
|
+
* its contents, not as base64: a textual one is counted by its decoded text,
|
|
283
|
+
* a binary one (Office formats) by its decoded size. Tokenizing the base64
|
|
284
|
+
* itself roughly doubles a text file's count.
|
|
285
|
+
*/
|
|
286
|
+
function estimateBase64DocumentTokens(
|
|
287
|
+
data: string,
|
|
288
|
+
mimeType: string,
|
|
289
|
+
getTokenCount: (text: string) => number
|
|
290
|
+
): number {
|
|
291
|
+
if (!mimeType.startsWith('text/')) {
|
|
292
|
+
return Math.ceil(
|
|
293
|
+
Buffer.byteLength(data, 'base64') / BINARY_DOCUMENT_BYTES_PER_TOKEN
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
return getTokenCount(Buffer.from(data, 'base64').toString('utf8'));
|
|
297
|
+
}
|
|
298
|
+
|
|
278
299
|
/**
|
|
279
300
|
* Estimates token cost for a document/file content block.
|
|
280
301
|
* Handles both LangChain standard format (`type: 'file'` with `source_type`)
|
|
@@ -282,6 +303,7 @@ export function estimateImageBlockTokens(
|
|
|
282
303
|
*
|
|
283
304
|
* - Plain text: tokenized directly via `getTokenCount`.
|
|
284
305
|
* - Base64 PDF: page count estimated from base64 length × per-page cost.
|
|
306
|
+
* - Other base64 documents: decoded text, or decoded size when binary.
|
|
285
307
|
* - URL reference: conservative flat estimate.
|
|
286
308
|
*/
|
|
287
309
|
export function estimateDocumentBlockTokens(
|
|
@@ -324,7 +346,11 @@ export function estimateDocumentBlockTokens(
|
|
|
324
346
|
encoding
|
|
325
347
|
);
|
|
326
348
|
}
|
|
327
|
-
return
|
|
349
|
+
return estimateBase64DocumentTokens(
|
|
350
|
+
block.data as string,
|
|
351
|
+
mimeType,
|
|
352
|
+
getTokenCount
|
|
353
|
+
);
|
|
328
354
|
}
|
|
329
355
|
|
|
330
356
|
if (sourceType === 'url') {
|
|
@@ -367,7 +393,7 @@ export function estimateDocumentBlockTokens(
|
|
|
367
393
|
encoding
|
|
368
394
|
);
|
|
369
395
|
}
|
|
370
|
-
return
|
|
396
|
+
return estimateBase64DocumentTokens(source.data, mediaType, getTokenCount);
|
|
371
397
|
}
|
|
372
398
|
|
|
373
399
|
if (source.type === 'url') {
|