Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🚧 WIP: Merge Dev Build (#4611)
Danny Avila95011ce34922
diff --git a/api/app/clients/tools/util/handleTools.js b/api/app/clients/tools/util/handleTools.jsindex 7a7be797d5..6f1acb549b 100644--- a/api/app/clients/tools/util/handleTools.js+++ b/api/app/clients/tools/util/handleTools.js@@ -24,6 +24,7 @@ const {StructuredWolfram,TavilySearchResults,} = require('../');+const { primeFiles } = require('~/server/services/Files/Code/process');const createFileSearchTool = require('./createFileSearchTool');const { loadToolSuite } = require('./loadToolSuite');const { loadSpecs } = require('./loadSpecs');@@ -255,12 +256,14 @@ const loadTools = async ({for (const tool of tools) {if (tool === Tools.execute_code) {const authValues = await loadAuthValues({- userId: user.id,+ userId: user,authFields: [EnvVar.CODE_API_KEY],});+ const files = await primeFiles(options, authValues[EnvVar.CODE_API_KEY]);requestedTools[tool] = () =>createCodeExecutionTool({- user_id: user.id,+ user_id: user,+ files,...authValues,});continue;diff --git a/api/models/schema/fileSchema.js b/api/models/schema/fileSchema.jsindex da3f31c406..77c6ff94d4 100644--- a/api/models/schema/fileSchema.js+++ b/api/models/schema/fileSchema.js@@ -21,6 +21,8 @@ const mongoose = require('mongoose');* @property {string} [source] - The source of the file (e.g., from FileSources)* @property {number} [width] - Optional width of the file* @property {number} [height] - Optional height of the file+ * @property {Object} [metadata] - Metadata related to the file+ * @property {string} [metadata.fileIdentifier] - Unique identifier for the file in metadata* @property {Date} [expiresAt] - Optional expiration date of the file* @property {Date} [createdAt] - Date when the file was created* @property {Date} [updatedAt] - Date when the file was updated@@ -91,6 +93,9 @@ const fileSchema = mongoose.Schema(},width: Number,height: Number,+ metadata: {+ fileIdentifier: String,+ },expiresAt: {type: Date,expires: 3600, // 1 hour in secondsdiff --git a/api/models/tx.js b/api/models/tx.jsindex e7960482c4..1b1501bd28 100644--- a/api/models/tx.js+++ b/api/models/tx.js@@ -10,6 +10,13 @@ const bedrockValues = {'llama3-1-8b': { prompt: 0.3, completion: 0.6 },'llama3-1-70b': { prompt: 2.65, completion: 3.5 },'llama3-1-405b': { prompt: 5.32, completion: 16.0 },+ 'llama2:13b': { prompt: 0.75, completion: 1.0 },+ 'llama2:70b': { prompt: 1.95, completion: 2.56 },+ 'llama3:8b': { prompt: 0.3, completion: 0.6 },+ 'llama3:70b': { prompt: 2.65, completion: 3.5 },+ 'llama3.1:8b': { prompt: 0.3, completion: 0.6 },+ 'llama3.1:70b': { prompt: 2.65, completion: 3.5 },+ 'llama3.1:405b': { prompt: 5.32, completion: 16.0 },'mistral-7b': { prompt: 0.15, completion: 0.2 },'mistral-small': { prompt: 0.15, completion: 0.2 },'mixtral-8x7b': { prompt: 0.45, completion: 0.7 },diff --git a/api/package.json b/api/package.jsonindex 68f6a3c823..22677f6c24 100644--- a/api/package.json+++ b/api/package.json@@ -43,7 +43,7 @@"@langchain/core": "^0.2.18","@langchain/google-genai": "^0.0.11","@langchain/google-vertexai": "^0.0.17",- "@librechat/agents": "^1.6.9",+ "@librechat/agents": "^1.7.7","axios": "^1.7.7","bcryptjs": "^2.4.3","cheerio": "^1.0.0-rc.12",diff --git a/api/server/controllers/PluginController.js b/api/server/controllers/PluginController.jsindex 5bb34671f8..3c7085c2a0 100644--- a/api/server/controllers/PluginController.js+++ b/api/server/controllers/PluginController.js@@ -1,5 +1,5 @@const { promises: fs } = require('fs');-const { CacheKeys } = require('librechat-data-provider');+const { CacheKeys, AuthType } = require('librechat-data-provider');const { addOpenAPISpecs } = require('~/app/clients/tools/util/addOpenAPISpecs');const { getLogStores } = require('~/cache');@@ -25,7 +25,7 @@ const filterUniquePlugins = (plugins) => {* @param {TPlugin} plugin The plugin object containing the authentication configuration.* @returns {boolean} True if the plugin is authenticated for all required fields, false otherwise.*/-const isPluginAuthenticated = (plugin) => {+const checkPluginAuth = (plugin) => {if (!plugin.authConfig || plugin.authConfig.length === 0) {return false;}@@ -36,7 +36,7 @@ const isPluginAuthenticated = (plugin) => {for (const fieldOption of authFieldOptions) {const envValue = process.env[fieldOption];- if (envValue && envValue.trim() !== '' && envValue !== 'user_provided') {+ if (envValue && envValue.trim() !== '' && envValue !== AuthType.USER_PROVIDED) {isFieldAuthenticated = true;break;}@@ -64,7 +64,7 @@ const getAvailablePluginsController = async (req, res) => {let authenticatedPlugins = [];for (const plugin of uniquePlugins) {authenticatedPlugins.push(- isPluginAuthenticated(plugin) ? { ...plugin, authenticated: true } : plugin,+ checkPluginAuth(plugin) ? { ...plugin, authenticated: true } : plugin,);}@@ -111,7 +111,7 @@ const getAvailableTools = async (req, res) => {const uniquePlugins = filterUniquePlugins(jsonData);const authenticatedPlugins = uniquePlugins.map((plugin) => {- if (isPluginAuthenticated(plugin)) {+ if (checkPluginAuth(plugin)) {return { ...plugin, authenticated: true };} else {return plugin;diff --git a/api/server/controllers/UserController.js b/api/server/controllers/UserController.jsindex abe89d2b0a..f9ed887b15 100644--- a/api/server/controllers/UserController.js+++ b/api/server/controllers/UserController.js@@ -61,10 +61,10 @@ const deleteUserFiles = async (req) => {const updateUserPluginsController = async (req, res) => {const { user } = req;- const { pluginKey, action, auth, isAssistantTool } = req.body;+ const { pluginKey, action, auth, isEntityTool } = req.body;let authService;try {- if (!isAssistantTool) {+ if (!isEntityTool) {const userPluginsService = await updateUserPluginsService(user, pluginKey, action);if (userPluginsService instanceof Error) {diff --git a/api/server/controllers/agents/callbacks.js b/api/server/controllers/agents/callbacks.jsindex 7bbb2212aa..209de71714 100644--- a/api/server/controllers/agents/callbacks.js+++ b/api/server/controllers/agents/callbacks.js@@ -1,6 +1,12 @@const { Tools } = require('librechat-data-provider');-const { GraphEvents, ToolEndHandler, ChatModelStreamHandler } = require('@librechat/agents');+const {+ EnvVar,+ GraphEvents,+ ToolEndHandler,+ ChatModelStreamHandler,+} = require('@librechat/agents');const { processCodeOutput } = require('~/server/services/Files/Code/process');+const { loadAuthValues } = require('~/app/clients/tools/util');const { logger } = require('~/config');/** @typedef {import('@librechat/agents').Graph} Graph */@@ -158,13 +164,18 @@ function createToolEndCallback({ req, res, artifactPromises }) {const { id, name } = file;artifactPromises.push((async () => {+ const result = await loadAuthValues({+ userId: req.user.id,+ authFields: [EnvVar.CODE_API_KEY],+ });const fileMetadata = await processCodeOutput({req,id,name,+ apiKey: result[EnvVar.CODE_API_KEY],toolCallId: tool_call_id,messageId: metadata.run_id,- sessionId: artifact.session_id,+ session_id: artifact.session_id,conversationId: metadata.thread_id,});if (!res.headersSent) {diff --git a/api/server/controllers/agents/client.js b/api/server/controllers/agents/client.jsindex f035d546f2..0534014bec 100644--- a/api/server/controllers/agents/client.js+++ b/api/server/controllers/agents/client.js@@ -15,7 +15,6 @@ const {EModelEndpoint,anthropicSchema,bedrockOutputParser,- providerEndpointMap,removeNullishValues,} = require('librechat-data-provider');const {@@ -465,7 +464,6 @@ class AgentClient extends BaseClient {const config = {configurable: {- provider: providerEndpointMap[this.options.agent.provider],thread_id: this.conversationId,},signal: abortController.signal,diff --git a/api/server/controllers/agents/run.js b/api/server/controllers/agents/run.jsindex 2377ce64f1..241d224730 100644--- a/api/server/controllers/agents/run.js+++ b/api/server/controllers/agents/run.js@@ -35,9 +35,10 @@ async function createRun({streaming = true,streamUsage = true,}) {+ const provider = providerEndpointMap[agent.provider] ?? agent.provider;const llmConfig = Object.assign({- provider: providerEndpointMap[agent.provider],+ provider,streaming,streamUsage,},diff --git a/api/server/controllers/tools.js b/api/server/controllers/tools.jsnew file mode 100644index 0000000000..9fd9cb2942--- /dev/null+++ b/api/server/controllers/tools.js@@ -0,0 +1,53 @@+const { EnvVar } = require('@librechat/agents');+const { Tools, AuthType } = require('librechat-data-provider');+const { loadAuthValues } = require('~/app/clients/tools/util');++const fieldsMap = {+ [Tools.execute_code]: [EnvVar.CODE_API_KEY],+};++/**+ * @param {ServerRequest} req - The request object, containing information about the HTTP request.+ * @param {ServerResponse} res - The response object, used to send back the desired HTTP response.+ * @returns {Promise<void>} A promise that resolves when the function has completed.+ */+const verifyToolAuth = async (req, res) => {+ try {+ const { toolId } = req.params;+ const authFields = fieldsMap[toolId];+ if (!authFields) {+ res.status(404).json({ message: 'Tool not found' });+ return;+ }+ let result;+ try {+ result = await loadAuthValues({+ userId: req.user.id,+ authFields,+ });+ } catch (error) {+ res.status(200).json({ authenticated: false, message: AuthType.USER_PROVIDED });+ return;+ }+ let isUserProvided = false;+ for (const field of authFields) {+ if (!result[field]) {+ res.status(200).json({ authenticated: false, message: AuthType.USER_PROVIDED });+ return;+ }+ if (!isUserProvided && process.env[field] !== result[field]) {+ isUserProvided = true;+ }+ }+ res.status(200).json({+ authenticated: true,+ message: isUserProvided ? AuthType.USER_PROVIDED : AuthType.SYSTEM_DEFINED,+ });+ } catch (error) {+ res.status(500).json({ message: error.message });+ }+};++module.exports = {+ verifyToolAuth,+};diff --git a/api/server/routes/agents/tools.js b/api/server/routes/agents/tools.jsnew file mode 100644index 0000000000..b58fc21d4f--- /dev/null+++ b/api/server/routes/agents/tools.js@@ -0,0 +1,22 @@+const express = require('express');+const { getAvailableTools } = require('~/server/controllers/PluginController');+const { verifyToolAuth } = require('~/server/controllers/tools');++const router = express.Router();++/**+ * Get a list of available tools for agents.+ * @route GET /agents/tools+ * @returns {TPlugin[]} 200 - application/json+ */+router.get('/', getAvailableTools);++/**+ * Verify authentication for a specific tool+ * @route GET /agents/tools/:toolId/auth+ * @param {string} toolId - The ID of the tool to verify+ * @returns {{ authenticated?: boolean; message?: string }}+ */+router.get('/:toolId/auth', verifyToolAuth);++module.exports = router;diff --git a/api/server/routes/agents/v1.js b/api/server/routes/agents/v1.jsindex 8e347bbe2a..a4fcde1241 100644--- a/api/server/routes/agents/v1.js+++ b/api/server/routes/agents/v1.js@@ -2,9 +2,9 @@ const multer = require('multer');const express = require('express');const { PermissionTypes, Permissions } = require('librechat-data-provider');const { requireJwtAuth, generateCheckAccess } = require('~/server/middleware');-const { getAvailableTools } = require('~/server/controllers/PluginController');const v1 = require('~/server/controllers/agents/v1');const actions = require('./actions');+const tools = require('./tools');const upload = multer();const router = express.Router();@@ -35,9 +35,8 @@ router.use('/actions', actions);/*** Get a list of available tools for agents.* @route GET /agents/tools- * @returns {TPlugin[]} 200 - application/json*/-router.use('/tools', getAvailableTools);+router.use('/tools', tools);/*** Creates an agent.diff --git a/api/server/routes/files/files.js b/api/server/routes/files/files.jsindex 6d4ab7fefb..df2c05efe7 100644--- a/api/server/routes/files/files.js+++ b/api/server/routes/files/files.js@@ -17,6 +17,7 @@ const {const { getStrategyFunctions } = require('~/server/services/Files/strategies');const { getOpenAIClient } = require('~/server/controllers/assistants/helpers');const { loadAuthValues } = require('~/app/clients/tools/util');+const { getAgent } = require('~/models/Agent');const { getFiles } = require('~/models/File');const { logger } = require('~/config');@@ -67,12 +68,31 @@ router.delete('/', async (req, res) => {}const fileIds = files.map((file) => file.file_id);- const userFiles = await getFiles({ file_id: { $in: fileIds }, user: req.user.id });- if (userFiles.length !== files.length) {- return res.status(403).json({ message: 'You can only delete your own files' });+ const dbFiles = await getFiles({ file_id: { $in: fileIds } });+ const unauthorizedFiles = dbFiles.filter((file) => file.user.toString() !== req.user.id);++ if (unauthorizedFiles.length > 0) {+ return res.status(403).json({+ message: 'You can only delete your own files',+ unauthorizedFiles: unauthorizedFiles.map((f) => f.file_id),+ });}- await processDeleteRequest({ req, files: userFiles });+ /* Handle entity unlinking even if no valid files to delete */+ if (req.body.agent_id && req.body.tool_resource && dbFiles.length === 0) {+ const agent = await getAgent({+ id: req.body.agent_id,+ });++ const toolResourceFiles = agent.tool_resources?.[req.body.tool_resource]?.file_ids ?? [];+ const agentFiles = files.filter((f) => toolResourceFiles.includes(f.file_id));++ await processDeleteRequest({ req, files: agentFiles });+ res.status(200).json({ message: 'File associations removed successfully' });+ return;+ }++ await processDeleteRequest({ req, files: dbFiles });logger.debug(`[/files] Files deleted successfully: ${files@@ -87,13 +107,13 @@ router.delete('/', async (req, res) => {}});-router.get('/code/download/:sessionId/:fileId', async (req, res) => {+router.get('/code/download/:session_id/:fileId', async (req, res) => {try {- const { sessionId, fileId } = req.params;- const logPrefix = `Session ID: ${sessionId} | File ID: ${fileId} | Code output download requested by user `;+ const { session_id, fileId } = req.params;+ const logPrefix = `Session ID: ${session_id} | File ID: ${fileId} | Code output download requested by user `;logger.debug(logPrefix);- if (!sessionId || !fileId) {+ if (!session_id || !fileId) {return res.status(400).send('Bad request');}@@ -108,7 +128,10 @@ router.get('/code/download/:sessionId/:fileId', async (req, res) => {const result = await loadAuthValues({ userId: req.user.id, authFields: [EnvVar.CODE_API_KEY] });/** @type {AxiosResponse<ReadableStream> | undefined} */- const response = await getDownloadStream(`${sessionId}/${fileId}`, result[EnvVar.CODE_API_KEY]);+ const response = await getDownloadStream(+ `${session_id}/${fileId}`,+ result[EnvVar.CODE_API_KEY],+ );res.set(response.headers);response.data.pipe(res);} catch (error) {diff --git a/api/server/services/Endpoints/agents/initialize.js b/api/server/services/Endpoints/agents/initialize.jsindex b756b781ee..190972ac51 100644--- a/api/server/services/Endpoints/agents/initialize.js+++ b/api/server/services/Endpoints/agents/initialize.js@@ -11,7 +11,7 @@const { z } = require('zod');const { tool } = require('@langchain/core/tools');-const { createContentAggregator } = require('@librechat/agents');+const { createContentAggregator, Providers } = require('@librechat/agents');const {EModelEndpoint,getResponseSender,@@ -22,8 +22,9 @@ const {createToolEndCallback,} = require('~/server/controllers/agents/callbacks');const initAnthropic = require('~/server/services/Endpoints/anthropic/initialize');-const initOpenAI = require('~/server/services/Endpoints/openAI/initialize');const getBedrockOptions = require('~/server/services/Endpoints/bedrock/options');+const initOpenAI = require('~/server/services/Endpoints/openAI/initialize');+const initCustom = require('~/server/services/Endpoints/custom/initialize');const { loadAgentTools } = require('~/server/services/ToolService');const AgentClient = require('~/server/controllers/agents/client');const { getModelMaxTokens } = require('~/utils');@@ -53,6 +54,7 @@ const providerConfigMap = {[EModelEndpoint.azureOpenAI]: initOpenAI,[EModelEndpoint.anthropic]: initAnthropic,[EModelEndpoint.bedrock]: getBedrockOptions,+ [Providers.OLLAMA]: initCustom,};const initializeClient = async ({ req, res, endpointOption }) => {@@ -92,7 +94,7 @@ const initializeClient = async ({ req, res, endpointOption }) => {});let modelOptions = { model: agent.model };- const getOptions = providerConfigMap[agent.provider];+ let getOptions = providerConfigMap[agent.provider];if (!getOptions) {throw new Error(`Provider ${agent.provider} not supported`);}diff --git a/api/server/services/Endpoints/custom/initialize.js b/api/server/services/Endpoints/custom/initialize.jsindex dbc7a769fb..a2f410cdf1 100644--- a/api/server/services/Endpoints/custom/initialize.js+++ b/api/server/services/Endpoints/custom/initialize.js@@ -12,11 +12,14 @@ const { fetchModels } = require('~/server/services/ModelService');const getLogStores = require('~/cache/getLogStores');const { isUserProvided } = require('~/server/utils');const { OpenAIClient } = require('~/app');+const { Providers } = require('@librechat/agents');const { PROXY } = process.env;-const initializeClient = async ({ req, res, endpointOption }) => {- const { key: expiresAt, endpoint } = req.body;+const initializeClient = async ({ req, res, endpointOption, optionsOnly, overrideEndpoint }) => {+ const { key: expiresAt } = req.body;+ const endpoint = overrideEndpoint ?? req.body.endpoint;+const customConfig = await getCustomConfig();if (!customConfig) {throw new Error(`Config not found for the ${endpoint} custom endpoint.`);@@ -133,6 +136,17 @@ const initializeClient = async ({ req, res, endpointOption }) => {...endpointOption,};+ if (optionsOnly) {+ const modelOptions = endpointOption.model_parameters;+ if (endpoint === Providers.OLLAMA && clientOptions.reverseProxyUrl) {+ modelOptions.baseUrl = clientOptions.reverseProxyUrl.split('/v1')[0];+ delete clientOptions.reverseProxyUrl;+ }+ return {+ llmConfig: modelOptions,+ };+ }+const client = new OpenAIClient(apiKey, clientOptions);return {client,diff --git a/api/server/services/Files/Code/crud.js b/api/server/services/Files/Code/crud.jsindex 10aa130d2e..82b999b9bb 100644--- a/api/server/services/Files/Code/crud.js+++ b/api/server/services/Files/Code/crud.js@@ -1,19 +1,20 @@-// downloadStream.js-+// Code Filesconst axios = require('axios');+const FormData = require('form-data');const { getCodeBaseURL } = require('@librechat/agents');-const baseURL = getCodeBaseURL();+const MAX_FILE_SIZE = 25 * 1024 * 1024;/*** Retrieves a download stream for a specified file.- * @param {string} fileIdentifier - The identifier for the file (e.g., "sessionId/fileId").+ * @param {string} fileIdentifier - The identifier for the file (e.g., "session_id/fileId").* @param {string} apiKey - The API key for authentication.* @returns {Promise<AxiosResponse>} A promise that resolves to a readable stream of the file content.* @throws {Error} If there's an error during the download process.*/async function getCodeOutputDownloadStream(fileIdentifier, apiKey) {try {+ const baseURL = getCodeBaseURL();const response = await axios({method: 'get',url: `${baseURL}/download/${fileIdentifier}`,@@ -31,4 +32,45 @@ async function getCodeOutputDownloadStream(fileIdentifier, apiKey) {}}-module.exports = { getCodeOutputDownloadStream };+/**+ * Uploads a file to the Code Environment server.+ * @param {Object} params - The params object.+ * @param {ServerRequest} params.req - The request object from Express. It should have a `user` property with an `id`+ * representing the user, and an `app.locals.paths` object with an `uploads` path.+ * @param {import('fs').ReadStream | import('stream').Readable} params.stream - The read stream for the file.+ * @param {string} params.filename - The name of the file.+ * @param {string} params.apiKey - The API key for authentication.+ * @returns {Promise<string>}+ * @throws {Error} If there's an error during the upload process.+ */+async function uploadCodeEnvFile({ req, stream, filename, apiKey }) {+ try {+ const form = new FormData();+ form.append('file', stream, filename);++ const baseURL = getCodeBaseURL();+ const response = await axios.post(`${baseURL}/upload`, form, {+ headers: {+ ...form.getHeaders(),+ 'Content-Type': 'multipart/form-data',+ 'User-Agent': 'LibreChat/1.0',+ 'User-Id': req.user.id,+ 'X-API-Key': apiKey,+ },+ maxContentLength: MAX_FILE_SIZE,+ maxBodyLength: MAX_FILE_SIZE,+ });++ /** @type {{ message: string; session_id: string; files: Array<{ fileId: string; filename: string }> }} */+ const result = response.data;+ if (result.message !== 'success') {+ throw new Error(`Error uploading file: ${result.message}`);+ }++ return `${result.session_id}/${result.files[0].fileId}`;+ } catch (error) {+ throw new Error(`Error uploading file: ${error.message}`);+ }+}++module.exports = { getCodeOutputDownloadStream, uploadCodeEnvFile };diff --git a/api/server/services/Files/Code/process.js b/api/server/services/Files/Code/process.jsindex d8e8119367..313b98f39b 100644--- a/api/server/services/Files/Code/process.js+++ b/api/server/services/Files/Code/process.js@@ -1,11 +1,16 @@const path = require('path');const { v4 } = require('uuid');const axios = require('axios');-const { getCodeBaseURL, EnvVar } = require('@librechat/agents');-const { FileContext, imageExtRegex } = require('librechat-data-provider');+const { getCodeBaseURL } = require('@librechat/agents');+const {+ EToolResources,+ FileContext,+ imageExtRegex,+ FileSources,+} = require('librechat-data-provider');+const { getStrategyFunctions } = require('~/server/services/Files/strategies');const { convertImage } = require('~/server/services/Files/images/convert');-const { loadAuthValues } = require('~/app/clients/tools/util');-const { createFile } = require('~/models/File');+const { createFile, getFiles, updateFile } = require('~/models/File');const { logger } = require('~/config');/**@@ -13,8 +18,9 @@ const { logger } = require('~/config');* @param {ServerRequest} params.req - The Express request object.* @param {string} params.id - The file ID.* @param {string} params.name - The filename.+ * @param {string} params.apiKey - The code execution API key.* @param {string} params.toolCallId - The tool call ID that generated the file.- * @param {string} params.sessionId - The code execution session ID.+ * @param {string} params.session_id - The code execution session ID.* @param {string} params.conversationId - The current conversation ID.* @param {string} params.messageId - The current message ID.* @returns {Promise<MongoFile & { messageId: string, toolCallId: string } | { filename: string; filepath: string; expiresAt: number; conversationId: string; toolCallId: string; messageId: string } | undefined>} The file metadata or undefined if an error occurs.@@ -23,10 +29,11 @@ const processCodeOutput = async ({req,id,name,+ apiKey,toolCallId,conversationId,messageId,- sessionId,+ session_id,}) => {const currentDate = new Date();const baseURL = getCodeBaseURL();@@ -34,7 +41,7 @@ const processCodeOutput = async ({if (!fileExt || !imageExtRegex.test(name)) {return {filename: name,- filepath: `/api/files/code/download/${sessionId}/${id}`,+ filepath: `/api/files/code/download/${session_id}/${id}`,/** Note: expires 24 hours after creation */expiresAt: currentDate.getTime() + 86400000,conversationId,@@ -45,14 +52,13 @@ const processCodeOutput = async ({try {const formattedDate = currentDate.toISOString();- const result = await loadAuthValues({ userId: req.user.id, authFields: [EnvVar.CODE_API_KEY] });const response = await axios({method: 'get',- url: `${baseURL}/download/${sessionId}/${id}`,+ url: `${baseURL}/download/${session_id}/${id}`,responseType: 'arraybuffer',headers: {'User-Agent': 'LibreChat/1.0',- 'X-API-Key': result[EnvVar.CODE_API_KEY],+ 'X-API-Key': apiKey,},timeout: 15000,});@@ -82,6 +88,120 @@ const processCodeOutput = async ({}};+function checkIfActive(dateString) {+ const givenDate = new Date(dateString);+ const currentDate = new Date();+ const timeDifference = currentDate - givenDate;+ const hoursPassed = timeDifference / (1000 * 60 * 60);+ return hoursPassed < 23;+}++/**+ * Retrieves the `lastModified` time string for a specified file from Code Execution Server.+ *+ * @param {Object} params - The parameters object.+ * @param {string} params.fileIdentifier - The identifier for the file (e.g., "session_id/fileId").+ * @param {string} params.apiKey - The API key for authentication.+ *+ * @returns {Promise<string|null>}+ * A promise that resolves to the `lastModified` time string of the file if successful, or null if there is an+ * error in initialization or fetching the info.+ */+async function getSessionInfo(fileIdentifier, apiKey) {+ try {+ const baseURL = getCodeBaseURL();+ const session_id = fileIdentifier.split('/')[0];+ const response = await axios({+ method: 'get',+ url: `${baseURL}/files/${session_id}`,+ params: {+ detail: 'summary',+ },+ headers: {+ 'User-Agent': 'LibreChat/1.0',+ 'X-API-Key': apiKey,+ },+ timeout: 5000,+ });++ return response.data.find((file) => file.name.startsWith(fileIdentifier))?.lastModified;+ } catch (error) {+ logger.error(`Error fetching session info: ${error.message}`, error);+ return null;+ }+}++/**+ *+ * @param {Object} options+ * @param {ServerRequest} options.req+ * @param {Agent['tool_resources']} options.tool_resources+ * @param {string} apiKey+ * @returns {Promise<Array<{ id: string; session_id: string; name: string }>>}+ */+const primeFiles = async (options, apiKey) => {+ const { tool_resources } = options;+ const file_ids = tool_resources?.[EToolResources.execute_code]?.file_ids ?? [];+ const dbFiles = await getFiles({ file_id: { $in: file_ids } });++ const files = [];+ const sessions = new Map();+ for (const file of dbFiles) {+ if (file.metadata.fileIdentifier) {+ const [session_id, id] = file.metadata.fileIdentifier.split('/');+ const pushFile = () => {+ files.push({+ id,+ session_id,+ name: file.filename,+ });+ };+ if (sessions.has(session_id)) {+ pushFile();+ continue;+ }+ const reuploadFile = async () => {+ try {+ const { getDownloadStream } = getStrategyFunctions(file.source);+ const { handleFileUpload: uploadCodeEnvFile } = getStrategyFunctions(+ FileSources.execute_code,+ );+ const stream = await getDownloadStream(file.filepath);+ const fileIdentifier = await uploadCodeEnvFile({+ req: options.req,+ stream,+ filename: file.filename,+ apiKey,+ });+ await updateFile({ file_id: file.file_id, metadata: { fileIdentifier } });+ sessions.set(session_id, true);+ pushFile();+ } catch (error) {+ logger.error(+ `Error re-uploading file ${id} in session ${session_id}: ${error.message}`,+ error,+ );+ }+ };+ const uploadTime = await getSessionInfo(file.metadata.fileIdentifier, apiKey);+ if (!uploadTime) {+ logger.warn(`Failed to get upload time for file ${id} in session ${session_id}`);+ await reuploadFile();+ continue;+ }+ if (!checkIfActive(uploadTime)) {+ await reuploadFile();+ continue;+ }+ sessions.set(session_id, true);+ pushFile();+ }+ }++ return files;+};+module.exports = {+ primeFiles,processCodeOutput,};diff --git a/api/server/services/Files/Firebase/crud.js b/api/server/services/Files/Firebase/crud.jsindex c4d1d05bf6..76a6c1d8d4 100644--- a/api/server/services/Files/Firebase/crud.js+++ b/api/server/services/Files/Firebase/crud.js@@ -2,7 +2,7 @@ const fs = require('fs');const path = require('path');const axios = require('axios');const fetch = require('node-fetch');-const { ref, uploadBytes, getDownloadURL, getStream, deleteObject } = require('firebase/storage');+const { ref, uploadBytes, getDownloadURL, deleteObject } = require('firebase/storage');const { getBufferMetadata } = require('~/server/utils');const { getFirebaseStorage } = require('./initialize');const { logger } = require('~/config');@@ -155,7 +155,7 @@ function extractFirebaseFilePath(urlString) {* Deletes a file from Firebase storage. This function determines the filepath from the* Firebase storage URL via regex for deletion. Validated by the user's ID.*- * @param {Express.Request} req - The request object from Express.+ * @param {ServerRequest} req - The request object from Express.* It should contain a `user` object with an `id` property.* @param {MongoFile} file - The file object to be deleted.*@@ -195,7 +195,7 @@ const deleteFirebaseFile = async (req, file) => {* Uploads a file to Firebase Storage.** @param {Object} params - The params object.- * @param {Express.Request} params.req - The request object from Express. It should have a `user` property with an `id`+ * @param {ServerRequest} params.req - The request object from Express. It should have a `user` property with an `id`* representing the user.* @param {Express.Multer.File} params.file - The file object, which is part of the request. The file object should* have a `path` property that points to the location of the uploaded file.@@ -225,16 +225,22 @@ async function uploadFileToFirebase({ req, file, file_id }) {* Retrieves a readable stream for a file from Firebase storage.** @param {string} filepath - The filepath.- * @returns {ReadableStream} A readable stream of the file.+ * @returns {Promise<ReadableStream>} A readable stream of the file.*/-function getFirebaseFileStream(filepath) {+async function getFirebaseFileStream(filepath) {try {const storage = getFirebaseStorage();if (!storage) {throw new Error('Firebase is not initialized');}- const fileRef = ref(storage, filepath);- return getStream(fileRef);++ const response = await axios({+ method: 'get',+ url: filepath,+ responseType: 'stream',+ });++ return response.data;} catch (error) {logger.error('Error getting Firebase file stream:', error);throw error;diff --git a/api/server/services/Files/Local/crud.js b/api/server/services/Files/Local/crud.jsindex 12b7738828..e004eab79e 100644--- a/api/server/services/Files/Local/crud.js+++ b/api/server/services/Files/Local/crud.js@@ -1,6 +1,7 @@const fs = require('fs');const path = require('path');const axios = require('axios');+const { EModelEndpoint } = require('librechat-data-provider');const { getBufferMetadata } = require('~/server/utils');const paths = require('~/config/paths');const { logger } = require('~/config');@@ -222,6 +223,10 @@ const deleteLocalFile = async (req, file) => {const parts = file.filepath.split(path.sep);const subfolder = parts[1];+ if (!subfolder && parts[0] === EModelEndpoint.agents) {+ logger.warn(`Agent File ${file.file_id} is missing filepath, may have been deleted already`);+ return;+ }const filepath = path.join(publicPath, file.filepath);if (!isValidPath(req, publicPath, subfolder, filepath)) {@@ -235,7 +240,7 @@ const deleteLocalFile = async (req, file) => {* Uploads a file to the specified upload directory.** @param {Object} params - The params object.- * @param {Object} params.req - The request object from Express. It should have a `user` property with an `id`+ * @param {ServerRequest} params.req - The request object from Express. It should have a `user` property with an `id`* representing the user, and an `app.locals.paths` object with an `uploads` path.* @param {Express.Multer.File} params.file - The file object, which is part of the request. The file object should* have a `path` property that points to the location of the uploaded file.diff --git a/api/server/services/Files/OpenAI/crud.js b/api/server/services/Files/OpenAI/crud.jsindex 881b2063b4..64478ce7b3 100644--- a/api/server/services/Files/OpenAI/crud.js+++ b/api/server/services/Files/OpenAI/crud.js@@ -7,7 +7,7 @@ const { logger } = require('~/config');* Uploads a file that can be used across various OpenAI services.** @param {Object} params - The params object.- * @param {Express.Request} params.req - The request object from Express. It should have a `user` property with an `id`+ * @param {ServerRequest} params.req - The request object from Express. It should have a `user` property with an `id`* representing the user, and an `app.locals.paths` object with an `imageOutput` path.* @param {Express.Multer.File} params.file - The file uploaded to the server via multer.* @param {OpenAIClient} params.openai - The initialized OpenAI client.@@ -42,7 +42,7 @@ async function uploadOpenAIFile({ req, file, openai }) {/*** Deletes a file previously uploaded to OpenAI.*- * @param {Express.Request} req - The request object from Express.+ * @param {ServerRequest} req - The request object from Express.* @param {MongoFile} file - The database representation of the uploaded file.* @param {OpenAI} openai - The initialized OpenAI client.* @returns {Promise<void>}diff --git a/api/server/services/Files/VectorDB/crud.js b/api/server/services/Files/VectorDB/crud.jsindex c9a8c31583..3d16c93e15 100644--- a/api/server/services/Files/VectorDB/crud.js+++ b/api/server/services/Files/VectorDB/crud.js@@ -8,7 +8,7 @@ const { logger } = require('~/config');* Deletes a file from the vector database. This function takes a file object, constructs the full path, and* verifies the path's validity before deleting the file. If the path is invalid, an error is thrown.*- * @param {Express.Request} req - The request object from Express. It should have an `app.locals.paths` object with+ * @param {ServerRequest} req - The request object from Express. It should have an `app.locals.paths` object with* a `publicPath` property.* @param {MongoFile} file - The file object to be deleted. It should have a `filepath` property that is* a string representing the path of the file relative to the publicPath.diff --git a/api/server/services/Files/process.js b/api/server/services/Files/process.jsindex 00d98bbc20..d1cbc13ed1 100644--- a/api/server/services/Files/process.js+++ b/api/server/services/Files/process.js@@ -1,3 +1,4 @@+const fs = require('fs');const path = require('path');const mime = require('mime');const { v4 } = require('uuid');@@ -12,14 +13,17 @@ const {mergeFileConfig,hostImageIdSuffix,checkOpenAIStorage,+ removeNullishValues,hostImageNamePrefix,isAssistantsEndpoint,} = require('librechat-data-provider');+const { EnvVar } = require('@librechat/agents');const { addResourceFileId, deleteResourceFileId } = require('~/server/controllers/assistants/v2');const { convertImage, resizeAndConvert } = require('~/server/services/Files/images');const { addAgentResourceFile, removeAgentResourceFile } = require('~/models/Agent');const { getOpenAIClient } = require('~/server/controllers/assistants/helpers');const { createFile, updateFileUsage, deleteFiles } = require('~/models/File');+const { loadAuthValues } = require('~/app/clients/tools/util');const { LB_QueueAsyncCall } = require('~/server/utils/queue');const { getStrategyFunctions } = require('./strategies');const { determineFileType } = require('~/server/utils');@@ -89,6 +93,7 @@ function enqueueDeleteOperation({ req, file, deleteFile, promises, resolvedFileI* @param {MongoFile[]} params.files - The file objects to delete.* @param {Express.Request} params.req - The express request object.* @param {DeleteFilesBody} params.req.body - The request body.+ * @param {string} [params.req.body.agent_id] - The agent ID if file uploaded is associated to an agent.* @param {string} [params.req.body.assistant_id] - The assistant ID if file uploaded is associated to an assistant.* @param {string} [params.req.body.tool_resource] - The tool resource if assistant file uploaded is associated to a tool resource.*@@ -438,10 +443,25 @@ const processAgentFileUpload = async ({ req, res, file, metadata }) => {throw new Error('No agent ID provided for agent file upload');}+ let fileInfoMetadata;+ if (tool_resource === EToolResources.execute_code) {+ const { handleFileUpload: uploadCodeEnvFile } = getStrategyFunctions(FileSources.execute_code);+ const result = await loadAuthValues({ userId: req.user.id, authFields: [EnvVar.CODE_API_KEY] });+ const stream = fs.createReadStream(file.path);+ const fileIdentifier = await uploadCodeEnvFile({+ req,+ stream,+ filename: file.originalname,+ apiKey: result[EnvVar.CODE_API_KEY],+ });+ fileInfoMetadata = { fileIdentifier };+ }+const source =tool_resource === EToolResources.file_search? FileSources.vectordb: req.app.locals.fileStrategy;+const { handleFileUpload } = getStrategyFunctions(source);const { file_id, temp_file_id } = metadata;@@ -463,9 +483,9 @@ const processAgentFileUpload = async ({ req, res, file, metadata }) => {if (!messageAttachment && tool_resource) {await addAgentResourceFile({req,- agent_id,file_id,- tool_resource: tool_resource,+ agent_id,+ tool_resource,});}@@ -479,24 +499,24 @@ const processAgentFileUpload = async ({ req, res, file, metadata }) => {filepath = result.filepath;}- const result = await createFile(- {- user: req.user.id,- file_id,- temp_file_id,- bytes,- filepath,- filename: filename ?? file.originalname,- context: messageAttachment ? FileContext.message_attachment : FileContext.agents,- model: messageAttachment ? undefined : req.body.model,- type: file.mimetype,- embedded,- source,- height,- width,- },- true,- );+ const fileInfo = removeNullishValues({+ user: req.user.id,+ file_id,+ temp_file_id,+ bytes,+ filepath,+ filename: filename ?? file.originalname,+ context: messageAttachment ? FileContext.message_attachment : FileContext.agents,+ model: messageAttachment ? undefined : req.body.model,+ metadata: fileInfoMetadata,+ type: file.mimetype,+ embedded,+ source,+ height,+ width,+ });++ const result = await createFile(fileInfo, true);res.status(200).json({ message: 'Agent file uploaded and processed successfully', ...result });};diff --git a/api/server/services/Files/strategies.js b/api/server/services/Files/strategies.jsindex cfb837a50e..ddfdd57469 100644--- a/api/server/services/Files/strategies.js+++ b/api/server/services/Files/strategies.js@@ -5,11 +5,13 @@ const {saveURLToFirebase,deleteFirebaseFile,saveBufferToFirebase,+ uploadFileToFirebase,uploadImageToFirebase,processFirebaseAvatar,getFirebaseFileStream,} = require('./Firebase');const {+ uploadLocalFile,getLocalFileURL,saveFileFromURL,saveLocalBuffer,@@ -20,17 +22,15 @@ const {getLocalFileStream,} = require('./Local');const { uploadOpenAIFile, deleteOpenAIFile, getOpenAIFileStream } = require('./OpenAI');+const { getCodeOutputDownloadStream, uploadCodeEnvFile } = require('./Code');const { uploadVectors, deleteVectors } = require('./VectorDB');-const { getCodeOutputDownloadStream } = require('./Code');/*** Firebase Storage Strategy Functions** */const firebaseStrategy = () => ({- // saveFile:- /** @type {typeof uploadVectors | null} */- handleFileUpload: null,+ handleFileUpload: uploadFileToFirebase,saveURL: saveURLToFirebase,getFileURL: getFirebaseURL,deleteFile: deleteFirebaseFile,@@ -46,8 +46,7 @@ const firebaseStrategy = () => ({** */const localStrategy = () => ({- /** @type {typeof uploadVectors | null} */- handleFileUpload: null,+ handleFileUpload: uploadLocalFile,saveURL: saveFileFromURL,getFileURL: getLocalFileURL,saveBuffer: saveLocalBuffer,@@ -124,8 +123,7 @@ const codeOutputStrategy = () => ({prepareImagePayload: null,/** @type {typeof deleteLocalFile | null} */deleteFile: null,- /** @type {typeof uploadVectors | null} */- handleFileUpload: null,+ handleFileUpload: uploadCodeEnvFile,getDownloadStream: getCodeOutputDownloadStream,});diff --git a/api/utils/tokens.js b/api/utils/tokens.jsindex 362b2fc670..11a29e31f2 100644--- a/api/utils/tokens.js+++ b/api/utils/tokens.js@@ -77,13 +77,27 @@ const anthropicModels = {};const metaModels = {- 'llama2-13b': 4000,- 'llama2-70b': 4000,- 'llama3-8b': 8000,- 'llama3-70b': 8000,- 'llama3-1-8b': 127500,- 'llama3-1-70b': 127500,+ llama3: 8000,+ llama2: 4000,+ 'llama3.1': 127500,+ 'llama3-1': 127500,+ 'llama3.1:405b': 127500,+ 'llama3.1:70b': 127500,+ 'llama3.1:8b': 127500,'llama3-1-405b': 127500,+ 'llama3-1-70b': 127500,+ 'llama3-1-8b': 127500,+ 'llama3-70b': 8000,+ 'llama3-8b': 8000,+ 'llama2-70b': 4000,+ 'llama2-13b': 4000,+ 'llama3:70b': 8000,+ 'llama3:8b': 8000,+ 'llama2:70b': 4000,+};++const ollamaModels = {+ 'qwen2.5': 32000,};const ai21Models = {@@ -102,6 +116,7 @@ const bedrockModels = {...anthropicModels,...mistralModels,...cohereModels,+ ...ollamaModels,...metaModels,...ai21Models,...amazonModels,diff --git a/api/utils/tokens.spec.js b/api/utils/tokens.spec.jsindex e76e01a568..4912d3c80c 100644--- a/api/utils/tokens.spec.js+++ b/api/utils/tokens.spec.js@@ -1,5 +1,5 @@const { EModelEndpoint } = require('librechat-data-provider');-const { getModelMaxTokens, matchModelName, maxTokensMap } = require('./tokens');+const { getModelMaxTokens, processModelData, matchModelName, maxTokensMap } = require('./tokens');describe('getModelMaxTokens', () => {test('should return correct tokens for exact match', () => {@@ -317,3 +317,108 @@ describe('matchModelName', () => {expect(matchModelName('chat-', EModelEndpoint.google)).toBe('chat-');});});++describe('Meta Models Tests', () => {+ describe('getModelMaxTokens', () => {+ test('should return correct tokens for LLaMa 2 models', () => {+ expect(getModelMaxTokens('llama2')).toBe(4000);+ expect(getModelMaxTokens('llama2.70b')).toBe(4000);+ expect(getModelMaxTokens('llama2-13b')).toBe(4000);+ expect(getModelMaxTokens('llama2-70b')).toBe(4000);+ });++ test('should return correct tokens for LLaMa 3 models', () => {+ expect(getModelMaxTokens('llama3')).toBe(8000);+ expect(getModelMaxTokens('llama3.8b')).toBe(8000);+ expect(getModelMaxTokens('llama3.70b')).toBe(8000);+ expect(getModelMaxTokens('llama3-8b')).toBe(8000);+ expect(getModelMaxTokens('llama3-70b')).toBe(8000);+ });++ test('should return correct tokens for LLaMa 3.1 models', () => {+ expect(getModelMaxTokens('llama3.1:8b')).toBe(127500);+ expect(getModelMaxTokens('llama3.1:70b')).toBe(127500);+ expect(getModelMaxTokens('llama3.1:405b')).toBe(127500);+ expect(getModelMaxTokens('llama3-1-8b')).toBe(127500);+ expect(getModelMaxTokens('llama3-1-70b')).toBe(127500);+ expect(getModelMaxTokens('llama3-1-405b')).toBe(127500);+ });++ test('should handle partial matches for Meta models', () => {+ // Test with full model names+ expect(getModelMaxTokens('meta/llama3.1:405b')).toBe(127500);+ expect(getModelMaxTokens('meta/llama3.1:70b')).toBe(127500);+ expect(getModelMaxTokens('meta/llama3.1:8b')).toBe(127500);+ expect(getModelMaxTokens('meta/llama3-1-8b')).toBe(127500);++ // Test base versions+ expect(getModelMaxTokens('meta/llama3.1')).toBe(127500);+ expect(getModelMaxTokens('meta/llama3-1')).toBe(127500);+ expect(getModelMaxTokens('meta/llama3')).toBe(8000);+ expect(getModelMaxTokens('meta/llama2')).toBe(4000);+ });+ });++ describe('matchModelName', () => {+ test('should match exact LLaMa model names', () => {+ expect(matchModelName('llama2')).toBe('llama2');+ expect(matchModelName('llama3')).toBe('llama3');+ expect(matchModelName('llama3.1:8b')).toBe('llama3.1:8b');+ });++ test('should match LLaMa model variations', () => {+ // Test full model names+ expect(matchModelName('meta/llama3.1:405b')).toBe('llama3.1:405b');+ expect(matchModelName('meta/llama3.1:70b')).toBe('llama3.1:70b');+ expect(matchModelName('meta/llama3.1:8b')).toBe('llama3.1:8b');+ expect(matchModelName('meta/llama3-1-8b')).toBe('llama3-1-8b');++ // Test base versions+ expect(matchModelName('meta/llama3.1')).toBe('llama3.1');+ expect(matchModelName('meta/llama3-1')).toBe('llama3-1');+ });++ test('should handle custom endpoint for Meta models', () => {+ expect(matchModelName('llama2', EModelEndpoint.bedrock)).toBe('llama2');+ expect(matchModelName('llama3', EModelEndpoint.bedrock)).toBe('llama3');+ expect(matchModelName('llama3.1:8b', EModelEndpoint.bedrock)).toBe('llama3.1:8b');+ });+ });++ describe('processModelData with Meta models', () => {+ test('should process Meta model data correctly', () => {+ const input = {+ data: [+ {+ id: 'llama2',+ pricing: {+ prompt: '0.00001',+ completion: '0.00003',+ },+ context_length: 4000,+ },+ {+ id: 'llama3',+ pricing: {+ prompt: '0.00002',+ completion: '0.00004',+ },+ context_length: 8000,+ },+ ],+ };++ const result = processModelData(input);+ expect(result.llama2).toEqual({+ prompt: 10,+ completion: 30,+ context: 4000,+ });+ expect(result.llama3).toEqual({+ prompt: 20,+ completion: 40,+ context: 8000,+ });+ });+ });+});diff --git a/client/src/components/Bookmarks/BookmarkForm.tsx b/client/src/components/Bookmarks/BookmarkForm.tsxindex 85018d3cfb..df89e8bbb5 100644--- a/client/src/components/Bookmarks/BookmarkForm.tsx+++ b/client/src/components/Bookmarks/BookmarkForm.tsx@@ -7,12 +7,12 @@ import type {TConversationTag,TConversationTagRequest,} from 'librechat-data-provider';-import { cn, removeFocusOutlines, defaultTextProps, logger } from '~/utils';import { Checkbox, Label, TextareaAutosize, Input } from '~/components';import { useBookmarkContext } from '~/Providers/BookmarkContext';import { useConversationTagMutation } from '~/data-provider';import { useToastContext } from '~/Providers';import { useLocalize } from '~/hooks';+import { cn, logger } from '~/utils';type TBookmarkFormProps = {tags?: string[];diff --git a/client/src/components/Chat/Menus/Endpoints/UnknownIcon.tsx b/client/src/components/Chat/Menus/Endpoints/UnknownIcon.tsxindex 775bebc5d8..21574abbef 100644--- a/client/src/components/Chat/Menus/Endpoints/UnknownIcon.tsx+++ b/client/src/components/Chat/Menus/Endpoints/UnknownIcon.tsx@@ -47,26 +47,28 @@ const getKnownClass = ({export default function UnknownIcon({className = '',- endpoint,- iconURL,+ endpoint: _endpoint,+ iconURL = '',context,}: {iconURL?: string;className?: string;- endpoint: EModelEndpoint | string | null;+ endpoint?: EModelEndpoint | string | null;context?: 'landing' | 'menu-item' | 'nav' | 'message';}) {+ const endpoint = _endpoint ?? '';if (!endpoint) {return <CustomMinimalIcon className={className} />;}+ console.log('UnknownIcon', endpoint);const currentEndpoint = endpoint.toLowerCase();if (iconURL) {return <img className={className} src={iconURL} alt={`${endpoint} Icon`} />;}- const assetPath = knownEndpointAssets[currentEndpoint];+ const assetPath: string = knownEndpointAssets[currentEndpoint] ?? '';if (!assetPath) {return <CustomMinimalIcon className={className} />;diff --git a/client/src/components/Plugins/Store/PluginAuthForm.tsx b/client/src/components/Plugins/Store/PluginAuthForm.tsxindex aa8ce21283..01894504cf 100644--- a/client/src/components/Plugins/Store/PluginAuthForm.tsx+++ b/client/src/components/Plugins/Store/PluginAuthForm.tsx@@ -1,22 +1,26 @@-import { TPlugin, TPluginAuthConfig, TPluginAction } from 'librechat-data-provider';import { Save } from 'lucide-react';import { useForm } from 'react-hook-form';+import { TPlugin, TPluginAuthConfig, TPluginAction } from 'librechat-data-provider';import { HoverCard, HoverCardTrigger } from '~/components/ui';import PluginTooltip from './PluginTooltip';+import { useLocalize } from '~/hooks';type TPluginAuthFormProps = {plugin: TPlugin | undefined;onSubmit: (installActionData: TPluginAction) => void;- isAssistantTool?: boolean;+ isEntityTool?: boolean;};-function PluginAuthForm({ plugin, onSubmit, isAssistantTool }: TPluginAuthFormProps) {+function PluginAuthForm({ plugin, onSubmit, isEntityTool }: TPluginAuthFormProps) {const {register,handleSubmit,formState: { errors, isDirty, isValid, isSubmitting },} = useForm();+ const localize = useLocalize();+ const authConfig = plugin?.authConfig ?? [];+return (<div className="flex w-full flex-col items-center gap-2"><div className="grid w-full gap-6 sm:grid-cols-2">@@ -28,11 +32,11 @@ function PluginAuthForm({ plugin, onSubmit, isAssistantTool }: TPluginAuthFormPrpluginKey: plugin?.pluginKey ?? '',action: 'install',auth,- isAssistantTool,+ isEntityTool,}),)}>- {plugin?.authConfig?.map((config: TPluginAuthConfig, i: number) => {+ {authConfig.map((config: TPluginAuthConfig, i: number) => {const authField = config.authField.split('||')[0];return (<div key={`${authField}-${i}`} className="flex w-full flex-col gap-1">@@ -66,8 +70,7 @@ function PluginAuthForm({ plugin, onSubmit, isAssistantTool }: TPluginAuthFormPr</HoverCard>{errors[authField] && (<span role="alert" className="mt-1 text-sm text-red-400">- {/* @ts-ignore - Type 'string | FieldError | Merge<FieldError, FieldErrorsImpl<any>> | undefined' is not assignable to type 'ReactNode' */}- {errors[authField].message}+ {errors[authField].message as string}</span>)}</div>@@ -79,7 +82,7 @@ function PluginAuthForm({ plugin, onSubmit, isAssistantTool }: TPluginAuthFormPrclassName="btn btn-primary relative"><div className="flex items-center justify-center gap-2">- Save+ {localize('com_ui_save')}<Save className="flex h-4 w-4 items-center stroke-2" /></div></button>diff --git a/client/src/components/SidePanel/Agents/AgentConfig.tsx b/client/src/components/SidePanel/Agents/AgentConfig.tsxindex aca975d9b4..fb14d7e5f3 100644--- a/client/src/components/SidePanel/Agents/AgentConfig.tsx+++ b/client/src/components/SidePanel/Agents/AgentConfig.tsx@@ -11,7 +11,6 @@ import { icons } from '~/components/Chat/Menus/Endpoints/Icons';import Action from '~/components/SidePanel/Builder/Action';import { ToolSelectDialog } from '~/components/Tools';import { useLocalize, useAuthContext } from '~/hooks';-import CapabilitiesForm from './CapabilitiesForm';import { processAgentOption } from '~/utils';import { Spinner } from '~/components/svg';import DeleteButton from './DeleteButton';@@ -19,6 +18,7 @@ import AgentAvatar from './AgentAvatar';import FileSearch from './FileSearch';import ShareAgent from './ShareAgent';import AgentTool from './AgentTool';+// import CodeForm from './Code/Form';import { Panel } from '~/common';const labelClass = 'mb-2 text-token-text-primary block font-medium';@@ -92,6 +92,26 @@ export default function AgentConfig({return _agent.knowledge_files ?? [];}, [agent, agent_id, fileMap]);+ const code_files = useMemo(() => {+ if (typeof agent === 'string') {+ return [];+ }++ if (agent?.id !== agent_id) {+ return [];+ }++ if (agent.code_files) {+ return agent.code_files;+ }++ const _agent = processAgentOption({+ agent,+ fileMap,+ });+ return _agent.code_files ?? [];+ }, [agent, agent_id, fileMap]);+/* Mutations */const update = useUpdateAgentMutation({onSuccess: (data) => {@@ -293,7 +313,7 @@ export default function AgentConfig({<div className="shadow-stroke relative flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full bg-white text-black dark:bg-white"><IconclassName="h-2/3 w-2/3"- endpoint={provider as string}+ endpoint={providerValue as string}endpointType={endpointType}iconURL={endpointIconURL}/>@@ -303,11 +323,8 @@ export default function AgentConfig({</div></button></div>- <CapabilitiesForm- codeEnabled={codeEnabled}- agentsConfig={agentsConfig}- retrievalEnabled={false}- />+ {/* Code Execution */}+ {/* {codeEnabled && <CodeForm agent_id={agent_id} files={code_files} />} */}{/* File Search */}{fileSearchEnabled && <FileSearch agent_id={agent_id} files={knowledge_files} />}{/* Agent Tools & Actions */}diff --git a/client/src/components/SidePanel/Agents/AgentTool.tsx b/client/src/components/SidePanel/Agents/AgentTool.tsxindex ed5eed0c07..59c2e267f1 100644--- a/client/src/components/SidePanel/Agents/AgentTool.tsx+++ b/client/src/components/SidePanel/Agents/AgentTool.tsx@@ -12,7 +12,7 @@ import { cn } from '~/utils';export default function AgentTool({tool,allTools,- agent_id,+ agent_id = '',}: {tool: string;allTools: TPlugin[];@@ -28,7 +28,7 @@ export default function AgentTool({const removeTool = (tool: string) => {if (tool) {updateUserPlugins.mutate(- { pluginKey: tool, action: 'uninstall', auth: null, isAgentTool: true },+ { pluginKey: tool, action: 'uninstall', auth: null, isEntityTool: true },{onError: (error: unknown) => {showToast({ message: `Error while deleting the tool: ${error}`, status: 'error' });diff --git a/client/src/components/SidePanel/Agents/CapabilitiesForm.tsx b/client/src/components/SidePanel/Agents/CapabilitiesForm.tsxdeleted file mode 100644index 064ab26646..0000000000--- a/client/src/components/SidePanel/Agents/CapabilitiesForm.tsx+++ /dev/null@@ -1,56 +0,0 @@-import { useMemo } from 'react';-// import { Capabilities } from 'librechat-data-provider';-// import { useFormContext, useWatch } from 'react-hook-form';-import type { TConfig } from 'librechat-data-provider';-// import type { AgentForm } from '~/common';-// import ImageVision from './ImageVision';-import { useLocalize } from '~/hooks';-import Retrieval from './Retrieval';-// import CodeFiles from './CodeFiles';-import Code from './Code';--export default function CapabilitiesForm({- codeEnabled,- retrievalEnabled,- agentsConfig,-}: {- codeEnabled?: boolean;- retrievalEnabled?: boolean;- agentsConfig?: TConfig | null;-}) {- const localize = useLocalize();-- // const methods = useFormContext<AgentForm>();- // const { control } = methods;- // const agent = useWatch({ control, name: 'agent' });- // const agent_id = useWatch({ control, name: 'id' });- // const files = useMemo(() => {- // if (typeof agent === 'string') {- // return [];- // }- // return agent?.code_files;- // }, [agent]);-- const retrievalModels = useMemo(- () => new Set(agentsConfig?.retrievalModels ?? []),- [agentsConfig],- );-- return (- <div className="mb-4">- <div className="mb-1.5 flex items-center">- <span>- <label className="text-token-text-primary block font-medium">- {localize('com_assistants_capabilities')}- </label>- </span>- </div>- <div className="flex flex-col items-start gap-2">- {codeEnabled === true && <Code />}- {retrievalEnabled === true && <Retrieval retrievalModels={retrievalModels} />}- {/* {imageVisionEnabled && version == 1 && <ImageVision />} */}- {/* {codeEnabled && <CodeFiles agent_id={agent_id} files={files} />} */}- </div>- </div>- );-}diff --git a/client/src/components/SidePanel/Agents/Code.tsx b/client/src/components/SidePanel/Agents/Code.tsxdeleted file mode 100644index bb3d383429..0000000000--- a/client/src/components/SidePanel/Agents/Code.tsx+++ /dev/null@@ -1,70 +0,0 @@-import { AgentCapabilities } from 'librechat-data-provider';-import { useFormContext, Controller } from 'react-hook-form';-import type { AgentForm } from '~/common';-import {- Checkbox,- HoverCard,- HoverCardContent,- HoverCardPortal,- HoverCardTrigger,-} from '~/components/ui';-import { CircleHelpIcon } from '~/components/svg';-import { useLocalize } from '~/hooks';-import { ESide } from '~/common';--export default function Code() {- const localize = useLocalize();- const methods = useFormContext<AgentForm>();- const { control, setValue, getValues } = methods;-- return (- <>- <HoverCard openDelay={50}>- <div className="flex items-center">- <Controller- name={AgentCapabilities.execute_code}- control={control}- render={({ field }) => (- <Checkbox- {...field}- checked={field.value}- onCheckedChange={field.onChange}- className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"- value={field.value.toString()}- />- )}- />- <button- type="button"- className="flex items-center space-x-2"- onClick={() =>- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions- setValue(AgentCapabilities.execute_code, !getValues(AgentCapabilities.execute_code), {- shouldDirty: true,- })- }- >- <label- className="form-check-label text-token-text-primary w-full cursor-pointer"- htmlFor={AgentCapabilities.execute_code}- >- {localize('com_agents_execute_code')}- </label>- <HoverCardTrigger>- <CircleHelpIcon className="h-5 w-5 text-gray-500" />- </HoverCardTrigger>- </button>- <HoverCardPortal>- <HoverCardContent side={ESide.Top} className="w-80">- <div className="space-y-2">- <p className="text-sm text-text-secondary">- {/* // TODO: add a Code Interpreter description */}- </p>- </div>- </HoverCardContent>- </HoverCardPortal>- </div>- </HoverCard>- </>- );-}diff --git a/client/src/components/SidePanel/Agents/Code/Action.tsx b/client/src/components/SidePanel/Agents/Code/Action.tsxnew file mode 100644index 0000000000..4a1af816d5--- /dev/null+++ b/client/src/components/SidePanel/Agents/Code/Action.tsx@@ -0,0 +1,151 @@+import { useState } from 'react';+import { KeyRoundIcon } from 'lucide-react';+import { AuthType, AgentCapabilities } from 'librechat-data-provider';+import { useFormContext, Controller, useForm, useWatch } from 'react-hook-form';+import type { AgentForm } from '~/common';+import {+ Input,+ OGDialog,+ Checkbox,+ HoverCard,+ HoverCardContent,+ HoverCardPortal,+ HoverCardTrigger,+ Button,+} from '~/components/ui';+import OGDialogTemplate from '~/components/ui/OGDialogTemplate';+import { useLocalize, useAuthCodeTool } from '~/hooks';+import { CircleHelpIcon } from '~/components/svg';+import { ESide } from '~/common';++type ApiKeyFormData = {+ apiKey: string;+ authType?: string | AuthType;+};++export default function Action({ authType = '', isToolAuthenticated = false }) {+ const localize = useLocalize();+ const methods = useFormContext<AgentForm>();+ const { control, setValue, getValues } = methods;+ const [isDialogOpen, setIsDialogOpen] = useState(false);+ const runCodeIsEnabled = useWatch({ control, name: AgentCapabilities.execute_code });++ const { installTool, removeTool } = useAuthCodeTool({ isEntityTool: true });++ const { reset, register, handleSubmit } = useForm<ApiKeyFormData>();+ const isUserProvided = authType === AuthType.USER_PROVIDED;++ const handleCheckboxChange = (checked: boolean) => {+ if (isToolAuthenticated) {+ setValue(AgentCapabilities.execute_code, checked, { shouldDirty: true });+ } else if (runCodeIsEnabled) {+ setValue(AgentCapabilities.execute_code, false, { shouldDirty: true });+ } else {+ setIsDialogOpen(true);+ }+ };++ const onSubmit = (data: { apiKey: string }) => {+ reset();+ installTool(data.apiKey);+ setIsDialogOpen(false);+ };++ const handleRevokeApiKey = () => {+ reset();+ removeTool();+ setIsDialogOpen(false);+ };++ return (+ <>+ <HoverCard openDelay={50}>+ <div className="flex items-center">+ <Controller+ name={AgentCapabilities.execute_code}+ control={control}+ render={({ field }) => (+ <Checkbox+ {...field}+ checked={runCodeIsEnabled ? runCodeIsEnabled : isToolAuthenticated && field.value}+ onCheckedChange={handleCheckboxChange}+ className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"+ value={field.value.toString()}+ disabled={runCodeIsEnabled ? false : !isToolAuthenticated}+ />+ )}+ />+ <button+ type="button"+ className="flex items-center space-x-2"+ onClick={() => {+ const value = !getValues(AgentCapabilities.execute_code);+ handleCheckboxChange(value);+ }}+ >+ <label+ className="form-check-label text-token-text-primary w-full cursor-pointer"+ htmlFor={AgentCapabilities.execute_code}+ >+ {localize('com_agents_execute_code')}+ </label>+ </button>+ <div className="ml-2 flex gap-2">+ {isUserProvided && (isToolAuthenticated || runCodeIsEnabled) && (+ <button type="button" onClick={() => setIsDialogOpen(true)}>+ <KeyRoundIcon className="h-5 w-5 text-text-primary" />+ </button>+ )}+ <HoverCardTrigger>+ <CircleHelpIcon className="h-5 w-5 text-gray-500" />+ </HoverCardTrigger>+ </div>+ <HoverCardPortal>+ <HoverCardContent side={ESide.Top} className="w-80">+ <div className="space-y-2">+ <p className="text-sm text-text-secondary">+ {/* // TODO: add a Code Interpreter description */}+ </p>+ </div>+ </HoverCardContent>+ </HoverCardPortal>+ </div>+ </HoverCard>+ <OGDialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>+ <OGDialogTemplate+ className="w-11/12 sm:w-1/4"+ title={localize('com_agents_tool_not_authenticated')}+ main={+ <form onSubmit={handleSubmit(onSubmit)}>+ <Input+ type="password"+ placeholder="Enter API Key"+ autoComplete="one-time-code"+ readOnly={true}+ onFocus={(e) => (e.target.readOnly = false)}+ {...register('apiKey', { required: true })}+ />+ </form>+ }+ selection={{+ selectHandler: handleSubmit(onSubmit),+ selectClasses: 'bg-green-500 hover:bg-green-600 text-white',+ selectText: localize('com_ui_save'),+ }}+ buttons={+ isUserProvided &&+ isToolAuthenticated && (+ <Button+ onClick={handleRevokeApiKey}+ className="bg-destructive text-white transition-all duration-200 hover:bg-destructive/80"+ >+ {localize('com_ui_revoke')}+ </Button>+ )+ }+ showCancelButton={true}+ />+ </OGDialog>+ </>+ );+}diff --git a/client/src/components/SidePanel/Agents/CodeFiles.tsx b/client/src/components/SidePanel/Agents/Code/Files.tsxsimilarity index 76%rename from client/src/components/SidePanel/Agents/CodeFiles.tsxrename to client/src/components/SidePanel/Agents/Code/Files.tsxindex e5f21017b1..2e92671571 100644--- a/client/src/components/SidePanel/Agents/CodeFiles.tsx+++ b/client/src/components/SidePanel/Agents/Code/Files.tsx@@ -1,21 +1,22 @@-import { useState, useRef, useEffect } from 'react';+import { useState, useRef } from 'react';+import { useFormContext } from 'react-hook-form';import {EToolResources,EModelEndpoint,mergeFileConfig,+ AgentCapabilities,fileConfig as defaultFileConfig,} from 'librechat-data-provider';import type { EndpointFileConfig } from 'librechat-data-provider';-import type { ExtendedFile } from '~/common';+import type { ExtendedFile, AgentForm } from '~/common';+import { useFileHandling, useLocalize, useLazyEffect } from '~/hooks';import FileRow from '~/components/Chat/Input/Files/FileRow';import { useGetFileConfig } from '~/data-provider';-import { useFileHandling } from '~/hooks/Files';-import useLocalize from '~/hooks/useLocalize';import { useChatContext } from '~/Providers';-const tool_resource = EToolResources.code_interpreter;+const tool_resource = EToolResources.execute_code;-export default function CodeFiles({+export default function Files({agent_id,files: _files,}: {@@ -24,22 +25,29 @@ export default function CodeFiles({}) {const localize = useLocalize();const { setFilesLoading } = useChatContext();+ const { watch } = useFormContext<AgentForm>();const fileInputRef = useRef<HTMLInputElement>(null);const [files, setFiles] = useState<Map<string, ExtendedFile>>(new Map());const { data: fileConfig = defaultFileConfig } = useGetFileConfig({select: (data) => mergeFileConfig(data),});- const { handleFileChange } = useFileHandling({+ const { abortUpload, handleFileChange } = useFileHandling({+ fileSetter: setFiles,overrideEndpoint: EModelEndpoint.agents,additionalMetadata: { agent_id, tool_resource },- fileSetter: setFiles,});- useEffect(() => {- if (_files) {- setFiles(new Map(_files));- }- }, [_files]);+ useLazyEffect(+ () => {+ if (_files) {+ setFiles(new Map(_files));+ }+ },+ [_files],+ 750,+ );++ const codeChecked = watch(AgentCapabilities.execute_code);const endpointFileConfig = fileConfig.endpoints[EModelEndpoint.agents] as| EndpointFileConfig@@ -68,6 +76,7 @@ export default function CodeFiles({files={files}setFiles={setFiles}agent_id={agent_id}+ abortUpload={abortUpload}tool_resource={tool_resource}setFilesLoading={setFilesLoading}Wrapper={({ children }) => <div className="flex flex-wrap gap-2">{children}</div>}@@ -75,7 +84,7 @@ export default function CodeFiles({<div><buttontype="button"- disabled={!agent_id}+ disabled={!agent_id || codeChecked === false}className="btn btn-neutral border-token-border-light relative h-8 w-full rounded-lg font-medium"onClick={handleButtonClick}>@@ -86,7 +95,7 @@ export default function CodeFiles({style={{ display: 'none' }}tabIndex={-1}ref={fileInputRef}- disabled={!agent_id}+ disabled={!agent_id || codeChecked === false}onChange={handleFileChange}/>{localize('com_ui_upload_files')}diff --git a/client/src/components/SidePanel/Agents/Code/Form.tsx b/client/src/components/SidePanel/Agents/Code/Form.tsxnew file mode 100644index 0000000000..6985c2b389--- /dev/null+++ b/client/src/components/SidePanel/Agents/Code/Form.tsx@@ -0,0 +1,33 @@+import { Tools } from 'librechat-data-provider';+import type { ExtendedFile } from '~/common';+import { useVerifyAgentToolAuth } from '~/data-provider';+import { useLocalize } from '~/hooks';+import Action from './Action';+import Files from './Files';++export default function CodeForm({+ agent_id,+ files,+}: {+ agent_id: string;+ files?: [string, ExtendedFile][];+}) {+ const localize = useLocalize();+ const { data } = useVerifyAgentToolAuth({ toolId: Tools.execute_code });++ return (+ <div className="mb-4">+ <div className="mb-1.5 flex items-center">+ <span>+ <label className="text-token-text-primary block font-medium">+ {localize('com_assistants_capabilities')}+ </label>+ </span>+ </div>+ <div className="flex flex-col items-start gap-2">+ <Action authType={data?.message} isToolAuthenticated={data?.authenticated} />+ <Files agent_id={agent_id} files={files} />+ </div>+ </div>+ );+}diff --git a/client/src/components/SidePanel/Agents/FileSearch.tsx b/client/src/components/SidePanel/Agents/FileSearch.tsxindex 9e4c061bd3..bd377fd072 100644--- a/client/src/components/SidePanel/Agents/FileSearch.tsx+++ b/client/src/components/SidePanel/Agents/FileSearch.tsx@@ -1,4 +1,4 @@-import { useState, useRef, useEffect } from 'react';+import { useState, useRef } from 'react';import { useFormContext } from 'react-hook-form';import {EModelEndpoint,@@ -9,12 +9,11 @@ import {fileConfig as defaultFileConfig,} from 'librechat-data-provider';import type { ExtendedFile, AgentForm } from '~/common';+import { useFileHandling, useLocalize, useLazyEffect } from '~/hooks';import FileRow from '~/components/Chat/Input/Files/FileRow';import FileSearchCheckbox from './FileSearchCheckbox';import { useGetFileConfig } from '~/data-provider';import { AttachmentIcon } from '~/components/svg';-import { useFileHandling } from '~/hooks/Files';-import useLocalize from '~/hooks/useLocalize';import { useChatContext } from '~/Providers';export default function FileSearch({@@ -40,18 +39,22 @@ export default function FileSearch({fileSetter: setFiles,});- useEffect(() => {- if (_files) {- setFiles(new Map(_files));- }- }, [_files]);+ useLazyEffect(+ () => {+ if (_files) {+ setFiles(new Map(_files));+ }+ },+ [_files],+ 750,+ );const fileSearchChecked = watch(AgentCapabilities.file_search);const endpointFileConfig = fileConfig.endpoints[EModelEndpoint.agents];- const disabled = endpointFileConfig.disabled ?? false;+ const isUploadDisabled = endpointFileConfig.disabled ?? false;- if (disabled === true) {+ if (isUploadDisabled) {return null;}diff --git a/client/src/components/SidePanel/Builder/AssistantTool.tsx b/client/src/components/SidePanel/Builder/AssistantTool.tsxindex 13b8d1ba9f..317f6264dd 100644--- a/client/src/components/SidePanel/Builder/AssistantTool.tsx+++ b/client/src/components/SidePanel/Builder/AssistantTool.tsx@@ -12,7 +12,7 @@ import { cn } from '~/utils';export default function AssistantTool({tool,allTools,- assistant_id,+ assistant_id = '',}: {tool: string;allTools: TPlugin[];@@ -28,7 +28,7 @@ export default function AssistantTool({const removeTool = (tool: string) => {if (tool) {updateUserPlugins.mutate(- { pluginKey: tool, action: 'uninstall', auth: null, isAssistantTool: true },+ { pluginKey: tool, action: 'uninstall', auth: null, isEntityTool: true },{onError: (error: unknown) => {showToast({ message: `Error while deleting the tool: ${error}`, status: 'error' });@@ -78,7 +78,7 @@ export default function AssistantTool({<OGDialogTrigger asChild><buttontype="button"- className="transition-colors flex h-9 w-9 min-w-9 items-center justify-center rounded-lg duration-200 hover:bg-gray-200 dark:hover:bg-gray-700"+ className="flex h-9 w-9 min-w-9 items-center justify-center rounded-lg transition-colors duration-200 hover:bg-gray-200 dark:hover:bg-gray-700"><TrashIcon /></button>diff --git a/client/src/components/Tools/ToolSelectDialog.tsx b/client/src/components/Tools/ToolSelectDialog.tsxindex 895f8aff47..a2a1dc79cb 100644--- a/client/src/components/Tools/ToolSelectDialog.tsx+++ b/client/src/components/Tools/ToolSelectDialog.tsx@@ -90,7 +90,7 @@ function ToolSelectDialog({const onRemoveTool = (tool: string) => {setShowPluginAuthForm(false);updateUserPlugins.mutate(- { pluginKey: tool, action: 'uninstall', auth: null, isAssistantTool: true },+ { pluginKey: tool, action: 'uninstall', auth: null, isEntityTool: true },{onError: (error: unknown) => {handleInstallError(error as TError);@@ -199,7 +199,7 @@ function ToolSelectDialog({<PluginAuthFormplugin={selectedPlugin}onSubmit={(installActionData: TPluginAction) => handleInstall(installActionData)}- isAssistantTool={true}+ isEntityTool={true}/></div>)}diff --git a/client/src/data-provider/Files/mutations.ts b/client/src/data-provider/Files/mutations.tsindex 5cdd226517..9f51a5e717 100644--- a/client/src/data-provider/Files/mutations.ts+++ b/client/src/data-provider/Files/mutations.ts@@ -10,13 +10,6 @@ import {import type * as t from 'librechat-data-provider';import type { UseMutationResult } from '@tanstack/react-query';-export type TGenTitleMutation = UseMutationResult<- t.TGenTitleResponse,- unknown,- t.TGenTitleRequest,- unknown->;-export const useUploadFileMutation = (_options?: t.UploadMutationOptions,signal?: AbortSignal | null,@@ -152,9 +145,9 @@ export const useDeleteFilesMutation = (return useMutation([MutationKeys.fileDelete], {mutationFn: (body: t.DeleteFilesBody) => dataService.deleteFiles(body),...options,- onSuccess: (data, ...args) => {+ onSuccess: (data, vars, context) => {queryClient.setQueryData<t.TFile[] | undefined>([QueryKeys.files], (cachefiles) => {- const { files: filesDeleted } = args[0];+ const { files: filesDeleted } = vars;const fileMap = filesDeleted.reduce((acc, file) => {acc.set(file.file_id, file);@@ -163,7 +156,10 @@ export const useDeleteFilesMutation = (return (cachefiles ?? []).filter((file) => !fileMap.has(file.file_id));});- onSuccess?.(data, ...args);+ onSuccess?.(data, vars, context);+ if (vars.agent_id != null && vars.agent_id) {+ queryClient.refetchQueries([QueryKeys.agent, vars.agent_id]);+ }},});};diff --git a/client/src/data-provider/Tools/index.ts b/client/src/data-provider/Tools/index.tsnew file mode 100644index 0000000000..c8699b2430--- /dev/null+++ b/client/src/data-provider/Tools/index.ts@@ -0,0 +1,2 @@+export * from './queries';+// export * from './mutations';diff --git a/client/src/data-provider/Tools/queries.ts b/client/src/data-provider/Tools/queries.tsnew file mode 100644index 0000000000..7ca8e2f0ef--- /dev/null+++ b/client/src/data-provider/Tools/queries.ts@@ -0,0 +1,20 @@+import { QueryKeys, dataService } from 'librechat-data-provider';+import { useQuery } from '@tanstack/react-query';+import type { QueryObserverResult, UseQueryOptions } from '@tanstack/react-query';+import type t from 'librechat-data-provider';++export const useVerifyAgentToolAuth = (+ params: t.VerifyToolAuthParams,+ config?: UseQueryOptions<t.VerifyToolAuthResponse>,+): QueryObserverResult<t.VerifyToolAuthResponse> => {+ return useQuery<t.VerifyToolAuthResponse>(+ [QueryKeys.toolAuth, params.toolId],+ () => dataService.getVerifyAgentToolAuth(params),+ {+ refetchOnWindowFocus: false,+ refetchOnReconnect: false,+ refetchOnMount: false,+ ...config,+ },+ );+};diff --git a/client/src/data-provider/index.ts b/client/src/data-provider/index.tsindex 1729c969bb..2a9dc740f2 100644--- a/client/src/data-provider/index.ts+++ b/client/src/data-provider/index.ts@@ -1,4 +1,5 @@export * from './Files';+export * from './Tools';export * from './connection';export * from './mutations';export * from './prompts';diff --git a/client/src/hooks/Generic/index.ts b/client/src/hooks/Generic/index.tsnew file mode 100644index 0000000000..9d9d64459f--- /dev/null+++ b/client/src/hooks/Generic/index.ts@@ -0,0 +1 @@+export * from './useLazyEffect';diff --git a/client/src/hooks/Generic/useLazyEffect.ts b/client/src/hooks/Generic/useLazyEffect.tsnew file mode 100644index 0000000000..b205a162d2--- /dev/null+++ b/client/src/hooks/Generic/useLazyEffect.ts@@ -0,0 +1,18 @@+/* eslint-disable react-hooks/exhaustive-deps */+// https://stackoverflow.com/a/67504622/51500+import { DependencyList, EffectCallback, useCallback, useEffect, useRef } from 'react';+import debounce from 'lodash/debounce';++export function useLazyEffect(effect: EffectCallback, deps: DependencyList = [], wait = 300) {+ const cleanUp = useRef<void | (() => void)>();+ const effectRef = useRef<EffectCallback>();+ effectRef.current = useCallback(effect, deps);+ const lazyEffect = useCallback(+ debounce(() => (cleanUp.current = effectRef.current?.()), wait),+ [],+ );+ useEffect(lazyEffect, deps);+ useEffect(() => {+ return () => (cleanUp.current instanceof Function ? cleanUp.current() : undefined);+ }, []);+}diff --git a/client/src/hooks/Plugins/index.ts b/client/src/hooks/Plugins/index.tsindex 53db4f0d27..0668e757d6 100644--- a/client/src/hooks/Plugins/index.ts+++ b/client/src/hooks/Plugins/index.ts@@ -1,2 +1,3 @@+export { default as useAuthCodeTool } from './useAuthCodeTool';export { default as usePluginInstall } from './usePluginInstall';export { default as usePluginDialogHelpers } from './usePluginDialogHelpers';diff --git a/client/src/hooks/Plugins/useAuthCodeTool.ts b/client/src/hooks/Plugins/useAuthCodeTool.tsnew file mode 100644index 0000000000..b33e05c169--- /dev/null+++ b/client/src/hooks/Plugins/useAuthCodeTool.ts@@ -0,0 +1,53 @@+import { useCallback } from 'react';+import { useQueryClient } from '@tanstack/react-query';+import { AuthType, Tools, QueryKeys } from 'librechat-data-provider';+import { useUpdateUserPluginsMutation } from 'librechat-data-provider/react-query';+// import { useToastContext } from '~/Providers';++const useAuthCodeTool = (options?: { isEntityTool: boolean }) => {+ // const { showToast } = useToastContext();+ const queryClient = useQueryClient();+ const isEntityTool = options?.isEntityTool ?? true;+ const updateUserPlugins = useUpdateUserPluginsMutation({+ onMutate: (vars) => {+ queryClient.setQueryData([QueryKeys.toolAuth, Tools.execute_code], () => ({+ authenticated: vars.action === 'install',+ message: AuthType.USER_PROVIDED,+ }));+ },+ onSuccess: () => {+ queryClient.invalidateQueries([QueryKeys.toolAuth, Tools.execute_code]);+ },+ onError: () => {+ queryClient.invalidateQueries([QueryKeys.toolAuth, Tools.execute_code]);+ },+ });++ const installTool = useCallback(+ (apiKey: string) => {+ updateUserPlugins.mutate({+ pluginKey: Tools.execute_code,+ action: 'install',+ auth: { LIBRECHAT_CODE_API_KEY: apiKey },+ isEntityTool,+ });+ },+ [updateUserPlugins, isEntityTool],+ );++ const removeTool = useCallback(() => {+ updateUserPlugins.mutate({+ pluginKey: Tools.execute_code,+ action: 'uninstall',+ auth: { LIBRECHAT_CODE_API_KEY: null },+ isEntityTool,+ });+ }, [updateUserPlugins, isEntityTool]);++ return {+ removeTool,+ installTool,+ };+};++export default useAuthCodeTool;diff --git a/client/src/hooks/index.ts b/client/src/hooks/index.tsindex 26e466b447..863173df3d 100644--- a/client/src/hooks/index.ts+++ b/client/src/hooks/index.ts@@ -6,6 +6,7 @@ export * from './Config';export * from './Conversations';export * from './Nav';export * from './Files';+export * from './Generic';export * from './Input';export * from './Messages';export * from './Plugins';diff --git a/package-lock.json b/package-lock.jsonindex b61352eff6..f218774e76 100644--- a/package-lock.json+++ b/package-lock.json@@ -52,7 +52,7 @@"@langchain/core": "^0.2.18","@langchain/google-genai": "^0.0.11","@langchain/google-vertexai": "^0.0.17",- "@librechat/agents": "^1.6.9",+ "@librechat/agents": "^1.7.7","axios": "^1.7.7","bcryptjs": "^2.4.3","cheerio": "^1.0.0-rc.12",@@ -1260,9 +1260,9 @@}},"api/node_modules/openai": {- "version": "4.63.0",- "resolved": "https://registry.npmjs.org/openai/-/openai-4.63.0.tgz",- "integrity": "sha512-Y9V4KODbmrOpqiOmCDVnPfMxMqKLOx8Hwcdn/r8mePq4yv7FSXGnxCs8/jZKO7zCB/IVPWihpJXwJNAIOEiZ2g==",+ "version": "4.70.2",+ "resolved": "https://registry.npmjs.org/openai/-/openai-4.70.2.tgz",+ "integrity": "sha512-Q2ymi/KPUYv+LJ9rFxeYxpkVAhcrZFTVvnJbdF1pUHg9eMC6lY8PU4TO1XOK5UZzOZuuVicouRwVMi1iDrT4qw==","dependencies": {"@types/node": "^18.11.18","@types/node-fetch": "^2.6.4",@@ -8245,6 +8245,29 @@"integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==","dev": true},+ "node_modules/@ibm-cloud/watsonx-ai": {+ "version": "1.1.2",+ "resolved": "https://registry.npmjs.org/@ibm-cloud/watsonx-ai/-/watsonx-ai-1.1.2.tgz",+ "integrity": "sha512-0+ClK12jk1Jk28Hwc2BDmKkTXPjFkQOfCKzUk82TsoPwAIEVN+rlM1cny52d3oSMXXbeKorVDmnIEbXPseHiQA==",+ "peer": true,+ "dependencies": {+ "@types/node": "^18.0.0",+ "extend": "3.0.2",+ "ibm-cloud-sdk-core": "^5.0.2"+ },+ "engines": {+ "node": ">=18.0.0"+ }+ },+ "node_modules/@ibm-cloud/watsonx-ai/node_modules/@types/node": {+ "version": "18.19.63",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.63.tgz",+ "integrity": "sha512-hcUB7THvrGmaEcPcvUZCZtQ2Z3C+UR/aOcraBLCvTsFMh916Gc1kCCYcfcMuB76HM2pSerxl1PoP3KnmHzd9Lw==",+ "peer": true,+ "dependencies": {+ "undici-types": "~5.26.4"+ }+ },"node_modules/@ioredis/commands": {"version": "1.2.0","resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz",@@ -8875,200 +8898,6 @@"node": ">= 14"}},- "node_modules/@langchain/anthropic": {- "version": "0.2.18",- "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-0.2.18.tgz",- "integrity": "sha512-4ZDTxMwGKTPRAi2Supu/faBSmwPIm/ga5QlazyO78Mf/8QbDR2DcvM5394FAy+X/nRAfnMbyXteO5IRJm653gw==",- "dependencies": {- "@anthropic-ai/sdk": "^0.25.2",- "@langchain/core": ">=0.2.21 <0.3.0",- "fast-xml-parser": "^4.4.1",- "zod": "^3.22.4",- "zod-to-json-schema": "^3.22.4"- },- "engines": {- "node": ">=18"- }- },- "node_modules/@langchain/anthropic/node_modules/@anthropic-ai/sdk": {- "version": "0.25.2",- "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.25.2.tgz",- "integrity": "sha512-F1Hck/asswwidFLtGdMg3XYgRxEUfygNbpkq5KEaEGsHNaSfxeX18/uZGQCL0oQNcj/tYNx8BaFXVwRhFDi45g==",- "dependencies": {- "@types/node": "^18.11.18",- "@types/node-fetch": "^2.6.4",- "abort-controller": "^3.0.0",- "agentkeepalive": "^4.2.1",- "form-data-encoder": "1.7.2",- "formdata-node": "^4.3.2",- "node-fetch": "^2.6.7"- }- },- "node_modules/@langchain/anthropic/node_modules/@langchain/core": {- "version": "0.2.34",- "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.34.tgz",- "integrity": "sha512-Hkveq1UcOjUj1DVn5erbqElyRj1t04NORSuSIZAJCtPO7EDkIqomjAarJ5+I5NUpQeIONgbOdnY9TkJ6cKUSVA==",- "dependencies": {- "ansi-styles": "^5.0.0",- "camelcase": "6",- "decamelize": "1.2.0",- "js-tiktoken": "^1.0.12",- "langsmith": "^0.1.56-rc.1",- "mustache": "^4.2.0",- "p-queue": "^6.6.2",- "p-retry": "4",- "uuid": "^10.0.0",- "zod": "^3.22.4",- "zod-to-json-schema": "^3.22.3"- },- "engines": {- "node": ">=18"- }- },- "node_modules/@langchain/anthropic/node_modules/@types/node": {- "version": "18.19.53",- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.53.tgz",- "integrity": "sha512-GLxgUgHhDKO1Edw9Q0lvMbiO/IQXJwJlMaqxSGBXMpPy8uhkCs2iiPFaB2Q/gmobnFkckD3rqTBMVjXdwq+nKg==",- "dependencies": {- "undici-types": "~5.26.4"- }- },- "node_modules/@langchain/anthropic/node_modules/@types/uuid": {- "version": "10.0.0",- "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz",- "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ=="- },- "node_modules/@langchain/anthropic/node_modules/ansi-styles": {- "version": "5.2.0",- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz",- "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",- "engines": {- "node": ">=10"- },- "funding": {- "url": "https://github.com/chalk/ansi-styles?sponsor=1"- }- },- "node_modules/@langchain/anthropic/node_modules/langsmith": {- "version": "0.1.61",- "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.61.tgz",- "integrity": "sha512-XQE4KPScwPmdaT0mWDzhNxj9gvqXUR+C7urLA0QFi27XeoQdm17eYpudenn4wxC0gIyUJutQCyuYJpfwlT5JnQ==",- "dependencies": {- "@types/uuid": "^10.0.0",- "commander": "^10.0.1",- "p-queue": "^6.6.2",- "p-retry": "4",- "semver": "^7.6.3",- "uuid": "^10.0.0"- },- "peerDependencies": {- "openai": "*"- },- "peerDependenciesMeta": {- "openai": {- "optional": true- }- }- },- "node_modules/@langchain/anthropic/node_modules/uuid": {- "version": "10.0.0",- "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",- "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==",- "funding": [- "https://github.com/sponsors/broofa",- "https://github.com/sponsors/ctavan"- ],- "bin": {- "uuid": "dist/bin/uuid"- }- },- "node_modules/@langchain/aws": {- "version": "0.0.10",- "resolved": "https://registry.npmjs.org/@langchain/aws/-/aws-0.0.10.tgz",- "integrity": "sha512-q9sL34lq2UpSVDBTNixy2+DJbjd5RSlCGBoatVeWpfMDv2J47sJZlfVGfXLidFZhQox6uL1GyQJoKrIb+Cu97Q==",- "dependencies": {- "@aws-sdk/client-bedrock-agent-runtime": "^3.616.0",- "@aws-sdk/client-bedrock-runtime": "^3.602.0",- "@aws-sdk/client-kendra": "^3.352.0",- "@aws-sdk/credential-provider-node": "^3.600.0",- "@langchain/core": ">=0.2.21 <0.3.0",- "zod": "^3.23.8",- "zod-to-json-schema": "^3.22.5"- },- "engines": {- "node": ">=18"- }- },- "node_modules/@langchain/aws/node_modules/@langchain/core": {- "version": "0.2.34",- "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.34.tgz",- "integrity": "sha512-Hkveq1UcOjUj1DVn5erbqElyRj1t04NORSuSIZAJCtPO7EDkIqomjAarJ5+I5NUpQeIONgbOdnY9TkJ6cKUSVA==",- "dependencies": {- "ansi-styles": "^5.0.0",- "camelcase": "6",- "decamelize": "1.2.0",- "js-tiktoken": "^1.0.12",- "langsmith": "^0.1.56-rc.1",- "mustache": "^4.2.0",- "p-queue": "^6.6.2",- "p-retry": "4",- "uuid": "^10.0.0",- "zod": "^3.22.4",- "zod-to-json-schema": "^3.22.3"- },- "engines": {- "node": ">=18"- }- },- "node_modules/@langchain/aws/node_modules/@types/uuid": {- "version": "10.0.0",- "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz",- "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ=="- },- "node_modules/@langchain/aws/node_modules/ansi-styles": {- "version": "5.2.0",- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz",- "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",- "engines": {- "node": ">=10"- },- "funding": {- "url": "https://github.com/chalk/ansi-styles?sponsor=1"- }- },- "node_modules/@langchain/aws/node_modules/langsmith": {- "version": "0.1.61",- "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.61.tgz",- "integrity": "sha512-XQE4KPScwPmdaT0mWDzhNxj9gvqXUR+C7urLA0QFi27XeoQdm17eYpudenn4wxC0gIyUJutQCyuYJpfwlT5JnQ==",- "dependencies": {- "@types/uuid": "^10.0.0",- "commander": "^10.0.1",- "p-queue": "^6.6.2",- "p-retry": "4",- "semver": "^7.6.3",- "uuid": "^10.0.0"- },- "peerDependencies": {- "openai": "*"- },- "peerDependenciesMeta": {- "openai": {- "optional": true- }- }- },- "node_modules/@langchain/aws/node_modules/uuid": {- "version": "10.0.0",- "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",- "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==",- "funding": [- "https://github.com/sponsors/broofa",- "https://github.com/sponsors/ctavan"- ],- "bin": {- "uuid": "dist/bin/uuid"- }- },"node_modules/@langchain/community": {"version": "0.0.17","resolved": "https://registry.npmjs.org/@langchain/community/-/community-0.0.17.tgz",@@ -9655,95 +9484,15 @@"node": ">=18"}},- "node_modules/@langchain/langgraph": {- "version": "0.0.31",- "resolved": "https://registry.npmjs.org/@langchain/langgraph/-/langgraph-0.0.31.tgz",- "integrity": "sha512-f5QMSLy/RnLktsqnNm2mq8gp1xplHwQf87XIPVO0IYuumOJiafx5lE7ahPO+fVmCzAz6LxcsVocvD0JqxXR/2w==",- "dependencies": {- "@langchain/core": ">=0.2.18 <0.3.0",- "uuid": "^10.0.0",- "zod": "^3.23.8"- },- "engines": {- "node": ">=18"- },- "peerDependencies": {- "better-sqlite3": "^9.5.0"- },- "peerDependenciesMeta": {- "better-sqlite3": {- "optional": true- }- }- },- "node_modules/@langchain/langgraph/node_modules/@langchain/core": {- "version": "0.2.34",- "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.34.tgz",- "integrity": "sha512-Hkveq1UcOjUj1DVn5erbqElyRj1t04NORSuSIZAJCtPO7EDkIqomjAarJ5+I5NUpQeIONgbOdnY9TkJ6cKUSVA==",- "dependencies": {- "ansi-styles": "^5.0.0",- "camelcase": "6",- "decamelize": "1.2.0",- "js-tiktoken": "^1.0.12",- "langsmith": "^0.1.56-rc.1",- "mustache": "^4.2.0",- "p-queue": "^6.6.2",- "p-retry": "4",- "uuid": "^10.0.0",- "zod": "^3.22.4",- "zod-to-json-schema": "^3.22.3"- },- "engines": {- "node": ">=18"- }- },- "node_modules/@langchain/langgraph/node_modules/@types/uuid": {- "version": "10.0.0",- "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz",- "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ=="- },- "node_modules/@langchain/langgraph/node_modules/ansi-styles": {- "version": "5.2.0",- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz",- "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",- "engines": {- "node": ">=10"- },- "funding": {- "url": "https://github.com/chalk/ansi-styles?sponsor=1"- }- },- "node_modules/@langchain/langgraph/node_modules/langsmith": {- "version": "0.1.61",- "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.61.tgz",- "integrity": "sha512-XQE4KPScwPmdaT0mWDzhNxj9gvqXUR+C7urLA0QFi27XeoQdm17eYpudenn4wxC0gIyUJutQCyuYJpfwlT5JnQ==",+ "node_modules/@langchain/langgraph-sdk": {+ "version": "0.0.20",+ "resolved": "https://registry.npmjs.org/@langchain/langgraph-sdk/-/langgraph-sdk-0.0.20.tgz",+ "integrity": "sha512-58iGYL0PppSiIHtIUNAN+x6TCl+Vb0dAmlToSMJHUng8W53ffXHQTNqVNxJlPsHO6zdgPJm4DRl53z6vkSUZpw==","dependencies": {- "@types/uuid": "^10.0.0",- "commander": "^10.0.1",+ "@types/json-schema": "^7.0.15","p-queue": "^6.6.2","p-retry": "4",- "semver": "^7.6.3",- "uuid": "^10.0.0"- },- "peerDependencies": {- "openai": "*"- },- "peerDependenciesMeta": {- "openai": {- "optional": true- }- }- },- "node_modules/@langchain/langgraph/node_modules/uuid": {- "version": "10.0.0",- "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",- "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==",- "funding": [- "https://github.com/sponsors/broofa",- "https://github.com/sponsors/ctavan"- ],- "bin": {- "uuid": "dist/bin/uuid"+ "uuid": "^9.0.0"}},"node_modules/@langchain/mistralai": {@@ -9762,9 +9511,9 @@}},"node_modules/@langchain/mistralai/node_modules/@langchain/core": {- "version": "0.2.34",- "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.34.tgz",- "integrity": "sha512-Hkveq1UcOjUj1DVn5erbqElyRj1t04NORSuSIZAJCtPO7EDkIqomjAarJ5+I5NUpQeIONgbOdnY9TkJ6cKUSVA==",+ "version": "0.2.36",+ "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.36.tgz",+ "integrity": "sha512-qHLvScqERDeH7y2cLuJaSAlMwg3f/3Oc9nayRSXRU2UuaK/SOhI42cxiPLj1FnuHJSmN0rBQFkrLx02gI4mcVg==","dependencies": {"ansi-styles": "^5.0.0","camelcase": "6",@@ -9799,9 +9548,9 @@}},"node_modules/@langchain/mistralai/node_modules/langsmith": {- "version": "0.1.61",- "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.61.tgz",- "integrity": "sha512-XQE4KPScwPmdaT0mWDzhNxj9gvqXUR+C7urLA0QFi27XeoQdm17eYpudenn4wxC0gIyUJutQCyuYJpfwlT5JnQ==",+ "version": "0.1.68",+ "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.68.tgz",+ "integrity": "sha512-otmiysWtVAqzMx3CJ4PrtUBhWRG5Co8Z4o7hSZENPjlit9/j3/vm3TSvbaxpDYakZxtMjhkcJTqrdYFipISEiQ==","dependencies": {"@types/uuid": "^10.0.0","commander": "^10.0.1",@@ -9872,88 +9621,6 @@"openai": "bin/cli"}},- "node_modules/@langchain/textsplitters": {- "version": "0.0.3",- "resolved": "https://registry.npmjs.org/@langchain/textsplitters/-/textsplitters-0.0.3.tgz",- "integrity": "sha512-cXWgKE3sdWLSqAa8ykbCcUsUF1Kyr5J3HOWYGuobhPEycXW4WI++d5DhzdpL238mzoEXTi90VqfSCra37l5YqA==",- "dependencies": {- "@langchain/core": ">0.2.0 <0.3.0",- "js-tiktoken": "^1.0.12"- },- "engines": {- "node": ">=18"- }- },- "node_modules/@langchain/textsplitters/node_modules/@langchain/core": {- "version": "0.2.34",- "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.34.tgz",- "integrity": "sha512-Hkveq1UcOjUj1DVn5erbqElyRj1t04NORSuSIZAJCtPO7EDkIqomjAarJ5+I5NUpQeIONgbOdnY9TkJ6cKUSVA==",- "dependencies": {- "ansi-styles": "^5.0.0",- "camelcase": "6",- "decamelize": "1.2.0",- "js-tiktoken": "^1.0.12",- "langsmith": "^0.1.56-rc.1",- "mustache": "^4.2.0",- "p-queue": "^6.6.2",- "p-retry": "4",- "uuid": "^10.0.0",- "zod": "^3.22.4",- "zod-to-json-schema": "^3.22.3"- },- "engines": {- "node": ">=18"- }- },- "node_modules/@langchain/textsplitters/node_modules/@types/uuid": {- "version": "10.0.0",- "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz",- "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ=="- },- "node_modules/@langchain/textsplitters/node_modules/ansi-styles": {- "version": "5.2.0",- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz",- "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",- "engines": {- "node": ">=10"- },- "funding": {- "url": "https://github.com/chalk/ansi-styles?sponsor=1"- }- },- "node_modules/@langchain/textsplitters/node_modules/langsmith": {- "version": "0.1.61",- "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.61.tgz",- "integrity": "sha512-XQE4KPScwPmdaT0mWDzhNxj9gvqXUR+C7urLA0QFi27XeoQdm17eYpudenn4wxC0gIyUJutQCyuYJpfwlT5JnQ==",- "dependencies": {- "@types/uuid": "^10.0.0",- "commander": "^10.0.1",- "p-queue": "^6.6.2",- "p-retry": "4",- "semver": "^7.6.3",- "uuid": "^10.0.0"- },- "peerDependencies": {- "openai": "*"- },- "peerDependenciesMeta": {- "openai": {- "optional": true- }- }- },- "node_modules/@langchain/textsplitters/node_modules/uuid": {- "version": "10.0.0",- "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",- "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==",- "funding": [- "https://github.com/sponsors/broofa",- "https://github.com/sponsors/ctavan"- ],- "bin": {- "uuid": "dist/bin/uuid"- }- },"node_modules/@lezer/common": {"version": "1.2.1","resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.2.1.tgz",@@ -10006,45 +9673,95 @@}},"node_modules/@librechat/agents": {- "version": "1.6.9",- "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-1.6.9.tgz",- "integrity": "sha512-a2ef4cpC8BpegiIOJkC5rVqtp2lAfTEm/wWUfQ/wtEFPPyUBlnzoQRcO79V3Veju3DzkmMBJP5oUrzGZ+lKemg==",+ "version": "1.7.7",+ "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-1.7.7.tgz",+ "integrity": "sha512-0VOvPtPzbAUF5BXt+qeIlQqYzPV4RC4+iz3g9HooBPDIuPlaEHAH7RC2fiRKO6XJ/1E5/8YSj6YugV3MJGyyoQ==","dependencies": {"@aws-crypto/sha256-js": "^5.2.0","@aws-sdk/credential-provider-node": "^3.613.0","@aws-sdk/types": "^3.609.0",- "@langchain/anthropic": "^0.2.15",- "@langchain/aws": "^0.0.10",- "@langchain/community": "^0.2.20",- "@langchain/core": "^0.2.31",+ "@langchain/anthropic": "^0.3.7",+ "@langchain/aws": "^0.1.1",+ "@langchain/community": "^0.3.11",+ "@langchain/core": "^0.3.16","@langchain/google-vertexai": "^0.0.20",- "@langchain/langgraph": "^0.0.31",+ "@langchain/langgraph": "^0.2.19","@langchain/mistralai": "^0.0.26",+ "@langchain/ollama": "^0.1.1",+ "@langchain/openai": "^0.3.11","@smithy/eventstream-codec": "^2.2.0","@smithy/protocol-http": "^3.0.6","@smithy/signature-v4": "^2.0.10","@smithy/util-utf8": "^2.0.0","dotenv": "^16.4.5",- "langchain": "^0.2.10","nanoid": "^3.3.7"},"engines": {"node": ">=14.0.0"}},+ "node_modules/@librechat/agents/node_modules/@anthropic-ai/sdk": {+ "version": "0.27.3",+ "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.27.3.tgz",+ "integrity": "sha512-IjLt0gd3L4jlOfilxVXTifn42FnVffMgDC04RJK1KDZpmkBWLv0XC92MVVmkxrFZNS/7l3xWgP/I3nqtX1sQHw==",+ "dependencies": {+ "@types/node": "^18.11.18",+ "@types/node-fetch": "^2.6.4",+ "abort-controller": "^3.0.0",+ "agentkeepalive": "^4.2.1",+ "form-data-encoder": "1.7.2",+ "formdata-node": "^4.3.2",+ "node-fetch": "^2.6.7"+ }+ },+ "node_modules/@librechat/agents/node_modules/@langchain/anthropic": {+ "version": "0.3.7",+ "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-0.3.7.tgz",+ "integrity": "sha512-MjV7BNPalnG3S6PqXYHRtv3nEML1fFHl9OsqjT5KCPcULxJImnIZrJX5qMTnezM5A+Q6KOZt3e07x7aYCmU3Sg==",+ "dependencies": {+ "@anthropic-ai/sdk": "^0.27.3",+ "fast-xml-parser": "^4.4.1",+ "zod": "^3.22.4",+ "zod-to-json-schema": "^3.22.4"+ },+ "engines": {+ "node": ">=18"+ },+ "peerDependencies": {+ "@langchain/core": ">=0.2.21 <0.4.0"+ }+ },+ "node_modules/@librechat/agents/node_modules/@langchain/aws": {+ "version": "0.1.1",+ "resolved": "https://registry.npmjs.org/@langchain/aws/-/aws-0.1.1.tgz",+ "integrity": "sha512-6JoRoW/8nca+jJcklZ6kJ7qBUQoBskygGiF5Wf3A89JPyGCHDds8rPQFNJO5S7ki+kRRNWh5G5hcc2ahaqZjWQ==",+ "dependencies": {+ "@aws-sdk/client-bedrock-agent-runtime": "^3.616.0",+ "@aws-sdk/client-bedrock-runtime": "^3.602.0",+ "@aws-sdk/client-kendra": "^3.352.0",+ "@aws-sdk/credential-provider-node": "^3.600.0",+ "zod": "^3.23.8",+ "zod-to-json-schema": "^3.22.5"+ },+ "engines": {+ "node": ">=18"+ },+ "peerDependencies": {+ "@langchain/core": ">=0.2.21 <0.4.0"+ }+ },"node_modules/@librechat/agents/node_modules/@langchain/community": {- "version": "0.2.33",- "resolved": "https://registry.npmjs.org/@langchain/community/-/community-0.2.33.tgz",- "integrity": "sha512-YsytROnBYoPqtUcV2In+afyLACzxwFrYRn7EBKYL7XWl3XNwrT85U1+nLM5b+MOjXvg9YfJSjrs1Tlbfy4st8g==",+ "version": "0.3.11",+ "resolved": "https://registry.npmjs.org/@langchain/community/-/community-0.3.11.tgz",+ "integrity": "sha512-hgnqsgWAhfUj9Kp0y+FGxlKot/qJFxat9GfIPJSJU4ViN434PgeMAQK53tkGZ361E2Zoo1V4RoGlSw4AjJILiA==","dependencies": {- "@langchain/core": ">=0.2.21 <0.3.0",- "@langchain/openai": ">=0.2.0 <0.3.0",+ "@langchain/openai": ">=0.2.0 <0.4.0","binary-extensions": "^2.2.0","expr-eval": "^2.0.2","flat": "^5.0.2","js-yaml": "^4.1.0",- "langchain": "~0.2.3",- "langsmith": "~0.1.30",+ "langchain": ">=0.2.3 <0.3.0 || >=0.3.4 <0.4.0",+ "langsmith": "^0.2.0","uuid": "^10.0.0","zod": "^3.22.3","zod-to-json-schema": "^3.22.5"@@ -10080,9 +9797,11 @@"@google-cloud/storage": "^6.10.1 || ^7.7.0","@gradientai/nodejs-sdk": "^1.2.0","@huggingface/inference": "^2.6.4",- "@langchain/langgraph": "*",+ "@ibm-cloud/watsonx-ai": "*",+ "@langchain/core": ">=0.2.21 <0.4.0","@layerup/layerup-security": "^1.5.12",- "@mendable/firecrawl-js": "^0.0.13",+ "@libsql/client": "^0.14.0",+ "@mendable/firecrawl-js": "^1.4.3","@mlc-ai/web-llm": "*","@mozilla/readability": "*","@neondatabase/serverless": "*",@@ -10103,7 +9822,7 @@"@tensorflow-models/universal-sentence-encoder": "*","@tensorflow/tfjs-converter": "*","@tensorflow/tfjs-core": "*",- "@upstash/ratelimit": "^1.1.3",+ "@upstash/ratelimit": "^1.1.3 || ^2.0.3","@upstash/redis": "^1.20.6","@upstash/vector": "^1.1.1","@vercel/kv": "^0.2.3",@@ -10124,7 +9843,6 @@"closevector-web": "0.1.6","cohere-ai": "*","convex": "^1.3.1",- "couchbase": "^4.3.0","crypto-js": "^4.2.0","d3-dsv": "^2.0.0","discord.js": "^14.14.1",@@ -10137,6 +9855,7 @@"googleapis": "*","hnswlib-node": "^3.0.0","html-to-text": "^9.0.5",+ "ibm-cloud-sdk-core": "*","ignore": "^5.2.0","interface-datastore": "^8.2.11","ioredis": "^5.3.2",@@ -10150,7 +9869,6 @@"mongodb": ">=5.2.0","mysql2": "^3.9.8","neo4j-driver": "*",- "node-llama-cpp": "*","notion-to-md": "^3.1.0","officeparser": "^4.0.4","pdf-parse": "1.1.1",@@ -10160,6 +9878,7 @@"playwright": "^1.32.1","portkey-ai": "^0.1.11","puppeteer": "*",+ "pyodide": ">=0.24.1 <0.27.0","redis": "*","replicate": "^0.29.4","sonix-speech-recognition": "^2.1.1",@@ -10257,10 +9976,10 @@"@huggingface/inference": {"optional": true},- "@langchain/langgraph": {+ "@layerup/layerup-security": {"optional": true},- "@layerup/layerup-security": {+ "@libsql/client": {"optional": true},"@mendable/firecrawl-js": {@@ -10389,9 +10108,6 @@"convex": {"optional": true},- "couchbase": {- "optional": true- },"crypto-js": {"optional": true},@@ -10467,9 +10183,6 @@"neo4j-driver": {"optional": true},- "node-llama-cpp": {- "optional": true- },"notion-to-md": {"optional": true},@@ -10497,6 +10210,9 @@"puppeteer": {"optional": true},+ "pyodide": {+ "optional": true+ },"redis": {"optional": true},@@ -10541,16 +10257,95 @@}}},+ "node_modules/@librechat/agents/node_modules/@langchain/community/node_modules/langchain": {+ "version": "0.3.5",+ "resolved": "https://registry.npmjs.org/langchain/-/langchain-0.3.5.tgz",+ "integrity": "sha512-Gq0xC45Sq6nszS8kQG9suCrmBsuXH0INMmiF7D2TwPb6mtG35Jiq4grCk9ykpwPsarTHdty3SzUbII/FqiYSSw==",+ "dependencies": {+ "@langchain/openai": ">=0.1.0 <0.4.0",+ "@langchain/textsplitters": ">=0.0.0 <0.2.0",+ "js-tiktoken": "^1.0.12",+ "js-yaml": "^4.1.0",+ "jsonpointer": "^5.0.1",+ "langsmith": "^0.2.0",+ "openapi-types": "^12.1.3",+ "p-retry": "4",+ "uuid": "^10.0.0",+ "yaml": "^2.2.1",+ "zod": "^3.22.4",+ "zod-to-json-schema": "^3.22.3"+ },+ "engines": {+ "node": ">=18"+ },+ "peerDependencies": {+ "@langchain/anthropic": "*",+ "@langchain/aws": "*",+ "@langchain/cohere": "*",+ "@langchain/core": ">=0.2.21 <0.4.0",+ "@langchain/google-genai": "*",+ "@langchain/google-vertexai": "*",+ "@langchain/groq": "*",+ "@langchain/mistralai": "*",+ "@langchain/ollama": "*",+ "axios": "*",+ "cheerio": "*",+ "handlebars": "^4.7.8",+ "peggy": "^3.0.2",+ "typeorm": "*"+ },+ "peerDependenciesMeta": {+ "@langchain/anthropic": {+ "optional": true+ },+ "@langchain/aws": {+ "optional": true+ },+ "@langchain/cohere": {+ "optional": true+ },+ "@langchain/google-genai": {+ "optional": true+ },+ "@langchain/google-vertexai": {+ "optional": true+ },+ "@langchain/groq": {+ "optional": true+ },+ "@langchain/mistralai": {+ "optional": true+ },+ "@langchain/ollama": {+ "optional": true+ },+ "axios": {+ "optional": true+ },+ "cheerio": {+ "optional": true+ },+ "handlebars": {+ "optional": true+ },+ "peggy": {+ "optional": true+ },+ "typeorm": {+ "optional": true+ }+ }+ },"node_modules/@librechat/agents/node_modules/@langchain/core": {- "version": "0.2.34",- "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.34.tgz",- "integrity": "sha512-Hkveq1UcOjUj1DVn5erbqElyRj1t04NORSuSIZAJCtPO7EDkIqomjAarJ5+I5NUpQeIONgbOdnY9TkJ6cKUSVA==",+ "version": "0.3.16",+ "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.3.16.tgz",+ "integrity": "sha512-g83M2Z1XlhECFUtT4C7XLsVVGt2Hk3Y/KhS5tZSsz+Gqtxwd790/MD7MxdUHpZj0VKkvrFuWARWpJmNKlkiY+g==","dependencies": {"ansi-styles": "^5.0.0","camelcase": "6","decamelize": "1.2.0","js-tiktoken": "^1.0.12",- "langsmith": "^0.1.56-rc.1",+ "langsmith": "^0.2.0","mustache": "^4.2.0","p-queue": "^6.6.2","p-retry": "4",@@ -10574,25 +10369,130 @@"node": ">=18"}},+ "node_modules/@librechat/agents/node_modules/@langchain/google-vertexai/node_modules/@langchain/core": {+ "version": "0.2.36",+ "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.2.36.tgz",+ "integrity": "sha512-qHLvScqERDeH7y2cLuJaSAlMwg3f/3Oc9nayRSXRU2UuaK/SOhI42cxiPLj1FnuHJSmN0rBQFkrLx02gI4mcVg==",+ "dependencies": {+ "ansi-styles": "^5.0.0",+ "camelcase": "6",+ "decamelize": "1.2.0",+ "js-tiktoken": "^1.0.12",+ "langsmith": "^0.1.56-rc.1",+ "mustache": "^4.2.0",+ "p-queue": "^6.6.2",+ "p-retry": "4",+ "uuid": "^10.0.0",+ "zod": "^3.22.4",+ "zod-to-json-schema": "^3.22.3"+ },+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@librechat/agents/node_modules/@langchain/google-vertexai/node_modules/langsmith": {+ "version": "0.1.68",+ "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.68.tgz",+ "integrity": "sha512-otmiysWtVAqzMx3CJ4PrtUBhWRG5Co8Z4o7hSZENPjlit9/j3/vm3TSvbaxpDYakZxtMjhkcJTqrdYFipISEiQ==",+ "dependencies": {+ "@types/uuid": "^10.0.0",+ "commander": "^10.0.1",+ "p-queue": "^6.6.2",+ "p-retry": "4",+ "semver": "^7.6.3",+ "uuid": "^10.0.0"+ },+ "peerDependencies": {+ "openai": "*"+ },+ "peerDependenciesMeta": {+ "openai": {+ "optional": true+ }+ }+ },+ "node_modules/@librechat/agents/node_modules/@langchain/langgraph": {+ "version": "0.2.19",+ "resolved": "https://registry.npmjs.org/@langchain/langgraph/-/langgraph-0.2.19.tgz",+ "integrity": "sha512-dgFdnEokC5zY32skZ6rcBYJNTH3WQXVY0LRI1zBGvbmK/nPfanIB1URwNxqRFjj/qHRKofxoehqYr1ww1zB+zA==",+ "dependencies": {+ "@langchain/langgraph-checkpoint": "~0.0.10",+ "@langchain/langgraph-sdk": "~0.0.20",+ "double-ended-queue": "^2.1.0-0",+ "uuid": "^10.0.0",+ "zod": "^3.23.8"+ },+ "engines": {+ "node": ">=18"+ },+ "peerDependencies": {+ "@langchain/core": ">=0.2.36 <0.3.0 || >=0.3.9 < 0.4.0"+ }+ },+ "node_modules/@librechat/agents/node_modules/@langchain/langgraph-checkpoint": {+ "version": "0.0.11",+ "resolved": "https://registry.npmjs.org/@langchain/langgraph-checkpoint/-/langgraph-checkpoint-0.0.11.tgz",+ "integrity": "sha512-nroHHkAi/UPn9LqqZcgOydfB8qZw5TXuXDFc43MIydnW4lb8m9hVHnQ3lgb2WGSgtbZJnsIx0TzL19oemJBRKg==",+ "dependencies": {+ "uuid": "^10.0.0"+ },+ "engines": {+ "node": ">=18"+ },+ "peerDependencies": {+ "@langchain/core": ">=0.2.31 <0.4.0"+ }+ },+ "node_modules/@librechat/agents/node_modules/@langchain/ollama": {+ "version": "0.1.1",+ "resolved": "https://registry.npmjs.org/@langchain/ollama/-/ollama-0.1.1.tgz",+ "integrity": "sha512-IQEdzGkfKzdoyys3GW5hCXc64d/u1xkrYXved73BLO+bnyQfzrM224jdsiYGUpjW3cUaO1ebD6PUiMYcANPPFQ==",+ "dependencies": {+ "ollama": "^0.5.9",+ "uuid": "^10.0.0"+ },+ "engines": {+ "node": ">=18"+ },+ "peerDependencies": {+ "@langchain/core": ">=0.2.21 <0.4.0"+ }+ },"node_modules/@librechat/agents/node_modules/@langchain/openai": {- "version": "0.2.11",- "resolved": "https://registry.npmjs.org/@langchain/openai/-/openai-0.2.11.tgz",- "integrity": "sha512-Pu8+WfJojCgSf0bAsXb4AjqvcDyAWyoEB1AoCRNACgEnBWZuitz3hLwCo9I+6hAbeg3QJ37g82yKcmvKAg1feg==",+ "version": "0.3.11",+ "resolved": "https://registry.npmjs.org/@langchain/openai/-/openai-0.3.11.tgz",+ "integrity": "sha512-mEFbpJ8w8NPArsquUlCwxvZTKNkXxqwzvTEYzv6Jb7gUoBDOZtwLg6AdcngTJ+w5VFh3wxgPy0g3zb9Aw0Qbpw==","dependencies": {- "@langchain/core": ">=0.2.26 <0.3.0","js-tiktoken": "^1.0.12",- "openai": "^4.57.3",+ "openai": "^4.68.0","zod": "^3.22.4","zod-to-json-schema": "^3.22.3"},"engines": {"node": ">=18"+ },+ "peerDependencies": {+ "@langchain/core": ">=0.2.26 <0.4.0"+ }+ },+ "node_modules/@librechat/agents/node_modules/@langchain/textsplitters": {+ "version": "0.1.0",+ "resolved": "https://registry.npmjs.org/@langchain/textsplitters/-/textsplitters-0.1.0.tgz",+ "integrity": "sha512-djI4uw9rlkAb5iMhtLED+xJebDdAG935AdP4eRTB02R7OB/act55Bj9wsskhZsvuyQRpO4O1wQOp85s6T6GWmw==",+ "dependencies": {+ "js-tiktoken": "^1.0.12"+ },+ "engines": {+ "node": ">=18"+ },+ "peerDependencies": {+ "@langchain/core": ">=0.2.21 <0.4.0"}},"node_modules/@librechat/agents/node_modules/@types/node": {- "version": "18.19.53",- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.53.tgz",- "integrity": "sha512-GLxgUgHhDKO1Edw9Q0lvMbiO/IQXJwJlMaqxSGBXMpPy8uhkCs2iiPFaB2Q/gmobnFkckD3rqTBMVjXdwq+nKg==",+ "version": "18.19.63",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.63.tgz",+ "integrity": "sha512-hcUB7THvrGmaEcPcvUZCZtQ2Z3C+UR/aOcraBLCvTsFMh916Gc1kCCYcfcMuB76HM2pSerxl1PoP3KnmHzd9Lw==","dependencies": {"undici-types": "~5.26.4"}@@ -10625,269 +10525,10 @@"node-addon-api": "^8.0.0"}},- "node_modules/@librechat/agents/node_modules/langchain": {- "version": "0.2.20",- "resolved": "https://registry.npmjs.org/langchain/-/langchain-0.2.20.tgz",- "integrity": "sha512-tbels6Rr524iMM3VOQ4aTGnEOOjAA1BQuBR8u/8gJ2yT48lMtIQRAN32Y4KVjKK+hEWxHHlmLBrtgLpTphFjNA==",- "dependencies": {- "@langchain/core": ">=0.2.21 <0.3.0",- "@langchain/openai": ">=0.1.0 <0.3.0",- "@langchain/textsplitters": "~0.0.0",- "binary-extensions": "^2.2.0",- "js-tiktoken": "^1.0.12",- "js-yaml": "^4.1.0",- "jsonpointer": "^5.0.1",- "langsmith": "^0.1.56-rc.1",- "openapi-types": "^12.1.3",- "p-retry": "4",- "uuid": "^10.0.0",- "yaml": "^2.2.1",- "zod": "^3.22.4",- "zod-to-json-schema": "^3.22.3"- },- "engines": {- "node": ">=18"- },- "peerDependencies": {- "@aws-sdk/client-s3": "*",- "@aws-sdk/client-sagemaker-runtime": "*",- "@aws-sdk/client-sfn": "*",- "@aws-sdk/credential-provider-node": "*",- "@azure/storage-blob": "*",- "@browserbasehq/sdk": "*",- "@gomomento/sdk": "*",- "@gomomento/sdk-core": "*",- "@gomomento/sdk-web": "^1.51.1",- "@langchain/anthropic": "*",- "@langchain/aws": "*",- "@langchain/cohere": "*",- "@langchain/google-genai": "*",- "@langchain/google-vertexai": "*",- "@langchain/groq": "*",- "@langchain/mistralai": "*",- "@langchain/ollama": "*",- "@mendable/firecrawl-js": "*",- "@notionhq/client": "*",- "@pinecone-database/pinecone": "*",- "@supabase/supabase-js": "*",- "@vercel/kv": "*",- "@xata.io/client": "*",- "apify-client": "*",- "assemblyai": "*",- "axios": "*",- "cheerio": "*",- "chromadb": "*",- "convex": "*",- "couchbase": "*",- "d3-dsv": "*",- "epub2": "*",- "fast-xml-parser": "*",- "handlebars": "^4.7.8",- "html-to-text": "*",- "ignore": "*",- "ioredis": "*",- "jsdom": "*",- "mammoth": "*",- "mongodb": "*",- "node-llama-cpp": "*",- "notion-to-md": "*",- "officeparser": "*",- "pdf-parse": "*",- "peggy": "^3.0.2",- "playwright": "*",- "puppeteer": "*",- "pyodide": ">=0.24.1 <0.27.0",- "redis": "*",- "sonix-speech-recognition": "*",- "srt-parser-2": "*",- "typeorm": "*",- "weaviate-ts-client": "*",- "web-auth-library": "*",- "ws": "*",- "youtube-transcript": "*",- "youtubei.js": "*"- },- "peerDependenciesMeta": {- "@aws-sdk/client-s3": {- "optional": true- },- "@aws-sdk/client-sagemaker-runtime": {- "optional": true- },- "@aws-sdk/client-sfn": {- "optional": true- },- "@aws-sdk/credential-provider-node": {- "optional": true- },- "@azure/storage-blob": {- "optional": true- },- "@browserbasehq/sdk": {- "optional": true- },- "@gomomento/sdk": {- "optional": true- },- "@gomomento/sdk-core": {- "optional": true- },- "@gomomento/sdk-web": {- "optional": true- },- "@langchain/anthropic": {- "optional": true- },- "@langchain/aws": {- "optional": true- },- "@langchain/cohere": {- "optional": true- },- "@langchain/google-genai": {- "optional": true- },- "@langchain/google-vertexai": {- "optional": true- },- "@langchain/groq": {- "optional": true- },- "@langchain/mistralai": {- "optional": true- },- "@langchain/ollama": {- "optional": true- },- "@mendable/firecrawl-js": {- "optional": true- },- "@notionhq/client": {- "optional": true- },- "@pinecone-database/pinecone": {- "optional": true- },- "@supabase/supabase-js": {- "optional": true- },- "@vercel/kv": {- "optional": true- },- "@xata.io/client": {- "optional": true- },- "apify-client": {- "optional": true- },- "assemblyai": {- "optional": true- },- "axios": {- "optional": true- },- "cheerio": {- "optional": true- },- "chromadb": {- "optional": true- },- "convex": {- "optional": true- },- "couchbase": {- "optional": true- },- "d3-dsv": {- "optional": true- },- "epub2": {- "optional": true- },- "faiss-node": {- "optional": true- },- "fast-xml-parser": {- "optional": true- },- "handlebars": {- "optional": true- },- "html-to-text": {- "optional": true- },- "ignore": {- "optional": true- },- "ioredis": {- "optional": true- },- "jsdom": {- "optional": true- },- "mammoth": {- "optional": true- },- "mongodb": {- "optional": true- },- "node-llama-cpp": {- "optional": true- },- "notion-to-md": {- "optional": true- },- "officeparser": {- "optional": true- },- "pdf-parse": {- "optional": true- },- "peggy": {- "optional": true- },- "playwright": {- "optional": true- },- "puppeteer": {- "optional": true- },- "pyodide": {- "optional": true- },- "redis": {- "optional": true- },- "sonix-speech-recognition": {- "optional": true- },- "srt-parser-2": {- "optional": true- },- "typeorm": {- "optional": true- },- "weaviate-ts-client": {- "optional": true- },- "web-auth-library": {- "optional": true- },- "ws": {- "optional": true- },- "youtube-transcript": {- "optional": true- },- "youtubei.js": {- "optional": true- }- }- },"node_modules/@librechat/agents/node_modules/langsmith": {- "version": "0.1.61",- "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.1.61.tgz",- "integrity": "sha512-XQE4KPScwPmdaT0mWDzhNxj9gvqXUR+C7urLA0QFi27XeoQdm17eYpudenn4wxC0gIyUJutQCyuYJpfwlT5JnQ==",+ "version": "0.2.3",+ "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.2.3.tgz",+ "integrity": "sha512-SPMYPVqR9kwXZVmJ2PXC61HeBnXIFHrjfjDxQ14H0+n5p4gqjLzgSHIQyxBlFeWQUQzArJxe65Ap+s+Xo1cZog==","dependencies": {"@types/uuid": "^10.0.0","commander": "^10.0.1",@@ -10906,9 +10547,9 @@}},"node_modules/@librechat/agents/node_modules/node-addon-api": {- "version": "8.1.0",- "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.1.0.tgz",- "integrity": "sha512-yBY+qqWSv3dWKGODD6OGE6GnTX7Q2r+4+DfpqxHSHh8x0B4EKP9+wVGLS6U/AM1vxSNNmUEuIV5EGhYwPpfOwQ==",+ "version": "8.2.1",+ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.2.1.tgz",+ "integrity": "sha512-vmEOvxwiH8tlOcv4SyE8RH34rI5/nWVaigUeAUPawC6f0+HoDthwI0vkMu4tbtsZrXq6QXFfrkhjofzKEs5tpA==","optional": true,"peer": true,"engines": {@@ -10916,9 +10557,9 @@}},"node_modules/@librechat/agents/node_modules/openai": {- "version": "4.65.0",- "resolved": "https://registry.npmjs.org/openai/-/openai-4.65.0.tgz",- "integrity": "sha512-LfA4KUBpH/8rA3vjCQ74LZtdK/8wx9W6Qxq8MHqEdImPsN1XPQ2ompIuJWkKS6kXt5Cs5i8Eb65IIo4M7U+yeQ==",+ "version": "4.70.2",+ "resolved": "https://registry.npmjs.org/openai/-/openai-4.70.2.tgz",+ "integrity": "sha512-Q2ymi/KPUYv+LJ9rFxeYxpkVAhcrZFTVvnJbdF1pUHg9eMC6lY8PU4TO1XOK5UZzOZuuVicouRwVMi1iDrT4qw==","dependencies": {"@types/node": "^18.11.18","@types/node-fetch": "^2.6.4",@@ -15353,8 +14994,7 @@"node_modules/@types/tough-cookie": {"version": "4.0.5","resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz",- "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==",- "dev": true+ "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA=="},"node_modules/@types/triple-beam": {"version": "1.3.5",@@ -19044,6 +18684,11 @@"url": "https://dotenvx.com"}},+ "node_modules/double-ended-queue": {+ "version": "2.1.0-0",+ "resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz",+ "integrity": "sha512-+BNfZ+deCo8hMNpDqDnvT+c0XpJ5cUa6mqYq89bho2Ifze4URTqRkcwR399hWoTrTkbZ/XJYDgP6rc7pRgffEQ=="+ },"node_modules/downloadjs": {"version": "1.4.7","resolved": "https://registry.npmjs.org/downloadjs/-/downloadjs-1.4.7.tgz",@@ -22099,6 +21744,113 @@"url": "https://github.com/sponsors/typicode"}},+ "node_modules/ibm-cloud-sdk-core": {+ "version": "5.1.0",+ "resolved": "https://registry.npmjs.org/ibm-cloud-sdk-core/-/ibm-cloud-sdk-core-5.1.0.tgz",+ "integrity": "sha512-KJCbPz3tiXB1NGAD7cL4JtwpWV8yd/C7jsaHsxvedMo2ZblNG8emMyvSpGhiKAQVZmi3c0ujz6eJdy22NHuUWQ==",+ "peer": true,+ "dependencies": {+ "@types/debug": "^4.1.12",+ "@types/node": "~10.14.19",+ "@types/tough-cookie": "^4.0.0",+ "axios": "1.7.4",+ "camelcase": "^6.3.0",+ "debug": "^4.3.4",+ "dotenv": "^16.4.5",+ "extend": "3.0.2",+ "file-type": "16.5.4",+ "form-data": "4.0.0",+ "isstream": "0.1.2",+ "jsonwebtoken": "^9.0.2",+ "mime-types": "2.1.35",+ "retry-axios": "^2.6.0",+ "tough-cookie": "^4.1.3"+ },+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/ibm-cloud-sdk-core/node_modules/@types/node": {+ "version": "10.14.22",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.22.tgz",+ "integrity": "sha512-9taxKC944BqoTVjE+UT3pQH0nHZlTvITwfsOZqyc+R3sfJuxaTtxWjfn1K2UlxyPcKHf0rnaXcVFrS9F9vf0bw==",+ "peer": true+ },+ "node_modules/ibm-cloud-sdk-core/node_modules/axios": {+ "version": "1.7.4",+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz",+ "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==",+ "peer": true,+ "dependencies": {+ "follow-redirects": "^1.15.6",+ "form-data": "^4.0.0",+ "proxy-from-env": "^1.1.0"+ }+ },+ "node_modules/ibm-cloud-sdk-core/node_modules/file-type": {+ "version": "16.5.4",+ "resolved": "https://registry.npmjs.org/file-type/-/file-type-16.5.4.tgz",+ "integrity": "sha512-/yFHK0aGjFEgDJjEKP0pWCplsPFPhwyfwevf/pVxiN0tmE4L9LmwWxWukdJSHdoCli4VgQLehjJtwQBnqmsKcw==",+ "peer": true,+ "dependencies": {+ "readable-web-to-node-stream": "^3.0.0",+ "strtok3": "^6.2.4",+ "token-types": "^4.1.1"+ },+ "engines": {+ "node": ">=10"+ },+ "funding": {+ "url": "https://github.com/sindresorhus/file-type?sponsor=1"+ }+ },+ "node_modules/ibm-cloud-sdk-core/node_modules/peek-readable": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-4.1.0.tgz",+ "integrity": "sha512-ZI3LnwUv5nOGbQzD9c2iDG6toheuXSZP5esSHBjopsXH4dg19soufvpUGA3uohi5anFtGb2lhAVdHzH6R/Evvg==",+ "peer": true,+ "engines": {+ "node": ">=8"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Borewit"+ }+ },+ "node_modules/ibm-cloud-sdk-core/node_modules/strtok3": {+ "version": "6.3.0",+ "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-6.3.0.tgz",+ "integrity": "sha512-fZtbhtvI9I48xDSywd/somNqgUHl2L2cstmXCCif0itOf96jeW18MBSyrLuNicYQVkvpOxkZtkzujiTJ9LW5Jw==",+ "peer": true,+ "dependencies": {+ "@tokenizer/token": "^0.3.0",+ "peek-readable": "^4.1.0"+ },+ "engines": {+ "node": ">=10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Borewit"+ }+ },+ "node_modules/ibm-cloud-sdk-core/node_modules/token-types": {+ "version": "4.2.1",+ "resolved": "https://registry.npmjs.org/token-types/-/token-types-4.2.1.tgz",+ "integrity": "sha512-6udB24Q737UD/SDsKAHI9FCRP7Bqc9D/MQUV02ORQg5iskjtLJlZJNdN4kKtcdtwCeWIwIHDGaUsTsCCAa8sFQ==",+ "peer": true,+ "dependencies": {+ "@tokenizer/token": "^0.3.0",+ "ieee754": "^1.2.1"+ },+ "engines": {+ "node": ">=10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Borewit"+ }+ },"node_modules/iconv-lite": {"version": "0.4.24","resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",@@ -23239,6 +22991,12 @@"ws": "*"}},+ "node_modules/isstream": {+ "version": "0.1.2",+ "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",+ "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==",+ "peer": true+ },"node_modules/istanbul-lib-coverage": {"version": "3.2.2","resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz",@@ -28244,9 +28002,9 @@}},"node_modules/ollama": {- "version": "0.5.0",- "resolved": "https://registry.npmjs.org/ollama/-/ollama-0.5.0.tgz",- "integrity": "sha512-CRtRzsho210EGdK52GrUMohA2pU+7NbgEaBG3DcYeRmvQthDO7E2LHOkLlUUeaYUlNmEd8icbjC02ug9meSYnw==",+ "version": "0.5.9",+ "resolved": "https://registry.npmjs.org/ollama/-/ollama-0.5.9.tgz",+ "integrity": "sha512-F/KZuDRC+ZsVCuMvcOYuQ6zj42/idzCkkuknGyyGVmNStMZ/sU3jQpvhnl4SyC0+zBzLiKNZJnJeuPFuieWZvQ==","dependencies": {"whatwg-fetch": "^3.6.20"}@@ -30625,8 +30383,7 @@"node_modules/psl": {"version": "1.9.0","resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",- "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==",- "devOptional": true+ "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag=="},"node_modules/pstree.remy": {"version": "1.1.8",@@ -30711,8 +30468,7 @@"node_modules/querystringify": {"version": "2.2.0","resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",- "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==",- "devOptional": true+ "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="},"node_modules/queue-microtask": {"version": "1.2.3",@@ -32183,8 +31939,7 @@"node_modules/requires-port": {"version": "1.0.0","resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",- "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",- "devOptional": true+ "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="},"node_modules/resolve": {"version": "1.22.8",@@ -32281,6 +32036,18 @@"node": ">= 4"}},+ "node_modules/retry-axios": {+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/retry-axios/-/retry-axios-2.6.0.tgz",+ "integrity": "sha512-pOLi+Gdll3JekwuFjXO3fTq+L9lzMQGcSq7M5gIjExcl3Gu1hd4XXuf5o3+LuSBsaULQH7DiNbsqPd1chVpQGQ==",+ "peer": true,+ "engines": {+ "node": ">=10.7.0"+ },+ "peerDependencies": {+ "axios": "*"+ }+ },"node_modules/reusify": {"version": "1.0.4","resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",@@ -34217,7 +33984,6 @@"version": "4.1.3","resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz","integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==",- "devOptional": true,"dependencies": {"psl": "^1.1.33","punycode": "^2.1.1",@@ -34232,7 +33998,6 @@"version": "0.2.0","resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz","integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",- "devOptional": true,"engines": {"node": ">= 4.0.0"}@@ -34915,7 +34680,6 @@"version": "1.5.10","resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz","integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",- "devOptional": true,"dependencies": {"querystringify": "^2.1.1","requires-port": "^1.0.0"diff --git a/packages/data-provider/src/api-endpoints.ts b/packages/data-provider/src/api-endpoints.tsindex ce9b77d4ac..a33b368a1b 100644--- a/packages/data-provider/src/api-endpoints.ts+++ b/packages/data-provider/src/api-endpoints.ts@@ -125,10 +125,10 @@ export const assistants = ({return url;};-export const agents = ({ path, options }: { path?: string; options?: object }) => {+export const agents = ({ path = '', options }: { path?: string; options?: object }) => {let url = '/api/agents';- if (path) {+ if (path && path !== '') {url += `/${path}`;}diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.tsindex bcaa739652..81ff5eca41 100644--- a/packages/data-provider/src/config.ts+++ b/packages/data-provider/src/config.ts@@ -584,6 +584,7 @@ export const alternateName = {[EModelEndpoint.anthropic]: 'Anthropic',[EModelEndpoint.custom]: 'Custom',[EModelEndpoint.bedrock]: 'AWS Bedrock',+ ollama: 'Ollama',};const sharedOpenAIModels = [diff --git a/packages/data-provider/src/data-service.ts b/packages/data-provider/src/data-service.tsindex 0df22f6236..ccce126a81 100644--- a/packages/data-provider/src/data-service.ts+++ b/packages/data-provider/src/data-service.ts@@ -304,6 +304,16 @@ export const getAvailableTools = (return request.get(path);};+export const getVerifyAgentToolAuth = (+ params: q.VerifyToolAuthParams,+): Promise<q.VerifyToolAuthResponse> => {+ return request.get(+ endpoints.agents({+ path: `tools/${params.toolId}/auth`,+ }),+ );+};+/* Files */export const getFiles = (): Promise<f.TFile[]> => {diff --git a/packages/data-provider/src/keys.ts b/packages/data-provider/src/keys.tsindex a4ed0b121c..b977853974 100644--- a/packages/data-provider/src/keys.ts+++ b/packages/data-provider/src/keys.ts@@ -25,6 +25,7 @@ export enum QueryKeys {files = 'files',fileConfig = 'fileConfig',tools = 'tools',+ toolAuth = 'toolAuth',agentTools = 'agentTools',actions = 'actions',assistantDocs = 'assistantDocs',diff --git a/packages/data-provider/src/react-query/react-query-service.ts b/packages/data-provider/src/react-query/react-query-service.tsindex 997751358a..0394addf5e 100644--- a/packages/data-provider/src/react-query/react-query-service.ts+++ b/packages/data-provider/src/react-query/react-query-service.ts@@ -408,16 +408,16 @@ export const useAvailablePluginsQuery = <TData = s.TPlugin[]>();};-export const useUpdateUserPluginsMutation = (): UseMutationResult<- t.TUser,- unknown,- t.TUpdateUserPlugins,- unknown-> => {+export const useUpdateUserPluginsMutation = (+ _options?: m.UpdatePluginAuthOptions,+): UseMutationResult<t.TUser, unknown, t.TUpdateUserPlugins, unknown> => {const queryClient = useQueryClient();+ const { onSuccess, ...options } = _options ?? {};return useMutation((payload: t.TUpdateUserPlugins) => dataService.updateUserPlugins(payload), {- onSuccess: () => {+ ...options,+ onSuccess: (...args) => {queryClient.invalidateQueries([QueryKeys.user]);+ onSuccess?.(...args);},});};diff --git a/packages/data-provider/src/schemas.ts b/packages/data-provider/src/schemas.tsindex 4438dd32a2..cef29a8cc6 100644--- a/packages/data-provider/src/schemas.ts+++ b/packages/data-provider/src/schemas.ts@@ -8,7 +8,7 @@ export const isUUID = z.string().uuid();export enum AuthType {OVERRIDE_AUTH = 'override_auth',USER_PROVIDED = 'user_provided',- SYSTEM_DEFINED = 'SYSTEM_DEFINED',+ SYSTEM_DEFINED = 'system_defined',}export const authTypeSchema = z.nativeEnum(AuthType);@@ -369,7 +369,7 @@ export const tPluginSchema = z.object({pluginKey: z.string(),description: z.string(),icon: z.string(),- authConfig: z.array(tPluginAuthConfigSchema),+ authConfig: z.array(tPluginAuthConfigSchema).optional(),authenticated: z.boolean().optional(),isButton: z.boolean().optional(),});diff --git a/packages/data-provider/src/types.ts b/packages/data-provider/src/types.tsindex a125a2c993..031a85f8c8 100644--- a/packages/data-provider/src/types.ts+++ b/packages/data-provider/src/types.ts@@ -72,14 +72,13 @@ export type TPluginAction = {pluginKey: string;action: 'install' | 'uninstall';auth?: unknown;- isAssistantTool?: boolean;+ isEntityTool?: boolean;};export type GroupedConversations = [key: string, TConversation[]][];export type TUpdateUserPlugins = {- isAssistantTool?: boolean;- isAgentTool?: boolean;+ isEntityTool?: boolean;pluginKey: string;action: string;auth?: unknown;diff --git a/packages/data-provider/src/types/files.ts b/packages/data-provider/src/types/files.tsindex 49ae79a313..5985096f4c 100644--- a/packages/data-provider/src/types/files.ts+++ b/packages/data-provider/src/types/files.ts@@ -69,6 +69,7 @@ export type TFile = {height?: number;expiresAt?: string | Date;preview?: string;+ metadata?: { fileIdentifier?: string };createdAt?: string | Date;updatedAt?: string | Date;};diff --git a/packages/data-provider/src/types/mutations.ts b/packages/data-provider/src/types/mutations.tsindex b9f8f2c385..8d4aed2501 100644--- a/packages/data-provider/src/types/mutations.ts+++ b/packages/data-provider/src/types/mutations.ts@@ -248,3 +248,6 @@ export type AcceptTermsMutationOptions = MutationOptions<unknown,void>;++/* Tools */+export type UpdatePluginAuthOptions = MutationOptions<types.TUser, types.TUpdateUserPlugins>;diff --git a/packages/data-provider/src/types/queries.ts b/packages/data-provider/src/types/queries.tsindex 13fb6a577a..7aeaa6eb20 100644--- a/packages/data-provider/src/types/queries.ts+++ b/packages/data-provider/src/types/queries.ts@@ -1,13 +1,13 @@import type { InfiniteData } from '@tanstack/react-query';+import type * as s from '../schemas';import type * as t from '../types';-import type { TMessage, TConversation, TSharedLink, TConversationTag } from '../schemas';export type Conversation = {id: string;createdAt: number;participants: string[];lastMessage: string;- conversations: TConversation[];+ conversations: s.TConversation[];};// Parameters for listing conversations (e.g., for pagination)@@ -24,33 +24,33 @@ export type ConversationListParams = {// Type for the response from the conversation list APIexport type ConversationListResponse = {- conversations: TConversation[];+ conversations: s.TConversation[];pageNumber: string;pageSize: string | number;pages: string | number;- messages: TMessage[];+ messages: s.TMessage[];};export type ConversationData = InfiniteData<ConversationListResponse>;export type ConversationUpdater = (data: ConversationData,- conversation: TConversation,+ conversation: s.TConversation,) => ConversationData;-export type SharedMessagesResponse = Omit<TSharedLink, 'messages'> & {- messages: TMessage[];+export type SharedMessagesResponse = Omit<s.TSharedLink, 'messages'> & {+ messages: s.TMessage[];};export type SharedLinkListParams = Omit<ConversationListParams, 'isArchived' | 'conversationId'> & {isPublic?: boolean;};export type SharedLinksResponse = Omit<ConversationListResponse, 'conversations' | 'messages'> & {- sharedLinks: TSharedLink[];+ sharedLinks: s.TSharedLink[];};// Type for the response from the conversation list APIexport type SharedLinkListResponse = {- sharedLinks: TSharedLink[];+ sharedLinks: s.TSharedLink[];pageNumber: string;pageSize: string | number;pages: string | number;@@ -71,4 +71,7 @@ export type AllPromptGroupsFilterRequest = {export type AllPromptGroupsResponse = t.TPromptGroup[];-export type ConversationTagsResponse = TConversationTag[];+export type ConversationTagsResponse = s.TConversationTag[];++export type VerifyToolAuthParams = { toolId: string };+export type VerifyToolAuthResponse = { authenticated: boolean; message?: string | s.AuthType };