@retrivora-ai/rag-engine 2.3.6 → 2.3.8

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.
Files changed (34) hide show
  1. package/dist/{BatchProcessor-Dfn23VAd.d.mts → BatchProcessor-BhLczWj5.d.mts} +100 -2
  2. package/dist/{BatchProcessor-ByBl-1MA.d.ts → BatchProcessor-C42_RVWO.d.ts} +100 -2
  3. package/dist/handlers/index.d.mts +1 -1
  4. package/dist/handlers/index.d.ts +1 -1
  5. package/dist/handlers/index.js +340 -172
  6. package/dist/handlers/index.mjs +342 -174
  7. package/dist/{index-ejOWsaqb.d.ts → index-BQd6Bax0.d.ts} +1 -1
  8. package/dist/{index-xxQOFx-u.d.mts → index-C7aHK7_g.d.mts} +1 -1
  9. package/dist/index.d.mts +2 -2
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +114 -87
  12. package/dist/index.mjs +114 -87
  13. package/dist/server.d.mts +263 -37
  14. package/dist/server.d.ts +263 -37
  15. package/dist/server.js +957 -178
  16. package/dist/server.mjs +949 -180
  17. package/package.json +1 -1
  18. package/src/LicensedRetrivora.ts +273 -0
  19. package/src/components/ChatWidget.tsx +0 -1
  20. package/src/components/ConfigProvider.tsx +2 -1
  21. package/src/config/LicenseConfigResolver.ts +296 -0
  22. package/src/config/serverConfig.ts +75 -16
  23. package/src/core/ConfigFetcher.ts +36 -3
  24. package/src/core/DatabaseStorage.ts +13 -13
  25. package/src/core/LicenseValidator.ts +5 -3
  26. package/src/core/LicenseVerifier.ts +85 -120
  27. package/src/core/Retrivora.ts +1 -1
  28. package/src/core/VectorPlugin.ts +1 -1
  29. package/src/handlers/index.ts +25 -11
  30. package/src/index.ts +9 -0
  31. package/src/llm/providers/UniversalLLMAdapter.ts +67 -12
  32. package/src/providers/vectordb/PineconeProvider.ts +69 -2
  33. package/src/server.ts +23 -1
  34. package/src/telemetry/TelemetryService.ts +330 -0
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, MouseEvent, ReactNode, ElementType } from 'react';
2
- import { W as WidgetPosition, Z as Product, s as UIConfig, P as ProjectChatSettings, o as RagMessage, w as VectorMatch, J as UITransformationResponse, n as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, _ as RetrievalResult, t as UniversalRagConfig } from './ILLMProvider-B8TAVx3j.mjs';
2
+ import { W as WidgetPosition, Z as Product, s as UIConfig, P as ProjectChatSettings, o as RagMessage, w as VectorMatch, L as LLMConfig, d as EmbeddingConfig, V as VectorDBConfig, J as UITransformationResponse, n as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, _ as RetrievalResult, t as UniversalRagConfig } from './ILLMProvider-B8TAVx3j.mjs';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -219,6 +219,104 @@ declare class ConfigFetcher {
219
219
  static fetchRemoteVectorConfig(projectId: string, licenseKey?: string): Promise<RemoteVectorConfig | null>;
220
220
  }
221
221
 
