lynkr 8.0.0 → 9.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 (128) hide show
  1. package/.lynkr/telemetry.db +0 -0
  2. package/.lynkr/telemetry.db-shm +0 -0
  3. package/.lynkr/telemetry.db-wal +0 -0
  4. package/README.md +196 -322
  5. package/lynkr-skill.tar.gz +0 -0
  6. package/package.json +4 -3
  7. package/src/api/openai-router.js +64 -13
  8. package/src/api/providers-handler.js +171 -3
  9. package/src/api/router.js +9 -2
  10. package/src/clients/circuit-breaker.js +10 -247
  11. package/src/clients/codex-process.js +342 -0
  12. package/src/clients/codex-utils.js +143 -0
  13. package/src/clients/databricks.js +210 -63
  14. package/src/clients/resilience.js +540 -0
  15. package/src/clients/retry.js +22 -167
  16. package/src/clients/standard-tools.js +23 -0
  17. package/src/config/index.js +77 -0
  18. package/src/context/compression.js +42 -9
  19. package/src/context/distill.js +492 -0
  20. package/src/orchestrator/index.js +48 -8
  21. package/src/routing/complexity-analyzer.js +258 -5
  22. package/src/routing/index.js +12 -2
  23. package/src/routing/latency-tracker.js +148 -0
  24. package/src/routing/model-tiers.js +2 -0
  25. package/src/routing/quality-scorer.js +113 -0
  26. package/src/routing/telemetry.js +464 -0
  27. package/src/server.js +13 -12
  28. package/src/tools/code-graph.js +538 -0
  29. package/src/tools/code-mode.js +304 -0
  30. package/src/tools/index.js +4 -0
  31. package/src/tools/lazy-loader.js +18 -0
  32. package/src/tools/mcp-remote.js +7 -0
  33. package/src/tools/smart-selection.js +11 -0
  34. package/src/tools/tinyfish.js +358 -0
  35. package/src/tools/truncate.js +1 -0
  36. package/src/utils/payload.js +206 -0
  37. package/src/utils/perf-timer.js +80 -0
  38. package/.github/FUNDING.yml +0 -15
  39. package/.github/workflows/README.md +0 -215
  40. package/.github/workflows/ci.yml +0 -69
  41. package/.github/workflows/index.yml +0 -62
  42. package/.github/workflows/web-tools-tests.yml +0 -56
  43. package/CITATIONS.bib +0 -6
  44. package/DEPLOYMENT.md +0 -1001
  45. package/LYNKR-TUI-PLAN.md +0 -984
  46. package/PERFORMANCE-REPORT.md +0 -866
  47. package/PLAN-per-client-model-routing.md +0 -252
  48. package/docs/42642f749da6234f41b6b425c3bb07c9.txt +0 -1
  49. package/docs/BingSiteAuth.xml +0 -4
  50. package/docs/docs-style.css +0 -478
  51. package/docs/docs.html +0 -198
  52. package/docs/google5be250e608e6da39.html +0 -1
  53. package/docs/index.html +0 -577
  54. package/docs/index.md +0 -584
  55. package/docs/robots.txt +0 -4
  56. package/docs/sitemap.xml +0 -44
  57. package/docs/style.css +0 -1223
  58. package/docs/toon-integration-spec.md +0 -130
  59. package/documentation/README.md +0 -101
  60. package/documentation/api.md +0 -806
  61. package/documentation/claude-code-cli.md +0 -679
  62. package/documentation/codex-cli.md +0 -397
  63. package/documentation/contributing.md +0 -571
  64. package/documentation/cursor-integration.md +0 -734
  65. package/documentation/docker.md +0 -874
  66. package/documentation/embeddings.md +0 -762
  67. package/documentation/faq.md +0 -713
  68. package/documentation/features.md +0 -403
  69. package/documentation/headroom.md +0 -519
  70. package/documentation/installation.md +0 -758
  71. package/documentation/memory-system.md +0 -476
  72. package/documentation/production.md +0 -636
  73. package/documentation/providers.md +0 -1009
  74. package/documentation/routing.md +0 -476
  75. package/documentation/testing.md +0 -629
  76. package/documentation/token-optimization.md +0 -325
  77. package/documentation/tools.md +0 -697
  78. package/documentation/troubleshooting.md +0 -969
  79. package/final-test.js +0 -33
  80. package/headroom-sidecar/config.py +0 -93
  81. package/headroom-sidecar/requirements.txt +0 -14
  82. package/headroom-sidecar/server.py +0 -451
  83. package/monitor-agents.sh +0 -31
  84. package/scripts/audit-log-reader.js +0 -399
  85. package/scripts/compact-dictionary.js +0 -204
  86. package/scripts/test-deduplication.js +0 -448
  87. package/src/db/database.sqlite +0 -0
  88. package/te +0 -11622
  89. package/test/README.md +0 -212
  90. package/test/azure-openai-config.test.js +0 -213
  91. package/test/azure-openai-error-resilience.test.js +0 -238
  92. package/test/azure-openai-format-conversion.test.js +0 -354
  93. package/test/azure-openai-integration.test.js +0 -287
  94. package/test/azure-openai-routing.test.js +0 -175
  95. package/test/azure-openai-streaming.test.js +0 -171
  96. package/test/bedrock-integration.test.js +0 -457
  97. package/test/comprehensive-test-suite.js +0 -928
  98. package/test/config-validation.test.js +0 -207
  99. package/test/cursor-integration.test.js +0 -484
  100. package/test/format-conversion.test.js +0 -578
  101. package/test/hybrid-routing-integration.test.js +0 -269
  102. package/test/hybrid-routing-performance.test.js +0 -428
  103. package/test/llamacpp-integration.test.js +0 -882
  104. package/test/lmstudio-integration.test.js +0 -347
  105. package/test/memory/extractor.test.js +0 -398
  106. package/test/memory/retriever.test.js +0 -613
  107. package/test/memory/retriever.test.js.bak +0 -585
  108. package/test/memory/search.test.js +0 -537
  109. package/test/memory/search.test.js.bak +0 -389
  110. package/test/memory/store.test.js +0 -344
  111. package/test/memory/store.test.js.bak +0 -312
  112. package/test/memory/surprise.test.js +0 -300
  113. package/test/memory-performance.test.js +0 -472
  114. package/test/openai-integration.test.js +0 -683
  115. package/test/openrouter-error-resilience.test.js +0 -418
  116. package/test/passthrough-mode.test.js +0 -385
  117. package/test/performance-benchmark.js +0 -351
  118. package/test/performance-tests.js +0 -528
  119. package/test/routing.test.js +0 -225
  120. package/test/toon-compression.test.js +0 -131
  121. package/test/web-tools.test.js +0 -329
  122. package/test-agents-simple.js +0 -43
  123. package/test-cli-connection.sh +0 -33
  124. package/test-learning-unit.js +0 -126
  125. package/test-learning.js +0 -112
  126. package/test-parallel-agents.sh +0 -124
  127. package/test-parallel-direct.js +0 -155
  128. 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
- });