@illuma-ai/agents 1.1.21 → 1.1.23

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 (244) 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 +105 -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/cjs/utils/llm.cjs.map +1 -1
  8. package/dist/esm/graphs/Graph.mjs +12 -1
  9. package/dist/esm/graphs/Graph.mjs.map +1 -1
  10. package/dist/esm/graphs/MultiAgentGraph.mjs +105 -1
  11. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  12. package/dist/esm/run.mjs +20 -9
  13. package/dist/esm/run.mjs.map +1 -1
  14. package/dist/esm/utils/llm.mjs.map +1 -1
  15. package/dist/types/graphs/MultiAgentGraph.d.ts +17 -0
  16. package/package.json +1 -1
  17. package/src/graphs/Graph.ts +13 -1
  18. package/src/graphs/MultiAgentGraph.ts +128 -1
  19. package/src/graphs/__tests__/multi-agent-delegate.test.ts +205 -0
  20. package/src/run.ts +20 -11
  21. package/src/scripts/test-bedrock-handoff-autonomous.ts +231 -0
  22. package/src/utils/llm.ts +1 -0
  23. package/src/agents/AgentContext.js +0 -782
  24. package/src/agents/AgentContext.test.js +0 -421
  25. package/src/agents/__tests__/AgentContext.test.js +0 -678
  26. package/src/agents/__tests__/resolveStructuredOutputMode.test.js +0 -117
  27. package/src/common/enum.js +0 -192
  28. package/src/common/index.js +0 -3
  29. package/src/events.js +0 -166
  30. package/src/graphs/Graph.js +0 -1857
  31. package/src/graphs/MultiAgentGraph.js +0 -1092
  32. package/src/graphs/__tests__/structured-output.integration.test.js +0 -624
  33. package/src/graphs/__tests__/structured-output.test.js +0 -144
  34. package/src/graphs/contextManagement.e2e.test.js +0 -718
  35. package/src/graphs/contextManagement.test.js +0 -485
  36. package/src/graphs/handoffValidation.test.js +0 -276
  37. package/src/graphs/index.js +0 -3
  38. package/src/index.js +0 -28
  39. package/src/instrumentation.js +0 -21
  40. package/src/llm/anthropic/index.js +0 -319
  41. package/src/llm/anthropic/types.js +0 -46
  42. package/src/llm/anthropic/utils/message_inputs.js +0 -627
  43. package/src/llm/anthropic/utils/message_outputs.js +0 -290
  44. package/src/llm/anthropic/utils/output_parsers.js +0 -89
  45. package/src/llm/anthropic/utils/tools.js +0 -25
  46. package/src/llm/bedrock/__tests__/bedrock-caching.test.js +0 -392
  47. package/src/llm/bedrock/index.js +0 -303
  48. package/src/llm/bedrock/types.js +0 -2
  49. package/src/llm/bedrock/utils/index.js +0 -6
  50. package/src/llm/bedrock/utils/message_inputs.js +0 -463
  51. package/src/llm/bedrock/utils/message_outputs.js +0 -269
  52. package/src/llm/fake.js +0 -92
  53. package/src/llm/google/index.js +0 -215
  54. package/src/llm/google/types.js +0 -12
  55. package/src/llm/google/utils/common.js +0 -670
  56. package/src/llm/google/utils/tools.js +0 -111
  57. package/src/llm/google/utils/zod_to_genai_parameters.js +0 -47
  58. package/src/llm/openai/index.js +0 -1033
  59. package/src/llm/openai/types.js +0 -2
  60. package/src/llm/openai/utils/index.js +0 -756
  61. package/src/llm/openai/utils/isReasoningModel.test.js +0 -79
  62. package/src/llm/openrouter/index.js +0 -261
  63. package/src/llm/openrouter/reasoning.test.js +0 -181
  64. package/src/llm/providers.js +0 -36
  65. package/src/llm/text.js +0 -65
  66. package/src/llm/vertexai/index.js +0 -402
  67. package/src/messages/__tests__/tools.test.js +0 -392
  68. package/src/messages/cache.js +0 -404
  69. package/src/messages/cache.test.js +0 -1167
  70. package/src/messages/content.js +0 -48
  71. package/src/messages/content.test.js +0 -314
  72. package/src/messages/core.js +0 -359
  73. package/src/messages/ensureThinkingBlock.test.js +0 -997
  74. package/src/messages/format.js +0 -973
  75. package/src/messages/formatAgentMessages.test.js +0 -2278
  76. package/src/messages/formatAgentMessages.tools.test.js +0 -362
  77. package/src/messages/formatMessage.test.js +0 -608
  78. package/src/messages/ids.js +0 -18
  79. package/src/messages/index.js +0 -9
  80. package/src/messages/labelContentByAgent.test.js +0 -725
  81. package/src/messages/prune.js +0 -438
  82. package/src/messages/reducer.js +0 -60
  83. package/src/messages/shiftIndexTokenCountMap.test.js +0 -63
  84. package/src/messages/summarize.js +0 -146
  85. package/src/messages/summarize.test.js +0 -332
  86. package/src/messages/tools.js +0 -90
  87. package/src/mockStream.js +0 -81
  88. package/src/prompts/collab.js +0 -7
  89. package/src/prompts/index.js +0 -3
  90. package/src/prompts/taskmanager.js +0 -58
  91. package/src/run.js +0 -427
  92. package/src/schemas/index.js +0 -3
  93. package/src/schemas/schema-preparation.test.js +0 -370
  94. package/src/schemas/validate.js +0 -314
  95. package/src/schemas/validate.test.js +0 -264
  96. package/src/scripts/abort.js +0 -127
  97. package/src/scripts/ant_web_search.js +0 -130
  98. package/src/scripts/ant_web_search_edge_case.js +0 -133
  99. package/src/scripts/ant_web_search_error_edge_case.js +0 -119
  100. package/src/scripts/args.js +0 -41
  101. package/src/scripts/bedrock-cache-debug.js +0 -186
  102. package/src/scripts/bedrock-content-aggregation-test.js +0 -195
  103. package/src/scripts/bedrock-merge-test.js +0 -80
  104. package/src/scripts/bedrock-parallel-tools-test.js +0 -150
  105. package/src/scripts/caching.js +0 -106
  106. package/src/scripts/cli.js +0 -152
  107. package/src/scripts/cli2.js +0 -119
  108. package/src/scripts/cli3.js +0 -163
  109. package/src/scripts/cli4.js +0 -165
  110. package/src/scripts/cli5.js +0 -165
  111. package/src/scripts/code_exec.js +0 -171
  112. package/src/scripts/code_exec_files.js +0 -180
  113. package/src/scripts/code_exec_multi_session.js +0 -185
  114. package/src/scripts/code_exec_ptc.js +0 -265
  115. package/src/scripts/code_exec_session.js +0 -217
  116. package/src/scripts/code_exec_simple.js +0 -120
  117. package/src/scripts/content.js +0 -111
  118. package/src/scripts/empty_input.js +0 -125
  119. package/src/scripts/handoff-test.js +0 -96
  120. package/src/scripts/image.js +0 -138
  121. package/src/scripts/memory.js +0 -83
  122. package/src/scripts/multi-agent-chain.js +0 -271
  123. package/src/scripts/multi-agent-conditional.js +0 -185
  124. package/src/scripts/multi-agent-document-review-chain.js +0 -171
  125. package/src/scripts/multi-agent-hybrid-flow.js +0 -264
  126. package/src/scripts/multi-agent-parallel-start.js +0 -214
  127. package/src/scripts/multi-agent-parallel.js +0 -346
  128. package/src/scripts/multi-agent-sequence.js +0 -184
  129. package/src/scripts/multi-agent-supervisor.js +0 -324
  130. package/src/scripts/multi-agent-test.js +0 -147
  131. package/src/scripts/parallel-asymmetric-tools-test.js +0 -202
  132. package/src/scripts/parallel-full-metadata-test.js +0 -176
  133. package/src/scripts/parallel-tools-test.js +0 -256
  134. package/src/scripts/programmatic_exec.js +0 -277
  135. package/src/scripts/programmatic_exec_agent.js +0 -168
  136. package/src/scripts/search.js +0 -118
  137. package/src/scripts/sequential-full-metadata-test.js +0 -143
  138. package/src/scripts/simple.js +0 -174
  139. package/src/scripts/single-agent-metadata-test.js +0 -152
  140. package/src/scripts/stream.js +0 -113
  141. package/src/scripts/test-custom-prompt-key.js +0 -132
  142. package/src/scripts/test-handoff-input.js +0 -143
  143. package/src/scripts/test-handoff-preamble.js +0 -227
  144. package/src/scripts/test-handoff-steering.js +0 -353
  145. package/src/scripts/test-multi-agent-list-handoff.js +0 -318
  146. package/src/scripts/test-parallel-agent-labeling.js +0 -253
  147. package/src/scripts/test-parallel-handoffs.js +0 -229
  148. package/src/scripts/test-thinking-handoff-bedrock.js +0 -132
  149. package/src/scripts/test-thinking-handoff.js +0 -132
  150. package/src/scripts/test-thinking-to-thinking-handoff-bedrock.js +0 -140
  151. package/src/scripts/test-tool-before-handoff-role-order.js +0 -223
  152. package/src/scripts/test-tools-before-handoff.js +0 -187
  153. package/src/scripts/test_code_api.js +0 -263
  154. package/src/scripts/thinking-bedrock.js +0 -128
  155. package/src/scripts/thinking-vertexai.js +0 -130
  156. package/src/scripts/thinking.js +0 -134
  157. package/src/scripts/tool_search.js +0 -114
  158. package/src/scripts/tools.js +0 -125
  159. package/src/specs/agent-handoffs-bedrock.integration.test.js +0 -280
  160. package/src/specs/agent-handoffs.test.js +0 -924
  161. package/src/specs/anthropic.simple.test.js +0 -287
  162. package/src/specs/azure.simple.test.js +0 -381
  163. package/src/specs/cache.simple.test.js +0 -282
  164. package/src/specs/custom-event-await.test.js +0 -148
  165. package/src/specs/deepseek.simple.test.js +0 -189
  166. package/src/specs/emergency-prune.test.js +0 -308
  167. package/src/specs/moonshot.simple.test.js +0 -237
  168. package/src/specs/observability.integration.test.js +0 -1337
  169. package/src/specs/openai.simple.test.js +0 -233
  170. package/src/specs/openrouter.simple.test.js +0 -202
  171. package/src/specs/prune.test.js +0 -733
  172. package/src/specs/reasoning.test.js +0 -144
  173. package/src/specs/spec.utils.js +0 -4
  174. package/src/specs/thinking-handoff.test.js +0 -486
  175. package/src/specs/thinking-prune.test.js +0 -600
  176. package/src/specs/token-distribution-edge-case.test.js +0 -246
  177. package/src/specs/token-memoization.test.js +0 -32
  178. package/src/specs/tokens.test.js +0 -49
  179. package/src/specs/tool-error.test.js +0 -139
  180. package/src/splitStream.js +0 -204
  181. package/src/splitStream.test.js +0 -504
  182. package/src/stream.js +0 -650
  183. package/src/stream.test.js +0 -225
  184. package/src/test/mockTools.js +0 -340
  185. package/src/tools/BrowserTools.js +0 -245
  186. package/src/tools/Calculator.js +0 -38
  187. package/src/tools/Calculator.test.js +0 -225
  188. package/src/tools/CodeExecutor.js +0 -233
  189. package/src/tools/ProgrammaticToolCalling.js +0 -602
  190. package/src/tools/StreamingToolCallBuffer.js +0 -179
  191. package/src/tools/ToolNode.js +0 -930
  192. package/src/tools/ToolSearch.js +0 -904
  193. package/src/tools/__tests__/BrowserTools.test.js +0 -306
  194. package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.js +0 -276
  195. package/src/tools/__tests__/ProgrammaticToolCalling.test.js +0 -807
  196. package/src/tools/__tests__/StreamingToolCallBuffer.test.js +0 -175
  197. package/src/tools/__tests__/ToolApproval.test.js +0 -675
  198. package/src/tools/__tests__/ToolNode.recovery.test.js +0 -200
  199. package/src/tools/__tests__/ToolNode.session.test.js +0 -319
  200. package/src/tools/__tests__/ToolSearch.integration.test.js +0 -125
  201. package/src/tools/__tests__/ToolSearch.test.js +0 -812
  202. package/src/tools/__tests__/handlers.test.js +0 -799
  203. package/src/tools/__tests__/truncation-recovery.integration.test.js +0 -362
  204. package/src/tools/handlers.js +0 -306
  205. package/src/tools/schema.js +0 -25
  206. package/src/tools/search/anthropic.js +0 -34
  207. package/src/tools/search/content.js +0 -116
  208. package/src/tools/search/content.test.js +0 -133
  209. package/src/tools/search/firecrawl.js +0 -173
  210. package/src/tools/search/format.js +0 -198
  211. package/src/tools/search/highlights.js +0 -241
  212. package/src/tools/search/index.js +0 -3
  213. package/src/tools/search/jina-reranker.test.js +0 -106
  214. package/src/tools/search/rerankers.js +0 -165
  215. package/src/tools/search/schema.js +0 -102
  216. package/src/tools/search/search.js +0 -561
  217. package/src/tools/search/serper-scraper.js +0 -126
  218. package/src/tools/search/test.js +0 -129
  219. package/src/tools/search/tool.js +0 -453
  220. package/src/tools/search/types.js +0 -2
  221. package/src/tools/search/utils.js +0 -59
  222. package/src/types/graph.js +0 -24
  223. package/src/types/graph.test.js +0 -192
  224. package/src/types/index.js +0 -7
  225. package/src/types/llm.js +0 -2
  226. package/src/types/messages.js +0 -2
  227. package/src/types/run.js +0 -2
  228. package/src/types/stream.js +0 -2
  229. package/src/types/tools.js +0 -2
  230. package/src/utils/contextAnalytics.js +0 -79
  231. package/src/utils/contextAnalytics.test.js +0 -166
  232. package/src/utils/events.js +0 -26
  233. package/src/utils/graph.js +0 -11
  234. package/src/utils/handlers.js +0 -65
  235. package/src/utils/index.js +0 -10
  236. package/src/utils/llm.js +0 -21
  237. package/src/utils/llmConfig.js +0 -205
  238. package/src/utils/logging.js +0 -37
  239. package/src/utils/misc.js +0 -51
  240. package/src/utils/run.js +0 -69
  241. package/src/utils/schema.js +0 -21
  242. package/src/utils/title.js +0 -119
  243. package/src/utils/tokens.js +0 -92
  244. package/src/utils/toonFormat.js +0 -379