222
+ /**
223
+ * LicenseConfigResolver — Resolves LLM and embedding configuration
224
+ * based on the user's license tier from Retrivora admin dashboard.
225
+ *
226
+ * The end-user SDK only needs:
227
+ * - licenseKey (JWT token from Retrivora)
228
+ * - projectId (workspace identifier)
229
+ *
230
+ * Configuration includes:
231
+ * 1. Tier-based model selection (/api/v1/config)
232
+ * 2. Provider API credentials (/api/v1/credentials)
233
+ * 3. Vector DB and rate limit settings
234
+ *
235
+ * All provider API keys (Gemini, Groq, Pinecone) are stored on Retrivora backend
236
+ * and never exposed to end-users directly.
237
+ */
238
+
239
+ interface LicenseTierConfig {
240
+ tier: 'free_trial' | 'free' | 'hobby' | 'pro' | 'enterprise';
241
+ llmModel: string;
242
+ embeddingModel: string;
243
+ embeddingDimensions: number;
244
+ maxTokens: number;
245
+ chunkSize: number;
246
+ chunkOverlap: number;
247
+ topK: number;
248
+ vectorDb: {
249
+ provider: string;
250
+ indexName: string;
251
+ };
252
+ rateLimit?: {
253
+ requestsPerMinute: number;
254
+ tokensPerDay: number;
255
+ };
256
+ }
257
+ interface ProviderCredentials {
258
+ geminiApiKey?: string;
259
+ groqApiKey?: string;
260
+ pineconeApiKey?: string;
261
+ textEmbeddingProvider?: string;
262
+ }
263
+ interface ProviderCredentials {
264
+ geminiApiKey?: string;
265
+ groqApiKey?: string;
266
+ pineconeApiKey?: string;
267
+ textEmbeddingProvider?: string;
268
+ }
269
+ /**
270
+ * Resolver for license-based configuration.
271
+ * This is called by the end-user SDK after they instantiate with licenseKey + projectId.
272
+ */
273
+ declare class LicenseConfigResolver {
274
+ private static readonly RETRIVORA_CONFIG_URL;
275
+ private static readonly RETRIVORA_CREDENTIALS_URL;
276
+ private static readonly CACHE_TTL_MS;
277
+ private static configCache;
278
+ /**
279
+ * Validate and resolve configuration from license key
280
+ * @param licenseKey JWT token from Retrivora (format: rtv_eyJ...)
281
+ * @param projectId Workspace identifier
282
+ * @returns Resolved LLM and embedding configs with provider credentials
283
+ */
284
+ static resolveFromLicense(licenseKey: string, projectId: string): Promise<{
285
+ llmConfig: LLMConfig;
286
+ embeddingConfig: EmbeddingConfig;
287
+ vectorDbConfig: VectorDBConfig;
288
+ tierConfig: LicenseTierConfig;
289
+ credentials: ProviderCredentials;
290
+ }>;
291
+ /**
292
+ * Fetch tier configuration from Retrivora config API
293
+ */
294
+ private static fetchTierConfig;
295
+ /**
296
+ * Fetch provider credentials from Retrivora credentials API
297
+ */
298
+ private static fetchProviderCredentials;
299
+ /**
300
+ * Build LLM, embedding, and vector DB configs from tier and credentials
301
+ */
302
+ private static buildConfigs;
303
+ /**
304
+ * Get provider-specific vector DB options
305
+ */
306
+ private static getVectorDbOptions;
307
+ /**
308
+ * Clear configuration cache (useful for testing or manual refresh)
309
+ */
310
+ static clearCache(): void;
311
+ /**
312
+ * Get cache stats for debugging
313
+ */
314
+ static getCacheStats(): {
315
+ size: number;
316
+ entries: string[];
317
+ };
318
+ }
319
+
222
320
  /**
223
321
  * Primary rendering outcome types supported by the decision engine.
224
322
  */
@@ -661,4 +759,4 @@ declare class BatchProcessor {
661
759
  static processConcurrent<T, R>(items: T[], processor: (item: T) => Promise<R>, concurrency?: number, options?: BatchOptions): Promise<BatchResult<R>>;
662
760
  }
663
761
 
664
- export { AuthenticationException as A, type BatchOptions as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, RetrivoraError as F, type RetrivoraErrorCode as G, SDKVersionUnsupportedError as H, type IRenderRule as I, SDK_VERSION as J, isTransientError as K, LicenseValidationError as L, type MessageBubbleProps as M, type ArchitectureCardProps as N, type ChatViewportSize as O, type ProductCardProps as P, DocumentChunker as Q, type RemoteConfig as R, type SourceCardProps as S, Pipeline as T, type PipelineStep as U, type ProviderPill as V, type RenderSectionDecision as W, type Snippet as X, wrapError as Y, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, BatchProcessor as e, type BatchResult as f, type ChartType as g, type Chunk as h, type ChunkOptions as i, ConfigFetcher as j, ConfigurationException as k, type DecisionContext as l, type IRendererStrategy as m, type IntentCategory as n, type LicenseValidationRequest as o, type LicenseValidationResponse as p, LicenseValidator as q, ProviderNotFoundException as r, RateLimitException as s, type RemoteEmbeddingConfig as t, type RemoteLLMConfig as u, type RemoteVectorConfig as v, type RenderDecision as w, type RenderType as x, RetrievalException as y, Retrivora as z };
762
+ export { wrapError as $, AuthenticationException as A, type BatchOptions as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, RetrievalException as F, Retrivora as G, RetrivoraError as H, type IRenderRule as I, type RetrivoraErrorCode as J, SDKVersionUnsupportedError as K, type LicenseTierConfig as L, type MessageBubbleProps as M, SDK_VERSION as N, isTransientError as O, type ProductCardProps as P, type ArchitectureCardProps as Q, type RemoteConfig as R, type SourceCardProps as S, type ChatViewportSize as T, DocumentChunker as U, LicenseConfigResolver as V, Pipeline as W, type PipelineStep as X, type ProviderPill as Y, type RenderSectionDecision as Z, type Snippet as _, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, BatchProcessor as e, type BatchResult as f, type ChartType as g, type Chunk as h, type ChunkOptions as i, ConfigFetcher as j, ConfigurationException as k, type DecisionContext as l, type IRendererStrategy as m, type IntentCategory as n, LicenseValidationError as o, type LicenseValidationRequest as p, type LicenseValidationResponse as q, LicenseValidator as r, type ProviderCredentials as s, ProviderNotFoundException as t, RateLimitException as u, type RemoteEmbeddingConfig as v, type RemoteLLMConfig as w, type RemoteVectorConfig as x, type RenderDecision as y, type RenderType as z };
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, MouseEvent, ReactNode, ElementType } from 'react';
2
- import { W as WidgetPosition, Z as Product, s as UIConfig, P as ProjectChatSettings, o as RagMessage, w as VectorMatch, J as UITransformationResponse, n as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, _ as RetrievalResult, t as UniversalRagConfig } from './ILLMProvider-B8TAVx3j.js';
2
+ import { W as WidgetPosition, Z as Product, s as UIConfig, P as ProjectChatSettings, o as RagMessage, w as VectorMatch, L as LLMConfig, d as EmbeddingConfig, V as VectorDBConfig, J as UITransformationResponse, n as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, _ as RetrievalResult, t as UniversalRagConfig } from './ILLMProvider-B8TAVx3j.js';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -219,6 +219,104 @@ declare class ConfigFetcher {
219
219
  static fetchRemoteVectorConfig(projectId: string, licenseKey?: string): Promise<RemoteVectorConfig | null>;
220
220
  }
