@ultrst-armada/kloks 1.11.0 → 1.13.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 +36 -1
- package/packages/backend/dist/AITransportClient-dToGr8nj.d.ts +30 -0
- package/packages/backend/dist/ai-inference/index.d.ts +99 -0
- package/packages/backend/dist/ai-inference/index.js +21 -0
- package/packages/backend/dist/ai-keys/index.d.ts +88 -0
- package/packages/backend/dist/ai-keys/index.js +16 -0
- package/packages/backend/dist/ai-models/index.d.ts +85 -0
- package/packages/backend/dist/ai-models/index.js +24 -0
- package/packages/backend/dist/ai-provider/index.d.ts +32 -0
- package/packages/backend/dist/ai-provider/index.js +23 -0
- package/packages/backend/dist/ai-routing/index.d.ts +84 -0
- package/packages/backend/dist/ai-routing/index.js +21 -0
- package/packages/backend/dist/ai-tools/index.d.ts +80 -0
- package/packages/backend/dist/ai-tools/index.js +16 -0
- package/packages/backend/dist/chunk-2WT7OUHW.js +51 -0
- package/packages/backend/dist/chunk-4IYKKD53.js +178 -0
- package/packages/backend/dist/chunk-6GQNYRD6.js +32 -0
- package/packages/backend/dist/chunk-AM2PLPNE.js +157 -0
- package/packages/backend/dist/chunk-ERDBD4TH.js +137 -0
- package/packages/backend/dist/chunk-GCTQY24J.js +195 -0
- package/packages/backend/dist/chunk-IN3WRHXE.js +0 -0
- package/packages/backend/dist/chunk-JSQZAFBU.js +153 -0
- package/packages/backend/dist/chunk-LV55WKZR.js +0 -0
- package/packages/backend/dist/chunk-MAMK4GDH.js +73 -0
- package/packages/backend/dist/chunk-NITVHSB3.js +225 -0
- package/packages/backend/dist/chunk-NSKVYL74.js +74 -0
- package/packages/backend/dist/chunk-SLR6SIEU.js +77 -0
- package/packages/backend/dist/chunk-WVDSMTW3.js +0 -0
- package/packages/backend/dist/chunk-Z2FHVSNF.js +42 -0
- package/packages/backend/dist/chunk-Z3LXEA6P.js +45 -0
- package/packages/backend/dist/index.d.ts +9 -0
- package/packages/backend/dist/index.js +230 -103
- package/packages/backend/dist/krnl-ai-services.d.ts +71 -0
- package/packages/backend/dist/krnl-ai-services.js +38 -0
- package/packages/backend/dist/krnl-services.js +4 -4
- package/packages/backend/dist/storage/index.js +7 -7
- package/packages/backend/dist/types-2p2AhboE.d.ts +33 -0
- package/packages/backend/package.json +36 -1
- package/packages/contracts/dist/index.d.ts +33 -1
- package/packages/services/dist/index.d.ts +3 -1
- package/packages/services/dist/index.js +133 -6
- package/packages/state-graph/dist/index.js +14 -14
- package/packages/backend/dist/{chunk-UMEO6XS4.js → chunk-T26VJ22Y.js} +12 -12
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"packageName": "@ultrst-armada/kloks",
|
|
4
|
-
"version": "1.
|
|
5
|
-
"sourceCommit": "
|
|
4
|
+
"version": "1.13.0",
|
|
5
|
+
"sourceCommit": "cf5fd02ba6186ab1f3002f68fd29694dad1719f0",
|
|
6
6
|
"releaseWorkflow": "npm Release",
|
|
7
|
-
"workflowRunId": "
|
|
7
|
+
"workflowRunId": "40833011549"
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultrst-armada/kloks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -109,6 +109,41 @@
|
|
|
109
109
|
"types": "./packages/backend/dist/development/index.d.ts",
|
|
110
110
|
"import": "./packages/backend/dist/development/index.js",
|
|
111
111
|
"default": "./packages/backend/dist/development/index.js"
|
|
112
|
+
},
|
|
113
|
+
"./ai-provider": {
|
|
114
|
+
"types": "./packages/backend/dist/ai-provider/index.d.ts",
|
|
115
|
+
"import": "./packages/backend/dist/ai-provider/index.js",
|
|
116
|
+
"default": "./packages/backend/dist/ai-provider/index.js"
|
|
117
|
+
},
|
|
118
|
+
"./ai-inference": {
|
|
119
|
+
"types": "./packages/backend/dist/ai-inference/index.d.ts",
|
|
120
|
+
"import": "./packages/backend/dist/ai-inference/index.js",
|
|
121
|
+
"default": "./packages/backend/dist/ai-inference/index.js"
|
|
122
|
+
},
|
|
123
|
+
"./ai-models": {
|
|
124
|
+
"types": "./packages/backend/dist/ai-models/index.d.ts",
|
|
125
|
+
"import": "./packages/backend/dist/ai-models/index.js",
|
|
126
|
+
"default": "./packages/backend/dist/ai-models/index.js"
|
|
127
|
+
},
|
|
128
|
+
"./ai-routing": {
|
|
129
|
+
"types": "./packages/backend/dist/ai-routing/index.d.ts",
|
|
130
|
+
"import": "./packages/backend/dist/ai-routing/index.js",
|
|
131
|
+
"default": "./packages/backend/dist/ai-routing/index.js"
|
|
132
|
+
},
|
|
133
|
+
"./ai-keys": {
|
|
134
|
+
"types": "./packages/backend/dist/ai-keys/index.d.ts",
|
|
135
|
+
"import": "./packages/backend/dist/ai-keys/index.js",
|
|
136
|
+
"default": "./packages/backend/dist/ai-keys/index.js"
|
|
137
|
+
},
|
|
138
|
+
"./ai-tools": {
|
|
139
|
+
"types": "./packages/backend/dist/ai-tools/index.d.ts",
|
|
140
|
+
"import": "./packages/backend/dist/ai-tools/index.js",
|
|
141
|
+
"default": "./packages/backend/dist/ai-tools/index.js"
|
|
142
|
+
},
|
|
143
|
+
"./krnl-ai-services": {
|
|
144
|
+
"types": "./packages/backend/dist/krnl-ai-services.d.ts",
|
|
145
|
+
"import": "./packages/backend/dist/krnl-ai-services.js",
|
|
146
|
+
"default": "./packages/backend/dist/krnl-ai-services.js"
|
|
112
147
|
}
|
|
113
148
|
},
|
|
114
149
|
"scripts": {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file AITransportClient.ts
|
|
3
|
+
* @description Universal HTTP/JSON Transport Client for AI Provider APIs
|
|
4
|
+
*/
|
|
5
|
+
interface AIHttpRequest {
|
|
6
|
+
url: string;
|
|
7
|
+
method?: string;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
body?: unknown;
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
interface AIHttpResponse<T = unknown> {
|
|
14
|
+
status: number;
|
|
15
|
+
ok: boolean;
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
data: T;
|
|
18
|
+
rawText: string;
|
|
19
|
+
}
|
|
20
|
+
declare class AITransportClient {
|
|
21
|
+
private readonly defaultTimeoutMs;
|
|
22
|
+
private readonly fetchImpl;
|
|
23
|
+
constructor(config?: {
|
|
24
|
+
defaultTimeoutMs?: number;
|
|
25
|
+
customFetch?: typeof fetch;
|
|
26
|
+
});
|
|
27
|
+
request<T = unknown>(req: AIHttpRequest): Promise<AIHttpResponse<T>>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { type AIHttpRequest as A, type AIHttpResponse as a, AITransportClient as b };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { a as ProviderId } from '../types-2p2AhboE.js';
|
|
2
|
+
import { b as AITransportClient } from '../AITransportClient-dToGr8nj.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file types.ts
|
|
6
|
+
* @description Canonical AI Inference domain contracts and types
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface ToolCall {
|
|
10
|
+
id: string;
|
|
11
|
+
type: 'function';
|
|
12
|
+
function: {
|
|
13
|
+
name: string;
|
|
14
|
+
arguments: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
interface InferenceOptions {
|
|
18
|
+
temperature?: number;
|
|
19
|
+
maxTokens?: number;
|
|
20
|
+
tools?: unknown[];
|
|
21
|
+
tool_choice?: unknown;
|
|
22
|
+
messages?: Array<{
|
|
23
|
+
role: string;
|
|
24
|
+
content: string;
|
|
25
|
+
}>;
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
}
|
|
28
|
+
interface InferenceResult {
|
|
29
|
+
text: string;
|
|
30
|
+
toolCalls?: ToolCall[];
|
|
31
|
+
usage?: {
|
|
32
|
+
promptTokens?: number;
|
|
33
|
+
completionTokens?: number;
|
|
34
|
+
totalTokens?: number;
|
|
35
|
+
};
|
|
36
|
+
durationMs?: number;
|
|
37
|
+
}
|
|
38
|
+
type ErrorClassification = 'UNKNOWN' | 'MODEL_UNAVAILABLE' | 'AUTH_FAILURE' | 'RATE_LIMITED' | 'PAYMENT_REQUIRED' | 'CONTEXT_OVERFLOW' | 'PARAMETER_MISMATCH' | 'SERVER_ERROR';
|
|
39
|
+
interface ParsedProviderError {
|
|
40
|
+
classification: ErrorClassification;
|
|
41
|
+
providerId: ProviderId;
|
|
42
|
+
modelId: string;
|
|
43
|
+
statusCode?: number;
|
|
44
|
+
message: string;
|
|
45
|
+
suggestion: string;
|
|
46
|
+
isModelSpecific: boolean;
|
|
47
|
+
isKeySpecific: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @file errorParser.ts
|
|
52
|
+
* @description Provider-neutral error parser and classifier for AI inference
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
declare function parseErrorJson(rawMsg: string): Record<string, unknown> | null;
|
|
56
|
+
declare function classifyAndFormatError(providerId: ProviderId, modelId: string, rawError: unknown, httpStatus?: number): {
|
|
57
|
+
error: Error;
|
|
58
|
+
details: ParsedProviderError;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @file inferenceExecutor.ts
|
|
63
|
+
* @description Multi-provider AI Inference Engine supporting Google Gemini REST & OpenAI-compatible endpoints
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
declare function performInference(providerId: ProviderId, modelId: string, apiKey: string, prompt: string, options?: InferenceOptions): Promise<InferenceResult>;
|
|
67
|
+
declare class InferenceExecutorService {
|
|
68
|
+
execute(providerId: ProviderId, modelId: string, apiKey: string, prompt: string, options?: InferenceOptions): Promise<InferenceResult>;
|
|
69
|
+
}
|
|
70
|
+
declare const inferenceExecutor: InferenceExecutorService;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @file DeterministicEndpointExecutor.ts
|
|
74
|
+
* @description Deterministic tool/feature endpoint execution with schema and timeout guards
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
interface EndpointExecutionParams {
|
|
78
|
+
url: string;
|
|
79
|
+
method?: string;
|
|
80
|
+
headers?: Record<string, string>;
|
|
81
|
+
payload?: unknown;
|
|
82
|
+
timeoutMs?: number;
|
|
83
|
+
expectedSchema?: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
interface EndpointExecutionResult {
|
|
86
|
+
success: boolean;
|
|
87
|
+
statusCode?: number;
|
|
88
|
+
responseBody?: unknown;
|
|
89
|
+
durationMs: number;
|
|
90
|
+
error?: string;
|
|
91
|
+
}
|
|
92
|
+
declare class DeterministicEndpointExecutor {
|
|
93
|
+
private readonly client;
|
|
94
|
+
constructor(client?: AITransportClient);
|
|
95
|
+
execute(params: EndpointExecutionParams): Promise<EndpointExecutionResult>;
|
|
96
|
+
}
|
|
97
|
+
declare const deterministicEndpointExecutor: DeterministicEndpointExecutor;
|
|
98
|
+
|
|
99
|
+
export { DeterministicEndpointExecutor, type EndpointExecutionParams, type EndpointExecutionResult, type ErrorClassification, InferenceExecutorService, type InferenceOptions, type InferenceResult, type ParsedProviderError, type ToolCall, classifyAndFormatError, deterministicEndpointExecutor, inferenceExecutor, parseErrorJson, performInference };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeterministicEndpointExecutor,
|
|
3
|
+
deterministicEndpointExecutor
|
|
4
|
+
} from "../chunk-Z2FHVSNF.js";
|
|
5
|
+
import {
|
|
6
|
+
InferenceExecutorService,
|
|
7
|
+
classifyAndFormatError,
|
|
8
|
+
inferenceExecutor,
|
|
9
|
+
parseErrorJson,
|
|
10
|
+
performInference
|
|
11
|
+
} from "../chunk-GCTQY24J.js";
|
|
12
|
+
import "../chunk-MAMK4GDH.js";
|
|
13
|
+
export {
|
|
14
|
+
DeterministicEndpointExecutor,
|
|
15
|
+
InferenceExecutorService,
|
|
16
|
+
classifyAndFormatError,
|
|
17
|
+
deterministicEndpointExecutor,
|
|
18
|
+
inferenceExecutor,
|
|
19
|
+
parseErrorJson,
|
|
20
|
+
performInference
|
|
21
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { a as ProviderId } from '../types-2p2AhboE.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file types.ts
|
|
5
|
+
* @description Canonical AI Key Management contracts and types for @ultrst-armada/kloks/backend
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
type RotationStrategy = 'lowest-latency' | 'round-robin' | 'weighted-random' | 'failover-priority';
|
|
9
|
+
interface ApiKeyEntry {
|
|
10
|
+
id: string;
|
|
11
|
+
providerId: ProviderId;
|
|
12
|
+
label: string;
|
|
13
|
+
key: string;
|
|
14
|
+
keyValue?: string;
|
|
15
|
+
status: 'active' | 'valid' | 'invalid' | 'rate-limited' | 'checking';
|
|
16
|
+
isActive: boolean;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
weight: number;
|
|
19
|
+
remainingCreditsUsd: number | null;
|
|
20
|
+
totalCalls: number;
|
|
21
|
+
successfulCalls: number;
|
|
22
|
+
failedCalls: number;
|
|
23
|
+
lastLatencyMs: number;
|
|
24
|
+
errorCount: number;
|
|
25
|
+
lifespanSeconds?: number | null;
|
|
26
|
+
expiresAt?: string | null;
|
|
27
|
+
lastUsedAt?: string | null;
|
|
28
|
+
validationError?: string | null;
|
|
29
|
+
failedModels?: string[];
|
|
30
|
+
}
|
|
31
|
+
interface KeyValidationResult {
|
|
32
|
+
valid: boolean;
|
|
33
|
+
status: 'valid' | 'invalid' | 'rate-limited';
|
|
34
|
+
error?: string;
|
|
35
|
+
latencyMs: number;
|
|
36
|
+
}
|
|
37
|
+
interface KeyModelUsageStats {
|
|
38
|
+
keyId: string;
|
|
39
|
+
modelId: string;
|
|
40
|
+
totalCalls: number;
|
|
41
|
+
successfulCalls: number;
|
|
42
|
+
failedCalls: number;
|
|
43
|
+
lastUsedAt?: string;
|
|
44
|
+
avgLatencyMs?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @file keyValidator.ts
|
|
49
|
+
* @description Validates API key authenticity against AI provider endpoints
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
declare function validateApiKey(providerId: ProviderId, apiKey: string): Promise<KeyValidationResult>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @file keysStorage.ts
|
|
56
|
+
* @description Storage layer for API keys with in-memory fallback and persistence
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
declare class KeysStorage {
|
|
60
|
+
private inMemoryKeys;
|
|
61
|
+
loadKeys(): ApiKeyEntry[];
|
|
62
|
+
saveKey(entry: ApiKeyEntry): void;
|
|
63
|
+
saveKeys(entries: ApiKeyEntry[]): void;
|
|
64
|
+
deleteKey(id: string): void;
|
|
65
|
+
clear(): void;
|
|
66
|
+
}
|
|
67
|
+
declare const keysStorage: KeysStorage;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @file keyStore.ts
|
|
71
|
+
* @description Key Store and Rotation service supporting multiple strategies
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
declare class KeyStoreService {
|
|
75
|
+
private strategy;
|
|
76
|
+
private roundRobinIndices;
|
|
77
|
+
getKeys(providerId?: ProviderId): ApiKeyEntry[];
|
|
78
|
+
getKey(id: string): ApiKeyEntry | undefined;
|
|
79
|
+
getActiveKey(providerId: ProviderId): ApiKeyEntry | undefined;
|
|
80
|
+
setStrategy(strategy: RotationStrategy): void;
|
|
81
|
+
getStrategy(): RotationStrategy;
|
|
82
|
+
addKey(entry: Omit<ApiKeyEntry, 'id' | 'createdAt' | 'totalCalls' | 'successfulCalls' | 'failedCalls' | 'lastLatencyMs' | 'errorCount'>): ApiKeyEntry;
|
|
83
|
+
verifyKey(id: string): Promise<boolean>;
|
|
84
|
+
recordUsage(keyId: string, success: boolean, latencyMs: number): void;
|
|
85
|
+
}
|
|
86
|
+
declare const keyStore: KeyStoreService;
|
|
87
|
+
|
|
88
|
+
export { type ApiKeyEntry, type KeyModelUsageStats, KeyStoreService, type KeyValidationResult, KeysStorage, type RotationStrategy, keyStore, keysStorage, validateApiKey };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../chunk-IN3WRHXE.js";
|
|
2
|
+
import {
|
|
3
|
+
KeyStoreService,
|
|
4
|
+
KeysStorage,
|
|
5
|
+
keyStore,
|
|
6
|
+
keysStorage,
|
|
7
|
+
validateApiKey
|
|
8
|
+
} from "../chunk-4IYKKD53.js";
|
|
9
|
+
import "../chunk-JSQZAFBU.js";
|
|
10
|
+
export {
|
|
11
|
+
KeyStoreService,
|
|
12
|
+
KeysStorage,
|
|
13
|
+
keyStore,
|
|
14
|
+
keysStorage,
|
|
15
|
+
validateApiKey
|
|
16
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { a as ProviderId } from '../types-2p2AhboE.js';
|
|
2
|
+
import { b as AITransportClient } from '../AITransportClient-dToGr8nj.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file types.ts
|
|
6
|
+
* @description Canonical Model Catalog and Discovery types for @ultrst-armada/kloks/backend
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface ModelCatalogEntry {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
providerId: ProviderId;
|
|
13
|
+
contextWindow?: number;
|
|
14
|
+
inputCostPer1k?: number;
|
|
15
|
+
outputCostPer1k?: number;
|
|
16
|
+
supportsTools?: boolean;
|
|
17
|
+
supportsVision?: boolean;
|
|
18
|
+
supportsJson?: boolean;
|
|
19
|
+
isFree?: boolean;
|
|
20
|
+
latencyRatingMs?: number;
|
|
21
|
+
qualityRating?: number;
|
|
22
|
+
maxOutputTokens?: number;
|
|
23
|
+
status?: 'active' | 'deprecated' | 'offline';
|
|
24
|
+
description?: string;
|
|
25
|
+
}
|
|
26
|
+
interface ModelHealthStatus {
|
|
27
|
+
modelId: string;
|
|
28
|
+
providerId: ProviderId;
|
|
29
|
+
isHealthy: boolean;
|
|
30
|
+
latencyMs: number;
|
|
31
|
+
consecutiveFailures: number;
|
|
32
|
+
lastCheckedAt: string;
|
|
33
|
+
lastError?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @file catalogData.ts
|
|
38
|
+
* @description Builtin static AI Model Catalog data across major providers
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
declare const STATIC_MODELS_CATALOG: ModelCatalogEntry[];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @file endpointRefresher.ts
|
|
45
|
+
* @description Dynamic provider model discovery and refresh logic
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
declare class EndpointRefresher {
|
|
49
|
+
private readonly client;
|
|
50
|
+
constructor(client?: AITransportClient);
|
|
51
|
+
fetchRemoteModels(providerId: ProviderId, apiKey: string): Promise<ModelCatalogEntry[]>;
|
|
52
|
+
}
|
|
53
|
+
declare const endpointRefresher: EndpointRefresher;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @file modelHealthService.ts
|
|
57
|
+
* @description Tracks and provides real-time health and availability for AI models
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
declare class ModelHealthService {
|
|
61
|
+
private healthMap;
|
|
62
|
+
recordSuccess(providerId: ProviderId, modelId: string, latencyMs: number): void;
|
|
63
|
+
recordFailure(providerId: ProviderId, modelId: string, error: string): void;
|
|
64
|
+
isModelAvailable(providerId: ProviderId, modelId: string): boolean;
|
|
65
|
+
getHealth(providerId: ProviderId, modelId: string): ModelHealthStatus | undefined;
|
|
66
|
+
getAllHealth(): ModelHealthStatus[];
|
|
67
|
+
}
|
|
68
|
+
declare const modelHealthService: ModelHealthService;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @file modelCatalog.ts
|
|
72
|
+
* @description Master Model Catalog Service for AI model registration and retrieval
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
declare class ModelCatalogService {
|
|
76
|
+
private customModels;
|
|
77
|
+
getAllModels(): ModelCatalogEntry[];
|
|
78
|
+
getModelsByProvider(providerId: ProviderId): ModelCatalogEntry[];
|
|
79
|
+
getModel(id: string): ModelCatalogEntry | undefined;
|
|
80
|
+
registerModel(model: ModelCatalogEntry): void;
|
|
81
|
+
getAvailableModels(): ModelCatalogEntry[];
|
|
82
|
+
}
|
|
83
|
+
declare const modelCatalog: ModelCatalogService;
|
|
84
|
+
|
|
85
|
+
export { EndpointRefresher, type ModelCatalogEntry, ModelCatalogService, ModelHealthService, type ModelHealthStatus, STATIC_MODELS_CATALOG, endpointRefresher, modelCatalog, modelHealthService };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EndpointRefresher,
|
|
3
|
+
endpointRefresher
|
|
4
|
+
} from "../chunk-2WT7OUHW.js";
|
|
5
|
+
import {
|
|
6
|
+
ModelCatalogService,
|
|
7
|
+
STATIC_MODELS_CATALOG,
|
|
8
|
+
modelCatalog
|
|
9
|
+
} from "../chunk-AM2PLPNE.js";
|
|
10
|
+
import {
|
|
11
|
+
ModelHealthService,
|
|
12
|
+
modelHealthService
|
|
13
|
+
} from "../chunk-Z3LXEA6P.js";
|
|
14
|
+
import "../chunk-MAMK4GDH.js";
|
|
15
|
+
import "../chunk-JSQZAFBU.js";
|
|
16
|
+
export {
|
|
17
|
+
EndpointRefresher,
|
|
18
|
+
ModelCatalogService,
|
|
19
|
+
ModelHealthService,
|
|
20
|
+
STATIC_MODELS_CATALOG,
|
|
21
|
+
endpointRefresher,
|
|
22
|
+
modelCatalog,
|
|
23
|
+
modelHealthService
|
|
24
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { b as ProviderMeta, a as ProviderId, A as AIProviderStatus } from '../types-2p2AhboE.js';
|
|
2
|
+
export { P as ProviderCapabilities } from '../types-2p2AhboE.js';
|
|
3
|
+
import { b as AITransportClient } from '../AITransportClient-dToGr8nj.js';
|
|
4
|
+
export { A as AIHttpRequest, a as AIHttpResponse } from '../AITransportClient-dToGr8nj.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @file providers.ts
|
|
8
|
+
* @description Master metadata, color mappings, and lookup for supported AI Providers.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare const PROVIDERS_META: Record<string, ProviderMeta>;
|
|
12
|
+
declare const PROVIDER_COLORS: Record<string, string>;
|
|
13
|
+
declare function getProviderMeta(providerId: ProviderId): ProviderMeta | undefined;
|
|
14
|
+
declare function listProviders(): ProviderMeta[];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @file AIProviderService.ts
|
|
18
|
+
* @description Provider management and registry service
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
declare class AIProviderService {
|
|
22
|
+
private readonly client;
|
|
23
|
+
private readonly customProviders;
|
|
24
|
+
constructor(client?: AITransportClient);
|
|
25
|
+
listProviders(): ProviderMeta[];
|
|
26
|
+
getProvider(id: ProviderId): ProviderMeta | undefined;
|
|
27
|
+
registerCustomProvider(meta: ProviderMeta): void;
|
|
28
|
+
checkHealth(id: ProviderId, apiKey?: string): Promise<AIProviderStatus>;
|
|
29
|
+
}
|
|
30
|
+
declare const aiProviderService: AIProviderService;
|
|
31
|
+
|
|
32
|
+
export { AIProviderService, AIProviderStatus, AITransportClient, PROVIDERS_META, PROVIDER_COLORS, ProviderId, ProviderMeta, aiProviderService, getProviderMeta, listProviders };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "../chunk-LV55WKZR.js";
|
|
2
|
+
import {
|
|
3
|
+
AIProviderService,
|
|
4
|
+
aiProviderService
|
|
5
|
+
} from "../chunk-SLR6SIEU.js";
|
|
6
|
+
import {
|
|
7
|
+
AITransportClient
|
|
8
|
+
} from "../chunk-MAMK4GDH.js";
|
|
9
|
+
import {
|
|
10
|
+
PROVIDERS_META,
|
|
11
|
+
PROVIDER_COLORS,
|
|
12
|
+
getProviderMeta,
|
|
13
|
+
listProviders
|
|
14
|
+
} from "../chunk-JSQZAFBU.js";
|
|
15
|
+
export {
|
|
16
|
+
AIProviderService,
|
|
17
|
+
AITransportClient,
|
|
18
|
+
PROVIDERS_META,
|
|
19
|
+
PROVIDER_COLORS,
|
|
20
|
+
aiProviderService,
|
|
21
|
+
getProviderMeta,
|
|
22
|
+
listProviders
|
|
23
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { a as ProviderId } from '../types-2p2AhboE.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file types.ts
|
|
5
|
+
* @description Canonical AI Routing and Failover types for @ultrst-armada/kloks/backend
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface RouteCandidate {
|
|
9
|
+
providerId: ProviderId;
|
|
10
|
+
modelId: string;
|
|
11
|
+
weight?: number;
|
|
12
|
+
priority?: number;
|
|
13
|
+
}
|
|
14
|
+
type AIRoutingStrategy = 'priority-order' | 'lowest-latency' | 'weighted-random' | 'round-robin';
|
|
15
|
+
interface RetryPolicy {
|
|
16
|
+
maxRetries: number;
|
|
17
|
+
backoffMs: number;
|
|
18
|
+
retryableStatuses?: number[];
|
|
19
|
+
}
|
|
20
|
+
interface RouteExecutionResult<T = unknown> {
|
|
21
|
+
success: boolean;
|
|
22
|
+
selectedCandidate?: RouteCandidate;
|
|
23
|
+
attempts: number;
|
|
24
|
+
result?: T;
|
|
25
|
+
error?: string;
|
|
26
|
+
totalDurationMs: number;
|
|
27
|
+
failoverHistory: Array<{
|
|
28
|
+
candidate: RouteCandidate;
|
|
29
|
+
error: string;
|
|
30
|
+
durationMs: number;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @file metricsLogger.ts
|
|
36
|
+
* @description Latency, throughput, and token usage metrics logger for AI operations
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
interface AIMetricRecord {
|
|
40
|
+
id: string;
|
|
41
|
+
timestamp: string;
|
|
42
|
+
providerId: ProviderId;
|
|
43
|
+
modelId: string;
|
|
44
|
+
durationMs: number;
|
|
45
|
+
success: boolean;
|
|
46
|
+
promptTokens?: number;
|
|
47
|
+
completionTokens?: number;
|
|
48
|
+
error?: string;
|
|
49
|
+
}
|
|
50
|
+
declare class MetricsLogger {
|
|
51
|
+
private records;
|
|
52
|
+
private readonly maxRecords;
|
|
53
|
+
log(record: Omit<AIMetricRecord, 'id' | 'timestamp'>): void;
|
|
54
|
+
getRecent(limit?: number): AIMetricRecord[];
|
|
55
|
+
getAverageLatency(providerId: ProviderId, modelId?: string): number;
|
|
56
|
+
getSuccessRate(providerId: ProviderId): number;
|
|
57
|
+
}
|
|
58
|
+
declare const metricsLogger: MetricsLogger;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @file healthCheckService.ts
|
|
62
|
+
* @description Periodic and on-demand route and provider health verification
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
declare class HealthCheckService {
|
|
66
|
+
checkProvider(providerId: ProviderId, apiKey?: string): Promise<boolean>;
|
|
67
|
+
isRouteAvailable(providerId: ProviderId, modelId: string): boolean;
|
|
68
|
+
recordRouteFailure(providerId: ProviderId, modelId: string, error: string): void;
|
|
69
|
+
recordRouteSuccess(providerId: ProviderId, modelId: string, latencyMs: number): void;
|
|
70
|
+
}
|
|
71
|
+
declare const healthCheckService: HealthCheckService;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @file failoverEngine.ts
|
|
75
|
+
* @description Resilient AI execution router with multi-candidate auto-failover
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
declare class FailoverExecutionEngine {
|
|
79
|
+
private defaultRetryPolicy;
|
|
80
|
+
executeWithFailover<T>(candidates: RouteCandidate[], executeCandidate: (candidate: RouteCandidate) => Promise<T>, policy?: Partial<RetryPolicy>): Promise<RouteExecutionResult<T>>;
|
|
81
|
+
}
|
|
82
|
+
declare const failoverExecutionEngine: FailoverExecutionEngine;
|
|
83
|
+
|
|
84
|
+
export { type AIMetricRecord, type AIRoutingStrategy, FailoverExecutionEngine, HealthCheckService, MetricsLogger, type RetryPolicy, type RouteCandidate, type RouteExecutionResult, failoverExecutionEngine, healthCheckService, metricsLogger };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "../chunk-WVDSMTW3.js";
|
|
2
|
+
import {
|
|
3
|
+
FailoverExecutionEngine,
|
|
4
|
+
HealthCheckService,
|
|
5
|
+
MetricsLogger,
|
|
6
|
+
failoverExecutionEngine,
|
|
7
|
+
healthCheckService,
|
|
8
|
+
metricsLogger
|
|
9
|
+
} from "../chunk-ERDBD4TH.js";
|
|
10
|
+
import "../chunk-SLR6SIEU.js";
|
|
11
|
+
import "../chunk-Z3LXEA6P.js";
|
|
12
|
+
import "../chunk-MAMK4GDH.js";
|
|
13
|
+
import "../chunk-JSQZAFBU.js";
|
|
14
|
+
export {
|
|
15
|
+
FailoverExecutionEngine,
|
|
16
|
+
HealthCheckService,
|
|
17
|
+
MetricsLogger,
|
|
18
|
+
failoverExecutionEngine,
|
|
19
|
+
healthCheckService,
|
|
20
|
+
metricsLogger
|
|
21
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file types.ts
|
|
3
|
+
* @description Canonical AI Tools and MCP runtime contracts for @ultrst-armada/kloks/backend
|
|
4
|
+
*/
|
|
5
|
+
interface MCPToolParameter {
|
|
6
|
+
type: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
properties?: Record<string, unknown>;
|
|
9
|
+
required?: string[];
|
|
10
|
+
items?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
interface MCPTool {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: string;
|
|
17
|
+
properties?: Record<string, unknown>;
|
|
18
|
+
required?: string[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface MCPServerConfig {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
transport: 'stdio' | 'sse' | 'websocket';
|
|
25
|
+
url?: string;
|
|
26
|
+
command?: string;
|
|
27
|
+
args?: string[];
|
|
28
|
+
env?: Record<string, string>;
|
|
29
|
+
status?: 'connected' | 'disconnected' | 'error';
|
|
30
|
+
}
|
|
31
|
+
interface ToolExecutionResult {
|
|
32
|
+
toolName: string;
|
|
33
|
+
success: boolean;
|
|
34
|
+
output?: unknown;
|
|
35
|
+
error?: string;
|
|
36
|
+
durationMs: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @file mcpEngine.ts
|
|
41
|
+
* @description Master Model Context Protocol (MCP) server manager and dispatcher
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
declare class MCPEngine {
|
|
45
|
+
private servers;
|
|
46
|
+
private registeredTools;
|
|
47
|
+
private toolHandlers;
|
|
48
|
+
registerServer(config: MCPServerConfig): void;
|
|
49
|
+
getServer(id: string): MCPServerConfig | undefined;
|
|
50
|
+
listServers(): MCPServerConfig[];
|
|
51
|
+
registerTool(tool: MCPTool, handler?: (args: any) => Promise<any>): void;
|
|
52
|
+
listTools(): MCPTool[];
|
|
53
|
+
executeTool(toolName: string, args: Record<string, unknown>): Promise<ToolExecutionResult>;
|
|
54
|
+
}
|
|
55
|
+
declare const mcpEngine: MCPEngine;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @file ToolManagerService.ts
|
|
59
|
+
* @description General-purpose Tool Registry and Lifecycle Orchestrator
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
declare class ToolManagerService {
|
|
63
|
+
registerTool(tool: MCPTool, handler?: (args: any) => Promise<any>): void;
|
|
64
|
+
listTools(): MCPTool[];
|
|
65
|
+
execute(toolName: string, args: Record<string, unknown>): Promise<ToolExecutionResult>;
|
|
66
|
+
}
|
|
67
|
+
declare const toolManagerService: ToolManagerService;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @file toolValidationLoop.ts
|
|
71
|
+
* @description Validates tool inputs and payload schemas before tool invocation
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
interface ToolInputValidationResult {
|
|
75
|
+
valid: boolean;
|
|
76
|
+
errors: string[];
|
|
77
|
+
}
|
|
78
|
+
declare function validateToolInput(tool: MCPTool, input: Record<string, unknown>): ToolInputValidationResult;
|
|
79
|
+
|
|
80
|
+
export { MCPEngine, type MCPServerConfig, type MCPTool, type MCPToolParameter, type ToolExecutionResult, type ToolInputValidationResult, ToolManagerService, mcpEngine, toolManagerService, validateToolInput };
|