illuma-agents 1.0.2 → 1.0.4
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/LICENSE +25 -21
- package/dist/cjs/agents/AgentContext.cjs +222 -0
- package/dist/cjs/agents/AgentContext.cjs.map +1 -0
- package/dist/cjs/common/enum.cjs +5 -4
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/events.cjs +7 -5
- package/dist/cjs/events.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +328 -207
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +507 -0
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -0
- package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
- package/dist/cjs/llm/google/index.cjs.map +1 -1
- package/dist/cjs/llm/ollama/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +35 -0
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/utils/index.cjs +3 -1
- package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
- package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
- package/dist/cjs/llm/providers.cjs +0 -2
- package/dist/cjs/llm/providers.cjs.map +1 -1
- package/dist/cjs/llm/vertexai/index.cjs.map +1 -1
- package/dist/cjs/main.cjs +12 -1
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/messages/cache.cjs +123 -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/format.cjs +17 -29
- package/dist/cjs/messages/format.cjs.map +1 -1
- package/dist/cjs/run.cjs +119 -74
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/stream.cjs +77 -73
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/Calculator.cjs +45 -0
- package/dist/cjs/tools/Calculator.cjs.map +1 -0
- package/dist/cjs/tools/CodeExecutor.cjs +22 -22
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +5 -3
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/handlers.cjs +20 -20
- package/dist/cjs/tools/handlers.cjs.map +1 -1
- package/dist/cjs/utils/events.cjs +31 -0
- package/dist/cjs/utils/events.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/tokens.cjs +54 -7
- package/dist/cjs/utils/tokens.cjs.map +1 -1
- package/dist/esm/agents/AgentContext.mjs +220 -0
- package/dist/esm/agents/AgentContext.mjs.map +1 -0
- package/dist/esm/common/enum.mjs +5 -4
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/events.mjs +7 -5
- package/dist/esm/events.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +330 -209
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +505 -0
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -0
- package/dist/esm/llm/anthropic/index.mjs.map +1 -1
- package/dist/esm/llm/google/index.mjs.map +1 -1
- package/dist/esm/llm/ollama/index.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +35 -0
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/llm/openai/utils/index.mjs +3 -1
- package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
- package/dist/esm/llm/openrouter/index.mjs.map +1 -1
- package/dist/esm/llm/providers.mjs +0 -2
- package/dist/esm/llm/providers.mjs.map +1 -1
- package/dist/esm/llm/vertexai/index.mjs.map +1 -1
- package/dist/esm/main.mjs +7 -2
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/messages/cache.mjs +120 -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/format.mjs +18 -29
- package/dist/esm/messages/format.mjs.map +1 -1
- package/dist/esm/run.mjs +119 -74
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/stream.mjs +77 -73
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/Calculator.mjs +24 -0
- package/dist/esm/tools/Calculator.mjs.map +1 -0
- package/dist/esm/tools/CodeExecutor.mjs +22 -22
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +5 -3
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/handlers.mjs +20 -20
- package/dist/esm/tools/handlers.mjs.map +1 -1
- package/dist/esm/utils/events.mjs +29 -0
- package/dist/esm/utils/events.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/tokens.mjs +54 -8
- package/dist/esm/utils/tokens.mjs.map +1 -1
- package/dist/types/agents/AgentContext.d.ts +94 -0
- package/dist/types/common/enum.d.ts +7 -5
- package/dist/types/events.d.ts +3 -3
- package/dist/types/graphs/Graph.d.ts +60 -66
- package/dist/types/graphs/MultiAgentGraph.d.ts +47 -0
- package/dist/types/graphs/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/llm/openai/index.d.ts +10 -0
- package/dist/types/messages/cache.d.ts +20 -0
- package/dist/types/messages/content.d.ts +7 -0
- package/dist/types/messages/format.d.ts +1 -7
- package/dist/types/messages/index.d.ts +2 -0
- package/dist/types/messages/reducer.d.ts +9 -0
- package/dist/types/run.d.ts +16 -10
- package/dist/types/stream.d.ts +4 -3
- package/dist/types/tools/Calculator.d.ts +8 -0
- package/dist/types/tools/ToolNode.d.ts +1 -1
- package/dist/types/tools/handlers.d.ts +9 -7
- package/dist/types/tools/search/tool.d.ts +4 -4
- package/dist/types/types/graph.d.ts +124 -11
- package/dist/types/types/llm.d.ts +13 -9
- package/dist/types/types/messages.d.ts +4 -0
- package/dist/types/types/run.d.ts +46 -8
- package/dist/types/types/stream.d.ts +3 -2
- package/dist/types/utils/events.d.ts +6 -0
- package/dist/types/utils/handlers.d.ts +34 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/tokens.d.ts +24 -0
- package/package.json +162 -145
- package/src/agents/AgentContext.ts +323 -0
- package/src/common/enum.ts +177 -176
- package/src/events.ts +197 -191
- package/src/graphs/Graph.ts +1058 -846
- package/src/graphs/MultiAgentGraph.ts +598 -0
- package/src/graphs/index.ts +2 -1
- package/src/index.ts +25 -24
- package/src/llm/anthropic/index.ts +413 -413
- package/src/llm/google/index.ts +222 -222
- package/src/llm/google/utils/zod_to_genai_parameters.ts +86 -88
- package/src/llm/ollama/index.ts +92 -92
- package/src/llm/openai/index.ts +894 -853
- package/src/llm/openai/utils/index.ts +920 -918
- package/src/llm/openrouter/index.ts +60 -60
- package/src/llm/providers.ts +55 -57
- package/src/llm/vertexai/index.ts +360 -360
- package/src/messages/cache.test.ts +461 -0
- package/src/messages/cache.ts +151 -0
- package/src/messages/content.test.ts +362 -0
- package/src/messages/content.ts +63 -0
- package/src/messages/format.ts +611 -625
- package/src/messages/formatAgentMessages.test.ts +1144 -917
- package/src/messages/index.ts +6 -4
- package/src/messages/reducer.ts +80 -0
- package/src/run.ts +447 -381
- package/src/scripts/abort.ts +157 -138
- package/src/scripts/ant_web_search.ts +158 -158
- package/src/scripts/cli.ts +172 -167
- package/src/scripts/cli2.ts +133 -125
- package/src/scripts/cli3.ts +184 -178
- package/src/scripts/cli4.ts +191 -184
- package/src/scripts/cli5.ts +191 -184
- package/src/scripts/code_exec.ts +213 -214
- package/src/scripts/code_exec_simple.ts +147 -129
- package/src/scripts/content.ts +138 -120
- package/src/scripts/handoff-test.ts +135 -0
- package/src/scripts/multi-agent-chain.ts +278 -0
- package/src/scripts/multi-agent-conditional.ts +220 -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.ts +343 -0
- package/src/scripts/multi-agent-sequence.ts +212 -0
- package/src/scripts/multi-agent-supervisor.ts +364 -0
- package/src/scripts/multi-agent-test.ts +186 -0
- package/src/scripts/search.ts +146 -150
- package/src/scripts/simple.ts +225 -225
- package/src/scripts/stream.ts +140 -122
- package/src/scripts/test-custom-prompt-key.ts +145 -0
- package/src/scripts/test-handoff-input.ts +170 -0
- package/src/scripts/test-multi-agent-list-handoff.ts +261 -0
- package/src/scripts/test-tools-before-handoff.ts +222 -0
- package/src/scripts/tools.ts +153 -155
- package/src/specs/agent-handoffs.test.ts +889 -0
- package/src/specs/anthropic.simple.test.ts +320 -317
- package/src/specs/azure.simple.test.ts +325 -316
- package/src/specs/openai.simple.test.ts +311 -316
- package/src/specs/openrouter.simple.test.ts +107 -0
- package/src/specs/prune.test.ts +758 -763
- package/src/specs/reasoning.test.ts +201 -165
- package/src/specs/thinking-prune.test.ts +769 -703
- package/src/specs/token-memoization.test.ts +39 -0
- package/src/stream.ts +664 -651
- package/src/tools/Calculator.test.ts +278 -0
- package/src/tools/Calculator.ts +25 -0
- package/src/tools/CodeExecutor.ts +220 -220
- package/src/tools/ToolNode.ts +170 -170
- package/src/tools/handlers.ts +341 -336
- package/src/types/graph.ts +372 -185
- package/src/types/llm.ts +141 -140
- package/src/types/messages.ts +4 -0
- package/src/types/run.ts +128 -89
- package/src/types/stream.ts +401 -400
- package/src/utils/events.ts +32 -0
- package/src/utils/handlers.ts +107 -0
- package/src/utils/index.ts +6 -5
- package/src/utils/llmConfig.ts +183 -183
- package/src/utils/tokens.ts +129 -70
- package/dist/types/scripts/abort.d.ts +0 -1
- package/dist/types/scripts/ant_web_search.d.ts +0 -1
- package/dist/types/scripts/args.d.ts +0 -7
- package/dist/types/scripts/caching.d.ts +0 -1
- package/dist/types/scripts/cli.d.ts +0 -1
- package/dist/types/scripts/cli2.d.ts +0 -1
- package/dist/types/scripts/cli3.d.ts +0 -1
- package/dist/types/scripts/cli4.d.ts +0 -1
- package/dist/types/scripts/cli5.d.ts +0 -1
- package/dist/types/scripts/code_exec.d.ts +0 -1
- package/dist/types/scripts/code_exec_files.d.ts +0 -1
- package/dist/types/scripts/code_exec_simple.d.ts +0 -1
- package/dist/types/scripts/content.d.ts +0 -1
- package/dist/types/scripts/empty_input.d.ts +0 -1
- package/dist/types/scripts/image.d.ts +0 -1
- package/dist/types/scripts/memory.d.ts +0 -1
- package/dist/types/scripts/search.d.ts +0 -1
- package/dist/types/scripts/simple.d.ts +0 -1
- package/dist/types/scripts/stream.d.ts +0 -1
- package/dist/types/scripts/thinking.d.ts +0 -1
- package/dist/types/scripts/tools.d.ts +0 -1
- package/dist/types/specs/spec.utils.d.ts +0 -1
- package/dist/types/tools/example.d.ts +0 -78
- package/src/tools/example.ts +0 -129
package/src/types/llm.ts
CHANGED
|
@@ -1,140 +1,141 @@
|
|
|
1
|
-
// src/types/llm.ts
|
|
2
|
-
import { ChatOllama } from '@langchain/ollama';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from '@langchain/
|
|
17
|
-
import type {
|
|
18
|
-
import type {
|
|
19
|
-
import type {
|
|
20
|
-
import type {
|
|
21
|
-
import type {
|
|
22
|
-
import type {
|
|
23
|
-
import type {
|
|
24
|
-
import type {
|
|
25
|
-
import type {
|
|
26
|
-
import type {
|
|
27
|
-
import type {
|
|
28
|
-
import type {
|
|
29
|
-
import
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} from '@/llm/
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export type
|
|
62
|
-
export type
|
|
63
|
-
export type
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
export type
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
export type
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
[Providers.
|
|
105
|
-
[Providers.
|
|
106
|
-
[Providers.
|
|
107
|
-
[Providers.
|
|
108
|
-
[Providers.
|
|
109
|
-
[Providers.
|
|
110
|
-
[Providers.
|
|
111
|
-
[Providers.
|
|
112
|
-
[Providers.
|
|
113
|
-
[Providers.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
[Providers.
|
|
120
|
-
[Providers.
|
|
121
|
-
[Providers.
|
|
122
|
-
[Providers.
|
|
123
|
-
[Providers.
|
|
124
|
-
[Providers.
|
|
125
|
-
[Providers.
|
|
126
|
-
[Providers.
|
|
127
|
-
[Providers.
|
|
128
|
-
[Providers.
|
|
129
|
-
[Providers.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1
|
+
// src/types/llm.ts
|
|
2
|
+
import { ChatOllama } from '@langchain/ollama';
|
|
3
|
+
import { ChatMistralAI } from '@langchain/mistralai';
|
|
4
|
+
import { ChatBedrockConverse } from '@langchain/aws';
|
|
5
|
+
import type {
|
|
6
|
+
BindToolsInput,
|
|
7
|
+
BaseChatModelParams,
|
|
8
|
+
} from '@langchain/core/language_models/chat_models';
|
|
9
|
+
import type {
|
|
10
|
+
OpenAIChatInput,
|
|
11
|
+
ChatOpenAIFields,
|
|
12
|
+
AzureOpenAIInput,
|
|
13
|
+
ClientOptions as OAIClientOptions,
|
|
14
|
+
} from '@langchain/openai';
|
|
15
|
+
import type { GoogleGenerativeAIChatInput } from '@langchain/google-genai';
|
|
16
|
+
import type { GeminiGenerationConfig } from '@langchain/google-common';
|
|
17
|
+
import type { ChatVertexAIInput } from '@langchain/google-vertexai';
|
|
18
|
+
import type { ChatDeepSeekCallOptions } from '@langchain/deepseek';
|
|
19
|
+
import type { ChatOpenRouterCallOptions } from '@/llm/openrouter';
|
|
20
|
+
import type { ChatBedrockConverseInput } from '@langchain/aws';
|
|
21
|
+
import type { ChatMistralAIInput } from '@langchain/mistralai';
|
|
22
|
+
import type { RequestOptions } from '@google/generative-ai';
|
|
23
|
+
import type { StructuredTool } from '@langchain/core/tools';
|
|
24
|
+
import type { AnthropicInput } from '@langchain/anthropic';
|
|
25
|
+
import type { Runnable } from '@langchain/core/runnables';
|
|
26
|
+
import type { ChatOllamaInput } from '@langchain/ollama';
|
|
27
|
+
import type { OpenAI as OpenAIClient } from 'openai';
|
|
28
|
+
import type { ChatXAIInput } from '@langchain/xai';
|
|
29
|
+
import {
|
|
30
|
+
AzureChatOpenAI,
|
|
31
|
+
ChatDeepSeek,
|
|
32
|
+
ChatOpenAI,
|
|
33
|
+
ChatXAI,
|
|
34
|
+
} from '@/llm/openai';
|
|
35
|
+
import { CustomChatGoogleGenerativeAI } from '@/llm/google';
|
|
36
|
+
import { CustomAnthropic } from '@/llm/anthropic';
|
|
37
|
+
import { ChatOpenRouter } from '@/llm/openrouter';
|
|
38
|
+
import { ChatVertexAI } from '@/llm/vertexai';
|
|
39
|
+
import { Providers } from '@/common';
|
|
40
|
+
|
|
41
|
+
export type AzureClientOptions = Partial<OpenAIChatInput> &
|
|
42
|
+
Partial<AzureOpenAIInput> & {
|
|
43
|
+
openAIApiKey?: string;
|
|
44
|
+
openAIApiVersion?: string;
|
|
45
|
+
openAIBasePath?: string;
|
|
46
|
+
deploymentName?: string;
|
|
47
|
+
} & BaseChatModelParams & {
|
|
48
|
+
configuration?: OAIClientOptions;
|
|
49
|
+
};
|
|
50
|
+
export type ThinkingConfig = AnthropicInput['thinking'];
|
|
51
|
+
export type ChatOpenAIToolType =
|
|
52
|
+
| BindToolsInput
|
|
53
|
+
| OpenAIClient.ChatCompletionTool;
|
|
54
|
+
export type CommonToolType = StructuredTool | ChatOpenAIToolType;
|
|
55
|
+
export type AnthropicReasoning = {
|
|
56
|
+
thinking?: ThinkingConfig | boolean;
|
|
57
|
+
thinkingBudget?: number;
|
|
58
|
+
};
|
|
59
|
+
export type OpenAIClientOptions = ChatOpenAIFields;
|
|
60
|
+
export type OllamaClientOptions = ChatOllamaInput;
|
|
61
|
+
export type AnthropicClientOptions = AnthropicInput;
|
|
62
|
+
export type MistralAIClientOptions = ChatMistralAIInput;
|
|
63
|
+
export type VertexAIClientOptions = ChatVertexAIInput & {
|
|
64
|
+
includeThoughts?: boolean;
|
|
65
|
+
};
|
|
66
|
+
export type BedrockAnthropicInput = ChatBedrockConverseInput & {
|
|
67
|
+
additionalModelRequestFields?: ChatBedrockConverseInput['additionalModelRequestFields'] &
|
|
68
|
+
AnthropicReasoning;
|
|
69
|
+
promptCache?: boolean;
|
|
70
|
+
};
|
|
71
|
+
export type BedrockConverseClientOptions = ChatBedrockConverseInput;
|
|
72
|
+
export type BedrockAnthropicClientOptions = BedrockAnthropicInput;
|
|
73
|
+
export type GoogleClientOptions = GoogleGenerativeAIChatInput & {
|
|
74
|
+
customHeaders?: RequestOptions['customHeaders'];
|
|
75
|
+
thinkingConfig?: GeminiGenerationConfig['thinkingConfig'];
|
|
76
|
+
};
|
|
77
|
+
export type DeepSeekClientOptions = ChatDeepSeekCallOptions;
|
|
78
|
+
export type XAIClientOptions = ChatXAIInput;
|
|
79
|
+
|
|
80
|
+
export type ClientOptions =
|
|
81
|
+
| OpenAIClientOptions
|
|
82
|
+
| AzureClientOptions
|
|
83
|
+
| OllamaClientOptions
|
|
84
|
+
| AnthropicClientOptions
|
|
85
|
+
| MistralAIClientOptions
|
|
86
|
+
| VertexAIClientOptions
|
|
87
|
+
| BedrockConverseClientOptions
|
|
88
|
+
| GoogleClientOptions
|
|
89
|
+
| DeepSeekClientOptions
|
|
90
|
+
| XAIClientOptions;
|
|
91
|
+
|
|
92
|
+
export type SharedLLMConfig = {
|
|
93
|
+
provider: Providers;
|
|
94
|
+
_lc_stream_delay?: number;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type LLMConfig = SharedLLMConfig &
|
|
98
|
+
ClientOptions & {
|
|
99
|
+
/** Optional provider fallbacks in order of attempt */
|
|
100
|
+
fallbacks?: Array<{ provider: Providers; clientOptions?: ClientOptions }>;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type ProviderOptionsMap = {
|
|
104
|
+
[Providers.AZURE]: AzureClientOptions;
|
|
105
|
+
[Providers.OPENAI]: OpenAIClientOptions;
|
|
106
|
+
[Providers.OLLAMA]: OllamaClientOptions;
|
|
107
|
+
[Providers.GOOGLE]: GoogleClientOptions;
|
|
108
|
+
[Providers.VERTEXAI]: VertexAIClientOptions;
|
|
109
|
+
[Providers.DEEPSEEK]: DeepSeekClientOptions;
|
|
110
|
+
[Providers.ANTHROPIC]: AnthropicClientOptions;
|
|
111
|
+
[Providers.MISTRALAI]: MistralAIClientOptions;
|
|
112
|
+
[Providers.MISTRAL]: MistralAIClientOptions;
|
|
113
|
+
[Providers.OPENROUTER]: ChatOpenRouterCallOptions;
|
|
114
|
+
[Providers.BEDROCK]: BedrockConverseClientOptions;
|
|
115
|
+
[Providers.XAI]: XAIClientOptions;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export type ChatModelMap = {
|
|
119
|
+
[Providers.XAI]: ChatXAI;
|
|
120
|
+
[Providers.OPENAI]: ChatOpenAI;
|
|
121
|
+
[Providers.OLLAMA]: ChatOllama;
|
|
122
|
+
[Providers.AZURE]: AzureChatOpenAI;
|
|
123
|
+
[Providers.DEEPSEEK]: ChatDeepSeek;
|
|
124
|
+
[Providers.VERTEXAI]: ChatVertexAI;
|
|
125
|
+
[Providers.ANTHROPIC]: CustomAnthropic;
|
|
126
|
+
[Providers.MISTRALAI]: ChatMistralAI;
|
|
127
|
+
[Providers.MISTRAL]: ChatMistralAI;
|
|
128
|
+
[Providers.OPENROUTER]: ChatOpenRouter;
|
|
129
|
+
[Providers.BEDROCK]: ChatBedrockConverse;
|
|
130
|
+
[Providers.GOOGLE]: CustomChatGoogleGenerativeAI;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export type ChatModelConstructorMap = {
|
|
134
|
+
[P in Providers]: new (config: ProviderOptionsMap[P]) => ChatModelMap[P];
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export type ChatModelInstance = ChatModelMap[Providers];
|
|
138
|
+
|
|
139
|
+
export type ModelWithTools = ChatModelInstance & {
|
|
140
|
+
bindTools(tools: CommonToolType[]): Runnable;
|
|
141
|
+
};
|
package/src/types/run.ts
CHANGED
|
@@ -1,89 +1,128 @@
|
|
|
1
|
-
// src/types/run.ts
|
|
2
|
-
import type * as z from 'zod';
|
|
3
|
-
import type { BaseMessage } from '@langchain/core/messages';
|
|
4
|
-
import type { StructuredTool } from '@langchain/core/tools';
|
|
5
|
-
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
6
|
-
import type {
|
|
7
|
-
BaseCallbackHandler,
|
|
8
|
-
CallbackHandlerMethods,
|
|
9
|
-
} from '@langchain/core/callbacks/base';
|
|
10
|
-
import type * as
|
|
11
|
-
import type * as
|
|
12
|
-
import type * as
|
|
13
|
-
import type * as
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export type
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
export type
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
1
|
+
// src/types/run.ts
|
|
2
|
+
import type * as z from 'zod';
|
|
3
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
4
|
+
import type { StructuredTool } from '@langchain/core/tools';
|
|
5
|
+
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
6
|
+
import type {
|
|
7
|
+
BaseCallbackHandler,
|
|
8
|
+
CallbackHandlerMethods,
|
|
9
|
+
} from '@langchain/core/callbacks/base';
|
|
10
|
+
import type * as s from '@/types/stream';
|
|
11
|
+
import type * as e from '@/common/enum';
|
|
12
|
+
import type * as g from '@/types/graph';
|
|
13
|
+
import type * as l from '@/types/llm';
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
export type ZodObjectAny = z.ZodObject<any, any, any, any>;
|
|
17
|
+
export type BaseGraphConfig = {
|
|
18
|
+
llmConfig: l.LLMConfig;
|
|
19
|
+
provider?: e.Providers;
|
|
20
|
+
clientOptions?: l.ClientOptions;
|
|
21
|
+
/** Optional compile options for workflow.compile() */
|
|
22
|
+
compileOptions?: g.CompileOptions;
|
|
23
|
+
};
|
|
24
|
+
export type LegacyGraphConfig = BaseGraphConfig & {
|
|
25
|
+
type?: 'standard';
|
|
26
|
+
} & Omit<g.StandardGraphInput, 'provider' | 'clientOptions' | 'agents'> &
|
|
27
|
+
Omit<g.AgentInputs, 'provider' | 'clientOptions' | 'agentId'>;
|
|
28
|
+
|
|
29
|
+
/* Supervised graph (opt-in) */
|
|
30
|
+
export type SupervisedGraphConfig = BaseGraphConfig & {
|
|
31
|
+
type: 'supervised';
|
|
32
|
+
/** Enable supervised router; when false, fall back to standard loop */
|
|
33
|
+
routerEnabled?: boolean;
|
|
34
|
+
/** Table-driven routing policy per stage */
|
|
35
|
+
routingPolicies?: Array<{
|
|
36
|
+
stage: string;
|
|
37
|
+
agents?: string[];
|
|
38
|
+
model?: e.Providers;
|
|
39
|
+
parallel?: boolean;
|
|
40
|
+
/** Optional simple condition on content/tools */
|
|
41
|
+
when?:
|
|
42
|
+
| 'always'
|
|
43
|
+
| 'has_tools'
|
|
44
|
+
| 'no_tools'
|
|
45
|
+
| { includes?: string[]; excludes?: string[] };
|
|
46
|
+
}>;
|
|
47
|
+
/** Opt-in feature flags */
|
|
48
|
+
featureFlags?: {
|
|
49
|
+
multi_model_routing?: boolean;
|
|
50
|
+
fan_out?: boolean;
|
|
51
|
+
fan_out_retries?: number;
|
|
52
|
+
fan_out_backoff_ms?: number;
|
|
53
|
+
fan_out_concurrency?: number;
|
|
54
|
+
};
|
|
55
|
+
/** Optional per-stage model configs */
|
|
56
|
+
models?: Record<string, l.LLMConfig>;
|
|
57
|
+
} & Omit<g.StandardGraphInput, 'provider' | 'clientOptions'>;
|
|
58
|
+
|
|
59
|
+
export type RunTitleOptions = {
|
|
60
|
+
inputText: string;
|
|
61
|
+
provider: e.Providers;
|
|
62
|
+
contentParts: (s.MessageContentComplex | undefined)[];
|
|
63
|
+
titlePrompt?: string;
|
|
64
|
+
skipLanguage?: boolean;
|
|
65
|
+
clientOptions?: l.ClientOptions;
|
|
66
|
+
chainOptions?: Partial<RunnableConfig> | undefined;
|
|
67
|
+
omitOptions?: Set<string>;
|
|
68
|
+
titleMethod?: e.TitleMethod;
|
|
69
|
+
titlePromptTemplate?: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export interface AgentStateChannels {
|
|
73
|
+
messages: BaseMessage[];
|
|
74
|
+
next: string;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
instructions?: string;
|
|
77
|
+
additional_instructions?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface Member {
|
|
81
|
+
name: string;
|
|
82
|
+
systemPrompt: string;
|
|
83
|
+
tools: StructuredTool[];
|
|
84
|
+
llmConfig: l.LLMConfig;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type CollaborativeGraphConfig = {
|
|
88
|
+
type: 'collaborative';
|
|
89
|
+
members: Member[];
|
|
90
|
+
supervisorConfig: { systemPrompt?: string; llmConfig: l.LLMConfig };
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type TaskManagerGraphConfig = {
|
|
94
|
+
type: 'taskmanager';
|
|
95
|
+
members: Member[];
|
|
96
|
+
supervisorConfig: { systemPrompt?: string; llmConfig: l.LLMConfig };
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type MultiAgentGraphConfig = {
|
|
100
|
+
type: 'multi-agent';
|
|
101
|
+
compileOptions?: g.CompileOptions;
|
|
102
|
+
agents: g.AgentInputs[];
|
|
103
|
+
edges: g.GraphEdge[];
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type StandardGraphConfig = Omit<
|
|
107
|
+
MultiAgentGraphConfig,
|
|
108
|
+
'edges' | 'type'
|
|
109
|
+
> & { type?: 'standard'; signal?: AbortSignal };
|
|
110
|
+
|
|
111
|
+
export type RunConfig = {
|
|
112
|
+
runId: string;
|
|
113
|
+
graphConfig: LegacyGraphConfig | StandardGraphConfig | MultiAgentGraphConfig;
|
|
114
|
+
customHandlers?: Record<string, g.EventHandler>;
|
|
115
|
+
returnContent?: boolean;
|
|
116
|
+
tokenCounter?: TokenCounter;
|
|
117
|
+
indexTokenCountMap?: Record<string, number>;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export type ProvidedCallbacks =
|
|
121
|
+
| (BaseCallbackHandler | CallbackHandlerMethods)[]
|
|
122
|
+
| undefined;
|
|
123
|
+
|
|
124
|
+
export type TokenCounter = (message: BaseMessage) => number;
|
|
125
|
+
export type EventStreamOptions = {
|
|
126
|
+
callbacks?: g.ClientCallbacks;
|
|
127
|
+
keepContent?: boolean;
|
|
128
|
+
};
|