surface

package
v0.1.55 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 41 Imported by: 0 modules, 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 surface is the workspace's shared desktop control service. HTTP clients and harness MCP tools use the same sessions, controller and input executor.

Index

Constants

View Source
const DesktopID = "desktop"
View Source
const DesktopPort = 8794

DesktopPort is virtual: the paired SSH server handles it without opening a TCP listener. A device-bound grant and a live human view session are required.

View Source
const LocalDesktopVersion = 1
View Source
const MCPName = "mindwire_desktop"
View Source
const MaxTextBytes = 1 << 20
View Source
const Version = 2

Variables

This section is empty.

Functions

func DesktopToolHelper

func DesktopToolHelper(ctx context.Context, args []string, out io.Writer) error

DesktopToolHelper bridges command-only harnesses to the same run-scoped MCP tools. Provider tokens and the daemon owner credential never enter this path.

func FallbackInstructions

func FallbackInstructions() string

Shell-capable harnesses without per-turn MCP support use the same MCP service through the daemon helper. Nothing is written into their global config.

func PermissionSettings

func PermissionSettings(harness string, existing json.RawMessage) (json.RawMessage, error)

PermissionSettings allows only these service-owned tools to reach the desktop permission gate. Existing Claude settings and explicit deny rules are retained. No shell, file, or third-party MCP permission is changed.

Types

type Action

type Action struct {
	Kind     string   `json:"kind" jsonschema:"pointer, click, drag, scroll, key, text, clipboard_read, clipboard_write, release"`
	X        *int     `json:"x,omitempty"`
	Y        *int     `json:"y,omitempty"`
	ToX      *int     `json:"toX,omitempty"`
	ToY      *int     `json:"toY,omitempty"`
	Buttons  int      `json:"buttons,omitempty"`
	Button   string   `json:"button,omitempty"`
	Count    int      `json:"count,omitempty"`
	DeltaX   int      `json:"deltaX,omitempty"`
	DeltaY   int      `json:"deltaY,omitempty"`
	Keys     []string `json:"keys,omitempty"`
	Text     string   `json:"text,omitempty"`
	TextMode string   `` /* 163-byte string literal not displayed */
}

type ActionRequest

type ActionRequest struct {
	RequestID         string `json:"requestId"`
	SessionID         string `json:"sessionId"`
	ControlGeneration int64  `json:"controlGeneration"`
	FrameID           string `json:"frameId,omitempty"`
	GeometryRevision  int64  `json:"geometryRevision,omitempty"`
	Action            Action `json:"action"`
}

type Actor

type Actor struct {
	Kind      string
	Name      string
	RunID     string
	ChatID    string
	ProjectID string
	CWD       string
	// contains filtered or unexported fields
}

Actor comes from authentication, not tool arguments.

type Approval

type Approval func(context.Context, Actor, string) error

type Binding

type Binding struct {
	RegistryID       string        `json:"registryId"`
	WorkspaceID      string        `json:"workspaceId"`
	GatewayToken     string        `json:"gatewayToken,omitempty"`
	Connection       SSHConnection `json:"connection"`
	DesktopID        string        `json:"desktopId,omitempty"`
	RuntimeExpiresAt time.Time     `json:"runtimeExpiresAt,omitempty"`
}

Binding is write-only. Its SSH grant is desktop-only, expires at the provider's deadline, and must match the workspace for which it was issued.

type Capabilities

type Capabilities struct {
	View           bool `json:"view"`
	Capture        bool `json:"capture"`
	Pointer        bool `json:"pointer"`
	Keyboard       bool `json:"keyboard"`
	Text           bool `json:"text"`
	ClipboardRead  bool `json:"clipboardRead"`
	ClipboardWrite bool `json:"clipboardWrite"`
	KeyboardText   bool `json:"keyboardText"`
	ExtendedKeys   bool `json:"extendedKeys"`
}

type Capture

type Capture struct {
	ID         string    `json:"id"`
	SurfaceID  string    `json:"surfaceId"`
	ArtifactID string    `json:"artifactId"`
	Mime       string    `json:"mime"`
	Geometry   Geometry  `json:"geometry"`
	CreatedAt  time.Time `json:"createdAt"`
}

type ControlRequest

type ControlRequest struct {
	Action     string `json:"action"`
	Generation int64  `json:"generation,omitempty"`
}

type Controller

type Controller struct {
	SessionID  string    `json:"sessionId"`
	Actor      string    `json:"actor"`
	Name       string    `json:"name"`
	RunID      string    `json:"runId,omitempty"`
	ChatID     string    `json:"chatId,omitempty"`
	Generation int64     `json:"generation"`
	ExpiresAt  time.Time `json:"expiresAt"`
}

type CreateDesktopRequest

