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,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
- });