@retrivora-ai/rag-engine 2.3.5 → 2.3.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/{BatchProcessor-tVzb9CdE.d.mts → BatchProcessor-BhLczWj5.d.mts} +179 -3
- package/dist/{BatchProcessor-CQDtlggz.d.ts → BatchProcessor-C42_RVWO.d.ts} +179 -3
- package/dist/{ILLMProvider-CcJ5N6XD.d.mts → ILLMProvider-B8TAVx3j.d.mts} +63 -1
- package/dist/{ILLMProvider-CcJ5N6XD.d.ts → ILLMProvider-B8TAVx3j.d.ts} +63 -1
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +493 -217
- package/dist/handlers/index.mjs +493 -217
- package/dist/{index-BwmyPJHp.d.ts → index-ejOWsaqb.d.ts} +1 -1
- package/dist/{index-CL-zF6bD.d.mts → index-xxQOFx-u.d.mts} +1 -1
- package/dist/index.css +9 -0
- package/dist/index.d.mts +19 -5
- package/dist/index.d.ts +19 -5
- package/dist/index.js +643 -207
- package/dist/index.mjs +683 -252
- package/dist/server.d.mts +253 -7
- package/dist/server.d.ts +253 -7
- package/dist/server.js +1145 -230
- package/dist/server.mjs +1131 -230
- package/package.json +1 -1
- package/src/LicensedRetrivora.ts +273 -0
- package/src/components/ChatWidget.tsx +44 -19
- package/src/components/ChatWindow.tsx +30 -14
- package/src/components/ConfigProvider.tsx +86 -6
- package/src/components/DocumentUpload.tsx +8 -2
- package/src/config/LicenseConfigResolver.ts +296 -0
- package/src/config/RagConfig.ts +4 -0
- package/src/config/serverConfig.ts +74 -14
- package/src/core/ConfigFetcher.ts +10 -1
- package/src/core/ConfigResolver.ts +1 -0
- package/src/core/LicenseValidator.ts +21 -12
- package/src/core/LicenseVerifier.ts +7 -11
- package/src/core/ProjectSettings.ts +247 -0
- package/src/handlers/index.ts +65 -5
- package/src/hooks/useProjectSettings.ts +105 -0
- package/src/index.css +9 -0
- package/src/index.ts +37 -0
- package/src/llm/providers/UniversalLLMAdapter.ts +67 -12
- package/src/server.ts +46 -2
- package/src/telemetry/TelemetryService.ts +330 -0
- package/src/types/props.ts +14 -2
package/dist/handlers/index.mjs
CHANGED
|
@@ -139,11 +139,326 @@ var init_BaseVectorProvider = __esm({
|
|
|
139
139
|
}
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
+
// src/core/ProjectSettings.ts
|
|
143
|
+
function createDefaultProjectSettings(projectId) {
|
|
144
|
+
return {
|
|
145
|
+
projectId,
|
|
146
|
+
branding: {
|
|
147
|
+
companyName: "Retrivora AI",
|
|
148
|
+
botName: "Retrivora Assistant",
|
|
149
|
+
welcomeMessage: "Hi, I can help you search your knowledge base.",
|
|
150
|
+
primaryColor: "#6366f1",
|
|
151
|
+
secondaryColor: "#8b5cf6",
|
|
152
|
+
fontFamily: "Inter",
|
|
153
|
+
borderRadius: 14,
|
|
154
|
+
logoUrl: "",
|
|
155
|
+
avatarUrl: "",
|
|
156
|
+
customCss: ""
|
|
157
|
+
},
|
|
158
|
+
ai: {
|
|
159
|
+
defaultModel: "llama-3.1-8b-instant",
|
|
160
|
+
embeddingModel: "text-embedding-3-small",
|
|
161
|
+
systemPrompt: "Answer using the connected knowledge base. Cite sources when available.",
|
|
162
|
+
memoryEnabled: true,
|
|
163
|
+
multiModelEnabled: true,
|
|
164
|
+
citationsEnabled: true,
|
|
165
|
+
fileUploadEnabled: true
|
|
166
|
+
},
|
|
167
|
+
auth: {
|
|
168
|
+
mode: "public",
|
|
169
|
+
allowedOrigins: [],
|
|
170
|
+
requireVerifiedEmail: false,
|
|
171
|
+
sessionTtlMinutes: 1440
|
|
172
|
+
},
|
|
173
|
+
widget: {
|
|
174
|
+
position: "bottom-right",
|
|
175
|
+
theme: "light",
|
|
176
|
+
lazyLoad: true,
|
|
177
|
+
autoReconnect: true,
|
|
178
|
+
persistConversations: true,
|
|
179
|
+
showRetrivoraBranding: false
|
|
180
|
+
},
|
|
181
|
+
telemetry: {
|
|
182
|
+
enabled: true,
|
|
183
|
+
collectBrowser: true,
|
|
184
|
+
collectCountry: false,
|
|
185
|
+
redactPii: true,
|
|
186
|
+
retentionDays: 30
|
|
187
|
+
},
|
|
188
|
+
lifecycleHooks: DEFAULT_LIFECYCLE_HOOKS,
|
|
189
|
+
conversationFeatures: DEFAULT_CONVERSATION_FEATURES
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function cleanString(value, fallback, maxLength = 2e3) {
|
|
193
|
+
if (typeof value !== "string") return fallback;
|
|
194
|
+
return value.trim().slice(0, maxLength);
|
|
195
|
+
}
|
|
196
|
+
function cleanBoolean(value, fallback) {
|
|
197
|
+
return typeof value === "boolean" ? value : fallback;
|
|
198
|
+
}
|
|
199
|
+
function cleanNumber(value, fallback, min, max) {
|
|
200
|
+
const num = typeof value === "number" ? value : Number(value);
|
|
201
|
+
if (!Number.isFinite(num)) return fallback;
|
|
202
|
+
return Math.min(Math.max(Math.round(num), min), max);
|
|
203
|
+
}
|
|
204
|
+
function cleanEnum(value, fallback, allowed) {
|
|
205
|
+
return typeof value === "string" && allowed.includes(value) ? value : fallback;
|
|
206
|
+
}
|
|
207
|
+
function cleanStringList(value, fallback, maxItems = 20) {
|
|
208
|
+
if (!Array.isArray(value)) return fallback;
|
|
209
|
+
const cleaned = value.filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean).slice(0, maxItems);
|
|
210
|
+
return cleaned.length > 0 ? Array.from(new Set(cleaned)) : fallback;
|
|
211
|
+
}
|
|
212
|
+
function normalizeProjectSettings(projectId, input) {
|
|
213
|
+
const defaults = createDefaultProjectSettings(projectId);
|
|
214
|
+
const branding = (input == null ? void 0 : input.branding) || {};
|
|
215
|
+
const ai = (input == null ? void 0 : input.ai) || {};
|
|
216
|
+
const auth = (input == null ? void 0 : input.auth) || {};
|
|
217
|
+
const widget = (input == null ? void 0 : input.widget) || {};
|
|
218
|
+
const telemetry = (input == null ? void 0 : input.telemetry) || {};
|
|
219
|
+
return {
|
|
220
|
+
projectId,
|
|
221
|
+
branding: {
|
|
222
|
+
companyName: cleanString(branding.companyName, defaults.branding.companyName, 120),
|
|
223
|
+
botName: cleanString(branding.botName, defaults.branding.botName, 120),
|
|
224
|
+
welcomeMessage: cleanString(branding.welcomeMessage, defaults.branding.welcomeMessage, 500),
|
|
225
|
+
primaryColor: cleanString(branding.primaryColor, defaults.branding.primaryColor, 32),
|
|
226
|
+
secondaryColor: cleanString(branding.secondaryColor, defaults.branding.secondaryColor, 32),
|
|
227
|
+
fontFamily: cleanString(branding.fontFamily, defaults.branding.fontFamily, 80),
|
|
228
|
+
borderRadius: cleanNumber(branding.borderRadius, defaults.branding.borderRadius, 0, 32),
|
|
229
|
+
logoUrl: cleanString(branding.logoUrl, defaults.branding.logoUrl, 500),
|
|
230
|
+
avatarUrl: cleanString(branding.avatarUrl, defaults.branding.avatarUrl, 500),
|
|
231
|
+
customCss: cleanString(branding.customCss, defaults.branding.customCss, 5e3)
|
|
232
|
+
},
|
|
233
|
+
ai: {
|
|
234
|
+
defaultModel: cleanString(ai.defaultModel, defaults.ai.defaultModel, 120),
|
|
235
|
+
embeddingModel: cleanString(ai.embeddingModel, defaults.ai.embeddingModel, 120),
|
|
236
|
+
systemPrompt: cleanString(ai.systemPrompt, defaults.ai.systemPrompt, 5e3),
|
|
237
|
+
memoryEnabled: cleanBoolean(ai.memoryEnabled, defaults.ai.memoryEnabled),
|
|
238
|
+
multiModelEnabled: cleanBoolean(ai.multiModelEnabled, defaults.ai.multiModelEnabled),
|
|
239
|
+
citationsEnabled: cleanBoolean(ai.citationsEnabled, defaults.ai.citationsEnabled),
|
|
240
|
+
fileUploadEnabled: cleanBoolean(ai.fileUploadEnabled, defaults.ai.fileUploadEnabled)
|
|
241
|
+
},
|
|
242
|
+
auth: {
|
|
243
|
+
mode: cleanEnum(auth.mode, defaults.auth.mode, ["public", "anonymous", "jwt", "oauth", "okta", "auth0", "supabase", "firebase", "sso", "custom_token"]),
|
|
244
|
+
allowedOrigins: cleanStringList(auth.allowedOrigins, defaults.auth.allowedOrigins, 25),
|
|
245
|
+
requireVerifiedEmail: cleanBoolean(auth.requireVerifiedEmail, defaults.auth.requireVerifiedEmail),
|
|
246
|
+
sessionTtlMinutes: cleanNumber(auth.sessionTtlMinutes, defaults.auth.sessionTtlMinutes, 15, 43200)
|
|
247
|
+
},
|
|
248
|
+
widget: {
|
|
249
|
+
position: cleanEnum(widget.position, defaults.widget.position, ["bottom-right", "bottom-left", "top-right", "top-left"]),
|
|
250
|
+
theme: cleanEnum(widget.theme, defaults.widget.theme, ["light", "dark", "system"]),
|
|
251
|
+
lazyLoad: cleanBoolean(widget.lazyLoad, defaults.widget.lazyLoad),
|
|
252
|
+
autoReconnect: cleanBoolean(widget.autoReconnect, defaults.widget.autoReconnect),
|
|
253
|
+
persistConversations: cleanBoolean(widget.persistConversations, defaults.widget.persistConversations),
|
|
254
|
+
showRetrivoraBranding: cleanBoolean(widget.showRetrivoraBranding, defaults.widget.showRetrivoraBranding)
|
|
255
|
+
},
|
|
256
|
+
telemetry: {
|
|
257
|
+
enabled: cleanBoolean(telemetry.enabled, defaults.telemetry.enabled),
|
|
258
|
+
collectBrowser: cleanBoolean(telemetry.collectBrowser, defaults.telemetry.collectBrowser),
|
|
259
|
+
collectCountry: cleanBoolean(telemetry.collectCountry, defaults.telemetry.collectCountry),
|
|
260
|
+
redactPii: cleanBoolean(telemetry.redactPii, defaults.telemetry.redactPii),
|
|
261
|
+
retentionDays: cleanNumber(telemetry.retentionDays, defaults.telemetry.retentionDays, 1, 365)
|
|
262
|
+
},
|
|
263
|
+
lifecycleHooks: cleanStringList(input == null ? void 0 : input.lifecycleHooks, defaults.lifecycleHooks, 30),
|
|
264
|
+
conversationFeatures: cleanStringList(input == null ? void 0 : input.conversationFeatures, defaults.conversationFeatures, 30),
|
|
265
|
+
updatedAt: input == null ? void 0 : input.updatedAt
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
var DEFAULT_LIFECYCLE_HOOKS, DEFAULT_CONVERSATION_FEATURES;
|
|
269
|
+
var init_ProjectSettings = __esm({
|
|
270
|
+
"src/core/ProjectSettings.ts"() {
|
|
271
|
+
"use strict";
|
|
272
|
+
DEFAULT_LIFECYCLE_HOOKS = [
|
|
273
|
+
"beforeInitialize",
|
|
274
|
+
"afterInitialize",
|
|
275
|
+
"beforeSend",
|
|
276
|
+
"afterResponse",
|
|
277
|
+
"onMessage",
|
|
278
|
+
"onCitationClick",
|
|
279
|
+
"onFeedback",
|
|
280
|
+
"onError",
|
|
281
|
+
"onReconnect",
|
|
282
|
+
"onFileUpload"
|
|
283
|
+
];
|
|
284
|
+
DEFAULT_CONVERSATION_FEATURES = [
|
|
285
|
+
"History",
|
|
286
|
+
"Resume",
|
|
287
|
+
"Search",
|
|
288
|
+
"Export",
|
|
289
|
+
"Rename",
|
|
290
|
+
"Delete",
|
|
291
|
+
"Tags",
|
|
292
|
+
"Pinned",
|
|
293
|
+
"Unread",
|
|
294
|
+
"Ratings"
|
|
295
|
+
];
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// package.json
|
|
300
|
+
var package_default;
|
|
301
|
+
var init_package = __esm({
|
|
302
|
+
"package.json"() {
|
|
303
|
+
package_default = {
|
|
304
|
+
name: "@retrivora-ai/rag-engine",
|
|
305
|
+
version: "2.3.7",
|
|
306
|
+
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
307
|
+
author: "Abhinav Alkuchi",
|
|
308
|
+
license: "UNLICENSED",
|
|
309
|
+
keywords: [
|
|
310
|
+
"rag",
|
|
311
|
+
"retrieval-augmented-generation",
|
|
312
|
+
"chatbot",
|
|
313
|
+
"vector-database",
|
|
314
|
+
"pinecone",
|
|
315
|
+
"pgvector",
|
|
316
|
+
"postgresql",
|
|
317
|
+
"milvus",
|
|
318
|
+
"qdrant",
|
|
319
|
+
"chromadb",
|
|
320
|
+
"redis",
|
|
321
|
+
"weaviate",
|
|
322
|
+
"mongodb",
|
|
323
|
+
"openai",
|
|
324
|
+
"anthropic",
|
|
325
|
+
"ollama",
|
|
326
|
+
"nextjs",
|
|
327
|
+
"react",
|
|
328
|
+
"ai",
|
|
329
|
+
"llm",
|
|
330
|
+
"embeddings"
|
|
331
|
+
],
|
|
332
|
+
main: "dist/index.js",
|
|
333
|
+
module: "dist/index.mjs",
|
|
334
|
+
types: "dist/index.d.ts",
|
|
335
|
+
exports: {
|
|
336
|
+
".": {
|
|
337
|
+
types: "./dist/index.d.ts",
|
|
338
|
+
require: "./dist/index.js",
|
|
339
|
+
import: "./dist/index.mjs"
|
|
340
|
+
},
|
|
341
|
+
"./style.css": "./dist/index.css",
|
|
342
|
+
"./index.css": "./dist/index.css",
|
|
343
|
+
"./styles.css": "./dist/index.css",
|
|
344
|
+
"./handlers": {
|
|
345
|
+
types: "./dist/handlers/index.d.ts",
|
|
346
|
+
require: "./dist/handlers/index.js",
|
|
347
|
+
import: "./dist/handlers/index.mjs"
|
|
348
|
+
},
|
|
349
|
+
"./server": {
|
|
350
|
+
types: "./dist/server.d.ts",
|
|
351
|
+
require: "./dist/server.js",
|
|
352
|
+
import: "./dist/server.mjs"
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
browser: {
|
|
356
|
+
child_process: false,
|
|
357
|
+
fs: false,
|
|
358
|
+
net: false,
|
|
359
|
+
tls: false,
|
|
360
|
+
crypto: false,
|
|
361
|
+
os: false,
|
|
362
|
+
path: false,
|
|
363
|
+
stream: false,
|
|
364
|
+
http: false,
|
|
365
|
+
https: false,
|
|
366
|
+
zlib: false,
|
|
367
|
+
mongodb: false,
|
|
368
|
+
pg: false,
|
|
369
|
+
"pdf-parse": false,
|
|
370
|
+
mammoth: false
|
|
371
|
+
},
|
|
372
|
+
files: [
|
|
373
|
+
"dist",
|
|
374
|
+
"src",
|
|
375
|
+
".env.example",
|
|
376
|
+
"README.md",
|
|
377
|
+
"FREE_TIER_ARCHITECTURE.md"
|
|
378
|
+
],
|
|
379
|
+
scripts: {
|
|
380
|
+
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",
|
|
381
|
+
build: "npm run build:pkg",
|
|
382
|
+
"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",
|
|
383
|
+
lint: "eslint",
|
|
384
|
+
typecheck: "tsc --noEmit -p tsconfig.build.json",
|
|
385
|
+
clean: "rm -rf dist"
|
|
386
|
+
},
|
|
387
|
+
peerDependencies: {
|
|
388
|
+
next: ">=15.0.0",
|
|
389
|
+
react: ">=18.0.0",
|
|
390
|
+
"react-dom": ">=18.0.0"
|
|
391
|
+
},
|
|
392
|
+
peerDependenciesMeta: {
|
|
393
|
+
next: {
|
|
394
|
+
optional: true
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
dependencies: {
|
|
398
|
+
"@anthropic-ai/sdk": "^0.95.1",
|
|
399
|
+
"@google/genai": "^0.8.0",
|
|
400
|
+
"@google/generative-ai": "^0.24.1",
|
|
401
|
+
"@pinecone-database/pinecone": "^7.2.0",
|
|
402
|
+
"@types/papaparse": "^5.5.2",
|
|
403
|
+
axios: "^1.15.0",
|
|
404
|
+
"lucide-react": "^1.8.0",
|
|
405
|
+
"next-themes": "^0.4.6",
|
|
406
|
+
openai: "^6.34.0",
|
|
407
|
+
papaparse: "^5.5.3",
|
|
408
|
+
"react-is": "^18.3.1",
|
|
409
|
+
"react-markdown": "^10.1.0",
|
|
410
|
+
recharts: "^3.8.1",
|
|
411
|
+
"remark-gfm": "^4.0.1",
|
|
412
|
+
xlsx: "^0.18.5"
|
|
413
|
+
},
|
|
414
|
+
optionalDependencies: {
|
|
415
|
+
"@langchain/core": "^1.1.42",
|
|
416
|
+
"@langchain/openai": "^1.4.5",
|
|
417
|
+
langchain: "^1.3.5",
|
|
418
|
+
llamaindex: "^0.11.9",
|
|
419
|
+
mammoth: "^1.8.0",
|
|
420
|
+
mongodb: "^7.1.1",
|
|
421
|
+
"pdf-parse": "^1.1.1",
|
|
422
|
+
pg: "^8.20.0"
|
|
423
|
+
},
|
|
424
|
+
devDependencies: {
|
|
425
|
+
"@tailwindcss/cli": "^4",
|
|
426
|
+
"@tailwindcss/postcss": "^4",
|
|
427
|
+
"@types/estree": "^1.0.9",
|
|
428
|
+
"@types/node": "^20",
|
|
429
|
+
"@types/pdf-parse": "^1.1.5",
|
|
430
|
+
"@types/pg": "^8.20.0",
|
|
431
|
+
"@types/react": "^19.2.14",
|
|
432
|
+
"@types/react-dom": "^19.2.3",
|
|
433
|
+
dotenv: "^17.4.2",
|
|
434
|
+
eslint: "^9",
|
|
435
|
+
"eslint-config-next": "16.2.4",
|
|
436
|
+
next: "16.2.10",
|
|
437
|
+
tailwindcss: "^4",
|
|
438
|
+
tsup: "^8.5.1",
|
|
439
|
+
typescript: "^5"
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
// src/version.ts
|
|
446
|
+
var SDK_VERSION;
|
|
447
|
+
var init_version = __esm({
|
|
448
|
+
"src/version.ts"() {
|
|
449
|
+
"use strict";
|
|
450
|
+
init_package();
|
|
451
|
+
SDK_VERSION = package_default.version || "2.1.3";
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
|
|
142
455
|
// src/core/ConfigFetcher.ts
|
|
143
456
|
var CONTROL_PLANE_URL, LLM_PROXY_BASE_URL, ConfigFetcher;
|
|
144
457
|
var init_ConfigFetcher = __esm({
|
|
145
458
|
"src/core/ConfigFetcher.ts"() {
|
|
146
459
|
"use strict";
|
|
460
|
+
init_ProjectSettings();
|
|
461
|
+
init_version();
|
|
147
462
|
CONTROL_PLANE_URL = "https://www.retrivora.com";
|
|
148
463
|
LLM_PROXY_BASE_URL = "https://www.retrivora.com/api/v1";
|
|
149
464
|
ConfigFetcher = class {
|
|
@@ -176,11 +491,12 @@ var init_ConfigFetcher = __esm({
|
|
|
176
491
|
].filter((url) => Boolean(url) && !url.includes("localhost") && !url.includes("127.0.0.1")).map((url) => url.replace(/\/$/, ""));
|
|
177
492
|
for (const baseUrl of controlPlaneUrls) {
|
|
178
493
|
try {
|
|
179
|
-
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}
|
|
494
|
+
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}`;
|
|
180
495
|
const res = await fetch(url, {
|
|
181
496
|
method: "GET",
|
|
182
497
|
headers: __spreadValues({
|
|
183
|
-
"Content-Type": "application/json"
|
|
498
|
+
"Content-Type": "application/json",
|
|
499
|
+
"x-sdk-version": SDK_VERSION
|
|
184
500
|
}, licenseKey ? { "x-license-key": licenseKey } : {})
|
|
185
501
|
});
|
|
186
502
|
if (res.ok) {
|
|
@@ -220,7 +536,11 @@ var init_ConfigFetcher = __esm({
|
|
|
220
536
|
workspace: data.workspace || {
|
|
221
537
|
namespace: fetchedProjectId,
|
|
222
538
|
indexName: data.vectorDb.indexName || "retrivora-free"
|
|
223
|
-
}
|
|
539
|
+
},
|
|
540
|
+
projectSettings: normalizeProjectSettings(
|
|
541
|
+
fetchedProjectId,
|
|
542
|
+
data.projectSettings || data.settings
|
|
543
|
+
)
|
|
224
544
|
};
|
|
225
545
|
this.cache.set(cacheKey, { config, cachedAt: now });
|
|
226
546
|
return config;
|
|
@@ -2306,10 +2626,6 @@ var LicenseVerifier = class {
|
|
|
2306
2626
|
static verify(licenseKey, currentProjectId, provider, publicKeyOverride) {
|
|
2307
2627
|
const isProduction = process.env.NODE_ENV === "production";
|
|
2308
2628
|
const now = Date.now();
|
|
2309
|
-
console.log(`[Retrivora SDK] LicenseVerifier.verify() - licenseKey`, licenseKey);
|
|
2310
|
-
console.log(`[Retrivora SDK] LicenseVerifier.verify() - currentProjectId`, currentProjectId);
|
|
2311
|
-
console.log(`[Retrivora SDK] LicenseVerifier.verify() - provider`, provider);
|
|
2312
|
-
console.log(`[Retrivora SDK] LicenseVerifier.verify() - publicKeyOverride`, publicKeyOverride);
|
|
2313
2629
|
if (licenseKey) {
|
|
2314
2630
|
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
2315
2631
|
const cached = this.cache.get(cacheKey);
|
|
@@ -2497,13 +2813,13 @@ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
|
|
|
2497
2813
|
// In production, this matches the private key held by Retrivora SaaS.
|
|
2498
2814
|
// Rotate this key only when the signing private key is replaced.
|
|
2499
2815
|
LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2816
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyKvvOSYdCimG3b236ebV
|
|
2817
|
+
jpG88xQiU8dSiaMahtBJDf4w0AewRj7hMNgmeZ1wyTOj8kVgeGBOolp1Z0QmTr6O
|
|
2818
|
+
Tj4EDQ/zjsg12If7hSf3NiwLHCYmMLslyK0aaP6PQoTrYkBv3GNdkMecrIjKCijb
|
|
2819
|
+
6VvDLLF3X696melTVM0z/d2e50BW2AlRw/rf1EqYi10d0BcPo5zje0XETr/WGmqu
|
|
2820
|
+
sDiXtsP5MlwkL9X7RQY2uovRa+l/vOAqAfdmJ+OzXuk5P7mDUPb+gCtKnoDbb1tr
|
|
2821
|
+
6UAu733dkUnetAcMqyT3fNPBLO66DCc6m9rGCYYAaG7piMEDwG0/ZySZBFbgllJc
|
|
2822
|
+
6QIDAQAB
|
|
2507
2823
|
-----END PUBLIC KEY-----`;
|
|
2508
2824
|
|
|
2509
2825
|
// src/config/constants.ts
|
|
@@ -2552,6 +2868,7 @@ var PROVIDERS_WITH_EMBEDDINGS = [
|
|
|
2552
2868
|
var UI_BORDER_RADIUS_OPTIONS = ["none", "sm", "md", "lg", "xl", "full"];
|
|
2553
2869
|
|
|
2554
2870
|
// src/config/serverConfig.ts
|
|
2871
|
+
var _runtimeConfig = null;
|
|
2555
2872
|
function readString(env, name) {
|
|
2556
2873
|
var _a3;
|
|
2557
2874
|
const value = (_a3 = env[name]) == null ? void 0 : _a3.trim();
|
|
@@ -2575,7 +2892,7 @@ function readEnum(env, name, fallback, allowed) {
|
|
|
2575
2892
|
throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
|
|
2576
2893
|
}
|
|
2577
2894
|
function getEnvConfig(env = process.env, base) {
|
|
2578
|
-
var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb, _xb, _yb, _zb, _Ab, _Bb, _Cb, _Db, _Eb, _Fb, _Gb, _Hb
|
|
2895
|
+
var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb, _xb, _yb, _zb, _Ab, _Bb, _Cb, _Db, _Eb, _Fb, _Gb, _Hb;
|
|
2579
2896
|
const licenseKey = (_d = (_c = (_b = (_a3 = readString(env, "RAG_LICENSE_KEY")) != null ? _a3 : readString(env, "RETRIVORA_LICENSE_KEY")) != null ? _b : readString(env, "NEXT_PUBLIC_RETRIVORA_LICENSE_KEY")) != null ? _c : readString(env, "LICENSE_KEY")) != null ? _d : base == null ? void 0 : base.licenseKey;
|
|
2580
2897
|
const jwtProjectId = (() => {
|
|
2581
2898
|
if (!licenseKey) return void 0;
|
|
@@ -2667,25 +2984,35 @@ function getEnvConfig(env = process.env, base) {
|
|
|
2667
2984
|
return true;
|
|
2668
2985
|
}
|
|
2669
2986
|
})();
|
|
2670
|
-
const
|
|
2671
|
-
const
|
|
2672
|
-
const
|
|
2673
|
-
const
|
|
2674
|
-
const
|
|
2675
|
-
const
|
|
2676
|
-
const
|
|
2677
|
-
const
|
|
2678
|
-
const
|
|
2679
|
-
const
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2987
|
+
const tierBasedLLMModel = isFreeTier2 ? "llama-3.1-8b-instant" : "llama-3.3-70b-versatile";
|
|
2988
|
+
const tierBasedEmbeddingModel = isFreeTier2 ? "text-embedding-004" : "text-embedding-004";
|
|
2989
|
+
const defaultGatewayUrl = "https://llm.retrivora.com/api/v1";
|
|
2990
|
+
const rt = _runtimeConfig;
|
|
2991
|
+
const defaultLlmProvider = "universal_rest";
|
|
2992
|
+
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;
|
|
2993
|
+
const llmBaseUrl = (_xa = (_wa = (_va = (_ta = readString(env, "LITELLM_BASE_URL")) != null ? _ta : readString(env, "LLM_BASE_URL")) != null ? _va : (_ua = base == null ? void 0 : base.llm) == null ? void 0 : _ua.baseUrl) != null ? _wa : rt == null ? void 0 : rt.llmBaseUrl) != null ? _xa : defaultGatewayUrl;
|
|
2994
|
+
const llmModel = (_Ba = (_Aa = (_za = readString(env, "LLM_MODEL")) != null ? _za : (_ya = base == null ? void 0 : base.llm) == null ? void 0 : _ya.model) != null ? _Aa : rt == null ? void 0 : rt.llmModel) != null ? _Ba : tierBasedLLMModel;
|
|
2995
|
+
const llmApiKey = (_Fa = (_Ea = (_Ca = readString(env, "LITELLM_MASTER_KEY")) != null ? _Ca : rt == null ? void 0 : rt.litellmApiKey) != null ? _Ea : (_Da = base == null ? void 0 : base.llm) == null ? void 0 : _Da.apiKey) != null ? _Fa : licenseKey;
|
|
2996
|
+
const llmProfile = (_Ja = (_Ia = readString(env, "LLM_UNIVERSAL_PROFILE")) != null ? _Ia : (_Ha = (_Ga = base == null ? void 0 : base.llm) == null ? void 0 : _Ga.options) == null ? void 0 : _Ha.profile) != null ? _Ja : "litellm";
|
|
2997
|
+
console.log("[serverConfig] \u{1F527} LLM Configuration:", {
|
|
2998
|
+
baseUrl: llmBaseUrl,
|
|
2999
|
+
model: llmModel,
|
|
3000
|
+
provider: llmProvider,
|
|
3001
|
+
hasApiKey: !!llmApiKey,
|
|
3002
|
+
source: (rt == null ? void 0 : rt.llmModel) ? "runtime-injected" : "env/fallback"
|
|
3003
|
+
});
|
|
3004
|
+
const defaultEmbeddingProvider = "universal_rest";
|
|
3005
|
+
const embeddingProvider = (_Ma = (_La = readEnum(env, "EMBEDDING_PROVIDER", defaultEmbeddingProvider, EMBEDDING_PROVIDERS)) != null ? _La : (_Ka = base == null ? void 0 : base.embedding) == null ? void 0 : _Ka.provider) != null ? _Ma : defaultEmbeddingProvider;
|
|
3006
|
+
const embeddingBaseUrl = (_Ta = (_Sa = (_Ra = (_Qa = (_Oa = (_Na = readString(env, "LITELLM_BASE_URL")) != null ? _Na : readString(env, "EMBEDDING_BASE_URL")) != null ? _Oa : readString(env, "LLM_BASE_URL")) != null ? _Qa : (_Pa = base == null ? void 0 : base.embedding) == null ? void 0 : _Pa.baseUrl) != null ? _Ra : rt == null ? void 0 : rt.embeddingBaseUrl) != null ? _Sa : rt == null ? void 0 : rt.llmBaseUrl) != null ? _Ta : defaultGatewayUrl;
|
|
3007
|
+
const embeddingModel = (_Xa = (_Wa = (_Va = readString(env, "EMBEDDING_MODEL")) != null ? _Va : (_Ua = base == null ? void 0 : base.embedding) == null ? void 0 : _Ua.model) != null ? _Wa : rt == null ? void 0 : rt.embeddingModel) != null ? _Xa : tierBasedEmbeddingModel;
|
|
3008
|
+
const embeddingApiKey = (_$a = (__a = (_Ya = readString(env, "LITELLM_MASTER_KEY")) != null ? _Ya : rt == null ? void 0 : rt.litellmApiKey) != null ? __a : (_Za = base == null ? void 0 : base.embedding) == null ? void 0 : _Za.apiKey) != null ? _$a : licenseKey;
|
|
3009
|
+
const embeddingProfile = (_db = (_cb = readString(env, "EMBEDDING_UNIVERSAL_PROFILE")) != null ? _cb : (_bb = (_ab = base == null ? void 0 : base.embedding) == null ? void 0 : _ab.options) == null ? void 0 : _bb.profile) != null ? _db : "litellm";
|
|
2683
3010
|
return __spreadProps(__spreadValues({
|
|
2684
3011
|
projectId,
|
|
2685
3012
|
licenseKey,
|
|
2686
3013
|
vectorDb: {
|
|
2687
3014
|
provider: vectorProvider,
|
|
2688
|
-
indexName: (
|
|
3015
|
+
indexName: (_fb = (_eb = readString(env, "VECTOR_DB_INDEX")) != null ? _eb : vectorDbOptions.indexName) != null ? _fb : "rag-index",
|
|
2689
3016
|
options: vectorDbOptions
|
|
2690
3017
|
},
|
|
2691
3018
|
llm: {
|
|
@@ -2715,30 +3042,30 @@ function getEnvConfig(env = process.env, base) {
|
|
|
2715
3042
|
}
|
|
2716
3043
|
},
|
|
2717
3044
|
ui: {
|
|
2718
|
-
title: (
|
|
2719
|
-
subtitle: (
|
|
2720
|
-
primaryColor: (
|
|
2721
|
-
accentColor: (
|
|
2722
|
-
logoUrl: (
|
|
2723
|
-
placeholder: (
|
|
2724
|
-
showSources: ((
|
|
2725
|
-
welcomeMessage: (
|
|
2726
|
-
visualStyle: (
|
|
2727
|
-
borderRadius: (
|
|
2728
|
-
allowUpload: ((
|
|
3045
|
+
title: (_hb = (_gb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _gb : readString(env, "UI_TITLE")) != null ? _hb : "AI Assistant",
|
|
3046
|
+
subtitle: (_jb = (_ib = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _ib : readString(env, "UI_SUBTITLE")) != null ? _jb : "Powered by RAG",
|
|
3047
|
+
primaryColor: (_lb = (_kb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _kb : readString(env, "UI_PRIMARY_COLOR")) != null ? _lb : "#10b981",
|
|
3048
|
+
accentColor: (_nb = (_mb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _mb : readString(env, "UI_ACCENT_COLOR")) != null ? _nb : "#3b82f6",
|
|
3049
|
+
logoUrl: (_ob = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _ob : readString(env, "UI_LOGO_URL"),
|
|
3050
|
+
placeholder: (_qb = (_pb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _pb : readString(env, "UI_PLACEHOLDER")) != null ? _qb : "Ask me anything\u2026",
|
|
3051
|
+
showSources: ((_sb = (_rb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _rb : readString(env, "UI_SHOW_SOURCES")) != null ? _sb : "true") !== "false",
|
|
3052
|
+
welcomeMessage: (_ub = (_tb = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _tb : readString(env, "UI_WELCOME_MESSAGE")) != null ? _ub : "Hello! I'm your AI assistant. Ask me anything about your documents.",
|
|
3053
|
+
visualStyle: (_wb = (_vb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _vb : readString(env, "UI_VISUAL_STYLE")) != null ? _wb : "glass",
|
|
3054
|
+
borderRadius: (_yb = (_xb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _xb : readString(env, "UI_BORDER_RADIUS")) != null ? _yb : "xl",
|
|
3055
|
+
allowUpload: ((_Ab = (_zb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _zb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Ab : "false") === "true"
|
|
2729
3056
|
},
|
|
2730
3057
|
rag: {
|
|
2731
3058
|
topK: readNumber(env, "RAG_TOP_K", 5),
|
|
2732
3059
|
scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
|
|
2733
3060
|
chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
|
|
2734
3061
|
chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
|
|
2735
|
-
filterableFields: (
|
|
3062
|
+
filterableFields: (_Bb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Bb.split(",").map((f) => f.trim()),
|
|
2736
3063
|
// Query pipeline toggles — read from .env.local
|
|
2737
3064
|
useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
|
|
2738
3065
|
useReranking: readString(env, "RAG_USE_RERANKING") === "true",
|
|
2739
3066
|
useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
|
|
2740
|
-
architecture: (
|
|
2741
|
-
chunkingStrategy: (
|
|
3067
|
+
architecture: (_Cb = readString(env, "RAG_ARCHITECTURE")) != null ? _Cb : "simple",
|
|
3068
|
+
chunkingStrategy: (_Db = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Db : "recursive",
|
|
2742
3069
|
uiMapping: (() => {
|
|
2743
3070
|
const raw = readString(env, "RAG_UI_MAPPING");
|
|
2744
3071
|
if (!raw) return void 0;
|
|
@@ -2751,7 +3078,7 @@ function getEnvConfig(env = process.env, base) {
|
|
|
2751
3078
|
},
|
|
2752
3079
|
telemetry: {
|
|
2753
3080
|
enabled: telemetryEnabled,
|
|
2754
|
-
url: (
|
|
3081
|
+
url: (_Hb = (_Gb = (_Eb = readString(env, "TELEMETRY_URL")) != null ? _Eb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Gb : (_Fb = base == null ? void 0 : base.telemetry) == null ? void 0 : _Fb.url) != null ? _Hb : "https://www.retrivora.com/api/telemetry"
|
|
2755
3082
|
}
|
|
2756
3083
|
}, readString(env, "GRAPH_DB_PROVIDER") ? {
|
|
2757
3084
|
graphDb: {
|
|
@@ -2800,6 +3127,7 @@ var ConfigResolver = class {
|
|
|
2800
3127
|
options: __spreadValues(__spreadValues({}, envConfig.embedding.options || {}), hostConfig.embedding.options || {})
|
|
2801
3128
|
}) : envConfig.embedding,
|
|
2802
3129
|
ui: hostConfig.ui ? mergeDefined(envConfig.ui, hostConfig.ui) : envConfig.ui,
|
|
3130
|
+
projectSettings: hostConfig.projectSettings || envConfig.projectSettings,
|
|
2803
3131
|
rag: hostConfig.rag ? __spreadValues(__spreadValues({}, envConfig.rag), hostConfig.rag) : envConfig.rag,
|
|
2804
3132
|
telemetry: hostConfig.telemetry ? __spreadValues(__spreadValues({}, envConfig.telemetry), hostConfig.telemetry) : envConfig.telemetry
|
|
2805
3133
|
});
|
|
@@ -4068,7 +4396,7 @@ var UniversalLLMAdapter = class {
|
|
|
4068
4396
|
});
|
|
4069
4397
|
}
|
|
4070
4398
|
async chat(messages, context) {
|
|
4071
|
-
var _a3, _b, _c, _d, _e;
|
|
4399
|
+
var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j;
|
|
4072
4400
|
const path2 = (_a3 = this.opts.chatPath) != null ? _a3 : "/chat/completions";
|
|
4073
4401
|
const safeMessages = (Array.isArray(messages) ? messages : []).filter((m) => Boolean(m && typeof m === "object")).map((m) => ({
|
|
4074
4402
|
role: m.role || "user",
|
|
@@ -4098,16 +4426,27 @@ ${context != null ? context : "None"}` },
|
|
|
4098
4426
|
};
|
|
4099
4427
|
}
|
|
4100
4428
|
try {
|
|
4429
|
+
console.debug(`[UniversalLLMAdapter] POST ${this.baseUrl}${path2}`);
|
|
4430
|
+
console.debug(`[UniversalLLMAdapter] Model: ${this.model}`);
|
|
4431
|
+
console.debug(`[UniversalLLMAdapter] Auth: Bearer ${((_b = this.apiKey) == null ? void 0 : _b.substring(0, 20)) || "none"}...`);
|
|
4101
4432
|
const { data: data2 } = await this.http.post(path2, payload);
|
|
4102
|
-
const extractPath2 = (
|
|
4103
|
-
const result2 = (
|
|
4433
|
+
const extractPath2 = (_c = this.opts.responseExtractPath) != null ? _c : "choices[0].message.content";
|
|
4434
|
+
const result2 = (_d = resolvePath(data2, extractPath2)) != null ? _d : extractContent(data2);
|
|
4104
4435
|
if (result2 !== void 0) {
|
|
4105
4436
|
return String(result2);
|
|
4106
4437
|
}
|
|
4107
4438
|
} catch (httpErr) {
|
|
4108
|
-
|
|
4109
|
-
|
|
4439
|
+
console.error("[UniversalLLMAdapter] \u274C HTTP chat request failed:", {
|
|
4440
|
+
status: (_e = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _e.status,
|
|
4441
|
+
statusText: (_f = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _f.statusText,
|
|
4442
|
+
url: (_g2 = httpErr == null ? void 0 : httpErr.config) == null ? void 0 : _g2.url,
|
|
4443
|
+
errorData: (_h = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _h.data,
|
|
4444
|
+
message: httpErr == null ? void 0 : httpErr.message
|
|
4445
|
+
});
|
|
4446
|
+
const _g3 = globalThis;
|
|
4447
|
+
const dispatch = _g3.__retrivoraDispatchChat;
|
|
4110
4448
|
if (typeof dispatch === "function") {
|
|
4449
|
+
console.debug("[UniversalLLMAdapter] \u{1F504} Attempting in-process fallback dispatch");
|
|
4111
4450
|
const res = await dispatch({
|
|
4112
4451
|
model: this.model,
|
|
4113
4452
|
messages: formattedMessages,
|
|
@@ -4122,8 +4461,8 @@ ${context != null ? context : "None"}` },
|
|
|
4122
4461
|
throw httpErr;
|
|
4123
4462
|
}
|
|
4124
4463
|
const { data } = await this.http.post(path2, payload);
|
|
4125
|
-
const extractPath = (
|
|
4126
|
-
const result = (
|
|
4464
|
+
const extractPath = (_i = this.opts.responseExtractPath) != null ? _i : "choices[0].message.content";
|
|
4465
|
+
const result = (_j = resolvePath(data, extractPath)) != null ? _j : extractContent(data);
|
|
4127
4466
|
if (result === void 0) {
|
|
4128
4467
|
throw new Error(`[UniversalLLMAdapter] Could not extract text from path '${extractPath}' in response.`);
|
|
4129
4468
|
}
|
|
@@ -4262,36 +4601,70 @@ ${context != null ? context : "None"}` },
|
|
|
4262
4601
|
});
|
|
4263
4602
|
}
|
|
4264
4603
|
async embed(text) {
|
|
4265
|
-
var _a3, _b, _c, _d, _e;
|
|
4604
|
+
var _a3, _b, _c, _d, _e, _f, _g2;
|
|
4266
4605
|
const path2 = (_a3 = this.opts.embedPath) != null ? _a3 : "/embeddings";
|
|
4267
4606
|
const payload = this.opts.embedPayloadTemplate ? buildPayload(this.opts.embedPayloadTemplate, { input: text, model: this.model }) : { input: text, model: this.model };
|
|
4268
4607
|
try {
|
|
4269
|
-
const { data
|
|
4270
|
-
const
|
|
4271
|
-
const
|
|
4272
|
-
if (Array.isArray(
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4608
|
+
const { data } = await this.http.post(path2, payload);
|
|
4609
|
+
const extractPath = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
|
|
4610
|
+
const vector = resolvePath(data, extractPath);
|
|
4611
|
+
if (Array.isArray(vector)) return vector;
|
|
4612
|
+
console.warn(
|
|
4613
|
+
`[UniversalLLMAdapter] Embedding API returned unexpected format for path '${extractPath}'. Response:`,
|
|
4614
|
+
data
|
|
4615
|
+
);
|
|
4616
|
+
} catch (err) {
|
|
4617
|
+
console.warn(
|
|
4618
|
+
`[UniversalLLMAdapter] HTTP embedding request failed: ${(err == null ? void 0 : err.message) || err}`,
|
|
4619
|
+
{ path: path2, model: this.model }
|
|
4620
|
+
);
|
|
4621
|
+
const _g3 = globalThis;
|
|
4622
|
+
const dispatchEmbed = _g3.__retrivoraDispatchEmbedding;
|
|
4276
4623
|
if (typeof dispatchEmbed === "function") {
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4624
|
+
try {
|
|
4625
|
+
const res = await dispatchEmbed({ input: text, model: this.model }, this.apiKey);
|
|
4626
|
+
if ((_d = (_c = res == null ? void 0 : res.data) == null ? void 0 : _c[0]) == null ? void 0 : _d.embedding) {
|
|
4627
|
+
return res.data[0].embedding;
|
|
4628
|
+
}
|
|
4629
|
+
} catch (dispatchErr) {
|
|
4630
|
+
console.warn("[UniversalLLMAdapter] In-process dispatch embedding failed:", dispatchErr);
|
|
4280
4631
|
}
|
|
4281
4632
|
}
|
|
4282
4633
|
}
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4634
|
+
try {
|
|
4635
|
+
const { data } = await this.http.post(path2, payload);
|
|
4636
|
+
const extractPath = (_e = this.opts.embedExtractPath) != null ? _e : "data[0].embedding";
|
|
4637
|
+
const vector = resolvePath(data, extractPath);
|
|
4638
|
+
if (Array.isArray(vector)) {
|
|
4639
|
+
return vector;
|
|
4640
|
+
}
|
|
4641
|
+
console.error(
|
|
4642
|
+
`[UniversalLLMAdapter] Retry embedding failed: unexpected response format for path '${extractPath}'. Response:`,
|
|
4643
|
+
data
|
|
4644
|
+
);
|
|
4645
|
+
throw new Error(
|
|
4646
|
+
`[UniversalLLMAdapter] Could not extract embedding vector. Expected array at '${extractPath}', got: ${typeof vector}. Response keys: ${Object.keys(data || {})}.`
|
|
4647
|
+
);
|
|
4648
|
+
} catch (err) {
|
|
4649
|
+
console.error(
|
|
4650
|
+
`[UniversalLLMAdapter] Both embedding attempts failed. Path: ${path2}, Model: ${this.model}`,
|
|
4651
|
+
{ error: err == null ? void 0 : err.message, statusCode: (_f = err == null ? void 0 : err.response) == null ? void 0 : _f.status, response: (_g2 = err == null ? void 0 : err.response) == null ? void 0 : _g2.data }
|
|
4652
|
+
);
|
|
4653
|
+
throw new Error(
|
|
4654
|
+
`[UniversalLLMAdapter] Failed to generate embedding after 2 attempts: ${(err == null ? void 0 : err.message) || err}`
|
|
4655
|
+
);
|
|
4288
4656
|
}
|
|
4289
|
-
return vector;
|
|
4290
4657
|
}
|
|
4291
4658
|
async batchEmbed(texts) {
|
|
4292
4659
|
const results = [];
|
|
4293
4660
|
for (const text of texts) {
|
|
4294
|
-
|
|
4661
|
+
try {
|
|
4662
|
+
const vector = await this.embed(text);
|
|
4663
|
+
results.push(vector);
|
|
4664
|
+
} catch (err) {
|
|
4665
|
+
console.warn(`[UniversalLLMAdapter] batchEmbed failed for text (first 50 chars): ${text.slice(0, 50)}...`, err);
|
|
4666
|
+
throw err;
|
|
4667
|
+
}
|
|
4295
4668
|
}
|
|
4296
4669
|
return results;
|
|
4297
4670
|
}
|
|
@@ -4702,149 +5075,8 @@ var ConfigValidator = class {
|
|
|
4702
5075
|
}
|
|
4703
5076
|
};
|
|
4704
5077
|
|
|
4705
|
-
//
|
|
4706
|
-
|
|
4707
|
-
name: "@retrivora-ai/rag-engine",
|
|
4708
|
-
version: "2.3.5",
|
|
4709
|
-
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
4710
|
-
author: "Abhinav Alkuchi",
|
|
4711
|
-
license: "UNLICENSED",
|
|
4712
|
-
keywords: [
|
|
4713
|
-
"rag",
|
|
4714
|
-
"retrieval-augmented-generation",
|
|
4715
|
-
"chatbot",
|
|
4716
|
-
"vector-database",
|
|
4717
|
-
"pinecone",
|
|
4718
|
-
"pgvector",
|
|
4719
|
-
"postgresql",
|
|
4720
|
-
"milvus",
|
|
4721
|
-
"qdrant",
|
|
4722
|
-
"chromadb",
|
|
4723
|
-
"redis",
|
|
4724
|
-
"weaviate",
|
|
4725
|
-
"mongodb",
|
|
4726
|
-
"openai",
|
|
4727
|
-
"anthropic",
|
|
4728
|
-
"ollama",
|
|
4729
|
-
"nextjs",
|
|
4730
|
-
"react",
|
|
4731
|
-
"ai",
|
|
4732
|
-
"llm",
|
|
4733
|
-
"embeddings"
|
|
4734
|
-
],
|
|
4735
|
-
main: "dist/index.js",
|
|
4736
|
-
module: "dist/index.mjs",
|
|
4737
|
-
types: "dist/index.d.ts",
|
|
4738
|
-
exports: {
|
|
4739
|
-
".": {
|
|
4740
|
-
types: "./dist/index.d.ts",
|
|
4741
|
-
require: "./dist/index.js",
|
|
4742
|
-
import: "./dist/index.mjs"
|
|
4743
|
-
},
|
|
4744
|
-
"./style.css": "./dist/index.css",
|
|
4745
|
-
"./index.css": "./dist/index.css",
|
|
4746
|
-
"./styles.css": "./dist/index.css",
|
|
4747
|
-
"./handlers": {
|
|
4748
|
-
types: "./dist/handlers/index.d.ts",
|
|
4749
|
-
require: "./dist/handlers/index.js",
|
|
4750
|
-
import: "./dist/handlers/index.mjs"
|
|
4751
|
-
},
|
|
4752
|
-
"./server": {
|
|
4753
|
-
types: "./dist/server.d.ts",
|
|
4754
|
-
require: "./dist/server.js",
|
|
4755
|
-
import: "./dist/server.mjs"
|
|
4756
|
-
}
|
|
4757
|
-
},
|
|
4758
|
-
browser: {
|
|
4759
|
-
child_process: false,
|
|
4760
|
-
fs: false,
|
|
4761
|
-
net: false,
|
|
4762
|
-
tls: false,
|
|
4763
|
-
crypto: false,
|
|
4764
|
-
os: false,
|
|
4765
|
-
path: false,
|
|
4766
|
-
stream: false,
|
|
4767
|
-
http: false,
|
|
4768
|
-
https: false,
|
|
4769
|
-
zlib: false,
|
|
4770
|
-
mongodb: false,
|
|
4771
|
-
pg: false,
|
|
4772
|
-
"pdf-parse": false,
|
|
4773
|
-
mammoth: false
|
|
4774
|
-
},
|
|
4775
|
-
files: [
|
|
4776
|
-
"dist",
|
|
4777
|
-
"src",
|
|
4778
|
-
".env.example",
|
|
4779
|
-
"README.md",
|
|
4780
|
-
"FREE_TIER_ARCHITECTURE.md"
|
|
4781
|
-
],
|
|
4782
|
-
scripts: {
|
|
4783
|
-
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",
|
|
4784
|
-
build: "npm run build:pkg",
|
|
4785
|
-
"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",
|
|
4786
|
-
lint: "eslint",
|
|
4787
|
-
typecheck: "tsc --noEmit -p tsconfig.build.json",
|
|
4788
|
-
clean: "rm -rf dist"
|
|
4789
|
-
},
|
|
4790
|
-
peerDependencies: {
|
|
4791
|
-
next: ">=15.0.0",
|
|
4792
|
-
react: ">=18.0.0",
|
|
4793
|
-
"react-dom": ">=18.0.0"
|
|
4794
|
-
},
|
|
4795
|
-
peerDependenciesMeta: {
|
|
4796
|
-
next: {
|
|
4797
|
-
optional: true
|
|
4798
|
-
}
|
|
4799
|
-
},
|
|
4800
|
-
dependencies: {
|
|
4801
|
-
"@anthropic-ai/sdk": "^0.95.1",
|
|
4802
|
-
"@google/genai": "^0.8.0",
|
|
4803
|
-
"@google/generative-ai": "^0.24.1",
|
|
4804
|
-
"@pinecone-database/pinecone": "^7.2.0",
|
|
4805
|
-
"@types/papaparse": "^5.5.2",
|
|
4806
|
-
axios: "^1.15.0",
|
|
4807
|
-
"lucide-react": "^1.8.0",
|
|
4808
|
-
"next-themes": "^0.4.6",
|
|
4809
|
-
openai: "^6.34.0",
|
|
4810
|
-
papaparse: "^5.5.3",
|
|
4811
|
-
"react-is": "^18.3.1",
|
|
4812
|
-
"react-markdown": "^10.1.0",
|
|
4813
|
-
recharts: "^3.8.1",
|
|
4814
|
-
"remark-gfm": "^4.0.1",
|
|
4815
|
-
xlsx: "^0.18.5"
|
|
4816
|
-
},
|
|
4817
|
-
optionalDependencies: {
|
|
4818
|
-
"@langchain/core": "^1.1.42",
|
|
4819
|
-
"@langchain/openai": "^1.4.5",
|
|
4820
|
-
langchain: "^1.3.5",
|
|
4821
|
-
llamaindex: "^0.11.9",
|
|
4822
|
-
mammoth: "^1.8.0",
|
|
4823
|
-
mongodb: "^7.1.1",
|
|
4824
|
-
"pdf-parse": "^1.1.1",
|
|
4825
|
-
pg: "^8.20.0"
|
|
4826
|
-
},
|
|
4827
|
-
devDependencies: {
|
|
4828
|
-
"@tailwindcss/cli": "^4",
|
|
4829
|
-
"@tailwindcss/postcss": "^4",
|
|
4830
|
-
"@types/estree": "^1.0.9",
|
|
4831
|
-
"@types/node": "^20",
|
|
4832
|
-
"@types/pdf-parse": "^1.1.5",
|
|
4833
|
-
"@types/pg": "^8.20.0",
|
|
4834
|
-
"@types/react": "^19.2.14",
|
|
4835
|
-
"@types/react-dom": "^19.2.3",
|
|
4836
|
-
dotenv: "^17.4.2",
|
|
4837
|
-
eslint: "^9",
|
|
4838
|
-
"eslint-config-next": "16.2.4",
|
|
4839
|
-
next: "16.2.10",
|
|
4840
|
-
tailwindcss: "^4",
|
|
4841
|
-
tsup: "^8.5.1",
|
|
4842
|
-
typescript: "^5"
|
|
4843
|
-
}
|
|
4844
|
-
};
|
|
4845
|
-
|
|
4846
|
-
// src/version.ts
|
|
4847
|
-
var SDK_VERSION = package_default.version || "2.1.3";
|
|
5078
|
+
// src/core/Pipeline.ts
|
|
5079
|
+
init_version();
|
|
4848
5080
|
|
|
4849
5081
|
// src/rag/DocumentChunker.ts
|
|
4850
5082
|
var DocumentChunker = class {
|
|
@@ -10513,6 +10745,7 @@ var DatabaseStorage = class {
|
|
|
10513
10745
|
};
|
|
10514
10746
|
|
|
10515
10747
|
// src/handlers/index.ts
|
|
10748
|
+
init_version();
|
|
10516
10749
|
async function checkAuth(req, onAuthorize) {
|
|
10517
10750
|
if (!onAuthorize) return null;
|
|
10518
10751
|
try {
|
|
@@ -10644,6 +10877,35 @@ function enforceLicense(req, config, bodyLicenseKey) {
|
|
|
10644
10877
|
};
|
|
10645
10878
|
}
|
|
10646
10879
|
}
|
|
10880
|
+
function getAllowedNamespaces(projectId) {
|
|
10881
|
+
const trimmed = projectId.trim();
|
|
10882
|
+
const withoutPrefix = trimmed.startsWith("retrivora-") ? trimmed.replace(/^retrivora-/, "") : trimmed;
|
|
10883
|
+
return new Set([
|
|
10884
|
+
trimmed,
|
|
10885
|
+
withoutPrefix,
|
|
10886
|
+
`retrivora-${withoutPrefix}`
|
|
10887
|
+
].filter(Boolean));
|
|
10888
|
+
}
|
|
10889
|
+
function resolveLicensedNamespace(payload, requestedNamespace) {
|
|
10890
|
+
const allowed = getAllowedNamespaces(payload.projectId);
|
|
10891
|
+
const requested = requestedNamespace == null ? void 0 : requestedNamespace.trim();
|
|
10892
|
+
if (requested && !allowed.has(requested)) {
|
|
10893
|
+
return {
|
|
10894
|
+
ok: false,
|
|
10895
|
+
response: new Response(JSON.stringify({
|
|
10896
|
+
error: {
|
|
10897
|
+
code: "NAMESPACE_FORBIDDEN",
|
|
10898
|
+
message: "Requested namespace is not authorized for this license."
|
|
10899
|
+
}
|
|
10900
|
+
}), {
|
|
10901
|
+
status: 403,
|
|
10902
|
+
headers: { "Content-Type": "application/json" }
|
|
10903
|
+
})
|
|
10904
|
+
};
|
|
10905
|
+
}
|
|
10906
|
+
const defaultNamespace = payload.projectId.startsWith("retrivora-") ? payload.projectId : `retrivora-${payload.projectId}`;
|
|
10907
|
+
return { ok: true, namespace: requested || defaultNamespace };
|
|
10908
|
+
}
|
|
10647
10909
|
var MAX_MESSAGE_LENGTH = 8e3;
|
|
10648
10910
|
function sanitizeInput(raw) {
|
|
10649
10911
|
const stripped = raw.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g, "");
|
|
@@ -10804,6 +11066,8 @@ function createChatHandler(configOrPlugin, options) {
|
|
|
10804
11066
|
}
|
|
10805
11067
|
const history = bodyObj.history || (Array.isArray(bodyObj.messages) ? bodyObj.messages.slice(0, -1) : []);
|
|
10806
11068
|
const { namespace, sessionId = "default", messageId, userMessageId } = bodyObj;
|
|
11069
|
+
const namespaceCheck = resolveLicensedNamespace(licenseCheck.payload, namespace);
|
|
11070
|
+
if (!namespaceCheck.ok) return namespaceCheck.response;
|
|
10807
11071
|
const sanitized = sanitizeInput(rawMessage != null ? rawMessage : "");
|
|
10808
11072
|
if (!sanitized.ok) {
|
|
10809
11073
|
return NextResponse.json({ error: { code: "INVALID_INPUT", message: sanitized.error } }, { status: 400 });
|
|
@@ -10815,7 +11079,7 @@ function createChatHandler(configOrPlugin, options) {
|
|
|
10815
11079
|
role: "user",
|
|
10816
11080
|
content: message
|
|
10817
11081
|
}).catch((err) => console.warn("[createChatHandler] Failed to save user message:", err));
|
|
10818
|
-
const result = await plugin.chat(message, history, namespace);
|
|
11082
|
+
const result = await plugin.chat(message, history, namespaceCheck.namespace);
|
|
10819
11083
|
const assistantMsgId = messageId || `assistant_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`;
|
|
10820
11084
|
await storage.saveMessage(sessionId, {
|
|
10821
11085
|
id: assistantMsgId,
|
|
@@ -10896,6 +11160,8 @@ function createStreamHandler(configOrPlugin, options) {
|
|
|
10896
11160
|
}
|
|
10897
11161
|
const history = bodyObj.history || (Array.isArray(bodyObj.messages) ? bodyObj.messages.slice(0, -1) : []);
|
|
10898
11162
|
const { namespace, sessionId = "default", messageId, userMessageId } = bodyObj;
|
|
11163
|
+
const namespaceCheck = resolveLicensedNamespace(licenseCheck.payload, namespace);
|
|
11164
|
+
if (!namespaceCheck.ok) return namespaceCheck.response;
|
|
10899
11165
|
const sanitized = sanitizeInput(rawMessage != null ? rawMessage : "");
|
|
10900
11166
|
if (!sanitized.ok) {
|
|
10901
11167
|
return new Response(
|
|
@@ -10925,7 +11191,7 @@ function createStreamHandler(configOrPlugin, options) {
|
|
|
10925
11191
|
}
|
|
10926
11192
|
};
|
|
10927
11193
|
try {
|
|
10928
|
-
const pipelineStream = plugin.chatStream(message, history, namespace);
|
|
11194
|
+
const pipelineStream = plugin.chatStream(message, history, namespaceCheck.namespace);
|
|
10929
11195
|
let fullReply = "";
|
|
10930
11196
|
try {
|
|
10931
11197
|
for (var iter = __forAwait(pipelineStream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
|
|
@@ -11031,6 +11297,8 @@ function createIngestHandler(configOrPlugin, options) {
|
|
|
11031
11297
|
if (!Array.isArray(documents) || documents.length === 0) {
|
|
11032
11298
|
return NextResponse.json({ error: "documents array is required" }, { status: 400 });
|
|
11033
11299
|
}
|
|
11300
|
+
const namespaceCheck = resolveLicensedNamespace(licenseCheck.payload, namespace);
|
|
11301
|
+
if (!namespaceCheck.ok) return namespaceCheck.response;
|
|
11034
11302
|
if (isFreeTier(licenseCheck.payload.tier)) {
|
|
11035
11303
|
const totalIncomingBytes = documents.reduce(
|
|
11036
11304
|
(sum, d) => sum + Buffer.byteLength(d.content || "", "utf8"),
|
|
@@ -11052,7 +11320,7 @@ function createIngestHandler(configOrPlugin, options) {
|
|
|
11052
11320
|
);
|
|
11053
11321
|
}
|
|
11054
11322
|
}
|
|
11055
|
-
const results = await plugin.ingest(documents, namespace);
|
|
11323
|
+
const results = await plugin.ingest(documents, namespaceCheck.namespace);
|
|
11056
11324
|
reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "success", `Ingested ${documents.length} document(s)`);
|
|
11057
11325
|
return NextResponse.json({ results });
|
|
11058
11326
|
} catch (err) {
|
|
@@ -11129,6 +11397,7 @@ function createUploadHandler(configOrPlugin, options) {
|
|
|
11129
11397
|
const plugin = getOrCreatePlugin(configOrPlugin);
|
|
11130
11398
|
const onAuthorize = options == null ? void 0 : options.onAuthorize;
|
|
11131
11399
|
return async function POST(req, context) {
|
|
11400
|
+
console.log("Upload handler invoked");
|
|
11132
11401
|
const authResult = await checkAuth(req, onAuthorize);
|
|
11133
11402
|
if (authResult) return authResult;
|
|
11134
11403
|
const config = plugin.getConfig();
|
|
@@ -11137,9 +11406,12 @@ function createUploadHandler(configOrPlugin, options) {
|
|
|
11137
11406
|
try {
|
|
11138
11407
|
const formData = await req.formData();
|
|
11139
11408
|
const files = formData.getAll("files");
|
|
11409
|
+
console.log("Files received for upload:", files.map((f) => f.name));
|
|
11140
11410
|
const namespace = formData.get("namespace") || void 0;
|
|
11141
11411
|
const dimensionRaw = formData.get("dimension");
|
|
11142
11412
|
const dimension = dimensionRaw ? parseInt(dimensionRaw, 10) : void 0;
|
|
11413
|
+
const namespaceCheck = resolveLicensedNamespace(licenseCheck.payload, namespace);
|
|
11414
|
+
if (!namespaceCheck.ok) return namespaceCheck.response;
|
|
11143
11415
|
if (!files || files.length === 0) {
|
|
11144
11416
|
return NextResponse.json({ error: "No files provided" }, { status: 400 });
|
|
11145
11417
|
}
|
|
@@ -11256,7 +11528,7 @@ function createUploadHandler(configOrPlugin, options) {
|
|
|
11256
11528
|
});
|
|
11257
11529
|
}
|
|
11258
11530
|
}
|
|
11259
|
-
const results = await plugin.ingest(documents, namespace);
|
|
11531
|
+
const results = await plugin.ingest(documents, namespaceCheck.namespace);
|
|
11260
11532
|
reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "success", `Uploaded & ingested ${files.length} file(s)`);
|
|
11261
11533
|
return NextResponse.json({ message: "Upload successful", results });
|
|
11262
11534
|
} catch (err) {
|
|
@@ -11275,6 +11547,7 @@ function createSuggestionsHandler(configOrPlugin, options) {
|
|
|
11275
11547
|
const config = plugin.getConfig();
|
|
11276
11548
|
const licenseCheck = enforceLicense(req, config);
|
|
11277
11549
|
if (!licenseCheck.ok) return licenseCheck.response;
|
|
11550
|
+
let effectiveLicensePayload = licenseCheck.payload;
|
|
11278
11551
|
try {
|
|
11279
11552
|
let query = "";
|
|
11280
11553
|
let namespace = void 0;
|
|
@@ -11287,6 +11560,7 @@ function createSuggestionsHandler(configOrPlugin, options) {
|
|
|
11287
11560
|
if (bodyLicenseKey) {
|
|
11288
11561
|
const recheck = enforceLicense(req, config, bodyLicenseKey);
|
|
11289
11562
|
if (!recheck.ok) return recheck.response;
|
|
11563
|
+
effectiveLicensePayload = recheck.payload;
|
|
11290
11564
|
}
|
|
11291
11565
|
} else {
|
|
11292
11566
|
const url = new URL(req.url);
|
|
@@ -11296,7 +11570,9 @@ function createSuggestionsHandler(configOrPlugin, options) {
|
|
|
11296
11570
|
if (!query || typeof query !== "string" || !query.trim()) {
|
|
11297
11571
|
return NextResponse.json({ suggestions: [] });
|
|
11298
11572
|
}
|
|
11299
|
-
const
|
|
11573
|
+
const namespaceCheck = resolveLicensedNamespace(effectiveLicensePayload, namespace);
|
|
11574
|
+
if (!namespaceCheck.ok) return namespaceCheck.response;
|
|
11575
|
+
const suggestions = await plugin.getSuggestions(query, namespaceCheck.namespace);
|
|
11300
11576
|
reportTelemetry(req, plugin, "AUTO_SUGGESTIONS", "success", `Fetched ${suggestions.length} suggestions for: ${query.slice(0, 30)}`);
|
|
11301
11577
|
return NextResponse.json({ suggestions });
|
|
11302
11578
|
} catch (err) {
|