@digilogiclabs/platform-core 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.
@@ -1,3 +1,4 @@
1
+ import { I as ICache, a as ILogger, b as ITracing, c as IAI } from './IAI-D8wA_i8N.js';
1
2
  import { z } from 'zod';
2
3
 
3
4
  /**
@@ -48,71 +49,6 @@ interface IQueryBuilder<T = unknown> {
48
49
  execute(): Promise<QueryResult<T>>;
49
50
  }
50
51
 
51
- /**
52
- * Cache abstraction interface
53
- * Provides a vendor-agnostic way to interact with key-value caches
54
- */
55
- interface ICacheOptions {
56
- /** Time to live in seconds */
57
- ttl?: number;
58
- /** Cache key prefix */
59
- prefix?: string;
60
- }
61
- interface ICache {
62
- /**
63
- * Get a value from cache
64
- */
65
- get<T = unknown>(key: string): Promise<T | null>;
66
- /**
67
- * Set a value in cache
68
- */
69
- set<T = unknown>(key: string, value: T, ttl?: number): Promise<void>;
70
- /**
71
- * Delete a value from cache
72
- */
73
- delete(key: string): Promise<void>;
74
- /**
75
- * Check if key exists
76
- */
77
- exists(key: string): Promise<boolean>;
78
- /**
79
- * Delete all keys matching pattern
80
- */
81
- deletePattern(pattern: string): Promise<number>;
82
- /**
83
- * Get multiple values
84
- */
85
- mget<T = unknown>(keys: string[]): Promise<(T | null)[]>;
86
- /**
87
- * Set multiple values
88
- */
89
- mset<T = unknown>(entries: Array<{
90
- key: string;
91
- value: T;
92
- ttl?: number;
93
- }>): Promise<void>;
94
- /**
95
- * Increment a numeric value
96
- */
97
- incr(key: string, by?: number): Promise<number>;
98
- /**
99
- * Publish a message to a channel
100
- */
101
- publish(channel: string, message: string): Promise<void>;
102
- /**
103
- * Subscribe to a channel
104
- */
105
- subscribe(channel: string, callback: (message: string) => void): Promise<() => void>;
106
- /**
107
- * Check cache connectivity
108
- */
109
- healthCheck(): Promise<boolean>;
110
- /**
111
- * Close cache connection
112
- */
113
- close(): Promise<void>;
114
- }
115
-
116
52
  /**
117
53
  * Storage abstraction interface
118
54
  * Provides a vendor-agnostic way to interact with file/blob storage
@@ -423,110 +359,6 @@ declare function calculateBackoff(attempt: number, options: BackoffOptions): num
423
359
  */
424
360
  declare function generateJobId(): string;
425
361
 
426
- /**
427
- * Logger Interface
428
- * Standardizes logging across the platform
429
- */
430
- /**
431
- * Log levels in order of severity
432
- */
433
- type LogLevel = "debug" | "info" | "warn" | "error";
434
- /**
435
- * Metadata that can be attached to log entries
436
- */
437
- interface LogMeta {
438
- /** Error object if logging an error */
439
- error?: Error;
440
- /** Duration in milliseconds (for timing operations) */
441
- duration?: number;
442
- /** Request ID for tracing */
443
- requestId?: string;
444
- /** User ID if applicable */
445
- userId?: string;
446
- /** Any additional key-value pairs */
447
- [key: string]: unknown;
448
- }
449
- /**
450
- * A structured log entry
451
- */
452
- interface LogEntry {
453
- /** Log level */
454
- level: LogLevel;
455
- /** Log message */
456
- message: string;
457
- /** When the log was created */
458
- timestamp: Date;
459
- /** Optional metadata */
460
- meta?: LogMeta;
461
- /** Logger context (e.g., service name) */
462
- context?: Record<string, unknown>;
463
- }
464
- /**
465
- * Logger interface for structured logging
466
- */
467
- interface ILogger {
468
- /**
469
- * Log a debug message (for development/troubleshooting)
470
- */
471
- debug(message: string, meta?: LogMeta): void;
472
- /**
473
- * Log an informational message
474
- */
475
- info(message: string, meta?: LogMeta): void;
476
- /**
477
- * Log a warning message
478
- */
479
- warn(message: string, meta?: LogMeta): void;
480
- /**
481
- * Log an error message
482
- */
483
- error(message: string, meta?: LogMeta): void;
484
- /**
485
- * Create a child logger with additional context
486
- * @param context Additional context to include in all logs from this child
487
- */
488
- child(context: Record<string, unknown>): ILogger;
489
- }
490
- /**
491
- * Configuration options for loggers
492
- */
493
- interface LoggerConfig {
494
- /** Minimum level to log */
495
- level?: LogLevel;
496
- /** Whether to pretty print (for development) */
497
- pretty?: boolean;
498
- /** Service name to include in logs */
499
- service?: string;
500
- /** Environment name */
501
- environment?: string;
502
- }
503
- /**
504
- * Console logger implementation (for development)
505
- */
506
- declare class ConsoleLogger implements ILogger {
507
- private context;
508
- private level;
509
- private static levelPriority;
510
- constructor(config?: LoggerConfig);
511
- private shouldLog;
512
- private log;
513
- debug(message: string, meta?: LogMeta): void;
514
- info(message: string, meta?: LogMeta): void;
515
- warn(message: string, meta?: LogMeta): void;
516
- error(message: string, meta?: LogMeta): void;
517
- child(context: Record<string, unknown>): ILogger;
518
- }
519
- /**
520
- * No-op logger for testing or when logging is disabled
521
- */
522
- declare class NoopLogger implements ILogger {
523
- debug(): void;
524
- info(): void;
525
- warn(): void;
526
- error(): void;
527
- child(): ILogger;
528
- }
529
-
530
362
  /**
531
363
  * Metrics Interface
532
364
  *
@@ -705,554 +537,6 @@ interface TimingStats extends HistogramStats {
705
537
  */
