@retrivora-ai/rag-engine 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.mjs CHANGED
@@ -315,7 +315,7 @@ var init_package = __esm({
315
315
  "package.json"() {
316
316
  package_default = {
317
317
  name: "@retrivora-ai/rag-engine",
318
- version: "2.4.0",
318
+ version: "2.4.2",
319
319
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
320
320
  author: "Abhinav Alkuchi",
321
321
  license: "UNLICENSED",
@@ -510,7 +510,6 @@ var init_ConfigFetcher = __esm({
510
510
  for (const baseUrl of controlPlaneUrls) {
511
511
  try {
512
512
  const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}`;
513
- console.log(`[ConfigFetcher] Fetching config from: ${url}`);
514
513
  const res = await fetch(url, {
515
514
  method: "GET",
516
515
  headers: __spreadValues({
@@ -518,7 +517,6 @@ var init_ConfigFetcher = __esm({
518
517
  "x-sdk-version": SDK_VERSION
519
518
  }, licenseKey ? { "x-license-key": licenseKey } : {})
520
519
  });
521
- console.log(`[ConfigFetcher] Response status: ${res.status}`);
522
520
  if (!res.ok) {
523
521
  console.warn(`[ConfigFetcher] Error text: ${await res.text()}`);
524
522
  }
@@ -1237,9 +1235,6 @@ var init_MultiTablePostgresProvider = __esm({
1237
1235
  if (this.tables.length === 0) {
1238
1236
  console.warn('[MultiTablePostgresProvider] No tables with "embedding" columns found in the database.');
1239
1237
  } else {
1240
- console.log(
1241
- `[MultiTablePostgresProvider] Connected. Searching across ${this.tables.length} table(s): ${this.tables.join(", ")}`
1242
- );
1243
1238
  }
1244
1239
  } finally {
1245
1240
  client.release();
@@ -1361,11 +1356,8 @@ var init_MultiTablePostgresProvider = __esm({
1361
1356
  }
1362
1357
  const vectorLiteral = `[${vector.join(",")}]`;
1363
1358
  const allResults = [];
1364
- console.log(`[MultiTablePostgresProvider] --- Starting Multi-Table Search ---`);
1365
1359
  const queryText = _filter == null ? void 0 : _filter.queryText;
1366
1360
  const entityHints = Array.isArray(_filter == null ? void 0 : _filter.keywords) ? _filter.keywords.map((k) => k.trim().toLowerCase()).filter(Boolean) : [];
1367
- console.log(`[MultiTablePostgresProvider] queryText: "${queryText}"`);
1368
- console.log(`[MultiTablePostgresProvider] entityHints: [${entityHints.join(", ")}]`);
1369
1361
  const getDynamicKeywordQuery = () => {
1370
1362
  if (entityHints.length > 0) {
1371
1363
  return entityHints.map((h) => h.replace(/\s+/g, " & ")).join(" & ");
@@ -1453,9 +1445,7 @@ var init_MultiTablePostgresProvider = __esm({
1453
1445
  }
1454
1446
  const result = await this.pool.query(sqlQuery, params);
1455
1447
  if (result.rowCount && result.rowCount > 0) {
1456
- console.log(` \u2705 Table "${table}": Found ${result.rowCount} potential matches. Top score: ${result.rows[0].hybrid_score.toFixed(4)}`);
1457
1448
  } else {
1458
- console.log(` \u26AA Table "${table}": No relevant matches found.`);
1459
1449
  }
1460
1450
  const tableResults = [];
1461
1451
  for (const row of result.rows) {
@@ -1493,9 +1483,6 @@ var init_MultiTablePostgresProvider = __esm({
1493
1483
  var _a4;
1494
1484
  return ((_a4 = res.metadata) == null ? void 0 : _a4.source_table) === bestMatchTable;
1495
1485
  });
1496
- console.log(`[MultiTablePostgresProvider] --- Search Complete ---`);
1497
- console.log(`[MultiTablePostgresProvider] Final top match from "${bestMatchTable}" with score ${finalSorted[0].score.toFixed(4)}`);
1498
- console.log(`[MultiTablePostgresProvider] Restricting recommendations strictly to table: "${bestMatchTable}"`);
1499
1486
  return finalSorted.slice(0, Math.max(topK, 15));
1500
1487
  }
1501
1488
  async delete(_id, _namespace) {
@@ -1873,13 +1860,11 @@ var init_QdrantProvider = __esm({
1873
1860
  if (this.schemaDiscovered) return;
1874
1861
  await this.ping();
1875
1862
  await this.ensureCollection();
1876
- console.log(`[QdrantProvider] \u{1F50D} Discovering schema for collection "${this.indexName}"...`);
1877
1863
  const discoveredFields = await this.discoverSchema();
1878
1864
  const opts = this.config.options;
1879
1865
  const configFields = opts.filterableFields || [];
1880
1866
  const allFields = [.../* @__PURE__ */ new Set([...discoveredFields, ...configFields])];
1881
1867
  if (allFields.length > 0) {
1882
- console.log(`[QdrantProvider] \u{1F6E0} Ensuring indexes for ${allFields.length} discovered fields...`);
1883
1868
  await Promise.all(
1884
1869
  allFields.map(async (fieldInfo) => {
1885
1870
  const [fieldName, schemaType] = fieldInfo.split(":");
@@ -1887,7 +1872,6 @@ var init_QdrantProvider = __esm({
1887
1872
  })
1888
1873
  );
1889
1874
  } else {
1890
- console.log(`[QdrantProvider] \u2139\uFE0F No fields discovered for indexing.`);
1891
1875
  }
1892
1876
  this.schemaDiscovered = true;
1893
1877
  }
@@ -1931,19 +1915,16 @@ var init_QdrantProvider = __esm({
1931
1915
  var _a3;
1932
1916
  try {
1933
1917
  await this.http.get(`/collections/${this.indexName}`);
1934
- console.log(`[QdrantProvider] \u2705 Collection "${this.indexName}" already exists.`);
1935
1918
  } catch (err) {
1936
1919
  if (axios4.isAxiosError(err) && ((_a3 = err.response) == null ? void 0 : _a3.status) === 404) {
1937
1920
  const opts = this.config.options;
1938
1921
  const dimensionsForCreate = opts.dimensions || 1536;
1939
- console.log(`[QdrantProvider] \u23F3 Creating collection "${this.indexName}" (dimensions: ${dimensionsForCreate})...`);
1940
1922
  await this.http.put(`/collections/${this.indexName}`, {
1941
1923
  vectors: {
1942
1924
  size: dimensionsForCreate,
1943
1925
  distance: "Cosine"
1944
1926
  }
1945
1927
  });
1946
- console.log(`[QdrantProvider] \u2705 Created collection "${this.indexName}"`);
1947
1928
  } else {
1948
1929
  throw err;
1949
1930
  }
@@ -1963,7 +1944,6 @@ var init_QdrantProvider = __esm({
1963
1944
  field_name: fullPath,
1964
1945
  field_schema: schema
1965
1946
  });
1966
- console.log(`[QdrantProvider] \u2705 Ensured ${schema} index for "${fullPath}"`);
1967
1947
  } catch (err) {
1968
1948
  let status;
1969
1949
  if (axios4.isAxiosError(err)) status = (_a3 = err.response) == null ? void 0 : _a3.status;
@@ -2116,15 +2096,12 @@ var init_ChromaDBProvider = __esm({
2116
2096
  try {
2117
2097
  const { data } = await this.http.get(`/api/v1/collections/${this.indexName}`);
2118
2098
  this.collectionId = data.id;
2119
- console.log(`[ChromaDBProvider] \u2705 Collection "${this.indexName}" found (id: ${this.collectionId})`);
2120
2099
  } catch (err) {
2121
2100
  if (axios5.isAxiosError(err) && ((_a3 = err.response) == null ? void 0 : _a3.status) === 404) {
2122
- console.log(`[ChromaDBProvider] \u23F3 Collection "${this.indexName}" not found. Creating...`);
2123
2101
  const { data } = await this.http.post("/api/v1/collections", {
2124
2102
  name: this.indexName
2125
2103
  });
2126
2104
  this.collectionId = data.id;
2127
- console.log(`[ChromaDBProvider] \u2705 Created collection "${this.indexName}" (id: ${this.collectionId})`);
2128
2105
  } else {
2129
2106
  throw err;
2130
2107
  }
@@ -2610,7 +2587,6 @@ var init_SimpleGraphProvider = __esm({
2610
2587
  this.edges = [];
2611
2588
  }
2612
2589
  async initialize() {
2613
- console.log("[SimpleGraphProvider] Initialised in-memory graph store.");
2614
2590
  }
2615
2591
  async addNodes(nodes) {
2616
2592
  for (const node of nodes) {
@@ -2996,13 +2972,6 @@ var UI_BORDER_RADIUS_OPTIONS = ["none", "sm", "md", "lg", "xl", "full"];
2996
2972
  var _runtimeConfig = null;
2997
2973
  function injectRuntimeConfig(config) {
2998
2974
  _runtimeConfig = config;
2999
- console.log("[serverConfig] \u2705 Runtime tier config injected:", {
3000
- tier: config.tier,
3001
- llmModel: config.llmModel,
3002
- embeddingModel: config.embeddingModel,
3003
- llmBaseUrl: config.llmBaseUrl,
3004
- hasLitellmKey: !!config.litellmApiKey
3005
- });
3006
2975
  }
3007
2976
  function getRuntimeConfig() {
3008
2977
  return _runtimeConfig;
@@ -3135,26 +3104,12 @@ function getEnvConfig(env = process.env, base) {
3135
3104
  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
3105
  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
3106
  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
3107
  const defaultEmbeddingProvider = "universal_rest";
3146
3108
  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
3109
  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
3110
  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
3111
  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
3112
  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
3113
  return __spreadProps(__spreadValues({
3159
3114
  projectId,
3160
3115
  licenseKey,
@@ -4576,12 +4531,6 @@ var UniversalLLMAdapter = class {
4576
4531
  this.resolvedHeaders = __spreadValues(__spreadValues({
4577
4532
  "Content-Type": "application/json"
4578
4533
  }, config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}), this.opts.headers || {});
4579
- console.log("[UniversalLLMAdapter] Initialized with:", {
4580
- model: this.model,
4581
- baseUrl: this.baseUrl,
4582
- hasApiKey: !!this.apiKey,
4583
- apiKeyPrefix: this.apiKey ? `${this.apiKey.slice(0, 12)}...` : void 0
4584
- });
4585
4534
  this.http = axios2.create({
4586
4535
  baseURL: this.baseUrl,
4587
4536
  headers: this.resolvedHeaders,
@@ -4798,15 +4747,10 @@ ${context != null ? context : "None"}` },
4798
4747
  const path2 = (_a3 = this.opts.embedPath) != null ? _a3 : "/embeddings";
4799
4748
  const payload = this.opts.embedPayloadTemplate ? buildPayload(this.opts.embedPayloadTemplate, { input: text, model: this.model }) : { input: text, model: this.model };
4800
4749
  try {
4801
- console.log(`[UniversalLLMAdapter] Posting to embedding endpoint: ${this.baseUrl}${path2}`, {
4802
- model: this.model,
4803
- inputLength: typeof text === "string" ? text.length : "unknown"
4804
- });
4805
4750
  const { data } = await this.http.post(path2, payload);
4806
4751
  const extractPath = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
4807
4752
  const vector = resolvePath(data, extractPath);
4808
4753
  if (Array.isArray(vector)) {
4809
- console.log(`[UniversalLLMAdapter] Embedding HTTP request successful. Vector size: ${vector.length}`);
4810
4754
  return vector;
4811
4755
  }
4812
4756
  console.warn(
@@ -4832,12 +4776,10 @@ ${context != null ? context : "None"}` },
4832
4776
  }
4833
4777
  }
4834
4778
  try {
4835
- console.log(`[UniversalLLMAdapter] Retrying embedding request to: ${this.baseUrl}${path2}`);
4836
4779
  const { data } = await this.http.post(path2, payload);
4837
4780
  const extractPath = (_f = this.opts.embedExtractPath) != null ? _f : "data[0].embedding";
4838
4781
  const vector = resolvePath(data, extractPath);
4839
4782
  if (Array.isArray(vector)) {
4840
- console.log(`[UniversalLLMAdapter] Retry embedding HTTP request successful. Vector size: ${vector.length}`);
4841
4783
  return vector;
4842
4784
  }
4843
4785
  console.error(
@@ -4901,7 +4843,6 @@ var LLMFactory = class _LLMFactory {
4901
4843
  */
4902
4844
  static register(name, factory) {
4903
4845
  customProviders.set(name.toLowerCase(), factory);
4904
- console.log(`[LLMFactory] Registered custom provider: "${name}"`);
4905
4846
  }
4906
4847
  /**
4907
4848
  * Unregister a previously registered custom provider.
@@ -5681,7 +5622,6 @@ var MCPClient = class {
5681
5622
  });
5682
5623
  await this.sendNotification("notifications/initialized");
5683
5624
  this.initialized = true;
5684
- console.log(`[MCPClient] Connected and initialized server "${this.config.name}" successfully.`);
5685
5625
  } catch (err) {
5686
5626
  this.disconnect();
5687
5627
  throw new Error(`[MCPClient] Failed to initialize server "${this.config.name}": ${err.message}`);
@@ -5707,7 +5647,6 @@ var MCPClient = class {
5707
5647
  console.warn(`[MCPClient] [stderr] [${this.config.name}]:`, data.toString("utf-8"));
5708
5648
  });
5709
5649
  this.childProcess.on("close", (code) => {
5710
- console.log(`[MCPClient] Connection closed for "${this.config.name}" with exit code: ${code}`);
5711
5650
  this.disconnect();
5712
5651
  });
5713
5652
  await new Promise((resolve) => setTimeout(resolve, 100));
@@ -6842,13 +6781,11 @@ var LLMRouter = class {
6842
6781
  const providerFastDefault = (_a3 = FAST_MODEL_DEFAULTS[this.config.llm.provider]) != null ? _a3 : "";
6843
6782
  const fastModelName = envFastModel || providerFastDefault;
6844
6783
  if (fastModelName && fastModelName !== this.config.llm.model) {
6845
- console.log(`[LLMRouter] Fast role \u2192 provider="${this.config.llm.provider}" model="${fastModelName}"`);
6846
6784
  const fastConfig = __spreadProps(__spreadValues({}, this.config.llm), {
6847
6785
  model: fastModelName
6848
6786
  });
6849
6787
  this.models.set("fast", LLMFactory.create(fastConfig, this.config.embedding));
6850
6788
  } else {
6851
- console.log(`[LLMRouter] Fast role \u2192 reusing default model (no lightweight alternative configured).`);
6852
6789
  this.models.set("fast", defaultModel);
6853
6790
  }
6854
6791
  this.models.set("powerful", defaultModel);
@@ -8844,7 +8781,6 @@ var SchemaMapper = class {
8844
8781
  }
8845
8782
  static async _doTrain(llm, cacheKey, keys) {
8846
8783
  var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
8847
- console.log(`[SchemaMapper] \u{1F9E0} Training on new schema keys: ${keys.join(", ")}`);
8848
8784
  const propertyList = Object.entries(this.TARGET_PROPERTIES).map(([prop, desc]) => `- ${prop} (${desc})`).join("\n");
8849
8785
  const messages = [
8850
8786
  { role: "system", content: "You are a database schema expert. Respond ONLY with valid JSON." },
@@ -11807,7 +11743,6 @@ function createStreamHandler(configOrPlugin, options) {
11807
11743
  },
11808
11744
  cancel(reason) {
11809
11745
  isActive = false;
11810
- console.log("[createStreamHandler] Stream connection closed by client:", reason);
11811
11746
  }
11812
11747
  });
11813
11748
  return new Response(stream, { headers: __spreadProps(__spreadValues({}, SSE_HEADERS), { "x-message-id": assistantMsgId, "x-user-message-id": userMsgId }) });
@@ -11898,7 +11833,6 @@ function createLicenseHandler(configOrPlugin, options) {
11898
11833
  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 || "";
11899
11834
  const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
11900
11835
  const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "";
11901
- console.log(`[DEBUG] createLicenseHandler: projectId="${projectId}", body.projectId="${body == null ? void 0 : body.projectId}", config.projectId="${config.projectId}"`);
11902
11836
  const payload = await LicenseVerifier.verifyAsync(licenseKey, projectId);
11903
11837
  return NextResponse.json({
11904
11838
  valid: true,
@@ -11929,7 +11863,6 @@ function createUploadHandler(configOrPlugin, options) {
11929
11863
  const plugin = getOrCreatePlugin(configOrPlugin);
11930
11864
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
11931
11865
  return async function POST(req, context) {
11932
- console.log("Upload handler invoked");
11933
11866
  const authResult = await checkAuth(req, onAuthorize);
11934
11867
  if (authResult) return authResult;
11935
11868
  const config = plugin.getConfig();
@@ -11938,7 +11871,6 @@ function createUploadHandler(configOrPlugin, options) {
11938
11871
  try {
11939
11872
  const formData = await req.formData();
11940
11873
  const files = formData.getAll("files");
11941
- console.log("Files received for upload:", files.map((f) => f.name));
11942
11874
  const namespace = formData.get("namespace") || void 0;
11943
11875
  const dimensionRaw = formData.get("dimension");
11944
11876
  const dimension = dimensionRaw ? parseInt(dimensionRaw, 10) : void 0;
@@ -12509,19 +12441,11 @@ var LicenseConfigResolver = class {
12509
12441
  const cacheKey = `${licenseKey}:${projectId}`;
12510
12442
  const cached = this.configCache.get(cacheKey);
12511
12443
  if (cached && Date.now() - cached.timestamp < this.CACHE_TTL_MS) {
12512
- console.log("[LicenseConfigResolver] Using cached config for", projectId);
12513
12444
  return this.buildConfigs(cached.config, cached.credentials, licenseKey, projectId);
12514
12445
  }
12515
- console.log("[LicenseConfigResolver] Fetching tier config from Retrivora...");
12516
12446
  const tierConfig = await this.fetchTierConfig(licenseKey, projectId);
12517
- console.log("[LicenseConfigResolver] Fetching provider credentials from Retrivora...");
12518
12447
  const credentials = await this.fetchProviderCredentials(licenseKey, projectId);
12519
12448
  this.configCache.set(cacheKey, { config: tierConfig, credentials, timestamp: Date.now() });
12520
- console.log("[LicenseConfigResolver] \u2705 Successfully resolved config from Retrivora:", {
12521
- tier: tierConfig.tier,
12522
- llmModel: tierConfig.llmModel,
12523
- embeddingModel: tierConfig.embeddingModel
12524
- });
12525
12449
  return this.buildConfigs(tierConfig, credentials, licenseKey, projectId);
12526
12450
  }
12527
12451
  /**
@@ -12547,7 +12471,6 @@ var LicenseConfigResolver = class {
12547
12471
  `[LicenseConfigResolver] Config API returned error: ${response.data.error || response.data.message}`
12548
12472
  );
12549
12473
  }
12550
- console.log(`[LicenseConfigResolver] Resolved tier: ${response.data.config.tier}`);
12551
12474
  return response.data.config;
12552
12475
  } catch (err) {
12553
12476
  console.error("[LicenseConfigResolver] Failed to fetch config:", err.message);
@@ -12579,7 +12502,6 @@ var LicenseConfigResolver = class {
12579
12502
  `[LicenseConfigResolver] Credentials API returned error: ${response.data.error || response.data.message}`
12580
12503
  );
12581
12504
  }
12582
- console.log(`[LicenseConfigResolver] Retrieved provider credentials for project: ${projectId}`);
12583
12505
  return response.data.credentials;
12584
12506
  } catch (err) {
12585
12507
  console.error("[LicenseConfigResolver] Failed to fetch credentials:", err.message);
@@ -12656,7 +12578,6 @@ var LicenseConfigResolver = class {
12656
12578
  */
12657
12579
  static clearCache() {
12658
12580
  this.configCache.clear();
12659
- console.log("[LicenseConfigResolver] Configuration cache cleared");
12660
12581
  }
12661
12582
  /**
12662
12583
  * Get cache stats for debugging
@@ -12803,7 +12724,6 @@ var _TelemetryService = class _TelemetryService {
12803
12724
  };
12804
12725
  try {
12805
12726
  await this.http.post(_TelemetryService.RETRIVORA_TELEMETRY_URL, payload);
12806
- console.log(`[TelemetryService] Flushed ${events.length} events to Retrivora`);
12807
12727
  } catch (err) {
12808
12728
  console.warn("[TelemetryService] Failed to send telemetry to Retrivora:", err.message);
12809
12729
  this.eventQueue.unshift(...events);
@@ -12817,7 +12737,6 @@ var _TelemetryService = class _TelemetryService {
12817
12737
  "X-Project-ID": this.projectId
12818
12738
  }
12819
12739
  });
12820
- console.log(`[TelemetryService] Flushed ${events.length} events to user telemetry`);
12821
12740
  } catch (err) {
12822
12741
  console.warn("[TelemetryService] Failed to send telemetry to user endpoint:", err.message);
12823
12742
  }
@@ -12871,7 +12790,6 @@ function getTelemetryService() {
12871
12790
  }
12872
12791
  function initializeTelemetryService(projectId, licenseKey, userTelemetryUrl) {
12873
12792
  globalTelemetryService = new TelemetryService(projectId, licenseKey, userTelemetryUrl);
12874
- console.log("[TelemetryService] Initialized for project:", projectId);
12875
12793
  return globalTelemetryService;
12876
12794
  }
12877
12795
  async function shutdownTelemetryService() {
@@ -12902,13 +12820,12 @@ var LicensedRetrivora = class {
12902
12820
  */
12903
12821
  async initialize() {
12904
12822
  if (this.initialized) {
12905
- console.log("[LicensedRetrivora] Already initialized");
12906
12823
  return;
12907
12824
  }
12908
- console.log("[LicensedRetrivora] Initializing with license key...");
12909
12825
  const operationId = this.generateId();
12910
12826
  try {
12911
12827
  const { llmConfig, embeddingConfig, vectorDbConfig, tierConfig } = await LicenseConfigResolver.resolveFromLicense(this.licenseKey, this.projectId);
12828
+ this.tierConfig = tierConfig;
12912
12829
  const telemetry = getTelemetryService();
12913
12830
  if (telemetry) {
12914
12831
  telemetry.recordEvent({
@@ -12942,7 +12859,6 @@ var LicensedRetrivora = class {
12942
12859
  this.pipeline = new Pipeline(this.ragConfig);
12943
12860
  await this.pipeline.initialize();
12944
12861
  this.initialized = true;
12945
- console.log(`[LicensedRetrivora] Initialized successfully for tier: ${tierConfig.tier}`);
12946
12862
  } catch (error) {
12947
12863
  const telemetry = getTelemetryService();
12948
12864
  if (telemetry && error instanceof Error) {
@@ -12964,16 +12880,16 @@ var LicensedRetrivora = class {
12964
12880
  const telemetry = getTelemetryService();
12965
12881
  const startTime = Date.now();
12966
12882
  try {
12967
- console.log(`[LicensedRetrivora] Starting ingestion of ${documents.length} document(s)`);
12968
12883
  const results = await this.pipeline.ingest(documents);
12969
12884
  const durationMs = Date.now() - startTime;
12970
12885
  if (telemetry) {
12971
12886
  for (const result of results) {
12887
+ const origDoc = documents.find((d) => String(d.docId) === String(result.docId));
12888
+ const size = origDoc ? new TextEncoder().encode(origDoc.content).length : 0;
12972
12889
  telemetry.recordDocumentIngested({
12973
12890
  documentId: String(result.docId),
12974
12891
  documentName: String(result.docId),
12975
- documentSize: 0,
12976
- // TODO: track actual size
12892
+ documentSize: size,
12977
12893
  chunksGenerated: result.chunksIngested,
12978
12894
  durationMs
12979
12895
  });
@@ -13008,7 +12924,6 @@ var LicensedRetrivora = class {
13008
12924
  const telemetry = getTelemetryService();
13009
12925
  const startTime = Date.now();
13010
12926
  try {
13011
- console.log(`[LicensedRetrivora] Executing query: "${queryText.substring(0, 100)}..."`);
13012
12927
  const response = await this.pipeline.runNormalQuery(queryText);
13013
12928
  const durationMs = Date.now() - startTime;
13014
12929
  if (telemetry) {
@@ -13037,12 +12952,11 @@ var LicensedRetrivora = class {
13037
12952
  * Get license tier information (for UI display if needed)
13038
12953
  */
13039
12954
  async getTierInfo() {
13040
- if (!this.ragConfig) {
12955
+ if (!this.ragConfig || !this.tierConfig) {
13041
12956
  throw new Error("[LicensedRetrivora] SDK not initialized.");
13042
12957
  }
13043
12958
  return {
13044
- tier: "Standard",
13045
- // TODO: fetch from tier config
12959
+ tier: this.tierConfig.tier,
13046
12960
  model: this.ragConfig.llm.model,
13047
12961
  embeddingModel: this.ragConfig.embedding.model
13048
12962
  };
@@ -13053,7 +12967,6 @@ var LicensedRetrivora = class {
13053
12967
  async shutdown() {
13054
12968
  await shutdownTelemetryService();
13055
12969
  this.initialized = false;
13056
- console.log("[LicensedRetrivora] Shutdown complete");
13057
12970
  }
13058
12971
  /**
13059
12972
  * Check if SDK is initialized
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
5
5
  "author": "Abhinav Alkuchi",
6
6
  "license": "UNLICENSED",
@@ -10,12 +10,12 @@
10
10
  * Do NOT import in client components.
11
11
  */
12
12
 
13
- import { LicenseConfigResolver } from './config/LicenseConfigResolver';
13
+ import { LicenseConfigResolver, LicenseTierConfig } from './config/LicenseConfigResolver';
14
14
  import { Pipeline } from './core/Pipeline';
15
15
  import { RagConfig, VectorDBConfig, LLMConfig, EmbeddingConfig } from './config/RagConfig';
16
- import {
17
- initializeTelemetryService,
18
- getTelemetryService,
16
+ import {
17
+ initializeTelemetryService,
18
+ getTelemetryService,
19
19
  shutdownTelemetryService,
20
20
  EventType,
21
21
  } from './telemetry/TelemetryService';
@@ -36,6 +36,7 @@ export class LicensedRetrivora {
36
36
  private projectId: string;
37
37
  private pipeline?: Pipeline;
38
38
  private ragConfig?: RagConfig;
39
+ private tierConfig?: LicenseTierConfig;
39
40
  private initialized: boolean = false;
40
41
 
41
42
  constructor(options: LicensedRetrivoraOptions) {
@@ -60,18 +61,20 @@ export class LicensedRetrivora {
60
61
  */
61
62
  async initialize(): Promise<void> {
62
63
  if (this.initialized) {
63
- console.log('[LicensedRetrivora] Already initialized');
64
+ //console.log('[LicensedRetrivora] Already initialized');
64
65
  return;
65
66
  }
66
67
 
67
- console.log('[LicensedRetrivora] Initializing with license key...');
68
+ //console.log('[LicensedRetrivora] Initializing with license key...');
68
69
  const operationId = this.generateId();
69
70
 
70
71
  try {
71
72
  // Resolve configuration from license tier
72
- const { llmConfig, embeddingConfig, vectorDbConfig, tierConfig } =
73
+ const { llmConfig, embeddingConfig, vectorDbConfig, tierConfig } =
73
74
  await LicenseConfigResolver.resolveFromLicense(this.licenseKey, this.projectId);
74
75
 
76
+ this.tierConfig = tierConfig;
77
+
75
78
  // Log successful configuration load
76
79
  const telemetry = getTelemetryService();
77
80
  if (telemetry) {
@@ -111,7 +114,7 @@ export class LicensedRetrivora {
111
114
  await this.pipeline.initialize();
112
115
 
113
116
  this.initialized = true;
114
- console.log(`[LicensedRetrivora] Initialized successfully for tier: ${tierConfig.tier}`);
117
+ //console.log(`[LicensedRetrivora] Initialized successfully for tier: ${tierConfig.tier}`);
115
118
  } catch (error) {
116
119
  const telemetry = getTelemetryService();
117
120
  if (telemetry && error instanceof Error) {
@@ -136,7 +139,7 @@ export class LicensedRetrivora {
136
139
  const startTime = Date.now();
137
140
 
138
141
  try {
139
- console.log(`[LicensedRetrivora] Starting ingestion of ${documents.length} document(s)`);
142
+ //console.log(`[LicensedRetrivora] Starting ingestion of ${documents.length} document(s)`);
140
143
 
141
144
  // Ingest documents
142
145
  const results = await this.pipeline.ingest(documents);
@@ -146,10 +149,12 @@ export class LicensedRetrivora {
146
149
  // Record successful ingestion
147
150
  if (telemetry) {
148
151
  for (const result of results) {
152
+ const origDoc = documents.find(d => String(d.docId) === String(result.docId));
153
+ const size = origDoc ? new TextEncoder().encode(origDoc.content).length : 0;
149
154
  telemetry.recordDocumentIngested({
150
155
  documentId: String(result.docId),
151
156
  documentName: String(result.docId),
152
- documentSize: 0, // TODO: track actual size
157
+ documentSize: size,
153
158
  chunksGenerated: result.chunksIngested,
154
159
  durationMs,
155
160
  });
@@ -164,7 +169,7 @@ export class LicensedRetrivora {
164
169
  };
165
170
  } catch (error) {
166
171
  const durationMs = Date.now() - startTime;
167
-
172
+
168
173
  if (telemetry && error instanceof Error) {
169
174
  telemetry.recordError(error, { operationId, durationMs });
170
175
  await telemetry.flush();
@@ -189,7 +194,7 @@ export class LicensedRetrivora {
189
194
  const startTime = Date.now();
190
195
 
191
196
  try {
192
- console.log(`[LicensedRetrivora] Executing query: "${queryText.substring(0, 100)}..."`);
197
+ //console.log(`[LicensedRetrivora] Executing query: "${queryText.substring(0, 100)}..."`);
193
198
 
194
199
  // Execute query
195
200
  const response = await this.pipeline.runNormalQuery(queryText);
@@ -213,7 +218,7 @@ export class LicensedRetrivora {
213
218
  };
214
219
  } catch (error) {
215
220
  const durationMs = Date.now() - startTime;
216
-
221
+
217
222
  if (telemetry && error instanceof Error) {
218
223
  telemetry.recordError(error, { operationId, durationMs });
219
224
  await telemetry.flush();
@@ -228,12 +233,12 @@ export class LicensedRetrivora {
228
233
  * Get license tier information (for UI display if needed)
229
234
  */
230
235
  async getTierInfo(): Promise<{ tier: string; model: string; embeddingModel: string }> {
231
- if (!this.ragConfig) {
236
+ if (!this.ragConfig || !this.tierConfig) {
232
237
  throw new Error('[LicensedRetrivora] SDK not initialized.');
233
238
  }
234
239
 
235
240
  return {
236
- tier: 'Standard', // TODO: fetch from tier config
241
+ tier: this.tierConfig.tier,
237
242
  model: this.ragConfig.llm.model,
238
243
  embeddingModel: this.ragConfig.embedding.model,
239
244
  };
@@ -245,7 +250,7 @@ export class LicensedRetrivora {
245
250
  async shutdown(): Promise<void> {
246
251
  await shutdownTelemetryService();
247
252
  this.initialized = false;
248
- console.log('[LicensedRetrivora] Shutdown complete');
253
+ //console.log('[LicensedRetrivora] Shutdown complete');
249
254
  }
250
255
 
251
256
  /**