@ultrst-armada/kloks 1.14.0 → 1.15.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/.krusbl-release-attestation.json +3 -3
- package/package.json +1 -1
- package/packages/backend/dist/ai-keys/index.d.ts +14 -1
- package/packages/backend/dist/ai-keys/index.js +1 -1
- package/packages/backend/dist/ai-models/index.d.ts +14 -1
- package/packages/backend/dist/ai-models/index.js +6 -8
- package/packages/backend/dist/ai-routing/index.d.ts +14 -0
- package/packages/backend/dist/ai-routing/index.js +3 -2
- package/packages/backend/dist/ai-tools/index.d.ts +2 -0
- package/packages/backend/dist/ai-tools/index.js +1 -1
- package/packages/backend/dist/{chunk-XGPL43T3.js → chunk-6YBBOHHG.js} +6 -6
- package/packages/backend/dist/{chunk-MSCOKLAO.js → chunk-AQT3GIXB.js} +30 -1
- package/packages/backend/dist/{chunk-MFM2QIY5.js → chunk-F4J4YPUR.js} +122 -2
- package/packages/backend/dist/{chunk-4GWYTYDQ.js → chunk-HXFTSHCP.js} +87 -24
- package/packages/backend/dist/{chunk-NSKVYL74.js → chunk-U4HUGPRH.js} +20 -0
- package/packages/backend/dist/chunk-UU6M3L3O.js +0 -0
- package/packages/backend/dist/index.js +48 -51
- package/packages/backend/dist/krnl-ai-services.js +5 -6
- package/packages/backend/dist/krnl-services.js +3 -3
- package/packages/backend/dist/services/index.js +1 -1
- package/packages/backend/dist/workspace/index.js +2 -2
- package/packages/state-graph/dist/index.js +15 -15
- package/packages/backend/dist/chunk-2WT7OUHW.js +0 -51
- package/packages/backend/dist/chunk-Z3LXEA6P.js +0 -45
- package/packages/backend/dist/{chunk-EIYYESEU.js → chunk-BTMIK44G.js} +3 -3
- package/packages/backend/dist/{chunk-D6ZGQFWQ.js → chunk-T26VJ22Y.js} +4 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"packageName": "@ultrst-armada/kloks",
|
|
4
|
-
"version": "1.
|
|
5
|
-
"sourceCommit": "
|
|
4
|
+
"version": "1.15.0",
|
|
5
|
+
"sourceCommit": "2604c1adbf1158c1223ace47e278a654082c4fad",
|
|
6
6
|
"releaseWorkflow": "npm Release",
|
|
7
|
-
"workflowRunId": "
|
|
7
|
+
"workflowRunId": "40836063403"
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -74,13 +74,26 @@ declare const keysStorage: KeysStorage;
|
|
|
74
74
|
declare class KeyStoreService {
|
|
75
75
|
private strategy;
|
|
76
76
|
private roundRobinIndices;
|
|
77
|
+
private forcedNextKeys;
|
|
78
|
+
private permanentKeys;
|
|
77
79
|
getKeys(providerId?: ProviderId): ApiKeyEntry[];
|
|
78
80
|
getKey(id: string): ApiKeyEntry | undefined;
|
|
79
81
|
getActiveKey(providerId: ProviderId): ApiKeyEntry | undefined;
|
|
80
82
|
setStrategy(strategy: RotationStrategy): void;
|
|
81
83
|
getStrategy(): RotationStrategy;
|
|
82
|
-
addKey(entry:
|
|
84
|
+
addKey(entry: Partial<ApiKeyEntry> & Pick<ApiKeyEntry, 'providerId' | 'label' | 'key'>): ApiKeyEntry;
|
|
85
|
+
getPermanentKey(providerId: ProviderId): string | null;
|
|
86
|
+
getPermanentKeysMap(): Record<string, string>;
|
|
87
|
+
setPermanentKey(providerId: ProviderId, keyId: string | null): void;
|
|
88
|
+
setForcedNextKey(providerId: ProviderId, keyId: string): void;
|
|
89
|
+
peekNextKey(providerId: ProviderId, _modelId?: string): ApiKeyEntry | null;
|
|
90
|
+
getNextKey(providerId: ProviderId, modelId?: string): ApiKeyEntry | null;
|
|
83
91
|
selectNextKey(providerId: ProviderId, _modelId?: string): ApiKeyEntry | undefined;
|
|
92
|
+
updateKeyLabel(id: string, label: string): ApiKeyEntry | undefined;
|
|
93
|
+
deleteKey(id: string): boolean;
|
|
94
|
+
resetKeyProbabilities(id: string): ApiKeyEntry | undefined;
|
|
95
|
+
resetAllFailures(): void;
|
|
96
|
+
getUsageStats(_keyId?: string, _modelId?: string): KeyModelUsageStats[];
|
|
84
97
|
updateKeyStatus(id: string, status: ApiKeyEntry['status']): void;
|
|
85
98
|
recordUsage(keyId: string, successOrLatency: boolean | number, latencyOrSuccess: boolean | number, _costUsd?: number, _modelId?: string, error?: string): void;
|
|
86
99
|
exportKeysStructured(): {
|
|
@@ -20,7 +20,8 @@ interface ModelCatalogEntry {
|
|
|
20
20
|
latencyRatingMs?: number;
|
|
21
21
|
qualityRating?: number;
|
|
22
22
|
maxOutputTokens?: number;
|
|
23
|
-
status?: 'active' | 'deprecated' | 'offline';
|
|
23
|
+
status?: 'active' | 'deprecated' | 'offline' | 'online' | 'currently_unavailable';
|
|
24
|
+
runtimeStats?: Record<string, any>;
|
|
24
25
|
description?: string;
|
|
25
26
|
}
|
|
26
27
|
interface ModelHealthStatus {
|
|
@@ -73,7 +74,19 @@ declare const modelHealthService: ModelHealthService;
|
|
|
73
74
|
*/
|
|
74
75
|
|
|
75
76
|
declare class ModelCatalogService {
|
|
77
|
+
private providerStatuses;
|
|
76
78
|
private customModels;
|
|
79
|
+
getCatalog(providerId?: ProviderId): ModelCatalogEntry[];
|
|
80
|
+
getProviderStatuses(): Array<{
|
|
81
|
+
providerId: ProviderId;
|
|
82
|
+
status: string;
|
|
83
|
+
modelsCount: number;
|
|
84
|
+
error?: string;
|
|
85
|
+
}>;
|
|
86
|
+
refreshCatalogFromEndpoints(): Promise<{
|
|
87
|
+
updated: number;
|
|
88
|
+
errors: string[];
|
|
89
|
+
}>;
|
|
77
90
|
getAllModels(): ModelCatalogEntry[];
|
|
78
91
|
getModelsByProvider(providerId: ProviderId): ModelCatalogEntry[];
|
|
79
92
|
getModelById(id: string): ModelCatalogEntry | undefined;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
import "../chunk-UU6M3L3O.js";
|
|
1
2
|
import {
|
|
2
3
|
EndpointRefresher,
|
|
3
|
-
endpointRefresher
|
|
4
|
-
} from "../chunk-2WT7OUHW.js";
|
|
5
|
-
import {
|
|
6
4
|
ModelCatalogService,
|
|
7
|
-
STATIC_MODELS_CATALOG,
|
|
8
|
-
modelCatalog
|
|
9
|
-
} from "../chunk-MFM2QIY5.js";
|
|
10
|
-
import {
|
|
11
5
|
ModelHealthService,
|
|
6
|
+
STATIC_MODELS_CATALOG,
|
|
7
|
+
endpointRefresher,
|
|
8
|
+
modelCatalog,
|
|
12
9
|
modelHealthService
|
|
13
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-F4J4YPUR.js";
|
|
11
|
+
import "../chunk-HXFTSHCP.js";
|
|
14
12
|
import "../chunk-MAMK4GDH.js";
|
|
15
13
|
import "../chunk-JSQZAFBU.js";
|
|
16
14
|
export {
|
|
@@ -69,6 +69,13 @@ declare class MetricsLogger {
|
|
|
69
69
|
toolCalls?: unknown;
|
|
70
70
|
toolsProvided?: unknown;
|
|
71
71
|
}): void;
|
|
72
|
+
getLogs(limit?: number): AIMetricRecord[];
|
|
73
|
+
getMetricsSummary(): {
|
|
74
|
+
totalRequests: number;
|
|
75
|
+
successRatePercent: number;
|
|
76
|
+
averageLatencyMs: number;
|
|
77
|
+
totalFailovers: number;
|
|
78
|
+
};
|
|
72
79
|
log(record: Omit<AIMetricRecord, 'id' | 'timestamp'>): void;
|
|
73
80
|
getRecent(limit?: number): AIMetricRecord[];
|
|
74
81
|
getAverageLatency(providerId: ProviderId, modelId?: string): number;
|
|
@@ -82,6 +89,13 @@ declare const metricsLogger: MetricsLogger;
|
|
|
82
89
|
*/
|
|
83
90
|
|
|
84
91
|
declare class HealthCheckService {
|
|
92
|
+
runRoutineCheck(): Promise<{
|
|
93
|
+
timestamp: string;
|
|
94
|
+
keysTotal: number;
|
|
95
|
+
keysValid: number;
|
|
96
|
+
modelsCatalogTotal: number;
|
|
97
|
+
status: 'healthy';
|
|
98
|
+
}>;
|
|
85
99
|
checkProvider(providerId: ProviderId, apiKey?: string): Promise<boolean>;
|
|
86
100
|
isRouteAvailable(providerId: ProviderId, modelId: string): boolean;
|
|
87
101
|
recordRouteFailure(providerId: ProviderId, modelId: string, error: string): void;
|
|
@@ -6,8 +6,9 @@ import {
|
|
|
6
6
|
failoverExecutionEngine,
|
|
7
7
|
healthCheckService,
|
|
8
8
|
metricsLogger
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-AQT3GIXB.js";
|
|
10
|
+
import "../chunk-F4J4YPUR.js";
|
|
11
|
+
import "../chunk-HXFTSHCP.js";
|
|
11
12
|
import "../chunk-SLR6SIEU.js";
|
|
12
13
|
import "../chunk-MAMK4GDH.js";
|
|
13
14
|
import "../chunk-JSQZAFBU.js";
|
|
@@ -45,6 +45,8 @@ declare class MCPEngine {
|
|
|
45
45
|
private servers;
|
|
46
46
|
private registeredTools;
|
|
47
47
|
private toolHandlers;
|
|
48
|
+
getSystemTools(): MCPTool[];
|
|
49
|
+
handleJsonRpc(payload: any): Promise<any>;
|
|
48
50
|
registerServer(config: MCPServerConfig): void;
|
|
49
51
|
getServer(id: string): MCPServerConfig | undefined;
|
|
50
52
|
listServers(): MCPServerConfig[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
toolManagerService
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-U4HUGPRH.js";
|
|
4
4
|
import {
|
|
5
5
|
createService,
|
|
6
6
|
createServiceDefinition
|
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
inferenceExecutor
|
|
10
10
|
} from "./chunk-GCTQY24J.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
12
|
+
failoverExecutionEngine
|
|
13
|
+
} from "./chunk-AQT3GIXB.js";
|
|
14
14
|
import {
|
|
15
15
|
modelCatalog
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-F4J4YPUR.js";
|
|
17
17
|
import {
|
|
18
|
-
|
|
19
|
-
} from "./chunk-
|
|
18
|
+
keyStore
|
|
19
|
+
} from "./chunk-HXFTSHCP.js";
|
|
20
20
|
import {
|
|
21
21
|
aiProviderService
|
|
22
22
|
} from "./chunk-SLR6SIEU.js";
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
modelCatalog,
|
|
2
3
|
modelHealthService
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-F4J4YPUR.js";
|
|
5
|
+
import {
|
|
6
|
+
keyStore
|
|
7
|
+
} from "./chunk-HXFTSHCP.js";
|
|
4
8
|
import {
|
|
5
9
|
aiProviderService
|
|
6
10
|
} from "./chunk-SLR6SIEU.js";
|
|
@@ -17,6 +21,20 @@ var MetricsLogger = class {
|
|
|
17
21
|
success: record.status !== "failure"
|
|
18
22
|
});
|
|
19
23
|
}
|
|
24
|
+
getLogs(limit = 50) {
|
|
25
|
+
return this.records.slice(-limit);
|
|
26
|
+
}
|
|
27
|
+
getMetricsSummary() {
|
|
28
|
+
const totalRequests = this.records.length;
|
|
29
|
+
const successes = this.records.filter((record) => record.success).length;
|
|
30
|
+
const averageLatencyMs = totalRequests ? Math.round(this.records.reduce((sum, record) => sum + record.durationMs, 0) / totalRequests) : 0;
|
|
31
|
+
return {
|
|
32
|
+
totalRequests,
|
|
33
|
+
successRatePercent: totalRequests ? Math.round(successes / totalRequests * 100) : 100,
|
|
34
|
+
averageLatencyMs,
|
|
35
|
+
totalFailovers: 0
|
|
36
|
+
};
|
|
37
|
+
}
|
|
20
38
|
log(record) {
|
|
21
39
|
const full = {
|
|
22
40
|
id: `met_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`,
|
|
@@ -50,6 +68,17 @@ var metricsLogger = new MetricsLogger();
|
|
|
50
68
|
|
|
51
69
|
// src/ai-routing/healthCheckService.ts
|
|
52
70
|
var HealthCheckService = class {
|
|
71
|
+
async runRoutineCheck() {
|
|
72
|
+
const keys = keyStore.getKeys();
|
|
73
|
+
const catalog = modelCatalog.getAllModels();
|
|
74
|
+
return {
|
|
75
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
76
|
+
keysTotal: keys.length,
|
|
77
|
+
keysValid: keys.filter((key) => key.status === "active" || key.status === "valid").length,
|
|
78
|
+
modelsCatalogTotal: catalog.length,
|
|
79
|
+
status: "healthy"
|
|
80
|
+
};
|
|
81
|
+
}
|
|
53
82
|
async checkProvider(providerId, apiKey) {
|
|
54
83
|
const status = await aiProviderService.checkHealth(providerId, apiKey);
|
|
55
84
|
return status.isOnline;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
keyStore
|
|
3
|
+
} from "./chunk-HXFTSHCP.js";
|
|
4
|
+
import {
|
|
5
|
+
AITransportClient
|
|
6
|
+
} from "./chunk-MAMK4GDH.js";
|
|
7
|
+
import {
|
|
8
|
+
getProviderMeta
|
|
9
|
+
} from "./chunk-JSQZAFBU.js";
|
|
4
10
|
|
|
5
11
|
// src/ai-models/catalogData.ts
|
|
6
12
|
var STATIC_MODELS_CATALOG = [
|
|
@@ -126,9 +132,119 @@ var STATIC_MODELS_CATALOG = [
|
|
|
126
132
|
}
|
|
127
133
|
];
|
|
128
134
|
|
|
135
|
+
// src/ai-models/endpointRefresher.ts
|
|
136
|
+
var EndpointRefresher = class {
|
|
137
|
+
client;
|
|
138
|
+
constructor(client) {
|
|
139
|
+
this.client = client ?? new AITransportClient();
|
|
140
|
+
}
|
|
141
|
+
async fetchRemoteModels(providerId, apiKey) {
|
|
142
|
+
const meta = getProviderMeta(providerId);
|
|
143
|
+
if (!meta) throw new Error(`Unknown provider ${providerId}`);
|
|
144
|
+
const url = `${meta.baseUrl}${meta.modelsEndpoint}`;
|
|
145
|
+
const headers = {};
|
|
146
|
+
if (meta.defaultHeaderKey === "Authorization") {
|
|
147
|
+
headers["Authorization"] = `Bearer ${apiKey.trim()}`;
|
|
148
|
+
} else {
|
|
149
|
+
headers[meta.defaultHeaderKey] = apiKey.trim();
|
|
150
|
+
}
|
|
151
|
+
const res = await this.client.request({
|
|
152
|
+
url,
|
|
153
|
+
method: "GET",
|
|
154
|
+
headers,
|
|
155
|
+
timeoutMs: 12e3
|
|
156
|
+
});
|
|
157
|
+
if (!res.ok) {
|
|
158
|
+
throw new Error(`Failed to fetch models from ${providerId}: HTTP ${res.status}`);
|
|
159
|
+
}
|
|
160
|
+
const rawList = res.data.data || res.data.models || [];
|
|
161
|
+
return rawList.map((item) => ({
|
|
162
|
+
id: item.id || item.name || "",
|
|
163
|
+
name: item.display_name || item.name || item.id || "",
|
|
164
|
+
providerId,
|
|
165
|
+
contextWindow: item.context_window || item.input_token_limit || 131072,
|
|
166
|
+
supportsTools: true,
|
|
167
|
+
supportsVision: Boolean(item.architecture?.modality?.includes("image")),
|
|
168
|
+
supportsJson: true,
|
|
169
|
+
status: "active"
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var endpointRefresher = new EndpointRefresher();
|
|
174
|
+
|
|
175
|
+
// src/ai-models/modelHealthService.ts
|
|
176
|
+
var ModelHealthService = class {
|
|
177
|
+
healthMap = /* @__PURE__ */ new Map();
|
|
178
|
+
recordSuccess(providerId, modelId, latencyMs) {
|
|
179
|
+
const key = `${providerId}:${modelId}`;
|
|
180
|
+
this.healthMap.set(key, {
|
|
181
|
+
modelId,
|
|
182
|
+
providerId,
|
|
183
|
+
isHealthy: true,
|
|
184
|
+
latencyMs,
|
|
185
|
+
consecutiveFailures: 0,
|
|
186
|
+
lastCheckedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
recordFailure(providerId, modelId, error) {
|
|
190
|
+
const key = `${providerId}:${modelId}`;
|
|
191
|
+
const existing = this.healthMap.get(key);
|
|
192
|
+
const consecutive = (existing?.consecutiveFailures ?? 0) + 1;
|
|
193
|
+
this.healthMap.set(key, {
|
|
194
|
+
modelId,
|
|
195
|
+
providerId,
|
|
196
|
+
isHealthy: consecutive < 3,
|
|
197
|
+
latencyMs: existing?.latencyMs ?? 0,
|
|
198
|
+
consecutiveFailures: consecutive,
|
|
199
|
+
lastCheckedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
200
|
+
lastError: error
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
isModelAvailable(providerId, modelId) {
|
|
204
|
+
const status = this.healthMap.get(`${providerId}:${modelId}`);
|
|
205
|
+
return status ? status.isHealthy : true;
|
|
206
|
+
}
|
|
207
|
+
getHealth(providerId, modelId) {
|
|
208
|
+
return this.healthMap.get(`${providerId}:${modelId}`);
|
|
209
|
+
}
|
|
210
|
+
getAllHealth() {
|
|
211
|
+
return Array.from(this.healthMap.values());
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
var modelHealthService = new ModelHealthService();
|
|
215
|
+
|
|
129
216
|
// src/ai-models/modelCatalog.ts
|
|
130
217
|
var ModelCatalogService = class {
|
|
218
|
+
providerStatuses = {};
|
|
131
219
|
customModels = /* @__PURE__ */ new Map();
|
|
220
|
+
getCatalog(providerId) {
|
|
221
|
+
return providerId ? this.getAllModels().filter((model) => model.providerId === providerId) : this.getAllModels();
|
|
222
|
+
}
|
|
223
|
+
getProviderStatuses() {
|
|
224
|
+
const providers = new Set(this.getAllModels().map((model) => model.providerId));
|
|
225
|
+
for (const providerId of providers) {
|
|
226
|
+
const modelsCount = this.getModelsByProvider(providerId).length;
|
|
227
|
+
this.providerStatuses[providerId] ??= { providerId, status: "online", modelsCount };
|
|
228
|
+
this.providerStatuses[providerId].modelsCount = modelsCount;
|
|
229
|
+
}
|
|
230
|
+
return Object.values(this.providerStatuses);
|
|
231
|
+
}
|
|
232
|
+
async refreshCatalogFromEndpoints() {
|
|
233
|
+
const errors = [];
|
|
234
|
+
let updated = 0;
|
|
235
|
+
for (const providerId of Array.from(new Set(this.getAllModels().map((model) => model.providerId)))) {
|
|
236
|
+
const key = keyStore.getActiveKey(providerId);
|
|
237
|
+
if (!key) continue;
|
|
238
|
+
try {
|
|
239
|
+
const models = await endpointRefresher.fetchRemoteModels(providerId, key.key);
|
|
240
|
+
for (const model of models) this.registerModel(model);
|
|
241
|
+
updated += models.length;
|
|
242
|
+
} catch (error) {
|
|
243
|
+
errors.push(error instanceof Error ? error.message : String(error));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return { updated, errors };
|
|
247
|
+
}
|
|
132
248
|
getAllModels() {
|
|
133
249
|
const list = [...STATIC_MODELS_CATALOG, ...Array.from(this.customModels.values())];
|
|
134
250
|
return list;
|
|
@@ -168,6 +284,10 @@ var modelCatalog = new ModelCatalogService();
|
|
|
168
284
|
|
|
169
285
|
export {
|
|
170
286
|
STATIC_MODELS_CATALOG,
|
|
287
|
+
EndpointRefresher,
|
|
288
|
+
endpointRefresher,
|
|
289
|
+
ModelHealthService,
|
|
290
|
+
modelHealthService,
|
|
171
291
|
ModelCatalogService,
|
|
172
292
|
modelCatalog
|
|
173
293
|
};
|
|
@@ -2,6 +2,29 @@ import {
|
|
|
2
2
|
getProviderMeta
|
|
3
3
|
} from "./chunk-JSQZAFBU.js";
|
|
4
4
|
|
|
5
|
+
// src/ai-keys/keysStorage.ts
|
|
6
|
+
var KeysStorage = class {
|
|
7
|
+
inMemoryKeys = /* @__PURE__ */ new Map();
|
|
8
|
+
loadKeys() {
|
|
9
|
+
return Array.from(this.inMemoryKeys.values());
|
|
10
|
+
}
|
|
11
|
+
saveKey(entry) {
|
|
12
|
+
this.inMemoryKeys.set(entry.id, entry);
|
|
13
|
+
}
|
|
14
|
+
saveKeys(entries) {
|
|
15
|
+
for (const e of entries) {
|
|
16
|
+
this.inMemoryKeys.set(e.id, e);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
deleteKey(id) {
|
|
20
|
+
this.inMemoryKeys.delete(id);
|
|
21
|
+
}
|
|
22
|
+
clear() {
|
|
23
|
+
this.inMemoryKeys.clear();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var keysStorage = new KeysStorage();
|
|
27
|
+
|
|
5
28
|
// src/ai-keys/keyValidator.ts
|
|
6
29
|
async function validateApiKey(providerId, apiKey) {
|
|
7
30
|
const meta = getProviderMeta(providerId);
|
|
@@ -68,33 +91,12 @@ async function validateApiKey(providerId, apiKey) {
|
|
|
68
91
|
}
|
|
69
92
|
}
|
|
70
93
|
|
|
71
|
-
// src/ai-keys/keysStorage.ts
|
|
72
|
-
var KeysStorage = class {
|
|
73
|
-
inMemoryKeys = /* @__PURE__ */ new Map();
|
|
74
|
-
loadKeys() {
|
|
75
|
-
return Array.from(this.inMemoryKeys.values());
|
|
76
|
-
}
|
|
77
|
-
saveKey(entry) {
|
|
78
|
-
this.inMemoryKeys.set(entry.id, entry);
|
|
79
|
-
}
|
|
80
|
-
saveKeys(entries) {
|
|
81
|
-
for (const e of entries) {
|
|
82
|
-
this.inMemoryKeys.set(e.id, e);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
deleteKey(id) {
|
|
86
|
-
this.inMemoryKeys.delete(id);
|
|
87
|
-
}
|
|
88
|
-
clear() {
|
|
89
|
-
this.inMemoryKeys.clear();
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
var keysStorage = new KeysStorage();
|
|
93
|
-
|
|
94
94
|
// src/ai-keys/keyStore.ts
|
|
95
95
|
var KeyStoreService = class {
|
|
96
96
|
strategy = "lowest-latency";
|
|
97
97
|
roundRobinIndices = /* @__PURE__ */ new Map();
|
|
98
|
+
forcedNextKeys = /* @__PURE__ */ new Map();
|
|
99
|
+
permanentKeys = /* @__PURE__ */ new Map();
|
|
98
100
|
getKeys(providerId) {
|
|
99
101
|
const all = keysStorage.loadKeys();
|
|
100
102
|
if (!providerId) return all;
|
|
@@ -137,14 +139,75 @@ var KeyStoreService = class {
|
|
|
137
139
|
failedCalls: 0,
|
|
138
140
|
lastLatencyMs: 0,
|
|
139
141
|
errorCount: 0,
|
|
142
|
+
status: "active",
|
|
143
|
+
isActive: true,
|
|
144
|
+
remainingCreditsUsd: null,
|
|
145
|
+
weight: 5,
|
|
140
146
|
...entry
|
|
141
147
|
};
|
|
142
148
|
keysStorage.saveKey(full);
|
|
143
149
|
return full;
|
|
144
150
|
}
|
|
151
|
+
getPermanentKey(providerId) {
|
|
152
|
+
return this.permanentKeys.get(providerId) ?? null;
|
|
153
|
+
}
|
|
154
|
+
getPermanentKeysMap() {
|
|
155
|
+
return Object.fromEntries(this.permanentKeys.entries());
|
|
156
|
+
}
|
|
157
|
+
setPermanentKey(providerId, keyId) {
|
|
158
|
+
if (keyId) this.permanentKeys.set(providerId, keyId);
|
|
159
|
+
else this.permanentKeys.delete(providerId);
|
|
160
|
+
}
|
|
161
|
+
setForcedNextKey(providerId, keyId) {
|
|
162
|
+
this.forcedNextKeys.set(providerId, keyId);
|
|
163
|
+
}
|
|
164
|
+
peekNextKey(providerId, _modelId) {
|
|
165
|
+
const keys = this.getKeys(providerId).filter((key) => key.status !== "invalid" && key.isActive);
|
|
166
|
+
const forced = this.forcedNextKeys.get(providerId);
|
|
167
|
+
const permanent = this.permanentKeys.get(providerId);
|
|
168
|
+
return forced && this.getKey(forced) || permanent && this.getKey(permanent) || keys[0] || null;
|
|
169
|
+
}
|
|
170
|
+
getNextKey(providerId, modelId) {
|
|
171
|
+
const key = this.peekNextKey(providerId, modelId);
|
|
172
|
+
this.forcedNextKeys.delete(providerId);
|
|
173
|
+
return key;
|
|
174
|
+
}
|
|
145
175
|
selectNextKey(providerId, _modelId) {
|
|
146
176
|
return this.getActiveKey(providerId);
|
|
147
177
|
}
|
|
178
|
+
updateKeyLabel(id, label) {
|
|
179
|
+
const key = this.getKey(id);
|
|
180
|
+
if (!key) return void 0;
|
|
181
|
+
key.label = label;
|
|
182
|
+
keysStorage.saveKey(key);
|
|
183
|
+
return key;
|
|
184
|
+
}
|
|
185
|
+
deleteKey(id) {
|
|
186
|
+
const existed = Boolean(this.getKey(id));
|
|
187
|
+
keysStorage.deleteKey(id);
|
|
188
|
+
return existed;
|
|
189
|
+
}
|
|
190
|
+
resetKeyProbabilities(id) {
|
|
191
|
+
const key = this.getKey(id);
|
|
192
|
+
if (!key) return void 0;
|
|
193
|
+
key.weight = 5;
|
|
194
|
+
key.errorCount = 0;
|
|
195
|
+
key.status = "active";
|
|
196
|
+
key.isActive = true;
|
|
197
|
+
keysStorage.saveKey(key);
|
|
198
|
+
return key;
|
|
199
|
+
}
|
|
200
|
+
resetAllFailures() {
|
|
201
|
+
for (const key of this.getKeys()) {
|
|
202
|
+
key.errorCount = 0;
|
|
203
|
+
key.status = "active";
|
|
204
|
+
key.isActive = true;
|
|
205
|
+
keysStorage.saveKey(key);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
getUsageStats(_keyId, _modelId) {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
148
211
|
updateKeyStatus(id, status) {
|
|
149
212
|
const key = this.getKey(id);
|
|
150
213
|
if (!key) return;
|
|
@@ -193,9 +256,9 @@ var KeyStoreService = class {
|
|
|
193
256
|
var keyStore = new KeyStoreService();
|
|
194
257
|
|
|
195
258
|
export {
|
|
196
|
-
validateApiKey,
|
|
197
259
|
KeysStorage,
|
|
198
260
|
keysStorage,
|
|
261
|
+
validateApiKey,
|
|
199
262
|
KeyStoreService,
|
|
200
263
|
keyStore
|
|
201
264
|
};
|
|
@@ -3,6 +3,26 @@ var MCPEngine = class {
|
|
|
3
3
|
servers = /* @__PURE__ */ new Map();
|
|
4
4
|
registeredTools = /* @__PURE__ */ new Map();
|
|
5
5
|
toolHandlers = /* @__PURE__ */ new Map();
|
|
6
|
+
getSystemTools() {
|
|
7
|
+
return this.listTools();
|
|
8
|
+
}
|
|
9
|
+
async handleJsonRpc(payload) {
|
|
10
|
+
const { id, method, params } = payload ?? {};
|
|
11
|
+
if (method === "tools/list") {
|
|
12
|
+
return { jsonrpc: "2.0", id, result: { tools: this.listTools() } };
|
|
13
|
+
}
|
|
14
|
+
if (method === "tools/call") {
|
|
15
|
+
const toolName = params?.name;
|
|
16
|
+
if (!toolName) return { jsonrpc: "2.0", id, error: { code: -32602, message: "Tool name is required." } };
|
|
17
|
+
const result = await this.executeTool(toolName, params?.arguments ?? {});
|
|
18
|
+
return {
|
|
19
|
+
jsonrpc: "2.0",
|
|
20
|
+
id,
|
|
21
|
+
result: result.success ? { content: [{ type: "text", text: JSON.stringify(result.output ?? "") }] } : { content: [{ type: "text", text: result.error ?? "Tool execution failed" }], isError: true }
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return { jsonrpc: "2.0", id, error: { code: -32601, message: `Method "${method}" not found.` } };
|
|
25
|
+
}
|
|
6
26
|
registerServer(config) {
|
|
7
27
|
this.servers.set(config.id, config);
|
|
8
28
|
}
|
|
File without changes
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
S3Adapter
|
|
3
|
-
} from "./chunk-RBQ4CW3T.js";
|
|
4
|
-
import {
|
|
5
|
-
RemoteWorkspaceService,
|
|
6
|
-
SyncEngine,
|
|
7
|
-
WorkingWorkspaceService,
|
|
8
|
-
WorkspaceCloneSyncEngine,
|
|
9
|
-
WorkspaceFS,
|
|
10
|
-
findWorkspaceRecord,
|
|
11
|
-
getDefaultWorkingWorkspaceDir,
|
|
12
|
-
getWorkingWorkspaceConfig,
|
|
13
|
-
getWorkingWorkspaceDir,
|
|
14
|
-
getWorkspaceFolderKey,
|
|
15
|
-
remoteWorkspaceService,
|
|
16
|
-
setWorkingWorkspaceConfig,
|
|
17
|
-
syncWorkspace,
|
|
18
|
-
workingWorkspaceService
|
|
19
|
-
} from "./chunk-EIYYESEU.js";
|
|
20
1
|
import {
|
|
21
2
|
CANONICAL_SRKL_URL,
|
|
22
3
|
SrklClient,
|
|
@@ -35,6 +16,25 @@ import {
|
|
|
35
16
|
syncSrklAccounts,
|
|
36
17
|
useSrklServices
|
|
37
18
|
} from "./chunk-3IUA66RS.js";
|
|
19
|
+
import {
|
|
20
|
+
S3Adapter
|
|
21
|
+
} from "./chunk-RBQ4CW3T.js";
|
|
22
|
+
import {
|
|
23
|
+
RemoteWorkspaceService,
|
|
24
|
+
SyncEngine,
|
|
25
|
+
WorkingWorkspaceService,
|
|
26
|
+
WorkspaceCloneSyncEngine,
|
|
27
|
+
WorkspaceFS,
|
|
28
|
+
findWorkspaceRecord,
|
|
29
|
+
getDefaultWorkingWorkspaceDir,
|
|
30
|
+
getWorkingWorkspaceConfig,
|
|
31
|
+
getWorkingWorkspaceDir,
|
|
32
|
+
getWorkspaceFolderKey,
|
|
33
|
+
remoteWorkspaceService,
|
|
34
|
+
setWorkingWorkspaceConfig,
|
|
35
|
+
syncWorkspace,
|
|
36
|
+
workingWorkspaceService
|
|
37
|
+
} from "./chunk-BTMIK44G.js";
|
|
38
38
|
import {
|
|
39
39
|
validateToolInput
|
|
40
40
|
} from "./chunk-6GQNYRD6.js";
|
|
@@ -138,13 +138,13 @@ import {
|
|
|
138
138
|
AIRoutingServiceFacade,
|
|
139
139
|
AIToolServiceDefinition,
|
|
140
140
|
AIToolServiceFacade
|
|
141
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-6YBBOHHG.js";
|
|
142
142
|
import {
|
|
143
143
|
MCPEngine,
|
|
144
144
|
ToolManagerService,
|
|
145
145
|
mcpEngine,
|
|
146
146
|
toolManagerService
|
|
147
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-U4HUGPRH.js";
|
|
148
148
|
import {
|
|
149
149
|
AuthServiceDefinition,
|
|
150
150
|
AuthServiceFacade,
|
|
@@ -178,11 +178,7 @@ import {
|
|
|
178
178
|
krnlWorkspaceGraphServiceFacade,
|
|
179
179
|
krnlWorkspaceServiceDefinition,
|
|
180
180
|
krnlWorkspaceServiceFacade
|
|
181
|
-
} from "./chunk-
|
|
182
|
-
import {
|
|
183
|
-
formatCanonicalWorkspaceFolderName,
|
|
184
|
-
sanitizeWorkspaceName
|
|
185
|
-
} from "./chunk-FZKBTF34.js";
|
|
181
|
+
} from "./chunk-T26VJ22Y.js";
|
|
186
182
|
import {
|
|
187
183
|
getPrimarySrklDeploymentUrl,
|
|
188
184
|
getSrklAccounts,
|
|
@@ -195,6 +191,10 @@ import {
|
|
|
195
191
|
b2ListFileNames,
|
|
196
192
|
b2UploadFile
|
|
197
193
|
} from "./chunk-4QEMALXF.js";
|
|
194
|
+
import {
|
|
195
|
+
formatCanonicalWorkspaceFolderName,
|
|
196
|
+
sanitizeWorkspaceName
|
|
197
|
+
} from "./chunk-FZKBTF34.js";
|
|
198
198
|
import {
|
|
199
199
|
CanonicalAuthClient,
|
|
200
200
|
RateLimiter,
|
|
@@ -241,13 +241,6 @@ import {
|
|
|
241
241
|
updateWorkspace,
|
|
242
242
|
writeWorkspaceFile
|
|
243
243
|
} from "./chunk-6K75XXFD.js";
|
|
244
|
-
import {
|
|
245
|
-
BaseStorageAdapter,
|
|
246
|
-
GoogleDriveAdapter,
|
|
247
|
-
createGoogleDriveAuthorizationUrl,
|
|
248
|
-
exchangeGoogleDriveCode,
|
|
249
|
-
refreshGoogleDriveAccessToken
|
|
250
|
-
} from "./chunk-KKRWZDMN.js";
|
|
251
244
|
import {
|
|
252
245
|
b2DeleteFileVersion,
|
|
253
246
|
b2DeleteFolder,
|
|
@@ -256,6 +249,13 @@ import {
|
|
|
256
249
|
getUnifiedDbUrl,
|
|
257
250
|
queryUnifiedDb
|
|
258
251
|
} from "./chunk-VAFCR2MS.js";
|
|
252
|
+
import {
|
|
253
|
+
BaseStorageAdapter,
|
|
254
|
+
GoogleDriveAdapter,
|
|
255
|
+
createGoogleDriveAuthorizationUrl,
|
|
256
|
+
exchangeGoogleDriveCode,
|
|
257
|
+
refreshGoogleDriveAccessToken
|
|
258
|
+
} from "./chunk-KKRWZDMN.js";
|
|
259
259
|
import "./chunk-TY32TUNI.js";
|
|
260
260
|
import {
|
|
261
261
|
DeterministicEndpointExecutor,
|
|
@@ -269,22 +269,7 @@ import {
|
|
|
269
269
|
performInference
|
|
270
270
|
} from "./chunk-GCTQY24J.js";
|
|
271
271
|
import "./chunk-IN3WRHXE.js";
|
|
272
|
-
import
|
|
273
|
-
KeyStoreService,
|
|
274
|
-
KeysStorage,
|
|
275
|
-
keyStore,
|
|
276
|
-
keysStorage,
|
|
277
|
-
validateApiKey
|
|
278
|
-
} from "./chunk-4GWYTYDQ.js";
|
|
279
|
-
import {
|
|
280
|
-
EndpointRefresher,
|
|
281
|
-
endpointRefresher
|
|
282
|
-
} from "./chunk-2WT7OUHW.js";
|
|
283
|
-
import {
|
|
284
|
-
ModelCatalogService,
|
|
285
|
-
STATIC_MODELS_CATALOG,
|
|
286
|
-
modelCatalog
|
|
287
|
-
} from "./chunk-MFM2QIY5.js";
|
|
272
|
+
import "./chunk-UU6M3L3O.js";
|
|
288
273
|
import "./chunk-LV55WKZR.js";
|
|
289
274
|
import "./chunk-WVDSMTW3.js";
|
|
290
275
|
import {
|
|
@@ -294,11 +279,23 @@ import {
|
|
|
294
279
|
failoverExecutionEngine,
|
|
295
280
|
healthCheckService,
|
|
296
281
|
metricsLogger
|
|
297
|
-
} from "./chunk-
|
|
282
|
+
} from "./chunk-AQT3GIXB.js";
|
|
298
283
|
import {
|
|
284
|
+
EndpointRefresher,
|
|
285
|
+
ModelCatalogService,
|
|
299
286
|
ModelHealthService,
|
|
287
|
+
STATIC_MODELS_CATALOG,
|
|
288
|
+
endpointRefresher,
|
|
289
|
+
modelCatalog,
|
|
300
290
|
modelHealthService
|
|
301
|
-
} from "./chunk-
|
|
291
|
+
} from "./chunk-F4J4YPUR.js";
|
|
292
|
+
import {
|
|
293
|
+
KeyStoreService,
|
|
294
|
+
KeysStorage,
|
|
295
|
+
keyStore,
|
|
296
|
+
keysStorage,
|
|
297
|
+
validateApiKey
|
|
298
|
+
} from "./chunk-HXFTSHCP.js";
|
|
302
299
|
import {
|
|
303
300
|
AIProviderService,
|
|
304
301
|
aiProviderService
|
|
@@ -11,14 +11,13 @@ import {
|
|
|
11
11
|
AIRoutingServiceFacade,
|
|
12
12
|
AIToolServiceDefinition,
|
|
13
13
|
AIToolServiceFacade
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-6YBBOHHG.js";
|
|
15
|
+
import "./chunk-U4HUGPRH.js";
|
|
16
16
|
import "./chunk-TY32TUNI.js";
|
|
17
17
|
import "./chunk-GCTQY24J.js";
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-Z3LXEA6P.js";
|
|
18
|
+
import "./chunk-AQT3GIXB.js";
|
|
19
|
+
import "./chunk-F4J4YPUR.js";
|
|
20
|
+
import "./chunk-HXFTSHCP.js";
|
|
22
21
|
import "./chunk-SLR6SIEU.js";
|
|
23
22
|
import "./chunk-MAMK4GDH.js";
|
|
24
23
|
import "./chunk-JSQZAFBU.js";
|
|
@@ -31,16 +31,16 @@ import {
|
|
|
31
31
|
krnlWorkspaceGraphServiceFacade,
|
|
32
32
|
krnlWorkspaceServiceDefinition,
|
|
33
33
|
krnlWorkspaceServiceFacade
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import "./chunk-FZKBTF34.js";
|
|
34
|
+
} from "./chunk-T26VJ22Y.js";
|
|
36
35
|
import "./chunk-XHADDA75.js";
|
|
37
36
|
import "./chunk-4QEMALXF.js";
|
|
37
|
+
import "./chunk-FZKBTF34.js";
|
|
38
38
|
import "./chunk-WTBAG4AV.js";
|
|
39
39
|
import "./chunk-VKSGYMAH.js";
|
|
40
40
|
import "./chunk-SHZAQTIT.js";
|
|
41
41
|
import "./chunk-6K75XXFD.js";
|
|
42
|
-
import "./chunk-KKRWZDMN.js";
|
|
43
42
|
import "./chunk-VAFCR2MS.js";
|
|
43
|
+
import "./chunk-KKRWZDMN.js";
|
|
44
44
|
import "./chunk-TY32TUNI.js";
|
|
45
45
|
export {
|
|
46
46
|
AuthServiceDefinition,
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
} from "../chunk-VKSGYMAH.js";
|
|
18
18
|
import "../chunk-SHZAQTIT.js";
|
|
19
19
|
import "../chunk-6K75XXFD.js";
|
|
20
|
-
import "../chunk-KKRWZDMN.js";
|
|
21
20
|
import "../chunk-VAFCR2MS.js";
|
|
21
|
+
import "../chunk-KKRWZDMN.js";
|
|
22
22
|
import "../chunk-TY32TUNI.js";
|
|
23
23
|
export {
|
|
24
24
|
CompositeBackend,
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
WorkspaceFS,
|
|
7
7
|
remoteWorkspaceService,
|
|
8
8
|
workingWorkspaceService
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-BTMIK44G.js";
|
|
10
10
|
import {
|
|
11
11
|
formatCanonicalWorkspaceFolderName,
|
|
12
12
|
sanitizeWorkspaceName
|
|
13
13
|
} from "../chunk-FZKBTF34.js";
|
|
14
14
|
import "../chunk-6K75XXFD.js";
|
|
15
|
-
import "../chunk-KKRWZDMN.js";
|
|
16
15
|
import "../chunk-VAFCR2MS.js";
|
|
16
|
+
import "../chunk-KKRWZDMN.js";
|
|
17
17
|
export {
|
|
18
18
|
RemoteWorkspaceService,
|
|
19
19
|
SyncEngine,
|
|
@@ -7,21 +7,6 @@ import {
|
|
|
7
7
|
instantiateSubgraph
|
|
8
8
|
} from "./chunk-S22PMERU.js";
|
|
9
9
|
import "./chunk-RHRXPY2U.js";
|
|
10
|
-
import {
|
|
11
|
-
AttractionEngine,
|
|
12
|
-
GhostInferenceEngine,
|
|
13
|
-
GhostLayoutResolver,
|
|
14
|
-
GhostTracePathBuilder,
|
|
15
|
-
calculateSocketCoordinates,
|
|
16
|
-
getBeamPoints,
|
|
17
|
-
useMagneticTraces
|
|
18
|
-
} from "./chunk-JXDJZSFW.js";
|
|
19
|
-
import {
|
|
20
|
-
ConnectionRuleStore,
|
|
21
|
-
HandleTypeRegistry,
|
|
22
|
-
WireTypeRegistry,
|
|
23
|
-
initializeDefaultGraphRules
|
|
24
|
-
} from "./chunk-TZOL3RN7.js";
|
|
25
10
|
import {
|
|
26
11
|
LifecycleCycleError,
|
|
27
12
|
LifecycleGraph,
|
|
@@ -45,6 +30,21 @@ import {
|
|
|
45
30
|
CustomViewWindow,
|
|
46
31
|
DEFAULT_GRAPH_SETTINGS
|
|
47
32
|
} from "./chunk-KG6QYS26.js";
|
|
33
|
+
import {
|
|
34
|
+
AttractionEngine,
|
|
35
|
+
GhostInferenceEngine,
|
|
36
|
+
GhostLayoutResolver,
|
|
37
|
+
GhostTracePathBuilder,
|
|
38
|
+
calculateSocketCoordinates,
|
|
39
|
+
getBeamPoints,
|
|
40
|
+
useMagneticTraces
|
|
41
|
+
} from "./chunk-JXDJZSFW.js";
|
|
42
|
+
import {
|
|
43
|
+
ConnectionRuleStore,
|
|
44
|
+
HandleTypeRegistry,
|
|
45
|
+
WireTypeRegistry,
|
|
46
|
+
initializeDefaultGraphRules
|
|
47
|
+
} from "./chunk-TZOL3RN7.js";
|
|
48
48
|
import {
|
|
49
49
|
AutoSolidify,
|
|
50
50
|
SpatialEngine,
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AITransportClient
|
|
3
|
-
} from "./chunk-MAMK4GDH.js";
|
|
4
|
-
import {
|
|
5
|
-
getProviderMeta
|
|
6
|
-
} from "./chunk-JSQZAFBU.js";
|
|
7
|
-
|
|
8
|
-
// src/ai-models/endpointRefresher.ts
|
|
9
|
-
var EndpointRefresher = class {
|
|
10
|
-
client;
|
|
11
|
-
constructor(client) {
|
|
12
|
-
this.client = client ?? new AITransportClient();
|
|
13
|
-
}
|
|
14
|
-
async fetchRemoteModels(providerId, apiKey) {
|
|
15
|
-
const meta = getProviderMeta(providerId);
|
|
16
|
-
if (!meta) throw new Error(`Unknown provider ${providerId}`);
|
|
17
|
-
const url = `${meta.baseUrl}${meta.modelsEndpoint}`;
|
|
18
|
-
const headers = {};
|
|
19
|
-
if (meta.defaultHeaderKey === "Authorization") {
|
|
20
|
-
headers["Authorization"] = `Bearer ${apiKey.trim()}`;
|
|
21
|
-
} else {
|
|
22
|
-
headers[meta.defaultHeaderKey] = apiKey.trim();
|
|
23
|
-
}
|
|
24
|
-
const res = await this.client.request({
|
|
25
|
-
url,
|
|
26
|
-
method: "GET",
|
|
27
|
-
headers,
|
|
28
|
-
timeoutMs: 12e3
|
|
29
|
-
});
|
|
30
|
-
if (!res.ok) {
|
|
31
|
-
throw new Error(`Failed to fetch models from ${providerId}: HTTP ${res.status}`);
|
|
32
|
-
}
|
|
33
|
-
const rawList = res.data.data || res.data.models || [];
|
|
34
|
-
return rawList.map((item) => ({
|
|
35
|
-
id: item.id || item.name || "",
|
|
36
|
-
name: item.display_name || item.name || item.id || "",
|
|
37
|
-
providerId,
|
|
38
|
-
contextWindow: item.context_window || item.input_token_limit || 131072,
|
|
39
|
-
supportsTools: true,
|
|
40
|
-
supportsVision: Boolean(item.architecture?.modality?.includes("image")),
|
|
41
|
-
supportsJson: true,
|
|
42
|
-
status: "active"
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
var endpointRefresher = new EndpointRefresher();
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
EndpointRefresher,
|
|
50
|
-
endpointRefresher
|
|
51
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// src/ai-models/modelHealthService.ts
|
|
2
|
-
var ModelHealthService = class {
|
|
3
|
-
healthMap = /* @__PURE__ */ new Map();
|
|
4
|
-
recordSuccess(providerId, modelId, latencyMs) {
|
|
5
|
-
const key = `${providerId}:${modelId}`;
|
|
6
|
-
this.healthMap.set(key, {
|
|
7
|
-
modelId,
|
|
8
|
-
providerId,
|
|
9
|
-
isHealthy: true,
|
|
10
|
-
latencyMs,
|
|
11
|
-
consecutiveFailures: 0,
|
|
12
|
-
lastCheckedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
recordFailure(providerId, modelId, error) {
|
|
16
|
-
const key = `${providerId}:${modelId}`;
|
|
17
|
-
const existing = this.healthMap.get(key);
|
|
18
|
-
const consecutive = (existing?.consecutiveFailures ?? 0) + 1;
|
|
19
|
-
this.healthMap.set(key, {
|
|
20
|
-
modelId,
|
|
21
|
-
providerId,
|
|
22
|
-
isHealthy: consecutive < 3,
|
|
23
|
-
latencyMs: existing?.latencyMs ?? 0,
|
|
24
|
-
consecutiveFailures: consecutive,
|
|
25
|
-
lastCheckedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
26
|
-
lastError: error
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
isModelAvailable(providerId, modelId) {
|
|
30
|
-
const status = this.healthMap.get(`${providerId}:${modelId}`);
|
|
31
|
-
return status ? status.isHealthy : true;
|
|
32
|
-
}
|
|
33
|
-
getHealth(providerId, modelId) {
|
|
34
|
-
return this.healthMap.get(`${providerId}:${modelId}`);
|
|
35
|
-
}
|
|
36
|
-
getAllHealth() {
|
|
37
|
-
return Array.from(this.healthMap.values());
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var modelHealthService = new ModelHealthService();
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
ModelHealthService,
|
|
44
|
-
modelHealthService
|
|
45
|
-
};
|
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
getWorkspaces,
|
|
6
6
|
updateWorkspace
|
|
7
7
|
} from "./chunk-6K75XXFD.js";
|
|
8
|
-
import {
|
|
9
|
-
GoogleDriveAdapter
|
|
10
|
-
} from "./chunk-KKRWZDMN.js";
|
|
11
8
|
import {
|
|
12
9
|
b2DownloadFile,
|
|
13
10
|
b2ListFileNames,
|
|
14
11
|
b2UploadFile,
|
|
15
12
|
queryUnifiedDb
|
|
16
13
|
} from "./chunk-VAFCR2MS.js";
|
|
14
|
+
import {
|
|
15
|
+
GoogleDriveAdapter
|
|
16
|
+
} from "./chunk-KKRWZDMN.js";
|
|
17
17
|
|
|
18
18
|
// src/workspace/WorkspaceFS.ts
|
|
19
19
|
import { SkipoBase } from "@ultrst-armada/kloks/functions";
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
formatCanonicalWorkspaceFolderName,
|
|
3
|
-
sanitizeWorkspaceName
|
|
4
|
-
} from "./chunk-FZKBTF34.js";
|
|
5
1
|
import {
|
|
6
2
|
getSrklAccounts,
|
|
7
3
|
srklListBackblazeBuckets
|
|
@@ -9,6 +5,10 @@ import {
|
|
|
9
5
|
import {
|
|
10
6
|
b2ListBuckets
|
|
11
7
|
} from "./chunk-4QEMALXF.js";
|
|
8
|
+
import {
|
|
9
|
+
formatCanonicalWorkspaceFolderName,
|
|
10
|
+
sanitizeWorkspaceName
|
|
11
|
+
} from "./chunk-FZKBTF34.js";
|
|
12
12
|
import {
|
|
13
13
|
RateLimiter,
|
|
14
14
|
SessionManager,
|