@retrivora-ai/rag-engine 2.3.6 → 2.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/{BatchProcessor-Dfn23VAd.d.mts → BatchProcessor-BhLczWj5.d.mts} +100 -2
  2. package/dist/{BatchProcessor-ByBl-1MA.d.ts → BatchProcessor-C42_RVWO.d.ts} +100 -2
  3. package/dist/handlers/index.d.mts +1 -1
  4. package/dist/handlers/index.d.ts +1 -1
  5. package/dist/handlers/index.js +340 -172
  6. package/dist/handlers/index.mjs +342 -174
  7. package/dist/{index-ejOWsaqb.d.ts → index-BQd6Bax0.d.ts} +1 -1
  8. package/dist/{index-xxQOFx-u.d.mts → index-C7aHK7_g.d.mts} +1 -1
  9. package/dist/index.d.mts +2 -2
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +114 -87
  12. package/dist/index.mjs +114 -87
  13. package/dist/server.d.mts +263 -37
  14. package/dist/server.d.ts +263 -37
  15. package/dist/server.js +957 -178
  16. package/dist/server.mjs +949 -180
  17. package/package.json +1 -1
  18. package/src/LicensedRetrivora.ts +273 -0
  19. package/src/components/ChatWidget.tsx +0 -1
  20. package/src/components/ConfigProvider.tsx +2 -1
  21. package/src/config/LicenseConfigResolver.ts +296 -0
  22. package/src/config/serverConfig.ts +75 -16
  23. package/src/core/ConfigFetcher.ts +36 -3
  24. package/src/core/DatabaseStorage.ts +13 -13
  25. package/src/core/LicenseValidator.ts +5 -3
  26. package/src/core/LicenseVerifier.ts +85 -120
  27. package/src/core/Retrivora.ts +1 -1
  28. package/src/core/VectorPlugin.ts +1 -1
  29. package/src/handlers/index.ts +25 -11
  30. package/src/index.ts +9 -0
  31. package/src/llm/providers/UniversalLLMAdapter.ts +67 -12
  32. package/src/providers/vectordb/PineconeProvider.ts +69 -2
  33. package/src/server.ts +23 -1
  34. package/src/telemetry/TelemetryService.ts +330 -0
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.3.6",
318
+ version: "2.3.8",
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",
@@ -501,7 +501,12 @@ var init_ConfigFetcher = __esm({
501
501
  process.env.RETRIVORA_CONTROL_PLANE_URL,
502
502
  process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
503
503
  CONTROL_PLANE_URL
504
- ].filter((url) => Boolean(url) && !url.includes("localhost") && !url.includes("127.0.0.1")).map((url) => url.replace(/\/$/, ""));
504
+ ].filter((url) => {
505
+ if (!url) return false;
506
+ const isEnvVar = url === process.env.RETRIVORA_CONTROL_PLANE_URL || url === process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL;
507
+ if (!isEnvVar && (url.includes("localhost") || url.includes("127.0.0.1"))) return false;
508
+ return true;
509
+ }).map((url) => url.replace(/\/$/, ""));
505
510
  for (const baseUrl of controlPlaneUrls) {
506
511
  try {
507
512
  const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}`;
@@ -522,8 +527,7 @@ var init_ConfigFetcher = __esm({
522
527
  isActive: data.isActive,
523
528
  expiresAt: data.expiresAt,
524
529
  vectorDb: {
525
- // apiKey is not returned by the config API — it's a server-only secret.
526
- // The SDK uses local PINECONE_API_KEY if available.
530
+ // Fetch apiKey from credentials API if available, else fallback to empty
527
531
  apiKey: data.vectorDb.apiKey || "",
528
532
  indexName: data.vectorDb.indexName || "retrivora-free",
529
533
  provider: data.vectorDb.provider || "pinecone",
@@ -555,6 +559,32 @@ var init_ConfigFetcher = __esm({
555
559
  data.projectSettings || data.settings
556
560
  )
557
561
  };
562
+ if (licenseKey) {
563
+ try {
564
+ const credUrl = `${baseUrl}/api/v1/credentials`;
565
+ const credRes = await fetch(credUrl, {
566
+ method: "POST",
567
+ headers: {
568
+ "Content-Type": "application/json"
569
+ },
570
+ body: JSON.stringify({ licenseKey, projectId: fetchedProjectId })
571
+ });
572
+ if (credRes.ok) {
573
+ const credData = await credRes.json();
574
+ if ((credData == null ? void 0 : credData.success) && (credData == null ? void 0 : credData.credentials)) {
575
+ if (credData.credentials.pineconeApiKey && !config.vectorDb.apiKey) {
576
+ config.vectorDb.apiKey = credData.credentials.pineconeApiKey;
577
+ }
578
+ if (credData.credentials.litellmApiKey) {
579
+ config.llm.apiKey = credData.credentials.litellmApiKey;
580
+ config.embedding.apiKey = credData.credentials.litellmApiKey;
581
+ }
582
+ }
583
+ }
584
+ } catch (e) {
585
+ console.warn("[ConfigFetcher] Failed to fetch credentials:", e);
586
+ }
587
+ }
558
588
  this.cache.set(cacheKey, { config, cachedAt: now });
559
589
  return config;
560
590
  }
@@ -594,6 +624,14 @@ var init_PineconeProvider = __esm({
594
624
  const opts = config.options || {};
595
625
  this.apiKey = opts.apiKey || process.env.PINECONE_API_KEY || "";
596
626
  }
627
+ getControlPlaneUrl() {
628
+ const urls = [
629
+ process.env.RETRIVORA_CONTROL_PLANE_URL,
630
+ process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
631
+ "https://www.retrivora.com"
632
+ ].filter((url) => Boolean(url));
633
+ return urls[0].replace(/\/$/, "");
634
+ }
597
635
  static getValidator() {
598
636
  return {
599
637
  validate(config) {
@@ -657,6 +695,7 @@ var init_PineconeProvider = __esm({
657
695
  let key = this.apiKey || process.env.PINECONE_API_KEY || "";
658
696
  if (!key) {
659
697
  const licenseKey = process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY;
698
+ this.licenseKey = licenseKey;
660
699
  const jwtProjectId = (() => {
661
700
  if (!licenseKey) return void 0;
662
701
  try {
@@ -670,6 +709,7 @@ var init_PineconeProvider = __esm({
670
709
  return void 0;
671
710
  })();
672
711
  const projectId = process.env.RAG_PROJECT_ID || process.env.NEXT_PUBLIC_RAG_PROJECT_ID || jwtProjectId || this.projectId || "default";
712
+ this.projectId = projectId;
673
713
  const remoteConfig = await ConfigFetcher.fetchRemoteVectorConfig(projectId, licenseKey);
674
714
  if (remoteConfig) {
675
715
  if (remoteConfig.apiKey) {
@@ -715,19 +755,59 @@ var init_PineconeProvider = __esm({
715
755
  return namespace ? idx.namespace(namespace) : idx.namespace("");
716
756
  }
717
757
  async upsert(doc, namespace) {
718
- var _a3;
758
+ var _a3, _b;
759
+ if (!this.client) {
760
+ if (!this.licenseKey) throw new Error("[PineconeProvider] Cannot execute vector operation: Missing API key and License key.");
761
+ const res = await fetch(`${this.getControlPlaneUrl()}/api/v1/vectors/upsert`, {
762
+ method: "POST",
763
+ headers: { "Content-Type": "application/json", "x-license-key": this.licenseKey },
764
+ body: JSON.stringify({
765
+ projectId: this.projectId,
766
+ indexName: this.indexName,
767
+ namespace: namespace || this.projectId,
768
+ records: [{ id: String(doc.id), values: doc.vector, metadata: __spreadValues({ content: doc.content }, (_a3 = doc.metadata) != null ? _a3 : {}) }]
769
+ })
770
+ });
771
+ if (!res.ok) throw new Error(`[PineconeProvider] Proxy upsert failed: ${await res.text()}`);
772
+ return;
773
+ }
719
774
  const targetIdx = await this.getActiveIndex(namespace);
720
775
  await targetIdx.upsert({
721
776
  records: [{
722
777
  id: String(doc.id),
723
778
  values: doc.vector,
724
- metadata: __spreadValues({ content: doc.content }, (_a3 = doc.metadata) != null ? _a3 : {})
779
+ metadata: __spreadValues({ content: doc.content }, (_b = doc.metadata) != null ? _b : {})
725
780
  }]
726
781
  });
727
782
  }
728
783
  async batchUpsert(docs, namespace) {
729
- const targetIdx = await this.getActiveIndex(namespace);
730
784
  const BATCH = 100;
785
+ if (!this.client) {
786
+ if (!this.licenseKey) throw new Error("[PineconeProvider] Cannot execute vector operation: Missing API key and License key.");
787
+ for (let i = 0; i < docs.length; i += BATCH) {
788
+ const records = docs.slice(i, i + BATCH).map((d) => {
789
+ var _a3;
790
+ return {
791
+ id: String(d.id),
792
+ values: d.vector,
793
+ metadata: __spreadValues({ content: d.content }, (_a3 = d.metadata) != null ? _a3 : {})
794
+ };
795
+ });
796
+ const res = await fetch(`${this.getControlPlaneUrl()}/api/v1/vectors/upsert`, {
797
+ method: "POST",
798
+ headers: { "Content-Type": "application/json", "x-license-key": this.licenseKey },
799
+ body: JSON.stringify({
800
+ projectId: this.projectId,
801
+ indexName: this.indexName,
802
+ namespace: namespace || this.projectId,
803
+ records
804
+ })
805
+ });
806
+ if (!res.ok) throw new Error(`[PineconeProvider] Proxy batch upsert failed: ${await res.text()}`);
807
+ }
808
+ return;
809
+ }
810
+ const targetIdx = await this.getActiveIndex(namespace);
731
811
  for (let i = 0; i < docs.length; i += BATCH) {
732
812
  const records = docs.slice(i, i + BATCH).map((d) => {
733
813
  var _a3;
@@ -741,20 +821,46 @@ var init_PineconeProvider = __esm({
741
821
  }
742
822
  }
743
823
  async query(vector, topK, namespace, filter) {
744
- var _a3;
745
- const targetIdx = await this.getActiveIndex(namespace);
824
+ var _a3, _b;
746
825
  const pineconeFilter = this.sanitizeFilter(filter);
826
+ if (!this.client) {
827
+ if (!this.licenseKey) throw new Error("[PineconeProvider] Cannot execute vector operation: Missing API key and License key.");
828
+ const res = await fetch(`${this.getControlPlaneUrl()}/api/v1/vectors/query`, {
829
+ method: "POST",
830
+ headers: { "Content-Type": "application/json", "x-license-key": this.licenseKey },
831
+ body: JSON.stringify({
832
+ projectId: this.projectId,
833
+ indexName: this.indexName,
834
+ namespace: namespace || this.projectId,
835
+ vector,
836
+ topK,
837
+ filter: pineconeFilter
838
+ })
839
+ });
840
+ if (!res.ok) throw new Error(`[PineconeProvider] Proxy query failed: ${await res.text()}`);
841
+ const data = await res.json();
842
+ return ((_a3 = data.matches) != null ? _a3 : []).map((m) => {
843
+ var _a4, _b2;
844
+ return {
845
+ id: m.id,
846
+ score: (_a4 = m.score) != null ? _a4 : 0,
847
+ content: ((_b2 = m.metadata) == null ? void 0 : _b2.content) || "",
848
+ metadata: m.metadata
849
+ };
850
+ });
851
+ }
852
+ const targetIdx = await this.getActiveIndex(namespace);
747
853
  const result = await targetIdx.query(__spreadValues({
748
854
  vector,
749
855
  topK,
750
856
  includeMetadata: true
751
857
  }, Object.keys(pineconeFilter).length > 0 ? { filter: pineconeFilter } : {}));
752
- return ((_a3 = result.matches) != null ? _a3 : []).map((m) => {
753
- var _a4, _b;
858
+ return ((_b = result.matches) != null ? _b : []).map((m) => {
859
+ var _a4, _b2;
754
860
  return {
755
861
  id: m.id,
756
862
  score: (_a4 = m.score) != null ? _a4 : 0,
757
- content: ((_b = m.metadata) == null ? void 0 : _b.content) || "",
863
+ content: ((_b2 = m.metadata) == null ? void 0 : _b2.content) || "",
758
864
  metadata: m.metadata
759
865
  };
760
866
  });
@@ -1733,7 +1839,7 @@ __export(QdrantProvider_exports, {
1733
1839
  QdrantProvider: () => QdrantProvider
1734
1840
  });
1735
1841
  import axios4 from "axios";
1736
- import crypto2 from "crypto";
1842
+ import crypto from "crypto";
1737
1843
  var QdrantProvider;
1738
1844
  var init_QdrantProvider = __esm({
1739
1845
  "src/providers/vectordb/QdrantProvider.ts"() {
@@ -1965,7 +2071,7 @@ var init_QdrantProvider = __esm({
1965
2071
  if (typeof id === "number") return id;
1966
2072
  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1967
2073
  if (uuidRegex.test(id)) return id.toLowerCase();
1968
- const hash = crypto2.createHash("md5").update(id).digest("hex");
2074
+ const hash = crypto.createHash("md5").update(id).digest("hex");
1969
2075
  return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-${hash.slice(12, 16)}-${hash.slice(16, 20)}-${hash.slice(20, 32)}`;
1970
2076
  }
