lynkr 1.0.0 → 2.0.0

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 (41) hide show
  1. package/CITATIONS.bib +6 -0
  2. package/DEPLOYMENT.md +1001 -0
  3. package/README.md +215 -71
  4. package/docs/index.md +55 -2
  5. package/monitor-agents.sh +31 -0
  6. package/package.json +7 -3
  7. package/src/agents/context-manager.js +220 -0
  8. package/src/agents/definitions/loader.js +563 -0
  9. package/src/agents/executor.js +412 -0
  10. package/src/agents/index.js +157 -0
  11. package/src/agents/parallel-coordinator.js +68 -0
  12. package/src/agents/reflector.js +321 -0
  13. package/src/agents/skillbook.js +331 -0
  14. package/src/agents/store.js +244 -0
  15. package/src/api/router.js +55 -0
  16. package/src/clients/databricks.js +214 -17
  17. package/src/clients/routing.js +15 -7
  18. package/src/clients/standard-tools.js +341 -0
  19. package/src/config/index.js +41 -5
  20. package/src/orchestrator/index.js +254 -37
  21. package/src/server.js +2 -0
  22. package/src/tools/agent-task.js +96 -0
  23. package/test/azure-openai-config.test.js +203 -0
  24. package/test/azure-openai-error-resilience.test.js +238 -0
  25. package/test/azure-openai-format-conversion.test.js +354 -0
  26. package/test/azure-openai-integration.test.js +281 -0
  27. package/test/azure-openai-routing.test.js +148 -0
  28. package/test/azure-openai-streaming.test.js +171 -0
  29. package/test/format-conversion.test.js +578 -0
  30. package/test/hybrid-routing-integration.test.js +18 -11
  31. package/test/openrouter-error-resilience.test.js +418 -0
  32. package/test/passthrough-mode.test.js +385 -0
  33. package/test/routing.test.js +9 -3
  34. package/test/web-tools.test.js +3 -0
  35. package/test-agents-simple.js +43 -0
  36. package/test-cli-connection.sh +33 -0
  37. package/test-learning-unit.js +126 -0
  38. package/test-learning.js +112 -0
  39. package/test-parallel-agents.sh +124 -0
  40. package/test-parallel-direct.js +155 -0
  41. package/test-subagents.sh +117 -0
