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,300 +0,0 @@
1
- const assert = require("assert");
2
- const { describe, it, beforeEach } = require("node:test");
3
-
4
- describe("Surprise Detection", () => {
5
- let surprise;
6
-
7
- beforeEach(() => {
8
- // Clear module cache
9
- delete require.cache[require.resolve("../../src/memory/surprise")];
10
- surprise = require("../../src/memory/surprise");
11
- });
12
-
13
- describe("calculateSurprise()", () => {
14
- it("should return high surprise for novel entities", () => {
15
- const newMemory = {
16
- content: "This project uses TensorFlow and PyTorch for ML models",
17
- type: "fact",
18
- category: "project"
19
- };
20
-
21
- const existingMemories = [
22
- { content: "This project uses Express.js and React", type: "fact" },
23
- { content: "Database is PostgreSQL", type: "fact" }
24
- ];
25
-
26
- const score = surprise.calculateSurprise(newMemory, existingMemories);
27
- assert.ok(score > 0.25, `Expected surprise > 0.25, got ${score}`);
28
- });
29
-
30
- it("should return low surprise for repeated information", () => {
31
- const newMemory = {
32
- content: "User prefers Python",
33
- type: "preference"
34
- };
35
-
36
- const existingMemories = [
37
- { content: "User prefers Python for scripting", type: "preference" },
38
- { content: "User always uses Python", type: "preference" }
39
- ];
40
-
41
- const score = surprise.calculateSurprise(newMemory, existingMemories);
42
- assert.ok(score < 0.3, `Expected surprise < 0.3, got ${score}`);
43
- });
44
-
45
- it("should detect contradictions and return high surprise", () => {
46
- const newMemory = {
47
- content: "User prefers TypeScript over JavaScript",
48
- type: "preference"
49
- };
50
-
51
- const existingMemories = [
52
- { content: "User prefers JavaScript for all projects", type: "preference" }
53
- ];
54
-
55
- const score = surprise.calculateSurprise(newMemory, existingMemories, {
56
- userContent: "Actually, I prefer TypeScript"
57
- });
58
-
59
- assert.ok(score > 0.4, `Expected high contradiction surprise > 0.4, got ${score}`);
60
- });
61
-
62
- it("should give higher scores to specific details", () => {
63
- const specificMemory = {
64
- content: "The authentication module uses JWT tokens with RS256 algorithm and 1-hour expiration",
65
- type: "fact"
66
- };
67
-
68
- const vagueMemory = {
69
- content: "Uses JWT",
70
- type: "fact"
71
- };
72
-
73
- const specificScore = surprise.calculateSurprise(specificMemory, []);
74
- const vagueScore = surprise.calculateSurprise(vagueMemory, []);
75
-
76
- assert.ok(specificScore > vagueScore,
77
- `Expected specific (${specificScore}) > vague (${vagueScore})`);
78
- });
79
-
80
- it("should detect user emphasis and increase surprise", () => {
81
- const memory = {
82
- content: "Always use async/await for database operations",
83
- type: "preference"
84
- };
85
-
86
- const withEmphasis = surprise.calculateSurprise(memory, [], {
87
- userContent: "IMPORTANT: Always use async/await!"
88
- });
89
-
90
- const withoutEmphasis = surprise.calculateSurprise(memory, []);
91
-
92
- assert.ok(withEmphasis > withoutEmphasis,
93
- `Expected emphasis (${withEmphasis}) > no emphasis (${withoutEmphasis})`);
94
- });
95
-
96
- it("should detect context switches", () => {
97
- const newMemory = {
98
- content: "User's favorite color is blue",
99
- type: "preference",
100
- category: "user"
101
- };
102
-
103
- const existingMemories = [
104
- { content: "Database uses connection pooling", type: "fact", category: "code" },
105
- { content: "API endpoint uses rate limiting", type: "fact", category: "code" }
106
- ];
107
-
108
- const score = surprise.calculateSurprise(newMemory, existingMemories);
109
- // Should have some surprise from context switch (5% weight)
110
- assert.ok(score > 0, `Expected some surprise from context switch, got ${score}`);
111
- });
112
-
113
- it("should return 0 for empty existing memories", () => {
114
- const memory = { content: "Test memory", type: "fact" };
115
- const score = surprise.calculateSurprise(memory, []);
116
- assert.ok(score >= 0 && score <= 1, `Score should be in [0,1], got ${score}`);
117
- });
118
-
119
- it("should bound surprise score between 0 and 1", () => {
120
- const memory = {
121
- content: "CRITICAL IMPORTANT: This is completely new revolutionary groundbreaking paradigm shift",
122
- type: "fact"
123
- };
124
-
125
- const score = surprise.calculateSurprise(memory, []);
126
- assert.ok(score >= 0 && score <= 1, `Score should be in [0,1], got ${score}`);
127
- });
128
- });
129
-
130
- describe("calculateNovelty()", () => {
131
- it("should return high novelty for unique content", () => {
132
- const memory = { content: "GraphQL and Apollo Server", type: "fact" };
133
- const existing = [
134
- { content: "REST API with Express", type: "fact" }
135
- ];
136
-
137
- const novelty = surprise.calculateNovelty(memory, existing);
138
- assert.ok(novelty > 0.5, `Expected high novelty > 0.5, got ${novelty}`);
139
- });
140
-
141
- it("should return low novelty for similar content", () => {
142
- const memory = { content: "Uses Express for API", type: "fact" };
143
- const existing = [
144
- { content: "Using Express.js for REST API", type: "fact" }
145
- ];
146
-
147
- const novelty = surprise.calculateNovelty(memory, existing);
148
- assert.ok(novelty < 0.5, `Expected low novelty < 0.5, got ${novelty}`);
149
- });
150
- });
151
-
152
- describe("detectContradiction()", () => {
153
- it("should detect contradictions with negation words", () => {
154
- const memory = { content: "User doesn't like Python", type: "preference" };
155
- const existing = [
156
- { content: "User prefers Python", type: "preference" }
157
- ];
158
-
159
- const contradiction = surprise.detectContradiction(memory, existing);
160
- assert.ok(contradiction > 0.5, `Expected contradiction > 0.5, got ${contradiction}`);
161
- });
162
-
163
- it("should detect contradictions with opposing preferences", () => {
164
- const memory = { content: "User prefers dark mode", type: "preference" };
165
- const existing = [
166
- { content: "User prefers light mode", type: "preference" }
167
- ];
168
-
169
- const contradiction = surprise.detectContradiction(memory, existing);
170
- assert.ok(contradiction > 0, `Expected some contradiction, got ${contradiction}`);
171
- });
172
-
173
- it("should return 0 for no contradictions", () => {
174
- const memory = { content: "User likes TypeScript", type: "preference" };
175
- const existing = [
176
- { content: "User likes JavaScript", type: "preference" }
177
- ];
178
-
179
- const contradiction = surprise.detectContradiction(memory, existing);
180
- // These are compatible preferences
181
- assert.ok(contradiction >= 0, `Expected non-negative, got ${contradiction}`);
182
- });
183
- });
184
-
185
- describe("measureSpecificity()", () => {
186
- it("should return high score for detailed content", () => {
187
- const detailed = "The authentication system uses JWT tokens with RS256 signing, 1-hour access tokens, 7-day refresh tokens, and Redis for token storage";
188
- const specific = surprise.measureSpecificity(detailed);
189
- assert.ok(specific >= 0.5, `Expected high specificity >= 0.5, got ${specific}`);
190
- });
191
-
192
- it("should return low score for vague content", () => {
193
- const vague = "Uses auth";
194
- const specific = surprise.measureSpecificity(vague);
195
- assert.ok(specific < 0.3, `Expected low specificity < 0.3, got ${specific}`);
196
- });
197
-
198
- it("should give higher scores to content with numbers and technical terms", () => {
199
- const withDetails = "Server runs on port 3000 with 50 concurrent connections";
200
- const withoutDetails = "Server runs";
201
-
202
- const scoreWith = surprise.measureSpecificity(withDetails);
203
- const scoreWithout = surprise.measureSpecificity(withoutDetails);
204
-
205
- assert.ok(scoreWith > scoreWithout,
206
- `Expected detailed (${scoreWith}) > simple (${scoreWithout})`);
207
- });
208
- });
209
-
210
- describe("detectEmphasis()", () => {
211
- it("should detect all-caps words", () => {
212
- const emphasized = "IMPORTANT: This is critical";
213
- const score = surprise.detectEmphasis(emphasized);
214
- assert.ok(score >= 0.5, `Expected high emphasis >= 0.5, got ${score}`);
215
- });
216
-
217
- it("should detect emphasis keywords", () => {
218
- const keywords = [
219
- "CRITICAL: Remember this",
220
- "IMPORTANT: Don't forget",
221
- "NOTE: This is key",
222
- "ALWAYS use this approach",
223
- "NEVER do this"
224
- ];
225
-
226
- keywords.forEach(text => {
227
- const score = surprise.detectEmphasis(text);
228
- assert.ok(score > 0, `Expected emphasis for "${text}", got ${score}`);
229
- });
230
- });
231
-
232
- it("should detect exclamation marks", () => {
233
- const excited = "This is really important!!!";
234
- const score = surprise.detectEmphasis(excited);
235
- assert.ok(score > 0.3, `Expected some emphasis > 0.3, got ${score}`);
236
- });
237
-
238
- it("should return 0 for neutral text", () => {
239
- const neutral = "This is a regular statement.";
240
- const score = surprise.detectEmphasis(neutral);
241
- assert.strictEqual(score, 0);
242
- });
243
- });
244
-
245
- describe("measureContextSwitch()", () => {
246
- it("should detect category changes", () => {
247
- const newMemory = { content: "User's birthday is January 1st", type: "fact", category: "user" };
248
- const existing = [
249
- { content: "Uses Express.js", type: "fact", category: "code" },
250
- { content: "Database is SQLite", type: "fact", category: "code" }
251
- ];
252
-
253
- const score = surprise.measureContextSwitch(newMemory, existing);
254
- assert.ok(score > 0, `Expected context switch score > 0, got ${score}`);
255
- });
256
-
257
- it("should detect type changes", () => {
258
- const newMemory = { content: "User prefers Python", type: "preference" };
259
- const existing = [
260
- { content: "Project uses JavaScript", type: "fact" },
261
- { content: "API uses REST", type: "fact" }
262
- ];
263
-
264
- const score = surprise.measureContextSwitch(newMemory, existing);
265
- assert.ok(score > 0, `Expected type switch score > 0, got ${score}`);
266
- });
267
-
268
- it("should return low score for similar context", () => {
269
- const newMemory = { content: "Code fact about functions", type: "fact", category: "code" };
270
- const existing = [
271
- { content: "Code fact about functions and classes", type: "fact", category: "code" }
272
- ];
273
-
274
- const score = surprise.measureContextSwitch(newMemory, existing);
275
- // Should have low context switch due to keyword overlap
276
- assert.ok(score < 0.5, `Expected low context switch < 0.5, got ${score}`);
277
- });
278
- });
279
-
280
- describe("Edge Cases", () => {
281
- it("should handle empty content", () => {
282
- const memory = { content: "", type: "fact" };
283
- const score = surprise.calculateSurprise(memory, []);
284
- assert.ok(score >= 0 && score <= 1);
285
- });
286
-
287
- it("should handle very long content", () => {
288
- const longContent = "word ".repeat(1000);
289
- const memory = { content: longContent, type: "fact" };
290
- const score = surprise.calculateSurprise(memory, []);
291
- assert.ok(score >= 0 && score <= 1);
292
- });
293
-
294
- it("should handle special characters", () => {
295
- const memory = { content: "Uses @angular/core ^16.0.0 with RxJS ~7.8", type: "fact" };
296
- const score = surprise.calculateSurprise(memory, []);
297
- assert.ok(score >= 0 && score <= 1);
298
- });
299
- });
300
- });