Repository navigation
computer: Add a ws:browser host module - #248
Draft
mattzcarey wants to merge 3 commits into
Draft
mattzcarey wants to merge 3 commits into
mattzcarey wants to merge 3 commits 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: e1e67d3 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: |
ws:browser kept its own copy of the CDP logic agents/browser already has: the active tab, attach handles, error hints and the end-of-run report. It now takes anything with a name and session(), such as Browser from agents/browser, starts one session per run, and on the run's end closes it and writes the report to standard error. The package still doesn't depend on agents.
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 are moving off
@cloudflare/codemode, which is being deprecated, and the browser itself stays in agents:nameand asession({ scope, maxResultBytes }).Browserfromagents/browserhas that shape (browser: run createBrowserTool without codemode, on a BrowserSession聽agents#2612), so neither package imports the other"active"tab, attach handles that last between runs, refusingBrowser.close, hints for common mistakes) live in that session, sows:browserand agents' directcreateBrowserToolbehave the same waynpm testinpackages/computerandnpm run checkran. Unit tests cover the routing to one session per run, the options passed through and the report lines. A workerd test importsws:browserfromexeccode and sees a restart on standard error. A scratch type check against agents' built types confirmedBrowseris assignable toBrowserSource, and that aconnect()-only source isn't.Stacked on #247, which adds
executionId,loganddefer.