Documentation
¶
Overview ¶
Package browser runs the sandbox's visible Chromium (DBX-45): Xvfb, Chromium with a CDP port the agent's Playwright MCP drives, x11vnc on localhost bridged to the /browser/vnc WebSocket, and the /preview/:port/* reverse proxy. The browser starts on demand (StartBrowser, a VNC viewer, or the first CDP connection) and stops when idle.
Index ¶
- Constants
- type Browser
- func (b *Browser) Available() bool
- func (b *Browser) IdleLoop(ctx context.Context)
- func (b *Browser) Info() *devboxv1.BrowserInfo
- func (b *Browser) LastActivity() time.Time
- func (b *Browser) Pipe(a, c io.ReadWriteCloser)
- func (b *Browser) PlaywrightMCP(command string) map[string]any
- func (b *Browser) ServeCDP(ctx context.Context) error
- func (b *Browser) ServeVNC(w http.ResponseWriter, r *http.Request)
- func (b *Browser) Start(ctx context.Context, width, height int32, url string) (*devboxv1.BrowserInfo, error)
- func (b *Browser) Stop() *devboxv1.BrowserInfo
- func (b *Browser) Streams() int
- type Options
- type PreviewProxy
Constants ¶
const ( DefaultDisplay = ":99" DefaultCDPPort = 9222 DefaultVNCPort = 5900 DefaultIdleTimeout = 15 * time.Minute VNCPath = "/browser/vnc" )
Defaults.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
Browser manages the browser stack.
func (*Browser) IdleLoop ¶
IdleLoop stops the browser after IdleTimeout without streams or stream bytes.
func (*Browser) Info ¶
func (b *Browser) Info() *devboxv1.BrowserInfo
Info returns the browser state.
func (*Browser) LastActivity ¶
LastActivity is the last time a stream carried bytes or the browser was started.
func (*Browser) Pipe ¶
func (b *Browser) Pipe(a, c io.ReadWriteCloser)
Pipe copies bytes both ways, counting the stream and its activity.
func (*Browser) PlaywrightMCP ¶
PlaywrightMCP is the stdio MCP server entry that drives this browser, added to every session when the image ships playwright-mcp.
func (*Browser) ServeCDP ¶
ServeCDP accepts agent CDP connections on 127.0.0.1:CDPPort, starting the browser on first use.
func (*Browser) ServeVNC ¶
func (b *Browser) ServeVNC(w http.ResponseWriter, r *http.Request)
ServeVNC bridges the /browser/vnc WebSocket (noVNC, binary frames) to x11vnc on localhost, starting the browser if needed.
type Options ¶
type Options struct {
Chromium string
Xvfb string
X11VNC string
Display string
// CDPPort is the localhost port agents connect to; the daemon proxies it to Chromium's own port (CDPPort+1)
// so the first connection can start the browser.
CDPPort int
VNCPort int
ProfileDir string
ExtraFlags []string
IdleTimeout time.Duration
Env func() []string
Supervisor *proc.Supervisor
Clock clock.Clock
Log *slog.Logger
}
Options configure a Browser.
type PreviewProxy ¶
type PreviewProxy struct {
// Deny are ports that must not be proxied (the daemon's own listener).
Deny map[int]bool
// Activity is told about proxied traffic (idle detection).
Activity *Browser
}
PreviewProxy serves /preview/<port>/* by reverse-proxying to 127.0.0.1:<port> (WebSockets included).
func (*PreviewProxy) ServeHTTP ¶
func (p *PreviewProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.