221
221
 
222
+ /**
223
+ * LicenseConfigResolver — Resolves LLM and embedding configuration
224
+ * based on the user's license tier from Retrivora admin dashboard.
225
+ *
226
+ * The end-user SDK only needs:
227
+ * - licenseKey (JWT token from Retrivora)
228
+ * - projectId (workspace identifier)
229
+ *
230
+ * Configuration includes:
231
+ * 1. Tier-based model selection (/api/v1/config)
232
+ * 2. Provider API credentials (/api/v1/credentials)
233
+ * 3. Vector DB and rate limit settings
234
+ *
235
+ * All provider API keys (Gemini, Groq, Pinecone) are stored on Retrivora backend
236
+ * and never exposed to end-users directly.
237
+ */
238
+
239
+ interface LicenseTierConfig {
240
+ tier: 'free_trial' | 'free' | 'hobby' | 'pro' | 'enterprise';
241
+ llmModel: string;
242
+ embeddingModel: string;
243
+ embeddingDimensions: number;
244
+ maxTokens: number;
245
+ chunkSize: number;
246
+ chunkOverlap: number;
247
+ topK: number;
248
+ vectorDb: {
249
+ provider: string;
250
+ indexName: string;
251
+ };
252
+ rateLimit?: {
253
+ requestsPerMinute: number;
254
+ tokensPerDay: number;
255
+ };
256
+ }
257
+ interface ProviderCredentials {
258
+ geminiApiKey?: string;
259
+ groqApiKey?: string;
260
+ pineconeApiKey?: string;
261
+ textEmbeddingProvider?: string;
262
+ }
263
+ interface ProviderCredentials {
264
+ geminiApiKey?: string;
265
+ groqApiKey?: string;
266
+ pineconeApiKey?: string;
267
+ textEmbeddingProvider?: string;
268
+ }
269
+ /**
270
+ * Resolver for license-based configuration.
271
+ * This is called by the end-user SDK after they instantiate with licenseKey + projectId.
272
+ */
273
+ declare class LicenseConfigResolver {
274
+ private static readonly RETRIVORA_CONFIG_URL;
275
+ private static readonly RETRIVORA_CREDENTIALS_URL;
276
+ private static readonly CACHE_TTL_MS;
277
+ private static configCache;
278
+ /**
279
+ * Validate and resolve configuration from license key
280
+ * @param licenseKey JWT token from Retrivora (format: rtv_eyJ...)
281
+ * @param projectId Workspace identifier
282
+ * @returns Resolved LLM and embedding configs with provider credentials
283
+ */
284
+ static resolveFromLicense(licenseKey: string, projectId: string): Promise<{
285
+ llmConfig: LLMConfig;
286
+ embeddingConfig: EmbeddingConfig;
287
+ vectorDbConfig: VectorDBConfig;
288
+ tierConfig: LicenseTierConfig;
289
+ credentials: ProviderCredentials;
290
+ }>;
291
+ /**
292
+ * Fetch tier configuration from Retrivora config API
293
+ */
294
+ private static fetchTierConfig;
295
+ /**
296
+ * Fetch provider credentials from Retrivora credentials API
297
+ */
298
+ private static fetchProviderCredentials;
299
+ /**
300
+ * Build LLM, embedding, and vector DB configs from tier and credentials
301
+ */
302
+ private static buildConfigs;
303
+ /**
304
+ * Get provider-specific vector DB options
305
+ */
306
+ private static getVectorDbOptions;
307
+ /**
308
+ * Clear configuration cache (useful for testing or manual refresh)
309
+ */
310
+ static clearCache(): void;
311
+ /**
312
+ * Get cache stats for debugging
313
+ */
314
+ static getCacheStats(): {
315
+ size: number;
316
+ entries: string[];
317
+ };
318
+ }
319
+
222
320
  /**
223
321
  * Primary rendering outcome types supported by the decision engine.
224
322
  */
