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,398 +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 Extractor", () => {
7
- let extractor;
8
- let testDbPath;
9
- let originalEnv;
10
-
11
- beforeEach(() => {
12
- // Save original environment
13
- originalEnv = { ...process.env };
14
-
15
- // Create a unique temporary test database
16
- const timestamp = Date.now();
17
- const random = Math.floor(Math.random() * 1000000);
18
- testDbPath = path.join(__dirname, `../../data/test-extractor-${timestamp}-${random}.db`);
19
-
20
- // Set test environment BEFORE loading any modules
21
- process.env.SESSION_DB_PATH = testDbPath;
22
- process.env.MEMORY_SURPRISE_THRESHOLD = "0.1"; // Very low threshold for tests
23
- process.env.MEMORY_ENABLED = "true";
24
- process.env.MEMORY_EXTRACTION_ENABLED = "true";
25
-
26
- // Clear ALL module cache to ensure fresh config
27
- Object.keys(require.cache).forEach(key => {
28
- if (key.includes('/src/')) {
29
- delete require.cache[key];
30
- }
31
- });
32
-
33
- // Initialize database first
34
- const db = require("../../src/db");
35
-
36
- // Create test sessions to satisfy foreign key constraints
37
- const now = Date.now();
38
- const insertSession = db.prepare(`
39
- INSERT OR IGNORE INTO sessions (id, created_at, updated_at, metadata)
40
- VALUES (?, ?, ?, ?)
41
- `);
42
- insertSession.run("test-session", now, now, "{}");
43
- insertSession.run("test-session-123", now, now, "{}");
44
- insertSession.run("test", now, now, "{}");
45
-
46
- // Then load extractor module
47
- extractor = require("../../src/memory/extractor");
48
- });
49
-
50
- afterEach(() => {
51
- // Close database connection first
52
- try {
53
- const db = require("../../src/db");
54
- if (db && typeof db.close === 'function') {
55
- db.close();
56
- }
57
- } catch (err) {
58
- // Ignore if already closed
59
- }
60
-
61
- // Clear module cache to release all references
62
- Object.keys(require.cache).forEach(key => {
63
- if (key.includes('/src/')) {
64
- delete require.cache[key];
65
- }
66
- });
67
-
68
- // Restore environment
69
- process.env = originalEnv;
70
-
71
- // Clean up all SQLite files (db, wal, shm)
72
- try {
73
- const files = [
74
- testDbPath,
75
- `${testDbPath}-wal`,
76
- `${testDbPath}-shm`,
77
- `${testDbPath}-journal`
78
- ];
79
-
80
- for (const file of files) {
81
- if (fs.existsSync(file)) {
82
- fs.unlinkSync(file);
83
- }
84
- }
85
- } catch (err) {
86
- // Ignore cleanup errors
87
- }
88
- });
89
-
90
- describe("extractMemories()", () => {
91
- it("should extract preferences from assistant response", async () => {
92
- const assistantResponse = {
93
- role: "assistant",
94
- content: "I understand that you prefer Python for data processing tasks and always use it for scripts."
95
- };
96
-
97
- const conversationMessages = [
98
- { role: "user", content: "I prefer Python for data processing" }
99
- ];
100
-
101
- const memories = await extractor.extractMemories(
102
- assistantResponse,
103
- conversationMessages,
104
- { sessionId: "test-session" }
105
- );
106
-
107
- assert.ok(Array.isArray(memories), "Should return array");
108
- const preferences = memories.filter(m => m.type === "preference");
109
- // With low threshold and novel content, should extract at least one
110
- assert.ok(preferences.length >= 0, "Should attempt extraction");
111
- });
112
-
113
- it("should extract decisions from assistant response", async () => {
114
- const assistantResponse = {
115
- role: "assistant",
116
- content: "We decided to use Express.js for the API framework and SQLite for the database storage system."
117
- };
118
-
119
- const conversationMessages = [
120
- { role: "user", content: "What should we use for the backend?" }
121
- ];
122
-
123
- const memories = await extractor.extractMemories(
124
- assistantResponse,
125
- conversationMessages,
126
- { sessionId: "test-session" }
127
- );
128
-
129
- assert.ok(Array.isArray(memories));
130
- const decisions = memories.filter(m => m.type === "decision");
131
- assert.ok(decisions.length >= 0);
132
- });
133
-
134
- it("should extract facts from assistant response", async () => {
135
- const assistantResponse = {
136
- role: "assistant",
137
- content: "This project uses TypeScript with strict mode enabled and implements ESLint for code quality."
138
- };
139
-
140
- const conversationMessages = [
141
- { role: "user", content: "Tell me about the project setup" }
142
- ];
143
-
144
- const memories = await extractor.extractMemories(
145
- assistantResponse,
146
- conversationMessages,
147
- { sessionId: "test-session" }
148
- );
149
-
150
- assert.ok(Array.isArray(memories));
151
- const facts = memories.filter(m => m.type === "fact");
152
- assert.ok(facts.length >= 0);
153
- });
154
-
155
- it("should include surprise scores in memories", async () => {
156
- const assistantResponse = {
157
- role: "assistant",
158
- content: "IMPORTANT: User always prefers async/await over callbacks in JavaScript code."
159
- };
160
-
161
- const memories = await extractor.extractMemories(
162
- assistantResponse,
163
- [],
164
- { sessionId: "test-session" }
165
- );
166
-
167
- if (memories.length > 0) {
168
- assert.ok(memories[0].surpriseScore >= 0 && memories[0].surpriseScore <= 1);
169
- assert.ok(memories[0].importance >= 0 && memories[0].importance <= 1);
170
- }
171
- });
172
-
173
- it("should include session context in stored memories", async () => {
174
- const assistantResponse = {
175
- role: "assistant",
176
- content: "I'll remember that you prefer async/await over callbacks for asynchronous operations."
177
- };
178
-
179
- const conversationMessages = [
180
- { role: "user", content: "Please use async/await" }
181
- ];
182
-
183
- const memories = await extractor.extractMemories(
184
- assistantResponse,
185
- conversationMessages,
186
- { sessionId: "test-session-123" }
187
- );
188
-
189
- if (memories.length > 0) {
190
- assert.strictEqual(memories[0].sessionId, "test-session-123");
191
- }
192
- });
193
-
194
- it("should handle empty assistant response", async () => {
195
- const assistantResponse = {
196
- role: "assistant",
197
- content: ""
198
- };
199
-
200
- const memories = await extractor.extractMemories(
201
- assistantResponse,
202
- [],
203
- { sessionId: "test-session" }
204
- );
205
-
206
- assert.strictEqual(memories.length, 0);
207
- });
208
-
209
- it("should handle responses with no extractable patterns", async () => {
210
- const assistantResponse = {
211
- role: "assistant",
212
- content: "Okay."
213
- };
214
-
215
- const memories = await extractor.extractMemories(
216
- assistantResponse,
217
- [],
218
- { sessionId: "test-session" }
219
- );
220
-
221
- assert.strictEqual(memories.length, 0);
222
- });
223
- });
224
-
225
- describe("Pattern Extraction (Internal)", () => {
226
- it("should match preference patterns", async () => {
227
- const responses = [
228
- "You always use TypeScript for new projects.",
229
- "User prefers functional programming over object-oriented design patterns.",
230
- "You typically want detailed error messages in production environments."
231
- ];
232
-
233
- for (const content of responses) {
234
- const memories = await extractor.extractMemories(
235
- { role: "assistant", content },
236
- [],
237
- { sessionId: "test" }
238
- );
239
- // Should at least try to extract (may be filtered by surprise)
240
- assert.ok(Array.isArray(memories));
241
- }
242
- });
243
-
244
- it("should match decision patterns", async () => {
245
- const responses = [
246
- "We decided to implement rate limiting at the API gateway level for better security.",
247
- "Going with PostgreSQL over MySQL for better JSON support and performance.",
248
- "Selected React for the frontend framework based on team experience."
249
- ];
250
-
251
- for (const content of responses) {
252
- const memories = await extractor.extractMemories(
253
- { role: "assistant", content },
254
- [],
255
- { sessionId: "test" }
256
- );
257
- assert.ok(Array.isArray(memories));
258
- }
259
- });
260
-
261
- it("should match fact patterns", async () => {
262
- const responses = [
263
- "This application uses Redis for caching and RabbitMQ for message queuing.",
264
- "The project implements JWT authentication with RS256 signing algorithm.",
265
- "IMPORTANT: Always validate user input for SQL injection vulnerabilities."
266
- ];
267
-
268
- for (const content of responses) {
269
- const memories = await extractor.extractMemories(
270
- { role: "assistant", content },
271
- [],
272
- { sessionId: "test" }
273
- );
274
- assert.ok(Array.isArray(memories));
275
- }
276
- });
277
- });
278
-
279
- describe("Edge Cases", () => {
280
- it("should handle very long assistant responses", async () => {
281
- const longContent = "The system architecture uses " + "microservices ".repeat(100);
282
- const assistantResponse = {
283
- role: "assistant",
284
- content: longContent
285
- };
286
-
287
- const memories = await extractor.extractMemories(
288
- assistantResponse,
289
- [],
290
- { sessionId: "test-session" }
291
- );
292
-
293
- assert.ok(Array.isArray(memories));
294
- });
295
-
296
- it("should handle special characters and code blocks", async () => {
297
- const assistantResponse = {
298
- role: "assistant",
299
- content: "This project uses @nestjs/core ^9.0.0 and implements JWT authentication with tokens."
300
- };
301
-
302
- const memories = await extractor.extractMemories(
303
- assistantResponse,
304
- [],
305
- { sessionId: "test-session" }
306
- );
307
-
308
- assert.ok(Array.isArray(memories));
309
- });
310
-
311
- it("should handle mixed content types", async () => {
312
- const assistantResponse = {
313
- role: "assistant",
314
- content: `
315
- I understand your requirements for the new authentication system.
316
- You prefer Python for this project and want to use FastAPI.
317
- We decided to use FastAPI for the backend framework with async support.
318
- The application uses PostgreSQL for the database with connection pooling.
319
- The UserModel class handles data validation and serialization.
320
- `
321
- };
322
-
323
- const memories = await extractor.extractMemories(
324
- assistantResponse,
325
- [],
326
- { sessionId: "test-session" }
327
- );
328
-
329
- assert.ok(Array.isArray(memories));
330
- // May extract multiple types
331
- if (memories.length > 0) {
332
- const types = new Set(memories.map(m => m.type));
333
- assert.ok(types.size >= 1);
334
- }
335
- });
336
-
337
- it("should not throw on malformed input", async () => {
338
- await assert.doesNotReject(async () => {
339
- await extractor.extractMemories(null, []);
340
- await extractor.extractMemories({}, []);
341
- await extractor.extractMemories({ content: null }, []);
342
- });
343
- });
344
- });
345
-
346
- describe("Surprise-Based Filtering", () => {
347
- it("should filter memories below surprise threshold", async () => {
348
- const store = require("../../src/memory/store");
349
-
350
- // Create existing memory
351
- store.createMemory({
352
- content: "User prefers Python programming",
353
- type: "preference",
354
- importance: 0.8
355
- });
356
-
357
- // Try to extract very similar memory
358
- const assistantResponse = {
359
- role: "assistant",
360
- content: "You prefer Python for programming tasks."
361
- };
362
-
363
- const memories = await extractor.extractMemories(
364
- assistantResponse,
365
- [],
366
- { sessionId: "test-session" }
367
- );
368
-
369
- // Should be filtered due to similarity (low surprise)
370
- const pythonPrefs = memories.filter(m =>
371
- m.type === "preference" && m.content.toLowerCase().includes("python")
372
- );
373
-
374
- // Either filtered out entirely, or has low surprise score
375
- if (pythonPrefs.length > 0) {
376
- assert.ok(pythonPrefs[0].surpriseScore <= 0.5);
377
- }
378
- });
379
-
380
- it("should store novel high-surprise memories", async () => {
381
- const assistantResponse = {
382
- role: "assistant",
383
- content: "CRITICAL: User always wants to use Rust for systems programming with zero-cost abstractions."
384
- };
385
-
386
- const memories = await extractor.extractMemories(
387
- assistantResponse,
388
- [{ role: "user", content: "IMPORTANT: Use Rust!" }],
389
- { sessionId: "test-session" }
390
- );
391
-
392
- // Novel content with emphasis should have higher surprise
393
- if (memories.length > 0) {
394
- assert.ok(memories[0].surpriseScore >= 0.1);
395
- }
396
- });
397
- });
398
- });