agentbrowser

package
v0.16.397 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agentbrowser owns persistent browser profiles and conversation tabs.

Index

Constants

View Source
const (
	DefaultIdle     = 3 * time.Minute
	DefaultMaxHosts = 3
	DefaultMaxTabs  = 8
	DefaultNice     = 10
)

The defaults of ConfigFromEnv: the same as the pane's live browser, a little wider for tabs (a profile serves every chat of a project).

View Source
const DefaultProfile = "common"

DefaultProfile is used for conversations without an explicit profile binding.

Variables

View Source
var ErrControlInterrupted = errors.New("Interrupted: the person changed browser control; retry")

ErrControlInterrupted asks an agent to retry after a person changes browser control.

View Source
var ErrDialogOpen = errors.New("browser tab has an open JavaScript dialog")

ErrDialogOpen means the command needs a renderer blocked by a JavaScript dialog. It applies to Runtime.*, DOM.*, DOMSnapshot.*, Accessibility.*, Page.getLayoutMetrics, Page.getFrameTree, Page.getResourceTree, Page.captureScreenshot, Input.insertText, Emulation.setDeviceMetricsOverride and Emulation.clearDeviceMetricsOverride. Mouse/key dispatch and Page.handleJavaScriptDialog remain available.

View Source
var ErrHandoffHistory = errors.New("cannot return browser control: navigation history could not be cleared")

ErrHandoffHistory keeps person control when old personal documents might still be reachable through the browser's back and forward history.

View Source
var ErrNotOwner = errors.New("browser tab belongs to another conversation")

ErrNotOwner means the requested tab does not belong to the calling conversation.

View Source
var ErrOff = errors.New("agent browser is disabled")

ErrOff reports that the browser was disabled by configuration.

View Source
var ErrPersonControl = errors.New("browser tab is controlled by the person")

ErrPersonControl means the person has reserved the tab's controls.

View Source
var ErrPersonDocument = errors.New("The person typed on this page; JavaScript is unavailable here until the tab loads " +
	"a new document (navigating to the same address works). Use chrome_snapshot.")

ErrPersonDocument keeps agent JavaScript away from a document containing human input.

View Source
var ErrProfileUnavailable = errors.New("Browser profile is unavailable to this chat")

ErrProfileUnavailable deliberately makes missing and unauthorized names indistinguishable.

Functions

func AllowedURL

func AllowedURL(raw string) error

