computeruse

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 11 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

Overview

Package computeruse defines the standard computer-use action vocabulary.

It is the most portable piece of this project's design. It depends on nothing except function calling, which every Realtime implementation already has, so it is proposed as a specification in its own right rather than documented as ours - another implementation can adopt the vocabulary without adopting anything else here.

Actions add no protocol. The result of an action is the next screen, and the screen already arrives through the video stream, so a tool output stays text and the visual consequence flows back through perception exactly as it does for a human. No image is ever carried in a function result.

Index

Constants

View Source
const (
	Click = "computer.click"
	// ClickNormalized uses the 0..1000 coordinate convention emitted by many
	// vision-language action models, independent of the captured frame size.
	ClickNormalized = "computer.click_normalized"
	ClickElement    = "computer.click_element"
	DoubleClick     = "computer.double_click"
	Move            = "computer.move"
	Drag            = "computer.drag"
	Type            = "computer.type"
	Key             = "computer.key"
	Scroll          = "computer.scroll"
	Screenshot      = "computer.screenshot"
	Wait            = "computer.wait"
)

Action names.

View Source
const Prefix = "computer."

Prefix is the namespace every action name carries.

Variables

This section is empty.

Functions

func IsAction

func IsAction(name string) bool

IsAction reports whether a tool name is in the namespace.

func IsReflexAction

func IsReflexAction(name string) bool

IsReflexAction reports whether name is an exact standard action that can usefully execute against the current frame. Screenshot and wait are observation-control operations: admitting either to a low-latency lane lets the model discard current evidence or deliberately sleep through a transient cue. They remain ordinary computer-use tools for the reasoning lane.

func Names

func Names() []string

Names lists the vocabulary in specification order.

func Specs

func Specs(target Target, dispatcher action.Dispatcher, overrides map[string]action.Confirm) ([]action.ToolSpec, error)

func TargetPolicy

func TargetPolicy(target Target) action.PolicyDecision

Specs renders the vocabulary as declared tools for one target.

A deployment overrides the confirmation requirements it wants; these are the defaults, and they err toward asking. An unattended deployment that declares no confirmer refuses everything above `never`, which is the correct failure for an action nobody can authorize. TargetPolicy answers the "policy" confirmation requirement for a declared target.

This is what "policy" means here, and it is worth being exact about, because the alternative was worse than it looked. Every clicking, typing, and scrolling action in the namespace declares "policy" by default; with no policy supplied the requirement reads as "always", and with no confirmer supplied "always" denies - so a deployment that turned computer use on got an agent that could move the pointer and take screenshots and could never press anything. A capability that cannot be exercised is not a safe capability, it is a broken one.

The fence that actually bounds the blast radius is the declared target: an action names a video source, the target owns a fixed set of sources, and the dispatcher refuses anything outside them. So the policy admits an action that lands inside the declared context and nothing else. A deployment that wants a human in the loop declares "always" and supplies a confirmer, which is a different requirement rather than a stricter reading of this one.

Types

type Definition

type Definition struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Parameters  json.RawMessage `json:"parameters"`
	// DefaultConfirm is what a deployment gets if it declares nothing. It is a
	// starting point a developer overrides, never an inference the runtime
	// makes about a particular call.
	DefaultConfirm action.Confirm `json:"default_confirm"`
}

Definition is one action's schema and its default consequence declaration.

func Definitions

func Definitions() []Definition

Definitions returns the complete vocabulary.

The schemas are strict - additionalProperties false, required fields listed - because an action with a misread argument is an action on the wrong thing, and a permissive schema turns that into a silent failure.

func DefinitionsFor

func DefinitionsFor(target Target) ([]Definition, error)

DefinitionsFor returns the vocabulary with the source field narrowed to the sources this target owns, which is what a deployment declaring tools should use. Definitions stays the target-free form, for publishing the schemas and for a caller that has no target yet.

func Lookup

func Lookup(name string) (Definition, bool)

Lookup returns one definition.

type Dispatcher

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

Dispatcher performs computer-use actions against one target.

func NewDispatcher

func NewDispatcher(config DispatcherConfig) (*Dispatcher, error)

NewDispatcher validates the configuration.

func (*Dispatcher) Dispatch

func (dispatcher *Dispatcher) Dispatch(ctx context.Context, call trajectory.ToolCall) (trajectory.ToolResult, error)

Dispatch performs one action.

Every rejection here is about grounding rather than about content: does this target own that source, and does that coordinate exist in the space the model was shown. An action that lands outside the screen is not a near-miss - it is an action on something nobody looked at.

func (*Dispatcher) Name

func (dispatcher *Dispatcher) Name() string

Name identifies the dispatcher in reports.

func (*Dispatcher) Records

func (dispatcher *Dispatcher) Records() []Record

Records returns the audit trail.

type DispatcherConfig

type DispatcherConfig struct {
	Target  Target
	Surface Surface
	// MaxWait bounds computer.wait, so a model cannot stall a session by
	// asking for an hour.
	MaxWait time.Duration
	// Audit receives every performed action.
	Audit func(Record)
	// Now supplies audit timestamps.
	Now func() uint64
}

DispatcherConfig configures action dispatch.

type ElementSurface

type ElementSurface interface {
	ClickElement(ctx context.Context, elementID string) error
}

ElementSurface is the optional browser grounding extension.

Pixel actions remain the portable baseline for a desktop, VM, or Android display. A browser can additionally expose a set-of-mark frame whose labels name interactive elements. Keeping that operation in a separate interface means a general screen surface does not pretend it can resolve DOM elements, and the dispatcher can refuse the wrong grounding mode explicitly.

type Record

type Record struct {
	CallID    string `json:"call_id"`
	Name      string `json:"name"`
	Target    string `json:"target"`
	Source    string `json:"source"`
	Arguments string `json:"arguments"`
	Error     string `json:"error,omitempty"`
	AtNS      uint64 `json:"at_ns"`
}

Record is one performed action, for the audit trail.

type Surface

type Surface interface {
	Name() string
	Click(ctx context.Context, x, y int, button string) error
	DoubleClick(ctx context.Context, x, y int) error
	Move(ctx context.Context, x, y int) error
	Drag(ctx context.Context, fromX, fromY, toX, toY int) error
	Type(ctx context.Context, text string) error
	Key(ctx context.Context, keys []string) error
	Scroll(ctx context.Context, x, y, deltaX, deltaY int) error
	Screenshot(ctx context.Context) error
}

Surface performs actions on a real screen.

It is the only thing in this package that touches the world, and it is deliberately tiny: a browser context, a virtual display, or a test double implements nine methods and nothing else. Everything about authority, confirmation, targeting, and auditing happens above it.

type Target

type Target struct {
	// Name identifies the context, and is what appears in a confirmation
	// prompt and in the audit record.
	Name string `json:"name"`
	// Sources are the declared video sources this target owns.
	Sources []string `json:"sources"`
	// Width and Height are the coordinate space, used to reject an action that
	// lands outside the screen the model saw.
	Width  int `json:"width"`
	Height int `json:"height"`
}

Target is a declared context an action may act on.

Blast radius is bounded by construction: an action names a video source, and a source is bound to a target that a deployment declared - a browser context or a virtual display, never an ambient desktop by default.

func (Target) Owns

func (target Target) Owns(source string) bool

Owns reports whether this target owns a source.

func (Target) Validate

func (target Target) Validate() error

Validate rejects an unusable target.

Directories

Path Synopsis
Package browser performs computer-use actions in a browser context.
Package browser performs computer-use actions in a browser context.

Jump to

Keyboard shortcuts

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