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,476 +0,0 @@
1
- # Long-Term Memory System
2
-
3
- Complete guide to Lynkr's Titans-inspired long-term memory system with surprise-based filtering.
4
-
5
- ---
6
-
7
- ## Overview
8
-
9
- Lynkr includes a comprehensive long-term memory system that remembers important context across conversations, inspired by Google's Titans architecture.
10
-
11
- **Key Benefits:**
12
- - 🧠 **Persistent Context** - Remembers across sessions
13
- - 🎯 **Intelligent Filtering** - Only stores novel information
14
- - 🔍 **Semantic Search** - FTS5 with Porter stemmer
15
- - ⚡ **Zero Latency** - <50ms retrieval, async extraction
16
- - 📊 **Multi-Signal Ranking** - Recency, importance, relevance
17
-
18
- ---
19
-
20
- ## How It Works
21
-
22
- ### 1. Automatic Extraction
23
-
24
- **After each assistant response:**
25
- 1. Parse response content
26
- 2. Calculate surprise score (0.0-1.0)
27
- 3. If score > threshold → Store memory
28
- 4. If score < threshold → Discard (redundant)
29
-
30
- **Surprise Score Factors (5):**
31
- 1. **Novelty** (40%) - Is this new information?
32
- 2. **Contradiction** (25%) - Does this contradict existing knowledge?
33
- 3. **Specificity** (20%) - Is this specific vs general?
34
- 4. **Emphasis** (10%) - Was this emphasized by user?
35
- 5. **Context Switch** (5%) - Did conversation topic change?
36
-
37
- **Example:**
38
- ```
39
- "I prefer Python" (first time) → Score: 0.9 (novel) → STORE
40
- "I prefer Python" (repeated) → Score: 0.1 (redundant) → DISCARD
41
- "Actually, I prefer Go" → Score: 0.95 (contradiction) → STORE
42
- ```
43
-
44
- ### 2. Storage
45
-
46
- **Memory Schema:**
47
- ```sql
48
- CREATE TABLE memories (
49
- id INTEGER PRIMARY KEY,
50
- session_id TEXT, -- Conversation ID (NULL = global)
51
- memory_type TEXT, -- preference, decision, fact, entity, relationship
52
- content TEXT NOT NULL, -- Memory text
53
- context TEXT, -- Surrounding context
54
- importance REAL, -- 0.0-1.0 (from surprise score)
55
- created_at INTEGER, -- Unix timestamp
56
- last_accessed INTEGER, -- For recency scoring
57
- access_count INTEGER -- For frequency tracking
58
- );
59
-
60
- CREATE VIRTUAL TABLE memories_fts USING fts5(
61
- content, context,
62
- tokenize='porter' -- Stemming for better search
63
- );
64
- ```
65
-
66
- ### 3. Retrieval
67
-
68
- **When processing request:**
69
- 1. Extract query keywords
70
- 2. FTS5 search: `MATCH query`
71
- 3. Rank by 3 signals:
72
- - **Recency** (30%) - Recently accessed memories
73
- - **Importance** (40%) - High surprise score
74
- - **Relevance** (30%) - FTS5 match score
75
- 4. Return top N memories (default: 5)
76
-
77
- **Multi-Signal Formula:**
78
- ```javascript
79
- score = (
80
- 0.30 * recency_score + // exp(-days_since_access / 30)
81
- 0.40 * importance_score + // stored surprise score
82
- 0.30 * relevance_score // FTS5 bm25 score
83
- )
84
- ```
85
-
86
- ### 4. Injection
87
-
88
- **Inject into system prompt:**
89
- ```
90
- ## Relevant Context from Previous Conversations
91
-
92
- - [User preference] I prefer Python for data processing
93
- - [Decision] Decided to use React for frontend
94
- - [Fact] This app uses PostgreSQL database
95
- - [Entity] File: src/api/auth.js handles authentication
96
- ```
97
-
98
- **Format Options:**
99
- - `system` - Inject into system prompt (recommended)
100
- - `assistant_preamble` - Inject as assistant message
101
-
102
- ---
103
-
104
- ## Memory Types
105
-
106
- ### 1. Preferences
107
- **What:** User preferences and likes
108
- **Example:** "I prefer TypeScript over JavaScript"
109
- **When:** User states preference explicitly
110
-
111
- ### 2. Decisions
112
- **What:** Important decisions made
113
- **Example:** "Decided to use Redux for state management"
114
- **When:** Decision is finalized
115
-
116
- ### 3. Facts
117
- **What:** Project-specific facts
118
- **Example:** "This API uses JWT authentication"
119
- **When:** New fact is established
120
-
121
- ### 4. Entities
122
- **What:** Important files, functions, modules
123
- **Example:** "File: utils/validation.js contains input validators"
124
- **When:** First mention of entity
125
-
126
- ### 5. Relationships
127
- **What:** Connections between entities
128
- **Example:** "auth.js depends on jwt.js"
129
- **When:** Relationship is established
130
-
131
- ---
132
-
133
- ## Configuration
134
-
135
- ### Core Settings
136
-
137
- ```bash
138
- # Enable/disable memory system
139
- MEMORY_ENABLED=true # default: true
140
-
141
- # Memories to inject per request
142
- MEMORY_RETRIEVAL_LIMIT=5 # default: 5, range: 1-20
143
-
144
- # Surprise threshold (0.0-1.0)
145
- MEMORY_SURPRISE_THRESHOLD=0.3 # default: 0.3
146
- # Lower (0.1-0.2) = store more
147
- # Higher (0.4-0.5) = only novel info
148
- ```
149
-
150
- ### Database Management
151
-
152
- ```bash
153
- # Auto-delete memories older than X days
154
- MEMORY_MAX_AGE_DAYS=90 # default: 90
155
-
156
- # Maximum total memories
157
- MEMORY_MAX_COUNT=10000 # default: 10000
158
-
159
- # Enable memory decay (importance decreases over time)
160
- MEMORY_DECAY_ENABLED=true # default: true
161
-
162
- # Decay half-life (days)
163
- MEMORY_DECAY_HALF_LIFE=30 # default: 30
164
- ```
165
-
166
- ### Advanced Settings
167
-
168
- ```bash
169
- # Include global memories (session_id=NULL) in all sessions
170
- MEMORY_INCLUDE_GLOBAL=true # default: true
171
-
172
- # Memory injection format
173
- MEMORY_INJECTION_FORMAT=system # options: system, assistant_preamble
174
-
175
- # Enable automatic extraction
176
- MEMORY_EXTRACTION_ENABLED=true # default: true
177
-
178
- # Memory format
179
- MEMORY_FORMAT=compact # options: compact, detailed
180
-
181
- # Enable deduplication
182
- MEMORY_DEDUP_ENABLED=true # default: true
183
-
184
- # Dedup lookback window
185
- MEMORY_DEDUP_LOOKBACK=5 # default: 5
186
- ```
187
-
188
- ---
189
-
190
- ## Management Tools
191
-
192
- ### memory_search
193
-
194
- Search stored memories:
195
-
196
- ```bash
197
- claude "Search memories for authentication"
198
-
199
- # Returns:
200
- # Found 3 relevant memories:
201
- # 1. [Preference] I prefer JWT over sessions
202
- # 2. [Fact] auth.js handles user authentication
203
- # 3. [Entity] File: utils/jwt.js creates tokens
204
- ```
205
-
206
- ### memory_add
207
-
208
- Manually add memory:
209
-
210
- ```bash
211
- claude "Remember that we're using PostgreSQL for this project"
212
-
213
- # Uses memory_add tool internally
214
- # Stores as fact with importance 1.0
215
- ```
216
-
217
- ### memory_forget
218
-
219
- Delete specific memory:
220
-
221
- ```bash
222
- claude "Forget the memory about using MongoDB"
223
-
224
- # Searches and deletes matching memories
225
- ```
226
-
227
- ### memory_stats
228
-
229
- View memory statistics:
230
-
231
- ```bash
232
- claude "Show memory statistics"
233
-
234
- # Returns:
235
- # Total memories: 127
236
- # Session memories: 45
237
- # Global memories: 82
238
- # Avg importance: 0.67
239
- # Oldest memory: 23 days ago
240
- ```
241
-
242
- ---
243
-
244
- ## What Gets Remembered
245
-
246
- ### ✅ Stored (High Surprise Score)
247
-
248
- - **Preferences**: "I prefer X"
249
- - **Decisions**: "Decided to use Y"
250
- - **Project facts**: "This app uses Z"
251
- - **New entities**: First mention of files/functions
252
- - **Contradictions**: "Actually, A not B"
253
- - **Specific details**: "Database on port 5432"
254
-
255
- ### ❌ Discarded (Low Surprise Score)
256
-
257
- - **Greetings**: "Hello", "Thanks"
258
- - **Confirmations**: "OK", "Got it"
259
- - **Repeated info**: Already said before
260
- - **Generic statements**: "That's good"
261
- - **Questions**: "What should I do?"
262
-
263
- ---
264
-
265
- ## Performance
266
-
267
- ### Metrics
268
-
269
- **Retrieval:**
270
- - Average: 20-50ms
271
- - 95th percentile: 80ms
272
- - 99th percentile: 150ms
273
-
274
- **Extraction:**
275
- - Async (non-blocking)
276
- - Average: 50-100ms
277
- - Happens after response sent
278
-
279
- **Storage:**
280
- - SQLite with WAL mode
281
- - FTS5 indexing
282
- - Automatic vacuum
283
-
284
- ### Database Size
285
-
286
- **Typical sizes:**
287
- - 100 memories: ~50KB
288
- - 1,000 memories: ~500KB
289
- - 10,000 memories: ~5MB
290
-
291
- **Prune regularly:**
292
- ```bash
293
- # Manual cleanup
294
- rm data/memories.db
295
-
296
- # Or configure auto-prune
297
- MEMORY_MAX_AGE_DAYS=30
298
- MEMORY_MAX_COUNT=5000
299
- ```
300
-
301
- ---
302
-
303
- ## Memory Decay
304
-
305
- ### Exponential Decay
306
-
307
- Importance decreases over time:
308
-
309
- ```javascript
310
- decayed_importance = original_importance * exp(-days / half_life)
311
- ```
312
-
313
- **Example with 30-day half-life:**
314
- - Day 0: 1.0 importance
315
- - Day 30: 0.5 importance (half)
316
- - Day 60: 0.25 importance
317
- - Day 90: 0.125 importance
318
-
319
- **Configure:**
320
- ```bash
321
- MEMORY_DECAY_ENABLED=true
322
- MEMORY_DECAY_HALF_LIFE=30 # Days for 50% decay
323
- ```
324
-
325
- ---
326
-
327
- ## Privacy
328
-
329
- ### Session-Specific Memories
330
-
331
- ```bash
332
- # Memories tied to session_id
333
- # Only visible in that conversation
334
- ```
335
-
336
- ### Global Memories
337
-
338
- ```bash
339
- # Memories with session_id=NULL
340
- # Visible across all conversations
341
- # Good for project facts
342
- ```
343
-
344
- ### Data Location
345
-
346
- ```bash
347
- # SQLite database
348
- data/memories.db
349
-
350
- # Delete to clear all memories
351
- rm data/memories.db
352
- ```
353
-
354
- ---
355
-
356
- ## Best Practices
357
-
358
- ### 1. Set Appropriate Threshold
359
-
360
- ```bash
361
- # For learning user preferences:
362
- MEMORY_SURPRISE_THRESHOLD=0.2 # Store more
363
-
364
- # For only critical info:
365
- MEMORY_SURPRISE_THRESHOLD=0.5 # Store less
366
- ```
367
-
368
- ### 2. Regular Pruning
369
-
370
- ```bash
371
- # Auto-prune old memories
372
- MEMORY_MAX_AGE_DAYS=60 # Delete after 2 months
373
- MEMORY_MAX_COUNT=5000 # Keep only 5k memories
374
- ```
375
-
376
- ### 3. Monitor Performance
377
-
378
- ```bash
379
- # Check memory count
380
- sqlite3 data/memories.db "SELECT COUNT(*) FROM memories;"
381
-
382
- # Check database size
383
- du -h data/memories.db
384
- ```
385
-
386
- ---
387
-
388
- ## Examples
389
-
390
- ### User Preference Learning
391
-
392
- ```
393
- User: "I prefer Python for scripting"
394
- System: [Stores: preference, importance 0.85]
395
-
396
- Later...
397
- User: "Write a script to process JSON"
398
- System: [Injects: "I prefer Python"]
399
- Assistant: "Here's a Python script to process JSON..."
400
- ```
401
-
402
- ### Project Context
403
-
404
- ```
405
- User: "This API uses port 3000"
406
- System: [Stores: fact, importance 0.75]
407
-
408
- Later...
409
- User: "How do I test the API?"
410
- System: [Injects: "API uses port 3000"]
411
- Assistant: "curl http://localhost:3000/endpoint"
412
- ```
413
-
414
- ### Decision Tracking
415
-
416
- ```
417
- User: "Let's use PostgreSQL"
418
- System: [Stores: decision, importance 0.90]
419
-
420
- Later...
421
- User: "Set up the database"
422
- System: [Injects: "Using PostgreSQL"]
423
- Assistant: "Here's the PostgreSQL setup..."
424
- ```
425
-
426
- ---
427
-
428
- ## Troubleshooting
429
-
430
- ### Too Many Memories
431
-
432
- ```bash
433
- # Increase threshold
434
- MEMORY_SURPRISE_THRESHOLD=0.5
435
-
436
- # Reduce max count
437
- MEMORY_MAX_COUNT=5000
438
-
439
- # Reduce max age
440
- MEMORY_MAX_AGE_DAYS=30
441
- ```
442
-
443
- ### Not Enough Memories
444
-
445
- ```bash
446
- # Decrease threshold
447
- MEMORY_SURPRISE_THRESHOLD=0.2
448
-
449
- # Check extraction is enabled
450
- MEMORY_EXTRACTION_ENABLED=true
451
- ```
452
-
453
- ### Poor Relevance
454
-
455
- ```bash
456
- # Adjust retrieval limit
457
- MEMORY_RETRIEVAL_LIMIT=10
458
-
459
- # Check search is working
460
- sqlite3 data/memories.db "SELECT * FROM memories_fts WHERE memories_fts MATCH 'your query';"
461
- ```
462
-
463
- ---
464
-
465
- ## Next Steps
466
-
467
- - **[Token Optimization](token-optimization.md)** - Cost reduction strategies
468
- - **[Features Guide](features.md)** - Core features
469
- - **[FAQ](faq.md)** - Common questions
470
-
471
- ---
472
-
473
- ## Getting Help
474
-
475
- - **[GitHub Discussions](https://github.com/vishalveerareddy123/Lynkr/discussions)** - Ask questions
476
- - **[GitHub Issues](https://github.com/vishalveerareddy123/Lynkr/issues)** - Report issues