lynkr 7.2.5 → 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 (124) hide show
  1. package/README.md +3 -3
  2. package/config/model-tiers.json +89 -0
  3. package/install.sh +6 -1
  4. package/package.json +4 -2
  5. package/scripts/setup.js +0 -1
  6. package/src/agents/executor.js +14 -6
  7. package/src/api/middleware/session.js +15 -2
  8. package/src/api/openai-router.js +162 -37
  9. package/src/api/providers-handler.js +15 -1
  10. package/src/api/router.js +107 -2
  11. package/src/budget/index.js +4 -3
  12. package/src/clients/databricks.js +431 -234
  13. package/src/clients/gpt-utils.js +181 -0
  14. package/src/clients/ollama-utils.js +66 -140
  15. package/src/clients/routing.js +0 -1
  16. package/src/clients/standard-tools.js +99 -3
  17. package/src/config/index.js +133 -35
  18. package/src/context/toon.js +173 -0
  19. package/src/logger/index.js +23 -0
  20. package/src/orchestrator/index.js +688 -213
  21. package/src/routing/agentic-detector.js +320 -0
  22. package/src/routing/complexity-analyzer.js +202 -2
  23. package/src/routing/cost-optimizer.js +305 -0
  24. package/src/routing/index.js +168 -159
  25. package/src/routing/model-tiers.js +365 -0
  26. package/src/server.js +4 -14
  27. package/src/sessions/cleanup.js +3 -3
  28. package/src/sessions/record.js +10 -1
  29. package/src/sessions/store.js +7 -2
  30. package/src/tools/agent-task.js +48 -1
  31. package/src/tools/index.js +19 -2
  32. package/src/tools/lazy-loader.js +7 -0
  33. package/src/tools/tinyfish.js +358 -0
  34. package/src/tools/truncate.js +1 -0
  35. package/.github/FUNDING.yml +0 -15
  36. package/.github/workflows/README.md +0 -215
  37. package/.github/workflows/ci.yml +0 -69
  38. package/.github/workflows/index.yml +0 -62
  39. package/.github/workflows/web-tools-tests.yml +0 -56
  40. package/CITATIONS.bib +0 -6
  41. package/CLAWROUTER_ROUTING_PLAN.md +0 -910
  42. package/DEPLOYMENT.md +0 -1001
  43. package/LYNKR-TUI-PLAN.md +0 -984
  44. package/PERFORMANCE-REPORT.md +0 -866
  45. package/PLAN-per-client-model-routing.md +0 -252
  46. package/ROUTER_COMPARISON.md +0 -173
  47. package/TIER_ROUTING_PLAN.md +0 -771
  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 -197
  52. package/docs/google5be250e608e6da39.html +0 -1
  53. package/docs/index.html +0 -577
  54. package/docs/index.md +0 -577
  55. package/docs/robots.txt +0 -4
  56. package/docs/sitemap.xml +0 -44
  57. package/docs/style.css +0 -1223
  58. package/documentation/README.md +0 -100
  59. package/documentation/api.md +0 -806
  60. package/documentation/claude-code-cli.md +0 -672
  61. package/documentation/codex-cli.md +0 -397
  62. package/documentation/contributing.md +0 -571
  63. package/documentation/cursor-integration.md +0 -731
  64. package/documentation/docker.md +0 -867
  65. package/documentation/embeddings.md +0 -760
  66. package/documentation/faq.md +0 -659
  67. package/documentation/features.md +0 -396
  68. package/documentation/headroom.md +0 -519
  69. package/documentation/installation.md +0 -706
  70. package/documentation/memory-system.md +0 -476
  71. package/documentation/production.md +0 -601
  72. package/documentation/providers.md +0 -906
  73. package/documentation/testing.md +0 -629
  74. package/documentation/token-optimization.md +0 -323
  75. package/documentation/tools.md +0 -697
  76. package/documentation/troubleshooting.md +0 -893
  77. package/final-test.js +0 -33
  78. package/headroom-sidecar/config.py +0 -93
  79. package/headroom-sidecar/requirements.txt +0 -14
  80. package/headroom-sidecar/server.py +0 -451
  81. package/monitor-agents.sh +0 -31
  82. package/scripts/audit-log-reader.js +0 -399
  83. package/scripts/compact-dictionary.js +0 -204
  84. package/scripts/test-deduplication.js +0 -448
  85. package/src/db/database.sqlite +0 -0
  86. package/test/README.md +0 -212
  87. package/test/azure-openai-config.test.js +0 -204
  88. package/test/azure-openai-error-resilience.test.js +0 -238
  89. package/test/azure-openai-format-conversion.test.js +0 -354
  90. package/test/azure-openai-integration.test.js +0 -281
  91. package/test/azure-openai-routing.test.js +0 -177
  92. package/test/azure-openai-streaming.test.js +0 -171
  93. package/test/bedrock-integration.test.js +0 -471
  94. package/test/comprehensive-test-suite.js +0 -928
  95. package/test/config-validation.test.js +0 -207
  96. package/test/cursor-integration.test.js +0 -484
  97. package/test/format-conversion.test.js +0 -578
  98. package/test/hybrid-routing-integration.test.js +0 -254
  99. package/test/hybrid-routing-performance.test.js +0 -418
  100. package/test/llamacpp-integration.test.js +0 -863
  101. package/test/lmstudio-integration.test.js +0 -335
  102. package/test/memory/extractor.test.js +0 -398
  103. package/test/memory/retriever.test.js +0 -613
  104. package/test/memory/retriever.test.js.bak +0 -585
  105. package/test/memory/search.test.js +0 -537
  106. package/test/memory/search.test.js.bak +0 -389
  107. package/test/memory/store.test.js +0 -344
  108. package/test/memory/store.test.js.bak +0 -312
  109. package/test/memory/surprise.test.js +0 -300
  110. package/test/memory-performance.test.js +0 -472
  111. package/test/openai-integration.test.js +0 -686
  112. package/test/openrouter-error-resilience.test.js +0 -418
  113. package/test/passthrough-mode.test.js +0 -385
  114. package/test/performance-benchmark.js +0 -351
  115. package/test/performance-tests.js +0 -528
  116. package/test/routing.test.js +0 -219
  117. package/test/web-tools.test.js +0 -329
  118. package/test-agents-simple.js +0 -43
  119. package/test-cli-connection.sh +0 -33
  120. package/test-learning-unit.js +0 -126
  121. package/test-learning.js +0 -112
  122. package/test-parallel-agents.sh +0 -124
  123. package/test-parallel-direct.js +0 -155
  124. 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).