@retrivora-ai/rag-engine 2.5.4 → 2.5.6

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.
@@ -312,7 +312,7 @@ var init_package = __esm({
312
312
  "package.json"() {
313
313
  package_default = {
314
314
  name: "@retrivora-ai/rag-engine",
315
- version: "2.5.4",
315
+ version: "2.5.6",
316
316
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
317
317
  author: "Abhinav Alkuchi",
318
318
  license: "UNLICENSED",
@@ -505,13 +505,27 @@ var init_ConfigFetcher = __esm({
505
505
  * PINECONE_API_KEY if available, or vector operations are handled server-side.
506
506
  */
507
507
  static async fetchRemoteConfig(projectId, licenseKey) {
508
- var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
509
508
  const cacheKey = `${projectId}:${licenseKey || ""}`;
510
509
  const now = Date.now();
511
510
  const cached = this.cache.get(cacheKey);
512
511
  if (cached && now - cached.cachedAt < this.TTL_MS) {
513
512
  return cached.config;
514
513
  }
514
+ const existingInflight = this.inflight.get(cacheKey);
515
+ if (existingInflight) {
516
+ return existingInflight;
517
+ }
518
+ const promise = this._doFetch(projectId, licenseKey, cacheKey, now);
519
+ this.inflight.set(cacheKey, promise);
520
+ try {
521
+ return await promise;
522
+ } finally {
523
+ this.inflight.delete(cacheKey);
524
+ }
525
+ }
526
+ /** Internal: performs the actual HTTP fetch. Shared by all callers via inflight dedup. */
527
+ static async _doFetch(projectId, licenseKey, cacheKey, now) {
528
+ var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
515
529
  const controlPlaneUrls = [
516
530
  process.env.RETRIVORA_CONTROL_PLANE_URL,
517
531
  process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
@@ -624,6 +638,8 @@ var init_ConfigFetcher = __esm({
624
638
  }
625
639
  };
626
640
  ConfigFetcher.cache = /* @__PURE__ */ new Map();
641
+ /** In-flight deduplication: concurrent callers for the same key share one network request */
642
+ ConfigFetcher.inflight = /* @__PURE__ */ new Map();
627
643
  ConfigFetcher.TTL_MS = 5 * 60 * 1e3;
628
644
  }
629
645
  });
@@ -1740,7 +1756,7 @@ var MilvusProvider_exports = {};
1740
1756
  __export(MilvusProvider_exports, {
1741
1757
  MilvusProvider: () => MilvusProvider
1742
1758
  });
1743
- import axios3 from "axios";
1759
+ import axios4 from "axios";
1744
1760
  var MilvusProvider;
1745
1761
  var init_MilvusProvider = __esm({
1746
1762
  "src/providers/vectordb/MilvusProvider.ts"() {
@@ -1752,7 +1768,7 @@ var init_MilvusProvider = __esm({
1752
1768
  const opts = config.options;
1753
1769
  const baseUrl = opts.baseUrl || opts.uri || (opts.host ? `http://${opts.host}:${opts.port || 19530}` : void 0);
1754
1770
  if (!baseUrl) throw new Error("[MilvusProvider] options.baseUrl (or uri / host+port) is required");
1755
- this.http = axios3.create({
1771
+ this.http = axios4.create({
1756
1772
  baseURL: baseUrl,
1757
1773
  headers: __spreadValues(__spreadValues({
1758
1774
  "Content-Type": "application/json"
@@ -1853,7 +1869,7 @@ var QdrantProvider_exports = {};
1853
1869
  __export(QdrantProvider_exports, {
1854
1870
  QdrantProvider: () => QdrantProvider
1855
1871
  });
1856
- import axios4 from "axios";
1872
+ import axios5 from "axios";
1857
1873
  import crypto from "crypto";
1858
1874
  var QdrantProvider;
1859
1875
  var init_QdrantProvider = __esm({
@@ -1870,7 +1886,7 @@ var init_QdrantProvider = __esm({
1870
1886
  this.contentField = opts.contentField || "content";
1871
1887
  this.metadataField = opts.metadataField || "metadata";
1872
1888
  this.isFlatPayload = !!opts.flatPayload;
1873
- this.http = axios4.create({
1889
+ this.http = axios5.create({
1874
1890
  baseURL: baseUrl,
1875
1891
  timeout: 15e3,
1876
1892
  // 15s timeout for vector DB operations
@@ -1938,7 +1954,7 @@ var init_QdrantProvider = __esm({
1938
1954
  try {
1939
1955
  await this.http.get(`/collections/${this.indexName}`);
1940
1956
  } catch (err) {
1941
- if (axios4.isAxiosError(err) && ((_a2 = err.response) == null ? void 0 : _a2.status) === 404) {
1957
+ if (axios5.isAxiosError(err) && ((_a2 = err.response) == null ? void 0 : _a2.status) === 404) {
1942
1958
  const opts = this.config.options;
1943
1959
  const dimensionsForCreate = opts.dimensions || 1536;
1944
1960
  await this.http.put(`/collections/${this.indexName}`, {
@@ -1968,7 +1984,7 @@ var init_QdrantProvider = __esm({
1968
1984
  });
1969
1985
  } catch (err) {
1970
1986
  let status;
1971
- if (axios4.isAxiosError(err)) status = (_a2 = err.response) == null ? void 0 : _a2.status;
1987
+ if (axios5.isAxiosError(err)) status = (_a2 = err.response) == null ? void 0 : _a2.status;
1972
1988
  if (status === 409) return;
1973
1989
  console.warn(`[QdrantProvider] \u26A0\uFE0F Could not ensure index for "${fullPath}":`, err instanceof Error ? err.message : String(err));
1974
1990
  }
@@ -2092,7 +2108,7 @@ var ChromaDBProvider_exports = {};
2092
2108
  __export(ChromaDBProvider_exports, {
2093
2109
  ChromaDBProvider: () => ChromaDBProvider
2094
2110
  });
2095
- import axios5 from "axios";
2111
+ import axios6 from "axios";
2096
2112
  var ChromaDBProvider;
2097
2113
  var init_ChromaDBProvider = __esm({
2098
2114
  "src/providers/vectordb/ChromaDBProvider.ts"() {
@@ -2105,7 +2121,7 @@ var init_ChromaDBProvider = __esm({
2105
2121
  const opts = config.options;
2106
2122
  const baseUrl = opts.baseUrl || (opts.host ? `http://${opts.host}:${opts.port || 8e3}` : void 0);
2107
2123
  if (!baseUrl) throw new Error("[ChromaDBProvider] options.baseUrl is required");
2108
- this.http = axios5.create({
2124
+ this.http = axios6.create({
2109
2125
  baseURL: baseUrl,
2110
2126
  headers: { "Content-Type": "application/json" }
2111
2127
  });
@@ -2119,7 +2135,7 @@ var init_ChromaDBProvider = __esm({
2119
2135
  const { data } = await this.http.get(`/api/v1/collections/${this.indexName}`);
2120
2136
  this.collectionId = data.id;
2121
2137
  } catch (err) {
2122
- if (axios5.isAxiosError(err) && ((_a2 = err.response) == null ? void 0 : _a2.status) === 404) {
2138
+ if (axios6.isAxiosError(err) && ((_a2 = err.response) == null ? void 0 : _a2.status) === 404) {
2123
2139
  const { data } = await this.http.post("/api/v1/collections", {
2124
2140
  name: this.indexName
2125
2141
  });
@@ -2200,7 +2216,7 @@ var RedisProvider_exports = {};
2200
2216
  __export(RedisProvider_exports, {
2201
2217
  RedisProvider: () => RedisProvider
2202
2218
  });
2203
- import axios6 from "axios";
2219
+ import axios7 from "axios";
2204
2220
  var RedisProvider;
2205
2221
  var init_RedisProvider = __esm({
2206
2222
  "src/providers/vectordb/RedisProvider.ts"() {
@@ -2212,7 +2228,7 @@ var init_RedisProvider = __esm({
2212
2228
  const opts = config.options;
2213
2229
  const baseUrl = opts.baseUrl || opts.url || (opts.host ? `http://${opts.host}:${opts.port || 6379}` : void 0);
2214
2230
  if (!baseUrl) throw new Error("[RedisProvider] options.baseUrl is required");
2215
- this.http = axios6.create({
2231
+ this.http = axios7.create({
2216
2232
  baseURL: baseUrl,
2217
2233
  headers: __spreadValues({
2218
2234
  "Content-Type": "application/json"
@@ -2282,7 +2298,7 @@ var WeaviateProvider_exports = {};
2282
2298
  __export(WeaviateProvider_exports, {
2283
2299
  WeaviateProvider: () => WeaviateProvider
2284
2300
  });
2285
- import axios7 from "axios";
2301
+ import axios8 from "axios";
2286
2302
  var WeaviateProvider;
2287
2303
  var init_WeaviateProvider = __esm({
2288
2304
  "src/providers/vectordb/WeaviateProvider.ts"() {
@@ -2294,7 +2310,7 @@ var init_WeaviateProvider = __esm({
2294
2310
  const opts = config.options;
2295
2311
  const baseUrl = opts.baseUrl || opts.url;
2296
2312
  if (!baseUrl) throw new Error("[WeaviateProvider] options.baseUrl is required");
2297
- this.http = axios7.create({
2313
+ this.http = axios8.create({
2298
2314
  baseURL: baseUrl,
2299
2315
  headers: __spreadValues(__spreadValues({
2300
2316
  "Content-Type": "application/json"
@@ -2434,7 +2450,7 @@ var UniversalVectorProvider_exports = {};
2434
2450
  __export(UniversalVectorProvider_exports, {
2435
2451
  UniversalVectorProvider: () => UniversalVectorProvider
2436
2452
  });
2437
- import axios8 from "axios";
2453
+ import axios9 from "axios";
2438
2454
  var UniversalVectorProvider;
2439
2455
  var init_UniversalVectorProvider = __esm({
2440
2456
  "src/providers/vectordb/UniversalVectorProvider.ts"() {
@@ -2451,7 +2467,7 @@ var init_UniversalVectorProvider = __esm({
2451
2467
  }
2452
2468
  async initialize() {
2453
2469
  var _a2;
2454
- this.http = axios8.create({
2470
+ this.http = axios9.create({
2455
2471
  baseURL: this.opts.baseUrl,
2456
2472
  headers: __spreadValues({
2457
2473
  "Content-Type": "application/json"
@@ -3024,7 +3040,9 @@ var LLM_PROVIDERS = [
3024
3040
  "qwen",
3025
3041
  "rest",
3026
3042
  "universal_rest",
3027
- "custom"
3043
+ "custom",
3044
+ "custom_embedding",
3045
+ "local_embedding"
3028
3046
  ];
3029
3047
  var EMBEDDING_PROVIDERS = [
3030
3048
  "openai",
@@ -3033,7 +3051,9 @@ var EMBEDDING_PROVIDERS = [
3033
3051
  "qwen",
3034
3052
  "rest",
3035
3053
  "universal_rest",
3036
- "custom"
3054
+ "custom",
3055
+ "custom_embedding",
3056
+ "local_embedding"
3037
3057
  ];
3038
3058
  var PROVIDERS_WITH_EMBEDDINGS = [
3039
3059
  "openai",
@@ -3041,7 +3061,10 @@ var PROVIDERS_WITH_EMBEDDINGS = [
3041
3061
  "gemini",
3042
3062
  "qwen",
3043
3063
  "rest",
3044
- "universal_rest"
3064
+ "universal_rest",
3065
+ "custom",
3066
+ "custom_embedding",
3067
+ "local_embedding"
3045
3068
  ];
3046
3069
 
3047
3070
  // src/config/serverConfig.ts
@@ -3778,8 +3801,8 @@ var OllamaProvider = class {
3778
3801
  const baseUrl = config.baseUrl || "http://localhost:11434";
3779
3802
  const modelName = config.model;
3780
3803
  try {
3781
- const axios9 = (await import("axios")).default;
3782
- const { data } = await axios9.get(`${baseUrl}/api/tags`);
3804
+ const axios10 = (await import("axios")).default;
3805
+ const { data } = await axios10.get(`${baseUrl}/api/tags`);
3783
3806
  const models = data.models || [];
3784
3807
  const hasModel = models.some((m) => m.name === modelName || m.name.startsWith(`${modelName}:`));
3785
3808
  return {
@@ -4857,6 +4880,158 @@ ${context != null ? context : "None"}` },
4857
4880
  }
4858
4881
  };
4859
4882
 
4883
+ // src/llm/providers/CustomEmbeddingProvider.ts
4884
+ init_templateUtils();
4885
+ import axios3 from "axios";
4886
+ var CustomEmbeddingProvider = class {
4887
+ constructor(config) {
4888
+ var _a2, _b;
4889
+ this.model = config.model || "custom-embedding-model";
4890
+ this.apiKey = config.apiKey;
4891
+ const options = (_a2 = config.options) != null ? _a2 : {};
4892
+ this.opts = {
4893
+ baseUrl: config.baseUrl || options.baseUrl,
4894
+ embedPath: options.embedPath || "/embeddings",
4895
+ pingPath: options.pingPath || "/health",
4896
+ queryPrefix: options.queryPrefix || "",
4897
+ documentPrefix: options.documentPrefix || "",
4898
+ embedPayloadTemplate: options.embedPayloadTemplate,
4899
+ embedExtractPath: options.embedExtractPath,
4900
+ headers: options.headers || {},
4901
+ timeout: options.timeout || 3e4
4902
+ };
4903
+ this.baseUrl = (_b = this.opts.baseUrl) != null ? _b : "";
4904
+ if (!this.baseUrl) {
4905
+ throw new Error("[CustomEmbeddingProvider] baseUrl is required in config or config.options");
4906
+ }
4907
+ const headers = __spreadValues(__spreadValues({
4908
+ "Content-Type": "application/json"
4909
+ }, this.apiKey ? { Authorization: `Bearer ${this.apiKey}` } : {}), this.opts.headers || {});
4910
+ this.http = axios3.create({
4911
+ baseURL: this.baseUrl.replace(/\/$/, ""),
4912
+ headers,
4913
+ timeout: this.opts.timeout
4914
+ });
4915
+ }
4916
+ /**
4917
+ * Dummy chat implementation. CustomEmbeddingProvider is dedicated to embedding generation.
4918
+ */
4919
+ async chat(_messages, _context, _options) {
4920
+ throw new Error("[CustomEmbeddingProvider] chat() is not supported on a dedicated embedding provider.");
4921
+ }
4922
+ /**
4923
+ * Generate vector embedding for a single string.
4924
+ */
4925
+ async embed(text, options) {
4926
+ var _a2;
4927
+ const taskType = (_a2 = options == null ? void 0 : options.taskType) != null ? _a2 : "document";
4928
+ const prefix = taskType === "query" ? this.opts.queryPrefix : this.opts.documentPrefix;
4929
+ const formattedText = prefix ? `${prefix}${text}` : text;
4930
+ const modelToUse = (options == null ? void 0 : options.model) || this.model;
4931
+ const path2 = this.opts.embedPath || "/embeddings";
4932
+ let payload;
4933
+ if (this.opts.embedPayloadTemplate) {
4934
+ payload = buildPayload(this.opts.embedPayloadTemplate, {
4935
+ input: formattedText,
4936
+ model: modelToUse
4937
+ });
4938
+ } else {
4939
+ payload = {
4940
+ model: modelToUse,
4941
+ input: formattedText
4942
+ };
4943
+ }
4944
+ try {
4945
+ const { data } = await this.http.post(path2, payload);
4946
+ const vector = this.extractVector(data);
4947
+ if (vector) return vector;
4948
+ throw new Error(`[CustomEmbeddingProvider] Failed to extract embedding vector from response at ${path2}`);
4949
+ } catch (err) {
4950
+ console.error("[CustomEmbeddingProvider] Embedding request failed:", {
4951
+ baseUrl: this.baseUrl,
4952
+ path: path2,
4953
+ model: modelToUse,
4954
+ error: (err == null ? void 0 : err.message) || err
4955
+ });
4956
+ throw err;
4957
+ }
4958
+ }
4959
+ /**
4960
+ * Batch embedding generation for multiple texts.
4961
+ */
4962
+ async batchEmbed(texts, options) {
4963
+ var _a2;
4964
+ if (!Array.isArray(texts) || texts.length === 0) return [];
4965
+ const taskType = (_a2 = options == null ? void 0 : options.taskType) != null ? _a2 : "document";
4966
+ const prefix = taskType === "query" ? this.opts.queryPrefix : this.opts.documentPrefix;
4967
+ const formattedTexts = prefix ? texts.map((t) => `${prefix}${t}`) : texts;
4968
+ const modelToUse = (options == null ? void 0 : options.model) || this.model;
4969
+ const path2 = this.opts.embedPath || "/embeddings";
4970
+ if (!this.opts.embedPayloadTemplate) {
4971
+ try {
4972
+ const payload = {
4973
+ model: modelToUse,
4974
+ input: formattedTexts
4975
+ };
4976
+ const { data } = await this.http.post(path2, payload);
4977
+ const batchVectors = this.extractBatchVectors(data);
4978
+ if (batchVectors && batchVectors.length === texts.length) {
4979
+ return batchVectors;
4980
+ }
4981
+ } catch (e) {
4982
+ }
4983
+ }
4984
+ return Promise.all(texts.map((text) => this.embed(text, options)));
4985
+ }
4986
+ /**
4987
+ * Ping provider endpoint for health check.
4988
+ */
4989
+ async ping() {
4990
+ try {
4991
+ const pingPath = this.opts.pingPath || "/health";
4992
+ const res = await this.http.get(pingPath);
4993
+ return res.status >= 200 && res.status < 300;
4994
+ } catch (e) {
4995
+ try {
4996
+ const embedPath = this.opts.embedPath || "/embeddings";
4997
+ await this.http.post(embedPath, { input: "ping", model: this.model });
4998
+ return true;
4999
+ } catch (e2) {
5000
+ return false;
5001
+ }
5002
+ }
5003
+ }
5004
+ extractVector(data) {
5005
+ if (!data) return void 0;
5006
+ if (this.opts.embedExtractPath) {
5007
+ const extracted = resolvePath(data, this.opts.embedExtractPath);
5008
+ if (Array.isArray(extracted) && typeof extracted[0] === "number") {
5009
+ return extracted;
5010
+ }
5011
+ }
5012
+ const directVector = resolvePath(data, "data[0].embedding") || resolvePath(data, "embedding") || resolvePath(data, "embeddings[0]") || resolvePath(data, "data[0].vector") || resolvePath(data, "vector");
5013
+ if (Array.isArray(directVector) && typeof directVector[0] === "number") {
5014
+ return directVector;
5015
+ }
5016
+ if (Array.isArray(data) && typeof data[0] === "number") {
5017
+ return data;
5018
+ }
5019
+ return void 0;
5020
+ }
5021
+ extractBatchVectors(data) {
5022
+ if (!data) return void 0;
5023
+ if (typeof data === "object" && data !== null && Array.isArray(data.data)) {
5024
+ const list = data.data;
5025
+ const vectors = list.map((item) => (item == null ? void 0 : item.embedding) || (item == null ? void 0 : item.vector)).filter((v) => Array.isArray(v));
5026
+ if (vectors.length > 0) return vectors;
5027
+ }
5028
+ if (Array.isArray(data) && Array.isArray(data[0]) && typeof data[0][0] === "number") {
5029
+ return data;
5030
+ }
5031
+ return void 0;
5032
+ }
5033
+ };
5034
+
4860
5035
  // src/llm/LLMFactory.ts
4861
5036
  var customProviders = /* @__PURE__ */ new Map();
4862
5037
  var LLMFactory = class _LLMFactory {
@@ -4899,6 +5074,8 @@ var LLMFactory = class _LLMFactory {
4899
5074
  "rest",
4900
5075
  "universal_rest",
4901
5076
  "custom",
5077
+ "custom_embedding",
5078
+ "local_embedding",
4902
5079
  ...Array.from(customProviders.keys())
4903
5080
  ];
4904
5081
  }
@@ -4917,6 +5094,9 @@ var LLMFactory = class _LLMFactory {
4917
5094
  return new GroqProvider(llmConfig, embeddingConfig);
4918
5095
  case "qwen":
4919
5096
  return new QwenProvider(llmConfig, embeddingConfig);
5097
+ case "custom_embedding":
5098
+ case "local_embedding":
5099
+ return new CustomEmbeddingProvider(llmConfig);
4920
5100
  case "rest":
4921
5101
  case "universal_rest":
4922
5102
  case "custom":
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, MouseEvent, ReactNode, ElementType } from 'react';
2
- import { W as WidgetPosition, P as Product, u as UIConfig, c as ProjectChatSettings, q as RagMessage, y as VectorMatch, p as RagConfig, I as ILLMProvider, h as IngestDocument, C as ChatMessage, e as ChatResponse, _ as RetrievalResult, v as UniversalRagConfig, U as UITransformationResponse, L as LLMConfig, f as EmbeddingConfig, V as VectorDBConfig } from './ILLMProvider-DO5gj-e5.mjs';
2
+ import { W as WidgetPosition, P as Product, u as UIConfig, c as ProjectChatSettings, q as RagMessage, y as VectorMatch, p as RagConfig, I as ILLMProvider, h as IngestDocument, C as ChatMessage, e as ChatResponse, _ as RetrievalResult, v as UniversalRagConfig, U as UITransformationResponse, L as LLMConfig, f as EmbeddingConfig, V as VectorDBConfig } from './ILLMProvider-DwFj0h2u.mjs';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -134,7 +134,14 @@ interface ClientConfig {
134
134
  retrivoraApiBase?: string;
135
135
  projectSettings?: ProjectChatSettings;
136
136
  autoLoadProjectSettings?: boolean;
137
+ /** True while validate + /config are still in-flight. ChatWidget shows nothing until false. */
137
138
  isProjectSettingsLoading?: boolean;
139
+ /** True once /validate succeeds. False if license is expired/invalid/revoked. */
140
+ isLicenseValid?: boolean;
141
+ /** True once /config returns 200 and config is populated. False if /config call failed. */
142
+ isConfigLoaded?: boolean;
143
+ /** Human-readable error from the init sequence (license error or config fetch error). */
144
+ initError?: string;
138
145
  }
139
146
  interface ConfigProviderProps {
140
147
  config?: {
@@ -524,6 +531,8 @@ interface RemoteConfig {
524
531
 
525
532
  declare class ConfigFetcher {
526
533
  private static cache;
534
+ /** In-flight deduplication: concurrent callers for the same key share one network request */
535
+ private static inflight;
527
536
  private static readonly TTL_MS;
528
537
  /**
529
538
  * Fetch full project configuration (vectorDb + embedding + llm + workspace) from Retrivora Control Plane.
@@ -539,6 +548,8 @@ declare class ConfigFetcher {
539
548
  * PINECONE_API_KEY if available, or vector operations are handled server-side.
540
549
  */
541
550
  static fetchRemoteConfig(projectId: string, licenseKey?: string): Promise<RemoteConfig | null>;
551
+ /** Internal: performs the actual HTTP fetch. Shared by all callers via inflight dedup. */
552
+ private static _doFetch;
542
553
  /** Convenience: fetch only vector DB config (backwards compat). */
543
554
  static fetchRemoteVectorConfig(projectId: string, licenseKey?: string): Promise<RemoteVectorConfig | null>;
544
555
  }
@@ -680,6 +691,8 @@ interface LicenseValidationResponse {
680
691
  declare class LicenseValidator {
681
692
  private static instance;
682
693
  private cache;
694
+ /** In-flight deduplication: concurrent calls for same key share one network request */
695
+ private inflight;
683
696
  private static readonly SUCCESS_CACHE_TTL_MS;
684
697
  private constructor();
685
698
  /** @returns Singleton instance of the validator (shared cache across all consumers). */
@@ -707,6 +720,8 @@ declare class LicenseValidator {
707
720
  * lock the chat widget.
708
721
  */
709
722
  validate(request: LicenseValidationRequest): Promise<LicenseValidationResponse>;
723
+ /** Performs the actual network request. Called once; result shared by in-flight dedup. */
724
+ private _doNetworkValidate;
710
725
  }
711
726
 
712
727
  /**
@@ -1,5 +1,5 @@
1
1
  import { NextRequest } from 'next/server';
2
- import { p as RagConfig, I as ILLMProvider, C as ChatMessage, e as ChatResponse, h as IngestDocument } from './ILLMProvider-DO5gj-e5.js';
2
+ import { p as RagConfig, I as ILLMProvider, C as ChatMessage, e as ChatResponse, h as IngestDocument } from './ILLMProvider-DwFj0h2u.js';
3
3
 
4
4
  interface ValidationError {
5
5
  field: string;
@@ -1,5 +1,5 @@
1
1
  import { NextRequest } from 'next/server';
2
- import { p as RagConfig, I as ILLMProvider, C as ChatMessage, e as ChatResponse, h as IngestDocument } from './ILLMProvider-DO5gj-e5.mjs';
2
+ import { p as RagConfig, I as ILLMProvider, C as ChatMessage, e as ChatResponse, h as IngestDocument } from './ILLMProvider-DwFj0h2u.mjs';
3
3
 
4
4
  interface ValidationError {
5
5
  field: string;
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, MouseEvent, ReactNode, ElementType } from 'react';
2
- import { W as WidgetPosition, P as Product, u as UIConfig, c as ProjectChatSettings, q as RagMessage, y as VectorMatch, p as RagConfig, I as ILLMProvider, h as IngestDocument, C as ChatMessage, e as ChatResponse, _ as RetrievalResult, v as UniversalRagConfig, U as UITransformationResponse, L as LLMConfig, f as EmbeddingConfig, V as VectorDBConfig } from './ILLMProvider-DO5gj-e5.js';
2
+ import { W as WidgetPosition, P as Product, u as UIConfig, c as ProjectChatSettings, q as RagMessage, y as VectorMatch, p as RagConfig, I as ILLMProvider, h as IngestDocument, C as ChatMessage, e as ChatResponse, _ as RetrievalResult, v as UniversalRagConfig, U as UITransformationResponse, L as LLMConfig, f as EmbeddingConfig, V as VectorDBConfig } from './ILLMProvider-DwFj0h2u.js';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -134,7 +134,14 @@ interface ClientConfig {
134
134
  retrivoraApiBase?: string;
135
135
  projectSettings?: ProjectChatSettings;
136
136
  autoLoadProjectSettings?: boolean;
137
+ /** True while validate + /config are still in-flight. ChatWidget shows nothing until false. */
137
138
  isProjectSettingsLoading?: boolean;
139
+ /** True once /validate succeeds. False if license is expired/invalid/revoked. */
140
+ isLicenseValid?: boolean;
141
+ /** True once /config returns 200 and config is populated. False if /config call failed. */
142
+ isConfigLoaded?: boolean;
143
+ /** Human-readable error from the init sequence (license error or config fetch error). */
144
+ initError?: string;
138
145
  }
139
146
  interface ConfigProviderProps {
140
147
  config?: {
@@ -524,6 +531,8 @@ interface RemoteConfig {
524
531
 
525
532
  declare class ConfigFetcher {
526
533
  private static cache;
534
+ /** In-flight deduplication: concurrent callers for the same key share one network request */
535
+ private static inflight;
527
536
  private static readonly TTL_MS;
528
537
  /**
529
538
  * Fetch full project configuration (vectorDb + embedding + llm + workspace) from Retrivora Control Plane.
@@ -539,6 +548,8 @@ declare class ConfigFetcher {
539
548
  * PINECONE_API_KEY if available, or vector operations are handled server-side.
540
549
  */
541
550
  static fetchRemoteConfig(projectId: string, licenseKey?: string): Promise<RemoteConfig | null>;
551
+ /** Internal: performs the actual HTTP fetch. Shared by all callers via inflight dedup. */
552
+ private static _doFetch;
542
553
  /** Convenience: fetch only vector DB config (backwards compat). */
543
554
  static fetchRemoteVectorConfig(projectId: string, licenseKey?: string): Promise<RemoteVectorConfig | null>;
544
555
  }
@@ -680,6 +691,8 @@ interface LicenseValidationResponse {
680
691
  declare class LicenseValidator {
681
692
  private static instance;
682
693
  private cache;
694
+ /** In-flight deduplication: concurrent calls for same key share one network request */
695
+ private inflight;
683
696
  private static readonly SUCCESS_CACHE_TTL_MS;
684
697
  private constructor();
685
698
  /** @returns Singleton instance of the validator (shared cache across all consumers). */
@@ -707,6 +720,8 @@ declare class LicenseValidator {
707
720
  * lock the chat widget.
708
721
  */
709
722
  validate(request: LicenseValidationRequest): Promise<LicenseValidationResponse>;
723
+ /** Performs the actual network request. Called once; result shared by in-flight dedup. */
724
+ private _doNetworkValidate;
710
725
  }
711
726
 
712
727
  /**