illuma-agents 1.0.37 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/agents/AgentContext.cjs +69 -14
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/common/enum.cjs +3 -1
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +50 -8
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +277 -11
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/index.cjs +128 -61
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
- package/dist/cjs/main.cjs +16 -7
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/messages/cache.cjs +1 -0
- package/dist/cjs/messages/cache.cjs.map +1 -1
- package/dist/cjs/messages/core.cjs +1 -1
- package/dist/cjs/messages/core.cjs.map +1 -1
- package/dist/cjs/messages/tools.cjs +2 -2
- package/dist/cjs/messages/tools.cjs.map +1 -1
- package/dist/cjs/stream.cjs +4 -2
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/BrowserTools.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +22 -21
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +14 -11
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +101 -2
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/ToolSearch.cjs +862 -0
- package/dist/cjs/tools/ToolSearch.cjs.map +1 -0
- package/dist/esm/agents/AgentContext.mjs +69 -14
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/common/enum.mjs +3 -1
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +51 -9
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +278 -12
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/llm/bedrock/index.mjs +127 -60
- package/dist/esm/llm/bedrock/index.mjs.map +1 -1
- package/dist/esm/main.mjs +1 -1
- package/dist/esm/messages/cache.mjs +1 -0
- package/dist/esm/messages/cache.mjs.map +1 -1
- package/dist/esm/messages/core.mjs +1 -1
- package/dist/esm/messages/core.mjs.map +1 -1
- package/dist/esm/messages/tools.mjs +2 -2
- package/dist/esm/messages/tools.mjs.map +1 -1
- package/dist/esm/stream.mjs +4 -2
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/BrowserTools.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +22 -21
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +14 -11
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +102 -3
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/ToolSearch.mjs +827 -0
- package/dist/esm/tools/ToolSearch.mjs.map +1 -0
- package/dist/types/agents/AgentContext.d.ts +33 -1
- package/dist/types/common/enum.d.ts +4 -2
- package/dist/types/graphs/Graph.d.ts +6 -0
- package/dist/types/graphs/MultiAgentGraph.d.ts +16 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/llm/bedrock/index.d.ts +89 -11
- 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/tools/CodeExecutor.d.ts +0 -3
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +0 -3
- package/dist/types/tools/ToolNode.d.ts +3 -1
- package/dist/types/tools/ToolSearch.d.ts +148 -0
- package/dist/types/types/graph.d.ts +2 -0
- package/dist/types/types/llm.d.ts +3 -1
- package/dist/types/types/tools.d.ts +42 -2
- package/package.json +12 -5
- package/src/agents/AgentContext.ts +88 -16
- package/src/common/enum.ts +3 -1
- package/src/graphs/Graph.ts +64 -13
- package/src/graphs/MultiAgentGraph.ts +350 -13
- package/src/index.ts +1 -1
- package/src/llm/bedrock/index.ts +221 -99
- 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/messages/__tests__/tools.test.ts +21 -21
- package/src/messages/cache.test.ts +259 -0
- package/src/messages/cache.ts +104 -1
- package/src/messages/core.ts +1 -1
- package/src/messages/tools.ts +2 -2
- package/src/scripts/caching.ts +27 -19
- package/src/scripts/code_exec_files.ts +58 -15
- package/src/scripts/code_exec_multi_session.ts +241 -0
- package/src/scripts/code_exec_session.ts +282 -0
- package/src/scripts/multi-agent-conditional.ts +1 -0
- package/src/scripts/multi-agent-supervisor.ts +1 -0
- package/src/scripts/programmatic_exec_agent.ts +4 -4
- package/src/scripts/test-handoff-preamble.ts +277 -0
- package/src/scripts/test-parallel-handoffs.ts +291 -0
- package/src/scripts/test-tools-before-handoff.ts +8 -4
- package/src/scripts/test_code_api.ts +361 -0
- package/src/scripts/thinking-bedrock.ts +159 -0
- package/src/scripts/thinking.ts +39 -18
- package/src/scripts/{tool_search_regex.ts → tool_search.ts} +5 -5
- package/src/scripts/tools.ts +7 -3
- package/src/stream.ts +4 -2
- package/src/tools/BrowserTools.ts +39 -17
- package/src/tools/CodeExecutor.ts +26 -23
- package/src/tools/ProgrammaticToolCalling.ts +18 -14
- package/src/tools/ToolNode.ts +114 -1
- package/src/tools/ToolSearch.ts +1041 -0
- package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +0 -2
- package/src/tools/__tests__/{ToolSearchRegex.integration.test.ts → ToolSearch.integration.test.ts} +6 -6
- package/src/tools/__tests__/ToolSearch.test.ts +1003 -0
- package/src/types/graph.ts +2 -0
- package/src/types/llm.ts +3 -1
- package/src/types/tools.ts +51 -2
- package/dist/cjs/tools/ToolSearchRegex.cjs +0 -455
- package/dist/cjs/tools/ToolSearchRegex.cjs.map +0 -1
- package/dist/esm/tools/ToolSearchRegex.mjs +0 -448
- package/dist/esm/tools/ToolSearchRegex.mjs.map +0 -1
- package/dist/types/tools/ToolSearchRegex.d.ts +0 -80
- package/src/tools/ToolSearchRegex.ts +0 -535
- package/src/tools/__tests__/ToolSearchRegex.test.ts +0 -232
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for converting Bedrock Converse responses to LangChain messages.
|
|
3
|
+
* Ported from @langchain/aws common.js
|
|
4
|
+
*/
|
|
5
|
+
import { AIMessage, AIMessageChunk } from '@langchain/core/messages';
|
|
6
|
+
import { ChatGenerationChunk } from '@langchain/core/outputs';
|
|
7
|
+
import type {
|
|
8
|
+
BedrockMessage,
|
|
9
|
+
ConverseResponse,
|
|
10
|
+
ContentBlockDeltaEvent,
|
|
11
|
+
ConverseStreamMetadataEvent,
|
|
12
|
+
ContentBlockStartEvent,
|
|
13
|
+
ReasoningContentBlock,
|
|
14
|
+
ReasoningContentBlockDelta,
|
|
15
|
+
MessageContentReasoningBlock,
|
|
16
|
+
MessageContentReasoningBlockReasoningTextPartial,
|
|
17
|
+
MessageContentReasoningBlockRedacted,
|
|
18
|
+
} from '../types';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Convert a Bedrock reasoning block delta to a LangChain partial reasoning block.
|
|
22
|
+
*/
|
|
23
|
+
export function bedrockReasoningDeltaToLangchainPartialReasoningBlock(
|
|
24
|
+
reasoningContent: ReasoningContentBlockDelta
|
|
25
|
+
):
|
|
26
|
+
| MessageContentReasoningBlockReasoningTextPartial
|
|
27
|
+
| MessageContentReasoningBlockRedacted {
|
|
28
|
+
const { text, redactedContent, signature } =
|
|
29
|
+
reasoningContent as ReasoningContentBlockDelta & {
|
|
30
|
+
text?: string;
|
|
31
|
+
redactedContent?: Uint8Array;
|
|
32
|
+
signature?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
if (typeof text === 'string') {
|
|
36
|
+
return {
|
|
37
|
+
type: 'reasoning_content',
|
|
38
|
+
reasoningText: { text },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (signature != null) {
|
|
42
|
+
return {
|
|
43
|
+
type: 'reasoning_content',
|
|
44
|
+
reasoningText: { signature },
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (redactedContent != null) {
|
|
48
|
+
return {
|
|
49
|
+
type: 'reasoning_content',
|
|
50
|
+
redactedContent: Buffer.from(redactedContent).toString('base64'),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
throw new Error('Invalid reasoning content');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Convert a Bedrock reasoning block to a LangChain reasoning block.
|
|
58
|
+
*/
|
|
59
|
+
export function bedrockReasoningBlockToLangchainReasoningBlock(
|
|
60
|
+
reasoningContent: ReasoningContentBlock
|
|
61
|
+
): MessageContentReasoningBlock {
|
|
62
|
+
const { reasoningText, redactedContent } =
|
|
63
|
+
reasoningContent as ReasoningContentBlock & {
|
|
64
|
+
reasoningText?: { text?: string; signature?: string };
|
|
65
|
+
redactedContent?: Uint8Array;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
if (reasoningText != null) {
|
|
69
|
+
return {
|
|
70
|
+
type: 'reasoning_content',
|
|
71
|
+
reasoningText: reasoningText,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (redactedContent != null) {
|
|
75
|
+
return {
|
|
76
|
+
type: 'reasoning_content',
|
|
77
|
+
redactedContent: Buffer.from(redactedContent).toString('base64'),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
throw new Error('Invalid reasoning content');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Convert a Bedrock Converse message to a LangChain message.
|
|
85
|
+
*/
|
|
86
|
+
export function convertConverseMessageToLangChainMessage(
|
|
87
|
+
message: BedrockMessage,
|
|
88
|
+
responseMetadata: Omit<ConverseResponse, 'output'>
|
|
89
|
+
): AIMessage {
|
|
90
|
+
if (message.content == null) {
|
|
91
|
+
throw new Error('No message content found in response.');
|
|
92
|
+
}
|
|
93
|
+
if (message.role !== 'assistant') {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`Unsupported message role received in ChatBedrockConverse response: ${message.role}`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let requestId: string | undefined;
|
|
100
|
+
if (
|
|
101
|
+
'$metadata' in responseMetadata &&
|
|
102
|
+
responseMetadata.$metadata != null &&
|
|
103
|
+
typeof responseMetadata.$metadata === 'object' &&
|
|
104
|
+
'requestId' in responseMetadata.$metadata
|
|
105
|
+
) {
|
|
106
|
+
requestId = responseMetadata.$metadata.requestId as string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let tokenUsage:
|
|
110
|
+
| { input_tokens: number; output_tokens: number; total_tokens: number }
|
|
111
|
+
| undefined;
|
|
112
|
+
if (responseMetadata.usage != null) {
|
|
113
|
+
const input_tokens = responseMetadata.usage.inputTokens ?? 0;
|
|
114
|
+
const output_tokens = responseMetadata.usage.outputTokens ?? 0;
|
|
115
|
+
tokenUsage = {
|
|
116
|
+
input_tokens,
|
|
117
|
+
output_tokens,
|
|
118
|
+
total_tokens:
|
|
119
|
+
responseMetadata.usage.totalTokens ?? input_tokens + output_tokens,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (
|
|
124
|
+
message.content.length === 1 &&
|
|
125
|
+
'text' in message.content[0] &&
|
|
126
|
+
typeof message.content[0].text === 'string'
|
|
127
|
+
) {
|
|
128
|
+
return new AIMessage({
|
|
129
|
+
content: message.content[0].text,
|
|
130
|
+
response_metadata: responseMetadata,
|
|
131
|
+
usage_metadata: tokenUsage,
|
|
132
|
+
id: requestId,
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
const toolCalls: Array<{
|
|
136
|
+
id?: string;
|
|
137
|
+
name: string;
|
|
138
|
+
args: Record<string, unknown>;
|
|
139
|
+
type: 'tool_call';
|
|
140
|
+
}> = [];
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
+
const content: any[] = [];
|
|
143
|
+
|
|
144
|
+
message.content.forEach((c) => {
|
|
145
|
+
if (
|
|
146
|
+
'toolUse' in c &&
|
|
147
|
+
c.toolUse != null &&
|
|
148
|
+
c.toolUse.name != null &&
|
|
149
|
+
c.toolUse.name !== '' &&
|
|
150
|
+
c.toolUse.input != null &&
|
|
151
|
+
typeof c.toolUse.input === 'object'
|
|
152
|
+
) {
|
|
153
|
+
toolCalls.push({
|
|
154
|
+
id: c.toolUse.toolUseId,
|
|
155
|
+
name: c.toolUse.name,
|
|
156
|
+
args: c.toolUse.input as Record<string, unknown>,
|
|
157
|
+
type: 'tool_call',
|
|
158
|
+
});
|
|
159
|
+
} else if ('text' in c && typeof c.text === 'string') {
|
|
160
|
+
content.push({ type: 'text', text: c.text });
|
|
161
|
+
} else if ('reasoningContent' in c && c.reasoningContent != null) {
|
|
162
|
+
content.push(
|
|
163
|
+
bedrockReasoningBlockToLangchainReasoningBlock(c.reasoningContent)
|
|
164
|
+
);
|
|
165
|
+
} else {
|
|
166
|
+
content.push(c);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
return new AIMessage({
|
|
171
|
+
content: content.length ? content : '',
|
|
172
|
+
tool_calls: toolCalls.length ? toolCalls : undefined,
|
|
173
|
+
response_metadata: responseMetadata,
|
|
174
|
+
usage_metadata: tokenUsage,
|
|
175
|
+
id: requestId,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Handle a content block delta event from Bedrock Converse stream.
|
|
182
|
+
*/
|
|
183
|
+
export function handleConverseStreamContentBlockDelta(
|
|
184
|
+
contentBlockDelta: ContentBlockDeltaEvent
|
|
185
|
+
): ChatGenerationChunk {
|
|
186
|
+
if (contentBlockDelta.delta == null) {
|
|
187
|
+
throw new Error('No delta found in content block.');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (typeof contentBlockDelta.delta.text === 'string') {
|
|
191
|
+
return new ChatGenerationChunk({
|
|
192
|
+
text: contentBlockDelta.delta.text,
|
|
193
|
+
message: new AIMessageChunk({
|
|
194
|
+
content: contentBlockDelta.delta.text,
|
|
195
|
+
response_metadata: {
|
|
196
|
+
contentBlockIndex: contentBlockDelta.contentBlockIndex,
|
|
197
|
+
},
|
|
198
|
+
}),
|
|
199
|
+
});
|
|
200
|
+
} else if (contentBlockDelta.delta.toolUse != null) {
|
|
201
|
+
const index = contentBlockDelta.contentBlockIndex;
|
|
202
|
+
return new ChatGenerationChunk({
|
|
203
|
+
text: '',
|
|
204
|
+
message: new AIMessageChunk({
|
|
205
|
+
content: '',
|
|
206
|
+
tool_call_chunks: [
|
|
207
|
+
{
|
|
208
|
+
args: contentBlockDelta.delta.toolUse.input as string,
|
|
209
|
+
index,
|
|
210
|
+
type: 'tool_call_chunk',
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
response_metadata: {
|
|
214
|
+
contentBlockIndex: contentBlockDelta.contentBlockIndex,
|
|
215
|
+
},
|
|
216
|
+
}),
|
|
217
|
+
});
|
|
218
|
+
} else if (contentBlockDelta.delta.reasoningContent != null) {
|
|
219
|
+
const reasoningBlock =
|
|
220
|
+
bedrockReasoningDeltaToLangchainPartialReasoningBlock(
|
|
221
|
+
contentBlockDelta.delta.reasoningContent
|
|
222
|
+
);
|
|
223
|
+
// Extract the text for additional_kwargs.reasoning_content (for stream handler compatibility)
|
|
224
|
+
const reasoningText =
|
|
225
|
+
'reasoningText' in reasoningBlock
|
|
226
|
+
? (reasoningBlock.reasoningText.text ??
|
|
227
|
+
reasoningBlock.reasoningText.signature ??
|
|
228
|
+
('redactedContent' in reasoningBlock
|
|
229
|
+
? reasoningBlock.redactedContent
|
|
230
|
+
: ''))
|
|
231
|
+
: '';
|
|
232
|
+
return new ChatGenerationChunk({
|
|
233
|
+
text: '',
|
|
234
|
+
message: new AIMessageChunk({
|
|
235
|
+
content: [reasoningBlock],
|
|
236
|
+
additional_kwargs: {
|
|
237
|
+
// Set reasoning_content for stream handler to detect reasoning mode
|
|
238
|
+
reasoning_content: reasoningText,
|
|
239
|
+
},
|
|
240
|
+
response_metadata: {
|
|
241
|
+
contentBlockIndex: contentBlockDelta.contentBlockIndex,
|
|
242
|
+
},
|
|
243
|
+
}),
|
|
244
|
+
});
|
|
245
|
+
} else {
|
|
246
|
+
throw new Error(
|
|
247
|
+
`Unsupported content block type(s): ${JSON.stringify(contentBlockDelta.delta, null, 2)}`
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Handle a content block start event from Bedrock Converse stream.
|
|
254
|
+
*/
|
|
255
|
+
export function handleConverseStreamContentBlockStart(
|
|
256
|
+
contentBlockStart: ContentBlockStartEvent
|
|
257
|
+
): ChatGenerationChunk | null {
|
|
258
|
+
const index = contentBlockStart.contentBlockIndex;
|
|
259
|
+
|
|
260
|
+
if (contentBlockStart.start?.toolUse != null) {
|
|
261
|
+
return new ChatGenerationChunk({
|
|
262
|
+
text: '',
|
|
263
|
+
message: new AIMessageChunk({
|
|
264
|
+
content: '',
|
|
265
|
+
tool_call_chunks: [
|
|
266
|
+
{
|
|
267
|
+
name: contentBlockStart.start.toolUse.name,
|
|
268
|
+
id: contentBlockStart.start.toolUse.toolUseId,
|
|
269
|
+
index,
|
|
270
|
+
type: 'tool_call_chunk',
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
response_metadata: {
|
|
274
|
+
contentBlockIndex: index,
|
|
275
|
+
},
|
|
276
|
+
}),
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Return null for non-tool content block starts (text blocks don't need special handling)
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Handle a metadata event from Bedrock Converse stream.
|
|
286
|
+
*/
|
|
287
|
+
export function handleConverseStreamMetadata(
|
|
288
|
+
metadata: ConverseStreamMetadataEvent,
|
|
289
|
+
extra: { streamUsage: boolean }
|
|
290
|
+
): ChatGenerationChunk {
|
|
291
|
+
const inputTokens = metadata.usage?.inputTokens ?? 0;
|
|
292
|
+
const outputTokens = metadata.usage?.outputTokens ?? 0;
|
|
293
|
+
const usage_metadata = {
|
|
294
|
+
input_tokens: inputTokens,
|
|
295
|
+
output_tokens: outputTokens,
|
|
296
|
+
total_tokens: metadata.usage?.totalTokens ?? inputTokens + outputTokens,
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
return new ChatGenerationChunk({
|
|
300
|
+
text: '',
|
|
301
|
+
message: new AIMessageChunk({
|
|
302
|
+
content: '',
|
|
303
|
+
usage_metadata: extra.streamUsage ? usage_metadata : undefined,
|
|
304
|
+
response_metadata: {
|
|
305
|
+
// Use the same key as returned from the Converse API
|
|
306
|
+
metadata,
|
|
307
|
+
},
|
|
308
|
+
}),
|
|
309
|
+
});
|
|
310
|
+
}
|
|
@@ -41,7 +41,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
41
41
|
return new ToolMessage({
|
|
42
42
|
content: `Found ${discoveredTools.length} tools`,
|
|
43
43
|
tool_call_id: toolCallId,
|
|
44
|
-
name: Constants.
|
|
44
|
+
name: Constants.TOOL_SEARCH,
|
|
45
45
|
artifact: {
|
|
46
46
|
tool_references: discoveredTools.map((name) => ({
|
|
47
47
|
tool_name: name,
|
|
@@ -79,7 +79,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
79
79
|
createAIMessage('Searching...', [
|
|
80
80
|
{
|
|
81
81
|
id: 'call_1',
|
|
82
|
-
name: Constants.
|
|
82
|
+
name: Constants.TOOL_SEARCH,
|
|
83
83
|
args: { pattern: 'database' },
|
|
84
84
|
},
|
|
85
85
|
]),
|
|
@@ -97,12 +97,12 @@ describe('Tool Discovery Functions', () => {
|
|
|
97
97
|
createAIMessage('Searching...', [
|
|
98
98
|
{
|
|
99
99
|
id: 'call_1',
|
|
100
|
-
name: Constants.
|
|
100
|
+
name: Constants.TOOL_SEARCH,
|
|
101
101
|
args: { pattern: 'database' },
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
id: 'call_2',
|
|
105
|
-
name: Constants.
|
|
105
|
+
name: Constants.TOOL_SEARCH,
|
|
106
106
|
args: { pattern: 'file' },
|
|
107
107
|
},
|
|
108
108
|
]),
|
|
@@ -137,7 +137,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
137
137
|
new ToolMessage({
|
|
138
138
|
content: 'Some result',
|
|
139
139
|
tool_call_id: 'orphan_call',
|
|
140
|
-
name: Constants.
|
|
140
|
+
name: Constants.TOOL_SEARCH,
|
|
141
141
|
}),
|
|
142
142
|
];
|
|
143
143
|
|
|
@@ -153,7 +153,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
153
153
|
createAIMessage('Searching...', [
|
|
154
154
|
{
|
|
155
155
|
id: 'old_call',
|
|
156
|
-
name: Constants.
|
|
156
|
+
name: Constants.TOOL_SEARCH,
|
|
157
157
|
args: { pattern: 'old' },
|
|
158
158
|
},
|
|
159
159
|
]),
|
|
@@ -163,7 +163,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
163
163
|
createAIMessage('Searching again...', [
|
|
164
164
|
{
|
|
165
165
|
id: 'new_call',
|
|
166
|
-
name: Constants.
|
|
166
|
+
name: Constants.TOOL_SEARCH,
|
|
167
167
|
args: { pattern: 'new' },
|
|
168
168
|
},
|
|
169
169
|
]),
|
|
@@ -182,7 +182,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
182
182
|
createAIMessage('Working...', [
|
|
183
183
|
{
|
|
184
184
|
id: 'search_call',
|
|
185
|
-
name: Constants.
|
|
185
|
+
name: Constants.TOOL_SEARCH,
|
|
186
186
|
args: { pattern: 'test' },
|
|
187
187
|
},
|
|
188
188
|
{ id: 'other_call', name: 'get_weather', args: { city: 'NYC' } },
|
|
@@ -202,14 +202,14 @@ describe('Tool Discovery Functions', () => {
|
|
|
202
202
|
createAIMessage('Searching...', [
|
|
203
203
|
{
|
|
204
204
|
id: 'call_1',
|
|
205
|
-
name: Constants.
|
|
205
|
+
name: Constants.TOOL_SEARCH,
|
|
206
206
|
args: { pattern: 'xyz' },
|
|
207
207
|
},
|
|
208
208
|
]),
|
|
209
209
|
new ToolMessage({
|
|
210
210
|
content: 'No tools found',
|
|
211
211
|
tool_call_id: 'call_1',
|
|
212
|
-
name: Constants.
|
|
212
|
+
name: Constants.TOOL_SEARCH,
|
|
213
213
|
artifact: {
|
|
214
214
|
tool_references: [],
|
|
215
215
|
metadata: { total_searched: 10, pattern: 'xyz' },
|
|
@@ -228,14 +228,14 @@ describe('Tool Discovery Functions', () => {
|
|
|
228
228
|
createAIMessage('Searching...', [
|
|
229
229
|
{
|
|
230
230
|
id: 'call_1',
|
|
231
|
-
name: Constants.
|
|
231
|
+
name: Constants.TOOL_SEARCH,
|
|
232
232
|
args: { pattern: 'test' },
|
|
233
233
|
},
|
|
234
234
|
]),
|
|
235
235
|
new ToolMessage({
|
|
236
236
|
content: 'Error occurred',
|
|
237
237
|
tool_call_id: 'call_1',
|
|
238
|
-
name: Constants.
|
|
238
|
+
name: Constants.TOOL_SEARCH,
|
|
239
239
|
// No artifact
|
|
240
240
|
}),
|
|
241
241
|
];
|
|
@@ -251,7 +251,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
251
251
|
createAIMessage('Searching...', [
|
|
252
252
|
{
|
|
253
253
|
id: 'call_1',
|
|
254
|
-
name: Constants.
|
|
254
|
+
name: Constants.TOOL_SEARCH,
|
|
255
255
|
args: { pattern: 'test' },
|
|
256
256
|
},
|
|
257
257
|
]),
|
|
@@ -271,7 +271,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
271
271
|
createAIMessage('First search', [
|
|
272
272
|
{
|
|
273
273
|
id: 'first_call',
|
|
274
|
-
name: Constants.
|
|
274
|
+
name: Constants.TOOL_SEARCH,
|
|
275
275
|
args: { pattern: 'first' },
|
|
276
276
|
},
|
|
277
277
|
]),
|
|
@@ -280,7 +280,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
280
280
|
createAIMessage('Second search', [
|
|
281
281
|
{
|
|
282
282
|
id: 'second_call',
|
|
283
|
-
name: Constants.
|
|
283
|
+
name: Constants.TOOL_SEARCH,
|
|
284
284
|
args: { pattern: 'second' },
|
|
285
285
|
},
|
|
286
286
|
]),
|
|
@@ -301,7 +301,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
301
301
|
createAIMessage('Searching...', [
|
|
302
302
|
{
|
|
303
303
|
id: 'call_1',
|
|
304
|
-
name: Constants.
|
|
304
|
+
name: Constants.TOOL_SEARCH,
|
|
305
305
|
args: { pattern: 'test' },
|
|
306
306
|
},
|
|
307
307
|
]),
|
|
@@ -335,7 +335,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
335
335
|
new ToolMessage({
|
|
336
336
|
content: 'Result',
|
|
337
337
|
tool_call_id: 'orphan',
|
|
338
|
-
name: Constants.
|
|
338
|
+
name: Constants.TOOL_SEARCH,
|
|
339
339
|
}),
|
|
340
340
|
];
|
|
341
341
|
|
|
@@ -364,7 +364,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
364
364
|
createAIMessage('Working...', [
|
|
365
365
|
{
|
|
366
366
|
id: 'search_call',
|
|
367
|
-
name: Constants.
|
|
367
|
+
name: Constants.TOOL_SEARCH,
|
|
368
368
|
args: { pattern: 'test' },
|
|
369
369
|
},
|
|
370
370
|
{ id: 'weather_call', name: 'get_weather', args: { city: 'NYC' } },
|
|
@@ -384,7 +384,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
384
384
|
createAIMessage('Searching...', [
|
|
385
385
|
{
|
|
386
386
|
id: 'old_call',
|
|
387
|
-
name: Constants.
|
|
387
|
+
name: Constants.TOOL_SEARCH,
|
|
388
388
|
args: { pattern: 'old' },
|
|
389
389
|
},
|
|
390
390
|
]),
|
|
@@ -410,7 +410,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
410
410
|
createAIMessage('Searching...', [
|
|
411
411
|
{
|
|
412
412
|
id: 'call_1',
|
|
413
|
-
name: Constants.
|
|
413
|
+
name: Constants.TOOL_SEARCH,
|
|
414
414
|
args: { pattern: 'test' },
|
|
415
415
|
},
|
|
416
416
|
]),
|
|
@@ -446,7 +446,7 @@ describe('Tool Discovery Functions', () => {
|
|
|
446
446
|
createAIMessage('Searching...', [
|
|
447
447
|
{
|
|
448
448
|
id: 'call_1',
|
|
449
|
-
name: Constants.
|
|
449
|
+
name: Constants.TOOL_SEARCH,
|
|
450
450
|
args: { pattern: 'test' },
|
|
451
451
|
},
|
|
452
452
|
]),
|