Documentation
¶
Overview ¶
Package computeruse owns the platform-independent authorization and lifecycle of a single locally resolved desktop window. Platform adapters must fail closed when they cannot prove the target and input conditions.
Index ¶
- Constants
- Variables
- func IsOperatorPane(windowID string) bool
- func MatchApplications(name string, targets []Target) []int
- func PreviewPoint(frame FrameGeometry, targetID, frameID string, ...) (float64, float64, error)
- func RequestMacPermission(string) bool
- func RunOperatorPane(ctx context.Context, socket string, in, out *os.File) error
- func ServeOperatorPane(ctx context.Context, conn net.Conn, pane *Pane) error
- func VerifyOperatorPanePeer(ctx context.Context, conn net.Conn, daemon *tuiosctl.Client, windowID string) error
- func WithApplicationLaunchGuard(ctx context.Context, guard func() error) context.Context
- type Application
- type ApplicationLauncher
- type ApplicationResolution
- type Backend
- type Capabilities
- type CaptureAvailability
- type CaptureBackend
- type Element
- type Frame
- type FrameBoundBackend
- type FrameGeometry
- type FrameKeyAvailability
- type FrameKeyBackend
- type FrameScrollBackend
- type KittyRenderer
- type OperatorPreview
- type OperatorPreviewBackend
- type OperatorPreviewDiscarder
- type Pane
- type PaneClient
- type PaneHandle
- type PaneRequest
- type PaneResponse
- type PermissionState
- type PlatformBackend
- type SemanticBackend
- type Session
- func (s *Session) Act(ctx context.Context, snapshotID, ref, action, text string) error
- func (s *Session) Capture(ctx context.Context) (Frame, error)
- func (s *Session) ClickFrame(ctx context.Context, frameID string, x, y float64) error
- func (s *Session) Close() error
- func (s *Session) Do(ctx context.Context, control bool, ...) error
- func (s *Session) InstallOperatorPreview(preview OperatorPreview) error
- func (s *Session) Observe(ctx context.Context) (Snapshot, error)
- func (s *Session) Pause()
- func (s *Session) PressFrame(ctx context.Context, frameID, key string) error
- func (s *Session) Resume(ctx context.Context) error
- func (s *Session) ScrollFrame(ctx context.Context, frameID string, x, y float64, dx, dy int) error
- func (s *Session) Start(ctx context.Context, target Target, caps Capabilities) error
- func (s *Session) Status() Status
- func (s *Session) Stop()
- func (s *Session) SupportsCapture() bool
- func (s *Session) SupportsCoordinates() bool
- func (s *Session) SupportsFrameAction(action string) bool
- func (s *Session) SupportsFrameKey(key string) bool
- func (s *Session) SupportsSemantic(action string) bool
- func (s *Session) SupportsSnapshot() bool
- func (s *Session) WaitOperatorPreview(ctx context.Context) error
- type Snapshot
- type SnapshotBackend
- type Status
- type Target
Constants ¶
const ( MaxFrameBytes = 8 << 20 MaxFramePixels = 16 << 20 )
const ( MaxSnapshotNodes = 500 MaxNodeTextBytes = 512 MaxSnapshotBytes = 32 << 10 )
const OperatorPanePrefix = "golder-computer-use-"
OperatorPanePrefix is reserved for the person's desktop-control view. Pane tools must not inject input into it or capture its sensitive contents.
Variables ¶
var ( ErrNotActive = errors.New("computer use session is not active") ErrNotAllowed = errors.New("computer use action is not authorized") ErrPaused = errors.New("computer use is paused; the user must resume") ErrTargetLost = errors.New("computer use target changed or is unavailable") )
var ErrStaleObservation = errors.New("computer use observation is stale; observe the target again")
Functions ¶
func IsOperatorPane ¶
func MatchApplications ¶
MatchApplications returns indexes whose application name exactly matches the requested name after case and whitespace normalization. A unique match can be used directly; ambiguous matches require an operator's selection. Substring or title matching is deliberately excluded because a document or a different application may contain the requested name.
func PreviewPoint ¶
func PreviewPoint(frame FrameGeometry, targetID, frameID string, previewWidth, previewHeight, x, y float64) (float64, float64, error)
PreviewPoint converts coordinates from a letterboxed preview into frame pixels; clicks outside the visible image and stale frame identities fail.
func RequestMacPermission ¶ added in v1.5.58
func RunOperatorPane ¶
RunOperatorPane is the internal child entry point for the dedicated tuios view. The parent authenticates all three socket peers before serving them. It must not be used as a model-facing desktop control interface.
func ServeOperatorPane ¶
ServeOperatorPane serves one already authenticated connection. The caller MUST verify its exact pane identity with VerifyOperatorPanePeer before using this function and keep it private from model-facing tools. If several connections share a Pane, they must all be pinned to the same verified process; disconnect or cancellation pauses the session before returning.
func VerifyOperatorPanePeer ¶
func VerifyOperatorPanePeer(ctx context.Context, conn net.Conn, daemon *tuiosctl.Client, windowID string) error
VerifyOperatorPanePeer binds a private pane connection to the exact helper pane Golder created. A claimed pane ID or a token in argv is not sufficient: the kernel supplies the peer PID and the daemon resolves that PID's pane. An older or restricted daemon that cannot prove this fails closed.
Types ¶
type Application ¶ added in v1.5.62
Application is a locally discovered, opaque launch candidate. Its ID is valid only for the backend that discovered it; Detail is for disambiguation.
type ApplicationLauncher ¶ added in v1.5.62
type ApplicationLauncher interface {
Applications(context.Context, string) ([]Application, error)
LaunchApplication(context.Context, Application) error
}
ApplicationLauncher is an optional platform capability. Names are matched against local inventory, never interpreted as paths or shell commands.
type ApplicationResolution ¶ added in v1.5.62
type ApplicationResolution struct {
Targets []Target
Applications []Application
Matched bool
}
ApplicationResolution contains either matching windows, ambiguous installed applications, or other windows for an explicit operator choice.
func LaunchAndFindApplication ¶ added in v1.5.62
func LaunchAndFindApplication(ctx context.Context, backend PlatformBackend, app Application) (ApplicationResolution, error)
LaunchAndFindApplication waits for a window belonging to the exact launched application. It never substitutes a window from another application.
func ResolveApplication ¶ added in v1.5.62
func ResolveApplication(ctx context.Context, backend PlatformBackend, name string) (ApplicationResolution, error)
ResolveApplication first reuses matching visible windows. If none exist, it launches only an unambiguous locally discovered application. Multiple app or window candidates are returned for a person to disambiguate.
type Backend ¶
Backend is implemented by a platform-specific adapter. Validate must check the identity and conditions needed for the requested action immediately before execution. A successful capture does not imply safe input control. Backends must honor context cancellation and recheck it before injecting input; cancellation cannot undo an input already delivered to the OS.
type Capabilities ¶
type CaptureAvailability ¶
type CaptureAvailability interface {
CaptureAvailable() bool
}
CaptureAvailability lets a backend with an operator-confirmed source avoid advertising screenshots while its local selection has not been approved.
type CaptureBackend ¶
CaptureBackend returns only the selected target window in PNG format. The adapter must refuse a capture if it cannot reliably exclude other windows.
type Element ¶
type Element struct {
Ref string `json:"ref"`
Role string `json:"role"`
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
Enabled bool `json:"enabled"`
Editable bool `json:"editable,omitempty"`
Secure bool `json:"secure,omitempty"`
}
Element represents only bounded, non-sensitive accessibility data. Secure includes password controls and nodes whose safety cannot be established; backends must never populate their Name or Value.
type Frame ¶
Frame is ephemeral. It must not be put into ordinary logs or persisted as a session artifact without an explicit retention policy and user consent.
type FrameBoundBackend ¶
type FrameBoundBackend interface {
CaptureBackend
CaptureBound(context.Context, Target) ([]byte, string, error)
ClickFrame(context.Context, Target, string, float64, float64) error
}
FrameBoundBackend binds a capture to opaque platform geometry. ClickFrame must revalidate the target, geometry and sensitive controls immediately before dispatch. Global input additionally requires focus and occlusion checks; a target-scoped semantic action must verify subtree membership. A token alone is never authorization.
type FrameGeometry ¶
FrameGeometry binds a preview to the exact captured target and dimensions. A backend must separately verify target identity, focus and occlusion before injecting any resulting point; this calculation alone is not authorization.
type FrameKeyAvailability ¶
FrameKeyAvailability narrows the keys a backend can safely implement.
type FrameKeyBackend ¶
type FrameKeyBackend interface {
FrameBoundBackend
PressFrame(context.Context, Target, string, string) error
}
FrameKeyBackend and FrameScrollBackend may be offered independently. Both must apply the same target, frame and dispatch checks as FrameBoundBackend.
type FrameScrollBackend ¶
type KittyRenderer ¶
type KittyRenderer struct {
// contains filtered or unexported fields
}
KittyRenderer draws ephemeral computer-use frames in a terminal pane that has already positively detected Kitty graphics support. It does not own the terminal, select targets, grant control, or forward input to a desktop.
func NewKittyRenderer ¶
func (*KittyRenderer) Clear ¶
func (r *KittyRenderer) Clear() error
Clear removes the current frame without closing the renderer, so a paused session never leaves its last captured image displayed in the pane.
func (*KittyRenderer) Close ¶
func (r *KittyRenderer) Close() error
Close removes only this pane's image. It is safe to call repeatedly.
type OperatorPreview ¶
type OperatorPreviewBackend ¶
type OperatorPreviewBackend interface {
PrepareOperatorPreview(context.Context, Target) (OperatorPreview, error)
ConfirmOperatorPreview(context.Context, Target, string) error
}
OperatorPreviewBackend supports a second, operator-only source selection. The candidate is never exposed through the model-facing Session before the person explicitly confirms that it matches the already selected target.
type OperatorPreviewDiscarder ¶
type OperatorPreviewDiscarder interface {
DiscardOperatorPreview(context.Context, Target, string) error
}
OperatorPreviewDiscarder permits an explicit semantic-only fallback.
type Pane ¶
type Pane struct {
// contains filtered or unexported fields
}
Pane is the state and rendering logic for a dedicated, operator-controlled terminal pane. The caller owns its PTY and must authenticate input as coming from the operator; this type must not be exposed as a model-callable socket.
func (*Pane) Close ¶
Close removes the frame and pauses control if the pane goes away. Closing a view must never leave an unseen desktop control session running.
func (*Pane) OperatorCommand ¶
OperatorCommand handles only local, person-originated input. It never accepts a window identity or a model request, and resume is operator-only.
type PaneClient ¶
type PaneClient struct {
// contains filtered or unexported fields
}
PaneClient is used by the dedicated operator pane, never by the model. Its bounded protocol transfers frames only in memory and never writes them to a screenshot file or the conversation transcript.
func NewPaneClient ¶
func NewPaneClient(conn net.Conn) *PaneClient
func (*PaneClient) Close ¶
func (c *PaneClient) Close() error
func (*PaneClient) Request ¶
func (c *PaneClient) Request(ctx context.Context, request PaneRequest) (PaneResponse, error)
type PaneHandle ¶
type PaneHandle struct {
// contains filtered or unexported fields
}
PaneHandle owns the helper pane and its private connections. Closing it revokes the target immediately, including when the model is still running.
func LaunchOperatorPane ¶
LaunchOperatorPane opens a helper next to this exact agent pane. The target must already have been resolved and started by the frontend. Separate sockets let pause/stop interrupt a slow capture or action rather than queue behind it. A failure to prove all peers as the same process in the new pane fails closed; no model-facing endpoint is created.
func (*PaneHandle) Close ¶
func (h *PaneHandle) Close()
func (*PaneHandle) Done ¶
func (h *PaneHandle) Done() <-chan struct{}
func (*PaneHandle) WindowID ¶
func (h *PaneHandle) WindowID() string
type PaneRequest ¶
type PaneRequest struct {
Action string `json:"action"`
Ref string `json:"ref,omitempty"`
Text string `json:"text,omitempty"`
Sequence uint64 `json:"sequence,omitempty"`
}
PaneRequest is private to a Golder-owned, kernel-verified operator pane. It intentionally has no target selector, shell, arbitrary OS handles or files.
type PaneResponse ¶
type PermissionState ¶
PermissionState is a non-prompting view of platform permission status. It cannot grant Golder authority to observe or control any particular target.
func ProbePermissions ¶
func ProbePermissions() PermissionState
ProbePermissions deliberately does not imply that a system permission or desktop session exists on platforms without a supported probe yet.
type PlatformBackend ¶
PlatformBackend exposes local window inventory and target validation. The inventory is used by frontend resolution and is not a model-facing tool.
func NewPlatformBackend ¶
func NewPlatformBackend() (PlatformBackend, error)
NewPlatformBackend uses the desktop's existing AT-SPI service. A desktop without AT-SPI fails closed rather than selecting an unrelated window.
type SemanticBackend ¶
type SemanticBackend interface {
SupportsAction(string) bool
Act(context.Context, Target, string, string, string, string) error
}
SemanticBackend may act only on the backend snapshot and ref passed here; it must reject stale nodes and revalidate the target immediately before an OS action. It must not treat an arbitrary model ref as a system handle.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session serializes lifecycle transitions with target validation and backend operations. Only the operator-facing host may call Start or Resume.
func (*Session) Act ¶
Act executes a supported semantic action only against a current observed ref. The lease is consumed even on failure so callers must observe again.
func (*Session) ClickFrame ¶
ClickFrame consumes a recent, single-use frame lease. Coordinates are pixels in that frame, never global screen coordinates or a system handle.
func (*Session) Do ¶
func (s *Session) Do(ctx context.Context, control bool, operation func(context.Context, Backend, Target) error) error
Do serializes one authorized backend operation and pauses if the platform cannot validate the pinned target. Callers must not invoke backend input by bypassing this method.
func (*Session) InstallOperatorPreview ¶
func (s *Session) InstallOperatorPreview(preview OperatorPreview) error
InstallOperatorPreview is called by the local host before it exposes the session to an agent. A pending preview blocks every model-facing operation.
func (*Session) Observe ¶
Observe validates the authorized target and binds the returned refs to a fresh, unpredictable session-owned snapshot identity.
func (*Session) PressFrame ¶
PressFrame permits only a small set of non-modifier keys. The platform must also prove the focused control belongs to the target and is not sensitive.
func (*Session) Resume ¶
Resume must only be called from an explicit operator action. It revalidates the original target and never changes the scope of the original grant.
func (*Session) ScrollFrame ¶
ScrollFrame applies a bounded number of lines at an authorized frame point.
func (*Session) Start ¶
Start installs a locally resolved target and capabilities. Starting a second target requires stopping the old session and resolving the new target.
func (*Session) Stop ¶
func (s *Session) Stop()
Stop revokes the current authorization. It does not close the backend, so a later operator selection can create a new session.
func (*Session) SupportsCapture ¶
func (*Session) SupportsCoordinates ¶
SupportsCoordinates is true only when the backend can bind and revalidate a captured frame through its native input safety checks.
func (*Session) SupportsFrameAction ¶
func (*Session) SupportsFrameKey ¶
func (*Session) SupportsSemantic ¶
func (*Session) SupportsSnapshot ¶
type Snapshot ¶
type Snapshot struct {
ID string `json:"id"`
Elements []Element `json:"elements"`
Truncated bool `json:"truncated,omitempty"`
}
func BoundedSnapshot ¶
BoundedSnapshot sanitizes platform-provided content before it can be sent to a model. Ref generation and identity resolution remain backend/session owned.
type SnapshotBackend ¶
type SnapshotBackend interface {
Snapshot(context.Context, Target) (string, []Element, bool, error)
}
SnapshotBackend is an optional semantic observation capability. Backends must keep refs scoped to the current target and snapshot.
type Status ¶
type Status struct {
Active bool
Paused bool
PendingPreview bool
Target Target
Capabilities Capabilities
}
type Target ¶
type Target struct {
ID string
Application string
ApplicationID string // platform identity, never a model-supplied selector
Window string
Detail string // operator-facing disambiguation; never a model selector
}
Target is an opaque identity returned by a platform backend. The local host resolves or confirms it; model-supplied process identifiers never select it.
Source Files
¶
- application.go
- atspi_linux.go
- capture.go
- coordinates.go
- escape_linux.go
- key_linux.go
- kitty.go
- match.go
- observation.go
- operator_preview.go
- pane.go
- pane_input.go
- pane_launch.go
- pane_peer.go
- pane_peer_linux.go
- pane_peer_proc.go
- pane_probe.go
- pane_probe_unix.go
- pane_protocol.go
- pane_verify_unix.go
- pane_viewer.go
- permissions.go
- permissions_other.go
- platform.go
- platform_linux.go
- point_linux.go
- portal_backend_linux.go
- portal_linux.go
- scroll_linux.go
- semantic.go
- session.go
- x11_backend_linux.go
- x11_core_event.go
- x11_linux.go