feat(plugin): scope MCP connections and add held input, region capture and force stop

- Each plugin connect connection gets a session id that is forwarded with
  channel/<id>/message; when the connection ends the host notifies the
  sidecar with channel/<id>/closed so it can cancel calls and release input.
- host/console.screenshot crops a region from the full-resolution frame,
  optionally measured in a reference image size, and full frames now honor
  max_width up to 2560.
- host/console.key can hold or release one key, and host/console.release
  lifts keys and pointer buttons in one call. Driver consoles stay press-only.
- host/vm.shutdown accepts force, and host/vm.snapshot.list needs only vm:read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NwflowerandClaude Opus 5.5 committed 2026-12-04 23:55:43 -07:00
1 parent 95236d624c
commit bd4e85af1a
13 files changed
+499 -45

No files matched your search

+19 -3
View File
@@ -143,9 +143,21 @@ func (m *Manager) NotifySidecar(pluginID, method string, params any) {
}
}
// ChannelSessionClosed tells pluginID's running Sidecar that one client
// connection to channelID has ended, so it can cancel that connection's calls
// and release anything it still holds. It never wakes an idle Sidecar.
func (m *Manager) ChannelSessionClosed(pluginID, channelID, session string) {
if m == nil || session == "" || strings.TrimSpace(channelID) == "" {
return
}
m.NotifySidecar(pluginID, "channel/"+channelID+"/closed", map[string]string{"session": session})
}
// ChannelMessage forwards one JSON line to a declared, active Sidecar channel.
// Channel payloads are never written to the host audit log.
func (m *Manager) ChannelMessage(ctx context.Context, pluginID, channelID string, message json.RawMessage) (json.RawMessage, error) {
// session identifies the client connection, so a Sidecar can scope request ids
// and cancellation per connection. Channel payloads are never written to the
// host audit log.
func (m *Manager) ChannelMessage(ctx context.Context, pluginID, channelID, session string, message json.RawMessage) (json.RawMessage, error) {
if m == nil || m.registry == nil {
return nil, errors.New("plugin manager is unavailable")
}
@@ -181,7 +193,11 @@ func (m *Manager) ChannelMessage(ctx context.Context, pluginID, channelID string
var response struct {
Message json.RawMessage `json:"message"`
}
err := supervisor.Call(ctx, "channel/"+channelID+"/message", map[string]json.RawMessage{"message": message}, &response)
params := map[string]any{"message": message}
if session != "" {
params["session"] = session
}
err := supervisor.Call(ctx, "channel/"+channelID+"/message", params, &response)
if err != nil {
return nil, err
}