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