@eko-ai/eko 1.0.9 → 1.0.10

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 (280) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +139 -139
  3. package/dist/extension/script/bing.js +0 -0
  4. package/dist/extension/script/build_dom_tree.js +661 -661
  5. package/dist/extension/script/common.js +0 -0
  6. package/dist/extension/script/duckduckgo.js +0 -0
  7. package/dist/extension/script/google.js +0 -0
  8. package/dist/extension/tools/cancel_workflow.d.ts +9 -0
  9. package/dist/extension.cjs.js +75 -75
  10. package/dist/extension.esm.js +75 -75
  11. package/dist/extension_content_script.js +55 -55
  12. package/dist/fellou.cjs.js +18 -18
  13. package/dist/fellou.esm.js +18 -18
  14. package/dist/index.cjs.js +4356 -4255
  15. package/dist/index.d.ts +2 -1
  16. package/dist/index.esm.js +4356 -4256
  17. package/dist/jest.config.js +10 -0
  18. package/dist/jest.config.js.map +1 -0
  19. package/dist/nodejs.cjs.js +1627 -1627
  20. package/dist/nodejs.esm.js +1627 -1627
  21. package/dist/rollup.config.js +171 -0
  22. package/dist/rollup.config.js.map +1 -0
  23. package/dist/script.js +10 -0
  24. package/dist/script.js.map +1 -0
  25. package/dist/services/llm/deepseek-provider.d.ts +13 -0
  26. package/dist/services/llm/provider-factory.d.ts +4 -0
  27. package/dist/services/llm/siliconflow-provider.d.ts +13 -0
  28. package/dist/services/workflow/generator.d.ts +1 -0
  29. package/dist/src/core/eko.js +99 -0
  30. package/dist/src/core/eko.js.map +1 -0
  31. package/dist/src/core/tool-registry.js +51 -0
  32. package/dist/src/core/tool-registry.js.map +1 -0
  33. package/dist/src/extension/content/index.js +409 -0
  34. package/dist/src/extension/content/index.js.map +1 -0
  35. package/dist/src/extension/core.js +29 -0
  36. package/dist/src/extension/core.js.map +1 -0
  37. package/dist/src/extension/index.js +12 -0
  38. package/dist/src/extension/index.js.map +1 -0
  39. package/dist/src/extension/script/bing.js +25 -0
  40. package/dist/src/extension/script/bing.js.map +1 -0
  41. package/dist/src/extension/script/build_dom_tree.js +585 -0
  42. package/dist/src/extension/script/build_dom_tree.js.map +1 -0
  43. package/dist/src/extension/script/common.js +203 -0
  44. package/dist/src/extension/script/common.js.map +1 -0
  45. package/dist/src/extension/script/duckduckgo.js +25 -0
  46. package/dist/src/extension/script/duckduckgo.js.map +1 -0
  47. package/dist/src/extension/script/google.js +26 -0
  48. package/dist/src/extension/script/google.js.map +1 -0
  49. package/dist/src/extension/tools/browser.js +174 -0
  50. package/dist/src/extension/tools/browser.js.map +1 -0
  51. package/dist/src/extension/tools/browser_use.js +186 -0
  52. package/dist/src/extension/tools/browser_use.js.map +1 -0
  53. package/dist/src/extension/tools/element_click.js +123 -0
  54. package/dist/src/extension/tools/element_click.js.map +1 -0
  55. package/dist/src/extension/tools/export_file.js +93 -0
  56. package/dist/src/extension/tools/export_file.js.map +1 -0
  57. package/dist/src/extension/tools/extract_content.js +38 -0
  58. package/dist/src/extension/tools/extract_content.js.map +1 -0
  59. package/dist/src/extension/tools/find_element_position.js +125 -0
  60. package/dist/src/extension/tools/find_element_position.js.map +1 -0
  61. package/dist/src/extension/tools/html_script.js +219 -0
  62. package/dist/src/extension/tools/html_script.js.map +1 -0
  63. package/dist/src/extension/tools/index.js +12 -0
  64. package/dist/src/extension/tools/index.js.map +1 -0
  65. package/dist/src/extension/tools/open_url.js +68 -0
  66. package/dist/src/extension/tools/open_url.js.map +1 -0
  67. package/dist/src/extension/tools/request_login.js +87 -0
  68. package/dist/src/extension/tools/request_login.js.map +1 -0
  69. package/dist/src/extension/tools/screenshot.js +26 -0
  70. package/dist/src/extension/tools/screenshot.js.map +1 -0
  71. package/dist/src/extension/tools/tab_management.js +160 -0
  72. package/dist/src/extension/tools/tab_management.js.map +1 -0
  73. package/dist/src/extension/tools/web_search.js +281 -0
  74. package/dist/src/extension/tools/web_search.js.map +1 -0
  75. package/dist/src/extension/utils.js +244 -0
  76. package/dist/src/extension/utils.js.map +1 -0
  77. package/dist/src/fellou/computer.js +104 -0
  78. package/dist/src/fellou/computer.js.map +1 -0
  79. package/dist/src/fellou/index.js +7 -0
  80. package/dist/src/fellou/index.js.map +1 -0
  81. package/dist/src/fellou/tools/computer_use.js +111 -0
  82. package/dist/src/fellou/tools/computer_use.js.map +1 -0
  83. package/dist/src/index.js +9 -0
  84. package/dist/src/index.js.map +1 -0
  85. package/dist/src/models/action.js +364 -0
  86. package/dist/src/models/action.js.map +1 -0
  87. package/dist/src/models/workflow.js +120 -0
  88. package/dist/src/models/workflow.js.map +1 -0
  89. package/dist/src/nodejs/core.js +18 -0
  90. package/dist/src/nodejs/core.js.map +1 -0
  91. package/dist/src/nodejs/index.js +6 -0
  92. package/dist/src/nodejs/index.js.map +1 -0
  93. package/dist/src/nodejs/script/build_dom_tree.js +586 -0
  94. package/dist/src/nodejs/script/build_dom_tree.js.map +1 -0
  95. package/dist/src/nodejs/tools/browser_use.js +458 -0
  96. package/dist/src/nodejs/tools/browser_use.js.map +1 -0
  97. package/dist/src/nodejs/tools/command_execute.js +65 -0
  98. package/dist/src/nodejs/tools/command_execute.js.map +1 -0
  99. package/dist/src/nodejs/tools/file_read.js +45 -0
  100. package/dist/src/nodejs/tools/file_read.js.map +1 -0
  101. package/dist/src/nodejs/tools/file_write.js +95 -0
  102. package/dist/src/nodejs/tools/file_write.js.map +1 -0
  103. package/dist/src/nodejs/tools/index.js +5 -0
  104. package/dist/src/nodejs/tools/index.js.map +1 -0
  105. package/dist/src/schemas/workflow.schema.js +64 -0
  106. package/dist/src/schemas/workflow.schema.js.map +1 -0
  107. package/dist/src/services/llm/claude-provider.js +140 -0
  108. package/dist/src/services/llm/claude-provider.js.map +1 -0
  109. package/dist/src/services/llm/deepseek-provider.js +432 -0
  110. package/dist/src/services/llm/deepseek-provider.js.map +1 -0
  111. package/dist/src/services/llm/glm-provider.js +317 -0
  112. package/dist/src/services/llm/glm-provider.js.map +1 -0
  113. package/dist/src/services/llm/openai-provider copy.js +317 -0
  114. package/dist/src/services/llm/openai-provider copy.js.map +1 -0
  115. package/dist/src/services/llm/openai-provider.js +317 -0
  116. package/dist/src/services/llm/openai-provider.js.map +1 -0
  117. package/dist/src/services/parser/workflow-parser.js +208 -0
  118. package/dist/src/services/parser/workflow-parser.js.map +1 -0
  119. package/dist/src/services/workflow/generator.js +105 -0
  120. package/dist/src/services/workflow/generator.js.map +1 -0
  121. package/dist/src/services/workflow/templates.js +42 -0
  122. package/dist/src/services/workflow/templates.js.map +1 -0
  123. package/dist/src/types/action.types.js +2 -0
  124. package/dist/src/types/action.types.js.map +1 -0
  125. package/dist/src/types/eko.types.js +2 -0
  126. package/dist/src/types/eko.types.js.map +1 -0
  127. package/dist/src/types/index.js +6 -0
  128. package/dist/src/types/index.js.map +1 -0
  129. package/dist/src/types/llm.types.js +2 -0
  130. package/dist/src/types/llm.types.js.map +1 -0
  131. package/dist/src/types/parser.types.js +2 -0
  132. package/dist/src/types/parser.types.js.map +1 -0
  133. package/dist/src/types/tools.types.js +2 -0
  134. package/dist/src/types/tools.types.js.map +1 -0
  135. package/dist/src/types/workflow.types.js +3 -0
  136. package/dist/src/types/workflow.types.js.map +1 -0
  137. package/dist/src/web/core.js +18 -0
  138. package/dist/src/web/core.js.map +1 -0
  139. package/dist/src/web/index.js +9 -0
  140. package/dist/src/web/index.js.map +1 -0
  141. package/dist/src/web/script/build_dom_tree.js +584 -0
  142. package/dist/src/web/script/build_dom_tree.js.map +1 -0
  143. package/dist/src/web/tools/browser.js +249 -0
  144. package/dist/src/web/tools/browser.js.map +1 -0
  145. package/dist/src/web/tools/browser_use.js +176 -0
  146. package/dist/src/web/tools/browser_use.js.map +1 -0
  147. package/dist/src/web/tools/element_click.js +121 -0
  148. package/dist/src/web/tools/element_click.js.map +1 -0
  149. package/dist/src/web/tools/export_file.js +74 -0
  150. package/dist/src/web/tools/export_file.js.map +1 -0
  151. package/dist/src/web/tools/extract_content.js +24 -0
  152. package/dist/src/web/tools/extract_content.js.map +1 -0
  153. package/dist/src/web/tools/find_element_position.js +121 -0
  154. package/dist/src/web/tools/find_element_position.js.map +1 -0
  155. package/dist/src/web/tools/html_script.js +219 -0
  156. package/dist/src/web/tools/html_script.js.map +1 -0
  157. package/dist/src/web/tools/index.js +8 -0
  158. package/dist/src/web/tools/index.js.map +1 -0
  159. package/dist/src/web/tools/screenshot.js +24 -0
  160. package/dist/src/web/tools/screenshot.js.map +1 -0
  161. package/dist/test/integration/claude-provider.test.js +170 -0
  162. package/dist/test/integration/claude-provider.test.js.map +1 -0
  163. package/dist/test/integration/deepseek-provider.test.js +171 -0
  164. package/dist/test/integration/deepseek-provider.test.js.map +1 -0
  165. package/dist/test/integration/glm-provider.test.js +173 -0
  166. package/dist/test/integration/glm-provider.test.js.map +1 -0
  167. package/dist/test/integration/openai-provider.test copy.js +170 -0
  168. package/dist/test/integration/openai-provider.test copy.js.map +1 -0
  169. package/dist/test/integration/openai-provider.test.js +170 -0
  170. package/dist/test/integration/openai-provider.test.js.map +1 -0
  171. package/dist/test/integration/qwen-provider.js +170 -0
  172. package/dist/test/integration/qwen-provider.js.map +1 -0
  173. package/dist/test/integration/qwen-provider.test copy.js +170 -0
  174. package/dist/test/integration/qwen-provider.test copy.js.map +1 -0
  175. package/dist/test/integration/qwen-provider.test.js +170 -0
  176. package/dist/test/integration/qwen-provider.test.js.map +1 -0
  177. package/dist/test/integration/workflow.execution.test.js +152 -0
  178. package/dist/test/integration/workflow.execution.test.js.map +1 -0
  179. package/dist/test/integration/workflow.generation-and-execution.test.js +131 -0
  180. package/dist/test/integration/workflow.generation-and-execution.test.js.map +1 -0
  181. package/dist/test/integration/workflow.generator.test.js +207 -0
  182. package/dist/test/integration/workflow.generator.test.js.map +1 -0
  183. package/dist/test/unit/action.test.js +186 -0
  184. package/dist/test/unit/action.test.js.map +1 -0
  185. package/dist/test/unit/tool-registry.test.js +99 -0
  186. package/dist/test/unit/tool-registry.test.js.map +1 -0
  187. package/dist/test/unit/workflow-parser.test.js +189 -0
  188. package/dist/test/unit/workflow-parser.test.js.map +1 -0
  189. package/dist/test/unit/workflow.test.js +102 -0
  190. package/dist/test/unit/workflow.test.js.map +1 -0
  191. package/dist/types/jest.config.d.ts +10 -0
  192. package/dist/types/rollup.config.d.ts +16 -0
  193. package/dist/types/script.d.ts +1 -0
  194. package/dist/types/src/core/eko.d.ts +20 -0
  195. package/dist/types/src/core/tool-registry.d.ts +13 -0
  196. package/dist/types/src/extension/content/index.d.ts +16 -0
  197. package/dist/types/src/extension/core.d.ts +11 -0
  198. package/dist/types/src/extension/index.d.ts +7 -0
  199. package/dist/types/src/extension/script/bing.d.ts +0 -0
  200. package/dist/types/src/extension/script/build_dom_tree.d.ts +38 -0
  201. package/dist/types/src/extension/script/common.d.ts +0 -0
  202. package/dist/types/src/extension/script/duckduckgo.d.ts +0 -0
  203. package/dist/types/src/extension/script/google.d.ts +0 -0
  204. package/dist/types/src/extension/tools/browser.d.ts +22 -0
  205. package/dist/types/src/extension/tools/browser_use.d.ts +19 -0
  206. package/dist/types/src/extension/tools/element_click.d.ts +12 -0
  207. package/dist/types/src/extension/tools/export_file.d.ts +18 -0
  208. package/dist/types/src/extension/tools/extract_content.d.ts +18 -0
  209. package/dist/types/src/extension/tools/find_element_position.d.ts +12 -0
  210. package/dist/types/src/extension/tools/html_script.d.ts +10 -0
  211. package/dist/types/src/extension/tools/index.d.ts +11 -0
  212. package/dist/types/src/extension/tools/open_url.d.ts +18 -0
  213. package/dist/{extension/tools/form_autofill.d.ts → types/src/extension/tools/request_login.d.ts} +3 -4
  214. package/dist/types/src/extension/tools/screenshot.d.ts +18 -0
  215. package/dist/types/src/extension/tools/tab_management.d.ts +19 -0
  216. package/dist/types/src/extension/tools/web_search.d.ts +18 -0
  217. package/dist/types/src/extension/utils.d.ts +31 -0
  218. package/dist/types/src/fellou/computer.d.ts +20 -0
  219. package/dist/types/src/fellou/index.d.ts +6 -0
  220. package/dist/types/src/fellou/tools/computer_use.d.ts +18 -0
  221. package/dist/types/src/index.d.ts +8 -0
  222. package/dist/types/src/models/action.d.ts +22 -0
  223. package/dist/types/src/models/workflow.d.ts +16 -0
  224. package/dist/types/src/nodejs/core.d.ts +2 -0
  225. package/dist/types/src/nodejs/index.d.ts +3 -0
  226. package/dist/types/src/nodejs/script/build_dom_tree.d.ts +1 -0
  227. package/dist/types/src/nodejs/tools/browser_use.d.ts +28 -0
  228. package/dist/types/src/nodejs/tools/command_execute.d.ts +12 -0
  229. package/dist/types/src/nodejs/tools/file_read.d.ts +11 -0
  230. package/dist/types/src/nodejs/tools/file_write.d.ts +15 -0
  231. package/dist/types/src/nodejs/tools/index.d.ts +4 -0
  232. package/dist/types/src/schemas/workflow.schema.d.ts +88 -0
  233. package/dist/types/src/services/llm/claude-provider.d.ts +11 -0
  234. package/dist/types/src/services/llm/deepseek-provider.d.ts +15 -0
  235. package/dist/types/src/services/llm/glm-provider.d.ts +11 -0
  236. package/dist/types/src/services/llm/openai-provider copy.d.ts +11 -0
  237. package/dist/types/src/services/llm/openai-provider.d.ts +11 -0
  238. package/dist/types/src/services/parser/workflow-parser.d.ts +29 -0
  239. package/dist/types/src/services/workflow/generator.d.ts +13 -0
  240. package/dist/types/src/services/workflow/templates.d.ts +8 -0
  241. package/dist/types/src/types/action.types.d.ts +38 -0
  242. package/dist/types/src/types/eko.types.d.ts +21 -0
  243. package/dist/types/src/types/index.d.ts +5 -0
  244. package/dist/types/src/types/llm.types.d.ts +54 -0
  245. package/dist/types/src/types/parser.types.d.ts +9 -0
  246. package/dist/types/src/types/tools.types.d.ts +88 -0
  247. package/dist/types/src/types/workflow.types.d.ts +39 -0
  248. package/dist/types/src/web/core.d.ts +2 -0
  249. package/dist/types/src/web/index.d.ts +5 -0
  250. package/dist/types/src/web/script/build_dom_tree.d.ts +10 -0
  251. package/dist/types/src/web/tools/browser.d.ts +21 -0
  252. package/dist/types/src/web/tools/browser_use.d.ts +19 -0
  253. package/dist/types/src/web/tools/element_click.d.ts +12 -0
  254. package/dist/types/src/web/tools/export_file.d.ts +18 -0
  255. package/dist/types/src/web/tools/extract_content.d.ts +17 -0
  256. package/dist/types/src/web/tools/find_element_position.d.ts +12 -0
  257. package/dist/types/src/web/tools/html_script.d.ts +10 -0
  258. package/dist/types/src/web/tools/index.d.ts +7 -0
  259. package/dist/types/src/web/tools/screenshot.d.ts +18 -0
  260. package/dist/types/test/integration/claude-provider.test.d.ts +1 -0
  261. package/dist/types/test/integration/deepseek-provider.test.d.ts +1 -0
  262. package/dist/types/test/integration/glm-provider.test.d.ts +1 -0
  263. package/dist/types/test/integration/openai-provider.test copy.d.ts +1 -0
  264. package/dist/types/test/integration/openai-provider.test.d.ts +1 -0
  265. package/dist/types/test/integration/qwen-provider.d.ts +1 -0
  266. package/dist/types/test/integration/qwen-provider.test copy.d.ts +1 -0
  267. package/dist/types/test/integration/qwen-provider.test.d.ts +1 -0
  268. package/dist/types/test/integration/workflow.execution.test.d.ts +1 -0
  269. package/dist/types/test/integration/workflow.generation-and-execution.test.d.ts +1 -0
  270. package/dist/types/test/integration/workflow.generator.test.d.ts +1 -0
  271. package/dist/types/test/unit/action.test.d.ts +1 -0
  272. package/dist/types/test/unit/tool-registry.test.d.ts +1 -0
  273. package/dist/types/test/unit/workflow-parser.test.d.ts +1 -0
  274. package/dist/types/test/unit/workflow.test.d.ts +1 -0
  275. package/dist/universal_tools/human/text.d.ts +9 -0
  276. package/dist/web.cjs.js +117 -117
  277. package/dist/web.esm.js +117 -117
  278. package/package.json +106 -106
  279. package/dist/fellou/tools/index.d.ts +0 -2
  280. package/dist/types/framework.types.d.ts +0 -11
