You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 86fa840
Browse filesBrowse the repository at this point in the historyBrowse files
| ui-dispatcher | authoritative | src/OpenClaw.Tray.WinUI/App.xaml.cs | UI-thread marshaling abstraction for presentation code | IUiDispatcher | App and existing WinUI code may call DispatcherQueue directly until the view-model migration | presentation view models depend on IUiDispatcher not a concrete DispatcherQueue | UiDispatcherContractTests.PageViewModel_ReceivesRegisteredDispatcher | behavioral | - |
123
+
| navigation-scope | authoritative | src/OpenClaw.Tray.WinUI/Windows/HubWindow.xaml.cs | page view-model activation/deactivation and disposal lifetime | NavigationScopeManager | HubWindow keeps frame navigation back-stack and rail selection | transient page view models are activated on navigation and deactivated then disposed on navigate-away | NavigationScopeManagerTests.NavigatingAway_DeactivatesAndDisposesPreviousViewModel | behavioral | - |
124
+
| composition-root | authoritative | src/OpenClaw.Tray.WinUI/App.xaml.cs | presentation-layer service construction and wiring | AppServiceRegistration | App remains the composition root and owns non-DI service lifetimes | one validated root ServiceProvider; App-owned singletons registered as instances are never disposed by the container | AppServiceRegistrationTests.Dispose_DoesNotDisposeAppOwnedInstanceSingletons | behavioral | - |
**OpenClaw.Shared** owns the low-level gateway clients (`OpenClawGatewayClient`, `WindowsNodeClient`, `WebSocketClientBase`), device identity/signing (`DeviceIdentity`), protocol models, and the `IOperatorGatewayClient` interface.
18
18
19
+
`WindowsNodeClient` also owns gateway invocation lifetime at the transport
20
+
boundary. Active invokes are registered by invoke ID in a focused cancellation
21
+
registry, linked to the node connection lifetime, and cancelled individually by
22
+
the gateway `node.invoke.cancel` event. Active invocations atomically transition
23
+
to cancelled or completed when capability execution returns; whichever
24
+
transition wins determines the protocol outcome. Capability implementations
25
+
remain responsible for cooperative cancellation of their own underlying work.
26
+
19
27
**OpenClaw.Connection** owns all connection management: `GatewayConnectionManager`, `GatewayRegistry`, `CredentialResolver`, `ConnectionStateMachine`, `NodeConnector`, `SshTunnelService/Manager`, `SetupCodeDecoder`, and all connection interfaces/DTOs/enums. This project has zero WinUI dependencies and is independently testable.
20
28
21
29
**OpenClaw.Tray.WinUI** consumes the connection layer through interfaces. It never creates gateway clients directly — `GatewayConnectionManager` owns that entirely.
Copy file name to clipboardExpand all lines: docs/MCP_MODE.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,9 +66,37 @@ The capability list lives on `NodeService`, *not* on `WindowsNodeClient`. That s
66
66
-`tools/list` — flattens `_capabilities` into MCP tools. Tool name = command name (`"screen.snapshot"`); known commands get curated descriptions from `McpToolBridge.CommandDescriptions`; unknown commands fall back to `"{category} capability: {command}"`. `inputSchema` is permissive.
67
67
-`tools/call` — finds the capability via `INodeCapability.CanHandle(name)`, builds a `NodeInvokeRequest` (the same struct the gateway path uses), calls `ExecuteAsync`, wraps the result as MCP `content[].text`. Tool failures come back as `result.isError = true`, not JSON-RPC errors (per MCP spec — JSON-RPC errors are reserved for protocol issues).
-`notifications/cancelled` — cancels the active request whose JSON-RPC ID is
70
+
supplied as `params.requestId`. A cancelled `tools/call` completes with an MCP
71
+
tool error containing `cancelled`. If concurrent HTTP scheduling processes
72
+
cancellation just before an already-sent call registers, the notification
73
+
records a pending cancellation for five seconds. The first matching
74
+
registration atomically consumes that tombstone and returns `cancelled` before
75
+
capability execution begins, so correctness does not depend on scheduler
76
+
timing. Repeated notifications for the same pending ID do not extend its
77
+
original five-second lifetime. Pending cancellations and recent-completion
78
+
guards are each capped at 1,024 entries;
79
+
expired entries are pruned first and the oldest remaining entry is evicted at
80
+
capacity. Because JSON-RPC IDs are client-scoped but this stateless HTTP
81
+
transport has no client identity, duplicate active IDs are allowed and
82
+
cancellation is ignored when more than one active call matches; this prevents
83
+
one local client from cancelling another client when the collision is already
84
+
observable. Request matching uses the decoded JSON string value or normalized
85
+
arbitrary-precision JSON number value, while preserving the distinction
86
+
between string and numeric IDs. A tombstone cannot predict a later
87
+
cross-client ID collision, so it cancels the first matching registration;
88
+
complete isolation would require client identity in the transport. A recent
89
+
completion guard also prevents a late notification from poisoning immediate
90
+
ID reuse.
69
91
70
92
The bridge takes a `Func<IReadOnlyList<INodeCapability>>` rather than a snapshot. Every `tools/list` re-reads the live list. This is what guarantees zero-cost capability addition — register a new capability after server start and it appears on the next `tools/list`.
71
93
94
+
Cancellation is cooperative and uses the same `CancellationToken` capability
95
+
contract as the gateway transport. Screen and camera operations propagate the
96
+
token through recording consent/countdown, camera admission, capture waits, and
97
+
recording shutdown. The HTTP request deadline remains a separate safety bound;
98
+
no command-specific transport deadlines are applied.
99
+
72
100
### HTTP transport
73
101
74
102
`OpenClaw.Shared/Mcp/McpHttpServer.cs` is `System.Net.HttpListener` bound to `http://127.0.0.1:8765/`. Loopback-only by construction; not reachable from any other machine even with firewall holes. A defensive `IPAddress.IsLoopback` check on each request acts as belt-and-suspenders.
Copy file name to clipboardExpand all lines: docs/SETUP_ENGINE_REDESIGN.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,8 @@ src/OpenClaw.SetupEngine.UI/
80
80
## Config File (`default-config.json`)
81
81
82
82
**Config is required.** Neither the headless exe nor the UI will run without one. The bundled `default-config.json` is auto-loaded from `AppContext.BaseDirectory` if no `--config` is specified.
83
+
If the setup UI cannot find, read, or deserialize the selected configuration,
84
+
it opens on the setup failure page with the load error and does not start setup.
Common flags include `--config`, `--headless`, `--dry-run`, `--rollback-on-failure`, `--no-rollback-on-failure`, `--log-path`, `--gateway-port`, and uninstall safety flags such as `--uninstall` plus `--confirm-destructive`.
321
323
324
+
SetupEngine option names are case-insensitive. Value options accept either separated
325
+
syntax (`--config custom.json`) or equals syntax (`--config=custom.json`). Unknown
326
+
options, bare `--`, and positional arguments are rejected with exit code 2.
327
+
Boolean flags do not accept values, and duplicate value options are rejected;
328
+
duplicate bare flags remain idempotent.
329
+
330
+
Duplicate value rejection is an intentional compatibility break from the legacy
331
+
first-value-wins behavior. Scripts that repeat a value option must remove the
332
+
duplicate before upgrading.
333
+
334
+
The same parser enforces the tray-hosted setup window's narrower command-line
335
+
contract: `--config` and `--no-rollback-on-failure`. The tray projects recognized
336
+
restart and deep-link host arguments out first. A restart PID must be a positive
337
+
integer other than the current process, and the post-setup launch target must be
338
+
`chat`; malformed host values remain for strict rejection. All remaining unknown options,
339
+
positionals, missing values, and duplicates render the setup failure page before
340
+
the setup lock is acquired. The tray executable's uninstall arguments are parsed
341
+
by `CliUninstallHandler` and currently use separated syntax for values such as
342
+
`--json-output <path>`.
343
+
322
344
Exit codes: 0 = success, 1 = pipeline failure, 2 = bad arguments or setup lock/safety failure, 3 = cancelled
Do not run `systemctl --user` as `root`; that checks root's user service manager, not the gateway's service.
96
96
97
+
## Inspect an optional Tailscale Serve endpoint
98
+
99
+
When the setup review enabled **Tailnet access with Tailscale Serve**, the generated distro runs its own Tailscale daemon. The Windows Companion intentionally uses the generated `wss://<node>.<tailnet>.ts.net` endpoint; it does not silently fall back to localhost.
100
+
101
+
Windows must also have Tailscale installed and signed in to the same tailnet. These checks do not print credentials:
102
+
103
+
```powershell
104
+
# Windows Companion side: confirm this PC is connected to Tailscale.
105
+
& "$env:ProgramFiles\Tailscale\tailscale.exe" status --json
106
+
107
+
# WSL side: confirm the daemon is connected and has a MagicDNS name.
108
+
wsl.exe -d OpenClawGateway --user root -- tailscale status --json
109
+
110
+
# Confirm Serve routes tailnet HTTPS to the loopback OpenClaw gateway port.
111
+
# Tailscale lifecycle and Serve are intentionally owned by root, not openclaw.
112
+
wsl.exe -d OpenClawGateway --user root -- /usr/bin/tailscale serve status --json
113
+
114
+
# Funnel is unsupported. This must show no public route.
115
+
wsl.exe -d OpenClawGateway --user root -- /usr/bin/tailscale funnel status --json
116
+
117
+
# Check the OpenClaw gateway itself; it remains loopback-bound inside WSL.
The generated WSL distro is Ubuntu 24.04 (noble). Tailscale Serve setup requires that exact generated distro and rejects another `BaseDistro` before replacing an existing gateway. Setup installs Tailscale from its signed stable APT repository rather than executing the mutable `install.sh` bootstrap script as root.
122
+
123
+
Tailscale Serve preserves Companion token and device authentication by default (`gateway.auth.allowTailscale=false`). Setup runs `tailscale up`, Serve, reset, logout, and daemon management as root; the `openclaw` account is never made a Tailscale operator. Tailscale's LocalAPI permits read-only operations, such as identity lookup, to local unprivileged clients while reserving mutation for root or an explicitly configured operator. In the setup review, **Trust Tailscale identities for gateway authentication** is an explicit opt-in; when enabled, verified Tailscale identity headers and tailnet ACLs become part of the gateway access-control boundary. Token and device credentials remain available for Companion pairing and compatibility. Do not enable Funnel for this generated gateway: this workflow supports private tailnet Serve only.
124
+
97
125
## Use root instead of sudo
98
126
99
127
There is no interactive sudo password prompt. Open a root shell only when you intentionally need to inspect or change protected files:
<TextBlockText="Tailnet access with Tailscale Serve"Style="{StaticResource BodyStrongTextBlockStyle}" />
118
+
<TextBlockTextWrapping="Wrap"Style="{StaticResource CaptionTextBlockStyle}"Foreground="{ThemeResource TextFillColorSecondaryBrush}"Text="Publish this private gateway as HTTPS/WSS to your Tailscale tailnet. Windows Tailscale must already be signed in; setup root owns Serve." />
<TextBlockx:Name="TailscaleStatusText"Text="Check Windows Tailscale before continuing."Style="{StaticResource CaptionTextBlockStyle}"Foreground="{ThemeResource TextFillColorSecondaryBrush}"TextWrapping="Wrap" />
<ToggleSwitchx:Name="TailscaleTrustAuthToggle"Header="Trust Tailscale identities for gateway authentication"OnContent="Enabled"OffContent="Disabled"Toggled="TailscaleTrustAuthToggle_Toggled" />
130
+
<TextBlockTextWrapping="Wrap"Style="{StaticResource CaptionTextBlockStyle}"Foreground="{ThemeResource TextFillColorSecondaryBrush}"Text="Off by default. Enable only when your Tailscale ACLs should be part of the gateway access-control boundary; OpenClaw receives only a restricted identity lookup, not Tailscale operator control." />
0 commit comments