codeexec

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 68 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 BotDesktopInstallNoSudo = -2

Installer exit code of an unprivileged host without sudo, the root command streamed through onLine

Variables

View Source
var (
	BotDesktopEnv              = botdesktop.DesktopEnv
	BotDesktopToolPlacement    = botdesktop.ToolPlacement
	BotDesktopPlacementWhere   = botDesktopPlacementWhere
	BotDesktopPublishedEnv     = botdesktop.MustPublishedEnv
	BotDesktopSandboxEnv       = botdesktop.TerminalEnvironment
	BotDesktopProfileName      = botdesktop.ProfileName
	BotDesktopTouchActivity    = botdesktop.TouchActivity
	BotDesktopCuaMCPInvocation = func(ctx context.Context, sandbox tools.Environment, profile string, published map[string]string, telemetryOptIn bool) (string, []string, error) {
		return botdesktop.CuaMCPInvocation(sandbox, profile, published, telemetryOptIn)
	}
	BotDesktopSandboxCommand = botdesktop.SandboxDisplayCommand
	// Admitted lease epoch, an error carrying the HumanHasControl text while a human holds the screen
	BotDesktopAssertAgentMayAct = botDesktopAssertAgentMayAct
	BotDesktopLeaseEpoch        = func(env *tools.Env) int {
		return botdesktop.LeaseGet(botdesktop.ProfileKey(env)).EpochInt()
	}
	BotDesktopEnsureStartedForTool = botdesktop.EnsureStartedForTool
	// Desktop pane package installer of tools/bot_desktop/install.py answering the installer exit code
	BotDesktopInstallPackages = botDesktopInstallPackages
)

Bot desktop runtime calls of the computer use tool, package vars so tests substitute them

View Source
var ComputerUseCommandPaths = []string{
	"computer-use install", "computer-use status", "computer-use doctor",
	"computer-use permissions status", "computer-use permissions grant",
	"computer-use screen status", "computer-use screen start", "computer-use screen stop", "computer-use screen install",
}

Leaf command paths of the computer-use tree the CLI binds to the dispatcher

View Source
var SecretSubstrings = state.SecretSubstrings

SecretSubstrings are the name fragments that mark an environment variable as a credential

Functions

func CuaDriverChildEnv

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

Driver spawn env over the process environment with the bot desktop display, telemetry policy, no release check and Wayland opt in

func DelegatedChildOwnerMatcher

func DelegatedChildOwnerMatcher(childSessionID string) func(owner string) bool

DelegatedChildOwnerMatcher matches the kernel owners of one delegate_task child

func GetComputerUseSchema

func GetComputerUseSchema() *pyjson.Object

Generic function calling schema of the computer_use tool

func InstallCuaDriver

func InstallCuaDriver(ctx context.Context, w io.Writer, showInstallerProgress bool) (bool, error)

Reconciles the pinned cua-driver and its host setup on the active home, progress lines written to w

func IsSecretEnvName

func IsSecretEnvName(name string) bool

Reports whether a variable name contains a credential fragment in any letter case

func PythonOnPath

func PythonOnPath(ctx context.Context, env *tools.Env, needs string) (string, error)

First Python 3.8 or newer on the session's PATH, an error naming what needed it when PATH holds none

func RegisterKernelForTests

func RegisterKernelForTests(owner, cwd string) (registered, stopped func() bool, remove func())

Seeds an unspawned project kernel of owner the way tests set a registry item, with its probes and removal

func ReleaseComputerUseSession

func ReleaseComputerUseSession(ctx context.Context, sessionID string) bool

Releases one session owned backend, true when one was released

func ResetScreenshotDedup

func ResetScreenshotDedup(ctx context.Context, sessionID string)

Compaction boundary hook so the next capture of the session delivers pixels again

func RuntimePython

func RuntimePython(ctx context.Context) (string, error)

Path of the Python interpreter execute_code runs, an error when PATH holds none

func ShutdownAllKernels

func ShutdownAllKernels()

ShutdownAllKernels kills every session kernel, the process wiring calls it at exit

func ShutdownAllRemoteKernels

func ShutdownAllRemoteKernels()

