@retrivora-ai/rag-engine 2.2.6 → 2.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-BbJGyNmW.d.mts → LicenseValidator-B3xpJaVf.d.mts} +42 -2
- package/dist/{index-BCbeeh74.d.ts → LicenseValidator-D4I4pbSL.d.ts} +42 -2
- package/dist/handlers/index.js +9 -4
- package/dist/handlers/index.mjs +9 -4
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +190 -96
- package/dist/index.mjs +187 -96
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +127 -4
- package/dist/server.mjs +124 -4
- package/package.json +1 -1
- package/src/components/ChatWidget.tsx +11 -34
- package/src/components/ChatWindow.tsx +18 -33
- package/src/core/LicenseValidator.ts +146 -0
- package/src/exceptions/index.ts +25 -5
- package/src/handlers/index.ts +11 -1
- package/src/hooks/useRagChat.ts +9 -1
- package/src/index.ts +4 -0
- package/src/server.ts +6 -0
package/dist/index.mjs
CHANGED
|
@@ -2919,7 +2919,10 @@ function useRagChat(projectId, options = {}) {
|
|
|
2919
2919
|
console.log("[useRagChat] Streaming stopped by user.");
|
|
2920
2920
|
return;
|
|
2921
2921
|
}
|
|
2922
|
-
|
|
2922
|
+
let msg = err instanceof Error ? err.message : "Something went wrong. Please try again.";
|
|
2923
|
+
if (msg.includes("403") || msg.toLowerCase().includes("license") || msg.toLowerCase().includes("revoked") || msg.toLowerCase().includes("terminated")) {
|
|
2924
|
+
msg = "Your Retrivora license key has been terminated, suspended, or revoked. Access denied.";
|
|
2925
|
+
}
|
|
2923
2926
|
setError(msg);
|
|
2924
2927
|
onError == null ? void 0 : onError(msg);
|
|
2925
2928
|
} finally {
|
|
@@ -3031,7 +3034,7 @@ function useRagChat(projectId, options = {}) {
|
|
|
3031
3034
|
// package.json
|
|
3032
3035
|
var package_default = {
|
|
3033
3036
|
name: "@retrivora-ai/rag-engine",
|
|
3034
|
-
version: "2.2.
|
|
3037
|
+
version: "2.2.7",
|
|
3035
3038
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
3036
3039
|
author: "Abhinav Alkuchi",
|
|
3037
3040
|
license: "UNLICENSED",
|
|
@@ -3171,6 +3174,158 @@ var package_default = {
|
|
|
3171
3174
|
// src/version.ts
|
|
3172
3175
|
var SDK_VERSION = package_default.version || "2.1.3";
|
|
3173
3176
|
|
|
3177
|
+
// src/exceptions/index.ts
|
|
3178
|
+
var RetrivoraError = class extends Error {
|
|
3179
|
+
constructor(message, code, details) {
|
|
3180
|
+
super(message);
|
|
3181
|
+
this.name = new.target.name;
|
|
3182
|
+
this.code = code;
|
|
3183
|
+
this.details = details;
|
|
3184
|
+
}
|
|
3185
|
+
};
|
|
3186
|
+
var ProviderNotFoundException = class extends RetrivoraError {
|
|
3187
|
+
constructor(providerType, provider, details) {
|
|
3188
|
+
super(`Unsupported ${providerType} provider: ${provider}`, "PROVIDER_NOT_FOUND", details);
|
|
3189
|
+
}
|
|
3190
|
+
};
|
|
3191
|
+
var EmbeddingFailedException = class extends RetrivoraError {
|
|
3192
|
+
constructor(message = "Embedding generation failed", details) {
|
|
3193
|
+
super(message, "EMBEDDING_FAILED", details);
|
|
3194
|
+
}
|
|
3195
|
+
};
|
|
3196
|
+
var RetrievalException = class extends RetrivoraError {
|
|
3197
|
+
constructor(message = "Retrieval failed", details) {
|
|
3198
|
+
super(message, "RETRIEVAL_FAILED", details);
|
|
3199
|
+
}
|
|
3200
|
+
};
|
|
3201
|
+
var RateLimitException = class extends RetrivoraError {
|
|
3202
|
+
constructor(message = "Provider rate limit exceeded", details) {
|
|
3203
|
+
super(message, "RATE_LIMITED", details);
|
|
3204
|
+
}
|
|
3205
|
+
};
|
|
3206
|
+
var ConfigurationException = class extends RetrivoraError {
|
|
3207
|
+
constructor(message, details) {
|
|
3208
|
+
super(message, "CONFIGURATION_ERROR", details);
|
|
3209
|
+
}
|
|
3210
|
+
};
|
|
3211
|
+
var AuthenticationException = class extends RetrivoraError {
|
|
3212
|
+
constructor(message = "Provider authentication failed", details) {
|
|
3213
|
+
super(message, "AUTHENTICATION_ERROR", details);
|
|
3214
|
+
}
|
|
3215
|
+
};
|
|
3216
|
+
var SDKVersionUnsupportedError = class extends RetrivoraError {
|
|
3217
|
+
constructor(message = "This SDK version is no longer supported.", details) {
|
|
3218
|
+
super(message, "SDK_VERSION_UNSUPPORTED", details);
|
|
3219
|
+
}
|
|
3220
|
+
};
|
|
3221
|
+
var LicenseValidationError = class extends RetrivoraError {
|
|
3222
|
+
constructor(message = "License validation failed.", details) {
|
|
3223
|
+
super(message, "LICENSE_VALIDATION_ERROR", details);
|
|
3224
|
+
}
|
|
3225
|
+
};
|
|
3226
|
+
|
|
3227
|
+
// src/core/LicenseValidator.ts
|
|
3228
|
+
var _LicenseValidator = class _LicenseValidator {
|
|
3229
|
+
// 5-minute TTL for successful validation only
|
|
3230
|
+
constructor() {
|
|
3231
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
3232
|
+
}
|
|
3233
|
+
static getInstance() {
|
|
3234
|
+
if (!_LicenseValidator.instance) {
|
|
3235
|
+
_LicenseValidator.instance = new _LicenseValidator();
|
|
3236
|
+
}
|
|
3237
|
+
return _LicenseValidator.instance;
|
|
3238
|
+
}
|
|
3239
|
+
/**
|
|
3240
|
+
* Invalidate local validation cache for a license key
|
|
3241
|
+
*/
|
|
3242
|
+
purgeCache(licenseKey) {
|
|
3243
|
+
if (licenseKey) {
|
|
3244
|
+
this.cache.delete(licenseKey);
|
|
3245
|
+
} else {
|
|
3246
|
+
this.cache.clear();
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
/**
|
|
3250
|
+
* Validate license status and SDK version against Retrivora License Service
|
|
3251
|
+
*/
|
|
3252
|
+
async validate(request) {
|
|
3253
|
+
const {
|
|
3254
|
+
licenseKey,
|
|
3255
|
+
projectId,
|
|
3256
|
+
sdkVersion = SDK_VERSION,
|
|
3257
|
+
sdk = "@retrivora-ai/rag-engine",
|
|
3258
|
+
platform = typeof window !== "undefined" ? "browser" : "node",
|
|
3259
|
+
retrivoraApiBase,
|
|
3260
|
+
headers: customHeaders
|
|
3261
|
+
} = request;
|
|
3262
|
+
if (!licenseKey) {
|
|
3263
|
+
this.purgeCache(licenseKey);
|
|
3264
|
+
throw new LicenseValidationError("Missing RETRIVORA_LICENSE_KEY in request.");
|
|
3265
|
+
}
|
|
3266
|
+
const cached = this.cache.get(licenseKey);
|
|
3267
|
+
if (cached) {
|
|
3268
|
+
const isFresh = Date.now() - cached.timestamp < _LicenseValidator.SUCCESS_CACHE_TTL_MS;
|
|
3269
|
+
if (isFresh && cached.response.valid && cached.response.licenseStatus === "ACTIVE" && !cached.response.forceUpgrade) {
|
|
3270
|
+
return cached.response;
|
|
3271
|
+
} else {
|
|
3272
|
+
this.cache.delete(licenseKey);
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
const base = retrivoraApiBase || (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_RETRIVORA_API_BASE || process.env.RETRIVORA_API_BASE : "") || "/api/retrivora";
|
|
3276
|
+
const validateUrl = `${base.replace(/\/$/, "")}/v1/license/validate`;
|
|
3277
|
+
let res;
|
|
3278
|
+
try {
|
|
3279
|
+
res = await fetch(validateUrl, {
|
|
3280
|
+
method: "POST",
|
|
3281
|
+
cache: "no-store",
|
|
3282
|
+
headers: __spreadValues({
|
|
3283
|
+
"Content-Type": "application/json",
|
|
3284
|
+
"x-license-key": licenseKey,
|
|
3285
|
+
"x-sdk-version": sdkVersion
|
|
3286
|
+
}, customHeaders || {}),
|
|
3287
|
+
body: JSON.stringify({
|
|
3288
|
+
licenseKey,
|
|
3289
|
+
projectId,
|
|
3290
|
+
sdkVersion,
|
|
3291
|
+
sdk,
|
|
3292
|
+
platform
|
|
3293
|
+
})
|
|
3294
|
+
});
|
|
3295
|
+
} catch (err) {
|
|
3296
|
+
this.purgeCache(licenseKey);
|
|
3297
|
+
throw new LicenseValidationError(`License validation request failed: ${(err == null ? void 0 : err.message) || "Network error"}`);
|
|
3298
|
+
}
|
|
3299
|
+
const data = await res.json().catch(() => ({
|
|
3300
|
+
valid: false,
|
|
3301
|
+
licenseStatus: "REVOKED",
|
|
3302
|
+
minimumSupportedVersion: "2.1.0",
|
|
3303
|
+
latestVersion: SDK_VERSION,
|
|
3304
|
+
forceUpgrade: false,
|
|
3305
|
+
expiresAt: null,
|
|
3306
|
+
message: "Failed to parse license validation response."
|
|
3307
|
+
}));
|
|
3308
|
+
if (!res.ok || !data.valid || data.licenseStatus !== "ACTIVE" || data.forceUpgrade) {
|
|
3309
|
+
this.purgeCache(licenseKey);
|
|
3310
|
+
if (data.forceUpgrade || res.status === 426) {
|
|
3311
|
+
throw new SDKVersionUnsupportedError(
|
|
3312
|
+
data.message || `This SDK version (${sdkVersion}) is no longer supported. Upgrade to version ${data.latestVersion || "2.2.6"} or later.`,
|
|
3313
|
+
data
|
|
3314
|
+
);
|
|
3315
|
+
}
|
|
3316
|
+
const errMsg = data.message || `License validation failed with status: ${data.licenseStatus}. Access denied.`;
|
|
3317
|
+
throw new LicenseValidationError(errMsg, data);
|
|
3318
|
+
}
|
|
3319
|
+
this.cache.set(licenseKey, {
|
|
3320
|
+
response: data,
|
|
3321
|
+
timestamp: Date.now()
|
|
3322
|
+
});
|
|
3323
|
+
return data;
|
|
3324
|
+
}
|
|
3325
|
+
};
|
|
3326
|
+
_LicenseValidator.SUCCESS_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
3327
|
+
var LicenseValidator = _LicenseValidator;
|
|
3328
|
+
|
|
3174
3329
|
// src/components/ChatWindow.tsx
|
|
3175
3330
|
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3176
3331
|
function ChatWindow({
|
|
@@ -3214,42 +3369,32 @@ function ChatWindow({
|
|
|
3214
3369
|
async function validateSessionLicense() {
|
|
3215
3370
|
var _a2;
|
|
3216
3371
|
try {
|
|
3217
|
-
const
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
headers
|
|
3223
|
-
"Content-Type": "application/json",
|
|
3224
|
-
"x-sdk-version": SDK_VERSION
|
|
3225
|
-
}, headers || {})
|
|
3372
|
+
const licenseKey = (headers == null ? void 0 : headers["x-license-key"]) || ((_a2 = headers == null ? void 0 : headers["authorization"]) == null ? void 0 : _a2.replace(/^Bearer\s+/i, "")) || "";
|
|
3373
|
+
await LicenseValidator.getInstance().validate({
|
|
3374
|
+
licenseKey,
|
|
3375
|
+
projectId,
|
|
3376
|
+
retrivoraApiBase,
|
|
3377
|
+
headers
|
|
3226
3378
|
});
|
|
3227
|
-
if (
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
}
|
|
3238
|
-
}
|
|
3239
|
-
} else {
|
|
3240
|
-
if (isMounted) {
|
|
3241
|
-
setLicenseError(null);
|
|
3242
|
-
setVersionError(null);
|
|
3379
|
+
if (isMounted) {
|
|
3380
|
+
setLicenseError(null);
|
|
3381
|
+
setVersionError(null);
|
|
3382
|
+
}
|
|
3383
|
+
} catch (err) {
|
|
3384
|
+
if (isMounted) {
|
|
3385
|
+
if ((err == null ? void 0 : err.code) === "SDK_VERSION_UNSUPPORTED") {
|
|
3386
|
+
setVersionError((err == null ? void 0 : err.message) || "SDK version unsupported.");
|
|
3387
|
+
} else {
|
|
3388
|
+
setLicenseError((err == null ? void 0 : err.message) || "License validation failed.");
|
|
3243
3389
|
}
|
|
3244
3390
|
}
|
|
3245
|
-
} catch (e) {
|
|
3246
3391
|
}
|
|
3247
3392
|
}
|
|
3248
3393
|
validateSessionLicense();
|
|
3249
3394
|
return () => {
|
|
3250
3395
|
isMounted = false;
|
|
3251
3396
|
};
|
|
3252
|
-
}, [retrivoraApiBase, headers]);
|
|
3397
|
+
}, [retrivoraApiBase, headers, projectId]);
|
|
3253
3398
|
useEffect5(() => {
|
|
3254
3399
|
if (typeof window !== "undefined") {
|
|
3255
3400
|
const win = window;
|
|
@@ -3698,7 +3843,7 @@ var GEMINI_STYLES = `
|
|
|
3698
3843
|
}
|
|
3699
3844
|
`;
|
|
3700
3845
|
function ChatWidget({ position = "bottom-right", onAddToCart, apiUrl, retrivoraApiBase, headers }) {
|
|
3701
|
-
const { ui } = useConfig();
|
|
3846
|
+
const { ui, projectId } = useConfig();
|
|
3702
3847
|
const [isOpen, setIsOpen] = useState7(false);
|
|
3703
3848
|
const [hasUnread, setHasUnread] = useState7(false);
|
|
3704
3849
|
const [dimensions, setDimensions] = useState7(DEFAULT_DIMENSIONS);
|
|
@@ -3714,36 +3859,19 @@ function ChatWidget({ position = "bottom-right", onAddToCart, apiUrl, retrivoraA
|
|
|
3714
3859
|
var _a;
|
|
3715
3860
|
setIsValidating(true);
|
|
3716
3861
|
try {
|
|
3717
|
-
const
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
headers
|
|
3723
|
-
"Content-Type": "application/json",
|
|
3724
|
-
"x-sdk-version": SDK_VERSION
|
|
3725
|
-
}, headers || {})
|
|
3862
|
+
const licenseKey = (headers == null ? void 0 : headers["x-license-key"]) || ((_a = headers == null ? void 0 : headers["authorization"]) == null ? void 0 : _a.replace(/^Bearer\s+/i, "")) || "";
|
|
3863
|
+
await LicenseValidator.getInstance().validate({
|
|
3864
|
+
licenseKey,
|
|
3865
|
+
projectId,
|
|
3866
|
+
retrivoraApiBase,
|
|
3867
|
+
headers
|
|
3726
3868
|
});
|
|
3727
|
-
if (!res.ok) {
|
|
3728
|
-
const data = await res.json().catch(() => ({}));
|
|
3729
|
-
if (res.status === 426 || data.code === "SDK_VERSION_OUTDATED") {
|
|
3730
|
-
const msg = data.error || "Your Retrivora SDK package version is outdated. Please update your package to the latest version to continue.";
|
|
3731
|
-
setWidgetError(msg);
|
|
3732
|
-
setIsOpen(false);
|
|
3733
|
-
return;
|
|
3734
|
-
}
|
|
3735
|
-
if (res.status === 403 || res.status === 401 || typeof data.error === "string" && data.error.toLowerCase().includes("license")) {
|
|
3736
|
-
const msg = (typeof data.error === "string" ? data.error : (_a = data.error) == null ? void 0 : _a.message) || "Your Retrivora license is no longer valid. Please contact your administrator or obtain a valid license key.";
|
|
3737
|
-
setWidgetError(msg);
|
|
3738
|
-
setIsOpen(false);
|
|
3739
|
-
return;
|
|
3740
|
-
}
|
|
3741
|
-
}
|
|
3742
3869
|
setWidgetError(null);
|
|
3743
3870
|
setIsOpen(true);
|
|
3744
3871
|
setHasUnread(false);
|
|
3745
|
-
} catch (
|
|
3746
|
-
|
|
3872
|
+
} catch (err) {
|
|
3873
|
+
setWidgetError((err == null ? void 0 : err.message) || "Access denied.");
|
|
3874
|
+
setIsOpen(false);
|
|
3747
3875
|
} finally {
|
|
3748
3876
|
setIsValidating(false);
|
|
3749
3877
|
}
|
|
@@ -5882,46 +6010,6 @@ _RendererRegistry.registerStrategy(new CarouselRendererStrategy());
|
|
|
5882
6010
|
_RendererRegistry.registerStrategy(new ChartRendererStrategy());
|
|
5883
6011
|
_RendererRegistry.registerStrategy(new MixedRendererStrategy());
|
|
5884
6012
|
var RendererRegistry = _RendererRegistry;
|
|
5885
|
-
|
|
5886
|
-
// src/exceptions/index.ts
|
|
5887
|
-
var RetrivoraError = class extends Error {
|
|
5888
|
-
constructor(message, code, details) {
|
|
5889
|
-
super(message);
|
|
5890
|
-
this.name = new.target.name;
|
|
5891
|
-
this.code = code;
|
|
5892
|
-
this.details = details;
|
|
5893
|
-
}
|
|
5894
|
-
};
|
|
5895
|
-
var ProviderNotFoundException = class extends RetrivoraError {
|
|
5896
|
-
constructor(providerType, provider, details) {
|
|
5897
|
-
super(`Unsupported ${providerType} provider: ${provider}`, "PROVIDER_NOT_FOUND", details);
|
|
5898
|
-
}
|
|
5899
|
-
};
|
|
5900
|
-
var EmbeddingFailedException = class extends RetrivoraError {
|
|
5901
|
-
constructor(message = "Embedding generation failed", details) {
|
|
5902
|
-
super(message, "EMBEDDING_FAILED", details);
|
|
5903
|
-
}
|
|
5904
|
-
};
|
|
5905
|
-
var RetrievalException = class extends RetrivoraError {
|
|
5906
|
-
constructor(message = "Retrieval failed", details) {
|
|
5907
|
-
super(message, "RETRIEVAL_FAILED", details);
|
|
5908
|
-
}
|
|
5909
|
-
};
|
|
5910
|
-
var RateLimitException = class extends RetrivoraError {
|
|
5911
|
-
constructor(message = "Provider rate limit exceeded", details) {
|
|
5912
|
-
super(message, "RATE_LIMITED", details);
|
|
5913
|
-
}
|
|
5914
|
-
};
|
|
5915
|
-
var ConfigurationException = class extends RetrivoraError {
|
|
5916
|
-
constructor(message, details) {
|
|
5917
|
-
super(message, "CONFIGURATION_ERROR", details);
|
|
5918
|
-
}
|
|
5919
|
-
};
|
|
5920
|
-
var AuthenticationException = class extends RetrivoraError {
|
|
5921
|
-
constructor(message = "Provider authentication failed", details) {
|
|
5922
|
-
super(message, "AUTHENTICATION_ERROR", details);
|
|
5923
|
-
}
|
|
5924
|
-
};
|
|
5925
6013
|
export {
|
|
5926
6014
|
AuthenticationException,
|
|
5927
6015
|
ChatWidget,
|
|
@@ -5932,6 +6020,8 @@ export {
|
|
|
5932
6020
|
DocumentUpload,
|
|
5933
6021
|
EmbeddingFailedException,
|
|
5934
6022
|
IntentClassifier,
|
|
6023
|
+
LicenseValidationError,
|
|
6024
|
+
LicenseValidator,
|
|
5935
6025
|
MessageBubble,
|
|
5936
6026
|
ObservabilityPanel,
|
|
5937
6027
|
ProductCard,
|
|
@@ -5942,6 +6032,7 @@ export {
|
|
|
5942
6032
|
RetrievalException,
|
|
5943
6033
|
RetrivoraError,
|
|
5944
6034
|
RuleEngine,
|
|
6035
|
+
SDKVersionUnsupportedError,
|
|
5945
6036
|
SDK_VERSION,
|
|
5946
6037
|
SourceCard,
|
|
5947
6038
|
VisualizationDecisionEngine,
|
package/dist/server.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { V as VectorDBConfig, L as LLMConfig, d as EmbeddingConfig, i as RagConfig, n as UniversalRagConfig, o as UpsertDocument, q as VectorMatch, G as GraphDBConfig, r as GraphNode, s as Edge, t as GraphSearchResult, I as ILLMProvider, p as VectorDBProvider, g as LLMProvider, e as EmbeddingProvider, R as RAGConfig, m as UIConfig, C as ChatMessage, b as ChatOptions, E as EmbedOptions } from './ILLMProvider-BWa68XX5.mjs';
|
|
2
2
|
export { B as BarChartData, u as CarouselProduct, c as ChatResponse, v as IRetriever, f as IngestDocument, h as LatencyBreakdown, w as LineChartDataPoint, M as MessageRole, x as MetricCardData, O as ObservabilityTrace, P as PieChartData, y as Product, j as RagMessage, k as RetrievalConfig, z as RetrievalResult, l as RetrievedChunk, A as RetrivoraChunkMetadata, D as RetrivoraIngestedDocument, S as ScatterPlotDataPoint, F as SuggestionsResponse, H as TableData, T as TokenUsage, J as UITransformationResponse, U as UseRagChatOptions, a as UseRagChatReturn, K as VisualizationType, W as WorkflowConfig } from './ILLMProvider-BWa68XX5.mjs';
|
|
3
|
-
import { I as IRenderRule, i as DecisionContext, k as IntentCategory,
|
|
4
|
-
export {
|
|
3
|
+
import { I as IRenderRule, i as DecisionContext, k as IntentCategory, q as RenderDecision } from './LicenseValidator-B3xpJaVf.mjs';
|
|
4
|
+
export { F as ArchitectureCardProps, A as AuthenticationException, G as CarouselRendererStrategy, H as ChartRendererStrategy, e as ChartType, J as ChatViewportSize, C as ChatWidgetProps, a as ChatWindowProps, f as Chunk, g as ChunkOptions, c as ClientConfig, b as ConfigProviderProps, h as ConfigurationException, K as DocumentChunker, D as DocumentUploadProps, E as EmbeddingFailedException, j as IRendererStrategy, l as IntentClassifier, L as LicenseValidationError, m as LicenseValidationRequest, n as LicenseValidationResponse, o as LicenseValidator, M as MessageBubbleProps, N as MixedRendererStrategy, O as Pipeline, Q as PipelineStep, P as ProductCardProps, d as ProductCarouselProps, p as ProviderNotFoundException, T as ProviderPill, R as RateLimitException, U as RenderSectionDecision, r as RenderType, s as RendererRegistry, t as RetrievalException, u as Retrivora, v as RetrivoraError, w as RetrivoraErrorCode, x as RuleEngine, y as SDKVersionUnsupportedError, z as SDK_VERSION, W as Snippet, S as SourceCardProps, X as TableRendererStrategy, Y as TextRendererStrategy, V as VisualizationDecisionEngine, B as decideVisualization, Z as wrapError } from './LicenseValidator-B3xpJaVf.mjs';
|
|
5
5
|
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-DvbtNz7m.mjs';
|
|
6
6
|
export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, n as sseTextFrame } from './index-DvbtNz7m.mjs';
|
|
7
7
|
import 'react';
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { V as VectorDBConfig, L as LLMConfig, d as EmbeddingConfig, i as RagConfig, n as UniversalRagConfig, o as UpsertDocument, q as VectorMatch, G as GraphDBConfig, r as GraphNode, s as Edge, t as GraphSearchResult, I as ILLMProvider, p as VectorDBProvider, g as LLMProvider, e as EmbeddingProvider, R as RAGConfig, m as UIConfig, C as ChatMessage, b as ChatOptions, E as EmbedOptions } from './ILLMProvider-BWa68XX5.js';
|
|
2
2
|
export { B as BarChartData, u as CarouselProduct, c as ChatResponse, v as IRetriever, f as IngestDocument, h as LatencyBreakdown, w as LineChartDataPoint, M as MessageRole, x as MetricCardData, O as ObservabilityTrace, P as PieChartData, y as Product, j as RagMessage, k as RetrievalConfig, z as RetrievalResult, l as RetrievedChunk, A as RetrivoraChunkMetadata, D as RetrivoraIngestedDocument, S as ScatterPlotDataPoint, F as SuggestionsResponse, H as TableData, T as TokenUsage, J as UITransformationResponse, U as UseRagChatOptions, a as UseRagChatReturn, K as VisualizationType, W as WorkflowConfig } from './ILLMProvider-BWa68XX5.js';
|
|
3
|
-
import { I as IRenderRule, i as DecisionContext, k as IntentCategory,
|
|
4
|
-
export {
|
|
3
|
+
import { I as IRenderRule, i as DecisionContext, k as IntentCategory, q as RenderDecision } from './LicenseValidator-D4I4pbSL.js';
|
|
4
|
+
export { F as ArchitectureCardProps, A as AuthenticationException, G as CarouselRendererStrategy, H as ChartRendererStrategy, e as ChartType, J as ChatViewportSize, C as ChatWidgetProps, a as ChatWindowProps, f as Chunk, g as ChunkOptions, c as ClientConfig, b as ConfigProviderProps, h as ConfigurationException, K as DocumentChunker, D as DocumentUploadProps, E as EmbeddingFailedException, j as IRendererStrategy, l as IntentClassifier, L as LicenseValidationError, m as LicenseValidationRequest, n as LicenseValidationResponse, o as LicenseValidator, M as MessageBubbleProps, N as MixedRendererStrategy, O as Pipeline, Q as PipelineStep, P as ProductCardProps, d as ProductCarouselProps, p as ProviderNotFoundException, T as ProviderPill, R as RateLimitException, U as RenderSectionDecision, r as RenderType, s as RendererRegistry, t as RetrievalException, u as Retrivora, v as RetrivoraError, w as RetrivoraErrorCode, x as RuleEngine, y as SDKVersionUnsupportedError, z as SDK_VERSION, W as Snippet, S as SourceCardProps, X as TableRendererStrategy, Y as TextRendererStrategy, V as VisualizationDecisionEngine, B as decideVisualization, Z as wrapError } from './LicenseValidator-D4I4pbSL.js';
|
|
5
5
|
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-B5TTZWkx.js';
|
|
6
6
|
export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, n as sseTextFrame } from './index-B5TTZWkx.js';
|
|
7
7
|
import 'react';
|
package/dist/server.js
CHANGED
|
@@ -2224,6 +2224,8 @@ __export(server_exports, {
|
|
|
2224
2224
|
IntentClassifier: () => IntentClassifier,
|
|
2225
2225
|
LLMFactory: () => LLMFactory,
|
|
2226
2226
|
LLM_PROFILES: () => LLM_PROFILES,
|
|
2227
|
+
LicenseValidationError: () => LicenseValidationError,
|
|
2228
|
+
LicenseValidator: () => LicenseValidator,
|
|
2227
2229
|
LicenseVerifier: () => LicenseVerifier,
|
|
2228
2230
|
MilvusProvider: () => MilvusProvider,
|
|
2229
2231
|
MixedRendererStrategy: () => MixedRendererStrategy,
|
|
@@ -2254,6 +2256,7 @@ __export(server_exports, {
|
|
|
2254
2256
|
Rule6SmallResultSetRule: () => Rule6SmallResultSetRule,
|
|
2255
2257
|
Rule7LargeTableRule: () => Rule7LargeTableRule,
|
|
2256
2258
|
RuleEngine: () => RuleEngine,
|
|
2259
|
+
SDKVersionUnsupportedError: () => SDKVersionUnsupportedError,
|
|
2257
2260
|
SDK_VERSION: () => SDK_VERSION,
|
|
2258
2261
|
TableRendererStrategy: () => TableRendererStrategy,
|
|
2259
2262
|
TextRendererStrategy: () => TextRendererStrategy,
|
|
@@ -2328,6 +2331,16 @@ var AuthenticationException = class extends RetrivoraError {
|
|
|
2328
2331
|
super(message, "AUTHENTICATION_ERROR", details);
|
|
2329
2332
|
}
|
|
2330
2333
|
};
|
|
2334
|
+
var SDKVersionUnsupportedError = class extends RetrivoraError {
|
|
2335
|
+
constructor(message = "This SDK version is no longer supported.", details) {
|
|
2336
|
+
super(message, "SDK_VERSION_UNSUPPORTED", details);
|
|
2337
|
+
}
|
|
2338
|
+
};
|
|
2339
|
+
var LicenseValidationError = class extends RetrivoraError {
|
|
2340
|
+
constructor(message = "License validation failed.", details) {
|
|
2341
|
+
super(message, "LICENSE_VALIDATION_ERROR", details);
|
|
2342
|
+
}
|
|
2343
|
+
};
|
|
2331
2344
|
function wrapError(err, defaultCode, defaultMessage) {
|
|
2332
2345
|
var _a2;
|
|
2333
2346
|
if (err instanceof RetrivoraError) {
|
|
@@ -2340,8 +2353,10 @@ function wrapError(err, defaultCode, defaultMessage) {
|
|
|
2340
2353
|
if (status === 429 || /rate[- ]?limit/i.test(message) || code === "RATE_LIMIT_EXCEEDED") {
|
|
2341
2354
|
return new RateLimitException(message, err);
|
|
2342
2355
|
}
|
|
2343
|
-
if (status === 401 || status === 403 || /unauthorized|auth|api[- ]?key/i.test(message) || code === "INVALID_API_KEY") {
|
|
2344
|
-
|
|
2356
|
+
if (status === 401 || status === 403 || /unauthorized|auth|license|revoked|terminated|api[- ]?key/i.test(message) || code === "INVALID_API_KEY" || code === "LICENSE_DELETED" || code === "LICENSE_INACTIVE") {
|
|
2357
|
+
const isLicenseError = /403|license|revoked|terminated/i.test(message) || status === 403;
|
|
2358
|
+
const cleanMsg = isLicenseError ? "Your Retrivora license key has been terminated, suspended, or revoked. Access denied." : message;
|
|
2359
|
+
return new AuthenticationException(cleanMsg, err);
|
|
2345
2360
|
}
|
|
2346
2361
|
switch (defaultCode) {
|
|
2347
2362
|
case "PROVIDER_NOT_FOUND":
|
|
@@ -4808,7 +4823,7 @@ var ConfigValidator = class {
|
|
|
4808
4823
|
// package.json
|
|
4809
4824
|
var package_default = {
|
|
4810
4825
|
name: "@retrivora-ai/rag-engine",
|
|
4811
|
-
version: "2.2.
|
|
4826
|
+
version: "2.2.7",
|
|
4812
4827
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
4813
4828
|
author: "Abhinav Alkuchi",
|
|
4814
4829
|
license: "UNLICENSED",
|
|
@@ -10924,7 +10939,10 @@ function createStreamHandler(configOrPlugin, options) {
|
|
|
10924
10939
|
}
|
|
10925
10940
|
} catch (streamError) {
|
|
10926
10941
|
if (isActive) {
|
|
10927
|
-
|
|
10942
|
+
let errorMessage = streamError instanceof Error ? streamError.message : String(streamError);
|
|
10943
|
+
if (errorMessage.includes("403") || errorMessage.toLowerCase().includes("license") || errorMessage.toLowerCase().includes("revoked") || errorMessage.toLowerCase().includes("terminated")) {
|
|
10944
|
+
errorMessage = "Your Retrivora license key has been terminated, suspended, or revoked. Access denied.";
|
|
10945
|
+
}
|
|
10928
10946
|
console.error("[createStreamHandler] Stream error:", streamError);
|
|
10929
10947
|
reportTelemetry(req, plugin, "QUERY_GENERATION", "error", errorMessage);
|
|
10930
10948
|
try {
|
|
@@ -11325,6 +11343,108 @@ function createRagHandler(configOrPlugin, options) {
|
|
|
11325
11343
|
}
|
|
11326
11344
|
};
|
|
11327
11345
|
}
|
|
11346
|
+
|
|
11347
|
+
// src/core/LicenseValidator.ts
|
|
11348
|
+
var _LicenseValidator = class _LicenseValidator {
|
|
11349
|
+
// 5-minute TTL for successful validation only
|
|
11350
|
+
constructor() {
|
|
11351
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
11352
|
+
}
|
|
11353
|
+
static getInstance() {
|
|
11354
|
+
if (!_LicenseValidator.instance) {
|
|
11355
|
+
_LicenseValidator.instance = new _LicenseValidator();
|
|
11356
|
+
}
|
|
11357
|
+
return _LicenseValidator.instance;
|
|
11358
|
+
}
|
|
11359
|
+
/**
|
|
11360
|
+
* Invalidate local validation cache for a license key
|
|
11361
|
+
*/
|
|
11362
|
+
purgeCache(licenseKey) {
|
|
11363
|
+
if (licenseKey) {
|
|
11364
|
+
this.cache.delete(licenseKey);
|
|
11365
|
+
} else {
|
|
11366
|
+
this.cache.clear();
|
|
11367
|
+
}
|
|
11368
|
+
}
|
|
11369
|
+
/**
|
|
11370
|
+
* Validate license status and SDK version against Retrivora License Service
|
|
11371
|
+
*/
|
|
11372
|
+
async validate(request) {
|
|
11373
|
+
const {
|
|
11374
|
+
licenseKey,
|
|
11375
|
+
projectId,
|
|
11376
|
+
sdkVersion = SDK_VERSION,
|
|
11377
|
+
sdk = "@retrivora-ai/rag-engine",
|
|
11378
|
+
platform = typeof window !== "undefined" ? "browser" : "node",
|
|
11379
|
+
retrivoraApiBase,
|
|
11380
|
+
headers: customHeaders
|
|
11381
|
+
} = request;
|
|
11382
|
+
if (!licenseKey) {
|
|
11383
|
+
this.purgeCache(licenseKey);
|
|
11384
|
+
throw new LicenseValidationError("Missing RETRIVORA_LICENSE_KEY in request.");
|
|
11385
|
+
}
|
|
11386
|
+
const cached = this.cache.get(licenseKey);
|
|
11387
|
+
if (cached) {
|
|
11388
|
+
const isFresh = Date.now() - cached.timestamp < _LicenseValidator.SUCCESS_CACHE_TTL_MS;
|
|
11389
|
+
if (isFresh && cached.response.valid && cached.response.licenseStatus === "ACTIVE" && !cached.response.forceUpgrade) {
|
|
11390
|
+
return cached.response;
|
|
11391
|
+
} else {
|
|
11392
|
+
this.cache.delete(licenseKey);
|
|
11393
|
+
}
|
|
11394
|
+
}
|
|
11395
|
+
const base = retrivoraApiBase || (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_RETRIVORA_API_BASE || process.env.RETRIVORA_API_BASE : "") || "/api/retrivora";
|
|
11396
|
+
const validateUrl = `${base.replace(/\/$/, "")}/v1/license/validate`;
|
|
11397
|
+
let res;
|
|
11398
|
+
try {
|
|
11399
|
+
res = await fetch(validateUrl, {
|
|
11400
|
+
method: "POST",
|
|
11401
|
+
cache: "no-store",
|
|
11402
|
+
headers: __spreadValues({
|
|
11403
|
+
"Content-Type": "application/json",
|
|
11404
|
+
"x-license-key": licenseKey,
|
|
11405
|
+
"x-sdk-version": sdkVersion
|
|
11406
|
+
}, customHeaders || {}),
|
|
11407
|
+
body: JSON.stringify({
|
|
11408
|
+
licenseKey,
|
|
11409
|
+
projectId,
|
|
11410
|
+
sdkVersion,
|
|
11411
|
+
sdk,
|
|
11412
|
+
platform
|
|
11413
|
+
})
|
|
11414
|
+
});
|
|
11415
|
+
} catch (err) {
|
|
11416
|
+
this.purgeCache(licenseKey);
|
|
11417
|
+
throw new LicenseValidationError(`License validation request failed: ${(err == null ? void 0 : err.message) || "Network error"}`);
|
|
11418
|
+
}
|
|
11419
|
+
const data = await res.json().catch(() => ({
|
|
11420
|
+
valid: false,
|
|
11421
|
+
licenseStatus: "REVOKED",
|
|
11422
|
+
minimumSupportedVersion: "2.1.0",
|
|
11423
|
+
latestVersion: SDK_VERSION,
|
|
11424
|
+
forceUpgrade: false,
|
|
11425
|
+
expiresAt: null,
|
|
11426
|
+
message: "Failed to parse license validation response."
|
|
11427
|
+
}));
|
|
11428
|
+
if (!res.ok || !data.valid || data.licenseStatus !== "ACTIVE" || data.forceUpgrade) {
|
|
11429
|
+
this.purgeCache(licenseKey);
|
|
11430
|
+
if (data.forceUpgrade || res.status === 426) {
|
|
11431
|
+
throw new SDKVersionUnsupportedError(
|
|
11432
|
+
data.message || `This SDK version (${sdkVersion}) is no longer supported. Upgrade to version ${data.latestVersion || "2.2.6"} or later.`,
|
|
11433
|
+
data
|
|
11434
|
+
);
|
|
11435
|
+
}
|
|
11436
|
+
const errMsg = data.message || `License validation failed with status: ${data.licenseStatus}. Access denied.`;
|
|
11437
|
+
throw new LicenseValidationError(errMsg, data);
|
|
11438
|
+
}
|
|
11439
|
+
this.cache.set(licenseKey, {
|
|
11440
|
+
response: data,
|
|
11441
|
+
timestamp: Date.now()
|
|
11442
|
+
});
|
|
11443
|
+
return data;
|
|
11444
|
+
}
|
|
11445
|
+
};
|
|
11446
|
+
_LicenseValidator.SUCCESS_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
11447
|
+
var LicenseValidator = _LicenseValidator;
|
|
11328
11448
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11329
11449
|
0 && (module.exports = {
|
|
11330
11450
|
AnthropicProvider,
|
|
@@ -11347,6 +11467,8 @@ function createRagHandler(configOrPlugin, options) {
|
|
|
11347
11467
|
IntentClassifier,
|
|
11348
11468
|
LLMFactory,
|
|
11349
11469
|
LLM_PROFILES,
|
|
11470
|
+
LicenseValidationError,
|
|
11471
|
+
LicenseValidator,
|
|
11350
11472
|
LicenseVerifier,
|
|
11351
11473
|
MilvusProvider,
|
|
11352
11474
|
MixedRendererStrategy,
|
|
@@ -11377,6 +11499,7 @@ function createRagHandler(configOrPlugin, options) {
|
|
|
11377
11499
|
Rule6SmallResultSetRule,
|
|
11378
11500
|
Rule7LargeTableRule,
|
|
11379
11501
|
RuleEngine,
|
|
11502
|
+
SDKVersionUnsupportedError,
|
|
11380
11503
|
SDK_VERSION,
|
|
11381
11504
|
TableRendererStrategy,
|
|
11382
11505
|
TextRendererStrategy,
|