@@ -661,4 +759,4 @@ declare class BatchProcessor {
661
759
  static processConcurrent<T, R>(items: T[], processor: (item: T) => Promise<R>, concurrency?: number, options?: BatchOptions): Promise<BatchResult<R>>;
662
760
  }
663
761
 
664
- export { AuthenticationException as A, type BatchOptions as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, RetrivoraError as F, type RetrivoraErrorCode as G, SDKVersionUnsupportedError as H, type IRenderRule as I, SDK_VERSION as J, isTransientError as K, LicenseValidationError as L, type MessageBubbleProps as M, type ArchitectureCardProps as N, type ChatViewportSize as O, type ProductCardProps as P, DocumentChunker as Q, type RemoteConfig as R, type SourceCardProps as S, Pipeline as T, type PipelineStep as U, type ProviderPill as V, type RenderSectionDecision as W, type Snippet as X, wrapError as Y, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, BatchProcessor as e, type BatchResult as f, type ChartType as g, type Chunk as h, type ChunkOptions as i, ConfigFetcher as j, ConfigurationException as k, type DecisionContext as l, type IRendererStrategy as m, type IntentCategory as n, type LicenseValidationRequest as o, type LicenseValidationResponse as p, LicenseValidator as q, ProviderNotFoundException as r, RateLimitException as s, type RemoteEmbeddingConfig as t, type RemoteLLMConfig as u, type RemoteVectorConfig as v, type RenderDecision as w, type RenderType as x, RetrievalException as y, Retrivora as z };
762
+ export { wrapError as $, AuthenticationException as A, type BatchOptions as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, RetrievalException as F, Retrivora as G, RetrivoraError as H, type IRenderRule as I, type RetrivoraErrorCode as J, SDKVersionUnsupportedError as K, type LicenseTierConfig as L, type MessageBubbleProps as M, SDK_VERSION as N, isTransientError as O, type ProductCardProps as P, type ArchitectureCardProps as Q, type RemoteConfig as R, type SourceCardProps as S, type ChatViewportSize as T, DocumentChunker as U, LicenseConfigResolver as V, Pipeline as W, type PipelineStep as X, type ProviderPill as Y, type RenderSectionDecision as Z, type Snippet as _, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, BatchProcessor as e, type BatchResult as f, type ChartType as g, type Chunk as h, type ChunkOptions as i, ConfigFetcher as j, ConfigurationException as k, type DecisionContext as l, type IRendererStrategy as m, type IntentCategory as n, LicenseValidationError as o, type LicenseValidationRequest as p, type LicenseValidationResponse as q, LicenseValidator as r, type ProviderCredentials as s, ProviderNotFoundException as t, RateLimitException as u, type RemoteEmbeddingConfig as v, type RemoteLLMConfig as w, type RemoteVectorConfig as x, type RenderDecision as y, type RenderType as z };
@@ -1,3 +1,3 @@
1
1
  import 'next/server';
2
- export { b as HandlerOptions, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, p as createLicenseHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, q as createSuggestionsHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, r as sseObservabilityFrame, o as sseTextFrame, t as sseUIFrame } from '../index-xxQOFx-u.mjs';
2
+ export { b as HandlerOptions, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, p as createLicenseHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, q as createSuggestionsHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, r as sseObservabilityFrame, o as sseTextFrame, t as sseUIFrame } from '../index-C7aHK7_g.mjs';
3
3
  import '../ILLMProvider-B8TAVx3j.mjs';
@@ -1,3 +1,3 @@
1
1
  import 'next/server';
2
- export { b as HandlerOptions, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, p as createLicenseHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, q as createSuggestionsHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, r as sseObservabilityFrame, o as sseTextFrame, t as sseUIFrame } from '../index-ejOWsaqb.js';
2
+ export { b as HandlerOptions, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, p as createLicenseHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, q as createSuggestionsHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, r as sseObservabilityFrame, o as sseTextFrame, t as sseUIFrame } from '../index-BQd6Bax0.js';
3
3
  import '../ILLMProvider-B8TAVx3j.js';