@illuma-ai/agents 1.1.21 → 1.1.22

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 (241) hide show
  1. package/dist/cjs/graphs/Graph.cjs +12 -1
  2. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  3. package/dist/cjs/graphs/MultiAgentGraph.cjs +85 -1
  4. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
  5. package/dist/cjs/run.cjs +20 -9
  6. package/dist/cjs/run.cjs.map +1 -1
  7. package/dist/esm/graphs/Graph.mjs +12 -1
  8. package/dist/esm/graphs/Graph.mjs.map +1 -1
  9. package/dist/esm/graphs/MultiAgentGraph.mjs +85 -1
  10. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  11. package/dist/esm/run.mjs +20 -9
  12. package/dist/esm/run.mjs.map +1 -1
  13. package/dist/types/graphs/MultiAgentGraph.d.ts +17 -0
  14. package/package.json +1 -1
  15. package/src/graphs/Graph.ts +12 -1
  16. package/src/graphs/MultiAgentGraph.ts +105 -1
  17. package/src/graphs/__tests__/multi-agent-delegate.test.ts +191 -0
  18. package/src/run.ts +20 -11
  19. package/src/scripts/test-bedrock-handoff-autonomous.ts +231 -0
  20. package/src/agents/AgentContext.js +0 -782
  21. package/src/agents/AgentContext.test.js +0 -421
  22. package/src/agents/__tests__/AgentContext.test.js +0 -678
  23. package/src/agents/__tests__/resolveStructuredOutputMode.test.js +0 -117
  24. package/src/common/enum.js +0 -192
  25. package/src/common/index.js +0 -3
  26. package/src/events.js +0 -166
  27. package/src/graphs/Graph.js +0 -1857
  28. package/src/graphs/MultiAgentGraph.js +0 -1092
  29. package/src/graphs/__tests__/structured-output.integration.test.js +0 -624
  30. package/src/graphs/__tests__/structured-output.test.js +0 -144
  31. package/src/graphs/contextManagement.e2e.test.js +0 -718
  32. package/src/graphs/contextManagement.test.js +0 -485
  33. package/src/graphs/handoffValidation.test.js +0 -276
  34. package/src/graphs/index.js +0 -3
  35. package/src/index.js +0 -28
  36. package/src/instrumentation.js +0 -21
  37. package/src/llm/anthropic/index.js +0 -319
  38. package/src/llm/anthropic/types.js +0 -46
  39. package/src/llm/anthropic/utils/message_inputs.js +0 -627
  40. package/src/llm/anthropic/utils/message_outputs.js +0 -290
  41. package/src/llm/anthropic/utils/output_parsers.js +0 -89
  42. package/src/llm/anthropic/utils/tools.js +0 -25
  43. package/src/llm/bedrock/__tests__/bedrock-caching.test.js +0 -392
  44. package/src/llm/bedrock/index.js +0 -303
  45. package/src/llm/bedrock/types.js +0 -2
  46. package/src/llm/bedrock/utils/index.js +0 -6
  47. package/src/llm/bedrock/utils/message_inputs.js +0 -463
  48. package/src/llm/bedrock/utils/message_outputs.js +0 -269
  49. package/src/llm/fake.js +0 -92
  50. package/src/llm/google/index.js +0 -215
  51. package/src/llm/google/types.js +0 -12
  52. package/src/llm/google/utils/common.js +0 -670
  53. package/src/llm/google/utils/tools.js +0 -111
  54. package/src/llm/google/utils/zod_to_genai_parameters.js +0 -47
  55. package/src/llm/openai/index.js +0 -1033
  56. package/src/llm/openai/types.js +0 -2
  57. package/src/llm/openai/utils/index.js +0 -756
  58. package/src/llm/openai/utils/isReasoningModel.test.js +0 -79
  59. package/src/llm/openrouter/index.js +0 -261
  60. package/src/llm/openrouter/reasoning.test.js +0 -181
  61. package/src/llm/providers.js +0 -36
  62. package/src/llm/text.js +0 -65
  63. package/src/llm/vertexai/index.js +0 -402
  64. package/src/messages/__tests__/tools.test.js +0 -392
  65. package/src/messages/cache.js +0 -404
  66. package/src/messages/cache.test.js +0 -1167
  67. package/src/messages/content.js +0 -48
  68. package/src/messages/content.test.js +0 -314
  69. package/src/messages/core.js +0 -359
  70. package/src/messages/ensureThinkingBlock.test.js +0 -997
  71. package/src/messages/format.js +0 -973
  72. package/src/messages/formatAgentMessages.test.js +0 -2278
  73. package/src/messages/formatAgentMessages.tools.test.js +0 -362
  74. package/src/messages/formatMessage.test.js +0 -608
  75. package/src/messages/ids.js +0 -18
  76. package/src/messages/index.js +0 -9
  77. package/src/messages/labelContentByAgent.test.js +0 -725
  78. package/src/messages/prune.js +0 -438
  79. package/src/messages/reducer.js +0 -60
  80. package/src/messages/shiftIndexTokenCountMap.test.js +0 -63
  81. package/src/messages/summarize.js +0 -146
  82. package/src/messages/summarize.test.js +0 -332
  83. package/src/messages/tools.js +0 -90
  84. package/src/mockStream.js +0 -81
  85. package/src/prompts/collab.js +0 -7
  86. package/src/prompts/index.js +0 -3
  87. package/src/prompts/taskmanager.js +0 -58
  88. package/src/run.js +0 -427
  89. package/src/schemas/index.js +0 -3
  90. package/src/schemas/schema-preparation.test.js +0 -370
  91. package/src/schemas/validate.js +0 -314
  92. package/src/schemas/validate.test.js +0 -264
  93. package/src/scripts/abort.js +0 -127
  94. package/src/scripts/ant_web_search.js +0 -130
  95. package/src/scripts/ant_web_search_edge_case.js +0 -133
  96. package/src/scripts/ant_web_search_error_edge_case.js +0 -119
  97. package/src/scripts/args.js +0 -41
  98. package/src/scripts/bedrock-cache-debug.js +0 -186
  99. package/src/scripts/bedrock-content-aggregation-test.js +0 -195
  100. package/src/scripts/bedrock-merge-test.js +0 -80
  101. package/src/scripts/bedrock-parallel-tools-test.js +0 -150
  102. package/src/scripts/caching.js +0 -106
  103. package/src/scripts/cli.js +0 -152
  104. package/src/scripts/cli2.js +0 -119
  105. package/src/scripts/cli3.js +0 -163
  106. package/src/scripts/cli4.js +0 -165
  107. package/src/scripts/cli5.js +0 -165
  108. package/src/scripts/code_exec.js +0 -171
  109. package/src/scripts/code_exec_files.js +0 -180
  110. package/src/scripts/code_exec_multi_session.js +0 -185
  111. package/src/scripts/code_exec_ptc.js +0 -265
  112. package/src/scripts/code_exec_session.js +0 -217
  113. package/src/scripts/code_exec_simple.js +0 -120
  114. package/src/scripts/content.js +0 -111
  115. package/src/scripts/empty_input.js +0 -125
  116. package/src/scripts/handoff-test.js +0 -96
  117. package/src/scripts/image.js +0 -138
  118. package/src/scripts/memory.js +0 -83
  119. package/src/scripts/multi-agent-chain.js +0 -271
  120. package/src/scripts/multi-agent-conditional.js +0 -185
  121. package/src/scripts/multi-agent-document-review-chain.js +0 -171
  122. package/src/scripts/multi-agent-hybrid-flow.js +0 -264
  123. package/src/scripts/multi-agent-parallel-start.js +0 -214
  124. package/src/scripts/multi-agent-parallel.js +0 -346
  125. package/src/scripts/multi-agent-sequence.js +0 -184
  126. package/src/scripts/multi-agent-supervisor.js +0 -324
  127. package/src/scripts/multi-agent-test.js +0 -147
  128. package/src/scripts/parallel-asymmetric-tools-test.js +0 -202
  129. package/src/scripts/parallel-full-metadata-test.js +0 -176
  130. package/src/scripts/parallel-tools-test.js +0 -256
  131. package/src/scripts/programmatic_exec.js +0 -277
  132. package/src/scripts/programmatic_exec_agent.js +0 -168
  133. package/src/scripts/search.js +0 -118
  134. package/src/scripts/sequential-full-metadata-test.js +0 -143
  135. package/src/scripts/simple.js +0 -174
  136. package/src/scripts/single-agent-metadata-test.js +0 -152
  137. package/src/scripts/stream.js +0 -113
  138. package/src/scripts/test-custom-prompt-key.js +0 -132
  139. package/src/scripts/test-handoff-input.js +0 -143
  140. package/src/scripts/test-handoff-preamble.js +0 -227
  141. package/src/scripts/test-handoff-steering.js +0 -353
  142. package/src/scripts/test-multi-agent-list-handoff.js +0 -318
  143. package/src/scripts/test-parallel-agent-labeling.js +0 -253
  144. package/src/scripts/test-parallel-handoffs.js +0 -229
  145. package/src/scripts/test-thinking-handoff-bedrock.js +0 -132
  146. package/src/scripts/test-thinking-handoff.js +0 -132
  147. package/src/scripts/test-thinking-to-thinking-handoff-bedrock.js +0 -140
  148. package/src/scripts/test-tool-before-handoff-role-order.js +0 -223
  149. package/src/scripts/test-tools-before-handoff.js +0 -187
  150. package/src/scripts/test_code_api.js +0 -263
  151. package/src/scripts/thinking-bedrock.js +0 -128
  152. package/src/scripts/thinking-vertexai.js +0 -130
  153. package/src/scripts/thinking.js +0 -134
  154. package/src/scripts/tool_search.js +0 -114
  155. package/src/scripts/tools.js +0 -125
  156. package/src/specs/agent-handoffs-bedrock.integration.test.js +0 -280
  157. package/src/specs/agent-handoffs.test.js +0 -924
  158. package/src/specs/anthropic.simple.test.js +0 -287
  159. package/src/specs/azure.simple.test.js +0 -381
  160. package/src/specs/cache.simple.test.js +0 -282
  161. package/src/specs/custom-event-await.test.js +0 -148
  162. package/src/specs/deepseek.simple.test.js +0 -189
  163. package/src/specs/emergency-prune.test.js +0 -308
  164. package/src/specs/moonshot.simple.test.js +0 -237
  165. package/src/specs/observability.integration.test.js +0 -1337
  166. package/src/specs/openai.simple.test.js +0 -233
  167. package/src/specs/openrouter.simple.test.js +0 -202
  168. package/src/specs/prune.test.js +0 -733
  169. package/src/specs/reasoning.test.js +0 -144
  170. package/src/specs/spec.utils.js +0 -4
  171. package/src/specs/thinking-handoff.test.js +0 -486
  172. package/src/specs/thinking-prune.test.js +0 -600
  173. package/src/specs/token-distribution-edge-case.test.js +0 -246
  174. package/src/specs/token-memoization.test.js +0 -32
  175. package/src/specs/tokens.test.js +0 -49
  176. package/src/specs/tool-error.test.js +0 -139
  177. package/src/splitStream.js +0 -204
  178. package/src/splitStream.test.js +0 -504
  179. package/src/stream.js +0 -650
  180. package/src/stream.test.js +0 -225
  181. package/src/test/mockTools.js +0 -340
  182. package/src/tools/BrowserTools.js +0 -245
  183. package/src/tools/Calculator.js +0 -38
  184. package/src/tools/Calculator.test.js +0 -225
  185. package/src/tools/CodeExecutor.js +0 -233
  186. package/src/tools/ProgrammaticToolCalling.js +0 -602
  187. package/src/tools/StreamingToolCallBuffer.js +0 -179
  188. package/src/tools/ToolNode.js +0 -930
  189. package/src/tools/ToolSearch.js +0 -904
  190. package/src/tools/__tests__/BrowserTools.test.js +0 -306
  191. package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.js +0 -276
  192. package/src/tools/__tests__/ProgrammaticToolCalling.test.js +0 -807
  193. package/src/tools/__tests__/StreamingToolCallBuffer.test.js +0 -175
  194. package/src/tools/__tests__/ToolApproval.test.js +0 -675
  195. package/src/tools/__tests__/ToolNode.recovery.test.js +0 -200
  196. package/src/tools/__tests__/ToolNode.session.test.js +0 -319
  197. package/src/tools/__tests__/ToolSearch.integration.test.js +0 -125
  198. package/src/tools/__tests__/ToolSearch.test.js +0 -812
  199. package/src/tools/__tests__/handlers.test.js +0 -799
  200. package/src/tools/__tests__/truncation-recovery.integration.test.js +0 -362
  201. package/src/tools/handlers.js +0 -306
  202. package/src/tools/schema.js +0 -25
  203. package/src/tools/search/anthropic.js +0 -34
  204. package/src/tools/search/content.js +0 -116
  205. package/src/tools/search/content.test.js +0 -133
  206. package/src/tools/search/firecrawl.js +0 -173
  207. package/src/tools/search/format.js +0 -198
  208. package/src/tools/search/highlights.js +0 -241
  209. package/src/tools/search/index.js +0 -3
  210. package/src/tools/search/jina-reranker.test.js +0 -106
  211. package/src/tools/search/rerankers.js +0 -165
  212. package/src/tools/search/schema.js +0 -102
  213. package/src/tools/search/search.js +0 -561
  214. package/src/tools/search/serper-scraper.js +0 -126
  215. package/src/tools/search/test.js +0 -129
  216. package/src/tools/search/tool.js +0 -453
  217. package/src/tools/search/types.js +0 -2
  218. package/src/tools/search/utils.js +0 -59
  219. package/src/types/graph.js +0 -24
  220. package/src/types/graph.test.js +0 -192
  221. package/src/types/index.js +0 -7
  222. package/src/types/llm.js +0 -2
  223. package/src/types/messages.js +0 -2
  224. package/src/types/run.js +0 -2
  225. package/src/types/stream.js +0 -2
  226. package/src/types/tools.js +0 -2
  227. package/src/utils/contextAnalytics.js +0 -79
  228. package/src/utils/contextAnalytics.test.js +0 -166
  229. package/src/utils/events.js +0 -26
  230. package/src/utils/graph.js +0 -11
  231. package/src/utils/handlers.js +0 -65
  232. package/src/utils/index.js +0 -10
  233. package/src/utils/llm.js +0 -21
  234. package/src/utils/llmConfig.js +0 -205
  235. package/src/utils/logging.js +0 -37
  236. package/src/utils/misc.js +0 -51
  237. package/src/utils/run.js +0 -69
  238. package/src/utils/schema.js +0 -21
  239. package/src/utils/title.js +0 -119
  240. package/src/utils/tokens.js +0 -92
  241. package/src/utils/toonFormat.js +0 -379