@@ -0,0 +1,578 @@
1
+ const assert = require("assert");
2
+ const { describe, it, beforeEach, afterEach } = require("node:test");
3
+
4
+ describe("Enhanced Format Conversion", () => {
5
+ let openrouterUtils;
6
+
7
+ beforeEach(() => {
8
+ // Set MODEL_PROVIDER to avoid validation errors
9
+ process.env.MODEL_PROVIDER = "databricks";
10
+ process.env.DATABRICKS_API_KEY = "test-key";
11
+ process.env.DATABRICKS_API_BASE = "http://test.com";
12
+
13
+ // Clear module cache
14
+ delete require.cache[require.resolve("../src/clients/openrouter-utils")];
15
+ delete require.cache[require.resolve("../src/config")];
16
+ openrouterUtils = require("../src/clients/openrouter-utils");
17
+ });
18
+
19
+ describe("Anthropic to OpenRouter Conversion", () => {
20
+ describe("Message Conversion", () => {
21
+ it("should convert simple text messages", () => {
22
+ const anthropicMessages = [
23
+ {
24
+ role: "user",
25
+ content: "Hello, how are you?"
26
+ }
27
+ ];
28
+
29
+ const result = openrouterUtils.convertAnthropicMessagesToOpenRouter(anthropicMessages);
30
+
31
+ assert.strictEqual(result.length, 1);
32
+ assert.strictEqual(result[0].role, "user");
33
+ assert.strictEqual(result[0].content, "Hello, how are you?");
34
+ });
35
+
36
+ it("should convert messages with content blocks", () => {
37
+ const anthropicMessages = [
38
+ {
39
+ role: "user",
40
+ content: [
41
+ { type: "text", text: "Please read this file" }
42
+ ]
43
+ }
44
+ ];
45
+
46
+ const result = openrouterUtils.convertAnthropicMessagesToOpenRouter(anthropicMessages);
47
+
48
+ assert.strictEqual(result.length, 1);
49
+ assert.strictEqual(result[0].role, "user");
50
+ assert.strictEqual(result[0].content, "Please read this file");
51
+ });
52
+
53
+ it("should handle multiple text blocks", () => {
54
+ const anthropicMessages = [
55
+ {
56
+ role: "user",
57
+ content: [
58
+ { type: "text", text: "First part" },
59
+ { type: "text", text: "Second part" }
60
+ ]
61
+ }
62
+ ];
63
+
64
+ const result = openrouterUtils.convertAnthropicMessagesToOpenRouter(anthropicMessages);
65
+
66
+ assert.strictEqual(result.length, 1);
67
+ assert.strictEqual(result[0].content, "First part\nSecond part");
68
+ });
69
+
70
+ it("should convert assistant messages with tool_use blocks", () => {
71
+ const anthropicMessages = [
72
+ {
73
+ role: "assistant",
74
+ content: [
75
+ { type: "text", text: "I'll read that file" },
76
+ {
77
+ type: "tool_use",
78
+ id: "toolu_123",
79
+ name: "Read",
80
+ input: { file_path: "/tmp/test.txt" }
81
+ }
82
+ ]
83
+ }
84
+ ];
85
+
86
+ const result = openrouterUtils.convertAnthropicMessagesToOpenRouter(anthropicMessages);
87
+
88
+ assert.strictEqual(result.length, 1);
89
+ assert.strictEqual(result[0].role, "assistant");
90
+ assert.strictEqual(result[0].content, "I'll read that file");
91
+ assert.strictEqual(Array.isArray(result[0].tool_calls), true);
92
+ assert.strictEqual(result[0].tool_calls.length, 1);
93
+ assert.strictEqual(result[0].tool_calls[0].id, "toolu_123");
94
+ assert.strictEqual(result[0].tool_calls[0].function.name, "Read");
95
+ });
96
+
97
+ it("should convert tool_result blocks to tool messages", () => {
98
+ // Must include the assistant message with tool_use first
99
+ // otherwise tool_result is orphaned and gets removed
100
+ const anthropicMessages = [
101
+ {
102
+ role: "assistant",
103
+ content: [
104
+ {
105
+ type: "tool_use",
106
+ id: "toolu_123",
107
+ name: "Read",
108
+ input: { file_path: "/tmp/test.txt" }
109
+ }
110
+ ]
111
+ },
112
+ {
113
+ role: "user",
114
+ content: [
115
+ {
116
+ type: "tool_result",
117
+ tool_use_id: "toolu_123",
118
+ content: "File content here"
119
+ }
120
+ ]
121
+ }
122
+ ];
123
+
124
+ const result = openrouterUtils.convertAnthropicMessagesToOpenRouter(anthropicMessages);
125
+
126
+ // Tool results should be converted to tool role messages
127
+ const toolMessage = result.find(m => m.role === "tool");
128
+ assert.ok(toolMessage, "Tool message should be present");
129
+ assert.strictEqual(toolMessage.tool_call_id, "toolu_123");
130
+ assert.strictEqual(toolMessage.content, "File content here");
131
+ });
132
+
133
+ it("should handle text content separate from tool_result", () => {
134
+ // Note: OpenRouter validation requires tool messages to immediately follow
135
+ // the assistant message with tool_calls. A user message in between will
136
+ // cause the tool message to be filtered as orphaned.
137
+ const anthropicMessages = [
138
+ {
139
+ role: "assistant",
140
+ content: [
141
+ {
142
+ type: "tool_use",
143
+ id: "toolu_123",
144
+ name: "Write",
145
+ input: { file_path: "/tmp/test.txt", content: "data" }
146
+ }
147
+ ]
148
+ },
149
+ {
150
+ role: "user",
151
+ content: [
152
+ {
153
+ type: "tool_result",
154
+ tool_use_id: "toolu_123",
155
+ content: "Success"
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ role: "user",
161
+ content: "Here's additional feedback"
162
+ }
163
+ ];
164
+
165
+ const result = openrouterUtils.convertAnthropicMessagesToOpenRouter(anthropicMessages);
166
+
167
+ // Should have assistant with tool_calls, tool message, and user message
168
+ const assistantMsg = result.find(m => m.role === "assistant");
169
+ const toolMsg = result.find(m => m.role === "tool");
170
+ const userMsg = result.find(m => m.role === "user" && m.content === "Here's additional feedback");
171
+
172
+ assert.ok(assistantMsg, "Assistant message should be present");
173
+ assert.ok(toolMsg, "Tool message should be present");
174
+ assert.ok(userMsg, "User message should be present");
175
+ assert.strictEqual(toolMsg.content, "Success");
176
+ });
177
+ });
178
+
179
+ describe("Tool Conversion", () => {
180
+ it("should convert Anthropic tools to OpenRouter format", () => {
181
+ const anthropicTools = [
182
+ {
183
+ name: "Write",
184
+ description: "Write a file to the filesystem",
185
+ input_schema: {
186
+ type: "object",
187
+ properties: {
188
+ file_path: { type: "string", description: "Path to file" },
189
+ content: { type: "string", description: "File content" }
190
+ },
191
+ required: ["file_path", "content"]
192
+ }
193
+ }
194
+ ];
195
+
196
+ const result = openrouterUtils.convertAnthropicToolsToOpenRouter(anthropicTools);
197
+
198
+ assert.strictEqual(result.length, 1);
199
+ assert.strictEqual(result[0].type, "function");
200
+ assert.strictEqual(result[0].function.name, "Write");
201
+ assert.strictEqual(result[0].function.description, "Write a file to the filesystem");
202
+ assert.deepStrictEqual(result[0].function.parameters, anthropicTools[0].input_schema);
203
+ });
204
+
205
+ it("should handle tools without descriptions", () => {
206
+ const anthropicTools = [
207
+ {
208
+ name: "TestTool",
209
+ input_schema: {
210
+ type: "object",
211
+ properties: {}
212
+ }
213
+ }
214
+ ];
215
+
216
+ const result = openrouterUtils.convertAnthropicToolsToOpenRouter(anthropicTools);
217
+
218
+ assert.strictEqual(result.length, 1);
219
+ assert.strictEqual(result[0].function.name, "TestTool");
220
+ assert.strictEqual(result[0].function.description, "");
221
+ });
222
+
223
+ it("should handle empty tools array", () => {
224
+ const result = openrouterUtils.convertAnthropicToolsToOpenRouter([]);
225
+ assert.strictEqual(result.length, 0);
226
+ });
227
+
228
+ it("should convert multiple tools", () => {
229
+ const anthropicTools = [
230
+ {
231
+ name: "Read",
232
+ description: "Read a file",
233
+ input_schema: { type: "object", properties: {} }
234
+ },
235
+ {
236
+ name: "Write",
237
+ description: "Write a file",
238
+ input_schema: { type: "object", properties: {} }
239
+ },
240
+ {
241
+ name: "Execute",
242
+ description: "Execute a command",
243
+ input_schema: { type: "object", properties: {} }
244
+ }
245
+ ];
246
+
247
+ const result = openrouterUtils.convertAnthropicToolsToOpenRouter(anthropicTools);
248
+
249
+ assert.strictEqual(result.length, 3);
250
+ assert.strictEqual(result[0].function.name, "Read");
251
+ assert.strictEqual(result[1].function.name, "Write");
252
+ assert.strictEqual(result[2].function.name, "Execute");
253
+ });
254
+ });
255
+ });
256
+
257
+ describe("OpenRouter to Anthropic Conversion", () => {
258
+ describe("Response Conversion", () => {
259
+ it("should convert text-only response", () => {
260
+ const openRouterResponse = {
261
+ choices: [
262
+ {
263
+ message: {
264
+ role: "assistant",
265
+ content: "Hello! I'm here to help."
266
+ },
267
+ finish_reason: "stop"
268
+ }
269
+ ],
270
+ model: "openai/gpt-4o-mini",
271
+ usage: { prompt_tokens: 10, completion_tokens: 8, total_tokens: 18 }
272
+ };
273
+
274
+ const result = openrouterUtils.convertOpenRouterResponseToAnthropic(
275
+ openRouterResponse,
276
+ "test-model"
277
+ );
278
+
279
+ assert.strictEqual(result.type, "message");
280
+ assert.strictEqual(result.role, "assistant");
281
+ assert.strictEqual(result.content.length, 1);
282
+ assert.strictEqual(result.content[0].type, "text");
283
+ assert.strictEqual(result.content[0].text, "Hello! I'm here to help.");
284
+ assert.strictEqual(result.stop_reason, "end_turn");
285
+ });
286
+
287
+ it("should convert response with tool calls", () => {
288
+ const openRouterResponse = {
289
+ choices: [
290
+ {
291
+ message: {
292
+ role: "assistant",
293
+ content: "I'll read that file",
294
+ tool_calls: [
295
+ {
296
+ id: "call_abc123",
297
+ type: "function",
298
+ function: {
299
+ name: "Read",
300
+ arguments: JSON.stringify({ file_path: "/tmp/test.txt" })
301
+ }
302
+ }
303
+ ]
304
+ },
305
+ finish_reason: "tool_calls"
306
+ }
307
+ ],
308
+ model: "openai/gpt-4o-mini",
309
+ usage: { prompt_tokens: 15, completion_tokens: 25, total_tokens: 40 }
310
+ };
311
+
312
+ const result = openrouterUtils.convertOpenRouterResponseToAnthropic(
313
+ openRouterResponse,
314
+ "test-model"
315
+ );
316
+
317
+ assert.strictEqual(result.content.length, 2);
318
+ assert.strictEqual(result.content[0].type, "text");
319
+ assert.strictEqual(result.content[1].type, "tool_use");
320
+ assert.strictEqual(result.content[1].id, "call_abc123");
321
+ assert.strictEqual(result.content[1].name, "Read");
322
+ assert.deepStrictEqual(result.content[1].input, { file_path: "/tmp/test.txt" });
323
+ assert.strictEqual(result.stop_reason, "tool_use");
324
+ });
325
+
326
+ it("should convert response with multiple tool calls", () => {
327
+ const openRouterResponse = {
328
+ choices: [
329
+ {
330
+ message: {
331
+ role: "assistant",
332
+ content: "Processing multiple operations",
333
+ tool_calls: [
334
+ {
335
+ id: "call_1",
336
+ type: "function",
337
+ function: {
338
+ name: "Read",
339
+ arguments: JSON.stringify({ file_path: "/input.txt" })
340
+ }
341
+ },
342
+ {
343
+ id: "call_2",
344
+ type: "function",
345
+ function: {
346
+ name: "Write",
347
+ arguments: JSON.stringify({
348
+ file_path: "/output.txt",
349
+ content: "result"
350
+ })
351
+ }
352
+ }
353
+ ]
354
+ },
355
+ finish_reason: "tool_calls"
356
+ }
357
+ ],
358
+ model: "openai/gpt-4o-mini",
359
+ usage: { prompt_tokens: 20, completion_tokens: 40, total_tokens: 60 }
360
+ };
361
+
362
+ const result = openrouterUtils.convertOpenRouterResponseToAnthropic(
363
+ openRouterResponse,
364
+ "test-model"
365
+ );
366
+
367
+ assert.strictEqual(result.content.length, 3); // 1 text + 2 tool_use
368
+ assert.strictEqual(result.content[0].type, "text");
369
+ assert.strictEqual(result.content[1].type, "tool_use");
370
+ assert.strictEqual(result.content[1].name, "Read");
371
+ assert.strictEqual(result.content[2].type, "tool_use");
372
+ assert.strictEqual(result.content[2].name, "Write");
373
+ });
374
+
375
+ it("should generate unique IDs for tools", () => {
376
+ const openRouterResponse = {
377
+ choices: [
378
+ {
379
+ message: {
380
+ role: "assistant",
381
+ content: "Using tools",
382
+ tool_calls: [
383
+ {
384
+ id: "call_1",
385
+ type: "function",
386
+ function: { name: "Tool1", arguments: "{}" }
387
+ },
388
+ {
389
+ id: "call_2",
390
+ type: "function",
391
+ function: { name: "Tool2", arguments: "{}" }
392
+ }
393
+ ]
394
+ },
395
+ finish_reason: "tool_calls"
396
+ }
397
+ ],
398
+ model: "test-model",
399
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 }
400
+ };
401
+
402
+ const result = openrouterUtils.convertOpenRouterResponseToAnthropic(
403
+ openRouterResponse,
404
+ "test-model"
405
+ );
406
+
407
+ const tool1Id = result.content[1].id;
408
+ const tool2Id = result.content[2].id;
409
+
410
+ assert.strictEqual(tool1Id !== tool2Id, true);
411
+ assert.strictEqual(typeof tool1Id, "string");
412
+ assert.strictEqual(typeof tool2Id, "string");
413
+ });
414
+
415
+ it("should map finish_reason correctly", () => {
416
+ const testCases = [
417
+ { finish_reason: "stop", expected: "end_turn" },
418
+ { finish_reason: "tool_calls", expected: "tool_use" },
419
+ { finish_reason: "length", expected: "max_tokens" }
420
+ ];
421
+
422
+ testCases.forEach(({ finish_reason, expected }) => {
423
+ const response = {
424
+ choices: [
425
+ {
426
+ message: {
427
+ role: "assistant",
428
+ content: "Test",
429
+ ...(finish_reason === "tool_calls" && {
430
+ tool_calls: [
431
+ {
432
+ id: "test",
433
+ function: { name: "test", arguments: "{}" }
434
+ }
435
+ ]
436
+ })
437
+ },
438
+ finish_reason
439
+ }
440
+ ],
441
+ model: "test-model",
442
+ usage: { prompt_tokens: 10, completion_tokens: 10, total_tokens: 20 }
443
+ };
444
+
445
+ const result = openrouterUtils.convertOpenRouterResponseToAnthropic(
446
+ response,
447
+ "test-model"
448
+ );
449
+
450
+ assert.strictEqual(result.stop_reason, expected);
451
+ });
452
+ });
453
+
454
+ it("should include proper message ID format", () => {
455
+ const response = {
456
+ choices: [
457
+ {
458
+ message: {
459
+ role: "assistant",
460
+ content: "Response"
461
+ },
462
+ finish_reason: "stop"
463
+ }
464
+ ],
465
+ id: "chatcmpl-123",
466
+ model: "openai/gpt-4o-mini",
467
+ usage: { prompt_tokens: 10, completion_tokens: 10, total_tokens: 20 }
468
+ };
469
+
470
+ const result = openrouterUtils.convertOpenRouterResponseToAnthropic(
471
+ response,
472
+ "test-model"
473
+ );
474
+
475
+ assert.strictEqual(typeof result.id, "string");
476
+ assert.strictEqual(result.id.length > 0, true);
477
+ });
478
+
479
+ it("should preserve usage metadata", () => {
480
+ const response = {
481
+ choices: [
482
+ {
483
+ message: {
484
+ role: "assistant",
485
+ content: "Test"
486
+ },
487
+ finish_reason: "stop"
488
+ }
489
+ ],
490
+ model: "openai/gpt-4o-mini",
491
+ usage: {
492
+ prompt_tokens: 100,
493
+ completion_tokens: 50,
494
+ total_tokens: 150
495
+ }
496
+ };
497
+
498
+ const result = openrouterUtils.convertOpenRouterResponseToAnthropic(
499
+ response,
500
+ "test-model"
501
+ );
502
+
503
+ assert.strictEqual(result.usage.input_tokens, 100);
504
+ assert.strictEqual(result.usage.output_tokens, 50);
505
+ });
506
+ });
507
+ });
508
+
509
+ describe("Round-Trip Conversion", () => {
510
+ it("should maintain data integrity through round-trip conversion", () => {
511
+ const originalMessage = {
512
+ role: "user",
513
+ content: "Please write to /tmp/test.txt"
514
+ };
515
+
516
+ // Convert to OpenRouter
517
+ const openRouterFormat = openrouterUtils.convertAnthropicMessagesToOpenRouter([
518
+ originalMessage
519
+ ]);
520
+
521
+ // Verify conversion
522
+ assert.strictEqual(openRouterFormat[0].role, "user");
523
+ assert.strictEqual(openRouterFormat[0].content, "Please write to /tmp/test.txt");
524
+ });
525
+
526
+ it("should handle complex conversation with tools", () => {
527
+ const conversation = [
528
+ {
529
+ role: "user",
530
+ content: "Read /tmp/input.txt and write to /tmp/output.txt"
531
+ },
532
+ {
533
+ role: "assistant",
534
+ content: [
535
+ { type: "text", text: "I'll do that for you" },
536
+ {
537
+ type: "tool_use",
538
+ id: "toolu_1",
539
+ name: "Read",
540
+ input: { file_path: "/tmp/input.txt" }
541
+ }
542
+ ]
543
+ },
544
+ {
545
+ role: "user",
546
+ content: [
547
+ {
548
+ type: "tool_result",
549
+ tool_use_id: "toolu_1",
550
+ content: "File contents"
551
+ }
552
+ ]
553
+ }
554
+ ];
555
+
556
+ // Convert to OpenRouter
557
+ const openRouterFormat = openrouterUtils.convertAnthropicMessagesToOpenRouter(
558
+ conversation
559
+ );
560
+
561
+ // Verify structure is maintained
562
+ assert.strictEqual(openRouterFormat.length >= 3, true);
563
+
564
+ // Check user message
565
+ const userMsgs = openRouterFormat.filter(m => m.role === "user");
566
+ assert.strictEqual(userMsgs.length >= 1, true);
567
+
568
+ // Check assistant message with tool calls
569
+ const assistantMsgs = openRouterFormat.filter(m => m.role === "assistant");
570
+ assert.strictEqual(assistantMsgs.length >= 1, true);
571
+ assert.strictEqual(Array.isArray(assistantMsgs[0].tool_calls), true);
572
+
573
+ // Check tool message
574
+ const toolMsgs = openRouterFormat.filter(m => m.role === "tool");
575
+ assert.strictEqual(toolMsgs.length >= 1, true);
576
+ });
577
+ });
578
+ });
@@ -42,35 +42,40 @@ describe("Hybrid Routing Integration Tests", () => {
42
42
  assert.strictEqual(config.ollama.endpoint, "http://localhost:11434");
43
43
  });
44
44
 
45
- it("should reject invalid OLLAMA_FALLBACK_PROVIDER", () => {
45
+ it("should reject invalid FALLBACK_PROVIDER", () => {
46
46
  process.env.PREFER_OLLAMA = "true";
47
47
  process.env.OLLAMA_ENDPOINT = "http://localhost:11434";
48
48
  process.env.OLLAMA_MODEL = "qwen2.5-coder:latest";
49
- process.env.OLLAMA_FALLBACK_PROVIDER = "invalid-provider";
49
+ process.env.FALLBACK_ENABLED = "true";
50
+ process.env.FALLBACK_PROVIDER = "invalid-provider";
50
51
 
51
52
  assert.throws(() => {
52
53
  require("../src/config");
53
- }, /OLLAMA_FALLBACK_PROVIDER must be one of/);
54
+ }, /FALLBACK_PROVIDER must be one of/);
54
55
  });
55
56
 
56
57
  it("should reject circular fallback (ollama -> ollama)", () => {
57
58
  process.env.PREFER_OLLAMA = "true";
58
59
  process.env.OLLAMA_ENDPOINT = "http://localhost:11434";
59
60
  process.env.OLLAMA_MODEL = "qwen2.5-coder:latest";
60
- process.env.OLLAMA_FALLBACK_PROVIDER = "ollama";
61
+ process.env.FALLBACK_ENABLED = "true";
62
+ process.env.FALLBACK_PROVIDER = "ollama";
61
63
 
62
64
  assert.throws(() => {
63
65
  require("../src/config");
64
- }, /OLLAMA_FALLBACK_PROVIDER cannot be 'ollama'/);
66
+ }, /FALLBACK_PROVIDER cannot be 'ollama'/);
65
67
  });
