@illuma-ai/agents 1.4.0-alpha.6 → 1.5.1
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/README.md +62 -0
- package/dist/cjs/agents/AgentContext.cjs +274 -67
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/common/enum.cjs +44 -13
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +182 -5
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +152 -1167
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/graphs/phases/memoryFlushPhase.cjs +1 -1
- package/dist/cjs/graphs/phases/memoryFlushPhase.cjs.map +1 -1
- package/dist/cjs/hooks/HookRegistry.cjs +162 -0
- package/dist/cjs/hooks/HookRegistry.cjs.map +1 -0
- package/dist/cjs/hooks/executeHooks.cjs +276 -0
- package/dist/cjs/hooks/executeHooks.cjs.map +1 -0
- package/dist/cjs/hooks/matchers.cjs +256 -0
- package/dist/cjs/hooks/matchers.cjs.map +1 -0
- package/dist/cjs/hooks/types.cjs +27 -0
- package/dist/cjs/hooks/types.cjs.map +1 -0
- package/dist/cjs/langchain/google-common.cjs +3 -0
- package/dist/cjs/langchain/google-common.cjs.map +1 -0
- package/dist/cjs/langchain/index.cjs +86 -0
- package/dist/cjs/langchain/index.cjs.map +1 -0
- package/dist/cjs/langchain/language_models/chat_models.cjs +3 -0
- package/dist/cjs/langchain/language_models/chat_models.cjs.map +1 -0
- package/dist/cjs/langchain/messages/tool.cjs +3 -0
- package/dist/cjs/langchain/messages/tool.cjs.map +1 -0
- package/dist/cjs/langchain/messages.cjs +51 -0
- package/dist/cjs/langchain/messages.cjs.map +1 -0
- package/dist/cjs/langchain/openai.cjs +3 -0
- package/dist/cjs/langchain/openai.cjs.map +1 -0
- package/dist/cjs/langchain/prompts.cjs +11 -0
- package/dist/cjs/langchain/prompts.cjs.map +1 -0
- package/dist/cjs/langchain/runnables.cjs +19 -0
- package/dist/cjs/langchain/runnables.cjs.map +1 -0
- package/dist/cjs/langchain/tools.cjs +23 -0
- package/dist/cjs/langchain/tools.cjs.map +1 -0
- package/dist/cjs/langchain/utils/env.cjs +11 -0
- package/dist/cjs/langchain/utils/env.cjs.map +1 -0
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +5 -1
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/cacheSupport.cjs +55 -0
- package/dist/cjs/llm/bedrock/cacheSupport.cjs.map +1 -0
- package/dist/cjs/llm/bedrock/index.cjs +61 -33
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +1 -4
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/utils/index.cjs +27 -10
- package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
- package/dist/cjs/main.cjs +178 -127
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/memory/citations.cjs +4 -4
- package/dist/cjs/memory/citations.cjs.map +1 -1
- package/dist/cjs/memory/constants.cjs +17 -17
- package/dist/cjs/memory/constants.cjs.map +1 -1
- package/dist/cjs/memory/mmr.cjs +1 -1
- package/dist/cjs/memory/mmr.cjs.map +1 -1
- package/dist/cjs/memory/paths.cjs +1 -1
- package/dist/cjs/memory/paths.cjs.map +1 -1
- package/dist/cjs/memory/recallTracking.cjs +3 -3
- package/dist/cjs/memory/recallTracking.cjs.map +1 -1
- package/dist/cjs/memory/temporalDecay.cjs +2 -2
- package/dist/cjs/memory/temporalDecay.cjs.map +1 -1
- package/dist/cjs/messages/cache.cjs +89 -0
- package/dist/cjs/messages/cache.cjs.map +1 -1
- package/dist/cjs/messages/contextPruning.cjs +156 -0
- package/dist/cjs/messages/contextPruning.cjs.map +1 -0
- package/dist/cjs/messages/contextPruningSettings.cjs +53 -0
- package/dist/cjs/messages/contextPruningSettings.cjs.map +1 -0
- package/dist/cjs/messages/format.cjs +144 -20
- package/dist/cjs/messages/format.cjs.map +1 -1
- package/dist/cjs/messages/prune.cjs +505 -4
- package/dist/cjs/messages/prune.cjs.map +1 -1
- package/dist/cjs/run.cjs +141 -1
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/tools/BashExecutor.cjs +235 -0
- package/dist/cjs/tools/BashExecutor.cjs.map +1 -0
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +297 -0
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -0
- package/dist/cjs/tools/CodeExecutor.cjs +45 -47
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +16 -11
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ReadFile.cjs +44 -0
- package/dist/cjs/tools/ReadFile.cjs.map +1 -0
- package/dist/cjs/tools/SkillTool.cjs +51 -0
- package/dist/cjs/tools/SkillTool.cjs.map +1 -0
- package/dist/cjs/tools/SubagentTool.cjs +93 -0
- package/dist/cjs/tools/SubagentTool.cjs.map +1 -0
- package/dist/cjs/tools/ToolNode.cjs +450 -24
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/memory/memoryAppendTool.cjs +1 -1
- package/dist/cjs/tools/memory/memoryAppendTool.cjs.map +1 -1
- package/dist/cjs/tools/memory/memoryGetTool.cjs +2 -2
- package/dist/cjs/tools/memory/memoryGetTool.cjs.map +1 -1
- package/dist/cjs/tools/memory/memorySearchTool.cjs +3 -3
- package/dist/cjs/tools/memory/memorySearchTool.cjs.map +1 -1
- package/dist/cjs/tools/memory/shared.cjs +1 -1
- package/dist/cjs/tools/memory/shared.cjs.map +1 -1
- package/dist/cjs/tools/search/search.cjs +11 -3
- package/dist/cjs/tools/search/search.cjs.map +1 -1
- package/dist/cjs/tools/search/tavily-scraper.cjs +189 -0
- package/dist/cjs/tools/search/tavily-scraper.cjs.map +1 -0
- package/dist/cjs/tools/search/tavily-search.cjs +372 -0
- package/dist/cjs/tools/search/tavily-search.cjs.map +1 -0
- package/dist/cjs/tools/search/tool.cjs +28 -4
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/cjs/tools/search/utils.cjs +10 -3
- package/dist/cjs/tools/search/utils.cjs.map +1 -1
- package/dist/cjs/tools/skillCatalog.cjs +84 -0
- package/dist/cjs/tools/skillCatalog.cjs.map +1 -0
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +512 -0
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -0
- package/dist/cjs/tools/toolOutputReferences.cjs +670 -0
- package/dist/cjs/tools/toolOutputReferences.cjs.map +1 -0
- package/dist/cjs/types/agent-cache.cjs +54 -0
- package/dist/cjs/types/agent-cache.cjs.map +1 -0
- package/dist/cjs/types/graph.cjs.map +1 -1
- package/dist/cjs/utils/truncation.cjs +135 -0
- package/dist/cjs/utils/truncation.cjs.map +1 -0
- package/dist/esm/agents/AgentContext.mjs +274 -67
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/common/enum.mjs +44 -12
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +182 -5
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +155 -1170
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/graphs/phases/memoryFlushPhase.mjs +1 -1
- package/dist/esm/graphs/phases/memoryFlushPhase.mjs.map +1 -1
- package/dist/esm/hooks/HookRegistry.mjs +160 -0
- package/dist/esm/hooks/HookRegistry.mjs.map +1 -0
- package/dist/esm/hooks/executeHooks.mjs +273 -0
- package/dist/esm/hooks/executeHooks.mjs.map +1 -0
- package/dist/esm/hooks/matchers.mjs +251 -0
- package/dist/esm/hooks/matchers.mjs.map +1 -0
- package/dist/esm/hooks/types.mjs +25 -0
- package/dist/esm/hooks/types.mjs.map +1 -0
- package/dist/esm/langchain/google-common.mjs +2 -0
- package/dist/esm/langchain/google-common.mjs.map +1 -0
- package/dist/esm/langchain/index.mjs +5 -0
- package/dist/esm/langchain/language_models/chat_models.mjs +2 -0
- package/dist/esm/langchain/language_models/chat_models.mjs.map +1 -0
- package/dist/esm/langchain/messages/tool.mjs +2 -0
- package/dist/esm/langchain/messages/tool.mjs.map +1 -0
- package/dist/esm/langchain/messages.mjs +2 -0
- package/dist/esm/langchain/messages.mjs.map +1 -0
- package/dist/esm/langchain/openai.mjs +2 -0
- package/dist/esm/langchain/openai.mjs.map +1 -0
- package/dist/esm/langchain/prompts.mjs +2 -0
- package/dist/esm/langchain/prompts.mjs.map +1 -0
- package/dist/esm/langchain/runnables.mjs +2 -0
- package/dist/esm/langchain/runnables.mjs.map +1 -0
- package/dist/esm/langchain/tools.mjs +2 -0
- package/dist/esm/langchain/tools.mjs.map +1 -0
- package/dist/esm/langchain/utils/env.mjs +2 -0
- package/dist/esm/langchain/utils/env.mjs.map +1 -0
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs +5 -1
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/bedrock/cacheSupport.mjs +52 -0
- package/dist/esm/llm/bedrock/cacheSupport.mjs.map +1 -0
- package/dist/esm/llm/bedrock/index.mjs +61 -34
- package/dist/esm/llm/bedrock/index.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +1 -4
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/llm/openai/utils/index.mjs +27 -10
- package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
- package/dist/esm/main.mjs +21 -27
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/memory/citations.mjs +4 -4
- package/dist/esm/memory/citations.mjs.map +1 -1
- package/dist/esm/memory/constants.mjs +17 -17
- package/dist/esm/memory/constants.mjs.map +1 -1
- package/dist/esm/memory/mmr.mjs +1 -1
- package/dist/esm/memory/mmr.mjs.map +1 -1
- package/dist/esm/memory/paths.mjs +1 -1
- package/dist/esm/memory/paths.mjs.map +1 -1
- package/dist/esm/memory/recallTracking.mjs +3 -3
- package/dist/esm/memory/recallTracking.mjs.map +1 -1
- package/dist/esm/memory/temporalDecay.mjs +2 -2
- package/dist/esm/memory/temporalDecay.mjs.map +1 -1
- package/dist/esm/messages/cache.mjs +89 -0
- package/dist/esm/messages/cache.mjs.map +1 -1
- package/dist/esm/messages/contextPruning.mjs +154 -0
- package/dist/esm/messages/contextPruning.mjs.map +1 -0
- package/dist/esm/messages/contextPruningSettings.mjs +50 -0
- package/dist/esm/messages/contextPruningSettings.mjs.map +1 -0
- package/dist/esm/messages/format.mjs +136 -12
- package/dist/esm/messages/format.mjs.map +1 -1
- package/dist/esm/messages/prune.mjs +504 -7
- package/dist/esm/messages/prune.mjs.map +1 -1
- package/dist/esm/run.mjs +141 -1
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/tools/BashExecutor.mjs +227 -0
- package/dist/esm/tools/BashExecutor.mjs.map +1 -0
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs +288 -0
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -0
- package/dist/esm/tools/CodeExecutor.mjs +45 -48
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +17 -12
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ReadFile.mjs +39 -0
- package/dist/esm/tools/ReadFile.mjs.map +1 -0
- package/dist/esm/tools/SkillTool.mjs +46 -0
- package/dist/esm/tools/SkillTool.mjs.map +1 -0
- package/dist/esm/tools/SubagentTool.mjs +86 -0
- package/dist/esm/tools/SubagentTool.mjs.map +1 -0
- package/dist/esm/tools/ToolNode.mjs +452 -26
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/memory/memoryAppendTool.mjs +1 -1
- package/dist/esm/tools/memory/memoryAppendTool.mjs.map +1 -1
- package/dist/esm/tools/memory/memoryGetTool.mjs +2 -2
- package/dist/esm/tools/memory/memoryGetTool.mjs.map +1 -1
- package/dist/esm/tools/memory/memorySearchTool.mjs +3 -3
- package/dist/esm/tools/memory/memorySearchTool.mjs.map +1 -1
- package/dist/esm/tools/memory/shared.mjs +1 -1
- package/dist/esm/tools/memory/shared.mjs.map +1 -1
- package/dist/esm/tools/search/search.mjs +11 -3
- package/dist/esm/tools/search/search.mjs.map +1 -1
- package/dist/esm/tools/search/tavily-scraper.mjs +186 -0
- package/dist/esm/tools/search/tavily-scraper.mjs.map +1 -0
- package/dist/esm/tools/search/tavily-search.mjs +370 -0
- package/dist/esm/tools/search/tavily-search.mjs.map +1 -0
- package/dist/esm/tools/search/tool.mjs +28 -4
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/esm/tools/search/utils.mjs +10 -3
- package/dist/esm/tools/search/utils.mjs.map +1 -1
- package/dist/esm/tools/skillCatalog.mjs +82 -0
- package/dist/esm/tools/skillCatalog.mjs.map +1 -0
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +506 -0
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -0
- package/dist/esm/tools/toolOutputReferences.mjs +662 -0
- package/dist/esm/tools/toolOutputReferences.mjs.map +1 -0
- package/dist/esm/types/agent-cache.mjs +52 -0
- package/dist/esm/types/agent-cache.mjs.map +1 -0
- package/dist/esm/types/graph.mjs.map +1 -1
- package/dist/esm/utils/truncation.mjs +128 -0
- package/dist/esm/utils/truncation.mjs.map +1 -0
- package/dist/types/agents/AgentContext.d.ts +101 -8
- package/dist/types/common/enum.d.ts +39 -12
- package/dist/types/common/index.d.ts +0 -1
- package/dist/types/graphs/Graph.d.ts +43 -0
- package/dist/types/graphs/MultiAgentGraph.d.ts +26 -150
- package/dist/types/graphs/index.d.ts +0 -1
- package/dist/types/graphs/phases/memoryFlushPhase.d.ts +2 -2
- package/dist/types/hooks/HookRegistry.d.ts +56 -0
- package/dist/types/hooks/executeHooks.d.ts +79 -0
- package/dist/types/hooks/index.d.ts +6 -0
- package/dist/types/hooks/matchers.d.ts +95 -0
- package/dist/types/hooks/types.d.ts +320 -0
- package/dist/types/index.d.ts +9 -9
- package/dist/types/langchain/google-common.d.ts +1 -0
- package/dist/types/langchain/index.d.ts +8 -0
- package/dist/types/langchain/language_models/chat_models.d.ts +1 -0
- package/dist/types/langchain/messages/tool.d.ts +1 -0
- package/dist/types/langchain/messages.d.ts +2 -0
- package/dist/types/langchain/openai.d.ts +1 -0
- package/dist/types/langchain/prompts.d.ts +1 -0
- package/dist/types/langchain/runnables.d.ts +2 -0
- package/dist/types/langchain/tools.d.ts +2 -0
- package/dist/types/langchain/utils/env.d.ts +1 -0
- package/dist/types/llm/bedrock/cacheSupport.d.ts +35 -0
- package/dist/types/llm/bedrock/index.d.ts +54 -1
- package/dist/types/llm/openai/index.d.ts +1 -1
- package/dist/types/memory/citations.d.ts +4 -4
- package/dist/types/memory/constants.d.ts +17 -17
- package/dist/types/memory/mmr.d.ts +3 -3
- package/dist/types/memory/paths.d.ts +1 -1
- package/dist/types/memory/temporalDecay.d.ts +2 -2
- package/dist/types/memory/types.d.ts +3 -3
- package/dist/types/messages/contextPruning.d.ts +42 -0
- package/dist/types/messages/contextPruningSettings.d.ts +44 -0
- package/dist/types/messages/format.d.ts +9 -1
- package/dist/types/messages/index.d.ts +2 -0
- package/dist/types/messages/prune.d.ts +91 -1
- package/dist/types/run.d.ts +2 -0
- package/dist/types/tools/BashExecutor.d.ts +76 -0
- package/dist/types/tools/BashProgrammaticToolCalling.d.ts +72 -0
- package/dist/types/tools/CodeExecutor.d.ts +8 -26
- package/dist/types/tools/ReadFile.d.ts +28 -0
- package/dist/types/tools/SkillTool.d.ts +40 -0
- package/dist/types/tools/SubagentTool.d.ts +36 -0
- package/dist/types/tools/ToolNode.d.ts +77 -5
- package/dist/types/tools/memory/shared.d.ts +1 -1
- package/dist/types/tools/search/tavily-scraper.d.ts +19 -0
- package/dist/types/tools/search/tavily-search.d.ts +4 -0
- package/dist/types/tools/search/types.d.ts +99 -5
- package/dist/types/tools/search/utils.d.ts +2 -2
- package/dist/types/tools/skillCatalog.d.ts +19 -0
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +137 -0
- package/dist/types/tools/subagent/index.d.ts +2 -0
- package/dist/types/tools/subagent/types.d.ts +84 -0
- package/dist/types/tools/toolOutputReferences.d.ts +236 -0
- package/dist/types/types/agent-cache.d.ts +71 -0
- package/dist/types/types/graph.d.ts +163 -22
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/messages.d.ts +26 -0
- package/dist/types/types/run.d.ts +22 -0
- package/dist/types/types/skill.d.ts +9 -0
- package/dist/types/types/tools.d.ts +111 -0
- package/dist/types/utils/index.d.ts +1 -3
- package/dist/types/utils/truncation.d.ts +70 -0
- package/package.json +57 -17
- package/src/agents/AgentContext.ts +321 -78
- package/src/agents/__tests__/AgentContext.cacheTtl.live.test.ts +259 -0
- package/src/agents/__tests__/AgentContext.crossAgentTier1.live.test.ts +266 -0
- package/src/agents/__tests__/AgentContext.crossUserCache.live.test.ts +342 -0
- package/src/agents/__tests__/AgentContext.test.ts +632 -0
- package/src/common/__tests__/enum.test.ts +7 -17
- package/src/common/enum.ts +43 -12
- package/src/common/index.ts +0 -1
- package/src/graphs/Graph.ts +222 -2
- package/src/graphs/MultiAgentGraph.ts +154 -1466
- package/src/graphs/__tests__/MultiAgentGraph.test.ts +91 -0
- package/src/graphs/gapFeatures.test.ts +1 -1
- package/src/graphs/index.ts +0 -1
- package/src/graphs/phases/__tests__/memoryFlushPhase.test.ts +1 -1
- package/src/graphs/phases/memoryFlushPhase.ts +2 -2
- package/src/hooks/HookRegistry.ts +208 -0
- package/src/hooks/__tests__/HookRegistry.test.ts +190 -0
- package/src/hooks/__tests__/compactHooks.test.ts +214 -0
- package/src/hooks/__tests__/executeHooks.test.ts +1013 -0
- package/src/hooks/__tests__/integration.test.ts +337 -0
- package/src/hooks/__tests__/matchers.test.ts +238 -0
- package/src/hooks/__tests__/toolHooks.test.ts +665 -0
- package/src/hooks/executeHooks.ts +375 -0
- package/src/hooks/index.ts +57 -0
- package/src/hooks/matchers.ts +280 -0
- package/src/hooks/types.ts +404 -0
- package/src/index.ts +15 -24
- package/src/langchain/google-common.ts +1 -0
- package/src/langchain/index.ts +8 -0
- package/src/langchain/language_models/chat_models.ts +1 -0
- package/src/langchain/messages/tool.ts +5 -0
- package/src/langchain/messages.ts +21 -0
- package/src/langchain/openai.ts +1 -0
- package/src/langchain/prompts.ts +1 -0
- package/src/langchain/runnables.ts +7 -0
- package/src/langchain/tools.ts +8 -0
- package/src/langchain/utils/env.ts +1 -0
- package/src/llm/anthropic/utils/message_inputs.ts +10 -1
- package/src/llm/anthropic/utils/server-tool-inputs.test.ts +436 -0
- package/src/llm/bedrock/__tests__/bedrock-caching.test.ts +166 -18
- package/src/llm/bedrock/cacheSupport.test.ts +99 -0
- package/src/llm/bedrock/cacheSupport.ts +53 -0
- package/src/llm/bedrock/index.ts +116 -41
- package/src/llm/openai/index.ts +2 -2
- package/src/llm/openai/utils/index.ts +31 -14
- package/src/memory/citations.ts +4 -4
- package/src/memory/constants.ts +17 -17
- package/src/memory/mmr.ts +3 -3
- package/src/memory/paths.ts +1 -1
- package/src/memory/recallTracking.ts +3 -3
- package/src/memory/temporalDecay.ts +2 -2
- package/src/memory/types.ts +3 -3
- package/src/messages/__tests__/contextPruning.test.ts +228 -0
- package/src/messages/cache.test.ts +62 -24
- package/src/messages/cache.ts +112 -0
- package/src/messages/contextPruning.ts +191 -0
- package/src/messages/contextPruningSettings.ts +90 -0
- package/src/messages/ensureThinkingBlock.test.ts +1 -1
- package/src/messages/format.ts +164 -12
- package/src/messages/formatAgentMessages.skills.test.ts +413 -0
- package/src/messages/formatAgentMessages.test.ts +1 -1
- package/src/messages/index.ts +2 -0
- package/src/messages/prune.ts +661 -4
- package/src/run.ts +155 -1
- package/src/scripts/multi-agent-chain.ts +2 -2
- package/src/scripts/multi-agent-document-review-chain.ts +2 -2
- package/src/scripts/multi-agent-hybrid-flow.ts +4 -4
- package/src/scripts/multi-agent-parallel.ts +3 -3
- package/src/scripts/multi-agent-sequence.ts +3 -3
- package/src/scripts/multi-agent-subagent.ts +246 -0
- package/src/scripts/multi-agent-supervisor.ts +5 -5
- package/src/scripts/poc-multi-agent-comprehensive.ts +8 -8
- package/src/scripts/sequential-full-metadata-test.ts +2 -2
- package/src/scripts/subagent-event-driven-debug.ts +190 -0
- package/src/scripts/subagent-tools-debug.ts +160 -0
- package/src/scripts/test-custom-prompt-key.ts +3 -3
- package/src/scripts/test-handoff-input.ts +1 -1
- package/src/scripts/test-handoff-steering.ts +3 -3
- package/src/scripts/test-multi-agent-list-handoff.ts +1 -1
- package/src/scripts/test-parallel-agent-labeling.ts +3 -3
- package/src/scripts/test-parallel-handoffs.ts +2 -2
- package/src/scripts/test-thinking-handoff-bedrock.ts +1 -1
- package/src/scripts/test-thinking-handoff.ts +1 -1
- package/src/scripts/test-thinking-to-thinking-handoff-bedrock.ts +1 -1
- package/src/scripts/test-tool-before-handoff-role-order.ts +1 -1
- package/src/scripts/test-tools-before-handoff.ts +1 -1
- package/src/specs/agent-handoffs.test.ts +26 -483
- package/src/specs/anthropic.simple.test.ts +61 -0
- package/src/specs/multi-agent-summarization.test.ts +396 -0
- package/src/specs/prune.orphans.test.ts +248 -0
- package/src/specs/prune.test.ts +104 -16
- package/src/specs/thinking-handoff.test.ts +19 -19
- package/src/tools/BashExecutor.ts +281 -0
- package/src/tools/BashProgrammaticToolCalling.ts +397 -0
- package/src/tools/CodeExecutor.ts +63 -54
- package/src/tools/ProgrammaticToolCalling.ts +29 -14
- package/src/tools/ReadFile.ts +39 -0
- package/src/tools/SkillTool.ts +46 -0
- package/src/tools/SubagentTool.ts +100 -0
- package/src/tools/ToolNode.ts +548 -26
- package/src/tools/__tests__/BashExecutor.test.ts +49 -0
- package/src/tools/__tests__/CodeExecutor.test.ts +37 -36
- package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +60 -0
- package/src/tools/__tests__/ReadFile.test.ts +44 -0
- package/src/tools/__tests__/SkillTool.test.ts +442 -0
- package/src/tools/__tests__/SubagentExecutor.test.ts +1148 -0
- package/src/tools/__tests__/SubagentTool.test.ts +149 -0
- package/src/tools/__tests__/ToolNode.outputReferences.test.ts +1438 -0
- package/src/tools/__tests__/annotateMessagesForLLM.test.ts +479 -0
- package/src/tools/__tests__/skillCatalog.test.ts +161 -0
- package/src/tools/__tests__/subagentHooks.test.ts +210 -0
- package/src/tools/__tests__/toolOutputReferences.test.ts +415 -0
- package/src/tools/memory/memoryAppendTool.ts +1 -1
- package/src/tools/memory/memoryGetTool.ts +2 -2
- package/src/tools/memory/memorySearchTool.ts +3 -3
- package/src/tools/memory/shared.ts +1 -1
- package/src/tools/search/search.ts +12 -2
- package/src/tools/search/tavily-scraper.ts +235 -0
- package/src/tools/search/tavily-search.ts +424 -0
- package/src/tools/search/tavily.test.ts +965 -0
- package/src/tools/search/tool.ts +36 -2
- package/src/tools/search/types.ts +133 -8
- package/src/tools/search/utils.ts +13 -5
- package/src/tools/skillCatalog.ts +126 -0
- package/src/tools/subagent/SubagentExecutor.ts +676 -0
- package/src/tools/subagent/index.ts +13 -0
- package/src/tools/subagent/types.test.ts +70 -0
- package/src/tools/subagent/types.ts +115 -0
- package/src/tools/toolOutputReferences.ts +825 -0
- package/src/types/agent-cache.ts +74 -0
- package/src/types/graph.ts +172 -20
- package/src/types/index.ts +3 -0
- package/src/types/messages.ts +27 -0
- package/src/types/run.ts +22 -0
- package/src/types/skill.ts +11 -0
- package/src/types/tools.ts +118 -0
- package/src/utils/__tests__/truncation.test.ts +66 -0
- package/src/utils/index.ts +1 -3
- package/src/utils/truncation.ts +154 -0
- package/dist/cjs/common/spawnPath.cjs +0 -104
- package/dist/cjs/common/spawnPath.cjs.map +0 -1
- package/dist/cjs/content/ArtifactStore.cjs +0 -579
- package/dist/cjs/content/ArtifactStore.cjs.map +0 -1
- package/dist/cjs/content/ContentStore.cjs +0 -638
- package/dist/cjs/content/ContentStore.cjs.map +0 -1
- package/dist/cjs/content/contentAnalyzer.cjs +0 -91
- package/dist/cjs/content/contentAnalyzer.cjs.map +0 -1
- package/dist/cjs/content/index.cjs +0 -20
- package/dist/cjs/content/index.cjs.map +0 -1
- package/dist/cjs/content/mcpAutoCache.cjs +0 -115
- package/dist/cjs/content/mcpAutoCache.cjs.map +0 -1
- package/dist/cjs/graphs/HandoffRegistry.cjs +0 -143
- package/dist/cjs/graphs/HandoffRegistry.cjs.map +0 -1
- package/dist/cjs/providers/a2a/A2ACapabilityProvider.cjs +0 -288
- package/dist/cjs/providers/a2a/A2ACapabilityProvider.cjs.map +0 -1
- package/dist/cjs/providers/a2a/client.cjs +0 -92
- package/dist/cjs/providers/a2a/client.cjs.map +0 -1
- package/dist/cjs/providers/a2a/config.cjs +0 -38
- package/dist/cjs/providers/a2a/config.cjs.map +0 -1
- package/dist/cjs/providers/capabilityNaming.cjs +0 -43
- package/dist/cjs/providers/capabilityNaming.cjs.map +0 -1
- package/dist/cjs/providers/mcp/MCPCapabilityProvider.cjs +0 -244
- package/dist/cjs/providers/mcp/MCPCapabilityProvider.cjs.map +0 -1
- package/dist/cjs/providers/mcp/config.cjs +0 -42
- package/dist/cjs/providers/mcp/config.cjs.map +0 -1
- package/dist/cjs/providers/mcp/transport.cjs +0 -65
- package/dist/cjs/providers/mcp/transport.cjs.map +0 -1
- package/dist/cjs/providers/tools-server/ToolsServerCapabilityProvider.cjs +0 -128
- package/dist/cjs/providers/tools-server/ToolsServerCapabilityProvider.cjs.map +0 -1
- package/dist/cjs/providers/types.cjs +0 -51
- package/dist/cjs/providers/types.cjs.map +0 -1
- package/dist/cjs/tools/artifacts/schema.cjs +0 -86
- package/dist/cjs/tools/artifacts/schema.cjs.map +0 -1
- package/dist/cjs/tools/artifacts/tool.cjs +0 -219
- package/dist/cjs/tools/artifacts/tool.cjs.map +0 -1
- package/dist/cjs/tools/fileSearch/formatter.cjs +0 -93
- package/dist/cjs/tools/fileSearch/formatter.cjs.map +0 -1
- package/dist/cjs/tools/fileSearch/ragClient.cjs +0 -102
- package/dist/cjs/tools/fileSearch/ragClient.cjs.map +0 -1
- package/dist/cjs/tools/fileSearch/schema.cjs +0 -18
- package/dist/cjs/tools/fileSearch/schema.cjs.map +0 -1
- package/dist/cjs/tools/fileSearch/tool.cjs +0 -155
- package/dist/cjs/tools/fileSearch/tool.cjs.map +0 -1
- package/dist/cjs/tools/proxyTool.cjs +0 -102
- package/dist/cjs/tools/proxyTool.cjs.map +0 -1
- package/dist/cjs/utils/childAgentContext.cjs +0 -242
- package/dist/cjs/utils/childAgentContext.cjs.map +0 -1
- package/dist/cjs/utils/credentials.cjs +0 -142
- package/dist/cjs/utils/credentials.cjs.map +0 -1
- package/dist/cjs/utils/httpClient.cjs +0 -74
- package/dist/cjs/utils/httpClient.cjs.map +0 -1
- package/dist/cjs/utils/toolManifest.cjs +0 -100
- package/dist/cjs/utils/toolManifest.cjs.map +0 -1
- package/dist/esm/common/spawnPath.mjs +0 -95
- package/dist/esm/common/spawnPath.mjs.map +0 -1
- package/dist/esm/content/ArtifactStore.mjs +0 -576
- package/dist/esm/content/ArtifactStore.mjs.map +0 -1
- package/dist/esm/content/ContentStore.mjs +0 -635
- package/dist/esm/content/ContentStore.mjs.map +0 -1
- package/dist/esm/content/contentAnalyzer.mjs +0 -87
- package/dist/esm/content/contentAnalyzer.mjs.map +0 -1
- package/dist/esm/content/index.mjs +0 -5
- package/dist/esm/content/mcpAutoCache.mjs +0 -111
- package/dist/esm/content/mcpAutoCache.mjs.map +0 -1
- package/dist/esm/graphs/HandoffRegistry.mjs +0 -141
- package/dist/esm/graphs/HandoffRegistry.mjs.map +0 -1
- package/dist/esm/providers/a2a/A2ACapabilityProvider.mjs +0 -281
- package/dist/esm/providers/a2a/A2ACapabilityProvider.mjs.map +0 -1
- package/dist/esm/providers/a2a/client.mjs +0 -88
- package/dist/esm/providers/a2a/client.mjs.map +0 -1
- package/dist/esm/providers/a2a/config.mjs +0 -35
- package/dist/esm/providers/a2a/config.mjs.map +0 -1
- package/dist/esm/providers/capabilityNaming.mjs +0 -39
- package/dist/esm/providers/capabilityNaming.mjs.map +0 -1
- package/dist/esm/providers/mcp/MCPCapabilityProvider.mjs +0 -240
- package/dist/esm/providers/mcp/MCPCapabilityProvider.mjs.map +0 -1
- package/dist/esm/providers/mcp/config.mjs +0 -39
- package/dist/esm/providers/mcp/config.mjs.map +0 -1
- package/dist/esm/providers/mcp/transport.mjs +0 -63
- package/dist/esm/providers/mcp/transport.mjs.map +0 -1
- package/dist/esm/providers/tools-server/ToolsServerCapabilityProvider.mjs +0 -126
- package/dist/esm/providers/tools-server/ToolsServerCapabilityProvider.mjs.map +0 -1
- package/dist/esm/providers/types.mjs +0 -51
- package/dist/esm/providers/types.mjs.map +0 -1
- package/dist/esm/tools/artifacts/schema.mjs +0 -79
- package/dist/esm/tools/artifacts/schema.mjs.map +0 -1
- package/dist/esm/tools/artifacts/tool.mjs +0 -213
- package/dist/esm/tools/artifacts/tool.mjs.map +0 -1
- package/dist/esm/tools/fileSearch/formatter.mjs +0 -90
- package/dist/esm/tools/fileSearch/formatter.mjs.map +0 -1
- package/dist/esm/tools/fileSearch/ragClient.mjs +0 -98
- package/dist/esm/tools/fileSearch/ragClient.mjs.map +0 -1
- package/dist/esm/tools/fileSearch/schema.mjs +0 -15
- package/dist/esm/tools/fileSearch/schema.mjs.map +0 -1
- package/dist/esm/tools/fileSearch/tool.mjs +0 -152
- package/dist/esm/tools/fileSearch/tool.mjs.map +0 -1
- package/dist/esm/tools/proxyTool.mjs +0 -100
- package/dist/esm/tools/proxyTool.mjs.map +0 -1
- package/dist/esm/utils/childAgentContext.mjs +0 -237
- package/dist/esm/utils/childAgentContext.mjs.map +0 -1
- package/dist/esm/utils/credentials.mjs +0 -135
- package/dist/esm/utils/credentials.mjs.map +0 -1
- package/dist/esm/utils/httpClient.mjs +0 -70
- package/dist/esm/utils/httpClient.mjs.map +0 -1
- package/dist/esm/utils/toolManifest.mjs +0 -96
- package/dist/esm/utils/toolManifest.mjs.map +0 -1
- package/dist/types/common/spawnPath.d.ts +0 -59
- package/dist/types/content/ArtifactStore.d.ts +0 -223
- package/dist/types/content/ContentStore.d.ts +0 -140
- package/dist/types/content/contentAnalyzer.d.ts +0 -38
- package/dist/types/content/index.d.ts +0 -24
- package/dist/types/content/mcpAutoCache.d.ts +0 -89
- package/dist/types/content/types.d.ts +0 -75
- package/dist/types/graphs/HandoffRegistry.d.ts +0 -97
- package/dist/types/providers/a2a/A2ACapabilityProvider.d.ts +0 -89
- package/dist/types/providers/a2a/client.d.ts +0 -47
- package/dist/types/providers/a2a/config.d.ts +0 -18
- package/dist/types/providers/a2a/index.d.ts +0 -6
- package/dist/types/providers/a2a/types.d.ts +0 -173
- package/dist/types/providers/capabilityNaming.d.ts +0 -25
- package/dist/types/providers/index.d.ts +0 -12
- package/dist/types/providers/mcp/MCPCapabilityProvider.d.ts +0 -54
- package/dist/types/providers/mcp/config.d.ts +0 -20
- package/dist/types/providers/mcp/index.d.ts +0 -5
- package/dist/types/providers/mcp/transport.d.ts +0 -18
- package/dist/types/providers/mcp/types.d.ts +0 -112
- package/dist/types/providers/tools-server/ToolsServerCapabilityProvider.d.ts +0 -59
- package/dist/types/providers/tools-server/index.d.ts +0 -1
- package/dist/types/providers/types.d.ts +0 -184
- package/dist/types/tools/artifacts/index.d.ts +0 -3
- package/dist/types/tools/artifacts/schema.d.ts +0 -63
- package/dist/types/tools/artifacts/tool.d.ts +0 -16
- package/dist/types/tools/artifacts/types.d.ts +0 -127
- package/dist/types/tools/fileSearch/formatter.d.ts +0 -25
- package/dist/types/tools/fileSearch/index.d.ts +0 -5
- package/dist/types/tools/fileSearch/ragClient.d.ts +0 -32
- package/dist/types/tools/fileSearch/schema.d.ts +0 -13
- package/dist/types/tools/fileSearch/tool.d.ts +0 -18
- package/dist/types/tools/fileSearch/types.d.ts +0 -139
- package/dist/types/tools/proxyTool.d.ts +0 -62
- package/dist/types/tools/search/test.d.ts +0 -1
- package/dist/types/utils/childAgentContext.d.ts +0 -99
- package/dist/types/utils/credentials.d.ts +0 -77
- package/dist/types/utils/httpClient.d.ts +0 -46
- package/dist/types/utils/toolManifest.d.ts +0 -49
- package/src/common/__tests__/spawnPath.test.ts +0 -110
- package/src/common/spawnPath.ts +0 -101
- package/src/content/ArtifactStore.ts +0 -782
- package/src/content/ContentStore.ts +0 -753
- package/src/content/contentAnalyzer.ts +0 -105
- package/src/content/index.ts +0 -51
- package/src/content/mcpAutoCache.ts +0 -185
- package/src/content/types.ts +0 -82
- package/src/graphs/HandoffRegistry.ts +0 -199
- package/src/graphs/__tests__/HandoffRegistry.test.ts +0 -410
- package/src/graphs/__tests__/multi-agent-delegate.test.ts +0 -458
- package/src/graphs/__tests__/multi-agent-edges.test.ts +0 -276
- package/src/graphs/__tests__/multi-agent-nested-subgraph.test.ts +0 -221
- package/src/graphs/handoffValidation.test.ts +0 -353
- package/src/providers/__tests__/ToolsServerCapabilityProvider.integration.spec.ts +0 -79
- package/src/providers/__tests__/ToolsServerCapabilityProvider.test.ts +0 -271
- package/src/providers/__tests__/types.test.ts +0 -64
- package/src/providers/a2a/A2ACapabilityProvider.ts +0 -384
- package/src/providers/a2a/__tests__/A2ACapabilityProvider.integration.spec.ts +0 -345
- package/src/providers/a2a/__tests__/A2ACapabilityProvider.test.ts +0 -460
- package/src/providers/a2a/client.ts +0 -115
- package/src/providers/a2a/config.ts +0 -40
- package/src/providers/a2a/index.ts +0 -29
- package/src/providers/a2a/types.ts +0 -191
- package/src/providers/capabilityNaming.ts +0 -42
- package/src/providers/index.ts +0 -68
- package/src/providers/mcp/MCPCapabilityProvider.ts +0 -345
- package/src/providers/mcp/__tests__/MCPCapabilityProvider.integration.spec.ts +0 -386
- package/src/providers/mcp/__tests__/MCPCapabilityProvider.test.ts +0 -371
- package/src/providers/mcp/config.ts +0 -45
- package/src/providers/mcp/index.ts +0 -21
- package/src/providers/mcp/transport.ts +0 -76
- package/src/providers/mcp/types.ts +0 -139
- package/src/providers/tools-server/ToolsServerCapabilityProvider.ts +0 -249
- package/src/providers/tools-server/index.ts +0 -1
- package/src/providers/types.ts +0 -204
- package/src/scripts/test-bedrock-handoff-autonomous.ts +0 -267
- package/src/scripts/test-handoff-preamble.ts +0 -278
- package/src/specs/agent-handoffs-bedrock.integration.test.ts +0 -415
- package/src/tools/artifacts/__tests__/tool.test.ts +0 -259
- package/src/tools/artifacts/index.ts +0 -33
- package/src/tools/artifacts/schema.ts +0 -99
- package/src/tools/artifacts/tool.ts +0 -289
- package/src/tools/artifacts/types.ts +0 -162
- package/src/tools/fileSearch/__tests__/tool.test.ts +0 -261
- package/src/tools/fileSearch/formatter.ts +0 -129
- package/src/tools/fileSearch/index.ts +0 -23
- package/src/tools/fileSearch/ragClient.ts +0 -137
- package/src/tools/fileSearch/schema.ts +0 -19
- package/src/tools/fileSearch/tool.ts +0 -207
- package/src/tools/fileSearch/types.ts +0 -149
- package/src/tools/proxyTool.ts +0 -166
- package/src/tools/search/output.md +0 -2775
- package/src/tools/search/test.html +0 -884
- package/src/tools/search/test.md +0 -643
- package/src/tools/search/test.ts +0 -159
- package/src/utils/__tests__/childAgentContext.test.ts +0 -217
- package/src/utils/__tests__/credentials.test.ts +0 -130
- package/src/utils/__tests__/httpClient.test.ts +0 -75
- package/src/utils/__tests__/toolManifest.test.ts +0 -116
- package/src/utils/childAgentContext.ts +0 -259
- package/src/utils/credentials.ts +0 -157
- package/src/utils/httpClient.ts +0 -92
- package/src/utils/toolManifest.ts +0 -109
- /package/dist/esm/{content → langchain}/index.mjs.map +0 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool output reference registry.
|
|
3
|
+
*
|
|
4
|
+
* When enabled via `RunConfig.toolOutputReferences.enabled`, ToolNode
|
|
5
|
+
* stores each successful tool output under a stable key
|
|
6
|
+
* (`tool<idx>turn<turn>`) where `idx` is the tool's position within a
|
|
7
|
+
* ToolNode batch and `turn` is the batch index within the run
|
|
8
|
+
* (incremented once per ToolNode invocation).
|
|
9
|
+
*
|
|
10
|
+
* Subsequent tool calls can pipe a previous output into their args by
|
|
11
|
+
* embedding `{{tool<idx>turn<turn>}}` inside any string argument;
|
|
12
|
+
* {@link ToolOutputReferenceRegistry.resolve} walks the args and
|
|
13
|
+
* substitutes the placeholders immediately before invocation.
|
|
14
|
+
*
|
|
15
|
+
* The registry stores the *raw, untruncated* tool output so a later
|
|
16
|
+
* `{{…}}` substitution pipes the full payload into the next tool —
|
|
17
|
+
* even when the LLM only saw a head+tail-truncated preview in
|
|
18
|
+
* `ToolMessage.content`. Outputs are stored without any annotation
|
|
19
|
+
* (the `_ref` key or the `[ref: ...]` prefix seen by the LLM is
|
|
20
|
+
* strictly a UX signal attached to `ToolMessage.content`). Keeping the
|
|
21
|
+
* registry pristine means downstream bash/jq piping receives the
|
|
22
|
+
* complete, verbatim output with no injected fields.
|
|
23
|
+
*/
|
|
24
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
25
|
+
/**
|
|
26
|
+
* Non-global matcher for a single `{{tool<i>turn<n>}}` placeholder.
|
|
27
|
+
* Exported for consumers that want to detect references (e.g., syntax
|
|
28
|
+
* highlighting, docs). The stateful `g` variant lives inside the
|
|
29
|
+
* registry so nobody trips on `lastIndex`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const TOOL_OUTPUT_REF_PATTERN: RegExp;
|
|
32
|
+
/** Object key used when a parsed-object output has `_ref` injected. */
|
|
33
|
+
export declare const TOOL_OUTPUT_REF_KEY = "_ref";
|
|
34
|
+
/**
|
|
35
|
+
* Object key used to carry unresolved reference warnings on a parsed-
|
|
36
|
+
* object output. Using a dedicated field instead of a trailing text
|
|
37
|
+
* line keeps the annotated `ToolMessage.content` parseable as JSON for
|
|
38
|
+
* downstream consumers that rely on the object shape.
|
|
39
|
+
*/
|
|
40
|
+
export declare const TOOL_OUTPUT_UNRESOLVED_KEY = "_unresolved_refs";
|
|
41
|
+
/** Single-line prefix prepended to non-object tool outputs so the LLM sees the reference key. */
|
|
42
|
+
export declare function buildReferencePrefix(key: string): string;
|
|
43
|
+
/** Stable registry key for a tool output. */
|
|
44
|
+
export declare function buildReferenceKey(toolIndex: number, turn: number): string;
|
|
45
|
+
export type ToolOutputReferenceRegistryOptions = {
|
|
46
|
+
/** Maximum characters stored per registered output. */
|
|
47
|
+
maxOutputSize?: number;
|
|
48
|
+
/** Maximum total characters retained across all registered outputs. */
|
|
49
|
+
maxTotalSize?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Upper bound on the number of concurrently-tracked runs. When
|
|
52
|
+
* exceeded, the oldest run bucket is evicted (FIFO). Defaults to 32.
|
|
53
|
+
*/
|
|
54
|
+
maxActiveRuns?: number;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Result of resolving placeholders in tool args.
|
|
58
|
+
*/
|
|
59
|
+
export type ResolveResult<T> = {
|
|
60
|
+
/** Arguments with placeholders replaced. Same shape as the input. */
|
|
61
|
+
resolved: T;
|
|
62
|
+
/** Reference keys that were referenced but had no stored value. */
|
|
63
|
+
unresolved: string[];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Read-only view over a frozen registry snapshot. Returned by
|
|
67
|
+
* {@link ToolOutputReferenceRegistry.snapshot} for callers that need
|
|
68
|
+
* to resolve placeholders against the registry state at a specific
|
|
69
|
+
* point in time, ignoring any subsequent registrations.
|
|
70
|
+
*/
|
|
71
|
+
export interface ToolOutputResolveView {
|
|
72
|
+
resolve<T>(args: T): ResolveResult<T>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Pre-resolved arg map keyed by `toolCallId`. Used by the mixed
|
|
76
|
+
* direct+event dispatch path to feed event calls' resolved args
|
|
77
|
+
* (captured pre-batch) into the dispatcher without re-resolving
|
|
78
|
+
* against the now-stale live registry.
|
|
79
|
+
*/
|
|
80
|
+
export type PreResolvedArgsMap = Map<string, {
|
|
81
|
+
resolved: Record<string, unknown>;
|
|
82
|
+
unresolved: string[];
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* Per-call sink for resolved args, keyed by `toolCallId`. Threaded
|
|
86
|
+
* as a per-batch local map so concurrent `ToolNode.run()` calls do
|
|
87
|
+
* not race on shared sink state.
|
|
88
|
+
*/
|
|
89
|
+
export type ResolvedArgsByCallId = Map<string, Record<string, unknown>>;
|
|
90
|
+
/**
|
|
91
|
+
* Ordered map of reference-key → stored output, partitioned by run so
|
|
92
|
+
* concurrent / interleaved runs sharing one registry cannot leak
|
|
93
|
+
* outputs between each other.
|
|
94
|
+
*
|
|
95
|
+
* Each public method takes a `runId` which selects the run's bucket.
|
|
96
|
+
* Hosts typically get one registry per run via `Graph`, in which
|
|
97
|
+
* case only a single bucket is ever populated; the partitioning
|
|
98
|
+
* exists so the registry also behaves correctly when a single
|
|
99
|
+
* instance is reused directly.
|
|
100
|
+
*/
|
|
101
|
+
export declare class ToolOutputReferenceRegistry {
|
|
102
|
+
private runStates;
|
|
103
|
+
private readonly maxOutputSize;
|
|
104
|
+
private readonly maxTotalSize;
|
|
105
|
+
private readonly maxActiveRuns;
|
|
106
|
+
/**
|
|
107
|
+
* Local stateful matcher used only by `replaceInString`. Kept
|
|
108
|
+
* off-module so callers of the exported `TOOL_OUTPUT_REF_PATTERN`
|
|
109
|
+
* never see a stale `lastIndex`.
|
|
110
|
+
*/
|
|
111
|
+
private static readonly PLACEHOLDER_MATCHER;
|
|
112
|
+
constructor(options?: ToolOutputReferenceRegistryOptions);
|
|
113
|
+
private keyFor;
|
|
114
|
+
private getOrCreate;
|
|
115
|
+
/** Registers (or replaces) the output stored under `key` for `runId`. */
|
|
116
|
+
set(runId: string | undefined, key: string, value: string): void;
|
|
117
|
+
/** Returns the stored value for `key` in `runId`'s bucket, or `undefined`. */
|
|
118
|
+
get(runId: string | undefined, key: string): string | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Returns `true` when `key` is currently stored in `runId`'s bucket.
|
|
121
|
+
* Used by {@link annotateMessagesForLLM} to gate transient annotation
|
|
122
|
+
* on whether the registry still owns the referenced output (a stale
|
|
123
|
+
* `_refKey` from a prior run silently no-ops here).
|
|
124
|
+
*/
|
|
125
|
+
has(runId: string | undefined, key: string): boolean;
|
|
126
|
+
/** Total number of registered outputs across every run bucket. */
|
|
127
|
+
get size(): number;
|
|
128
|
+
/** Maximum characters retained per output (post-clip). */
|
|
129
|
+
get perOutputLimit(): number;
|
|
130
|
+
/** Maximum total characters retained *per run*. */
|
|
131
|
+
get totalLimit(): number;
|
|
132
|
+
/** Drops every run's state. */
|
|
133
|
+
clear(): void;
|
|
134
|
+
/**
|
|
135
|
+
* Explicitly release `runId`'s state. Safe to call when a run has
|
|
136
|
+
* finished. Hosts sharing one registry across runs should call this
|
|
137
|
+
* to reclaim memory deterministically; otherwise LRU eviction kicks
|
|
138
|
+
* in when `maxActiveRuns` runs accumulate.
|
|
139
|
+
*/
|
|
140
|
+
releaseRun(runId: string | undefined): void;
|
|
141
|
+
/**
|
|
142
|
+
* Claims the next batch turn synchronously from `runId`'s bucket.
|
|
143
|
+
*
|
|
144
|
+
* Must be called once at the start of each ToolNode batch before
|
|
145
|
+
* any `await`, so concurrent invocations within the same run see
|
|
146
|
+
* distinct turn values (reads are effectively atomic by JS's
|
|
147
|
+
* single-threaded execution of the sync prefix).
|
|
148
|
+
*
|
|
149
|
+
* If `runId` is missing the anonymous bucket is dropped and a
|
|
150
|
+
* fresh one created so each anonymous call behaves as its own run.
|
|
151
|
+
*/
|
|
152
|
+
nextTurn(runId: string | undefined): number;
|
|
153
|
+
/**
|
|
154
|
+
* Records that `toolName` has been warned about in `runId` (returns
|
|
155
|
+
* `true` on the first call per run, `false` after). Used by
|
|
156
|
+
* ToolNode to emit one log line per offending tool per run when a
|
|
157
|
+
* `ToolMessage.content` isn't a string.
|
|
158
|
+
*/
|
|
159
|
+
claimWarnOnce(runId: string | undefined, toolName: string): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Walks `args` and replaces every `{{tool<i>turn<n>}}` placeholder in
|
|
162
|
+
* string values with the stored output *from `runId`'s bucket*. Non-
|
|
163
|
+
* string values and object keys are left untouched. Unresolved
|
|
164
|
+
* references are left in-place and reported so the caller can
|
|
165
|
+
* surface them to the LLM. When no placeholder appears anywhere in
|
|
166
|
+
* the serialized args, the original input is returned without
|
|
167
|
+
* walking the tree.
|
|
168
|
+
*/
|
|
169
|
+
resolve<T>(runId: string | undefined, args: T): ResolveResult<T>;
|
|
170
|
+
/**
|
|
171
|
+
* Captures a frozen snapshot of `runId`'s current entries and
|
|
172
|
+
* returns a view that resolves placeholders against *only* that
|
|
173
|
+
* snapshot. The snapshot is decoupled from the live registry, so
|
|
174
|
+
* subsequent `set()` calls (for example, same-turn direct outputs
|
|
175
|
+
* registering while an event branch is still in flight) are
|
|
176
|
+
* invisible to the snapshot's `resolve`. Used by the mixed
|
|
177
|
+
* direct+event dispatch path to preserve same-turn isolation when
|
|
178
|
+
* a `PreToolUse` hook rewrites event args after directs have
|
|
179
|
+
* completed.
|
|
180
|
+
*/
|
|
181
|
+
snapshot(runId: string | undefined): ToolOutputResolveView;
|
|
182
|
+
private resolveAgainst;
|
|
183
|
+
private transform;
|
|
184
|
+
private replaceInString;
|
|
185
|
+
private evictWithinBucket;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Annotates `content` with a reference key and/or unresolved-ref
|
|
189
|
+
* warnings so the LLM sees both alongside the tool output.
|
|
190
|
+
*
|
|
191
|
+
* Behavior:
|
|
192
|
+
* - If `content` parses as a plain (non-array, non-null) JSON object
|
|
193
|
+
* and the object does not already have a conflicting `_ref` key,
|
|
194
|
+
* the reference key and (when present) `_unresolved_refs` array
|
|
195
|
+
* are injected as object fields, preserving JSON validity for
|
|
196
|
+
* downstream consumers that parse the output.
|
|
197
|
+
* - Otherwise (string output, JSON array/primitive, parse failure,
|
|
198
|
+
* or `_ref` collision), a `[ref: <key>]\n` prefix line is
|
|
199
|
+
* prepended and unresolved refs are appended as a trailing
|
|
200
|
+
* `[unresolved refs: …]` line.
|
|
201
|
+
*
|
|
202
|
+
* The annotated string is what the LLM sees as `ToolMessage.content`.
|
|
203
|
+
* The *original* (un-annotated) value is what gets stored in the
|
|
204
|
+
* registry, so downstream piping remains pristine.
|
|
205
|
+
*
|
|
206
|
+
* @param content Raw (post-truncation) tool output.
|
|
207
|
+
* @param key Reference key for this output, or undefined when
|
|
208
|
+
* there is nothing to register (errors etc.).
|
|
209
|
+
* @param unresolved Reference keys that failed to resolve during
|
|
210
|
+
* argument substitution. Surfaced so the LLM can
|
|
211
|
+
* self-correct its next tool call.
|
|
212
|
+
*/
|
|
213
|
+
export declare function annotateToolOutputWithReference(content: string, key: string | undefined, unresolved?: string[]): string;
|
|
214
|
+
/**
|
|
215
|
+
* Lazy projection that, given a registry and a runId, returns a new
|
|
216
|
+
* `messages` array where each `ToolMessage` carrying ref metadata is
|
|
217
|
+
* projected into a transient copy with annotated content (when the ref
|
|
218
|
+
* is live in the registry) and with the framework-owned `additional_
|
|
219
|
+
* kwargs` keys (`_refKey`, `_refScope`, `_unresolvedRefs`) stripped
|
|
220
|
+
* regardless of whether annotation applied. The original input array
|
|
221
|
+
* and its messages are never mutated.
|
|
222
|
+
*
|
|
223
|
+
* Annotation is gated on registry presence: a stale `_refKey` from a
|
|
224
|
+
* prior run (e.g. one that survived in persisted history) silently
|
|
225
|
+
* no-ops on the *content* side. The strip-metadata side still runs so
|
|
226
|
+
* stale framework keys never leak onto the wire under any custom or
|
|
227
|
+
* future provider serializer that might transmit `additional_kwargs`.
|
|
228
|
+
* `_unresolvedRefs` is always meaningful and is not gated.
|
|
229
|
+
*
|
|
230
|
+
* **Feature-disabled fast path:** when the host hasn't enabled the
|
|
231
|
+
* tool-output-reference feature, the registry is `undefined` and this
|
|
232
|
+
* function returns the input array reference-equal *without iterating
|
|
233
|
+
* a single message*. The loop is exclusive to the feature-enabled
|
|
234
|
+
* code path.
|
|
235
|
+
*/
|
|
236
|
+
export declare function annotateMessagesForLLM(messages: BaseMessage[], registry: ToolOutputReferenceRegistry | undefined, runId: string | undefined): BaseMessage[];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent system-message prompt-cache types.
|
|
3
|
+
* ==========================================
|
|
4
|
+
*
|
|
5
|
+
* `@illuma-ai/agents` exposes a generic primitive — `system_cache_blocks` —
|
|
6
|
+
* for composing a system message that gets explicit cache markers
|
|
7
|
+
* (cachePoint on Bedrock, cache_control on Anthropic) at consumer-defined
|
|
8
|
+
* boundaries. The library encodes each entry into the right wire format
|
|
9
|
+
* for the active provider; consumers decide what content to put in each
|
|
10
|
+
* block.
|
|
11
|
+
*
|
|
12
|
+
* Why this is generic rather than tier-named
|
|
13
|
+
* ------------------------------------------------
|
|
14
|
+
* Earlier iterations exposed `platform_instructions` and `cache_ttl:
|
|
15
|
+
* { platform, agent }` — vocabulary borrowed from a specific consumer's
|
|
16
|
+
* multi-tenant chat-platform mental model. That leaked one consumer's
|
|
17
|
+
* domain into the library and made it confusing for other consumers
|
|
18
|
+
* (CLI tools, desktop apps, gateways) which have no notion of
|
|
19
|
+
* "platforms" or "agents".
|
|
20
|
+
*
|
|
21
|
+
* The current shape lets every consumer define their own cache-tier
|
|
22
|
+
* organization without the library knowing or caring.
|
|
23
|
+
*
|
|
24
|
+
* Cache key composition
|
|
25
|
+
* ---------------------
|
|
26
|
+
* Both Anthropic and Bedrock hash the message bytes leading up to each
|
|
27
|
+
* cache marker. So entry N's cache key is the concatenation of bytes
|
|
28
|
+
* 0..N. Stable content (universal rules, framework docs) goes earlier;
|
|
29
|
+
* volatile content (per-agent identity, per-tool docs) goes later. The
|
|
30
|
+
* earlier entries get cross-tenant cache hits; the later entries get
|
|
31
|
+
* narrower hits.
|
|
32
|
+
*
|
|
33
|
+
* Provider budget
|
|
34
|
+
* ---------------
|
|
35
|
+
* Bedrock's Converse API supports up to 4 cachePoint blocks per request.
|
|
36
|
+
* The default tools-array cache strategy (see `IllumaBedrockConverse`)
|
|
37
|
+
* uses up to 2 of those. So at most 2 entries should appear in
|
|
38
|
+
* `system_cache_blocks` to leave budget for the trailing
|
|
39
|
+
* `instructions` block. The library throws on more than 2.
|
|
40
|
+
*
|
|
41
|
+
* Anthropic supports up to 4 cache breakpoints per request workspace-wide;
|
|
42
|
+
* the same constraint applies to keep tools + system within budget.
|
|
43
|
+
*/
|
|
44
|
+
/** Provider TTL hint applied to a cachePoint / cache_control marker. */
|
|
45
|
+
export type AgentCacheTTL = '5m' | '1h';
|
|
46
|
+
/**
|
|
47
|
+
* One cacheable system content block. Each entry produces a text block
|
|
48
|
+
* followed by a provider-specific cache marker in the assembled system
|
|
49
|
+
* message. Entries are emitted in array order — earlier = more stable
|
|
50
|
+
* = wider cache key.
|
|
51
|
+
*/
|
|
52
|
+
export interface SystemCacheBlock {
|
|
53
|
+
/**
|
|
54
|
+
* Text payload. Caller is responsible for keeping this byte-stable
|
|
55
|
+
* across requests that should share a cache entry. ANY change to
|
|
56
|
+
* these bytes invalidates every cache key that includes this entry.
|
|
57
|
+
*/
|
|
58
|
+
text: string;
|
|
59
|
+
/**
|
|
60
|
+
* Optional TTL hint for the cache marker. Defaults to '5m' when
|
|
61
|
+
* omitted. '1h' costs more to write (2× base vs 1.25×) but survives
|
|
62
|
+
* longer idle, which is the right tradeoff for low-traffic blocks.
|
|
63
|
+
*/
|
|
64
|
+
ttl?: AgentCacheTTL;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Maximum number of `system_cache_blocks` entries the library accepts.
|
|
68
|
+
* Higher than this would exceed Bedrock's 4-cachePoint budget once the
|
|
69
|
+
* tools array and trailing `instructions` block are counted.
|
|
70
|
+
*/
|
|
71
|
+
export declare const MAX_SYSTEM_CACHE_BLOCKS = 2;
|
|
@@ -4,12 +4,13 @@ import type { BaseMessage, AIMessageChunk, SystemMessage } from '@langchain/core
|
|
|
4
4
|
import type { RunnableConfig, Runnable } from '@langchain/core/runnables';
|
|
5
5
|
import type { ChatGenerationChunk } from '@langchain/core/outputs';
|
|
6
6
|
import type { GoogleAIToolType } from '@langchain/google-common';
|
|
7
|
-
import type { ToolMap, ToolEndEvent, GenericTool, LCTool, ToolApprovalConfig } from '@/types/tools';
|
|
7
|
+
import type { ToolMap, ToolEndEvent, GenericTool, LCTool, ToolApprovalConfig, ToolExecuteBatchRequest } from '@/types/tools';
|
|
8
8
|
import type { Providers, Callback, GraphNodeKeys } from '@/common';
|
|
9
9
|
import type { StandardGraph, MultiAgentGraph } from '@/graphs';
|
|
10
10
|
import type { ClientOptions } from '@/types/llm';
|
|
11
11
|
import type { RunStep, RunStepDeltaEvent, MessageDeltaEvent, ReasoningDeltaEvent } from '@/types/stream';
|
|
12
12
|
import type { TokenCounter } from '@/types/run';
|
|
13
|
+
import type { SystemCacheBlock, AgentCacheTTL } from '@/types/agent-cache';
|
|
13
14
|
/** Interface for bound model with stream and invoke methods */
|
|
14
15
|
export interface ChatModel {
|
|
15
16
|
stream?: (messages: BaseMessage[], config?: RunnableConfig) => Promise<AsyncIterable<AIMessageChunk>>;
|
|
@@ -53,7 +54,7 @@ export type MultiAgentGraphState = BaseGraphState & {
|
|
|
53
54
|
};
|
|
54
55
|
export type IState = BaseGraphState;
|
|
55
56
|
export interface EventHandler {
|
|
56
|
-
handle(event: string, data: StreamEventData | ModelEndData | RunStep | RunStepDeltaEvent | MessageDeltaEvent | ReasoningDeltaEvent | {
|
|
57
|
+
handle(event: string, data: StreamEventData | ModelEndData | RunStep | RunStepDeltaEvent | MessageDeltaEvent | ReasoningDeltaEvent | SubagentUpdateEvent | ToolExecuteBatchRequest | {
|
|
57
58
|
result: ToolEndEvent;
|
|
58
59
|
}, metadata?: Record<string, unknown>, graph?: StandardGraph | MultiAgentGraph): void | Promise<void>;
|
|
59
60
|
}
|
|
@@ -261,9 +262,13 @@ export type GraphEdge = {
|
|
|
261
262
|
/** Can return boolean or specific destination(s) */
|
|
262
263
|
condition?: (state: BaseGraphState) => boolean | string | string[];
|
|
263
264
|
/**
|
|
264
|
-
* EdgeType.HANDOFF —
|
|
265
|
-
*
|
|
266
|
-
*
|
|
265
|
+
* EdgeType.HANDOFF — one-way routing: parent emits an `lc_transfer_to_*`
|
|
266
|
+
* tool call and exits, child takes over and responds directly to the
|
|
267
|
+
* user. Aligns with the standard handoff semantics.
|
|
268
|
+
* EdgeType.DIRECT — fixed graph edges for automatic sequential / parallel
|
|
269
|
+
* transitions. Downstream consumers may layer additional wiring on top
|
|
270
|
+
* (fan-in with prompt, parallel groups, approval-gate nodes,
|
|
271
|
+
* excludeResults / agentMessages).
|
|
267
272
|
*/
|
|
268
273
|
edgeType?: import('@/common').EdgeType;
|
|
269
274
|
/**
|
|
@@ -288,19 +293,6 @@ export type GraphEdge = {
|
|
|
288
293
|
* For handoff edges: Customizes the parameter name for the handoff instruction input.
|
|
289
294
|
*/
|
|
290
295
|
promptKey?: string;
|
|
291
|
-
/**
|
|
292
|
-
* For handoff edges: Maximum characters for the result returned to the parent.
|
|
293
|
-
* Uses head/tail truncation (60/40 split) to preserve key findings and conclusions.
|
|
294
|
-
* Defaults to DEFAULT_HANDOFF_MAX_RESULT_CHARS (32768 chars, ~8192 tokens).
|
|
295
|
-
*/
|
|
296
|
-
maxResultChars?: number;
|
|
297
|
-
/**
|
|
298
|
-
* For handoff edges: When true, the child agent receives the full parent
|
|
299
|
-
* conversation history plus the orchestrator's instructions appended.
|
|
300
|
-
* When false (default), the child only receives the orchestrator's scoped
|
|
301
|
-
* instructions — isolated from the parent conversation.
|
|
302
|
-
*/
|
|
303
|
-
passthrough?: boolean;
|
|
304
296
|
/**
|
|
305
297
|
* Approval gate configuration for sequence edges.
|
|
306
298
|
* When set, inserts an approval gate node between source and destination.
|
|
@@ -311,12 +303,15 @@ export type GraphEdge = {
|
|
|
311
303
|
export type MultiAgentGraphInput = StandardGraphInput & {
|
|
312
304
|
edges: GraphEdge[];
|
|
313
305
|
/**
|
|
314
|
-
* When set, the graph routes START to this agent instead of the default
|
|
315
|
-
* Used for multi-turn resumption: the caller reads
|
|
316
|
-
*
|
|
306
|
+
* When set, the graph routes START to this agent instead of the default
|
|
307
|
+
* starting nodes. Used for multi-turn resumption: the caller reads the
|
|
308
|
+
* last active agent id from the previous turn (e.g. via
|
|
309
|
+
* `Run.getLastActiveAgentId()`, which derives it from the run's content
|
|
310
|
+
* data trail) and passes it here so follow-up messages route to the
|
|
317
311
|
* agent that last handled the conversation.
|
|
318
312
|
*
|
|
319
|
-
* If the agent ID is invalid (not in the graph), falls back to default
|
|
313
|
+
* If the agent ID is invalid (not in the graph), falls back to default
|
|
314
|
+
* starting nodes.
|
|
320
315
|
*/
|
|
321
316
|
resumeFromAgentId?: string;
|
|
322
317
|
};
|
|
@@ -463,6 +458,22 @@ export interface SummarizationConfig {
|
|
|
463
458
|
* while persistedSummary is loaded from the conversation's own history.
|
|
464
459
|
*/
|
|
465
460
|
initialSummary?: string;
|
|
461
|
+
/**
|
|
462
|
+
* optional fields. When the host wants the summarization
|
|
463
|
+
* pass to run on a different LLM than the agent's own (e.g. a cheaper
|
|
464
|
+
* model for compaction), these provider/model overrides flow through to
|
|
465
|
+
* the summarize callback.
|
|
466
|
+
*/
|
|
467
|
+
provider?: Providers;
|
|
468
|
+
model?: string;
|
|
469
|
+
parameters?: Record<string, unknown>;
|
|
470
|
+
prompt?: string;
|
|
471
|
+
updatePrompt?: string;
|
|
472
|
+
trigger?: {
|
|
473
|
+
type: string;
|
|
474
|
+
value: number;
|
|
475
|
+
};
|
|
476
|
+
maxSummaryTokens?: number;
|
|
466
477
|
}
|
|
467
478
|
/**
|
|
468
479
|
* Runtime state for EMA-based pruning calibration.
|
|
@@ -493,6 +504,61 @@ export interface FileManifestEntry {
|
|
|
493
504
|
/** Index of the message that introduced this file (0-based in the original message array) */
|
|
494
505
|
messageIndex?: number;
|
|
495
506
|
}
|
|
507
|
+
/** Configuration for a subagent type that can be spawned by a parent agent. */
|
|
508
|
+
export type SubagentConfig = {
|
|
509
|
+
/** Identifier used in the tool's `subagent_type` enum (e.g. 'researcher', 'coder'). */
|
|
510
|
+
type: string;
|
|
511
|
+
/** Human-readable display name. */
|
|
512
|
+
name: string;
|
|
513
|
+
/** What this subagent specializes in — shown to the LLM. */
|
|
514
|
+
description: string;
|
|
515
|
+
/** Full agent config for the child graph. Omit when `self` is true. */
|
|
516
|
+
agentInputs?: AgentInputs;
|
|
517
|
+
/** When true, reuse the parent's AgentInputs (context isolation without separate config). */
|
|
518
|
+
self?: boolean;
|
|
519
|
+
/** Max AGENT→TOOLS cycles before forced stop (default: 25). */
|
|
520
|
+
maxTurns?: number;
|
|
521
|
+
/** Allow this subagent to spawn its own subagents (default: false). */
|
|
522
|
+
allowNested?: boolean;
|
|
523
|
+
};
|
|
524
|
+
/** SubagentConfig with agentInputs guaranteed present (self-spawn resolved). */
|
|
525
|
+
export type ResolvedSubagentConfig = SubagentConfig & {
|
|
526
|
+
agentInputs: AgentInputs;
|
|
527
|
+
};
|
|
528
|
+
/** Lifecycle phase carried on {@link SubagentUpdateEvent}. */
|
|
529
|
+
export type SubagentUpdatePhase = 'start' | 'run_step' | 'run_step_delta' | 'run_step_completed' | 'message_delta' | 'reasoning_delta' | 'stop' | 'error';
|
|
530
|
+
/**
|
|
531
|
+
* Wrapper event emitted when a subagent's child graph dispatches activity.
|
|
532
|
+
* Lets hosts show subagent progress in a UI surface separate from the parent
|
|
533
|
+
* conversation without having to untangle events by agent ID.
|
|
534
|
+
*/
|
|
535
|
+
export interface SubagentUpdateEvent {
|
|
536
|
+
/** Parent run ID. */
|
|
537
|
+
runId: string;
|
|
538
|
+
/** Child run ID (unique per subagent execution). */
|
|
539
|
+
subagentRunId: string;
|
|
540
|
+
/**
|
|
541
|
+
* Parent-side `tool_call_id` for the `subagent` tool invocation that
|
|
542
|
+
* triggered this run. Stable for the duration of the child; lets hosts
|
|
543
|
+
* correlate updates deterministically instead of inferring by ordering.
|
|
544
|
+
* Omitted when the executor was invoked outside of a tool-call context.
|
|
545
|
+
*/
|
|
546
|
+
parentToolCallId?: string;
|
|
547
|
+
/** Subagent `type` identifier from the SubagentConfig. */
|
|
548
|
+
subagentType: string;
|
|
549
|
+
/** Child agent ID assigned to this subagent execution. */
|
|
550
|
+
subagentAgentId: string;
|
|
551
|
+
/** Parent agent ID that spawned this subagent. */
|
|
552
|
+
parentAgentId?: string;
|
|
553
|
+
/** Lifecycle phase carried by this update. */
|
|
554
|
+
phase: SubagentUpdatePhase;
|
|
555
|
+
/** Underlying event payload (shape depends on phase). */
|
|
556
|
+
data?: unknown;
|
|
557
|
+
/** Short human-readable description. Hosts can render this directly. */
|
|
558
|
+
label?: string;
|
|
559
|
+
/** ISO timestamp for ordering / display. */
|
|
560
|
+
timestamp: string;
|
|
561
|
+
}
|
|
496
562
|
export interface AgentInputs {
|
|
497
563
|
agentId: string;
|
|
498
564
|
/** Human-readable name for the agent (used in handoff context). Defaults to agentId if not provided. */
|
|
@@ -503,12 +569,67 @@ export interface AgentInputs {
|
|
|
503
569
|
toolMap?: ToolMap;
|
|
504
570
|
tools?: GraphTools;
|
|
505
571
|
provider: Providers;
|
|
572
|
+
/**
|
|
573
|
+
* Ordered list of cacheable system content blocks emitted BEFORE
|
|
574
|
+
* `instructions` in the system message. Each block gets its own cache
|
|
575
|
+
* marker (cachePoint on Bedrock, cache_control on Anthropic) so the
|
|
576
|
+
* cache key for each block includes only the bytes up to and including
|
|
577
|
+
* its own marker. Entries are emitted in array order — earlier =
|
|
578
|
+
* stabler = wider cache key (best for cross-tenant sharing).
|
|
579
|
+
*
|
|
580
|
+
* See `src/types/agent-cache.ts` for full semantics. Capped at
|
|
581
|
+
* `MAX_SYSTEM_CACHE_BLOCKS` (2) entries to stay within Bedrock's
|
|
582
|
+
* 4-cachePoint budget after the tools array consumes 2.
|
|
583
|
+
*/
|
|
584
|
+
system_cache_blocks?: SystemCacheBlock[];
|
|
585
|
+
/**
|
|
586
|
+
* Stable/cacheable system instructions for this agent. Always emitted
|
|
587
|
+
* with its own trailing cache marker (when caching is supported by
|
|
588
|
+
* the provider/model). Use `instructions_cache_ttl` to override the
|
|
589
|
+
* default '5m' TTL.
|
|
590
|
+
*/
|
|
506
591
|
instructions?: string;
|
|
592
|
+
/** TTL for the trailing `instructions` cache marker. Defaults to '5m'. */
|
|
593
|
+
instructions_cache_ttl?: AgentCacheTTL;
|
|
507
594
|
streamBuffer?: number;
|
|
508
595
|
maxContextTokens?: number;
|
|
509
596
|
clientOptions?: ClientOptions;
|
|
597
|
+
/**
|
|
598
|
+
* Dynamic system tail appended after the cacheable instructions
|
|
599
|
+
* without any cache marker. Per-user / per-message context belongs
|
|
600
|
+
* here so it does not invalidate the cacheable prefix.
|
|
601
|
+
*/
|
|
510
602
|
additional_instructions?: string;
|
|
511
603
|
reasoningKey?: 'reasoning_content' | 'reasoning';
|
|
604
|
+
/**
|
|
605
|
+
* Subagent types this agent may spawn. When non-empty, Graph injects the
|
|
606
|
+
* `subagent` tool into the agent's toolset with the per-config enum and
|
|
607
|
+
* description populated.
|
|
608
|
+
*/
|
|
609
|
+
subagentConfigs?: SubagentConfig[];
|
|
610
|
+
/**
|
|
611
|
+
* Maximum subagent depth allowed below this agent. Used by SubagentExecutor
|
|
612
|
+
* to abort runaway nesting. Defaults to a small constant.
|
|
613
|
+
*/
|
|
614
|
+
maxSubagentDepth?: number;
|
|
615
|
+
/**
|
|
616
|
+
* Pre-existing summary injected into the system message via
|
|
617
|
+
* AgentContext.buildInstructionsString. Populated by SubagentExecutor when
|
|
618
|
+
* spawning a self-config subagent that should inherit the parent's prior
|
|
619
|
+
* compaction summary; otherwise host-supplied at run time.
|
|
620
|
+
*/
|
|
621
|
+
initialSummary?: {
|
|
622
|
+
text: string;
|
|
623
|
+
tokenCount: number;
|
|
624
|
+
};
|
|
625
|
+
/**
|
|
626
|
+
* opt-in for summarization. When false, the agent never
|
|
627
|
+
* invokes the summarize callback regardless of context utilization.
|
|
628
|
+
* Defaults to undefined (treated as enabled by default to preserve prior
|
|
629
|
+
* behaviour); hosts that want strict opt-in semantics should set it
|
|
630
|
+
* explicitly.
|
|
631
|
+
*/
|
|
632
|
+
summarizationEnabled?: boolean;
|
|
512
633
|
/** Format content blocks as strings (for legacy compatibility i.e. Ollama/Azure Serverless) */
|
|
513
634
|
useLegacyContent?: boolean;
|
|
514
635
|
/**
|
|
@@ -585,3 +706,23 @@ export interface AgentInputs {
|
|
|
585
706
|
*/
|
|
586
707
|
fileManifest?: FileManifestEntry[];
|
|
587
708
|
}
|
|
709
|
+
/**
|
|
710
|
+
* Tunable knobs for position-based content degradation.
|
|
711
|
+
* See `messages/contextPruning.ts` and `messages/contextPruningSettings.ts`.
|
|
712
|
+
*/
|
|
713
|
+
export interface ContextPruningConfig {
|
|
714
|
+
enabled?: boolean;
|
|
715
|
+
keepLastAssistants?: number;
|
|
716
|
+
softTrimRatio?: number;
|
|
717
|
+
hardClearRatio?: number;
|
|
718
|
+
minPrunableToolChars?: number;
|
|
719
|
+
softTrim?: {
|
|
720
|
+
maxChars?: number;
|
|
721
|
+
headChars?: number;
|
|
722
|
+
tailChars?: number;
|
|
723
|
+
};
|
|
724
|
+
hardClear?: {
|
|
725
|
+
enabled?: boolean;
|
|
726
|
+
placeholder?: string;
|
|
727
|
+
};
|
|
728
|
+
}
|
|
@@ -2,3 +2,29 @@ import type Anthropic from '@anthropic-ai/sdk';
|
|
|
2
2
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
3
3
|
export type AnthropicMessages = Array<AnthropicMessage | BaseMessage>;
|
|
4
4
|
export type AnthropicMessage = Anthropic.MessageParam;
|
|
5
|
+
/**
|
|
6
|
+
* Per-message ref metadata stamped onto a `ToolMessage` at execution time
|
|
7
|
+
* (PR #117). Read by `annotateMessagesForLLM` to apply transient
|
|
8
|
+
* annotation to a copy of the message right before it goes on the wire to
|
|
9
|
+
* the provider. Never read after the run-scoped registry has been cleared.
|
|
10
|
+
*
|
|
11
|
+
* Lives in `ToolMessage.additional_kwargs`. LangChain's provider
|
|
12
|
+
* serializers don't transmit `additional_kwargs` to provider APIs, so the
|
|
13
|
+
* metadata never leaks even if you forget to clean it.
|
|
14
|
+
*/
|
|
15
|
+
export interface ToolMessageRefMetadata {
|
|
16
|
+
/** Key under which this message's untruncated output was registered. */
|
|
17
|
+
_refKey?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Registry bucket scope under which `_refKey` was stored. For named runs
|
|
20
|
+
* this equals `config.configurable.run_id`; for anonymous invocations
|
|
21
|
+
* (no `run_id`) ToolNode mints a per-batch synthetic scope
|
|
22
|
+
* (`\0anon-<n>`) so concurrent batches don't collide. Stamping the
|
|
23
|
+
* scope on the message itself lets `annotateMessagesForLLM` recover it
|
|
24
|
+
* without re-deriving from config — which is impossible for the
|
|
25
|
+
* anonymous case, since the scope is internal to ToolNode.
|
|
26
|
+
*/
|
|
27
|
+
_refScope?: string;
|
|
28
|
+
/** Placeholders the model used that could not be resolved this batch. */
|
|
29
|
+
_unresolvedRefs?: string[];
|
|
30
|
+
}
|
|
@@ -7,6 +7,7 @@ import type * as s from '@/types/stream';
|
|
|
7
7
|
import type * as e from '@/common/enum';
|
|
8
8
|
import type * as g from '@/types/graph';
|
|
9
9
|
import type * as l from '@/types/llm';
|
|
10
|
+
import type { HookRegistry } from '@/hooks';
|
|
10
11
|
export type ZodObjectAny = z.ZodObject<any, any, any, any>;
|
|
11
12
|
export type BaseGraphConfig = {
|
|
12
13
|
llmConfig: l.LLMConfig;
|
|
@@ -61,7 +62,9 @@ export interface AgentStateChannels {
|
|
|
61
62
|
messages: BaseMessage[];
|
|
62
63
|
next: string;
|
|
63
64
|
[key: string]: unknown;
|
|
65
|
+
/** Stable/cacheable system instructions for this agent. */
|
|
64
66
|
instructions?: string;
|
|
67
|
+
/** Dynamic system tail appended after stable instructions. */
|
|
65
68
|
additional_instructions?: string;
|
|
66
69
|
}
|
|
67
70
|
export interface Member {
|
|
@@ -106,6 +109,25 @@ export type RunConfig = {
|
|
|
106
109
|
runId: string;
|
|
107
110
|
graphConfig: LegacyGraphConfig | StandardGraphConfig | MultiAgentGraphConfig;
|
|
108
111
|
customHandlers?: Record<string, g.EventHandler>;
|
|
112
|
+
/**
|
|
113
|
+
* Optional {@link HookRegistry} that wires host-defined hook callbacks
|
|
114
|
+
* (PreToolUse / PostToolUse / PreCompact / etc.) into this run.
|
|
115
|
+
*
|
|
116
|
+
* Hooks fire synchronously inside ToolNode and processStream; returning
|
|
117
|
+
* `deny` from a PreToolUse hook short-circuits the tool call. Lifetime
|
|
118
|
+
* is per-run — the host should construct a fresh registry (or reuse a
|
|
119
|
+
* shared one) and dispose of it together with the conversation block
|
|
120
|
+
* to prevent leaks.
|
|
121
|
+
*/
|
|
122
|
+
hooks?: HookRegistry;
|
|
123
|
+
/**
|
|
124
|
+
* Tool output reference configuration (PRs #114 / #117).
|
|
125
|
+
* When `enabled` is true, the Run constructs a single
|
|
126
|
+
* ToolOutputReferenceRegistry and threads it to every ToolNode built by
|
|
127
|
+
* the graph so `{{tool<i>turn<n>}}` placeholders resolve across agents.
|
|
128
|
+
* Defaults to disabled (registry not constructed).
|
|
129
|
+
*/
|
|
130
|
+
toolOutputReferences?: import('@/types/tools').ToolOutputReferencesConfig;
|
|
109
131
|
returnContent?: boolean;
|
|
110
132
|
tokenCounter?: TokenCounter;
|
|
111
133
|
indexTokenCountMap?: Record<string, number>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Minimal skill metadata for catalog assembly. The host provides these from its own data layer. */
|
|
2
|
+
export type SkillCatalogEntry = {
|
|
3
|
+
/** Kebab-case identifier (what the model passes to SkillTool) */
|
|
4
|
+
name: string;
|
|
5
|
+
/** One-line description for the catalog listing */
|
|
6
|
+
description: string;
|
|
7
|
+
/** Optional human-readable label (UI only, not shown to model) */
|
|
8
|
+
displayTitle?: string;
|
|
9
|
+
};
|