@@ -1,225 +0,0 @@
1
- import { getChunkContent, createContentAggregator } from './stream';
2
- import { Providers, GraphEvents, StepTypes } from '@/common';
3
- describe('getChunkContent', () => {
4
- it('should handle reasoning content for OpenAI/Azure providers', () => {
5
- const chunk = {
6
- content: 'Regular content',
7
- additional_kwargs: {
8
- reasoning: {
9
- summary: [{ text: 'Reasoning summary text' }],
10
- },
11
- },
12
- };
13
- const result = getChunkContent({
14
- chunk,
15
- provider: Providers.OPENAI,
16
- reasoningKey: 'reasoning',
17
- });
18
- expect(result).toBe('Reasoning summary text');
19
- });
20
- it('should fallback to reasoningKey when no OpenAI reasoning summary', () => {
21
- const chunk = {
22
- content: 'Regular content',
23
- additional_kwargs: {
24
- reasoning_content: 'Reasoning from key',
25
- },
26
- };
27
- const result = getChunkContent({
28
- chunk,
29
- reasoningKey: 'reasoning_content',
30
- });
31
- expect(result).toBe('Reasoning from key');
32
- });
33
- it('should fallback to chunk.content when reasoningKey value is null or undefined', () => {
34
- const chunk = {
35
- content: 'Fallback content',
36
- additional_kwargs: {
37
- reasoning_content: null,
38
- },
39
- };
40
- const result = getChunkContent({
41
- chunk,
42
- reasoningKey: 'reasoning_content',
43
- });
44
- expect(result).toBe('Fallback content');
45
- });
46
- it('should fallback to chunk.content when reasoningKey value is empty string', () => {
47
- const chunk = {
48
- content: ' can',
49
- additional_kwargs: {
50
- reasoning_content: '',
51
- },
52
- };
53
- const result = getChunkContent({
54
- chunk,
55
- reasoningKey: 'reasoning_content',
56
- });
57
- expect(result).toBe(' can');
58
- });
59
- it('should return undefined when no content is available', () => {
60
- const chunk = {
61
- additional_kwargs: {},
62
- };
63
- const result = getChunkContent({
64
- chunk,
65
- reasoningKey: 'reasoning',
66
- });
67
- expect(result).toBeUndefined();
68
- });
69
- it('should handle missing chunk gracefully', () => {
70
- const result = getChunkContent({
71
- reasoningKey: 'reasoning',
72
- });
73
- expect(result).toBeUndefined();
74
- });
75
- });
76
- describe('createContentAggregator — tool call delta streaming', () => {
77
- it('should allow delta updates when content part already has a name', () => {
78
- const { contentParts, aggregateContent } = createContentAggregator();
79
- // Step 1: ON_RUN_STEP creates the initial tool call with name
80
- aggregateContent({
81
- event: GraphEvents.ON_RUN_STEP,
82
- data: {
83
- id: 'step-1',
84
- index: 0,
85
- type: StepTypes.TOOL_CALLS,
86
- stepDetails: {
87
- type: StepTypes.TOOL_CALLS,
88
- tool_calls: [
89
- { id: 'tc-1', name: 'content_tool', args: '{"action":"write"' },
90
- ],
91
- },
92
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
- },
94
- });
95
- // Verify initial content part was created with tool name
96
- expect(contentParts[0]).toBeDefined();
97
- expect(contentParts[0].tool_call?.name).toBe('content_tool');
98
- const initialArgs = contentParts[0].tool_call?.args;
99
- // Step 2: ON_RUN_STEP_DELTA — should UPDATE args (not be dropped)
100
- aggregateContent({
101
- event: GraphEvents.ON_RUN_STEP_DELTA,
102
- data: {
103
- id: 'step-1',
104
- delta: {
105
- type: StepTypes.TOOL_CALLS,
106
- tool_calls: [{ args: ',"content":"hello world"', name: undefined }],
107
- },
108
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
109
- },
110
- });
111
- // Verify args were UPDATED (delta was not dropped)
112
- const updatedArgs = contentParts[0].tool_call?.args;
113
- expect(updatedArgs).not.toBe(initialArgs);
114
- expect(updatedArgs).toContain('content');
115
- expect(updatedArgs).toContain('hello world');
116
- });
117
- it('should still drop delta updates when no content part exists yet', () => {
118
- const { contentParts, aggregateContent } = createContentAggregator();
119
- // Simulate a delta arriving BEFORE the initial ON_RUN_STEP
120
- // This creates an entry at index 0 via the delta but with no name
121
- aggregateContent({
122
- event: GraphEvents.ON_RUN_STEP,
123
- data: {
124
- id: 'step-orphan',
125
- index: 5,
126
- type: StepTypes.TOOL_CALLS,
127
- stepDetails: {
128
- type: StepTypes.TOOL_CALLS,
129
- tool_calls: [],
130
- },
131
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
132
- },
133
- });
134
- // Delta for an index that has no content part (index 5 has no tool call)
135
- aggregateContent({
136
- event: GraphEvents.ON_RUN_STEP_DELTA,
137
- data: {
138
- id: 'step-orphan',
139
- delta: {
140
- type: StepTypes.TOOL_CALLS,
141
- tool_calls: [{ args: '{"some":"data"}', name: undefined }],
142
- },
143
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
144
- },
145
- });
146
- // contentParts[5] should remain undefined or have no valid tool call name
147
- const part = contentParts[5];
148
- // The part either doesn't exist or has empty name — delta should have been dropped
149
- if (part?.tool_call != null) {
150
- expect(part.tool_call.name).toBe('');
151
- }
152
- });
153
- it('should handle the full lifecycle: ON_RUN_STEP → deltas → ON_RUN_STEP_COMPLETED', () => {
154
- const { contentParts, aggregateContent } = createContentAggregator();
155
- // Step 1: Initial tool call
156
- aggregateContent({
157
- event: GraphEvents.ON_RUN_STEP,
158
- data: {
159
- id: 'step-write',
160
- index: 0,
161
- type: StepTypes.TOOL_CALLS,
162
- stepDetails: {
163
- type: StepTypes.TOOL_CALLS,
164
- tool_calls: [
165
- { id: 'tc-write', name: 'content_tool', args: '{"action":"write"' },
166
- ],
167
- },
168
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
169
- },
170
- });
171
- // Step 2: Multiple delta updates growing the args
172
- aggregateContent({
173
- event: GraphEvents.ON_RUN_STEP_DELTA,
174
- data: {
175
- id: 'step-write',
176
- delta: {
177
- type: StepTypes.TOOL_CALLS,
178
- tool_calls: [{ args: ',"name":"Dashboard.tsx"', name: undefined }],
179
- },
180
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
181
- },
182
- });
183
- aggregateContent({
184
- event: GraphEvents.ON_RUN_STEP_DELTA,
185
- data: {
186
- id: 'step-write',
187
- delta: {
188
- type: StepTypes.TOOL_CALLS,
189
- tool_calls: [{ args: ',"content":"import React', name: undefined }],
190
- },
191
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
192
- },
193
- });
194
- // Verify args accumulated progressively
195
- const midArgs = contentParts[0].tool_call?.args;
196
- expect(midArgs).toContain('Dashboard.tsx');
197
- expect(midArgs).toContain('import React');
198
- // Step 3: Completion with full output
199
- aggregateContent({
200
- event: GraphEvents.ON_RUN_STEP_COMPLETED,
201
- data: {
202
- result: {
203
- id: 'step-write',
204
- index: 0,
205
- type: 'tool_call',
206
- tool_call: {
207
- id: 'tc-write',
208
- name: 'content_tool',
209
- args: '{"action":"write","name":"Dashboard.tsx","content":"import React..."}',
210
- output: 'Stored "Dashboard.tsx" (content_id: abc). 176 lines, 5000 chars.',
211
- progress: 1,
212
- },
213
- },
214
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
215
- },
216
- });
217
- // Final content part should have output and progress=1
218
- const final = contentParts[0]
219
- .tool_call;
220
- expect(final.output).toContain('Stored');
221
- expect(final.progress).toBe(1);
222
- expect(final.name).toBe('content_tool');
223
- });
224
- });
225
- //# sourceMappingURL=stream.test.js.map
@@ -1,340 +0,0 @@
1
- // src/test/mockTools.ts
2
- /**
3
- * Shared mock tools for testing across all test scripts.
4
- * Centralizes tool definitions to follow DRY principles.
5
- */
6
- import { tool } from '@langchain/core/tools';
7
- // ============================================================================
8
- // Mock Tool Implementations
9
- // ============================================================================
10
- /**
11
- * Mock get_team_members tool - returns list of team members
12
- */
13
- export function createGetTeamMembersTool() {
14
- return tool(async () => {
15
- await new Promise((resolve) => setTimeout(resolve, 50));
16
- return [
17
- { id: 'u1', name: 'Alice', department: 'Engineering' },
18
- { id: 'u2', name: 'Bob', department: 'Marketing' },
19
- { id: 'u3', name: 'Charlie', department: 'Engineering' },
20
- ];
21
- }, {
22
- name: 'get_team_members',
23
- description: 'Get list of team members. Returns array of objects with id, name, and department fields.',
24
- schema: { type: 'object', properties: {}, required: [] },
25
- });
26
- }
27
- /**
28
- * Mock get_expenses tool - returns expense records for a user
29
- */
30
- export function createGetExpensesTool() {
31
- const expenseData = {
32
- u1: [
33
- { amount: 150.0, category: 'travel' },
34
- { amount: 75.5, category: 'meals' },
35
- ],
36
- u2: [
37
- { amount: 200.0, category: 'marketing' },
38
- { amount: 50.0, category: 'meals' },
39
- { amount: 300.0, category: 'events' },
40
- ],
41
- u3: [
42
- { amount: 500.0, category: 'equipment' },
43
- { amount: 120.0, category: 'travel' },
44
- { amount: 80.0, category: 'meals' },
45
- ],
46
- };
47
- return tool(async (input) => {
48
- const { user_id } = input;
49
- await new Promise((resolve) => setTimeout(resolve, 30));
50
- return expenseData[user_id] ?? [];
51
- }, {
52
- name: 'get_expenses',
53
- description: 'Get expense records for a user. Returns array of objects with amount and category fields.',
54
- schema: {
55
- type: 'object',
56
- properties: {
57
- user_id: {
58
- type: 'string',
59
- description: 'The user ID to fetch expenses for',
60
- },
61
- },
62
- required: ['user_id'],
63
- },
64
- });
65
- }
66
- /**
67
- * Mock get_weather tool - returns weather data for a city
68
- */
69
- export function createGetWeatherTool() {
70
- const weatherData = {
71
- 'San Francisco': { temperature: 65, condition: 'Foggy' },
72
- 'New York': { temperature: 75, condition: 'Sunny' },
73
- London: { temperature: 55, condition: 'Rainy' },
74
- Tokyo: { temperature: 80, condition: 'Humid' },
75
- SF: { temperature: 65, condition: 'Foggy' },
76
- NYC: { temperature: 75, condition: 'Sunny' },
77
- };
78
- return tool(async (input) => {
79
- const { city } = input;
80
- await new Promise((resolve) => setTimeout(resolve, 40));
81
- const weather = weatherData[city];
82
- if (!weather) {
83
- throw new Error(`Weather data not available for city: ${city}`);
84
- }
85
- return weather;
86
- }, {
87
- name: 'get_weather',
88
- description: 'Get current weather for a city. Returns object with temperature (number) and condition (string) fields.',
89
- schema: {
90
- type: 'object',
91
- properties: {
92
- city: { type: 'string', description: 'City name' },
93
- },
94
- required: ['city'],
95
- },
96
- });
97
- }
98
- /**
99
- * Mock calculator tool - evaluates mathematical expressions
100
- */
101
- export function createCalculatorTool() {
102
- return tool(async (input) => {
103
- const { expression } = input;
104
- await new Promise((resolve) => setTimeout(resolve, 10));
105
- // Simple eval for demo (in production, use a proper math parser)
106
- const result = eval(expression);
107
- return { expression, result };
108
- }, {
109
- name: 'calculator',
110
- description: 'Evaluate a mathematical expression',
111
- schema: {
112
- type: 'object',
113
- properties: {
114
- expression: {
115
- type: 'string',
116
- description: 'Mathematical expression to evaluate',
117
- },
118
- },
119
- required: ['expression'],
120
- },
121
- });
122
- }
123
- // ============================================================================
124
- // Tool Registry Definitions
125
- // ============================================================================
126
- /**
127
- * Creates a tool registry for programmatic tool calling tests.
128
- * Tools are configured with allowed_callers to demonstrate classification.
129
- */
130
- export function createProgrammaticToolRegistry() {
131
- const toolDefs = [
132
- {
133
- name: 'get_team_members',
134
- description: 'Get list of team members. Returns array of objects with id, name, and department fields.',
135
- parameters: {
136
- type: 'object',
137
- properties: {},
138
- required: [],
139
- },
140
- allowed_callers: ['code_execution'], // Programmatic-only
141
- defer_loading: false,
142
- },
143
- {
144
- name: 'get_expenses',
145
- description: 'Get expense records for a user. Returns array of objects with amount and category fields.',
146
- parameters: {
147
- type: 'object',
148
- properties: {
149
- user_id: {
150
- type: 'string',
151
- description: 'The user ID to fetch expenses for',
152
- },
153
- },
154
- required: ['user_id'],
155
- },
156
- allowed_callers: ['code_execution'], // Programmatic-only
157
- defer_loading: false,
158
- },
159
- {
160
- name: 'get_weather',
161
- description: 'Get current weather for a city. Returns object with temperature (number) and condition (string) fields.',
162
- parameters: {
163
- type: 'object',
164
- properties: {
165
- city: {
166
- type: 'string',
167
- description: 'City name',
168
- },
169
- },
170
- required: ['city'],
171
- },
172
- allowed_callers: ['direct', 'code_execution'], // Both contexts
173
- defer_loading: false,
174
- },
175
- {
176
- name: 'calculator',
177
- description: 'Evaluate a mathematical expression',
178
- parameters: {
179
- type: 'object',
180
- properties: {
181
- expression: {
182
- type: 'string',
183
- description: 'Mathematical expression to evaluate',
184
- },
185
- },
186
- required: ['expression'],
187
- },
188
- allowed_callers: ['code_execution'], // Programmatic-only
189
- defer_loading: false,
190
- },
191
- ];
192
- return new Map(toolDefs.map((t) => [t.name, t]));
193
- }
194
- /**
195
- * Creates a sample tool registry for tool search tests.
196
- * Includes mix of deferred and non-deferred tools.
197
- */
198
- export function createToolSearchToolRegistry() {
199
- const tools = [
200
- {
201
- name: 'get_expenses',
202
- description: 'Retrieve expense records from the database. Supports filtering by date range, category, and amount.',
203
- parameters: {
204
- type: 'object',
205
- properties: {
206
- start_date: {
207
- type: 'string',
208
- description: 'Start date for filtering',
209
- },
210
- end_date: { type: 'string', description: 'End date for filtering' },
211
- category: { type: 'string', description: 'Expense category' },
212
- },
213
- },
214
- defer_loading: true,
215
- },
216
- {
217
- name: 'calculate_expense_totals',
218
- description: 'Calculate total expenses by category or time period. Returns aggregated financial data.',
219
- parameters: {
220
- type: 'object',
221
- properties: {
222
- group_by: {
223
- type: 'string',
224
- description: 'Group by category or month',
225
- },
226
- },
227
- },
228
- defer_loading: true,
229
- },
230
- {
231
- name: 'create_budget',
232
- description: 'Create a new budget plan with spending limits for different categories.',
233
- parameters: {
234
- type: 'object',
235
- properties: {
236
- name: { type: 'string', description: 'Budget name' },
237
- limits: { type: 'object', description: 'Category spending limits' },
238
- },
239
- },
240
- defer_loading: true,
241
- },
242
- {
243
- name: 'get_weather',
244
- description: 'Get current weather conditions for a specified location.',
245
- parameters: {
246
- type: 'object',
247
- properties: {
248
- location: { type: 'string', description: 'City or coordinates' },
249
- },
250
- },
251
- defer_loading: true,
252
- },
253
- {
254
- name: 'get_forecast',
255
- description: 'Get weather forecast for the next 7 days for a location.',
256
- parameters: {
257
- type: 'object',
258
- properties: {
259
- location: { type: 'string', description: 'City or coordinates' },
260
- days: { type: 'number', description: 'Number of days to forecast' },
261
- },
262
- },
263
- defer_loading: true,
264
- },
265
- {
266
- name: 'send_email',
267
- description: 'Send an email to one or more recipients with attachments support.',
268
- parameters: {
269
- type: 'object',
270
- properties: {
271
- to: {
272
- type: 'array',
273
- items: { type: 'string' },
274
- description: 'Recipients',
275
- },
276
- subject: { type: 'string', description: 'Email subject' },
277
- body: { type: 'string', description: 'Email body' },
278
- },
279
- },
280
- defer_loading: true,
281
- },
282
- {
283
- name: 'search_files',
284
- description: 'Search for files in the file system by name or content.',
285
- parameters: {
286
- type: 'object',
287
- properties: {
288
- query: { type: 'string', description: 'Search query' },
289
- path: { type: 'string', description: 'Directory to search in' },
290
- },
291
- },
292
- defer_loading: true,
293
- },
294
- {
295
- name: 'run_database_query',
296
- description: 'Execute a SQL query against the database and return results.',
297
- parameters: {
298
- type: 'object',
299
- properties: {
300
- query: { type: 'string', description: 'SQL query to execute' },
301
- database: { type: 'string', description: 'Target database' },
302
- },
303
- },
304
- defer_loading: true,
305
- },
306
- {
307
- name: 'generate_report',
308
- description: 'Generate a PDF or Excel report from data with customizable templates.',
309
- parameters: {
310
- type: 'object',
311
- properties: {
312
- template: { type: 'string', description: 'Report template name' },
313
- format: { type: 'string', description: 'Output format: pdf or xlsx' },
314
- data: { type: 'object', description: 'Data to include in report' },
315
- },
316
- },
317
- defer_loading: true,
318
- },
319
- {
320
- name: 'translate_text',
321
- description: 'Translate text between languages using machine translation.',
322
- parameters: {
323
- type: 'object',
324
- properties: {
325
- text: { type: 'string', description: 'Text to translate' },
326
- source_lang: { type: 'string', description: 'Source language code' },
327
- target_lang: { type: 'string', description: 'Target language code' },
328
- },
329
- },
330
- defer_loading: true,
331
- },
332
- {
333
- name: 'calculator',
334
- description: 'Perform mathematical calculations. Supports basic arithmetic and scientific functions.',
335
- defer_loading: false, // Not deferred - should be excluded by default
336
- },
337
- ];
338
- return new Map(tools.map((t) => [t.name, t]));
339
- }
340
- //# sourceMappingURL=mockTools.js.map