botdesktop

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 47 Imported by: 1 module, 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

Index

Constants

View Source
const (
	LeaseAgent = "agent"
	LeaseHuman = "human"
)
View Source
const (
	Gateway  = "gateway"
	Terminal = "terminal"
	Refused  = "refused"
)

Placement values the screen resolves to

View Source
const (
	DefaultIdleStopMinutes     = 30
	HumanLeaseAbandonedWindows = 4
	HumanLeaseAbandonedMinS    = 600.0
)

Idle stop defaults and the human lease abandonment rule

View Source
const (
	ThumbMaxW    = 960
	ThumbMaxH    = 600
	ThumbQuality = 72
)

Largest width and height of a screen thumbnail, and its JPEG quality

View Source
const CuaUpdateCheckVar = "CUA_DRIVER_RS_UPDATE_CHECK"

Switch stopping cua-driver from asking GitHub for releases, icebath installs the versions it runs

View Source
const DefaultMinFreeMB = 1536

DefaultMinFreeMB is the memory floor a screen start needs when config sets none

View Source
const DesktopUser = "pn"

DesktopUser is the account the desktop and browser run as inside a sandbox image that has it

View Source
const DiskCacheBytes = 256 * 1024 * 1024

DiskCacheBytes caps the persistent profile HTTP cache

View Source
const IdleWatchEntry = "__icebath_bot_desktop_idle_watch__"

IdleWatchEntry is the argv entry the launcher loop re-executes this binary with for one idle check

View Source
const NoSudo = -2

Exit code of an install on an unprivileged host without sudo, the command went to the line sink

View Source
const SandboxImageHint = config.DefaultSandboxImage

SandboxImageHint names the image icebath builds with the desktop stack

Variables

View Source
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

View Source
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

View Source
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

View Source
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

View Source
var SharedProfileArgs = []string{"--test-type", "--ozone-platform=x11", "--start-maximized", fmt.Sprintf("--disk-cache-size=%d", DiskCacheBytes)}

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

func Claim(env *tools.Env) (string, error)

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

func CuaTelemetryOff() map[string]string

Switches every Cua program honours to keep its maker's product telemetry off

func DesktopEnv

func DesktopEnv(env *tools.Env, base map[string]string) map[string]string

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

func DockArgv(exe, userDataDir string, sandboxBypass *bool) []string

Command the dock Browser icon runs, attachable through a debugging port, with the launcher sandbox policy

func DockExecLine

func DockExecLine(exe, userDataDir string, sandboxBypass *bool) string

Exec line of the dock desktop entry with every argument quoted and escaped per the Desktop Entry spec

func DockLaunch

func DockLaunch(env *tools.Env) (string, string, bool)

Executable and user data dir for the dock Browser icon, ok false when no Chromium exists

func EnsureStartedForTool

func EnsureStartedForTool(env *tools.Env)

Tool boundary hook bringing the sandbox screen up, or a headless host screen when auto_start allows

func Executable

func Executable(env *tools.Env) string

Chromium the bot runs, pinned then packaged then system, the order flipped under the AppArmor userns rule

func Geometry

func Geometry(env *tools.Env) (string, error)

Configured screen geometry, 1440x900 by default

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

func IdleSeconds(env *tools.Env) *float64

Seconds since the last stamped use, the env publish time standing in, nil when neither exists

func IdleStopSeconds

func IdleStopSeconds(env *tools.Env) (float64, error)

Configured idle stop window in seconds, zero when off or not a positive finite number

func IdleWatchMain

func IdleWatchMain(env *tools.Env, argv []string, stdout io.Writer) error

One idle check, stopping the screen when due and printing the next delay otherwise

func InSandbox

func InSandbox(env *tools.Env) (bool, error)

True when policy places the screen inside the terminal backend

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 IsRoot

func IsRoot() bool

True when the process runs as root

func IsRunning

func IsRunning(env *tools.Env) (bool, error)

True when the screen published a display

func IsSupportedHost

func IsSupportedHost() bool

True on Linux, the only host the screen runs on

func LauncherPid

func LauncherPid(env *tools.Env) (int, bool)

