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
- func DesktopToolHelper(ctx context.Context, args []string, out io.Writer) error
- func FallbackInstructions() string
- func PermissionSettings(harness string, existing json.RawMessage) (json.RawMessage, error)
- type Action
- type ActionRequest
- type Actor
- type Approval
- type Binding
- type Capabilities
- type Capture
- type ControlRequest
- type Controller
- type CreateDesktopRequest
- type Credentials
- type Cursor
- type DesktopCatalog
- type DesktopResolution
- type DesktopResult
- type DesktopSessionCapabilities
- type DesktopSetup
- type Error
- type Geometry
- type LocalDesktopInfo
- type LocalDesktopSettings
- type MacDesktop
- func (p *MacDesktop) Apply(ctx context.Context, action Action) (string, error)
- func (p *MacDesktop) Capture(ctx context.Context) (image.Image, Geometry, error)
- func (p *MacDesktop) Close() error
- func (p *MacDesktop) Connect(ctx context.Context) (Geometry, error)
- func (p *MacDesktop) ExpiresAt() time.Time
- func (p *MacDesktop) Info(ctx context.Context) LocalDesktopInfo
- func (p *MacDesktop) InputGeometry(ctx context.Context, action Action) (Geometry, error)
- func (p *MacDesktop) PrepareControl(ctx context.Context) error
- func (p *MacDesktop) Release(ctx context.Context) error
- func (p *MacDesktop) SetCursorObserver(fn func(*Cursor))
- func (p *MacDesktop) Status(ctx context.Context) (ProviderStatus, error)
- type Oblien
- func (p *Oblien) Apply(ctx context.Context, a Action) (string, error)
- func (p *Oblien) Capture(ctx context.Context) (image.Image, Geometry, error)
- func (p *Oblien) Close() error
- func (p *Oblien) Connect(ctx context.Context) (Geometry, error)
- func (p *Oblien) ExpiresAt() time.Time
- func (p *Oblien) InputGeometry(ctx context.Context, action Action) (Geometry, error)
- func (p *Oblien) Release(ctx context.Context) error
- func (p *Oblien) SetCursorObserver(fn func(*Cursor))
- func (p *Oblien) Status(ctx context.Context) (ProviderStatus, error)
- type OpenRequest
- type Provider
- type ProviderStatus
- type Receipt
- type RuntimeBinding
- type SSHConnection
- type SSHSettings
- type SavedDesktop
- type Service
- func (s *Service) ActiveSessionCount() int
- func (s *Service) Apply(ctx context.Context, actor Actor, req ActionRequest) (Receipt, error)
- func (s *Service) Artifacts() *artifact.Store
- func (s *Service) AuthorizeViewer(sessionID string) error
- func (s *Service) Bind(binding Binding, credentials Credentials) error
- func (s *Service) BindRun(ctx context.Context, actor Actor, harness string, existing json.RawMessage) (json.RawMessage, map[string]string, func(), error)
- func (s *Service) BindRuntime(binding RuntimeBinding, credentials Credentials) error
- func (s *Service) Capture(ctx context.Context, sessionID string, actor Actor) (Capture, error)
- func (s *Service) Changes() <-chan struct{}
- func (s *Service) Close()
- func (s *Service) CloseRun(runID string)
- func (s *Service) CloseSession(id string, actor Actor) error
- func (s *Service) Configure(p Provider) error
- func (s *Service) ConfigureLocalDesktop(ctx context.Context, settings LocalDesktopSettings, credentials Credentials) (Snapshot, error)
- func (s *Service) Control(ctx context.Context, id string, actor Actor, req ControlRequest) (Session, error)
- func (s *Service) CreateDesktop(ctx context.Context, req CreateDesktopRequest) (SavedDesktop, error)
- func (s *Service) DesktopOperation(ctx context.Context, id, operation string, update *UpdateDesktopRequest) (DesktopResult, error)
- func (s *Service) EnableLocalDesktop(credentials Credentials) error
- func (s *Service) EnsureProjectDesktop(ctx context.Context, projectID string) (SavedDesktop, error)
- func (s *Service) ForDesktop(id string) (*Service, error)
- func (s *Service) HasDesktopCatalog() bool
- func (s *Service) ListDesktops(ctx context.Context, projectID string) (DesktopCatalog, error)
- func (s *Service) LocalDesktopInfo(ctx context.Context) (LocalDesktopInfo, error)
- func (s *Service) Open(ctx context.Context, actor Actor, req OpenRequest) (Session, error)
- func (s *Service) Receipt(id string) (Receipt, error)
- func (s *Service) Refresh(ctx context.Context) (Snapshot, error)
- func (s *Service) ServeViewer(ctx context.Context, id string, viewer io.ReadWriteCloser) error
- func (s *Service) SetApproval(fn Approval)
- func (s *Service) Snapshot() Snapshot
- type Session
- type Snapshot
- type UpdateDesktopRequest
- type VNCSettings
Constants ¶
const DesktopID = "desktop"
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.
const LocalDesktopVersion = 1
const MCPName = "mindwire_desktop"
const MaxTextBytes = 1 << 20
const Version = 2
Variables ¶
This section is empty.
Functions ¶
func DesktopToolHelper ¶
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 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 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 ControlRequest ¶
type Controller ¶
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 ¶
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 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 Error ¶
func ErrorResponse ¶
ErrorResponse is shared by HTTP and the embedded SDK.
type LocalDesktopInfo ¶
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) Close ¶
func (p *MacDesktop) Close() error
func (*MacDesktop) ExpiresAt ¶
func (p *MacDesktop) ExpiresAt() time.Time
func (*MacDesktop) Info ¶
func (p *MacDesktop) Info(ctx context.Context) LocalDesktopInfo
func (*MacDesktop) InputGeometry ¶
func (*MacDesktop) PrepareControl ¶
func (p *MacDesktop) PrepareControl(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 (*Oblien) InputGeometry ¶
func (*Oblien) SetCursorObserver ¶
The input connection is authoritative: TigerVNC can suppress cursor images on a separate video-only connection after the controller moves the pointer.
type OpenRequest ¶
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 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 NewConfigured ¶
func NewConfigured(db *registry.Store, credentials Credentials) (*Service, error)
func (*Service) ActiveSessionCount ¶
func (*Service) AuthorizeViewer ¶
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) 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) ConfigureLocalDesktop ¶
func (s *Service) ConfigureLocalDesktop(ctx context.Context, settings LocalDesktopSettings, credentials Credentials) (Snapshot, 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 ¶
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 ¶
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 (*Service) ListDesktops ¶
func (*Service) LocalDesktopInfo ¶
func (s *Service) LocalDesktopInfo(ctx context.Context) (LocalDesktopInfo, error)
func (*Service) ServeViewer ¶
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 ¶
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"`
}