Repository navigation
Add MXC Sandbox example to Windows Node - #298
MythiliMur wants to merge 1 commit into
Conversation
Add MXC sandbox example debug action and readable output
There was a problem hiding this comment.
Pull request overview
Adds an MXC SDK “simple sandbox” example to this repo and wires it into the Tray app’s Debug page so developers can run it and view a more readable result payload.
Changes:
- Add a Node-based MXC sandbox example script that prints a JSON payload with sandbox stdout/stderr.
- Add a DebugPage action that locates Node + the script, executes it with a timeout, and renders parsed/sanitized output in a dialog.
- Introduce npm dependency metadata (
package.json/package-lock.json) for@microsoft/mxc-sdk.
Show a summary per file
| File | Description |
|---|---|
| tools/mxc/simple-sandbox-example.cjs | New Node script that runs a sandboxed command via MXC and prints a JSON payload. |
| src/OpenClaw.Tray.WinUI/Pages/DebugPage.xaml.cs | Adds MXC invoke action, process execution helper, payload parsing, and dialog rendering. |
| src/OpenClaw.Tray.WinUI/Pages/DebugPage.xaml | Adds a button to run the MXC sandbox example from the Debug Actions section. |
| package.json | Adds npm dependency on @microsoft/mxc-sdk. |
| package-lock.json | Locks @microsoft/mxc-sdk and transitive dependencies. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/5 changed files
- Comments generated: 5
| using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); | ||
| cts.CancelAfter(TimeSpan.FromMilliseconds(timeoutMs)); | ||
|
|
||
| using var process = new Process { StartInfo = psi }; | ||
| process.Start(); | ||
|
|
||
| var stdoutTask = process.StandardOutput.ReadToEndAsync(cts.Token); | ||
| var stderrTask = process.StandardError.ReadToEndAsync(cts.Token); | ||
|
|
||
| await process.WaitForExitAsync(cts.Token); | ||
|
|
| Environment.CurrentDirectory, | ||
| AppContext.BaseDirectory, | ||
| Path.GetDirectoryName(typeof(DebugPage).Assembly.Location) ?? string.Empty, | ||
| }; | ||
|
|
||
| foreach (var root in probeRoots) | ||
| { | ||
| if (string.IsNullOrWhiteSpace(root)) | ||
| { | ||
| continue; | ||
| } | ||
|
|
| <Button Content="🧪 Run MXC Sandbox Example" Click="OnInvokeNodeCapabilityViaMxc" | ||
| HorizontalAlignment="Stretch"/> |
| }; | ||
|
|
||
| process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`); | ||
| process.exit(result.exitCode === 0 ? 0 : 1); |
| @@ -0,0 +1,5 @@ | |||
| { | |||
| "dependencies": { | |||
|
Thanks for putting this MXC example together. Since this PR was opened, #319 has landed a production MXC/AppContainer implementation for I don't think this PR should be merged as-is now because:
Closing as superseded by #319. If we still want a sample, the better follow-up would be a small docs/dev-only example that calls the production |
|
Closing as superseded by #319's production MXC sandbox implementation. |
Add MXC sandbox example debug action and readable output