Skip to content

Commit c2e3617

Browse files
committed
feat(node): project truthful capability readiness
1 parent fe81645 commit c2e3617

20 files changed

Lines changed: 755 additions & 13 deletions

‎docs/ARCHITECTURE.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ These are the canonical homes. Do not reintroduce private copies elsewhere.
7373
| Hub navigation tags, page mapping, command catalog/search, and gateway-page classification | `HubPageRegistry` | authoritative |
7474
| Hub notification banner severity and action projection | `AppNotificationInfoBarPresenter` | authoritative |
7575
| Tray-menu semantic composition and connection-toggle state | `TrayMenuPresenter` + `ConnectionTogglePresenter` | authoritative |
76-
| Capability UI metadata | `NodeCapabilityUiCatalog` (planned) | planned |
76+
| Capability state projection for camera, browser proxy, and system.run | `CapabilityTruthProjection` fed by `NodeCapabilityTruthSource` | authoritative |
7777
| Capability registration/gating | `NodeCapabilityRegistrationPolicy` (planned) | planned |
7878
| Local MCP exposure policy | `McpCapabilityPolicy` (planned) | planned |
7979
| Gateway connect envelope | `ConnectEnvelopeBuilder` (planned) | planned |
@@ -141,6 +141,7 @@ leading and trailing pipe. Columns, in order:
141141
| connection-page-direct-connect-closed | closed | src/OpenClaw.Tray.WinUI/Pages/ConnectionPage.xaml.cs | direct-connect registry, identity-token, settings, rollback, terminal-wait, and runtime-tunnel transaction | GatewayDirectConnectService | add-form control reads, input validation, result text, and post-success visual refresh only | the page delegates one request; rollback restores the durable registry before identity and settings, reconnects a previously live gateway, and a later credential writer wins | GatewayDirectConnectServiceTests.Connect_Failure_RestoresPreviousLiveConnection | behavioral | when the Connection page no longer contains any direct-connect persistence or rollback logic |
142142
| connection-status-direct-connect-closed | closed | src/OpenClaw.Tray.WinUI/Windows/ConnectionStatusWindow.xaml.cs | direct-connect registry, settings, rollback, terminal-wait, and runtime-tunnel transaction | GatewayDirectConnectService | diagnostics control reads, input validation, and result text only | diagnostics direct connect delegates one request and cannot report success before a terminal manager state | AppRefactorContractTests.StatusWindowDirectConnect_WaitsForManagerStateBeforeReportingConnected | source-shape | when the status window no longer contains direct-connect persistence or rollback logic |
143143
| app-window-manager | planned | src/OpenClaw.Tray.WinUI/App.xaml.cs | window creation/show/hide/shutdown | IWindowManager | composition/delegation only | startup/shutdown ordering deterministic; disposed once | none | review-only | extracted in Phase 3 |
144+
| capability-truth-projection | authoritative | NodeService, Command Center, and app.connection diagnostics | independent interpretations of settings, Windows permission, declaration, approval, and runtime readiness | CapabilityTruthProjection fed by NodeCapabilityTruthSource | existing owners continue to produce facts; projection owns no lifecycle or persistence | camera, browser proxy, and system.run report one fail-closed state to Command Center and local MCP without duplicating GatewayConnectionManager lifecycle | CapabilityTruthProjectionTests.Project_PendingGatewayDeclaration_IsNotReportedReady | behavioral | - |
144145
| app-tray-controller | planned | src/OpenClaw.Tray.WinUI/App.xaml.cs | tray icon/menu/action routing | ITrayController | composition/delegation only | tray actions route unchanged | none | review-only | extracted in Phase 3 |
145146
| app-activation-router | planned | src/OpenClaw.Tray.WinUI/App.xaml.cs | deep-link/toast/single-instance activation | IActivationRouter | composition/delegation only | activation routes land on the same UI/actions; current-user pipe security preserved | none | review-only | extracted in Phase 3 |
146147
| native-tool-projector | authoritative | src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs | pure native tool identity, allowlisted display arguments, payload extraction, and flattened-history detection/classification/summary | NativeToolProjector | provider calls the projector while retaining stateful live/history application and metadata cache behavior | unknown identities remain truthful Tool; title aliases are strict; display arguments are allowlisted, redacted, and bounded; live/history projection stays consistent | NativeToolProjectorTests.ExtractToolIdentity_TitleRequiresExactTrustedAlias | behavioral | - |

