illuma-agents 1.0.2 → 1.0.3

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.
Files changed (225) hide show
  1. package/LICENSE +25 -21
  2. package/dist/cjs/agents/AgentContext.cjs +222 -0
  3. package/dist/cjs/agents/AgentContext.cjs.map +1 -0
  4. package/dist/cjs/common/enum.cjs +7 -6
  5. package/dist/cjs/common/enum.cjs.map +1 -1
  6. package/dist/cjs/events.cjs +7 -5
  7. package/dist/cjs/events.cjs.map +1 -1
  8. package/dist/cjs/graphs/Graph.cjs +328 -207
  9. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  10. package/dist/cjs/graphs/MultiAgentGraph.cjs +507 -0
  11. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -0
  12. package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
  13. package/dist/cjs/llm/google/index.cjs.map +1 -1
  14. package/dist/cjs/llm/ollama/index.cjs.map +1 -1
  15. package/dist/cjs/llm/openai/index.cjs +35 -0
  16. package/dist/cjs/llm/openai/index.cjs.map +1 -1
  17. package/dist/cjs/llm/openai/utils/index.cjs +3 -1
  18. package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
  19. package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
  20. package/dist/cjs/llm/providers.cjs +0 -2
  21. package/dist/cjs/llm/providers.cjs.map +1 -1
  22. package/dist/cjs/llm/vertexai/index.cjs.map +1 -1
  23. package/dist/cjs/main.cjs +12 -1
  24. package/dist/cjs/main.cjs.map +1 -1
  25. package/dist/cjs/messages/cache.cjs +123 -0
  26. package/dist/cjs/messages/cache.cjs.map +1 -0
  27. package/dist/cjs/messages/content.cjs +53 -0
  28. package/dist/cjs/messages/content.cjs.map +1 -0
  29. package/dist/cjs/messages/format.cjs +17 -29
  30. package/dist/cjs/messages/format.cjs.map +1 -1
  31. package/dist/cjs/run.cjs +119 -74
  32. package/dist/cjs/run.cjs.map +1 -1
  33. package/dist/cjs/stream.cjs +77 -73
  34. package/dist/cjs/stream.cjs.map +1 -1
  35. package/dist/cjs/tools/Calculator.cjs +45 -0
  36. package/dist/cjs/tools/Calculator.cjs.map +1 -0
  37. package/dist/cjs/tools/CodeExecutor.cjs +22 -22
  38. package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
  39. package/dist/cjs/tools/ToolNode.cjs +5 -3
  40. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  41. package/dist/cjs/tools/handlers.cjs +20 -20
  42. package/dist/cjs/tools/handlers.cjs.map +1 -1
  43. package/dist/cjs/utils/events.cjs +31 -0
  44. package/dist/cjs/utils/events.cjs.map +1 -0
  45. package/dist/cjs/utils/handlers.cjs +70 -0
  46. package/dist/cjs/utils/handlers.cjs.map +1 -0
  47. package/dist/cjs/utils/tokens.cjs +54 -7
  48. package/dist/cjs/utils/tokens.cjs.map +1 -1
  49. package/dist/esm/agents/AgentContext.mjs +220 -0
  50. package/dist/esm/agents/AgentContext.mjs.map +1 -0
  51. package/dist/esm/common/enum.mjs +7 -6
  52. package/dist/esm/common/enum.mjs.map +1 -1
  53. package/dist/esm/events.mjs +7 -5
  54. package/dist/esm/events.mjs.map +1 -1
  55. package/dist/esm/graphs/Graph.mjs +330 -209
  56. package/dist/esm/graphs/Graph.mjs.map +1 -1
  57. package/dist/esm/graphs/MultiAgentGraph.mjs +505 -0
  58. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -0
  59. package/dist/esm/llm/anthropic/index.mjs.map +1 -1
  60. package/dist/esm/llm/google/index.mjs.map +1 -1
  61. package/dist/esm/llm/ollama/index.mjs.map +1 -1
  62. package/dist/esm/llm/openai/index.mjs +35 -0
  63. package/dist/esm/llm/openai/index.mjs.map +1 -1
  64. package/dist/esm/llm/openai/utils/index.mjs +3 -1
  65. package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
  66. package/dist/esm/llm/openrouter/index.mjs.map +1 -1
  67. package/dist/esm/llm/providers.mjs +0 -2
  68. package/dist/esm/llm/providers.mjs.map +1 -1
  69. package/dist/esm/llm/vertexai/index.mjs.map +1 -1
  70. package/dist/esm/main.mjs +7 -2
  71. package/dist/esm/main.mjs.map +1 -1
  72. package/dist/esm/messages/cache.mjs +120 -0
  73. package/dist/esm/messages/cache.mjs.map +1 -0
  74. package/dist/esm/messages/content.mjs +51 -0
  75. package/dist/esm/messages/content.mjs.map +1 -0
  76. package/dist/esm/messages/format.mjs +18 -29
  77. package/dist/esm/messages/format.mjs.map +1 -1
  78. package/dist/esm/run.mjs +119 -74
  79. package/dist/esm/run.mjs.map +1 -1
  80. package/dist/esm/stream.mjs +77 -73
  81. package/dist/esm/stream.mjs.map +1 -1
  82. package/dist/esm/tools/Calculator.mjs +24 -0
  83. package/dist/esm/tools/Calculator.mjs.map +1 -0
  84. package/dist/esm/tools/CodeExecutor.mjs +22 -22
  85. package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
  86. package/dist/esm/tools/ToolNode.mjs +5 -3
  87. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  88. package/dist/esm/tools/handlers.mjs +20 -20
  89. package/dist/esm/tools/handlers.mjs.map +1 -1
  90. package/dist/esm/utils/events.mjs +29 -0
  91. package/dist/esm/utils/events.mjs.map +1 -0
  92. package/dist/esm/utils/handlers.mjs +68 -0
  93. package/dist/esm/utils/handlers.mjs.map +1 -0
  94. package/dist/esm/utils/tokens.mjs +54 -8
  95. package/dist/esm/utils/tokens.mjs.map +1 -1
  96. package/dist/types/agents/AgentContext.d.ts +94 -0
  97. package/dist/types/common/enum.d.ts +9 -7
  98. package/dist/types/events.d.ts +3 -3
  99. package/dist/types/graphs/Graph.d.ts +60 -66
  100. package/dist/types/graphs/MultiAgentGraph.d.ts +47 -0
  101. package/dist/types/graphs/index.d.ts +1 -0
  102. package/dist/types/index.d.ts +1 -0
  103. package/dist/types/llm/openai/index.d.ts +10 -0
  104. package/dist/types/messages/cache.d.ts +20 -0
  105. package/dist/types/messages/content.d.ts +7 -0
  106. package/dist/types/messages/format.d.ts +1 -7
  107. package/dist/types/messages/index.d.ts +2 -0
  108. package/dist/types/messages/reducer.d.ts +9 -0
  109. package/dist/types/run.d.ts +16 -10
  110. package/dist/types/stream.d.ts +4 -3
  111. package/dist/types/tools/Calculator.d.ts +8 -0
  112. package/dist/types/tools/ToolNode.d.ts +1 -1
  113. package/dist/types/tools/handlers.d.ts +9 -7
  114. package/dist/types/tools/search/tool.d.ts +4 -4
  115. package/dist/types/types/graph.d.ts +124 -11
  116. package/dist/types/types/llm.d.ts +13 -9
  117. package/dist/types/types/messages.d.ts +4 -0
  118. package/dist/types/types/run.d.ts +46 -8
  119. package/dist/types/types/stream.d.ts +3 -2
  120. package/dist/types/utils/events.d.ts +6 -0
  121. package/dist/types/utils/handlers.d.ts +34 -0
  122. package/dist/types/utils/index.d.ts +1 -0
  123. package/dist/types/utils/tokens.d.ts +24 -0
  124. package/package.json +162 -145
  125. package/src/agents/AgentContext.ts +323 -0
  126. package/src/common/enum.ts +177 -176
  127. package/src/events.ts +197 -191
  128. package/src/graphs/Graph.ts +1058 -846
  129. package/src/graphs/MultiAgentGraph.ts +598 -0
  130. package/src/graphs/index.ts +2 -1
  131. package/src/index.ts +25 -24
  132. package/src/llm/anthropic/index.ts +413 -413
  133. package/src/llm/google/index.ts +222 -222
  134. package/src/llm/google/utils/zod_to_genai_parameters.ts +86 -88
  135. package/src/llm/ollama/index.ts +92 -92
  136. package/src/llm/openai/index.ts +894 -853
  137. package/src/llm/openai/utils/index.ts +920 -918
  138. package/src/llm/openrouter/index.ts +60 -60
  139. package/src/llm/providers.ts +55 -57
  140. package/src/llm/vertexai/index.ts +360 -360
  141. package/src/messages/cache.test.ts +461 -0
  142. package/src/messages/cache.ts +151 -0
  143. package/src/messages/content.test.ts +362 -0
  144. package/src/messages/content.ts +63 -0
  145. package/src/messages/format.ts +611 -625
  146. package/src/messages/formatAgentMessages.test.ts +1144 -917
  147. package/src/messages/index.ts +6 -4
  148. package/src/messages/reducer.ts +80 -0
  149. package/src/run.ts +447 -381
  150. package/src/scripts/abort.ts +157 -138
  151. package/src/scripts/ant_web_search.ts +158 -158
  152. package/src/scripts/cli.ts +172 -167
  153. package/src/scripts/cli2.ts +133 -125
  154. package/src/scripts/cli3.ts +184 -178
  155. package/src/scripts/cli4.ts +191 -184
  156. package/src/scripts/cli5.ts +191 -184
  157. package/src/scripts/code_exec.ts +213 -214
  158. package/src/scripts/code_exec_simple.ts +147 -129
  159. package/src/scripts/content.ts +138 -120
  160. package/src/scripts/handoff-test.ts +135 -0
  161. package/src/scripts/multi-agent-chain.ts +278 -0
  162. package/src/scripts/multi-agent-conditional.ts +220 -0
  163. package/src/scripts/multi-agent-document-review-chain.ts +197 -0
  164. package/src/scripts/multi-agent-hybrid-flow.ts +310 -0
  165. package/src/scripts/multi-agent-parallel.ts +343 -0
  166. package/src/scripts/multi-agent-sequence.ts +212 -0
  167. package/src/scripts/multi-agent-supervisor.ts +364 -0
  168. package/src/scripts/multi-agent-test.ts +186 -0
  169. package/src/scripts/search.ts +146 -150
  170. package/src/scripts/simple.ts +225 -225
  171. package/src/scripts/stream.ts +140 -122
  172. package/src/scripts/test-custom-prompt-key.ts +145 -0
  173. package/src/scripts/test-handoff-input.ts +170 -0
  174. package/src/scripts/test-multi-agent-list-handoff.ts +261 -0
  175. package/src/scripts/test-tools-before-handoff.ts +222 -0
  176. package/src/scripts/tools.ts +153 -155
  177. package/src/specs/agent-handoffs.test.ts +889 -0
  178. package/src/specs/anthropic.simple.test.ts +320 -317
  179. package/src/specs/azure.simple.test.ts +325 -316
  180. package/src/specs/openai.simple.test.ts +311 -316
  181. package/src/specs/openrouter.simple.test.ts +107 -0
  182. package/src/specs/prune.test.ts +758 -763
  183. package/src/specs/reasoning.test.ts +201 -165
  184. package/src/specs/thinking-prune.test.ts +769 -703
  185. package/src/specs/token-memoization.test.ts +39 -0
  186. package/src/stream.ts +664 -651
  187. package/src/tools/Calculator.test.ts +278 -0
  188. package/src/tools/Calculator.ts +25 -0
  189. package/src/tools/CodeExecutor.ts +220 -220
  190. package/src/tools/ToolNode.ts +170 -170
  191. package/src/tools/handlers.ts +341 -336
  192. package/src/types/graph.ts +372 -185
  193. package/src/types/llm.ts +141 -140
  194. package/src/types/messages.ts +4 -0
  195. package/src/types/run.ts +128 -89
  196. package/src/types/stream.ts +401 -400
  197. package/src/utils/events.ts +32 -0
  198. package/src/utils/handlers.ts +107 -0
  199. package/src/utils/index.ts +6 -5
  200. package/src/utils/llmConfig.ts +183 -183
  201. package/src/utils/tokens.ts +129 -70
  202. package/dist/types/scripts/abort.d.ts +0 -1
  203. package/dist/types/scripts/ant_web_search.d.ts +0 -1
  204. package/dist/types/scripts/args.d.ts +0 -7
  205. package/dist/types/scripts/caching.d.ts +0 -1
  206. package/dist/types/scripts/cli.d.ts +0 -1
  207. package/dist/types/scripts/cli2.d.ts +0 -1
  208. package/dist/types/scripts/cli3.d.ts +0 -1
  209. package/dist/types/scripts/cli4.d.ts +0 -1
  210. package/dist/types/scripts/cli5.d.ts +0 -1
  211. package/dist/types/scripts/code_exec.d.ts +0 -1
  212. package/dist/types/scripts/code_exec_files.d.ts +0 -1
  213. package/dist/types/scripts/code_exec_simple.d.ts +0 -1
  214. package/dist/types/scripts/content.d.ts +0 -1
  215. package/dist/types/scripts/empty_input.d.ts +0 -1
  216. package/dist/types/scripts/image.d.ts +0 -1
  217. package/dist/types/scripts/memory.d.ts +0 -1
  218. package/dist/types/scripts/search.d.ts +0 -1
  219. package/dist/types/scripts/simple.d.ts +0 -1
  220. package/dist/types/scripts/stream.d.ts +0 -1
  221. package/dist/types/scripts/thinking.d.ts +0 -1
  222. package/dist/types/scripts/tools.d.ts +0 -1
  223. package/dist/types/specs/spec.utils.d.ts +0 -1
  224. package/dist/types/tools/example.d.ts +0 -78
  225. package/src/tools/example.ts +0 -129
@@ -0,0 +1,94 @@
1
+ import { SystemMessage } from '@langchain/core/messages';
2
+ import type { UsageMetadata, BaseMessage } from '@langchain/core/messages';
3
+ import type { RunnableConfig, Runnable } from '@langchain/core/runnables';
4
+ import type * as t from '@/types';
5
+ import type { createPruneMessages } from '@/messages';
6
+ import { ContentTypes, Providers } from '@/common';
7
+ /**
8
+ * Encapsulates agent-specific state that can vary between agents in a multi-agent system
9
+ */
10
+ export declare class AgentContext {
11
+ /**
12
+ * Create an AgentContext from configuration with token accounting initialization
13
+ */
14
+ static fromConfig(agentConfig: t.AgentInputs, tokenCounter?: t.TokenCounter, indexTokenCountMap?: Record<string, number>): AgentContext;
15
+ /** Agent identifier */
16
+ agentId: string;
17
+ /** Provider for this specific agent */
18
+ provider: Providers;
19
+ /** Client options for this agent */
20
+ clientOptions?: t.ClientOptions;
21
+ /** Token count map indexed by message position */
22
+ indexTokenCountMap: Record<string, number | undefined>;
23
+ /** Maximum context tokens for this agent */
24
+ maxContextTokens?: number;
25
+ /** Current usage metadata for this agent */
26
+ currentUsage?: Partial<UsageMetadata>;
27
+ /** Prune messages function configured for this agent */
28
+ pruneMessages?: ReturnType<typeof createPruneMessages>;
29
+ /** Token counter function for this agent */
30
+ tokenCounter?: t.TokenCounter;
31
+ /** Instructions/system message token count */
32
+ instructionTokens: number;
33
+ /** The amount of time that should pass before another consecutive API call */
34
+ streamBuffer?: number;
35
+ /** Last stream call timestamp for rate limiting */
36
+ lastStreamCall?: number;
37
+ /** Tools available to this agent */
38
+ tools?: t.GraphTools;
39
+ /** Tool map for this agent */
40
+ toolMap?: t.ToolMap;
41
+ /** Instructions for this agent */
42
+ instructions?: string;
43
+ /** Additional instructions for this agent */
44
+ additionalInstructions?: string;
45
+ /** Reasoning key for this agent */
46
+ reasoningKey: 'reasoning_content' | 'reasoning';
47
+ /** Last token for reasoning detection */
48
+ lastToken?: string;
49
+ /** Token type switch state */
50
+ tokenTypeSwitch?: 'reasoning' | 'content';
51
+ /** Current token type being processed */
52
+ currentTokenType: ContentTypes.TEXT | ContentTypes.THINK | 'think_and_text';
53
+ /** Whether tools should end the workflow */
54
+ toolEnd: boolean;
55
+ /** System runnable for this agent */
56
+ systemRunnable?: Runnable<BaseMessage[], (BaseMessage | SystemMessage)[], RunnableConfig<Record<string, unknown>>>;
57
+ /** Promise for token calculation initialization */
58
+ tokenCalculationPromise?: Promise<void>;
59
+ /** Format content blocks as strings (for legacy compatibility) */
60
+ useLegacyContent: boolean;
61
+ constructor({ agentId, provider, clientOptions, maxContextTokens, streamBuffer, tokenCounter, tools, toolMap, instructions, additionalInstructions, reasoningKey, toolEnd, instructionTokens, useLegacyContent, }: {
62
+ agentId: string;
63
+ provider: Providers;
64
+ clientOptions?: t.ClientOptions;
65
+ maxContextTokens?: number;
66
+ streamBuffer?: number;
67
+ tokenCounter?: t.TokenCounter;
68
+ tools?: t.GraphTools;
69
+ toolMap?: t.ToolMap;
70
+ instructions?: string;
71
+ additionalInstructions?: string;
72
+ reasoningKey?: 'reasoning_content' | 'reasoning';
73
+ toolEnd?: boolean;
74
+ instructionTokens?: number;
75
+ useLegacyContent?: boolean;
76
+ });
77
+ /**
78
+ * Create system runnable from instructions and calculate tokens if tokenCounter is available
79
+ */
80
+ private createSystemRunnable;
81
+ /**
82
+ * Reset context for a new run
83
+ */
84
+ reset(): void;
85
+ /**
86
+ * Update the token count map with instruction tokens
87
+ */
88
+ updateTokenMapWithInstructions(baseTokenMap: Record<string, number>): void;
89
+ /**
90
+ * Calculate tool tokens and add to instruction tokens
91
+ * Note: System message tokens are calculated during systemRunnable creation
92
+ */
93
+ calculateInstructionTokens(tokenCounter: t.TokenCounter): Promise<void>;
94
+ }
@@ -52,7 +52,6 @@ export declare enum GraphEvents {
52
52
  }
