@illuma-ai/agents 1.1.20 → 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 (246) 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/llm/bedrock/index.cjs +14 -0
  6. package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
  7. package/dist/cjs/run.cjs +20 -9
  8. package/dist/cjs/run.cjs.map +1 -1
  9. package/dist/esm/graphs/Graph.mjs +12 -1
  10. package/dist/esm/graphs/Graph.mjs.map +1 -1
  11. package/dist/esm/graphs/MultiAgentGraph.mjs +85 -1
  12. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  13. package/dist/esm/llm/bedrock/index.mjs +14 -0
  14. package/dist/esm/llm/bedrock/index.mjs.map +1 -1
  15. package/dist/esm/run.mjs +20 -9
  16. package/dist/esm/run.mjs.map +1 -1
  17. package/dist/types/graphs/MultiAgentGraph.d.ts +17 -0
  18. package/package.json +1 -1
  19. package/src/graphs/Graph.ts +12 -1
  20. package/src/graphs/MultiAgentGraph.ts +105 -1
  21. package/src/graphs/__tests__/multi-agent-delegate.test.ts +191 -0
  22. package/src/llm/bedrock/index.ts +17 -0
  23. package/src/run.ts +20 -11
  24. package/src/scripts/test-bedrock-handoff-autonomous.ts +231 -0
  25. package/src/agents/AgentContext.js +0 -782
  26. package/src/agents/AgentContext.test.js +0 -421
  27. package/src/agents/__tests__/AgentContext.test.js +0 -678
  28. package/src/agents/__tests__/resolveStructuredOutputMode.test.js +0 -117
  29. package/src/common/enum.js +0 -192
  30. package/src/common/index.js +0 -3
  31. package/src/events.js +0 -166
  32. package/src/graphs/Graph.js +0 -1857
  33. package/src/graphs/MultiAgentGraph.js +0 -1092
  34. package/src/graphs/__tests__/structured-output.integration.test.js +0 -624
  35. package/src/graphs/__tests__/structured-output.test.js +0 -144
  36. package/src/graphs/contextManagement.e2e.test.js +0 -718
  37. package/src/graphs/contextManagement.test.js +0 -485
  38. package/src/graphs/handoffValidation.test.js +0 -276
  39. package/src/graphs/index.js +0 -3
  40. package/src/index.js +0 -28
  41. package/src/instrumentation.js +0 -21
  42. package/src/llm/anthropic/index.js +0 -319
  43. package/src/llm/anthropic/types.js +0 -46
  44. package/src/llm/anthropic/utils/message_inputs.js +0 -627
  45. package/src/llm/anthropic/utils/message_outputs.js +0 -290
  46. package/src/llm/anthropic/utils/output_parsers.js +0 -89
  47. package/src/llm/anthropic/utils/tools.js +0 -25
  48. package/src/llm/bedrock/__tests__/bedrock-caching.test.js +0 -392
  49. package/src/llm/bedrock/index.js +0 -303
  50. package/src/llm/bedrock/types.js +0 -2
  51. package/src/llm/bedrock/utils/index.js +0 -6
  52. package/src/llm/bedrock/utils/message_inputs.js +0 -463
  53. package/src/llm/bedrock/utils/message_outputs.js +0 -269
  54. package/src/llm/fake.js +0 -92
  55. package/src/llm/google/index.js +0 -215
  56. package/src/llm/google/types.js +0 -12
  57. package/src/llm/google/utils/common.js +0 -670
  58. package/src/llm/google/utils/tools.js +0 -111
  59. package/src/llm/google/utils/zod_to_genai_parameters.js +0 -47
  60. package/src/llm/openai/index.js +0 -1033
  61. package/src/llm/openai/types.js +0 -2
  62. package/src/llm/openai/utils/index.js +0 -756
  63. package/src/llm/openai/utils/isReasoningModel.test.js +0 -79
  64. package/src/llm/openrouter/index.js +0 -261
  65. package/src/llm/openrouter/reasoning.test.js +0 -181
  66. package/src/llm/providers.js +0 -36
  67. package/src/llm/text.js +0 -65
  68. package/src/llm/vertexai/index.js +0 -402
  69. package/src/messages/__tests__/tools.test.js +0 -392
  70. package/src/messages/cache.js +0 -404
  71. package/src/messages/cache.test.js +0 -1167
  72. package/src/messages/content.js +0 -48
  73. package/src/messages/content.test.js +0 -314
  74. package/src/messages/core.js +0 -359
  75. package/src/messages/ensureThinkingBlock.test.js +0 -997
  76. package/src/messages/format.js +0 -973
  77. package/src/messages/formatAgentMessages.test.js +0 -2278
  78. package/src/messages/formatAgentMessages.tools.test.js +0 -362
  79. package/src/messages/formatMessage.test.js +0 -608
  80. package/src/messages/ids.js +0 -18
  81. package/src/messages/index.js +0 -9
  82. package/src/messages/labelContentByAgent.test.js +0 -725
  83. package/src/messages/prune.js +0 -438
  84. package/src/messages/reducer.js +0 -60
  85. package/src/messages/shiftIndexTokenCountMap.test.js +0 -63
  86. package/src/messages/summarize.js +0 -146
  87. package/src/messages/summarize.test.js +0 -332
  88. package/src/messages/tools.js +0 -90
  89. package/src/mockStream.js +0 -81
  90. package/src/prompts/collab.js +0 -7
  91. package/src/prompts/index.js +0 -3
  92. package/src/prompts/taskmanager.js +0 -58
  93. package/src/run.js +0 -427
  94. package/src/schemas/index.js +0 -3
  95. package/src/schemas/schema-preparation.test.js +0 -370
  96. package/src/schemas/validate.js +0 -314
  97. package/src/schemas/validate.test.js +0 -264
  98. package/src/scripts/abort.js +0 -127
  99. package/src/scripts/ant_web_search.js +0 -130
  100. package/src/scripts/ant_web_search_edge_case.js +0 -133
  101. package/src/scripts/ant_web_search_error_edge_case.js +0 -119
  102. package/src/scripts/args.js +0 -41
  103. package/src/scripts/bedrock-cache-debug.js +0 -186
  104. package/src/scripts/bedrock-content-aggregation-test.js +0 -195
  105. package/src/scripts/bedrock-merge-test.js +0 -80
  106. package/src/scripts/bedrock-parallel-tools-test.js +0 -150
  107. package/src/scripts/caching.js +0 -106
  108. package/src/scripts/cli.js +0 -152
  109. package/src/scripts/cli2.js +0 -119
  110. package/src/scripts/cli3.js +0 -163
  111. package/src/scripts/cli4.js +0 -165
  112. package/src/scripts/cli5.js +0 -165
  113. package/src/scripts/code_exec.js +0 -171
  114. package/src/scripts/code_exec_files.js +0 -180
  115. package/src/scripts/code_exec_multi_session.js +0 -185
  116. package/src/scripts/code_exec_ptc.js +0 -265
  117. package/src/scripts/code_exec_session.js +0 -217
  118. package/src/scripts/code_exec_simple.js +0 -120
  119. package/src/scripts/content.js +0 -111
  120. package/src/scripts/empty_input.js +0 -125
  121. package/src/scripts/handoff-test.js +0 -96
  122. package/src/scripts/image.js +0 -138
  123. package/src/scripts/memory.js +0 -83
  124. package/src/scripts/multi-agent-chain.js +0 -271
  125. package/src/scripts/multi-agent-conditional.js +0 -185
  126. package/src/scripts/multi-agent-document-review-chain.js +0 -171
  127. package/src/scripts/multi-agent-hybrid-flow.js +0 -264
  128. package/src/scripts/multi-agent-parallel-start.js +0 -214
  129. package/src/scripts/multi-agent-parallel.js +0 -346
  130. package/src/scripts/multi-agent-sequence.js +0 -184
  131. package/src/scripts/multi-agent-supervisor.js +0 -324
  132. package/src/scripts/multi-agent-test.js +0 -147
  133. package/src/scripts/parallel-asymmetric-tools-test.js +0 -202
  134. package/src/scripts/parallel-full-metadata-test.js +0 -176
  135. package/src/scripts/parallel-tools-test.js +0 -256
  136. package/src/scripts/programmatic_exec.js +0 -277
  137. package/src/scripts/programmatic_exec_agent.js +0 -168
  138. package/src/scripts/search.js +0 -118
  139. package/src/scripts/sequential-full-metadata-test.js +0 -143
  140. package/src/scripts/simple.js +0 -174
  141. package/src/scripts/single-agent-metadata-test.js +0 -152
  142. package/src/scripts/stream.js +0 -113
  143. package/src/scripts/test-custom-prompt-key.js +0 -132
  144. package/src/scripts/test-handoff-input.js +0 -143
  145. package/src/scripts/test-handoff-preamble.js +0 -227
  146. package/src/scripts/test-handoff-steering.js +0 -353
  147. package/src/scripts/test-multi-agent-list-handoff.js +0 -318
  148. package/src/scripts/test-parallel-agent-labeling.js +0 -253
  149. package/src/scripts/test-parallel-handoffs.js +0 -229
  150. package/src/scripts/test-thinking-handoff-bedrock.js +0 -132
  151. package/src/scripts/test-thinking-handoff.js +0 -132
  152. package/src/scripts/test-thinking-to-thinking-handoff-bedrock.js +0 -140
  153. package/src/scripts/test-tool-before-handoff-role-order.js +0 -223
  154. package/src/scripts/test-tools-before-handoff.js +0 -187
  155. package/src/scripts/test_code_api.js +0 -263
  156. package/src/scripts/thinking-bedrock.js +0 -128
  157. package/src/scripts/thinking-vertexai.js +0 -130
  158. package/src/scripts/thinking.js +0 -134
  159. package/src/scripts/tool_search.js +0 -114
  160. package/src/scripts/tools.js +0 -125
  161. package/src/specs/agent-handoffs-bedrock.integration.test.js +0 -280
  162. package/src/specs/agent-handoffs.test.js +0 -924
  163. package/src/specs/anthropic.simple.test.js +0 -287
  164. package/src/specs/azure.simple.test.js +0 -381
  165. package/src/specs/cache.simple.test.js +0 -282
  166. package/src/specs/custom-event-await.test.js +0 -148
  167. package/src/specs/deepseek.simple.test.js +0 -189
  168. package/src/specs/emergency-prune.test.js +0 -308
  169. package/src/specs/moonshot.simple.test.js +0 -237
  170. package/src/specs/observability.integration.test.js +0 -1337
  171. package/src/specs/openai.simple.test.js +0 -233
  172. package/src/specs/openrouter.simple.test.js +0 -202
  173. package/src/specs/prune.test.js +0 -733
  174. package/src/specs/reasoning.test.js +0 -144
  175. package/src/specs/spec.utils.js +0 -4
  176. package/src/specs/thinking-handoff.test.js +0 -486
  177. package/src/specs/thinking-prune.test.js +0 -600
  178. package/src/specs/token-distribution-edge-case.test.js +0 -246
  179. package/src/specs/token-memoization.test.js +0 -32
  180. package/src/specs/tokens.test.js +0 -49
  181. package/src/specs/tool-error.test.js +0 -139
  182. package/src/splitStream.js +0 -204
  183. package/src/splitStream.test.js +0 -504
  184. package/src/stream.js +0 -650
  185. package/src/stream.test.js +0 -225
  186. package/src/test/mockTools.js +0 -340
  187. package/src/tools/BrowserTools.js +0 -245
  188. package/src/tools/Calculator.js +0 -38
  189. package/src/tools/Calculator.test.js +0 -225
  190. package/src/tools/CodeExecutor.js +0 -233
  191. package/src/tools/ProgrammaticToolCalling.js +0 -602
  192. package/src/tools/StreamingToolCallBuffer.js +0 -179
  193. package/src/tools/ToolNode.js +0 -930
  194. package/src/tools/ToolSearch.js +0 -904
  195. package/src/tools/__tests__/BrowserTools.test.js +0 -306
  196. package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.js +0 -276
  197. package/src/tools/__tests__/ProgrammaticToolCalling.test.js +0 -807
  198. package/src/tools/__tests__/StreamingToolCallBuffer.test.js +0 -175
  199. package/src/tools/__tests__/ToolApproval.test.js +0 -675
  200. package/src/tools/__tests__/ToolNode.recovery.test.js +0 -200
  201. package/src/tools/__tests__/ToolNode.session.test.js +0 -319
  202. package/src/tools/__tests__/ToolSearch.integration.test.js +0 -125
  203. package/src/tools/__tests__/ToolSearch.test.js +0 -812
  204. package/src/tools/__tests__/handlers.test.js +0 -799
  205. package/src/tools/__tests__/truncation-recovery.integration.test.js +0 -362
  206. package/src/tools/handlers.js +0 -306
  207. package/src/tools/schema.js +0 -25
  208. package/src/tools/search/anthropic.js +0 -34
  209. package/src/tools/search/content.js +0 -116
  210. package/src/tools/search/content.test.js +0 -133
  211. package/src/tools/search/firecrawl.js +0 -173
  212. package/src/tools/search/format.js +0 -198
  213. package/src/tools/search/highlights.js +0 -241
  214. package/src/tools/search/index.js +0 -3
  215. package/src/tools/search/jina-reranker.test.js +0 -106
  216. package/src/tools/search/rerankers.js +0 -165
  217. package/src/tools/search/schema.js +0 -102
  218. package/src/tools/search/search.js +0 -561
  219. package/src/tools/search/serper-scraper.js +0 -126
  220. package/src/tools/search/test.js +0 -129
  221. package/src/tools/search/tool.js +0 -453
  222. package/src/tools/search/types.js +0 -2
  223. package/src/tools/search/utils.js +0 -59
  224. package/src/types/graph.js +0 -24
  225. package/src/types/graph.test.js +0 -192
  226. package/src/types/index.js +0 -7
  227. package/src/types/llm.js +0 -2
  228. package/src/types/messages.js +0 -2
  229. package/src/types/run.js +0 -2
  230. package/src/types/stream.js +0 -2
  231. package/src/types/tools.js +0 -2
  232. package/src/utils/contextAnalytics.js +0 -79
  233. package/src/utils/contextAnalytics.test.js +0 -166
  234. package/src/utils/events.js +0 -26
  235. package/src/utils/graph.js +0 -11
  236. package/src/utils/handlers.js +0 -65
  237. package/src/utils/index.js +0 -10
  238. package/src/utils/llm.js +0 -21
  239. package/src/utils/llmConfig.js +0 -205
  240. package/src/utils/logging.js +0 -37
  241. package/src/utils/misc.js +0 -51
  242. package/src/utils/run.js +0 -69
  243. package/src/utils/schema.js +0 -21
  244. package/src/utils/title.js +0 -119
  245. package/src/utils/tokens.js +0 -92
  246. package/src/utils/toonFormat.js +0 -379
