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
package/src/api/router.js
CHANGED
|
@@ -2,10 +2,11 @@ const express = require("express");
|
|
|
2
2
|
const { processMessage } = require("../orchestrator");
|
|
3
3
|
const { getSession } = require("../sessions");
|
|
4
4
|
const metrics = require("../metrics");
|
|
5
|
+
const logger = require("../logger");
|
|
5
6
|
const { createRateLimiter } = require("./middleware/rate-limiter");
|
|
6
7
|
const openaiRouter = require("./openai-router");
|
|
7
8
|
const providersRouter = require("./providers-handler");
|
|
8
|
-
const { getRoutingHeaders, getRoutingStats, analyzeComplexity } = require("../routing");
|
|
9
|
+
const { getRoutingHeaders, getRoutingStats, analyzeComplexity, getModelTierSelector } = require("../routing");
|
|
9
10
|
const { validateCwd } = require("../workspace");
|
|
10
11
|
|
|
11
12
|
const router = express.Router();
|
|
@@ -71,6 +72,99 @@ router.get("/routing/stats", (req, res) => {
|
|
|
71
72
|
});
|
|
72
73
|
});
|
|
73
74
|
|
|
75
|
+
// Model registry info (from LiteLLM + models.dev APIs)
|
|
76
|
+
router.get("/routing/models", async (req, res) => {
|
|
77
|
+
try {
|
|
78
|
+
const { getModelRegistry } = require("../routing/model-registry");
|
|
79
|
+
const registry = await getModelRegistry();
|
|
80
|
+
res.json({
|
|
81
|
+
status: "ok",
|
|
82
|
+
...registry.getStats(),
|
|
83
|
+
});
|
|
84
|
+
} catch (err) {
|
|
85
|
+
res.status(500).json({ error: err.message });
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Get specific model info
|
|
90
|
+
router.get("/routing/models/:model", async (req, res) => {
|
|
91
|
+
try {
|
|
92
|
+
const { getModelRegistry } = require("../routing/model-registry");
|
|
93
|
+
const registry = await getModelRegistry();
|
|
94
|
+
const model = registry.getModel(req.params.model);
|
|
95
|
+
if (!model || model.source === "default") {
|
|
96
|
+
return res.status(404).json({ error: "Model not found", model: req.params.model });
|
|
97
|
+
}
|
|
98
|
+
res.json({ status: "ok", model: req.params.model, ...model });
|
|
99
|
+
} catch (err) {
|
|
100
|
+
res.status(500).json({ error: err.message });
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Routing tier information
|
|
105
|
+
router.get("/routing/tiers", (req, res) => {
|
|
106
|
+
try {
|
|
107
|
+
const { getModelTierSelector } = require("../routing/model-tiers");
|
|
108
|
+
const selector = getModelTierSelector();
|
|
109
|
+
res.json({
|
|
110
|
+
status: "ok",
|
|
111
|
+
...selector.getTierStats(),
|
|
112
|
+
});
|
|
113
|
+
} catch (err) {
|
|
114
|
+
res.status(500).json({ error: err.message });
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Cost optimization stats
|
|
119
|
+
router.get("/metrics/cost-optimization", (req, res) => {
|
|
120
|
+
try {
|
|
121
|
+
const { getCostOptimizer } = require("../routing/cost-optimizer");
|
|
122
|
+
const optimizer = getCostOptimizer();
|
|
123
|
+
res.json({
|
|
124
|
+
status: "ok",
|
|
125
|
+
...optimizer.getStats(),
|
|
126
|
+
});
|
|
127
|
+
} catch (err) {
|
|
128
|
+
res.status(500).json({ error: err.message });
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Request analysis test endpoint
|
|
133
|
+
router.post("/routing/analyze", async (req, res) => {
|
|
134
|
+
try {
|
|
135
|
+
const { getAgenticDetector } = require("../routing/agentic-detector");
|
|
136
|
+
const { getModelTierSelector } = require("../routing/model-tiers");
|
|
137
|
+
const { getModelRegistry } = require("../routing/model-registry");
|
|
138
|
+
|
|
139
|
+
const analysis = analyzeComplexity(req.body, { weighted: req.query.weighted === "true" });
|
|
140
|
+
const agentic = getAgenticDetector().detect(req.body);
|
|
141
|
+
const selector = getModelTierSelector();
|
|
142
|
+
const tier = selector.getTier(analysis.score);
|
|
143
|
+
|
|
144
|
+
// Get recommended model for tier
|
|
145
|
+
const provider = req.query.provider || "openai";
|
|
146
|
+
const modelSelection = selector.selectModel(tier, provider);
|
|
147
|
+
|
|
148
|
+
// Get model cost info
|
|
149
|
+
let modelInfo = null;
|
|
150
|
+
if (modelSelection.model) {
|
|
151
|
+
const registry = await getModelRegistry();
|
|
152
|
+
modelInfo = registry.getCost(modelSelection.model);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
res.json({
|
|
156
|
+
status: "ok",
|
|
157
|
+
analysis,
|
|
158
|
+
agentic,
|
|
159
|
+
tier,
|
|
160
|
+
modelSelection,
|
|
161
|
+
modelInfo,
|
|
162
|
+
});
|
|
163
|
+
} catch (err) {
|
|
164
|
+
res.status(500).json({ error: err.message });
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
74
168
|
router.get("/debug/session", (req, res) => {
|
|
75
169
|
if (!req.sessionId) {
|
|
76
170
|
return res.status(400).json({ error: "missing_session_id", message: "Provide x-session-id header" });
|
|
@@ -123,8 +217,19 @@ router.post("/v1/messages", rateLimiter, async (req, res, next) => {
|
|
|
123
217
|
|
|
124
218
|
// Analyze complexity for routing headers (Phase 3)
|
|
125
219
|
const complexity = analyzeComplexity(req.body);
|
|
220
|
+
let preRouteProvider = 'cloud';
|
|
221
|
+
if (complexity.recommendation === 'local') {
|
|
222
|
+
// Use tier config to determine actual provider instead of hardcoding 'ollama'
|
|
223
|
+
try {
|
|
224
|
+
const selector = getModelTierSelector();
|
|
225
|
+
const tierResult = selector.selectModel('SIMPLE', null);
|
|
226
|
+
preRouteProvider = tierResult.provider;
|
|
227
|
+
} catch (_) {
|
|
228
|
+
preRouteProvider = 'ollama';
|
|
229
|
+
}
|
|
230
|
+
}
|
|
126
231
|
const routingHeaders = getRoutingHeaders({
|
|
127
|
-
provider:
|
|
232
|
+
provider: preRouteProvider,
|
|
128
233
|
score: complexity.score,
|
|
129
234
|
threshold: complexity.threshold,
|
|
130
235
|
method: 'complexity',
|
package/src/budget/index.js
CHANGED
|
@@ -11,13 +11,14 @@ const logger = require('../logger');
|
|
|
11
11
|
class BudgetManager {
|
|
12
12
|
constructor(options = {}) {
|
|
13
13
|
this.enabled = options.enabled !== false;
|
|
14
|
+
let dbPath = null;
|
|
14
15
|
if (!this.enabled || !Database) {
|
|
15
16
|
this.enabled = false;
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
try {
|
|
20
|
-
|
|
21
|
+
dbPath = path.join(process.cwd(), 'data', 'budgets.db');
|
|
21
22
|
const dbDir = path.dirname(dbPath);
|
|
22
23
|
|
|
23
24
|
if (!fs.existsSync(dbDir)) {
|
|
@@ -25,14 +26,14 @@ class BudgetManager {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
this.db = new Database(dbPath);
|
|
29
|
+
this.dbPath = dbPath;
|
|
28
30
|
this.initDatabase();
|
|
31
|
+
logger.info({ dbPath }, 'Budget manager initialized');
|
|
29
32
|
} catch (err) {
|
|
30
33
|
logger.warn({ err: err.message }, "BudgetManager: better-sqlite3 not available");
|
|
31
34
|
this.enabled = false;
|
|
32
35
|
return;
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
logger.info({ dbPath }, 'Budget manager initialized');
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
initDatabase() {
|