fix(core): replace _def introspection with zod-to-json-schema

elsium-ai/elsium-ai·May 18, 2026·✅ Merged

Direct access to schema._def breaks when Zod internals change. Need safe, public JSON Schema conversion using zod-to-json-schema.

The elsium-ai codebase had direct accesses to schema._def across multiple files for converting Zod schemas to JSON Schema. This approach relied on private Zod internals that could break with any Zod version upgrade, making the code fragile and maintenance-heavy.

This PR replaced all _def introspection with the zod-to-json-schema library (v3.25.2) for safe, public JSON Schema conversion. A post-processing layer maintains backward-compatible output for LLM providers. The change involved rewriting zodToJsonSchema across 10 files with 772 additions and 133 deletions, adding the library as a dependency to @elsium-ai/core, and updating tests for ZodDefault to reflect that the library preserves default values. All 2121 existing tests pass with zero behavioral changes for consumers — the exported zodToJsonSchema(schema) signature remains identical.

GitHub
LinkedIn
LeetCode