fix: use dynamic import for Zod v4 JSON schema conversion
Static import from 'zod@4/json-schema' was failing and crashing executor. Use dynamic import inside the schema extraction logic instead. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
1c8b516db8
commit
c2d244a5c9
1 changed files with 9 additions and 7 deletions
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
// Import zod-to-json-schema for Zod v3 support
|
||||
import { zodToJsonSchema } from 'https://esm.sh/zod-to-json-schema@3.25.0';
|
||||
// Import Zod v4's JSON Schema converter (for packages using Zod v4)
|
||||
import { toJSONSchema as zodV4ToJsonSchema } from 'https://esm.sh/zod@4/json-schema';
|
||||
|
||||
// Cache TTL: 2 minutes
|
||||
const CACHE_TTL_MS = 2 * 60 * 1000;
|
||||
|
|
@ -410,12 +408,16 @@ async function loadAndDescribe(req: Request): Promise<Response> {
|
|||
|
||||
// Strategy 3: Try Zod v4 schema (detect via _zod property - new in Zod v4)
|
||||
if (!rawJsonSchema && toolModule.inputSchema._zod) {
|
||||
console.log(
|
||||
`📋 Detected Zod v4 schema, converting with Zod v4 toJSONSchema for ${cacheKey}`
|
||||
);
|
||||
console.log(`📋 Detected Zod v4 schema for ${cacheKey}`);
|
||||
try {
|
||||
rawJsonSchema = zodV4ToJsonSchema(toolModule.inputSchema);
|
||||
console.log(`✅ Successfully converted Zod v4 schema for ${cacheKey}`);
|
||||
// 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}`);
|
||||
} else {
|
||||
console.warn(`⚠️ Zod v4 toJSONSchema function not found in module`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`⚠️ Zod v4 toJSONSchema conversion failed for ${cacheKey}:`, error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue