@retrivora-ai/rag-engine 1.9.8 → 1.9.9

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 (37) hide show
  1. package/README.md +36 -28
  2. package/dist/{ILLMProvider-B8ROITYK.d.mts → ILLMProvider-DMxLyTdq.d.mts} +2 -2
  3. package/dist/{ILLMProvider-B8ROITYK.d.ts → ILLMProvider-DMxLyTdq.d.ts} +2 -2
  4. package/dist/handlers/index.d.mts +2 -2
  5. package/dist/handlers/index.d.ts +2 -2
  6. package/dist/handlers/index.js +140 -28
  7. package/dist/handlers/index.mjs +146 -28
  8. package/dist/{index-DNvoi-sV.d.ts → index-CfkqZd2Y.d.ts} +1 -1
  9. package/dist/{index-CrxCy36A.d.mts → index-DXd29KMq.d.mts} +1 -1
  10. package/dist/{index-BCPKUAVL.d.ts → index-D_bOdJML.d.ts} +1 -1
  11. package/dist/{index-B8PbEFSY.d.mts → index-xygonxpW.d.mts} +1 -1
  12. package/dist/index.css +485 -557
  13. package/dist/index.d.mts +16 -10
  14. package/dist/index.d.ts +16 -10
  15. package/dist/index.js +24 -765
  16. package/dist/index.mjs +20 -779
  17. package/dist/server.d.mts +8 -5
  18. package/dist/server.d.ts +8 -5
  19. package/dist/server.js +141 -28
  20. package/dist/server.mjs +147 -28
  21. package/package.json +3 -2
  22. package/src/app/page.tsx +2 -0
  23. package/src/components/constants.tsx +224 -0
  24. package/src/config/RagConfig.ts +2 -2
  25. package/src/core/ConfigResolver.ts +32 -6
  26. package/src/core/LicenseVerifier.ts +106 -0
  27. package/src/core/Pipeline.ts +8 -6
  28. package/src/core/Retrivora.ts +1 -0
  29. package/src/index.ts +3 -5
  30. package/src/components/AmbientBackground.tsx +0 -29
  31. package/src/components/ArchitectureCard.tsx +0 -53
  32. package/src/components/ArchitectureCardsSection.tsx +0 -48
  33. package/src/components/DocViewer.tsx +0 -97
  34. package/src/components/Documentation.tsx +0 -141
  35. package/src/components/Hero.tsx +0 -142
  36. package/src/components/Lifecycle.tsx +0 -77
  37. package/src/components/Navbar.tsx +0 -55
@@ -19,6 +19,12 @@ var __spreadValues = (a, b) => {
19
19
  return a;
20
20
  };
21
21
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
23
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
24
+ }) : x)(function(x) {
25
+ if (typeof require !== "undefined") return require.apply(this, arguments);
26
+ throw Error('Dynamic require of "' + x + '" is not supported');
27
+ });
22
28
  var __objRest = (source, exclude) => {
23
29
  var target = {};
24
30
  for (var prop in source)
@@ -2344,7 +2350,7 @@ var ConfigResolver = class {
2344
2350
  }
2345
2351
  }