‎docs/MCP_MODE.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ The implementation is structured so that **adding a new node capability automati
2525

2626
## Architecture
2727

28+
`app.connection.status` exposes an agent-facing `capabilities` projection for
29+
camera, browser proxy, and system.run. It keeps local MCP exposure distinct
30+
from the Gateway's effective declaration and reports Settings, Windows
31+
permission, approval, and runtime readiness without moving connection
32+
lifecycle out of `GatewayConnectionManager`.
33+
2834
### Single capability registry, two transports
2935

3036
![Single capability registry, two transports](diagrams/mcp-mode-dual-transport.svg)

‎docs/WINDOWS_NODE_TESTING.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Every new Windows node call must be exposed through local MCP and `winnode`: reg
6262
- If the gateway omits a safe pending request ID, verify the copy action emits `openclaw nodes pending`, labels it as discovery only, and does not offer reconnect-after-approval yet
6363
- Approve the request explicitly, reconnect the node, and verify the effective capability/command counts update and the pending reapproval warning clears
6464
- Use "Copy fix" only for safe repair commands; privacy-sensitive commands remain informational unless you explicitly opt in on the gateway
65+
- Copy **Capability diagnostics** and verify camera, browser proxy, and system.run each report Settings, Windows permission, Gateway declaration, approval, local MCP exposure, runtime readiness, an overall state, and a repair path. The same entries must appear in `app.connection.status`.
6566

6667
## What Requires Gateway Support
6768

‎src/OpenClaw.SetupEngine/WindowsNodeContextSection.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static class WindowsNodeContextSection
88
public const string Payload = """
99
This WSL gateway may be paired with the OpenClaw Windows tray node. For Windows desktop, Windows files, screenshots, camera, notifications, browser proxy, or Windows commands, use the `nodes` tool (`status` / `describe`) and target the Windows node instead of assuming the WSL shell can do it.
1010
11-
For Windows shell work, use `exec host=node` / `system.run`; normal gateway exec runs in WSL. If Windows node commands fail, ask the user to check the tray Permissions page: Node mode, System run (or the requested capability), and Exec policy. If settings changed or capabilities look stale, ask the user to reconnect/restart the Windows node or gateway.
11+
For Windows shell work, use `exec host=node` / `system.run`; normal gateway exec runs in WSL. Before claiming that camera, browser proxy, or system.run is unavailable, inspect the Windows Hub capability state with local MCP `app.connection.status` when available. Its `capabilities` entries distinguish the Settings toggle, Windows permission, Gateway declaration, pairing/approval, local MCP exposure, and runtime readiness, and provide the repair path. If the local MCP diagnostic is unavailable, ask the user to copy Capability diagnostics from Windows Hub Command Center. Do not infer camera permission from the Settings toggle alone.
1212
""";
1313

