Files
Reims-Go/internal/app/host_api_service.go
千川白浪 9006e6d9a7
CI / verify (push) Canceled after 0s
CI / rolling-release (push) Canceled after 0s
refactor: 抽离 HostAPIService 并将 internal/plugin 拆分为四层无环子包 (#202)
2026-12-05 06:05:41 -07:00

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
}