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.
- package/README.md +3 -3
- package/config/model-tiers.json +89 -0
- package/install.sh +6 -1
- package/package.json +4 -2
- package/scripts/setup.js +0 -1
- package/src/agents/executor.js +14 -6
- package/src/api/middleware/session.js +15 -2
- package/src/api/openai-router.js +162 -37
- package/src/api/providers-handler.js +15 -1
- package/src/api/router.js +107 -2
- package/src/budget/index.js +4 -3
- package/src/clients/databricks.js +431 -234
- package/src/clients/gpt-utils.js +181 -0
- package/src/clients/ollama-utils.js +66 -140
- package/src/clients/routing.js +0 -1
- package/src/clients/standard-tools.js +99 -3
- package/src/config/index.js +133 -35
- package/src/context/toon.js +173 -0
- package/src/logger/index.js +23 -0
- package/src/orchestrator/index.js +688 -213
- package/src/routing/agentic-detector.js +320 -0
- package/src/routing/complexity-analyzer.js +202 -2
- package/src/routing/cost-optimizer.js +305 -0
- package/src/routing/index.js +168 -159
- package/src/routing/model-tiers.js +365 -0
- package/src/server.js +4 -14
- package/src/sessions/cleanup.js +3 -3
- package/src/sessions/record.js +10 -1
- package/src/sessions/store.js +7 -2
- package/src/tools/agent-task.js +48 -1
- package/src/tools/index.js +19 -2
- package/src/tools/lazy-loader.js +7 -0
- package/src/tools/tinyfish.js +358 -0
- package/src/tools/truncate.js +1 -0
- package/.github/FUNDING.yml +0 -15
- package/.github/workflows/README.md +0 -215
- package/.github/workflows/ci.yml +0 -69
- package/.github/workflows/index.yml +0 -62
- package/.github/workflows/web-tools-tests.yml +0 -56
- package/CITATIONS.bib +0 -6
- package/CLAWROUTER_ROUTING_PLAN.md +0 -910
- package/DEPLOYMENT.md +0 -1001
- package/LYNKR-TUI-PLAN.md +0 -984
- package/PERFORMANCE-REPORT.md +0 -866
- package/PLAN-per-client-model-routing.md +0 -252
- package/ROUTER_COMPARISON.md +0 -173
- package/TIER_ROUTING_PLAN.md +0 -771
- package/docs/42642f749da6234f41b6b425c3bb07c9.txt +0 -1
- package/docs/BingSiteAuth.xml +0 -4
- package/docs/docs-style.css +0 -478
- package/docs/docs.html +0 -197
- package/docs/google5be250e608e6da39.html +0 -1
- package/docs/index.html +0 -577
- package/docs/index.md +0 -577
- package/docs/robots.txt +0 -4
- package/docs/sitemap.xml +0 -44
- package/docs/style.css +0 -1223
- package/documentation/README.md +0 -100
- package/documentation/api.md +0 -806
- package/documentation/claude-code-cli.md +0 -672
- package/documentation/codex-cli.md +0 -397
- package/documentation/contributing.md +0 -571
- package/documentation/cursor-integration.md +0 -731
- package/documentation/docker.md +0 -867
- package/documentation/embeddings.md +0 -760
- package/documentation/faq.md +0 -659
- package/documentation/features.md +0 -396
- package/documentation/headroom.md +0 -519
- package/documentation/installation.md +0 -706
- package/documentation/memory-system.md +0 -476
- package/documentation/production.md +0 -601
- package/documentation/providers.md +0 -906
- package/documentation/testing.md +0 -629
- package/documentation/token-optimization.md +0 -323
- package/documentation/tools.md +0 -697
- package/documentation/troubleshooting.md +0 -893
- package/final-test.js +0 -33
- package/headroom-sidecar/config.py +0 -93
- package/headroom-sidecar/requirements.txt +0 -14
- package/headroom-sidecar/server.py +0 -451
- package/monitor-agents.sh +0 -31
- package/scripts/audit-log-reader.js +0 -399
- package/scripts/compact-dictionary.js +0 -204
- package/scripts/test-deduplication.js +0 -448
- package/src/db/database.sqlite +0 -0
- package/test/README.md +0 -212
- package/test/azure-openai-config.test.js +0 -204
- package/test/azure-openai-error-resilience.test.js +0 -238
- package/test/azure-openai-format-conversion.test.js +0 -354
- package/test/azure-openai-integration.test.js +0 -281
- package/test/azure-openai-routing.test.js +0 -177
- package/test/azure-openai-streaming.test.js +0 -171
- package/test/bedrock-integration.test.js +0 -471
- package/test/comprehensive-test-suite.js +0 -928
- package/test/config-validation.test.js +0 -207
- package/test/cursor-integration.test.js +0 -484
- package/test/format-conversion.test.js +0 -578
- package/test/hybrid-routing-integration.test.js +0 -254
- package/test/hybrid-routing-performance.test.js +0 -418
- package/test/llamacpp-integration.test.js +0 -863
- package/test/lmstudio-integration.test.js +0 -335
- package/test/memory/extractor.test.js +0 -398
- package/test/memory/retriever.test.js +0 -613
- package/test/memory/retriever.test.js.bak +0 -585
- package/test/memory/search.test.js +0 -537
- package/test/memory/search.test.js.bak +0 -389
- package/test/memory/store.test.js +0 -344
- package/test/memory/store.test.js.bak +0 -312
- package/test/memory/surprise.test.js +0 -300
- package/test/memory-performance.test.js +0 -472
- package/test/openai-integration.test.js +0 -686
- package/test/openrouter-error-resilience.test.js +0 -418
- package/test/passthrough-mode.test.js +0 -385
- package/test/performance-benchmark.js +0 -351
- package/test/performance-tests.js +0 -528
- package/test/routing.test.js +0 -219
- package/test/web-tools.test.js +0 -329
- package/test-agents-simple.js +0 -43
- package/test-cli-connection.sh +0 -33
- package/test-learning-unit.js +0 -126
- package/test-learning.js +0 -112
- package/test-parallel-agents.sh +0 -124
- package/test-parallel-direct.js +0 -155
- package/test-subagents.sh +0 -117
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
# Per-Client Model Routing Implementation Plan
|
|
2
|
-
|
|
3
|
-
## Current State
|
|
4
|
-
|
|
5
|
-
### How Model Routing Works Now
|
|
6
|
-
|
|
7
|
-
1. **Global Provider**: Set via `MODEL_PROVIDER` in `.env`
|
|
8
|
-
2. **No Per-Client Routing**: All clients use the same provider
|
|
9
|
-
3. **Smart Routing**: Only when `PREFER_OLLAMA=true` (routes based on tool count/complexity)
|
|
10
|
-
4. **No Client-Side Indication**: Clients don't know which model was used
|
|
11
|
-
|
|
12
|
-
### Current Configuration Options
|
|
13
|
-
|
|
14
|
-
| Config | Purpose | Example Values |
|
|
15
|
-
|--------|---------|-----------------|
|
|
16
|
-
| `MODEL_PROVIDER` | Primary provider | databricks, ollama, openrouter, azure-openai, bedrock |
|
|
17
|
-
| `PREFER_OLLAMA` | Enable smart routing | true/false |
|
|
18
|
-
| `FALLBACK_ENABLED` | Allow fallback to cloud | true/false (default: true) |
|
|
19
|
-
| `FALLBACK_PROVIDER` | Cloud fallback provider | databricks, azure-anthropic, bedrock |
|
|
20
|
-
| `OLLAMA_MAX_TOOLS_FOR_ROUTING` | Tool threshold for Ollama | 3 (default) |
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Implementation Plan
|
|
25
|
-
|
|
26
|
-
### Phase 1: Add Client-to-Provider Mapping Config
|
|
27
|
-
|
|
28
|
-
**File**: `.env`
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
# Per-client provider mapping (new)
|
|
32
|
-
CLIENT_PROVIDER_MAP=claude-code:ollama,codex:azure-openai,cline:openrouter,kilo:zai
|
|
33
|
-
CLIENT_PROVIDER_DEFAULT=azure-openai
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
**File**: `src/config/index.js`
|
|
37
|
-
|
|
38
|
-
```javascript
|
|
39
|
-
// Add helper function
|
|
40
|
-
function parseClientProviderMap(envValue) {
|
|
41
|
-
if (!envValue) return {};
|
|
42
|
-
const map = {};
|
|
43
|
-
envValue.split(',').forEach(pair => {
|
|
44
|
-
const [client, provider] = pair.split(':').map(s => s.trim().toLowerCase());
|
|
45
|
-
if (client && provider) {
|
|
46
|
-
map[client] = provider;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return map;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Add to config object
|
|
53
|
-
clientProviderMap: parseClientProviderMap(process.env.CLIENT_PROVIDER_MAP),
|
|
54
|
-
clientProviderDefault: process.env.CLIENT_PROVIDER_DEFAULT || process.env.MODEL_PROVIDER || 'azure-openai',
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
### Phase 2: Detect Client & Override Provider
|
|
60
|
-
|
|
61
|
-
**File**: `src/orchestrator/index.js` (around line 769)
|
|
62
|
-
|
|
63
|
-
```javascript
|
|
64
|
-
// Add at top of file
|
|
65
|
-
const VALID_PROVIDERS = new Set([
|
|
66
|
-
'databricks', 'azure-anthropic', 'azure-openai', 'openrouter',
|
|
67
|
-
'openai', 'ollama', 'llamacpp', 'lmstudio', 'bedrock', 'zai', 'vertex'
|
|
68
|
-
]);
|
|
69
|
-
|
|
70
|
-
// Add helper function
|
|
71
|
-
function detectClientType(headers) {
|
|
72
|
-
const userAgent = (headers?.["user-agent"] || "").toLowerCase();
|
|
73
|
-
const clientHeader = (headers?.["x-client"] || headers?.["x-client-name"] || "").toLowerCase();
|
|
74
|
-
|
|
75
|
-
if (userAgent.includes("claude") || clientHeader.includes("claude")) return "claude-code";
|
|
76
|
-
if (userAgent.includes("codex") || clientHeader.includes("codex")) return "codex";
|
|
77
|
-
if (userAgent.includes("kilo") || clientHeader.includes("kilo")) return "kilo";
|
|
78
|
-
if (userAgent.includes("cline") || clientHeader.includes("cline")) return "cline";
|
|
79
|
-
if (userAgent.includes("continue") || clientHeader.includes("continue")) return "continue";
|
|
80
|
-
if (userAgent.includes("cursor") || clientHeader.includes("cursor")) return "cursor";
|
|
81
|
-
if (userAgent.includes("windsurf") || clientHeader.includes("windsurf")) return "windsurf";
|
|
82
|
-
|
|
83
|
-
return "unknown";
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function getProviderForClient(headers, defaultProvider) {
|
|
87
|
-
const clientType = detectClientType(headers);
|
|
88
|
-
const clientMap = config.clientProviderMap || {};
|
|
89
|
-
|
|
90
|
-
// 1. Check for explicit header override
|
|
91
|
-
const headerOverride = headers?.["x-model-provider"]?.toLowerCase();
|
|
92
|
-
if (headerOverride && VALID_PROVIDERS.has(headerOverride)) {
|
|
93
|
-
logger.info({ clientType, headerOverride }, "Using header-specified provider");
|
|
94
|
-
return headerOverride;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// 2. Check client-specific mapping from config
|
|
98
|
-
if (clientMap[clientType]) {
|
|
99
|
-
logger.info({ clientType, provider: clientMap[clientType] }, "Using client-mapped provider");
|
|
100
|
-
return clientMap[clientType];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// 3. Fall back to default
|
|
104
|
-
logger.debug({ clientType, defaultProvider }, "Using default provider");
|
|
105
|
-
return config.clientProviderDefault || defaultProvider;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Replace current static provider selection:
|
|
109
|
-
// OLD: const providerType = config.modelProvider?.type ?? "databricks";
|
|
110
|
-
// NEW:
|
|
111
|
-
const providerType = getProviderForClient(headers, config.modelProvider?.type ?? "databricks");
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
### Phase 3: Add Response Header for Model Indication
|
|
117
|
-
|
|
118
|
-
**File**: `src/api/openai-router.js`
|
|
119
|
-
|
|
120
|
-
In the streaming response section, add headers:
|
|
121
|
-
|
|
122
|
-
```javascript
|
|
123
|
-
// After res.setHeader("Content-Type", "text/event-stream");
|
|
124
|
-
res.setHeader("X-Lynkr-Provider", providerType);
|
|
125
|
-
res.setHeader("X-Lynkr-Client-Detected", clientType);
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
**File**: `src/api/openai-router.js` (in /v1/responses endpoint)
|
|
129
|
-
|
|
130
|
-
In the response.completed event, add metadata:
|
|
131
|
-
|
|
132
|
-
```javascript
|
|
133
|
-
const completedEvent = {
|
|
134
|
-
type: "response.completed",
|
|
135
|
-
response: {
|
|
136
|
-
id: responseId,
|
|
137
|
-
object: "response",
|
|
138
|
-
status: "completed",
|
|
139
|
-
// ... existing fields
|
|
140
|
-
|
|
141
|
-
// NEW: Add provider metadata
|
|
142
|
-
_lynkr: {
|
|
143
|
-
provider: providerType,
|
|
144
|
-
client_detected: clientType,
|
|
145
|
-
model_actual: actualModelUsed
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
sequence_number: sequenceNumber++
|
|
149
|
-
};
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
### Phase 4: Hot Reload Support
|
|
155
|
-
|
|
156
|
-
**File**: `src/config/index.js`
|
|
157
|
-
|
|
158
|
-
```javascript
|
|
159
|
-
reloadConfig() {
|
|
160
|
-
// ... existing reload logic
|
|
161
|
-
|
|
162
|
-
// Add client provider map reload
|
|
163
|
-
this.clientProviderMap = parseClientProviderMap(process.env.CLIENT_PROVIDER_MAP);
|
|
164
|
-
this.clientProviderDefault = process.env.CLIENT_PROVIDER_DEFAULT || process.env.MODEL_PROVIDER;
|
|
165
|
-
|
|
166
|
-
logger.info({
|
|
167
|
-
clientProviderMap: this.clientProviderMap,
|
|
168
|
-
clientProviderDefault: this.clientProviderDefault
|
|
169
|
-
}, "Client provider mapping reloaded");
|
|
170
|
-
}
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
---
|
|
174
|
-
|
|
175
|
-
### Phase 5: Logging & Observability
|
|
176
|
-
|
|
177
|
-
**File**: `src/orchestrator/index.js`
|
|
178
|
-
|
|
179
|
-
Add logging for routing decisions:
|
|
180
|
-
|
|
181
|
-
```javascript
|
|
182
|
-
logger.info({
|
|
183
|
-
sessionId: session?.id,
|
|
184
|
-
clientType,
|
|
185
|
-
requestedModel: payload.model,
|
|
186
|
-
resolvedProvider: providerType,
|
|
187
|
-
headerOverride: headers?.["x-model-provider"],
|
|
188
|
-
configuredMapping: config.clientProviderMap[clientType]
|
|
189
|
-
}, "Model routing decision");
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## Files to Modify
|
|
195
|
-
|
|
196
|
-
| File | Changes |
|
|
197
|
-
|------|---------|
|
|
198
|
-
| `.env` | Add `CLIENT_PROVIDER_MAP`, `CLIENT_PROVIDER_DEFAULT` |
|
|
199
|
-
| `src/config/index.js` | Parse new config, add helper function, add to exports |
|
|
200
|
-
| `src/orchestrator/index.js` | Add `getProviderForClient()`, `detectClientType()`, use headers |
|
|
201
|
-
| `src/api/openai-router.js` | Add `X-Lynkr-Provider` response header, add `_lynkr` metadata |
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## Example Configuration
|
|
206
|
-
|
|
207
|
-
```bash
|
|
208
|
-
# .env
|
|
209
|
-
|
|
210
|
-
# Default provider (used if no client mapping matches)
|
|
211
|
-
MODEL_PROVIDER=azure-openai
|
|
212
|
-
CLIENT_PROVIDER_DEFAULT=azure-openai
|
|
213
|
-
|
|
214
|
-
# Per-client provider mapping
|
|
215
|
-
# Format: client1:provider1,client2:provider2,...
|
|
216
|
-
CLIENT_PROVIDER_MAP=claude-code:ollama,codex:azure-openai,cline:openrouter,kilo:zai,cursor:databricks
|
|
217
|
-
|
|
218
|
-
# Individual provider configs
|
|
219
|
-
OLLAMA_MODEL=qwen2.5-coder:7b
|
|
220
|
-
AZURE_OPENAI_DEPLOYMENT=gpt-4o
|
|
221
|
-
OPENROUTER_MODEL=anthropic/claude-3.5-sonnet
|
|
222
|
-
ZAI_MODEL=GLM-4.7
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
**Result**:
|
|
226
|
-
- Claude Code → Ollama (local, fast, free)
|
|
227
|
-
- Codex CLI → Azure OpenAI (GPT-4o/GPT-5)
|
|
228
|
-
- Cline → OpenRouter (Claude 3.5 Sonnet)
|
|
229
|
-
- Kilo Code → Z.AI (GLM-4.7, cheap)
|
|
230
|
-
- Cursor → Databricks (Claude via Databricks)
|
|
231
|
-
- Unknown → Azure OpenAI (default)
|
|
232
|
-
|
|
233
|
-
---
|
|
234
|
-
|
|
235
|
-
## Testing
|
|
236
|
-
|
|
237
|
-
1. Start server with new config
|
|
238
|
-
2. Make request from Claude Code → should route to Ollama
|
|
239
|
-
3. Check logs for "Model routing decision"
|
|
240
|
-
4. Check response header `X-Lynkr-Provider`
|
|
241
|
-
5. Make request from Codex → should route to Azure OpenAI
|
|
242
|
-
6. Test header override: `curl -H "X-Model-Provider: ollama" ...`
|
|
243
|
-
|
|
244
|
-
---
|
|
245
|
-
|
|
246
|
-
## Future Enhancements
|
|
247
|
-
|
|
248
|
-
1. **Per-Model Routing**: Route based on requested model name, not just client
|
|
249
|
-
2. **Cost-Based Routing**: Route to cheapest provider that supports the request
|
|
250
|
-
3. **Latency-Based Routing**: Route to fastest available provider
|
|
251
|
-
4. **Load Balancing**: Distribute across multiple providers
|
|
252
|
-
5. **UI Dashboard**: Visual config for routing rules
|
package/ROUTER_COMPARISON.md
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
# Comparison: claude-code-router vs Lynkr Proxy
|
|
2
|
-
|
|
3
|
-
## Architecture Differences
|
|
4
|
-
|
|
5
|
-
**claude-code-router:**
|
|
6
|
-
- **CLI-first design** - `ccr` commands for interactive model switching
|
|
7
|
-
- **Request interceptor** - Sits between Claude Code CLI and LLM providers
|
|
8
|
-
- **Transformer pipeline** - Middleware system for request/response modification
|
|
9
|
-
- **Built with Fastify** (web framework)
|
|
10
|
-
- **TypeScript + esbuild** compilation
|
|
11
|
-
- **Web UI** for configuration
|
|
12
|
-
|
|
13
|
-
**Lynkr:**
|
|
14
|
-
- **HTTP proxy server** - Express-based API endpoint
|
|
15
|
-
- **Provider abstraction** - Unified interface for 7+ providers
|
|
16
|
-
- **Long-term memory system** (Titans-inspired)
|
|
17
|
-
- **Built with Express** (web framework)
|
|
18
|
-
- **Pure JavaScript** (no compilation)
|
|
19
|
-
- **Token optimization focus** (6 optimization phases)
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Key Feature Comparison
|
|
24
|
-
|
|
25
|
-
| Feature | claude-code-router | Lynkr | Winner |
|
|
26
|
-
|---------|-------------------|-------|--------|
|
|
27
|
-
| **Dynamic Model Switching** | ✅ Runtime `/model` command | ❌ Static .env config | 🏆 Router |
|
|
28
|
-
| **Routing Logic** | ✅ Context-aware (think/background/long-context) | ❌ Simple provider fallback only | 🏆 Router |
|
|
29
|
-
| **Custom Router Scripts** | ✅ JavaScript-based routing rules | ❌ No custom routing | 🏆 Router |
|
|
30
|
-
| **Web UI** | ✅ `ccr ui` browser interface | ❌ No UI | 🏆 Router |
|
|
31
|
-
| **Long-Term Memory** | ❌ None | ✅ Vector search + surprise scoring | 🏆 Lynkr |
|
|
32
|
-
| **Token Optimization** | ⚠️ Basic (long-context detection) | ✅ 6 phases (smart tools, compression, etc.) | 🏆 Lynkr |
|
|
33
|
-
| **Smart Tool Selection** | ❌ None | ✅ Heuristic-based (just implemented) | 🏆 Lynkr |
|
|
34
|
-
| **History Compression** | ❌ None | ✅ Automatic + token budget enforcement | 🏆 Lynkr |
|
|
35
|
-
| **Prompt Caching** | ✅ Via transformer | ✅ Built-in | 🟰 Tie |
|
|
36
|
-
| **Provider Count** | 6 (OpenRouter, DeepSeek, Ollama, Gemini, etc.) | 7 (Databricks, Azure, OpenAI, OpenRouter, Ollama, llama.cpp) | 🟰 Tie |
|
|
37
|
-
| **Tool Enhancement** | ✅ `enhancetool` transformer | ❌ Basic passthrough | 🏆 Router |
|
|
38
|
-
| **GitHub Actions** | ✅ CI/CD integration | ❌ None | 🏆 Router |
|
|
39
|
-
| **Logging** | ✅ Rotating file logs | ✅ Pino logger | 🟰 Tie |
|
|
40
|
-
| **TypeScript** | ✅ Full TypeScript | ❌ JavaScript only | 🏆 Router |
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## Improvements for Lynkr (Ranked by Impact)
|
|
45
|
-
|
|
46
|
-
### 🔴 **Critical - High Impact, High Value**
|
|
47
|
-
|
|
48
|
-
#### 1. Dynamic Model Switching via `/model` Command
|
|
49
|
-
- **What**: Allow users to switch models mid-conversation without restarting server
|
|
50
|
-
- **Why**: Router's killer feature - flexibility without configuration edits
|
|
51
|
-
- **Implementation**: Add chat command parser, session-level model overrides
|
|
52
|
-
- **Effort**: Medium (2-3 days)
|
|
53
|
-
|
|
54
|
-
#### 2. Context-Aware Routing (Background/Think/Long-Context)
|
|
55
|
-
- **What**: Automatically route requests based on context type
|
|
56
|
-
- **Why**: Cost optimization + performance (cheap models for background, reasoning models for planning)
|
|
57
|
-
- **Example**:
|
|
58
|
-
- Background tasks → `gpt-4o-mini` ($0.15/1M)
|
|
59
|
-
- Planning/thinking → `o1-preview` (reasoning model)
|
|
60
|
-
- Long context (>60k tokens) → `claude-sonnet-4` (200k context)
|
|
61
|
-
- **Effort**: Medium (3-4 days)
|
|
62
|
-
|
|
63
|
-
#### 3. Custom Router Scripts (JavaScript-based)
|
|
64
|
-
- **What**: Let users define routing logic in JavaScript
|
|
65
|
-
- **Why**: Ultimate flexibility - enterprise users need custom rules
|
|
66
|
-
- **Example**:
|
|
67
|
-
```javascript
|
|
68
|
-
// router.js
|
|
69
|
-
module.exports = function(request) {
|
|
70
|
-
if (request.tools.length > 5) return 'gpt-4o'; // Complex task
|
|
71
|
-
if (request.content.includes('urgent')) return 'databricks'; // Fast provider
|
|
72
|
-
return 'openrouter/nova-lite'; // Default cheap
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
- **Effort**: High (5-7 days)
|
|
76
|
-
|
|
77
|
-
#### 4. Web UI for Configuration
|
|
78
|
-
- **What**: Browser-based interface at `http://localhost:8081/ui`
|
|
79
|
-
- **Why**: Non-technical users can't edit .env files
|
|
80
|
-
- **Features**: Model selection, provider config, logs viewer, cost tracking
|
|
81
|
-
- **Effort**: High (7-10 days)
|
|
82
|
-
|
|
83
|
-
### 🟡 **High Impact, Medium Complexity**
|
|
84
|
-
|
|
85
|
-
#### 5. Tool Enhancement Transformer
|
|
86
|
-
- **What**: Add error tolerance and response buffering to tool calls
|
|
87
|
-
- **Why**: Prevents cascade failures when tools return malformed JSON
|
|
88
|
-
- **Example**: Retry tool calls with exponential backoff, validate tool outputs
|
|
89
|
-
- **Effort**: Low (1-2 days)
|
|
90
|
-
|
|
91
|
-
#### 6. Request/Response Transformer Pipeline
|
|
92
|
-
- **What**: Middleware system to modify requests/responses per provider
|
|
93
|
-
- **Why**: Provider-specific quirks (Azure needs different format, Ollama strips thinking blocks)
|
|
94
|
-
- **Current**: Hardcoded in client adapters
|
|
95
|
-
- **Improved**: Pluggable transformer chain
|
|
96
|
-
- **Effort**: Medium (3-4 days)
|
|
97
|
-
|
|
98
|
-
#### 7. Token-Based Auto-Routing
|
|
99
|
-
- **What**: Switch to high-context models when input exceeds threshold
|
|
100
|
-
- **Why**: Prevent truncation errors, automatic upgrade
|
|
101
|
-
- **Example**: Request >100k tokens → auto-switch from `gpt-4o` (128k) to `claude-sonnet-4` (200k)
|
|
102
|
-
- **Effort**: Low (1-2 days) - you already have token counting
|
|
103
|
-
|
|
104
|
-
### 🟢 **Nice to Have - Lower Priority**
|
|
105
|
-
|
|
106
|
-
#### 8. GitHub Actions Integration
|
|
107
|
-
- **What**: Trigger Claude Code workflows in CI/CD
|
|
108
|
-
- **Why**: Automated code reviews, documentation generation
|
|
109
|
-
- **Use Case**: PR opens → Claude reviews code → posts comments
|
|
110
|
-
- **Effort**: Medium (3-4 days)
|
|
111
|
-
|
|
112
|
-
#### 9. CLI Commands (`lynkr model`, `lynkr ui`)
|
|
113
|
-
- **What**: Interactive terminal commands for management
|
|
114
|
-
- **Why**: Better DX than editing .env and restarting
|
|
115
|
-
- **Effort**: Medium (2-3 days)
|
|
116
|
-
|
|
117
|
-
#### 10. Rotating File Logs
|
|
118
|
-
- **What**: Auto-rotate logs by size/date (keep last 7 days)
|
|
119
|
-
- **Why**: Prevent disk bloat in production
|
|
120
|
-
- **Current**: Pino logs to stdout only
|
|
121
|
-
- **Effort**: Low (1 day) - use `pino-rotating-file-stream`
|
|
122
|
-
|
|
123
|
-
#### 11. LRU Caching for Responses
|
|
124
|
-
- **What**: Cache identical requests for X minutes
|
|
125
|
-
- **Why**: Save money on repeated queries
|
|
126
|
-
- **Example**: User asks "what is 2+2?" 3 times → only 1 LLM call
|
|
127
|
-
- **Effort**: Low (1-2 days)
|
|
128
|
-
|
|
129
|
-
#### 12. TypeScript Migration
|
|
130
|
-
- **What**: Convert codebase to TypeScript
|
|
131
|
-
- **Why**: Type safety, better IDE support, fewer runtime errors
|
|
132
|
-
- **Effort**: Very High (15-20 days) - 87 files to convert
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
## Unique Strengths of Lynkr (Don't Lose These!)
|
|
137
|
-
|
|
138
|
-
1. **Long-term memory system** - Router doesn't have this
|
|
139
|
-
2. **Smart tool selection** - Just implemented, very valuable
|
|
140
|
-
3. **6-phase token optimization** - Industry-leading
|
|
141
|
-
4. **History compression** - Automatic context management
|
|
142
|
-
5. **7 providers** - Broader support than Router
|
|
143
|
-
6. **Hybrid routing** - Ollama + cloud fallback
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## Recommended Implementation Order
|
|
148
|
-
|
|
149
|
-
### Phase 1: Quick Wins (1-2 weeks)
|
|
150
|
-
1. Token-based auto-routing
|
|
151
|
-
2. Tool enhancement transformer
|
|
152
|
-
3. Rotating file logs
|
|
153
|
-
4. LRU caching
|
|
154
|
-
|
|
155
|
-
### Phase 2: Game Changers (3-4 weeks)
|
|
156
|
-
5. Dynamic model switching via `/model` command
|
|
157
|
-
6. Context-aware routing (background/think/long-context)
|
|
158
|
-
7. Request/Response transformer pipeline
|
|
159
|
-
|
|
160
|
-
### Phase 3: Enterprise Features (4-6 weeks)
|
|
161
|
-
8. Custom router scripts
|
|
162
|
-
9. Web UI
|
|
163
|
-
10. CLI commands
|
|
164
|
-
11. GitHub Actions integration
|
|
165
|
-
|
|
166
|
-
### Phase 4: Long-Term (Optional)
|
|
167
|
-
12. TypeScript migration
|
|
168
|
-
|
|
169
|
-
---
|
|
170
|
-
|
|
171
|
-
## Bottom Line
|
|
172
|
-
|
|
173
|
-
Router excels at **flexibility and user experience** (dynamic switching, routing logic, Web UI). Lynkr excels at **optimization and intelligence** (memory, token optimization, smart tools). Merging the best of both would create the ultimate Claude Code proxy.
|