53
53
  export declare enum Providers {
54
54
  OPENAI = "openAI",
55
- BEDROCK_LEGACY = "bedrock_legacy",
56
55
  VERTEXAI = "vertexai",
57
56
  BEDROCK = "bedrock",
58
57
  ANTHROPIC = "anthropic",
@@ -66,8 +65,9 @@ export declare enum Providers {
66
65
  XAI = "xai"
67
66
  }
68
67
  export declare enum GraphNodeKeys {
69
- TOOLS = "tools",
70
- AGENT = "agent",
68
+ TOOLS = "tools=",
69
+ AGENT = "agent=",
70
+ ROUTER = "router",
71
71
  PRE_TOOLS = "pre_tools",
72
72
  POST_TOOLS = "post_tools"
73
73
  }
@@ -109,13 +109,15 @@ export declare enum ToolCallTypes {
109
109
  export declare enum Callback {
110
110
  TOOL_ERROR = "handleToolError",
111
111
  TOOL_START = "handleToolStart",
112
- TOOL_END = "handleToolEnd"
112
+ TOOL_END = "handleToolEnd",
113
+ CUSTOM_EVENT = "handleCustomEvent"
113
114
  }
114
115
  export declare enum Constants {
115
116
  OFFICIAL_CODE_BASEURL = "https://api.illuma.ai/v1",
116
117
  EXECUTE_CODE = "execute_code",
117
118
  WEB_SEARCH = "web_search",
118
- CONTENT_AND_ARTIFACT = "content_and_artifact"
119
+ CONTENT_AND_ARTIFACT = "content_and_artifact",
120
+ LC_TRANSFER_TO_ = "lc_transfer_to_"
119
121
  }
120
122
  export declare enum TitleMethod {
121
123
  STRUCTURED = "structured",
@@ -123,6 +125,6 @@ export declare enum TitleMethod {
123
125
  COMPLETION = "completion"
124
126
  }
125
127
  export declare enum EnvVar {
126
- CODE_API_KEY = "CODE_EXECUTOR_API_KEY",
127
- CODE_BASEURL = "CODE_EXECUTOR_API_BASEURL"
128
+ CODE_API_KEY = "ILLUMA_CODE_API_KEY",
129
+ CODE_BASEURL = "ILLUMA_CODE_BASEURL"
128
130
  }
@@ -1,5 +1,5 @@
1
1
  import type { UsageMetadata, BaseMessageFields } from '@langchain/core/messages';
2
- import type { Graph } from '@/graphs';
2
+ import type { MultiAgentGraph, StandardGraph } from '@/graphs';
3
3
  import type * as t from '@/types';
4
4
  export declare class HandlerRegistry {
5
5
  private handlers;
@@ -9,13 +9,13 @@ export declare class HandlerRegistry {
9
9
  export declare class ModelEndHandler implements t.EventHandler {
10
10
  collectedUsage?: UsageMetadata[];
11
11
  constructor(collectedUsage?: UsageMetadata[]);
12
- handle(event: string, data: t.ModelEndData, metadata?: Record<string, unknown>, graph?: Graph): void;
12
+ handle(event: string, data: t.ModelEndData, metadata?: Record<string, unknown>, graph?: StandardGraph | MultiAgentGraph): Promise<void>;
13
13
  }
14
14
  export declare class ToolEndHandler implements t.EventHandler {
15
15
  private callback?;
16
16
  private omitOutput?;
17
17
  constructor(callback?: t.ToolEndCallback, omitOutput?: (name?: string) => boolean);
18
- handle(event: string, data: t.StreamEventData | undefined, metadata?: Record<string, unknown>, graph?: Graph): void;
18
+ handle(event: string, data: t.StreamEventData | undefined, metadata?: Record<string, unknown>, graph?: StandardGraph | MultiAgentGraph): Promise<void>;
19
19
  }
20
20
  export declare class TestLLMStreamHandler implements t.EventHandler {
21
21
  handle(event: string, data: t.StreamEventData | undefined): void;
@@ -1,29 +1,23 @@
1
1
  import { ToolNode } from '@langchain/langgraph/prebuilt';
2
- import { START } from '@langchain/langgraph';
3
2
  import { Runnable, RunnableConfig } from '@langchain/core/runnables';
4
- import { SystemMessage } from '@langchain/core/messages';
5
- import type { BaseMessage, UsageMetadata } from '@langchain/core/messages';
6
- import type * as t from '@/types';
7
- import { Providers, GraphNodeKeys, Callback, ContentTypes } from '@/common';
3
+ import type { UsageMetadata, BaseMessage } from '@langchain/core/messages';
8
4
  import type { ToolCall } from '@langchain/core/messages/tool';
5
+ import type * as t from '@/types';
6
+ import { Providers } from '@/common';
9
7
  import { ToolNode as CustomToolNode } from '@/tools/ToolNode';
10
- import { createPruneMessages } from '@/messages';
8
+ import { AgentContext } from '@/agents/AgentContext';
11
9
  import { HandlerRegistry } from '@/events';
12
- export type GraphNode = GraphNodeKeys | typeof START;
13
- export type ClientCallback<T extends unknown[]> = (graph: StandardGraph, ...args: T) => void;
14
- export type ClientCallbacks = {
15
- [Callback.TOOL_ERROR]?: ClientCallback<[Error, string]>;
16
- [Callback.TOOL_START]?: ClientCallback<unknown[]>;
17
- [Callback.TOOL_END]?: ClientCallback<unknown[]>;
18
- };
19
- export type SystemCallbacks = {
20
- [K in keyof ClientCallbacks]: ClientCallbacks[K] extends ClientCallback<infer Args> ? (...args: Args) => void : never;
21
- };
22
- export declare abstract class Graph<T extends t.BaseGraphState = t.BaseGraphState, TNodeName extends string = string> {
10
+ export declare abstract class Graph<T extends t.BaseGraphState = t.BaseGraphState, _TNodeName extends string = string> {
23
11
  abstract resetValues(): void;
24
- abstract createGraphState(): t.GraphStateChannels<T>;
25
- abstract initializeTools(): CustomToolNode<T> | ToolNode<T>;
26
- abstract initializeModel(): Runnable;
12
+ abstract initializeTools({ currentTools, currentToolMap, }: {
13
+ currentTools?: t.GraphTools;
14
+ currentToolMap?: t.ToolMap;
15
+ }): CustomToolNode<T> | ToolNode<T>;
16
+ abstract initializeModel({ currentModel, tools, clientOptions, }: {
17
+ currentModel?: t.ChatModel;
18
+ tools?: t.GraphTools;
19
+ clientOptions?: t.ClientOptions;
20
+ }): Runnable;
27
21
  abstract getRunMessages(): BaseMessage[] | undefined;
28
22
  abstract getContentParts(): t.MessageContentComplex[] | undefined;
29
23
  abstract generateStepId(stepKey: string): [string, number];
@@ -32,17 +26,12 @@ export declare abstract class Graph<T extends t.BaseGraphState = t.BaseGraphStat
32
26
  abstract checkKeyList(keyList: (string | number | undefined)[]): boolean;
33
27
  abstract getStepIdByKey(stepKey: string, index?: number): string;
34
28
  abstract getRunStep(stepId: string): t.RunStep | undefined;
35
- abstract dispatchRunStep(stepKey: string, stepDetails: t.StepDetails): string;
36
- abstract dispatchRunStepDelta(id: string, delta: t.ToolCallDelta): void;
37
- abstract dispatchMessageDelta(id: string, delta: t.MessageDelta): void;
38
- abstract dispatchReasoningDelta(stepId: string, delta: t.ReasoningDelta): void;
39
- abstract handleToolCallCompleted(data: t.ToolEndData, metadata?: Record<string, unknown>, omitOutput?: boolean): void;
40
- abstract createCallModel(): (state: T, config?: RunnableConfig) => Promise<Partial<T>>;
41
- abstract createWorkflow(): t.CompiledWorkflow<T>;
42
- lastToken?: string;
43
- tokenTypeSwitch?: 'reasoning' | 'content';
44
- reasoningKey: 'reasoning_content' | 'reasoning';
45
- currentTokenType: ContentTypes.TEXT | ContentTypes.THINK | 'think_and_text';
29
+ abstract dispatchRunStep(stepKey: string, stepDetails: t.StepDetails): Promise<string>;
30
+ abstract dispatchRunStepDelta(id: string, delta: t.ToolCallDelta): Promise<void>;
31
+ abstract dispatchMessageDelta(id: string, delta: t.MessageDelta): Promise<void>;
32
+ abstract dispatchReasoningDelta(stepId: string, delta: t.ReasoningDelta): Promise<void>;
33
+ abstract handleToolCallCompleted(data: t.ToolEndData, metadata?: Record<string, unknown>, omitOutput?: boolean): Promise<void>;
34
+ abstract createCallModel(agentId?: string, currentModel?: t.ChatModel): (state: T, config?: RunnableConfig) => Promise<Partial<T>>;
46
35
  messageStepHasToolCalls: Map<string, boolean>;
47
36
  messageIdsByStepKey: Map<string, string>;
48
37
  prelimMessageIdsByStepKey: Map<string, string>;
@@ -51,36 +40,27 @@ export declare abstract class Graph<T extends t.BaseGraphState = t.BaseGraphStat
51
40
  stepKeyIds: Map<string, string[]>;
52
41
  contentIndexMap: Map<string, number>;
53
42
  toolCallStepIds: Map<string, string>;
54
- currentUsage: Partial<UsageMetadata> | undefined;
55
- indexTokenCountMap: Record<string, number | undefined>;
56
- maxContextTokens: number | undefined;
57
- pruneMessages?: ReturnType<typeof createPruneMessages>;
58
- /** The amount of time that should pass before another consecutive API call */
59
- streamBuffer: number | undefined;
60
- tokenCounter?: t.TokenCounter;
61
43
  signal?: AbortSignal;
62
44
  /** Set of invoked tool call IDs from non-message run steps completed mid-run, if any */
63
45
  invokedToolIds?: Set<string>;
64
46
  handlerRegistry: HandlerRegistry | undefined;
65
47
  }
66
- export declare class StandardGraph extends Graph<t.BaseGraphState, GraphNode> {
67
- private graphState;
68
- clientOptions: t.ClientOptions;
69
- boundModel?: Runnable;
70
- /** The last recorded timestamp that a stream API call was invoked */
71
- lastStreamCall: number | undefined;
72
- systemMessage: SystemMessage | undefined;
48
+ export declare class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
49
+ overrideModel?: t.ChatModel;
50
+ /** Optional compile options passed into workflow.compile() */
51
+ compileOptions?: t.CompileOptions | undefined;
73
52
  messages: BaseMessage[];
74
53
  runId: string | undefined;
75
- tools?: t.GraphTools;
76
- toolMap?: t.ToolMap;
77
54
  startIndex: number;
78
- provider: Providers;
79
- toolEnd: boolean;
80
55
  signal?: AbortSignal;
81
- constructor({ runId, tools, signal, toolMap, provider, streamBuffer, instructions, reasoningKey, clientOptions, toolEnd, additional_instructions, }: t.StandardGraphInput);
56
+ /** Map of agent contexts by agent ID */
57
+ agentContexts: Map<string, AgentContext>;
58
+ /** Default agent ID to use */
59
+ defaultAgentId: string;
60
+ constructor({ runId, signal, agents, tokenCounter, indexTokenCountMap, }: t.StandardGraphInput);
82
61
  resetValues(keepContent?: boolean): void;
83
62
  getRunStep(stepId: string): t.RunStep | undefined;
63
+ getAgentContext(metadata: Record<string, unknown> | undefined): AgentContext;
84
64
  getStepKey(metadata: Record<string, unknown> | undefined): string;
85
65
  getStepIdByKey(stepKey: string, index?: number): string;
86
66
  generateStepId(stepKey: string): [string, number];
@@ -88,35 +68,49 @@ export declare class StandardGraph extends Graph<t.BaseGraphState, GraphNode> {
88
68
  checkKeyList(keyList: (string | number | undefined)[]): boolean;
89
69
  getRunMessages(): BaseMessage[] | undefined;
90
70
  getContentParts(): t.MessageContentComplex[] | undefined;
91
- createGraphState(): t.GraphStateChannels<t.BaseGraphState>;
92
- initializeTools(): CustomToolNode<t.BaseGraphState> | ToolNode<t.BaseGraphState>;
93
- initializeModel(): Runnable;
71
+ createSystemRunnable({ provider, clientOptions, instructions, additional_instructions, }: {
72
+ provider?: Providers;
73
+ clientOptions?: t.ClientOptions;
74
+ instructions?: string;
75
+ additional_instructions?: string;
76
+ }): t.SystemRunnable | undefined;
77
+ initializeTools({ currentTools, currentToolMap, }: {
78
+ currentTools?: t.GraphTools;
79
+ currentToolMap?: t.ToolMap;
80
+ }): CustomToolNode<t.BaseGraphState> | ToolNode<t.BaseGraphState>;
81
+ initializeModel({ provider, tools, clientOptions, }: {
82
+ provider: Providers;
83
+ tools?: t.GraphTools;
84
+ clientOptions?: t.ClientOptions;
85
+ }): Runnable;
94
86
  overrideTestModel(responses: string[], sleep?: number, toolCalls?: ToolCall[]): void;
95
- getNewModel({ provider, clientOptions, omitOptions, }: {
87
+ getNewModel({ provider, clientOptions, }: {
96
88
  provider: Providers;
97
89
  clientOptions?: t.ClientOptions;
98
- omitOptions?: Set<string>;
99
90
  }): t.ChatModelInstance;
100
- storeUsageMetadata(finalMessage?: BaseMessage): void;
101
- cleanupSignalListener(): void;
102
- createCallModel(): (state: t.BaseGraphState, config?: RunnableConfig) => Promise<Partial<t.BaseGraphState>>;
103
- createWorkflow(): t.CompiledWorkflow<t.BaseGraphState>;
91
+ getUsageMetadata(finalMessage?: BaseMessage): Partial<UsageMetadata> | undefined;
92
+ /** Execute model invocation with streaming support */
93
+ private attemptInvoke;
94
+ cleanupSignalListener(currentModel?: t.ChatModel): void;
95
+ createCallModel(agentId?: string, currentModel?: t.ChatModel): (state: t.BaseGraphState, config?: RunnableConfig) => Promise<Partial<t.BaseGraphState>>;
96
+ createAgentNode(agentId: string): t.CompiledAgentWorfklow;
97
+ createWorkflow(): t.CompiledStateWorkflow;
104
98
  /**
105
99
  * Dispatches a run step to the client, returns the step ID
106
100
  */
107
- dispatchRunStep(stepKey: string, stepDetails: t.StepDetails): string;
108
- handleToolCallCompleted(data: t.ToolEndData, metadata?: Record<string, unknown>, omitOutput?: boolean): void;
101
+ dispatchRunStep(stepKey: string, stepDetails: t.StepDetails): Promise<string>;
102
+ handleToolCallCompleted(data: t.ToolEndData, metadata?: Record<string, unknown>, omitOutput?: boolean): Promise<void>;
109
103
  /**
110
104
  * Static version of handleToolCallError to avoid creating strong references
111
105
  * that prevent garbage collection
112
106
  */
113
- static handleToolCallErrorStatic(graph: StandardGraph, data: t.ToolErrorData, metadata?: Record<string, unknown>): void;
107
+ static handleToolCallErrorStatic(graph: StandardGraph, data: t.ToolErrorData, metadata?: Record<string, unknown>): Promise<void>;
114
108
  /**
115
109
  * Instance method that delegates to the static method
116
110
  * Kept for backward compatibility
117
111
  */
118
- handleToolCallError(data: t.ToolErrorData, metadata?: Record<string, unknown>): void;
119
- dispatchRunStepDelta(id: string, delta: t.ToolCallDelta): void;
120
- dispatchMessageDelta(id: string, delta: t.MessageDelta): void;
121
- dispatchReasoningDelta: (stepId: string, delta: t.ReasoningDelta) => void;
112
+ handleToolCallError(data: t.ToolErrorData, metadata?: Record<string, unknown>): Promise<void>;
113
+ dispatchRunStepDelta(id: string, delta: t.ToolCallDelta): Promise<void>;
114
+ dispatchMessageDelta(id: string, delta: t.MessageDelta): Promise<void>;
115
+ dispatchReasoningDelta: (stepId: string, delta: t.ReasoningDelta) => Promise<void>;
122
116
  }
@@ -0,0 +1,47 @@
1
+ import type * as t from '@/types';
2
+ import { StandardGraph } from './Graph';
3
+ /**
4
+ * MultiAgentGraph extends StandardGraph to support dynamic multi-agent workflows
5
+ * with handoffs, fan-in/fan-out, and other composable patterns.
6
+ *
7
+ * Key behavior:
8
+ * - Agents with ONLY handoff edges: Can dynamically route to any handoff destination
9
+ * - Agents with ONLY direct edges: Always follow their direct edges
10
+ * - Agents with BOTH: Use Command for exclusive routing (handoff OR direct, not both)
11
+ * - If handoff occurs: Only the handoff destination executes
12
+ * - If no handoff: Direct edges execute (potentially in parallel)
13
+ *
14
+ * This enables the common pattern where an agent either delegates (handoff)
15
+ * OR continues its workflow (direct edges), but not both simultaneously.
16
+ */
17
+ export declare class MultiAgentGraph extends StandardGraph {
18
+ private edges;
19
+ private startingNodes;
20
+ private directEdges;
21
+ private handoffEdges;
22
+ constructor(input: t.MultiAgentGraphInput);
23
+ /**
24
+ * Categorize edges into handoff and direct types
25
+ */
26
+ private categorizeEdges;
27
+ /**
28
+ * Analyze graph structure to determine starting nodes and connections
29
+ */
30
+ private analyzeGraph;
31
+ /**
32
+ * Create handoff tools for agents based on handoff edges only
33
+ */
34
+ private createHandoffTools;
35
+ /**
36
+ * Create handoff tools for an edge (handles multiple destinations)
37
+ */
38
+ private createHandoffToolsForEdge;
39
+ /**
40
+ * Create a complete agent subgraph (similar to createReactAgent)
41
+ */
42
+ private createAgentSubgraph;
43
+ /**
44
+ * Create the multi-agent workflow with dynamic handoffs
45
+ */
46
+ createWorkflow(): t.CompiledMultiAgentWorkflow;
47
+ }
@@ -1 +1,2 @@
1
1
  export * from './Graph';
2
+ export * from './MultiAgentGraph';
@@ -4,6 +4,7 @@ export * from './splitStream';
4
4
  export * from './events';
5
5
  export * from './messages';
6
6
  export * from './graphs';
7
+ export * from './tools/Calculator';
7
8
  export * from './tools/CodeExecutor';
8
9
  export * from './tools/handlers';
9
10
  export * from './tools/search';
@@ -40,6 +40,10 @@ export declare class CustomAzureOpenAIClient extends AzureOpenAIClient {
40
40
  }
41
41
  /** @ts-expect-error We are intentionally overriding `getReasoningParams` */
42
42
  export declare class ChatOpenAI extends OriginalChatOpenAI<t.ChatOpenAICallOptions> {
43
+ _lc_stream_delay?: number;
44
+ constructor(fields?: t.ChatOpenAICallOptions & {
45
+ _lc_stream_delay?: number;
46
+ } & t.OpenAIChatInput['modelKwargs']);
43
47
  get exposedClient(): CustomOpenAIClient;
44
48
  static lc_name(): string;
45
49
  protected _getClientOptions(options?: OpenAICoreRequestOptions): OpenAICoreRequestOptions;
@@ -54,6 +58,10 @@ export declare class ChatOpenAI extends OriginalChatOpenAI<t.ChatOpenAICallOptio
54
58
  }
55
59
  /** @ts-expect-error We are intentionally overriding `getReasoningParams` */
56
60
  export declare class AzureChatOpenAI extends OriginalAzureChatOpenAI {
61
+ _lc_stream_delay?: number;
62
+ constructor(fields?: t.AzureOpenAIInput & {
63
+ _lc_stream_delay?: number;
64
+ });
57
65
  get exposedClient(): CustomOpenAIClient;
58
66
  static lc_name(): 'IllumaAzureOpenAI';
59
67
  /**
@@ -87,6 +95,7 @@ export interface XAIUsageMetadata extends OpenAIClient.Completions.CompletionUsa
87
95
  num_sources_used?: number;
88
96
  }
89
97
  export declare class ChatXAI extends OriginalChatXAI {
98
+ _lc_stream_delay?: number;
90
99
  constructor(fields?: Partial<ChatXAIInput> & {
91
100
  configuration?: {
92
101
  baseURL?: string;
@@ -94,6 +103,7 @@ export declare class ChatXAI extends OriginalChatXAI {
94
103
  clientConfig?: {
95
104
  baseURL?: string;
96
105
  };
106
+ _lc_stream_delay?: number;
97
107
  });
98
108
  static lc_name(): 'IllumaXAI';
99
109
  get exposedClient(): CustomOpenAIClient;
@@ -0,0 +1,20 @@
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
+ * @param messages - The array of message objects.
9
+ * @returns - The updated array of message objects with cache control added.
10
+ */
11
+ export declare function addCacheControl<T extends AnthropicMessage | BaseMessage>(messages: T[]): T[];
12
+ /**
13
+ * Adds Bedrock Converse API cache points to the last two messages.
14
+ * Inserts `{ cachePoint: { type: 'default' } }` as a separate content block
15
+ * immediately after the last text block in each targeted message.
16
+ * @param messages - The array of message objects.
17
+ * @returns - The updated array of message objects with cache points added.
18
+ */
19
+ export declare function addBedrockCacheControl<T extends Partial<BaseMessage> & MessageWithContent>(messages: T[]): T[];
20
+ 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>;
@@ -1,4 +1,4 @@
1
- import { AIMessage, ToolMessage, BaseMessage, HumanMessage, SystemMessage } from '@langchain/core/messages';
1
+ import { AIMessage, ToolMessage, HumanMessage, SystemMessage } from '@langchain/core/messages';
2
2
  import type { MessageContentImageUrl } from '@langchain/core/messages';
3
3
  import type { MessageContentComplex, TPayload } from '@/types';
4
4
  import { Providers } from '@/common';
@@ -95,12 +95,6 @@ export declare const formatAgentMessages: (payload: TPayload, indexTokenCountMap
95
95
  messages: Array<HumanMessage | AIMessage | SystemMessage | ToolMessage>;
96
96
  indexTokenCountMap?: Record<number, number>;
97
97
  };
98
- /**
99
- * Formats an array of messages for LangChain, making sure all content fields are strings
100
- * @param payload - The array of messages to format.
101
- * @returns - The array of formatted LangChain messages, including ToolMessages for tool calls.
102
- */
103
- export declare const formatContentStrings: (payload: Array<BaseMessage>) => Array<BaseMessage>;
104
98
  /**
105
99
  * Adds a value at key 0 for system messages and shifts all key indices by one in an indexTokenCountMap.
106
100
  * This is useful when adding a system message at the beginning of a conversation.
@@ -2,3 +2,5 @@ export * from './core';
2
2
  export * from './ids';
3
3
  export * from './prune';
4
4
  export * from './format';
5
+ export * from './cache';
6
+ export * from './content';
@@ -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[];
@@ -1,29 +1,35 @@
1
1
  import './instrumentation';
2
2
  import type { MessageContentComplex, BaseMessage } from '@langchain/core/messages';
3
3
  import type { RunnableConfig } from '@langchain/core/runnables';
4
- import type { ClientCallbacks, SystemCallbacks } from '@/graphs/Graph';
5
4
  import type * as t from '@/types';
6
- import { Providers } from '@/common';
5
+ import { MultiAgentGraph } from '@/graphs/MultiAgentGraph';
7
6
  import { StandardGraph } from '@/graphs/Graph';
8
7
  export declare const defaultOmitOptions: Set<string>;
9
- export declare class Run<T extends t.BaseGraphState> {
10
- graphRunnable?: t.CompiledWorkflow<T, Partial<T>, string>;
11
- private handlerRegistry;
8
+ export declare class Run<_T extends t.BaseGraphState> {
12
9
  id: string;
13
- Graph: StandardGraph | undefined;
14
- provider: Providers | undefined;
10
+ private tokenCounter?;
11
+ private handlerRegistry?;
12
+ private indexTokenCountMap?;
13
+ graphRunnable?: t.CompiledStateWorkflow;
14
+ Graph: StandardGraph | MultiAgentGraph | undefined;
15
15
  returnContent: boolean;
16
16
  private constructor();
17
- private createStandardGraph;
17
+ private createLegacyGraph;
18
+ private createMultiAgentGraph;
18
19
  static create<T extends t.BaseGraphState>(config: t.RunConfig): Promise<Run<T>>;
19
20
  getRunMessages(): BaseMessage[] | undefined;
21
+ /**
22
+ * Creates a custom event callback handler that intercepts custom events
23
+ * and processes them through our handler registry instead of EventStreamCallbackHandler
24
+ */
25
+ private createCustomEventCallback;
20
26
  processStream(inputs: t.IState, config: Partial<RunnableConfig> & {
21
27
  version: 'v1' | 'v2';
22
28
  run_id?: string;
23
29
  }, streamOptions?: t.EventStreamOptions): Promise<MessageContentComplex[] | undefined>;
24
30
  private createSystemCallback;
25
- getCallbacks(clientCallbacks: ClientCallbacks): SystemCallbacks;
26
- generateTitle({ provider, inputText, contentParts, titlePrompt, clientOptions, chainOptions, skipLanguage, omitOptions, titleMethod, titlePromptTemplate, }: t.RunTitleOptions): Promise<{
31
+ getCallbacks(clientCallbacks: t.ClientCallbacks): t.SystemCallbacks;
32
+ generateTitle({ provider, inputText, contentParts, titlePrompt, clientOptions, chainOptions, skipLanguage, titleMethod, titlePromptTemplate, }: t.RunTitleOptions): Promise<{
27
33
  language?: string;
28
34
  title?: string;
29
35
  }>;
@@ -1,5 +1,6 @@
1
1
  import type { AIMessageChunk } from '@langchain/core/messages';
2
- import type { Graph } from '@/graphs';
2
+ import type { AgentContext } from '@/agents/AgentContext';
3
+ import type { StandardGraph } from '@/graphs';
3
4
  import type * as t from '@/types';
4
5
  import { Providers } from '@/common';
5
6
  export declare function getChunkContent({ chunk, provider, reasoningKey, }: {
@@ -8,7 +9,7 @@ export declare function getChunkContent({ chunk, provider, reasoningKey, }: {
8
9
  reasoningKey: 'reasoning_content' | 'reasoning';
9
10
  }): string | t.MessageContentComplex[] | undefined;
10
11
  export declare class ChatModelStreamHandler implements t.EventHandler {
11
- handle(event: string, data: t.StreamEventData, metadata?: Record<string, unknown>, graph?: Graph): void;
12
- handleReasoning(chunk: Partial<AIMessageChunk>, graph: Graph, provider?: Providers): void;
12
+ handle(event: string, data: t.StreamEventData, metadata?: Record<string, unknown>, graph?: StandardGraph): Promise<void>;
13
+ handleReasoning(chunk: Partial<AIMessageChunk>, agentContext: AgentContext): void;
13
14
  }
14
15
  export declare function createContentAggregator(): t.ContentAggregatorResult;
@@ -0,0 +1,8 @@
1
+ import { Tool } from '@langchain/core/tools';
2
+ export declare class Calculator extends Tool {
3
+ static lc_name(): string;
4
+ get lc_namespace(): string[];
5
+ name: string;
6
+ _call(input: string): Promise<string>;
7
+ description: string;
8
+ }
@@ -19,4 +19,4 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
19
19
  getToolUsageCounts(): ReadonlyMap<string, number>;
20
20
  protected run(input: any, config: RunnableConfig): Promise<T>;
21
21
  }
22
- export declare function toolsCondition(state: BaseMessage[] | typeof MessagesAnnotation.State, invokedToolIds?: Set<string>): 'tools' | typeof END;
22
+ export declare function toolsCondition<T extends string>(state: BaseMessage[] | typeof MessagesAnnotation.State, toolNode: T, invokedToolIds?: Set<string>): T | typeof END;
@@ -1,19 +1,21 @@
1
1
  import type { ToolCall, ToolCallChunk } from '@langchain/core/messages/tool';
2
- import type { Graph } from '@/graphs';
2
+ import type { MultiAgentGraph, StandardGraph } from '@/graphs';
3
+ import type { AgentContext } from '@/agents/AgentContext';
3
4
  import type * as t from '@/types';
4
5
  export declare function handleToolCallChunks({ graph, stepKey, toolCallChunks, }: {
5
- graph: Graph;
6
+ graph: StandardGraph | MultiAgentGraph;
6
7
  stepKey: string;
7
8
  toolCallChunks: ToolCallChunk[];
8
- }): void;
9
- export declare const handleToolCalls: (toolCalls?: ToolCall[], metadata?: Record<string, unknown>, graph?: Graph) => void;
9
+ }): Promise<void>;
10
+ export declare const handleToolCalls: (toolCalls?: ToolCall[], metadata?: Record<string, unknown>, graph?: StandardGraph | MultiAgentGraph) => Promise<void>;
10
11
  export declare const toolResultTypes: Set<string>;
11
12
  /**
12
13
  * Handles the result of a server tool call; in other words, a provider's built-in tool.
13
14
  * As of 2025-07-06, only Anthropic handles server tool calls with this pattern.
14
15
  */
15
- export declare function handleServerToolResult({ content, metadata, graph, }: {
16
+ export declare function handleServerToolResult({ graph, content, metadata, agentContext, }: {
17
+ graph: StandardGraph | MultiAgentGraph;
16
18
  content?: string | t.MessageContentComplex[];
17
19
  metadata?: Record<string, unknown>;
18
- graph: Graph;
19
- }): boolean;
20
+ agentContext?: AgentContext;
21
+ }): Promise<boolean>;
@@ -39,16 +39,16 @@ export declare const createSearchTool: (config?: t.SearchToolConfig) => DynamicS
39
39
  news: z.ZodOptional<z.ZodBoolean>;
40
40
  }, "strip", z.ZodTypeAny, {
41
41
  query: string;
42
- date?: DATE_RANGE | undefined;
43
- images?: boolean | undefined;
44
42
  videos?: boolean | undefined;
43
+ images?: boolean | undefined;
45
44
  news?: boolean | undefined;
45
+ date?: DATE_RANGE | undefined;
46
46
  country?: unknown;
47
47
  }, {
48
48
  query: string;
49
- date?: DATE_RANGE | undefined;
50
- images?: boolean | undefined;
51
49
  videos?: boolean | undefined;
50
+ images?: boolean | undefined;
52
51
  news?: boolean | undefined;
52
+ date?: DATE_RANGE | undefined;
53
53
  country?: unknown;
54
54
  }>>;