@@ -1,264 +0,0 @@
1
- // src/schemas/validate.test.ts
2
- import { validateStructuredOutput, createValidationErrorMessage, isValidJsonSchema, normalizeJsonSchema, } from './validate';
3
- describe('validateStructuredOutput', () => {
4
- const simpleObjectSchema = {
5
- type: 'object',
6
- properties: {
7
- name: { type: 'string' },
8
- age: { type: 'number' },
9
- },
10
- required: ['name'],
11
- };
12
- describe('basic validation', () => {
13
- it('should validate a correct object', () => {
14
- const result = validateStructuredOutput({ name: 'John', age: 30 }, simpleObjectSchema);
15
- expect(result.success).toBe(true);
16
- expect(result.data).toEqual({ name: 'John', age: 30 });
17
- expect(result.error).toBeUndefined();
18
- });
19
- it('should validate an object with only required fields', () => {
20
- const result = validateStructuredOutput({ name: 'Jane' }, simpleObjectSchema);
21
- expect(result.success).toBe(true);
22
- expect(result.data).toEqual({ name: 'Jane' });
23
- });
24
- it('should fail when required field is missing', () => {
25
- const result = validateStructuredOutput({ age: 25 }, simpleObjectSchema);
26
- expect(result.success).toBe(false);
27
- expect(result.error).toContain('missing required property \'name\'');
28
- expect(result.raw).toEqual({ age: 25 });
29
- });
30
- it('should fail when type is incorrect', () => {
31
- const result = validateStructuredOutput({ name: 123 }, simpleObjectSchema);
32
- expect(result.success).toBe(false);
33
- expect(result.error).toContain('expected string');
34
- });
35
- });
36
- describe('string input parsing', () => {
37
- it('should parse valid JSON string input', () => {
38
- const jsonString = '{"name": "Alice", "age": 28}';
39
- const result = validateStructuredOutput(jsonString, simpleObjectSchema);
40
- expect(result.success).toBe(true);
41
- expect(result.data).toEqual({ name: 'Alice', age: 28 });
42
- });
43
- it('should fail on invalid JSON string', () => {
44
- const invalidJson = '{ name: "Bob" }'; // Missing quotes around key
45
- const result = validateStructuredOutput(invalidJson, simpleObjectSchema);
46
- expect(result.success).toBe(false);
47
- expect(result.error).toContain('Failed to parse output');
48
- });
49
- });
50
- describe('type validation', () => {
51
- it('should validate string type when passed as object property', () => {
52
- // String values at root level get parsed as JSON first, so test nested
53
- const schema = {
54
- type: 'object',
55
- properties: {
56
- value: { type: 'string' },
57
- },
58
- };
59
- expect(validateStructuredOutput({ value: 'hello' }, schema).success).toBe(true);
60
- expect(validateStructuredOutput({ value: 123 }, schema).success).toBe(false);
61
- });
62
- it('should validate number type when passed as object property', () => {
63
- const schema = {
64
- type: 'object',
65
- properties: {
66
- value: { type: 'number' },
67
- },
68
- };
69
- expect(validateStructuredOutput({ value: 42 }, schema).success).toBe(true);
70
- expect(validateStructuredOutput({ value: '42' }, schema).success).toBe(false);
71
- });
72
- it('should validate boolean type when passed as object property', () => {
73
- const schema = {
74
- type: 'object',
75
- properties: {
76
- value: { type: 'boolean' },
77
- },
78
- };
79
- expect(validateStructuredOutput({ value: true }, schema).success).toBe(true);
80
- expect(validateStructuredOutput({ value: false }, schema).success).toBe(true);
81
- expect(validateStructuredOutput({ value: 'true' }, schema).success).toBe(false);
82
- });
83
- it('should validate array type', () => {
84
- const schema = { type: 'array', items: { type: 'string' } };
85
- expect(validateStructuredOutput(['a', 'b'], schema).success).toBe(true);
86
- expect(validateStructuredOutput('not an array', schema).success).toBe(false);
87
- });
88
- it('should validate object type', () => {
89
- const schema = { type: 'object' };
90
- expect(validateStructuredOutput({}, schema).success).toBe(true);
91
- expect(validateStructuredOutput('not an object', schema).success).toBe(false);
92
- });
93
- });
94
- describe('nested object validation', () => {
95
- const nestedSchema = {
96
- type: 'object',
97
- properties: {
98
- user: {
99
- type: 'object',
100
- properties: {
101
- name: { type: 'string' },
102
- email: { type: 'string' },
103
- },
104
- required: ['name'],
105
- },
106
- active: { type: 'boolean' },
107
- },
108
- required: ['user'],
109
- };
110
- it('should validate correct nested object', () => {
111
- const result = validateStructuredOutput({ user: { name: 'John', email: 'john@example.com' }, active: true }, nestedSchema);
112
- expect(result.success).toBe(true);
113
- });
114
- it('should fail on missing nested required field', () => {
115
- const result = validateStructuredOutput({ user: { email: 'john@example.com' } }, nestedSchema);
116
- expect(result.success).toBe(false);
117
- expect(result.error).toContain('missing required property \'name\'');
118
- });
119
- it('should fail on incorrect nested type', () => {
120
- const result = validateStructuredOutput({ user: { name: 123 } }, nestedSchema);
121
- expect(result.success).toBe(false);
122
- expect(result.error).toContain('expected string');
123
- });
124
- });
125
- describe('array item validation', () => {
126
- const arraySchema = {
127
- type: 'array',
128
- items: {
129
- type: 'object',
130
- properties: {
131
- id: { type: 'number' },
132
- value: { type: 'string' },
133
- },
134
- required: ['id'],
135
- },
136
- };
137
- it('should validate correct array items', () => {
138
- const result = validateStructuredOutput([
139
- { id: 1, value: 'one' },
140
- { id: 2, value: 'two' },
141
- ], arraySchema);
142
- expect(result.success).toBe(true);
143
- });
144
- it('should fail on incorrect array item type', () => {
145
- const result = validateStructuredOutput([{ id: 'not a number', value: 'one' }], arraySchema);
146
- expect(result.success).toBe(false);
147
- expect(result.error).toContain('expected number');
148
- });
149
- it('should fail on missing required field in array item', () => {
150
- const result = validateStructuredOutput([{ value: 'missing id' }], arraySchema);
151
- expect(result.success).toBe(false);
152
- expect(result.error).toContain('missing required property \'id\'');
153
- });
154
- });
155
- describe('enum validation', () => {
156
- it('should validate valid enum value in object property', () => {
157
- const schema = {
158
- type: 'object',
159
- properties: {
160
- color: { type: 'string', enum: ['red', 'green', 'blue'] },
161
- },
162
- };
163
- const result = validateStructuredOutput({ color: 'red' }, schema);
164
- expect(result.success).toBe(true);
165
- });
166
- it('should fail on invalid enum value in object property', () => {
167
- const schema = {
168
- type: 'object',
169
- properties: {
170
- color: { type: 'string', enum: ['red', 'green', 'blue'] },
171
- },
172
- };
173
- const result = validateStructuredOutput({ color: 'yellow' }, schema);
174
- expect(result.success).toBe(false);
175
- expect(result.error).toContain('not in enum');
176
- });
177
- });
178
- });
179
- describe('createValidationErrorMessage', () => {
180
- it('should return custom message when provided', () => {
181
- const result = { success: false, error: 'Some error' };
182
- const message = createValidationErrorMessage(result, 'Custom error message');
183
- expect(message).toBe('Custom error message');
184
- });
185
- it('should create message from error when no custom message', () => {
186
- const result = { success: false, error: 'Missing required field' };
187
- const message = createValidationErrorMessage(result);
188
- expect(message).toContain('Missing required field');
189
- expect(message).toContain('did not match the expected schema');
190
- });
191
- });
192
- describe('isValidJsonSchema', () => {
193
- it('should return true for schema with type', () => {
194
- expect(isValidJsonSchema({ type: 'object' })).toBe(true);
195
- expect(isValidJsonSchema({ type: 'string' })).toBe(true);
196
- });
197
- it('should return true for schema with properties', () => {
198
- expect(isValidJsonSchema({ properties: { name: { type: 'string' } } })).toBe(true);
199
- });
200
- it('should return true for schema with $schema', () => {
201
- expect(isValidJsonSchema({ $schema: 'http://json-schema.org/draft-07/schema#' })).toBe(true);
202
- });
203
- it('should return false for non-object values', () => {
204
- expect(isValidJsonSchema(null)).toBe(false);
205
- expect(isValidJsonSchema(undefined)).toBe(false);
206
- expect(isValidJsonSchema('string')).toBe(false);
207
- expect(isValidJsonSchema(123)).toBe(false);
208
- });
209
- it('should return false for empty object', () => {
210
- expect(isValidJsonSchema({})).toBe(false);
211
- });
212
- });
213
- describe('normalizeJsonSchema', () => {
214
- it('should add type: object when properties exist', () => {
215
- const schema = { properties: { name: { type: 'string' } } };
216
- const normalized = normalizeJsonSchema(schema);
217
- expect(normalized.type).toBe('object');
218
- });
219
- it('should not override existing type', () => {
220
- const schema = { type: 'array', items: { type: 'string' } };
221
- const normalized = normalizeJsonSchema(schema);
222
- expect(normalized.type).toBe('array');
223
- });
224
- it('should add title from config name', () => {
225
- const schema = { type: 'object' };
226
- const config = { schema: {}, name: 'MySchema' };
227
- const normalized = normalizeJsonSchema(schema, config);
228
- expect(normalized.title).toBe('MySchema');
229
- });
230
- it('should not override existing title', () => {
231
- const schema = { type: 'object', title: 'ExistingTitle' };
232
- const config = { schema: {}, name: 'NewTitle' };
233
- const normalized = normalizeJsonSchema(schema, config);
234
- expect(normalized.title).toBe('ExistingTitle');
235
- });
236
- it('should add description from config', () => {
237
- const schema = { type: 'object' };
238
- const config = {
239
- schema: {},
240
- description: 'My description',
241
- };
242
- const normalized = normalizeJsonSchema(schema, config);
243
- expect(normalized.description).toBe('My description');
244
- });
245
- it('should set additionalProperties: false in strict mode', () => {
246
- const schema = { type: 'object' };
247
- const config = { schema: {}, strict: true };
248
- const normalized = normalizeJsonSchema(schema, config);
249
- expect(normalized.additionalProperties).toBe(false);
250
- });
251
- it('should preserve existing additionalProperties value', () => {
252
- const schema = { type: 'object', additionalProperties: true };
253
- const config = { schema: {}, strict: true };
254
- const normalized = normalizeJsonSchema(schema, config);
255
- expect(normalized.additionalProperties).toBe(true);
256
- });
257
- it('should not modify additionalProperties when strict is false', () => {
258
- const schema = { type: 'object' };
259
- const config = { schema: {}, strict: false };
260
- const normalized = normalizeJsonSchema(schema, config);
261
- expect(normalized.additionalProperties).toBeUndefined();
262
- });
263
- });
264
- //# sourceMappingURL=validate.test.js.map
@@ -1,127 +0,0 @@
1
- /* eslint-disable no-console */
2
- // src/scripts/cli.ts
3
- import { config } from 'dotenv';
4
- config();
5
- import { HumanMessage } from '@langchain/core/messages';
6
- import { ChatModelStreamHandler, createContentAggregator } from '@/stream';
7
- import { ToolEndHandler } from '@/events';
8
- import { getArgs } from '@/scripts/args';
9
- import { Run } from '@/run';
10
- import { GraphEvents } from '@/common';
11
- import { getLLMConfig } from '@/utils/llmConfig';
12
- const conversationHistory = [];
13
- async function testStandardStreaming() {
14
- const { userName, location, provider, currentDate } = await getArgs();
15
- const { contentParts, aggregateContent } = createContentAggregator();
16
- const controller = new AbortController();
17
- const customHandlers = {
18
- [GraphEvents.TOOL_END]: new ToolEndHandler(),
19
- [GraphEvents.CHAT_MODEL_STREAM]: new ChatModelStreamHandler(),
20
- [GraphEvents.ON_RUN_STEP_COMPLETED]: {
21
- handle: (event, data) => {
22
- console.log('====== ON_RUN_STEP_COMPLETED ======');
23
- aggregateContent({
24
- event,
25
- data: data,
26
- });
27
- },
28
- },
29
- [GraphEvents.ON_RUN_STEP]: {
30
- handle: (event, data) => {
31
- console.log('====== ON_RUN_STEP ======');
32
- console.dir(data, { depth: null });
33
- aggregateContent({ event, data: data });
34
- },
35
- },
36
- [GraphEvents.ON_RUN_STEP_DELTA]: {
37
- handle: (event, data) => {
38
- console.log('====== ON_RUN_STEP_DELTA ======');
39
- console.dir(data, { depth: null });
40
- aggregateContent({ event, data: data });
41
- },
42
- },
43
- [GraphEvents.ON_MESSAGE_DELTA]: {
44
- handle: (event, data) => {
45
- console.log('====== ON_MESSAGE_DELTA ======');
46
- console.dir(data, { depth: null });
47
- aggregateContent({ event, data: data });
48
- },
49
- },
50
- [GraphEvents.TOOL_START]: {
51
- handle: (_event, data, metadata) => {
52
- console.log('====== TOOL_START ======');
53
- },
54
- },
55
- };
56
- const llmConfig = getLLMConfig(provider);
57
- const signal = controller.signal;
58
- const run = await Run.create({
59
- runId: 'test-run-id',
60
- graphConfig: {
61
- type: 'standard',
62
- signal,
63
- llmConfig,
64
- tools: [],
65
- instructions: 'You are a friendly AI assistant. Always address the user by their name.',
66
- additional_instructions: `The user's name is ${userName} and they are located in ${location}.`,
67
- },
68
- customHandlers,
69
- });
70
- const config = {
71
- configurable: {
72
- provider,
73
- thread_id: 'conversation-num-1',
74
- },
75
- signal,
76
- streamMode: 'values',
77
- version: 'v2',
78
- };
79
- console.log('Test 1: Weather query (content parts test)');
80
- const userMessage = `
81
- Make a search for the weather in ${location} today, which is ${currentDate}.
82
- Make sure to always refer to me by name, which is ${userName}.
83
- After giving me a thorough summary, tell me a joke about the weather forecast we went over.
84
- `;
85
- conversationHistory.push(new HumanMessage(userMessage));
86
- const inputs = {
87
- messages: conversationHistory,
88
- };
89
- // Set a timeout to abort the operation after 5 seconds
90
- setTimeout(() => {
91
- controller.abort();
92
- console.log('Operation aborted');
93
- console.log('Current content parts:');
94
- console.dir(contentParts, { depth: null });
95
- }, 4000);
96
- try {
97
- const finalContentParts = await run.processStream(inputs, config);
98
- const finalMessages = run.getRunMessages();
99
- if (finalMessages) {
100
- conversationHistory.push(...finalMessages);
101
- console.dir(conversationHistory, { depth: null });
102
- }
103
- console.dir(finalContentParts, { depth: null });
104
- }
105
- catch (error) {
106
- if (error?.name === 'AbortError') {
107
- console.log('Operation was aborted');
108
- }
109
- else {
110
- console.error('An error occurred:', error);
111
- }
112
- }
113
- console.log('\n\n====================\n\n');
114
- console.dir(contentParts, { depth: null });
115
- }
116
- process.on('unhandledRejection', (reason, promise) => {
117
- console.error('Unhandled Rejection at:', promise, 'reason:', reason);
118
- console.log('Conversation history:');
119
- process.exit(1);
120
- });
121
- testStandardStreaming().catch((err) => {
122
- console.error(err);
123
- console.log('Conversation history:');
124
- console.dir(conversationHistory, { depth: null });
125
- process.exit(1);
126
- });
127
- //# sourceMappingURL=abort.js.map
@@ -1,130 +0,0 @@
1
- /* eslint-disable no-console */
2
- // src/scripts/cli.ts
3
- import { config } from 'dotenv';
4
- config();
5
- import { HumanMessage } from '@langchain/core/messages';
6
- import { ChatModelStreamHandler, createContentAggregator } from '@/stream';
7
- import { ToolEndHandler, ModelEndHandler } from '@/events';
8
- import { getArgs } from '@/scripts/args';
9
- import { Run } from '@/run';
10
- import { GraphEvents, Providers } from '@/common';
11
- import { getLLMConfig } from '@/utils/llmConfig';
12
- const conversationHistory = [];
13
- let _contentParts = [];
14
- async function testStandardStreaming() {
15
- const { userName, location, currentDate } = await getArgs();
16
- const { contentParts, aggregateContent } = createContentAggregator();
17
- _contentParts = contentParts;
18
- const customHandlers = {
19
- [GraphEvents.TOOL_END]: new ToolEndHandler(),
20
- [GraphEvents.CHAT_MODEL_END]: new ModelEndHandler(),
21
- [GraphEvents.CHAT_MODEL_STREAM]: new ChatModelStreamHandler(),
22
- [GraphEvents.ON_RUN_STEP_COMPLETED]: {
23
- handle: (event, data) => {
24
- console.log('====== ON_RUN_STEP_COMPLETED ======');
25
- // console.dir(data, { depth: null });
26
- aggregateContent({
27
- event,
28
- data: data,
29
- });
30
- },
31
- },
32
- [GraphEvents.ON_RUN_STEP]: {
33
- handle: (event, data) => {
34
- console.log('====== ON_RUN_STEP ======');
35
- console.dir(data, { depth: null });
36
- aggregateContent({ event, data: data });
37
- },
38
- },
39
- [GraphEvents.ON_RUN_STEP_DELTA]: {
40
- handle: (event, data) => {
41
- console.log('====== ON_RUN_STEP_DELTA ======');
42
- console.dir(data, { depth: null });
43
- aggregateContent({ event, data: data });
44
- },
45
- },
46
- [GraphEvents.ON_MESSAGE_DELTA]: {
47
- handle: (event, data) => {
48
- console.log('====== ON_MESSAGE_DELTA ======');
49
- console.dir(data, { depth: null });
50
- aggregateContent({ event, data: data });
51
- },
52
- },
53
- [GraphEvents.TOOL_START]: {
54
- handle: (_event, data, metadata) => {
55
- console.log('====== TOOL_START ======');
56
- // console.dir(data, { depth: null });
57
- },
58
- },
59
- };
60
- const llmConfig = getLLMConfig(Providers.ANTHROPIC);
61
- llmConfig.model = 'claude-haiku-4-5';
62
- const run = await Run.create({
63
- runId: 'test-run-id',
64
- graphConfig: {
65
- type: 'standard',
66
- llmConfig,
67
- tools: [
68
- {
69
- type: 'web_search_20250305',
70
- name: 'web_search',
71
- max_uses: 5,
72
- },
73
- ],
74
- instructions: 'You are a friendly AI assistant.',
75
- // additional_instructions: `Always address the user by their name. The user's name is ${userName} and they are located in ${location}.`,
76
- },
77
- returnContent: true,
78
- skipCleanup: true,
79
- customHandlers,
80
- });
81
- const config = {
82
- configurable: {
83
- provider: Providers.ANTHROPIC,
84
- thread_id: 'conversation-num-1',
85
- },
86
- streamMode: 'values',
87
- version: 'v2',
88
- };
89
- console.log('Test 1: Search query (search tool test)');
90
- // const userMessage = `
91
- // Make a search for the weather in ${location} today, which is ${currentDate}.
92
- // Before making the search, please let me know what you're about to do, then immediately start searching without hesitation.
93
- // Make sure to always refer to me by name, which is ${userName}.
94
- // After giving me a thorough summary, tell me a joke about the weather forecast we went over.
95
- // `;
96
- // const userMessage = 'Are massage guns good?';
97
- // const userMessage = 'What is functional programming?';
98
- const userMessage = "Get me today's trending news.";
99
- // const userMessage = "search recent italy earthquake volcano activity";
100
- // const userMessage =
101
- // "use 'Trump' as the exact search query and tell me what you find.";
102
- conversationHistory.push(new HumanMessage(userMessage));
103
- const inputs = {
104
- messages: conversationHistory,
105
- };
106
- const finalContentParts = await run.processStream(inputs, config);
107
- const finalMessages = run.getRunMessages();
108
- if (finalMessages) {
109
- conversationHistory.push(...finalMessages);
110
- console.dir(conversationHistory, { depth: null });
111
- }
112
- // console.dir(finalContentParts, { depth: null });
113
- console.log('\n\n====================\n\n');
114
- // console.dir(contentParts, { depth: null });
115
- }
116
- process.on('unhandledRejection', (reason, promise) => {
117
- console.error('Unhandled Rejection at:', promise, 'reason:', reason);
118
- console.log('Content Parts:');
119
- console.dir(_contentParts, { depth: null });
120
- process.exit(1);
121
- });
122
- testStandardStreaming().catch((err) => {
123
- console.error(err);
124
- console.log('Conversation history:');
125
- console.dir(conversationHistory, { depth: null });
126
- console.log('Content Parts:');
127
- console.dir(_contentParts, { depth: null });
128
- process.exit(1);
129
- });
130
- //# sourceMappingURL=ant_web_search.js.map
@@ -1,133 +0,0 @@
1
- /* eslint-disable no-console */
2
- // src/scripts/cli.ts
3
- import { config } from 'dotenv';
4
- config();
5
- import { HumanMessage } from '@langchain/core/messages';
6
- import { ChatModelStreamHandler, createContentAggregator } from '@/stream';
7
- import { ToolEndHandler, ModelEndHandler } from '@/events';
8
- import { Calculator } from '@/tools/Calculator';
9
- import { getArgs } from '@/scripts/args';
10
- import { Run } from '@/run';
11
- import { GraphEvents, Providers } from '@/common';
12
- import { getLLMConfig } from '@/utils/llmConfig';
13
- const conversationHistory = [];
14
- let _contentParts = [];
15
- async function testStandardStreaming() {
16
- const { userName, location, currentDate } = await getArgs();
17
- const { contentParts, aggregateContent } = createContentAggregator();
18
- _contentParts = contentParts;
19
- const customHandlers = {
20
- [GraphEvents.TOOL_END]: new ToolEndHandler(),
21
- [GraphEvents.CHAT_MODEL_END]: new ModelEndHandler(),
22
- [GraphEvents.CHAT_MODEL_STREAM]: new ChatModelStreamHandler(),
23
- [GraphEvents.ON_RUN_STEP_COMPLETED]: {
24
- handle: (event, data) => {
25
- console.log('====== ON_RUN_STEP_COMPLETED ======');
26
- // console.dir(data, { depth: null });
27
- aggregateContent({
28
- event,
29
- data: data,
30
- });
31
- },
32
- },
33
- [GraphEvents.ON_RUN_STEP]: {
34
- handle: (event, data) => {
35
- console.log('====== ON_RUN_STEP ======');
36
- console.dir(data, { depth: null });
37
- aggregateContent({ event, data: data });
38
- },
39
- },
40
- [GraphEvents.ON_RUN_STEP_DELTA]: {
41
- handle: (event, data) => {
42
- console.log('====== ON_RUN_STEP_DELTA ======');
43
- console.dir(data, { depth: null });
44
- aggregateContent({ event, data: data });
45
- },
46
- },
47
- [GraphEvents.ON_MESSAGE_DELTA]: {
48
- handle: (event, data) => {
49
- // console.log('====== ON_MESSAGE_DELTA ======');
50
- // console.dir(data, { depth: null });
51
- aggregateContent({ event, data: data });
52
- },
53
- },
54
- [GraphEvents.TOOL_START]: {
55
- handle: (_event, data, metadata) => {
56
- console.log('====== TOOL_START ======');
57
- // console.dir(data, { depth: null });
58
- },
59
- },
60
- };
61
- const llmConfig = getLLMConfig(Providers.ANTHROPIC);
62
- llmConfig.model = 'claude-haiku-4-5';
63
- const run = await Run.create({
64
- runId: 'test-run-id',
65
- graphConfig: {
66
- type: 'standard',
67
- llmConfig,
68
- tools: [
69
- {
70
- type: 'web_search_20250305',
71
- name: 'web_search',
72
- max_uses: 5,
73
- },
74
- new Calculator(),
75
- ],
76
- instructions: 'You are a friendly AI assistant.',
77
- // additional_instructions: `Always address the user by their name. The user's name is ${userName} and they are located in ${location}.`,
78
- },
79
- returnContent: true,
80
- skipCleanup: true,
81
- customHandlers,
82
- });
83
- const config = {
84
- configurable: {
85
- provider: Providers.ANTHROPIC,
86
- thread_id: 'conversation-num-1',
87
- },
88
- streamMode: 'values',
89
- version: 'v2',
90
- };
91
- console.log('Test 1: Web search + calculator (simultaneous tool test)');
92
- // const userMessage = `
93
- // Make a search for the weather in ${location} today, which is ${currentDate}.
94
- // Before making the search, please let me know what you're about to do, then immediately start searching without hesitation.
95
- // Make sure to always refer to me by name, which is ${userName}.
96
- // After giving me a thorough summary, tell me a joke about the weather forecast we went over.
97
- // `;
98
- // const userMessage = 'Are massage guns good?';
99
- // const userMessage = 'What is functional programming?';
100
- // const userMessage = "Get me today's trending news.";
101
- // const userMessage = "search recent italy earthquake volcano activity";
102
- // const userMessage =
103
- // "use 'Trump' as the exact search query and tell me what you find.";
104
- const userMessage = 'Can you search the web for the current population of Tokyo, and also calculate what 15% of that population would be? Do both at the same time.';
105
- conversationHistory.push(new HumanMessage(userMessage));
106
- const inputs = {
107
- messages: conversationHistory,
108
- };
109
- const finalContentParts = await run.processStream(inputs, config);
110
- const finalMessages = run.getRunMessages();
111
- if (finalMessages) {
112
- conversationHistory.push(...finalMessages);
113
- console.dir(conversationHistory, { depth: null });
114
- }
115
- // console.dir(finalContentParts, { depth: null });
116
- console.log('\n\n====================\n\n');
117
- // console.dir(contentParts, { depth: null });
118
- }
119
- process.on('unhandledRejection', (reason, promise) => {
120
- console.error('Unhandled Rejection at:', promise, 'reason:', reason);
121
- console.log('Content Parts:');
122
- console.dir(_contentParts, { depth: null });
123
- process.exit(1);
124
- });
125
- testStandardStreaming().catch((err) => {
126
- console.error(err);
127
- console.log('Conversation history:');
128
- console.dir(conversationHistory, { depth: null });
129
- console.log('Content Parts:');
130
- console.dir(_contentParts, { depth: null });
131
- process.exit(1);
132
- });
133
- //# sourceMappingURL=ant_web_search_edge_case.js.map