@ultrst-armada/kloks 1.13.0 → 1.14.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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "packageName": "@ultrst-armada/kloks",
4
- "version": "1.13.0",
5
- "sourceCommit": "cf5fd02ba6186ab1f3002f68fd29694dad1719f0",
4
+ "version": "1.14.0",
5
+ "sourceCommit": "f78e0968c6172b3d594f9af45c17e5478df2290b",
6
6
  "releaseWorkflow": "npm Release",
7
- "workflowRunId": "40833011549"
7
+ "workflowRunId": "40835042415"
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrst-armada/kloks",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -80,8 +80,19 @@ declare class KeyStoreService {
80
80
  setStrategy(strategy: RotationStrategy): void;
81
81
  getStrategy(): RotationStrategy;
82
82
  addKey(entry: Omit<ApiKeyEntry, 'id' | 'createdAt' | 'totalCalls' | 'successfulCalls' | 'failedCalls' | 'lastLatencyMs' | 'errorCount'>): ApiKeyEntry;
83
+ selectNextKey(providerId: ProviderId, _modelId?: string): ApiKeyEntry | undefined;
84
+ updateKeyStatus(id: string, status: ApiKeyEntry['status']): void;
85
+ recordUsage(keyId: string, successOrLatency: boolean | number, latencyOrSuccess: boolean | number, _costUsd?: number, _modelId?: string, error?: string): void;
86
+ exportKeysStructured(): {
87
+ version: 1;
88
+ exportedAt: string;
89
+ keys: ApiKeyEntry[];
90
+ };
91
+ importKeys(payload: unknown): Promise<{
92
+ importedCount: number;
93
+ keys: ApiKeyEntry[];
94
+ }>;
83
95
  verifyKey(id: string): Promise<boolean>;
84
- recordUsage(keyId: string, success: boolean, latencyMs: number): void;
85
96
  }
86
97
  declare const keyStore: KeyStoreService;
87
98
 
@@ -5,7 +5,7 @@ import {
5
5
  keyStore,
6
6
  keysStorage,
7
7
  validateApiKey
8
- } from "../chunk-4IYKKD53.js";
8
+ } from "../chunk-4GWYTYDQ.js";
9
9
  import "../chunk-JSQZAFBU.js";
