@openai/agents-core
Version:
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.
58 lines • 1.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.asZodType = asZodType;
exports.readZodDefinition = readZodDefinition;
exports.readZodDescription = readZodDescription;
exports.readZodType = readZodType;
function asZodType(schema) {
return schema;
}
function readZodDefinition(input) {
if (typeof input !== 'object' || input === null) {
return undefined;
}
const candidate = input;
return candidate._zod?.def || candidate._def || candidate.def;
}
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;
}
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.js.map