@@ -1,263 +0,0 @@
1
- // src/scripts/test_code_api.ts
2
- /**
3
- * Direct test of the Code API to verify session file persistence.
4
- * This bypasses the LLM and tests the API directly.
5
- *
6
- * Run with: npx ts-node -r dotenv/config src/scripts/test_code_api.ts
7
- */
8
- import { config } from 'dotenv';
9
- config();
10
- import fetch from 'node-fetch';
11
- import { HttpsProxyAgent } from 'https-proxy-agent';
12
- const API_KEY = process.env.CODE_EXECUTOR_API_KEY ?? '';
13
- const BASE_URL = process.env.ILLUMA_CODE_BASEURL ?? 'https://api.illuma.ai/v1';
14
- const PROXY = process.env.PROXY;
15
- if (!API_KEY) {
16
- console.error('CODE_EXECUTOR_API_KEY not set');
17
- process.exit(1);
18
- }
19
- async function makeRequest(endpoint, body) {
20
- const fetchOptions = {
21
- method: body ? 'POST' : 'GET',
22
- headers: {
23
- 'Content-Type': 'application/json',
24
- 'User-Agent': 'Illuma/1.0',
25
- 'X-API-Key': API_KEY,
26
- },
27
- };
28
- if (body) {
29
- fetchOptions.body = JSON.stringify(body);
30
- }
31
- if (PROXY) {
32
- fetchOptions.agent = new HttpsProxyAgent(PROXY);
33
- }
34
- console.log(`\n>>> ${body ? 'POST' : 'GET'} ${endpoint}`);
35
- if (body) {
36
- console.log('Body:', JSON.stringify(body, null, 2));
37
- }
38
- const response = await fetch(endpoint, fetchOptions);
39
- const result = await response.json();
40
- console.log(`<<< Response (${response.status}):`);
41
- console.log(JSON.stringify(result, null, 2));
42
- if (!response.ok) {
43
- throw new Error(`HTTP ${response.status}: ${JSON.stringify(result)}`);
44
- }
45
- return result;
46
- }
47
- async function testCodeAPI() {
48
- console.log('='.repeat(60));
49
- console.log('TEST 1: Create a file');
50
- console.log('='.repeat(60));
51
- const createCode = `
52
- import json
53
-
54
- config = {
55
- "app_name": "TestApp",
56
- "version": "1.0.0",
57
- "debug": True
58
- }
59
-
60
- with open("/mnt/data/test_config.json", "w") as f:
61
- json.dump(config, f, indent=2)
62
-
63
- with open("/mnt/data/test_config.json", "r") as f:
64
- print(f.read())
65
- `;
66
- const result1 = (await makeRequest(`${BASE_URL}/exec`, {
67
- lang: 'py',
68
- code: createCode,
69
- }));
70
- const sessionId = result1.session_id;
71
- const files = result1.files ?? [];
72
- console.log('\n--- Result Summary ---');
73
- console.log('session_id:', sessionId);
74
- console.log('files:', files);
75
- console.log('stdout:', result1.stdout);
76
- console.log('stderr:', result1.stderr);
77
- if (!sessionId || files.length === 0) {
78
- console.error('\n❌ No session_id or files returned!');
79
- return;
80
- }
81
- // Check if files now include session_id (new API feature)
82
- const hasSessionIdInFiles = files.some((f) => f.session_id != null);
83
- console.log('\n✅ Files include session_id:', hasSessionIdInFiles);
84
- console.log('\n' + '='.repeat(60));
85
- console.log('TEST 2: Fetch files IMMEDIATELY (no delay - testing race condition fix)');
86
- console.log('='.repeat(60));
87
- const filesResult = (await makeRequest(`${BASE_URL}/files/${sessionId}?detail=full`));
88
- console.log('\n--- Files in session (detail=full) ---');
89
- for (const file of filesResult) {
90
- console.log('File:', file.name);
91
- console.log(' metadata:', file.metadata);
92
- }
93
- if (filesResult.length === 0) {
94
- console.log('\n⚠️ Files endpoint returned empty - race condition may still exist');
95
- }
96
- else {
97
- console.log('\n✅ Files available immediately!');
98
- }
99
- // Test new normalized detail level
100
- console.log('\n' + '='.repeat(60));
101
- console.log('TEST 2b: Fetch files with detail=normalized');
102
- console.log('='.repeat(60));
103
- const normalizedResult = (await makeRequest(`${BASE_URL}/files/${sessionId}?detail=normalized`));
104
- console.log('\n--- Files in session (detail=normalized) ---');
105
- console.log(JSON.stringify(normalizedResult, null, 2));
106
- console.log('\n' + '='.repeat(60));
107
- console.log('TEST 3: Read file IMMEDIATELY using files from original response');
108
- console.log('='.repeat(60));
109
- // Use files directly - if API returns session_id, use that; otherwise add it
110
- const fileReferences = files.map((file) => ({
111
- session_id: file.session_id ?? sessionId,
112
- id: file.id,
113
- name: file.name,
114
- }));
115
- console.log('\nFile references we will send:', JSON.stringify(fileReferences, null, 2));
116
- const readCode = `
117
- import json
118
-
119
- with open("/mnt/data/test_config.json", "r") as f:
120
- config = json.load(f)
121
- print("Read config:")
122
- print(json.dumps(config, indent=2))
123
- print("Version:", config.get("version"))
124
- `;
125
- const result2 = (await makeRequest(`${BASE_URL}/exec`, {
126
- lang: 'py',
127
- code: readCode,
128
- files: fileReferences,
129
- }));
130
- console.log('\n--- Result Summary ---');
131
- console.log('stdout:', result2.stdout);
132
- console.log('stderr:', result2.stderr);
133
- if (result2.stderr && result2.stderr.includes('FileNotFoundError')) {
134
- console.log('\n❌ File not found! The file reference format might be wrong.');
135
- // Try alternative format - just session_id
136
- console.log('\n' + '='.repeat(60));
137
- console.log('TEST 4: Try with just session_id in request');
138
- console.log('='.repeat(60));
139
- const result3 = (await makeRequest(`${BASE_URL}/exec`, {
140
- lang: 'py',
141
- code: readCode,
142
- session_id: sessionId,
143
- }));
144
- console.log('\n--- Result Summary ---');
145
- console.log('stdout:', result3.stdout);
146
- console.log('stderr:', result3.stderr);
147
- }
148
- else {
149
- console.log('\n✅ File read successfully!');
150
- }
151
- // ============================================================
152
- // TEST 4: MODIFY the file (same filename) - tests editable files
153
- // ============================================================
154
- console.log('\n' + '='.repeat(60));
155
- console.log('TEST 4: MODIFY file in-place (testing editable files feature)');
156
- console.log('='.repeat(60));
157
- const modifyCode = `
158
- import json
159
-
160
- # Read the existing file
161
- with open("/mnt/data/test_config.json", "r") as f:
162
- config = json.load(f)
163
-
164
- print("Original config:")
165
- print(json.dumps(config, indent=2))
166
-
167
- # Modify the config
168
- config["version"] = "2.0.0"
169
- config["modified"] = True
170
-
171
- # Write BACK to the SAME filename (should work now!)
172
- with open("/mnt/data/test_config.json", "w") as f:
173
- json.dump(config, f, indent=2)
174
-
175
- # Verify the write
176
- with open("/mnt/data/test_config.json", "r") as f:
177
- updated = json.load(f)
178
-
179
- print("\\nUpdated config:")
180
- print(json.dumps(updated, indent=2))
181
- `;
182
- const result3 = (await makeRequest(`${BASE_URL}/exec`, {
183
- lang: 'py',
184
- code: modifyCode,
185
- files: fileReferences,
186
- }));
187
- console.log('\n--- Result Summary ---');
188
- console.log('stdout:', result3.stdout);
189
- console.log('stderr:', result3.stderr);
190
- console.log('files:', JSON.stringify(result3.files, null, 2));
191
- if (result3.stderr && result3.stderr.includes('Permission denied')) {
192
- console.log('\n❌ Permission denied - files are still read-only!');
193
- }
194
- else if (result3.stderr && result3.stderr.includes('Error')) {
195
- console.log('\n❌ Error modifying file:', result3.stderr);
196
- }
197
- else {
198
- console.log('\n✅ File modified successfully!');
199
- // Check for modified_from lineage
200
- const modifiedFile = result3.files?.find((f) => f.name === 'test_config.json');
201
- if (modifiedFile) {
202
- console.log('\n--- Modified File Details ---');
203
- console.log(' id:', modifiedFile.id);
204
- console.log(' name:', modifiedFile.name);
205
- console.log(' session_id:', modifiedFile.session_id);
206
- if (modifiedFile.modified_from) {
207
- console.log(' modified_from:', JSON.stringify(modifiedFile.modified_from));
208
- console.log('\n✅ Lineage tracking working! File shows it was modified from previous session.');
209
- }
210
- else {
211
- console.log('\n⚠️ No modified_from field - lineage tracking not present');
212
- }
213
- }
214
- else {
215
- console.log('\n⚠️ Modified file not found in response files array');
216
- }
217
- }
218
- // ============================================================
219
- // TEST 5: Verify modification persists in next execution
220
- // ============================================================
221
- console.log('\n' + '='.repeat(60));
222
- console.log('TEST 5: Verify modified file can be read in subsequent execution');
223
- console.log('='.repeat(60));
224
- // Use the new file references from the modify response
225
- const newFileRefs = (result3.files ?? []).map((file) => ({
226
- session_id: file.session_id ?? result3.session_id,
227
- id: file.id,
228
- name: file.name,
229
- }));
230
- if (newFileRefs.length === 0) {
231
- console.log('\n⚠️ No files returned from modification, skipping verification');
232
- }
233
- else {
234
- console.log('\nUsing new file references:', JSON.stringify(newFileRefs, null, 2));
235
- const verifyCode = `
236
- import json
237
-
238
- with open("/mnt/data/test_config.json", "r") as f:
239
- config = json.load(f)
240
-
241
- print("Verified config:")
242
- print(json.dumps(config, indent=2))
243
-
244
- if config.get("version") == "2.0.0" and config.get("modified") == True:
245
- print("\\n✅ Modification persisted correctly!")
246
- else:
247
- print("\\n❌ Modification did NOT persist!")
248
- `;
249
- const result4 = (await makeRequest(`${BASE_URL}/exec`, {
250
- lang: 'py',
251
- code: verifyCode,
252
- files: newFileRefs,
253
- }));
254
- console.log('\n--- Result Summary ---');
255
- console.log('stdout:', result4.stdout);
256
- console.log('stderr:', result4.stderr);
257
- }
258
- }
259
- testCodeAPI().catch((err) => {
260
- console.error('Error:', err);
261
- process.exit(1);
262
- });
263
- //# sourceMappingURL=test_code_api.js.map
@@ -1,128 +0,0 @@
1
- // src/scripts/thinking-bedrock.ts
2
- import { config } from 'dotenv';
3
- config();
4
- import { HumanMessage } from '@langchain/core/messages';
5
- import { ChatModelStreamHandler, createContentAggregator } from '@/stream';
6
- import { createCodeExecutionTool } from '@/tools/CodeExecutor';
7
- import { ToolEndHandler, ModelEndHandler } from '@/events';
8
- import { GraphEvents, Providers } from '@/common';
9
- import { getLLMConfig } from '@/utils/llmConfig';
10
- import { getArgs } from '@/scripts/args';
11
- import { Run } from '@/run';
12
- const conversationHistory = [];
13
- let _contentParts = [];
14
- const collectedUsage = [];
15
- async function testBedrockThinking() {
16
- const { userName } = await getArgs();
17
- const instructions = `You are a helpful AI assistant for ${userName}. When answering questions, be thorough in your reasoning.`;
18
- const { contentParts, aggregateContent } = createContentAggregator();
19
- _contentParts = contentParts;
20
- // Set up event handlers
21
- const customHandlers = {
22
- [GraphEvents.TOOL_END]: new ToolEndHandler(),
23
- [GraphEvents.CHAT_MODEL_END]: new ModelEndHandler(collectedUsage),
24
- [GraphEvents.CHAT_MODEL_STREAM]: new ChatModelStreamHandler(),
25
- [GraphEvents.ON_RUN_STEP_COMPLETED]: {
26
- handle: (event, data) => {
27
- console.log('====== ON_RUN_STEP_COMPLETED ======');
28
- aggregateContent({
29
- event,
30
- data: data,
31
- });
32
- },
33
- },
34
- [GraphEvents.ON_RUN_STEP]: {
35
- handle: (event, data) => {
36
- aggregateContent({ event, data });
37
- },
38
- },
39
- [GraphEvents.ON_RUN_STEP_DELTA]: {
40
- handle: (event, data) => {
41
- aggregateContent({ event, data });
42
- },
43
- },
44
- [GraphEvents.ON_MESSAGE_DELTA]: {
45
- handle: (event, data) => {
46
- aggregateContent({ event, data });
47
- },
48
- },
49
- [GraphEvents.ON_REASONING_DELTA]: {
50
- handle: (event, data) => {
51
- aggregateContent({ event, data });
52
- },
53
- },
54
- };
55
- const baseLlmConfig = getLLMConfig(Providers.BEDROCK);
56
- // Enable thinking with token budget for Bedrock
57
- const llmConfig = {
58
- ...baseLlmConfig,
59
- model: 'us.anthropic.claude-3-7-sonnet-20250219-v1:0',
60
- maxTokens: 5000,
61
- additionalModelRequestFields: {
62
- thinking: { type: 'enabled', budget_tokens: 2000 },
63
- },
64
- };
65
- const run = await Run.create({
66
- runId: 'test-bedrock-thinking-id',
67
- graphConfig: {
68
- instructions,
69
- type: 'standard',
70
- tools: [createCodeExecutionTool()],
71
- llmConfig,
72
- },
73
- returnContent: true,
74
- skipCleanup: true,
75
- customHandlers: customHandlers,
76
- });
77
- const config = {
78
- configurable: {
79
- thread_id: 'bedrock-thinking-test-thread',
80
- },
81
- streamMode: 'values',
82
- version: 'v2',
83
- };
84
- // Test 1: Regular thinking mode
85
- console.log('\n\nTest 1: Bedrock Regular thinking mode');
86
- const userMessage1 = `Please print 'hello world' in python`;
87
- conversationHistory.push(new HumanMessage(userMessage1));
88
- console.log('Running first query with Bedrock thinking enabled...');
89
- const firstInputs = { messages: [...conversationHistory] };
90
- await run.processStream(firstInputs, config);
91
- // Extract and display thinking blocks
92
- const finalMessages = run.getRunMessages();
93
- console.log('\n\nFinal messages after Test 1:');
94
- console.dir(finalMessages, { depth: null });
95
- // Test 2: Try multi-turn conversation
96
- console.log('\n\nTest 2: Multi-turn conversation with Bedrock thinking enabled');
97
- const userMessage2 = `Given your previous analysis, what would be the most significant technical challenges in making this transition?`;
98
- conversationHistory.push(new HumanMessage(userMessage2));
99
- console.log('Running second query with Bedrock thinking enabled...');
100
- const secondInputs = { messages: [...conversationHistory] };
101
- await run.processStream(secondInputs, config);
102
- // Display thinking blocks for second response
103
- const finalMessages2 = run.getRunMessages();
104
- console.log('\n\nBedrock thinking feature test completed!');
105
- console.dir(finalMessages2, { depth: null });
106
- console.log('\n\nContent parts:');
107
- console.dir(_contentParts, { depth: null });
108
- }
109
- process.on('unhandledRejection', (reason, promise) => {
110
- console.error('Unhandled Rejection at:', promise, 'reason:', reason);
111
- console.log('Conversation history:');
112
- console.dir(conversationHistory, { depth: null });
113
- console.log('Content parts:');
114
- console.dir(_contentParts, { depth: null });
115
- process.exit(1);
116
- });
117
- process.on('uncaughtException', (err) => {
118
- console.error('Uncaught Exception:', err);
119
- });
120
- testBedrockThinking().catch((err) => {
121
- console.error(err);
122
- console.log('Conversation history:');
123
- console.dir(conversationHistory, { depth: null });
124
- console.log('Content parts:');
125
- console.dir(_contentParts, { depth: null });
126
- process.exit(1);
127
- });
128
- //# sourceMappingURL=thinking-bedrock.js.map
@@ -1,130 +0,0 @@
1
- // src/scripts/thinking-vertexai.ts
2
- import { config } from 'dotenv';
3
- config();
4
- import { HumanMessage } from '@langchain/core/messages';
5
- import { ChatModelStreamHandler, createContentAggregator } from '@/stream';
6
- import { ToolEndHandler, ModelEndHandler } from '@/events';
7
- import { GraphEvents, Providers } from '@/common';
8
- import { getLLMConfig } from '@/utils/llmConfig';
9
- import { getArgs } from '@/scripts/args';
10
- import { Run } from '@/run';
11
- const conversationHistory = [];
12
- let _contentParts = [];
13
- const collectedUsage = [];
14
- async function testVertexAIThinking() {
15
- const { userName } = await getArgs();
16
- const instructions = `You are a helpful AI assistant for ${userName}. When answering questions, be thorough in your reasoning.`;
17
- const { contentParts, aggregateContent } = createContentAggregator();
18
- _contentParts = contentParts;
19
- // Set up event handlers
20
- const customHandlers = {
21
- [GraphEvents.TOOL_END]: new ToolEndHandler(),
22
- [GraphEvents.CHAT_MODEL_END]: new ModelEndHandler(collectedUsage),
23
- [GraphEvents.CHAT_MODEL_STREAM]: new ChatModelStreamHandler(),
24
- [GraphEvents.ON_RUN_STEP_COMPLETED]: {
25
- handle: (event, data) => {
26
- console.log('====== ON_RUN_STEP_COMPLETED ======');
27
- aggregateContent({
28
- event,
29
- data: data,
30
- });
31
- },
32
- },
33
- [GraphEvents.ON_RUN_STEP]: {
34
- handle: (event, data) => {
35
- aggregateContent({ event, data });
36
- },
37
- },
38
- [GraphEvents.ON_RUN_STEP_DELTA]: {
39
- handle: (event, data) => {
40
- aggregateContent({ event, data });
41
- },
42
- },
43
- [GraphEvents.ON_MESSAGE_DELTA]: {
44
- handle: (event, data) => {
45
- aggregateContent({ event, data });
46
- },
47
- },
48
- [GraphEvents.ON_REASONING_DELTA]: {
49
- handle: (event, data) => {
50
- console.log('[ON_REASONING_DELTA]', JSON.stringify(data.delta.content?.[0]).slice(0, 100));
51
- aggregateContent({ event, data });
52
- },
53
- },
54
- };
55
- const baseLlmConfig = getLLMConfig(Providers.VERTEXAI);
56
- const llmConfig = {
57
- ...baseLlmConfig,
58
- model: 'gemini-3-flash-preview',
59
- location: 'global',
60
- streaming: true,
61
- streamUsage: true,
62
- thinkingConfig: {
63
- thinkingLevel: 'HIGH',
64
- includeThoughts: true,
65
- },
66
- };
67
- const run = await Run.create({
68
- runId: 'test-vertexai-thinking-id',
69
- graphConfig: {
70
- instructions,
71
- type: 'standard',
72
- llmConfig,
73
- },
74
- returnContent: true,
75
- skipCleanup: true,
76
- customHandlers: customHandlers,
77
- });
78
- const streamConfig = {
79
- configurable: {
80
- thread_id: 'vertexai-thinking-test-thread',
81
- },
82
- streamMode: 'values',
83
- version: 'v2',
84
- };
85
- // Test 1: Regular thinking mode
86
- console.log('\n\nTest 1: Vertex AI thinking mode with thinkingLevel=HIGH');
87
- const userMessage1 = 'How many r\'s are in the word "strawberry"? Think carefully.';
88
- conversationHistory.push(new HumanMessage(userMessage1));
89
- console.log('Running first query with Vertex AI thinking enabled...');
90
- const firstInputs = { messages: [...conversationHistory] };
91
- await run.processStream(firstInputs, streamConfig);
92
- // Extract and display results
93
- const finalMessages = run.getRunMessages();
94
- console.log('\n\nFinal messages after Test 1:');
95
- console.dir(finalMessages, { depth: null });
96
- // Test 2: Multi-turn conversation
97
- console.log('\n\nTest 2: Multi-turn conversation with Vertex AI thinking enabled');
98
- const userMessage2 = 'Now count the number of letters in "Mississippi". Explain step by step.';
99
- conversationHistory.push(new HumanMessage(userMessage2));
100
- console.log('Running second query with Vertex AI thinking enabled...');
101
- const secondInputs = { messages: [...conversationHistory] };
102
- await run.processStream(secondInputs, streamConfig);
103
- const finalMessages2 = run.getRunMessages();
104
- console.log('\n\nVertex AI thinking feature test completed!');
105
- console.dir(finalMessages2, { depth: null });
106
- console.log('\n\nContent parts:');
107
- console.dir(_contentParts, { depth: null });
108
- console.log('\n\nCollected usage:');
109
- console.dir(collectedUsage, { depth: null });
110
- }
111
- process.on('unhandledRejection', (reason, promise) => {
112
- console.error('Unhandled Rejection at:', promise, 'reason:', reason);
113
- console.log('Conversation history:');
114
- console.dir(conversationHistory, { depth: null });
115
- console.log('Content parts:');
116
- console.dir(_contentParts, { depth: null });
117
- process.exit(1);
118
- });
119
- process.on('uncaughtException', (err) => {
120
- console.error('Uncaught Exception:', err);
121
- });
122
- testVertexAIThinking().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=thinking-vertexai.js.map
@@ -1,134 +0,0 @@
1
- // src/scripts/test-thinking.ts
2
- import { config } from 'dotenv';
3
- config();
4
- import { HumanMessage, } from '@langchain/core/messages';
5
- import { ChatModelStreamHandler, createContentAggregator } from '@/stream';
6
- import { createCodeExecutionTool } from '@/tools/CodeExecutor';
7
- import { ToolEndHandler, ModelEndHandler } from '@/events';
8
- import { GraphEvents, Providers } from '@/common';
9
- import { getLLMConfig } from '@/utils/llmConfig';
10
- import { getArgs } from '@/scripts/args';
11
- import { Run } from '@/run';
12
- const conversationHistory = [];
13
- let _contentParts = [];
14
- const collectedUsage = [];
15
- async function testThinking() {
16
- const { userName } = await getArgs();
17
- const instructions = `You are a helpful AI assistant for ${userName}. When answering questions, be thorough in your reasoning.`;
18
- const { contentParts, aggregateContent } = createContentAggregator();
19
- _contentParts = contentParts;
20
- // Set up event handlers
21
- const customHandlers = {
22
- [GraphEvents.TOOL_END]: new ToolEndHandler(),
23
- [GraphEvents.CHAT_MODEL_END]: new ModelEndHandler(collectedUsage),
24
- [GraphEvents.CHAT_MODEL_STREAM]: new ChatModelStreamHandler(),
25
- [GraphEvents.ON_RUN_STEP_COMPLETED]: {
26
- handle: (event, data) => {
27
- console.log('====== ON_RUN_STEP_COMPLETED ======');
28
- aggregateContent({
29
- event,
30
- data: data,
31
- });
32
- },
33
- },
34
- [GraphEvents.ON_RUN_STEP]: {
35
- handle: (event, data) => {
36
- aggregateContent({ event, data });
37
- },
38
- },
39
- [GraphEvents.ON_RUN_STEP_DELTA]: {
40
- handle: (event, data) => {
41
- aggregateContent({ event, data });
42
- },
43
- },
44
- [GraphEvents.ON_MESSAGE_DELTA]: {
45
- handle: (event, data) => {
46
- aggregateContent({ event, data });
47
- },
48
- },
49
- [GraphEvents.ON_REASONING_DELTA]: {
50
- handle: (event, data) => {
51
- aggregateContent({ event, data });
52
- },
53
- },
54
- };
55
- const baseLlmConfig = getLLMConfig(Providers.ANTHROPIC);
56
- // Enable thinking with token budget
57
- const llmConfig = {
58
- ...baseLlmConfig,
59
- model: 'claude-3-7-sonnet-latest',
60
- thinking: { type: 'enabled', budget_tokens: 2000 },
61
- };
62
- const run = await Run.create({
63
- runId: 'test-thinking-id',
64
- graphConfig: {
65
- instructions,
66
- type: 'standard',
67
- tools: [createCodeExecutionTool()],
68
- llmConfig,
69
- },
70
- returnContent: true,
71
- skipCleanup: true,
72
- customHandlers: customHandlers,
73
- });
74
- const config = {
75
- configurable: {
76
- thread_id: 'thinking-test-thread',
77
- },
78
- streamMode: 'values',
79
- version: 'v2',
80
- };
81
- // Test 1: Regular thinking mode
82
- console.log('\n\nTest 1: Regular thinking mode');
83
- // const userMessage1 = `What would be the environmental and economic impacts if all cars globally were replaced by electric vehicles overnight?`;
84
- const userMessage1 = `Please print 'hello world' in python`;
85
- conversationHistory.push(new HumanMessage(userMessage1));
86
- console.log('Running first query with thinking enabled...');
87
- const firstInputs = { messages: [...conversationHistory] };
88
- await run.processStream(firstInputs, config);
89
- // Extract and display thinking blocks
90
- const finalMessages = run.getRunMessages();
91
- // Test 2: Try multi-turn conversation
92
- console.log('\n\nTest 2: Multi-turn conversation with thinking enabled');
93
- const userMessage2 = `Given your previous analysis, what would be the most significant technical challenges in making this transition?`;
94
- conversationHistory.push(new HumanMessage(userMessage2));
95
- console.log('Running second query with thinking enabled...');
96
- const secondInputs = { messages: [...conversationHistory] };
97
- await run.processStream(secondInputs, config);
98
- // Display thinking blocks for second response
99
- const finalMessages2 = run.getRunMessages();
100
- // Test 3: Redacted thinking mode
101
- console.log('\n\nTest 3: Redacted thinking mode');
102
- const magicString = 'ANTHROPIC_MAGIC_STRING_TRIGGER_REDACTED_THINKING_46C9A13E193C177646C7398A98432ECCCE4C1253D5E2D82641AC0E52CC2876CB';
103
- const userMessage3 = `${magicString}\n\nExplain how quantum computing works in simple terms.`;
104
- // Reset conversation for clean test
105
- conversationHistory.length = 0;
106
- conversationHistory.push(new HumanMessage(userMessage3));
107
- console.log('Running query with redacted thinking...');
108
- const thirdInputs = { messages: [...conversationHistory] };
109
- await run.processStream(thirdInputs, config);
110
- // Display redacted thinking blocks
111
- const finalMessages3 = run.getRunMessages();
112
- console.log('\n\nThinking feature test completed!');
113
- console.dir(finalMessages3, { depth: null });
114
- }
115
- process.on('unhandledRejection', (reason, promise) => {
116
- console.error('Unhandled Rejection at:', promise, 'reason:', reason);
117
- console.log('Conversation history:');
118
- console.dir(conversationHistory, { depth: null });
119
- console.log('Content parts:');
120
- console.dir(_contentParts, { depth: null });
121
- process.exit(1);
122
- });
123
- process.on('uncaughtException', (err) => {
124
- console.error('Uncaught Exception:', err);
125
- });
126
- testThinking().catch((err) => {
127
- console.error(err);
128
- console.log('Conversation history:');
129
- console.dir(conversationHistory, { depth: null });
130
- console.log('Content parts:');
131
- console.dir(_contentParts, { depth: null });
132
- process.exit(1);
133
- });
134
- //# sourceMappingURL=thinking.js.map