type CreateDesktopRequest struct {
	RequestID  string             `json:"requestId"`
	ProjectID  string             `json:"projectId,omitempty"`
	Name       string             `json:"name"`
	Resolution *DesktopResolution `json:"resolution,omitempty"`
}

type Credentials

type Credentials interface {
	Get(string) string
	Set(string, string) error
}

Credentials is the daemon's existing private credential store, never registry metadata.

type Cursor

type Cursor struct {
	ID       string `json:"id"`
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	HotspotX int    `json:"hotspotX"`
	HotspotY int    `json:"hotspotY"`
	PNG      string `json:"png"`
}

Cursor is a small, immutable remote cursor image, not a screenshot. Its ID changes only when the pixels or hotspot change; moving it sends no new image.

type DesktopCatalog

type DesktopCatalog struct {
	Success      bool                       `json:"success"`
	Sessions     []SavedDesktop             `json:"sessions"`
	Capabilities DesktopSessionCapabilities `json:"capabilities"`
	ProjectID    string                     `json:"projectId,omitempty"`
}

type DesktopResolution

type DesktopResolution struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

type DesktopResult

type DesktopResult struct {
	Success bool         `json:"success"`
	Session SavedDesktop `json:"session"`
}

type DesktopSessionCapabilities

type DesktopSessionCapabilities struct {
	Mode        string `json:"mode"`
	MaxSessions int    `json:"max_sessions"`
	CanCreate   bool   `json:"can_create"`
	Resolution  *struct {
		Min     DesktopResolution `json:"min"`
		Max     DesktopResolution `json:"max"`
		Default DesktopResolution `json:"default"`
	} `json:"resolution,omitempty"`
}

type DesktopSetup

type DesktopSetup struct {
	Reason  string `json:"reason"`
	Command string `json:"command"`
}

type Error

type Error struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

func ErrorResponse

func ErrorResponse(err error) (*Error, int)

ErrorResponse is shared by HTTP and the embedded SDK.

func (*Error) Error

func (e *Error) Error() string

type Geometry

type Geometry struct {
	Width    int   `json:"width"`
	Height   int   `json:"height"`
	Revision int64 `json:"revision"`
}

type LocalDesktopInfo

type LocalDesktopInfo struct {
	Supported     bool   `json:"supported"`
	Enabled       bool   `json:"enabled"`
	ScreenSharing bool   `json:"screenSharing"`
	Username      string `json:"username"`
}

type LocalDesktopSettings

