Documentation
¶
Overview ¶
Package agentbrowser owns persistent browser profiles and conversation tabs.
Index ¶
- Constants
- Variables
- func AllowedURL(raw string) error
- func FindChrome() (string, error)
- func ImportChrome(ctx context.Context, source, destination string) (warning string, err error)
- func NormalizeURL(u string) string
- func Shown(url string) bool
- type AgentEvent
- type AgentFrame
- type Call
- type Config
- type ConversationIdentity
- type Dialog
- type Frame
- type Input
- type Instance
- func (i *Instance) AgentCall(ctx context.Context, conv, id, method string, params any) (json.RawMessage, error)
- func (i *Instance) AgentCheck(conv, id, method string) error
- func (i *Instance) AgentCloseTab(ctx context.Context, conv, id string) error
- func (i *Instance) AgentEvents(ctx context.Context, conv, id string) (<-chan AgentEvent, func(), error)
- func (i *Instance) AgentFrameCall(ctx context.Context, conv, id, session, method string, params any) (json.RawMessage, error)
- func (i *Instance) AgentFrames(ctx context.Context, conv, id string) ([]AgentFrame, error)
- func (i *Instance) AgentNewTab(ctx context.Context, conv, url string) (Tab, error)
- func (i *Instance) AgentSetViewport(ctx context.Context, conv, id string, v Viewport) error
- func (i *Instance) AgentTabs(conv string) []Tab
- func (i *Instance) BeginSecretInput(conv, id, document string) (func(bool), error)
- func (i *Instance) Call(ctx context.Context, id, method string, params any) (json.RawMessage, error)
- func (i *Instance) Changes() (<-chan struct{}, func())
- func (i *Instance) CheckPersonDocuments(ctx context.Context, conv, id string) error
- func (i *Instance) CloseTab(ctx context.Context, id string) error
- func (i *Instance) Current(conv string) string
- func (i *Instance) HandleDialog(ctx context.Context, id string, accept bool, text string) error
- func (i *Instance) InspectPersonInputs(ctx context.Context, conv string) error
- func (i *Instance) LockConversation(conv string) func()
- func (i *Instance) LockToolConversation(ctx context.Context, conv string) (context.Context, func(), error)
- func (i *Instance) MarkScripted(conv, id string) error
- func (i *Instance) NewTab(ctx context.Context, conv, by, url string) (Tab, error)
- func (i *Instance) Profile() Profile
- func (i *Instance) Redact(s string) string
- func (i *Instance) RememberSecret(value string)
- func (i *Instance) ReserveSecrets(values ...string) func(bool)
- func (i *Instance) Seal(conv, id, document string) error
- func (i *Instance) SetAgentTab(conv, id string) error
- func (i *Instance) SetControl(id, holder string) error
- func (i *Instance) SetViewport(ctx context.Context, id string, v Viewport) error
- func (i *Instance) State() (string, string)
- func (i *Instance) Tabs(conv string) []Tab
- func (i *Instance) Unseal(conv, id string, generation uint64) error
- func (i *Instance) Watch(ctx context.Context, id string) (*Viewer, error)
- type LoginAnswer
- type LoginAsk
- type LoginRequests
- type Manager
- func (m *Manager) ClearProfile(ctx context.Context, id string) error
- func (m *Manager) Close()
- func (m *Manager) CloseConversation(ctx context.Context, conv string) error
- func (m *Manager) ConversationHasTabs(conv string) bool
- func (m *Manager) Enabled() bool
- func (m *Manager) Instance(ctx context.Context, id string) (*Instance, error)
- func (m *Manager) InstanceFor(ctx context.Context, conv string) (*Instance, error)
- func (m *Manager) ProfileRunning(id string) bool
- func (m *Manager) Ready(ctx context.Context) Status
- func (m *Manager) ReadyFor(ctx context.Context, conv string) Status
- func (m *Manager) RemoveProfile(ctx context.Context, id string, forget func() error) error
- func (m *Manager) Retry(ctx context.Context) Status
- func (m *Manager) RetryFor(ctx context.Context, conv string) Status
- func (m *Manager) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (m *Manager) StopProfile(ctx context.Context, id string) error
- func (m *Manager) Sweep(ctx context.Context)
- type Notice
- type PanelTab
- type PreparingError
- type Profile
- type ProfileAccess
- func (a *ProfileAccess) Answer(ctx context.Context, askID, id, scope, name, color string) error
- func (a *ProfileAccess) AnswerLogin(ctx context.Context, id, action string) error
- func (a *ProfileAccess) ConversationChanged(conv, project string, removed bool) error
- func (a *ProfileAccess) Delete(ctx context.Context, id string) error
- func (a *ProfileAccess) List(conv string) ([]ProfileSummary, ProfileSummary, error)
- func (a *ProfileAccess) ProfileOf(conv string) string
- func (a *ProfileAccess) ProjectAffectedChats(project string, access ProjectAccess) (int, error)
- func (a *ProfileAccess) ReconcileProjects(projects map[string]bool) error
- func (a *ProfileAccess) Request(ctx context.Context, conv, why string) (ProfileAnswer, error)
- func (a *ProfileAccess) RequestLogin(ctx context.Context, conv, target, why string) (LoginAnswer, error)
- func (a *ProfileAccess) SetProject(ctx context.Context, project string, access ProjectAccess) error
- func (a *ProfileAccess) TakeNotice(conv string) string
- func (a *ProfileAccess) UseID(ctx context.Context, conv, id string) error
- func (a *ProfileAccess) UseName(ctx context.Context, conv, name string) (ProfileSummary, error)
- type ProfileAnswer
- type ProfileAsk
- type ProfileAsks
- func (a *ProfileAsks) Find(id string) (ProfileAsk, bool)
- func (a *ProfileAsks) Forget(conv string)
- func (a *ProfileAsks) Open(conv, project, title, why string) (ProfileAsk, error)
- func (a *ProfileAsks) Pending() []ProfileAsk
- func (a *ProfileAsks) Settle(id string, answer ProfileAnswer) bool
- func (a *ProfileAsks) Wait(ctx context.Context, id string, d time.Duration) ProfileAnswer
- type ProfileStore
- func (s *ProfileStore) Allowed(conv, project string) []ProfileSummary
- func (s *ProfileStore) Create(name, color string) (Profile, error)
- func (s *ProfileStore) Err() error
- func (s *ProfileStore) ForgetConversation(conv string) error
- func (s *ProfileStore) Grant(conv, project, id, scope string) error
- func (s *ProfileStore) Import(ctx context.Context, source, name, color string) (string, error)
- func (s *ProfileStore) Lookup(id string) (Profile, bool)
- func (s *ProfileStore) NoSandbox() bool
- func (s *ProfileStore) ProjectOf(conv string) (string, bool)
- func (s *ProfileStore) Remove(id string) error
- func (s *ProfileStore) RemoveProject(project string) error
- func (s *ProfileStore) Resolve(conv, project, projectName, title string) (Profile, error)
- func (s *ProfileStore) Select(conv, project, id string) error
- func (s *ProfileStore) SetNoSandbox(value bool) error
- func (s *ProfileStore) SetProject(project string, a ProjectAccess) error
- func (s *ProfileStore) SizeBytes(id string) *int64
- func (s *ProfileStore) Snapshot() ([]Profile, map[string]ProjectAccess)
- func (s *ProfileStore) Update(id, name, color string) error
- type ProfileSummary
- type ProjectAccess
- type Status
- type Tab
- type TabsMessage
- type Viewer
- type Viewport
Constants ¶
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).
const DefaultProfile = "common"
DefaultProfile is used for conversations without an explicit profile binding.
Variables ¶
var ErrControlInterrupted = errors.New("Interrupted: the person changed browser control; retry")
ErrControlInterrupted asks an agent to retry after a person changes browser control.
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.
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.
var ErrNotOwner = errors.New("browser tab belongs to another conversation")
ErrNotOwner means the requested tab does not belong to the calling conversation.
var ErrOff = errors.New("agent browser is disabled")
ErrOff reports that the browser was disabled by configuration.
var ErrPersonControl = errors.New("browser tab is controlled by the person")
ErrPersonControl means the person has reserved the tab's controls.
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.
ErrProfileUnavailable deliberately makes missing and unauthorized names indistinguishable.
Functions ¶
func AllowedURL ¶
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 ¶
FindChrome discovers an installed browser without downloading; Manager.Ready also provisions missing Chrome.
func ImportChrome ¶
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 ¶
NormalizeURL supplies HTTPS for addresses without an explicit scheme.
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 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 ¶
ConfigFromEnv reads browser settings without starting any processes.
type ConversationIdentity ¶
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 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.
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 ¶
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 ¶
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 ¶
AgentFrames enables flattened iframe attachment only for a tab used by an agent.
func (*Instance) AgentNewTab ¶
AgentNewTab creates and selects an agent-owned working tab in this conversation.
func (*Instance) AgentSetViewport ¶
AgentSetViewport rechecks ownership and control after acquiring the tab queue.
func (*Instance) AgentTabs ¶
AgentTabs omits person-controlled page contents while preserving tab IDs and current URLs.
func (*Instance) BeginSecretInput ¶
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 ¶
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 ¶
CloseTab bypasses a renderer's operation queue, including a renderer blocked in a dialog.
func (*Instance) Current ¶
Current returns the agent working tab, falling back to the conversation's newest tab when no explicit selection survives.
func (*Instance) HandleDialog ¶
HandleDialog answers the current JavaScript dialog without waiting for the renderer.
func (*Instance) InspectPersonInputs ¶
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 ¶
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 ¶
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 ¶
NewTab creates a separate window without waiting for work on any existing tab.
func (*Instance) RememberSecret ¶
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 ¶
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 ¶
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 ¶
SetAgentTab selects an owned working tab without changing pinned panel views.
func (*Instance) SetControl ¶
SetControl persists who may operate a tab; people may always use Call to take over.
func (*Instance) SetViewport ¶
SetViewport changes the content size without holding the profile registry lock.
func (*Instance) State ¶
State reports connection or persistence failures without discarding healthy tabs.
func (*Instance) Tabs ¶
Tabs returns creation order; an empty conversation returns all visible tabs for the person.
type LoginAnswer ¶
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 (*Manager) ClearProfile ¶
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 ¶
CloseConversation closes owned tabs in every profile, including dormant registries. It never launches an unused browser to perform cleanup.
func (*Manager) ConversationHasTabs ¶
ConversationHasTabs checks active snapshots and dormant registries without exposing tab metadata or starting Chrome.
func (*Manager) Instance ¶
Instance waits for the named profile to become usable, starting its host when necessary.
func (*Manager) InstanceFor ¶
InstanceFor resolves the conversation's profile without coupling callers to profile storage.
func (*Manager) ProfileRunning ¶
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 ¶
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 ¶
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 ¶
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 ¶
Retry immediately rechecks a failed preparation after an operator repairs the machine. An in-flight preparation is shared rather than duplicated.
func (*Manager) RetryFor ¶
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 ¶
StopProfile stops a managed browser and preserves its tab registry. Attached browsers are disconnected only. The next Instance access starts/reconnects it.
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 ¶
func (a *ProfileAccess) List(conv string) ([]ProfileSummary, ProfileSummary, error)
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 ¶
func (a *ProfileAsks) Wait(ctx context.Context, id string, d time.Duration) ProfileAnswer
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 ¶
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 ¶
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.
Source Files
¶
- agent.go
- agent_frames.go
- cast.go
- clipboard.go
- conversation_gate.go
- diagnostic.go
- events.go
- handoff.go
- hosts.go
- import.go
- input.go
- instance.go
- lifecycle.go
- lifecycle_conversation.go
- lifecycle_restore.go
- login.go
- manager.go
- panel_dialog.go
- person_input.go
- profile_access.go
- profile_asks.go
- profile_sizes.go
- profiles.go
- profiles_import.go
- protocol.go
- readiness.go
- reconcile.go
- registry.go
- scripted.go
- secrets.go
- select.go
- viewport.go
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. |