Repository navigation
computer: Add a ws:browser host module - #248
Draft
mattzcarey wants to merge 1 commit into
Draft
mattzcarey wants to merge 1 commit into
mattzcarey wants to merge 1 commit into
Conversation
createBrowserModule() from @cloudflare/computer/modules/browser lets
isolate JavaScript drive a persistent Chrome browser over the Chrome
DevTools Protocol: send, attachToTarget, spec, getDebugLog and
clearDebugLog.
The browser belongs to the host. The module takes anything with the
BrowserSource shape, a name and a connect({ scope }) that returns a
CDP connection and the scope's active tab. Browser from agents/browser
has that shape, so neither package depends on the other.
Each run gets its own CDP connection, keyed by the call context's
executionId. A deferred function saves the scope's active tab, closes
the connection, and writes restarts, closed or shared tabs and tabs
the page opened to the run's standard error. sessionId "active", the
attach handles that work across runs, scopes, refusing Browser.close
and the hints for common CDP mistakes follow the browser tool in
agents. The module is experimental.
馃 Changeset detectedLatest commit: f11d1ad The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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 |
commit: |
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.
Adds an experimental
ws:browserhost module,createBrowserModule()from@cloudflare/computer/modules/browser. Code thatexecruns can drive a persistent Chrome browser over the Chrome DevTools Protocol withsend,attachToTarget,spec,getDebugLogandclearDebugLog.The agents SDK's browser tools run on
@cloudflare/codemode, which is being deprecated, and running code is moving toexecon a Workspace. The browser itself (sessions, Browser Run, Live View) stays in agents. So this module takes anything with theBrowserSourceshape: anameand aconnect({ scope })that returns a CDP connection plus the scope's active tab.Browserfromagents/browserhas that shape, so neither package imports the other. A scratch type check confirmedBrowseris assignable toBrowserSource.Behavior follows the agents browser tool:
sessionId: "active"is the scope's tab, remembered between runs;attachToTargetreturns handles that work across runs;Browser.closeis refused;Each run gets its own connection, keyed by
executionId. A deferred function saves the active tab, closes the connection, and writes restarts and tabs the page opened to standard error. The module's description covers the calls and those rules for the model.npm testinpackages/computerandnpm run checkran. Unit tests use an in-memory browser that keeps tabs and active tabs across connections. A workerd test importsws:browserfromexeccode and sees a restart on standard error.docs/17_isolate_javascript.mdand the package README's status table cover the module.Stacked on #247, which adds
executionId,loganddefer.