From d132da9c20f25b23adcb3a7b2a07b18ee12bdf09 Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Mon, 29 Dec 2025 23:29:06 +1000 Subject: [PATCH] fix: use z.toJSONSchema for Zod v4 schema conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Import zod@4 directly and use z.toJSONSchema method with fallback to z.default.toJSONSchema for compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- apps/railway-executor/server.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/railway-executor/server.ts b/apps/railway-executor/server.ts index 3b87011..481c683 100644 --- a/apps/railway-executor/server.ts +++ b/apps/railway-executor/server.ts @@ -410,13 +410,16 @@ async function loadAndDescribe(req: Request): Promise { if (!rawJsonSchema && toolModule.inputSchema._zod) { console.log(`📋 Detected Zod v4 schema for ${cacheKey}`); try { - // Dynamically import Zod v4's toJSONSchema function - const zodJsonSchema = await import('https://esm.sh/zod@4.0.0/json-schema'); - if (zodJsonSchema.toJSONSchema) { - rawJsonSchema = zodJsonSchema.toJSONSchema(toolModule.inputSchema); - console.log(`✅ Successfully converted Zod v4 schema for ${cacheKey}`); + // Dynamically import Zod v4 and use its toJSONSchema method + const zod = await import('https://esm.sh/zod@4'); + if (zod.toJSONSchema) { + rawJsonSchema = zod.toJSONSchema(toolModule.inputSchema); + console.log(`✅ Successfully converted Zod v4 schema using z.toJSONSchema for ${cacheKey}`); + } else if (zod.default?.toJSONSchema) { + rawJsonSchema = zod.default.toJSONSchema(toolModule.inputSchema); + console.log(`✅ Successfully converted Zod v4 schema using z.default.toJSONSchema for ${cacheKey}`); } else { - console.warn(`⚠️ Zod v4 toJSONSchema function not found in module`); + console.warn(`⚠️ Zod v4 toJSONSchema not found. Available exports:`, Object.keys(zod)); } } catch (error) { console.warn(`⚠️ Zod v4 toJSONSchema conversion failed for ${cacheKey}:`, error);