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,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