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,397 +0,0 @@
1
- # Codex CLI Integration
2
-
3
- This guide explains how to configure [OpenAI Codex CLI](https://github.com/openai/codex) to use Lynkr as its backend, enabling you to use any LLM provider (Ollama, Azure OpenAI, Bedrock, Databricks, etc.) with Codex.
4
-
5
- ---
6
-
7
- ## Overview
8
-
9
- Codex CLI is OpenAI's terminal-based AI coding assistant. By routing it through Lynkr, you can:
10
-
11
- - Use **local models** (Ollama, llama.cpp, LM Studio) for free, private coding assistance
12
- - Access **enterprise providers** (Azure OpenAI, Databricks, AWS Bedrock)
13
- - Benefit from Lynkr's **token optimization** and **caching** features
14
- - Switch between providers without changing Codex configuration
15
-
16
- ---
17
-
18
- ## Quick Start
19
-
20
- ### Option 1: Environment Variables
21
-
22
- The fastest way to get started:
23
-
24
- ```bash
25
- # Set Lynkr as the OpenAI endpoint
26
- export OPENAI_BASE_URL=http://localhost:8081/v1
27
- export OPENAI_API_KEY=dummy
28
-
29
- # Start Lynkr (in another terminal)
30
- cd /path/to/lynkr && npm start
31
-
32
- # Run Codex
33
- codex
34
- ```
35
-
36
- ### Option 2: Config File (Recommended)
37
-
38
- For persistent configuration, edit `~/.codex/config.toml`:
39
-
40
- ```toml
41
- # Set Lynkr as the default provider
42
- model_provider = "lynkr"
43
- model = "gpt-4o"
44
-
45
- # Define the Lynkr provider
46
- [model_providers.lynkr]
47
- name = "Lynkr Proxy"
48
- base_url = "http://localhost:8081/v1"
49
- wire_api = "responses"
50
-
51
- # Optional: Trust your project directories for tool execution
52
- [projects."/path/to/your/project"]
53
- trust_level = "trusted"
54
- ```
55
-
56
- ---
57
-
58
- ## Complete Configuration Reference
59
-
60
- ### Full config.toml Example
61
-
62
- ```toml
63
- # =============================================================================
64
- # Codex CLI Configuration for Lynkr
65
- # Location: ~/.codex/config.toml
66
- # =============================================================================
67
-
68
- # Active provider (must match a key in [model_providers])
69
- model_provider = "lynkr"
70
-
71
- # Model to request (Lynkr maps this to your configured provider)
72
- model = "gpt-4o"
73
-
74
- # Personality affects response style: default, pragmatic, concise, educational
75
- personality = "pragmatic"
76
-
77
- # =============================================================================
78
- # Lynkr Provider Definition
79
- # =============================================================================
80
-
81
- [model_providers.lynkr]
82
- name = "Lynkr Proxy"
83
- base_url = "http://localhost:8081/v1"
84
- wire_api = "responses"
85
-
86
- # Alternative: Use chat completions API instead of responses API
87
- # wire_api = "chat"
88
-
89
- # =============================================================================
90
- # Remote Lynkr Server (Optional)
91
- # =============================================================================
92
-
93
- [model_providers.lynkr-remote]
94
- name = "Remote Lynkr (GPU Server)"
95
- base_url = "http://192.168.1.100:8081/v1"
96
- wire_api = "responses"
97
-
98
- # =============================================================================
99
- # Project Trust Levels
100
- # =============================================================================
101
- # trusted - Full tool execution allowed
102
- # sandboxed - Restricted tool execution
103
- # untrusted - No tool execution (default for new projects)
104
-
105
- [projects."/Users/yourname/work"]
106
- trust_level = "trusted"
107
-
108
- [projects."/Users/yourname/personal"]
109
- trust_level = "trusted"
110
-
111
- # =============================================================================
112
- # Agent Configuration (Optional)
113
- # =============================================================================
114
-
115
- [agent]
116
- enabled = true
117
-
118
- # =============================================================================
119
- # Skills Configuration (Optional)
120
- # =============================================================================
121
-
122
- [skills]
123
- enabled = true
124
- ```
125
-
126
- ---
127
-
128
- ## Configuration Options
129
-
130
- ### Provider Options
131
-
132
- | Option | Description | Values |
133
- |--------|-------------|--------|
134
- | `model_provider` | Active provider name | `"lynkr"`, `"openai"`, etc. |
135
- | `model` | Model to request | `"gpt-4o"`, `"claude-sonnet-4-5"`, etc. |
136
- | `personality` | Response style | `"default"`, `"pragmatic"`, `"concise"`, `"educational"` |
137
-
138
- ### Model Provider Options
139
-
140
- | Option | Description | Example |
141
- |--------|-------------|---------|
142
- | `name` | Display name | `"Lynkr Proxy"` |
143
- | `base_url` | API endpoint URL | `"http://localhost:8081/v1"` |
144
- | `wire_api` | API format | `"responses"` (recommended) or `"chat"` |
145
- | `env_key` | Environment variable for API key | `"OPENAI_API_KEY"` |
146
-
147
- ### Project Options
148
-
149
- | Option | Description | Values |
150
- |--------|-------------|--------|
151
- | `trust_level` | Tool execution permissions | `"trusted"`, `"sandboxed"`, `"untrusted"` |
152
-
153
- ---
154
-
155
- ## Wire API Formats
156
-
157
- Codex supports two API formats:
158
-
159
- ### Responses API (Recommended)
160
-
161
- ```toml
162
- wire_api = "responses"
163
- ```
164
-
165
- - Uses OpenAI's newer Responses API format
166
- - Better support for multi-turn conversations
167
- - Recommended for Lynkr integration
168
-
169
- ### Chat Completions API
170
-
171
- ```toml
172
- wire_api = "chat"
173
- ```
174
-
175
- - Uses standard OpenAI Chat Completions format
176
- - Broader compatibility with proxies
177
- - Use if you encounter issues with `responses`
178
-
179
- ---
180
-
181
- ## Remote Server Configuration
182
-
183
- Connect Codex to a Lynkr instance running on another machine:
184
-
185
- ### On the Remote Server
186
-
187
- ```bash
188
- # Edit .env to allow remote connections
189
- PORT=8081
190
-
191
- # Start Lynkr
192
- npm start
193
- ```
194
-
195
- ### On Your Local Machine
196
-
197
- ```toml
198
- # ~/.codex/config.toml
199
- model_provider = "lynkr-remote"
200
-
201
- [model_providers.lynkr-remote]
202
- name = "Remote Lynkr"
203
- base_url = "http://192.168.1.100:8081/v1"
204
- wire_api = "responses"
205
- ```
206
-
207
- ---
208
-
209
- ## Lynkr Configuration for Codex
210
-
211
- Optimize Lynkr for Codex usage by configuring these `.env` settings:
212
-
213
- ### Recommended Settings
214
-
215
- ```bash
216
- # =============================================================================
217
- # Lynkr .env Configuration for Codex
218
- # =============================================================================
219
-
220
- # Your LLM provider (Codex works with all Lynkr providers)
221
- MODEL_PROVIDER=azure-openai
222
- # MODEL_PROVIDER=ollama
223
- # MODEL_PROVIDER=bedrock
224
-
225
- # Tool execution mode - let Codex handle tools locally
226
- TOOL_EXECUTION_MODE=client
227
-
228
- # Increase tool loop threshold for complex multi-step tasks
229
- POLICY_TOOL_LOOP_THRESHOLD=15
230
-
231
- # Semantic cache (disable if getting repeated responses)
232
- SEMANTIC_CACHE_ENABLED=false
233
-
234
- # Or keep enabled with proper embeddings for faster responses
235
- # SEMANTIC_CACHE_ENABLED=true
236
- # OLLAMA_EMBEDDINGS_MODEL=nomic-embed-text
237
- ```
238
-
239
- ### Provider-Specific Examples
240
-
241
- **Azure OpenAI:**
242
- ```bash
243
- MODEL_PROVIDER=azure-openai
244
- AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/openai/responses?api-version=2025-04-01-preview
245
- AZURE_OPENAI_API_KEY=your-key
246
- AZURE_OPENAI_DEPLOYMENT=gpt-4o
247
- ```
248
-
249
- **Ollama (Local, Free):**
250
- ```bash
251
- MODEL_PROVIDER=ollama
252
- OLLAMA_MODEL=qwen2.5-coder:latest
253
- OLLAMA_ENDPOINT=http://localhost:11434
254
- ```
255
-
256
- **AWS Bedrock:**
257
- ```bash
258
- MODEL_PROVIDER=bedrock
259
- AWS_BEDROCK_API_KEY=your-key
260
- AWS_BEDROCK_MODEL_ID=anthropic.claude-3-5-sonnet-20241022-v2:0
261
- ```
262
-
263
- ---
264
-
265
- ## Troubleshooting
266
-
267
- ### Common Issues
268
-
269
- | Issue | Cause | Solution |
270
- |-------|-------|----------|
271
- | Same response for all queries | Semantic cache matching on system prompt | Set `SEMANTIC_CACHE_ENABLED=false` in Lynkr `.env` |
272
- | Tool calls not executing | Tool loop threshold too low | Set `POLICY_TOOL_LOOP_THRESHOLD=15` |
273
- | Connection refused | Lynkr not running | Run `npm start` in Lynkr directory |
274
- | Slow first request | Cold start / model loading | Set `OLLAMA_KEEP_ALIVE=24h` for Ollama |
275
- | "Invalid API key" errors | API key not set | Set `OPENAI_API_KEY=dummy` (Lynkr doesn't validate) |
276
- | Streaming issues | Wire API mismatch | Try `wire_api = "chat"` instead of `"responses"` |
277
-
278
- ### Debug Mode
279
-
280
- Enable verbose logging to diagnose issues:
281
-
282
- ```bash
283
- # In Lynkr .env
284
- LOG_LEVEL=debug
285
-
286
- # Restart Lynkr and watch logs
287
- npm start
288
- ```
289
-
290
- ### Verify Connection
291
-
292
- Test that Codex can reach Lynkr:
293
-
294
- ```bash
295
- curl http://localhost:8081/health
296
- # Expected: {"status":"ok",...}
297
- ```
298
-
299
- ---
300
-
301
- ## Model Mapping
302
-
303
- When you specify a model in Codex, Lynkr maps it to your configured provider:
304
-
305
- | Codex Model | Lynkr Mapping |
306
- |-------------|---------------|
307
- | `gpt-4o` | Uses your `MODEL_PROVIDER` default model |
308
- | `gpt-4o-mini` | Maps to smaller/cheaper model variant |
309
- | `claude-sonnet-4-5` | Routes to Anthropic-compatible provider |
310
- | `claude-opus-4-5` | Routes to most capable model |
311
-
312
- The actual model used depends on your Lynkr provider configuration.
313
-
314
- ---
315
-
316
- ## Architecture
317
-
318
- ```
319
- ┌─────────────────┐
320
- │ Codex CLI │ Terminal AI coding assistant
321
- │ (Your Machine)│
322
- └────────┬────────┘
323
- │ OpenAI Responses API
324
- │ http://localhost:8081/v1
325
-
326
- ┌─────────────────┐
327
- │ Lynkr │ Universal LLM proxy
328
- │ Port 8081 │
329
- │ │
330
- │ • Format conv. │ Converts between API formats
331
- │ • Token optim. │ Reduces costs 60-80%
332
- │ • Caching │ Semantic + prompt caching
333
- │ • Tool routing │ Server or client execution
334
- └────────┬────────┘
335
-
336
- ┌────┴────┬──────────┬──────────┐
337
- ▼ ▼ ▼ ▼
338
- ┌───────┐ ┌───────┐ ┌─────────┐ ┌─────────┐
339
- │Ollama │ │Azure │ │Bedrock │ │Databricks│
340
- │(Free) │ │OpenAI │ │(100+) │ │ │
341
- └───────┘ └───────┘ └─────────┘ └─────────┘
342
- ```
343
-
344
- ---
345
-
346
- ## Tips & Best Practices
347
-
348
- ### 1. Use Trusted Projects
349
-
350
- For frequently used projects, set trust level to avoid repeated permission prompts:
351
-
352
- ```toml
353
- [projects."/Users/yourname/main-project"]
354
- trust_level = "trusted"
355
- ```
356
-
357
- ### 2. Configure Personality
358
-
359
- Choose a personality that matches your workflow:
360
-
361
- - `pragmatic` - Direct, solution-focused responses
362
- - `concise` - Minimal explanations, code-focused
363
- - `educational` - Detailed explanations, good for learning
364
- - `default` - Balanced approach
365
-
366
- ### 3. Keep Models Loaded
367
-
368
- Prevent slow first requests with Ollama:
369
-
370
- ```bash
371
- # macOS
372
- launchctl setenv OLLAMA_KEEP_ALIVE "24h"
373
-
374
- # Linux/Windows
375
- export OLLAMA_KEEP_ALIVE=24h
376
- ```
377
-
378
- ### 4. Monitor Token Usage
379
-
380
- Check Lynkr metrics to monitor usage:
381
-
382
- ```bash
383
- curl http://localhost:8081/metrics/token-usage
384
- ```
385
-
386
- ---
387
-
388
- ## Related Documentation
389
-
390
- - **[Installation Guide](installation.md)** - Install and configure Lynkr
391
- - **[Provider Configuration](providers.md)** - Configure your LLM provider
392
- - **[Token Optimization](token-optimization.md)** - Reduce costs with Lynkr
393
- - **[Troubleshooting](troubleshooting.md)** - Common issues and solutions
394
-
395
- ---
396
-
397
- **Need help?** Visit [GitHub Discussions](https://github.com/vishalveerareddy123/Lynkr/discussions) or check the [FAQ](faq.md).