2346
2352
  static mergeRetrievalWorkflow(rag, retrieval, workflow) {
2347
- var _a2, _b, _c, _d, _e;
2353
+ var _a2, _b, _c, _d, _e, _f;
2348
2354
  if (!rag && !retrieval && !workflow) return void 0;
2349
2355
  const normalized = __spreadValues({}, rag != null ? rag : {});
2350
2356
  if (retrieval) {
@@ -2352,20 +2358,44 @@ var ConfigResolver = class {
2352
2358
  normalized.scoreThreshold = (_b = retrieval.scoreThreshold) != null ? _b : normalized.scoreThreshold;
2353
2359
  normalized.useReranking = (_c = retrieval.useReranking) != null ? _c : normalized.useReranking;
2354
2360
  if (retrieval.strategy === "hybrid") normalized.architecture = (_d = normalized.architecture) != null ? _d : "hybrid";
2355
- if (retrieval.strategy === "agentic") normalized.architecture = "agentic";
2356
- if (retrieval.strategy === "contextual-compression") normalized.useReranking = true;
2361
+ if (retrieval.strategy === "agentic") normalized.architecture = "multi-agent";
2362
+ if (retrieval.strategy === "contextual-compression") {
2363
+ normalized.useReranking = true;
2364
+ normalized.architecture = (_e = normalized.architecture) != null ? _e : "retrieve-and-rerank";
2365
+ }
2357
2366
  }
2358
2367
  if (workflow == null ? void 0 : workflow.type) {
2359
2368
  const type = workflow.type;
2360
- if (type === "agentic" || type === "agentic-rag") normalized.architecture = "agentic";
2361
- else if (type === "hybrid-rag") normalized.architecture = "hybrid";
2362
- else if (type === "graph-rag") {
2369
+ if (type === "naive-rag") {
2370
+ normalized.architecture = "naive";
2371
+ normalized.useReranking = false;
2372
+ normalized.useGraphRetrieval = false;
2373
+ } else if (type === "retrieve-and-rerank") {
2374
+ normalized.architecture = "retrieve-and-rerank";
2375
+ normalized.useReranking = true;
2376
+ } else if (type === "multimodal-rag") {
2377
+ normalized.architecture = "multimodal";
2378
+ } else if (type === "graph-rag") {
2363
2379
  normalized.architecture = "graph";
2364
2380
  normalized.useGraphRetrieval = true;
2381
+ } else if (type === "hybrid-rag") {
2382
+ normalized.architecture = "hybrid";
2383
+ } else if (type === "agentic-router") {
2384
+ normalized.architecture = "agentic-router";
2385
+ } else if (type === "multi-agent-rag" || type === "multi-agent" || type === "agentic" || type === "agentic-rag") {
2386
+ normalized.architecture = "multi-agent";
2365
2387
  } else if (type === "simple-rag" || type === "rag") {
2366
- normalized.architecture = (_e = normalized.architecture) != null ? _e : "simple";
2388
+ normalized.architecture = (_f = normalized.architecture) != null ? _f : "naive";
2367
2389
  }
2368
2390
  }
2391
+ if (normalized.architecture === "retrieve-and-rerank") {
2392
+ normalized.useReranking = true;
2393
+ } else if (normalized.architecture === "graph") {
2394
+ normalized.useGraphRetrieval = true;
2395
+ } else if (normalized.architecture === "naive") {
2396
+ normalized.useReranking = false;
2397
+ normalized.useGraphRetrieval = false;
2398
+ }
2369
2399
  return normalized;
2370
2400
  }
2371
2401
  };
@@ -7111,7 +7141,7 @@ var Pipeline = class {
7111
7141
  return this.initialised ? this.llmProvider : void 0;
7112
7142
  }
7113
7143
  async initialize() {
7114
- var _a2, _b, _c;
7144
+ var _a2, _b, _c, _d;
7115
7145
  if (this.initialised) return;
7116
7146
  const chartInstruction = `You are a helpful assistant. Use the provided context to answer questions accurately.
7117
7147
 
@@ -7154,7 +7184,7 @@ var Pipeline = class {
7154
7184
  this.entityExtractor = new EntityExtractor(this.llmProvider);
7155
7185
  }
7156
7186
  await this.vectorDB.initialize();
7157
- if (((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || this.config.mcpServers && this.config.mcpServers.length > 0) {
7187
+ if (((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || ((_b = this.config.rag) == null ? void 0 : _b.architecture) === "multi-agent" || this.config.mcpServers && this.config.mcpServers.length > 0) {
7158
7188
  this.mcpRegistry = new MCPRegistry(this.config.mcpServers || []);
7159
7189
  this.multiAgentCoordinator = new MultiAgentCoordinator({
7160
7190
  llmProvider: this.llmProvider,
@@ -7166,7 +7196,7 @@ var Pipeline = class {
7166
7196
  this.agent = new LangChainAgent(this, this.config);
7167
7197
  await this.agent.initialize(this.llmProvider);
7168
7198
  }
7169
- if ((_c = (_b = this.config.rag) == null ? void 0 : _b.cag) == null ? void 0 : _c.enabled) {
7199
+ if ((_d = (_c = this.config.rag) == null ? void 0 : _c.cag) == null ? void 0 : _d.enabled) {
7170
7200
  await this.loadColdContext(this.config.projectId);
7171
7201
  }
7172
7202
  this.initialised = true;
@@ -7329,9 +7359,9 @@ ${m.content}`).join("\n\n---\n\n");
7329
7359
  return { reply, sources };
7330
7360
  }
