49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package app
|
|
|
|
import "sync"
|
|
|
|
// HostAPIService owns the state and RPC handlers for all host-side plugin
|
|
// capabilities: computer-use VM control & held inputs, secret materialization,
|
|
// host downloads, plugin elevation prompts, and panel file grants.
|
|
// Keeping this state off *App isolates lock domains and keeps *App focused on
|
|
// Wails IPC bindings and desktop lifecycle coordination.
|
|
type HostAPIService struct {
|
|
app *App
|
|
|
|
// Plugin panel file grants (plugin_bridge_files.go).
|
|
filesMu sync.Mutex
|
|
pluginFiles map[string]pluginFileGrant
|
|
|
|
// Computer-use VM ownership & held console inputs (computer_use_host.go, computer_use_held.go).
|
|
ownedMu sync.Mutex
|
|
computerUseOwnedVMs map[string]map[string]bool
|
|
computerUseCloneMu sync.Mutex
|
|
heldMu sync.Mutex
|
|
computerUseHeld map[string]map[string]*heldInputs
|
|
|
|
// Plugin elevation requests (elevate_flow.go).
|
|
elevatePromptMu sync.Mutex
|
|
elevateMu sync.Mutex
|
|
elevatePending map[string]chan bool
|
|
elevateSeq uint64
|
|
elevateEmit func(ElevationPrompt)
|
|
elevateDismiss func(string)
|
|
elevateRunner elevationRunner
|
|
}
|
|
|
|
func (h *HostAPIService) ResetPluginFiles() {
|
|
h.filesMu.Lock()
|
|
h.pluginFiles = make(map[string]pluginFileGrant)
|
|
h.filesMu.Unlock()
|
|
}
|
|
|
|
func (a *App) hostAPISvc() *HostAPIService {
|
|
a.mu.Lock()
|
|
if a.hostAPI.app == nil {
|
|
a.hostAPI.app = a
|
|
}
|
|
svc := &a.hostAPI
|
|
a.mu.Unlock()
|
|
return svc
|
|
}
|