Skip to content

stagehand-python@4.5.0a0.dev1708

@seanmcguire12 seanmcguire12 tagged this 16 Nov 23:51
# why
- the extension had a reverse dependency on code inside of the ts sdk
- this is because `experimentalBatch()` uses the same object model
(`page`, `locator`, `browsercontext`, etc) as the client side ts sdk
- the ts sdk should depend on the extension. not the other way around
# what changed
- moved shared object model code into its own package/workspace member
called `shared-object-model`
- the ts sdk & the extension now both depend on the
`shared-object-model`. this fixes the circular dependency/package
boundary issue without having duplicate/independent implementations
# test plan
- test boundaries need to be addressed in a later PR. for now, this PR
just adds a few AST grep rules for actual production code to check for
cross package imports

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Removes the circular dependency between the extension and the TS SDK by
extracting their shared object model into a new workspace package,
`@browserbasehq/stagehand-browser-api`. The extension no longer imports
SDK internals; both now depend on the shared package.

- The new package holds the shared object model (`Page`, `Locator`,
`BrowserContext`, etc.), operation schemas, and file upload helpers.
- Node file access, capture writes, and base64 encoding are injected
through a platform adapter; extension batch runs default to browser
capabilities, while the SDK supplies Node capabilities. File upload
encoding now handles cross-realm buffers, preserves typed-array slices,
and rejects invalid buffer payloads.
- AST grep rules enforce package boundaries and prevent cross-imports
between the SDK, extension, and shared package, while an oxlint rule
forbids Node globals in browser production code (ignoring local
bindings, property names, tests, and build files).

<sup>Written for commit 3638ac1651cdac5c40c9a09c894c0e18e759826e.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/browserbase/stagehand/pull/3372?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/browserbase/stagehand/3372?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3372&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->
Assets 2
Loading