7331
7361
  async ask(question, history = [], namespace) {
7332
- var _a2;
7362
+ var _a2, _b;
7333
7363
  await this.initialize();
7334
- if ((((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || this.config.mcpServers && this.config.mcpServers.length > 0) && this.multiAgentCoordinator) {
7364
+ if ((((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || ((_b = this.config.rag) == null ? void 0 : _b.architecture) === "multi-agent" || this.config.mcpServers && this.config.mcpServers.length > 0) && this.multiAgentCoordinator) {
7335
7365
  return await this.multiAgentCoordinator.run(question, history);
7336
7366
  }
7337
7367
  const stream = this.askStream(question, history, namespace);
@@ -7366,9 +7396,9 @@ ${m.content}`).join("\n\n---\n\n");
7366
7396
  }
7367
7397
  askStream(_0) {
7368
7398
  return __asyncGenerator(this, arguments, function* (question, history = [], namespace) {
7369
- var _a2;
7399
+ var _a2, _b;
7370
7400
  yield new __await(this.initialize());
7371
- if ((((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || this.config.mcpServers && this.config.mcpServers.length > 0) && this.multiAgentCoordinator) {
7401
+ if ((((_a2 = this.config.rag) == null ? void 0 : _a2.architecture) === "agentic" || ((_b = this.config.rag) == null ? void 0 : _b.architecture) === "multi-agent" || this.config.mcpServers && this.config.mcpServers.length > 0) && this.multiAgentCoordinator) {
7372
7402
  const stream2 = this.multiAgentCoordinator.runStream(question, history);
7373
7403
  try {
7374
7404
  for (var iter = __forAwait(stream2), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
@@ -7417,7 +7447,7 @@ ${m.content}`).join("\n\n---\n\n");
7417
7447
  */
7418
7448
  askStreamInternal(_0) {
7419
7449
  return __asyncGenerator(this, arguments, function* (question, history = [], namespace) {
7420
- var _a2, _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;
7450
+ var _a2, _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;
7421
7451
  yield new __await(this.initialize());
7422
7452
  const ns = namespace != null ? namespace : this.config.projectId;
7423
7453
  const topK = (_b = (_a2 = this.config.rag) == null ? void 0 : _a2.topK) != null ? _b : 5;
@@ -7440,13 +7470,14 @@ ${m.content}`).join("\n\n---\n\n");
7440
7470
  const embedStart = performance.now();
7441
7471
  const cacheKey = `${ns}::${searchQuery}`;
7442
7472
  const cachedVector = this.embeddingCache.get(cacheKey);
7443
- const useGraph = this.graphDB && ((_h = this.config.rag) == null ? void 0 : _h.useGraphRetrieval);
7473
+ const arch = (_h = this.config.rag) == null ? void 0 : _h.architecture;
7474
+ const useGraph = arch !== "naive" && arch !== "retrieve-and-rerank" && this.graphDB && ((_i = this.config.rag) == null ? void 0 : _i.useGraphRetrieval);
7444
7475
  const [strategyResult, embeddedVector] = yield new __await(Promise.all([
7445
7476
  QueryProcessor.determineRetrievalStrategy(
7446
7477
  searchQuery,
7447
7478
  useGraph ? this.llmRouter.get("fast") : void 0,
7448
- (_i = this.config.rag) == null ? void 0 : _i.graphKeywords,
7449
- (_j = this.config.rag) == null ? void 0 : _j.vectorKeywords
7479
+ (_j = this.config.rag) == null ? void 0 : _j.graphKeywords,
7480
+ (_k = this.config.rag) == null ? void 0 : _k.vectorKeywords
7450
7481
  ),
7451
7482
  // Embed immediately regardless of strategy — costs nothing if cached.
7452
7483
  // If strategy turns out to be 'graph'-only we just won't use the vector.
@@ -7456,7 +7487,7 @@ ${m.content}`).join("\n\n---\n\n");
7456
7487
  if (!cachedVector && queryVector.length > 0) {
7457
7488
  this.embeddingCache.set(cacheKey, queryVector);
7458
7489
  }
7459
- const graphData = (strategyResult === "graph" || strategyResult === "both") && this.graphDB && ((_k = this.config.rag) == null ? void 0 : _k.useGraphRetrieval) ? yield new __await(this.graphDB.query(searchQuery)) : void 0;
7490
+ const graphData = (strategyResult === "graph" || strategyResult === "both") && this.graphDB && ((_l = this.config.rag) == null ? void 0 : _l.useGraphRetrieval) ? yield new __await(this.graphDB.query(searchQuery)) : void 0;
7460
7491
  const hasMetadataFilter = filter.metadata && Object.keys(filter.metadata).length > 0;
7461
7492
  const hasNumericPredicates = Array.isArray(filter.__numericPredicates) && filter.__numericPredicates.length > 0;
7462
7493
  const wantsExhaustiveList = hasNumericPredicates || hasMetadataFilter || /\b(list|all|show|provide|give|get|browse|find|search|display)\b/i.test(question);
@@ -7469,7 +7500,8 @@ ${m.content}`).join("\n\n---\n\n");
7469
7500
  const structuredSources = this.applyStructuredFilters(rawSources, filter);
7470
7501
  let fullSources = hasNumericPredicates ? structuredSources : structuredSources.filter((m) => m.score >= scoreThreshold);
7471
7502
  const rerankLimit = wantsExhaustiveList ? retrievalLimit : topK;
7472
- if (!hasNumericPredicates && ((_l = this.config.rag) == null ? void 0 : _l.useReranking)) {
7503
+ const useReranking = arch !== "naive" && (arch === "retrieve-and-rerank" || ((_m = this.config.rag) == null ? void 0 : _m.useReranking));
7504
+ if (!hasNumericPredicates && useReranking) {
7473
7505
  fullSources = yield new __await(this.reranker.rerank(fullSources, question, rerankLimit));
7474
7506
  } else if (!wantsExhaustiveList) {
7475
7507
  fullSources = fullSources.slice(0, topK);
@@ -7499,7 +7531,7 @@ ${graphContext}
7499
7531
  VECTOR CONTEXT:
7500
7532
  ${context}`;
7501
7533
  }
7502
- if ((_n = (_m = this.config.rag) == null ? void 0 : _m.cag) == null ? void 0 : _n.enabled) {
7534
+ if ((_o = (_n = this.config.rag) == null ? void 0 : _n.cag) == null ? void 0 : _o.enabled) {
7503
7535
  if (!this.coldContexts.has(ns)) {
7504
7536
  yield new __await(this.loadColdContext(ns));
7505
7537
  }
@@ -7552,10 +7584,10 @@ ${context}`;
7552
7584
  let hallucinationScoringPromise = Promise.resolve(void 0);
7553
7585
  const restrictionSuffix = "\n\n(IMPORTANT: Format your response beautifully using rich Markdown! Use bolding for emphasis, headings (##) for structure, bullet points for lists, and proper line breaks between paragraphs to make it highly readable. However, NEVER generate Markdown tables, HTML figures, or text charts (the UI renders requested charts separately, so NEVER say you cannot create, display, draw, render, or provide a chart/visualization). If listing products, use simple markdown bullet points or comma-separated names. NEVER use plus signs (+) to separate product names, category names, or list items. For product description/detail questions, provide customer-facing prose only and do NOT list internal catalog fields such as Handle, Body (HTML), Vendor, Type, Tags, Published, Option, Variant, SKU, or raw metadata labels. You CAN use numbers for years/counts like 2006 or 5800, but NEVER put a dollar sign ($) before them.)";
7554
7586
  const isClaude37 = this.config.llm.model.includes("claude-3-7-sonnet");
7555
- const isNativeThinking = isClaude37 && (((_o = this.config.llm.options) == null ? void 0 : _o.thinking) === true || ((_p = this.config.llm.options) == null ? void 0 : _p.thinking) === "enabled" || ((_q = this.config.llm.options) == null ? void 0 : _q.thinking) !== false);
7587
+ const isNativeThinking = isClaude37 && (((_p = this.config.llm.options) == null ? void 0 : _p.thinking) === true || ((_q = this.config.llm.options) == null ? void 0 : _q.thinking) === "enabled" || ((_r = this.config.llm.options) == null ? void 0 : _r.thinking) !== false);
7556
7588
  const modelNameLower = this.config.llm.model.toLowerCase();
7557
7589
  const isReasoningModel = modelNameLower.includes("-r1") || modelNameLower.includes("deepseek-r1") || modelNameLower.includes("reasoning") || modelNameLower.includes("thinking");
7558
- const isSimulatedThinking = !isNativeThinking && (((_r = this.config.llm.options) == null ? void 0 : _r.thinking) === true || ((_s = this.config.llm.options) == null ? void 0 : _s.thinking) === "enabled" || isReasoningModel && ((_t = this.config.llm.options) == null ? void 0 : _t.thinking) !== false);
7590
+ const isSimulatedThinking = !isNativeThinking && (((_s = this.config.llm.options) == null ? void 0 : _s.thinking) === true || ((_t = this.config.llm.options) == null ? void 0 : _t.thinking) === "enabled" || isReasoningModel && ((_u = this.config.llm.options) == null ? void 0 : _u.thinking) !== false);
7559
7591
  let finalRestrictionSuffix = restrictionSuffix;
7560
7592
  if (isSimulatedThinking) {
7561
7593
  finalRestrictionSuffix += "\n\n(IMPORTANT: You must think step-by-step before answering. Write your thinking process inside a `<think>...</think>` block. Write the `<think>` block first, then follow it with your final response. Keep the thinking process thorough and detailed. Example: `<think>Thinking details here...</think>Final answer text here.`)";
@@ -7563,7 +7595,7 @@ ${context}`;
7563
7595
  const hardenedHistory = [...history];
7564
7596
  const userQuestion = { role: "user", content: question + finalRestrictionSuffix };
7565
7597
  const messages = [...hardenedHistory, userQuestion];
7566
- const systemPrompt = (_u = this.config.llm.systemPrompt) != null ? _u : "";
7598
+ const systemPrompt = (_v = this.config.llm.systemPrompt) != null ? _v : "";
7567
7599
  const userPrompt = messages.map((m) => `${m.role}: ${m.content}`).join("\n");
7568
7600
  let fullReply = "";
7569
7601
  let thinkingText = "";
@@ -7674,7 +7706,7 @@ ${context}`;
7674
7706
  }
7675
7707
  yield fullReply;
7676
7708
  }
7677
- const runHallucination = ((_v = this.config.llm.options) == null ? void 0 : _v.hallucinationScoring) === true || this.config.llm.provider !== "ollama" && ((_w = this.config.llm.options) == null ? void 0 : _w.hallucinationScoring) !== false;
7709
+ const runHallucination = ((_w = this.config.llm.options) == null ? void 0 : _w.hallucinationScoring) === true || this.config.llm.provider !== "ollama" && ((_x = this.config.llm.options) == null ? void 0 : _x.hallucinationScoring) !== false;
7678
7710
  if (runHallucination) {
7679
7711
  hallucinationScoringPromise = scoreHallucination(this.llmProvider, fullReply, context).catch(() => void 0);
7680
7712
  }
@@ -7683,7 +7715,7 @@ ${context}`;
7683
7715
  const latency = {
7684
7716
  embedMs: Math.round(embedMs),
7685
7717
  retrieveMs: Math.round(retrieveMs),
7686
- rerankMs: ((_x = this.config.rag) == null ? void 0 : _x.useReranking) ? Math.round(rerankMs) : void 0,
7718
+ rerankMs: arch !== "naive" && (arch === "retrieve-and-rerank" || ((_y = this.config.rag) == null ? void 0 : _y.useReranking)) ? Math.round(rerankMs) : void 0,
7687
7719
  generateMs: Math.round(generateMs),
7688
7720
  totalMs: Math.round(totalMs)
7689
7721
  };
@@ -7696,7 +7728,7 @@ ${context}`;
7696
7728
  totalTokens: promptTokens + completionTokens,
7697
7729
  estimatedCostUsd: estimateCostUsd(promptTokens, completionTokens, this.config.llm.model)
7698
7730
  };
7699
- const awaitHallucination = ((_y = this.config.llm.options) == null ? void 0 : _y.awaitHallucination) === true;
7731
+ const awaitHallucination = ((_z = this.config.llm.options) == null ? void 0 : _z.awaitHallucination) === true;
7700
7732
  const [uiTransformation, hallucinationResult] = yield new __await(Promise.all([
7701
7733
  uiTransformationPromise,
7702
7734
  awaitHallucination ? hallucinationScoringPromise : Promise.resolve(void 0)
@@ -7725,7 +7757,7 @@ ${context}`;
7725
7757
  hallucinationReason: hScore.reason
7726
7758
  } : {});
7727
7759
  const trace = buildTrace(hallucinationResult);
7728
- if ((_z = this.config.telemetry) == null ? void 0 : _z.enabled) {
7760
+ if ((_A = this.config.telemetry) == null ? void 0 : _A.enabled) {
7729
7761
  const telemetryUrl = this.config.telemetry.url || "/api/telemetry";
7730
7762
  const absoluteUrl = telemetryUrl.startsWith("http") ? telemetryUrl : (process.env.NEXT_PUBLIC_APP_URL || `http://localhost:${process.env.PORT || 3e3}`) + telemetryUrl;
7731
7763
  (async () => {
@@ -8101,6 +8133,19 @@ var LicenseVerifier = class {
8101
8133
  */
8102
8134
  static verify(licenseKey, currentProjectId, provider, publicKeyOverride) {
8103
8135
  const isProduction = process.env.NODE_ENV === "production";
8136
+ const now = Date.now();
8137
+ if (licenseKey) {
8138
+ const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
8139
+ const cached = this.cache.get(cacheKey);
8140
+ if (cached && now - cached.cachedAt < this.CACHE_TTL_MS) {
8141
+ const currentTimestampSec = Math.floor(now / 1e3);
8142
+ if (cached.payload.expiresAt && currentTimestampSec > cached.payload.expiresAt) {
8143
+ this.cache.delete(cacheKey);
8144
+ } else {
8145
+ return cached.payload;
8146
+ }
8147
+ }
8148
+ }
8104
8149
  if (!licenseKey) {
8105
8150
  if (isProduction) {
8106
8151
  throw new ConfigurationException(
@@ -8187,6 +8232,10 @@ var LicenseVerifier = class {
8187
8232
  }
8188
8233
  }
8189
8234
  }
8235
+ if (licenseKey) {
8236
+ const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
8237
+ this.cache.set(cacheKey, { payload, cachedAt: now });
8238
+ }
8190
8239
  return payload;
8191
8240
  } catch (err) {
8192
8241
  const message = err instanceof Error ? err.message : String(err);
@@ -8195,7 +8244,76 @@ var LicenseVerifier = class {
8195
8244
  );
8196
8245
  }
8197
8246
  }
8247
+ static async verifyIP(licenseKey) {
8248
+ if (!licenseKey) return;
8249
+ try {
8250
+ const parts = licenseKey.split(".");
8251
+ if (parts.length !== 3) return;
8252
+ const [, payloadB64] = parts;
8253
+ const payload = JSON.parse(
8254
+ Buffer.from(payloadB64, "base64url").toString("utf8")
8255
+ );
8256
+ const tier = (payload.tier || "").toLowerCase();
8257
+ if (tier === "enterprise" || tier === "custom") {
8258
+ return;
8259
+ }
8260
+ if (payload.ipv4 || payload.ipv6) {
8261
+ let currentIpv4 = "";
8262
+ let currentIpv6 = "";
8263
+ try {
8264
+ const res = await fetch("https://api4.ipify.org?format=json", { signal: AbortSignal.timeout(3e3) });
8265
+ const data = await res.json();
8266
+ currentIpv4 = data.ip;
8267
+ } catch (e) {
8268
+ }
8269
+ try {
8270
+ const res = await fetch("https://api6.ipify.org?format=json", { signal: AbortSignal.timeout(3e3) });
8271
+ const data = await res.json();
8272
+ currentIpv6 = data.ip;
8273
+ } catch (e) {
8274
+ }
8275
+ const localIps = [];
8276
+ try {
8277
+ const osModule = __require("os");
8278
+ const interfaces = osModule.networkInterfaces();
8279
+ for (const name of Object.keys(interfaces)) {
8280
+ for (const iface of interfaces[name] || []) {
8281
+ if (!iface.internal) {
8282
+ localIps.push(iface.address);
8283
+ }
8284
+ }
8285
+ }
8286
+ } catch (e) {
8287
+ }
8288
+ const isIpv4Match = payload.ipv4 && (currentIpv4 === payload.ipv4 || localIps.includes(payload.ipv4));
8289
+ const isIpv6Match = payload.ipv6 && (currentIpv6 === payload.ipv6 || localIps.includes(payload.ipv6));
8290
+ if (payload.ipv4 && payload.ipv6) {
8291
+ if (!isIpv4Match && !isIpv6Match) {
8292
+ throw new Error(
8293
+ `License key access restricted. This license key was created for a different system (authorized IPv4: ${payload.ipv4}, IPv6: ${payload.ipv6}) and cannot be used on this machine.`
8294
+ );
8295
+ }
8296
+ } else if (payload.ipv4 && !isIpv4Match) {
8297
+ throw new Error(
8298
+ `License key access restricted. This license key was created for a different system (authorized IPv4: ${payload.ipv4}) and cannot be used on this machine.`
8299
+ );
8300
+ } else if (payload.ipv6 && !isIpv6Match) {
8301
+ throw new Error(
8302
+ `License key access restricted. This license key was created for a different system (authorized IPv6: ${payload.ipv6}) and cannot be used on this machine.`
8303
+ );
8304
+ }
8305
+ }
8306
+ } catch (err) {
8307
+ if (err.message.includes("License key access restricted")) {
8308
+ throw new ConfigurationException(`[Retrivora SDK] ${err.message}`);
8309
+ }
8310
+ }
8311
+ }
8198
8312
  };
8313
+ // A simple in-memory cache to save CPU overhead of cryptographic signature checks.
8314
+ LicenseVerifier.cache = /* @__PURE__ */ new Map();
8315
+ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
8316
+ // Cache verified license for 60 seconds
8199
8317
  // Retrivora's Public Key used to verify the license key signature.
8200
8318
  // In production, this matches the private key held by Retrivora SaaS.
8201
8319
  LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
@@ -1,4 +1,4 @@
1
- import { k as RagConfig, I as ILLMProvider, g as IngestDocument, C as ChatMessage, d as ChatResponse, u as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-B8ROITYK.js';
1
+ import { k as RagConfig, I as ILLMProvider, g as IngestDocument, C as ChatMessage, d as ChatResponse, u as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-DMxLyTdq.js';
2
2
 
3
3
  /**
4
4
  * DocumentChunker — splits long text into overlapping chunks
@@ -1,5 +1,5 @@
1
1
  import { NextRequest } from 'next/server';
2
- import { k as RagConfig, I as ILLMProvider, C as ChatMessage, d as ChatResponse, g as IngestDocument } from './ILLMProvider-B8ROITYK.mjs';
2
+ import { k as RagConfig, I as ILLMProvider, C as ChatMessage, d as ChatResponse, g as IngestDocument } from './ILLMProvider-DMxLyTdq.mjs';
3
3
 
4
4
  interface ValidationError {
5
5
  field: string;
@@ -1,5 +1,5 @@
1
1
  import { NextRequest } from 'next/server';
2
- import { k as RagConfig, I as ILLMProvider, C as ChatMessage, d as ChatResponse, g as IngestDocument } from './ILLMProvider-B8ROITYK.js';
2
+ import { k as RagConfig, I as ILLMProvider, C as ChatMessage, d as ChatResponse, g as IngestDocument } from './ILLMProvider-DMxLyTdq.js';
3
3
 
4
4
  interface ValidationError {
5
5
  field: string;
@@ -1,4 +1,4 @@
1
- import { k as RagConfig, I as ILLMProvider, g as IngestDocument, C as ChatMessage, d as ChatResponse, u as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-B8ROITYK.mjs';
1
+ import { k as RagConfig, I as ILLMProvider, g as IngestDocument, C as ChatMessage, d as ChatResponse, u as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-DMxLyTdq.mjs';
2
2
 
3
3
  /**
4
4
  * DocumentChunker — splits long text into overlapping chunks