@retrivora-ai/rag-engine 2.5.2 → 2.5.4

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.
@@ -312,7 +312,7 @@ var init_package = __esm({
312
312
  "package.json"() {
313
313
  package_default = {
314
314
  name: "@retrivora-ai/rag-engine",
315
- version: "2.5.2",
315
+ version: "2.5.4",
316
316
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
317
317
  author: "Abhinav Alkuchi",
318
318
  license: "UNLICENSED",
@@ -394,7 +394,7 @@ var init_package = __esm({
394
394
  lint: "eslint",
395
395
  typecheck: "tsc --noEmit -p tsconfig.build.json",
396
396
  test: "jest",
397
- clean: "rm -rf dist"
397
+ clean: `node -e "require('fs').rmSync('dist', { recursive: true, force: true })"`
398
398
  },
399
399
  peerDependencies: {
400
400
  axios: ">=1.0.0",
@@ -414,18 +414,24 @@ var init_package = __esm({
414
414
  "@anthropic-ai/sdk": "^0.95.1",
415
415
  "@google/genai": "^0.8.0",
416
416
  "@google/generative-ai": "^0.24.1",
417
- "@retrivora-ai/billing-guards": "*",
418
417
  "@pinecone-database/pinecone": "^7.2.0",
418
+ "@retrivora-ai/billing-guards": "*",
419
419
  "@types/papaparse": "^5.5.2",
420
+ "framer-motion": "^13.1.0",
421
+ katex: "^0.18.4",
420
422
  "lucide-react": "^1.8.0",
421
423
  "next-themes": "^0.4.6",
422
424
  openai: "^6.34.0",
423
425
  papaparse: "^5.5.3",
424
426
  "react-is": "^18.3.1",
425
427
  "react-markdown": "^10.1.0",
428
+ "react-syntax-highlighter": "^16.1.1",
426
429
  recharts: "^3.8.1",
430
+ "rehype-katex": "^7.0.1",
427
431
  "remark-gfm": "^4.0.1",
428
- xlsx: "^0.18.5"
432
+ "remark-math": "^6.0.0",
433
+ exceljs: "^4.4.0",
434
+ zod: "^4.4.3"
429
435
  },
430
436
  optionalDependencies: {
431
437
  "@langchain/core": "^1.1.42",
@@ -442,17 +448,19 @@ var init_package = __esm({
442
448
  "@tailwindcss/postcss": "^4",
443
449
  "@types/estree": "^1.0.9",
444
450
  "@types/jest": "^30.0.0",
451
+ "@types/katex": "^0.16.8",
445
452
  "@types/node": "^20",
446
453
  "@types/pdf-parse": "^1.1.5",
447
454
  "@types/pg": "^8.20.0",
448
455
  "@types/react": "^19.2.14",
449
456
  "@types/react-dom": "^19.2.3",
457
+ "@types/react-syntax-highlighter": "^15.5.13",
450
458
  axios: "^1.15.0",
451
459
  dotenv: "^17.4.2",
452
460
  eslint: "^9",
453
- "eslint-config-next": "16.2.4",
461
+ "eslint-config-next": "16.3.2",
454
462
  jest: "^30.4.2",
455
- next: "16.2.10",
463
+ next: "^16.3.2",
456
464
  tailwindcss: "^4",
457
465
  "ts-jest": "^29.4.12",
458
466
  tsup: "^8.5.1",
@@ -2742,6 +2750,36 @@ function wrapError(err, defaultCode, defaultMessage) {
2742
2750
  // src/core/LicenseVerifier.ts
2743
2751
  var _LicenseVerifier = class _LicenseVerifier {
2744
2752
  // Cache verified license for 5 minutes
2753
+ /**
2754
+ * Computes a deterministic hardware fingerprint to enforce node-locked licensing.
2755
+ */
2756
+ static async generateMachineFingerprint() {
2757
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
2758
+ return navigator.userAgent || "browser-fallback-fingerprint";
2759
+ }
2760
+ try {
2761
+ const os2 = await import("os");
2762
+ const crypto2 = await import("crypto");
2763
+ const interfaces = os2.networkInterfaces();
2764
+ const macAddresses = [];
2765
+ for (const name of Object.keys(interfaces)) {
2766
+ for (const iface of interfaces[name] || []) {
2767
+ if (!iface.internal && iface.mac && iface.mac !== "00:00:00:00:00:00") {
2768
+ macAddresses.push(iface.mac);
2769
+ }
2770
+ }
2771
+ }
2772
+ const rawData = [
2773
+ macAddresses.sort().join(","),
2774
+ os2.platform(),
2775
+ os2.arch(),
2776
+ os2.hostname()
2777
+ ].join("|");
2778
+ return crypto2.createHash("sha256").update(rawData).digest("hex");
2779
+ } catch (err) {
2780
+ return "fallback-fingerprint-failed";
2781
+ }
2782
+ }
2745
2783
  /**
2746
2784
  * Validates the license key asynchronously by calling the Retrivora backend.
2747
2785
  *
@@ -2785,6 +2823,7 @@ var _LicenseVerifier = class _LicenseVerifier {
2785
2823
  }
2786
2824
  const endpoint = `${baseUrl}/api/v1/license/validate`;
2787
2825
  let response;
2826
+ const machineFingerprint = await this.generateMachineFingerprint();
2788
2827
  try {
2789
2828
  response = await fetch(endpoint, {
2790
2829
  method: "POST",
@@ -2795,7 +2834,8 @@ var _LicenseVerifier = class _LicenseVerifier {
2795
2834
  body: JSON.stringify({
2796
2835
  licenseKey,
2797
2836
  projectId: currentProjectId,
2798
- provider
2837
+ provider,
2838
+ machineFingerprint
2799
2839
  })
2800
2840
  });
2801
2841
  } catch (fetchErr) {
@@ -3003,7 +3043,6 @@ var PROVIDERS_WITH_EMBEDDINGS = [
3003
3043
  "rest",
3004
3044
  "universal_rest"
3005
3045
  ];
3006
- var UI_BORDER_RADIUS_OPTIONS = ["none", "sm", "md", "lg", "xl", "full"];
3007
3046
 
3008
3047
  // src/config/serverConfig.ts
3009
3048
  var _runtimeConfig = null;
@@ -3115,7 +3154,7 @@ function getEnvConfig(env = process.env, base) {
3115
3154
  return true;
3116
3155
  }
3117
3156
  })();
3118
- const tierBasedLLMModel = isFreeTier2 ? "llama-3.1-8b-instant" : "llama-3.3-70b-versatile";
3157
+ const tierBasedLLMModel = isFreeTier2 ? "free-tier-standard" : "qwen-3.6-27b";
3119
3158
  const tierBasedEmbeddingModel = isFreeTier2 ? "text-embedding-004" : "text-embedding-004";
3120
3159
  const controlPlaneUrl = (_ma = readString(env, "RETRIVORA_CONTROL_PLANE_URL")) != null ? _ma : readString(env, "NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL");
3121
3160
  const defaultGatewayUrl = controlPlaneUrl ? `${controlPlaneUrl.replace(/\/$/, "")}/api/v1` : "https://llm.retrivora.com/api/v1";
@@ -3123,7 +3162,16 @@ function getEnvConfig(env = process.env, base) {
3123
3162
  const defaultLlmProvider = "universal_rest";
3124
3163
  const llmProvider = (_pa = (_oa = readEnum(env, "LLM_PROVIDER", defaultLlmProvider, LLM_PROVIDERS)) != null ? _oa : (_na = base == null ? void 0 : base.llm) == null ? void 0 : _na.provider) != null ? _pa : defaultLlmProvider;
3125
3164
  const llmBaseUrl = (_ua = (_ta = (_sa = (_qa = readString(env, "LITELLM_BASE_URL")) != null ? _qa : readString(env, "LLM_BASE_URL")) != null ? _sa : (_ra = base == null ? void 0 : base.llm) == null ? void 0 : _ra.baseUrl) != null ? _ta : rt == null ? void 0 : rt.llmBaseUrl) != null ? _ua : defaultGatewayUrl;
3126
- const llmModel = (_ya = (_xa = (_wa = readString(env, "LLM_MODEL")) != null ? _wa : (_va = base == null ? void 0 : base.llm) == null ? void 0 : _va.model) != null ? _xa : rt == null ? void 0 : rt.llmModel) != null ? _ya : tierBasedLLMModel;
3165
+ let llmModel = (_ya = (_xa = (_wa = readString(env, "LLM_MODEL")) != null ? _wa : (_va = base == null ? void 0 : base.llm) == null ? void 0 : _va.model) != null ? _xa : rt == null ? void 0 : rt.llmModel) != null ? _ya : tierBasedLLMModel;
3166
+ if ((rt == null ? void 0 : rt.allowedModels) && rt.allowedModels.length > 0) {
3167
+ if (!rt.allowedModels.includes(llmModel)) {
3168
+ console.warn(`[Retrivora SDK] Model "${llmModel}" is not permitted on the current license tier. Falling back to default: ${rt.llmModel || tierBasedLLMModel}`);
3169
+ llmModel = rt.llmModel || tierBasedLLMModel;
3170
+ }
3171
+ } else if (isFreeTier2 && llmModel !== "free-tier-standard") {
3172
+ console.warn(`[Retrivora SDK] Explicit models are not permitted on the Free tier. Falling back to default load-balanced pool.`);
3173
+ llmModel = "free-tier-standard";
3174
+ }
3127
3175
  const llmApiKey = (_Ca = (_Ba = (_za = readString(env, "LITELLM_MASTER_KEY")) != null ? _za : rt == null ? void 0 : rt.litellmApiKey) != null ? _Ba : (_Aa = base == null ? void 0 : base.llm) == null ? void 0 : _Aa.apiKey) != null ? _Ca : licenseKey;
3128
3176
  const llmProfile = (_Ga = (_Fa = readString(env, "LLM_UNIVERSAL_PROFILE")) != null ? _Fa : (_Ea = (_Da = base == null ? void 0 : base.llm) == null ? void 0 : _Da.options) == null ? void 0 : _Ea.profile) != null ? _Ga : "litellm";
3129
3177
  const defaultEmbeddingProvider = "universal_rest";
@@ -3336,6 +3384,9 @@ var ConfigResolver = class {
3336
3384
  }
3337
3385
  };
3338
3386
 
3387
+ // src/core/ConfigValidator.ts
3388
+ import { z } from "zod";
3389
+
3339
3390
  // src/llm/providers/OpenAIProvider.ts
3340
3391
  import OpenAI from "openai";
3341
3392
 
@@ -3359,7 +3410,11 @@ ${context}`;
3359
3410
  var OpenAIProvider = class {
3360
3411
  constructor(llmConfig, embeddingConfig) {
3361
3412
  if (!llmConfig.apiKey) throw new Error("[OpenAIProvider] llmConfig.apiKey is required");
3362
- this.client = new OpenAI({ apiKey: llmConfig.apiKey });
3413
+ this.client = new OpenAI({
3414
+ apiKey: llmConfig.apiKey,
3415
+ baseURL: llmConfig.baseUrl,
3416
+ maxRetries: 5
3417
+ });
3363
3418
  this.llmConfig = llmConfig;
3364
3419
  this.embeddingConfig = embeddingConfig;
3365
3420
  }
@@ -4121,7 +4176,8 @@ var GroqProvider = class {
4121
4176
  if (!apiKey) throw new Error("[GroqProvider] llmConfig.apiKey or GROQ_API_KEY environment variable is required");
4122
4177
  this.client = new OpenAI2({
4123
4178
  apiKey,
4124
- baseURL: llmConfig.baseUrl || "https://api.groq.com/openai/v1"
4179
+ baseURL: llmConfig.baseUrl || "https://api.groq.com/openai/v1",
4180
+ maxRetries: 5
4125
4181
  });
4126
4182
  this.llmConfig = llmConfig;
4127
4183
  }
@@ -4141,7 +4197,7 @@ var GroqProvider = class {
4141
4197
  errors.push({
4142
4198
  field: "llm.model",
4143
4199
  message: "Groq model name is required",
4144
- suggestion: 'e.g., "llama-3.3-70b-versatile"',
4200
+ suggestion: 'e.g., "qwen-3.6-27b"',
4145
4201
  severity: "error"
4146
4202
  });
4147
4203
  }
@@ -5054,24 +5110,69 @@ ProviderRegistry.llmValidators = {};
5054
5110
  ProviderRegistry.llmHealthCheckers = {};
5055
5111
 
5056
5112
  // src/core/ConfigValidator.ts
5113
+ var UIConfigSchema = z.object({
5114
+ primaryColor: z.string().optional(),
5115
+ borderRadius: z.enum(["none", "sm", "md", "lg", "xl", "full"]).optional()
5116
+ }).passthrough().optional();
5117
+ var VectorDbSchema = z.object({
5118
+ provider: z.string().min(1, "Vector database provider is required"),
5119
+ indexName: z.string().min(1, "Vector database index name is required"),
5120
+ options: z.record(z.string(), z.unknown()).optional()
5121
+ }).passthrough().superRefine((val, ctx) => {
5122
+ const opts = val.options || {};
5123
+ if (val.provider === "milvus") {
5124
+ if (!opts.baseUrl && !opts.uri && !(opts.host && opts.port)) {
5125
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["options", "baseUrl"], message: "Milvus connection info required" });
5126
+ }
5127
+ } else if (val.provider === "qdrant") {
5128
+ if (!opts.baseUrl && !opts.url) {
5129
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["options", "baseUrl"], message: "Qdrant URL required" });
5130
+ }
5131
+ }
5132
+ });
5133
+ var LLMSchema = z.object({
5134
+ provider: z.string().min(1, "LLM provider is required"),
5135
+ model: z.string().optional(),
5136
+ temperature: z.number().min(0, "Temperature must be at least 0").max(2, "Temperature must be at most 2").optional()
5137
+ }).passthrough().superRefine((val, ctx) => {
5138
+ if (!val.model) {
5139
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["model"], message: "LLM model name is required" });
5140
+ }
5141
+ });
5142
+ var EmbeddingSchema = z.object({
5143
+ provider: z.string().min(1, "Embedding provider is required"),
5144
+ model: z.string().optional()
5145
+ }).passthrough().superRefine((val, ctx) => {
5146
+ if (!val.model) {
5147
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["model"], message: "Embedding model name is required" });
5148
+ }
5149
+ });
5150
+ var RAGSchema = z.object({
5151
+ topK: z.number().positive("topK must be a positive integer").optional()
5152
+ }).passthrough().optional();
5153
+ var RagConfigSchema = z.object({
5154
+ projectId: z.string().min(1, "projectId is required"),
5155
+ vectorDb: VectorDbSchema,
5156
+ llm: LLMSchema,
5157
+ embedding: EmbeddingSchema.optional(),
5158
+ ui: UIConfigSchema,
5159
+ rag: RAGSchema
5160
+ }).passthrough();
5057
5161
  var ConfigValidator = class {
5058
- /**
5059
- * Validates the entire RagConfig object.
5060
- */
5061
5162
  static async validate(config) {
5163
+ var _a2, _b, _c, _d, _e;
5062
5164
  const errors = [];
5063
- if (!config.projectId) {
5064
- errors.push({
5065
- field: "projectId",
5066
- message: "projectId is required",
5067
- severity: "error"
5068
- });
5165
+ const result = RagConfigSchema.safeParse(config);
5166
+ if (!result.success) {
5167
+ for (const issue of result.error.issues) {
5168
+ errors.push({
5169
+ field: issue.path.join("."),
5170
+ message: issue.message,
5171
+ severity: "error"
5172
+ });
5173
+ }
5069
5174
  }
5070
- errors.push(...await this.validateVectorDbConfig(config.vectorDb));
5071
- errors.push(...await this.validateLLMConfig(config.llm));
5072
- if (config.embedding) {
5073
- errors.push(...await this.validateEmbeddingConfig(config.embedding));
5074
- } else if (config.llm.provider === "anthropic") {
5175
+ if (((_a2 = config.llm) == null ? void 0 : _a2.provider) === "anthropic" && !config.embedding) {
5075
5176
  errors.push({
5076
5177
  field: "embedding",
5077
5178
  message: "Embedding config is required when using Anthropic LLM",
@@ -5079,113 +5180,35 @@ var ConfigValidator = class {
5079
5180
  severity: "error"
5080
5181
  });
5081
5182
  }
5082
- if (config.ui) {
5083
- errors.push(...this.validateUIConfig(config.ui));
5084
- }
5085
- if (config.rag) {
5086
- errors.push(...this.validateRAGConfig(config.rag));
5087
- }
5088
- return errors;
5089
- }
5090
- static async validateVectorDbConfig(config) {
5091
- const errors = [];
5092
- if (!config.provider) {
5093
- errors.push({ field: "vectorDb.provider", message: "Vector database provider is required", severity: "error" });
5094
- return errors;
5095
- }
5096
- if (!config.indexName) {
5097
- errors.push({ field: "vectorDb.indexName", message: "Vector database index name is required", severity: "error" });
5098
- }
5099
- const validator = await ProviderRegistry.getVectorValidator(config.provider);
5100
- if (validator) {
5101
- errors.push(...validator.validate(config));
5102
- } else {
5103
- this.fallbackVectorValidation(config, errors);
5104
- }
5105
- return errors;
5106
- }
5107
- static async validateLLMConfig(config) {
5108
- const errors = [];
5109
- if (!config.provider) {
5110
- errors.push({ field: "llm.provider", message: "LLM provider is required", severity: "error" });
5111
- return errors;
5112
- }
5113
- const validator = LLMFactory.getValidator(config.provider);
5114
- if (validator) {
5115
- errors.push(...validator.validate(config));
5116
- } else {
5117
- this.fallbackLLMValidation(config, errors);
5118
- }
5119
- if (config.temperature !== void 0 && (config.temperature < 0 || config.temperature > 2)) {
5120
- errors.push({ field: "llm.temperature", message: "Temperature must be between 0 and 2", severity: "error" });
5121
- }
5122
- return errors;
5123
- }
5124
- static async validateEmbeddingConfig(config) {
5125
- const errors = [];
5126
- if (!config.provider) {
5127
- errors.push({ field: "embedding.provider", message: "Embedding provider is required", severity: "error" });
5128
- return errors;
5129
- }
5130
- const validator = LLMFactory.getValidator(config.provider);
5131
- if (validator) {
5132
- errors.push(...validator.validate(config));
5133
- } else {
5134
- this.fallbackEmbeddingValidation(config, errors);
5135
- }
5136
- return errors;
5137
- }
5138
- /**
5139
- * Temporary fallbacks for providers not yet migrated to the pluggable architecture.
5140
- */
5141
- static fallbackVectorValidation(config, errors) {
5142
- const opts = config.options || {};
5143
- switch (config.provider) {
5144
- case "milvus":
5145
- if (!opts.baseUrl && !opts.uri && !(opts.host && opts.port)) {
5146
- errors.push({ field: "vectorDb.options.baseUrl", message: "Milvus connection info required", severity: "error" });
5147
- }
5148
- break;
5149
- case "qdrant":
5150
- if (!opts.baseUrl && !opts.url) {
5151
- errors.push({ field: "vectorDb.options.baseUrl", message: "Qdrant URL required", severity: "error" });
5152
- }
5153
- break;
5154
- }
5155
- }
5156
- static fallbackLLMValidation(config, errors) {
5157
- if (!config.model) {
5158
- errors.push({ field: "llm.model", message: "LLM model name is required", severity: "error" });
5159
- }
5160
- }
5161
- static fallbackEmbeddingValidation(config, errors) {
5162
- if (!config.model) {
5163
- errors.push({ field: "embedding.model", message: "Embedding model name is required", severity: "error" });
5183
+ if ((_b = config.ui) == null ? void 0 : _b.primaryColor) {
5184
+ const hexRegex = /^#([0-9a-f]{3}){1,2}$/i;
5185
+ const rgbRegex = /^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/i;
5186
+ const namedColors = ["red", "blue", "green", "black", "white", "transparent"];
5187
+ const color = config.ui.primaryColor;
5188
+ if (!hexRegex.test(color) && !rgbRegex.test(color) && !namedColors.includes(color.toLowerCase())) {
5189
+ errors.push({ field: "ui.primaryColor", message: "Invalid CSS color format", severity: "warning" });
5190
+ }
5164
5191
  }
5165
- }
5166
- static validateUIConfig(config) {
5167
- const errors = [];
5168
- if (config.primaryColor && !this.isValidCSSColor(config.primaryColor)) {
5169
- errors.push({ field: "ui.primaryColor", message: "Invalid CSS color format", severity: "warning" });
5192
+ if ((_c = config.vectorDb) == null ? void 0 : _c.provider) {
5193
+ const vectorValidator = await ProviderRegistry.getVectorValidator(config.vectorDb.provider);
5194
+ if (vectorValidator) {
5195
+ errors.push(...vectorValidator.validate(config.vectorDb));
5196
+ }
5170
5197
  }
5171
- if (config.borderRadius && !UI_BORDER_RADIUS_OPTIONS.includes(config.borderRadius)) {
5172
- errors.push({ field: "ui.borderRadius", message: `borderRadius must be one of: ${UI_BORDER_RADIUS_OPTIONS.join(", ")}`, severity: "warning" });
5198
+ if ((_d = config.llm) == null ? void 0 : _d.provider) {
5199
+ const llmValidator = LLMFactory.getValidator(config.llm.provider);
5200
+ if (llmValidator) {
5201
+ errors.push(...llmValidator.validate(config.llm));
5202
+ }
5173
5203
  }
5174
- return errors;
5175
- }
5176
- static validateRAGConfig(config) {
5177
- const errors = [];
5178
- if (config.topK !== void 0 && (typeof config.topK !== "number" || config.topK <= 0)) {
5179
- errors.push({ field: "rag.topK", message: "topK must be a positive integer", severity: "error" });
5204
+ if ((_e = config.embedding) == null ? void 0 : _e.provider) {
5205
+ const embeddingValidator = LLMFactory.getValidator(config.embedding.provider);
5206
+ if (embeddingValidator) {
5207
+ errors.push(...embeddingValidator.validate(config.embedding));
5208
+ }
5180
5209
  }
5181
5210
  return errors;
5182
5211
  }
5183
- static isValidCSSColor(color) {
5184
- const hexRegex = /^#([0-9a-f]{3}){1,2}$/i;
5185
- const rgbRegex = /^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/i;
5186
- const namedColors = ["red", "blue", "green", "black", "white", "transparent"];
5187
- return hexRegex.test(color) || rgbRegex.test(color) || namedColors.includes(color.toLowerCase());
5188
- }
5189
5212
  static async validateAndThrow(config) {
5190
5213
  const errors = await this.validate(config);
5191
5214
  const errorItems = errors.filter((e) => e.severity === "error");
@@ -5831,6 +5854,38 @@ var MCPRegistry = class {
5831
5854
  }
5832
5855
  };
5833
5856
 
5857
+ // src/utils/logger.ts
5858
+ var Logger = class {
5859
+ static format(level, message, meta) {
5860
+ if (this.isProduction) {
5861
+ return JSON.stringify(__spreadValues({
5862
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
5863
+ level,
5864
+ message
5865
+ }, meta));
5866
+ }
5867
+ const metaString = meta ? `
5868
+ ${JSON.stringify(meta, null, 2)}` : "";
5869
+ return `[${(/* @__PURE__ */ new Date()).toISOString()}] [${level}] ${message}${metaString}`;
5870
+ }
5871
+ static info(message, meta) {
5872
+ console.log(this.format("INFO", message, meta));
5873
+ }
5874
+ static warn(message, meta) {
5875
+ console.warn(this.format("WARN", message, meta));
5876
+ }
5877
+ static error(message, error, meta) {
5878
+ const errorMeta = error instanceof Error ? { errorMessage: error.message, stack: error.stack } : { error: String(error) };
5879
+ console.error(this.format("ERROR", message, __spreadValues(__spreadValues({}, meta), errorMeta)));
5880
+ }
5881
+ static debug(message, meta) {
5882
+ if (process.env.DEBUG === "true") {
5883
+ console.debug(this.format("DEBUG", message, meta));
5884
+ }
5885
+ }
5886
+ };
5887
+ Logger.isProduction = process.env.NODE_ENV === "production" || process.env.VERCEL_ENV === "production";
5888
+
5834
5889
  // src/core/MultiAgentCoordinator.ts
5835
5890
  function parseToolCall(text) {
5836
5891
  const match = text.match(/TOOL_CALL:\s*([\w-]+)\s*\(\s*([\s\S]*?)\s*\)\s*[.,;]?\s*$/m);
@@ -5848,7 +5903,7 @@ function parseToolCall(text) {
5848
5903
  } catch (e) {
5849
5904
  const pairs = [...argsRaw.matchAll(/"?([\w-]+)"?\s*:\s*"([^"]*)"/g)];
5850
5905
  if (pairs.length === 0) {
5851
- console.warn("[parseToolCall] Could not parse tool args:", argsRaw);
5906
+ Logger.warn("[parseToolCall] Could not parse tool args", { argsRaw });
5852
5907
  return null;
5853
5908
  }
5854
5909
  for (const [, k, v] of pairs) args[k] = v;
@@ -6251,7 +6306,7 @@ ${errorMessages}`
6251
6306
  static async mapWithRetry(items, mapper, options) {
6252
6307
  const result = await this.processSequential(items, mapper, options);
6253
6308
  if (result.errors.length > 0) {
6254
- console.warn(
6309
+ Logger.warn(
6255
6310
  `[BatchProcessor] mapWithRetry: ${result.errors.length} items failed`
6256
6311
  );
6257
6312
  }
@@ -8989,7 +9044,7 @@ var Pipeline = class {
8989
9044
  }
8990
9045
  await this.vectorDB.initialize();
8991
9046
  if (this.isMultiAgentMode) {
8992
- console.log("[Pipeline] Initializing MultiAgentCoordinator (multi-agent / MCP mode).");
9047
+ Logger.info("[Pipeline] Initializing MultiAgentCoordinator (multi-agent / MCP mode).");
8993
9048
  this.mcpRegistry = new MCPRegistry(this.config.mcpServers || []);
8994
9049
  this.multiAgentCoordinator = new MultiAgentCoordinator({
8995
9050
  llmProvider: this.llmProvider,
@@ -8999,7 +9054,7 @@ var Pipeline = class {
8999
9054
  maxIterations: (_a2 = this.config.rag) == null ? void 0 : _a2.agentMaxIterations
9000
9055
  });
9001
9056
  } else if (this.isLangChainAgentMode) {
9002
- console.log("[Pipeline] Initializing LangChainAgent (agentic / ReAct mode).");
9057
+ Logger.info("[Pipeline] Initializing LangChainAgent (agentic / ReAct mode).");
9003
9058
  this.agent = new LangChainAgent(this, this.config);
9004
9059
  await this.agent.initialize(this.llmProvider);
9005
9060
  }
@@ -9022,13 +9077,13 @@ var Pipeline = class {
9022
9077
  const formatted = coldMatches.map((m, i) => `[Cold Source ${i + 1}]
9023
9078
  ${m.content}`).join("\n\n---\n\n");
9024
9079
  this.coldContexts.set(ns, formatted);
9025
- console.log(`[Pipeline] Cold RAG (CAG) loaded ${coldMatches.length} documents into cached context for namespace: ${ns}`);
9080
+ Logger.info(`[Pipeline] Cold RAG (CAG) loaded ${coldMatches.length} documents into cached context for namespace: ${ns}`);
9026
9081
  } else {
9027
9082
  this.coldContexts.set(ns, "No cold context found.");
9028
- console.warn(`[Pipeline] Cold RAG (CAG) initialized but no documents were found in namespace: ${coldNs}`);
9083
+ Logger.warn(`[Pipeline] Cold RAG (CAG) initialized but no documents were found in namespace: ${coldNs}`);
9029
9084
  }
9030
9085
  } catch (err) {
9031
- console.error(`[Pipeline] Failed to load Cold RAG (CAG) context for namespace ${ns}:`, err);
9086
+ Logger.error(`[Pipeline] Failed to load Cold RAG (CAG) context for namespace ${ns}`, err);
9032
9087
  this.coldContexts.set(ns, "Failed to load cold context.");
9033
9088
  }
9034
9089
  }
@@ -9055,7 +9110,7 @@ ${m.content}`).join("\n\n---\n\n");
9055
9110
  await this.processGraphIngestion(doc.docId, chunks);
9056
9111
  }
9057
9112
  } catch (error) {
9058
- console.error(`[Pipeline] Failed to ingest document ${doc.docId}:`, error);
9113
+ Logger.error(`[Pipeline] Failed to ingest document ${doc.docId}`, error);
9059
9114
  results.push({ docId: doc.docId, chunksIngested: 0 });
9060
9115
  }
9061
9116
  }
@@ -9109,10 +9164,7 @@ ${m.content}`).join("\n\n---\n\n");
9109
9164
  upsertBatchOptions
9110
9165
  );
9111
9166
  if (upsertResult.errors.length > 0) {
9112
- console.warn(`[Pipeline] Ingestion: ${upsertResult.errors.length} batches failed. Error details:`);
9113
- upsertResult.errors.forEach((err, idx) => {
9114
- console.warn(` Batch ${idx + 1} Error: ${err.error.message || String(err.error)}`);
9115
- });
9167
+ Logger.warn(`[Pipeline] Ingestion: ${upsertResult.errors.length} batches failed.`, { errors: upsertResult.errors.map((e) => e.error.message || String(e.error)) });
9116
9168
  }
9117
9169
  return upsertResult.totalProcessed;
9118
9170
  }
@@ -9132,7 +9184,7 @@ ${m.content}`).join("\n\n---\n\n");
9132
9184
  if (nodes.length > 0) await this.graphDB.addNodes(nodes);
9133
9185
  if (edges.length > 0) await this.graphDB.addEdges(edges);
9134
9186
  } catch (err) {
9135
- console.warn(`[Pipeline] Entity extraction failed for chunk in doc ${docId}:`, err);
9187
+ Logger.warn(`[Pipeline] Entity extraction failed for chunk in doc ${docId}`, { error: String(err) });
9136
9188
  }
9137
9189
  }
9138
9190
  },
@@ -9393,7 +9445,7 @@ ${context}`;
9393
9445
  cachedSchema,
9394
9446
  hasNumericPredicates
9395
9447
  ).catch((uiError) => {
9396
- console.warn("[Pipeline] UI transformation failed concurrently:", uiError);
9448
+ Logger.warn("[Pipeline] UI transformation failed concurrently", { error: String(uiError) });
9397
9449
  return UITransformer.transform(question, sources, this.config, cachedSchema);
9398
9450
  });
9399
9451
  let hallucinationScoringPromise = Promise.resolve(void 0);
@@ -9595,7 +9647,9 @@ ${context}`;
9595
9647
  const tokenCount = Number(((_c2 = finalTrace == null ? void 0 : finalTrace.tokens) == null ? void 0 : _c2.totalTokens) || 0);
9596
9648
  const costEst = Number(((_d2 = finalTrace == null ? void 0 : finalTrace.tokens) == null ? void 0 : _d2.estimatedCostUsd) || 0);
9597
9649
  const latencyDuration = Number(((_e2 = finalTrace == null ? void 0 : finalTrace.latency) == null ? void 0 : _e2.totalMs) || 0);
9598
- console.log(`[Retrivora Pipeline Telemetry] \u{1F4CA} Dispatching RAG telemetry -> Project: "${ns}", Tokens: ${tokenCount}, Latency: ${latencyDuration}ms`);
9650
+ if (typeof window === "undefined") {
9651
+ Logger.info(`[Retrivora Pipeline Telemetry] \u{1F4CA} Dispatching RAG telemetry -> Project: "${ns}", Tokens: ${tokenCount}, Latency: ${latencyDuration}ms`);
9652
+ }
9599
9653
  await fetch(absoluteUrl, {
9600
9654
  method: "POST",
9601
9655
  headers: {
@@ -9619,9 +9673,11 @@ ${context}`;
9619
9673
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
9620
9674
  details: `Org: default-org | Model: ${providerName}/${modelName} | Tokens: ${tokenCount} | Latency: ${latencyDuration}ms | Cost: $${costEst} | SDK: v${SDK_VERSION} | Feature: RAG`
9621
9675
  })
9676
+ }).catch((err) => {
9677
+ Logger.warn(`[Pipeline Telemetry] Failed to send trace async to ${absoluteUrl}`, { error: err.message });
9622
9678
  });
9623
9679
  } catch (err) {
9624
- console.warn(`[Pipeline Telemetry] Failed to send trace async to ${absoluteUrl}:`, err.message);
9680
+ Logger.warn(`[Pipeline Telemetry] Failed to send trace async to ${absoluteUrl}:`, { error: err.message });
9625
9681
  }
9626
9682
  })();
9627
9683
  }
@@ -9664,7 +9720,7 @@ ${context}`;
9664
9720
  try {
9665
9721
  return await UITransformer.analyzeAndDecide(question, sources, this.llmRouter.get("fast"));
9666
9722
  } catch (err) {
9667
- console.warn("[Pipeline] generateUiTransformation failed, using heuristic fallback:", err);
9723
+ Logger.warn("[Pipeline] generateUiTransformation failed, using heuristic fallback", { error: String(err) });
9668
9724
  return UITransformer.transform(question, sources, this.config, cachedSchema);
9669
9725
  }
9670
9726
  }
@@ -9762,7 +9818,7 @@ ${context}`;
9762
9818
  query,
9763
9819
  useGraph ? this.llmRouter.get("fast") : void 0
9764
9820
  );
9765
- console.debug(`[Pipeline] Determined retrieval strategy: ${strategy}`);
9821
+ Logger.debug(`[Pipeline] Determined retrieval strategy: ${strategy}`);
9766
9822
  const [retrievedVector, graphData] = await Promise.all([
9767
9823
  // Only embed if we need vector search (strategy is 'vector' or 'both')
9768
9824
  strategy === "vector" || strategy === "both" ? queryVector ? Promise.resolve(queryVector) : this.embeddingProvider.embed(query, { taskType: "query" }) : Promise.resolve([]),
@@ -9784,8 +9840,7 @@ ${context}`;
9784
9840
  baseFilter
9785
9841
  ) : [];
9786
9842
  const resolvedSources = sources;
9787
- console.log("[Pipeline] retrieve() response:", {
9788
- query,
9843
+ Logger.info("[Pipeline] retrieve() response", {
9789
9844
  namespace: ns,
9790
9845
  count: resolvedSources.length,
9791
9846
  sample: resolvedSources.slice(0, 2).map((s) => {
@@ -9865,7 +9920,7 @@ Suggestions:`;
9865
9920
  }
9866
9921
  }
9867
9922
  } catch (error) {
9868
- console.error("[Pipeline] Failed to generate suggestions:", error);
9923
+ Logger.error("[Pipeline] Failed to generate suggestions", error);
9869
9924
  }
9870
9925
  return [];
9871
9926
  }
@@ -10174,18 +10229,25 @@ var DocumentParser = class {
10174
10229
  }
10175
10230
  if (extension === "xlsx" || extension === "xls" || mimeType.includes("spreadsheet") || mimeType.includes("excel")) {
10176
10231
  try {
10177
- const xlsx = await import("xlsx");
10232
+ const ExcelJS = await import("exceljs");
10178
10233
  const buffer = Buffer.isBuffer(file) ? file : Buffer.from(await file.arrayBuffer());
10179
- const workbook = xlsx.read(buffer, { type: "buffer" });
10234
+ const workbook = new ExcelJS.Workbook();
10235
+ await workbook.xlsx.load(buffer);
10180
10236
  const sheetsText = [];
10181
- for (const sheetName of workbook.SheetNames) {
10182
- const sheet = workbook.Sheets[sheetName];
10183
- const csv = xlsx.utils.sheet_to_csv(sheet);
10237
+ workbook.eachSheet((sheet, sheetId) => {
10238
+ const csvLines = [];
10239
+ sheet.eachRow((row, rowNumber) => {
10240
+ const values = row.values;
10241
+ if (Array.isArray(values)) {
10242
+ csvLines.push(values.slice(1).join(","));
10243
+ }
10244
+ });
10245
+ const csv = csvLines.join("\n");
10184
10246
  if (csv && csv.trim()) {
10185
- sheetsText.push(`--- Sheet: ${sheetName} ---
10247
+ sheetsText.push(`--- Sheet: ${sheet.name} ---
10186
10248
  ${csv.trim()}`);
10187
10249
  }
10188
- }
10250
+ });
10189
10251
  return sheetsText.join("\n\n") || `[Empty Excel Workbook: ${fileName}]`;
10190
10252
  } catch (e) {
10191
10253
  try {
@@ -10197,9 +10259,10 @@ ${csv.trim()}`);
10197
10259
  }
10198
10260
  if (extension === "pdf" || mimeType === "application/pdf") {
10199
10261
  try {
10200
- const pdf = await import("pdf-parse");
10262
+ const pdfModule = await import("pdf-parse");
10201
10263
  const buffer = Buffer.isBuffer(file) ? file : Buffer.from(await file.arrayBuffer());
10202
- const data = await pdf.default(buffer);
10264
+ const pdf = pdfModule.default || pdfModule;
10265
+ const data = await pdf(buffer);
10203
10266
  return data.text;
10204
10267
  } catch (err) {
10205
10268
  console.warn('[DocumentParser] PDF parsing failed. Make sure "pdf-parse" is installed.', err);
@@ -10943,7 +11006,7 @@ function sanitizeTelemetryUrl(raw) {
10943
11006
  return null;
10944
11007
  }
10945
11008
  }
10946
- function reportTelemetry(req, plugin, action, status, details, trace) {
11009
+ async function reportTelemetry(req, plugin, action, status, details, trace) {
10947
11010
  var _a2, _b, _c, _d, _e, _f, _g2;
10948
11011
  try {
10949
11012
  const config = plugin.getConfig();
@@ -10978,7 +11041,7 @@ function reportTelemetry(req, plugin, action, status, details, trace) {
10978
11041
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
10979
11042
  details
10980
11043
  };
10981
- fetch(telemetryUrl, {
11044
+ await fetch(telemetryUrl, {
10982
11045
  method: "POST",
10983
11046
  headers: __spreadProps(__spreadValues({
10984
11047
  "Content-Type": "application/json"
@@ -11099,14 +11162,14 @@ function createChatHandler(configOrPlugin, options) {
11099
11162
  uiTransformation: result.ui_transformation,
11100
11163
  trace: result.trace
11101
11164
  }).catch((err) => console.warn("[createChatHandler] Failed to save assistant message:", err));
11102
- reportTelemetry(req, plugin, "QUERY_GENERATION", "success", `Tokens: ${((_d = (_c = result.trace) == null ? void 0 : _c.tokens) == null ? void 0 : _d.totalTokens) || 0}, Latency: ${((_f = (_e = result.trace) == null ? void 0 : _e.latency) == null ? void 0 : _f.totalMs) || 0}ms`, result.trace);
11165
+ await reportTelemetry(req, plugin, "QUERY_GENERATION", "success", `Tokens: ${((_d = (_c = result.trace) == null ? void 0 : _c.tokens) == null ? void 0 : _d.totalTokens) || 0}, Latency: ${((_f = (_e = result.trace) == null ? void 0 : _e.latency) == null ? void 0 : _f.totalMs) || 0}ms`, result.trace);
11103
11166
  return NextResponse.json(__spreadProps(__spreadValues({}, result), {
11104
11167
  messageId: assistantMsgId,
11105
11168
  userMessageId: userMsgId
11106
11169
  }));
11107
11170
  } catch (err) {
11108
11171
  const message = err instanceof Error ? err.message : "Internal server error";
11109
- reportTelemetry(req, plugin, "QUERY_GENERATION", "error", message);
11172
+ await reportTelemetry(req, plugin, "QUERY_GENERATION", "error", message);
11110
11173
  return NextResponse.json({ error: message }, { status: 500 });
11111
11174
  }
11112
11175
  };
@@ -11244,7 +11307,7 @@ function createStreamHandler(configOrPlugin, options) {
11244
11307
  uiTransformation,
11245
11308
  trace: responseChunk == null ? void 0 : responseChunk.trace
11246
11309
  }).catch((err) => console.warn("[createStreamHandler] Failed to save assistant message:", err));
11247
- reportTelemetry(req, plugin, "QUERY_GENERATION", "success", `Tokens: ${((_c = (_b2 = responseChunk == null ? void 0 : responseChunk.trace) == null ? void 0 : _b2.tokens) == null ? void 0 : _c.totalTokens) || 0}, Latency: ${((_e = (_d = responseChunk == null ? void 0 : responseChunk.trace) == null ? void 0 : _d.latency) == null ? void 0 : _e.totalMs) || 0}ms`, responseChunk == null ? void 0 : responseChunk.trace);
11310
+ await reportTelemetry(req, plugin, "QUERY_GENERATION", "success", `Tokens: ${((_c = (_b2 = responseChunk == null ? void 0 : responseChunk.trace) == null ? void 0 : _b2.tokens) == null ? void 0 : _c.totalTokens) || 0}, Latency: ${((_e = (_d = responseChunk == null ? void 0 : responseChunk.trace) == null ? void 0 : _d.latency) == null ? void 0 : _e.totalMs) || 0}ms`, responseChunk == null ? void 0 : responseChunk.trace);
11248
11311
  }
11249
11312
  }
11250
11313
  } catch (temp) {
@@ -11264,7 +11327,7 @@ function createStreamHandler(configOrPlugin, options) {
11264
11327
  errorMessage = "Your Retrivora license key has been terminated, suspended, or revoked. Access denied.";
11265
11328
  }
11266
11329
  console.error("[createStreamHandler] Stream error:", streamError);
11267
- reportTelemetry(req, plugin, "QUERY_GENERATION", "error", errorMessage);
11330
+ await reportTelemetry(req, plugin, "QUERY_GENERATION", "error", errorMessage);
11268
11331
  try {
11269
11332
  enqueue(sseErrorFrame(errorMessage));
11270
11333
  } catch (e) {
@@ -11326,11 +11389,11 @@ function createIngestHandler(configOrPlugin, options) {
11326
11389
  }
11327
11390
  }
11328
11391
  const results = await plugin.ingest(documents, namespaceCheck.namespace);
11329
- reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "success", `Ingested ${documents.length} document(s)`);
11392
+ await reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "success", `Ingested ${documents.length} document(s)`);
11330
11393
  return NextResponse.json({ results });
11331
11394
  } catch (err) {
11332
11395
  const message = err instanceof Error ? err.message : "Internal server error";
11333
- reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "error", message);
11396
+ await reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "error", message);
11334
11397
  return NextResponse.json({ error: message }, { status: 500 });
11335
11398
  }
11336
11399
  };
@@ -11491,41 +11554,47 @@ function createUploadHandler(configOrPlugin, options) {
11491
11554
  }
11492
11555
  }
11493
11556
  } else if (isExcel) {
11494
- const xlsx = await import("xlsx");
11557
+ const ExcelJS = await import("exceljs");
11495
11558
  const buffer = Buffer.isBuffer(file) ? file : Buffer.from(await file.arrayBuffer());
11496
- const workbook = xlsx.read(buffer, { type: "buffer" });
11497
- for (const sheetName of workbook.SheetNames) {
11498
- const sheet = workbook.Sheets[sheetName];
11499
- const jsonRows = xlsx.utils.sheet_to_json(sheet, { defval: "" });
11500
- if (jsonRows && jsonRows.length > 0) {
11501
- let i = 0;
11502
- const headers = Object.keys(jsonRows[0] || {});
11503
- for (const rowData of jsonRows) {
11504
- i++;
11505
- const contentParts = [];
11506
- for (const [key, val] of Object.entries(rowData)) {
11507
- if (key && val !== void 0 && val !== null && String(val).trim()) {
11508
- contentParts.push(`${key}: ${val}`);
11509
- }
11510
- }
11511
- if (contentParts.length > 0) {
11512
- documents.push({
11513
- docId: `${file.name}-${sheetName}-row-${i}`,
11514
- content: contentParts.join(", "),
11515
- metadata: __spreadValues(__spreadProps(__spreadValues({
11516
- fileName: file.name,
11517
- sheetName,
11518
- fileSize: file.size,
11519
- fileType: file.type || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
11520
- uploadedAt: (/* @__PURE__ */ new Date()).toISOString()
11521
- }, dimension ? { dimension } : {}), {
11522
- headers
11523
- }), rowData)
11524
- });
11559
+ const workbook = new ExcelJS.Workbook();
11560
+ await workbook.xlsx.load(buffer);
11561
+ workbook.eachSheet((sheet, sheetId) => {
11562
+ const sheetName = sheet.name;
11563
+ let headers = [];
11564
+ let i = 0;
11565
+ sheet.eachRow((row, rowNumber) => {
11566
+ const values = Array.isArray(row.values) ? row.values.slice(1) : [];
11567
+ if (rowNumber === 1) {
11568
+ headers = values.map((v) => String(v));
11569
+ return;
11570
+ }
11571
+ i++;
11572
+ const contentParts = [];
11573
+ const rowData = {};
11574
+ values.forEach((val, index) => {
11575
+ const key = headers[index] || `Column${index + 1}`;
11576
+ rowData[key] = val;
11577
+ if (key && val !== void 0 && val !== null && String(val).trim()) {
11578
+ contentParts.push(`${key}: ${val}`);
11525
11579
  }
11580
+ });
11581
+ if (contentParts.length > 0) {
11582
+ documents.push({
11583
+ docId: `${file.name}-${sheetName}-row-${i}`,
11584
+ content: contentParts.join(", "),
11585
+ metadata: __spreadValues(__spreadProps(__spreadValues({
11586
+ fileName: file.name,
11587
+ sheetName,
11588
+ fileSize: file.size,
11589
+ fileType: file.type || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
11590
+ uploadedAt: (/* @__PURE__ */ new Date()).toISOString()
11591
+ }, dimension ? { dimension } : {}), {
11592
+ headers
11593
+ }), rowData)
11594
+ });
11526
11595
  }
11527
- }
11528
- }
11596
+ });
11597
+ });
11529
11598
  } else {
11530
11599
  const content = await DocumentParser.parse(file, file.name, file.type);
11531
11600
  documents.push({
@@ -11541,11 +11610,11 @@ function createUploadHandler(configOrPlugin, options) {
11541
11610
  }
11542
11611
  }
11543
11612
  const results = await plugin.ingest(documents, namespaceCheck.namespace);
11544
- reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "success", `Uploaded & ingested ${files.length} file(s)`);
11613
+ await reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "success", `Uploaded & ingested ${files.length} file(s)`);
11545
11614
  return NextResponse.json({ message: "Upload successful", results });
11546
11615
  } catch (err) {
11547
11616
  const message = err instanceof Error ? err.message : "Upload failed";
11548
- reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "error", message);
11617
+ await reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "error", message);
11549
11618
  return NextResponse.json({ error: message }, { status: 500 });
11550
11619
  }
11551
11620
  };
@@ -11585,11 +11654,11 @@ function createSuggestionsHandler(configOrPlugin, options) {
11585
11654
  const namespaceCheck = resolveLicensedNamespace(effectiveLicensePayload, namespace);
11586
11655
  if (!namespaceCheck.ok) return namespaceCheck.response;
11587
11656
  const suggestions = await plugin.getSuggestions(query, namespaceCheck.namespace);
11588
- reportTelemetry(req, plugin, "AUTO_SUGGESTIONS", "success", `Fetched ${suggestions.length} suggestions for: ${query.slice(0, 30)}`);
11657
+ await reportTelemetry(req, plugin, "AUTO_SUGGESTIONS", "success", `Fetched ${suggestions.length} suggestions for: ${query.slice(0, 30)}`);
11589
11658
  return NextResponse.json({ suggestions });
11590
11659
  } catch (err) {
11591
11660
  const message = err instanceof Error ? err.message : "Internal server error";
11592
- reportTelemetry(req, plugin, "AUTO_SUGGESTIONS", "error", message);
11661
+ await reportTelemetry(req, plugin, "AUTO_SUGGESTIONS", "error", message);
11593
11662
  return NextResponse.json({ error: message }, { status: 500 });
11594
11663
  }
11595
11664
  };