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,351 +0,0 @@
1
- /**
2
- * Comprehensive Performance Benchmark
3
- *
4
- * Measures performance impact of all production hardening features:
5
- * - Option 1: Retries, budgets, rate limits, path allowlisting, sandboxing, safe commands
6
- * - Option 2 & 3: Metrics, health checks, logging, error handling, validation, load shedding, circuit breakers
7
- *
8
- * Key Metrics:
9
- * - Request throughput (req/s)
10
- * - Latency (p50, p95, p99)
11
- * - Memory usage
12
- * - CPU usage
13
- * - Overhead per middleware
14
- */
15
-
16
- const { performance } = require("perf_hooks");
17
- const { MetricsCollector } = require("../src/observability/metrics");
18
- const { LoadShedder } = require("../src/api/middleware/load-shedding");
19
- const { CircuitBreaker } = require("../src/clients/circuit-breaker");
20
- const { validateObject } = require("../src/api/middleware/validation");
21
-
22
- // Color utilities
23
- function colorize(text, color) {
24
- const colors = {
25
- green: "\x1b[32m",
26
- red: "\x1b[31m",
27
- yellow: "\x1b[33m",
28
- blue: "\x1b[34m",
29
- cyan: "\x1b[36m",
30
- reset: "\x1b[0m",
31
- };
32
- return `${colors[color] || ""}${text}${colors.reset}`;
33
- }
34
-
35
- // =============================================================================
36
- // Benchmark Utilities
37
- // =============================================================================
38
-
39
- async function benchmark(name, iterations, fn) {
40
- console.log(colorize(`\n📊 ${name}`, "cyan"));
41
- console.log(` Iterations: ${iterations.toLocaleString()}`);
42
-
43
- // Warmup
44
- for (let i = 0; i < Math.min(iterations / 10, 1000); i++) {
45
- await fn();
46
- }
47
-
48
- // Force GC if available
49
- if (global.gc) {
50
- global.gc();
51
- }
52
-
53
- const memBefore = process.memoryUsage();
54
- const cpuBefore = process.cpuUsage();
55
- const startTime = performance.now();
56
-
57
- // Run benchmark
58
- for (let i = 0; i < iterations; i++) {
59
- await fn();
60
- }
61
-
62
- const endTime = performance.now();
63
- const cpuAfter = process.cpuUsage();
64
- const memAfter = process.memoryUsage();
65
-
66
- // Calculate metrics
67
- const totalTime = endTime - startTime;
68
- const avgTime = totalTime / iterations;
69
- const throughput = (iterations / totalTime) * 1000; // ops/sec
70
-
71
- const cpuUser = (cpuAfter.user - cpuBefore.user) / 1000; // ms
72
- const cpuSystem = (cpuAfter.system - cpuBefore.system) / 1000; // ms
73
- const cpuTotal = cpuUser + cpuSystem;
74
-
75
- const memUsed = (memAfter.heapUsed - memBefore.heapUsed) / 1024 / 1024; // MB
76
-
77
- // Results
78
- console.log(` ${colorize("Duration:", "blue")} ${totalTime.toFixed(2)}ms`);
79
- console.log(` ${colorize("Avg/op:", "blue")} ${avgTime.toFixed(4)}ms`);
80
- console.log(` ${colorize("Throughput:", "green")} ${throughput.toLocaleString("en-US", { maximumFractionDigits: 0 })} ops/sec`);
81
- console.log(` ${colorize("CPU:", "yellow")} ${cpuTotal.toFixed(2)}ms (user: ${cpuUser.toFixed(2)}ms, system: ${cpuSystem.toFixed(2)}ms)`);
82
- console.log(` ${colorize("Memory:", "yellow")} ${memUsed >= 0 ? "+" : ""}${memUsed.toFixed(2)}MB`);
83
-
84
- return {
85
- name,
86
- iterations,
87
- totalTime,
88
- avgTime,
89
- throughput,
90
- cpu: {
91
- user: cpuUser,
92
- system: cpuSystem,
93
- total: cpuTotal,
94
- },
95
- memory: memUsed,
96
- };
97
- }
98
-
99
- // =============================================================================
100
- // Benchmarks
101
- // =============================================================================
102
-
103
- async function runBenchmarks() {
104
- console.log(colorize("\n╔═══════════════════════════════════════════════════╗", "blue"));
105
- console.log(colorize("║ Performance Benchmark Suite ║", "blue"));
106
- console.log(colorize("╚═══════════════════════════════════════════════════╝", "blue"));
107
-
108
- const results = [];
109
-
110
- // Baseline: No-op function
111
- results.push(
112
- await benchmark("Baseline (no-op)", 1000000, async () => {
113
- return true;
114
- })
115
- );
116
-
117
- // Metrics Collection
118
- results.push(
119
- await benchmark("Metrics Collection", 100000, async () => {
120
- const metrics = new MetricsCollector();
121
- metrics.recordRequest("GET", "/test", 200, 100);
122
- metrics.recordTokens(100, 50);
123
- metrics.recordCost(0.01);
124
- })
125
- );
126
-
127
- // Metrics Snapshot (lazy calculation)
128
- results.push(
129
- await benchmark("Metrics Snapshot", 10000, async () => {
130
- const metrics = new MetricsCollector();
131
- for (let i = 0; i < 100; i++) {
132
- metrics.recordRequest("GET", "/test", 200, Math.random() * 200);
133
- }
134
- metrics.getMetrics();
135
- })
136
- );
137
-
138
- // Prometheus Export
139
- results.push(
140
- await benchmark("Prometheus Export", 10000, async () => {
141
- const metrics = new MetricsCollector();
142
- for (let i = 0; i < 100; i++) {
143
- metrics.recordRequest("GET", "/test", 200, Math.random() * 200);
144
- }
145
- metrics.toPrometheus();
146
- })
147
- );
148
-
149
- // Load Shedding Check (not overloaded)
150
- results.push(
151
- await benchmark("Load Shedding Check", 100000, async () => {
152
- const shedder = new LoadShedder();
153
- shedder.isOverloaded();
154
- })
155
- );
156
-
157
- // Circuit Breaker (closed state)
158
- results.push(
159
- await benchmark("Circuit Breaker (closed)", 100000, async () => {
160
- const breaker = new CircuitBreaker("test");
161
- await breaker.execute(async () => "success");
162
- })
163
- );
164
-
165
- // Input Validation (simple)
166
- results.push(
167
- await benchmark("Input Validation (simple)", 100000, async () => {
168
- const schema = {
169
- required: ["name"],
170
- properties: {
171
- name: { type: "string", minLength: 1, maxLength: 100 },
172
- },
173
- };
174
- validateObject({ name: "test" }, schema);
175
- })
176
- );
177
-
178
- // Input Validation (complex)
179
- results.push(
180
- await benchmark("Input Validation (complex)", 10000, async () => {
181
- const schema = {
182
- required: ["model", "messages"],
183
- properties: {
184
- model: { type: "string", minLength: 1 },
185
- messages: {
186
- type: "array",
187
- minItems: 1,
188
- items: {
189
- type: "object",
190
- required: ["role", "content"],
191
- properties: {
192
- role: { type: "string", enum: ["user", "assistant", "system"] },
193
- content: { type: "string", minLength: 1 },
194
- },
195
- },
196
- },
197
- temperature: { type: "number", minimum: 0, maximum: 2 },
198
- },
199
- };
200
-
201
- validateObject(
202
- {
203
- model: "test-model",
204
- messages: [
205
- { role: "user", content: "Hello" },
206
- { role: "assistant", content: "Hi there" },
207
- ],
208
- temperature: 0.7,
209
- },
210
- schema
211
- );
212
- })
213
- );
214
-
215
- // Request ID Generation
216
- results.push(
217
- await benchmark("Request ID Generation", 100000, async () => {
218
- const crypto = require("crypto");
219
- crypto.randomBytes(16).toString("hex");
220
- })
221
- );
222
-
223
- // Combined middleware stack simulation
224
- results.push(
225
- await benchmark("Combined Middleware Stack", 10000, async () => {
226
- // Simulate request flowing through all middleware
227
- const requestId = require("crypto").randomBytes(16).toString("hex");
228
-
229
- const metrics = new MetricsCollector();
230
- const shedder = new LoadShedder();
231
-
232
- // Load shedding check
233
- if (!shedder.isOverloaded()) {
234
- // Metrics collection
235
- const start = performance.now();
236
- metrics.recordRequest("POST", "/v1/messages", 200, 0);
237
-
238
- // Validation
239
- const schema = {
240
- required: ["model"],
241
- properties: {
242
- model: { type: "string" },
243
- },
244
- };
245
- validateObject({ model: "test" }, schema);
246
-
247
- // Record latency
248
- const latency = performance.now() - start;
249
- metrics.recordRequest("POST", "/v1/messages", 200, latency);
250
- }
251
- })
252
- );
253
-
254
- // =============================================================================
255
- // Summary
256
- // =============================================================================
257
-
258
- console.log(colorize("\n╔═══════════════════════════════════════════════════╗", "blue"));
259
- console.log(colorize("║ Performance Summary ║", "blue"));
260
- console.log(colorize("╚═══════════════════════════════════════════════════╝", "blue"));
261
-
262
- const baseline = results[0];
263
-
264
- console.log(colorize("\n📈 Throughput Comparison", "cyan"));
265
- console.log(colorize("─".repeat(80), "blue"));
266
- console.log(
267
- `${"Benchmark".padEnd(40)} ${"Throughput".padEnd(20)} ${"Overhead".padEnd(20)}`
268
- );
269
- console.log(colorize("─".repeat(80), "blue"));
270
-
271
- for (const result of results) {
272
- const overhead =
273
- result.name === baseline.name
274
- ? "-"
275
- : `${((baseline.throughput / result.throughput - 1) * 100).toFixed(1)}%`;
276
-
277
- const throughputStr = `${result.throughput.toLocaleString("en-US", { maximumFractionDigits: 0 })} ops/s`;
278
-
279
- console.log(`${result.name.padEnd(40)} ${throughputStr.padEnd(20)} ${overhead.padEnd(20)}`);
280
- }
281
-
282
- console.log(colorize("\n⏱️ Latency Comparison", "cyan"));
283
- console.log(colorize("─".repeat(80), "blue"));
284
- console.log(
285
- `${"Benchmark".padEnd(40)} ${"Avg Latency".padEnd(20)} ${"vs Baseline".padEnd(20)}`
286
- );
287
- console.log(colorize("─".repeat(80), "blue"));
288
-
289
- for (const result of results) {
290
- const vsBaseline =
291
- result.name === baseline.name
292
- ? "-"
293
- : `+${(result.avgTime - baseline.avgTime).toFixed(4)}ms`;
294
-
295
- console.log(
296
- `${result.name.padEnd(40)} ${result.avgTime.toFixed(4)}ms${"".padEnd(12)} ${vsBaseline.padEnd(20)}`
297
- );
298
- }
299
-
300
- console.log(colorize("\n💾 Memory Impact", "cyan"));
301
- console.log(colorize("─".repeat(60), "blue"));
302
- for (const result of results) {
303
- const memStr = result.memory >= 0 ? `+${result.memory.toFixed(2)}MB` : `${result.memory.toFixed(2)}MB`;
304
- console.log(`${result.name.padEnd(40)} ${memStr}`);
305
- }
306
-
307
- console.log(colorize("\n🔥 Key Insights", "yellow"));
308
- console.log(colorize("─".repeat(60), "blue"));
309
-
310
- const metricsResult = results.find((r) => r.name === "Metrics Collection");
311
- const stackResult = results.find((r) => r.name === "Combined Middleware Stack");
312
-
313
- console.log(
314
- `✓ Metrics collection: ${colorize(metricsResult.throughput.toLocaleString() + " ops/sec", "green")} (${((baseline.throughput / metricsResult.throughput - 1) * 100).toFixed(1)}% overhead)`
315
- );
316
- console.log(
317
- `✓ Full middleware stack: ${colorize(stackResult.throughput.toLocaleString() + " ops/sec", "green")} (${((baseline.throughput / stackResult.throughput - 1) * 100).toFixed(1)}% overhead)`
318
- );
319
- console.log(
320
- `✓ Average latency added: ${colorize((stackResult.avgTime - baseline.avgTime).toFixed(4) + "ms", "cyan")}`
321
- );
322
-
323
- // Performance rating
324
- const totalOverhead = ((baseline.throughput / stackResult.throughput - 1) * 100);
325
- let rating, color;
326
- if (totalOverhead < 5) {
327
- rating = "EXCELLENT";
328
- color = "green";
329
- } else if (totalOverhead < 15) {
330
- rating = "GOOD";
331
- color = "green";
332
- } else if (totalOverhead < 30) {
333
- rating = "ACCEPTABLE";
334
- color = "yellow";
335
- } else {
336
- rating = "NEEDS OPTIMIZATION";
337
- color = "red";
338
- }
339
-
340
- console.log(
341
- `\n🏆 Overall Performance Rating: ${colorize(rating, color)} (${totalOverhead.toFixed(1)}% total overhead)`
342
- );
343
-
344
- console.log(colorize("\n" + "=".repeat(60), "blue"));
345
- }
346
-
347
- // Run benchmarks
348
- runBenchmarks().catch((err) => {
349
- console.error("Benchmark error:", err);
350
- process.exit(1);
351
- });