lynkr 7.2.5 → 8.0.0
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 +2 -2
- package/config/model-tiers.json +89 -0
- package/docs/docs.html +1 -0
- package/docs/index.md +7 -0
- package/docs/toon-integration-spec.md +130 -0
- package/documentation/README.md +3 -2
- package/documentation/claude-code-cli.md +23 -16
- package/documentation/cursor-integration.md +17 -14
- package/documentation/docker.md +11 -4
- package/documentation/embeddings.md +7 -5
- package/documentation/faq.md +66 -12
- package/documentation/features.md +22 -15
- package/documentation/installation.md +66 -14
- package/documentation/production.md +43 -8
- package/documentation/providers.md +145 -42
- package/documentation/routing.md +476 -0
- package/documentation/token-optimization.md +7 -5
- package/documentation/troubleshooting.md +81 -5
- 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 +130 -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 +76 -3
- package/src/config/index.js +113 -35
- package/src/context/toon.js +173 -0
- package/src/logger/index.js +23 -0
- package/src/orchestrator/index.js +686 -211
- 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 +2 -2
- 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 +15 -2
- package/te +11622 -0
- package/test/README.md +1 -1
- package/test/azure-openai-config.test.js +17 -8
- package/test/azure-openai-integration.test.js +7 -1
- package/test/azure-openai-routing.test.js +41 -43
- package/test/bedrock-integration.test.js +18 -32
- package/test/hybrid-routing-integration.test.js +35 -20
- package/test/hybrid-routing-performance.test.js +74 -64
- package/test/llamacpp-integration.test.js +28 -9
- package/test/lmstudio-integration.test.js +20 -8
- package/test/openai-integration.test.js +17 -20
- package/test/performance-tests.js +1 -1
- package/test/routing.test.js +65 -59
- package/test/toon-compression.test.js +131 -0
- package/CLAWROUTER_ROUTING_PLAN.md +0 -910
- package/ROUTER_COMPARISON.md +0 -173
- package/TIER_ROUTING_PLAN.md +0 -771
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.
|