Documentation
¶
Index ¶
- Constants
- Variables
- func BrowserProfileDir(e tools.Environment) (string, error)
- func Claim(env *tools.Env) (string, error)
- func CuaMCPInvocation(e tools.Environment, profile string, published map[string]string, ...) (string, []string, error)
- func CuaTelemetryOff() map[string]string
- func DesktopEnv(env *tools.Env, base map[string]string) map[string]string
- func DesktopHome(e tools.Environment) (string, error)
- func DispatchIdleWatchEntry()
- func DockArgv(exe, userDataDir string, sandboxBypass *bool) []string
- func DockExecLine(exe, userDataDir string, sandboxBypass *bool) string
- func DockLaunch(env *tools.Env) (string, string, bool)
- func EnsureStartedForTool(env *tools.Env)
- func Executable(env *tools.Env) string
- func Geometry(env *tools.Env) (string, error)
- func GrabJPEG(e tools.Environment, published map[string]string, maxW, maxH, quality int) ([]byte, error)
- func IdleSeconds(env *tools.Env) *float64
- func IdleStopSeconds(env *tools.Env) (float64, error)
- func IdleWatchMain(env *tools.Env, argv []string, stdout io.Writer) error
- func InSandbox(env *tools.Env) (bool, error)
- func InstallCommand() string
- func InstallPackages(env *tools.Env, askPassword func() (string, error), onLine func(string)) (int, error)
- func InstallPackagesWith(env *tools.Env, askPassword func() (string, error), onLine func(string), ...) (int, error)
- func Installable() bool
- func IsRoot() bool
- func IsRunning(env *tools.Env) (bool, error)
- func IsSupportedHost() bool
- func LauncherPid(env *tools.Env) (int, bool)
- func LeaseHumanHolds(profileKey string) bool
- func LeaseOnChange(fn func(key string, lease BotDesktopLease)) func()
- func LeasePublicView(l BotDesktopLease) *jsonutil.Object
- func MarkerSandboxAlive(marker map[string]any) bool
- func MemoryBlocker(info MemoryInfo, need int) string
- func MinFreeMB(env *tools.Env) (int, error)
- func MissingBinaries() []string
- func MustPublishedEnv(env *tools.Env) map[string]string
- func NextCheckIn(limit float64, idle *float64) int
- func PackageManager() string
- func PluginImageAdvice(backend string) string
- func ProfileDir(env *tools.Env) string
- func ProfileKey(env *tools.Env) string
- func ProfileName(env *tools.Env) (name string)
- func PublishedEnv(env *tools.Env) (map[string]string, error)
- func RFBSocketPath(env *tools.Env) string
- func Release(key string)
- func SandboxChromiumExecutable(e tools.Environment) (string, error)
- func SandboxDisplayCommand(e tools.Environment, published map[string]string, argv []string) (string, []string, error)
- func SandboxMissingBinaries(e tools.Environment) ([]string, error)
- func SandboxPublishedEnv(e tools.Environment, profile string) (map[string]string, error)
- func SandboxScreenRunning(env *tools.Env) (bool, error)
- func SandboxStart(env *tools.Env, e tools.Environment, profile, geometry string, ...) (map[string]string, error)
- func SandboxStop(env *tools.Env, e tools.Environment, profile string) (bool, error)
- func SeedSandboxBrowserProfile(e tools.Environment, userDataDir string) error
- func StateDir(env *tools.Env) string
- func Stop(env *tools.Env, stillDue func() (bool, error)) (bool, error)
- func StopIfIdle(env *tools.Env, launcher *launcherID) (bool, error)
- func TerminalEnvironment(env *tools.Env, create bool) (tools.Environment, error)
- func Thumbnail(env *tools.Env, maxW, maxH, quality int) ([]byte, error)
- func TightHeadroomMB(floor int) int
- func ToolPlacement(env *tools.Env) (string, error)
- func TouchActivity(env *tools.Env)
- func UserFor(e tools.Environment) (string, error)
- type BotDesktopLease
- type DesktopStatus
- type HumanHasControl
- type InstallBusy
- type LeaseReleaseOptions
- type MemoryInfo
- type Placement
Constants ¶
const ( LeaseAgent = "agent" LeaseHuman = "human" )
const ( Gateway = "gateway" Terminal = "terminal" Refused = "refused" )
Placement values the screen resolves to
const ( DefaultIdleStopMinutes = 30 HumanLeaseAbandonedWindows = 4 HumanLeaseAbandonedMinS = 600.0 )
Idle stop defaults and the human lease abandonment rule
const ( ThumbMaxW = 960 ThumbMaxH = 600 ThumbQuality = 72 )
Largest width and height of a screen thumbnail, and its JPEG quality
const CuaUpdateCheckVar = "CUA_DRIVER_RS_UPDATE_CHECK"
Switch stopping cua-driver from asking GitHub for releases, icebath installs the versions it runs
const DefaultMinFreeMB = 1536
DefaultMinFreeMB is the memory floor a screen start needs when config sets none
const DesktopUser = "pn"
DesktopUser is the account the desktop and browser run as inside a sandbox image that has it
const DiskCacheBytes = 256 * 1024 * 1024
DiskCacheBytes caps the persistent profile HTTP cache
const IdleWatchEntry = "__icebath_bot_desktop_idle_watch__"
IdleWatchEntry is the argv entry the launcher loop re-executes this binary with for one idle check
const NoSudo = -2
Exit code of an install on an unprivileged host without sudo, the command went to the line sink
const SandboxImageHint = config.DefaultSandboxImage
SandboxImageHint names the image icebath builds with the desktop stack
Variables ¶
var ( BrowserUserDataDir func(env *tools.Env) string BrowserExecutablePath func(env *tools.Env) string BrowserChromiumExecutable func(env *tools.Env, allowOverride bool) string BrowserAppArmorRestricts func() bool BrowserNeedsSandboxBypass func() bool BrowserSandboxBypassArgs func() []string BrowserSeedProfile func(userDataDir string) error )
Browser facts pkg/browser assigns at init, so this package never imports it
var BinaryPackages = map[string]map[string]string{
"apt": {"Xvnc": "tigervnc-standalone-server", "xfwm4": "xfwm4", "xfce4-panel": "xfce4-panel",
"xfdesktop": "xfdesktop4", "xfsettingsd": "xfce4-settings", "dbus-run-session": "dbus-x11",
"xauth": "xauth", "xdpyinfo": "x11-utils", "setxkbmap": "x11-xkb-utils", "xprop": "x11-utils"},
"dnf": {"Xvnc": "tigervnc-x11-server", "xfwm4": "xfwm4", "xfce4-panel": "xfce4-panel",
"xfdesktop": "xfdesktop", "xfsettingsd": "xfce4-settings", "dbus-run-session": "dbus-daemon",
"xauth": "xorg-x11-xauth", "xdpyinfo": "xdpyinfo", "setxkbmap": "setxkbmap", "xprop": "xprop"},
"pacman": {"Xvnc": "tigervnc", "xfwm4": "xfwm4", "xfce4-panel": "xfce4-panel", "xfdesktop": "xfdesktop",
"xfsettingsd": "xfce4-settings", "dbus-run-session": "dbus",
"xauth": "xorg-xauth", "xdpyinfo": "xorg-xdpyinfo", "setxkbmap": "xorg-setxkbmap", "xprop": "xorg-xprop"},
}
BinaryPackages maps each required binary to its package per package manager
var Packages = map[string][]string{
"apt": {"tigervnc-standalone-server", "xfce4-panel", "xfwm4", "xfdesktop4", "xfce4-settings",
"xfce4-terminal", "dbus-x11", "x11-xserver-utils", "x11-utils", "x11-xkb-utils", "xauth",
"fonts-dejavu-core"},
"dnf": {"tigervnc-x11-server", "xfce4-panel", "xfwm4", "xfdesktop", "xfce4-settings",
"xfce4-terminal", "dbus-daemon", "xsetroot", "xset", "xdpyinfo", "xprop", "xorg-x11-xauth", "setxkbmap",
"dejavu-sans-fonts"},
"pacman": {"tigervnc", "xfce4-panel", "xfwm4", "xfdesktop", "xfce4-settings", "xfce4-terminal", "dbus",
"xorg-xsetroot", "xorg-xset", "xorg-xdpyinfo", "xorg-xprop", "xorg-xauth", "xorg-setxkbmap",
"ttf-dejavu"},
}
Packages are the full install sets per package manager
var RequiredBinaries = []string{"Xvnc", "xfwm4", "xfce4-panel", "xfdesktop", "xfsettingsd", "dbus-run-session",
"xauth", "xdpyinfo", "setxkbmap", "xprop"}
RequiredBinaries are the host programs the gateway hosted screen needs
Flags the agent launch and the dock icon share, on the bot X screen even under a Wayland session, maximized on it
Functions ¶
func BrowserProfileDir ¶
func BrowserProfileDir(e tools.Environment) (string, error)
The one user data dir the agent browser and the dock icon share inside the sandbox
func Claim ¶
Atomically takes the install slot of the profile and returns its key, InstallBusy when taken
func CuaMCPInvocation ¶
func CuaMCPInvocation(e tools.Environment, profile string, published map[string]string, telemetryOptIn bool) (string, []string, error)
Command and args running cua-driver mcp on the sandbox display, telemetry off unless the user opted in
func CuaTelemetryOff ¶
Switches every Cua program honours to keep its maker's product telemetry off
func DesktopEnv ¶
Base env with the running screen DISPLAY, XAUTHORITY and DBUS merged in, unchanged when it is down
func DesktopHome ¶
func DesktopHome(e tools.Environment) (string, error)
HOME of the desktop user inside the sandbox, where state outliving a container stop goes
func DispatchIdleWatchEntry ¶
func DispatchIdleWatchEntry()
Runs one idle check and exits when argv carries the entry, the check in a session of its own
func DockArgv ¶
Command the dock Browser icon runs, attachable through a debugging port, with the launcher sandbox policy
func DockExecLine ¶
Exec line of the dock desktop entry with every argument quoted and escaped per the Desktop Entry spec
func DockLaunch ¶
Executable and user data dir for the dock Browser icon, ok false when no Chromium exists
func EnsureStartedForTool ¶
Tool boundary hook bringing the sandbox screen up, or a headless host screen when auto_start allows
func Executable ¶
Chromium the bot runs, pinned then packaged then system, the order flipped under the AppArmor userns rule
func GrabJPEG ¶
func GrabJPEG(e tools.Environment, published map[string]string, maxW, maxH, quality int) ([]byte, error)
One JPEG of the sandbox screen grabbed inside the sandbox, where the X socket and its cookie live, nil when the grab fails
func IdleSeconds ¶
Seconds since the last stamped use, the env publish time standing in, nil when neither exists
func IdleStopSeconds ¶
Configured idle stop window in seconds, zero when off or not a positive finite number
func IdleWatchMain ¶
One idle check, stopping the screen when due and printing the next delay otherwise
func InstallCommand ¶
func InstallCommand() string
Distro install command as the human types it here, sudo prefixed unless root, empty without a manager
func InstallPackages ¶
func InstallPackages(env *tools.Env, askPassword func() (string, error), onLine func(string)) (int, error)
Runs the distro package install with the default fifteen minute timeout and returns its exit code
func InstallPackagesWith ¶
func InstallPackagesWith(env *tools.Env, askPassword func() (string, error), onLine func(string), timeoutSeconds float64, claimed bool) (int, error)
Runs the package install under the profile slot, released on return even when the caller claimed it
func Installable ¶
func Installable() bool
Whether the install command could succeed here, false unprivileged without sudo
func LauncherPid ¶
Live launcher pid of the profile screen, ok false when launcher.pid names no live launcher
func LeaseHumanHolds ¶
func LeaseOnChange ¶
func LeaseOnChange(fn func(key string, lease BotDesktopLease)) func()
Subscribes to transitions made in this process and returns the unsubscribe
func LeasePublicView ¶
func LeasePublicView(l BotDesktopLease) *jsonutil.Object
Lease as RPC results and broadcasts show it, the viewer id capability replaced by a short hash
func MarkerSandboxAlive ¶
Whether the sandbox a marker names still exists, docker inspect cached five seconds, others alive
func MemoryBlocker ¶
func MemoryBlocker(info MemoryInfo, need int) string
Why the screen must not start now for lack of memory, empty when it may
func MustPublishedEnv ¶
Published env for hook signatures without an error, panicking where the lookup fails
func NextCheckIn ¶
Whole seconds until the screen could next be due, a default window when the auto stop is off
func PackageManager ¶
func PackageManager() string
apt, dnf or pacman by the first manager on PATH, empty for none
func PluginImageAdvice ¶
How a plugin sandbox gets the desktop stack, empty for a built in backend
func ProfileDir ¶
User data dir of the bot browser, the pinned browser.user_data_dir or the screen state dir
func ProfileKey ¶
Lease key of the env, the profile home path
func ProfileName ¶
Active profile name of the env home, default when it cannot be read
func PublishedEnv ¶
Variables the launcher published once the screen bus existed, empty while it is down
func RFBSocketPath ¶
Host RFB socket path, empty when down or sandbox hosted
func SandboxChromiumExecutable ¶
func SandboxChromiumExecutable(e tools.Environment) (string, error)
Playwright Chromium inside the sandbox, empty when the image has none, cached per env
func SandboxDisplayCommand ¶
func SandboxDisplayCommand(e tools.Environment, published map[string]string, argv []string) (string, []string, error)
Command and args running argv as the desktop user on the sandbox display through the backend exec prefix
func SandboxMissingBinaries ¶
func SandboxMissingBinaries(e tools.Environment) ([]string, error)
Desktop binaries the sandbox lacks
func SandboxPublishedEnv ¶
Published env of the profile screen inside the sandbox
func SandboxScreenRunning ¶
True when a marker exists and its sandbox is alive, dropping a marker whose sandbox is gone
func SandboxStart ¶
func SandboxStart(env *tools.Env, e tools.Environment, profile, geometry string, waitSeconds float64, browserExec, browserExecLine string) (map[string]string, error)
Brings the screen up inside the sandbox, idempotent, returning the published env or the blocker
func SandboxStop ¶
Kills the launcher session and every process holding the profile dir, true when something was live
func SeedSandboxBrowserProfile ¶
func SeedSandboxBrowserProfile(e tools.Environment, userDataDir string) error
Writes the agent profile preferences into the sandbox browser profile as the desktop user
func StopIfIdle ¶
Stops the screen idle past the limit with no live human hold, handing an abandoned lease back
func TerminalEnvironment ¶
The profile terminal environment, created through the terminal tool when asked and absent
func Thumbnail ¶
JPEG of the running screen shrunk into the box, nil when no screen is up, read only so neither the lease nor a person in control is disturbed
func TightHeadroomMB ¶
Free memory below which a start is allowed and logged, a third above the floor
func ToolPlacement ¶
Where the browser or cua-driver about to spawn must run, starting a down sandbox screen first
Types ¶
type BotDesktopLease ¶
Who drives a profile's Bot Desktop screen, the non holder fields kept as the JSON values Python carries
func LeaseAcquire ¶
func LeaseAcquire(viewerID, profileKey, reason string) (BotDesktopLease, error)
Human viewer takes control, last writer wins and an existing hold by the same viewer stays put
func LeaseAssertAgentMayAct ¶
func LeaseAssertAgentMayAct(profileKey string) (BotDesktopLease, error)
Lease as of now for an admitted action, HumanHasControl while a human holds the screen
func LeaseGet ¶
func LeaseGet(profileKey string) BotDesktopLease
Lease of a profile home, empty meaning the process home
func LeaseRelease ¶
func LeaseRelease(opts LeaseReleaseOptions) (BotDesktopLease, error)
Returns control to the agent unless the lease changed since the judged epoch or another viewer holds
func (BotDesktopLease) AsDict ¶
func (l BotDesktopLease) AsDict() *jsonutil.Object
func (BotDesktopLease) EpochInt ¶
func (l BotDesktopLease) EpochInt() int
Integer epoch for comparisons across an admitted action, bools and floats folded as Python int does
type DesktopStatus ¶
type DesktopStatus struct {
Profile string
Supported bool
Installed bool
Missing []string
Running bool
PID *int
Display *string
Socket *string
Geometry string
InstallCommand *string
Browser *string
Blocker *string
MemoryAvailableMB *int
MemoryLimitMB *int
Placement string
ImageSwitch *jsonutil.Object
}
Screen status the pane renders
func Start ¶
func Start(env *tools.Env, waitSeconds float64) (DesktopStatus, error)
Starts this profile screen, idempotent, blocking until the launcher publishes or the wait passes
func Status ¶
func Status(env *tools.Env, profile string) (DesktopStatus, error)
Screen status of this profile, the sandbox status when the screen lives there
func (DesktopStatus) AsDict ¶
func (s DesktopStatus) AsDict() *jsonutil.Object
Field dict in dataclass order
type HumanHasControl ¶
type HumanHasControl struct{ Msg string }
Raised by screen driving tools while a human holds the lease
func (*HumanHasControl) Error ¶
func (e *HumanHasControl) Error() string
type InstallBusy ¶
type InstallBusy struct{ Msg string }
Refusal raised while another install holds the slot of the profile
func (*InstallBusy) Error ¶
func (e *InstallBusy) Error() string
type LeaseReleaseOptions ¶
Release scope, a nil viewer or epoch meaning any
type MemoryInfo ¶
Available memory and the limit in MiB, nil when unreadable
func GetMemoryInfo ¶
func GetMemoryInfo() MemoryInfo
Tighter of host MemAvailable and the cgroup headroom, with the cgroup limit or MemTotal