ShutdownAllRemoteKernels kills every remote session kernel, the process wiring calls it at exit

func ShutdownComputerUseBackends

func ShutdownComputerUseBackends()

Stops every cached backend so no cua-driver outlives the process, never raising

func ShutdownKernelsForDelegatedChild

func ShutdownKernelsForDelegatedChild(childSessionID string)

ShutdownKernelsForDelegatedChild disposes a finished child's local and remote kernels

func ShutdownKernelsForOwner

func ShutdownKernelsForOwner(owner string)

ShutdownKernelsForOwner disposes every kernel a session owns when its approval state clears

Types

type ActionResult

type ActionResult struct {
	OK           bool
	Action       string
	Message      string
	Capture      *CaptureResult
	Meta         *pyjson.Object
	Verified     *bool
	Effect       *string
	Escalation   *pyjson.Object
	Path         *string
	Degraded     *bool
	DeliveryMode *string
	Code         *string
}

ActionResult carries transport success plus the structured driver verdict of one action

type AttributeError

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

AttributeError is the Python exception a non string action raises, named so the dispatcher reports its class

func (*AttributeError) Error

func (e *AttributeError) Error() string

type BackendDefaults

type BackendDefaults struct{}

BackendDefaults supplies the non abstract list_windows and wait methods of the abstract backend

func (BackendDefaults) ListWindows

func (BackendDefaults) ListWindows() ([]*pyjson.Object, error)

Reports no windows for backends that predate window discovery

func (BackendDefaults) Wait

func (BackendDefaults) Wait(seconds float64) (*ActionResult, error)

Sleeps the requested seconds clamped to zero through thirty and reports the wait

type BotDesktopInstallBusy

type BotDesktopInstallBusy struct{ Msg string }

BotDesktopInstallBusy is the InstallBusy another holder of the per profile install slot raises

func (*BotDesktopInstallBusy) Error

func (e *BotDesktopInstallBusy) Error() string

type CaptureResult

type CaptureResult struct {
	Mode          string
	Width         int
	Height        int
	PNGB64        *string
	Elements      []UIElement
	App           string
	WindowTitle   string
	PNGBytesLen   int
	ImageMimeType *string
	Note          string
	AXMaxElements int
}

CaptureResult carries the screenshot, the element mapping or both depending on the capture mode

type ChildPipe

type ChildPipe struct {
	Replies  uintptr
	Requests uintptr
	Handles  bool
}

ChildPipe names the descriptors a child reads replies from and writes requests to, Windows handles when Handles is set

type ChildResult

type ChildResult struct {
	ReturnCode int
	Stdout     string
	Stderr     string
	TimedOut   bool
}

ChildResult is the return code and text mode output of one child run

func RunChild

func RunChild(ctx context.Context, env *tools.Env, run ChildRun) (ChildResult, error)

Runs the child in its own owned process group, killing the whole group at the timeout or on cancel

type ChildRun

type ChildRun struct {
	Python  string
	Args    func(pipe ChildPipe) []string
	Stdin   string
	Env     map[string]string
	Timeout time.Duration
	Purpose string
	Serve   func(ctx context.Context, requests io.Reader, replies io.Writer)
}

ChildRun is one run of user code on an interpreter, its stdin fed and its pipe requests served by the caller

type ClickArgs

type ClickArgs struct {
	Element      *int
	X, Y         *int
	Button       string
	ClickCount   int
	Modifiers    []string
	DeliveryMode *string
	BringToFront bool
}

ClickArgs are the keyword arguments of a click, Button and ClickCount carry the caller's values

type ComputerUseArgs

type ComputerUseArgs struct {
	Action       string
	PermsAction  string
	ScreenAction string
	Include      []string
	Skip         []string
	JSON         bool
	Force        bool
	Yes          bool
}

ComputerUseArgs is the argparse namespace the computer-use parser tree produces

func ParseComputerUseArgs

func ParseComputerUseArgs(path string, flags *pflag.FlagSet) (ComputerUseArgs, error)

Namespace a command path and its parsed flags produce, each flag read only where the path declares it

type ComputerUseBackend

