lynkr 9.4.5 → 9.4.6
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/package.json +1 -1
- package/src/dashboard/api.js +49 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lynkr",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.6",
|
|
4
4
|
"description": "Self-hosted LLM gateway and tier-routing proxy for Claude Code, Cursor, and Codex. Routes across Ollama, AWS Bedrock, OpenRouter, Databricks, Azure OpenAI, llama.cpp, and LM Studio with prompt caching, MCP tools, and 60-80% cost savings.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
package/src/dashboard/api.js
CHANGED
|
@@ -112,59 +112,69 @@ function overview(req, res) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
function usage(req, res) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
try {
|
|
116
|
+
const window = req.query.window || '7d';
|
|
117
|
+
const provider = req.query.provider || undefined;
|
|
118
|
+
const model = req.query.model || undefined;
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
const data = getUsage({ window, provider, model });
|
|
120
121
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
: telemetry.query({ limit: 50000 });
|
|
122
|
+
const days = window === '1d' ? 1 : window === '30d' ? 30 : 7;
|
|
123
|
+
const since = window === 'all' ? 0 : Date.now() - days * 86400000;
|
|
124
|
+
const rawRows = since > 0
|
|
125
|
+
? telemetry.query({ since, limit: 50000 })
|
|
126
|
+
: telemetry.query({ limit: 50000 });
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
data.daily = dailyBreakdown(rawRows, Math.min(days, 30));
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
res.json(data);
|
|
131
|
+
} catch (e) {
|
|
132
|
+
res.status(500).json({ error: 'usage_api_error', detail: e.message });
|
|
133
|
+
}
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
function routing(req, res) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
137
|
+
try {
|
|
138
|
+
const win = findActiveWindow();
|
|
139
|
+
const { since } = win;
|
|
140
|
+
|
|
141
|
+
const accuracy = telemetry.getRoutingAccuracy({ since });
|
|
142
|
+
const stats = telemetry.getStats({ since });
|
|
143
|
+
const cbStates = getCircuitBreakerStates();
|
|
144
|
+
|
|
145
|
+
const dbRows = telemetry.query({ limit: 100000, since });
|
|
146
|
+
const dbProviders = [...new Set(
|
|
147
|
+
dbRows.map(r => r.provider).filter(p => p && !TEST_PROVIDER_RE.test(p))
|
|
148
|
+
)];
|
|
149
|
+
|
|
150
|
+
const providerStats = {};
|
|
151
|
+
for (const p of dbProviders) {
|
|
152
|
+
const s = telemetry.getProviderStats(p, { since });
|
|
153
|
+
if (s) providerStats[p] = s;
|
|
154
|
+
}
|
|
152
155
|
|
|
153
|
-
|
|
156
|
+
res.json({ tierDefinitions: TIER_DEFINITIONS, accuracy, stats, providerStats, circuitBreakers: cbStates, window: win.label });
|
|
157
|
+
} catch (e) {
|
|
158
|
+
res.status(500).json({ error: 'routing_api_error', detail: e.message });
|
|
159
|
+
}
|
|
154
160
|
}
|
|
155
161
|
|
|
156
162
|
function logs(req, res) {
|
|
157
|
-
|
|
158
|
-
|
|
163
|
+
try {
|
|
164
|
+
const limit = Math.min(parseInt(req.query.limit || '100', 10), 500);
|
|
165
|
+
const filters = { limit };
|
|
159
166
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
167
|
+
if (req.query.provider) filters.provider = req.query.provider;
|
|
168
|
+
if (req.query.tier) filters.tier = req.query.tier;
|
|
169
|
+
if (req.query.since) filters.since = parseInt(req.query.since, 10);
|
|
163
170
|
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
let rows = telemetry.query(filters);
|
|
172
|
+
if (req.query.error === 'true') rows = rows.filter(r => r.error_type);
|
|
166
173
|
|
|
167
|
-
|
|
174
|
+
res.json(rows);
|
|
175
|
+
} catch (e) {
|
|
176
|
+
res.status(500).json({ error: 'logs_api_error', detail: e.message });
|
|
177
|
+
}
|
|
168
178
|
}
|
|
169
179
|
|
|
170
180
|
module.exports = { overview, usage, routing, logs };
|