@retrivora-ai/rag-engine 2.6.2 → 2.6.3
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/ChromaDBProvider-NDA2IBOH.mjs +8 -0
- package/dist/MilvusProvider-H6GGL5FQ.mjs +8 -0
- package/dist/MongoDBProvider-KC3GF3FH.mjs +8 -0
- package/dist/MultiTablePostgresProvider-6LJBFZL2.mjs +9 -0
- package/dist/PineconeProvider-22RF2QPF.mjs +10 -0
- package/dist/PineconeProvider-HBBIXLT3.mjs +10 -0
- package/dist/PostgreSQLProvider-VWFL4OIP.mjs +8 -0
- package/dist/QdrantProvider-UU7RGXBI.mjs +8 -0
- package/dist/RedisProvider-MIIPSAAE.mjs +8 -0
- package/dist/SimpleGraphProvider-HJIS4S7Y.mjs +70 -0
- package/dist/UniversalVectorProvider-NO3L255G.mjs +9 -0
- package/dist/WeaviateProvider-YRZDZFAC.mjs +8 -0
- package/dist/chunk-23PFNEBF.mjs +107 -0
- package/dist/chunk-3E4GZGDX.mjs +10851 -0
- package/dist/chunk-3SQ4DODU.mjs +238 -0
- package/dist/chunk-AHMMUZ4W.mjs +152 -0
- package/dist/chunk-ASBNNEVI.mjs +81 -0
- package/dist/chunk-AT4TFUQN.mjs +219 -0
- package/dist/chunk-BEPLYQBS.mjs +89 -0
- package/dist/chunk-G7MJRFCO.mjs +340 -0
- package/dist/chunk-IHWKVAUR.mjs +112 -0
- package/dist/chunk-IMP6FUCY.mjs +30 -0
- package/dist/chunk-LFNV6DEL.mjs +281 -0
- package/dist/chunk-MAXMVO7B.mjs +211 -0
- package/dist/chunk-MGJ6V2IT.mjs +203 -0
- package/dist/chunk-N3TI27LG.mjs +334 -0
- package/dist/chunk-NWYE4Q7B.mjs +334 -0
- package/dist/chunk-OJMAT4EG.mjs +219 -0
- package/dist/chunk-QKZM3RSJ.mjs +10851 -0
- package/dist/chunk-QUY3E6HJ.mjs +168 -0
- package/dist/chunk-SG6XYLQE.mjs +53 -0
- package/dist/chunk-UT6SZZEC.mjs +69 -0
- package/dist/chunk-VW3U4MMX.mjs +157 -0
- package/dist/chunk-WOJCOTXI.mjs +281 -0
- package/dist/chunk-XP6NJMX4.mjs +168 -0
- package/dist/chunk-XYBKDJDW.mjs +696 -0
- package/dist/handlers/index.d.mts +1 -1
- package/dist/handlers/index.d.ts +1 -1
- package/dist/handlers/index.js +56 -23
- package/dist/handlers/index.mjs +24 -14027
- package/dist/{index-D7FuQRSb.d.mts → index-BBbt5A2y.d.mts} +3 -1
- package/dist/{index-CFl4KrKq.d.ts → index-BZ_rR6V8.d.ts} +3 -1
- package/dist/index.js +12 -4
- package/dist/index.mjs +46 -1461
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +56 -23
- package/dist/server.mjs +377 -14573
- package/package.json +1 -1
package/dist/server.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import { b as RagConfig, f as UniversalRagConfig, h as VectorDBConfig, y as Upse
|
|
|
2
2
|
export { A as AuthMode, N as BarChartData, Q as CarouselProduct, S as IRetriever, o as LatencyBreakdown, X as LineChartDataPoint, Y as MessageRole, Z as MetricCardData, O as ObservabilityTrace, _ as PieChartData, P as Product, p as ProjectAiSettings, q as ProjectAuthSettings, r as ProjectBrandingSettings, a as ProjectChatSettings, s as ProjectTelemetrySettings, t as ProjectWidgetSettings, R as RagMessage, v as RetrievalConfig, e as RetrievalResult, w as RetrievedChunk, $ as RetrivoraChunkMetadata, a0 as RetrivoraIngestedDocument, a1 as ScatterPlotDataPoint, a2 as SuggestionsResponse, a3 as TableData, T as ThemeMode, x as TokenUsage, i as UseRagChatOptions, j as UseRagChatReturn, a4 as VisualizationType, W as WidgetPosition, B as WorkflowConfig, D as createDefaultProjectSettings, F as normalizeProjectSettings, G as projectSettingsToUiConfig } from './ILLMProvider-CzXcTA6d.mjs';
|
|
3
3
|
import { V as Pipeline, o as DecisionContext, q as IntentCategory, I as IRenderRule, G as RenderDecision, p as IRendererStrategy } from './index-BST9Gzsv.mjs';
|
|
4
4
|
export { W as ArchitectureCardProps, A as AuthenticationException, B as BatchOptions, f as BatchProcessor, g as BatchResult, h as ChartType, e as ChatViewportSize, C as ChatWidgetProps, a as ChatWindowProps, i as Chunk, j as ChunkOptions, c as ClientConfig, m as ConfigFetcher, b as ConfigProviderProps, n as ConfigurationException, X as DocumentChunker, D as DocumentUploadProps, E as EmbeddingFailedException, Y as LicenseConfigResolver, L as LicenseTierConfig, r as LicenseValidationError, s as LicenseValidationRequest, t as LicenseValidationResponse, u as LicenseValidator, M as MessageBubbleProps, Z as PipelineStep, P as ProductCardProps, d as ProductCarouselProps, v as ProviderCredentials, w as ProviderNotFoundException, _ as ProviderPill, x as RateLimitException, R as RemoteConfig, y as RemoteEmbeddingConfig, z as RemoteLLMConfig, F as RemoteVectorConfig, $ as RenderSectionDecision, H as RenderType, J as RetrievalException, K as Retrivora, N as RetrivoraError, O as RetrivoraErrorCode, Q as SDKVersionUnsupportedError, T as SDK_VERSION, a0 as Snippet, S as SourceCardProps, a1 as wrapError } from './index-BST9Gzsv.mjs';
|
|
5
|
-
import { I as IProviderValidator, a as IProviderHealthChecker, H as HealthCheckResult } from './index-
|
|
6
|
-
export { C as ConfigValidator, b as HandlerOptions, V as ValidationError, c as VectorPlugin, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, i as createLicenseHandler, j as createRagHandler, k as createSessionsHandler, l as createStreamHandler, m as createSuggestionsHandler, n as createUploadHandler, s as sseErrorFrame, o as sseFrame, p as sseMetaFrame, q as sseObservabilityFrame, r as sseTextFrame, t as sseUIFrame } from './index-
|
|
5
|
+
import { I as IProviderValidator, a as IProviderHealthChecker, H as HealthCheckResult } from './index-BBbt5A2y.mjs';
|
|
6
|
+
export { C as ConfigValidator, b as HandlerOptions, V as ValidationError, c as VectorPlugin, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, i as createLicenseHandler, j as createRagHandler, k as createSessionsHandler, l as createStreamHandler, m as createSuggestionsHandler, n as createUploadHandler, s as sseErrorFrame, o as sseFrame, p as sseMetaFrame, q as sseObservabilityFrame, r as sseTextFrame, t as sseUIFrame } from './index-BBbt5A2y.mjs';
|
|
7
7
|
import 'react';
|
|
8
8
|
import 'next/server';
|
|
9
9
|
|
package/dist/server.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { b as RagConfig, f as UniversalRagConfig, h as VectorDBConfig, y as Upse
|
|
|
2
2
|
export { A as AuthMode, N as BarChartData, Q as CarouselProduct, S as IRetriever, o as LatencyBreakdown, X as LineChartDataPoint, Y as MessageRole, Z as MetricCardData, O as ObservabilityTrace, _ as PieChartData, P as Product, p as ProjectAiSettings, q as ProjectAuthSettings, r as ProjectBrandingSettings, a as ProjectChatSettings, s as ProjectTelemetrySettings, t as ProjectWidgetSettings, R as RagMessage, v as RetrievalConfig, e as RetrievalResult, w as RetrievedChunk, $ as RetrivoraChunkMetadata, a0 as RetrivoraIngestedDocument, a1 as ScatterPlotDataPoint, a2 as SuggestionsResponse, a3 as TableData, T as ThemeMode, x as TokenUsage, i as UseRagChatOptions, j as UseRagChatReturn, a4 as VisualizationType, W as WidgetPosition, B as WorkflowConfig, D as createDefaultProjectSettings, F as normalizeProjectSettings, G as projectSettingsToUiConfig } from './ILLMProvider-CzXcTA6d.js';
|
|
3
3
|
import { V as Pipeline, o as DecisionContext, q as IntentCategory, I as IRenderRule, G as RenderDecision, p as IRendererStrategy } from './index-qLvtMUr-.js';
|
|
4
4
|
export { W as ArchitectureCardProps, A as AuthenticationException, B as BatchOptions, f as BatchProcessor, g as BatchResult, h as ChartType, e as ChatViewportSize, C as ChatWidgetProps, a as ChatWindowProps, i as Chunk, j as ChunkOptions, c as ClientConfig, m as ConfigFetcher, b as ConfigProviderProps, n as ConfigurationException, X as DocumentChunker, D as DocumentUploadProps, E as EmbeddingFailedException, Y as LicenseConfigResolver, L as LicenseTierConfig, r as LicenseValidationError, s as LicenseValidationRequest, t as LicenseValidationResponse, u as LicenseValidator, M as MessageBubbleProps, Z as PipelineStep, P as ProductCardProps, d as ProductCarouselProps, v as ProviderCredentials, w as ProviderNotFoundException, _ as ProviderPill, x as RateLimitException, R as RemoteConfig, y as RemoteEmbeddingConfig, z as RemoteLLMConfig, F as RemoteVectorConfig, $ as RenderSectionDecision, H as RenderType, J as RetrievalException, K as Retrivora, N as RetrivoraError, O as RetrivoraErrorCode, Q as SDKVersionUnsupportedError, T as SDK_VERSION, a0 as Snippet, S as SourceCardProps, a1 as wrapError } from './index-qLvtMUr-.js';
|
|
5
|
-
import { I as IProviderValidator, a as IProviderHealthChecker, H as HealthCheckResult } from './index-
|
|
6
|
-
export { C as ConfigValidator, b as HandlerOptions, V as ValidationError, c as VectorPlugin, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, i as createLicenseHandler, j as createRagHandler, k as createSessionsHandler, l as createStreamHandler, m as createSuggestionsHandler, n as createUploadHandler, s as sseErrorFrame, o as sseFrame, p as sseMetaFrame, q as sseObservabilityFrame, r as sseTextFrame, t as sseUIFrame } from './index-
|
|
5
|
+
import { I as IProviderValidator, a as IProviderHealthChecker, H as HealthCheckResult } from './index-BZ_rR6V8.js';
|
|
6
|
+
export { C as ConfigValidator, b as HandlerOptions, V as ValidationError, c as VectorPlugin, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, i as createLicenseHandler, j as createRagHandler, k as createSessionsHandler, l as createStreamHandler, m as createSuggestionsHandler, n as createUploadHandler, s as sseErrorFrame, o as sseFrame, p as sseMetaFrame, q as sseObservabilityFrame, r as sseTextFrame, t as sseUIFrame } from './index-BZ_rR6V8.js';
|
|
7
7
|
import 'react';
|
|
8
8
|
import 'next/server';
|
|
9
9
|
|
package/dist/server.js
CHANGED
|
@@ -84,6 +84,9 @@ function isRecord(value) {
|
|
|
84
84
|
function resolvePath(obj, path2) {
|
|
85
85
|
if (!path2 || !obj) return void 0;
|
|
86
86
|
return path2.replace(/\[(\w+)\]/g, ".$1").replace(/^\./, "").split(".").reduce((current, segment) => {
|
|
87
|
+
if (segment === "__proto__" || segment === "constructor" || segment === "prototype") {
|
|
88
|
+
return void 0;
|
|
89
|
+
}
|
|
87
90
|
if (!isRecord(current) && !Array.isArray(current)) {
|
|
88
91
|
return void 0;
|
|
89
92
|
}
|
|
@@ -94,8 +97,9 @@ function buildPayload(template, vars) {
|
|
|
94
97
|
let raw = template;
|
|
95
98
|
for (const [key, val] of Object.entries(vars)) {
|
|
96
99
|
const stringifiedVal = val === void 0 ? "null" : JSON.stringify(val);
|
|
97
|
-
|
|
98
|
-
raw = raw.replace(new RegExp(
|
|
100
|
+
const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
101
|
+
raw = raw.replace(new RegExp(`"\\{\\{${escapedKey}\\}\\}"`, "g"), () => stringifiedVal);
|
|
102
|
+
raw = raw.replace(new RegExp(`\\{\\{${escapedKey}\\}\\}`, "g"), () => stringifiedVal);
|
|
99
103
|
}
|
|
100
104
|
try {
|
|
101
105
|
return JSON.parse(raw);
|
|
@@ -332,7 +336,7 @@ var init_package = __esm({
|
|
|
332
336
|
"package.json"() {
|
|
333
337
|
package_default = {
|
|
334
338
|
name: "@retrivora-ai/rag-engine",
|
|
335
|
-
version: "2.6.
|
|
339
|
+
version: "2.6.3",
|
|
336
340
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
337
341
|
author: "Abhinav Alkuchi",
|
|
338
342
|
license: "UNLICENSED",
|
|
@@ -1104,13 +1108,14 @@ var init_PostgreSQLProvider = __esm({
|
|
|
1104
1108
|
const filterConditions = Object.entries(publicFilter).map(([key, val]) => {
|
|
1105
1109
|
const paramIdx = params.length + 1;
|
|
1106
1110
|
params.push(String(val));
|
|
1107
|
-
return `metadata->>'${key}' = $${paramIdx}`;
|
|
1111
|
+
return `metadata->>'${key.replace(/[^a-zA-Z0-9_.-]/g, "")}' = $${paramIdx}`;
|
|
1108
1112
|
}).join(" AND ");
|
|
1109
1113
|
whereClause = whereClause ? `${whereClause} AND ${filterConditions}` : `WHERE ${filterConditions}`;
|
|
1110
1114
|
}
|
|
1111
1115
|
const client = await this.pool.connect();
|
|
1112
1116
|
try {
|
|
1113
|
-
const
|
|
1117
|
+
const rawEfSearch = Number(this.config.options.efSearch) || Math.max(topK * 10, 40);
|
|
1118
|
+
const efSearch = Math.max(1, Math.min(1e3, Math.floor(Number.isFinite(rawEfSearch) ? rawEfSearch : 40)));
|
|
1114
1119
|
await client.query(`SET LOCAL hnsw.ef_search = ${efSearch}`);
|
|
1115
1120
|
const result = await client.query(
|
|
1116
1121
|
`SELECT id, content, metadata, 1 - (embedding <=> $1::vector) AS score
|
|
@@ -1254,7 +1259,11 @@ var init_MultiTablePostgresProvider = __esm({
|
|
|
1254
1259
|
this.tables = [];
|
|
1255
1260
|
const rawSearchFields = (_c = (_b = opts.searchFields) != null ? _b : process.env.VECTOR_DB_SEARCH_FIELDS) != null ? _c : ["name", "product_name", "productname", "title"];
|
|
1256
1261
|
this.searchFields = typeof rawSearchFields === "string" ? rawSearchFields.split(",").map((f) => f.trim()).filter(Boolean) : rawSearchFields;
|
|
1257
|
-
|
|
1262
|
+
const rawUploadTable = opts.uploadTable || "document_chunks";
|
|
1263
|
+
if (!/^[a-zA-Z_][a-zA-Z0-9_]{0,62}$/.test(rawUploadTable)) {
|
|
1264
|
+
throw new Error(`Invalid uploadTable name: ${rawUploadTable}`);
|
|
1265
|
+
}
|
|
1266
|
+
this.uploadTable = rawUploadTable;
|
|
1258
1267
|
}
|
|
1259
1268
|
async initialize() {
|
|
1260
1269
|
this.pool = new import_pg2.Pool({ connectionString: this.connectionString });
|
|
@@ -1437,7 +1446,7 @@ var init_MultiTablePostgresProvider = __esm({
|
|
|
1437
1446
|
const baseOffset = queryText && dynamicKeywordQuery ? 2 : 1;
|
|
1438
1447
|
const paramIdx = baseOffset + filterParams.length;
|
|
1439
1448
|
const synonyms = (_a4 = FIELD_SYNONYMS[key]) != null ? _a4 : [];
|
|
1440
|
-
const keysToCheck = [key, ...synonyms];
|
|
1449
|
+
const keysToCheck = [key, ...synonyms].filter((k) => /^[a-zA-Z_][a-zA-Z0-9_]{0,62}$/.test(k));
|
|
1441
1450
|
const coalesceExprs = keysToCheck.flatMap((k) => [
|
|
1442
1451
|
`metadata->>'${k}'`,
|
|
1443
1452
|
`to_jsonb(t)->>'${k}'`
|
|
@@ -1454,7 +1463,7 @@ var init_MultiTablePostgresProvider = __esm({
|
|
|
1454
1463
|
THEN 1.0 ELSE 0.0 END
|
|
1455
1464
|
), 0)
|
|
1456
1465
|
FROM jsonb_each_text(COALESCE(v.metadata, k.metadata)) AS kv(key, val)
|
|
1457
|
-
WHERE key IN (${this.searchFields.map((f) => `'${f}'`).join(", ")})
|
|
1466
|
+
WHERE key IN (${this.searchFields.map((f) => `'${f.replace(/'/g, "''")}'`).join(", ")})
|
|
1458
1467
|
) * 3.0` : "";
|
|
1459
1468
|
sqlQuery = `
|
|
1460
1469
|
WITH vector_search AS (
|
|
@@ -2928,6 +2937,7 @@ var _LicenseVerifier = class _LicenseVerifier {
|
|
|
2928
2937
|
* Computes a deterministic hardware fingerprint to enforce node-locked licensing.
|
|
2929
2938
|
*/
|
|
2930
2939
|
static async generateMachineFingerprint() {
|
|
2940
|
+
if (typeof process !== "undefined" && (process.env.VERCEL || process.env.AWS_LAMBDA_FUNCTION_NAME)) return "browser-client";
|
|
2931
2941
|
if (typeof window !== "undefined" && typeof navigator !== "undefined") {
|
|
2932
2942
|
return "browser-client";
|
|
2933
2943
|
}
|
|
@@ -2991,7 +3001,7 @@ var _LicenseVerifier = class _LicenseVerifier {
|
|
|
2991
3001
|
}
|
|
2992
3002
|
}
|
|
2993
3003
|
try {
|
|
2994
|
-
let baseUrl = typeof process !== "undefined" && process.env.RETRIVORA_CONTROL_PLANE_URL ? process.env.RETRIVORA_CONTROL_PLANE_URL : "https://retrivora.com";
|
|
3004
|
+
let baseUrl = typeof process !== "undefined" && process.env.RETRIVORA_CONTROL_PLANE_URL ? process.env.RETRIVORA_CONTROL_PLANE_URL : "https://www.retrivora.com";
|
|
2995
3005
|
if (typeof process !== "undefined" && process.env.TELEMETRY_URL) {
|
|
2996
3006
|
baseUrl = process.env.TELEMETRY_URL.replace(/\/api\/telemetry\/?$/, "");
|
|
2997
3007
|
}
|
|
@@ -4462,7 +4472,7 @@ var GroqProvider = class {
|
|
|
4462
4472
|
return (_i = (_h = (_g2 = completion.choices[0]) == null ? void 0 : _g2.message) == null ? void 0 : _h.content) != null ? _i : "";
|
|
4463
4473
|
} catch (err) {
|
|
4464
4474
|
console.warn("[GroqProvider] Groq chat request failed, falling back strictly to Hugging Face Qwen:", (err == null ? void 0 : err.message) || err);
|
|
4465
|
-
const hfToken = process.env.HF_TOKEN || process.env.HUGGINGFACE_API_KEY || "
|
|
4475
|
+
const hfToken = process.env.HF_TOKEN || process.env.HUGGINGFACE_API_KEY || "";
|
|
4466
4476
|
try {
|
|
4467
4477
|
const hfRes = await fetch("https://router.huggingface.co/v1/chat/completions", {
|
|
4468
4478
|
method: "POST",
|
|
@@ -4534,7 +4544,7 @@ var GroqProvider = class {
|
|
|
4534
4544
|
}
|
|
4535
4545
|
} catch (err) {
|
|
4536
4546
|
console.warn("[GroqProvider] Groq chat stream failed, falling back strictly to Hugging Face Qwen stream:", (err == null ? void 0 : err.message) || err);
|
|
4537
|
-
const hfToken = process.env.HF_TOKEN || process.env.HUGGINGFACE_API_KEY || "
|
|
4547
|
+
const hfToken = process.env.HF_TOKEN || process.env.HUGGINGFACE_API_KEY || "";
|
|
4538
4548
|
try {
|
|
4539
4549
|
const hfRes = yield new __await(fetch("https://router.huggingface.co/v1/chat/completions", {
|
|
4540
4550
|
method: "POST",
|
|
@@ -6959,7 +6969,7 @@ var MCPClient = class {
|
|
|
6959
6969
|
}
|
|
6960
6970
|
const args = this.config.args || [];
|
|
6961
6971
|
const env = __spreadValues(__spreadValues({}, process.env), this.config.env || {});
|
|
6962
|
-
this.childProcess = (0, import_child_process.spawn)(cmd, args, { env
|
|
6972
|
+
this.childProcess = (0, import_child_process.spawn)(cmd, args, { env });
|
|
6963
6973
|
if (!this.childProcess || !this.childProcess.stdout || !this.childProcess.stdin) {
|
|
6964
6974
|
throw new Error(`[MCPClient] Failed to spawn stdio child process for "${this.config.name}"`);
|
|
6965
6975
|
}
|
|
@@ -7003,7 +7013,11 @@ var MCPClient = class {
|
|
|
7003
7013
|
if (!this.config.url) {
|
|
7004
7014
|
throw new Error(`[MCPClient] URL is required for sse transport on "${this.config.name}"`);
|
|
7005
7015
|
}
|
|
7006
|
-
|
|
7016
|
+
const parsed = new URL(this.config.url);
|
|
7017
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
7018
|
+
throw new Error(`[MCPClient] Invalid SSE URL protocol: ${parsed.protocol}`);
|
|
7019
|
+
}
|
|
7020
|
+
this.sseUrl = parsed.toString();
|
|
7007
7021
|
}
|
|
7008
7022
|
async sendJsonRpc(method, params) {
|
|
7009
7023
|
const id = this.getNextMessageId();
|
|
@@ -7018,7 +7032,16 @@ var MCPClient = class {
|
|
|
7018
7032
|
throw new Error(`[MCPClient] Server "${this.config.name}" is not connected (stdio process missing)`);
|
|
7019
7033
|
}
|
|
7020
7034
|
return new Promise((resolve, reject) => {
|
|
7021
|
-
|
|
7035
|
+
const timer = setTimeout(() => {
|
|
7036
|
+
if (this.pendingRequests.delete(id)) reject(new Error(`[MCPClient] Request ${method} (id=${id}) timed out after 30000ms`));
|
|
7037
|
+
}, 3e4);
|
|
7038
|
+
this.pendingRequests.set(id, { resolve: (val) => {
|
|
7039
|
+
clearTimeout(timer);
|
|
7040
|
+
resolve(val);
|
|
7041
|
+
}, reject: (err) => {
|
|
7042
|
+
clearTimeout(timer);
|
|
7043
|
+
reject(err);
|
|
7044
|
+
} });
|
|
7022
7045
|
this.childProcess.stdin.write(JSON.stringify(request) + "\n", "utf-8");
|
|
7023
7046
|
});
|
|
7024
7047
|
} else {
|
|
@@ -7357,7 +7380,7 @@ Once you have gathered enough information to fully satisfy the user query, write
|
|
|
7357
7380
|
try {
|
|
7358
7381
|
if (toolName === "document_search") {
|
|
7359
7382
|
const query = String((_a2 = toolArgs.query) != null ? _a2 : "");
|
|
7360
|
-
const { sources } = yield new __await(this.retriever.retrieve(query));
|
|
7383
|
+
const { sources } = yield new __await(this.retriever.retrieve(query, { namespace: typeof toolArgs.namespace === "string" ? toolArgs.namespace : void 0 }));
|
|
7361
7384
|
const snippets = sources.slice(0, 5).map((s, i) => {
|
|
7362
7385
|
var _a3;
|
|
7363
7386
|
return `[${i + 1}] ${String((_a3 = s.content) != null ? _a3 : "").slice(0, 400)}`;
|
|
@@ -7838,7 +7861,8 @@ var QueryProcessor = class {
|
|
|
7838
7861
|
}
|
|
7839
7862
|
if (validFields.length > 0) {
|
|
7840
7863
|
for (const field of validFields) {
|
|
7841
|
-
const
|
|
7864
|
+
const escapedField = field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7865
|
+
const pattern = new RegExp(`\\b${escapedField}\\s*(?:is|are|:|of)?\\s+["']?([^"\\n?.!,]{1,60})["']?(?=[?.!,]|$)`, "gi");
|
|
7842
7866
|
for (const match of question.matchAll(pattern)) {
|
|
7843
7867
|
const value = match[1];
|
|
7844
7868
|
if (value && !this.isLikelyPromptPhrase(value)) {
|
|
@@ -11560,12 +11584,14 @@ __reExport(FreeTierLimitsGuard_exports, require("@retrivora-ai/billing-guards"))
|
|
|
11560
11584
|
|
|
11561
11585
|
// src/core/VectorPlugin.ts
|
|
11562
11586
|
var VectorPlugin = class {
|
|
11563
|
-
constructor(hostConfig) {
|
|
11587
|
+
constructor(hostConfig, options) {
|
|
11564
11588
|
const resolvedConfig = ConfigResolver.resolve(hostConfig);
|
|
11565
11589
|
this.config = resolvedConfig;
|
|
11566
11590
|
this.validationPromise = (async () => {
|
|
11567
11591
|
var _a2;
|
|
11568
11592
|
await ConfigValidator.validateAndThrow(resolvedConfig);
|
|
11593
|
+
const isControlPlane = Boolean(typeof process !== "undefined" && process.env.LITELLM_MASTER_KEY && resolvedConfig.licenseKey === process.env.LITELLM_MASTER_KEY);
|
|
11594
|
+
if ((options == null ? void 0 : options.skipLicenseCheck) || isControlPlane) return;
|
|
11569
11595
|
await LicenseVerifier.verifyAsync(
|
|
11570
11596
|
resolvedConfig.licenseKey,
|
|
11571
11597
|
resolvedConfig.projectId,
|
|
@@ -12880,7 +12906,13 @@ var _DatabaseStorage = class _DatabaseStorage {
|
|
|
12880
12906
|
getPGPool() {
|
|
12881
12907
|
const globalKey = `pg:${this.config.projectId}`;
|
|
12882
12908
|
if (!_pgInitPromises.has(globalKey)) {
|
|
12883
|
-
_pgInitPromises.set(
|
|
12909
|
+
_pgInitPromises.set(
|
|
12910
|
+
globalKey,
|
|
12911
|
+
this.createPGPool().catch((err) => {
|
|
12912
|
+
_pgInitPromises.delete(globalKey);
|
|
12913
|
+
throw err;
|
|
12914
|
+
})
|
|
12915
|
+
);
|
|
12884
12916
|
}
|
|
12885
12917
|
return _pgInitPromises.get(globalKey);
|
|
12886
12918
|
}
|
|
@@ -13433,8 +13465,8 @@ function resolveLicensedNamespace(payload, requestedNamespace) {
|
|
|
13433
13465
|
var _a2;
|
|
13434
13466
|
const allowed = getAllowedNamespaces(payload.projectId);
|
|
13435
13467
|
const requested = requestedNamespace == null ? void 0 : requestedNamespace.trim();
|
|
13436
|
-
const
|
|
13437
|
-
if (requested && !
|
|
13468
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
13469
|
+
if (requested && !isDev && !allowed.has(requested)) {
|
|
13438
13470
|
return {
|
|
13439
13471
|
ok: false,
|
|
13440
13472
|
response: new Response(JSON.stringify({
|
|
@@ -13478,7 +13510,7 @@ function getOrCreatePlugin(configOrPlugin) {
|
|
|
13478
13510
|
const key = configHash(configOrPlugin);
|
|
13479
13511
|
const cached = _pluginCache.get(key);
|
|
13480
13512
|
if (cached && Date.now() - cached.createdAt < PLUGIN_CACHE_TTL_MS) return cached.plugin;
|
|
13481
|
-
const plugin = new VectorPlugin(configOrPlugin);
|
|
13513
|
+
const plugin = new VectorPlugin(configOrPlugin, { skipLicenseCheck: true });
|
|
13482
13514
|
_pluginCache.set(key, { plugin, createdAt: Date.now() });
|
|
13483
13515
|
return plugin;
|
|
13484
13516
|
}
|
|
@@ -14387,7 +14419,7 @@ function createFeedbackHandler(configOrPlugin, options) {
|
|
|
14387
14419
|
}
|
|
14388
14420
|
if (scope && scope.length > 0) {
|
|
14389
14421
|
const matches = scope.some(
|
|
14390
|
-
(pid) => pid && (sessionId === pid || sessionId.startsWith(pid) || sessionId.
|
|
14422
|
+
(pid) => pid && (sessionId === pid || sessionId.startsWith(`${pid}:`) || sessionId.startsWith(`${pid}-`) || sessionId.startsWith(`${pid}_`))
|
|
14391
14423
|
);
|
|
14392
14424
|
if (!matches) {
|
|
14393
14425
|
return import_server10.NextResponse.json(
|
|
@@ -14497,7 +14529,8 @@ function createRagHandler(configOrPlugin, options) {
|
|
|
14497
14529
|
const pathname = url.pathname;
|
|
14498
14530
|
if (pathname.includes("/license/validate")) return "v1/license/validate";
|
|
14499
14531
|
if (pathname.endsWith("/upload")) return "upload";
|
|
14500
|
-
if (pathname.endsWith("/chat
|
|
14532
|
+
if (pathname.endsWith("/chat-sync")) return "chat-sync";
|
|
14533
|
+
if (pathname.endsWith("/chat")) return "chat";
|
|
14501
14534
|
if (pathname.endsWith("/health")) return "health";
|
|
14502
14535
|
if (pathname.endsWith("/suggestions")) return "suggestions";
|
|
14503
14536
|
if (pathname.endsWith("/feedback")) return "feedback";
|