706
538
  declare function createScopedMetrics(metrics: IMetrics, prefix: string, defaultTags?: MetricTags): IMetrics;
707
539
 
708
- /**
709
- * Distributed Tracing Interface
710
- *
711
- * Provides vendor-agnostic distributed tracing for observability.
712
- * Supports OpenTelemetry, Jaeger, Zipkin, and custom implementations.
713
- */
714
- type SpanKind = "internal" | "server" | "client" | "producer" | "consumer";
715
- type SpanStatusCode = "unset" | "ok" | "error";
716
- interface SpanStatus {
717
- code: SpanStatusCode;
718
- message?: string;
719
- }
720
- interface SpanContext {
721
- traceId: string;
722
- spanId: string;
723
- traceFlags: number;
724
- traceState?: string;
725
- }
726
- interface SpanOptions {
727
- /** Type of span */
728
- kind?: SpanKind;
729
- /** Initial attributes */
730
- attributes?: Record<string, string | number | boolean>;
731
- /** Parent span (for manual context propagation) */
732
- parent?: ISpan;
733
- /** Links to other spans */
734
- links?: SpanContext[];
735
- /** Start time (defaults to now) */
736
- startTime?: number;
737
- }
738
- interface SpanEvent {
739
- name: string;
740
- timestamp: number;
741
- attributes?: Record<string, string | number | boolean>;
742
- }
743
- interface ISpan {
744
- /** Span name */
745
- readonly name: string;
746
- /** Span context (trace ID, span ID) */
747
- readonly context: SpanContext;
748
- /** Whether the span is recording */
749
- readonly isRecording: boolean;
750
- /**
751
- * Set a single attribute
752
- */
753
- setAttribute(key: string, value: string | number | boolean): this;
754
- /**
755
- * Set multiple attributes
756
- */
757
- setAttributes(attributes: Record<string, string | number | boolean>): this;
758
- /**
759
- * Add an event to the span
760
- */
761
- addEvent(name: string, attributes?: Record<string, string | number | boolean>): this;
762
- /**
763
- * Set the span status
764
- */
765
- setStatus(status: SpanStatus): this;
766
- /**
767
- * Record an exception
768
- */
769
- recordException(exception: Error, attributes?: Record<string, string | number | boolean>): this;
770
- /**
771
- * Update the span name
772
- */
773
- updateName(name: string): this;
774
- /**
775
- * End the span (required to export)
776
- */
777
- end(endTime?: number): void;
778
- }
779
- interface ITracing {
780
- /**
781
- * Create and start a new span
782
- */
783
- startSpan(name: string, options?: SpanOptions): ISpan;
784
- /**
785
- * Get the currently active span
786
- */
787
- getCurrentSpan(): ISpan | undefined;
788
- /**
789
- * Execute a function within a span context
790
- */
791
- withSpan<T>(name: string, fn: (span: ISpan) => T, options?: SpanOptions): T;
792
- /**
793
- * Execute an async function within a span context
794
- */
795
- withSpanAsync<T>(name: string, fn: (span: ISpan) => Promise<T>, options?: SpanOptions): Promise<T>;
796
- /**
797
- * Instrument a function with automatic span creation
798
- */
799
- instrument<TArgs extends unknown[], TReturn>(name: string, fn: (...args: TArgs) => TReturn, options?: SpanOptions): (...args: TArgs) => TReturn;
800
- /**
801
- * Instrument an async function with automatic span creation
802
- */
803
- instrumentAsync<TArgs extends unknown[], TReturn>(name: string, fn: (...args: TArgs) => Promise<TReturn>, options?: SpanOptions): (...args: TArgs) => Promise<TReturn>;
804
- /**
805
- * Extract trace context from headers (for incoming requests)
806
- */
807
- extractContext(headers: Record<string, string | string[] | undefined>): SpanContext | undefined;
808
- /**
809
- * Inject trace context into headers (for outgoing requests)
810
- */
811
- injectContext(headers: Record<string, string>): void;
812
- /**
813
- * Check if tracing is enabled and healthy
814
- */
815
- healthCheck(): Promise<boolean>;
816
- /**
817
- * Flush pending spans to the exporter
818
- */
819
- flush(): Promise<void>;
820
- /**
821
- * Shutdown the tracer
822
- */
823
- close(): Promise<void>;
824
- }
825
- interface TracingConfig {
826
- /** Enable tracing */
827
- enabled: boolean;
828
- /** Service name for traces */
829
- serviceName: string;
830
- /** Service version */
831
- serviceVersion?: string;
832
- /** Environment (dev, staging, production) */
833
- environment?: string;
834
- /** Sampling rate (0.0 to 1.0) */
835
- sampleRate?: number;
836
- /** Exporter type */
837
- exporter?: "console" | "otlp" | "jaeger" | "zipkin" | "none";
838
- /** Exporter endpoint */
839
- endpoint?: string;
840
- /** Additional resource attributes */
841
- resourceAttributes?: Record<string, string>;
842
- /** Propagation format */
843
- propagation?: "w3c" | "b3" | "jaeger";
844
- }
845
- declare class MemorySpan implements ISpan {
846
- readonly name: string;
847
- readonly context: SpanContext;
848
- readonly isRecording: boolean;
849
- private _attributes;
850
- private _events;
851
- private _status;
852
- private _endTime?;
853
- private _startTime;
854
- constructor(name: string, traceId: string, parentSpanId?: string);
855
- private generateSpanId;
856
- setAttribute(key: string, value: string | number | boolean): this;
857
- setAttributes(attributes: Record<string, string | number | boolean>): this;
858
- addEvent(name: string, attributes?: Record<string, string | number | boolean>): this;
859
- setStatus(status: SpanStatus): this;
860
- recordException(exception: Error, attributes?: Record<string, string | number | boolean>): this;
861
- updateName(name: string): this;
862
- end(endTime?: number): void;
863
- getAttributes(): Record<string, string | number | boolean>;
864
- getEvents(): SpanEvent[];
865
- getStatus(): SpanStatus;
866
- getDuration(): number | undefined;
867
- isEnded(): boolean;
868
- }
869
- declare class MemoryTracing implements ITracing {
870
- private spans;
871
- private currentSpan;
872
- private traceId;
873
- constructor();
874
- private generateTraceId;
875
- startSpan(name: string, options?: SpanOptions): ISpan;
876
- getCurrentSpan(): ISpan | undefined;
877
- withSpan<T>(name: string, fn: (span: ISpan) => T, options?: SpanOptions): T;
878
- withSpanAsync<T>(name: string, fn: (span: ISpan) => Promise<T>, options?: SpanOptions): Promise<T>;
879
- instrument<TArgs extends unknown[], TReturn>(name: string, fn: (...args: TArgs) => TReturn, options?: SpanOptions): (...args: TArgs) => TReturn;
880
- instrumentAsync<TArgs extends unknown[], TReturn>(name: string, fn: (...args: TArgs) => Promise<TReturn>, options?: SpanOptions): (...args: TArgs) => Promise<TReturn>;
881
- extractContext(headers: Record<string, string | string[] | undefined>): SpanContext | undefined;
882
- injectContext(headers: Record<string, string>): void;
883
- healthCheck(): Promise<boolean>;
884
- flush(): Promise<void>;
885
- close(): Promise<void>;
886
- getSpans(): MemorySpan[];
887
- getCompletedSpans(): MemorySpan[];
888
- clear(): void;
889
- }
890
- declare class NoopTracing implements ITracing {
891
- private noopSpan;
892
- startSpan(): ISpan;
893
- getCurrentSpan(): ISpan | undefined;
894
- withSpan<T>(_name: string, fn: (span: ISpan) => T): T;
895
- withSpanAsync<T>(_name: string, fn: (span: ISpan) => Promise<T>): Promise<T>;
896
- instrument<TArgs extends unknown[], TReturn>(_name: string, fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
897
- instrumentAsync<TArgs extends unknown[], TReturn>(_name: string, fn: (...args: TArgs) => Promise<TReturn>): (...args: TArgs) => Promise<TReturn>;
898
- extractContext(): SpanContext | undefined;
899
- injectContext(): void;
900
- healthCheck(): Promise<boolean>;
901
- flush(): Promise<void>;
902
- close(): Promise<void>;
903
- }
904
-
905
- /**
906
- * IAI - Core AI abstraction interface for platform-core
907
- *
908
- * Provides a vendor-agnostic interface for AI operations including:
909
- * - Text generation (chat, completion)
910
- * - Embeddings generation
911
- * - Model routing and fallback
912
- * - Streaming support
913
- * - Token usage tracking
914
- */
915
- type AIProvider = "openai" | "anthropic" | "google" | "azure" | "bedrock" | "custom";
916
- type AIModelType = "chat" | "completion" | "embedding" | "image" | "audio" | "video";
917
- type AIRole = "system" | "user" | "assistant" | "function" | "tool";
918
- interface AIMessage {
919
- role: AIRole;
920
- content: string;
921
- name?: string;
922
- toolCallId?: string;
923
- toolCalls?: AIToolCall[];
924
- }
925
- interface AIToolCall {
926
- id: string;
927
- type: "function";
928
- function: {
929
- name: string;
930
- arguments: string;
931
- };
932
- }
933
- interface AITool {
934
- type: "function";
935
- function: {
936
- name: string;
937
- description: string;
938
- parameters: Record<string, unknown>;
939
- };
940
- }
941
- interface AIModelConfig {
942
- /** Model identifier (e.g., 'gpt-4', 'claude-3-opus') */
943
- modelId: string;
944
- /** Provider for this model */
945
- provider: AIProvider;
946
- /** Model capabilities */
947
- capabilities: AIModelType[];
948
- /** Maximum context window in tokens */
949
- maxContextTokens: number;
950
- /** Maximum output tokens */
951
- maxOutputTokens: number;
952
- /** Cost per 1K input tokens in USD */
953
- inputCostPer1K: number;
954
- /** Cost per 1K output tokens in USD */
955
- outputCostPer1K: number;
956
- /** Supports streaming */
957
- supportsStreaming: boolean;
958
- /** Supports function/tool calling */
959
- supportsTools: boolean;
960
- /** Supports vision (image input) */
961
- supportsVision: boolean;
962
- /** Rate limits per minute */
963
- rateLimits?: {
964
- requestsPerMinute: number;
965
- tokensPerMinute: number;
966
- };
967
- /** Custom endpoint for self-hosted models */
968
- endpoint?: string;
969
- /** Additional provider-specific config */
970
- providerConfig?: Record<string, unknown>;
971
- }
972
- interface AIChatRequest {
973
- messages: AIMessage[];
974
- model?: string;
975
- temperature?: number;
976
- maxTokens?: number;
977
- topP?: number;
978
- frequencyPenalty?: number;
979
- presencePenalty?: number;
980
- stop?: string | string[];
981
- tools?: AITool[];
982
- toolChoice?: "auto" | "none" | "required" | {
983
- type: "function";
984
- function: {
985
- name: string;
986
- };
987
- };
988
- stream?: boolean;
989
- user?: string;
990
- metadata?: Record<string, unknown>;
991
- }
992
- interface AICompletionRequest {
993
- prompt: string;
994
- model?: string;
995
- temperature?: number;
996
- maxTokens?: number;
997
- topP?: number;
998
- frequencyPenalty?: number;
999
- presencePenalty?: number;
1000
- stop?: string | string[];
1001
- stream?: boolean;
1002
- user?: string;
1003
- metadata?: Record<string, unknown>;
1004
- }
1005
- interface AIEmbeddingRequest {
1006
- input: string | string[];
1007
- model?: string;
1008
- dimensions?: number;
1009
- user?: string;
1010
- metadata?: Record<string, unknown>;
1011
- }
1012
- interface AIChatResponse {
1013
- id: string;
1014
- model: string;
1015
- provider: AIProvider;
1016
- choices: AIChatChoice[];
1017
- usage: AIUsageInfo;
1018
- created: Date;
1019
- finishReason: AIFinishReason;
1020
- }
1021
- interface AIChatChoice {
1022
- index: number;
1023
- message: AIMessage;
1024
- finishReason: AIFinishReason;
1025
- }
1026
- type AIFinishReason = "stop" | "length" | "tool_calls" | "content_filter" | "error";
1027
- interface AICompletionResponse {
1028
- id: string;
1029
- model: string;
1030
- provider: AIProvider;
1031
- text: string;
1032
- usage: AIUsageInfo;
1033
- created: Date;
1034
- finishReason: AIFinishReason;
1035
- }
1036
- interface AIEmbeddingResponse {
1037
- id: string;
1038
- model: string;
1039
- provider: AIProvider;
1040
- embeddings: number[][];
1041
- usage: AIUsageInfo;
1042
- created: Date;
1043
- }
1044
- interface AIUsageInfo {
1045
- promptTokens: number;
1046
- completionTokens: number;
1047
- totalTokens: number;
1048
- estimatedCostUsd: number;
1049
- }
1050
- interface AIStreamChunk {
1051
- id: string;
1052
- model: string;
1053
- provider: AIProvider;
1054
- delta: {
1055
- content?: string;
1056
- toolCalls?: AIToolCall[];
1057
- role?: AIRole;
1058
- };
1059
- finishReason?: AIFinishReason;
1060
- usage?: AIUsageInfo;
1061
- }
1062
- type AIStreamCallback = (chunk: AIStreamChunk) => void | Promise<void>;
1063
- type RoutingStrategy = "priority" | "round-robin" | "least-latency" | "cost-optimized" | "random";
1064
- interface AIRouterConfig {
1065
- /** Primary model to use */
1066
- primaryModel: string;
1067
- /** Fallback models in order of preference */
1068
- fallbackModels?: string[];
1069
- /** Routing strategy for load balancing */
1070
- strategy?: RoutingStrategy;
1071
- /** Maximum retries before failing */
1072
- maxRetries?: number;
1073
- /** Timeout in milliseconds */
1074
- timeoutMs?: number;
1075
- /** Enable automatic fallback on errors */
1076
- autoFallback?: boolean;
1077
- /** Cost budget per request in USD (for cost-optimized routing) */
1078
- costBudget?: number;
1079
- /** Custom routing function */
1080
- customRouter?: (request: AIChatRequest | AICompletionRequest) => string;
1081
- }
1082
- type AIErrorCode = "invalid_request" | "authentication_error" | "rate_limit_exceeded" | "quota_exceeded" | "model_not_found" | "context_length_exceeded" | "content_filter" | "server_error" | "timeout" | "network_error" | "provider_unavailable" | "unknown";
1083
- interface AIError extends Error {
1084
- code: AIErrorCode;
1085
- provider?: AIProvider;
1086
- model?: string;
1087
- statusCode?: number;
1088
- retryable: boolean;
1089
- retryAfterMs?: number;
1090
- }
1091
- declare const AIErrorMessages: Record<AIErrorCode, string>;
1092
- declare function createAIError(code: AIErrorCode, message?: string, options?: {
1093
- provider?: AIProvider;
1094
- model?: string;
1095
- statusCode?: number;
1096
- retryable?: boolean;
1097
- retryAfterMs?: number;
1098
- cause?: Error;
1099
- }): AIError;
1100
- declare function isAIError(error: unknown): error is AIError;
1101
- interface AIConfig {
1102
- /** Default model for chat requests */
1103
- defaultChatModel?: string;
1104
- /** Default model for completion requests */
1105
- defaultCompletionModel?: string;
1106
- /** Default model for embedding requests */
1107
- defaultEmbeddingModel?: string;
1108
- /** Router configuration */
1109
- router?: AIRouterConfig;
1110
- /** Available model configurations */
1111
- models?: AIModelConfig[];
1112
- /** API keys for providers */
1113
- apiKeys?: Partial<Record<AIProvider, string>>;
1114
- /** Default timeout in milliseconds */
1115
- defaultTimeoutMs?: number;
1116
- /** Enable request/response logging */
1117
- enableLogging?: boolean;
1118
- /** Cache embeddings */
1119
- cacheEmbeddings?: boolean;
1120
- /** Embedding cache TTL in seconds */
1121
- embeddingCacheTtlSeconds?: number;
1122
- }
1123
- /**
1124
- * IAI - Core AI interface
1125
- *
1126
- * @example
1127
- * ```typescript
1128
- * const ai = platform.ai;
1129
- *
1130
- * // Chat completion
1131
- * const response = await ai.chat({
1132
- * messages: [
1133
- * { role: 'system', content: 'You are a helpful assistant.' },
1134
- * { role: 'user', content: 'Hello!' }
1135
- * ]
1136
- * });
1137
- *
1138
- * // Streaming chat
1139
- * for await (const chunk of ai.chatStream({
1140
- * messages: [{ role: 'user', content: 'Tell me a story' }]
1141
- * })) {
1142
- * process.stdout.write(chunk.delta.content || '');
1143
- * }
1144
- *
1145
- * // Embeddings
1146
- * const embeddings = await ai.embed({
1147
- * input: ['Hello world', 'Goodbye world']
1148
- * });
1149
- * ```
1150
- */
1151
- interface IAI {
1152
- /**
1153
- * Send a chat completion request
1154
- */
1155
- chat(request: AIChatRequest): Promise<AIChatResponse>;
1156
- /**
1157
- * Send a streaming chat completion request
1158
- */
1159
- chatStream(request: AIChatRequest): AsyncIterable<AIStreamChunk>;
1160
- /**
1161
- * Send a chat completion request with callback-based streaming
1162
- */
1163
- chatWithCallback(request: AIChatRequest, callback: AIStreamCallback): Promise<AIChatResponse>;
1164
- /**
1165
- * Send a text completion request
1166
- */
1167
- complete(request: AICompletionRequest): Promise<AICompletionResponse>;
1168
- /**
1169
- * Send a streaming completion request
1170
- */
1171
- completeStream(request: AICompletionRequest): AsyncIterable<AIStreamChunk>;
1172
- /**
1173
- * Generate embeddings for text
1174
- */
1175
- embed(request: AIEmbeddingRequest): Promise<AIEmbeddingResponse>;
1176
- /**
1177
- * Calculate similarity between two texts
1178
- */
1179
- similarity(text1: string, text2: string, model?: string): Promise<number>;
1180
- /**
1181
- * List available models
1182
- */
1183
- listModels(): Promise<AIModelConfig[]>;
1184
- /**
1185
- * Get model configuration
1186
- */
1187
- getModel(modelId: string): Promise<AIModelConfig | null>;
1188
- /**
1189
- * Check if a model supports a capability
1190
- */
1191
- supportsCapability(modelId: string, capability: AIModelType): Promise<boolean>;
1192
- /**
1193
- * Estimate tokens for text
1194
- */
1195
- estimateTokens(text: string, model?: string): Promise<number>;
1196
- /**
1197
- * Estimate cost for a request
1198
- */
1199
- estimateCost(request: AIChatRequest | AICompletionRequest | AIEmbeddingRequest): Promise<number>;
1200
- /**
1201
- * Check if AI service is healthy
1202
- */
1203
- healthCheck(): Promise<{
1204
- healthy: boolean;
1205
- providers: Record<AIProvider, {
1206
- available: boolean;
1207
- latencyMs?: number;
1208
- error?: string;
1209
- }>;
1210
- }>;
1211
- }
1212
- /**
1213
- * MemoryAI - In-memory implementation for testing
1214
- */
1215
- declare class MemoryAI implements IAI {
1216
- private config;
1217
- private models;
1218
- private responses;
1219
- private embeddings;
1220
- private requestLog;
1221
- constructor(config?: AIConfig);
1222
- setResponse(key: string, response: AIChatResponse | AICompletionResponse): void;
1223
- setEmbedding(text: string, embedding: number[]): void;
1224
- getRequestLog(): Array<{
1225
- type: string;
1226
- request: unknown;
1227
- timestamp: Date;
1228
- }>;
1229
- clearRequestLog(): void;
1230
- chat(request: AIChatRequest): Promise<AIChatResponse>;
1231
- chatStream(request: AIChatRequest): AsyncIterable<AIStreamChunk>;
1232
- chatWithCallback(request: AIChatRequest, callback: AIStreamCallback): Promise<AIChatResponse>;
1233
- complete(request: AICompletionRequest): Promise<AICompletionResponse>;
1234
- completeStream(request: AICompletionRequest): AsyncIterable<AIStreamChunk>;
1235
- embed(request: AIEmbeddingRequest): Promise<AIEmbeddingResponse>;
1236
- similarity(text1: string, text2: string, model?: string): Promise<number>;
1237
- listModels(): Promise<AIModelConfig[]>;
1238
- getModel(modelId: string): Promise<AIModelConfig | null>;
1239
- supportsCapability(modelId: string, capability: AIModelType): Promise<boolean>;
1240
- estimateTokens(text: string, _model?: string): Promise<number>;
1241
- estimateCost(request: AIChatRequest | AICompletionRequest | AIEmbeddingRequest): Promise<number>;
1242
- healthCheck(): Promise<{
1243
- healthy: boolean;
1244
- providers: Record<AIProvider, {
1245
- available: boolean;
1246
- latencyMs?: number;
1247
- error?: string;
1248
- }>;
1249
- }>;
1250
- private estimateTokensSync;
1251
- private calculateCost;
1252
- private generateMockEmbedding;
1253
- private cosineSimilarity;
1254
- }
1255
-
1256
540
  /**
1257
541
  * IRAG - Retrieval Augmented Generation interface
1258
542
  *
@@ -2862,4 +2146,4 @@ declare class ConsoleEmail implements IEmail {
2862
2146
  private formatAddresses;
2863
2147
  }
2864
2148
 
2865
- export { type AIModelType as $, type JobState as A, type JobEventType as B, ConsoleEmail as C, type DeterministicEncryptedField as D, EnvSecrets as E, type JobEventHandler as F, type IAI as G, type AIConfig as H, type IPlatform as I, type Job as J, type KeyRotationResult as K, type AIChatRequest as L, MemoryDatabase as M, NoopLogger as N, type AIChatResponse as O, type PlatformHealthStatus as P, type QueryResult as Q, type RepeatOptions as R, type StorageFile as S, type AIStreamChunk as T, type UploadOptions as U, type AIStreamCallback as V, type AICompletionRequest as W, type AICompletionResponse as X, type AIEmbeddingRequest as Y, type AIEmbeddingResponse as Z, type AIModelConfig as _, MemoryCache as a, NoopTracing as a$, type AIProvider as a0, type IRAG as a1, type RAGConfig as a2, type CreateCollectionOptions as a3, type RAGCollection as a4, type RAGDocument as a5, type IngestionOptions as a6, type BulkIngestionResult as a7, type IngestionResult as a8, type DocumentStatus as a9, createAIError as aA, isAIError as aB, AIErrorMessages as aC, MemoryAI as aD, type AIRole as aE, type AIMessage as aF, type AIToolCall as aG, type AITool as aH, type AIChatChoice as aI, type AIFinishReason as aJ, type AIUsageInfo as aK, type RoutingStrategy as aL, type AIRouterConfig as aM, type AIErrorCode as aN, type AIError as aO, MemoryRAG as aP, ChunkingPresets as aQ, type ChunkingStrategy as aR, type ChunkingConfig as aS, type SearchMode as aT, type RAGFilter as aU, type RAGPipelineStep as aV, type CryptoKeyStatus as aW, type CryptoAlgorithm as aX, createPlatformAsync as aY, createScopedMetrics as aZ, MemoryTracing as a_, type RAGChunk as aa, type RAGSearchQuery as ab, type RAGSearchResponse as ac, type RAGSearchResult as ad, type ContextAssemblyConfig as ae, type AssembledContext as af, type RAGPipeline as ag, type ICacheOptions as ah, type JobResult as ai, type JobContext as aj, type JobEvent as ak, type QueueStats as al, type BackoffOptions as am, type LogLevel as an, type LogMeta as ao, type LogEntry as ap, type LoggerConfig as aq, type MetricTags as ar, type HistogramStats as as, type TimingStats as at, type Secret as au, type SecretMetadata as av, type GetSecretOptions as aw, type SetSecretOptions as ax, type RotateSecretOptions as ay, type RotationResult as az, MemoryStorage as b, type ITracing as b0, type ISpan as b1, type SpanContext as b2, type SpanOptions as b3, type SpanStatus as b4, type SpanKind as b5, type TracingConfig as b6, type EmailAddress as b7, type EmailAttachment as b8, calculateBackoff as b9, LoggingConfigSchema as bA, MetricsConfigSchema as bB, TracingConfigSchema as bC, ObservabilityConfigSchema as bD, MiddlewareConfigSchema as bE, PlatformConfigSchema as bF, type PlatformConfig as bG, type DatabaseConfig as bH, type CacheConfig as bI, type StorageConfig as bJ, type EmailConfig as bK, type QueueConfig as bL, type ResilienceConfig as bM, type ObservabilityConfig as bN, type MiddlewareConfig as bO, type CryptoConfig as bP, type SecurityConfig as bQ, loadConfig as bR, validateConfig as bS, safeValidateConfig as bT, getDefaultConfig as bU, generateJobId as ba, type SpanStatusCode as bb, type SpanEvent as bc, DatabaseProviderSchema as bd, CacheProviderSchema as be, StorageProviderSchema as bf, EmailProviderSchema as bg, QueueProviderSchema as bh, TracingProviderSchema as bi, LogLevelSchema as bj, AIProviderSchema as bk, RAGProviderSchema as bl, DatabaseConfigSchema as bm, CacheConfigSchema as bn, StorageConfigSchema as bo, EmailConfigSchema as bp, QueueConfigSchema as bq, AIConfigSchema as br, RAGConfigSchema as bs, CryptoConfigSchema as bt, SecurityConfigSchema as bu, RetryConfigSchema as bv, CircuitBreakerConfigSchema as bw, TimeoutConfigSchema as bx, BulkheadConfigSchema as by, ResilienceConfigSchema as bz, MemoryEmail as c, MemoryQueue as d, type IDatabase as e, MemorySecrets as f, createPlatform as g, ConsoleLogger as h, MemoryMetrics as i, NoopMetrics as j, type IQueryBuilder as k, type ICache as l, type IStorage as m, type IEmail as n, type IQueue as o, type ILogger as p, type IMetrics as q, type ISecrets as r, type JobOptions as s, type EmailMessage as t, type MetricsSummary as u, type ICrypto as v, type EncryptOptions as w, type EncryptedField as x, type CryptoKeyMetadata as y, type EmailResult as z };
2149
+ export { type RAGPipeline as $, type RAGConfig as A, type CreateCollectionOptions as B, ConsoleEmail as C, type DeterministicEncryptedField as D, EnvSecrets as E, type RAGCollection as F, type RAGDocument as G, type IngestionOptions as H, type IPlatform as I, type Job as J, type KeyRotationResult as K, type BulkIngestionResult as L, MemoryDatabase as M, NoopMetrics as N, type IngestionResult as O, type PlatformHealthStatus as P, type QueryResult as Q, type RepeatOptions as R, type StorageFile as S, type DocumentStatus as T, type UploadOptions as U, type RAGChunk as V, type RAGSearchQuery as W, type RAGSearchResponse as X, type RAGSearchResult as Y, type ContextAssemblyConfig as Z, type AssembledContext as _, MemoryCache as a, type QueueConfig as a$, type JobResult as a0, type JobContext as a1, type JobEvent as a2, type QueueStats as a3, type BackoffOptions as a4, type MetricTags as a5, type HistogramStats as a6, type TimingStats as a7, type Secret as a8, type SecretMetadata as a9, AIProviderSchema as aA, RAGProviderSchema as aB, DatabaseConfigSchema as aC, CacheConfigSchema as aD, StorageConfigSchema as aE, EmailConfigSchema as aF, QueueConfigSchema as aG, AIConfigSchema as aH, RAGConfigSchema as aI, CryptoConfigSchema as aJ, SecurityConfigSchema as aK, RetryConfigSchema as aL, CircuitBreakerConfigSchema as aM, TimeoutConfigSchema as aN, BulkheadConfigSchema as aO, ResilienceConfigSchema as aP, LoggingConfigSchema as aQ, MetricsConfigSchema as aR, TracingConfigSchema as aS, ObservabilityConfigSchema as aT, MiddlewareConfigSchema as aU, PlatformConfigSchema as aV, type PlatformConfig as aW, type DatabaseConfig as aX, type CacheConfig as aY, type StorageConfig as aZ, type EmailConfig as a_, type GetSecretOptions as aa, type SetSecretOptions as ab, type RotateSecretOptions as ac, type RotationResult as ad, MemoryRAG as ae, ChunkingPresets as af, type ChunkingStrategy as ag, type ChunkingConfig as ah, type SearchMode as ai, type RAGFilter as aj, type RAGPipelineStep as ak, type CryptoKeyStatus as al, type CryptoAlgorithm as am, createPlatformAsync as an, createScopedMetrics as ao, type EmailAddress as ap, type EmailAttachment as aq, calculateBackoff as ar, generateJobId as as, DatabaseProviderSchema as at, CacheProviderSchema as au, StorageProviderSchema as av, EmailProviderSchema as aw, QueueProviderSchema as ax, TracingProviderSchema as ay, LogLevelSchema as az, MemoryStorage as b, type ResilienceConfig as b0, type ObservabilityConfig as b1, type MiddlewareConfig as b2, type CryptoConfig as b3, type SecurityConfig as b4, loadConfig as b5, validateConfig as b6, safeValidateConfig as b7, getDefaultConfig as b8, MemoryEmail as c, MemoryQueue as d, type IDatabase as e, MemorySecrets as f, createPlatform as g, MemoryMetrics as h, type IQueryBuilder as i, type IStorage as j, type IEmail as k, type IQueue as l, type IMetrics as m, type ISecrets as n, type JobOptions as o, type EmailMessage as p, type MetricsSummary as q, type ICrypto as r, type EncryptOptions as s, type EncryptedField as t, type CryptoKeyMetadata as u, type EmailResult as v, type JobState as w, type JobEventType as x, type JobEventHandler as y, type IRAG as z };