66
68
 
67
69
  it("should reject PREFER_OLLAMA with databricks fallback but no databricks credentials", () => {
70
+ process.env.MODEL_PROVIDER = "ollama"; // Set to ollama for hybrid routing scenario
68
71
  process.env.PREFER_OLLAMA = "true";
69
72
  process.env.OLLAMA_ENDPOINT = "http://localhost:11434";
70
73
  process.env.OLLAMA_MODEL = "qwen2.5-coder:latest";
71
- process.env.OLLAMA_FALLBACK_PROVIDER = "databricks";
72
- delete process.env.DATABRICKS_API_KEY;
73
- delete process.env.DATABRICKS_API_BASE;
74
+ process.env.FALLBACK_ENABLED = "true";
75
+ process.env.FALLBACK_PROVIDER = "databricks";
76
+ // Set to empty strings instead of deleting (dotenv.config() in config module would reload from .env)
77
+ process.env.DATABRICKS_API_KEY = "";
78
+ process.env.DATABRICKS_API_BASE = "";
74
79
 
75
80
  // Should throw error about missing databricks credentials
76
81
  // (Either from standard validation or hybrid routing validation)
@@ -83,16 +88,18 @@ describe("Hybrid Routing Integration Tests", () => {
83
88
  process.env.PREFER_OLLAMA = "true";
84
89
  process.env.OLLAMA_ENDPOINT = "http://localhost:11434";
85
90
  process.env.OLLAMA_MODEL = "qwen2.5-coder:latest";
86
- process.env.OLLAMA_FALLBACK_PROVIDER = "databricks";
91
+ process.env.FALLBACK_ENABLED = "true";
92
+ process.env.FALLBACK_PROVIDER = "databricks";
93
+ process.env.OLLAMA_MAX_TOOLS_FOR_ROUTING = "3"; // Override .env which sets it to 2
87
94
  process.env.DATABRICKS_API_KEY = "test-key";
88
95
  process.env.DATABRICKS_API_BASE = "http://test.com";
89
96
 
90
97
  const config = require("../src/config");
91
98
 
92
99
  assert.strictEqual(config.modelProvider.preferOllama, true);
93
- assert.strictEqual(config.modelProvider.ollamaFallbackEnabled, true);
100
+ assert.strictEqual(config.modelProvider.fallbackEnabled, true);
94
101
  assert.strictEqual(config.modelProvider.ollamaMaxToolsForRouting, 3);
95
- assert.strictEqual(config.modelProvider.ollamaFallbackProvider, "databricks");
102
+ assert.strictEqual(config.modelProvider.fallbackProvider, "databricks");
96
103
  });
97
104
  });
98
105