@exulu/backend 1.51.0 → 1.51.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -10863,6 +10863,7 @@ var providerRateLimiter = async (key, windowSeconds, limit, points) => {
10863
10863
 
10864
10864
  // src/exulu/routes.ts
10865
10865
  var import_zod_from_json_schema = require("zod-from-json-schema");
10866
+ var import_zod8 = require("zod");
10866
10867
  var REQUEST_SIZE_LIMIT = "50mb";
10867
10868
  var getExuluVersionNumber = async () => {
10868
10869
  try {
@@ -11765,7 +11766,7 @@ var import_types2 = require("@modelcontextprotocol/sdk/types.js");
11765
11766
  var import_express4 = require("express");
11766
11767
  var import_api3 = require("@opentelemetry/api");
11767
11768
  var import_crypto_js7 = __toESM(require("crypto-js"), 1);
11768
- var import_zod8 = require("zod");
11769
+ var import_zod9 = require("zod");
11769
11770
  var SESSION_ID_HEADER = "mcp-session-id";
11770
11771
  var ExuluMCP = class {
11771
11772
  server = {};
@@ -11848,7 +11849,7 @@ var ExuluMCP = class {
11848
11849
  title: tool3.name + " agent",
11849
11850
  description: tool3.description,
11850
11851
  inputSchema: {
11851
- inputs: tool3.inputSchema || import_zod8.z.object({})
11852
+ inputs: tool3.inputSchema || import_zod9.z.object({})
11852
11853
  }
11853
11854
  },
11854
11855
  async ({ inputs }, args) => {
@@ -11900,7 +11901,7 @@ var ExuluMCP = class {
11900
11901
  title: "Get List of Prompt Templates",
11901
11902
  description: "Retrieves a list of prompt templates available for this agent. Returns the name, description, and ID of each template.",
11902
11903
  inputSchema: {
11903
- inputs: import_zod8.z.object({})
11904
+ inputs: import_zod9.z.object({})
11904
11905
  }
11905
11906
  },
11906
11907
  async ({ inputs }, args) => {
@@ -11946,8 +11947,8 @@ var ExuluMCP = class {
11946
11947
  title: "Get Prompt Template Details",
11947
11948
  description: "Retrieves the full details of a specific prompt template by ID, including the actual template content with variables.",
11948
11949
  inputSchema: {
11949
- inputs: import_zod8.z.object({
11950
- id: import_zod8.z.string().describe("The ID of the prompt template to retrieve")
11950
+ inputs: import_zod9.z.object({
11951
+ id: import_zod9.z.string().describe("The ID of the prompt template to retrieve")
11951
11952
  })
11952
11953
  }
11953
11954
  },
@@ -12855,7 +12856,7 @@ var ExuluEval = class {
12855
12856
  };
12856
12857
 
12857
12858
  // src/templates/evals/index.ts
12858
- var import_zod9 = require("zod");
12859
+ var import_zod10 = require("zod");
12859
12860
  var llmAsJudgeEval = () => {
12860
12861
  if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
12861
12862
  return new ExuluEval({
@@ -12900,8 +12901,8 @@ var llmAsJudgeEval = () => {
12900
12901
  contexts: [],
12901
12902
  rerankers: [],
12902
12903
  prompt,
12903
- outputSchema: import_zod9.z.object({
12904
- score: import_zod9.z.number().min(0).max(100).describe("The score between 0 and 100.")
12904
+ outputSchema: import_zod10.z.object({
12905
+ score: import_zod10.z.number().min(0).max(100).describe("The score between 0 and 100.")
12905
12906
  }),
12906
12907
  providerapikey
12907
12908
  });
@@ -13129,12 +13130,12 @@ Usage:
13129
13130
  - If no todos exist yet, an empty list will be returned`;
13130
13131
 
13131
13132
  // src/templates/tools/todo/todo.ts
13132
- var import_zod10 = __toESM(require("zod"), 1);
13133
- var TodoSchema = import_zod10.default.object({
13134
- content: import_zod10.default.string().describe("Brief description of the task"),
13135
- status: import_zod10.default.string().describe("Current status of the task: pending, in_progress, completed, cancelled"),
13136
- priority: import_zod10.default.string().describe("Priority level of the task: high, medium, low"),
13137
- id: import_zod10.default.string().describe("Unique identifier for the todo item")
13133
+ var import_zod11 = __toESM(require("zod"), 1);
13134
+ var TodoSchema = import_zod11.default.object({
13135
+ content: import_zod11.default.string().describe("Brief description of the task"),
13136
+ status: import_zod11.default.string().describe("Current status of the task: pending, in_progress, completed, cancelled"),
13137
+ priority: import_zod11.default.string().describe("Priority level of the task: high, medium, low"),
13138
+ id: import_zod11.default.string().describe("Unique identifier for the todo item")
13138
13139
  });
13139
13140
  var TodoWriteTool = new ExuluTool({
13140
13141
  id: "todo_write",
@@ -13150,8 +13151,8 @@ var TodoWriteTool = new ExuluTool({
13150
13151
  default: todowrite_default
13151
13152
  }
13152
13153
  ],
13153
- inputSchema: import_zod10.default.object({
13154
- todos: import_zod10.default.array(TodoSchema).describe("The updated todo list")
13154
+ inputSchema: import_zod11.default.object({
13155
+ todos: import_zod11.default.array(TodoSchema).describe("The updated todo list")
13155
13156
  }),
13156
13157
  execute: async (inputs) => {
13157
13158
  const { sessionID, todos, user } = inputs;
@@ -13186,7 +13187,7 @@ var TodoReadTool = new ExuluTool({
13186
13187
  id: "todo_read",
13187
13188
  name: "Todo Read",
13188
13189
  description: "Use this tool to read your todo list",
13189
- inputSchema: import_zod10.default.object({}),
13190
+ inputSchema: import_zod11.default.object({}),
13190
13191
  type: "function",
13191
13192
  category: "todo",
13192
13193
  config: [
@@ -13225,15 +13226,15 @@ async function getTodos(sessionID) {
13225
13226
  var todoTools = [TodoWriteTool, TodoReadTool];
13226
13227
 
13227
13228
  // src/templates/tools/perplexity.ts
13228
- var import_zod11 = __toESM(require("zod"), 1);
13229
+ var import_zod12 = __toESM(require("zod"), 1);
13229
13230
  var import_perplexity_ai = __toESM(require("@perplexity-ai/perplexity_ai"), 1);
13230
13231
  var internetSearchTool = new ExuluTool({
13231
13232
  id: "internet_search",
13232
13233
  name: "Perplexity Live Internet Search",
13233
13234
  description: "Search the internet for information.",
13234
- inputSchema: import_zod11.default.object({
13235
- query: import_zod11.default.string().describe("The query to the tool."),
13236
- search_recency_filter: import_zod11.default.enum(["day", "week", "month", "year"]).optional().describe("The recency filter for the search, can be day, week, month or year.")
13235
+ inputSchema: import_zod12.default.object({
13236
+ query: import_zod12.default.string().describe("The query to the tool."),
13237
+ search_recency_filter: import_zod12.default.enum(["day", "week", "month", "year"]).optional().describe("The recency filter for the search, can be day, week, month or year.")
13237
13238
  }),
13238
13239
  category: "internet_search",
13239
13240
  type: "web_search",
@@ -16192,7 +16193,7 @@ Or manually run the setup script:
16192
16193
  var fs2 = __toESM(require("fs"), 1);
16193
16194
  var path = __toESM(require("path"), 1);
16194
16195
  var import_ai7 = require("ai");
16195
- var import_zod12 = require("zod");
16196
+ var import_zod13 = require("zod");
16196
16197
  var import_p_limit = __toESM(require("p-limit"), 1);
16197
16198
  var import_crypto = require("crypto");
16198
16199
  var mammoth = __toESM(require("mammoth"), 1);
@@ -16495,15 +16496,15 @@ If the page contains a flow-chart, schematic, technical drawing or control board
16495
16496
  const result = await (0, import_ai7.generateText)({
16496
16497
  model,
16497
16498
  output: import_ai7.Output.object({
16498
- schema: import_zod12.z.object({
16499
- needs_correction: import_zod12.z.boolean(),
16500
- corrected_text: import_zod12.z.string().nullable(),
16501
- current_page_table: import_zod12.z.object({
16502
- headers: import_zod12.z.array(import_zod12.z.string()),
16503
- is_continuation: import_zod12.z.boolean()
16499
+ schema: import_zod13.z.object({
16500
+ needs_correction: import_zod13.z.boolean(),
16501
+ corrected_text: import_zod13.z.string().nullable(),
16502
+ current_page_table: import_zod13.z.object({
16503
+ headers: import_zod13.z.array(import_zod13.z.string()),
16504
+ is_continuation: import_zod13.z.boolean()
16504
16505
  }).nullable(),
16505
- confidence: import_zod12.z.enum(["high", "medium", "low"]),
16506
- reasoning: import_zod12.z.string()
16506
+ confidence: import_zod13.z.enum(["high", "medium", "low"]),
16507
+ reasoning: import_zod13.z.string()
16507
16508
  })
16508
16509
  }),
16509
16510
  messages: [
@@ -16696,6 +16697,13 @@ async function processDocument(filePath, fileType, buffer, tempDir, config, verb
16696
16697
  }
16697
16698
  };
16698
16699
  }
16700
+ var getMistralApiKey = async () => {
16701
+ if (process.env.MISTRAL_API_KEY) {
16702
+ return process.env.MISTRAL_API_KEY;
16703
+ } else {
16704
+ return await ExuluVariables.get("MISTRAL_API_KEY");
16705
+ }
16706
+ };
16699
16707
  async function processPdf(buffer, paths, config, verbose = false) {
16700
16708
  try {
16701
16709
  let json = [];
@@ -16751,12 +16759,13 @@ ${setupResult.output || ""}`);
16751
16759
  headings: []
16752
16760
  }];
16753
16761
  } else if (config?.processor.name === "mistral") {
16754
- if (!process.env.MISTRAL_API_KEY) {
16755
- throw new Error("[EXULU] MISTRAL_API_KEY is not set, please set it in the environment variables.");
16762
+ const MISTRAL_API_KEY = await getMistralApiKey();
16763
+ if (MISTRAL_API_KEY) {
16764
+ throw new Error('[EXULU] MISTRAL_API_KEY is not set, please set it in the environment variable via process.env or via an Exulu variable named "MISTRAL_API_KEY".');
16756
16765
  }
16757
16766
  await new Promise((resolve3) => setTimeout(resolve3, Math.floor(Math.random() * 4e3) + 1e3));
16758
16767
  const base64Pdf = buffer.toString("base64");
16759
- const client2 = new import_mistralai.Mistral({ apiKey: process.env.MISTRAL_API_KEY });
16768
+ const client2 = new import_mistralai.Mistral({ apiKey: MISTRAL_API_KEY });
16760
16769
  const ocrResponse = await withRetry(async () => {
16761
16770
  const ocrResponse2 = await client2.ocr.process({
16762
16771
  document: {
package/dist/index.js CHANGED
@@ -10829,6 +10829,7 @@ var providerRateLimiter = async (key, windowSeconds, limit, points) => {
10829
10829
 
10830
10830
  // src/exulu/routes.ts
10831
10831
  import { convertJsonSchemaToZod } from "zod-from-json-schema";
10832
+ import "zod";
10832
10833
  var REQUEST_SIZE_LIMIT = "50mb";
10833
10834
  var getExuluVersionNumber = async () => {
10834
10835
  try {
@@ -11731,7 +11732,7 @@ import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
11731
11732
  import "express";
11732
11733
  import "@opentelemetry/api";
11733
11734
  import CryptoJS7 from "crypto-js";
11734
- import { z as z8 } from "zod";
11735
+ import { z as z9 } from "zod";
11735
11736
  var SESSION_ID_HEADER = "mcp-session-id";
11736
11737
  var ExuluMCP = class {
11737
11738
  server = {};
@@ -11814,7 +11815,7 @@ var ExuluMCP = class {
11814
11815
  title: tool3.name + " agent",
11815
11816
  description: tool3.description,
11816
11817
  inputSchema: {
11817
- inputs: tool3.inputSchema || z8.object({})
11818
+ inputs: tool3.inputSchema || z9.object({})
11818
11819
  }
11819
11820
  },
11820
11821
  async ({ inputs }, args) => {
@@ -11866,7 +11867,7 @@ var ExuluMCP = class {
11866
11867
  title: "Get List of Prompt Templates",
11867
11868
  description: "Retrieves a list of prompt templates available for this agent. Returns the name, description, and ID of each template.",
11868
11869
  inputSchema: {
11869
- inputs: z8.object({})
11870
+ inputs: z9.object({})
11870
11871
  }
11871
11872
  },
11872
11873
  async ({ inputs }, args) => {
@@ -11912,8 +11913,8 @@ var ExuluMCP = class {
11912
11913
  title: "Get Prompt Template Details",
11913
11914
  description: "Retrieves the full details of a specific prompt template by ID, including the actual template content with variables.",
11914
11915
  inputSchema: {
11915
- inputs: z8.object({
11916
- id: z8.string().describe("The ID of the prompt template to retrieve")
11916
+ inputs: z9.object({
11917
+ id: z9.string().describe("The ID of the prompt template to retrieve")
11917
11918
  })
11918
11919
  }
11919
11920
  },
@@ -12821,7 +12822,7 @@ var ExuluEval = class {
12821
12822
  };
12822
12823
 
12823
12824
  // src/templates/evals/index.ts
12824
- import { z as z9 } from "zod";
12825
+ import { z as z10 } from "zod";
12825
12826
  var llmAsJudgeEval = () => {
12826
12827
  if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
12827
12828
  return new ExuluEval({
@@ -12866,8 +12867,8 @@ var llmAsJudgeEval = () => {
12866
12867
  contexts: [],
12867
12868
  rerankers: [],
12868
12869
  prompt,
12869
- outputSchema: z9.object({
12870
- score: z9.number().min(0).max(100).describe("The score between 0 and 100.")
12870
+ outputSchema: z10.object({
12871
+ score: z10.number().min(0).max(100).describe("The score between 0 and 100.")
12871
12872
  }),
12872
12873
  providerapikey
12873
12874
  });
@@ -13095,12 +13096,12 @@ Usage:
13095
13096
  - If no todos exist yet, an empty list will be returned`;
13096
13097
 
13097
13098
  // src/templates/tools/todo/todo.ts
13098
- import z10 from "zod";
13099
- var TodoSchema = z10.object({
13100
- content: z10.string().describe("Brief description of the task"),
13101
- status: z10.string().describe("Current status of the task: pending, in_progress, completed, cancelled"),
13102
- priority: z10.string().describe("Priority level of the task: high, medium, low"),
13103
- id: z10.string().describe("Unique identifier for the todo item")
13099
+ import z11 from "zod";
13100
+ var TodoSchema = z11.object({
13101
+ content: z11.string().describe("Brief description of the task"),
13102
+ status: z11.string().describe("Current status of the task: pending, in_progress, completed, cancelled"),
13103
+ priority: z11.string().describe("Priority level of the task: high, medium, low"),
13104
+ id: z11.string().describe("Unique identifier for the todo item")
13104
13105
  });
13105
13106
  var TodoWriteTool = new ExuluTool({
13106
13107
  id: "todo_write",
@@ -13116,8 +13117,8 @@ var TodoWriteTool = new ExuluTool({
13116
13117
  default: todowrite_default
13117
13118
  }
13118
13119
  ],
13119
- inputSchema: z10.object({
13120
- todos: z10.array(TodoSchema).describe("The updated todo list")
13120
+ inputSchema: z11.object({
13121
+ todos: z11.array(TodoSchema).describe("The updated todo list")
13121
13122
  }),
13122
13123
  execute: async (inputs) => {
13123
13124
  const { sessionID, todos, user } = inputs;
@@ -13152,7 +13153,7 @@ var TodoReadTool = new ExuluTool({
13152
13153
  id: "todo_read",
13153
13154
  name: "Todo Read",
13154
13155
  description: "Use this tool to read your todo list",
13155
- inputSchema: z10.object({}),
13156
+ inputSchema: z11.object({}),
13156
13157
  type: "function",
13157
13158
  category: "todo",
13158
13159
  config: [
@@ -13191,15 +13192,15 @@ async function getTodos(sessionID) {
13191
13192
  var todoTools = [TodoWriteTool, TodoReadTool];
13192
13193
 
13193
13194
  // src/templates/tools/perplexity.ts
13194
- import z11 from "zod";
13195
+ import z12 from "zod";
13195
13196
  import Perplexity from "@perplexity-ai/perplexity_ai";
13196
13197
  var internetSearchTool = new ExuluTool({
13197
13198
  id: "internet_search",
13198
13199
  name: "Perplexity Live Internet Search",
13199
13200
  description: "Search the internet for information.",
13200
- inputSchema: z11.object({
13201
- query: z11.string().describe("The query to the tool."),
13202
- search_recency_filter: z11.enum(["day", "week", "month", "year"]).optional().describe("The recency filter for the search, can be day, week, month or year.")
13201
+ inputSchema: z12.object({
13202
+ query: z12.string().describe("The query to the tool."),
13203
+ search_recency_filter: z12.enum(["day", "week", "month", "year"]).optional().describe("The recency filter for the search, can be day, week, month or year.")
13203
13204
  }),
13204
13205
  category: "internet_search",
13205
13206
  type: "web_search",
@@ -16158,7 +16159,7 @@ Or manually run the setup script:
16158
16159
  import * as fs2 from "fs";
16159
16160
  import * as path from "path";
16160
16161
  import { generateText as generateText3, Output as Output3 } from "ai";
16161
- import { z as z12 } from "zod";
16162
+ import { z as z13 } from "zod";
16162
16163
  import pLimit from "p-limit";
16163
16164
  import { randomUUID as randomUUID6 } from "crypto";
16164
16165
  import * as mammoth from "mammoth";
@@ -16461,15 +16462,15 @@ If the page contains a flow-chart, schematic, technical drawing or control board
16461
16462
  const result = await generateText3({
16462
16463
  model,
16463
16464
  output: Output3.object({
16464
- schema: z12.object({
16465
- needs_correction: z12.boolean(),
16466
- corrected_text: z12.string().nullable(),
16467
- current_page_table: z12.object({
16468
- headers: z12.array(z12.string()),
16469
- is_continuation: z12.boolean()
16465
+ schema: z13.object({
16466
+ needs_correction: z13.boolean(),
16467
+ corrected_text: z13.string().nullable(),
16468
+ current_page_table: z13.object({
16469
+ headers: z13.array(z13.string()),
16470
+ is_continuation: z13.boolean()
16470
16471
  }).nullable(),
16471
- confidence: z12.enum(["high", "medium", "low"]),
16472
- reasoning: z12.string()
16472
+ confidence: z13.enum(["high", "medium", "low"]),
16473
+ reasoning: z13.string()
16473
16474
  })
16474
16475
  }),
16475
16476
  messages: [
@@ -16662,6 +16663,13 @@ async function processDocument(filePath, fileType, buffer, tempDir, config, verb
16662
16663
  }
16663
16664
  };
16664
16665
  }
16666
+ var getMistralApiKey = async () => {
16667
+ if (process.env.MISTRAL_API_KEY) {
16668
+ return process.env.MISTRAL_API_KEY;
16669
+ } else {
16670
+ return await ExuluVariables.get("MISTRAL_API_KEY");
16671
+ }
16672
+ };
16665
16673
  async function processPdf(buffer, paths, config, verbose = false) {
16666
16674
  try {
16667
16675
  let json = [];
@@ -16717,12 +16725,13 @@ ${setupResult.output || ""}`);
16717
16725
  headings: []
16718
16726
  }];
16719
16727
  } else if (config?.processor.name === "mistral") {
16720
- if (!process.env.MISTRAL_API_KEY) {
16721
- throw new Error("[EXULU] MISTRAL_API_KEY is not set, please set it in the environment variables.");
16728
+ const MISTRAL_API_KEY = await getMistralApiKey();
16729
+ if (MISTRAL_API_KEY) {
16730
+ throw new Error('[EXULU] MISTRAL_API_KEY is not set, please set it in the environment variable via process.env or via an Exulu variable named "MISTRAL_API_KEY".');
16722
16731
  }
16723
16732
  await new Promise((resolve3) => setTimeout(resolve3, Math.floor(Math.random() * 4e3) + 1e3));
16724
16733
  const base64Pdf = buffer.toString("base64");
16725
- const client2 = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });
16734
+ const client2 = new Mistral({ apiKey: MISTRAL_API_KEY });
16726
16735
  const ocrResponse = await withRetry(async () => {
16727
16736
  const ocrResponse2 = await client2.ocr.process({
16728
16737
  document: {
@@ -15,6 +15,7 @@ import { executePythonScript } from '@SRC/utils/python-executor';
15
15
  import { setupPythonEnvironment, validatePythonEnvironment } from '@SRC/utils/python-setup';
16
16
  import { LiteParse } from '@llamaindex/liteparse';
17
17
  import { Mistral } from '@mistralai/mistralai';
18
+ import { ExuluVariables } from '@SRC/index';
18
19
 
19
20
  type DocumentProcessorConfig = {
20
21
  vlm?: {
@@ -586,6 +587,14 @@ async function processDocument(
586
587
  };
587
588
  }
588
589
 
590
+ const getMistralApiKey = async () => {
591
+ if (process.env.MISTRAL_API_KEY) {
592
+ return process.env.MISTRAL_API_KEY;
593
+ } else {
594
+ return await ExuluVariables.get("MISTRAL_API_KEY");
595
+ }
596
+ }
597
+
589
598
  async function processPdf(
590
599
  buffer: Buffer,
591
600
  paths: ProcessingPaths,
@@ -656,15 +665,17 @@ async function processPdf(
656
665
  }];
657
666
 
658
667
  } else if (config?.processor.name === "mistral") {
659
- if (!process.env.MISTRAL_API_KEY) {
660
- throw new Error('[EXULU] MISTRAL_API_KEY is not set, please set it in the environment variables.');
668
+
669
+ const MISTRAL_API_KEY = await getMistralApiKey();
670
+ if (MISTRAL_API_KEY) {
671
+ throw new Error('[EXULU] MISTRAL_API_KEY is not set, please set it in the environment variable via process.env or via an Exulu variable named "MISTRAL_API_KEY".');
661
672
  }
662
673
 
663
674
  // Wait a randomn time between 1 and 5 seconds to prevent rate limiting
664
675
  await new Promise(resolve => setTimeout(resolve, Math.floor(Math.random() * 4000) + 1000));
665
676
 
666
677
  const base64Pdf = buffer.toString('base64');
667
- const client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });
678
+ const client = new Mistral({ apiKey: MISTRAL_API_KEY });
668
679
 
669
680
  const ocrResponse = await withRetry(async () => {
670
681
  type MistralOCRResponse = Awaited<ReturnType<typeof client.ocr.process>>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exulu/backend",
3
3
  "author": "Qventu Bv.",
4
- "version": "1.51.0",
4
+ "version": "1.51.1",
5
5
  "main": "./dist/index.js",
6
6
  "private": false,
7
7
  "publishConfig": {