Documentation
¶
Overview ¶
Package computersetup owns the interactive "open a desktop application for Computer Use" flow that the TUI and the GUI must share: resolve a requested application, choose one window, take the grant, and start the session.
The package holds no rendering and no terminal/UI dependency. Frontends render View/Plan and call these methods from their own goroutine or message loop, so the decision about which application and window to use can only be made here.
Index ¶
- Variables
- type Grant
- type Options
- type Setup
- func (s *Setup) AutoGrant() Grant
- func (s *Setup) ChooseApplication(ctx context.Context, index int) error
- func (s *Setup) Close()
- func (s *Setup) HasPreviewGate() bool
- func (s *Setup) Plan() computeruse.SetupPlan
- func (s *Setup) PreparePreview(ctx context.Context) (computeruse.Target, computeruse.OperatorPreview, error)
- func (s *Setup) ReadOnly() bool
- func (s *Setup) Resolve(ctx context.Context) error
- func (s *Setup) Select(index int) bool
- func (s *Setup) SessionID() string
- func (s *Setup) Start(ctx context.Context, grant Grant) (*computeruse.Session, error)
- func (s *Setup) StartConfirmed(ctx context.Context, grant Grant, candidateID string) (*computeruse.Session, error)
- func (s *Setup) Suggested() string
- func (s *Setup) Target() (computeruse.Target, bool)
- func (s *Setup) View() View
- type View
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosed reports a setup that was already dismissed by the frontend. ErrClosed = errors.New("computer setup is no longer current") // ErrResolved reports a second resolution of the same setup. ErrResolved = errors.New("computer setup was already resolved") // ErrNoTarget reports a start without a selected window. ErrNoTarget = errors.New("no desktop window is selected") // ErrReadOnly reports a control grant while the conversation is read-only. ErrReadOnly = errors.New("computer control is unavailable in read-only mode") )
Functions ¶
This section is empty.
Types ¶
type Grant ¶
type Grant struct {
Control bool
// SemanticOnly skips the operator preview whose confirmation proves a
// system-selected capture source. Backends without a preview gate ignore it.
SemanticOnly bool
// SkipPreview skips only the confirmation step, keeping capture and control.
// Used when the person explicitly chose the window on macOS.
SkipPreview bool
}
Grant is the authority a frontend asks for.
type Options ¶
type Options struct {
SessionID string
Suggested string
ReadOnly bool
// Guard revalidates the frontend's live authorization immediately before an
// asynchronous application launch. It must not select a window.
Guard func() error
// Backend overrides the platform backend. Tests use it; production leaves
// it nil so every setup gets a fresh catalog.
Backend func() (computeruse.PlatformBackend, error)
}
Options describe one setup. Suggested is the application name the model requested; it is empty for a manually opened picker.
type Setup ¶
type Setup struct {
// contains filtered or unexported fields
}
Setup is one application/window selection. Backends are owned here until a session takes them, and it is safe to call Close from any goroutine.
func New ¶
New prepares an unresolved setup. Selected starts at -1 so a frontend can rely on "no window chosen yet" before Resolve runs.
func (*Setup) AutoGrant ¶
AutoGrant is the authority a requested application receives after a unique match: control, with the operator preview skipped only when the backend requires that confirmation for a system-selected source.
func (*Setup) ChooseApplication ¶
ChooseApplication launches one installed candidate and adopts its windows.
func (*Setup) Close ¶
func (s *Setup) Close()
Close releases the catalog if no session took it. Sessions are stopped by the frontend that owns them.
func (*Setup) HasPreviewGate ¶
HasPreviewGate reports whether the backend asks for a system-selected capture source that a person must confirm.
func (*Setup) Plan ¶
func (s *Setup) Plan() computeruse.SetupPlan
Plan is the shared decision every frontend renders: installed applications first, then no match, then a unique requested window, then the window picker.
func (*Setup) PreparePreview ¶
func (s *Setup) PreparePreview(ctx context.Context) (computeruse.Target, computeruse.OperatorPreview, error)
PreparePreview asks the backend for an operator-only preview of the selected window. It never starts a session.
func (*Setup) Resolve ¶
Resolve discovers or launches the requested application. It must run once; repeating it would let a conversation retarget itself after granting access.
func (*Setup) Select ¶
Select records an explicit window choice. It refuses ambiguous or stale indexes so a frontend cannot start a window the person did not see.
func (*Setup) Start ¶
Start begins the selected window with the requested grant. It prepares and installs the operator preview unless the grant is semantic-only, and returns the active session; the backend then belongs to that session.
func (*Setup) StartConfirmed ¶
func (s *Setup) StartConfirmed(ctx context.Context, grant Grant, candidateID string) (*computeruse.Session, error)
StartConfirmed is Start for a frontend that already showed the preview to the person and collected an explicit confirmation of the same window.
type View ¶
type View struct {
Targets []computeruse.Target
Applications []computeruse.Application
Matched bool
NotFound bool
Selected int
Suggested string
PreviewGate bool
}
View is the resolution state a frontend renders.