@illuma-ai/agents 1.0.81
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 +485 -0
- package/dist/cjs/agents/AgentContext.cjs +734 -0
- package/dist/cjs/agents/AgentContext.cjs.map +1 -0
- package/dist/cjs/common/enum.cjs +190 -0
- package/dist/cjs/common/enum.cjs.map +1 -0
- package/dist/cjs/events.cjs +172 -0
- package/dist/cjs/events.cjs.map +1 -0
- package/dist/cjs/graphs/Graph.cjs +1615 -0
- package/dist/cjs/graphs/Graph.cjs.map +1 -0
- package/dist/cjs/graphs/MultiAgentGraph.cjs +890 -0
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -0
- package/dist/cjs/instrumentation.cjs +21 -0
- package/dist/cjs/instrumentation.cjs.map +1 -0
- package/dist/cjs/llm/anthropic/index.cjs +292 -0
- package/dist/cjs/llm/anthropic/index.cjs.map +1 -0
- package/dist/cjs/llm/anthropic/types.cjs +50 -0
- package/dist/cjs/llm/anthropic/types.cjs.map +1 -0
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +630 -0
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -0
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +218 -0
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -0
- package/dist/cjs/llm/anthropic/utils/tools.cjs +29 -0
- package/dist/cjs/llm/anthropic/utils/tools.cjs.map +1 -0
- package/dist/cjs/llm/bedrock/index.cjs +282 -0
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -0
- package/dist/cjs/llm/fake.cjs +97 -0
- package/dist/cjs/llm/fake.cjs.map +1 -0
- package/dist/cjs/llm/google/index.cjs +216 -0
- package/dist/cjs/llm/google/index.cjs.map +1 -0
- package/dist/cjs/llm/google/utils/common.cjs +647 -0
- package/dist/cjs/llm/google/utils/common.cjs.map +1 -0
- package/dist/cjs/llm/openai/index.cjs +1028 -0
- package/dist/cjs/llm/openai/index.cjs.map +1 -0
- package/dist/cjs/llm/openai/utils/index.cjs +765 -0
- package/dist/cjs/llm/openai/utils/index.cjs.map +1 -0
- package/dist/cjs/llm/openrouter/index.cjs +212 -0
- package/dist/cjs/llm/openrouter/index.cjs.map +1 -0
- package/dist/cjs/llm/providers.cjs +43 -0
- package/dist/cjs/llm/providers.cjs.map +1 -0
- package/dist/cjs/llm/text.cjs +69 -0
- package/dist/cjs/llm/text.cjs.map +1 -0
- package/dist/cjs/llm/vertexai/index.cjs +329 -0
- package/dist/cjs/llm/vertexai/index.cjs.map +1 -0
- package/dist/cjs/main.cjs +240 -0
- package/dist/cjs/main.cjs.map +1 -0
- package/dist/cjs/messages/cache.cjs +387 -0
- package/dist/cjs/messages/cache.cjs.map +1 -0
- package/dist/cjs/messages/content.cjs +53 -0
- package/dist/cjs/messages/content.cjs.map +1 -0
- package/dist/cjs/messages/core.cjs +367 -0
- package/dist/cjs/messages/core.cjs.map +1 -0
- package/dist/cjs/messages/format.cjs +761 -0
- package/dist/cjs/messages/format.cjs.map +1 -0
- package/dist/cjs/messages/ids.cjs +23 -0
- package/dist/cjs/messages/ids.cjs.map +1 -0
- package/dist/cjs/messages/prune.cjs +398 -0
- package/dist/cjs/messages/prune.cjs.map +1 -0
- package/dist/cjs/messages/tools.cjs +96 -0
- package/dist/cjs/messages/tools.cjs.map +1 -0
- package/dist/cjs/run.cjs +328 -0
- package/dist/cjs/run.cjs.map +1 -0
- package/dist/cjs/schemas/validate.cjs +324 -0
- package/dist/cjs/schemas/validate.cjs.map +1 -0
- package/dist/cjs/splitStream.cjs +210 -0
- package/dist/cjs/splitStream.cjs.map +1 -0
- package/dist/cjs/stream.cjs +620 -0
- package/dist/cjs/stream.cjs.map +1 -0
- package/dist/cjs/tools/BrowserTools.cjs +248 -0
- package/dist/cjs/tools/BrowserTools.cjs.map +1 -0
- package/dist/cjs/tools/Calculator.cjs +66 -0
- package/dist/cjs/tools/Calculator.cjs.map +1 -0
- package/dist/cjs/tools/CodeExecutor.cjs +234 -0
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -0
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +636 -0
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -0
- package/dist/cjs/tools/ToolNode.cjs +548 -0
- package/dist/cjs/tools/ToolNode.cjs.map +1 -0
- package/dist/cjs/tools/ToolSearch.cjs +909 -0
- package/dist/cjs/tools/ToolSearch.cjs.map +1 -0
- package/dist/cjs/tools/handlers.cjs +255 -0
- package/dist/cjs/tools/handlers.cjs.map +1 -0
- package/dist/cjs/tools/schema.cjs +31 -0
- package/dist/cjs/tools/schema.cjs.map +1 -0
- package/dist/cjs/tools/search/anthropic.cjs +40 -0
- package/dist/cjs/tools/search/anthropic.cjs.map +1 -0
- package/dist/cjs/tools/search/content.cjs +140 -0
- package/dist/cjs/tools/search/content.cjs.map +1 -0
- package/dist/cjs/tools/search/firecrawl.cjs +179 -0
- package/dist/cjs/tools/search/firecrawl.cjs.map +1 -0
- package/dist/cjs/tools/search/format.cjs +203 -0
- package/dist/cjs/tools/search/format.cjs.map +1 -0
- package/dist/cjs/tools/search/highlights.cjs +245 -0
- package/dist/cjs/tools/search/highlights.cjs.map +1 -0
- package/dist/cjs/tools/search/rerankers.cjs +174 -0
- package/dist/cjs/tools/search/rerankers.cjs.map +1 -0
- package/dist/cjs/tools/search/schema.cjs +117 -0
- package/dist/cjs/tools/search/schema.cjs.map +1 -0
- package/dist/cjs/tools/search/search.cjs +566 -0
- package/dist/cjs/tools/search/search.cjs.map +1 -0
- package/dist/cjs/tools/search/serper-scraper.cjs +132 -0
- package/dist/cjs/tools/search/serper-scraper.cjs.map +1 -0
- package/dist/cjs/tools/search/tool.cjs +456 -0
- package/dist/cjs/tools/search/tool.cjs.map +1 -0
- package/dist/cjs/tools/search/utils.cjs +66 -0
- package/dist/cjs/tools/search/utils.cjs.map +1 -0
- package/dist/cjs/types/graph.cjs +29 -0
- package/dist/cjs/types/graph.cjs.map +1 -0
- package/dist/cjs/utils/contextAnalytics.cjs +66 -0
- package/dist/cjs/utils/contextAnalytics.cjs.map +1 -0
- package/dist/cjs/utils/events.cjs +31 -0
- package/dist/cjs/utils/events.cjs.map +1 -0
- package/dist/cjs/utils/graph.cjs +16 -0
- package/dist/cjs/utils/graph.cjs.map +1 -0
- package/dist/cjs/utils/handlers.cjs +70 -0
- package/dist/cjs/utils/handlers.cjs.map +1 -0
- package/dist/cjs/utils/llm.cjs +27 -0
- package/dist/cjs/utils/llm.cjs.map +1 -0
- package/dist/cjs/utils/misc.cjs +56 -0
- package/dist/cjs/utils/misc.cjs.map +1 -0
- package/dist/cjs/utils/run.cjs +73 -0
- package/dist/cjs/utils/run.cjs.map +1 -0
- package/dist/cjs/utils/schema.cjs +27 -0
- package/dist/cjs/utils/schema.cjs.map +1 -0
- package/dist/cjs/utils/title.cjs +125 -0
- package/dist/cjs/utils/title.cjs.map +1 -0
- package/dist/cjs/utils/tokens.cjs +125 -0
- package/dist/cjs/utils/tokens.cjs.map +1 -0
- package/dist/cjs/utils/toonFormat.cjs +388 -0
- package/dist/cjs/utils/toonFormat.cjs.map +1 -0
- package/dist/esm/agents/AgentContext.mjs +732 -0
- package/dist/esm/agents/AgentContext.mjs.map +1 -0
- package/dist/esm/common/enum.mjs +190 -0
- package/dist/esm/common/enum.mjs.map +1 -0
- package/dist/esm/events.mjs +164 -0
- package/dist/esm/events.mjs.map +1 -0
- package/dist/esm/graphs/Graph.mjs +1612 -0
- package/dist/esm/graphs/Graph.mjs.map +1 -0
- package/dist/esm/graphs/MultiAgentGraph.mjs +888 -0
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -0
- package/dist/esm/instrumentation.mjs +19 -0
- package/dist/esm/instrumentation.mjs.map +1 -0
- package/dist/esm/llm/anthropic/index.mjs +290 -0
- package/dist/esm/llm/anthropic/index.mjs.map +1 -0
- package/dist/esm/llm/anthropic/types.mjs +48 -0
- package/dist/esm/llm/anthropic/types.mjs.map +1 -0
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs +627 -0
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -0
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs +216 -0
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -0
- package/dist/esm/llm/anthropic/utils/tools.mjs +27 -0
- package/dist/esm/llm/anthropic/utils/tools.mjs.map +1 -0
- package/dist/esm/llm/bedrock/index.mjs +280 -0
- package/dist/esm/llm/bedrock/index.mjs.map +1 -0
- package/dist/esm/llm/fake.mjs +94 -0
- package/dist/esm/llm/fake.mjs.map +1 -0
- package/dist/esm/llm/google/index.mjs +214 -0
- package/dist/esm/llm/google/index.mjs.map +1 -0
- package/dist/esm/llm/google/utils/common.mjs +638 -0
- package/dist/esm/llm/google/utils/common.mjs.map +1 -0
- package/dist/esm/llm/openai/index.mjs +1018 -0
- package/dist/esm/llm/openai/index.mjs.map +1 -0
- package/dist/esm/llm/openai/utils/index.mjs +759 -0
- package/dist/esm/llm/openai/utils/index.mjs.map +1 -0
- package/dist/esm/llm/openrouter/index.mjs +210 -0
- package/dist/esm/llm/openrouter/index.mjs.map +1 -0
- package/dist/esm/llm/providers.mjs +39 -0
- package/dist/esm/llm/providers.mjs.map +1 -0
- package/dist/esm/llm/text.mjs +67 -0
- package/dist/esm/llm/text.mjs.map +1 -0
- package/dist/esm/llm/vertexai/index.mjs +327 -0
- package/dist/esm/llm/vertexai/index.mjs.map +1 -0
- package/dist/esm/main.mjs +37 -0
- package/dist/esm/main.mjs.map +1 -0
- package/dist/esm/messages/cache.mjs +382 -0
- package/dist/esm/messages/cache.mjs.map +1 -0
- package/dist/esm/messages/content.mjs +51 -0
- package/dist/esm/messages/content.mjs.map +1 -0
- package/dist/esm/messages/core.mjs +359 -0
- package/dist/esm/messages/core.mjs.map +1 -0
- package/dist/esm/messages/format.mjs +752 -0
- package/dist/esm/messages/format.mjs.map +1 -0
- package/dist/esm/messages/ids.mjs +21 -0
- package/dist/esm/messages/ids.mjs.map +1 -0
- package/dist/esm/messages/prune.mjs +393 -0
- package/dist/esm/messages/prune.mjs.map +1 -0
- package/dist/esm/messages/tools.mjs +93 -0
- package/dist/esm/messages/tools.mjs.map +1 -0
- package/dist/esm/run.mjs +325 -0
- package/dist/esm/run.mjs.map +1 -0
- package/dist/esm/schemas/validate.mjs +317 -0
- package/dist/esm/schemas/validate.mjs.map +1 -0
- package/dist/esm/splitStream.mjs +207 -0
- package/dist/esm/splitStream.mjs.map +1 -0
- package/dist/esm/stream.mjs +616 -0
- package/dist/esm/stream.mjs.map +1 -0
- package/dist/esm/tools/BrowserTools.mjs +244 -0
- package/dist/esm/tools/BrowserTools.mjs.map +1 -0
- package/dist/esm/tools/Calculator.mjs +41 -0
- package/dist/esm/tools/Calculator.mjs.map +1 -0
- package/dist/esm/tools/CodeExecutor.mjs +226 -0
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -0
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +622 -0
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -0
- package/dist/esm/tools/ToolNode.mjs +545 -0
- package/dist/esm/tools/ToolNode.mjs.map +1 -0
- package/dist/esm/tools/ToolSearch.mjs +870 -0
- package/dist/esm/tools/ToolSearch.mjs.map +1 -0
- package/dist/esm/tools/handlers.mjs +250 -0
- package/dist/esm/tools/handlers.mjs.map +1 -0
- package/dist/esm/tools/schema.mjs +28 -0
- package/dist/esm/tools/schema.mjs.map +1 -0
- package/dist/esm/tools/search/anthropic.mjs +37 -0
- package/dist/esm/tools/search/anthropic.mjs.map +1 -0
- package/dist/esm/tools/search/content.mjs +119 -0
- package/dist/esm/tools/search/content.mjs.map +1 -0
- package/dist/esm/tools/search/firecrawl.mjs +176 -0
- package/dist/esm/tools/search/firecrawl.mjs.map +1 -0
- package/dist/esm/tools/search/format.mjs +201 -0
- package/dist/esm/tools/search/format.mjs.map +1 -0
- package/dist/esm/tools/search/highlights.mjs +243 -0
- package/dist/esm/tools/search/highlights.mjs.map +1 -0
- package/dist/esm/tools/search/rerankers.mjs +168 -0
- package/dist/esm/tools/search/rerankers.mjs.map +1 -0
- package/dist/esm/tools/search/schema.mjs +104 -0
- package/dist/esm/tools/search/schema.mjs.map +1 -0
- package/dist/esm/tools/search/search.mjs +563 -0
- package/dist/esm/tools/search/search.mjs.map +1 -0
- package/dist/esm/tools/search/serper-scraper.mjs +129 -0
- package/dist/esm/tools/search/serper-scraper.mjs.map +1 -0
- package/dist/esm/tools/search/tool.mjs +454 -0
- package/dist/esm/tools/search/tool.mjs.map +1 -0
- package/dist/esm/tools/search/utils.mjs +61 -0
- package/dist/esm/tools/search/utils.mjs.map +1 -0
- package/dist/esm/types/graph.mjs +26 -0
- package/dist/esm/types/graph.mjs.map +1 -0
- package/dist/esm/utils/contextAnalytics.mjs +64 -0
- package/dist/esm/utils/contextAnalytics.mjs.map +1 -0
- package/dist/esm/utils/events.mjs +29 -0
- package/dist/esm/utils/events.mjs.map +1 -0
- package/dist/esm/utils/graph.mjs +13 -0
- package/dist/esm/utils/graph.mjs.map +1 -0
- package/dist/esm/utils/handlers.mjs +68 -0
- package/dist/esm/utils/handlers.mjs.map +1 -0
- package/dist/esm/utils/llm.mjs +24 -0
- package/dist/esm/utils/llm.mjs.map +1 -0
- package/dist/esm/utils/misc.mjs +53 -0
- package/dist/esm/utils/misc.mjs.map +1 -0
- package/dist/esm/utils/run.mjs +70 -0
- package/dist/esm/utils/run.mjs.map +1 -0
- package/dist/esm/utils/schema.mjs +24 -0
- package/dist/esm/utils/schema.mjs.map +1 -0
- package/dist/esm/utils/title.mjs +122 -0
- package/dist/esm/utils/title.mjs.map +1 -0
- package/dist/esm/utils/tokens.mjs +121 -0
- package/dist/esm/utils/tokens.mjs.map +1 -0
- package/dist/esm/utils/toonFormat.mjs +381 -0
- package/dist/esm/utils/toonFormat.mjs.map +1 -0
- package/dist/types/agents/AgentContext.d.ts +293 -0
- package/dist/types/common/enum.d.ts +155 -0
- package/dist/types/common/index.d.ts +1 -0
- package/dist/types/events.d.ts +31 -0
- package/dist/types/graphs/Graph.d.ts +216 -0
- package/dist/types/graphs/MultiAgentGraph.d.ts +104 -0
- package/dist/types/graphs/index.d.ts +2 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/instrumentation.d.ts +1 -0
- package/dist/types/llm/anthropic/index.d.ts +39 -0
- package/dist/types/llm/anthropic/types.d.ts +37 -0
- package/dist/types/llm/anthropic/utils/message_inputs.d.ts +14 -0
- package/dist/types/llm/anthropic/utils/message_outputs.d.ts +14 -0
- package/dist/types/llm/anthropic/utils/output_parsers.d.ts +22 -0
- package/dist/types/llm/anthropic/utils/tools.d.ts +3 -0
- package/dist/types/llm/bedrock/index.d.ts +141 -0
- package/dist/types/llm/bedrock/types.d.ts +27 -0
- package/dist/types/llm/bedrock/utils/index.d.ts +5 -0
- package/dist/types/llm/bedrock/utils/message_inputs.d.ts +31 -0
- package/dist/types/llm/bedrock/utils/message_outputs.d.ts +33 -0
- package/dist/types/llm/fake.d.ts +31 -0
- package/dist/types/llm/google/index.d.ts +24 -0
- package/dist/types/llm/google/types.d.ts +42 -0
- package/dist/types/llm/google/utils/common.d.ts +34 -0
- package/dist/types/llm/google/utils/tools.d.ts +10 -0
- package/dist/types/llm/google/utils/zod_to_genai_parameters.d.ts +14 -0
- package/dist/types/llm/openai/index.d.ts +127 -0
- package/dist/types/llm/openai/types.d.ts +10 -0
- package/dist/types/llm/openai/utils/index.d.ts +29 -0
- package/dist/types/llm/openrouter/index.d.ts +15 -0
- package/dist/types/llm/providers.d.ts +5 -0
- package/dist/types/llm/text.d.ts +21 -0
- package/dist/types/llm/vertexai/index.d.ts +293 -0
- package/dist/types/messages/cache.d.ts +54 -0
- package/dist/types/messages/content.d.ts +7 -0
- package/dist/types/messages/core.d.ts +14 -0
- package/dist/types/messages/format.d.ts +137 -0
- package/dist/types/messages/ids.d.ts +3 -0
- package/dist/types/messages/index.d.ts +7 -0
- package/dist/types/messages/prune.d.ts +52 -0
- package/dist/types/messages/reducer.d.ts +9 -0
- package/dist/types/messages/tools.d.ts +17 -0
- package/dist/types/mockStream.d.ts +32 -0
- package/dist/types/prompts/collab.d.ts +1 -0
- package/dist/types/prompts/index.d.ts +2 -0
- package/dist/types/prompts/taskmanager.d.ts +41 -0
- package/dist/types/run.d.ts +41 -0
- package/dist/types/schemas/index.d.ts +1 -0
- package/dist/types/schemas/validate.d.ts +59 -0
- package/dist/types/splitStream.d.ts +37 -0
- package/dist/types/stream.d.ts +15 -0
- package/dist/types/test/mockTools.d.ts +28 -0
- package/dist/types/tools/BrowserTools.d.ts +87 -0
- package/dist/types/tools/Calculator.d.ts +34 -0
- package/dist/types/tools/CodeExecutor.d.ts +57 -0
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +138 -0
- package/dist/types/tools/ToolNode.d.ts +51 -0
- package/dist/types/tools/ToolSearch.d.ts +219 -0
- package/dist/types/tools/handlers.d.ts +22 -0
- package/dist/types/tools/schema.d.ts +12 -0
- package/dist/types/tools/search/anthropic.d.ts +16 -0
- package/dist/types/tools/search/content.d.ts +4 -0
- package/dist/types/tools/search/firecrawl.d.ts +54 -0
- package/dist/types/tools/search/format.d.ts +5 -0
- package/dist/types/tools/search/highlights.d.ts +13 -0
- package/dist/types/tools/search/index.d.ts +3 -0
- package/dist/types/tools/search/rerankers.d.ts +38 -0
- package/dist/types/tools/search/schema.d.ts +103 -0
- package/dist/types/tools/search/search.d.ts +8 -0
- package/dist/types/tools/search/serper-scraper.d.ts +59 -0
- package/dist/types/tools/search/test.d.ts +1 -0
- package/dist/types/tools/search/tool.d.ts +3 -0
- package/dist/types/tools/search/types.d.ts +575 -0
- package/dist/types/tools/search/utils.d.ts +10 -0
- package/dist/types/types/graph.d.ts +399 -0
- package/dist/types/types/index.d.ts +5 -0
- package/dist/types/types/llm.d.ts +105 -0
- package/dist/types/types/messages.d.ts +4 -0
- package/dist/types/types/run.d.ts +112 -0
- package/dist/types/types/stream.d.ts +308 -0
- package/dist/types/types/tools.d.ts +296 -0
- package/dist/types/utils/contextAnalytics.d.ts +37 -0
- package/dist/types/utils/events.d.ts +6 -0
- package/dist/types/utils/graph.d.ts +2 -0
- package/dist/types/utils/handlers.d.ts +34 -0
- package/dist/types/utils/index.d.ts +9 -0
- package/dist/types/utils/llm.d.ts +3 -0
- package/dist/types/utils/llmConfig.d.ts +3 -0
- package/dist/types/utils/logging.d.ts +1 -0
- package/dist/types/utils/misc.d.ts +7 -0
- package/dist/types/utils/run.d.ts +27 -0
- package/dist/types/utils/schema.d.ts +8 -0
- package/dist/types/utils/title.d.ts +4 -0
- package/dist/types/utils/tokens.d.ts +28 -0
- package/dist/types/utils/toonFormat.d.ts +111 -0
- package/package.json +190 -0
- package/src/agents/AgentContext.test.ts +458 -0
- package/src/agents/AgentContext.ts +972 -0
- package/src/agents/__tests__/AgentContext.test.ts +805 -0
- package/src/agents/__tests__/resolveStructuredOutputMode.test.ts +137 -0
- package/src/common/enum.ts +203 -0
- package/src/common/index.ts +2 -0
- package/src/events.ts +223 -0
- package/src/graphs/Graph.ts +2228 -0
- package/src/graphs/MultiAgentGraph.ts +1063 -0
- package/src/graphs/__tests__/structured-output.integration.test.ts +809 -0
- package/src/graphs/__tests__/structured-output.test.ts +183 -0
- package/src/graphs/index.ts +2 -0
- package/src/index.ts +34 -0
- package/src/instrumentation.ts +22 -0
- package/src/llm/anthropic/Jacob_Lee_Resume_2023.pdf +0 -0
- package/src/llm/anthropic/index.ts +413 -0
- package/src/llm/anthropic/llm.spec.ts +1442 -0
- package/src/llm/anthropic/types.ts +140 -0
- package/src/llm/anthropic/utils/message_inputs.ts +757 -0
- package/src/llm/anthropic/utils/message_outputs.ts +289 -0
- package/src/llm/anthropic/utils/output_parsers.ts +133 -0
- package/src/llm/anthropic/utils/tools.ts +29 -0
- package/src/llm/bedrock/__tests__/bedrock-caching.test.ts +495 -0
- package/src/llm/bedrock/index.ts +411 -0
- package/src/llm/bedrock/llm.spec.ts +616 -0
- package/src/llm/bedrock/types.ts +51 -0
- package/src/llm/bedrock/utils/index.ts +18 -0
- package/src/llm/bedrock/utils/message_inputs.ts +563 -0
- package/src/llm/bedrock/utils/message_outputs.ts +310 -0
- package/src/llm/fake.ts +133 -0
- package/src/llm/google/data/gettysburg10.wav +0 -0
- package/src/llm/google/data/hotdog.jpg +0 -0
- package/src/llm/google/index.ts +337 -0
- package/src/llm/google/llm.spec.ts +934 -0
- package/src/llm/google/types.ts +56 -0
- package/src/llm/google/utils/common.ts +873 -0
- package/src/llm/google/utils/tools.ts +160 -0
- package/src/llm/google/utils/zod_to_genai_parameters.ts +86 -0
- package/src/llm/openai/index.ts +1366 -0
- package/src/llm/openai/types.ts +24 -0
- package/src/llm/openai/utils/index.ts +1035 -0
- package/src/llm/openai/utils/isReasoningModel.test.ts +90 -0
- package/src/llm/openrouter/index.ts +291 -0
- package/src/llm/providers.ts +52 -0
- package/src/llm/text.ts +94 -0
- package/src/llm/vertexai/index.ts +359 -0
- package/src/messages/__tests__/tools.test.ts +473 -0
- package/src/messages/cache.test.ts +1261 -0
- package/src/messages/cache.ts +518 -0
- package/src/messages/content.test.ts +362 -0
- package/src/messages/content.ts +63 -0
- package/src/messages/core.ts +473 -0
- package/src/messages/ensureThinkingBlock.test.ts +468 -0
- package/src/messages/format.ts +1029 -0
- package/src/messages/formatAgentMessages.test.ts +1513 -0
- package/src/messages/formatAgentMessages.tools.test.ts +419 -0
- package/src/messages/formatMessage.test.ts +693 -0
- package/src/messages/ids.ts +26 -0
- package/src/messages/index.ts +7 -0
- package/src/messages/labelContentByAgent.test.ts +887 -0
- package/src/messages/prune.ts +568 -0
- package/src/messages/reducer.ts +80 -0
- package/src/messages/shiftIndexTokenCountMap.test.ts +81 -0
- package/src/messages/tools.ts +108 -0
- package/src/mockStream.ts +99 -0
- package/src/prompts/collab.ts +6 -0
- package/src/prompts/index.ts +2 -0
- package/src/prompts/taskmanager.ts +61 -0
- package/src/run.ts +467 -0
- package/src/schemas/index.ts +2 -0
- package/src/schemas/schema-preparation.test.ts +500 -0
- package/src/schemas/validate.test.ts +358 -0
- package/src/schemas/validate.ts +454 -0
- package/src/scripts/abort.ts +157 -0
- package/src/scripts/ant_web_search.ts +158 -0
- package/src/scripts/ant_web_search_edge_case.ts +162 -0
- package/src/scripts/ant_web_search_error_edge_case.ts +148 -0
- package/src/scripts/args.ts +48 -0
- package/src/scripts/caching.ts +132 -0
- package/src/scripts/cli.ts +172 -0
- package/src/scripts/cli2.ts +133 -0
- package/src/scripts/cli3.ts +184 -0
- package/src/scripts/cli4.ts +191 -0
- package/src/scripts/cli5.ts +191 -0
- package/src/scripts/code_exec.ts +213 -0
- package/src/scripts/code_exec_files.ts +236 -0
- package/src/scripts/code_exec_multi_session.ts +241 -0
- package/src/scripts/code_exec_ptc.ts +334 -0
- package/src/scripts/code_exec_session.ts +282 -0
- package/src/scripts/code_exec_simple.ts +147 -0
- package/src/scripts/content.ts +138 -0
- package/src/scripts/empty_input.ts +137 -0
- package/src/scripts/handoff-test.ts +135 -0
- package/src/scripts/image.ts +178 -0
- package/src/scripts/memory.ts +97 -0
- package/src/scripts/multi-agent-chain.ts +331 -0
- package/src/scripts/multi-agent-conditional.ts +221 -0
- package/src/scripts/multi-agent-document-review-chain.ts +197 -0
- package/src/scripts/multi-agent-hybrid-flow.ts +310 -0
- package/src/scripts/multi-agent-parallel-start.ts +265 -0
- package/src/scripts/multi-agent-parallel.ts +394 -0
- package/src/scripts/multi-agent-sequence.ts +217 -0
- package/src/scripts/multi-agent-supervisor.ts +365 -0
- package/src/scripts/multi-agent-test.ts +186 -0
- package/src/scripts/parallel-asymmetric-tools-test.ts +274 -0
- package/src/scripts/parallel-full-metadata-test.ts +240 -0
- package/src/scripts/parallel-tools-test.ts +340 -0
- package/src/scripts/programmatic_exec.ts +396 -0
- package/src/scripts/programmatic_exec_agent.ts +231 -0
- package/src/scripts/search.ts +146 -0
- package/src/scripts/sequential-full-metadata-test.ts +197 -0
- package/src/scripts/simple.ts +225 -0
- package/src/scripts/single-agent-metadata-test.ts +198 -0
- package/src/scripts/stream.ts +140 -0
- package/src/scripts/test-custom-prompt-key.ts +145 -0
- package/src/scripts/test-handoff-input.ts +170 -0
- package/src/scripts/test-handoff-preamble.ts +277 -0
- package/src/scripts/test-multi-agent-list-handoff.ts +417 -0
- package/src/scripts/test-parallel-agent-labeling.ts +325 -0
- package/src/scripts/test-parallel-handoffs.ts +291 -0
- package/src/scripts/test-thinking-handoff-bedrock.ts +153 -0
- package/src/scripts/test-thinking-handoff.ts +155 -0
- package/src/scripts/test-tools-before-handoff.ts +226 -0
- package/src/scripts/test_code_api.ts +361 -0
- package/src/scripts/thinking-bedrock.ts +159 -0
- package/src/scripts/thinking.ts +171 -0
- package/src/scripts/tool_search.ts +162 -0
- package/src/scripts/tools.ts +177 -0
- package/src/specs/agent-handoffs.test.ts +888 -0
- package/src/specs/anthropic.simple.test.ts +387 -0
- package/src/specs/azure.simple.test.ts +364 -0
- package/src/specs/cache.simple.test.ts +396 -0
- package/src/specs/deepseek.simple.test.ts +283 -0
- package/src/specs/emergency-prune.test.ts +407 -0
- package/src/specs/moonshot.simple.test.ts +358 -0
- package/src/specs/openai.simple.test.ts +311 -0
- package/src/specs/openrouter.simple.test.ts +107 -0
- package/src/specs/prune.test.ts +901 -0
- package/src/specs/reasoning.test.ts +201 -0
- package/src/specs/spec.utils.ts +3 -0
- package/src/specs/thinking-handoff.test.ts +620 -0
- package/src/specs/thinking-prune.test.ts +703 -0
- package/src/specs/token-distribution-edge-case.test.ts +316 -0
- package/src/specs/token-memoization.test.ts +32 -0
- package/src/specs/tool-error.test.ts +198 -0
- package/src/splitStream.test.ts +691 -0
- package/src/splitStream.ts +234 -0
- package/src/stream.test.ts +94 -0
- package/src/stream.ts +801 -0
- package/src/test/mockTools.ts +386 -0
- package/src/tools/BrowserTools.ts +393 -0
- package/src/tools/Calculator.test.ts +278 -0
- package/src/tools/Calculator.ts +46 -0
- package/src/tools/CodeExecutor.ts +270 -0
- package/src/tools/ProgrammaticToolCalling.ts +785 -0
- package/src/tools/ToolNode.ts +674 -0
- package/src/tools/ToolSearch.ts +1095 -0
- package/src/tools/__tests__/BrowserTools.test.ts +265 -0
- package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.ts +319 -0
- package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +1006 -0
- package/src/tools/__tests__/ToolSearch.integration.test.ts +162 -0
- package/src/tools/__tests__/ToolSearch.test.ts +1003 -0
- package/src/tools/handlers.ts +363 -0
- package/src/tools/schema.ts +37 -0
- package/src/tools/search/anthropic.ts +51 -0
- package/src/tools/search/content.test.ts +173 -0
- package/src/tools/search/content.ts +147 -0
- package/src/tools/search/firecrawl.ts +210 -0
- package/src/tools/search/format.ts +250 -0
- package/src/tools/search/highlights.ts +320 -0
- package/src/tools/search/index.ts +3 -0
- package/src/tools/search/jina-reranker.test.ts +130 -0
- package/src/tools/search/output.md +2775 -0
- package/src/tools/search/rerankers.ts +242 -0
- package/src/tools/search/schema.ts +113 -0
- package/src/tools/search/search.ts +768 -0
- package/src/tools/search/serper-scraper.ts +155 -0
- package/src/tools/search/test.html +884 -0
- package/src/tools/search/test.md +643 -0
- package/src/tools/search/test.ts +159 -0
- package/src/tools/search/tool.ts +657 -0
- package/src/tools/search/types.ts +665 -0
- package/src/tools/search/utils.ts +79 -0
- package/src/types/graph.test.ts +218 -0
- package/src/types/graph.ts +533 -0
- package/src/types/index.ts +6 -0
- package/src/types/llm.ts +140 -0
- package/src/types/messages.ts +4 -0
- package/src/types/run.ts +128 -0
- package/src/types/stream.ts +417 -0
- package/src/types/tools.ts +355 -0
- package/src/utils/contextAnalytics.ts +103 -0
- package/src/utils/events.ts +32 -0
- package/src/utils/graph.ts +11 -0
- package/src/utils/handlers.ts +107 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/llm.ts +26 -0
- package/src/utils/llmConfig.ts +208 -0
- package/src/utils/logging.ts +48 -0
- package/src/utils/misc.ts +57 -0
- package/src/utils/run.ts +106 -0
- package/src/utils/schema.ts +35 -0
- package/src/utils/title.ts +177 -0
- package/src/utils/tokens.ts +142 -0
- package/src/utils/toonFormat.ts +475 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { ChatGoogle } from '@langchain/google-gauth';
|
|
2
|
+
import type { GoogleAIModelRequestParams, GoogleAbstractedClient } from '@langchain/google-common';
|
|
3
|
+
import type { VertexAIClientOptions } from '@/types';
|
|
4
|
+
/**
|
|
5
|
+
* Integration with Google Vertex AI chat models.
|
|
6
|
+
*
|
|
7
|
+
* Setup:
|
|
8
|
+
* Install `@langchain/google-vertexai` and set your stringified
|
|
9
|
+
* Vertex AI credentials as an environment variable named `GOOGLE_APPLICATION_CREDENTIALS`.
|
|
10
|
+
*
|
|
11
|
+
* ```bash
|
|
12
|
+
* npm install @langchain/google-vertexai
|
|
13
|
+
* export GOOGLE_APPLICATION_CREDENTIALS="path/to/credentials"
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ## [Constructor args](https://api.js.langchain.com/classes/_langchain_google_vertexai.index.ChatVertexAI.html#constructor.new_ChatVertexAI)
|
|
17
|
+
*
|
|
18
|
+
* ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_google_common_types.GoogleAIBaseLanguageModelCallOptions.html)
|
|
19
|
+
*
|
|
20
|
+
* Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.
|
|
21
|
+
* They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:
|
|
22
|
+
*
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // When calling `.withConfig`, call options should be passed via the first argument
|
|
25
|
+
* const llmWithArgsBound = llm.withConfig({
|
|
26
|
+
* stop: ["\n"],
|
|
27
|
+
* tools: [...],
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // When calling `.bindTools`, call options should be passed via the second argument
|
|
31
|
+
* const llmWithTools = llm.bindTools(
|
|
32
|
+
* [...],
|
|
33
|
+
* {
|
|
34
|
+
* tool_choice: "auto",
|
|
35
|
+
* }
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* ## Examples
|
|
40
|
+
*
|
|
41
|
+
* <details open>
|
|
42
|
+
* <summary><strong>Instantiate</strong></summary>
|
|
43
|
+
*
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { ChatVertexAI } from '@langchain/google-vertexai';
|
|
46
|
+
*
|
|
47
|
+
* const llm = new ChatVertexAI({
|
|
48
|
+
* model: "gemini-1.5-pro",
|
|
49
|
+
* temperature: 0,
|
|
50
|
+
* // other params...
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
* </details>
|
|
54
|
+
*
|
|
55
|
+
* <br />
|
|
56
|
+
*
|
|
57
|
+
* <details>
|
|
58
|
+
* <summary><strong>Invoking</strong></summary>
|
|
59
|
+
*
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const input = `Translate "I love programming" into French.`;
|
|
62
|
+
*
|
|
63
|
+
* // Models also accept a list of chat messages or a formatted prompt
|
|
64
|
+
* const result = await llm.invoke(input);
|
|
65
|
+
* console.log(result);
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* ```txt
|
|
69
|
+
* AIMessageChunk {
|
|
70
|
+
* "content": "\"J'adore programmer\" \n\nHere's why this is the best translation:\n\n* **J'adore** means \"I love\" and conveys a strong passion.\n* **Programmer** is the French verb for \"to program.\"\n\nThis translation is natural and idiomatic in French. \n",
|
|
71
|
+
* "additional_kwargs": {},
|
|
72
|
+
* "response_metadata": {},
|
|
73
|
+
* "tool_calls": [],
|
|
74
|
+
* "tool_call_chunks": [],
|
|
75
|
+
* "invalid_tool_calls": [],
|
|
76
|
+
* "usage_metadata": {
|
|
77
|
+
* "input_tokens": 9,
|
|
78
|
+
* "output_tokens": 63,
|
|
79
|
+
* "total_tokens": 72
|
|
80
|
+
* }
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
* </details>
|
|
84
|
+
*
|
|
85
|
+
* <br />
|
|
86
|
+
*
|
|
87
|
+
* <details>
|
|
88
|
+
* <summary><strong>Streaming Chunks</strong></summary>
|
|
89
|
+
*
|
|
90
|
+
* ```typescript
|
|
91
|
+
* for await (const chunk of await llm.stream(input)) {
|
|
92
|
+
* console.log(chunk);
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* ```txt
|
|
97
|
+
* AIMessageChunk {
|
|
98
|
+
* "content": "\"",
|
|
99
|
+
* "additional_kwargs": {},
|
|
100
|
+
* "response_metadata": {},
|
|
101
|
+
* "tool_calls": [],
|
|
102
|
+
* "tool_call_chunks": [],
|
|
103
|
+
* "invalid_tool_calls": []
|
|
104
|
+
* }
|
|
105
|
+
* AIMessageChunk {
|
|
106
|
+
* "content": "J'adore programmer\" \n",
|
|
107
|
+
* "additional_kwargs": {},
|
|
108
|
+
* "response_metadata": {},
|
|
109
|
+
* "tool_calls": [],
|
|
110
|
+
* "tool_call_chunks": [],
|
|
111
|
+
* "invalid_tool_calls": []
|
|
112
|
+
* }
|
|
113
|
+
* AIMessageChunk {
|
|
114
|
+
* "content": "",
|
|
115
|
+
* "additional_kwargs": {},
|
|
116
|
+
* "response_metadata": {},
|
|
117
|
+
* "tool_calls": [],
|
|
118
|
+
* "tool_call_chunks": [],
|
|
119
|
+
* "invalid_tool_calls": []
|
|
120
|
+
* }
|
|
121
|
+
* AIMessageChunk {
|
|
122
|
+
* "content": "",
|
|
123
|
+
* "additional_kwargs": {},
|
|
124
|
+
* "response_metadata": {
|
|
125
|
+
* "finishReason": "stop"
|
|
126
|
+
* },
|
|
127
|
+
* "tool_calls": [],
|
|
128
|
+
* "tool_call_chunks": [],
|
|
129
|
+
* "invalid_tool_calls": [],
|
|
130
|
+
* "usage_metadata": {
|
|
131
|
+
* "input_tokens": 9,
|
|
132
|
+
* "output_tokens": 8,
|
|
133
|
+
* "total_tokens": 17
|
|
134
|
+
* }
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
* </details>
|
|
138
|
+
*
|
|
139
|
+
* <br />
|
|
140
|
+
*
|
|
141
|
+
* <details>
|
|
142
|
+
* <summary><strong>Aggregate Streamed Chunks</strong></summary>
|
|
143
|
+
*
|
|
144
|
+
* ```typescript
|
|
145
|
+
* import { AIMessageChunk } from '@langchain/core/messages';
|
|
146
|
+
* import { concat } from '@langchain/core/utils/stream';
|
|
147
|
+
*
|
|
148
|
+
* const stream = await llm.stream(input);
|
|
149
|
+
* let full: AIMessageChunk | undefined;
|
|
150
|
+
* for await (const chunk of stream) {
|
|
151
|
+
* full = !full ? chunk : concat(full, chunk);
|
|
152
|
+
* }
|
|
153
|
+
* console.log(full);
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* ```txt
|
|
157
|
+
* AIMessageChunk {
|
|
158
|
+
* "content": "\"J'adore programmer\" \n",
|
|
159
|
+
* "additional_kwargs": {},
|
|
160
|
+
* "response_metadata": {
|
|
161
|
+
* "finishReason": "stop"
|
|
162
|
+
* },
|
|
163
|
+
* "tool_calls": [],
|
|
164
|
+
* "tool_call_chunks": [],
|
|
165
|
+
* "invalid_tool_calls": [],
|
|
166
|
+
* "usage_metadata": {
|
|
167
|
+
* "input_tokens": 9,
|
|
168
|
+
* "output_tokens": 8,
|
|
169
|
+
* "total_tokens": 17
|
|
170
|
+
* }
|
|
171
|
+
* }
|
|
172
|
+
* ```
|
|
173
|
+
* </details>
|
|
174
|
+
*
|
|
175
|
+
* <br />
|
|
176
|
+
*
|
|
177
|
+
* <details>
|
|
178
|
+
* <summary><strong>Bind tools</strong></summary>
|
|
179
|
+
*
|
|
180
|
+
* ```typescript
|
|
181
|
+
* import { z } from 'zod';
|
|
182
|
+
*
|
|
183
|
+
* const GetWeather = {
|
|
184
|
+
* name: "GetWeather",
|
|
185
|
+
* description: "Get the current weather in a given location",
|
|
186
|
+
* schema: z.object({
|
|
187
|
+
* location: z.string().describe("The city and state, e.g. San Francisco, CA")
|
|
188
|
+
* }),
|
|
189
|
+
* }
|
|
190
|
+
*
|
|
191
|
+
* const GetPopulation = {
|
|
192
|
+
* name: "GetPopulation",
|
|
193
|
+
* description: "Get the current population in a given location",
|
|
194
|
+
* schema: z.object({
|
|
195
|
+
* location: z.string().describe("The city and state, e.g. San Francisco, CA")
|
|
196
|
+
* }),
|
|
197
|
+
* }
|
|
198
|
+
*
|
|
199
|
+
* const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);
|
|
200
|
+
* const aiMsg = await llmWithTools.invoke(
|
|
201
|
+
* "Which city is hotter today and which is bigger: LA or NY?"
|
|
202
|
+
* );
|
|
203
|
+
* console.log(aiMsg.tool_calls);
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* ```txt
|
|
207
|
+
* [
|
|
208
|
+
* {
|
|
209
|
+
* name: 'GetPopulation',
|
|
210
|
+
* args: { location: 'New York City, NY' },
|
|
211
|
+
* id: '33c1c1f47e2f492799c77d2800a43912',
|
|
212
|
+
* type: 'tool_call'
|
|
213
|
+
* }
|
|
214
|
+
* ]
|
|
215
|
+
* ```
|
|
216
|
+
* </details>
|
|
217
|
+
*
|
|
218
|
+
* <br />
|
|
219
|
+
*
|
|
220
|
+
* <details>
|
|
221
|
+
* <summary><strong>Structured Output</strong></summary>
|
|
222
|
+
*
|
|
223
|
+
* ```typescript
|
|
224
|
+
* import { z } from 'zod';
|
|
225
|
+
*
|
|
226
|
+
* const Joke = z.object({
|
|
227
|
+
* setup: z.string().describe("The setup of the joke"),
|
|
228
|
+
* punchline: z.string().describe("The punchline to the joke"),
|
|
229
|
+
* rating: z.number().optional().describe("How funny the joke is, from 1 to 10")
|
|
230
|
+
* }).describe('Joke to tell user.');
|
|
231
|
+
*
|
|
232
|
+
* const structuredLlm = llm.withStructuredOutput(Joke, { name: "Joke" });
|
|
233
|
+
* const jokeResult = await structuredLlm.invoke("Tell me a joke about cats");
|
|
234
|
+
* console.log(jokeResult);
|
|
235
|
+
* ```
|
|
236
|
+
*
|
|
237
|
+
* ```txt
|
|
238
|
+
* {
|
|
239
|
+
* setup: 'What do you call a cat that loves to bowl?',
|
|
240
|
+
* punchline: 'An alley cat!'
|
|
241
|
+
* }
|
|
242
|
+
* ```
|
|
243
|
+
* </details>
|
|
244
|
+
*
|
|
245
|
+
* <br />
|
|
246
|
+
*
|
|
247
|
+
* <details>
|
|
248
|
+
* <summary><strong>Usage Metadata</strong></summary>
|
|
249
|
+
*
|
|
250
|
+
* ```typescript
|
|
251
|
+
* const aiMsgForMetadata = await llm.invoke(input);
|
|
252
|
+
* console.log(aiMsgForMetadata.usage_metadata);
|
|
253
|
+
* ```
|
|
254
|
+
*
|
|
255
|
+
* ```txt
|
|
256
|
+
* { input_tokens: 9, output_tokens: 8, total_tokens: 17 }
|
|
257
|
+
* ```
|
|
258
|
+
* </details>
|
|
259
|
+
*
|
|
260
|
+
* <br />
|
|
261
|
+
*
|
|
262
|
+
* <details>
|
|
263
|
+
* <summary><strong>Stream Usage Metadata</strong></summary>
|
|
264
|
+
*
|
|
265
|
+
* ```typescript
|
|
266
|
+
* const streamForMetadata = await llm.stream(
|
|
267
|
+
* input,
|
|
268
|
+
* {
|
|
269
|
+
* streamUsage: true
|
|
270
|
+
* }
|
|
271
|
+
* );
|
|
272
|
+
* let fullForMetadata: AIMessageChunk | undefined;
|
|
273
|
+
* for await (const chunk of streamForMetadata) {
|
|
274
|
+
* fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);
|
|
275
|
+
* }
|
|
276
|
+
* console.log(fullForMetadata?.usage_metadata);
|
|
277
|
+
* ```
|
|
278
|
+
*
|
|
279
|
+
* ```txt
|
|
280
|
+
* { input_tokens: 9, output_tokens: 8, total_tokens: 17 }
|
|
281
|
+
* ```
|
|
282
|
+
* </details>
|
|
283
|
+
*
|
|
284
|
+
* <br />
|
|
285
|
+
*/
|
|
286
|
+
export declare class ChatVertexAI extends ChatGoogle {
|
|
287
|
+
lc_namespace: string[];
|
|
288
|
+
dynamicThinkingBudget: boolean;
|
|
289
|
+
static lc_name(): 'IllumaVertexAI';
|
|
290
|
+
constructor(fields?: VertexAIClientOptions);
|
|
291
|
+
invocationParams(options?: this['ParsedCallOptions'] | undefined): GoogleAIModelRequestParams;
|
|
292
|
+
buildConnection(fields: VertexAIClientOptions, client: GoogleAbstractedClient): void;
|
|
293
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BaseMessage, MessageContentComplex } from '@langchain/core/messages';
|
|
2
|
+
import type { AnthropicMessage } from '@/types/messages';
|
|
3
|
+
type MessageWithContent = {
|
|
4
|
+
content?: string | MessageContentComplex[];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Anthropic API: Adds cache control to the appropriate user messages in the payload.
|
|
8
|
+
* Strips ALL existing cache control (both Anthropic and Bedrock formats) from all messages,
|
|
9
|
+
* then adds fresh cache control to the last 2 user messages in a single backward pass.
|
|
10
|
+
* This ensures we don't accumulate stale cache points across multiple turns.
|
|
11
|
+
* Returns a new array - only clones messages that require modification.
|
|
12
|
+
* @param messages - The array of message objects.
|
|
13
|
+
* @returns - A new array of message objects with cache control added.
|
|
14
|
+
*/
|
|
15
|
+
export declare function addCacheControl<T extends AnthropicMessage | BaseMessage>(messages: T[]): T[];
|
|
16
|
+
/**
|
|
17
|
+
* Removes all Anthropic cache_control fields from messages
|
|
18
|
+
* Used when switching from Anthropic to Bedrock provider
|
|
19
|
+
* Returns a new array - only clones messages that require modification.
|
|
20
|
+
*/
|
|
21
|
+
export declare function stripAnthropicCacheControl<T extends MessageWithContent>(messages: T[]): T[];
|
|
22
|
+
/**
|
|
23
|
+
* Removes all Bedrock cachePoint blocks from messages
|
|
24
|
+
* Used when switching from Bedrock to Anthropic provider
|
|
25
|
+
* Returns a new array - only clones messages that require modification.
|
|
26
|
+
*/
|
|
27
|
+
export declare function stripBedrockCacheControl<T extends MessageWithContent>(messages: T[]): T[];
|
|
28
|
+
/**
|
|
29
|
+
* Adds Bedrock Converse API cache points using "Stable Prefix Caching" strategy.
|
|
30
|
+
*
|
|
31
|
+
* STRATEGY: Place cache point after the LAST ASSISTANT message only.
|
|
32
|
+
* This ensures the prefix (everything before the cache point) remains STABLE
|
|
33
|
+
* as the conversation grows, maximizing cache hits.
|
|
34
|
+
*
|
|
35
|
+
* Why this works:
|
|
36
|
+
* - System message has its own cachePoint (added in AgentContext)
|
|
37
|
+
* - Tools have their own cachePoint (added in CustomChatBedrockConverse)
|
|
38
|
+
* - Conversation history grows, but the PREFIX stays the same
|
|
39
|
+
* - Only the NEW user message is uncached (it's always different)
|
|
40
|
+
*
|
|
41
|
+
* Example conversation flow:
|
|
42
|
+
* Request 1: [System+cachePoint][Tools+cachePoint][User1] → No conversation cache yet
|
|
43
|
+
* Request 2: [System][Tools][User1][Assistant1+cachePoint][User2] → Cache User1+Assistant1
|
|
44
|
+
* Request 3: [System][Tools][User1][Assistant1][User2][Assistant2+cachePoint][User3]
|
|
45
|
+
* → Cache reads User1+A1+User2+A2, cache writes new portion
|
|
46
|
+
*
|
|
47
|
+
* Claude's "Simplified Cache Management" automatically looks back up to 20 content
|
|
48
|
+
* blocks from the cache checkpoint to find the longest matching prefix.
|
|
49
|
+
*
|
|
50
|
+
* @param messages - The array of message objects (excluding system message).
|
|
51
|
+
* @returns - The updated array with a single cache point after the last assistant message.
|
|
52
|
+
*/
|
|
53
|
+
export declare function addBedrockCacheControl<T extends Partial<BaseMessage> & MessageWithContent>(messages: T[]): T[];
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
/**
|
|
3
|
+
* Formats an array of messages for LangChain, making sure all content fields are strings
|
|
4
|
+
* @param {Array<HumanMessage | AIMessage | SystemMessage | ToolMessage>} payload - The array of messages to format.
|
|
5
|
+
* @returns {Array<HumanMessage | AIMessage | SystemMessage | ToolMessage>} - The array of formatted LangChain messages, including ToolMessages for tool calls.
|
|
6
|
+
*/
|
|
7
|
+
export declare const formatContentStrings: (payload: Array<BaseMessage>) => Array<BaseMessage>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AIMessageChunk, HumanMessage, ToolMessage, AIMessage, BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import type * as t from '@/types';
|
|
3
|
+
import { Providers } from '@/common';
|
|
4
|
+
export declare function getConverseOverrideMessage({ userMessage, lastMessageX, lastMessageY, }: {
|
|
5
|
+
userMessage: string[];
|
|
6
|
+
lastMessageX: AIMessageChunk | null;
|
|
7
|
+
lastMessageY: ToolMessage;
|
|
8
|
+
}): HumanMessage;
|
|
9
|
+
export declare function modifyDeltaProperties(provider: Providers, obj?: AIMessageChunk): AIMessageChunk | undefined;
|
|
10
|
+
export declare function formatAnthropicMessage(message: AIMessageChunk): AIMessage;
|
|
11
|
+
export declare function convertMessagesToContent(messages: BaseMessage[]): t.MessageContentComplex[];
|
|
12
|
+
export declare function formatAnthropicArtifactContent(messages: BaseMessage[]): void;
|
|
13
|
+
export declare function formatArtifactPayload(messages: BaseMessage[]): void;
|
|
14
|
+
export declare function findLastIndex<T>(array: T[], predicate: (value: T) => boolean): number;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { AIMessage, ToolMessage, BaseMessage, HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
2
|
+
import type { MessageContentImageUrl } from '@langchain/core/messages';
|
|
3
|
+
import type { MessageContentComplex, TPayload } from '@/types';
|
|
4
|
+
import { Providers } from '@/common';
|
|
5
|
+
interface MediaMessageParams {
|
|
6
|
+
message: {
|
|
7
|
+
role: string;
|
|
8
|
+
content: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
mediaParts: MessageContentComplex[];
|
|
13
|
+
endpoint?: Providers;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Formats a message with media content (images, documents, videos, audios) to API payload format.
|
|
17
|
+
*
|
|
18
|
+
* @param params - The parameters for formatting.
|
|
19
|
+
* @returns - The formatted message.
|
|
20
|
+
*/
|
|
21
|
+
export declare const formatMediaMessage: ({ message, endpoint, mediaParts, }: MediaMessageParams) => {
|
|
22
|
+
role: string;
|
|
23
|
+
content: MessageContentComplex[];
|
|
24
|
+
name?: string;
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
};
|
|
27
|
+
interface MessageInput {
|
|
28
|
+
role?: string;
|
|
29
|
+
_name?: string;
|
|
30
|
+
sender?: string;
|
|
31
|
+
text?: string;
|
|
32
|
+
content?: string | MessageContentComplex[];
|
|
33
|
+
image_urls?: MessageContentImageUrl[];
|
|
34
|
+
documents?: MessageContentComplex[];
|
|
35
|
+
videos?: MessageContentComplex[];
|
|
36
|
+
audios?: MessageContentComplex[];
|
|
37
|
+
lc_id?: string[];
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
interface FormatMessageParams {
|
|
41
|
+
message: MessageInput;
|
|
42
|
+
userName?: string;
|
|
43
|
+
assistantName?: string;
|
|
44
|
+
endpoint?: Providers;
|
|
45
|
+
langChain?: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface FormattedMessage {
|
|
48
|
+
role: string;
|
|
49
|
+
content: string | MessageContentComplex[];
|
|
50
|
+
name?: string;
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Formats a message to OpenAI payload format based on the provided options.
|
|
55
|
+
*
|
|
56
|
+
* @param params - The parameters for formatting.
|
|
57
|
+
* @returns - The formatted message.
|
|
58
|
+
*/
|
|
59
|
+
export declare const formatMessage: ({ message, userName, endpoint, assistantName, langChain, }: FormatMessageParams) => FormattedMessage | HumanMessage | AIMessage | SystemMessage;
|
|
60
|
+
/**
|
|
61
|
+
* Formats an array of messages for LangChain.
|
|
62
|
+
*
|
|
63
|
+
* @param messages - The array of messages to format.
|
|
64
|
+
* @param formatOptions - The options for formatting each message.
|
|
65
|
+
* @returns - The array of formatted LangChain messages.
|
|
66
|
+
*/
|
|
67
|
+
export declare const formatLangChainMessages: (messages: Array<MessageInput>, formatOptions: Omit<FormatMessageParams, "message" | "langChain">) => Array<HumanMessage | AIMessage | SystemMessage>;
|
|
68
|
+
interface LangChainMessage {
|
|
69
|
+
lc_kwargs?: {
|
|
70
|
+
additional_kwargs?: Record<string, any>;
|
|
71
|
+
[key: string]: any;
|
|
72
|
+
};
|
|
73
|
+
kwargs?: {
|
|
74
|
+
additional_kwargs?: Record<string, any>;
|
|
75
|
+
[key: string]: any;
|
|
76
|
+
};
|
|
77
|
+
[key: string]: any;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Formats a LangChain message object by merging properties from `lc_kwargs` or `kwargs` and `additional_kwargs`.
|
|
81
|
+
*
|
|
82
|
+
* @param message - The message object to format.
|
|
83
|
+
* @returns - The formatted LangChain message.
|
|
84
|
+
*/
|
|
85
|
+
export declare const formatFromLangChain: (message: LangChainMessage) => Record<string, any>;
|
|
86
|
+
/**
|
|
87
|
+
* Groups content parts by agent and formats them with agent labels
|
|
88
|
+
* This preprocesses multi-agent content to prevent identity confusion
|
|
89
|
+
*
|
|
90
|
+
* @param contentParts - The content parts from a run
|
|
91
|
+
* @param agentIdMap - Map of content part index to agent ID
|
|
92
|
+
* @param agentNames - Optional map of agent ID to display name
|
|
93
|
+
* @param options - Configuration options
|
|
94
|
+
* @param options.labelNonTransferContent - If true, labels all agent transitions (for parallel patterns)
|
|
95
|
+
* @returns Modified content parts with agent labels where appropriate
|
|
96
|
+
*/
|
|
97
|
+
export declare const labelContentByAgent: (contentParts: MessageContentComplex[], agentIdMap?: Record<number, string>, agentNames?: Record<string, string>, options?: {
|
|
98
|
+
labelNonTransferContent?: boolean;
|
|
99
|
+
}) => MessageContentComplex[];
|
|
100
|
+
/**
|
|
101
|
+
* Formats an array of messages for LangChain, handling tool calls and creating ToolMessage instances.
|
|
102
|
+
*
|
|
103
|
+
* @param payload - The array of messages to format.
|
|
104
|
+
* @param indexTokenCountMap - Optional map of message indices to token counts.
|
|
105
|
+
* @param tools - Optional set of tool names that are allowed in the request.
|
|
106
|
+
* @returns - Object containing formatted messages and updated indexTokenCountMap if provided.
|
|
107
|
+
*/
|
|
108
|
+
export declare const formatAgentMessages: (payload: TPayload, indexTokenCountMap?: Record<number, number | undefined>, tools?: Set<string>) => {
|
|
109
|
+
messages: Array<HumanMessage | AIMessage | SystemMessage | ToolMessage>;
|
|
110
|
+
indexTokenCountMap?: Record<number, number>;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Adds a value at key 0 for system messages and shifts all key indices by one in an indexTokenCountMap.
|
|
114
|
+
* This is useful when adding a system message at the beginning of a conversation.
|
|
115
|
+
*
|
|
116
|
+
* @param indexTokenCountMap - The original map of message indices to token counts
|
|
117
|
+
* @param instructionsTokenCount - The token count for the system message to add at index 0
|
|
118
|
+
* @returns A new map with the system message at index 0 and all other indices shifted by 1
|
|
119
|
+
*/
|
|
120
|
+
export declare function shiftIndexTokenCountMap(indexTokenCountMap: Record<number, number>, instructionsTokenCount: number): Record<number, number>;
|
|
121
|
+
/**
|
|
122
|
+
* Ensures compatibility when switching from a non-thinking agent to a thinking-enabled agent.
|
|
123
|
+
* Converts AI messages with tool calls (that lack thinking/reasoning blocks) into buffer strings,
|
|
124
|
+
* avoiding the thinking block signature requirement.
|
|
125
|
+
*
|
|
126
|
+
* Recognizes the following as valid thinking/reasoning blocks:
|
|
127
|
+
* - ContentTypes.THINKING (Anthropic)
|
|
128
|
+
* - ContentTypes.REASONING_CONTENT (Bedrock)
|
|
129
|
+
* - ContentTypes.REASONING (VertexAI / Google)
|
|
130
|
+
* - 'redacted_thinking'
|
|
131
|
+
*
|
|
132
|
+
* @param messages - Array of messages to process
|
|
133
|
+
* @param provider - The provider being used (unused but kept for future compatibility)
|
|
134
|
+
* @returns The messages array with tool sequences converted to buffer strings if necessary
|
|
135
|
+
*/
|
|
136
|
+
export declare function ensureThinkingBlockInMessages(messages: BaseMessage[], _provider: Providers): BaseMessage[];
|
|
137
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BaseMessage, UsageMetadata } from '@langchain/core/messages';
|
|
2
|
+
import type { TokenCounter } from '@/types/run';
|
|
3
|
+
import { ContentTypes, Providers } from '@/common';
|
|
4
|
+
export type PruneMessagesFactoryParams = {
|
|
5
|
+
provider?: Providers;
|
|
6
|
+
maxTokens: number;
|
|
7
|
+
startIndex: number;
|
|
8
|
+
tokenCounter: TokenCounter;
|
|
9
|
+
indexTokenCountMap: Record<string, number | undefined>;
|
|
10
|
+
thinkingEnabled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type PruneMessagesParams = {
|
|
13
|
+
messages: BaseMessage[];
|
|
14
|
+
usageMetadata?: Partial<UsageMetadata>;
|
|
15
|
+
startType?: ReturnType<BaseMessage['getType']>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Calculates the total tokens from a single usage object
|
|
19
|
+
*
|
|
20
|
+
* @param usage The usage metadata object containing token information
|
|
21
|
+
* @returns An object containing the total input and output tokens
|
|
22
|
+
*/
|
|
23
|
+
export declare function calculateTotalTokens(usage: Partial<UsageMetadata>): UsageMetadata;
|
|
24
|
+
export type PruningResult = {
|
|
25
|
+
context: BaseMessage[];
|
|
26
|
+
remainingContextTokens: number;
|
|
27
|
+
messagesToRefine: BaseMessage[];
|
|
28
|
+
thinkingStartIndex?: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Processes an array of messages and returns a context of messages that fit within a specified token limit.
|
|
32
|
+
* It iterates over the messages from newest to oldest, adding them to the context until the token limit is reached.
|
|
33
|
+
*
|
|
34
|
+
* @param options Configuration options for processing messages
|
|
35
|
+
* @returns Object containing the message context, remaining tokens, messages not included, and summary index
|
|
36
|
+
*/
|
|
37
|
+
export declare function getMessagesWithinTokenLimit({ messages: _messages, maxContextTokens, indexTokenCountMap, startType: _startType, thinkingEnabled, tokenCounter, thinkingStartIndex: _thinkingStartIndex, reasoningType, }: {
|
|
38
|
+
messages: BaseMessage[];
|
|
39
|
+
maxContextTokens: number;
|
|
40
|
+
indexTokenCountMap: Record<string, number | undefined>;
|
|
41
|
+
startType?: string | string[];
|
|
42
|
+
thinkingEnabled?: boolean;
|
|
43
|
+
tokenCounter: TokenCounter;
|
|
44
|
+
thinkingStartIndex?: number;
|
|
45
|
+
reasoningType?: ContentTypes.THINKING | ContentTypes.REASONING_CONTENT;
|
|
46
|
+
}): PruningResult;
|
|
47
|
+
export declare function checkValidNumber(value: unknown): value is number;
|
|
48
|
+
export declare function createPruneMessages(factoryParams: PruneMessagesFactoryParams): (params: PruneMessagesParams) => {
|
|
49
|
+
context: BaseMessage[];
|
|
50
|
+
indexTokenCountMap: Record<string, number | undefined>;
|
|
51
|
+
messagesToRefine: BaseMessage[];
|
|
52
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseMessage, BaseMessageLike } from '@langchain/core/messages';
|
|
2
|
+
export declare const REMOVE_ALL_MESSAGES = "__remove_all__";
|
|
3
|
+
export type Messages = Array<BaseMessage | BaseMessageLike> | BaseMessage | BaseMessageLike;
|
|
4
|
+
/**
|
|
5
|
+
* Prebuilt reducer that combines returned messages.
|
|
6
|
+
* Can handle standard messages and special modifiers like {@link RemoveMessage}
|
|
7
|
+
* instances.
|
|
8
|
+
*/
|
|
9
|
+
export declare function messagesStateReducer(left: Messages, right: Messages): BaseMessage[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts discovered tool names from tool search results in the current turn.
|
|
4
|
+
* Only processes tool search messages after the latest AI message with tool calls.
|
|
5
|
+
*
|
|
6
|
+
* Similar pattern to formatArtifactPayload - finds relevant messages efficiently
|
|
7
|
+
* by identifying the latest AI parent and only processing subsequent tool messages.
|
|
8
|
+
*
|
|
9
|
+
* @param messages - All messages in the conversation
|
|
10
|
+
* @returns Array of discovered tool names (empty if no new discoveries)
|
|
11
|
+
*/
|
|
12
|
+
export declare function extractToolDiscoveries(messages: BaseMessage[]): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the current turn has any tool search results.
|
|
15
|
+
* Quick check to avoid full extraction when not needed.
|
|
16
|
+
*/
|
|
17
|
+
export declare function hasToolSearchInCurrentTurn(messages: BaseMessage[]): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type * as t from '@/types';
|
|
2
|
+
export declare const createMockStream: (options?: {
|
|
3
|
+
text?: string;
|
|
4
|
+
reasoningText?: string;
|
|
5
|
+
streamRate?: number;
|
|
6
|
+
reasoningKey?: "reasoning" | "reasoning_content";
|
|
7
|
+
}) => () => AsyncGenerator<t.CustomChunk>;
|
|
8
|
+
/**
|
|
9
|
+
(async function testStream(): Promise<void> {
|
|
10
|
+
const runId = nanoid();
|
|
11
|
+
|
|
12
|
+
const streamHandler = new SplitStreamHandler({
|
|
13
|
+
runId,
|
|
14
|
+
handlers: {
|
|
15
|
+
[GraphEvents.ON_RUN_STEP]: (data): void => {
|
|
16
|
+
console.dir(data, { depth: null });
|
|
17
|
+
},
|
|
18
|
+
[GraphEvents.ON_MESSAGE_DELTA]: (): void => {
|
|
19
|
+
// console.dir(data, { depth: null });
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const stream = createMockStream({
|
|
24
|
+
reasoningText: 'This is a test reasoning text.',
|
|
25
|
+
streamRate: 5,
|
|
26
|
+
})();
|
|
27
|
+
|
|
28
|
+
for await (const chunk of stream) {
|
|
29
|
+
streamHandler.handle(chunk);
|
|
30
|
+
}
|
|
31
|
+
})();
|
|
32
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const supervisorPrompt = "You are a supervisor tasked with managing a conversation between the\nfollowing workers: {members}. Given the following user request,\nrespond with the worker to act next. Each worker will perform a\ntask and respond with their results and status. Multiple workers can work at once, and they can use multiple tools at once. Each worker can run their tools multiple times per task. When finished,\nrespond with FINISH.";
|