@@ -0,0 +1,170 @@
1
+ import { OpenaiProvider } from '../../src/services/llm/openai-provider';
2
+ import dotenv from 'dotenv';
3
+ dotenv.config();
4
+ const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
5
+ const OPENAI_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1";
6
+ if (!OPENAI_API_KEY) {
7
+ throw new Error('OPENAI_API_KEY environment variable is required for integration tests');
8
+ }
9
+ // Only run these tests if explicitly enabled
10
+ const ENABLE_INTEGRATION_TESTS = process.env.ENABLE_INTEGRATION_TESTS === 'true';
11
+ const describeIntegration = ENABLE_INTEGRATION_TESTS ? describe : describe.skip;
12
+ // Default model for all tests
13
+ const DEFAULT_MODEL = 'qwen-vl-max';
14
+ describeIntegration('OpenaiProvider Integration', () => {
15
+ let provider;
16
+ beforeAll(() => {
17
+ provider = new OpenaiProvider(OPENAI_API_KEY, DEFAULT_MODEL, {
18
+ baseURL: OPENAI_BASE_URL,
19
+ });
20
+ });
21
+ describe('generateText', () => {
22
+ const params = {
23
+ temperature: 0.7,
24
+ maxTokens: 1000,
25
+ };
26
+ const toolParams = {
27
+ ...params,
28
+ tools: [
29
+ {
30
+ name: 'calculate',
31
+ description: 'Performs a calculation and returns the result',
32
+ input_schema: {
33
+ type: 'object',
34
+ properties: {
35
+ expression: {
36
+ type: 'string',
37
+ description: 'The mathematical expression to calculate',
38
+ },
39
+ },
40
+ required: ['expression'],
41
+ },
42
+ },
43
+ ],
44
+ toolChoice: { type: 'auto' },
45
+ };
46
+ test('should generate simple text response', async () => {
47
+ const messages = [
48
+ {
49
+ role: 'user',
50
+ content: 'What is 2+2? Please respond with just the number.',
51
+ },
52
+ ];
53
+ const result = await provider.generateText(messages, params);
54
+ expect(result.textContent).toBe('4');
55
+ expect(result.toolCalls).toHaveLength(0);
56
+ expect(result.stop_reason).toBe('stop');
57
+ }, 30000);
58
+ test('should use tools when provided', async () => {
59
+ const messages = [
60
+ {
61
+ role: 'user',
62
+ content: 'What is 234 * 456?',
63
+ },
64
+ ];
65
+ const result = await provider.generateText(messages, toolParams);
66
+ expect(result.toolCalls).toHaveLength(1);
67
+ expect(result.toolCalls[0].name).toBe('calculate');
68
+ expect(result.toolCalls[0].input).toHaveProperty('expression');
69
+ expect(result.stop_reason).toBe('tool_calls');
70
+ }, 30000);
71
+ it('should handle multi-turn conversation', async () => {
72
+ const user_message = {
73
+ role: 'user',
74
+ content: 'What is 234 * 456?',
75
+ };
76
+ const messages_1 = [user_message];
77
+ const result_1 = await provider.generateText(messages_1, toolParams);
78
+ const tool_use_id = result_1.toolCalls[0].id;
79
+ const messages_2 = [
80
+ user_message,
81
+ {
82
+ role: 'assistant',
83
+ content: result_1.content,
84
+ },
85
+ {
86
+ role: 'user',
87
+ content: [
88
+ {
89
+ type: 'tool_result',
90
+ tool_use_id: tool_use_id,
91
+ content: [{ type: 'text', text: '106704' }],
92
+ },
93
+ ],
94
+ },
95
+ ];
96
+ const result = await provider.generateText(messages_2, toolParams);
97
+ expect(result.textContent).toMatch(/106,?704/);
98
+ expect(result.stop_reason).toBe('stop');
99
+ }, 30000);
100
+ });
101
+ describe('generateStream', () => {
102
+ it('should stream text content', async () => {
103
+ const accumulated = [];
104
+ let isStarted = false;
105
+ let isCompleted = false;
106
+ const handler = {
107
+ onStart: () => {
108
+ isStarted = true;
109
+ },
110
+ onContent: (content) => {
111
+ accumulated.push(content);
112
+ },
113
+ onComplete: () => {
114
+ isCompleted = true;
115
+ },
116
+ onError: (error) => {
117
+ throw error;
118
+ },
119
+ };
120
+ const messages = [
121
+ {
122
+ role: 'user',
123
+ content: 'Count from 1 to 3, with each number on a new line (\n).',
124
+ },
125
+ ];
126
+ await provider.generateStream(messages, {
127
+ temperature: 0,
128
+ maxTokens: 100,
129
+ }, handler);
130
+ expect(isStarted).toBe(true);
131
+ expect(isCompleted).toBe(true);
132
+ expect(accumulated.join('')).toMatch(/1\s+2\s+3\s?/);
133
+ }, 30000);
134
+ it('should stream tool use', async () => {
135
+ const toolCalls = [];
136
+ const handler = {
137
+ onToolUse: (toolCall) => {
138
+ toolCalls.push(toolCall);
139
+ },
140
+ };
141
+ const messages = [
142
+ {
143
+ role: 'user',
144
+ content: 'What is 123 + 456?',
145
+ },
146
+ ];
147
+ await provider.generateStream(messages, {
148
+ temperature: 0,
149
+ tools: [
150
+ {
151
+ name: 'calculate',
152
+ description: 'Performs a calculation',
153
+ input_schema: {
154
+ type: 'object',
155
+ properties: {
156
+ expression: { type: 'string' },
157
+ },
158
+ required: ['expression'],
159
+ },
160
+ },
161
+ ],
162
+ toolChoice: { type: 'auto' },
163
+ }, handler);
164
+ expect(toolCalls).toHaveLength(1);
165
+ expect(toolCalls[0].name).toBe('calculate');
166
+ expect(toolCalls[0].input).toHaveProperty('expression');
167
+ }, 30000);
168
+ });
169
+ });
170
+ //# sourceMappingURL=qwen-provider.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qwen-provider.test.js","sourceRoot":"","sources":["../../../test/integration/qwen-provider.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;AAClD,MAAM,eAAe,GAAG,mDAAmD,CAAC;AAC5E,IAAI,CAAC,cAAc,EAAE,CAAC;IACpB,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;AAC3F,CAAC;AAED,6CAA6C;AAC7C,MAAM,wBAAwB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,MAAM,CAAC;AACjF,MAAM,mBAAmB,GAAG,wBAAwB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;AAEhF,8BAA8B;AAC9B,MAAM,aAAa,GAAG,aAAa,CAAC;AAEpC,mBAAmB,CAAC,4BAA4B,EAAE,GAAG,EAAE;IACrD,IAAI,QAAwB,CAAC;IAE7B,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,GAAG,IAAI,cAAc,CAAC,cAAc,EAAE,aAAa,EAAE;YAC3D,OAAO,EAAE,eAAe;SACzB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,MAAM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;QAEV,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;YACtC,MAAM,SAAS,GAAU,EAAE,CAAC;YAC5B,MAAM,OAAO,GAAqB;gBAChC,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE;oBACtB,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC3B,CAAC;aACF,CAAC;YAEF,MAAM,QAAQ,GAAc;gBAC1B;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,oBAAoB;iBAC9B;aACF,CAAC;YAEF,MAAM,QAAQ,CAAC,cAAc,CAC3B,QAAQ,EACR;gBACE,WAAW,EAAE,CAAC;gBACd,KAAK,EAAE;oBACL;wBACE,IAAI,EAAE,WAAW;wBACjB,WAAW,EAAE,wBAAwB;wBACrC,YAAY,EAAE;4BACZ,IAAI,EAAE,QAAQ;4BACd,UAAU,EAAE;gCACV,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;6BAC/B;4BACD,QAAQ,EAAE,CAAC,YAAY,CAAC;yBACzB;qBACF;iBACF;gBACD,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;aAC7B,EACD,OAAO,CACR,CAAC;YAEF,MAAM,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC5C,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QAC1D,CAAC,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,152 @@
1
+ import { WorkflowImpl } from '../../src/models/workflow';
2
+ import { ActionImpl } from '../../src/models/action';
3
+ import { ClaudeProvider } from '../../src/services/llm/claude-provider';
4
+ import dotenv from 'dotenv';
5
+ dotenv.config();
6
+ const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
7
+ if (!ANTHROPIC_API_KEY) {
8
+ throw new Error('ANTHROPIC_API_KEY environment variable is required for integration tests');
9
+ }
10
+ // Only run these tests if explicitly enabled
11
+ const ENABLE_INTEGRATION_TESTS = process.env.ENABLE_INTEGRATION_TESTS === 'true';
12
+ const describeIntegration = ENABLE_INTEGRATION_TESTS ? describe : describe.skip;
13
+ // Addition tool
14
+ class AddTool {
15
+ constructor() {
16
+ this.name = 'add';
17
+ this.description = 'Add two numbers together.';
18
+ this.input_schema = {
19
+ type: 'object',
20
+ properties: {
21
+ a: {
22
+ type: 'number',
23
+ description: 'First number'
24
+ },
25
+ b: {
26
+ type: 'number',
27
+ description: 'Second number'
28
+ }
29
+ },
30
+ required: ['a', 'b']
31
+ };
32
+ }
33
+ async execute(context, params) {
34
+ const { a, b } = params;
35
+ return { result: a + b };
36
+ }
37
+ }
38
+ // Multiplication tool
39
+ class MultiplyTool {
40
+ constructor() {
41
+ this.name = 'multiply';
42
+ this.description = 'Multiply two numbers together.';
43
+ this.input_schema = {
44
+ type: 'object',
45
+ properties: {
46
+ a: {
47
+ type: 'number',
48
+ description: 'First number'
49
+ },
50
+ b: {
51
+ type: 'number',
52
+ description: 'Second number'
53
+ }
54
+ },
55
+ required: ['a', 'b']
56
+ };
57
+ }
58
+ async execute(context, params) {
59
+ const { a, b } = params;
60
+ return { result: a * b };
61
+ }
62
+ }
63
+ // Echo tool to display results
64
+ class EchoTool {
65
+ constructor() {
66
+ this.name = 'echo';
67
+ this.description = 'Display or print a message or value.';
68
+ this.input_schema = {
69
+ type: 'object',
70
+ properties: {
71
+ message: {
72
+ type: 'string',
73
+ description: 'Message or value to display'
74
+ }
75
+ },
76
+ required: ['message']
77
+ };
78
+ }
79
+ async execute(context, params) {
80
+ const { message } = params;
81
+ console.log('Echo:', message);
82
+ return { displayed: message };
83
+ }
84
+ }
85
+ describeIntegration('Minimal Workflow Integration', () => {
86
+ let llmProvider;
87
+ let context;
88
+ let tools;
89
+ beforeAll(() => {
90
+ llmProvider = new ClaudeProvider(ANTHROPIC_API_KEY);
91
+ tools = [new AddTool(), new MultiplyTool(), new EchoTool()];
92
+ });
93
+ beforeEach(() => {
94
+ });
95
+ it('should calculate 23 * 45 + 67 using tool chain', async () => {
96
+ // Create calculation action
97
+ const calculateAction = ActionImpl.createPromptAction('calculate expression 23 * 45 + 67', 'calculate expression 23 * 45 + 67', tools, llmProvider, { maxTokens: 1000 });
98
+ // Create display action
99
+ const displayAction = ActionImpl.createPromptAction('display result', 'display result', tools, llmProvider, { maxTokens: 1000 });
100
+ // Create workflow
101
+ const workflow = new WorkflowImpl('calc-and-display', 'Calculate and Display Workflow');
102
+ workflow.llmProvider = llmProvider;
103
+ // Add calculation node
104
+ const calculateNode = {
105
+ id: 'calculate',
106
+ name: 'Calculate Expression',
107
+ dependencies: [],
108
+ input: {
109
+ type: 'object',
110
+ schema: {},
111
+ value: null
112
+ },
113
+ output: {
114
+ type: 'object',
115
+ schema: {},
116
+ value: null
117
+ },
118
+ action: calculateAction
119
+ };
120
+ workflow.addNode(calculateNode);
121
+ // Add display node
122
+ workflow.addNode({
123
+ id: 'display',
124
+ name: 'Display Result',
125
+ dependencies: ['calculate'],
126
+ input: {
127
+ type: 'object',
128
+ schema: {},
129
+ value: null
130
+ },
131
+ output: {
132
+ type: 'object',
133
+ schema: {},
134
+ value: null
135
+ },
136
+ action: displayAction
137
+ });
138
+ // Execute workflow
139
+ await workflow.execute();
140
+ // Log all context variables
141
+ console.log('Context variables:', Object.fromEntries(workflow.variables));
142
+ // Find numerical result in context variables
143
+ const numberResults = Array.from(workflow.variables.entries())
144
+ .filter(([_, value]) => typeof value === 'number');
145
+ expect(numberResults.length).toBeGreaterThan(0);
146
+ // Find the final calculation result (1102)
147
+ const finalResult = numberResults.find(([_, value]) => value === 1102);
148
+ expect(finalResult).toBeDefined();
149
+ console.log('Found result:', finalResult);
150
+ }, 30000);
151
+ });
152
+ //# sourceMappingURL=workflow.execution.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.execution.test.js","sourceRoot":"","sources":["../../../test/integration/workflow.execution.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;AACxD,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACvB,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;AAC9F,CAAC;AAED,6CAA6C;AAC7C,MAAM,wBAAwB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,MAAM,CAAC;AACjF,MAAM,mBAAmB,GAAG,wBAAwB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;AAEhF,gBAAgB;AAChB,MAAM,OAAO;IAAb;QACE,SAAI,GAAG,KAAK,CAAC;QACb,gBAAW,GAAG,2BAA2B,CAAC;QAC1C,iBAAY,GAAG;YACb,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,CAAC,EAAE;oBACD,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,cAAc;iBACnB;gBACV,CAAC,EAAE;oBACD,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,eAAe;iBACpB;aACc;YAC1B,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;SACN,CAAC;IAMnB,CAAC;IAJC,KAAK,CAAC,OAAO,CAAC,OAAyB,EAAE,MAAe;QACtD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,MAAkC,CAA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services/workflow/generator';
2
+ import { ClaudeProvider } from '../../src/services/llm/claude-provider';
3
+ import { WorkflowParser } from '../../src/services/parser/workflow-parser';
4
+ import * as fs from 'fs/promises';
5
+ import * as path from 'path';
6
+ import dotenv from 'dotenv';
7
+ import { ToolRegistry } from '@/index';
8
+ dotenv.config();
9
+ const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
10
+ if (!ANTHROPIC_API_KEY) {
11
+ throw new Error('ANTHROPIC_API_KEY environment variable is required for integration tests');
12
+ }
13
+ // Only run these tests if explicitly enabled
14
+ const ENABLE_INTEGRATION_TESTS = process.env.ENABLE_INTEGRATION_TESTS === 'true';
15
+ const describeIntegration = ENABLE_INTEGRATION_TESTS ? describe : describe.skip;
16
+ // Addition tool
17
+ class AddTool {
18
+ constructor() {
19
+ this.name = 'add';
20
+ this.description = 'Add two numbers together.';
21
+ this.input_schema = {
22
+ type: 'object',
23
+ properties: {
24
+ a: {
25
+ type: 'number',
26
+ description: 'First number',
27
+ },
28
+ b: {
29
+ type: 'number',
30
+ description: 'Second number',
31
+ },
32
+ },
33
+ required: ['a', 'b'],
34
+ };
35
+ }
36
+ async execute(context, params) {
37
+ const { a, b } = params;
38
+ await new Promise((resolve) => setTimeout(resolve, 5000));
39
+ return { result: a + b };
40
+ }
41
+ }
42
+ // Multiplication tool
43
+ class MultiplyTool {
44
+ constructor() {
45
+ this.name = 'multiply';
46
+ this.description = 'Multiply two numbers together.';
47
+ this.input_schema = {
48
+ type: 'object',
49
+ properties: {
50
+ a: {
51
+ type: 'number',
52
+ description: 'First number',
53
+ },
54
+ b: {
55
+ type: 'number',
56
+ description: 'Second number',
57
+ },
58
+ },
59
+ required: ['a', 'b'],
60
+ };
61
+ }
62
+ async execute(context, params) {
63
+ const { a, b } = params;
64
+ await new Promise((resolve) => setTimeout(resolve, 5000));
65
+ return { result: a * b };
66
+ }
67
+ }
68
+ // Echo tool to display results
69
+ class EchoTool {
70
+ constructor() {
71
+ this.name = 'echo';
72
+ this.description = 'Display or print a message or value.';
73
+ this.input_schema = {
74
+ type: 'object',
75
+ properties: {
76
+ message: {
77
+ type: 'string',
78
+ description: 'Message or value to display',
79
+ },
80
+ },
81
+ required: ['message'],
82
+ };
83
+ }
84
+ async execute(context, params) {
85
+ const { message } = params;
86
+ console.log('Echo:', message);
87
+ return { displayed: message };
88
+ }
89
+ }
90
+ describeIntegration('Minimal Workflow Integration with Generation', () => {
91
+ let llmProvider;
92
+ let context;
93
+ let tools;
94
+ let toolRegistry;
95
+ let generator;
96
+ // Helper function to save workflow DSL to file
97
+ async function saveWorkflowToFile(dsl, filename) {
98
+ const testOutputDir = path.join(__dirname, '../fixtures/generated');
99
+ await fs.mkdir(testOutputDir, { recursive: true });
100
+ await fs.writeFile(path.join(testOutputDir, filename), dsl, 'utf-8');
101
+ }
102
+ beforeAll(() => {
103
+ llmProvider = new ClaudeProvider(ANTHROPIC_API_KEY);
104
+ tools = [new AddTool(), new MultiplyTool(), new EchoTool()];
105
+ toolRegistry = new ToolRegistry();
106
+ tools.forEach((tool) => toolRegistry.registerTool(tool));
107
+ generator = new WorkflowGenerator(llmProvider, toolRegistry);
108
+ });
109
+ beforeEach(() => { });
110
+ it('should calculate 23 * 45 + 67 using tool chain', async () => {
111
+ const prompt = 'Calculate 23 * 45 + 67 using the provided calculation tools, and display the result';
112
+ // Generate workflow
113
+ const workflow = await generator.generateWorkflow(prompt);
114
+ // Convert to DSL for validation and inspection
115
+ const dsl = WorkflowParser.serialize(workflow);
116
+ // Save DSL for human inspection
117
+ await saveWorkflowToFile(dsl, 'calculator.json');
118
+ // Execute workflow
119
+ await workflow.execute();
120
+ // Log all context variables
121
+ console.log('Context variables:', Object.fromEntries(workflow.variables));
122
+ // Find numerical result in context variables
123
+ const numberResults = Array.from(workflow.variables.entries()).filter(([_, value]) => typeof value === 'number');
124
+ expect(numberResults.length).toBeGreaterThan(0);
125
+ // Find the final calculation result (1102)
126
+ const finalResult = numberResults.find(([_, value]) => value === 1102);
127
+ expect(finalResult).toBeDefined();
128
+ console.log('Found result:', finalResult);
129
+ }, 60000);
130
+ });
131
+ //# sourceMappingURL=workflow.generation-and-execution.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.generation-and-execution.test.js","sourceRoot":"","sources":["../../../test/integration/workflow.generation-and-execution.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;AACxD,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACvB,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;AAC9F,CAAC;AAED,6CAA6C;AAC7C,MAAM,wBAAwB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,MAAM,CAAC;AACjF,MAAM,mBAAmB,GAAG,wBAAwB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;AAEhF,gBAAgB;AAChB,MAAM,OAAO;IAAb;QACE,SAAI,GAAG,KAAK,CAAC;QACb,gBAAW,GAAG,2BAA2B,CAAC;QAC1C,iBAAY,GAAG;YACb,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,CAAC,EAAE;oBACD,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,cAAc;iBACnB;gBACV,CAAC,EAAE;oBACD,IAAI,EAAE,QAAQ;oBACd,WAA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