type LocalDesktopSettings struct {
	Enabled  bool   `json:"enabled"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

Write-only configuration. It lives in the existing private credential store, never in workspace metadata, SDK status responses, or pairing invitations.

type MacDesktop

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

func (*MacDesktop) Apply

func (p *MacDesktop) Apply(ctx context.Context, action Action) (string, error)

func (*MacDesktop) Capture

func (p *MacDesktop) Capture(ctx context.Context) (image.Image, Geometry, error)

func (*MacDesktop) Close

func (p *MacDesktop) Close() error

func (*MacDesktop) Connect

func (p *MacDesktop) Connect(ctx context.Context) (Geometry, error)

func (*MacDesktop) ExpiresAt

func (p *MacDesktop) ExpiresAt() time.Time

func (*MacDesktop) Info

func (*MacDesktop) InputGeometry

func (p *MacDesktop) InputGeometry(ctx context.Context, action Action) (Geometry, error)

func (*MacDesktop) PrepareControl

func (p *MacDesktop) PrepareControl(ctx context.Context) error

func (*MacDesktop) Release

func (p *MacDesktop) Release(ctx context.Context) error

func (*MacDesktop) SetCursorObserver

func (p *MacDesktop) SetCursorObserver(fn func(*Cursor))

func (*MacDesktop) Status

func (p *MacDesktop) Status(ctx context.Context) (ProviderStatus, error)

type Oblien

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

func NewOblien

func NewOblien(binding Binding) (*Oblien, error)

func (*Oblien) Apply

func (p *Oblien) Apply(ctx context.Context, a Action) (string, error)

func (*Oblien) Capture

func (p *Oblien) Capture(ctx context.Context) (image.Image, Geometry, error)

func (*Oblien) Close

func (p *Oblien) Close() error

func (*Oblien) Connect

func (p *Oblien) Connect(ctx context.Context) (Geometry, error)

func (*Oblien) ExpiresAt

func (p *Oblien) ExpiresAt() time.Time

func (*Oblien) InputGeometry

func (p *Oblien) InputGeometry(ctx context.Context, action Action) (Geometry, error)

func (*Oblien) Release

func (p *Oblien) Release(ctx context.Context) error

func (*Oblien) SetCursorObserver

func (p *Oblien) SetCursorObserver(fn func(*Cursor))

The input connection is authoritative: TigerVNC can suppress cursor images on a separate video-only connection after the controller moves the pointer.

func (*Oblien) Status

func (p *Oblien) Status(ctx context.Context) (ProviderStatus, error)

type OpenRequest

type OpenRequest struct {
	DesktopID string `json:"desktopId,omitempty" jsonschema:"Saved provider desktop ID. Omit to use this project's desktop."`
	RequestID string `json:"requestId"`
	Name      string `json:"name,omitempty"`
	Mode      string `json:"mode"`
}

type Provider

type Provider interface {
	Status(context.Context) (ProviderStatus, error)
	Connect(context.Context) (Geometry, error)
	Capture(context.Context) (image.Image, Geometry, error)
	Apply(context.Context, Action) (string, error)
	Release(context.Context) error
	Close() error
	ExpiresAt() time.Time
}

type ProviderStatus

type ProviderStatus struct {
	Supported    bool          `json:"supported"`
	Enabled      bool          `json:"enabled"`
	Available    bool          `json:"available"`
	Credentials  bool          `json:"credentials"`
	OS           string        `json:"os,omitempty"`
	Capabilities Capabilities  `json:"capabilities"`
	Setup        *DesktopSetup `json:"setup,omitempty"`
}

type Receipt

type Receipt struct {
	ID        string    `json:"id"`
	SessionID string    `json:"sessionId"`
	SurfaceID string    `json:"surfaceId"`
	Kind      string    `json:"kind"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"createdAt"`
	Error     *Error    `json:"error,omitempty"`
	// Text is transient clipboard output; it is omitted from persisted receipts.
	Text string `json:"text,omitempty"`
}

type RuntimeBinding

type RuntimeBinding struct {
	RegistryID   string    `json:"registryId"`
	WorkspaceID  string    `json:"workspaceId"`
	GatewayToken string    `json:"gatewayToken"`
	ExpiresAt    time.Time `json:"expiresAt,omitempty"`
}

RuntimeBinding is write-only and workspace-scoped. No account credential is stored in the daemon. It enables tools even before a human opens the viewer.

type SSHConnection

type SSHConnection struct {
	SessionID string      `json:"session_id,omitempty"`
	ExpiresAt time.Time   `json:"expires_at"`
	SSH       SSHSettings `json:"ssh"`
	VNC       VNCSettings `json:"vnc"`
}

type SSHSettings

type SSHSettings struct {
	Host               string `json:"host"`
	Port               int    `json:"port"`
	Username           string `json:"username"`
	Password           string `json:"password"`
	HostKeyFingerprint string `json:"host_key_fingerprint"`
}

type SavedDesktop

type SavedDesktop struct {
	ID              string             `json:"id"`
	Name            string             `json:"name"`
	Resolution      *DesktopResolution `json:"resolution,omitempty"`
	State           string             `json:"state"`
	Managed         bool               `json:"managed"`
	Available       bool               `json:"available"`
	CanResize       *bool              `json:"can_resize,omitempty"`
	CanDelete       *bool              `json:"can_delete,omitempty"`
	DeletionPending *bool              `json:"deletion_pending,omitempty"`
	Mode            string             `json:"mode,omitempty"`
	CreatedAt       string             `json:"created_at,omitempty"`
	UpdatedAt       string             `json:"updated_at,omitempty"`
	Error           string             `json:"error,omitempty"`
}

type Service

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

func New

func New(db *registry.Store) (*Service, error)

func NewConfigured

func NewConfigured(db *registry.Store, credentials Credentials) (*Service, error)

func (*Service) ActiveSessionCount

func (s *Service) ActiveSessionCount() int

func (*Service) Apply

func (s *Service) Apply(ctx context.Context, actor Actor, req ActionRequest) (Receipt, error)

func (*Service) Artifacts

func (s *Service) Artifacts() *artifact.Store

func (*Service) AuthorizeViewer

func (s *Service) AuthorizeViewer(sessionID string) error

AuthorizeViewer is used for the existing paired SSH forward grant. A raw display cannot outlive its human session or enable desktop access implicitly.

func (*Service) Bind

func (s *Service) Bind(binding Binding, credentials Credentials) error

func (*Service) BindRun

func (s *Service) BindRun(ctx context.Context, actor Actor, harness string, existing json.RawMessage) (json.RawMessage, map[string]string, func(), error)

BindRun returns a per-turn, harness-native MCP overlay and private environment. Existing MCP servers are preserved; the built-in name cannot be shadowed.

func (*Service) BindRuntime

func (s *Service) BindRuntime(binding RuntimeBinding, credentials Credentials) error

func (*Service) Capture

func (s *Service) Capture(ctx context.Context, sessionID string, actor Actor) (Capture, error)

func (*Service) Changes

func (s *Service) Changes() <-chan struct{}

func (*Service) Close

func (s *Service) Close()

func (*Service) CloseRun

func (s *Service) CloseRun(runID string)

func (*Service) CloseSession

func (s *Service) CloseSession(id string, actor Actor) error

func (*Service) Configure

func (s *Service) Configure(p Provider) error

func (*Service) ConfigureLocalDesktop

func (s *Service) ConfigureLocalDesktop(ctx context.Context, settings LocalDesktopSettings, credentials Credentials) (Snapshot, error)

func (*Service) Control

func (s *Service) Control(ctx context.Context, id string, actor Actor, req ControlRequest) (Session, error)

func (*Service) CreateDesktop

func (s *Service) CreateDesktop(ctx context.Context, req CreateDesktopRequest) (SavedDesktop, error)

func (*Service) DesktopOperation

func (s *Service) DesktopOperation(ctx context.Context, id, operation string, update *UpdateDesktopRequest) (DesktopResult, error)

func (*Service) EnableLocalDesktop

func (s *Service) EnableLocalDesktop(credentials Credentials) error

EnableLocalDesktop exposes only capability/setup status. It never turns on Screen Sharing or opts an owner into desktop access.

func (*Service) EnsureProjectDesktop

func (s *Service) EnsureProjectDesktop(ctx context.Context, projectID string) (SavedDesktop, error)

EnsureProjectDesktop is atomic across callers and durable across a daemon restart. An uncertain create always reuses its saved request and provider key.

func (*Service) ForDesktop

func (s *Service) ForDesktop(id string) (*Service, error)

ForDesktop selects a physical display. A Mindwire control session is a different ID, and can never be used to select or change the physical display.

func (*Service) HasDesktopCatalog

func (s *Service) HasDesktopCatalog() bool

func (*Service) ListDesktops

func (s *Service) ListDesktops(ctx context.Context, projectID string) (DesktopCatalog, error)

func (*Service) LocalDesktopInfo

func (s *Service) LocalDesktopInfo(ctx context.Context) (LocalDesktopInfo, error)

func (*Service) Open

func (s *Service) Open(ctx context.Context, actor Actor, req OpenRequest) (Session, error)

func (*Service) Receipt

func (s *Service) Receipt(id string) (Receipt, error)

func (*Service) Refresh

func (s *Service) Refresh(ctx context.Context) (Snapshot, error)

func (*Service) ServeViewer

func (s *Service) ServeViewer(ctx context.Context, id string, viewer io.ReadWriteCloser) error

ServeViewer forwards compressed RFB frames without decoding/re-encoding them. The Mac login terminates here. The phone sees None auth only inside its pinned, device-authorized SSH channel. Input messages cannot bypass Service.Apply.

func (*Service) SetApproval

func (s *Service) SetApproval(fn Approval)

func (*Service) Snapshot

func (s *Service) Snapshot() Snapshot

type Session

type Session struct {
	ID         string      `json:"id"`
	SurfaceID  string      `json:"surfaceId"`
	DesktopID  string      `json:"desktopId,omitempty"`
	Actor      string      `json:"actor"`
	Name       string      `json:"name"`
	ChatID     string      `json:"chatId,omitempty"`
	RunID      string      `json:"runId,omitempty"`
	Mode       string      `json:"mode"`
	CreatedAt  time.Time   `json:"createdAt"`
	Controller *Controller `json:"controller,omitempty"`
}

type Snapshot

type Snapshot struct {
	ID          string     `json:"id"`
	DesktopID   string     `json:"desktopId,omitempty"`
	WorkspaceID string     `json:"workspaceId"`
	Kind        string     `json:"kind"`
	Provider    string     `json:"provider"`
	Version     int        `json:"version"`
	Revision    int64      `json:"revision"`
	InstanceID  string     `json:"instanceId"`
	State       string     `json:"state"`
	ObservedAt  *time.Time `json:"observedAt,omitempty"`
	ProviderStatus
	Geometry               *Geometry   `json:"geometry,omitempty"`
	Cursor                 *Cursor     `json:"cursor,omitempty"`
	Controller             *Controller `json:"controller,omitempty"`
	AuthorizationExpiresAt *time.Time  `json:"authorizationExpiresAt,omitempty"`
	Error                  *Error      `json:"error,omitempty"`
}

type UpdateDesktopRequest

type UpdateDesktopRequest struct {
	Name       *string            `json:"name,omitempty"`
	Resolution *DesktopResolution `json:"resolution,omitempty"`
}

type VNCSettings

type VNCSettings struct {
	Host           string `json:"host"`
	Port           int    `json:"port"`
	Authentication string `json:"authentication"`
}

Jump to

Keyboard shortcuts

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