AllowedURL is shared by chrome_open and login requests: http(s) or about:blank. Where an address may lead (localhost only to the machine's dev servers) is the egress's to decide; see host.Refusal.

func FindChrome

func FindChrome() (string, error)

FindChrome discovers an installed browser without downloading; Manager.Ready also provisions missing Chrome.

func ImportChrome

func ImportChrome(ctx context.Context, source, destination string) (warning string, err error)

ImportChrome copies a stopped Chrome user-data directory to a new or empty destination (the managed profile's chrome directory). The source is untouched. It cannot decrypt cookies protected by another system keyring or OS account.

func NormalizeURL

func NormalizeURL(u string) string

NormalizeURL supplies HTTPS for addresses without an explicit scheme.

func Shown

func Shown(url string) bool

Shown excludes browser internals from the conversation's page list.

Types

type AgentEvent

type AgentEvent struct {
	Method, Session string
	Params          json.RawMessage
}

AgentEvent is a tab-scoped event. Session is empty for the tab itself.

type AgentFrame

type AgentFrame struct{ Session, Frame, Parent string }

AgentFrame identifies a flattened child session without exposing the shared connection. Parent is empty when the frame belongs directly to the tab session.

type Call

type Call struct {
	Method string
	Params map[string]any
}

Call is one CDP method and its params.

type Config

type Config struct {
	// ProfileOf resolves a conversation on each InstanceFor call. Nil or an empty result
	// selects DefaultProfile. The callback must be safe for concurrent calls.
	ProfileOf     func(conv string) string
	LookupProfile func(id string) (Profile, bool)
	// NoSandbox, when set, is the explicit preference and overrides environment flags.
	NoSandbox func() bool
	// Idle is the inactivity timeout; zero disables automatic shutdown.
	Idle time.Duration
	// MaxHosts bounds the managed browsers running at once for this runtime (RUNTIME_BROWSER_MAX_HOSTS): starting one
	// more closes the longest idle, or is refused while every one is busy. Zero is no bound.
	MaxHosts int
	// MaxTabs bounds a browser's tabs and its renderer processes (RUNTIME_BROWSER_MAX_TABS); zero is no bound.
	MaxTabs int
	// Nice lowers the priority of Chrome and Xvfb (RUNTIME_BROWSER_NICE).
	Nice int
	// DownloadLimit is the largest file a page may download into its profile (RUNTIME_BROWSER_DOWNLOAD_LIMIT,
	// bytes); zero refuses downloads.
	DownloadLimit int64
	DataDir       string
	Executable    string
	Chrome        string
	Mode          string
	CDP           string
	Off           bool
}

Config selects managed Chrome or an externally owned CDP endpoint.

func ConfigFromEnv

func ConfigFromEnv(data string) Config

ConfigFromEnv reads browser settings without starting any processes.

type ConversationIdentity

type ConversationIdentity struct {
	Project     string
	ProjectName string
	Title       string
}

ConversationIdentity is read from a local conversation record, not request arguments.

type Dialog

type Dialog struct {
	Type          string `json:"type"`
	Message       string `json:"message"`
	DefaultPrompt string `json:"defaultPrompt"`
}

Dialog describes a JavaScript modal dialog currently awaiting a response.

type Frame

type Frame struct {
	Width, Height int
	JPEG          []byte
}

Frame contains a JPEG and the page size in CSS pixels, independent of JPEG scaling.

func (Frame) Encode

func (f Frame) Encode(gen uint32) []byte

Encode prefixes a frame with dimensions and the panel's selection generation.

type Input

type Input struct {
	Index      int     `json:"index,omitempty"`
	Accept     bool    `json:"accept,omitempty"`
	Holder     string  `json:"holder,omitempty"`
	Mode       string  `json:"mode,omitempty"`
	W          int     `json:"w,omitempty"`
	H          int     `json:"h,omitempty"`
	DPR        float64 `json:"dpr,omitempty"`
	T          string  `json:"t"` // See the complete wire contract in protocol.go.
	Type       string  `json:"type,omitempty"`
	Button     string  `json:"button,omitempty"`
	Buttons    int     `json:"buttons,omitempty"`
	ClickCount int     `json:"clickCount,omitempty"`
	X          float64 `json:"x,omitempty"`
	Y          float64 `json:"y,omitempty"`
	DX         float64 `json:"dx,omitempty"`
	DY         float64 `json:"dy,omitempty"`
	Key        string  `json:"key,omitempty"`
	Code       string  `json:"code,omitempty"`
	KeyCode    int     `json:"keyCode,omitempty"`
	Text       string  `json:"text,omitempty"`
	ID         string  `json:"id,omitempty"`
	Action     string  `json:"action,omitempty"`
	URL        string  `json:"url,omitempty"`
	Alt        bool    `json:"alt,omitempty"`
	Ctrl       bool    `json:"ctrl,omitempty"`
	Meta       bool    `json:"meta,omitempty"`
	Shift      bool    `json:"shift,omitempty"`
}

Input is what the person does in the pane.

func (Input) Calls

func (in Input) Calls() []Call

Calls is what an input asks of Chrome, in order; nothing for one the pane cannot send.

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance keeps registry locks independent of browser replies and disk writes.

func (*Instance) AgentCall

func (i *Instance) AgentCall(ctx context.Context, conv, id, method string, params any) (json.RawMessage, error)

AgentCall is the tab-scoped entry point for tools. It enforces ownership and control; renderer commands additionally fail with ErrDialogOpen while a dialog awaits an answer. Page.handleJavaScriptDialog is allowed through this entry point. Ownership and control are checked again after attachment, immediately before dispatch. Commands already dispatched are not cancelled when the person changes control.

func (*Instance) AgentCheck

func (i *Instance) AgentCheck(conv, id, method string) error

AgentCheck allows tools to validate metadata operations without sending a command into a renderer that may already be blocked by a modal dialog.

func (*Instance) AgentCloseTab

func (i *Instance) AgentCloseTab(ctx context.Context, conv, id string) error

AgentCloseTab closes only an owned, agent-controlled tab, including a tab with a dialog.

func (*Instance) AgentEvents

func (i *Instance) AgentEvents(ctx context.Context, conv, id string) (<-chan AgentEvent, func(), error)

AgentEvents observes only an owned tab; callers must unsubscribe when the tab is no longer used. A bounded queue deliberately drops excess events so tools cannot stall the CDP reader.

func (*Instance) AgentFrameCall

func (i *Instance) AgentFrameCall(ctx context.Context, conv, id, session, method string, params any) (json.RawMessage, error)

AgentFrameCall enforces the same owner, control and dialog checks as AgentCall, plus membership of the child session in that tab's current connection.

func (*Instance) AgentFrames

func (i *Instance) AgentFrames(ctx context.Context, conv, id string) ([]AgentFrame, error)

AgentFrames enables flattened iframe attachment only for a tab used by an agent.

func (*Instance) AgentNewTab

func (i *Instance) AgentNewTab(ctx context.Context, conv, url string) (Tab, error)

AgentNewTab creates and selects an agent-owned working tab in this conversation.

func (*Instance) AgentSetViewport

func (i *Instance) AgentSetViewport(ctx context.Context, conv, id string, v Viewport) error

AgentSetViewport rechecks ownership and control after acquiring the tab queue.

func (*Instance) AgentTabs

func (i *Instance) AgentTabs(conv string) []Tab

AgentTabs omits person-controlled page contents while preserving tab IDs and current URLs.

func (*Instance) BeginSecretInput

func (i *Instance) BeginSecretInput(conv, id, document string) (func(bool), error)

BeginSecretInput persists a provisional seal before the renderer can receive a value. The control gate keeps a rejected attempt from rolling back a concurrent person's handoff. Finish restores the prior state only when insertion is known not to have happened.

func (*Instance) Call

func (i *Instance) Call(ctx context.Context, id, method string, params any) (json.RawMessage, error)

Call sends a human tab command with a bounded lifetime, independently of other tabs. It enforces ErrDialogOpen but does not enforce agent ownership or control.

func (*Instance) Changes

func (i *Instance) Changes() (<-chan struct{}, func())

Changes coalesces notifications; the caller reads current snapshots after each wakeup.

func (*Instance) CheckPersonDocuments

func (i *Instance) CheckPersonDocuments(ctx context.Context, conv, id string) error

CheckPersonDocuments checks the live opener component before marking or executing agent JavaScript. Other tools and independent tabs do not use this guard.

func (*Instance) CloseTab

func (i *Instance) CloseTab(ctx context.Context, id string) error

CloseTab bypasses a renderer's operation queue, including a renderer blocked in a dialog.

func (*Instance) Current

func (i *Instance) Current(conv string) string

Current returns the agent working tab, falling back to the conversation's newest tab when no explicit selection survives.

func (*Instance) HandleDialog

func (i *Instance) HandleDialog(ctx context.Context, id string, accept bool, text string) error

HandleDialog answers the current JavaScript dialog without waiting for the renderer.

func (*Instance) InspectPersonInputs

func (i *Instance) InspectPersonInputs(ctx context.Context, conv string) error

InspectPersonInputs checks human input before a chat tool reads or acts. The caller holds the conversation gate; CDP inspection never holds the instance mutex.

func (*Instance) LockConversation

func (i *Instance) LockConversation(conv string) func()

LockConversation serializes a non-cancellable action with tools and handoffs. Release it exactly once; never acquire it from an action already holding it.

func (*Instance) LockToolConversation

func (i *Instance) LockToolConversation(ctx context.Context, conv string) (context.Context, func(), error)

LockToolConversation keeps seal checks and dispatch together. Returning control cancels this tool before waiting for its gate; queued tools yield to the person.

func (*Instance) MarkScripted

func (i *Instance) MarkScripted(conv, id string) error

MarkScripted records arbitrary agent execution before it is dispatched. Opener links permit script access in both directions, even after a tab navigates.

func (*Instance) NewTab

func (i *Instance) NewTab(ctx context.Context, conv, by, url string) (Tab, error)

NewTab creates a separate window without waiting for work on any existing tab.

func (*Instance) Profile

func (i *Instance) Profile() Profile

Profile returns this instance's identity.

func (*Instance) Redact

func (i *Instance) Redact(s string) string

Redact removes registered secret bytes from a tool response.

func (*Instance) RememberSecret

func (i *Instance) RememberSecret(value string)

RememberSecret registers a value before input so metadata and registry writes cannot echo it. Values stay in memory only, including after navigation; sibling tabs can receive page messages.

func (*Instance) ReserveSecrets

func (i *Instance) ReserveSecrets(values ...string) func(bool)

ReserveSecrets masks an in-flight input before any page event can echo it. Finish commits successful or uncertain input, or removes a reservation that never reached the page.

func (*Instance) Seal

func (i *Instance) Seal(conv, id, document string) error

Seal persists only a document marker, never the value. A runtime restart fails closed until the main frame reaches another document because node references were in memory. It also protects uncertain input if the person took control during the CDP call.

func (*Instance) SetAgentTab

func (i *Instance) SetAgentTab(conv, id string) error

SetAgentTab selects an owned working tab without changing pinned panel views.

func (*Instance) SetControl

func (i *Instance) SetControl(id, holder string) error

SetControl persists who may operate a tab; people may always use Call to take over.

func (*Instance) SetViewport

func (i *Instance) SetViewport(ctx context.Context, id string, v Viewport) error

SetViewport changes the content size without holding the profile registry lock.

func (*Instance) State

func (i *Instance) State() (string, string)

State reports connection or persistence failures without discarding healthy tabs.

func (*Instance) Tabs

func (i *Instance) Tabs(conv string) []Tab

Tabs returns creation order; an empty conversation returns all visible tabs for the person.

func (*Instance) Unseal

func (i *Instance) Unseal(conv, id string, generation uint64) error

Unseal removes only the seal whose browser proof was checked by the caller. Callers hold LockConversation across that proof, the reset and subsequent tool dispatch.

func (*Instance) Watch

func (i *Instance) Watch(ctx context.Context, id string) (*Viewer, error)

Watch activates the target and subscribes to its screencast.

type LoginAnswer

type LoginAnswer struct {
	Status string `json:"status"`
	URL    string `json:"url"`
}

LoginAnswer deliberately exposes only the outcome and the current URL.

type LoginAsk

type LoginAsk struct {
	ID      string `json:"id"`
	Conv    string `json:"conv"`
	Title   string `json:"title"`
	Why     string `json:"why"`
	URL     string `json:"url"`
	Tab     string `json:"tab"`
	At      int64  `json:"at"`
	Project string `json:"-"`
}

LoginAsk is page-only metadata. Agent results contain no page contents or titles.

type LoginRequests

type LoginRequests struct {
	// contains filtered or unexported fields
}

LoginRequests coalesces retries across tool calls and panel connections.

func NewLoginRequests

func NewLoginRequests() *LoginRequests

NewLoginRequests creates the page request queue independently of browser connections.

func (*LoginRequests) Pending

func (q *LoginRequests) Pending() []LoginAsk

Pending supplies global cards even when the requesting chat has no panel connection.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager reconnects independent browser profiles throughout the runtime lifetime.

func New

func New(cfg Config) *Manager

New creates a lazy manager; Instance starts the first connection.

func (*Manager) ClearProfile

func (m *Manager) ClearProfile(ctx context.Context, id string) error

ClearProfile stops Chrome and erases the managed profile, including cookies and the tab registry. An attached browser's data belongs to its operator.

func (*Manager) Close

func (m *Manager) Close()

Close disconnects clients but deliberately leaves hosts and browsers running.

func (*Manager) CloseConversation

func (m *Manager) CloseConversation(ctx context.Context, conv string) error

CloseConversation closes owned tabs in every profile, including dormant registries. It never launches an unused browser to perform cleanup.

func (*Manager) ConversationHasTabs

func (m *Manager) ConversationHasTabs(conv string) bool

ConversationHasTabs checks active snapshots and dormant registries without exposing tab metadata or starting Chrome.

func (*Manager) Enabled

func (m *Manager) Enabled() bool

Enabled reports whether browser access is configured.

func (*Manager) Instance

func (m *Manager) Instance(ctx context.Context, id string) (*Instance, error)

Instance waits for the named profile to become usable, starting its host when necessary.

func (*Manager) InstanceFor

func (m *Manager) InstanceFor(ctx context.Context, conv string) (*Instance, error)

InstanceFor resolves the conversation's profile without coupling callers to profile storage.

func (*Manager) ProfileRunning

func (m *Manager) ProfileRunning(id string) bool

ProfileRunning reports a live connection or a managed host holding its lock. It never launches Chrome or connects to a dormant external browser.

func (*Manager) Ready

func (m *Manager) Ready(ctx context.Context) Status

Ready starts lazy preparation and returns immediately. State is preparing, up (executable ready), error or down. Tools should call this before InstanceFor; preparing includes progress and a retry hint, never a blocked download.

func (*Manager) ReadyFor

func (m *Manager) ReadyFor(ctx context.Context, conv string) Status

ReadyFor resolves outside the manager lock: profile callbacks may acquire the access/store locks and must never run while holding the manager mutex.

func (*Manager) RemoveProfile

func (m *Manager) RemoveProfile(ctx context.Context, id string, forget func() error) error

RemoveProfile stops a profile and removes local data and metadata while holding its lifecycle lock, preventing a concurrent start between erasure and revocation. Attached Chrome is only disconnected; its external user-data directory is never touched.

func (*Manager) Retry

func (m *Manager) Retry(ctx context.Context) Status

Retry immediately rechecks a failed preparation after an operator repairs the machine. An in-flight preparation is shared rather than duplicated.

func (*Manager) RetryFor

func (m *Manager) RetryFor(ctx context.Context, conv string) Status

RetryFor rechecks managed Chrome or immediately accepts an attached profile.

func (*Manager) ServeHTTP

func (m *Manager) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves an authenticated panel; the caller checks session and conversation access.

func (*Manager) StopProfile

func (m *Manager) StopProfile(ctx context.Context, id string) error

StopProfile stops a managed browser and preserves its tab registry. Attached browsers are disconnected only. The next Instance access starts/reconnects it.

func (*Manager) Sweep

func (m *Manager) Sweep(ctx context.Context)

Sweep stops the hosts this runtime will not use, at its start: every one with RUNTIME_BROWSER=off, otherwise those of another build (an update). They start again, of this build, on the next use. A profile in use is left alone.

type Notice

type Notice struct {
	T       string `json:"t"`
	Level   string `json:"level"`
	Message string `json:"message"`
}

Notice reports a recoverable failure without changing browser availability.

type PanelTab

type PanelTab struct {
	Scripted bool      `json:"scripted"`
	Login    *LoginAsk `json:"login,omitempty"`
	Control  string    `json:"control"`
	AgentAt  int64     `json:"agentAt"`
	Dialog   *Dialog   `json:"dialog,omitempty"`
	ID       string    `json:"id"`
	Title    string    `json:"title"`
	URL      string    `json:"url"`
	Owner    string    `json:"owner"`
	By       string    `json:"by"`
	Viewport Viewport  `json:"viewport"`
	Crashed  bool      `json:"crashed"`
}

PanelTab is the public metadata for one visible page.

type PreparingError

type PreparingError struct{ Status Status }

PreparingError asks an agent to retry while installation continues in the manager's lifetime.

func (*PreparingError) Error

func (e *PreparingError) Error() string

Error gives agents a concise retry instruction.

type Profile

type Profile struct {
	ID         string        `json:"id"`
	Name       string        `json:"name"`
	Color      string        `json:"color"`
	Kind       string        `json:"kind"`
	CDP        string        `json:"cdp,omitempty"`
	CreatedAt  int64         `json:"createdAt"`
	LastUsedAt int64         `json:"lastUsedAt"`
	UsedBy     []secrets.Use `json:"usedBy"`
}

Profile identifies the browser process or external connection shared by conversations.

type ProfileAccess

type ProfileAccess struct {
	Store    *ProfileStore
	Manager  *Manager
	Asks     *ProfileAsks
	Logins   *LoginRequests
	Identity func(string) (ConversationIdentity, bool)
	Wait     time.Duration
	// contains filtered or unexported fields
}

ProfileAccess coordinates permissions with live tabs. Future login and sealed-tab policy can use the same trusted conversation resolver without granting access by agent-supplied IDs.

func NewProfileAccess

func NewProfileAccess(store *ProfileStore, identity func(string) (ConversationIdentity, bool)) *ProfileAccess

NewProfileAccess creates the shared authorization service for page, MCP and CLI callers.

func (*ProfileAccess) Answer

func (a *ProfileAccess) Answer(ctx context.Context, askID, id, scope, name, color string) error

Answer grants access only from the authenticated page, optionally creating a new profile.

func (*ProfileAccess) AnswerLogin

func (a *ProfileAccess) AnswerLogin(ctx context.Context, id, action string) error

AnswerLogin is called only by authenticated page routes. Return-to-agent also completes through SetControl.

func (*ProfileAccess) ConversationChanged

func (a *ProfileAccess) ConversationChanged(conv, project string, removed bool) error

ConversationChanged handles record events without calling back into the conversation actor.

func (*ProfileAccess) Delete

func (a *ProfileAccess) Delete(ctx context.Context, id string) error

Delete stops a managed profile before erasing data and every local permission referencing it.

func (*ProfileAccess) List

List contains only the current conversation's permitted profiles and active selection.

func (*ProfileAccess) ProfileOf

func (a *ProfileAccess) ProfileOf(conv string) string

ProfileOf implements Config.ProfileOf. A resolver error never falls back to common.

func (*ProfileAccess) ProjectAffectedChats

func (a *ProfileAccess) ProjectAffectedChats(project string, access ProjectAccess) (int, error)

ProjectAffectedChats counts chats whose existing tabs would close on applying access. It shares mutation validation but never resolves profiles, starts Chrome or writes metadata.

func (*ProfileAccess) ReconcileProjects

func (a *ProfileAccess) ReconcileProjects(projects map[string]bool) error

ReconcileProjects drops bindings absent from an authoritative project snapshot. This also supports runtimes that remove projects without publishing a dedicated wire event.

func (*ProfileAccess) Request

func (a *ProfileAccess) Request(ctx context.Context, conv, why string) (ProfileAnswer, error)

Request waits on one card without holding the access mutex while the person decides.

func (*ProfileAccess) RequestLogin

func (a *ProfileAccess) RequestLogin(ctx context.Context, conv, target, why string) (LoginAnswer, error)

RequestLogin opens a person-controlled tab before navigating and waits without holding access locks.

func (*ProfileAccess) SetProject

func (a *ProfileAccess) SetProject(ctx context.Context, project string, access ProjectAccess) error

SetProject closes affected tabs before applying the person's changed project permissions.

func (*ProfileAccess) TakeNotice

func (a *ProfileAccess) TakeNotice(conv string) string

TakeNotice reports page-initiated profile changes to the agent's next tool call.

func (*ProfileAccess) UseID

func (a *ProfileAccess) UseID(ctx context.Context, conv, id string) error

UseID is the page's equivalent of UseName; an ID is still checked against the chat's permissions.

func (*ProfileAccess) UseName

func (a *ProfileAccess) UseName(ctx context.Context, conv, name string) (ProfileSummary, error)

UseName resolves exclusively against the permitted set, so errors cannot reveal other profile names.

type ProfileAnswer

type ProfileAnswer struct {
	Status  string `json:"status"`
	Name    string `json:"name,omitempty"`
	Message string `json:"message,omitempty"`
}

ProfileAnswer is the complete agent-visible result of a request.

type ProfileAsk

type ProfileAsk struct {
	ID      string `json:"id"`
	Conv    string `json:"conv"`
	Title   string `json:"title"`
	Why     string `json:"why"`
	At      int64  `json:"at"`
	Project string `json:"-"`
}

ProfileAsk is shown only to the person; profile names are supplied separately by page routes.

type ProfileAsks

type ProfileAsks struct {
	// contains filtered or unexported fields
}

ProfileAsks coalesces retries per conversation and bounds pending cards and waits.

func NewProfileAsks

func NewProfileAsks() *ProfileAsks

NewProfileAsks creates a request queue independent of browser panel connections.

func (*ProfileAsks) Find

func (a *ProfileAsks) Find(id string) (ProfileAsk, bool)

Find returns a pending request for a page decision.

func (*ProfileAsks) Forget

func (a *ProfileAsks) Forget(conv string)

Forget declines pending requests when a conversation moves or disappears.

func (*ProfileAsks) Open

func (a *ProfileAsks) Open(conv, project, title, why string) (ProfileAsk, error)

Open keeps a repeated request waiting on the same card and remembers a recent answer.

func (*ProfileAsks) Pending

func (a *ProfileAsks) Pending() []ProfileAsk

Pending lists open cards for the person's page in creation order.

func (*ProfileAsks) Settle

func (a *ProfileAsks) Settle(id string, answer ProfileAnswer) bool

Settle wakes every retry after the permission change has been persisted successfully.

func (*ProfileAsks) Wait

Wait returns within d; a timeout preserves the pending card for the next call.

type ProfileStore

type ProfileStore struct {
	// contains filtered or unexported fields
}

ProfileStore keeps machine-local permissions separate from portable conversation records. Mutations publish only after an owner-only atomic write succeeds.

func OpenProfiles

func OpenProfiles(dataDir, cdp string) *ProfileStore

OpenProfiles reads existing metadata without starting Chrome or changing the legacy common directory. A corrupt or inaccessible registry fails closed until the runtime is restarted after repair.

func (*ProfileStore) Allowed

func (s *ProfileStore) Allowed(conv, project string) []ProfileSummary

Allowed returns only profiles available to the conversation's current project and direct grants.

func (*ProfileStore) Create

func (s *ProfileStore) Create(name, color string) (Profile, error)

Create adds a managed profile; its directory is created lazily by the browser host.

func (*ProfileStore) Err

func (s *ProfileStore) Err() error

Err reports an unavailable registry without revealing any profile names.

func (*ProfileStore) ForgetConversation

func (s *ProfileStore) ForgetConversation(conv string) error

ForgetConversation drops local choices and direct grants on deletion or project moves.

func (*ProfileStore) Grant

func (s *ProfileStore) Grant(conv, project, id, scope string) error

Grant is called only after the person answers an access request.

func (*ProfileStore) Import

func (s *ProfileStore) Import(ctx context.Context, source, name, color string) (string, error)

Import publishes a copied Chrome directory only after the copy succeeds. Until publication the random ID cannot be selected or started by another page.

func (*ProfileStore) Lookup

func (s *ProfileStore) Lookup(id string) (Profile, bool)

Lookup returns a detached copy for manager configuration and the person's settings page.

func (*ProfileStore) NoSandbox

func (s *ProfileStore) NoSandbox() bool

NoSandbox reports the explicit page preference used by managed Chrome startup.

func (*ProfileStore) ProjectOf

func (s *ProfileStore) ProjectOf(conv string) (string, bool)

ProjectOf returns the last observed project, so event delivery can detect moves without actor calls.

func (*ProfileStore) Remove

func (s *ProfileStore) Remove(id string) error

Remove drops every reference after the manager has stopped and cleared the profile.

func (*ProfileStore) RemoveProject

func (s *ProfileStore) RemoveProject(project string) error

RemoveProject drops bindings while leaving profile data available for manual removal.

func (*ProfileStore) Resolve

func (s *ProfileStore) Resolve(conv, project, projectName, title string) (Profile, error)

Resolve chooses a permitted chat selection, then the project's lazily created default. Project identity comes from the runtime record, never an agent argument.

func (*ProfileStore) Select

func (s *ProfileStore) Select(conv, project, id string) error

Select accepts only a permitted opaque ID. Names are resolved against Allowed, not the global registry.

func (*ProfileStore) SetNoSandbox

func (s *ProfileStore) SetNoSandbox(value bool) error

SetNoSandbox persists the person's choice; there is deliberately no agent tool for it.

func (*ProfileStore) SetProject

func (s *ProfileStore) SetProject(project string, a ProjectAccess) error

SetProject changes the default and extra grants. An empty default means a new own profile on next use.

func (*ProfileStore) SizeBytes

func (s *ProfileStore) SizeBytes(id string) *int64

SizeBytes returns cached managed Chrome file sizes, or nil while unknown. Only background workers traverse disk; repeated failures wait before retrying.

func (*ProfileStore) Snapshot

func (s *ProfileStore) Snapshot() ([]Profile, map[string]ProjectAccess)

Snapshot returns detached metadata for the authenticated settings page, never for agent tools.

func (*ProfileStore) Update

func (s *ProfileStore) Update(id, name, color string) error

Update changes person-visible metadata without changing the profile's disk identity.

type ProfileSummary

type ProfileSummary struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Color string `json:"color"`
	Kind  string `json:"kind"`
}

ProfileSummary contains only information a conversation may learn about an allowed profile.

type ProjectAccess

type ProjectAccess struct {
	Default string   `json:"default"`
	Granted []string `json:"granted"`
}

ProjectAccess names a project's default and additional permitted browser profiles.

type Status

type Status struct {
	Command  string  `json:"command,omitempty"`
	Progress int     `json:"progress"`
	Hint     string  `json:"hint,omitempty"`
	Mode     string  `json:"mode,omitempty"`
	Sandbox  string  `json:"sandbox,omitempty"`
	T        string  `json:"t"`
	State    string  `json:"state"`
	Error    string  `json:"error,omitempty"`
	Profile  Profile `json:"profile"`
}

Status reports browser availability, never individual command failures.

type Tab

type Tab struct {
	Scripted        bool     `json:"scripted,omitempty"`
	Opener          string   `json:"opener,omitempty"`
	Sealed          bool     `json:"sealed,omitempty"`
	SecretTouched   bool     `json:"secretTouched,omitempty"`
	SecretDocument  string   `json:"secretDocument,omitempty"`
	SealGeneration  uint64   `json:"sealGeneration,omitempty"`
	PersonInput     bool     `json:"personInput,omitempty"`
	PersonDocument  string   `json:"personDocument,omitempty"`
	SecretUntracked bool     `json:"secretUntracked,omitempty"`
	Control         string   `json:"control"`
	AgentAt         int64    `json:"agentAt"`
	Dialog          *Dialog  `json:"dialog,omitempty"`
	ID              string   `json:"id"`
	Title           string   `json:"title"`
	URL             string   `json:"url"`
	Conversation    string   `json:"conversation,omitempty"`
	By              string   `json:"by"`
	Viewport        Viewport `json:"viewport"`
	Crashed         bool     `json:"crashed"`
	Order           uint64   `json:"order"`
	WindowID        int      `json:"windowId"`
}

Tab records creation order independently of Chrome's target IDs. All fields except the live Dialog are persisted; callers receive snapshots they may safely retain.

type TabsMessage

type TabsMessage struct {
	AgentTab  string     `json:"agentTab"`
	Following bool       `json:"following"`
	T         string     `json:"t"`
	Tabs      []PanelTab `json:"tabs"`
	Current   string     `json:"current"`
	Gen       uint32     `json:"gen"`
}

TabsMessage pairs a selection with the generation used by subsequent frames.

type Viewer

type Viewer struct {
	// contains filtered or unexported fields
}

Viewer holds only the most recent frame for one subscriber.

func (*Viewer) Close

func (v *Viewer) Close()

Close removes the viewer immediately and schedules stopping an unused screencast.

func (*Viewer) Frames

func (v *Viewer) Frames() <-chan Frame

Frames returns the latest-frame mailbox, which remains open until the viewer is discarded.

type Viewport

type Viewport struct {
	Mode string  `json:"mode"`
	W    int     `json:"w"`
	H    int     `json:"h"`
	DPR  float64 `json:"dpr"`
}

Viewport describes the requested content area in CSS pixels.

Directories

Path Synopsis
Package host owns Chrome independently of the runtime's lifetime.
Package host owns Chrome independently of the runtime's lifetime.
Package provision finds and installs a verified browser without weakening its sandbox.
Package provision finds and installs a verified browser without weakening its sandbox.
Package tools supplies the conversation-scoped browser tools shared by MCP and the CLI.
Package tools supplies the conversation-scoped browser tools shared by MCP and the CLI.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL