@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
|
@@ -2,14 +2,13 @@ import { tool } from '@langchain/core/tools';
|
|
|
2
2
|
import type { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
3
|
import type * as t from '@/types';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from '@/tools/BashExecutor';
|
|
5
|
+
createCloudflareLocalExecutionConfig,
|
|
6
|
+
createCloudflareWorkspaceFS,
|
|
7
|
+
executeCloudflareBash,
|
|
8
|
+
executeCloudflareCode,
|
|
9
|
+
formatCloudflareOutput,
|
|
10
|
+
getCloudflareWorkspaceRoot,
|
|
11
|
+
} from './CloudflareSandboxExecutionEngine';
|
|
13
12
|
import {
|
|
14
13
|
createLocalReadFileTool,
|
|
15
14
|
createLocalWriteFileTool,
|
|
@@ -18,21 +17,22 @@ import {
|
|
|
18
17
|
createLocalGlobSearchTool,
|
|
19
18
|
createLocalListDirectoryTool,
|
|
20
19
|
} from '@/tools/local/LocalCodingTools';
|
|
21
|
-
import { createLocalFileCheckpointer } from '@/tools/local/FileCheckpointer';
|
|
22
|
-
import { createCompileCheckTool } from '@/tools/local/CompileCheckTool';
|
|
23
|
-
import { Constants } from '@/common';
|
|
24
|
-
import {
|
|
25
|
-
createCloudflareLocalExecutionConfig,
|
|
26
|
-
createCloudflareWorkspaceFS,
|
|
27
|
-
executeCloudflareBash,
|
|
28
|
-
executeCloudflareCode,
|
|
29
|
-
formatCloudflareOutput,
|
|
30
|
-
getCloudflareWorkspaceRoot,
|
|
31
|
-
} from './CloudflareSandboxExecutionEngine';
|
|
32
20
|
import {
|
|
33
21
|
createCloudflareBashProgrammaticToolCallingTool,
|
|
34
22
|
createCloudflareProgrammaticToolCallingTool,
|
|
35
23
|
} from './CloudflareProgrammaticToolCalling';
|
|
24
|
+
import {
|
|
25
|
+
BashExecutionToolName,
|
|
26
|
+
BashExecutionToolSchema,
|
|
27
|
+
BashToolOutputReferencesGuide,
|
|
28
|
+
} from '@/tools/BashExecutor';
|
|
29
|
+
import {
|
|
30
|
+
CodeExecutionToolName,
|
|
31
|
+
CodeExecutionToolSchema,
|
|
32
|
+
} from '@/tools/CodeExecutor';
|
|
33
|
+
import { createLocalFileCheckpointer } from '@/tools/local/FileCheckpointer';
|
|
34
|
+
import { createCompileCheckTool } from '@/tools/local/CompileCheckTool';
|
|
35
|
+
import { Constants } from '@/common';
|
|
36
36
|
|
|
37
37
|
export const CLOUDFLARE_CODING_TOOL_NAMES: readonly string[] = [
|
|
38
38
|
Constants.READ_FILE,
|
package/src/tools/handlers.ts
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
// src/tools/handlers.ts
|
|
3
3
|
import { nanoid } from 'nanoid';
|
|
4
4
|
import { ToolMessage } from '@langchain/core/messages';
|
|
5
|
-
import type { AnthropicWebSearchResultBlockParam } from '@/llm/anthropic/types';
|
|
6
5
|
import type { ToolCall, ToolCallChunk } from '@langchain/core/messages/tool';
|
|
6
|
+
import type { AnthropicWebSearchResultBlockParam } from '@/llm/anthropic/types';
|
|
7
7
|
import type { Graph, MultiAgentGraph, StandardGraph } from '@/graphs';
|
|
8
8
|
import type { AgentContext } from '@/agents/AgentContext';
|
|
9
9
|
import type * as t from '@/types';
|
|
10
|
+
import {
|
|
11
|
+
coerceAnthropicSearchResults,
|
|
12
|
+
isAnthropicWebSearchResult,
|
|
13
|
+
} from '@/tools/search/anthropic';
|
|
10
14
|
import {
|
|
11
15
|
ToolCallTypes,
|
|
12
16
|
GraphEvents,
|
|
@@ -14,10 +18,6 @@ import {
|
|
|
14
18
|
Providers,
|
|
15
19
|
Constants,
|
|
16
20
|
} from '@/common';
|
|
17
|
-
import {
|
|
18
|
-
coerceAnthropicSearchResults,
|
|
19
|
-
isAnthropicWebSearchResult,
|
|
20
|
-
} from '@/tools/search/anthropic';
|
|
21
21
|
import { formatResultsForLLM } from '@/tools/search/format';
|
|
22
22
|
import { getMessageId } from '@/messages';
|
|
23
23
|
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
import { resolve } from 'path';
|
|
27
27
|
import { tool } from '@langchain/core/tools';
|
|
28
28
|
import type { DynamicStructuredTool } from '@langchain/core/tools';
|
|
29
|
+
import type { WorkspaceFS } from './workspaceFS';
|
|
29
30
|
import type * as t from '@/types';
|
|
30
31
|
import {
|
|
31
32
|
getLocalCwd,
|
|
@@ -34,7 +35,6 @@ import {
|
|
|
34
35
|
truncateLocalOutput,
|
|
35
36
|
validateBashCommand,
|
|
36
37
|
} from './LocalExecutionEngine';
|
|
37
|
-
import type { WorkspaceFS } from './workspaceFS';
|
|
38
38
|
import { Constants } from '@/common';
|
|
39
39
|
|
|
40
40
|
/** Back-compat alias; canonical name lives on `Constants.COMPILE_CHECK`. */
|
|
@@ -173,8 +173,7 @@ export function createCompileCheckTool(
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
if (detection.command === '') {
|
|
176
|
-
const explainer =
|
|
177
|
-
`compile_check: ${detection.reason}. Pass an explicit \`command\` (e.g. \`npm run typecheck\`) to override.`;
|
|
176
|
+
const explainer = `compile_check: ${detection.reason}. Pass an explicit \`command\` (e.g. \`npm run typecheck\`) to override.`;
|
|
178
177
|
return [
|
|
179
178
|
explainer,
|
|
180
179
|
{
|
|
@@ -196,8 +195,7 @@ export function createCompileCheckTool(
|
|
|
196
195
|
// mutating overrides.
|
|
197
196
|
const validation = await validateBashCommand(detection.command, config);
|
|
198
197
|
if (!validation.valid) {
|
|
199
|
-
const explainer =
|
|
200
|
-
`compile_check refused to run \`${detection.command}\`: ${validation.errors.join('; ')}`;
|
|
198
|
+
const explainer = `compile_check refused to run \`${detection.command}\`: ${validation.errors.join('; ')}`;
|
|
201
199
|
return [
|
|
202
200
|
explainer,
|
|
203
201
|
{
|
|
@@ -223,8 +221,7 @@ export function createCompileCheckTool(
|
|
|
223
221
|
}
|
|
224
222
|
);
|
|
225
223
|
|
|
226
|
-
const passed =
|
|
227
|
-
result.exitCode === 0 && !result.timedOut;
|
|
224
|
+
const passed = result.exitCode === 0 && !result.timedOut;
|
|
228
225
|
const headline = passed
|
|
229
226
|
? `compile_check (${detection.kind}) PASSED via \`${detection.command}\``
|
|
230
227
|
: `compile_check (${detection.kind}) FAILED via \`${detection.command}\` ` +
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { dirname } from 'path';
|
|
2
|
-
import { nodeWorkspaceFS } from './workspaceFS';
|
|
3
2
|
import type { WorkspaceFS } from './workspaceFS';
|
|
4
3
|
import type * as t from '@/types';
|
|
4
|
+
import { nodeWorkspaceFS } from './workspaceFS';
|
|
5
5
|
|
|
6
|
-
type Snapshot =
|
|
7
|
-
| { kind: 'absent' }
|
|
8
|
-
| { kind: 'present'; content: Buffer };
|
|
6
|
+
type Snapshot = { kind: 'absent' } | { kind: 'present'; content: Buffer };
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* Per-Run snapshot store for write_file / edit_file. Captures the
|
|
@@ -34,7 +32,10 @@ export class LocalFileCheckpointerImpl implements t.LocalFileCheckpointer {
|
|
|
34
32
|
) {}
|
|
35
33
|
|
|
36
34
|
async captureBeforeWrite(absolutePath: string): Promise<void> {
|
|
37
|
-
if (
|
|
35
|
+
if (
|
|
36
|
+
this.snapshots.has(absolutePath) ||
|
|
37
|
+
this.oversizePaths.has(absolutePath)
|
|
38
|
+
) {
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
41
|
let info;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { basename, dirname } from 'path';
|
|
2
|
-
import { tool } from '@langchain/core/tools';
|
|
3
2
|
import { createTwoFilesPatch } from 'diff';
|
|
3
|
+
import { tool } from '@langchain/core/tools';
|
|
4
4
|
import type { DynamicStructuredTool } from '@langchain/core/tools';
|
|
5
5
|
import type * as t from '@/types';
|
|
6
|
-
import {
|
|
7
|
-
createLocalBashExecutionTool,
|
|
8
|
-
createLocalCodeExecutionTool,
|
|
9
|
-
} from './LocalExecutionTools';
|
|
10
6
|
import {
|
|
11
7
|
createLocalBashProgrammaticToolCallingTool,
|
|
12
8
|
createLocalProgrammaticToolCallingTool,
|
|
@@ -18,15 +14,19 @@ import {
|
|
|
18
14
|
spawnLocalProcess,
|
|
19
15
|
truncateLocalOutput,
|
|
20
16
|
} from './LocalExecutionEngine';
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import { runPostEditSyntaxCheck } from './syntaxCheck';
|
|
17
|
+
import {
|
|
18
|
+
createLocalBashExecutionTool,
|
|
19
|
+
createLocalCodeExecutionTool,
|
|
20
|
+
} from './LocalExecutionTools';
|
|
26
21
|
import {
|
|
27
22
|
createCompileCheckTool,
|
|
28
23
|
createCompileCheckToolDefinition,
|
|
29
24
|
} from './CompileCheckTool';
|
|
25
|
+
import { classifyAttachment, imageAttachmentContent } from './attachments';
|
|
26
|
+
import { createLocalFileCheckpointer } from './FileCheckpointer';
|
|
27
|
+
import { applyEdit, locateEdit } from './editStrategies';
|
|
28
|
+
import { decodeFile, encodeFile } from './textEncoding';
|
|
29
|
+
import { runPostEditSyntaxCheck } from './syntaxCheck';
|
|
30
30
|
import { Constants } from '@/common';
|
|
31
31
|
|
|
32
32
|
const MAX_READ_CHARS = 256000;
|
|
@@ -51,7 +51,8 @@ export const LocalReadFileToolSchema: t.JsonSchemaType = {
|
|
|
51
51
|
properties: {
|
|
52
52
|
file_path: {
|
|
53
53
|
type: 'string',
|
|
54
|
-
description:
|
|
54
|
+
description:
|
|
55
|
+
'Path to a local file, relative to the configured cwd unless absolute paths are allowed.',
|
|
55
56
|
},
|
|
56
57
|
offset: {
|
|
57
58
|
type: 'integer',
|
|
@@ -70,7 +71,8 @@ export const LocalWriteFileToolSchema: t.JsonSchemaType = {
|
|
|
70
71
|
properties: {
|
|
71
72
|
file_path: {
|
|
72
73
|
type: 'string',
|
|
73
|
-
description:
|
|
74
|
+
description:
|
|
75
|
+
'Path to write, relative to the configured cwd unless absolute paths are allowed.',
|
|
74
76
|
},
|
|
75
77
|
content: {
|
|
76
78
|
type: 'string',
|
|
@@ -85,7 +87,8 @@ export const LocalEditFileToolSchema: t.JsonSchemaType = {
|
|
|
85
87
|
properties: {
|
|
86
88
|
file_path: {
|
|
87
89
|
type: 'string',
|
|
88
|
-
description:
|
|
90
|
+
description:
|
|
91
|
+
'Path to edit, relative to the configured cwd unless absolute paths are allowed.',
|
|
89
92
|
},
|
|
90
93
|
old_text: {
|
|
91
94
|
type: 'string',
|
|
@@ -97,7 +100,8 @@ export const LocalEditFileToolSchema: t.JsonSchemaType = {
|
|
|
97
100
|
},
|
|
98
101
|
edits: {
|
|
99
102
|
type: 'array',
|
|
100
|
-
description:
|
|
103
|
+
description:
|
|
104
|
+
'Optional batch of exact replacements. Each old_text must appear exactly once in the original file.',
|
|
101
105
|
items: {
|
|
102
106
|
type: 'object',
|
|
103
107
|
properties: {
|
|
@@ -217,8 +221,7 @@ function lineWindow(
|
|
|
217
221
|
}
|
|
218
222
|
const numbered = out
|
|
219
223
|
.map(
|
|
220
|
-
(text, index) =>
|
|
221
|
-
`${String(start + index + 1).padStart(6, ' ')}\t${text}`
|
|
224
|
+
(text, index) => `${String(start + index + 1).padStart(6, ' ')}\t${text}`
|
|
222
225
|
)
|
|
223
226
|
.join('\n');
|
|
224
227
|
return {
|
|
@@ -247,10 +250,7 @@ async function maybeRunSyntaxCheck(
|
|
|
247
250
|
return { mode, outcome };
|
|
248
251
|
}
|
|
249
252
|
|
|
250
|
-
function appendSyntaxCheckSummary(
|
|
251
|
-
base: string,
|
|
252
|
-
run: SyntaxRun
|
|
253
|
-
): string {
|
|
253
|
+
function appendSyntaxCheckSummary(base: string, run: SyntaxRun): string {
|
|
254
254
|
if (run == null) return base;
|
|
255
255
|
if (run.outcome.ok) return base;
|
|
256
256
|
const banner =
|
|
@@ -395,7 +395,11 @@ export function createLocalReadFileTool(
|
|
|
395
395
|
offset?: number;
|
|
396
396
|
limit?: number;
|
|
397
397
|
};
|
|
398
|
-
const path = await resolveWorkspacePathSafe(
|
|
398
|
+
const path = await resolveWorkspacePathSafe(
|
|
399
|
+
input.file_path,
|
|
400
|
+
config,
|
|
401
|
+
'read'
|
|
402
|
+
);
|
|
399
403
|
const fileStat = await fs.stat(path);
|
|
400
404
|
if (!fileStat.isFile()) {
|
|
401
405
|
throw new Error(`Path is not a file: ${input.file_path}`);
|
|
@@ -416,8 +420,7 @@ export function createLocalReadFileTool(
|
|
|
416
420
|
path,
|
|
417
421
|
bytes: fileStat.size,
|
|
418
422
|
mode: attachmentMode,
|
|
419
|
-
maxBytes:
|
|
420
|
-
config.maxAttachmentBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
423
|
+
maxBytes: config.maxAttachmentBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
421
424
|
// Route through the configured WorkspaceFS so a custom
|
|
422
425
|
// engine sees the same path semantics as `read_file`
|
|
423
426
|
// itself (manual review finding F).
|
|
@@ -515,7 +518,11 @@ export function createLocalWriteFileTool(
|
|
|
515
518
|
if (config.readOnly === true) {
|
|
516
519
|
throw new Error('write_file is blocked in read-only local mode.');
|
|
517
520
|
}
|
|
518
|
-
const path = await resolveWorkspacePathSafe(
|
|
521
|
+
const path = await resolveWorkspacePathSafe(
|
|
522
|
+
input.file_path,
|
|
523
|
+
config,
|
|
524
|
+
'write'
|
|
525
|
+
);
|
|
519
526
|
if (checkpointer != null) {
|
|
520
527
|
await checkpointer.captureBeforeWrite(path);
|
|
521
528
|
}
|
|
@@ -604,7 +611,11 @@ export function createLocalEditFileTool(
|
|
|
604
611
|
throw new Error('edit_file requires old_text/new_text or edits[].');
|
|
605
612
|
}
|
|
606
613
|
|
|
607
|
-
const path = await resolveWorkspacePathSafe(
|
|
614
|
+
const path = await resolveWorkspacePathSafe(
|
|
615
|
+
input.file_path,
|
|
616
|
+
config,
|
|
617
|
+
'write'
|
|
618
|
+
);
|
|
608
619
|
const raw = await fs.readFile(path, 'utf8');
|
|
609
620
|
const encoding = decodeFile(raw);
|
|
610
621
|
const original = encoding.text;
|
|
@@ -727,7 +738,7 @@ async function isRipgrepAvailable(
|
|
|
727
738
|
{ ...config, timeoutMs: 5000, sandbox: { enabled: false } },
|
|
728
739
|
{ internal: true }
|
|
729
740
|
)
|
|
730
|
-
.then((probe) => probe
|
|
741
|
+
.then((probe) => probe.exitCode === 0)
|
|
731
742
|
.catch(() => false);
|
|
732
743
|
envMap.set(envKey, probePromise);
|
|
733
744
|
}
|
|
@@ -943,6 +954,17 @@ function compileFallbackRegex(pattern: string): RegExp {
|
|
|
943
954
|
* diagnostic skip-sentinels (Codex P2 [43]). */
|
|
944
955
|
type FallbackGrepResult = { matches: string[]; skipped: string[] };
|
|
945
956
|
|
|
957
|
+
/** Renders fallback-grep output: real matches first, skip diagnostics appended. */
|
|
958
|
+
function formatFallbackGrepDisplay(result: FallbackGrepResult): string {
|
|
959
|
+
if (result.matches.length > 0) {
|
|
960
|
+
return [...result.matches, ...result.skipped].join('\n');
|
|
961
|
+
}
|
|
962
|
+
if (result.skipped.length > 0) {
|
|
963
|
+
return result.skipped.join('\n');
|
|
964
|
+
}
|
|
965
|
+
return 'No matches found.';
|
|
966
|
+
}
|
|
967
|
+
|
|
946
968
|
async function fallbackGrep(
|
|
947
969
|
root: string,
|
|
948
970
|
pattern: string,
|
|
@@ -953,7 +975,9 @@ async function fallbackGrep(
|
|
|
953
975
|
const rx = compileFallbackRegex(pattern);
|
|
954
976
|
const deadline = Date.now() + FALLBACK_GREP_BUDGET_MS;
|
|
955
977
|
const globRx =
|
|
956
|
-
globFilter != null && globFilter !== ''
|
|
978
|
+
globFilter != null && globFilter !== ''
|
|
979
|
+
? globToRegExp(globFilter)
|
|
980
|
+
: undefined;
|
|
957
981
|
const matches: string[] = [];
|
|
958
982
|
// Track skipped (oversize) files separately so they don't consume
|
|
959
983
|
// the maxResults budget. Codex P2 [43]: round 14's fix pushed skip
|
|
@@ -970,7 +994,9 @@ async function fallbackGrep(
|
|
|
970
994
|
return { matches, skipped: skippedDiagnostics };
|
|
971
995
|
}
|
|
972
996
|
if (globRx != null) {
|
|
973
|
-
const rel = file.startsWith(root + '/')
|
|
997
|
+
const rel = file.startsWith(root + '/')
|
|
998
|
+
? file.slice(root.length + 1)
|
|
999
|
+
: file;
|
|
974
1000
|
if (!globRx.test(rel)) {
|
|
975
1001
|
continue;
|
|
976
1002
|
}
|
|
@@ -1028,7 +1054,9 @@ async function fallbackGlob(
|
|
|
1028
1054
|
const rx = globToRegExp(pattern);
|
|
1029
1055
|
const out: string[] = [];
|
|
1030
1056
|
for await (const file of walkFiles(root, fs)) {
|
|
1031
|
-
const rel = file.startsWith(root + '/')
|
|
1057
|
+
const rel = file.startsWith(root + '/')
|
|
1058
|
+
? file.slice(root.length + 1)
|
|
1059
|
+
: file;
|
|
1032
1060
|
if (rx.test(rel)) {
|
|
1033
1061
|
out.push(file);
|
|
1034
1062
|
if (out.length >= maxResults) {
|
|
@@ -1051,7 +1079,11 @@ export function createLocalGrepSearchTool(
|
|
|
1051
1079
|
glob?: string;
|
|
1052
1080
|
max_results?: number;
|
|
1053
1081
|
};
|
|
1054
|
-
const target = await resolveWorkspacePathSafe(
|
|
1082
|
+
const target = await resolveWorkspacePathSafe(
|
|
1083
|
+
input.path ?? '.',
|
|
1084
|
+
config,
|
|
1085
|
+
'read'
|
|
1086
|
+
);
|
|
1055
1087
|
const maxResults = Math.max(input.max_results ?? DEFAULT_MAX_RESULTS, 1);
|
|
1056
1088
|
|
|
1057
1089
|
if (await isRipgrepAvailable(config)) {
|
|
@@ -1067,7 +1099,9 @@ export function createLocalGrepSearchTool(
|
|
|
1067
1099
|
'--hidden',
|
|
1068
1100
|
'--glob',
|
|
1069
1101
|
'!.git/**',
|
|
1070
|
-
...(input.glob != null && input.glob !== ''
|
|
1102
|
+
...(input.glob != null && input.glob !== ''
|
|
1103
|
+
? ['--glob', input.glob]
|
|
1104
|
+
: []),
|
|
1071
1105
|
'-e',
|
|
1072
1106
|
input.pattern,
|
|
1073
1107
|
target,
|
|
@@ -1084,7 +1118,10 @@ export function createLocalGrepSearchTool(
|
|
|
1084
1118
|
// got from P2 #13), exit-2 errors silently mapped to
|
|
1085
1119
|
// `matches: 0`, so the agent treated tooling failures as a
|
|
1086
1120
|
// genuine absence of matches.
|
|
1087
|
-
if (
|
|
1121
|
+
if (
|
|
1122
|
+
result.timedOut ||
|
|
1123
|
+
(result.exitCode != null && result.exitCode > 1)
|
|
1124
|
+
) {
|
|
1088
1125
|
const detail = result.stderr.trim() || `rg exited ${result.exitCode}`;
|
|
1089
1126
|
return [
|
|
1090
1127
|
`grep_search failed: ${detail}`,
|
|
@@ -1096,7 +1133,10 @@ export function createLocalGrepSearchTool(
|
|
|
1096
1133
|
},
|
|
1097
1134
|
];
|
|
1098
1135
|
}
|
|
1099
|
-
const lines = result.stdout
|
|
1136
|
+
const lines = result.stdout
|
|
1137
|
+
.split('\n')
|
|
1138
|
+
.filter(Boolean)
|
|
1139
|
+
.slice(0, maxResults);
|
|
1100
1140
|
const output =
|
|
1101
1141
|
lines.length > 0
|
|
1102
1142
|
? lines.join('\n')
|
|
@@ -1112,15 +1152,9 @@ export function createLocalGrepSearchTool(
|
|
|
1112
1152
|
maxResults,
|
|
1113
1153
|
fs
|
|
1114
1154
|
);
|
|
1115
|
-
// Display: real matches first, skip diagnostics appended.
|
|
1116
1155
|
// Artifact count: ONLY real matches (Codex P2 [43] —
|
|
1117
1156
|
// skip sentinels used to inflate the count and the budget).
|
|
1118
|
-
const display =
|
|
1119
|
-
matches.length > 0
|
|
1120
|
-
? [...matches, ...skipped].join('\n')
|
|
1121
|
-
: skipped.length > 0
|
|
1122
|
-
? skipped.join('\n')
|
|
1123
|
-
: 'No matches found.';
|
|
1157
|
+
const display = formatFallbackGrepDisplay({ matches, skipped });
|
|
1124
1158
|
return [
|
|
1125
1159
|
display,
|
|
1126
1160
|
{
|
|
@@ -1165,13 +1199,25 @@ export function createLocalGlobSearchTool(
|
|
|
1165
1199
|
path?: string;
|
|
1166
1200
|
max_results?: number;
|
|
1167
1201
|
};
|
|
1168
|
-
const target = await resolveWorkspacePathSafe(
|
|
1202
|
+
const target = await resolveWorkspacePathSafe(
|
|
1203
|
+
input.path ?? '.',
|
|
1204
|
+
config,
|
|
1205
|
+
'read'
|
|
1206
|
+
);
|
|
1169
1207
|
const maxResults = Math.max(input.max_results ?? DEFAULT_MAX_RESULTS, 1);
|
|
1170
1208
|
|
|
1171
1209
|
if (await isRipgrepAvailable(config)) {
|
|
1172
1210
|
const result = await spawnLocalProcess(
|
|
1173
1211
|
'rg',
|
|
1174
|
-
[
|
|
1212
|
+
[
|
|
1213
|
+
'--files',
|
|
1214
|
+
'--hidden',
|
|
1215
|
+
'--glob',
|
|
1216
|
+
'!.git/**',
|
|
1217
|
+
'--glob',
|
|
1218
|
+
input.pattern,
|
|
1219
|
+
target,
|
|
1220
|
+
],
|
|
1175
1221
|
{ ...config, timeoutMs: config.timeoutMs ?? 30000 }
|
|
1176
1222
|
);
|
|
1177
1223
|
// rg --files exit codes:
|
|
@@ -1181,7 +1227,10 @@ export function createLocalGlobSearchTool(
|
|
|
1181
1227
|
// Without this branch, exit-2 errors used to silently map to
|
|
1182
1228
|
// "No files found." — the agent then treats a tooling failure
|
|
1183
1229
|
// as a real absence of matches.
|
|
1184
|
-
if (
|
|
1230
|
+
if (
|
|
1231
|
+
result.timedOut ||
|
|
1232
|
+
(result.exitCode != null && result.exitCode > 1)
|
|
1233
|
+
) {
|
|
1185
1234
|
const detail = result.stderr.trim() || `rg exited ${result.exitCode}`;
|
|
1186
1235
|
return [
|
|
1187
1236
|
`glob_search failed: ${detail}`,
|
|
@@ -1226,10 +1275,16 @@ export function createLocalListDirectoryTool(
|
|
|
1226
1275
|
return tool(
|
|
1227
1276
|
async (rawInput) => {
|
|
1228
1277
|
const input = rawInput as { path?: string };
|
|
1229
|
-
const path = await resolveWorkspacePathSafe(
|
|
1278
|
+
const path = await resolveWorkspacePathSafe(
|
|
1279
|
+
input.path ?? '.',
|
|
1280
|
+
config,
|
|
1281
|
+
'read'
|
|
1282
|
+
);
|
|
1230
1283
|
const entries = await fs.readdir(path, { withFileTypes: true });
|
|
1231
1284
|
const output = entries
|
|
1232
|
-
.map(
|
|
1285
|
+
.map(
|
|
1286
|
+
(entry) => `${entry.isDirectory() ? 'dir ' : 'file'}\t${entry.name}`
|
|
1287
|
+
)
|
|
1233
1288
|
.join('\n');
|
|
1234
1289
|
return [output || 'Directory is empty.', { path, count: entries.length }];
|
|
1235
1290
|
},
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { tmpdir } from 'os';
|
|
2
|
-
import {
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { createWriteStream } from 'fs';
|
|
3
4
|
import { createHash, randomUUID } from 'crypto';
|
|
5
|
+
import { isAbsolute, relative, resolve } from 'path';
|
|
4
6
|
import { mkdir, realpath, rm, writeFile } from 'fs/promises';
|
|
5
|
-
import { createWriteStream } from 'fs';
|
|
6
|
-
import { spawn } from 'child_process';
|
|
7
7
|
import type { ChildProcess } from 'child_process';
|
|
8
|
-
import { runBashAstChecks, bashAstFindingsToErrors } from './bashAst';
|
|
9
|
-
import { nodeWorkspaceFS } from './workspaceFS';
|
|
10
8
|
import type { WorkspaceFS } from './workspaceFS';
|
|
11
9
|
import type * as t from '@/types';
|
|
10
|
+
import { runBashAstChecks, bashAstFindingsToErrors } from './bashAst';
|
|
11
|
+
import { nodeWorkspaceFS } from './workspaceFS';
|
|
12
12
|
|
|
13
13
|
const DEFAULT_TIMEOUT_MS = 60000;
|
|
14
14
|
const DEFAULT_MAX_OUTPUT_CHARS = 200000;
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { tool } from '@langchain/core/tools';
|
|
2
2
|
import type { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
3
|
import type * as t from '@/types';
|
|
4
|
-
import {
|
|
5
|
-
CodeExecutionToolName,
|
|
6
|
-
CodeExecutionToolSchema,
|
|
7
|
-
} from '@/tools/CodeExecutor';
|
|
8
|
-
import {
|
|
9
|
-
BashExecutionToolName,
|
|
10
|
-
BashExecutionToolSchema,
|
|
11
|
-
BashToolOutputReferencesGuide,
|
|
12
|
-
} from '@/tools/BashExecutor';
|
|
13
4
|
import {
|
|
14
5
|
executeLocalBash,
|
|
15
6
|
executeLocalBashWithArgs,
|
|
@@ -17,6 +8,15 @@ import {
|
|
|
17
8
|
getLocalCwd,
|
|
18
9
|
getLocalSessionId,
|
|
19
10
|
} from './LocalExecutionEngine';
|
|
11
|
+
import {
|
|
12
|
+
BashExecutionToolName,
|
|
13
|
+
BashExecutionToolSchema,
|
|
14
|
+
BashToolOutputReferencesGuide,
|
|
15
|
+
} from '@/tools/BashExecutor';
|
|
16
|
+
import {
|
|
17
|
+
CodeExecutionToolName,
|
|
18
|
+
CodeExecutionToolSchema,
|
|
19
|
+
} from '@/tools/CodeExecutor';
|
|
20
20
|
import { Constants } from '@/common';
|
|
21
21
|
|
|
22
22
|
const emptyOutputMessage =
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { randomBytes, randomUUID, timingSafeEqual } from 'crypto';
|
|
2
1
|
import { createServer } from 'http';
|
|
3
2
|
import { tool } from '@langchain/core/tools';
|
|
4
|
-
import
|
|
5
|
-
import type { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
import { randomBytes, randomUUID, timingSafeEqual } from 'crypto';
|
|
6
4
|
import type { DynamicStructuredTool } from '@langchain/core/tools';
|
|
5
|
+
import type { IncomingMessage, ServerResponse } from 'http';
|
|
6
|
+
import type { AddressInfo } from 'net';
|
|
7
7
|
import type * as t from '@/types';
|
|
8
|
-
import { executeHooks } from '@/hooks';
|
|
9
8
|
import {
|
|
10
9
|
executeTools,
|
|
11
10
|
filterToolsByUsage,
|
|
@@ -27,6 +26,7 @@ import {
|
|
|
27
26
|
getLocalSessionId,
|
|
28
27
|
shellQuote,
|
|
29
28
|
} from './LocalExecutionEngine';
|
|
29
|
+
import { executeHooks } from '@/hooks';
|
|
30
30
|
import { Constants } from '@/common';
|
|
31
31
|
|
|
32
32
|
const DEFAULT_TIMEOUT = 60000;
|
|
@@ -219,6 +219,7 @@ export async function applyPreToolUseHooksForBridge(
|
|
|
219
219
|
runId: hookContext.runId,
|
|
220
220
|
threadId: hookContext.threadId,
|
|
221
221
|
agentId: hookContext.agentId,
|
|
222
|
+
executingAgentId: hookContext.executingAgentId,
|
|
222
223
|
toolName,
|
|
223
224
|
toolInput,
|
|
224
225
|
toolUseId,
|
|
@@ -112,12 +112,6 @@ const SUPPORTED_IMAGE_MIMES = new Set<string>([
|
|
|
112
112
|
'image/webp',
|
|
113
113
|
]);
|
|
114
114
|
|
|
115
|
-
/** Mime types that get returned to the model as inline attachments. */
|
|
116
|
-
const SUPPORTED_ATTACHMENT_MIMES = new Set<string>([
|
|
117
|
-
...SUPPORTED_IMAGE_MIMES,
|
|
118
|
-
'application/pdf',
|
|
119
|
-
]);
|
|
120
|
-
|
|
121
115
|
export type AttachmentMode = 'images-only' | 'images-and-pdf' | 'off';
|
|
122
116
|
|
|
123
117
|
export type Attachment =
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
Constants,
|
|
3
|
-
CODE_EXECUTION_TOOLS,
|
|
4
|
-
LOCAL_CODING_BUNDLE_NAMES,
|
|
5
|
-
} from '@/common';
|
|
6
|
-
import {
|
|
7
|
-
createLocalBashExecutionTool,
|
|
8
|
-
createLocalCodeExecutionTool,
|
|
9
|
-
} from './LocalExecutionTools';
|
|
10
|
-
import {
|
|
11
|
-
createLocalCodingToolBundle,
|
|
12
|
-
createLocalCodingToolDefinitions,
|
|
13
|
-
createLocalCodingTools,
|
|
14
|
-
} from './LocalCodingTools';
|
|
1
|
+
import type * as t from '@/types';
|
|
15
2
|
import {
|
|
16
3
|
createLocalBashProgrammaticToolCallingTool,
|
|
17
4
|
createLocalProgrammaticToolCallingTool,
|
|
@@ -21,7 +8,20 @@ import {
|
|
|
21
8
|
createCloudflareCodingTools,
|
|
22
9
|
createCloudflareExecutionTool,
|
|
23
10
|
} from '@/tools/cloudflare';
|
|
24
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
createLocalCodingToolBundle,
|
|
13
|
+
createLocalCodingToolDefinitions,
|
|
14
|
+
createLocalCodingTools,
|
|
15
|
+
} from './LocalCodingTools';
|
|
16
|
+
import {
|
|
17
|
+
createLocalBashExecutionTool,
|
|
18
|
+
createLocalCodeExecutionTool,
|
|
19
|
+
} from './LocalExecutionTools';
|
|
20
|
+
import {
|
|
21
|
+
Constants,
|
|
22
|
+
CODE_EXECUTION_TOOLS,
|
|
23
|
+
LOCAL_CODING_BUNDLE_NAMES,
|
|
24
|
+
} from '@/common';
|
|
25
25
|
|
|
26
26
|
type ResolveLocalToolsResult = {
|
|
27
27
|
toolMap: t.ToolMap;
|