mxc icon indicating copy to clipboard operation
mxc copied to clipboard

Expose inherit console option on SDK

Open AndreaVielCGN opened this issue 1 month ago • 3 comments

Description of the new feature / enhancement

I'm building a Windows CLI tool that launches interactive programs inside a ProcessContainer (BaseContainer / PSEC 1.1) and gives them the user's terminal, such as Claude Code or Powershell.

The SDK can spawn new programs but connects to them using a pipe while I want to inherit the original console. The possibility is there at https://github.com/microsoft/mxc/blob/2c1a874e7bac6faa32376a335a8db8dcba7d6079/src/mxc-sdk/src/core/mxc_common/sandbox_process.rs#L550 but it's not exposed by the SDK.

My current workaround is to write the JSON config file and call wxc-exec.exe extracted from the npm package, and launch wxc-exec.exe --config <file> with inherited stdio. I use the SDK only for Probe() and disable telemetry. This depends on the wxc-exec.exe CLI and on the npm package layout, neither of which is a documented API.

PS: writing down the JSON also permits me to set fallback.allowDaclMutation: false to avoid using the ProcessContainer fallback by mistake.

Proposed technical implementation details

Add a new Spawn method or an option to the existing ones.

AndreaVielCGN avatar Oct 21 '26 09:10 AndreaVielCGN

Hi @AndreaVielCGN, thanks for the suggestion. We currently don't have plans to expose the inheritConsole option through the SDK.

If we see broader community demand and compelling use cases for exposing this functionality, we can reconsider it in the future.

Separately, we plan to remove the current fallback behavior in the next release of MXC. Going forward, Windows builds that do not meet the minimum supported version will return a not-supported error rather than falling back to the previous behavior. You can find the minimum supported Windows versions in our OS version support documentation

bbonaby avatar Oct 23 '26 03:10 bbonaby

Hi @bbonaby, thanks for the response.

My usecase is to be able to sandbox arbitrary programs. If the program is batch-like it can be done, but if it's something interactive with deep console integration like Claude or PowerShell it cannot be work without an inherited shell. I got it to work and it's quite nice to be able to run anything without worrying about it making arbitrary changes to my PC. I used it even with untrusted program. I think with the new ProcessContainers for the first time we have a nice and easy sandboxing solution that doesn't require VMs, DACLs, or heavy setup.

The wxc-exec.exe I use to workaround the limitation will remain in some form or will it also be removed in the future?

AndreaVielCGN avatar Oct 23 '26 07:10 AndreaVielCGN

Adding another use case for this, since you mentioned community demand.

We build an open-source coding agent harness in Rust. The harness already owns a ConPTY for its terminal, and each command the agent runs must go into a ProcessContainer with the user's filesystem and network policy. Interactive tools such as shells, git prompts and test runners only behave correctly with an inherited console.

We use mxc-sdk = 1.0.1 on Windows 11 26200.9457 at Medium integrity. BaseContainerRunner with StdioMode::Inherit works well for us: input, resize, output and exit status are preserved while the policy is enforced. The public v1::spawn_with_pty rejects processcontainer, though, and v1::spawn uses pipes. That leaves us depending on doc-hidden runner types, pinned to an exact version with a canary test.

We'd use a supported processcontainer spawn option that:

  • inherits the caller's standard handles or console, without allocating its own ConPTY;
  • takes the policy as input and reports the containment actually realized;
  • refuses explicitly when native PSEC is unavailable. That matches your plan to drop the fallback.

We can provide a small safe-Rust reproduction if that helps.

JimmyMederos avatar Nov 01 '26 00:11 JimmyMederos