-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add support for zod v4 #1282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for zod v4 #1282
Conversation
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
- Moved complete LLMUsage and LLMParsedResponse definitions to LLMClient.ts - Added reasoning_tokens and cached_input_tokens to LLMUsage interface - Re-export types from inference.ts for backward compatibility - Keeps cleaner architecture with types in their proper location
🦋 Changeset detectedLatest commit: d66a5d6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
92 files reviewed, 1 comment
Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
93 files reviewed, no comments
Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format
Greptile Summary
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Stagehand
participant zodCompat
participant LLMClient
participant LLM as "LLM Provider"
User->>Stagehand: extract(instruction, zodSchema)
Stagehand->>zodCompat: toJsonSchema(zodSchema)
zodCompat->>zodCompat: isZod4Schema(schema)?
alt Zod v4
zodCompat->>zodCompat: z.toJSONSchema(schema)
else Zod v3
zodCompat->>zodCompat: zodToJsonSchema(schema)
end
zodCompat-->>Stagehand: jsonSchema
Stagehand->>LLMClient: createChatCompletion(options)
LLMClient->>LLM: API call with jsonSchema
LLM-->>LLMClient: structured response
LLMClient-->>Stagehand: {data, usage}
Stagehand-->>User: extracted data
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
93 files reviewed, no comments
Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format
Why
Adds support for zod 4 while maintaining backwards compatibility with zod 3
What changed
Manual testing
To make sure nothing regressed, I ran:
Custom OpenAI client example (schema conversion + structured output).
Standard extract (including URL injection path).
Google computer-use agent with a custom tool.
Anthropic computer-use agent with a custom tool.
All behaved as before