ai.matey.types 0.2.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/LICENSE +21 -0
- package/dist/cjs/adapters.js +16 -0
- package/dist/cjs/adapters.js.map +1 -0
- package/dist/cjs/bridge.js +32 -0
- package/dist/cjs/bridge.js.map +1 -0
- package/dist/cjs/errors.js +121 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +44 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/ir.js +17 -0
- package/dist/cjs/ir.js.map +1 -0
- package/dist/cjs/middleware.js +11 -0
- package/dist/cjs/middleware.js.map +1 -0
- package/dist/cjs/model-runner.js +11 -0
- package/dist/cjs/model-runner.js.map +1 -0
- package/dist/cjs/model-translation.js +10 -0
- package/dist/cjs/model-translation.js.map +1 -0
- package/dist/cjs/models.js +11 -0
- package/dist/cjs/models.js.map +1 -0
- package/dist/cjs/router.js +93 -0
- package/dist/cjs/router.js.map +1 -0
- package/dist/cjs/streaming.js +28 -0
- package/dist/cjs/streaming.js.map +1 -0
- package/dist/esm/adapters.js +15 -0
- package/dist/esm/adapters.js.map +1 -0
- package/dist/esm/bridge.js +29 -0
- package/dist/esm/bridge.js.map +1 -0
- package/dist/esm/errors.js +118 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +28 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/ir.js +16 -0
- package/dist/esm/ir.js.map +1 -0
- package/dist/esm/middleware.js +10 -0
- package/dist/esm/middleware.js.map +1 -0
- package/dist/esm/model-runner.js +10 -0
- package/dist/esm/model-runner.js.map +1 -0
- package/dist/esm/model-translation.js +9 -0
- package/dist/esm/model-translation.js.map +1 -0
- package/dist/esm/models.js +10 -0
- package/dist/esm/models.js.map +1 -0
- package/dist/esm/router.js +90 -0
- package/dist/esm/router.js.map +1 -0
- package/dist/esm/streaming.js +25 -0
- package/dist/esm/streaming.js.map +1 -0
- package/dist/types/adapters.d.ts +377 -0
- package/dist/types/adapters.d.ts.map +1 -0
- package/dist/types/bridge.d.ts +290 -0
- package/dist/types/bridge.d.ts.map +1 -0
- package/dist/types/errors.d.ts +380 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/ir.d.ts +820 -0
- package/dist/types/ir.d.ts.map +1 -0
- package/dist/types/middleware.d.ts +256 -0
- package/dist/types/middleware.d.ts.map +1 -0
- package/dist/types/model-runner.d.ts +344 -0
- package/dist/types/model-runner.d.ts.map +1 -0
- package/dist/types/model-translation.d.ts +76 -0
- package/dist/types/model-translation.d.ts.map +1 -0
- package/dist/types/models.d.ts +160 -0
- package/dist/types/models.d.ts.map +1 -0
- package/dist/types/router.d.ts +526 -0
- package/dist/types/router.d.ts.map +1 -0
- package/dist/types/streaming.d.ts +96 -0
- package/dist/types/streaming.d.ts.map +1 -0
- package/package.json +64 -0
- package/readme.md +84 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router Types and Interfaces
|
|
3
|
+
*
|
|
4
|
+
* The Router manages multiple backend adapters and provides intelligent routing,
|
|
5
|
+
* fallback strategies, and parallel dispatch capabilities.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { BackendAdapter, AdapterMetadata } from './adapters.js';
|
|
10
|
+
import type { IRChatRequest, IRChatResponse, IRChatStream } from './ir.js';
|
|
11
|
+
import type { AdapterError } from './errors.js';
|
|
12
|
+
import type { ModelTranslationConfig, ModelMapping } from './model-translation.js';
|
|
13
|
+
export type { ModelMapping };
|
|
14
|
+
/**
|
|
15
|
+
* Fallback strategies for handling backend failures.
|
|
16
|
+
*/
|
|
17
|
+
export declare const FallbackStrategy: {
|
|
18
|
+
/**
|
|
19
|
+
* No fallback - fail immediately if primary backend fails.
|
|
20
|
+
*/
|
|
21
|
+
readonly NONE: "none";
|
|
22
|
+
/**
|
|
23
|
+
* Try backends sequentially in order until one succeeds.
|
|
24
|
+
*/
|
|
25
|
+
readonly SEQUENTIAL: "sequential";
|
|
26
|
+
/**
|
|
27
|
+
* Try all backends in parallel, return first success.
|
|
28
|
+
*/
|
|
29
|
+
readonly PARALLEL: "parallel";
|
|
30
|
+
/**
|
|
31
|
+
* Use custom fallback logic.
|
|
32
|
+
*/
|
|
33
|
+
readonly CUSTOM: "custom";
|
|
34
|
+
};
|
|
35
|
+
export type FallbackStrategy = (typeof FallbackStrategy)[keyof typeof FallbackStrategy];
|
|
36
|
+
/**
|
|
37
|
+
* Routing strategies for selecting backends.
|
|
38
|
+
*/
|
|
39
|
+
export declare const RoutingStrategy: {
|
|
40
|
+
/**
|
|
41
|
+
* Use backend specified in request options.
|
|
42
|
+
*/
|
|
43
|
+
readonly EXPLICIT: "explicit";
|
|
44
|
+
/**
|
|
45
|
+
* Route based on model name.
|
|
46
|
+
*/
|
|
47
|
+
readonly MODEL_BASED: "model-based";
|
|
48
|
+
/**
|
|
49
|
+
* Route to least-cost backend.
|
|
50
|
+
*/
|
|
51
|
+
readonly COST_OPTIMIZED: "cost-optimized";
|
|
52
|
+
/**
|
|
53
|
+
* Route to fastest backend (lowest latency).
|
|
54
|
+
*/
|
|
55
|
+
readonly LATENCY_OPTIMIZED: "latency-optimized";
|
|
56
|
+
/**
|
|
57
|
+
* Round-robin load balancing.
|
|
58
|
+
*/
|
|
59
|
+
readonly ROUND_ROBIN: "round-robin";
|
|
60
|
+
/**
|
|
61
|
+
* Random backend selection.
|
|
62
|
+
*/
|
|
63
|
+
readonly RANDOM: "random";
|
|
64
|
+
/**
|
|
65
|
+
* Use custom routing logic.
|
|
66
|
+
*/
|
|
67
|
+
readonly CUSTOM: "custom";
|
|
68
|
+
};
|
|
69
|
+
export type RoutingStrategy = (typeof RoutingStrategy)[keyof typeof RoutingStrategy];
|
|
70
|
+
/**
|
|
71
|
+
* Router configuration options.
|
|
72
|
+
*/
|
|
73
|
+
export interface RouterConfig {
|
|
74
|
+
/**
|
|
75
|
+
* Primary routing strategy.
|
|
76
|
+
* @default 'explicit'
|
|
77
|
+
*/
|
|
78
|
+
readonly routingStrategy?: RoutingStrategy;
|
|
79
|
+
/**
|
|
80
|
+
* Fallback strategy when primary backend fails.
|
|
81
|
+
* @default 'sequential'
|
|
82
|
+
*/
|
|
83
|
+
readonly fallbackStrategy?: FallbackStrategy;
|
|
84
|
+
/**
|
|
85
|
+
* Default backend to use if routing doesn't select one.
|
|
86
|
+
*/
|
|
87
|
+
readonly defaultBackend?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Interval for health checking backends (milliseconds).
|
|
90
|
+
* Set to 0 to disable health checks.
|
|
91
|
+
* @default 0
|
|
92
|
+
*/
|
|
93
|
+
readonly healthCheckInterval?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Enable circuit breaker pattern.
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
readonly enableCircuitBreaker?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Number of consecutive failures before circuit breaker opens.
|
|
101
|
+
* @default 5
|
|
102
|
+
*/
|
|
103
|
+
readonly circuitBreakerThreshold?: number;
|
|
104
|
+
/**
|
|
105
|
+
* Time to wait before attempting to close circuit breaker (milliseconds).
|
|
106
|
+
* @default 60000
|
|
107
|
+
*/
|
|
108
|
+
readonly circuitBreakerTimeout?: number;
|
|
109
|
+
/**
|
|
110
|
+
* Track latency statistics per backend.
|
|
111
|
+
* @default true
|
|
112
|
+
*/
|
|
113
|
+
readonly trackLatency?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Track cost per backend (requires backends to implement estimateCost).
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
readonly trackCost?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Enable capability-based routing.
|
|
121
|
+
* When enabled, the router will select backends based on their model capabilities
|
|
122
|
+
* matching the request requirements.
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
125
|
+
readonly capabilityBasedRouting?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Optimization strategy for capability-based routing.
|
|
128
|
+
* Determines how to weigh cost, speed, and quality when selecting models.
|
|
129
|
+
* @default 'balanced'
|
|
130
|
+
*/
|
|
131
|
+
readonly optimization?: 'cost' | 'speed' | 'quality' | 'balanced';
|
|
132
|
+
/**
|
|
133
|
+
* Custom optimization weights for capability-based routing.
|
|
134
|
+
* Must sum to 1.0. Overrides optimization preset.
|
|
135
|
+
*/
|
|
136
|
+
readonly optimizationWeights?: {
|
|
137
|
+
cost: number;
|
|
138
|
+
speed: number;
|
|
139
|
+
quality: number;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Cache duration for model capability data in milliseconds.
|
|
143
|
+
* @default 3600000 (1 hour)
|
|
144
|
+
*/
|
|
145
|
+
readonly capabilityCacheDuration?: number;
|
|
146
|
+
/**
|
|
147
|
+
* Custom routing function.
|
|
148
|
+
*/
|
|
149
|
+
readonly customRouter?: CustomRoutingFunction;
|
|
150
|
+
/**
|
|
151
|
+
* Custom fallback function.
|
|
152
|
+
*/
|
|
153
|
+
readonly customFallback?: CustomFallbackFunction;
|
|
154
|
+
/**
|
|
155
|
+
* Model translation configuration for fallback scenarios.
|
|
156
|
+
* Controls how model names are translated when falling back to different backends.
|
|
157
|
+
* @default { strategy: 'hybrid', warnOnDefault: true, strictMode: false }
|
|
158
|
+
*/
|
|
159
|
+
readonly modelTranslation?: ModelTranslationConfig;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Custom routing function signature.
|
|
163
|
+
*/
|
|
164
|
+
export type CustomRoutingFunction = (request: IRChatRequest, availableBackends: readonly string[], context: RoutingContext) => Promise<string | null>;
|
|
165
|
+
/**
|
|
166
|
+
* Custom fallback function signature.
|
|
167
|
+
*/
|
|
168
|
+
export type CustomFallbackFunction = (request: IRChatRequest, failedBackend: string, error: AdapterError, attemptedBackends: readonly string[], availableBackends: readonly string[]) => Promise<string | null>;
|
|
169
|
+
/**
|
|
170
|
+
* Context provided to routing functions.
|
|
171
|
+
*/
|
|
172
|
+
export interface RoutingContext {
|
|
173
|
+
/**
|
|
174
|
+
* Backend statistics for making informed decisions.
|
|
175
|
+
*/
|
|
176
|
+
readonly stats: RouterStats;
|
|
177
|
+
/**
|
|
178
|
+
* Request metadata.
|
|
179
|
+
*/
|
|
180
|
+
readonly metadata: Record<string, unknown>;
|
|
181
|
+
/**
|
|
182
|
+
* Preferred backend from request options (if any).
|
|
183
|
+
*/
|
|
184
|
+
readonly preferredBackend?: string;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Information about a registered backend.
|
|
188
|
+
*/
|
|
189
|
+
export interface BackendInfo {
|
|
190
|
+
/**
|
|
191
|
+
* Backend identifier.
|
|
192
|
+
*/
|
|
193
|
+
readonly name: string;
|
|
194
|
+
/**
|
|
195
|
+
* Backend adapter instance.
|
|
196
|
+
*/
|
|
197
|
+
readonly adapter: BackendAdapter;
|
|
198
|
+
/**
|
|
199
|
+
* Backend metadata.
|
|
200
|
+
*/
|
|
201
|
+
readonly metadata: AdapterMetadata;
|
|
202
|
+
/**
|
|
203
|
+
* Whether backend is currently healthy.
|
|
204
|
+
*/
|
|
205
|
+
readonly isHealthy: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Last health check timestamp.
|
|
208
|
+
*/
|
|
209
|
+
readonly lastHealthCheck?: number;
|
|
210
|
+
/**
|
|
211
|
+
* Circuit breaker state.
|
|
212
|
+
*/
|
|
213
|
+
readonly circuitBreakerState: 'closed' | 'open' | 'half-open';
|
|
214
|
+
/**
|
|
215
|
+
* Consecutive failures count (for circuit breaker).
|
|
216
|
+
*/
|
|
217
|
+
readonly consecutiveFailures: number;
|
|
218
|
+
/**
|
|
219
|
+
* Statistics for this backend.
|
|
220
|
+
*/
|
|
221
|
+
readonly stats: BackendStats;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Statistics for a single backend.
|
|
225
|
+
*/
|
|
226
|
+
export interface BackendStats {
|
|
227
|
+
/**
|
|
228
|
+
* Total requests routed to this backend.
|
|
229
|
+
*/
|
|
230
|
+
readonly totalRequests: number;
|
|
231
|
+
/**
|
|
232
|
+
* Successful requests.
|
|
233
|
+
*/
|
|
234
|
+
readonly successfulRequests: number;
|
|
235
|
+
/**
|
|
236
|
+
* Failed requests.
|
|
237
|
+
*/
|
|
238
|
+
readonly failedRequests: number;
|
|
239
|
+
/**
|
|
240
|
+
* Success rate (0-100).
|
|
241
|
+
*/
|
|
242
|
+
readonly successRate: number;
|
|
243
|
+
/**
|
|
244
|
+
* Average latency in milliseconds.
|
|
245
|
+
*/
|
|
246
|
+
readonly averageLatencyMs: number;
|
|
247
|
+
/**
|
|
248
|
+
* P50 latency in milliseconds.
|
|
249
|
+
*/
|
|
250
|
+
readonly p50LatencyMs: number;
|
|
251
|
+
/**
|
|
252
|
+
* P95 latency in milliseconds.
|
|
253
|
+
*/
|
|
254
|
+
readonly p95LatencyMs: number;
|
|
255
|
+
/**
|
|
256
|
+
* P99 latency in milliseconds.
|
|
257
|
+
*/
|
|
258
|
+
readonly p99LatencyMs: number;
|
|
259
|
+
/**
|
|
260
|
+
* Total estimated cost (if tracking enabled).
|
|
261
|
+
*/
|
|
262
|
+
readonly totalCost?: number;
|
|
263
|
+
/**
|
|
264
|
+
* Average cost per request (if tracking enabled).
|
|
265
|
+
*/
|
|
266
|
+
readonly averageCost?: number;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Overall router statistics.
|
|
270
|
+
*/
|
|
271
|
+
export interface RouterStats {
|
|
272
|
+
/**
|
|
273
|
+
* Total requests routed.
|
|
274
|
+
*/
|
|
275
|
+
readonly totalRequests: number;
|
|
276
|
+
/**
|
|
277
|
+
* Requests that succeeded on first try.
|
|
278
|
+
*/
|
|
279
|
+
readonly successfulRequests: number;
|
|
280
|
+
/**
|
|
281
|
+
* Requests that failed completely.
|
|
282
|
+
*/
|
|
283
|
+
readonly failedRequests: number;
|
|
284
|
+
/**
|
|
285
|
+
* Requests that required fallback.
|
|
286
|
+
*/
|
|
287
|
+
readonly totalFallbacks: number;
|
|
288
|
+
/**
|
|
289
|
+
* Parallel/fan-out requests.
|
|
290
|
+
*/
|
|
291
|
+
readonly parallelRequests: number;
|
|
292
|
+
/**
|
|
293
|
+
* Per-backend statistics.
|
|
294
|
+
*/
|
|
295
|
+
readonly backendStats: Record<string, BackendStats>;
|
|
296
|
+
/**
|
|
297
|
+
* When statistics were last reset.
|
|
298
|
+
*/
|
|
299
|
+
readonly sinceTimestamp: number;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Strategy for handling parallel dispatch results.
|
|
303
|
+
*/
|
|
304
|
+
export declare const ParallelStrategy: {
|
|
305
|
+
/**
|
|
306
|
+
* Return first successful response, cancel others.
|
|
307
|
+
*/
|
|
308
|
+
readonly FIRST: "first";
|
|
309
|
+
/**
|
|
310
|
+
* Wait for all responses, return array of results.
|
|
311
|
+
*/
|
|
312
|
+
readonly ALL: "all";
|
|
313
|
+
/**
|
|
314
|
+
* Return fastest successful response (with timeout).
|
|
315
|
+
*/
|
|
316
|
+
readonly FASTEST: "fastest";
|
|
317
|
+
/**
|
|
318
|
+
* Use custom aggregation logic.
|
|
319
|
+
*/
|
|
320
|
+
readonly CUSTOM: "custom";
|
|
321
|
+
};
|
|
322
|
+
export type ParallelStrategy = (typeof ParallelStrategy)[keyof typeof ParallelStrategy];
|
|
323
|
+
/**
|
|
324
|
+
* Options for parallel dispatch.
|
|
325
|
+
*/
|
|
326
|
+
export interface ParallelDispatchOptions {
|
|
327
|
+
/**
|
|
328
|
+
* Backend names to dispatch to.
|
|
329
|
+
*/
|
|
330
|
+
readonly backends?: readonly string[];
|
|
331
|
+
/**
|
|
332
|
+
* Parallel dispatch strategy.
|
|
333
|
+
* @default 'first'
|
|
334
|
+
*/
|
|
335
|
+
readonly strategy?: ParallelStrategy;
|
|
336
|
+
/**
|
|
337
|
+
* Timeout for parallel requests (milliseconds).
|
|
338
|
+
*/
|
|
339
|
+
readonly timeout?: number;
|
|
340
|
+
/**
|
|
341
|
+
* Cancel remaining requests on first success.
|
|
342
|
+
* @default true
|
|
343
|
+
*/
|
|
344
|
+
readonly cancelOnFirstSuccess?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Custom aggregation function for 'custom' strategy.
|
|
347
|
+
*/
|
|
348
|
+
readonly customAggregator?: (responses: Array<{
|
|
349
|
+
backend: string;
|
|
350
|
+
response: IRChatResponse;
|
|
351
|
+
latencyMs: number;
|
|
352
|
+
}>) => IRChatResponse;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Result of parallel dispatch.
|
|
356
|
+
*/
|
|
357
|
+
export interface ParallelDispatchResult {
|
|
358
|
+
/**
|
|
359
|
+
* Primary response (based on strategy).
|
|
360
|
+
*/
|
|
361
|
+
readonly response: IRChatResponse;
|
|
362
|
+
/**
|
|
363
|
+
* All responses (only for 'all' strategy).
|
|
364
|
+
*/
|
|
365
|
+
readonly allResponses?: Array<{
|
|
366
|
+
readonly backend: string;
|
|
367
|
+
readonly response: IRChatResponse;
|
|
368
|
+
readonly latencyMs: number;
|
|
369
|
+
}>;
|
|
370
|
+
/**
|
|
371
|
+
* Backends that succeeded.
|
|
372
|
+
*/
|
|
373
|
+
readonly successfulBackends: readonly string[];
|
|
374
|
+
/**
|
|
375
|
+
* Backends that failed.
|
|
376
|
+
*/
|
|
377
|
+
readonly failedBackends: Array<{
|
|
378
|
+
readonly backend: string;
|
|
379
|
+
readonly error: AdapterError;
|
|
380
|
+
}>;
|
|
381
|
+
/**
|
|
382
|
+
* Total time for parallel dispatch (milliseconds).
|
|
383
|
+
*/
|
|
384
|
+
readonly totalTimeMs: number;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Model pattern to backend mapping.
|
|
388
|
+
*/
|
|
389
|
+
export interface ModelPatternMapping {
|
|
390
|
+
/**
|
|
391
|
+
* Regular expression pattern to match model names.
|
|
392
|
+
*/
|
|
393
|
+
readonly pattern: RegExp;
|
|
394
|
+
/**
|
|
395
|
+
* Backend name to route matching models to.
|
|
396
|
+
*/
|
|
397
|
+
readonly backend: string;
|
|
398
|
+
/**
|
|
399
|
+
* Optional target model name to use (for translation during fallback).
|
|
400
|
+
* If not specified, original model name is passed through.
|
|
401
|
+
*/
|
|
402
|
+
readonly targetModel?: string;
|
|
403
|
+
/**
|
|
404
|
+
* Pattern matching priority (higher = checked first).
|
|
405
|
+
* @default 0
|
|
406
|
+
*/
|
|
407
|
+
readonly priority?: number;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Router manages multiple backend adapters with intelligent routing.
|
|
411
|
+
*/
|
|
412
|
+
export interface Router extends BackendAdapter<unknown, unknown> {
|
|
413
|
+
/**
|
|
414
|
+
* Router configuration.
|
|
415
|
+
*/
|
|
416
|
+
readonly config: RouterConfig;
|
|
417
|
+
/**
|
|
418
|
+
* Register a backend adapter.
|
|
419
|
+
*/
|
|
420
|
+
register(name: string, adapter: BackendAdapter): Router;
|
|
421
|
+
/**
|
|
422
|
+
* Unregister a backend adapter.
|
|
423
|
+
*/
|
|
424
|
+
unregister(name: string): Router;
|
|
425
|
+
/**
|
|
426
|
+
* Get a registered backend adapter.
|
|
427
|
+
*/
|
|
428
|
+
get(name: string): BackendAdapter | undefined;
|
|
429
|
+
/**
|
|
430
|
+
* Check if backend is registered.
|
|
431
|
+
*/
|
|
432
|
+
has(name: string): boolean;
|
|
433
|
+
/**
|
|
434
|
+
* List all registered backend names.
|
|
435
|
+
*/
|
|
436
|
+
listBackends(): readonly string[];
|
|
437
|
+
/**
|
|
438
|
+
* Get information about all registered backends.
|
|
439
|
+
*/
|
|
440
|
+
getBackendInfo(): BackendInfo[];
|
|
441
|
+
/**
|
|
442
|
+
* Get information about specific backend.
|
|
443
|
+
*/
|
|
444
|
+
getBackendInfo(name: string): BackendInfo | undefined;
|
|
445
|
+
/**
|
|
446
|
+
* Set fallback chain for sequential failover.
|
|
447
|
+
*/
|
|
448
|
+
setFallbackChain(chain: readonly string[]): Router;
|
|
449
|
+
/**
|
|
450
|
+
* Get current fallback chain.
|
|
451
|
+
*/
|
|
452
|
+
getFallbackChain(): readonly string[];
|
|
453
|
+
/**
|
|
454
|
+
* Set model to backend mapping.
|
|
455
|
+
*/
|
|
456
|
+
setModelMapping(mapping: ModelMapping): Router;
|
|
457
|
+
/**
|
|
458
|
+
* Get current model mapping.
|
|
459
|
+
*/
|
|
460
|
+
getModelMapping(): ModelMapping;
|
|
461
|
+
/**
|
|
462
|
+
* Set model pattern mappings.
|
|
463
|
+
*/
|
|
464
|
+
setModelPatterns(patterns: readonly ModelPatternMapping[]): Router;
|
|
465
|
+
/**
|
|
466
|
+
* Get current model patterns.
|
|
467
|
+
*/
|
|
468
|
+
getModelPatterns(): readonly ModelPatternMapping[];
|
|
469
|
+
/**
|
|
470
|
+
* Select backend for a request.
|
|
471
|
+
*/
|
|
472
|
+
selectBackend(request: IRChatRequest, preferredBackend?: string): Promise<string>;
|
|
473
|
+
/**
|
|
474
|
+
* Execute request with automatic backend selection and fallback.
|
|
475
|
+
*/
|
|
476
|
+
execute(request: IRChatRequest, signal?: AbortSignal): Promise<IRChatResponse>;
|
|
477
|
+
/**
|
|
478
|
+
* Execute streaming request with automatic backend selection and fallback.
|
|
479
|
+
*/
|
|
480
|
+
executeStream(request: IRChatRequest, signal?: AbortSignal): IRChatStream;
|
|
481
|
+
/**
|
|
482
|
+
* Dispatch request to multiple backends in parallel.
|
|
483
|
+
*/
|
|
484
|
+
dispatchParallel(request: IRChatRequest, options?: ParallelDispatchOptions, signal?: AbortSignal): Promise<ParallelDispatchResult>;
|
|
485
|
+
/**
|
|
486
|
+
* Check health of all backends.
|
|
487
|
+
*/
|
|
488
|
+
checkHealth(): Promise<Record<string, boolean>>;
|
|
489
|
+
/**
|
|
490
|
+
* Check health of specific backend.
|
|
491
|
+
*/
|
|
492
|
+
checkHealth(name: string): Promise<boolean>;
|
|
493
|
+
/**
|
|
494
|
+
* Manually open circuit breaker for a backend.
|
|
495
|
+
*/
|
|
496
|
+
openCircuitBreaker(name: string, timeoutMs?: number): void;
|
|
497
|
+
/**
|
|
498
|
+
* Manually close circuit breaker for a backend.
|
|
499
|
+
*/
|
|
500
|
+
closeCircuitBreaker(name: string): void;
|
|
501
|
+
/**
|
|
502
|
+
* Reset circuit breaker statistics.
|
|
503
|
+
*/
|
|
504
|
+
resetCircuitBreaker(name?: string): void;
|
|
505
|
+
/**
|
|
506
|
+
* Get router statistics.
|
|
507
|
+
*/
|
|
508
|
+
getStats(): RouterStats;
|
|
509
|
+
/**
|
|
510
|
+
* Reset router statistics.
|
|
511
|
+
*/
|
|
512
|
+
resetStats(): void;
|
|
513
|
+
/**
|
|
514
|
+
* Get statistics for specific backend.
|
|
515
|
+
*/
|
|
516
|
+
getBackendStats(name: string): BackendStats | undefined;
|
|
517
|
+
/**
|
|
518
|
+
* Clone router with new configuration.
|
|
519
|
+
*/
|
|
520
|
+
clone(config: Partial<RouterConfig>): Router;
|
|
521
|
+
/**
|
|
522
|
+
* Clean up resources.
|
|
523
|
+
*/
|
|
524
|
+
dispose(): void;
|
|
525
|
+
}
|
|
526
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/router.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGnF,YAAY,EAAE,YAAY,EAAE,CAAC;AAM7B;;GAEG;AACH,eAAO,MAAM,g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;IAExC;;OAEG;IACH,mBAAmB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAMzC;;OAEG;IACH,QAAQ,IAAI,WAAW,CAAC;IAExB;;OAEG;IACH,UAAU,IAAI,IAAI,CAAC;IAEnB;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;IAMxD;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;IAE7C;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* Defines how streaming responses should be delivered across the system.
|
|
5
|
+
* Supports flexible streaming modes with delta (incremental) and accumulated (full text) formats.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Streaming mode determines how chunks are delivered.
|
|
11
|
+
*
|
|
12
|
+
* - `delta`: Stream only new content chunks (standard behavior, most efficient)
|
|
13
|
+
* - Each chunk contains only the incremental text that was just generated
|
|
14
|
+
* - Consumers must accumulate chunks to get full text
|
|
15
|
+
* - Example: chunk1="Hello", chunk2=" world", chunk3="!"
|
|
16
|
+
*
|
|
17
|
+
* - `accumulated`: Stream full accumulated content so far (Chrome AI behavior)
|
|
18
|
+
* - Each chunk contains all text generated up to that point
|
|
19
|
+
* - Consumers can use the latest chunk directly without accumulation
|
|
20
|
+
* - Example: chunk1="Hello", chunk2="Hello world", chunk3="Hello world!"
|
|
21
|
+
*/
|
|
22
|
+
export type StreamMode = 'delta' | 'accumulated';
|
|
23
|
+
/**
|
|
24
|
+
* Buffer strategy for accumulated mode.
|
|
25
|
+
*/
|
|
26
|
+
export type BufferStrategy = 'memory' | 'none';
|
|
27
|
+
/**
|
|
28
|
+
* Streaming configuration options.
|
|
29
|
+
*/
|
|
30
|
+
export interface StreamingConfig {
|
|
31
|
+
/**
|
|
32
|
+
* How to deliver streaming chunks.
|
|
33
|
+
*
|
|
34
|
+
* - `delta`: Only new content (default, most efficient)
|
|
35
|
+
* - `accumulated`: Full content accumulated so far (Chrome AI style)
|
|
36
|
+
*
|
|
37
|
+
* @default 'delta'
|
|
38
|
+
*/
|
|
39
|
+
mode?: StreamMode;
|
|
40
|
+
/**
|
|
41
|
+
* Whether to include both delta and accumulated in chunks.
|
|
42
|
+
* Only applicable when mode='accumulated' at backend level.
|
|
43
|
+
* When true, chunks will contain both formats for maximum flexibility.
|
|
44
|
+
*
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
includeBoth?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Buffer strategy for accumulated mode.
|
|
50
|
+
*
|
|
51
|
+
* - 'memory': Keep full buffer in memory (default, works with any provider)
|
|
52
|
+
* - 'none': Don't buffer (only works if provider natively gives accumulated)
|
|
53
|
+
*
|
|
54
|
+
* @default 'memory'
|
|
55
|
+
*/
|
|
56
|
+
bufferStrategy?: BufferStrategy;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Options for stream conversion/transformation.
|
|
60
|
+
*/
|
|
61
|
+
export interface StreamConversionOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Target streaming mode for conversion.
|
|
64
|
+
* If specified, stream will be converted to this mode.
|
|
65
|
+
*/
|
|
66
|
+
mode?: StreamMode;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to preserve original format if already in target mode.
|
|
69
|
+
* When true, avoids unnecessary conversion overhead.
|
|
70
|
+
*
|
|
71
|
+
* @default true
|
|
72
|
+
*/
|
|
73
|
+
preserveIfMatch?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Custom buffer transform function.
|
|
76
|
+
* Applied to accumulated text before yielding.
|
|
77
|
+
* Useful for sanitization, formatting, etc.
|
|
78
|
+
*/
|
|
79
|
+
transform?: (text: string) => string;
|
|
80
|
+
/**
|
|
81
|
+
* Whether to validate chunk sequence numbers.
|
|
82
|
+
* When true, throws error if chunks arrive out of order.
|
|
83
|
+
*
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
validateSequence?: boolean;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Default streaming configuration.
|
|
90
|
+
*/
|
|
91
|
+
export declare const DEFAULT_STREAMING_CONFIG: Required<StreamingConfig>;
|
|
92
|
+
/**
|
|
93
|
+
* Default conversion options.
|
|
94
|
+
*/
|
|
95
|
+
export declare const DEFAULT_CONVERSION_OPTIONS: Required<Omit<StreamConversionOptions, 'transform'>>;
|
|
96
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../src/streaming.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,aAAa,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAErC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,eAAe,CAI9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,WAAW,CAAC,CAI3F,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ai.matey.types",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Type definitions for AI Matey - Universal AI Adapter System",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/cjs/index.js",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/types/index.d.ts",
|
|
13
|
+
"default": "./dist/esm/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/types/index.d.ts",
|
|
17
|
+
"default": "./dist/cjs/index.js"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"readme.md",
|
|
24
|
+
"CHANGELOG.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "npm run build:esm && npm run build:cjs && npm run build:types",
|
|
29
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
30
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
31
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
32
|
+
"clean": "rm -rf dist",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"lint": "eslint src --ext .ts",
|
|
35
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:watch": "vitest"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"typescript": "^5.9.3",
|
|
41
|
+
"vitest": "^3.2.4"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"ai",
|
|
45
|
+
"llm",
|
|
46
|
+
"types",
|
|
47
|
+
"typescript",
|
|
48
|
+
"ai-matey"
|
|
49
|
+
],
|
|
50
|
+
"author": "AI Matey",
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"homepage": "https://github.com/johnhenry/ai.matey#readme",
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/johnhenry/ai.matey/issues"
|
|
55
|
+
},
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "git+https://github.com/johnhenry/ai.matey.git",
|
|
59
|
+
"directory": "packages/ai.matey.types"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=18.0.0"
|
|
63
|
+
}
|
|
64
|
+
}
|