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,389 +0,0 @@
1
- const assert = require("assert");
2
- const { describe, it, beforeEach, afterEach } = require("node:test");
3
- const fs = require("fs");
4
- const path = require("path");
5
-
6
- describe("Memory Search", () => {
7
- let store;
8
- let search;
9
- let testDbPath;
10
-
11
- beforeEach(() => {
12
- // Create a temporary test database
13
- testDbPath = path.join(__dirname, `../../data/test-memory-${Date.now()}.db`);
14
-
15
- // Clear module cache
16
- delete require.cache[require.resolve("../../src/db")];
17
- delete require.cache[require.resolve("../../src/memory/store")];
18
- delete require.cache[require.resolve("../../src/memory/search")];
19
-
20
- // Set test environment
21
- process.env.DB_PATH = testDbPath;
22
-
23
- // Initialize database with schema
24
- require("../../src/db");
25
-
26
- // Load modules
27
- store = require("../../src/memory/store");
28
- search = require("../../src/memory/search");
29
-
30
- // Create test memories
31
- store.createMemory({
32
- content: "User prefers Python for data processing and machine learning tasks",
33
- type: "preference",
34
- category: "user",
35
- importance: 0.8
36
- });
37
-
38
- store.createMemory({
39
- content: "This project uses Express.js framework with TypeScript",
40
- type: "fact",
41
- category: "project",
42
- importance: 0.7
43
- });
44
-
45
- store.createMemory({
46
- content: "Decided to implement authentication using JWT tokens",
47
- type: "decision",
48
- category: "code",
49
- importance: 0.9
50
- });
51
-
52
- store.createMemory({
53
- content: "Database uses SQLite with better-sqlite3 driver",
54
- type: "fact",
55
- category: "project",
56
- importance: 0.6
57
- });
58
-
59
- store.createMemory({
60
- content: "UserController class handles user authentication and profile management",
61
- type: "entity",
62
- category: "code",
63
- importance: 0.5
64
- });
65
- });
66
-
67
- afterEach(() => {
68
- // Clean up test database
69
- try {
70
- if (fs.existsSync(testDbPath)) {
71
- fs.unlinkSync(testDbPath);
72
- }
73
- } catch (err) {
74
- // Ignore cleanup errors
75
- }
76
- });
77
-
78
- describe("searchMemories()", () => {
79
- it("should find memories by keyword", () => {
80
- const results = search.searchMemories({ query: "Python" });
81
- assert.ok(results.length > 0, "Should find Python memory");
82
- assert.ok(results[0].content.toLowerCase().includes("python"));
83
- });
84
-
85
- it("should find memories with partial matches", () => {
86
- const results = search.searchMemories({ query: "express" });
87
- assert.ok(results.length > 0, "Should find Express memory");
88
- assert.ok(results.some(m => m.content.toLowerCase().includes("express")));
89
- });
90
-
91
- it("should support FTS5 phrase search", () => {
92
- const results = search.searchMemories({ query: "machine learning" });
93
- assert.ok(results.length > 0, "Should find 'machine learning' phrase");
94
- });
95
-
96
- it("should filter by memory type", () => {
97
- const results = search.searchMemories({
98
- query: "project",
99
- types: ["fact"]
100
- });
101
- assert.ok(results.length > 0);
102
- assert.ok(results.every(m => m.type === "fact"), "All results should be facts");
103
- });
104
-
105
- it("should filter by category", () => {
106
- const results = search.searchMemories({
107
- query: "project",
108
- categories: ["project"]
109
- });
110
- assert.ok(results.length > 0);
111
- assert.ok(results.every(m => m.category === "project"));
112
- });
113
-
114
- it("should filter by session id", () => {
115
- // Create session-specific memory
116
- store.createMemory({
117
- content: "Session-specific memory about testing",
118
- type: "fact",
119
- sessionId: "test-session-123"
120
- });
121
-
122
- const results = search.searchMemories({
123
- query: "testing",
124
- sessionId: "test-session-123"
125
- });
126
-
127
- assert.ok(results.length > 0);
128
- assert.ok(results.every(m => m.sessionId === "test-session-123" || m.sessionId === null));
129
- });
130
-
131
- it("should filter by minimum importance", () => {
132
- const results = search.searchMemories({
133
- query: "project",
134
- minImportance: 0.7
135
- });
136
-
137
- assert.ok(results.length > 0);
138
- assert.ok(results.every(m => m.importance >= 0.7));
139
- });
140
-
141
- it("should respect limit parameter", () => {
142
- const results = search.searchMemories({ query: "project", limit: 2 });
143
- assert.ok(results.length <= 2);
144
- });
145
-
146
- it("should return empty array for no matches", () => {
147
- const results = search.searchMemories({ query: "nonexistent-keyword-xyz" });
148
- assert.strictEqual(results.length, 0);
149
- });
150
-
151
- it("should handle special characters in query", () => {
152
- store.createMemory({
153
- content: "Uses @nestjs/core package version ^9.0.0",
154
- type: "fact",
155
- category: "project"
156
- });
157
-
158
- const results = search.searchMemories({ query: "nestjs" });
159
- assert.ok(results.length > 0);
160
- });
161
-
162
- it("should be case-insensitive", () => {
163
- const lower = search.searchMemories({ query: "python" });
164
- const upper = search.searchMemories({ query: "PYTHON" });
165
- const mixed = search.searchMemories({ query: "PyThOn" });
166
-
167
- assert.ok(lower.length > 0);
168
- assert.strictEqual(lower.length, upper.length);
169
- assert.strictEqual(lower.length, mixed.length);
170
- });
171
- });
172
-
173
- describe("searchWithExpansion()", () => {
174
- it("should expand query and find more results", () => {
175
- const basicResults = search.searchMemories({ query: "database" });
176
- const expandedResults = search.searchWithExpansion({ query: "database" });
177
-
178
- // Expanded search should find at least as many as basic
179
- assert.ok(expandedResults.length >= basicResults.length);
180
- });
181
-
182
- it("should find results with related terms", () => {
183
- // Should find both "Express.js" and "authentication" memories
184
- const results = search.searchWithExpansion({ query: "authentication" });
185
- assert.ok(results.length > 0);
186
- });
187
-
188
- it("should handle multi-word queries", () => {
189
- const results = search.searchWithExpansion({ query: "user authentication system" });
190
- assert.ok(results.length >= 0); // Should not error
191
- });
192
- });
193
-
194
- describe("extractKeywords()", () => {
195
- it("should extract meaningful keywords", () => {
196
- const keywords = search.extractKeywords("User prefers Python for data processing");
197
- assert.ok(keywords.length > 0);
198
- assert.ok(keywords.includes("python") || keywords.includes("data"));
199
- });
200
-
201
- it("should filter out stop words", () => {
202
- const keywords = search.extractKeywords("The user is using the database");
203
- // Should not include common stop words like "the", "is", "using"
204
- assert.ok(!keywords.includes("the"));
205
- assert.ok(!keywords.includes("is"));
206
- });
207
-
208
- it("should handle empty text", () => {
209
- const keywords = search.extractKeywords("");
210
- assert.ok(Array.isArray(keywords));
211
- assert.strictEqual(keywords.length, 0);
212
- });
213
-
214
- it("should extract from technical content", () => {
215
- const keywords = search.extractKeywords("Using Express.js with TypeScript and JWT authentication");
216
- assert.ok(keywords.length > 0);
217
- assert.ok(keywords.some(k => k.includes("express") || k.includes("typescript") || k.includes("jwt")));
218
- });
219
- });
220
-
221
- describe("findSimilar()", () => {
222
- it("should find memories similar to reference", () => {
223
- const reference = store.createMemory({
224
- content: "User likes JavaScript frameworks like React and Vue",
225
- type: "preference"
226
- });
227
-
228
- const similar = search.findSimilar(reference.id, { limit: 3 });
229
- assert.ok(similar.length >= 0);
230
- // Should not include the reference memory itself
231
- assert.ok(!similar.some(m => m.id === reference.id));
232
- });
233
-
234
- it("should return empty for no similar memories", () => {
235
- const unique = store.createMemory({
236
- content: "Quantum computing with superconducting qubits",
237
- type: "fact"
238
- });
239
-
240
- const similar = search.findSimilar(unique.id, { limit: 5 });
241
- assert.ok(similar.length >= 0);
242
- });
243
-
244
- it("should throw error for non-existent memory id", () => {
245
- assert.throws(() => {
246
- search.findSimilar(99999);
247
- });
248
- });
249
- });
250
-
251
- describe("searchByContent()", () => {
252
- it("should search by content similarity", () => {
253
- const results = search.searchByContent("Python programming language");
254
- assert.ok(results.length > 0);
255
- assert.ok(results.some(m => m.content.toLowerCase().includes("python")));
256
- });
257
-
258
- it("should handle empty content", () => {
259
- const results = search.searchByContent("");
260
- assert.strictEqual(results.length, 0);
261
- });
262
-
263
- it("should filter by type and category", () => {
264
- const results = search.searchByContent("project", {
265
- types: ["fact"],
266
- categories: ["project"]
267
- });
268
-
269
- assert.ok(results.every(m => m.type === "fact" && m.category === "project"));
270
- });
271
- });
272
-
273
- describe("countSearchResults()", () => {
274
- it("should count matching memories", () => {
275
- const count = search.countSearchResults({ query: "project" });
276
- assert.ok(count > 0);
277
- assert.strictEqual(typeof count, "number");
278
- });
279
-
280
- it("should return 0 for no matches", () => {
281
- const count = search.countSearchResults({ query: "nonexistent-xyz" });
282
- assert.strictEqual(count, 0);
283
- });
284
-
285
- it("should respect filters", () => {
286
- const totalCount = search.countSearchResults({ query: "project" });
287
- const factCount = search.countSearchResults({ query: "project", types: ["fact"] });
288
-
289
- assert.ok(factCount <= totalCount);
290
- });
291
- });
292
-
293
- describe("FTS5 Query Preparation", () => {
294
- it("should handle AND operator", () => {
295
- const results = search.searchMemories({ query: "Python AND machine" });
296
- if (results.length > 0) {
297
- assert.ok(results[0].content.toLowerCase().includes("python"));
298
- assert.ok(results[0].content.toLowerCase().includes("machine"));
299
- }
300
- });
301
-
302
- it("should handle OR operator", () => {
303
- const results = search.searchMemories({ query: "Python OR JavaScript" });
304
- assert.ok(results.length > 0);
305
- });
306
-
307
- it("should handle complex queries", () => {
308
- // Should not throw error with complex FTS5 syntax
309
- assert.doesNotThrow(() => {
310
- search.searchMemories({ query: "(Python OR JavaScript) AND framework" });
311
- });
312
- });
313
-
314
- it("should escape special FTS5 characters", () => {
315
- // Characters like quotes, parens can break FTS5
316
- assert.doesNotThrow(() => {
317
- search.searchMemories({ query: 'test "quoted" (parens)' });
318
- });
319
- });
320
- });
321
-
322
- describe("Performance", () => {
323
- it("should handle searches with many results efficiently", () => {
324
- // Create many memories
325
- for (let i = 0; i < 100; i++) {
326
- store.createMemory({
327
- content: `Test memory number ${i} about Python and JavaScript`,
328
- type: "fact",
329
- importance: Math.random()
330
- });
331
- }
332
-
333
- const start = Date.now();
334
- const results = search.searchMemories({ query: "Python", limit: 10 });
335
- const duration = Date.now() - start;
336
-
337
- assert.ok(results.length > 0);
338
- assert.ok(duration < 100, `Search took ${duration}ms, expected < 100ms`);
339
- });
340
-
341
- it("should handle multiple concurrent searches", () => {
342
- const searches = [
343
- search.searchMemories({ query: "Python" }),
344
- search.searchMemories({ query: "Express" }),
345
- search.searchMemories({ query: "database" }),
346
- search.searchMemories({ query: "authentication" })
347
- ];
348
-
349
- // All should complete without errors
350
- searches.forEach(results => {
351
- assert.ok(Array.isArray(results));
352
- });
353
- });
354
- });
355
-
356
- describe("Edge Cases", () => {
357
- it("should handle very long queries", () => {
358
- const longQuery = "Python ".repeat(100);
359
- assert.doesNotThrow(() => {
360
- search.searchMemories({ query: longQuery });
361
- });
362
- });
363
-
364
- it("should handle queries with only stop words", () => {
365
- const results = search.searchMemories({ query: "the a an is are" });
366
- assert.ok(Array.isArray(results));
367
- });
368
-
369
- it("should handle numeric queries", () => {
370
- store.createMemory({
371
- content: "Server runs on port 3000",
372
- type: "fact"
373
- });
374
-
375
- const results = search.searchMemories({ query: "3000" });
376
- assert.ok(results.length > 0);
377
- });
378
-
379
- it("should handle emoji and unicode", () => {
380
- store.createMemory({
381
- content: "User's favorite emoji is 🚀 for deployment",
382
- type: "preference"
383
- });
384
-
385
- const results = search.searchMemories({ query: "emoji" });
386
- assert.ok(results.length > 0);
387
- });
388
- });
389
- });