type ComputerUseBackend interface {
	Start() error
	Stop() error
	IsAvailable() (bool, error)
	Capture(mode string, app *string, pid, windowID *int) (*CaptureResult, error)
	Click(a ClickArgs) (*ActionResult, error)
	Drag(a DragArgs) (*ActionResult, error)
	Scroll(a ScrollArgs) (*ActionResult, error)
	TypeText(text string, d DeliveryArgs) (*ActionResult, error)
	Key(keys string, d DeliveryArgs) (*ActionResult, error)
	ListApps() ([]any, error)
	ListWindows() ([]*pyjson.Object, error)
	FocusApp(app string, raiseWindow bool) (*ActionResult, error)
	SetValue(value string, element *int) (*ActionResult, error)
	Wait(seconds float64) (*ActionResult, error)
}

ComputerUseBackend is the synchronous driver surface every computer use implementation provides

type ComputerUseCLI

type ComputerUseCLI struct {
	Env       *tools.Env
	Console   *cliui.Console
	Stderr    io.Writer
	PrintHelp func(path string) error
}

ComputerUseCLI is the process one computer-use command runs in with its streams and help printer

type ComputerUseCommand

type ComputerUseCommand func(ctx context.Context, cli *ComputerUseCLI, ns ComputerUseArgs) (int, error)

ComputerUseCommand is the set_defaults func of the computer-use parser answering the exit code

func BuildComputerUseParser

func BuildComputerUseParser() ComputerUseCommand

Dispatcher of the computer-use tree, help for a missing action at the parser that lacks it

type ComputerUseProvider

type ComputerUseProvider interface {
	Name() string
	DisplayName() string
	GetSetupSchema() (map[string]any, error)
	CreateBackend(permissionMode string) (ComputerUseBackend, error)
	IsAvailable() (bool, error)
	Doctor() (code int, ok bool, err error)
}

ComputerUseProvider is the factory a computer use provider plugin registers for one backend name

type CuaDriverBackend

type CuaDriverBackend struct {
	BackendDefaults

	PermissionMode string
	// contains filtered or unexported fields
}

CuaDriverBackend is the default computer use backend over the cua-driver MCP server

func (*CuaDriverBackend) BringToFront

func (b *CuaDriverBackend) BringToFront(pid int, windowID *int) *ActionResult

Activates a window so later foreground input lands on it

func (*CuaDriverBackend) CallTool

func (b *CuaDriverBackend) CallTool(name string, args *pyjson.Object, timeout float64) (*pyjson.Object, error)

Calls any cua-driver MCP tool by name with the session label defaulted in

func (*CuaDriverBackend) Capture

func (b *CuaDriverBackend) Capture(mode string, app *string, pid, windowID *int) (*CaptureResult, error)

Captures the frontmost window or an exact known target in som, ax or vision mode

func (*CuaDriverBackend) Click

func (b *CuaDriverBackend) Click(a ClickArgs) (*ActionResult, error)

Single or double click by element index or coordinates with the button through click's enum

func (*CuaDriverBackend) Drag

Drag between two elements or two points

func (*CuaDriverBackend) FocusApp

func (b *CuaDriverBackend) FocusApp(app string, raiseWindow bool) (*ActionResult, error)

Selects the app's window as the sticky target, raising it only through the approved bring_to_front tool

func (*CuaDriverBackend) IsAvailable

func (b *CuaDriverBackend) IsAvailable() (bool, error)

Desktop platforms with a resolvable driver binary

func (*CuaDriverBackend) Key

Presses a key or a modifier combination through hotkey

func (*CuaDriverBackend) LaunchApp

func (b *CuaDriverBackend) LaunchApp(a LaunchAppArgs) (any, error)

Idempotent launch returning the driver's pid, bundle id, name and windows

func (*CuaDriverBackend) ListApps

func (b *CuaDriverBackend) ListApps() ([]any, error)

Running apps from structuredContent, the compatibility envelopes, the windows payload, then the text listing

func (*CuaDriverBackend) ListWindows

func (b *CuaDriverBackend) ListWindows() ([]*pyjson.Object, error)

Visible windows frontmost first, refetched over the CLI transport when MCP returns none

func (*CuaDriverBackend) Scroll