1971
2077
  async disconnect() {
@@ -2547,9 +2653,6 @@ var init_SimpleGraphProvider = __esm({
2547
2653
  // src/core/ConfigResolver.ts
2548
2654
  init_templateUtils();
2549
2655
 
2550
- // src/core/LicenseVerifier.ts
2551
- import * as crypto from "crypto";
2552
-
2553
2656
  // src/exceptions/index.ts
2554
2657
  var RetrivoraError = class extends Error {
2555
2658
  constructor(message, code, details) {
@@ -2635,29 +2738,18 @@ function wrapError(err, defaultCode, defaultMessage) {
2635
2738
  }
2636
2739
 
2637
2740
  // src/core/LicenseVerifier.ts
2638
- var LicenseVerifier = class {
2741
+ var _LicenseVerifier = class _LicenseVerifier {
2742
+ // Cache verified license for 5 minutes
2639
2743
  /**
2640
- * Decodes, verifies signature, and checks metadata of a license key.
2744
+ * Validates the license key asynchronously by calling the Retrivora backend.
2641
2745
  *
2642
2746
  * @param licenseKey - Base64url signed JWT license key.
2643
2747
  * @param currentProjectId - Project namespace ID.
2644
- * @param publicKeyOverride - Optional override for unit/integration tests.
2748
+ * @param provider - Optional provider for tier checks.
2645
2749
  */
2646
- static verify(licenseKey, currentProjectId, provider, publicKeyOverride) {
2750
+ static async verifyAsync(licenseKey, currentProjectId, provider) {
2647
2751
  const isProduction = process.env.NODE_ENV === "production";
2648
2752
  const now = Date.now();
2649
- if (licenseKey) {
2650
- const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
2651
- const cached = this.cache.get(cacheKey);
2652
- if (cached && now - cached.cachedAt < this.CACHE_TTL_MS) {
2653
- const currentTimestampSec = Math.floor(now / 1e3);
2654
- if (cached.payload.expiresAt && currentTimestampSec > cached.payload.expiresAt) {
2655
- this.cache.delete(cacheKey);
2656
- } else {
2657
- return cached.payload;
2658
- }
2659
- }
2660
- }
2661
2753
  if (!licenseKey) {
2662
2754
  if (isProduction) {
2663
2755
  throw new ConfigurationException(
@@ -2674,52 +2766,61 @@ var LicenseVerifier = class {
2674
2766
  tier: "hobby"
2675
2767
  };
2676
2768
  }
2677
- try {
2678
- const sanitizedKey = (licenseKey || "").trim().replace(/^["']|["']$/g, "").trim();
2679
- const rawToken = sanitizedKey.replace(/^rtv_/i, "").trim();
2680
- const parts = rawToken.split(".");
2681
- if (parts.length !== 3) {
2682
- throw new Error("Malformed token structure (expected 3 parts).");
2683
- }
2684
- const [headerB64, payloadB64, signatureB64] = parts;
2685
- const dataToVerify = `${headerB64}.${payloadB64}`;
2686
- const publicKey = publicKeyOverride != null ? publicKeyOverride : this.PUBLIC_KEY;
2687
- const signature = Buffer.from(signatureB64, "base64url");
2688
- const data = Buffer.from(dataToVerify);
2689
- const isValid = crypto.verify(
2690
- "sha256",
2691
- data,
2692
- publicKey,
2693
- signature
2694
- );
2695
- if (!isValid) {
2696
- throw new Error("Signature verification failed.");
2769
+ const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}`;
2770
+ const cached = this.cache.get(cacheKey);
2771
+ if (cached && now - cached.cachedAt < this.CACHE_TTL_MS) {
2772
+ const currentTimestampSec = Math.floor(now / 1e3);
2773
+ if (cached.payload.expiresAt && currentTimestampSec > cached.payload.expiresAt) {
2774
+ this.cache.delete(cacheKey);
2775
+ } else {
2776
+ return cached.payload;
2697
2777
  }
2698
- const payload = JSON.parse(
2699
- Buffer.from(payloadB64, "base64url").toString("utf8")
2700
- );
2701
- if (!payload.projectId) {
2702
- throw new Error('License payload is missing "projectId".');
2778
+ }
2779
+ try {
2780
+ let baseUrl = typeof process !== "undefined" && process.env.RETRIVORA_CONTROL_PLANE_URL ? process.env.RETRIVORA_CONTROL_PLANE_URL : "https://retrivora.com";
2781
+ if (typeof process !== "undefined" && process.env.TELEMETRY_URL) {
2782
+ baseUrl = process.env.TELEMETRY_URL.replace(/\/api\/telemetry\/?$/, "");
2703
2783
  }
2704
- const isProjectMatch = payload.projectId === currentProjectId || payload.projectId === `retrivora-${currentProjectId}` || `retrivora-${payload.projectId}` === currentProjectId;
2705
- if (!isProjectMatch) {
2706
- throw new Error(
2707
- `Project ID mismatch. License is bound to project namespace "${payload.projectId}" but configuration has "${currentProjectId}".`
2708
- );
2784
+ const endpoint = `${baseUrl}/api/v1/license/validate`;
2785
+ const response = await fetch(endpoint, {
2786
+ method: "POST",
2787
+ headers: {
2788
+ "Content-Type": "application/json",
2789
+ "x-license-key": licenseKey
2790
+ },
2791
+ body: JSON.stringify({
2792
+ licenseKey,
2793
+ projectId: currentProjectId,
2794
+ provider
2795
+ })
2796
+ });
2797
+ if (!response.ok) {
2798
+ let errMessage = `HTTP ${response.status}`;
2799
+ try {
2800
+ const body = await response.json();
2801
+ if (body.message) errMessage = body.message;
2802
+ } catch (e) {
2803
+ }
2804
+ throw new Error(errMessage);
2709
2805
  }
2710
- if (!payload.expiresAt) {
2711
- throw new Error('License payload is missing expiration ("expiresAt").');
2806
+ const data = await response.json();
2807
+ if (!data.valid) {
2808
+ throw new Error(data.message || "License validation failed by server.");
2712
2809
  }
2713
- const currentTimestampSec = Math.floor(Date.now() / 1e3);
2714
- if (currentTimestampSec > payload.expiresAt) {
2715
- throw new Error(
2716
- `License key has expired. Expiration: ${new Date(
2717
- payload.expiresAt * 1e3
2718
- ).toDateString()}`
2719
- );
2810
+ let expiresAtNum = Math.floor(Date.now() / 1e3) + 100 * 365 * 24 * 60 * 60;
2811
+ if (data.expiresAt) {
2812
+ expiresAtNum = Math.floor(new Date(data.expiresAt).getTime() / 1e3);
2720
2813
  }
2814
+ const tier = _LicenseVerifier.extractTier(licenseKey);
2815
+ const payload = {
2816
+ projectId: currentProjectId,
2817
+ expiresAt: expiresAtNum,
2818
+ tier,
2819
+ licenseStatus: data.licenseStatus,
2820
+ minimumSupportedVersion: data.minimumSupportedVersion,
2821
+ forceUpgrade: data.forceUpgrade
2822
+ };
2721
2823
  if (isProduction && provider) {
2722
- const tier = (payload.tier || "").toLowerCase();
2723
2824
  const normalizedProvider = provider.toLowerCase();
2724
2825
  if (tier === "hobby") {
2725
2826
  const allowedHobby = ["postgresql", "pgvector", "supabase"];
@@ -2747,15 +2848,12 @@ var LicenseVerifier = class {
2747
2848
  }
2748
2849
  }
2749
2850
  }
2750
- if (licenseKey) {
2751
- const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
2752
- this.cache.set(cacheKey, { payload, cachedAt: now });
2753
- }
2851
+ this.cache.set(cacheKey, { payload, cachedAt: now });
2754
2852
  return payload;
2755
2853
  } catch (err) {
2756
2854
  const message = err instanceof Error ? err.message : String(err);
2757
2855
  throw new ConfigurationException(
2758
- `[Retrivora SDK] License key validation failed: ${message}`
2856
+ `[Retrivora SDK] License key validation failed via API: ${message}`
2759
2857
  );
2760
2858
  }
2761
2859
  }
@@ -2824,23 +2922,25 @@ var LicenseVerifier = class {
2824
2922
  }
2825
2923
  }
2826
2924
  }
2925
+ static extractTier(licenseKey) {
2926
+ if (!licenseKey) return "hobby";
2927
+ try {
2928
+ const sanitizedKey = licenseKey.trim().replace(/^["']|["']$/g, "").trim();
2929
+ const rawToken = sanitizedKey.replace(/^rtv_/i, "").trim();
2930
+ const parts = rawToken.split(".");
2931
+ if (parts.length === 3) {
2932
+ const decodedPayload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
2933
+ if (decodedPayload.tier) return decodedPayload.tier;
2934
+ }
2935
+ } catch (e) {
2936
+ }
2937
+ return "hobby";
2938
+ }
2827
2939
  };
2828
- // A simple in-memory cache to save CPU overhead of cryptographic signature checks.
2829
- LicenseVerifier.cache = /* @__PURE__ */ new Map();
2830
- LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
2831
- // Cache verified license for 60 seconds
2832
- // Retrivora's Public Key used to verify the license key signature.
2833
- // In production, this matches the private key held by Retrivora SaaS.
2834
- // Rotate this key only when the signing private key is replaced.
2835
- LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
2836
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
2837
- chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
2838
- 4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
2839
- NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
2840
- HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
2841
- OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
2842
- gQIDAQAB
2843
- -----END PUBLIC KEY-----`;
2940
+ // In-memory cache to save network overhead on hot paths.
2941
+ _LicenseVerifier.cache = /* @__PURE__ */ new Map();
2942
+ _LicenseVerifier.CACHE_TTL_MS = 5 * 60 * 1e3;
2943
+ var LicenseVerifier = _LicenseVerifier;
2844
2944
 
2845
2945
  // src/config/constants.ts
2846
2946
  var VECTOR_DB_PROVIDERS = [
@@ -2888,6 +2988,20 @@ var PROVIDERS_WITH_EMBEDDINGS = [
2888
2988
  var UI_BORDER_RADIUS_OPTIONS = ["none", "sm", "md", "lg", "xl", "full"];
2889
2989
 
2890
2990
  // src/config/serverConfig.ts
2991
+ var _runtimeConfig = null;
2992
+ function injectRuntimeConfig(config) {
2993
+ _runtimeConfig = config;
2994
+ console.log("[serverConfig] \u2705 Runtime tier config injected:", {
2995
+ tier: config.tier,
2996
+ llmModel: config.llmModel,
2997
+ embeddingModel: config.embeddingModel,
2998
+ llmBaseUrl: config.llmBaseUrl,
2999
+ hasLitellmKey: !!config.litellmApiKey
3000
+ });
3001
+ }
3002
+ function getRuntimeConfig() {
3003
+ return _runtimeConfig;
3004
+ }
2891
3005
  function readString(env, name) {
2892
3006
  var _a3;
2893
3007
  const value = (_a3 = env[name]) == null ? void 0 : _a3.trim();
@@ -2914,7 +3028,7 @@ function getRagConfig(baseConfig, env = process.env) {
2914
3028
  return getEnvConfig(env, baseConfig);
2915
3029
  }
2916
3030
  function getEnvConfig(env = process.env, base) {
2917
- 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;
3031
+ 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;
2918
3032
  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;
2919
3033
  const jwtProjectId = (() => {
2920
3034
  if (!licenseKey) return void 0;
@@ -2999,32 +3113,41 @@ function getEnvConfig(env = process.env, base) {
2999
3113
  const isFreeTier2 = (() => {
3000
3114
  if (!licenseKey) return true;
3001
3115
  try {
3002
- const payload = LicenseVerifier.verify(licenseKey, projectId);
3003
- const tier = (payload.tier || "").toLowerCase();
3116
+ const tier = LicenseVerifier.extractTier(licenseKey).toLowerCase();
3004
3117
  return tier === "free_trial" || tier === "free_tier" || tier === "free" || tier === "hobby";
3005
3118
  } catch (e) {
3006
3119
  return true;
3007
3120
  }
3008
3121
  })();
3009
- const defaultGatewayUrl = (_ra = (_qa = readString(env, "LITELLM_BASE_URL")) != null ? _qa : readString(env, "LLM_BASE_URL")) != null ? _ra : "https://www.retrivora.com/api/v1";
3010
- const defaultLlmProvider = isFreeTier2 ? "universal_rest" : "universal_rest";
3011
- const llmProvider = (_ua = (_ta = readEnum(env, "LLM_PROVIDER", defaultLlmProvider, LLM_PROVIDERS)) != null ? _ta : (_sa = base == null ? void 0 : base.llm) == null ? void 0 : _sa.provider) != null ? _ua : defaultLlmProvider;
3012
- const llmBaseUrl = (_ya = (_xa = (_va = readString(env, "LITELLM_BASE_URL")) != null ? _va : readString(env, "LLM_BASE_URL")) != null ? _xa : (_wa = base == null ? void 0 : base.llm) == null ? void 0 : _wa.baseUrl) != null ? _ya : defaultGatewayUrl;
3013
- const llmModel = (_Ca = (_Aa = readString(env, "LLM_MODEL")) != null ? _Aa : (_za = base == null ? void 0 : base.llm) == null ? void 0 : _za.model) != null ? _Ca : isFreeTier2 ? "llama-3.1-8b-instant" : (_Ba = DEFAULT_MODEL_BY_PROVIDER[llmProvider]) != null ? _Ba : "gpt-4o";
3014
- const llmApiKey = (_Ia = (_Ha = (_Fa = (_Ea = (_Da = llmApiKeyByProvider[llmProvider]) != null ? _Da : readString(env, "LLM_API_KEY")) != null ? _Ea : readString(env, "LITELLM_MASTER_KEY")) != null ? _Fa : readString(env, "LITELLM_API_KEY")) != null ? _Ha : (_Ga = base == null ? void 0 : base.llm) == null ? void 0 : _Ga.apiKey) != null ? _Ia : licenseKey;
3015
- const llmProfile = (_Ma = (_La = readString(env, "LLM_UNIVERSAL_PROFILE")) != null ? _La : (_Ka = (_Ja = base == null ? void 0 : base.llm) == null ? void 0 : _Ja.options) == null ? void 0 : _Ka.profile) != null ? _Ma : "litellm";
3016
- const defaultEmbeddingProvider = isFreeTier2 ? "universal_rest" : "universal_rest";
3017
- const embeddingProvider = (_Pa = (_Oa = readEnum(env, "EMBEDDING_PROVIDER", defaultEmbeddingProvider, EMBEDDING_PROVIDERS)) != null ? _Oa : (_Na = base == null ? void 0 : base.embedding) == null ? void 0 : _Na.provider) != null ? _Pa : defaultEmbeddingProvider;
3018
- const embeddingBaseUrl = (_Ua = (_Ta = (_Ra = (_Qa = readString(env, "LITELLM_BASE_URL")) != null ? _Qa : readString(env, "EMBEDDING_BASE_URL")) != null ? _Ra : readString(env, "LLM_BASE_URL")) != null ? _Ta : (_Sa = base == null ? void 0 : base.embedding) == null ? void 0 : _Sa.baseUrl) != null ? _Ua : defaultGatewayUrl;
3019
- const embeddingModel = (_Xa = (_Wa = readString(env, "EMBEDDING_MODEL")) != null ? _Wa : (_Va = base == null ? void 0 : base.embedding) == null ? void 0 : _Va.model) != null ? _Xa : "text-embedding-004";
3020
- const embeddingApiKey = (_cb = (_bb = (_$a = (__a = (_Za = (_Ya = embeddingApiKeyByProvider[embeddingProvider]) != null ? _Ya : readString(env, "EMBEDDING_API_KEY")) != null ? _Za : readString(env, "LLM_API_KEY")) != null ? __a : readString(env, "LITELLM_MASTER_KEY")) != null ? _$a : readString(env, "LITELLM_API_KEY")) != null ? _bb : (_ab = base == null ? void 0 : base.embedding) == null ? void 0 : _ab.apiKey) != null ? _cb : licenseKey;
3021
- const embeddingProfile = (_gb = (_fb = readString(env, "EMBEDDING_UNIVERSAL_PROFILE")) != null ? _fb : (_eb = (_db = base == null ? void 0 : base.embedding) == null ? void 0 : _db.options) == null ? void 0 : _eb.profile) != null ? _gb : "litellm";
3122
+ const tierBasedLLMModel = isFreeTier2 ? "llama-3.1-8b-instant" : "llama-3.3-70b-versatile";
3123
+ const tierBasedEmbeddingModel = isFreeTier2 ? "text-embedding-004" : "text-embedding-004";
3124
+ const defaultGatewayUrl = "https://llm.retrivora.com/api/v1";
3125
+ const rt = _runtimeConfig;
3126
+ const defaultLlmProvider = "universal_rest";
3127
+ const llmProvider = (_sa = (_ra = readEnum(env, "LLM_PROVIDER", defaultLlmProvider, LLM_PROVIDERS)) != null ? _ra : (_qa = base == null ? void 0 : base.llm) == null ? void 0 : _qa.provider) != null ? _sa : defaultLlmProvider;
3128
+ const llmBaseUrl = (_xa = (_wa = (_va = (_ta = readString(env, "LITELLM_BASE_URL")) != null ? _ta : readString(env, "LLM_BASE_URL")) != null ? _va : (_ua = base == null ? void 0 : base.llm) == null ? void 0 : _ua.baseUrl) != null ? _wa : rt == null ? void 0 : rt.llmBaseUrl) != null ? _xa : defaultGatewayUrl;
3129
+ const llmModel = (_Ba = (_Aa = (_za = readString(env, "LLM_MODEL")) != null ? _za : (_ya = base == null ? void 0 : base.llm) == null ? void 0 : _ya.model) != null ? _Aa : rt == null ? void 0 : rt.llmModel) != null ? _Ba : tierBasedLLMModel;
3130
+ const llmApiKey = (_Fa = (_Ea = (_Ca = readString(env, "LITELLM_MASTER_KEY")) != null ? _Ca : rt == null ? void 0 : rt.litellmApiKey) != null ? _Ea : (_Da = base == null ? void 0 : base.llm) == null ? void 0 : _Da.apiKey) != null ? _Fa : licenseKey;
3131
+ const llmProfile = (_Ja = (_Ia = readString(env, "LLM_UNIVERSAL_PROFILE")) != null ? _Ia : (_Ha = (_Ga = base == null ? void 0 : base.llm) == null ? void 0 : _Ga.options) == null ? void 0 : _Ha.profile) != null ? _Ja : "litellm";
3132
+ console.log("[serverConfig] \u{1F527} LLM Configuration:", {
3133
+ baseUrl: llmBaseUrl,
3134
+ model: llmModel,
3135
+ provider: llmProvider,
3136
+ hasApiKey: !!llmApiKey,
3137
+ source: (rt == null ? void 0 : rt.llmModel) ? "runtime-injected" : "env/fallback"
3138
+ });
3139
+ const defaultEmbeddingProvider = "universal_rest";
3140
+ const embeddingProvider = (_Ma = (_La = readEnum(env, "EMBEDDING_PROVIDER", defaultEmbeddingProvider, EMBEDDING_PROVIDERS)) != null ? _La : (_Ka = base == null ? void 0 : base.embedding) == null ? void 0 : _Ka.provider) != null ? _Ma : defaultEmbeddingProvider;
3141
+ const embeddingBaseUrl = (_Ta = (_Sa = (_Ra = (_Qa = (_Oa = (_Na = readString(env, "LITELLM_BASE_URL")) != null ? _Na : readString(env, "EMBEDDING_BASE_URL")) != null ? _Oa : readString(env, "LLM_BASE_URL")) != null ? _Qa : (_Pa = base == null ? void 0 : base.embedding) == null ? void 0 : _Pa.baseUrl) != null ? _Ra : rt == null ? void 0 : rt.embeddingBaseUrl) != null ? _Sa : rt == null ? void 0 : rt.llmBaseUrl) != null ? _Ta : defaultGatewayUrl;
3142
+ const embeddingModel = (_Xa = (_Wa = (_Va = readString(env, "EMBEDDING_MODEL")) != null ? _Va : (_Ua = base == null ? void 0 : base.embedding) == null ? void 0 : _Ua.model) != null ? _Wa : rt == null ? void 0 : rt.embeddingModel) != null ? _Xa : tierBasedEmbeddingModel;
3143
+ const embeddingApiKey = (_$a = (__a = (_Ya = readString(env, "LITELLM_MASTER_KEY")) != null ? _Ya : rt == null ? void 0 : rt.litellmApiKey) != null ? __a : (_Za = base == null ? void 0 : base.embedding) == null ? void 0 : _Za.apiKey) != null ? _$a : licenseKey;
3144
+ const embeddingProfile = (_db = (_cb = readString(env, "EMBEDDING_UNIVERSAL_PROFILE")) != null ? _cb : (_bb = (_ab = base == null ? void 0 : base.embedding) == null ? void 0 : _ab.options) == null ? void 0 : _bb.profile) != null ? _db : "litellm";
3022
3145
  return __spreadProps(__spreadValues({
3023
3146
  projectId,
3024
3147
  licenseKey,
3025
3148
  vectorDb: {
3026
3149
  provider: vectorProvider,
3027
- indexName: (_ib = (_hb = readString(env, "VECTOR_DB_INDEX")) != null ? _hb : vectorDbOptions.indexName) != null ? _ib : "rag-index",
3150
+ indexName: (_fb = (_eb = readString(env, "VECTOR_DB_INDEX")) != null ? _eb : vectorDbOptions.indexName) != null ? _fb : "rag-index",
3028
3151
  options: vectorDbOptions
3029
3152
  },
3030
3153
  llm: {
@@ -3054,30 +3177,30 @@ function getEnvConfig(env = process.env, base) {
3054
3177
  }
3055
3178
  },
3056
3179
  ui: {
3057
- title: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _jb : readString(env, "UI_TITLE")) != null ? _kb : "AI Assistant",
3058
- subtitle: (_mb = (_lb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _lb : readString(env, "UI_SUBTITLE")) != null ? _mb : "Powered by RAG",
3059
- primaryColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _nb : readString(env, "UI_PRIMARY_COLOR")) != null ? _ob : "#10b981",
3060
- accentColor: (_qb = (_pb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _pb : readString(env, "UI_ACCENT_COLOR")) != null ? _qb : "#3b82f6",
3061
- logoUrl: (_rb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _rb : readString(env, "UI_LOGO_URL"),
3062
- placeholder: (_tb = (_sb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _sb : readString(env, "UI_PLACEHOLDER")) != null ? _tb : "Ask me anything\u2026",
3063
- showSources: ((_vb = (_ub = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ub : readString(env, "UI_SHOW_SOURCES")) != null ? _vb : "true") !== "false",
3064
- 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.",
3065
- visualStyle: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _yb : readString(env, "UI_VISUAL_STYLE")) != null ? _zb : "glass",
3066
- borderRadius: (_Bb = (_Ab = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _Ab : readString(env, "UI_BORDER_RADIUS")) != null ? _Bb : "xl",
3067
- allowUpload: ((_Db = (_Cb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Cb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Db : "false") === "true"
3180
+ title: (_hb = (_gb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _gb : readString(env, "UI_TITLE")) != null ? _hb : "AI Assistant",
3181
+ subtitle: (_jb = (_ib = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _ib : readString(env, "UI_SUBTITLE")) != null ? _jb : "Powered by RAG",
3182
+ primaryColor: (_lb = (_kb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _kb : readString(env, "UI_PRIMARY_COLOR")) != null ? _lb : "#10b981",
3183
+ accentColor: (_nb = (_mb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _mb : readString(env, "UI_ACCENT_COLOR")) != null ? _nb : "#3b82f6",
3184
+ logoUrl: (_ob = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _ob : readString(env, "UI_LOGO_URL"),
3185
+ placeholder: (_qb = (_pb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _pb : readString(env, "UI_PLACEHOLDER")) != null ? _qb : "Ask me anything\u2026",
3186
+ showSources: ((_sb = (_rb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _rb : readString(env, "UI_SHOW_SOURCES")) != null ? _sb : "true") !== "false",
3187
+ welcomeMessage: (_ub = (_tb = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _tb : readString(env, "UI_WELCOME_MESSAGE")) != null ? _ub : "Hello! I'm your AI assistant. Ask me anything about your documents.",
3188
+ visualStyle: (_wb = (_vb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _vb : readString(env, "UI_VISUAL_STYLE")) != null ? _wb : "glass",
3189
+ borderRadius: (_yb = (_xb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _xb : readString(env, "UI_BORDER_RADIUS")) != null ? _yb : "xl",
3190
+ allowUpload: ((_Ab = (_zb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _zb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Ab : "false") === "true"
3068
3191
  },
3069
3192
  rag: {
3070
3193
  topK: readNumber(env, "RAG_TOP_K", 5),
3071
3194
  scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
3072
3195
  chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
3073
3196
  chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
3074
- filterableFields: (_Eb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Eb.split(",").map((f) => f.trim()),
3197
+ filterableFields: (_Bb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Bb.split(",").map((f) => f.trim()),
3075
3198
  // Query pipeline toggles — read from .env.local
3076
3199
  useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
3077
3200
  useReranking: readString(env, "RAG_USE_RERANKING") === "true",
3078
3201
  useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
3079
- architecture: (_Fb = readString(env, "RAG_ARCHITECTURE")) != null ? _Fb : "simple",
3080
- chunkingStrategy: (_Gb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Gb : "recursive",
3202
+ architecture: (_Cb = readString(env, "RAG_ARCHITECTURE")) != null ? _Cb : "simple",
3203
+ chunkingStrategy: (_Db = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Db : "recursive",
3081
3204
  uiMapping: (() => {
3082
3205
  const raw = readString(env, "RAG_UI_MAPPING");
3083
3206
  if (!raw) return void 0;
@@ -3090,7 +3213,7 @@ function getEnvConfig(env = process.env, base) {
3090
3213
  },
3091
3214
  telemetry: {
3092
3215
  enabled: telemetryEnabled,
3093
- url: (_Kb = (_Jb = (_Hb = readString(env, "TELEMETRY_URL")) != null ? _Hb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Jb : (_Ib = base == null ? void 0 : base.telemetry) == null ? void 0 : _Ib.url) != null ? _Kb : "https://www.retrivora.com/api/telemetry"
3216
+ url: (_Hb = (_Gb = (_Eb = readString(env, "TELEMETRY_URL")) != null ? _Eb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Gb : (_Fb = base == null ? void 0 : base.telemetry) == null ? void 0 : _Fb.url) != null ? _Hb : "https://www.retrivora.com/api/telemetry"
3094
3217
  }
3095
3218
  }, readString(env, "GRAPH_DB_PROVIDER") ? {
3096
3219
  graphDb: {
@@ -3614,8 +3737,8 @@ var OllamaProvider = class {
3614
3737
  const baseUrl = config.baseUrl || "http://localhost:11434";
3615
3738
  const modelName = config.model;
3616
3739
  try {
3617
- const axios9 = (await import("axios")).default;
3618
- const { data } = await axios9.get(`${baseUrl}/api/tags`);
3740
+ const axios11 = (await import("axios")).default;
3741
+ const { data } = await axios11.get(`${baseUrl}/api/tags`);
3619
3742
  const models = data.models || [];
3620
3743
  const hasModel = models.some((m) => m.name === modelName || m.name.startsWith(`${modelName}:`));
3621
3744
  return {
@@ -4447,7 +4570,7 @@ var UniversalLLMAdapter = class {
4447
4570
  });
4448
4571
  }
4449
4572
  async chat(messages, context) {
4450
- var _a3, _b, _c, _d, _e;
4573
+ var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j;
4451
4574
  const path2 = (_a3 = this.opts.chatPath) != null ? _a3 : "/chat/completions";
4452
4575
  const safeMessages = (Array.isArray(messages) ? messages : []).filter((m) => Boolean(m && typeof m === "object")).map((m) => ({
4453
4576
  role: m.role || "user",
@@ -4477,16 +4600,27 @@ ${context != null ? context : "None"}` },
4477
4600
  };
4478
4601
  }
4479
4602
  try {
4603
+ console.debug(`[UniversalLLMAdapter] POST ${this.baseUrl}${path2}`);
4604
+ console.debug(`[UniversalLLMAdapter] Model: ${this.model}`);
4605
+ console.debug(`[UniversalLLMAdapter] Auth: Bearer ${((_b = this.apiKey) == null ? void 0 : _b.substring(0, 20)) || "none"}...`);
4480
4606
  const { data: data2 } = await this.http.post(path2, payload);
4481
- const extractPath2 = (_b = this.opts.responseExtractPath) != null ? _b : "choices[0].message.content";
4482
- const result2 = (_c = resolvePath(data2, extractPath2)) != null ? _c : extractContent(data2);
4607
+ const extractPath2 = (_c = this.opts.responseExtractPath) != null ? _c : "choices[0].message.content";
4608
+ const result2 = (_d = resolvePath(data2, extractPath2)) != null ? _d : extractContent(data2);
4483
4609
  if (result2 !== void 0) {
4484
4610
  return String(result2);
4485
4611
  }
4486
4612
  } catch (httpErr) {
4487
- const _g2 = globalThis;
4488
- const dispatch = _g2.__retrivoraDispatchChat;
4613
+ console.error("[UniversalLLMAdapter] \u274C HTTP chat request failed:", {
4614
+ status: (_e = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _e.status,
4615
+ statusText: (_f = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _f.statusText,
4616
+ url: (_g2 = httpErr == null ? void 0 : httpErr.config) == null ? void 0 : _g2.url,
4617
+ errorData: (_h = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _h.data,
4618
+ message: httpErr == null ? void 0 : httpErr.message
4619
+ });
4620
+ const _g3 = globalThis;
4621
+ const dispatch = _g3.__retrivoraDispatchChat;
4489
4622
  if (typeof dispatch === "function") {
4623
+ console.debug("[UniversalLLMAdapter] \u{1F504} Attempting in-process fallback dispatch");
4490
4624
  const res = await dispatch({
4491
4625
  model: this.model,
4492
4626
  messages: formattedMessages,
@@ -4501,8 +4635,8 @@ ${context != null ? context : "None"}` },
4501
4635
  throw httpErr;
4502
4636
  }
4503
4637
  const { data } = await this.http.post(path2, payload);
4504
- const extractPath = (_d = this.opts.responseExtractPath) != null ? _d : "choices[0].message.content";
4505
- const result = (_e = resolvePath(data, extractPath)) != null ? _e : extractContent(data);
4638
+ const extractPath = (_i = this.opts.responseExtractPath) != null ? _i : "choices[0].message.content";
4639
+ const result = (_j = resolvePath(data, extractPath)) != null ? _j : extractContent(data);
4506
4640
  if (result === void 0) {
4507
4641
  throw new Error(`[UniversalLLMAdapter] Could not extract text from path '${extractPath}' in response.`);
4508
4642
  }
@@ -4641,36 +4775,70 @@ ${context != null ? context : "None"}` },
4641
4775
  });
4642
4776
  }
4643
4777
  async embed(text) {
4644
- var _a3, _b, _c, _d, _e;
4778
+ var _a3, _b, _c, _d, _e, _f, _g2;
4645
4779
  const path2 = (_a3 = this.opts.embedPath) != null ? _a3 : "/embeddings";
4646
4780
  const payload = this.opts.embedPayloadTemplate ? buildPayload(this.opts.embedPayloadTemplate, { input: text, model: this.model }) : { input: text, model: this.model };
4647
4781
  try {
4648
- const { data: data2 } = await this.http.post(path2, payload);
4649
- const extractPath2 = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
4650
- const vector2 = resolvePath(data2, extractPath2);
4651
- if (Array.isArray(vector2)) return vector2;
4652
- } catch (e) {
4653
- const _g2 = globalThis;
4654
- const dispatchEmbed = _g2.__retrivoraDispatchEmbedding;
4782
+ const { data } = await this.http.post(path2, payload);
4783
+ const extractPath = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
4784
+ const vector = resolvePath(data, extractPath);
4785
+ if (Array.isArray(vector)) return vector;
4786
+ console.warn(
4787
+ `[UniversalLLMAdapter] Embedding API returned unexpected format for path '${extractPath}'. Response:`,
4788
+ data
4789
+ );
4790
+ } catch (err) {
4791
+ console.warn(
4792
+ `[UniversalLLMAdapter] HTTP embedding request failed: ${(err == null ? void 0 : err.message) || err}`,
4793
+ { path: path2, model: this.model }
4794
+ );
4795
+ const _g3 = globalThis;
4796
+ const dispatchEmbed = _g3.__retrivoraDispatchEmbedding;
4655
4797
  if (typeof dispatchEmbed === "function") {
4656
- const res = await dispatchEmbed({ input: text, model: this.model }, this.apiKey);
4657
- if ((_d = (_c = res == null ? void 0 : res.data) == null ? void 0 : _c[0]) == null ? void 0 : _d.embedding) {
4658
- return res.data[0].embedding;
4798
+ try {
4799
+ const res = await dispatchEmbed({ input: text, model: this.model }, this.apiKey);
4800
+ if ((_d = (_c = res == null ? void 0 : res.data) == null ? void 0 : _c[0]) == null ? void 0 : _d.embedding) {
4801
+ return res.data[0].embedding;
4802
+ }
4803
+ } catch (dispatchErr) {
4804
+ console.warn("[UniversalLLMAdapter] In-process dispatch embedding failed:", dispatchErr);
4659
4805
  }
4660
4806
  }
4661
4807
  }
4662
- const { data } = await this.http.post(path2, payload);
4663
- const extractPath = (_e = this.opts.embedExtractPath) != null ? _e : "data[0].embedding";
4664
- const vector = resolvePath(data, extractPath);
4665
- if (!Array.isArray(vector)) {
4666
- throw new Error(`[UniversalLLMAdapter] Could not extract embedding vector from path '${extractPath}' in response.`);
4808
+ try {
4809
+ const { data } = await this.http.post(path2, payload);
4810
+ const extractPath = (_e = this.opts.embedExtractPath) != null ? _e : "data[0].embedding";
4811
+ const vector = resolvePath(data, extractPath);
4812
+ if (Array.isArray(vector)) {
4813
+ return vector;
4814
+ }
4815
+ console.error(
4816
+ `[UniversalLLMAdapter] Retry embedding failed: unexpected response format for path '${extractPath}'. Response:`,
4817
+ data
4818
+ );
4819
+ throw new Error(
4820
+ `[UniversalLLMAdapter] Could not extract embedding vector. Expected array at '${extractPath}', got: ${typeof vector}. Response keys: ${Object.keys(data || {})}.`
4821
+ );
4822
+ } catch (err) {
4823
+ console.error(
4824
+ `[UniversalLLMAdapter] Both embedding attempts failed. Path: ${path2}, Model: ${this.model}`,
4825
+ { error: err == null ? void 0 : err.message, statusCode: (_f = err == null ? void 0 : err.response) == null ? void 0 : _f.status, response: (_g2 = err == null ? void 0 : err.response) == null ? void 0 : _g2.data }
4826
+ );
4827
+ throw new Error(
4828
+ `[UniversalLLMAdapter] Failed to generate embedding after 2 attempts: ${(err == null ? void 0 : err.message) || err}`
4829
+ );
4667
4830
  }
4668
- return vector;
4669
4831
  }
4670
4832
  async batchEmbed(texts) {
4671
4833
  const results = [];
4672
4834
  for (const text of texts) {
4673
- results.push(await this.embed(text));
4835
+ try {
4836
+ const vector = await this.embed(text);
4837
+ results.push(vector);
4838
+ } catch (err) {
4839
+ console.warn(`[UniversalLLMAdapter] batchEmbed failed for text (first 50 chars): ${text.slice(0, 50)}...`, err);
4840
+ throw err;
4841
+ }
4674
4842
  }
4675
4843
  return results;
4676
4844
  }
@@ -9790,7 +9958,7 @@ var Retrivora = class {
9790
9958
  var _a3;
9791
9959
  try {
9792
9960
  await ConfigValidator.validateAndThrow(this.config);
9793
- LicenseVerifier.verify(
9961
+ await LicenseVerifier.verifyAsync(
9794
9962
  this.config.licenseKey,
9795
9963
  this.config.projectId,
9796
9964
  (_a3 = this.config.vectorDb) == null ? void 0 : _a3.provider
@@ -10156,7 +10324,7 @@ var VectorPlugin = class {
10156
10324
  this.validationPromise = (async () => {
10157
10325
  var _a3;
10158
10326
  await ConfigValidator.validateAndThrow(resolvedConfig);
10159
- LicenseVerifier.verify(
10327
+ await LicenseVerifier.verifyAsync(
10160
10328
  resolvedConfig.licenseKey,
10161
10329
  resolvedConfig.projectId,
10162
10330
  (_a3 = resolvedConfig.vectorDb) == null ? void 0 : _a3.provider
@@ -10650,7 +10818,7 @@ var DatabaseStorage = class {
10650
10818
  * In non-production (development / test) environments this is a complete no-op —
10651
10819
  * all History and Feedback features are freely accessible for local development.
10652
10820
  */
10653
- checkPremiumSubscription() {
10821
+ async checkPremiumSubscription() {
10654
10822
  if (process.env.NODE_ENV !== "production") {
10655
10823
  return;
10656
10824
  }
@@ -10660,7 +10828,7 @@ var DatabaseStorage = class {
10660
10828
  );
10661
10829
  }
10662
10830
  try {
10663
- const payload = LicenseVerifier.verify(this.config.licenseKey, this.config.projectId);
10831
+ const payload = await LicenseVerifier.verifyAsync(this.config.licenseKey, this.config.projectId);
10664
10832
  const tier = (payload.tier || "").toLowerCase();
10665
10833
  if (tier !== "premium" && tier !== "enterprise" && tier !== "growth" && tier !== "pro" && tier !== "developer_pro" && tier !== "free_trial" && tier !== "free_tier" && tier !== "free" && tier !== "hobby") {
10666
10834
  throw new Error(
@@ -10673,16 +10841,16 @@ var DatabaseStorage = class {
10673
10841
  );
10674
10842
  }
10675
10843
  }
10676
- checkHistoryEnabled() {
10844
+ async checkHistoryEnabled() {
10677
10845
  var _a3, _b;
10678
- this.checkPremiumSubscription();
10846
+ await this.checkPremiumSubscription();
10679
10847
  if (((_b = (_a3 = this.config.rag) == null ? void 0 : _a3.history) == null ? void 0 : _b.enabled) === false) {
10680
10848
  throw new Error("[Retrivora SDK] Chat History is disabled in RagConfig.");
10681
10849
  }
10682
10850
  }
10683
- checkFeedbackEnabled() {
10851
+ async checkFeedbackEnabled() {
10684
10852
  var _a3, _b;
10685
- this.checkPremiumSubscription();
10853
+ await this.checkPremiumSubscription();
10686
10854
  if (((_b = (_a3 = this.config.rag) == null ? void 0 : _a3.feedback) == null ? void 0 : _b.enabled) === false) {
10687
10855
  throw new Error("[Retrivora SDK] User Feedback is disabled in RagConfig.");
10688
10856
  }
@@ -10788,7 +10956,7 @@ var DatabaseStorage = class {
10788
10956
  }
10789
10957
  // ─── Message History Operations ──────────────────────────────────────────
10790
10958
  async saveMessage(sessionId, message) {
10791
- this.checkHistoryEnabled();
10959
+ await this.checkHistoryEnabled();
10792
10960
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
10793
10961
  const msgId = message.id || `msg_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`;
10794
10962
  if (this.provider === "postgresql" || this.provider === "pgvector") {
@@ -10851,7 +11019,7 @@ var DatabaseStorage = class {
10851
11019
  }
10852
11020
  }
10853
11021
  async getHistory(sessionId, projectIds) {
10854
- this.checkHistoryEnabled();
11022
+ await this.checkHistoryEnabled();
10855
11023
  if (projectIds && projectIds.length > 0 && !this.sessionInScope(sessionId, projectIds)) {
10856
11024
  return [];
10857
11025
  }
@@ -10885,7 +11053,7 @@ var DatabaseStorage = class {
10885
11053
  }
10886
11054
  }
10887
11055
  async clearHistory(sessionId, projectIds) {
10888
- this.checkHistoryEnabled();
11056
+ await this.checkHistoryEnabled();
10889
11057
  if (projectIds && projectIds.length > 0 && !this.sessionInScope(sessionId, projectIds)) {
10890
11058
  return;
10891
11059
  }
@@ -10921,7 +11089,7 @@ var DatabaseStorage = class {
10921
11089
  );
10922
11090
  }
10923
11091
  async listSessions(projectIds) {
10924
- this.checkHistoryEnabled();
11092
+ await this.checkHistoryEnabled();
10925
11093
  let raw = [];
10926
11094
  if (this.provider === "postgresql" || this.provider === "pgvector") {
10927
11095
  const pool = await this.getPGPool();
@@ -10940,7 +11108,7 @@ var DatabaseStorage = class {
10940
11108
  }
10941
11109
  // ─── Feedback Operations ──────────────────────────────────────────────────
10942
11110
  async saveFeedback(feedback) {
10943
- this.checkFeedbackEnabled();
11111
+ await this.checkFeedbackEnabled();
10944
11112
  const id = `fb_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`;
10945
11113
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
10946
11114
  if (this.provider === "postgresql" || this.provider === "pgvector") {
@@ -10990,7 +11158,7 @@ var DatabaseStorage = class {
10990
11158
  }
10991
11159
  }
10992
11160
  async getFeedback(messageId, projectIds) {
10993
- this.checkFeedbackEnabled();
11161
+ await this.checkFeedbackEnabled();
10994
11162
  let item = null;
10995
11163
  if (this.provider === "postgresql" || this.provider === "pgvector") {
10996
11164
  const pool = await this.getPGPool();
@@ -11026,7 +11194,7 @@ var DatabaseStorage = class {
11026
11194
  return item;
11027
11195
  }
11028
11196
  async listFeedback(projectIds) {
11029
- this.checkFeedbackEnabled();
11197
+ await this.checkFeedbackEnabled();
11030
11198
  let raw = [];
11031
11199
  if (this.provider === "postgresql" || this.provider === "pgvector") {
11032
11200
  const pool = await this.getPGPool();
@@ -11176,12 +11344,23 @@ function resolveLicenseKey(req, config, bodyLicenseKey) {
11176
11344
  var _a3;
11177
11345
  return req.headers.get("x-license-key") || bodyLicenseKey || ((_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 || process.env.RAG_LICENSE_KEY || "";
11178
11346
  }
11179
- function enforceLicense(req, config, bodyLicenseKey) {
11347
+ async function enforceLicense(req, config, bodyLicenseKey) {
11180
11348
  const rawKey = resolveLicenseKey(req, config, bodyLicenseKey);
11181
11349
  const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
11182
11350
  const projectId = config.projectId || "";
11183
11351
  try {
11184
- const payload = LicenseVerifier.verify(licenseKey, projectId);
11352
+ let payload;
11353
+ try {
11354
+ payload = await LicenseVerifier.verifyAsync(licenseKey, projectId);
11355
+ } catch (err) {
11356
+ return {
11357
+ ok: false,
11358
+ response: NextResponse.json(
11359
+ { error: `License validation failed: ${err.message}` },
11360
+ { status: 401 }
11361
+ )
11362
+ };
11363
+ }
11185
11364
  return { ok: true, payload };
11186
11365
  } catch (err) {
11187
11366
  const message = err instanceof Error ? err.message : "Missing or invalid RETRIVORA_LICENSE_KEY. Set NEXT_PUBLIC_RETRIVORA_LICENSE_KEY in your environment or contact your administrator.";
@@ -11356,7 +11535,7 @@ function createChatHandler(configOrPlugin, options) {
11356
11535
  try {
11357
11536
  const body = await req.json();
11358
11537
  const bodyObj = body != null ? body : {};
11359
- const licenseCheck = enforceLicense(req, config, bodyObj == null ? void 0 : bodyObj.licenseKey);
11538
+ const licenseCheck = await enforceLicense(req, config, bodyObj == null ? void 0 : bodyObj.licenseKey);
11360
11539
  if (!licenseCheck.ok) return licenseCheck.response;
11361
11540
  if (isFreeTier(licenseCheck.payload.tier)) {
11362
11541
  const estimatedInputTokens = Math.ceil(
@@ -11450,7 +11629,7 @@ function createStreamHandler(configOrPlugin, options) {
11450
11629
  });
11451
11630
  }
11452
11631
  const bodyObj = body != null ? body : {};
11453
- const licenseCheck = enforceLicense(req, config, bodyObj == null ? void 0 : bodyObj.licenseKey);
11632
+ const licenseCheck = await enforceLicense(req, config, bodyObj == null ? void 0 : bodyObj.licenseKey);
11454
11633
  if (!licenseCheck.ok) return licenseCheck.response;
11455
11634
  if (isFreeTier(licenseCheck.payload.tier)) {
11456
11635
  const estimatedInputTokens = Math.ceil(
@@ -11615,7 +11794,7 @@ function createIngestHandler(configOrPlugin, options) {
11615
11794
  const config = plugin.getConfig();
11616
11795
  try {
11617
11796
  const body = await req.json();
11618
- const licenseCheck = enforceLicense(req, config, body == null ? void 0 : body.licenseKey);
11797
+ const licenseCheck = await enforceLicense(req, config, body == null ? void 0 : body.licenseKey);
11619
11798
  if (!licenseCheck.ok) return licenseCheck.response;
11620
11799
  const { documents, namespace } = body;
11621
11800
  if (!Array.isArray(documents) || documents.length === 0) {
@@ -11691,7 +11870,7 @@ function createLicenseHandler(configOrPlugin, options) {
11691
11870
  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 || "";
11692
11871
  const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
11693
11872
  const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "";
11694
- const payload = LicenseVerifier.verify(licenseKey, projectId);
11873
+ const payload = await LicenseVerifier.verifyAsync(licenseKey, projectId);
11695
11874
  return NextResponse.json({
11696
11875
  valid: true,
11697
11876
  licenseStatus: "ACTIVE",
@@ -11721,14 +11900,16 @@ function createUploadHandler(configOrPlugin, options) {
11721
11900
  const plugin = getOrCreatePlugin(configOrPlugin);
11722
11901
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
11723
11902
  return async function POST(req, context) {
11903
+ console.log("Upload handler invoked");
11724
11904
  const authResult = await checkAuth(req, onAuthorize);
11725
11905
  if (authResult) return authResult;
11726
11906
  const config = plugin.getConfig();
11727
- const licenseCheck = enforceLicense(req, config);
11907
+ const licenseCheck = await enforceLicense(req, config);
11728
11908
  if (!licenseCheck.ok) return licenseCheck.response;
11729
11909
  try {
11730
11910
  const formData = await req.formData();
11731
11911
  const files = formData.getAll("files");
11912
+ console.log("Files received for upload:", files.map((f) => f.name));
11732
11913
  const namespace = formData.get("namespace") || void 0;
11733
11914
  const dimensionRaw = formData.get("dimension");
11734
11915
  const dimension = dimensionRaw ? parseInt(dimensionRaw, 10) : void 0;
@@ -11867,7 +12048,7 @@ function createSuggestionsHandler(configOrPlugin, options) {
11867
12048
  const authResult = await checkAuth(req, onAuthorize);
11868
12049
  if (authResult) return authResult;
11869
12050
  const config = plugin.getConfig();
11870
- const licenseCheck = enforceLicense(req, config);
12051
+ const licenseCheck = await enforceLicense(req, config);
11871
12052
  if (!licenseCheck.ok) return licenseCheck.response;
11872
12053
  let effectiveLicensePayload = licenseCheck.payload;
11873
12054
  try {
@@ -11880,7 +12061,7 @@ function createSuggestionsHandler(configOrPlugin, options) {
11880
12061
  namespace = body.namespace;
11881
12062
  bodyLicenseKey = body.licenseKey;
11882
12063
  if (bodyLicenseKey) {
11883
- const recheck = enforceLicense(req, config, bodyLicenseKey);
12064
+ const recheck = await enforceLicense(req, config, bodyLicenseKey);
11884
12065
  if (!recheck.ok) return recheck.response;
11885
12066
  effectiveLicensePayload = recheck.payload;
11886
12067
  }
@@ -12171,6 +12352,7 @@ var _LicenseValidator = class _LicenseValidator {
12171
12352
  retrivoraApiBase,
12172
12353
  headers: customHeaders
12173
12354
  } = request;
12355
+ const effectiveProjectId = projectId || (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_RETRIVORA_PROJECT_ID || process.env.RETRIVORA_PROJECT_ID : "") || "";
12174
12356
  const getHeader = (name) => {
12175
12357
  if (!customHeaders) return void 0;
12176
12358
  const target = name.toLowerCase();
@@ -12208,7 +12390,7 @@ var _LicenseValidator = class _LicenseValidator {
12208
12390
  }, customHeaders || {}),
12209
12391
  body: JSON.stringify({
12210
12392
  licenseKey: effectiveLicenseKey,
12211
- projectId,
12393
+ projectId: effectiveProjectId,
12212
12394
  sdkVersion,
12213
12395
  sdk,
12214
12396
  platform
@@ -12219,7 +12401,7 @@ var _LicenseValidator = class _LicenseValidator {
12219
12401
  if (!canUseLocalValidationFallback(base)) {
12220
12402
  throw err;
12221
12403
  }
12222
- const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "");
12404
+ const payload = await LicenseVerifier.verifyAsync(effectiveLicenseKey, effectiveProjectId);
12223
12405
  const fallbackResp = {
12224
12406
  valid: true,
12225
12407
  licenseStatus: "ACTIVE",
@@ -12238,7 +12420,7 @@ var _LicenseValidator = class _LicenseValidator {
12238
12420
  }
12239
12421
  if (res && !res.ok && canUseLocalValidationFallback(base, res.status)) {
12240
12422
  try {
12241
- const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "");
12423
+ const payload = await LicenseVerifier.verifyAsync(effectiveLicenseKey, effectiveProjectId);
12242
12424
  const fallbackResp = {
12243
12425
  valid: true,
12244
12426
  licenseStatus: "ACTIVE",
@@ -12282,6 +12464,583 @@ var _LicenseValidator = class _LicenseValidator {
12282
12464
  };
12283
12465
  _LicenseValidator.SUCCESS_CACHE_TTL_MS = 5 * 60 * 1e3;
12284
12466
  var LicenseValidator = _LicenseValidator;
12467
+
12468
+ // src/config/LicenseConfigResolver.ts
12469
+ import axios9 from "axios";
12470
+ var LicenseConfigResolver = class {
12471
+ /**
12472
+ * Validate and resolve configuration from license key
12473
+ * @param licenseKey JWT token from Retrivora (format: rtv_eyJ...)
12474
+ * @param projectId Workspace identifier
12475
+ * @returns Resolved LLM and embedding configs with provider credentials
12476
+ */
12477
+ static async resolveFromLicense(licenseKey, projectId) {
12478
+ const cacheKey = `${licenseKey}:${projectId}`;
12479
+ const cached = this.configCache.get(cacheKey);
12480
+ if (cached && Date.now() - cached.timestamp < this.CACHE_TTL_MS) {
12481
+ console.log("[LicenseConfigResolver] Using cached config for", projectId);
12482
+ return this.buildConfigs(cached.config, cached.credentials, licenseKey, projectId);
12483
+ }
12484
+ console.log("[LicenseConfigResolver] Fetching tier config from Retrivora...");
12485
+ const tierConfig = await this.fetchTierConfig(licenseKey, projectId);
12486
+ console.log("[LicenseConfigResolver] Fetching provider credentials from Retrivora...");
12487
+ const credentials = await this.fetchProviderCredentials(licenseKey, projectId);
12488
+ this.configCache.set(cacheKey, { config: tierConfig, credentials, timestamp: Date.now() });
12489
+ console.log("[LicenseConfigResolver] \u2705 Successfully resolved config from Retrivora:", {
12490
+ tier: tierConfig.tier,
12491
+ llmModel: tierConfig.llmModel,
12492
+ embeddingModel: tierConfig.embeddingModel
12493
+ });
12494
+ return this.buildConfigs(tierConfig, credentials, licenseKey, projectId);
12495
+ }
12496
+ /**
12497
+ * Fetch tier configuration from Retrivora config API
12498
+ */
12499
+ static async fetchTierConfig(licenseKey, projectId) {
12500
+ try {
12501
+ const response = await axios9.post(
12502
+ this.RETRIVORA_CONFIG_URL,
12503
+ { licenseKey, projectId },
12504
+ {
12505
+ headers: {
12506
+ "Content-Type": "application/json",
12507
+ Authorization: `Bearer ${licenseKey}`,
12508
+ "X-License-Key": licenseKey,
12509
+ "X-Project-ID": projectId
12510
+ },
12511
+ timeout: 1e4
12512
+ }
12513
+ );
12514
+ if (!response.data.success || !response.data.config) {
12515
+ throw new Error(
12516
+ `[LicenseConfigResolver] Config API returned error: ${response.data.error || response.data.message}`
12517
+ );
12518
+ }
12519
+ console.log(`[LicenseConfigResolver] Resolved tier: ${response.data.config.tier}`);
12520
+ return response.data.config;
12521
+ } catch (err) {
12522
+ console.error("[LicenseConfigResolver] Failed to fetch config:", err.message);
12523
+ throw new Error(
12524
+ `[LicenseConfigResolver] Could not validate license key or fetch tier configuration: ${err.message}`
12525
+ );
12526
+ }
12527
+ }
12528
+ /**
12529
+ * Fetch provider credentials from Retrivora credentials API
12530
+ */
12531
+ static async fetchProviderCredentials(licenseKey, projectId) {
12532
+ try {
12533
+ const response = await axios9.post(
12534
+ this.RETRIVORA_CREDENTIALS_URL,
12535
+ { licenseKey, projectId },
12536
+ {
12537
+ headers: {
12538
+ "Content-Type": "application/json",
12539
+ Authorization: `Bearer ${licenseKey}`,
12540
+ "X-License-Key": licenseKey,
12541
+ "X-Project-ID": projectId
12542
+ },
12543
+ timeout: 1e4
12544
+ }
12545
+ );
12546
+ if (!response.data.success || !response.data.credentials) {
12547
+ throw new Error(
12548
+ `[LicenseConfigResolver] Credentials API returned error: ${response.data.error || response.data.message}`
12549
+ );
12550
+ }
12551
+ console.log(`[LicenseConfigResolver] Retrieved provider credentials for project: ${projectId}`);
12552
+ return response.data.credentials;
12553
+ } catch (err) {
12554
+ console.error("[LicenseConfigResolver] Failed to fetch credentials:", err.message);
12555
+ throw new Error(
12556
+ `[LicenseConfigResolver] Could not fetch provider credentials: ${err.message}`
12557
+ );
12558
+ }
12559
+ }
12560
+ /**
12561
+ * Build LLM, embedding, and vector DB configs from tier and credentials
12562
+ */
12563
+ static buildConfigs(tierConfig, credentials, licenseKey, projectId) {
12564
+ let llmProvider = "gemini";
12565
+ let llmApiKey = credentials.geminiApiKey || licenseKey;
12566
+ if (tierConfig.llmModel.includes("gpt")) {
12567
+ llmProvider = "openai";
12568
+ } else if (tierConfig.llmModel.includes("groq") || tierConfig.llmModel.includes("llama")) {
12569
+ llmProvider = "groq";
12570
+ llmApiKey = credentials.groqApiKey || licenseKey;
12571
+ }
12572
+ const llmConfig = {
12573
+ provider: llmProvider,
12574
+ model: tierConfig.llmModel,
12575
+ apiKey: llmApiKey,
12576
+ maxTokens: tierConfig.maxTokens,
12577
+ temperature: 0.7,
12578
+ options: {}
12579
+ };
12580
+ const embeddingConfig = {
12581
+ provider: "gemini",
12582
+ model: tierConfig.embeddingModel,
12583
+ apiKey: credentials.geminiApiKey || licenseKey,
12584
+ dimensions: tierConfig.embeddingDimensions,
12585
+ options: {}
12586
+ };
12587
+ const vectorDbConfig = {
12588
+ provider: tierConfig.vectorDb.provider,
12589
+ indexName: tierConfig.vectorDb.indexName,
12590
+ options: this.getVectorDbOptions(tierConfig.vectorDb.provider, projectId, credentials)
12591
+ };
12592
+ return { llmConfig, embeddingConfig, vectorDbConfig, tierConfig, credentials };
12593
+ }
12594
+ /**
12595
+ * Get provider-specific vector DB options
12596
+ */
12597
+ static getVectorDbOptions(provider, projectId, credentials) {
12598
+ switch (provider) {
12599
+ case "pinecone":
12600
+ return {
12601
+ apiKey: credentials.pineconeApiKey,
12602
+ indexName: `retrivora-${projectId}`
12603
+ };
12604
+ case "pgvector":
12605
+ case "postgresql":
12606
+ return {
12607
+ tables: [`documents_${projectId}`]
12608
+ };
12609
+ case "mongodb":
12610
+ return {
12611
+ database: `retrivora_${projectId}`,
12612
+ collection: `vectors_${projectId}`
12613
+ };
12614
+ case "qdrant":
12615
+ return {
12616
+ collection: `retrivora_${projectId}`
12617
+ };
12618
+ default:
12619
+ return {};
12620
+ }
12621
+ }
12622
+ /**
12623
+ * Clear configuration cache (useful for testing or manual refresh)
12624
+ */
12625
+ static clearCache() {
12626
+ this.configCache.clear();
12627
+ console.log("[LicenseConfigResolver] Configuration cache cleared");
12628
+ }
12629
+ /**
12630
+ * Get cache stats for debugging
12631
+ */
12632
+ static getCacheStats() {
12633
+ return {
12634
+ size: this.configCache.size,
12635
+ entries: Array.from(this.configCache.keys())
12636
+ };
12637
+ }
12638
+ };
12639
+ LicenseConfigResolver.RETRIVORA_CONFIG_URL = "https://www.retrivora.com/api/v1/config";
12640
+ LicenseConfigResolver.RETRIVORA_CREDENTIALS_URL = "https://www.retrivora.com/api/v1/credentials";
12641
+ LicenseConfigResolver.CACHE_TTL_MS = 36e5;
12642
+ // 1 hour
12643
+ LicenseConfigResolver.configCache = /* @__PURE__ */ new Map();
12644
+
12645
+ // src/telemetry/TelemetryService.ts
12646
+ import axios10 from "axios";
12647
+ var EventType = /* @__PURE__ */ ((EventType2) => {
12648
+ EventType2["EMBEDDING_GENERATED"] = "embedding_generated";
12649
+ EventType2["LLM_CHAT_COMPLETION"] = "llm_chat_completion";
12650
+ EventType2["DOCUMENT_INGESTED"] = "document_ingested";
12651
+ EventType2["QUERY_EXECUTED"] = "query_executed";
12652
+ EventType2["ERROR_OCCURRED"] = "error_occurred";
12653
+ EventType2["CONFIGURATION_LOADED"] = "configuration_loaded";
12654
+ return EventType2;
12655
+ })(EventType || {});
12656
+ var _TelemetryService = class _TelemetryService {
12657
+ constructor(projectId, licenseKey, userTelemetryUrl) {
12658
+ this.batchSize = 10;
12659
+ this.flushIntervalMs = 3e4;
12660
+ // 30 seconds
12661
+ this.eventQueue = [];
12662
+ this.enabled = true;
12663
+ this.projectId = projectId;
12664
+ this.licenseKey = licenseKey;
12665
+ this.userTelemetryUrl = userTelemetryUrl || process.env[_TelemetryService.USER_TELEMETRY_URL_ENV_KEY];
12666
+ this.http = axios10.create({
12667
+ timeout: 5e3,
12668
+ headers: {
12669
+ "Content-Type": "application/json",
12670
+ "X-License-Key": licenseKey,
12671
+ "X-Project-ID": projectId
12672
+ }
12673
+ });
12674
+ this.startAutoFlush();
12675
+ }
12676
+ /**
12677
+ * Record a telemetry event
12678
+ */
12679
+ recordEvent(event) {
12680
+ if (!this.enabled) return;
12681
+ const _a3 = event, { licenseKey } = _a3, safeEvent = __objRest(_a3, ["licenseKey"]);
12682
+ const completeEvent = __spreadValues({
12683
+ eventType: event.eventType || "error_occurred" /* ERROR_OCCURRED */,
12684
+ projectId: this.projectId,
12685
+ timestamp: event.timestamp || Date.now()
12686
+ }, safeEvent);
12687
+ this.eventQueue.push(completeEvent);
12688
+ if (this.eventQueue.length >= this.batchSize) {
12689
+ this.flush().catch((err) => {
12690
+ console.warn("[TelemetryService] Flush error:", err.message);
12691
+ });
12692
+ }
12693
+ }
12694
+ /**
12695
+ * Record LLM completion event
12696
+ */
12697
+ recordLLMCompletion(data) {
12698
+ this.recordEvent({
12699
+ eventType: "llm_chat_completion" /* LLM_CHAT_COMPLETION */,
12700
+ model: data.model,
12701
+ inputTokens: data.inputTokens,
12702
+ outputTokens: data.outputTokens,
12703
+ totalTokens: data.inputTokens + data.outputTokens,
12704
+ durationMs: data.durationMs,
12705
+ operationId: data.operationId,
12706
+ metadata: data.metadata
12707
+ });
12708
+ }
12709
+ /**
12710
+ * Record embedding generation event
12711
+ */
12712
+ recordEmbeddingGenerated(data) {
12713
+ this.recordEvent({
12714
+ eventType: "embedding_generated" /* EMBEDDING_GENERATED */,
12715
+ embeddingModel: data.embeddingModel,
12716
+ vectorDimensions: data.vectorDimensions,
12717
+ textLength: data.textLength,
12718
+ durationMs: data.durationMs,
12719
+ operationId: data.operationId
12720
+ });
12721
+ }
12722
+ /**
12723
+ * Record document ingestion event
12724
+ */
12725
+ recordDocumentIngested(data) {
12726
+ this.recordEvent({
12727
+ eventType: "document_ingested" /* DOCUMENT_INGESTED */,
12728
+ documentId: data.documentId,
12729
+ documentName: data.documentName,
12730
+ documentSize: data.documentSize,
12731
+ chunksGenerated: data.chunksGenerated,
12732
+ durationMs: data.durationMs
12733
+ });
12734
+ }
12735
+ /**
12736
+ * Record query execution event
12737
+ */
12738
+ recordQueryExecuted(data) {
12739
+ this.recordEvent({
12740
+ eventType: "query_executed" /* QUERY_EXECUTED */,
12741
+ queryText: data.queryText,
12742
+ resultCount: data.resultCount,
12743
+ durationMs: data.durationMs,
12744
+ operationId: data.operationId
12745
+ });
12746
+ }
12747
+ /**
12748
+ * Record error event
12749
+ */
12750
+ recordError(error, context) {
12751
+ this.recordEvent({
12752
+ eventType: "error_occurred" /* ERROR_OCCURRED */,
12753
+ errorCode: error.code || "UNKNOWN",
12754
+ errorMessage: error.message,
12755
+ stackTrace: error.stack,
12756
+ metadata: context
12757
+ });
12758
+ }
12759
+ /**
12760
+ * Flush all queued events to telemetry endpoints
12761
+ */
12762
+ async flush() {
12763
+ if (this.eventQueue.length === 0) return;
12764
+ const events = this.eventQueue.splice(0, this.batchSize);
12765
+ const payload = {
12766
+ events: events.map((e) => {
12767
+ const eventWithoutKey = __objRest(e, []);
12768
+ return eventWithoutKey;
12769
+ }),
12770
+ batchId: `${this.projectId}_${Date.now()}`
12771
+ };
12772
+ try {
12773
+ await this.http.post(_TelemetryService.RETRIVORA_TELEMETRY_URL, payload);
12774
+ console.log(`[TelemetryService] Flushed ${events.length} events to Retrivora`);
12775
+ } catch (err) {
12776
+ console.warn("[TelemetryService] Failed to send telemetry to Retrivora:", err.message);
12777
+ this.eventQueue.unshift(...events);
12778
+ }
12779
+ if (this.userTelemetryUrl) {
12780
+ try {
12781
+ await axios10.post(this.userTelemetryUrl, payload, {
12782
+ timeout: 5e3,
12783
+ headers: {
12784
+ "Content-Type": "application/json",
12785
+ "X-Project-ID": this.projectId
12786
+ }
12787
+ });
12788
+ console.log(`[TelemetryService] Flushed ${events.length} events to user telemetry`);
12789
+ } catch (err) {
12790
+ console.warn("[TelemetryService] Failed to send telemetry to user endpoint:", err.message);
12791
+ }
12792
+ }
12793
+ }
12794
+ /**
12795
+ * Start automatic flush interval
12796
+ */
12797
+ startAutoFlush() {
12798
+ this.flushTimer = setInterval(() => {
12799
+ this.flush().catch((err) => {
12800
+ console.warn("[TelemetryService] Auto-flush error:", err.message);
12801
+ });
12802
+ }, this.flushIntervalMs);
12803
+ }
12804
+ /**
12805
+ * Stop telemetry service and flush remaining events
12806
+ */
12807
+ async shutdown() {
12808
+ if (this.flushTimer) {
12809
+ clearInterval(this.flushTimer);
12810
+ }
12811
+ await this.flush();
12812
+ this.enabled = false;
12813
+ }
12814
+ /**
12815
+ * Disable telemetry temporarily
12816
+ */
12817
+ disable() {
12818
+ this.enabled = false;
12819
+ }
12820
+ /**
12821
+ * Enable telemetry
12822
+ */
12823
+ enable() {
12824
+ this.enabled = true;
12825
+ }
12826
+ /**
12827
+ * Get current queue size (for debugging)
12828
+ */
12829
+ getQueueSize() {
12830
+ return this.eventQueue.length;
12831
+ }
12832
+ };
12833
+ _TelemetryService.RETRIVORA_TELEMETRY_URL = "https://www.retrivora.com/api/telemetry";
12834
+ _TelemetryService.USER_TELEMETRY_URL_ENV_KEY = "TELEMETRY_URL";
12835
+ var TelemetryService = _TelemetryService;
12836
+ var globalTelemetryService = null;
12837
+ function getTelemetryService() {
12838
+ return globalTelemetryService;
12839
+ }
12840
+ function initializeTelemetryService(projectId, licenseKey, userTelemetryUrl) {
12841
+ globalTelemetryService = new TelemetryService(projectId, licenseKey, userTelemetryUrl);
12842
+ console.log("[TelemetryService] Initialized for project:", projectId);
12843
+ return globalTelemetryService;
12844
+ }
12845
+ async function shutdownTelemetryService() {
12846
+ if (globalTelemetryService) {
12847
+ await globalTelemetryService.shutdown();
12848
+ globalTelemetryService = null;
12849
+ }
12850
+ }
12851
+
12852
+ // src/LicensedRetrivora.ts
12853
+ var LicensedRetrivora = class {
12854
+ constructor(options) {
12855
+ this.initialized = false;
12856
+ this.licenseKey = options.licenseKey;
12857
+ this.projectId = options.projectId;
12858
+ if (options.enableTelemetry !== false) {
12859
+ initializeTelemetryService(this.projectId, this.licenseKey, options.userTelemetryUrl);
12860
+ }
12861
+ }
12862
+ /**
12863
+ * Initialize the SDK by validating license and fetching config
12864
+ */
12865
+ generateId() {
12866
+ return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
12867
+ }
12868
+ /**
12869
+ * Initialize the SDK by validating license and fetching config
12870
+ */
12871
+ async initialize() {
12872
+ if (this.initialized) {
12873
+ console.log("[LicensedRetrivora] Already initialized");
12874
+ return;
12875
+ }
12876
+ console.log("[LicensedRetrivora] Initializing with license key...");
12877
+ const operationId = this.generateId();
12878
+ try {
12879
+ const { llmConfig, embeddingConfig, vectorDbConfig, tierConfig } = await LicenseConfigResolver.resolveFromLicense(this.licenseKey, this.projectId);
12880
+ const telemetry = getTelemetryService();
12881
+ if (telemetry) {
12882
+ telemetry.recordEvent({
12883
+ eventType: "configuration_loaded" /* CONFIGURATION_LOADED */,
12884
+ operationId,
12885
+ metadata: {
12886
+ tier: tierConfig.tier,
12887
+ llmModel: tierConfig.llmModel,
12888
+ embeddingModel: tierConfig.embeddingModel,
12889
+ vectorDb: tierConfig.vectorDb.provider
12890
+ }
12891
+ });
12892
+ }
12893
+ this.ragConfig = {
12894
+ projectId: this.projectId,
12895
+ licenseKey: this.licenseKey,
12896
+ llm: llmConfig,
12897
+ embedding: embeddingConfig,
12898
+ vectorDb: vectorDbConfig,
12899
+ rag: {
12900
+ topK: tierConfig.topK,
12901
+ chunkSize: tierConfig.chunkSize,
12902
+ chunkOverlap: tierConfig.chunkOverlap,
12903
+ scoreThreshold: 0
12904
+ },
12905
+ telemetry: {
12906
+ enabled: true,
12907
+ url: "https://www.retrivora.com/api/telemetry"
12908
+ }
12909
+ };
12910
+ this.pipeline = new Pipeline(this.ragConfig);
12911
+ await this.pipeline.initialize();
12912
+ this.initialized = true;
12913
+ console.log(`[LicensedRetrivora] Initialized successfully for tier: ${tierConfig.tier}`);
12914
+ } catch (error) {
12915
+ const telemetry = getTelemetryService();
12916
+ if (telemetry && error instanceof Error) {
12917
+ telemetry.recordError(error, { operationId });
12918
+ await telemetry.flush();
12919
+ }
12920
+ throw error;
12921
+ }
12922
+ }
12923
+ /**
12924
+ * Ingest documents (upload files to vector database)
12925
+ * Returns success/failure status to end-user
12926
+ */
12927
+ async ingest(documents) {
12928
+ if (!this.initialized || !this.pipeline) {
12929
+ throw new Error("[LicensedRetrivora] SDK not initialized. Call initialize() first.");
12930
+ }
12931
+ const operationId = this.generateId();
12932
+ const telemetry = getTelemetryService();
12933
+ const startTime = Date.now();
12934
+ try {
12935
+ console.log(`[LicensedRetrivora] Starting ingestion of ${documents.length} document(s)`);
12936
+ const results = await this.pipeline.ingest(documents);
12937
+ const durationMs = Date.now() - startTime;
12938
+ if (telemetry) {
12939
+ for (const result of results) {
12940
+ telemetry.recordDocumentIngested({
12941
+ documentId: String(result.docId),
12942
+ documentName: String(result.docId),
12943
+ documentSize: 0,
12944
+ // TODO: track actual size
12945
+ chunksGenerated: result.chunksIngested,
12946
+ durationMs
12947
+ });
12948
+ }
12949
+ }
12950
+ const successCount = results.length;
12951
+ return {
12952
+ success: successCount > 0,
12953
+ message: `Successfully ingested ${successCount} document(s). Data is now available for search.`,
12954
+ documentIds: results.map((r) => String(r.docId))
12955
+ };
12956
+ } catch (error) {
12957
+ const durationMs = Date.now() - startTime;
12958
+ if (telemetry && error instanceof Error) {
12959
+ telemetry.recordError(error, { operationId, durationMs });
12960
+ await telemetry.flush();
12961
+ }
12962
+ console.error("[LicensedRetrivora] Ingestion failed:", error);
12963
+ throw error;
12964
+ }
12965
+ }
12966
+ /**
12967
+ * Execute a user query and get response
12968
+ * Returns only the response text and sources (abstracted from underlying models)
12969
+ */
12970
+ async query(queryText, options) {
12971
+ var _a3;
12972
+ if (!this.initialized || !this.pipeline) {
12973
+ throw new Error("[LicensedRetrivora] SDK not initialized. Call initialize() first.");
12974
+ }
12975
+ const operationId = this.generateId();
12976
+ const telemetry = getTelemetryService();
12977
+ const startTime = Date.now();
12978
+ try {
12979
+ console.log(`[LicensedRetrivora] Executing query: "${queryText.substring(0, 100)}..."`);
12980
+ const response = await this.pipeline.runNormalQuery(queryText);
12981
+ const durationMs = Date.now() - startTime;
12982
+ if (telemetry) {
12983
+ telemetry.recordQueryExecuted({
12984
+ queryText,
12985
+ resultCount: ((_a3 = response.sources) == null ? void 0 : _a3.length) || 0,
12986
+ durationMs,
12987
+ operationId
12988
+ });
12989
+ }
12990
+ return {
12991
+ reply: response.reply,
12992
+ sources: response.sources
12993
+ };
12994
+ } catch (error) {
12995
+ const durationMs = Date.now() - startTime;
12996
+ if (telemetry && error instanceof Error) {
12997
+ telemetry.recordError(error, { operationId, durationMs });
12998
+ await telemetry.flush();
12999
+ }
13000
+ console.error("[LicensedRetrivora] Query failed:", error);
13001
+ throw error;
13002
+ }
13003
+ }
13004
+ /**
13005
+ * Get license tier information (for UI display if needed)
13006
+ */
13007
+ async getTierInfo() {
13008
+ if (!this.ragConfig) {
13009
+ throw new Error("[LicensedRetrivora] SDK not initialized.");
13010
+ }
13011
+ return {
13012
+ tier: "Standard",
13013
+ // TODO: fetch from tier config
13014
+ model: this.ragConfig.llm.model,
13015
+ embeddingModel: this.ragConfig.embedding.model
13016
+ };
13017
+ }
13018
+ /**
13019
+ * Cleanup and shutdown
13020
+ */
13021
+ async shutdown() {
13022
+ await shutdownTelemetryService();
13023
+ this.initialized = false;
13024
+ console.log("[LicensedRetrivora] Shutdown complete");
13025
+ }
13026
+ /**
13027
+ * Check if SDK is initialized
13028
+ */
13029
+ isInitialized() {
13030
+ return this.initialized;
13031
+ }
13032
+ /**
13033
+ * Get current RAG configuration (for debugging)
13034
+ */
13035
+ getConfig() {
13036
+ return this.ragConfig;
13037
+ }
13038
+ };
13039
+ async function createRetrivora(options) {
13040
+ const retrivora = new LicensedRetrivora(options);
13041
+ await retrivora.initialize();
13042
+ return retrivora;
13043
+ }
12285
13044
  export {
12286
13045
  AnthropicProvider,
12287
13046
  AuthenticationException,
@@ -12300,13 +13059,16 @@ export {
12300
13059
  EmbeddingFailedException,
12301
13060
  EmbeddingStrategy,
12302
13061
  EmbeddingStrategyResolver,
13062
+ EventType,
12303
13063
  GroqProvider,
12304
13064
  IntentClassifier,
12305
13065
  LLMFactory,
12306
13066
  LLM_PROFILES,
13067
+ LicenseConfigResolver,
12307
13068
  LicenseValidationError,
12308
13069
  LicenseValidator,
12309
13070
  LicenseVerifier,
13071
+ LicensedRetrivora,
12310
13072
  MilvusProvider,
12311
13073
  MixedRendererStrategy,
12312
13074
  MongoDBProvider,
@@ -12339,6 +13101,7 @@ export {
12339
13101
  SDKVersionUnsupportedError,
12340
13102
  SDK_VERSION,
12341
13103
  TableRendererStrategy,
13104
+ TelemetryService,
12342
13105
  TextRendererStrategy,
12343
13106
  UniversalLLMAdapter,
12344
13107
  UniversalVectorProvider,
@@ -12354,13 +13117,19 @@ export {
12354
13117
  createHistoryHandler,
12355
13118
  createIngestHandler,
12356
13119
  createRagHandler,
13120
+ createRetrivora,
12357
13121
  createSessionsHandler,
12358
13122
  createStreamHandler,
12359
13123
  createUploadHandler,
12360
13124
  decideVisualization,
12361
13125
  getRagConfig,
13126
+ getRuntimeConfig,
13127
+ getTelemetryService,
13128
+ initializeTelemetryService,
13129
+ injectRuntimeConfig,
12362
13130
  normalizeProjectSettings,
12363
13131
  projectSettingsToUiConfig,
13132
+ shutdownTelemetryService,
12364
13133
  sseErrorFrame,
12365
13134
  sseFrame,
12366
13135
  sseMetaFrame,