lynkr 8.0.0 → 8.0.1

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 (102) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/api/openai-router.js +34 -2
  4. package/src/clients/standard-tools.js +23 -0
  5. package/src/config/index.js +20 -0
  6. package/src/orchestrator/index.js +2 -2
  7. package/src/server.js +2 -12
  8. package/src/tools/index.js +4 -0
  9. package/src/tools/lazy-loader.js +7 -0
  10. package/src/tools/tinyfish.js +358 -0
  11. package/src/tools/truncate.js +1 -0
  12. package/.github/FUNDING.yml +0 -15
  13. package/.github/workflows/README.md +0 -215
  14. package/.github/workflows/ci.yml +0 -69
  15. package/.github/workflows/index.yml +0 -62
  16. package/.github/workflows/web-tools-tests.yml +0 -56
  17. package/CITATIONS.bib +0 -6
  18. package/DEPLOYMENT.md +0 -1001
  19. package/LYNKR-TUI-PLAN.md +0 -984
  20. package/PERFORMANCE-REPORT.md +0 -866
  21. package/PLAN-per-client-model-routing.md +0 -252
  22. package/docs/42642f749da6234f41b6b425c3bb07c9.txt +0 -1
  23. package/docs/BingSiteAuth.xml +0 -4
  24. package/docs/docs-style.css +0 -478
  25. package/docs/docs.html +0 -198
  26. package/docs/google5be250e608e6da39.html +0 -1
  27. package/docs/index.html +0 -577
  28. package/docs/index.md +0 -584
  29. package/docs/robots.txt +0 -4
  30. package/docs/sitemap.xml +0 -44
  31. package/docs/style.css +0 -1223
  32. package/docs/toon-integration-spec.md +0 -130
  33. package/documentation/README.md +0 -101
  34. package/documentation/api.md +0 -806
  35. package/documentation/claude-code-cli.md +0 -679
  36. package/documentation/codex-cli.md +0 -397
  37. package/documentation/contributing.md +0 -571
  38. package/documentation/cursor-integration.md +0 -734
  39. package/documentation/docker.md +0 -874
  40. package/documentation/embeddings.md +0 -762
  41. package/documentation/faq.md +0 -713
  42. package/documentation/features.md +0 -403
  43. package/documentation/headroom.md +0 -519
  44. package/documentation/installation.md +0 -758
  45. package/documentation/memory-system.md +0 -476
  46. package/documentation/production.md +0 -636
  47. package/documentation/providers.md +0 -1009
  48. package/documentation/routing.md +0 -476
  49. package/documentation/testing.md +0 -629
  50. package/documentation/token-optimization.md +0 -325
  51. package/documentation/tools.md +0 -697
  52. package/documentation/troubleshooting.md +0 -969
  53. package/final-test.js +0 -33
  54. package/headroom-sidecar/config.py +0 -93
  55. package/headroom-sidecar/requirements.txt +0 -14
  56. package/headroom-sidecar/server.py +0 -451
  57. package/monitor-agents.sh +0 -31
  58. package/scripts/audit-log-reader.js +0 -399
  59. package/scripts/compact-dictionary.js +0 -204
  60. package/scripts/test-deduplication.js +0 -448
  61. package/src/db/database.sqlite +0 -0
  62. package/te +0 -11622
  63. package/test/README.md +0 -212
  64. package/test/azure-openai-config.test.js +0 -213
  65. package/test/azure-openai-error-resilience.test.js +0 -238
  66. package/test/azure-openai-format-conversion.test.js +0 -354
  67. package/test/azure-openai-integration.test.js +0 -287
  68. package/test/azure-openai-routing.test.js +0 -175
  69. package/test/azure-openai-streaming.test.js +0 -171
  70. package/test/bedrock-integration.test.js +0 -457
  71. package/test/comprehensive-test-suite.js +0 -928
  72. package/test/config-validation.test.js +0 -207
  73. package/test/cursor-integration.test.js +0 -484
  74. package/test/format-conversion.test.js +0 -578
  75. package/test/hybrid-routing-integration.test.js +0 -269
  76. package/test/hybrid-routing-performance.test.js +0 -428
  77. package/test/llamacpp-integration.test.js +0 -882
  78. package/test/lmstudio-integration.test.js +0 -347
  79. package/test/memory/extractor.test.js +0 -398
  80. package/test/memory/retriever.test.js +0 -613
  81. package/test/memory/retriever.test.js.bak +0 -585
  82. package/test/memory/search.test.js +0 -537
  83. package/test/memory/search.test.js.bak +0 -389
  84. package/test/memory/store.test.js +0 -344
  85. package/test/memory/store.test.js.bak +0 -312
  86. package/test/memory/surprise.test.js +0 -300
  87. package/test/memory-performance.test.js +0 -472
  88. package/test/openai-integration.test.js +0 -683
  89. package/test/openrouter-error-resilience.test.js +0 -418
  90. package/test/passthrough-mode.test.js +0 -385
  91. package/test/performance-benchmark.js +0 -351
  92. package/test/performance-tests.js +0 -528
  93. package/test/routing.test.js +0 -225
  94. package/test/toon-compression.test.js +0 -131
  95. package/test/web-tools.test.js +0 -329
  96. package/test-agents-simple.js +0 -43
  97. package/test-cli-connection.sh +0 -33
  98. package/test-learning-unit.js +0 -126
  99. package/test-learning.js +0 -112
  100. package/test-parallel-agents.sh +0 -124
  101. package/test-parallel-direct.js +0 -155
  102. package/test-subagents.sh +0 -117