Live launcher pid of the profile screen, ok false when launcher.pid names no live launcher

func LeaseHumanHolds

func LeaseHumanHolds(profileKey string) bool

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) *pyjson.Object

Lease as RPC results and broadcasts show it, the viewer id capability replaced by a short hash

func MarkerSandboxAlive

func MarkerSandboxAlive(marker map[string]any) bool

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 MinFreeMB

func MinFreeMB(env *tools.Env) (int, error)

Configured bot_desktop.min_free_memory_mb, zero disabling the gate

func MissingBinaries

func MissingBinaries() []string

Required binaries missing from PATH

func MustPublishedEnv

func MustPublishedEnv(env *tools.Env) map[string]string

Published env for hook signatures without an error, panicking where the lookup fails

func NextCheckIn

func NextCheckIn(limit float64, idle *float64) int

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

func PluginImageAdvice(backend string) string

How a plugin sandbox gets the desktop stack, empty for a built in backend

func ProfileDir

func ProfileDir(env *tools.Env) string

User data dir of the bot browser, the pinned browser.user_data_dir or the screen state dir

func ProfileKey

func ProfileKey(env *tools.Env) string

Lease key of the env, the profile home path

func ProfileName

func ProfileName(env *tools.Env) (name string)

Active profile name of the env home, default when it cannot be read

func PublishedEnv

func PublishedEnv(env *tools.Env) (map[string]string, error)

Variables the launcher published once the screen bus existed, empty while it is down

func RFBSocketPath

func RFBSocketPath(env *tools.Env) string

Host RFB socket path, empty when down or sandbox hosted

func Release

func Release(key string)

Frees the install slot under key and drops its file lock

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

func SandboxPublishedEnv(e tools.Environment, profile string) (map[string]string, error)

Published env of the profile screen inside the sandbox

func SandboxScreenRunning

func SandboxScreenRunning(env *tools.Env) (bool, error)

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

func SandboxStop(env *tools.Env, e tools.Environment, profile string) (bool, error)

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 StateDir

func StateDir(env *tools.Env) string

Per profile screen state directory under the env home

func Stop

func Stop(env *tools.Env, stillDue func() (bool, error)) (bool, error)

Stops this profile screen, true when a launcher or an orphaned X server was signalled

func StopIfIdle

func StopIfIdle(env *tools.Env, launcher *launcherID) (bool, error)

Stops the screen idle past the limit with no live human hold, handing an abandoned lease back

func TerminalEnvironment

func TerminalEnvironment(env *tools.Env, create bool) (tools.Environment, error)

The profile terminal environment, created through the terminal tool when asked and absent

func Thumbnail

func Thumbnail(env *tools.Env, maxW, maxH, quality int) ([]byte, error)

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

func TightHeadroomMB(floor int) int

Free memory below which a start is allowed and logged, a third above the floor

func ToolPlacement

func ToolPlacement(env *tools.Env) (string, error)

Where the browser or cua-driver about to spawn must run, starting a down sandbox screen first

func TouchActivity

func TouchActivity(env *tools.Env)

Stamps the screen activity file

func UserFor

func UserFor(e tools.Environment) (string, error)

Desktop user of the sandbox for callers outside the package

Types

type BotDesktopLease

type BotDesktopLease struct {
	Holder   string
	ViewerID any
	Since    any
	Reason   any
	Epoch    any
}

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() *pyjson.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       *pyjson.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() *pyjson.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

type LeaseReleaseOptions struct {
	ViewerID    *string
	ProfileKey  string
	UnlessHuman bool
	Epoch       *int
}

Release scope, a nil viewer or epoch meaning any

type MemoryInfo

type MemoryInfo struct {
	AvailableMB *int
	LimitMB     *int
}

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

type Placement

type Placement struct {
	Where   string
	Backend string
	Reason  string
}

Where the screen runs, the configured terminal backend and the sentence a refusal shows

func Resolve

func Resolve(env *tools.Env) (Placement, error)

Gateway, terminal or refused from config and backend class alone, never starting a sandbox

Jump to

Keyboard shortcuts

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