func (b *CuaDriverBackend) Scroll(a ScrollArgs) (*ActionResult, error)

Scroll by wheel ticks clamped to 1 through 50, coordinates only when the driver advertises them

func (*CuaDriverBackend) SetAgentCursorEnabled

func (b *CuaDriverBackend) SetAgentCursorEnabled(enabled bool, cursorID string) *ActionResult

Toggles the agent cursor overlay of this run

func (*CuaDriverBackend) SetConfig

func (b *CuaDriverBackend) SetConfig(config *pyjson.Object) *ActionResult

Sets cua-driver config keys, unknown keys pass through for the driver to validate

func (*CuaDriverBackend) SetValue

func (b *CuaDriverBackend) SetValue(value string, element *int) (*ActionResult, error)

Sets a value on an element, popup selects included

func (*CuaDriverBackend) Start

func (b *CuaDriverBackend) Start() error

Checks the runtime contract, starts the private daemon and the session, then declares this run's identity

func (*CuaDriverBackend) Stop

func (b *CuaDriverBackend) Stop() error

Ends the driver session, then tears down session, bridge and private daemon even when one step fails

func (*CuaDriverBackend) TypeText

func (b *CuaDriverBackend) TypeText(text string, d DeliveryArgs) (*ActionResult, error)

Types text into the sticky target window

type CuaDriverProvider

type CuaDriverProvider struct {
	ProviderDefaults
	// contains filtered or unexported fields
}

Built in cua provider driving cua-driver over MCP

func (*CuaDriverProvider) CreateBackend

func (p *CuaDriverProvider) CreateBackend(permissionMode string) (ComputerUseBackend, error)

Fresh cua-driver backend in the requested permission mode

func (*CuaDriverProvider) IsAvailable

func (p *CuaDriverProvider) IsAvailable() (bool, error)

Supported platform with a cua-driver binary, or a desktop placed inside the terminal backend

type DeliveryArgs

type DeliveryArgs struct {
	DeliveryMode *string
	BringToFront bool
}

DeliveryArgs are the delivery keyword arguments of type_text and key

type DragArgs

type DragArgs struct {
	FromElement  *int
	ToElement    *int
	FromXY       *[2]int
	ToXY         *[2]int
	Button       string
	Modifiers    []string
	DeliveryMode *string
	BringToFront bool
}

DragArgs are the keyword arguments of a drag between two elements or two points

type LaunchAppArgs

type LaunchAppArgs struct {
	BundleID                      string
	Name                          string
	URLs                          []string
	AdditionalArguments           []string
	CreatesNewApplicationInstance bool
}

LaunchAppArgs are the keyword arguments of launch_app

type ProviderDefaults

type ProviderDefaults struct {
	ID    string
	Label string
}

ProviderDefaults supplies the identity, picker row, availability and doctor defaults of a provider

func (ProviderDefaults) DisplayName

func (p ProviderDefaults) DisplayName() string

Human readable label, the name when no label is set

func (ProviderDefaults) Doctor

func (ProviderDefaults) Doctor() (int, bool, error)

Backend ships no doctor by default

func (ProviderDefaults) GetSetupSchema

func (p ProviderDefaults) GetSetupSchema() (map[string]any, error)

Picker row with the display name and no badge, tag or env vars

func (ProviderDefaults) IsAvailable

func (ProviderDefaults) IsAvailable() (bool, error)

Usable on this host by default

func (ProviderDefaults) Name

func (p ProviderDefaults) Name() string

Stable config key value of the provider

type ScrollArgs

type ScrollArgs struct {
	Direction    string
	Amount       int
	Element      *int
	X, Y         *int
	Modifiers    []string
	DeliveryMode *string
	BringToFront bool
}

ScrollArgs are the keyword arguments of a scroll, Amount is wheel ticks

type UIElement

type UIElement struct {
	Index        int
	Role         string
	Label        string
	Bounds       [4]int
	App          string
	PID          int
	WindowID     int
	Attributes   map[string]any
	ElementToken *string
}

UIElement is one interactable element of a capture, bounds are x y w h in logical pixels

Jump to

Keyboard shortcuts

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