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
- func IsAction(name string) bool
- func IsReflexAction(name string) bool
- func Names() []string
- func Specs(target Target, dispatcher action.Dispatcher, ...) ([]action.ToolSpec, error)
- func TargetPolicy(target Target) action.PolicyDecision
- type Definition
- type Dispatcher
- type DispatcherConfig
- type ElementSurface
- type Record
- type Surface
- type Target
Constants ¶
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.
const Prefix = "computer."
Prefix is the namespace every action name carries.
Variables ¶
This section is empty.
Functions ¶
func IsReflexAction ¶
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 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.
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 ¶
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.