Skip to content

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

⬆️ feat: Migrate to Zod v4 (#17442)

Danny Avilaaa8e5849e082
diff --git a/api/package.json b/api/package.json
index 7bec41c747..0fa1f81f39 100644
--- a/api/package.json
+++ b/api/package.json
@@ -40,7 +40,7 @@
"@azure/storage-blob": "^12.30.0",
"@google/genai": "^2.8.0",
"@keyv/redis": "5.1.6",
- "@librechat/agents": "^4.1.0",
+ "@librechat/agents": "^4.1.1",
"@librechat/api": "*",
"@librechat/data-schemas": "*",
"@microsoft/microsoft-graph-client": "^3.0.7",
@@ -105,7 +105,7 @@
"nanoid": "^3.3.18",
"node-fetch": "^2.7.0",
"nodemailer": "^10.2.1",
- "openai": "5.8.2",
+ "openai": "^6.49.0",
"openid-client": "^6.5.0",
"passport": "^0.6.0",
"passport-apple": "^2.0.2",
@@ -129,7 +129,8 @@
"winston-daily-rotate-file": "^5.0.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"yauzl": "^3.2.1",
- "zod": "^3.22.4"
+ "zod": "^4.6.7",
+ "zod-to-json-schema": "^3.25.1"
},
"devDependencies": {
"@babel/preset-env": "^7.29.5",
diff --git a/api/server/controllers/agents/v1.js b/api/server/controllers/agents/v1.js
index 5d49b6bca3..828aa2b6e0 100644
--- a/api/server/controllers/agents/v1.js
+++ b/api/server/controllers/agents/v1.js
@@ -901,8 +901,8 @@ const createAgentHandler = async (req, res) => {
res.status(201).json(agent);
} catch (error) {
if (error instanceof z.ZodError) {
- logger.error('[/Agents] Validation error', error.errors);
- return res.status(400).json({ error: 'Invalid request data', details: error.errors });
+ logger.error('[/Agents] Validation error', error.issues);
+ return res.status(400).json({ error: 'Invalid request data', details: error.issues });
}
logger.error('[/Agents] Error creating agent', error);
if (error?.statusCode === 409) {
@@ -1403,8 +1403,8 @@ const updateAgentHandler = async (req, res) => {
return res.json(presentedAgent);
} catch (error) {
if (error instanceof z.ZodError) {
- logger.error('[/Agents/:id] Validation error', error.errors);
- return res.status(400).json({ error: 'Invalid request data', details: error.errors });
+ logger.error('[/Agents/:id] Validation error', error.issues);
+ return res.status(400).json({ error: 'Invalid request data', details: error.issues });
}
logger.error('[/Agents/:id] Error updating Agent', error);
diff --git a/api/server/controllers/mcp.js b/api/server/controllers/mcp.js
index eed65ffc38..cd51ee80e8 100644
--- a/api/server/controllers/mcp.js
+++ b/api/server/controllers/mcp.js
@@ -439,7 +439,7 @@ const createMCPServerController = async (req, res) => {
if (!validation.success) {
return res.status(400).json({
message: 'Invalid configuration',
- errors: validation.error.errors,
+ errors: validation.error.issues,
});
}
if (validation.data.iconPath) {
@@ -545,7 +545,7 @@ const updateMCPServerController = async (req, res) => {
if (!validation.success) {
return res.status(400).json({
message: 'Invalid configuration',
- errors: validation.error.errors,
+ errors: validation.error.issues,
});
}
if (validation.data.iconPath) {
diff --git a/api/server/services/AuthService.js b/api/server/services/AuthService.js
index 17b024930a..7beb540918 100644
--- a/api/server/services/AuthService.js
+++ b/api/server/services/AuthService.js
@@ -393,7 +393,7 @@ const verifyEmail = async (req) => {
const registerUser = async (user, additionalData = {}) => {
const result = registerSchema.safeParse(user);
if (!result.success) {
- const errorMessage = errorsToString(result.error.errors);
+ const errorMessage = errorsToString(result.error.issues);
logger.info('Route: register - Validation Error', {
name: 'Validation error:',
value: errorMessage,
diff --git a/api/server/services/start/tools.js b/api/server/services/start/tools.js
index 461b380745..eff9103673 100644
--- a/api/server/services/start/tools.js
+++ b/api/server/services/start/tools.js
@@ -2,7 +2,6 @@ const fs = require('fs');
const path = require('path');
const { Calculator } = require('@librechat/agents');
const { logger } = require('@librechat/data-schemas');
-const { zodToJsonSchema } = require('zod-to-json-schema');
const { Tool } = require('@librechat/agents/langchain/tools');
const { Tools, ImageVisionTool } = require('librechat-data-provider');
const {
@@ -12,6 +11,7 @@ const {
oaiToolkit,
geminiToolkit,
createAskUserQuestionTool,
+ toToolParameters,
} = require('@librechat/api');
const { toolkits } = require('~/app/clients/tools/manifest');
@@ -115,27 +115,16 @@ function loadAndFormatTools({ directory, adminFilter = [], adminIncluded = [] })
}, {});
}
-/**
- * Checks if a schema is a Zod schema by looking for the _def property
- * @param {unknown} schema - The schema to check
- * @returns {boolean} True if it's a Zod schema
- */
-function isZodSchema(schema) {
- return schema && typeof schema === 'object' && '_def' in schema;
-}
-
/**
* Formats a `StructuredTool` instance into a format that is compatible
- * with OpenAI's ChatCompletionFunctions. It uses the `zodToJsonSchema`
- * function to convert the schema of the `StructuredTool` into a JSON
- * schema, which is then used as the parameters for the OpenAI function.
- * If the schema is already a JSON schema, it is used directly.
+ * with OpenAI's ChatCompletionFunctions, converting the schema of the
+ * `StructuredTool` into the JSON schema used as the function parameters.
*
* @param {StructuredTool} tool - The StructuredTool to format.
* @returns {FunctionTool} The OpenAI Assistant Tool.
*/
function formatToOpenAIAssistantTool(tool) {
- const parameters = isZodSchema(tool.schema) ? zodToJsonSchema(tool.schema) : tool.schema;
+ const parameters = toToolParameters(tool.schema);
return {
type: Tools.function,
[Tools.function]: {
diff --git a/api/strategies/localStrategy.js b/api/strategies/localStrategy.js
index bb8b39fc40..b066c5e3c5 100644
--- a/api/strategies/localStrategy.js
+++ b/api/strategies/localStrategy.js
@@ -12,7 +12,7 @@ const { loginSchema } = require('./validators');
async function validateLoginRequest(req) {
const { error } = loginSchema.safeParse(req.body);
- return error ? errorsToString(error.errors) : null;
+ return error ? errorsToString(error.issues) : null;
}
async function passportLogin(req, email, password, done) {
diff --git a/api/strategies/validators.spec.js b/api/strategies/validators.spec.js
index b15cf05c69..ab064c50a0 100644
--- a/api/strategies/validators.spec.js
+++ b/api/strategies/validators.spec.js
@@ -449,8 +449,8 @@ describe('Zod Schemas', () => {
confirm_password: 'password123',
});
- const result = errorsToString(error.errors);
- expect(result).toBe('name: String must contain at least 3 character(s)');
+ const result = errorsToString(error.issues);
+ expect(result).toBe('name: Too small: expected string to have >=3 characters');
});
});
diff --git a/bun.lock b/bun.lock
index 1388ff845c..71ab3bfc3f 100644
--- a/bun.lock
+++ b/bun.lock
@@ -55,7 +55,7 @@
"@azure/storage-blob": "^12.30.0",
"@google/genai": "^2.8.0",
"@keyv/redis": "5.1.6",
- "@librechat/agents": "^4.1.0",
+ "@librechat/agents": "^4.1.1",
"@librechat/api": "*",
"@librechat/data-schemas": "*",
"@microsoft/microsoft-graph-client": "^3.0.7",
@@ -120,7 +120,7 @@
"nanoid": "^3.3.18",
"node-fetch": "^2.7.0",
"nodemailer": "^10.2.1",
- "openai": "5.8.2",
+ "openai": "^6.49.0",
"openid-client": "^6.5.0",
"passport": "^0.6.0",
"passport-apple": "^2.0.2",
@@ -144,7 +144,8 @@
"winston-daily-rotate-file": "^5.0.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"yauzl": "^3.2.1",
- "zod": "^3.22.4",
+ "zod": "^4.6.7",
+ "zod-to-json-schema": "^3.25.1",
},
"devDependencies": {
"@babel/preset-env": "^7.29.5",
@@ -269,7 +270,7 @@
"tailwindcss-animate": "^1.0.5",
"ts-md5": "^1.3.1",
"web-vitals": "^3.5.2",
- "zod": "^3.22.4",
+ "zod": "^4.6.7",
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.22.15",
@@ -364,7 +365,7 @@
"winston": "^3.17.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"yauzl": "^3.2.1",
- "zod-openapi": "^4.2.4",
+ "zod-openapi": "^6.0.2",
},
"peerDependencies": {
"@anthropic-ai/vertex-sdk": "^0.16.0",
@@ -377,7 +378,7 @@
"@azure/identity": "^4.14.0",
"@azure/storage-blob": "^12.30.0",
"@keyv/redis": "5.1.6",
- "@librechat/agents": "^4.0.6",
+ "@librechat/agents": "^4.1.1",
"@librechat/data-schemas": "*",
"@modelcontextprotocol/sdk": "^1.32.1",
"@opentelemetry/api": "^1.9.0",
@@ -432,7 +433,8 @@
"sharp": "^0.35.5",
"undici": "^7.30.1",
"yauzl": "^3.2.1",
- "zod": "^3.22.4",
+ "zod": "^4.6.7",
+ "zod-to-json-schema": "^3.25.1",
},
},
"packages/chat": {
@@ -577,7 +579,7 @@
"dayjs": "^1.11.13",
"js-yaml": "^4.3.2",
"re2js": "^2.8.6",
- "zod": "^3.22.4",
+ "zod": "^4.6.7",
},
"devDependencies": {
"@babel/preset-env": "^7.21.5",
@@ -1574,7 +1576,7 @@
"@lezer/lr": ["@lezer/[email protected]", "", { "dependencies": { "@lezer/common": "^1.0.0" } }, "sha512-pu0K1jCIdnQ12aWNaAVU5bzi7Bd1w54J3ECgANPmYLtQKP0HBj2cE/5coBD66MT10xbtIuUr7tg0Shbsvk0mDA=="],
- "@librechat/agents": ["@librechat/[email protected]", "", { "dependencies": { "@anthropic-ai/sdk": "^0.115.0", "@aws-sdk/client-bedrock-runtime": "^3.1075.0", "@langchain/anthropic": "1.5.2", "@langchain/aws": "^1.4.2", "@langchain/core": "1.2.8", "@langchain/deepseek": "^1.1.3", "@langchain/google-common": "2.2.0", "@langchain/google-gauth": "2.2.0", "@langchain/google-genai": "2.2.0", "@langchain/google-vertexai": "2.2.0", "@langchain/langgraph": "1.4.8", "@langchain/mistralai": "^1.2.0", "@langchain/openai": "1.5.8", "@langchain/textsplitters": "^1.0.1", "@langchain/xai": "^1.4.3", "@langfuse/core": "^5.10.1", "@langfuse/langchain": "^5.10.1", "@langfuse/otel": "^5.10.1", "@langfuse/tracing": "^5.10.1", "@opentelemetry/context-async-hooks": "^2.9.0", "@opentelemetry/sdk-node": "^0.220.0", "@types/diff": "^7.0.2", "ai-tokenizer": "^1.0.6", "axios": "^1.20.0", "cheerio": "^1.2.0", "diff": "^9.0.0", "dotenv": "^16.4.7", "https-proxy-agent": "^7.0.6", "mathjs": "^15.2.0", "nanoid": "^3.3.18", "okapibm25": "^1.4.1", "openai": "^6.46.0", "reova": "^0.4.1", "socks-proxy-agent": "^8.0.5", "uuid": "^11.1.1" }, "peerDependencies": { "@anthropic-ai/sandbox-runtime": "^0.0.78" }, "optionalPeers": ["@anthropic-ai/sandbox-runtime"] }, "sha512-NaYwM5fM53iZuFDMKfZPucbWNeQn/Szb4LAwVSsZ02n9Vvb0WSFPYhdE45gmZm+pQMV3Yykv8+IzKP7m/+COXg=="],
+ "@librechat/agents": ["@librechat/[email protected]", "", { "dependencies": { "@anthropic-ai/sdk": "^0.115.0", "@aws-sdk/client-bedrock-runtime": "^3.1075.0", "@langchain/anthropic": "1.5.2", "@langchain/aws": "^1.4.2", "@langchain/core": "1.2.8", "@langchain/deepseek": "^1.1.3", "@langchain/google-common": "2.2.0", "@langchain/google-gauth": "2.2.0", "@langchain/google-genai": "2.2.0", "@langchain/google-vertexai": "2.2.0", "@langchain/langgraph": "1.4.8", "@langchain/mistralai": "^1.2.0", "@langchain/openai": "1.5.8", "@langchain/textsplitters": "^1.0.1", "@langchain/xai": "^1.4.3", "@langfuse/core": "^5.10.1", "@langfuse/langchain": "^5.10.1", "@langfuse/otel": "^5.10.1", "@langfuse/tracing": "^5.10.1", "@opentelemetry/context-async-hooks": "^2.9.0", "@opentelemetry/sdk-node": "^0.220.0", "@types/diff": "^7.0.2", "ai-tokenizer": "^1.0.6", "axios": "^1.20.0", "cheerio": "^1.2.0", "diff": "^9.0.0", "dotenv": "^16.4.7", "https-proxy-agent": "^7.0.6", "mathjs": "^15.2.0", "nanoid": "^3.3.18", "okapibm25": "^1.4.1", "openai": "^6.46.0", "reova": "^0.4.1", "socks-proxy-agent": "^8.0.5", "uuid": "^11.1.1", "zod": "3.25.67", "zod-to-json-schema": "3.25.2", "zod-v4": "npm:[email protected]" }, "peerDependencies": { "@anthropic-ai/sandbox-runtime": "^0.0.78" }, "optionalPeers": ["@anthropic-ai/sandbox-runtime"] }, "sha512-vbZcHgFPFox+crvvDwt2lBg6tJzl5ADOkzw6HgyOJlkOigScYjS51EGWS3sDoaemBtv4EndRNSlJSGQvJvW/iw=="],
"@librechat/api": ["@librechat/api@workspace:packages/api"],
@@ -1834,7 +1836,7 @@
"@protobufjs/utf8": ["@protobufjs/[email protected]", "", {}, "sha512-oOAWABowe8EAbMyWKM0tYDKi8Yaox52D+HWZhAIJqQXbqe0xI/GV7FhLWqlEKreMkfDjshR5FKgi3mnle0h6Eg=="],
- "@puppeteer/browsers": ["@puppeteer/[email protected]", "", { "dependencies": { "modern-tar": "^0.8.4", "yargs": "^18.0.0" }, "peerDependencies": { "proxy-agent": ">=8.0.1", "yauzl": "^2.10.0 || ^3.4.0" }, "optionalPeers": ["proxy-agent", "yauzl"], "bin": { "browsers": "lib/main-cli.js" } }, "sha512-q2BU4YfO9h/Wt7IcWPcggpOOqLk2Tbs1hDwolvKZrweRjy751OJBKMN9zO5bfD0pzU7X/tvKw/exQds4pM/LOg=="],
+ "@puppeteer/browsers": ["@puppeteer/[email protected]", "", { "dependencies": { "modern-tar": "^0.8.6", "yargs": "^18.0.0" }, "peerDependencies": { "proxy-agent": ">=8.0.1", "yauzl": "^2.10.0 || ^3.4.0" }, "optionalPeers": ["proxy-agent", "yauzl"], "bin": { "browsers": "lib/main-cli.js" } }, "sha512-MJP29gVoHznmqmwhH1tlZqzfeQ3aylTpSSa6WKZXtkwYUH02i9imBmWGTyZrbnAou5paX78SE4jMAUqnEPf8ug=="],
"@quansync/fs": ["@quansync/[email protected]", "", { "dependencies": { "quansync": "^1.0.0" } }, "sha512-4TJ3DFtlf1L5LDMaM6CanJ/0lckGNtJcMjQ1NAV6zDmA0tEHKZtxNKin8EgPaVX1YzljbxckyT2tJrpQKAtngQ=="],
@@ -2844,7 +2846,7 @@
"chrome-launcher": ["[email protected]", "", { "dependencies": { "@types/node": "*", "escape-string-regexp": "^4.0.0", "is-wsl": "^2.2.0", "lighthouse-logger": "^2.0.1" }, "bin": { "print-chrome-path": "bin/print-chrome-path.cjs" } }, "sha512-qmFR5PLMzHyuNJHwOloHPAHhbaNglkfeV/xDtt5b7xiFFyU1I+AZZX0PYseMuhenJSSirgxELYIbswcoc+5H4A=="],
- "chromium-bidi": ["[email protected]", "", { "dependencies": { "mitt": "^3.0.1", "zod": "^3.24.1" }, "peerDependencies": { "devtools-protocol": "*" } }, "sha512-5v9GQFhTktFvotn/OFNJBmKLKRAb6n9r0bVCwf7sHgWc3/JryK0bj1nn93L3pHFrfgcsu6Be6EWsDi+1XHTGDg=="],
+ "chromium-bidi": ["[email protected]", "", { "dependencies": { "mitt": "^3.0.1", "zod": "^4.6.5" }, "peerDependencies": { "devtools-protocol": "*" } }, "sha512-KJw7IQgqXwxpJgJlEIPg5mr2ZoqA+jkTRtc5EABI7sUJ3bu3cpI7NuEBoj4Gn1AsF78CaT9So5WQWspK3/wYag=="],
"ci-info": ["[email protected]", "", {}, "sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA=="],
@@ -4166,7 +4168,7 @@
"mlly": ["[email protected]", "", { "dependencies": { "acorn": "^8.15.0", "pathe": "^2.0.3", "pkg-types": "^1.3.1", "ufo": "^1.6.1" } }, "sha512-l8D9ODSRWLe2KHJSifWGwBqpTZXIXTeo8mlKjY+E2HAakaTeNpqAyBZ8GSqLzHgw4XmHmC8whvpjJNMbFZN7/g=="],
- "modern-tar": ["[email protected]", "", {}, "sha512-snEhs+6G5Tjd4I7tLCDOaoln2RgE0bD19RzEKgvgK2hZ5VKy3MpLhLTZ2fWpXSTg4K2cyPwp+VHATFJhxfnOeA=="],
+ "modern-tar": ["[email protected]", "", {}, "sha512-LYSks0tNVqbtez/9OB0YFP6qLRSqkdAxJWOQpVaR67lNTbj2zNLyYpowkRMia5lXLCZKzxwoxkxH2MbbBR2aEg=="],
"module-alias": ["[email protected]", "", {}, "sha512-23g5BFj4zdQL/b6tor7Ji+QY4pEfNH784BMslY9Qb0UnJWRAt+lQGLYmRaM0KDBwIG23ffEBELhZDP2rhi9f/Q=="],
@@ -4286,7 +4288,7 @@
"open": ["[email protected]", "", { "dependencies": { "define-lazy-prop": "^2.0.0", "is-docker": "^2.1.1", "is-wsl": "^2.2.0" } }, "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ=="],
- "openai": ["[email protected]", "", { "peerDependencies": { "ws": "^8.18.0", "zod": "^3.23.8" }, "optionalPeers": ["ws", "zod"], "bin": "bin/cli" }, "sha512-8C+nzoHYgyYOXhHGN6r0fcb4SznuEn1R7YZMvlqDbnCuE0FM2mm3T1HiYW6WIcMS/F1Of2up/cSPjLPaWt0X9Q=="],
+ "openai": ["[email protected]", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "ws": "^8.18.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "ws", "zod"] }, "sha512-aYCc0C6L864eR6WSYIwQGyXriw/nIyZx0ObvhzOEVuk0zoBDpynjSbrionWI7q65B5H8jJX0DXR9snEzM6bfPg=="],
"openapi-types": ["[email protected]", "", {}, "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw=="],
@@ -4460,7 +4462,7 @@
"punycode": ["[email protected]", "", {}, "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ=="],
- "puppeteer-core": ["[email protected]", "", { "dependencies": { "@puppeteer/browsers": "3.2.2", "chromium-bidi": "17.0.2", "devtools-protocol": "0.0.1666840", "typed-query-selector": "^2.12.2", "webdriver-bidi-protocol": "0.4.3", "ws": "^8.21.3" } }, "sha512-Hy5eMQshOEMil4JUUx03h5pw1HYkYCso1RG/gcpPlFSd4cYPOcopxcXEAxpLPOkOPJb9LIJtwxuj66bSdvknFg=="],
+ "puppeteer-core": ["[email protected]", "", { "dependencies": { "@puppeteer/browsers": "3.2.6", "chromium-bidi": "157.0.8090-0", "devtools-protocol": "0.0.1704951", "typed-query-selector": "^2.12.3", "webdriver-bidi-protocol": "1.0.1", "ws": "^8.22.0" } }, "sha512-VA5Pf54N8shfopNkZZXCdiiwfnnY8ZJYAMqFQRhlH5mGUhfwf53Ar770GPtdpTDLUqvQeYpIBtC9/G2Jij2IJw=="],
"pure-rand": ["[email protected]", "", {}, "sha512-oTUZM/NAZS8p7ANR3SHh30kXB+zK2r2BPcEn/awJIbOvq82WoMN4p62AWWp3Hhw50G0xMsw1mhIBLqHw64EcNQ=="],
@@ -4970,7 +4972,7 @@
"typed-function": ["[email protected]", "", {}, "sha512-EGjWssW7Tsk4DGfE+5yluuljS1OGYWiI1J6e8puZz9nTMM51Oug8CD5Zo4gWMsOhq5BI+1bF+rWTm4Vbj3ivRA=="],
- "typed-query-selector": ["[email protected]", "", {}, "sha512-EOPFbyIub4ngnEdqi2yOcNeDLaX/0jcE1JoAXQDDMIthap7FoN795lc/SHfIq2d416VufXpM8z/lD+WRm2gfOQ=="],
+ "typed-query-selector": ["[email protected]", "", {}, "sha512-/dtuMZyutHLlrxWhhC1uib00ELUr2dZ8C9B8YzZYsJmeE3V56OxRblrSM2UaF142pcMtak7ehZ6+poWGeehNIg=="],
"typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
@@ -5102,7 +5104,7 @@
"web-vitals": ["[email protected]", "", {}, "sha512-c0rhqNcHXRkY/ogGDJQxZ9Im9D19hDihbzSQJrsioex+KnFgmMzBiy57Z1EjkhX/+OjyBpclDCzz2ITtjokFmg=="],
- "webdriver-bidi-protocol": ["[email protected]", "", {}, "sha512-uuN0goWfxP22B7J/uAgBpOYNPttC+XVseYE+rSY5+rQ+YBeVz/VORw8WbmLVcqW78zNg5A4qnjNXYUWR3il2ig=="],
+ "webdriver-bidi-protocol": ["[email protected]", "", {}, "sha512-WXWs/aXF2a6Al1Z2/V/7Gp2oPZOAAmHjJOTmv4KCXRJ122IMj3tSSMc6a4q3K4QOmhQbse/Ahr+oTVJOU2dUiw=="],
"webidl-conversions": ["[email protected]", "", {}, "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g=="],
@@ -5220,11 +5222,13 @@
"yocto-queue": ["[email protected]", "", {}, "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="],
- "zod": ["[email protected]", "", {}, "sha512-idA2YXwpCdqUSKRCACDE6ItZD9TZzy3OZMtpfLoh6oPR47lipysRrJfjzMqFxQ3uJuUPyUeWe1r9vLH33xO/Qw=="],
+ "zod": ["[email protected]", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="],
- "zod-openapi": ["[email protected]", "", { "peerDependencies": { "zod": "^3.21.4" } }, "sha512-tsrQpbpqFCXqVXUzi3TPwFhuMtLN3oNZobOtYnK6/5VkXsNdnIgyNr4r8no4wmYluaxzN3F7iS+8xCW8BmMQ8g=="],
+ "zod-openapi": ["[email protected]", "", { "peerDependencies": { "zod": "^4.0.0" } }, "sha512-SwC5Ppi2ov8WimzNWP/XK95VqPyLDzxPYj10HgNPzhZH9gO7zx0sxdYL9eq7wOADHx1JddOApjhYDmMWQvnVnw=="],
- "zod-to-json-schema": ["[email protected]", "", { "peerDependencies": { "zod": "^3.25 || ^4" } }, "sha512-pM/SU9d3YAggzi6MtR4h7ruuQlqKtad8e9S0fmxcMi+ueAK5Korys/aWcV9LIIHTVbj01NdzxcnXSN+O74ZIVA=="],
+ "zod-to-json-schema": ["[email protected]", "", { "peerDependencies": { "zod": "^3.25.28 || ^4" } }, "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA=="],
+
+ "zod-v4": ["[email protected]", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="],
"zone.js": ["[email protected]", "", {}, "sha512-Eky7p2Z1Ig3NnbfodSPoARCjKBSTFMnE/ACsP1L/XJEfY4SdOFce19BsUCWVwL6K5ABZFy5J3bjcMWffX+YM3Q=="],
@@ -5330,12 +5334,8 @@
"@jridgewell/source-map/@jridgewell/trace-mapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
- "@langchain/anthropic/zod": ["[email protected]", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="],
-
"@langchain/core/p-queue": ["[email protected]", "", { "dependencies": { "eventemitter3": "^4.0.4", "p-timeout": "^3.2.0" } }, "sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ=="],
- "@langchain/core/zod": ["[email protected]", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="],
-
"@langchain/deepseek/@langchain/openai": ["@langchain/[email protected]", "", { "dependencies": { "js-tiktoken": "^1.0.12", "openai": "^6.41.0", "zod": "^3.25.76 || ^4" }, "peerDependencies": { "@langchain/core": "^1.2.2" } }, "sha512-wX7dwb9z4nf5FHXlIl/X2mk08pzonvRHCt1D4+s1zXLP0duYDC95j7dulPIQJ6fmhbyYQc9Ki8mEhY/D1lB8kw=="],
"@langchain/google-gauth/google-auth-library": ["[email protected]", "", { "dependencies": { "base64-js": "^1.3.0", "ecdsa-sig-formatter": "^1.0.11", "gaxios": "^7.1.4", "gcp-metadata": "8.1.2", "google-logging-utils": "1.1.3", "jws": "^4.0.0" } }, "sha512-i1ydyHrqcIxXkWh/uBmVkzCvIuq5yiK2ATndIe5XxKholrG/MTYP9xGYka4sQhrbIAgGjL2B6NOE7rFaiF3fXw=="],
@@ -5344,17 +5344,13 @@
"@langchain/langgraph-sdk/p-retry": ["[email protected]", "", { "dependencies": { "is-network-error": "^1.1.0" } }, "sha512-J5ApzjyRkkf601HpEeykoiCvzHQjWxPAHhyjFcEUP2SWq0+35NKh8TLhpLw+Dkq5TZBFvUM6UigdE9hIVYTl5w=="],
- "@langchain/openai/openai": ["[email protected]", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "ws": "^8.18.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "ws", "zod"] }, "sha512-aYCc0C6L864eR6WSYIwQGyXriw/nIyZx0ObvhzOEVuk0zoBDpynjSbrionWI7q65B5H8jJX0DXR9snEzM6bfPg=="],
-
- "@langchain/openai/zod": ["[email protected]", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="],
-
"@langchain/xai/@langchain/openai": ["@langchain/[email protected]", "", { "dependencies": { "js-tiktoken": "^1.0.12", "openai": "^6.41.0", "zod": "^3.25.76 || ^4" }, "peerDependencies": { "@langchain/core": "^1.2.2" } }, "sha512-wX7dwb9z4nf5FHXlIl/X2mk08pzonvRHCt1D4+s1zXLP0duYDC95j7dulPIQJ6fmhbyYQc9Ki8mEhY/D1lB8kw=="],
"@librechat/agents/@opentelemetry/sdk-node": ["@opentelemetry/[email protected]", "", { "dependencies": { "@opentelemetry/api-logs": "0.220.0", "@opentelemetry/configuration": "0.220.0", "@opentelemetry/context-async-hooks": "2.9.0", "@opentelemetry/core": "2.9.0", "@opentelemetry/exporter-logs-otlp-grpc": "0.220.0", "@opentelemetry/exporter-logs-otlp-http": "0.220.0", "@opentelemetry/exporter-logs-otlp-proto": "0.220.0", "@opentelemetry/exporter-metrics-otlp-grpc": "0.220.0", "@opentelemetry/exporter-metrics-otlp-http": "0.220.0", "@opentelemetry/exporter-metrics-otlp-proto": "0.220.0", "@opentelemetry/exporter-prometheus": "0.220.0", "@opentelemetry/exporter-trace-otlp-grpc": "0.220.0", "@opentelemetry/exporter-trace-otlp-http": "0.220.0", "@opentelemetry/exporter-trace-otlp-proto": "0.220.0", "@opentelemetry/exporter-zipkin": "2.9.0", "@opentelemetry/instrumentation": "0.220.0", "@opentelemetry/otlp-exporter-base": "0.220.0", "@opentelemetry/otlp-grpc-exporter-base": "0.220.0", "@opentelemetry/propagator-b3": "2.9.0", "@opentelemetry/propagator-jaeger": "2.9.0", "@opentelemetry/resources": "2.9.0", "@opentelemetry/sdk-logs": "0.220.0", "@opentelemetry/sdk-metrics": "2.9.0", "@opentelemetry/sdk-trace": "2.9.0", "@opentelemetry/sdk-trace-base": "2.9.0", "@opentelemetry/sdk-trace-node": "2.9.0", "@opentelemetry/semantic-conventions": "^1.29.0" }, "peerDependencies": { "@opentelemetry/api": ">=1.3.0 <1.10.0" } }, "sha512-wHtGyHhSKHNH3fym33xRu4Ef/HXTFvX8eQ42xdQdEO9LYx9Y2qNyBDJytyqVlvmo6abWZlNYTUthuAGUMYqYnQ=="],
"@librechat/agents/diff": ["[email protected]", "", {}, "sha512-svtcdpS8CgJyqAjEQIXdb3OjhFVVYjzGAPO8WGCmRbrml64SPw/jJD4GoE98aR7r25A0XcgrK3F02yw9R/vhQw=="],
- "@librechat/agents/openai": ["[email protected]", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "ws": "^8.18.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "ws", "zod"] }, "sha512-aYCc0C6L864eR6WSYIwQGyXriw/nIyZx0ObvhzOEVuk0zoBDpynjSbrionWI7q65B5H8jJX0DXR9snEzM6bfPg=="],
+ "@librechat/agents/zod": ["[email protected]", "", {}, "sha512-idA2YXwpCdqUSKRCACDE6ItZD9TZzy3OZMtpfLoh6oPR47lipysRrJfjzMqFxQ3uJuUPyUeWe1r9vLH33xO/Qw=="],
"@librechat/api/@librechat/code": ["@librechat/code@file:vendor/code", {}],
@@ -5420,7 +5416,7 @@
"@opentelemetry/sdk-trace-node/@opentelemetry/context-async-hooks": ["@opentelemetry/[email protected]", "", { "peerDependencies": { "@opentelemetry/api": ">=1.0.0 <1.10.0" } }, "sha512-OPFBYuXEn1E4ja3Y6eeA7O+ZnLBNcXTV5Cgsn1VaqBZ6hC5FnpZPLBNme1LJY8ZtF4aOujPKFoeWN4ik487KuQ=="],
- "@puppeteer/browsers/yargs": ["[email protected]", "", { "dependencies": { "cliui": "^9.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "string-width": "^8.2.1", "y18n": "^5.0.5", "yargs-parser": "^22.0.0" } }, "sha512-2rAgRKu54VsHkqI0/tYkmluGXHD4KW7yZoycuqDQ15QOTnc2VVfy0nN/1eMhnQLO00A+dwtK20xuCnc1YGeUyg=="],
+ "@puppeteer/browsers/yargs": ["[email protected]", "", { "dependencies": { "cliui": "^9.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "string-width": "^8.2.1", "y18n": "^5.0.5", "yargs-parser": "^22.0.0" } }, "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w=="],
"@radix-ui/react-collection/@radix-ui/react-slot": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.5" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-qx7oqnYbxnK9kYI9m317qmFmEgo6ywqWvbTogdj7cL9p3/yx4M48p7Rnw5z3H890cL/ow/EeWJsuTykeZVXP5Q=="],
@@ -5872,7 +5868,7 @@
"prop-types/react-is": ["[email protected]", "", {}, "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="],
- "puppeteer-core/devtools-protocol": ["[email protected]", "", {}, "sha512-gCcO42XCHKEs7Ag0S7aGYsnJ7hlgrO3qderYqeiY0Eqk+0GFfuvT13IA0hHreJTa2KCdDVyGMeOhdMNmrrTjVg=="],
+ "puppeteer-core/devtools-protocol": ["[email protected]", "", {}, "sha512-GQhQOs9u/Mvm1zMtJIH872JS4AskuZdUSsPNPk4ChahtWAUqgz6atEtIsMt+nO7MqF1Ic4HxII/k8Cu36JivNg=="],
"raw-body/http-errors": ["[email protected]", "", { "dependencies": { "depd": "~2.0.0", "inherits": "~2.0.4", "setprototypeof": "~1.2.0", "statuses": "~2.0.2", "toidentifier": "~1.0.1" } }, "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ=="],
@@ -6070,20 +6066,12 @@
"@langchain/core/p-queue/p-timeout": ["[email protected]", "", { "dependencies": { "p-finally": "^1.0.0" } }, "sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg=="],
- "@langchain/deepseek/@langchain/openai/openai": ["[email protected]", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "ws": "^8.18.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "ws", "zod"] }, "sha512-aYCc0C6L864eR6WSYIwQGyXriw/nIyZx0ObvhzOEVuk0zoBDpynjSbrionWI7q65B5H8jJX0DXR9snEzM6bfPg=="],
-
- "@langchain/deepseek/@langchain/openai/zod": ["[email protected]", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="],
-
"@langchain/google-gauth/google-auth-library/gaxios": ["[email protected]", "", { "dependencies": { "extend": "^3.0.2", "https-proxy-agent": "^7.0.1", "node-fetch": "^3.3.2" } }, "sha512-RB5vLV+vvQeoFPCX4QMK6/hjVkbIamPp1QSUD0CiZcnj12qbpiL+pLbYtgD+oZkWl0tl9z+o2Utp+MpM3QRhBA=="],
"@langchain/google-gauth/google-auth-library/gcp-metadata": ["[email protected]", "", { "dependencies": { "gaxios": "^7.0.0", "google-logging-utils": "^1.0.0", "json-bigint": "^1.0.0" } }, "sha512-zV/5HKTfCeKWnxG0Dmrw51hEWFGfcF2xiXqcA3+J90WDuP0SvoiSO5ORvcBsifmx/FoIjgQN3oNOGaQ5PhLFkg=="],
"@langchain/google-gauth/google-auth-library/google-logging-utils": ["[email protected]", "", {}, "sha512-eAmLkjDjAFCVXg7A1unxHsLf961m6y17QFqXqAXGj/gVkKFrEICfStRfwUlGNfeCEjNRa32JEWOUTlYXPyyKvA=="],
- "@langchain/xai/@langchain/openai/openai": ["[email protected]", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "ws": "^8.18.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "ws", "zod"] }, "sha512-aYCc0C6L864eR6WSYIwQGyXriw/nIyZx0ObvhzOEVuk0zoBDpynjSbrionWI7q65B5H8jJX0DXR9snEzM6bfPg=="],
-
- "@langchain/xai/@langchain/openai/zod": ["[email protected]", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="],
-
"@librechat/agents/@opentelemetry/sdk-node/@opentelemetry/api-logs": ["@opentelemetry/[email protected]", "", { "dependencies": { "@opentelemetry/api": "^1.3.0" } }, "sha512-CmVa4ImJ+ynfrPMNaAXHET6Bhb44SwzmfyVJFq9ni2jgXJR/l7C6gfVFddNmHP+ZOkP9cf4f9DBe68qVLTHc9w=="],
"@librechat/agents/@opentelemetry/sdk-node/@opentelemetry/configuration": ["@opentelemetry/[email protected]", "", { "dependencies": { "@opentelemetry/core": "2.9.0", "yaml": "^2.8.3" }, "peerDependencies": { "@opentelemetry/api": "^1.9.0" } }, "sha512-glfIVKnZevRin8fY/9uES/mhRtMT1lGINLHc9MIo5fTQZXswEEHamJtgjv4MTtzgnhHGC92mIS/0lzAUZMyE0w=="],
@@ -6226,7 +6214,7 @@
"@puppeteer/browsers/yargs/cliui": ["[email protected]", "", { "dependencies": { "string-width": "^7.2.0", "strip-ansi": "^7.1.0", "wrap-ansi": "^9.0.0" } }, "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w=="],
- "@puppeteer/browsers/yargs/string-width": ["[email protected]", "", { "dependencies": { "get-east-asian-width": "^1.5.0", "strip-ansi": "^7.1.2" } }, "sha512-GaPUh5gfdrYzqeVNZvUfT23vYYxXzKYidUcnMtJg/3rxRV63EFZy3k6xfKlmfeJD0176lnUV/Usr3XcwSvFzpg=="],
+ "@puppeteer/browsers/yargs/string-width": ["[email protected]", "", { "dependencies": { "get-east-asian-width": "^1.5.0", "strip-ansi": "^7.1.2" } }, "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ=="],
"@puppeteer/browsers/yargs/yargs-parser": ["[email protected]", "", {}, "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw=="],
@@ -6746,11 +6734,11 @@
"@puppeteer/browsers/yargs/cliui/string-width/strip-ansi": ["[email protected]", "", { "dependencies": { "ansi-regex": "^6.0.1" } }, "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ=="],
- "@puppeteer/browsers/yargs/cliui/strip-ansi/ansi-regex": ["[email protected]", "", {}, "sha512-WpDfL7NO6j7tH88IDBNVdUJxDh9nmCteAVW9dsep846XdwF4naCBK+/tGLX3KJgcpgMRXCFlTM2hKGoK9FsdrQ=="],
+ "@puppeteer/browsers/yargs/cliui/strip-ansi/ansi-regex": ["[email protected]", "", {}, "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw=="],
"@puppeteer/browsers/yargs/cliui/wrap-ansi/ansi-styles": ["[email protected]", "", {}, "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg=="],
- "@puppeteer/browsers/yargs/string-width/strip-ansi/ansi-regex": ["[email protected]", "", {}, "sha512-WpDfL7NO6j7tH88IDBNVdUJxDh9nmCteAVW9dsep846XdwF4naCBK+/tGLX3KJgcpgMRXCFlTM2hKGoK9FsdrQ=="],
+ "@puppeteer/browsers/yargs/string-width/strip-ansi/ansi-regex": ["[email protected]", "", {}, "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw=="],
"expect/jest-message-util/@jest/types/@jest/schemas/@sinclair/typebox": ["@sinclair/[email protected]", "", {}, "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA=="],
diff --git a/client/package.json b/client/package.json
index 5516f4e68f..1bfbedffe1 100644
--- a/client/package.json
+++ b/client/package.json
@@ -137,7 +137,7 @@
"tailwindcss-animate": "^1.0.5",
"ts-md5": "^1.3.1",
"web-vitals": "^3.5.2",
- "zod": "^3.22.4"
+ "zod": "^4.6.7"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.22.15",
diff --git a/client/src/utils/email.ts b/client/src/utils/email.ts
index b1ad6d7d1c..7ee2a4f53e 100644
--- a/client/src/utils/email.ts
+++ b/client/src/utils/email.ts
@@ -22,7 +22,7 @@ export const validateEmail = (email: string, errorMessage?: string): true | stri
return (
result.success ||
errorMessage ||
- result.error.errors[0]?.message ||
+ result.error.issues[0]?.message ||
'Please enter a valid email address'
);
};
diff --git a/package-lock.json b/package-lock.json
index 86dd67f323..b0fdc00505 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -65,7 +65,7 @@
"@azure/storage-blob": "^12.30.0",
"@google/genai": "^2.8.0",
"@keyv/redis": "5.1.6",
- "@librechat/agents": "^4.1.0",
+ "@librechat/agents": "^4.1.1",
"@librechat/api": "*",
"@librechat/data-schemas": "*",
"@microsoft/microsoft-graph-client": "^3.0.7",
@@ -130,7 +130,7 @@
"nanoid": "^3.3.18",
"node-fetch": "^2.7.0",
"nodemailer": "^10.2.1",
- "openai": "5.8.2",
+ "openai": "^6.49.0",
"openid-client": "^6.5.0",
"passport": "^0.6.0",
"passport-apple": "^2.0.2",
@@ -154,7 +154,8 @@
"winston-daily-rotate-file": "^5.0.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"yauzl": "^3.2.1",
- "zod": "^3.22.4"
+ "zod": "^4.6.7",
+ "zod-to-json-schema": "^3.25.1"
},
"devDependencies": {
"@babel/preset-env": "^7.29.5",
@@ -966,7 +967,7 @@
"tailwindcss-animate": "^1.0.5",
"ts-md5": "^1.3.1",
"web-vitals": "^3.5.2",
- "zod": "^3.22.4"
+ "zod": "^4.6.7"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.22.15",
@@ -8654,15 +8655,6 @@
"@langchain/core": "^1.2.3"
}
},
- "node_modules/@langchain/anthropic/node_modules/zod": {
- "version": "4.6.7",
- "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
- "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
- "license": "MIT",
- "funding": {
- "url": "https://github.com/sponsors/colinhacks"
- }
- },
"node_modules/@langchain/aws": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/@langchain/aws/-/aws-1.4.3.tgz",
@@ -8699,15 +8691,6 @@
"node": ">=20"
}
},
- "node_modules/@langchain/core/node_modules/zod": {
- "version": "4.6.7",
- "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
- "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
- "license": "MIT",
- "funding": {
- "url": "https://github.com/sponsors/colinhacks"
- }
- },
"node_modules/@langchain/deepseek": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/@langchain/deepseek/-/deepseek-1.1.5.tgz",
@@ -9033,45 +9016,6 @@
"@langchain/core": "^1.2.2"
}
},
- "node_modules/@langchain/openai/node_modules/openai": {
- "version": "6.49.0",
- "resolved": "https://registry.npmjs.org/openai/-/openai-6.49.0.tgz",
- "integrity": "sha512-aYCc0C6L864eR6WSYIwQGyXriw/nIyZx0ObvhzOEVuk0zoBDpynjSbrionWI7q65B5H8jJX0DXR9snEzM6bfPg==",
- "license": "Apache-2.0",
- "peerDependencies": {
- "@aws-sdk/credential-provider-node": ">=3.972.0 <4",
- "@smithy/hash-node": ">=4.3.0 <5",
- "@smithy/signature-v4": ">=5.4.0 <6",
- "ws": "^8.18.0",
- "zod": "^3.25 || ^4.0"
- },
- "peerDependenciesMeta": {
- "@aws-sdk/credential-provider-node": {
- "optional": true
- },
- "@smithy/hash-node": {
- "optional": true
- },
- "@smithy/signature-v4": {
- "optional": true
- },
- "ws": {
- "optional": true
- },
- "zod": {
- "optional": true
- }
- }
- },
- "node_modules/@langchain/openai/node_modules/zod": {
- "version": "4.6.7",
- "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
- "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
- "license": "MIT",
- "funding": {
- "url": "https://github.com/sponsors/colinhacks"
- }
- },
"node_modules/@langchain/protocol": {
"version": "0.0.18",
"resolved": "https://registry.npmjs.org/@langchain/protocol/-/protocol-0.0.18.tgz",
@@ -9222,9 +9166,9 @@
}
},
"node_modules/@librechat/agents": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-4.1.0.tgz",
- "integrity": "sha512-NaYwM5fM53iZuFDMKfZPucbWNeQn/Szb4LAwVSsZ02n9Vvb0WSFPYhdE45gmZm+pQMV3Yykv8+IzKP7m/+COXg==",
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-4.1.1.tgz",
+ "integrity": "sha512-vbZcHgFPFox+crvvDwt2lBg6tJzl5ADOkzw6HgyOJlkOigScYjS51EGWS3sDoaemBtv4EndRNSlJSGQvJvW/iw==",
"license": "MIT",
"dependencies": {
"@anthropic-ai/sdk": "^0.115.0",
@@ -9261,7 +9205,10 @@
"openai": "^6.46.0",
"reova": "^0.4.1",
"socks-proxy-agent": "^8.0.5",
- "uuid": "^11.1.1"
+ "uuid": "^11.1.1",
+ "zod": "3.25.67",
+ "zod-to-json-schema": "3.25.2",
+ "zod-v4": "npm:[email protected]"
},
"engines": {
"node": ">=24.0.0"
@@ -9292,6 +9239,15 @@
"@langchain/core": "^1.2.8"
}
},
+ "node_modules/@librechat/agents/node_modules/@langchain/openai/node_modules/zod": {
+ "version": "4.6.7",
+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
+ "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/colinhacks"
+ }
+ },
"node_modules/@librechat/agents/node_modules/@opentelemetry/api-logs": {
"version": "0.220.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.220.0.tgz",
@@ -9801,40 +9757,10 @@
"node": ">=18"
}
},
- "node_modules/@librechat/agents/node_modules/openai": {
- "version": "6.49.0",
- "resolved": "https://registry.npmjs.org/openai/-/openai-6.49.0.tgz",
- "integrity": "sha512-aYCc0C6L864eR6WSYIwQGyXriw/nIyZx0ObvhzOEVuk0zoBDpynjSbrionWI7q65B5H8jJX0DXR9snEzM6bfPg==",
- "license": "Apache-2.0",
- "peerDependencies": {
- "@aws-sdk/credential-provider-node": ">=3.972.0 <4",
- "@smithy/hash-node": ">=4.3.0 <5",
- "@smithy/signature-v4": ">=5.4.0 <6",
- "ws": "^8.18.0",
- "zod": "^3.25 || ^4.0"
- },
- "peerDependenciesMeta": {
- "@aws-sdk/credential-provider-node": {
- "optional": true
- },
- "@smithy/hash-node": {
- "optional": true
- },
- "@smithy/signature-v4": {
- "optional": true
- },
- "ws": {
- "optional": true
- },
- "zod": {
- "optional": true
- }
- }
- },
"node_modules/@librechat/agents/node_modules/zod": {
- "version": "4.6.7",
- "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
- "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
+ "version": "3.25.67",
+ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.67.tgz",
+ "integrity": "sha512-idA2YXwpCdqUSKRCACDE6ItZD9TZzy3OZMtpfLoh6oPR47lipysRrJfjzMqFxQ3uJuUPyUeWe1r9vLH33xO/Qw==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
@@ -12048,6 +11974,198 @@
"integrity": "sha512-oOAWABowe8EAbMyWKM0tYDKi8Yaox52D+HWZhAIJqQXbqe0xI/GV7FhLWqlEKreMkfDjshR5FKgi3mnle0h6Eg==",
"license": "BSD-3-Clause"
},
+ "node_modules/@puppeteer/browsers": {
+ "version": "3.2.6",
+ "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.2.6.tgz",
+ "integrity": "sha512-MJP29gVoHznmqmwhH1tlZqzfeQ3aylTpSSa6WKZXtkwYUH02i9imBmWGTyZrbnAou5paX78SE4jMAUqnEPf8ug==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "modern-tar": "^0.8.6",
+ "yargs": "^18.0.0"
+ },
+ "bin": {
+ "browsers": "lib/main-cli.js"
+ },
+ "engines": {
+ "node": ">=22.12.0"
+ },
+ "peerDependencies": {
+ "proxy-agent": ">=8.0.1",
+ "yauzl": "^2.10.0 || ^3.4.0"
+ },
+ "peerDependenciesMeta": {
+ "proxy-agent": {
+ "optional": true
+ },
+ "yauzl": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@puppeteer/browsers/node_modules/ansi-regex": {
+ "version": "6.4.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz",
+ "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-regex?sponsor=1"
+ }
+ },
+ "node_modules/@puppeteer/browsers/node_modules/ansi-styles": {
+ "version": "6.2.3",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz",
+ "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+ }
+ },
+ "node_modules/@puppeteer/browsers/node_modules/cliui": {
+ "version": "9.0.1",
+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz",
+ "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "string-width": "^7.2.0",
+ "strip-ansi": "^7.1.0",
+ "wrap-ansi": "^9.0.0"
+ },
+ "engines": {
+ "node": ">=20"
+ }
+ },
+ "node_modules/@puppeteer/browsers/node_modules/cliui/node_modules/string-width": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
+ "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "emoji-regex": "^10.3.0",
+ "get-east-asian-width": "^1.0.0",
+ "strip-ansi": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/@puppeteer/browsers/node_modules/emoji-regex": {
+ "version": "10.6.0",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
+ "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@puppeteer/browsers/node_modules/string-width": {
+ "version": "8.3.0",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz",
+ "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "get-east-asian-width": "^1.5.0",
+ "strip-ansi": "^7.1.2"
+ },
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/@puppeteer/browsers/node_modules/strip-ansi": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
+ "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ansi-regex": "^6.2.2"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/strip-ansi?sponsor=1"
+ }
+ },
+ "node_modules/@puppeteer/browsers/node_modules/wrap-ansi": {
+ "version": "9.0.2",
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz",
+ "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ansi-styles": "^6.2.1",
+ "string-width": "^7.0.0",
+ "strip-ansi": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
+ }
+ },
+ "node_modules/@puppeteer/browsers/node_modules/wrap-ansi/node_modules/string-width": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
+ "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "emoji-regex": "^10.3.0",
+ "get-east-asian-width": "^1.0.0",
+ "strip-ansi": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/@puppeteer/browsers/node_modules/yargs": {
+ "version": "18.2.0",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz",
+ "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "cliui": "^9.0.1",
+ "escalade": "^3.1.1",
+ "get-caller-file": "^2.0.5",
+ "string-width": "^8.2.1",
+ "y18n": "^5.0.5",
+ "yargs-parser": "^22.0.0"
+ },
+ "engines": {
+ "node": "^20.19.0 || ^22.12.0 || >=23"
+ }
+ },
+ "node_modules/@puppeteer/browsers/node_modules/yargs-parser": {
+ "version": "22.0.0",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz",
+ "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==",
+ "dev": true,
+ "license": "ISC",
+ "engines": {
+ "node": "^20.19.0 || ^22.12.0 || >=23"
+ }
+ },
"node_modules/@quansync/fs": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@quansync/fs/-/fs-1.0.0.tgz",
@@ -21157,14 +21275,14 @@
}
},
"node_modules/chromium-bidi": {
- "version": "17.0.2",
- "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-17.0.2.tgz",
- "integrity": "sha512-5v9GQFhTktFvotn/OFNJBmKLKRAb6n9r0bVCwf7sHgWc3/JryK0bj1nn93L3pHFrfgcsu6Be6EWsDi+1XHTGDg==",
+ "version": "157.0.8090-0",
+ "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-157.0.8090-0.tgz",
+ "integrity": "sha512-KJw7IQgqXwxpJgJlEIPg5mr2ZoqA+jkTRtc5EABI7sUJ3bu3cpI7NuEBoj4Gn1AsF78CaT9So5WQWspK3/wYag==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"mitt": "^3.0.1",
- "zod": "^3.24.1"
+ "zod": "^4.6.5"
},
"engines": {
"node": ">=20.19.0 <22.0.0 || >=22.12.0"
@@ -32000,9 +32118,9 @@
}
},
"node_modules/modern-tar": {
- "version": "0.8.5",
- "resolved": "https://registry.npmjs.org/modern-tar/-/modern-tar-0.8.5.tgz",
- "integrity": "sha512-snEhs+6G5Tjd4I7tLCDOaoln2RgE0bD19RzEKgvgK2hZ5VKy3MpLhLTZ2fWpXSTg4K2cyPwp+VHATFJhxfnOeA==",
+ "version": "0.8.6",
+ "resolved": "https://registry.npmjs.org/modern-tar/-/modern-tar-0.8.6.tgz",
+ "integrity": "sha512-LYSks0tNVqbtez/9OB0YFP6qLRSqkdAxJWOQpVaR67lNTbj2zNLyYpowkRMia5lXLCZKzxwoxkxH2MbbBR2aEg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -33000,18 +33118,27 @@
}
},
"node_modules/openai": {
- "version": "5.8.2",
- "resolved": "https://registry.npmjs.org/openai/-/openai-5.8.2.tgz",
- "integrity": "sha512-8C+nzoHYgyYOXhHGN6r0fcb4SznuEn1R7YZMvlqDbnCuE0FM2mm3T1HiYW6WIcMS/F1Of2up/cSPjLPaWt0X9Q==",
+ "version": "6.49.0",
+ "resolved": "https://registry.npmjs.org/openai/-/openai-6.49.0.tgz",
+ "integrity": "sha512-aYCc0C6L864eR6WSYIwQGyXriw/nIyZx0ObvhzOEVuk0zoBDpynjSbrionWI7q65B5H8jJX0DXR9snEzM6bfPg==",
"license": "Apache-2.0",
- "bin": {
- "openai": "bin/cli"
- },
"peerDependencies": {
+ "@aws-sdk/credential-provider-node": ">=3.972.0 <4",
+ "@smithy/hash-node": ">=4.3.0 <5",
+ "@smithy/signature-v4": ">=5.4.0 <6",
"ws": "^8.18.0",
- "zod": "^3.23.8"
+ "zod": "^3.25 || ^4.0"
},
"peerDependenciesMeta": {
+ "@aws-sdk/credential-provider-node": {
+ "optional": true
+ },
+ "@smithy/hash-node": {
+ "optional": true
+ },
+ "@smithy/signature-v4": {
+ "optional": true
+ },
"ws": {
"optional": true
},
@@ -34178,222 +34305,30 @@
}
},
"node_modules/puppeteer-core": {
- "version": "25.10.0",
- "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-25.10.0.tgz",
- "integrity": "sha512-Hy5eMQshOEMil4JUUx03h5pw1HYkYCso1RG/gcpPlFSd4cYPOcopxcXEAxpLPOkOPJb9LIJtwxuj66bSdvknFg==",
+ "version": "25.16.0",
+ "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-25.16.0.tgz",
+ "integrity": "sha512-VA5Pf54N8shfopNkZZXCdiiwfnnY8ZJYAMqFQRhlH5mGUhfwf53Ar770GPtdpTDLUqvQeYpIBtC9/G2Jij2IJw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
- "@puppeteer/browsers": "3.2.2",
- "chromium-bidi": "17.0.2",
- "devtools-protocol": "0.0.1666840",
- "typed-query-selector": "^2.12.2",
- "webdriver-bidi-protocol": "0.4.3",
- "ws": "^8.21.3"
- },
- "engines": {
- "node": ">=22.12.0"
- }
- },
- "node_modules/puppeteer-core/node_modules/@puppeteer/browsers": {
- "version": "3.2.2",
- "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.2.2.tgz",
- "integrity": "sha512-q2BU4YfO9h/Wt7IcWPcggpOOqLk2Tbs1hDwolvKZrweRjy751OJBKMN9zO5bfD0pzU7X/tvKw/exQds4pM/LOg==",
- "dev": true,
- "license": "Apache-2.0",
- "dependencies": {
- "modern-tar": "^0.8.4",
- "yargs": "^18.0.0"
- },
- "bin": {
- "browsers": "lib/main-cli.js"
+ "@puppeteer/browsers": "3.2.6",
+ "chromium-bidi": "157.0.8090-0",
+ "devtools-protocol": "0.0.1704951",
+ "typed-query-selector": "^2.12.3",
+ "webdriver-bidi-protocol": "1.0.1",
+ "ws": "^8.22.0"
},
"engines": {
"node": ">=22.12.0"
- },
- "peerDependencies": {
- "proxy-agent": ">=8.0.1",
- "yauzl": "^2.10.0 || ^3.4.0"
- },
- "peerDependenciesMeta": {
- "proxy-agent": {
- "optional": true
- },
- "yauzl": {
- "optional": true
- }
- }
- },
- "node_modules/puppeteer-core/node_modules/ansi-regex": {
- "version": "6.3.0",
- "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.3.0.tgz",
- "integrity": "sha512-WpDfL7NO6j7tH88IDBNVdUJxDh9nmCteAVW9dsep846XdwF4naCBK+/tGLX3KJgcpgMRXCFlTM2hKGoK9FsdrQ==",
- "dev": true,
- "license": "MIT",
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/chalk/ansi-regex?sponsor=1"
- }
- },
- "node_modules/puppeteer-core/node_modules/ansi-styles": {
- "version": "6.2.3",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz",
- "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==",
- "dev": true,
- "license": "MIT",
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/chalk/ansi-styles?sponsor=1"
- }
- },
- "node_modules/puppeteer-core/node_modules/cliui": {
- "version": "9.0.1",
- "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz",
- "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==",
- "dev": true,
- "license": "ISC",
- "dependencies": {
- "string-width": "^7.2.0",
- "strip-ansi": "^7.1.0",
- "wrap-ansi": "^9.0.0"
- },
- "engines": {
- "node": ">=20"
- }
- },
- "node_modules/puppeteer-core/node_modules/cliui/node_modules/string-width": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
- "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "emoji-regex": "^10.3.0",
- "get-east-asian-width": "^1.0.0",
- "strip-ansi": "^7.1.0"
- },
- "engines": {
- "node": ">=18"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/puppeteer-core/node_modules/devtools-protocol": {
- "version": "0.0.1666840",
- "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1666840.tgz",
- "integrity": "sha512-gCcO42XCHKEs7Ag0S7aGYsnJ7hlgrO3qderYqeiY0Eqk+0GFfuvT13IA0hHreJTa2KCdDVyGMeOhdMNmrrTjVg==",
+ "version": "0.0.1704951",
+ "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1704951.tgz",
+ "integrity": "sha512-GQhQOs9u/Mvm1zMtJIH872JS4AskuZdUSsPNPk4ChahtWAUqgz6atEtIsMt+nO7MqF1Ic4HxII/k8Cu36JivNg==",
"dev": true,
"license": "BSD-3-Clause"
},
- "node_modules/puppeteer-core/node_modules/emoji-regex": {
- "version": "10.6.0",
- "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
- "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
- "dev": true,
- "license": "MIT"
- },
- "node_modules/puppeteer-core/node_modules/string-width": {
- "version": "8.2.2",
- "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.2.2.tgz",
- "integrity": "sha512-GaPUh5gfdrYzqeVNZvUfT23vYYxXzKYidUcnMtJg/3rxRV63EFZy3k6xfKlmfeJD0176lnUV/Usr3XcwSvFzpg==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "get-east-asian-width": "^1.5.0",
- "strip-ansi": "^7.1.2"
- },
- "engines": {
- "node": ">=20"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
- "node_modules/puppeteer-core/node_modules/strip-ansi": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
- "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "ansi-regex": "^6.2.2"
- },
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/chalk/strip-ansi?sponsor=1"
- }
- },
- "node_modules/puppeteer-core/node_modules/wrap-ansi": {
- "version": "9.0.2",
- "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz",
- "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "ansi-styles": "^6.2.1",
- "string-width": "^7.0.0",
- "strip-ansi": "^7.1.0"
- },
- "engines": {
- "node": ">=18"
- },
- "funding": {
- "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
- }
- },
- "node_modules/puppeteer-core/node_modules/wrap-ansi/node_modules/string-width": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
- "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "emoji-regex": "^10.3.0",
- "get-east-asian-width": "^1.0.0",
- "strip-ansi": "^7.1.0"
- },
- "engines": {
- "node": ">=18"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
- "node_modules/puppeteer-core/node_modules/yargs": {
- "version": "18.1.0",
- "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.1.0.tgz",
- "integrity": "sha512-2rAgRKu54VsHkqI0/tYkmluGXHD4KW7yZoycuqDQ15QOTnc2VVfy0nN/1eMhnQLO00A+dwtK20xuCnc1YGeUyg==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "cliui": "^9.0.1",
- "escalade": "^3.1.1",
- "get-caller-file": "^2.0.5",
- "string-width": "^8.2.1",
- "y18n": "^5.0.5",
- "yargs-parser": "^22.0.0"
- },
- "engines": {
- "node": "^20.19.0 || ^22.12.0 || >=23"
- }
- },
- "node_modules/puppeteer-core/node_modules/yargs-parser": {
- "version": "22.0.0",
- "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz",
- "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==",
- "dev": true,
- "license": "ISC",
- "engines": {
- "node": "^20.19.0 || ^22.12.0 || >=23"
- }
- },
"node_modules/pvtsutils": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.6.tgz",
@@ -38619,9 +38554,9 @@
}
},
"node_modules/typed-query-selector": {
- "version": "2.12.2",
- "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.2.tgz",
- "integrity": "sha512-EOPFbyIub4ngnEdqi2yOcNeDLaX/0jcE1JoAXQDDMIthap7FoN795lc/SHfIq2d416VufXpM8z/lD+WRm2gfOQ==",
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.3.tgz",
+ "integrity": "sha512-/dtuMZyutHLlrxWhhC1uib00ELUr2dZ8C9B8YzZYsJmeE3V56OxRblrSM2UaF142pcMtak7ehZ6+poWGeehNIg==",
"dev": true,
"license": "MIT"
},
@@ -39654,9 +39589,9 @@
"license": "Apache-2.0"
},
"node_modules/webdriver-bidi-protocol": {
- "version": "0.4.3",
- "resolved": "https://registry.npmjs.org/webdriver-bidi-protocol/-/webdriver-bidi-protocol-0.4.3.tgz",
- "integrity": "sha512-uuN0goWfxP22B7J/uAgBpOYNPttC+XVseYE+rSY5+rQ+YBeVz/VORw8WbmLVcqW78zNg5A4qnjNXYUWR3il2ig==",
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/webdriver-bidi-protocol/-/webdriver-bidi-protocol-1.0.1.tgz",
+ "integrity": "sha512-WXWs/aXF2a6Al1Z2/V/7Gp2oPZOAAmHjJOTmv4KCXRJ122IMj3tSSMc6a4q3K4QOmhQbse/Ahr+oTVJOU2dUiw==",
"dev": true,
"license": "Apache-2.0"
},
@@ -40750,34 +40685,47 @@
}
},
"node_modules/zod": {
- "version": "3.25.67",
- "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.67.tgz",
- "integrity": "sha512-idA2YXwpCdqUSKRCACDE6ItZD9TZzy3OZMtpfLoh6oPR47lipysRrJfjzMqFxQ3uJuUPyUeWe1r9vLH33xO/Qw==",
+ "version": "4.6.7",
+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
+ "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
},
"node_modules/zod-openapi": {
- "version": "4.2.4",
- "resolved": "https://registry.npmjs.org/zod-openapi/-/zod-openapi-4.2.4.tgz",
- "integrity": "sha512-tsrQpbpqFCXqVXUzi3TPwFhuMtLN3oNZobOtYnK6/5VkXsNdnIgyNr4r8no4wmYluaxzN3F7iS+8xCW8BmMQ8g==",
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/zod-openapi/-/zod-openapi-6.0.2.tgz",
+ "integrity": "sha512-SwC5Ppi2ov8WimzNWP/XK95VqPyLDzxPYj10HgNPzhZH9gO7zx0sxdYL9eq7wOADHx1JddOApjhYDmMWQvnVnw==",
"dev": true,
"license": "MIT",
"engines": {
- "node": ">=18"
+ "node": ">=22.14.0"
+ },
+ "funding": {
+ "url": "https://github.com/samchungy/zod-openapi?sponsor=1"
},
"peerDependencies": {
- "zod": "^3.21.4"
+ "zod": "^4.0.0"
}
},
"node_modules/zod-to-json-schema": {
- "version": "3.25.1",
- "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.1.tgz",
- "integrity": "sha512-pM/SU9d3YAggzi6MtR4h7ruuQlqKtad8e9S0fmxcMi+ueAK5Korys/aWcV9LIIHTVbj01NdzxcnXSN+O74ZIVA==",
+ "version": "3.25.2",
+ "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz",
+ "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==",
"license": "ISC",
"peerDependencies": {
- "zod": "^3.25 || ^4"
+ "zod": "^3.25.28 || ^4"
+ }
+ },
+ "node_modules/zod-v4": {
+ "name": "zod",
+ "version": "4.6.7",
+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
+ "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/colinhacks"
}
},
"node_modules/zone.js": {
@@ -40849,7 +40797,7 @@
"winston": "^3.17.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"yauzl": "^3.2.1",
- "zod-openapi": "^4.2.4"
+ "zod-openapi": "^6.0.2"
},
"peerDependencies": {
"@anthropic-ai/vertex-sdk": "^0.16.0",
@@ -40862,7 +40810,7 @@
"@azure/identity": "^4.14.0",
"@azure/storage-blob": "^12.30.0",
"@keyv/redis": "5.1.6",
- "@librechat/agents": "^4.0.6",
+ "@librechat/agents": "^4.1.1",
"@librechat/data-schemas": "*",
"@modelcontextprotocol/sdk": "^1.32.1",
"@opentelemetry/api": "^1.9.0",
@@ -40917,7 +40865,8 @@
"sharp": "^0.35.5",
"undici": "^7.30.1",
"yauzl": "^3.2.1",
- "zod": "^3.22.4"
+ "zod": "^4.6.7",
+ "zod-to-json-schema": "^3.25.1"
}
},
"packages/api/node_modules/@babel/generator": {
@@ -43201,7 +43150,7 @@
"dayjs": "^1.11.13",
"js-yaml": "^4.3.2",
"re2js": "^2.8.6",
- "zod": "^3.22.4"
+ "zod": "^4.6.7"
},
"devDependencies": {
"@babel/preset-env": "^7.21.5",
diff --git a/packages/api/openapi/agents.openapi.json b/packages/api/openapi/agents.openapi.json
index 702acfe0d4..70fc480355 100644
--- a/packages/api/openapi/agents.openapi.json
+++ b/packages/api/openapi/agents.openapi.json
@@ -156,10 +156,10 @@
"in": "query",
"name": "limit",
"schema": {
+ "default": 20,
"type": "integer",
"minimum": 1,
- "maximum": 100,
- "default": 20
+ "maximum": 100
}
},
{
@@ -295,11 +295,12 @@
{
"in": "path",
"name": "id",
- "description": "The agent id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The agent id"
},
- "required": true
+ "required": true,
+ "description": "The agent id"
}
],
"responses": {
@@ -423,11 +424,12 @@
{
"in": "path",
"name": "id",
- "description": "The agent id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The agent id"
},
- "required": true
+ "required": true,
+ "description": "The agent id"
}
],
"requestBody": {
@@ -561,11 +563,12 @@
{
"in": "path",
"name": "id",
- "description": "The agent id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The agent id"
},
- "required": true
+ "required": true,
+ "description": "The agent id"
}
],
"responses": {
@@ -691,11 +694,12 @@
{
"in": "path",
"name": "id",
- "description": "The agent id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The agent id"
},
- "required": true
+ "required": true,
+ "description": "The agent id"
}
],
"requestBody": {
@@ -858,11 +862,12 @@
{
"in": "path",
"name": "id",
- "description": "The agent id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The agent id"
},
- "required": true
+ "required": true,
+ "description": "The agent id"
}
],
"responses": {
@@ -988,20 +993,22 @@
{
"in": "path",
"name": "id",
- "description": "The agent id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The agent id"
},
- "required": true
+ "required": true,
+ "description": "The agent id"
},
{
"in": "path",
"name": "fileId",
- "description": "The file id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The file id"
},
- "required": true
+ "required": true,
+ "description": "The file id"
}
],
"responses": {
@@ -1128,10 +1135,10 @@
"in": "query",
"name": "limit",
"schema": {
+ "default": 20,
"type": "integer",
"minimum": 1,
- "maximum": 100,
- "default": 20
+ "maximum": 100
}
},
{
@@ -1401,11 +1408,12 @@
{
"in": "path",
"name": "id",
- "description": "The skill id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The skill id"
},
- "required": true
+ "required": true,
+ "description": "The skill id"
}
],
"responses": {
@@ -1529,11 +1537,12 @@
{
"in": "path",
"name": "id",
- "description": "The skill id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The skill id"
},
- "required": true
+ "required": true,
+ "description": "The skill id"
}
],
"requestBody": {
@@ -1674,11 +1683,12 @@
{
"in": "path",
"name": "id",
- "description": "The skill id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The skill id"
},
- "required": true
+ "required": true,
+ "description": "The skill id"
}
],
"responses": {
@@ -1804,11 +1814,12 @@
{
"in": "path",
"name": "id",
- "description": "The skill id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The skill id"
},
- "required": true
+ "required": true,
+ "description": "The skill id"
}
],
"responses": {
@@ -1934,20 +1945,22 @@
{
"in": "path",
"name": "id",
- "description": "The skill id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The skill id"
},
- "required": true
+ "required": true,
+ "description": "The skill id"
},
{
"in": "path",
"name": "relativePath",
- "description": "The file path within the skill",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The file path within the skill"
},
- "required": true
+ "required": true,
+ "description": "The file path within the skill"
}
],
"responses": {
@@ -2071,20 +2084,22 @@
{
"in": "path",
"name": "id",
- "description": "The skill id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The skill id"
},
- "required": true
+ "required": true,
+ "description": "The skill id"
},
{
"in": "path",
"name": "relativePath",
- "description": "The file path within the skill",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The file path within the skill"
},
- "required": true
+ "required": true,
+ "description": "The file path within the skill"
}
],
"responses": {
@@ -2215,20 +2230,22 @@
{
"in": "path",
"name": "id",
- "description": "The skill id",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The skill id"
},
- "required": true
+ "required": true,
+ "description": "The skill id"
},
{
"in": "path",
"name": "relativePath",
- "description": "The file path within the skill",
"schema": {
- "type": "string"
+ "type": "string",
+ "description": "The file path within the skill"
},
- "required": true
+ "required": true,
+ "description": "The file path within the skill"
}
],
"requestBody": {
@@ -2360,14 +2377,6 @@
}
},
"components": {
- "securitySchemes": {
- "oidcBearer": {
- "type": "http",
- "scheme": "bearer",
- "bearerFormat": "JWT",
- "description": "An OIDC access token, sent as a bearer token."
- }
- },
"schemas": {
"AgentCreateRequest": {
"type": "object",
@@ -2391,33 +2400,40 @@
]
},
"avatar": {
- "type": [
- "object",
- "null"
- ],
- "properties": {
- "filepath": {
- "type": "string"
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "filepath": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "filepath",
+ "source"
+ ]
},
- "source": {
- "type": "string"
+ {
+ "type": "null"
}
- },
- "required": [
- "filepath",
- "source"
]
},
"model_parameters": {
"type": "object",
+ "propertyNames": {
+ "type": "string"
+ },
"additionalProperties": {}
},
"tools": {
+ "default": [],
"type": "array",
"items": {
"type": "string"
- },
- "default": []
+ }
},
"skills": {
"type": "array",
@@ -2531,12 +2547,12 @@
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"code_environment_ids": {
+ "maxItems": 128,
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
- },
- "maxItems": 128
+ }
},
"code_workspace_id": {
"anyOf": [
@@ -2656,6 +2672,9 @@
},
"tool_options": {
"type": "object",
+ "propertyNames": {
+ "type": "string"
+ },
"additionalProperties": {
"type": "object",
"properties": {
@@ -2689,7 +2708,8 @@
},
"approval_revision": {
"type": "string",
- "format": "uuid"
+ "format": "uuid",
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
}
}
}
@@ -2730,12 +2750,12 @@
"minLength": 1
},
"agent_ids": {
+ "minItems": 1,
+ "maxItems": 32,
"type": "array",
"items": {
"type": "string"
- },
- "minItems": 1,
- "maxItems": 32
+ }
},
"edges": {
"type": "array",
@@ -2748,11 +2768,11 @@
"type": "string"
},
{
+ "minItems": 1,
"type": "array",
"items": {
"type": "string"
- },
- "minItems": 1
+ }
}
]
},
@@ -2762,11 +2782,11 @@
"type": "string"
},
{
+ "minItems": 1,
"type": "array",
"items": {
"type": "string"
- },
- "minItems": 1
+ }
}
]
},
@@ -2826,7 +2846,8 @@
},
{
"type": "string",
- "format": "email"
+ "format": "email",
+ "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
}
]
}
@@ -2865,6 +2886,9 @@
},
"model_parameters": {
"type": "object",
+ "propertyNames": {
+ "type": "string"
+ },
"additionalProperties": {}
},
"tools": {
@@ -2981,19 +3005,23 @@
]
},
"code_environment_id": {
- "type": [
- "string",
- "null"
- ],
- "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
+ "anyOf": [
+ {
+ "type": "string",
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"code_environment_ids": {
+ "maxItems": 128,
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
- },
- "maxItems": 128
+ }
},
"code_workspace_id": {
"anyOf": [
@@ -3016,24 +3044,28 @@
]
},
"git_identity": {
- "type": [
- "object",
- "null"
- ],
- "properties": {
- "name": {
- "type": "string",
- "minLength": 1,
- "maxLength": 128
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 128
+ },
+ "email": {
+ "type": "string",
+ "maxLength": 254
+ }
+ },
+ "required": [
+ "name",
+ "email"
+ ]
},
- "email": {
- "type": "string",
- "maxLength": 254
+ {
+ "type": "null"
}
- },
- "required": [
- "name",
- "email"
]
},
"artifacts": {
@@ -3116,6 +3148,9 @@
},
"tool_options": {
"type": "object",
+ "propertyNames": {
+ "type": "string"
+ },
"additionalProperties": {
"type": "object",
"properties": {
@@ -3149,7 +3184,8 @@
},
"approval_revision": {
"type": "string",
- "format": "uuid"
+ "format": "uuid",
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
}
}
}
@@ -3190,12 +3226,12 @@
"minLength": 1
},
"agent_ids": {
+ "minItems": 1,
+ "maxItems": 32,
"type": "array",
"items": {
"type": "string"
- },
- "minItems": 1,
- "maxItems": 32
+ }
},
"edges": {
"type": "array",
@@ -3208,11 +3244,11 @@
"type": "string"
},
{
+ "minItems": 1,
"type": "array",
"items": {
"type": "string"
- },
- "minItems": 1
+ }
}
]
},
@@ -3222,11 +3258,11 @@
"type": "string"
},
{
+ "minItems": 1,
"type": "array",
"items": {
"type": "string"
- },
- "minItems": 1
+ }
}
]
},
@@ -3286,7 +3322,8 @@
},
{
"type": "string",
- "format": "email"
+ "format": "email",
+ "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
}
]
}
@@ -3349,6 +3386,9 @@
},
"model_parameters": {
"type": "object",
+ "propertyNames": {
+ "type": "string"
+ },
"additionalProperties": {}
},
"tools": {
@@ -3465,19 +3505,23 @@
]
},
"code_environment_id": {
- "type": [
- "string",
- "null"
- ],
- "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
+ "anyOf": [
+ {
+ "type": "string",
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"code_environment_ids": {
+ "maxItems": 128,
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
- },
- "maxItems": 128
+ }
},
"code_workspace_id": {
"anyOf": [
@@ -3500,24 +3544,28 @@
]
},
"git_identity": {
- "type": [
- "object",
- "null"
- ],
- "properties": {
- "name": {
- "type": "string",
- "minLength": 1,
- "maxLength": 128
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 128
+ },
+ "email": {
+ "type": "string",
+ "maxLength": 254
+ }
+ },
+ "required": [
+ "name",
+ "email"
+ ]
},
- "email": {
- "type": "string",
- "maxLength": 254
+ {
+ "type": "null"
}
- },
- "required": [
- "name",
- "email"
]
},
"artifacts": {
@@ -3600,6 +3648,9 @@
},
"tool_options": {
"type": "object",
+ "propertyNames": {
+ "type": "string"
+ },
"additionalProperties": {
"type": "object",
"properties": {
@@ -3633,7 +3684,8 @@
},
"approval_revision": {
"type": "string",
- "format": "uuid"
+ "format": "uuid",
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
}
}
}
@@ -3762,7 +3814,8 @@
},
{
"type": "string",
- "format": "email"
+ "format": "email",
+ "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
}
]
}
@@ -3786,15 +3839,18 @@
},
"version": {
"type": "integer",
- "minimum": 0
+ "minimum": 0,
+ "maximum": 9007199254740991
},
"createdAt": {
"type": "string",
- "format": "date-time"
+ "format": "date-time",
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
},
"updatedAt": {
"type": "string",
- "format": "date-time"
+ "format": "date-time",
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
}
},
"required": [
@@ -3807,71 +3863,6 @@
],
"additionalProperties": false
},
- "AgentList": {
- "type": "object",
- "properties": {
- "object": {
- "type": "string",
- "const": "list"
- },
- "data": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Agent"
- }
- },
- "first_id": {
- "type": [
- "string",
- "null"
- ]
- },
- "last_id": {
- "type": [
- "string",
- "null"
- ]
- },
- "has_more": {
- "type": "boolean"
- },
- "after": {
- "type": [
- "string",
- "null"
- ],
- "minLength": 1,
- "maxLength": 512
- }
- },
- "required": [
- "object",
- "data",
- "first_id",
- "last_id",
- "has_more",
- "after"
- ],
- "additionalProperties": false
- },
- "AgentDeleted": {
- "type": "object",
- "properties": {
- "id": {
- "type": "string",
- "minLength": 1
- },
- "deleted": {
- "type": "boolean",
- "const": true
- }
- },
- "required": [
- "id",
- "deleted"
- ],
- "additionalProperties": false
- },
"AgentFile": {
"type": "object",
"properties": {
@@ -3887,7 +3878,8 @@
},
"bytes": {
"type": "integer",
- "minimum": 0
+ "minimum": 0,
+ "maximum": 9007199254740991
},
"mime_type": {
"type": "string"
@@ -3899,11 +3891,16 @@
}
},
"created_at": {
- "type": [
- "string",
- "null"
- ],
- "format": "date-time"
+ "anyOf": [
+ {
+ "type": "string",
+ "format": "date-time",
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
+ },
+ {
+ "type": "null"
+ }
+ ]
}
},
"required": [
@@ -3916,6 +3913,225 @@
"created_at"
]
},
+ "SkillFrontmatterValue": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "number"
+ },
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ },
+ {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/SkillFrontmatterValue"
+ }
+ },
+ {
+ "type": "object",
+ "propertyNames": {
+ "type": "string"
+ },
+ "additionalProperties": {
+ "$ref": "#/components/schemas/SkillFrontmatterValue"
+ }
+ }
+ ]
+ },
+ "SkillCreateRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "displayTitle": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "body": {
+ "type": "string"
+ },
+ "frontmatter": {
+ "type": "object",
+ "propertyNames": {
+ "type": "string"
+ },
+ "additionalProperties": {
+ "$ref": "#/components/schemas/SkillFrontmatterValue"
+ }
+ },
+ "category": {
+ "type": "string"
+ },
+ "alwaysApply": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "name",
+ "description",
+ "body"
+ ],
+ "additionalProperties": false
+ },
+ "SkillUpdateRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "displayTitle": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "category": {
+ "type": "string"
+ },
+ "alwaysApply": {
+ "type": "boolean"
+ },
+ "body": {
+ "type": "string"
+ },
+ "frontmatter": {
+ "type": "object",
+ "propertyNames": {
+ "type": "string"
+ },
+ "additionalProperties": {
+ "$ref": "#/components/schemas/SkillFrontmatterValue"
+ }
+ },
+ "expectedVersion": {
+ "type": "integer",
+ "exclusiveMinimum": 0,
+ "maximum": 9007199254740991
+ }
+ },
+ "required": [
+ "expectedVersion"
+ ],
+ "additionalProperties": false,
+ "minProperties": 2
+ },
+ "SkillFile": {
+ "type": "object",
+ "properties": {
+ "relativePath": {
+ "type": "string"
+ },
+ "filename": {
+ "type": "string"
+ },
+ "mimeType": {
+ "type": "string"
+ },
+ "bytes": {
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 9007199254740991
+ }
+ },
+ "required": [
+ "relativePath",
+ "filename",
+ "mimeType",
+ "bytes"
+ ]
+ },
+ "SkillFileUpdateRequest": {
+ "type": "object",
+ "properties": {
+ "content": {
+ "type": "string",
+ "maxLength": 1048576,
+ "description": "The file content. The accepted maximum is 1 MiB (1,048,576 bytes) of UTF-8-encoded content. The limit is measured in bytes, not characters, so non-ASCII content reaches it at fewer characters."
+ }
+ },
+ "required": [
+ "content"
+ ],
+ "additionalProperties": false
+ },
+ "AgentList": {
+ "type": "object",
+ "properties": {
+ "object": {
+ "type": "string",
+ "const": "list"
+ },
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Agent"
+ }
+ },
+ "first_id": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "last_id": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "has_more": {
+ "type": "boolean"
+ },
+ "after": {
+ "anyOf": [
+ {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 512
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": [
+ "object",
+ "data",
+ "first_id",
+ "last_id",
+ "has_more",
+ "after"
+ ],
+ "additionalProperties": false
+ },
+ "AgentDeleted": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "minLength": 1
+ },
+ "deleted": {
+ "type": "boolean",
+ "const": true
+ }
+ },
+ "required": [
+ "id",
+ "deleted"
+ ],
+ "additionalProperties": false
+ },
"AgentFileList": {
"type": "object",
"properties": {
@@ -3978,13 +4194,9 @@
"path": {
"type": "array",
"items": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "number"
- }
+ "type": [
+ "string",
+ "number"
]
}
},
@@ -4012,34 +4224,6 @@
],
"additionalProperties": false
},
- "SkillFrontmatterValue": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "number"
- },
- {
- "type": "boolean"
- },
- {
- "type": "null"
- },
- {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/SkillFrontmatterValue"
- }
- },
- {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/components/schemas/SkillFrontmatterValue"
- }
- }
- ]
- },
"Skill": {
"type": "object",
"properties": {
@@ -4064,11 +4248,13 @@
},
"version": {
"type": "integer",
- "exclusiveMinimum": 0
+ "exclusiveMinimum": 0,
+ "maximum": 9007199254740991
},
"fileCount": {
"type": "integer",
- "minimum": 0
+ "minimum": 0,
+ "maximum": 9007199254740991
},
"disableModelInvocation": {
"type": "boolean"
@@ -4084,17 +4270,22 @@
},
"createdAt": {
"type": "string",
- "format": "date-time"
+ "format": "date-time",
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
},
"updatedAt": {
"type": "string",
- "format": "date-time"
+ "format": "date-time",
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
},
"body": {
"type": "string"
},
"frontmatter": {
"type": "object",
+ "propertyNames": {
+ "type": "string"
+ },
"additionalProperties": {
"$ref": "#/components/schemas/SkillFrontmatterValue"
}
@@ -4144,11 +4335,13 @@
},
"version": {
"type": "integer",
- "exclusiveMinimum": 0
+ "exclusiveMinimum": 0,
+ "maximum": 9007199254740991
},
"fileCount": {
"type": "integer",
- "minimum": 0
+ "minimum": 0,
+ "maximum": 9007199254740991
},
"disableModelInvocation": {
"type": "boolean"
@@ -4164,11 +4357,13 @@
},
"createdAt": {
"type": "string",
- "format": "date-time"
+ "format": "date-time",
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
},
"updatedAt": {
"type": "string",
- "format": "date-time"
+ "format": "date-time",
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
}
},
"required": [
@@ -4213,103 +4408,6 @@
"after"
]
},
- "SkillCreateRequest": {
- "type": "object",
- "properties": {
- "name": {
- "type": "string"
- },
- "displayTitle": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "body": {
- "type": "string"
- },
- "frontmatter": {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/components/schemas/SkillFrontmatterValue"
- }
- },
- "category": {
- "type": "string"
- },
- "alwaysApply": {
- "type": "boolean"
- }
- },
- "required": [
- "name",
- "description",
- "body"
- ],
- "additionalProperties": false
- },
- "SkillUpdateRequest": {
- "type": "object",
- "properties": {
- "name": {
- "type": "string"
- },
- "displayTitle": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "category": {
- "type": "string"
- },
- "alwaysApply": {
- "type": "boolean"
- },
- "body": {
- "type": "string"
- },
- "frontmatter": {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/components/schemas/SkillFrontmatterValue"
- }
- },
- "expectedVersion": {
- "type": "integer",
- "exclusiveMinimum": 0
- }
- },
- "required": [
- "expectedVersion"
- ],
- "additionalProperties": false,
- "minProperties": 2
- },
- "SkillFile": {
- "type": "object",
- "properties": {
- "relativePath": {
- "type": "string"
- },
- "filename": {
- "type": "string"
- },
- "mimeType": {
- "type": "string"
- },
- "bytes": {
- "type": "integer",
- "minimum": 0
- }
- },
- "required": [
- "relativePath",
- "filename",
- "mimeType",
- "bytes"
- ]
- },
"SkillFileList": {
"type": "object",
"properties": {
@@ -4343,7 +4441,8 @@
},
"bytes": {
"type": "integer",
- "minimum": 0
+ "minimum": 0,
+ "maximum": 9007199254740991
},
"content": {
"type": "string"
@@ -4360,20 +4459,6 @@
"isBinary"
]
},
- "SkillFileUpdateRequest": {
- "type": "object",
- "properties": {
- "content": {
- "type": "string",
- "maxLength": 1048576,
- "description": "The file content. The accepted maximum is 1 MiB (1,048,576 bytes) of UTF-8-encoded content. The limit is measured in bytes, not characters, so non-ASCII content reaches it at fewer characters."
- }
- },
- "required": [
- "content"
- ],
- "additionalProperties": false
- },
"SkillFileUpdated": {
"type": "object",
"properties": {
@@ -4382,7 +4467,8 @@
},
"bytes": {
"type": "integer",
- "minimum": 0
+ "minimum": 0,
+ "maximum": 9007199254740991
}
},
"required": [
@@ -4490,6 +4576,14 @@
],
"additionalProperties": false
}
+ },
+ "securitySchemes": {
+ "oidcBearer": {
+ "type": "http",
+ "scheme": "bearer",
+ "bearerFormat": "JWT",
+ "description": "An OIDC access token, sent as a bearer token."
+ }
}
}
}
diff --git a/packages/api/package.json b/packages/api/package.json
index 5a554885bd..adf66b7772 100644
--- a/packages/api/package.json
+++ b/packages/api/package.json
@@ -96,7 +96,7 @@
"winston": "^3.17.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"yauzl": "^3.2.1",
- "zod-openapi": "^4.2.4"
+ "zod-openapi": "^6.0.2"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
@@ -112,7 +112,7 @@
"@azure/identity": "^4.14.0",
"@azure/storage-blob": "^12.30.0",
"@keyv/redis": "5.1.6",
- "@librechat/agents": "^4.0.6",
+ "@librechat/agents": "^4.1.1",
"@librechat/data-schemas": "*",
"@modelcontextprotocol/sdk": "^1.32.1",
"@opentelemetry/api": "^1.9.0",
@@ -167,7 +167,8 @@
"sharp": "^0.35.5",
"undici": "^7.30.1",
"yauzl": "^3.2.1",
- "zod": "^3.22.4"
+ "zod": "^4.6.7",
+ "zod-to-json-schema": "^3.25.1"
},
"dependencies": {
"@langchain/langgraph-checkpoint": "^1.1.2",
diff --git a/packages/api/src/admin/roles.spec.ts b/packages/api/src/admin/roles.spec.ts
index 13f4359d1c..5e9e493796 100644
--- a/packages/api/src/admin/roles.spec.ts
+++ b/packages/api/src/admin/roles.spec.ts
@@ -1,5 +1,5 @@
import { Types } from 'mongoose';
-import { PrincipalType, SystemRoles } from 'librechat-data-provider';
+import { PrincipalType, SystemRoles, promptPermissionsSchema } from 'librechat-data-provider';
import type { IRole, IUser } from '@librechat/data-schemas';
import type { Response } from 'express';
import type { ServerRequest } from '~/types/http';
@@ -2518,17 +2518,7 @@ describe('admin role audit entries', () => {
describe('createRolePermissionsUpdateHandler', () => {
const config = {
- schema: {
- partial: () => ({
- parse: (value: unknown) => {
- const body = value as Record<string, unknown>;
- if (Object.values(body).some((v) => typeof v !== 'boolean')) {
- throw Object.assign(new Error('invalid'), { errors: ['bad value'] });
- }
- return body as Record<string, boolean>;
- },
- }),
- },
+ schema: promptPermissionsSchema,
permissionType: 'PROMPTS',
errorMessage: 'Invalid prompt permissions.',
};
@@ -2602,7 +2592,7 @@ describe('createRolePermissionsUpdateHandler', () => {
expect(status).toHaveBeenCalledWith(400);
expect(send).toHaveBeenCalledWith({
message: 'Invalid prompt permissions.',
- error: ['bad value'],
+ error: [expect.objectContaining({ code: 'invalid_type', path: ['USE'] })],
});
expect(deps.updateRoleByName).not.toHaveBeenCalled();
});
diff --git a/packages/api/src/admin/roles.ts b/packages/api/src/admin/roles.ts
index 94a2fd39d1..c025318f79 100644
--- a/packages/api/src/admin/roles.ts
+++ b/packages/api/src/admin/roles.ts
@@ -1,4 +1,4 @@
-import { PrincipalType, SystemRoles } from 'librechat-data-provider';
+import { PrincipalType, SystemRoles, partialWithoutDefaults } from 'librechat-data-provider';
import {
logger,
RoleConflictError,
@@ -18,6 +18,7 @@ import type {
} from '@librechat/data-schemas';
import type { FilterQuery, Types } from 'mongoose';
import type { Response } from 'express';
+import type { z } from 'zod';
import type { ServerRequest } from '~/types/http';
import type { RecordAuditEntry } from './audit';
import type { CascadeStep } from './cascade';
@@ -1311,8 +1312,8 @@ export interface RolePermissionsUpdateDeps {
}
export interface RolePermissionsUpdateConfig {
- /** Zod object schema for one permission type; parsed as a partial update. */
- schema: { partial: () => { parse: (value: unknown) => Record<string, boolean | undefined> } };
+ /** Zod object schema for one permission type; parsed as a partial update without its defaults. */
+ schema: z.ZodObject<Record<string, z.ZodType<boolean, boolean | undefined>>>;
permissionType: string;
errorMessage: string;
}
@@ -1335,14 +1336,11 @@ export function createRolePermissionsUpdateHandler(
return async function updateRolePermissions(req, res) {
const { roleName } = req.params as { roleName: string };
- let parsedUpdates: Record<string, boolean | undefined>;
- try {
- parsedUpdates = config.schema.partial().parse(req.body);
- } catch (error) {
- return res
- .status(400)
- .send({ message: config.errorMessage, error: (error as { errors?: unknown }).errors });
+ const parsed = partialWithoutDefaults(config.schema).safeParse(req.body);
+ if (!parsed.success) {
+ return res.status(400).send({ message: config.errorMessage, error: parsed.error.issues });
}
+ const parsedUpdates: Record<string, boolean | undefined> = parsed.data;
try {
const role = await getRoleByName(roleName);
diff --git a/packages/api/src/agents/hitl/askUserQuestionTool.ts b/packages/api/src/agents/hitl/askUserQuestionTool.ts
index 07dead25f3..8ecaf60f5a 100644
--- a/packages/api/src/agents/hitl/askUserQuestionTool.ts
+++ b/packages/api/src/agents/hitl/askUserQuestionTool.ts
@@ -58,19 +58,14 @@ const ASK_USER_QUESTION_DESCRIPTION = [
* `askUserQuestions()` unchanged, so this schema is the wire shape inside the
* pending-action payload.
*/
-const askUserQuestionItemSchema: z.ZodObject<
- {
- id: z.ZodString;
- header: z.ZodOptional<z.ZodString>;
- question: z.ZodString;
- description: z.ZodOptional<z.ZodString>;
- options: z.ZodOptional<
- z.ZodArray<z.ZodObject<{ label: z.ZodString; value: z.ZodString }, 'strip'>, 'many'>
- >;
- multiSelect: z.ZodOptional<z.ZodBoolean>;
- },
- 'strip'
-> = z.object({
+const askUserQuestionItemSchema: z.ZodObject<{
+ id: z.ZodString;
+ header: z.ZodOptional<z.ZodString>;
+ question: z.ZodString;
+ description: z.ZodOptional<z.ZodString>;
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{ label: z.ZodString; value: z.ZodString }>>>;
+ multiSelect: z.ZodOptional<z.ZodBoolean>;
+}> = z.object({
id: z
.string()
.regex(ASK_USER_QUESTION_ID_PATTERN)
@@ -117,7 +112,7 @@ const askUserQuestionItemSchema: z.ZodObject<
.describe('Allow the user to pick several options; their values are returned joined by ", ".'),
});
-const askUserQuestionsArraySchema: z.ZodEffects<z.ZodArray<typeof askUserQuestionItemSchema>> = z
+const askUserQuestionsArraySchema: z.ZodArray<typeof askUserQuestionItemSchema> = z
.array(askUserQuestionItemSchema)
.min(1)
.max(MAX_ASK_USER_QUESTIONS)
@@ -131,10 +126,9 @@ const askUserQuestionsArraySchema: z.ZodEffects<z.ZodArray<typeof askUserQuestio
const legacyAskUserQuestionToolSchema = askUserQuestionItemSchema.omit({ id: true, header: true });
-export const askUserQuestionToolSchema: z.ZodObject<
- { questions: typeof askUserQuestionsArraySchema },
- 'strip'
-> = z.object({
+export const askUserQuestionToolSchema: z.ZodObject<{
+ questions: typeof askUserQuestionsArraySchema;
+}> = z.object({
questions: askUserQuestionsArraySchema,
});
diff --git a/packages/api/src/agents/hooks/schema.ts b/packages/api/src/agents/hooks/schema.ts
index e5882a9c12..9d62041ccb 100644
--- a/packages/api/src/agents/hooks/schema.ts
+++ b/packages/api/src/agents/hooks/schema.ts
@@ -163,7 +163,7 @@ export const pluginHooksDocumentSchema: z.ZodType<PluginHooksDocument> = z
}
context.addIssue({
code: z.ZodIssueCode.too_big,
- type: 'array',
+ origin: 'array',
maximum: MAX_TOTAL_HANDLERS,
inclusive: true,
path: ['hooks'],
diff --git a/packages/api/src/agents/management.ts b/packages/api/src/agents/management.ts
index 1c51e313fd..c2311185cd 100644
--- a/packages/api/src/agents/management.ts
+++ b/packages/api/src/agents/management.ts
@@ -106,7 +106,6 @@ export type AgentManagementError = {
*/
export const agentManagementCreateSchema: z.ZodType<
AgentManagementCreate,
- z.ZodTypeDef,
AgentManagementCreateInput
> = agentCreateSchema.omit({ instructionsPrompt: true }).extend({ model: z.string() }).strict();
export const agentManagementUpdateSchema: z.ZodType<AgentManagementUpdate> = agentUpdateSchema
@@ -143,7 +142,7 @@ const agentManagementCursorSchema = z
}
});
-export const agentManagementListSchema: z.ZodType<AgentManagementList, z.ZodTypeDef, unknown> = z
+export const agentManagementListSchema: z.ZodType<AgentManagementList, unknown> = z
.object({
limit: z.coerce.number().int().min(1).max(MAX_LIST_LIMIT).default(DEFAULT_LIST_LIMIT),
cursor: agentManagementCursorSchema.optional(),
diff --git a/packages/api/src/agents/validation.spec.ts b/packages/api/src/agents/validation.spec.ts
index 025a6541d7..7af87e16fd 100644
--- a/packages/api/src/agents/validation.spec.ts
+++ b/packages/api/src/agents/validation.spec.ts
@@ -62,7 +62,10 @@ describe('agent Git identity validation', () => {
const regexCheck = jest.spyOn(RegExp.prototype, 'test');
const result = schema.safeParse({ ...base, git_identity: { name: 'Lia', email } });
- const regexCheckedEmail = regexCheck.mock.calls.some(([value]) => value === email);
+ const regexCheckedEmail = regexCheck.mock.calls.some(
+ ([value], index) =>
+ value === email && !regexCheck.mock.contexts[index].source.startsWith('[\\uD800'),
+ );
regexCheck.mockRestore();
expect(result.success).toBe(false);
diff --git a/packages/api/src/agents/validation.ts b/packages/api/src/agents/validation.ts
index fbe4aeb83c..cadfffe4c7 100644
--- a/packages/api/src/agents/validation.ts
+++ b/packages/api/src/agents/validation.ts
@@ -30,56 +30,52 @@ import { getToolOptionsLimitError } from './options';
*/
type LooseRequest = Request<unknown, unknown, unknown>;
-const agentCodeWorkspaceIdSchema: z.ZodUnion<[z.ZodLiteral<''>, z.ZodString]> = z.union([
+/** A string enum schema over the literal union `T`. */
+type EnumOf<T extends string> = z.ZodEnum<{ [K in T]: K }>;
+
+/** An optional field whose empty string parses as `undefined`. */
+type BlankAsUndefined<T extends z.ZodType> = z.ZodOptional<
+ z.ZodPipe<z.ZodOptional<T>, z.ZodTransform<z.output<T> | undefined, z.output<T> | undefined>>
+>;
+
+const agentCodeWorkspaceIdSchema: z.ZodUnion<readonly [z.ZodLiteral<''>, z.ZodString]> = z.union([
z.literal(''),
z.string().regex(CODE_WORKSPACE_ID_PATTERN),
]);
/** Avatar schema shared between create and update */
-export const agentAvatarSchema: z.ZodObject<
- {
- filepath: z.ZodString;
- source: z.ZodString;
- },
- 'strip'
-> = z.object({
+export const agentAvatarSchema: z.ZodObject<{
+ filepath: z.ZodString;
+ source: z.ZodString;
+}> = z.object({
filepath: z.string(),
source: z.string(),
});
/** Persisted resource schema. Full file records are populated only after database authorization. */
-export const agentBaseResourceSchema: z.ZodObject<
- {
- file_ids: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- },
- 'strip'
-> = z.object({
+export const agentBaseResourceSchema: z.ZodObject<{
+ file_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
+}> = z.object({
file_ids: z.array(z.string()).optional(),
});
/** File resource schema extends base with vector_store_ids. */
-export const agentFileResourceSchema: z.ZodObject<
- {
- file_ids: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- vector_store_ids: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- },
- 'strip'
-> = agentBaseResourceSchema.extend({
+export const agentFileResourceSchema: z.ZodObject<{
+ file_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
+ vector_store_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
+}> = agentBaseResourceSchema.extend({
vector_store_ids: z.array(z.string()).optional(),
});
/** Persisted tool resources accepted by Agent create and update APIs. */
export const agentToolResourcesSchema: z.ZodOptional<
- z.ZodObject<
- {
- image_edit: z.ZodOptional<typeof agentBaseResourceSchema>;
- execute_code: z.ZodOptional<typeof agentBaseResourceSchema>;
- file_search: z.ZodOptional<typeof agentFileResourceSchema>;
- context: z.ZodOptional<typeof agentBaseResourceSchema>;
- ocr: z.ZodOptional<typeof agentBaseResourceSchema>;
- },
- 'strip'
- >
+ z.ZodObject<{
+ image_edit: z.ZodOptional<typeof agentBaseResourceSchema>;
+ execute_code: z.ZodOptional<typeof agentBaseResourceSchema>;
+ file_search: z.ZodOptional<typeof agentFileResourceSchema>;
+ context: z.ZodOptional<typeof agentBaseResourceSchema>;
+ ocr: z.ZodOptional<typeof agentBaseResourceSchema>;
+ }>
> = z
.object({
image_edit: agentBaseResourceSchema.optional(),
@@ -93,22 +89,10 @@ export const agentToolResourcesSchema: z.ZodOptional<
/** Support contact schema for agent */
export const agentSupportContactSchema: z.ZodOptional<
- z.ZodObject<
- {
- name: z.ZodOptional<z.ZodString>;
- email: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<''>, z.ZodString]>>;
- },
- 'strip',
- z.ZodTypeAny,
- {
- name?: string | undefined;
- email?: string | undefined;
- },
- {
- name?: string | undefined;
- email?: string | undefined;
- }
- >
+ z.ZodObject<{
+ name: z.ZodOptional<z.ZodString>;
+ email: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<''>, z.ZodString]>>;
+ }>
> = z
.object({
name: z.string().optional(),
@@ -117,54 +101,45 @@ export const agentSupportContactSchema: z.ZodOptional<
.optional();
/** Graph edge schema for agent handoffs */
-export const graphEdgeSchema: z.ZodObject<
- {
- from: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, 'many'>]>;
- to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, 'many'>]>;
- description: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
- edgeType: z.ZodOptional<z.ZodEnum<['handoff', 'direct']>>;
- prompt: z.ZodEffects<
- z.ZodOptional<
- z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>]>
- >,
- string | ((...args: unknown[]) => unknown) | undefined,
- string | ((...args: unknown[]) => unknown) | undefined
- >;
- excludeResults: z.ZodOptional<z.ZodBoolean>;
- promptKey: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
- },
- 'strip'
-> = z.object({
+export const graphEdgeSchema: z.ZodObject<{
+ from: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
+ to: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
+ description: BlankAsUndefined<z.ZodString>;
+ edgeType: z.ZodOptional<EnumOf<'handoff' | 'direct'>>;
+ prompt: BlankAsUndefined<z.ZodUnion<readonly [z.ZodString, z.ZodFunction]>>;
+ excludeResults: z.ZodOptional<z.ZodBoolean>;
+ promptKey: BlankAsUndefined<z.ZodString>;
+}> = z.object({
from: z.union([z.string(), z.array(z.string())]),
to: z.union([z.string(), z.array(z.string())]),
description: z
.string()
.optional()
- .transform((v) => (v === '' ? undefined : v)),
+ .transform((v) => (v === '' ? undefined : v))
+ .optional(),
edgeType: z.enum(['handoff', 'direct']).optional(),
prompt: z
.union([z.string(), z.function()])
.optional()
- .transform((v) => (v === '' ? undefined : v)),
+ .transform((v) => (v === '' ? undefined : v))
+ .optional(),
excludeResults: z.boolean().optional(),
promptKey: z
.string()
.optional()
- .transform((v) => (v === '' ? undefined : v)),
+ .transform((v) => (v === '' ? undefined : v))
+ .optional(),
});
/** Per-tool options schema (defer_loading, allowed_callers, run_in_background, describe_intent) */
-export const toolOptionsSchema: z.ZodObject<
- {
- defer_loading: z.ZodOptional<z.ZodBoolean>;
- allowed_callers: z.ZodOptional<z.ZodArray<z.ZodEnum<['direct', 'code_execution']>, 'many'>>;
- run_in_background: z.ZodOptional<z.ZodBoolean>;
- describe_intent: z.ZodOptional<z.ZodBoolean>;
- approval_mode: z.ZodOptional<z.ZodEnum<['ask', 'allow', 'chat', 'always']>>;
- approval_revision: z.ZodOptional<z.ZodString>;
- },
- 'strip'
-> = z.object({
+export const toolOptionsSchema: z.ZodObject<{
+ defer_loading: z.ZodOptional<z.ZodBoolean>;
+ allowed_callers: z.ZodOptional<z.ZodArray<EnumOf<'direct' | 'code_execution'>>>;
+ run_in_background: z.ZodOptional<z.ZodBoolean>;
+ describe_intent: z.ZodOptional<z.ZodBoolean>;
+ approval_mode: z.ZodOptional<EnumOf<'ask' | 'allow' | 'chat' | 'always'>>;
+ approval_revision: z.ZodOptional<z.ZodString>;
+}> = z.object({
defer_loading: z.boolean().optional(),
allowed_callers: z.array(z.enum(['direct', 'code_execution'])).optional(),
run_in_background: z.boolean().optional(),
@@ -175,7 +150,7 @@ export const toolOptionsSchema: z.ZodObject<
/** Agent tool options - map of tool_id to tool options */
export const agentToolOptionsSchema: z.ZodOptional<
- z.ZodEffects<z.ZodRecord<z.ZodString, typeof toolOptionsSchema>>
+ z.ZodRecord<z.ZodString, typeof toolOptionsSchema>
> = z
.record(z.string(), toolOptionsSchema)
.superRefine((options, ctx) => {
@@ -434,134 +409,49 @@ const agentInstructionsPromptFieldSchema: z.ZodOptional<
z.ZodNullable<typeof agentInstructionsPromptSchema>
> = agentInstructionsPromptSchema.nullable().optional();
-export const agentBaseSchema: z.ZodObject<
- {
- name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
- description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
- instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
- instructionsPrompt: z.ZodOptional<z.ZodNullable<typeof agentInstructionsPromptSchema>>;
- avatar: z.ZodOptional<
- z.ZodNullable<
- z.ZodObject<
- {
- filepath: z.ZodString;
- source: z.ZodString;
- },
- 'strip',
- z.ZodTypeAny,
- {
- source: string;
- filepath: string;
- },
- {
- source: string;
- filepath: string;
- }
- >
- >
- >;
- model_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
- tools: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- skills: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- skills_enabled: z.ZodOptional<z.ZodBoolean>;
- skill_authoring_enabled: z.ZodOptional<z.ZodBoolean>;
- skills_scope: z.ZodOptional<z.ZodNativeEnum<typeof SkillsScope>>;
- memory_scope: z.ZodOptional<z.ZodNativeEnum<typeof MemoryScope>>;
- /** @deprecated Use edges instead */
- agent_ids: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- edges: z.ZodOptional<
- z.ZodArray<
- z.ZodObject<
- {
- from: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, 'many'>]>;
- to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, 'many'>]>;
- description: z.ZodEffects<
- z.ZodOptional<z.ZodString>,
- string | undefined,
- string | undefined
- >;
- edgeType: z.ZodOptional<z.ZodEnum<['handoff', 'direct']>>;
- prompt: z.ZodEffects<
- z.ZodOptional<
- z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>]>
- >,
- string | ((...args: unknown[]) => unknown) | undefined,
- string | ((...args: unknown[]) => unknown) | undefined
- >;
- excludeResults: z.ZodOptional<z.ZodBoolean>;
- promptKey: z.ZodEffects<
- z.ZodOptional<z.ZodString>,
- string | undefined,
- string | undefined
- >;
- },
- 'strip',
- z.ZodTypeAny,
- {
- from: string | string[];
- to: string | string[];
- description?: string | undefined;
- prompt?: string | ((...args: unknown[]) => unknown) | undefined;
- edgeType?: 'direct' | 'handoff' | undefined;
- excludeResults?: boolean | undefined;
- promptKey?: string | undefined;
- },
- {
- from: string | string[];
- to: string | string[];
- description?: string | undefined;
- prompt?: string | ((...args: unknown[]) => unknown) | undefined;
- edgeType?: 'direct' | 'handoff' | undefined;
- excludeResults?: boolean | undefined;
- promptKey?: string | undefined;
- }
- >,
- 'many'
- >
- >;
- end_after_tools: z.ZodOptional<z.ZodBoolean>;
- hide_sequential_outputs: z.ZodOptional<z.ZodBoolean>;
- stateful_code_sessions: z.ZodOptional<z.ZodBoolean>;
- stateful_code_environment: z.ZodOptional<z.ZodEnum<['user', 'agent-user', 'conversation']>>;
- code_environment_id: z.ZodOptional<z.ZodString>;
- code_environment_ids: z.ZodOptional<typeof agentCodeEnvironmentIdsSchema>;
- code_workspace_id: z.ZodOptional<typeof agentCodeWorkspaceIdSchema>;
- repositoryInstructions: z.ZodOptional<z.ZodEnum<['prefer', 'defer', 'off']>>;
- git_identity: typeof agentGitIdentitySchema;
- artifacts: z.ZodOptional<z.ZodString>;
- recursion_limit: z.ZodOptional<z.ZodNumber>;
- conversation_starters: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- tool_resources: typeof agentToolResourcesSchema;
- tool_options: typeof agentToolOptionsSchema;
- subagents: typeof agentSubagentsSchema;
- support_contact: z.ZodOptional<
- z.ZodObject<
- {
- name: z.ZodOptional<z.ZodString>;
- email: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<''>, z.ZodString]>>;
- },
- 'strip',
- z.ZodTypeAny,
- {
- name?: string | undefined;
- email?: string | undefined;
- },
- {
- name?: string | undefined;
- email?: string | undefined;
- }
- >
- >;
- category: z.ZodOptional<z.ZodString>;
- },
- 'strip'
-> = z.object({
+/** Fields shared by the agent create and update schemas. */
+type AgentBaseShape = {
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
+ instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
+ instructionsPrompt: typeof agentInstructionsPromptFieldSchema;
+ avatar: z.ZodOptional<z.ZodNullable<typeof agentAvatarSchema>>;
+ model_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
+ tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
+ skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
+ skills_enabled: z.ZodOptional<z.ZodBoolean>;
+ skill_authoring_enabled: z.ZodOptional<z.ZodBoolean>;
+ skills_scope: z.ZodOptional<z.ZodEnum<typeof SkillsScope>>;
+ memory_scope: z.ZodOptional<z.ZodEnum<typeof MemoryScope>>;
+ /** @deprecated Use edges instead */
+ agent_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
+ edges: z.ZodOptional<z.ZodArray<typeof graphEdgeSchema>>;
+ end_after_tools: z.ZodOptional<z.ZodBoolean>;
+ hide_sequential_outputs: z.ZodOptional<z.ZodBoolean>;
+ stateful_code_sessions: z.ZodOptional<z.ZodBoolean>;
+ stateful_code_environment: z.ZodOptional<EnumOf<'user' | 'agent-user' | 'conversation'>>;
+ code_environment_id: z.ZodOptional<z.ZodString>;
+ code_environment_ids: z.ZodOptional<typeof agentCodeEnvironmentIdsSchema>;
+ code_workspace_id: z.ZodOptional<typeof agentCodeWorkspaceIdSchema>;
+ repositoryInstructions: z.ZodOptional<EnumOf<'prefer' | 'defer' | 'off'>>;
+ git_identity: typeof agentGitIdentitySchema;
+ artifacts: z.ZodOptional<z.ZodString>;
+ recursion_limit: z.ZodOptional<z.ZodNumber>;
+ conversation_starters: z.ZodOptional<z.ZodArray<z.ZodString>>;
+ tool_resources: typeof agentToolResourcesSchema;
+ tool_options: typeof agentToolOptionsSchema;
+ subagents: typeof agentSubagentsSchema;
+ support_contact: typeof agentSupportContactSchema;
+ category: z.ZodOptional<z.ZodString>;
+};
+
+export const agentBaseSchema: z.ZodObject<AgentBaseShape> = z.object({
name: z.string().nullable().optional(),
description: z.string().nullable().optional(),
instructions: z.string().nullable().optional(),
instructionsPrompt: agentInstructionsPromptFieldSchema,
avatar: agentAvatarSchema.nullable().optional(),
- model_parameters: z.record(z.unknown()).optional(),
+ model_parameters: z.record(z.string(), z.unknown()).optional(),
tools: z.array(z.string()).optional(),
skills: z.array(z.string()).optional(),
skills_enabled: z.boolean().optional(),
@@ -592,128 +482,11 @@ export const agentBaseSchema: z.ZodObject<
/** Create schema extends base with required fields for creation */
export const agentCreateSchema: z.ZodObject<
- {
- name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
- description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
- instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
- instructionsPrompt: z.ZodOptional<z.ZodNullable<typeof agentInstructionsPromptSchema>>;
- avatar: z.ZodOptional<
- z.ZodNullable<
- z.ZodObject<
- {
- filepath: z.ZodString;
- source: z.ZodString;
- },
- 'strip',
- z.ZodTypeAny,
- {
- source: string;
- filepath: string;
- },
- {
- source: string;
- filepath: string;
- }
- >
- >
- >;
- model_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
- skills: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- skills_enabled: z.ZodOptional<z.ZodBoolean>;
- skill_authoring_enabled: z.ZodOptional<z.ZodBoolean>;
- skills_scope: z.ZodOptional<z.ZodNativeEnum<typeof SkillsScope>>;
- memory_scope: z.ZodOptional<z.ZodNativeEnum<typeof MemoryScope>>;
- agent_ids: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- edges: z.ZodOptional<
- z.ZodArray<
- z.ZodObject<
- {
- from: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, 'many'>]>;
- to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, 'many'>]>;
- description: z.ZodEffects<
- z.ZodOptional<z.ZodString>,
- string | undefined,
- string | undefined
- >;
- edgeType: z.ZodOptional<z.ZodEnum<['handoff', 'direct']>>;
- prompt: z.ZodEffects<
- z.ZodOptional<
- z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>]>
- >,
- string | ((...args: unknown[]) => unknown) | undefined,
- string | ((...args: unknown[]) => unknown) | undefined
- >;
- excludeResults: z.ZodOptional<z.ZodBoolean>;
- promptKey: z.ZodEffects<
- z.ZodOptional<z.ZodString>,
- string | undefined,
- string | undefined
- >;
- },
- 'strip',
- z.ZodTypeAny,
- {
- from: string | string[];
- to: string | string[];
- description?: string | undefined;
- prompt?: string | ((...args: unknown[]) => unknown) | undefined;
- edgeType?: 'direct' | 'handoff' | undefined;
- excludeResults?: boolean | undefined;
- promptKey?: string | undefined;
- },
- {
- from: string | string[];
- to: string | string[];
- description?: string | undefined;
- prompt?: string | ((...args: unknown[]) => unknown) | undefined;
- edgeType?: 'direct' | 'handoff' | undefined;
- excludeResults?: boolean | undefined;
- promptKey?: string | undefined;
- }
- >,
- 'many'
- >
- >;
- end_after_tools: z.ZodOptional<z.ZodBoolean>;
- hide_sequential_outputs: z.ZodOptional<z.ZodBoolean>;
- stateful_code_sessions: z.ZodOptional<z.ZodBoolean>;
- stateful_code_environment: z.ZodOptional<z.ZodEnum<['user', 'agent-user', 'conversation']>>;
- code_environment_id: z.ZodOptional<z.ZodString>;
- code_environment_ids: z.ZodOptional<typeof agentCodeEnvironmentIdsSchema>;
- git_identity: typeof agentGitIdentitySchema;
- code_workspace_id: z.ZodOptional<typeof agentCodeWorkspaceIdSchema>;
- repositoryInstructions: z.ZodOptional<z.ZodEnum<['prefer', 'defer', 'off']>>;
- artifacts: z.ZodOptional<z.ZodString>;
- recursion_limit: z.ZodOptional<z.ZodNumber>;
- conversation_starters: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- tool_resources: typeof agentToolResourcesSchema;
- tool_options: typeof agentToolOptionsSchema;
- subagents: typeof agentSubagentsSchema;
- support_contact: z.ZodOptional<
- z.ZodObject<
- {
- name: z.ZodOptional<z.ZodString>;
- email: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<''>, z.ZodString]>>;
- },
- 'strip',
- z.ZodTypeAny,
- {
- name?: string | undefined;
- email?: string | undefined;
- },
- {
- name?: string | undefined;
- email?: string | undefined;
- }
- >
- >;
- category: z.ZodOptional<z.ZodString>;
- } & {
+ Omit<AgentBaseShape, 'tools'> & {
provider: z.ZodString;
model: z.ZodNullable<z.ZodString>;
- tools: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>>;
- },
- 'strip'
+ tools: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
+ }
> = agentBaseSchema.extend({
provider: z.string(),
model: z.string().nullable(),
@@ -722,131 +495,13 @@ export const agentCreateSchema: z.ZodObject<
/** Update schema extends base with all fields optional and additional update-only fields */
export const agentUpdateSchema: z.ZodObject<
- {
- name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
- description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
- instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
- instructionsPrompt: z.ZodOptional<z.ZodNullable<typeof agentInstructionsPromptSchema>>;
- model_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
- tools: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- skills: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- skills_enabled: z.ZodOptional<z.ZodBoolean>;
- skill_authoring_enabled: z.ZodOptional<z.ZodBoolean>;
- skills_scope: z.ZodOptional<z.ZodNativeEnum<typeof SkillsScope>>;
- memory_scope: z.ZodOptional<z.ZodNativeEnum<typeof MemoryScope>>;
- agent_ids: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- edges: z.ZodOptional<
- z.ZodArray<
- z.ZodObject<
- {
- from: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, 'many'>]>;
- to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, 'many'>]>;
- description: z.ZodEffects<
- z.ZodOptional<z.ZodString>,
- string | undefined,
- string | undefined
- >;
- edgeType: z.ZodOptional<z.ZodEnum<['handoff', 'direct']>>;
- prompt: z.ZodEffects<
- z.ZodOptional<
- z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>]>
- >,
- string | ((...args: unknown[]) => unknown) | undefined,
- string | ((...args: unknown[]) => unknown) | undefined
- >;
- excludeResults: z.ZodOptional<z.ZodBoolean>;
- promptKey: z.ZodEffects<
- z.ZodOptional<z.ZodString>,
- string | undefined,
- string | undefined
- >;
- },
- 'strip',
- z.ZodTypeAny,
- {
- from: string | string[];
- to: string | string[];
- description?: string | undefined;
- prompt?: string | ((...args: unknown[]) => unknown) | undefined;
- edgeType?: 'direct' | 'handoff' | undefined;
- excludeResults?: boolean | undefined;
- promptKey?: string | undefined;
- },
- {
- from: string | string[];
- to: string | string[];
- description?: string | undefined;
- prompt?: string | ((...args: unknown[]) => unknown) | undefined;
- edgeType?: 'direct' | 'handoff' | undefined;
- excludeResults?: boolean | undefined;
- promptKey?: string | undefined;
- }
- >,
- 'many'
- >
- >;
- end_after_tools: z.ZodOptional<z.ZodBoolean>;
- hide_sequential_outputs: z.ZodOptional<z.ZodBoolean>;
- stateful_code_sessions: z.ZodOptional<z.ZodBoolean>;
- stateful_code_environment: z.ZodOptional<z.ZodEnum<['user', 'agent-user', 'conversation']>>;
+ Omit<AgentBaseShape, 'avatar' | 'code_environment_id' | 'git_identity'> & {
+ avatar: z.ZodOptional<z.ZodUnion<readonly [typeof agentAvatarSchema, z.ZodNull]>>;
code_environment_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
- code_environment_ids: z.ZodOptional<typeof agentCodeEnvironmentIdsSchema>;
- code_workspace_id: z.ZodOptional<typeof agentCodeWorkspaceIdSchema>;
- repositoryInstructions: z.ZodOptional<z.ZodEnum<['prefer', 'defer', 'off']>>;
git_identity: typeof agentGitIdentityUpdateSchema;
- artifacts: z.ZodOptional<z.ZodString>;
- recursion_limit: z.ZodOptional<z.ZodNumber>;
- conversation_starters: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
- tool_resources: typeof agentToolResourcesSchema;
- tool_options: typeof agentToolOptionsSchema;
- subagents: typeof agentSubagentsSchema;
- support_contact: z.ZodOptional<
- z.ZodObject<
- {
- name: z.ZodOptional<z.ZodString>;
- email: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<''>, z.ZodString]>>;
- },
- 'strip',
- z.ZodTypeAny,
- {
- name?: string | undefined;
- email?: string | undefined;
- },
- {
- name?: string | undefined;
- email?: string | undefined;
- }
- >
- >;
- category: z.ZodOptional<z.ZodString>;
- } & {
- avatar: z.ZodOptional<
- z.ZodUnion<
- [
- z.ZodObject<
- {
- filepath: z.ZodString;
- source: z.ZodString;
- },
- 'strip',
- z.ZodTypeAny,
- {
- source: string;
- filepath: string;
- },
- {
- source: string;
- filepath: string;
- }
- >,
- z.ZodNull,
- ]
- >
- >;
provider: z.ZodOptional<z.ZodString>;
model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
- },
- 'strip'
+ }
> = agentBaseSchema.extend({
avatar: z.union([agentAvatarSchema, z.null()]).optional(),
code_environment_id: agentCodeEnvironmentIdSchema.nullable().optional(),
diff --git a/packages/api/src/app/loader.ts b/packages/api/src/app/loader.ts
index f8a4c8c4d8..b3fd1885d1 100644
--- a/packages/api/src/app/loader.ts
+++ b/packages/api/src/app/loader.ts
@@ -216,7 +216,7 @@ export function createCustomConfigLoader({
setMaxSubagents(getConfiguredMaxSubagents(loadedConfig));
const result = configSchema.strict().safeParse(loadedConfig);
if (
- result.error?.errors.some(
+ result.error?.issues.some(
(error) => error.path != null && error.path.includes('imageOutputType'),
)
) {
@@ -233,7 +233,7 @@ export function createCustomConfigLoader({
if (!result.success) {
const message = `Invalid custom config file at ${configPath}:\n${JSON.stringify(result.error, null, 2)}`;
logger.error(message);
- const speechError = result.error.errors.find(
+ const speechError = result.error.issues.find(
(error) =>
error.code === 'unrecognized_keys' &&
(error.message?.includes('stt') || error.message?.includes('tts')),
@@ -251,12 +251,12 @@ export function createCustomConfigLoader({
'CONFIG_BYPASS_VALIDATION is enabled. Continuing with default configuration despite validation errors.',
);
if (mode === 'reload') {
- throw new ConfigReloadError(message, result.error, result.error.errors);
+ throw new ConfigReloadError(message, result.error, result.error.issues);
}
return null;
}
if (mode === 'reload') {
- throw new ConfigReloadError(message, result.error, result.error.errors);
+ throw new ConfigReloadError(message, result.error, result.error.issues);
}
logger.error(
diff --git a/packages/api/src/app/service.spec.ts b/packages/api/src/app/service.spec.ts
index deaad44f54..0c868b767f 100644
--- a/packages/api/src/app/service.spec.ts
+++ b/packages/api/src/app/service.spec.ts
@@ -1793,7 +1793,6 @@ describe('createAppConfigService', () => {
{
code: 'invalid_type',
expected: 'string',
- received: 'number',
path: ['interface', 'customWelcome'],
message: 'Expected string, received number',
},
diff --git a/packages/api/src/app/theme.ts b/packages/api/src/app/theme.ts
index 3b56453fb2..48c4151677 100644
--- a/packages/api/src/app/theme.ts
+++ b/packages/api/src/app/theme.ts
@@ -45,7 +45,7 @@ function collectErrors(theme: unknown): ThemeIssue[] {
if (result.success) {
return [];
}
- return result.error.errors.map(({ path, message }) => ({
+ return result.error.issues.map(({ path, message }) => ({
path: path.map(String),
message,
}));
diff --git a/packages/api/src/langfuse/reader.ts b/packages/api/src/langfuse/reader.ts
index 64a59d102b..074f9f5971 100644
--- a/packages/api/src/langfuse/reader.ts
+++ b/packages/api/src/langfuse/reader.ts
@@ -67,19 +67,19 @@ const observationSchema = z.object({
/** Langfuse Cloud serves the `model` field group as `model`; its SDK types name it `providedModelName`. */
model: z.string().nullish(),
providedModelName: z.string().nullish(),
- usageDetails: z.record(z.number()).nullish(),
- costDetails: z.record(z.number()).nullish(),
+ usageDetails: z.record(z.string(), z.number()).nullish(),
+ costDetails: z.record(z.string(), z.number()).nullish(),
totalCost: z.number().nullish(),
- input: z.unknown(),
- output: z.unknown(),
- metadata: z.unknown(),
+ input: z.unknown().optional(),
+ output: z.unknown().optional(),
+ metadata: z.unknown().optional(),
});
const pageSchema = z.object({
data: z.array(z.unknown()),
meta: z.object({ cursor: z.string().nullish() }).partial().nullish(),
});
-const roundSchema = z.object({ id: z.string().min(1), input: z.unknown() });
+const roundSchema = z.object({ id: z.string().min(1), input: z.unknown().optional() });
type LangfuseObservation = z.infer<typeof observationSchema>;
/** The response that owns a trace, and whether the trace is its title run rather than the run itself. */
diff --git a/packages/api/src/mcp/__tests__/zod.spec.ts b/packages/api/src/mcp/__tests__/zod.spec.ts
index fa1780cd2a..d962b926c4 100644
--- a/packages/api/src/mcp/__tests__/zod.spec.ts
+++ b/packages/api/src/mcp/__tests__/zod.spec.ts
@@ -10,6 +10,12 @@ import {
sanitizeGeminiSchema,
} from '../zod';
+/** A parsed value read by key path; JSON Schema conversions have no static output type. */
+type ParsedTree = { readonly [key: string]: ParsedTree | undefined };
+
+const parseTree = (schema: z.ZodType | undefined, data: unknown): ParsedTree | undefined =>
+ schema?.parse(data) as ParsedTree | undefined;
+
describe('convertJsonSchemaToZod', () => {
describe('integer type handling', () => {
// Before the fix, integer types were falling through to the default case
@@ -84,9 +90,9 @@ describe('convertJsonSchemaToZod', () => {
// Test with valid data
const validData = { query: 'test search' };
- const parsedValid = result?.parse(validData);
+ const parsedValid = parseTree(result, validData);
expect(parsedValid).toBeDefined();
- expect(parsedValid.query).toBe('test search');
+ expect(parsedValid?.query).toBe('test search');
// max_results is optional and may not be in the result when not provided
// Test with max_results included
@@ -132,12 +138,12 @@ describe('convertJsonSchemaToZod', () => {
// Test with optional fields omitted
const minimalData = { numberField: 2.5 };
- const parsedMinimal = result?.parse(minimalData);
+ const parsedMinimal = parseTree(result, minimalData);
expect(parsedMinimal).toBeDefined();
- expect(parsedMinimal.numberField).toBe(2.5);
+ expect(parsedMinimal?.numberField).toBe(2.5);
// Optional fields may be undefined or null when not provided
- expect(parsedMinimal.integerField ?? null).toBe(null);
- expect(parsedMinimal.floatField ?? null).toBe(null);
+ expect(parsedMinimal?.integerField ?? null).toBe(null);
+ expect(parsedMinimal?.floatField ?? null).toBe(null);
});
});
@@ -1316,7 +1322,7 @@ describe('convertJsonSchemaToZod', () => {
},
};
- const result = zodSchema?.parse(testData);
+ const result = parseTree(zodSchema, testData);
expect(result).toEqual(testData);
expect(result?.filter).toBeDefined();
expect(result?.filter?.title?._icontains).toBe('Pirate');
@@ -1451,7 +1457,7 @@ describe('convertJsonSchemaToZod', () => {
},
};
- const result = zodSchema?.parse(testData);
+ const result = parseTree(zodSchema, testData);
expect(result).toEqual(testData);
expect(result?.query?.filter?.title?._icontains).toBe('Pirate');
});
@@ -1531,7 +1537,7 @@ describe('convertJsonSchemaToZod', () => {
};
// Without resolving refs, the filter field won't work correctly
- const resultUnresolved = zodSchemaUnresolved?.parse(testData);
+ const resultUnresolved = parseTree(zodSchemaUnresolved, testData);
expect(resultUnresolved?.query?.filter).toEqual({});
// Now resolve refs first
@@ -1552,7 +1558,7 @@ describe('convertJsonSchemaToZod', () => {
});
// With resolved refs, it should work correctly
- const resultResolved = zodSchemaResolved?.parse(testData);
+ const resultResolved = parseTree(zodSchemaResolved, testData);
expect(resultResolved).toEqual(testData);
expect(resultResolved?.query?.filter?.status?._eq).toBe('draft');
});
@@ -1773,7 +1779,7 @@ describe('convertJsonSchemaToZod', () => {
},
};
- const result = zodSchema?.parse(testData);
+ const result = parseTree(zodSchema, testData);
expect(result).toEqual(testData);
expect(result?.properties?.minutes_id).toBeDefined();
});
@@ -2000,7 +2006,7 @@ describe('convertJsonSchemaToZod', () => {
};
// Without ref resolution, the data field should be stripped/empty
- const result = zodSchema?.parse(testData);
+ const result = parseTree(zodSchema, testData);
expect(result?.data).toEqual({});
});
@@ -2031,7 +2037,7 @@ describe('convertJsonSchemaToZod', () => {
};
// The random field should be stripped because this isn't a bare object
- const result = zodSchema?.parse(testData);
+ const result = parseTree(zodSchema, testData);
expect(result?.config).toEqual({});
});
});
diff --git a/packages/api/src/mcp/zod.ts b/packages/api/src/mcp/zod.ts
index 082b6b6c96..dd98c1bf95 100644
--- a/packages/api/src/mcp/zod.ts
+++ b/packages/api/src/mcp/zod.ts
@@ -818,6 +818,12 @@ export function sanitizeGeminiSchema<T extends Record<string, unknown>>(schema:
return result as T;
}
+/** An optional, nullable field that keeps its description, which Zod 4 does not copy onto wrappers. */
+function toOptionalField(field: z.ZodType): z.ZodType {
+ const wrapped = field.optional().nullable();
+ return field.description ? wrapped.describe(field.description) : wrapped;
+}
+
/**
* Converts a JSON Schema to a Zod schema.
*
@@ -1015,13 +1021,13 @@ export function convertJsonSchemaToZod(
const partial = Object.fromEntries(
Object.entries(shape).map(([key, value]) => [
key,
- schema.required?.includes(key) === true ? value : value.optional().nullable(),
+ schema.required?.includes(key) === true ? value : toOptionalField(value),
]),
);
objectSchema = z.object(partial);
} else {
const partialNullable = Object.fromEntries(
- Object.entries(shape).map(([key, value]) => [key, value.optional().nullable()]),
+ Object.entries(shape).map(([key, value]) => [key, toOptionalField(value)]),
);
objectSchema = z.object(partialNullable);
}
diff --git a/packages/api/src/openapi/adapter.ts b/packages/api/src/openapi/adapter.ts
index 2e2d9ae746..ca0babf359 100644
--- a/packages/api/src/openapi/adapter.ts
+++ b/packages/api/src/openapi/adapter.ts
@@ -1,5 +1,6 @@
import { z } from 'zod';
import { createDocument } from 'zod-openapi';
+import type { CreateDocumentOptions } from 'zod-openapi';
import type { ZodTypeAny } from 'zod';
/**
@@ -148,6 +149,21 @@ function applyComponentSchemaOverrides(
}
}
+/**
+ * Zod 4 renders every non-strict object as `additionalProperties: false` in responses only, so
+ * a component nested in another one renders differently per direction and is duplicated as
+ * `<Name>Output`. Only strict objects reject unknown keys, so both directions render alike.
+ */
+const renderObjectsAlike: CreateDocumentOptions['override'] = ({ jsonSchema, zodSchema, io }) => {
+ const def = zodSchema._zod.def;
+ if (io !== 'output' || def.type !== 'object' || def.catchall) {
+ return;
+ }
+ if (jsonSchema.additionalProperties === false) {
+ delete jsonSchema.additionalProperties;
+ }
+};
+
export function buildOpenApiDocument(input: OpenApiInput): Record<string, unknown> {
const paths: Record<string, Record<string, unknown>> = {};
for (const contract of input.contracts) {
@@ -164,7 +180,10 @@ export function buildOpenApiDocument(input: OpenApiInput): Record<string, unknow
},
paths,
} as unknown as Parameters<typeof createDocument>[0];
- const document = createDocument(spec) as unknown as Record<string, unknown>;
+ const document = createDocument(spec, { override: renderObjectsAlike }) as unknown as Record<
+ string,
+ unknown
+ >;
applyComponentSchemaOverrides(document, input.componentSchemaOverrides);
return document;
}
diff --git a/packages/api/src/openapi/agents.ts b/packages/api/src/openapi/agents.ts
index c7e271b620..bb87bbd279 100644
--- a/packages/api/src/openapi/agents.ts
+++ b/packages/api/src/openapi/agents.ts
@@ -42,7 +42,7 @@ const documentedEdgeSchema = z.object({
* one cast is needed to reach `.extend`.
*/
function withDocumentedEdges(schema: ZodTypeAny): ZodTypeAny {
- return (schema as unknown as z.AnyZodObject).extend({
+ return (schema as unknown as z.ZodObject).extend({
edges: z.array(documentedEdgeSchema).optional(),
});
}
@@ -63,7 +63,7 @@ const agentResponseSchema = withDocumentedEdges(agentManagementResponseSchema);
* The envelope is exported as `ZodType`, so reach `.extend` the same way `withDocumentedEdges` does.
*/
const agentListResponseSchema = (
- agentManagementListEnvelopeSchema as unknown as z.AnyZodObject
+ agentManagementListEnvelopeSchema as unknown as z.ZodObject
).extend({
data: z.array(agentResponseSchema),
});
diff --git a/packages/api/src/prompts/handlers.ts b/packages/api/src/prompts/handlers.ts
index 5294515de8..8ca43bfaf8 100644
--- a/packages/api/src/prompts/handlers.ts
+++ b/packages/api/src/prompts/handlers.ts
@@ -32,7 +32,7 @@ import { isPromptStoreError } from './errors';
* validation instead of silently falling back to `production`. */
const resolveVersionQuerySchema = z.union([
z.undefined(),
- z.string().pipe(z.coerce.number().int().positive().max(Number.MAX_SAFE_INTEGER)),
+ z.string().pipe(z.coerce.number<string>().int().positive().max(Number.MAX_SAFE_INTEGER)),
]);
/** A request after the prompt access middleware stored the resolved record. */
diff --git a/packages/api/src/prompts/schemas.spec.ts b/packages/api/src/prompts/schemas.spec.ts
index 088a85b866..631ee8a97d 100644
--- a/packages/api/src/prompts/schemas.spec.ts
+++ b/packages/api/src/prompts/schemas.spec.ts
@@ -227,7 +227,7 @@ describe('safeValidatePromptGroupUpdate', () => {
const result = safeValidatePromptGroupUpdate({ author: 'malicious-id' });
expect(result.success).toBe(false);
if (!result.success) {
- expect(result.error.errors.length).toBeGreaterThan(0);
+ expect(result.error.issues.length).toBeGreaterThan(0);
}
});
});
diff --git a/packages/api/src/prompts/schemas.ts b/packages/api/src/prompts/schemas.ts
index 2c2940823a..888c1b38ae 100644
--- a/packages/api/src/prompts/schemas.ts
+++ b/packages/api/src/prompts/schemas.ts
@@ -13,16 +13,16 @@ const PROMPT_TYPE_MESSAGE = 'Prompt type must be "text" or "chat"';
const promptPayloadSchema: z.ZodType<TPromptPayloadSchema> = z.object(
{
prompt: z
- .string({ required_error: PROMPT_TEXT_MESSAGE, invalid_type_error: PROMPT_TEXT_MESSAGE })
+ .string({ error: PROMPT_TEXT_MESSAGE })
.refine((value) => value.trim().length > 0, { message: PROMPT_TEXT_MESSAGE }),
- type: z.enum(['text', 'chat'], { errorMap: () => ({ message: PROMPT_TYPE_MESSAGE }) }),
+ type: z.enum(['text', 'chat'], { error: PROMPT_TYPE_MESSAGE }),
},
- { invalid_type_error: PROMPT_TEXT_MESSAGE },
+ { error: PROMPT_TEXT_MESSAGE },
);
export function safeValidatePromptPayload(
data: unknown,
-): z.SafeParseReturnType<unknown, TPromptPayloadSchema> {
+): z.ZodSafeParseResult<TPromptPayloadSchema> {
return promptPayloadSchema.safeParse(data);
}
@@ -42,7 +42,7 @@ export const updatePromptGroupSchema: z.ZodObject<
/** Command shortcut for the prompt group */
command: z.ZodNullable<z.ZodOptional<z.ZodString>>;
},
- 'strict'
+ z.core.$strict
> = z
.object({
/** The name of the prompt group */
@@ -70,19 +70,8 @@ export type TUpdatePromptGroupSchema = z.infer<typeof updatePromptGroupSchema>;
* @param data - The raw request body to validate
* @returns A SafeParseResult with either the validated data or validation errors
*/
-export function safeValidatePromptGroupUpdate(data: unknown): z.SafeParseReturnType<
- {
- name?: string | undefined;
- category?: string | undefined;
- command?: string | null | undefined;
- oneliner?: string | undefined;
- },
- {
- name?: string | undefined;
- category?: string | undefined;
- command?: string | null | undefined;
- oneliner?: string | undefined;
- }
-> {
+export function safeValidatePromptGroupUpdate(
+ data: unknown,
+): z.ZodSafeParseResult<TUpdatePromptGroupSchema> {
return updatePromptGroupSchema.safeParse(data);
}
diff --git a/packages/api/src/prompts/service.ts b/packages/api/src/prompts/service.ts
index fa035a66c4..a83482f12f 100644
--- a/packages/api/src/prompts/service.ts
+++ b/packages/api/src/prompts/service.ts
@@ -325,7 +325,7 @@ export function createPromptServiceFromAdapters(adapters: PromptServiceAdapters)
}
const validation = safeValidatePromptGroupUpdate(updates);
if (!validation.success) {
- return invalidInput('Invalid request body', validation.error.errors);
+ return invalidInput('Invalid request body', validation.error.issues);
}
const rejection = inspect({ group: validation.data }, filters);
if (rejection != null) {
diff --git a/packages/api/src/skills/management.ts b/packages/api/src/skills/management.ts
index 3fd3aad455..258fe861a0 100644
--- a/packages/api/src/skills/management.ts
+++ b/packages/api/src/skills/management.ts
@@ -40,7 +40,7 @@ export const skillFrontmatterValueSchema: z.ZodType<SkillFrontmatterValue> = z.l
z.boolean(),
z.null(),
z.array(skillFrontmatterValueSchema),
- z.record(skillFrontmatterValueSchema),
+ z.record(z.string(), skillFrontmatterValueSchema),
]),
);
export type SkillManagementUpdate = TUpdateSkillPayload & { expectedVersion: number };
@@ -51,7 +51,7 @@ export const skillManagementCreateSchema: z.ZodType<TCreateSkill> = z
displayTitle: fields.displayTitle,
description: fields.description,
body: z.string(),
- frontmatter: z.record(skillFrontmatterValueSchema).optional(),
+ frontmatter: z.record(z.string(), skillFrontmatterValueSchema).optional(),
category: fields.category,
alwaysApply: fields.alwaysApply,
})
@@ -65,13 +65,13 @@ export const skillManagementUpdateSchema: z.ZodType<SkillManagementUpdate> = z
category: fields.category,
alwaysApply: fields.alwaysApply,
body: z.string().optional(),
- frontmatter: z.record(skillFrontmatterValueSchema).optional(),
+ frontmatter: z.record(z.string(), skillFrontmatterValueSchema).optional(),
expectedVersion: z.number().int().positive(),
})
.strict()
.refine((value) => Object.keys(value).length > 1, 'At least one update field is required');
-export const skillSummarySchema: z.AnyZodObject = z.object({
+export const skillSummarySchema: z.ZodObject = z.object({
...fields,
id: idSchema,
version: z.number().int().positive(),
@@ -111,19 +111,19 @@ export const skillManagementResponseSchema: z.ZodType<SkillManagementResponse> =
createdAt: z.string().datetime(),
updatedAt: z.string().datetime(),
body: z.string(),
- frontmatter: z.record(skillFrontmatterValueSchema).optional(),
+ frontmatter: z.record(z.string(), skillFrontmatterValueSchema).optional(),
});
-export const skillFileSchema: z.AnyZodObject = z.object({
+export const skillFileSchema: z.ZodObject = z.object({
relativePath: z.string(),
filename: z.string(),
mimeType: z.string(),
bytes: z.number().int().nonnegative(),
});
-export const skillFileContentSchema: z.AnyZodObject = skillFileSchema.extend({
+export const skillFileContentSchema: z.ZodObject = skillFileSchema.extend({
content: z.string().optional(),
isBinary: z.boolean(),
});
-export const skillFileUpdateSchema: z.AnyZodObject = z
+export const skillFileUpdateSchema: z.ZodObject<{ content: z.ZodString }, z.core.$strict> = z
.object({ content: z.string().max(1024 * 1024) })
.strict();
export const skillFileDeleteResponseSchema: z.ZodType<TDeleteSkillFileResponse> = z.object({
diff --git a/packages/api/src/tools/index.ts b/packages/api/src/tools/index.ts
index 630201e75b..d082a97d8e 100644
--- a/packages/api/src/tools/index.ts
+++ b/packages/api/src/tools/index.ts
@@ -8,3 +8,4 @@ export * from './classification';
export * from './rolePermissions';
export * from './compare';
export * from './available';
+export * from './schema';
diff --git a/packages/api/src/tools/schema.spec.ts b/packages/api/src/tools/schema.spec.ts
new file mode 100644
index 0000000000..e877862a80
--- /dev/null
+++ b/packages/api/src/tools/schema.spec.ts
@@ -0,0 +1,44 @@
+import { z } from 'zod';
+import { z as zodV3 } from 'zod/v3';
+import { toToolParameters } from './schema';
+
+describe('toToolParameters', () => {
+ it('converts a Zod 4 schema to draft-07 input parameters', () => {
+ const parameters = toToolParameters(
+ z.object({
+ query: z.string().describe('Search query'),
+ limit: z.number().default(5),
+ since: z.date().optional(),
+ }),
+ );
+
+ expect(parameters).toEqual({
+ $schema: 'http://json-schema.org/draft-07/schema#',
+ type: 'object',
+ properties: {
+ query: { type: 'string', description: 'Search query' },
+ limit: { type: 'number', default: 5 },
+ since: {},
+ },
+ required: ['query'],
+ });
+ });
+
+ it('converts a Zod 3 schema such as the legacy LangChain `Tool` default', () => {
+ const parameters = toToolParameters(
+ zodV3.object({ input: zodV3.string().optional() }).transform((value) => value.input),
+ );
+
+ expect(parameters).toMatchObject({
+ type: 'object',
+ properties: { input: { type: 'string' } },
+ });
+ });
+
+ it('returns a JSON Schema or a missing schema unchanged', () => {
+ const jsonSchema = { type: 'object', properties: { id: { type: 'string' } } };
+
+ expect(toToolParameters(jsonSchema)).toBe(jsonSchema);
+ expect(toToolParameters(undefined)).toBeUndefined();
+ });
+});
diff --git a/packages/api/src/tools/schema.ts b/packages/api/src/tools/schema.ts
new file mode 100644
index 0000000000..003e20b2ef
--- /dev/null
+++ b/packages/api/src/tools/schema.ts
@@ -0,0 +1,25 @@
+import { z } from 'zod';
+import { zodToJsonSchema } from 'zod-to-json-schema';
+import type { ZodType as ZodV3Type } from 'zod/v3';
+
+/**
+ * Draft-07 JSON Schema parameters for a tool schema. LibreChat tools declare Zod 4 schemas, while
+ * LangChain's legacy `Tool` still builds its default schema with the Zod 3 API, which Zod 4's
+ * converter cannot read. A JSON Schema, or no schema, is returned unchanged.
+ */
+export function toToolParameters(schema: object | undefined): object | undefined {
+ if (schema == null) {
+ return schema;
+ }
+ if ('_zod' in schema) {
+ return z.toJSONSchema(schema as z.core.$ZodType, {
+ target: 'draft-7',
+ io: 'input',
+ unrepresentable: 'any',
+ });
+ }
+ if ('_def' in schema) {
+ return zodToJsonSchema(schema as ZodV3Type);
+ }
+ return schema;
+}
diff --git a/packages/api/src/utils/tokens.ts b/packages/api/src/utils/tokens.ts
index 4878041c7a..7db08a6a6c 100644
--- a/packages/api/src/utils/tokens.ts
+++ b/packages/api/src/utils/tokens.ts
@@ -678,29 +678,14 @@ export function matchModelName(
return matchedPattern || modelName;
}
-export const modelSchema: z.ZodObject<
- {
- id: z.ZodString;
- pricing: z.ZodObject<
- {
- prompt: z.ZodString;
- completion: z.ZodString;
- },
- 'strip',
- z.ZodTypeAny,
- {
- prompt: string;
- completion: string;
- },
- {
- prompt: string;
- completion: string;
- }
- >;
- context_length: z.ZodNumber;
- },
- 'strip'
-> = z.object({
+export const modelSchema: z.ZodObject<{
+ id: z.ZodString;
+ pricing: z.ZodObject<{
+ prompt: z.ZodString;
+ completion: z.ZodString;
+ }>;
+ context_length: z.ZodNumber;
+}> = z.object({
id: z.string(),
pricing: z.object({
prompt: z.string(),
@@ -709,54 +694,9 @@ export const modelSchema: z.ZodObject<
context_length: z.number(),
});
-export const inputSchema: z.ZodObject<
- {
- data: z.ZodArray<
- z.ZodObject<
- {
- id: z.ZodString;
- pricing: z.ZodObject<
- {
- prompt: z.ZodString;
- completion: z.ZodString;
- },
- 'strip',
- z.ZodTypeAny,
- {
- prompt: string;
- completion: string;
- },
- {
- prompt: string;
- completion: string;
- }
- >;
- context_length: z.ZodNumber;
- },
- 'strip',
- z.ZodTypeAny,
- {
- id: string;
- pricing: {
- prompt: string;
- completion: string;
- };
- context_length: number;
- },
- {
- id: string;
- pricing: {
- prompt: string;
- completion: string;
- };
- context_length: number;
- }
- >,
- 'many'
- >;
- },
- 'strip'
-> = z.object({
+export const inputSchema: z.ZodObject<{
+ data: z.ZodArray<typeof modelSchema>;
+}> = z.object({
data: z.array(modelSchema),
});
diff --git a/packages/data-provider/package.json b/packages/data-provider/package.json
index 131618c176..cdeb52941e 100644
--- a/packages/data-provider/package.json
+++ b/packages/data-provider/package.json
@@ -47,7 +47,7 @@
"dayjs": "^1.11.13",
"js-yaml": "^4.3.2",
"re2js": "^2.8.6",
- "zod": "^3.22.4"
+ "zod": "^4.6.7"
},
"devDependencies": {
"@babel/preset-env": "^7.21.5",
diff --git a/packages/data-provider/specs/actions.spec.ts b/packages/data-provider/specs/actions.spec.ts
index 646bd1d9ac..ff630f44a6 100644
--- a/packages/data-provider/specs/actions.spec.ts
+++ b/packages/data-provider/specs/actions.spec.ts
@@ -1330,7 +1330,7 @@ describe('createURL', () => {
expect(timeSchema._def.innerType instanceof z.ZodString).toBe(true);
// Check the description
- expect(shape.locations._def.description).toBe(
+ expect(shape.locations.description).toBe(
'A list of locations to retrieve the weather for.',
);
});
diff --git a/packages/data-provider/src/azure.ts b/packages/data-provider/src/azure.ts
index 1343c01c69..64480a351e 100644
--- a/packages/data-provider/src/azure.ts
+++ b/packages/data-provider/src/azure.ts
@@ -20,7 +20,7 @@ export function validateAzureGroups(configs: TAzureGroups): TAzureConfigValidati
const result = azureGroupConfigsSchema.safeParse(configs);
if (!result.success) {
isValid = false;
- errors.push(errorsToString(result.error.errors));
+ errors.push(errorsToString(result.error.issues));
} else {
for (const group of result.data) {
const {
diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts
index 59be86ea64..809d6bae69 100644
--- a/packages/data-provider/src/config.ts
+++ b/packages/data-provider/src/config.ts
@@ -39,6 +39,7 @@ import {
scheduledMCPResourceBindingSchema,
scheduledMCPReadOnlyPolicySchema,
} from './types/scheduleConsent';
+import { partialWithoutDefaults } from './zod';
export const AGENT_BACKGROUND_COMPLETION_RESULT_MAX_CHARS_DEFAULT = 24 * 1024;
export const AGENT_BACKGROUND_COMPLETION_RESULT_MAX_CHARS_HARD_MAX = 64 * 1024;
@@ -708,7 +709,11 @@ type SchemaShape<T> = T extends z.ZodObject<infer U> ? U : never;
// Helper type to determine the default value or undefined based on whether the field has a default
type DefaultValue<T> =
- T extends z.ZodDefault<z.ZodTypeAny> ? ReturnType<T['_def']['defaultValue']> : undefined;
+ T extends z.ZodDefault<infer Inner>
+ ? z.output<Inner>
+ : T extends z.ZodPrefault<infer Inner>
+ ? z.input<Inner>
+ : undefined;
// Extract default values or undefined from the schema shape
type ExtractDefaults<T> = {
@@ -719,14 +724,13 @@ export type SchemaDefaults<T> = ExtractDefaults<SchemaShape<T>>;
export type TConfigDefaults = SchemaDefaults<typeof configSchema>;
-export function getSchemaDefaults<Schema extends z.AnyZodObject>(
+export function getSchemaDefaults<Schema extends z.ZodObject>(
schema: Schema,
): ExtractDefaults<SchemaShape<Schema>> {
const shape = schema.shape;
const entries = Object.entries(shape).map(([key, value]) => {
- if (value instanceof z.ZodDefault) {
- // Extract default value if it exists
- return [key, value._def.defaultValue()];
+ if (value instanceof z.ZodDefault || value instanceof z.ZodPrefault) {
+ return [key, value.def.defaultValue];
}
return [key, undefined];
});
@@ -781,7 +785,7 @@ export const azureBaseSchema = z.object({
dropParams: z.array(z.string()).optional(),
version: z.string().optional(),
baseURL: z.string().optional(),
- additionalHeaders: z.record(z.string()).optional(),
+ additionalHeaders: z.record(z.string(), z.string()).optional(),
});
export type TAzureBaseSchema = z.infer<typeof azureBaseSchema>;
@@ -884,7 +888,7 @@ export const baseEndpointSchema = z.object({
* providers through an AI gateway / reverse proxy that consumes metadata
* headers (provider-native request shaping is preserved).
*/
- headers: z.record(z.string()).optional(),
+ headers: z.record(z.string(), z.string()).optional(),
titlePrompt: z.string().optional(),
titleModel: z.string().optional(),
titleConvo: z.boolean().optional(),
@@ -1012,7 +1016,7 @@ export const assistantEndpointSchema = baseEndpointSchema.merge(
userIdQuery: z.boolean().optional(),
})
.optional(),
- headers: z.record(z.string()).optional(),
+ headers: z.record(z.string(), z.string()).optional(),
}),
);
@@ -1235,7 +1239,7 @@ export const toolApprovalHookConfigSchema = z.object({
/** Optional regex matched against the tool name; omit to run for every tool. */
matcher: z.string().optional(),
/** Static options forwarded to the module's builder; the hook's own per-call config. */
- options: z.record(z.unknown()).optional(),
+ options: z.record(z.string(), z.unknown()).optional(),
});
export type TToolApprovalHookConfig = z.infer<typeof toolApprovalHookConfigSchema>;
@@ -1726,7 +1730,7 @@ export const agentsEndpointSchema = baseEndpointSchema
.default(DEFAULT_CACHE_CLEAR_TIMEOUT_MS),
})
.optional()
- .default({}),
+ .prefault({}),
})
.optional(),
/** Cap on any agent's `recursion_limit` and on `recursionLimit`. */
@@ -1739,7 +1743,7 @@ export const agentsEndpointSchema = baseEndpointSchema
/** Per-tool overrides of `maxToolCallArgBytes`, keyed by model-facing tool name; `0`
* disables the guard for that tool only. Merged over LibreChat's shipped default of
* `{ create_file: 131072 }`. */
- maxToolCallArgBytesByTool: z.record(z.number()).optional(),
+ maxToolCallArgBytesByTool: z.record(z.string(), z.number()).optional(),
/** Characters of retained tool output the save path may tokenize exactly for the
* context gauge when a turn stops at the tool-call limit (see
* `retainedToolTokens`). Tokenizing costs ~60 ms/MB and runs once per stopped
@@ -2208,7 +2212,7 @@ export const agentsEndpointSchema = baseEndpointSchema
checkpointer: checkpointerSchema,
}),
)
- .default({
+ .prefault({
disableBuilder: false,
capabilities: defaultAgentCapabilities,
maxCitations: 30,
@@ -2242,7 +2246,7 @@ export const paramDefinitionSchema = z.object({
path: ['positiveMin'],
})
.optional(),
- enumMappings: z.record(z.union([z.number(), z.boolean(), z.string()])).optional(),
+ enumMappings: z.record(z.string(), z.union([z.number(), z.boolean(), z.string()])).optional(),
component: z.nativeEnum(ComponentTypes).optional(),
optionType: z.nativeEnum(OptionTypes).optional(),
columnSpan: z.number().int().nonnegative().optional(),
@@ -2299,7 +2303,7 @@ export const endpointSchema = baseEndpointSchema.merge(
* OpenAI-compatible endpoints.
*/
provider: z.literal(EModelEndpoint.anthropic).optional(),
- headers: z.record(z.string()).optional(),
+ headers: z.record(z.string(), z.string()).optional(),
addParams: addParamsSchema.optional(),
dropParams: z.array(z.string()).optional(),
customParams: z
@@ -2340,6 +2344,7 @@ export const endpointSchema = baseEndpointSchema.merge(
/** Static per-model token config: context window and per-million-token rates */
tokenConfig: z
.record(
+ z.string(),
z.object({
prompt: z.number(),
completion: z.number(),
@@ -2687,7 +2692,7 @@ export const mcpAppRateLimitSchema = z
resourcesPerMinute: z.number().int().positive().default(120),
toolCallsPerMinute: z.number().int().positive().default(60),
})
- .default({});
+ .prefault({});
export type TMCPAppRateLimits = z.infer<typeof mcpAppRateLimitSchema>;
@@ -2763,7 +2768,7 @@ export const rateLimitSchema = z.object({
userWindowInMinutes: z.number().optional(),
})
.optional(),
- mcpApps: mcpAppRateLimitSchema.optional(),
+ mcpApps: mcpAppRateLimitSchema.unwrap().optional(),
/** Requesting a change of the registered email; keyed by the authenticated user. */
emailChange: z
.object({
@@ -2839,7 +2844,7 @@ const termsOfServiceSchema = z.object({
export type TTermsOfService = z.infer<typeof termsOfServiceSchema>;
// Schema for localized string (either simple string or language-keyed object)
-const localizedStringSchema = z.union([z.string(), z.record(z.string())]);
+const localizedStringSchema = z.union([z.string(), z.record(z.string(), z.string())]);
export const mcpRefreshDefaults = {
toolsRefreshInterval: 5 * 60 * 1000,
@@ -2976,8 +2981,8 @@ const themeModeSchema = z
z.string().regex(/^[a-z][a-z0-9-]*$/),
z.string().regex(/^\d{1,3} \d{1,3} \d{1,3}$/),
),
- appearance: z.record(z.string()),
- brands: z.record(z.string()),
+ appearance: z.record(z.string(), z.string()),
+ brands: z.record(z.string(), z.string()),
})
.partial()
.strict();
@@ -2991,7 +2996,7 @@ export const themeDefinitionSchema = z
version: z.literal(1),
name: z.string().trim().min(1),
modes: z.object({ light: themeModeSchema, dark: themeModeSchema }).partial().strict(),
- brands: z.record(z.string()).optional(),
+ brands: z.record(z.string(), z.string()).optional(),
})
.strict();
@@ -3267,9 +3272,9 @@ export const interfaceSchema = z
.object({
enabled: z.boolean().optional(),
maxLifetimeHours: z.number().int().min(1).max(8760).optional(),
- resources: z.record(scheduledMCPResourceBindingSchema).optional(),
+ resources: z.record(z.string(), scheduledMCPResourceBindingSchema).optional(),
/** Trusted service declarations, keyed by raw server and upstream tool name. */
- readOnlyPolicy: z.record(scheduledMCPReadOnlyPolicySchema).optional(),
+ readOnlyPolicy: z.record(z.string(), scheduledMCPReadOnlyPolicySchema).optional(),
})
.optional(),
/** Bounded exponential receipt retry interval; equal jitter prevents outage waves. */
@@ -3351,7 +3356,7 @@ export const interfaceSchema = z
.max(Number.MAX_SAFE_INTEGER)
.default(DEFAULT_HISTORY_CACHE_MAX_BYTES),
})
- .default({
+ .prefault({
modelSelect: true,
runningChatRename: true,
codeHighlightThrottleMs: DEFAULT_CODE_HIGHLIGHT_THROTTLE_MS,
@@ -3460,7 +3465,7 @@ export const turnstileOptionsSchema = z
export const turnstileSchema = z.object({
siteKey: z.string(),
- options: turnstileOptionsSchema.optional(),
+ options: turnstileOptionsSchema.unwrap().optional(),
});
export type TTurnstileConfig = z.infer<typeof turnstileSchema>;
@@ -3855,7 +3860,7 @@ export const webSearchSchema = z.object({
formats: z.array(z.string()).optional(),
includeTags: z.array(z.string()).optional(),
excludeTags: z.array(z.string()).optional(),
- headers: z.record(z.string()).optional(),
+ headers: z.record(z.string(), z.string()).optional(),
waitFor: z.number().optional(),
timeout: z.number().int().nonnegative().optional(),
maxAge: z.number().optional(),
@@ -3876,7 +3881,7 @@ export const webSearchSchema = z.object({
changeTrackingOptions: z
.object({
modes: z.array(z.string()).optional(),
- schema: z.record(z.unknown()).optional(),
+ schema: z.record(z.string(), z.unknown()).optional(),
prompt: z.string().optional(),
tag: z.string().nullable().optional(),
})
@@ -4005,7 +4010,9 @@ export const memorySchema = z.object({
provider: z.string(),
model: z.string(),
instructions: z.string().optional(),
- model_parameters: z.record(z.union([z.string(), z.number(), z.boolean()])).optional(),
+ model_parameters: z
+ .record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
+ .optional(),
}),
])
.optional(),
@@ -4045,7 +4052,9 @@ export const summarizationConfigSchema = z.object({
enabled: z.boolean().optional(),
provider: z.string().optional(),
model: z.string().optional(),
- parameters: z.record(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(),
+ parameters: z
+ .record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()]))
+ .optional(),
trigger: summarizationTriggerSchema.optional(),
prompt: z.string().optional(),
updatePrompt: z.string().optional(),
@@ -4268,7 +4277,7 @@ export const langfuseConfigSchema = z.object({
* schema does not yet express — and note the fanout collector forwards only
* `Authorization` upstream regardless.
*/
- headers: z.record(z.string()).optional(),
+ headers: z.record(z.string(), z.string()).optional(),
/** Trace user identity and allowlisted user/request metadata. */
trace: langfuseTraceConfigSchema.optional(),
/** Tenant admin switch for Langfuse prompt sync. Effective only when the
@@ -4325,7 +4334,7 @@ export const chatProjectsConfigSchema = z
.default(MAX_CHAT_PROJECT_DESCRIPTION_LENGTH),
})
.strict()
- .default({});
+ .prefault({});
export type TChatProjectsConfig = z.infer<typeof chatProjectsConfigSchema>;
@@ -4509,9 +4518,9 @@ export const configSchema = z.object({
.max(256)
.default(DEFAULT_MCP_APP_OPERATION_LIMITS.maxActive),
})
- .default({}),
+ .prefault({}),
})
- .default({}),
+ .prefault({}),
mcpSettings: z
.object({
allowedDomains: z.array(z.string()).optional(),
@@ -4570,7 +4579,7 @@ export const configSchema = z.object({
.default(30_000),
authorizationFenceRetryBatchSize: z.number().int().positive().max(10_000).default(100),
})
- .default({}),
+ .prefault({}),
apps: z.boolean().optional(),
})
.optional(),
@@ -4594,7 +4603,7 @@ export const configSchema = z.object({
/** Milliseconds a started social login may take to reach its callback; defaults to `DEFAULT_OAUTH_STATE_TTL_MS`. */
oauthStateTtlMs: z.number().int().min(60_000).max(3_600_000).optional(),
/** OpenID discovery retries; an unset field falls back to its `OPENID_DISCOVERY_RETRY_*` env var, then the schema default. */
- openidDiscovery: openIdDiscoverySchema.partial().optional(),
+ openidDiscovery: partialWithoutDefaults(openIdDiscoverySchema).optional(),
})
.default({ socialLogins: defaultSocialLogins }),
/** Changing the registered email address. An unset field falls back to its env var, then the
@@ -4661,7 +4670,7 @@ export const configSchema = z.object({
[EModelEndpoint.azureOpenAI]: azureEndpointSchema.optional(),
[EModelEndpoint.azureAssistants]: assistantEndpointSchema.optional(),
[EModelEndpoint.assistants]: assistantEndpointSchema.optional(),
- [EModelEndpoint.agents]: agentsEndpointSchema.optional(),
+ [EModelEndpoint.agents]: agentsEndpointSchema.unwrap().optional(),
[EModelEndpoint.custom]: customEndpointsSchema.optional(),
[EModelEndpoint.bedrock]: bedrockEndpointSchema.optional(),
})
diff --git a/packages/data-provider/src/file-config.ts b/packages/data-provider/src/file-config.ts
index c70e195ecb..5404bc9f5d 100644
--- a/packages/data-provider/src/file-config.ts
+++ b/packages/data-provider/src/file-config.ts
@@ -637,7 +637,7 @@ export type TDefaultLLMDeliveryPath = z.infer<typeof DefaultLLMDeliveryPath>;
export const defaultLLMDeliveryPathSchema = z.object({
fallback: DefaultLLMDeliveryPath.optional(),
- overrides: z.record(DefaultLLMDeliveryPath).optional(),
+ overrides: z.record(z.string(), DefaultLLMDeliveryPath).optional(),
});
export type TDefaultLLMDeliveryPathConfig = z.infer<typeof defaultLLMDeliveryPathSchema>;
type TDeliveryPathOverrides = NonNullable<TDefaultLLMDeliveryPathConfig['overrides']>;
@@ -662,7 +662,7 @@ const skillFileConfigSchema = z.object({
export const fileConfigSchema = z.object({
/** Enable only after every replica and rollback target reads retained file destinations. */
retainedFileCleanup: z.boolean().optional(),
- endpoints: z.record(endpointFileConfigSchema).optional(),
+ endpoints: z.record(z.string(), endpointFileConfigSchema).optional(),
skills: skillFileConfigSchema.optional(),
serverFileSizeLimit: z.number().min(0).optional(),
avatarSizeLimit: z.number().min(0).optional(),
diff --git a/packages/data-provider/src/generate.ts b/packages/data-provider/src/generate.ts
index 06a5d22fc2..7cb66a0cf7 100644
--- a/packages/data-provider/src/generate.ts
+++ b/packages/data-provider/src/generate.ts
@@ -238,9 +238,9 @@ export function generateDynamicSchema(settings: SettingsConfiguration) {
}
const ZodTypeToSettingType: Record<string, string | undefined> = {
- ZodString: 'string',
- ZodNumber: 'number',
- ZodBoolean: 'boolean',
+ string: 'string',
+ number: 'number',
+ boolean: 'boolean',
};
const minColumns = 1;
@@ -500,7 +500,7 @@ export function validateSettingDefinitions(settings: SettingsConfiguration): voi
path: ['optionType'],
});
} else {
- const zodType = conversationSchema._def.typeName;
+ const zodType = conversationSchema.def.type;
const settingTypeEquivalent = ZodTypeToSettingType[zodType] || null;
if (settingTypeEquivalent !== setting.type) {
errors.push({
diff --git a/packages/data-provider/src/index.ts b/packages/data-provider/src/index.ts
index 5df907e1cc..99b88b5358 100644
--- a/packages/data-provider/src/index.ts
+++ b/packages/data-provider/src/index.ts
@@ -90,6 +90,7 @@ export * from './providers';
export * from './svg';
/* general helpers */
export * from './utils';
+export * from './zod';
export * from './actions';
export * from './twoFactor';
export { default as createPayload } from './createPayload';
diff --git a/packages/data-provider/src/mcp.ts b/packages/data-provider/src/mcp.ts
index 0e2f6aa1b9..67cdcb0efb 100644
--- a/packages/data-provider/src/mcp.ts
+++ b/packages/data-provider/src/mcp.ts
@@ -453,7 +453,8 @@ export const StdioOptionsSchema = BaseOptionsSchema.extend({
processedEnv[key] = extractEnvVariable(value);
}
return processedEnv;
- }),
+ })
+ .optional(),
/**
* How to handle stderr of the child process.
* Accepts: 'pipe' | 'ignore' | 'inherit' | file descriptor number.
diff --git a/packages/data-provider/src/schemas.ts b/packages/data-provider/src/schemas.ts
index 22a61f92a1..0efafbaf1b 100644
--- a/packages/data-provider/src/schemas.ts
+++ b/packages/data-provider/src/schemas.ts
@@ -15,7 +15,7 @@ import { TFeedback, feedbackSchema } from './feedback';
import { CODE_APPROVAL_MODES } from './code/approval';
import { Tools } from './types/tools';
-export const isUUID = z.string().uuid();
+export const isUUID = z.guid();
export enum AuthType {
OVERRIDE_AUTH = 'override_auth',
@@ -980,7 +980,7 @@ export const tMessageSchema = z.object({
iconURL: z.string().nullable().optional(),
feedback: feedbackSchema.optional(),
/** metadata */
- metadata: z.record(z.unknown()).optional(),
+ metadata: z.record(z.string(), z.unknown()).optional(),
/** Output tokens for assistant messages, calibrated prompt-side estimate for user messages */
tokenCount: z.number().optional(),
contextMeta: z
@@ -1173,7 +1173,10 @@ const DocumentType: z.ZodType<DocumentTypeValue> = z.lazy(() =>
z.number(),
z.string(),
z.array(z.lazy(() => DocumentType)),
- z.record(z.lazy(() => DocumentType)),
+ z.record(
+ z.string(),
+ z.lazy(() => DocumentType),
+ ),
]),
);
@@ -1309,7 +1312,7 @@ export const tConversationSchema = z.object({
additional_instructions: z.string().optional(),
append_current_datetime: z.boolean().optional(),
/** Used to overwrite active conversation settings when saving a Preset */
- presetOverride: z.record(z.unknown()).optional(),
+ presetOverride: z.record(z.string(), z.unknown()).optional(),
stop: z.array(z.string()).optional(),
/* frontend components */
greeting: z.string().optional(),
diff --git a/packages/data-provider/src/types/agents.spec.ts b/packages/data-provider/src/types/agents.spec.ts
index 1bb43b76b0..0efee52770 100644
--- a/packages/data-provider/src/types/agents.spec.ts
+++ b/packages/data-provider/src/types/agents.spec.ts
@@ -41,7 +41,10 @@ describe('agentGitIdentitySchema', () => {
const regexCheck = jest.spyOn(RegExp.prototype, 'test');
const result = agentGitIdentitySchema.safeParse({ name: 'Lia', email });
- const regexCheckedEmail = regexCheck.mock.calls.some(([value]) => value === email);
+ const regexCheckedEmail = regexCheck.mock.calls.some(
+ ([value], index) =>
+ value === email && !regexCheck.mock.contexts[index].source.startsWith('[\\uD800'),
+ );
regexCheck.mockRestore();
expect(result.success).toBe(false);
diff --git a/packages/data-provider/src/types/schedules.ts b/packages/data-provider/src/types/schedules.ts
index 2bf4d4616e..d87f639d46 100644
--- a/packages/data-provider/src/types/schedules.ts
+++ b/packages/data-provider/src/types/schedules.ts
@@ -1,5 +1,6 @@
import { z } from 'zod';
import { scheduledMCPFailureReasonSchema } from './scheduleConsent';
+import { partialWithoutDefaults } from '../zod';
/** Cadences the dialog builds from structured pickers (hour, minute, weekday). */
export const scheduleStructuredFrequencies = ['hourly', 'daily', 'weekdays', 'weekly'] as const;
@@ -102,19 +103,18 @@ export const createSchedulePayloadSchema = z.object({
export type TCreateSchedule = z.infer<typeof createSchedulePayloadSchema>;
/** Idempotency is a property of the CREATE attempt, not of the schedule's config. */
-export const updateSchedulePayloadSchema = createSchedulePayloadSchema
- .omit({ clientRequestId: true })
- .partial()
- .extend({
- /**
- * The configRevision the client's edit was computed from (captured when the
- * dialog opened). The server fences the update on it, so a concurrent edit
- * from another tab answers 409 instead of being silently overwritten by a
- * payload rebuilt from a stale snapshot (cadence is sent whole, so the
- * server-side fresh-read fence alone cannot detect this).
- */
- expectedConfigRevision: z.number().int().min(0).optional(),
- });
+export const updateSchedulePayloadSchema = partialWithoutDefaults(
+ createSchedulePayloadSchema.omit({ clientRequestId: true }),
+).extend({
+ /**
+ * The configRevision the client's edit was computed from (captured when the
+ * dialog opened). The server fences the update on it, so a concurrent edit
+ * from another tab answers 409 instead of being silently overwritten by a
+ * payload rebuilt from a stale snapshot (cadence is sent whole, so the
+ * server-side fresh-read fence alone cannot detect this).
+ */
+ expectedConfigRevision: z.number().int().min(0).optional(),
+});
export type TUpdateSchedule = z.infer<typeof updateSchedulePayloadSchema>;
export type TScheduleLastRun = {
diff --git a/packages/data-provider/src/zod.spec.ts b/packages/data-provider/src/zod.spec.ts
new file mode 100644
index 0000000000..d0a37f5c11
--- /dev/null
+++ b/packages/data-provider/src/zod.spec.ts
@@ -0,0 +1,45 @@
+import { z } from 'zod';
+import { updateSchedulePayloadSchema } from './types/schedules';
+import { partialWithoutDefaults } from './zod';
+import { configSchema } from './config';
+
+describe('partialWithoutDefaults', () => {
+ const schema = z
+ .object({
+ enabled: z.boolean().default(true),
+ mode: z.enum(['a', 'b']).prefault('a'),
+ name: z.string(),
+ })
+ .strict();
+
+ it('leaves omitted fields absent instead of filling their defaults', () => {
+ expect(partialWithoutDefaults(schema).parse({})).toEqual({});
+ expect(partialWithoutDefaults(schema).parse({ name: 'x' })).toEqual({ name: 'x' });
+ });
+
+ it('still validates the fields that are sent and keeps the object config', () => {
+ expect(partialWithoutDefaults(schema).parse({ enabled: false })).toEqual({ enabled: false });
+ expect(partialWithoutDefaults(schema).safeParse({ enabled: 'yes' }).success).toBe(false);
+ expect(partialWithoutDefaults(schema).safeParse({ extra: 1 }).success).toBe(false);
+ });
+});
+
+describe('optional sections with defaults', () => {
+ it('does not re-enable or retarget a schedule on a partial update', () => {
+ expect(updateSchedulePayloadSchema.parse({ name: 'renamed' })).toEqual({ name: 'renamed' });
+ });
+
+ it('leaves unset config sections absent', () => {
+ const parsed = configSchema.parse({
+ version: '1.0.0',
+ endpoints: { custom: [] },
+ rateLimits: {},
+ turnstile: { siteKey: 'key' },
+ registration: { openidDiscovery: { startupAttempts: 3 } },
+ });
+ expect(parsed.endpoints?.agents).toBeUndefined();
+ expect(parsed.rateLimits?.mcpApps).toBeUndefined();
+ expect(parsed.turnstile?.options).toBeUndefined();
+ expect(parsed.registration?.openidDiscovery).toEqual({ startupAttempts: 3 });
+ });
+});
diff --git a/packages/data-provider/src/zod.ts b/packages/data-provider/src/zod.ts
new file mode 100644
index 0000000000..d6cbc0ffd0
--- /dev/null
+++ b/packages/data-provider/src/zod.ts
@@ -0,0 +1,27 @@
+import { z } from 'zod';
+
+type WithoutDefault<T> = T extends z.ZodDefault<infer I> | z.ZodPrefault<infer I> ? I : T;
+
+export type PartialWithoutDefaultsShape<S extends z.core.$ZodShape> = {
+ [K in keyof S]: z.ZodOptional<WithoutDefault<S[K]>>;
+};
+
+/**
+ * `.partial()` that leaves omitted keys absent. Zod 4 runs a field's `.default()` even
+ * inside `.optional()`, so a plain partial fills every unsent field with its default and
+ * a partial update would overwrite stored values the caller never sent.
+ */
+export function partialWithoutDefaults<
+ S extends z.core.$ZodShape,
+ C extends z.core.$ZodObjectConfig,
+>(schema: z.ZodObject<S, C>): z.ZodObject<PartialWithoutDefaultsShape<S>, C> {
+ const shape: Record<string, z.core.$ZodType> = {};
+ for (const [key, field] of Object.entries(schema.shape)) {
+ shape[key] =
+ field instanceof z.ZodDefault || field instanceof z.ZodPrefault ? field.unwrap() : field;
+ }
+ return schema.extend(shape).partial() as unknown as z.ZodObject<
+ PartialWithoutDefaultsShape<S>,
+ C
+ >;
+}
diff --git a/packages/data-schemas/src/app/resolution.spec.ts b/packages/data-schemas/src/app/resolution.spec.ts
index 47581d9490..aa3f15fcdc 100644
--- a/packages/data-schemas/src/app/resolution.spec.ts
+++ b/packages/data-schemas/src/app/resolution.spec.ts
@@ -4423,6 +4423,27 @@ describe('issue params', () => {
expect(byPath['endpoints.allowedAddresses.0']).toEqual({ reason: 'missing_port' });
});
+ it('keeps record-key diagnostics at their full path inside a union', () => {
+ expect(
+ getConfigOverrideIssues({
+ interface: {
+ theme: {
+ version: 1,
+ name: 'Custom',
+ modes: { light: { colors: { Invalid: '255 255 255' } } },
+ },
+ },
+ }),
+ ).toEqual([
+ {
+ path: 'interface.theme.modes.light.colors.Invalid',
+ segments: ['interface', 'theme', 'modes', 'light', 'colors', 'Invalid'],
+ code: 'invalid_string',
+ params: { validation: 'regex' },
+ },
+ ]);
+ });
+
it('names the integer expectation of a fractional step limit', () => {
expect(getConfigOverrideIssues({ endpoints: { agents: { maxRecursionLimit: 2.5 } } })).toEqual([
{
diff --git a/packages/data-schemas/src/app/resolution.ts b/packages/data-schemas/src/app/resolution.ts
index f26a6608ad..51bf9c1e6f 100644
--- a/packages/data-schemas/src/app/resolution.ts
+++ b/packages/data-schemas/src/app/resolution.ts
@@ -77,7 +77,7 @@ export type ConfigOverrideLayer = Pick<Config, 'principalType' | 'priority' | 'o
const MAX_MERGE_DEPTH = 10;
const ARRAY_INDEX = /^(?:0|[1-9]\d*)$/;
/** Schemas whose children the path walk cannot see, so the stored value decides their shape. */
-const OPAQUE_SCHEMA_TYPES = new Set(['ZodAny', 'ZodUnknown', 'ZodIntersection']);
+const OPAQUE_SCHEMA_TYPES = new Set(['any', 'unknown', 'intersection']);
const MAX_STRIP_PASSES = 16;
const UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
/** Filters are a fail-closed security boundary even during mixed-package rollouts. */
@@ -626,36 +626,108 @@ function toIssueNumber(value: unknown): number | undefined {
function getBoundParams(
bound: 'minimum' | 'maximum',
value: unknown,
- issue: { inclusive: boolean; exact?: boolean; type: string },
+ issue: { inclusive?: boolean; exact?: boolean; origin: string },
): ConfigIssueParams {
const number = toIssueNumber(value);
return {
...(number !== undefined && { [bound]: number }),
- inclusive: issue.inclusive,
+ inclusive: issue.inclusive ?? false,
exact: issue.exact ?? false,
- type: issue.type,
+ type: issue.origin,
};
}
+/** Expected-type names that the reported contract spells differently from zod. */
+const EXPECTED_TYPE_NAMES: Record<string, string> = {
+ int: 'integer',
+ record: 'object',
+ tuple: 'array',
+};
+
+/** String-format names that the reported contract spells as the check that failed. */
+const STRING_FORMAT_NAMES: Record<string, string> = {
+ starts_with: 'startsWith',
+ ends_with: 'endsWith',
+};
+
+/** The kind of the submitted value, by name only, so the value itself is never reported. */
+function getReceivedType(input: unknown, expected: string): string {
+ if (input === null) {
+ return 'null';
+ }
+ if (Array.isArray(input)) {
+ return 'array';
+ }
+ if (input instanceof Date) {
+ return 'date';
+ }
+ if (input instanceof Map) {
+ return 'map';
+ }
+ if (input instanceof Set) {
+ return 'set';
+ }
+ if (typeof input !== 'number') {
+ return typeof input;
+ }
+ if (Number.isNaN(input)) {
+ return 'nan';
+ }
+ return expected === 'int' && !Number.isInteger(input) ? 'float' : 'number';
+}
+
+/** Whether a union issue is the discriminator mismatch of a discriminated union. */
+function isDiscriminatorIssue(issue: SchemaIssue): issue is SchemaIssue & { options: unknown[] } {
+ return (
+ issue.code === 'invalid_union' &&
+ issue.discriminator != null &&
+ Array.isArray((issue as { options?: unknown }).options)
+ );
+}
+
+/**
+ * The stable code an issue is reported under. Codes keep the names the override contract was
+ * published with, so a zod release that renames its issue codes does not change the response.
+ */
+export function getConfigIssueCode(issue: SchemaIssue): string {
+ if (issue.code === 'invalid_value') {
+ return issue.values.length === 1 ? 'invalid_literal' : 'invalid_enum_value';
+ }
+ if (issue.code === 'invalid_format') {
+ return 'invalid_string';
+ }
+ return isDiscriminatorIssue(issue) ? 'invalid_union_discriminator' : issue.code;
+}
+
/**
* The parts of a zod issue that describe the schema rather than the submitted value, by an
* allowlist per issue code: expected types and literals, accepted options, numeric bounds, the
* failed string check, a multiple, and a refinement's stable `reason`. A value the client sent
- * is never copied (no `received` literal or enum value, no message), so the result is safe to
- * return. `undefined` when the issue carries none of these.
+ * is never copied (only the name of its type, no literal or enum value, no message), so the
+ * result is safe to return. `undefined` when the issue carries none of these.
*/
export function getConfigIssueParams(issue: SchemaIssue): ConfigIssueParams | undefined {
let params: ConfigIssueParams | undefined;
switch (issue.code) {
case 'invalid_type':
- params = { expected: String(issue.expected), received: String(issue.received) };
+ params = {
+ expected: EXPECTED_TYPE_NAMES[issue.expected] ?? issue.expected,
+ ...('input' in issue && { received: getReceivedType(issue.input, issue.expected) }),
+ };
break;
- case 'invalid_literal':
- params = isIssuePrimitive(issue.expected) ? { expected: issue.expected } : undefined;
+ case 'invalid_value': {
+ const [expected] = issue.values;
+ if (issue.values.length > 1) {
+ params = { options: issue.values.filter(isIssuePrimitive) };
+ } else {
+ params = isIssuePrimitive(expected) ? { expected } : undefined;
+ }
break;
- case 'invalid_enum_value':
- case 'invalid_union_discriminator':
- params = { options: (issue.options as unknown[]).filter(isIssuePrimitive) };
+ }
+ case 'invalid_union':
+ params = isDiscriminatorIssue(issue)
+ ? { options: issue.options.filter(isIssuePrimitive) }
+ : undefined;
break;
case 'too_small':
params = getBoundParams('minimum', issue.minimum, issue);
@@ -663,15 +735,11 @@ export function getConfigIssueParams(issue: SchemaIssue): ConfigIssueParams | un
case 'too_big':
params = getBoundParams('maximum', issue.maximum, issue);
break;
- case 'invalid_string': {
- const { validation } = issue;
- params = {
- validation: typeof validation === 'string' ? validation : Object.keys(validation)[0],
- };
+ case 'invalid_format':
+ params = { validation: STRING_FORMAT_NAMES[issue.format] ?? issue.format };
break;
- }
case 'not_multiple_of': {
- const multipleOf = toIssueNumber(issue.multipleOf);
+ const multipleOf = toIssueNumber(issue.divisor);
params = multipleOf !== undefined ? { multipleOf } : undefined;
break;
}
@@ -816,16 +884,35 @@ type SchemaIssue = NonNullable<
ReturnType<typeof configSchema.safeParse>['error']
>['issues'][number];
+/** A zod issue path as an override path; config keys are never symbols. */
+function toIssuePath(path: readonly PropertyKey[]): IssuePath {
+ return path.filter((segment): segment is string | number => typeof segment !== 'symbol');
+}
+
/**
- * A union reports one issue at its own path; the branch whose failures are fewest, then
- * deepest, is the shape the value was written for, so its issues locate the actual fault.
+ * Unwrap record-key failures and select the closest union branch by issue count, then depth.
+ * Nested issues have relative paths, so each wrapper's path is prepended before recursing.
*/
-function expandUnionIssues(issues: SchemaIssue[], depth = 0): SchemaIssue[] {
+function expandSchemaIssues(issues: SchemaIssue[], depth = 0): SchemaIssue[] {
return issues.flatMap((issue) => {
- if (issue.code !== 'invalid_union' || depth >= MAX_MERGE_DEPTH) {
+ if (depth >= MAX_MERGE_DEPTH) {
+ return [issue];
+ }
+ if (issue.code === 'invalid_key') {
+ return expandSchemaIssues(
+ issue.issues.map((keyIssue) => ({
+ ...keyIssue,
+ path: [...issue.path, ...keyIssue.path],
+ })),
+ depth + 1,
+ );
+ }
+ if (issue.code !== 'invalid_union') {
return [issue];
}
- const branches = issue.unionErrors.map((error) => error.issues);
+ const branches = (issue.errors as SchemaIssue[][]).map((branch) =>
+ branch.map((branchIssue) => ({ ...branchIssue, path: [...issue.path, ...branchIssue.path] })),
+ );
const closest = branches.reduce<SchemaIssue[] | undefined>((best, branch) => {
if (!best || branch.length < best.length) {
return branch;
@@ -833,32 +920,42 @@ function expandUnionIssues(issues: SchemaIssue[], depth = 0): SchemaIssue[] {
const depthOf = (list: SchemaIssue[]) => Math.max(0, ...list.map((i) => i.path.length));
return branch.length === best.length && depthOf(branch) > depthOf(best) ? branch : best;
}, undefined);
- return closest && closest.length > 0 ? expandUnionIssues(closest, depth + 1) : [issue];
+ return closest && closest.length > 0 ? expandSchemaIssues(closest, depth + 1) : [issue];
});
}
/** The parts of a zod schema the shape walk reads, without depending on zod. */
type SchemaNode = {
- _def: {
- typeName?: string;
+ def: {
+ type: string;
innerType?: SchemaNode;
- schema?: SchemaNode;
+ in?: SchemaNode;
+ out?: SchemaNode;
getter?: () => SchemaNode;
- type?: SchemaNode;
+ element?: SchemaNode;
valueType?: SchemaNode;
left?: SchemaNode;
right?: SchemaNode;
- options?: SchemaNode[] | Map<unknown, SchemaNode>;
+ options?: SchemaNode[];
};
shape?: Record<string, SchemaNode>;
safeParse: (value: unknown) => { success: boolean };
};
-/** The schema beneath optional, nullable, default, refinement and lazy wrappers. */
+/** The side of a pipe that validates the value: the input, unless it only preprocesses. */
+function getPipeSchema(node: SchemaNode): SchemaNode | undefined {
+ const { in: input, out } = node.def;
+ return input?.def.type === 'transform' ? out : input;
+}
+
+/** The schema beneath optional, nullable, default, transform, preprocess and lazy wrappers. */
function unwrapSchema(schema: SchemaNode): SchemaNode {
let node = schema;
for (let depth = 0; depth < MAX_MERGE_DEPTH; depth++) {
- const inner = node._def.innerType ?? node._def.schema ?? node._def.getter?.();
+ const inner =
+ node.def.innerType ??
+ (node.def.type === 'pipe' ? getPipeSchema(node) : undefined) ??
+ node.def.getter?.();
if (!inner) {
break;
}
@@ -870,22 +967,18 @@ function unwrapSchema(schema: SchemaNode): SchemaNode {
/** The schema one segment below `node`, through objects, records, arrays and union options. */
function getChildSchema(node: SchemaNode, segment: string, depth = 0): SchemaNode | undefined {
const inner = unwrapSchema(node);
- const { typeName } = inner._def;
- if (typeName === 'ZodObject' && inner.shape) {
+ const { type } = inner.def;
+ if (type === 'object' && inner.shape) {
return hasOwn(inner.shape, segment) ? inner.shape[segment] : undefined;
}
- if (typeName === 'ZodRecord') {
- return inner._def.valueType;
+ if (type === 'record') {
+ return inner.def.valueType;
}
- if (typeName === 'ZodArray') {
- return ARRAY_INDEX.test(segment) ? inner._def.type : undefined;
+ if (type === 'array') {
+ return ARRAY_INDEX.test(segment) ? inner.def.element : undefined;
}
- if (
- (typeName === 'ZodUnion' || typeName === 'ZodDiscriminatedUnion') &&
- inner._def.options &&
- depth < MAX_MERGE_DEPTH
- ) {
- for (const option of inner._def.options.values()) {
+ if (type === 'union' && inner.def.options && depth < MAX_MERGE_DEPTH) {
+ for (const option of inner.def.options.values()) {
const child = getChildSchema(option, segment, depth + 1);
if (child) {
return child;
@@ -898,18 +991,14 @@ function getChildSchema(node: SchemaNode, segment: string, depth = 0): SchemaNod
/** Whether {@link getChildSchema} reaches `segment` below `node` through an array. */
function isArrayStep(node: SchemaNode, segment: string, depth = 0): boolean {
const inner = unwrapSchema(node);
- const { typeName } = inner._def;
- if (typeName === 'ZodArray') {
+ const { type } = inner.def;
+ if (type === 'array') {
return true;
}
- if (
- (typeName !== 'ZodUnion' && typeName !== 'ZodDiscriminatedUnion') ||
- !inner._def.options ||
- depth >= MAX_MERGE_DEPTH
- ) {
+ if (type !== 'union' || !inner.def.options || depth >= MAX_MERGE_DEPTH) {
return false;
}
- for (const option of inner._def.options.values()) {
+ for (const option of inner.def.options.values()) {
if (getChildSchema(option, segment, depth + 1)) {
return isArrayStep(option, segment, depth + 1);
}
@@ -943,7 +1032,7 @@ function resolveConfigSchemaPath(
const segment = rest[index];
/** `from` counts in `segments`, where `rest[index]` is `segments[index + 1]`. */
const counts = index + 1 >= from;
- if (!node || OPAQUE_SCHEMA_TYPES.has(unwrapSchema(node)._def.typeName ?? '')) {
+ if (!node || OPAQUE_SCHEMA_TYPES.has(unwrapSchema(node).def.type)) {
node = undefined;
throughArray = throughArray || (counts && ARRAY_INDEX.test(segment));
continue;
@@ -962,7 +1051,7 @@ function resolveConfigSchemaPath(
*/
export function isConfigRecordPath(segments: readonly string[]): boolean {
const { node } = resolveConfigSchemaPath(segments);
- return node != null && unwrapSchema(node)._def.typeName === 'ZodRecord';
+ return node != null && unwrapSchema(node).def.type === 'record';
}
/**
@@ -992,14 +1081,12 @@ export function isConfigEntryArrayItemPath(
* side is not an object, so nothing is judged on a shape the walk cannot see whole.
*/
function getIntersectionShape(node: SchemaNode, depth = 0): Record<string, SchemaNode> | undefined {
- if (depth >= MAX_MERGE_DEPTH || !node._def.left || !node._def.right) {
+ if (depth >= MAX_MERGE_DEPTH || !node.def.left || !node.def.right) {
return undefined;
}
- const [left, right] = [node._def.left, node._def.right].map((side) => {
+ const [left, right] = [node.def.left, node.def.right].map((side) => {
const inner = unwrapSchema(side);
- return inner._def.typeName === 'ZodIntersection'
- ? getIntersectionShape(inner, depth + 1)
- : inner.shape;
+ return inner.def.type === 'intersection' ? getIntersectionShape(inner, depth + 1) : inner.shape;
});
return left && right ? { ...left, ...right } : undefined;
}
@@ -1007,15 +1094,11 @@ function getIntersectionShape(node: SchemaNode, depth = 0): Record<string, Schem
/** Whether a schema accepts arbitrary keys at this level (a record, or a union with one). */
function isRecordSchema(schema: SchemaNode): boolean {
const node = unwrapSchema(schema);
- const { typeName, options } = node._def;
- if (typeName === 'ZodRecord') {
+ const { type, options } = node.def;
+ if (type === 'record') {
return true;
}
- return (
- (typeName === 'ZodUnion' || typeName === 'ZodDiscriminatedUnion') &&
- options != null &&
- [...options.values()].some(isRecordSchema)
- );
+ return type === 'union' && options != null && [...options.values()].some(isRecordSchema);
}
type ShapeIssue = { code: 'union_dropped_key' | 'dotted_key'; path: IssuePath };
@@ -1068,34 +1151,30 @@ function findShapeIssues(
return [];
}
const node = unwrapSchema(schema);
- const { typeName } = node._def;
- if (typeName === 'ZodObject' && node.shape && isPlainObject(value)) {
+ const { type } = node.def;
+ if (type === 'object' && node.shape && isPlainObject(value)) {
return findObjectShapeIssues(node.shape, value, path, depth);
}
- if (typeName === 'ZodIntersection' && isPlainObject(value)) {
+ if (type === 'intersection' && isPlainObject(value)) {
const shape = getIntersectionShape(node);
return shape ? findObjectShapeIssues(shape, value, path, depth) : [];
}
- if (typeName === 'ZodArray' && node._def.type && Array.isArray(value)) {
- const item = node._def.type;
+ if (type === 'array' && node.def.element && Array.isArray(value)) {
+ const item = node.def.element;
return value.flatMap((entry, index) =>
findShapeIssues(item, entry, [...path, index], depth + 1),
);
}
- if (typeName === 'ZodRecord' && node._def.valueType && isPlainObject(value)) {
- const entrySchema = node._def.valueType;
+ if (type === 'record' && node.def.valueType && isPlainObject(value)) {
+ const entrySchema = node.def.valueType;
return Object.entries(value).flatMap(([key, entry]) =>
findShapeIssues(entrySchema, entry, [...path, key], depth + 1),
);
}
- if (
- (typeName !== 'ZodUnion' && typeName !== 'ZodDiscriminatedUnion') ||
- !node._def.options ||
- !isPlainObject(value)
- ) {
+ if (type !== 'union' || !node.def.options || !isPlainObject(value)) {
return [];
}
- const options = [...node._def.options.values()];
+ const options = [...node.def.options.values()];
const accepted = options.find((option) => option.safeParse(value).success);
if (!accepted) {
/** A strict option fails on the dotted key itself, and parsing reports it only as unrecognized. */
@@ -1178,9 +1257,11 @@ export function getConfigOverrideIssues(
continue;
}
const schema = shape[section as keyof typeof shape] as unknown as SchemaNode;
- const result = shape[section as keyof typeof shape].safeParse(merged[section]);
+ const result = shape[section as keyof typeof shape].safeParse(merged[section], {
+ reportInput: true,
+ });
const shapeIssues = findShapeIssues(schema, merged[section], []);
- const schemaIssues = result.success ? [] : expandUnionIssues(result.error.issues);
+ const schemaIssues = result.success ? [] : expandSchemaIssues(result.error.issues);
if (result.success && shapeIssues.length === 0) {
validSections.add(section);
}
@@ -1189,7 +1270,7 @@ export function getConfigOverrideIssues(
}
for (const issue of schemaIssues) {
if (issue.code !== 'unrecognized_keys') {
- report([section, ...issue.path], issue.code, issue);
+ report([section, ...toIssuePath(issue.path)], getConfigIssueCode(issue), issue);
}
}
}