Skip to content

feat(mxc): stream workload output for foreground sandbox create on Windows - #6032

Open
nv-rahool wants to merge 4 commits into
ai-openshell:windowsfrom
nv-rahool:feat/6031-windows-foreground-create-streaming/nv-rahool
Open

nv-rahool wants to merge 4 commits into
ai-openshell:windowsfrom
nv-rahool:feat/6031-windows-foreground-create-streaming/nv-rahool

Conversation

@nv-rahool

Copy link
Copy Markdown

Summary

Lets a foreground openshell sandbox create -- <command> without a terminal work on Windows with the MXC driver: the workload's stdout and stderr reach the CLI's own streams, and the CLI returns the workload's exit code. It reuses the openshell-main attachment over the in-process SSH server added in #5859, and fills four gaps that kept it from working.

Related Issue

Closes #6031

Changes

  • Driver admission (driver.rs): reject a foreground request only when it also asks for a terminal (await_main_process_attachment && tty), still before provisioning, with a message pointing to --no-tty or --detach. --detach is unchanged.
  • Supervisor gate (supervisor/lib.rs): allow a foreground main process when the SSH adapter is present instead of refusing on non-Unix.
  • ProxyCommand quoting (forward.rs, CLI ssh.rs): quote each argument for the Windows command-line parser on Windows. build_proxy_command used POSIX single quotes, so ssh.exe could not start openshell ssh-proxy (CreateProcessW error 2) and the CLI waited forever. POSIX behavior is unchanged.
  • Windows SSH server (supervisor-process/ssh.rs): pass the main session to run_ssh_server instead of None (otherwise every openshell-main request answered "no main session is available"), and send the full 32-bit exit status with exit_code_to_wire instead of code.max(0), so a crash code such as 0xC0000005 is not reported as success.
  • Docs: WINDOWS.md, docs/how-it-works/gateways/configuration.mdx, the MXC driver README and skills/openshell-cli/SKILL.md no longer say foreground attach needs --detach.

Example, from the issue:

openshell sandbox create -- cmd /c "echo step1 & timeout 2 >nul & echo oops 1>&2 & exit 7"

step1 appears on stdout, oops on stderr, the CLI returns and %ERRORLEVEL% is 7.

Testing

  • Checks appropriate to the affected code and behavior pass
  • Unit tests added/updated (if applicable)
  • E2E tests added/updated (if applicable)
Host: Windows build 28020.3382, x64, wxc-exec 1.0.0+7bf21024 (ProcessContainer)
Commands (mise run --skip-tools): windows:test:x64, windows:test:unsupported:x64;
  cargo test --lib on openshell-core, -driver-mxc, -cli, -supervisor-process, -supervisor;
  cargo clippy on those crates; windows:build:x64
Result: windows:test:x64 6787 passed, 0 failed, 43 skipped; unsupported-driver lane passed;
  clippy has no warnings in the changed lines. Linux: cargo test for forward:: (68) and cli ssh:: (75) pass.
Manual: foreground create with the CLI's stdout/stderr redirected to files returned exit code 7 in
  1.4 to 3.3 s with out-1 on stdout and err-1 on stderr; output was visible while a 16 s run was still going.
Not run: ARM64; windows:test:mxc-real:x64 and windows:e2e:mxc fail identically on unmodified
  d875be6b on this host (two network/HTTPS real tests panic; e2e "gateway did not start within 30 s"),
  so they give no signal here; windows:lint:x64 fails in files this change does not touch
  (large_futures in openshell-server, unused_async in openshell-extension-core); Ctrl-C behavior.

New tests: a driver admission matrix (--tty rejected with no state created; non-TTY foreground and --detach admitted) and Windows command-line quoting cases, including a case where an argument contains &.

Known limitations

  • On unmodified windows d875be6, output can be lost or the exit status can go missing on bursty or long runs. For example, openshell sandbox exec of a workload that prints 400 alternating stdout/stderr lines returns about 170 per stream. The supervisor SSH server sent everything in that case, so the loss is later on the relay path. This change does not alter that path.
  • Windows ssh.exe (Win32-OpenSSH 9.5) does not exit after writing to a pipe, so scripts should redirect the CLI's output to files. Noted in WINDOWS.md.
  • --tty for the main process is still rejected.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

Signed-off-by: Rahool Paliwal <rpaliwal@nvidia.com>
Signed-off-by: Rahool Paliwal <rpaliwal@nvidia.com>
Signed-off-by: Rahool Paliwal <rpaliwal@nvidia.com>
Signed-off-by: Rahool Paliwal <rpaliwal@nvidia.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant