Skip to content

feat(sdk): support Standard Schema extract schemas - #2847

Draft
antonvishal wants to merge 12 commits into
browserbase:mainfrom
antonvishal:codex/standard-schema-docs
Draft

feat(sdk): support Standard Schema extract schemas#2847
antonvishal wants to merge 12 commits into
browserbase:mainfrom
antonvishal:codex/standard-schema-docs

Conversation

@antonvishal

@antonvishal antonvishal commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Make TypeScript extract() accept Standard Schema implementations that can also produce Draft 2020-12 JSON Schema, then validate the schema and extracted value consistently across the SDK, protocol, and browser extension.

  • Accept Zod 4.2+, ArkType, and compatible Standard Schema implementations directly.
  • Add adapters for Valibot, Effect, TypeBox, and raw JSON Schema.
  • Bound schema validation and local $ref resolution before schemas reach model inference.
  • Validate structured model output against the normalized schema before returning it.
  • Add shared fixtures for TypeScript, Python, and Go schema generation.
  • Document the new contract, migration behavior, supported libraries, and errors.

Stack

The mergeable upstream diff is this PR. For smaller review boundaries, read these draft PRs from bottom to top:

  1. Protocol conversion and validation
  2. TypeScript SDK schema adapters
  3. Extension conversion and runtime validation
  4. Cross-SDK fixtures, docs, and release wiring

Review boundary

This is the cumulative merge target because GitHub cannot create a stack across the contributor fork and the upstream repository. The linked fork PRs exist only to provide small, focused diffs. Review comments can go on those PRs, but the final approval and merge happen here. After this PR merges, the fork PRs will be closed.

Test plan

The exact source tip passed the locally runnable CI suite before restacking:

  • TypeScript checks and unit tests.
  • Python lock, generation, Ruff, typecheck, and 474 pytest tests.
  • Local-browser integration suite: 31 files and 184 tests passed.
  • Go generation, formatting, vet, examples, SDK and generator tests, builds, and embedded-extension drift.

The reconstructed stack was checked layer by layer:

  • Protocol build and typecheck; 27 test files and 368 tests passed.
  • TypeScript SDK build and publint; 16 test files and 242 tests passed.
  • Extension build; 38 test files with 334 tests passed and 10 existing TODOs.
  • Documentation and package-contract tests: 2 files and 28 tests passed.
  • Python and Go cross-language schema fixtures passed.
  • Changeset validation and embedded-extension drift passed.
  • The stack tip is byte-for-byte identical to the tested standard-schema source branch.

TODO

  • Improve the plain JSON Schema DX. The current jsonSchema() wrapper works, but the ergonomics and error guidance need another pass before this draft is ready for review.

@changeset-bot

changeset-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c2467fa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@browserbasehq/stagehand Major
@browserbasehq/stagehand-protocol Patch
@browserbasehq/stagehand-integrations Patch
@browserbasehq/stagehand-integrations-example-eve-facade Patch
@browserbasehq/stagehand-integrations-example-pi-facade Patch
@browserbasehq/stagehand-integrations-example-claude-code-facade Patch
@browserbasehq/stagehand-integrations-example-codex-facade Patch
@browserbasehq/stagehand-integrations-example-mastra-facade Patch
@browserbasehq/stagehand-integrations-example-vercel-ai-facade Patch

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

@github-actions

Copy link
Copy Markdown
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions Bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Aug 28, 2026
@socket-security

socket-security Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​cfworker/​json-schema@​4.1.11001009480100
Addednpm/​@​valibot/​to-json-schema@​1.7.110010010083100
Addednpm/​valibot@​1.4.21001009985100
Addednpm/​effect@​4.0.0-rc.1121001009097100

View full report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant