UNPKG

@openai/agents-core

Version:

The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.

52 lines • 1.63 kB
export function asZodType(schema) { return schema; } export function readZodDefinition(input) { if (typeof input !== 'object' || input === null) { return undefined; } const candidate = input; return candidate._zod?.def || candidate._def || candidate.def; } export function readZodDescription(value) { if (typeof value === 'object' && value !== null) { const direct = value.description; if (typeof direct === 'string' && direct.trim()) { return direct; } } let current = value; const visited = new Set(); while (current && typeof current === 'object' && !visited.has(current)) { visited.add(current); const def = readZodDefinition(current); if (typeof def?.description === 'string' && def.description.trim()) { return def.description; } const next = def?.innerType ?? def?.schema ?? def?.base ?? def?.type ?? def?.wrapped ?? def?.underlying; if (!next || next === current) { break; } current = next; } return undefined; } export function readZodType(input) { const def = readZodDefinition(input); if (!def) { return undefined; } const rawType = (typeof def.typeName === 'string' && def.typeName) || (typeof def.type === 'string' && def.type); if (typeof rawType !== 'string') { return undefined; } const lower = rawType.toLowerCase(); return lower.startsWith('zod') ? lower.slice(3) : lower; } //# sourceMappingURL=zodCompat.mjs.map