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,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).