10
10
  export {
11
11
  KeyStoreService,
@@ -76,6 +76,12 @@ declare class ModelCatalogService {
76
76
  private customModels;
77
77
  getAllModels(): ModelCatalogEntry[];
78
78
  getModelsByProvider(providerId: ProviderId): ModelCatalogEntry[];
79
+ getModelById(id: string): ModelCatalogEntry | undefined;
80
+ recordModelSuccess(id: string): void;
81
+ recordModelFailure(id: string): void;
82
+ createExecutionContract(modelId: string, providerId: ProviderId, keyId: string, intelligenceSpec?: unknown): {
83
+ contractId: string;
84
+ };
79
85
  getModel(id: string): ModelCatalogEntry | undefined;
80
86
  registerModel(model: ModelCatalogEntry): void;
81
87
  getAvailableModels(): ModelCatalogEntry[];
@@ -6,7 +6,7 @@ import {
6
6
  ModelCatalogService,
7
7
  STATIC_MODELS_CATALOG,
8
8
  modelCatalog
9
- } from "../chunk-AM2PLPNE.js";
9
+ } from "../chunk-MFM2QIY5.js";
10
10
  import {
11
11
  ModelHealthService,
12
12
  modelHealthService
@@ -50,6 +50,25 @@ interface AIMetricRecord {
50
50
  declare class MetricsLogger {
51
51
  private records;
52
52
  private readonly maxRecords;
53
+ logRequest(record: {
54
+ providerId: ProviderId;
55
+ modelId: string;
56
+ latencyMs: number;
57
+ status?: string;
58
+ clientIp?: string;
59
+ profileRequested?: unknown;
60
+ selectedModel?: string;
61
+ selectedProvider?: ProviderId;
62
+ selectedKeyId?: string;
63
+ tokensUsed?: number;
64
+ statusCode?: number;
65
+ failoverOccurred?: boolean;
66
+ failoverChain?: string[];
67
+ promptSnippet?: string;
68
+ responseSnippet?: string;
69
+ toolCalls?: unknown;
70
+ toolsProvided?: unknown;
71
+ }): void;
53
72
  log(record: Omit<AIMetricRecord, 'id' | 'timestamp'>): void;
54
73
  getRecent(limit?: number): AIMetricRecord[];
55
74
  getAverageLatency(providerId: ProviderId, modelId?: string): number;
@@ -6,9 +6,9 @@ import {
6
6
  failoverExecutionEngine,
7
7
  healthCheckService,
8
8
  metricsLogger
9
- } from "../chunk-ERDBD4TH.js";
10
- import "../chunk-SLR6SIEU.js";
9
+ } from "../chunk-MSCOKLAO.js";
11
10
  import "../chunk-Z3LXEA6P.js";
11
+ import "../chunk-SLR6SIEU.js";
12
12
  import "../chunk-MAMK4GDH.js";
13
13
  import "../chunk-JSQZAFBU.js";
14
14
  export {
@@ -142,30 +142,53 @@ var KeyStoreService = class {
142
142
  keysStorage.saveKey(full);
143
143
  return full;
144
144
  }
145
- async verifyKey(id) {
146
- const entry = this.getKey(id);
147
- if (!entry) return false;
148
- const res = await validateApiKey(entry.providerId, entry.key);
149
- entry.status = res.status;
150
- entry.lastLatencyMs = res.latencyMs;
151
- entry.validationError = res.error;
152
- keysStorage.saveKey(entry);
153
- return res.valid;
145
+ selectNextKey(providerId, _modelId) {
146
+ return this.getActiveKey(providerId);
147
+ }
148
+ updateKeyStatus(id, status) {
149
+ const key = this.getKey(id);
150
+ if (!key) return;
151
+ key.status = status;
152
+ keysStorage.saveKey(key);
154
153
  }
155
- recordUsage(keyId, success, latencyMs) {
154
+ recordUsage(keyId, successOrLatency, latencyOrSuccess, _costUsd = 0, _modelId, error) {
156
155
  const key = this.getKey(keyId);
157
156
  if (!key) return;
157
+ const success = typeof successOrLatency === "boolean" ? successOrLatency : Boolean(latencyOrSuccess);
158
+ const latencyMs = typeof successOrLatency === "number" ? successOrLatency : Number(latencyOrSuccess);
158
159
  key.totalCalls++;
159
160
  key.lastLatencyMs = latencyMs;
160
161
  key.lastUsedAt = (/* @__PURE__ */ new Date()).toISOString();
161
- if (success) {
162
- key.successfulCalls++;
163
- } else {
162
+ if (success) key.successfulCalls++;
163
+ else {
164
164
  key.failedCalls++;
165
165
  key.errorCount++;
166
+ key.validationError = error ?? key.validationError;
166
167
  }
167
168
  keysStorage.saveKey(key);
168
169
  }
170
+ exportKeysStructured() {
171
+ return { version: 1, exportedAt: (/* @__PURE__ */ new Date()).toISOString(), keys: this.getKeys() };
172
+ }
173
+ async importKeys(payload) {
174
+ const raw = payload?.keys ?? payload;
175
+ if (!Array.isArray(raw)) throw new Error("Invalid key backup payload.");
176
+ const keys = raw.filter(
177
+ (entry) => Boolean(entry && typeof entry.id === "string" && typeof entry.providerId === "string" && typeof entry.key === "string")
178
+ );
179
+ keysStorage.saveKeys(keys);
180
+ return { importedCount: keys.length, keys };
181
+ }
182
+ async verifyKey(id) {
183
+ const entry = this.getKey(id);
184
+ if (!entry) return false;
185
+ const res = await validateApiKey(entry.providerId, entry.key);
186
+ entry.status = res.status;
187
+ entry.lastLatencyMs = res.latencyMs;
188
+ entry.validationError = res.error;
189
+ keysStorage.saveKey(entry);
190
+ return res.valid;
191
+ }
169
192
  };
170
193
  var keyStore = new KeyStoreService();
171
194
 
@@ -136,6 +136,22 @@ var ModelCatalogService = class {
136
136
  getModelsByProvider(providerId) {
137
137
  return this.getAllModels().filter((m) => m.providerId === providerId);
138
138
  }
139
+ getModelById(id) {
140
+ return this.getModel(id);
141
+ }
142
+ recordModelSuccess(id) {
143
+ const model = this.getModel(id);
144
+ if (model) model.status = "active";
145
+ }
146
+ recordModelFailure(id) {
147
+ const model = this.getModel(id);
148
+ if (model) model.status = "offline";
149
+ }
150
+ createExecutionContract(modelId, providerId, keyId, intelligenceSpec) {
151
+ return {
152
+ contractId: `contract-${Date.now()}-${providerId}-${modelId}-${keyId}`
153
+ };
154
+ }
139
155
  getModel(id) {
140
156
  return this.customModels.get(id) ?? this.getAllModels().find((m) => m.id === id || m.id.endsWith(id));
141
157
  }
@@ -1,14 +1,22 @@
1
- import {
2
- aiProviderService
3
- } from "./chunk-SLR6SIEU.js";
4
1
  import {
5
2
  modelHealthService
6
3
  } from "./chunk-Z3LXEA6P.js";
4
+ import {
5
+ aiProviderService
6
+ } from "./chunk-SLR6SIEU.js";
7
7
 
8
8
  // src/ai-routing/metricsLogger.ts
9
9
  var MetricsLogger = class {
10
10
  records = [];
11
11
  maxRecords = 2e3;
12
+ logRequest(record) {
13
+ this.log({
14
+ providerId: record.providerId,
15
+ modelId: record.modelId,
16
+ durationMs: record.latencyMs,
17
+ success: record.status !== "failure"
18
+ });
19
+ }
12
20
  log(record) {
13
21
  const full = {
14
22
  id: `met_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`,
@@ -10,13 +10,13 @@ import {
10
10
  } from "./chunk-GCTQY24J.js";
11
11
  import {
12
12
  keyStore
13
- } from "./chunk-4IYKKD53.js";
13
+ } from "./chunk-4GWYTYDQ.js";
14
14
  import {
15
15
  modelCatalog
16
- } from "./chunk-AM2PLPNE.js";
16
+ } from "./chunk-MFM2QIY5.js";
17
17
  import {
18
18
  failoverExecutionEngine
19
- } from "./chunk-ERDBD4TH.js";
19
+ } from "./chunk-MSCOKLAO.js";
20
20
  import {
21
21
  aiProviderService
22
22
  } from "./chunk-SLR6SIEU.js";
@@ -1,21 +1,3 @@
1
- import {
2
- CANONICAL_SRKL_URL,
3
- SrklClient,
4
- SrklCredentialRegistry,
5
- SrklVaultAccessClient,
6
- createSrklClient,
7
- decryptVaultBufferInBrowser,
8
- getPrimarySrklDeploymentUrl as getPrimarySrklDeploymentUrl2,
9
- getSrklAccounts as getSrklAccounts2,
10
- getSrklStatus,
11
- globalCredentialRegistry,
12
- hexToBytes,
13
- listBackblazeBuckets,
14
- srklListBackblazeBuckets as srklListBackblazeBuckets2,
15
- srklService,
16
- syncSrklAccounts,
17
- useSrklServices
18
- } from "./chunk-3IUA66RS.js";
19
1
  import {
20
2
  S3Adapter
21
3
  } from "./chunk-RBQ4CW3T.js";
@@ -34,7 +16,25 @@ import {
34
16
  setWorkingWorkspaceConfig,
35
17
  syncWorkspace,
36
18
  workingWorkspaceService
37
- } from "./chunk-BTMIK44G.js";
19
+ } from "./chunk-EIYYESEU.js";
20
+ import {
21
+ CANONICAL_SRKL_URL,
22
+ SrklClient,
23
+ SrklCredentialRegistry,
24
+ SrklVaultAccessClient,
25
+ createSrklClient,
26
+ decryptVaultBufferInBrowser,
27
+ getPrimarySrklDeploymentUrl as getPrimarySrklDeploymentUrl2,
28
+ getSrklAccounts as getSrklAccounts2,
29
+ getSrklStatus,
30
+ globalCredentialRegistry,
31
+ hexToBytes,
32
+ listBackblazeBuckets,
33
+ srklListBackblazeBuckets as srklListBackblazeBuckets2,
34
+ srklService,
35
+ syncSrklAccounts,
36
+ useSrklServices
37
+ } from "./chunk-3IUA66RS.js";
38
38
  import {
39
39
  validateToolInput
40
40
  } from "./chunk-6GQNYRD6.js";
@@ -138,7 +138,7 @@ import {
138
138
  AIRoutingServiceFacade,
139
139
  AIToolServiceDefinition,
140
140
  AIToolServiceFacade
141
- } from "./chunk-NITVHSB3.js";
141
+ } from "./chunk-XGPL43T3.js";
142
142
  import {
143
143
  MCPEngine,
144
144
  ToolManagerService,
@@ -178,7 +178,11 @@ import {
178
178
  krnlWorkspaceGraphServiceFacade,
179
179
  krnlWorkspaceServiceDefinition,
180
180
  krnlWorkspaceServiceFacade
181
- } from "./chunk-T26VJ22Y.js";
181
+ } from "./chunk-D6ZGQFWQ.js";
182
+ import {
183
+ formatCanonicalWorkspaceFolderName,
184
+ sanitizeWorkspaceName
185
+ } from "./chunk-FZKBTF34.js";
182
186
  import {
183
187
  getPrimarySrklDeploymentUrl,
184
188
  getSrklAccounts,
@@ -191,10 +195,6 @@ import {
191
195
  b2ListFileNames,
192
196
  b2UploadFile
193
197
  } 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,6 +241,13 @@ 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";
244
251
  import {
245
252
  b2DeleteFileVersion,
246
253
  b2DeleteFolder,
@@ -249,13 +256,6 @@ import {
249
256
  getUnifiedDbUrl,
250
257
  queryUnifiedDb
251
258
  } 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,
@@ -275,8 +275,7 @@ import {
275
275
  keyStore,
276
276
  keysStorage,
277
277
  validateApiKey
278
- } from "./chunk-4IYKKD53.js";
279
- import "./chunk-LV55WKZR.js";
278
+ } from "./chunk-4GWYTYDQ.js";
280
279
  import {
281
280
  EndpointRefresher,
282
281
  endpointRefresher
@@ -285,7 +284,8 @@ import {
285
284
  ModelCatalogService,
286
285
  STATIC_MODELS_CATALOG,
287
286
  modelCatalog
288
- } from "./chunk-AM2PLPNE.js";
287
+ } from "./chunk-MFM2QIY5.js";
288
+ import "./chunk-LV55WKZR.js";
289
289
  import "./chunk-WVDSMTW3.js";
290
290
  import {
291
291
  FailoverExecutionEngine,
@@ -294,15 +294,15 @@ import {
294
294
  failoverExecutionEngine,
295
295
  healthCheckService,
296
296
  metricsLogger
297
- } from "./chunk-ERDBD4TH.js";
298
- import {
299
- AIProviderService,
300
- aiProviderService
301
- } from "./chunk-SLR6SIEU.js";
297
+ } from "./chunk-MSCOKLAO.js";
302
298
  import {
303
299
  ModelHealthService,
304
300
  modelHealthService
305
301
  } from "./chunk-Z3LXEA6P.js";
302
+ import {
303
+ AIProviderService,
304
+ aiProviderService
305
+ } from "./chunk-SLR6SIEU.js";
306
306
  import {
307
307
  AITransportClient
308
308
  } from "./chunk-MAMK4GDH.js";
@@ -11,15 +11,15 @@ import {
11
11
  AIRoutingServiceFacade,
12
12
  AIToolServiceDefinition,
13
13
  AIToolServiceFacade
14
- } from "./chunk-NITVHSB3.js";
14
+ } from "./chunk-XGPL43T3.js";
15
15
  import "./chunk-NSKVYL74.js";
16
16
  import "./chunk-TY32TUNI.js";
17
17
  import "./chunk-GCTQY24J.js";
18
- import "./chunk-4IYKKD53.js";
19
- import "./chunk-AM2PLPNE.js";
20
- import "./chunk-ERDBD4TH.js";
21
- import "./chunk-SLR6SIEU.js";
18
+ import "./chunk-4GWYTYDQ.js";
19
+ import "./chunk-MFM2QIY5.js";
20
+ import "./chunk-MSCOKLAO.js";
22
21
  import "./chunk-Z3LXEA6P.js";
22
+ import "./chunk-SLR6SIEU.js";
23
23
  import "./chunk-MAMK4GDH.js";
24
24
  import "./chunk-JSQZAFBU.js";
25
25
  export {
@@ -31,16 +31,16 @@ import {
31
31
  krnlWorkspaceGraphServiceFacade,
32
32
  krnlWorkspaceServiceDefinition,
33
33
  krnlWorkspaceServiceFacade
34
- } from "./chunk-T26VJ22Y.js";
34
+ } from "./chunk-D6ZGQFWQ.js";
35
+ import "./chunk-FZKBTF34.js";
35
36
  import "./chunk-XHADDA75.js";
36
37
  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-VAFCR2MS.js";
43
42
  import "./chunk-KKRWZDMN.js";
43
+ import "./chunk-VAFCR2MS.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-VAFCR2MS.js";
21
20
  import "../chunk-KKRWZDMN.js";
21
+ import "../chunk-VAFCR2MS.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-BTMIK44G.js";
9
+ } from "../chunk-EIYYESEU.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-VAFCR2MS.js";
16
15
  import "../chunk-KKRWZDMN.js";
16
+ import "../chunk-VAFCR2MS.js";
17
17
  export {
18
18
  RemoteWorkspaceService,
19
19
  SyncEngine,
@@ -7,6 +7,21 @@ 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";
10
25
  import {
11
26
  LifecycleCycleError,
12
27
  LifecycleGraph,
@@ -30,21 +45,6 @@ import {
30
45
  CustomViewWindow,
31
46
  DEFAULT_GRAPH_SETTINGS
32
47
  } 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,3 +1,7 @@
1
+ import {
2
+ formatCanonicalWorkspaceFolderName,
3
+ sanitizeWorkspaceName
4
+ } from "./chunk-FZKBTF34.js";
1
5
  import {
2
6
  getSrklAccounts,
3
7
  srklListBackblazeBuckets
@@ -5,10 +9,6 @@ import {
5
9
  import {
6
10
  b2ListBuckets
7
11
  } from "./chunk-4QEMALXF.js";
8
- import {
9
- formatCanonicalWorkspaceFolderName,
10
- sanitizeWorkspaceName
11
- } from "./chunk-FZKBTF34.js";
12
12
  import {
13
13
  RateLimiter,
14
14
  SessionManager,
@@ -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";
8
11
  import {
9
12
  b2DownloadFile,
10
13
  b2ListFileNames,
11
14
  b2UploadFile,
12
15
  queryUnifiedDb
13
16
  } 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";