1414
public static string ManagedBlock => $"{BeginMarker}\n{Payload.TrimEnd()}\n{EndMarker}";
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text.Json.Serialization;
5+
6+
namespace OpenClaw.Shared;
7+
8+
/// <summary>
9+
/// Pure, transport-neutral projection of the facts that determine whether an
10+
/// agent can use a Windows-node capability. The owners of settings, Windows
11+
/// permissions, gateway lifecycle, approval, and runtime probes remain
12+
/// unchanged; this type only makes their combined result inspectable.
13+
/// </summary>
14+
public static class CapabilityTruthProjection
15+
{
16+
/// <summary>
17+
/// The declaration gate shared with the projection. Runtime and approval
18+
/// facts may block usability, but they never override an explicit local
19+
/// Settings opt-out by advertising the command anyway.
20+
/// </summary>
21+
public static bool ShouldDeclare(bool settingsEnabled) => settingsEnabled;
22+
23+
public enum WindowsPermissionKind
24+
{
25+
NotRequired,
26+
Unknown,
27+
Allowed,
28+
Denied,
29+
}
30+
31+
public enum ApprovalKind
32+
{
33+
NotConnected,
34+
Unknown,
35+
Approved,
36+
Pending,
37+
Rejected,
38+
}
39+
40+
public enum RuntimeKind
41+
{
42+
Unknown,
43+
Ready,
44+
Blocked,
45+
}
46+
47+
public sealed record Input(
48+
string Id,
49+
string DisplayName,
50+
IReadOnlyList<string> Commands,
51+
bool SettingsEnabled,
52+
WindowsPermissionKind WindowsPermission,
53+
bool GatewaySessionLive,
54+
ApprovalKind Approval,
55+
IReadOnlyCollection<string> EffectiveCommands,
56+
IReadOnlyCollection<string> PendingCommands,
57+
IReadOnlyDictionary<string, bool> GatewayPermissions,
58+
bool LocalMcpExposed,
59+
RuntimeKind Runtime,
60+
string? RuntimeDetail = null,
61+
string? RuntimeRepair = null);
62+
63+
public sealed record State(
64+
[property: JsonPropertyName("id")] string Id,
65+
[property: JsonPropertyName("displayName")] string DisplayName,
66+
[property: JsonPropertyName("commands")] IReadOnlyList<string> Commands,
67+
[property: JsonPropertyName("settingsEnabled")] bool SettingsEnabled,
68+
[property: JsonPropertyName("windowsPermission")] string WindowsPermission,
69+
[property: JsonPropertyName("gatewayDeclaration")] string GatewayDeclaration,
70+
[property: JsonPropertyName("approval")] string Approval,
71+
[property: JsonPropertyName("gatewayPathState")] string GatewayPathState,
72+
[property: JsonPropertyName("gatewayRepair")] string GatewayRepair,
73+
[property: JsonPropertyName("localMcpExposed")] bool LocalMcpExposed,
74+
[property: JsonPropertyName("runtimeReadiness")] string RuntimeReadiness,
75+
[property: JsonPropertyName("overallState")] string OverallState,
76+
[property: JsonPropertyName("summary")] string Summary,
77+
[property: JsonPropertyName("repair")] string Repair);
78+
79+
public static State Project(Input input)
80+
{
81+
ArgumentNullException.ThrowIfNull(input);
82+
83+
var gatewayEffective = input.GatewaySessionLive && input.Commands.All(command =>
84+
input.EffectiveCommands.Contains(command, StringComparer.OrdinalIgnoreCase));
85+
var pending = input.Commands.Any(command =>
86+
input.PendingCommands.Contains(command, StringComparer.OrdinalIgnoreCase));
87+
var gatewayPermissionBlocked = input.Commands.Any(command =>
88+
CommandCenterDiagnostics.TryGetCommandPermission(input.GatewayPermissions, command, out var allowed) && !allowed);
89+
90+
var declaration = gatewayEffective
91+
? "effective"
92+
: pending
93+
? "pending-approval"
94+
: !input.GatewaySessionLive
95+
? "not-connected"
96+
: "not-declared";
97+
98+
if (!input.SettingsEnabled)
99+
{
100+
return Build(input, declaration, "disabled",
101+
$"{input.DisplayName} is disabled in Windows Hub Settings.",
102+
$"Enable {input.DisplayName} on the Permissions page, save, and reconnect the Windows node.");
103+
}
104+
105+
if (input.WindowsPermission == WindowsPermissionKind.Denied)
106+
{
107+
return Build(input, declaration, "blocked",
108+
$"{input.DisplayName} is enabled, but Windows permission is denied.",
109+
input.RuntimeRepair ?? "Open Windows privacy settings, grant the required desktop-app permission, and retry.");
110+
}
111+
112+
if (input.Runtime == RuntimeKind.Blocked)
113+
{
114+
return Build(input, declaration, "blocked",
115+
input.RuntimeDetail ?? $"{input.DisplayName} is not runtime-ready.",
116+
input.RuntimeRepair ?? "Repair the runtime prerequisite and retry.");
117+
}
118+
119+
if (input.LocalMcpExposed)
120+
{
121+
var runtime = input.Runtime == RuntimeKind.Unknown ? "unchecked" : "ready";
122+
var summary = input.RuntimeDetail ??
123+
$"{input.DisplayName} is available through local MCP independently of the Gateway declaration.";
124+
var repair = input.Runtime == RuntimeKind.Unknown
125+
? input.RuntimeRepair ?? "Invoke a read-only or safe command to verify the Windows runtime prerequisite."
126+
: "No repair is required.";
127+
return Build(input, declaration, "ready", summary, repair, runtime);
128+
}
129+
130+
if (!gatewayEffective && (pending || input.Approval == ApprovalKind.Rejected))
131+
{
132+
return Build(input, declaration, "pending-approval",
133+
$"{input.DisplayName} is waiting for gateway node command approval.",
134+
"Approve the pending Windows node declaration on the Gateway, then reconnect the node.");
135+
}
136+
137+
if (gatewayPermissionBlocked)
138+
{
139+
return Build(input, declaration, "blocked",
140+
$"{input.DisplayName} is declared, but the Gateway policy blocks one or more commands.",
141+
"Review gateway.nodes allow/deny policy for the listed commands, approve the change, and reconnect the node.");
142+
}
143+
144+
if (gatewayEffective)
145+
{
146+
var runtime = input.Runtime == RuntimeKind.Unknown ? "unchecked" : "ready";
147+
var summary = input.RuntimeDetail ??
148+
$"{input.DisplayName} is effective for the connected Gateway node.";
149+
var repair = input.Runtime == RuntimeKind.Unknown
150+
? input.RuntimeRepair ?? "Invoke a read-only or safe command to verify the Windows runtime prerequisite."
151+
: "No repair is required.";
152+
return Build(input, declaration, "ready", summary, repair, runtime);
153+
}
154+
155+
if (input.GatewaySessionLive)
156+
{
157+
return Build(input, declaration, "blocked",
158+
$"{input.DisplayName} is enabled locally but is not in the Gateway's effective Windows node declaration.",
159+
"Reconnect the Windows node. If the declaration changed, approve the pending command set on the Gateway.");
160+
}
161+
162+
return Build(input, declaration, "unavailable",
163+
$"{input.DisplayName} is enabled, but neither local MCP nor a Gateway declaration currently exposes it.",
164+
"Enable Local MCP Server or connect and approve the Windows node, then retry.");
165+
}
166+
167+
private static State Build(
168+
Input input,
169+
string declaration,
170+
string overall,
171+
string summary,
172+
string repair,
173+
string? runtime = null)
174+
{
175+
var gatewayEffective = input.GatewaySessionLive && input.Commands.All(command =>
176+
input.EffectiveCommands.Contains(command, StringComparer.OrdinalIgnoreCase));
177+
var pending = input.Commands.Any(command =>
178+
input.PendingCommands.Contains(command, StringComparer.OrdinalIgnoreCase));
179+
var gatewayPermissionBlocked = input.Commands.Any(command =>
180+
CommandCenterDiagnostics.TryGetCommandPermission(input.GatewayPermissions, command, out var allowed) && !allowed);
181+
var gatewayPathState = !input.GatewaySessionLive
182+
? pending ? "pending-approval" : "not-connected"
183+
: gatewayPermissionBlocked
184+
? "blocked"
185+
: gatewayEffective
186+
? "ready"
187+
: pending
188+
? "pending-approval"
189+
: "not-declared";
190+
var gatewayRepair = gatewayPathState switch
191+
{
192+
"ready" when pending => "The current declaration remains effective. Approve the pending Windows node changes, then reconnect to activate them.",
193+
"ready" => "No Gateway repair is required.",
194+
"blocked" => "Review gateway.nodes allow/deny policy for the listed commands, approve the change, and reconnect the node.",
195+
"pending-approval" => "Approve the pending Windows node declaration on the Gateway, then reconnect the node.",
196+
"not-declared" => "Reconnect the Windows node. If the declaration changed, approve the pending command set on the Gateway.",
197+
_ => "Connect the Windows node to inspect its Gateway declaration."
198+
};
199+
200+
return new(
201+
input.Id,
202+
input.DisplayName,
203+
input.Commands,
204+
input.SettingsEnabled,
205+
ToKebabCase(input.WindowsPermission.ToString()),
206+
declaration,
207+
ToKebabCase(input.Approval.ToString()),
208+
gatewayPathState,
209+
gatewayRepair,
210+
input.LocalMcpExposed,
211+
runtime ?? ToKebabCase(input.Runtime.ToString()),
212+
overall,
213+
summary,
214+
repair);
215+
}
216+
217+
private static string ToKebabCase(string value) =>
218+
string.Concat(value.Select((character, index) =>
219+
index > 0 && char.IsUpper(character) ? $"-{char.ToLowerInvariant(character)}" : char.ToLowerInvariant(character).ToString()));
220+
}

