@retrivora-ai/rag-engine 2.1.3 → 2.1.5

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.
@@ -3045,7 +3045,7 @@ function readEnum(env, name, fallback, allowed) {
3045
3045
  throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
3046
3046
  }
3047
3047
  function getEnvConfig(env = process.env, base) {
3048
- var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _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;
3048
+ var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _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;
3049
3049
  const projectId = (_c = (_b = (_a2 = readString(env, "RAG_PROJECT_ID")) != null ? _a2 : readString(env, "NEXT_PUBLIC_PROJECT_ID")) != null ? _b : base == null ? void 0 : base.projectId) != null ? _c : "__default__";
3050
3050
  const licenseKey = (_g2 = (_f = (_e = (_d = readString(env, "RAG_LICENSE_KEY")) != null ? _d : readString(env, "RETRIVORA_LICENSE_KEY")) != null ? _e : readString(env, "NEXT_PUBLIC_RETRIVORA_LICENSE_KEY")) != null ? _f : readString(env, "LICENSE_KEY")) != null ? _g2 : base == null ? void 0 : base.licenseKey;
3051
3051
  const telemetryEnabled = readString(env, "TELEMETRY_ENABLED") === "true" || readString(env, "NEXT_PUBLIC_TELEMETRY_ENABLED") === "true" || ((_h = base == null ? void 0 : base.telemetry) == null ? void 0 : _h.enabled) || Boolean(licenseKey);
@@ -3053,38 +3053,38 @@ function getEnvConfig(env = process.env, base) {
3053
3053
  const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 768);
3054
3054
  const vectorDbOptions = {};
3055
3055
  if (vectorProvider === "pinecone") {
3056
- vectorDbOptions.apiKey = (_l = (_k = readString(env, "PINECONE_API_KEY")) != null ? _k : (_j = (_i = base == null ? void 0 : base.vectorDb) == null ? void 0 : _i.options) == null ? void 0 : _j.apiKey) != null ? _l : "";
3057
- vectorDbOptions.indexName = (_q = (_n = readString(env, "PINECONE_INDEX")) != null ? _n : (_m = base == null ? void 0 : base.vectorDb) == null ? void 0 : _m.indexName) != null ? _q : (_p = (_o = base == null ? void 0 : base.vectorDb) == null ? void 0 : _o.options) == null ? void 0 : _p.indexName;
3056
+ vectorDbOptions.apiKey = (_m = (_l = (_k = readString(env, "PINECONE_API_KEY")) != null ? _k : (_j = (_i = base == null ? void 0 : base.vectorDb) == null ? void 0 : _i.options) == null ? void 0 : _j.apiKey) != null ? _l : process.env.PINECONE_API_KEY) != null ? _m : "";
3057
+ vectorDbOptions.indexName = (_t = (_s = (_r = (_o = readString(env, "PINECONE_INDEX")) != null ? _o : (_n = base == null ? void 0 : base.vectorDb) == null ? void 0 : _n.indexName) != null ? _r : (_q = (_p = base == null ? void 0 : base.vectorDb) == null ? void 0 : _p.options) == null ? void 0 : _q.indexName) != null ? _s : process.env.PINECONE_INDEX) != null ? _t : "retrivora-free";
3058
3058
  } else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
3059
- vectorDbOptions.connectionString = (_v = (_u = (_r = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _r : readString(env, "POSTGRES_URL")) != null ? _u : (_t = (_s = base == null ? void 0 : base.vectorDb) == null ? void 0 : _s.options) == null ? void 0 : _t.connectionString) != null ? _v : "";
3060
- vectorDbOptions.tables = (_A = (_x = (_w = readString(env, "VECTOR_DB_TABLES")) != null ? _w : readString(env, "POSTGRES_TABLES")) == null ? void 0 : _x.split(",").map((t) => t.trim())) != null ? _A : (_z = (_y = base == null ? void 0 : base.vectorDb) == null ? void 0 : _y.options) == null ? void 0 : _z.tables;
3061
- vectorDbOptions.searchFields = (_E = (_B = readString(env, "POSTGRES_SEARCH_FIELDS")) == null ? void 0 : _B.split(",").map((f) => f.trim())) != null ? _E : (_D = (_C = base == null ? void 0 : base.vectorDb) == null ? void 0 : _C.options) == null ? void 0 : _D.searchFields;
3059
+ vectorDbOptions.connectionString = (_y = (_x = (_u = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _u : readString(env, "POSTGRES_URL")) != null ? _x : (_w = (_v = base == null ? void 0 : base.vectorDb) == null ? void 0 : _v.options) == null ? void 0 : _w.connectionString) != null ? _y : "";
3060
+ vectorDbOptions.tables = (_D = (_A = (_z = readString(env, "VECTOR_DB_TABLES")) != null ? _z : readString(env, "POSTGRES_TABLES")) == null ? void 0 : _A.split(",").map((t) => t.trim())) != null ? _D : (_C = (_B = base == null ? void 0 : base.vectorDb) == null ? void 0 : _B.options) == null ? void 0 : _C.tables;
3061
+ vectorDbOptions.searchFields = (_H = (_E = readString(env, "POSTGRES_SEARCH_FIELDS")) == null ? void 0 : _E.split(",").map((f) => f.trim())) != null ? _H : (_G = (_F = base == null ? void 0 : base.vectorDb) == null ? void 0 : _F.options) == null ? void 0 : _G.searchFields;
3062
3062
  vectorDbOptions.dimensions = embeddingDimensions;
3063
3063
  } else if (vectorProvider === "mongodb") {
3064
- vectorDbOptions.uri = (_I = (_H = readString(env, "MONGODB_URI")) != null ? _H : (_G = (_F = base == null ? void 0 : base.vectorDb) == null ? void 0 : _F.options) == null ? void 0 : _G.uri) != null ? _I : "";
3065
- vectorDbOptions.database = (_M = (_L = readString(env, "MONGODB_DB")) != null ? _L : (_K = (_J = base == null ? void 0 : base.vectorDb) == null ? void 0 : _J.options) == null ? void 0 : _K.database) != null ? _M : "";
3066
- vectorDbOptions.collection = (_Q = (_P = readString(env, "MONGODB_COLLECTION")) != null ? _P : (_O = (_N = base == null ? void 0 : base.vectorDb) == null ? void 0 : _N.options) == null ? void 0 : _O.collection) != null ? _Q : "";
3067
- vectorDbOptions.indexName = (_W = (_V = (_S = readString(env, "MONGODB_INDEX_NAME")) != null ? _S : (_R = base == null ? void 0 : base.vectorDb) == null ? void 0 : _R.indexName) != null ? _V : (_U = (_T = base == null ? void 0 : base.vectorDb) == null ? void 0 : _T.options) == null ? void 0 : _U.indexName) != null ? _W : "vector_index";
3064
+ vectorDbOptions.uri = (_L = (_K = readString(env, "MONGODB_URI")) != null ? _K : (_J = (_I = base == null ? void 0 : base.vectorDb) == null ? void 0 : _I.options) == null ? void 0 : _J.uri) != null ? _L : "";
3065
+ vectorDbOptions.database = (_P = (_O = readString(env, "MONGODB_DB")) != null ? _O : (_N = (_M = base == null ? void 0 : base.vectorDb) == null ? void 0 : _M.options) == null ? void 0 : _N.database) != null ? _P : "";
3066
+ vectorDbOptions.collection = (_T = (_S = readString(env, "MONGODB_COLLECTION")) != null ? _S : (_R = (_Q = base == null ? void 0 : base.vectorDb) == null ? void 0 : _Q.options) == null ? void 0 : _R.collection) != null ? _T : "";
3067
+ vectorDbOptions.indexName = (_Z = (_Y = (_V = readString(env, "MONGODB_INDEX_NAME")) != null ? _V : (_U = base == null ? void 0 : base.vectorDb) == null ? void 0 : _U.indexName) != null ? _Y : (_X = (_W = base == null ? void 0 : base.vectorDb) == null ? void 0 : _W.options) == null ? void 0 : _X.indexName) != null ? _Z : "vector_index";
3068
3068
  } else if (vectorProvider === "qdrant") {
3069
- vectorDbOptions.baseUrl = (__ = (_Z = readString(env, "QDRANT_URL")) != null ? _Z : (_Y = (_X = base == null ? void 0 : base.vectorDb) == null ? void 0 : _X.options) == null ? void 0 : _Y.baseUrl) != null ? __ : "http://localhost:6333";
3070
- vectorDbOptions.apiKey = (_ba = readString(env, "QDRANT_API_KEY")) != null ? _ba : (_aa = (_$ = base == null ? void 0 : base.vectorDb) == null ? void 0 : _$.options) == null ? void 0 : _aa.apiKey;
3069
+ vectorDbOptions.baseUrl = (_ba = (_aa = readString(env, "QDRANT_URL")) != null ? _aa : (_$ = (__ = base == null ? void 0 : base.vectorDb) == null ? void 0 : __.options) == null ? void 0 : _$.baseUrl) != null ? _ba : "http://localhost:6333";
3070
+ vectorDbOptions.apiKey = (_ea = readString(env, "QDRANT_API_KEY")) != null ? _ea : (_da = (_ca = base == null ? void 0 : base.vectorDb) == null ? void 0 : _ca.options) == null ? void 0 : _da.apiKey;
3071
3071
  vectorDbOptions.dimensions = embeddingDimensions;
3072
3072
  } else if (vectorProvider === "milvus") {
3073
- vectorDbOptions.baseUrl = (_ca = readString(env, "MILVUS_URL")) != null ? _ca : "http://localhost:19530";
3073
+ vectorDbOptions.baseUrl = (_fa = readString(env, "MILVUS_URL")) != null ? _fa : "http://localhost:19530";
3074
3074
  vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
3075
3075
  } else if (vectorProvider === "chromadb") {
3076
- vectorDbOptions.baseUrl = (_da = readString(env, "CHROMADB_URL")) != null ? _da : "http://localhost:8000";
3076
+ vectorDbOptions.baseUrl = (_ga = readString(env, "CHROMADB_URL")) != null ? _ga : "http://localhost:8000";
3077
3077
  } else if (vectorProvider === "weaviate") {
3078
- vectorDbOptions.baseUrl = (_ea = readString(env, "WEAVIATE_URL")) != null ? _ea : "http://localhost:8080";
3078
+ vectorDbOptions.baseUrl = (_ha = readString(env, "WEAVIATE_URL")) != null ? _ha : "http://localhost:8080";
3079
3079
  vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
3080
3080
  } else if (vectorProvider === "redis") {
3081
- vectorDbOptions.baseUrl = (_fa = readString(env, "REDIS_URL")) != null ? _fa : "";
3081
+ vectorDbOptions.baseUrl = (_ia = readString(env, "REDIS_URL")) != null ? _ia : "";
3082
3082
  vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
3083
3083
  } else if (vectorProvider === "rest") {
3084
- vectorDbOptions.baseUrl = (_ga = readString(env, "VECTOR_DB_REST_URL")) != null ? _ga : "";
3084
+ vectorDbOptions.baseUrl = (_ja = readString(env, "VECTOR_DB_REST_URL")) != null ? _ja : "";
3085
3085
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
3086
3086
  } else if (vectorProvider === "universal_rest") {
3087
- vectorDbOptions.baseUrl = (_ia = (_ha = readString(env, "VECTOR_BASE_URL")) != null ? _ha : readString(env, "VECTOR_DB_REST_URL")) != null ? _ia : "";
3087
+ vectorDbOptions.baseUrl = (_la = (_ka = readString(env, "VECTOR_BASE_URL")) != null ? _ka : readString(env, "VECTOR_DB_REST_URL")) != null ? _la : "";
3088
3088
  vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
3089
3089
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
3090
3090
  }
@@ -3103,8 +3103,8 @@ function getEnvConfig(env = process.env, base) {
3103
3103
  // Anthropic needs a separate embedding provider; key kept for completeness
3104
3104
  gemini: readString(env, "GEMINI_API_KEY"),
3105
3105
  ollama: void 0,
3106
- universal_rest: (_ja = readString(env, "EMBEDDING_API_KEY")) != null ? _ja : readString(env, "OPENAI_API_KEY"),
3107
- custom: (_ka = readString(env, "EMBEDDING_API_KEY")) != null ? _ka : readString(env, "OPENAI_API_KEY")
3106
+ universal_rest: (_ma = readString(env, "EMBEDDING_API_KEY")) != null ? _ma : readString(env, "OPENAI_API_KEY"),
3107
+ custom: (_na = readString(env, "EMBEDDING_API_KEY")) != null ? _na : readString(env, "OPENAI_API_KEY")
3108
3108
  };
3109
3109
  const DEFAULT_MODEL_BY_PROVIDER = {
3110
3110
  openai: "gpt-4o",
@@ -3125,25 +3125,25 @@ function getEnvConfig(env = process.env, base) {
3125
3125
  return true;
3126
3126
  }
3127
3127
  })();
3128
- const defaultGatewayUrl = (_ma = (_la = readString(env, "LITELLM_BASE_URL")) != null ? _la : readString(env, "LLM_BASE_URL")) != null ? _ma : "https://llm.retrivora.com/api/v1";
3128
+ const defaultGatewayUrl = (_pa = (_oa = readString(env, "LITELLM_BASE_URL")) != null ? _oa : readString(env, "LLM_BASE_URL")) != null ? _pa : "https://llm.retrivora.com/api/v1";
3129
3129
  const defaultLlmProvider = isFreeTier ? "universal_rest" : "universal_rest";
3130
- const llmProvider = (_pa = (_oa = readEnum(env, "LLM_PROVIDER", defaultLlmProvider, LLM_PROVIDERS)) != null ? _oa : (_na = base == null ? void 0 : base.llm) == null ? void 0 : _na.provider) != null ? _pa : defaultLlmProvider;
3131
- const llmBaseUrl = (_ta = (_sa = (_qa = readString(env, "LITELLM_BASE_URL")) != null ? _qa : readString(env, "LLM_BASE_URL")) != null ? _sa : (_ra = base == null ? void 0 : base.llm) == null ? void 0 : _ra.baseUrl) != null ? _ta : defaultGatewayUrl;
3132
- const llmModel = (_xa = (_va = readString(env, "LLM_MODEL")) != null ? _va : (_ua = base == null ? void 0 : base.llm) == null ? void 0 : _ua.model) != null ? _xa : isFreeTier ? "llama-3.1-8b-instant" : (_wa = DEFAULT_MODEL_BY_PROVIDER[llmProvider]) != null ? _wa : "gpt-4o";
3133
- const llmApiKey = (_Da = (_Ca = (_Aa = (_za = (_ya = llmApiKeyByProvider[llmProvider]) != null ? _ya : readString(env, "LLM_API_KEY")) != null ? _za : readString(env, "LITELLM_MASTER_KEY")) != null ? _Aa : readString(env, "LITELLM_API_KEY")) != null ? _Ca : (_Ba = base == null ? void 0 : base.llm) == null ? void 0 : _Ba.apiKey) != null ? _Da : licenseKey;
3134
- const llmProfile = (_Ha = (_Ga = readString(env, "LLM_UNIVERSAL_PROFILE")) != null ? _Ga : (_Fa = (_Ea = base == null ? void 0 : base.llm) == null ? void 0 : _Ea.options) == null ? void 0 : _Fa.profile) != null ? _Ha : "litellm";
3130
+ 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;
3131
+ const llmBaseUrl = (_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 : defaultGatewayUrl;
3132
+ const llmModel = (_Aa = (_ya = readString(env, "LLM_MODEL")) != null ? _ya : (_xa = base == null ? void 0 : base.llm) == null ? void 0 : _xa.model) != null ? _Aa : isFreeTier ? "llama-3.1-8b-instant" : (_za = DEFAULT_MODEL_BY_PROVIDER[llmProvider]) != null ? _za : "gpt-4o";
3133
+ const llmApiKey = (_Ga = (_Fa = (_Da = (_Ca = (_Ba = llmApiKeyByProvider[llmProvider]) != null ? _Ba : readString(env, "LLM_API_KEY")) != null ? _Ca : readString(env, "LITELLM_MASTER_KEY")) != null ? _Da : readString(env, "LITELLM_API_KEY")) != null ? _Fa : (_Ea = base == null ? void 0 : base.llm) == null ? void 0 : _Ea.apiKey) != null ? _Ga : licenseKey;
3134
+ const llmProfile = (_Ka = (_Ja = readString(env, "LLM_UNIVERSAL_PROFILE")) != null ? _Ja : (_Ia = (_Ha = base == null ? void 0 : base.llm) == null ? void 0 : _Ha.options) == null ? void 0 : _Ia.profile) != null ? _Ka : "litellm";
3135
3135
  const defaultEmbeddingProvider = isFreeTier ? "universal_rest" : "universal_rest";
3136
- const embeddingProvider = (_Ka = (_Ja = readEnum(env, "EMBEDDING_PROVIDER", defaultEmbeddingProvider, EMBEDDING_PROVIDERS)) != null ? _Ja : (_Ia = base == null ? void 0 : base.embedding) == null ? void 0 : _Ia.provider) != null ? _Ka : defaultEmbeddingProvider;
3137
- const embeddingBaseUrl = (_Pa = (_Oa = (_Ma = (_La = readString(env, "LITELLM_BASE_URL")) != null ? _La : readString(env, "EMBEDDING_BASE_URL")) != null ? _Ma : readString(env, "LLM_BASE_URL")) != null ? _Oa : (_Na = base == null ? void 0 : base.embedding) == null ? void 0 : _Na.baseUrl) != null ? _Pa : defaultGatewayUrl;
3138
- const embeddingModel = (_Sa = (_Ra = readString(env, "EMBEDDING_MODEL")) != null ? _Ra : (_Qa = base == null ? void 0 : base.embedding) == null ? void 0 : _Qa.model) != null ? _Sa : "text-embedding-004";
3139
- const embeddingApiKey = (_Za = (_Ya = (_Wa = (_Va = (_Ua = (_Ta = embeddingApiKeyByProvider[embeddingProvider]) != null ? _Ta : readString(env, "EMBEDDING_API_KEY")) != null ? _Ua : readString(env, "LLM_API_KEY")) != null ? _Va : readString(env, "LITELLM_MASTER_KEY")) != null ? _Wa : readString(env, "LITELLM_API_KEY")) != null ? _Ya : (_Xa = base == null ? void 0 : base.embedding) == null ? void 0 : _Xa.apiKey) != null ? _Za : licenseKey;
3140
- const embeddingProfile = (_bb = (_ab = readString(env, "EMBEDDING_UNIVERSAL_PROFILE")) != null ? _ab : (_$a = (__a = base == null ? void 0 : base.embedding) == null ? void 0 : __a.options) == null ? void 0 : _$a.profile) != null ? _bb : "litellm";
3136
+ const embeddingProvider = (_Na = (_Ma = readEnum(env, "EMBEDDING_PROVIDER", defaultEmbeddingProvider, EMBEDDING_PROVIDERS)) != null ? _Ma : (_La = base == null ? void 0 : base.embedding) == null ? void 0 : _La.provider) != null ? _Na : defaultEmbeddingProvider;
3137
+ const embeddingBaseUrl = (_Sa = (_Ra = (_Pa = (_Oa = readString(env, "LITELLM_BASE_URL")) != null ? _Oa : readString(env, "EMBEDDING_BASE_URL")) != null ? _Pa : readString(env, "LLM_BASE_URL")) != null ? _Ra : (_Qa = base == null ? void 0 : base.embedding) == null ? void 0 : _Qa.baseUrl) != null ? _Sa : defaultGatewayUrl;
3138
+ const embeddingModel = (_Va = (_Ua = readString(env, "EMBEDDING_MODEL")) != null ? _Ua : (_Ta = base == null ? void 0 : base.embedding) == null ? void 0 : _Ta.model) != null ? _Va : "text-embedding-004";
3139
+ const embeddingApiKey = (_ab = (_$a = (_Za = (_Ya = (_Xa = (_Wa = embeddingApiKeyByProvider[embeddingProvider]) != null ? _Wa : readString(env, "EMBEDDING_API_KEY")) != null ? _Xa : readString(env, "LLM_API_KEY")) != null ? _Ya : readString(env, "LITELLM_MASTER_KEY")) != null ? _Za : readString(env, "LITELLM_API_KEY")) != null ? _$a : (__a = base == null ? void 0 : base.embedding) == null ? void 0 : __a.apiKey) != null ? _ab : licenseKey;
3140
+ const embeddingProfile = (_eb = (_db = readString(env, "EMBEDDING_UNIVERSAL_PROFILE")) != null ? _db : (_cb = (_bb = base == null ? void 0 : base.embedding) == null ? void 0 : _bb.options) == null ? void 0 : _cb.profile) != null ? _eb : "litellm";
3141
3141
  return __spreadProps(__spreadValues({
3142
3142
  projectId,
3143
3143
  licenseKey,
3144
3144
  vectorDb: {
3145
3145
  provider: vectorProvider,
3146
- indexName: (_db = (_cb = readString(env, "VECTOR_DB_INDEX")) != null ? _cb : vectorDbOptions.indexName) != null ? _db : "rag-index",
3146
+ indexName: (_gb = (_fb = readString(env, "VECTOR_DB_INDEX")) != null ? _fb : vectorDbOptions.indexName) != null ? _gb : "rag-index",
3147
3147
  options: vectorDbOptions
3148
3148
  },
3149
3149
  llm: {
@@ -3173,30 +3173,30 @@ function getEnvConfig(env = process.env, base) {
3173
3173
  }
3174
3174
  },
3175
3175
  ui: {
3176
- title: (_fb = (_eb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _eb : readString(env, "UI_TITLE")) != null ? _fb : "AI Assistant",
3177
- subtitle: (_hb = (_gb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _gb : readString(env, "UI_SUBTITLE")) != null ? _hb : "Powered by RAG",
3178
- primaryColor: (_jb = (_ib = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _ib : readString(env, "UI_PRIMARY_COLOR")) != null ? _jb : "#10b981",
3179
- accentColor: (_lb = (_kb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _kb : readString(env, "UI_ACCENT_COLOR")) != null ? _lb : "#3b82f6",
3180
- logoUrl: (_mb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _mb : readString(env, "UI_LOGO_URL"),
3181
- placeholder: (_ob = (_nb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _nb : readString(env, "UI_PLACEHOLDER")) != null ? _ob : "Ask me anything\u2026",
3182
- showSources: ((_qb = (_pb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _pb : readString(env, "UI_SHOW_SOURCES")) != null ? _qb : "true") !== "false",
3183
- welcomeMessage: (_sb = (_rb = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _rb : readString(env, "UI_WELCOME_MESSAGE")) != null ? _sb : "Hello! I'm your AI assistant. Ask me anything about your documents.",
3184
- visualStyle: (_ub = (_tb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _tb : readString(env, "UI_VISUAL_STYLE")) != null ? _ub : "glass",
3185
- borderRadius: (_wb = (_vb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _vb : readString(env, "UI_BORDER_RADIUS")) != null ? _wb : "xl",
3186
- allowUpload: ((_yb = (_xb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _xb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _yb : "false") === "true"
3176
+ title: (_ib = (_hb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _hb : readString(env, "UI_TITLE")) != null ? _ib : "AI Assistant",
3177
+ subtitle: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _jb : readString(env, "UI_SUBTITLE")) != null ? _kb : "Powered by RAG",
3178
+ primaryColor: (_mb = (_lb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _lb : readString(env, "UI_PRIMARY_COLOR")) != null ? _mb : "#10b981",
3179
+ accentColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _nb : readString(env, "UI_ACCENT_COLOR")) != null ? _ob : "#3b82f6",
3180
+ logoUrl: (_pb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _pb : readString(env, "UI_LOGO_URL"),
3181
+ placeholder: (_rb = (_qb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _qb : readString(env, "UI_PLACEHOLDER")) != null ? _rb : "Ask me anything\u2026",
3182
+ showSources: ((_tb = (_sb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _sb : readString(env, "UI_SHOW_SOURCES")) != null ? _tb : "true") !== "false",
3183
+ welcomeMessage: (_vb = (_ub = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _ub : readString(env, "UI_WELCOME_MESSAGE")) != null ? _vb : "Hello! I'm your AI assistant. Ask me anything about your documents.",
3184
+ visualStyle: (_xb = (_wb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _wb : readString(env, "UI_VISUAL_STYLE")) != null ? _xb : "glass",
3185
+ borderRadius: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _yb : readString(env, "UI_BORDER_RADIUS")) != null ? _zb : "xl",
3186
+ allowUpload: ((_Bb = (_Ab = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Ab : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Bb : "false") === "true"
3187
3187
  },
3188
3188
  rag: {
3189
3189
  topK: readNumber(env, "RAG_TOP_K", 5),
3190
3190
  scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
3191
3191
  chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
3192
3192
  chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
3193
- filterableFields: (_zb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _zb.split(",").map((f) => f.trim()),
3193
+ filterableFields: (_Cb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Cb.split(",").map((f) => f.trim()),
3194
3194
  // Query pipeline toggles — read from .env.local
3195
3195
  useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
3196
3196
  useReranking: readString(env, "RAG_USE_RERANKING") === "true",
3197
3197
  useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
3198
- architecture: (_Ab = readString(env, "RAG_ARCHITECTURE")) != null ? _Ab : "simple",
3199
- chunkingStrategy: (_Bb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Bb : "recursive",
3198
+ architecture: (_Db = readString(env, "RAG_ARCHITECTURE")) != null ? _Db : "simple",
3199
+ chunkingStrategy: (_Eb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Eb : "recursive",
3200
3200
  uiMapping: (() => {
3201
3201
  const raw = readString(env, "RAG_UI_MAPPING");
3202
3202
  if (!raw) return void 0;
@@ -3209,7 +3209,7 @@ function getEnvConfig(env = process.env, base) {
3209
3209
  },
3210
3210
  telemetry: {
3211
3211
  enabled: telemetryEnabled,
3212
- url: (_Fb = (_Eb = (_Cb = readString(env, "TELEMETRY_URL")) != null ? _Cb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Eb : (_Db = base == null ? void 0 : base.telemetry) == null ? void 0 : _Db.url) != null ? _Fb : process.env.NODE_ENV === "development" ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry"
3212
+ url: (_Ib = (_Hb = (_Fb = readString(env, "TELEMETRY_URL")) != null ? _Fb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Hb : (_Gb = base == null ? void 0 : base.telemetry) == null ? void 0 : _Gb.url) != null ? _Ib : process.env.NODE_ENV === "development" ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry"
3213
3213
  }
3214
3214
  }, readString(env, "GRAPH_DB_PROVIDER") ? {
3215
3215
  graphDb: {
@@ -5209,6 +5209,147 @@ var ConfigValidator = class {
5209
5209
  }
5210
5210
  };
5211
5211
 
5212
+ // package.json
5213
+ var package_default = {
5214
+ name: "@retrivora-ai/rag-engine",
5215
+ version: "2.1.5",
5216
+ description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
5217
+ author: "Abhinav Alkuchi",
5218
+ license: "UNLICENSED",
5219
+ keywords: [
5220
+ "rag",
5221
+ "retrieval-augmented-generation",
5222
+ "chatbot",
5223
+ "vector-database",
5224
+ "pinecone",
5225
+ "pgvector",
5226
+ "postgresql",
5227
+ "milvus",
5228
+ "qdrant",
5229
+ "chromadb",
5230
+ "redis",
5231
+ "weaviate",
5232
+ "mongodb",
5233
+ "openai",
5234
+ "anthropic",
5235
+ "ollama",
5236
+ "nextjs",
5237
+ "react",
5238
+ "ai",
5239
+ "llm",
5240
+ "embeddings"
5241
+ ],
5242
+ main: "dist/index.js",
5243
+ module: "dist/index.mjs",
5244
+ types: "dist/index.d.ts",
5245
+ exports: {
5246
+ ".": {
5247
+ types: "./dist/index.d.ts",
5248
+ require: "./dist/index.js",
5249
+ import: "./dist/index.mjs"
5250
+ },
5251
+ "./style.css": "./dist/index.css",
5252
+ "./handlers": {
5253
+ types: "./dist/handlers/index.d.ts",
5254
+ require: "./dist/handlers/index.js",
5255
+ import: "./dist/handlers/index.mjs"
5256
+ },
5257
+ "./server": {
5258
+ types: "./dist/server.d.ts",
5259
+ require: "./dist/server.js",
5260
+ import: "./dist/server.mjs"
5261
+ }
5262
+ },
5263
+ browser: {
5264
+ child_process: false,
5265
+ fs: false,
5266
+ net: false,
5267
+ tls: false,
5268
+ crypto: false,
5269
+ os: false,
5270
+ path: false,
5271
+ stream: false,
5272
+ http: false,
5273
+ https: false,
5274
+ zlib: false,
5275
+ mongodb: false,
5276
+ pg: false,
5277
+ "pdf-parse": false,
5278
+ mammoth: false
5279
+ },
5280
+ files: [
5281
+ "dist",
5282
+ "src",
5283
+ ".env.example",
5284
+ "README.md",
5285
+ "FREE_TIER_ARCHITECTURE.md"
5286
+ ],
5287
+ scripts: {
5288
+ dev: "npx @tailwindcss/cli -i src/tailwind.css -o src/index.css && tsup src/index.ts src/handlers/index.ts src/server.ts --format cjs,esm --watch --tsconfig tsconfig.build.json --external react,react-dom,next,mongodb,pg,openai,@anthropic-ai/sdk,@pinecone-database/pinecone,axios,lucide-react,mammoth,pdf-parse,xlsx,react-markdown,remark-gfm,next-themes,langchain,@langchain/core,@langchain/openai,llamaindex --inject-style",
5289
+ build: "npm run build:pkg",
5290
+ "build:pkg": "npx @tailwindcss/cli -i src/tailwind.css -o src/index.css && tsup src/index.ts src/handlers/index.ts src/server.ts --format cjs,esm --dts --clean --no-splitting --tsconfig tsconfig.build.json --external react,react-dom,next,mongodb,pg,openai,@anthropic-ai/sdk,@pinecone-database/pinecone,axios,lucide-react,mammoth,pdf-parse,xlsx,react-markdown,remark-gfm,next-themes,langchain,@langchain/core,@langchain/openai,llamaindex --inject-style && npx @tailwindcss/cli -i src/tailwind.css -o dist/index.css",
5291
+ lint: "eslint",
5292
+ clean: "rm -rf dist"
5293
+ },
5294
+ peerDependencies: {
5295
+ next: ">=15.0.0",
5296
+ react: ">=18.0.0",
5297
+ "react-dom": ">=18.0.0"
5298
+ },
5299
+ peerDependenciesMeta: {
5300
+ next: {
5301
+ optional: true
5302
+ }
5303
+ },
5304
+ dependencies: {
5305
+ "@anthropic-ai/sdk": "^0.95.1",
5306
+ "@google/genai": "^0.8.0",
5307
+ "@google/generative-ai": "^0.24.1",
5308
+ "@pinecone-database/pinecone": "^7.2.0",
5309
+ "@types/papaparse": "^5.5.2",
5310
+ axios: "^1.15.0",
5311
+ "lucide-react": "^1.8.0",
5312
+ "next-themes": "^0.4.6",
5313
+ openai: "^6.34.0",
5314
+ papaparse: "^5.5.3",
5315
+ "react-is": "^18.3.1",
5316
+ "react-markdown": "^10.1.0",
5317
+ recharts: "^3.8.1",
5318
+ "remark-gfm": "^4.0.1",
5319
+ xlsx: "^0.18.5"
5320
+ },
5321
+ optionalDependencies: {
5322
+ "@langchain/core": "^1.1.42",
5323
+ "@langchain/openai": "^1.4.5",
5324
+ langchain: "^1.3.5",
5325
+ llamaindex: "^0.11.9",
5326
+ mammoth: "^1.8.0",
5327
+ mongodb: "^7.1.1",
5328
+ "pdf-parse": "^1.1.1",
5329
+ pg: "^8.20.0"
5330
+ },
5331
+ devDependencies: {
5332
+ "@tailwindcss/cli": "^4",
5333
+ "@tailwindcss/postcss": "^4",
5334
+ "@types/estree": "^1.0.9",
5335
+ "@types/node": "^20",
5336
+ "@types/pdf-parse": "^1.1.5",
5337
+ "@types/pg": "^8.20.0",
5338
+ "@types/react": "^19.2.14",
5339
+ "@types/react-dom": "^19.2.3",
5340
+ dotenv: "^17.4.2",
5341
+ eslint: "^9",
5342
+ "eslint-config-next": "16.2.4",
5343
+ next: "16.2.10",
5344
+ tailwindcss: "^4",
5345
+ tsup: "^8.5.1",
5346
+ typescript: "^5"
5347
+ }
5348
+ };
5349
+
5350
+ // src/version.ts
5351
+ var SDK_VERSION = package_default.version || "2.1.3";
5352
+
5212
5353
  // src/rag/DocumentChunker.ts
5213
5354
  var DocumentChunker = class {
5214
5355
  constructor(chunkSize = 1e3, chunkOverlap = 200, separators = ["\n# ", "\n## ", "\n### ", "\n#### ", "\n\n", "\n", " ", ""]) {
@@ -9478,6 +9619,7 @@ ${context}`;
9478
9619
  const telemetryUrl = ((_B = this.config.telemetry) == null ? void 0 : _B.url) || process.env.TELEMETRY_URL || process.env.NEXT_PUBLIC_TELEMETRY_URL || defaultUrl;
9479
9620
  const absoluteUrl = telemetryUrl.startsWith("http") ? telemetryUrl : (process.env.NEXT_PUBLIC_APP_URL || `http://localhost:${process.env.PORT || 3e3}`) + telemetryUrl;
9480
9621
  (async () => {
9622
+ var _a3, _b2, _c2, _d2, _e2;
9481
9623
  try {
9482
9624
  let finalTrace = trace;
9483
9625
  if (!awaitHallucination && runHallucination) {
@@ -9486,6 +9628,12 @@ ${context}`;
9486
9628
  finalTrace = buildTrace(backgroundScoreResult);
9487
9629
  }
9488
9630
  }
9631
+ const modelName = (finalTrace == null ? void 0 : finalTrace.model) || ((_a3 = this.config.llm) == null ? void 0 : _a3.model) || "llama-3.1-8b-instant";
9632
+ const providerName = (finalTrace == null ? void 0 : finalTrace.provider) || ((_b2 = this.config.llm) == null ? void 0 : _b2.provider) || "groq";
9633
+ const tokenCount = Number(((_c2 = finalTrace == null ? void 0 : finalTrace.tokens) == null ? void 0 : _c2.totalTokens) || 0);
9634
+ const costEst = Number(((_d2 = finalTrace == null ? void 0 : finalTrace.tokens) == null ? void 0 : _d2.estimatedCostUsd) || 0);
9635
+ const latencyDuration = Number(((_e2 = finalTrace == null ? void 0 : finalTrace.latency) == null ? void 0 : _e2.totalMs) || 0);
9636
+ console.log(`[Retrivora Pipeline Telemetry] \u{1F4CA} Dispatching RAG telemetry -> Project: "${ns}", Model: "${providerName}/${modelName}", Tokens: ${tokenCount}, Latency: ${latencyDuration}ms`);
9489
9637
  await fetch(absoluteUrl, {
9490
9638
  method: "POST",
9491
9639
  headers: {
@@ -9494,7 +9642,20 @@ ${context}`;
9494
9642
  body: JSON.stringify({
9495
9643
  trace: finalTrace,
9496
9644
  licenseKey: this.config.licenseKey,
9497
- projectId: ns
9645
+ projectId: ns,
9646
+ organization: process.env.RETRIVORA_ORGANIZATION || "default-org",
9647
+ sdkVersion: SDK_VERSION,
9648
+ model: modelName,
9649
+ provider: providerName,
9650
+ tokens: tokenCount,
9651
+ cost: costEst,
9652
+ costUsd: costEst,
9653
+ latencyMs: latencyDuration,
9654
+ status: "success",
9655
+ action: "RAG_QUERY",
9656
+ feature: "RAG",
9657
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
9658
+ details: `Org: default-org | Model: ${providerName}/${modelName} | Tokens: ${tokenCount} | Latency: ${latencyDuration}ms | Cost: $${costEst} | SDK: v${SDK_VERSION} | Feature: RAG`
9498
9659
  })
9499
9660
  });
9500
9661
  } catch (err) {
@@ -10591,7 +10752,7 @@ function getOrCreatePlugin(configOrPlugin) {
10591
10752
  return _g[cacheKey];
10592
10753
  }
10593
10754
  function reportTelemetry(req, plugin, action, status, details, trace) {
10594
- var _a2;
10755
+ var _a2, _b, _c, _d, _e, _f, _g2, _h;
10595
10756
  try {
10596
10757
  const config = plugin.getConfig();
10597
10758
  const licenseKey = config.licenseKey || process.env.RAG_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY;
@@ -10600,29 +10761,49 @@ function reportTelemetry(req, plugin, action, status, details, trace) {
10600
10761
  const defaultUrl = process.env.NODE_ENV === "development" && !process.env.TELEMETRY_URL && !process.env.NEXT_PUBLIC_TELEMETRY_URL ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry";
10601
10762
  const telemetryUrl = (telemetryConfig == null ? void 0 : telemetryConfig.url) || process.env.TELEMETRY_URL || process.env.NEXT_PUBLIC_TELEMETRY_URL || defaultUrl;
10602
10763
  const host = req.headers.get("host") || "localhost";
10764
+ const userAgent = req.headers.get("user-agent") || `Retrivora-SDK/${SDK_VERSION}`;
10603
10765
  let absoluteUrl = telemetryUrl;
10604
10766
  if (!telemetryUrl.startsWith("http")) {
10605
10767
  const proto = req.headers.get("x-forwarded-proto") || "http";
10606
10768
  absoluteUrl = `${proto}://${host}${telemetryUrl}`;
10607
10769
  }
10608
10770
  const projectId = config.projectId || "default";
10771
+ const model = (trace == null ? void 0 : trace.model) || ((_b = config.llm) == null ? void 0 : _b.model) || ((_c = config.embedding) == null ? void 0 : _c.model) || "llama-3.1-8b-instant";
10772
+ const provider = (trace == null ? void 0 : trace.provider) || ((_d = config.llm) == null ? void 0 : _d.provider) || ((_e = config.embedding) == null ? void 0 : _e.provider) || "groq";
10773
+ const tokens = Number(((_f = trace == null ? void 0 : trace.tokens) == null ? void 0 : _f.totalTokens) || (trace == null ? void 0 : trace.totalTokens) || 0);
10774
+ const costUsd = Number(((_g2 = trace == null ? void 0 : trace.tokens) == null ? void 0 : _g2.estimatedCostUsd) || (trace == null ? void 0 : trace.costUsd) || 0);
10775
+ const latencyMs = Number(((_h = trace == null ? void 0 : trace.latency) == null ? void 0 : _h.totalMs) || (trace == null ? void 0 : trace.latencyMs) || 0);
10776
+ const payload = {
10777
+ trace,
10778
+ licenseKey,
10779
+ projectId,
10780
+ organization: process.env.RETRIVORA_ORGANIZATION || "default-org",
10781
+ sdkVersion: SDK_VERSION,
10782
+ model,
10783
+ provider,
10784
+ tokens,
10785
+ cost: costUsd,
10786
+ costUsd,
10787
+ latencyMs,
10788
+ status,
10789
+ action,
10790
+ feature: action,
10791
+ userAgent,
10792
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
10793
+ details
10794
+ };
10795
+ console.log(`[Retrivora SDK Telemetry] \u{1F4CA} Dispatching telemetry -> Feature: "${action}", Status: "${status}", Project: "${projectId}", Model: "${provider}/${model}", Latency: ${latencyMs}ms`);
10609
10796
  fetch(absoluteUrl, {
10610
10797
  method: "POST",
10611
10798
  headers: {
10612
10799
  "Content-Type": "application/json",
10613
10800
  "x-forwarded-for": req.headers.get("x-forwarded-for") || "",
10614
- "x-real-ip": req.headers.get("x-real-ip") || ""
10801
+ "x-real-ip": req.headers.get("x-real-ip") || "",
10802
+ "user-agent": userAgent
10615
10803
  },
10616
- body: JSON.stringify({
10617
- trace,
10618
- licenseKey,
10619
- projectId,
10620
- action,
10621
- status,
10622
- details
10623
- })
10804
+ body: JSON.stringify(payload)
10624
10805
  }).catch((err) => {
10625
- console.warn("[Retrivora Telemetry] Async report warning:", err.message);
10806
+ console.warn("[Retrivora SDK Telemetry] Async report warning:", err.message);
10626
10807
  });
10627
10808
  } catch (e) {
10628
10809
  }
@@ -10725,12 +10906,19 @@ function createStreamHandler(configOrPlugin, options) {
10725
10906
  const storage = new DatabaseStorage(plugin.getConfig());
10726
10907
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
10727
10908
  return async function POST(req) {
10909
+ var _a2;
10728
10910
  const authResult = await checkAuth(req, onAuthorize);
10729
10911
  if (authResult) return authResult;
10730
10912
  const rateLimited = checkRateLimit(req);
10731
10913
  if (rateLimited) return rateLimited;
10732
10914
  let body;
10733
10915
  try {
10916
+ if ((_a2 = req.headers.get("content-type")) == null ? void 0 : _a2.includes("multipart/form-data")) {
10917
+ return new Response(JSON.stringify({ error: { code: "INVALID_ENDPOINT", message: "Multipart file upload requests must be sent to the /upload endpoint." } }), {
10918
+ status: 400,
10919
+ headers: { "Content-Type": "application/json" }
10920
+ });
10921
+ }
10734
10922
  body = await req.json();
10735
10923
  } catch (e) {
10736
10924
  return new Response(JSON.stringify({ error: { code: "INVALID_JSON", message: "Invalid JSON body" } }), {
@@ -10768,7 +10956,7 @@ function createStreamHandler(configOrPlugin, options) {
10768
10956
  let isActive = true;
10769
10957
  const stream = new ReadableStream({
10770
10958
  async start(controller) {
10771
- var _a2, _b, _c, _d, _e;
10959
+ var _a3, _b, _c, _d, _e;
10772
10960
  const enqueue = (text) => {
10773
10961
  if (!isActive) return;
10774
10962
  try {
@@ -10801,7 +10989,7 @@ function createStreamHandler(configOrPlugin, options) {
10801
10989
  let uiTransformation = responseChunk == null ? void 0 : responseChunk.ui_transformation;
10802
10990
  if (sources.length > 0) {
10803
10991
  try {
10804
- uiTransformation = (_a2 = responseChunk == null ? void 0 : responseChunk.ui_transformation) != null ? _a2 : UITransformer.transform(message, sources, plugin.getConfig());
10992
+ uiTransformation = (_a3 = responseChunk == null ? void 0 : responseChunk.ui_transformation) != null ? _a3 : UITransformer.transform(message, sources, plugin.getConfig());
10805
10993
  if (uiTransformation) {
10806
10994
  enqueue(sseUIFrame(uiTransformation));
10807
10995
  }
@@ -11198,16 +11386,32 @@ function createRagHandler(configOrPlugin, options) {
11198
11386
  return NextResponse.json({ error: `Method Not Allowed: GET segment "${segment}" not supported.` }, { status: 405 });
11199
11387
  }
11200
11388
  }
11201
- async function getSegment(context) {
11202
- var _a2;
11389
+ async function getSegment(req, context) {
11390
+ var _a2, _b;
11391
+ const contentType = req.headers.get("content-type") || "";
11392
+ if (contentType.includes("multipart/form-data")) {
11393
+ return "upload";
11394
+ }
11395
+ try {
11396
+ const url = new URL(req.url);
11397
+ const pathname = url.pathname;
11398
+ if (pathname.endsWith("/upload")) return "upload";
11399
+ if (pathname.endsWith("/chat") || pathname.endsWith("/chat-sync")) return "chat";
11400
+ if (pathname.endsWith("/health")) return "health";
11401
+ if (pathname.endsWith("/suggestions")) return "suggestions";
11402
+ if (pathname.endsWith("/feedback")) return "feedback";
11403
+ if (pathname.endsWith("/history")) return "history";
11404
+ } catch (e) {
11405
+ }
11203
11406
  const resolvedParams = typeof ((_a2 = context == null ? void 0 : context.params) == null ? void 0 : _a2.then) === "function" ? await context.params : context == null ? void 0 : context.params;
11204
- const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || [];
11205
- return segments.join("/") || "chat";
11407
+ const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || [];
11408
+ const joined = segments.join("/");
11409
+ return joined || "chat";
11206
11410
  }
11207
11411
  return {
11208
11412
  GET: async (req, context) => {
11209
11413
  try {
11210
- const segment = await getSegment(context);
11414
+ const segment = await getSegment(req, context);
11211
11415
  return await routeGetRequest(req, segment);
11212
11416
  } catch (err) {
11213
11417
  const msg = err instanceof Error ? err.message : "GET Routing failed";
@@ -11216,7 +11420,7 @@ function createRagHandler(configOrPlugin, options) {
11216
11420
  },
11217
11421
  POST: async (req, context) => {
11218
11422
  try {
11219
- const segment = await getSegment(context);
11423
+ const segment = await getSegment(req, context);
11220
11424
  return await routePostRequest(req, segment);
11221
11425
  } catch (err) {
11222
11426
  const msg = err instanceof Error ? err.message : "POST Routing failed";
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, MouseEvent, ReactNode, ElementType } from 'react';
2
- import { y as Product, m as UIConfig, j as RagMessage, q as VectorMatch, J as UITransformationResponse, i as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, z as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-0rRBYbVW.mjs';
2
+ import { y as Product, m as UIConfig, j as RagMessage, q as VectorMatch, J as UITransformationResponse, i as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, z as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-BWa68XX5.js';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -100,6 +100,10 @@ interface ProductCarouselProps {
100
100
  interface DocumentUploadProps {
101
101
  /** Optional namespace for the upload */
102
102
  namespace?: string;
103
+ /** Custom upload API endpoint URL (defaults to /api/retrivora/upload or /api/upload) */
104
+ uploadUrl?: string;
105
+ /** Base URL for Retrivora SDK endpoints (defaults to /api/retrivora) */
106
+ retrivoraApiBase?: string;
103
107
  /** Callback when upload completes */
104
108
  onUploadComplete?: (results: unknown) => void;
105
109
  /** Additional className */
@@ -129,6 +133,11 @@ interface ConfigProviderProps {
129
133
  children: ReactNode;
130
134
  }
131
135
 
136
+ /**
137
+ * Dynamically resolved SDK Version from package.json
138
+ */
139
+ declare const SDK_VERSION: string;
140
+
132
141
  /**
133
142
  * Primary rendering outcome types supported by the decision engine.
134
143
  */
@@ -529,4 +538,4 @@ declare class AuthenticationException extends RetrivoraError {
529
538
  */
530
539
  declare function wrapError(err: unknown, defaultCode: RetrivoraErrorCode, defaultMessage?: string): RetrivoraError;
531
540
 
532
- export { AuthenticationException as A, DocumentChunker as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, MixedRendererStrategy as F, Pipeline as G, type PipelineStep as H, type IRenderRule as I, type ProviderPill as J, type RenderSectionDecision as K, type Snippet as L, type MessageBubbleProps as M, TextRendererStrategy as N, wrapError as O, type ProductCardProps as P, RateLimitException as R, type SourceCardProps as S, TableRendererStrategy as T, VisualizationDecisionEngine as V, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, type ChartType as e, type Chunk as f, type ChunkOptions as g, ConfigurationException as h, type DecisionContext as i, type IRendererStrategy as j, type IntentCategory as k, IntentClassifier as l, ProviderNotFoundException as m, type RenderDecision as n, type RenderType as o, RendererRegistry as p, RetrievalException as q, Retrivora as r, RetrivoraError as s, type RetrivoraErrorCode as t, RuleEngine as u, decideVisualization as v, type ArchitectureCardProps as w, CarouselRendererStrategy as x, ChartRendererStrategy as y, type ChatViewportSize as z };
541
+ export { AuthenticationException as A, type ChatViewportSize as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, DocumentChunker as F, MixedRendererStrategy as G, Pipeline as H, type IRenderRule as I, type PipelineStep as J, type ProviderPill as K, type RenderSectionDecision as L, type MessageBubbleProps as M, type Snippet as N, TextRendererStrategy as O, type ProductCardProps as P, wrapError as Q, RateLimitException as R, type SourceCardProps as S, TableRendererStrategy as T, VisualizationDecisionEngine as V, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, type ChartType as e, type Chunk as f, type ChunkOptions as g, ConfigurationException as h, type DecisionContext as i, type IRendererStrategy as j, type IntentCategory as k, IntentClassifier as l, ProviderNotFoundException as m, type RenderDecision as n, type RenderType as o, RendererRegistry as p, RetrievalException as q, Retrivora as r, RetrivoraError as s, type RetrivoraErrorCode as t, RuleEngine as u, SDK_VERSION as v, decideVisualization as w, type ArchitectureCardProps as x, CarouselRendererStrategy as y, ChartRendererStrategy as z };
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, MouseEvent, ReactNode, ElementType } from 'react';
2
- import { y as Product, m as UIConfig, j as RagMessage, q as VectorMatch, J as UITransformationResponse, i as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, z as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-0rRBYbVW.js';
2
+ import { y as Product, m as UIConfig, j as RagMessage, q as VectorMatch, J as UITransformationResponse, i as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, z as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-BWa68XX5.mjs';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -100,6 +100,10 @@ interface ProductCarouselProps {
100
100
  interface DocumentUploadProps {
101
101
  /** Optional namespace for the upload */
102
102
  namespace?: string;
103
+ /** Custom upload API endpoint URL (defaults to /api/retrivora/upload or /api/upload) */
104
+ uploadUrl?: string;
105
+ /** Base URL for Retrivora SDK endpoints (defaults to /api/retrivora) */
106
+ retrivoraApiBase?: string;
103
107
  /** Callback when upload completes */
104
108
  onUploadComplete?: (results: unknown) => void;
105
109
  /** Additional className */
@@ -129,6 +133,11 @@ interface ConfigProviderProps {
129
133
  children: ReactNode;
130
134
  }
131
135
 
136
+ /**
137
+ * Dynamically resolved SDK Version from package.json
138
+ */
139
+ declare const SDK_VERSION: string;
140
+
132
141
  /**
133
142
  * Primary rendering outcome types supported by the decision engine.
134
143
  */
@@ -529,4 +538,4 @@ declare class AuthenticationException extends RetrivoraError {
529
538
  */
530
539
  declare function wrapError(err: unknown, defaultCode: RetrivoraErrorCode, defaultMessage?: string): RetrivoraError;
531
540
 
532
- export { AuthenticationException as A, DocumentChunker as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, MixedRendererStrategy as F, Pipeline as G, type PipelineStep as H, type IRenderRule as I, type ProviderPill as J, type RenderSectionDecision as K, type Snippet as L, type MessageBubbleProps as M, TextRendererStrategy as N, wrapError as O, type ProductCardProps as P, RateLimitException as R, type SourceCardProps as S, TableRendererStrategy as T, VisualizationDecisionEngine as V, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, type ChartType as e, type Chunk as f, type ChunkOptions as g, ConfigurationException as h, type DecisionContext as i, type IRendererStrategy as j, type IntentCategory as k, IntentClassifier as l, ProviderNotFoundException as m, type RenderDecision as n, type RenderType as o, RendererRegistry as p, RetrievalException as q, Retrivora as r, RetrivoraError as s, type RetrivoraErrorCode as t, RuleEngine as u, decideVisualization as v, type ArchitectureCardProps as w, CarouselRendererStrategy as x, ChartRendererStrategy as y, type ChatViewportSize as z };
541
+ export { AuthenticationException as A, type ChatViewportSize as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, DocumentChunker as F, MixedRendererStrategy as G, Pipeline as H, type IRenderRule as I, type PipelineStep as J, type ProviderPill as K, type RenderSectionDecision as L, type MessageBubbleProps as M, type Snippet as N, TextRendererStrategy as O, type ProductCardProps as P, wrapError as Q, RateLimitException as R, type SourceCardProps as S, TableRendererStrategy as T, VisualizationDecisionEngine as V, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, type ChartType as e, type Chunk as f, type ChunkOptions as g, ConfigurationException as h, type DecisionContext as i, type IRendererStrategy as j, type IntentCategory as k, IntentClassifier as l, ProviderNotFoundException as m, type RenderDecision as n, type RenderType as o, RendererRegistry as p, RetrievalException as q, Retrivora as r, RetrivoraError as s, type RetrivoraErrorCode as t, RuleEngine as u, SDK_VERSION as v, decideVisualization as w, type ArchitectureCardProps as x, CarouselRendererStrategy as y, ChartRendererStrategy as z };
@@ -1,5 +1,5 @@
1
1
  import { NextRequest } from 'next/server';
2
- import { i as RagConfig, I as ILLMProvider, C as ChatMessage, c as ChatResponse, f as IngestDocument } from './ILLMProvider-0rRBYbVW.js';
2
+ import { i as RagConfig, I as ILLMProvider, C as ChatMessage, c as ChatResponse, f as IngestDocument } from './ILLMProvider-BWa68XX5.js';
3
3
 
4
4
  interface ValidationError {
5
5
  field: string;