@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.js
CHANGED
|
@@ -154,11 +154,326 @@ var init_BaseVectorProvider = __esm({
|
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
|
|
157
|
+
// src/core/ProjectSettings.ts
|
|
158
|
+
function createDefaultProjectSettings(projectId) {
|
|
159
|
+
return {
|
|
160
|
+
projectId,
|
|
161
|
+
branding: {
|
|
162
|
+
companyName: "Retrivora AI",
|
|
163
|
+
botName: "Retrivora Assistant",
|
|
164
|
+
welcomeMessage: "Hi, I can help you search your knowledge base.",
|
|
165
|
+
primaryColor: "#6366f1",
|
|
166
|
+
secondaryColor: "#8b5cf6",
|
|
167
|
+
fontFamily: "Inter",
|
|
168
|
+
borderRadius: 14,
|
|
169
|
+
logoUrl: "",
|
|
170
|
+
avatarUrl: "",
|
|
171
|
+
customCss: ""
|
|
172
|
+
},
|
|
173
|
+
ai: {
|
|
174
|
+
defaultModel: "llama-3.1-8b-instant",
|
|
175
|
+
embeddingModel: "text-embedding-3-small",
|
|
176
|
+
systemPrompt: "Answer using the connected knowledge base. Cite sources when available.",
|
|
177
|
+
memoryEnabled: true,
|
|
178
|
+
multiModelEnabled: true,
|
|
179
|
+
citationsEnabled: true,
|
|
180
|
+
fileUploadEnabled: true
|
|
181
|
+
},
|
|
182
|
+
auth: {
|
|
183
|
+
mode: "public",
|
|
184
|
+
allowedOrigins: [],
|
|
185
|
+
requireVerifiedEmail: false,
|
|
186
|
+
sessionTtlMinutes: 1440
|
|
187
|
+
},
|
|
188
|
+
widget: {
|
|
189
|
+
position: "bottom-right",
|
|
190
|
+
theme: "light",
|
|
191
|
+
lazyLoad: true,
|
|
192
|
+
autoReconnect: true,
|
|
193
|
+
persistConversations: true,
|
|
194
|
+
showRetrivoraBranding: false
|
|
195
|
+
},
|
|
196
|
+
telemetry: {
|
|
197
|
+
enabled: true,
|
|
198
|
+
collectBrowser: true,
|
|
199
|
+
collectCountry: false,
|
|
200
|
+
redactPii: true,
|
|
201
|
+
retentionDays: 30
|
|
202
|
+
},
|
|
203
|
+
lifecycleHooks: DEFAULT_LIFECYCLE_HOOKS,
|
|
204
|
+
conversationFeatures: DEFAULT_CONVERSATION_FEATURES
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function cleanString(value, fallback, maxLength = 2e3) {
|
|
208
|
+
if (typeof value !== "string") return fallback;
|
|
209
|
+
return value.trim().slice(0, maxLength);
|
|
210
|
+
}
|
|
211
|
+
function cleanBoolean(value, fallback) {
|
|
212
|
+
return typeof value === "boolean" ? value : fallback;
|
|
213
|
+
}
|
|
214
|
+
function cleanNumber(value, fallback, min, max) {
|
|
215
|
+
const num = typeof value === "number" ? value : Number(value);
|
|
216
|
+
if (!Number.isFinite(num)) return fallback;
|
|
217
|
+
return Math.min(Math.max(Math.round(num), min), max);
|
|
218
|
+
}
|
|
219
|
+
function cleanEnum(value, fallback, allowed) {
|
|
220
|
+
return typeof value === "string" && allowed.includes(value) ? value : fallback;
|
|
221
|
+
}
|
|
222
|
+
function cleanStringList(value, fallback, maxItems = 20) {
|
|
223
|
+
if (!Array.isArray(value)) return fallback;
|
|
224
|
+
const cleaned = value.filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean).slice(0, maxItems);
|
|
225
|
+
return cleaned.length > 0 ? Array.from(new Set(cleaned)) : fallback;
|
|
226
|
+
}
|
|
227
|
+
function normalizeProjectSettings(projectId, input) {
|
|
228
|
+
const defaults = createDefaultProjectSettings(projectId);
|
|
229
|
+
const branding = (input == null ? void 0 : input.branding) || {};
|
|
230
|
+
const ai = (input == null ? void 0 : input.ai) || {};
|
|
231
|
+
const auth = (input == null ? void 0 : input.auth) || {};
|
|
232
|
+
const widget = (input == null ? void 0 : input.widget) || {};
|
|
233
|
+
const telemetry = (input == null ? void 0 : input.telemetry) || {};
|
|
234
|
+
return {
|
|
235
|
+
projectId,
|
|
236
|
+
branding: {
|
|
237
|
+
companyName: cleanString(branding.companyName, defaults.branding.companyName, 120),
|
|
238
|
+
botName: cleanString(branding.botName, defaults.branding.botName, 120),
|
|
239
|
+
welcomeMessage: cleanString(branding.welcomeMessage, defaults.branding.welcomeMessage, 500),
|
|
240
|
+
primaryColor: cleanString(branding.primaryColor, defaults.branding.primaryColor, 32),
|
|
241
|
+
secondaryColor: cleanString(branding.secondaryColor, defaults.branding.secondaryColor, 32),
|
|
242
|
+
fontFamily: cleanString(branding.fontFamily, defaults.branding.fontFamily, 80),
|
|
243
|
+
borderRadius: cleanNumber(branding.borderRadius, defaults.branding.borderRadius, 0, 32),
|
|
244
|
+
logoUrl: cleanString(branding.logoUrl, defaults.branding.logoUrl, 500),
|
|
245
|
+
avatarUrl: cleanString(branding.avatarUrl, defaults.branding.avatarUrl, 500),
|
|
246
|
+
customCss: cleanString(branding.customCss, defaults.branding.customCss, 5e3)
|
|
247
|
+
},
|
|
248
|
+
ai: {
|
|
249
|
+
defaultModel: cleanString(ai.defaultModel, defaults.ai.defaultModel, 120),
|
|
250
|
+
embeddingModel: cleanString(ai.embeddingModel, defaults.ai.embeddingModel, 120),
|
|
251
|
+
systemPrompt: cleanString(ai.systemPrompt, defaults.ai.systemPrompt, 5e3),
|
|
252
|
+
memoryEnabled: cleanBoolean(ai.memoryEnabled, defaults.ai.memoryEnabled),
|
|
253
|
+
multiModelEnabled: cleanBoolean(ai.multiModelEnabled, defaults.ai.multiModelEnabled),
|
|
254
|
+
citationsEnabled: cleanBoolean(ai.citationsEnabled, defaults.ai.citationsEnabled),
|
|
255
|
+
fileUploadEnabled: cleanBoolean(ai.fileUploadEnabled, defaults.ai.fileUploadEnabled)
|
|
256
|
+
},
|
|
257
|
+
auth: {
|
|
258
|
+
mode: cleanEnum(auth.mode, defaults.auth.mode, ["public", "anonymous", "jwt", "oauth", "okta", "auth0", "supabase", "firebase", "sso", "custom_token"]),
|
|
259
|
+
allowedOrigins: cleanStringList(auth.allowedOrigins, defaults.auth.allowedOrigins, 25),
|
|
260
|
+
requireVerifiedEmail: cleanBoolean(auth.requireVerifiedEmail, defaults.auth.requireVerifiedEmail),
|
|
261
|
+
sessionTtlMinutes: cleanNumber(auth.sessionTtlMinutes, defaults.auth.sessionTtlMinutes, 15, 43200)
|
|
262
|
+
},
|
|
263
|
+
widget: {
|
|
264
|
+
position: cleanEnum(widget.position, defaults.widget.position, ["bottom-right", "bottom-left", "top-right", "top-left"]),
|
|
265
|
+
theme: cleanEnum(widget.theme, defaults.widget.theme, ["light", "dark", "system"]),
|
|
266
|
+
lazyLoad: cleanBoolean(widget.lazyLoad, defaults.widget.lazyLoad),
|
|
267
|
+
autoReconnect: cleanBoolean(widget.autoReconnect, defaults.widget.autoReconnect),
|
|
268
|
+
persistConversations: cleanBoolean(widget.persistConversations, defaults.widget.persistConversations),
|
|
269
|
+
showRetrivoraBranding: cleanBoolean(widget.showRetrivoraBranding, defaults.widget.showRetrivoraBranding)
|
|
270
|
+
},
|
|
271
|
+
telemetry: {
|
|
272
|
+
enabled: cleanBoolean(telemetry.enabled, defaults.telemetry.enabled),
|
|
273
|
+
collectBrowser: cleanBoolean(telemetry.collectBrowser, defaults.telemetry.collectBrowser),
|
|
274
|
+
collectCountry: cleanBoolean(telemetry.collectCountry, defaults.telemetry.collectCountry),
|
|
275
|
+
redactPii: cleanBoolean(telemetry.redactPii, defaults.telemetry.redactPii),
|
|
276
|
+
retentionDays: cleanNumber(telemetry.retentionDays, defaults.telemetry.retentionDays, 1, 365)
|
|
277
|
+
},
|
|
278
|
+
lifecycleHooks: cleanStringList(input == null ? void 0 : input.lifecycleHooks, defaults.lifecycleHooks, 30),
|
|
279
|
+
conversationFeatures: cleanStringList(input == null ? void 0 : input.conversationFeatures, defaults.conversationFeatures, 30),
|
|
280
|
+
updatedAt: input == null ? void 0 : input.updatedAt
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
var DEFAULT_LIFECYCLE_HOOKS, DEFAULT_CONVERSATION_FEATURES;
|
|
284
|
+
var init_ProjectSettings = __esm({
|
|
285
|
+
"src/core/ProjectSettings.ts"() {
|
|
286
|
+
"use strict";
|
|
287
|
+
DEFAULT_LIFECYCLE_HOOKS = [
|
|
288
|
+
"beforeInitialize",
|
|
289
|
+
"afterInitialize",
|
|
290
|
+
"beforeSend",
|
|
291
|
+
"afterResponse",
|
|
292
|
+
"onMessage",
|
|
293
|
+
"onCitationClick",
|
|
294
|
+
"onFeedback",
|
|
295
|
+
"onError",
|
|
296
|
+
"onReconnect",
|
|
297
|
+
"onFileUpload"
|
|
298
|
+
];
|
|
299
|
+
DEFAULT_CONVERSATION_FEATURES = [
|
|
300
|
+
"History",
|
|
301
|
+
"Resume",
|
|
302
|
+
"Search",
|
|
303
|
+
"Export",
|
|
304
|
+
"Rename",
|
|
305
|
+
"Delete",
|
|
306
|
+
"Tags",
|
|
307
|
+
"Pinned",
|
|
308
|
+
"Unread",
|
|
309
|
+
"Ratings"
|
|
310
|
+
];
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// package.json
|
|
315
|
+
var package_default;
|
|
316
|
+
var init_package = __esm({
|
|
317
|
+
"package.json"() {
|
|
318
|
+
package_default = {
|
|
319
|
+
name: "@retrivora-ai/rag-engine",
|
|
320
|
+
version: "2.3.7",
|
|
321
|
+
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
322
|
+
author: "Abhinav Alkuchi",
|
|
323
|
+
license: "UNLICENSED",
|
|
324
|
+
keywords: [
|
|
325
|
+
"rag",
|
|
326
|
+
"retrieval-augmented-generation",
|
|
327
|
+
"chatbot",
|
|
328
|
+
"vector-database",
|
|
329
|
+
"pinecone",
|
|
330
|
+
"pgvector",
|
|
331
|
+
"postgresql",
|
|
332
|
+
"milvus",
|
|
333
|
+
"qdrant",
|
|
334
|
+
"chromadb",
|
|
335
|
+
"redis",
|
|
336
|
+
"weaviate",
|
|
337
|
+
"mongodb",
|
|
338
|
+
"openai",
|
|
339
|
+
"anthropic",
|
|
340
|
+
"ollama",
|
|
341
|
+
"nextjs",
|
|
342
|
+
"react",
|
|
343
|
+
"ai",
|
|
344
|
+
"llm",
|
|
345
|
+
"embeddings"
|
|
346
|
+
],
|
|
347
|
+
main: "dist/index.js",
|
|
348
|
+
module: "dist/index.mjs",
|
|
349
|
+
types: "dist/index.d.ts",
|
|
350
|
+
exports: {
|
|
351
|
+
".": {
|
|
352
|
+
types: "./dist/index.d.ts",
|
|
353
|
+
require: "./dist/index.js",
|
|
354
|
+
import: "./dist/index.mjs"
|
|
355
|
+
},
|
|
356
|
+
"./style.css": "./dist/index.css",
|
|
357
|
+
"./index.css": "./dist/index.css",
|
|
358
|
+
"./styles.css": "./dist/index.css",
|
|
359
|
+
"./handlers": {
|
|
360
|
+
types: "./dist/handlers/index.d.ts",
|
|
361
|
+
require: "./dist/handlers/index.js",
|
|
362
|
+
import: "./dist/handlers/index.mjs"
|
|
363
|
+
},
|
|
364
|
+
"./server": {
|
|
365
|
+
types: "./dist/server.d.ts",
|
|
366
|
+
require: "./dist/server.js",
|
|
367
|
+
import: "./dist/server.mjs"
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
browser: {
|
|
371
|
+
child_process: false,
|
|
372
|
+
fs: false,
|
|
373
|
+
net: false,
|
|
374
|
+
tls: false,
|
|
375
|
+
crypto: false,
|
|
376
|
+
os: false,
|
|
377
|
+
path: false,
|
|
378
|
+
stream: false,
|
|
379
|
+
http: false,
|
|
380
|
+
https: false,
|
|
381
|
+
zlib: false,
|
|
382
|
+
mongodb: false,
|
|
383
|
+
pg: false,
|
|
384
|
+
"pdf-parse": false,
|
|
385
|
+
mammoth: false
|
|
386
|
+
},
|
|
387
|
+
files: [
|
|
388
|
+
"dist",
|
|
389
|
+
"src",
|
|
390
|
+
".env.example",
|
|
391
|
+
"README.md",
|
|
392
|
+
"FREE_TIER_ARCHITECTURE.md"
|
|
393
|
+
],
|
|
394
|
+
scripts: {
|
|
395
|
+
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",
|
|
396
|
+
build: "npm run build:pkg",
|
|
397
|
+
"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",
|
|
398
|
+
lint: "eslint",
|
|
399
|
+
typecheck: "tsc --noEmit -p tsconfig.build.json",
|
|
400
|
+
clean: "rm -rf dist"
|
|
401
|
+
},
|
|
402
|
+
peerDependencies: {
|
|
403
|
+
next: ">=15.0.0",
|
|
404
|
+
react: ">=18.0.0",
|
|
405
|
+
"react-dom": ">=18.0.0"
|
|
406
|
+
},
|
|
407
|
+
peerDependenciesMeta: {
|
|
408
|
+
next: {
|
|
409
|
+
optional: true
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
dependencies: {
|
|
413
|
+
"@anthropic-ai/sdk": "^0.95.1",
|
|
414
|
+
"@google/genai": "^0.8.0",
|
|
415
|
+
"@google/generative-ai": "^0.24.1",
|
|
416
|
+
"@pinecone-database/pinecone": "^7.2.0",
|
|
417
|
+
"@types/papaparse": "^5.5.2",
|
|
418
|
+
axios: "^1.15.0",
|
|
419
|
+
"lucide-react": "^1.8.0",
|
|
420
|
+
"next-themes": "^0.4.6",
|
|
421
|
+
openai: "^6.34.0",
|
|
422
|
+
papaparse: "^5.5.3",
|
|
423
|
+
"react-is": "^18.3.1",
|
|
424
|
+
"react-markdown": "^10.1.0",
|
|
425
|
+
recharts: "^3.8.1",
|
|
426
|
+
"remark-gfm": "^4.0.1",
|
|
427
|
+
xlsx: "^0.18.5"
|
|
428
|
+
},
|
|
429
|
+
optionalDependencies: {
|
|
430
|
+
"@langchain/core": "^1.1.42",
|
|
431
|
+
"@langchain/openai": "^1.4.5",
|
|
432
|
+
langchain: "^1.3.5",
|
|
433
|
+
llamaindex: "^0.11.9",
|
|
434
|
+
mammoth: "^1.8.0",
|
|
435
|
+
mongodb: "^7.1.1",
|
|
436
|
+
"pdf-parse": "^1.1.1",
|
|
437
|
+
pg: "^8.20.0"
|
|
438
|
+
},
|
|
439
|
+
devDependencies: {
|
|
440
|
+
"@tailwindcss/cli": "^4",
|
|
441
|
+
"@tailwindcss/postcss": "^4",
|
|
442
|
+
"@types/estree": "^1.0.9",
|
|
443
|
+
"@types/node": "^20",
|
|
444
|
+
"@types/pdf-parse": "^1.1.5",
|
|
445
|
+
"@types/pg": "^8.20.0",
|
|
446
|
+
"@types/react": "^19.2.14",
|
|
447
|
+
"@types/react-dom": "^19.2.3",
|
|
448
|
+
dotenv: "^17.4.2",
|
|
449
|
+
eslint: "^9",
|
|
450
|
+
"eslint-config-next": "16.2.4",
|
|
451
|
+
next: "16.2.10",
|
|
452
|
+
tailwindcss: "^4",
|
|
453
|
+
tsup: "^8.5.1",
|
|
454
|
+
typescript: "^5"
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
// src/version.ts
|
|
461
|
+
var SDK_VERSION;
|
|
462
|
+
var init_version = __esm({
|
|
463
|
+
"src/version.ts"() {
|
|
464
|
+
"use strict";
|
|
465
|
+
init_package();
|
|
466
|
+
SDK_VERSION = package_default.version || "2.1.3";
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
|
|
157
470
|
// src/core/ConfigFetcher.ts
|
|
158
471
|
var CONTROL_PLANE_URL, LLM_PROXY_BASE_URL, ConfigFetcher;
|
|
159
472
|
var init_ConfigFetcher = __esm({
|
|
160
473
|
"src/core/ConfigFetcher.ts"() {
|
|
161
474
|
"use strict";
|
|
475
|
+
init_ProjectSettings();
|
|
476
|
+
init_version();
|
|
162
477
|
CONTROL_PLANE_URL = "https://www.retrivora.com";
|
|
163
478
|
LLM_PROXY_BASE_URL = "https://www.retrivora.com/api/v1";
|
|
164
479
|
ConfigFetcher = class {
|
|
@@ -191,11 +506,12 @@ var init_ConfigFetcher = __esm({
|
|
|
191
506
|
].filter((url) => Boolean(url) && !url.includes("localhost") && !url.includes("127.0.0.1")).map((url) => url.replace(/\/$/, ""));
|
|
192
507
|
for (const baseUrl of controlPlaneUrls) {
|
|
193
508
|
try {
|
|
194
|
-
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}
|
|
509
|
+
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}`;
|
|
195
510
|
const res = await fetch(url, {
|
|
196
511
|
method: "GET",
|
|
197
512
|
headers: __spreadValues({
|
|
198
|
-
"Content-Type": "application/json"
|
|
513
|
+
"Content-Type": "application/json",
|
|
514
|
+
"x-sdk-version": SDK_VERSION
|
|
199
515
|
}, licenseKey ? { "x-license-key": licenseKey } : {})
|
|
200
516
|
});
|
|
201
517
|
if (res.ok) {
|
|
@@ -235,7 +551,11 @@ var init_ConfigFetcher = __esm({
|
|
|
235
551
|
workspace: data.workspace || {
|
|
236
552
|
namespace: fetchedProjectId,
|
|
237
553
|
indexName: data.vectorDb.indexName || "retrivora-free"
|
|
238
|
-
}
|
|
554
|
+
},
|
|
555
|
+
projectSettings: normalizeProjectSettings(
|
|
556
|
+
fetchedProjectId,
|
|
557
|
+
data.projectSettings || data.settings
|
|
558
|
+
)
|
|
239
559
|
};
|
|
240
560
|
this.cache.set(cacheKey, { config, cachedAt: now });
|
|
241
561
|
return config;
|
|
@@ -2342,10 +2662,6 @@ var LicenseVerifier = class {
|
|
|
2342
2662
|
static verify(licenseKey, currentProjectId, provider, publicKeyOverride) {
|
|
2343
2663
|
const isProduction = process.env.NODE_ENV === "production";
|
|
2344
2664
|
const now = Date.now();
|
|
2345
|
-
console.log(`[Retrivora SDK] LicenseVerifier.verify() - licenseKey`, licenseKey);
|
|
2346
|
-
console.log(`[Retrivora SDK] LicenseVerifier.verify() - currentProjectId`, currentProjectId);
|
|
2347
|
-
console.log(`[Retrivora SDK] LicenseVerifier.verify() - provider`, provider);
|
|
2348
|
-
console.log(`[Retrivora SDK] LicenseVerifier.verify() - publicKeyOverride`, publicKeyOverride);
|
|
2349
2665
|
if (licenseKey) {
|
|
2350
2666
|
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
2351
2667
|
const cached = this.cache.get(cacheKey);
|
|
@@ -2533,13 +2849,13 @@ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
|
|
|
2533
2849
|
// In production, this matches the private key held by Retrivora SaaS.
|
|
2534
2850
|
// Rotate this key only when the signing private key is replaced.
|
|
2535
2851
|
LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2852
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyKvvOSYdCimG3b236ebV
|
|
2853
|
+
jpG88xQiU8dSiaMahtBJDf4w0AewRj7hMNgmeZ1wyTOj8kVgeGBOolp1Z0QmTr6O
|
|
2854
|
+
Tj4EDQ/zjsg12If7hSf3NiwLHCYmMLslyK0aaP6PQoTrYkBv3GNdkMecrIjKCijb
|
|
2855
|
+
6VvDLLF3X696melTVM0z/d2e50BW2AlRw/rf1EqYi10d0BcPo5zje0XETr/WGmqu
|
|
2856
|
+
sDiXtsP5MlwkL9X7RQY2uovRa+l/vOAqAfdmJ+OzXuk5P7mDUPb+gCtKnoDbb1tr
|
|
2857
|
+
6UAu733dkUnetAcMqyT3fNPBLO66DCc6m9rGCYYAaG7piMEDwG0/ZySZBFbgllJc
|
|
2858
|
+
6QIDAQAB
|
|
2543
2859
|
-----END PUBLIC KEY-----`;
|
|
2544
2860
|
|
|
2545
2861
|
// src/config/constants.ts
|
|
@@ -2588,6 +2904,7 @@ var PROVIDERS_WITH_EMBEDDINGS = [
|
|
|
2588
2904
|
var UI_BORDER_RADIUS_OPTIONS = ["none", "sm", "md", "lg", "xl", "full"];
|
|
2589
2905
|
|
|
2590
2906
|
// src/config/serverConfig.ts
|
|
2907
|
+
var _runtimeConfig = null;
|
|
2591
2908
|
function readString(env, name) {
|
|
2592
2909
|
var _a3;
|
|
2593
2910
|
const value = (_a3 = env[name]) == null ? void 0 : _a3.trim();
|
|
@@ -2611,7 +2928,7 @@ function readEnum(env, name, fallback, allowed) {
|
|
|
2611
2928
|
throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
|
|
2612
2929
|
}
|
|
2613
2930
|
function getEnvConfig(env = process.env, base) {
|
|
2614
|
-
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
|
|
2931
|
+
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;
|
|
2615
2932
|
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;
|
|
2616
2933
|
const jwtProjectId = (() => {
|
|
2617
2934
|
if (!licenseKey) return void 0;
|
|
@@ -2703,25 +3020,35 @@ function getEnvConfig(env = process.env, base) {
|
|
|
2703
3020
|
return true;
|
|
2704
3021
|
}
|
|
2705
3022
|
})();
|
|
2706
|
-
const
|
|
2707
|
-
const
|
|
2708
|
-
const
|
|
2709
|
-
const
|
|
2710
|
-
const
|
|
2711
|
-
const
|
|
2712
|
-
const
|
|
2713
|
-
const
|
|
2714
|
-
const
|
|
2715
|
-
const
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
3023
|
+
const tierBasedLLMModel = isFreeTier2 ? "llama-3.1-8b-instant" : "llama-3.3-70b-versatile";
|
|
3024
|
+
const tierBasedEmbeddingModel = isFreeTier2 ? "text-embedding-004" : "text-embedding-004";
|
|
3025
|
+
const defaultGatewayUrl = "https://llm.retrivora.com/api/v1";
|
|
3026
|
+
const rt = _runtimeConfig;
|
|
3027
|
+
const defaultLlmProvider = "universal_rest";
|
|
3028
|
+
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;
|
|
3029
|
+
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;
|
|
3030
|
+
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;
|
|
3031
|
+
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;
|
|
3032
|
+
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";
|
|
3033
|
+
console.log("[serverConfig] \u{1F527} LLM Configuration:", {
|
|
3034
|
+
baseUrl: llmBaseUrl,
|
|
3035
|
+
model: llmModel,
|
|
3036
|
+
provider: llmProvider,
|
|
3037
|
+
hasApiKey: !!llmApiKey,
|
|
3038
|
+
source: (rt == null ? void 0 : rt.llmModel) ? "runtime-injected" : "env/fallback"
|
|
3039
|
+
});
|
|
3040
|
+
const defaultEmbeddingProvider = "universal_rest";
|
|
3041
|
+
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;
|
|
3042
|
+
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;
|
|
3043
|
+
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;
|
|
3044
|
+
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;
|
|
3045
|
+
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";
|
|
2719
3046
|
return __spreadProps(__spreadValues({
|
|
2720
3047
|
projectId,
|
|
2721
3048
|
licenseKey,
|
|
2722
3049
|
vectorDb: {
|
|
2723
3050
|
provider: vectorProvider,
|
|
2724
|
-
indexName: (
|
|
3051
|
+
indexName: (_fb = (_eb = readString(env, "VECTOR_DB_INDEX")) != null ? _eb : vectorDbOptions.indexName) != null ? _fb : "rag-index",
|
|
2725
3052
|
options: vectorDbOptions
|
|
2726
3053
|
},
|
|
2727
3054
|
llm: {
|
|
@@ -2751,30 +3078,30 @@ function getEnvConfig(env = process.env, base) {
|
|
|
2751
3078
|
}
|
|
2752
3079
|
},
|
|
2753
3080
|
ui: {
|
|
2754
|
-
title: (
|
|
2755
|
-
subtitle: (
|
|
2756
|
-
primaryColor: (
|
|
2757
|
-
accentColor: (
|
|
2758
|
-
logoUrl: (
|
|
2759
|
-
placeholder: (
|
|
2760
|
-
showSources: ((
|
|
2761
|
-
welcomeMessage: (
|
|
2762
|
-
visualStyle: (
|
|
2763
|
-
borderRadius: (
|
|
2764
|
-
allowUpload: ((
|
|
3081
|
+
title: (_hb = (_gb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _gb : readString(env, "UI_TITLE")) != null ? _hb : "AI Assistant",
|
|
3082
|
+
subtitle: (_jb = (_ib = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _ib : readString(env, "UI_SUBTITLE")) != null ? _jb : "Powered by RAG",
|
|
3083
|
+
primaryColor: (_lb = (_kb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _kb : readString(env, "UI_PRIMARY_COLOR")) != null ? _lb : "#10b981",
|
|
3084
|
+
accentColor: (_nb = (_mb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _mb : readString(env, "UI_ACCENT_COLOR")) != null ? _nb : "#3b82f6",
|
|
3085
|
+
logoUrl: (_ob = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _ob : readString(env, "UI_LOGO_URL"),
|
|
3086
|
+
placeholder: (_qb = (_pb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _pb : readString(env, "UI_PLACEHOLDER")) != null ? _qb : "Ask me anything\u2026",
|
|
3087
|
+
showSources: ((_sb = (_rb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _rb : readString(env, "UI_SHOW_SOURCES")) != null ? _sb : "true") !== "false",
|
|
3088
|
+
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.",
|
|
3089
|
+
visualStyle: (_wb = (_vb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _vb : readString(env, "UI_VISUAL_STYLE")) != null ? _wb : "glass",
|
|
3090
|
+
borderRadius: (_yb = (_xb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _xb : readString(env, "UI_BORDER_RADIUS")) != null ? _yb : "xl",
|
|
3091
|
+
allowUpload: ((_Ab = (_zb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _zb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Ab : "false") === "true"
|
|
2765
3092
|
},
|
|
2766
3093
|
rag: {
|
|
2767
3094
|
topK: readNumber(env, "RAG_TOP_K", 5),
|
|
2768
3095
|
scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
|
|
2769
3096
|
chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
|
|
2770
3097
|
chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
|
|
2771
|
-
filterableFields: (
|
|
3098
|
+
filterableFields: (_Bb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Bb.split(",").map((f) => f.trim()),
|
|
2772
3099
|
// Query pipeline toggles — read from .env.local
|
|
2773
3100
|
useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
|
|
2774
3101
|
useReranking: readString(env, "RAG_USE_RERANKING") === "true",
|
|
2775
3102
|
useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
|
|
2776
|
-
architecture: (
|
|
2777
|
-
chunkingStrategy: (
|
|
3103
|
+
architecture: (_Cb = readString(env, "RAG_ARCHITECTURE")) != null ? _Cb : "simple",
|
|
3104
|
+
chunkingStrategy: (_Db = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Db : "recursive",
|
|
2778
3105
|
uiMapping: (() => {
|
|
2779
3106
|
const raw = readString(env, "RAG_UI_MAPPING");
|
|
2780
3107
|
if (!raw) return void 0;
|
|
@@ -2787,7 +3114,7 @@ function getEnvConfig(env = process.env, base) {
|
|
|
2787
3114
|
},
|
|
2788
3115
|
telemetry: {
|
|
2789
3116
|
enabled: telemetryEnabled,
|
|
2790
|
-
url: (
|
|
3117
|
+
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"
|
|
2791
3118
|
}
|
|
2792
3119
|
}, readString(env, "GRAPH_DB_PROVIDER") ? {
|
|
2793
3120
|
graphDb: {
|
|
@@ -2836,6 +3163,7 @@ var ConfigResolver = class {
|
|
|
2836
3163
|
options: __spreadValues(__spreadValues({}, envConfig.embedding.options || {}), hostConfig.embedding.options || {})
|
|
2837
3164
|
}) : envConfig.embedding,
|
|
2838
3165
|
ui: hostConfig.ui ? mergeDefined(envConfig.ui, hostConfig.ui) : envConfig.ui,
|
|
3166
|
+
projectSettings: hostConfig.projectSettings || envConfig.projectSettings,
|
|
2839
3167
|
rag: hostConfig.rag ? __spreadValues(__spreadValues({}, envConfig.rag), hostConfig.rag) : envConfig.rag,
|
|
2840
3168
|
telemetry: hostConfig.telemetry ? __spreadValues(__spreadValues({}, envConfig.telemetry), hostConfig.telemetry) : envConfig.telemetry
|
|
2841
3169
|
});
|
|
@@ -4104,7 +4432,7 @@ var UniversalLLMAdapter = class {
|
|
|
4104
4432
|
});
|
|
4105
4433
|
}
|
|
4106
4434
|
async chat(messages, context) {
|
|
4107
|
-
var _a3, _b, _c, _d, _e;
|
|
4435
|
+
var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j;
|
|
4108
4436
|
const path2 = (_a3 = this.opts.chatPath) != null ? _a3 : "/chat/completions";
|
|
4109
4437
|
const safeMessages = (Array.isArray(messages) ? messages : []).filter((m) => Boolean(m && typeof m === "object")).map((m) => ({
|
|
4110
4438
|
role: m.role || "user",
|
|
@@ -4134,16 +4462,27 @@ ${context != null ? context : "None"}` },
|
|
|
4134
4462
|
};
|
|
4135
4463
|
}
|
|
4136
4464
|
try {
|
|
4465
|
+
console.debug(`[UniversalLLMAdapter] POST ${this.baseUrl}${path2}`);
|
|
4466
|
+
console.debug(`[UniversalLLMAdapter] Model: ${this.model}`);
|
|
4467
|
+
console.debug(`[UniversalLLMAdapter] Auth: Bearer ${((_b = this.apiKey) == null ? void 0 : _b.substring(0, 20)) || "none"}...`);
|
|
4137
4468
|
const { data: data2 } = await this.http.post(path2, payload);
|
|
4138
|
-
const extractPath2 = (
|
|
4139
|
-
const result2 = (
|
|
4469
|
+
const extractPath2 = (_c = this.opts.responseExtractPath) != null ? _c : "choices[0].message.content";
|
|
4470
|
+
const result2 = (_d = resolvePath(data2, extractPath2)) != null ? _d : extractContent(data2);
|
|
4140
4471
|
if (result2 !== void 0) {
|
|
4141
4472
|
return String(result2);
|
|
4142
4473
|
}
|
|
4143
4474
|
} catch (httpErr) {
|
|
4144
|
-
|
|
4145
|
-
|
|
4475
|
+
console.error("[UniversalLLMAdapter] \u274C HTTP chat request failed:", {
|
|
4476
|
+
status: (_e = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _e.status,
|
|
4477
|
+
statusText: (_f = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _f.statusText,
|
|
4478
|
+
url: (_g2 = httpErr == null ? void 0 : httpErr.config) == null ? void 0 : _g2.url,
|
|
4479
|
+
errorData: (_h = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _h.data,
|
|
4480
|
+
message: httpErr == null ? void 0 : httpErr.message
|
|
4481
|
+
});
|
|
4482
|
+
const _g3 = globalThis;
|
|
4483
|
+
const dispatch = _g3.__retrivoraDispatchChat;
|
|
4146
4484
|
if (typeof dispatch === "function") {
|
|
4485
|
+
console.debug("[UniversalLLMAdapter] \u{1F504} Attempting in-process fallback dispatch");
|
|
4147
4486
|
const res = await dispatch({
|
|
4148
4487
|
model: this.model,
|
|
4149
4488
|
messages: formattedMessages,
|
|
@@ -4158,8 +4497,8 @@ ${context != null ? context : "None"}` },
|
|
|
4158
4497
|
throw httpErr;
|
|
4159
4498
|
}
|
|
4160
4499
|
const { data } = await this.http.post(path2, payload);
|
|
4161
|
-
const extractPath = (
|
|
4162
|
-
const result = (
|
|
4500
|
+
const extractPath = (_i = this.opts.responseExtractPath) != null ? _i : "choices[0].message.content";
|
|
4501
|
+
const result = (_j = resolvePath(data, extractPath)) != null ? _j : extractContent(data);
|
|
4163
4502
|
if (result === void 0) {
|
|
4164
4503
|
throw new Error(`[UniversalLLMAdapter] Could not extract text from path '${extractPath}' in response.`);
|
|
4165
4504
|
}
|
|
@@ -4298,36 +4637,70 @@ ${context != null ? context : "None"}` },
|
|
|
4298
4637
|
});
|
|
4299
4638
|
}
|
|
4300
4639
|
async embed(text) {
|
|
4301
|
-
var _a3, _b, _c, _d, _e;
|
|
4640
|
+
var _a3, _b, _c, _d, _e, _f, _g2;
|
|
4302
4641
|
const path2 = (_a3 = this.opts.embedPath) != null ? _a3 : "/embeddings";
|
|
4303
4642
|
const payload = this.opts.embedPayloadTemplate ? buildPayload(this.opts.embedPayloadTemplate, { input: text, model: this.model }) : { input: text, model: this.model };
|
|
4304
4643
|
try {
|
|
4305
|
-
const { data
|
|
4306
|
-
const
|
|
4307
|
-
const
|
|
4308
|
-
if (Array.isArray(
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4644
|
+
const { data } = await this.http.post(path2, payload);
|
|
4645
|
+
const extractPath = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
|
|
4646
|
+
const vector = resolvePath(data, extractPath);
|
|
4647
|
+
if (Array.isArray(vector)) return vector;
|
|
4648
|
+
console.warn(
|
|
4649
|
+
`[UniversalLLMAdapter] Embedding API returned unexpected format for path '${extractPath}'. Response:`,
|
|
4650
|
+
data
|
|
4651
|
+
);
|
|
4652
|
+
} catch (err) {
|
|
4653
|
+
console.warn(
|
|
4654
|
+
`[UniversalLLMAdapter] HTTP embedding request failed: ${(err == null ? void 0 : err.message) || err}`,
|
|
4655
|
+
{ path: path2, model: this.model }
|
|
4656
|
+
);
|
|
4657
|
+
const _g3 = globalThis;
|
|
4658
|
+
const dispatchEmbed = _g3.__retrivoraDispatchEmbedding;
|
|
4312
4659
|
if (typeof dispatchEmbed === "function") {
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4660
|
+
try {
|
|
4661
|
+
const res = await dispatchEmbed({ input: text, model: this.model }, this.apiKey);
|
|
4662
|
+
if ((_d = (_c = res == null ? void 0 : res.data) == null ? void 0 : _c[0]) == null ? void 0 : _d.embedding) {
|
|
4663
|
+
return res.data[0].embedding;
|
|
4664
|
+
}
|
|
4665
|
+
} catch (dispatchErr) {
|
|
4666
|
+
console.warn("[UniversalLLMAdapter] In-process dispatch embedding failed:", dispatchErr);
|
|
4316
4667
|
}
|
|
4317
4668
|
}
|
|
4318
4669
|
}
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4670
|
+
try {
|
|
4671
|
+
const { data } = await this.http.post(path2, payload);
|
|
4672
|
+
const extractPath = (_e = this.opts.embedExtractPath) != null ? _e : "data[0].embedding";
|
|
4673
|
+
const vector = resolvePath(data, extractPath);
|
|
4674
|
+
if (Array.isArray(vector)) {
|
|
4675
|
+
return vector;
|
|
4676
|
+
}
|
|
4677
|
+
console.error(
|
|
4678
|
+
`[UniversalLLMAdapter] Retry embedding failed: unexpected response format for path '${extractPath}'. Response:`,
|
|
4679
|
+
data
|
|
4680
|
+
);
|
|
4681
|
+
throw new Error(
|
|
4682
|
+
`[UniversalLLMAdapter] Could not extract embedding vector. Expected array at '${extractPath}', got: ${typeof vector}. Response keys: ${Object.keys(data || {})}.`
|
|
4683
|
+
);
|
|
4684
|
+
} catch (err) {
|
|
4685
|
+
console.error(
|
|
4686
|
+
`[UniversalLLMAdapter] Both embedding attempts failed. Path: ${path2}, Model: ${this.model}`,
|
|
4687
|
+
{ 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 }
|
|
4688
|
+
);
|
|
4689
|
+
throw new Error(
|
|
4690
|
+
`[UniversalLLMAdapter] Failed to generate embedding after 2 attempts: ${(err == null ? void 0 : err.message) || err}`
|
|
4691
|
+
);
|
|
4324
4692
|
}
|
|
4325
|
-
return vector;
|
|
4326
4693
|
}
|
|
4327
4694
|
async batchEmbed(texts) {
|
|
4328
4695
|
const results = [];
|
|
4329
4696
|
for (const text of texts) {
|
|
4330
|
-
|
|
4697
|
+
try {
|
|
4698
|
+
const vector = await this.embed(text);
|
|
4699
|
+
results.push(vector);
|
|
4700
|
+
} catch (err) {
|
|
4701
|
+
console.warn(`[UniversalLLMAdapter] batchEmbed failed for text (first 50 chars): ${text.slice(0, 50)}...`, err);
|
|
4702
|
+
throw err;
|
|
4703
|
+
}
|
|
4331
4704
|
}
|
|
4332
4705
|
return results;
|
|
4333
4706
|
}
|
|
@@ -4738,149 +5111,8 @@ var ConfigValidator = class {
|
|
|
4738
5111
|
}
|
|
4739
5112
|
};
|
|
4740
5113
|
|
|
4741
|
-
//
|
|
4742
|
-
|
|
4743
|
-
name: "@retrivora-ai/rag-engine",
|
|
4744
|
-
version: "2.3.5",
|
|
4745
|
-
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
4746
|
-
author: "Abhinav Alkuchi",
|
|
4747
|
-
license: "UNLICENSED",
|
|
4748
|
-
keywords: [
|
|
4749
|
-
"rag",
|
|
4750
|
-
"retrieval-augmented-generation",
|
|
4751
|
-
"chatbot",
|
|
4752
|
-
"vector-database",
|
|
4753
|
-
"pinecone",
|
|
4754
|
-
"pgvector",
|
|
4755
|
-
"postgresql",
|
|
4756
|
-
"milvus",
|
|
4757
|
-
"qdrant",
|
|
4758
|
-
"chromadb",
|
|
4759
|
-
"redis",
|
|
4760
|
-
"weaviate",
|
|
4761
|
-
"mongodb",
|
|
4762
|
-
"openai",
|
|
4763
|
-
"anthropic",
|
|
4764
|
-
"ollama",
|
|
4765
|
-
"nextjs",
|
|
4766
|
-
"react",
|
|
4767
|
-
"ai",
|
|
4768
|
-
"llm",
|
|
4769
|
-
"embeddings"
|
|
4770
|
-
],
|
|
4771
|
-
main: "dist/index.js",
|
|
4772
|
-
module: "dist/index.mjs",
|
|
4773
|
-
types: "dist/index.d.ts",
|
|
4774
|
-
exports: {
|
|
4775
|
-
".": {
|
|
4776
|
-
types: "./dist/index.d.ts",
|
|
4777
|
-
require: "./dist/index.js",
|
|
4778
|
-
import: "./dist/index.mjs"
|
|
4779
|
-
},
|
|
4780
|
-
"./style.css": "./dist/index.css",
|
|
4781
|
-
"./index.css": "./dist/index.css",
|
|
4782
|
-
"./styles.css": "./dist/index.css",
|
|
4783
|
-
"./handlers": {
|
|
4784
|
-
types: "./dist/handlers/index.d.ts",
|
|
4785
|
-
require: "./dist/handlers/index.js",
|
|
4786
|
-
import: "./dist/handlers/index.mjs"
|
|
4787
|
-
},
|
|
4788
|
-
"./server": {
|
|
4789
|
-
types: "./dist/server.d.ts",
|
|
4790
|
-
require: "./dist/server.js",
|
|
4791
|
-
import: "./dist/server.mjs"
|
|
4792
|
-
}
|
|
4793
|
-
},
|
|
4794
|
-
browser: {
|
|
4795
|
-
child_process: false,
|
|
4796
|
-
fs: false,
|
|
4797
|
-
net: false,
|
|
4798
|
-
tls: false,
|
|
4799
|
-
crypto: false,
|
|
4800
|
-
os: false,
|
|
4801
|
-
path: false,
|
|
4802
|
-
stream: false,
|
|
4803
|
-
http: false,
|
|
4804
|
-
https: false,
|
|
4805
|
-
zlib: false,
|
|
4806
|
-
mongodb: false,
|
|
4807
|
-
pg: false,
|
|
4808
|
-
"pdf-parse": false,
|
|
4809
|
-
mammoth: false
|
|
4810
|
-
},
|
|
4811
|
-
files: [
|
|
4812
|
-
"dist",
|
|
4813
|
-
"src",
|
|
4814
|
-
".env.example",
|
|
4815
|
-
"README.md",
|
|
4816
|
-
"FREE_TIER_ARCHITECTURE.md"
|
|
4817
|
-
],
|
|
4818
|
-
scripts: {
|
|
4819
|
-
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",
|
|
4820
|
-
build: "npm run build:pkg",
|
|
4821
|
-
"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",
|
|
4822
|
-
lint: "eslint",
|
|
4823
|
-
typecheck: "tsc --noEmit -p tsconfig.build.json",
|
|
4824
|
-
clean: "rm -rf dist"
|
|
4825
|
-
},
|
|
4826
|
-
peerDependencies: {
|
|
4827
|
-
next: ">=15.0.0",
|
|
4828
|
-
react: ">=18.0.0",
|
|
4829
|
-
"react-dom": ">=18.0.0"
|
|
4830
|
-
},
|
|
4831
|
-
peerDependenciesMeta: {
|
|
4832
|
-
next: {
|
|
4833
|
-
optional: true
|
|
4834
|
-
}
|
|
4835
|
-
},
|
|
4836
|
-
dependencies: {
|
|
4837
|
-
"@anthropic-ai/sdk": "^0.95.1",
|
|
4838
|
-
"@google/genai": "^0.8.0",
|
|
4839
|
-
"@google/generative-ai": "^0.24.1",
|
|
4840
|
-
"@pinecone-database/pinecone": "^7.2.0",
|
|
4841
|
-
"@types/papaparse": "^5.5.2",
|
|
4842
|
-
axios: "^1.15.0",
|
|
4843
|
-
"lucide-react": "^1.8.0",
|
|
4844
|
-
"next-themes": "^0.4.6",
|
|
4845
|
-
openai: "^6.34.0",
|
|
4846
|
-
papaparse: "^5.5.3",
|
|
4847
|
-
"react-is": "^18.3.1",
|
|
4848
|
-
"react-markdown": "^10.1.0",
|
|
4849
|
-
recharts: "^3.8.1",
|
|
4850
|
-
"remark-gfm": "^4.0.1",
|
|
4851
|
-
xlsx: "^0.18.5"
|
|
4852
|
-
},
|
|
4853
|
-
optionalDependencies: {
|
|
4854
|
-
"@langchain/core": "^1.1.42",
|
|
4855
|
-
"@langchain/openai": "^1.4.5",
|
|
4856
|
-
langchain: "^1.3.5",
|
|
4857
|
-
llamaindex: "^0.11.9",
|
|
4858
|
-
mammoth: "^1.8.0",
|
|
4859
|
-
mongodb: "^7.1.1",
|
|
4860
|
-
"pdf-parse": "^1.1.1",
|
|
4861
|
-
pg: "^8.20.0"
|
|
4862
|
-
},
|
|
4863
|
-
devDependencies: {
|
|
4864
|
-
"@tailwindcss/cli": "^4",
|
|
4865
|
-
"@tailwindcss/postcss": "^4",
|
|
4866
|
-
"@types/estree": "^1.0.9",
|
|
4867
|
-
"@types/node": "^20",
|
|
4868
|
-
"@types/pdf-parse": "^1.1.5",
|
|
4869
|
-
"@types/pg": "^8.20.0",
|
|
4870
|
-
"@types/react": "^19.2.14",
|
|
4871
|
-
"@types/react-dom": "^19.2.3",
|
|
4872
|
-
dotenv: "^17.4.2",
|
|
4873
|
-
eslint: "^9",
|
|
4874
|
-
"eslint-config-next": "16.2.4",
|
|
4875
|
-
next: "16.2.10",
|
|
4876
|
-
tailwindcss: "^4",
|
|
4877
|
-
tsup: "^8.5.1",
|
|
4878
|
-
typescript: "^5"
|
|
4879
|
-
}
|
|
4880
|
-
};
|
|
4881
|
-
|
|
4882
|
-
// src/version.ts
|
|
4883
|
-
var SDK_VERSION = package_default.version || "2.1.3";
|
|
5114
|
+
// src/core/Pipeline.ts
|
|
5115
|
+
init_version();
|
|
4884
5116
|
|
|
4885
5117
|
// src/rag/DocumentChunker.ts
|
|
4886
5118
|
var DocumentChunker = class {
|
|
@@ -10549,6 +10781,7 @@ var DatabaseStorage = class {
|
|
|
10549
10781
|
};
|
|
10550
10782
|
|
|
10551
10783
|
// src/handlers/index.ts
|
|
10784
|
+
init_version();
|
|
10552
10785
|
async function checkAuth(req, onAuthorize) {
|
|
10553
10786
|
if (!onAuthorize) return null;
|
|
10554
10787
|
try {
|
|
@@ -10680,6 +10913,35 @@ function enforceLicense(req, config, bodyLicenseKey) {
|
|
|
10680
10913
|
};
|
|
10681
10914
|
}
|
|
10682
10915
|
}
|
|
10916
|
+
function getAllowedNamespaces(projectId) {
|
|
10917
|
+
const trimmed = projectId.trim();
|
|
10918
|
+
const withoutPrefix = trimmed.startsWith("retrivora-") ? trimmed.replace(/^retrivora-/, "") : trimmed;
|
|
10919
|
+
return new Set([
|
|
10920
|
+
trimmed,
|
|
10921
|
+
withoutPrefix,
|
|
10922
|
+
`retrivora-${withoutPrefix}`
|
|
10923
|
+
].filter(Boolean));
|
|
10924
|
+
}
|
|
10925
|
+
function resolveLicensedNamespace(payload, requestedNamespace) {
|
|
10926
|
+
const allowed = getAllowedNamespaces(payload.projectId);
|
|
10927
|
+
const requested = requestedNamespace == null ? void 0 : requestedNamespace.trim();
|
|
10928
|
+
if (requested && !allowed.has(requested)) {
|
|
10929
|
+
return {
|
|
10930
|
+
ok: false,
|
|
10931
|
+
response: new Response(JSON.stringify({
|
|
10932
|
+
error: {
|
|
10933
|
+
code: "NAMESPACE_FORBIDDEN",
|
|
10934
|
+
message: "Requested namespace is not authorized for this license."
|
|
10935
|
+
}
|
|
10936
|
+
}), {
|
|
10937
|
+
status: 403,
|
|
10938
|
+
headers: { "Content-Type": "application/json" }
|
|
10939
|
+
})
|
|
10940
|
+
};
|
|
10941
|
+
}
|
|
10942
|
+
const defaultNamespace = payload.projectId.startsWith("retrivora-") ? payload.projectId : `retrivora-${payload.projectId}`;
|
|
10943
|
+
return { ok: true, namespace: requested || defaultNamespace };
|
|
10944
|
+
}
|
|
10683
10945
|
var MAX_MESSAGE_LENGTH = 8e3;
|
|
10684
10946
|
function sanitizeInput(raw) {
|
|
10685
10947
|
const stripped = raw.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g, "");
|
|
@@ -10840,6 +11102,8 @@ function createChatHandler(configOrPlugin, options) {
|
|
|
10840
11102
|
}
|
|
10841
11103
|
const history = bodyObj.history || (Array.isArray(bodyObj.messages) ? bodyObj.messages.slice(0, -1) : []);
|
|
10842
11104
|
const { namespace, sessionId = "default", messageId, userMessageId } = bodyObj;
|
|
11105
|
+
const namespaceCheck = resolveLicensedNamespace(licenseCheck.payload, namespace);
|
|
11106
|
+
if (!namespaceCheck.ok) return namespaceCheck.response;
|
|
10843
11107
|
const sanitized = sanitizeInput(rawMessage != null ? rawMessage : "");
|
|
10844
11108
|
if (!sanitized.ok) {
|
|
10845
11109
|
return import_server.NextResponse.json({ error: { code: "INVALID_INPUT", message: sanitized.error } }, { status: 400 });
|
|
@@ -10851,7 +11115,7 @@ function createChatHandler(configOrPlugin, options) {
|
|
|
10851
11115
|
role: "user",
|
|
10852
11116
|
content: message
|
|
10853
11117
|
}).catch((err) => console.warn("[createChatHandler] Failed to save user message:", err));
|
|
10854
|
-
const result = await plugin.chat(message, history, namespace);
|
|
11118
|
+
const result = await plugin.chat(message, history, namespaceCheck.namespace);
|
|
10855
11119
|
const assistantMsgId = messageId || `assistant_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`;
|
|
10856
11120
|
await storage.saveMessage(sessionId, {
|
|
10857
11121
|
id: assistantMsgId,
|
|
@@ -10932,6 +11196,8 @@ function createStreamHandler(configOrPlugin, options) {
|
|
|
10932
11196
|
}
|
|
10933
11197
|
const history = bodyObj.history || (Array.isArray(bodyObj.messages) ? bodyObj.messages.slice(0, -1) : []);
|
|
10934
11198
|
const { namespace, sessionId = "default", messageId, userMessageId } = bodyObj;
|
|
11199
|
+
const namespaceCheck = resolveLicensedNamespace(licenseCheck.payload, namespace);
|
|
11200
|
+
if (!namespaceCheck.ok) return namespaceCheck.response;
|
|
10935
11201
|
const sanitized = sanitizeInput(rawMessage != null ? rawMessage : "");
|
|
10936
11202
|
if (!sanitized.ok) {
|
|
10937
11203
|
return new Response(
|
|
@@ -10961,7 +11227,7 @@ function createStreamHandler(configOrPlugin, options) {
|
|
|
10961
11227
|
}
|
|
10962
11228
|
};
|
|
10963
11229
|
try {
|
|
10964
|
-
const pipelineStream = plugin.chatStream(message, history, namespace);
|
|
11230
|
+
const pipelineStream = plugin.chatStream(message, history, namespaceCheck.namespace);
|
|
10965
11231
|
let fullReply = "";
|
|
10966
11232
|
try {
|
|
10967
11233
|
for (var iter = __forAwait(pipelineStream), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
|
|
@@ -11067,6 +11333,8 @@ function createIngestHandler(configOrPlugin, options) {
|
|
|
11067
11333
|
if (!Array.isArray(documents) || documents.length === 0) {
|
|
11068
11334
|
return import_server.NextResponse.json({ error: "documents array is required" }, { status: 400 });
|
|
11069
11335
|
}
|
|
11336
|
+
const namespaceCheck = resolveLicensedNamespace(licenseCheck.payload, namespace);
|
|
11337
|
+
if (!namespaceCheck.ok) return namespaceCheck.response;
|
|
11070
11338
|
if (isFreeTier(licenseCheck.payload.tier)) {
|
|
11071
11339
|
const totalIncomingBytes = documents.reduce(
|
|
11072
11340
|
(sum, d) => sum + Buffer.byteLength(d.content || "", "utf8"),
|
|
@@ -11088,7 +11356,7 @@ function createIngestHandler(configOrPlugin, options) {
|
|
|
11088
11356
|
);
|
|
11089
11357
|
}
|
|
11090
11358
|
}
|
|
11091
|
-
const results = await plugin.ingest(documents, namespace);
|
|
11359
|
+
const results = await plugin.ingest(documents, namespaceCheck.namespace);
|
|
11092
11360
|
reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "success", `Ingested ${documents.length} document(s)`);
|
|
11093
11361
|
return import_server.NextResponse.json({ results });
|
|
11094
11362
|
} catch (err) {
|
|
@@ -11165,6 +11433,7 @@ function createUploadHandler(configOrPlugin, options) {
|
|
|
11165
11433
|
const plugin = getOrCreatePlugin(configOrPlugin);
|
|
11166
11434
|
const onAuthorize = options == null ? void 0 : options.onAuthorize;
|
|
11167
11435
|
return async function POST(req, context) {
|
|
11436
|
+
console.log("Upload handler invoked");
|
|
11168
11437
|
const authResult = await checkAuth(req, onAuthorize);
|
|
11169
11438
|
if (authResult) return authResult;
|
|
11170
11439
|
const config = plugin.getConfig();
|
|
@@ -11173,9 +11442,12 @@ function createUploadHandler(configOrPlugin, options) {
|
|
|
11173
11442
|
try {
|
|
11174
11443
|
const formData = await req.formData();
|
|
11175
11444
|
const files = formData.getAll("files");
|
|
11445
|
+
console.log("Files received for upload:", files.map((f) => f.name));
|
|
11176
11446
|
const namespace = formData.get("namespace") || void 0;
|
|
11177
11447
|
const dimensionRaw = formData.get("dimension");
|
|
11178
11448
|
const dimension = dimensionRaw ? parseInt(dimensionRaw, 10) : void 0;
|
|
11449
|
+
const namespaceCheck = resolveLicensedNamespace(licenseCheck.payload, namespace);
|
|
11450
|
+
if (!namespaceCheck.ok) return namespaceCheck.response;
|
|
11179
11451
|
if (!files || files.length === 0) {
|
|
11180
11452
|
return import_server.NextResponse.json({ error: "No files provided" }, { status: 400 });
|
|
11181
11453
|
}
|
|
@@ -11292,7 +11564,7 @@ function createUploadHandler(configOrPlugin, options) {
|
|
|
11292
11564
|
});
|
|
11293
11565
|
}
|
|
11294
11566
|
}
|
|
11295
|
-
const results = await plugin.ingest(documents, namespace);
|
|
11567
|
+
const results = await plugin.ingest(documents, namespaceCheck.namespace);
|
|
11296
11568
|
reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "success", `Uploaded & ingested ${files.length} file(s)`);
|
|
11297
11569
|
return import_server.NextResponse.json({ message: "Upload successful", results });
|
|
11298
11570
|
} catch (err) {
|
|
@@ -11311,6 +11583,7 @@ function createSuggestionsHandler(configOrPlugin, options) {
|
|
|
11311
11583
|
const config = plugin.getConfig();
|
|
11312
11584
|
const licenseCheck = enforceLicense(req, config);
|
|
11313
11585
|
if (!licenseCheck.ok) return licenseCheck.response;
|
|
11586
|
+
let effectiveLicensePayload = licenseCheck.payload;
|
|
11314
11587
|
try {
|
|
11315
11588
|
let query = "";
|
|
11316
11589
|
let namespace = void 0;
|
|
@@ -11323,6 +11596,7 @@ function createSuggestionsHandler(configOrPlugin, options) {
|
|
|
11323
11596
|
if (bodyLicenseKey) {
|
|
11324
11597
|
const recheck = enforceLicense(req, config, bodyLicenseKey);
|
|
11325
11598
|
if (!recheck.ok) return recheck.response;
|
|
11599
|
+
effectiveLicensePayload = recheck.payload;
|
|
11326
11600
|
}
|
|
11327
11601
|
} else {
|
|
11328
11602
|
const url = new URL(req.url);
|
|
@@ -11332,7 +11606,9 @@ function createSuggestionsHandler(configOrPlugin, options) {
|
|
|
11332
11606
|
if (!query || typeof query !== "string" || !query.trim()) {
|
|
11333
11607
|
return import_server.NextResponse.json({ suggestions: [] });
|
|
11334
11608
|
}
|
|
11335
|
-
const
|
|
11609
|
+
const namespaceCheck = resolveLicensedNamespace(effectiveLicensePayload, namespace);
|
|
11610
|
+
if (!namespaceCheck.ok) return namespaceCheck.response;
|
|
11611
|
+
const suggestions = await plugin.getSuggestions(query, namespaceCheck.namespace);
|
|
11336
11612
|
reportTelemetry(req, plugin, "AUTO_SUGGESTIONS", "success", `Fetched ${suggestions.length} suggestions for: ${query.slice(0, 30)}`);
|
|
11337
11613
|
return import_server.NextResponse.json({ suggestions });
|
|
11338
11614
|
} catch (err) {
|