‎src/OpenClaw.Shared/Mcp/McpToolBridge.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ private object HandleToolsList()
386386
["app.chat.queue.cancel"] =
387387
"Cancel/remove one native chat outgoing queue entry before it is sent. Args: queuedMessageId (string, required), threadId/sessionKey (string, required; use the threadId returned by app.chat.queue.list or app.chat.snapshot). Only Queued/Failed entries can be removed; Sending entries may already have reached the gateway. Returns { canceled, threadId, queuedMessageId, remainingCount, error? }.",
388388
["app.connection.status"] =
389-
"READ-ONLY local MCP connection diagnostics. No args. Returns effective mode/state, active gateway metadata, operator/node credential resolution, MCP runtime state, browser proxy caveat, pending approval actions, retry hints, and recent diagnostic events.",
389+
"READ-ONLY local MCP connection and capability diagnostics. No args. Returns effective mode/state, active gateway metadata, operator/node credential resolution, MCP runtime state, capability truth for camera/browser proxy/system.run, browser proxy caveat, pending approval actions, retry hints, and recent diagnostic events.",
390390
["app.connection.gateways"] =
391391
"READ-ONLY saved gateway diagnostics. No args. Returns { activeGatewayId, count, gateways[] } with per-gateway id/name/url, active flag, lastConnected, credential presence booleans, SSH/browser-proxy configuration, and no token values.",
392392
["app.connection.applySetupCode"] =

‎src/OpenClaw.Shared/Models.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,7 @@ public class GatewayCommandCenterState
10781078
public GatewaySelfInfo? GatewaySelf { get; set; }
10791079
public List<PortDiagnosticInfo> PortDiagnostics { get; set; } = new();
10801080
public List<PermissionDiagnosticInfo> Permissions { get; set; } = new();
1081+
public List<CapabilityTruthProjection.State> CapabilityStates { get; set; } = new();
10811082
public List<ChannelCommandCenterInfo> Channels { get; set; } = new();
10821083
public List<SessionInfo> Sessions { get; set; } = new();
10831084
public GatewayUsageInfo? Usage { get; set; }

0 commit comments

Comments
 (0)