Repository navigation
[shared] Move to zod 4 and AG-UI 1.0 - #101
Merged
Merged
Conversation
The two travel together: AG-UI 1.0's validators are zod 4 schemas (and
take zod as a peer), and kitAguiEventSchema is a z.discriminatedUnion
over them, so neither upgrade type-checks without the other.
AG-UI 0.0.59 -> 1.0.3 (exact): validators come from @ag-ui/core/schemas;
TOOL_CALL_RESULT.content is typed string | parts, which tests and the
eval transcript now narrow. @ag-ui/proto 1.0.3 carries TOOL_CALL_RESULT,
so the protobuf drop list is empty and a test round-trips the event.
zod 3 -> 4: ZodTypeDef is gone (z.ZodType<Output, Input>), z.record
needs a key schema, invalid_type_error is error, ZodObject generics
changed. JobVariant/JobTypeOf in the plugin API are restated for zod 4.
zod-to-json-schema is replaced by z.toJSONSchema (draft-7, input side).
zod 4 fills a .default() field under .partial(): example-feature's
update schema turned PATCH { title } into { title, body: '' }. It is
rebuilt without the default, with a test; no kit schema had the shape.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This moves the kit to zod 4 (
^3.25.76→^4.6.7) and AG-UI 1.0 (0.0.59→1.0.3, exact pins) in one PR, because neither type-checks without the other. AG-UI 1.0's validators are zod 4 schemas, andkitAguiEventSchemais az.discriminatedUnionover them:Behaviour changes:
TOOL_CALL_RESULT(PROTO_UNSUPPORTED_EVENTS = [])@ag-ui/proto@1.0.3has the message. A new test round-trips the whole event, not just its type.example-feature's PATCH no longer fillsbody: ''.default()under.partial(), soPATCH { title }would have wiped the body. The update schema is rebuilt without the default. An audit of every.partial()found no other affected schema.zod-to-json-schemaremoved;toolInputSchema()usesz.toJSONSchemadraft-7, input side (so defaulted fields are optional) and lenient on unrepresentable types, the same as before.Type-level changes:
ZodTypeDefis gone, so the UI'sapi-client.tsinferred every response as{}until its signature becamez.ZodType<T, unknown>.z.recordneeds a key schema.invalid_type_erroris nowerror.ZodObjectgenerics changed.TOOL_CALL_RESULT.contentisstring | ContentPart[]. The kit still emits strings, and its readers now narrow.Plugin API (
docs/plugin-api.md, regenerated):JobVariantis nowZodObject<{ type: ZodTypeAny } & ZodRawShape>.JobTypeOfreads the variant'sshape.type.The type test pinning
JobTypeOf<Orders>to'orders.sync'still passes.Docs:
docs/CONCEPTS.md§9's known gaps drop "protobuf dropsTOOL_CALL_RESULT" and "@ag-ui/coreis 0.0.x", and add that a cancelled run doesn't emit AG-UI 1.0'scancelledRUN_FINISHEDoutcome.Left for later:
.uuid(),.email(),.passthrough(),.strict()) still work, and no tool reports them. Moving toz.uuid()and the like would be about 200 lines of churn, so it's left for a separate PR.createAguiEncodernever fires while the list is empty. I kept it because the contract test compares the list with a real round-trip, so the next upstream gap fails loudly.Evidence
pnpm typecheckgives 12 errors inshared, then 325 inweb(pages inferring{}).After:
pnpm gatepasses on Node 26.13.0: api 638, the other web projects 1807 + 5 skipped (2 new tests), driver 13, cli 58, evals 25.+ "body": ""before the fix and passes after.kit.yml's plugins job (plugin add …@3.4.2,db:generate, migrate,GATE_SUITE_DRIVER=neon pnpm gate). Typecheck, build, api 685 and the rest passed. The one failure was local only: my global gitignore hides.claude/, and with the skill files staged it passes.Merge Danger
Door: two-way
Blast Radius: plugins
Plugins compile against the host's zod, so a plugin with zod 3–only code (
ZodTypeDef, single-argumentz.record,.partial()over defaults) breaks on a host that takes this. The porting note's steps 27–34 cover the migration, including the.partial()audit.🤖 Generated with Claude Code