fix: disable unsolicited background UI automation
This commit is contained in:
@@ -6,8 +6,8 @@ namespace WxAgent.Host;
|
||||
|
||||
public sealed class WindowsAgentBackend(AccountBindingStore bindings, ServiceOptions options) : IAgentBackend, IAgentEventSource
|
||||
{
|
||||
private const bool ListenerEventsEnabled = true;
|
||||
private readonly bool validationOperationsEnabled = options.EnableValidationOperations;
|
||||
private readonly bool listenerEventsEnabled = options.EnableListenerEvents;
|
||||
private readonly SemaphoreSlim bindingGate = new(1, 1);
|
||||
|
||||
public IReadOnlyList<AgentCapability> Capabilities =>
|
||||
@@ -28,8 +28,8 @@ public sealed class WindowsAgentBackend(AccountBindingStore bindings, ServiceOpt
|
||||
new("db-messages", true, false, false, false, false, "read", false, 30, "Database key/account query acceptance is pending.", ["Requires explicit verified account key scope."], "4.1.13.65"),
|
||||
new("db-merged", true, false, false, false, false, "read", false, 30, "Database key/account query acceptance is pending.", ["Requires explicit verified account key scope."], "4.1.13.65"),
|
||||
new("group-members", true, true, true, false, false, "read", false, 30, null, ["docs/validation/WebUI-MCP-single-client-2026-09-19.md"], "4.1.13.65"),
|
||||
new("listener-events", true, ListenerEventsEnabled, ListenerEventsEnabled, true, false, "read", false, 30,
|
||||
ListenerEventsEnabled ? null : "Listener events are reserved for controlled validation.", ["docs/validation/WebUI-MCP-single-client-2026-09-19.md"], "4.1.13.65"),
|
||||
new("listener-events", true, listenerEventsEnabled, listenerEventsEnabled, true, false, "read", false, 30,
|
||||
listenerEventsEnabled ? null : "Background UI listener is disabled; enable it explicitly in the Tray settings window.", ["docs/validation/WebUI-MCP-single-client-2026-09-19.md"], "4.1.13.65"),
|
||||
new("send-text", true, true, validationOperationsEnabled, true, true, "write", true, 30,
|
||||
validationOperationsEnabled ? null : "Validation operations are disabled for this service session.", ["docs/validation/WebUI-MCP-single-client-2026-09-19.md"], "4.1.13.65"),
|
||||
new("broadcast-text", true, true, validationOperationsEnabled, true, true, "write", true, 300,
|
||||
@@ -42,6 +42,12 @@ public sealed class WindowsAgentBackend(AccountBindingStore bindings, ServiceOpt
|
||||
|
||||
public async IAsyncEnumerable<AgentEvent> ListenAsync([System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
if (!listenerEventsEnabled)
|
||||
{
|
||||
await Task.Delay(Timeout.InfiniteTimeSpan, cancellationToken);
|
||||
yield break;
|
||||
}
|
||||
|
||||
var active = bindings.ReadAll();
|
||||
if (active.Count != 1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user