Documentation
¶
Overview ¶
Package browser manages optional, externally installed Chrome processes for runner workspaces.
Index ¶
- type AssetChunk
- type Config
- type Info
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) Command(ctx context.Context, scope Scope, method string, params json.RawMessage) (json.RawMessage, error)
- func (m *Manager) Connect(ctx context.Context, scope Scope, sessionID string) (*websocket.Conn, func(), error)
- func (m *Manager) Enabled() bool
- func (m *Manager) Open(ctx context.Context, scope Scope) (Info, error)
- func (m *Manager) ReadAsset(path string, offset int64) (AssetChunk, error)
- func (m *Manager) Stop(scope Scope, sessionID string) error
- type Scope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetChunk ¶
type AssetChunk struct {
Data []byte `json:"data"`
ContentType string `json:"contentType"`
EOF bool `json:"eof"`
}
AssetChunk is a bounded portion of one trusted DevTools frontend file.
type Config ¶
type Config struct {
// Executable is an installed Chrome/Chromium executable or PATH name. Blank disables launching.
Executable string
// DevToolsDir optionally contains a compiled frontend compatible with the installed browser version.
// These trusted assets are never downloaded or embedded by this package.
DevToolsDir string
// IdleTimeout applies only to sessions without attachments. Nonpositive values use fifteen minutes.
IdleTimeout time.Duration
}
Config is trusted runner configuration, not workspace- or page-provided input.
type Info ¶
type Info struct {
SessionID string `json:"sessionId"`
ConversationID string `json:"conversationId"`
CWD string `json:"cwd"`
DevTools bool `json:"devTools"`
}
Info identifies one immutable browser session. DevTools indicates a configured frontend directory.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns at most four conversation sessions, independently of individual agent runs. Call Close at runner shutdown. Connections must be released even if their socket has already closed.
func NewManager ¶
NewManager creates a lazy manager. It does not launch a browser or inspect a user profile.
func (*Manager) Close ¶
Close stops all sessions and waits for subprocess and temporary-profile cleanup.
func (*Manager) Command ¶
func (m *Manager) Command(ctx context.Context, scope Scope, method string, params json.RawMessage) (json.RawMessage, error)
Command opens or reuses a session and sends one CDP command over its own page connection. It returns the command's result (not the envelope), ignoring events and unrelated response IDs. Methods are not allowlisted: authorization belongs to the caller, as it does for Connect.
func (*Manager) Connect ¶
func (m *Manager) Connect(ctx context.Context, scope Scope, sessionID string) (*websocket.Conn, func(), error)
Connect attaches to an existing page target, never creating a session for a stale ID. The idempotent release function closes the socket and releases its idle-timeout lease. Canceling ctx, stopping the session, or closing the manager also closes the socket.
func (*Manager) Enabled ¶
Enabled reports whether an executable is configured, not whether it has successfully launched.
func (*Manager) Open ¶
Open opens or reuses a conversation session. Concurrent opens within a scope share one startup. Canceling the initiating request during startup tears down that startup; after success, request cancellation does not affect the browser lifetime.