@@ -1,347 +0,0 @@
1
- const assert = require("assert");
2
- const { describe, it, beforeEach, afterEach } = require("node:test");
3
-
4
- describe("LM Studio Integration", () => {
5
- let originalEnv;
6
-
7
- beforeEach(() => {
8
- originalEnv = { ...process.env };
9
-
10
- // Clear module cache
11
- delete require.cache[require.resolve("../src/config")];
12
- delete require.cache[require.resolve("../src/clients/routing")];
13
- delete require.cache[require.resolve("../src/clients/openrouter-utils")];
14
-
15
- // Prevent .env TIER_* values from being picked up by dotenv
16
- process.env.TIER_SIMPLE = "";
17
- process.env.TIER_MEDIUM = "";
18
- process.env.TIER_COMPLEX = "";
19
- process.env.TIER_REASONING = "";
20
- });
21
-
22
- afterEach(() => {
23
- process.env = originalEnv;
24
- });
25
-
26
- describe("Configuration", () => {
27
- it("should accept lmstudio as a valid MODEL_PROVIDER", () => {
28
- process.env.MODEL_PROVIDER = "lmstudio";
29
- process.env.LMSTUDIO_ENDPOINT = "http://localhost:1234";
30
-
31
- const config = require("../src/config");
32
- assert.strictEqual(config.modelProvider.type, "lmstudio");
33
- });
34
-
35
- it("should use default endpoint when LMSTUDIO_ENDPOINT is not set", () => {
36
- process.env.MODEL_PROVIDER = "lmstudio";
37
- delete process.env.LMSTUDIO_ENDPOINT;
38
-
39
- const config = require("../src/config");
40
- assert.strictEqual(config.lmstudio.endpoint, "http://localhost:1234");
41
- });
42
-
43
- it("should use custom endpoint when LMSTUDIO_ENDPOINT is set", () => {
44
- process.env.MODEL_PROVIDER = "lmstudio";
45
- process.env.LMSTUDIO_ENDPOINT = "http://192.168.1.100:9000";
46
-
47
- const config = require("../src/config");
48
- assert.strictEqual(config.lmstudio.endpoint, "http://192.168.1.100:9000");
49
- });
50
-
51
- it("should throw error when LMSTUDIO_ENDPOINT is invalid URL", () => {
52
- process.env.MODEL_PROVIDER = "lmstudio";
53
- process.env.LMSTUDIO_ENDPOINT = "not-a-valid-url";
54
-
55
- assert.throws(
56
- () => require("../src/config"),
57
- /LMSTUDIO_ENDPOINT must be a valid URL/
58
- );
59
- });
60
-
61
- it("should use default model when LMSTUDIO_MODEL is not set", () => {
62
- process.env.MODEL_PROVIDER = "lmstudio";
63
- delete process.env.LMSTUDIO_MODEL;
64
-
65
- const config = require("../src/config");
66
- assert.strictEqual(config.lmstudio.model, "default");
67
- });
68
-
69
- it("should use custom model when LMSTUDIO_MODEL is set", () => {
70
- process.env.MODEL_PROVIDER = "lmstudio";
71
- process.env.LMSTUDIO_MODEL = "hermes-2-pro-llama-3-8b";
72
-
73
- const config = require("../src/config");
74
- assert.strictEqual(config.lmstudio.model, "hermes-2-pro-llama-3-8b");
75
- });
76
-
77
- it("should use default timeout when LMSTUDIO_TIMEOUT_MS is not set", () => {
78
- process.env.MODEL_PROVIDER = "lmstudio";
79
- delete process.env.LMSTUDIO_TIMEOUT_MS;
80
-
81
- const config = require("../src/config");
82
- assert.strictEqual(config.lmstudio.timeout, 120000);
83
- });
84
-
85
- it("should use custom timeout when LMSTUDIO_TIMEOUT_MS is set", () => {
86
- process.env.MODEL_PROVIDER = "lmstudio";
87
- process.env.LMSTUDIO_TIMEOUT_MS = "300000";
88
-
89
- const config = require("../src/config");
90
- assert.strictEqual(config.lmstudio.timeout, 300000);
91
- });
92
-
93
- it("should have null apiKey when LMSTUDIO_API_KEY is not set", () => {
94
- process.env.MODEL_PROVIDER = "lmstudio";
95
- delete process.env.LMSTUDIO_API_KEY;
96
-
97
- const config = require("../src/config");
98
- assert.strictEqual(config.lmstudio.apiKey, null);
99
- });
100
-
101
- it("should store apiKey when LMSTUDIO_API_KEY is set", () => {
102
- process.env.MODEL_PROVIDER = "lmstudio";
103
- process.env.LMSTUDIO_API_KEY = "my-secret-key";
104
-
105
- const config = require("../src/config");
106
- assert.strictEqual(config.lmstudio.apiKey, "my-secret-key");
107
- });
108
- });
109
-
110
- describe("Routing", () => {
111
- it("should route to lmstudio when MODEL_PROVIDER is lmstudio", () => {
112
- process.env.MODEL_PROVIDER = "lmstudio";
113
- process.env.LMSTUDIO_ENDPOINT = "http://localhost:1234";
114
-
115
- const config = require("../src/config");
116
- const routing = require("../src/clients/routing");
117
-
118
- const payload = { messages: [{ role: "user", content: "test" }] };
119
- const provider = routing.determineProviderSync(payload);
120
-
121
- assert.strictEqual(provider, "lmstudio");
122
- });
123
-
124
- it("should return static routing from determineProviderSmart when tiers disabled", async () => {
125
- process.env.MODEL_PROVIDER = "lmstudio";
126
- process.env.LMSTUDIO_ENDPOINT = "http://localhost:1234";
127
-
128
- const config = require("../src/config");
129
- const routing = require("../src/clients/routing");
130
-
131
- const payload = { messages: [{ role: "user", content: "test" }] };
132
- const result = await routing.determineProviderSmart(payload);
133
-
134
- assert.strictEqual(result.provider, "lmstudio");
135
- assert.strictEqual(result.method, "static");
136
- assert.strictEqual(result.reason, "tier_routing_disabled");
137
- });
138
-
139
- it("should throw error when lmstudio is set as FALLBACK_PROVIDER", () => {
140
- process.env.MODEL_PROVIDER = "ollama";
141
- process.env.OLLAMA_MODEL = "qwen2.5-coder:latest";
142
- process.env.FALLBACK_PROVIDER = "lmstudio";
143
- process.env.LMSTUDIO_ENDPOINT = "http://localhost:1234";
144
- process.env.FALLBACK_ENABLED = "true";
145
-
146
- assert.throws(
147
- () => require("../src/config"),
148
- /FALLBACK_PROVIDER cannot be 'lmstudio'/
149
- );
150
- });
151
- });
152
-
153
- describe("Response Conversion", () => {
154
- // LM Studio uses OpenAI-compatible format, so we reuse the same converter
155
-
156
- it("should convert LM Studio text response to Anthropic format", () => {
157
- process.env.MODEL_PROVIDER = "databricks";
158
- process.env.DATABRICKS_API_KEY = "test-key";
159
- process.env.DATABRICKS_API_BASE = "http://test.com";
160
-
161
- const { convertOpenRouterResponseToAnthropic } = require("../src/clients/openrouter-utils");
162
-
163
- const lmstudioResponse = {
164
- id: "chatcmpl-123",
165
- object: "chat.completion",
166
- created: 1677652288,
167
- model: "hermes-2-pro-llama-3-8b",
168
- choices: [
169
- {
170
- index: 0,
171
- message: {
172
- role: "assistant",
173
- content: "Hello! I'm running on LM Studio."
174
- },
175
- finish_reason: "stop"
176
- }
177
- ],
178
- usage: {
179
- prompt_tokens: 9,
180
- completion_tokens: 12,
181
- total_tokens: 21
182
- }
183
- };
184
-
185
- const result = convertOpenRouterResponseToAnthropic(lmstudioResponse, "claude-sonnet-4-5");
186
-
187
- assert.strictEqual(result.role, "assistant");
188
- assert.strictEqual(result.model, "claude-sonnet-4-5");
189
- assert.strictEqual(Array.isArray(result.content), true);
190
- assert.strictEqual(result.content.length, 1);
191
- assert.strictEqual(result.content[0].type, "text");
192
- assert.strictEqual(result.content[0].text, "Hello! I'm running on LM Studio.");
193
- assert.strictEqual(result.stop_reason, "end_turn");
194
- assert.strictEqual(result.usage.input_tokens, 9);
195
- assert.strictEqual(result.usage.output_tokens, 12);
196
- });
197
-
198
- it("should convert LM Studio tool call response to Anthropic format", () => {
199
- process.env.MODEL_PROVIDER = "databricks";
200
- process.env.DATABRICKS_API_KEY = "test-key";
201
- process.env.DATABRICKS_API_BASE = "http://test.com";
202
-
203
- const { convertOpenRouterResponseToAnthropic } = require("../src/clients/openrouter-utils");
204
-
205
- const lmstudioResponse = {
206
- id: "chatcmpl-123",
207
- object: "chat.completion",
208
- model: "hermes-2-pro-llama-3-8b",
209
- choices: [
210
- {
211
- index: 0,
212
- message: {
213
- role: "assistant",
214
- content: "I'll read that file for you.",
215
- tool_calls: [
216
- {
217
- id: "call_abc123",
218
- type: "function",
219
- function: {
220
- name: "Read",
221
- arguments: JSON.stringify({
222
- file_path: "/tmp/example.txt"
223
- })
224
- }
225
- }
226
- ]
227
- },
228
- finish_reason: "tool_calls"
229
- }
230
- ],
231
- usage: {
232
- prompt_tokens: 50,
233
- completion_tokens: 30,
234
- total_tokens: 80
235
- }
236
- };
237
-
238
- const result = convertOpenRouterResponseToAnthropic(lmstudioResponse, "claude-sonnet-4-5");
239
-
240
- assert.strictEqual(result.role, "assistant");
241
- assert.strictEqual(result.content.length, 2); // text + tool_use
242
- assert.strictEqual(result.content[0].type, "text");
243
- assert.strictEqual(result.content[0].text, "I'll read that file for you.");
244
- assert.strictEqual(result.content[1].type, "tool_use");
245
- assert.strictEqual(result.content[1].name, "Read");
246
- assert.strictEqual(result.content[1].id, "call_abc123");
247
- assert.deepStrictEqual(result.content[1].input, {
248
- file_path: "/tmp/example.txt"
249
- });
250
- assert.strictEqual(result.stop_reason, "tool_use");
251
- });
252
- });
253
-
254
- describe("Message Conversion", () => {
255
- it("should convert Anthropic messages to LM Studio (OpenAI) format", () => {
256
- process.env.MODEL_PROVIDER = "databricks";
257
- process.env.DATABRICKS_API_KEY = "test-key";
258
- process.env.DATABRICKS_API_BASE = "http://test.com";
259
-
260
- const { convertAnthropicMessagesToOpenRouter } = require("../src/clients/openrouter-utils");
261
-
262
- const anthropicMessages = [
263
- {
264
- role: "user",
265
- content: [
266
- { type: "text", text: "What is 2 + 2?" }
267
- ]
268
- },
269
- {
270
- role: "assistant",
271
- content: [
272
- { type: "text", text: "2 + 2 equals 4." }
273
- ]
274
- }
275
- ];
276
-
277
- const result = convertAnthropicMessagesToOpenRouter(anthropicMessages);
278
-
279
- assert.strictEqual(result.length, 2);
280
- assert.strictEqual(result[0].role, "user");
281
- assert.strictEqual(result[0].content, "What is 2 + 2?");
282
- assert.strictEqual(result[1].role, "assistant");
283
- assert.strictEqual(result[1].content, "2 + 2 equals 4.");
284
- });
285
- });
286
-
287
- describe("Tool Conversion", () => {
288
- it("should convert Anthropic tools to LM Studio (OpenAI) format", () => {
289
- process.env.MODEL_PROVIDER = "databricks";
290
- process.env.DATABRICKS_API_KEY = "test-key";
291
- process.env.DATABRICKS_API_BASE = "http://test.com";
292
-
293
- const { convertAnthropicToolsToOpenRouter } = require("../src/clients/openrouter-utils");
294
-
295
- const anthropicTools = [
296
- {
297
- name: "Read",
298
- description: "Read a file from disk",
299
- input_schema: {
300
- type: "object",
301
- properties: {
302
- file_path: { type: "string", description: "Path to the file" }
303
- },
304
- required: ["file_path"]
305
- }
306
- }
307
- ];
308
-
309
- const result = convertAnthropicToolsToOpenRouter(anthropicTools);
310
-
311
- assert.strictEqual(result.length, 1);
312
- assert.strictEqual(result[0].type, "function");
313
- assert.strictEqual(result[0].function.name, "Read");
314
- assert.strictEqual(result[0].function.description, "Read a file from disk");
315
- assert.deepStrictEqual(result[0].function.parameters, {
316
- type: "object",
317
- properties: {
318
- file_path: { type: "string", description: "Path to the file" }
319
- },
320
- required: ["file_path"]
321
- });
322
- });
323
- });
324
-
325
- describe("Fallback Prevention", () => {
326
- it("should prevent lmstudio from being used as fallback provider", () => {
327
- process.env.MODEL_PROVIDER = "ollama";
328
- process.env.OLLAMA_MODEL = "qwen2.5-coder:latest";
329
- process.env.FALLBACK_PROVIDER = "lmstudio";
330
- process.env.LMSTUDIO_ENDPOINT = "http://localhost:1234";
331
- process.env.FALLBACK_ENABLED = "true";
332
-
333
- assert.throws(
334
- () => require("../src/config"),
335
- /FALLBACK_PROVIDER cannot be 'lmstudio' \(local providers should not be fallbacks\)/
336
- );
337
- });
338
-
339
- it("should allow lmstudio as primary provider", () => {
340
- process.env.MODEL_PROVIDER = "lmstudio";
341
- process.env.LMSTUDIO_ENDPOINT = "http://localhost:1234";
342
-
343
- const config = require("../src/config");
344
- assert.strictEqual(config.modelProvider.type, "lmstudio");
345
- });
346
- });
347
- });