mxc icon indicating copy to clipboard operation
mxc copied to clipboard

Cross SDK public API surface alignment for creating containers

Open bbonaby opened this issue 2 months ago • 4 comments

Description of the task

Right now we have the following matrix of API support:

Capability Rust .NET Node
One-shot request model SandboxRequest
SandboxPolicy
SandboxRequest
SandboxPolicy
ContainerConfig
Run to completion run() Run()
RunAsync()
spawnSandboxAsync()
Native streaming spawn_sandbox() Spawn() SpawnSandbox / SpawnSandboxFromConfig – uses executables and not the mxc_ffi foundation that was added to the node sdk and returns either a Node ChildProcess or IPty interface
State-aware lifecycle run_state_aware_json() ProvisionSandbox()
StartSandbox()
StopSandbox()
DeprovisionSandbox()
provisionSandbox()
startSandbox()
stopSandbox()
deprovisionSandbox()
State-aware streaming exec exec_sandbox() ExecInSandbox()
ExecInSandboxAsync()
execInSandbox()
execInSandboxAsync()
Attached state-aware exec exec_attached() ExecInSandboxAttached() Missing

What we want at the completion of this issue

All node rust SDKs should use in proc mxc_ffi shared library for their api calls. Node is now set up to use the mxc_ffi layer however, the public facing APIs need to be updated to call into them rather than the mxc executables. NOTE: rust can stay synchronous for v1 while the other SDKs can have their both synchronous and *Async functions.

Capability Rust .NET Node
One-shot request model SandboxRequestV1 SandboxRequestV1 SandboxRequestV1
Run to completion run() Run()
RunAsync()
Run()
RunAsync()
Native streaming spawn() Spawn() Spawn()
State-aware lifecycle provision_sandbox()
start_sandbox()
stop_sandbox()
deprovision_sandbox()
ProvisionSandbox()
StartSandbox()
StopSandbox()
DeprovisionSandbox()
provisionSandbox()
startSandbox()
stopSandbox()
deprovisionSandbox()
State-aware streaming exec exec_in_sandbox() ExecInSandbox()
ExecInSandboxAsync()
execInSandbox()
execInSandboxAsync()
Attached state-aware exec exec_in_attached() ExecInSandboxAttached() execInSandboxAttached()

Additional context

No response

bbonaby avatar Sep 25 '26 18:09 bbonaby

Let's not do the attached variant

jsidewhite avatar Sep 25 '26 19:09 jsidewhite

We need some solution for customers like OpenClaw who want to run their sandboxed command(s) in a fully interactive terminal with a text user interface. Simply handling the stdio pipes back isn't enough. I'm open to options that remove exec_attached, but that's the variant that wires up this interactivity on top of the pty support for isolation sessions.

adpa-ms avatar Sep 29 '26 16:09 adpa-ms

@jsidewhite to confirm, when you say "Let's not do the attached variant" you mean, simply not to have a separate public API, but to instead collapse its functionality into the current ExecInSandbox API right? Simply adding a function parameter to that API that gets the attach behavior. So, in this case it's not removing this functionality we're just removing the need to expose a separate API for it.

bbonaby avatar Sep 30 '26 16:09 bbonaby

Decision: ExecInAttach to move to private surface of the SDK and we will expose a flag in the current ExecInSandbox API to allow this behavior instead of having the separate API.

EDIT: Moving attach to private for now and going the pseudo terminal route. Callers can then access stdio, and resize options for the returned PTY

bbonaby avatar Sep 30 '26 22:09 bbonaby