@retrivora-ai/rag-engine 2.3.9 → 2.4.1

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 (47) hide show
  1. package/README.md +1 -1
  2. package/dist/{BatchProcessor-C42_RVWO.d.ts → BatchProcessor-D42E706a.d.ts} +12 -1
  3. package/dist/{BatchProcessor-BhLczWj5.d.mts → BatchProcessor-zbQMaZHm.d.mts} +12 -1
  4. package/dist/{ILLMProvider-B8TAVx3j.d.mts → ILLMProvider-Y6aL5N8J.d.mts} +1 -0
  5. package/dist/{ILLMProvider-B8TAVx3j.d.ts → ILLMProvider-Y6aL5N8J.d.ts} +1 -0
  6. package/dist/handlers/index.d.mts +2 -2
  7. package/dist/handlers/index.d.ts +2 -2
  8. package/dist/handlers/index.js +26 -85
  9. package/dist/handlers/index.mjs +26 -85
  10. package/dist/{index-C7aHK7_g.d.mts → index-59CHg0V3.d.mts} +1 -1
  11. package/dist/{index-BQd6Bax0.d.ts → index-BgKRInpa.d.ts} +1 -1
  12. package/dist/index.css +83 -0
  13. package/dist/index.d.mts +5 -5
  14. package/dist/index.d.ts +5 -5
  15. package/dist/index.js +482 -260
  16. package/dist/index.mjs +494 -269
  17. package/dist/server.d.mts +9 -6
  18. package/dist/server.d.ts +9 -6
  19. package/dist/server.js +34 -118
  20. package/dist/server.mjs +34 -118
  21. package/package.json +1 -1
  22. package/src/LicensedRetrivora.ts +21 -16
  23. package/src/components/ChatWindow.tsx +296 -28
  24. package/src/components/ConfigProvider.tsx +10 -1
  25. package/src/components/DocumentUpload.tsx +28 -29
  26. package/src/components/UIDispatcher.tsx +1 -1
  27. package/src/config/LicenseConfigResolver.ts +14 -12
  28. package/src/config/RagConfig.ts +1 -0
  29. package/src/config/serverConfig.ts +31 -29
  30. package/src/config/uiConstants.ts +1 -0
  31. package/src/core/ConfigFetcher.ts +2 -2
  32. package/src/core/LLMRouter.ts +3 -3
  33. package/src/core/PluginManager.ts +5 -5
  34. package/src/core/mcp.ts +5 -5
  35. package/src/handlers/index.ts +11 -5
  36. package/src/hooks/useRagChat.ts +13 -13
  37. package/src/index.css +83 -0
  38. package/src/llm/LLMFactory.ts +1 -1
  39. package/src/llm/providers/UniversalLLMAdapter.ts +18 -18
  40. package/src/providers/graphdb/SimpleGraphProvider.ts +5 -5
  41. package/src/providers/vectordb/ChromaDBProvider.ts +4 -4
  42. package/src/providers/vectordb/MultiTablePostgresProvider.ts +32 -32
  43. package/src/providers/vectordb/QdrantProvider.ts +17 -17
  44. package/src/telemetry/TelemetryService.ts +12 -12
  45. package/src/types/props.ts +11 -0
  46. package/src/utils/SchemaMapper.ts +1 -1
  47. package/src/utils/UITransformer.ts +1 -1
package/dist/server.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { V as VectorDBConfig, L as LLMConfig, d as EmbeddingConfig, n as RagConfig, t as UniversalRagConfig, u as UpsertDocument, w as VectorMatch, G as GraphDBConfig, D as GraphNode, F as Edge, H as GraphSearchResult, I as ILLMProvider, v as VectorDBProvider, g as LLMProvider, e as EmbeddingProvider, R as RAGConfig, s as UIConfig, J as UITransformationResponse, C as ChatMessage, b as ChatOptions, E as EmbedOptions, f as IngestDocument, c as ChatResponse } from './ILLMProvider-B8TAVx3j.mjs';
2
- export { A as AuthMode, K as BarChartData, M as CarouselProduct, N as IRetriever, h as LatencyBreakdown, Q as LineChartDataPoint, S as MessageRole, X as MetricCardData, O as ObservabilityTrace, Y as PieChartData, Z as Product, i as ProjectAiSettings, j as ProjectAuthSettings, k as ProjectBrandingSettings, P as ProjectChatSettings, l as ProjectTelemetrySettings, m as ProjectWidgetSettings, o as RagMessage, p as RetrievalConfig, _ as RetrievalResult, q as RetrievedChunk, $ as RetrivoraChunkMetadata, a0 as RetrivoraIngestedDocument, a1 as ScatterPlotDataPoint, a2 as SuggestionsResponse, a3 as TableData, T as ThemeMode, r as TokenUsage, U as UseRagChatOptions, a as UseRagChatReturn, a4 as VisualizationType, W as WidgetPosition, x as WorkflowConfig, y as createDefaultProjectSettings, z as normalizeProjectSettings, B as projectSettingsToUiConfig } from './ILLMProvider-B8TAVx3j.mjs';
3
- import { l as DecisionContext, n as IntentCategory, I as IRenderRule, y as RenderDecision, m as IRendererStrategy } from './BatchProcessor-BhLczWj5.mjs';
4
- export { Q as ArchitectureCardProps, A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, T as ChatViewportSize, C as ChatWidgetProps, a as ChatWindowProps, h as Chunk, i as ChunkOptions, c as ClientConfig, j as ConfigFetcher, b as ConfigProviderProps, k as ConfigurationException, U as DocumentChunker, D as DocumentUploadProps, E as EmbeddingFailedException, V as LicenseConfigResolver, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, M as MessageBubbleProps, W as Pipeline, X as PipelineStep, P as ProductCardProps, d as ProductCarouselProps, s as ProviderCredentials, t as ProviderNotFoundException, Y as ProviderPill, u as RateLimitException, R as RemoteConfig, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, Z as RenderSectionDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, _ as Snippet, S as SourceCardProps, $ as wrapError } from './BatchProcessor-BhLczWj5.mjs';
5
- import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-C7aHK7_g.mjs';
6
- export { C as ConfigValidator, b as HandlerOptions, V as ValidationError, c as VectorPlugin, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, o as sseTextFrame } from './index-C7aHK7_g.mjs';
1
+ import { V as VectorDBConfig, L as LLMConfig, d as EmbeddingConfig, n as RagConfig, t as UniversalRagConfig, u as UpsertDocument, w as VectorMatch, G as GraphDBConfig, D as GraphNode, F as Edge, H as GraphSearchResult, I as ILLMProvider, v as VectorDBProvider, g as LLMProvider, e as EmbeddingProvider, R as RAGConfig, s as UIConfig, J as UITransformationResponse, C as ChatMessage, b as ChatOptions, E as EmbedOptions, f as IngestDocument, c as ChatResponse } from './ILLMProvider-Y6aL5N8J.mjs';
2
+ export { A as AuthMode, K as BarChartData, M as CarouselProduct, N as IRetriever, h as LatencyBreakdown, Q as LineChartDataPoint, S as MessageRole, X as MetricCardData, O as ObservabilityTrace, Y as PieChartData, Z as Product, i as ProjectAiSettings, j as ProjectAuthSettings, k as ProjectBrandingSettings, P as ProjectChatSettings, l as ProjectTelemetrySettings, m as ProjectWidgetSettings, o as RagMessage, p as RetrievalConfig, _ as RetrievalResult, q as RetrievedChunk, $ as RetrivoraChunkMetadata, a0 as RetrivoraIngestedDocument, a1 as ScatterPlotDataPoint, a2 as SuggestionsResponse, a3 as TableData, T as ThemeMode, r as TokenUsage, U as UseRagChatOptions, a as UseRagChatReturn, a4 as VisualizationType, W as WidgetPosition, x as WorkflowConfig, y as createDefaultProjectSettings, z as normalizeProjectSettings, B as projectSettingsToUiConfig } from './ILLMProvider-Y6aL5N8J.mjs';
3
+ import { l as DecisionContext, n as IntentCategory, I as IRenderRule, y as RenderDecision, m as IRendererStrategy } from './BatchProcessor-zbQMaZHm.mjs';
4
+ export { Q as ArchitectureCardProps, A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, T as ChatViewportSize, C as ChatWidgetProps, a as ChatWindowProps, h as Chunk, i as ChunkOptions, c as ClientConfig, j as ConfigFetcher, b as ConfigProviderProps, k as ConfigurationException, U as DocumentChunker, D as DocumentUploadProps, E as EmbeddingFailedException, V as LicenseConfigResolver, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, M as MessageBubbleProps, W as Pipeline, X as PipelineStep, P as ProductCardProps, d as ProductCarouselProps, s as ProviderCredentials, t as ProviderNotFoundException, Y as ProviderPill, u as RateLimitException, R as RemoteConfig, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, Z as RenderSectionDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, _ as Snippet, S as SourceCardProps, $ as wrapError } from './BatchProcessor-zbQMaZHm.mjs';
5
+ import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-59CHg0V3.mjs';
6
+ export { C as ConfigValidator, b as HandlerOptions, V as ValidationError, c as VectorPlugin, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, o as sseTextFrame } from './index-59CHg0V3.mjs';
7
7
  import 'react';
