@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/README.md CHANGED
@@ -116,7 +116,7 @@ async function runIngestion() {
116
116
  ];
117
117
 
118
118
  const results = await retrivora.ingest(documents, 'default-namespace');
119
- console.log(`Successfully ingested ${results.length} documents.`);
119
+ //console.log(`Successfully ingested ${results.length} documents.`);
120
120
  }
121
121
  ```
122
122
 
@@ -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, 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';
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-Y6aL5N8J.js';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -61,6 +61,10 @@ interface ChatWindowProps {
61
61
  licenseKey?: string;
62
62
  /** Optional custom headers to send with the chat request */
63
63
  headers?: Record<string, string>;
64
+ /** Optional session ID to load conversation history from the server */
65
+ sessionId?: string;
66
+ /** Whether to show the ChatGPT-style sidebar history management and new chat controls */
67
+ showHistory?: boolean;
64
68
  }
65
69
  interface ChatWidgetProps {
66
70
  /** Position of the floating button. Defaults to bottom-right. */
@@ -143,6 +147,12 @@ interface ConfigProviderProps {
143
147
  retrivoraApiBase?: string;
144
148
  projectSettings?: Partial<ProjectChatSettings>;
145
149
  autoLoadProjectSettings?: boolean;
150
+ primaryColor?: string;
151
+ secondaryColor?: string;
152
+ accentColor?: string;
153
+ theme?: 'light' | 'dark' | 'system';
154
+ borderRadius?: 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
155
+ visualStyle?: 'solid' | 'glass';
146
156
  };
147
157
  children: ReactNode;
148
158
  }
@@ -253,6 +263,7 @@ interface LicenseTierConfig {
253
263
  requestsPerMinute: number;
254
264
  tokensPerDay: number;
255
265
  };
266
+ systemPrompt?: string;
256
267
  }
257
268
  interface ProviderCredentials {
258
269
  geminiApiKey?: string;
@@ -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, 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';
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-Y6aL5N8J.mjs';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -61,6 +61,10 @@ interface ChatWindowProps {
61
61
  licenseKey?: string;
62
62
  /** Optional custom headers to send with the chat request */
63
63
  headers?: Record<string, string>;
64
+ /** Optional session ID to load conversation history from the server */
65
+ sessionId?: string;
66
+ /** Whether to show the ChatGPT-style sidebar history management and new chat controls */
67
+ showHistory?: boolean;
64
68
  }
65
69
  interface ChatWidgetProps {
66
70
  /** Position of the floating button. Defaults to bottom-right. */
@@ -143,6 +147,12 @@ interface ConfigProviderProps {
143
147
  retrivoraApiBase?: string;
144
148
  projectSettings?: Partial<ProjectChatSettings>;
145
149
  autoLoadProjectSettings?: boolean;
150
+ primaryColor?: string;
151
+ secondaryColor?: string;
152
+ accentColor?: string;
153
+ theme?: 'light' | 'dark' | 'system';
154
+ borderRadius?: 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
155
+ visualStyle?: 'solid' | 'glass';
146
156
  };
147
157
  children: ReactNode;
148
158
  }
@@ -253,6 +263,7 @@ interface LicenseTierConfig {
253
263
  requestsPerMinute: number;
254
264
  tokensPerDay: number;
255
265
  };
266
+ systemPrompt?: string;
256
267
  }
257
268
  interface ProviderCredentials {
258
269
  geminiApiKey?: string;
@@ -264,6 +264,7 @@ interface UIConfig {
264
264
  allowResize?: boolean;
265
265
  /** Whether to enable voice search input. Defaults to true. */
266
266
  enableVoiceInput?: boolean;
267
+ theme?: 'light' | 'dark' | 'system';
267
268
  }
268
269
  interface CAGConfig {
269
270
  /** Enable Cold RAG (Cache Augmented Generation) */
@@ -264,6 +264,7 @@ interface UIConfig {
264
264
  allowResize?: boolean;
265
265
  /** Whether to enable voice search input. Defaults to true. */
266
266
  enableVoiceInput?: boolean;
267
+ theme?: 'light' | 'dark' | 'system';
267
268
  }
268
269
  interface CAGConfig {
269
270
  /** Enable Cold RAG (Cache Augmented Generation) */
@@ -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-C7aHK7_g.mjs';
3
- import '../ILLMProvider-B8TAVx3j.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-59CHg0V3.mjs';
3
+ import '../ILLMProvider-Y6aL5N8J.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-BQd6Bax0.js';
3
- import '../ILLMProvider-B8TAVx3j.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-BgKRInpa.js';
3
+ import '../ILLMProvider-Y6aL5N8J.js';
@@ -317,7 +317,7 @@ var init_package = __esm({
317
317
  "package.json"() {
318
318
  package_default = {
319
319
  name: "@retrivora-ai/rag-engine",
320
- version: "2.3.9",
320
+ version: "2.4.1",
321
321
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
322
322
  author: "Abhinav Alkuchi",
323
323
  license: "UNLICENSED",
@@ -512,7 +512,6 @@ var init_ConfigFetcher = __esm({
512
512
  for (const baseUrl of controlPlaneUrls) {
513
513
  try {
514
514
  const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}`;
515
- console.log(`[ConfigFetcher] Fetching config from: ${url}`);
516
515
  const res = await fetch(url, {
517
516
  method: "GET",
518
517
  headers: __spreadValues({
@@ -520,7 +519,6 @@ var init_ConfigFetcher = __esm({
520
519
  "x-sdk-version": SDK_VERSION
521
520
  }, licenseKey ? { "x-license-key": licenseKey } : {})
522
521
  });
523
- console.log(`[ConfigFetcher] Response status: ${res.status}`);
524
522
  if (!res.ok) {
525
523
  console.warn(`[ConfigFetcher] Error text: ${await res.text()}`);
526
524
  }
@@ -1239,9 +1237,6 @@ var init_MultiTablePostgresProvider = __esm({
1239
1237
  if (this.tables.length === 0) {
1240
1238
  console.warn('[MultiTablePostgresProvider] No tables with "embedding" columns found in the database.');
1241
1239
  } else {
1242
- console.log(
1243
- `[MultiTablePostgresProvider] Connected. Searching across ${this.tables.length} table(s): ${this.tables.join(", ")}`
1244
- );
1245
1240
  }
1246
1241
  } finally {
1247
1242
  client.release();
@@ -1363,11 +1358,8 @@ var init_MultiTablePostgresProvider = __esm({
1363
1358
  }
1364
1359
  const vectorLiteral = `[${vector.join(",")}]`;
1365
1360
  const allResults = [];
1366
- console.log(`[MultiTablePostgresProvider] --- Starting Multi-Table Search ---`);
1367
1361
  const queryText = _filter == null ? void 0 : _filter.queryText;
1368
1362
  const entityHints = Array.isArray(_filter == null ? void 0 : _filter.keywords) ? _filter.keywords.map((k) => k.trim().toLowerCase()).filter(Boolean) : [];
1369
- console.log(`[MultiTablePostgresProvider] queryText: "${queryText}"`);
1370
- console.log(`[MultiTablePostgresProvider] entityHints: [${entityHints.join(", ")}]`);
1371
1363
  const getDynamicKeywordQuery = () => {
1372
1364
  if (entityHints.length > 0) {
1373
1365
  return entityHints.map((h) => h.replace(/\s+/g, " & ")).join(" & ");
@@ -1455,9 +1447,7 @@ var init_MultiTablePostgresProvider = __esm({
1455
1447
  }
1456
1448
  const result = await this.pool.query(sqlQuery, params);
1457
1449
  if (result.rowCount && result.rowCount > 0) {
1458
- console.log(` \u2705 Table "${table}": Found ${result.rowCount} potential matches. Top score: ${result.rows[0].hybrid_score.toFixed(4)}`);
1459
1450
  } else {
1460
- console.log(` \u26AA Table "${table}": No relevant matches found.`);
1461
1451
  }
1462
1452
  const tableResults = [];
1463
1453
  for (const row of result.rows) {
@@ -1495,9 +1485,6 @@ var init_MultiTablePostgresProvider = __esm({
1495
1485
  var _a4;
1496
1486
  return ((_a4 = res.metadata) == null ? void 0 : _a4.source_table) === bestMatchTable;
1497
1487
  });
1498
- console.log(`[MultiTablePostgresProvider] --- Search Complete ---`);
1499
- console.log(`[MultiTablePostgresProvider] Final top match from "${bestMatchTable}" with score ${finalSorted[0].score.toFixed(4)}`);
1500
- console.log(`[MultiTablePostgresProvider] Restricting recommendations strictly to table: "${bestMatchTable}"`);
1501
1488
  return finalSorted.slice(0, Math.max(topK, 15));
1502
1489
  }
1503
1490
  async delete(_id, _namespace) {
@@ -1875,13 +1862,11 @@ var init_QdrantProvider = __esm({
1875
1862
  if (this.schemaDiscovered) return;
1876
1863
  await this.ping();
1877
1864
  await this.ensureCollection();
1878
- console.log(`[QdrantProvider] \u{1F50D} Discovering schema for collection "${this.indexName}"...`);
1879
1865
  const discoveredFields = await this.discoverSchema();
1880
1866
  const opts = this.config.options;
1881
1867
  const configFields = opts.filterableFields || [];
1882
1868
  const allFields = [.../* @__PURE__ */ new Set([...discoveredFields, ...configFields])];
1883
1869
  if (allFields.length > 0) {
1884
- console.log(`[QdrantProvider] \u{1F6E0} Ensuring indexes for ${allFields.length} discovered fields...`);
1885
1870
  await Promise.all(
1886
1871
  allFields.map(async (fieldInfo) => {
1887
1872
  const [fieldName, schemaType] = fieldInfo.split(":");
@@ -1889,7 +1874,6 @@ var init_QdrantProvider = __esm({
1889
1874
  })
1890
1875
  );
1891
1876
  } else {
1892
- console.log(`[QdrantProvider] \u2139\uFE0F No fields discovered for indexing.`);
1893
1877
  }
1894
1878
  this.schemaDiscovered = true;
1895
1879
  }
@@ -1933,19 +1917,16 @@ var init_QdrantProvider = __esm({
1933
1917
  var _a3;
1934
1918
  try {
1935
1919
  await this.http.get(`/collections/${this.indexName}`);
1936
- console.log(`[QdrantProvider] \u2705 Collection "${this.indexName}" already exists.`);
1937
1920
  } catch (err) {
1938
1921
  if (import_axios4.default.isAxiosError(err) && ((_a3 = err.response) == null ? void 0 : _a3.status) === 404) {
1939
1922
  const opts = this.config.options;
1940
1923
  const dimensionsForCreate = opts.dimensions || 1536;
1941
- console.log(`[QdrantProvider] \u23F3 Creating collection "${this.indexName}" (dimensions: ${dimensionsForCreate})...`);
1942
1924
  await this.http.put(`/collections/${this.indexName}`, {
1943
1925
  vectors: {
1944
1926
  size: dimensionsForCreate,
1945
1927
  distance: "Cosine"
1946
1928
  }
1947
1929
  });
1948
- console.log(`[QdrantProvider] \u2705 Created collection "${this.indexName}"`);
1949
1930
  } else {
1950
1931
  throw err;
1951
1932
  }
@@ -1965,7 +1946,6 @@ var init_QdrantProvider = __esm({
1965
1946
  field_name: fullPath,
1966
1947
  field_schema: schema
1967
1948
  });
1968
- console.log(`[QdrantProvider] \u2705 Ensured ${schema} index for "${fullPath}"`);
1969
1949
  } catch (err) {
1970
1950
  let status;
1971
1951
  if (import_axios4.default.isAxiosError(err)) status = (_a3 = err.response) == null ? void 0 : _a3.status;
@@ -2118,15 +2098,12 @@ var init_ChromaDBProvider = __esm({
2118
2098
  try {
2119
2099
  const { data } = await this.http.get(`/api/v1/collections/${this.indexName}`);
2120
2100
  this.collectionId = data.id;
2121
- console.log(`[ChromaDBProvider] \u2705 Collection "${this.indexName}" found (id: ${this.collectionId})`);
2122
2101
  } catch (err) {
2123
2102
  if (import_axios5.default.isAxiosError(err) && ((_a3 = err.response) == null ? void 0 : _a3.status) === 404) {
2124
- console.log(`[ChromaDBProvider] \u23F3 Collection "${this.indexName}" not found. Creating...`);
2125
2103
  const { data } = await this.http.post("/api/v1/collections", {
2126
2104
  name: this.indexName
2127
2105
  });
2128
2106
  this.collectionId = data.id;
2129
- console.log(`[ChromaDBProvider] \u2705 Created collection "${this.indexName}" (id: ${this.collectionId})`);
2130
2107
  } else {
2131
2108
  throw err;
2132
2109
  }
@@ -2612,7 +2589,6 @@ var init_SimpleGraphProvider = __esm({
2612
2589
  this.edges = [];
2613
2590
  }
2614
2591
  async initialize() {
2615
- console.log("[SimpleGraphProvider] Initialised in-memory graph store.");
2616
2592
  }
2617
2593
  async addNodes(nodes) {
2618
2594
  for (const node of nodes) {
@@ -3033,7 +3009,7 @@ function readEnum(env, name, fallback, allowed) {
3033
3009
  throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
3034
3010
  }
3035
3011
  function getEnvConfig(env = process.env, base) {
3036
- 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;
3012
+ 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;
3037
3013
  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;
3038
3014
  const jwtProjectId = (() => {
3039
3015
  if (!licenseKey) return void 0;
@@ -3135,26 +3111,12 @@ function getEnvConfig(env = process.env, base) {
3135
3111
  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;
3136
3112
  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;
3137
3113
  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";
3138
- console.log("[serverConfig] \u{1F527} LLM Configuration:", {
3139
- baseUrl: llmBaseUrl,
3140
- model: llmModel,
3141
- provider: llmProvider,
3142
- hasApiKey: !!llmApiKey,
3143
- source: (rt == null ? void 0 : rt.llmModel) ? "runtime-injected" : "env/fallback"
3144
- });
3145
3114
  const defaultEmbeddingProvider = "universal_rest";
3146
3115
  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;
3147
3116
  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;
3148
3117
  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;
3149
3118
  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;
3150
3119
  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";
3151
- console.log("[serverConfig] \u{1F527} Embedding Configuration:", {
3152
- baseUrl: embeddingBaseUrl,
3153
- model: embeddingModel,
3154
- provider: embeddingProvider,
3155
- hasApiKey: !!embeddingApiKey,
3156
- source: (rt == null ? void 0 : rt.embeddingModel) ? "runtime-injected" : "env/fallback"
3157
- });
3158
3120
  return __spreadProps(__spreadValues({
3159
3121
  projectId,
3160
3122
  licenseKey,
@@ -3168,8 +3130,8 @@ function getEnvConfig(env = process.env, base) {
3168
3130
  model: llmModel,
3169
3131
  apiKey: llmApiKey,
3170
3132
  baseUrl: llmBaseUrl,
3171
- systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
3172
- maxTokens: readNumber(env, "LLM_MAX_TOKENS", 4096),
3133
+ systemPrompt: (_hb = readString(env, "LLM_SYSTEM_PROMPT")) != null ? _hb : rt == null ? void 0 : rt.systemPrompt,
3134
+ maxTokens: readNumber(env, "LLM_MAX_TOKENS", (_ib = rt == null ? void 0 : rt.maxTokens) != null ? _ib : 4096),
3173
3135
  temperature: readNumber(env, "LLM_TEMPERATURE", 0.7),
3174
3136
  options: {
3175
3137
  profile: llmProfile,
@@ -3190,30 +3152,30 @@ function getEnvConfig(env = process.env, base) {
3190
3152
  }
3191
3153
  },
3192
3154
  ui: {
3193
- title: (_ib = (_hb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _hb : readString(env, "UI_TITLE")) != null ? _ib : "AI Assistant",
3194
- subtitle: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _jb : readString(env, "UI_SUBTITLE")) != null ? _kb : "Powered by RAG",
3195
- primaryColor: (_mb = (_lb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _lb : readString(env, "UI_PRIMARY_COLOR")) != null ? _mb : "#10b981",
3196
- accentColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _nb : readString(env, "UI_ACCENT_COLOR")) != null ? _ob : "#3b82f6",
3197
- logoUrl: (_pb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _pb : readString(env, "UI_LOGO_URL"),
3198
- placeholder: (_rb = (_qb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _qb : readString(env, "UI_PLACEHOLDER")) != null ? _rb : "Ask me anything\u2026",
3199
- showSources: ((_tb = (_sb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _sb : readString(env, "UI_SHOW_SOURCES")) != null ? _tb : "true") !== "false",
3200
- 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.",
3201
- visualStyle: (_xb = (_wb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _wb : readString(env, "UI_VISUAL_STYLE")) != null ? _xb : "glass",
3202
- borderRadius: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _yb : readString(env, "UI_BORDER_RADIUS")) != null ? _zb : "xl",
3203
- allowUpload: ((_Bb = (_Ab = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Ab : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Bb : "false") === "true"
3155
+ title: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _jb : readString(env, "UI_TITLE")) != null ? _kb : "AI Assistant",
3156
+ subtitle: (_mb = (_lb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _lb : readString(env, "UI_SUBTITLE")) != null ? _mb : "Powered by RAG",
3157
+ primaryColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _nb : readString(env, "UI_PRIMARY_COLOR")) != null ? _ob : "#10b981",
3158
+ accentColor: (_qb = (_pb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _pb : readString(env, "UI_ACCENT_COLOR")) != null ? _qb : "#3b82f6",
3159
+ logoUrl: (_rb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _rb : readString(env, "UI_LOGO_URL"),
3160
+ placeholder: (_tb = (_sb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _sb : readString(env, "UI_PLACEHOLDER")) != null ? _tb : "Ask me anything\u2026",
3161
+ showSources: ((_vb = (_ub = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ub : readString(env, "UI_SHOW_SOURCES")) != null ? _vb : "true") !== "false",
3162
+ 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.",
3163
+ visualStyle: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _yb : readString(env, "UI_VISUAL_STYLE")) != null ? _zb : "glass",
3164
+ borderRadius: (_Bb = (_Ab = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _Ab : readString(env, "UI_BORDER_RADIUS")) != null ? _Bb : "xl",
3165
+ allowUpload: ((_Db = (_Cb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Cb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Db : "false") === "true"
3204
3166
  },
3205
3167
  rag: {
3206
- topK: readNumber(env, "RAG_TOP_K", 5),
3168
+ topK: readNumber(env, "RAG_TOP_K", (_Eb = rt == null ? void 0 : rt.topK) != null ? _Eb : 5),
3207
3169
  scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
3208
- chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
3209
- chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
3210
- filterableFields: (_Cb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Cb.split(",").map((f) => f.trim()),
3170
+ chunkSize: readNumber(env, "RAG_CHUNK_SIZE", (_Fb = rt == null ? void 0 : rt.chunkSize) != null ? _Fb : 1e3),
3171
+ chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", (_Gb = rt == null ? void 0 : rt.chunkOverlap) != null ? _Gb : 200),
3172
+ filterableFields: (_Hb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Hb.split(",").map((f) => f.trim()),
3211
3173
  // Query pipeline toggles — read from .env.local
3212
3174
  useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
3213
3175
  useReranking: readString(env, "RAG_USE_RERANKING") === "true",
3214
3176
  useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
3215
- architecture: (_Db = readString(env, "RAG_ARCHITECTURE")) != null ? _Db : "simple",
3216
- chunkingStrategy: (_Eb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Eb : "recursive",
3177
+ architecture: (_Ib = readString(env, "RAG_ARCHITECTURE")) != null ? _Ib : "simple",
3178
+ chunkingStrategy: (_Jb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Jb : "recursive",
3217
3179
  uiMapping: (() => {
3218
3180
  const raw = readString(env, "RAG_UI_MAPPING");
3219
3181
  if (!raw) return void 0;
@@ -3226,7 +3188,7 @@ function getEnvConfig(env = process.env, base) {
3226
3188
  },
3227
3189
  telemetry: {
3228
3190
  enabled: telemetryEnabled,
3229
- 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"
3191
+ 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"
3230
3192
  }
3231
3193
  }, readString(env, "GRAPH_DB_PROVIDER") ? {
3232
3194
  graphDb: {
@@ -4537,12 +4499,6 @@ var UniversalLLMAdapter = class {
4537
4499
  this.resolvedHeaders = __spreadValues(__spreadValues({
4538
4500
  "Content-Type": "application/json"
4539
4501
  }, config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}), this.opts.headers || {});
4540
- console.log("[UniversalLLMAdapter] Initialized with:", {
4541
- model: this.model,
4542
- baseUrl: this.baseUrl,
4543
- hasApiKey: !!this.apiKey,
4544
- apiKeyPrefix: this.apiKey ? `${this.apiKey.slice(0, 12)}...` : void 0
4545
- });
4546
4502
  this.http = import_axios2.default.create({
4547
4503
  baseURL: this.baseUrl,
4548
4504
  headers: this.resolvedHeaders,
@@ -4759,15 +4715,10 @@ ${context != null ? context : "None"}` },
4759
4715
  const path2 = (_a3 = this.opts.embedPath) != null ? _a3 : "/embeddings";
4760
4716
  const payload = this.opts.embedPayloadTemplate ? buildPayload(this.opts.embedPayloadTemplate, { input: text, model: this.model }) : { input: text, model: this.model };
4761
4717
  try {
4762
- console.log(`[UniversalLLMAdapter] Posting to embedding endpoint: ${this.baseUrl}${path2}`, {
4763
- model: this.model,
4764
- inputLength: typeof text === "string" ? text.length : "unknown"
4765
- });
4766
4718
  const { data } = await this.http.post(path2, payload);
4767
4719
  const extractPath = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
4768
4720
  const vector = resolvePath(data, extractPath);
4769
4721
  if (Array.isArray(vector)) {
4770
- console.log(`[UniversalLLMAdapter] Embedding HTTP request successful. Vector size: ${vector.length}`);
4771
4722
  return vector;
4772
4723
  }
4773
4724
  console.warn(
@@ -4793,12 +4744,10 @@ ${context != null ? context : "None"}` },
4793
4744
  }
4794
4745
  }
4795
4746
  try {
4796
- console.log(`[UniversalLLMAdapter] Retrying embedding request to: ${this.baseUrl}${path2}`);
4797
4747
  const { data } = await this.http.post(path2, payload);
4798
4748
  const extractPath = (_f = this.opts.embedExtractPath) != null ? _f : "data[0].embedding";
4799
4749
  const vector = resolvePath(data, extractPath);
4800
4750
  if (Array.isArray(vector)) {
4801
- console.log(`[UniversalLLMAdapter] Retry embedding HTTP request successful. Vector size: ${vector.length}`);
4802
4751
  return vector;
4803
4752
  }
4804
4753
  console.error(
@@ -4862,7 +4811,6 @@ var LLMFactory = class _LLMFactory {
4862
4811
  */
4863
4812
  static register(name, factory) {
4864
4813
  customProviders.set(name.toLowerCase(), factory);
4865
- console.log(`[LLMFactory] Registered custom provider: "${name}"`);
4866
4814
  }
4867
4815
  /**
4868
4816
  * Unregister a previously registered custom provider.
@@ -5642,7 +5590,6 @@ var MCPClient = class {
5642
5590
  });
5643
5591
  await this.sendNotification("notifications/initialized");
5644
5592
  this.initialized = true;
5645
- console.log(`[MCPClient] Connected and initialized server "${this.config.name}" successfully.`);
5646
5593
  } catch (err) {
5647
5594
  this.disconnect();
5648
5595
  throw new Error(`[MCPClient] Failed to initialize server "${this.config.name}": ${err.message}`);
@@ -5668,7 +5615,6 @@ var MCPClient = class {
5668
5615
  console.warn(`[MCPClient] [stderr] [${this.config.name}]:`, data.toString("utf-8"));
5669
5616
  });
5670
5617
  this.childProcess.on("close", (code) => {
5671
- console.log(`[MCPClient] Connection closed for "${this.config.name}" with exit code: ${code}`);
5672
5618
  this.disconnect();
5673
5619
  });
5674
5620
  await new Promise((resolve) => setTimeout(resolve, 100));
@@ -6797,13 +6743,11 @@ var LLMRouter = class {
6797
6743
  const providerFastDefault = (_a3 = FAST_MODEL_DEFAULTS[this.config.llm.provider]) != null ? _a3 : "";
6798
6744
  const fastModelName = envFastModel || providerFastDefault;
6799
6745
  if (fastModelName && fastModelName !== this.config.llm.model) {
6800
- console.log(`[LLMRouter] Fast role \u2192 provider="${this.config.llm.provider}" model="${fastModelName}"`);
6801
6746
  const fastConfig = __spreadProps(__spreadValues({}, this.config.llm), {
6802
6747
  model: fastModelName
6803
6748
  });
6804
6749
  this.models.set("fast", LLMFactory.create(fastConfig, this.config.embedding));
6805
6750
  } else {
6806
- console.log(`[LLMRouter] Fast role \u2192 reusing default model (no lightweight alternative configured).`);
6807
6751
  this.models.set("fast", defaultModel);
6808
6752
  }
6809
6753
  this.models.set("powerful", defaultModel);
@@ -8791,7 +8735,6 @@ var SchemaMapper = class {
8791
8735
  }
8792
8736
  static async _doTrain(llm, cacheKey, keys) {
8793
8737
  var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
8794
- console.log(`[SchemaMapper] \u{1F9E0} Training on new schema keys: ${keys.join(", ")}`);
8795
8738
  const propertyList = Object.entries(this.TARGET_PROPERTIES).map(([prop, desc]) => `- ${prop} (${desc})`).join("\n");
8796
8739
  const messages = [
8797
8740
  { role: "system", content: "You are a database schema expert. Respond ONLY with valid JSON." },
@@ -11450,7 +11393,6 @@ function createStreamHandler(configOrPlugin, options) {
11450
11393
  },
11451
11394
  cancel(reason) {
11452
11395
  isActive = false;
11453
- console.log("[createStreamHandler] Stream connection closed by client:", reason);
11454
11396
  }
11455
11397
  });
11456
11398
  return new Response(stream, { headers: __spreadProps(__spreadValues({}, SSE_HEADERS), { "x-message-id": assistantMsgId, "x-user-message-id": userMsgId }) });
@@ -11541,7 +11483,6 @@ function createLicenseHandler(configOrPlugin, options) {
11541
11483
  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 || "";
11542
11484
  const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
11543
11485
  const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "";
11544
- console.log(`[DEBUG] createLicenseHandler: projectId="${projectId}", body.projectId="${body == null ? void 0 : body.projectId}", config.projectId="${config.projectId}"`);
11545
11486
  const payload = await LicenseVerifier.verifyAsync(licenseKey, projectId);
11546
11487
  return import_server.NextResponse.json({
11547
11488
  valid: true,
@@ -11572,7 +11513,6 @@ function createUploadHandler(configOrPlugin, options) {
11572
11513
  const plugin = getOrCreatePlugin(configOrPlugin);
11573
11514
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
11574
11515
  return async function POST(req, context) {
11575
- console.log("Upload handler invoked");
11576
11516
  const authResult = await checkAuth(req, onAuthorize);
11577
11517
  if (authResult) return authResult;
11578
11518
  const config = plugin.getConfig();
@@ -11581,7 +11521,6 @@ function createUploadHandler(configOrPlugin, options) {
11581
11521
  try {
11582
11522
  const formData = await req.formData();
11583
11523
  const files = formData.getAll("files");
11584
- console.log("Files received for upload:", files.map((f) => f.name));
11585
11524
  const namespace = formData.get("namespace") || void 0;
11586
11525
  const dimensionRaw = formData.get("dimension");
11587
11526
  const dimension = dimensionRaw ? parseInt(dimensionRaw, 10) : void 0;
@@ -11919,7 +11858,7 @@ function createRagHandler(configOrPlugin, options) {
11919
11858
  }
11920
11859
  }
11921
11860
  async function getSegment(req, context) {
11922
- var _a3, _b;
11861
+ var _a3, _b, _c;
11923
11862
  const contentType = req.headers.get("content-type") || "";
11924
11863
  if (contentType.includes("multipart/form-data")) {
11925
11864
  return "upload";
@@ -11934,10 +11873,12 @@ function createRagHandler(configOrPlugin, options) {
11934
11873
  if (pathname.endsWith("/suggestions")) return "suggestions";
11935
11874
  if (pathname.endsWith("/feedback")) return "feedback";
11936
11875
  if (pathname.endsWith("/history")) return "history";
11876
+ if (pathname.endsWith("/history/clear")) return "history/clear";
11877
+ if (pathname.endsWith("/sessions")) return "sessions";
11937
11878
  } catch (e) {
11938
11879
  }
11939
11880
  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;
11940
- const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || [];
11881
+ 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) || [];
11941
11882
  const joined = segments.join("/");
11942
11883
  return joined || "chat";
11943
11884
  }