Documentation
¶
Overview ¶
Package browserhost runs one headless Chromium behind the same native control API the visible pane serves: /v1/info, /v1/actions, /v1/screenshot and /v1/quit on an owner-only Unix socket.
It exists for hosts such as golder that want the browser without a terminal pane. Action semantics are not reimplemented: page actions run through internal/action and host-managed actions through internal/host, the same code paths the visible browsepane uses. The pane remains the primary integration.
Index ¶
- Constants
- func RuntimePolicyDigest(opts Options) string
- func ServeShared(ctx context.Context, opts SharedOptions) error
- func SharedReady(ctx context.Context, runtimeDir string) bool
- func SharedSocket(dir string) string
- func ViewID(conversation, instance string) string
- func ViewSocket(dir, id string) string
- type ContinueRequest
- type Host
- func (h *Host) Close() error
- func (h *Host) ContinueChecked(ctx context.Context, req ContinueRequest) error
- func (h *Host) OperatorAction(ctx context.Context, raw json.RawMessage) (json.RawMessage, error)
- func (h *Host) SendOperatorInput(ctx context.Context, event OperatorInput) error
- func (h *Host) SendOperatorInputJSON(ctx context.Context, raw []byte) error
- func (h *Host) Socket() string
- func (h *Host) Wait() error
- type Hub
- type InteractionState
- type OperatorInput
- type Options
- type RemoteView
- func (v *RemoteView) Attest(ctx context.Context) (ViewAttestation, error)
- func (v *RemoteView) Close() error
- func (v *RemoteView) ContinuationOutcome(ctx context.Context, req ContinueRequest) (string, error)
- func (v *RemoteView) ContinueChecked(ctx context.Context, req ContinueRequest) error
- func (v *RemoteView) KeepAlive(ctx context.Context) func()
- func (v *RemoteView) OperatorAction(ctx context.Context, raw json.RawMessage) (json.RawMessage, error)
- func (v *RemoteView) SendOperatorInput(ctx context.Context, in OperatorInput) error
- type Sessions
- type SharedOptions
- type ViewAttestation
- type ViewOptions
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func RuntimePolicyDigest ¶ added in v0.2.12
RuntimePolicyDigest identifies the broker's immutable execution configuration, not any embedding application's permission decision or outer OS sandbox.
func ServeShared ¶ added in v0.2.11
func ServeShared(ctx context.Context, opts SharedOptions) error
ServeShared runs a single profile owner. Its advisory runtime lock prevents concurrent starts; normal shutdown flushes the profile after closing views.
func SharedSocket ¶ added in v0.2.11
SharedSocket returns the hub endpoint. Unix keeps the historical short path.
func ViewID ¶ added in v0.2.11
ViewID binds a conversation and an optional independently opened instance.
func ViewSocket ¶ added in v0.2.11
ViewSocket returns one conversation's control endpoint.
Types ¶
type ContinueRequest ¶ added in v0.2.12
type ContinueRequest = host.ContinueRequest
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host is one running headless browser.
func Start ¶
Start launches Chromium, opens the first page and starts serving the control API. It returns once the socket is listening; page load failures leave Chromium's error page and the socket alive, exactly like the pane.
func (*Host) ContinueChecked ¶ added in v0.2.12
func (h *Host) ContinueChecked(ctx context.Context, req ContinueRequest) error
func (*Host) OperatorAction ¶ added in v0.2.11
func (h *Host) OperatorAction(ctx context.Context, raw json.RawMessage) (json.RawMessage, error)
OperatorAction lets a trusted surface use browser chrome while automation is paused. This closed set has no scripts, file access or arbitrary page actions. It is intentionally absent from /v1/actions and requires a private capability when called through the shared host's separate management socket.
func (*Host) SendOperatorInput ¶ added in v0.2.9
func (h *Host) SendOperatorInput(ctx context.Context, event OperatorInput) error
SendOperatorInput delivers an input from a trusted, locally authenticated operator surface. This is deliberately an in-process API, not a socket action. Embedders must authenticate remote surfaces before calling it; merely possessing the ordinary browser control socket is not sufficient authority. It leaves an automation pause in place and never retries a rejected action.
func (*Host) SendOperatorInputJSON ¶ added in v0.2.9
SendOperatorInputJSON is the version-independent in-process embedding seam for SendOperatorInput. It accepts only the closed OperatorInput schema and is not registered on the control socket.
type Hub ¶ added in v0.2.11
type Hub struct {
// contains filtered or unexported fields
}
Hub owns one Chromium and one profile. Each view opened on it has its own browser identity, socket, tab collection, selection and operator surface. Closing a View never closes another View or the Hub's profile.
func StartHub ¶ added in v0.2.11
StartHub starts a private anchor in one Chromium using opts' profile and launch policy. The caller's context owns the hub after startup. No view or browser control socket is exposed until OpenView succeeds.
type InteractionState ¶ added in v0.2.12
type InteractionState = host.InteractionState
type OperatorInput ¶ added in v0.2.9
type OperatorInput struct {
BrowserID string `json:"browserId"`
TabID string `json:"tabId"`
TargetID string `json:"targetId"`
Kind string `json:"kind"` // pointer-down, pointer-hover, pointer-move, pointer-up, pointer-cancel, scroll, text, key
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
DeltaY float64 `json:"deltaY,omitempty"`
Text string `json:"text,omitempty"`
Key string `json:"key,omitempty"`
}
OperatorInput is a bounded, person-originated input event for one exact tab. It intentionally does not carry a script, selector, filesystem path, or URL.
type Options ¶
type Options struct {
// URL is the first page to open. Empty opens https://example.com, the same
// default the pane and the kitty-browse binary use.
URL string
// Socket is the owner-only Unix socket that serves the control API. Empty
// runs the browser without one, which is useful only for a smoke test.
Socket string
// Chrome is the Chromium executable path. Empty searches PATH.
Chrome string
// ProxyServer is an explicit reviewed proxy; ambient proxy variables are not
// used. Credentials in the proxy URL are rejected by the browser launcher.
ProxyServer string
// ProfileDir is a dedicated persistent profile. Empty uses kitty-browse's
// own configuration directory.
ProfileDir string
// LoginProfile is an optional host-assigned identity for saved-login access
// checks. It contains no cookie values or filesystem path.
LoginProfile string
// DownloadDir is where downloads are written. Empty uses the profile's
// Downloads directory, or a temporary directory in private mode.
DownloadDir string
// Private uses a temporary profile and writes no state.
Private bool
// Stealth removes Chromium's headless UA token and automation markers. The
// pane defaults this on, so DefaultOptions sets it; the zero value keeps
// Chromium's native headless identity.
Stealth bool
// UserAgent overrides the per-target User-Agent. Empty derives it from the
// running Chromium build, exactly like the pane.
UserAgent string
// ViewportWidth and ViewportHeight are the emulated page size. Zero uses
// 1280x800. The pane always emulates the pane's own size; a headless host
// needs one explicitly, because Chromium's default window is not a page the
// control API can screenshot predictably.
ViewportWidth int
ViewportHeight int
// LoadTimeout bounds one page load. Zero uses 30s.
LoadTimeout time.Duration
// BrowserOutput receives Chromium's diagnostic output. Private mode ignores
// it, like the pane's debug log.
BrowserOutput io.Writer
// Controlled embedders may require the allocator to retain Chromium's
// native sandbox even when running as root (otherwise startup must fail).
RequireSandbox bool
}
Options configures one headless browser.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns the pane's defaults, so a headless host started with them behaves like a visible one.
type RemoteView ¶ added in v0.2.11
type RemoteView struct {
Socket, BrowserID string
// contains filtered or unexported fields
}
RemoteView is a trusted operator connection. Do not expose its credential to tools, logs or transcripts. The ordinary Socket serves automation only.
func OpenShared ¶ added in v0.2.11
func OpenShared(ctx context.Context, opts SharedOptions, id, url string) (*RemoteView, error)
OpenShared authenticates a trusted frontend and opens/reconnects only its conversation's view. The returned operator capability must remain private.
func ReconnectShared ¶ added in v0.2.11
func ReconnectShared(ctx context.Context, opts SharedOptions, id string) (*RemoteView, error)
ReconnectShared never launches, navigates, changes proxy or creates a view.
func (*RemoteView) Attest ¶ added in v0.2.12
func (v *RemoteView) Attest(ctx context.Context) (ViewAttestation, error)
func (*RemoteView) Close ¶ added in v0.2.11
func (v *RemoteView) Close() error
Close releases only this conversation's view, never the profile owner or another view. The broker exits after the last view and an idle grace period.
func (*RemoteView) ContinuationOutcome ¶ added in v0.2.12
func (v *RemoteView) ContinuationOutcome(ctx context.Context, req ContinueRequest) (string, error)
func (*RemoteView) ContinueChecked ¶ added in v0.2.12
func (v *RemoteView) ContinueChecked(ctx context.Context, req ContinueRequest) error
func (*RemoteView) KeepAlive ¶ added in v0.2.11
func (v *RemoteView) KeepAlive(ctx context.Context) func()
KeepAlive maintains this view while a frontend owns it. A crashed frontend cannot leak an immortal Chromium view: the owner expires its lease after two minutes. It never retries a failed input or opens a replacement view.
func (*RemoteView) OperatorAction ¶ added in v0.2.11
func (v *RemoteView) OperatorAction(ctx context.Context, raw json.RawMessage) (json.RawMessage, error)
func (*RemoteView) SendOperatorInput ¶ added in v0.2.11
func (v *RemoteView) SendOperatorInput(ctx context.Context, in OperatorInput) error
type Sessions ¶ added in v0.2.11
type Sessions struct {
// contains filtered or unexported fields
}
Sessions assigns at most one live view to each trusted conversation ID. It is an in-process registry: a cross-process broker must authenticate callers and derive IDs and socket paths before invoking it.
func NewSessions ¶ added in v0.2.11
NewSessions creates the conversation registry for one shared profile.
type SharedOptions ¶ added in v0.2.11
type SharedOptions struct {
SharedOptions is supplied only by the trusted embedder, never a page or model. StateDir holds an owner-only credential outside the agent's file boundary; RuntimeDir holds short Unix sockets. One server owns a dedicated profile.
type ViewAttestation ¶ added in v0.2.12
type ViewAttestation struct {
ViewID string `json:"viewId"`
BrowserID string `json:"browserId"`
InstanceEpoch string `json:"instanceEpoch"`
Socket string `json:"socket"`
LoginProfile string `json:"loginProfile"`
ProxyMode string `json:"proxyMode"`
ChromiumSandbox bool `json:"chromiumSandbox"`
Challenge string `json:"challenge"`
RuntimeEnvelope string `json:"runtimeEnvelope"`
RuntimePolicyDigest string `json:"runtimePolicyDigest"`
}
ViewAttestation is returned over the authenticated management connection, never by a page. It proves runtime facts, not Golder policy approval.