From fd04674501dfc6ca58c8aa7a92a169597e541989 Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Thu, 4 Dec 2025 17:44:26 +1000 Subject: [PATCH] fix: support AI SDK jsonSchema() with .jsonSchema property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added Strategy 2.5 to schema extraction to handle AI SDK v6's jsonSchema() wrapper which uses `.jsonSchema` property instead of `.schema`. This fixes schema validation errors for @tpmjs/hello and other packages that use jsonSchema() wrapper. Error was: "No valid schema found" with keys ["_type", "jsonSchema", "validate"] Fix: Check for inputSchema.jsonSchema as an object property 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/railway-executor/server.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/railway-executor/server.ts b/apps/railway-executor/server.ts index b788aca..ee78e11 100644 --- a/apps/railway-executor/server.ts +++ b/apps/railway-executor/server.ts @@ -232,6 +232,17 @@ async function loadAndDescribe(req: Request): Promise { rawJsonSchema = toolModule.inputSchema.schema; } + // Strategy 2.5: Try AI SDK jsonSchema() wrapper (has .jsonSchema property) + // Note: Some versions use .jsonSchema instead of .schema + if ( + !rawJsonSchema && + toolModule.inputSchema.jsonSchema && + typeof toolModule.inputSchema.jsonSchema === 'object' + ) { + console.log(`📋 Using AI SDK jsonSchema.jsonSchema for ${cacheKey}`); + rawJsonSchema = toolModule.inputSchema.jsonSchema; + } + // Strategy 3: Try Zod v3 schema (detect via _def property and convert) if (!rawJsonSchema && toolModule.inputSchema._def) { console.log( @@ -252,7 +263,10 @@ async function loadAndDescribe(req: Request): Promise { hasInputSchema: !!toolModule.inputSchema, inputSchemaType: typeof toolModule.inputSchema, hasToJSONSchema: typeof toolModule.inputSchema?.toJSONSchema === 'function', - hasJsonSchema: typeof toolModule.inputSchema?.jsonSchema === 'function', + hasJsonSchemaFunction: typeof toolModule.inputSchema?.jsonSchema === 'function', + hasJsonSchemaProperty: + !!toolModule.inputSchema?.jsonSchema && + typeof toolModule.inputSchema?.jsonSchema === 'object', hasSchema: !!toolModule.inputSchema?.schema, keys: toolModule.inputSchema ? Object.keys(toolModule.inputSchema) : [], });