Repository navigation
MXC AppContainer sandboxing for system.run + Sandbox settings page - #319
Merged
Merged
Conversation
Adds MxcCommandRunner that routes system.run through MXC AppContainer via the existing SystemCapability.SetCommandRunner seam. Sandbox is binary on/off (no host fallback when enabled and MXC unavailable: invocation is denied). Three new fields in SettingsData / SettingsManager: SystemRunSandboxEnabled, SystemRunAllowOutbound, SystemRunAllowLocalNetwork. UI toggles added to the Debug page. Backed by 17 unit tests plus 3 real-MXC integration tests.
New top-level Sandbox page with per-folder access (Documents/Downloads/Desktop + custom folder picker), clipboard mode (None/Read/Write/Both), timeout slider, max output cap, and a master enable toggle. Tight by default: nothing exposed beyond what was already in Slice 1; user can opt-in to looser posture with consequences shown inline. Toggles previously on the Debug page moved here. Settings: 7 new fields (SandboxClipboard, SandboxDocumentsAccess, SandboxDownloadsAccess, SandboxDesktopAccess, SandboxCustomFolders, SandboxTimeoutMs, SandboxMaxOutputBytes). MxcPolicyBuilder.ForSystemRun consumes them. 7 new unit tests for the policy mappings (all 1432 shared tests green; 466 tray tests green). Co-authored-by: Copilot <[email protected]>
Mythili's PR #298 introduced the original package.json/package-lock.json when it added the MXC sample. We rebased our work directly onto origin/master (skipping Mythili's commit since her PR isn't merged yet); this restores the npm dep declaration that tools/mxc/run-command.cjs consumes. Co-authored-by: Copilot <[email protected]>
Fixes from a rubber-duck pass on the Sandbox page: 1. Fail-closed when MXC missing: BuildSystemRunRunner used to return LocalCommandRunner directly when no MXC backend was found, so the master sandbox toggle was silently ignored. Now always wraps in MxcCommandRunner backed by an UnavailableSandboxExecutor that denies invocations while sandbox is enabled (matches the user-stated "no host fallback" promise). 2. Timeout slider now actually caps execution. MxcCommandRunner picks the smaller of the agent-supplied timeout and the user-configured sandbox cap (policy.TimeoutMs) and passes that to the executor. 3. Max output dropdown now actually takes effect. SandboxExecutionRequest carries MaxOutputBytes per-call; run-command.cjs honors req.maxOutputBytes (was hardcoded 4MB). HARD_MAX_OUTPUT_BYTES safety ceiling at 256 MiB on the Node side. 4. Downloads folder uses SHGetKnownFolderPath(FOLDERID_Downloads) instead of %USERPROFILE%\Downloads so redirected/OneDrive layouts work. 5. LAN toggle removed from the Sandbox page. The underlying privateNetworkClientServer AppContainer capability is not validated by the MXC team (only internetClient is). The setting field stays for forward compat but the policy builder forces it false. New tests: CombineTimeouts theory, max-output wiring, policy-cap wiring, UnavailableSandboxExecutor denial. Shared: 1500 passed; tray: 914 passed. Co-authored-by: Copilot <[email protected]>
The NodeConnector owns the WindowsNodeClient lifecycle and creates a fresh
client on every (re)connect. The connect-handshake serializes
_registration.Capabilities/Commands into the outbound "connect" message —
but those lists were never populated because nothing wired NodeService's
capability list into the client.
Result: every reconnect shipped an empty caps array and the gateway
recorded the node as having no advertised commands. The agent couldn't
invoke anything on the Windows node. Capabilities only worked when the
first-run setup flow ran NodeService.ConnectAsync (which uses its own
internal WindowsNodeClient), and that orphaned a node entry on the
gateway each time.
Fix:
- INodeConnector exposes a ClientCreated event raised right after
construction, BEFORE the outbound connect handshake.
- NodeConnector.ConnectAsync fires it.
- NodeService.AttachClient adopts the supplied client and registers all
capability objects on it. Handles both first-time (RegisterCapabilities
builds the list) and reconnect (iterates existing _capabilities).
- App.xaml.cs wires the bridge: nodeConnector.ClientCreated invokes
nodeService.AttachClient.
- App startup now pre-constructs NodeService when EnableNodeMode (or
EnableMcpServer) is true, so it's available before the first connect.
Verified end-to-end:
- Tray launches → operator + node handshake
- Log: "Registered capability: app/system/canvas/screen/camera/location/
device/browser" + "AttachClient: re-registered 8 capabilities on new
client"
- openclaw nodes status shows the connected node with caps and commands
populated — agent can now invoke them.
Tests: 1500 shared, 914 tray — all green. ScriptedNodeConnector test stub
implements the new event (no-op for tests that don't exercise the bridge).
Co-authored-by: Copilot <[email protected]>
User-facing redesign of the Sandbox page based on rubber-duck feedback:
- Unified page header (icon + title + subtext + master toggle) instead of
separate title block + status banner. Title text is itself state-driven:
"Sandbox is on" / "Sandbox is off -- high risk" / "Sandbox unavailable".
- Security level section (3 preset cards: Locked Down / Balanced /
Permissive). Cards are taller, larger type. Active preset gets an accent
border that survives hover/pressed (per-state ButtonBackground* and
ButtonBorderBrush* resources overridden so the default grey hover doesn't
fight the accent). Presets touch the fixed-set fields only; custom
folders are preserved across preset clicks.
- Scope callout under the header explicitly names what this page does
and doesn't control (Windows agent commands yes; WSL gateway tools,
chat-pasted files, manual terminals no). Addresses real confusion the
user hit with gateway-side dir_list bypassing this page entirely.
- Section order is now Files -> Clipboard -> Network -> Limits (highest
privacy-risk first).
- Sub-sections and presets dim (Opacity 0.45 + IsHitTestVisible false)
when sandbox is off or MXC unavailable, so users can't tweak settings
that won't apply.
- Confirmation ContentDialog before turning sandbox OFF, with explicit
risk language. Cancel reverts the toggle.
- Custom folder access is now editable per row (Blocked / Read only /
Read & write) instead of remove + re-add. Selecting Blocked drops the
grant. CustomFolderRow gains an AccessIndex + InitialSelectionFired
flag so the ComboBox's materialization-fired SelectionChanged event
doesn't trigger a phantom save.
- After applying a preset with custom folder grants still active, an
InfoBar appears noting that those grants persist (extra-loud copy for
Locked Down -- users may think they're fully locked down when they
aren't).
- MXC-unavailable state shows a prominent Error InfoBar with a
categorized fix action:
- Windows build/UBR too old -> "Open Windows Update"
(ms-settings:windowsupdate)
- wxc-exec.exe or run-command.cjs missing -> "Show install
instructions" -> github.com/microsoft/mxc
Plus a "Learn more about MXC sandboxing" hyperlink in all variants.
- Tightened wording throughout: drop "isolation_session" jargon from
primary copy, generalize "Allow internet" subtitle, call out
exfiltration risk in Balanced preset description, disambiguate
clipboard Write ("can replace your clipboard, cannot read it"),
clarify the maximum-captured-output limit, surface that custom grants
are additive on top of fixed-folder rules.
Co-authored-by: Copilot <[email protected]>
…ecycle) Hanselman dual-model review (claude-opus-4.6 + gpt-5.2-codex) surfaced 15 issues across the MXC integration. This commit fixes the trivial ones plus the small/contained ones; the two design-level findings (locked-down-leaky from SDK's getAvailableToolsPolicy adding C:\, and unavailable-toggle-off routing) are tracked separately. Security / policy correctness: - Browser profile roots (Edge, Chrome, Firefox, Brave) added to deniedPaths in MxcPolicyBuilder. UI claimed these were "always blocked" but only ~/.ssh and the OpenClaw settings dir were actually denied. - Defense-in-depth: deny-list now wins over allow-list in the policy we hand to the SDK. Any custom folder grant equal to or nested inside a denied path is stripped before the policy is sent. Removes reliance on the SDK's (undocumented, alpha) deny-precedence behavior. - New unit tests cover: browser-profile denies present by default, custom grant at a denied path is filtered, custom grant nested in a denied path is filtered, normal custom grants still flow through. Bridge hardening (tools/mxc/run-command.cjs): - Move startTime declaration above the missing-command guard so an empty command no longer hits TDZ and returns NaN/ReferenceError. - timedOut is now set when child exit + elapsed >= sdkTimeoutMs (was always false, so SDK-level timeouts looked like generic failures). - Switch PowerShell variants to -EncodedCommand (UTF-16LE Base64) so the agent-supplied command can't leak shell metacharacters into the outer cmdline parser. Cmd path wraps in cmd.exe /S /C "..." with proper escape. Executor lifecycle (OneShotAppContainerExecutor): - Drop the maxOutputBytes constructor parameter. The previous Math.Max with a baked floor meant a user lowering SandboxMaxOutputBytes after the executor was built would keep the older larger cap. Now everything is per-request, defaulting to DefaultMaxOutputBytes when null. - Cancellation now ALWAYS kills the spawned process tree, whether the source is the caller's CancellationToken or the local timeout. Previously only the timeout path called KillProcessTree, so caller cancel left node + the sandboxed payload running until they exited on their own. - Envelope cap doubled to accommodate worst-case stdout + stderr (each was capped at maxOutputBytes on the bridge side, but the C# reader budget was only maxOutputBytes + 256 KiB total — large stderr could truncate the JSON envelope). - Set StandardInputEncoding = UTF-8 so non-ASCII command/env/cwd survive the C# -> node JSON handoff. Fail-closed widened (MxcCommandRunner): - Previously only SandboxUnavailableException was caught. Any other exception (JSON parse, IO error, bridge crash) propagated, potentially crashing the node loop. Now broad catch returns a CommandResult with ExitCode -1 and the error surfaced in stderr; OperationCanceledException still propagates. Availability + UI: - MxcAvailability.HasAnyBackend now requires IsWxcExecResolvable. Without wxc-exec the executor refuses to run, so reporting "available" was a lie. - SandboxPage now caches MxcAvailability for the lifetime of the page instance instead of calling Probe() on every UI update (registry + file walks). - ContentDialog re-entry guard: rapid double-toggle of the master sandbox switch could otherwise stack ShowAsync calls -> COMException crash. Settings cleanup: - Remove the SystemRunAllowLocalNetwork setting. It was read but hardcoded to false in the policy builder (MXC team confirmed only internetClient is validated today) -- the field was a silent no-op that confused users reading the JSON. Old settings.json files with the field are still loaded fine; JsonSerializer ignores unknown properties. - NodeService.SnapshotSettings now deep-copies each SandboxCustomFolder. The class is mutable so the previous shallow list copy shared references, opening a narrow TOCTOU window where a UI thread mutation of Access could show up mid-policy-build on the command-execution thread. Test rename: - SystemRun_DeniesAccessToSettingsDirectory was a smoke test, not a deny assertion. Renamed to SystemRun_PipelineSmokeTest_WithDenyPaths_ReturnsResult so the name matches what the test actually does. Test body unchanged. Not fixed in this commit (tracked separately): - locked-down-leaky: @microsoft/mxc-sdk's getAvailableToolsPolicy adds the drive root (C:\) and PSReadLine history to every policy when pwsh is on PATH. Combined with %TEMP% being added wholesale, "Locked Down" can still read most of the user's data on a typical dev box. Fix requires deciding whether to stop merging the tools/temp policy entirely or curate it. Needs a design discussion. - unavailable-toggle-off: when MXC is unavailable AND the user toggle is OFF, MxcCommandRunner currently routes to the host runner anyway. UI says "blocked"; behavior is "runs unsandboxed". Fix requires deciding whether the unavailable state should override the toggle. Tests: 1478 shared + 914 tray green. Co-authored-by: Copilot <[email protected]>
Closes the unavailable-toggle-off hole flagged by the Hanselman review. The Sandbox page already hid the master toggle when MXC was unavailable and the header said "agent commands are blocked", but the routing logic in MxcCommandRunner.RunAsync still honored a persisted toggle=OFF and routed to host. That was the UI lying about what was happening. Change: - MxcCommandRunner takes a new isSandboxAvailable Func<bool> provider. When it returns false, RunAsync short-circuits to a deny CommandResult BEFORE checking the toggle. The toggle is now only meaningful when MXC is available. - NodeService.BuildSystemRunRunner passes () => availability.HasAnyBackend so the runner sees the same availability the UI sees. - The UnavailableSandboxExecutor that NodeService wires when MXC is missing becomes dead code on the hot path -- MxcCommandRunner now blocks earlier. Kept for defense-in-depth in case future callers construct an MxcCommandRunner without the availability check. UI: - SandboxPage reverted to the 3-state header (was briefly experimented with as a 4-state matrix). MXC unavailable hides the toggle entirely and says "Sandbox unavailable -- commands blocked" with the existing error InfoBar + fix actions. There is no way for the user to opt out of the block on an unsupported machine -- they must fix MXC. - Confirmation dialog reverted to a single flavor (the "running unsandboxed" variant is unreachable now). Tests: - New: RunAsync_MxcUnavailable_BlocksEvenWithSandboxToggleOff -- the exact regression the Hanselman review caught. - New: RunAsync_MxcUnavailable_BlocksEvenWithSandboxToggleOn -- the short-circuit fires before the executor path. - Existing tests updated to pass () => true (MXC available) for the new ctor arg. Tests: 1480 shared + 914 tray green. Co-authored-by: Copilot <[email protected]>
…-8 BOM fix The @microsoft/mxc-sdk's getAvailableToolsPolicy adds the drive root (C:\) as readonly to every policy when pwsh.exe is on PATH, and getTemporaryFilesPolicy adds the user's full %TEMP% as readwrite. That bypasses the user's explicit choices in the Sandbox UI — Locked Down "no standard user folders" was technically false because the agent could read the entire drive. Same problem for Balanced and Permissive: the UI lists specific folders, the policy gave away much more. This commit scopes the merged policy in tools/mxc/run-command.cjs: - After mergePolicy(req.policy, tools, temp), filter readonlyPaths to drop any drive root (C:\, D:\, etc.) and filter readwritePaths to drop the user's real %TEMP% / %TMP% / os.tmpdir(). - Create a per-invocation scratch directory with fs.mkdtempSync(openclaw-mxc- prefix). Add it as the only readwrite path replacing %TEMP%. Override TEMP/TMP/TMPDIR in the spawned process's env so commands that write to %TEMP% land in our scratch dir. Clean up the scratch dir in a finally block after the child exits (best-effort — if the user's command spawned a detached process still using the dir, the OS reaps it eventually). - PATH-specific tool dirs (git, node, python locations) stay in the policy unchanged — those are needed for command discovery. - PSReadLine history dir stays — single small file, lets interactive PowerShell work normally. The UI's promises (Locked Down: "no standard user folders. Commands can still use a temporary workspace.") now match actual behavior. Encoding fix: - Set StandardInputEncoding to ew UTF8Encoding(false) instead of Encoding.UTF8. The default UTF8 encoding emits a BOM, which JSON.parse on the Node side chokes on. This broke EVERY integration test since commit 43dfd1c (where the stdin encoding fix was first applied). Found because OPENCLAW_RUN_INTEGRATION=1 surfaced the bridge unhandled-error: "Unexpected token '\\ufeff' is not valid JSON". Tests: all 1505 shared + 914 tray pass. Integration tests (SystemRun_EchoCmd_ExecutesInsideAppContainer, SystemRun_PowerShell_ ReturnsStdout, SystemRun_PipelineSmokeTest_WithDenyPaths_ReturnsResult) verified end-to-end with real AppContainer + scoped policy. Co-authored-by: Copilot <[email protected]>
…che TTL, tests) Hanselman pass #2 surfaced two blockers and three quality items. All fixed. Blockers: - Argument quoting parity with LocalCommandRunner. The bridge previously always-quoted every arg, which broke PowerShell parameter binding: a switch like `-Name` was passed as the literal string `'-Name'` so `Get-ChildItem -Name` failed to bind. And the cmd.exe path applied `.replace(/"/g, '""')` to the whole concatenated command line AFTER quoteArg had already doubled quotes, producing quadruple `""""` sequences cmd parsed as garbage. Fix: port ShellQuoting.NeedsQuoting to JS (same metacharacter set as the C# side) so only args that need quoting get quoted, and drop the outer .replace in the cmd path — /S /C strips exactly the first and last " of the operand so the inner content (already quoteArg-escaped) goes through verbatim. - JS bridge deny-filter bypass. The C# MxcPolicyBuilder.FilterOutDenied strips any allow-list entry equal to or nested inside a denied path, protecting ~/.ssh, OpenClaw settings, and browser profile roots. But the JS bridge's mergePolicy then injects @microsoft/mxc-sdk's tools policy (PSReadLine history readwrite, %LOCALAPPDATA% readonly parents in some configs) without re-applying that filter. Custom grants could therefore overlap with denied paths via SDK additions. Fix: port FilterOutDenied to JS as filterOutDenied(allowed, denied) and apply it after mergePolicy, before passing to createConfigFromPolicy. Same semantics as the C# side: case-insensitive, normalize with path.resolve, exact-match OR prefix-with-separator. Quality items: - MxcAvailabilityTests.Probe_Result_IsConsistent asserted the OLD HasAnyBackend formula (just OR of the two backend flags), but HasAnyBackend was tightened in commit 43dfd1c to also require IsWxcExecResolvable AND RunCommandScriptPath != null. The test would pass when both new conjuncts happened to be true on the test host, giving false confidence. Updated assertion to match the current property. - Added two missing tests: * RunAsync_SandboxUnavailableException_InvalidatesAvailabilityCache — verifies the new invalidate-availability callback is invoked when the executor throws SandboxUnavailableException. * RunAsync_GenericException_ReturnsDeny_DoesNotPropagate — covers the generic catch in MxcCommandRunner.RunAsync added in 43dfd1c. Without a test, a future refactor could remove the catch and let a bridge crash escape the node loop. * RunAsync_OperationCanceled_Propagates — verifies the ONE exception type that escapes the catch-all does in fact propagate. - Stale availability cache. NodeService._mxcAvailability was cached once and never re-probed, so if MXC components were uninstalled mid-session (or wxc-exec.exe moved on disk) the runner would happily route to a sandbox that no longer exists. Fix: MxcCommandRunner now takes an Action? invalidateAvailability callback. On SandboxUnavailableException, it invokes the callback. NodeService wires it to `() => _mxcAvailability = null`, so the next command re-probes via `??=`. SandboxPage already constructs a fresh page per navigation so it doesn't need this fix. Deferred (low-severity, documented in tracking): - NormalizePath doesn't resolve junctions/symlinks (defense-in-depth; AppContainer likely enforces deny at the NT object path level). - _mxcAvailability lacks a volatile annotation (benign on x64 CLR; ref reads are atomic). - Scratch dir rmSync can race with forked subprocesses (already best-effort with try/catch, OS reaps %TEMP% eventually). Tests: 1483 shared + 3 integration (real AppContainer + scoped policy) + 914 tray, all green. Co-authored-by: Copilot <[email protected]>
Removed references to "Slice 1 / 7 / 8", "Q-NESTED-APPCONTAINER",
internal review nicknames, and personal chat-thread references from
source comments. These were artifacts of our internal planning doc
and meant nothing to anyone outside the team. The same information
that's still useful (e.g., "isolation_session requires IsolationProxy
in System32", "deny-paths semantics on the alpha SDK are unverified")
is preserved without the planning-deck framing.
No behavior change. Comment-only cleanup across:
- src/OpenClaw.Shared/Mxc/{ISandboxExecutor,MxcAvailability,MxcPolicyBuilder,OneShotAppContainerExecutor}.cs
- src/OpenClaw.Shared/SettingsData.cs
- src/OpenClaw.Tray.WinUI/Services/SettingsManager.cs
- tools/mxc/run-command.cjs
- tests/OpenClaw.Shared.Tests/Mxc/MxcCommandRunnerIntegrationTests.cs
Tests still green: 1483 shared + 914 tray.
Co-authored-by: Copilot <[email protected]>
Pass over the page polish based on a fresh-eyes review.
- Header icon dialed back from 40pt to 32pt — was visually heavier
than the title text it sat next to.
- Scope info folded into the header subtext: "Restricts what
agent-started Windows commands can see. Doesn't cover commands run
inside WSL or files you paste into chat." Removes the separate
blue InfoBar that pushed the cards down.
- Master toggle gains AutomationProperties.Name="Sandbox enabled"
for screen readers.
- Security level card descriptions tightened — dropped editorializing
("Use sparingly", "Long timeouts") and verbose qualifiers; each
card now is a single short fact-line.
- Two "Add folder" buttons collapsed into one. New rows default to
read-only; user changes via the per-row access dropdown that's
already there.
No behavior change beyond the single-add-button consolidation.
Tests: 914 tray pass.
Co-authored-by: Copilot <[email protected]>
These were dev-time artifacts from when the sandbox toggles briefly
lived in DebugPage before being moved to the dedicated Sandbox page.
The comments ("Sandbox toggles moved to SandboxPage", etc.) only made
sense in the context of that internal refactor and are noise to anyone
else reviewing the PR.
Reverts both DebugPage files to origin/master state.
Co-authored-by: Copilot <[email protected]>
bkudiess
marked this pull request as ready for review
May 12, 2026 18:32
Propagate gateway bearer tokens through NodeConnector adoption, tighten denied path overlap filtering, and ship the MXC node bridge dependencies with tray build/publish output. Co-authored-by: Copilot <[email protected]>
Disable MXC sandboxing in the MCP tray integration fixture so hosted CI can continue testing tray/MCP system.run wiring on machines without MXC. Dedicated MXC tests still cover fail-closed behavior. Co-authored-by: Copilot <[email protected]>
7 of 16 tasks
This was referenced Oct 30, 2026
14 of 16 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Adds MXC AppContainer sandboxing for
system.runcommands plus a full user-facing Sandbox settings page in the tray. Agent-invoked Windows shell commands now run inside a@microsoft/mxc-sdkAppContainer with a policy derived from the user's choices in the UI. Fail-closed when MXC isn't available.Also fixes a pre-existing architectural bug where
NodeConnectorcreatedWindowsNodeClientinstances thatNodeServicenever registered capabilities on (the agent saw a connected node with zero capabilities).What's new
Sandbox runtime (
src/OpenClaw.Shared/Mxc/)MxcCommandRunnerplugs into the existingICommandRunnerseam whereLocalCommandRunnerplugged in before. Honors a master toggle in settings.OneShotAppContainerExecutorspawnsnode tools/mxc/run-command.cjsper invocation, which calls@microsoft/mxc-sdk.spawnSandboxFromConfigto run the payload inside an AppContainer.MxcPolicyBuilderis a pure function:SettingsData+ capability →SandboxPolicy. Always denies~/.ssh, OpenClaw's settings folder, and Edge/Chrome/Firefox/Brave profile roots regardless of grants. Strips any allow-list entry equal to or nested inside a denied path so a malicious or mistaken custom-folder grant can't bleed through.MxcAvailability.Probe()checks Windows build/UBR, locateswxc-exec.exe, and locates the bridge script.HasAnyBackendrequires all three to be true.UnavailableSandboxExecutorfail-closes loudly when MXC isn't available;MxcCommandRunnershort-circuits to a deny CommandResult before even reaching the executor whenisSandboxAvailable()returns false, regardless of the persisted toggle state.Bridge (
tools/mxc/run-command.cjs)usePty:falseso stdout/stderr stay separate and exit codes are reliable.C:\grant (added whenpwsh.exeis on PATH) and the SDK's full%TEMP%grant. Replaces with a per-invocationfs.mkdtempSync(...)scratch dir +TEMP/TMP/TMPDIRenv vars rewritten. PATH-specific tool dirs (git, node, python) stay in the policy. Scratch dir torn down infinally.LocalCommandRunner: PowerShell variants use-EncodedCommand(UTF-16LE Base64) so agent-supplied commands can't leak shell metacharacters; cmd usescmd.exe /S /C "..."; per-arg conditional quoting via a portedneedsQuoting(only quote when shell metacharacters are present, so PowerShell parameter binding for switches like-Namekeeps working).Sandbox settings page (
src/OpenClaw.Tray.WinUI/Pages/SandboxPage.xaml(.cs))ms-settings:windowsupdate) for build/UBR issues, "Show install instructions" for missing-component issues. Plus a "Learn more about MXC" hyperlink.NodeService / NodeConnector wiring
INodeConnector.ClientCreatedevent raised afterWindowsNodeClientconstruction but beforeConnectAsync— critical timing, because the handshake serializes registered capabilities.NodeService.AttachClient(WindowsNodeClient)method. First call registers all capabilities; subsequent calls (on reconnect) iterate_capabilitiesand re-register on the new client. Idempotent.App.xaml.cspre-constructsNodeServicebeforeInitializeGatewayClient()so it exists when the firstClientCreatedfires, and subscribesnodeConnector.ClientCreated += (_, client) => _nodeService?.AttachClient(client).Why this approach
The whole PR follows a "tight by default, user can loosen with consequences shown" philosophy. Three principles:
%TEMP%) are stripped because they bypass the user's explicit choices.Test coverage
MxcPolicyBuilderTests— defaults, network honor, browser profile denies, custom-folder-overlapping-denies filtered, custom-folder-nested-inside-denied filtered, normal grants flow through, custom folders + fixed folders coexist, timeout passthrough.MxcCommandRunnerTests— sandbox-on routes through executor, sandbox-off routes to host, MXC-unavailable + toggle-off blocks anyway, MXC-unavailable + toggle-on blocks, success result mapping,SandboxUnavailableExceptionreturns deny,SandboxUnavailableExceptioninvalidates the availability cache, generic exception returns deny (does not propagate),OperationCanceledExceptionpropagates.MxcAvailabilityTests— probe consistency, asserts the fullHasAnyBackendformula.MxcCommandRunnerIntegrationTests(gated byOPENCLAW_RUN_INTEGRATION=1) — real AppContainer end-to-end with cmd, PowerShell, and pipeline-with-deny-paths.Scope
This PR sandboxes
system.run. The underlyingMxcPolicyBuilderis structured per-capability so other capabilities can be added on top with the same model.The page does not control gateway-side WSL tools (
dir_list,file_get, etc.) — those are gateway plugins running outside the Windows companion app. The scope callout in the UI says so explicitly.