8
8
  import 'next/server';
9
9
 
@@ -232,6 +232,8 @@ declare class ProviderRegistry {
232
232
  interface RuntimeTierConfig {
233
233
  llmModel?: string;
234
234
  embeddingModel?: string;
235
+ /** Custom system prompt from project configuration */
236
+ systemPrompt?: string;
235
237
  /** LiteLLM master key for authenticating with llm.retrivora.com */
236
238
  litellmApiKey?: string;
237
239
  /** LiteLLM gateway base URL (defaults to https://llm.retrivora.com/api/v1) */
@@ -1158,6 +1160,7 @@ declare class LicensedRetrivora {
1158
1160
  private projectId;
1159
1161
  private pipeline?;
1160
1162
  private ragConfig?;
1163
+ private tierConfig?;
1161
1164
  private initialized;
1162
1165
  constructor(options: LicensedRetrivoraOptions);
1163
1166
  /**
package/dist/server.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { V as VectorDBConfig, L as LLMConfig, d as EmbeddingConfig, n as RagConfig, t as UniversalRagConfig, u as UpsertDocument, w as VectorMatch, G as GraphDBConfig, D as GraphNode, F as Edge, H as GraphSearchResult, I as ILLMProvider, v as VectorDBProvider, g as LLMProvider, e as EmbeddingProvider, R as RAGConfig, s as UIConfig, J as UITransformationResponse, C as ChatMessage, b as ChatOptions, E as EmbedOptions, f as IngestDocument, c as ChatResponse } from './ILLMProvider-B8TAVx3j.js';
2
- export { A as AuthMode, K as BarChartData, M as CarouselProduct, N as IRetriever, h as LatencyBreakdown, Q as LineChartDataPoint, S as MessageRole, X as MetricCardData, O as ObservabilityTrace, Y as PieChartData, Z as Product, i as ProjectAiSettings, j as ProjectAuthSettings, k as ProjectBrandingSettings, P as ProjectChatSettings, l as ProjectTelemetrySettings, m as ProjectWidgetSettings, o as RagMessage, p as RetrievalConfig, _ as RetrievalResult, q as RetrievedChunk, $ as RetrivoraChunkMetadata, a0 as RetrivoraIngestedDocument, a1 as ScatterPlotDataPoint, a2 as SuggestionsResponse, a3 as TableData, T as ThemeMode, r as TokenUsage, U as UseRagChatOptions, a as UseRagChatReturn, a4 as VisualizationType, W as WidgetPosition, x as WorkflowConfig, y as createDefaultProjectSettings, z as normalizeProjectSettings, B as projectSettingsToUiConfig } from './ILLMProvider-B8TAVx3j.js';
3
- import { l as DecisionContext, n as IntentCategory, I as IRenderRule, y as RenderDecision, m as IRendererStrategy } from './BatchProcessor-C42_RVWO.js';
4
- export { Q as ArchitectureCardProps, A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, T as ChatViewportSize, C as ChatWidgetProps, a as ChatWindowProps, h as Chunk, i as ChunkOptions, c as ClientConfig, j as ConfigFetcher, b as ConfigProviderProps, k as ConfigurationException, U as DocumentChunker, D as DocumentUploadProps, E as EmbeddingFailedException, V as LicenseConfigResolver, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, M as MessageBubbleProps, W as Pipeline, X as PipelineStep, P as ProductCardProps, d as ProductCarouselProps, s as ProviderCredentials, t as ProviderNotFoundException, Y as ProviderPill, u as RateLimitException, R as RemoteConfig, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, Z as RenderSectionDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, _ as Snippet, S as SourceCardProps, $ as wrapError } from './BatchProcessor-C42_RVWO.js';
5
- import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-BQd6Bax0.js';
6
- export { C as ConfigValidator, b as HandlerOptions, V as ValidationError, c as VectorPlugin, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, o as sseTextFrame } from './index-BQd6Bax0.js';
1
+ import { V as VectorDBConfig, L as LLMConfig, d as EmbeddingConfig, n as RagConfig, t as UniversalRagConfig, u as UpsertDocument, w as VectorMatch, G as GraphDBConfig, D as GraphNode, F as Edge, H as GraphSearchResult, I as ILLMProvider, v as VectorDBProvider, g as LLMProvider, e as EmbeddingProvider, R as RAGConfig, s as UIConfig, J as UITransformationResponse, C as ChatMessage, b as ChatOptions, E as EmbedOptions, f as IngestDocument, c as ChatResponse } from './ILLMProvider-Y6aL5N8J.js';
2
+ export { A as AuthMode, K as BarChartData, M as CarouselProduct, N as IRetriever, h as LatencyBreakdown, Q as LineChartDataPoint, S as MessageRole, X as MetricCardData, O as ObservabilityTrace, Y as PieChartData, Z as Product, i as ProjectAiSettings, j as ProjectAuthSettings, k as ProjectBrandingSettings, P as ProjectChatSettings, l as ProjectTelemetrySettings, m as ProjectWidgetSettings, o as RagMessage, p as RetrievalConfig, _ as RetrievalResult, q as RetrievedChunk, $ as RetrivoraChunkMetadata, a0 as RetrivoraIngestedDocument, a1 as ScatterPlotDataPoint, a2 as SuggestionsResponse, a3 as TableData, T as ThemeMode, r as TokenUsage, U as UseRagChatOptions, a as UseRagChatReturn, a4 as VisualizationType, W as WidgetPosition, x as WorkflowConfig, y as createDefaultProjectSettings, z as normalizeProjectSettings, B as projectSettingsToUiConfig } from './ILLMProvider-Y6aL5N8J.js';
3
+ import { l as DecisionContext, n as IntentCategory, I as IRenderRule, y as RenderDecision, m as IRendererStrategy } from './BatchProcessor-D42E706a.js';
4
+ export { Q as ArchitectureCardProps, A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, T as ChatViewportSize, C as ChatWidgetProps, a as ChatWindowProps, h as Chunk, i as ChunkOptions, c as ClientConfig, j as ConfigFetcher, b as ConfigProviderProps, k as ConfigurationException, U as DocumentChunker, D as DocumentUploadProps, E as EmbeddingFailedException, V as LicenseConfigResolver, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, M as MessageBubbleProps, W as Pipeline, X as PipelineStep, P as ProductCardProps, d as ProductCarouselProps, s as ProviderCredentials, t as ProviderNotFoundException, Y as ProviderPill, u as RateLimitException, R as RemoteConfig, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, Z as RenderSectionDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, _ as Snippet, S as SourceCardProps, $ as wrapError } from './BatchProcessor-D42E706a.js';
5
+ import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-BgKRInpa.js';
6
+ export { C as ConfigValidator, b as HandlerOptions, V as ValidationError, c as VectorPlugin, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, o as sseTextFrame } from './index-BgKRInpa.js';
7
7
  import 'react';
8
8
  import 'next/server';
9
9
 
@@ -232,6 +232,8 @@ declare class ProviderRegistry {
232
232
  interface RuntimeTierConfig {
233
233
  llmModel?: string;
234
234
  embeddingModel?: string;
235
+ /** Custom system prompt from project configuration */
236
+ systemPrompt?: string;
235
237
  /** LiteLLM master key for authenticating with llm.retrivora.com */
236
238
  litellmApiKey?: string;
237
239
  /** LiteLLM gateway base URL (defaults to https://llm.retrivora.com/api/v1) */
@@ -1158,6 +1160,7 @@ declare class LicensedRetrivora {
1158
1160
  private projectId;
1159
1161
  private pipeline?;
1160
1162
  private ragConfig?;
1163
+ private tierConfig?;
1161
1164
  private initialized;
1162
1165
  constructor(options: LicensedRetrivoraOptions);
1163
1166
  /**
package/dist/server.js CHANGED
@@ -330,7 +330,7 @@ var init_package = __esm({
330
330
  "package.json"() {
331
331
  package_default = {
332
332
  name: "@retrivora-ai/rag-engine",
333
- version: "2.3.9",
333
+ version: "2.4.1",
334
334
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
335
335
  author: "Abhinav Alkuchi",
336
336
  license: "UNLICENSED",
@@ -525,7 +525,6 @@ var init_ConfigFetcher = __esm({
525
525
  for (const baseUrl of controlPlaneUrls) {
526
526
  try {
527
527
  const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}`;
528
- console.log(`[ConfigFetcher] Fetching config from: ${url}`);
529
528
  const res = await fetch(url, {
530
529
  method: "GET",
531
530
  headers: __spreadValues({
@@ -533,7 +532,6 @@ var init_ConfigFetcher = __esm({
533
532
  "x-sdk-version": SDK_VERSION
534
533
  }, licenseKey ? { "x-license-key": licenseKey } : {})
535
534
  });
536
- console.log(`[ConfigFetcher] Response status: ${res.status}`);
537
535
  if (!res.ok) {
538
536
  console.warn(`[ConfigFetcher] Error text: ${await res.text()}`);
539
537
  }
@@ -1252,9 +1250,6 @@ var init_MultiTablePostgresProvider = __esm({
1252
1250
  if (this.tables.length === 0) {
1253
1251
  console.warn('[MultiTablePostgresProvider] No tables with "embedding" columns found in the database.');
1254
1252
  } else {
1255
- console.log(
1256
- `[MultiTablePostgresProvider] Connected. Searching across ${this.tables.length} table(s): ${this.tables.join(", ")}`
1257
- );
1258
1253
  }
1259
1254
  } finally {
1260
1255
  client.release();
@@ -1376,11 +1371,8 @@ var init_MultiTablePostgresProvider = __esm({
1376
1371
  }
1377
1372
  const vectorLiteral = `[${vector.join(",")}]`;
1378
1373
  const allResults = [];
1379
- console.log(`[MultiTablePostgresProvider] --- Starting Multi-Table Search ---`);
1380
1374
  const queryText = _filter == null ? void 0 : _filter.queryText;
1381
1375
  const entityHints = Array.isArray(_filter == null ? void 0 : _filter.keywords) ? _filter.keywords.map((k) => k.trim().toLowerCase()).filter(Boolean) : [];
1382
- console.log(`[MultiTablePostgresProvider] queryText: "${queryText}"`);
1383
- console.log(`[MultiTablePostgresProvider] entityHints: [${entityHints.join(", ")}]`);
1384
1376
  const getDynamicKeywordQuery = () => {
1385
1377
  if (entityHints.length > 0) {
1386
1378
  return entityHints.map((h) => h.replace(/\s+/g, " & ")).join(" & ");
@@ -1468,9 +1460,7 @@ var init_MultiTablePostgresProvider = __esm({
1468
1460
  }
1469
1461
  const result = await this.pool.query(sqlQuery, params);
1470
1462
  if (result.rowCount && result.rowCount > 0) {
1471
- console.log(` \u2705 Table "${table}": Found ${result.rowCount} potential matches. Top score: ${result.rows[0].hybrid_score.toFixed(4)}`);
1472
1463
  } else {
1473
- console.log(` \u26AA Table "${table}": No relevant matches found.`);
1474
1464
  }
1475
1465
  const tableResults = [];
1476
1466
  for (const row of result.rows) {
@@ -1508,9 +1498,6 @@ var init_MultiTablePostgresProvider = __esm({
1508
1498
  var _a4;
1509
1499
  return ((_a4 = res.metadata) == null ? void 0 : _a4.source_table) === bestMatchTable;
1510
1500
  });
1511
- console.log(`[MultiTablePostgresProvider] --- Search Complete ---`);
1512
- console.log(`[MultiTablePostgresProvider] Final top match from "${bestMatchTable}" with score ${finalSorted[0].score.toFixed(4)}`);
1513
- console.log(`[MultiTablePostgresProvider] Restricting recommendations strictly to table: "${bestMatchTable}"`);
1514
1501
  return finalSorted.slice(0, Math.max(topK, 15));
1515
1502
  }
1516
1503
  async delete(_id, _namespace) {
@@ -1888,13 +1875,11 @@ var init_QdrantProvider = __esm({
1888
1875
  if (this.schemaDiscovered) return;
1889
1876
  await this.ping();
1890
1877
  await this.ensureCollection();
1891
- console.log(`[QdrantProvider] \u{1F50D} Discovering schema for collection "${this.indexName}"...`);
1892
1878
  const discoveredFields = await this.discoverSchema();
1893
1879
  const opts = this.config.options;
1894
1880
  const configFields = opts.filterableFields || [];
1895
1881
  const allFields = [.../* @__PURE__ */ new Set([...discoveredFields, ...configFields])];
1896
1882
  if (allFields.length > 0) {
1897
- console.log(`[QdrantProvider] \u{1F6E0} Ensuring indexes for ${allFields.length} discovered fields...`);
1898
1883
  await Promise.all(
1899
1884
  allFields.map(async (fieldInfo) => {
1900
1885
  const [fieldName, schemaType] = fieldInfo.split(":");
@@ -1902,7 +1887,6 @@ var init_QdrantProvider = __esm({
1902
1887
  })
1903
1888
  );
1904
1889
  } else {
1905
- console.log(`[QdrantProvider] \u2139\uFE0F No fields discovered for indexing.`);
1906
1890
  }
1907
1891
  this.schemaDiscovered = true;
1908
1892
  }
@@ -1946,19 +1930,16 @@ var init_QdrantProvider = __esm({
1946
1930
  var _a3;
1947
1931
  try {
1948
1932
  await this.http.get(`/collections/${this.indexName}`);
1949
- console.log(`[QdrantProvider] \u2705 Collection "${this.indexName}" already exists.`);
1950
1933
  } catch (err) {
1951
1934
  if (import_axios4.default.isAxiosError(err) && ((_a3 = err.response) == null ? void 0 : _a3.status) === 404) {
1952
1935
  const opts = this.config.options;
1953
1936
  const dimensionsForCreate = opts.dimensions || 1536;
1954
- console.log(`[QdrantProvider] \u23F3 Creating collection "${this.indexName}" (dimensions: ${dimensionsForCreate})...`);
1955
1937
  await this.http.put(`/collections/${this.indexName}`, {
1956
1938
  vectors: {
1957
1939
  size: dimensionsForCreate,
1958
1940
  distance: "Cosine"
1959
1941
  }
1960
1942
  });
1961
- console.log(`[QdrantProvider] \u2705 Created collection "${this.indexName}"`);
1962
1943
  } else {
1963
1944
  throw err;
1964
1945
  }
@@ -1978,7 +1959,6 @@ var init_QdrantProvider = __esm({
1978
1959
  field_name: fullPath,
1979
1960
  field_schema: schema
1980
1961
  });
1981
- console.log(`[QdrantProvider] \u2705 Ensured ${schema} index for "${fullPath}"`);
1982
1962
  } catch (err) {
1983
1963
  let status;
1984
1964
  if (import_axios4.default.isAxiosError(err)) status = (_a3 = err.response) == null ? void 0 : _a3.status;
@@ -2131,15 +2111,12 @@ var init_ChromaDBProvider = __esm({
2131
2111
  try {
2132
2112
  const { data } = await this.http.get(`/api/v1/collections/${this.indexName}`);
2133
2113
  this.collectionId = data.id;
2134
- console.log(`[ChromaDBProvider] \u2705 Collection "${this.indexName}" found (id: ${this.collectionId})`);
2135
2114
  } catch (err) {
2136
2115
  if (import_axios5.default.isAxiosError(err) && ((_a3 = err.response) == null ? void 0 : _a3.status) === 404) {
2137
- console.log(`[ChromaDBProvider] \u23F3 Collection "${this.indexName}" not found. Creating...`);
2138
2116
  const { data } = await this.http.post("/api/v1/collections", {
2139
2117
  name: this.indexName
2140
2118
  });
2141
2119
  this.collectionId = data.id;
2142
- console.log(`[ChromaDBProvider] \u2705 Created collection "${this.indexName}" (id: ${this.collectionId})`);
2143
2120
  } else {
2144
2121
  throw err;
2145
2122
  }
@@ -2625,7 +2602,6 @@ var init_SimpleGraphProvider = __esm({
2625
2602
  this.edges = [];
2626
2603
  }
2627
2604
  async initialize() {
2628
- console.log("[SimpleGraphProvider] Initialised in-memory graph store.");
2629
2605
  }
2630
2606
  async addNodes(nodes) {
2631
2607
  for (const node of nodes) {
@@ -3110,13 +3086,6 @@ var UI_BORDER_RADIUS_OPTIONS = ["none", "sm", "md", "lg", "xl", "full"];
3110
3086
  var _runtimeConfig = null;
3111
3087
  function injectRuntimeConfig(config) {
3112
3088
  _runtimeConfig = config;
3113
- console.log("[serverConfig] \u2705 Runtime tier config injected:", {
3114
- tier: config.tier,
3115
- llmModel: config.llmModel,
3116
- embeddingModel: config.embeddingModel,
3117
- llmBaseUrl: config.llmBaseUrl,
3118
- hasLitellmKey: !!config.litellmApiKey
3119
- });
3120
3089
  }
3121
3090
  function getRuntimeConfig() {
3122
3091
  return _runtimeConfig;
@@ -3147,7 +3116,7 @@ function getRagConfig(baseConfig, env = process.env) {
3147
3116
  return getEnvConfig(env, baseConfig);
3148
3117
  }
3149
3118
  function getEnvConfig(env = process.env, base) {
3150
- var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb, _xb, _yb, _zb, _Ab, _Bb, _Cb, _Db, _Eb, _Fb, _Gb, _Hb, _Ib;
3119
+ var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb, _xb, _yb, _zb, _Ab, _Bb, _Cb, _Db, _Eb, _Fb, _Gb, _Hb, _Ib, _Jb, _Kb, _Lb, _Mb, _Nb;
3151
3120
  const licenseKey = (_d = (_c = (_b = (_a3 = readString(env, "RAG_LICENSE_KEY")) != null ? _a3 : readString(env, "RETRIVORA_LICENSE_KEY")) != null ? _b : readString(env, "NEXT_PUBLIC_RETRIVORA_LICENSE_KEY")) != null ? _c : readString(env, "LICENSE_KEY")) != null ? _d : base == null ? void 0 : base.licenseKey;
3152
3121
  const jwtProjectId = (() => {
3153
3122
  if (!licenseKey) return void 0;
@@ -3249,26 +3218,12 @@ function getEnvConfig(env = process.env, base) {
3249
3218
  const llmModel = (_Ca = (_Ba = (_Aa = readString(env, "LLM_MODEL")) != null ? _Aa : (_za = base == null ? void 0 : base.llm) == null ? void 0 : _za.model) != null ? _Ba : rt == null ? void 0 : rt.llmModel) != null ? _Ca : tierBasedLLMModel;
3250
3219
  const llmApiKey = (_Ga = (_Fa = (_Da = readString(env, "LITELLM_MASTER_KEY")) != null ? _Da : rt == null ? void 0 : rt.litellmApiKey) != null ? _Fa : (_Ea = base == null ? void 0 : base.llm) == null ? void 0 : _Ea.apiKey) != null ? _Ga : licenseKey;
3251
3220
  const llmProfile = (_Ka = (_Ja = readString(env, "LLM_UNIVERSAL_PROFILE")) != null ? _Ja : (_Ia = (_Ha = base == null ? void 0 : base.llm) == null ? void 0 : _Ha.options) == null ? void 0 : _Ia.profile) != null ? _Ka : "litellm";
3252
- console.log("[serverConfig] \u{1F527} LLM Configuration:", {
3253
- baseUrl: llmBaseUrl,
3254
- model: llmModel,
3255
- provider: llmProvider,
3256
- hasApiKey: !!llmApiKey,
3257
- source: (rt == null ? void 0 : rt.llmModel) ? "runtime-injected" : "env/fallback"
3258
- });
3259
3221
  const defaultEmbeddingProvider = "universal_rest";
3260
3222
  const embeddingProvider = (_Na = (_Ma = readEnum(env, "EMBEDDING_PROVIDER", defaultEmbeddingProvider, EMBEDDING_PROVIDERS)) != null ? _Ma : (_La = base == null ? void 0 : base.embedding) == null ? void 0 : _La.provider) != null ? _Na : defaultEmbeddingProvider;
3261
3223
  const embeddingBaseUrl = (_Ua = (_Ta = (_Sa = (_Ra = (_Pa = (_Oa = readString(env, "LITELLM_BASE_URL")) != null ? _Oa : readString(env, "EMBEDDING_BASE_URL")) != null ? _Pa : readString(env, "LLM_BASE_URL")) != null ? _Ra : (_Qa = base == null ? void 0 : base.embedding) == null ? void 0 : _Qa.baseUrl) != null ? _Sa : rt == null ? void 0 : rt.embeddingBaseUrl) != null ? _Ta : rt == null ? void 0 : rt.llmBaseUrl) != null ? _Ua : defaultGatewayUrl;
3262
3224
  const embeddingModel = (_Ya = (_Xa = (_Wa = readString(env, "EMBEDDING_MODEL")) != null ? _Wa : (_Va = base == null ? void 0 : base.embedding) == null ? void 0 : _Va.model) != null ? _Xa : rt == null ? void 0 : rt.embeddingModel) != null ? _Ya : tierBasedEmbeddingModel;
3263
3225
  const embeddingApiKey = (_ab = (_$a = (_Za = readString(env, "LITELLM_MASTER_KEY")) != null ? _Za : rt == null ? void 0 : rt.litellmApiKey) != null ? _$a : (__a = base == null ? void 0 : base.embedding) == null ? void 0 : __a.apiKey) != null ? _ab : licenseKey;
3264
3226
  const embeddingProfile = (_eb = (_db = readString(env, "EMBEDDING_UNIVERSAL_PROFILE")) != null ? _db : (_cb = (_bb = base == null ? void 0 : base.embedding) == null ? void 0 : _bb.options) == null ? void 0 : _cb.profile) != null ? _eb : "litellm";
3265
- console.log("[serverConfig] \u{1F527} Embedding Configuration:", {
3266
- baseUrl: embeddingBaseUrl,
3267
- model: embeddingModel,
3268
- provider: embeddingProvider,
3269
- hasApiKey: !!embeddingApiKey,
3270
- source: (rt == null ? void 0 : rt.embeddingModel) ? "runtime-injected" : "env/fallback"
3271
- });
3272
3227
  return __spreadProps(__spreadValues({
3273
3228
  projectId,
3274
3229
  licenseKey,
@@ -3282,8 +3237,8 @@ function getEnvConfig(env = process.env, base) {
3282
3237
  model: llmModel,
3283
3238
  apiKey: llmApiKey,
3284
3239
  baseUrl: llmBaseUrl,
3285
- systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
3286
- maxTokens: readNumber(env, "LLM_MAX_TOKENS", 4096),
3240
+ systemPrompt: (_hb = readString(env, "LLM_SYSTEM_PROMPT")) != null ? _hb : rt == null ? void 0 : rt.systemPrompt,
3241
+ maxTokens: readNumber(env, "LLM_MAX_TOKENS", (_ib = rt == null ? void 0 : rt.maxTokens) != null ? _ib : 4096),
3287
3242
  temperature: readNumber(env, "LLM_TEMPERATURE", 0.7),
3288
3243
  options: {
3289
3244
  profile: llmProfile,
@@ -3304,30 +3259,30 @@ function getEnvConfig(env = process.env, base) {
3304
3259
  }
3305
3260
  },
3306
3261
  ui: {
3307
- title: (_ib = (_hb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _hb : readString(env, "UI_TITLE")) != null ? _ib : "AI Assistant",
3308
- subtitle: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _jb : readString(env, "UI_SUBTITLE")) != null ? _kb : "Powered by RAG",
3309
- primaryColor: (_mb = (_lb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _lb : readString(env, "UI_PRIMARY_COLOR")) != null ? _mb : "#10b981",
3310
- accentColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _nb : readString(env, "UI_ACCENT_COLOR")) != null ? _ob : "#3b82f6",
3311
- logoUrl: (_pb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _pb : readString(env, "UI_LOGO_URL"),
3312
- placeholder: (_rb = (_qb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _qb : readString(env, "UI_PLACEHOLDER")) != null ? _rb : "Ask me anything\u2026",
3313
- showSources: ((_tb = (_sb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _sb : readString(env, "UI_SHOW_SOURCES")) != null ? _tb : "true") !== "false",
3314
- welcomeMessage: (_vb = (_ub = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _ub : readString(env, "UI_WELCOME_MESSAGE")) != null ? _vb : "Hello! I'm your AI assistant. Ask me anything about your documents.",
3315
- visualStyle: (_xb = (_wb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _wb : readString(env, "UI_VISUAL_STYLE")) != null ? _xb : "glass",
3316
- borderRadius: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _yb : readString(env, "UI_BORDER_RADIUS")) != null ? _zb : "xl",
3317
- allowUpload: ((_Bb = (_Ab = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Ab : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Bb : "false") === "true"
3262
+ title: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _jb : readString(env, "UI_TITLE")) != null ? _kb : "AI Assistant",
3263
+ subtitle: (_mb = (_lb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _lb : readString(env, "UI_SUBTITLE")) != null ? _mb : "Powered by RAG",
3264
+ primaryColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _nb : readString(env, "UI_PRIMARY_COLOR")) != null ? _ob : "#10b981",
3265
+ accentColor: (_qb = (_pb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _pb : readString(env, "UI_ACCENT_COLOR")) != null ? _qb : "#3b82f6",
3266
+ logoUrl: (_rb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _rb : readString(env, "UI_LOGO_URL"),
3267
+ placeholder: (_tb = (_sb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _sb : readString(env, "UI_PLACEHOLDER")) != null ? _tb : "Ask me anything\u2026",
3268
+ showSources: ((_vb = (_ub = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ub : readString(env, "UI_SHOW_SOURCES")) != null ? _vb : "true") !== "false",
3269
+ welcomeMessage: (_xb = (_wb = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _wb : readString(env, "UI_WELCOME_MESSAGE")) != null ? _xb : "Hello! I'm your AI assistant. Ask me anything about your documents.",
3270
+ visualStyle: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _yb : readString(env, "UI_VISUAL_STYLE")) != null ? _zb : "glass",
3271
+ borderRadius: (_Bb = (_Ab = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _Ab : readString(env, "UI_BORDER_RADIUS")) != null ? _Bb : "xl",
3272
+ allowUpload: ((_Db = (_Cb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Cb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Db : "false") === "true"
3318
3273
  },
3319
3274
  rag: {
3320
- topK: readNumber(env, "RAG_TOP_K", 5),
3275
+ topK: readNumber(env, "RAG_TOP_K", (_Eb = rt == null ? void 0 : rt.topK) != null ? _Eb : 5),
3321
3276
  scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
3322
- chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
3323
- chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
3324
- filterableFields: (_Cb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Cb.split(",").map((f) => f.trim()),
3277
+ chunkSize: readNumber(env, "RAG_CHUNK_SIZE", (_Fb = rt == null ? void 0 : rt.chunkSize) != null ? _Fb : 1e3),
3278
+ chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", (_Gb = rt == null ? void 0 : rt.chunkOverlap) != null ? _Gb : 200),
3279
+ filterableFields: (_Hb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Hb.split(",").map((f) => f.trim()),
3325
3280
  // Query pipeline toggles — read from .env.local
3326
3281
  useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
3327
3282
  useReranking: readString(env, "RAG_USE_RERANKING") === "true",
3328
3283
  useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
3329
- architecture: (_Db = readString(env, "RAG_ARCHITECTURE")) != null ? _Db : "simple",
3330
- chunkingStrategy: (_Eb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Eb : "recursive",
3284
+ architecture: (_Ib = readString(env, "RAG_ARCHITECTURE")) != null ? _Ib : "simple",
3285
+ chunkingStrategy: (_Jb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Jb : "recursive",
3331
3286
  uiMapping: (() => {
3332
3287
  const raw = readString(env, "RAG_UI_MAPPING");
3333
3288
  if (!raw) return void 0;
@@ -3340,7 +3295,7 @@ function getEnvConfig(env = process.env, base) {
3340
3295
  },
3341
3296
  telemetry: {
3342
3297
  enabled: telemetryEnabled,
3343
- url: (_Ib = (_Hb = (_Fb = readString(env, "TELEMETRY_URL")) != null ? _Fb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Hb : (_Gb = base == null ? void 0 : base.telemetry) == null ? void 0 : _Gb.url) != null ? _Ib : "https://www.retrivora.com/api/telemetry"
3298
+ url: (_Nb = (_Mb = (_Kb = readString(env, "TELEMETRY_URL")) != null ? _Kb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Mb : (_Lb = base == null ? void 0 : base.telemetry) == null ? void 0 : _Lb.url) != null ? _Nb : "https://www.retrivora.com/api/telemetry"
3344
3299
  }
3345
3300
  }, readString(env, "GRAPH_DB_PROVIDER") ? {
3346
3301
  graphDb: {
@@ -4690,12 +4645,6 @@ var UniversalLLMAdapter = class {
4690
4645
  this.resolvedHeaders = __spreadValues(__spreadValues({
4691
4646
  "Content-Type": "application/json"
4692
4647
  }, config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}), this.opts.headers || {});
4693
- console.log("[UniversalLLMAdapter] Initialized with:", {
4694
- model: this.model,
4695
- baseUrl: this.baseUrl,
4696
- hasApiKey: !!this.apiKey,
4697
- apiKeyPrefix: this.apiKey ? `${this.apiKey.slice(0, 12)}...` : void 0
4698
- });
4699
4648
  this.http = import_axios2.default.create({
4700
4649
  baseURL: this.baseUrl,
4701
4650
  headers: this.resolvedHeaders,
@@ -4912,15 +4861,10 @@ ${context != null ? context : "None"}` },
4912
4861
  const path2 = (_a3 = this.opts.embedPath) != null ? _a3 : "/embeddings";
4913
4862
  const payload = this.opts.embedPayloadTemplate ? buildPayload(this.opts.embedPayloadTemplate, { input: text, model: this.model }) : { input: text, model: this.model };
4914
4863
  try {
4915
- console.log(`[UniversalLLMAdapter] Posting to embedding endpoint: ${this.baseUrl}${path2}`, {
4916
- model: this.model,
4917
- inputLength: typeof text === "string" ? text.length : "unknown"
4918
- });
4919
4864
  const { data } = await this.http.post(path2, payload);
4920
4865
  const extractPath = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
4921
4866
  const vector = resolvePath(data, extractPath);
4922
4867
  if (Array.isArray(vector)) {
4923
- console.log(`[UniversalLLMAdapter] Embedding HTTP request successful. Vector size: ${vector.length}`);
4924
4868
  return vector;
4925
4869
  }
4926
4870
  console.warn(
@@ -4946,12 +4890,10 @@ ${context != null ? context : "None"}` },
4946
4890
  }
4947
4891
  }
4948
4892
  try {
4949
- console.log(`[UniversalLLMAdapter] Retrying embedding request to: ${this.baseUrl}${path2}`);
4950
4893
  const { data } = await this.http.post(path2, payload);
4951
4894
  const extractPath = (_f = this.opts.embedExtractPath) != null ? _f : "data[0].embedding";
4952
4895
  const vector = resolvePath(data, extractPath);
4953
4896
  if (Array.isArray(vector)) {
4954
- console.log(`[UniversalLLMAdapter] Retry embedding HTTP request successful. Vector size: ${vector.length}`);
4955
4897
  return vector;
4956
4898
  }
4957
4899
  console.error(
@@ -5015,7 +4957,6 @@ var LLMFactory = class _LLMFactory {
5015
4957
  */
5016
4958
  static register(name, factory) {
5017
4959
  customProviders.set(name.toLowerCase(), factory);
5018
- console.log(`[LLMFactory] Registered custom provider: "${name}"`);
5019
4960
  }
5020
4961
  /**
5021
4962
  * Unregister a previously registered custom provider.
@@ -5795,7 +5736,6 @@ var MCPClient = class {
5795
5736
  });
5796
5737
  await this.sendNotification("notifications/initialized");
5797
5738
  this.initialized = true;
5798
- console.log(`[MCPClient] Connected and initialized server "${this.config.name}" successfully.`);
5799
5739
  } catch (err) {
5800
5740
  this.disconnect();
5801
5741
  throw new Error(`[MCPClient] Failed to initialize server "${this.config.name}": ${err.message}`);
@@ -5821,7 +5761,6 @@ var MCPClient = class {
5821
5761
  console.warn(`[MCPClient] [stderr] [${this.config.name}]:`, data.toString("utf-8"));
5822
5762
  });
5823
5763
  this.childProcess.on("close", (code) => {
5824
- console.log(`[MCPClient] Connection closed for "${this.config.name}" with exit code: ${code}`);
5825
5764
  this.disconnect();
5826
5765
  });
5827
5766
  await new Promise((resolve) => setTimeout(resolve, 100));
@@ -6956,13 +6895,11 @@ var LLMRouter = class {
6956
6895
  const providerFastDefault = (_a3 = FAST_MODEL_DEFAULTS[this.config.llm.provider]) != null ? _a3 : "";
6957
6896
  const fastModelName = envFastModel || providerFastDefault;
6958
6897
  if (fastModelName && fastModelName !== this.config.llm.model) {
6959
- console.log(`[LLMRouter] Fast role \u2192 provider="${this.config.llm.provider}" model="${fastModelName}"`);
6960
6898
  const fastConfig = __spreadProps(__spreadValues({}, this.config.llm), {
6961
6899
  model: fastModelName
6962
6900
  });
6963
6901
  this.models.set("fast", LLMFactory.create(fastConfig, this.config.embedding));
6964
6902
  } else {
6965
- console.log(`[LLMRouter] Fast role \u2192 reusing default model (no lightweight alternative configured).`);
6966
6903
  this.models.set("fast", defaultModel);
6967
6904
  }
6968
6905
  this.models.set("powerful", defaultModel);
@@ -8958,7 +8895,6 @@ var SchemaMapper = class {
8958
8895
  }
8959
8896
  static async _doTrain(llm, cacheKey, keys) {
8960
8897
  var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
8961
- console.log(`[SchemaMapper] \u{1F9E0} Training on new schema keys: ${keys.join(", ")}`);
8962
8898
  const propertyList = Object.entries(this.TARGET_PROPERTIES).map(([prop, desc]) => `- ${prop} (${desc})`).join("\n");
8963
8899
  const messages = [
8964
8900
  { role: "system", content: "You are a database schema expert. Respond ONLY with valid JSON." },
@@ -11921,7 +11857,6 @@ function createStreamHandler(configOrPlugin, options) {
11921
11857
  },
11922
11858
  cancel(reason) {
11923
11859
  isActive = false;
11924
- console.log("[createStreamHandler] Stream connection closed by client:", reason);
11925
11860
  }
11926
11861
  });
11927
11862
  return new Response(stream, { headers: __spreadProps(__spreadValues({}, SSE_HEADERS), { "x-message-id": assistantMsgId, "x-user-message-id": userMsgId }) });
@@ -12012,7 +11947,6 @@ function createLicenseHandler(configOrPlugin, options) {
12012
11947
  const rawKey = req.headers.get("x-license-key") || (body == null ? void 0 : body.licenseKey) || ((_a3 = req.headers.get("authorization")) == null ? void 0 : _a3.replace(/^Bearer\s+/i, "")) || config.licenseKey || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || "";
12013
11948
  const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
12014
11949
  const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "";
12015
- console.log(`[DEBUG] createLicenseHandler: projectId="${projectId}", body.projectId="${body == null ? void 0 : body.projectId}", config.projectId="${config.projectId}"`);
12016
11950
  const payload = await LicenseVerifier.verifyAsync(licenseKey, projectId);
12017
11951
  return import_server.NextResponse.json({
12018
11952
  valid: true,
@@ -12043,7 +11977,6 @@ function createUploadHandler(configOrPlugin, options) {
12043
11977
  const plugin = getOrCreatePlugin(configOrPlugin);
12044
11978
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
12045
11979
  return async function POST(req, context) {
12046
- console.log("Upload handler invoked");
12047
11980
  const authResult = await checkAuth(req, onAuthorize);
12048
11981
  if (authResult) return authResult;
12049
11982
  const config = plugin.getConfig();
@@ -12052,7 +11985,6 @@ function createUploadHandler(configOrPlugin, options) {
12052
11985
  try {
12053
11986
  const formData = await req.formData();
12054
11987
  const files = formData.getAll("files");
12055
- console.log("Files received for upload:", files.map((f) => f.name));
12056
11988
  const namespace = formData.get("namespace") || void 0;
12057
11989
  const dimensionRaw = formData.get("dimension");
12058
11990
  const dimension = dimensionRaw ? parseInt(dimensionRaw, 10) : void 0;
@@ -12390,7 +12322,7 @@ function createRagHandler(configOrPlugin, options) {
12390
12322
  }
12391
12323
  }
12392
12324
  async function getSegment(req, context) {
12393
- var _a3, _b;
12325
+ var _a3, _b, _c;
12394
12326
  const contentType = req.headers.get("content-type") || "";
12395
12327
  if (contentType.includes("multipart/form-data")) {
12396
12328
  return "upload";
@@ -12405,10 +12337,12 @@ function createRagHandler(configOrPlugin, options) {
12405
12337
  if (pathname.endsWith("/suggestions")) return "suggestions";
12406
12338
  if (pathname.endsWith("/feedback")) return "feedback";
12407
12339
  if (pathname.endsWith("/history")) return "history";
12340
+ if (pathname.endsWith("/history/clear")) return "history/clear";
12341
+ if (pathname.endsWith("/sessions")) return "sessions";
12408
12342
  } catch (e) {
12409
12343
  }
12410
12344
  const resolvedParams = typeof ((_a3 = context == null ? void 0 : context.params) == null ? void 0 : _a3.then) === "function" ? await context.params : context == null ? void 0 : context.params;
12411
- const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || [];
12345
+ const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || (resolvedParams == null ? void 0 : resolvedParams.rag) || ((_c = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _c.rag) || [];
12412
12346
  const joined = segments.join("/");
12413
12347
  return joined || "chat";
12414
12348
  }
@@ -12621,19 +12555,11 @@ var LicenseConfigResolver = class {
12621
12555
  const cacheKey = `${licenseKey}:${projectId}`;
12622
12556
  const cached = this.configCache.get(cacheKey);
12623
12557
  if (cached && Date.now() - cached.timestamp < this.CACHE_TTL_MS) {
12624
- console.log("[LicenseConfigResolver] Using cached config for", projectId);
12625
12558
  return this.buildConfigs(cached.config, cached.credentials, licenseKey, projectId);
12626
12559
  }
12627
- console.log("[LicenseConfigResolver] Fetching tier config from Retrivora...");
12628
12560
  const tierConfig = await this.fetchTierConfig(licenseKey, projectId);
12629
- console.log("[LicenseConfigResolver] Fetching provider credentials from Retrivora...");
12630
12561
  const credentials = await this.fetchProviderCredentials(licenseKey, projectId);
12631
12562
  this.configCache.set(cacheKey, { config: tierConfig, credentials, timestamp: Date.now() });
12632
- console.log("[LicenseConfigResolver] \u2705 Successfully resolved config from Retrivora:", {
12633
- tier: tierConfig.tier,
12634
- llmModel: tierConfig.llmModel,
12635
- embeddingModel: tierConfig.embeddingModel
12636
- });
12637
12563
  return this.buildConfigs(tierConfig, credentials, licenseKey, projectId);
12638
12564
  }
12639
12565
  /**
@@ -12659,7 +12585,6 @@ var LicenseConfigResolver = class {
12659
12585
  `[LicenseConfigResolver] Config API returned error: ${response.data.error || response.data.message}`
12660
12586
  );
12661
12587
  }
12662
- console.log(`[LicenseConfigResolver] Resolved tier: ${response.data.config.tier}`);
12663
12588
  return response.data.config;
12664
12589
  } catch (err) {
12665
12590
  console.error("[LicenseConfigResolver] Failed to fetch config:", err.message);
@@ -12691,7 +12616,6 @@ var LicenseConfigResolver = class {
12691
12616
  `[LicenseConfigResolver] Credentials API returned error: ${response.data.error || response.data.message}`
12692
12617
  );
12693
12618
  }
12694
- console.log(`[LicenseConfigResolver] Retrieved provider credentials for project: ${projectId}`);
12695
12619
  return response.data.credentials;
12696
12620
  } catch (err) {
12697
12621
  console.error("[LicenseConfigResolver] Failed to fetch credentials:", err.message);
@@ -12716,8 +12640,9 @@ var LicenseConfigResolver = class {
12716
12640
  provider: llmProvider,
12717
12641
  model: tierConfig.llmModel,
12718
12642
  apiKey: llmApiKey,
12719
- maxTokens: tierConfig.maxTokens,
12643
+ maxTokens: tierConfig == null ? void 0 : tierConfig.maxTokens,
12720
12644
  temperature: 0.7,
12645
+ systemPrompt: tierConfig == null ? void 0 : tierConfig.systemPrompt,
12721
12646
  options: {}
12722
12647
  };
12723
12648
  const embeddingConfig = {
@@ -12767,7 +12692,6 @@ var LicenseConfigResolver = class {
12767
12692
  */
12768
12693
  static clearCache() {
12769
12694
  this.configCache.clear();
12770
- console.log("[LicenseConfigResolver] Configuration cache cleared");
12771
12695
  }
12772
12696
  /**
12773
12697
  * Get cache stats for debugging
@@ -12914,7 +12838,6 @@ var _TelemetryService = class _TelemetryService {
12914
12838
  };
12915
12839
  try {
12916
12840
  await this.http.post(_TelemetryService.RETRIVORA_TELEMETRY_URL, payload);
12917
- console.log(`[TelemetryService] Flushed ${events.length} events to Retrivora`);
12918
12841
  } catch (err) {
12919
12842
  console.warn("[TelemetryService] Failed to send telemetry to Retrivora:", err.message);
12920
12843
  this.eventQueue.unshift(...events);
@@ -12928,7 +12851,6 @@ var _TelemetryService = class _TelemetryService {
12928
12851
  "X-Project-ID": this.projectId
12929
12852
  }
12930
12853
  });
12931
- console.log(`[TelemetryService] Flushed ${events.length} events to user telemetry`);
12932
12854
  } catch (err) {
12933
12855
  console.warn("[TelemetryService] Failed to send telemetry to user endpoint:", err.message);
12934
12856
  }
@@ -12982,7 +12904,6 @@ function getTelemetryService() {
12982
12904
  }
12983
12905
  function initializeTelemetryService(projectId, licenseKey, userTelemetryUrl) {
12984
12906
  globalTelemetryService = new TelemetryService(projectId, licenseKey, userTelemetryUrl);
12985
- console.log("[TelemetryService] Initialized for project:", projectId);
12986
12907
  return globalTelemetryService;
12987
12908
  }
12988
12909
  async function shutdownTelemetryService() {
@@ -13013,13 +12934,12 @@ var LicensedRetrivora = class {
13013
12934
  */
13014
12935
  async initialize() {
13015
12936
  if (this.initialized) {
13016
- console.log("[LicensedRetrivora] Already initialized");
13017
12937
  return;
13018
12938
  }
13019
- console.log("[LicensedRetrivora] Initializing with license key...");
13020
12939
  const operationId = this.generateId();
13021
12940
  try {
13022
12941
  const { llmConfig, embeddingConfig, vectorDbConfig, tierConfig } = await LicenseConfigResolver.resolveFromLicense(this.licenseKey, this.projectId);
12942
+ this.tierConfig = tierConfig;
13023
12943
  const telemetry = getTelemetryService();
13024
12944
  if (telemetry) {
13025
12945
  telemetry.recordEvent({
@@ -13053,7 +12973,6 @@ var LicensedRetrivora = class {
13053
12973
  this.pipeline = new Pipeline(this.ragConfig);
13054
12974
  await this.pipeline.initialize();
13055
12975
  this.initialized = true;
13056
- console.log(`[LicensedRetrivora] Initialized successfully for tier: ${tierConfig.tier}`);
13057
12976
  } catch (error) {
13058
12977
  const telemetry = getTelemetryService();
13059
12978
  if (telemetry && error instanceof Error) {
@@ -13075,16 +12994,16 @@ var LicensedRetrivora = class {
13075
12994
  const telemetry = getTelemetryService();
13076
12995
  const startTime = Date.now();
13077
12996
  try {
13078
- console.log(`[LicensedRetrivora] Starting ingestion of ${documents.length} document(s)`);
13079
12997
  const results = await this.pipeline.ingest(documents);
13080
12998
  const durationMs = Date.now() - startTime;
13081
12999
  if (telemetry) {
13082
13000
  for (const result of results) {
13001
+ const origDoc = documents.find((d) => String(d.docId) === String(result.docId));
13002
+ const size = origDoc ? new TextEncoder().encode(origDoc.content).length : 0;
13083
13003
  telemetry.recordDocumentIngested({
13084
13004
  documentId: String(result.docId),
13085
13005
  documentName: String(result.docId),
13086
- documentSize: 0,
13087
- // TODO: track actual size
13006
+ documentSize: size,
13088
13007
  chunksGenerated: result.chunksIngested,
13089
13008
  durationMs
13090
13009
  });
@@ -13119,7 +13038,6 @@ var LicensedRetrivora = class {
13119
13038
  const telemetry = getTelemetryService();
13120
13039
  const startTime = Date.now();
13121
13040
  try {
13122
- console.log(`[LicensedRetrivora] Executing query: "${queryText.substring(0, 100)}..."`);
13123
13041
  const response = await this.pipeline.runNormalQuery(queryText);
13124
13042
  const durationMs = Date.now() - startTime;
13125
13043
  if (telemetry) {
@@ -13148,12 +13066,11 @@ var LicensedRetrivora = class {
13148
13066
  * Get license tier information (for UI display if needed)
13149
13067
  */
13150
13068
  async getTierInfo() {
13151
- if (!this.ragConfig) {
13069
+ if (!this.ragConfig || !this.tierConfig) {
13152
13070
  throw new Error("[LicensedRetrivora] SDK not initialized.");
13153
13071
  }
13154
13072
  return {
13155
- tier: "Standard",
13156
- // TODO: fetch from tier config
13073
+ tier: this.tierConfig.tier,
13157
13074
  model: this.ragConfig.llm.model,
13158
13075
  embeddingModel: this.ragConfig.embedding.model
13159
13076
  };
@@ -13164,7 +13081,6 @@ var LicensedRetrivora = class {
13164
13081
  async shutdown() {
13165
13082
  await shutdownTelemetryService();
13166
13083
  this.initialized = false;
13167
- console.log("[LicensedRetrivora] Shutdown complete");
13168
13084
  }
13169
13085
  /**
13170
13086
  * Check if SDK is initialized